@budibase/server 2.6.16 → 2.6.18
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.a40dcadd.js → index.69c5c1ea.js} +227 -227
- package/builder/index.html +1 -1
- package/dist/automations/triggers.js +2 -1
- package/dist/automations/utils.js +22 -17
- package/dist/threads/automation.js +2 -1
- package/dist/threads/index.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/automations/triggers.ts +5 -3
- package/src/automations/utils.ts +23 -16
- package/src/definitions/automations.ts +1 -5
- package/src/threads/automation.ts +11 -6
- package/src/threads/definitions.ts +0 -2
- package/src/threads/index.ts +4 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.6.
|
|
4
|
+
"version": "2.6.18",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"license": "GPL-3.0",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
48
|
-
"@budibase/backend-core": "^2.6.
|
|
49
|
-
"@budibase/client": "^2.6.
|
|
50
|
-
"@budibase/pro": "2.6.
|
|
51
|
-
"@budibase/shared-core": "^2.6.
|
|
52
|
-
"@budibase/string-templates": "^2.6.
|
|
53
|
-
"@budibase/types": "^2.6.
|
|
48
|
+
"@budibase/backend-core": "^2.6.18",
|
|
49
|
+
"@budibase/client": "^2.6.18",
|
|
50
|
+
"@budibase/pro": "2.6.17",
|
|
51
|
+
"@budibase/shared-core": "^2.6.18",
|
|
52
|
+
"@budibase/string-templates": "^2.6.18",
|
|
53
|
+
"@budibase/types": "^2.6.18",
|
|
54
54
|
"@bull-board/api": "3.7.0",
|
|
55
55
|
"@bull-board/koa": "3.9.4",
|
|
56
56
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -176,5 +176,5 @@
|
|
|
176
176
|
"optionalDependencies": {
|
|
177
177
|
"oracledb": "5.3.0"
|
|
178
178
|
},
|
|
179
|
-
"gitHead": "
|
|
179
|
+
"gitHead": "6e97c358e00e4a7be0c620858c564960c393c1b8"
|
|
180
180
|
}
|
|
@@ -9,7 +9,7 @@ import { checkTestFlag } from "../utilities/redis"
|
|
|
9
9
|
import * as utils from "./utils"
|
|
10
10
|
import env from "../environment"
|
|
11
11
|
import { context, db as dbCore } from "@budibase/backend-core"
|
|
12
|
-
import { Automation, Row } from "@budibase/types"
|
|
12
|
+
import { Automation, Row, AutomationData, AutomationJob } from "@budibase/types"
|
|
13
13
|
|
|
14
14
|
export const TRIGGER_DEFINITIONS = definitions
|
|
15
15
|
const JOB_OPTS = {
|
|
@@ -109,14 +109,16 @@ export async function externalTrigger(
|
|
|
109
109
|
}
|
|
110
110
|
params.fields = coercedFields
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
|
|
113
|
+
const data: AutomationData = { automation, event: params as any }
|
|
113
114
|
if (getResponses) {
|
|
114
115
|
data.event = {
|
|
115
116
|
...data.event,
|
|
116
117
|
appId: context.getAppId(),
|
|
117
118
|
automation,
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
+
const job = { data } as AutomationJob
|
|
121
|
+
return utils.processEvent(job)
|
|
120
122
|
} else {
|
|
121
123
|
return automationQueue.add(data, JOB_OPTS)
|
|
122
124
|
}
|
package/src/automations/utils.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { db as dbCore, context } from "@budibase/backend-core"
|
|
|
8
8
|
import { getAutomationMetadataParams } from "../db/utils"
|
|
9
9
|
import { cloneDeep } from "lodash/fp"
|
|
10
10
|
import { quotas } from "@budibase/pro"
|
|
11
|
-
import { Automation, WebhookActionType } from "@budibase/types"
|
|
11
|
+
import { Automation, AutomationJob, WebhookActionType } from "@budibase/types"
|
|
12
12
|
import sdk from "../sdk"
|
|
13
13
|
|
|
14
14
|
const REBOOT_CRON = "@reboot"
|
|
@@ -16,27 +16,34 @@ const WH_STEP_ID = definitions.WEBHOOK.stepId
|
|
|
16
16
|
const CRON_STEP_ID = definitions.CRON.stepId
|
|
17
17
|
const Runner = new Thread(ThreadType.AUTOMATION)
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
return
|
|
19
|
+
function loggingArgs(job: AutomationJob) {
|
|
20
|
+
return {
|
|
21
|
+
jobId: job.id,
|
|
22
|
+
trigger: job.data.automation.definition.trigger.event,
|
|
23
|
+
}
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
export async function processEvent(job:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
export async function processEvent(job: AutomationJob) {
|
|
27
|
+
const appId = job.data.event.appId!
|
|
28
|
+
const automationId = job.data.automation._id!
|
|
29
|
+
const task = async () => {
|
|
30
|
+
try {
|
|
31
|
+
// need to actually await these so that an error can be captured properly
|
|
32
|
+
console.log("automation running", loggingArgs(job))
|
|
33
|
+
|
|
29
34
|
const runFn = () => Runner.run(job)
|
|
30
|
-
|
|
35
|
+
const result = await quotas.addAutomation(runFn, {
|
|
31
36
|
automationId,
|
|
32
37
|
})
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
console.log("automation completed", loggingArgs(job))
|
|
39
|
+
return result
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error(`automation was unable to run`, err, loggingArgs(job))
|
|
42
|
+
return { err }
|
|
43
|
+
}
|
|
39
44
|
}
|
|
45
|
+
|
|
46
|
+
return await context.doInAutomationContext({ appId, automationId, task })
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
export async function updateTestHistory(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AutomationResults, AutomationStep
|
|
1
|
+
import { AutomationResults, AutomationStep } from "@budibase/types"
|
|
2
2
|
|
|
3
3
|
export enum LoopStepType {
|
|
4
4
|
ARRAY = "Array",
|
|
@@ -27,7 +27,3 @@ export interface AutomationContext extends AutomationResults {
|
|
|
27
27
|
env?: Record<string, string>
|
|
28
28
|
trigger: any
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
export interface AutomationMetadata extends Document {
|
|
32
|
-
errorCount?: number
|
|
33
|
-
}
|
|
@@ -13,13 +13,18 @@ import { generateAutomationMetadataID, isProdAppID } from "../db/utils"
|
|
|
13
13
|
import { definitions as triggerDefs } from "../automations/triggerInfo"
|
|
14
14
|
import { AutomationErrors, MAX_AUTOMATION_RECURRING_ERRORS } from "../constants"
|
|
15
15
|
import { storeLog } from "../automations/logging"
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
Automation,
|
|
18
|
+
AutomationStep,
|
|
19
|
+
AutomationStatus,
|
|
20
|
+
AutomationMetadata,
|
|
21
|
+
AutomationJob,
|
|
22
|
+
} from "@budibase/types"
|
|
17
23
|
import {
|
|
18
24
|
LoopStep,
|
|
19
25
|
LoopInput,
|
|
20
26
|
TriggerOutput,
|
|
21
27
|
AutomationContext,
|
|
22
|
-
AutomationMetadata,
|
|
23
28
|
} from "../definitions/automations"
|
|
24
29
|
import { WorkerCallback } from "./definitions"
|
|
25
30
|
import { context, logging } from "@budibase/backend-core"
|
|
@@ -60,11 +65,11 @@ class Orchestrator {
|
|
|
60
65
|
_job: Job
|
|
61
66
|
executionOutput: AutomationContext
|
|
62
67
|
|
|
63
|
-
constructor(job:
|
|
64
|
-
let automation = job.data.automation
|
|
65
|
-
|
|
68
|
+
constructor(job: AutomationJob) {
|
|
69
|
+
let automation = job.data.automation
|
|
70
|
+
let triggerOutput = job.data.event
|
|
66
71
|
const metadata = triggerOutput.metadata
|
|
67
|
-
this._chainCount = metadata ? metadata.automationChainCount : 0
|
|
72
|
+
this._chainCount = metadata ? metadata.automationChainCount! : 0
|
|
68
73
|
this._appId = triggerOutput.appId as string
|
|
69
74
|
this._job = job
|
|
70
75
|
const triggerStepId = automation.definition.trigger.stepId
|
package/src/threads/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import workerFarm from "worker-farm"
|
|
2
2
|
import env from "../environment"
|
|
3
|
+
import { AutomationJob } from "@budibase/types"
|
|
4
|
+
import { QueryEvent } from "./definitions"
|
|
3
5
|
|
|
4
6
|
export const ThreadType = {
|
|
5
7
|
QUERY: "query",
|
|
@@ -64,11 +66,11 @@ export class Thread {
|
|
|
64
66
|
)
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
run(
|
|
69
|
+
run(job: AutomationJob | QueryEvent) {
|
|
68
70
|
const timeout = this.timeoutMs
|
|
69
71
|
return new Promise((resolve, reject) => {
|
|
70
72
|
function fire(worker: any) {
|
|
71
|
-
worker.execute(
|
|
73
|
+
worker.execute(job, (err: any, response: any) => {
|
|
72
74
|
if (err && err.type === "TimeoutError") {
|
|
73
75
|
reject(
|
|
74
76
|
new Error(`Query response time exceeded ${timeout}ms timeout.`)
|