@ai-matrx/records 0.76.17 → 0.77.1

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 (70) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/app-table/index.cjs +81 -0
  3. package/dist/app-table/index.cjs.map +1 -1
  4. package/dist/app-table/index.d.cts +7 -7
  5. package/dist/app-table/index.d.ts +7 -7
  6. package/dist/app-table/index.js +81 -0
  7. package/dist/app-table/index.js.map +1 -1
  8. package/dist/{client-kVZ54twD.d.ts → client-BbzLb-sB.d.ts} +53 -5
  9. package/dist/{client-PaKP4Cnd.d.cts → client-BcGGEpNi.d.cts} +53 -5
  10. package/dist/core/index.cjs +93 -6
  11. package/dist/core/index.cjs.map +1 -1
  12. package/dist/core/index.d.cts +21 -11
  13. package/dist/core/index.d.ts +21 -11
  14. package/dist/core/index.js +93 -6
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/data/index.cjs +81 -0
  17. package/dist/data/index.cjs.map +1 -1
  18. package/dist/data/index.d.cts +6 -6
  19. package/dist/data/index.d.ts +6 -6
  20. package/dist/data/index.js +81 -0
  21. package/dist/data/index.js.map +1 -1
  22. package/dist/{declareTable-Bv4V8Bjm.d.cts → declareTable-COEPJpke.d.cts} +4 -4
  23. package/dist/{declareTable-4MK51nXs.d.ts → declareTable-Dxq0Aega.d.ts} +4 -4
  24. package/dist/{field-DkB6Nods.d.cts → field-BTW7h7Wh.d.cts} +1 -1
  25. package/dist/{field-cWRPTM3U.d.ts → field-D7I9yck6.d.ts} +1 -1
  26. package/dist/index.cjs +26 -6
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +7 -7
  29. package/dist/index.d.ts +7 -7
  30. package/dist/index.js +26 -6
  31. package/dist/index.js.map +1 -1
  32. package/dist/memory/index.cjs +31 -0
  33. package/dist/memory/index.cjs.map +1 -1
  34. package/dist/memory/index.d.cts +6 -6
  35. package/dist/memory/index.d.ts +6 -6
  36. package/dist/memory/index.js +31 -0
  37. package/dist/memory/index.js.map +1 -1
  38. package/dist/{ports-C2_pOWrL.d.ts → ports-CaYEF1dG.d.ts} +1 -1
  39. package/dist/{ports-C83nhjoM.d.cts → ports-PpvsH1cQ.d.cts} +1 -1
  40. package/dist/react/index.cjs +93 -6
  41. package/dist/react/index.cjs.map +1 -1
  42. package/dist/react/index.d.cts +325 -15
  43. package/dist/react/index.d.ts +325 -15
  44. package/dist/react/index.js +93 -6
  45. package/dist/react/index.js.map +1 -1
  46. package/dist/realtime/index.d.cts +2 -2
  47. package/dist/realtime/index.d.ts +2 -2
  48. package/dist/{record-DVtXK-6L.d.cts → record-B7iwye2k.d.cts} +75 -13
  49. package/dist/{record-DVtXK-6L.d.ts → record-B7iwye2k.d.ts} +75 -13
  50. package/dist/{subscription-BJgDMerQ.d.cts → subscription-BWaRPLyo.d.ts} +67 -3
  51. package/dist/{subscription-D8OHY3kw.d.ts → subscription-Br30ZwIt.d.cts} +67 -3
  52. package/dist/{table-kind-BtguhnRV.d.cts → table-kind-C5jsmotR.d.ts} +140 -4
  53. package/dist/{table-kind-DzyRtFNa.d.ts → table-kind-DrVhYZbX.d.cts} +140 -4
  54. package/dist/templates/index.cjs +27 -3
  55. package/dist/templates/index.cjs.map +1 -1
  56. package/dist/templates/index.d.cts +11 -11
  57. package/dist/templates/index.d.ts +11 -11
  58. package/dist/templates/index.js +27 -3
  59. package/dist/templates/index.js.map +1 -1
  60. package/dist/{types-C6gdqgsI.d.ts → types-DWZ5_3by.d.ts} +2 -2
  61. package/dist/{types-DWoJFBbr.d.cts → types-DYoWzHwJ.d.cts} +2 -2
  62. package/dist/{types-DqCWKOYh.d.ts → types-DrJLOqVi.d.ts} +2 -2
  63. package/dist/{types-Mx-Wzm_d.d.cts → types-LvxsZ6Zv.d.cts} +2 -2
  64. package/dist/use-cases/index.cjs.map +1 -1
  65. package/dist/use-cases/index.d.cts +5 -5
  66. package/dist/use-cases/index.d.ts +5 -5
  67. package/dist/use-cases/index.js.map +1 -1
  68. package/dist/{validate-CEE0ts9g.d.cts → validate-CRdXE73G.d.cts} +1 -1
  69. package/dist/{validate-d9QMYjBm.d.ts → validate-j0WQoC3C.d.ts} +1 -1
  70. package/package.json +3 -3
