@ai-matrx/records 0.7.2 → 0.11.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.
@@ -327,6 +327,16 @@ declare const STORE_DOORS: readonly [{
327
327
  readonly args: "p_organization_id uuid, p_door text";
328
328
  readonly returns: "void";
329
329
  readonly security: "invoker";
330
+ }, {
331
+ readonly name: "assert_entity_door";
332
+ readonly args: "p_organization_id uuid, p_door text";
333
+ readonly returns: "void";
334
+ readonly security: "definer";
335
+ }, {
336
+ readonly name: "assert_entity_is_organization_scoped";
337
+ readonly args: "p_token text, p_label text, p_scoped boolean";
338
+ readonly returns: "void";
339
+ readonly security: "invoker";
330
340
  }, {
331
341
  readonly name: "assert_may_know_table";
332
342
  readonly args: "p_organization_id uuid, p_table_id uuid, p_door text";
@@ -472,6 +482,11 @@ declare const STORE_DOORS: readonly [{
472
482
  readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid";
473
483
  readonly returns: "uuid";
474
484
  readonly security: "definer";
485
+ }, {
486
+ readonly name: "doc_render_read";
487
+ readonly args: "p_organization_id uuid, p_render_id uuid";
488
+ readonly returns: "jsonb";
489
+ readonly security: "definer";
475
490
  }, {
476
491
  readonly name: "doc_render_write";
477
492
  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";
@@ -492,11 +507,21 @@ declare const STORE_DOORS: readonly [{
492
507
  readonly args: "p_organization_id uuid, p_signature_id uuid";
493
508
  readonly returns: "jsonb";
494
509
  readonly security: "invoker";
510
+ }, {
511
+ readonly name: "doc_signature_read";
512
+ readonly args: "p_organization_id uuid, p_signature_id uuid";
513
+ readonly returns: "jsonb";
514
+ readonly security: "definer";
495
515
  }, {
496
516
  readonly name: "doc_signature_write";
497
517
  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";
498
518
  readonly returns: "uuid";
499
519
  readonly security: "definer";
520
+ }, {
521
+ readonly name: "doc_template_read";
522
+ readonly args: "p_organization_id uuid, p_template_id uuid";
523
+ readonly returns: "jsonb";
524
+ readonly security: "definer";
500
525
  }, {
501
526
  readonly name: "doc_template_save";
502
527
  readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
@@ -537,6 +562,51 @@ declare const STORE_DOORS: readonly [{
537
562
  readonly args: "p_user_id uuid, p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text";
538
563
  readonly returns: "permission_level";
539
564
  readonly security: "definer";
565
+ }, {
566
+ readonly name: "entity_field_declare";
567
+ readonly args: "p_organization_id uuid, p_token text, p_spec jsonb";
568
+ readonly returns: "uuid";
569
+ readonly security: "definer";
570
+ }, {
571
+ readonly name: "entity_field_retire";
572
+ readonly args: "p_organization_id uuid, p_field_id uuid";
573
+ readonly returns: "uuid";
574
+ readonly security: "definer";
575
+ }, {
576
+ readonly name: "entity_field_rights";
577
+ readonly args: "p_organization_id uuid, p_token text";
578
+ readonly returns: "jsonb";
579
+ readonly security: "definer";
580
+ }, {
581
+ readonly name: "entity_field_update";
582
+ readonly args: "p_organization_id uuid, p_field_id uuid, p_patch jsonb";
583
+ readonly returns: "uuid";
584
+ readonly security: "definer";
585
+ }, {
586
+ readonly name: "entity_fields";
587
+ readonly args: "p_organization_id uuid, p_token text";
588
+ readonly returns: "SETOF custom.record";
589
+ readonly security: "definer";
590
+ }, {
591
+ readonly name: "entity_record_read";
592
+ readonly args: "p_organization_id uuid, p_token text, p_record_id uuid";
593
+ readonly returns: "jsonb";
594
+ readonly security: "invoker";
595
+ }, {
596
+ readonly name: "entity_records_find";
597
+ readonly args: "p_organization_id uuid, p_token text, p_key text, p_value jsonb DEFAULT NULL::jsonb, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0";
598
+ readonly returns: "jsonb";
599
+ readonly security: "invoker";
600
+ }, {
601
+ readonly name: "entity_table";
602
+ readonly args: "p_token text";
603
+ readonly returns: "TABLE(token text, schema_name text, table_name text, type text, title_column text, label text, has_organization boolean, has_deleted_at boolean)";
604
+ readonly security: "invoker";
605
+ }, {
606
+ readonly name: "entity_value_write";
607
+ readonly args: "p_organization_id uuid, p_token text, p_record_id uuid, p_patch jsonb";
608
+ readonly returns: "jsonb";
609
+ readonly security: "invoker";
540
610
  }, {
541
611
  readonly name: "export_records";
542
612
  readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000";
@@ -632,6 +702,36 @@ declare const STORE_DOORS: readonly [{
632
702
  readonly args: "";
633
703
  readonly returns: "uuid";
634
704
  readonly security: "invoker";
705
+ }, {
706
+ readonly name: "form_declare";
707
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_title text, p_questions jsonb, p_presentation jsonb DEFAULT '{}'::jsonb, p_submission_cap integer DEFAULT NULL::integer, p_quarantine_rule_id uuid DEFAULT NULL::uuid, p_notify_rule_id uuid DEFAULT NULL::uuid, p_form_id uuid DEFAULT NULL::uuid, p_slug text DEFAULT NULL::text";
708
+ readonly returns: "uuid";
709
+ readonly security: "definer";
710
+ }, {
711
+ readonly name: "form_notify";
712
+ readonly args: "p_organization_id uuid, p_form_id uuid, p_record_id uuid, p_submission_id uuid";
713
+ readonly returns: "uuid";
714
+ readonly security: "invoker";
715
+ }, {
716
+ readonly name: "form_public";
717
+ readonly args: "p_form_id uuid";
718
+ readonly returns: "TABLE(form_id uuid, organization_id uuid, table_id uuid, title text, presentation jsonb, fields jsonb, honeypot_key text, state text, message text)";
719
+ readonly security: "definer";
720
+ }, {
721
+ readonly name: "form_slug";
722
+ readonly args: "p_organization_id uuid, p_title text, p_form_id uuid DEFAULT NULL::uuid";
723
+ readonly returns: "text";
724
+ readonly security: "invoker";
725
+ }, {
726
+ readonly name: "form_submit";
727
+ readonly 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";
728
+ readonly returns: "TABLE(submission_id uuid, record_id uuid, state text, message text)";
729
+ readonly security: "definer";
730
+ }, {
731
+ readonly name: "forms";
732
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
733
+ readonly 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)";
734
+ readonly security: "definer";
635
735
  }, {
636
736
  readonly name: "formula_value";
637
737
  readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb";
@@ -892,6 +992,16 @@ declare const STORE_DOORS: readonly [{
892
992
  readonly args: "p_organization_id uuid, p_ids jsonb, p_type text DEFAULT 'record'::text";
893
993
  readonly returns: "TABLE(id uuid, level permission_level)";
894
994
  readonly security: "definer";
995
+ }, {
996
+ readonly name: "organization_clear";
997
+ readonly args: "p_organization_id uuid, p_confirm text, p_and_destroy boolean DEFAULT false";
998
+ readonly returns: "jsonb";
999
+ readonly security: "definer";
1000
+ }, {
1001
+ readonly name: "organization_contents";
1002
+ readonly args: "p_organization_id uuid";
1003
+ readonly returns: "jsonb";
1004
+ readonly security: "definer";
895
1005
  }, {
896
1006
  readonly name: "organization_kernel_id";
897
1007
  readonly args: "";
@@ -1212,6 +1322,11 @@ declare const STORE_DOORS: readonly [{
1212
1322
  readonly args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid";
1213
1323
  readonly returns: "uuid";
1214
1324
  readonly security: "definer";
1325
+ }, {
1326
+ readonly name: "relation_edges_withdraw";
1327
+ readonly args: "p_organization_id uuid, p_field_ids uuid[], p_why text";
1328
+ readonly returns: "integer";
1329
+ readonly security: "definer";
1215
1330
  }, {
1216
1331
  readonly name: "relation_own";
1217
1332
  readonly args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid";
@@ -1282,6 +1397,11 @@ declare const STORE_DOORS: readonly [{
1282
1397
  readonly args: "p_organization_id uuid, p_record_id uuid";
1283
1398
  readonly returns: "jsonb";
1284
1399
  readonly security: "invoker";
1400
+ }, {
1401
+ readonly name: "rule_declare";
1402
+ readonly args: "p_organization_id uuid, p_spec jsonb, p_rule_id uuid DEFAULT NULL::uuid";
1403
+ readonly returns: "uuid";
1404
+ readonly security: "definer";
1285
1405
  }, {
1286
1406
  readonly name: "rule_dependency_edges";
1287
1407
  readonly args: "p_organization_id uuid, p_row custom.record DEFAULT NULL::custom.record";
@@ -1582,6 +1702,36 @@ declare const STORE_DOORS: readonly [{
1582
1702
  readonly args: "";
1583
1703
  readonly returns: "uuid";
1584
1704
  readonly security: "invoker";
1705
+ }, {
1706
+ readonly name: "work_approval_approvers";
1707
+ readonly args: "p_organization_id uuid, p_subject_id uuid, p_approver_id uuid DEFAULT NULL::uuid";
1708
+ readonly returns: "TABLE(user_id uuid, name text, why text)";
1709
+ readonly security: "definer";
1710
+ }, {
1711
+ readonly name: "work_approval_decide";
1712
+ readonly args: "p_organization_id uuid, p_approval_id uuid, p_approve boolean, p_note text DEFAULT NULL::text";
1713
+ readonly returns: "jsonb";
1714
+ readonly security: "definer";
1715
+ }, {
1716
+ readonly name: "work_approval_may_decide";
1717
+ readonly args: "p_organization_id uuid, p_approval_id uuid";
1718
+ readonly returns: "boolean";
1719
+ readonly security: "definer";
1720
+ }, {
1721
+ readonly name: "work_approval_read";
1722
+ readonly args: "p_organization_id uuid, p_approval_id uuid";
1723
+ readonly returns: "jsonb";
1724
+ readonly security: "definer";
1725
+ }, {
1726
+ readonly name: "work_approval_request";
1727
+ readonly args: "p_organization_id uuid, p_subject_id uuid, p_change jsonb, p_note text DEFAULT NULL::text, p_approver_id uuid DEFAULT NULL::uuid, p_origin text DEFAULT 'person'::text, p_conversation_id uuid DEFAULT NULL::uuid";
1728
+ readonly returns: "jsonb";
1729
+ readonly security: "definer";
1730
+ }, {
1731
+ readonly name: "work_assign";
1732
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_assignee_user_id uuid, p_due_date timestamp with time zone DEFAULT NULL::timestamp with time zone, p_clear_due boolean DEFAULT false";
1733
+ readonly returns: "jsonb";
1734
+ readonly security: "definer";
1585
1735
  }, {
1586
1736
  readonly name: "work_assignment_fields";
1587
1737
  readonly args: "p_options_table_id uuid DEFAULT NULL::uuid";
@@ -1591,32 +1741,57 @@ declare const STORE_DOORS: readonly [{
1591
1741
  readonly name: "work_has_assignment";
1592
1742
  readonly args: "p_organization_id uuid, p_table_id uuid";
1593
1743
  readonly returns: "boolean";
1594
- readonly security: "invoker";
1744
+ readonly security: "definer";
1745
+ }, {
1746
+ readonly name: "work_inbox";
1747
+ readonly args: "p_organization_id uuid, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0, p_include_decided boolean DEFAULT false";
1748
+ readonly returns: "TABLE(item_id uuid, kind text, origin text, title text, subject_id uuid, subject_kind text, summary text, state text, due_on timestamp with time zone, due_state text, actionable boolean, requested_by uuid, requested_by_name text, at timestamp with time zone)";
1749
+ readonly security: "definer";
1595
1750
  }, {
1596
1751
  readonly name: "work_instantiation_shape";
1597
1752
  readonly args: "p_organization_id uuid, p_instantiation_id uuid";
1598
1753
  readonly returns: "jsonb";
1599
- readonly security: "invoker";
1754
+ readonly security: "definer";
1755
+ }, {
1756
+ readonly name: "work_list";
1757
+ readonly args: "p_organization_id uuid, p_flavour text DEFAULT 'mine'::text, p_include_finished boolean DEFAULT false, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0";
1758
+ readonly returns: "TABLE(record_id uuid, table_id uuid, table_name text, title text, assignee_id uuid, assignee_name text, assignee_user_id uuid, due_on timestamp with time zone, due_state text, status text, terminal boolean, assigned_by uuid, updated_at timestamp with time zone)";
1759
+ readonly security: "definer";
1760
+ }, {
1761
+ readonly name: "work_person";
1762
+ readonly args: "p_organization_id uuid, p_user_id uuid, p_create boolean DEFAULT true";
1763
+ readonly returns: "uuid";
1764
+ readonly security: "definer";
1765
+ }, {
1766
+ readonly name: "work_record_states";
1767
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1768
+ readonly returns: "TABLE(state_id uuid, name text, sort integer, terminal boolean, is_current boolean, allowed boolean, refusal text)";
1769
+ readonly security: "definer";
1600
1770
  }, {
1601
1771
  readonly name: "work_relation_kinds";
1602
1772
  readonly args: "";
1603
1773
  readonly returns: "TABLE(kind text, available boolean, why text)";
1604
1774
  readonly security: "invoker";
1775
+ }, {
1776
+ readonly name: "work_set_state";
1777
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_state_id uuid";
1778
+ readonly returns: "jsonb";
1779
+ readonly security: "definer";
1605
1780
  }, {
1606
1781
  readonly name: "work_slot_expire";
1607
1782
  readonly args: "p_organization_id uuid, p_table_id uuid";
1608
1783
  readonly returns: "integer";
1609
- readonly security: "invoker";
1784
+ readonly security: "definer";
1610
1785
  }, {
1611
1786
  readonly name: "work_slot_hold";
1612
1787
  readonly args: "p_organization_id uuid, p_table_id uuid, p_slot_key text, p_holder text, p_ttl interval DEFAULT '00:15:00'::interval";
1613
1788
  readonly returns: "jsonb";
1614
- readonly security: "invoker";
1789
+ readonly security: "definer";
1615
1790
  }, {
1616
1791
  readonly name: "work_slot_holds";
1617
1792
  readonly args: "p_organization_id uuid, p_table_id uuid";
1618
1793
  readonly returns: "TABLE(hold_id uuid, slot_key text, holder text, expires_at timestamp with time zone, expired boolean)";
1619
- readonly security: "invoker";
1794
+ readonly security: "definer";
1620
1795
  }, {
1621
1796
  readonly name: "work_slot_index_name";
1622
1797
  readonly args: "p_table_id uuid";
@@ -1626,12 +1801,12 @@ declare const STORE_DOORS: readonly [{
1626
1801
  readonly name: "work_slot_release";
1627
1802
  readonly args: "p_organization_id uuid, p_hold_id uuid";
1628
1803
  readonly returns: "boolean";
1629
- readonly security: "invoker";
1804
+ readonly security: "definer";
1630
1805
  }, {
1631
1806
  readonly name: "work_slots_declare";
1632
1807
  readonly args: "p_organization_id uuid, p_name text, p_slug text, p_home_id uuid DEFAULT NULL::uuid";
1633
1808
  readonly returns: "jsonb";
1634
- readonly security: "invoker";
1809
+ readonly security: "definer";
1635
1810
  }, {
1636
1811
  readonly name: "work_states";
1637
1812
  readonly args: "";
@@ -1641,17 +1816,17 @@ declare const STORE_DOORS: readonly [{
1641
1816
  readonly name: "work_take_assignment";
1642
1817
  readonly args: "p_organization_id uuid, p_table_id uuid";
1643
1818
  readonly returns: "jsonb";
1644
- readonly security: "invoker";
1819
+ readonly security: "definer";
1645
1820
  }, {
1646
1821
  readonly name: "work_template_declare";
1647
1822
  readonly args: "p_organization_id uuid, p_name text, p_graph jsonb";
1648
1823
  readonly returns: "uuid";
1649
- readonly security: "invoker";
1824
+ readonly security: "definer";
1650
1825
  }, {
1651
1826
  readonly name: "work_template_instantiate";
1652
1827
  readonly args: "p_organization_id uuid, p_template_id uuid, p_overrides jsonb DEFAULT '{}'::jsonb";
1653
1828
  readonly returns: "jsonb";
1654
- readonly security: "invoker";
1829
+ readonly security: "definer";
1655
1830
  }, {
1656
1831
  readonly name: "work_template_refusal";
1657
1832
  readonly args: "p_graph jsonb";
@@ -1661,17 +1836,22 @@ declare const STORE_DOORS: readonly [{
1661
1836
  readonly name: "work_template_shape";
1662
1837
  readonly args: "p_organization_id uuid, p_template_id uuid";
1663
1838
  readonly returns: "jsonb";
1664
- readonly security: "invoker";
1839
+ readonly security: "definer";
1840
+ }, {
1841
+ readonly name: "work_templates";
1842
+ readonly args: "p_organization_id uuid, p_limit integer DEFAULT 100";
1843
+ readonly returns: "TABLE(template_id uuid, name text, nodes integer, relations integer, created_at timestamp with time zone)";
1844
+ readonly security: "definer";
1665
1845
  }, {
1666
1846
  readonly name: "work_transition_refusal";
1667
1847
  readonly args: "p_organization_id uuid, p_from_state_id uuid, p_to_state_id uuid";
1668
1848
  readonly returns: "text";
1669
- readonly security: "invoker";
1849
+ readonly security: "definer";
1670
1850
  }, {
1671
1851
  readonly name: "work_whose_turn";
1672
1852
  readonly args: "p_organization_id uuid, p_table_id uuid, p_include_finished boolean DEFAULT false";
1673
1853
  readonly returns: "TABLE(record_id uuid, title text, assignee_id uuid, turn text, due_on timestamp with time zone, state text, status text, terminal boolean)";
1674
- readonly security: "invoker";
1854
+ readonly security: "definer";
1675
1855
  }];
1676
1856
  /** The campaign's own knobs, with the value the store resolves them to today. */
1677
1857
  declare const STORE_KNOBS: readonly [{
@@ -1823,34 +2003,37 @@ declare const STORE_KNOBS: readonly [{
1823
2003
  */
1824
2004
  declare const STORE_REFUSAL_CODES: readonly [{
1825
2005
  readonly code: "02000";
1826
- readonly raised_by: "doc_render_body,doc_render_document,doc_sign,doc_signature_intact,doc_template_save,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,read_record,record_delete,record_restore,record_update,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,visibility_as_of";
2006
+ 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";
1827
2007
  }, {
1828
2008
  readonly code: "0A000";
1829
- readonly raised_by: "external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_slots_declare";
2009
+ 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";
1830
2010
  }, {
1831
2011
  readonly code: "22004";
1832
- readonly raised_by: "_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,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_purge,migrate_split,migrate_undo,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,share_grant,table_declare,work_template_declare";
2012
+ 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";
1833
2013
  }, {
1834
2014
  readonly code: "22012";
1835
2015
  readonly raised_by: "rule_eval";
1836
2016
  }, {
1837
2017
  readonly code: "22023";
1838
- readonly raised_by: "_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,external_history_event,external_source_declare,external_stub_upsert,external_write_through,io_import_open,io_proposal_accept,migrate_merge,my_levels,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_slot_hold";
2018
+ 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";
1839
2019
  }, {
1840
2020
  readonly code: "23503";
1841
- readonly raised_by: "_containment_guard,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,delete_rule,doc_sign,doc_template_save,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_eval,rule_members,rule_run,work_take_assignment,work_template_instantiate";
2021
+ 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";
1842
2022
  }, {
1843
2023
  readonly code: "23505";
1844
- readonly raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_slot_hold";
2024
+ 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";
1845
2025
  }, {
1846
2026
  readonly code: "23514";
1847
- readonly raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_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,doc_sign,doc_signature_write,doc_template_save,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_slots_declare,work_take_assignment,work_template_instantiate";
2027
+ 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";
1848
2028
  }, {
1849
2029
  readonly code: "40001";
1850
2030
  readonly raised_by: "has_visibility_at";
1851
2031
  }, {
1852
2032
  readonly code: "42501";
1853
- 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,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,my_levels,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of";
2033
+ 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";
2034
+ }, {
2035
+ readonly code: "42703";
2036
+ readonly raised_by: "entity_table";
1854
2037
  }, {
1855
2038
  readonly code: "53400";
1856
2039
  readonly raised_by: "anon_rate_take,delete_cascade_closure,promote_field";
@@ -2416,6 +2599,116 @@ interface FieldPatch {
2416
2599
  options?: string[];
2417
2600
  }
2418
2601
 
2602
+ /** The seven table types. Only these two carry custom fields (REC-34, DD-011). */
2603
+ type CustomFieldTableType = "entity" | "detail";
2604
+ /** What `custom.entity_table` answers about a registry token. */
2605
+ interface EntityTableFacts {
2606
+ token: string;
2607
+ schema_name: string;
2608
+ table_name: string;
2609
+ type: CustomFieldTableType;
2610
+ title_column: string | null;
2611
+ /** The name a person reads. Never the type word. */
2612
+ label: string;
2613
+ /**
2614
+ * 57 of the 643 have no `organization_id`. They carry the column like every
2615
+ * other one, but a VALUE on them would belong to nobody — the guard finds an
2616
+ * organization's Fields through the row's own `organization_id` — so the
2617
+ * value doors refuse them BY NAME rather than writing something unowned.
2618
+ */
2619
+ has_organization: boolean;
2620
+ has_deleted_at: boolean;
2621
+ }
2622
+ /** One custom field of a standard row, as the read door hands it back. */
2623
+ interface EntityFieldValue {
2624
+ id: Uuid;
2625
+ key: string;
2626
+ label: string;
2627
+ type: Field["type"];
2628
+ parity_type?: ParityFieldType;
2629
+ format?: string;
2630
+ unit?: string;
2631
+ multi?: boolean;
2632
+ required?: boolean;
2633
+ sort?: number;
2634
+ sensitivity?: Field["sensitivity"];
2635
+ options_table_id?: Uuid;
2636
+ relation_target?: Uuid;
2637
+ /** The value itself, or undefined when this row has none. */
2638
+ value?: unknown;
2639
+ /** VAL-1…VAL-8: who wrote it, when, on whose behalf, in which version. */
2640
+ written?: {
2641
+ ver?: number;
2642
+ actor?: string;
2643
+ on_behalf_of?: string | null;
2644
+ at?: string;
2645
+ src?: unknown;
2646
+ absent?: unknown;
2647
+ alternates?: unknown;
2648
+ dated?: unknown;
2649
+ };
2650
+ }
2651
+ /**
2652
+ * REC-53 IN ONE ANSWER: a standard row is its real columns, plus the base
2653
+ * contract, plus its organization's custom fields — three named blocks, never
2654
+ * one flat bag, so nothing can quietly shadow anything.
2655
+ */
2656
+ interface EntityRecordRead {
2657
+ token: string;
2658
+ label: string;
2659
+ type: CustomFieldTableType;
2660
+ id: Uuid;
2661
+ organization_id: Uuid;
2662
+ /** The registry's `title_column` of this row, when it has one. */
2663
+ title: string | null;
2664
+ /** The row's own columns, `custom_fields` removed. */
2665
+ columns: Record<string, unknown>;
2666
+ /** The custom values, by key. */
2667
+ custom: Record<string, unknown>;
2668
+ /** Their envelopes, by key. */
2669
+ custom_written: Record<string, EntityFieldValue["written"]>;
2670
+ /** The definitions, in the organization's own sort order, each with its value. */
2671
+ fields: EntityFieldValue[];
2672
+ live: boolean;
2673
+ }
2674
+ /** One row the filter matched. */
2675
+ interface EntityRecordMatch {
2676
+ id: Uuid;
2677
+ title: string | null;
2678
+ value: unknown;
2679
+ }
2680
+ interface EntityRecordsFound {
2681
+ token: string;
2682
+ label: string;
2683
+ key: string;
2684
+ value: unknown;
2685
+ rows: EntityRecordMatch[];
2686
+ count: number;
2687
+ }
2688
+ /**
2689
+ * What a person knows when they add a column. The SAME spec `fieldDeclare`
2690
+ * takes for a custom table — the store turns it into the document its guards
2691
+ * demand, so a standard table gets the whole type vocabulary rather than a
2692
+ * second, poorer one.
2693
+ */
2694
+ type NewEntityFieldDeclaration = Record<string, unknown> & {
2695
+ label: string;
2696
+ type?: string;
2697
+ options?: string[];
2698
+ };
2699
+ /**
2700
+ * SCR-12. May this person add a column to this standard table, and if not, the
2701
+ * sentence saying why — so the control is ABSENT with a reason rather than dead
2702
+ * when pressed. Filling in the fields that already exist is not admin work.
2703
+ */
2704
+ interface EntityFieldRights {
2705
+ token: string;
2706
+ label: string;
2707
+ may_declare: boolean;
2708
+ reason: string | null;
2709
+ may_fill_in: boolean;
2710
+ }
2711
+
2419
2712
  /**
2420
2713
  * A rule expression as `custom.rule_eval` ACTUALLY evaluates it — read off the
2421
2714
  * door's own body, not invented here. A leaf is the node's name carrying its
@@ -2483,6 +2776,37 @@ interface RuleAnswer {
2483
2776
  applies: boolean;
2484
2777
  answer: unknown;
2485
2778
  }
2779
+ /** One form as `custom.forms` reports it to its owner. */
2780
+ interface FormSummary {
2781
+ form_id: string;
2782
+ table_id: string;
2783
+ title: string | null;
2784
+ slug: string;
2785
+ published_at: string | null;
2786
+ closed_at: string | null;
2787
+ submission_cap: number | null;
2788
+ /** Every answer that arrived, rejected ones excluded from `in_table` and `held`. */
2789
+ responses: number;
2790
+ /** Answers that became records — the only number that means "it is in the table". */
2791
+ in_table: number;
2792
+ /** Answers waiting for a person, because the form's accept Rule did not clear them. */
2793
+ held: number;
2794
+ /** Answers the accept Rule or the decoy turned away. */
2795
+ rejected: number;
2796
+ /** draft · open · closed · full — the store's own word, never derived on a screen. */
2797
+ state: "draft" | "open" | "closed" | "full";
2798
+ quarantine_rule_id: string | null;
2799
+ notify_rule_id: string | null;
2800
+ presentation: Record<string, unknown>;
2801
+ }
2802
+ /**
2803
+ * THE PUBLIC LINK, and the one place its shape is written down.
2804
+ *
2805
+ * The form's own id IS the capability — 122 bits of UUIDv4, exactly as
2806
+ * Typeform's form id in `/to/<id>` is and as an unguessable meeting slug is
2807
+ * here. There is no second secret to keep, and revoking it is closing the form.
2808
+ */
2809
+ declare function publicFormPath(formId: string): string;
2486
2810
 
2487
2811
  /** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
2488
2812
  type AggregateOperation = "count" | "sum" | "avg" | "min" | "max";
@@ -2885,6 +3209,111 @@ interface AnonTokenBinding {
2885
3209
  record_id: Uuid | null;
2886
3210
  mode: "read" | "write";
2887
3211
  }
3212
+ /** The three things that land in the one inbox. Closed, one word each. */
3213
+ type WorkInboxKind = "assignment" | "approval" | "proposal";
3214
+ /** Who filed it: a colleague, or an agent acting for one. */
3215
+ type WorkOrigin = "person" | "agent";
3216
+ /** Where a due date stands, in the store's own words. */
3217
+ type WorkDueState = "overdue" | "due_today" | "scheduled" | "undated" | "finished";
3218
+ /** One row of `custom.work_inbox` — the SAME shape whichever of the three it is. */
3219
+ interface WorkInboxItem {
3220
+ item_id: Uuid;
3221
+ kind: WorkInboxKind;
3222
+ origin: WorkOrigin;
3223
+ title: string;
3224
+ subject_id: Uuid | null;
3225
+ subject_kind: string;
3226
+ summary: string | null;
3227
+ state: string;
3228
+ due_on: Timestamp | null;
3229
+ due_state: WorkDueState | null;
3230
+ /** False for a decided row a person asked to see. A screen shows it, inert. */
3231
+ actionable: boolean;
3232
+ requested_by: Uuid | null;
3233
+ requested_by_name: string | null;
3234
+ at: Timestamp;
3235
+ }
3236
+ /** Which of the three lists `custom.work_list` answers. */
3237
+ type WorkListFlavour = "mine" | "assigned" | "unassigned";
3238
+ /** One row of `custom.work_list`: a record, whose it is, and where it is up to. */
3239
+ interface WorkListItem {
3240
+ record_id: Uuid;
3241
+ table_id: Uuid;
3242
+ table_name: string | null;
3243
+ title: string | null;
3244
+ assignee_id: Uuid | null;
3245
+ assignee_name: string | null;
3246
+ assignee_user_id: Uuid | null;
3247
+ due_on: Timestamp | null;
3248
+ due_state: WorkDueState;
3249
+ status: string | null;
3250
+ terminal: boolean;
3251
+ assigned_by: Uuid | null;
3252
+ updated_at: Timestamp;
3253
+ }
3254
+ /**
3255
+ * One state a record may be moved to, with the model's own answer about whether
3256
+ * it may — and, when it may not, the sentence saying why. A screen offers what
3257
+ * is allowed and explains what is not; it never renders a dead control.
3258
+ */
3259
+ interface WorkRecordState {
3260
+ state_id: Uuid;
3261
+ name: string;
3262
+ sort: number;
3263
+ terminal: boolean;
3264
+ is_current: boolean;
3265
+ allowed: boolean;
3266
+ refusal: string | null;
3267
+ }
3268
+ /** The change a pending approval carries. Two kinds, because two can be applied. */
3269
+ type WorkChange = {
3270
+ kind: "record_patch";
3271
+ patch: Record<string, unknown>;
3272
+ } | {
3273
+ kind: "field_add";
3274
+ field: Record<string, unknown>;
3275
+ };
3276
+ /** Somebody who may decide a particular request, and the reason they may. */
3277
+ interface WorkApprover {
3278
+ user_id: Uuid;
3279
+ name: string;
3280
+ why: string;
3281
+ }
3282
+ /** What `custom.work_approval_request` answers: it is filed, and who it waits on. */
3283
+ interface WorkApprovalFiled {
3284
+ approval_id: Uuid;
3285
+ state: "pending";
3286
+ subject_id: Uuid;
3287
+ subject_kind: string;
3288
+ origin: WorkOrigin;
3289
+ approvers: WorkApprover[];
3290
+ message: string;
3291
+ }
3292
+ /** What a decision answers — including whether the change was actually made. */
3293
+ interface WorkApprovalDecision {
3294
+ approval_id: Uuid;
3295
+ state: "approved" | "declined";
3296
+ subject_id: Uuid;
3297
+ /** The whole point: approving APPLIES the change, in the same transaction. */
3298
+ applied: boolean;
3299
+ field_id: Uuid | null;
3300
+ version: number | null;
3301
+ message: string;
3302
+ }
3303
+ /** What `custom.work_assign` answers: the value, the access, and who holds it now. */
3304
+ interface WorkAssignment {
3305
+ record_id: Uuid;
3306
+ assigned: boolean;
3307
+ assignee: Uuid | null;
3308
+ assignee_user_id: Uuid | null;
3309
+ assignee_name: string | null;
3310
+ was: Uuid | null;
3311
+ due_date: Timestamp | null;
3312
+ version: number | null;
3313
+ /** The share sentence, or why nothing was taken away when un-assigning. */
3314
+ access: string;
3315
+ message: string;
3316
+ }
2888
3317
 
2889
3318
  /**
2890
3319
  * VIS-31. A signed-in OUTSIDER, with the reason in plain English.
@@ -3349,6 +3778,51 @@ interface RecordsClient {
3349
3778
  fieldRetire(args: {
3350
3779
  field_id: Uuid;
3351
3780
  }): Promise<RecordsResult<boolean>>;
3781
+ /** What the registry says about a token, and whether it can hold a value at all. */
3782
+ entityTable(args: {
3783
+ token: string;
3784
+ }): Promise<RecordsResult<EntityTableFacts>>;
3785
+ /** The fields THIS organization added to that standard table. */
3786
+ entityFields(args: {
3787
+ token: string;
3788
+ }): Promise<RecordsResult<Field[]>>;
3789
+ /** Add a column to a standard table. An organization admin's right - it changes the table for everybody. */
3790
+ entityFieldDeclare(args: {
3791
+ token: string;
3792
+ spec: NewEntityFieldDeclaration;
3793
+ }): Promise<RecordsResult<Uuid>>;
3794
+ /** One field's own settings. A TYPE change is refused here by name, as it is on a custom table. */
3795
+ entityFieldUpdate(args: {
3796
+ field_id: Uuid;
3797
+ patch: Record<string, unknown>;
3798
+ }): Promise<RecordsResult<Uuid>>;
3799
+ /** Take a custom field off a standard table. The values already written stay in each row. */
3800
+ entityFieldRetire(args: {
3801
+ field_id: Uuid;
3802
+ }): Promise<RecordsResult<Uuid>>;
3803
+ /** May this person add a column here - and if not, the store's own sentence saying why. */
3804
+ entityFieldRights(args: {
3805
+ token: string;
3806
+ }): Promise<RecordsResult<EntityFieldRights>>;
3807
+ /** REC-53 in one answer: the row's real columns AND its custom values AND the definitions. */
3808
+ entityRecordRead(args: {
3809
+ token: string;
3810
+ record_id: Uuid;
3811
+ }): Promise<RecordsResult<EntityRecordRead>>;
3812
+ /** A patch: a key left out is left alone, a key set to null is cleared with its envelope. */
3813
+ entityValueWrite(args: {
3814
+ token: string;
3815
+ record_id: Uuid;
3816
+ patch: Record<string, unknown>;
3817
+ }): Promise<RecordsResult<EntityRecordRead>>;
3818
+ /** Rows of that standard table with this custom value. Refuses a field nobody declared. */
3819
+ entityRecordsFind(args: {
3820
+ token: string;
3821
+ key: string;
3822
+ value?: unknown;
3823
+ limit?: number;
3824
+ offset?: number;
3825
+ }): Promise<RecordsResult<EntityRecordsFound>>;
3352
3826
  /** The kernel Tables a caller writes a Home, a Field or a Rule into. */
3353
3827
  personKernelId(): Promise<RecordsResult<Uuid>>;
3354
3828
  fieldKernelId(): Promise<RecordsResult<Uuid>>;
@@ -3374,6 +3848,29 @@ interface RecordsClient {
3374
3848
  values: Record<string, unknown>;
3375
3849
  context?: Record<string, unknown>;
3376
3850
  }): Promise<RecordsResult<unknown>>;
3851
+ /**
3852
+ * Write ONE Rule as a real Rule. `recordWrite` into the Rule kernel makes a
3853
+ * valid Rule document that carries `data_class = 'record'`, and every reader
3854
+ * that looks for a Rule looks for the class — `custom.agg_subscriptions`
3855
+ * selects `where data_class = 'rule'` — so a subscription written that way
3856
+ * fires at nobody. This is the door that closes it.
3857
+ */
3858
+ /** This organization's forms, with how many answers arrived and how many are in the table. */
3859
+ forms(args?: {
3860
+ table_id?: Uuid | null;
3861
+ }): Promise<RecordsResult<FormSummary[]>>;
3862
+ /** Create or re-state one form. A question naming no Field of that Table is refused BY NAME. */
3863
+ formDeclare(args: {
3864
+ table_id: Uuid;
3865
+ title: string;
3866
+ questions: unknown[];
3867
+ presentation?: Record<string, unknown> | null;
3868
+ submission_cap?: number | null;
3869
+ quarantine_rule_id?: Uuid | null;
3870
+ notify_rule_id?: Uuid | null;
3871
+ form_id?: Uuid | null;
3872
+ slug?: string | null;
3873
+ }): Promise<RecordsResult<Uuid>>;
3377
3874
  /**
3378
3875
  * Group, bucket, filter and measure INSIDE `custom.record_aggregate`. The
3379
3876
  * aggregate node sits above the visibility join, so what a chart draws is
@@ -3609,6 +4106,86 @@ interface RecordsClient {
3609
4106
  workSlotExpire(args: {
3610
4107
  table_id: Uuid;
3611
4108
  }): Promise<RecordsResult<number>>;
4109
+ /**
4110
+ * THE ONE INBOX. Assignments, approvals and the agent's proposals, in one
4111
+ * ordered list with ONE row shape — PRODUCTS.md row 6. A second queue for the
4112
+ * agent's suggestions is the thing this replaces.
4113
+ */
4114
+ workInbox(args?: {
4115
+ limit?: number;
4116
+ offset?: number;
4117
+ includeDecided?: boolean;
4118
+ }): Promise<RecordsResult<WorkInboxItem[]>>;
4119
+ /** "My work", "work I assigned", "waiting on somebody being chosen". */
4120
+ workList(args?: {
4121
+ flavour?: WorkListFlavour;
4122
+ includeFinished?: boolean;
4123
+ limit?: number;
4124
+ offset?: number;
4125
+ }): Promise<RecordsResult<WorkListItem[]>>;
4126
+ /**
4127
+ * Give one record to one person: the Assignee value AND editor access, in one
4128
+ * transaction. Passing no `user_id` un-assigns and says plainly that nobody's
4129
+ * access was taken away.
4130
+ */
4131
+ workAssign(args: {
4132
+ record_id: Uuid;
4133
+ user_id?: Uuid | null;
4134
+ dueDate?: string | null;
4135
+ clearDue?: boolean;
4136
+ }): Promise<RecordsResult<WorkAssignment>>;
4137
+ /** The states this record may be moved to, and the sentence for each it may not. */
4138
+ workRecordStates(args: {
4139
+ record_id: Uuid;
4140
+ }): Promise<RecordsResult<WorkRecordState[]>>;
4141
+ /** Move it. The store refuses a move the model forbids, in its own words. */
4142
+ workSetState(args: {
4143
+ record_id: Uuid;
4144
+ state_id: Uuid | null;
4145
+ }): Promise<RecordsResult<unknown>>;
4146
+ /** The person-kernel record standing for a signed-in person here. */
4147
+ workPerson(args: {
4148
+ user_id: Uuid;
4149
+ create?: boolean;
4150
+ }): Promise<RecordsResult<Uuid | null>>;
4151
+ /** The templates this person may run, so a picker has ids to offer. */
4152
+ workTemplates(args?: {
4153
+ limit?: number;
4154
+ }): Promise<RecordsResult<Array<{
4155
+ template_id: Uuid;
4156
+ name: string;
4157
+ nodes: number;
4158
+ relations: number;
4159
+ created_at: string;
4160
+ }>>>;
4161
+ /** Who may decide a change about this subject, and why each of them may. */
4162
+ workApprovalApprovers(args: {
4163
+ subject_id: Uuid | null;
4164
+ approver_id?: Uuid | null;
4165
+ }): Promise<RecordsResult<WorkApprover[]>>;
4166
+ /** Ask for a change instead of making it. Viewer on the subject is enough to ASK. */
4167
+ workApprovalRequest(args: {
4168
+ subject_id: Uuid;
4169
+ change: WorkChange;
4170
+ note?: string | null;
4171
+ approver_id?: Uuid | null;
4172
+ origin?: "person" | "agent";
4173
+ conversation_id?: Uuid | null;
4174
+ }): Promise<RecordsResult<WorkApprovalFiled>>;
4175
+ /** Whether THIS person may decide THIS one — so a screen never draws a dead button. */
4176
+ workApprovalMayDecide(args: {
4177
+ approval_id: Uuid;
4178
+ }): Promise<RecordsResult<boolean>>;
4179
+ /** Approve or decline. Approving APPLIES the change, as the person approving. */
4180
+ workApprovalDecide(args: {
4181
+ approval_id: Uuid;
4182
+ approve: boolean;
4183
+ note?: string | null;
4184
+ }): Promise<RecordsResult<WorkApprovalDecision>>;
4185
+ /** One waiting change in full, for the person deciding it or the one who asked. */
4186
+ workApprovalRead(args: {
4187
+ approval_id: Uuid;
4188
+ }): Promise<RecordsResult<Record<string, unknown>>>;
3612
4189
  /** VIS-31. Is this account a signed-in outsider — no NON-personal organization? */
3613
4190
  isExternalPrincipal(args?: {
3614
4191
  user_id?: Uuid | null;
@@ -3656,7 +4233,8 @@ interface RecordsClient {
3656
4233
  */
3657
4234
  ruleDeclare(args: {
3658
4235
  spec: Record<string, unknown>;
3659
- }): Promise<RecordsResult<never>>;
4236
+ rule_id?: Uuid | null;
4237
+ }): Promise<RecordsResult<Uuid>>;
3660
4238
  fieldPropose(proposal: FieldProposal): Promise<RecordsResult<never>>;
3661
4239
  tablePropose(proposal: TableProposal): Promise<RecordsResult<never>>;
3662
4240
  promoteTable(args: {
@@ -3693,6 +4271,21 @@ declare function RecordsProvider({ config, children }: RecordsProviderProps): re
3693
4271
  * mounted the provider is the silent failure this throws instead of.
3694
4272
  */
3695
4273
  declare function useRecordsClient(): RecordsClient;
4274
+ /**
4275
+ * The client IF one is mounted, and `null` if none is — for the ONE case where
4276
+ * that is not a mistake: a screen served to somebody who has no account.
4277
+ *
4278
+ * A public form page (DOOR-17) renders for a stranger. There is no session to
4279
+ * build a client from, no organization the caller may name and no read of the
4280
+ * table it writes into; the server resolved the form through
4281
+ * `custom.form_public` and hands the screen its questions and a submit port.
4282
+ * `useRecordsClient` is right to throw for every other caller — a hook that
4283
+ * quietly did nothing is the silent failure it exists to prevent — so this is a
4284
+ * SECOND, NAMED hook rather than a softening of the first. A component using it
4285
+ * must work with `null`, and the ones in `@ai-matrx/records-ui` say out loud
4286
+ * which half of themselves is unavailable when it is.
4287
+ */
4288
+ declare function useOptionalRecordsClient(): RecordsClient | null;
3696
4289
  /** For a screen that wants to show who it is acting as (AGT-N-4). */
3697
4290
  declare function useRecordsActor(): RecordsActor;
3698
4291
 
@@ -3805,6 +4398,57 @@ interface UseFieldMutation {
3805
4398
  * has not declared. A screen that reached for the record writer here is the
3806
4399
  * screen that spent 19 September refusing every column a person tried to add.
3807
4400
  */
4401
+ /**
4402
+ * A STANDARD BUSINESS TABLE'S CUSTOM FIELDS, by its registry token.
4403
+ *
4404
+ * `useFields(tableId)` is about one of YOUR OWN tables. This is the other half:
4405
+ * the fields an organization added to a CRM contact, a deal, a note - any of the
4406
+ * 643 tables the registry types Entity or Detail - and there is no per-entity
4407
+ * code here or in any screen that uses it.
4408
+ */
4409
+ declare function useEntityFields(token: string | null): Async<Field[]>;
4410
+ /**
4411
+ * REC-53 in one answer: a standard row's real columns AND its organization's
4412
+ * custom values AND the definitions that describe them. A row the person may
4413
+ * not open comes back as the store's own refusal, because the door reads it AS
4414
+ * them through the table's own row-level security.
4415
+ */
4416
+ declare function useEntityRecord(token: string | null, recordId: Uuid | null): Async<EntityRecordRead | null>;
4417
+ /** What the registry says about a token - and whether it can hold a value at all. */
4418
+ declare function useEntityTable(token: string | null): Async<EntityTableFacts | null>;
4419
+ /** SCR-12: the answer a screen needs to make "Add field" absent-or-honest. */
4420
+ declare function useEntityFieldRights(token: string | null): Async<EntityFieldRights | null>;
4421
+ interface UseEntityFieldMutation {
4422
+ /** Add a column to a standard table. Refused for anybody but an organization admin. */
4423
+ declare: (args: {
4424
+ token: string;
4425
+ spec: NewEntityFieldDeclaration;
4426
+ }) => Promise<Uuid | null>;
4427
+ update: (args: {
4428
+ field_id: Uuid;
4429
+ patch: Record<string, unknown>;
4430
+ }) => Promise<Uuid | null>;
4431
+ retire: (args: {
4432
+ field_id: Uuid;
4433
+ }) => Promise<Uuid | null>;
4434
+ /** Set custom values on one standard row. A key left out is left alone. */
4435
+ write: (args: {
4436
+ token: string;
4437
+ record_id: Uuid;
4438
+ patch: Record<string, unknown>;
4439
+ }) => Promise<EntityRecordRead | null>;
4440
+ saving: boolean;
4441
+ error: RecordsError | null;
4442
+ clearError: () => void;
4443
+ }
4444
+ /**
4445
+ * Changing a standard table's custom fields, and filling them in. Deliberately
4446
+ * ONE hook for both, because the store keeps them the same way: the definition
4447
+ * is a record in the field kernel and the value is in the row's own
4448
+ * `custom_fields` column, and a screen that had two mutation hooks would have
4449
+ * two places to get the refusal wording from.
4450
+ */
4451
+ declare function useEntityFieldMutation(): UseEntityFieldMutation;
3808
4452
  declare function useFieldMutation(): UseFieldMutation;
3809
4453
  /**
3810
4454
  * DYN-14 / AGT-N-7. A merge field's value — and while the resolver's server half
@@ -3813,4 +4457,4 @@ declare function useFieldMutation(): UseFieldMutation;
3813
4457
  */
3814
4458
  declare function useMergeField(key: string | null, state?: Record<string, unknown>): MergeFieldResolution | null;
3815
4459
 
3816
- 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, DELIVERIES, type Delivery, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, 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 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 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, RecordsProvider, type RecordsProviderProps, 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 UseFieldMutation, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkAssignmentField, type WorkGraph, type WorkInstantiation, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, err, highestLevel, isRecordsErr, measureKey, ok, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };
4460
+ 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, RecordsProvider, type RecordsProviderProps, 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 UseEntityFieldMutation, type UseFieldMutation, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, 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, useEntityFieldMutation, useEntityFieldRights, useEntityFields, useEntityRecord, useEntityTable, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useOptionalRecordsClient, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };