@ai-matrx/records 0.80.2 → 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 +29 -0
- package/README.md +19 -0
- package/dist/app-table/index.cjs +100 -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 +100 -23
- package/dist/app-table/index.js.map +1 -1
- package/dist/{client-DKKRZKNw.d.ts → client-D1LTezMZ.d.ts} +10 -5
- package/dist/{client-BfNJEpar.d.cts → client-DLIKeBWF.d.cts} +10 -5
- package/dist/core/index.cjs +115 -31
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +22 -12
- package/dist/core/index.d.ts +22 -12
- package/dist/core/index.js +115 -31
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +100 -23
- package/dist/data/index.cjs.map +1 -1
- package/dist/data/index.d.cts +7 -7
- package/dist/data/index.d.ts +7 -7
- package/dist/data/index.js +100 -23
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-CzLMdOSy.d.cts → declareTable-02uao-5n.d.cts} +4 -4
- package/dist/{declareTable-Cg522Sk0.d.ts → declareTable-C5FlIS0z.d.ts} +4 -4
- package/dist/{field-DJAvDExi.d.ts → field-BIJiFPc0.d.ts} +1 -1
- package/dist/{field-DCXU6k9i.d.cts → field-snQG2jMq.d.cts} +1 -1
- package/dist/index.cjs +12 -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 +12 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.cjs +5 -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 +5 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/{ports-Kpc-RihV.d.ts → ports-Y5gLbCXe.d.ts} +1 -1
- package/dist/{ports-DaHUjVg7.d.cts → ports-y1QNfM80.d.cts} +1 -1
- package/dist/react/index.cjs +107 -27
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +31 -1
- package/dist/react/index.d.ts +31 -1
- package/dist/react/index.js +107 -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-DCaOJbhA.d.cts → record-1yDCn169.d.cts} +26 -1
- package/dist/{record-DCaOJbhA.d.ts → record-1yDCn169.d.ts} +26 -1
- package/dist/{subscription-C_hNjbaR.d.cts → subscription-B_WaT-kr.d.cts} +1 -1
- package/dist/{subscription-B9znK2dw.d.ts → subscription-CUok1vAm.d.ts} +1 -1
- package/dist/{table-kind-B9RBUmSb.d.ts → table-kind-COmkYYkc.d.ts} +3 -3
- package/dist/{table-kind-DXktQGzR.d.cts → table-kind-LodkBhCZ.d.cts} +3 -3
- package/dist/templates/index.cjs +70 -6
- package/dist/templates/index.cjs.map +1 -1
- package/dist/templates/index.d.cts +26 -10
- package/dist/templates/index.d.ts +26 -10
- package/dist/templates/index.js +70 -6
- package/dist/templates/index.js.map +1 -1
- package/dist/{types-DuyBN2im.d.cts → types-BJGTxu3Y.d.cts} +2 -2
- package/dist/{types-b-VGi15H.d.ts → types-C5-AaPa6.d.ts} +2 -2
- package/dist/{types-CHEFgCu1.d.ts → types-CU_Tn2Np.d.ts} +2 -2
- package/dist/{types-CD2HoaZt.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-CubFFxpu.d.cts → validate-CE6qpJIb.d.cts} +1 -1
- package/dist/{validate-BEfYwBpA.d.ts → validate-Rz9djP6H.d.ts} +1 -1
- package/package.json +1 -1
package/dist/templates/index.cjs
CHANGED
|
@@ -134,6 +134,7 @@ __export(templates_exports, {
|
|
|
134
134
|
rowsFor: () => rowsFor,
|
|
135
135
|
ruleBreak: () => ruleBreak,
|
|
136
136
|
runTemplateDoor: () => runTemplateDoor,
|
|
137
|
+
safeReuses: () => safeReuses,
|
|
137
138
|
sameMeaning: () => sameMeaning,
|
|
138
139
|
selfDeclaredFieldSpec: () => selfDeclaredFieldSpec,
|
|
139
140
|
sensitivityFloorOf: () => sensitivityFloorOf,
|
|
@@ -1065,21 +1066,25 @@ var STORE_DOORS = [
|
|
|
1065
1066
|
{ name: "form_declare", args: "p_organization_id uuid, p_table_id uuid, p_title text, p_questions jsonb, p_presentation jsonb DEFAULT '{}'::jsonb, p_submission_cap integer DEFAULT NULL::integer, p_quarantine_rule_id uuid DEFAULT NULL::uuid, p_notify_rule_id uuid DEFAULT NULL::uuid, p_form_id uuid DEFAULT NULL::uuid, p_slug text DEFAULT NULL::text", returns: "uuid", security: "definer" },
|
|
1066
1067
|
{ name: "form_draft_read", args: "p_form_id uuid, p_secret text", returns: "TABLE(answers jsonb, saved_at timestamp with time zone, expires_at timestamp with time zone, state text, message text)", security: "definer" },
|
|
1067
1068
|
{ name: "form_draft_save", args: "p_form_id uuid, p_answers jsonb, p_secret text DEFAULT NULL::text, p_bucket text DEFAULT NULL::text, p_origin text DEFAULT NULL::text", returns: "TABLE(draft_secret text, saved_at timestamp with time zone, expires_at timestamp with time zone, state text, message text)", security: "definer" },
|
|
1069
|
+
{ name: "form_knobs", args: "p_organization_id uuid", returns: "jsonb", security: "definer" },
|
|
1068
1070
|
{ name: "form_look_options", args: "p_organization_id uuid, p_presentation jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "definer" },
|
|
1069
1071
|
{ name: "form_notify", args: "p_organization_id uuid, p_form_id uuid, p_record_id uuid, p_submission_id uuid", returns: "uuid", security: "invoker" },
|
|
1070
1072
|
{ name: "form_preview_asks", args: "p_organization_id uuid, p_table_id uuid, p_questions jsonb, p_values jsonb", returns: "TABLE(field_key text, asked boolean, decided boolean, said text)", security: "definer" },
|
|
1071
1073
|
{ name: "form_preview_route", args: "p_organization_id uuid, p_table_id uuid, p_questions jsonb, p_endings jsonb, p_values jsonb", returns: "jsonb", security: "definer" },
|
|
1072
1074
|
{ name: "form_public", args: "p_form_id uuid", returns: "TABLE(form_id uuid, organization_id uuid, table_id uuid, title text, presentation jsonb, fields jsonb, honeypot_key text, state text, message text)", security: "definer" },
|
|
1073
1075
|
{ name: "form_public_asks", args: "p_form_id uuid, p_values jsonb, p_secret text DEFAULT NULL::text, p_origin text DEFAULT NULL::text", returns: "TABLE(field_key text, asked boolean, decided boolean, said text)", security: "definer" },
|
|
1076
|
+
{ name: "form_public_options", args: "p_form_id uuid", returns: "jsonb", security: "definer" },
|
|
1074
1077
|
{ name: "form_public_route", args: "p_form_id uuid, p_values jsonb", returns: "jsonb", security: "definer" },
|
|
1075
1078
|
{ name: "form_redirect_domains", args: "p_organization_id uuid", returns: "text[]", security: "invoker" },
|
|
1076
1079
|
{ name: "form_redirect_refusal", args: "p_organization_id uuid, p_url text", returns: "text", security: "invoker" },
|
|
1080
|
+
{ name: "form_respondent_copy", args: "p_organization_id uuid, p_form_id uuid, p_record_id uuid, p_submission_id uuid", returns: "jsonb", security: "definer" },
|
|
1077
1081
|
{ name: "form_restore", args: "p_organization_id uuid, p_form_id uuid", returns: "jsonb", security: "definer" },
|
|
1078
1082
|
{ name: "form_results", args: "p_organization_id uuid, p_form_id uuid", returns: "jsonb", security: "definer" },
|
|
1079
1083
|
{ name: "form_slug", args: "p_organization_id uuid, p_title text, p_form_id uuid DEFAULT NULL::uuid", returns: "text", security: "invoker" },
|
|
1080
1084
|
{ name: "form_submit", args: "p_form_id uuid, p_origin text, p_payload jsonb, p_bucket text, p_honeypot text DEFAULT NULL::text, p_client_key text DEFAULT NULL::text", returns: "TABLE(submission_id uuid, record_id uuid, state text, message text)", security: "definer" },
|
|
1081
1085
|
{ name: "form_theme_options", args: "", returns: "jsonb", security: "invoker" },
|
|
1082
1086
|
{ name: "form_visit", args: "p_form_id uuid, p_visit text, p_event text, p_field text DEFAULT NULL::text", returns: "text", security: "definer" },
|
|
1087
|
+
{ name: "form_visit_admit", args: "p_form_id uuid, p_bucket text", returns: "boolean", security: "definer" },
|
|
1083
1088
|
{ name: "forms", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(form_id uuid, table_id uuid, title text, slug text, published_at timestamp with time zone, closed_at timestamp with time zone, submission_cap integer, responses bigint, in_table bigint, held bigint, rejected bigint, state text, quarantine_rule_id uuid, notify_rule_id uuid, presentation jsonb)", security: "definer" },
|
|
1084
1089
|
{ name: "forms_archived", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_limit integer DEFAULT 100", returns: "TABLE(form_id uuid, table_id uuid, table_name text, kind text, title text, slug text, archived_at timestamp with time zone, archived_by uuid, table_archived boolean, can_restore boolean)", security: "definer" },
|
|
1085
1090
|
{ name: "formula_compile_sql", args: "p_organization_id uuid, p_expr jsonb, p_values_sql text", returns: "text", security: "invoker" },
|
|
@@ -1347,6 +1352,7 @@ var STORE_DOORS = [
|
|
|
1347
1352
|
{ name: "record_filter_sql", args: "p_organization_id uuid, p_table_id uuid, p_filter jsonb", returns: "text", security: "invoker" },
|
|
1348
1353
|
{ 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" },
|
|
1349
1354
|
{ 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" },
|
|
1355
|
+
{ name: "record_page_bundle", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
|
|
1350
1356
|
{ name: "record_platform_keys", args: "", returns: "text[]", security: "invoker" },
|
|
1351
1357
|
{ 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" },
|
|
1352
1358
|
{ name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
|
|
@@ -3611,7 +3617,7 @@ var THING_NAME = /^(section|class|course|period|room|bay|item|job|role|team|pool
|
|
|
3611
3617
|
var FILE_VALUE_RE = /^@file:([A-Za-z0-9_.-]+)$/;
|
|
3612
3618
|
function attachmentProblems(raw, assets) {
|
|
3613
3619
|
const out = [];
|
|
3614
|
-
const say = (at, says) => out.push({ at, says });
|
|
3620
|
+
const say = (at, says) => void out.push({ at, says });
|
|
3615
3621
|
const listed = raw.attachments ?? [];
|
|
3616
3622
|
if (raw.attachments !== void 0 && !Array.isArray(raw.attachments)) {
|
|
3617
3623
|
say("attachments", "attachments is a list of pictures from templates/ASSETS.json.");
|
|
@@ -3669,7 +3675,7 @@ function attachmentProblems(raw, assets) {
|
|
|
3669
3675
|
}
|
|
3670
3676
|
function validateTemplate(raw, options = {}) {
|
|
3671
3677
|
const problems = [];
|
|
3672
|
-
const say = (at, says) => problems.push({ at, says });
|
|
3678
|
+
const say = (at, says) => void problems.push({ at, says });
|
|
3673
3679
|
const seedLooks = /* @__PURE__ */ new WeakSet();
|
|
3674
3680
|
const saySeed = (at, says) => {
|
|
3675
3681
|
const p = { at, says };
|
|
@@ -6709,13 +6715,13 @@ function viewHolds(v, tables) {
|
|
|
6709
6715
|
return typeof v.token === "string" && !!v.token && typeof v.name === "string" && !!v.name;
|
|
6710
6716
|
}
|
|
6711
6717
|
function fallbackView(t) {
|
|
6712
|
-
const
|
|
6718
|
+
const plural2 = typeof t.name === "string" ? t.name : labelOfKey(t.token);
|
|
6713
6719
|
const stage = t.fields.find((f) => STAGE_KEY.test(f.key) && CHOICE.includes(f.parityType));
|
|
6714
|
-
if (stage) return { token: `${t.token}_board`, name: `${
|
|
6720
|
+
if (stage) return { token: `${t.token}_board`, name: `${plural2} board`, table: t.token, kind: "kanban", groupBy: stage.key, isDefault: true };
|
|
6715
6721
|
if (t.fields.some((f) => f.key === "slot" && f.parityType === "datetime")) {
|
|
6716
|
-
return { token: `${t.token}_calendar`, name: `${
|
|
6722
|
+
return { token: `${t.token}_calendar`, name: `${plural2} calendar`, table: t.token, kind: "calendar", dateField: "slot", isDefault: true };
|
|
6717
6723
|
}
|
|
6718
|
-
return { token: `${t.token}_list`, name: `All ${
|
|
6724
|
+
return { token: `${t.token}_list`, name: `All ${plural2.toLowerCase()}`, table: t.token, kind: "grid", isDefault: true, sorts: [{ field: String(t.titleField), direction: "asc" }] };
|
|
6719
6725
|
}
|
|
6720
6726
|
function mergeViews(plan, part, tables) {
|
|
6721
6727
|
const given = Array.isArray(part?.views) ? part.views : [];
|
|
@@ -7375,4 +7381,62 @@ function describeVocabulary() {
|
|
|
7375
7381
|
title_field: "a table's titleField is the key of a plain text-like field of that same table (a name, a title) \u2014 never a link to another table, a formula or a timed date"
|
|
7376
7382
|
};
|
|
7377
7383
|
}
|
|
7384
|
+
|
|
7385
|
+
// src/templates/describe/safe-reuse.ts
|
|
7386
|
+
var norm2 = (s) => String(s ?? "").trim().toLowerCase().replace(/[\s_-]+/g, " ");
|
|
7387
|
+
var nameKey = (s) => norm2(s).replace(/ies$/, "y").replace(/s$/, "");
|
|
7388
|
+
var sameChoices = (a, b) => {
|
|
7389
|
+
const x = Array.isArray(a) ? a.map(String).sort() : [];
|
|
7390
|
+
const y = Array.isArray(b) ? b.map(String).sort() : [];
|
|
7391
|
+
return x.length === y.length && x.every((v, i) => v === y[i]);
|
|
7392
|
+
};
|
|
7393
|
+
function changeOf(declared, existing) {
|
|
7394
|
+
for (const f of declared) {
|
|
7395
|
+
const match = existing.fields.find((e) => e.key === f.key) ?? existing.fields.find((e) => norm2(e.label) === norm2(f.label));
|
|
7396
|
+
if (!match) return `adds the field "${f.label ?? f.key}"`;
|
|
7397
|
+
if (match.key !== f.key) return `renames "${match.label}"`;
|
|
7398
|
+
if (norm2(match.label) !== norm2(f.label)) return `renames "${match.label}"`;
|
|
7399
|
+
if (f.parityType && norm2(match.kind) !== norm2(f.parityType)) return `changes the kind of "${match.label}"`;
|
|
7400
|
+
if (match.choices || f.choices) {
|
|
7401
|
+
if (!sameChoices(match.choices, f.choices)) return `changes the choices of "${match.label}"`;
|
|
7402
|
+
}
|
|
7403
|
+
}
|
|
7404
|
+
return null;
|
|
7405
|
+
}
|
|
7406
|
+
function plural(s) {
|
|
7407
|
+
return /[^aeiou]y$/i.test(s) ? s.replace(/y$/i, "ies") : /s$/i.test(s) ? s : `${s}s`;
|
|
7408
|
+
}
|
|
7409
|
+
function safeReuses(spec, reuses, existingTables) {
|
|
7410
|
+
const byId = new Map(existingTables.map((t) => [t.id, t]));
|
|
7411
|
+
const taken = /* @__PURE__ */ new Set([...existingTables.map((t) => nameKey(t.name)), ...(spec.tables ?? []).map((t) => nameKey(t.name))]);
|
|
7412
|
+
const kept = [];
|
|
7413
|
+
const notes = [];
|
|
7414
|
+
const converted = [];
|
|
7415
|
+
const rename = /* @__PURE__ */ new Map();
|
|
7416
|
+
for (const r of reuses) {
|
|
7417
|
+
const existing = byId.get(r.existing_table_id);
|
|
7418
|
+
const table = (spec.tables ?? []).find((t2) => t2.token === r.token);
|
|
7419
|
+
if (!existing || !table) {
|
|
7420
|
+
kept.push(r);
|
|
7421
|
+
continue;
|
|
7422
|
+
}
|
|
7423
|
+
const why = changeOf(table.fields ?? [], existing);
|
|
7424
|
+
if (!why) {
|
|
7425
|
+
kept.push(r);
|
|
7426
|
+
continue;
|
|
7427
|
+
}
|
|
7428
|
+
const t = table;
|
|
7429
|
+
const candidates = [t.labelPlural, t.labelSingular && plural(t.labelSingular)].filter((c) => !!c);
|
|
7430
|
+
const free = candidates.find((c) => !taken.has(nameKey(c)));
|
|
7431
|
+
let name = free ?? `${existing.name} (new)`;
|
|
7432
|
+
for (let n = 2; taken.has(nameKey(name)); n++) name = `${existing.name} (new ${n})`;
|
|
7433
|
+
taken.add(nameKey(name));
|
|
7434
|
+
rename.set(r.token, { name, labelPlural: name });
|
|
7435
|
+
converted.push({ token: r.token, existingName: existing.name, newName: name, why });
|
|
7436
|
+
notes.push(`Built a new ${name} table instead of changing your existing ${existing.name}.`);
|
|
7437
|
+
}
|
|
7438
|
+
if (!rename.size) return { spec, reuses: kept, notes, converted };
|
|
7439
|
+
const out = { ...spec, tables: spec.tables.map((t) => rename.has(t.token) ? { ...t, ...rename.get(t.token) } : t) };
|
|
7440
|
+
return { spec: out, reuses: kept, notes, converted };
|
|
7441
|
+
}
|
|
7378
7442
|
//# sourceMappingURL=index.cjs.map
|