@budibase/server 1.1.30 → 1.1.32-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/index.3c7a4b19.js +977 -0
- package/builder/assets/{index.192adf4c.css → index.aa03d5f4.css} +2 -2
- package/builder/assets/{vendor.162098da.js → vendor.6bcafa60.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +407 -711
- package/coverage/coverage-final.json +15 -18
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +2 -2
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +18 -18
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +94 -49
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +2 -2
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +17 -17
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +5 -2
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +25 -25
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +73 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +27 -9
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +5 -14
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +61 -13
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +66 -81
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +21 -21
- package/coverage/lcov-report/middleware/joi-validator.js.html +43 -43
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +67 -13
- package/coverage/lcov-report/utilities/index.html +20 -20
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +26 -14
- package/coverage/lcov-report/utilities/queue/index.html +17 -17
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +747 -1245
- package/dist/api/controllers/deploy/index.js +1 -0
- package/dist/api/controllers/query/index.js +1 -1
- package/dist/api/controllers/query/validation.js +1 -1
- package/dist/api/controllers/row/internalSearch.js +30 -16
- package/dist/api/routes/utils/validators.js +1 -1
- package/dist/automations/steps/queryRows.js +21 -1
- package/dist/automations/steps/serverLog.js +8 -2
- package/dist/automations/utils.js +47 -1
- package/dist/constants/index.js +1 -4
- package/dist/db/utils.js +14 -1
- package/dist/definitions/automations.js +8 -0
- package/dist/integrations/base/sql.js +43 -14
- package/dist/package.json +8 -8
- package/dist/threads/automation.js +147 -54
- package/dist/threads/definitions.js +2 -0
- package/dist/threads/index.js +27 -20
- package/dist/threads/query.js +23 -15
- package/dist/threads/utils.js +47 -24
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/global.js +21 -4
- package/dist/utilities/queue/inMemoryQueue.js +5 -0
- package/package.json +9 -9
- package/src/api/controllers/deploy/index.ts +6 -1
- package/src/api/controllers/query/index.ts +1 -1
- package/src/api/controllers/query/validation.js +1 -1
- package/src/api/controllers/row/internalSearch.js +35 -20
- package/src/api/routes/tests/user.spec.js +2 -0
- package/src/api/routes/utils/validators.js +1 -1
- package/src/automations/steps/executeQuery.js +1 -0
- package/src/automations/steps/queryRows.js +22 -1
- package/src/automations/steps/serverLog.js +8 -2
- package/src/automations/tests/automation.spec.js +2 -2
- package/src/automations/utils.ts +54 -1
- package/src/constants/index.js +2 -5
- package/src/db/utils.js +16 -0
- package/src/definitions/automations.ts +49 -0
- package/src/definitions/datasource.ts +3 -0
- package/src/integrations/base/sql.ts +44 -13
- package/src/integrations/tests/sql.spec.js +50 -4
- package/src/middleware/tests/currentapp.spec.js +11 -0
- package/src/threads/{automation.js → automation.ts} +172 -48
- package/src/threads/definitions.ts +18 -0
- package/src/threads/index.ts +31 -23
- package/src/threads/{query.js → query.ts} +32 -12
- package/src/threads/{utils.js → utils.ts} +31 -12
- package/src/utilities/global.js +20 -2
- package/src/utilities/queue/inMemoryQueue.js +4 -0
- package/builder/assets/index.8084846c.js +0 -978
- package/coverage/lcov-report/threads/automation.js.html +0 -1114
- package/coverage/lcov-report/threads/index.html +0 -146
- package/coverage/lcov-report/threads/query.js.html +0 -916
- package/coverage/lcov-report/threads/utils.js.html +0 -319
|
@@ -8,36 +8,45 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.execute = void 0;
|
|
16
|
+
const utils_1 = __importDefault(require("./utils"));
|
|
17
|
+
utils_1.default.threadSetup();
|
|
18
|
+
const utils_2 = require("../automations/utils");
|
|
19
|
+
const actions_1 = __importDefault(require("../automations/actions"));
|
|
20
|
+
const automationUtils_1 = __importDefault(require("../automations/automationUtils"));
|
|
21
|
+
const AutomationEmitter_1 = __importDefault(require("../events/AutomationEmitter"));
|
|
22
|
+
const utils_3 = require("../db/utils");
|
|
23
|
+
const triggerInfo_1 = require("../automations/triggerInfo");
|
|
24
|
+
const constants_1 = require("../constants");
|
|
25
|
+
const logging_1 = require("../automations/logging");
|
|
26
|
+
const types_1 = require("@budibase/types");
|
|
27
|
+
const automations_1 = require("../definitions/automations");
|
|
18
28
|
const { doInAppContext, getAppDB } = require("@budibase/backend-core/context");
|
|
19
|
-
const {
|
|
20
|
-
const {
|
|
21
|
-
const FILTER_STEP_ID =
|
|
22
|
-
const LOOP_STEP_ID =
|
|
23
|
-
const CRON_STEP_ID =
|
|
24
|
-
const STOPPED_STATUS = { success: true, status:
|
|
29
|
+
const { logAlertWithInfo, logWarn } = require("@budibase/backend-core/logging");
|
|
30
|
+
const { processObject } = require("@budibase/string-templates");
|
|
31
|
+
const FILTER_STEP_ID = actions_1.default.ACTION_DEFINITIONS.FILTER.stepId;
|
|
32
|
+
const LOOP_STEP_ID = actions_1.default.ACTION_DEFINITIONS.LOOP.stepId;
|
|
33
|
+
const CRON_STEP_ID = triggerInfo_1.definitions.CRON.stepId;
|
|
34
|
+
const STOPPED_STATUS = { success: true, status: types_1.AutomationStatus.STOPPED };
|
|
25
35
|
const { cloneDeep } = require("lodash/fp");
|
|
26
36
|
const env = require("../environment");
|
|
27
37
|
function typecastForLooping(loopStep, input) {
|
|
28
38
|
if (!input || !input.binding) {
|
|
29
39
|
return null;
|
|
30
40
|
}
|
|
31
|
-
const isArray = Array.isArray(input.binding), isString = typeof input.binding === "string";
|
|
32
41
|
try {
|
|
33
42
|
switch (loopStep.inputs.option) {
|
|
34
|
-
case LoopStepTypes.ARRAY:
|
|
35
|
-
if (
|
|
43
|
+
case automations_1.LoopStepTypes.ARRAY:
|
|
44
|
+
if (typeof input.binding === "string") {
|
|
36
45
|
return JSON.parse(input.binding);
|
|
37
46
|
}
|
|
38
47
|
break;
|
|
39
|
-
case LoopStepTypes.STRING:
|
|
40
|
-
if (isArray) {
|
|
48
|
+
case automations_1.LoopStepTypes.STRING:
|
|
49
|
+
if (Array.isArray(input.binding)) {
|
|
41
50
|
return input.binding.join(",");
|
|
42
51
|
}
|
|
43
52
|
break;
|
|
@@ -55,7 +64,7 @@ function getLoopIterations(loopStep, input) {
|
|
|
55
64
|
}
|
|
56
65
|
return Array.isArray(binding)
|
|
57
66
|
? binding.length
|
|
58
|
-
:
|
|
67
|
+
: automationUtils_1.default.stringSplit(binding).length;
|
|
59
68
|
}
|
|
60
69
|
/**
|
|
61
70
|
* The automation orchestrator is a class responsible for executing automations.
|
|
@@ -63,11 +72,16 @@ function getLoopIterations(loopStep, input) {
|
|
|
63
72
|
* inputs and handles any outputs.
|
|
64
73
|
*/
|
|
65
74
|
class Orchestrator {
|
|
66
|
-
constructor(automation, triggerOutput
|
|
67
|
-
|
|
68
|
-
this._chainCount =
|
|
75
|
+
constructor(automation, triggerOutput, opts) {
|
|
76
|
+
const metadata = triggerOutput.metadata;
|
|
77
|
+
this._chainCount = metadata ? metadata.automationChainCount : 0;
|
|
69
78
|
this._appId = triggerOutput.appId;
|
|
70
|
-
|
|
79
|
+
if (opts === null || opts === void 0 ? void 0 : opts.repeat) {
|
|
80
|
+
this._repeat = {
|
|
81
|
+
jobId: opts.repeat.jobId,
|
|
82
|
+
jobKey: opts.repeat.key,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
71
85
|
const triggerStepId = automation.definition.trigger.stepId;
|
|
72
86
|
triggerOutput = this.cleanupTriggerOutputs(triggerStepId, triggerOutput);
|
|
73
87
|
// remove from context
|
|
@@ -78,7 +92,7 @@ class Orchestrator {
|
|
|
78
92
|
this._automation = automation;
|
|
79
93
|
// create an emitter which has the chain count for this automation run in it, so it can block
|
|
80
94
|
// excessive chaining if required
|
|
81
|
-
this._emitter = new
|
|
95
|
+
this._emitter = new AutomationEmitter_1.default(this._chainCount + 1);
|
|
82
96
|
this.executionOutput = { trigger: {}, steps: [] };
|
|
83
97
|
// setup the execution output
|
|
84
98
|
const triggerId = automation.definition.trigger.id;
|
|
@@ -92,32 +106,98 @@ class Orchestrator {
|
|
|
92
106
|
}
|
|
93
107
|
getStepFunctionality(stepId) {
|
|
94
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
-
let step = yield
|
|
109
|
+
let step = yield actions_1.default.getAction(stepId);
|
|
96
110
|
if (step == null) {
|
|
97
111
|
throw `Cannot find automation step by name ${stepId}`;
|
|
98
112
|
}
|
|
99
113
|
return step;
|
|
100
114
|
});
|
|
101
115
|
}
|
|
102
|
-
|
|
116
|
+
getMetadata() {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const metadataId = (0, utils_3.generateAutomationMetadataID)(this._automation._id);
|
|
119
|
+
const db = getAppDB();
|
|
120
|
+
let metadata;
|
|
121
|
+
try {
|
|
122
|
+
metadata = yield db.get(metadataId);
|
|
123
|
+
}
|
|
124
|
+
catch (err) {
|
|
125
|
+
metadata = {
|
|
126
|
+
_id: metadataId,
|
|
127
|
+
errorCount: 0,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return metadata;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
checkIfShouldStop(metadata) {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
if (!metadata.errorCount || !this._repeat) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const automation = this._automation;
|
|
140
|
+
const trigger = automation.definition.trigger;
|
|
141
|
+
if (metadata.errorCount >= constants_1.MAX_AUTOMATION_RECURRING_ERRORS) {
|
|
142
|
+
logWarn(`CRON disabled due to errors - ${this._appId}/${this._automation._id}`);
|
|
143
|
+
yield (0, utils_2.disableCron)((_a = this._repeat) === null || _a === void 0 ? void 0 : _a.jobId, (_b = this._repeat) === null || _b === void 0 ? void 0 : _b.jobKey);
|
|
144
|
+
this.updateExecutionOutput(trigger.id, trigger.stepId, {}, {
|
|
145
|
+
status: types_1.AutomationStatus.STOPPED_ERROR,
|
|
146
|
+
success: false,
|
|
147
|
+
});
|
|
148
|
+
yield (0, logging_1.storeLog)(automation, this.executionOutput);
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return false;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
updateMetadata(metadata) {
|
|
103
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
|
|
105
|
-
|
|
156
|
+
const output = this.executionOutput, automation = this._automation;
|
|
157
|
+
if (!output || !(0, utils_2.isRecurring)(automation)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const count = metadata.errorCount;
|
|
161
|
+
const isError = (0, utils_2.isErrorInOutput)(output);
|
|
162
|
+
// nothing to do in this scenario, escape
|
|
163
|
+
if (!count && !isError) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (isError) {
|
|
167
|
+
metadata.errorCount = count ? count + 1 : 1;
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
metadata.errorCount = 0;
|
|
106
171
|
}
|
|
107
172
|
const db = getAppDB();
|
|
108
|
-
|
|
109
|
-
|
|
173
|
+
try {
|
|
174
|
+
yield db.put(metadata);
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
logAlertWithInfo("Failed to write automation metadata", db.name, automation._id, err);
|
|
178
|
+
}
|
|
110
179
|
});
|
|
111
180
|
}
|
|
112
181
|
updateExecutionOutput(id, stepId, inputs, outputs) {
|
|
113
182
|
const stepObj = { id, stepId, inputs, outputs };
|
|
183
|
+
// replacing trigger when disabling CRON
|
|
184
|
+
if (stepId === CRON_STEP_ID &&
|
|
185
|
+
outputs.status === types_1.AutomationStatus.STOPPED_ERROR) {
|
|
186
|
+
this.executionOutput.trigger = stepObj;
|
|
187
|
+
this.executionOutput.steps = [stepObj];
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
114
190
|
// first entry is always the trigger (constructor)
|
|
115
|
-
if (this.executionOutput.steps.length === 0
|
|
191
|
+
if (this.executionOutput.steps.length === 0 ||
|
|
192
|
+
this.executionOutput.trigger.id === id) {
|
|
116
193
|
this.executionOutput.trigger = stepObj;
|
|
117
194
|
}
|
|
118
195
|
this.executionOutput.steps.push(stepObj);
|
|
119
196
|
}
|
|
120
197
|
updateContextAndOutput(loopStepNumber, step, output, result) {
|
|
198
|
+
if (!loopStepNumber) {
|
|
199
|
+
throw new Error("No loop step number provided.");
|
|
200
|
+
}
|
|
121
201
|
this.executionOutput.steps.splice(loopStepNumber, 0, {
|
|
122
202
|
id: step.id,
|
|
123
203
|
stepId: step.stepId,
|
|
@@ -131,10 +211,19 @@ class Orchestrator {
|
|
|
131
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
212
|
let automation = this._automation;
|
|
133
213
|
let stopped = false;
|
|
134
|
-
let loopStep =
|
|
214
|
+
let loopStep = undefined;
|
|
135
215
|
let stepCount = 0;
|
|
136
|
-
let loopStepNumber =
|
|
216
|
+
let loopStepNumber = undefined;
|
|
137
217
|
let loopSteps = [];
|
|
218
|
+
let metadata;
|
|
219
|
+
// check if this is a recurring automation,
|
|
220
|
+
if ((0, utils_3.isProdAppID)(this._appId) && (0, utils_2.isRecurring)(automation)) {
|
|
221
|
+
metadata = yield this.getMetadata();
|
|
222
|
+
const shouldStop = yield this.checkIfShouldStop(metadata);
|
|
223
|
+
if (shouldStop) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
138
227
|
for (let step of automation.definition.steps) {
|
|
139
228
|
stepCount++;
|
|
140
229
|
let input, iterations = 1, iterationCount = 0;
|
|
@@ -158,17 +247,17 @@ class Orchestrator {
|
|
|
158
247
|
}
|
|
159
248
|
catch (err) {
|
|
160
249
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
|
|
161
|
-
status: AutomationErrors.INCORRECT_TYPE,
|
|
250
|
+
status: constants_1.AutomationErrors.INCORRECT_TYPE,
|
|
162
251
|
success: false,
|
|
163
252
|
});
|
|
164
|
-
loopSteps =
|
|
165
|
-
loopStep =
|
|
253
|
+
loopSteps = undefined;
|
|
254
|
+
loopStep = undefined;
|
|
166
255
|
break;
|
|
167
256
|
}
|
|
168
257
|
let item;
|
|
169
258
|
if (typeof loopStep.inputs.binding === "string" &&
|
|
170
259
|
loopStep.inputs.option === "String") {
|
|
171
|
-
item =
|
|
260
|
+
item = automationUtils_1.default.stringSplit(newInput.binding);
|
|
172
261
|
}
|
|
173
262
|
else {
|
|
174
263
|
item = loopStep.inputs.binding;
|
|
@@ -183,31 +272,31 @@ class Orchestrator {
|
|
|
183
272
|
for (let [innerKey, innerValue] of Object.entries(originalStepInput[key])) {
|
|
184
273
|
if (typeof innerValue === "string") {
|
|
185
274
|
originalStepInput[key][innerKey] =
|
|
186
|
-
|
|
275
|
+
automationUtils_1.default.substituteLoopStep(innerValue, `steps.${loopStepNumber}`);
|
|
187
276
|
}
|
|
188
277
|
}
|
|
189
278
|
}
|
|
190
279
|
else {
|
|
191
280
|
if (typeof value === "string") {
|
|
192
|
-
originalStepInput[key] =
|
|
281
|
+
originalStepInput[key] = automationUtils_1.default.substituteLoopStep(value, `steps.${loopStepNumber}`);
|
|
193
282
|
}
|
|
194
283
|
}
|
|
195
284
|
}
|
|
196
285
|
if (index === env.AUTOMATION_MAX_ITERATION ||
|
|
197
286
|
index === parseInt(loopStep.inputs.iterations)) {
|
|
198
287
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
|
|
199
|
-
status: AutomationErrors.MAX_ITERATIONS,
|
|
288
|
+
status: constants_1.AutomationErrors.MAX_ITERATIONS,
|
|
200
289
|
success: true,
|
|
201
290
|
});
|
|
202
|
-
loopSteps =
|
|
203
|
-
loopStep =
|
|
291
|
+
loopSteps = undefined;
|
|
292
|
+
loopStep = undefined;
|
|
204
293
|
break;
|
|
205
294
|
}
|
|
206
295
|
let isFailure = false;
|
|
207
296
|
const currentItem = (_a = this._context.steps[loopStepNumber]) === null || _a === void 0 ? void 0 : _a.currentItem;
|
|
208
297
|
if (currentItem && typeof currentItem === "object") {
|
|
209
298
|
isFailure = Object.keys(currentItem).some(value => {
|
|
210
|
-
return currentItem[value] === loopStep.inputs.failure;
|
|
299
|
+
return currentItem[value] === (loopStep === null || loopStep === void 0 ? void 0 : loopStep.inputs.failure);
|
|
211
300
|
});
|
|
212
301
|
}
|
|
213
302
|
else {
|
|
@@ -215,11 +304,11 @@ class Orchestrator {
|
|
|
215
304
|
}
|
|
216
305
|
if (isFailure) {
|
|
217
306
|
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
|
|
218
|
-
status: AutomationErrors.FAILURE_CONDITION,
|
|
307
|
+
status: constants_1.AutomationErrors.FAILURE_CONDITION,
|
|
219
308
|
success: false,
|
|
220
309
|
});
|
|
221
|
-
loopSteps =
|
|
222
|
-
loopStep =
|
|
310
|
+
loopSteps = undefined;
|
|
311
|
+
loopStep = undefined;
|
|
223
312
|
break;
|
|
224
313
|
}
|
|
225
314
|
}
|
|
@@ -231,7 +320,7 @@ class Orchestrator {
|
|
|
231
320
|
// If it's a loop step, we need to manually add the bindings to the context
|
|
232
321
|
let stepFn = yield this.getStepFunctionality(step.stepId);
|
|
233
322
|
let inputs = yield processObject(originalStepInput, this._context);
|
|
234
|
-
inputs =
|
|
323
|
+
inputs = automationUtils_1.default.cleanInputValues(inputs, step.schema.inputs);
|
|
235
324
|
try {
|
|
236
325
|
// appId is always passed
|
|
237
326
|
const outputs = yield stepFn({
|
|
@@ -262,7 +351,7 @@ class Orchestrator {
|
|
|
262
351
|
if (loopStep) {
|
|
263
352
|
iterationCount++;
|
|
264
353
|
if (index === iterations - 1) {
|
|
265
|
-
loopStep =
|
|
354
|
+
loopStep = undefined;
|
|
266
355
|
this._context.steps.splice(loopStepNumber, 1);
|
|
267
356
|
break;
|
|
268
357
|
}
|
|
@@ -281,19 +370,22 @@ class Orchestrator {
|
|
|
281
370
|
inputs: step.inputs,
|
|
282
371
|
});
|
|
283
372
|
this._context.steps.splice(loopStepNumber, 0, tempOutput);
|
|
284
|
-
loopSteps =
|
|
373
|
+
loopSteps = undefined;
|
|
285
374
|
}
|
|
286
375
|
}
|
|
287
376
|
// store the logs for the automation run
|
|
288
|
-
yield storeLog(this._automation, this.executionOutput);
|
|
377
|
+
yield (0, logging_1.storeLog)(this._automation, this.executionOutput);
|
|
378
|
+
if ((0, utils_3.isProdAppID)(this._appId) && (0, utils_2.isRecurring)(automation) && metadata) {
|
|
379
|
+
yield this.updateMetadata(metadata);
|
|
380
|
+
}
|
|
289
381
|
return this.executionOutput;
|
|
290
382
|
});
|
|
291
383
|
}
|
|
292
384
|
}
|
|
293
|
-
|
|
385
|
+
function execute(input, callback) {
|
|
294
386
|
const appId = input.data.event.appId;
|
|
295
|
-
doInAppContext(appId, () => __awaiter(
|
|
296
|
-
const automationOrchestrator = new Orchestrator(input.data.automation, input.data.event);
|
|
387
|
+
doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
388
|
+
const automationOrchestrator = new Orchestrator(input.data.automation, input.data.event, input.opts);
|
|
297
389
|
try {
|
|
298
390
|
const response = yield automationOrchestrator.execute();
|
|
299
391
|
callback(null, response);
|
|
@@ -302,4 +394,5 @@ module.exports = (input, callback) => {
|
|
|
302
394
|
callback(err);
|
|
303
395
|
}
|
|
304
396
|
}));
|
|
305
|
-
}
|
|
397
|
+
}
|
|
398
|
+
exports.execute = execute;
|
package/dist/threads/index.js
CHANGED
|
@@ -54,17 +54,14 @@ function typeToFile(type) {
|
|
|
54
54
|
default:
|
|
55
55
|
throw "Unknown thread type";
|
|
56
56
|
}
|
|
57
|
+
// have to use require here, to make it work with worker-farm
|
|
57
58
|
return require.resolve(filename);
|
|
58
59
|
}
|
|
59
60
|
class Thread {
|
|
60
61
|
constructor(type, opts = { timeoutMs: null, count: 1 }) {
|
|
61
62
|
this.type = type;
|
|
62
63
|
this.count = opts.count ? opts.count : 1;
|
|
63
|
-
this.disableThreading =
|
|
64
|
-
env.isTest() ||
|
|
65
|
-
env.DISABLE_THREADING ||
|
|
66
|
-
this.count === 0 ||
|
|
67
|
-
env.isInThread();
|
|
64
|
+
this.disableThreading = this.shouldDisableThreading();
|
|
68
65
|
if (!this.disableThreading) {
|
|
69
66
|
const workerOpts = {
|
|
70
67
|
autoStart: true,
|
|
@@ -74,31 +71,41 @@ class Thread {
|
|
|
74
71
|
this.timeoutMs = opts.timeoutMs;
|
|
75
72
|
workerOpts.maxCallTime = opts.timeoutMs;
|
|
76
73
|
}
|
|
77
|
-
this.workers = (0, worker_farm_1.default)(workerOpts, typeToFile(type));
|
|
74
|
+
this.workers = (0, worker_farm_1.default)(workerOpts, typeToFile(type), ["execute"]);
|
|
78
75
|
Thread.workerRefs.push(this.workers);
|
|
79
76
|
}
|
|
80
77
|
}
|
|
78
|
+
shouldDisableThreading() {
|
|
79
|
+
return !!(env.isTest() ||
|
|
80
|
+
env.DISABLE_THREADING ||
|
|
81
|
+
this.count === 0 ||
|
|
82
|
+
env.isInThread());
|
|
83
|
+
}
|
|
81
84
|
run(data) {
|
|
85
|
+
const timeout = this.timeoutMs;
|
|
82
86
|
return new Promise((resolve, reject) => {
|
|
83
|
-
|
|
87
|
+
function fire(worker) {
|
|
88
|
+
worker.execute(data, (err, response) => {
|
|
89
|
+
if (err && err.type === "TimeoutError") {
|
|
90
|
+
reject(new Error(`Query response time exceeded ${timeout}ms timeout.`));
|
|
91
|
+
}
|
|
92
|
+
else if (err) {
|
|
93
|
+
reject(err);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
resolve(response);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
84
100
|
// if in test then don't use threading
|
|
85
101
|
if (this.disableThreading) {
|
|
86
|
-
|
|
102
|
+
Promise.resolve().then(() => __importStar(require(typeToFile(this.type)))).then((thread) => {
|
|
103
|
+
fire(thread);
|
|
104
|
+
});
|
|
87
105
|
}
|
|
88
106
|
else {
|
|
89
|
-
|
|
107
|
+
fire(this.workers);
|
|
90
108
|
}
|
|
91
|
-
fncToCall(data, (err, response) => {
|
|
92
|
-
if (err && err.type === "TimeoutError") {
|
|
93
|
-
reject(new Error(`Query response time exceeded ${this.timeoutMs}ms timeout.`));
|
|
94
|
-
}
|
|
95
|
-
else if (err) {
|
|
96
|
-
reject(err);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
resolve(response);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
109
|
});
|
|
103
110
|
}
|
|
104
111
|
static stopThreads() {
|
package/dist/threads/query.js
CHANGED
|
@@ -8,8 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.execute = void 0;
|
|
16
|
+
const utils_1 = __importDefault(require("./utils"));
|
|
17
|
+
utils_1.default.threadSetup();
|
|
13
18
|
const ScriptRunner = require("../utilities/scriptRunner");
|
|
14
19
|
const { integrations } = require("../integrations");
|
|
15
20
|
const { processStringSync } = require("@budibase/string-templates");
|
|
@@ -39,6 +44,7 @@ class QueryRunner {
|
|
|
39
44
|
this.queryResponse = {};
|
|
40
45
|
this.hasRerun = false;
|
|
41
46
|
this.hasRefreshedOAuth = false;
|
|
47
|
+
this.hasDynamicVariables = false;
|
|
42
48
|
}
|
|
43
49
|
execute() {
|
|
44
50
|
var _a;
|
|
@@ -52,7 +58,7 @@ class QueryRunner {
|
|
|
52
58
|
}
|
|
53
59
|
if (datasourceClone.config.authConfigs) {
|
|
54
60
|
datasourceClone.config.authConfigs =
|
|
55
|
-
datasourceClone.config.authConfigs.map(config => {
|
|
61
|
+
datasourceClone.config.authConfigs.map((config) => {
|
|
56
62
|
return enrichQueryFields(config, this.ctx);
|
|
57
63
|
});
|
|
58
64
|
}
|
|
@@ -79,9 +85,9 @@ class QueryRunner {
|
|
|
79
85
|
if (this.pagination) {
|
|
80
86
|
query.paginationValues = this.pagination;
|
|
81
87
|
}
|
|
82
|
-
let output =
|
|
88
|
+
let output = utils_1.default.formatResponse(yield integration[queryVerb](query));
|
|
83
89
|
let rows = output, info = undefined, extra = undefined, pagination = undefined;
|
|
84
|
-
if (
|
|
90
|
+
if (utils_1.default.hasExtraData(output)) {
|
|
85
91
|
rows = output.data;
|
|
86
92
|
info = output.info;
|
|
87
93
|
extra = output.extra;
|
|
@@ -107,7 +113,7 @@ class QueryRunner {
|
|
|
107
113
|
else {
|
|
108
114
|
this.hasRerun = true;
|
|
109
115
|
}
|
|
110
|
-
yield
|
|
116
|
+
yield utils_1.default.invalidateDynamicVariables(this.cachedVariables);
|
|
111
117
|
return this.execute();
|
|
112
118
|
}
|
|
113
119
|
// check for undefined response
|
|
@@ -119,8 +125,8 @@ class QueryRunner {
|
|
|
119
125
|
rows = [rows];
|
|
120
126
|
}
|
|
121
127
|
// map into JSON if just raw primitive here
|
|
122
|
-
if (rows.find(row => typeof row !== "object")) {
|
|
123
|
-
rows = rows.map(value => ({ value }));
|
|
128
|
+
if (rows.find((row) => typeof row !== "object")) {
|
|
129
|
+
rows = rows.map((value) => ({ value }));
|
|
124
130
|
}
|
|
125
131
|
// get all the potential fields in the schema
|
|
126
132
|
let keys = rows.flatMap(Object.keys);
|
|
@@ -141,6 +147,7 @@ class QueryRunner {
|
|
|
141
147
|
fields: query.fields,
|
|
142
148
|
parameters,
|
|
143
149
|
transformer: query.transformer,
|
|
150
|
+
queryId,
|
|
144
151
|
}, { noRecursiveQuery: true }).execute();
|
|
145
152
|
});
|
|
146
153
|
}
|
|
@@ -172,14 +179,14 @@ class QueryRunner {
|
|
|
172
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
173
180
|
let { parameters } = this;
|
|
174
181
|
const queryId = variable.queryId, name = variable.name;
|
|
175
|
-
let value = yield
|
|
182
|
+
let value = yield utils_1.default.checkCacheForDynamicVariable(queryId, name);
|
|
176
183
|
if (!value) {
|
|
177
184
|
value = this.queryResponse[queryId]
|
|
178
185
|
? this.queryResponse[queryId]
|
|
179
186
|
: yield this.runAnotherQuery(queryId, parameters);
|
|
180
187
|
// store incase this query is to be called again
|
|
181
188
|
this.queryResponse[queryId] = value;
|
|
182
|
-
yield
|
|
189
|
+
yield utils_1.default.storeDynamicVariable(queryId, name, value);
|
|
183
190
|
}
|
|
184
191
|
else {
|
|
185
192
|
this.cachedVariables.push({ queryId, name });
|
|
@@ -203,7 +210,7 @@ class QueryRunner {
|
|
|
203
210
|
if (!this.noRecursiveQuery) {
|
|
204
211
|
// need to see if this uses any variables
|
|
205
212
|
const stringFields = JSON.stringify(fields);
|
|
206
|
-
const foundVars = dynamicVars.filter(variable => {
|
|
213
|
+
const foundVars = dynamicVars.filter((variable) => {
|
|
207
214
|
// don't allow a query to use its own dynamic variable (loop)
|
|
208
215
|
if (variable.queryId === this.queryId) {
|
|
209
216
|
return false;
|
|
@@ -212,7 +219,7 @@ class QueryRunner {
|
|
|
212
219
|
const regex = new RegExp(`{{[ ]*${variable.name}[ ]*}}`);
|
|
213
220
|
return regex.test(stringFields);
|
|
214
221
|
});
|
|
215
|
-
const dynamics = foundVars.map(dynVar => this.getDynamicVariable(dynVar));
|
|
222
|
+
const dynamics = foundVars.map((dynVar) => this.getDynamicVariable(dynVar));
|
|
216
223
|
const responses = yield Promise.all(dynamics);
|
|
217
224
|
for (let i = 0; i < foundVars.length; i++) {
|
|
218
225
|
const variable = foundVars[i];
|
|
@@ -230,8 +237,8 @@ class QueryRunner {
|
|
|
230
237
|
});
|
|
231
238
|
}
|
|
232
239
|
}
|
|
233
|
-
|
|
234
|
-
doInAppContext(input.appId, () => __awaiter(
|
|
240
|
+
function execute(input, callback) {
|
|
241
|
+
doInAppContext(input.appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
235
242
|
const Runner = new QueryRunner(input);
|
|
236
243
|
try {
|
|
237
244
|
const response = yield Runner.execute();
|
|
@@ -241,4 +248,5 @@ module.exports = (input, callback) => {
|
|
|
241
248
|
callback(err);
|
|
242
249
|
}
|
|
243
250
|
}));
|
|
244
|
-
}
|
|
251
|
+
}
|
|
252
|
+
exports.execute = execute;
|
package/dist/threads/utils.js
CHANGED
|
@@ -8,6 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.hasExtraData = exports.formatResponse = exports.storeDynamicVariable = exports.invalidateDynamicVariables = exports.checkCacheForDynamicVariable = exports.threadSetup = void 0;
|
|
11
13
|
const env = require("../environment");
|
|
12
14
|
const db = require("../db");
|
|
13
15
|
const redis = require("@budibase/backend-core/redis");
|
|
@@ -23,10 +25,14 @@ function getClient() {
|
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
process.on("exit", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
-
if (client)
|
|
28
|
+
if (client) {
|
|
27
29
|
yield client.finish();
|
|
30
|
+
}
|
|
28
31
|
}));
|
|
29
|
-
|
|
32
|
+
function makeVariableKey(queryId, variable) {
|
|
33
|
+
return `${queryId}${SEPARATOR}${variable}`;
|
|
34
|
+
}
|
|
35
|
+
function threadSetup() {
|
|
30
36
|
// don't run this if not threading
|
|
31
37
|
if (env.isTest() || env.DISABLE_THREADING) {
|
|
32
38
|
return;
|
|
@@ -34,27 +40,34 @@ exports.threadSetup = () => {
|
|
|
34
40
|
// when thread starts, make sure it is recorded
|
|
35
41
|
env.setInThread();
|
|
36
42
|
db.init();
|
|
37
|
-
};
|
|
38
|
-
function makeVariableKey(queryId, variable) {
|
|
39
|
-
return `${queryId}${SEPARATOR}${variable}`;
|
|
40
43
|
}
|
|
41
|
-
exports.
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
exports.threadSetup = threadSetup;
|
|
45
|
+
function checkCacheForDynamicVariable(queryId, variable) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const cache = yield getClient();
|
|
48
|
+
return cache.get(makeVariableKey(queryId, variable));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.checkCacheForDynamicVariable = checkCacheForDynamicVariable;
|
|
52
|
+
function invalidateDynamicVariables(cachedVars) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const cache = yield getClient();
|
|
55
|
+
let promises = [];
|
|
56
|
+
for (let variable of cachedVars) {
|
|
57
|
+
promises.push(cache.delete(makeVariableKey(variable.queryId, variable.name)));
|
|
58
|
+
}
|
|
59
|
+
yield Promise.all(promises);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.invalidateDynamicVariables = invalidateDynamicVariables;
|
|
63
|
+
function storeDynamicVariable(queryId, variable, value) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const cache = yield getClient();
|
|
66
|
+
yield cache.store(makeVariableKey(queryId, variable), value, VARIABLE_TTL_SECONDS);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
exports.storeDynamicVariable = storeDynamicVariable;
|
|
70
|
+
function formatResponse(resp) {
|
|
58
71
|
if (typeof resp === "string") {
|
|
59
72
|
try {
|
|
60
73
|
resp = JSON.parse(resp);
|
|
@@ -64,11 +77,21 @@ exports.formatResponse = resp => {
|
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
return resp;
|
|
67
|
-
}
|
|
68
|
-
exports.
|
|
80
|
+
}
|
|
81
|
+
exports.formatResponse = formatResponse;
|
|
82
|
+
function hasExtraData(response) {
|
|
69
83
|
return (typeof response === "object" &&
|
|
70
84
|
!Array.isArray(response) &&
|
|
71
85
|
response &&
|
|
72
86
|
response.data != null &&
|
|
73
87
|
response.info != null);
|
|
88
|
+
}
|
|
89
|
+
exports.hasExtraData = hasExtraData;
|
|
90
|
+
exports.default = {
|
|
91
|
+
hasExtraData,
|
|
92
|
+
formatResponse,
|
|
93
|
+
storeDynamicVariable,
|
|
94
|
+
invalidateDynamicVariables,
|
|
95
|
+
checkCacheForDynamicVariable,
|
|
96
|
+
threadSetup,
|
|
74
97
|
};
|