new(basic.gblib): TABLE keyword #375 fixes.
This commit is contained in:
parent
b14ff889b2
commit
5f751cfbe7
4 changed files with 19 additions and 14 deletions
|
@ -177,7 +177,7 @@ export class GBVMService extends GBService {
|
||||||
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
const tablesFile = urlJoin(folder, `${filename}.tables.json`);
|
||||||
if (Fs.existsSync(tablesFile)) {
|
if (Fs.existsSync(tablesFile)) {
|
||||||
const minBoot = GBServer.globals.minBoot;
|
const minBoot = GBServer.globals.minBoot;
|
||||||
GBLogEx.info(min, `BASIC: Reading tables and sync storage for ${min.botId}...`);
|
GBLogEx.info(min, `BASIC: Sync TABLE keywords storage for ${min.botId}...`);
|
||||||
|
|
||||||
const t = JSON.parse(Fs.readFileSync(tablesFile, 'utf8'));
|
const t = JSON.parse(Fs.readFileSync(tablesFile, 'utf8'));
|
||||||
|
|
||||||
|
@ -207,10 +207,10 @@ export class GBVMService extends GBService {
|
||||||
|
|
||||||
minBoot.core.sequelize.define(t.name, t.fields);
|
minBoot.core.sequelize.define(t.name, t.fields);
|
||||||
|
|
||||||
// await minBoot.core.sequelize.sync({
|
await minBoot.core.sequelize.sync({
|
||||||
// alter: true,
|
alter: true,
|
||||||
// force: false // Keep it false due to data loss danger.
|
force: false // Keep it false due to data loss danger.
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsedCode: string = Fs.readFileSync(jsfile, 'utf8');
|
const parsedCode: string = Fs.readFileSync(jsfile, 'utf8');
|
||||||
|
@ -623,7 +623,8 @@ export class GBVMService extends GBService {
|
||||||
const gbotConfig = JSON.parse(min.instance.params);
|
const gbotConfig = JSON.parse(min.instance.params);
|
||||||
let keys = Object.keys(gbotConfig);
|
let keys = Object.keys(gbotConfig);
|
||||||
for (let j = 0; j < keys.length; j++) {
|
for (let j = 0; j < keys.length; j++) {
|
||||||
variables[keys[j]] = gbotConfig[keys[j]];
|
const name = keys[j].replace(/\s/gi, '');
|
||||||
|
variables[name] = gbotConfig[keys[j]];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto-NLP generates BASIC variables related to entities.
|
// Auto-NLP generates BASIC variables related to entities.
|
||||||
|
|
|
@ -343,7 +343,7 @@ export class KeywordsExpressions {
|
||||||
|
|
||||||
return `
|
return `
|
||||||
|
|
||||||
__totalCalls = 10; // TODO: global from Config.
|
__totalCalls = 10;
|
||||||
__next = true;
|
__next = true;
|
||||||
__calls = 0;
|
__calls = 0;
|
||||||
__index = 0;
|
__index = 0;
|
||||||
|
@ -355,7 +355,7 @@ export class KeywordsExpressions {
|
||||||
|
|
||||||
while (__next)
|
while (__next)
|
||||||
{
|
{
|
||||||
let ${$1} = __data[__index];
|
let ${$1} = __data.items[__index];
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -797,9 +797,12 @@ export class KeywordsExpressions {
|
||||||
];
|
];
|
||||||
|
|
||||||
keywords[i++] = [
|
keywords[i++] = [
|
||||||
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*post\s*(.*),\s*(.*)/gim,
|
/^\s*((?:[a-z]+.?)(?:(?:\w+).)(?:\w+)*)\s*=\s*post\s*(.*)/gim,
|
||||||
($0, $1, $2, $3) => {
|
($0, $1, $2, $3) => {
|
||||||
return `${$1} = await sys.postByHttp ({pid: pid, url:${$2}, data:${$3}, headers})`;
|
|
||||||
|
const args = $2.split(',');
|
||||||
|
|
||||||
|
return `${$1} = await sys.postByHttp ({pid: pid, url:${args[0]}, data:${args[1]}, headers})`;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1098,7 +1101,7 @@ export class KeywordsExpressions {
|
||||||
const fieldRegExp = /(?:.*\.)(.*)/gim;
|
const fieldRegExp = /(?:.*\.)(.*)/gim;
|
||||||
let name = fieldRegExp.exec(field)[1]
|
let name = fieldRegExp.exec(field)[1]
|
||||||
|
|
||||||
fieldsNamesOnly.push (name);
|
fieldsNamesOnly.push (`'${name}'`);
|
||||||
});
|
});
|
||||||
let fieldsNames = fieldsNamesOnly.join(',');
|
let fieldsNames = fieldsNamesOnly.join(',');
|
||||||
|
|
||||||
|
|
|
@ -654,7 +654,7 @@ export class SystemKeywords {
|
||||||
* @example SAVE "Billing", columnName1, columnName2
|
* @example SAVE "Billing", columnName1, columnName2
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async saveToStorage({ pid, table, fields, fieldsNames }) {
|
public async saveToStorage({ pid, table, fields, fieldsNames }) : Promise<any> {
|
||||||
|
|
||||||
GBLog.info(`BASIC: Saving '${table}' (SAVE). Values: ${fields.join(',')}.`);
|
GBLog.info(`BASIC: Saving '${table}' (SAVE). Values: ${fields.join(',')}.`);
|
||||||
const minBoot = GBServer.globals.minBoot as any;
|
const minBoot = GBServer.globals.minBoot as any;
|
||||||
|
@ -664,10 +664,10 @@ export class SystemKeywords {
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
fieldsNames.forEach(field => {
|
fieldsNames.forEach(field => {
|
||||||
data[fieldsNames] = fields[index++];
|
field = field.charAt(0).toUpperCase() + field.slice(1);
|
||||||
|
data[field] = fields[index++];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return await definition.create(data);
|
return await definition.create(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,7 @@ export class GBCoreService implements IGBCoreService {
|
||||||
logging: logging as boolean,
|
logging: logging as boolean,
|
||||||
dialect: this.dialect as Dialect,
|
dialect: this.dialect as Dialect,
|
||||||
storage: storage,
|
storage: storage,
|
||||||
|
quoteIdentifiers: false, // set case-insensitive
|
||||||
dialectOptions: {
|
dialectOptions: {
|
||||||
options: {
|
options: {
|
||||||
trustServerCertificate: true,
|
trustServerCertificate: true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue