@budibase/server 2.5.6-alpha.9 → 2.5.7
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.7f9a008b.css +6 -0
- package/builder/assets/index.f02eef32.js +1817 -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
|
@@ -1,40 +0,0 @@
|
|
|
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.error = exports.alert = exports.log = void 0;
|
|
13
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
14
|
-
function log(ctx) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
const body = ctx.request.body;
|
|
17
|
-
console.trace(body.message, body.data);
|
|
18
|
-
console.debug(body.message, body.data);
|
|
19
|
-
console.info(body.message, body.data);
|
|
20
|
-
console.warn(body.message, body.data);
|
|
21
|
-
console.error(body.message, body.data);
|
|
22
|
-
ctx.status = 204;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
exports.log = log;
|
|
26
|
-
function alert(ctx) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
const body = ctx.request.body;
|
|
29
|
-
backend_core_1.logging.logAlert(body.message, new Error(body.message));
|
|
30
|
-
ctx.status = 204;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
exports.alert = alert;
|
|
34
|
-
function error(ctx) {
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const body = ctx.request.body;
|
|
37
|
-
throw new Error(body.message);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
exports.error = error;
|
package/dist/api/routes/ops.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.errorValidator = exports.logsValidator = void 0;
|
|
30
|
-
const router_1 = __importDefault(require("@koa/router"));
|
|
31
|
-
const controller = __importStar(require("../controllers/ops"));
|
|
32
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
33
|
-
const joi_1 = __importDefault(require("joi"));
|
|
34
|
-
function logsValidator() {
|
|
35
|
-
return backend_core_1.middleware.joiValidator.body(joi_1.default.object({
|
|
36
|
-
message: joi_1.default.string().required(),
|
|
37
|
-
data: joi_1.default.object(),
|
|
38
|
-
}));
|
|
39
|
-
}
|
|
40
|
-
exports.logsValidator = logsValidator;
|
|
41
|
-
function errorValidator() {
|
|
42
|
-
return backend_core_1.middleware.joiValidator.body(joi_1.default.object({
|
|
43
|
-
message: joi_1.default.string().required(),
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
exports.errorValidator = errorValidator;
|
|
47
|
-
const router = new router_1.default();
|
|
48
|
-
router
|
|
49
|
-
.post("/api/ops/log", logsValidator(), controller.log)
|
|
50
|
-
.post("/api/ops/error", errorValidator(), controller.error)
|
|
51
|
-
.post("/api/ops/alert", errorValidator(), controller.alert);
|
|
52
|
-
exports.default = router;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./processors"), exports);
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.init = void 0;
|
|
7
|
-
const syncUsers_1 = __importDefault(require("./syncUsers"));
|
|
8
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
9
|
-
let started = false;
|
|
10
|
-
function init(updateCb) {
|
|
11
|
-
if (started) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const processors = [(0, syncUsers_1.default)(updateCb)];
|
|
15
|
-
backend_core_1.docUpdates.init(processors);
|
|
16
|
-
started = true;
|
|
17
|
-
}
|
|
18
|
-
exports.init = init;
|
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
13
|
-
const pro_1 = require("@budibase/pro");
|
|
14
|
-
const types_1 = require("@budibase/types");
|
|
15
|
-
const sync_1 = require("../../sdk/app/applications/sync");
|
|
16
|
-
function process(updateCb) {
|
|
17
|
-
const processor = (update) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
var _a;
|
|
19
|
-
try {
|
|
20
|
-
const docId = update.id;
|
|
21
|
-
const isGroup = docId.startsWith(backend_core_1.constants.DocumentType.GROUP);
|
|
22
|
-
let userIds;
|
|
23
|
-
if (isGroup) {
|
|
24
|
-
const group = yield pro_1.sdk.groups.get(docId);
|
|
25
|
-
userIds = ((_a = group.users) === null || _a === void 0 ? void 0 : _a.map(user => user._id)) || [];
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
userIds = [docId];
|
|
29
|
-
}
|
|
30
|
-
if (userIds.length > 0) {
|
|
31
|
-
yield (0, sync_1.syncUsersToAllApps)(userIds);
|
|
32
|
-
}
|
|
33
|
-
if (updateCb) {
|
|
34
|
-
updateCb(docId);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch (err) {
|
|
38
|
-
// if something not found - no changes to perform
|
|
39
|
-
if ((err === null || err === void 0 ? void 0 : err.status) === 404) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
backend_core_1.logging.logAlert("Failed to perform user/group app sync", err);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return { events: types_1.UserGroupSyncEvents, processor };
|
|
48
|
-
}
|
|
49
|
-
exports.default = process;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const plugins = __importStar(require("./plugins"));
|
|
27
|
-
exports.default = Object.assign({}, plugins);
|
|
@@ -1,53 +0,0 @@
|
|
|
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;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
7
|
-
const authorized_1 = __importDefault(require("../middleware/authorized"));
|
|
8
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
9
|
-
class ClientAppWebsocket extends websocket_1.default {
|
|
10
|
-
constructor(app, server) {
|
|
11
|
-
super(app, server, "/socket/client", [(0, authorized_1.default)(backend_core_1.permissions.BUILDER)]);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.default = ClientAppWebsocket;
|
package/dist/websockets/grid.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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
|
-
const authorized_1 = __importDefault(require("../middleware/authorized"));
|
|
16
|
-
const websocket_1 = __importDefault(require("./websocket"));
|
|
17
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
18
|
-
class GridSocket extends websocket_1.default {
|
|
19
|
-
constructor(app, server) {
|
|
20
|
-
super(app, server, "/socket/grid", [(0, authorized_1.default)(backend_core_1.permissions.BUILDER)]);
|
|
21
|
-
this.io.on("connection", socket => {
|
|
22
|
-
const user = socket.data.user;
|
|
23
|
-
console.log(`Spreadsheet user connected: ${user === null || user === void 0 ? void 0 : user.id}`);
|
|
24
|
-
// Socket state
|
|
25
|
-
let currentRoom;
|
|
26
|
-
// Initial identification of connected spreadsheet
|
|
27
|
-
socket.on("select-table", (tableId, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
// Leave current room
|
|
29
|
-
if (currentRoom) {
|
|
30
|
-
socket.to(currentRoom).emit("user-disconnect", socket.data.user);
|
|
31
|
-
socket.leave(currentRoom);
|
|
32
|
-
}
|
|
33
|
-
// Join new room
|
|
34
|
-
currentRoom = tableId;
|
|
35
|
-
socket.join(currentRoom);
|
|
36
|
-
socket.to(currentRoom).emit("user-update", socket.data.user);
|
|
37
|
-
// Reply with all users in current room
|
|
38
|
-
const sockets = yield this.io.in(currentRoom).fetchSockets();
|
|
39
|
-
callback({
|
|
40
|
-
users: sockets.map(socket => socket.data.user),
|
|
41
|
-
id: user.id,
|
|
42
|
-
});
|
|
43
|
-
}));
|
|
44
|
-
// Handle users selecting a new cell
|
|
45
|
-
socket.on("select-cell", cellId => {
|
|
46
|
-
socket.data.user.selectedCellId = cellId;
|
|
47
|
-
if (currentRoom) {
|
|
48
|
-
socket.to(currentRoom).emit("user-update", socket.data.user);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
// Disconnection cleanup
|
|
52
|
-
socket.on("disconnect", () => {
|
|
53
|
-
if (currentRoom) {
|
|
54
|
-
socket.to(currentRoom).emit("user-disconnect", socket.data.user);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.default = GridSocket;
|
package/dist/websockets/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.gridSocket = exports.clientAppSocket = exports.initialise = void 0;
|
|
7
|
-
const grid_1 = __importDefault(require("./grid"));
|
|
8
|
-
const client_1 = __importDefault(require("./client"));
|
|
9
|
-
let clientAppSocket;
|
|
10
|
-
exports.clientAppSocket = clientAppSocket;
|
|
11
|
-
let gridSocket;
|
|
12
|
-
exports.gridSocket = gridSocket;
|
|
13
|
-
const initialise = (app, server) => {
|
|
14
|
-
exports.clientAppSocket = clientAppSocket = new client_1.default(app, server);
|
|
15
|
-
exports.gridSocket = gridSocket = new grid_1.default(app, server);
|
|
16
|
-
};
|
|
17
|
-
exports.initialise = initialise;
|
|
@@ -1,78 +0,0 @@
|
|
|
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
|
-
const socket_io_1 = require("socket.io");
|
|
16
|
-
const http_1 = __importDefault(require("http"));
|
|
17
|
-
const cookies_1 = __importDefault(require("cookies"));
|
|
18
|
-
const koa_useragent_1 = require("koa-useragent");
|
|
19
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
20
|
-
const currentapp_1 = __importDefault(require("../middleware/currentapp"));
|
|
21
|
-
class Socket {
|
|
22
|
-
constructor(app, server, path, additionalMiddlewares) {
|
|
23
|
-
this.io = new socket_io_1.Server(server, {
|
|
24
|
-
path,
|
|
25
|
-
});
|
|
26
|
-
// Attach default middlewares
|
|
27
|
-
const authenticate = backend_core_1.auth.buildAuthMiddleware([], {
|
|
28
|
-
publicAllowed: true,
|
|
29
|
-
});
|
|
30
|
-
const middlewares = [
|
|
31
|
-
koa_useragent_1.userAgent,
|
|
32
|
-
authenticate,
|
|
33
|
-
currentapp_1.default,
|
|
34
|
-
...(additionalMiddlewares || []),
|
|
35
|
-
];
|
|
36
|
-
// Apply middlewares
|
|
37
|
-
this.io.use((socket, next) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
// Build fake koa context
|
|
39
|
-
const res = new http_1.default.ServerResponse(socket.request);
|
|
40
|
-
const ctx = Object.assign(Object.assign({}, app.createContext(socket.request, res)), {
|
|
41
|
-
// Additional overrides needed to make our middlewares work with this
|
|
42
|
-
// fake koa context
|
|
43
|
-
cookies: new cookies_1.default(socket.request, res), get: (field) => socket.request.headers[field], throw: (code, message) => {
|
|
44
|
-
throw new Error(message);
|
|
45
|
-
},
|
|
46
|
-
// Needed for koa-useragent middleware
|
|
47
|
-
headers: socket.request.headers, header: socket.request.headers,
|
|
48
|
-
// We don't really care about the path since it will never contain
|
|
49
|
-
// an app ID
|
|
50
|
-
path: "/socket" });
|
|
51
|
-
// Run all koa middlewares
|
|
52
|
-
try {
|
|
53
|
-
for (let [idx, middleware] of middlewares.entries()) {
|
|
54
|
-
yield middleware(ctx, () => {
|
|
55
|
-
if (idx === middlewares.length - 1) {
|
|
56
|
-
// Middlewares are finished.
|
|
57
|
-
// Extract some data from our enriched koa context to persist
|
|
58
|
-
// as metadata for the socket
|
|
59
|
-
socket.data.user = {
|
|
60
|
-
id: ctx.user._id,
|
|
61
|
-
email: ctx.user.email,
|
|
62
|
-
};
|
|
63
|
-
next();
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
next(error);
|
|
70
|
-
}
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
// Emit an event to all sockets
|
|
74
|
-
emit(event, payload) {
|
|
75
|
-
this.io.sockets.emit(event, payload);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.default = Socket;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Ctx } from "@budibase/types"
|
|
2
|
-
import { logging } from "@budibase/backend-core"
|
|
3
|
-
|
|
4
|
-
interface LogRequest {
|
|
5
|
-
message: string
|
|
6
|
-
data?: any
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface ErrorRequest {
|
|
10
|
-
message: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function log(ctx: Ctx<LogRequest>) {
|
|
14
|
-
const body = ctx.request.body
|
|
15
|
-
console.trace(body.message, body.data)
|
|
16
|
-
console.debug(body.message, body.data)
|
|
17
|
-
console.info(body.message, body.data)
|
|
18
|
-
console.warn(body.message, body.data)
|
|
19
|
-
console.error(body.message, body.data)
|
|
20
|
-
ctx.status = 204
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function alert(ctx: Ctx<ErrorRequest>) {
|
|
24
|
-
const body = ctx.request.body
|
|
25
|
-
logging.logAlert(body.message, new Error(body.message))
|
|
26
|
-
ctx.status = 204
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function error(ctx: Ctx<ErrorRequest>) {
|
|
30
|
-
const body = ctx.request.body
|
|
31
|
-
throw new Error(body.message)
|
|
32
|
-
}
|
package/src/api/routes/ops.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import Router from "@koa/router"
|
|
2
|
-
import * as controller from "../controllers/ops"
|
|
3
|
-
import { middleware } from "@budibase/backend-core"
|
|
4
|
-
import Joi from "joi"
|
|
5
|
-
|
|
6
|
-
export function logsValidator() {
|
|
7
|
-
return middleware.joiValidator.body(
|
|
8
|
-
Joi.object({
|
|
9
|
-
message: Joi.string().required(),
|
|
10
|
-
data: Joi.object(),
|
|
11
|
-
})
|
|
12
|
-
)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function errorValidator() {
|
|
16
|
-
return middleware.joiValidator.body(
|
|
17
|
-
Joi.object({
|
|
18
|
-
message: Joi.string().required(),
|
|
19
|
-
})
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const router: Router = new Router()
|
|
24
|
-
|
|
25
|
-
router
|
|
26
|
-
.post("/api/ops/log", logsValidator(), controller.log)
|
|
27
|
-
.post("/api/ops/error", errorValidator(), controller.error)
|
|
28
|
-
.post("/api/ops/alert", errorValidator(), controller.alert)
|
|
29
|
-
|
|
30
|
-
export default router
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./processors"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import userGroupProcessor from "./syncUsers"
|
|
2
|
-
import { docUpdates } from "@budibase/backend-core"
|
|
3
|
-
|
|
4
|
-
export type UpdateCallback = (docId: string) => void
|
|
5
|
-
let started = false
|
|
6
|
-
|
|
7
|
-
export function init(updateCb?: UpdateCallback) {
|
|
8
|
-
if (started) {
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
const processors = [userGroupProcessor(updateCb)]
|
|
12
|
-
docUpdates.init(processors)
|
|
13
|
-
started = true
|
|
14
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { constants, logging } from "@budibase/backend-core"
|
|
2
|
-
import { sdk as proSdk } from "@budibase/pro"
|
|
3
|
-
import { DocUpdateEvent, UserGroupSyncEvents } from "@budibase/types"
|
|
4
|
-
import { syncUsersToAllApps } from "../../sdk/app/applications/sync"
|
|
5
|
-
import { UpdateCallback } from "./processors"
|
|
6
|
-
|
|
7
|
-
export default function process(updateCb?: UpdateCallback) {
|
|
8
|
-
const processor = async (update: DocUpdateEvent) => {
|
|
9
|
-
try {
|
|
10
|
-
const docId = update.id
|
|
11
|
-
const isGroup = docId.startsWith(constants.DocumentType.GROUP)
|
|
12
|
-
let userIds: string[]
|
|
13
|
-
if (isGroup) {
|
|
14
|
-
const group = await proSdk.groups.get(docId)
|
|
15
|
-
userIds = group.users?.map(user => user._id) || []
|
|
16
|
-
} else {
|
|
17
|
-
userIds = [docId]
|
|
18
|
-
}
|
|
19
|
-
if (userIds.length > 0) {
|
|
20
|
-
await syncUsersToAllApps(userIds)
|
|
21
|
-
}
|
|
22
|
-
if (updateCb) {
|
|
23
|
-
updateCb(docId)
|
|
24
|
-
}
|
|
25
|
-
} catch (err: any) {
|
|
26
|
-
// if something not found - no changes to perform
|
|
27
|
-
if (err?.status === 404) {
|
|
28
|
-
return
|
|
29
|
-
} else {
|
|
30
|
-
logging.logAlert("Failed to perform user/group app sync", err)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return { events: UserGroupSyncEvents, processor }
|
|
35
|
-
}
|