@budibase/server 1.3.17 → 1.3.19-alpha.0
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.a70e216a.css → index.3850883f.css} +2 -2
- package/builder/assets/index.fdade753.js +995 -0
- package/builder/index.html +2 -4
- package/coverage/clover.xml +409 -361
- package/coverage/coverage-final.json +18 -18
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- 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 +68 -11
- package/coverage/lcov-report/api/controllers/datasource.js.html +73 -34
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +38 -38
- 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 +207 -12
- 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 +12 -12
- 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 +5 -5
- package/coverage/lcov-report/api/routes/utils/validators.js.html +9 -6
- 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 +56 -20
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- 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 +30 -30
- 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 +33 -33
- package/coverage/lcov-report/middleware/index.html +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov.info +725 -623
- package/dist/api/controllers/application.js +5 -4
- package/dist/api/controllers/component.js +14 -1
- package/dist/api/controllers/datasource.js +21 -8
- package/dist/api/controllers/integration.js +4 -4
- package/dist/api/controllers/plugin/file.js +24 -0
- package/dist/api/controllers/plugin/github.js +69 -0
- package/dist/api/controllers/plugin/index.js +197 -0
- package/dist/api/controllers/plugin/npm.js +58 -0
- package/dist/api/controllers/plugin/uploaders.js +11 -0
- package/dist/api/controllers/plugin/url.js +24 -0
- package/dist/api/controllers/plugin/utils.js +26 -0
- package/dist/api/controllers/row/external.js +1 -1
- package/dist/api/controllers/screen.js +52 -2
- package/dist/api/controllers/static/index.js +1 -0
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/dist/api/controllers/static/templates/preview.hbs +5 -1
- package/dist/api/routes/application.js +3 -2
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/plugin.js +39 -0
- 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 -1
- package/dist/app.js +11 -0
- package/dist/db/utils.js +10 -1
- package/dist/environment.js +1 -0
- package/dist/integrations/airtable.js +126 -129
- package/dist/integrations/arangodb.js +86 -89
- package/dist/integrations/base/query.js +2 -2
- package/dist/integrations/base/sqlTable.js +3 -1
- package/dist/integrations/couchdb.js +80 -83
- package/dist/integrations/dynamodb.js +161 -164
- package/dist/integrations/elasticsearch.js +135 -138
- package/dist/integrations/firebase.js +154 -157
- package/dist/integrations/googlesheets.js +323 -327
- package/dist/integrations/index.js +99 -51
- package/dist/integrations/microsoftSqlServer.js +240 -243
- package/dist/integrations/mongodb.js +239 -242
- package/dist/integrations/mysql.js +215 -219
- package/dist/integrations/oracle.js +318 -322
- package/dist/integrations/postgres.js +262 -265
- package/dist/integrations/redis.js +134 -139
- package/dist/integrations/rest.js +289 -292
- package/dist/integrations/s3.js +61 -64
- package/dist/integrations/snowflake.js +83 -86
- package/dist/package.json +9 -6
- 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 +110 -1
- package/dist/watch.js +77 -0
- package/dist/websocket.js +22 -0
- package/package.json +10 -7
- package/scripts/dev/manage.js +1 -0
- package/specs/openapi.json +3 -3
- package/specs/openapi.yaml +3 -3
- package/specs/resources/query.js +1 -1
- package/src/api/controllers/application.ts +1 -1
- package/src/api/controllers/component.js +21 -2
- package/src/api/controllers/datasource.js +21 -8
- package/src/api/controllers/integration.js +4 -4
- package/src/api/controllers/plugin/file.ts +15 -0
- package/src/api/controllers/plugin/github.ts +75 -0
- package/src/api/controllers/plugin/index.ts +212 -0
- package/src/api/controllers/plugin/npm.ts +56 -0
- package/src/api/controllers/plugin/uploaders.ts +4 -0
- package/src/api/controllers/plugin/url.ts +12 -0
- package/src/api/controllers/plugin/utils.ts +19 -0
- package/src/api/controllers/row/external.js +1 -1
- package/src/api/controllers/screen.js +66 -1
- package/src/api/controllers/static/index.ts +1 -0
- package/src/api/controllers/static/templates/BudibaseApp.svelte +10 -0
- package/src/api/controllers/static/templates/preview.hbs +5 -1
- package/src/api/routes/application.ts +13 -2
- package/src/api/routes/index.ts +2 -0
- package/src/api/routes/plugin.ts +14 -0
- 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 +8 -25
- package/src/api/routes/utils/validators.js +2 -1
- package/src/app.ts +14 -0
- package/src/db/utils.js +12 -0
- package/src/definitions/openapi.ts +3 -3
- package/src/environment.js +1 -0
- package/src/integrations/airtable.ts +116 -118
- package/src/integrations/arangodb.ts +87 -89
- package/src/integrations/base/query.ts +2 -2
- package/src/integrations/base/sqlTable.ts +3 -1
- package/src/integrations/couchdb.ts +83 -89
- package/src/integrations/dynamodb.ts +173 -175
- package/src/integrations/elasticsearch.ts +120 -122
- package/src/integrations/firebase.ts +157 -159
- package/src/integrations/googlesheets.ts +328 -338
- package/src/integrations/index.ts +64 -21
- package/src/integrations/microsoftSqlServer.ts +249 -251
- package/src/integrations/mongodb.ts +261 -258
- package/src/integrations/mysql.ts +229 -234
- package/src/integrations/oracle.ts +373 -380
- package/src/integrations/postgres.ts +264 -268
- package/src/integrations/redis.ts +128 -132
- package/src/integrations/rest.ts +324 -329
- package/src/integrations/s3.ts +68 -71
- package/src/integrations/snowflake.ts +80 -82
- package/src/integrations/tests/{airtable.spec.js → airtable.spec.ts} +21 -18
- package/src/integrations/tests/{arangodb.spec.js → arangodb.spec.ts} +12 -9
- package/src/integrations/tests/{couchdb.spec.js → couchdb.spec.ts} +33 -27
- package/src/integrations/tests/{dynamodb.spec.js → dynamodb.spec.ts} +45 -41
- package/src/integrations/tests/{elasticsearch.spec.js → elasticsearch.spec.ts} +22 -21
- package/src/integrations/tests/{firebase.spec.js → firebase.spec.ts} +33 -28
- package/src/integrations/tests/{microsoftSqlServer.spec.js → microsoftSqlServer.spec.ts} +12 -11
- package/src/integrations/tests/{mongo.spec.js → mongo.spec.ts} +46 -35
- package/src/integrations/tests/{mysql.spec.js → mysql.spec.ts} +17 -15
- package/src/integrations/tests/{oracle.spec.js → oracle.spec.ts} +19 -17
- package/src/integrations/tests/{postgres.spec.js → postgres.spec.ts} +19 -17
- package/src/integrations/tests/{redis.spec.js → redis.spec.ts} +27 -18
- package/src/integrations/tests/{rest.spec.js → rest.spec.ts} +22 -14
- package/src/integrations/tests/{s3.spec.js → s3.spec.ts} +10 -8
- package/src/integrations/tests/{sql.spec.js → sql.spec.ts} +228 -177
- package/src/module.d.ts +2 -0
- package/src/tests/utilities/TestConfiguration.js +1 -1
- package/src/threads/query.ts +2 -2
- package/src/utilities/fileSystem/index.js +129 -0
- package/src/watch.ts +38 -0
- package/src/websocket.ts +26 -0
- package/builder/assets/index.8f5f192a.js +0 -876
- package/builder/assets/vendor.5e1fe644.css +0 -1
- package/builder/assets/vendor.67dbd8fa.js +0 -248
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.sync = exports.destroy = exports.revertClient = exports.updateClient = exports.update = exports.create = exports.fetchAppPackage = exports.fetchAppDefinition = exports.fetch = exports.getAppUrl = void 0;
|
|
15
|
+
exports.updateAppPackage = exports.sync = exports.destroy = exports.revertClient = exports.updateClient = exports.update = exports.create = exports.fetchAppPackage = exports.fetchAppDefinition = exports.fetch = exports.getAppUrl = void 0;
|
|
16
16
|
const environment_1 = __importDefault(require("../../environment"));
|
|
17
17
|
const package_json_1 = __importDefault(require("../../../package.json"));
|
|
18
18
|
const staticViews_1 = require("../../db/views/staticViews");
|
|
@@ -353,7 +353,7 @@ const update = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
353
353
|
checkAppUrl(ctx, apps, url, ctx.params.appId);
|
|
354
354
|
ctx.request.body.url = url;
|
|
355
355
|
}
|
|
356
|
-
const app = yield updateAppPackage(ctx.request.body, ctx.params.appId);
|
|
356
|
+
const app = yield (0, exports.updateAppPackage)(ctx.request.body, ctx.params.appId);
|
|
357
357
|
yield backend_core_2.events.app.updated(app);
|
|
358
358
|
ctx.status = 200;
|
|
359
359
|
ctx.body = app;
|
|
@@ -375,7 +375,7 @@ const updateClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
375
375
|
version: updatedToVersion,
|
|
376
376
|
revertableVersion: currentVersion,
|
|
377
377
|
};
|
|
378
|
-
const app = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
378
|
+
const app = yield (0, exports.updateAppPackage)(appPackageUpdates, ctx.params.appId);
|
|
379
379
|
yield backend_core_2.events.app.versionUpdated(app, currentVersion, updatedToVersion);
|
|
380
380
|
ctx.status = 200;
|
|
381
381
|
ctx.body = app;
|
|
@@ -399,7 +399,7 @@ const revertClient = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
399
399
|
version: revertedToVersion,
|
|
400
400
|
revertableVersion: null,
|
|
401
401
|
};
|
|
402
|
-
const app = yield updateAppPackage(appPackageUpdates, ctx.params.appId);
|
|
402
|
+
const app = yield (0, exports.updateAppPackage)(appPackageUpdates, ctx.params.appId);
|
|
403
403
|
yield backend_core_2.events.app.versionReverted(app, currentVersion, revertedToVersion);
|
|
404
404
|
ctx.status = 200;
|
|
405
405
|
ctx.body = app;
|
|
@@ -527,6 +527,7 @@ const updateAppPackage = (appPackage, appId) => __awaiter(void 0, void 0, void 0
|
|
|
527
527
|
return newAppPackage;
|
|
528
528
|
}));
|
|
529
529
|
});
|
|
530
|
+
exports.updateAppPackage = updateAppPackage;
|
|
530
531
|
const migrateAppNavigation = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
531
532
|
const db = backend_core_1.context.getAppDB();
|
|
532
533
|
const existing = yield db.get(utils_1.DocumentType.APP_METADATA);
|
|
@@ -8,9 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const { DocumentType } = require("../../db/utils");
|
|
11
|
+
const { DocumentType, getPluginParams } = require("../../db/utils");
|
|
12
12
|
const { getComponentLibraryManifest } = require("../../utilities/fileSystem");
|
|
13
13
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
14
|
+
const { getGlobalDB } = require("@budibase/backend-core/tenancy");
|
|
14
15
|
exports.fetchAppComponentDefinitions = function (ctx) {
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
try {
|
|
@@ -35,6 +36,18 @@ exports.fetchAppComponentDefinitions = function (ctx) {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
// Add custom components
|
|
40
|
+
const globalDB = getGlobalDB();
|
|
41
|
+
const response = yield globalDB.allDocs(getPluginParams(null, {
|
|
42
|
+
include_docs: true,
|
|
43
|
+
}));
|
|
44
|
+
response.rows
|
|
45
|
+
.map(row => row.doc)
|
|
46
|
+
.filter(plugin => plugin.schema.type === "component")
|
|
47
|
+
.forEach(plugin => {
|
|
48
|
+
const fullComponentName = `plugin/${plugin.name}`;
|
|
49
|
+
definitions[fullComponentName] = Object.assign({ component: fullComponentName }, plugin.schema.schema);
|
|
50
|
+
});
|
|
38
51
|
ctx.body = definitions;
|
|
39
52
|
}
|
|
40
53
|
catch (err) {
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const { generateDatasourceID, getDatasourceParams, getQueryParams, DocumentType, BudibaseInternalDB, getTableParams, } = require("../../db/utils");
|
|
12
12
|
const { BuildSchemaErrors, InvalidColumns } = require("../../constants");
|
|
13
|
-
const {
|
|
13
|
+
const { getIntegration } = require("../../integrations");
|
|
14
14
|
const { getDatasourceAndQuery } = require("./row/utils");
|
|
15
15
|
const { invalidateDynamicVariables } = require("../../threads/utils");
|
|
16
16
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
@@ -41,8 +41,21 @@ exports.buildSchemaFromDb = function (ctx) {
|
|
|
41
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
const db = getAppDB();
|
|
43
43
|
const datasource = yield db.get(ctx.params.datasourceId);
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const tablesFilter = ctx.request.body.tablesFilter;
|
|
45
|
+
let { tables, error } = yield buildSchemaHelper(datasource);
|
|
46
|
+
if (tablesFilter) {
|
|
47
|
+
if (!datasource.entities) {
|
|
48
|
+
datasource.entities = {};
|
|
49
|
+
}
|
|
50
|
+
for (let key in tables) {
|
|
51
|
+
if (tablesFilter.some(filter => filter.toLowerCase() === key.toLowerCase())) {
|
|
52
|
+
datasource.entities[key] = tables[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
datasource.entities = tables;
|
|
58
|
+
}
|
|
46
59
|
const dbResp = yield db.put(datasource);
|
|
47
60
|
datasource._rev = dbResp.rev;
|
|
48
61
|
const response = { datasource };
|
|
@@ -96,7 +109,7 @@ exports.update = function (ctx) {
|
|
|
96
109
|
datasource._rev = response.rev;
|
|
97
110
|
// Drain connection pools when configuration is changed
|
|
98
111
|
if (datasource.source) {
|
|
99
|
-
const source =
|
|
112
|
+
const source = yield getIntegration(datasource.source);
|
|
100
113
|
if (source && source.pool) {
|
|
101
114
|
yield source.pool.end();
|
|
102
115
|
}
|
|
@@ -123,7 +136,7 @@ exports.save = function (ctx) {
|
|
|
123
136
|
datasource._rev = dbResp.rev;
|
|
124
137
|
// Drain connection pools when configuration is changed
|
|
125
138
|
if (datasource.source) {
|
|
126
|
-
const source =
|
|
139
|
+
const source = yield getIntegration(datasource.source);
|
|
127
140
|
if (source && source.pool) {
|
|
128
141
|
yield source.pool.end();
|
|
129
142
|
}
|
|
@@ -188,13 +201,13 @@ function updateError(error, newError, tables) {
|
|
|
188
201
|
return error;
|
|
189
202
|
}
|
|
190
203
|
const buildSchemaHelper = (datasource) => __awaiter(void 0, void 0, void 0, function* () {
|
|
191
|
-
|
|
204
|
+
var _a;
|
|
205
|
+
const Connector = yield getIntegration(datasource.source);
|
|
192
206
|
// Connect to the DB and build the schema
|
|
193
207
|
const connector = new Connector(datasource.config);
|
|
194
208
|
yield connector.buildSchema(datasource._id, datasource.entities);
|
|
195
|
-
datasource.entities = connector.tables;
|
|
196
209
|
// make sure they all have a display name selected
|
|
197
|
-
for (let entity of Object.values(datasource.entities)) {
|
|
210
|
+
for (let entity of Object.values((_a = datasource.entities) !== null && _a !== void 0 ? _a : {})) {
|
|
198
211
|
if (entity.primaryDisplay) {
|
|
199
212
|
continue;
|
|
200
213
|
}
|
|
@@ -8,15 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
const {
|
|
12
|
-
const { definitions } = require("../../integrations");
|
|
11
|
+
const { getDefinitions } = require("../../integrations");
|
|
13
12
|
const { SourceName } = require("@budibase/types");
|
|
14
13
|
const googlesheets = require("../../integrations/googlesheets");
|
|
15
14
|
const { featureFlags } = require("@budibase/backend-core");
|
|
16
15
|
exports.fetch = function (ctx) {
|
|
17
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
17
|
ctx.status = 200;
|
|
19
|
-
const defs =
|
|
18
|
+
const defs = yield getDefinitions();
|
|
20
19
|
// for google sheets integration google verification
|
|
21
20
|
if (featureFlags.isEnabled(featureFlags.FeatureFlag.GOOGLE_SHEETS)) {
|
|
22
21
|
defs[SourceName.GOOGLE_SHEETS] = googlesheets.schema;
|
|
@@ -26,7 +25,8 @@ exports.fetch = function (ctx) {
|
|
|
26
25
|
};
|
|
27
26
|
exports.find = function (ctx) {
|
|
28
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const defs = yield getDefinitions();
|
|
29
29
|
ctx.status = 200;
|
|
30
|
-
ctx.body =
|
|
30
|
+
ctx.body = defs[ctx.params.type];
|
|
31
31
|
});
|
|
32
32
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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.fileUpload = void 0;
|
|
13
|
+
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
14
|
+
function fileUpload(file) {
|
|
15
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
if (!file.name.endsWith(".tar.gz")) {
|
|
17
|
+
throw new Error("Plugin must be compressed into a gzipped tarball.");
|
|
18
|
+
}
|
|
19
|
+
const path = (0, fileSystem_1.createTempFolder)(file.name.split(".tar.gz")[0]);
|
|
20
|
+
yield (0, fileSystem_1.extractTarball)(file.path, path);
|
|
21
|
+
return yield (0, fileSystem_1.getPluginMetadata)(path);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.fileUpload = fileUpload;
|
|
@@ -0,0 +1,69 @@
|
|
|
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;
|
|
@@ -0,0 +1,197 @@
|
|
|
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
|
+
function getPlugins(type) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const db = (0, tenancy_1.getGlobalDB)();
|
|
29
|
+
const response = yield db.allDocs((0, utils_1.getPluginParams)(null, {
|
|
30
|
+
include_docs: true,
|
|
31
|
+
}));
|
|
32
|
+
const plugins = response.rows.map((row) => row.doc);
|
|
33
|
+
if (type) {
|
|
34
|
+
return plugins.filter((plugin) => { var _a; return ((_a = plugin.schema) === null || _a === void 0 ? void 0 : _a.type) === type; });
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return plugins;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.getPlugins = getPlugins;
|
|
42
|
+
function upload(ctx) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const plugins = ctx.request.files.file.length > 1
|
|
45
|
+
? Array.from(ctx.request.files.file)
|
|
46
|
+
: [ctx.request.files.file];
|
|
47
|
+
try {
|
|
48
|
+
let docs = [];
|
|
49
|
+
// can do single or multiple plugins
|
|
50
|
+
for (let plugin of plugins) {
|
|
51
|
+
const doc = yield processPlugin(plugin, types_1.PluginSource.FILE);
|
|
52
|
+
docs.push(doc);
|
|
53
|
+
}
|
|
54
|
+
ctx.body = {
|
|
55
|
+
message: "Plugin(s) uploaded successfully",
|
|
56
|
+
plugins: docs,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
61
|
+
ctx.throw(400, `Failed to import plugin: ${errMsg}`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.upload = upload;
|
|
66
|
+
function create(ctx) {
|
|
67
|
+
var _a;
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const { source, url, headers, githubToken } = ctx.request.body;
|
|
70
|
+
try {
|
|
71
|
+
let metadata;
|
|
72
|
+
let directory;
|
|
73
|
+
// Generating random name as a backup and needed for url
|
|
74
|
+
let name = "PLUGIN_" + Math.floor(100000 + Math.random() * 900000);
|
|
75
|
+
switch (source) {
|
|
76
|
+
case types_1.PluginSource.NPM:
|
|
77
|
+
const { metadata: metadataNpm, directory: directoryNpm } = yield (0, uploaders_1.npmUpload)(url, name);
|
|
78
|
+
metadata = metadataNpm;
|
|
79
|
+
directory = directoryNpm;
|
|
80
|
+
break;
|
|
81
|
+
case types_1.PluginSource.GITHUB:
|
|
82
|
+
const { metadata: metadataGithub, directory: directoryGithub } = yield (0, uploaders_1.githubUpload)(url, name, githubToken);
|
|
83
|
+
metadata = metadataGithub;
|
|
84
|
+
directory = directoryGithub;
|
|
85
|
+
break;
|
|
86
|
+
case types_1.PluginSource.URL:
|
|
87
|
+
const headersObj = headers || {};
|
|
88
|
+
const { metadata: metadataUrl, directory: directoryUrl } = yield (0, uploaders_1.urlUpload)(url, name, headersObj);
|
|
89
|
+
metadata = metadataUrl;
|
|
90
|
+
directory = directoryUrl;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
(0, plugins_1.validate)(metadata === null || metadata === void 0 ? void 0 : metadata.schema);
|
|
94
|
+
// Only allow components in cloud
|
|
95
|
+
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) {
|
|
96
|
+
throw new Error("Only component plugins are supported outside of self-host");
|
|
97
|
+
}
|
|
98
|
+
const doc = yield storePlugin(metadata, directory, source);
|
|
99
|
+
ctx.body = {
|
|
100
|
+
message: "Plugin uploaded successfully",
|
|
101
|
+
plugins: [doc],
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
106
|
+
ctx.throw(400, `Failed to import plugin: ${errMsg}`);
|
|
107
|
+
}
|
|
108
|
+
ctx.status = 200;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
exports.create = create;
|
|
112
|
+
function fetch(ctx) {
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
ctx.body = yield getPlugins();
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.fetch = fetch;
|
|
118
|
+
function destroy(ctx) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const db = (0, tenancy_1.getGlobalDB)();
|
|
121
|
+
const { pluginId } = ctx.params;
|
|
122
|
+
try {
|
|
123
|
+
const plugin = yield db.get(pluginId);
|
|
124
|
+
const bucketPath = `${plugin.name}/`;
|
|
125
|
+
yield (0, objectStore_1.deleteFolder)(constants_1.ObjectStoreBuckets.PLUGINS, bucketPath);
|
|
126
|
+
yield db.remove(pluginId, plugin._rev);
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
130
|
+
ctx.throw(400, `Failed to delete plugin: ${errMsg}`);
|
|
131
|
+
}
|
|
132
|
+
ctx.message = `Plugin ${ctx.params.pluginId} deleted.`;
|
|
133
|
+
ctx.status = 200;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
exports.destroy = destroy;
|
|
137
|
+
function storePlugin(metadata, directory, source) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const db = (0, tenancy_1.getGlobalDB)();
|
|
140
|
+
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description, hash = metadata.schema.hash;
|
|
141
|
+
// first open the tarball into tmp directory
|
|
142
|
+
const bucketPath = `${name}/`;
|
|
143
|
+
const files = yield (0, objectStore_1.uploadDirectory)(constants_1.ObjectStoreBuckets.PLUGINS, directory, bucketPath);
|
|
144
|
+
const jsFile = files.find((file) => file.name.endsWith(".js"));
|
|
145
|
+
if (!jsFile) {
|
|
146
|
+
throw new Error(`Plugin missing .js file.`);
|
|
147
|
+
}
|
|
148
|
+
// validate the JS for a datasource
|
|
149
|
+
if (metadata.schema.type === types_1.PluginType.DATASOURCE) {
|
|
150
|
+
const js = (0, fileSystem_1.loadJSFile)(directory, jsFile.name);
|
|
151
|
+
// TODO: this isn't safe - but we need full node environment
|
|
152
|
+
// in future we should do this in a thread for safety
|
|
153
|
+
try {
|
|
154
|
+
eval(js);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
const message = (err === null || err === void 0 ? void 0 : err.message) ? err.message : JSON.stringify(err);
|
|
158
|
+
throw new Error(`JS invalid: ${message}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const jsFileName = jsFile.name;
|
|
162
|
+
const pluginId = (0, utils_1.generatePluginID)(name);
|
|
163
|
+
// overwrite existing docs entirely if they exist
|
|
164
|
+
let rev;
|
|
165
|
+
try {
|
|
166
|
+
const existing = yield db.get(pluginId);
|
|
167
|
+
rev = existing._rev;
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
rev = undefined;
|
|
171
|
+
}
|
|
172
|
+
let doc = Object.assign(Object.assign({ _id: pluginId, _rev: rev }, metadata), { name,
|
|
173
|
+
version,
|
|
174
|
+
hash,
|
|
175
|
+
description, jsUrl: `${bucketPath}${jsFileName}` });
|
|
176
|
+
if (source) {
|
|
177
|
+
doc = Object.assign(Object.assign({}, doc), { source });
|
|
178
|
+
}
|
|
179
|
+
const response = yield db.put(doc);
|
|
180
|
+
websocket_1.ClientAppSocket.emit("plugin-update", { name, hash });
|
|
181
|
+
return Object.assign(Object.assign({}, doc), { _rev: response.rev });
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
exports.storePlugin = storePlugin;
|
|
185
|
+
function processPlugin(plugin, source) {
|
|
186
|
+
var _a;
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const { metadata, directory } = yield (0, uploaders_1.fileUpload)(plugin);
|
|
189
|
+
(0, plugins_1.validate)(metadata === null || metadata === void 0 ? void 0 : metadata.schema);
|
|
190
|
+
// Only allow components in cloud
|
|
191
|
+
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) {
|
|
192
|
+
throw new Error("Only component plugins are supported outside of self-host");
|
|
193
|
+
}
|
|
194
|
+
return yield storePlugin(metadata, directory, source);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
exports.processPlugin = processPlugin;
|
|
@@ -0,0 +1,58 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
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; } });
|
|
@@ -0,0 +1,24 @@
|
|
|
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.urlUpload = void 0;
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const fileSystem_1 = require("../../../utilities/fileSystem");
|
|
15
|
+
function urlUpload(url, name = "", headers = {}) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (!url.includes(".tar.gz")) {
|
|
18
|
+
throw new Error("Plugin must be compressed into a gzipped tarball.");
|
|
19
|
+
}
|
|
20
|
+
const path = yield (0, utils_1.downloadUnzipTarball)(url, name, headers);
|
|
21
|
+
return yield (0, fileSystem_1.getPluginMetadata)(path);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.urlUpload = urlUpload;
|
|
@@ -0,0 +1,26 @@
|
|
|
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;
|
|
@@ -63,7 +63,7 @@ exports.save = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
exports.fetchView = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
-
// there are no views in external
|
|
66
|
+
// there are no views in external datasources, shouldn't ever be called
|
|
67
67
|
// for now just fetch
|
|
68
68
|
const split = ctx.params.viewName.split("all_");
|
|
69
69
|
ctx.params.tableId = split[1] ? split[1] : split[0];
|