@ai-matrx/records 0.6.2 → 0.8.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.
@@ -182,11 +182,21 @@ declare const STORE_DOORS: readonly [{
182
182
  readonly args: "p_declared text";
183
183
  readonly returns: "text";
184
184
  readonly security: "invoker";
185
+ }, {
186
+ readonly name: "agent_change_approval";
187
+ readonly args: "p_organization uuid, p_conversation uuid DEFAULT NULL::uuid, p_table uuid DEFAULT NULL::uuid";
188
+ readonly returns: "jsonb";
189
+ readonly security: "definer";
185
190
  }, {
186
191
  readonly name: "agent_context";
187
192
  readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 50";
188
193
  readonly returns: "jsonb";
189
194
  readonly security: "invoker";
195
+ }, {
196
+ readonly name: "agent_table_claim";
197
+ readonly args: "p_organization uuid, p_table uuid, p_conversation uuid DEFAULT NULL::uuid";
198
+ readonly returns: "void";
199
+ readonly security: "definer";
190
200
  }, {
191
201
  readonly name: "agg_assert_key";
192
202
  readonly args: "p_key text";
@@ -272,6 +282,11 @@ declare const STORE_DOORS: readonly [{
272
282
  readonly args: "p_organization_id uuid, p_form_id uuid, p_bucket text, p_token_id uuid DEFAULT NULL::uuid";
273
283
  readonly returns: "integer";
274
284
  readonly security: "definer";
285
+ }, {
286
+ readonly name: "anon_submissions";
287
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_state text DEFAULT NULL::text, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0";
288
+ readonly returns: "TABLE(id uuid, form_id uuid, inbound_id uuid, table_id uuid, source text, state text, payload jsonb, raw_payload jsonb, client_key text, record_id uuid, remote_origin text, rejection_reason text, created_at timestamp with time zone, cleared_at timestamp with time zone)";
289
+ readonly security: "definer";
275
290
  }, {
276
291
  readonly name: "anon_token_issue";
277
292
  readonly args: "p_organization_id uuid, p_mode text, p_allowed_origins jsonb, p_form_id uuid DEFAULT NULL::uuid, p_saved_view_id uuid DEFAULT NULL::uuid, p_record_id uuid DEFAULT NULL::uuid, p_expires_at timestamp with time zone DEFAULT NULL::timestamp with time zone";
@@ -312,6 +327,16 @@ declare const STORE_DOORS: readonly [{
312
327
  readonly args: "p_organization_id uuid, p_door text";
313
328
  readonly returns: "void";
314
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";
315
340
  }, {
316
341
  readonly name: "assert_may_know_table";
317
342
  readonly args: "p_organization_id uuid, p_table_id uuid, p_door text";
@@ -347,6 +372,16 @@ declare const STORE_DOORS: readonly [{
347
372
  readonly args: "";
348
373
  readonly returns: "name";
349
374
  readonly security: "invoker";
375
+ }, {
376
+ readonly name: "carrying_edges_in";
377
+ readonly args: "p_organization_id uuid";
378
+ readonly returns: "TABLE(container_type text, container_id uuid, item_type text, item_id uuid, conveys_max permission_level)";
379
+ readonly security: "definer";
380
+ }, {
381
+ readonly name: "carrying_edges_of";
382
+ readonly args: "p_item_type text, p_item_id uuid";
383
+ readonly returns: "TABLE(container_type text, container_id uuid, conveys_max permission_level)";
384
+ readonly security: "definer";
350
385
  }, {
351
386
  readonly name: "client_write_grants";
352
387
  readonly args: "";
@@ -392,6 +427,11 @@ declare const STORE_DOORS: readonly [{
392
427
  readonly args: "p_organization_id uuid, p_record_id uuid";
393
428
  readonly returns: "uuid[]";
394
429
  readonly security: "invoker";
430
+ }, {
431
+ readonly name: "delete_preview";
432
+ readonly args: "p_organization_id uuid, p_record_id uuid";
433
+ readonly returns: "jsonb";
434
+ readonly security: "definer";
395
435
  }, {
396
436
  readonly name: "delete_rule";
397
437
  readonly args: "p_organization_id uuid, p_record_id uuid, p_apply boolean DEFAULT true";
@@ -442,6 +482,11 @@ declare const STORE_DOORS: readonly [{
442
482
  readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid";
443
483
  readonly returns: "uuid";
444
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";
445
490
  }, {
446
491
  readonly name: "doc_render_write";
447
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";
@@ -462,11 +507,21 @@ declare const STORE_DOORS: readonly [{
462
507
  readonly args: "p_organization_id uuid, p_signature_id uuid";
463
508
  readonly returns: "jsonb";
464
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";
465
515
  }, {
466
516
  readonly name: "doc_signature_write";
467
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";
468
518
  readonly returns: "uuid";
469
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";
470
525
  }, {
471
526
  readonly name: "doc_template_save";
472
527
  readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
@@ -507,6 +562,51 @@ declare const STORE_DOORS: readonly [{
507
562
  readonly args: "p_user_id uuid, p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text";
508
563
  readonly returns: "permission_level";
509
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";
510
610
  }, {
511
611
  readonly name: "export_records";
512
612
  readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000";
@@ -566,7 +666,7 @@ declare const STORE_DOORS: readonly [{
566
666
  readonly name: "field_dependants";
567
667
  readonly args: "p_organization_id uuid, p_field_id uuid";
568
668
  readonly returns: "TABLE(kind text, dependant_id uuid, label text, how text)";
569
- readonly security: "invoker";
669
+ readonly security: "definer";
570
670
  }, {
571
671
  readonly name: "field_kernel_id";
572
672
  readonly args: "";
@@ -602,11 +702,46 @@ declare const STORE_DOORS: readonly [{
602
702
  readonly args: "";
603
703
  readonly returns: "uuid";
604
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";
605
735
  }, {
606
736
  readonly name: "formula_value";
607
737
  readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb";
608
738
  readonly returns: "jsonb";
609
739
  readonly security: "invoker";
740
+ }, {
741
+ readonly name: "guard_refusals_are_complete";
742
+ readonly args: "";
743
+ readonly returns: "TABLE(guard text, said text)";
744
+ readonly security: "invoker";
610
745
  }, {
611
746
  readonly name: "has_visibility";
612
747
  readonly args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
@@ -762,6 +897,11 @@ declare const STORE_DOORS: readonly [{
762
897
  readonly args: "p_organization_id uuid, p_record_id uuid";
763
898
  readonly returns: "TABLE(version integer, changed_at timestamp with time zone, changed_by uuid, summary text, operation text, changed_fields jsonb)";
764
899
  readonly security: "definer";
900
+ }, {
901
+ readonly name: "is_a_retirement";
902
+ readonly args: "p_old_deleted timestamp with time zone, p_new_deleted timestamp with time zone, p_old_data jsonb, p_new_data jsonb, p_old_table uuid, p_new_table uuid, p_old_org uuid, p_new_org uuid, p_old_class text, p_new_class text";
903
+ readonly returns: "boolean";
904
+ readonly security: "invoker";
765
905
  }, {
766
906
  readonly name: "lookup_value";
767
907
  readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb";
@@ -826,7 +966,7 @@ declare const STORE_DOORS: readonly [{
826
966
  readonly name: "migrate_retype";
827
967
  readonly args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text";
828
968
  readonly returns: "jsonb";
829
- readonly security: "invoker";
969
+ readonly security: "definer";
830
970
  }, {
831
971
  readonly name: "migrate_split";
832
972
  readonly args: "p_organization_id uuid, p_record_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text";
@@ -837,6 +977,31 @@ declare const STORE_DOORS: readonly [{
837
977
  readonly args: "p_organization_id uuid, p_log_id uuid";
838
978
  readonly returns: "jsonb";
839
979
  readonly security: "definer";
980
+ }, {
981
+ readonly name: "migrations";
982
+ readonly args: "p_organization_id uuid, p_target_id uuid DEFAULT NULL::uuid, p_limit integer DEFAULT 100";
983
+ readonly returns: "TABLE(id uuid, verb text, target_kind text, target_id uuid, note text, applied_at timestamp with time zone, applied_by uuid, undone_at timestamp with time zone)";
984
+ readonly security: "definer";
985
+ }, {
986
+ readonly name: "my_level";
987
+ readonly args: "p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text";
988
+ readonly returns: "permission_level";
989
+ readonly security: "definer";
990
+ }, {
991
+ readonly name: "my_levels";
992
+ readonly args: "p_organization_id uuid, p_ids jsonb, p_type text DEFAULT 'record'::text";
993
+ readonly returns: "TABLE(id uuid, level permission_level)";
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";
840
1005
  }, {
841
1006
  readonly name: "organization_kernel_id";
842
1007
  readonly args: "";
@@ -1037,6 +1202,31 @@ declare const STORE_DOORS: readonly [{
1037
1202
  readonly args: "p_organization_id uuid, p_roots uuid[]";
1038
1203
  readonly returns: "TABLE(record_id uuid, depth integer, via text)";
1039
1204
  readonly security: "invoker";
1205
+ }, {
1206
+ readonly name: "reaches_directly";
1207
+ readonly args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
1208
+ readonly returns: "boolean";
1209
+ readonly security: "definer";
1210
+ }, {
1211
+ readonly name: "read_door_carried_ids";
1212
+ readonly args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level, OUT o_ids uuid[], OUT o_containers integer";
1213
+ readonly returns: "record";
1214
+ readonly security: "definer";
1215
+ }, {
1216
+ readonly name: "read_door_granted_ids";
1217
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1218
+ readonly returns: "uuid[]";
1219
+ readonly security: "definer";
1220
+ }, {
1221
+ readonly name: "read_door_ladder_ceiling";
1222
+ readonly args: "";
1223
+ readonly returns: "integer";
1224
+ readonly security: "invoker";
1225
+ }, {
1226
+ readonly name: "read_door_parity";
1227
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_user uuid, p_required permission_level, p_sample integer";
1228
+ readonly returns: "TABLE(record_id uuid, set_based boolean, per_row boolean, verdict text)";
1229
+ readonly security: "definer";
1040
1230
  }, {
1041
1231
  readonly name: "read_paths_outside_the_door";
1042
1232
  readonly args: "";
@@ -1062,6 +1252,11 @@ declare const STORE_DOORS: readonly [{
1062
1252
  readonly args: "p_organization_id uuid, p_record_id uuid";
1063
1253
  readonly returns: "TABLE(rule_id uuid, rule_name text, rule_version integer, applies boolean, answer jsonb)";
1064
1254
  readonly security: "invoker";
1255
+ }, {
1256
+ readonly name: "record_as_of";
1257
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_at timestamp with time zone";
1258
+ readonly returns: "TABLE(state jsonb, replayed boolean)";
1259
+ readonly security: "definer";
1065
1260
  }, {
1066
1261
  readonly name: "record_card";
1067
1262
  readonly args: "p_viewer uuid, p_organization_id uuid, p_record_id uuid";
@@ -1127,6 +1322,11 @@ declare const STORE_DOORS: readonly [{
1127
1322
  readonly args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid";
1128
1323
  readonly returns: "uuid";
1129
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";
1130
1330
  }, {
1131
1331
  readonly name: "relation_own";
1132
1332
  readonly args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid";
@@ -1197,6 +1397,11 @@ declare const STORE_DOORS: readonly [{
1197
1397
  readonly args: "p_organization_id uuid, p_record_id uuid";
1198
1398
  readonly returns: "jsonb";
1199
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";
1200
1405
  }, {
1201
1406
  readonly name: "rule_dependency_edges";
1202
1407
  readonly args: "p_organization_id uuid, p_row custom.record DEFAULT NULL::custom.record";
@@ -1257,6 +1462,11 @@ declare const STORE_DOORS: readonly [{
1257
1462
  readonly args: "p_organization_id uuid, p_rule_id uuid";
1258
1463
  readonly returns: "integer";
1259
1464
  readonly security: "invoker";
1465
+ }, {
1466
+ readonly name: "said";
1467
+ readonly args: "p_value text, p_when_there_is_none text";
1468
+ readonly returns: "text";
1469
+ readonly security: "invoker";
1260
1470
  }, {
1261
1471
  readonly name: "share_access";
1262
1472
  readonly args: "p_organization_id uuid, p_subject_id uuid";
@@ -1297,6 +1507,11 @@ declare const STORE_DOORS: readonly [{
1297
1507
  readonly args: "p_organization_id uuid, p_type text, p_id uuid";
1298
1508
  readonly returns: "text";
1299
1509
  readonly security: "definer";
1510
+ }, {
1511
+ readonly name: "shared_only_disagreements";
1512
+ readonly args: "p_pretend text DEFAULT NULL::text";
1513
+ readonly returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, record_id uuid, table_id uuid, ladder boolean, read_door boolean, rls_mirror boolean, why text)";
1514
+ readonly security: "invoker";
1300
1515
  }, {
1301
1516
  readonly name: "size_refusal";
1302
1517
  readonly args: "p_organization_id uuid, p_data jsonb";
@@ -1342,6 +1557,11 @@ declare const STORE_DOORS: readonly [{
1342
1557
  readonly args: "p_organization_id uuid, p_spec jsonb";
1343
1558
  readonly returns: "uuid";
1344
1559
  readonly security: "definer";
1560
+ }, {
1561
+ readonly name: "table_has_a_visible_record";
1562
+ readonly args: "p_user uuid, p_organization_id uuid, p_table_id uuid";
1563
+ readonly returns: "boolean";
1564
+ readonly security: "definer";
1345
1565
  }, {
1346
1566
  readonly name: "table_is_live";
1347
1567
  readonly args: "p_organization_id uuid, p_table_id uuid";
@@ -1376,7 +1596,7 @@ declare const STORE_DOORS: readonly [{
1376
1596
  readonly name: "table_type_field";
1377
1597
  readonly args: "p_organization_id uuid, p_table_id uuid";
1378
1598
  readonly returns: "text";
1379
- readonly security: "invoker";
1599
+ readonly security: "definer";
1380
1600
  }, {
1381
1601
  readonly name: "tables_at_home";
1382
1602
  readonly args: "p_organization_id uuid, p_home_ids uuid[]";
@@ -1431,7 +1651,7 @@ declare const STORE_DOORS: readonly [{
1431
1651
  readonly name: "value_read";
1432
1652
  readonly args: "p_organization_id uuid, p_record_id uuid, p_key text";
1433
1653
  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)";
1434
- readonly security: "invoker";
1654
+ readonly security: "definer";
1435
1655
  }, {
1436
1656
  readonly name: "value_versions";
1437
1657
  readonly args: "p_old jsonb, p_new jsonb";
@@ -1462,16 +1682,56 @@ declare const STORE_DOORS: readonly [{
1462
1682
  readonly args: "p_container_type text, p_container_id uuid";
1463
1683
  readonly returns: "integer";
1464
1684
  readonly security: "definer";
1685
+ }, {
1686
+ readonly name: "visible_predicate_sql";
1687
+ readonly args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, p_alias text DEFAULT 'r'::text";
1688
+ readonly returns: "text";
1689
+ readonly security: "definer";
1465
1690
  }, {
1466
1691
  readonly name: "visible_record_ids";
1467
1692
  readonly args: "p_user_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
1468
1693
  readonly returns: "TABLE(id uuid)";
1469
1694
  readonly security: "definer";
1695
+ }, {
1696
+ readonly name: "visible_set";
1697
+ readonly args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, OUT o_all_visible boolean, OUT o_true_visibility platform.visibility[], OUT o_granted_all uuid[], OUT o_granted_visible uuid[], OUT o_carried_visible uuid[], OUT o_ladder_calls integer, OUT o_fallback boolean, OUT o_note text";
1698
+ readonly returns: "record";
1699
+ readonly security: "definer";
1470
1700
  }, {
1471
1701
  readonly name: "widget_kernel_id";
1472
1702
  readonly args: "";
1473
1703
  readonly returns: "uuid";
1474
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";
1475
1735
  }, {
1476
1736
  readonly name: "work_assignment_fields";
1477
1737
  readonly args: "p_options_table_id uuid DEFAULT NULL::uuid";
@@ -1481,32 +1741,57 @@ declare const STORE_DOORS: readonly [{
1481
1741
  readonly name: "work_has_assignment";
1482
1742
  readonly args: "p_organization_id uuid, p_table_id uuid";
1483
1743
  readonly returns: "boolean";
1484
- 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";
1485
1750
  }, {
1486
1751
  readonly name: "work_instantiation_shape";
1487
1752
  readonly args: "p_organization_id uuid, p_instantiation_id uuid";
1488
1753
  readonly returns: "jsonb";
1489
- 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";
1490
1770
  }, {
1491
1771
  readonly name: "work_relation_kinds";
1492
1772
  readonly args: "";
1493
1773
  readonly returns: "TABLE(kind text, available boolean, why text)";
1494
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";
1495
1780
  }, {
1496
1781
  readonly name: "work_slot_expire";
1497
1782
  readonly args: "p_organization_id uuid, p_table_id uuid";
1498
1783
  readonly returns: "integer";
1499
- readonly security: "invoker";
1784
+ readonly security: "definer";
1500
1785
  }, {
1501
1786
  readonly name: "work_slot_hold";
1502
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";
1503
1788
  readonly returns: "jsonb";
1504
- readonly security: "invoker";
1789
+ readonly security: "definer";
1505
1790
  }, {
1506
1791
  readonly name: "work_slot_holds";
1507
1792
  readonly args: "p_organization_id uuid, p_table_id uuid";
1508
1793
  readonly returns: "TABLE(hold_id uuid, slot_key text, holder text, expires_at timestamp with time zone, expired boolean)";
1509
- readonly security: "invoker";
1794
+ readonly security: "definer";
1510
1795
  }, {
1511
1796
  readonly name: "work_slot_index_name";
1512
1797
  readonly args: "p_table_id uuid";
@@ -1516,12 +1801,12 @@ declare const STORE_DOORS: readonly [{
1516
1801
  readonly name: "work_slot_release";
1517
1802
  readonly args: "p_organization_id uuid, p_hold_id uuid";
1518
1803
  readonly returns: "boolean";
1519
- readonly security: "invoker";
1804
+ readonly security: "definer";
1520
1805
  }, {
1521
1806
  readonly name: "work_slots_declare";
1522
1807
  readonly args: "p_organization_id uuid, p_name text, p_slug text, p_home_id uuid DEFAULT NULL::uuid";
1523
1808
  readonly returns: "jsonb";
1524
- readonly security: "invoker";
1809
+ readonly security: "definer";
1525
1810
  }, {
1526
1811
  readonly name: "work_states";
1527
1812
  readonly args: "";
@@ -1531,17 +1816,17 @@ declare const STORE_DOORS: readonly [{
1531
1816
  readonly name: "work_take_assignment";
1532
1817
  readonly args: "p_organization_id uuid, p_table_id uuid";
1533
1818
  readonly returns: "jsonb";
1534
- readonly security: "invoker";
1819
+ readonly security: "definer";
1535
1820
  }, {
1536
1821
  readonly name: "work_template_declare";
1537
1822
  readonly args: "p_organization_id uuid, p_name text, p_graph jsonb";
1538
1823
  readonly returns: "uuid";
1539
- readonly security: "invoker";
1824
+ readonly security: "definer";
1540
1825
  }, {
1541
1826
  readonly name: "work_template_instantiate";
1542
1827
  readonly args: "p_organization_id uuid, p_template_id uuid, p_overrides jsonb DEFAULT '{}'::jsonb";
1543
1828
  readonly returns: "jsonb";
1544
- readonly security: "invoker";
1829
+ readonly security: "definer";
1545
1830
  }, {
1546
1831
  readonly name: "work_template_refusal";
1547
1832
  readonly args: "p_graph jsonb";
@@ -1551,30 +1836,35 @@ declare const STORE_DOORS: readonly [{
1551
1836
  readonly name: "work_template_shape";
1552
1837
  readonly args: "p_organization_id uuid, p_template_id uuid";
1553
1838
  readonly returns: "jsonb";
1554
- 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";
1555
1845
  }, {
1556
1846
  readonly name: "work_transition_refusal";
1557
1847
  readonly args: "p_organization_id uuid, p_from_state_id uuid, p_to_state_id uuid";
1558
1848
  readonly returns: "text";
1559
- readonly security: "invoker";
1849
+ readonly security: "definer";
1560
1850
  }, {
1561
1851
  readonly name: "work_whose_turn";
1562
1852
  readonly args: "p_organization_id uuid, p_table_id uuid, p_include_finished boolean DEFAULT false";
1563
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)";
1564
- readonly security: "invoker";
1854
+ readonly security: "definer";
1565
1855
  }];
1566
1856
  /** The campaign's own knobs, with the value the store resolves them to today. */
1567
1857
  declare const STORE_KNOBS: readonly [{
1568
1858
  readonly key: "accessible_entity_ids_guard";
1569
- readonly value: "false";
1859
+ readonly value: "true";
1570
1860
  readonly type: "boolean";
1571
1861
  }, {
1572
1862
  readonly key: "agent_schema_changes";
1573
- readonly value: "\"propose\"";
1863
+ readonly value: "\"ask\"";
1574
1864
  readonly type: "string";
1575
1865
  }, {
1576
1866
  readonly key: "associations_guard";
1577
- readonly value: "false";
1867
+ readonly value: "true";
1578
1868
  readonly type: "boolean";
1579
1869
  }, {
1580
1870
  readonly key: "code_paths_enabled";
@@ -1655,7 +1945,7 @@ declare const STORE_KNOBS: readonly [{
1655
1945
  }, {
1656
1946
  readonly key: "member_default_level";
1657
1947
  readonly value: "\"viewer\"";
1658
- readonly type: "string";
1948
+ readonly type: "enum";
1659
1949
  }, {
1660
1950
  readonly key: "member_default_visibility";
1661
1951
  readonly value: "\"all_records\"";
@@ -1713,34 +2003,37 @@ declare const STORE_KNOBS: readonly [{
1713
2003
  */
1714
2004
  declare const STORE_REFUSAL_CODES: readonly [{
1715
2005
  readonly code: "02000";
1716
- 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";
1717
2007
  }, {
1718
2008
  readonly code: "0A000";
1719
- 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";
1720
2010
  }, {
1721
2011
  readonly code: "22004";
1722
- 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";
1723
2013
  }, {
1724
2014
  readonly code: "22012";
1725
2015
  readonly raised_by: "rule_eval";
1726
2016
  }, {
1727
2017
  readonly code: "22023";
1728
- 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,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";
1729
2019
  }, {
1730
2020
  readonly code: "23503";
1731
- 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";
1732
2022
  }, {
1733
2023
  readonly code: "23505";
1734
- readonly raised_by: "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";
1735
2025
  }, {
1736
2026
  readonly code: "23514";
1737
- 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,_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";
1738
2028
  }, {
1739
2029
  readonly code: "40001";
1740
2030
  readonly raised_by: "has_visibility_at";
1741
2031
  }, {
1742
2032
  readonly code: "42501";
1743
- 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_organization_admin,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,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";
1744
2037
  }, {
1745
2038
  readonly code: "53400";
1746
2039
  readonly raised_by: "anon_rate_take,delete_cascade_closure,promote_field";
@@ -2041,6 +2334,27 @@ interface RecordRead {
2041
2334
  }>;
2042
2335
  }
2043
2336
 
2337
+ /** `public.permission_level`, in the store's own order. */
2338
+ type PermissionLevel = "viewer" | "commenter" | "editor" | "admin";
2339
+ /** The order the store writes them in, lowest first. */
2340
+ declare const PERMISSION_LEVELS: readonly PermissionLevel[];
2341
+ /** Whether `held` is the same rung as `needed` or a higher one. Nothing held is never enough. */
2342
+ declare function atLeast(held: PermissionLevel | null | undefined, needed: PermissionLevel): boolean;
2343
+ /** A level word the store sent, or null when it sent something this package does not know. */
2344
+ declare function asPermissionLevel(word: unknown): PermissionLevel | null;
2345
+ /** The higher of two levels — what a person holds when two ways in both let them through. */
2346
+ declare function highestLevel(left: PermissionLevel | null | undefined, right: PermissionLevel | null | undefined): PermissionLevel | null;
2347
+ /**
2348
+ * What one subject's level is, as `custom.my_levels` answers it. `null` is an
2349
+ * ANSWER — "you hold nothing on this" — and never a missing row: a screen that
2350
+ * could not tell "no access" from "not asked yet" would draw one of them as the
2351
+ * other.
2352
+ */
2353
+ interface MyLevel {
2354
+ id: string;
2355
+ level: PermissionLevel | null;
2356
+ }
2357
+
2044
2358
  /**
2045
2359
  * REC-1. A Table declares its fields, exactly one Home, and the properties
2046
2360
  * `display`, `ordered`, `heavy` | `light`, `retention` and `detail`.
@@ -2352,6 +2666,37 @@ interface RuleAnswer {
2352
2666
  applies: boolean;
2353
2667
  answer: unknown;
2354
2668
  }
2669
+ /** One form as `custom.forms` reports it to its owner. */
2670
+ interface FormSummary {
2671
+ form_id: string;
2672
+ table_id: string;
2673
+ title: string | null;
2674
+ slug: string;
2675
+ published_at: string | null;
2676
+ closed_at: string | null;
2677
+ submission_cap: number | null;
2678
+ /** Every answer that arrived, rejected ones excluded from `in_table` and `held`. */
2679
+ responses: number;
2680
+ /** Answers that became records — the only number that means "it is in the table". */
2681
+ in_table: number;
2682
+ /** Answers waiting for a person, because the form's accept Rule did not clear them. */
2683
+ held: number;
2684
+ /** Answers the accept Rule or the decoy turned away. */
2685
+ rejected: number;
2686
+ /** draft · open · closed · full — the store's own word, never derived on a screen. */
2687
+ state: "draft" | "open" | "closed" | "full";
2688
+ quarantine_rule_id: string | null;
2689
+ notify_rule_id: string | null;
2690
+ presentation: Record<string, unknown>;
2691
+ }
2692
+ /**
2693
+ * THE PUBLIC LINK, and the one place its shape is written down.
2694
+ *
2695
+ * The form's own id IS the capability — 122 bits of UUIDv4, exactly as
2696
+ * Typeform's form id in `/to/<id>` is and as an unguessable meeting slug is
2697
+ * here. There is no second secret to keep, and revoking it is closing the form.
2698
+ */
2699
+ declare function publicFormPath(formId: string): string;
2355
2700
 
2356
2701
  /** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
2357
2702
  type AggregateOperation = "count" | "sum" | "avg" | "min" | "max";
@@ -3243,6 +3588,29 @@ interface RecordsClient {
3243
3588
  values: Record<string, unknown>;
3244
3589
  context?: Record<string, unknown>;
3245
3590
  }): Promise<RecordsResult<unknown>>;
3591
+ /**
3592
+ * Write ONE Rule as a real Rule. `recordWrite` into the Rule kernel makes a
3593
+ * valid Rule document that carries `data_class = 'record'`, and every reader
3594
+ * that looks for a Rule looks for the class — `custom.agg_subscriptions`
3595
+ * selects `where data_class = 'rule'` — so a subscription written that way
3596
+ * fires at nobody. This is the door that closes it.
3597
+ */
3598
+ /** This organization's forms, with how many answers arrived and how many are in the table. */
3599
+ forms(args?: {
3600
+ table_id?: Uuid | null;
3601
+ }): Promise<RecordsResult<FormSummary[]>>;
3602
+ /** Create or re-state one form. A question naming no Field of that Table is refused BY NAME. */
3603
+ formDeclare(args: {
3604
+ table_id: Uuid;
3605
+ title: string;
3606
+ questions: unknown[];
3607
+ presentation?: Record<string, unknown> | null;
3608
+ submission_cap?: number | null;
3609
+ quarantine_rule_id?: Uuid | null;
3610
+ notify_rule_id?: Uuid | null;
3611
+ form_id?: Uuid | null;
3612
+ slug?: string | null;
3613
+ }): Promise<RecordsResult<Uuid>>;
3246
3614
  /**
3247
3615
  * Group, bucket, filter and measure INSIDE `custom.record_aggregate`. The
3248
3616
  * aggregate node sits above the visibility join, so what a chart draws is
@@ -3525,7 +3893,8 @@ interface RecordsClient {
3525
3893
  */
3526
3894
  ruleDeclare(args: {
3527
3895
  spec: Record<string, unknown>;
3528
- }): Promise<RecordsResult<never>>;
3896
+ rule_id?: Uuid | null;
3897
+ }): Promise<RecordsResult<Uuid>>;
3529
3898
  fieldPropose(proposal: FieldProposal): Promise<RecordsResult<never>>;
3530
3899
  tablePropose(proposal: TableProposal): Promise<RecordsResult<never>>;
3531
3900
  promoteTable(args: {
@@ -3537,6 +3906,19 @@ interface RecordsClient {
3537
3906
  }): Promise<RecordsResult<unknown>>;
3538
3907
  /** Is the store switched on for this organization? A product switch, never the boundary. */
3539
3908
  storeIsOpen(): Promise<RecordsResult<boolean>>;
3909
+ /**
3910
+ * WHAT THIS PERSON MAY DO TO THESE THINGS — asked once, for a whole page.
3911
+ *
3912
+ * There is no principal argument, on purpose: the door resolves the caller
3913
+ * from the session, so a person can ask about their OWN access and about
3914
+ * nobody else's. A subject they hold nothing on answers `level: null`, which
3915
+ * is an answer; the row is never omitted, because a screen that could not
3916
+ * tell "no access" from "not asked yet" would draw one of them as the other.
3917
+ */
3918
+ myLevels(args: {
3919
+ ids: Uuid[];
3920
+ subject?: "record";
3921
+ }): Promise<RecordsResult<MyLevel[]>>;
3540
3922
  }
3541
3923
 
3542
3924
  interface RecordsProviderProps {
@@ -3549,6 +3931,21 @@ declare function RecordsProvider({ config, children }: RecordsProviderProps): re
3549
3931
  * mounted the provider is the silent failure this throws instead of.
3550
3932
  */
3551
3933
  declare function useRecordsClient(): RecordsClient;
3934
+ /**
3935
+ * The client IF one is mounted, and `null` if none is — for the ONE case where
3936
+ * that is not a mistake: a screen served to somebody who has no account.
3937
+ *
3938
+ * A public form page (DOOR-17) renders for a stranger. There is no session to
3939
+ * build a client from, no organization the caller may name and no read of the
3940
+ * table it writes into; the server resolved the form through
3941
+ * `custom.form_public` and hands the screen its questions and a submit port.
3942
+ * `useRecordsClient` is right to throw for every other caller — a hook that
3943
+ * quietly did nothing is the silent failure it exists to prevent — so this is a
3944
+ * SECOND, NAMED hook rather than a softening of the first. A component using it
3945
+ * must work with `null`, and the ones in `@ai-matrx/records-ui` say out loud
3946
+ * which half of themselves is unavailable when it is.
3947
+ */
3948
+ declare function useOptionalRecordsClient(): RecordsClient | null;
3552
3949
  /** For a screen that wants to show who it is acting as (AGT-N-4). */
3553
3950
  declare function useRecordsActor(): RecordsActor;
3554
3951
 
@@ -3563,6 +3960,21 @@ interface Async<T> {
3563
3960
  declare function useTable(tableId: Uuid | null): Async<Table | null>;
3564
3961
  /** Every Table this person can see in this organization. */
3565
3962
  declare function useTables(): Async<Table[]>;
3963
+ /**
3964
+ * WHAT THIS PERSON MAY DO TO THESE THINGS — one call for a whole page.
3965
+ *
3966
+ * A screen asks this BEFORE it draws a control, which is the whole difference
3967
+ * between a product that offers what you may use and one that offers everything
3968
+ * and apologises afterwards. The ids are joined into the dependency key so a
3969
+ * page that re-renders with the same rows does not re-ask.
3970
+ *
3971
+ * `null` for a subject is an ANSWER ("you hold nothing on this"), and `loading`
3972
+ * is a third state that is neither — a caller that treated loading as "no"
3973
+ * would blink every control off on every reload.
3974
+ */
3975
+ declare function useMyLevels(ids: Uuid[]): Async<Record<string, PermissionLevel | null>>;
3976
+ /** The same question about one thing. */
3977
+ declare function useMyLevel(id: Uuid | null): Async<PermissionLevel | null>;
3566
3978
  /**
3567
3979
  * FLD-10. The Fields that APPLY — the store decides, from the record type, and
3568
3980
  * the client asks rather than filtering a list it has.
@@ -3654,4 +4066,4 @@ declare function useFieldMutation(): UseFieldMutation;
3654
4066
  */
3655
4067
  declare function useMergeField(key: string | null, state?: Record<string, unknown>): MergeFieldResolution | null;
3656
4068
 
3657
- 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 NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PER_VALUE_ACCESS_WORDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, 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, err, isRecordsErr, measureKey, ok, useFieldMutation, useFields, useMergeField, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };
4069
+ 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 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 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, publicFormPath, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useOptionalRecordsClient, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };