@ai-matrx/records 0.80.4 → 0.80.7
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 +18 -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
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { N as NewFieldSpec } from '../declareTable-
|
|
2
|
-
import { U as Uuid, h as RecordsResult, n as RecordPageSort } from '../record-
|
|
3
|
-
import { R as RecordsClient } from '../client-
|
|
4
|
-
import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-
|
|
5
|
-
import '../field-
|
|
6
|
-
import '../subscription-
|
|
7
|
-
import '../ports-
|
|
1
|
+
import { N as NewFieldSpec } from '../declareTable-02uao-5n.cjs';
|
|
2
|
+
import { U as Uuid, h as RecordsResult, n as RecordPageSort } from '../record-1yDCn169.cjs';
|
|
3
|
+
import { R as RecordsClient } from '../client-DLIKeBWF.cjs';
|
|
4
|
+
import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-LodkBhCZ.cjs';
|
|
5
|
+
import '../field-snQG2jMq.cjs';
|
|
6
|
+
import '../subscription-B_WaT-kr.cjs';
|
|
7
|
+
import '../ports-y1QNfM80.cjs';
|
|
8
8
|
|
|
9
9
|
/** Where a declared field's value goes in the graduated table. */
|
|
10
10
|
declare const TO_CUSTOM_FIELDS: "custom_fields";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { N as NewFieldSpec } from '../declareTable-
|
|
2
|
-
import { U as Uuid, h as RecordsResult, n as RecordPageSort } from '../record-
|
|
3
|
-
import { R as RecordsClient } from '../client-
|
|
4
|
-
import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-
|
|
5
|
-
import '../field-
|
|
6
|
-
import '../subscription-
|
|
7
|
-
import '../ports-
|
|
1
|
+
import { N as NewFieldSpec } from '../declareTable-C5FlIS0z.js';
|
|
2
|
+
import { U as Uuid, h as RecordsResult, n as RecordPageSort } from '../record-1yDCn169.js';
|
|
3
|
+
import { R as RecordsClient } from '../client-D1LTezMZ.js';
|
|
4
|
+
import { F as FieldDrift, T as TableArchiveProgress } from '../table-kind-COmkYYkc.js';
|
|
5
|
+
import '../field-BIJiFPc0.js';
|
|
6
|
+
import '../subscription-CUok1vAm.js';
|
|
7
|
+
import '../ports-Y5gLbCXe.js';
|
|
8
8
|
|
|
9
9
|
/** Where a declared field's value goes in the graduated table. */
|
|
10
10
|
declare const TO_CUSTOM_FIELDS: "custom_fields";
|
package/dist/app-table/index.js
CHANGED
|
@@ -377,6 +377,32 @@ function takePrimedTablePageBundle(organizationId, tableId, viewId) {
|
|
|
377
377
|
return Date.now() - held.at < PRIMED_TTL_MS ? held.answer : null;
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
+
// src/core/recordChanges.ts
|
|
381
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
382
|
+
function announceRecordChanged(recordId) {
|
|
383
|
+
for (const listener of [...listeners]) {
|
|
384
|
+
try {
|
|
385
|
+
listener(recordId);
|
|
386
|
+
} catch (thrown) {
|
|
387
|
+
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
function onRecordChanged(listener) {
|
|
392
|
+
listeners.add(listener);
|
|
393
|
+
return () => listeners.delete(listener);
|
|
394
|
+
}
|
|
395
|
+
var tableListeners = /* @__PURE__ */ new Set();
|
|
396
|
+
function announceTableStructureChanged(tableId) {
|
|
397
|
+
for (const listener of [...tableListeners]) {
|
|
398
|
+
try {
|
|
399
|
+
listener(tableId);
|
|
400
|
+
} catch (thrown) {
|
|
401
|
+
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
380
406
|
// src/archive.ts
|
|
381
407
|
var DEFAULT_ARCHIVE_LANE = "org";
|
|
382
408
|
|
|
@@ -1508,6 +1534,7 @@ var STORE_DOORS = [
|
|
|
1508
1534
|
{ name: "record_filter_sql", args: "p_organization_id uuid, p_table_id uuid, p_filter jsonb", returns: "text", security: "invoker" },
|
|
1509
1535
|
{ 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" },
|
|
1510
1536
|
{ 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" },
|
|
1537
|
+
{ name: "record_page_bundle", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
1511
1538
|
{ name: "record_platform_keys", args: "", returns: "text[]", security: "invoker" },
|
|
1512
1539
|
{ 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" },
|
|
1513
1540
|
{ name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
|
|
@@ -2605,28 +2632,6 @@ var DRILL_DOORS = {
|
|
|
2605
2632
|
rows: "drill_rows"
|
|
2606
2633
|
};
|
|
2607
2634
|
|
|
2608
|
-
// src/core/recordChanges.ts
|
|
2609
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
2610
|
-
function announceRecordChanged(recordId) {
|
|
2611
|
-
for (const listener of [...listeners]) {
|
|
2612
|
-
try {
|
|
2613
|
-
listener(recordId);
|
|
2614
|
-
} catch (thrown) {
|
|
2615
|
-
console.error("[@ai-matrx/records] a record-change listener threw", thrown);
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
|
-
}
|
|
2619
|
-
var tableListeners = /* @__PURE__ */ new Set();
|
|
2620
|
-
function announceTableStructureChanged(tableId) {
|
|
2621
|
-
for (const listener of [...tableListeners]) {
|
|
2622
|
-
try {
|
|
2623
|
-
listener(tableId);
|
|
2624
|
-
} catch (thrown) {
|
|
2625
|
-
console.error("[@ai-matrx/records] a table-structure listener threw", thrown);
|
|
2626
|
-
}
|
|
2627
|
-
}
|
|
2628
|
-
}
|
|
2629
|
-
|
|
2630
2635
|
// src/core/query.ts
|
|
2631
2636
|
var DEFAULT_PAGE_SIZE = 50;
|
|
2632
2637
|
function planQuery(query) {
|
|
@@ -2746,8 +2751,68 @@ function createRecordsClient(given) {
|
|
|
2746
2751
|
} catch {
|
|
2747
2752
|
}
|
|
2748
2753
|
}
|
|
2754
|
+
const RECORD_OPENERS = /* @__PURE__ */ new Set(["read_record", "record_row_controls", "record_history", "comment_thread", "computed_provenance"]);
|
|
2755
|
+
const recordFlights = /* @__PURE__ */ new Map();
|
|
2756
|
+
const recordAsked = /* @__PURE__ */ new Map();
|
|
2757
|
+
let recordChangesHeard = false;
|
|
2758
|
+
function bundleRecordOf(door, args) {
|
|
2759
|
+
if (RECORD_OPENERS.has(door)) return typeof args["p_record_id"] === "string" ? args["p_record_id"] : null;
|
|
2760
|
+
const ids = args["p_ids"];
|
|
2761
|
+
const one = Array.isArray(ids) && ids.length === 1 && typeof ids[0] === "string" ? ids[0] : null;
|
|
2762
|
+
if (door === "record_headers") return one;
|
|
2763
|
+
if (door === "my_levels" && args["p_type"] === "record") return one;
|
|
2764
|
+
return null;
|
|
2765
|
+
}
|
|
2766
|
+
async function fillRecordBundle(recordId) {
|
|
2767
|
+
if (!recordChangesHeard) {
|
|
2768
|
+
recordChangesHeard = true;
|
|
2769
|
+
onRecordChanged((changed) => {
|
|
2770
|
+
recordAsked.delete(changed);
|
|
2771
|
+
for (const key of [...bundleParts.keys()]) if (key.includes(changed)) bundleParts.delete(key);
|
|
2772
|
+
});
|
|
2773
|
+
}
|
|
2774
|
+
try {
|
|
2775
|
+
const usable = (r) => r !== null && !r.error && r.data !== null && typeof r.data === "object" && Array.isArray(r.data.parts);
|
|
2776
|
+
const primedAnswer = takePrimedTablePageBundle(org, `record:${recordId}`, null);
|
|
2777
|
+
let response = primedAnswer ? await primedAnswer : null;
|
|
2778
|
+
if (!usable(response)) {
|
|
2779
|
+
response = await config.dataSource.rpc("record_page_bundle", { p_organization_id: org, p_record_id: recordId }, { schema });
|
|
2780
|
+
}
|
|
2781
|
+
if (!usable(response)) return;
|
|
2782
|
+
const now = Date.now();
|
|
2783
|
+
for (const part of response.data.parts) {
|
|
2784
|
+
if (part.error !== void 0 || part.data === void 0) continue;
|
|
2785
|
+
bundleParts.set(bundleKey(part.door, part.args), { data: part.data, at: now });
|
|
2786
|
+
}
|
|
2787
|
+
} catch {
|
|
2788
|
+
}
|
|
2789
|
+
}
|
|
2790
|
+
async function fromRecordBundle(door, args) {
|
|
2791
|
+
if (!doorReady(config, "record_page_bundle")) return void 0;
|
|
2792
|
+
const recordId = bundleRecordOf(door, args);
|
|
2793
|
+
if (!recordId) return void 0;
|
|
2794
|
+
const opener = RECORD_OPENERS.has(door);
|
|
2795
|
+
if (!opener && !recordFlights.has(recordId) && !recordAsked.has(recordId)) return void 0;
|
|
2796
|
+
const asked = recordAsked.get(recordId);
|
|
2797
|
+
const fresh = asked !== void 0 && Date.now() - asked < BUNDLE_TTL_MS;
|
|
2798
|
+
if (!fresh && opener) {
|
|
2799
|
+
recordAsked.set(recordId, Date.now());
|
|
2800
|
+
const flight2 = fillRecordBundle(recordId).finally(() => recordFlights.delete(recordId));
|
|
2801
|
+
recordFlights.set(recordId, flight2);
|
|
2802
|
+
}
|
|
2803
|
+
const flight = recordFlights.get(recordId);
|
|
2804
|
+
if (flight) await flight;
|
|
2805
|
+
const key = bundleKey(door, args);
|
|
2806
|
+
const held = bundleParts.get(key);
|
|
2807
|
+
if (!held) return opener ? null : void 0;
|
|
2808
|
+
bundleParts.delete(key);
|
|
2809
|
+
return Date.now() - held.at < BUNDLE_TTL_MS ? { data: held.data } : null;
|
|
2810
|
+
}
|
|
2749
2811
|
async function fromBundle(door, args) {
|
|
2750
|
-
if (!config.dataSource.opensInOneCall
|
|
2812
|
+
if (!config.dataSource.opensInOneCall) return null;
|
|
2813
|
+
const fromRecord = await fromRecordBundle(door, args);
|
|
2814
|
+
if (fromRecord !== void 0) return fromRecord;
|
|
2815
|
+
if (!doorReady(config, "table_page_bundle")) return null;
|
|
2751
2816
|
const tableId = bundleTableOf(door, args);
|
|
2752
2817
|
if (tableId) {
|
|
2753
2818
|
const asked = bundleAsked.get(tableId);
|