@ai-matrx/records 0.11.0 → 0.17.0

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/dist/index.d.ts CHANGED
@@ -379,11 +379,96 @@ declare const STORE_DOORS: readonly [{
379
379
  readonly args: "p_item_type text, p_item_id uuid";
380
380
  readonly returns: "TABLE(container_type text, container_id uuid, conveys_max permission_level)";
381
381
  readonly security: "definer";
382
+ }, {
383
+ readonly name: "choice_census";
384
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
385
+ readonly returns: "jsonb";
386
+ readonly security: "definer";
387
+ }, {
388
+ readonly name: "choice_field_map";
389
+ readonly args: "p_organization_id uuid, p_table_id uuid";
390
+ readonly returns: "jsonb";
391
+ readonly security: "invoker";
392
+ }, {
393
+ readonly name: "choice_filter_normalize";
394
+ readonly args: "p_map jsonb, p_filter jsonb";
395
+ readonly returns: "jsonb";
396
+ readonly security: "invoker";
397
+ }, {
398
+ readonly name: "choice_key_for";
399
+ readonly args: "p_organization_id uuid, p_options_table_id uuid, p_title text, p_exclude uuid DEFAULT NULL::uuid";
400
+ readonly returns: "text";
401
+ readonly security: "invoker";
402
+ }, {
403
+ readonly name: "choice_key_of";
404
+ readonly args: "p_field jsonb, p_token text";
405
+ readonly returns: "text";
406
+ readonly security: "invoker";
407
+ }, {
408
+ readonly name: "choice_options";
409
+ readonly args: "p_organization_id uuid, p_options_table_id uuid";
410
+ readonly returns: "jsonb";
411
+ readonly security: "invoker";
412
+ }, {
413
+ readonly name: "choice_render";
414
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_doc jsonb";
415
+ readonly returns: "jsonb";
416
+ readonly security: "invoker";
417
+ }, {
418
+ readonly name: "choice_render_groups";
419
+ readonly args: "p_map jsonb, p_groups jsonb";
420
+ readonly returns: "jsonb";
421
+ readonly security: "invoker";
422
+ }, {
423
+ readonly name: "choice_render_note";
424
+ readonly args: "p_field jsonb, p_value jsonb";
425
+ readonly returns: "jsonb";
426
+ readonly security: "invoker";
427
+ }, {
428
+ readonly name: "choice_render_value";
429
+ readonly args: "p_field jsonb, p_value jsonb";
430
+ readonly returns: "jsonb";
431
+ readonly security: "invoker";
432
+ }, {
433
+ readonly name: "choice_slug";
434
+ readonly args: "p_word text";
435
+ readonly returns: "text";
436
+ readonly security: "invoker";
437
+ }, {
438
+ readonly name: "choice_synonyms";
439
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_token text";
440
+ readonly returns: "text[]";
441
+ readonly security: "invoker";
442
+ }, {
443
+ readonly name: "choice_synonyms_in";
444
+ readonly args: "p_map jsonb, p_token text";
445
+ readonly returns: "text[]";
446
+ readonly security: "invoker";
447
+ }, {
448
+ readonly name: "choice_words";
449
+ readonly args: "p_field jsonb";
450
+ readonly returns: "text";
451
+ readonly security: "invoker";
382
452
  }, {
383
453
  readonly name: "client_write_grants";
384
454
  readonly args: "";
385
455
  readonly returns: "TABLE(role_name text, object_name text, privilege text)";
386
456
  readonly security: "invoker";
457
+ }, {
458
+ readonly name: "comment_mention_deliver";
459
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_table_id uuid, p_comment_id uuid, p_recipient uuid, p_author_name text, p_record_title text, p_body text";
460
+ readonly returns: "uuid";
461
+ readonly security: "definer";
462
+ }, {
463
+ readonly name: "comment_thread";
464
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_include_resolved boolean DEFAULT false";
465
+ readonly returns: "jsonb";
466
+ readonly security: "definer";
467
+ }, {
468
+ readonly name: "comment_write";
469
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_body text, p_anchor jsonb DEFAULT '{}'::jsonb, p_parent_comment_id uuid DEFAULT NULL::uuid, p_mentions uuid[] DEFAULT NULL::uuid[]";
470
+ readonly returns: "jsonb";
471
+ readonly security: "definer";
387
472
  }, {
388
473
  readonly name: "computed_provenance";
389
474
  readonly args: "p_organization_id uuid, p_record_id uuid";
@@ -419,6 +504,61 @@ declare const STORE_DOORS: readonly [{
419
504
  readonly args: "";
420
505
  readonly returns: "TABLE(token text, schema_name text, table_name text)";
421
506
  readonly security: "invoker";
507
+ }, {
508
+ readonly name: "dashboard_block_normalize";
509
+ readonly args: "p_organization_id uuid, p_subject_table_id uuid, p_block jsonb";
510
+ readonly returns: "jsonb";
511
+ readonly security: "definer";
512
+ }, {
513
+ readonly name: "dashboard_class";
514
+ readonly args: "";
515
+ readonly returns: "text";
516
+ readonly security: "invoker";
517
+ }, {
518
+ readonly name: "dashboard_declare";
519
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_blocks jsonb DEFAULT '[]'::jsonb, p_presentation jsonb DEFAULT '{}'::jsonb, p_dashboard_id uuid DEFAULT NULL::uuid";
520
+ readonly returns: "uuid";
521
+ readonly security: "definer";
522
+ }, {
523
+ readonly name: "dashboard_delete";
524
+ readonly args: "p_organization_id uuid, p_dashboard_id uuid";
525
+ readonly returns: "boolean";
526
+ readonly security: "definer";
527
+ }, {
528
+ readonly name: "dashboard_field_keys";
529
+ readonly args: "p_organization_id uuid, p_table_id uuid";
530
+ readonly returns: "text[]";
531
+ readonly security: "definer";
532
+ }, {
533
+ readonly name: "dashboard_kinds";
534
+ readonly args: "";
535
+ readonly returns: "text[]";
536
+ readonly security: "invoker";
537
+ }, {
538
+ readonly name: "dashboard_moment_sql";
539
+ readonly args: "p_key text";
540
+ readonly returns: "text";
541
+ readonly security: "invoker";
542
+ }, {
543
+ readonly name: "dashboard_run";
544
+ readonly args: "p_organization_id uuid, p_dashboard_id uuid, p_filter jsonb DEFAULT '{}'::jsonb";
545
+ readonly returns: "jsonb";
546
+ readonly security: "definer";
547
+ }, {
548
+ readonly name: "dashboard_stuck";
549
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_state_key text, p_days integer DEFAULT 14, p_filter jsonb DEFAULT '{}'::jsonb, p_limit integer DEFAULT 50, p_required text DEFAULT 'viewer'::text";
550
+ readonly returns: "TABLE(record_id uuid, title text, state text, last_changed_at timestamp with time zone, days_unchanged numeric, measured_from text)";
551
+ readonly security: "definer";
552
+ }, {
553
+ readonly name: "dashboard_window_sql";
554
+ readonly args: "p_key text, p_window jsonb";
555
+ readonly returns: "text";
556
+ readonly security: "invoker";
557
+ }, {
558
+ readonly name: "dashboards";
559
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
560
+ readonly returns: "TABLE(dashboard_id uuid, table_id uuid, name text, blocks jsonb, presentation jsonb, block_count integer, version integer, created_at timestamp with time zone, updated_at timestamp with time zone)";
561
+ readonly security: "definer";
422
562
  }, {
423
563
  readonly name: "delete_cascade_closure";
424
564
  readonly args: "p_organization_id uuid, p_record_id uuid";
@@ -489,6 +629,11 @@ declare const STORE_DOORS: readonly [{
489
629
  readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid, p_table_id uuid, p_template_version integer, p_body text, p_content_hash text";
490
630
  readonly returns: "uuid";
491
631
  readonly security: "definer";
632
+ }, {
633
+ readonly name: "doc_renders";
634
+ readonly args: "p_organization_id uuid, p_record_id uuid";
635
+ readonly returns: "TABLE(render_id uuid, template_id uuid, record_id uuid, table_id uuid, template_version integer, body text, content_hash text, rendered_at timestamp with time zone)";
636
+ readonly security: "definer";
492
637
  }, {
493
638
  readonly name: "doc_sign";
494
639
  readonly args: "p_organization_id uuid, p_render_id uuid, p_field_key text, p_signer_name text, p_signer_user_id uuid DEFAULT NULL::uuid";
@@ -514,6 +659,16 @@ declare const STORE_DOORS: readonly [{
514
659
  readonly args: "p_organization_id uuid, p_render_id uuid, p_record_id uuid, p_field_key text, p_signer_name text, p_signer_user_id uuid, p_document_hash text, p_document_version integer";
515
660
  readonly returns: "uuid";
516
661
  readonly security: "definer";
662
+ }, {
663
+ readonly name: "doc_signatures";
664
+ readonly args: "p_organization_id uuid, p_record_id uuid";
665
+ readonly returns: "TABLE(signature_id uuid, render_id uuid, record_id uuid, field_key text, signer_name text, signer_user_id uuid, signed_at timestamp with time zone, document_hash text, document_version integer)";
666
+ readonly security: "definer";
667
+ }, {
668
+ readonly name: "doc_template_delete";
669
+ readonly args: "p_organization_id uuid, p_template_id uuid";
670
+ readonly returns: "boolean";
671
+ readonly security: "definer";
517
672
  }, {
518
673
  readonly name: "doc_template_read";
519
674
  readonly args: "p_organization_id uuid, p_template_id uuid";
@@ -524,6 +679,11 @@ declare const STORE_DOORS: readonly [{
524
679
  readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
525
680
  readonly returns: "uuid";
526
681
  readonly security: "definer";
682
+ }, {
683
+ readonly name: "doc_templates";
684
+ readonly args: "p_organization_id uuid, p_table_id uuid";
685
+ readonly returns: "TABLE(template_id uuid, renders_table_id uuid, name text, body text, template_version integer, token_count bigint, updated_at timestamp with time zone)";
686
+ readonly security: "definer";
527
687
  }, {
528
688
  readonly name: "doc_token_pattern";
529
689
  readonly args: "";
@@ -664,6 +824,11 @@ declare const STORE_DOORS: readonly [{
664
824
  readonly args: "p_organization_id uuid, p_field_id uuid";
665
825
  readonly returns: "TABLE(kind text, dependant_id uuid, label text, how text)";
666
826
  readonly security: "definer";
827
+ }, {
828
+ readonly name: "field_history";
829
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_key text, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0, p_record_id uuid DEFAULT NULL::uuid";
830
+ readonly returns: "TABLE(record_id uuid, record_title text, version integer, occurred_at timestamp with time zone, operation_label text, actor jsonb, before jsonb, after jsonb)";
831
+ readonly security: "definer";
667
832
  }, {
668
833
  readonly name: "field_kernel_id";
669
834
  readonly args: "";
@@ -754,11 +919,31 @@ declare const STORE_DOORS: readonly [{
754
919
  readonly args: "p_field custom.record, p_action text DEFAULT 'read'::text";
755
920
  readonly returns: "jsonb";
756
921
  readonly security: "invoker";
922
+ }, {
923
+ readonly name: "history_actor";
924
+ readonly args: "p_tier text, p_document jsonb, p_actor_id uuid, p_people jsonb";
925
+ readonly returns: "jsonb";
926
+ readonly security: "invoker";
927
+ }, {
928
+ readonly name: "history_changes";
929
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_old jsonb, p_new jsonb";
930
+ readonly returns: "jsonb";
931
+ readonly security: "invoker";
932
+ }, {
933
+ readonly name: "history_people";
934
+ readonly args: "p_organization_id uuid, p_ids uuid[]";
935
+ readonly returns: "jsonb";
936
+ readonly security: "definer";
757
937
  }, {
758
938
  readonly name: "history_prune";
759
939
  readonly args: "p_organization_id uuid, p_scope text DEFAULT 'values'::text, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true";
760
940
  readonly returns: "jsonb";
761
941
  readonly security: "definer";
942
+ }, {
943
+ readonly name: "history_restore_body";
944
+ readonly args: "p_current jsonb, p_target jsonb, p_field_key text DEFAULT NULL::text";
945
+ readonly returns: "jsonb";
946
+ readonly security: "invoker";
762
947
  }, {
763
948
  readonly name: "history_retention";
764
949
  readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
@@ -899,6 +1084,16 @@ declare const STORE_DOORS: readonly [{
899
1084
  readonly args: "p_old_deleted timestamp with time zone, p_new_deleted timestamp with time zone, p_old_data jsonb, p_new_data jsonb, p_old_table uuid, p_new_table uuid, p_old_org uuid, p_new_org uuid, p_old_class text, p_new_class text";
900
1085
  readonly returns: "boolean";
901
1086
  readonly security: "invoker";
1087
+ }, {
1088
+ readonly name: "list_door_disagreements";
1089
+ readonly args: "p_pretend text DEFAULT NULL::text, p_only_organization uuid DEFAULT NULL::uuid, p_sample integer DEFAULT 200";
1090
+ readonly returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, table_id uuid, record_id uuid, door text, why text)";
1091
+ readonly security: "invoker";
1092
+ }, {
1093
+ readonly name: "list_door_disagreements";
1094
+ readonly args: "p_pretend text, p_only_organization uuid, p_sample integer, p_exhaustive boolean";
1095
+ readonly returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, table_id uuid, record_id uuid, door text, why text)";
1096
+ readonly security: "invoker";
902
1097
  }, {
903
1098
  readonly name: "lookup_value";
904
1099
  readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb";
@@ -919,6 +1114,11 @@ declare const STORE_DOORS: readonly [{
919
1114
  readonly args: "";
920
1115
  readonly returns: "uuid";
921
1116
  readonly security: "invoker";
1117
+ }, {
1118
+ readonly name: "migrate_choice_keys";
1119
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_dry_run boolean DEFAULT false";
1120
+ readonly returns: "jsonb";
1121
+ readonly security: "definer";
922
1122
  }, {
923
1123
  readonly name: "migrate_delete";
924
1124
  readonly args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text";
@@ -949,6 +1149,11 @@ declare const STORE_DOORS: readonly [{
949
1149
  readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true";
950
1150
  readonly returns: "jsonb";
951
1151
  readonly security: "definer";
1152
+ }, {
1153
+ readonly name: "migrate_reclass";
1154
+ readonly args: "p_organization_id uuid, p_id uuid, p_to text DEFAULT 'field'::text, p_note text DEFAULT NULL::text";
1155
+ readonly returns: "jsonb";
1156
+ readonly security: "definer";
952
1157
  }, {
953
1158
  readonly name: "migrate_rename";
954
1159
  readonly args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text";
@@ -1044,6 +1249,76 @@ declare const STORE_DOORS: readonly [{
1044
1249
  readonly args: "";
1045
1250
  readonly returns: "uuid";
1046
1251
  readonly security: "invoker";
1252
+ }, {
1253
+ readonly name: "portal_admits";
1254
+ readonly args: "p_organization_id uuid, p_user_id uuid DEFAULT NULL::uuid";
1255
+ readonly returns: "boolean";
1256
+ readonly security: "definer";
1257
+ }, {
1258
+ readonly name: "portal_card";
1259
+ readonly args: "p_organization_id uuid, p_portal_id uuid";
1260
+ readonly returns: "jsonb";
1261
+ readonly security: "definer";
1262
+ }, {
1263
+ readonly name: "portal_declare";
1264
+ readonly args: "p_organization_id uuid, p_title text, p_client_table_id uuid, p_tables jsonb, p_portal_id uuid DEFAULT NULL::uuid, p_slug text DEFAULT NULL::text, p_sign_in_method text DEFAULT 'magic_link'::text";
1265
+ readonly returns: "uuid";
1266
+ readonly security: "definer";
1267
+ }, {
1268
+ readonly name: "portal_field_map";
1269
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1270
+ readonly returns: "TABLE(field_id uuid, field_key text, field_type text, points_at uuid)";
1271
+ readonly security: "definer";
1272
+ }, {
1273
+ readonly name: "portal_invitation";
1274
+ readonly args: "p_slug text, p_email text";
1275
+ readonly returns: "jsonb";
1276
+ readonly security: "definer";
1277
+ }, {
1278
+ readonly name: "portal_invite";
1279
+ readonly args: "p_organization_id uuid, p_portal_id uuid, p_client_record_id uuid, p_email text, p_user_id uuid DEFAULT NULL::uuid";
1280
+ readonly returns: "jsonb";
1281
+ readonly security: "definer";
1282
+ }, {
1283
+ readonly name: "portal_me";
1284
+ readonly args: "";
1285
+ readonly returns: "jsonb";
1286
+ readonly security: "definer";
1287
+ }, {
1288
+ readonly name: "portal_preview";
1289
+ readonly args: "p_organization_id uuid, p_portal_id uuid, p_principal_id uuid, p_table_id uuid";
1290
+ readonly returns: "TABLE(record_id uuid, title text)";
1291
+ readonly security: "definer";
1292
+ }, {
1293
+ readonly name: "portal_principal_bind";
1294
+ readonly args: "p_organization_id uuid, p_principal_id uuid, p_user_id uuid";
1295
+ readonly returns: "jsonb";
1296
+ readonly security: "definer";
1297
+ }, {
1298
+ readonly name: "portal_public";
1299
+ readonly args: "p_slug text";
1300
+ readonly returns: "jsonb";
1301
+ readonly security: "definer";
1302
+ }, {
1303
+ readonly name: "portal_record_title";
1304
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1305
+ readonly returns: "text";
1306
+ readonly security: "definer";
1307
+ }, {
1308
+ readonly name: "portal_revoke";
1309
+ readonly args: "p_organization_id uuid, p_portal_id uuid, p_principal_id uuid";
1310
+ readonly returns: "jsonb";
1311
+ readonly security: "definer";
1312
+ }, {
1313
+ readonly name: "portal_slug";
1314
+ readonly args: "p_organization_id uuid, p_title text, p_portal_id uuid DEFAULT NULL::uuid";
1315
+ readonly returns: "text";
1316
+ readonly security: "definer";
1317
+ }, {
1318
+ readonly name: "portals";
1319
+ readonly args: "p_organization_id uuid";
1320
+ readonly returns: "TABLE(portal_id uuid, title text, slug text, client_table_id uuid, client_table text, is_active boolean, tables integer, invited integer, signed_in integer, sign_in_method text, opened_at timestamp with time zone)";
1321
+ readonly security: "definer";
1047
1322
  }, {
1048
1323
  readonly name: "presentation_kernel_id";
1049
1324
  readonly args: "";
@@ -1269,6 +1544,11 @@ declare const STORE_DOORS: readonly [{
1269
1544
  readonly args: "p_organization_id uuid, p_record_id uuid";
1270
1545
  readonly returns: "timestamp with time zone";
1271
1546
  readonly security: "definer";
1547
+ }, {
1548
+ readonly name: "record_history";
1549
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0";
1550
+ readonly returns: "TABLE(version integer, occurred_at timestamp with time zone, operation text, operation_label text, actor jsonb, changes jsonb, migration_id uuid, undoable boolean)";
1551
+ readonly security: "definer";
1272
1552
  }, {
1273
1553
  readonly name: "record_relation_edges";
1274
1554
  readonly 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";
@@ -1289,11 +1569,26 @@ declare const STORE_DOORS: readonly [{
1289
1569
  readonly args: "p_organization_id uuid, p_record_id uuid";
1290
1570
  readonly returns: "void";
1291
1571
  readonly security: "definer";
1572
+ }, {
1573
+ readonly name: "record_restore_preview";
1574
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_version integer, p_field_key text DEFAULT NULL::text";
1575
+ readonly returns: "jsonb";
1576
+ readonly security: "definer";
1577
+ }, {
1578
+ readonly name: "record_restore_version";
1579
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_version integer";
1580
+ readonly returns: "jsonb";
1581
+ readonly security: "definer";
1292
1582
  }, {
1293
1583
  readonly name: "record_state_as_of";
1294
1584
  readonly args: "p_record_id uuid, p_at timestamp with time zone";
1295
1585
  readonly returns: "TABLE(state jsonb, replayed boolean)";
1296
1586
  readonly security: "definer";
1587
+ }, {
1588
+ readonly name: "record_table";
1589
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1590
+ readonly returns: "uuid";
1591
+ readonly security: "definer";
1297
1592
  }, {
1298
1593
  readonly name: "record_update";
1299
1594
  readonly args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer";
@@ -1314,6 +1609,11 @@ declare const STORE_DOORS: readonly [{
1314
1609
  readonly args: "p_organization_id uuid, p_table_id uuid, p_data jsonb";
1315
1610
  readonly returns: "uuid";
1316
1611
  readonly security: "definer";
1612
+ }, {
1613
+ readonly name: "refusals_claiming_a_level_never_asked";
1614
+ readonly args: "";
1615
+ readonly returns: "TABLE(function_name text, identity_args text, why text)";
1616
+ readonly security: "invoker";
1317
1617
  }, {
1318
1618
  readonly name: "relation_carry";
1319
1619
  readonly args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid";
@@ -1539,11 +1839,31 @@ declare const STORE_DOORS: readonly [{
1539
1839
  readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
1540
1840
  readonly returns: "boolean";
1541
1841
  readonly security: "invoker";
1842
+ }, {
1843
+ readonly name: "subscription_cadences";
1844
+ readonly args: "p_organization_id uuid";
1845
+ readonly returns: "text[]";
1846
+ readonly security: "definer";
1847
+ }, {
1848
+ readonly name: "subscription_mute";
1849
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_muted boolean DEFAULT true";
1850
+ readonly returns: "boolean";
1851
+ readonly security: "definer";
1852
+ }, {
1853
+ readonly name: "subscriptions";
1854
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
1855
+ readonly returns: "TABLE(rule_id uuid, name text, table_id uuid, saved_view_id uuid, cadence text, schedule text, channel text, recipient_user_id uuid, event_key text, muted boolean, mine boolean, i_may_mute boolean)";
1856
+ readonly security: "definer";
1542
1857
  }, {
1543
1858
  readonly name: "table_capacity";
1544
1859
  readonly args: "p_organization_id uuid, p_table_id uuid";
1545
1860
  readonly returns: "jsonb";
1546
1861
  readonly security: "definer";
1862
+ }, {
1863
+ readonly name: "table_carries_its_rows";
1864
+ readonly args: "p_user_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
1865
+ readonly returns: "boolean";
1866
+ readonly security: "definer";
1547
1867
  }, {
1548
1868
  readonly name: "table_contents";
1549
1869
  readonly args: "p_organization_id uuid, p_table_id uuid";
@@ -1649,6 +1969,11 @@ declare const STORE_DOORS: readonly [{
1649
1969
  readonly args: "p_organization_id uuid, p_record_id uuid, p_key text";
1650
1970
  readonly returns: "TABLE(field_key text, field_id uuid, value jsonb, value_version integer, source jsonb, absent_reason text, actor text, on_behalf_of text, written_at timestamp with time zone, alternates jsonb)";
1651
1971
  readonly security: "definer";
1972
+ }, {
1973
+ readonly name: "value_restore";
1974
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_key text, p_version integer";
1975
+ readonly returns: "jsonb";
1976
+ readonly security: "definer";
1652
1977
  }, {
1653
1978
  readonly name: "value_versions";
1654
1979
  readonly args: "p_old jsonb, p_new jsonb";
@@ -1709,6 +2034,11 @@ declare const STORE_DOORS: readonly [{
1709
2034
  readonly args: "p_organization_id uuid, p_approval_id uuid, p_approve boolean, p_note text DEFAULT NULL::text";
1710
2035
  readonly returns: "jsonb";
1711
2036
  readonly security: "definer";
2037
+ }, {
2038
+ readonly name: "work_approval_kinds";
2039
+ readonly args: "";
2040
+ readonly returns: "text[]";
2041
+ readonly security: "invoker";
1712
2042
  }, {
1713
2043
  readonly name: "work_approval_may_decide";
1714
2044
  readonly args: "p_organization_id uuid, p_approval_id uuid";
@@ -1804,6 +2134,11 @@ declare const STORE_DOORS: readonly [{
1804
2134
  readonly args: "p_organization_id uuid, p_name text, p_slug text, p_home_id uuid DEFAULT NULL::uuid";
1805
2135
  readonly returns: "jsonb";
1806
2136
  readonly security: "definer";
2137
+ }, {
2138
+ readonly name: "work_state_id";
2139
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_value text";
2140
+ readonly returns: "uuid";
2141
+ readonly security: "invoker";
1807
2142
  }, {
1808
2143
  readonly name: "work_states";
1809
2144
  readonly args: "";
@@ -1875,6 +2210,10 @@ declare const STORE_KNOBS: readonly [{
1875
2210
  readonly key: "consumer_checkout_enabled";
1876
2211
  readonly value: "false";
1877
2212
  readonly type: "boolean";
2213
+ }, {
2214
+ readonly key: "consumer_context_enabled";
2215
+ readonly value: "false";
2216
+ readonly type: "boolean";
1878
2217
  }, {
1879
2218
  readonly key: "consumer_education_enabled";
1880
2219
  readonly value: "false";
@@ -2000,37 +2339,40 @@ declare const STORE_KNOBS: readonly [{
2000
2339
  */
2001
2340
  declare const STORE_REFUSAL_CODES: readonly [{
2002
2341
  readonly code: "02000";
2003
- readonly raised_by: "doc_render_body,doc_render_document,doc_render_read,doc_sign,doc_signature_intact,doc_signature_read,doc_template_read,doc_template_save,entity_field_retire,entity_field_update,entity_record_read,entity_value_write,external_history_event,external_rows,external_stub_upsert,external_writes_set,migrate_delete,migrate_extract_parent,migrate_merge,migrate_rename,migrate_reparent,migrate_retype,migrate_split,migrate_undo,organization_clear,read_record,record_delete,record_restore,record_update,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_assign,work_record_states,work_set_state";
2342
+ readonly raised_by: "dashboard_delete,dashboard_run,doc_render_body,doc_render_document,doc_render_read,doc_sign,doc_signature_intact,doc_signature_read,doc_template_delete,doc_template_read,doc_template_save,entity_field_retire,entity_field_update,entity_record_read,entity_value_write,external_history_event,external_rows,external_stub_upsert,external_writes_set,io_restore,migrate_delete,migrate_extract_parent,migrate_merge,migrate_reclass,migrate_rename,migrate_reparent,migrate_retype,migrate_split,migrate_undo,organization_clear,portal_card,portal_declare,portal_invite,portal_preview,portal_principal_bind,portal_revoke,read_record,record_delete,record_restore,record_restore_preview,record_table,record_update,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_assign,work_record_states,work_set_state";
2004
2343
  }, {
2005
2344
  readonly code: "0A000";
2006
- readonly raised_by: "external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_assign,work_slots_declare";
2345
+ readonly raised_by: "external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_assign";
2007
2346
  }, {
2008
2347
  readonly code: "22004";
2009
- readonly raised_by: "_entity_custom_fields_guard,_value_envelope,actor_word,agg_assert_key,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,doc_render_write,doc_sign,doc_signature_write,doc_template_save,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,form_declare,form_submit,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_purge,migrate_split,migrate_undo,organization_clear,organization_contents,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,rule_declare,share_grant,table_declare,work_approval_decide,work_approval_request,work_template_declare";
2348
+ readonly raised_by: "_entity_custom_fields_guard,_value_envelope,actor_word,agg_assert_key,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,field_history,form_declare,form_submit,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,portal_declare,portal_invite,portal_principal_bind,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,rule_declare,share_grant,table_declare,value_restore,work_approval_decide,work_approval_request,work_template_declare";
2349
+ }, {
2350
+ readonly code: "22007";
2351
+ readonly raised_by: "dashboard_window_sql";
2010
2352
  }, {
2011
2353
  readonly code: "22012";
2012
2354
  readonly raised_by: "rule_eval";
2013
2355
  }, {
2014
2356
  readonly code: "22023";
2015
- readonly raised_by: "_entity_custom_fields_guard,_value_envelope,_work_shape_guard,actor_word,agg_assert_key,agg_sql,anon_token_issue,containment_parent,doc_render_body,doc_render_write,doc_signature_write,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,io_import_open,io_proposal_accept,migrate_merge,my_levels,organization_clear,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_approval_request,work_list,work_slot_hold";
2357
+ readonly raised_by: "_entity_custom_fields_guard,_value_envelope,_work_shape_guard,actor_word,agg_assert_key,agg_sql,anon_token_issue,containment_parent,dashboard_block_normalize,dashboard_window_sql,doc_render_body,doc_render_write,doc_signature_write,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,field_history,io_import_open,io_proposal_accept,migrate_merge,migrate_reclass,my_levels,organization_clear,portal_declare,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_approval_request,work_list,work_slot_hold";
2016
2358
  }, {
2017
2359
  readonly code: "23503";
2018
- readonly raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,delete_rule,doc_sign,doc_template_save,form_declare,form_submit,home_add,io_comment_write,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,promote_field,promote_table,record_applicability,record_reparent,relation_carry,relation_own,resolve_first_match,rule_applies,rule_declare,rule_eval,rule_members,rule_run,work_set_state,work_take_assignment,work_template_instantiate";
2360
+ readonly raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,comment_write,dashboard_declare,delete_rule,doc_sign,doc_template_save,form_declare,form_submit,home_add,io_comment_write,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,promote_field,promote_table,record_applicability,record_reparent,relation_carry,relation_own,resolve_first_match,rule_applies,rule_declare,rule_eval,rule_members,rule_run,subscription_mute,work_set_state,work_take_assignment,work_template_instantiate";
2019
2361
  }, {
2020
2362
  readonly code: "23505";
2021
2363
  readonly raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,entity_field_declare,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_approval_decide,work_slot_hold";
2022
2364
  }, {
2023
2365
  readonly code: "23514";
2024
- readonly raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_entity_custom_fields_guard,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_shape_guard,_value_envelope,_work_shape_guard,_workdoors_approval_guard,assert_entity_is_organization_scoped,doc_sign,doc_signature_write,doc_template_save,entity_field_declare,entity_field_retire,entity_field_update,entity_records_find,entity_table,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate";
2366
+ readonly raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_entity_custom_fields_guard,_field_class_guard,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_shape_guard,_value_envelope,_work_shape_guard,_workdoors_approval_guard,assert_entity_is_organization_scoped,doc_sign,doc_signature_write,doc_template_save,entity_field_declare,entity_field_retire,entity_field_update,entity_records_find,entity_table,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate";
2025
2367
  }, {
2026
2368
  readonly code: "40001";
2027
2369
  readonly raised_by: "has_visibility_at";
2028
2370
  }, {
2029
2371
  readonly code: "42501";
2030
- readonly raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_submit,io_comment_resolve,io_comment_write,io_restore,migrate_purge,my_levels,organization_clear,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person";
2372
+ readonly raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,comment_write,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_submit,io_comment_resolve,io_comment_write,io_restore,migrate_purge,migrate_reclass,my_levels,organization_clear,portal_declare,portal_invitation,portal_invite,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,record_table,share_grant,subscription_mute,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person";
2031
2373
  }, {
2032
2374
  readonly code: "42703";
2033
- readonly raised_by: "entity_table";
2375
+ readonly raised_by: "entity_table,portal_declare";
2034
2376
  }, {
2035
2377
  readonly code: "53400";
2036
2378
  readonly raised_by: "anon_rate_take,delete_cascade_closure,promote_field";
@@ -2553,6 +2895,14 @@ interface NewFieldDeclaration {
2553
2895
  parity_type?: ParityFieldType;
2554
2896
  /** Plain text, a long text or a plain number — the three that carry no parity type. */
2555
2897
  plain?: "text" | "long_text" | "number";
2898
+ /**
2899
+ * THE ONE WORD EVERY OTHER CALLER REACHES FOR. An agent, a script, an import
2900
+ * and this package's own table-declaring path all say `type`, and until
2901
+ * 2026-09-20 `custom._field_document_for` threw it away — a `number` became a
2902
+ * text column in silence. It now resolves all three vocabularies, so this is
2903
+ * named here rather than left as a shape only the store knows about.
2904
+ */
2905
+ type?: FieldTypeWord;
2556
2906
  /** Derived from the label when absent, which is why the panel never asks for it. */
2557
2907
  key?: string;
2558
2908
  required?: boolean;
@@ -2581,8 +2931,42 @@ interface NewFieldDeclaration {
2581
2931
  expr?: Record<string, unknown>;
2582
2932
  compute_on?: ComputeOn;
2583
2933
  relation_max?: number;
2934
+ /**
2935
+ * REL / FLD-11. The Table this column points at, when it is neither a Person
2936
+ * (`member`) nor a File (`attachment`). The store has taken it since
2937
+ * 2026-09-20 and no client type named it, so a person with an Invoice table
2938
+ * and a Line table could not declare the link through this package at all.
2939
+ */
2940
+ relation_target?: Uuid;
2941
+ /** REL-2. What happens to this record when the thing it points at goes. */
2942
+ on_target_delete?: OnDelete;
2943
+ /**
2944
+ * Presentation and behaviour settings the store carries verbatim — a long
2945
+ * text's `multiline`, a list's existing options table. The door has always
2946
+ * read it (`p_spec -> 'config'`) and this interface never offered it, so a
2947
+ * package-owned table could not declare its own multi-line column.
2948
+ */
2949
+ config?: Record<string, unknown>;
2950
+ /** A text column that holds a signature (`custom.doc_sign` accepts no other). */
2951
+ format?: string;
2584
2952
  }
2585
- /** What `custom.field_update` accepts: a field's settings, never what it holds. */
2953
+ /**
2954
+ * Every word `custom._field_document_for` resolves for `type`: one of the
2955
+ * thirteen, one of the five behaviours, or one of the plain synonyms a person
2956
+ * or an agent actually writes.
2957
+ */
2958
+ type FieldTypeWord = ParityFieldType | FieldBehavior | "number" | "integer" | "decimal" | "float" | "long_text" | "string";
2959
+ /**
2960
+ * What `custom.field_update` accepts.
2961
+ *
2962
+ * THE SETTINGS **AND** THE BEHAVIOUR. The door has had a behaviour arm since
2963
+ * T12 — say `parity_type`, `plain` or `type` and every value of the column is
2964
+ * converted (or kept in `_retired` with its reason) by
2965
+ * `custom._field_type_converts_values`. This interface named only the settings,
2966
+ * so the one client that needed to move a field back onto the behaviour it is
2967
+ * written against had no door and reached for `custom.record_update` instead,
2968
+ * which writes the document under the guards rather than through them.
2969
+ */
2586
2970
  interface FieldPatch {
2587
2971
  label?: string;
2588
2972
  required?: boolean;
@@ -2594,7 +2978,78 @@ interface FieldPatch {
2594
2978
  rules?: FieldRule[];
2595
2979
  /** The choices of a choice list, rewritten. A choice still wanted keeps its id. */
2596
2980
  options?: string[];
2981
+ /** One of the thirteen — a change of what this column HOLDS, not of a setting. */
2982
+ parity_type?: ParityFieldType;
2983
+ /** …or one of the three plain behaviours, …*/
2984
+ plain?: "text" | "long_text" | "number";
2985
+ /** …or the one word every other caller reaches for (see `NewFieldDeclaration`). */
2986
+ type?: FieldTypeWord;
2987
+ /**
2988
+ * FLD-2. The shape of the value. The door reads it ONLY inside its behaviour
2989
+ * arm, so a patch that moves `multi` alone changes nothing — send the
2990
+ * behaviour word with it.
2991
+ */
2992
+ multi?: boolean;
2993
+ /** REL / FLD-11: re-point the column. The old edges are withdrawn by the door. */
2994
+ relation_target?: Uuid;
2995
+ on_target_delete?: OnDelete;
2996
+ /** SEAT-SUITES: whether the store builds an index for this column, and a unique one. */
2997
+ promoted?: boolean;
2998
+ unique?: boolean;
2999
+ /** §D / T7: which fields a worked-out column reads. */
3000
+ depends_on?: Uuid[];
3001
+ }
3002
+
3003
+ /** One option, as `_choices` names it and as `optionsOf` returns it. */
3004
+ interface ChoiceOption {
3005
+ /** The stable key the cell actually holds. */
3006
+ key: string;
3007
+ /** What a person reads. */
3008
+ label: string;
3009
+ /** The option RECORD's id, for a caller that needs the row itself. */
3010
+ id?: string;
3011
+ /** True when the option was retired: still readable, no longer pickable. */
3012
+ retired?: boolean;
3013
+ /** Why it is no longer offered, in a sentence, when it is retired. */
3014
+ reason?: string | null;
2597
3015
  }
3016
+ /**
3017
+ * The stable key of an option RECORD as `custom.field_options` returns it.
3018
+ *
3019
+ * It lives in `metadata.option_key`, not in the document: FLD-5 keeps a category to one title
3020
+ * field, and the key is the store's own bookkeeping rather than a column anybody declared.
3021
+ * The fallback is the same slug the store derives, so an option written by something that has
3022
+ * not caught up still answers.
3023
+ */
3024
+ declare function optionKey(option: StoredRecord): string;
3025
+ /** What a person reads on an option record. */
3026
+ declare function optionLabel(option: StoredRecord): string;
3027
+ /**
3028
+ * The store's own slug, mirrored so a client can predict a key without a round trip.
3029
+ * `custom.choice_slug` is the original; a title with nothing a-z0-9 in it gets a short hash of
3030
+ * itself there, and this returns the empty-ish fallback rather than guessing a hash — a caller
3031
+ * that needs the real key for such a title reads it off the option.
3032
+ */
3033
+ declare function choiceSlug(word: string): string;
3034
+ /**
3035
+ * Does this stored (or typed) value name this option? The key, the label and the option's own
3036
+ * id all name the same choice, and a control has to recognise every one of them: what the read
3037
+ * door hands it is the LABEL, what the store holds is the KEY, and what a screen written before
3038
+ * this contract sends is the ID.
3039
+ */
3040
+ declare function isTheChosen(option: StoredRecord, value: unknown): boolean;
3041
+ /** Every value of one cell, as strings, whether the Field is multi or not. */
3042
+ declare function choiceValuesOf(value: unknown): string[];
3043
+ /**
3044
+ * What the read door said about one column's choices: the key behind the label, and whether the
3045
+ * option was retired and why. Returns an empty array when the document carries no `_choices`
3046
+ * entry for that column, which is also what a document written before this contract looks like.
3047
+ */
3048
+ declare function choicesOf(document: RecordDocument | undefined, fieldKeyOrId: string): ChoiceOption[];
3049
+ /** True when this cell's value points at a choice that has since been retired. */
3050
+ declare function holdsARetiredChoice(document: RecordDocument | undefined, fieldKeyOrId: string): boolean;
3051
+ /** True when a token looks like a uuid — which a choice value is no longer allowed to be. */
3052
+ declare function looksLikeAnId(value: unknown): boolean;
2598
3053
 
2599
3054
  /** The seven table types. Only these two carry custom fields (REC-34, DD-011). */
2600
3055
  type CustomFieldTableType = "entity" | "detail";
@@ -2805,10 +3260,144 @@ interface FormSummary {
2805
3260
  */
2806
3261
  declare function publicFormPath(formId: string): string;
2807
3262
 
3263
+ /** One portal as `custom.portals` reports it to its organization. */
3264
+ interface PortalSummary {
3265
+ portal_id: Uuid;
3266
+ title: string;
3267
+ slug: string;
3268
+ /** The Table whose records ARE the clients. A principal is one of its rows. */
3269
+ client_table_id: Uuid;
3270
+ /** That Table's name, so a list never has to read a second door to draw a row. */
3271
+ client_table: string;
3272
+ is_active: boolean;
3273
+ /** How many Tables this portal exposes. */
3274
+ tables: number;
3275
+ /** Everybody invited and not revoked — NOT everybody who can see anything. */
3276
+ invited: number;
3277
+ /** Of those, how many have followed the link and hold an identity. */
3278
+ signed_in: number;
3279
+ /** `magic_link` today, and the door refuses every other word by name. */
3280
+ sign_in_method: string;
3281
+ opened_at: Timestamp | null;
3282
+ }
3283
+ /** One Table a portal exposes, as `custom.portal_card` reports it. */
3284
+ interface PortalTableExposure {
3285
+ table_id: Uuid;
3286
+ /** The Table's own name. */
3287
+ name: string;
3288
+ /**
3289
+ * The key of the relation Field that says WHOSE a record is. This is the
3290
+ * whole of "only theirs": the association that Field writes is what carries
3291
+ * the record to the client, so a portal cannot exist without one.
3292
+ */
3293
+ names_via: string;
3294
+ /** The field keys a client sees. Empty is impossible — the door fills it. */
3295
+ visible_fields: string[];
3296
+ /** The subset a client may change. Always a subset of `visible_fields`. */
3297
+ editable_fields: string[];
3298
+ comments: boolean;
3299
+ /**
3300
+ * The most a client is ever conveyed on this Table — `viewer`, `commenter`
3301
+ * or `editor` — worked out by the door from the two lists above, never by a
3302
+ * screen.
3303
+ */
3304
+ conveys: string;
3305
+ }
3306
+ /** One person a portal was opened to, as `custom.portal_card` reports them. */
3307
+ interface PortalPrincipal {
3308
+ principal_id: Uuid;
3309
+ email: string;
3310
+ /** The record of the client Table this person IS, for the portal's purposes. */
3311
+ client_record_id: Uuid;
3312
+ /** That record's title — what an owner calls this client. */
3313
+ client: string;
3314
+ /** They followed the link and hold an identity. Until then this is false. */
3315
+ signed_in: boolean;
3316
+ /** Not revoked. An invitation that was never followed is still active. */
3317
+ is_active: boolean;
3318
+ invited_at: Timestamp;
3319
+ revoked_at: Timestamp | null;
3320
+ }
3321
+ /** Everything about ONE portal: what it shows, and who it was opened to. */
3322
+ interface PortalCard {
3323
+ portal_id: Uuid;
3324
+ title: string;
3325
+ slug: string;
3326
+ is_active: boolean;
3327
+ sign_in_method: string;
3328
+ client_table_id: Uuid;
3329
+ tables: PortalTableExposure[];
3330
+ principals: PortalPrincipal[];
3331
+ /**
3332
+ * Whether this organization's outside lane is open
3333
+ * (`custom/external_principal_enabled`). Declaring a portal opens it; while
3334
+ * it is false every door refuses an outsider BY NAME, and a screen that drew
3335
+ * the people as reachable anyway would be lying about the one thing that
3336
+ * decides whether they can sign in at all.
3337
+ */
3338
+ external_lane_open: boolean;
3339
+ }
3340
+ /** What `custom.portal_invite` answers. `say` is the door's own sentence. */
3341
+ interface PortalInvitation {
3342
+ invited: boolean;
3343
+ principal_id: Uuid;
3344
+ portal_id: Uuid;
3345
+ slug: string;
3346
+ email: string;
3347
+ client_record_id: Uuid;
3348
+ client: string;
3349
+ /** They already hold an identity. From a screen this is false: the door is passed no user. */
3350
+ bound: boolean;
3351
+ /**
3352
+ * The door's own words, and the ONLY correct summary of what just happened —
3353
+ * it says outright that an invitation confers nothing until the link is
3354
+ * followed. Show it; never paraphrase it.
3355
+ */
3356
+ say: string;
3357
+ }
3358
+ /** What `custom.portal_revoke` answers. `say` names the consequence, past tense. */
3359
+ interface PortalRevocation {
3360
+ revoked: boolean;
3361
+ principal_id: Uuid;
3362
+ email: string;
3363
+ /** The door's own sentence: they can no longer sign in, and their records stop reaching them. */
3364
+ say: string;
3365
+ }
3366
+ /** One row of "what this client sees", from `custom.portal_preview`. */
3367
+ interface PortalPreviewRow {
3368
+ record_id: Uuid;
3369
+ title: string;
3370
+ }
3371
+ /**
3372
+ * THE PUBLIC ADDRESS OF A PORTAL, and the one place its shape is written down.
3373
+ *
3374
+ * Unlike a form's link, a portal's slug is NOT the capability: the page it
3375
+ * serves asks who you are and emails a one-time link, so the slug is a name and
3376
+ * nothing more. That is why it is readable and why copying it is safe.
3377
+ */
3378
+ declare function portalPath(slug: string): string;
3379
+
2808
3380
  /** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
2809
3381
  type AggregateOperation = "count" | "sum" | "avg" | "min" | "max";
2810
3382
  /** The periods a date Field can be bucketed into (`custom.agg_buckets()`). */
2811
3383
  type AggregateBucket = "day" | "week" | "month" | "quarter" | "year";
3384
+ /**
3385
+ * A HALF-OPEN MOMENT WINDOW: `from` is inclusive, `to` is exclusive. Half-open
3386
+ * is the only shape that makes "September" and "October" meet exactly once —
3387
+ * an inclusive `to` either double-counts the boundary moment or drops it,
3388
+ * depending on the reader, and both of those are a chart telling a lie.
3389
+ */
3390
+ interface AggregateWindow {
3391
+ from?: string | null;
3392
+ to?: string | null;
3393
+ }
3394
+ /**
3395
+ * ONE FILTER VALUE, as `custom.record_aggregate` and `custom.dashboard_run`
3396
+ * both read it: a SCALAR is an equality, and an OBJECT is a window. It is not
3397
+ * `unknown` on purpose — a filter value the store cannot read is a refusal a
3398
+ * caller should get from the compiler, not from the database.
3399
+ */
3400
+ type AggregateFilter = string | number | boolean | null | AggregateWindow;
2812
3401
  /** One measure. `count` counts rows and needs no Field; the rest read one. */
2813
3402
  interface AggregateMeasure {
2814
3403
  op: AggregateOperation;
@@ -2828,6 +3417,107 @@ interface AggregateRow {
2828
3417
  /** The measure key the store answers with, so a chart can find its own series. */
2829
3418
  declare function measureKey(measure: AggregateMeasure): string;
2830
3419
 
3420
+ /** The seven shapes a block can take, exactly as `custom.dashboard_kinds()` answers. */
3421
+ type DashboardBlockKind = "number" | "bar" | "column" | "line" | "donut" | "table" | "stuck";
3422
+ /**
3423
+ * ONE SAVED BLOCK — the spec, not the answer. `table_id` left out means the
3424
+ * dashboard's own subject Table, and `state_key` / `days` belong to `stuck`
3425
+ * alone (the door refuses a `stuck` block that names no field to watch).
3426
+ */
3427
+ interface DashboardBlock {
3428
+ title?: string;
3429
+ kind: DashboardBlockKind;
3430
+ /** Absent = the dashboard's subject Table. */
3431
+ table_id?: Uuid | null;
3432
+ /** Field keys whose values become the groups. */
3433
+ group_by?: string[];
3434
+ /** `count` needs no key; every other operation reads one Field. */
3435
+ measures?: AggregateMeasure[];
3436
+ /** A date Field truncated to a period. */
3437
+ bucket?: {
3438
+ key: string;
3439
+ by: AggregateBucket;
3440
+ } | null;
3441
+ /** A scalar is an equality; an object is a half-open moment window. */
3442
+ filter?: Record<string, AggregateFilter> | null;
3443
+ /** Rows this block reads. The door clamps it to 1…500 and defaults to 50. */
3444
+ limit?: number;
3445
+ /** Columns of the twelve this block occupies. The door clamps it to 2…12 and defaults to 6. */
3446
+ span?: number;
3447
+ /** `stuck` only: the field whose value is watched for a change. */
3448
+ state_key?: string;
3449
+ /** `stuck` only: how long a record may sit on the same value. Defaults to 14. */
3450
+ days?: number;
3451
+ }
3452
+ /** One dashboard as `custom.dashboards` reports it to its organization. */
3453
+ interface DashboardSummary {
3454
+ dashboard_id: Uuid;
3455
+ /** The subject Table: the one a block that names no table of its own reads. */
3456
+ table_id: Uuid | null;
3457
+ name: string;
3458
+ blocks: DashboardBlock[];
3459
+ presentation: Record<string, unknown>;
3460
+ block_count: number;
3461
+ version: number;
3462
+ created_at: Timestamp;
3463
+ updated_at: Timestamp;
3464
+ }
3465
+ /**
3466
+ * One row of a `stuck` block: a record that has sat on the same value of
3467
+ * `state` for `days_unchanged` days. `measured_from` names WHERE that age was
3468
+ * measured from, because a record whose history does not reach back that far is
3469
+ * aged from what the store actually knows and says so.
3470
+ */
3471
+ interface StuckRow {
3472
+ record_id: Uuid;
3473
+ title: string | null;
3474
+ state: string | null;
3475
+ last_changed_at: Timestamp | null;
3476
+ days_unchanged: number;
3477
+ measured_from: string;
3478
+ }
3479
+ /**
3480
+ * ONE BLOCK'S ANSWER. The door echoes the block back NORMALIZED — the defaults
3481
+ * it applied, the merged filter it actually ran — and adds `rows` and `ms`;
3482
+ * a block it could not run carries `refused` and `sqlstate` INSTEAD of rows,
3483
+ * and a block it could not even normalize carries only its title and kind.
3484
+ */
3485
+ interface DashboardBlockResult {
3486
+ title: string;
3487
+ kind: DashboardBlockKind | (string & {});
3488
+ table_id?: Uuid;
3489
+ group_by?: string[];
3490
+ measures?: AggregateMeasure[];
3491
+ bucket?: {
3492
+ key: string;
3493
+ by: AggregateBucket;
3494
+ } | null;
3495
+ /** The block's own filter with the canvas bar merged under it — the block's own key wins. */
3496
+ filter?: Record<string, AggregateFilter>;
3497
+ limit?: number;
3498
+ span?: number;
3499
+ state_key?: string;
3500
+ days?: number;
3501
+ /** An aggregate block's groups and measures, or a `stuck` block's records. Absent when refused. */
3502
+ rows?: AggregateRow[] | StuckRow[];
3503
+ /** How long this one block took, in milliseconds. Absent when refused. */
3504
+ ms?: number;
3505
+ /** The store's own sentence, when this block could not be run. */
3506
+ refused?: string;
3507
+ /** The SQLSTATE that refusal carried. */
3508
+ sqlstate?: string;
3509
+ }
3510
+ /** What `custom.dashboard_run` answers: the canvas, and every block's own result. */
3511
+ interface DashboardRunResult {
3512
+ dashboard_id: Uuid;
3513
+ name: string | null;
3514
+ subject_table_id: Uuid | null;
3515
+ presentation: Record<string, unknown>;
3516
+ /** The one filter bar this run was asked with. */
3517
+ filter: Record<string, AggregateFilter>;
3518
+ blocks: DashboardBlockResult[];
3519
+ }
3520
+
2831
3521
  /** One token found in a body, in the order it appears. */
2832
3522
  interface DocToken {
2833
3523
  ordinal: number;
@@ -2852,7 +3542,6 @@ interface DocSignatureCheck {
2852
3542
  /** `custom.doc_template` — a body with tokens, and the Table it renders. */
2853
3543
  interface DocTemplateRow {
2854
3544
  id: Uuid;
2855
- organization_id: Uuid;
2856
3545
  renders_table_id: Uuid;
2857
3546
  name: string;
2858
3547
  body: string;
@@ -2904,6 +3593,25 @@ interface Subscription {
2904
3593
  event_key: string;
2905
3594
  name: string;
2906
3595
  }
3596
+ /**
3597
+ * ONE SUBSCRIPTION AS ITS OWNER SEES IT — `custom.subscriptions`.
3598
+ *
3599
+ * `custom.agg_subscriptions` is the NOTIFIER's reader: it answers the whole
3600
+ * organization's firing subscriptions so the delivery path can run, and it is
3601
+ * not callable by a client. This is the other side of the same rows — narrowed
3602
+ * to Tables the caller can already open, so the list never reveals a Table —
3603
+ * and it carries the two things a screen needs and the notifier does not: is it
3604
+ * switched off, and may I switch it off.
3605
+ */
3606
+ interface MySubscription extends Subscription {
3607
+ table_id: Uuid | null;
3608
+ /** Off. `custom.agg_subscriptions` already excludes a muted one, so this is the truth. */
3609
+ muted: boolean;
3610
+ /** It is addressed to me. */
3611
+ mine: boolean;
3612
+ /** I may switch it off: mine, or I hold admin on the Table it watches. */
3613
+ i_may_mute: boolean;
3614
+ }
2907
3615
  /** The `subscription` block a Rule record carries. Written through `record_write`. */
2908
3616
  interface SubscriptionBlock {
2909
3617
  saved_view_id: Uuid;
@@ -3641,4 +4349,4 @@ interface RecordsConfig {
3641
4349
  schema?: string;
3642
4350
  }
3643
4351
 
3644
- export { ABSENCE_REASONS, ACTOR_VOCABULARY, type AbsenceReason, type Actor, type AggregateBucket, type AggregateMeasure, type AggregateOperation, type AggregateRow, type AnonTokenBinding, COMPUTE_ON, CONTEXT_POLICIES, type ComputeOn, type ContextPolicy, type CustomFieldTableType, DELIVERIES, type Delivery, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, type EntityFieldRights, type EntityFieldValue, type EntityRecordMatch, type EntityRecordRead, type EntityRecordsFound, type EntityTableFacts, type EntityToken, type ExternalPrincipalCard, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, type Field, type FieldBehavior, type FieldPatch, type FieldProposal, type FieldRule, type FieldSensitivity, type FieldSource, type ForbiddenEnvelopeWord, type FormSummary, type Freshness, type HiddenFieldNotice, type Home, KERNEL_TABLES, type KernelTableName, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, type MergeField, type MergeFieldModifier, type MergeFieldProvenance, type MergeFieldResolution, type MergeFieldSemanticType, type MergeFieldSource, type MergeFieldTransform, type MissingBehavior, type MyLevel, type NewEntityFieldDeclaration, type NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, type PermissionLevel, type PgError, type PredictedRefusal, type ProvenancePointer, type PublishBinding, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, type ReadRow, type ReadValue, type RecordDocument, type RecordRead, type RecordRevision, type RecordsActor, type RecordsConfig, type RecordsDataSource, type RecordsError, type RecordsErrorCode, type RecordsErrorSink, type RecordsFilter, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type Subscription, type SubscriptionBlock, type SubscriptionCadence, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkApprovalDecision, type WorkApprovalFiled, type WorkApprover, type WorkAssignment, type WorkAssignmentField, type WorkChange, type WorkDueState, type WorkGraph, type WorkInboxItem, type WorkInboxKind, type WorkInstantiation, type WorkListFlavour, type WorkListItem, type WorkOrigin, type WorkRecordState, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, err, highestLevel, isRecordsErr, measureKey, ok, publicFormPath };
4352
+ export { ABSENCE_REASONS, ACTOR_VOCABULARY, type AbsenceReason, type Actor, type AggregateBucket, type AggregateFilter, type AggregateMeasure, type AggregateOperation, type AggregateRow, type AggregateWindow, type AnonTokenBinding, COMPUTE_ON, CONTEXT_POLICIES, type ChoiceOption, type ComputeOn, type ContextPolicy, type CustomFieldTableType, DELIVERIES, type DashboardBlock, type DashboardBlockKind, type DashboardBlockResult, type DashboardRunResult, type DashboardSummary, type Delivery, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, type EntityFieldRights, type EntityFieldValue, type EntityRecordMatch, type EntityRecordRead, type EntityRecordsFound, type EntityTableFacts, type EntityToken, type ExternalPrincipalCard, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, type Field, type FieldBehavior, type FieldPatch, type FieldProposal, type FieldRule, type FieldSensitivity, type FieldSource, type FieldTypeWord, type ForbiddenEnvelopeWord, type FormSummary, type Freshness, type HiddenFieldNotice, type Home, KERNEL_TABLES, type KernelTableName, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, type MergeField, type MergeFieldModifier, type MergeFieldProvenance, type MergeFieldResolution, type MergeFieldSemanticType, type MergeFieldSource, type MergeFieldTransform, type MissingBehavior, type MyLevel, type MySubscription, type NewEntityFieldDeclaration, type NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, type PermissionLevel, type PgError, type PortalCard, type PortalInvitation, type PortalPreviewRow, type PortalPrincipal, type PortalRevocation, type PortalSummary, type PortalTableExposure, type PredictedRefusal, type ProvenancePointer, type PublishBinding, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, type ReadRow, type ReadValue, type RecordDocument, type RecordRead, type RecordRevision, type RecordsActor, type RecordsConfig, type RecordsDataSource, type RecordsError, type RecordsErrorCode, type RecordsErrorSink, type RecordsFilter, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type StuckRow, type Subscription, type SubscriptionBlock, type SubscriptionCadence, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkApprovalDecision, type WorkApprovalFiled, type WorkApprover, type WorkAssignment, type WorkAssignmentField, type WorkChange, type WorkDueState, type WorkGraph, type WorkInboxItem, type WorkInboxKind, type WorkInstantiation, type WorkListFlavour, type WorkListItem, type WorkOrigin, type WorkRecordState, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, choiceSlug, choiceValuesOf, choicesOf, err, highestLevel, holdsARetiredChoice, isRecordsErr, isTheChosen, looksLikeAnId, measureKey, ok, optionKey, optionLabel, portalPath, publicFormPath };