@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.cjs
CHANGED
|
@@ -103,6 +103,7 @@ __export(core_exports, {
|
|
|
103
103
|
STORE_DOORS: () => STORE_DOORS,
|
|
104
104
|
STORE_KNOBS: () => STORE_KNOBS,
|
|
105
105
|
STORE_REFUSAL_CODES: () => STORE_REFUSAL_CODES,
|
|
106
|
+
STORE_SCHEMA: () => STORE_SCHEMA,
|
|
106
107
|
SYSTEM_WRITER_WORDS: () => SYSTEM_WRITER_WORDS,
|
|
107
108
|
TABLE_DISPLAYS: () => TABLE_DISPLAYS,
|
|
108
109
|
TABLE_KIND_PREFIX: () => TABLE_KIND_PREFIX,
|
|
@@ -118,6 +119,7 @@ __export(core_exports, {
|
|
|
118
119
|
addressMapUrl: () => addressMapUrl,
|
|
119
120
|
addressText: () => addressText,
|
|
120
121
|
allowsOtherValues: () => allowsOtherValues,
|
|
122
|
+
alternatePatch: () => alternatePatch,
|
|
121
123
|
announceRecordChanged: () => announceRecordChanged,
|
|
122
124
|
announceTableStructureChanged: () => announceTableStructureChanged,
|
|
123
125
|
archivedByLine: () => archivedByLine,
|
|
@@ -142,6 +144,7 @@ __export(core_exports, {
|
|
|
142
144
|
choiceSlug: () => choiceSlug,
|
|
143
145
|
choiceValuesOf: () => choiceValuesOf,
|
|
144
146
|
choicesOf: () => choicesOf,
|
|
147
|
+
chooseAlternate: () => chooseAlternate,
|
|
145
148
|
coerceTypedAnswer: () => coerceTypedAnswer,
|
|
146
149
|
coerceTypedAnswers: () => coerceTypedAnswers,
|
|
147
150
|
coercionLabel: () => coercionLabel,
|
|
@@ -296,6 +299,7 @@ __export(core_exports, {
|
|
|
296
299
|
stableFilterKey: () => stableFilterKey,
|
|
297
300
|
staleWriteDetail: () => staleWriteDetail,
|
|
298
301
|
statusGroupOf: () => statusGroupOf,
|
|
302
|
+
storeDoors: () => storeDoors,
|
|
299
303
|
supabaseDataSource: () => supabaseDataSource,
|
|
300
304
|
tableIdOf: () => tableIdOf,
|
|
301
305
|
tableJsonSchema: () => tableJsonSchema,
|
|
@@ -5455,6 +5459,49 @@ function tableRenderSchema(facts) {
|
|
|
5455
5459
|
return { kind: slug, fields: out };
|
|
5456
5460
|
}
|
|
5457
5461
|
|
|
5462
|
+
// src/alternates.ts
|
|
5463
|
+
function refuse(code, message, hint) {
|
|
5464
|
+
return { ok: false, error: { code, message, hint, ours: true } };
|
|
5465
|
+
}
|
|
5466
|
+
function alternatePatch(document, field_key, alternate_index) {
|
|
5467
|
+
const block = document._values ?? {};
|
|
5468
|
+
const envelope = block[field_key];
|
|
5469
|
+
const alternates = Array.isArray(envelope?.alternates) ? envelope.alternates : [];
|
|
5470
|
+
const chosen = alternates[alternate_index];
|
|
5471
|
+
if (!envelope || !chosen) return { ok: false, message: "That other value is no longer on this record." };
|
|
5472
|
+
const kept = alternates.filter((_, i) => i !== alternate_index);
|
|
5473
|
+
const current = document[field_key];
|
|
5474
|
+
const next = [...kept];
|
|
5475
|
+
if (current !== null && current !== void 0) {
|
|
5476
|
+
const taken = new Set(kept.map((a) => a.rank));
|
|
5477
|
+
let rank = 1;
|
|
5478
|
+
while (taken.has(rank)) rank += 1;
|
|
5479
|
+
next.push({ value: current, ...envelope.src ? { src: envelope.src } : {}, rank });
|
|
5480
|
+
}
|
|
5481
|
+
const { ver: _ver, actor: _actor, at: _at, on_behalf_of: _on, absent: _absent, alternates: _alts, src: _src, ...rest } = envelope;
|
|
5482
|
+
const changed = { ...rest, ...chosen.src ? { src: chosen.src } : {} };
|
|
5483
|
+
if (next.length > 0) changed["alternates"] = next;
|
|
5484
|
+
return {
|
|
5485
|
+
ok: true,
|
|
5486
|
+
patch: {
|
|
5487
|
+
[field_key]: chosen.value,
|
|
5488
|
+
// THE WHOLE BLOCK — every other field's envelope and alternates travel with it.
|
|
5489
|
+
_values: { ...block, [field_key]: changed }
|
|
5490
|
+
}
|
|
5491
|
+
};
|
|
5492
|
+
}
|
|
5493
|
+
async function chooseAlternate(client, { record_id, field_key, alternate_index }) {
|
|
5494
|
+
const read = await client.recordRead({ record_id, withVersion: true });
|
|
5495
|
+
if (!read.ok) return read;
|
|
5496
|
+
const version = read.data.version;
|
|
5497
|
+
if (version === null || version === void 0) {
|
|
5498
|
+
return refuse("stale_read", "Nothing was saved: this record's latest changes could not be checked.", "Reload, then try again.");
|
|
5499
|
+
}
|
|
5500
|
+
const built = alternatePatch(read.data.document, field_key, alternate_index);
|
|
5501
|
+
if (!built.ok) return refuse("not_found", built.message, "Reload, then look again.");
|
|
5502
|
+
return client.recordUpdate({ record_id, patch: built.patch, expectedVersion: version });
|
|
5503
|
+
}
|
|
5504
|
+
|
|
5458
5505
|
// src/core/primedBundle.ts
|
|
5459
5506
|
var PRIMED_TTL_MS = 15e3;
|
|
5460
5507
|
var REGISTRY = /* @__PURE__ */ Symbol.for("@ai-matrx/records/primed-table-page-bundles");
|
|
@@ -6489,6 +6536,14 @@ var DOORS = {
|
|
|
6489
6536
|
// archived and aliased), and put any recorded Migration back.
|
|
6490
6537
|
migrateMerge: "migrate_merge",
|
|
6491
6538
|
migrateUndo: "migrate_undo",
|
|
6539
|
+
// CORE-VISION (2026-10-10): the structural Migrations a person runs on ONE record from its menu.
|
|
6540
|
+
// Split moves the named values to a new record of the same Table (the original keeps its id);
|
|
6541
|
+
// extract parent copies the named values up into a new record of another Table and puts this
|
|
6542
|
+
// record under it. Both answer a `migration_id` that `migrateUndo` takes. `migrations` lists
|
|
6543
|
+
// the Migration log for one target, newest first.
|
|
6544
|
+
migrateSplit: "migrate_split",
|
|
6545
|
+
migrateExtractParent: "migrate_extract_parent",
|
|
6546
|
+
migrations: "migrations",
|
|
6492
6547
|
recordValues: "record_values",
|
|
6493
6548
|
recordValuesVersioned: "record_values_versioned",
|
|
6494
6549
|
valueRead: "value_read",
|
|
@@ -7043,7 +7098,7 @@ function doorCensus() {
|
|
|
7043
7098
|
}
|
|
7044
7099
|
|
|
7045
7100
|
// src/core/supabase.ts
|
|
7046
|
-
function
|
|
7101
|
+
function refuse2(code, message, hint) {
|
|
7047
7102
|
return { data: null, error: { code, message, hint, details: "" } };
|
|
7048
7103
|
}
|
|
7049
7104
|
function supabaseDataSource(client) {
|
|
@@ -7056,7 +7111,7 @@ function supabaseDataSource(client) {
|
|
|
7056
7111
|
rpc(fn, args, options) {
|
|
7057
7112
|
if (!hasSchema) {
|
|
7058
7113
|
return Promise.resolve(
|
|
7059
|
-
|
|
7114
|
+
refuse2(
|
|
7060
7115
|
"data_source_unbound",
|
|
7061
7116
|
`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.`,
|
|
7062
7117
|
"Pass a supabase-js v2 client (createClient(...)) to supabaseDataSource()."
|
|
@@ -7066,7 +7121,7 @@ function supabaseDataSource(client) {
|
|
|
7066
7121
|
const name = options?.schema;
|
|
7067
7122
|
if (!name) {
|
|
7068
7123
|
return Promise.resolve(
|
|
7069
|
-
|
|
7124
|
+
refuse2(
|
|
7070
7125
|
"schema_unsaid",
|
|
7071
7126
|
`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.`,
|
|
7072
7127
|
"This is a bug in the caller, not in your data: /core says the schema on every call."
|
|
@@ -8417,6 +8472,49 @@ function createRecordsClient(given) {
|
|
|
8417
8472
|
}
|
|
8418
8473
|
return result;
|
|
8419
8474
|
},
|
|
8475
|
+
async migrateSplit({ record_id, moved_keys, note }) {
|
|
8476
|
+
const result = await callDoor(
|
|
8477
|
+
DOORS.migrateSplit,
|
|
8478
|
+
{ p_organization_id: org, p_record_id: record_id, p_moved_keys: moved_keys, p_note: note ?? null },
|
|
8479
|
+
"migrateSplit"
|
|
8480
|
+
);
|
|
8481
|
+
if (result.ok) {
|
|
8482
|
+
announceRecordChanged(record_id);
|
|
8483
|
+
announceRecordChanged(result.data.new_record);
|
|
8484
|
+
}
|
|
8485
|
+
return result;
|
|
8486
|
+
},
|
|
8487
|
+
async migrateExtractParent({ record_id, parent_table_id, moved_keys, note }) {
|
|
8488
|
+
const result = await callDoor(
|
|
8489
|
+
DOORS.migrateExtractParent,
|
|
8490
|
+
{ p_organization_id: org, p_id: record_id, p_parent_table_id: parent_table_id, p_moved_keys: moved_keys, p_note: note ?? null },
|
|
8491
|
+
"migrateExtractParent"
|
|
8492
|
+
);
|
|
8493
|
+
if (result.ok) {
|
|
8494
|
+
announceRecordChanged(record_id);
|
|
8495
|
+
announceRecordChanged(result.data.parent);
|
|
8496
|
+
}
|
|
8497
|
+
return result;
|
|
8498
|
+
},
|
|
8499
|
+
async migrations({ target_id, limit }) {
|
|
8500
|
+
return callDoor(
|
|
8501
|
+
DOORS.migrations,
|
|
8502
|
+
{ p_organization_id: org, p_target_id: target_id ?? null, p_limit: limit ?? 100 },
|
|
8503
|
+
"migrations"
|
|
8504
|
+
);
|
|
8505
|
+
},
|
|
8506
|
+
async recordAsOf({ record_id, recorded_at, world_on }) {
|
|
8507
|
+
return callDoor(
|
|
8508
|
+
DOORS.queryRecordAsOf,
|
|
8509
|
+
{
|
|
8510
|
+
p_organization_id: org,
|
|
8511
|
+
p_record_id: record_id,
|
|
8512
|
+
...recorded_at ? { p_recorded_at: recorded_at } : {},
|
|
8513
|
+
...world_on ? { p_world_on: world_on.slice(0, 10) } : {}
|
|
8514
|
+
},
|
|
8515
|
+
"recordAsOf"
|
|
8516
|
+
);
|
|
8517
|
+
},
|
|
8420
8518
|
async migrateUndo({ migration_id }) {
|
|
8421
8519
|
const result = await callDoor(
|
|
8422
8520
|
DOORS.migrateUndo,
|
|
@@ -8424,6 +8522,7 @@ function createRecordsClient(given) {
|
|
|
8424
8522
|
"migrateUndo"
|
|
8425
8523
|
);
|
|
8426
8524
|
if (result.ok && result.data.record_id) announceRecordChanged(result.data.record_id);
|
|
8525
|
+
if (result.ok && result.data.removed) announceRecordChanged(result.data.removed);
|
|
8427
8526
|
return result;
|
|
8428
8527
|
},
|
|
8429
8528
|
async fieldUpdate({ field_id, patch }) {
|
|
@@ -11059,6 +11158,58 @@ function blockLandedInStore(outcomes, block) {
|
|
|
11059
11158
|
return false;
|
|
11060
11159
|
}
|
|
11061
11160
|
|
|
11161
|
+
// src/core/storeDoors.ts
|
|
11162
|
+
var STORE_SCHEMA = "custom";
|
|
11163
|
+
function storeDoors(client) {
|
|
11164
|
+
const source = supabaseDataSource(client ?? {});
|
|
11165
|
+
const call = (fn, args = {}) => source.rpc(fn, args, { schema: STORE_SCHEMA });
|
|
11166
|
+
const typed = (fn, args) => call(fn, args);
|
|
11167
|
+
return {
|
|
11168
|
+
rpc: call,
|
|
11169
|
+
async whereIdOpens(id) {
|
|
11170
|
+
const raw = await call("where_id_opens", { p_id: id });
|
|
11171
|
+
const e = raw.error;
|
|
11172
|
+
return {
|
|
11173
|
+
data: raw.data ?? null,
|
|
11174
|
+
error: e ? { code: typeof e.code === "string" ? e.code : null, message: typeof e.message === "string" ? e.message : "The record store refused." } : null
|
|
11175
|
+
};
|
|
11176
|
+
},
|
|
11177
|
+
tableKernelId: () => typed("table_kernel_id", {}),
|
|
11178
|
+
readRecordsByIds: (organizationId, tableId, ids) => typed("read_records_by_ids", { p_organization_id: organizationId, p_table_id: tableId, p_record_ids: ids }),
|
|
11179
|
+
readRecordsPage: (args) => typed("read_records_page", args),
|
|
11180
|
+
recordTable: (organizationId, recordId) => typed("record_table", { p_organization_id: organizationId, p_record_id: recordId }),
|
|
11181
|
+
applicableFields: (organizationId, tableId) => typed("applicable_fields", { p_organization_id: organizationId, p_table_id: tableId }),
|
|
11182
|
+
fieldDeclare: (organizationId, tableId, spec) => typed("field_declare", { p_organization_id: organizationId, p_table_id: tableId, p_spec: spec }),
|
|
11183
|
+
recordUpdate: (organizationId, recordId, patch) => typed("record_update", { p_organization_id: organizationId, p_record_id: recordId, p_patch: patch }),
|
|
11184
|
+
entityReferenceWords: (organizationId, refs) => typed("entity_reference_words", { p_organization_id: organizationId, p_refs: refs.map((r) => ({ token: r.token, id: r.id })) }),
|
|
11185
|
+
templates: (filter) => typed("templates", { p_filter: filter }),
|
|
11186
|
+
templateFromTables: ({ organizationId, tableIds, includeRows, rowsPerTable }) => typed("template_from_tables", {
|
|
11187
|
+
p_organization_id: organizationId,
|
|
11188
|
+
p_table_ids: tableIds,
|
|
11189
|
+
p_include_rows: includeRows,
|
|
11190
|
+
p_rows_per_table: rowsPerTable
|
|
11191
|
+
}),
|
|
11192
|
+
templateDeclare: (scope, spec) => typed("template_declare", { p_scope: scope, p_spec: spec }),
|
|
11193
|
+
templateKeep: (templateId) => typed("template_keep", { p_template_id: templateId }),
|
|
11194
|
+
templateArchive: (templateId, restore) => typed("template_archive", restore === void 0 ? { p_template_id: templateId } : { p_template_id: templateId, p_restore: restore }),
|
|
11195
|
+
templateInstallClaim: ({ organizationId, installId, kind, label, sourceId, leaseSeconds }) => typed("template_install_claim", {
|
|
11196
|
+
p_organization_id: organizationId,
|
|
11197
|
+
p_install_id: installId,
|
|
11198
|
+
p_kind: kind,
|
|
11199
|
+
p_label: label,
|
|
11200
|
+
...sourceId ? { p_source_id: sourceId } : {},
|
|
11201
|
+
p_lease_seconds: leaseSeconds
|
|
11202
|
+
}),
|
|
11203
|
+
templateInstallNote: ({ organizationId, installId, kind, id, label }) => typed("template_install_note", {
|
|
11204
|
+
p_organization_id: organizationId,
|
|
11205
|
+
p_install_id: installId,
|
|
11206
|
+
p_kind: kind,
|
|
11207
|
+
p_id: id,
|
|
11208
|
+
p_label: label
|
|
11209
|
+
})
|
|
11210
|
+
};
|
|
11211
|
+
}
|
|
11212
|
+
|
|
11062
11213
|
// src/core/validation.ts
|
|
11063
11214
|
var import_uuid7 = require("@ai-matrx/kit/uuid");
|
|
11064
11215
|
var DEFAULT_VALUE_MAX_BYTES = 1e5;
|