@ai-matrx/records 0.30.0 → 0.37.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.
@@ -91,6 +91,7 @@ var RULE_NODE_KINDS = [
91
91
  { node: "parent_field", evaluated_by: "W1-RULE-APPLY" },
92
92
  { node: "present", evaluated_by: "W1-RULE" },
93
93
  { node: "previous", evaluated_by: "PIPELINES" },
94
+ { node: "sibling_count", evaluated_by: "STAGE-RULES" },
94
95
  { node: "stage_count", evaluated_by: "PIPELINES" },
95
96
  { node: "sub", evaluated_by: "W1-RULE" }
96
97
  ];
@@ -418,7 +419,9 @@ var STORE_DOORS = [
418
419
  { name: "pin_agent_cells", args: "p_new jsonb, p_old jsonb, p_agent_keys text[]", returns: "jsonb", security: "invoker" },
419
420
  { name: "pipeline_board", args: "p_organization_id uuid, p_table_id uuid, p_measure text DEFAULT NULL::text", returns: "TABLE(stage_key text, stage_label text, stage_position integer, cards bigint, total numeric, wip_limit integer, over_limit boolean)", security: "definer" },
420
421
  { name: "pipeline_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "jsonb", security: "definer" },
422
+ { name: "pipeline_gate_preview", args: "p_organization_id uuid, p_table_id uuid, p_stage text, p_gate jsonb", returns: "jsonb", security: "definer" },
421
423
  { name: "pipeline_move", args: "p_organization_id uuid, p_record_id uuid, p_to text, p_also jsonb DEFAULT '{}'::jsonb, p_expected_version integer DEFAULT NULL::integer", returns: "jsonb", security: "definer" },
424
+ { name: "pipeline_pending", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
422
425
  { name: "pipeline_read", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
423
426
  { name: "pipeline_transition_refusal", args: "p_organization_id uuid, p_record_id uuid, p_to text", returns: "jsonb", security: "definer" },
424
427
  { name: "portal_admits", args: "p_organization_id uuid, p_user_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "definer" },
@@ -485,6 +488,7 @@ var STORE_DOORS = [
485
488
  { 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" },
486
489
  { name: "record_delete", args: "p_organization_id uuid, p_record_id uuid", returns: "timestamp with time zone", security: "definer" },
487
490
  { 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" },
491
+ { name: "record_platform_keys", args: "", returns: "text[]", security: "invoker" },
488
492
  { 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" },
489
493
  { name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
490
494
  { name: "record_resolve", args: "p_organization_id uuid, p_id uuid", returns: "jsonb", security: "definer" },
@@ -493,6 +497,7 @@ var STORE_DOORS = [
493
497
  { name: "record_restore_version", args: "p_organization_id uuid, p_record_id uuid, p_version integer", returns: "jsonb", security: "definer" },
494
498
  { name: "record_restore_version", args: "p_organization_id uuid, p_record_id uuid, p_version integer, p_author jsonb", returns: "jsonb", security: "definer" },
495
499
  { name: "record_scope_context", args: "p_organization_id uuid, p_record_id uuid, p_relations integer DEFAULT 12, p_history integer DEFAULT 15, p_siblings integer DEFAULT 8", returns: "jsonb", security: "definer" },
500
+ { name: "record_stage_pending", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
496
501
  { name: "record_state_as_of", args: "p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
497
502
  { name: "record_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "definer" },
498
503
  { 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" },
@@ -556,6 +561,8 @@ var STORE_DOORS = [
556
561
  { name: "size_refusal", args: "p_organization_id uuid, p_data jsonb", returns: "text", security: "invoker" },
557
562
  { name: "source_next_pointer", args: "p_sources jsonb", returns: "text", security: "invoker" },
558
563
  { name: "source_pointer", args: "p_sources jsonb, p_source jsonb", returns: "text", security: "invoker" },
564
+ { name: "stage_rule_enforcement", args: "p_organization_id uuid", returns: "text", security: "invoker" },
565
+ { name: "stage_rule_on_fail_kinds", args: "", returns: "TABLE(behaviour text, note text)", security: "invoker" },
559
566
  { 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" },
560
567
  { name: "storage_modes", args: "", returns: "text[]", security: "invoker" },
561
568
  { name: "store_is_open", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "invoker" },
@@ -566,6 +573,7 @@ var STORE_DOORS = [
566
573
  { 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, quiet_hours jsonb, channel text, recipient_user_id uuid, event_key text, muted boolean, mine boolean, i_may_mute boolean, last_sent_at timestamp with time zone, next_digest_at timestamp with time zone)", security: "definer" },
567
574
  { name: "table_capacity", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
568
575
  { name: "table_carries_its_rows", args: "p_user_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
576
+ { name: "table_column_source", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
569
577
  { name: "table_contents", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(record_id uuid, kind text, goes_at integer)", security: "invoker" },
570
578
  { name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
571
579
  { name: "table_has_a_visible_record", args: "p_user uuid, p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
@@ -580,6 +588,7 @@ var STORE_DOORS = [
580
588
  { name: "tables_at_home", args: "p_organization_id uuid, p_home_ids uuid[]", returns: "TABLE(table_id uuid, home_record_id uuid, kind text)", security: "definer" },
581
589
  { name: "tables_described_without_asking", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
582
590
  { name: "trg_associations_bump_visibility", args: "", returns: "trigger", security: "definer" },
591
+ { name: "undeclared_keys", args: "p_organization_id uuid, p_table_id uuid, p_data jsonb", returns: "text[]", security: "invoker" },
583
592
  { name: "validate_custom_fields", args: "p_token text, p_organization_id uuid, p_values jsonb", returns: "void", security: "invoker" },
584
593
  { name: "validate_value_envelope", args: "p_organization_id uuid, p_fields custom.record[], p_data jsonb", returns: "void", security: "invoker" },
585
594
  { name: "validate_values", args: "p_organization_id uuid, p_fields custom.record[], p_values jsonb, p_record_type text DEFAULT NULL::text", returns: "void", security: "invoker" },
@@ -680,6 +689,7 @@ var STORE_KNOBS = [
680
689
  { key: "sandbox_message_bytes", value: "65536", type: "integer" },
681
690
  { key: "sandbox_org_components", value: "true", type: "boolean" },
682
691
  { key: "signup_provisioning_guard", value: "false", type: "boolean" },
692
+ { key: "stage_rule_enforcement", value: '"refuse"', type: "enum" },
683
693
  { key: "system_enabled", value: "false", type: "boolean" },
684
694
  { key: "table_record_ceiling", value: "150000", type: "integer" },
685
695
  { key: "value_max_bytes", value: "100000", type: "integer" },
@@ -689,19 +699,20 @@ var STORE_REFUSAL_CODES = [
689
699
  { code: "02000", raised_by: "_checklist_instantiate,checklist_declare,checklist_run,checklist_step_complete,checklist_step_refusal,checklist_template_shape,conversation_scope_bind,dashboard_delete,dashboard_run,doc_letterhead,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,enrich_pin,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,sign_request_cancel,sign_request_create,sign_request_remind,sign_request_unchanged,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_assign,work_record_states,work_set_state" },
690
700
  { code: "0A000", raised_by: "checklist_step_complete,external_rows,external_source_declare,external_write_through,promote_field,promoted_index_expr,promoted_query_sql,promoted_read,rule_eval,work_assign" },
691
701
  { code: "22003", raised_by: "context_resolve" },
692
- { 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,booking_declare,capture_submit,checklist_declare,context_resolve,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,enrich_land,enrich_normalize,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_begin,io_infer_column,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,pipeline_declare,portal_declare,portal_invite,portal_principal_bind,provenance_retention_days,provenance_write,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,record_write_many,relation_carry,relation_own,rule_declare,share_grant,sign_request_create,sign_request_sign,subscription_declare,table_declare,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare" },
702
+ { 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,booking_declare,capture_submit,checklist_declare,context_resolve,dashboard_block_normalize,dashboard_declare,dashboard_window_sql,doc_render_write,doc_sign,doc_signature_write,doc_template_save,enrich_land,enrich_normalize,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_begin,io_infer_column,io_outbox_drain,io_restore,migrate_choice_keys,migrate_purge,migrate_reclass,migrate_split,migrate_undo,organization_clear,organization_contents,pipeline_declare,pipeline_gate_preview,portal_declare,portal_invite,portal_principal_bind,provenance_retention_days,provenance_write,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,record_write_many,relation_carry,relation_own,rule_declare,share_grant,sign_request_create,sign_request_sign,subscription_declare,table_declare,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare" },
693
703
  { code: "22007", raised_by: "dashboard_window_sql" },
694
704
  { code: "22012", raised_by: "rule_eval" },
695
705
  { code: "22023", raised_by: "_booking_availability,_entity_custom_fields_guard,_value_envelope,_work_shape_guard,actor_word,agg_assert_key,agg_sql,anon_token_issue,booking_declare,containment_parent,dashboard_block_normalize,dashboard_window_sql,doc_render_body,doc_render_write,doc_signature_write,enrich_declare,enrich_land,enrich_normalize,enrich_pin,entity_value_write,external_history_event,external_source_declare,external_stub_upsert,external_write_through,field_history,io_export,io_import_begin,io_import_finish,io_import_plan,io_import_report,io_proposal_accept,migrate_merge,migrate_reclass,my_levels,organization_clear,page_size,pin_agent_cells,pipeline_move,portal_declare,provenance_write,query_by_coordinates,query_rollup,record_update,record_write_many,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,sign_request_create,sign_request_sign,subscription_declare,table_rules,visibility_as_of,work_approval_request,work_list,work_slot_hold" },
696
706
  { code: "23503", raised_by: "_booking_availability,_checklist_instantiate,_containment_guard,_field_document_for,_pipeline_stage_key,_record_rule_uses,agg_digest_assemble,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,booking_cancel,booking_confirm,booking_declare,booking_hold,booking_reschedule,capture_publish,checklist_declare,checklist_steps_table,comment_write,dashboard_declare,delete_rule,doc_sign,doc_template_save,enrich_declare,enrich_due,enrich_land,form_declare,form_submit,home_add,inbound_declare,inbound_mail_land,inbound_set,io_comment_write,io_import_begin,io_import_finish,io_import_report,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,pipeline_board,pipeline_declare,pipeline_move,pipeline_read,pipeline_transition_refusal,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,sign_request_create,subscription_mute,subscription_preview,view_declare,work_set_state,work_take_assignment,work_template_instantiate" },
697
707
  { code: "23505", raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,entity_field_declare,field_declare,home_add,inbound_declare,io_proposal_accept,relation_carry,relation_own,share_grant,sign_request_cancel,sign_request_create,work_approval_decide,work_slot_hold" },
698
- { code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,_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,capture_publish,capture_sheet_declare,checklist_declare,checklist_step_complete,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,io_import_rows,migrate_merge,relation_carry,relation_own,sign_request_create,sign_request_sign,table_declare,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
708
+ { code: "23514", raised_by: "_checklist_instantiate,_checklist_step_guard,_claimed_column_guard,_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_columns_word_guard,_table_shape_guard,_undeclared_key_guard,_value_envelope,_work_shape_guard,_workdoors_approval_guard,assert_entity_is_organization_scoped,capture_publish,capture_sheet_declare,checklist_declare,checklist_step_complete,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,io_import_rows,migrate_merge,relation_carry,relation_own,sign_request_create,sign_request_sign,table_declare,validate_value_envelope,validate_values,work_set_state,work_slots_declare,work_take_assignment,work_template_instantiate" },
699
709
  { code: "40001", raised_by: "has_visibility_at" },
700
710
  { 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,booking_confirm,booking_declare,booking_hold,capture_submit,checklist_run,comment_write,conversation_scope_bind,conversation_scope_unbind,enrich_declare,enrich_due,enrich_land,enrich_normalize,entity_field_declare,entity_field_retire,entity_field_update,entity_value_write,external_write_through,form_declare,form_submit,inbound_mail_land,io_comment_resolve,io_comment_write,io_import_begin,io_import_finish,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,subscription_preview,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person" },
701
711
  { code: "42703", raised_by: "entity_table,portal_declare" },
702
712
  { code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,enrich_due,enrich_land,promote_field" },
703
713
  { code: "54001", raised_by: "record_delete" },
704
- { code: "PT409", raised_by: "record_update" }
714
+ { code: "PT409", raised_by: "record_update" },
715
+ { code: "PT428", raised_by: "_record_rule_uses" }
705
716
  ];
706
717
  var ENTITY_TOKENS = [
707
718
  "access_delta_probe",
@@ -1365,6 +1376,7 @@ var ENTITY_TOKENS = [
1365
1376
  "plan_node_artifact",
1366
1377
  "plan_node_step",
1367
1378
  "plan_profile",
1379
+ "platform_action_request",
1368
1380
  "platform_actor_session",
1369
1381
  "platform_actor_token",
1370
1382
  "platform_actor_token_event",
@@ -1866,6 +1878,14 @@ var DOORS = {
1866
1878
  pipelineTransitionRefusal: "pipeline_transition_refusal",
1867
1879
  pipelineMove: "pipeline_move",
1868
1880
  tableStageField: "table_stage_field",
1881
+ // STAGE-RULES. A gate can refuse or it can hand the change to the approvals queue; the
1882
+ // closed list is the store's, the knob is the organization's, and what is WAITING on a
1883
+ // card has to be askable or a card that did not move looks like a card nobody dragged.
1884
+ stageRuleOnFailKinds: "stage_rule_on_fail_kinds",
1885
+ stageRuleEnforcement: "stage_rule_enforcement",
1886
+ recordStagePending: "record_stage_pending",
1887
+ pipelinePending: "pipeline_pending",
1888
+ pipelineGatePreview: "pipeline_gate_preview",
1869
1889
  ruleMembers: "rule_members",
1870
1890
  ruleMembership: "rule_membership",
1871
1891
  ruleRun: "rule_run",
@@ -1887,6 +1907,10 @@ var DOORS = {
1887
1907
  // VISITOR's three (`booking_public`, `booking_hold`, `booking_confirm`) are
1888
1908
  // deliberately absent: they are server-lane and a browser never calls them.
1889
1909
  bookings: "bookings",
1910
+ // The OWNER's side of a booking page, and the door that had no client method at
1911
+ // all until 2026-09-21: without it the only way to get a booking page was to ask
1912
+ // an agent, which made the agent the ONLY path rather than the faster one.
1913
+ bookingDeclare: "booking_declare",
1890
1914
  // PRODUCTS row 9 — "pull my spreadsheet in". W4-IO built `io_import_open` and
1891
1915
  // `io_import_rows`; lane IMPORT gave a run an IDENTITY (the file's sha-256, so
1892
1916
  // a re-import doubles nothing), a duplicate key, a policy, per-row outcomes
@@ -2019,6 +2043,13 @@ var DOORS = {
2019
2043
  // the summary it would send right now without sending it.
2020
2044
  subscriptionDeclare: "subscription_declare",
2021
2045
  subscriptionPreview: "subscription_preview",
2046
+ // A SUBSCRIPTION IS OVER A SAVED VIEW, so a person who has never saved one has
2047
+ // nothing to subscribe to. These two are the saved-view pair (lane DIGESTS'
2048
+ // `digests_a_saved_view_has_a_door.sql`), unreachable from this client until
2049
+ // 2026-09-21: `views` lists this Table's, `viewDeclare` writes one. A LIST IS A
2050
+ // DOOR, never a grant on `platform.saved_view` behind it.
2051
+ views: "views",
2052
+ viewDeclare: "view_declare",
2022
2053
  // The cadence CATALOGUE a person's screen may ask for. `agg_subscription_cadences`
2023
2054
  // above is the notifier's own and holds no client grant; this door delegates to
2024
2055
  // it, so a picker and the digest runner can never offer different words.
@@ -2184,7 +2215,17 @@ var BY_SQLSTATE = {
2184
2215
  // the grants not copied, land here.
2185
2216
  PGRST202: "store_not_served",
2186
2217
  PGRST205: "store_not_served",
2187
- PGRST301: "door"
2218
+ PGRST301: "door",
2219
+ // PT428 — NOT A FAILURE, and the release gate's live census is what found it
2220
+ // missing: the store raises it and this package answered `internal`, which is
2221
+ // the one classification that tells a screen nothing. A stage gate whose
2222
+ // `on_fail` is `require_approval` files the request and leaves the record
2223
+ // where it was; the transaction is rolled back to the pipeline's own block, so
2224
+ // "nothing was written" is a fact rather than a promise. Landed by lane
2225
+ // STAGE-RULES; mapped here by STAGE-RULES-2 the day after, when the census
2226
+ // caught it — the sixth time that census has been the thing that found a
2227
+ // refusal class rather than a person guessing one.
2228
+ PT428: "needs_approval"
2188
2229
  };
2189
2230
  var MAPPED_SQLSTATES = Object.keys(BY_SQLSTATE);
2190
2231
  function parseDetail(details) {
@@ -2363,16 +2404,17 @@ function createRecordsClient(config) {
2363
2404
  if (!door.ok) return err(door.error);
2364
2405
  const { document, hidden } = unfold(door.data);
2365
2406
  let computed = [];
2407
+ let computedUnavailable = null;
2366
2408
  if (withComputed) {
2367
2409
  const provenance = await callDoor(
2368
2410
  DOORS.computedProvenance,
2369
2411
  { p_organization_id: org, p_record_id: record_id },
2370
2412
  "recordRead.computed"
2371
2413
  );
2372
- if (!provenance.ok) return err(provenance.error);
2373
- computed = provenance.data ?? [];
2414
+ if (provenance.ok) computed = provenance.data ?? [];
2415
+ else computedUnavailable = provenance.error;
2374
2416
  }
2375
- return ok({ record_id, document, hidden, computed });
2417
+ return ok({ record_id, document, hidden, computed, computedUnavailable });
2376
2418
  },
2377
2419
  async list({ table_id, limit = 50, offset = 0 }) {
2378
2420
  const door = await callDoor(
@@ -2711,6 +2753,41 @@ function createRecordsClient(config) {
2711
2753
  "tableStageField"
2712
2754
  );
2713
2755
  },
2756
+ async stageRuleOnFailKinds() {
2757
+ return callDoor(
2758
+ DOORS.stageRuleOnFailKinds,
2759
+ {},
2760
+ "stageRuleOnFailKinds"
2761
+ );
2762
+ },
2763
+ async stageRuleEnforcement() {
2764
+ return callDoor(
2765
+ DOORS.stageRuleEnforcement,
2766
+ { p_organization_id: org },
2767
+ "stageRuleEnforcement"
2768
+ );
2769
+ },
2770
+ async recordStagePending({ record_id }) {
2771
+ return callDoor(
2772
+ DOORS.recordStagePending,
2773
+ { p_organization_id: org, p_record_id: record_id },
2774
+ "recordStagePending"
2775
+ );
2776
+ },
2777
+ async pipelinePending({ table_id }) {
2778
+ return callDoor(
2779
+ DOORS.pipelinePending,
2780
+ { p_organization_id: org, p_table_id: table_id },
2781
+ "pipelinePending"
2782
+ );
2783
+ },
2784
+ async pipelineGatePreview({ table_id, stage, gate }) {
2785
+ return callDoor(
2786
+ DOORS.pipelineGatePreview,
2787
+ { p_organization_id: org, p_table_id: table_id, p_stage: stage, p_gate: gate },
2788
+ "pipelineGatePreview"
2789
+ );
2790
+ },
2714
2791
  async ruleMembers({ rule_id }) {
2715
2792
  return callDoor(
2716
2793
  DOORS.ruleMembers,
@@ -2739,6 +2816,30 @@ function createRecordsClient(config) {
2739
2816
  "bookings"
2740
2817
  );
2741
2818
  },
2819
+ async bookingDeclare(args) {
2820
+ return callDoor(
2821
+ DOORS.bookingDeclare,
2822
+ {
2823
+ p_organization_id: org,
2824
+ p_table_id: args.table_id,
2825
+ p_title: args.title,
2826
+ p_questions: args.questions,
2827
+ // AN EMPTY OBJECT IS NOT A MISTAKE. The store owns every default, so a
2828
+ // page declared with no availability comes back Monday-to-Friday,
2829
+ // nine-to-five, in the organization's own zone — and the screen draws
2830
+ // what came BACK rather than what it sent.
2831
+ p_availability: args.availability ?? {},
2832
+ p_presentation: args.presentation ?? {},
2833
+ p_submission_cap: args.submission_cap ?? null,
2834
+ p_quarantine_rule_id: args.quarantine_rule_id ?? null,
2835
+ p_notify_rule_id: args.notify_rule_id ?? null,
2836
+ p_form_id: args.form_id ?? null,
2837
+ p_slug: args.slug ?? null,
2838
+ p_home_id: args.home_id ?? null
2839
+ },
2840
+ "bookingDeclare"
2841
+ );
2842
+ },
2742
2843
  async formDeclare(args) {
2743
2844
  return callDoor(
2744
2845
  DOORS.formDeclare,
@@ -3163,6 +3264,20 @@ function createRecordsClient(config) {
3163
3264
  "subscriptionPreview"
3164
3265
  );
3165
3266
  },
3267
+ async views(args) {
3268
+ return callDoor(
3269
+ DOORS.views,
3270
+ { p_organization_id: org, p_table_id: args?.table_id ?? null },
3271
+ "views"
3272
+ );
3273
+ },
3274
+ async viewDeclare({ table_id, spec }) {
3275
+ return callDoor(
3276
+ DOORS.viewDeclare,
3277
+ { p_organization_id: org, p_table_id: table_id, p_spec: spec },
3278
+ "viewDeclare"
3279
+ );
3280
+ },
3166
3281
  async subscriptionMute({ rule_id, muted }) {
3167
3282
  return callDoor(
3168
3283
  DOORS.subscriptionMute,
@@ -4392,6 +4507,8 @@ function looksLikeAnId(value) {
4392
4507
 
4393
4508
  // src/pipeline.ts
4394
4509
  var PIPELINE_RULE_KINDS = ["moves", "requires", "who", "limit", "entry"];
4510
+ var STAGE_RULE_ON_FAIL = ["refuse", "require_approval"];
4511
+ var STAGE_RULE_ENFORCEMENT = ["refuse", "warn"];
4395
4512
  function mayDrag(level) {
4396
4513
  return level === "editor" || level === "admin" || level === "owner";
4397
4514
  }
@@ -4725,6 +4842,8 @@ export {
4725
4842
  RULE_NODE_KINDS,
4726
4843
  RULE_USES,
4727
4844
  RecordsProvider,
4845
+ STAGE_RULE_ENFORCEMENT,
4846
+ STAGE_RULE_ON_FAIL,
4728
4847
  STORAGE_MODES,
4729
4848
  STORE_DOORS,
4730
4849
  STORE_KNOBS,