@budibase/server 2.5.6-alpha.3 → 2.5.6-alpha.31
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.a33a6c3d.js → index.39cfdb4b.js} +382 -366
- package/builder/assets/index.44a18341.css +6 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/application.js +2 -3
- package/dist/api/controllers/automation.js +13 -7
- package/dist/api/controllers/dev.js +1 -1
- package/dist/api/controllers/plugin/index.js +6 -37
- package/dist/api/controllers/query/index.js +2 -2
- package/dist/api/controllers/row/ExternalRequest.js +21 -14
- package/dist/api/controllers/table/utils.js +9 -3
- package/dist/api/index.js +1 -2
- package/dist/api/routes/index.js +0 -2
- package/dist/app.js +2 -2
- 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/base/sqlTable.js +9 -2
- package/dist/integrations/index.js +3 -3
- package/dist/migrations/functions/syncQuotas.js +2 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -1
- package/dist/migrations/functions/usageQuotas/syncUsers.js +21 -0
- package/dist/sdk/app/backups/exports.js +1 -35
- package/dist/sdk/index.js +2 -0
- package/dist/{api/routes/cloud.js → sdk/plugins/index.js} +2 -14
- 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/utilities/rowProcessor/utils.js +4 -5
- package/dist/watch.js +2 -2
- package/dist/websockets/client.js +14 -0
- package/dist/websockets/grid.js +60 -0
- package/dist/websockets/index.js +17 -0
- package/dist/websockets/websocket.js +78 -0
- package/package.json +11 -10
- package/src/api/controllers/application.ts +3 -3
- package/src/api/controllers/automation.ts +12 -6
- package/src/api/controllers/dev.ts +2 -2
- package/src/api/controllers/plugin/index.ts +8 -45
- package/src/api/controllers/query/index.ts +2 -2
- package/src/api/controllers/row/ExternalRequest.ts +21 -12
- package/src/api/controllers/table/utils.ts +10 -3
- package/src/api/index.ts +2 -4
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/tests/automation.spec.js +2 -2
- package/src/app.ts +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/integration-test/postgres.spec.ts +2 -0
- package/src/integrations/base/sqlTable.ts +9 -2
- package/src/integrations/index.ts +3 -3
- package/src/migrations/functions/syncQuotas.ts +2 -0
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -2
- package/src/migrations/functions/usageQuotas/syncUsers.ts +9 -0
- package/src/migrations/functions/usageQuotas/tests/syncUsers.spec.ts +26 -0
- package/src/migrations/index.ts +1 -0
- package/src/sdk/app/backups/exports.ts +0 -35
- 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/utilities/rowProcessor/utils.ts +9 -10
- package/src/watch.ts +2 -2
- package/src/websockets/client.ts +11 -0
- package/src/websockets/grid.ts +55 -0
- package/src/websockets/index.ts +14 -0
- package/src/websockets/websocket.ts +83 -0
- package/tsconfig.build.json +3 -5
- package/tsconfig.json +2 -1
- package/builder/assets/index.841e62d8.css +0 -6
- package/dist/api/controllers/cloud.js +0 -130
- package/dist/package.json +0 -179
- package/dist/websocket.js +0 -22
- package/src/api/controllers/cloud.ts +0 -119
- package/src/api/routes/cloud.ts +0 -18
- package/src/api/routes/tests/cloud.spec.ts +0 -54
- package/src/migrations/functions/tests/syncQuotas.spec.js +0 -26
- package/src/websocket.ts +0 -26
|
@@ -19,7 +19,7 @@ const types_1 = require("@budibase/types");
|
|
|
19
19
|
exports.definition = {
|
|
20
20
|
name: "Zapier Webhook",
|
|
21
21
|
stepId: types_1.AutomationActionStepId.zapier,
|
|
22
|
-
type:
|
|
22
|
+
type: types_1.AutomationStepType.ACTION,
|
|
23
23
|
internal: false,
|
|
24
24
|
description: "Trigger a Zapier Zap via webhooks",
|
|
25
25
|
tagline: "Trigger a Zapier Zap",
|
|
@@ -29,27 +29,27 @@ exports.definition = {
|
|
|
29
29
|
inputs: {
|
|
30
30
|
properties: {
|
|
31
31
|
url: {
|
|
32
|
-
type:
|
|
32
|
+
type: types_1.AutomationIOType.STRING,
|
|
33
33
|
title: "Webhook URL",
|
|
34
34
|
},
|
|
35
35
|
value1: {
|
|
36
|
-
type:
|
|
36
|
+
type: types_1.AutomationIOType.STRING,
|
|
37
37
|
title: "Payload Value 1",
|
|
38
38
|
},
|
|
39
39
|
value2: {
|
|
40
|
-
type:
|
|
40
|
+
type: types_1.AutomationIOType.STRING,
|
|
41
41
|
title: "Payload Value 2",
|
|
42
42
|
},
|
|
43
43
|
value3: {
|
|
44
|
-
type:
|
|
44
|
+
type: types_1.AutomationIOType.STRING,
|
|
45
45
|
title: "Payload Value 3",
|
|
46
46
|
},
|
|
47
47
|
value4: {
|
|
48
|
-
type:
|
|
48
|
+
type: types_1.AutomationIOType.STRING,
|
|
49
49
|
title: "Payload Value 4",
|
|
50
50
|
},
|
|
51
51
|
value5: {
|
|
52
|
-
type:
|
|
52
|
+
type: types_1.AutomationIOType.STRING,
|
|
53
53
|
title: "Payload Value 5",
|
|
54
54
|
},
|
|
55
55
|
},
|
|
@@ -58,11 +58,11 @@ exports.definition = {
|
|
|
58
58
|
outputs: {
|
|
59
59
|
properties: {
|
|
60
60
|
httpStatus: {
|
|
61
|
-
type:
|
|
61
|
+
type: types_1.AutomationIOType.NUMBER,
|
|
62
62
|
description: "The HTTP status code of the request",
|
|
63
63
|
},
|
|
64
64
|
response: {
|
|
65
|
-
type:
|
|
65
|
+
type: types_1.AutomationIOType.STRING,
|
|
66
66
|
description: "The response from Zapier",
|
|
67
67
|
},
|
|
68
68
|
},
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
fields: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: types_1.AutomationIOType.OBJECT,
|
|
18
|
+
customType: types_1.AutomationCustomIOType.TRIGGER_SCHEMA,
|
|
19
19
|
title: "Fields",
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -24,13 +24,13 @@ exports.definition = {
|
|
|
24
24
|
outputs: {
|
|
25
25
|
properties: {
|
|
26
26
|
fields: {
|
|
27
|
-
type:
|
|
27
|
+
type: types_1.AutomationIOType.OBJECT,
|
|
28
28
|
description: "Fields submitted from the app frontend",
|
|
29
|
-
customType:
|
|
29
|
+
customType: types_1.AutomationCustomIOType.TRIGGER_SCHEMA,
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
required: ["fields"],
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
-
type:
|
|
35
|
+
type: types_1.AutomationStepType.TRIGGER,
|
|
36
36
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
cron: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: types_1.AutomationIOType.STRING,
|
|
18
|
+
customType: types_1.AutomationCustomIOType.CRON,
|
|
19
19
|
title: "Expression",
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -24,12 +24,12 @@ exports.definition = {
|
|
|
24
24
|
outputs: {
|
|
25
25
|
properties: {
|
|
26
26
|
timestamp: {
|
|
27
|
-
type:
|
|
27
|
+
type: types_1.AutomationIOType.NUMBER,
|
|
28
28
|
description: "Timestamp the cron was executed",
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
required: ["timestamp"],
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
-
type:
|
|
34
|
+
type: types_1.AutomationStepType.TRIGGER,
|
|
35
35
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
tableId: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: types_1.AutomationIOType.STRING,
|
|
18
|
+
customType: types_1.AutomationCustomIOType.TABLE,
|
|
19
19
|
title: "Table",
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -24,13 +24,13 @@ exports.definition = {
|
|
|
24
24
|
outputs: {
|
|
25
25
|
properties: {
|
|
26
26
|
row: {
|
|
27
|
-
type:
|
|
28
|
-
customType:
|
|
27
|
+
type: types_1.AutomationIOType.OBJECT,
|
|
28
|
+
customType: types_1.AutomationCustomIOType.ROW,
|
|
29
29
|
description: "The row that was deleted",
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
required: ["row"],
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
-
type:
|
|
35
|
+
type: types_1.AutomationStepType.TRIGGER,
|
|
36
36
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
tableId: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: types_1.AutomationIOType.STRING,
|
|
18
|
+
customType: types_1.AutomationCustomIOType.TABLE,
|
|
19
19
|
title: "Table",
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -24,21 +24,21 @@ exports.definition = {
|
|
|
24
24
|
outputs: {
|
|
25
25
|
properties: {
|
|
26
26
|
row: {
|
|
27
|
-
type:
|
|
28
|
-
customType:
|
|
27
|
+
type: types_1.AutomationIOType.OBJECT,
|
|
28
|
+
customType: types_1.AutomationCustomIOType.ROW,
|
|
29
29
|
description: "The new row that was created",
|
|
30
30
|
},
|
|
31
31
|
id: {
|
|
32
|
-
type:
|
|
32
|
+
type: types_1.AutomationIOType.STRING,
|
|
33
33
|
description: "Row ID - can be used for updating",
|
|
34
34
|
},
|
|
35
35
|
revision: {
|
|
36
|
-
type:
|
|
36
|
+
type: types_1.AutomationIOType.STRING,
|
|
37
37
|
description: "Revision of row",
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
required: ["row", "id"],
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
type:
|
|
43
|
+
type: types_1.AutomationStepType.TRIGGER,
|
|
44
44
|
};
|
|
@@ -14,8 +14,8 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
tableId: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: types_1.AutomationIOType.STRING,
|
|
18
|
+
customType: types_1.AutomationCustomIOType.TABLE,
|
|
19
19
|
title: "Table",
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -24,21 +24,21 @@ exports.definition = {
|
|
|
24
24
|
outputs: {
|
|
25
25
|
properties: {
|
|
26
26
|
row: {
|
|
27
|
-
type:
|
|
28
|
-
customType:
|
|
27
|
+
type: types_1.AutomationIOType.OBJECT,
|
|
28
|
+
customType: types_1.AutomationCustomIOType.ROW,
|
|
29
29
|
description: "The row that was updated",
|
|
30
30
|
},
|
|
31
31
|
id: {
|
|
32
|
-
type:
|
|
32
|
+
type: types_1.AutomationIOType.STRING,
|
|
33
33
|
description: "Row ID - can be used for updating",
|
|
34
34
|
},
|
|
35
35
|
revision: {
|
|
36
|
-
type:
|
|
36
|
+
type: types_1.AutomationIOType.STRING,
|
|
37
37
|
description: "Revision of row",
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
required: ["row", "id"],
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
type:
|
|
43
|
+
type: types_1.AutomationStepType.TRIGGER,
|
|
44
44
|
};
|
|
@@ -14,13 +14,13 @@ exports.definition = {
|
|
|
14
14
|
inputs: {
|
|
15
15
|
properties: {
|
|
16
16
|
schemaUrl: {
|
|
17
|
-
type:
|
|
18
|
-
customType:
|
|
17
|
+
type: types_1.AutomationIOType.STRING,
|
|
18
|
+
customType: types_1.AutomationCustomIOType.WEBHOOK_URL,
|
|
19
19
|
title: "Schema URL",
|
|
20
20
|
},
|
|
21
21
|
triggerUrl: {
|
|
22
|
-
type:
|
|
23
|
-
customType:
|
|
22
|
+
type: types_1.AutomationIOType.STRING,
|
|
23
|
+
customType: types_1.AutomationCustomIOType.WEBHOOK_URL,
|
|
24
24
|
title: "Trigger URL",
|
|
25
25
|
},
|
|
26
26
|
},
|
|
@@ -29,12 +29,12 @@ exports.definition = {
|
|
|
29
29
|
outputs: {
|
|
30
30
|
properties: {
|
|
31
31
|
body: {
|
|
32
|
-
type:
|
|
32
|
+
type: types_1.AutomationIOType.OBJECT,
|
|
33
33
|
description: "Body of the request which hit the webhook",
|
|
34
34
|
},
|
|
35
35
|
},
|
|
36
36
|
required: ["body"],
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
|
-
type:
|
|
39
|
+
type: types_1.AutomationStepType.TRIGGER,
|
|
40
40
|
};
|
|
@@ -69,10 +69,17 @@ function generateSchema(schema, table, tables, oldTable = null, renamed) {
|
|
|
69
69
|
if (!relatedTable) {
|
|
70
70
|
throw "Referenced table doesn't exist";
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
const relatedPrimary = relatedTable.primary[0];
|
|
73
|
+
const externalType = relatedTable.schema[relatedPrimary].externalType;
|
|
74
|
+
if (externalType) {
|
|
75
|
+
schema.specificType(column.foreignKey, externalType);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
schema.integer(column.foreignKey).unsigned();
|
|
79
|
+
}
|
|
73
80
|
schema
|
|
74
81
|
.foreign(column.foreignKey)
|
|
75
|
-
.references(`${tableName}.${
|
|
82
|
+
.references(`${tableName}.${relatedPrimary}`);
|
|
76
83
|
}
|
|
77
84
|
break;
|
|
78
85
|
}
|
|
@@ -29,11 +29,11 @@ const firebase_1 = __importDefault(require("./firebase"));
|
|
|
29
29
|
const redis_1 = __importDefault(require("./redis"));
|
|
30
30
|
const snowflake_1 = __importDefault(require("./snowflake"));
|
|
31
31
|
const oracle_1 = __importDefault(require("./oracle"));
|
|
32
|
-
const plugin_1 = require("../api/controllers/plugin");
|
|
33
32
|
const types_1 = require("@budibase/types");
|
|
34
33
|
const fileSystem_1 = require("../utilities/fileSystem");
|
|
35
34
|
const environment_1 = __importDefault(require("../environment"));
|
|
36
35
|
const lodash_1 = require("lodash");
|
|
36
|
+
const sdk_1 = __importDefault(require("../sdk"));
|
|
37
37
|
const DEFINITIONS = {
|
|
38
38
|
[types_1.SourceName.POSTGRES]: postgres_1.default.schema,
|
|
39
39
|
[types_1.SourceName.DYNAMODB]: dynamodb_1.default.schema,
|
|
@@ -91,7 +91,7 @@ function getDefinitions() {
|
|
|
91
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
92
|
const pluginSchemas = {};
|
|
93
93
|
if (environment_1.default.SELF_HOSTED) {
|
|
94
|
-
const plugins = yield
|
|
94
|
+
const plugins = yield sdk_1.default.plugins.fetch(types_1.PluginType.DATASOURCE);
|
|
95
95
|
// extract the actual schema from each custom
|
|
96
96
|
for (let plugin of plugins) {
|
|
97
97
|
const sourceId = plugin.name;
|
|
@@ -111,7 +111,7 @@ function getIntegration(integration) {
|
|
|
111
111
|
return INTEGRATIONS[integration];
|
|
112
112
|
}
|
|
113
113
|
if (environment_1.default.SELF_HOSTED) {
|
|
114
|
-
const plugins = yield
|
|
114
|
+
const plugins = yield sdk_1.default.plugins.fetch(types_1.PluginType.DATASOURCE);
|
|
115
115
|
for (let plugin of plugins) {
|
|
116
116
|
if (plugin.name === integration) {
|
|
117
117
|
// need to use commonJS require due to its dynamic runtime nature
|
|
@@ -37,6 +37,7 @@ const usageQuotas_1 = require("./usageQuotas");
|
|
|
37
37
|
const syncApps = __importStar(require("./usageQuotas/syncApps"));
|
|
38
38
|
const syncRows = __importStar(require("./usageQuotas/syncRows"));
|
|
39
39
|
const syncPlugins = __importStar(require("./usageQuotas/syncPlugins"));
|
|
40
|
+
const syncUsers = __importStar(require("./usageQuotas/syncUsers"));
|
|
40
41
|
/**
|
|
41
42
|
* Synchronise quotas to the state of the db.
|
|
42
43
|
*/
|
|
@@ -45,6 +46,7 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
45
46
|
yield syncApps.run();
|
|
46
47
|
yield syncRows.run();
|
|
47
48
|
yield syncPlugins.run();
|
|
49
|
+
yield syncUsers.run();
|
|
48
50
|
}));
|
|
49
51
|
});
|
|
50
52
|
exports.run = run;
|
|
@@ -18,7 +18,6 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
18
18
|
const devApps = yield backend_core_1.db.getAllApps({ dev: true });
|
|
19
19
|
const appCount = devApps ? devApps.length : 0;
|
|
20
20
|
// sync app count
|
|
21
|
-
const tenantId = backend_core_1.tenancy.getTenantId();
|
|
22
21
|
console.log(`Syncing app count: ${appCount}`);
|
|
23
22
|
yield pro_1.quotas.setUsage(appCount, types_1.StaticQuotaName.APPS, types_1.QuotaUsageType.STATIC);
|
|
24
23
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.run = void 0;
|
|
13
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
+
const pro_1 = require("@budibase/pro");
|
|
15
|
+
const types_1 = require("@budibase/types");
|
|
16
|
+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const userCount = yield backend_core_1.users.getUserCount();
|
|
18
|
+
console.log(`Syncing user count: ${userCount}`);
|
|
19
|
+
yield pro_1.quotas.setUsage(userCount, types_1.StaticQuotaName.USERS, types_1.QuotaUsageType.STATIC);
|
|
20
|
+
});
|
|
21
|
+
exports.run = run;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.streamExportApp = exports.
|
|
15
|
+
exports.streamExportApp = exports.exportApp = exports.exportDB = void 0;
|
|
16
16
|
const backend_core_1 = require("@budibase/backend-core");
|
|
17
17
|
const budibaseDir_1 = require("../../../utilities/budibaseDir");
|
|
18
18
|
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
@@ -135,40 +135,6 @@ function exportApp(appId, config) {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
exports.exportApp = exportApp;
|
|
138
|
-
/**
|
|
139
|
-
* Export all apps + global DB (if supplied) to a single tarball, this includes
|
|
140
|
-
* the attachments for each app as well.
|
|
141
|
-
* @param {object[]} appMetadata The IDs and names of apps to export.
|
|
142
|
-
* @param {string} globalDbContents The contents of the global DB to export as well.
|
|
143
|
-
* @return {string} The path to the tarball.
|
|
144
|
-
*/
|
|
145
|
-
function exportMultipleApps(appMetadata, globalDbContents) {
|
|
146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
const tmpPath = (0, path_1.join)((0, budibaseDir_1.budibaseTempDir)(), uuid());
|
|
148
|
-
fs_1.default.mkdirSync(tmpPath);
|
|
149
|
-
let exportPromises = [];
|
|
150
|
-
// export each app to a directory, then move it into the complete export
|
|
151
|
-
const exportAndMove = (appId, appName) => __awaiter(this, void 0, void 0, function* () {
|
|
152
|
-
const path = yield exportApp(appId);
|
|
153
|
-
yield fs_1.default.promises.rename(path, (0, path_1.join)(tmpPath, appName));
|
|
154
|
-
});
|
|
155
|
-
for (let metadata of appMetadata) {
|
|
156
|
-
exportPromises.push(exportAndMove(metadata.appId, metadata.name));
|
|
157
|
-
}
|
|
158
|
-
// wait for all exports to finish
|
|
159
|
-
yield Promise.all(exportPromises);
|
|
160
|
-
// add the global DB contents
|
|
161
|
-
if (globalDbContents) {
|
|
162
|
-
fs_1.default.writeFileSync((0, path_1.join)(tmpPath, constants_2.GLOBAL_DB_EXPORT_FILE), globalDbContents);
|
|
163
|
-
}
|
|
164
|
-
const appNames = appMetadata.map(metadata => metadata.name);
|
|
165
|
-
const tarPath = tarFilesToTmp(tmpPath, [...appNames, constants_2.GLOBAL_DB_EXPORT_FILE]);
|
|
166
|
-
// clear up the tmp path now tarball generated
|
|
167
|
-
fs_1.default.rmSync(tmpPath, { recursive: true, force: true });
|
|
168
|
-
return tarPath;
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
exports.exportMultipleApps = exportMultipleApps;
|
|
172
138
|
/**
|
|
173
139
|
* Streams a backup of the database state for an app
|
|
174
140
|
* @param {string} appId The ID of the app which is to be backed up.
|
package/dist/sdk/index.js
CHANGED
|
@@ -11,6 +11,7 @@ const datasources_1 = __importDefault(require("./app/datasources"));
|
|
|
11
11
|
const queries_1 = __importDefault(require("./app/queries"));
|
|
12
12
|
const rows_1 = __importDefault(require("./app/rows"));
|
|
13
13
|
const users_1 = __importDefault(require("./users"));
|
|
14
|
+
const plugins_1 = __importDefault(require("./plugins"));
|
|
14
15
|
const sdk = {
|
|
15
16
|
backups: backups_1.default,
|
|
16
17
|
tables: tables_1.default,
|
|
@@ -20,6 +21,7 @@ const sdk = {
|
|
|
20
21
|
users: users_1.default,
|
|
21
22
|
datasources: datasources_1.default,
|
|
22
23
|
queries: queries_1.default,
|
|
24
|
+
plugins: plugins_1.default,
|
|
23
25
|
};
|
|
24
26
|
// default export for TS
|
|
25
27
|
exports.default = sdk;
|
|
@@ -22,18 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const authorized_1 = __importDefault(require("../../middleware/authorized"));
|
|
32
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
33
|
-
const router = new router_1.default();
|
|
34
|
-
router
|
|
35
|
-
.get("/api/cloud/export", (0, authorized_1.default)(backend_core_1.permissions.BUILDER), controller.exportApps)
|
|
36
|
-
// has to be public, only run if apps don't exist
|
|
37
|
-
.post("/api/cloud/import", controller.importApps)
|
|
38
|
-
.get("/api/cloud/import/complete", controller.hasBeenImported);
|
|
39
|
-
exports.default = router;
|
|
26
|
+
const plugins = __importStar(require("./plugins"));
|
|
27
|
+
exports.default = Object.assign({}, plugins);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
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.processUploaded = exports.fetch = void 0;
|
|
16
|
+
const types_1 = require("@budibase/types");
|
|
17
|
+
const backend_core_1 = require("@budibase/backend-core");
|
|
18
|
+
const file_1 = require("../../api/controllers/plugin/file");
|
|
19
|
+
const environment_1 = __importDefault(require("../../environment"));
|
|
20
|
+
const websockets_1 = require("../../websockets");
|
|
21
|
+
const pro_1 = require("@budibase/pro");
|
|
22
|
+
function fetch(type) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const db = backend_core_1.tenancy.getGlobalDB();
|
|
25
|
+
const response = yield db.allDocs(backend_core_1.db.getPluginParams(null, {
|
|
26
|
+
include_docs: true,
|
|
27
|
+
}));
|
|
28
|
+
let plugins = response.rows.map((row) => row.doc);
|
|
29
|
+
plugins = backend_core_1.objectStore.enrichPluginURLs(plugins);
|
|
30
|
+
if (type) {
|
|
31
|
+
return plugins.filter((plugin) => { var _a; return ((_a = plugin.schema) === null || _a === void 0 ? void 0 : _a.type) === type; });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return plugins;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.fetch = fetch;
|
|
39
|
+
function processUploaded(plugin, source) {
|
|
40
|
+
var _a;
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const { metadata, directory } = yield (0, file_1.fileUpload)(plugin);
|
|
43
|
+
backend_core_1.plugins.validate(metadata === null || metadata === void 0 ? void 0 : metadata.schema);
|
|
44
|
+
// Only allow components in cloud
|
|
45
|
+
if (!environment_1.default.SELF_HOSTED && ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.schema) === null || _a === void 0 ? void 0 : _a.type) !== types_1.PluginType.COMPONENT) {
|
|
46
|
+
throw new Error("Only component plugins are supported outside of self-host");
|
|
47
|
+
}
|
|
48
|
+
const doc = yield pro_1.sdk.plugins.storePlugin(metadata, directory, source);
|
|
49
|
+
websockets_1.clientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash });
|
|
50
|
+
return doc;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.processUploaded = processUploaded;
|
|
@@ -52,8 +52,8 @@ const string_templates_1 = require("@budibase/string-templates");
|
|
|
52
52
|
const fp_1 = require("lodash/fp");
|
|
53
53
|
const sdkUtils = __importStar(require("../sdk/utils"));
|
|
54
54
|
const environment_1 = __importDefault(require("../environment"));
|
|
55
|
-
const FILTER_STEP_ID = actions.
|
|
56
|
-
const LOOP_STEP_ID = actions.
|
|
55
|
+
const FILTER_STEP_ID = actions.BUILTIN_ACTION_DEFINITIONS.FILTER.stepId;
|
|
56
|
+
const LOOP_STEP_ID = actions.BUILTIN_ACTION_DEFINITIONS.LOOP.stepId;
|
|
57
57
|
const CRON_STEP_ID = triggerInfo_1.definitions.CRON.stepId;
|
|
58
58
|
const STOPPED_STATUS = { success: true, status: types_1.AutomationStatus.STOPPED };
|
|
59
59
|
function getLoopIterations(loopStep, input) {
|