@budibase/server 1.3.15-alpha.0 → 1.3.15-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{index.f5c54dd2.css → index.ecdac070.css} +2 -2
- package/builder/assets/{index.b266d29f.js → index.ed9ae6a1.js} +288 -288
- package/builder/index.html +2 -2
- package/coverage/clover.xml +2 -2
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- 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 +1 -1
- 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/dist/api/controllers/plugin/file.js +24 -0
- package/dist/api/controllers/plugin/github.js +69 -0
- package/dist/api/controllers/{plugin.js → plugin/index.js} +83 -13
- 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/routes/plugin.js +1 -0
- package/dist/package.json +6 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +56 -12
- package/package.json +7 -7
- 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 +202 -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/routes/plugin.ts +1 -0
- package/src/module.d.ts +1 -0
- package/src/utilities/fileSystem/index.js +72 -12
- package/src/api/controllers/plugin.ts +0 -110
|
@@ -12,14 +12,16 @@ 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.processPlugin = exports.destroy = exports.fetch = exports.upload = exports.getPlugins = void 0;
|
|
16
|
-
const constants_1 = require("
|
|
17
|
-
const fileSystem_1 = require("
|
|
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");
|
|
18
19
|
const tenancy_1 = require("@budibase/backend-core/tenancy");
|
|
19
|
-
const
|
|
20
|
+
const plugins_1 = require("@budibase/backend-core/plugins");
|
|
21
|
+
const utils_1 = require("../../../db/utils");
|
|
20
22
|
const objectStore_1 = require("@budibase/backend-core/objectStore");
|
|
21
23
|
const types_1 = require("@budibase/types");
|
|
22
|
-
const environment_1 = __importDefault(require("
|
|
24
|
+
const environment_1 = __importDefault(require("../../../environment"));
|
|
23
25
|
function getPlugins(type) {
|
|
24
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
27
|
const db = (0, tenancy_1.getGlobalDB)();
|
|
@@ -45,7 +47,7 @@ function upload(ctx) {
|
|
|
45
47
|
let docs = [];
|
|
46
48
|
// can do single or multiple plugins
|
|
47
49
|
for (let plugin of plugins) {
|
|
48
|
-
const doc = yield processPlugin(plugin);
|
|
50
|
+
const doc = yield processPlugin(plugin, types_1.PluginSource.FILE);
|
|
49
51
|
docs.push(doc);
|
|
50
52
|
}
|
|
51
53
|
ctx.body = {
|
|
@@ -60,6 +62,50 @@ function upload(ctx) {
|
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
64
|
exports.upload = upload;
|
|
65
|
+
function create(ctx) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const { source, url, headers, githubToken } = ctx.request.body;
|
|
68
|
+
if (!environment_1.default.SELF_HOSTED) {
|
|
69
|
+
ctx.throw(400, "Plugins not supported outside of self-host.");
|
|
70
|
+
}
|
|
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
|
+
const doc = yield storePlugin(metadata, directory, source);
|
|
96
|
+
ctx.body = {
|
|
97
|
+
message: "Plugin uploaded successfully",
|
|
98
|
+
plugins: [doc],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
103
|
+
ctx.throw(400, `Failed to import plugin: ${errMsg}`);
|
|
104
|
+
}
|
|
105
|
+
ctx.status = 200;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
exports.create = create;
|
|
63
109
|
function fetch(ctx) {
|
|
64
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
111
|
ctx.body = yield getPlugins();
|
|
@@ -67,16 +113,27 @@ function fetch(ctx) {
|
|
|
67
113
|
}
|
|
68
114
|
exports.fetch = fetch;
|
|
69
115
|
function destroy(ctx) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const db = (0, tenancy_1.getGlobalDB)();
|
|
118
|
+
const { pluginId } = ctx.params;
|
|
119
|
+
try {
|
|
120
|
+
const plugin = yield db.get(pluginId);
|
|
121
|
+
const bucketPath = `${plugin.name}/`;
|
|
122
|
+
yield (0, objectStore_1.deleteFolder)(constants_1.ObjectStoreBuckets.PLUGINS, bucketPath);
|
|
123
|
+
yield db.remove(pluginId, plugin._rev);
|
|
124
|
+
}
|
|
125
|
+
catch (err) {
|
|
126
|
+
const errMsg = (err === null || err === void 0 ? void 0 : err.message) ? err === null || err === void 0 ? void 0 : err.message : err;
|
|
127
|
+
ctx.throw(400, `Failed to delete plugin: ${errMsg}`);
|
|
128
|
+
}
|
|
129
|
+
ctx.message = `Plugin ${ctx.params.pluginId} deleted.`;
|
|
130
|
+
ctx.status = 200;
|
|
131
|
+
});
|
|
71
132
|
}
|
|
72
133
|
exports.destroy = destroy;
|
|
73
|
-
function
|
|
134
|
+
function storePlugin(metadata, directory, source) {
|
|
74
135
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
if (!environment_1.default.SELF_HOSTED) {
|
|
76
|
-
throw new Error("Plugins not supported outside of self-host.");
|
|
77
|
-
}
|
|
78
136
|
const db = (0, tenancy_1.getGlobalDB)();
|
|
79
|
-
const { metadata, directory } = yield (0, fileSystem_1.extractPluginTarball)(plugin);
|
|
80
137
|
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description;
|
|
81
138
|
// first open the tarball into tmp directory
|
|
82
139
|
const bucketPath = `${name}/`;
|
|
@@ -109,11 +166,24 @@ function processPlugin(plugin) {
|
|
|
109
166
|
catch (err) {
|
|
110
167
|
rev = undefined;
|
|
111
168
|
}
|
|
112
|
-
|
|
169
|
+
let doc = Object.assign(Object.assign({ _id: pluginId, _rev: rev }, metadata), { name,
|
|
113
170
|
version,
|
|
114
171
|
description, jsUrl: `${bucketPath}${jsFileName}` });
|
|
172
|
+
if (source) {
|
|
173
|
+
doc = Object.assign(Object.assign({}, doc), { source });
|
|
174
|
+
}
|
|
115
175
|
const response = yield db.put(doc);
|
|
116
176
|
return Object.assign(Object.assign({}, doc), { _rev: response.rev });
|
|
117
177
|
});
|
|
118
178
|
}
|
|
179
|
+
exports.storePlugin = storePlugin;
|
|
180
|
+
function processPlugin(plugin, source) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
if (!environment_1.default.SELF_HOSTED) {
|
|
183
|
+
throw new Error("Plugins not supported outside of self-host.");
|
|
184
|
+
}
|
|
185
|
+
const { metadata, directory } = yield (0, uploaders_1.fileUpload)(plugin);
|
|
186
|
+
return yield storePlugin(metadata, directory, source);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
119
189
|
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;
|
|
@@ -33,6 +33,7 @@ const permissions_1 = require("@budibase/backend-core/permissions");
|
|
|
33
33
|
const router = new router_1.default();
|
|
34
34
|
router
|
|
35
35
|
.post("/api/plugin/upload", (0, authorized_1.default)(permissions_1.BUILDER), controller.upload)
|
|
36
|
+
.post("/api/plugin", (0, authorized_1.default)(permissions_1.BUILDER), controller.create)
|
|
36
37
|
.get("/api/plugin", (0, authorized_1.default)(permissions_1.BUILDER), controller.fetch)
|
|
37
38
|
.delete("/api/plugin/:pluginId", (0, authorized_1.default)(permissions_1.BUILDER), controller.destroy);
|
|
38
39
|
exports.default = router;
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.15-alpha.0",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "
|
|
81
|
-
"@budibase/client": "
|
|
82
|
-
"@budibase/pro": "1.3.
|
|
83
|
-
"@budibase/string-templates": "
|
|
84
|
-
"@budibase/types": "
|
|
80
|
+
"@budibase/backend-core": "1.3.15-alpha.0",
|
|
81
|
+
"@budibase/client": "1.3.15-alpha.0",
|
|
82
|
+
"@budibase/pro": "1.3.15-alpha.0",
|
|
83
|
+
"@budibase/string-templates": "1.3.15-alpha.0",
|
|
84
|
+
"@budibase/types": "1.3.15-alpha.0",
|
|
85
85
|
"@bull-board/api": "3.7.0",
|
|
86
86
|
"@bull-board/koa": "3.9.4",
|
|
87
87
|
"@elastic/elasticsearch": "7.10.0",
|