@ai-matrx/records 0.16.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.cts CHANGED
@@ -454,6 +454,21 @@ declare const STORE_DOORS: readonly [{
454
454
  readonly args: "";
455
455
  readonly returns: "TABLE(role_name text, object_name text, privilege text)";
456
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";
457
472
  }, {
458
473
  readonly name: "computed_provenance";
459
474
  readonly args: "p_organization_id uuid, p_record_id uuid";
@@ -614,6 +629,11 @@ declare const STORE_DOORS: readonly [{
614
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";
615
630
  readonly returns: "uuid";
616
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";
617
637
  }, {
618
638
  readonly name: "doc_sign";
619
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";
@@ -639,6 +659,16 @@ declare const STORE_DOORS: readonly [{
639
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";
640
660
  readonly returns: "uuid";
641
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";
642
672
  }, {
643
673
  readonly name: "doc_template_read";
644
674
  readonly args: "p_organization_id uuid, p_template_id uuid";
@@ -649,6 +679,11 @@ declare const STORE_DOORS: readonly [{
649
679
  readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
650
680
  readonly returns: "uuid";
651
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";
652
687
  }, {
653
688
  readonly name: "doc_token_pattern";
654
689
  readonly args: "";
@@ -789,6 +824,11 @@ declare const STORE_DOORS: readonly [{
789
824
  readonly args: "p_organization_id uuid, p_field_id uuid";
790
825
  readonly returns: "TABLE(kind text, dependant_id uuid, label text, how text)";
791
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";
792
832
  }, {
793
833
  readonly name: "field_kernel_id";
794
834
  readonly args: "";
@@ -879,11 +919,31 @@ declare const STORE_DOORS: readonly [{
879
919
  readonly args: "p_field custom.record, p_action text DEFAULT 'read'::text";
880
920
  readonly returns: "jsonb";
881
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";
882
937
  }, {
883
938
  readonly name: "history_prune";
884
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";
885
940
  readonly returns: "jsonb";
886
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";
887
947
  }, {
888
948
  readonly name: "history_retention";
889
949
  readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
@@ -1484,6 +1544,11 @@ declare const STORE_DOORS: readonly [{
1484
1544
  readonly args: "p_organization_id uuid, p_record_id uuid";
1485
1545
  readonly returns: "timestamp with time zone";
1486
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";
1487
1552
  }, {
1488
1553
  readonly name: "record_relation_edges";
1489
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";
@@ -1504,6 +1569,16 @@ declare const STORE_DOORS: readonly [{
1504
1569
  readonly args: "p_organization_id uuid, p_record_id uuid";
1505
1570
  readonly returns: "void";
1506
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";
1507
1582
  }, {
1508
1583
  readonly name: "record_state_as_of";
1509
1584
  readonly args: "p_record_id uuid, p_at timestamp with time zone";
@@ -1764,6 +1839,11 @@ declare const STORE_DOORS: readonly [{
1764
1839
  readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
1765
1840
  readonly returns: "boolean";
1766
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";
1767
1847
  }, {
1768
1848
  readonly name: "subscription_mute";
1769
1849
  readonly args: "p_organization_id uuid, p_rule_id uuid, p_muted boolean DEFAULT true";
@@ -1889,6 +1969,11 @@ declare const STORE_DOORS: readonly [{
1889
1969
  readonly args: "p_organization_id uuid, p_record_id uuid, p_key text";
1890
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)";
1891
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";
1892
1977
  }, {
1893
1978
  readonly name: "value_versions";
1894
1979
  readonly args: "p_old jsonb, p_new jsonb";
@@ -2125,6 +2210,10 @@ declare const STORE_KNOBS: readonly [{
2125
2210
  readonly key: "consumer_checkout_enabled";
2126
2211
  readonly value: "false";
2127
2212
  readonly type: "boolean";
2213
+ }, {
2214
+ readonly key: "consumer_context_enabled";
2215
+ readonly value: "false";
2216
+ readonly type: "boolean";
2128
2217
  }, {
2129
2218
  readonly key: "consumer_education_enabled";
2130
2219
  readonly value: "false";
@@ -2250,13 +2339,13 @@ declare const STORE_KNOBS: readonly [{
2250
2339
  */
2251
2340
  declare const STORE_REFUSAL_CODES: readonly [{
2252
2341
  readonly code: "02000";
2253
- 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_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_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_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";
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";
2254
2343
  }, {
2255
2344
  readonly code: "0A000";
2256
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";
2257
2346
  }, {
2258
2347
  readonly code: "22004";
2259
- 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,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,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";
2260
2349
  }, {
2261
2350
  readonly code: "22007";
2262
2351
  readonly raised_by: "dashboard_window_sql";
@@ -2265,10 +2354,10 @@ declare const STORE_REFUSAL_CODES: readonly [{
2265
2354
  readonly raised_by: "rule_eval";
2266
2355
  }, {
2267
2356
  readonly code: "22023";
2268
- 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,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";
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";
2269
2358
  }, {
2270
2359
  readonly code: "23503";
2271
- readonly raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,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";
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";
2272
2361
  }, {
2273
2362
  readonly code: "23505";
2274
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";
@@ -2280,7 +2369,7 @@ declare const STORE_REFUSAL_CODES: readonly [{
2280
2369
  readonly raised_by: "has_visibility_at";
2281
2370
  }, {
2282
2371
  readonly code: "42501";
2283
- 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,migrate_reclass,my_levels,organization_clear,portal_declare,portal_invitation,portal_invite,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,share_grant,subscription_mute,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";
2284
2373
  }, {
2285
2374
  readonly code: "42703";
2286
2375
  readonly raised_by: "entity_table,portal_declare";
@@ -3453,7 +3542,6 @@ interface DocSignatureCheck {
3453
3542
  /** `custom.doc_template` — a body with tokens, and the Table it renders. */
3454
3543
  interface DocTemplateRow {
3455
3544
  id: Uuid;
3456
- organization_id: Uuid;
3457
3545
  renders_table_id: Uuid;
3458
3546
  name: string;
3459
3547
  body: string;
package/dist/index.d.ts CHANGED
@@ -454,6 +454,21 @@ declare const STORE_DOORS: readonly [{
454
454
  readonly args: "";
455
455
  readonly returns: "TABLE(role_name text, object_name text, privilege text)";
456
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";
457
472
  }, {
458
473
  readonly name: "computed_provenance";
459
474
  readonly args: "p_organization_id uuid, p_record_id uuid";
@@ -614,6 +629,11 @@ declare const STORE_DOORS: readonly [{
614
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";
615
630
  readonly returns: "uuid";
616
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";
617
637
  }, {
618
638
  readonly name: "doc_sign";
619
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";
@@ -639,6 +659,16 @@ declare const STORE_DOORS: readonly [{
639
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";
640
660
  readonly returns: "uuid";
641
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";
642
672
  }, {
643
673
  readonly name: "doc_template_read";
644
674
  readonly args: "p_organization_id uuid, p_template_id uuid";
@@ -649,6 +679,11 @@ declare const STORE_DOORS: readonly [{
649
679
  readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
650
680
  readonly returns: "uuid";
651
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";
652
687
  }, {
653
688
  readonly name: "doc_token_pattern";
654
689
  readonly args: "";
@@ -789,6 +824,11 @@ declare const STORE_DOORS: readonly [{
789
824
  readonly args: "p_organization_id uuid, p_field_id uuid";
790
825
  readonly returns: "TABLE(kind text, dependant_id uuid, label text, how text)";
791
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";
792
832
  }, {
793
833
  readonly name: "field_kernel_id";
794
834
  readonly args: "";
@@ -879,11 +919,31 @@ declare const STORE_DOORS: readonly [{
879
919
  readonly args: "p_field custom.record, p_action text DEFAULT 'read'::text";
880
920
  readonly returns: "jsonb";
881
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";
882
937
  }, {
883
938
  readonly name: "history_prune";
884
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";
885
940
  readonly returns: "jsonb";
886
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";
887
947
  }, {
888
948
  readonly name: "history_retention";
889
949
  readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid";
@@ -1484,6 +1544,11 @@ declare const STORE_DOORS: readonly [{
1484
1544
  readonly args: "p_organization_id uuid, p_record_id uuid";
1485
1545
  readonly returns: "timestamp with time zone";
1486
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";
1487
1552
  }, {
1488
1553
  readonly name: "record_relation_edges";
1489
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";
@@ -1504,6 +1569,16 @@ declare const STORE_DOORS: readonly [{
1504
1569
  readonly args: "p_organization_id uuid, p_record_id uuid";
1505
1570
  readonly returns: "void";
1506
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";
1507
1582
  }, {
1508
1583
  readonly name: "record_state_as_of";
1509
1584
  readonly args: "p_record_id uuid, p_at timestamp with time zone";
@@ -1764,6 +1839,11 @@ declare const STORE_DOORS: readonly [{
1764
1839
  readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
1765
1840
  readonly returns: "boolean";
1766
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";
1767
1847
  }, {
1768
1848
  readonly name: "subscription_mute";
1769
1849
  readonly args: "p_organization_id uuid, p_rule_id uuid, p_muted boolean DEFAULT true";
@@ -1889,6 +1969,11 @@ declare const STORE_DOORS: readonly [{
1889
1969
  readonly args: "p_organization_id uuid, p_record_id uuid, p_key text";
1890
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)";
1891
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";
1892
1977
  }, {
1893
1978
  readonly name: "value_versions";
1894
1979
  readonly args: "p_old jsonb, p_new jsonb";
@@ -2125,6 +2210,10 @@ declare const STORE_KNOBS: readonly [{
2125
2210
  readonly key: "consumer_checkout_enabled";
2126
2211
  readonly value: "false";
2127
2212
  readonly type: "boolean";
2213
+ }, {
2214
+ readonly key: "consumer_context_enabled";
2215
+ readonly value: "false";
2216
+ readonly type: "boolean";
2128
2217
  }, {
2129
2218
  readonly key: "consumer_education_enabled";
2130
2219
  readonly value: "false";
@@ -2250,13 +2339,13 @@ declare const STORE_KNOBS: readonly [{
2250
2339
  */
2251
2340
  declare const STORE_REFUSAL_CODES: readonly [{
2252
2341
  readonly code: "02000";
2253
- 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_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_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_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";
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";
2254
2343
  }, {
2255
2344
  readonly code: "0A000";
2256
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";
2257
2346
  }, {
2258
2347
  readonly code: "22004";
2259
- 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,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,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";
2260
2349
  }, {
2261
2350
  readonly code: "22007";
2262
2351
  readonly raised_by: "dashboard_window_sql";
@@ -2265,10 +2354,10 @@ declare const STORE_REFUSAL_CODES: readonly [{
2265
2354
  readonly raised_by: "rule_eval";
2266
2355
  }, {
2267
2356
  readonly code: "22023";
2268
- 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,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";
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";
2269
2358
  }, {
2270
2359
  readonly code: "23503";
2271
- readonly raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,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";
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";
2272
2361
  }, {
2273
2362
  readonly code: "23505";
2274
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";
@@ -2280,7 +2369,7 @@ declare const STORE_REFUSAL_CODES: readonly [{
2280
2369
  readonly raised_by: "has_visibility_at";
2281
2370
  }, {
2282
2371
  readonly code: "42501";
2283
- 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,migrate_reclass,my_levels,organization_clear,portal_declare,portal_invitation,portal_invite,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,share_grant,subscription_mute,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";
2284
2373
  }, {
2285
2374
  readonly code: "42703";
2286
2375
  readonly raised_by: "entity_table,portal_declare";
@@ -3453,7 +3542,6 @@ interface DocSignatureCheck {
3453
3542
  /** `custom.doc_template` — a body with tokens, and the Table it renders. */
3454
3543
  interface DocTemplateRow {
3455
3544
  id: Uuid;
3456
- organization_id: Uuid;
3457
3545
  renders_table_id: Uuid;
3458
3546
  name: string;
3459
3547
  body: string;
package/dist/index.js CHANGED
@@ -263,6 +263,9 @@ var STORE_DOORS = [
263
263
  { name: "choice_synonyms_in", args: "p_map jsonb, p_token text", returns: "text[]", security: "invoker" },
264
264
  { name: "choice_words", args: "p_field jsonb", returns: "text", security: "invoker" },
265
265
  { name: "client_write_grants", args: "", returns: "TABLE(role_name text, object_name text, privilege text)", security: "invoker" },
266
+ { name: "comment_mention_deliver", 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", returns: "uuid", security: "definer" },
267
+ { name: "comment_thread", args: "p_organization_id uuid, p_record_id uuid, p_include_resolved boolean DEFAULT false", returns: "jsonb", security: "definer" },
268
+ { name: "comment_write", 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[]", returns: "jsonb", security: "definer" },
266
269
  { name: "computed_provenance", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(field_key text, field_id uuid, value jsonb, rule_id uuid, rule_version integer, computed_at timestamp with time zone)", security: "invoker" },
267
270
  { name: "containment_chain", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(ancestor_id uuid, depth integer)", security: "invoker" },
268
271
  { name: "containment_depth_ceiling", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "integer", security: "invoker" },
@@ -295,13 +298,17 @@ var STORE_DOORS = [
295
298
  { name: "doc_render_document", args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid", returns: "uuid", security: "definer" },
296
299
  { name: "doc_render_read", args: "p_organization_id uuid, p_render_id uuid", returns: "jsonb", security: "definer" },
297
300
  { name: "doc_render_write", 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", returns: "uuid", security: "definer" },
301
+ { name: "doc_renders", args: "p_organization_id uuid, p_record_id uuid", 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)", security: "definer" },
298
302
  { name: "doc_sign", 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", returns: "uuid", security: "definer" },
299
303
  { name: "doc_signature_field_ok", args: "p_field_data jsonb", returns: "boolean", security: "invoker" },
300
304
  { name: "doc_signature_intact", args: "p_organization_id uuid, p_signature_id uuid", returns: "jsonb", security: "invoker" },
301
305
  { name: "doc_signature_read", args: "p_organization_id uuid, p_signature_id uuid", returns: "jsonb", security: "definer" },
302
306
  { name: "doc_signature_write", 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", returns: "uuid", security: "definer" },
307
+ { name: "doc_signatures", args: "p_organization_id uuid, p_record_id uuid", 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)", security: "definer" },
308
+ { name: "doc_template_delete", args: "p_organization_id uuid, p_template_id uuid", returns: "boolean", security: "definer" },
303
309
  { name: "doc_template_read", args: "p_organization_id uuid, p_template_id uuid", returns: "jsonb", security: "definer" },
304
310
  { name: "doc_template_save", args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid", returns: "uuid", security: "definer" },
311
+ { name: "doc_templates", args: "p_organization_id uuid, p_table_id uuid", 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)", security: "definer" },
305
312
  { name: "doc_token_pattern", args: "", returns: "text", security: "invoker" },
306
313
  { name: "doc_tokens", args: "p_body text", returns: "TABLE(ordinal integer, raw text, field_id uuid)", security: "invoker" },
307
314
  { name: "doc_unresolved_tokens", args: "p_organization_id uuid, p_table_id uuid, p_body text", returns: "TABLE(raw text, field_id uuid, why text)", security: "invoker" },
@@ -330,6 +337,7 @@ var STORE_DOORS = [
330
337
  { name: "field_behaviour", args: "p_field_data jsonb", returns: "text", security: "invoker" },
331
338
  { name: "field_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
332
339
  { name: "field_dependants", args: "p_organization_id uuid, p_field_id uuid", returns: "TABLE(kind text, dependant_id uuid, label text, how text)", security: "definer" },
340
+ { name: "field_history", 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", 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)", security: "definer" },
333
341
  { name: "field_kernel_id", args: "", returns: "uuid", security: "invoker" },
334
342
  { name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "definer" },
335
343
  { name: "field_retire", args: "p_organization_id uuid, p_field_id uuid", returns: "boolean", security: "definer" },
@@ -348,7 +356,11 @@ var STORE_DOORS = [
348
356
  { name: "has_visibility", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
349
357
  { name: "has_visibility_at", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, p_organization_id uuid DEFAULT NULL::uuid, p_min_version bigint DEFAULT NULL::bigint", returns: "boolean", security: "definer" },
350
358
  { name: "hidden_field_notice", args: "p_field custom.record, p_action text DEFAULT 'read'::text", returns: "jsonb", security: "invoker" },
359
+ { name: "history_actor", args: "p_tier text, p_document jsonb, p_actor_id uuid, p_people jsonb", returns: "jsonb", security: "invoker" },
360
+ { name: "history_changes", args: "p_organization_id uuid, p_table_id uuid, p_old jsonb, p_new jsonb", returns: "jsonb", security: "invoker" },
361
+ { name: "history_people", args: "p_organization_id uuid, p_ids uuid[]", returns: "jsonb", security: "definer" },
351
362
  { name: "history_prune", args: "p_organization_id uuid, p_scope text DEFAULT 'values'::text, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true", returns: "jsonb", security: "definer" },
363
+ { name: "history_restore_body", args: "p_current jsonb, p_target jsonb, p_field_key text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
352
364
  { name: "history_retention", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
353
365
  { name: "history_retention_floor_raise", args: "p_organization_id uuid, p_days integer", returns: "integer", security: "definer" },
354
366
  { name: "history_retention_set", args: "p_organization_id uuid, p_table_id uuid, p_days integer", returns: "integer", security: "definer" },
@@ -469,10 +481,13 @@ var STORE_DOORS = [
469
481
  { name: "record_card", args: "p_viewer uuid, p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
470
482
  { name: "record_carrying_edges", args: "p_id uuid, p_data_class text, p_data jsonb, p_deleted_at timestamp with time zone", returns: "TABLE(container_id uuid, item_id uuid, edge_role text)", security: "invoker" },
471
483
  { name: "record_delete", args: "p_organization_id uuid, p_record_id uuid", returns: "timestamp with time zone", security: "definer" },
484
+ { name: "record_history", args: "p_organization_id uuid, p_record_id uuid, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0", returns: "TABLE(version integer, occurred_at timestamp with time zone, operation text, operation_label text, actor jsonb, changes jsonb, migration_id uuid, undoable boolean)", security: "definer" },
472
485
  { name: "record_relation_edges", 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", returns: "TABLE(target_id uuid, edge_role text, field_id uuid, ord integer)", security: "invoker" },
473
486
  { name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
474
487
  { name: "record_resolve", args: "p_organization_id uuid, p_id uuid", returns: "jsonb", security: "definer" },
475
488
  { name: "record_restore", args: "p_organization_id uuid, p_record_id uuid", returns: "void", security: "definer" },
489
+ { name: "record_restore_preview", args: "p_organization_id uuid, p_record_id uuid, p_version integer, p_field_key text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
490
+ { name: "record_restore_version", args: "p_organization_id uuid, p_record_id uuid, p_version integer", returns: "jsonb", security: "definer" },
476
491
  { name: "record_state_as_of", args: "p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
477
492
  { name: "record_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "definer" },
478
493
  { name: "record_update", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer", returns: "integer", security: "definer" },
@@ -525,6 +540,7 @@ var STORE_DOORS = [
525
540
  { name: "stamp_value_envelopes", args: "p_data jsonb, p_actor text, p_on_behalf_of text, p_at timestamp with time zone", returns: "jsonb", security: "invoker" },
526
541
  { name: "storage_modes", args: "", returns: "text[]", security: "invoker" },
527
542
  { name: "store_is_open", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "invoker" },
543
+ { name: "subscription_cadences", args: "p_organization_id uuid", returns: "text[]", security: "definer" },
528
544
  { name: "subscription_mute", args: "p_organization_id uuid, p_rule_id uuid, p_muted boolean DEFAULT true", returns: "boolean", security: "definer" },
529
545
  { name: "subscriptions", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", 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)", security: "definer" },
530
546
  { name: "table_capacity", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
@@ -550,6 +566,7 @@ var STORE_DOORS = [
550
566
  { name: "value_envelope_ok", args: "p_data jsonb", returns: "boolean", security: "invoker" },
551
567
  { name: "value_envelope_refusal", args: "p_data jsonb", returns: "text", security: "invoker" },
552
568
  { name: "value_read", args: "p_organization_id uuid, p_record_id uuid, p_key text", 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)", security: "definer" },
569
+ { name: "value_restore", args: "p_organization_id uuid, p_record_id uuid, p_field_key text, p_version integer", returns: "jsonb", security: "definer" },
553
570
  { name: "value_versions", args: "p_old jsonb, p_new jsonb", returns: "jsonb", security: "invoker" },
554
571
  { name: "visibility_ancestors", args: "p_item_type text, p_item_id uuid", returns: "TABLE(container_type text, container_id uuid, depth integer, max_level permission_level)", security: "definer" },
555
572
  { name: "visibility_as_of", args: "p_organization_id uuid, p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(principal_kind text, principal_id uuid, level permission_level, through_kind text, through_id uuid, reason text, replayed boolean, held_from timestamp with time zone, held_to timestamp with time zone)", security: "definer" },
@@ -600,6 +617,7 @@ var STORE_KNOBS = [
600
617
  { key: "code_paths_enabled", value: "false", type: "boolean" },
601
618
  { key: "consumer_chat_seeding_enabled", value: "false", type: "boolean" },
602
619
  { key: "consumer_checkout_enabled", value: "false", type: "boolean" },
620
+ { key: "consumer_context_enabled", value: "false", type: "boolean" },
603
621
  { key: "consumer_education_enabled", value: "false", type: "boolean" },
604
622
  { key: "consumer_extension_enabled", value: "false", type: "boolean" },
605
623
  { key: "consumer_grid_enabled", value: "false", type: "boolean" },
@@ -631,17 +649,17 @@ var STORE_KNOBS = [
631
649
  { key: "world_publish_enabled", value: "false", type: "boolean" }
632
650
  ];
633
651
  var STORE_REFUSAL_CODES = [
634
- { code: "02000", 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_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_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_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" },
652
+ { code: "02000", 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" },
635
653
  { code: "0A000", raised_by: "external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_assign" },
636
- { code: "22004", 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,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,work_approval_decide,work_approval_request,work_template_declare" },
654
+ { code: "22004", 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" },
637
655
  { code: "22007", raised_by: "dashboard_window_sql" },
638
656
  { code: "22012", raised_by: "rule_eval" },
639
- { code: "22023", 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,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" },
640
- { code: "23503", raised_by: "_containment_guard,_field_document_for,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,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" },
657
+ { code: "22023", 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" },
658
+ { code: "23503", 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" },
641
659
  { code: "23505", 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" },
642
660
  { code: "23514", 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" },
643
661
  { code: "40001", raised_by: "has_visibility_at" },
644
- { code: "42501", 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,migrate_reclass,my_levels,organization_clear,portal_declare,portal_invitation,portal_invite,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,share_grant,subscription_mute,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
662
+ { code: "42501", 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" },
645
663
  { code: "42703", raised_by: "entity_table,portal_declare" },
646
664
  { code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,promote_field" },
647
665
  { code: "54001", raised_by: "record_delete" },