@budibase/server 2.6.19-alpha.48 → 2.6.19-alpha.49
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.95754dff.js → index.66019862.js} +249 -249
- package/builder/index.html +1 -1
- package/dist/automation.js +45 -18
- package/dist/automation.js.map +3 -3
- package/dist/index.js +82 -30
- package/dist/index.js.map +3 -3
- package/dist/query.js +1 -0
- package/dist/query.js.map +2 -2
- package/package.json +8 -8
- package/src/api/controllers/row/external.ts +39 -15
- package/src/api/controllers/row/index.ts +4 -3
- package/src/api/controllers/row/staticFormula.ts +6 -1
- package/src/db/linkedRows/index.ts +5 -3
- package/src/utilities/rowProcessor/index.ts +4 -1
- package/src/websockets/builder.ts +15 -12
- package/src/websockets/grid.ts +12 -8
- package/src/websockets/websocket.ts +10 -1
package/dist/index.js
CHANGED
|
@@ -1512,6 +1512,7 @@ var init_misc = __esm({
|
|
|
1512
1512
|
Header2["LICENSE_KEY"] = "x-budibase-license-key";
|
|
1513
1513
|
Header2["API_VER"] = "x-budibase-api-version";
|
|
1514
1514
|
Header2["APP_ID"] = "x-budibase-app-id";
|
|
1515
|
+
Header2["SESSION_ID"] = "x-budibase-session-id";
|
|
1515
1516
|
Header2["TYPE"] = "x-budibase-type";
|
|
1516
1517
|
Header2["PREVIEW_ROLE"] = "x-budibase-role";
|
|
1517
1518
|
Header2["TENANT_ID"] = "x-budibase-tenant-id";
|
|
@@ -21290,7 +21291,9 @@ async function attachFullLinkedDocs(table2, rows2) {
|
|
|
21290
21291
|
}
|
|
21291
21292
|
async function squashLinksToPrimaryDisplay(table2, enriched) {
|
|
21292
21293
|
const linkedTables = [table2];
|
|
21293
|
-
|
|
21294
|
+
const isArray = Array.isArray(enriched);
|
|
21295
|
+
let enrichedArray = !isArray ? [enriched] : enriched;
|
|
21296
|
+
for (let row2 of enrichedArray) {
|
|
21294
21297
|
const rowTable = await getLinkedTable(row2.tableId, linkedTables);
|
|
21295
21298
|
for (let [column, schema] of Object.entries((rowTable == null ? void 0 : rowTable.schema) || {})) {
|
|
21296
21299
|
if (schema.type !== "link" /* LINK */ || !Array.isArray(row2[column])) {
|
|
@@ -21309,7 +21312,7 @@ async function squashLinksToPrimaryDisplay(table2, enriched) {
|
|
|
21309
21312
|
row2[column] = newLinks;
|
|
21310
21313
|
}
|
|
21311
21314
|
}
|
|
21312
|
-
return
|
|
21315
|
+
return isArray ? enrichedArray : enrichedArray[0];
|
|
21313
21316
|
}
|
|
21314
21317
|
var import_lodash2, import_lodash3, EventType;
|
|
21315
21318
|
var init_linkedRows = __esm({
|
|
@@ -21636,7 +21639,10 @@ async function outputProcessing(table2, rows2, opts = { squash: true }) {
|
|
|
21636
21639
|
}
|
|
21637
21640
|
}
|
|
21638
21641
|
if (opts.squash) {
|
|
21639
|
-
enriched = await squashLinksToPrimaryDisplay(
|
|
21642
|
+
enriched = await squashLinksToPrimaryDisplay(
|
|
21643
|
+
table2,
|
|
21644
|
+
enriched
|
|
21645
|
+
);
|
|
21640
21646
|
}
|
|
21641
21647
|
return wasArray ? enriched : enriched[0];
|
|
21642
21648
|
}
|
|
@@ -31294,6 +31300,15 @@ var init_websocket2 = __esm({
|
|
|
31294
31300
|
emit(event, payload) {
|
|
31295
31301
|
this.io.sockets.emit(event, payload);
|
|
31296
31302
|
}
|
|
31303
|
+
// Emit an event to everyone in a room, including metadata of whom
|
|
31304
|
+
// the originator of the request was
|
|
31305
|
+
emitToRoom(ctx, room, event, payload) {
|
|
31306
|
+
var _a2;
|
|
31307
|
+
this.io.in(room).emit(event, {
|
|
31308
|
+
...payload,
|
|
31309
|
+
apiSessionId: (_a2 = ctx.headers) == null ? void 0 : _a2["x-budibase-session-id" /* SESSION_ID */]
|
|
31310
|
+
});
|
|
31311
|
+
}
|
|
31297
31312
|
};
|
|
31298
31313
|
}
|
|
31299
31314
|
});
|
|
@@ -31642,17 +31657,23 @@ var init_grid = __esm({
|
|
|
31642
31657
|
}
|
|
31643
31658
|
emitRowUpdate(ctx, row2) {
|
|
31644
31659
|
const tableId = getTableId(ctx);
|
|
31645
|
-
this.
|
|
31660
|
+
this.emitToRoom(ctx, tableId, "RowChange" /* RowChange */, {
|
|
31661
|
+
id: row2._id,
|
|
31662
|
+
row: row2
|
|
31663
|
+
});
|
|
31646
31664
|
}
|
|
31647
31665
|
emitRowDeletion(ctx, id) {
|
|
31648
31666
|
const tableId = getTableId(ctx);
|
|
31649
|
-
this.
|
|
31667
|
+
this.emitToRoom(ctx, tableId, "RowChange" /* RowChange */, { id, row: null });
|
|
31650
31668
|
}
|
|
31651
|
-
emitTableUpdate(table2) {
|
|
31652
|
-
this.
|
|
31669
|
+
emitTableUpdate(ctx, table2) {
|
|
31670
|
+
this.emitToRoom(ctx, table2._id, "TableChange" /* TableChange */, {
|
|
31671
|
+
id: table2._id,
|
|
31672
|
+
table: table2
|
|
31673
|
+
});
|
|
31653
31674
|
}
|
|
31654
|
-
emitTableDeletion(id) {
|
|
31655
|
-
this.
|
|
31675
|
+
emitTableDeletion(ctx, id) {
|
|
31676
|
+
this.emitToRoom(ctx, id, "TableChange" /* TableChange */, { id, table: null });
|
|
31656
31677
|
}
|
|
31657
31678
|
};
|
|
31658
31679
|
}
|
|
@@ -31696,22 +31717,31 @@ var init_builder2 = __esm({
|
|
|
31696
31717
|
}
|
|
31697
31718
|
emitTableUpdate(ctx, table2) {
|
|
31698
31719
|
var _a2;
|
|
31699
|
-
this.
|
|
31700
|
-
|
|
31720
|
+
this.emitToRoom(ctx, ctx.appId, "TableChange" /* TableChange */, {
|
|
31721
|
+
id: table2._id,
|
|
31722
|
+
table: table2
|
|
31723
|
+
});
|
|
31724
|
+
(_a2 = gridSocket) == null ? void 0 : _a2.emitTableUpdate(ctx, table2);
|
|
31701
31725
|
}
|
|
31702
31726
|
emitTableDeletion(ctx, id) {
|
|
31703
31727
|
var _a2;
|
|
31704
|
-
this.
|
|
31705
|
-
|
|
31728
|
+
this.emitToRoom(ctx, ctx.appId, "TableChange" /* TableChange */, {
|
|
31729
|
+
id,
|
|
31730
|
+
table: null
|
|
31731
|
+
});
|
|
31732
|
+
(_a2 = gridSocket) == null ? void 0 : _a2.emitTableDeletion(ctx, id);
|
|
31706
31733
|
}
|
|
31707
31734
|
emitDatasourceUpdate(ctx, datasource2) {
|
|
31708
|
-
this.
|
|
31735
|
+
this.emitToRoom(ctx, ctx.appId, "DatasourceChange" /* DatasourceChange */, {
|
|
31709
31736
|
id: datasource2._id,
|
|
31710
31737
|
datasource: datasource2
|
|
31711
31738
|
});
|
|
31712
31739
|
}
|
|
31713
31740
|
emitDatasourceDeletion(ctx, id) {
|
|
31714
|
-
this.
|
|
31741
|
+
this.emitToRoom(ctx, ctx.appId, "DatasourceChange" /* DatasourceChange */, {
|
|
31742
|
+
id,
|
|
31743
|
+
datasource: null
|
|
31744
|
+
});
|
|
31715
31745
|
}
|
|
31716
31746
|
};
|
|
31717
31747
|
}
|
|
@@ -32215,7 +32245,11 @@ async function finaliseRow(table2, row2, { oldTable, updateFormula } = {
|
|
|
32215
32245
|
if (updateFormula) {
|
|
32216
32246
|
await updateRelatedFormula(table2, enrichedRow);
|
|
32217
32247
|
}
|
|
32218
|
-
|
|
32248
|
+
const squashed = await squashLinksToPrimaryDisplay(
|
|
32249
|
+
table2,
|
|
32250
|
+
enrichedRow
|
|
32251
|
+
);
|
|
32252
|
+
return { row: enrichedRow, squashed, table: table2 };
|
|
32219
32253
|
}
|
|
32220
32254
|
var isEqual3, cloneDeep9;
|
|
32221
32255
|
var init_staticFormula = __esm({
|
|
@@ -32224,6 +32258,7 @@ var init_staticFormula = __esm({
|
|
|
32224
32258
|
init_rowProcessor();
|
|
32225
32259
|
init_constants4();
|
|
32226
32260
|
init_src2();
|
|
32261
|
+
init_linkedRows();
|
|
32227
32262
|
({ isEqual: isEqual3 } = require("lodash"));
|
|
32228
32263
|
({ cloneDeep: cloneDeep9 } = require("lodash/fp"));
|
|
32229
32264
|
}
|
|
@@ -33277,6 +33312,13 @@ __export(external_exports, {
|
|
|
33277
33312
|
save: () => save10,
|
|
33278
33313
|
search: () => search4
|
|
33279
33314
|
});
|
|
33315
|
+
async function getRow(tableId, rowId, opts) {
|
|
33316
|
+
const response2 = await handleRequest("READ" /* READ */, tableId, {
|
|
33317
|
+
id: breakRowIdField(rowId),
|
|
33318
|
+
includeSqlRelationships: (opts == null ? void 0 : opts.relationships) ? 1 /* INCLUDE */ : 0 /* EXCLUDE */
|
|
33319
|
+
});
|
|
33320
|
+
return response2 ? response2[0] : response2;
|
|
33321
|
+
}
|
|
33280
33322
|
async function handleRequest(operation, tableId, opts) {
|
|
33281
33323
|
if (opts && opts.filters) {
|
|
33282
33324
|
for (let filterField of NoEmptyFilterStrings) {
|
|
@@ -33306,11 +33348,15 @@ async function patch2(ctx) {
|
|
|
33306
33348
|
if (!validateResult.valid) {
|
|
33307
33349
|
throw { validation: validateResult.errors };
|
|
33308
33350
|
}
|
|
33309
|
-
|
|
33351
|
+
const response2 = await handleRequest("UPDATE" /* UPDATE */, tableId, {
|
|
33310
33352
|
id: breakRowIdField(id),
|
|
33311
|
-
row: inputs
|
|
33312
|
-
includeSqlRelationships: 1 /* INCLUDE */
|
|
33353
|
+
row: inputs
|
|
33313
33354
|
});
|
|
33355
|
+
const row2 = await getRow(tableId, id, { relationships: true });
|
|
33356
|
+
return {
|
|
33357
|
+
...response2,
|
|
33358
|
+
row: row2
|
|
33359
|
+
};
|
|
33314
33360
|
}
|
|
33315
33361
|
async function save10(ctx) {
|
|
33316
33362
|
const inputs = ctx.request.body;
|
|
@@ -33322,10 +33368,20 @@ async function save10(ctx) {
|
|
|
33322
33368
|
if (!validateResult.valid) {
|
|
33323
33369
|
throw { validation: validateResult.errors };
|
|
33324
33370
|
}
|
|
33325
|
-
|
|
33326
|
-
row: inputs
|
|
33327
|
-
includeSqlRelationships: 0 /* EXCLUDE */
|
|
33371
|
+
const response2 = await handleRequest("CREATE" /* CREATE */, tableId, {
|
|
33372
|
+
row: inputs
|
|
33328
33373
|
});
|
|
33374
|
+
const responseRow = response2;
|
|
33375
|
+
const rowId = responseRow.row._id;
|
|
33376
|
+
if (rowId) {
|
|
33377
|
+
const row2 = await getRow(tableId, rowId, { relationships: true });
|
|
33378
|
+
return {
|
|
33379
|
+
...response2,
|
|
33380
|
+
row: row2
|
|
33381
|
+
};
|
|
33382
|
+
} else {
|
|
33383
|
+
return response2;
|
|
33384
|
+
}
|
|
33329
33385
|
}
|
|
33330
33386
|
async function fetchView2(ctx) {
|
|
33331
33387
|
const split = ctx.params.viewName.split("all_");
|
|
@@ -33341,11 +33397,7 @@ async function fetch19(ctx) {
|
|
|
33341
33397
|
async function find6(ctx) {
|
|
33342
33398
|
const id = ctx.params.rowId;
|
|
33343
33399
|
const tableId = ctx.params.tableId;
|
|
33344
|
-
|
|
33345
|
-
id: breakRowIdField(id),
|
|
33346
|
-
includeSqlRelationships: 0 /* EXCLUDE */
|
|
33347
|
-
});
|
|
33348
|
-
return response2 ? response2[0] : response2;
|
|
33400
|
+
return getRow(tableId, id);
|
|
33349
33401
|
}
|
|
33350
33402
|
async function destroy9(ctx) {
|
|
33351
33403
|
const tableId = ctx.params.tableId;
|
|
@@ -33656,7 +33708,7 @@ var init_row2 = __esm({
|
|
|
33656
33708
|
if (body2 && body2._id) {
|
|
33657
33709
|
return patch3(ctx);
|
|
33658
33710
|
}
|
|
33659
|
-
const { row: row2, table: table2 } = await quotas_exports4.addRow(
|
|
33711
|
+
const { row: row2, table: table2, squashed } = await quotas_exports4.addRow(
|
|
33660
33712
|
() => quotas_exports4.addQuery(() => pickApi(tableId).save(ctx), {
|
|
33661
33713
|
datasourceId: tableId
|
|
33662
33714
|
})
|
|
@@ -33664,8 +33716,8 @@ var init_row2 = __esm({
|
|
|
33664
33716
|
ctx.status = 200;
|
|
33665
33717
|
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:save`, appId, row2, table2);
|
|
33666
33718
|
ctx.message = `${table2.name} saved successfully`;
|
|
33667
|
-
ctx.body = row2;
|
|
33668
|
-
(_a2 = gridSocket) == null ? void 0 : _a2.emitRowUpdate(ctx, row2);
|
|
33719
|
+
ctx.body = row2 || squashed;
|
|
33720
|
+
(_a2 = gridSocket) == null ? void 0 : _a2.emitRowUpdate(ctx, row2 || squashed);
|
|
33669
33721
|
};
|
|
33670
33722
|
exportRows3 = async (ctx) => {
|
|
33671
33723
|
const tableId = getTableId(ctx);
|