@ai-matrx/records 0.72.14 → 0.72.24

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/app-table/index.d.cts +3 -3
  3. package/dist/app-table/index.d.ts +3 -3
  4. package/dist/core/index.d.cts +5 -5
  5. package/dist/core/index.d.ts +5 -5
  6. package/dist/{declareTable-Br8pE4fr.d.cts → declareTable-CLvpMdgJ.d.cts} +2 -2
  7. package/dist/{declareTable-DM6z1tc-.d.ts → declareTable-DY3oN4rq.d.ts} +2 -2
  8. package/dist/index.d.cts +3 -3
  9. package/dist/index.d.ts +3 -3
  10. package/dist/memory/index.cjs +2912 -0
  11. package/dist/memory/index.cjs.map +1 -0
  12. package/dist/memory/index.d.cts +126 -0
  13. package/dist/memory/index.d.ts +126 -0
  14. package/dist/memory/index.js +2889 -0
  15. package/dist/memory/index.js.map +1 -0
  16. package/dist/{ports-DKBvsoya.d.cts → ports-DKOk7AT2.d.cts} +1 -1
  17. package/dist/{ports-Bhu2Q3V0.d.ts → ports-Df3VghxK.d.ts} +1 -1
  18. package/dist/{table-kind-D6Lz7ebE.d.ts → table-kind-CD9B1vtx.d.ts} +1 -1
  19. package/dist/{table-kind-D6VOew74.d.cts → table-kind-e-g5kGXV.d.cts} +1 -1
  20. package/dist/templates/index.cjs +44 -17
  21. package/dist/templates/index.cjs.map +1 -1
  22. package/dist/templates/index.d.cts +18 -1176
  23. package/dist/templates/index.d.ts +18 -1176
  24. package/dist/templates/index.js +44 -17
  25. package/dist/templates/index.js.map +1 -1
  26. package/dist/{validate-QtFxMmJc.d.ts → types-Ba11aOEO.d.ts} +1 -42
  27. package/dist/{validate-DUSrx-9E.d.cts → types-BtEKp3ot.d.cts} +1 -42
  28. package/dist/types-DxVoKKpL.d.ts +1186 -0
  29. package/dist/types-dlj1-2t2.d.cts +1186 -0
  30. package/dist/use-cases/index.d.cts +3 -2
  31. package/dist/use-cases/index.d.ts +3 -2
  32. package/dist/validate-CMb7R_ke.d.cts +44 -0
  33. package/dist/validate-E-g4LAZ6.d.ts +44 -0
  34. package/package.json +13 -1
@@ -1020,4 +1020,4 @@ interface RecordsConfig {
1020
1020
  knownDoors?: readonly string[];
1021
1021
  }
1022
1022
 
