@ai-matrx/records 0.98.7 → 0.98.9
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 +12 -0
- package/dist/{table-kind-CboiMJuE.d.cts → client-9fzhCPD5.d.cts} +2771 -4
- package/dist/{table-kind-B4sdlvHf.d.ts → client-DcWZjmg2.d.ts} +2771 -4
- package/dist/core/index.cjs +154 -3
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +109 -18
- package/dist/core/index.d.ts +109 -18
- package/dist/core/index.js +154 -3
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +52 -0
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +11 -12
- package/dist/data/index.d.ts +11 -12
- package/dist/data/index.js +52 -0
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-BIuPJ3Vj.d.ts → declareTable-B6ic3leL.d.ts} +3 -4
- package/dist/{declareTable-d-HxRmF0.d.cts → declareTable-_GwN-ERY.d.cts} +3 -4
- package/dist/{doors-Bx3Shs3z.d.cts → doors-Dm5q9H8Y.d.cts} +1 -1
- package/dist/{doors-BTifsjNv.d.ts → doors-t-Oc2l9E.d.ts} +1 -1
- package/dist/entity/index.d.cts +7 -7
- package/dist/entity/index.d.ts +7 -7
- package/dist/{field-CJtssH3q.d.ts → field-BIRNApm1.d.ts} +2 -2
- package/dist/{field-DoVl2I9K.d.cts → field-BLy8drjM.d.cts} +2 -2
- package/dist/forms/index.d.cts +3 -3
- package/dist/forms/index.d.ts +3 -3
- package/dist/index.cjs +45 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -13
- package/dist/index.d.ts +30 -13
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.cts +7 -7
- package/dist/memory/index.d.ts +7 -7
- package/dist/{objectOrganization-Crk9gJUM.d.ts → objectOrganization-D5Ytjah7.d.ts} +1 -1
- package/dist/{objectOrganization-CUa6jjhV.d.cts → objectOrganization-zgpoUAH1.d.cts} +1 -1
- package/dist/{port-CRP5g9l9.d.cts → port-B9glCG2h.d.cts} +3 -3
- package/dist/{port-CtnELAJQ.d.ts → port-C-p-_lAu.d.ts} +3 -3
- package/dist/{portal-DW5NGBT0.d.ts → portal-B9HCNPTc.d.ts} +2 -2
- package/dist/{portal-C4N9ByaY.d.cts → portal-C_LgvDeh.d.cts} +2 -2
- package/dist/{ports-WwHHNwge.d.ts → ports-BE_5jz-c.d.ts} +2 -2
- package/dist/{ports-YIh9jrCZ.d.cts → ports-BIdYUS-C.d.cts} +2 -2
- package/dist/questions/index.d.cts +9 -10
- package/dist/questions/index.d.ts +9 -10
- package/dist/react/index.cjs +97 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +86 -1
- package/dist/react/index.d.ts +86 -1
- package/dist/react/index.js +97 -0
- 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-CxGK1OEK.d.cts → record-BrJNCmH1.d.cts} +1 -1
- package/dist/{record-CxGK1OEK.d.ts → record-BrJNCmH1.d.ts} +1 -1
- package/dist/{relation-Dh-lCkkh.d.ts → relation-BxGXLRaG.d.ts} +3 -3
- package/dist/{relation-DSGhM3tO.d.cts → relation-R10qQyQU.d.cts} +3 -3
- package/dist/{rule-DQpC7WqT.d.cts → rule-BGtYd6Pf.d.cts} +2 -2
- package/dist/{rule-xNwJF6Qo.d.ts → rule-BtjrE42J.d.ts} +2 -2
- package/dist/scopes/index.d.cts +3 -3
- package/dist/scopes/index.d.ts +3 -3
- package/dist/search/index.d.cts +1 -1
- package/dist/search/index.d.ts +1 -1
- package/dist/setup/index.cjs +52 -0
- package/dist/setup/index.cjs.map +1 -1
- package/dist/setup/index.d.cts +12 -13
- package/dist/setup/index.d.ts +12 -13
- package/dist/setup/index.js +52 -0
- package/dist/setup/index.js.map +1 -1
- package/dist/{subscription-BVCn1PVe.d.cts → subscription-BEM4B4dR.d.cts} +3 -3
- package/dist/{subscription-DQzPVKBR.d.ts → subscription-Ca15Z7Gu.d.ts} +3 -3
- package/dist/templates/index.d.cts +10 -10
- package/dist/templates/index.d.ts +10 -10
- package/dist/typed-table/index.cjs +52 -0
- package/dist/typed-table/index.cjs.map +1 -1
- package/dist/typed-table/index.d.cts +10 -11
- package/dist/typed-table/index.d.ts +10 -11
- package/dist/typed-table/index.js +52 -0
- package/dist/typed-table/index.js.map +1 -1
- package/dist/{types-3lM5f6b0.d.cts → types-5ql9_q-o.d.cts} +2 -2
- package/dist/{types-04kFNi3-.d.ts → types-BALEbMc8.d.ts} +2 -2
- package/dist/{types-DKJO83lQ.d.cts → types-BhnjvJ8U.d.cts} +2 -2
- package/dist/{types-SUAmeBId.d.ts → types-CURw95qc.d.ts} +2 -2
- package/dist/{types-DKeGkHpE.d.cts → types-DRMeL0uW.d.cts} +2 -2
- package/dist/{types-DJVccwh0.d.ts → types-_odOqLOe.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-BIJtP2KB.d.cts → validate-Cdtk0y18.d.cts} +1 -1
- package/dist/{validate--y-pPc-c.d.ts → validate-ChibJPPI.d.ts} +1 -1
- package/dist/views/index.d.cts +9 -10
- package/dist/views/index.d.ts +9 -10
- package/package.json +2 -2
- package/dist/client-C1B-MNzb.d.ts +0 -2704
- package/dist/client-D2jAgJNn.d.cts +0 -2704
package/dist/core/index.js
CHANGED
|
@@ -5127,6 +5127,49 @@ function tableRenderSchema(facts) {
|
|
|
5127
5127
|
return { kind: slug, fields: out };
|
|
5128
5128
|
}
|
|
5129
5129
|
|
|
5130
|
+
// src/alternates.ts
|
|
5131
|
+
function refuse(code, message, hint) {
|
|
5132
|
+
return { ok: false, error: { code, message, hint, ours: true } };
|
|
5133
|
+
}
|
|
5134
|
+
function alternatePatch(document, field_key, alternate_index) {
|
|
5135
|
+
const block = document._values ?? {};
|
|
5136
|
+
const envelope = block[field_key];
|
|
5137
|
+
const alternates = Array.isArray(envelope?.alternates) ? envelope.alternates : [];
|
|
5138
|
+
const chosen = alternates[alternate_index];
|
|
5139
|
+
if (!envelope || !chosen) return { ok: false, message: "That other value is no longer on this record." };
|
|
5140
|
+
const kept = alternates.filter((_, i) => i !== alternate_index);
|
|
5141
|
+
const current = document[field_key];
|
|
5142
|
+
const next = [...kept];
|
|
5143
|
+
if (current !== null && current !== void 0) {
|
|
5144
|
+
const taken = new Set(kept.map((a) => a.rank));
|
|
5145
|
+
let rank = 1;
|
|
5146
|
+
while (taken.has(rank)) rank += 1;
|
|
5147
|
+
next.push({ value: current, ...envelope.src ? { src: envelope.src } : {}, rank });
|
|
5148
|
+
}
|
|
5149
|
+
const { ver: _ver, actor: _actor, at: _at, on_behalf_of: _on, absent: _absent, alternates: _alts, src: _src, ...rest } = envelope;
|
|
5150
|
+
const changed = { ...rest, ...chosen.src ? { src: chosen.src } : {} };
|
|
5151
|
+
if (next.length > 0) changed["alternates"] = next;
|
|
5152
|
+
return {
|
|
5153
|
+
ok: true,
|
|
5154
|
+
patch: {
|
|
5155
|
+
[field_key]: chosen.value,
|
|
5156
|
+
// THE WHOLE BLOCK — every other field's envelope and alternates travel with it.
|
|
5157
|
+
_values: { ...block, [field_key]: changed }
|
|
5158
|
+
}
|
|
5159
|
+
};
|
|
5160
|
+
}
|
|
5161
|
+
async function chooseAlternate(client, { record_id, field_key, alternate_index }) {
|
|
5162
|
+
const read = await client.recordRead({ record_id, withVersion: true });
|
|
5163
|
+
if (!read.ok) return read;
|
|
5164
|
+
const version = read.data.version;
|
|
5165
|
+
if (version === null || version === void 0) {
|
|
5166
|
+
return refuse("stale_read", "Nothing was saved: this record's latest changes could not be checked.", "Reload, then try again.");
|
|
5167
|
+
}
|
|
5168
|
+
const built = alternatePatch(read.data.document, field_key, alternate_index);
|
|
5169
|
+
if (!built.ok) return refuse("not_found", built.message, "Reload, then look again.");
|
|
5170
|
+
return client.recordUpdate({ record_id, patch: built.patch, expectedVersion: version });
|
|
5171
|
+
}
|
|
5172
|
+
|
|
5130
5173
|
// src/core/primedBundle.ts
|
|
5131
5174
|
var PRIMED_TTL_MS = 15e3;
|
|
5132
5175
|
var REGISTRY = /* @__PURE__ */ Symbol.for("@ai-matrx/records/primed-table-page-bundles");
|
|
@@ -6161,6 +6204,14 @@ var DOORS = {
|
|
|
6161
6204
|
// archived and aliased), and put any recorded Migration back.
|
|
6162
6205
|
migrateMerge: "migrate_merge",
|
|
6163
6206
|
migrateUndo: "migrate_undo",
|
|
6207
|
+
// CORE-VISION (2026-10-10): the structural Migrations a person runs on ONE record from its menu.
|
|
6208
|
+
// Split moves the named values to a new record of the same Table (the original keeps its id);
|
|
6209
|
+
// extract parent copies the named values up into a new record of another Table and puts this
|
|
6210
|
+
// record under it. Both answer a `migration_id` that `migrateUndo` takes. `migrations` lists
|
|
6211
|
+
// the Migration log for one target, newest first.
|
|
6212
|
+
migrateSplit: "migrate_split",
|
|
6213
|
+
migrateExtractParent: "migrate_extract_parent",
|
|
6214
|
+
migrations: "migrations",
|
|
6164
6215
|
recordValues: "record_values",
|
|
6165
6216
|
recordValuesVersioned: "record_values_versioned",
|
|
6166
6217
|
valueRead: "value_read",
|
|
@@ -6715,7 +6766,7 @@ function doorCensus() {
|
|
|
6715
6766
|
}
|
|
6716
6767
|
|
|
6717
6768
|
// src/core/supabase.ts
|
|
6718
|
-
function
|
|
6769
|
+
function refuse2(code, message, hint) {
|
|
6719
6770
|
return { data: null, error: { code, message, hint, details: "" } };
|
|
6720
6771
|
}
|
|
6721
6772
|
function supabaseDataSource(client) {
|
|
@@ -6728,7 +6779,7 @@ function supabaseDataSource(client) {
|
|
|
6728
6779
|
rpc(fn, args, options) {
|
|
6729
6780
|
if (!hasSchema) {
|
|
6730
6781
|
return Promise.resolve(
|
|
6731
|
-
|
|
6782
|
+
refuse2(
|
|
6732
6783
|
"data_source_unbound",
|
|
6733
6784
|
`The records client was given something that is not a supabase client: it has no schema() method, so the door ${fn} cannot be called in the schema it lives in.`,
|
|
6734
6785
|
"Pass a supabase-js v2 client (createClient(...)) to supabaseDataSource()."
|
|
@@ -6738,7 +6789,7 @@ function supabaseDataSource(client) {
|
|
|
6738
6789
|
const name = options?.schema;
|
|
6739
6790
|
if (!name) {
|
|
6740
6791
|
return Promise.resolve(
|
|
6741
|
-
|
|
6792
|
+
refuse2(
|
|
6742
6793
|
"schema_unsaid",
|
|
6743
6794
|
`The door ${fn} was called without saying which schema it lives in. Every door of this store is custom.${fn} and every trust door is iam.${fn}; an unqualified call reaches PostgREST's default profile (public) and is refused there.`,
|
|
6744
6795
|
"This is a bug in the caller, not in your data: /core says the schema on every call."
|
|
@@ -8089,6 +8140,49 @@ function createRecordsClient(given) {
|
|
|
8089
8140
|
}
|
|
8090
8141
|
return result;
|
|
8091
8142
|
},
|
|
8143
|
+
async migrateSplit({ record_id, moved_keys, note }) {
|
|
8144
|
+
const result = await callDoor(
|
|
8145
|
+
DOORS.migrateSplit,
|
|
8146
|
+
{ p_organization_id: org, p_record_id: record_id, p_moved_keys: moved_keys, p_note: note ?? null },
|
|
8147
|
+
"migrateSplit"
|
|
8148
|
+
);
|
|
8149
|
+
if (result.ok) {
|
|
8150
|
+
announceRecordChanged(record_id);
|
|
8151
|
+
announceRecordChanged(result.data.new_record);
|
|
8152
|
+
}
|
|
8153
|
+
return result;
|
|
8154
|
+
},
|
|
8155
|
+
async migrateExtractParent({ record_id, parent_table_id, moved_keys, note }) {
|
|
8156
|
+
const result = await callDoor(
|
|
8157
|
+
DOORS.migrateExtractParent,
|
|
8158
|
+
{ p_organization_id: org, p_id: record_id, p_parent_table_id: parent_table_id, p_moved_keys: moved_keys, p_note: note ?? null },
|
|
8159
|
+
"migrateExtractParent"
|
|
8160
|
+
);
|
|
8161
|
+
if (result.ok) {
|
|
8162
|
+
announceRecordChanged(record_id);
|
|
8163
|
+
announceRecordChanged(result.data.parent);
|
|
8164
|
+
}
|
|
8165
|
+
return result;
|
|
8166
|
+
},
|
|
8167
|
+
async migrations({ target_id, limit }) {
|
|
8168
|
+
return callDoor(
|
|
8169
|
+
DOORS.migrations,
|
|
8170
|
+
{ p_organization_id: org, p_target_id: target_id ?? null, p_limit: limit ?? 100 },
|
|
8171
|
+
"migrations"
|
|
8172
|
+
);
|
|
8173
|
+
},
|
|
8174
|
+
async recordAsOf({ record_id, recorded_at, world_on }) {
|
|
8175
|
+
return callDoor(
|
|
8176
|
+
DOORS.queryRecordAsOf,
|
|
8177
|
+
{
|
|
8178
|
+
p_organization_id: org,
|
|
8179
|
+
p_record_id: record_id,
|
|
8180
|
+
...recorded_at ? { p_recorded_at: recorded_at } : {},
|
|
8181
|
+
...world_on ? { p_world_on: world_on.slice(0, 10) } : {}
|
|
8182
|
+
},
|
|
8183
|
+
"recordAsOf"
|
|
8184
|
+
);
|
|
8185
|
+
},
|
|
8092
8186
|
async migrateUndo({ migration_id }) {
|
|
8093
8187
|
const result = await callDoor(
|
|
8094
8188
|
DOORS.migrateUndo,
|
|
@@ -8096,6 +8190,7 @@ function createRecordsClient(given) {
|
|
|
8096
8190
|
"migrateUndo"
|
|
8097
8191
|
);
|
|
8098
8192
|
if (result.ok && result.data.record_id) announceRecordChanged(result.data.record_id);
|
|
8193
|
+
if (result.ok && result.data.removed) announceRecordChanged(result.data.removed);
|
|
8099
8194
|
return result;
|
|
8100
8195
|
},
|
|
8101
8196
|
async fieldUpdate({ field_id, patch }) {
|
|
@@ -10731,6 +10826,58 @@ function blockLandedInStore(outcomes, block) {
|
|
|
10731
10826
|
return false;
|
|
10732
10827
|
}
|
|
10733
10828
|
|
|
10829
|
+
// src/core/storeDoors.ts
|
|
10830
|
+
var STORE_SCHEMA = "custom";
|
|
10831
|
+
function storeDoors(client) {
|
|
10832
|
+
const source = supabaseDataSource(client ?? {});
|
|
10833
|
+
const call = (fn, args = {}) => source.rpc(fn, args, { schema: STORE_SCHEMA });
|
|
10834
|
+
const typed = (fn, args) => call(fn, args);
|
|
10835
|
+
return {
|
|
10836
|
+
rpc: call,
|
|
10837
|
+
async whereIdOpens(id) {
|
|
10838
|
+
const raw = await call("where_id_opens", { p_id: id });
|
|
10839
|
+
const e = raw.error;
|
|
10840
|
+
return {
|
|
10841
|
+
data: raw.data ?? null,
|
|
10842
|
+
error: e ? { code: typeof e.code === "string" ? e.code : null, message: typeof e.message === "string" ? e.message : "The record store refused." } : null
|
|
10843
|
+
};
|
|
10844
|
+
},
|
|
10845
|
+
tableKernelId: () => typed("table_kernel_id", {}),
|
|
10846
|
+
readRecordsByIds: (organizationId, tableId, ids) => typed("read_records_by_ids", { p_organization_id: organizationId, p_table_id: tableId, p_record_ids: ids }),
|
|
10847
|
+
readRecordsPage: (args) => typed("read_records_page", args),
|
|
10848
|
+
recordTable: (organizationId, recordId) => typed("record_table", { p_organization_id: organizationId, p_record_id: recordId }),
|
|
10849
|
+
applicableFields: (organizationId, tableId) => typed("applicable_fields", { p_organization_id: organizationId, p_table_id: tableId }),
|
|
10850
|
+
fieldDeclare: (organizationId, tableId, spec) => typed("field_declare", { p_organization_id: organizationId, p_table_id: tableId, p_spec: spec }),
|
|
10851
|
+
recordUpdate: (organizationId, recordId, patch) => typed("record_update", { p_organization_id: organizationId, p_record_id: recordId, p_patch: patch }),
|
|
10852
|
+
entityReferenceWords: (organizationId, refs) => typed("entity_reference_words", { p_organization_id: organizationId, p_refs: refs.map((r) => ({ token: r.token, id: r.id })) }),
|
|
10853
|
+
templates: (filter) => typed("templates", { p_filter: filter }),
|
|
10854
|
+
templateFromTables: ({ organizationId, tableIds, includeRows, rowsPerTable }) => typed("template_from_tables", {
|
|
10855
|
+
p_organization_id: organizationId,
|
|
10856
|
+
p_table_ids: tableIds,
|
|
10857
|
+
p_include_rows: includeRows,
|
|
10858
|
+
p_rows_per_table: rowsPerTable
|
|
10859
|
+
}),
|
|
10860
|
+
templateDeclare: (scope, spec) => typed("template_declare", { p_scope: scope, p_spec: spec }),
|
|
10861
|
+
templateKeep: (templateId) => typed("template_keep", { p_template_id: templateId }),
|
|
10862
|
+
templateArchive: (templateId, restore) => typed("template_archive", restore === void 0 ? { p_template_id: templateId } : { p_template_id: templateId, p_restore: restore }),
|
|
10863
|
+
templateInstallClaim: ({ organizationId, installId, kind, label, sourceId, leaseSeconds }) => typed("template_install_claim", {
|
|
10864
|
+
p_organization_id: organizationId,
|
|
10865
|
+
p_install_id: installId,
|
|
10866
|
+
p_kind: kind,
|
|
10867
|
+
p_label: label,
|
|
10868
|
+
...sourceId ? { p_source_id: sourceId } : {},
|
|
10869
|
+
p_lease_seconds: leaseSeconds
|
|
10870
|
+
}),
|
|
10871
|
+
templateInstallNote: ({ organizationId, installId, kind, id, label }) => typed("template_install_note", {
|
|
10872
|
+
p_organization_id: organizationId,
|
|
10873
|
+
p_install_id: installId,
|
|
10874
|
+
p_kind: kind,
|
|
10875
|
+
p_id: id,
|
|
10876
|
+
p_label: label
|
|
10877
|
+
})
|
|
10878
|
+
};
|
|
10879
|
+
}
|
|
10880
|
+
|
|
10734
10881
|
// src/core/validation.ts
|
|
10735
10882
|
import { isUuidShape as isUuidShape6 } from "@ai-matrx/kit/uuid";
|
|
10736
10883
|
var DEFAULT_VALUE_MAX_BYTES = 1e5;
|
|
@@ -11350,6 +11497,7 @@ export {
|
|
|
11350
11497
|
STORE_DOORS,
|
|
11351
11498
|
STORE_KNOBS,
|
|
11352
11499
|
STORE_REFUSAL_CODES,
|
|
11500
|
+
STORE_SCHEMA,
|
|
11353
11501
|
SYSTEM_WRITER_WORDS,
|
|
11354
11502
|
TABLE_DISPLAYS,
|
|
11355
11503
|
TABLE_KIND_PREFIX,
|
|
@@ -11365,6 +11513,7 @@ export {
|
|
|
11365
11513
|
addressMapUrl,
|
|
11366
11514
|
addressText,
|
|
11367
11515
|
allowsOtherValues,
|
|
11516
|
+
alternatePatch,
|
|
11368
11517
|
announceRecordChanged,
|
|
11369
11518
|
announceTableStructureChanged,
|
|
11370
11519
|
archivedByLine,
|
|
@@ -11389,6 +11538,7 @@ export {
|
|
|
11389
11538
|
choiceSlug,
|
|
11390
11539
|
choiceValuesOf,
|
|
11391
11540
|
choicesOf,
|
|
11541
|
+
chooseAlternate,
|
|
11392
11542
|
coerceTypedAnswer,
|
|
11393
11543
|
coerceTypedAnswers,
|
|
11394
11544
|
coercionLabel,
|
|
@@ -11543,6 +11693,7 @@ export {
|
|
|
11543
11693
|
stableFilterKey,
|
|
11544
11694
|
staleWriteDetail,
|
|
11545
11695
|
statusGroupOf,
|
|
11696
|
+
storeDoors,
|
|
11546
11697
|
supabaseDataSource,
|
|
11547
11698
|
tableIdOf,
|
|
11548
11699
|
tableJsonSchema,
|