@budibase/server 2.6.19-alpha.47 → 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.
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
10
10
  rel="stylesheet" />
11
- <script type="module" crossorigin src="/builder/assets/index.e6c92ddc.js"></script>
11
+ <script type="module" crossorigin src="/builder/assets/index.66019862.js"></script>
12
12
  <link rel="stylesheet" href="/builder/assets/index.b7e50d51.css">
13
13
  </head>
14
14
 
@@ -1597,6 +1597,7 @@ var init_misc = __esm({
1597
1597
  Header2["LICENSE_KEY"] = "x-budibase-license-key";
1598
1598
  Header2["API_VER"] = "x-budibase-api-version";
1599
1599
  Header2["APP_ID"] = "x-budibase-app-id";
1600
+ Header2["SESSION_ID"] = "x-budibase-session-id";
1600
1601
  Header2["TYPE"] = "x-budibase-type";
1601
1602
  Header2["PREVIEW_ROLE"] = "x-budibase-role";
1602
1603
  Header2["TENANT_ID"] = "x-budibase-tenant-id";
@@ -28239,7 +28240,10 @@ async function outputProcessing(table, rows2, opts = { squash: true }) {
28239
28240
  }
28240
28241
  }
28241
28242
  if (opts.squash) {
28242
- enriched = await squashLinksToPrimaryDisplay(table, enriched);
28243
+ enriched = await squashLinksToPrimaryDisplay(
28244
+ table,
28245
+ enriched
28246
+ );
28243
28247
  }
28244
28248
  return wasArray ? enriched : enriched[0];
28245
28249
  }
@@ -28395,7 +28399,9 @@ async function attachFullLinkedDocs(table, rows2) {
28395
28399
  }
