@ai-matrx/records 0.54.0 → 0.56.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.
@@ -1083,6 +1083,11 @@ declare const STORE_DOORS: readonly [{
1083
1083
  readonly args: "";
1084
1084
  readonly returns: "TABLE(function_name text, identity_args text, why text)";
1085
1085
  readonly security: "invoker";
1086
+ }, {
1087
+ readonly name: "doors_refusing_in_another_doors_name";
1088
+ readonly args: "";
1089
+ readonly returns: "TABLE(function_name text, identity_args text, why text)";
1090
+ readonly security: "invoker";
1086
1091
  }, {
1087
1092
  readonly name: "effective_level";
1088
1093
  readonly args: "p_user_id uuid, p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text";
@@ -1293,6 +1298,11 @@ declare const STORE_DOORS: readonly [{
1293
1298
  readonly args: "p_to jsonb, p_value jsonb";
1294
1299
  readonly returns: "jsonb";
1295
1300
  readonly security: "invoker";
1301
+ }, {
1302
+ readonly name: "field_words";
1303
+ readonly args: "p_organization_id uuid, p_field_id uuid, p_value jsonb";
1304
+ readonly returns: "text";
1305
+ readonly security: "invoker";
1296
1306
  }, {
1297
1307
  readonly name: "file_kernel_id";
1298
1308
  readonly args: "";
@@ -1748,6 +1758,11 @@ declare const STORE_DOORS: readonly [{
1748
1758
  readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true";
1749
1759
  readonly returns: "jsonb";
1750
1760
  readonly security: "definer";
1761
+ }, {
1762
+ readonly name: "migrate_purge_hard";
1763
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_compliance_reason text DEFAULT NULL::text, p_chunk integer DEFAULT 200, p_dry_run boolean DEFAULT true";
1764
+ readonly returns: "jsonb";
1765
+ readonly security: "definer";
1751
1766
  }, {
1752
1767
  readonly name: "migrate_reclass";
1753
1768
  readonly args: "p_organization_id uuid, p_id uuid, p_to text DEFAULT 'field'::text, p_note text DEFAULT NULL::text";
@@ -2383,6 +2398,11 @@ declare const STORE_DOORS: readonly [{
2383
2398
  readonly args: "p_organization_id uuid, p_table_id uuid, p_data jsonb";
2384
2399
  readonly returns: "uuid";
2385
2400
  readonly security: "definer";
2401
+ }, {
2402
+ readonly name: "record_write_graph";
2403
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_parent jsonb, p_edges jsonb DEFAULT '[]'::jsonb, p_children jsonb DEFAULT '[]'::jsonb";
2404
+ readonly returns: "jsonb";
2405
+ readonly security: "definer";
2386
2406
  }, {
2387
2407
  readonly name: "record_write_many";
2388
2408
  readonly args: "p_organization_id uuid, p_table_id uuid, p_rows jsonb[], p_ids uuid[] DEFAULT NULL::uuid[]";
@@ -2773,6 +2793,11 @@ declare const STORE_DOORS: readonly [{
2773
2793
  readonly args: "p_organization_id uuid, p_table_id uuid";
2774
2794
  readonly returns: "boolean";
2775
2795
  readonly security: "invoker";
2796
+ }, {
2797
+ readonly name: "table_is_options_table";
2798
+ readonly args: "p_organization_id uuid, p_table_id uuid";
2799
+ readonly returns: "boolean";
2800
+ readonly security: "invoker";
2776
2801
  }, {
2777
2802
  readonly name: "table_kernel_id";
2778
2803
  readonly args: "";
@@ -2838,6 +2863,16 @@ declare const STORE_DOORS: readonly [{
2838
2863
  readonly args: "p_organization_id uuid, p_table_id uuid";
2839
2864
  readonly returns: "text";
2840
2865
  readonly security: "definer";
2866
+ }, {
2867
+ readonly name: "table_unique_rule_fields";
2868
+ readonly args: "p_organization_id uuid, p_table_id uuid";
2869
+ readonly returns: "jsonb";
2870
+ readonly security: "invoker";
2871
+ }, {
2872
+ readonly name: "table_work_kind";
2873
+ readonly args: "p_organization_id uuid, p_table_id uuid";
2874
+ readonly returns: "text";
2875
+ readonly security: "invoker";
2841
2876
  }, {
2842
2877
  readonly name: "tables_at_home";
2843
2878
  readonly args: "p_organization_id uuid, p_home_ids uuid[]";
@@ -3350,7 +3385,7 @@ declare const STORE_REFUSAL_CODES: readonly [{
3350
3385
  readonly raised_by: "context_resolve";
3351
3386
  }, {
3352
3387
  readonly code: "22004";
3353
- readonly raised_by: "_entity_custom_fields_guard,_share_write_person,_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_archive,table_declare,table_share_outside_invite,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare";
3388
+ readonly raised_by: "_entity_custom_fields_guard,_share_write_person,_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_purge_hard,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_graph,record_write_many,relation_carry,relation_own,rule_declare,share_grant,sign_request_create,sign_request_sign,subscription_declare,table_archive,table_declare,table_share_outside_invite,value_restore,view_declare,work_approval_decide,work_approval_request,work_template_declare";
3354
3389
  }, {
3355
3390
  readonly code: "22007";
3356
3391
  readonly raised_by: "dashboard_window_sql";
@@ -3359,7 +3394,7 @@ declare const STORE_REFUSAL_CODES: readonly [{
3359
3394
  readonly raised_by: "rule_eval";
3360
3395
  }, {
3361
3396
  readonly code: "22023";
3362
- readonly raised_by: "_booking_availability,_entity_custom_fields_guard,_take_op_id,_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,field_update,io_export,io_import_begin,io_import_finish,io_import_plan,io_import_report,io_proposal_accept,list_portals,migrate_merge,migrate_reclass,my_levels,organization_clear,page_size,pin_agent_cells,pipeline_move,portal_declare,provenance_write,query_by_coordinates,query_rollup,read_records_archived,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";
3397
+ readonly raised_by: "_booking_availability,_entity_custom_fields_guard,_take_op_id,_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,field_update,io_export,io_import_begin,io_import_finish,io_import_plan,io_import_report,io_proposal_accept,list_portals,migrate_merge,migrate_reclass,my_levels,organization_clear,page_size,pin_agent_cells,pipeline_move,portal_declare,provenance_write,query_by_coordinates,query_rollup,read_records_archived,record_update,record_write_graph,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";
3363
3398
  }, {
3364
3399
  readonly code: "23503";
3365
3400
  readonly raised_by: "_booking_availability,_checklist_instantiate,_containment_guard,_display_spec_for,_field_document_for,_field_type_parity_guard,_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";
@@ -3368,13 +3403,13 @@ declare const STORE_REFUSAL_CODES: readonly [{
3368
3403
  readonly raised_by: "_share_write_person,_unique_rule_holds,doc_sign,doc_signature_write,entity_field_declare,field_declare,home_add,inbound_declare,io_proposal_accept,relation_carry,relation_own,sign_request_cancel,sign_request_create,table_share_outside_resend,work_approval_decide,work_slot_hold";
3369
3404
  }, {
3370
3405
  readonly code: "23514";
3371
- readonly raised_by: "_checklist_instantiate,_checklist_step_guard,_containment_guard,_dated_values_guard,_derived_fields,_display_spec_for,_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,_with_display,_work_shape_guard,_workdoors_approval_guard,assert_columns_are_defined,assert_entity_is_organization_scoped,booking_declare,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_comment_write,io_import_rows,migrate_merge,portal_archive,portal_restore,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";
3406
+ readonly raised_by: "_checklist_instantiate,_checklist_step_guard,_containment_guard,_dated_values_guard,_derived_fields,_display_spec_for,_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,_relation_halves_agree,_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,_with_display,_work_shape_guard,_workdoors_approval_guard,assert_columns_are_defined,assert_entity_is_organization_scoped,booking_declare,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_comment_write,io_import_rows,migrate_merge,migrate_purge_hard,portal_archive,portal_restore,record_write_graph,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";
3372
3407
  }, {
3373
3408
  readonly code: "40001";
3374
3409
  readonly raised_by: "has_visibility_at";
3375
3410
  }, {
3376
3411
  readonly code: "42501";
3377
- readonly raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,agent_table_claim,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,doc_sign,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_invite_accept,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,read_records_archived,read_records_by_ids,read_records_matching,record_table,share_grant,subscription_mute,subscription_preview,table_share_outside_accept,table_share_outside_invite,table_share_outside_resend,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person";
3412
+ readonly raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,agent_table_claim,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,doc_sign,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_purge_hard,migrate_reclass,my_levels,organization_clear,portal_declare,portal_invitation,portal_invite,portal_invite_accept,portal_principal_bind,promote_table,query_visibility_parity,read_record,read_records,read_records_archived,read_records_by_ids,read_records_matching,record_table,record_write_graph,share_grant,subscription_mute,subscription_preview,table_share_outside_accept,table_share_outside_invite,table_share_outside_resend,visibility_as_of,work_approval_decide,work_approval_read,work_approval_request,work_person";
3378
3413
  }, {
3379
3414
  readonly code: "42703";
3380
3415
  readonly raised_by: "entity_table,portal_declare";
@@ -3779,6 +3814,27 @@ interface RecordDocument {
3779
3814
  [fieldKey: string]: unknown;
3780
3815
  }
3781
3816
  /** `custom.record` as the store holds it — the row around the document. */
3817
+ /**
3818
+ * What `custom.record_write_graph` wrote — a parent, the rows that belong to it, and the
3819
+ * edges it stands on, all in one transaction.
3820
+ *
3821
+ * `edges` counts BOTH writers: the edges written through `public.assoc_add` (whose ids are
3822
+ * in `edge_ids`) and the relation targets written through `platform.relation_set`, which
3823
+ * answers a count rather than ids because a relation is one field's worth of targets and
3824
+ * not a list of independent edges. `relations` is that second number on its own, so a
3825
+ * caller can tell them apart instead of subtracting.
3826
+ */
3827
+ interface RecordGraphWritten {
3828
+ parent_id: Uuid;
3829
+ table_id: Uuid | null;
3830
+ child_ids: Uuid[];
3831
+ edge_ids: Uuid[];
3832
+ children: number;
3833
+ edges: number;
3834
+ relations: number;
3835
+ /** The door's own sentence about what it did. Shown, never re-worded. */
3836
+ how: string;
3837
+ }
3782
3838
  interface StoredRecord {
3783
3839
  id: Uuid;
3784
3840
  organization_id: Uuid;
@@ -4203,4 +4259,338 @@ interface FieldPatch {
4203
4259
  expr?: Record<string, unknown>;
4204
4260
  }
4205
4261
 
4206
- export { MERGE_FIELD_SEMANTIC_TYPES as $, ABSENCE_REASONS as A, DELIVERIES as B, type ComputeOn as C, DECLARABLE_FIELD_KINDS as D, type DeclarableFieldKind as E, type FieldTypeWord as F, type Delivery as G, ENTITY_TOKENS as H, type EntityToken as I, FIELD_SENSITIVITIES as J, FIELD_SOURCES as K, FRESHNESS as L, type FieldBehavior as M, type NewFieldDeclaration as N, type OnDelete as O, type PgError as P, type ForbiddenEnvelopeWord as Q, type RelationFlavor as R, type StorageMode as S, type TableType as T, type Uuid as U, type Freshness as V, type WriteConflict as W, type HiddenFieldNotice as X, KERNEL_TABLES as Y, type KernelTableName as Z, MERGE_FIELD_MODIFIERS as _, type TableDisplay as a, MERGE_FIELD_SOURCES as a0, type MergeFieldModifier as a1, type MergeFieldSemanticType as a2, type MergeFieldSource as a3, ON_DELETE as a4, OVERRIDE_POLICIES as a5, type OverridePolicy as a6, PARITY_FIELD_TYPES as a7, PER_VALUE_ACCESS_WORDS as a8, type ParityFieldType as a9, VALUE_ENVELOPE_KEYS as aA, type ValueAlternate as aB, type ValueAlternateKey as aC, type ValueEnvelope as aD, type ValueEnvelopeKey as aE, type ValueSource as aF, err as aG, isRecordsErr as aH, ok as aI, type ParityFieldTypeDescriptor as aa, type PerValueAccessWord as ab, type ProvenancePointer as ac, RELATION_BINDINGS as ad, RELATION_CARDINALITIES as ae, RELATION_FLAVORS as af, RETIRED_ACTOR_WORDS as ag, RULE_NODE_KINDS as ah, RULE_USES as ai, type RecordsErrorCode as aj, type RelationBinding as ak, type RelationDisplay as al, type RetiredActorWord as am, type RuleNodeKind as an, type RuleUse as ao, STORAGE_MODES as ap, STORE_DOORS as aq, STORE_KNOBS as ar, STORE_REFUSAL_CODES as as, type StoreDoorName as at, type StoreRefusalCode as au, TABLE_DISPLAYS as av, TABLE_ORIGINS as aw, TABLE_TYPES as ax, type TableOrigin as ay, VALUE_ALTERNATE_KEYS as az, type FieldSource as b, type FieldRule as c, type FieldSensitivity as d, type ContextPolicy as e, type RelationCardinality as f, type Timestamp as g, type RecordDocument as h, type RecordsResult as i, type RecordRead as j, type ReadRow as k, type Field as l, type StoredRecord as m, type FieldPatch as n, type RecordRevision as o, type ReadValue as p, type FieldProposal as q, type TableProposal as r, type RecordsError as s, type StaleWriteDetail as t, type PredictedRefusal as u, ACTOR_VOCABULARY as v, type AbsenceReason as w, type Actor as x, COMPUTE_ON as y, CONTEXT_POLICIES as z };
4262
+ /**
4263
+ * Who the data belongs to. A test organization is created under this name — the
4264
+ * owner's law #4: every organization, table, record, form, portal, dashboard,
4265
+ * document, checklist, booking page, capture sheet, subscription, pipeline and
4266
+ * enrichment created for a test carries the use case's own name. Cleanup finds
4267
+ * a test organization by `cleanupTag` in its settings, NEVER by a junk name.
4268
+ */
4269
+ interface BusinessIdentity {
4270
+ /** "Harbor Dental Group" — what goes on the organization, the invoice, the screenshot. */
4271
+ name: string;
4272
+ /** "Harbor Dental Group, PLLC" — used on documents that need the legal entity. */
4273
+ legalName?: string;
4274
+ /** One line a stranger would understand: "A six-chair family dental practice." */
4275
+ describes: string;
4276
+ /** Plausible and synthesized. Never a real business's real address. */
4277
+ address: PostalAddress;
4278
+ /** Synthesized, E.164-shaped or the local convention the document uses. */
4279
+ phone: string;
4280
+ /**
4281
+ * Synthesized. NOT a `.example` domain — those read as fake on a screenshot.
4282
+ * Optional, because the law welcomes personal-life use cases and a household
4283
+ * renovation or a family recipe collection genuinely has no website.
4284
+ */
4285
+ website?: string;
4286
+ /** Synthesized mailbox on the same domain: "frontdesk@harbordentalgroup.com". */
4287
+ email: string;
4288
+ /** IANA zone, so dates in the rows make sense together. */
4289
+ timezone: string;
4290
+ }
4291
+ interface PostalAddress {
4292
+ line1: string;
4293
+ line2?: string;
4294
+ city: string;
4295
+ /** State, province or region, in the country's own convention. */
4296
+ region: string;
4297
+ postalCode: string;
4298
+ /** ISO 3166-1 alpha-2. */
4299
+ country: string;
4300
+ }
4301
+ /**
4302
+ * One table of the business, in the words the practitioner uses. `token` is the
4303
+ * slug the store addresses it by; `name` is what a person reads.
4304
+ */
4305
+ interface UseCaseTable {
4306
+ /** snake_case, singular, the practitioner's noun: "patient", "work_order". */
4307
+ token: string;
4308
+ /** "Patients", "Work orders". */
4309
+ name: string;
4310
+ labelSingular: string;
4311
+ labelPlural: string;
4312
+ /** REC-32. One of the seven, closed. Most business tables are `entity`. */
4313
+ type: TableType;
4314
+ display: TableDisplay;
4315
+ /** REC-4. `light` is the whole document; `heavy` is indexed on write. */
4316
+ weight: StorageMode;
4317
+ ordered: boolean;
4318
+ /** A lucide icon name, so the screen is not a wall of identical rows. */
4319
+ icon?: string;
4320
+ /** REC-2. The field key whose value titles a record. Must be a declared field. */
4321
+ titleField: string;
4322
+ /** What this table is FOR, in the practitioner's words. */
4323
+ describes: string;
4324
+ fields: UseCaseField[];
4325
+ /** The seed rows. Enough that the screen looks like a working business. */
4326
+ rows: UseCaseRow[];
4327
+ }
4328
+ /**
4329
+ * One field. `parityType` is the word a person picks in the UI and it must be
4330
+ * one the store resolves — any parity type the store ships, any behaviour they
4331
+ * are made of, or one of the plain synonyms (see `FieldTypeWord`). The set is
4332
+ * `RESOLVABLE_FIELD_TYPE_WORDS`, derived from the registry; never a count or a
4333
+ * list typed out here.
4334
+ */
4335
+ interface UseCaseField {
4336
+ /** snake_case, the practitioner's own name for it: "date_of_birth", "po_number". */
4337
+ key: string;
4338
+ /** "Date of birth", "PO number". Sentence case, the way the form reads. */
4339
+ label: string;
4340
+ parityType: FieldTypeWord;
4341
+ /** FLD-2. The shape of the value, never a second behaviour. */
4342
+ multi?: boolean;
4343
+ /** FLD-2. The values carry their own dates. */
4344
+ dated?: boolean;
4345
+ required?: boolean;
4346
+ /** FLD-N-1. The unit CHANGES THE MEANING and lives on the field: "USD", "lb", "mi". */
4347
+ unit?: string | null;
4348
+ /** "currency", "percent", "email", "phone", "url", "date". Never decoration. */
4349
+ format?: string | null;
4350
+ /** FLD-7. Where the values come from. Defaults to `manual`. */
4351
+ source?: FieldSource;
4352
+ /** FLD-9. A formula says whether it computes on read or on write. */
4353
+ computeOn?: ComputeOn;
4354
+ /** FLD-3. Validation rules the store will enforce. */
4355
+ rules?: FieldRule[];
4356
+ /**
4357
+ * For `select` / `multi_select`: the REAL lifecycle words of this business,
4358
+ * in the order they actually happen. "Scheduled, Confirmed, Seen, No-show" —
4359
+ * never "Option A, Option B".
4360
+ */
4361
+ choices?: string[];
4362
+ /** For a relation field: the `token` of the table it points at. */
4363
+ relationTarget?: string;
4364
+ relationMax?: number;
4365
+ /** AGT-7. The ceiling a merge field's delivery can never widen. */
4366
+ sensitivity: FieldSensitivity;
4367
+ /** FLD-12. Whether an agent may see this field's values at all. */
4368
+ contextPolicy: ContextPolicy;
4369
+ /** What the practitioner would be told about this field, if anything. */
4370
+ help?: string;
4371
+ }
4372
+ /**
4373
+ * One row of seed data.
4374
+ *
4375
+ * `key` is a stable LOCAL id (not a UUID): relationships across tables point at
4376
+ * it, so a template is readable and a seeder can resolve the graph in one pass
4377
+ * without inventing identifiers. Use a meaningful slug — "patient-rivera-m",
4378
+ * not "row-7".
4379
+ */
4380
+ interface UseCaseRow {
4381
+ key: string;
4382
+ /**
4383
+ * Keyed by the table's field keys. A relation field's value is the `key` (or
4384
+ * an array of keys) of rows in the target table.
4385
+ */
4386
+ values: Record<string, unknown>;
4387
+ }
4388
+ /**
4389
+ * REL-1…REL-9. The domain truth, stated once: "an invoice belongs to the job it
4390
+ * bills, and a job belongs to the client who asked for it."
4391
+ *
4392
+ * The field side carries `relationTarget`; this is the declaration a seeder
4393
+ * reads, because it also carries the flavour, the cardinality, what happens to
4394
+ * the far side on delete, and the reverse name.
4395
+ */
4396
+ interface UseCaseRelationship {
4397
+ /** One sentence of domain truth. Not "links A to B". */
4398
+ describes: string;
4399
+ /** The table that HOLDS the relation field. */
4400
+ fromTable: string;
4401
+ /** The field key on `fromTable`. Must be declared and must be a relation. */
4402
+ fromField: string;
4403
+ /** The `token` of the table it points at. */
4404
+ toTable: string;
4405
+ /** REL-1. Ownership is one fact, stored once, read from the field's side. */
4406
+ flavor: RelationFlavor;
4407
+ /** REL-7. */
4408
+ cardinality: RelationCardinality;
4409
+ /** REL-2. What happens to the far side, separate from flavour. */
4410
+ onDelete: OnDelete;
4411
+ /** REL-9. The reverse, visible from both ends, and NOT a second field. */
4412
+ inverseKey: string;
4413
+ }
4414
+ /** Who is allowed to open a form. */
4415
+ type FormAudience = "public" | "member" | "staff";
4416
+ /**
4417
+ * A form a practitioner in this business would actually put in front of someone
4418
+ * — "the Harbor Dental new-patient intake", never "Test Form 1".
4419
+ */
4420
+ interface UseCaseForm {
4421
+ token: string;
4422
+ name: string;
4423
+ /** What it is for, and who fills it in. */
4424
+ describes: string;
4425
+ audience: FormAudience;
4426
+ /** The table a submission becomes a record of. */
4427
+ table: string;
4428
+ fields: UseCaseFormField[];
4429
+ submitLabel: string;
4430
+ /** What the person sees after they submit. Real words, not "Success!". */
4431
+ confirmation: string;
4432
+ }
4433
+ interface UseCaseFormField {
4434
+ /** A field key on the form's table. */
4435
+ fieldKey: string;
4436
+ /** Override the field's own label when the form asks it differently. */
4437
+ label?: string;
4438
+ required?: boolean;
4439
+ /** The helper line under the input, if a practitioner would want one. */
4440
+ help?: string;
4441
+ }
4442
+ /**
4443
+ * The real lifecycle a record moves through in this business, in order. A
4444
+ * pipeline's stages are the words the staff say out loud.
4445
+ */
4446
+ interface UseCasePipeline {
4447
+ token: string;
4448
+ name: string;
4449
+ describes: string;
4450
+ /** The table whose records move through it. */
4451
+ table: string;
4452
+ /** The `select` field that holds the current stage. */
4453
+ stageField: string;
4454
+ stages: UseCasePipelineStage[];
4455
+ }
4456
+ interface UseCasePipelineStage {
4457
+ /** Must appear in the stage field's `choices`. */
4458
+ key: string;
4459
+ label: string;
4460
+ /** What is true of a record sitting here, and what moves it on. */
4461
+ describes: string;
4462
+ /** Roughly how long a record sits here, so a board looks believable. */
4463
+ typicalDurationDays?: number;
4464
+ }
4465
+ /**
4466
+ * The question the owner of this business actually asks a dashboard on Monday
4467
+ * morning — "how much have we invoiced this month that hasn't been paid?" —
4468
+ * plus how it is answered from the tables above.
4469
+ */
4470
+ interface UseCaseDashboardQuestion {
4471
+ /** The question in the practitioner's own words, ending in a question mark. */
4472
+ question: string;
4473
+ /** Why they care. What they DO differently depending on the answer. */
4474
+ whyItMatters: string;
4475
+ table: string;
4476
+ aggregate: "count" | "sum" | "avg" | "min" | "max";
4477
+ /** The field aggregated. Omitted only for `count`. */
4478
+ of?: string;
4479
+ groupBy?: string;
4480
+ /** A plain-language filter: "status is Unpaid and due_date is before today". */
4481
+ filter?: string;
4482
+ /** What the number IS: "USD", "days", "appointments". */
4483
+ answerUnit: string;
4484
+ }
4485
+ /**
4486
+ * A document this business really sends. The body carries merge fields in
4487
+ * `{{double_brace}}` form; every one of them is declared below and resolves to a
4488
+ * field on the document's table (or a stated literal).
4489
+ */
4490
+ interface UseCaseDocumentTemplate {
4491
+ token: string;
4492
+ name: string;
4493
+ describes: string;
4494
+ table: string;
4495
+ /** The subject or title line, merge fields allowed. */
4496
+ title: string;
4497
+ /** The body. Real prose this business would send, merge fields inline. */
4498
+ body: string;
4499
+ mergeFields: UseCaseMergeField[];
4500
+ }
4501
+ interface UseCaseMergeField {
4502
+ /** The token inside `{{ }}` in the body. */
4503
+ key: string;
4504
+ /**
4505
+ * The field key it reads, on the document's table — or, when it is not a
4506
+ * field, the word `business` (from `BusinessIdentity`) or `today`.
4507
+ */
4508
+ from: string;
4509
+ describes: string;
4510
+ }
4511
+ /** How a notification reaches someone. */
4512
+ type NotificationChannel = "email" | "sms" | "in_app";
4513
+ /**
4514
+ * The one automatic message this business would genuinely want — the thing a
4515
+ * practitioner sets up on day one and never turns off.
4516
+ */
4517
+ interface UseCaseNotificationRule {
4518
+ token: string;
4519
+ name: string;
4520
+ describes: string;
4521
+ when: UseCaseNotificationTrigger;
4522
+ /** Who it goes to, in the business's own words: "the assigned hygienist". */
4523
+ audience: string;
4524
+ channel: NotificationChannel;
4525
+ /** The actual message. Merge fields allowed, same convention as documents. */
4526
+ message: string;
4527
+ }
4528
+ interface UseCaseNotificationTrigger {
4529
+ table: string;
4530
+ event: "created" | "updated" | "stage_entered" | "due" | "overdue";
4531
+ /** For `stage_entered`: the stage key. */
4532
+ stage?: string;
4533
+ /** For `due` / `overdue`: the date field watched. */
4534
+ field?: string;
4535
+ /** For `due`: how many days ahead it fires. */
4536
+ daysBefore?: number;
4537
+ }
4538
+ /**
4539
+ * Where the shape and the values came from. `synthesized` means a person wrote
4540
+ * plausible values out of domain knowledge; `public-data` means the numbers or
4541
+ * names were derived from a genuinely public dataset, which is named.
4542
+ *
4543
+ * Either way the law holds: no real person, no real customer, no production row.
4544
+ */
4545
+ interface UseCaseProvenance {
4546
+ kind: "synthesized" | "public-data";
4547
+ /** Named when `kind` is `public-data`. */
4548
+ source?: string;
4549
+ /** Who or what wrote this file, and when. */
4550
+ authoredBy: string;
4551
+ authoredOn: string;
4552
+ /**
4553
+ * The affirmation, carried in the data so a reviewer can see it: every person,
4554
+ * address, phone and mailbox here is invented and belongs to nobody.
4555
+ */
4556
+ noRealPeople: true;
4557
+ }
4558
+ /** One real business, and everything a test, seed, demo or screenshot needs of it. */
4559
+ interface UseCase {
4560
+ /** kebab-case and unique: "harbor-dental-new-patient-intake". */
4561
+ id: string;
4562
+ /**
4563
+ * THE SENTENCE. Who the user is, what business they run, and what job this
4564
+ * exact feature does for them — one sentence, at the top, before anything
4565
+ * else. This is the first thing the law asks for and the validator checks it.
4566
+ */
4567
+ useCase: string;
4568
+ /** The industry, for rotation: "Dentistry", "Property management". */
4569
+ industry: string;
4570
+ business: BusinessIdentity;
4571
+ /**
4572
+ * The tag written into a test organization's settings so cleanup can find it.
4573
+ * Cleanup finds test data by THIS, never by a junk name.
4574
+ */
4575
+ cleanupTag: string;
4576
+ tables: UseCaseTable[];
4577
+ relationships: UseCaseRelationship[];
4578
+ form: UseCaseForm;
4579
+ pipeline: UseCasePipeline;
4580
+ dashboardQuestion: UseCaseDashboardQuestion;
4581
+ documentTemplate: UseCaseDocumentTemplate;
4582
+ notificationRule: UseCaseNotificationRule;
4583
+ provenance: UseCaseProvenance;
4584
+ }
4585
+ /** What the registry lists without loading a use case's rows. */
4586
+ interface UseCaseSummary {
4587
+ id: string;
4588
+ useCase: string;
4589
+ industry: string;
4590
+ businessName: string;
4591
+ /** How many tables and rows the file carries, so a caller can pick by size. */
4592
+ tableCount: number;
4593
+ rowCount: number;
4594
+ }
4595
+
4596
+ export { type EntityToken as $, type TableProposal as A, type BusinessIdentity as B, type RecordsError as C, type PgError as D, type StaleWriteDetail as E, type FormAudience as F, type PredictedRefusal as G, ABSENCE_REASONS as H, ACTOR_VOCABULARY as I, type AbsenceReason as J, type Actor as K, COMPUTE_ON as L, CONTEXT_POLICIES as M, type NotificationChannel as N, type ComputeOn as O, type PostalAddress as P, type ContextPolicy as Q, type RecordDocument as R, type StoredRecord as S, type Timestamp as T, type UseCase as U, DECLARABLE_FIELD_KINDS as V, type WriteConflict as W, DELIVERIES as X, type DeclarableFieldKind as Y, type Delivery as Z, ENTITY_TOKENS as _, type UseCaseSummary as a, err as a$, FIELD_SENSITIVITIES as a0, FIELD_SOURCES as a1, FRESHNESS as a2, type FieldBehavior as a3, type FieldRule as a4, type FieldSensitivity as a5, type FieldSource as a6, type FieldTypeWord as a7, type ForbiddenEnvelopeWord as a8, type Freshness as a9, type RelationBinding as aA, type RelationCardinality as aB, type RelationDisplay as aC, type RelationFlavor as aD, type RetiredActorWord as aE, type RuleNodeKind as aF, type RuleUse as aG, STORAGE_MODES as aH, STORE_DOORS as aI, STORE_KNOBS as aJ, STORE_REFUSAL_CODES as aK, type StorageMode as aL, type StoreDoorName as aM, type StoreRefusalCode as aN, TABLE_DISPLAYS as aO, TABLE_ORIGINS as aP, TABLE_TYPES as aQ, type TableDisplay as aR, type TableOrigin as aS, type TableType as aT, VALUE_ALTERNATE_KEYS as aU, VALUE_ENVELOPE_KEYS as aV, type ValueAlternate as aW, type ValueAlternateKey as aX, type ValueEnvelope as aY, type ValueEnvelopeKey as aZ, type ValueSource as a_, type HiddenFieldNotice as aa, KERNEL_TABLES as ab, type KernelTableName as ac, MERGE_FIELD_MODIFIERS as ad, MERGE_FIELD_SEMANTIC_TYPES as ae, MERGE_FIELD_SOURCES as af, type MergeFieldModifier as ag, type MergeFieldSemanticType as ah, type MergeFieldSource as ai, ON_DELETE as aj, OVERRIDE_POLICIES as ak, type OnDelete as al, type OverridePolicy as am, PARITY_FIELD_TYPES as an, PER_VALUE_ACCESS_WORDS as ao, type ParityFieldType as ap, type ParityFieldTypeDescriptor as aq, type PerValueAccessWord as ar, type ProvenancePointer as as, RELATION_BINDINGS as at, RELATION_CARDINALITIES as au, RELATION_FLAVORS as av, RETIRED_ACTOR_WORDS as aw, RULE_NODE_KINDS as ax, RULE_USES as ay, type RecordsErrorCode as az, type UseCaseDashboardQuestion as b, isRecordsErr as b0, ok as b1, type UseCaseDocumentTemplate as c, type UseCaseField as d, type UseCaseForm as e, type UseCaseFormField as f, type UseCaseMergeField as g, type UseCaseNotificationRule as h, type UseCaseNotificationTrigger as i, type UseCasePipeline as j, type UseCasePipelineStage as k, type UseCaseProvenance as l, type UseCaseRelationship as m, type UseCaseRow as n, type UseCaseTable as o, type Uuid as p, type RecordsResult as q, type RecordGraphWritten as r, type RecordRead as s, type ReadRow as t, type Field as u, type NewFieldDeclaration as v, type FieldPatch as w, type RecordRevision as x, type ReadValue as y, type FieldProposal as z };