1023
- export { type SubscriptionBlock as $, type AggregateCompare as A, type BookingSummary as B, type DashboardTarget as C, type DashboardSummary as D, type DashboardTargetBase as E, type FormSummary as F, type DashboardTargetOp as G, type DashboardTargetResult as H, type DashboardTotals as I, type RecordsActor as J, type RecordsChangeSink as K, type RecordsErrorSink as L, type MySubscription as M, type RecordsFilter as N, type RecordsRealtimePort as O, type RecordsResolverPort as P, type QuietHours as Q, type RecordsConfig as R, type StoreFilter as S, type RecordsResponse as T, type RecordsTableQuery as U, type Rule as V, type RuleAnswer as W, type RuleExpression as X, type SavedViewColorBy as Y, type SavedViewDefinition as Z, type SavedViewLayout as _, type BookingAvailability as a, bookingPath as a0, callersTimeZone as a1, hasQuietHours as a2, isRuleFilter as a3, liftWithheld as a4, measureKey as a5, publicFormPath as a6, stableFilterKey as a7, withCallersClock as a8, type BookingDeclared as b, type DashboardBlock as c, type RecordFilter as d, type AggregateBucket as e, type DashboardRunResult as f, type StuckRow as g, type AggregateMeasure as h, type AggregateRow as i, type Subscription as j, type SubscriptionSpec as k, type DigestPreview as l, type SavedViewRow as m, type SavedViewSpecIn as n, type RowTemplateRow as o, type DashboardBlockKind as p, type AggregateFilter as q, type SubscriptionCadence as r, type AggregateOperation as s, type RecordsDataSource as t, type AggregateCompareKind as u, type AggregateCompareWindows as v, type AggregateDelta as w, type AggregateWindow as x, type BookingWindow as y, type DashboardBlockResult as z };
1023
+ export { type SubscriptionBlock as $, type AggregateOperation as A, type BookingSummary as B, type DashboardTarget as C, type DashboardBlockKind as D, type DashboardTargetBase as E, type FormSummary as F, type DashboardTargetOp as G, type DashboardTargetResult as H, type DashboardTotals as I, type RecordsActor as J, type RecordsChangeSink as K, type RecordsErrorSink as L, type MySubscription as M, type RecordsFilter as N, type RecordsRealtimePort as O, type RecordsResolverPort as P, type QuietHours as Q, type RecordsConfig as R, type SubscriptionCadence as S, type RecordsResponse as T, type RecordsTableQuery as U, type Rule as V, type RuleAnswer as W, type RuleExpression as X, type SavedViewColorBy as Y, type SavedViewDefinition as Z, type SavedViewLayout as _, type AggregateFilter as a, bookingPath as a0, callersTimeZone as a1, hasQuietHours as a2, isRuleFilter as a3, liftWithheld as a4, measureKey as a5, publicFormPath as a6, stableFilterKey as a7, withCallersClock as a8, type AggregateMeasure as b, type AggregateBucket as c, type StoreFilter as d, type BookingAvailability as e, type BookingDeclared as f, type DashboardSummary as g, type DashboardBlock as h, type RecordFilter as i, type AggregateCompare as j, type DashboardRunResult as k, type StuckRow as l, type AggregateRow as m, type Subscription as n, type SubscriptionSpec as o, type DigestPreview as p, type SavedViewRow as q, type SavedViewSpecIn as r, type RowTemplateRow as s, type RecordsDataSource as t, type AggregateCompareKind as u, type AggregateCompareWindows as v, type AggregateDelta as w, type AggregateWindow as x, type BookingWindow as y, type DashboardBlockResult as z };
@@ -1020,4 +1020,4 @@ interface RecordsConfig {
1020
1020
  knownDoors?: readonly string[];
1021
1021
  }
1022
1022
 
1023
- export { type SubscriptionBlock as $, type AggregateCompare as A, type BookingSummary as B, type DashboardTarget as C, type DashboardSummary as D, type DashboardTargetBase as E, type FormSummary as F, type DashboardTargetOp as G, type DashboardTargetResult as H, type DashboardTotals as I, type RecordsActor as J, type RecordsChangeSink as K, type RecordsErrorSink as L, type MySubscription as M, type RecordsFilter as N, type RecordsRealtimePort as O, type RecordsResolverPort as P, type QuietHours as Q, type RecordsConfig as R, type StoreFilter as S, type RecordsResponse as T, type RecordsTableQuery as U, type Rule as V, type RuleAnswer as W, type RuleExpression as X, type SavedViewColorBy as Y, type SavedViewDefinition as Z, type SavedViewLayout as _, type BookingAvailability as a, bookingPath as a0, callersTimeZone as a1, hasQuietHours as a2, isRuleFilter as a3, liftWithheld as a4, measureKey as a5, publicFormPath as a6, stableFilterKey as a7, withCallersClock as a8, type BookingDeclared as b, type DashboardBlock as c, type RecordFilter as d, type AggregateBucket as e, type DashboardRunResult as f, type StuckRow as g, type AggregateMeasure as h, type AggregateRow as i, type Subscription as j, type SubscriptionSpec as k, type DigestPreview as l, type SavedViewRow as m, type SavedViewSpecIn as n, type RowTemplateRow as o, type DashboardBlockKind as p, type AggregateFilter as q, type SubscriptionCadence as r, type AggregateOperation as s, type RecordsDataSource as t, type AggregateCompareKind as u, type AggregateCompareWindows as v, type AggregateDelta as w, type AggregateWindow as x, type BookingWindow as y, type DashboardBlockResult as z };
1023
+ export { type SubscriptionBlock as $, type AggregateOperation as A, type BookingSummary as B, type DashboardTarget as C, type DashboardBlockKind as D, type DashboardTargetBase as E, type FormSummary as F, type DashboardTargetOp as G, type DashboardTargetResult as H, type DashboardTotals as I, type RecordsActor as J, type RecordsChangeSink as K, type RecordsErrorSink as L, type MySubscription as M, type RecordsFilter as N, type RecordsRealtimePort as O, type RecordsResolverPort as P, type QuietHours as Q, type RecordsConfig as R, type SubscriptionCadence as S, type RecordsResponse as T, type RecordsTableQuery as U, type Rule as V, type RuleAnswer as W, type RuleExpression as X, type SavedViewColorBy as Y, type SavedViewDefinition as Z, type SavedViewLayout as _, type AggregateFilter as a, bookingPath as a0, callersTimeZone as a1, hasQuietHours as a2, isRuleFilter as a3, liftWithheld as a4, measureKey as a5, publicFormPath as a6, stableFilterKey as a7, withCallersClock as a8, type AggregateMeasure as b, type AggregateBucket as c, type StoreFilter as d, type BookingAvailability as e, type BookingDeclared as f, type DashboardSummary as g, type DashboardBlock as h, type RecordFilter as i, type AggregateCompare as j, type DashboardRunResult as k, type StuckRow as l, type AggregateRow as m, type Subscription as n, type SubscriptionSpec as o, type DigestPreview as p, type SavedViewRow as q, type SavedViewSpecIn as r, type RowTemplateRow as s, type RecordsDataSource as t, type AggregateCompareKind as u, type AggregateCompareWindows as v, type AggregateDelta as w, type AggregateWindow as x, type BookingWindow as y, type DashboardBlockResult as z };
@@ -1,5 +1,5 @@
1
1
  import { n as ReadRow, g as Timestamp, U as Uuid, h as RecordDocument, R as RelationFlavor, O as OnDelete, aK as RelationBinding, f as RelationCardinality, i as RecordsResult, r as StoredRecord, q as Field, az as ParityFieldType, T as TableType, a as TableDisplay, S as StorageMode, b0 as TableOrigin, z as RecordsError } from './field-CekLWOPw.js';
