@ai-matrx/records 0.3.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.
@@ -0,0 +1,2723 @@
1
+ declare const ACTOR_VOCABULARY: readonly ["user", "agent", "system"];
2
+ /** The three words the store still accepts and rewrites, and what each becomes. */
3
+ declare const RETIRED_ACTOR_WORDS: {
4
+ readonly ai: "agent";
5
+ readonly code: "system";
6
+ readonly human: "user";
7
+ };
8
+ declare const ABSENCE_REASONS: readonly ["never asked", "none", "refused", "conflicting"];
9
+ declare const VALUE_ENVELOPE_KEYS: readonly ["ver", "src", "actor", "on_behalf_of", "at", "absent", "alternates", "dated"];
10
+ declare const VALUE_ALTERNATE_KEYS: readonly ["value", "src", "rank"];
11
+ declare const STORAGE_MODES: readonly ["light", "heavy"];
12
+ declare const RULE_USES: readonly ["validate", "compute", "membership", "applicability"];
13
+ declare const PER_VALUE_ACCESS_WORDS: readonly ["visibility", "access", "share", "acl", "permission", "permissions", "secret"];
14
+ /** FLD-11's parity floor, each with the behaviour it is MADE OF (FLD-1). */
15
+ declare const PARITY_FIELD_TYPES: readonly [{
16
+ readonly parity_type: "attachment";
17
+ readonly behavior: "relation";
18
+ readonly made_of: "REC-31: a File record reached through a relation, target the kernel `File` Table";
19
+ }, {
20
+ readonly parity_type: "currency";
21
+ readonly behavior: "range";
22
+ readonly made_of: "FLD-N-1: a number whose UNIT is the currency and whose format is currency — on the Field, never in presentation";
23
+ }, {
24
+ readonly parity_type: "datetime";
25
+ readonly behavior: "range";
26
+ readonly made_of: "a range of kind date or datetime — the dated modifier says the VALUES are dated, which is a different question";
27
+ }, {
28
+ readonly parity_type: "email";
29
+ readonly behavior: "text";
30
+ readonly made_of: "text whose format is email";
31
+ }, {
32
+ readonly parity_type: "formula";
33
+ readonly behavior: "formula";
34
+ readonly made_of: "FLD-9: a declared computation, on read or on write, evaluated by custom.rule_eval";
35
+ }, {
36
+ readonly parity_type: "lookup";
37
+ readonly behavior: "formula";
38
+ readonly made_of: "a Value read THROUGH a relation — config.via names the relation field, config.pick the Value on the far side";
39
+ }, {
40
+ readonly parity_type: "member";
41
+ readonly behavior: "relation";
42
+ readonly made_of: "a person: a relation whose target is the kernel `Person` Table";
43
+ }, {
44
+ readonly parity_type: "multi_select";
45
+ readonly behavior: "list";
46
+ readonly made_of: "many choices from the same Table — the multi modifier, never a second behaviour";
47
+ }, {
48
+ readonly parity_type: "percent";
49
+ readonly behavior: "range";
50
+ readonly made_of: "a number whose unit is % and whose format is percent";
51
+ }, {
52
+ readonly parity_type: "phone";
53
+ readonly behavior: "text";
54
+ readonly made_of: "text whose format is phone";
55
+ }, {
56
+ readonly parity_type: "rollup";
57
+ readonly behavior: "formula";
58
+ readonly made_of: "an aggregate ALONG a relation — config.via, config.of, config.agg; far-side ids are taken DISTINCT, so nothing is counted twice";
59
+ }, {
60
+ readonly parity_type: "select";
61
+ readonly behavior: "list";
62
+ readonly made_of: "one choice from a Table shown as a list (FLD-5/FLD-6)";
63
+ }, {
64
+ readonly parity_type: "url";
65
+ readonly behavior: "text";
66
+ readonly made_of: "text whose format is url, with the pattern Rule that makes the format enforceable";
67
+ }];
68
+ /** The node kinds `custom.rule_eval` evaluates, and the lane that owns each. */
69
+ declare const RULE_NODE_KINDS: readonly [{
70
+ readonly node: "add";
71
+ readonly evaluated_by: "W1-RULE";
72
+ }, {
73
+ readonly node: "and";
74
+ readonly evaluated_by: "W1-RULE";
75
+ }, {
76
+ readonly node: "concat";
77
+ readonly evaluated_by: "W1-RULE";
78
+ }, {
79
+ readonly node: "const";
80
+ readonly evaluated_by: "W1-RULE";
81
+ }, {
82
+ readonly node: "div";
83
+ readonly evaluated_by: "W1-RULE";
84
+ }, {
85
+ readonly node: "eq";
86
+ readonly evaluated_by: "W1-RULE";
87
+ }, {
88
+ readonly node: "field";
89
+ readonly evaluated_by: "W1-RULE";
90
+ }, {
91
+ readonly node: "gt";
92
+ readonly evaluated_by: "W1-RULE";
93
+ }, {
94
+ readonly node: "gte";
95
+ readonly evaluated_by: "W1-RULE";
96
+ }, {
97
+ readonly node: "length";
98
+ readonly evaluated_by: "W1-RULE";
99
+ }, {
100
+ readonly node: "lt";
101
+ readonly evaluated_by: "W1-RULE";
102
+ }, {
103
+ readonly node: "lte";
104
+ readonly evaluated_by: "W1-RULE";
105
+ }, {
106
+ readonly node: "matches";
107
+ readonly evaluated_by: "W1-RULE";
108
+ }, {
109
+ readonly node: "merge_field";
110
+ readonly evaluated_by: "W5-MERGE-B";
111
+ }, {
112
+ readonly node: "mul";
113
+ readonly evaluated_by: "W1-RULE";
114
+ }, {
115
+ readonly node: "ne";
116
+ readonly evaluated_by: "W1-RULE";
117
+ }, {
118
+ readonly node: "not";
119
+ readonly evaluated_by: "W1-RULE";
120
+ }, {
121
+ readonly node: "or";
122
+ readonly evaluated_by: "W1-RULE";
123
+ }, {
124
+ readonly node: "parent_field";
125
+ readonly evaluated_by: "W1-RULE-APPLY";
126
+ }, {
127
+ readonly node: "present";
128
+ readonly evaluated_by: "W1-RULE";
129
+ }, {
130
+ readonly node: "sub";
131
+ readonly evaluated_by: "W1-RULE";
132
+ }];
133
+ /** REC-27. The kernel, by name and by id, as the store holds it. */
134
+ declare const KERNEL_TABLES: readonly [{
135
+ readonly id: "11111111-0000-4000-8000-000000000002";
136
+ readonly name: "Field";
137
+ }, {
138
+ readonly id: "11111111-0000-4000-8000-000000000006";
139
+ readonly name: "File";
140
+ }, {
141
+ readonly id: "11111111-0000-4000-8000-000000000009";
142
+ readonly name: "Merge Field";
143
+ }, {
144
+ readonly id: "11111111-0000-4000-8000-000000000004";
145
+ readonly name: "Organization";
146
+ }, {
147
+ readonly id: "11111111-0000-4000-8000-000000000005";
148
+ readonly name: "Person";
149
+ }, {
150
+ readonly id: "11111111-0000-4000-8000-000000000007";
151
+ readonly name: "Presentation";
152
+ }, {
153
+ readonly id: "11111111-0000-4000-8000-000000000003";
154
+ readonly name: "Rule";
155
+ }, {
156
+ readonly id: "11111111-0000-4000-8000-000000000001";
157
+ readonly name: "Table";
158
+ }, {
159
+ readonly id: "11111111-0000-4000-8000-000000000008";
160
+ readonly name: "Widget";
161
+ }];
162
+ /**
163
+ * Every door the store actually has, with the argument list and the result the
164
+ * catalogue reports. A client call whose door is not in this list is answered
165
+ * `door_absent` by name — never a guess, never a silent no-op.
166
+ */
167
+ declare const STORE_DOORS: readonly [{
168
+ readonly name: "absence_reasons";
169
+ readonly args: "";
170
+ readonly returns: "text[]";
171
+ readonly security: "invoker";
172
+ }, {
173
+ readonly name: "actor_vocabulary";
174
+ readonly args: "";
175
+ readonly returns: "text[]";
176
+ readonly security: "invoker";
177
+ }, {
178
+ readonly name: "actor_word";
179
+ readonly args: "p_declared text";
180
+ readonly returns: "text";
181
+ readonly security: "invoker";
182
+ }, {
183
+ readonly name: "agent_context";
184
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 50";
185
+ readonly returns: "jsonb";
186
+ readonly security: "invoker";
187
+ }, {
188
+ readonly name: "agg_assert_key";
189
+ readonly args: "p_key text";
190
+ readonly returns: "text";
191
+ readonly security: "invoker";
192
+ }, {
193
+ readonly name: "agg_buckets";
194
+ readonly args: "";
195
+ readonly returns: "text[]";
196
+ readonly security: "invoker";
197
+ }, {
198
+ readonly name: "agg_deliver";
199
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid, p_channel text, p_recipient_user_id uuid, p_event_key text, p_subject text, p_body text, p_payload jsonb DEFAULT '{}'::jsonb";
200
+ readonly returns: "uuid";
201
+ readonly security: "invoker";
202
+ }, {
203
+ readonly name: "agg_digest_run";
204
+ readonly args: "p_organization_id uuid, p_rule_id uuid DEFAULT NULL::uuid, p_since timestamp with time zone DEFAULT NULL::timestamp with time zone";
205
+ readonly returns: "integer";
206
+ readonly security: "invoker";
207
+ }, {
208
+ readonly name: "agg_explain";
209
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_group_by jsonb DEFAULT '[]'::jsonb, p_measures jsonb DEFAULT '[]'::jsonb, p_bucket jsonb DEFAULT NULL::jsonb, p_filter jsonb DEFAULT '{}'::jsonb, p_required text DEFAULT 'viewer'::text";
210
+ readonly returns: "jsonb";
211
+ readonly security: "invoker";
212
+ }, {
213
+ readonly name: "agg_operations";
214
+ readonly args: "";
215
+ readonly returns: "text[]";
216
+ readonly security: "invoker";
217
+ }, {
218
+ readonly name: "agg_sql";
219
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_group_by jsonb DEFAULT '[]'::jsonb, p_measures jsonb DEFAULT '[]'::jsonb, p_bucket jsonb DEFAULT NULL::jsonb, p_filter jsonb DEFAULT '{}'::jsonb, p_limit integer DEFAULT 200, p_required text DEFAULT 'viewer'::text";
220
+ readonly returns: "text";
221
+ readonly security: "invoker";
222
+ }, {
223
+ readonly name: "agg_subscription_cadences";
224
+ readonly args: "";
225
+ readonly returns: "text[]";
226
+ readonly security: "invoker";
227
+ }, {
228
+ readonly name: "agg_subscription_fire";
229
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_changed_field_ids jsonb DEFAULT '[]'::jsonb";
230
+ readonly returns: "integer";
231
+ readonly security: "invoker";
232
+ }, {
233
+ readonly name: "agg_subscriptions";
234
+ readonly args: "p_organization_id uuid, p_saved_view_id uuid DEFAULT NULL::uuid, p_cadence text DEFAULT NULL::text";
235
+ readonly returns: "TABLE(rule_id uuid, saved_view_id uuid, cadence text, schedule text, channel text, recipient_user_id uuid, event_key text, name text)";
236
+ readonly security: "invoker";
237
+ }, {
238
+ readonly name: "agg_value_sql";
239
+ readonly args: "p_key text";
240
+ readonly returns: "text";
241
+ readonly security: "invoker";
242
+ }, {
243
+ readonly name: "agg_view_admits";
244
+ readonly args: "p_organization_id uuid, p_saved_view_id uuid, p_record_id uuid";
245
+ readonly returns: "boolean";
246
+ readonly security: "invoker";
247
+ }, {
248
+ readonly name: "anon_capture";
249
+ readonly args: "p_organization_id uuid, p_client_key text, p_table_id uuid, p_payload jsonb, p_device text DEFAULT NULL::text, p_captured_at timestamp with time zone DEFAULT NULL::timestamp with time zone";
250
+ readonly returns: "uuid";
251
+ readonly security: "definer";
252
+ }, {
253
+ readonly name: "anon_clear";
254
+ readonly args: "p_organization_id uuid, p_submission_id uuid";
255
+ readonly returns: "uuid";
256
+ readonly security: "definer";
257
+ }, {
258
+ readonly name: "anon_inbound_land";
259
+ readonly args: "p_address text, p_secret text, p_payload jsonb, p_raw_payload jsonb DEFAULT '{}'::jsonb, p_client_key text DEFAULT NULL::text";
260
+ readonly returns: "uuid";
261
+ readonly security: "definer";
262
+ }, {
263
+ readonly name: "anon_publish";
264
+ readonly args: "p_organization_id uuid, p_form_id uuid, p_published boolean DEFAULT true";
265
+ readonly returns: "timestamp with time zone";
266
+ readonly security: "definer";
267
+ }, {
268
+ readonly name: "anon_rate_take";
269
+ readonly args: "p_organization_id uuid, p_form_id uuid, p_bucket text, p_token_id uuid DEFAULT NULL::uuid";
270
+ readonly returns: "integer";
271
+ readonly security: "definer";
272
+ }, {
273
+ readonly name: "anon_token_issue";
274
+ 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";
275
+ readonly returns: "TABLE(token_id uuid, secret text)";
276
+ readonly security: "definer";
277
+ }, {
278
+ readonly name: "anon_token_revoke";
279
+ readonly args: "p_organization_id uuid, p_token_id uuid";
280
+ readonly returns: "boolean";
281
+ readonly security: "definer";
282
+ }, {
283
+ readonly name: "anon_token_verify";
284
+ readonly args: "p_secret text, p_origin text, p_required_mode text";
285
+ readonly returns: "TABLE(token_id uuid, organization_id uuid, form_id uuid, saved_view_id uuid, record_id uuid, mode text)";
286
+ readonly security: "definer";
287
+ }, {
288
+ readonly name: "anon_write";
289
+ readonly args: "p_secret text, p_origin text, p_payload jsonb, p_client_key text DEFAULT NULL::text, p_raw_payload jsonb DEFAULT '{}'::jsonb";
290
+ readonly returns: "uuid";
291
+ readonly security: "definer";
292
+ }, {
293
+ readonly name: "applicable_fields";
294
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_record_type text DEFAULT NULL::text";
295
+ readonly returns: "SETOF custom.record";
296
+ readonly security: "definer";
297
+ }, {
298
+ readonly name: "assert_client_may_reach";
299
+ readonly args: "p_organization_id uuid, p_door text";
300
+ readonly returns: "void";
301
+ readonly security: "invoker";
302
+ }, {
303
+ readonly name: "assert_organization_wall";
304
+ readonly args: "p_kind text, p_organization_id uuid, p_row jsonb";
305
+ readonly returns: "void";
306
+ readonly security: "invoker";
307
+ }, {
308
+ readonly name: "assert_store_door";
309
+ readonly args: "p_organization_id uuid, p_door text";
310
+ readonly returns: "void";
311
+ readonly security: "invoker";
312
+ }, {
313
+ readonly name: "bump_epoch";
314
+ readonly args: "p_entity_type text, p_entity_id uuid, p_organization_id uuid DEFAULT NULL::uuid";
315
+ readonly returns: "bigint";
316
+ readonly security: "definer";
317
+ }, {
318
+ readonly name: "cache_lookup";
319
+ readonly args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid";
320
+ readonly returns: "permission_level";
321
+ readonly security: "definer";
322
+ }, {
323
+ readonly name: "caller_role";
324
+ readonly args: "";
325
+ readonly returns: "name";
326
+ readonly security: "invoker";
327
+ }, {
328
+ readonly name: "client_write_grants";
329
+ readonly args: "";
330
+ readonly returns: "TABLE(role_name text, object_name text, privilege text)";
331
+ readonly security: "invoker";
332
+ }, {
333
+ readonly name: "computed_provenance";
334
+ readonly args: "p_organization_id uuid, p_record_id uuid";
335
+ readonly returns: "TABLE(field_key text, field_id uuid, value jsonb, rule_id uuid, rule_version integer, computed_at timestamp with time zone)";
336
+ readonly security: "invoker";
337
+ }, {
338
+ readonly name: "containment_chain";
339
+ readonly args: "p_organization_id uuid, p_record_id uuid";
340
+ readonly returns: "TABLE(ancestor_id uuid, depth integer)";
341
+ readonly security: "invoker";
342
+ }, {
343
+ readonly name: "containment_depth_ceiling";
344
+ readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
345
+ readonly returns: "integer";
346
+ readonly security: "invoker";
347
+ }, {
348
+ readonly name: "containment_edges";
349
+ readonly args: "p_organization_id uuid";
350
+ readonly returns: "TABLE(parent_id uuid, child_id uuid, via text)";
351
+ readonly security: "invoker";
352
+ }, {
353
+ readonly name: "containment_parent";
354
+ readonly args: "p_data jsonb";
355
+ readonly returns: "uuid";
356
+ readonly security: "invoker";
357
+ }, {
358
+ readonly name: "custom_fields_tables";
359
+ readonly args: "";
360
+ readonly returns: "TABLE(token text, schema_name text, table_name text)";
361
+ readonly security: "invoker";
362
+ }, {
363
+ readonly name: "dependency_cycle";
364
+ readonly args: "p_organization_id uuid, p_row custom.record";
365
+ readonly returns: "text[]";
366
+ readonly security: "invoker";
367
+ }, {
368
+ readonly name: "dependency_label";
369
+ readonly args: "p_organization_id uuid, p_node text";
370
+ readonly returns: "text";
371
+ readonly security: "invoker";
372
+ }, {
373
+ readonly name: "derive_visibility";
374
+ readonly args: "p_container_type text, p_container_id uuid";
375
+ readonly returns: "TABLE(item_type text, item_id uuid, depth integer, max_level permission_level)";
376
+ readonly security: "definer";
377
+ }, {
378
+ readonly name: "derived_value";
379
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb";
380
+ readonly returns: "jsonb";
381
+ readonly security: "invoker";
382
+ }, {
383
+ readonly name: "derived_values";
384
+ readonly args: "p_organization_id uuid, p_record_id uuid";
385
+ readonly returns: "jsonb";
386
+ readonly security: "invoker";
387
+ }, {
388
+ readonly name: "doc_content_hash";
389
+ readonly args: "p_body text";
390
+ readonly returns: "text";
391
+ readonly security: "invoker";
392
+ }, {
393
+ readonly name: "doc_format_value";
394
+ readonly args: "p_field_data jsonb, p_value jsonb";
395
+ readonly returns: "text";
396
+ readonly security: "invoker";
397
+ }, {
398
+ readonly name: "doc_render_body";
399
+ readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid";
400
+ readonly returns: "text";
401
+ readonly security: "invoker";
402
+ }, {
403
+ readonly name: "doc_render_document";
404
+ readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid";
405
+ readonly returns: "uuid";
406
+ readonly security: "definer";
407
+ }, {
408
+ readonly name: "doc_render_write";
409
+ 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";
410
+ readonly returns: "uuid";
411
+ readonly security: "definer";
412
+ }, {
413
+ readonly name: "doc_sign";
414
+ readonly args: "p_organization_id uuid, p_render_id uuid, p_field_key text, p_signer_name text, p_signer_user_id uuid DEFAULT NULL::uuid";
415
+ readonly returns: "uuid";
416
+ readonly security: "definer";
417
+ }, {
418
+ readonly name: "doc_signature_field_ok";
419
+ readonly args: "p_field_data jsonb";
420
+ readonly returns: "boolean";
421
+ readonly security: "invoker";
422
+ }, {
423
+ readonly name: "doc_signature_intact";
424
+ readonly args: "p_organization_id uuid, p_signature_id uuid";
425
+ readonly returns: "jsonb";
426
+ readonly security: "invoker";
427
+ }, {
428
+ readonly name: "doc_signature_write";
429
+ 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";
430
+ readonly returns: "uuid";
431
+ readonly security: "definer";
432
+ }, {
433
+ readonly name: "doc_template_save";
434
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
435
+ readonly returns: "uuid";
436
+ readonly security: "definer";
437
+ }, {
438
+ readonly name: "doc_token_pattern";
439
+ readonly args: "";
440
+ readonly returns: "text";
441
+ readonly security: "invoker";
442
+ }, {
443
+ readonly name: "doc_tokens";
444
+ readonly args: "p_body text";
445
+ readonly returns: "TABLE(ordinal integer, raw text, field_id uuid)";
446
+ readonly security: "invoker";
447
+ }, {
448
+ readonly name: "doc_unresolved_tokens";
449
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_body text";
450
+ readonly returns: "TABLE(raw text, field_id uuid, why text)";
451
+ readonly security: "invoker";
452
+ }, {
453
+ readonly name: "export_records";
454
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000";
455
+ readonly returns: "TABLE(id uuid, document jsonb)";
456
+ readonly security: "invoker";
457
+ }, {
458
+ readonly name: "external_foreign_table_findings";
459
+ readonly args: "";
460
+ readonly returns: "SETOF text";
461
+ readonly security: "definer";
462
+ }, {
463
+ readonly name: "external_history_event";
464
+ readonly args: "p_organization_id uuid, p_link_id uuid, p_operation text";
465
+ readonly returns: "bigint";
466
+ readonly security: "definer";
467
+ }, {
468
+ readonly name: "external_rows";
469
+ readonly args: "p_organization_id uuid, p_source_id uuid";
470
+ readonly returns: "SETOF jsonb";
471
+ readonly security: "definer";
472
+ }, {
473
+ readonly name: "external_source_declare";
474
+ readonly args: "p_organization_id uuid, p_tier text, p_connection_token text, p_external_schema text, p_external_table text, p_link_template text";
475
+ readonly returns: "uuid";
476
+ readonly security: "definer";
477
+ }, {
478
+ readonly name: "external_stub_upsert";
479
+ readonly args: "p_organization_id uuid, p_source_id uuid, p_table_id uuid, p_external_key text, p_link_url text, p_cached_title text";
480
+ readonly returns: "uuid";
481
+ readonly security: "definer";
482
+ }, {
483
+ readonly name: "external_tier_contract";
484
+ readonly args: "";
485
+ readonly returns: "jsonb";
486
+ readonly security: "definer";
487
+ }, {
488
+ readonly name: "external_write_through";
489
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb";
490
+ readonly returns: "void";
491
+ readonly security: "definer";
492
+ }, {
493
+ readonly name: "external_writes_set";
494
+ readonly args: "p_organization_id uuid, p_source_id uuid, p_enabled boolean";
495
+ readonly returns: "boolean";
496
+ readonly security: "definer";
497
+ }, {
498
+ readonly name: "field_dependants";
499
+ readonly args: "p_organization_id uuid, p_field_id uuid";
500
+ readonly returns: "TABLE(kind text, dependant_id uuid, label text, how text)";
501
+ readonly security: "invoker";
502
+ }, {
503
+ readonly name: "field_kernel_id";
504
+ readonly args: "";
505
+ readonly returns: "uuid";
506
+ readonly security: "invoker";
507
+ }, {
508
+ readonly name: "field_options";
509
+ readonly args: "p_organization_id uuid, p_field_id uuid";
510
+ readonly returns: "SETOF custom.record";
511
+ readonly security: "invoker";
512
+ }, {
513
+ readonly name: "field_rules";
514
+ readonly args: "p_field_data jsonb";
515
+ readonly returns: "TABLE(kind text, spec jsonb)";
516
+ readonly security: "invoker";
517
+ }, {
518
+ readonly name: "file_kernel_id";
519
+ readonly args: "";
520
+ readonly returns: "uuid";
521
+ readonly security: "invoker";
522
+ }, {
523
+ readonly name: "formula_value";
524
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb";
525
+ readonly returns: "jsonb";
526
+ readonly security: "invoker";
527
+ }, {
528
+ readonly name: "has_visibility";
529
+ readonly args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
530
+ readonly returns: "boolean";
531
+ readonly security: "definer";
532
+ }, {
533
+ readonly name: "has_visibility_at";
534
+ readonly args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, p_organization_id uuid DEFAULT NULL::uuid, p_min_version bigint DEFAULT NULL::bigint";
535
+ readonly returns: "boolean";
536
+ readonly security: "definer";
537
+ }, {
538
+ readonly name: "hidden_field_notice";
539
+ readonly args: "p_field custom.record, p_action text DEFAULT 'read'::text";
540
+ readonly returns: "jsonb";
541
+ readonly security: "invoker";
542
+ }, {
543
+ readonly name: "home_add";
544
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_home_record_id uuid";
545
+ readonly returns: "uuid";
546
+ readonly security: "invoker";
547
+ }, {
548
+ readonly name: "home_relations";
549
+ readonly args: "";
550
+ readonly returns: "TABLE(table_id uuid, home_record_id uuid, organization_id uuid, relation_id uuid)";
551
+ readonly security: "invoker";
552
+ }, {
553
+ readonly name: "index_payload";
554
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000";
555
+ readonly returns: "TABLE(id uuid, searchable text)";
556
+ readonly security: "invoker";
557
+ }, {
558
+ readonly name: "intern_provenance";
559
+ readonly args: "p_data jsonb";
560
+ readonly returns: "jsonb";
561
+ readonly security: "invoker";
562
+ }, {
563
+ readonly name: "io_changed_field_ids";
564
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_old jsonb, p_new jsonb";
565
+ readonly returns: "jsonb";
566
+ readonly security: "invoker";
567
+ }, {
568
+ readonly name: "io_changed_keys";
569
+ readonly args: "p_old jsonb, p_new jsonb";
570
+ readonly returns: "text[]";
571
+ readonly security: "invoker";
572
+ }, {
573
+ readonly name: "io_comment_resolve";
574
+ readonly args: "p_organization_id uuid, p_comment_id uuid, p_resolved boolean DEFAULT true";
575
+ readonly returns: "boolean";
576
+ readonly security: "definer";
577
+ }, {
578
+ readonly name: "io_comment_write";
579
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_body text, p_anchor jsonb DEFAULT '{}'::jsonb, p_parent_comment_id uuid DEFAULT NULL::uuid";
580
+ readonly returns: "uuid";
581
+ readonly security: "definer";
582
+ }, {
583
+ readonly name: "io_comments";
584
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_include_resolved boolean DEFAULT false";
585
+ readonly returns: "TABLE(id uuid, body text, anchor jsonb, parent_comment_id uuid, created_by uuid, created_at timestamp with time zone, resolved_at timestamp with time zone, resolved_by uuid)";
586
+ readonly security: "definer";
587
+ }, {
588
+ readonly name: "io_csv_escape";
589
+ readonly args: "p_value text, p_delimiter text DEFAULT ','::text";
590
+ readonly returns: "text";
591
+ readonly security: "invoker";
592
+ }, {
593
+ readonly name: "io_csv_parse";
594
+ readonly args: "p_text text, p_delimiter text DEFAULT NULL::text";
595
+ readonly returns: "TABLE(row_number integer, cells text[])";
596
+ readonly security: "invoker";
597
+ }, {
598
+ readonly name: "io_export";
599
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_columns text[] DEFAULT NULL::text[], p_limit integer DEFAULT 10000, p_required text DEFAULT 'viewer'::text";
600
+ readonly returns: "jsonb";
601
+ readonly security: "definer";
602
+ }, {
603
+ readonly name: "io_export_csv";
604
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_columns text[] DEFAULT NULL::text[], p_limit integer DEFAULT 10000, p_delimiter text DEFAULT ','::text, p_required text DEFAULT 'viewer'::text";
605
+ readonly returns: "text";
606
+ readonly security: "definer";
607
+ }, {
608
+ readonly name: "io_import_open";
609
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_format text DEFAULT 'csv'::text, p_source_name text DEFAULT NULL::text, p_source_columns jsonb DEFAULT '[]'::jsonb";
610
+ readonly returns: "uuid";
611
+ readonly security: "definer";
612
+ }, {
613
+ readonly name: "io_import_rows";
614
+ readonly args: "p_organization_id uuid, p_import_id uuid, p_rows jsonb, p_mapping jsonb DEFAULT '{}'::jsonb";
615
+ readonly returns: "jsonb";
616
+ readonly security: "definer";
617
+ }, {
618
+ readonly name: "io_infer_type";
619
+ readonly args: "p_samples jsonb";
620
+ readonly returns: "text";
621
+ readonly security: "invoker";
622
+ }, {
623
+ readonly name: "io_outbox_announce";
624
+ readonly args: "";
625
+ readonly returns: "trigger";
626
+ readonly security: "definer";
627
+ }, {
628
+ readonly name: "io_outbox_drain";
629
+ readonly args: "p_organization_id uuid, p_consumer text, p_limit integer DEFAULT 100, p_event_key text DEFAULT 'records.changed'::text";
630
+ readonly returns: "TABLE(outbox_id uuid, record_id uuid, table_id uuid, operation text, changed_field_ids jsonb, actor jsonb, occurred_at timestamp with time zone)";
631
+ readonly security: "definer";
632
+ }, {
633
+ readonly name: "io_outbox_release";
634
+ readonly args: "p_organization_id uuid, p_consumer text, p_older_than interval DEFAULT '00:15:00'::interval";
635
+ readonly returns: "integer";
636
+ readonly security: "definer";
637
+ }, {
638
+ readonly name: "io_proposal_accept";
639
+ readonly args: "p_organization_id uuid, p_import_id uuid, p_column text, p_type text DEFAULT NULL::text, p_label text DEFAULT NULL::text";
640
+ readonly returns: "uuid";
641
+ readonly security: "definer";
642
+ }, {
643
+ readonly name: "io_proposal_reject";
644
+ readonly args: "p_organization_id uuid, p_import_id uuid, p_column text";
645
+ readonly returns: "boolean";
646
+ readonly security: "definer";
647
+ }, {
648
+ readonly name: "io_record_changed";
649
+ readonly args: "";
650
+ readonly returns: "trigger";
651
+ readonly security: "definer";
652
+ }, {
653
+ readonly name: "io_restore";
654
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_version integer";
655
+ readonly returns: "integer";
656
+ readonly security: "definer";
657
+ }, {
658
+ readonly name: "io_revisions";
659
+ readonly args: "p_organization_id uuid, p_record_id uuid";
660
+ readonly returns: "TABLE(version integer, changed_at timestamp with time zone, changed_by uuid, summary text)";
661
+ readonly security: "definer";
662
+ }, {
663
+ readonly name: "lookup_value";
664
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb";
665
+ readonly returns: "jsonb";
666
+ readonly security: "invoker";
667
+ }, {
668
+ readonly name: "mask_document";
669
+ readonly args: "p_document jsonb, p_visible_keys text[], p_notices jsonb, p_by_id boolean DEFAULT false, p_key_ids jsonb DEFAULT '{}'::jsonb";
670
+ readonly returns: "jsonb";
671
+ readonly security: "invoker";
672
+ }, {
673
+ readonly name: "mask_document";
674
+ readonly args: "p_document jsonb, p_visible_keys text[], p_notices jsonb, p_by_id boolean DEFAULT false, p_key_ids jsonb DEFAULT '{}'::jsonb, p_declared_keys text[] DEFAULT NULL::text[]";
675
+ readonly returns: "jsonb";
676
+ readonly security: "invoker";
677
+ }, {
678
+ readonly name: "merge_field_kernel_id";
679
+ readonly args: "";
680
+ readonly returns: "uuid";
681
+ readonly security: "invoker";
682
+ }, {
683
+ readonly name: "migrate_delete";
684
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text";
685
+ readonly returns: "jsonb";
686
+ readonly security: "invoker";
687
+ }, {
688
+ readonly name: "migrate_demote";
689
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text";
690
+ readonly returns: "jsonb";
691
+ readonly security: "invoker";
692
+ }, {
693
+ readonly name: "migrate_extract_parent";
694
+ readonly args: "p_organization_id uuid, p_id uuid, p_parent_table_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text";
695
+ readonly returns: "jsonb";
696
+ readonly security: "invoker";
697
+ }, {
698
+ readonly name: "migrate_merge";
699
+ readonly args: "p_organization_id uuid, p_winner_id uuid, p_loser_id uuid, p_note text DEFAULT NULL::text";
700
+ readonly returns: "jsonb";
701
+ readonly security: "invoker";
702
+ }, {
703
+ readonly name: "migrate_promote";
704
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text";
705
+ readonly returns: "jsonb";
706
+ readonly security: "invoker";
707
+ }, {
708
+ readonly name: "migrate_purge";
709
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true";
710
+ readonly returns: "jsonb";
711
+ readonly security: "invoker";
712
+ }, {
713
+ readonly name: "migrate_rename";
714
+ readonly args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text";
715
+ readonly returns: "jsonb";
716
+ readonly security: "invoker";
717
+ }, {
718
+ readonly name: "migrate_reparent";
719
+ readonly args: "p_organization_id uuid, p_id uuid, p_parent_id uuid, p_note text DEFAULT NULL::text";
720
+ readonly returns: "jsonb";
721
+ readonly security: "invoker";
722
+ }, {
723
+ readonly name: "migrate_retype";
724
+ readonly args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text";
725
+ readonly returns: "jsonb";
726
+ readonly security: "invoker";
727
+ }, {
728
+ readonly name: "migrate_split";
729
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text";
730
+ readonly returns: "jsonb";
731
+ readonly security: "invoker";
732
+ }, {
733
+ readonly name: "organization_references";
734
+ readonly args: "p_kind text, p_organization_id uuid, p_row jsonb";
735
+ readonly returns: "TABLE(site text, what text, ref_id uuid, openable boolean)";
736
+ readonly security: "invoker";
737
+ }, {
738
+ readonly name: "parity_field_types";
739
+ readonly args: "";
740
+ readonly returns: "TABLE(parity_type text, behavior text, made_of text)";
741
+ readonly security: "invoker";
742
+ }, {
743
+ readonly name: "parity_type";
744
+ readonly args: "p_field_data jsonb";
745
+ readonly returns: "text";
746
+ readonly security: "invoker";
747
+ }, {
748
+ readonly name: "parity_values";
749
+ readonly args: "p_organization_id uuid, p_record_id uuid";
750
+ readonly returns: "TABLE(field_key text, field_id uuid, parity_type text, behavior text, unit text, format text, value jsonb, value_version integer, actor text, written_at timestamp with time zone)";
751
+ readonly security: "invoker";
752
+ }, {
753
+ readonly name: "per_value_access_words";
754
+ readonly args: "";
755
+ readonly returns: "text[]";
756
+ readonly security: "invoker";
757
+ }, {
758
+ readonly name: "person_kernel_id";
759
+ readonly args: "";
760
+ readonly returns: "uuid";
761
+ readonly security: "invoker";
762
+ }, {
763
+ readonly name: "promote_field";
764
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_id uuid";
765
+ readonly returns: "jsonb";
766
+ readonly security: "invoker";
767
+ }, {
768
+ readonly name: "promote_table";
769
+ readonly args: "p_organization_id uuid, p_table_id uuid";
770
+ readonly returns: "jsonb";
771
+ readonly security: "definer";
772
+ }, {
773
+ readonly name: "promoted_field_cap";
774
+ readonly args: "";
775
+ readonly returns: "integer";
776
+ readonly security: "invoker";
777
+ }, {
778
+ readonly name: "promoted_fields";
779
+ readonly args: "p_organization_id uuid, p_table_id uuid";
780
+ readonly returns: "TABLE(field_id uuid, field_key text, parity_type text, is_unique boolean, value_path text, index_arm text, index_expr text, index_name text, indexable boolean, why_not text)";
781
+ readonly security: "invoker";
782
+ }, {
783
+ readonly name: "promoted_index_arm";
784
+ readonly args: "p_field_data jsonb";
785
+ readonly returns: "text";
786
+ readonly security: "invoker";
787
+ }, {
788
+ readonly name: "promoted_index_ddl";
789
+ readonly args: "p_organization_id uuid, p_table_id uuid";
790
+ readonly returns: "TABLE(step integer, purpose text, statement text)";
791
+ readonly security: "invoker";
792
+ }, {
793
+ readonly name: "promoted_index_expr";
794
+ readonly args: "p_field_data jsonb";
795
+ readonly returns: "text";
796
+ readonly security: "invoker";
797
+ }, {
798
+ readonly name: "promoted_index_name";
799
+ readonly args: "p_table_id uuid, p_field_key text, p_unique boolean";
800
+ readonly returns: "text";
801
+ readonly security: "invoker";
802
+ }, {
803
+ readonly name: "promoted_query_sql";
804
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_key text";
805
+ readonly returns: "text";
806
+ readonly security: "invoker";
807
+ }, {
808
+ readonly name: "promoted_read";
809
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_key text, p_value text";
810
+ readonly returns: "SETOF uuid";
811
+ readonly security: "invoker";
812
+ }, {
813
+ readonly name: "promoted_value_path";
814
+ readonly args: "p_field_data jsonb";
815
+ readonly returns: "text";
816
+ readonly security: "invoker";
817
+ }, {
818
+ readonly name: "promotion_inline_ceiling";
819
+ readonly args: "";
820
+ readonly returns: "integer";
821
+ readonly security: "invoker";
822
+ }, {
823
+ readonly name: "query_access_ids";
824
+ readonly args: "p_organization_id uuid, p_required text DEFAULT 'viewer'::text";
825
+ readonly returns: "uuid[]";
826
+ readonly security: "invoker";
827
+ }, {
828
+ readonly name: "query_across_homes";
829
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0, p_required text DEFAULT 'viewer'::text";
830
+ readonly returns: "TABLE(record_id uuid, home_record_id uuid, data jsonb, created_at timestamp with time zone)";
831
+ readonly security: "invoker";
832
+ }, {
833
+ readonly name: "query_by_coordinates";
834
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_coordinates jsonb DEFAULT '[]'::jsonb, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0, p_required text DEFAULT 'viewer'::text";
835
+ readonly returns: "TABLE(record_id uuid, table_id uuid, data jsonb, coordinates_matched integer)";
836
+ readonly security: "invoker";
837
+ }, {
838
+ readonly name: "query_can_see";
839
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_required text DEFAULT 'viewer'::text";
840
+ readonly returns: "boolean";
841
+ readonly security: "invoker";
842
+ }, {
843
+ readonly name: "query_hot_paths";
844
+ readonly args: "";
845
+ readonly returns: "TABLE(name text, statement text)";
846
+ readonly security: "invoker";
847
+ }, {
848
+ readonly name: "query_hot_paths_prepared";
849
+ readonly args: "";
850
+ readonly returns: "TABLE(name text, prepared boolean, generic_plans bigint)";
851
+ readonly security: "invoker";
852
+ }, {
853
+ readonly name: "query_is_store_owner";
854
+ readonly args: "";
855
+ readonly returns: "boolean";
856
+ readonly security: "invoker";
857
+ }, {
858
+ readonly name: "query_prepare_hot";
859
+ readonly args: "";
860
+ readonly returns: "integer";
861
+ readonly security: "invoker";
862
+ }, {
863
+ readonly name: "query_principal";
864
+ readonly args: "";
865
+ readonly returns: "uuid";
866
+ readonly security: "invoker";
867
+ }, {
868
+ readonly name: "query_record_as_of";
869
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_recorded_at timestamp with time zone DEFAULT NULL::timestamp with time zone, p_world_on date DEFAULT NULL::date, p_required text DEFAULT 'viewer'::text";
870
+ readonly returns: "jsonb";
871
+ readonly security: "invoker";
872
+ }, {
873
+ readonly name: "query_relation_edges";
874
+ readonly args: "p_organization_id uuid, p_flavor text DEFAULT NULL::text, p_role text DEFAULT NULL::text";
875
+ readonly returns: "TABLE(parent_id uuid, child_id uuid, role text, flavor text)";
876
+ readonly security: "invoker";
877
+ }, {
878
+ readonly name: "query_rollup";
879
+ readonly args: "p_organization_id uuid, p_roots uuid[], p_flavor text DEFAULT NULL::text, p_role text DEFAULT NULL::text, p_max_depth integer DEFAULT 33, p_required text DEFAULT 'viewer'::text";
880
+ readonly returns: "TABLE(record_id uuid, depth integer)";
881
+ readonly security: "invoker";
882
+ }, {
883
+ readonly name: "query_rollup_sum";
884
+ readonly args: "p_organization_id uuid, p_roots uuid[], p_field_key text, p_flavor text DEFAULT NULL::text, p_role text DEFAULT NULL::text, p_max_depth integer DEFAULT 33, p_required text DEFAULT 'viewer'::text";
885
+ readonly returns: "numeric";
886
+ readonly security: "invoker";
887
+ }, {
888
+ readonly name: "query_table_as_of";
889
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_recorded_at timestamp with time zone DEFAULT NULL::timestamp with time zone, p_world_on date DEFAULT NULL::date, p_limit integer DEFAULT 50, p_offset integer DEFAULT 0, p_required text DEFAULT 'viewer'::text";
890
+ readonly returns: "TABLE(record_id uuid, data jsonb)";
891
+ readonly security: "invoker";
892
+ }, {
893
+ readonly name: "query_table_homes";
894
+ readonly args: "p_organization_id uuid, p_table_id uuid";
895
+ readonly returns: "SETOF uuid";
896
+ readonly security: "invoker";
897
+ }, {
898
+ readonly name: "query_visible_ids";
899
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_required text DEFAULT 'viewer'::text";
900
+ readonly returns: "SETOF uuid";
901
+ readonly security: "invoker";
902
+ }, {
903
+ readonly name: "reachable_from";
904
+ readonly args: "p_organization_id uuid, p_roots uuid[]";
905
+ readonly returns: "TABLE(record_id uuid, depth integer, via text)";
906
+ readonly security: "invoker";
907
+ }, {
908
+ readonly name: "read_paths_outside_the_door";
909
+ readonly args: "";
910
+ readonly returns: "TABLE(object_name text, why text)";
911
+ readonly security: "invoker";
912
+ }, {
913
+ readonly name: "read_record";
914
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_by_id boolean DEFAULT false";
915
+ readonly returns: "jsonb";
916
+ readonly security: "definer";
917
+ }, {
918
+ readonly name: "read_records";
919
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_by_id boolean DEFAULT false, p_limit integer DEFAULT 200, p_offset integer DEFAULT 0";
920
+ readonly returns: "TABLE(id uuid, document jsonb, level permission_level)";
921
+ readonly security: "definer";
922
+ }, {
923
+ readonly name: "record_aggregate";
924
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_group_by jsonb DEFAULT '[]'::jsonb, p_measures jsonb DEFAULT '[]'::jsonb, p_bucket jsonb DEFAULT NULL::jsonb, p_filter jsonb DEFAULT '{}'::jsonb, p_limit integer DEFAULT 200, p_required text DEFAULT 'viewer'::text";
925
+ readonly returns: "TABLE(groups jsonb, measures jsonb, row_count bigint)";
926
+ readonly security: "invoker";
927
+ }, {
928
+ readonly name: "record_applicability";
929
+ readonly args: "p_organization_id uuid, p_record_id uuid";
930
+ readonly returns: "TABLE(rule_id uuid, rule_name text, rule_version integer, applies boolean, answer jsonb)";
931
+ readonly security: "invoker";
932
+ }, {
933
+ readonly name: "record_delete";
934
+ readonly args: "p_organization_id uuid, p_record_id uuid";
935
+ readonly returns: "timestamp with time zone";
936
+ readonly security: "definer";
937
+ }, {
938
+ readonly name: "record_reparent";
939
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid";
940
+ readonly returns: "void";
941
+ readonly security: "invoker";
942
+ }, {
943
+ readonly name: "record_restore";
944
+ readonly args: "p_organization_id uuid, p_record_id uuid";
945
+ readonly returns: "void";
946
+ readonly security: "definer";
947
+ }, {
948
+ readonly name: "record_update";
949
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer";
950
+ readonly returns: "integer";
951
+ readonly security: "definer";
952
+ }, {
953
+ readonly name: "record_values";
954
+ readonly args: "p_organization_id uuid, p_record_id uuid";
955
+ readonly returns: "jsonb";
956
+ readonly security: "invoker";
957
+ }, {
958
+ readonly name: "record_values_versioned";
959
+ readonly args: "p_organization_id uuid, p_record_id uuid";
960
+ 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)";
961
+ readonly security: "invoker";
962
+ }, {
963
+ readonly name: "record_write";
964
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_data jsonb";
965
+ readonly returns: "uuid";
966
+ readonly security: "definer";
967
+ }, {
968
+ readonly name: "relation_own";
969
+ readonly args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid";
970
+ readonly returns: "uuid";
971
+ readonly security: "invoker";
972
+ }, {
973
+ readonly name: "relation_target_external";
974
+ readonly args: "p_connection_token text, p_external_table text, p_external_key text";
975
+ readonly returns: "jsonb";
976
+ readonly security: "definer";
977
+ }, {
978
+ readonly name: "relation_target_ours";
979
+ readonly args: "p_entity_token text, p_row_id uuid";
980
+ readonly returns: "jsonb";
981
+ readonly security: "definer";
982
+ }, {
983
+ readonly name: "relation_targets";
984
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_via_key text";
985
+ readonly returns: "SETOF uuid";
986
+ readonly security: "invoker";
987
+ }, {
988
+ readonly name: "reopen_declared_doors";
989
+ readonly args: "";
990
+ readonly returns: "TABLE(reopened text)";
991
+ readonly security: "definer";
992
+ }, {
993
+ readonly name: "required_epoch";
994
+ readonly args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid";
995
+ readonly returns: "bigint";
996
+ readonly security: "definer";
997
+ }, {
998
+ readonly name: "resolve_first_match";
999
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1000
+ readonly returns: "jsonb";
1001
+ readonly security: "invoker";
1002
+ }, {
1003
+ readonly name: "resolve_id";
1004
+ readonly args: "p_organization_id uuid, p_id uuid";
1005
+ readonly returns: "uuid";
1006
+ readonly security: "invoker";
1007
+ }, {
1008
+ readonly name: "retired_actor_words";
1009
+ readonly args: "";
1010
+ readonly returns: "jsonb";
1011
+ readonly security: "invoker";
1012
+ }, {
1013
+ readonly name: "rollup_value";
1014
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb";
1015
+ readonly returns: "jsonb";
1016
+ readonly security: "invoker";
1017
+ }, {
1018
+ readonly name: "rule_applies";
1019
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid";
1020
+ readonly returns: "jsonb";
1021
+ readonly security: "invoker";
1022
+ }, {
1023
+ readonly name: "rule_context";
1024
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1025
+ readonly returns: "jsonb";
1026
+ readonly security: "invoker";
1027
+ }, {
1028
+ readonly name: "rule_dependency_edges";
1029
+ readonly args: "p_organization_id uuid, p_row custom.record DEFAULT NULL::custom.record";
1030
+ readonly returns: "TABLE(needs text, needed text)";
1031
+ readonly security: "invoker";
1032
+ }, {
1033
+ readonly name: "rule_eval";
1034
+ readonly args: "p_organization_id uuid, p_expr jsonb, p_values jsonb, p_context jsonb DEFAULT '{}'::jsonb";
1035
+ readonly returns: "jsonb";
1036
+ readonly security: "invoker";
1037
+ }, {
1038
+ readonly name: "rule_field_key";
1039
+ readonly args: "p_organization_id uuid, p_field_id uuid";
1040
+ readonly returns: "text";
1041
+ readonly security: "invoker";
1042
+ }, {
1043
+ readonly name: "rule_field_label";
1044
+ readonly args: "p_organization_id uuid, p_field_id uuid";
1045
+ readonly returns: "text";
1046
+ readonly security: "invoker";
1047
+ }, {
1048
+ readonly name: "rule_kernel_id";
1049
+ readonly args: "";
1050
+ readonly returns: "uuid";
1051
+ readonly security: "invoker";
1052
+ }, {
1053
+ readonly name: "rule_members";
1054
+ readonly args: "p_organization_id uuid, p_rule_id uuid";
1055
+ readonly returns: "SETOF custom.record";
1056
+ readonly security: "invoker";
1057
+ }, {
1058
+ readonly name: "rule_membership";
1059
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid";
1060
+ readonly returns: "jsonb";
1061
+ readonly security: "invoker";
1062
+ }, {
1063
+ readonly name: "rule_node_kinds";
1064
+ readonly args: "";
1065
+ readonly returns: "TABLE(node text, evaluated_by text, note text)";
1066
+ readonly security: "invoker";
1067
+ }, {
1068
+ readonly name: "rule_run";
1069
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_values jsonb, p_context jsonb DEFAULT '{}'::jsonb";
1070
+ readonly returns: "jsonb";
1071
+ readonly security: "invoker";
1072
+ }, {
1073
+ readonly name: "rule_truth";
1074
+ readonly args: "p_answer jsonb";
1075
+ readonly returns: "boolean";
1076
+ readonly security: "invoker";
1077
+ }, {
1078
+ readonly name: "rule_uses";
1079
+ readonly args: "";
1080
+ readonly returns: "text[]";
1081
+ readonly security: "invoker";
1082
+ }, {
1083
+ readonly name: "rule_version";
1084
+ readonly args: "p_organization_id uuid, p_rule_id uuid";
1085
+ readonly returns: "integer";
1086
+ readonly security: "invoker";
1087
+ }, {
1088
+ readonly name: "size_refusal";
1089
+ readonly args: "p_organization_id uuid, p_data jsonb";
1090
+ readonly returns: "text";
1091
+ readonly security: "invoker";
1092
+ }, {
1093
+ readonly name: "source_next_pointer";
1094
+ readonly args: "p_sources jsonb";
1095
+ readonly returns: "text";
1096
+ readonly security: "invoker";
1097
+ }, {
1098
+ readonly name: "source_pointer";
1099
+ readonly args: "p_sources jsonb, p_source jsonb";
1100
+ readonly returns: "text";
1101
+ readonly security: "invoker";
1102
+ }, {
1103
+ readonly name: "stamp_value_envelopes";
1104
+ readonly args: "p_data jsonb, p_actor text, p_on_behalf_of text, p_at timestamp with time zone";
1105
+ readonly returns: "jsonb";
1106
+ readonly security: "invoker";
1107
+ }, {
1108
+ readonly name: "storage_modes";
1109
+ readonly args: "";
1110
+ readonly returns: "text[]";
1111
+ readonly security: "invoker";
1112
+ }, {
1113
+ readonly name: "store_is_open";
1114
+ readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
1115
+ readonly returns: "boolean";
1116
+ readonly security: "invoker";
1117
+ }, {
1118
+ readonly name: "table_capacity";
1119
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1120
+ readonly returns: "jsonb";
1121
+ readonly security: "definer";
1122
+ }, {
1123
+ readonly name: "table_declare";
1124
+ readonly args: "p_organization_id uuid, p_spec jsonb";
1125
+ readonly returns: "uuid";
1126
+ readonly security: "definer";
1127
+ }, {
1128
+ readonly name: "table_kernel_id";
1129
+ readonly args: "";
1130
+ readonly returns: "uuid";
1131
+ readonly security: "invoker";
1132
+ }, {
1133
+ readonly name: "table_record_ceiling";
1134
+ readonly args: "";
1135
+ readonly returns: "integer";
1136
+ readonly security: "invoker";
1137
+ }, {
1138
+ readonly name: "table_record_ceiling";
1139
+ readonly args: "p_organization_id uuid";
1140
+ readonly returns: "integer";
1141
+ readonly security: "invoker";
1142
+ }, {
1143
+ readonly name: "table_rules";
1144
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_use text, p_record_type text DEFAULT NULL::text";
1145
+ readonly returns: "SETOF custom.record";
1146
+ readonly security: "invoker";
1147
+ }, {
1148
+ readonly name: "table_storage";
1149
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1150
+ readonly returns: "text";
1151
+ readonly security: "invoker";
1152
+ }, {
1153
+ readonly name: "table_type_field";
1154
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1155
+ readonly returns: "text";
1156
+ readonly security: "invoker";
1157
+ }, {
1158
+ readonly name: "tables_at_home";
1159
+ readonly args: "p_organization_id uuid, p_home_ids uuid[]";
1160
+ readonly returns: "TABLE(table_id uuid, home_record_id uuid, kind text)";
1161
+ readonly security: "invoker";
1162
+ }, {
1163
+ readonly name: "trg_associations_bump_visibility";
1164
+ readonly args: "";
1165
+ readonly returns: "trigger";
1166
+ readonly security: "definer";
1167
+ }, {
1168
+ readonly name: "validate_custom_fields";
1169
+ readonly args: "p_token text, p_organization_id uuid, p_values jsonb";
1170
+ readonly returns: "void";
1171
+ readonly security: "invoker";
1172
+ }, {
1173
+ readonly name: "validate_value_envelope";
1174
+ readonly args: "p_organization_id uuid, p_fields custom.record[], p_data jsonb";
1175
+ readonly returns: "void";
1176
+ readonly security: "invoker";
1177
+ }, {
1178
+ readonly name: "validate_values";
1179
+ readonly args: "p_organization_id uuid, p_fields custom.record[], p_values jsonb, p_record_type text DEFAULT NULL::text";
1180
+ readonly returns: "void";
1181
+ readonly security: "invoker";
1182
+ }, {
1183
+ readonly name: "value_alternate_keys";
1184
+ readonly args: "";
1185
+ readonly returns: "text[]";
1186
+ readonly security: "invoker";
1187
+ }, {
1188
+ readonly name: "value_envelope_keys";
1189
+ readonly args: "";
1190
+ readonly returns: "text[]";
1191
+ readonly security: "invoker";
1192
+ }, {
1193
+ readonly name: "value_envelope_ok";
1194
+ readonly args: "p_data jsonb";
1195
+ readonly returns: "boolean";
1196
+ readonly security: "invoker";
1197
+ }, {
1198
+ readonly name: "value_envelope_refusal";
1199
+ readonly args: "p_data jsonb";
1200
+ readonly returns: "text";
1201
+ readonly security: "invoker";
1202
+ }, {
1203
+ readonly name: "value_read";
1204
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_key text";
1205
+ 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)";
1206
+ readonly security: "invoker";
1207
+ }, {
1208
+ readonly name: "value_versions";
1209
+ readonly args: "p_old jsonb, p_new jsonb";
1210
+ readonly returns: "jsonb";
1211
+ readonly security: "invoker";
1212
+ }, {
1213
+ readonly name: "visibility_ancestors";
1214
+ readonly args: "p_item_type text, p_item_id uuid";
1215
+ readonly returns: "TABLE(container_type text, container_id uuid, depth integer, max_level permission_level)";
1216
+ readonly security: "definer";
1217
+ }, {
1218
+ readonly name: "visibility_cache_rebuild";
1219
+ readonly args: "";
1220
+ readonly returns: "integer";
1221
+ readonly security: "definer";
1222
+ }, {
1223
+ readonly name: "visibility_parity";
1224
+ readonly args: "";
1225
+ readonly returns: "TABLE(side text, container_type text, container_id uuid, item_type text, item_id uuid, stored_level permission_level, derived_level permission_level, reason text)";
1226
+ readonly security: "definer";
1227
+ }, {
1228
+ readonly name: "visibility_warm";
1229
+ readonly args: "p_container_type text, p_container_id uuid";
1230
+ readonly returns: "integer";
1231
+ readonly security: "definer";
1232
+ }, {
1233
+ readonly name: "visible_record_ids";
1234
+ readonly args: "p_user_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
1235
+ readonly returns: "TABLE(id uuid)";
1236
+ readonly security: "definer";
1237
+ }, {
1238
+ readonly name: "work_assignment_fields";
1239
+ readonly args: "p_options_table_id uuid DEFAULT NULL::uuid";
1240
+ readonly returns: "TABLE(key text, label text, spec jsonb)";
1241
+ readonly security: "invoker";
1242
+ }, {
1243
+ readonly name: "work_has_assignment";
1244
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1245
+ readonly returns: "boolean";
1246
+ readonly security: "invoker";
1247
+ }, {
1248
+ readonly name: "work_instantiation_shape";
1249
+ readonly args: "p_organization_id uuid, p_instantiation_id uuid";
1250
+ readonly returns: "jsonb";
1251
+ readonly security: "invoker";
1252
+ }, {
1253
+ readonly name: "work_relation_kinds";
1254
+ readonly args: "";
1255
+ readonly returns: "TABLE(kind text, available boolean, why text)";
1256
+ readonly security: "invoker";
1257
+ }, {
1258
+ readonly name: "work_slot_expire";
1259
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1260
+ readonly returns: "integer";
1261
+ readonly security: "invoker";
1262
+ }, {
1263
+ readonly name: "work_slot_hold";
1264
+ 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";
1265
+ readonly returns: "jsonb";
1266
+ readonly security: "invoker";
1267
+ }, {
1268
+ readonly name: "work_slot_holds";
1269
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1270
+ readonly returns: "TABLE(hold_id uuid, slot_key text, holder text, expires_at timestamp with time zone, expired boolean)";
1271
+ readonly security: "invoker";
1272
+ }, {
1273
+ readonly name: "work_slot_index_name";
1274
+ readonly args: "p_table_id uuid";
1275
+ readonly returns: "text";
1276
+ readonly security: "invoker";
1277
+ }, {
1278
+ readonly name: "work_slot_release";
1279
+ readonly args: "p_organization_id uuid, p_hold_id uuid";
1280
+ readonly returns: "boolean";
1281
+ readonly security: "invoker";
1282
+ }, {
1283
+ readonly name: "work_slots_declare";
1284
+ readonly args: "p_organization_id uuid, p_name text, p_slug text, p_home_id uuid DEFAULT NULL::uuid";
1285
+ readonly returns: "jsonb";
1286
+ readonly security: "invoker";
1287
+ }, {
1288
+ readonly name: "work_states";
1289
+ readonly args: "";
1290
+ readonly returns: "TABLE(sort integer, name text, terminal boolean, next text[])";
1291
+ readonly security: "invoker";
1292
+ }, {
1293
+ readonly name: "work_take_assignment";
1294
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1295
+ readonly returns: "jsonb";
1296
+ readonly security: "invoker";
1297
+ }, {
1298
+ readonly name: "work_template_declare";
1299
+ readonly args: "p_organization_id uuid, p_name text, p_graph jsonb";
1300
+ readonly returns: "uuid";
1301
+ readonly security: "invoker";
1302
+ }, {
1303
+ readonly name: "work_template_instantiate";
1304
+ readonly args: "p_organization_id uuid, p_template_id uuid, p_overrides jsonb DEFAULT '{}'::jsonb";
1305
+ readonly returns: "jsonb";
1306
+ readonly security: "invoker";
1307
+ }, {
1308
+ readonly name: "work_template_refusal";
1309
+ readonly args: "p_graph jsonb";
1310
+ readonly returns: "text";
1311
+ readonly security: "invoker";
1312
+ }, {
1313
+ readonly name: "work_template_shape";
1314
+ readonly args: "p_organization_id uuid, p_template_id uuid";
1315
+ readonly returns: "jsonb";
1316
+ readonly security: "invoker";
1317
+ }, {
1318
+ readonly name: "work_transition_refusal";
1319
+ readonly args: "p_organization_id uuid, p_from_state_id uuid, p_to_state_id uuid";
1320
+ readonly returns: "text";
1321
+ readonly security: "invoker";
1322
+ }, {
1323
+ readonly name: "work_whose_turn";
1324
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_include_finished boolean DEFAULT false";
1325
+ 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)";
1326
+ readonly security: "invoker";
1327
+ }];
1328
+ /** The campaign's own knobs, with the value the store resolves them to today. */
1329
+ declare const STORE_KNOBS: readonly [{
1330
+ readonly key: "accessible_entity_ids_guard";
1331
+ readonly value: "false";
1332
+ readonly type: "boolean";
1333
+ }, {
1334
+ readonly key: "associations_guard";
1335
+ readonly value: "false";
1336
+ readonly type: "boolean";
1337
+ }, {
1338
+ readonly key: "code_paths_enabled";
1339
+ readonly value: "false";
1340
+ readonly type: "boolean";
1341
+ }, {
1342
+ readonly key: "containment_depth_ceiling";
1343
+ readonly value: "16";
1344
+ readonly type: "integer";
1345
+ }, {
1346
+ readonly key: "document_max_bytes";
1347
+ readonly value: "1048576";
1348
+ readonly type: "integer";
1349
+ }, {
1350
+ readonly key: "emergency_door_guard";
1351
+ readonly value: "false";
1352
+ readonly type: "boolean";
1353
+ }, {
1354
+ readonly key: "emergency_door_sweep_enabled";
1355
+ readonly value: "false";
1356
+ readonly type: "boolean";
1357
+ }, {
1358
+ readonly key: "entity_custom_fields_guard";
1359
+ readonly value: "false";
1360
+ readonly type: "boolean";
1361
+ }, {
1362
+ readonly key: "entity_types_guard";
1363
+ readonly value: "false";
1364
+ readonly type: "boolean";
1365
+ }, {
1366
+ readonly key: "external_principal_enabled";
1367
+ readonly value: "false";
1368
+ readonly type: "boolean";
1369
+ }, {
1370
+ readonly key: "field_index_guard";
1371
+ readonly value: "false";
1372
+ readonly type: "boolean";
1373
+ }, {
1374
+ readonly key: "field_sensitivity_levels";
1375
+ readonly value: "{\"edit\": {\"public\": \"editor\", \"internal\": \"editor\", \"restricted\": \"admin\", \"confidential\": \"admin\"}, \"read\": {\"public\": \"viewer\", \"internal\": \"viewer\", \"restricted\": \"admin\", \"confidential\": \"editor\"}}";
1376
+ readonly type: "json";
1377
+ }, {
1378
+ readonly key: "member_default_level";
1379
+ readonly value: "\"viewer\"";
1380
+ readonly type: "string";
1381
+ }, {
1382
+ readonly key: "row_versions_guard";
1383
+ readonly value: "false";
1384
+ readonly type: "boolean";
1385
+ }, {
1386
+ readonly key: "sandbox_expanded_frame_height_px";
1387
+ readonly value: "20000";
1388
+ readonly type: "integer";
1389
+ }, {
1390
+ readonly key: "sandbox_frame_height_px";
1391
+ readonly value: "4000";
1392
+ readonly type: "integer";
1393
+ }, {
1394
+ readonly key: "sandbox_message_bytes";
1395
+ readonly value: "65536";
1396
+ readonly type: "integer";
1397
+ }, {
1398
+ readonly key: "sandbox_org_components";
1399
+ readonly value: "true";
1400
+ readonly type: "boolean";
1401
+ }, {
1402
+ readonly key: "signup_provisioning_guard";
1403
+ readonly value: "false";
1404
+ readonly type: "boolean";
1405
+ }, {
1406
+ readonly key: "system_enabled";
1407
+ readonly value: "false";
1408
+ readonly type: "boolean";
1409
+ }, {
1410
+ readonly key: "table_record_ceiling";
1411
+ readonly value: "150000";
1412
+ readonly type: "integer";
1413
+ }, {
1414
+ readonly key: "value_max_bytes";
1415
+ readonly value: "100000";
1416
+ readonly type: "integer";
1417
+ }, {
1418
+ readonly key: "world_publish_enabled";
1419
+ readonly value: "false";
1420
+ readonly type: "boolean";
1421
+ }];
1422
+ /**
1423
+ * Every SQLSTATE the store's own function bodies raise, with the functions that
1424
+ * raise it. This is the list the client's refusal mapper is checked against: a
1425
+ * code the store can raise and the package cannot name is a hole, and the
1426
+ * real-door suite says so by name.
1427
+ */
1428
+ declare const STORE_REFUSAL_CODES: readonly [{
1429
+ readonly code: "02000";
1430
+ 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,read_record,record_delete,record_restore,record_update";
1431
+ }, {
1432
+ readonly code: "0A000";
1433
+ 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";
1434
+ }, {
1435
+ readonly code: "22004";
1436
+ 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,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_restore,record_update,record_write,relation_own,table_declare,work_template_declare";
1437
+ }, {
1438
+ readonly code: "22012";
1439
+ readonly raised_by: "rule_eval";
1440
+ }, {
1441
+ readonly code: "22023";
1442
+ 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,rule_eval,rule_members,table_rules,work_slot_hold";
1443
+ }, {
1444
+ readonly code: "23503";
1445
+ readonly raised_by: "_containment_guard,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,doc_sign,doc_template_save,home_add,io_comment_write,io_import_rows,io_proposal_accept,migrate_delete,migrate_demote,migrate_promote,promote_field,promote_table,record_applicability,record_reparent,relation_own,resolve_first_match,rule_applies,rule_eval,rule_members,rule_run,work_take_assignment,work_template_instantiate";
1446
+ }, {
1447
+ readonly code: "23505";
1448
+ readonly raised_by: "doc_sign,doc_signature_write,home_add,io_proposal_accept,work_slot_hold";
1449
+ }, {
1450
+ readonly code: "23514";
1451
+ readonly raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_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,_table_shape_guard,_value_envelope,_work_shape_guard,doc_sign,doc_signature_write,doc_template_save,home_add,validate_value_envelope,validate_values,work_slots_declare,work_take_assignment,work_template_instantiate";
1452
+ }, {
1453
+ readonly code: "40001";
1454
+ readonly raised_by: "has_visibility_at";
1455
+ }, {
1456
+ readonly code: "42501";
1457
+ 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_reach,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,promote_table,read_record,read_records";
1458
+ }, {
1459
+ readonly code: "53400";
1460
+ readonly raised_by: "anon_rate_take,promote_field";
1461
+ }, {
1462
+ readonly code: "PT409";
1463
+ readonly raised_by: "record_update";
1464
+ }];
1465
+ /** `platform.entity_types` — the registered tokens a Table or relation may name. */
1466
+ declare const ENTITY_TOKENS: readonly ["access_delta_probe", "access_delta_run", "access_request", "account_addon", "acquisition_block", "activity", "admin_audit_log", "admin_email_log", "admin_markdown_sample", "admin_user", "admission_config", "agent", "agent_card", "agent_definition_version", "agent_drift_alert", "agent_exemplar", "agent_mandate_note", "agent_prompt_remediation", "agent_provision_legacy", "agent_run", "agent_run_stage", "agent_schedule", "agent_schedule_claim", "agent_shortcut", "agent_surface_binding", "agent_template", "agent_usage", "agent_user_kv", "ai_api", "ai_endpoint", "ai_model", "ai_model_alias", "ai_offering", "ai_provider", "ai_setting", "analysis_result", "anon_form", "anon_function_birth_grandfather", "anon_hit", "anon_inbound", "anon_replay", "anon_submission", "anon_token", "api_field_warning", "api_request_log", "app", "app_config", "app_config_history", "app_definition_version", "app_error", "app_execution", "app_instance", "app_log", "app_log_muted_pattern", "app_log_norm_exception", "app_rate_limit", "app_setting", "app_sync_status", "approach", "artifact", "assessment", "assessment_item", "assessment_result", "assignment_session", "assist", "assist_producer_policy", "assist_producer_policy_history", "association_type", "assurance_level", "attempt", "audit_broken_functions", "audit_canonical_findings", "audit_exemption", "audit_function_deps", "audit_function_runtime_probe", "audit_m2m_candidates", "audit_refresh_log", "audit_stale_registry", "audit_unregistered_candidates", "bak_assoc_file_processed_document_20260812", "bak_assoc_type_file_processed_document_20260812", "bak_organization_name_dd043", "base_entity_template", "batch_cost_event", "batch_provider_batch", "batch_work_item", "billing_capability", "billing_capability_limit", "billing_connect_account", "billing_customer", "billing_plan", "billing_plan_limit", "billing_price", "billing_product", "billing_spend_guardrail", "billing_stripe_event", "billing_subscription", "billing_usage_ledger", "billing_user_plan", "browser_account_binding", "browser_action_event", "browser_authenticator_window", "browser_capture", "browser_control_request", "browser_handoff", "browser_login_attempt", "browser_login_recipe", "browser_profile", "browser_profile_checkpoint", "browser_run", "browser_site_observation", "browser_site_policy", "browser_stream_ticket", "build_lock", "calendar_event", "canvas_comment", "canvas_comment_like", "canvas_item", "canvas_item_state", "canvas_like", "canvas_score", "canvas_view", "capture_window", "carrying_rule", "catalog_entries_history", "catalog_entry", "category", "change_type_default", "chat_user_usage_summary", "citations", "class_purchase", "classifier_revision_ledger", "client_callable_door", "client_callable_door_retirement", "client_excluded_column_unregistered", "cmp_entry", "cmp_feedback", "code_file", "code_folder", "code_repository", "coding_session", "coding_session_entry", "comment", "commerce_asset_allocation", "commerce_asset_grading", "commerce_asset_identifier", "commerce_asset_lot_event", "commerce_asset_mandate_result", "commerce_asset_price_factor", "commerce_asset_reshoot_request", "commerce_asset_review", "commerce_asset_unknown", "commerce_certified_printer", "commerce_cloud_sync_connection", "commerce_ebay_business_policy", "commerce_ebay_category", "commerce_ebay_category_aspect", "commerce_ebay_category_tree", "commerce_ebay_custom_policy", "commerce_ebay_inventory_item", "commerce_ebay_inventory_item_group", "commerce_ebay_inventory_item_group_member", "commerce_ebay_inventory_location", "commerce_ebay_listing", "commerce_ebay_marketplace_policy", "commerce_ebay_media_asset", "commerce_ebay_notification_destination", "commerce_ebay_notification_event", "commerce_ebay_notification_subscription", "commerce_ebay_notification_topic", "commerce_ebay_offer", "commerce_ebay_order", "commerce_ebay_order_line_item", "commerce_ebay_shipping_fulfillment", "commerce_ebay_store_category", "commerce_human_correction", "commerce_intake_artifact", "commerce_intake_asset", "commerce_intake_batch", "commerce_label_batch", "commerce_label_code", "commerce_marketplace_account", "commerce_marketplace_account_deletion_audit", "commerce_marketplace_api_call", "commerce_marketplace_rate_budget", "commerce_marketplace_site", "commerce_marketplace_sync_run", "commerce_prediction_outcome", "commerce_print_order", "commerce_product", "commerce_product_channel_ref", "commerce_product_media", "commerce_product_variant", "commerce_recall_audit", "comparison_set", "component_group", "contact_medium", "contact_submission", "content_certification", "content_ir_kind", "content_ir_kind_component", "content_ir_kind_component_incident", "content_ir_kind_conformance", "content_ir_kind_edge", "content_ir_kind_example", "content_ir_kind_instance", "content_ir_kind_surface", "context_access_log", "context_item", "context_item_suggestion", "context_item_value", "context_value_refs", "conversation", "conversation_value", "courts", "credential_attachment", "credential_item", "credential_mutation_receipt", "crm_address", "crm_affiliation", "crm_blocklist_entry", "crm_contact_candidate", "crm_deal", "crm_deal_stage_event", "crm_enrichment_call", "crm_interaction", "crm_merge_candidate", "crm_outreach_list", "crm_outreach_list_member", "crm_party_merge", "crm_registry_ingest_run", "crm_registry_source", "crm_saved_view", "crm_sending_event", "crm_sending_identity", "crm_sending_identity_check", "crm_sending_policy", "custom_entity_definition", "custom_field_definition", "custom_field_target", "custom_record", "cx_agent_memory", "cx_agent_plan", "cx_agent_task", "cx_code_edit", "cx_code_message_file", "cx_conversation_documents", "cx_media", "cx_observational_memory", "cx_observational_memory_event", "cx_pending_injection", "cx_request", "cx_request_snapshot", "cx_tool_trace", "cx_user_request", "cx_user_todo", "dashboard_saved_view", "data_rights_event", "data_store", "data_store_members", "dataset", "dd171_containment_baseline", "dd175_cast", "dd175_component_lane_baseline", "ddl_guard_log", "deck_suggestion", "definer_class_exemption", "definer_client_grant_grandfather", "definer_grant_baseline", "deprecated_relation", "derive_run", "dev_login_audit", "dict_entry", "dict_provider_publication", "dict_setting", "dm_conversation", "dm_message", "dm_participant", "doc_render", "doc_signature", "dockets", "domain_classification", "edge_payload_kind", "egress_device", "egress_pairing", "egress_ticket", "emails", "embedding_cache", "embeddings_google_gemini_2_1536", "embeddings_oai_3_small_1536", "embeddings_voyage_4_large_1024", "embeddings_voyage_code_3_1024", "endpoint_family_sweep_state", "engine_owner_task", "entity_grant", "entity_relationship", "entity_type", "esign_campaign", "esign_campaign_member", "esign_consent_disclosure", "esign_envelope", "esign_envelope_certificate", "esign_envelope_document", "esign_envelope_event", "esign_envelope_external_ref", "esign_envelope_signer", "esign_provider", "esign_provider_binding", "esign_signing_key", "execution_event_cursor", "extension_auth_code", "external_link", "external_source", "extract_sweep_state", "fc_card", "fc_detail", "fc_set", "feature_doc", "feature_knob", "feedback_comments", "feedback_user_messages", "field_component", "file", "file_analysis", "file_entities", "file_overrides", "file_page_annotations", "file_pages", "file_rag_job", "file_version", "files_account_tier", "files_machine_written_prefix", "files_sync_mapping", "files_user_account", "flashcard_data", "flashcard_history", "flashcard_review", "flashcard_set", "flashcard_sets", "flexible_data", "folder", "function_contract", "game_badge", "game_result", "game_room", "global_execution", "global_execution_checkpoint", "global_execution_control", "global_execution_event", "global_meter_entry", "global_origin", "global_request", "google_document", "growth_loop_event", "growth_loop_run", "growth_loop_stage_run", "guardian_link", "guest_conversion_audit", "guest_execution_log", "guest_executions", "guided_checklist_run", "heatmap_save", "hindsight_enrollment", "hindsight_finding", "hindsight_regression_case", "hindsight_replay", "hindsight_replay_step", "hindsight_review", "hr_access_audit", "hr_access_role", "hr_accommodation_request", "hr_ai_evidence", "hr_alert_routing_rule", "hr_application", "hr_approval_authority", "hr_approval_delegation", "hr_asset", "hr_asset_assignment", "hr_attendance_exception", "hr_auto_close_rule", "hr_availability", "hr_background_check", "hr_benefits_event", "hr_calculation_snapshot", "hr_candidate", "hr_candidate_conversion", "hr_candidate_message", "hr_careers_portal", "hr_checklist_item", "hr_checklist_run", "hr_checklist_template", "hr_checklist_template_item", "hr_compensation", "hr_corrective_action", "hr_course", "hr_course_version", "hr_credential", "hr_crew", "hr_deduction_code", "hr_department", "hr_derived_grant", "hr_disposition_event", "hr_earning_code", "hr_eeo_response", "hr_emergency_contact", "hr_employee", "hr_employee_private", "hr_employer_profile", "hr_employment", "hr_employment_pin", "hr_engagement", "hr_establishment", "hr_external_identity", "hr_field_policy", "hr_holiday", "hr_holiday_calendar", "hr_i9", "hr_i9_document", "hr_incident", "hr_incident_party", "hr_interview", "hr_interview_kit", "hr_job_title", "hr_jurisdiction", "hr_jurisdiction_rule", "hr_jurisdiction_rule_class", "hr_jurisdiction_rule_org_decision", "hr_jurisdiction_rule_test", "hr_kiosk_device", "hr_kiosk_session", "hr_labor_target", "hr_leave_case", "hr_leave_enrollment", "hr_leave_ledger", "hr_leave_policy", "hr_leave_request", "hr_legal_hold", "hr_legal_hold_item", "hr_location", "hr_new_hire_report", "hr_offer", "hr_opening", "hr_overtime_alert", "hr_overtime_alert_rule", "hr_overtime_preapproval", "hr_pay_group", "hr_pay_period", "hr_pay_period_employment", "hr_payroll_export", "hr_payroll_export_line", "hr_position_assignment", "hr_posting", "hr_posting_publication", "hr_provider_binding", "hr_provider_event", "hr_provisioning_result", "hr_punch", "hr_recalculation_batch", "hr_record_class", "hr_records_request", "hr_reference_check", "hr_reporting_line", "hr_requisition", "hr_restricted_note", "hr_retention_rule", "hr_role_assignment", "hr_schedule", "hr_schedule_change", "hr_schedule_guidance", "hr_schedule_template", "hr_schedule_template_shift", "hr_scorecard", "hr_separation", "hr_shift", "hr_shift_claim", "hr_staffing_requirement", "hr_survey", "hr_survey_invitation", "hr_survey_question", "hr_survey_response", "hr_tax_registration", "hr_tax_withholding", "hr_time_adjustment", "hr_training_assignment", "hr_training_attempt", "hr_transcript_entry", "hr_verification_letter_request", "hr_work_interval", "hr_workflow_binding", "hr_workflow_decision", "hr_workflow_definition", "hr_workflow_event", "hr_workflow_failure", "hr_workflow_flow_type", "hr_workflow_instance", "hr_workflow_step", "hr_workflow_step_definition", "hr_workweek", "html_extraction", "iam_access_audit", "iam_api_key", "iam_emergency_door_request", "idempotency", "industry", "industry_curator", "infra_status", "ingest_runs", "integration_connection", "integration_connection_resource", "interview_decision_interview", "interview_decision_question", "interview_document_revision", "interview_hole", "interview_question", "interview_session", "interview_turn", "invitation", "invitation_code", "invitation_request", "io_comment", "io_contract", "io_import", "io_outbox", "item", "item_mastery", "judge_verdict", "jurisdiction_policy", "keyword_classification_queue", "kg_alert", "kg_chunk_entities", "kg_chunks", "kg_clusters", "kg_edges", "kg_entities", "kg_entity_aliases", "kg_suggestion_ack", "kg_sweep_queue", "kg_sweep_run", "kg_sweep_state", "kg_value_match", "knob_override", "knob_override_audit", "knob_rung_lock", "knob_scope_kind", "knob_write_door", "league_membership", "learn_doc", "library_doc", "lifecycle_archive", "lifecycle_archive_row", "lifecycle_audit", "lifecycle_entity_plan", "lifecycle_map_build", "lifecycle_reference_map", "lifecycle_run", "lifecycle_tier_ledger", "location", "mandate", "mandate_advance_batch_row", "mandate_binding", "mandate_binding_legacy", "mandate_legacy", "mandate_observation", "mandate_reference", "mandate_scan", "mandate_treatment", "marketing_initiative", "masterwork_corpus_item", "masterwork_run", "masterwork_run_kind", "masterwork_source", "math_course_structure", "math_problem", "matrx_action_ledger", "mcp_config", "mcp_server", "mcp_user_conn", "media_capture_handoff", "media_catalog_setting", "media_library_item", "media_selection_item", "media_selection_job", "media_source_library", "meet_call_invite", "meet_meeting", "meet_note", "meet_participant", "meet_recording", "meet_transcript_segment", "membership", "membership_grant", "merge_field_provenance", "message", "message_template", "meta_excluded_schema", "meta_table_stats_history", "metadata_reserved_keys", "microservice_project", "migration_log", "mtx_media_heal_queue", "mtx_public_url_guard", "ner_shadow", "note", "note_folder", "notification", "notification_channel_preference", "notification_event_override", "notification_event_type", "notification_preference", "notify_outsider_door_baseline", "oauth_handoff_claim", "opinion_clusters", "opinions", "ops_issue_class", "ops_issue_event", "ops_proof_check", "ops_proof_run", "ops_proof_scenario", "org_admin_audit", "org_change_policy", "org_context_ledger", "org_industries", "org_member_control", "org_module_config", "org_plan", "org_repair_0253_backup", "organization", "organization_preferences", "organization_visibility_version", "output_feedback", "outreach_acceptance", "page_extraction_job", "page_extraction_page_run", "page_extraction_results", "page_extraction_runs", "page_intent_queue", "page_mapping_queue", "part_config", "part_config_sub", "party", "party_contact_point", "path_drift_repair_2026_09", "pc_article", "pc_episode", "pc_show", "pc_studio_run", "pc_studio_run_asset", "pdf_consolidation_log", "pdf_redaction_audit", "pdf_redaction_key_escrow", "permission_grant", "plan_cms_fill_item", "plan_cms_fill_job", "plan_entity", "plan_node", "plan_node_artifact", "plan_node_step", "plan_profile", "platform_actor_session", "platform_actor_token", "platform_actor_token_event", "platform_continued_access", "platform_org_knob_override", "platform_outcome_event", "platform_outsider_consumer", "platform_reachability", "platform_reference_category", "platform_reference_declaration", "platform_repo", "platform_saved_view", "platform_schema", "platform_share_link", "platform_user_knob_override", "podcast_race", "policy_overlap_backup", "policy_overlap_probe", "processed_document", "processed_document_page", "product_capture_file", "product_capture_item", "product_capture_payload", "product_capture_product", "product_capture_question", "profile", "project", "prompt", "provider_account", "provider_account_credential", "provision", "provision_generate_target", "provision_grant", "provision_marker", "provision_rule_message", "provision_schema", "provision_shape_debt", "provision_spec", "provision_spec_grandfather", "provision_vocabulary", "purpose", "quiz_session", "rag_ingest_run", "rag_library_audit_log", "rate_limit_buckets", "recompute_queue", "record", "record_alias", "redaction_mapping", "research_analysis", "research_content", "research_context_bundle", "research_document", "research_intent", "research_keyword", "research_media", "research_source", "research_synthesis", "research_tag", "research_template", "research_topic", "retention_policy", "retrieval_audit", "review_queue", "route_manifest_entry", "row_version", "rulebook", "runtime_operation_stream", "runtime_operation_stream_batch", "sandbox_instance", "sch_agent_task", "sch_run", "sch_task", "sch_trigger", "schema_client_exposure", "schema_migration_ledger", "schema_migration_legacy", "schema_migration_slot_grandfather", "schema_templates", "scope", "scope_association_suggestion", "scope_dataset_instance", "scope_door_registry", "scope_item_value_suggestion", "scope_suggestion", "scope_type", "scrape_domain", "scrape_domain_settings", "scrape_failure_log", "scrape_parsed_page", "scrape_path_override", "scrape_path_pattern", "scrape_retry_queue", "seo_ai_capability", "seo_ai_visibility_citation", "seo_ai_visibility_claim", "seo_ai_visibility_panel", "seo_ai_visibility_response", "seo_ai_visibility_signal", "seo_backlink", "seo_backlink_change_event", "seo_backlink_dimension_snapshot", "seo_backlink_observation", "seo_backlink_snapshot", "seo_change_assessment", "seo_change_event", "seo_change_item", "seo_change_metric", "seo_change_set", "seo_change_theory", "seo_collection_run", "seo_competitor", "seo_competitor_observation", "seo_competitor_opportunity", "seo_coverage_mention", "seo_coverage_tracker", "seo_dimension_value_matcher", "seo_engine_schedule", "seo_geo_place", "seo_gsc_dig_rule", "seo_keyword", "seo_keyword_class_rule", "seo_keyword_edge", "seo_keyword_facet", "seo_keyword_market", "seo_keyword_market_observation", "seo_keyword_place", "seo_keyword_saved_view", "seo_keyword_topic", "seo_landscape_brief", "seo_link_gap_domain", "seo_link_gap_match", "seo_map_facet", "seo_map_facet_value", "seo_map_topic", "seo_page_measurement_health", "seo_page_performance", "seo_provider_call", "seo_provider_task", "seo_rank_observation", "seo_rank_target", "seo_raw_payload", "seo_referring_domain_profile", "seo_reputation_case", "seo_search_performance_daily", "seo_serp_mention", "seo_serp_opportunity", "seo_serp_result", "seo_serp_snapshot", "seo_site_geo_area", "seo_site_keyword_offering", "seo_site_keyword_value", "seo_site_offering_value", "seo_site_topic_value", "seo_site_value_combo", "seo_site_value_worth", "seo_site_vocabulary", "seo_source_request", "seo_starter_pack", "seo_starter_pack_item", "seo_story_angle", "seo_topic", "seo_topical_map", "seo_web_analytics_daily", "share_link", "shareable_resource_registry", "shared_canvas_item", "short_link", "shortcut_category", "skill", "skill_category", "skill_render_definition", "sms_consent", "sms_conversation", "sms_message", "sms_message_media", "sms_notification", "sms_notification_preference", "sms_phone_number", "sms_rate_limits", "sms_webhook_logs", "soft_delete_edge", "source_authority", "stage_dockets_966c18eca7", "stage_ref_kind", "stamped_write_table", "structure", "structured_list", "studio_cleaned_segments", "studio_concept_items", "studio_documents", "studio_module_segments", "studio_raw_segments", "studio_recording_chunks", "studio_recording_segments", "studio_run", "studio_session", "studio_session_settings", "study_attempt", "study_goal", "study_media", "study_plan", "study_plan_block", "study_plan_day", "study_reminder_context", "study_reminder_delivery", "study_session", "study_source_chunk", "study_streak", "study_structured_section", "superseded_policy", "surface", "system_announcement", "system_context_item", "system_error", "system_orgs", "system_personal_org_failure", "system_write_failure", "task", "task_user_state", "taxonomy_node", "template_context_items", "template_scope_types", "templates", "thread", "tool", "tool_binding", "tool_bundle", "tool_call", "tool_definition_version", "tool_executor", "tool_surface_defaults", "tool_test_sample", "tool_ui", "tool_ui_incident", "tool_ui_version", "topic_placement_queue", "transcript", "trigger_event", "udt_dataset_fields", "udt_dataset_row_versions", "udt_dataset_rows", "udt_dataset_template", "udt_dataset_template_fields", "udt_document", "udt_document_snapshot", "udt_structured_list_items", "udt_workbook_snapshot", "ui_client", "ui_surface_agent_pref", "ui_surface_agent_role", "ui_surface_client_tool", "ui_surface_config", "ui_surface_value", "ui_surface_write_target", "unsubscribe_token", "uploads_inflight", "user_achievement", "user_active_context", "user_analysis_preference", "user_bookmark", "user_email_preference", "user_entity_state", "user_feedback", "user_follows", "user_form_profile", "user_markdown_sample", "user_memory", "user_preference", "user_profile", "user_secret", "user_secret_audit", "user_secret_grant", "user_stat", "user_storage_usage", "user_surface_state", "visibility_cache", "visibility_epoch", "voice", "war_room", "wbx_capture", "wbx_demo", "wbx_guidance", "wbx_highlight", "wbx_pattern", "wbx_recipe", "wbx_screenshot", "wbx_seo_audit", "wc_claim", "wc_impairment_definition", "wc_injury", "wc_report", "web_analysis_item", "web_brand", "web_brand_asset", "web_brand_offering", "web_business_fact", "web_business_location", "web_channel_analytics_daily", "web_crawl_event", "web_crawl_preset", "web_crawl_schedule", "web_crawl_session", "web_crawl_url", "web_discovered_item", "web_finding", "web_gsc_page_stat", "web_link_edge", "web_listing_publisher", "web_location_listing", "web_offering_template", "web_page", "web_page_content", "web_page_evidence", "web_page_sitemap", "web_property", "web_provider", "web_result", "web_screenshot", "web_site", "web_site_endpoint_rule", "web_site_item_config", "web_site_offering", "web_sitemap", "web_snapshot", "web_tag_manager_snapshot", "web_youtube_video", "webhook_deliveries", "webhook_dispatch_state", "webhooks", "wf_node_data_slot", "work_claim", "work_item", "workbook", "worker_heartbeat", "workflow", "workflow_card", "workflow_checkpoint", "workflow_comparison", "workflow_definition_version", "workflow_idempotency", "workflow_job", "workflow_node_events", "workflow_node_outcome", "workflow_plan", "workflow_plan_event", "workflow_plan_sample", "workflow_recovery_audit", "workflow_run", "workflow_run_log", "workflow_runtime_surface", "workflow_template", "workflow_trigger", "workflow_trigger_fire", "workflow_work_item", "working_document", "write_guard_key", "youtube_quota_day", "youtube_search", "youtube_video"];
1467
+ type StoreRefusalCode = (typeof STORE_REFUSAL_CODES)[number]["code"];
1468
+ type StoreDoorName = (typeof STORE_DOORS)[number]["name"];
1469
+ type EntityToken = (typeof ENTITY_TOKENS)[number];
1470
+ type KernelTableName = (typeof KERNEL_TABLES)[number]["name"];
1471
+
1472
+ /**
1473
+ * VAL-8. Who wrote a value. `user`, `agent`, `system` — enforced by every write
1474
+ * door, and the three retired words (`human`, `ai`, `code`) are translated by
1475
+ * the store's own `custom.actor_word`, never by a caller.
1476
+ */
1477
+ type Actor = (typeof ACTOR_VOCABULARY)[number];
1478
+ /** The words the store still accepts and rewrites, mapped to what they become. */
1479
+ type RetiredActorWord = keyof typeof RETIRED_ACTOR_WORDS;
1480
+ /**
1481
+ * VAL-2. Why a value is missing. A value is never blank for an unexplained
1482
+ * reason: it either holds something or it says one of these four words.
1483
+ */
1484
+ type AbsenceReason = (typeof ABSENCE_REASONS)[number];
1485
+ /** The closed key set of one value envelope (VAL-1 … VAL-4). */
1486
+ type ValueEnvelopeKey = (typeof VALUE_ENVELOPE_KEYS)[number];
1487
+ /** The closed key set of one ranked alternate (VAL-3). */
1488
+ type ValueAlternateKey = (typeof VALUE_ALTERNATE_KEYS)[number];
1489
+ /**
1490
+ * REC-4. `heavy` is indexed storage with Rules on write; `light` is
1491
+ * whole-document storage with Rules on read. Per Table, one store.
1492
+ */
1493
+ type StorageMode = (typeof STORAGE_MODES)[number];
1494
+ /** REC-15. One Rule object, four uses. */
1495
+ type RuleUse = (typeof RULE_USES)[number];
1496
+ /**
1497
+ * VAL-5 / VAL-6. The words that may NOT appear inside a value envelope:
1498
+ * visibility and access belong to a Field and to a Record, never to a value.
1499
+ * The store refuses each of them by name and so does this package's mirror.
1500
+ */
1501
+ type PerValueAccessWord = (typeof PER_VALUE_ACCESS_WORDS)[number];
1502
+ /** FLD-11. The parity floor: the field type a person picks in the UI. */
1503
+ type ParityFieldType = (typeof PARITY_FIELD_TYPES)[number]["parity_type"];
1504
+ /** FLD-1. The five behaviours a Field can have. One, exactly, and closed. */
1505
+ type FieldBehavior = (typeof PARITY_FIELD_TYPES)[number]["behavior"];
1506
+ /** The node kinds `custom.rule_eval` evaluates. */
1507
+ type RuleNodeKind = (typeof RULE_NODE_KINDS)[number]["node"];
1508
+ /**
1509
+ * REC-32. The seven table types, closed. The parenthesised names are the
1510
+ * retired ones the doctrine records; never coin an eighth.
1511
+ */
1512
+ declare const TABLE_TYPES: readonly ["entity", "detail", "reference", "ledger", "restricted", "system", "deprecated"];
1513
+ type TableType = (typeof TABLE_TYPES)[number];
1514
+ /** REC-33. The two origins. A table we ship in schema `custom` is `standard`. */
1515
+ declare const TABLE_ORIGINS: readonly ["standard", "custom"];
1516
+ type TableOrigin = (typeof TABLE_ORIGINS)[number];
1517
+ /** REL-1. Ownership is one fact, stored once, read from the field's side. */
1518
+ declare const RELATION_FLAVORS: readonly ["owned", "referenced"];
1519
+ type RelationFlavor = (typeof RELATION_FLAVORS)[number];
1520
+ /** REL-2. What happens to the far side, separate from flavour. */
1521
+ declare const ON_DELETE: readonly ["cascade", "set_null", "restrict"];
1522
+ type OnDelete = (typeof ON_DELETE)[number];
1523
+ /** REL-3. A snapshot is a frozen copy in the relation's payload, never a pointer. */
1524
+ declare const RELATION_BINDINGS: readonly ["live", "snapshot"];
1525
+ type RelationBinding = (typeof RELATION_BINDINGS)[number];
1526
+ /** REL-7. */
1527
+ declare const RELATION_CARDINALITIES: readonly ["one", "many"];
1528
+ type RelationCardinality = (typeof RELATION_CARDINALITIES)[number];
1529
+ /** FLD-7. Where a Field's values come from. */
1530
+ declare const FIELD_SOURCES: readonly ["manual", "formula", "agent", "synced"];
1531
+ type FieldSource = (typeof FIELD_SOURCES)[number];
1532
+ /** FLD-9. A Formula declares whether it computes on read or on write. */
1533
+ declare const COMPUTE_ON: readonly ["read", "write"];
1534
+ type ComputeOn = (typeof COMPUTE_ON)[number];
1535
+ /**
1536
+ * AGT-7 / FLD-12. A Field's sensitivity sets a ceiling a merge field can never
1537
+ * widen — and these are THE STORE'S four words, checked against its own guard.
1538
+ *
1539
+ * This list used to read `standard · sensitive · secret`, which the store has
1540
+ * never accepted: writing a Field with `sensitivity: "standard"` is refused
1541
+ * with "the field <name> has to say how sensitive its values are, and it says
1542
+ * standard". The knob `custom/field_sensitivity_levels` keys off these same
1543
+ * four words to decide which level may read and edit each one, so a package
1544
+ * carrying three different words could never have agreed with it. Corrected
1545
+ * against the live store, 2026-09-18.
1546
+ */
1547
+ declare const FIELD_SENSITIVITIES: readonly ["public", "internal", "confidential", "restricted"];
1548
+ type FieldSensitivity = (typeof FIELD_SENSITIVITIES)[number];
1549
+ /** DYN-17 / §D. Which tier a MERGE FIELD's value is delivered in. */
1550
+ declare const DELIVERIES: readonly ["inline", "on_demand", "auto"];
1551
+ type Delivery = (typeof DELIVERIES)[number];
1552
+ /**
1553
+ * FLD-12. WHETHER AN AGENT MAY SEE A FIELD'S VALUES, and these are the STORE'S
1554
+ * four words — not the merge field's delivery tiers.
1555
+ *
1556
+ * `Field.context_policy` used to be typed as `Delivery` here, which is a
1557
+ * different question with a different vocabulary: writing a Field with
1558
+ * `context_policy: "inline"` is refused with "the field <name> has to say
1559
+ * whether an agent may see its values, and it says inline". Delivery is about
1560
+ * HOW MUCH of a value a merge field carries into a turn; this is about WHETHER
1561
+ * the value reaches an agent at all, and conflating them let a screen offer a
1562
+ * word the store has never accepted. Corrected against the live store,
1563
+ * 2026-09-18.
1564
+ */
1565
+ declare const CONTEXT_POLICIES: readonly ["include", "summarize", "exclude", "on_request"];
1566
+ type ContextPolicy = (typeof CONTEXT_POLICIES)[number];
1567
+ /** DYN-3. The eight sources, closed. Relationships and rules are not sources. */
1568
+ declare const MERGE_FIELD_SOURCES: readonly ["literal", "record", "state", "actor", "platform", "user_input", "tool", "derived"];
1569
+ type MergeFieldSource = (typeof MERGE_FIELD_SOURCES)[number];
1570
+ /** DYN-4. What a merge field resolves INTO. The consumer never learns which. */
1571
+ declare const MERGE_FIELD_SEMANTIC_TYPES: readonly ["value", "reference", "resolver", "computed", "collection"];
1572
+ type MergeFieldSemanticType = (typeof MERGE_FIELD_SEMANTIC_TYPES)[number];
1573
+ /** DYNAMIC-VALUES §A. Any number of these; never fused into the source. */
1574
+ declare const MERGE_FIELD_MODIFIERS: readonly ["scoped", "temporal", "collection", "live", "fallback", "formatted", "required"];
1575
+ type MergeFieldModifier = (typeof MERGE_FIELD_MODIFIERS)[number];
1576
+ /** DYN-12. The five override policies. Exactly one, and it outranks the ladder. */
1577
+ declare const OVERRIDE_POLICIES: readonly ["must_supply", "shown_overridable", "shown_locked", "server_fixed", "derived"];
1578
+ type OverridePolicy = (typeof OVERRIDE_POLICIES)[number];
1579
+ /** DYNAMIC-VALUES §C. What a resolved merge field's freshness was. */
1580
+ declare const FRESHNESS: readonly ["live", "cached", "snapshot"];
1581
+ type Freshness = (typeof FRESHNESS)[number];
1582
+ /** REC-1. How a Table shows itself. */
1583
+ declare const TABLE_DISPLAYS: readonly ["list", "grid", "board", "calendar", "timeline"];
1584
+ type TableDisplay = (typeof TABLE_DISPLAYS)[number];
1585
+
1586
+ /** A `uuid` as the store writes it. */
1587
+ type Uuid = string;
1588
+ /** An ISO-8601 timestamp, as jsonb carries it. */
1589
+ type Timestamp = string;
1590
+ /**
1591
+ * VAL-1. WHERE a value came from, addressed by a pointer the STORE interns —
1592
+ * `s1`, `s2`, `s3`. A writer supplies the source itself and the store interns
1593
+ * it; a writer that invents a pointer is refused by name. Interned once per
1594
+ * save: two pointers holding the same description is the defect the word
1595
+ * "interned" exists to prevent, and the store refuses that too.
1596
+ */
1597
+ type ProvenancePointer = string;
1598
+ /** The description a pointer resolves to. Free-shaped by design: the store checks that it is an object, and the organization decides what it says. */
1599
+ type ValueSource = Record<string, unknown>;
1600
+ /**
1601
+ * VAL-3 / VAL-4. Another candidate for the same value, with the source it came
1602
+ * from and the RANK — the order an organization trusts its sources in, never a
1603
+ * score or a confidence a machine invented. Ranks are whole, start at 1, and
1604
+ * two alternates never claim the same one. They live INSIDE this record's
1605
+ * document; there is never a row per value.
1606
+ */
1607
+ interface ValueAlternate {
1608
+ value: unknown;
1609
+ /** A pointer this record's `_sources` block resolves. */
1610
+ src?: ProvenancePointer | null;
1611
+ rank: number;
1612
+ }
1613
+ /**
1614
+ * The value envelope. One per field key, in the record's `_values` block, with
1615
+ * the value itself sitting at the top level under the same key.
1616
+ *
1617
+ * The key set is CLOSED (`custom.value_envelope_keys()`). In particular it can
1618
+ * never carry visibility, access, share, acl, permission, permissions or
1619
+ * secret: VAL-5 puts those on the Field and on the Record, and VAL-6 says a
1620
+ * value that must be secret goes in a contained record with its own visibility.
1621
+ * The store refuses each of those words by name.
1622
+ */
1623
+ interface ValueEnvelope {
1624
+ /** The per-value version, 1 or more. THE STORE WRITES IT — no caller sets it. */
1625
+ ver: number;
1626
+ /** A provenance pointer this record's `_sources` block resolves. */
1627
+ src?: ProvenancePointer | null;
1628
+ /** VAL-8. Who wrote it. */
1629
+ actor: Actor;
1630
+ /** Only an agent acts on behalf of a person; a person's id. */
1631
+ on_behalf_of?: Uuid | null;
1632
+ at?: Timestamp | null;
1633
+ /** VAL-2. Why it is missing. A value either holds something or says this. */
1634
+ absent?: AbsenceReason | null;
1635
+ alternates?: ValueAlternate[] | null;
1636
+ /**
1637
+ * FLD-2's `dated` modifier: the WORLD clock for this value — when it was true
1638
+ * of the world, which is a different question from when it was written. Added
1639
+ * to the store's closed key set after this package's first generation, and
1640
+ * caught by `pnpm check:store-registry` rather than by anybody noticing.
1641
+ */
1642
+ dated?: string | null;
1643
+ }
1644
+ /**
1645
+ * The one jsonb document. Field keys sit at the top level; the store's own
1646
+ * blocks are underscore-prefixed and are never a writer's value.
1647
+ */
1648
+ interface RecordDocument {
1649
+ /** The store's interned provenance table: pointer -> source. */
1650
+ _sources?: Record<ProvenancePointer, ValueSource>;
1651
+ /** The envelopes, keyed by field key. */
1652
+ _values?: Record<string, ValueEnvelope>;
1653
+ /** FLD-10. Which type of record this is, selecting the Fields and Rules that apply. */
1654
+ _type?: string;
1655
+ /** REC-7. Zero or one parent. Never two. */
1656
+ _parent?: Uuid | null;
1657
+ [fieldKey: string]: unknown;
1658
+ }
1659
+ /** `custom.record` as the store holds it — the row around the document. */
1660
+ interface StoredRecord {
1661
+ id: Uuid;
1662
+ organization_id: Uuid;
1663
+ table_id: Uuid | null;
1664
+ /** `record` for ordinary rows, `kernel` for the nine kernel Tables (REC-27). */
1665
+ data_class: string;
1666
+ data: RecordDocument;
1667
+ created_by: Uuid | null;
1668
+ updated_by: Uuid | null;
1669
+ created_at: Timestamp;
1670
+ updated_at: Timestamp;
1671
+ /** REC-23: soft, and reversible within `retention`. */
1672
+ deleted_at: Timestamp | null;
1673
+ /** The RECORD clock. `recordUpdate` writes against it (optimistic concurrency). */
1674
+ version: number;
1675
+ metadata: Record<string, unknown>;
1676
+ custom_fields: Record<string, unknown>;
1677
+ visibility: string;
1678
+ }
1679
+ /**
1680
+ * One value read back with everything the store knows about it — the shape
1681
+ * `custom.record_values_versioned` and `custom.value_read` answer in. This is
1682
+ * what a screen needs to explain a value (DYN-24) without a second query.
1683
+ */
1684
+ interface ReadValue {
1685
+ field_key: string;
1686
+ field_id: Uuid | null;
1687
+ value: unknown;
1688
+ value_version: number | null;
1689
+ source: ValueSource | null;
1690
+ absent_reason: AbsenceReason | null;
1691
+ actor: Actor | null;
1692
+ on_behalf_of: Uuid | null;
1693
+ written_at: Timestamp | null;
1694
+ alternates: ValueAlternate[] | null;
1695
+ }
1696
+ /**
1697
+ * Why one field of a record came back empty — `custom.hidden_field_notice`, as
1698
+ * the read door attaches it under `_hidden`. It is the store's own sentence, so
1699
+ * a screen says "you need X to see this" instead of drawing a blank cell.
1700
+ */
1701
+ interface HiddenFieldNotice {
1702
+ /** The field's sensitivity word. */
1703
+ reason: string | null;
1704
+ /** The level this person would need. */
1705
+ needs: string | null;
1706
+ /** The other way in — "a share of this one field with you". */
1707
+ or: string | null;
1708
+ }
1709
+ /**
1710
+ * One row as the read door `custom.read_records` answers it: the id, the
1711
+ * document the store decided this reader may see, and the reader's level on the
1712
+ * Table. A field this reader may not see is PRESENT and null, with its reason
1713
+ * in `hidden` — the masking is the store's, never this client's.
1714
+ */
1715
+ interface ReadRow {
1716
+ id: Uuid;
1717
+ document: RecordDocument;
1718
+ /** `public.permission_level` — the caller's level on the Table. */
1719
+ level: string;
1720
+ hidden: Record<string, HiddenFieldNotice>;
1721
+ }
1722
+ /**
1723
+ * One revision of one record, as `custom.io_revisions` answers it, newest
1724
+ * first. `version` is the record's own version at that point — the number a
1725
+ * screen hands back as `expectedVersion` so the store, not the screen, decides
1726
+ * whether someone else got there first.
1727
+ */
1728
+ interface RecordRevision {
1729
+ version: number;
1730
+ changed_at: string;
1731
+ changed_by: Uuid | null;
1732
+ summary: string | null;
1733
+ }
1734
+ /** A whole record as `recordRead` answers it, through `custom.read_record`. */
1735
+ interface RecordRead {
1736
+ record_id: Uuid;
1737
+ /** The masked document. A hidden field is present and null. */
1738
+ document: RecordDocument;
1739
+ /** Why each masked field is masked, in the store's words. */
1740
+ hidden: Record<string, HiddenFieldNotice>;
1741
+ /**
1742
+ * FLD-9 / REC-19. Which Rule version produced each computed value. Present
1743
+ * only where the store has computed provenance for this record.
1744
+ */
1745
+ computed: Array<{
1746
+ field_key: string;
1747
+ field_id: Uuid;
1748
+ value: unknown;
1749
+ rule_id: Uuid;
1750
+ rule_version: number;
1751
+ computed_at: Timestamp;
1752
+ }>;
1753
+ }
1754
+
1755
+ /**
1756
+ * REC-1. A Table declares its fields, exactly one Home, and the properties
1757
+ * `display`, `ordered`, `heavy` | `light`, `retention` and `detail`.
1758
+ */
1759
+ interface Table {
1760
+ id: Uuid;
1761
+ organization_id: Uuid;
1762
+ /** The token this Table is addressed by. */
1763
+ slug: string;
1764
+ name: string;
1765
+ label_singular: string | null;
1766
+ label_plural: string | null;
1767
+ icon: string | null;
1768
+ color: string | null;
1769
+ /** REC-32. One of the seven, closed. */
1770
+ type: TableType;
1771
+ /** REC-11. A detail Table inherits only: no direct shares, never a Home. */
1772
+ detail: boolean;
1773
+ parent_token: string | null;
1774
+ /** AGT-1 / AGT-2. On by default for a custom table; an organization turns it off. */
1775
+ agent_writable: boolean;
1776
+ display: TableDisplay | null;
1777
+ ordered: boolean;
1778
+ /** REC-4. `heavy` is indexed with Rules on write; `light` is the whole document with Rules on read. */
1779
+ weight: StorageMode;
1780
+ /** REC-23. How long a soft delete stays reversible. */
1781
+ retention_days: number | null;
1782
+ /** REC-2. Every Table has one; without it a record cannot be a chip. */
1783
+ title_field: string | null;
1784
+ /** The field ids this Table declares, in declaration order. */
1785
+ fields: Uuid[];
1786
+ default_sort: string | null;
1787
+ row_order: string | null;
1788
+ /** REC-14. Where this Table lives. Exactly one primary Home. */
1789
+ home_id: Uuid | null;
1790
+ /** REC-27. One of the nine, defined in code and not editable by Migration. */
1791
+ is_kernel: boolean;
1792
+ created_by: Uuid | null;
1793
+ updated_by: Uuid | null;
1794
+ created_at: Timestamp;
1795
+ updated_at: Timestamp;
1796
+ version: number;
1797
+ metadata: Record<string, unknown>;
1798
+ visibility: string;
1799
+ }
1800
+ /**
1801
+ * REC-33. `origin` is `standard` or `custom`, and it is orthogonal to `type`.
1802
+ * A Table we ship in schema `custom` is `standard` — the schema name is not the
1803
+ * origin.
1804
+ */
1805
+ interface RegisteredTable {
1806
+ token: string;
1807
+ type: TableType;
1808
+ origin: TableOrigin;
1809
+ /** REC-34. Carried per table type: true for Entity and Detail, false for the other five. */
1810
+ custom_fields_enabled: boolean;
1811
+ }
1812
+ /**
1813
+ * REC-3 / REC-26. A Home is where a Table appears. The declared organization
1814
+ * Home is the tree's root; every additional Home is a referenced carrying
1815
+ * relation from the Home record to the Table record, which is why this shape
1816
+ * names a relation id rather than a second placement column.
1817
+ */
1818
+ interface Home {
1819
+ table_id: Uuid;
1820
+ home_record_id: Uuid;
1821
+ organization_id: Uuid;
1822
+ /** `declared` for the Table's own Home, `carried` for an additional one. */
1823
+ kind: string;
1824
+ relation_id: Uuid | null;
1825
+ }
1826
+ /** What `tablePropose` / `tableList` hands back about how full a Table is (REC-N-5). */
1827
+ interface TableCapacity {
1828
+ records: number;
1829
+ ceiling: number;
1830
+ full: boolean;
1831
+ /** The knob that decides the ceiling, named so a person can act on it. */
1832
+ knob: string;
1833
+ }
1834
+
1835
+ /** FLD-3. A constraint attached to a Field. A Rule, never a behaviour. */
1836
+ interface FieldRule {
1837
+ kind: "min" | "max" | "length" | "pattern" | "equals_field" | "differs_from_field";
1838
+ value: string | number;
1839
+ /** FLD-10. Empty means "wherever the Field applies". */
1840
+ applies_to_types?: string[];
1841
+ }
1842
+ /**
1843
+ * `custom.field` — the ONE definitions table (FLD-8), organization-scoped, so
1844
+ * two organizations add different fields to the same standard table.
1845
+ */
1846
+ interface Field {
1847
+ id: Uuid;
1848
+ organization_id: Uuid;
1849
+ /** Set when this Field extends a standard entity rather than a custom Table. */
1850
+ entity_definition_id: Uuid | null;
1851
+ /** The token of the Table this Field belongs to. */
1852
+ table_token: string | null;
1853
+ key: string;
1854
+ label: string;
1855
+ name: string | null;
1856
+ /** FLD-1. Exactly one of five. */
1857
+ type: FieldBehavior;
1858
+ /** FLD-2. The shape of the value, never a second behaviour. */
1859
+ multi: boolean;
1860
+ /** FLD-2. The values carry their own dates — the world clock, not History. */
1861
+ dated: boolean;
1862
+ /** FLD-3. Any number of attached validation Rules. */
1863
+ rules: FieldRule[];
1864
+ config: Record<string, unknown>;
1865
+ required: boolean;
1866
+ default: unknown;
1867
+ sort: number | null;
1868
+ /** The Table this relation points at. */
1869
+ relation_target: Uuid | null;
1870
+ relation_max: number | null;
1871
+ on_target_delete: OnDelete | null;
1872
+ /** REL-9. The reverse is visible from both ends and is NOT a second Field. */
1873
+ inverse_key: string | null;
1874
+ source: FieldSource;
1875
+ source_config: Record<string, unknown>;
1876
+ /** FLD-9. A Formula declares whether it computes on read or on write. */
1877
+ compute_on: ComputeOn | null;
1878
+ /** The unit, on the Field, because it changes the meaning. Never presentation. */
1879
+ unit: string | null;
1880
+ format: string | null;
1881
+ /** AGT-7. A ceiling a merge field's delivery can never widen. */
1882
+ sensitivity: FieldSensitivity | null;
1883
+ /** FLD-12. Whether an agent may see this Field's values: include · summarize · exclude · on_request. */
1884
+ context_policy: ContextPolicy | null;
1885
+ /** AGT-6. How often a `source = agent` Field is refilled. */
1886
+ review_interval_days: number | null;
1887
+ /**
1888
+ * §D says this is on the wrong object and moves to the merge field. It is
1889
+ * still carried here because the live column is, and the client reads what
1890
+ * the store holds — never what the plan wishes it held.
1891
+ */
1892
+ depends_on: Uuid[] | null;
1893
+ /** FLD-10. Which record types this Field applies to. Empty means all of them. */
1894
+ applies_to_types: string[];
1895
+ /** FLD-5 / FLD-6. A list field's choices are the records of THIS Table. */
1896
+ options_table_id: Uuid | null;
1897
+ created_by: Uuid | null;
1898
+ updated_by: Uuid | null;
1899
+ created_at: Timestamp;
1900
+ updated_at: Timestamp;
1901
+ version: number;
1902
+ metadata: Record<string, unknown>;
1903
+ visibility: string;
1904
+ }
1905
+ /**
1906
+ * FLD-11. What the person picked, and what the store says it is made of. The
1907
+ * list itself is generated from `custom.parity_field_types()`; this is its type.
1908
+ */
1909
+ interface ParityFieldTypeDescriptor {
1910
+ parity_type: ParityFieldType;
1911
+ behavior: FieldBehavior;
1912
+ made_of: string;
1913
+ }
1914
+ /** AGT-8 / AGT-4. What an agent (or a person) proposes when a Field is missing. */
1915
+ interface FieldProposal {
1916
+ table_id: Uuid;
1917
+ key: string;
1918
+ label: string;
1919
+ type: FieldBehavior;
1920
+ multi?: boolean;
1921
+ required?: boolean;
1922
+ config?: Record<string, unknown>;
1923
+ relation_target?: Uuid;
1924
+ /** Why this Field should exist — what an approver reads before approving. */
1925
+ because: string;
1926
+ }
1927
+ /** AGT-8. What a table proposal looks like, same shape of question. */
1928
+ interface TableProposal {
1929
+ name: string;
1930
+ slug: string;
1931
+ title_field: string;
1932
+ fields: Array<Omit<FieldProposal, "table_id" | "because">>;
1933
+ because: string;
1934
+ }
1935
+
1936
+ /**
1937
+ * A rule expression as `custom.rule_eval` ACTUALLY evaluates it — read off the
1938
+ * door's own body, not invented here. A leaf is the node's name carrying its
1939
+ * payload (`{"const": 3}`, `{"field": "<uuid>"}`); an operator is
1940
+ * `{"op": "eq", "args": [...]}`.
1941
+ *
1942
+ * `field` / `parent_field` name a Field BY ID (REC-17 — the door refuses
1943
+ * `field_name`, `field_key` and `field_label` by name), and `merge_field` is
1944
+ * the resolver's seam, storable today and refused `0A000` until W5-MERGE-B.
1945
+ *
1946
+ * `p_values` is keyed by the Field's KEY: the door resolves the id to a key
1947
+ * (`custom.rule_field_key`) and then reads `p_values -> key`.
1948
+ */
1949
+ type RuleExpression = {
1950
+ const: unknown;
1951
+ } | {
1952
+ field: Uuid;
1953
+ } | {
1954
+ parent_field: Uuid;
1955
+ } | {
1956
+ merge_field: string;
1957
+ } | {
1958
+ op: RuleNodeKind;
1959
+ args: RuleExpression[];
1960
+ };
1961
+ /** REC-15. One Rule, four uses; a Rule may serve more than one. */
1962
+ interface Rule {
1963
+ id: Uuid;
1964
+ organization_id: Uuid;
1965
+ name: string;
1966
+ kind: string | null;
1967
+ /** The Table this Rule is scoped to. */
1968
+ scope_table_id: Uuid | null;
1969
+ uses: RuleUse[];
1970
+ validates: boolean;
1971
+ computes: boolean;
1972
+ defines_membership: boolean;
1973
+ /**
1974
+ * REC-16. An applicability Rule reads the record's own Values and its
1975
+ * parent's, ONE level up, and no further.
1976
+ */
1977
+ decides_applicability: boolean;
1978
+ applies_to_types: string[];
1979
+ use_types: string[];
1980
+ expr: RuleExpression;
1981
+ /** Which Field this Rule's answer is about (REC-17: by id). */
1982
+ target_field_id: Uuid | null;
1983
+ /** What a person reads when this Rule refuses. */
1984
+ message: string | null;
1985
+ sort: number | null;
1986
+ created_by: Uuid | null;
1987
+ updated_by: Uuid | null;
1988
+ created_at: Timestamp;
1989
+ updated_at: Timestamp;
1990
+ /** REC-19. Rules have versions, and History knows which one produced a Value. */
1991
+ version: number;
1992
+ metadata: Record<string, unknown>;
1993
+ visibility: string;
1994
+ }
1995
+ /** What the store answers when a Rule is run: the answer and the version that gave it. */
1996
+ interface RuleAnswer {
1997
+ rule_id: Uuid;
1998
+ rule_name: string;
1999
+ rule_version: number;
2000
+ applies: boolean;
2001
+ answer: unknown;
2002
+ }
2003
+
2004
+ /** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
2005
+ type AggregateOperation = "count" | "sum" | "avg" | "min" | "max";
2006
+ /** The periods a date Field can be bucketed into (`custom.agg_buckets()`). */
2007
+ type AggregateBucket = "day" | "week" | "month" | "quarter" | "year";
2008
+ /** One measure. `count` counts rows and needs no Field; the rest read one. */
2009
+ interface AggregateMeasure {
2010
+ op: AggregateOperation;
2011
+ /** The Field's key. Required for every operation except `count`. */
2012
+ key?: string;
2013
+ }
2014
+ /**
2015
+ * One row of an aggregate: which group it is, what each measure came to, and
2016
+ * how many records it was worked out from. The measure keys are the store's
2017
+ * own (`count`, `sum_amount`, `avg_amount`, …), never renamed on the way out.
2018
+ */
2019
+ interface AggregateRow {
2020
+ groups: Record<string, string | null>;
2021
+ measures: Record<string, number | null>;
2022
+ row_count: number;
2023
+ }
2024
+ /** The measure key the store answers with, so a chart can find its own series. */
2025
+ declare function measureKey(measure: AggregateMeasure): string;
2026
+
2027
+ /** One token found in a body, in the order it appears. */
2028
+ interface DocToken {
2029
+ ordinal: number;
2030
+ /** Exactly as it is written in the body. */
2031
+ raw: string;
2032
+ field_id: Uuid | null;
2033
+ }
2034
+ /** A token this Table cannot answer, with the store's own reason. */
2035
+ interface DocUnresolvedToken {
2036
+ raw: string;
2037
+ field_id: Uuid | null;
2038
+ /** The store's sentence. Shown verbatim — a template is not published over it. */
2039
+ why: string;
2040
+ }
2041
+ /** What the store says about a signature when it is asked whether it still holds. */
2042
+ interface DocSignatureCheck {
2043
+ intact: boolean;
2044
+ /** The store's own sentence when it is not. */
2045
+ reason?: string;
2046
+ signed_at?: Timestamp;
2047
+ }
2048
+ /** `custom.doc_template` — a body with tokens, and the Table it renders. */
2049
+ interface DocTemplateRow {
2050
+ id: Uuid;
2051
+ organization_id: Uuid;
2052
+ renders_table_id: Uuid;
2053
+ name: string;
2054
+ body: string;
2055
+ /** REC-68 / VAL-10: a seal is over a document VERSION, so the version is first-class. */
2056
+ template_version: number;
2057
+ token_count: number;
2058
+ updated_at: Timestamp;
2059
+ }
2060
+ /**
2061
+ * `custom.doc_render` — a rendered document, FROZEN. The bytes and their
2062
+ * SHA-256 are what a signature seals, which is why a render is never edited:
2063
+ * a further agreement is a further version with its own seal.
2064
+ */
2065
+ interface DocRenderRow {
2066
+ id: Uuid;
2067
+ template_id: Uuid;
2068
+ record_id: Uuid;
2069
+ table_id: Uuid;
2070
+ template_version: number;
2071
+ body: string;
2072
+ content_hash: string;
2073
+ rendered_at: Timestamp;
2074
+ }
2075
+ /** `custom.doc_signature` — one seal, immutable once made. */
2076
+ interface DocSignatureRow {
2077
+ id: Uuid;
2078
+ render_id: Uuid;
2079
+ record_id: Uuid;
2080
+ field_key: string;
2081
+ signer_name: string;
2082
+ signer_user_id: Uuid | null;
2083
+ signed_at: Timestamp;
2084
+ document_hash: string;
2085
+ document_version: number;
2086
+ }
2087
+
2088
+ /** `immediate` fires on the change; `digest` is collected and sent on a schedule. */
2089
+ type SubscriptionCadence = "immediate" | "digest";
2090
+ /** One subscription, exactly as `custom.agg_subscriptions` reports it. */
2091
+ interface Subscription {
2092
+ rule_id: Uuid;
2093
+ saved_view_id: Uuid | null;
2094
+ cadence: string;
2095
+ /** The digest's schedule. Null for `immediate`. */
2096
+ schedule: string | null;
2097
+ channel: string;
2098
+ /** Null means this subscription fires at nobody, and the store says so. */
2099
+ recipient_user_id: Uuid | null;
2100
+ event_key: string;
2101
+ name: string;
2102
+ }
2103
+ /** The `subscription` block a Rule record carries. Written through `record_write`. */
2104
+ interface SubscriptionBlock {
2105
+ saved_view_id: Uuid;
2106
+ cadence: SubscriptionCadence;
2107
+ schedule?: string | null;
2108
+ channel?: string;
2109
+ recipient_user_id?: Uuid | null;
2110
+ event_key?: string;
2111
+ }
2112
+
2113
+ /**
2114
+ * REL-6. Whether Visibility flows along this relation and the MAXIMUM access
2115
+ * level it carries. Default off on `referenced`, on for `owned`.
2116
+ */
2117
+ interface RelationCarries {
2118
+ carries: boolean;
2119
+ /** The ceiling — a relation never carries more access than this. */
2120
+ max_access: string | null;
2121
+ }
2122
+ /** The seven properties, each its own question. */
2123
+ interface RelationProperties {
2124
+ /** REL-1. Stored once on the contained table, read from the field's side. */
2125
+ flavor: RelationFlavor;
2126
+ /** REL-2. Separate from flavour. */
2127
+ on_delete: OnDelete;
2128
+ /** REL-3. A snapshot is a frozen copy in the relation's payload — never a pointer into History. */
2129
+ binding: RelationBinding;
2130
+ /** REL-4. */
2131
+ ordered: boolean;
2132
+ /** REL-5. */
2133
+ loops: "allowed" | "refused";
2134
+ /** REL-6. */
2135
+ carries: RelationCarries;
2136
+ /** REL-7. */
2137
+ cardinality: RelationCardinality;
2138
+ }
2139
+ /**
2140
+ * REL-8 / REL-N-1. A target is a REFERENCE, written that way from the first
2141
+ * line of code, because it may name a row outside our database. One Table,
2142
+ * several, or any — polymorphic without restriction. External targets are
2143
+ * read-only in v1.
2144
+ */
2145
+ type RelationTarget = {
2146
+ kind: "ours";
2147
+ entity_token: string;
2148
+ row_id: Uuid;
2149
+ } | {
2150
+ kind: "external";
2151
+ connection_token: string;
2152
+ external_table: string;
2153
+ external_key: string;
2154
+ } | {
2155
+ kind: "any";
2156
+ };
2157
+ /** One edge, as the store holds it in `platform.associations`. */
2158
+ interface Relation {
2159
+ id: Uuid;
2160
+ organization_id: Uuid;
2161
+ /** REL-10. The field key, which is what `role` holds. */
2162
+ role: string;
2163
+ source: RelationTarget;
2164
+ target: RelationTarget;
2165
+ properties: RelationProperties;
2166
+ /** REL-4. Meaningful only when `ordered`. */
2167
+ position: number | null;
2168
+ /** REL-3. The frozen copy, when `binding` is `snapshot`. */
2169
+ payload: Record<string, unknown> | null;
2170
+ /** REL-14. Hydrated from the target's title field AT READ — never stored. */
2171
+ label: string | null;
2172
+ created_at: Timestamp;
2173
+ updated_at: Timestamp;
2174
+ /** REL-13 / REL-16. Associations are versioned, so relation history exists. */
2175
+ version: number;
2176
+ }
2177
+ /**
2178
+ * DOOR-6. A query coordinate: "related to THIS, along THAT role, in that
2179
+ * direction". Any combination, and any subset of them.
2180
+ */
2181
+ interface RelationCoordinate {
2182
+ /** The record at the other end. */
2183
+ record_id: Uuid;
2184
+ /** The field key the edge carries as its role. Omit to mean any role. */
2185
+ role?: string;
2186
+ /** Which way to walk. `out` is this record's own relation fields. */
2187
+ direction?: "out" | "in" | "either";
2188
+ }
2189
+
2190
+ /**
2191
+ * DYN-14 / DYN-15. An ordered list of merge fields ENDING IN A LITERAL, or the
2192
+ * decision to block the turn, or a named absence. No unresolved value is ever
2193
+ * rendered blank or left as a literal placeholder.
2194
+ */
2195
+ type MissingBehavior = {
2196
+ kind: "fallback";
2197
+ chain: Array<{
2198
+ merge_field_key: string;
2199
+ } | {
2200
+ literal: unknown;
2201
+ }>;
2202
+ } | {
2203
+ kind: "block_turn";
2204
+ } | {
2205
+ kind: "named_absence";
2206
+ say: string;
2207
+ };
2208
+ /** DYN-16. Applied AFTER resolution, on the merge field and never on the Field. */
2209
+ interface MergeFieldTransform {
2210
+ /** e.g. `currency`, `upper`, `date`; the organization's own list. */
2211
+ name: string;
2212
+ options?: Record<string, unknown>;
2213
+ }
2214
+ /** DYN-1. A Record of the kernel Table `Merge Field`. */
2215
+ interface MergeField {
2216
+ id: Uuid;
2217
+ organization_id: Uuid;
2218
+ key: string;
2219
+ label: string;
2220
+ /** DYN-3. Exactly one of eight. Relationships and rules are NOT sources. */
2221
+ source: MergeFieldSource;
2222
+ /** DYN-4. What it resolves INTO. The consumer never learns which. */
2223
+ semantic_type: MergeFieldSemanticType;
2224
+ /** §A. Any number. Never fused into the source. */
2225
+ modifiers: MergeFieldModifier[];
2226
+ /**
2227
+ * DYN-12. Exactly one, and it drives the input surface. It OUTRANKS the
2228
+ * precedence ladder: `server_fixed` is not offered as an input at all, and a
2229
+ * value sent for one anyway is discarded and recorded — never merged.
2230
+ */
2231
+ override_policy: OverridePolicy;
2232
+ /**
2233
+ * DYN-13. Whether an override is POSSIBLE and WHO MAY perform it are two
2234
+ * settings. This is the second one: an access level or an organization role.
2235
+ */
2236
+ override_requires: string | null;
2237
+ /** DYN-16. */
2238
+ format: MergeFieldTransform | null;
2239
+ /** DYN-17. `inline`, `on_demand`, or `auto` by budget. A value in no tier is a defect. */
2240
+ delivery?: Delivery;
2241
+ /** DYN-14. Declared, always. */
2242
+ missing?: MissingBehavior;
2243
+ /**
2244
+ * What the source needs: for `record`, the starting record and the chain; for
2245
+ * `tool`, the connection token and the freshness ceiling (DYN-20); for
2246
+ * `literal`, the literal.
2247
+ */
2248
+ source_config: Record<string, unknown>;
2249
+ created_by: Uuid | null;
2250
+ updated_by: Uuid | null;
2251
+ created_at: Timestamp;
2252
+ updated_at: Timestamp;
2253
+ version: number;
2254
+ metadata: Record<string, unknown>;
2255
+ visibility: string;
2256
+ }
2257
+ /** DYN-8. The triple the RUN gets. Every audit question is answerable from it. */
2258
+ interface ResolutionTriple {
2259
+ record_id: Uuid | null;
2260
+ field_id: Uuid | null;
2261
+ value_version: number | null;
2262
+ }
2263
+ /** DYN-22. The one provenance row per merge field per turn. */
2264
+ interface MergeFieldProvenance {
2265
+ merge_field_id: Uuid;
2266
+ declared_source: MergeFieldSource;
2267
+ /** Which source actually answered — the fallback chain makes these differ. */
2268
+ actual_source: MergeFieldSource | null;
2269
+ record_id: Uuid | null;
2270
+ field_id: Uuid | null;
2271
+ value_version: number | null;
2272
+ rule_id: Uuid | null;
2273
+ rule_version: number | null;
2274
+ /** DYN-11. Who overrode it, and every LOSER of the ladder, not only the winner. */
2275
+ override_by: Uuid | null;
2276
+ losers?: Array<{
2277
+ source: MergeFieldSource;
2278
+ value: unknown;
2279
+ why_lost: string;
2280
+ }>;
2281
+ /** DYN-11/DYN-12. A value a client sent for a field it may not supply, discarded and recorded. */
2282
+ discarded_attempt?: {
2283
+ value: unknown;
2284
+ because: string;
2285
+ } | null;
2286
+ resolved_at: Timestamp;
2287
+ freshness: Freshness;
2288
+ outcome: string;
2289
+ }
2290
+ /**
2291
+ * What a consumer gets back. `pending` is a first-class answer, not a blank:
2292
+ * until the server's resolver exists, a merge field says so and says WHY
2293
+ * (AGT-N-7 — anything that could not be delivered is named, never omitted).
2294
+ */
2295
+ type MergeFieldResolution = {
2296
+ state: "resolved";
2297
+ /** The rendered string the prompt gets. */
2298
+ rendered: string;
2299
+ value: unknown;
2300
+ triple: ResolutionTriple;
2301
+ provenance: MergeFieldProvenance;
2302
+ } | {
2303
+ state: "absent";
2304
+ /** DYN-14's named absence — what the screen says instead of a blank. */
2305
+ say: string;
2306
+ reason: string;
2307
+ provenance: MergeFieldProvenance | null;
2308
+ } | {
2309
+ state: "pending";
2310
+ /** WHY it is pending, in the words a person can act on. Never empty. */
2311
+ reason: string;
2312
+ };
2313
+
2314
+ /**
2315
+ * One of the five states, as `custom.work_states()` lists them — with what it
2316
+ * may become next and whether it is the end. A screen that hardcoded these
2317
+ * would be a second source of truth for the one question the store answers.
2318
+ */
2319
+ interface WorkState {
2320
+ sort: number;
2321
+ name: string;
2322
+ terminal: boolean;
2323
+ next: string[];
2324
+ }
2325
+ /** One node of a template graph: a record-to-be, in a named Table, under a ref. */
2326
+ interface WorkTemplateNode {
2327
+ /** The name the graph refers to this node by, and the key an override is filed under. */
2328
+ ref: string;
2329
+ /** The Table the record lands in. */
2330
+ table: Uuid;
2331
+ /** The document it starts life with. An override merges on top at instantiation. */
2332
+ data?: Record<string, unknown>;
2333
+ }
2334
+ /** One edge. `owned` is what `custom.relation_own` makes; W1-REL owns the rest. */
2335
+ interface WorkTemplateRelation {
2336
+ from: string;
2337
+ to: string;
2338
+ kind?: string;
2339
+ }
2340
+ /**
2341
+ * THE WHOLE TEMPLATE, DECLARATIVELY. REC-70: the graph is created in ONE act
2342
+ * and judged before any of it is written, so an agent writes a twelve-step
2343
+ * checklist in a single call and a half-made checklist is not a state the store
2344
+ * can be in.
2345
+ */
2346
+ interface WorkGraph {
2347
+ nodes: WorkTemplateNode[];
2348
+ relations?: WorkTemplateRelation[];
2349
+ }
2350
+ /** What `custom.work_template_instantiate` answers: what it made, and how much. */
2351
+ interface WorkInstantiation {
2352
+ template_id: Uuid;
2353
+ /** The log row. Until W3-HIST lands, this row IS the log of the act, and says so. */
2354
+ instantiation_id: Uuid;
2355
+ records_created: number;
2356
+ relations_created: number;
2357
+ relation_kind: string;
2358
+ /** ref → the record it became, which is how a step finds its own record. */
2359
+ refs: Record<string, Uuid>;
2360
+ records: Uuid[];
2361
+ relations: Uuid[];
2362
+ ms?: number;
2363
+ }
2364
+ /** One row of `custom.work_whose_turn`: a record, whose turn it is, and where it is up to. */
2365
+ interface WorkTurn {
2366
+ record_id: Uuid;
2367
+ title: string | null;
2368
+ assignee_id: Uuid | null;
2369
+ turn: string | null;
2370
+ due_on: Timestamp | null;
2371
+ state: string | null;
2372
+ status: string | null;
2373
+ terminal: boolean | null;
2374
+ }
2375
+ /** A Field assignment is made of, as the store itself describes it. */
2376
+ interface WorkAssignmentField {
2377
+ key: string;
2378
+ label: string;
2379
+ spec: Record<string, unknown>;
2380
+ }
2381
+ /**
2382
+ * One hold on one slot. `expired` is the STORE's answer, not a clock comparison
2383
+ * a screen ran: a hold whose time is up is named as lapsed rather than quietly
2384
+ * disappearing, so a person can see why the slot came back.
2385
+ */
2386
+ interface WorkSlotHold {
2387
+ hold_id: Uuid;
2388
+ slot_key: string;
2389
+ holder: string;
2390
+ expires_at: Timestamp | null;
2391
+ expired: boolean;
2392
+ }
2393
+ /**
2394
+ * What an embed token is good for, from `custom.anon_token_verify`. A token
2395
+ * carries ONE decision: `read` or `write`, never both.
2396
+ */
2397
+ interface AnonTokenBinding {
2398
+ token_id: Uuid;
2399
+ organization_id: Uuid;
2400
+ form_id: Uuid | null;
2401
+ saved_view_id: Uuid | null;
2402
+ record_id: Uuid | null;
2403
+ mode: "read" | "write";
2404
+ }
2405
+
2406
+ /**
2407
+ * VIS-31. A signed-in OUTSIDER, with the reason in plain English.
2408
+ *
2409
+ * "No organization" cannot mean "no row in the membership table": signup mints
2410
+ * every account a PERSONAL organization, so under that reading nobody would
2411
+ * ever be external. It means no membership of a NON-personal organization, and
2412
+ * `iam.is_external_principal` says that once so no surface can invent a second
2413
+ * answer.
2414
+ */
2415
+ interface ExternalPrincipalCard {
2416
+ user_id: Uuid | null;
2417
+ /** The answer itself. */
2418
+ external: boolean;
2419
+ signed_in: boolean;
2420
+ /**
2421
+ * WHY, in the platform's own words — the sentence a portal shows instead of
2422
+ * an empty screen. `iam` writes it, not us, so the portal and the API and the
2423
+ * admin screen all say the same thing about the same person.
2424
+ */
2425
+ explanation: string;
2426
+ /** How many NON-personal organizations they belong to. Zero is what external means. */
2427
+ organization_memberships: number;
2428
+ [key: string]: unknown;
2429
+ }
2430
+ /** VIS-32. A record or a view bound to a public address, with a declared render mode. */
2431
+ interface PublishBinding {
2432
+ id: Uuid;
2433
+ slug: string;
2434
+ resource_type: string;
2435
+ resource_id: Uuid;
2436
+ organization_id: Uuid;
2437
+ render_mode: string;
2438
+ is_active: boolean;
2439
+ created_at?: Timestamp;
2440
+ [key: string]: unknown;
2441
+ }
2442
+ /**
2443
+ * What a SIGNED-OUT visitor resolves. An invented address, a revoked one and an
2444
+ * unpublished one all resolve to NOTHING — the same 404 — because an address
2445
+ * that answered differently for a revoked binding would be an existence oracle.
2446
+ *
2447
+ * `notice` is D-15's admission, carried on every read: nothing was scanned
2448
+ * before this was listed, and nothing here pretends otherwise.
2449
+ */
2450
+ interface ResolvedPublishBinding {
2451
+ slug: string;
2452
+ resource_type: string;
2453
+ resource_id: Uuid;
2454
+ organization_id: Uuid;
2455
+ render_mode: string;
2456
+ namespace: string | null;
2457
+ notice: string;
2458
+ }
2459
+
2460
+ /**
2461
+ * What KIND of refusal it was. The mapping from SQLSTATE to code lives in
2462
+ * `/core`, and it is checked against `STORE_REFUSAL_CODES` — the list of every
2463
+ * SQLSTATE the store's own bodies raise, generated from the live catalogue. A
2464
+ * code the store can raise and this union cannot name is a hole, and the
2465
+ * real-door suite fails on it.
2466
+ */
2467
+ type RecordsErrorCode =
2468
+ /** `PT409` — somebody else's write won. The record clock moved under you. */
2469
+ "stale_write"
2470
+ /** `42501` — a door. Either the schema is revoked, or the store is switched off, or this principal may not pass. */
2471
+ | "door"
2472
+ /** `23514` — a Rule, a shape guard, or a validation the store enforces refused it. */
2473
+ | "refused_by_rule"
2474
+ /** `22004` / `22023` — the call itself was malformed: a missing id, a patch that is not an object. */
2475
+ | "invalid_argument"
2476
+ /** `02000` — the record is not here (deleted, never existed, or another organization's). */
2477
+ | "not_found"
2478
+ /** `23503` — something it points at is not there. */
2479
+ | "missing_reference"
2480
+ /** `23505` — that thing is already here. */
2481
+ | "already_exists"
2482
+ /** `0A000` — the store does not do this yet, and says which part. */
2483
+ | "not_supported"
2484
+ /** `53400` / `22012` — the store ran out of something, or the arithmetic could not be done. */
2485
+ | "store_limit"
2486
+ /**
2487
+ * `40001` — the visibility snapshot this connection carries is older than a
2488
+ * write the reader has already observed, so the store refused to answer at
2489
+ * all rather than hand back something they just lost. Retry on a fresh
2490
+ * connection; it is the one refusal in this list that is worth repeating.
2491
+ */
2492
+ | "stale_read"
2493
+ /**
2494
+ * THE DOOR THAT DOES NOT EXIST YET. Not an error condition in the database —
2495
+ * this package asked for a door that is not in the live catalogue, so it
2496
+ * refused to guess. `door_absent` always names the door and the lane that
2497
+ * owns it; it is never a silent no-op and never an empty list.
2498
+ */
2499
+ | "door_absent"
2500
+ /**
2501
+ * `PGRST202` / `PGRST205` — PostgREST could not find the function or the
2502
+ * schema. The database this client is pointed at is not serving the record
2503
+ * store: the schema is not exposed, or the grants are not there.
2504
+ */
2505
+ | "store_not_served"
2506
+ /** Anything the mapper could not place. It still carries the store's own words. */
2507
+ | "internal";
2508
+ /** A refusal, in the store's own words. */
2509
+ interface RecordsError {
2510
+ code: RecordsErrorCode;
2511
+ /** THE STORE'S message, verbatim. Never paraphrased. */
2512
+ message: string;
2513
+ /** THE STORE'S hint, verbatim — this is where the remedy is written. */
2514
+ hint?: string;
2515
+ /** The SQLSTATE, so a caller can be exact when a code is not exact enough. */
2516
+ sqlstate?: string;
2517
+ /** Whatever the store put in DETAIL, parsed when it was json. */
2518
+ detail?: unknown;
2519
+ }
2520
+ type RecordsResult<T> = {
2521
+ ok: true;
2522
+ data: T;
2523
+ } | {
2524
+ ok: false;
2525
+ error: RecordsError;
2526
+ };
2527
+ /** Narrowing helper for hosts compiled without `strictNullChecks`. */
2528
+ declare function isRecordsErr<T>(result: RecordsResult<T>): result is {
2529
+ ok: false;
2530
+ error: RecordsError;
2531
+ };
2532
+ declare const ok: <T>(data: T) => RecordsResult<T>;
2533
+ declare const err: <T>(error: RecordsError) => RecordsResult<T>;
2534
+ /**
2535
+ * A `stale_write` carries everything the screen needs to show the conflict
2536
+ * rather than a toast: which version you wrote against, which one won, and the
2537
+ * value of every field you touched as it stands now. The store builds this and
2538
+ * this type is its shape — nothing is reconstructed on the client.
2539
+ */
2540
+ interface StaleWriteDetail {
2541
+ expected_version: number;
2542
+ current_version: number;
2543
+ contested_fields: Record<string, unknown>;
2544
+ }
2545
+ /** The parsed form of a `stale_write`, for `useRecordMutation`'s conflict state. */
2546
+ interface WriteConflict extends StaleWriteDetail {
2547
+ record_id: Uuid;
2548
+ /** The store's own sentence — what the screen shows. */
2549
+ message: string;
2550
+ /** The store's own remedy. */
2551
+ hint: string;
2552
+ }
2553
+ /**
2554
+ * The structural shape of a PostgREST failure as supabase-js resolves it: a
2555
+ * PLAIN OBJECT parsed from the response body, NOT an `Error`. Reading
2556
+ * `.message` off `instanceof Error` discards the real database message on every
2557
+ * genuine failure.
2558
+ */
2559
+ interface PgError {
2560
+ code?: string | null;
2561
+ message: string;
2562
+ details?: string | null;
2563
+ hint?: string | null;
2564
+ }
2565
+ /** What the validation mirror answers: the same sentence the trigger would raise. */
2566
+ interface PredictedRefusal {
2567
+ /** The field key the store would name, when it names one. */
2568
+ field_key?: string;
2569
+ /** The message the store's own body would raise, word for word. */
2570
+ message: string;
2571
+ hint?: string;
2572
+ sqlstate: string;
2573
+ /**
2574
+ * Which of the store's bodies would raise it, so a reader can go and check
2575
+ * that this mirror still tells the truth.
2576
+ */
2577
+ predicted_by: string;
2578
+ }
2579
+ /** VAL-5 / VAL-6, named so a caller can say which word was the problem. */
2580
+ interface ForbiddenEnvelopeWord {
2581
+ field_key: string;
2582
+ word: PerValueAccessWord;
2583
+ }
2584
+
2585
+ /**
2586
+ * The data seam: a structural subset of `SupabaseClient`. The package never
2587
+ * opens a database connection of its own and never holds a key — the HOST
2588
+ * supplies a client that already carries the operating person's session, which
2589
+ * is what makes DOOR-5 and AGT-N-4 true (the store sees the person, not us).
2590
+ */
2591
+ interface RecordsDataSource {
2592
+ /**
2593
+ * Call a door. The name is always a door the live catalogue has; `/core`
2594
+ * refuses `door_absent` before it ever reaches here for one that does not.
2595
+ */
2596
+ rpc(fn: string, args: Record<string, unknown>,
2597
+ /**
2598
+ * THE SCHEMA THE DOOR LIVES IN, always supplied: `custom` for the store's
2599
+ * own doors, `iam` for the trust doors (the external principal and the
2600
+ * publish binding, which are the PLATFORM's). A host binding supabase-js
2601
+ * routes this to `client.schema(options.schema).rpc(fn, args)`; a host that
2602
+ * ignores it calls its own default PostgREST profile — `public` — and is
2603
+ * refused by name, which is the failure we want rather than a silent answer
2604
+ * from the wrong system. (Before 2026-09-18 this was described as "only ever
2605
+ * `iam`" and the store's doors went unqualified; the extension's first real
2606
+ * turn proved that asks `public.store_is_open` and finds nothing.)
2607
+ */
2608
+ options?: {
2609
+ schema?: string;
2610
+ }): PromiseLike<{
2611
+ data: unknown;
2612
+ error: PgError | null;
2613
+ }>;
2614
+ /** Reads of `custom.*` go through the schema-qualified builder, never a bare `from`. */
2615
+ schema(name: string): {
2616
+ from(table: string): RecordsTableQuery;
2617
+ };
2618
+ }
2619
+ /** The read surface the list and query paths use. A real supabase-js client satisfies it. */
2620
+ interface RecordsTableQuery {
2621
+ select(columns: string, options?: {
2622
+ count?: "exact" | "planned" | "estimated";
2623
+ head?: boolean;
2624
+ }): RecordsFilter;
2625
+ }
2626
+ interface RecordsFilter extends PromiseLike<RecordsResponse> {
2627
+ eq(column: string, value: unknown): RecordsFilter;
2628
+ neq(column: string, value: unknown): RecordsFilter;
2629
+ in(column: string, values: readonly unknown[]): RecordsFilter;
2630
+ is(column: string, value: null | boolean): RecordsFilter;
2631
+ gte(column: string, value: unknown): RecordsFilter;
2632
+ lte(column: string, value: unknown): RecordsFilter;
2633
+ order(column: string, options?: {
2634
+ ascending?: boolean;
2635
+ }): RecordsFilter;
2636
+ range(from: number, to: number): RecordsFilter;
2637
+ limit(count: number): RecordsFilter;
2638
+ }
2639
+ interface RecordsResponse {
2640
+ data: unknown;
2641
+ error: PgError | null;
2642
+ count?: number | null;
2643
+ }
2644
+ /**
2645
+ * WHO IS ACTING. AGT-N-4: an agent carries the exact authority of the person
2646
+ * operating it — there is no agent identity and there are no service roles. So
2647
+ * the actor word and the person are two separate facts, and `on_behalf_of` is
2648
+ * meaningful only when the actor is `agent`.
2649
+ */
2650
+ interface RecordsActor {
2651
+ actor: Actor;
2652
+ /** The signed-in person. The store reads this from the session, not from us; this is for the client's own mirror. */
2653
+ user_id?: Uuid;
2654
+ /** Only an agent acts on behalf of a person (the store refuses it otherwise). */
2655
+ on_behalf_of?: Uuid;
2656
+ }
2657
+ /**
2658
+ * OPTIONAL. A live-updates seam. The default degradation is stated rather than
2659
+ * silent: with no port bound, `useRecords` reports `live: false` and the screen
2660
+ * can say "not live" instead of quietly going stale.
2661
+ *
2662
+ * A host binds this with `@ai-matrx/data/react`'s channel hygiene — the package
2663
+ * deliberately does NOT depend on it, so the headless core stays free of a
2664
+ * realtime client and a host that has one keeps using the one it already has.
2665
+ */
2666
+ interface RecordsRealtimePort {
2667
+ /**
2668
+ * Watch one organization's records of one table. Returns an unsubscribe. The
2669
+ * callback fires with the record id that changed; the hook re-reads through
2670
+ * the read door, because a realtime payload has NOT passed the door.
2671
+ */
2672
+ subscribeRecords(args: {
2673
+ organization_id: Uuid;
2674
+ table_id: Uuid;
2675
+ }, onChange: (recordId: Uuid) => void): () => void;
2676
+ }
2677
+ /**
2678
+ * OPTIONAL. Where a refusal that nobody asked about goes — the loud funnel.
2679
+ * Default degradation: `console.error` with the store's own words, never
2680
+ * silence.
2681
+ */
2682
+ type RecordsErrorSink = (error: {
2683
+ code: string;
2684
+ message: string;
2685
+ hint?: string;
2686
+ where: string;
2687
+ }) => void;
2688
+ /**
2689
+ * OPTIONAL. The merge-field resolver's server half (`W5-MERGE-B`). While it is
2690
+ * not bound, `useMergeField` answers `pending` WITH THE REASON — never a blank,
2691
+ * never a literal placeholder left in the text (DYN-14).
2692
+ */
2693
+ interface RecordsResolverPort {
2694
+ resolve(args: {
2695
+ organization_id: Uuid;
2696
+ merge_field_keys: string[];
2697
+ /** The live selection the `state` source reads (DYNAMIC-VALUES §C). */
2698
+ state?: Record<string, unknown>;
2699
+ }): Promise<unknown>;
2700
+ }
2701
+ /** The one config a host binds. */
2702
+ interface RecordsConfig {
2703
+ /** REQUIRED. */
2704
+ dataSource: RecordsDataSource;
2705
+ /** REQUIRED. */
2706
+ actor: RecordsActor;
2707
+ /**
2708
+ * REQUIRED. REC-29: organizations are hard walls, and the store is keyed
2709
+ * `(organization_id, id)`. There is no "current organization" this package
2710
+ * discovers for itself — the host says which one, every time.
2711
+ */
2712
+ organizationId: Uuid;
2713
+ realtime?: RecordsRealtimePort;
2714
+ onError?: RecordsErrorSink;
2715
+ resolver?: RecordsResolverPort;
2716
+ /**
2717
+ * The schema the record store lives in. Exists so a rehearsal branch and
2718
+ * production can differ without a fork; it is `custom` everywhere today.
2719
+ */
2720
+ schema?: string;
2721
+ }
2722
+
2723
+ 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 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, 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, 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 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 };