@@ -1,12 +1,12 @@
1
- import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-Mx-Wzm_d.cjs';
2
- export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-Mx-Wzm_d.cjs';
3
- import { g as AggregateMeasure, p as AggregateFilter } from '../subscription-BJgDMerQ.cjs';
4
- import { U as UseCase, o as UseCaseRelationship } from '../types-DWoJFBbr.cjs';
5
- import { U as UseCaseProblem } from '../validate-CEE0ts9g.cjs';
6
- export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-CEE0ts9g.cjs';
7
- import { b as RecordsDataSource } from '../ports-C83nhjoM.cjs';
8
- import '../record-DVtXK-6L.cjs';
9
- import '../field-DkB6Nods.cjs';
1
+ import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-LvxsZ6Zv.cjs';
2
+ export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-LvxsZ6Zv.cjs';
3
+ import { i as AggregateMeasure, r as AggregateFilter } from '../subscription-Br30ZwIt.cjs';
4
+ import { U as UseCase, o as UseCaseRelationship } from '../types-DYoWzHwJ.cjs';
5
+ import { U as UseCaseProblem } from '../validate-CRdXE73G.cjs';
6
+ export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-CRdXE73G.cjs';
7
+ import { b as RecordsDataSource } from '../ports-PpvsH1cQ.cjs';
8
+ import '../record-B7iwye2k.cjs';
9
+ import '../field-BTW7h7Wh.cjs';
10
10
 
11
11
  /** The UTC offset ("-04:00") of a local wall-clock moment in an IANA zone. */
12
12
  declare function zoneOffset(localIso: string, timeZone: string): string;
@@ -49,9 +49,9 @@ type AggregateOutcome = {
49
49
  };
50
50
  /**
51
51
  * custom.record_aggregate for ONE measure over seed rows (live, non-archived), as the store
52
- * computes it: count(*); sum/avg/min/max/median over `nullif(text,'')::numeric` (a text that
52
+ * computes it: count(*); sum/avg/min/max/median/range over `nullif(text,'')::numeric` (a text that
53
53
  * is not a number is a refusal; no values at all is NULL, not 0); filled/empty/unique by
54
- * `nullif(text,'')`. Exact: an average that does not terminate is reported as inexact.
54
+ * `nullif(text,'')`; percent_empty/percent_filled as 100 x share of the rows (NULL over none). Exact: an average that does not terminate is reported as inexact.
55
55
  */
56
56
  /** custom.formula_node_kinds(), the functions a formula may call (read on the clone 2026-10-03). */
57
57
  declare const FORMULA_FUNCTIONS: Set<string>;
