From dbe430c6230a317d8eb1c1dc0ac555110df56688 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Wed, 4 Oct 2023 09:48:54 -0300 Subject: [PATCH] new(basic.gblib): SET PAGED keyword #377. --- .../services/AzureDeployerService.ts | 14 ++-- .../services/KeywordsExpressions.ts | 71 ++++++++++++++++++- src/app.ts | 5 +- 3 files changed, 80 insertions(+), 10 deletions(-) diff --git a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts index dd145f54..3c6f79e4 100644 --- a/packages/azuredeployer.gbapp/services/AzureDeployerService.ts +++ b/packages/azuredeployer.gbapp/services/AzureDeployerService.ts @@ -267,7 +267,7 @@ export class AzureDeployerService implements IGBInstallationDeployer { public async updateBotProxy(botId: string, group: string, endpoint: string) { if (!await this.botExists(botId)) { - GBLog.error(`Bot ${botId} does not exist on cloud.`); + GBLog.error(`Bot ${botId} does not exist on cloud.`); return; } @@ -367,13 +367,13 @@ export class AzureDeployerService implements IGBInstallationDeployer { credentials, subscriptionId); } - + public async deployFarm2( proxyAddress: string, instance: IGBInstance, credentials: any, subscriptionId: string - ){ + ) { const culture = 'en-us'; const token = credentials['tokenCache']._entries[0]; @@ -390,6 +390,7 @@ export class AzureDeployerService implements IGBInstallationDeployer { await this.enableResourceProviders('Microsoft.CognitiveServices'); await this.enableResourceProviders('Microsoft.BotService'); + await this.enableResourceProviders('Microsoft.Search'); await this.enableResourceProviders('Microsoft.Web'); await this.enableResourceProviders('Microsoft.Sql'); @@ -398,12 +399,13 @@ export class AzureDeployerService implements IGBInstallationDeployer { let serverFarm; let serverName; - if (process.env.DEPLOY_WEB){ + + if (process.env.DEPLOY_WEB) { GBLog.info(`Deploying Bot Server...`); serverFarm = await this.createHostingPlan(name, `${name}-server-plan`, instance.cloudLocation); serverName = `${name}-server`; await this.createServer(serverFarm.id, name, serverName, instance.cloudLocation); - }; + } GBLog.info(`Deploying Bot Storage...`); const administratorLogin = `sa${GBAdminService.getRndReadableIdentifier()}`; @@ -492,7 +494,7 @@ export class AzureDeployerService implements IGBInstallationDeployer { // const nlpAppId = await this.createNLPService(name, name, instance.cloudLocation, culture, instance.nlpAuthoringKey); // instance.nlpAppId = nlpAppId; - if (process.env.DEPLOY_WEB){ + if (process.env.DEPLOY_WEB) { GBLog.info('Updating server environment variables...'); await this.updateWebisteConfig(name, serverName, serverFarm.id, instance); } diff --git a/packages/basic.gblib/services/KeywordsExpressions.ts b/packages/basic.gblib/services/KeywordsExpressions.ts index ba770f2e..a6c84aaf 100644 --- a/packages/basic.gblib/services/KeywordsExpressions.ts +++ b/packages/basic.gblib/services/KeywordsExpressions.ts @@ -1,11 +1,11 @@ /*****************************************************************************\ | ( )_ _ | -| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ | +| _ _ _ __ _ _ __ __ __ _ _ | ,_)(_) __ __ _ | | ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' v `\ /'_`\ | | | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__,\| (˅) |( (_) ) | -| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' | +| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(___/(_) (_)`\__/' | | | | ( )_) | | -| (_) \___/' | +| (_) \__/' | | | | General Bots Copyright (c) Pragmatismo.io. All rights reserved. | | Licensed under the AGPL-3.0. | @@ -320,13 +320,78 @@ export class KeywordsExpressions { } ]; + keywords[i++] = [ /^\s*(set hear on)(\s*)(.*)/gim, ($0, $1, $2, $3) => { return `hrOn = ${$3}`; } ]; + + keywords[i++] = [/^\s*for each +(.*to.*)/gim, 'for ($1) {']; + + keywords[i++] = [ + /^\s*FOR EACH\s*(.*)\s*IN\s*(.*)/gim, + ($0, $1, $2) => { + + return ` + __totalCalls = 10; // TODO: global from Config. + __next = true; + __calls = 0; + __index = 0; + + __url = $2.links?.next?.uri; + __seekToken = $2.links?.self?.headers["MS-ContinuationToken"] + __totalCount = $2["totalCount"]; + + while (__next) + { + let $1 = $2[__index]; +`; + } + ]; + + keywords[i++] = [ + /^\s*END FOR\s*/gim, + ($0, $1, $2) => { + + return ` + + // TRUE if all items are processed. + + if (__index >= __totalCount) { + + // Check if HTTP call limit has reached. + + if (__calls < __totalCalls) { + + // Perform GET request using the constructed URL + + $2 = await sys.get ({pid: pid, file: __url, addressOrHeaders: headers, httpUsername, httpPs}); + + // Update current variable handlers. + + __url = $2.links?.next?.uri; + __seekToken = $2.links?.self?.headers["MS-ContinuationToken"] + __totalCount = $2["totalCount"]; + + index = 0; + __calls++; + + } else { + + next = false; + + } + + index = index + 1; + } +`; + } + ]; + + keywords[i++] = [ /^\s*(.*)\=\s*(REWRITE)(\s*)(.*)/gim, ($0, $1, $2, $3, $4) => { diff --git a/src/app.ts b/src/app.ts index 3313ab34..19171f45 100644 --- a/src/app.ts +++ b/src/app.ts @@ -215,8 +215,11 @@ export class GBServer { 'packages/boot.gbot', GBServer.globals.bootInstance ); - await deployer.deployBotFull(instance, GBServer.globals.publicAddress); + instances.push(instance); + GBServer.globals.minBoot + GBServer.globals.bootInstance = instances[0]; + await deployer.deployBotFull(instance, GBServer.globals.publicAddress); // Runs the search even with empty content to create structure.