@budibase/server 2.5.6-alpha.4 → 2.5.6-alpha.6
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.58b41739.js → index.4216de02.js} +241 -241
- package/builder/assets/{index.841e62d8.css → index.e2ac94e5.css} +1 -1
- package/builder/index.html +2 -2
- package/dist/api/controllers/automation.js +13 -7
- package/dist/api/controllers/plugin/index.js +4 -35
- package/dist/automations/actions.js +32 -6
- package/dist/automations/index.js +3 -2
- package/dist/automations/steps/bash.js +6 -6
- package/dist/automations/steps/createRow.js +11 -11
- package/dist/automations/steps/delay.js +3 -3
- package/dist/automations/steps/deleteRow.js +8 -8
- package/dist/automations/steps/discord.js +8 -8
- package/dist/automations/steps/executeQuery.js +9 -9
- package/dist/automations/steps/executeScript.js +6 -6
- package/dist/automations/steps/filter.js +6 -6
- package/dist/automations/steps/integromat.js +10 -10
- package/dist/automations/steps/loop.js +9 -9
- package/dist/automations/steps/outgoingWebhook.js +10 -10
- package/dist/automations/steps/queryRows.js +14 -14
- package/dist/automations/steps/sendSmtpEmail.js +9 -9
- package/dist/automations/steps/serverLog.js +4 -4
- package/dist/automations/steps/slack.js +6 -6
- package/dist/automations/steps/updateRow.js +11 -11
- package/dist/automations/steps/zapier.js +9 -9
- package/dist/automations/triggerInfo/app.js +5 -5
- package/dist/automations/triggerInfo/cron.js +4 -4
- package/dist/automations/triggerInfo/rowDeleted.js +5 -5
- package/dist/automations/triggerInfo/rowSaved.js +7 -7
- package/dist/automations/triggerInfo/rowUpdated.js +7 -7
- package/dist/automations/triggerInfo/webhook.js +6 -6
- package/dist/integrations/index.js +3 -3
- package/dist/package.json +7 -7
- package/dist/sdk/index.js +2 -0
- package/dist/sdk/plugins/index.js +27 -0
- package/dist/sdk/plugins/plugins.js +53 -0
- package/dist/threads/automation.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/plugin.js +33 -23
- package/dist/watch.js +2 -2
- package/package.json +8 -8
- package/src/api/controllers/automation.ts +12 -6
- package/src/api/controllers/plugin/index.ts +6 -43
- package/src/api/routes/tests/automation.spec.js +2 -2
- package/src/automations/actions.ts +56 -24
- package/src/automations/index.ts +1 -1
- package/src/automations/steps/bash.ts +10 -7
- package/src/automations/steps/createRow.ts +15 -12
- package/src/automations/steps/delay.ts +6 -4
- package/src/automations/steps/deleteRow.ts +12 -9
- package/src/automations/steps/discord.ts +10 -8
- package/src/automations/steps/executeQuery.ts +13 -10
- package/src/automations/steps/executeScript.ts +10 -7
- package/src/automations/steps/filter.ts +8 -6
- package/src/automations/steps/integromat.ts +12 -10
- package/src/automations/steps/loop.ts +16 -10
- package/src/automations/steps/outgoingWebhook.ts +14 -11
- package/src/automations/steps/queryRows.ts +18 -15
- package/src/automations/steps/sendSmtpEmail.ts +11 -9
- package/src/automations/steps/serverLog.ts +6 -4
- package/src/automations/steps/slack.ts +8 -6
- package/src/automations/steps/updateRow.ts +15 -12
- package/src/automations/steps/zapier.ts +11 -9
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/triggerInfo/app.ts +8 -5
- package/src/automations/triggerInfo/cron.ts +7 -4
- package/src/automations/triggerInfo/rowDeleted.ts +8 -5
- package/src/automations/triggerInfo/rowSaved.ts +10 -7
- package/src/automations/triggerInfo/rowUpdated.ts +10 -7
- package/src/automations/triggerInfo/webhook.ts +9 -6
- package/src/integrations/index.ts +3 -3
- package/src/sdk/index.ts +2 -0
- package/src/sdk/plugins/index.ts +5 -0
- package/src/sdk/plugins/plugins.ts +41 -0
- package/src/tests/utilities/structures.ts +25 -17
- package/src/threads/automation.ts +2 -2
- package/src/utilities/fileSystem/plugin.ts +13 -4
- package/src/watch.ts +2 -2
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
AutomationActionStepId,
|
|
5
5
|
AutomationStepSchema,
|
|
6
6
|
AutomationStepInput,
|
|
7
|
+
AutomationStepType,
|
|
8
|
+
AutomationIOType,
|
|
7
9
|
} from "@budibase/types"
|
|
8
10
|
|
|
9
11
|
export const definition: AutomationStepSchema = {
|
|
10
12
|
name: "Zapier Webhook",
|
|
11
13
|
stepId: AutomationActionStepId.zapier,
|
|
12
|
-
type:
|
|
14
|
+
type: AutomationStepType.ACTION,
|
|
13
15
|
internal: false,
|
|
14
16
|
description: "Trigger a Zapier Zap via webhooks",
|
|
15
17
|
tagline: "Trigger a Zapier Zap",
|
|
@@ -19,27 +21,27 @@ export const definition: AutomationStepSchema = {
|
|
|
19
21
|
inputs: {
|
|
20
22
|
properties: {
|
|
21
23
|
url: {
|
|
22
|
-
type:
|
|
24
|
+
type: AutomationIOType.STRING,
|
|
23
25
|
title: "Webhook URL",
|
|
24
26
|
},
|
|
25
27
|
value1: {
|
|
26
|
-
type:
|
|
28
|
+
type: AutomationIOType.STRING,
|
|
27
29
|
title: "Payload Value 1",
|
|
28
30
|
},
|
|
29
31
|
value2: {
|
|
30
|
-
type:
|
|
32
|
+
type: AutomationIOType.STRING,
|
|
31
33
|
title: "Payload Value 2",
|
|
32
34
|
},
|
|
33
35
|
value3: {
|
|
34
|
-
type:
|
|
36
|
+
type: AutomationIOType.STRING,
|
|
35
37
|
title: "Payload Value 3",
|
|
36
38
|
},
|
|
37
39
|
value4: {
|
|
38
|
-
type:
|
|
40
|
+
type: AutomationIOType.STRING,
|
|
39
41
|
title: "Payload Value 4",
|
|
40
42
|
},
|
|
41
43
|
value5: {
|
|
42
|
-
type:
|
|
44
|
+
type: AutomationIOType.STRING,
|
|
43
45
|
title: "Payload Value 5",
|
|
44
46
|
},
|
|
45
47
|
},
|
|
@@ -48,11 +50,11 @@ export const definition: AutomationStepSchema = {
|
|
|
48
50
|
outputs: {
|
|
49
51
|
properties: {
|
|
50
52
|
httpStatus: {
|
|
51
|
-
type:
|
|
53
|
+
type: AutomationIOType.NUMBER,
|
|
52
54
|
description: "The HTTP status code of the request",
|
|
53
55
|
},
|
|
54
56
|
response: {
|
|
55
|
-
type:
|
|
57
|
+
type: AutomationIOType.STRING,
|
|
56
58
|
description: "The response from Zapier",
|
|
57
59
|
},
|
|
58
60
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import TestConfig from "../../../tests/utilities/TestConfiguration"
|
|
2
2
|
import { context } from "@budibase/backend-core"
|
|
3
|
-
import {
|
|
3
|
+
import { BUILTIN_ACTION_DEFINITIONS, getAction } from "../../actions"
|
|
4
4
|
import emitter from "../../../events/index"
|
|
5
5
|
import env from "../../../environment"
|
|
6
6
|
|
|
@@ -57,4 +57,4 @@ export async function runStep(stepId: string, inputs: any, stepContext?: any) {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export const apiKey = "test"
|
|
60
|
-
export const actions =
|
|
60
|
+
export const actions = BUILTIN_ACTION_DEFINITIONS
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutomationCustomIOType,
|
|
3
|
+
AutomationIOType,
|
|
4
|
+
AutomationStepType,
|
|
2
5
|
AutomationTriggerSchema,
|
|
3
6
|
AutomationTriggerStepId,
|
|
4
7
|
} from "@budibase/types"
|
|
@@ -15,8 +18,8 @@ export const definition: AutomationTriggerSchema = {
|
|
|
15
18
|
inputs: {
|
|
16
19
|
properties: {
|
|
17
20
|
fields: {
|
|
18
|
-
type:
|
|
19
|
-
customType:
|
|
21
|
+
type: AutomationIOType.OBJECT,
|
|
22
|
+
customType: AutomationCustomIOType.TRIGGER_SCHEMA,
|
|
20
23
|
title: "Fields",
|
|
21
24
|
},
|
|
22
25
|
},
|
|
@@ -25,13 +28,13 @@ export const definition: AutomationTriggerSchema = {
|
|
|
25
28
|
outputs: {
|
|
26
29
|
properties: {
|
|
27
30
|
fields: {
|
|
28
|
-
type:
|
|
31
|
+
type: AutomationIOType.OBJECT,
|
|
29
32
|
description: "Fields submitted from the app frontend",
|
|
30
|
-
customType:
|
|
33
|
+
customType: AutomationCustomIOType.TRIGGER_SCHEMA,
|
|
31
34
|
},
|
|
32
35
|
},
|
|
33
36
|
required: ["fields"],
|
|
34
37
|
},
|
|
35
38
|
},
|
|
36
|
-
type:
|
|
39
|
+
type: AutomationStepType.TRIGGER,
|
|
37
40
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutomationCustomIOType,
|
|
3
|
+
AutomationIOType,
|
|
4
|
+
AutomationStepType,
|
|
2
5
|
AutomationTriggerSchema,
|
|
3
6
|
AutomationTriggerStepId,
|
|
4
7
|
} from "@budibase/types"
|
|
@@ -15,8 +18,8 @@ export const definition: AutomationTriggerSchema = {
|
|
|
15
18
|
inputs: {
|
|
16
19
|
properties: {
|
|
17
20
|
cron: {
|
|
18
|
-
type:
|
|
19
|
-
customType:
|
|
21
|
+
type: AutomationIOType.STRING,
|
|
22
|
+
customType: AutomationCustomIOType.CRON,
|
|
20
23
|
title: "Expression",
|
|
21
24
|
},
|
|
22
25
|
},
|
|
@@ -25,12 +28,12 @@ export const definition: AutomationTriggerSchema = {
|
|
|
25
28
|
outputs: {
|
|
26
29
|
properties: {
|
|
27
30
|
timestamp: {
|
|
28
|
-
type:
|
|
31
|
+
type: AutomationIOType.NUMBER,
|
|
29
32
|
description: "Timestamp the cron was executed",
|
|
30
33
|
},
|
|
31
34
|
},
|
|
32
35
|
required: ["timestamp"],
|
|
33
36
|
},
|
|
34
37
|
},
|
|
35
|
-
type:
|
|
38
|
+
type: AutomationStepType.TRIGGER,
|
|
36
39
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutomationCustomIOType,
|
|
3
|
+
AutomationIOType,
|
|
4
|
+
AutomationStepType,
|
|
2
5
|
AutomationTriggerSchema,
|
|
3
6
|
AutomationTriggerStepId,
|
|
4
7
|
} from "@budibase/types"
|
|
@@ -15,8 +18,8 @@ export const definition: AutomationTriggerSchema = {
|
|
|
15
18
|
inputs: {
|
|
16
19
|
properties: {
|
|
17
20
|
tableId: {
|
|
18
|
-
type:
|
|
19
|
-
customType:
|
|
21
|
+
type: AutomationIOType.STRING,
|
|
22
|
+
customType: AutomationCustomIOType.TABLE,
|
|
20
23
|
title: "Table",
|
|
21
24
|
},
|
|
22
25
|
},
|
|
@@ -25,13 +28,13 @@ export const definition: AutomationTriggerSchema = {
|
|
|
25
28
|
outputs: {
|
|
26
29
|
properties: {
|
|
27
30
|
row: {
|
|
28
|
-
type:
|
|
29
|
-
customType:
|
|
31
|
+
type: AutomationIOType.OBJECT,
|
|
32
|
+
customType: AutomationCustomIOType.ROW,
|
|
30
33
|
description: "The row that was deleted",
|
|
31
34
|
},
|
|
32
35
|
},
|
|
33
36
|
required: ["row"],
|
|
34
37
|
},
|
|
35
38
|
},
|
|
36
|
-
type:
|
|
39
|
+
type: AutomationStepType.TRIGGER,
|
|
37
40
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutomationCustomIOType,
|
|
3
|
+
AutomationIOType,
|
|
4
|
+
AutomationStepType,
|
|
2
5
|
AutomationTriggerSchema,
|
|
3
6
|
AutomationTriggerStepId,
|
|
4
7
|
} from "@budibase/types"
|
|
@@ -15,8 +18,8 @@ export const definition: AutomationTriggerSchema = {
|
|
|
15
18
|
inputs: {
|
|
16
19
|
properties: {
|
|
17
20
|
tableId: {
|
|
18
|
-
type:
|
|
19
|
-
customType:
|
|
21
|
+
type: AutomationIOType.STRING,
|
|
22
|
+
customType: AutomationCustomIOType.TABLE,
|
|
20
23
|
title: "Table",
|
|
21
24
|
},
|
|
22
25
|
},
|
|
@@ -25,21 +28,21 @@ export const definition: AutomationTriggerSchema = {
|
|
|
25
28
|
outputs: {
|
|
26
29
|
properties: {
|
|
27
30
|
row: {
|
|
28
|
-
type:
|
|
29
|
-
customType:
|
|
31
|
+
type: AutomationIOType.OBJECT,
|
|
32
|
+
customType: AutomationCustomIOType.ROW,
|
|
30
33
|
description: "The new row that was created",
|
|
31
34
|
},
|
|
32
35
|
id: {
|
|
33
|
-
type:
|
|
36
|
+
type: AutomationIOType.STRING,
|
|
34
37
|
description: "Row ID - can be used for updating",
|
|
35
38
|
},
|
|
36
39
|
revision: {
|
|
37
|
-
type:
|
|
40
|
+
type: AutomationIOType.STRING,
|
|
38
41
|
description: "Revision of row",
|
|
39
42
|
},
|
|
40
43
|
},
|
|
41
44
|
required: ["row", "id"],
|
|
42
45
|
},
|
|
43
46
|
},
|
|
44
|
-
type:
|
|
47
|
+
type: AutomationStepType.TRIGGER,
|
|
45
48
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutomationCustomIOType,
|
|
3
|
+
AutomationIOType,
|
|
4
|
+
AutomationStepType,
|
|
2
5
|
AutomationTriggerSchema,
|
|
3
6
|
AutomationTriggerStepId,
|
|
4
7
|
} from "@budibase/types"
|
|
@@ -15,8 +18,8 @@ export const definition: AutomationTriggerSchema = {
|
|
|
15
18
|
inputs: {
|
|
16
19
|
properties: {
|
|
17
20
|
tableId: {
|
|
18
|
-
type:
|
|
19
|
-
customType:
|
|
21
|
+
type: AutomationIOType.STRING,
|
|
22
|
+
customType: AutomationCustomIOType.TABLE,
|
|
20
23
|
title: "Table",
|
|
21
24
|
},
|
|
22
25
|
},
|
|
@@ -25,21 +28,21 @@ export const definition: AutomationTriggerSchema = {
|
|
|
25
28
|
outputs: {
|
|
26
29
|
properties: {
|
|
27
30
|
row: {
|
|
28
|
-
type:
|
|
29
|
-
customType:
|
|
31
|
+
type: AutomationIOType.OBJECT,
|
|
32
|
+
customType: AutomationCustomIOType.ROW,
|
|
30
33
|
description: "The row that was updated",
|
|
31
34
|
},
|
|
32
35
|
id: {
|
|
33
|
-
type:
|
|
36
|
+
type: AutomationIOType.STRING,
|
|
34
37
|
description: "Row ID - can be used for updating",
|
|
35
38
|
},
|
|
36
39
|
revision: {
|
|
37
|
-
type:
|
|
40
|
+
type: AutomationIOType.STRING,
|
|
38
41
|
description: "Revision of row",
|
|
39
42
|
},
|
|
40
43
|
},
|
|
41
44
|
required: ["row", "id"],
|
|
42
45
|
},
|
|
43
46
|
},
|
|
44
|
-
type:
|
|
47
|
+
type: AutomationStepType.TRIGGER,
|
|
45
48
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AutomationCustomIOType,
|
|
3
|
+
AutomationIOType,
|
|
4
|
+
AutomationStepType,
|
|
2
5
|
AutomationTriggerSchema,
|
|
3
6
|
AutomationTriggerStepId,
|
|
4
7
|
} from "@budibase/types"
|
|
@@ -15,13 +18,13 @@ export const definition: AutomationTriggerSchema = {
|
|
|
15
18
|
inputs: {
|
|
16
19
|
properties: {
|
|
17
20
|
schemaUrl: {
|
|
18
|
-
type:
|
|
19
|
-
customType:
|
|
21
|
+
type: AutomationIOType.STRING,
|
|
22
|
+
customType: AutomationCustomIOType.WEBHOOK_URL,
|
|
20
23
|
title: "Schema URL",
|
|
21
24
|
},
|
|
22
25
|
triggerUrl: {
|
|
23
|
-
type:
|
|
24
|
-
customType:
|
|
26
|
+
type: AutomationIOType.STRING,
|
|
27
|
+
customType: AutomationCustomIOType.WEBHOOK_URL,
|
|
25
28
|
title: "Trigger URL",
|
|
26
29
|
},
|
|
27
30
|
},
|
|
@@ -30,12 +33,12 @@ export const definition: AutomationTriggerSchema = {
|
|
|
30
33
|
outputs: {
|
|
31
34
|
properties: {
|
|
32
35
|
body: {
|
|
33
|
-
type:
|
|
36
|
+
type: AutomationIOType.OBJECT,
|
|
34
37
|
description: "Body of the request which hit the webhook",
|
|
35
38
|
},
|
|
36
39
|
},
|
|
37
40
|
required: ["body"],
|
|
38
41
|
},
|
|
39
42
|
},
|
|
40
|
-
type:
|
|
43
|
+
type: AutomationStepType.TRIGGER,
|
|
41
44
|
}
|
|
@@ -14,11 +14,11 @@ import firebase from "./firebase"
|
|
|
14
14
|
import redis from "./redis"
|
|
15
15
|
import snowflake from "./snowflake"
|
|
16
16
|
import oracle from "./oracle"
|
|
17
|
-
import { getPlugins } from "../api/controllers/plugin"
|
|
18
17
|
import { SourceName, Integration, PluginType } from "@budibase/types"
|
|
19
18
|
import { getDatasourcePlugin } from "../utilities/fileSystem"
|
|
20
19
|
import env from "../environment"
|
|
21
20
|
import { cloneDeep } from "lodash"
|
|
21
|
+
import sdk from "../sdk"
|
|
22
22
|
|
|
23
23
|
const DEFINITIONS: { [key: string]: Integration } = {
|
|
24
24
|
[SourceName.POSTGRES]: postgres.schema,
|
|
@@ -79,7 +79,7 @@ export async function getDefinition(source: SourceName): Promise<Integration> {
|
|
|
79
79
|
export async function getDefinitions() {
|
|
80
80
|
const pluginSchemas: { [key: string]: Integration } = {}
|
|
81
81
|
if (env.SELF_HOSTED) {
|
|
82
|
-
const plugins = await
|
|
82
|
+
const plugins = await sdk.plugins.fetch(PluginType.DATASOURCE)
|
|
83
83
|
// extract the actual schema from each custom
|
|
84
84
|
for (let plugin of plugins) {
|
|
85
85
|
const sourceId = plugin.name
|
|
@@ -103,7 +103,7 @@ export async function getIntegration(integration: string) {
|
|
|
103
103
|
return INTEGRATIONS[integration]
|
|
104
104
|
}
|
|
105
105
|
if (env.SELF_HOSTED) {
|
|
106
|
-
const plugins = await
|
|
106
|
+
const plugins = await sdk.plugins.fetch(PluginType.DATASOURCE)
|
|
107
107
|
for (let plugin of plugins) {
|
|
108
108
|
if (plugin.name === integration) {
|
|
109
109
|
// need to use commonJS require due to its dynamic runtime nature
|
package/src/sdk/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { default as datasources } from "./app/datasources"
|
|
|
6
6
|
import { default as queries } from "./app/queries"
|
|
7
7
|
import { default as rows } from "./app/rows"
|
|
8
8
|
import { default as users } from "./users"
|
|
9
|
+
import { default as plugins } from "./plugins"
|
|
9
10
|
|
|
10
11
|
const sdk = {
|
|
11
12
|
backups,
|
|
@@ -16,6 +17,7 @@ const sdk = {
|
|
|
16
17
|
users,
|
|
17
18
|
datasources,
|
|
18
19
|
queries,
|
|
20
|
+
plugins,
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// default export for TS
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FileType, Plugin, PluginSource, PluginType } from "@budibase/types"
|
|
2
|
+
import {
|
|
3
|
+
db as dbCore,
|
|
4
|
+
objectStore,
|
|
5
|
+
plugins as pluginCore,
|
|
6
|
+
tenancy,
|
|
7
|
+
} from "@budibase/backend-core"
|
|
8
|
+
import { fileUpload } from "../../api/controllers/plugin/file"
|
|
9
|
+
import env from "../../environment"
|
|
10
|
+
import { ClientAppSocket } from "../../websocket"
|
|
11
|
+
import { sdk as pro } from "@budibase/pro"
|
|
12
|
+
|
|
13
|
+
export async function fetch(type?: PluginType) {
|
|
14
|
+
const db = tenancy.getGlobalDB()
|
|
15
|
+
const response = await db.allDocs(
|
|
16
|
+
dbCore.getPluginParams(null, {
|
|
17
|
+
include_docs: true,
|
|
18
|
+
})
|
|
19
|
+
)
|
|
20
|
+
let plugins = response.rows.map((row: any) => row.doc) as Plugin[]
|
|
21
|
+
plugins = objectStore.enrichPluginURLs(plugins)
|
|
22
|
+
if (type) {
|
|
23
|
+
return plugins.filter((plugin: Plugin) => plugin.schema?.type === type)
|
|
24
|
+
} else {
|
|
25
|
+
return plugins
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function processUploaded(plugin: FileType, source?: PluginSource) {
|
|
30
|
+
const { metadata, directory } = await fileUpload(plugin)
|
|
31
|
+
pluginCore.validate(metadata?.schema)
|
|
32
|
+
|
|
33
|
+
// Only allow components in cloud
|
|
34
|
+
if (!env.SELF_HOSTED && metadata?.schema?.type !== PluginType.COMPONENT) {
|
|
35
|
+
throw new Error("Only component plugins are supported outside of self-host")
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const doc = await pro.plugins.storePlugin(metadata, directory, source)
|
|
39
|
+
ClientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash })
|
|
40
|
+
return doc
|
|
41
|
+
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { permissions, roles } from "@budibase/backend-core"
|
|
1
|
+
import { permissions, roles, utils } from "@budibase/backend-core"
|
|
2
2
|
import { createHomeScreen } from "../../constants/screens"
|
|
3
3
|
import { EMPTY_LAYOUT } from "../../constants/layouts"
|
|
4
4
|
import { cloneDeep } from "lodash/fp"
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
BUILTIN_ACTION_DEFINITIONS,
|
|
7
|
+
TRIGGER_DEFINITIONS,
|
|
8
|
+
} from "../../automations"
|
|
6
9
|
import {
|
|
7
10
|
Automation,
|
|
8
11
|
AutomationActionStepId,
|
|
12
|
+
AutomationStep,
|
|
13
|
+
AutomationStepType,
|
|
14
|
+
AutomationTrigger,
|
|
9
15
|
AutomationTriggerStepId,
|
|
10
16
|
Datasource,
|
|
11
17
|
SourceName,
|
|
12
18
|
} from "@budibase/types"
|
|
13
19
|
|
|
14
|
-
const { v4: uuidv4 } = require("uuid")
|
|
15
|
-
|
|
16
20
|
export function basicTable() {
|
|
17
21
|
return {
|
|
18
22
|
name: "TestTable",
|
|
@@ -71,19 +75,19 @@ export function view(tableId: string) {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
export function automationStep(
|
|
74
|
-
actionDefinition =
|
|
75
|
-
) {
|
|
78
|
+
actionDefinition = BUILTIN_ACTION_DEFINITIONS.CREATE_ROW
|
|
79
|
+
): AutomationStep {
|
|
76
80
|
return {
|
|
77
|
-
id:
|
|
81
|
+
id: utils.newid(),
|
|
78
82
|
...actionDefinition,
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
export function automationTrigger(
|
|
83
87
|
triggerDefinition = TRIGGER_DEFINITIONS.ROW_SAVED
|
|
84
|
-
) {
|
|
88
|
+
): AutomationTrigger {
|
|
85
89
|
return {
|
|
86
|
-
id:
|
|
90
|
+
id: utils.newid(),
|
|
87
91
|
...triggerDefinition,
|
|
88
92
|
}
|
|
89
93
|
}
|
|
@@ -106,7 +110,7 @@ export function newAutomation({ steps, trigger }: any = {}) {
|
|
|
106
110
|
return automation
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
export function basicAutomation(appId?: string) {
|
|
113
|
+
export function basicAutomation(appId?: string): Automation {
|
|
110
114
|
return {
|
|
111
115
|
name: "My Automation",
|
|
112
116
|
screenId: "kasdkfldsafkl",
|
|
@@ -119,18 +123,22 @@ export function basicAutomation(appId?: string) {
|
|
|
119
123
|
tagline: "test",
|
|
120
124
|
icon: "test",
|
|
121
125
|
description: "test",
|
|
122
|
-
type:
|
|
126
|
+
type: AutomationStepType.TRIGGER,
|
|
123
127
|
id: "test",
|
|
124
128
|
inputs: {},
|
|
125
129
|
schema: {
|
|
126
|
-
inputs: {
|
|
127
|
-
|
|
130
|
+
inputs: {
|
|
131
|
+
properties: {},
|
|
132
|
+
},
|
|
133
|
+
outputs: {
|
|
134
|
+
properties: {},
|
|
135
|
+
},
|
|
128
136
|
},
|
|
129
137
|
},
|
|
130
138
|
steps: [],
|
|
131
139
|
},
|
|
132
140
|
type: "automation",
|
|
133
|
-
appId
|
|
141
|
+
appId: appId!,
|
|
134
142
|
}
|
|
135
143
|
}
|
|
136
144
|
|
|
@@ -154,7 +162,7 @@ export function loopAutomation(tableId: string, loopOpts?: any): Automation {
|
|
|
154
162
|
inputs: {
|
|
155
163
|
tableId,
|
|
156
164
|
},
|
|
157
|
-
schema:
|
|
165
|
+
schema: BUILTIN_ACTION_DEFINITIONS.QUERY_ROWS.schema,
|
|
158
166
|
},
|
|
159
167
|
{
|
|
160
168
|
id: "c",
|
|
@@ -163,7 +171,7 @@ export function loopAutomation(tableId: string, loopOpts?: any): Automation {
|
|
|
163
171
|
internal: true,
|
|
164
172
|
inputs: loopOpts,
|
|
165
173
|
blockToLoop: "d",
|
|
166
|
-
schema:
|
|
174
|
+
schema: BUILTIN_ACTION_DEFINITIONS.LOOP.schema,
|
|
167
175
|
},
|
|
168
176
|
{
|
|
169
177
|
id: "d",
|
|
@@ -173,7 +181,7 @@ export function loopAutomation(tableId: string, loopOpts?: any): Automation {
|
|
|
173
181
|
inputs: {
|
|
174
182
|
text: "log statement",
|
|
175
183
|
},
|
|
176
|
-
schema:
|
|
184
|
+
schema: BUILTIN_ACTION_DEFINITIONS.SERVER_LOG.schema,
|
|
177
185
|
},
|
|
178
186
|
],
|
|
179
187
|
trigger: {
|
|
@@ -27,8 +27,8 @@ import { processObject } from "@budibase/string-templates"
|
|
|
27
27
|
import { cloneDeep } from "lodash/fp"
|
|
28
28
|
import * as sdkUtils from "../sdk/utils"
|
|
29
29
|
import env from "../environment"
|
|
30
|
-
const FILTER_STEP_ID = actions.
|
|
31
|
-
const LOOP_STEP_ID = actions.
|
|
30
|
+
const FILTER_STEP_ID = actions.BUILTIN_ACTION_DEFINITIONS.FILTER.stepId
|
|
31
|
+
const LOOP_STEP_ID = actions.BUILTIN_ACTION_DEFINITIONS.LOOP.stepId
|
|
32
32
|
const CRON_STEP_ID = triggerDefs.CRON.stepId
|
|
33
33
|
const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
|
|
34
34
|
|
|
@@ -5,6 +5,7 @@ import { join } from "path"
|
|
|
5
5
|
import { objectStore } from "@budibase/backend-core"
|
|
6
6
|
|
|
7
7
|
const DATASOURCE_PATH = join(budibaseTempDir(), "datasource")
|
|
8
|
+
const AUTOMATION_PATH = join(budibaseTempDir(), "automation")
|
|
8
9
|
|
|
9
10
|
export const getPluginMetadata = async (path: string) => {
|
|
10
11
|
let metadata: any = {}
|
|
@@ -33,12 +34,12 @@ export const getPluginMetadata = async (path: string) => {
|
|
|
33
34
|
return { metadata, directory: path }
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
async function getPluginImpl(path: string, plugin: Plugin) {
|
|
37
38
|
const hash = plugin.schema?.hash
|
|
38
|
-
if (!fs.existsSync(
|
|
39
|
-
fs.mkdirSync(
|
|
39
|
+
if (!fs.existsSync(path)) {
|
|
40
|
+
fs.mkdirSync(path)
|
|
40
41
|
}
|
|
41
|
-
const filename = join(
|
|
42
|
+
const filename = join(path, plugin.name)
|
|
42
43
|
const metadataName = `${filename}.bbmetadata`
|
|
43
44
|
if (fs.existsSync(filename)) {
|
|
44
45
|
const currentHash = fs.readFileSync(metadataName, "utf8")
|
|
@@ -62,3 +63,11 @@ export const getDatasourcePlugin = async (plugin: Plugin) => {
|
|
|
62
63
|
|
|
63
64
|
return require(filename)
|
|
64
65
|
}
|
|
66
|
+
|
|
67
|
+
export const getDatasourcePlugin = async (plugin: Plugin) => {
|
|
68
|
+
return getPluginImpl(DATASOURCE_PATH, plugin)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const getAutomationPlugin = async (plugin: Plugin) => {
|
|
72
|
+
return getPluginImpl(AUTOMATION_PATH, plugin)
|
|
73
|
+
}
|
package/src/watch.ts
CHANGED
|
@@ -3,7 +3,7 @@ import env from "./environment"
|
|
|
3
3
|
import chokidar from "chokidar"
|
|
4
4
|
import fs from "fs"
|
|
5
5
|
import { constants, tenancy } from "@budibase/backend-core"
|
|
6
|
-
import
|
|
6
|
+
import pluginsSdk from "./sdk/plugins"
|
|
7
7
|
|
|
8
8
|
export function watch() {
|
|
9
9
|
const watchPath = path.join(env.PLUGINS_DIR, "./**/*.tar.gz")
|
|
@@ -27,7 +27,7 @@ export function watch() {
|
|
|
27
27
|
const split = path.split("/")
|
|
28
28
|
const name = split[split.length - 1]
|
|
29
29
|
console.log("Importing plugin:", path)
|
|
30
|
-
await
|
|
30
|
+
await pluginsSdk.processUploaded({ name, path })
|
|
31
31
|
} catch (err: any) {
|
|
32
32
|
const message = err?.message ? err?.message : err
|
|
33
33
|
console.error("Failed to import plugin:", message)
|