@@ -1,12 +1,12 @@
1
- import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-C6gdqgsI.js';
2
- export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-C6gdqgsI.js';
3
- import { g as AggregateMeasure, p as AggregateFilter } from '../subscription-D8OHY3kw.js';
4
- import { U as UseCase, o as UseCaseRelationship } from '../types-DqCWKOYh.js';
5
- import { U as UseCaseProblem } from '../validate-d9QMYjBm.js';
6
- export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-d9QMYjBm.js';
7
- import { b as RecordsDataSource } from '../ports-C2_pOWrL.js';
8
- import '../record-DVtXK-6L.js';
9
- import '../field-cWRPTM3U.js';
1
+ import { A as AgentSnapshotRow, T as TemplateSpec, a as TemplateTable, S as SharedBlockId, C as CapabilityWord, b as TemplateField, c as TemplateAgent, d as TemplateAutomation, e as TemplateBooking, f as TemplateChecklist, g as TemplateDashboard, h as TemplateDigest, i as TemplateDocument, j as TemplateDrillDown, k as TemplateDimensions, l as TemplateForm, m as TemplateNotification, n as TemplatePortal, o as TemplateRowAction, p as TemplateStageRules, q as TemplateView, r as TemplateMergeBinding, s as TemplateTryIt, t as TemplateWorkflow, u as TemplateFootprint, I as IndustryGroup, v as TemplateJob, w as TeachesFeature, x as TemplateViewKind, y as TemplateBookingWindow } from '../types-DWZ5_3by.js';
2
+ export { z as CAPABILITY_WORDS, B as CATALOGUE_QUOTAS, D as CATALOGUE_STATUSES, E as CHOICE_COLORS, F as CHOICE_COLORS_DISTINCT_UP_TO, G as CatalogueRow, H as CatalogueStatus, J as ChoiceColor, K as ConfidentialLevel, L as ConfidentialRequest, M as DEFAULT_TEMPLATE_AGENT, N as ENTITY_REFERENCE_KINDS, O as INDUSTRY_GROUPS, R as RELATIVE_DATE, P as RetiredId, Q as SHARED_BLOCKS, U as SHARED_BLOCK_IDS, V as STRENGTHS, W as SharedBlock, X as SharedBlockField, Y as SharedBlockUse, Z as Strength, _ as TABLE_KERNEL_ID, $ as TEACHES_FEATURES, a0 as TEMPLATE_AUDIENCES, a1 as TEMPLATE_EXTRA_KINDS, a2 as TEMPLATE_JOBS, a3 as TEMPLATE_REFERENCE_DATE, a4 as TEMPLATE_SPEC_VERSION, a5 as TEMPLATE_VIEW_KINDS, a6 as TemplateAgentQuestion, a7 as TemplateAgentVariable, a8 as TemplateAudience, a9 as TemplateCalendarView, aa as TemplateChecklistStep, ab as TemplateConfidential, ac as TemplateConfidentialReader, ad as TemplateDashboardBlock, ae as TemplateDimensionOverride, af as TemplateDrillPath, ag as TemplateExtra, ah as TemplateExtraAgent, ai as TemplateExtraAgentVariable, aj as TemplateExtraKind, ak as TemplateFormField, al as TemplateFoundation, am as TemplateGalleryView, an as TemplateGridView, ao as TemplateGuideStep, ap as TemplateKanbanView, aq as TemplateMeasureOverride, ar as TemplatePortalTable, as as TemplateProvenance, at as TemplateSource, au as TemplateTableSettings, av as TemplateTimelineView, aw as TemplateViewSort, ax as UseCaseSingulars, ay as WalkAction, az as WalkAssertion, aA as WalkImport, aB as WalkMove, aC as WalkStep, aD as confidentialPending, aE as confidentialRequests, aF as footprintOf, aG as membersAddRowsSteps, aH as tableSettingsProblems, aI as whenRule } from '../types-DWZ5_3by.js';
3
+ import { i as AggregateMeasure, r as AggregateFilter } from '../subscription-BWaRPLyo.js';
4
+ import { U as UseCase, o as UseCaseRelationship } from '../types-DrJLOqVi.js';
5
+ import { U as UseCaseProblem } from '../validate-j0WQoC3C.js';
6
+ export { R as RESOLVABLE_FIELD_TYPE_WORDS } from '../validate-j0WQoC3C.js';
7
+ import { b as RecordsDataSource } from '../ports-CaYEF1dG.js';
8
+ import '../record-B7iwye2k.js';
9
+ import '../field-D7I9yck6.js';
10
10
 
