fix(basic.gblib): OPEN keyword fix. Magic number removal.

This commit is contained in:
Alan 2023-01-26 12:47:37 -03:00
parent fe2af84b21
commit e1c389cbd0
2 changed files with 78 additions and 81 deletions

View file

@ -312,9 +312,9 @@ export class GBVMService extends GBService {
}); });
} }
private getParams = (text, names) => { private getParams = (text: string, names) => {
let ret = {}; let ret = {};
const splitParamsButIgnoreCommasInDoublequotes = str => { const splitParamsButIgnoreCommasInDoublequotes = (str: string) => {
return str.split(',').reduce( return str.split(',').reduce(
(accum, curr) => { (accum, curr) => {
if (accum.isConcatting) { if (accum.isConcatting) {
@ -334,13 +334,13 @@ export class GBVMService extends GBService {
const items = splitParamsButIgnoreCommasInDoublequotes(text); const items = splitParamsButIgnoreCommasInDoublequotes(text);
let i = 0; let i = 0;
let json = '{'; let json = '';
names.forEach(name => { names.forEach(name => {
let value = items[i]; let value = items[i];
i++; i++;
json = `${json} "${name}": ${value} ${names.length == i ? '' : ','}`; json = `${json} "${name}": ${value} ${names.length == i ? '' : ','}`;
}); });
json = `${json}}`; json = `${json}`;
return json; return json;
}; };
@ -403,7 +403,7 @@ export class GBVMService extends GBService {
if (!$1.startsWith('"') && !$1.startsWith("'")) { if (!$1.startsWith('"') && !$1.startsWith("'")) {
$1 = `"${$1}"`; $1 = `"${$1}"`;
} }
const params = this.getParams($1, ['pid', 'url', 'username', 'password']); const params = this.getParams($1, ['url', 'username', 'password']);
return `page = await wa.getPage({pid: pid,${params}})\n`; return `page = await wa.getPage({pid: pid,${params}})\n`;
} }

View file

@ -479,8 +479,7 @@ export class SystemKeywords {
await client await client
.api( .api(
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${ `${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
sheets.value[0].name
}')/range(address='${address}')` }')/range(address='${address}')`
) )
.patch(body); .patch(body);
@ -552,8 +551,7 @@ export class SystemKeywords {
await client await client
.api( .api(
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${ `${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
sheets.value[0].name
}')/range(address='A2:DX2')/insert` }')/range(address='A2:DX2')/insert`
) )
.post({}); .post({});
@ -575,8 +573,7 @@ export class SystemKeywords {
await client await client
.api( .api(
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${ `${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
sheets.value[0].name
}')/range(address='${address}')` }')/range(address='${address}')`
) )
.patch(body); .patch(body);
@ -612,8 +609,7 @@ export class SystemKeywords {
let results = await client let results = await client
.api( .api(
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${ `${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
sheets.value[0].name
}')/range(address='${addressOrHeaders}')` }')/range(address='${addressOrHeaders}')`
) )
.get(); .get();
@ -762,8 +758,7 @@ export class SystemKeywords {
results = await client results = await client
.api( .api(
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${ `${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
sheets.value[0].name
}')/range(address='A1:CZ${maxLines}')` }')/range(address='A1:CZ${maxLines}')`
) )
.get(); .get();
@ -1461,7 +1456,10 @@ export class SystemKeywords {
public async merge({ pid, file, data, key1, key2 }): Promise<any> { public async merge({ pid, file, data, key1, key2 }): Promise<any> {
GBLog.info(`BASIC: MERGE running on ${file} and key1: ${key1}, key2: ${key2}...`); GBLog.info(`BASIC: MERGE running on ${file} and key1: ${key1}, key2: ${key2}...`);
const botId = this.min.instance.botId; const {
min, user
} = await DialogKeywords.getProcessInfo(pid);
const botId = min.instance.botId;
const path = `/${botId}.gbai/${botId}.gbdata`; const path = `/${botId}.gbai/${botId}.gbdata`;
// MAX LINES property. // MAX LINES property.
@ -1477,7 +1475,7 @@ export class SystemKeywords {
let results; let results;
let header, rows; let header, rows;
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(this.min); let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
let document; let document;
document = await this.internalGetDocument(client, baseUrl, path, file); document = await this.internalGetDocument(client, baseUrl, path, file);
@ -1488,8 +1486,7 @@ export class SystemKeywords {
results = await client results = await client
.api( .api(
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${ `${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
sheets.value[0].name
}')/range(address='A1:CZ${maxLines}')` }')/range(address='A1:CZ${maxLines}')`
) )
.get(); .get();