@budibase/server 3.3.2 → 3.3.4
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-f22ac5d2.js → index-3199ca61.js} +5 -5
- package/builder/assets/{index-5c106eca.css → index-fae37678.css} +1 -1
- package/builder/index.html +2 -2
- package/client/budibase-client.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/yarn.lock +3 -3
- package/package.json +2 -2
- package/src/api/routes/tests/automation.spec.ts +215 -231
- package/src/api/routes/tests/utilities/TestFunctions.ts +0 -9
- package/src/tests/utilities/TestConfiguration.ts +5 -1
- package/src/tests/utilities/api/automation.ts +86 -5
- package/src/tests/utilities/api/index.ts +24 -24
- package/src/tests/utilities/structures.ts +35 -29
|
@@ -53,15 +53,6 @@ export const clearAllApps = async (
|
|
|
53
53
|
})
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export const clearAllAutomations = async (config: TestConfiguration) => {
|
|
57
|
-
const { automations } = await config.getAllAutomations()
|
|
58
|
-
for (let auto of automations) {
|
|
59
|
-
await context.doInAppContext(config.getAppId(), async () => {
|
|
60
|
-
await config.deleteAutomation(auto)
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
56
|
export const wipeDb = async () => {
|
|
66
57
|
const couchInfo = db.getCouchInfo()
|
|
67
58
|
const nano = Nano({
|
|
@@ -258,7 +258,7 @@ export default class TestConfiguration {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
async withApp(app: App | string, f: () => Promise<
|
|
261
|
+
async withApp<R>(app: App | string, f: () => Promise<R>) {
|
|
262
262
|
const oldAppId = this.appId
|
|
263
263
|
this.appId = typeof app === "string" ? app : app.appId
|
|
264
264
|
try {
|
|
@@ -268,6 +268,10 @@ export default class TestConfiguration {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
async withProdApp<R>(f: () => Promise<R>) {
|
|
272
|
+
return await this.withApp(this.getProdAppId(), f)
|
|
273
|
+
}
|
|
274
|
+
|
|
271
275
|
// UTILS
|
|
272
276
|
|
|
273
277
|
_req<Req extends Record<string, any> | void, Res>(
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Automation,
|
|
3
|
+
CreateAutomationResponse,
|
|
4
|
+
DeleteAutomationResponse,
|
|
3
5
|
FetchAutomationResponse,
|
|
6
|
+
GetAutomationActionDefinitionsResponse,
|
|
7
|
+
GetAutomationStepDefinitionsResponse,
|
|
8
|
+
GetAutomationTriggerDefinitionsResponse,
|
|
4
9
|
TestAutomationRequest,
|
|
5
10
|
TestAutomationResponse,
|
|
11
|
+
TriggerAutomationRequest,
|
|
12
|
+
TriggerAutomationResponse,
|
|
13
|
+
UpdateAutomationRequest,
|
|
14
|
+
UpdateAutomationResponse,
|
|
6
15
|
} from "@budibase/types"
|
|
7
16
|
import { Expectations, TestAPI } from "./base"
|
|
8
17
|
|
|
@@ -20,6 +29,39 @@ export class AutomationAPI extends TestAPI {
|
|
|
20
29
|
return result
|
|
21
30
|
}
|
|
22
31
|
|
|
32
|
+
getActions = async (
|
|
33
|
+
expectations?: Expectations
|
|
34
|
+
): Promise<GetAutomationActionDefinitionsResponse> => {
|
|
35
|
+
return await this._get<GetAutomationActionDefinitionsResponse>(
|
|
36
|
+
`/api/automations/actions/list`,
|
|
37
|
+
{
|
|
38
|
+
expectations,
|
|
39
|
+
}
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getTriggers = async (
|
|
44
|
+
expectations?: Expectations
|
|
45
|
+
): Promise<GetAutomationTriggerDefinitionsResponse> => {
|
|
46
|
+
return await this._get<GetAutomationTriggerDefinitionsResponse>(
|
|
47
|
+
`/api/automations/triggers/list`,
|
|
48
|
+
{
|
|
49
|
+
expectations,
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
getDefinitions = async (
|
|
55
|
+
expectations?: Expectations
|
|
56
|
+
): Promise<GetAutomationStepDefinitionsResponse> => {
|
|
57
|
+
return await this._get<GetAutomationStepDefinitionsResponse>(
|
|
58
|
+
`/api/automations/definitions/list`,
|
|
59
|
+
{
|
|
60
|
+
expectations,
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
23
65
|
fetch = async (
|
|
24
66
|
expectations?: Expectations
|
|
25
67
|
): Promise<FetchAutomationResponse> => {
|
|
@@ -31,11 +73,14 @@ export class AutomationAPI extends TestAPI {
|
|
|
31
73
|
post = async (
|
|
32
74
|
body: Automation,
|
|
33
75
|
expectations?: Expectations
|
|
34
|
-
): Promise<
|
|
35
|
-
const result = await this._post<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
): Promise<CreateAutomationResponse> => {
|
|
77
|
+
const result = await this._post<CreateAutomationResponse>(
|
|
78
|
+
`/api/automations`,
|
|
79
|
+
{
|
|
80
|
+
body,
|
|
81
|
+
expectations,
|
|
82
|
+
}
|
|
83
|
+
)
|
|
39
84
|
return result
|
|
40
85
|
}
|
|
41
86
|
|
|
@@ -52,4 +97,40 @@ export class AutomationAPI extends TestAPI {
|
|
|
52
97
|
}
|
|
53
98
|
)
|
|
54
99
|
}
|
|
100
|
+
|
|
101
|
+
trigger = async (
|
|
102
|
+
id: string,
|
|
103
|
+
body: TriggerAutomationRequest,
|
|
104
|
+
expectations?: Expectations
|
|
105
|
+
): Promise<TriggerAutomationResponse> => {
|
|
106
|
+
return await this._post<TriggerAutomationResponse>(
|
|
107
|
+
`/api/automations/${id}/trigger`,
|
|
108
|
+
{
|
|
109
|
+
expectations,
|
|
110
|
+
body,
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
update = async (
|
|
116
|
+
body: UpdateAutomationRequest,
|
|
117
|
+
expectations?: Expectations
|
|
118
|
+
): Promise<UpdateAutomationResponse> => {
|
|
119
|
+
return await this._put<UpdateAutomationResponse>(`/api/automations`, {
|
|
120
|
+
body,
|
|
121
|
+
expectations,
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
delete = async (
|
|
126
|
+
automation: Automation,
|
|
127
|
+
expectations?: Expectations
|
|
128
|
+
): Promise<DeleteAutomationResponse> => {
|
|
129
|
+
return await this._delete<DeleteAutomationResponse>(
|
|
130
|
+
`/api/automations/${automation._id!}/${automation._rev!}`,
|
|
131
|
+
{
|
|
132
|
+
expectations,
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
55
136
|
}
|
|
@@ -19,43 +19,43 @@ import { PluginAPI } from "./plugin"
|
|
|
19
19
|
import { WebhookAPI } from "./webhook"
|
|
20
20
|
|
|
21
21
|
export default class API {
|
|
22
|
-
table: TableAPI
|
|
23
|
-
legacyView: LegacyViewAPI
|
|
24
|
-
viewV2: ViewV2API
|
|
25
|
-
row: RowAPI
|
|
26
|
-
permission: PermissionAPI
|
|
27
|
-
datasource: DatasourceAPI
|
|
28
|
-
screen: ScreenAPI
|
|
29
22
|
application: ApplicationAPI
|
|
30
|
-
backup: BackupAPI
|
|
31
23
|
attachment: AttachmentAPI
|
|
32
|
-
|
|
24
|
+
automation: AutomationAPI
|
|
25
|
+
backup: BackupAPI
|
|
26
|
+
datasource: DatasourceAPI
|
|
27
|
+
legacyView: LegacyViewAPI
|
|
28
|
+
permission: PermissionAPI
|
|
29
|
+
plugin: PluginAPI
|
|
33
30
|
query: QueryAPI
|
|
34
31
|
roles: RoleAPI
|
|
35
|
-
|
|
32
|
+
row: RowAPI
|
|
36
33
|
rowAction: RowActionAPI
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
screen: ScreenAPI
|
|
35
|
+
table: TableAPI
|
|
36
|
+
templates: TemplateAPI
|
|
37
|
+
user: UserAPI
|
|
38
|
+
viewV2: ViewV2API
|
|
39
39
|
webhook: WebhookAPI
|
|
40
40
|
|
|
41
41
|
constructor(config: TestConfiguration) {
|
|
42
|
-
this.table = new TableAPI(config)
|
|
43
|
-
this.legacyView = new LegacyViewAPI(config)
|
|
44
|
-
this.viewV2 = new ViewV2API(config)
|
|
45
|
-
this.row = new RowAPI(config)
|
|
46
|
-
this.permission = new PermissionAPI(config)
|
|
47
|
-
this.datasource = new DatasourceAPI(config)
|
|
48
|
-
this.screen = new ScreenAPI(config)
|
|
49
42
|
this.application = new ApplicationAPI(config)
|
|
50
|
-
this.backup = new BackupAPI(config)
|
|
51
43
|
this.attachment = new AttachmentAPI(config)
|
|
52
|
-
this.
|
|
44
|
+
this.automation = new AutomationAPI(config)
|
|
45
|
+
this.backup = new BackupAPI(config)
|
|
46
|
+
this.datasource = new DatasourceAPI(config)
|
|
47
|
+
this.legacyView = new LegacyViewAPI(config)
|
|
48
|
+
this.permission = new PermissionAPI(config)
|
|
49
|
+
this.plugin = new PluginAPI(config)
|
|
53
50
|
this.query = new QueryAPI(config)
|
|
54
51
|
this.roles = new RoleAPI(config)
|
|
55
|
-
this.
|
|
52
|
+
this.row = new RowAPI(config)
|
|
56
53
|
this.rowAction = new RowActionAPI(config)
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
54
|
+
this.screen = new ScreenAPI(config)
|
|
55
|
+
this.table = new TableAPI(config)
|
|
56
|
+
this.templates = new TemplateAPI(config)
|
|
57
|
+
this.user = new UserAPI(config)
|
|
58
|
+
this.viewV2 = new ViewV2API(config)
|
|
59
59
|
this.webhook = new WebhookAPI(config)
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
Webhook,
|
|
35
35
|
WebhookActionType,
|
|
36
36
|
BuiltinPermissionID,
|
|
37
|
+
DeepPartial,
|
|
37
38
|
} from "@budibase/types"
|
|
38
39
|
import { LoopInput } from "../../definitions/automations"
|
|
39
40
|
import { merge } from "lodash"
|
|
@@ -184,21 +185,12 @@ export function newAutomation({
|
|
|
184
185
|
steps,
|
|
185
186
|
trigger,
|
|
186
187
|
}: { steps?: AutomationStep[]; trigger?: AutomationTrigger } = {}) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (steps) {
|
|
196
|
-
automation.definition.steps = steps
|
|
197
|
-
} else {
|
|
198
|
-
automation.definition.steps = [automationStep()]
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return automation
|
|
188
|
+
return basicAutomation({
|
|
189
|
+
definition: {
|
|
190
|
+
steps: steps || [automationStep()],
|
|
191
|
+
trigger: trigger || automationTrigger(),
|
|
192
|
+
},
|
|
193
|
+
})
|
|
202
194
|
}
|
|
203
195
|
|
|
204
196
|
export function rowActionAutomation() {
|
|
@@ -211,8 +203,8 @@ export function rowActionAutomation() {
|
|
|
211
203
|
return automation
|
|
212
204
|
}
|
|
213
205
|
|
|
214
|
-
export function basicAutomation(
|
|
215
|
-
|
|
206
|
+
export function basicAutomation(opts?: DeepPartial<Automation>): Automation {
|
|
207
|
+
const baseAutomation: Automation = {
|
|
216
208
|
name: "My Automation",
|
|
217
209
|
screenId: "kasdkfldsafkl",
|
|
218
210
|
live: true,
|
|
@@ -241,8 +233,9 @@ export function basicAutomation(appId?: string): Automation {
|
|
|
241
233
|
steps: [],
|
|
242
234
|
},
|
|
243
235
|
type: "automation",
|
|
244
|
-
appId: appId
|
|
236
|
+
appId: "appId",
|
|
245
237
|
}
|
|
238
|
+
return merge(baseAutomation, opts)
|
|
246
239
|
}
|
|
247
240
|
|
|
248
241
|
export function basicCronAutomation(appId: string, cron: string): Automation {
|
|
@@ -387,16 +380,21 @@ export function loopAutomation(
|
|
|
387
380
|
return automation as Automation
|
|
388
381
|
}
|
|
389
382
|
|
|
390
|
-
export function collectAutomation(
|
|
391
|
-
const
|
|
383
|
+
export function collectAutomation(opts?: DeepPartial<Automation>): Automation {
|
|
384
|
+
const baseAutomation: Automation = {
|
|
385
|
+
appId: "appId",
|
|
392
386
|
name: "looping",
|
|
393
387
|
type: "automation",
|
|
394
388
|
definition: {
|
|
395
389
|
steps: [
|
|
396
390
|
{
|
|
397
391
|
id: "b",
|
|
398
|
-
|
|
392
|
+
name: "b",
|
|
393
|
+
tagline: "An automation action step",
|
|
394
|
+
icon: "Icon",
|
|
395
|
+
type: AutomationStepType.ACTION,
|
|
399
396
|
internal: true,
|
|
397
|
+
description: "Execute script",
|
|
400
398
|
stepId: AutomationActionStepId.EXECUTE_SCRIPT,
|
|
401
399
|
inputs: {
|
|
402
400
|
code: "return [1,2,3]",
|
|
@@ -405,8 +403,12 @@ export function collectAutomation(tableId?: string): Automation {
|
|
|
405
403
|
},
|
|
406
404
|
{
|
|
407
405
|
id: "c",
|
|
408
|
-
|
|
406
|
+
name: "c",
|
|
407
|
+
type: AutomationStepType.ACTION,
|
|
408
|
+
tagline: "An automation action step",
|
|
409
|
+
icon: "Icon",
|
|
409
410
|
internal: true,
|
|
411
|
+
description: "Collect",
|
|
410
412
|
stepId: AutomationActionStepId.COLLECT,
|
|
411
413
|
inputs: {
|
|
412
414
|
collection: "{{ literal steps.1.value }}",
|
|
@@ -416,24 +418,28 @@ export function collectAutomation(tableId?: string): Automation {
|
|
|
416
418
|
],
|
|
417
419
|
trigger: {
|
|
418
420
|
id: "a",
|
|
419
|
-
type:
|
|
421
|
+
type: AutomationStepType.TRIGGER,
|
|
420
422
|
event: AutomationEventType.ROW_SAVE,
|
|
421
423
|
stepId: AutomationTriggerStepId.ROW_SAVED,
|
|
424
|
+
name: "trigger Step",
|
|
425
|
+
tagline: "An automation trigger",
|
|
426
|
+
description: "A trigger",
|
|
427
|
+
icon: "Icon",
|
|
422
428
|
inputs: {
|
|
423
|
-
tableId,
|
|
429
|
+
tableId: "tableId",
|
|
424
430
|
},
|
|
425
431
|
schema: TRIGGER_DEFINITIONS.ROW_SAVED.schema,
|
|
426
432
|
},
|
|
427
433
|
},
|
|
428
434
|
}
|
|
429
|
-
return
|
|
435
|
+
return merge(baseAutomation, opts)
|
|
430
436
|
}
|
|
431
437
|
|
|
432
|
-
export function filterAutomation(
|
|
438
|
+
export function filterAutomation(opts?: DeepPartial<Automation>): Automation {
|
|
433
439
|
const automation: Automation = {
|
|
434
440
|
name: "looping",
|
|
435
441
|
type: "automation",
|
|
436
|
-
appId,
|
|
442
|
+
appId: "appId",
|
|
437
443
|
definition: {
|
|
438
444
|
steps: [
|
|
439
445
|
{
|
|
@@ -459,13 +465,13 @@ export function filterAutomation(appId: string, tableId?: string): Automation {
|
|
|
459
465
|
event: AutomationEventType.ROW_SAVE,
|
|
460
466
|
stepId: AutomationTriggerStepId.ROW_SAVED,
|
|
461
467
|
inputs: {
|
|
462
|
-
tableId: tableId
|
|
468
|
+
tableId: "tableId",
|
|
463
469
|
},
|
|
464
470
|
schema: TRIGGER_DEFINITIONS.ROW_SAVED.schema,
|
|
465
471
|
},
|
|
466
472
|
},
|
|
467
473
|
}
|
|
468
|
-
return automation
|
|
474
|
+
return merge(automation, opts)
|
|
469
475
|
}
|
|
470
476
|
|
|
471
477
|
export function updateRowAutomationWithFilters(
|