28396
28400
  async function squashLinksToPrimaryDisplay(table, enriched) {
28397
28401
  const linkedTables = [table];
28398
- for (let row of enriched) {
28402
+ const isArray = Array.isArray(enriched);
28403
+ let enrichedArray = !isArray ? [enriched] : enriched;
28404
+ for (let row of enrichedArray) {
28399
28405
  const rowTable = await getLinkedTable(row.tableId, linkedTables);
28400
28406
  for (let [column, schema] of Object.entries((rowTable == null ? void 0 : rowTable.schema) || {})) {
28401
28407
  if (schema.type !== "link" /* LINK */ || !Array.isArray(row[column])) {
@@ -28414,7 +28420,7 @@ async function squashLinksToPrimaryDisplay(table, enriched) {
28414
28420
  row[column] = newLinks;
28415
28421
  }
28416
28422
  }
28417
- return enriched;
28423
+ return isArray ? enrichedArray : enrichedArray[0];
28418
28424
  }
28419
28425
 
28420
28426
  // src/api/controllers/row/internal.ts
@@ -28754,7 +28760,11 @@ async function finaliseRow(table, row, { oldTable, updateFormula } = {
28754
28760
  if (updateFormula) {
28755
28761
  await updateRelatedFormula(table, enrichedRow);
28756
28762
  }
28757
- return { row: enrichedRow, table };
28763
+ const squashed = await squashLinksToPrimaryDisplay(
28764
+ table,
28765
+ enrichedRow
28766
+ );
28767
+ return { row: enrichedRow, squashed, table };
28758
28768
  }
28759
28769
 
28760
28770
  // src/api/controllers/row/internal.ts
@@ -29777,6 +29787,13 @@ init_src();
29777
29787
  init_sdk3();
29778
29788
  init_utils20();
29779
29789
  var { cleanExportRows: cleanExportRows2 } = (init_utils20(), __toCommonJS(utils_exports9));
29790
+ async function getRow(tableId, rowId, opts) {
29791
+ const response2 = await handleRequest("READ" /* READ */, tableId, {
29792
+ id: breakRowIdField(rowId),
29793
+ includeSqlRelationships: (opts == null ? void 0 : opts.relationships) ? 1 /* INCLUDE */ : 0 /* EXCLUDE */
29794
+ });
29795
+ return response2 ? response2[0] : response2;
29796
+ }
29780
29797
  async function handleRequest(operation, tableId, opts) {
29781
29798
  if (opts && opts.filters) {
29782
29799
  for (let filterField of NoEmptyFilterStrings2) {
@@ -29806,11 +29823,15 @@ async function patch2(ctx) {
29806
29823
  if (!validateResult.valid) {
29807
29824
  throw { validation: validateResult.errors };
29808
29825
  }
29809
- return handleRequest("UPDATE" /* UPDATE */, tableId, {
29826
+ const response2 = await handleRequest("UPDATE" /* UPDATE */, tableId, {
29810
29827
  id: breakRowIdField(id),
29811
- row: inputs,
29812
- includeSqlRelationships: 1 /* INCLUDE */
29828
+ row: inputs
29813
29829
  });
29830
+ const row = await getRow(tableId, id, { relationships: true });
29831
+ return {
29832
+ ...response2,
29833
+ row
29834
+ };
29814
29835
  }
29815
29836
  async function save9(ctx) {
29816
29837
  const inputs = ctx.request.body;
@@ -29822,10 +29843,20 @@ async function save9(ctx) {
29822
29843
  if (!validateResult.valid) {
29823
29844
  throw { validation: validateResult.errors };
29824
29845
  }
29825
- return handleRequest("CREATE" /* CREATE */, tableId, {
29826
- row: inputs,
29827
- includeSqlRelationships: 0 /* EXCLUDE */
29846
+ const response2 = await handleRequest("CREATE" /* CREATE */, tableId, {
29847
+ row: inputs
29828
29848
  });
29849
+ const responseRow = response2;
29850
+ const rowId = responseRow.row._id;
29851
+ if (rowId) {
29852
+ const row = await getRow(tableId, rowId, { relationships: true });
29853
+ return {
29854
+ ...response2,
29855
+ row
29856
+ };
29857
+ } else {
29858
+ return response2;
29859
+ }
29829
29860
  }
29830
29861
  async function fetchView2(ctx) {
29831
29862
  const split = ctx.params.viewName.split("all_");
@@ -29841,11 +29872,7 @@ async function fetch19(ctx) {
29841
29872
  async function find6(ctx) {
29842
29873
  const id = ctx.params.rowId;
29843
29874
  const tableId = ctx.params.tableId;
29844
- const response2 = await handleRequest("READ" /* READ */, tableId, {
29845
- id: breakRowIdField(id),
29846
- includeSqlRelationships: 0 /* EXCLUDE */
29847
- });
29848
- return response2 ? response2[0] : response2;
29875
+ return getRow(tableId, id);
29849
29876
  }
29850
29877
  async function destroy8(ctx) {
29851
29878
  const tableId = ctx.params.tableId;
@@ -30058,7 +30085,7 @@ var save10 = async (ctx) => {
30058
30085
  if (body2 && body2._id) {
30059
30086
  return patch3(ctx);
30060
30087
  }
30061
- const { row, table } = await quotas_exports4.addRow(
30088
+ const { row, table, squashed } = await quotas_exports4.addRow(
30062
30089
  () => quotas_exports4.addQuery(() => pickApi(tableId).save(ctx), {
30063
30090
  datasourceId: tableId
30064
30091
  })
@@ -30066,8 +30093,8 @@ var save10 = async (ctx) => {
30066
30093
  ctx.status = 200;
30067
30094
  ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:save`, appId, row, table);
30068
30095
  ctx.message = `${table.name} saved successfully`;
30069
- ctx.body = row;
30070
- (_a = gridSocket) == null ? void 0 : _a.emitRowUpdate(ctx, row);
30096
+ ctx.body = row || squashed;
30097
+ (_a = gridSocket) == null ? void 0 : _a.emitRowUpdate(ctx, row || squashed);
30071
30098
  };
30072
30099
  async function destroy9(ctx) {
30073
30100
  var _a, _b;