@budibase/server 2.6.19-alpha.26 → 2.6.19-alpha.27
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.ffb6a106.css → index.87500798.css} +1 -1
- package/builder/assets/{index.47cc7efc.js → index.dc879886.js} +294 -293
- package/builder/index.html +2 -2
- package/dist/automation.js +301 -273
- package/dist/automation.js.map +4 -4
- package/dist/index.js +452 -339
- package/dist/index.js.map +4 -4
- package/dist/query.js +24 -6
- package/dist/query.js.map +4 -4
- package/package.json +9 -8
- package/src/api/controllers/application.ts +2 -1
- package/src/api/controllers/datasource.ts +4 -0
- package/src/api/controllers/row/index.ts +15 -22
- package/src/api/controllers/row/utils.ts +12 -0
- package/src/api/controllers/table/index.ts +3 -0
- package/src/api/controllers/view/index.ts +5 -5
- package/src/app.ts +0 -1
- package/src/middleware/builder.ts +4 -5
- package/src/startup.ts +2 -0
- package/src/utilities/redis.ts +19 -2
- package/src/websockets/builder.ts +69 -0
- package/src/websockets/grid.ts +25 -7
- package/src/websockets/index.ts +5 -2
- package/src/websockets/websocket.ts +20 -4
package/dist/automation.js
CHANGED
|
@@ -2728,6 +2728,7 @@ var init_utils2 = __esm({
|
|
|
2728
2728
|
Databases2["GENERIC_CACHE"] = "data_cache";
|
|
2729
2729
|
Databases2["WRITE_THROUGH"] = "writeThrough";
|
|
2730
2730
|
Databases2["LOCKS"] = "locks";
|
|
2731
|
+
Databases2["SOCKET_IO"] = "socket_io";
|
|
2731
2732
|
return Databases2;
|
|
2732
2733
|
})(Databases || {});
|
|
2733
2734
|
SelectableDatabase = /* @__PURE__ */ ((SelectableDatabase2) => {
|
|
@@ -25925,23 +25926,6 @@ var init_file = __esm({
|
|
|
25925
25926
|
}
|
|
25926
25927
|
});
|
|
25927
25928
|
|
|
25928
|
-
// src/utilities/redis.ts
|
|
25929
|
-
var init_redis5 = __esm({
|
|
25930
|
-
"src/utilities/redis.ts"() {
|
|
25931
|
-
init_src2();
|
|
25932
|
-
init_utils13();
|
|
25933
|
-
}
|
|
25934
|
-
});
|
|
25935
|
-
|
|
25936
|
-
// src/middleware/builder.ts
|
|
25937
|
-
var init_builder = __esm({
|
|
25938
|
-
"src/middleware/builder.ts"() {
|
|
25939
|
-
init_utils13();
|
|
25940
|
-
init_redis5();
|
|
25941
|
-
init_src2();
|
|
25942
|
-
}
|
|
25943
|
-
});
|
|
25944
|
-
|
|
25945
25929
|
// src/middleware/utils.ts
|
|
25946
25930
|
var WEBHOOK_ENDPOINTS;
|
|
25947
25931
|
var init_utils19 = __esm({
|
|
@@ -25952,17 +25936,6 @@ var init_utils19 = __esm({
|
|
|
25952
25936
|
}
|
|
25953
25937
|
});
|
|
25954
25938
|
|
|
25955
|
-
// src/middleware/authorized.ts
|
|
25956
|
-
var csrf;
|
|
25957
|
-
var init_authorized = __esm({
|
|
25958
|
-
"src/middleware/authorized.ts"() {
|
|
25959
|
-
init_src2();
|
|
25960
|
-
init_builder();
|
|
25961
|
-
init_utils19();
|
|
25962
|
-
csrf = auth_exports.buildCsrfMiddleware();
|
|
25963
|
-
}
|
|
25964
|
-
});
|
|
25965
|
-
|
|
25966
25939
|
// src/middleware/currentapp.ts
|
|
25967
25940
|
var init_currentapp = __esm({
|
|
25968
25941
|
"src/middleware/currentapp.ts"() {
|
|
@@ -25974,8 +25947,16 @@ var init_currentapp = __esm({
|
|
|
25974
25947
|
}
|
|
25975
25948
|
});
|
|
25976
25949
|
|
|
25950
|
+
// src/utilities/redis.ts
|
|
25951
|
+
var init_redis5 = __esm({
|
|
25952
|
+
"src/utilities/redis.ts"() {
|
|
25953
|
+
init_src2();
|
|
25954
|
+
init_utils13();
|
|
25955
|
+
}
|
|
25956
|
+
});
|
|
25957
|
+
|
|
25977
25958
|
// src/websockets/websocket.ts
|
|
25978
|
-
var import_socket, import_cookies, import_koa_useragent;
|
|
25959
|
+
var import_socket, import_cookies, import_koa_useragent, import_redis_adapter, import_uuid4;
|
|
25979
25960
|
var init_websocket = __esm({
|
|
25980
25961
|
"src/websockets/websocket.ts"() {
|
|
25981
25962
|
import_socket = require("socket.io");
|
|
@@ -25983,15 +25964,29 @@ var init_websocket = __esm({
|
|
|
25983
25964
|
import_koa_useragent = require("koa-useragent");
|
|
25984
25965
|
init_src2();
|
|
25985
25966
|
init_currentapp();
|
|
25967
|
+
import_redis_adapter = require("@socket.io/redis-adapter");
|
|
25968
|
+
init_redis5();
|
|
25969
|
+
import_uuid4 = __toESM(require("uuid"));
|
|
25986
25970
|
}
|
|
25987
25971
|
});
|
|
25988
25972
|
|
|
25989
|
-
// src/
|
|
25990
|
-
var
|
|
25991
|
-
"src/
|
|
25992
|
-
|
|
25993
|
-
|
|
25973
|
+
// src/middleware/builder.ts
|
|
25974
|
+
var init_builder = __esm({
|
|
25975
|
+
"src/middleware/builder.ts"() {
|
|
25976
|
+
init_utils13();
|
|
25977
|
+
init_redis5();
|
|
25978
|
+
init_src2();
|
|
25979
|
+
}
|
|
25980
|
+
});
|
|
25981
|
+
|
|
25982
|
+
// src/middleware/authorized.ts
|
|
25983
|
+
var csrf;
|
|
25984
|
+
var init_authorized = __esm({
|
|
25985
|
+
"src/middleware/authorized.ts"() {
|
|
25994
25986
|
init_src2();
|
|
25987
|
+
init_builder();
|
|
25988
|
+
init_utils19();
|
|
25989
|
+
csrf = auth_exports.buildCsrfMiddleware();
|
|
25995
25990
|
}
|
|
25996
25991
|
});
|
|
25997
25992
|
|
|
@@ -26004,228 +25999,6 @@ var init_client2 = __esm({
|
|
|
26004
25999
|
}
|
|
26005
26000
|
});
|
|
26006
26001
|
|
|
26007
|
-
// src/websockets/index.ts
|
|
26008
|
-
var clientAppSocket;
|
|
26009
|
-
var init_websockets = __esm({
|
|
26010
|
-
"src/websockets/index.ts"() {
|
|
26011
|
-
init_grid();
|
|
26012
|
-
init_client2();
|
|
26013
|
-
}
|
|
26014
|
-
});
|
|
26015
|
-
|
|
26016
|
-
// src/sdk/plugins/plugins.ts
|
|
26017
|
-
var plugins_exports2 = {};
|
|
26018
|
-
__export(plugins_exports2, {
|
|
26019
|
-
fetch: () => fetch16,
|
|
26020
|
-
processUploaded: () => processUploaded
|
|
26021
|
-
});
|
|
26022
|
-
async function fetch16(type) {
|
|
26023
|
-
const db2 = tenancy.getGlobalDB();
|
|
26024
|
-
const response2 = await db2.allDocs(
|
|
26025
|
-
db_exports.getPluginParams(null, {
|
|
26026
|
-
include_docs: true
|
|
26027
|
-
})
|
|
26028
|
-
);
|
|
26029
|
-
let plugins2 = response2.rows.map((row) => row.doc);
|
|
26030
|
-
plugins2 = objectStore_exports2.enrichPluginURLs(plugins2);
|
|
26031
|
-
if (type) {
|
|
26032
|
-
return plugins2.filter((plugin) => {
|
|
26033
|
-
var _a;
|
|
26034
|
-
return ((_a = plugin.schema) == null ? void 0 : _a.type) === type;
|
|
26035
|
-
});
|
|
26036
|
-
} else {
|
|
26037
|
-
return plugins2;
|
|
26038
|
-
}
|
|
26039
|
-
}
|
|
26040
|
-
async function processUploaded(plugin, source) {
|
|
26041
|
-
var _a;
|
|
26042
|
-
const { metadata, directory } = await fileUpload(plugin);
|
|
26043
|
-
plugin_exports.validate(metadata == null ? void 0 : metadata.schema);
|
|
26044
|
-
if (!environment_default.SELF_HOSTED && ((_a = metadata == null ? void 0 : metadata.schema) == null ? void 0 : _a.type) !== "component" /* COMPONENT */) {
|
|
26045
|
-
throw new Error("Only component plugins are supported outside of self-host");
|
|
26046
|
-
}
|
|
26047
|
-
const doc = await sdk_exports.plugins.storePlugin(metadata, directory, source);
|
|
26048
|
-
clientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash });
|
|
26049
|
-
return doc;
|
|
26050
|
-
}
|
|
26051
|
-
var init_plugins4 = __esm({
|
|
26052
|
-
"src/sdk/plugins/plugins.ts"() {
|
|
26053
|
-
init_src();
|
|
26054
|
-
init_src2();
|
|
26055
|
-
init_file();
|
|
26056
|
-
init_environment();
|
|
26057
|
-
init_websockets();
|
|
26058
|
-
init_src4();
|
|
26059
|
-
}
|
|
26060
|
-
});
|
|
26061
|
-
|
|
26062
|
-
// src/sdk/plugins/index.ts
|
|
26063
|
-
var plugins_default;
|
|
26064
|
-
var init_plugins5 = __esm({
|
|
26065
|
-
"src/sdk/plugins/index.ts"() {
|
|
26066
|
-
init_plugins4();
|
|
26067
|
-
plugins_default = {
|
|
26068
|
-
...plugins_exports2
|
|
26069
|
-
};
|
|
26070
|
-
}
|
|
26071
|
-
});
|
|
26072
|
-
|
|
26073
|
-
// src/sdk/index.ts
|
|
26074
|
-
var sdk, sdk_default;
|
|
26075
|
-
var init_sdk3 = __esm({
|
|
26076
|
-
"src/sdk/index.ts"() {
|
|
26077
|
-
init_backups5();
|
|
26078
|
-
init_tables();
|
|
26079
|
-
init_automations5();
|
|
26080
|
-
init_applications();
|
|
26081
|
-
init_datasources3();
|
|
26082
|
-
init_queries3();
|
|
26083
|
-
init_rows5();
|
|
26084
|
-
init_users11();
|
|
26085
|
-
init_plugins5();
|
|
26086
|
-
sdk = {
|
|
26087
|
-
backups: backups_default3,
|
|
26088
|
-
tables: tables_default,
|
|
26089
|
-
automations: automations_default,
|
|
26090
|
-
applications: applications_default,
|
|
26091
|
-
rows: rows_default2,
|
|
26092
|
-
users: users_default,
|
|
26093
|
-
datasources: datasources_default,
|
|
26094
|
-
queries: queries_default,
|
|
26095
|
-
plugins: plugins_default
|
|
26096
|
-
};
|
|
26097
|
-
sdk_default = sdk;
|
|
26098
|
-
}
|
|
26099
|
-
});
|
|
26100
|
-
|
|
26101
|
-
// src/definitions/automations.ts
|
|
26102
|
-
var init_automations6 = __esm({
|
|
26103
|
-
"src/definitions/automations.ts"() {
|
|
26104
|
-
}
|
|
26105
|
-
});
|
|
26106
|
-
|
|
26107
|
-
// src/automations/automationUtils.ts
|
|
26108
|
-
function cleanInputValues(inputs, schema) {
|
|
26109
|
-
var _a, _b;
|
|
26110
|
-
if (schema == null) {
|
|
26111
|
-
return inputs;
|
|
26112
|
-
}
|
|
26113
|
-
for (let inputKey of Object.keys(inputs)) {
|
|
26114
|
-
let input = inputs[inputKey];
|
|
26115
|
-
if (typeof input !== "string") {
|
|
26116
|
-
continue;
|
|
26117
|
-
}
|
|
26118
|
-
let propSchema = schema.properties[inputKey];
|
|
26119
|
-
if (!propSchema) {
|
|
26120
|
-
continue;
|
|
26121
|
-
}
|
|
26122
|
-
if (propSchema.type === "boolean") {
|
|
26123
|
-
let lcInput = input.toLowerCase();
|
|
26124
|
-
if (lcInput === "true") {
|
|
26125
|
-
inputs[inputKey] = true;
|
|
26126
|
-
}
|
|
26127
|
-
if (lcInput === "false") {
|
|
26128
|
-
inputs[inputKey] = false;
|
|
26129
|
-
}
|
|
26130
|
-
}
|
|
26131
|
-
if (propSchema.type === "number") {
|
|
26132
|
-
let floatInput = parseFloat(input);
|
|
26133
|
-
if (!isNaN(floatInput)) {
|
|
26134
|
-
inputs[inputKey] = floatInput;
|
|
26135
|
-
}
|
|
26136
|
-
}
|
|
26137
|
-
}
|
|
26138
|
-
for (let key in inputs.row) {
|
|
26139
|
-
if (((_b = (_a = inputs.schema) == null ? void 0 : _a[key]) == null ? void 0 : _b.type) === "link" && inputs.row[key] && typeof inputs.row[key] === "string") {
|
|
26140
|
-
try {
|
|
26141
|
-
inputs.row[key] = JSON.parse(inputs.row[key]);
|
|
26142
|
-
} catch (e) {
|
|
26143
|
-
}
|
|
26144
|
-
}
|
|
26145
|
-
}
|
|
26146
|
-
return inputs;
|
|
26147
|
-
}
|
|
26148
|
-
async function cleanUpRow(tableId, row) {
|
|
26149
|
-
let table = await sdk_default.tables.getTable(tableId);
|
|
26150
|
-
return cleanInputValues(row, { properties: table.schema });
|
|
26151
|
-
}
|
|
26152
|
-
function getError(err) {
|
|
26153
|
-
if (err == null) {
|
|
26154
|
-
return "No error provided.";
|
|
26155
|
-
}
|
|
26156
|
-
if (typeof err === "object" && (err.toString == null || err.toString() === "[object Object]")) {
|
|
26157
|
-
return JSON.stringify(err);
|
|
26158
|
-
}
|
|
26159
|
-
return typeof err !== "string" ? err.toString() : err;
|
|
26160
|
-
}
|
|
26161
|
-
function substituteLoopStep(hbsString, substitute) {
|
|
26162
|
-
let checkForJS = (0, import_string_templates3.isJSBinding)(hbsString);
|
|
26163
|
-
let substitutedHbsString = "";
|
|
26164
|
-
let open = checkForJS ? `$("` : "{{";
|
|
26165
|
-
let closed = checkForJS ? `")` : "}}";
|
|
26166
|
-
if (checkForJS) {
|
|
26167
|
-
hbsString = (0, import_string_templates3.decodeJSBinding)(hbsString);
|
|
26168
|
-
}
|
|
26169
|
-
let pointer = 0, openPointer = 0, closedPointer = 0;
|
|
26170
|
-
while (pointer < (hbsString == null ? void 0 : hbsString.length)) {
|
|
26171
|
-
openPointer = hbsString.indexOf(open, pointer);
|
|
26172
|
-
closedPointer = hbsString.indexOf(closed, pointer) + 2;
|
|
26173
|
-
if (openPointer < 0 || closedPointer < 0) {
|
|
26174
|
-
substitutedHbsString += hbsString.substring(pointer);
|
|
26175
|
-
break;
|
|
26176
|
-
}
|
|
26177
|
-
let before = hbsString.substring(pointer, openPointer);
|
|
26178
|
-
let block = hbsString.substring(openPointer, closedPointer).replace(/loop/, substitute);
|
|
26179
|
-
substitutedHbsString += before + block;
|
|
26180
|
-
pointer = closedPointer;
|
|
26181
|
-
}
|
|
26182
|
-
if (checkForJS) {
|
|
26183
|
-
substitutedHbsString = (0, import_string_templates3.encodeJSBinding)(substitutedHbsString);
|
|
26184
|
-
}
|
|
26185
|
-
return substitutedHbsString;
|
|
26186
|
-
}
|
|
26187
|
-
function stringSplit(value) {
|
|
26188
|
-
if (value == null || Array.isArray(value)) {
|
|
26189
|
-
return value || [];
|
|
26190
|
-
}
|
|
26191
|
-
if (value.split("\n").length > 1) {
|
|
26192
|
-
value = value.split("\n");
|
|
26193
|
-
} else {
|
|
26194
|
-
value = value.split(",");
|
|
26195
|
-
}
|
|
26196
|
-
return value;
|
|
26197
|
-
}
|
|
26198
|
-
function typecastForLooping(loopStep, input) {
|
|
26199
|
-
if (!input || !input.binding) {
|
|
26200
|
-
return null;
|
|
26201
|
-
}
|
|
26202
|
-
try {
|
|
26203
|
-
switch (loopStep.inputs.option) {
|
|
26204
|
-
case "Array" /* ARRAY */:
|
|
26205
|
-
if (typeof input.binding === "string") {
|
|
26206
|
-
return JSON.parse(input.binding);
|
|
26207
|
-
}
|
|
26208
|
-
break;
|
|
26209
|
-
case "String" /* STRING */:
|
|
26210
|
-
if (Array.isArray(input.binding)) {
|
|
26211
|
-
return input.binding.join(",");
|
|
26212
|
-
}
|
|
26213
|
-
break;
|
|
26214
|
-
}
|
|
26215
|
-
} catch (err) {
|
|
26216
|
-
throw new Error("Unable to cast to correct type");
|
|
26217
|
-
}
|
|
26218
|
-
return input.binding;
|
|
26219
|
-
}
|
|
26220
|
-
var import_string_templates3;
|
|
26221
|
-
var init_automationUtils = __esm({
|
|
26222
|
-
"src/automations/automationUtils.ts"() {
|
|
26223
|
-
import_string_templates3 = __toESM(require_src2());
|
|
26224
|
-
init_sdk3();
|
|
26225
|
-
init_automations6();
|
|
26226
|
-
}
|
|
26227
|
-
});
|
|
26228
|
-
|
|
26229
26002
|
// src/utilities/users.ts
|
|
26230
26003
|
async function getFullUser(ctx, userId) {
|
|
26231
26004
|
const global = await getGlobalUser(userId);
|
|
@@ -26379,6 +26152,7 @@ __export(utils_exports9, {
|
|
|
26379
26152
|
cleanExportRows: () => cleanExportRows,
|
|
26380
26153
|
findRow: () => findRow,
|
|
26381
26154
|
getDatasourceAndQuery: () => getDatasourceAndQuery,
|
|
26155
|
+
getTableId: () => getTableId,
|
|
26382
26156
|
validate: () => validate3
|
|
26383
26157
|
});
|
|
26384
26158
|
async function getDatasourceAndQuery(json2) {
|
|
@@ -26417,7 +26191,7 @@ async function validate3({
|
|
|
26417
26191
|
const errors = {};
|
|
26418
26192
|
for (let fieldName of Object.keys(fetchedTable.schema)) {
|
|
26419
26193
|
const column = fetchedTable.schema[fieldName];
|
|
26420
|
-
const constraints =
|
|
26194
|
+
const constraints = cloneDeep5(column.constraints);
|
|
26421
26195
|
const type = column.type;
|
|
26422
26196
|
if (type === "formula" /* FORMULA */ || column.autocolumn) {
|
|
26423
26197
|
continue;
|
|
@@ -26482,9 +26256,20 @@ function cleanExportRows(rows2, schema, format, columns) {
|
|
|
26482
26256
|
}
|
|
26483
26257
|
}
|
|
26484
26258
|
}
|
|
26485
|
-
return cleanRows;
|
|
26259
|
+
return cleanRows;
|
|
26260
|
+
}
|
|
26261
|
+
function getTableId(ctx) {
|
|
26262
|
+
if (ctx.request.body && ctx.request.body.tableId) {
|
|
26263
|
+
return ctx.request.body.tableId;
|
|
26264
|
+
}
|
|
26265
|
+
if (ctx.params && ctx.params.tableId) {
|
|
26266
|
+
return ctx.params.tableId;
|
|
26267
|
+
}
|
|
26268
|
+
if (ctx.params && ctx.params.viewName) {
|
|
26269
|
+
return ctx.params.viewName;
|
|
26270
|
+
}
|
|
26486
26271
|
}
|
|
26487
|
-
var validateJs,
|
|
26272
|
+
var validateJs, cloneDeep5;
|
|
26488
26273
|
var init_utils20 = __esm({
|
|
26489
26274
|
"src/api/controllers/row/utils.ts"() {
|
|
26490
26275
|
init_utils13();
|
|
@@ -26495,7 +26280,7 @@ var init_utils20 = __esm({
|
|
|
26495
26280
|
init_exporters();
|
|
26496
26281
|
init_sdk3();
|
|
26497
26282
|
validateJs = require("validate.js");
|
|
26498
|
-
({ cloneDeep:
|
|
26283
|
+
({ cloneDeep: cloneDeep5 } = require("lodash/fp"));
|
|
26499
26284
|
validateJs.extend(validateJs.validators.datetime, {
|
|
26500
26285
|
parse: function(value) {
|
|
26501
26286
|
return new Date(value).getTime();
|
|
@@ -26508,6 +26293,250 @@ var init_utils20 = __esm({
|
|
|
26508
26293
|
}
|
|
26509
26294
|
});
|
|
26510
26295
|
|
|
26296
|
+
// src/websockets/grid.ts
|
|
26297
|
+
var init_grid = __esm({
|
|
26298
|
+
"src/websockets/grid.ts"() {
|
|
26299
|
+
init_authorized();
|
|
26300
|
+
init_websocket();
|
|
26301
|
+
init_src2();
|
|
26302
|
+
init_utils20();
|
|
26303
|
+
}
|
|
26304
|
+
});
|
|
26305
|
+
|
|
26306
|
+
// src/websockets/builder.ts
|
|
26307
|
+
var init_builder2 = __esm({
|
|
26308
|
+
"src/websockets/builder.ts"() {
|
|
26309
|
+
init_authorized();
|
|
26310
|
+
init_websocket();
|
|
26311
|
+
init_src2();
|
|
26312
|
+
init_websockets();
|
|
26313
|
+
init_redis5();
|
|
26314
|
+
}
|
|
26315
|
+
});
|
|
26316
|
+
|
|
26317
|
+
// src/websockets/index.ts
|
|
26318
|
+
var clientAppSocket, gridSocket;
|
|
26319
|
+
var init_websockets = __esm({
|
|
26320
|
+
"src/websockets/index.ts"() {
|
|
26321
|
+
init_client2();
|
|
26322
|
+
init_grid();
|
|
26323
|
+
init_builder2();
|
|
26324
|
+
}
|
|
26325
|
+
});
|
|
26326
|
+
|
|
26327
|
+
// src/sdk/plugins/plugins.ts
|
|
26328
|
+
var plugins_exports2 = {};
|
|
26329
|
+
__export(plugins_exports2, {
|
|
26330
|
+
fetch: () => fetch16,
|
|
26331
|
+
processUploaded: () => processUploaded
|
|
26332
|
+
});
|
|
26333
|
+
async function fetch16(type) {
|
|
26334
|
+
const db2 = tenancy.getGlobalDB();
|
|
26335
|
+
const response2 = await db2.allDocs(
|
|
26336
|
+
db_exports.getPluginParams(null, {
|
|
26337
|
+
include_docs: true
|
|
26338
|
+
})
|
|
26339
|
+
);
|
|
26340
|
+
let plugins2 = response2.rows.map((row) => row.doc);
|
|
26341
|
+
plugins2 = objectStore_exports2.enrichPluginURLs(plugins2);
|
|
26342
|
+
if (type) {
|
|
26343
|
+
return plugins2.filter((plugin) => {
|
|
26344
|
+
var _a;
|
|
26345
|
+
return ((_a = plugin.schema) == null ? void 0 : _a.type) === type;
|
|
26346
|
+
});
|
|
26347
|
+
} else {
|
|
26348
|
+
return plugins2;
|
|
26349
|
+
}
|
|
26350
|
+
}
|
|
26351
|
+
async function processUploaded(plugin, source) {
|
|
26352
|
+
var _a;
|
|
26353
|
+
const { metadata, directory } = await fileUpload(plugin);
|
|
26354
|
+
plugin_exports.validate(metadata == null ? void 0 : metadata.schema);
|
|
26355
|
+
if (!environment_default.SELF_HOSTED && ((_a = metadata == null ? void 0 : metadata.schema) == null ? void 0 : _a.type) !== "component" /* COMPONENT */) {
|
|
26356
|
+
throw new Error("Only component plugins are supported outside of self-host");
|
|
26357
|
+
}
|
|
26358
|
+
const doc = await sdk_exports.plugins.storePlugin(metadata, directory, source);
|
|
26359
|
+
clientAppSocket.emit("plugin-update", { name: doc.name, hash: doc.hash });
|
|
26360
|
+
return doc;
|
|
26361
|
+
}
|
|
26362
|
+
var init_plugins4 = __esm({
|
|
26363
|
+
"src/sdk/plugins/plugins.ts"() {
|
|
26364
|
+
init_src();
|
|
26365
|
+
init_src2();
|
|
26366
|
+
init_file();
|
|
26367
|
+
init_environment();
|
|
26368
|
+
init_websockets();
|
|
26369
|
+
init_src4();
|
|
26370
|
+
}
|
|
26371
|
+
});
|
|
26372
|
+
|
|
26373
|
+
// src/sdk/plugins/index.ts
|
|
26374
|
+
var plugins_default;
|
|
26375
|
+
var init_plugins5 = __esm({
|
|
26376
|
+
"src/sdk/plugins/index.ts"() {
|
|
26377
|
+
init_plugins4();
|
|
26378
|
+
plugins_default = {
|
|
26379
|
+
...plugins_exports2
|
|
26380
|
+
};
|
|
26381
|
+
}
|
|
26382
|
+
});
|
|
26383
|
+
|
|
26384
|
+
// src/sdk/index.ts
|
|
26385
|
+
var sdk, sdk_default;
|
|
26386
|
+
var init_sdk3 = __esm({
|
|
26387
|
+
"src/sdk/index.ts"() {
|
|
26388
|
+
init_backups5();
|
|
26389
|
+
init_tables();
|
|
26390
|
+
init_automations5();
|
|
26391
|
+
init_applications();
|
|
26392
|
+
init_datasources3();
|
|
26393
|
+
init_queries3();
|
|
26394
|
+
init_rows5();
|
|
26395
|
+
init_users11();
|
|
26396
|
+
init_plugins5();
|
|
26397
|
+
sdk = {
|
|
26398
|
+
backups: backups_default3,
|
|
26399
|
+
tables: tables_default,
|
|
26400
|
+
automations: automations_default,
|
|
26401
|
+
applications: applications_default,
|
|
26402
|
+
rows: rows_default2,
|
|
26403
|
+
users: users_default,
|
|
26404
|
+
datasources: datasources_default,
|
|
26405
|
+
queries: queries_default,
|
|
26406
|
+
plugins: plugins_default
|
|
26407
|
+
};
|
|
26408
|
+
sdk_default = sdk;
|
|
26409
|
+
}
|
|
26410
|
+
});
|
|
26411
|
+
|
|
26412
|
+
// src/definitions/automations.ts
|
|
26413
|
+
var init_automations6 = __esm({
|
|
26414
|
+
"src/definitions/automations.ts"() {
|
|
26415
|
+
}
|
|
26416
|
+
});
|
|
26417
|
+
|
|
26418
|
+
// src/automations/automationUtils.ts
|
|
26419
|
+
function cleanInputValues(inputs, schema) {
|
|
26420
|
+
var _a, _b;
|
|
26421
|
+
if (schema == null) {
|
|
26422
|
+
return inputs;
|
|
26423
|
+
}
|
|
26424
|
+
for (let inputKey of Object.keys(inputs)) {
|
|
26425
|
+
let input = inputs[inputKey];
|
|
26426
|
+
if (typeof input !== "string") {
|
|
26427
|
+
continue;
|
|
26428
|
+
}
|
|
26429
|
+
let propSchema = schema.properties[inputKey];
|
|
26430
|
+
if (!propSchema) {
|
|
26431
|
+
continue;
|
|
26432
|
+
}
|
|
26433
|
+
if (propSchema.type === "boolean") {
|
|
26434
|
+
let lcInput = input.toLowerCase();
|
|
26435
|
+
if (lcInput === "true") {
|
|
26436
|
+
inputs[inputKey] = true;
|
|
26437
|
+
}
|
|
26438
|
+
if (lcInput === "false") {
|
|
26439
|
+
inputs[inputKey] = false;
|
|
26440
|
+
}
|
|
26441
|
+
}
|
|
26442
|
+
if (propSchema.type === "number") {
|
|
26443
|
+
let floatInput = parseFloat(input);
|
|
26444
|
+
if (!isNaN(floatInput)) {
|
|
26445
|
+
inputs[inputKey] = floatInput;
|
|
26446
|
+
}
|
|
26447
|
+
}
|
|
26448
|
+
}
|
|
26449
|
+
for (let key in inputs.row) {
|
|
26450
|
+
if (((_b = (_a = inputs.schema) == null ? void 0 : _a[key]) == null ? void 0 : _b.type) === "link" && inputs.row[key] && typeof inputs.row[key] === "string") {
|
|
26451
|
+
try {
|
|
26452
|
+
inputs.row[key] = JSON.parse(inputs.row[key]);
|
|
26453
|
+
} catch (e) {
|
|
26454
|
+
}
|
|
26455
|
+
}
|
|
26456
|
+
}
|
|
26457
|
+
return inputs;
|
|
26458
|
+
}
|
|
26459
|
+
async function cleanUpRow(tableId, row) {
|
|
26460
|
+
let table = await sdk_default.tables.getTable(tableId);
|
|
26461
|
+
return cleanInputValues(row, { properties: table.schema });
|
|
26462
|
+
}
|
|
26463
|
+
function getError(err) {
|
|
26464
|
+
if (err == null) {
|
|
26465
|
+
return "No error provided.";
|
|
26466
|
+
}
|
|
26467
|
+
if (typeof err === "object" && (err.toString == null || err.toString() === "[object Object]")) {
|
|
26468
|
+
return JSON.stringify(err);
|
|
26469
|
+
}
|
|
26470
|
+
return typeof err !== "string" ? err.toString() : err;
|
|
26471
|
+
}
|
|
26472
|
+
function substituteLoopStep(hbsString, substitute) {
|
|
26473
|
+
let checkForJS = (0, import_string_templates3.isJSBinding)(hbsString);
|
|
26474
|
+
let substitutedHbsString = "";
|
|
26475
|
+
let open = checkForJS ? `$("` : "{{";
|
|
26476
|
+
let closed = checkForJS ? `")` : "}}";
|
|
26477
|
+
if (checkForJS) {
|
|
26478
|
+
hbsString = (0, import_string_templates3.decodeJSBinding)(hbsString);
|
|
26479
|
+
}
|
|
26480
|
+
let pointer = 0, openPointer = 0, closedPointer = 0;
|
|
26481
|
+
while (pointer < (hbsString == null ? void 0 : hbsString.length)) {
|
|
26482
|
+
openPointer = hbsString.indexOf(open, pointer);
|
|
26483
|
+
closedPointer = hbsString.indexOf(closed, pointer) + 2;
|
|
26484
|
+
if (openPointer < 0 || closedPointer < 0) {
|
|
26485
|
+
substitutedHbsString += hbsString.substring(pointer);
|
|
26486
|
+
break;
|
|
26487
|
+
}
|
|
26488
|
+
let before = hbsString.substring(pointer, openPointer);
|
|
26489
|
+
let block = hbsString.substring(openPointer, closedPointer).replace(/loop/, substitute);
|
|
26490
|
+
substitutedHbsString += before + block;
|
|
26491
|
+
pointer = closedPointer;
|
|
26492
|
+
}
|
|
26493
|
+
if (checkForJS) {
|
|
26494
|
+
substitutedHbsString = (0, import_string_templates3.encodeJSBinding)(substitutedHbsString);
|
|
26495
|
+
}
|
|
26496
|
+
return substitutedHbsString;
|
|
26497
|
+
}
|
|
26498
|
+
function stringSplit(value) {
|
|
26499
|
+
if (value == null || Array.isArray(value)) {
|
|
26500
|
+
return value || [];
|
|
26501
|
+
}
|
|
26502
|
+
if (value.split("\n").length > 1) {
|
|
26503
|
+
value = value.split("\n");
|
|
26504
|
+
} else {
|
|
26505
|
+
value = value.split(",");
|
|
26506
|
+
}
|
|
26507
|
+
return value;
|
|
26508
|
+
}
|
|
26509
|
+
function typecastForLooping(loopStep, input) {
|
|
26510
|
+
if (!input || !input.binding) {
|
|
26511
|
+
return null;
|
|
26512
|
+
}
|
|
26513
|
+
try {
|
|
26514
|
+
switch (loopStep.inputs.option) {
|
|
26515
|
+
case "Array" /* ARRAY */:
|
|
26516
|
+
if (typeof input.binding === "string") {
|
|
26517
|
+
return JSON.parse(input.binding);
|
|
26518
|
+
}
|
|
26519
|
+
break;
|
|
26520
|
+
case "String" /* STRING */:
|
|
26521
|
+
if (Array.isArray(input.binding)) {
|
|
26522
|
+
return input.binding.join(",");
|
|
26523
|
+
}
|
|
26524
|
+
break;
|
|
26525
|
+
}
|
|
26526
|
+
} catch (err) {
|
|
26527
|
+
throw new Error("Unable to cast to correct type");
|
|
26528
|
+
}
|
|
26529
|
+
return input.binding;
|
|
26530
|
+
}
|
|
26531
|
+
var import_string_templates3;
|
|
26532
|
+
var init_automationUtils = __esm({
|
|
26533
|
+
"src/automations/automationUtils.ts"() {
|
|
26534
|
+
import_string_templates3 = __toESM(require_src2());
|
|
26535
|
+
init_sdk3();
|
|
26536
|
+
init_automations6();
|
|
26537
|
+
}
|
|
26538
|
+
});
|
|
26539
|
+
|
|
26511
26540
|
// src/automations/steps/bash.ts
|
|
26512
26541
|
var bash_exports = {};
|
|
26513
26542
|
__export(bash_exports, {
|
|
@@ -28027,7 +28056,7 @@ var TYPE_TRANSFORM_MAP = {
|
|
|
28027
28056
|
};
|
|
28028
28057
|
|
|
28029
28058
|
// src/utilities/rowProcessor/index.ts
|
|
28030
|
-
var { cloneDeep:
|
|
28059
|
+
var { cloneDeep: cloneDeep7 } = require("lodash/fp");
|
|
28031
28060
|
var BASE_AUTO_ID = 1;
|
|
28032
28061
|
function getRemovedAttachmentKeys(oldRow, row, attachmentKey) {
|
|
28033
28062
|
if (!oldRow[attachmentKey]) {
|
|
@@ -28094,7 +28123,7 @@ function coerce(row, type) {
|
|
|
28094
28123
|
return row;
|
|
28095
28124
|
}
|
|
28096
28125
|
function inputProcessing(user, table, row, opts) {
|
|
28097
|
-
let clonedRow =
|
|
28126
|
+
let clonedRow = cloneDeep7(row);
|
|
28098
28127
|
const dontCleanseKeys = ["type", "_id", "_rev", "tableId"];
|
|
28099
28128
|
for (let [key, value] of Object.entries(clonedRow)) {
|
|
28100
28129
|
const field = table.schema[key];
|
|
@@ -29922,24 +29951,15 @@ async function fetchEnrichedRow2(ctx) {
|
|
|
29922
29951
|
// src/api/controllers/row/index.ts
|
|
29923
29952
|
init_utils14();
|
|
29924
29953
|
init_utils20();
|
|
29954
|
+
init_websockets();
|
|
29925
29955
|
function pickApi(tableId) {
|
|
29926
29956
|
if (isExternalTable(tableId)) {
|
|
29927
29957
|
return external_exports;
|
|
29928
29958
|
}
|
|
29929
29959
|
return internal_exports;
|
|
29930
29960
|
}
|
|
29931
|
-
function getTableId(ctx) {
|
|
29932
|
-
if (ctx.request.body && ctx.request.body.tableId) {
|
|
29933
|
-
return ctx.request.body.tableId;
|
|
29934
|
-
}
|
|
29935
|
-
if (ctx.params && ctx.params.tableId) {
|
|
29936
|
-
return ctx.params.tableId;
|
|
29937
|
-
}
|
|
29938
|
-
if (ctx.params && ctx.params.viewName) {
|
|
29939
|
-
return ctx.params.viewName;
|
|
29940
|
-
}
|
|
29941
|
-
}
|
|
29942
29961
|
async function patch3(ctx) {
|
|
29962
|
+
var _a;
|
|
29943
29963
|
const appId = ctx.appId;
|
|
29944
29964
|
const tableId = getTableId(ctx);
|
|
29945
29965
|
const body2 = ctx.request.body;
|
|
@@ -29960,11 +29980,13 @@ async function patch3(ctx) {
|
|
|
29960
29980
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table);
|
|
29961
29981
|
ctx.message = `${table.name} updated successfully.`;
|
|
29962
29982
|
ctx.body = row;
|
|
29983
|
+
(_a = gridSocket) == null ? void 0 : _a.emitRowUpdate(ctx, row);
|
|
29963
29984
|
} catch (err) {
|
|
29964
29985
|
ctx.throw(400, err);
|
|
29965
29986
|
}
|
|
29966
29987
|
}
|
|
29967
29988
|
var save10 = async (ctx) => {
|
|
29989
|
+
var _a;
|
|
29968
29990
|
const appId = ctx.appId;
|
|
29969
29991
|
const tableId = getTableId(ctx);
|
|
29970
29992
|
const body2 = ctx.request.body;
|
|
@@ -29980,8 +30002,10 @@ var save10 = async (ctx) => {
|
|
|
29980
30002
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:save`, appId, row, table);
|
|
29981
30003
|
ctx.message = `${table.name} saved successfully`;
|
|
29982
30004
|
ctx.body = row;
|
|
30005
|
+
(_a = gridSocket) == null ? void 0 : _a.emitRowUpdate(ctx, row);
|
|
29983
30006
|
};
|
|
29984
30007
|
async function destroy9(ctx) {
|
|
30008
|
+
var _a, _b;
|
|
29985
30009
|
const appId = ctx.appId;
|
|
29986
30010
|
const inputs = ctx.request.body;
|
|
29987
30011
|
const tableId = getTableId(ctx);
|
|
@@ -29997,6 +30021,7 @@ async function destroy9(ctx) {
|
|
|
29997
30021
|
response2 = rows2;
|
|
29998
30022
|
for (let row2 of rows2) {
|
|
29999
30023
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row2);
|
|
30024
|
+
(_a = gridSocket) == null ? void 0 : _a.emitRowDeletion(ctx, row2._id);
|
|
30000
30025
|
}
|
|
30001
30026
|
} else {
|
|
30002
30027
|
let resp = await quotas_exports4.addQuery(() => pickApi(tableId).destroy(ctx), {
|
|
@@ -30006,6 +30031,7 @@ async function destroy9(ctx) {
|
|
|
30006
30031
|
response2 = resp.response;
|
|
30007
30032
|
row = resp.row;
|
|
30008
30033
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:delete`, appId, row);
|
|
30034
|
+
(_b = gridSocket) == null ? void 0 : _b.emitRowDeletion(ctx, row._id);
|
|
30009
30035
|
}
|
|
30010
30036
|
ctx.status = 200;
|
|
30011
30037
|
ctx.row = row || {};
|
|
@@ -30511,6 +30537,7 @@ init_integrations2();
|
|
|
30511
30537
|
init_utils20();
|
|
30512
30538
|
init_src2();
|
|
30513
30539
|
init_sdk3();
|
|
30540
|
+
init_websockets();
|
|
30514
30541
|
|
|
30515
30542
|
// src/api/controllers/query/validation.ts
|
|
30516
30543
|
init_src2();
|
|
@@ -31447,6 +31474,7 @@ init_sdk3();
|
|
|
31447
31474
|
var import_csvtojson2 = __toESM(require("csvtojson"));
|
|
31448
31475
|
|
|
31449
31476
|
// src/api/controllers/table/index.ts
|
|
31477
|
+
init_websockets();
|
|
31450
31478
|
async function find7(ctx) {
|
|
31451
31479
|
const tableId = ctx.params.tableId;
|
|
31452
31480
|
ctx.body = await sdk_default.tables.getTable(tableId);
|