@ai-matrx/records 0.80.4 → 0.80.8
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 +24 -0
- package/README.md +19 -0
- package/dist/app-table/index.cjs +88 -23
- package/dist/app-table/index.cjs.map +1 -1
- package/dist/app-table/index.d.cts +7 -7
- package/dist/app-table/index.d.ts +7 -7
- package/dist/app-table/index.js +88 -23
- package/dist/app-table/index.js.map +1 -1
- package/dist/{client-CB_Klj1P.d.ts → client-D1LTezMZ.d.ts} +5 -5
- package/dist/{client-D0yGEof4.d.cts → client-DLIKeBWF.d.cts} +5 -5
- package/dist/core/index.cjs +97 -31
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +21 -12
- package/dist/core/index.d.ts +21 -12
- package/dist/core/index.js +97 -31
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +88 -23
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +6 -6
- package/dist/data/index.d.ts +6 -6
- package/dist/data/index.js +88 -23
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-l7ktxN6p.d.cts → declareTable-02uao-5n.d.cts} +4 -4
- package/dist/{declareTable-DoYVueVF.d.ts → declareTable-C5FlIS0z.d.ts} +4 -4
- package/dist/{field-6UtYgFeu.d.ts → field-BIJiFPc0.d.ts} +1 -1
- package/dist/{field-DpJR_5Pe.d.cts → field-snQG2jMq.d.cts} +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.cjs +1 -0
- package/dist/memory/index.cjs.map +1 -1
- package/dist/memory/index.d.cts +6 -6
- package/dist/memory/index.d.ts +6 -6
- package/dist/memory/index.js +1 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/{ports-CiEYhwi5.d.ts → ports-Y5gLbCXe.d.ts} +1 -1
- package/dist/{ports-CE7umTp-.d.cts → ports-y1QNfM80.d.cts} +1 -1
- package/dist/react/index.cjs +89 -27
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +6 -1
- package/dist/react/index.d.ts +6 -1
- package/dist/react/index.js +89 -27
- package/dist/react/index.js.map +1 -1
- package/dist/realtime/index.d.cts +2 -2
- package/dist/realtime/index.d.ts +2 -2
- package/dist/{record-CvqV8wyO.d.cts → record-1yDCn169.d.cts} +6 -1
- package/dist/{record-CvqV8wyO.d.ts → record-1yDCn169.d.ts} +6 -1
- package/dist/{subscription-CC0kgkwa.d.cts → subscription-B_WaT-kr.d.cts} +1 -1
- package/dist/{subscription-DjkuDMcX.d.ts → subscription-CUok1vAm.d.ts} +1 -1
- package/dist/{table-kind-FMYq3nCr.d.ts → table-kind-COmkYYkc.d.ts} +3 -3
- package/dist/{table-kind-DHpMEOHd.d.cts → table-kind-LodkBhCZ.d.cts} +3 -3
- package/dist/templates/index.cjs +3 -2
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.d.cts +9 -9
- package/dist/templates/index.d.ts +9 -9
- package/dist/templates/index.js +3 -2
- package/dist/templates/index.js.map +1 -1
- package/dist/{types-DuceX7js.d.cts → types-BJGTxu3Y.d.cts} +2 -2
- package/dist/{types-BbCZJh1C.d.ts → types-C5-AaPa6.d.ts} +2 -2
- package/dist/{types-B4LF3sFx.d.ts → types-CU_Tn2Np.d.ts} +2 -2
- package/dist/{types-Flsf_KU5.d.cts → types-yBZLtxrZ.d.cts} +2 -2
- package/dist/use-cases/index.cjs.map +1 -1
- package/dist/use-cases/index.d.cts +5 -5
- package/dist/use-cases/index.d.ts +5 -5
- package/dist/use-cases/index.js.map +1 -1
- package/dist/{validate-EvZGkD96.d.cts → validate-CE6qpJIb.d.cts} +1 -1
- package/dist/{validate-DyVwSD74.d.ts → validate-Rz9djP6H.d.ts} +1 -1
- package/package.json +1 -1
package/dist/react/index.cjs
CHANGED
|
@@ -310,6 +310,32 @@ function takePrimedTablePageBundle(organizationId, tableId, viewId) {
|
|
|
310
310
|
return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
+
// src/core/recordChanges.ts
|
|
314
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
315
|
+
function announceRecordChanged(recordId) {
|
|
316
|
+
for (const listener of [...listeners]) {
|
|
317
|
+
try {
|
|
318
|
+
listener(recordId);
|
|
319
|
+
} catch (thrown) {
|
|
320
|
+
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function onRecordChanged(listener) {
|
|
325
|
+
listeners.add(listener);
|
|
326
|
+
return () => listeners.delete(listener);
|
|
327
|
+
}
|
|
328
|
+
var tableListeners = /* @__PURE__ */ new Set();
|
|
329
|
+
function announceTableStructureChanged(tableId) {
|
|
330
|
+
for (const listener of [...tableListeners]) {
|
|
331
|
+
try {
|
|
332
|
+
listener(tableId);
|
|
333
|
+
} catch (thrown) {
|
|
334
|
+
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
313
339
|
// src/archive.ts
|
|
314
340
|
var ARCHIVE_LANES = ["mine", "org"];
|
|
315
341
|
var DEFAULT_ARCHIVE_LANE = "org";
|
|
@@ -1933,6 +1959,7 @@ var STORE_DOORS = [
|
|
|
1933
1959
|
{ name: "record_filter_sql", args: "p_organization_id uuid, p_table_id uuid, p_filter jsonb", returns: "text", security: "invoker" },
|
|
1934
1960
|
{ name: "record_headers", args: "p_organization_id uuid, p_ids uuid[]", returns: "TABLE(id uuid, table_id uuid, created_at timestamp with time zone, updated_at timestamp with time zone, version integer, deleted_at timestamp with time zone, mine boolean, created_by uuid)", security: "definer" },
|
|
1935
1961
|
{ name: "record_history", args: "p_organization_id uuid, p_record_id uuid, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0", returns: "TABLE(version integer, occurred_at timestamp with time zone, operation text, operation_label text, actor jsonb, changes jsonb, migration_id uuid, undoable boolean)", security: "definer" },
|
|
1962
|
+
{ name: "record_page_bundle", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
1936
1963
|
{ name: "record_platform_keys", args: "", returns: "text[]", security: "invoker" },
|
|
1937
1964
|
{ name: "record_relation_edges", args: "p_organization_id uuid, p_id uuid, p_table_id uuid, p_data_class text, p_data jsonb, p_deleted_at timestamp with time zone", returns: "TABLE(target_id uuid, edge_role text, field_id uuid, ord integer)", security: "invoker" },
|
|
1938
1965
|
{ name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
|
|
@@ -2343,6 +2370,7 @@ var ENTITY_TOKENS = [
|
|
|
2343
2370
|
"access_shadow_log",
|
|
2344
2371
|
"account_addon",
|
|
2345
2372
|
"account_closure",
|
|
2373
|
+
"account_facts",
|
|
2346
2374
|
"acquisition_block",
|
|
2347
2375
|
"activity",
|
|
2348
2376
|
"admin_audit_log",
|
|
@@ -4262,32 +4290,6 @@ var DRILL_DOORS = {
|
|
|
4262
4290
|
rows: "drill_rows"
|
|
4263
4291
|
};
|
|
4264
4292
|
|
|
4265
|
-
// src/core/recordChanges.ts
|
|
4266
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
4267
|
-
function announceRecordChanged(recordId) {
|
|
4268
|
-
for (const listener of [...listeners]) {
|
|
4269
|
-
try {
|
|
4270
|
-
listener(recordId);
|
|
4271
|
-
} catch (thrown) {
|
|
4272
|
-
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
4273
|
-
}
|
|
4274
|
-
}
|
|
4275
|
-
}
|
|
4276
|
-
function onRecordChanged(listener) {
|
|
4277
|
-
listeners.add(listener);
|
|
4278
|
-
return () => listeners.delete(listener);
|
|
4279
|
-
}
|
|
4280
|
-
var tableListeners = /* @__PURE__ */ new Set();
|
|
4281
|
-
function announceTableStructureChanged(tableId) {
|
|
4282
|
-
for (const listener of [...tableListeners]) {
|
|
4283
|
-
try {
|
|
4284
|
-
listener(tableId);
|
|
4285
|
-
} catch (thrown) {
|
|
4286
|
-
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
4287
|
-
}
|
|
4288
|
-
}
|
|
4289
|
-
}
|
|
4290
|
-
|
|
4291
4293
|
// src/core/query.ts
|
|
4292
4294
|
var DEFAULT_PAGE_SIZE = 50;
|
|
4293
4295
|
function planQuery(query) {
|
|
@@ -4407,8 +4409,68 @@ function createRecordsClient(given) {
|
|
|
4407
4409
|
} catch {
|
|
4408
4410
|
}
|
|
4409
4411
|
}
|
|
4412
|
+
const RECORD_OPENERS = /* @__PURE__ */ new Set(["read_record", "record_row_controls", "record_history", "comment_thread", "computed_provenance"]);
|
|
4413
|
+
const recordFlights = /* @__PURE__ */ new Map();
|
|
4414
|
+
const recordAsked = /* @__PURE__ */ new Map();
|
|
4415
|
+
let recordChangesHeard = false;
|
|
4416
|
+
function bundleRecordOf(door, args) {
|
|
4417
|
+
if (RECORD_OPENERS.has(door)) return typeof args["p_record_id"] === "string" ? args["p_record_id"] : null;
|
|
4418
|
+
const ids = args["p_ids"];
|
|
4419
|
+
const one = Array.isArray(ids) && ids.length === 1 && typeof ids[0] === "string" ? ids[0] : null;
|
|
4420
|
+
if (door === "record_headers") return one;
|
|
4421
|
+
if (door === "my_levels" && args["p_type"] === "record") return one;
|
|
4422
|
+
return null;
|
|
4423
|
+
}
|
|
4424
|
+
async function fillRecordBundle(recordId) {
|
|
4425
|
+
if (!recordChangesHeard) {
|
|
4426
|
+
recordChangesHeard = true;
|
|
4427
|
+
onRecordChanged((changed) => {
|
|
4428
|
+
recordAsked.delete(changed);
|
|
4429
|
+
for (const key of [...bundleParts.keys()]) if (key.includes(changed)) bundleParts.delete(key);
|
|
4430
|
+
});
|
|
4431
|
+
}
|
|
4432
|
+
try {
|
|
4433
|
+
const usable = (r) => r !== null && !r.error && r.data !== null && typeof r.data === "object" && Array.isArray(r.data.parts);
|
|
4434
|
+
const primedAnswer = takePrimedTablePageBundle(org, `record:${recordId}`, null);
|
|
4435
|
+
let response = primedAnswer ? await primedAnswer : null;
|
|
4436
|
+
if (!usable(response)) {
|
|
4437
|
+
response = await config.dataSource.rpc("record_page_bundle", { p_organization_id: org, p_record_id: recordId }, { schema });
|
|
4438
|
+
}
|
|
4439
|
+
if (!usable(response)) return;
|
|
4440
|
+
const now = Date.now();
|
|
4441
|
+
for (const part of response.data.parts) {
|
|
4442
|
+
if (part.error !== void 0 || part.data === void 0) continue;
|
|
4443
|
+
bundleParts.set(bundleKey(part.door, part.args), { data: part.data, at: now });
|
|
4444
|
+
}
|
|
4445
|
+
} catch {
|
|
4446
|
+
}
|
|
4447
|
+
}
|
|
4448
|
+
async function fromRecordBundle(door, args) {
|
|
4449
|
+
if (!doorReady(config, "record_page_bundle")) return void 0;
|
|
4450
|
+
const recordId = bundleRecordOf(door, args);
|
|
4451
|
+
if (!recordId) return void 0;
|
|
4452
|
+
const opener = RECORD_OPENERS.has(door);
|
|
4453
|
+
if (!opener && !recordFlights.has(recordId) && !recordAsked.has(recordId)) return void 0;
|
|
4454
|
+
const asked = recordAsked.get(recordId);
|
|
4455
|
+
const fresh = asked !== void 0 && Date.now() - asked < BUNDLE_TTL_MS;
|
|
4456
|
+
if (!fresh && opener) {
|
|
4457
|
+
recordAsked.set(recordId, Date.now());
|
|
4458
|
+
const flight2 = fillRecordBundle(recordId).finally(() => recordFlights.delete(recordId));
|
|
4459
|
+
recordFlights.set(recordId, flight2);
|
|
4460
|
+
}
|
|
4461
|
+
const flight = recordFlights.get(recordId);
|
|
4462
|
+
if (flight) await flight;
|
|
4463
|
+
const key = bundleKey(door, args);
|
|
4464
|
+
const held = bundleParts.get(key);
|
|
4465
|
+
if (!held) return opener ? null : void 0;
|
|
4466
|
+
bundleParts.delete(key);
|
|
4467
|
+
return Date.now() - held.at < BUNDLE_TTL_MS ? { data: held.data } : null;
|
|
4468
|
+
}
|
|
4410
4469
|
async function fromBundle(door, args) {
|
|
4411
|
-
if (!config.dataSource.opensInOneCall
|
|
4470
|
+
if (!config.dataSource.opensInOneCall) return null;
|
|
4471
|
+
const fromRecord = await fromRecordBundle(door, args);
|
|
4472
|
+
if (fromRecord !== void 0) return fromRecord;
|
|
4473
|
+
if (!doorReady(config, "table_page_bundle")) return null;
|
|
4412
4474
|
const tableId = bundleTableOf(door, args);
|
|
4413
4475
|
if (tableId) {
|
|
4414
4476
|
const asked = bundleAsked.get(tableId);
|