@lotics/app-sdk 0.127.4 → 0.127.5
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/dist/index.js +27 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -963,6 +963,20 @@ function getFormulaValue(value) {
|
|
|
963
963
|
if (isFormulaError(value)) return null;
|
|
964
964
|
return value;
|
|
965
965
|
}
|
|
966
|
+
var NO_LINKED_ROWS = /* @__PURE__ */ new Map();
|
|
967
|
+
function prepareLinkedRows(records) {
|
|
968
|
+
return new Map(
|
|
969
|
+
[...records].map(([tableId, rows]) => {
|
|
970
|
+
const positions = /* @__PURE__ */ new Map();
|
|
971
|
+
for (let at2 = 0; at2 < rows.length; at2++) {
|
|
972
|
+
const held2 = positions.get(rows[at2].id);
|
|
973
|
+
if (held2 === void 0) positions.set(rows[at2].id, [at2]);
|
|
974
|
+
else held2.push(at2);
|
|
975
|
+
}
|
|
976
|
+
return [tableId, { rows, positions }];
|
|
977
|
+
})
|
|
978
|
+
);
|
|
979
|
+
}
|
|
966
980
|
|
|
967
981
|
// ../shared/src/lookup_display.ts
|
|
968
982
|
function flattenLookupValues(values2) {
|
|
@@ -13306,14 +13320,14 @@ function prepareFormulaContext(fields) {
|
|
|
13306
13320
|
names: optionNamesOf(fields)
|
|
13307
13321
|
};
|
|
13308
13322
|
}
|
|
13309
|
-
function computeFormulaFieldsWithContext(row2, fields, context, linkedTableRecords =
|
|
13323
|
+
function computeFormulaFieldsWithContext(row2, fields, context, linkedTableRecords = NO_LINKED_ROWS, linkedTableFields = /* @__PURE__ */ new Map(), timezone, loadedLinkKeys, linkExpandedTableIds, fileFacts, memberNames) {
|
|
13310
13324
|
const result = { ...row2 };
|
|
13311
13325
|
const mayRecompute = (linkKey) => loadedLinkKeys === void 0 || loadedLinkKeys.has(linkKey) || isEmptyFieldValue(row2[linkKey]);
|
|
13312
13326
|
const computes = (key) => context.computedAggregates === void 0 || context.computedAggregates.has(key);
|
|
13313
13327
|
for (const { field, sourceField } of context.rollupFields) {
|
|
13314
13328
|
if (!computes(field.key) || !mayRecompute(sourceField.key)) continue;
|
|
13315
13329
|
if (linkedTableRecords.has(sourceField.table_id) && linkedTableFields.has(sourceField.table_id)) {
|
|
13316
|
-
const linkedRecords = linkedTableRecords.get(sourceField.table_id)
|
|
13330
|
+
const linkedRecords = linkedTableRecords.get(sourceField.table_id);
|
|
13317
13331
|
const linkedTableFieldsArray = linkedTableFields.get(sourceField.table_id) ?? [];
|
|
13318
13332
|
const linkedFieldType = linkedTableFieldsArray.find(
|
|
13319
13333
|
(f) => f.key === field.aggregate_option?.field_key
|
|
@@ -13509,7 +13523,7 @@ function computeFormulaFields(row2, fields, linkedTableRecords = /* @__PURE__ */
|
|
|
13509
13523
|
row2,
|
|
13510
13524
|
fields,
|
|
13511
13525
|
context,
|
|
13512
|
-
linkedTableRecords,
|
|
13526
|
+
prepareLinkedRows(linkedTableRecords),
|
|
13513
13527
|
linkedTableFields,
|
|
13514
13528
|
timezone
|
|
13515
13529
|
);
|
|
@@ -13672,39 +13686,24 @@ function planFilterTraversal(filter2, aggregatedTableId, aggregatedFields, linke
|
|
|
13672
13686
|
resolveLinkedRecords: (parent, linkFieldKey, parentFields) => {
|
|
13673
13687
|
const hop = parentFields[linkFieldKey];
|
|
13674
13688
|
if (!hop || hop.type !== "select_record_link") return null;
|
|
13675
|
-
const
|
|
13689
|
+
const table = linkedTableRecords.get(hop.table_id);
|
|
13676
13690
|
const hopFields = linkedTableFields.get(hop.table_id);
|
|
13677
|
-
if (!
|
|
13691
|
+
if (!table || !hopFields) return null;
|
|
13678
13692
|
const ids = new Set(
|
|
13679
13693
|
extractRecordLinkIds(parent.data[linkFieldKey])
|
|
13680
13694
|
);
|
|
13681
13695
|
if (ids.size === 0) return null;
|
|
13682
13696
|
return {
|
|
13683
|
-
records: linkedRowsNamed(
|
|
13697
|
+
records: linkedRowsNamed(table, [...ids]),
|
|
13684
13698
|
fields: fieldMapOf(hop.table_id, hopFields)
|
|
13685
13699
|
};
|
|
13686
13700
|
}
|
|
13687
13701
|
}
|
|
13688
13702
|
};
|
|
13689
13703
|
}
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
const held2 = frozen ? positionsOfFrozenRows.get(rows) : void 0;
|
|
13694
|
-
if (held2 !== void 0) return held2;
|
|
13695
|
-
const positions = /* @__PURE__ */ new Map();
|
|
13696
|
-
for (let at2 = 0; at2 < rows.length; at2++) {
|
|
13697
|
-
const of = positions.get(rows[at2].id);
|
|
13698
|
-
if (of === void 0) positions.set(rows[at2].id, [at2]);
|
|
13699
|
-
else of.push(at2);
|
|
13700
|
-
}
|
|
13701
|
-
if (frozen) positionsOfFrozenRows.set(rows, positions);
|
|
13702
|
-
return positions;
|
|
13703
|
-
}
|
|
13704
|
-
function linkedRowsNamed(rows, ids) {
|
|
13705
|
-
const positions = linkedRowPositions(rows);
|
|
13706
|
-
const found = [...new Set(ids)].flatMap((id) => positions.get(id) ?? []);
|
|
13707
|
-
return found.sort((a, b) => a - b).map((at2) => rows[at2]);
|
|
13704
|
+
function linkedRowsNamed(table, ids) {
|
|
13705
|
+
const found = [...new Set(ids)].flatMap((id) => table.positions.get(id) ?? []);
|
|
13706
|
+
return found.sort((a, b) => a - b).map((at2) => table.rows[at2]);
|
|
13708
13707
|
}
|
|
13709
13708
|
function rollupOverNothing(operation) {
|
|
13710
13709
|
return operation !== void 0 && accumulates(operation) ? 0 : null;
|
|
@@ -13722,14 +13721,13 @@ function calculateRollupValue(value, fieldType, allLinkedTableRecords, aggregate
|
|
|
13722
13721
|
if (operation === "count") return relevantRecords.length;
|
|
13723
13722
|
return aggregateByField(relevantRecords, fieldType, aggregateOption, subject).result;
|
|
13724
13723
|
}
|
|
13725
|
-
function calculateLookupValue(value,
|
|
13726
|
-
if (!
|
|
13724
|
+
function calculateLookupValue(value, linked, lookupFieldKey, linkedField, orderBy, linkedFields, memberNames) {
|
|
13725
|
+
if (!linked.rows.length || !lookupFieldKey) {
|
|
13727
13726
|
return null;
|
|
13728
13727
|
}
|
|
13729
|
-
const positions = linkedRowPositions(linkedRecords);
|
|
13730
13728
|
const relevantRecords = extractRecordLinkIds(value).flatMap((id) => {
|
|
13731
|
-
const at2 = positions.get(id)?.at(-1);
|
|
13732
|
-
return at2 === void 0 ? [] : [
|
|
13729
|
+
const at2 = linked.positions.get(id)?.at(-1);
|
|
13730
|
+
return at2 === void 0 ? [] : [linked.rows[at2]];
|
|
13733
13731
|
});
|
|
13734
13732
|
if (relevantRecords.length === 0) {
|
|
13735
13733
|
return null;
|
package/package.json
CHANGED