@ai-matrx/records 0.80.1 → 0.80.4
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 +17 -0
- package/dist/app-table/index.cjs +12 -0
- 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 +12 -0
- package/dist/app-table/index.js.map +1 -1
- package/dist/{client-BbLzOf08.d.ts → client-CB_Klj1P.d.ts} +10 -5
- package/dist/{client-GhSH0bR7.d.cts → client-D0yGEof4.d.cts} +10 -5
- package/dist/core/index.cjs +18 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +12 -11
- package/dist/core/index.d.ts +12 -11
- package/dist/core/index.js +18 -0
- package/dist/core/index.js.map +1 -1
- package/dist/data/index.cjs +12 -0
- 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 +12 -0
- package/dist/data/index.js.map +1 -1
- package/dist/{declareTable-D6mB7Va8.d.ts → declareTable-DoYVueVF.d.ts} +4 -4
- package/dist/{declareTable-Bb0eUtPF.d.cts → declareTable-l7ktxN6p.d.cts} +4 -4
- package/dist/{field-DJAvDExi.d.ts → field-6UtYgFeu.d.ts} +1 -1
- package/dist/{field-DCXU6k9i.d.cts → field-DpJR_5Pe.d.cts} +1 -1
- package/dist/index.cjs +10 -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 +10 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.cjs +4 -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 +4 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/{ports-DaHUjVg7.d.cts → ports-CE7umTp-.d.cts} +1 -1
- package/dist/{ports-Kpc-RihV.d.ts → ports-CiEYhwi5.d.ts} +1 -1
- package/dist/react/index.cjs +18 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +29 -2
- package/dist/react/index.d.ts +29 -2
- package/dist/react/index.js +18 -0
- 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-CvqV8wyO.d.cts} +21 -1
- package/dist/{record-DCaOJbhA.d.ts → record-CvqV8wyO.d.ts} +21 -1
- package/dist/{subscription-C_hNjbaR.d.cts → subscription-CC0kgkwa.d.cts} +1 -1
- package/dist/{subscription-B9znK2dw.d.ts → subscription-DjkuDMcX.d.ts} +1 -1
- package/dist/{table-kind-lHVdMZGy.d.ts → table-kind-DHpMEOHd.d.cts} +6 -4
- package/dist/{table-kind-DptSVo_4.d.cts → table-kind-FMYq3nCr.d.ts} +6 -4
- package/dist/templates/index.cjs +67 -4
- 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 +67 -4
- package/dist/templates/index.js.map +1 -1
- package/dist/{types-CHEFgCu1.d.ts → types-B4LF3sFx.d.ts} +2 -2
- package/dist/{types-b-VGi15H.d.ts → types-BbCZJh1C.d.ts} +2 -2
- package/dist/{types-DuyBN2im.d.cts → types-DuceX7js.d.cts} +2 -2
- package/dist/{types-CD2HoaZt.d.cts → types-Flsf_KU5.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-BEfYwBpA.d.ts → validate-DyVwSD74.d.ts} +1 -1
- package/dist/{validate-CubFFxpu.d.cts → validate-EvZGkD96.d.cts} +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" },
|
|
@@ -6709,13 +6714,13 @@ function viewHolds(v, tables) {
|
|
|
6709
6714
|
return typeof v.token === "string" && !!v.token && typeof v.name === "string" && !!v.name;
|
|
6710
6715
|
}
|
|
6711
6716
|
function fallbackView(t) {
|
|
6712
|
-
const
|
|
6717
|
+
const plural2 = typeof t.name === "string" ? t.name : labelOfKey(t.token);
|
|
6713
6718
|
const stage = t.fields.find((f) => STAGE_KEY.test(f.key) && CHOICE.includes(f.parityType));
|
|
6714
|
-
if (stage) return { token: `${t.token}_board`, name: `${
|
|
6719
|
+
if (stage) return { token: `${t.token}_board`, name: `${plural2} board`, table: t.token, kind: "kanban", groupBy: stage.key, isDefault: true };
|
|
6715
6720
|
if (t.fields.some((f) => f.key === "slot" && f.parityType === "datetime")) {
|
|
6716
|
-
return { token: `${t.token}_calendar`, name: `${
|
|
6721
|
+
return { token: `${t.token}_calendar`, name: `${plural2} calendar`, table: t.token, kind: "calendar", dateField: "slot", isDefault: true };
|
|
6717
6722
|
}
|
|
6718
|
-
return { token: `${t.token}_list`, name: `All ${
|
|
6723
|
+
return { token: `${t.token}_list`, name: `All ${plural2.toLowerCase()}`, table: t.token, kind: "grid", isDefault: true, sorts: [{ field: String(t.titleField), direction: "asc" }] };
|
|
6719
6724
|
}
|
|
6720
6725
|
function mergeViews(plan, part, tables) {
|
|
6721
6726
|
const given = Array.isArray(part?.views) ? part.views : [];
|
|
@@ -7375,4 +7380,62 @@ function describeVocabulary() {
|
|
|
7375
7380
|
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
7381
|
};
|
|
7377
7382
|
}
|
|
7383
|
+
|
|
7384
|
+
// src/templates/describe/safe-reuse.ts
|
|
7385
|
+
var norm2 = (s) => String(s ?? "").trim().toLowerCase().replace(/[\s_-]+/g, " ");
|
|
7386
|
+
var nameKey = (s) => norm2(s).replace(/ies$/, "y").replace(/s$/, "");
|
|
7387
|
+
var sameChoices = (a, b) => {
|
|
7388
|
+
const x = Array.isArray(a) ? a.map(String).sort() : [];
|
|
7389
|
+
const y = Array.isArray(b) ? b.map(String).sort() : [];
|
|
7390
|
+
return x.length === y.length && x.every((v, i) => v === y[i]);
|
|
7391
|
+
};
|
|
7392
|
+
function changeOf(declared, existing) {
|
|
7393
|
+
for (const f of declared) {
|
|
7394
|
+
const match = existing.fields.find((e) => e.key === f.key) ?? existing.fields.find((e) => norm2(e.label) === norm2(f.label));
|
|
7395
|
+
if (!match) return `adds the field "${f.label ?? f.key}"`;
|
|
7396
|
+
if (match.key !== f.key) return `renames "${match.label}"`;
|
|
7397
|
+
if (norm2(match.label) !== norm2(f.label)) return `renames "${match.label}"`;
|
|
7398
|
+
if (f.parityType && norm2(match.kind) !== norm2(f.parityType)) return `changes the kind of "${match.label}"`;
|
|
7399
|
+
if (match.choices || f.choices) {
|
|
7400
|
+
if (!sameChoices(match.choices, f.choices)) return `changes the choices of "${match.label}"`;
|
|
7401
|
+
}
|
|
7402
|
+
}
|
|
7403
|
+
return null;
|
|
7404
|
+
}
|
|
7405
|
+
function plural(s) {
|
|
7406
|
+
return /[^aeiou]y$/i.test(s) ? s.replace(/y$/i, "ies") : /s$/i.test(s) ? s : `${s}s`;
|
|
7407
|
+
}
|
|
7408
|
+
function safeReuses(spec, reuses, existingTables) {
|
|
7409
|
+
const byId = new Map(existingTables.map((t) => [t.id, t]));
|
|
7410
|
+
const taken = /* @__PURE__ */ new Set([...existingTables.map((t) => nameKey(t.name)), ...(spec.tables ?? []).map((t) => nameKey(t.name))]);
|
|
7411
|
+
const kept = [];
|
|
7412
|
+
const notes = [];
|
|
7413
|
+
const converted = [];
|
|
7414
|
+
const rename = /* @__PURE__ */ new Map();
|
|
7415
|
+
for (const r of reuses) {
|
|
7416
|
+
const existing = byId.get(r.existing_table_id);
|
|
7417
|
+
const table = (spec.tables ?? []).find((t2) => t2.token === r.token);
|
|
7418
|
+
if (!existing || !table) {
|
|
7419
|
+
kept.push(r);
|
|
7420
|
+
continue;
|
|
7421
|
+
}
|
|
7422
|
+
const why = changeOf(table.fields ?? [], existing);
|
|
7423
|
+
if (!why) {
|
|
7424
|
+
kept.push(r);
|
|
7425
|
+
continue;
|
|
7426
|
+
}
|
|
7427
|
+
const t = table;
|
|
7428
|
+
const candidates = [t.labelPlural, t.labelSingular && plural(t.labelSingular)].filter((c) => !!c);
|
|
7429
|
+
const free = candidates.find((c) => !taken.has(nameKey(c)));
|
|
7430
|
+
let name = free ?? `${existing.name} (new)`;
|
|
7431
|
+
for (let n = 2; taken.has(nameKey(name)); n++) name = `${existing.name} (new ${n})`;
|
|
7432
|
+
taken.add(nameKey(name));
|
|
7433
|
+
rename.set(r.token, { name, labelPlural: name });
|
|
7434
|
+
converted.push({ token: r.token, existingName: existing.name, newName: name, why });
|
|
7435
|
+
notes.push(`Built a new ${name} table instead of changing your existing ${existing.name}.`);
|
|
7436
|
+
}
|
|
7437
|
+
if (!rename.size) return { spec, reuses: kept, notes, converted };
|
|
7438
|
+
const out = { ...spec, tables: spec.tables.map((t) => rename.has(t.token) ? { ...t, ...rename.get(t.token) } : t) };
|
|
7439
|
+
return { spec: out, reuses: kept, notes, converted };
|
|
7440
|
+
}
|
|
7378
7441
|
//# sourceMappingURL=index.cjs.map
|