@ai-matrx/records 0.99.31 → 0.99.33
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/CHANGELOG.md +21 -0
- package/dist/{client-Dthx26hr.d.ts → client-CSfkP7Xf.d.ts} +11 -80
- package/dist/{client-B7KEs9hi.d.cts → client-jKf1Z-kp.d.cts} +11 -80
- package/dist/core/index.cjs +149 -105
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +18 -359
- package/dist/core/index.d.ts +18 -359
- package/dist/core/index.js +149 -105
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +280 -236
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +12 -11
- package/dist/data/index.d.ts +12 -11
- package/dist/data/index.js +280 -236
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-CvBu5dTJ.d.ts → declareTable-0emxEewn.d.ts} +3 -3
- package/dist/{declareTable-enQs2N0E.d.cts → declareTable-800bwUn3.d.cts} +3 -3
- package/dist/door-call/index.cjs +1287 -0
- package/dist/door-call/index.cjs.map +1 -0
- package/dist/door-call/index.d.cts +20 -0
- package/dist/door-call/index.d.ts +20 -0
- package/dist/door-call/index.js +1264 -0
- package/dist/door-call/index.js.map +1 -0
- package/dist/{doors-KbjyhBW-.d.cts → doors-BgjRUdxw.d.cts} +14 -2
- package/dist/{doors-C2-sFvAk.d.ts → doors-D7_jEKtg.d.ts} +14 -2
- package/dist/entity/index.d.cts +7 -7
- package/dist/entity/index.d.ts +7 -7
- package/dist/{field-ppX29ddi.d.cts → field-B8loYt-A.d.cts} +1 -1
- package/dist/{field-BHlhq24W.d.ts → field-DaE90BZ7.d.ts} +1 -1
- package/dist/forms/index.d.cts +3 -3
- package/dist/forms/index.d.ts +3 -3
- package/dist/index.d.cts +14 -13
- package/dist/index.d.ts +14 -13
- package/dist/memory/index.d.cts +7 -7
- package/dist/memory/index.d.ts +7 -7
- package/dist/{objectOrganization-Cu73SBxH.d.cts → objectOrganization-B5YFGVUB.d.cts} +2 -2
- package/dist/{objectOrganization-DtR3lWG2.d.ts → objectOrganization-DozoVIxS.d.ts} +2 -2
- package/dist/pickListDoors-C-_eAEGL.d.cts +135 -0
- package/dist/pickListDoors-DgWVnNRI.d.ts +135 -0
- package/dist/{port-Bk7TG0aE.d.ts → port-D6wepPvr.d.ts} +3 -3
- package/dist/{port-rqQEGhew.d.cts → port-O-UdH1HS.d.cts} +3 -3
- package/dist/{portal-DmxuUr2f.d.ts → portal-CAssJHRZ.d.ts} +1 -1
- package/dist/{portal-ffH13fsE.d.cts → portal-L_mN8l9P.d.cts} +1 -1
- package/dist/{ports-BCNNghmf.d.ts → ports-CmmvR8OI.d.ts} +2 -2
- package/dist/{ports-iATV-A2v.d.cts → ports-alv3bgKY.d.cts} +2 -2
- package/dist/questions/index.d.cts +10 -9
- package/dist/questions/index.d.ts +10 -9
- package/dist/react/index.cjs +363 -319
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +37 -22
- package/dist/react/index.d.ts +37 -22
- package/dist/react/index.js +363 -319
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.d.cts +3 -3
- package/dist/realtime/index.d.ts +3 -3
- package/dist/{record-C8q21jjB.d.cts → record-CTgSgWe3.d.cts} +1 -1
- package/dist/{record-C8q21jjB.d.ts → record-CTgSgWe3.d.ts} +1 -1
- package/dist/{relation-Bwp8iuei.d.cts → relation-BjjjXyqn.d.cts} +2 -2
- package/dist/{relation-Bsjwkn6N.d.ts → relation-T4biacnz.d.ts} +2 -2
- package/dist/results/index.cjs +245 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.d.cts +24 -0
- package/dist/results/index.d.ts +24 -0
- package/dist/results/index.js +222 -0
- package/dist/results/index.js.map +1 -0
- package/dist/{rule-BQwUtKk5.d.cts → rule-49jO7lN-.d.cts} +1 -1
- package/dist/{rule-cGqclk_0.d.ts → rule-DzNj0QvN.d.ts} +1 -1
- package/dist/scopes/index.cjs +7 -0
- package/dist/scopes/index.cjs.map +1 -1
- package/dist/scopes/index.d.cts +3 -3
- package/dist/scopes/index.d.ts +3 -3
- package/dist/scopes/index.js +7 -0
- package/dist/scopes/index.js.map +1 -1
- package/dist/search/index.d.cts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/setup/index.cjs +289 -245
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +13 -12
- package/dist/setup/index.d.ts +13 -12
- package/dist/setup/index.js +289 -245
- package/dist/setup/index.js.map +1 -1
- package/dist/{subscription-eNzL9scc.d.ts → subscription-Bp1RSb6p.d.ts} +2 -2
- package/dist/{subscription-Ba8RKtPA.d.cts → subscription-CuaGi3lC.d.cts} +2 -2
- package/dist/table-logic-BPquabNN.d.ts +328 -0
- package/dist/table-logic-CTh6lwaq.d.cts +328 -0
- package/dist/templates/index.d.cts +10 -10
- package/dist/templates/index.d.ts +10 -10
- package/dist/typed-table/index.cjs +280 -236
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +11 -10
- package/dist/typed-table/index.d.ts +11 -10
- package/dist/typed-table/index.js +280 -236
- package/dist/typed-table/index.js.map +1 -1
- package/dist/{types-C4XCuv8O.d.cts → types-B54BeQzf.d.cts} +2 -2
- package/dist/{types-BlzdL4Vd.d.cts → types-BWfL38XJ.d.cts} +2 -2
- package/dist/{types-BBR2NGqj.d.ts → types-BZcYXFK3.d.ts} +2 -2
- package/dist/{types-EKwXJfxY.d.cts → types-Bztv0-pH.d.cts} +2 -2
- package/dist/{types-CmkHpvll.d.ts → types-CjGuR5ks.d.ts} +2 -2
- package/dist/{types-CrkzINrb.d.ts → types-bN7dG2ji.d.ts} +2 -2
- package/dist/use-cases/index.d.cts +5 -5
- package/dist/use-cases/index.d.ts +5 -5
- package/dist/{validate-BKeBAVSi.d.cts → validate-8VBa2xIU.d.cts} +1 -1
- package/dist/{validate-BB6DWgCP.d.ts → validate-xBnply7J.d.ts} +1 -1
- package/dist/views/index.d.cts +10 -9
- package/dist/views/index.d.ts +10 -9
- package/package.json +24 -4
package/dist/react/index.js
CHANGED
|
@@ -73,184 +73,6 @@ function isWritingDoor(door) {
|
|
|
73
73
|
return /(_declare|_set(_|$)|_update|_write|_delete|_restore|_archive|_upsert|_reparent|_change|_duplicate|_move|_decide|_run$|_submit|_publish|_import_|_start$|_complete|_sign$|_add$|_retire|_propose|_promote|_land$|_pin$|_mute|_snooze|_unsnooze|_clear|_unclear|_revoke|_issue|_bind|_unbind|_apply|_backfill|_sync$|_decorate|_designate|_ensure|^migrate_|^set_table_|^home_add|^capture_|^claim_|^record_stage|^anon_|^io_import_|^io_comment_resolve|^enrich_(declare|land|pin)|^field_(declare|duplicate|propose|restore|retire|update)|^table_(declare|ensure|from_example|move|sync)|^value_restore|^relation_own)/.test(door);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// src/core/recordChanges.ts
|
|
77
|
-
import { globalSlot } from "@ai-matrx/kit/global-slot";
|
|
78
|
-
var listeners = globalSlot("ai-matrx.records.record-change-listeners", () => /* @__PURE__ */ new Set());
|
|
79
|
-
function announceRecordChanged(recordId) {
|
|
80
|
-
for (const listener of [...listeners]) {
|
|
81
|
-
try {
|
|
82
|
-
listener(recordId);
|
|
83
|
-
} catch (thrown) {
|
|
84
|
-
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
var removed = globalSlot("ai-matrx.records.removed-records", () => /* @__PURE__ */ new Set());
|
|
89
|
-
function markRecordRemoved(recordId) {
|
|
90
|
-
removed.add(recordId);
|
|
91
|
-
}
|
|
92
|
-
function markRecordRestored(recordId) {
|
|
93
|
-
removed.delete(recordId);
|
|
94
|
-
}
|
|
95
|
-
function isRecordRemoved(recordId) {
|
|
96
|
-
return removed.has(recordId);
|
|
97
|
-
}
|
|
98
|
-
function onRecordChanged(listener) {
|
|
99
|
-
listeners.add(listener);
|
|
100
|
-
return () => listeners.delete(listener);
|
|
101
|
-
}
|
|
102
|
-
var tableListeners = globalSlot("ai-matrx.records.table-structure-listeners", () => /* @__PURE__ */ new Set());
|
|
103
|
-
function announceTableStructureChanged(tableId) {
|
|
104
|
-
for (const listener of [...tableListeners]) {
|
|
105
|
-
try {
|
|
106
|
-
listener(tableId);
|
|
107
|
-
} catch (thrown) {
|
|
108
|
-
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// src/archive.ts
|
|
114
|
-
var ARCHIVE_LANES = ["mine", "org"];
|
|
115
|
-
var DEFAULT_ARCHIVE_LANE = "org";
|
|
116
|
-
var ARCHIVE_LANE_LABEL = {
|
|
117
|
-
mine: "Archived by me",
|
|
118
|
-
org: "Archived by anyone"
|
|
119
|
-
};
|
|
120
|
-
var ARCHIVE_LANE_MEANS = {
|
|
121
|
-
mine: "The records you archived yourself.",
|
|
122
|
-
org: "Everything anybody in this organization archived, including you."
|
|
123
|
-
};
|
|
124
|
-
function isArchiveLane(word) {
|
|
125
|
-
return typeof word === "string" && ARCHIVE_LANES.includes(word);
|
|
126
|
-
}
|
|
127
|
-
function archivedWhen(at, locale = "en-GB") {
|
|
128
|
-
const when = new Date(at);
|
|
129
|
-
if (Number.isNaN(when.getTime())) return "a moment nobody recorded";
|
|
130
|
-
return new Intl.DateTimeFormat(locale, {
|
|
131
|
-
day: "numeric",
|
|
132
|
-
month: "long",
|
|
133
|
-
year: "numeric",
|
|
134
|
-
hour: "2-digit",
|
|
135
|
-
minute: "2-digit"
|
|
136
|
-
}).format(when);
|
|
137
|
-
}
|
|
138
|
-
function archivedByLine(row, locale = "en-GB") {
|
|
139
|
-
const when = archivedWhen(row.archivedAt, locale);
|
|
140
|
-
const who = (row.archivedByName ?? "").trim();
|
|
141
|
-
if (who === "") {
|
|
142
|
-
return `Archived on ${when}. The store does not know who archived it \u2014 whoever did is no longer in this organization, or it happened before this table kept that.`;
|
|
143
|
-
}
|
|
144
|
-
return `Archived by ${who} on ${when}.`;
|
|
145
|
-
}
|
|
146
|
-
function emptyArchiveLine(lane) {
|
|
147
|
-
return lane === "mine" ? "You have not archived anything in this table. Switch to \u201CArchived by anyone\u201D to see what the rest of the organization has." : "Nothing in this table has been archived. Records you remove from the grid arrive here, and nothing is ever destroyed.";
|
|
148
|
-
}
|
|
149
|
-
function sameDocument(a, b) {
|
|
150
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// src/aggregate.ts
|
|
154
|
-
function isRuleFilter(filter) {
|
|
155
|
-
if (!filter || typeof filter !== "object" || Array.isArray(filter)) return false;
|
|
156
|
-
const node = filter;
|
|
157
|
-
return typeof node.op === "string" && Array.isArray(node.args);
|
|
158
|
-
}
|
|
159
|
-
function measureKey(measure) {
|
|
160
|
-
return measure.op === "count" ? "count" : `${measure.op}_${measure.key ?? ""}`;
|
|
161
|
-
}
|
|
162
|
-
function stableFilterKey(filter) {
|
|
163
|
-
if (!filter) return "{}";
|
|
164
|
-
if (isRuleFilter(filter)) return JSON.stringify(filter);
|
|
165
|
-
const keys = Object.keys(filter).sort();
|
|
166
|
-
if (keys.length === 0) return "{}";
|
|
167
|
-
const parts = keys.map((key) => {
|
|
168
|
-
const value = filter[key];
|
|
169
|
-
if (value !== null && typeof value === "object") {
|
|
170
|
-
const window2 = value;
|
|
171
|
-
return `${JSON.stringify(key)}:{"from":${JSON.stringify(window2.from ?? null)},"to":${JSON.stringify(window2.to ?? null)}}`;
|
|
172
|
-
}
|
|
173
|
-
return `${JSON.stringify(key)}:${JSON.stringify(value ?? null)}`;
|
|
174
|
-
});
|
|
175
|
-
return `{${parts.join(",")}}`;
|
|
176
|
-
}
|
|
177
|
-
function liftWithheld(rows) {
|
|
178
|
-
let shared;
|
|
179
|
-
for (const row of rows) {
|
|
180
|
-
const m = (row.measures ?? {})["_withheld"];
|
|
181
|
-
if (m !== void 0 && m !== null && typeof m === "object") {
|
|
182
|
-
shared = m;
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return rows.map((row) => {
|
|
187
|
-
const measures = row.measures ?? {};
|
|
188
|
-
const own = measures["_withheld"];
|
|
189
|
-
const marker = own !== void 0 && own !== null && typeof own === "object" ? own : shared;
|
|
190
|
-
const rowCount = row.row_count ?? 0;
|
|
191
|
-
if (marker === void 0 || marker === null || typeof marker !== "object") {
|
|
192
|
-
return rowCount === row.row_count ? row : { ...row, row_count: rowCount };
|
|
193
|
-
}
|
|
194
|
-
const { _withheld: _drop, ...rest } = measures;
|
|
195
|
-
const withheld = {};
|
|
196
|
-
for (const [name, raw] of Object.entries(marker)) {
|
|
197
|
-
const m = raw ?? {};
|
|
198
|
-
withheld[name] = {
|
|
199
|
-
reason: m.withheld?.reason ?? null,
|
|
200
|
-
needs: m.withheld?.needs ?? null,
|
|
201
|
-
or: m.withheld?.or ?? null,
|
|
202
|
-
...m.says ? { says: m.says } : {},
|
|
203
|
-
...m.label ? { label: m.label } : {},
|
|
204
|
-
...m.field_key ? { field_key: m.field_key } : {}
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
return { ...row, measures: rest, withheld, row_count: rowCount };
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// src/record.ts
|
|
212
|
-
function isLockedStub(row) {
|
|
213
|
-
if (!row) return false;
|
|
214
|
-
if (row.level !== null && row.level !== void 0) return false;
|
|
215
|
-
const doc = row.document;
|
|
216
|
-
if (!doc || typeof doc !== "object") return false;
|
|
217
|
-
const keys = Object.keys(doc);
|
|
218
|
-
if (keys.length === 0 || keys.length > 3) return false;
|
|
219
|
-
const d = doc;
|
|
220
|
-
return d["exists"] === true && keys.every((k) => k === "id" || k === "exists" || k === "submitted_at");
|
|
221
|
-
}
|
|
222
|
-
function splitLockedRows(rows) {
|
|
223
|
-
const open = [];
|
|
224
|
-
let locked = 0;
|
|
225
|
-
for (const row of rows) {
|
|
226
|
-
if (isLockedStub(row)) locked += 1;
|
|
227
|
-
else open.push(row);
|
|
228
|
-
}
|
|
229
|
-
return { rows: open, locked };
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// src/subscription.ts
|
|
233
|
-
function hasQuietHours(quiet2) {
|
|
234
|
-
return Boolean(quiet2?.start && quiet2?.end);
|
|
235
|
-
}
|
|
236
|
-
function callersTimeZone() {
|
|
237
|
-
try {
|
|
238
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
239
|
-
} catch {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function withCallersClock(spec, zone = callersTimeZone()) {
|
|
244
|
-
if (!zone || spec.quiet_hours?.tz) return spec;
|
|
245
|
-
return { ...spec, quiet_hours: { ...spec.quiet_hours ?? {}, tz: zone } };
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// src/rowLabel.ts
|
|
249
|
-
var ROW_LABEL_FORMULA_MAX_LENGTH = 2e3;
|
|
250
|
-
function clearsRowLabel(formula) {
|
|
251
|
-
return formula == null || formula.trim() === "";
|
|
252
|
-
}
|
|
253
|
-
|
|
254
76
|
// src/results.ts
|
|
255
77
|
function isRecordsErr(result) {
|
|
256
78
|
return result.ok === false;
|
|
@@ -396,48 +218,319 @@ function parseDetail(details) {
|
|
|
396
218
|
return details;
|
|
397
219
|
}
|
|
398
220
|
}
|
|
399
|
-
function isNotASqlstate(code) {
|
|
400
|
-
if (!code) return true;
|
|
401
|
-
return /^[0-9]{3}$/.test(code);
|
|
221
|
+
function isNotASqlstate(code) {
|
|
222
|
+
if (!code) return true;
|
|
223
|
+
return /^[0-9]{3}$/.test(code);
|
|
224
|
+
}
|
|
225
|
+
function mapPgError(error, where) {
|
|
226
|
+
const raw = error.code ?? void 0;
|
|
227
|
+
const sqlstate = raw && raw !== "" ? raw : void 0;
|
|
228
|
+
const mapped = {
|
|
229
|
+
code: "internal",
|
|
230
|
+
message: error.message,
|
|
231
|
+
...error.hint ? { hint: error.hint } : {},
|
|
232
|
+
...sqlstate ? { sqlstate } : {}
|
|
233
|
+
};
|
|
234
|
+
if (isNotASqlstate(sqlstate)) {
|
|
235
|
+
mapped.code = "unreachable";
|
|
236
|
+
} else {
|
|
237
|
+
mapped.code = BY_SQLSTATE[sqlstate] ?? "internal";
|
|
238
|
+
}
|
|
239
|
+
const detail = parseDetail(error.details);
|
|
240
|
+
if (detail !== void 0) mapped.detail = detail;
|
|
241
|
+
if (mapped.code === "internal") {
|
|
242
|
+
mapped.unmapped = true;
|
|
243
|
+
mapped.diagnostic = `@ai-matrx/records did not recognise SQLSTATE ${sqlstate ?? "(none)"} from ${where}; the store's own message is the thing to act on.`;
|
|
244
|
+
} else if (mapped.code === "unreachable") {
|
|
245
|
+
mapped.unmapped = true;
|
|
246
|
+
mapped.diagnostic = `@ai-matrx/records never reached the store from ${where}: ${raw ? `the transport answered ${raw}` : "no response"} \u2014 ${error.message}`;
|
|
247
|
+
mapped.message = "We could not reach your data.";
|
|
248
|
+
delete mapped.hint;
|
|
249
|
+
}
|
|
250
|
+
return mapped;
|
|
251
|
+
}
|
|
252
|
+
function staleWriteDetail(error) {
|
|
253
|
+
if (error.code !== "stale_write") return null;
|
|
254
|
+
const detail = error.detail;
|
|
255
|
+
if (!detail || typeof detail.expected_version !== "number" || typeof detail.current_version !== "number") {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
expected_version: detail.expected_version,
|
|
260
|
+
current_version: detail.current_version,
|
|
261
|
+
contested_fields: detail.contested_fields ?? {}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/core/doorCall.ts
|
|
266
|
+
var DEFAULT_DOOR_SCHEMA = "custom";
|
|
267
|
+
function canonicalArgs(value) {
|
|
268
|
+
return JSON.stringify(
|
|
269
|
+
value,
|
|
270
|
+
(_key, held) => held && typeof held === "object" && !Array.isArray(held) ? Object.fromEntries(Object.keys(held).sort().map((k) => [k, held[k]])) : held
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
|
|
274
|
+
"refused_by_rule",
|
|
275
|
+
"stale_write",
|
|
276
|
+
"invalid_argument",
|
|
277
|
+
"already_exists",
|
|
278
|
+
"missing_reference"
|
|
279
|
+
]);
|
|
280
|
+
function isAPersonsRefusal(code) {
|
|
281
|
+
return A_PERSONS_REFUSAL.has(code);
|
|
282
|
+
}
|
|
283
|
+
function recordsErrorSink(onError) {
|
|
284
|
+
return onError ?? ((e) => {
|
|
285
|
+
const line = `[@ai-matrx/records] ${e.where}: ${e.code} \u2014 ${e.message}${e.hint ? ` (${e.hint})` : ""}`;
|
|
286
|
+
if (isAPersonsRefusal(e.code)) console.info(line);
|
|
287
|
+
else console.error(line);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function doorAbsentRefusal(name, owedBy) {
|
|
291
|
+
return {
|
|
292
|
+
code: "door_absent",
|
|
293
|
+
message: `The record store has no door \`custom.${name}\` yet, so this call was not made. Nothing was read and nothing was written.`,
|
|
294
|
+
hint: owedBy ? `That door is ${owedBy}. Until it lands, this call refuses rather than guessing: an empty answer here would read like "there is nothing", which is a different sentence.` : `No lane in the build book claims this door. Either the name is wrong, or the door was removed from the store and this package has not been regenerated \u2014 run \`pnpm records:generate\`.`
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
function primedDoorAnswer(door, args) {
|
|
298
|
+
const look = LOOK_WRITES[door];
|
|
299
|
+
if (look) {
|
|
300
|
+
dropPrimedDoorAnswers(look);
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
if (isWritingDoor(door)) {
|
|
304
|
+
dropPrimedDoorAnswers();
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
|
|
308
|
+
}
|
|
309
|
+
function createDoorCall(options) {
|
|
310
|
+
const { dataSource, doorReady: doorReady2, held, wrote } = options;
|
|
311
|
+
const schema = options.schema ?? DEFAULT_DOOR_SCHEMA;
|
|
312
|
+
const scream = recordsErrorSink(options.onError);
|
|
313
|
+
const absent = options.absent ?? ((door) => doorAbsentRefusal(door));
|
|
314
|
+
const readsInFlight = /* @__PURE__ */ new Map();
|
|
315
|
+
const say = (refusal3, where) => scream({ code: refusal3.code, message: refusal3.message, ...refusal3.hint ? { hint: refusal3.hint } : {}, where });
|
|
316
|
+
return async function callDoor(door, args, where, opts) {
|
|
317
|
+
const primed = primedDoorAnswer(door, args);
|
|
318
|
+
if (primed) return ok(primed.data);
|
|
319
|
+
if (held) {
|
|
320
|
+
const bundled = await held(door, args);
|
|
321
|
+
if (bundled) return ok(bundled.data);
|
|
322
|
+
}
|
|
323
|
+
if (doorReady2 && !doorReady2(door)) {
|
|
324
|
+
const refusal3 = absent(door);
|
|
325
|
+
say(refusal3, where);
|
|
326
|
+
return err(refusal3);
|
|
327
|
+
}
|
|
328
|
+
const flightKey = isWritingDoor(door) ? null : `${door}|${canonicalArgs(args)}`;
|
|
329
|
+
const flying = flightKey ? readsInFlight.get(flightKey) : void 0;
|
|
330
|
+
const response = await (flying ?? (() => {
|
|
331
|
+
const call = Promise.resolve(dataSource.rpc(`${door}`, args, { schema }));
|
|
332
|
+
if (flightKey) {
|
|
333
|
+
readsInFlight.set(flightKey, call);
|
|
334
|
+
const forget = () => {
|
|
335
|
+
if (readsInFlight.get(flightKey) === call) readsInFlight.delete(flightKey);
|
|
336
|
+
};
|
|
337
|
+
call.then(forget, forget);
|
|
338
|
+
}
|
|
339
|
+
return call;
|
|
340
|
+
})());
|
|
341
|
+
if (response.error) {
|
|
342
|
+
const code = response.error.code;
|
|
343
|
+
const refusal3 = !doorReady2 && (code === "PGRST202" || code === "42883") ? absent(door) : mapPgError(response.error, where);
|
|
344
|
+
if (opts?.quiet) console.info(`[@ai-matrx/records] ${where}: ${refusal3.code} - ${refusal3.message}`);
|
|
345
|
+
else say(refusal3, where);
|
|
346
|
+
return err(refusal3);
|
|
347
|
+
}
|
|
348
|
+
if (isWritingDoor(door) || LOOK_WRITES[door]) {
|
|
349
|
+
const tableId = args["p_table_id"];
|
|
350
|
+
wrote?.(door, args);
|
|
351
|
+
forgetPrimedTablePageBundlesOf(typeof tableId === "string" ? tableId : null);
|
|
352
|
+
dropPrimedDoorAnswers(LOOK_WRITES[door]);
|
|
353
|
+
}
|
|
354
|
+
return ok(response.data);
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// src/core/recordChanges.ts
|
|
359
|
+
import { globalSlot } from "@ai-matrx/kit/global-slot";
|
|
360
|
+
var listeners = globalSlot("ai-matrx.records.record-change-listeners", () => /* @__PURE__ */ new Set());
|
|
361
|
+
function announceRecordChanged(recordId) {
|
|
362
|
+
for (const listener of [...listeners]) {
|
|
363
|
+
try {
|
|
364
|
+
listener(recordId);
|
|
365
|
+
} catch (thrown) {
|
|
366
|
+
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
var removed = globalSlot("ai-matrx.records.removed-records", () => /* @__PURE__ */ new Set());
|
|
371
|
+
function markRecordRemoved(recordId) {
|
|
372
|
+
removed.add(recordId);
|
|
373
|
+
}
|
|
374
|
+
function markRecordRestored(recordId) {
|
|
375
|
+
removed.delete(recordId);
|
|
376
|
+
}
|
|
377
|
+
function isRecordRemoved(recordId) {
|
|
378
|
+
return removed.has(recordId);
|
|
379
|
+
}
|
|
380
|
+
function onRecordChanged(listener) {
|
|
381
|
+
listeners.add(listener);
|
|
382
|
+
return () => listeners.delete(listener);
|
|
383
|
+
}
|
|
384
|
+
var tableListeners = globalSlot("ai-matrx.records.table-structure-listeners", () => /* @__PURE__ */ new Set());
|
|
385
|
+
function announceTableStructureChanged(tableId) {
|
|
386
|
+
for (const listener of [...tableListeners]) {
|
|
387
|
+
try {
|
|
388
|
+
listener(tableId);
|
|
389
|
+
} catch (thrown) {
|
|
390
|
+
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// src/archive.ts
|
|
396
|
+
var ARCHIVE_LANES = ["mine", "org"];
|
|
397
|
+
var DEFAULT_ARCHIVE_LANE = "org";
|
|
398
|
+
var ARCHIVE_LANE_LABEL = {
|
|
399
|
+
mine: "Archived by me",
|
|
400
|
+
org: "Archived by anyone"
|
|
401
|
+
};
|
|
402
|
+
var ARCHIVE_LANE_MEANS = {
|
|
403
|
+
mine: "The records you archived yourself.",
|
|
404
|
+
org: "Everything anybody in this organization archived, including you."
|
|
405
|
+
};
|
|
406
|
+
function isArchiveLane(word) {
|
|
407
|
+
return typeof word === "string" && ARCHIVE_LANES.includes(word);
|
|
408
|
+
}
|
|
409
|
+
function archivedWhen(at, locale = "en-GB") {
|
|
410
|
+
const when = new Date(at);
|
|
411
|
+
if (Number.isNaN(when.getTime())) return "a moment nobody recorded";
|
|
412
|
+
return new Intl.DateTimeFormat(locale, {
|
|
413
|
+
day: "numeric",
|
|
414
|
+
month: "long",
|
|
415
|
+
year: "numeric",
|
|
416
|
+
hour: "2-digit",
|
|
417
|
+
minute: "2-digit"
|
|
418
|
+
}).format(when);
|
|
419
|
+
}
|
|
420
|
+
function archivedByLine(row, locale = "en-GB") {
|
|
421
|
+
const when = archivedWhen(row.archivedAt, locale);
|
|
422
|
+
const who = (row.archivedByName ?? "").trim();
|
|
423
|
+
if (who === "") {
|
|
424
|
+
return `Archived on ${when}. The store does not know who archived it \u2014 whoever did is no longer in this organization, or it happened before this table kept that.`;
|
|
425
|
+
}
|
|
426
|
+
return `Archived by ${who} on ${when}.`;
|
|
427
|
+
}
|
|
428
|
+
function emptyArchiveLine(lane) {
|
|
429
|
+
return lane === "mine" ? "You have not archived anything in this table. Switch to \u201CArchived by anyone\u201D to see what the rest of the organization has." : "Nothing in this table has been archived. Records you remove from the grid arrive here, and nothing is ever destroyed.";
|
|
402
430
|
}
|
|
403
|
-
function
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
415
|
-
|
|
431
|
+
function sameDocument(a, b) {
|
|
432
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/aggregate.ts
|
|
436
|
+
function isRuleFilter(filter) {
|
|
437
|
+
if (!filter || typeof filter !== "object" || Array.isArray(filter)) return false;
|
|
438
|
+
const node = filter;
|
|
439
|
+
return typeof node.op === "string" && Array.isArray(node.args);
|
|
440
|
+
}
|
|
441
|
+
function measureKey(measure) {
|
|
442
|
+
return measure.op === "count" ? "count" : `${measure.op}_${measure.key ?? ""}`;
|
|
443
|
+
}
|
|
444
|
+
function stableFilterKey(filter) {
|
|
445
|
+
if (!filter) return "{}";
|
|
446
|
+
if (isRuleFilter(filter)) return JSON.stringify(filter);
|
|
447
|
+
const keys = Object.keys(filter).sort();
|
|
448
|
+
if (keys.length === 0) return "{}";
|
|
449
|
+
const parts = keys.map((key) => {
|
|
450
|
+
const value = filter[key];
|
|
451
|
+
if (value !== null && typeof value === "object") {
|
|
452
|
+
const window2 = value;
|
|
453
|
+
return `${JSON.stringify(key)}:{"from":${JSON.stringify(window2.from ?? null)},"to":${JSON.stringify(window2.to ?? null)}}`;
|
|
454
|
+
}
|
|
455
|
+
return `${JSON.stringify(key)}:${JSON.stringify(value ?? null)}`;
|
|
456
|
+
});
|
|
457
|
+
return `{${parts.join(",")}}`;
|
|
458
|
+
}
|
|
459
|
+
function liftWithheld(rows) {
|
|
460
|
+
let shared;
|
|
461
|
+
for (const row of rows) {
|
|
462
|
+
const m = (row.measures ?? {})["_withheld"];
|
|
463
|
+
if (m !== void 0 && m !== null && typeof m === "object") {
|
|
464
|
+
shared = m;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
416
467
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
468
|
+
return rows.map((row) => {
|
|
469
|
+
const measures = row.measures ?? {};
|
|
470
|
+
const own = measures["_withheld"];
|
|
471
|
+
const marker = own !== void 0 && own !== null && typeof own === "object" ? own : shared;
|
|
472
|
+
const rowCount = row.row_count ?? 0;
|
|
473
|
+
if (marker === void 0 || marker === null || typeof marker !== "object") {
|
|
474
|
+
return rowCount === row.row_count ? row : { ...row, row_count: rowCount };
|
|
475
|
+
}
|
|
476
|
+
const { _withheld: _drop, ...rest } = measures;
|
|
477
|
+
const withheld = {};
|
|
478
|
+
for (const [name, raw] of Object.entries(marker)) {
|
|
479
|
+
const m = raw ?? {};
|
|
480
|
+
withheld[name] = {
|
|
481
|
+
reason: m.withheld?.reason ?? null,
|
|
482
|
+
needs: m.withheld?.needs ?? null,
|
|
483
|
+
or: m.withheld?.or ?? null,
|
|
484
|
+
...m.says ? { says: m.says } : {},
|
|
485
|
+
...m.label ? { label: m.label } : {},
|
|
486
|
+
...m.field_key ? { field_key: m.field_key } : {}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
return { ...row, measures: rest, withheld, row_count: rowCount };
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/record.ts
|
|
494
|
+
function isLockedStub(row) {
|
|
495
|
+
if (!row) return false;
|
|
496
|
+
if (row.level !== null && row.level !== void 0) return false;
|
|
497
|
+
const doc = row.document;
|
|
498
|
+
if (!doc || typeof doc !== "object") return false;
|
|
499
|
+
const keys = Object.keys(doc);
|
|
500
|
+
if (keys.length === 0 || keys.length > 3) return false;
|
|
501
|
+
const d = doc;
|
|
502
|
+
return d["exists"] === true && keys.every((k) => k === "id" || k === "exists" || k === "submitted_at");
|
|
503
|
+
}
|
|
504
|
+
function splitLockedRows(rows) {
|
|
505
|
+
const open = [];
|
|
506
|
+
let locked = 0;
|
|
507
|
+
for (const row of rows) {
|
|
508
|
+
if (isLockedStub(row)) locked += 1;
|
|
509
|
+
else open.push(row);
|
|
427
510
|
}
|
|
428
|
-
return
|
|
511
|
+
return { rows: open, locked };
|
|
429
512
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
513
|
+
|
|
514
|
+
// src/subscription.ts
|
|
515
|
+
function hasQuietHours(quiet2) {
|
|
516
|
+
return Boolean(quiet2?.start && quiet2?.end);
|
|
517
|
+
}
|
|
518
|
+
function callersTimeZone() {
|
|
519
|
+
try {
|
|
520
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone || null;
|
|
521
|
+
} catch {
|
|
434
522
|
return null;
|
|
435
523
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
524
|
+
}
|
|
525
|
+
function withCallersClock(spec, zone = callersTimeZone()) {
|
|
526
|
+
if (!zone || spec.quiet_hours?.tz) return spec;
|
|
527
|
+
return { ...spec, quiet_hours: { ...spec.quiet_hours ?? {}, tz: zone } };
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/rowLabel.ts
|
|
531
|
+
var ROW_LABEL_FORMULA_MAX_LENGTH = 2e3;
|
|
532
|
+
function clearsRowLabel(formula) {
|
|
533
|
+
return formula == null || formula.trim() === "";
|
|
441
534
|
}
|
|
442
535
|
|
|
443
536
|
// src/relation.ts
|
|
@@ -1288,11 +1381,51 @@ function createScopeDoors(call) {
|
|
|
1288
1381
|
source_type: String(envelope.data?.source_type ?? cell.source_type ?? "ai_enriched")
|
|
1289
1382
|
}
|
|
1290
1383
|
};
|
|
1384
|
+
},
|
|
1385
|
+
tableProvision({ organization_id, item_id, scope_id, home_id }) {
|
|
1386
|
+
return call(
|
|
1387
|
+
"scope_table_provision",
|
|
1388
|
+
{ p_organization_id: organization_id, p_item_id: item_id, p_scope_id: scope_id, p_home_id: home_id ?? null },
|
|
1389
|
+
"scopeTableProvision"
|
|
1390
|
+
);
|
|
1291
1391
|
}
|
|
1292
1392
|
};
|
|
1293
1393
|
return doors;
|
|
1294
1394
|
}
|
|
1295
1395
|
|
|
1396
|
+
// src/core/pickListDoors.ts
|
|
1397
|
+
var PICK_LIST_DOORS = {
|
|
1398
|
+
pickListGet: "pick_list_get",
|
|
1399
|
+
pickListForSelection: "pick_list_for_selection",
|
|
1400
|
+
pickListUpdate: "pick_list_update"
|
|
1401
|
+
};
|
|
1402
|
+
function createPickListDoors(callDoor) {
|
|
1403
|
+
return {
|
|
1404
|
+
async pickListGet({ list_id }) {
|
|
1405
|
+
return callDoor(PICK_LIST_DOORS.pickListGet, { p_list_id: list_id }, "pickListGet");
|
|
1406
|
+
},
|
|
1407
|
+
async pickListForSelection({ list_id }) {
|
|
1408
|
+
return callDoor(
|
|
1409
|
+
PICK_LIST_DOORS.pickListForSelection,
|
|
1410
|
+
{ p_list_id: list_id },
|
|
1411
|
+
"pickListForSelection"
|
|
1412
|
+
);
|
|
1413
|
+
},
|
|
1414
|
+
async pickListUpdate({ list_id, list_name, description, items }) {
|
|
1415
|
+
return callDoor(
|
|
1416
|
+
PICK_LIST_DOORS.pickListUpdate,
|
|
1417
|
+
{
|
|
1418
|
+
p_list_id: list_id,
|
|
1419
|
+
p_list_name: list_name ?? null,
|
|
1420
|
+
p_description: description ?? null,
|
|
1421
|
+
p_items: items ? [...items] : null
|
|
1422
|
+
},
|
|
1423
|
+
"pickListUpdate"
|
|
1424
|
+
);
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1296
1429
|
// src/choice.ts
|
|
1297
1430
|
import { isUuidShape as isUuidShape3 } from "@ai-matrx/kit/uuid";
|
|
1298
1431
|
function optionKey(option) {
|
|
@@ -4495,12 +4628,7 @@ function doorReady(config, name) {
|
|
|
4495
4628
|
return DOOR_NAMES.has(name) || Boolean(config?.knownDoors?.includes(name));
|
|
4496
4629
|
}
|
|
4497
4630
|
function doorAbsent(name) {
|
|
4498
|
-
|
|
4499
|
-
return {
|
|
4500
|
-
code: "door_absent",
|
|
4501
|
-
message: `The record store has no door \`custom.${name}\` yet, so this call was not made. Nothing was read and nothing was written.`,
|
|
4502
|
-
hint: owed ? `That door is ${owed}. Until it lands, this call refuses rather than guessing: an empty answer here would read like "there is nothing", which is a different sentence.` : `No lane in the build book claims this door. Either the name is wrong, or the door was removed from the store and this package has not been regenerated \u2014 run \`pnpm records:generate\`.`
|
|
4503
|
-
};
|
|
4631
|
+
return doorAbsentRefusal(name, OWED_BY[name]);
|
|
4504
4632
|
}
|
|
4505
4633
|
var DOORS = {
|
|
4506
4634
|
// THE READ DOOR (DOOR-1). Every read of a record's values goes through these
|
|
@@ -5300,29 +5428,6 @@ function intersectIds(sets) {
|
|
|
5300
5428
|
|
|
5301
5429
|
// src/core/client.ts
|
|
5302
5430
|
var DEFAULT_SCHEMA = "custom";
|
|
5303
|
-
function canonicalArgs(value) {
|
|
5304
|
-
return JSON.stringify(
|
|
5305
|
-
value,
|
|
5306
|
-
(_key, held) => held && typeof held === "object" && !Array.isArray(held) ? Object.fromEntries(Object.keys(held).sort().map((k) => [k, held[k]])) : held
|
|
5307
|
-
);
|
|
5308
|
-
}
|
|
5309
|
-
var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
|
|
5310
|
-
"refused_by_rule",
|
|
5311
|
-
"stale_write",
|
|
5312
|
-
"invalid_argument",
|
|
5313
|
-
"already_exists",
|
|
5314
|
-
"missing_reference"
|
|
5315
|
-
]);
|
|
5316
|
-
function isAPersonsRefusal(code) {
|
|
5317
|
-
return A_PERSONS_REFUSAL.has(code);
|
|
5318
|
-
}
|
|
5319
|
-
function sink(config) {
|
|
5320
|
-
return config.onError ?? ((e) => {
|
|
5321
|
-
const line = `[@ai-matrx/records] ${e.where}: ${e.code} \u2014 ${e.message}${e.hint ? ` (${e.hint})` : ""}`;
|
|
5322
|
-
if (isAPersonsRefusal(e.code)) console.info(line);
|
|
5323
|
-
else console.error(line);
|
|
5324
|
-
});
|
|
5325
|
-
}
|
|
5326
5431
|
var TABLE_LIST_PAGE = 500;
|
|
5327
5432
|
var TABLE_ARCHIVE_PASS = 20;
|
|
5328
5433
|
var TABLE_RESTORE_PASS = 20;
|
|
@@ -5335,7 +5440,7 @@ function createRecordsClient(given) {
|
|
|
5335
5440
|
const org = config.organizationId;
|
|
5336
5441
|
const ledger = config.opLedger ?? defaultOpLedger;
|
|
5337
5442
|
const mintOp = () => ledger.mint();
|
|
5338
|
-
const scream =
|
|
5443
|
+
const scream = recordsErrorSink(config.onError);
|
|
5339
5444
|
const BUNDLE_TTL_MS = 1e4;
|
|
5340
5445
|
const BUNDLE_OPENERS = /* @__PURE__ */ new Set(["applicable_fields", "views", "view_look_read", "table_decorations", "row_actions", "reverse_columns", "record_change_actions", "grid_layout", "io_imports"]);
|
|
5341
5446
|
const bundleParts = /* @__PURE__ */ new Map();
|
|
@@ -5477,56 +5582,20 @@ function createRecordsClient(given) {
|
|
|
5477
5582
|
bundleAsked.delete(tableId);
|
|
5478
5583
|
for (const key of [...bundleParts.keys()]) if (key.includes(tableId)) bundleParts.delete(key);
|
|
5479
5584
|
}
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
}
|
|
5490
|
-
return takePrimedDoorAnswer(`${door}|${canonicalArgs(args)}`);
|
|
5491
|
-
}
|
|
5492
|
-
const readsInFlight = /* @__PURE__ */ new Map();
|
|
5493
|
-
async function callDoor(door, args, where, opts) {
|
|
5494
|
-
const primed = primedFor(door, args);
|
|
5495
|
-
if (primed) return ok(primed.data);
|
|
5496
|
-
const bundled = await fromBundle(door, args);
|
|
5497
|
-
if (bundled) return ok(bundled.data);
|
|
5498
|
-
if (!doorReady(config, door)) {
|
|
5499
|
-
const refusal3 = doorAbsent(door);
|
|
5500
|
-
scream({ code: refusal3.code, message: refusal3.message, ...refusal3.hint ? { hint: refusal3.hint } : {}, where });
|
|
5501
|
-
return err(refusal3);
|
|
5502
|
-
}
|
|
5503
|
-
const flightKey = isWritingDoor(door) ? null : `${door}|${canonicalArgs(args)}`;
|
|
5504
|
-
const flying = flightKey ? readsInFlight.get(flightKey) : void 0;
|
|
5505
|
-
const response = await (flying ?? (() => {
|
|
5506
|
-
const call = Promise.resolve(config.dataSource.rpc(`${door}`, args, { schema }));
|
|
5507
|
-
if (flightKey) {
|
|
5508
|
-
readsInFlight.set(flightKey, call);
|
|
5509
|
-
const forget = () => {
|
|
5510
|
-
if (readsInFlight.get(flightKey) === call) readsInFlight.delete(flightKey);
|
|
5511
|
-
};
|
|
5512
|
-
call.then(forget, forget);
|
|
5513
|
-
}
|
|
5514
|
-
return call;
|
|
5515
|
-
})());
|
|
5516
|
-
if (response.error) {
|
|
5517
|
-
const refusal3 = mapPgError(response.error, where);
|
|
5518
|
-
if (opts?.quiet) console.info(`[@ai-matrx/records] ${where}: ${refusal3.code} - ${refusal3.message}`);
|
|
5519
|
-
else scream({ code: refusal3.code, message: refusal3.message, ...refusal3.hint ? { hint: refusal3.hint } : {}, where });
|
|
5520
|
-
return err(refusal3);
|
|
5521
|
-
}
|
|
5522
|
-
if (isWritingDoor(door) || LOOK_WRITES[door]) {
|
|
5585
|
+
const primedFor = primedDoorAnswer;
|
|
5586
|
+
const callDoor = createDoorCall({
|
|
5587
|
+
dataSource: config.dataSource,
|
|
5588
|
+
schema,
|
|
5589
|
+
onError: scream,
|
|
5590
|
+
doorReady: (door) => doorReady(config, door),
|
|
5591
|
+
absent: doorAbsent,
|
|
5592
|
+
held: fromBundle,
|
|
5593
|
+
wrote: (_door, args) => {
|
|
5523
5594
|
const tableId = args["p_table_id"];
|
|
5524
5595
|
bundleDrop(typeof tableId === "string" ? tableId : null);
|
|
5525
|
-
forgetPrimedTablePageBundlesOf(typeof tableId === "string" ? tableId : null);
|
|
5526
|
-
dropPrimedDoorAnswers(LOOK_WRITES[door]);
|
|
5527
5596
|
}
|
|
5528
|
-
|
|
5529
|
-
|
|
5597
|
+
});
|
|
5598
|
+
const scopes = createScopeDoors(callDoor);
|
|
5530
5599
|
function structureMoved(tableId, result) {
|
|
5531
5600
|
if (result.ok) {
|
|
5532
5601
|
bundleDrop(tableId);
|
|
@@ -5725,7 +5794,7 @@ function createRecordsClient(given) {
|
|
|
5725
5794
|
const unavailableReason = (error) => `${error.message}${error.hint ? ` ${error.hint}` : ""}`;
|
|
5726
5795
|
const client = {
|
|
5727
5796
|
config,
|
|
5728
|
-
scopes
|
|
5797
|
+
scopes,
|
|
5729
5798
|
async recordWrite({ table_id, data }) {
|
|
5730
5799
|
const result = await callDoor(
|
|
5731
5800
|
DOORS.recordWrite,
|
|
@@ -6424,28 +6493,7 @@ function createRecordsClient(given) {
|
|
|
6424
6493
|
"fieldOptions"
|
|
6425
6494
|
);
|
|
6426
6495
|
},
|
|
6427
|
-
|
|
6428
|
-
return callDoor(DOORS.pickListGet, { p_list_id: list_id }, "pickListGet");
|
|
6429
|
-
},
|
|
6430
|
-
async pickListForSelection({ list_id }) {
|
|
6431
|
-
return callDoor(
|
|
6432
|
-
DOORS.pickListForSelection,
|
|
6433
|
-
{ p_list_id: list_id },
|
|
6434
|
-
"pickListForSelection"
|
|
6435
|
-
);
|
|
6436
|
-
},
|
|
6437
|
-
async pickListUpdate({ list_id, list_name, description, items }) {
|
|
6438
|
-
return callDoor(
|
|
6439
|
-
DOORS.pickListUpdate,
|
|
6440
|
-
{
|
|
6441
|
-
p_list_id: list_id,
|
|
6442
|
-
p_list_name: list_name ?? null,
|
|
6443
|
-
p_description: description ?? null,
|
|
6444
|
-
p_items: items ? [...items] : null
|
|
6445
|
-
},
|
|
6446
|
-
"pickListUpdate"
|
|
6447
|
-
);
|
|
6448
|
-
},
|
|
6496
|
+
...createPickListDoors(callDoor),
|
|
6449
6497
|
async fieldChoiceUsage({ field_id }) {
|
|
6450
6498
|
const result = await callDoor(
|
|
6451
6499
|
DOORS.fieldChoiceUsage,
|
|
@@ -8979,11 +9027,7 @@ function createRecordsClient(given) {
|
|
|
8979
9027
|
);
|
|
8980
9028
|
},
|
|
8981
9029
|
async scopeTableProvision({ home_id, item_id, scope_id }) {
|
|
8982
|
-
return
|
|
8983
|
-
DOORS.scopeTableProvision,
|
|
8984
|
-
{ p_organization_id: org, p_item_id: item_id, p_scope_id: scope_id, p_home_id: home_id ?? null },
|
|
8985
|
-
"scopeTableProvision"
|
|
8986
|
-
);
|
|
9030
|
+
return scopes.tableProvision({ organization_id: org, item_id, scope_id, home_id: home_id ?? null });
|
|
8987
9031
|
},
|
|
8988
9032
|
async tableRowCounts({ table_ids }) {
|
|
8989
9033
|
return callDoor(
|