@budibase/server 1.3.21-alpha.1 → 1.3.21
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/__mocks__/mongodb.ts +1 -1
- package/builder/assets/index.8d12d461.css +6 -0
- package/builder/assets/index.d354271c.js +879 -0
- package/builder/assets/vendor.5e1fe644.css +1 -0
- package/builder/assets/vendor.67dbd8fa.js +248 -0
- package/builder/index.html +4 -2
- package/coverage/clover.xml +390 -451
- package/coverage/coverage-final.json +21 -21
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +8 -41
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +11 -68
- package/coverage/lcov-report/api/controllers/datasource.js.html +34 -73
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +46 -46
- package/coverage/lcov-report/api/controllers/integration.js.html +6 -6
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +12 -207
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +13 -13
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +2 -2
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +9 -9
- package/coverage/lcov-report/api/routes/utils/validators.js.html +12 -75
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +18 -18
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +20 -56
- package/coverage/lcov-report/events/AutomationEmitter.js.html +3 -3
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +46 -46
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +40 -46
- package/coverage/lcov-report/middleware/index.html +15 -15
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +7 -7
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +16 -16
- package/coverage/lcov-report/utilities/index.html +15 -15
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +8 -32
- package/coverage/lcov.info +672 -798
- package/dist/api/controllers/application.js +5 -5
- package/dist/api/controllers/auth.js +0 -9
- package/dist/api/controllers/component.js +1 -14
- package/dist/api/controllers/datasource.js +8 -21
- package/dist/api/controllers/deploy/index.js +8 -1
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +2 -52
- package/dist/api/controllers/static/index.js +0 -1
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/dist/api/controllers/static/templates/preview.hbs +1 -5
- package/dist/api/index.js +1 -1
- package/dist/api/routes/application.js +2 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/public/rows.js +82 -1
- package/dist/api/routes/public/tables.js +1 -1
- package/dist/api/routes/table.js +1 -1
- package/dist/api/routes/utils/validators.js +2 -20
- package/dist/app.js +1 -16
- package/dist/db/utils.js +1 -10
- package/dist/environment.js +0 -1
- package/dist/integrations/airtable.js +129 -126
- package/dist/integrations/arangodb.js +89 -86
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +1 -3
- package/dist/integrations/couchdb.js +83 -80
- package/dist/integrations/dynamodb.js +164 -161
- package/dist/integrations/elasticsearch.js +138 -135
- package/dist/integrations/firebase.js +157 -154
- package/dist/integrations/googlesheets.js +327 -323
- package/dist/integrations/index.js +51 -99
- package/dist/integrations/microsoftSqlServer.js +243 -240
- package/dist/integrations/mongodb.js +242 -239
- package/dist/integrations/mysql.js +219 -215
- package/dist/integrations/oracle.js +322 -318
- package/dist/integrations/postgres.js +265 -262
- package/dist/integrations/redis.js +139 -134
- package/dist/integrations/rest.js +292 -289
- package/dist/integrations/s3.js +64 -61
- package/dist/integrations/snowflake.js +86 -83
- package/dist/middleware/currentapp.js +0 -2
- package/dist/migrations/functions/backfill/global.js +3 -0
- package/dist/migrations/functions/developerQuota.js +49 -0
- package/dist/{api/routes/plugin.js → migrations/functions/publishedAppsQuota.js} +21 -13
- package/dist/{api/controllers/plugin/url.js → migrations/functions/usageQuotas/syncDevelopers.js} +13 -13
- package/dist/{api/controllers/plugin/file.js → migrations/functions/usageQuotas/syncPublishedApps.js} +15 -13
- package/dist/migrations/index.js +10 -0
- package/dist/package.json +6 -9
- package/dist/tests/utilities/TestConfiguration.js +1 -1
- package/dist/threads/query.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +1 -111
- package/dist/utilities/workerRequests.js +0 -4
- package/package.json +7 -10
- package/scripts/dev/manage.js +0 -4
- package/scripts/localdomain.js +1 -3
- package/specs/openapi.json +112 -115
- package/specs/openapi.yaml +94 -96
- package/specs/resources/misc.js +0 -116
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +2 -1
- package/src/api/controllers/auth.js +0 -11
- package/src/api/controllers/component.js +2 -21
- package/src/api/controllers/datasource.js +8 -21
- package/src/api/controllers/deploy/index.ts +6 -1
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/public/mapping/types.ts +0 -8
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.js +1 -66
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -10
- package/src/api/controllers/static/templates/preview.hbs +1 -5
- package/src/api/index.js +1 -1
- package/src/api/routes/application.ts +2 -13
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/public/rows.ts +82 -1
- package/src/api/routes/public/tables.ts +1 -1
- package/src/api/routes/table.js +1 -1
- package/src/api/routes/tests/query.spec.js +25 -8
- package/src/api/routes/tests/user.spec.js +2 -0
- package/src/api/routes/utils/validators.js +5 -26
- package/src/app.ts +2 -25
- package/src/db/utils.js +0 -12
- package/src/definitions/openapi.ts +55 -56
- package/src/environment.js +0 -1
- package/src/integrations/airtable.ts +118 -116
- package/src/integrations/arangodb.ts +89 -87
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +1 -3
- package/src/integrations/couchdb.ts +89 -83
- package/src/integrations/dynamodb.ts +175 -173
- package/src/integrations/elasticsearch.ts +122 -120
- package/src/integrations/firebase.ts +159 -157
- package/src/integrations/googlesheets.ts +338 -328
- package/src/integrations/index.ts +21 -64
- package/src/integrations/microsoftSqlServer.ts +251 -249
- package/src/integrations/mongodb.ts +258 -261
- package/src/integrations/mysql.ts +234 -229
- package/src/integrations/oracle.ts +380 -373
- package/src/integrations/postgres.ts +268 -264
- package/src/integrations/redis.ts +132 -128
- package/src/integrations/rest.ts +329 -324
- package/src/integrations/s3.ts +71 -68
- package/src/integrations/snowflake.ts +82 -80
- package/src/integrations/tests/{airtable.spec.ts → airtable.spec.js} +18 -21
- package/src/integrations/tests/{arangodb.spec.ts → arangodb.spec.js} +9 -12
- package/src/integrations/tests/{couchdb.spec.ts → couchdb.spec.js} +27 -33
- package/src/integrations/tests/{dynamodb.spec.ts → dynamodb.spec.js} +41 -45
- package/src/integrations/tests/{elasticsearch.spec.ts → elasticsearch.spec.js} +21 -22
- package/src/integrations/tests/{firebase.spec.ts → firebase.spec.js} +28 -33
- package/src/integrations/tests/{microsoftSqlServer.spec.ts → microsoftSqlServer.spec.js} +11 -12
- package/src/integrations/tests/{mongo.spec.ts → mongo.spec.js} +35 -46
- package/src/integrations/tests/{mysql.spec.ts → mysql.spec.js} +15 -17
- package/src/integrations/tests/{oracle.spec.ts → oracle.spec.js} +17 -19
- package/src/integrations/tests/{postgres.spec.ts → postgres.spec.js} +17 -19
- package/src/integrations/tests/{redis.spec.ts → redis.spec.js} +18 -27
- package/src/integrations/tests/{rest.spec.ts → rest.spec.js} +14 -22
- package/src/integrations/tests/{s3.spec.ts → s3.spec.js} +8 -10
- package/src/integrations/tests/{sql.spec.ts → sql.spec.js} +177 -228
- package/src/middleware/currentapp.js +0 -2
- package/src/migrations/functions/backfill/global.ts +3 -0
- package/src/migrations/functions/developerQuota.ts +15 -0
- package/src/migrations/functions/publishedAppsQuota.ts +13 -0
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +19 -0
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +21 -0
- package/src/migrations/index.ts +16 -0
- package/src/module.d.ts +0 -2
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +0 -130
- package/src/utilities/workerRequests.js +0 -8
- package/builder/assets/index.c9d3f9e8.js +0 -1005
- package/builder/assets/index.f1b70f52.css +0 -6
- package/dist/api/controllers/plugin/github.js +0 -69
- package/dist/api/controllers/plugin/index.js +0 -200
- package/dist/api/controllers/plugin/npm.js +0 -58
- package/dist/api/controllers/plugin/uploaders.js +0 -11
- package/dist/api/controllers/plugin/utils.js +0 -26
- package/dist/watch.js +0 -77
- package/dist/websocket.js +0 -22
- package/src/api/controllers/plugin/file.ts +0 -15
- package/src/api/controllers/plugin/github.ts +0 -75
- package/src/api/controllers/plugin/index.ts +0 -215
- package/src/api/controllers/plugin/npm.ts +0 -56
- package/src/api/controllers/plugin/uploaders.ts +0 -4
- package/src/api/controllers/plugin/url.ts +0 -12
- package/src/api/controllers/plugin/utils.ts +0 -19
- package/src/api/routes/plugin.ts +0 -14
- package/src/watch.ts +0 -38
- package/src/websocket.ts +0 -26
|
@@ -1,69 +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.githubUpload = exports.request = void 0;
|
|
16
|
-
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
17
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
18
|
-
const utils_1 = require("./utils");
|
|
19
|
-
function request(url, headers, err) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const response = yield (0, node_fetch_1.default)(url, { headers });
|
|
22
|
-
if (response.status >= 300) {
|
|
23
|
-
const respErr = yield response.text();
|
|
24
|
-
throw new Error(`Error: ${err} - ${respErr}`);
|
|
25
|
-
}
|
|
26
|
-
return response.json();
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
exports.request = request;
|
|
30
|
-
function githubUpload(url, name = "", token = "") {
|
|
31
|
-
var _a;
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
let githubUrl = url;
|
|
34
|
-
if (!githubUrl.includes("https://github.com/")) {
|
|
35
|
-
throw new Error("The plugin origin must be from Github");
|
|
36
|
-
}
|
|
37
|
-
if (url.includes(".git")) {
|
|
38
|
-
githubUrl = url.replace(".git", "");
|
|
39
|
-
}
|
|
40
|
-
const githubApiUrl = githubUrl.replace("https://github.com/", "https://api.github.com/repos/");
|
|
41
|
-
const headers = token ? { Authorization: `Bearer ${token}` } : {};
|
|
42
|
-
const pluginDetails = yield request(githubApiUrl, headers, "Repository not found");
|
|
43
|
-
const pluginName = pluginDetails.name || name;
|
|
44
|
-
const pluginLatestReleaseUrl = (pluginDetails === null || pluginDetails === void 0 ? void 0 : pluginDetails["releases_url"])
|
|
45
|
-
? pluginDetails === null || pluginDetails === void 0 ? void 0 : pluginDetails["releases_url"].replace("{/id}", "/latest")
|
|
46
|
-
: undefined;
|
|
47
|
-
if (!pluginLatestReleaseUrl) {
|
|
48
|
-
throw new Error("Github release not found");
|
|
49
|
-
}
|
|
50
|
-
const pluginReleaseDetails = yield request(pluginLatestReleaseUrl, headers, "Github latest release not found");
|
|
51
|
-
const pluginReleaseTarballAsset = (_a = pluginReleaseDetails === null || pluginReleaseDetails === void 0 ? void 0 : pluginReleaseDetails.assets) === null || _a === void 0 ? void 0 : _a.find((x) => (x === null || x === void 0 ? void 0 : x["content_type"]) === "application/gzip");
|
|
52
|
-
const pluginLastReleaseTarballUrl = pluginReleaseTarballAsset === null || pluginReleaseTarballAsset === void 0 ? void 0 : pluginReleaseTarballAsset["browser_download_url"];
|
|
53
|
-
if (!pluginLastReleaseTarballUrl) {
|
|
54
|
-
throw new Error("Github latest release url not found");
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const path = yield (0, utils_1.downloadUnzipTarball)(pluginLastReleaseTarballUrl, pluginName, headers);
|
|
58
|
-
return yield (0, fileSystem_1.getPluginMetadata)(path);
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
let errMsg = (err === null || err === void 0 ? void 0 : err.message) || err;
|
|
62
|
-
if (errMsg === "unexpected response Not Found") {
|
|
63
|
-
errMsg = "Github release tarball not found";
|
|
64
|
-
}
|
|
65
|
-
throw new Error(errMsg);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
exports.githubUpload = githubUpload;
|
|
@@ -1,200 +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.processPlugin = exports.storePlugin = exports.destroy = exports.fetch = exports.create = exports.upload = exports.getPlugins = void 0;
|
|
16
|
-
const constants_1 = require("../../../constants");
|
|
17
|
-
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
18
|
-
const uploaders_1 = require("./uploaders");
|
|
19
|
-
const tenancy_1 = require("@budibase/backend-core/tenancy");
|
|
20
|
-
const plugins_1 = require("@budibase/backend-core/plugins");
|
|
21
|
-
const utils_1 = require("../../../db/utils");
|
|
22
|
-
const objectStore_1 = require("@budibase/backend-core/objectStore");
|
|
23
|
-
const types_1 = require("@budibase/types");
|
|
24
|
-
const environment_1 = __importDefault(require("../../../environment"));
|
|
25
|
-
const websocket_1 = require("../../../websocket");
|
|
26
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
27
|
-
function getPlugins(type) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const db = (0, tenancy_1.getGlobalDB)();
|
|
30
|
-
const response = yield db.allDocs((0, utils_1.getPluginParams)(null, {
|
|
31
|
-
include_docs: true,
|
|
32
|
-
}));
|
|
33
|
-
const plugins = response.rows.map((row) => row.doc);
|
|
34
|
-
if (type) {
|
|
35
|
-
return plugins.filter((plugin) => { var _a; return ((_a = plugin.schema) === null || _a === void 0 ? void 0 : _a.type) === type; });
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
return plugins;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
exports.getPlugins = getPlugins;
|
|
43
|
-
function upload(ctx) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const plugins = ctx.request.files.file.length > 1
|
|
46
|
-
? Array.from(ctx.request.files.file)
|
|
47
|
-
: [ctx.request.files.file];
|
|
48
|
-
try {
|
|
49
|
-
let docs = [];
|
|
50
|
-
// can do single or multiple plugins
|
|
51
|
-
for (let plugin of plugins) {
|
|
52
|
-
const doc = yield processPlugin(plugin, types_1.PluginSource.FILE);
|
|
53
|
-
docs.push(doc);
|
|
54
|
-
}
|
|
55
|
-
ctx.body = {
|
|
56
|
-
message: "Plugin(s) uploaded successfully",
|
|
57
|
-
plugins: docs,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
catch (err) {
|
|
61
|
-
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
62
|
-
ctx.throw(400, `Failed to import plugin: ${errMsg}`);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
exports.upload = upload;
|
|
67
|
-
function create(ctx) {
|
|
68
|
-
var _a;
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const { source, url, headers, githubToken } = ctx.request.body;
|
|
71
|
-
try {
|
|
72
|
-
let metadata;
|
|
73
|
-
let directory;
|
|
74
|
-
// Generating random name as a backup and needed for url
|
|
75
|
-
let name = "PLUGIN_" + Math.floor(100000 + Math.random() * 900000);
|
|
76
|
-
switch (source) {
|
|
77
|
-
case types_1.PluginSource.NPM:
|
|
78
|
-
const { metadata: metadataNpm, directory: directoryNpm } = yield (0, uploaders_1.npmUpload)(url, name);
|
|
79
|
-
metadata = metadataNpm;
|
|
80
|
-
directory = directoryNpm;
|
|
81
|
-
break;
|
|
82
|
-
case types_1.PluginSource.GITHUB:
|
|
83
|
-
const { metadata: metadataGithub, directory: directoryGithub } = yield (0, uploaders_1.githubUpload)(url, name, githubToken);
|
|
84
|
-
metadata = metadataGithub;
|
|
85
|
-
directory = directoryGithub;
|
|
86
|
-
break;
|
|
87
|
-
case types_1.PluginSource.URL:
|
|
88
|
-
const headersObj = headers || {};
|
|
89
|
-
const { metadata: metadataUrl, directory: directoryUrl } = yield (0, uploaders_1.urlUpload)(url, name, headersObj);
|
|
90
|
-
metadata = metadataUrl;
|
|
91
|
-
directory = directoryUrl;
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
(0, plugins_1.validate)(metadata === null || metadata === void 0 ? void 0 : metadata.schema);
|
|
95
|
-
// Only allow components in cloud
|
|
96
|
-
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) {
|
|
97
|
-
throw new Error("Only component plugins are supported outside of self-host");
|
|
98
|
-
}
|
|
99
|
-
const doc = yield storePlugin(metadata, directory, source);
|
|
100
|
-
ctx.body = {
|
|
101
|
-
message: "Plugin uploaded successfully",
|
|
102
|
-
plugins: [doc],
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
catch (err) {
|
|
106
|
-
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
107
|
-
ctx.throw(400, `Failed to import plugin: ${errMsg}`);
|
|
108
|
-
}
|
|
109
|
-
ctx.status = 200;
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
exports.create = create;
|
|
113
|
-
function fetch(ctx) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
ctx.body = yield getPlugins();
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
exports.fetch = fetch;
|
|
119
|
-
function destroy(ctx) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
const db = (0, tenancy_1.getGlobalDB)();
|
|
122
|
-
const { pluginId } = ctx.params;
|
|
123
|
-
try {
|
|
124
|
-
const plugin = yield db.get(pluginId);
|
|
125
|
-
const bucketPath = `${plugin.name}/`;
|
|
126
|
-
yield (0, objectStore_1.deleteFolder)(constants_1.ObjectStoreBuckets.PLUGINS, bucketPath);
|
|
127
|
-
yield db.remove(pluginId, plugin._rev);
|
|
128
|
-
yield backend_core_1.events.plugin.deleted(plugin);
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
132
|
-
ctx.throw(400, `Failed to delete plugin: ${errMsg}`);
|
|
133
|
-
}
|
|
134
|
-
ctx.message = `Plugin ${ctx.params.pluginId} deleted.`;
|
|
135
|
-
ctx.status = 200;
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
exports.destroy = destroy;
|
|
139
|
-
function storePlugin(metadata, directory, source) {
|
|
140
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
-
const db = (0, tenancy_1.getGlobalDB)();
|
|
142
|
-
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description, hash = metadata.schema.hash;
|
|
143
|
-
// first open the tarball into tmp directory
|
|
144
|
-
const bucketPath = `${name}/`;
|
|
145
|
-
const files = yield (0, objectStore_1.uploadDirectory)(constants_1.ObjectStoreBuckets.PLUGINS, directory, bucketPath);
|
|
146
|
-
const jsFile = files.find((file) => file.name.endsWith(".js"));
|
|
147
|
-
if (!jsFile) {
|
|
148
|
-
throw new Error(`Plugin missing .js file.`);
|
|
149
|
-
}
|
|
150
|
-
// validate the JS for a datasource
|
|
151
|
-
if (metadata.schema.type === types_1.PluginType.DATASOURCE) {
|
|
152
|
-
const js = (0, fileSystem_1.loadJSFile)(directory, jsFile.name);
|
|
153
|
-
// TODO: this isn't safe - but we need full node environment
|
|
154
|
-
// in future we should do this in a thread for safety
|
|
155
|
-
try {
|
|
156
|
-
eval(js);
|
|
157
|
-
}
|
|
158
|
-
catch (err) {
|
|
159
|
-
const message = (err === null || err === void 0 ? void 0 : err.message) ? err.message : JSON.stringify(err);
|
|
160
|
-
throw new Error(`JS invalid: ${message}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
const jsFileName = jsFile.name;
|
|
164
|
-
const pluginId = (0, utils_1.generatePluginID)(name);
|
|
165
|
-
// overwrite existing docs entirely if they exist
|
|
166
|
-
let rev;
|
|
167
|
-
try {
|
|
168
|
-
const existing = yield db.get(pluginId);
|
|
169
|
-
rev = existing._rev;
|
|
170
|
-
}
|
|
171
|
-
catch (err) {
|
|
172
|
-
rev = undefined;
|
|
173
|
-
}
|
|
174
|
-
let doc = Object.assign(Object.assign({ _id: pluginId, _rev: rev }, metadata), { name,
|
|
175
|
-
version,
|
|
176
|
-
hash,
|
|
177
|
-
description, jsUrl: `${bucketPath}${jsFileName}` });
|
|
178
|
-
if (source) {
|
|
179
|
-
doc = Object.assign(Object.assign({}, doc), { source });
|
|
180
|
-
}
|
|
181
|
-
const response = yield db.put(doc);
|
|
182
|
-
yield backend_core_1.events.plugin.imported(doc);
|
|
183
|
-
websocket_1.ClientAppSocket.emit("plugin-update", { name, hash });
|
|
184
|
-
return Object.assign(Object.assign({}, doc), { _rev: response.rev });
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
exports.storePlugin = storePlugin;
|
|
188
|
-
function processPlugin(plugin, source) {
|
|
189
|
-
var _a;
|
|
190
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
-
const { metadata, directory } = yield (0, uploaders_1.fileUpload)(plugin);
|
|
192
|
-
(0, plugins_1.validate)(metadata === null || metadata === void 0 ? void 0 : metadata.schema);
|
|
193
|
-
// Only allow components in cloud
|
|
194
|
-
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) {
|
|
195
|
-
throw new Error("Only component plugins are supported outside of self-host");
|
|
196
|
-
}
|
|
197
|
-
return yield storePlugin(metadata, directory, source);
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
exports.processPlugin = processPlugin;
|
|
@@ -1,58 +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.npmUpload = void 0;
|
|
16
|
-
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
17
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
18
|
-
const path_1 = require("path");
|
|
19
|
-
const utils_1 = require("./utils");
|
|
20
|
-
function npmUpload(url, name, headers = {}) {
|
|
21
|
-
var _a, _b, _c;
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
let npmTarballUrl = url;
|
|
24
|
-
let pluginName = name;
|
|
25
|
-
if (!npmTarballUrl.includes("https://www.npmjs.com") &&
|
|
26
|
-
!npmTarballUrl.includes("https://registry.npmjs.org")) {
|
|
27
|
-
throw new Error("The plugin origin must be from NPM");
|
|
28
|
-
}
|
|
29
|
-
if (!npmTarballUrl.includes(".tgz")) {
|
|
30
|
-
const npmPackageURl = url.replace("https://www.npmjs.com/package/", "https://registry.npmjs.org/");
|
|
31
|
-
const response = yield (0, node_fetch_1.default)(npmPackageURl);
|
|
32
|
-
if (response.status !== 200) {
|
|
33
|
-
throw new Error("NPM Package not found");
|
|
34
|
-
}
|
|
35
|
-
let npmDetails = yield response.json();
|
|
36
|
-
pluginName = npmDetails.name;
|
|
37
|
-
const npmVersion = npmDetails["dist-tags"].latest;
|
|
38
|
-
npmTarballUrl = (_c = (_b = (_a = npmDetails === null || npmDetails === void 0 ? void 0 : npmDetails.versions) === null || _a === void 0 ? void 0 : _a[npmVersion]) === null || _b === void 0 ? void 0 : _b.dist) === null || _c === void 0 ? void 0 : _c.tarball;
|
|
39
|
-
if (!npmTarballUrl) {
|
|
40
|
-
throw new Error("NPM tarball url not found");
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
const path = yield (0, utils_1.downloadUnzipTarball)(npmTarballUrl, pluginName, headers);
|
|
44
|
-
const tarballPluginFile = (0, fileSystem_1.findFileRec)(path, ".tar.gz");
|
|
45
|
-
if (!tarballPluginFile) {
|
|
46
|
-
throw new Error("Tarball plugin file not found");
|
|
47
|
-
}
|
|
48
|
-
try {
|
|
49
|
-
yield (0, fileSystem_1.extractTarball)(tarballPluginFile, path);
|
|
50
|
-
(0, fileSystem_1.deleteFolderFileSystem)((0, path_1.join)(path, "package"));
|
|
51
|
-
}
|
|
52
|
-
catch (err) {
|
|
53
|
-
throw new Error(err);
|
|
54
|
-
}
|
|
55
|
-
return yield (0, fileSystem_1.getPluginMetadata)(path);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
exports.npmUpload = npmUpload;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.urlUpload = exports.npmUpload = exports.githubUpload = exports.fileUpload = void 0;
|
|
4
|
-
var file_1 = require("./file");
|
|
5
|
-
Object.defineProperty(exports, "fileUpload", { enumerable: true, get: function () { return file_1.fileUpload; } });
|
|
6
|
-
var github_1 = require("./github");
|
|
7
|
-
Object.defineProperty(exports, "githubUpload", { enumerable: true, get: function () { return github_1.githubUpload; } });
|
|
8
|
-
var npm_1 = require("./npm");
|
|
9
|
-
Object.defineProperty(exports, "npmUpload", { enumerable: true, get: function () { return npm_1.npmUpload; } });
|
|
10
|
-
var url_1 = require("./url");
|
|
11
|
-
Object.defineProperty(exports, "urlUpload", { enumerable: true, get: function () { return url_1.urlUpload; } });
|
|
@@ -1,26 +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.downloadUnzipTarball = void 0;
|
|
13
|
-
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
14
|
-
function downloadUnzipTarball(url, name, headers = {}) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
try {
|
|
17
|
-
const path = (0, fileSystem_1.createTempFolder)(name);
|
|
18
|
-
yield (0, fileSystem_1.downloadTarballDirect)(url, path, headers);
|
|
19
|
-
return path;
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
throw new Error(e.message);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
exports.downloadUnzipTarball = downloadUnzipTarball;
|
package/dist/watch.js
DELETED
|
@@ -1,77 +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.watch = void 0;
|
|
39
|
-
const path_1 = __importDefault(require("path"));
|
|
40
|
-
const env = __importStar(require("./environment"));
|
|
41
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
42
|
-
const fs_1 = __importDefault(require("fs"));
|
|
43
|
-
const backend_core_1 = require("@budibase/backend-core");
|
|
44
|
-
const constants_1 = require("@budibase/backend-core/constants");
|
|
45
|
-
const plugin_1 = require("./api/controllers/plugin");
|
|
46
|
-
function watch() {
|
|
47
|
-
const watchPath = path_1.default.join(env.PLUGINS_DIR, "./**/*.tar.gz");
|
|
48
|
-
chokidar_1.default
|
|
49
|
-
.watch(watchPath, {
|
|
50
|
-
ignored: "**/node_modules",
|
|
51
|
-
awaitWriteFinish: {
|
|
52
|
-
pollInterval: 100,
|
|
53
|
-
stabilityThreshold: 250,
|
|
54
|
-
},
|
|
55
|
-
usePolling: true,
|
|
56
|
-
interval: 250,
|
|
57
|
-
})
|
|
58
|
-
.on("all", (event, path) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
// Sanity checks
|
|
60
|
-
if (!(path === null || path === void 0 ? void 0 : path.endsWith(".tar.gz")) || !fs_1.default.existsSync(path)) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
yield backend_core_1.tenancy.doInTenant(constants_1.DEFAULT_TENANT_ID, () => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
try {
|
|
65
|
-
const split = path.split("/");
|
|
66
|
-
const name = split[split.length - 1];
|
|
67
|
-
console.log("Importing plugin:", path);
|
|
68
|
-
yield (0, plugin_1.processPlugin)({ name, path });
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
const message = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
72
|
-
console.error("Failed to import plugin:", message);
|
|
73
|
-
}
|
|
74
|
-
}));
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
exports.watch = watch;
|
package/dist/websocket.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClientAppSocket = exports.initialise = void 0;
|
|
4
|
-
const socket_io_1 = require("socket.io");
|
|
5
|
-
class Websocket {
|
|
6
|
-
constructor(server, path) {
|
|
7
|
-
this.socketServer = new socket_io_1.Server(server, {
|
|
8
|
-
path,
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
// Emit an event to all sockets
|
|
12
|
-
emit(event, payload) {
|
|
13
|
-
this.socketServer.sockets.emit(event, payload);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
// Likely to be more socket instances in future
|
|
17
|
-
let ClientAppSocket;
|
|
18
|
-
exports.ClientAppSocket = ClientAppSocket;
|
|
19
|
-
const initialise = (server) => {
|
|
20
|
-
exports.ClientAppSocket = ClientAppSocket = new Websocket(server, "/socket/client");
|
|
21
|
-
};
|
|
22
|
-
exports.initialise = initialise;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createTempFolder,
|
|
3
|
-
getPluginMetadata,
|
|
4
|
-
extractTarball,
|
|
5
|
-
} from "../../../utilities/fileSystem"
|
|
6
|
-
|
|
7
|
-
export async function fileUpload(file: { name: string; path: string }) {
|
|
8
|
-
if (!file.name.endsWith(".tar.gz")) {
|
|
9
|
-
throw new Error("Plugin must be compressed into a gzipped tarball.")
|
|
10
|
-
}
|
|
11
|
-
const path = createTempFolder(file.name.split(".tar.gz")[0])
|
|
12
|
-
await extractTarball(file.path, path)
|
|
13
|
-
|
|
14
|
-
return await getPluginMetadata(path)
|
|
15
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { getPluginMetadata } from "../../../utilities/fileSystem"
|
|
2
|
-
import fetch from "node-fetch"
|
|
3
|
-
import { downloadUnzipTarball } from "./utils"
|
|
4
|
-
|
|
5
|
-
export async function request(
|
|
6
|
-
url: string,
|
|
7
|
-
headers: { [key: string]: string },
|
|
8
|
-
err: string
|
|
9
|
-
) {
|
|
10
|
-
const response = await fetch(url, { headers })
|
|
11
|
-
if (response.status >= 300) {
|
|
12
|
-
const respErr = await response.text()
|
|
13
|
-
throw new Error(`Error: ${err} - ${respErr}`)
|
|
14
|
-
}
|
|
15
|
-
return response.json()
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function githubUpload(url: string, name = "", token = "") {
|
|
19
|
-
let githubUrl = url
|
|
20
|
-
|
|
21
|
-
if (!githubUrl.includes("https://github.com/")) {
|
|
22
|
-
throw new Error("The plugin origin must be from Github")
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (url.includes(".git")) {
|
|
26
|
-
githubUrl = url.replace(".git", "")
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const githubApiUrl = githubUrl.replace(
|
|
30
|
-
"https://github.com/",
|
|
31
|
-
"https://api.github.com/repos/"
|
|
32
|
-
)
|
|
33
|
-
const headers: any = token ? { Authorization: `Bearer ${token}` } : {}
|
|
34
|
-
const pluginDetails = await request(
|
|
35
|
-
githubApiUrl,
|
|
36
|
-
headers,
|
|
37
|
-
"Repository not found"
|
|
38
|
-
)
|
|
39
|
-
const pluginName = pluginDetails.name || name
|
|
40
|
-
const pluginLatestReleaseUrl = pluginDetails?.["releases_url"]
|
|
41
|
-
? pluginDetails?.["releases_url"].replace("{/id}", "/latest")
|
|
42
|
-
: undefined
|
|
43
|
-
if (!pluginLatestReleaseUrl) {
|
|
44
|
-
throw new Error("Github release not found")
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const pluginReleaseDetails = await request(
|
|
48
|
-
pluginLatestReleaseUrl,
|
|
49
|
-
headers,
|
|
50
|
-
"Github latest release not found"
|
|
51
|
-
)
|
|
52
|
-
const pluginReleaseTarballAsset = pluginReleaseDetails?.assets?.find(
|
|
53
|
-
(x: any) => x?.["content_type"] === "application/gzip"
|
|
54
|
-
)
|
|
55
|
-
const pluginLastReleaseTarballUrl =
|
|
56
|
-
pluginReleaseTarballAsset?.["browser_download_url"]
|
|
57
|
-
if (!pluginLastReleaseTarballUrl) {
|
|
58
|
-
throw new Error("Github latest release url not found")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const path = await downloadUnzipTarball(
|
|
63
|
-
pluginLastReleaseTarballUrl,
|
|
64
|
-
pluginName,
|
|
65
|
-
headers
|
|
66
|
-
)
|
|
67
|
-
return await getPluginMetadata(path)
|
|
68
|
-
} catch (err: any) {
|
|
69
|
-
let errMsg = err?.message || err
|
|
70
|
-
if (errMsg === "unexpected response Not Found") {
|
|
71
|
-
errMsg = "Github release tarball not found"
|
|
72
|
-
}
|
|
73
|
-
throw new Error(errMsg)
|
|
74
|
-
}
|
|
75
|
-
}
|