11
11
  /** The UTC offset ("-04:00") of a local wall-clock moment in an IANA zone. */
12
12
  declare function zoneOffset(localIso: string, timeZone: string): string;
@@ -49,9 +49,9 @@ type AggregateOutcome = {
49
49
  };
50
50
  /**
51
51
  * custom.record_aggregate for ONE measure over seed rows (live, non-archived), as the store
52
- * computes it: count(*); sum/avg/min/max/median over `nullif(text,'')::numeric` (a text that
52
+ * computes it: count(*); sum/avg/min/max/median/range over `nullif(text,'')::numeric` (a text that
53
53
  * is not a number is a refusal; no values at all is NULL, not 0); filled/empty/unique by
54
- * `nullif(text,'')`. Exact: an average that does not terminate is reported as inexact.
54
+ * `nullif(text,'')`; percent_empty/percent_filled as 100 x share of the rows (NULL over none). Exact: an average that does not terminate is reported as inexact.
55
55
  */
56
56
  /** custom.formula_node_kinds(), the functions a formula may call (read on the clone 2026-10-03). */
57
57
  declare const FORMULA_FUNCTIONS: Set<string>;
@@ -646,6 +646,12 @@ var STORE_DOORS = [
646
646
  { name: "assert_public_reader_names_a_public_table", args: "p_organization_id uuid, p_table_id uuid, p_door text", returns: "void", security: "definer" },
647
647
  { name: "assert_scope_door", args: "p_organization_id uuid, p_door text", returns: "void", security: "definer" },
648
648
  { name: "assert_store_door", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
649
+ { name: "automation_archive", args: "p_organization_id uuid, p_automation_id uuid", returns: "jsonb", security: "definer" },
650
+ { name: "automation_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb, p_automation_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
651
+ { name: "automation_restore", args: "p_organization_id uuid, p_automation_id uuid", returns: "jsonb", security: "definer" },
652
+ { name: "automation_runs", args: "p_automation_id uuid, p_limit integer DEFAULT 50, p_cursor timestamp with time zone DEFAULT NULL::timestamp with time zone, p_organization_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
653
+ { name: "automation_set_enabled", args: "p_organization_id uuid, p_automation_id uuid, p_enabled boolean", returns: "jsonb", security: "definer" },
654
+ { name: "automations", args: "p_table_id uuid, p_organization_id uuid DEFAULT NULL::uuid, p_include_archived boolean DEFAULT false", returns: "jsonb", security: "definer" },
649
655
  { name: "autonumber_backfill", args: "p_organization_id uuid, p_field_id uuid", returns: "jsonb", security: "definer" },
650
656
  { name: "barcode_symbologies", args: "", returns: "text[]", security: "invoker" },
651
657
  { name: "booking_cancel", args: "p_booking_ref text, p_origin text DEFAULT NULL::text", returns: "TABLE(booking_ref text, record_id uuid, slot_key text, state text, message text)", security: "definer" },
@@ -892,13 +898,18 @@ var STORE_DOORS = [
892
898
  { name: "form_look_options", args: "p_organization_id uuid, p_presentation jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "definer" },
893
899
  { name: "form_notify", args: "p_organization_id uuid, p_form_id uuid, p_record_id uuid, p_submission_id uuid", returns: "uuid", security: "invoker" },
894
900
  { 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" },
901
+ { 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" },
895
902
  { 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" },
896
903
  { 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" },
904
+ { name: "form_public_route", args: "p_form_id uuid, p_values jsonb", returns: "jsonb", security: "definer" },
897
905
  { name: "form_redirect_domains", args: "p_organization_id uuid", returns: "text[]", security: "invoker" },
898
906
  { name: "form_redirect_refusal", args: "p_organization_id uuid, p_url text", returns: "text", security: "invoker" },
899
907
  { name: "form_restore", args: "p_organization_id uuid, p_form_id uuid", returns: "jsonb", security: "definer" },
908
+ { name: "form_results", args: "p_organization_id uuid, p_form_id uuid", returns: "jsonb", security: "definer" },
900
909
  { name: "form_slug", args: "p_organization_id uuid, p_title text, p_form_id uuid DEFAULT NULL::uuid", returns: "text", security: "invoker" },
901
910
  { 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" },
911
+ { name: "form_theme_options", args: "", returns: "jsonb", security: "invoker" },
912
+ { name: "form_visit", args: "p_form_id uuid, p_visit text, p_event text, p_field text DEFAULT NULL::text", returns: "text", security: "definer" },
902
913
  { 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" },
903
914
  { 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" },
904
915
  { name: "formula_compile_sql", args: "p_organization_id uuid, p_expr jsonb, p_values_sql text", returns: "text", security: "invoker" },
@@ -1229,6 +1240,7 @@ var STORE_DOORS = [
1229
1240
  { name: "rollup_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb", returns: "jsonb", security: "invoker" },
1230
1241
  { name: "row_actions", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
1231
1242
  { name: "row_sits_in_a_personal_table", args: "p_type text, p_organization_id uuid, p_id uuid", returns: "boolean", security: "invoker" },
1243
+ { name: "row_template_bodies", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(template_id uuid, body jsonb)", security: "definer" },
1232
1244
  { name: "row_template_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
1233
1245
  { name: "row_templates", args: "p_organization_id uuid, p_table_id uuid", returns: 'TABLE(template_id uuid, name text, table_id uuid, "values" jsonb, created_at timestamp with time zone, updated_at timestamp with time zone)', security: "definer" },
1234
1246
  { name: "rule_applies", args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
@@ -1355,6 +1367,8 @@ var STORE_DOORS = [
1355
1367
  { name: "table_stage_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "definer" },
1356
1368
  { name: "table_storage", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
1357
1369
  { name: "table_sync", args: "p_organization_id uuid, p_home_id uuid, p_spec jsonb", returns: "jsonb", security: "definer" },
1370
+ { name: "table_template_declare", args: "p_org_id uuid, p_name text, p_description text, p_fields jsonb", returns: "uuid", security: "invoker" },
1371
+ { name: "table_templates", args: "p_org_id uuid", returns: "jsonb", security: "definer" },
1358
1372
  { name: "table_transfer_owner", args: "p_table_id uuid, p_to_person uuid, p_reason text", returns: "jsonb", security: "definer" },
1359
1373
  { name: "table_type_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "definer" },
1360
1374
  { name: "table_unique_rule_fields", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "invoker" },
@@ -2915,6 +2929,12 @@ function storeAggregate(rows, measure, filter, timeZone) {
2915
2929
  if (op === "filled") return { ok: true, value: present.length, exact: true };
2916
2930
  if (op === "empty") return { ok: true, value: live.length - present.length, exact: true };
2917
2931
  if (op === "unique") return { ok: true, value: new Set(present).size, exact: true };
2932
+ if (op === "percent_empty" || op === "percent_filled") {
2933
+ if (!live.length) return { ok: true, value: null, exact: true };
2934
+ const share = q(100n * BigInt(op === "percent_filled" ? present.length : live.length - present.length), BigInt(live.length));
2935
+ const pct = qToNumber(share);
2936
+ return pct === null ? { ok: true, value: Number(share.n) / Number(share.d), exact: false } : { ok: true, value: pct, exact: true };
2937
+ }
2918
2938
  const nums = [];
2919
2939
  for (const t of present) {
2920
2940
  const v = parseNumeric(t);
@@ -2928,6 +2948,10 @@ function storeAggregate(rows, measure, filter, timeZone) {
2928
2948
  if (op === "avg") result = q(result.n, result.d * BigInt(nums.length));
2929
2949
  } else if (op === "min" || op === "max") {
2930
2950
  result = nums.reduce((a, b) => (op === "min" ? qCmp(b, a) < 0 : qCmp(b, a) > 0) ? b : a);
2951
+ } else if (op === "range") {
2952
+ const lo = nums.reduce((a, b) => qCmp(b, a) < 0 ? b : a);
2953
+ const hi = nums.reduce((a, b) => qCmp(b, a) > 0 ? b : a);
2954
+ result = qAdd(hi, q(-lo.n, lo.d));
2931
2955
  } else if (op === "median") {
2932
2956
  const s = [...nums].sort(qCmp);
2933
2957
  const mid = Math.floor(s.length / 2);
@@ -2964,7 +2988,7 @@ var TIME_BOUND_STAGE = /\b(?:no[- ]?show|completed?|done|seen|checked[- ]?in|arr
2964
2988
  var TERMINAL_STAGE = /^(?:cancell?ed|no[- ]?show|lost|closed[- ]lost|declined|closed|withdrawn|fell off|rejected|void(?:ed)?|skipped|missed)$/i;
2965
2989
  var CHART_BLOCK_KINDS = /* @__PURE__ */ new Set(["bar", "column", "line", "donut"]);
2966
2990
  var BUCKETS = ["year", "quarter", "month", "week", "day"];
2967
- var AGG_OPERATIONS = ["count", "sum", "avg", "min", "max", "median", "filled", "empty", "unique"];
2991
+ var AGG_OPERATIONS = ["count", "sum", "avg", "min", "max", "median", "filled", "empty", "unique", "percent_empty", "percent_filled", "range"];
2968
2992
  var MEASURE_KEY = /^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/;
2969
2993
  var STORE_LIST_RELATION_MAX = 25;
2970
2994
  function ruleBreak(field2, v) {
@@ -3979,7 +4003,7 @@ function validateTemplate(raw, options = {}) {
3979
4003
  if (!m.op || !AGG_OPERATIONS.includes(m.op) || m.op === "count") say(mat, `The measure "${m.key}" needs one of: ${AGG_OPERATIONS.filter((o) => o !== "count").join(", ")}.`);
3980
4004
  const of = m.of ? fieldOf(dim.table, m.of) : void 0;
3981
4005
  if (!of) say(mat, `The measure "${m.key}" reads "${m.of ?? "(nothing)"}", which is not a column of "${dim.table}".`);
3982
- else if (m.op && ["sum", "avg", "min", "max", "median"].includes(m.op) && !(isNumber(of) && !isComputed(of))) say(mat, isComputed(of) ? `"${m.of}" is worked out, and a dimension totals only a number that is typed in; total the stored columns it is made from.` : `"${m.of}" is not a number, so it cannot be added up or averaged.`);
4006
+ else if (m.op && ["sum", "avg", "min", "max", "median", "range"].includes(m.op) && !(isNumber(of) && !isComputed(of))) say(mat, isComputed(of) ? `"${m.of}" is worked out, and a dimension totals only a number that is typed in; total the stored columns it is made from.` : `"${m.of}" is not a number, so it cannot be added up or averaged.`);
3983
4007
  if (newMeasures.has(m.key)) say(mat, `Two measures are both called "${m.key}".`);
3984
4008
  newMeasures.add(m.key);
3985
4009
  });
@@ -4072,7 +4096,7 @@ function validateTemplate(raw, options = {}) {
4072
4096
  let honest = true;
4073
4097
  for (const m of b.measures ?? []) {
4074
4098
  const f = m.key ? fieldOf(table, m.key) : void 0;
4075
- if (f && ["sum", "avg", "min", "max", "median"].includes(m.op) && !isNumberish(table, f)) {
4099
+ if (f && (["sum", "avg", "min", "max", "median"].includes(m.op) || m.op === "range" && !isDate(f)) && !isNumberish(table, f)) {
4076
4100
  honest = false;
4077
4101
  say(`${at}.blocks[${bi}]`, `"${b.title}" takes the ${m.op} of "${f.label}", which is not a number.`);
4078
4102
  }