fix(basic.gblib): OPEN keyword fix. Magic number removal.
This commit is contained in:
parent
fe2af84b21
commit
e1c389cbd0
2 changed files with 78 additions and 81 deletions
|
@ -312,9 +312,9 @@ export class GBVMService extends GBService {
|
|||
});
|
||||
}
|
||||
|
||||
private getParams = (text, names) => {
|
||||
private getParams = (text: string, names) => {
|
||||
let ret = {};
|
||||
const splitParamsButIgnoreCommasInDoublequotes = str => {
|
||||
const splitParamsButIgnoreCommasInDoublequotes = (str: string) => {
|
||||
return str.split(',').reduce(
|
||||
(accum, curr) => {
|
||||
if (accum.isConcatting) {
|
||||
|
@ -334,13 +334,13 @@ export class GBVMService extends GBService {
|
|||
const items = splitParamsButIgnoreCommasInDoublequotes(text);
|
||||
|
||||
let i = 0;
|
||||
let json = '{';
|
||||
let json = '';
|
||||
names.forEach(name => {
|
||||
let value = items[i];
|
||||
i++;
|
||||
json = `${json} "${name}": ${value} ${names.length == i ? '' : ','}`;
|
||||
});
|
||||
json = `${json}}`;
|
||||
json = `${json}`;
|
||||
|
||||
return json;
|
||||
};
|
||||
|
@ -403,7 +403,7 @@ export class GBVMService extends GBService {
|
|||
if (!$1.startsWith('"') && !$1.startsWith("'")) {
|
||||
$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`;
|
||||
}
|
||||
|
|
|
@ -479,8 +479,7 @@ export class SystemKeywords {
|
|||
|
||||
await client
|
||||
.api(
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${
|
||||
sheets.value[0].name
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
|
||||
}')/range(address='${address}')`
|
||||
)
|
||||
.patch(body);
|
||||
|
@ -552,8 +551,7 @@ export class SystemKeywords {
|
|||
|
||||
await client
|
||||
.api(
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${
|
||||
sheets.value[0].name
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
|
||||
}')/range(address='A2:DX2')/insert`
|
||||
)
|
||||
.post({});
|
||||
|
@ -575,8 +573,7 @@ export class SystemKeywords {
|
|||
|
||||
await client
|
||||
.api(
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${
|
||||
sheets.value[0].name
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
|
||||
}')/range(address='${address}')`
|
||||
)
|
||||
.patch(body);
|
||||
|
@ -612,8 +609,7 @@ export class SystemKeywords {
|
|||
|
||||
let results = await client
|
||||
.api(
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${
|
||||
sheets.value[0].name
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
|
||||
}')/range(address='${addressOrHeaders}')`
|
||||
)
|
||||
.get();
|
||||
|
@ -762,8 +758,7 @@ export class SystemKeywords {
|
|||
|
||||
results = await client
|
||||
.api(
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${
|
||||
sheets.value[0].name
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
|
||||
}')/range(address='A1:CZ${maxLines}')`
|
||||
)
|
||||
.get();
|
||||
|
@ -1461,7 +1456,10 @@ export class SystemKeywords {
|
|||
public async merge({ pid, file, data, key1, key2 }): Promise<any> {
|
||||
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`;
|
||||
|
||||
// MAX LINES property.
|
||||
|
@ -1477,7 +1475,7 @@ export class SystemKeywords {
|
|||
|
||||
let results;
|
||||
let header, rows;
|
||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(this.min);
|
||||
let { baseUrl, client } = await GBDeployer.internalGetDriveClient(min);
|
||||
|
||||
let document;
|
||||
document = await this.internalGetDocument(client, baseUrl, path, file);
|
||||
|
@ -1488,8 +1486,7 @@ export class SystemKeywords {
|
|||
|
||||
results = await client
|
||||
.api(
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${
|
||||
sheets.value[0].name
|
||||
`${baseUrl}/drive/items/${document.id}/workbook/worksheets('${sheets.value[0].name
|
||||
}')/range(address='A1:CZ${maxLines}')`
|
||||
)
|
||||
.get();
|
||||
|
|
Loading…
Add table
Reference in a new issue