@budibase/server 2.5.6-alpha.9 → 2.5.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.56bca6f6.js +1817 -0
- package/builder/assets/index.7f9a008b.css +6 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/automation.js +7 -13
- package/dist/api/controllers/plugin/index.js +37 -6
- package/dist/api/controllers/table/utils.js +1 -2
- package/dist/api/controllers/user.js +83 -1
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/user.js +1 -0
- package/dist/app.js +13 -4
- package/dist/automations/actions.js +6 -32
- package/dist/automations/index.js +2 -3
- 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/elasticApm.js +14 -0
- package/dist/environment.js +1 -0
- package/dist/events/index.js +0 -3
- package/dist/integrations/index.js +3 -3
- package/dist/integrations/microsoftSqlServer.js +2 -5
- package/dist/integrations/mysql.js +3 -5
- package/dist/integrations/postgres.js +5 -7
- package/dist/integrations/redis.js +0 -7
- package/dist/integrations/rest.js +0 -4
- package/dist/migrations/functions/usageQuotas/syncApps.js +1 -1
- package/dist/migrations/functions/usageQuotas/syncRows.js +2 -1
- package/dist/package.json +15 -15
- package/dist/sdk/app/applications/sync.js +23 -117
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/users/utils.js +4 -21
- package/dist/startup.js +28 -31
- package/dist/threads/automation.js +5 -16
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/plugin.js +23 -33
- package/dist/utilities/global.js +12 -17
- package/dist/watch.js +2 -2
- package/dist/websocket.js +22 -0
- package/jest.config.ts +3 -3
- package/nodemon.json +3 -7
- package/package.json +16 -16
- package/scripts/dev/manage.js +0 -2
- package/scripts/integrations/mssql/data/entrypoint.sh +0 -1
- package/scripts/integrations/mssql/data/setup.sql +17 -17
- package/scripts/integrations/mysql/init.sql +1 -1
- package/scripts/integrations/postgres/init.sql +0 -1
- package/scripts/likeCypress.ts +35 -0
- package/src/api/controllers/automation.ts +6 -12
- package/src/api/controllers/plugin/index.ts +45 -8
- package/src/api/controllers/row/internal.ts +10 -9
- package/src/api/controllers/row/utils.ts +2 -2
- package/src/api/controllers/table/utils.ts +1 -2
- package/src/api/controllers/user.ts +96 -10
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/tests/automation.spec.js +4 -7
- package/src/api/routes/tests/user.spec.js +37 -48
- package/src/api/routes/user.ts +5 -0
- package/src/app.ts +15 -4
- package/src/automations/actions.ts +24 -56
- package/src/automations/index.ts +1 -1
- package/src/automations/steps/bash.ts +7 -10
- package/src/automations/steps/createRow.ts +12 -15
- package/src/automations/steps/delay.ts +4 -6
- package/src/automations/steps/deleteRow.ts +9 -12
- package/src/automations/steps/discord.ts +8 -10
- package/src/automations/steps/executeQuery.ts +10 -13
- package/src/automations/steps/executeScript.ts +7 -10
- package/src/automations/steps/filter.ts +6 -8
- package/src/automations/steps/integromat.ts +10 -12
- package/src/automations/steps/loop.ts +10 -16
- package/src/automations/steps/outgoingWebhook.ts +11 -14
- package/src/automations/steps/queryRows.ts +15 -18
- package/src/automations/steps/sendSmtpEmail.ts +9 -11
- package/src/automations/steps/serverLog.ts +4 -6
- package/src/automations/steps/slack.ts +6 -8
- package/src/automations/steps/updateRow.ts +12 -15
- package/src/automations/steps/zapier.ts +9 -11
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/triggerInfo/app.ts +5 -8
- package/src/automations/triggerInfo/cron.ts +4 -7
- package/src/automations/triggerInfo/rowDeleted.ts +5 -8
- package/src/automations/triggerInfo/rowSaved.ts +7 -10
- package/src/automations/triggerInfo/rowUpdated.ts +7 -10
- package/src/automations/triggerInfo/webhook.ts +6 -9
- package/src/elasticApm.ts +10 -0
- package/src/environment.ts +1 -0
- package/src/events/index.ts +0 -1
- package/src/integrations/index.ts +3 -3
- package/src/integrations/microsoftSqlServer.ts +2 -5
- package/src/integrations/mysql.ts +3 -5
- package/src/integrations/postgres.ts +5 -7
- package/src/integrations/redis.ts +0 -8
- package/src/integrations/rest.ts +0 -3
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -1
- package/src/migrations/functions/usageQuotas/syncRows.ts +3 -2
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
- package/src/sdk/app/applications/sync.ts +22 -129
- package/src/sdk/index.ts +0 -2
- package/src/sdk/users/tests/utils.spec.ts +32 -1
- package/src/sdk/users/utils.ts +5 -23
- package/src/startup.ts +34 -36
- package/src/tests/jestEnv.ts +1 -0
- package/src/tests/jestSetup.ts +1 -0
- package/src/tests/logging.ts +34 -0
- package/src/tests/utilities/TestConfiguration.ts +0 -28
- package/src/tests/utilities/structures.ts +17 -25
- package/src/threads/automation.ts +6 -18
- package/src/utilities/fileSystem/plugin.ts +4 -13
- package/src/utilities/global.ts +16 -21
- package/src/watch.ts +2 -2
- package/src/websocket.ts +26 -0
- package/tsconfig.json +7 -1
- package/builder/assets/index.5c1a6913.js +0 -1776
- package/builder/assets/index.c0265b74.css +0 -6
- package/dist/api/controllers/ops.js +0 -40
- package/dist/api/routes/ops.js +0 -52
- package/dist/events/docUpdates/index.js +0 -17
- package/dist/events/docUpdates/processors.js +0 -18
- package/dist/events/docUpdates/syncUsers.js +0 -49
- package/dist/sdk/plugins/index.js +0 -27
- package/dist/sdk/plugins/plugins.js +0 -53
- package/dist/websockets/client.js +0 -14
- package/dist/websockets/grid.js +0 -60
- package/dist/websockets/index.js +0 -17
- package/dist/websockets/websocket.js +0 -78
- package/src/api/controllers/ops.ts +0 -32
- package/src/api/routes/ops.ts +0 -30
- package/src/events/docUpdates/index.ts +0 -1
- package/src/events/docUpdates/processors.ts +0 -14
- package/src/events/docUpdates/syncUsers.ts +0 -35
- package/src/sdk/app/applications/tests/sync.spec.ts +0 -137
- package/src/sdk/plugins/index.ts +0 -5
- package/src/sdk/plugins/plugins.ts +0 -41
- package/src/websockets/client.ts +0 -11
- package/src/websockets/grid.ts +0 -55
- package/src/websockets/index.ts +0 -14
- package/src/websockets/websocket.ts +0 -83
package/builder/index.html
CHANGED
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
9
9
|
<link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
|
|
10
10
|
rel="stylesheet" />
|
|
11
|
-
<script type="module" crossorigin src="/builder/assets/index.
|
|
12
|
-
<link rel="stylesheet" href="/builder/assets/index.
|
|
11
|
+
<script type="module" crossorigin src="/builder/assets/index.56bca6f6.js"></script>
|
|
12
|
+
<link rel="stylesheet" href="/builder/assets/index.7f9a008b.css">
|
|
13
13
|
</head>
|
|
14
14
|
|
|
15
15
|
<body id="app">
|
|
@@ -33,6 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.test = exports.trigger = exports.getDefinitionList = exports.getTriggerList = exports.getActionList = exports.clearLogError = exports.logSearch = exports.destroy = exports.find = exports.fetch = exports.update = exports.handleStepEvents = exports.getDeletedSteps = exports.getNewSteps = exports.create = void 0;
|
|
36
|
+
const actions = __importStar(require("../../automations/actions"));
|
|
36
37
|
const triggers = __importStar(require("../../automations/triggers"));
|
|
37
38
|
const utils_1 = require("../../db/utils");
|
|
38
39
|
const utils_2 = require("../../automations/utils");
|
|
@@ -41,15 +42,8 @@ const constants_1 = require("../../constants");
|
|
|
41
42
|
const redis_1 = require("../../utilities/redis");
|
|
42
43
|
const backend_core_1 = require("@budibase/backend-core");
|
|
43
44
|
const pro_1 = require("@budibase/pro");
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return (0, utils_2.removeDeprecated)(yield (0, actions_1.getActionDefinitions)());
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function getTriggerDefinitions() {
|
|
51
|
-
return (0, utils_2.removeDeprecated)(triggers.TRIGGER_DEFINITIONS);
|
|
52
|
-
}
|
|
45
|
+
const ACTION_DEFS = (0, utils_2.removeDeprecated)(actions.ACTION_DEFINITIONS);
|
|
46
|
+
const TRIGGER_DEFS = (0, utils_2.removeDeprecated)(triggers.TRIGGER_DEFINITIONS);
|
|
53
47
|
/*************************
|
|
54
48
|
* *
|
|
55
49
|
* BUILDER FUNCTIONS *
|
|
@@ -240,21 +234,21 @@ function clearLogError(ctx) {
|
|
|
240
234
|
exports.clearLogError = clearLogError;
|
|
241
235
|
function getActionList(ctx) {
|
|
242
236
|
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
ctx.body =
|
|
237
|
+
ctx.body = ACTION_DEFS;
|
|
244
238
|
});
|
|
245
239
|
}
|
|
246
240
|
exports.getActionList = getActionList;
|
|
247
241
|
function getTriggerList(ctx) {
|
|
248
242
|
return __awaiter(this, void 0, void 0, function* () {
|
|
249
|
-
ctx.body =
|
|
243
|
+
ctx.body = TRIGGER_DEFS;
|
|
250
244
|
});
|
|
251
245
|
}
|
|
252
246
|
exports.getTriggerList = getTriggerList;
|
|
253
247
|
function getDefinitionList(ctx) {
|
|
254
248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
249
|
ctx.body = {
|
|
256
|
-
trigger:
|
|
257
|
-
action:
|
|
250
|
+
trigger: TRIGGER_DEFS,
|
|
251
|
+
action: ACTION_DEFS,
|
|
258
252
|
};
|
|
259
253
|
});
|
|
260
254
|
}
|
|
@@ -12,14 +12,30 @@ 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.destroy = exports.fetch = exports.create = exports.upload = void 0;
|
|
15
|
+
exports.processUploadedPlugin = exports.destroy = exports.fetch = exports.create = exports.upload = exports.getPlugins = void 0;
|
|
16
16
|
const uploaders_1 = require("./uploaders");
|
|
17
17
|
const backend_core_1 = require("@budibase/backend-core");
|
|
18
18
|
const types_1 = require("@budibase/types");
|
|
19
19
|
const environment_1 = __importDefault(require("../../../environment"));
|
|
20
|
-
const
|
|
21
|
-
const sdk_1 = __importDefault(require("../../../sdk"));
|
|
20
|
+
const websocket_1 = require("../../../websocket");
|
|
22
21
|
const pro_1 = require("@budibase/pro");
|
|
22
|
+
function getPlugins(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.getPlugins = getPlugins;
|
|
23
39
|
function upload(ctx) {
|
|
24
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
41
|
const plugins = ctx.request.files.file.length > 1
|
|
@@ -29,7 +45,7 @@ function upload(ctx) {
|
|
|
29
45
|
let docs = [];
|
|
30
46
|
// can do single or multiple plugins
|
|
31
47
|
for (let plugin of plugins) {
|
|
32
|
-
const doc = yield
|
|
48
|
+
const doc = yield processUploadedPlugin(plugin, types_1.PluginSource.FILE);
|
|
33
49
|
docs.push(doc);
|
|
34
50
|
}
|
|
35
51
|
ctx.body = {
|
|
@@ -77,7 +93,7 @@ function create(ctx) {
|
|
|
77
93
|
throw new Error("Only component plugins are supported outside of self-host");
|
|
78
94
|
}
|
|
79
95
|
const doc = yield pro_1.sdk.plugins.storePlugin(metadata, directory, source);
|
|
80
|
-
|
|
96
|
+
websocket_1.ClientAppSocket.emit("plugins-update", { name, hash: doc.hash });
|
|
81
97
|
ctx.body = {
|
|
82
98
|
message: "Plugin uploaded successfully",
|
|
83
99
|
plugins: [doc],
|
|
@@ -93,7 +109,7 @@ function create(ctx) {
|
|
|
93
109
|
exports.create = create;
|
|
94
110
|
function fetch(ctx) {
|
|
95
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
ctx.body = yield
|
|
112
|
+
ctx.body = yield getPlugins();
|
|
97
113
|
});
|
|
98
114
|
}
|
|
99
115
|
exports.fetch = fetch;
|
|
@@ -110,3 +126,18 @@ function destroy(ctx) {
|
|
|
110
126
|
});
|
|
111
127
|
}
|
|
112
128
|
exports.destroy = destroy;
|
|
129
|
+
function processUploadedPlugin(plugin, source) {
|
|
130
|
+
var _a;
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const { metadata, directory } = yield (0, uploaders_1.fileUpload)(plugin);
|
|
133
|
+
backend_core_1.plugins.validate(metadata === null || metadata === void 0 ? void 0 : metadata.schema);
|
|
134
|
+
// Only allow components in cloud
|
|
135
|
+
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) {
|
|
136
|
+
throw new Error("Only component plugins are supported outside of self-host");
|
|
137
|
+
}
|
|
138
|
+
const doc = yield pro_1.sdk.plugins.storePlugin(metadata, directory, source);
|
|
139
|
+
websocket_1.ClientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash });
|
|
140
|
+
return doc;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.processUploadedPlugin = processUploadedPlugin;
|
|
@@ -109,8 +109,7 @@ function importToRows(data, table, user = null) {
|
|
|
109
109
|
table = processed.table;
|
|
110
110
|
for (const [fieldName, schema] of Object.entries(table.schema)) {
|
|
111
111
|
// check whether the options need to be updated for inclusion as part of the data import
|
|
112
|
-
if (
|
|
113
|
-
schema.type === constants_1.FieldTypes.ARRAY) &&
|
|
112
|
+
if (schema.type === constants_1.FieldTypes.OPTIONS &&
|
|
114
113
|
row[fieldName] &&
|
|
115
114
|
(!schema.constraints.inclusion ||
|
|
116
115
|
schema.constraints.inclusion.indexOf(row[fieldName]) === -1)) {
|
|
@@ -12,13 +12,95 @@ 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.getFlags = exports.setFlag = exports.findMetadata = exports.destroyMetadata = exports.updateMetadata = exports.updateSelfMetadata = exports.fetchMetadata = void 0;
|
|
15
|
+
exports.getFlags = exports.setFlag = exports.findMetadata = exports.destroyMetadata = exports.updateMetadata = exports.updateSelfMetadata = exports.fetchMetadata = exports.syncUser = void 0;
|
|
16
16
|
const utils_1 = require("../../db/utils");
|
|
17
17
|
const utils_2 = require("../../db/utils");
|
|
18
18
|
const global_1 = require("../../utilities/global");
|
|
19
19
|
const users_1 = require("../../utilities/users");
|
|
20
20
|
const backend_core_1 = require("@budibase/backend-core");
|
|
21
21
|
const sdk_1 = __importDefault(require("../../sdk"));
|
|
22
|
+
function syncUser(ctx) {
|
|
23
|
+
var _a;
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
let deleting = false, user;
|
|
26
|
+
const userId = ctx.params.id;
|
|
27
|
+
const previousUser = (_a = ctx.request.body) === null || _a === void 0 ? void 0 : _a.previousUser;
|
|
28
|
+
try {
|
|
29
|
+
user = (yield (0, global_1.getRawGlobalUser)(userId));
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (err && err.status === 404) {
|
|
33
|
+
user = {};
|
|
34
|
+
deleting = true;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
let previousApps = previousUser
|
|
41
|
+
? Object.keys(previousUser.roles).map(appId => appId)
|
|
42
|
+
: [];
|
|
43
|
+
const roles = deleting ? {} : user.roles;
|
|
44
|
+
// remove props which aren't useful to metadata
|
|
45
|
+
delete user.password;
|
|
46
|
+
delete user.forceResetPassword;
|
|
47
|
+
delete user.roles;
|
|
48
|
+
// run through all production appIDs in the users roles
|
|
49
|
+
let prodAppIds;
|
|
50
|
+
// if they are a builder then get all production app IDs
|
|
51
|
+
if ((user.builder && user.builder.global) || deleting) {
|
|
52
|
+
prodAppIds = yield backend_core_1.db.getProdAppIDs();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
prodAppIds = Object.entries(roles)
|
|
56
|
+
.filter(entry => entry[1] !== backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC)
|
|
57
|
+
.map(([appId]) => appId);
|
|
58
|
+
}
|
|
59
|
+
for (let prodAppId of new Set([...prodAppIds, ...previousApps])) {
|
|
60
|
+
const roleId = roles[prodAppId];
|
|
61
|
+
const deleteFromApp = !roleId;
|
|
62
|
+
const devAppId = backend_core_1.db.getDevelopmentAppID(prodAppId);
|
|
63
|
+
for (let appId of [prodAppId, devAppId]) {
|
|
64
|
+
if (!(yield backend_core_1.db.dbExists(appId))) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
yield backend_core_1.context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const db = backend_core_1.context.getAppDB();
|
|
69
|
+
const metadataId = (0, utils_1.generateUserMetadataID)(userId);
|
|
70
|
+
let metadata;
|
|
71
|
+
try {
|
|
72
|
+
metadata = yield db.get(metadataId);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
if (deleteFromApp) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
metadata = {
|
|
79
|
+
tableId: utils_2.InternalTables.USER_METADATA,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (deleteFromApp) {
|
|
83
|
+
yield db.remove(metadata);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
// assign the roleId for the metadata doc
|
|
87
|
+
if (roleId) {
|
|
88
|
+
metadata.roleId = roleId;
|
|
89
|
+
}
|
|
90
|
+
let combined = sdk_1.default.users.combineMetadataAndUser(user, metadata);
|
|
91
|
+
// if its null then there was no updates required
|
|
92
|
+
if (combined) {
|
|
93
|
+
yield db.put(combined);
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
ctx.body = {
|
|
99
|
+
message: "User synced.",
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
exports.syncUser = syncUser;
|
|
22
104
|
function fetchMetadata(ctx) {
|
|
23
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
106
|
const global = yield (0, global_1.getGlobalUsers)();
|
package/dist/api/routes/index.js
CHANGED
|
@@ -31,7 +31,6 @@ const dev_1 = __importDefault(require("./dev"));
|
|
|
31
31
|
const cloud_1 = __importDefault(require("./cloud"));
|
|
32
32
|
const migrations_1 = __importDefault(require("./migrations"));
|
|
33
33
|
const plugin_1 = __importDefault(require("./plugin"));
|
|
34
|
-
const ops_1 = __importDefault(require("./ops"));
|
|
35
34
|
const pro_1 = require("@budibase/pro");
|
|
36
35
|
var static_1 = require("./static");
|
|
37
36
|
Object.defineProperty(exports, "staticRoutes", { enumerable: true, get: function () { return __importDefault(static_1).default; } });
|
|
@@ -68,7 +67,6 @@ exports.mainRoutes = [
|
|
|
68
67
|
row_1.default,
|
|
69
68
|
migrations_1.default,
|
|
70
69
|
plugin_1.default,
|
|
71
|
-
ops_1.default,
|
|
72
70
|
scheduleRoutes,
|
|
73
71
|
environmentVariableRoutes,
|
|
74
72
|
// these need to be handled last as they still use /api/:tableId
|
package/dist/api/routes/user.js
CHANGED
|
@@ -38,6 +38,7 @@ router
|
|
|
38
38
|
.put("/api/users/metadata", (0, authorized_1.default)(PermissionType.USER, PermissionLevel.WRITE), controller.updateMetadata)
|
|
39
39
|
.post("/api/users/metadata/self", (0, authorized_1.default)(PermissionType.USER, PermissionLevel.WRITE), controller.updateSelfMetadata)
|
|
40
40
|
.delete("/api/users/metadata/:id", (0, authorized_1.default)(PermissionType.USER, PermissionLevel.WRITE), controller.destroyMetadata)
|
|
41
|
+
.post("/api/users/metadata/sync/:id", (0, authorized_1.default)(PermissionType.USER, PermissionLevel.WRITE), controller.syncUser)
|
|
41
42
|
.post("/api/users/flags", (0, authorized_1.default)(PermissionType.USER, PermissionLevel.WRITE), controller.setFlag)
|
|
42
43
|
.get("/api/users/flags", (0, authorized_1.default)(PermissionType.USER, PermissionLevel.READ), controller.getFlags);
|
|
43
44
|
exports.default = router;
|
package/dist/app.js
CHANGED
|
@@ -38,8 +38,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
38
38
|
if (process.env.DD_APM_ENABLED) {
|
|
39
39
|
require("./ddApm");
|
|
40
40
|
}
|
|
41
|
+
if (process.env.ELASTIC_APM_ENABLED) {
|
|
42
|
+
require("./elasticApm");
|
|
43
|
+
}
|
|
41
44
|
// need to load environment first
|
|
42
45
|
const environment_1 = __importDefault(require("./environment"));
|
|
46
|
+
// enable APM if configured
|
|
47
|
+
if (process.env.ELASTIC_APM_ENABLED) {
|
|
48
|
+
const apm = require("elastic-apm-node").start({
|
|
49
|
+
serviceName: process.env.SERVICE,
|
|
50
|
+
environment: process.env.BUDIBASE_ENVIRONMENT,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
43
53
|
const db = __importStar(require("./db"));
|
|
44
54
|
db.init();
|
|
45
55
|
const koa_1 = __importDefault(require("koa"));
|
|
@@ -49,8 +59,8 @@ const api = __importStar(require("./api"));
|
|
|
49
59
|
const automations = __importStar(require("./automations"));
|
|
50
60
|
const threads_1 = require("./threads");
|
|
51
61
|
const redis = __importStar(require("./utilities/redis"));
|
|
52
|
-
const websockets_1 = require("./websockets");
|
|
53
62
|
const backend_core_1 = require("@budibase/backend-core");
|
|
63
|
+
const websocket_1 = require("./websocket");
|
|
54
64
|
const startup_1 = require("./startup");
|
|
55
65
|
const Sentry = require("@sentry/node");
|
|
56
66
|
const destroyable = require("server-destroy");
|
|
@@ -70,8 +80,7 @@ app.use((0, koa_body_1.default)({
|
|
|
70
80
|
enableTypes: ["json", "form", "text"],
|
|
71
81
|
parsedMethods: ["POST", "PUT", "PATCH", "DELETE"],
|
|
72
82
|
}));
|
|
73
|
-
app.use(backend_core_1.middleware.
|
|
74
|
-
app.use(backend_core_1.middleware.pino);
|
|
83
|
+
app.use(backend_core_1.middleware.logging);
|
|
75
84
|
app.use(userAgent);
|
|
76
85
|
if (environment_1.default.isProd()) {
|
|
77
86
|
environment_1.default._set("NODE_ENV", "production");
|
|
@@ -87,7 +96,7 @@ if (environment_1.default.isProd()) {
|
|
|
87
96
|
}
|
|
88
97
|
const server = http_1.default.createServer(app.callback());
|
|
89
98
|
destroyable(server);
|
|
90
|
-
(0,
|
|
99
|
+
(0, websocket_1.initialise)(server);
|
|
91
100
|
let shuttingDown = false, errCode = 0;
|
|
92
101
|
server.on("close", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
102
|
// already in process
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.getAction = exports.
|
|
38
|
+
exports.getAction = exports.ACTION_DEFINITIONS = void 0;
|
|
39
39
|
const sendSmtpEmail = __importStar(require("./steps/sendSmtpEmail"));
|
|
40
40
|
const createRow = __importStar(require("./steps/createRow"));
|
|
41
41
|
const updateRow = __importStar(require("./steps/updateRow"));
|
|
@@ -53,9 +53,6 @@ const delay = __importStar(require("./steps/delay"));
|
|
|
53
53
|
const queryRow = __importStar(require("./steps/queryRows"));
|
|
54
54
|
const loop = __importStar(require("./steps/loop"));
|
|
55
55
|
const environment_1 = __importDefault(require("../environment"));
|
|
56
|
-
const types_1 = require("@budibase/types");
|
|
57
|
-
const sdk_1 = __importDefault(require("../sdk"));
|
|
58
|
-
const fileSystem_1 = require("../utilities/fileSystem");
|
|
59
56
|
const ACTION_IMPLS = {
|
|
60
57
|
SEND_EMAIL_SMTP: sendSmtpEmail.run,
|
|
61
58
|
CREATE_ROW: createRow.run,
|
|
@@ -74,7 +71,7 @@ const ACTION_IMPLS = {
|
|
|
74
71
|
zapier: zapier.run,
|
|
75
72
|
integromat: integromat.run,
|
|
76
73
|
};
|
|
77
|
-
exports.
|
|
74
|
+
exports.ACTION_DEFINITIONS = {
|
|
78
75
|
SEND_EMAIL_SMTP: sendSmtpEmail.definition,
|
|
79
76
|
CREATE_ROW: createRow.definition,
|
|
80
77
|
UPDATE_ROW: updateRow.definition,
|
|
@@ -101,36 +98,13 @@ if (environment_1.default.SELF_HOSTED) {
|
|
|
101
98
|
// @ts-ignore
|
|
102
99
|
ACTION_IMPLS["EXECUTE_BASH"] = bash.run;
|
|
103
100
|
// @ts-ignore
|
|
104
|
-
exports.
|
|
101
|
+
exports.ACTION_DEFINITIONS["EXECUTE_BASH"] = bash.definition;
|
|
105
102
|
}
|
|
106
|
-
function getActionDefinitions() {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
const actionDefinitions = exports.BUILTIN_ACTION_DEFINITIONS;
|
|
109
|
-
if (environment_1.default.SELF_HOSTED) {
|
|
110
|
-
const plugins = yield sdk_1.default.plugins.fetch(types_1.PluginType.AUTOMATION);
|
|
111
|
-
for (let plugin of plugins) {
|
|
112
|
-
const schema = plugin.schema.schema;
|
|
113
|
-
actionDefinitions[schema.stepId] = Object.assign(Object.assign({}, schema), { custom: true });
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return actionDefinitions;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
exports.getActionDefinitions = getActionDefinitions;
|
|
120
103
|
/* istanbul ignore next */
|
|
121
|
-
function getAction(
|
|
104
|
+
function getAction(actionName) {
|
|
122
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
if (ACTION_IMPLS[
|
|
124
|
-
return ACTION_IMPLS[
|
|
125
|
-
}
|
|
126
|
-
// must be a plugin
|
|
127
|
-
if (environment_1.default.SELF_HOSTED) {
|
|
128
|
-
const plugins = yield sdk_1.default.plugins.fetch(types_1.PluginType.AUTOMATION);
|
|
129
|
-
const found = plugins.find(plugin => plugin.schema.schema.stepId === stepId);
|
|
130
|
-
if (!found) {
|
|
131
|
-
throw new Error(`Unable to find action implementation for "${stepId}"`);
|
|
132
|
-
}
|
|
133
|
-
return (yield (0, fileSystem_1.getAutomationPlugin)(found)).action;
|
|
106
|
+
if (ACTION_IMPLS[actionName] != null) {
|
|
107
|
+
return ACTION_IMPLS[actionName];
|
|
134
108
|
}
|
|
135
109
|
});
|
|
136
110
|
}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getQueues = exports.init = exports.
|
|
12
|
+
exports.getQueues = exports.init = exports.ACTION_DEFINITIONS = exports.TRIGGER_DEFINITIONS = exports.shutdown = exports.automationQueue = void 0;
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
const bullboard_1 = require("./bullboard");
|
|
15
15
|
const triggers_1 = require("./triggers");
|
|
@@ -20,8 +20,7 @@ Object.defineProperty(exports, "shutdown", { enumerable: true, get: function ()
|
|
|
20
20
|
var triggers_2 = require("./triggers");
|
|
21
21
|
Object.defineProperty(exports, "TRIGGER_DEFINITIONS", { enumerable: true, get: function () { return triggers_2.TRIGGER_DEFINITIONS; } });
|
|
22
22
|
var actions_1 = require("./actions");
|
|
23
|
-
Object.defineProperty(exports, "
|
|
24
|
-
Object.defineProperty(exports, "getActionDefinitions", { enumerable: true, get: function () { return actions_1.getActionDefinitions; } });
|
|
23
|
+
Object.defineProperty(exports, "ACTION_DEFINITIONS", { enumerable: true, get: function () { return actions_1.ACTION_DEFINITIONS; } });
|
|
25
24
|
/**
|
|
26
25
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
27
26
|
*/
|
|
@@ -46,7 +46,7 @@ exports.definition = {
|
|
|
46
46
|
tagline: "Execute a bash command",
|
|
47
47
|
icon: "JourneyEvent",
|
|
48
48
|
description: "Run a bash script",
|
|
49
|
-
type:
|
|
49
|
+
type: "ACTION",
|
|
50
50
|
internal: true,
|
|
51
51
|
stepId: types_1.AutomationActionStepId.EXECUTE_BASH,
|
|
52
52
|
inputs: {},
|
|
@@ -54,8 +54,8 @@ exports.definition = {
|
|
|
54
54
|
inputs: {
|
|
55
55
|
properties: {
|
|
56
56
|
code: {
|
|
57
|
-
type:
|
|
58
|
-
customType:
|
|
57
|
+
type: "string",
|
|
58
|
+
customType: "code",
|
|
59
59
|
title: "Code",
|
|
60
60
|
},
|
|
61
61
|
},
|
|
@@ -64,16 +64,16 @@ exports.definition = {
|
|
|
64
64
|
outputs: {
|
|
65
65
|
properties: {
|
|
66
66
|
stdout: {
|
|
67
|
-
type:
|
|
67
|
+
type: "string",
|
|
68
68
|
description: "Standard output of your bash command or script",
|
|
69
69
|
},
|
|
70
70
|
success: {
|
|
71
|
-
type:
|
|
71
|
+
type: "boolean",
|
|
72
72
|
description: "Whether the command was successful",
|
|
73
73
|
},
|
|
74
74
|
},
|
|
75
|
-
required: ["stdout"],
|
|
76
75
|
},
|
|
76
|
+
required: ["stdout"],
|
|
77
77
|
},
|
|
78
78
|
};
|
|
79
79
|
function run({ inputs, context }) {
|
|
@@ -19,7 +19,7 @@ exports.definition = {
|
|
|
19
19
|
tagline: "Create a {{inputs.enriched.table.name}} row",
|
|
20
20
|
icon: "TableRowAddBottom",
|
|
21
21
|
description: "Add a row to your database",
|
|
22
|
-
type:
|
|
22
|
+
type: "ACTION",
|
|
23
23
|
internal: true,
|
|
24
24
|
stepId: types_1.AutomationActionStepId.CREATE_ROW,
|
|
25
25
|
inputs: {},
|
|
@@ -27,14 +27,14 @@ exports.definition = {
|
|
|
27
27
|
inputs: {
|
|
28
28
|
properties: {
|
|
29
29
|
row: {
|
|
30
|
-
type:
|
|
30
|
+
type: "object",
|
|
31
31
|
properties: {
|
|
32
32
|
tableId: {
|
|
33
|
-
type:
|
|
34
|
-
customType:
|
|
33
|
+
type: "string",
|
|
34
|
+
customType: "table",
|
|
35
35
|
},
|
|
36
36
|
},
|
|
37
|
-
customType:
|
|
37
|
+
customType: "row",
|
|
38
38
|
title: "Table",
|
|
39
39
|
required: ["tableId"],
|
|
40
40
|
},
|
|
@@ -44,24 +44,24 @@ exports.definition = {
|
|
|
44
44
|
outputs: {
|
|
45
45
|
properties: {
|
|
46
46
|
row: {
|
|
47
|
-
type:
|
|
48
|
-
customType:
|
|
47
|
+
type: "object",
|
|
48
|
+
customType: "row",
|
|
49
49
|
description: "The new row",
|
|
50
50
|
},
|
|
51
51
|
response: {
|
|
52
|
-
type:
|
|
52
|
+
type: "object",
|
|
53
53
|
description: "The response from the table",
|
|
54
54
|
},
|
|
55
55
|
success: {
|
|
56
|
-
type:
|
|
56
|
+
type: "boolean",
|
|
57
57
|
description: "Whether the row creation was successful",
|
|
58
58
|
},
|
|
59
59
|
id: {
|
|
60
|
-
type:
|
|
60
|
+
type: "string",
|
|
61
61
|
description: "The identifier of the new row",
|
|
62
62
|
},
|
|
63
63
|
revision: {
|
|
64
|
-
type:
|
|
64
|
+
type: "string",
|
|
65
65
|
description: "The revision of the new row",
|
|
66
66
|
},
|
|
67
67
|
},
|
|
@@ -24,7 +24,7 @@ exports.definition = {
|
|
|
24
24
|
inputs: {
|
|
25
25
|
properties: {
|
|
26
26
|
time: {
|
|
27
|
-
type:
|
|
27
|
+
type: "number",
|
|
28
28
|
title: "Delay in milliseconds",
|
|
29
29
|
},
|
|
30
30
|
},
|
|
@@ -33,14 +33,14 @@ exports.definition = {
|
|
|
33
33
|
outputs: {
|
|
34
34
|
properties: {
|
|
35
35
|
success: {
|
|
36
|
-
type:
|
|
36
|
+
type: "boolean",
|
|
37
37
|
description: "Whether the delay was successful",
|
|
38
38
|
},
|
|
39
39
|
},
|
|
40
40
|
required: ["success"],
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
type:
|
|
43
|
+
type: "LOGIC",
|
|
44
44
|
};
|
|
45
45
|
function run({ inputs }) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -19,7 +19,7 @@ exports.definition = {
|
|
|
19
19
|
icon: "TableRowRemoveCenter",
|
|
20
20
|
name: "Delete Row",
|
|
21
21
|
tagline: "Delete a {{inputs.enriched.table.name}} row",
|
|
22
|
-
type:
|
|
22
|
+
type: "ACTION",
|
|
23
23
|
stepId: types_1.AutomationActionStepId.DELETE_ROW,
|
|
24
24
|
internal: true,
|
|
25
25
|
inputs: {},
|
|
@@ -27,12 +27,12 @@ exports.definition = {
|
|
|
27
27
|
inputs: {
|
|
28
28
|
properties: {
|
|
29
29
|
tableId: {
|
|
30
|
-
type:
|
|
31
|
-
customType:
|
|
30
|
+
type: "string",
|
|
31
|
+
customType: "table",
|
|
32
32
|
title: "Table",
|
|
33
33
|
},
|
|
34
34
|
id: {
|
|
35
|
-
type:
|
|
35
|
+
type: "string",
|
|
36
36
|
title: "Row ID",
|
|
37
37
|
},
|
|
38
38
|
},
|
|
@@ -41,16 +41,16 @@ exports.definition = {
|
|
|
41
41
|
outputs: {
|
|
42
42
|
properties: {
|
|
43
43
|
row: {
|
|
44
|
-
type:
|
|
45
|
-
customType:
|
|
44
|
+
type: "object",
|
|
45
|
+
customType: "row",
|
|
46
46
|
description: "The deleted row",
|
|
47
47
|
},
|
|
48
48
|
response: {
|
|
49
|
-
type:
|
|
49
|
+
type: "object",
|
|
50
50
|
description: "The response from the table",
|
|
51
51
|
},
|
|
52
52
|
success: {
|
|
53
|
-
type:
|
|
53
|
+
type: "boolean",
|
|
54
54
|
description: "Whether the deletion was successful",
|
|
55
55
|
},
|
|
56
56
|
},
|
|
@@ -24,26 +24,26 @@ exports.definition = {
|
|
|
24
24
|
description: "Send a message to a Discord server",
|
|
25
25
|
icon: "ri-discord-line",
|
|
26
26
|
stepId: types_1.AutomationActionStepId.discord,
|
|
27
|
-
type:
|
|
27
|
+
type: "ACTION",
|
|
28
28
|
internal: false,
|
|
29
29
|
inputs: {},
|
|
30
30
|
schema: {
|
|
31
31
|
inputs: {
|
|
32
32
|
properties: {
|
|
33
33
|
url: {
|
|
34
|
-
type:
|
|
34
|
+
type: "string",
|
|
35
35
|
title: "Discord Webhook URL",
|
|
36
36
|
},
|
|
37
37
|
username: {
|
|
38
|
-
type:
|
|
38
|
+
type: "string",
|
|
39
39
|
title: "Bot Name",
|
|
40
40
|
},
|
|
41
41
|
avatar_url: {
|
|
42
|
-
type:
|
|
42
|
+
type: "string",
|
|
43
43
|
title: "Bot Avatar URL",
|
|
44
44
|
},
|
|
45
45
|
content: {
|
|
46
|
-
type:
|
|
46
|
+
type: "string",
|
|
47
47
|
title: "Message",
|
|
48
48
|
},
|
|
49
49
|
},
|
|
@@ -52,15 +52,15 @@ exports.definition = {
|
|
|
52
52
|
outputs: {
|
|
53
53
|
properties: {
|
|
54
54
|
httpStatus: {
|
|
55
|
-
type:
|
|
55
|
+
type: "number",
|
|
56
56
|
description: "The HTTP status code of the request",
|
|
57
57
|
},
|
|
58
58
|
response: {
|
|
59
|
-
type:
|
|
59
|
+
type: "string",
|
|
60
60
|
description: "The response from the Discord Webhook",
|
|
61
61
|
},
|
|
62
62
|
success: {
|
|
63
|
-
type:
|
|
63
|
+
type: "boolean",
|
|
64
64
|
description: "Whether the message sent successfully",
|
|
65
65
|
},
|
|
66
66
|
},
|