2
- import { t as RecordsDataSource } from './ports-Bhu2Q3V0.js';
2
+ import { t as RecordsDataSource } from './ports-Df3VghxK.js';
3
3
 
4
4
  /**
5
5
  * THE TWO LANES THE ARCHIVED-ITEMS LAW NAMES (Arman, 2026-09-09) — the same
@@ -1,5 +1,5 @@
1
1
  import { n as ReadRow, g as Timestamp, U as Uuid, h as RecordDocument, R as RelationFlavor, O as OnDelete, aK as RelationBinding, f as RelationCardinality, i as RecordsResult, r as StoredRecord, q as Field, az as ParityFieldType, T as TableType, a as TableDisplay, S as StorageMode, b0 as TableOrigin, z as RecordsError } from './field-CekLWOPw.cjs';
2
- import { t as RecordsDataSource } from './ports-DKBvsoya.cjs';
2
+ import { t as RecordsDataSource } from './ports-DKOk7AT2.cjs';
3
3
 
4
4
  /**
5
5
  * THE TWO LANES THE ARCHIVED-ITEMS LAW NAMES (Arman, 2026-09-09) — the same
@@ -37,6 +37,7 @@ __export(templates_exports, {
37
37
  RECORDS_UI_FIELD_SURFACES: () => RECORDS_UI_FIELD_SURFACES,
38
38
  RECORDS_UI_VIEW_LAYOUTS: () => RECORDS_UI_VIEW_LAYOUTS,
39
39
  RELATIVE_DATE: () => RELATIVE_DATE,
40
+ RESOLVABLE_FIELD_TYPE_WORDS: () => RESOLVABLE_FIELD_TYPE_WORDS,
40
41
  SERVER_DATE_GRAMMAR: () => SERVER_DATE_GRAMMAR,
41
42
  SHARED_BLOCKS: () => SHARED_BLOCKS,
42
43
  SHARED_BLOCK_IDS: () => SHARED_BLOCK_IDS,
@@ -5136,7 +5137,8 @@ function validateTemplate(raw, options = {}) {
5136
5137
  const at = `tables (${t.token}).fields (${f.key})`;
5137
5138
  const text2 = `${f.key} ${norm(f.label)}`;
5138
5139
  const e = effective(t.token, f);
5139
- const criminalCharges = /(^|_)charges?($|_)/.test(f.key) && behaviorOf(f) === "text";
5140
+ const billingTable = /(invoice|bill|statement|receipt|payment|charge|fee|order|account)/i.test(`${t.token} ${t.labelSingular}`);
5141
+ const criminalCharges = /(^|_)charges?($|_)/.test(f.key) && behaviorOf(f) === "text" && !billingTable;
5140
5142
  const phoneLike = behaviorOf(f) === "text" && /\b(cell|mobile|phone)\b/.test(norm(f.label));
5141
5143
  const personal = PERSONAL_ONLY.test(f.key) || /\b(medical conditions?|medications?|diagnos[ie]s)\b/.test(norm(f.label));
5142
5144
  const floored = (RESTRICTED_KEY.test(f.key) || RESTRICTED_LABEL.test(norm(f.label)) || criminalCharges) && (!personal || holdsPeople(t));
@@ -5440,7 +5442,8 @@ ${e.body}`.matchAll(MERGE_TOKEN)].map((m) => m[1]));
5440
5442
  const qq = agent.question;
5441
5443
  const ask = norm(qq.ask);
5442
5444
  const words = (t) => norm(t).split(" ").filter((w) => w.length >= 4);
5443
- const mentions = (t) => words(t).some((w) => ask.includes(w.replace(/s$/, "")));
5445
+ const askWords = new Set(ask.split(" "));
5446
+ const mentions = (t) => !!norm(t) && ask.includes(norm(t)) || words(t).some((w) => ask.includes(w.replace(/s$/, ""))) || words(t).length === 0 && norm(t).split(" ").filter(Boolean).some((w) => w.length >= 3 && (askWords.has(w) || askWords.has(`${w}s`)));
5444
5447
  for (const [k, v] of Object.entries(qq.expect.filter ?? {})) {
5445
5448
  if (typeof v === "string" && !mentions(v) && !ask.includes(norm(v))) say("agent.question.ask", `It filters on ${k} = "${v}", and the question never says so.`);
5446
5449
  }
@@ -5521,7 +5524,8 @@ ${e.body}`.matchAll(MERGE_TOKEN)].map((m) => m[1]));
5521
5524
  const named = (t) => {
5522
5525
  if (!t) return false;
5523
5526
  if (says.includes(norm(t))) return true;
5524
- const words = [...new Set(norm(t).split(" ").filter((w) => w.length >= 4))];
5527
+ const long = [...new Set(norm(t).split(" ").filter((w) => w.length >= 4))];
5528
+ const words = long.length ? long : [...new Set(norm(t).split(" ").filter((w) => w.length >= 2))];
5525
5529
  const said = new Set(says.split(" "));
5526
5530
  return words.length > 0 && words.filter((w) => said.has(w) || said.has(`${w}s`)).length >= Math.min(2, words.length);
5527
5531
  };
@@ -6071,7 +6075,14 @@ function compileInstallPlan(written) {
6071
6075
  const attachments = written.attachments ?? [];
6072
6076
  const attachmentKeys = new Set(attachments.map((a) => a.key));
6073
6077
  const spec = tokenizeValues({ ...written, attachments: void 0 }, attachmentKeys);
6074
- const tables = allTables(spec);
6078
+ const bound = new Map(allTables(spec).filter((t) => t.bindsTo?.tableId).map((t) => [t.token, t.bindsTo]));
6079
+ const has = (token, key) => bound.get(token)?.fields.includes(key) ?? false;
6080
+ const tables = allTables(spec).map((t) => {
6081
+ if (bound.has(t.token)) return { ...t, rows: [] };
6082
+ const toBound = t.fields.filter((f) => f.parityType === "relation" && f.relationTarget && bound.has(f.relationTarget)).map((f) => f.key);
6083
+ if (!toBound.length) return t;
6084
+ return { ...t, rows: t.rows.map((r) => ({ ...r, values: Object.fromEntries(Object.entries(r.values ?? {}).filter(([k]) => !toBound.includes(k))) })) };
6085
+ });
6075
6086
  const steps = [];
6076
6087
  const tableRef = (token) => {
6077
6088
  if (!tables.some((t) => t.token === token)) throw new Error(`The template names a table "${token}" it does not have.`);
@@ -6101,6 +6112,18 @@ function compileInstallPlan(written) {
6101
6112
  }
6102
6113
  }
6103
6114
  for (const t of tables) {
6115
+ if (bound.has(t.token)) {
6116
+ for (const f of t.fields.filter((x) => !DERIVED.has(x.parityType) && x.parityType !== "formula" && x.parityType !== "relation" && !isSelfDeclaredField(x) && !has(t.token, x.key))) {
6117
+ steps.push({
6118
+ label: `bound.${t.token}.${f.key}`,
6119
+ door: "field_declare",
6120
+ args: { p_organization_id: "${org}", p_table_id: tableRef(t.token), p_spec: selfDeclaredFieldSpec(f) },
6121
+ save: { [`fields.${t.token}.${f.key}`]: [] },
6122
+ made: [{ kind: "field", ref: `fields.${t.token}.${f.key}`, table: `tables.${t.token}` }]
6123
+ });
6124
+ }
6125
+ continue;
6126
+ }
6104
6127
  steps.push({
6105
6128
  label: `tables.${t.token}`,
6106
6129
  door: "table_from_example",
@@ -6111,7 +6134,7 @@ function compileInstallPlan(written) {
6111
6134
  }
6112
6135
  steps.push(...membersAddRowsSteps(spec, tableRef));
6113
6136
  for (const t of tables) {
6114
- for (const f of t.fields.filter((x) => x.parityType === "relation" && x.relationTarget)) {
6137
+ for (const f of t.fields.filter((x) => x.parityType === "relation" && x.relationTarget && !has(t.token, x.key))) {
6115
6138
  steps.push({
6116
6139
  label: `relations.${t.token}.${f.key}`,
6117
6140
  door: "field_declare",
@@ -6122,7 +6145,7 @@ function compileInstallPlan(written) {
6122
6145
  }
6123
6146
  }
6124
6147
  for (const t of tables) {
6125
- for (const f of t.fields.filter(isSelfDeclaredField)) {
6148
+ for (const f of t.fields.filter((x) => isSelfDeclaredField(x) && !has(t.token, x.key))) {
6126
6149
  steps.push({
6127
6150
  label: `self_declared.${t.token}.${f.key}`,
6128
6151
  door: "field_declare",
@@ -6158,7 +6181,7 @@ function compileInstallPlan(written) {
6158
6181
  }
6159
6182
  }
6160
6183
  for (const t of tables) {
6161
- for (const f of t.fields.filter((x) => DERIVED.has(x.parityType))) {
6184
+ for (const f of t.fields.filter((x) => DERIVED.has(x.parityType) && !has(t.token, x.key))) {
6162
6185
  steps.push({
6163
6186
  label: `derived.${t.token}.${f.key}`,
6164
6187
  door: "field_declare",
@@ -6169,7 +6192,7 @@ function compileInstallPlan(written) {
6169
6192
  }
6170
6193
  }
6171
6194
  for (const t of tables) {
6172
- for (const f of formulaOrder(t)) {
6195
+ for (const f of formulaOrder(t).filter((x) => !has(t.token, x.key))) {
6173
6196
  steps.push({
6174
6197
  label: `formula.${t.token}.${f.key}`,
6175
6198
  door: "field_declare",
@@ -6195,7 +6218,7 @@ function compileInstallPlan(written) {
6195
6218
  saveEach: { array: [], key: ["data", "key"], value: ["id"], prefix: `fields.${token}.` }
6196
6219
  });
6197
6220
  }
6198
- for (const d of spec.dimensions) {
6221
+ for (const d of spec.dimensions.filter((x) => !bound.has(x.table))) {
6199
6222
  const overrides = {};
6200
6223
  if (d.dimensions) overrides["dimensions"] = d.dimensions;
6201
6224
  if (d.measures) overrides["measures"] = d.measures;
@@ -6352,18 +6375,22 @@ function compileInstallPlan(written) {
6352
6375
  });
6353
6376
  }
6354
6377
  const host = compileHostExtras(spec);
6378
+ const agent = spec.agent;
6355
6379
  return {
6356
6380
  planVersion: INSTALL_PLAN_VERSION,
6357
6381
  timezone: spec.business.timezone || "UTC",
6358
6382
  steps,
6359
- agent: {
6360
- platformAgent: spec.agent.platformAgent,
6361
- name: spec.agent.name,
6362
- bindings: spec.agent.variables.map((v) => {
6363
- const binding = host.agentBindings.get(v.name);
6364
- return { variable: v.name, tableToken: v.table, describes: v.describes, ...binding ? { binding } : {} };
6365
- })
6366
- },
6383
+ ...agent?.platformAgent ? {
6384
+ agent: {
6385
+ platformAgent: agent.platformAgent,
6386
+ name: agent.name,
6387
+ bindings: (agent.variables ?? []).map((v) => {
6388
+ const binding = host.agentBindings.get(v.name);
6389
+ return { variable: v.name, tableToken: v.table, describes: v.describes, ...binding ? { binding } : {} };
6390
+ })
6391
+ }
6392
+ } : {},
6393
+ ...bound.size ? { ids: Object.fromEntries([...bound].map(([token, b]) => [`ref:tables.${token}`, b.tableId])) } : {},
6367
6394
  ...host.extras
6368
6395
  };
6369
6396
  }