@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,3238 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare const ACTOR_VOCABULARY: readonly ["user", "agent", "system"];
5
+ /** The three words the store still accepts and rewrites, and what each becomes. */
6
+ declare const RETIRED_ACTOR_WORDS: {
7
+ readonly ai: "agent";
8
+ readonly code: "system";
9
+ readonly human: "user";
10
+ };
11
+ declare const ABSENCE_REASONS: readonly ["never asked", "none", "refused", "conflicting"];
12
+ declare const VALUE_ENVELOPE_KEYS: readonly ["ver", "src", "actor", "on_behalf_of", "at", "absent", "alternates", "dated"];
13
+ declare const VALUE_ALTERNATE_KEYS: readonly ["value", "src", "rank"];
14
+ declare const STORAGE_MODES: readonly ["light", "heavy"];
15
+ declare const RULE_USES: readonly ["validate", "compute", "membership", "applicability"];
16
+ declare const PER_VALUE_ACCESS_WORDS: readonly ["visibility", "access", "share", "acl", "permission", "permissions", "secret"];
17
+ /** FLD-11's parity floor, each with the behaviour it is MADE OF (FLD-1). */
18
+ declare const PARITY_FIELD_TYPES: readonly [{
19
+ readonly parity_type: "attachment";
20
+ readonly behavior: "relation";
21
+ readonly made_of: "REC-31: a File record reached through a relation, target the kernel `File` Table";
22
+ }, {
23
+ readonly parity_type: "currency";
24
+ readonly behavior: "range";
25
+ readonly made_of: "FLD-N-1: a number whose UNIT is the currency and whose format is currency — on the Field, never in presentation";
26
+ }, {
27
+ readonly parity_type: "datetime";
28
+ readonly behavior: "range";
29
+ readonly made_of: "a range of kind date or datetime — the dated modifier says the VALUES are dated, which is a different question";
30
+ }, {
31
+ readonly parity_type: "email";
32
+ readonly behavior: "text";
33
+ readonly made_of: "text whose format is email";
34
+ }, {
35
+ readonly parity_type: "formula";
36
+ readonly behavior: "formula";
37
+ readonly made_of: "FLD-9: a declared computation, on read or on write, evaluated by custom.rule_eval";
38
+ }, {
39
+ readonly parity_type: "lookup";
40
+ readonly behavior: "formula";
41
+ readonly made_of: "a Value read THROUGH a relation — config.via names the relation field, config.pick the Value on the far side";
42
+ }, {
43
+ readonly parity_type: "member";
44
+ readonly behavior: "relation";
45
+ readonly made_of: "a person: a relation whose target is the kernel `Person` Table";
46
+ }, {
47
+ readonly parity_type: "multi_select";
48
+ readonly behavior: "list";
49
+ readonly made_of: "many choices from the same Table — the multi modifier, never a second behaviour";
50
+ }, {
51
+ readonly parity_type: "percent";
52
+ readonly behavior: "range";
53
+ readonly made_of: "a number whose unit is % and whose format is percent";
54
+ }, {
55
+ readonly parity_type: "phone";
56
+ readonly behavior: "text";
57
+ readonly made_of: "text whose format is phone";
58
+ }, {
59
+ readonly parity_type: "rollup";
60
+ readonly behavior: "formula";
61
+ 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";
62
+ }, {
63
+ readonly parity_type: "select";
64
+ readonly behavior: "list";
65
+ readonly made_of: "one choice from a Table shown as a list (FLD-5/FLD-6)";
66
+ }, {
67
+ readonly parity_type: "url";
68
+ readonly behavior: "text";
69
+ readonly made_of: "text whose format is url, with the pattern Rule that makes the format enforceable";
70
+ }];
71
+ /** The node kinds `custom.rule_eval` evaluates, and the lane that owns each. */
72
+ declare const RULE_NODE_KINDS: readonly [{
73
+ readonly node: "add";
74
+ readonly evaluated_by: "W1-RULE";
75
+ }, {
76
+ readonly node: "and";
77
+ readonly evaluated_by: "W1-RULE";
78
+ }, {
79
+ readonly node: "concat";
80
+ readonly evaluated_by: "W1-RULE";
81
+ }, {
82
+ readonly node: "const";
83
+ readonly evaluated_by: "W1-RULE";
84
+ }, {
85
+ readonly node: "div";
86
+ readonly evaluated_by: "W1-RULE";
87
+ }, {
88
+ readonly node: "eq";
89
+ readonly evaluated_by: "W1-RULE";
90
+ }, {
91
+ readonly node: "field";
92
+ readonly evaluated_by: "W1-RULE";
93
+ }, {
94
+ readonly node: "gt";
95
+ readonly evaluated_by: "W1-RULE";
96
+ }, {
97
+ readonly node: "gte";
98
+ readonly evaluated_by: "W1-RULE";
99
+ }, {
100
+ readonly node: "length";
101
+ readonly evaluated_by: "W1-RULE";
102
+ }, {
103
+ readonly node: "lt";
104
+ readonly evaluated_by: "W1-RULE";
105
+ }, {
106
+ readonly node: "lte";
107
+ readonly evaluated_by: "W1-RULE";
108
+ }, {
109
+ readonly node: "matches";
110
+ readonly evaluated_by: "W1-RULE";
111
+ }, {
112
+ readonly node: "merge_field";
113
+ readonly evaluated_by: "W5-MERGE-B";
114
+ }, {
115
+ readonly node: "mul";
116
+ readonly evaluated_by: "W1-RULE";
117
+ }, {
118
+ readonly node: "ne";
119
+ readonly evaluated_by: "W1-RULE";
120
+ }, {
121
+ readonly node: "not";
122
+ readonly evaluated_by: "W1-RULE";
123
+ }, {
124
+ readonly node: "or";
125
+ readonly evaluated_by: "W1-RULE";
126
+ }, {
127
+ readonly node: "parent_field";
128
+ readonly evaluated_by: "W1-RULE-APPLY";
129
+ }, {
130
+ readonly node: "present";
131
+ readonly evaluated_by: "W1-RULE";
132
+ }, {
133
+ readonly node: "sub";
134
+ readonly evaluated_by: "W1-RULE";
135
+ }];
136
+ /** REC-27. The kernel, by name and by id, as the store holds it. */
137
+ declare const KERNEL_TABLES: readonly [{
138
+ readonly id: "11111111-0000-4000-8000-000000000002";
139
+ readonly name: "Field";
140
+ }, {
141
+ readonly id: "11111111-0000-4000-8000-000000000006";
142
+ readonly name: "File";
143
+ }, {
144
+ readonly id: "11111111-0000-4000-8000-000000000009";
145
+ readonly name: "Merge Field";
146
+ }, {
147
+ readonly id: "11111111-0000-4000-8000-000000000004";
148
+ readonly name: "Organization";
149
+ }, {
150
+ readonly id: "11111111-0000-4000-8000-000000000005";
151
+ readonly name: "Person";
152
+ }, {
153
+ readonly id: "11111111-0000-4000-8000-000000000007";
154
+ readonly name: "Presentation";
155
+ }, {
156
+ readonly id: "11111111-0000-4000-8000-000000000003";
157
+ readonly name: "Rule";
158
+ }, {
159
+ readonly id: "11111111-0000-4000-8000-000000000001";
160
+ readonly name: "Table";
161
+ }, {
162
+ readonly id: "11111111-0000-4000-8000-000000000008";
163
+ readonly name: "Widget";
164
+ }];
165
+ /**
166
+ * Every door the store actually has, with the argument list and the result the
167
+ * catalogue reports. A client call whose door is not in this list is answered
168
+ * `door_absent` by name — never a guess, never a silent no-op.
169
+ */
170
+ declare const STORE_DOORS: readonly [{
171
+ readonly name: "absence_reasons";
172
+ readonly args: "";
173
+ readonly returns: "text[]";
174
+ readonly security: "invoker";
175
+ }, {
176
+ readonly name: "actor_vocabulary";
177
+ readonly args: "";
178
+ readonly returns: "text[]";
179
+ readonly security: "invoker";
180
+ }, {
181
+ readonly name: "actor_word";
182
+ readonly args: "p_declared text";
183
+ readonly returns: "text";
184
+ readonly security: "invoker";
185
+ }, {
186
+ readonly name: "agent_context";
187
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 50";
188
+ readonly returns: "jsonb";
189
+ readonly security: "invoker";
190
+ }, {
191
+ readonly name: "agg_assert_key";
192
+ readonly args: "p_key text";
193
+ readonly returns: "text";
194
+ readonly security: "invoker";
195
+ }, {
196
+ readonly name: "agg_buckets";
197
+ readonly args: "";
198
+ readonly returns: "text[]";
199
+ readonly security: "invoker";
200
+ }, {
201
+ readonly name: "agg_deliver";
202
+ 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";
203
+ readonly returns: "uuid";
204
+ readonly security: "invoker";
205
+ }, {
206
+ readonly name: "agg_digest_run";
207
+ 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";
208
+ readonly returns: "integer";
209
+ readonly security: "invoker";
210
+ }, {
211
+ readonly name: "agg_explain";
212
+ 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";
213
+ readonly returns: "jsonb";
214
+ readonly security: "invoker";
215
+ }, {
216
+ readonly name: "agg_operations";
217
+ readonly args: "";
218
+ readonly returns: "text[]";
219
+ readonly security: "invoker";
220
+ }, {
221
+ readonly name: "agg_sql";
222
+ 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";
223
+ readonly returns: "text";
224
+ readonly security: "invoker";
225
+ }, {
226
+ readonly name: "agg_subscription_cadences";
227
+ readonly args: "";
228
+ readonly returns: "text[]";
229
+ readonly security: "invoker";
230
+ }, {
231
+ readonly name: "agg_subscription_fire";
232
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_changed_field_ids jsonb DEFAULT '[]'::jsonb";
233
+ readonly returns: "integer";
234
+ readonly security: "invoker";
235
+ }, {
236
+ readonly name: "agg_subscriptions";
237
+ readonly args: "p_organization_id uuid, p_saved_view_id uuid DEFAULT NULL::uuid, p_cadence text DEFAULT NULL::text";
238
+ 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)";
239
+ readonly security: "invoker";
240
+ }, {
241
+ readonly name: "agg_value_sql";
242
+ readonly args: "p_key text";
243
+ readonly returns: "text";
244
+ readonly security: "invoker";
245
+ }, {
246
+ readonly name: "agg_view_admits";
247
+ readonly args: "p_organization_id uuid, p_saved_view_id uuid, p_record_id uuid";
248
+ readonly returns: "boolean";
249
+ readonly security: "invoker";
250
+ }, {
251
+ readonly name: "anon_capture";
252
+ 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";
253
+ readonly returns: "uuid";
254
+ readonly security: "definer";
255
+ }, {
256
+ readonly name: "anon_clear";
257
+ readonly args: "p_organization_id uuid, p_submission_id uuid";
258
+ readonly returns: "uuid";
259
+ readonly security: "definer";
260
+ }, {
261
+ readonly name: "anon_inbound_land";
262
+ readonly args: "p_address text, p_secret text, p_payload jsonb, p_raw_payload jsonb DEFAULT '{}'::jsonb, p_client_key text DEFAULT NULL::text";
263
+ readonly returns: "uuid";
264
+ readonly security: "definer";
265
+ }, {
266
+ readonly name: "anon_publish";
267
+ readonly args: "p_organization_id uuid, p_form_id uuid, p_published boolean DEFAULT true";
268
+ readonly returns: "timestamp with time zone";
269
+ readonly security: "definer";
270
+ }, {
271
+ readonly name: "anon_rate_take";
272
+ readonly args: "p_organization_id uuid, p_form_id uuid, p_bucket text, p_token_id uuid DEFAULT NULL::uuid";
273
+ readonly returns: "integer";
274
+ readonly security: "definer";
275
+ }, {
276
+ readonly name: "anon_token_issue";
277
+ 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";
278
+ readonly returns: "TABLE(token_id uuid, secret text)";
279
+ readonly security: "definer";
280
+ }, {
281
+ readonly name: "anon_token_revoke";
282
+ readonly args: "p_organization_id uuid, p_token_id uuid";
283
+ readonly returns: "boolean";
284
+ readonly security: "definer";
285
+ }, {
286
+ readonly name: "anon_token_verify";
287
+ readonly args: "p_secret text, p_origin text, p_required_mode text";
288
+ readonly returns: "TABLE(token_id uuid, organization_id uuid, form_id uuid, saved_view_id uuid, record_id uuid, mode text)";
289
+ readonly security: "definer";
290
+ }, {
291
+ readonly name: "anon_write";
292
+ readonly args: "p_secret text, p_origin text, p_payload jsonb, p_client_key text DEFAULT NULL::text, p_raw_payload jsonb DEFAULT '{}'::jsonb";
293
+ readonly returns: "uuid";
294
+ readonly security: "definer";
295
+ }, {
296
+ readonly name: "applicable_fields";
297
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_record_type text DEFAULT NULL::text";
298
+ readonly returns: "SETOF custom.record";
299
+ readonly security: "definer";
300
+ }, {
301
+ readonly name: "assert_client_may_reach";
302
+ readonly args: "p_organization_id uuid, p_door text";
303
+ readonly returns: "void";
304
+ readonly security: "invoker";
305
+ }, {
306
+ readonly name: "assert_organization_wall";
307
+ readonly args: "p_kind text, p_organization_id uuid, p_row jsonb";
308
+ readonly returns: "void";
309
+ readonly security: "invoker";
310
+ }, {
311
+ readonly name: "assert_store_door";
312
+ readonly args: "p_organization_id uuid, p_door text";
313
+ readonly returns: "void";
314
+ readonly security: "invoker";
315
+ }, {
316
+ readonly name: "bump_epoch";
317
+ readonly args: "p_entity_type text, p_entity_id uuid, p_organization_id uuid DEFAULT NULL::uuid";
318
+ readonly returns: "bigint";
319
+ readonly security: "definer";
320
+ }, {
321
+ readonly name: "cache_lookup";
322
+ readonly args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid";
323
+ readonly returns: "permission_level";
324
+ readonly security: "definer";
325
+ }, {
326
+ readonly name: "caller_role";
327
+ readonly args: "";
328
+ readonly returns: "name";
329
+ readonly security: "invoker";
330
+ }, {
331
+ readonly name: "client_write_grants";
332
+ readonly args: "";
333
+ readonly returns: "TABLE(role_name text, object_name text, privilege text)";
334
+ readonly security: "invoker";
335
+ }, {
336
+ readonly name: "computed_provenance";
337
+ readonly args: "p_organization_id uuid, p_record_id uuid";
338
+ readonly returns: "TABLE(field_key text, field_id uuid, value jsonb, rule_id uuid, rule_version integer, computed_at timestamp with time zone)";
339
+ readonly security: "invoker";
340
+ }, {
341
+ readonly name: "containment_chain";
342
+ readonly args: "p_organization_id uuid, p_record_id uuid";
343
+ readonly returns: "TABLE(ancestor_id uuid, depth integer)";
344
+ readonly security: "invoker";
345
+ }, {
346
+ readonly name: "containment_depth_ceiling";
347
+ readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
348
+ readonly returns: "integer";
349
+ readonly security: "invoker";
350
+ }, {
351
+ readonly name: "containment_edges";
352
+ readonly args: "p_organization_id uuid";
353
+ readonly returns: "TABLE(parent_id uuid, child_id uuid, via text)";
354
+ readonly security: "invoker";
355
+ }, {
356
+ readonly name: "containment_parent";
357
+ readonly args: "p_data jsonb";
358
+ readonly returns: "uuid";
359
+ readonly security: "invoker";
360
+ }, {
361
+ readonly name: "custom_fields_tables";
362
+ readonly args: "";
363
+ readonly returns: "TABLE(token text, schema_name text, table_name text)";
364
+ readonly security: "invoker";
365
+ }, {
366
+ readonly name: "dependency_cycle";
367
+ readonly args: "p_organization_id uuid, p_row custom.record";
368
+ readonly returns: "text[]";
369
+ readonly security: "invoker";
370
+ }, {
371
+ readonly name: "dependency_label";
372
+ readonly args: "p_organization_id uuid, p_node text";
373
+ readonly returns: "text";
374
+ readonly security: "invoker";
375
+ }, {
376
+ readonly name: "derive_visibility";
377
+ readonly args: "p_container_type text, p_container_id uuid";
378
+ readonly returns: "TABLE(item_type text, item_id uuid, depth integer, max_level permission_level)";
379
+ readonly security: "definer";
380
+ }, {
381
+ readonly name: "derived_value";
382
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb";
383
+ readonly returns: "jsonb";
384
+ readonly security: "invoker";
385
+ }, {
386
+ readonly name: "derived_values";
387
+ readonly args: "p_organization_id uuid, p_record_id uuid";
388
+ readonly returns: "jsonb";
389
+ readonly security: "invoker";
390
+ }, {
391
+ readonly name: "doc_content_hash";
392
+ readonly args: "p_body text";
393
+ readonly returns: "text";
394
+ readonly security: "invoker";
395
+ }, {
396
+ readonly name: "doc_format_value";
397
+ readonly args: "p_field_data jsonb, p_value jsonb";
398
+ readonly returns: "text";
399
+ readonly security: "invoker";
400
+ }, {
401
+ readonly name: "doc_render_body";
402
+ readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid";
403
+ readonly returns: "text";
404
+ readonly security: "invoker";
405
+ }, {
406
+ readonly name: "doc_render_document";
407
+ readonly args: "p_organization_id uuid, p_template_id uuid, p_record_id uuid";
408
+ readonly returns: "uuid";
409
+ readonly security: "definer";
410
+ }, {
411
+ readonly name: "doc_render_write";
412
+ 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";
413
+ readonly returns: "uuid";
414
+ readonly security: "definer";
415
+ }, {
416
+ readonly name: "doc_sign";
417
+ 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";
418
+ readonly returns: "uuid";
419
+ readonly security: "definer";
420
+ }, {
421
+ readonly name: "doc_signature_field_ok";
422
+ readonly args: "p_field_data jsonb";
423
+ readonly returns: "boolean";
424
+ readonly security: "invoker";
425
+ }, {
426
+ readonly name: "doc_signature_intact";
427
+ readonly args: "p_organization_id uuid, p_signature_id uuid";
428
+ readonly returns: "jsonb";
429
+ readonly security: "invoker";
430
+ }, {
431
+ readonly name: "doc_signature_write";
432
+ 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";
433
+ readonly returns: "uuid";
434
+ readonly security: "definer";
435
+ }, {
436
+ readonly name: "doc_template_save";
437
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_name text, p_body text, p_template_id uuid DEFAULT NULL::uuid";
438
+ readonly returns: "uuid";
439
+ readonly security: "definer";
440
+ }, {
441
+ readonly name: "doc_token_pattern";
442
+ readonly args: "";
443
+ readonly returns: "text";
444
+ readonly security: "invoker";
445
+ }, {
446
+ readonly name: "doc_tokens";
447
+ readonly args: "p_body text";
448
+ readonly returns: "TABLE(ordinal integer, raw text, field_id uuid)";
449
+ readonly security: "invoker";
450
+ }, {
451
+ readonly name: "doc_unresolved_tokens";
452
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_body text";
453
+ readonly returns: "TABLE(raw text, field_id uuid, why text)";
454
+ readonly security: "invoker";
455
+ }, {
456
+ readonly name: "export_records";
457
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000";
458
+ readonly returns: "TABLE(id uuid, document jsonb)";
459
+ readonly security: "invoker";
460
+ }, {
461
+ readonly name: "external_foreign_table_findings";
462
+ readonly args: "";
463
+ readonly returns: "SETOF text";
464
+ readonly security: "definer";
465
+ }, {
466
+ readonly name: "external_history_event";
467
+ readonly args: "p_organization_id uuid, p_link_id uuid, p_operation text";
468
+ readonly returns: "bigint";
469
+ readonly security: "definer";
470
+ }, {
471
+ readonly name: "external_rows";
472
+ readonly args: "p_organization_id uuid, p_source_id uuid";
473
+ readonly returns: "SETOF jsonb";
474
+ readonly security: "definer";
475
+ }, {
476
+ readonly name: "external_source_declare";
477
+ 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";
478
+ readonly returns: "uuid";
479
+ readonly security: "definer";
480
+ }, {
481
+ readonly name: "external_stub_upsert";
482
+ 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";
483
+ readonly returns: "uuid";
484
+ readonly security: "definer";
485
+ }, {
486
+ readonly name: "external_tier_contract";
487
+ readonly args: "";
488
+ readonly returns: "jsonb";
489
+ readonly security: "definer";
490
+ }, {
491
+ readonly name: "external_write_through";
492
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb";
493
+ readonly returns: "void";
494
+ readonly security: "definer";
495
+ }, {
496
+ readonly name: "external_writes_set";
497
+ readonly args: "p_organization_id uuid, p_source_id uuid, p_enabled boolean";
498
+ readonly returns: "boolean";
499
+ readonly security: "definer";
500
+ }, {
501
+ readonly name: "field_dependants";
502
+ readonly args: "p_organization_id uuid, p_field_id uuid";
503
+ readonly returns: "TABLE(kind text, dependant_id uuid, label text, how text)";
504
+ readonly security: "invoker";
505
+ }, {
506
+ readonly name: "field_kernel_id";
507
+ readonly args: "";
508
+ readonly returns: "uuid";
509
+ readonly security: "invoker";
510
+ }, {
511
+ readonly name: "field_options";
512
+ readonly args: "p_organization_id uuid, p_field_id uuid";
513
+ readonly returns: "SETOF custom.record";
514
+ readonly security: "invoker";
515
+ }, {
516
+ readonly name: "field_rules";
517
+ readonly args: "p_field_data jsonb";
518
+ readonly returns: "TABLE(kind text, spec jsonb)";
519
+ readonly security: "invoker";
520
+ }, {
521
+ readonly name: "file_kernel_id";
522
+ readonly args: "";
523
+ readonly returns: "uuid";
524
+ readonly security: "invoker";
525
+ }, {
526
+ readonly name: "formula_value";
527
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb";
528
+ readonly returns: "jsonb";
529
+ readonly security: "invoker";
530
+ }, {
531
+ readonly name: "has_visibility";
532
+ readonly args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
533
+ readonly returns: "boolean";
534
+ readonly security: "definer";
535
+ }, {
536
+ readonly name: "has_visibility_at";
537
+ 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";
538
+ readonly returns: "boolean";
539
+ readonly security: "definer";
540
+ }, {
541
+ readonly name: "hidden_field_notice";
542
+ readonly args: "p_field custom.record, p_action text DEFAULT 'read'::text";
543
+ readonly returns: "jsonb";
544
+ readonly security: "invoker";
545
+ }, {
546
+ readonly name: "home_add";
547
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_home_record_id uuid";
548
+ readonly returns: "uuid";
549
+ readonly security: "invoker";
550
+ }, {
551
+ readonly name: "home_relations";
552
+ readonly args: "";
553
+ readonly returns: "TABLE(table_id uuid, home_record_id uuid, organization_id uuid, relation_id uuid)";
554
+ readonly security: "invoker";
555
+ }, {
556
+ readonly name: "index_payload";
557
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000";
558
+ readonly returns: "TABLE(id uuid, searchable text)";
559
+ readonly security: "invoker";
560
+ }, {
561
+ readonly name: "intern_provenance";
562
+ readonly args: "p_data jsonb";
563
+ readonly returns: "jsonb";
564
+ readonly security: "invoker";
565
+ }, {
566
+ readonly name: "io_changed_field_ids";
567
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_old jsonb, p_new jsonb";
568
+ readonly returns: "jsonb";
569
+ readonly security: "invoker";
570
+ }, {
571
+ readonly name: "io_changed_keys";
572
+ readonly args: "p_old jsonb, p_new jsonb";
573
+ readonly returns: "text[]";
574
+ readonly security: "invoker";
575
+ }, {
576
+ readonly name: "io_comment_resolve";
577
+ readonly args: "p_organization_id uuid, p_comment_id uuid, p_resolved boolean DEFAULT true";
578
+ readonly returns: "boolean";
579
+ readonly security: "definer";
580
+ }, {
581
+ readonly name: "io_comment_write";
582
+ 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";
583
+ readonly returns: "uuid";
584
+ readonly security: "definer";
585
+ }, {
586
+ readonly name: "io_comments";
587
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_include_resolved boolean DEFAULT false";
588
+ 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)";
589
+ readonly security: "definer";
590
+ }, {
591
+ readonly name: "io_csv_escape";
592
+ readonly args: "p_value text, p_delimiter text DEFAULT ','::text";
593
+ readonly returns: "text";
594
+ readonly security: "invoker";
595
+ }, {
596
+ readonly name: "io_csv_parse";
597
+ readonly args: "p_text text, p_delimiter text DEFAULT NULL::text";
598
+ readonly returns: "TABLE(row_number integer, cells text[])";
599
+ readonly security: "invoker";
600
+ }, {
601
+ readonly name: "io_export";
602
+ 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";
603
+ readonly returns: "jsonb";
604
+ readonly security: "definer";
605
+ }, {
606
+ readonly name: "io_export_csv";
607
+ 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";
608
+ readonly returns: "text";
609
+ readonly security: "definer";
610
+ }, {
611
+ readonly name: "io_import_open";
612
+ 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";
613
+ readonly returns: "uuid";
614
+ readonly security: "definer";
615
+ }, {
616
+ readonly name: "io_import_rows";
617
+ readonly args: "p_organization_id uuid, p_import_id uuid, p_rows jsonb, p_mapping jsonb DEFAULT '{}'::jsonb";
618
+ readonly returns: "jsonb";
619
+ readonly security: "definer";
620
+ }, {
621
+ readonly name: "io_infer_type";
622
+ readonly args: "p_samples jsonb";
623
+ readonly returns: "text";
624
+ readonly security: "invoker";
625
+ }, {
626
+ readonly name: "io_outbox_announce";
627
+ readonly args: "";
628
+ readonly returns: "trigger";
629
+ readonly security: "definer";
630
+ }, {
631
+ readonly name: "io_outbox_drain";
632
+ readonly args: "p_organization_id uuid, p_consumer text, p_limit integer DEFAULT 100, p_event_key text DEFAULT 'records.changed'::text";
633
+ 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)";
634
+ readonly security: "definer";
635
+ }, {
636
+ readonly name: "io_outbox_release";
637
+ readonly args: "p_organization_id uuid, p_consumer text, p_older_than interval DEFAULT '00:15:00'::interval";
638
+ readonly returns: "integer";
639
+ readonly security: "definer";
640
+ }, {
641
+ readonly name: "io_proposal_accept";
642
+ 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";
643
+ readonly returns: "uuid";
644
+ readonly security: "definer";
645
+ }, {
646
+ readonly name: "io_proposal_reject";
647
+ readonly args: "p_organization_id uuid, p_import_id uuid, p_column text";
648
+ readonly returns: "boolean";
649
+ readonly security: "definer";
650
+ }, {
651
+ readonly name: "io_record_changed";
652
+ readonly args: "";
653
+ readonly returns: "trigger";
654
+ readonly security: "definer";
655
+ }, {
656
+ readonly name: "io_restore";
657
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_version integer";
658
+ readonly returns: "integer";
659
+ readonly security: "definer";
660
+ }, {
661
+ readonly name: "io_revisions";
662
+ readonly args: "p_organization_id uuid, p_record_id uuid";
663
+ readonly returns: "TABLE(version integer, changed_at timestamp with time zone, changed_by uuid, summary text)";
664
+ readonly security: "definer";
665
+ }, {
666
+ readonly name: "lookup_value";
667
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb";
668
+ readonly returns: "jsonb";
669
+ readonly security: "invoker";
670
+ }, {
671
+ readonly name: "mask_document";
672
+ readonly args: "p_document jsonb, p_visible_keys text[], p_notices jsonb, p_by_id boolean DEFAULT false, p_key_ids jsonb DEFAULT '{}'::jsonb";
673
+ readonly returns: "jsonb";
674
+ readonly security: "invoker";
675
+ }, {
676
+ readonly name: "mask_document";
677
+ 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[]";
678
+ readonly returns: "jsonb";
679
+ readonly security: "invoker";
680
+ }, {
681
+ readonly name: "merge_field_kernel_id";
682
+ readonly args: "";
683
+ readonly returns: "uuid";
684
+ readonly security: "invoker";
685
+ }, {
686
+ readonly name: "migrate_delete";
687
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text";
688
+ readonly returns: "jsonb";
689
+ readonly security: "invoker";
690
+ }, {
691
+ readonly name: "migrate_demote";
692
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text";
693
+ readonly returns: "jsonb";
694
+ readonly security: "invoker";
695
+ }, {
696
+ readonly name: "migrate_extract_parent";
697
+ readonly args: "p_organization_id uuid, p_id uuid, p_parent_table_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text";
698
+ readonly returns: "jsonb";
699
+ readonly security: "invoker";
700
+ }, {
701
+ readonly name: "migrate_merge";
702
+ readonly args: "p_organization_id uuid, p_winner_id uuid, p_loser_id uuid, p_note text DEFAULT NULL::text";
703
+ readonly returns: "jsonb";
704
+ readonly security: "invoker";
705
+ }, {
706
+ readonly name: "migrate_promote";
707
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text";
708
+ readonly returns: "jsonb";
709
+ readonly security: "invoker";
710
+ }, {
711
+ readonly name: "migrate_purge";
712
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true";
713
+ readonly returns: "jsonb";
714
+ readonly security: "invoker";
715
+ }, {
716
+ readonly name: "migrate_rename";
717
+ readonly args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text";
718
+ readonly returns: "jsonb";
719
+ readonly security: "invoker";
720
+ }, {
721
+ readonly name: "migrate_reparent";
722
+ readonly args: "p_organization_id uuid, p_id uuid, p_parent_id uuid, p_note text DEFAULT NULL::text";
723
+ readonly returns: "jsonb";
724
+ readonly security: "invoker";
725
+ }, {
726
+ readonly name: "migrate_retype";
727
+ readonly args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text";
728
+ readonly returns: "jsonb";
729
+ readonly security: "invoker";
730
+ }, {
731
+ readonly name: "migrate_split";
732
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text";
733
+ readonly returns: "jsonb";
734
+ readonly security: "invoker";
735
+ }, {
736
+ readonly name: "organization_references";
737
+ readonly args: "p_kind text, p_organization_id uuid, p_row jsonb";
738
+ readonly returns: "TABLE(site text, what text, ref_id uuid, openable boolean)";
739
+ readonly security: "invoker";
740
+ }, {
741
+ readonly name: "parity_field_types";
742
+ readonly args: "";
743
+ readonly returns: "TABLE(parity_type text, behavior text, made_of text)";
744
+ readonly security: "invoker";
745
+ }, {
746
+ readonly name: "parity_type";
747
+ readonly args: "p_field_data jsonb";
748
+ readonly returns: "text";
749
+ readonly security: "invoker";
750
+ }, {
751
+ readonly name: "parity_values";
752
+ readonly args: "p_organization_id uuid, p_record_id uuid";
753
+ 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)";
754
+ readonly security: "invoker";
755
+ }, {
756
+ readonly name: "per_value_access_words";
757
+ readonly args: "";
758
+ readonly returns: "text[]";
759
+ readonly security: "invoker";
760
+ }, {
761
+ readonly name: "person_kernel_id";
762
+ readonly args: "";
763
+ readonly returns: "uuid";
764
+ readonly security: "invoker";
765
+ }, {
766
+ readonly name: "promote_field";
767
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_id uuid";
768
+ readonly returns: "jsonb";
769
+ readonly security: "invoker";
770
+ }, {
771
+ readonly name: "promote_table";
772
+ readonly args: "p_organization_id uuid, p_table_id uuid";
773
+ readonly returns: "jsonb";
774
+ readonly security: "definer";
775
+ }, {
776
+ readonly name: "promoted_field_cap";
777
+ readonly args: "";
778
+ readonly returns: "integer";
779
+ readonly security: "invoker";
780
+ }, {
781
+ readonly name: "promoted_fields";
782
+ readonly args: "p_organization_id uuid, p_table_id uuid";
783
+ 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)";
784
+ readonly security: "invoker";
785
+ }, {
786
+ readonly name: "promoted_index_arm";
787
+ readonly args: "p_field_data jsonb";
788
+ readonly returns: "text";
789
+ readonly security: "invoker";
790
+ }, {
791
+ readonly name: "promoted_index_ddl";
792
+ readonly args: "p_organization_id uuid, p_table_id uuid";
793
+ readonly returns: "TABLE(step integer, purpose text, statement text)";
794
+ readonly security: "invoker";
795
+ }, {
796
+ readonly name: "promoted_index_expr";
797
+ readonly args: "p_field_data jsonb";
798
+ readonly returns: "text";
799
+ readonly security: "invoker";
800
+ }, {
801
+ readonly name: "promoted_index_name";
802
+ readonly args: "p_table_id uuid, p_field_key text, p_unique boolean";
803
+ readonly returns: "text";
804
+ readonly security: "invoker";
805
+ }, {
806
+ readonly name: "promoted_query_sql";
807
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_key text";
808
+ readonly returns: "text";
809
+ readonly security: "invoker";
810
+ }, {
811
+ readonly name: "promoted_read";
812
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_field_key text, p_value text";
813
+ readonly returns: "SETOF uuid";
814
+ readonly security: "invoker";
815
+ }, {
816
+ readonly name: "promoted_value_path";
817
+ readonly args: "p_field_data jsonb";
818
+ readonly returns: "text";
819
+ readonly security: "invoker";
820
+ }, {
821
+ readonly name: "promotion_inline_ceiling";
822
+ readonly args: "";
823
+ readonly returns: "integer";
824
+ readonly security: "invoker";
825
+ }, {
826
+ readonly name: "query_access_ids";
827
+ readonly args: "p_organization_id uuid, p_required text DEFAULT 'viewer'::text";
828
+ readonly returns: "uuid[]";
829
+ readonly security: "invoker";
830
+ }, {
831
+ readonly name: "query_across_homes";
832
+ 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";
833
+ readonly returns: "TABLE(record_id uuid, home_record_id uuid, data jsonb, created_at timestamp with time zone)";
834
+ readonly security: "invoker";
835
+ }, {
836
+ readonly name: "query_by_coordinates";
837
+ 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";
838
+ readonly returns: "TABLE(record_id uuid, table_id uuid, data jsonb, coordinates_matched integer)";
839
+ readonly security: "invoker";
840
+ }, {
841
+ readonly name: "query_can_see";
842
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_required text DEFAULT 'viewer'::text";
843
+ readonly returns: "boolean";
844
+ readonly security: "invoker";
845
+ }, {
846
+ readonly name: "query_hot_paths";
847
+ readonly args: "";
848
+ readonly returns: "TABLE(name text, statement text)";
849
+ readonly security: "invoker";
850
+ }, {
851
+ readonly name: "query_hot_paths_prepared";
852
+ readonly args: "";
853
+ readonly returns: "TABLE(name text, prepared boolean, generic_plans bigint)";
854
+ readonly security: "invoker";
855
+ }, {
856
+ readonly name: "query_is_store_owner";
857
+ readonly args: "";
858
+ readonly returns: "boolean";
859
+ readonly security: "invoker";
860
+ }, {
861
+ readonly name: "query_prepare_hot";
862
+ readonly args: "";
863
+ readonly returns: "integer";
864
+ readonly security: "invoker";
865
+ }, {
866
+ readonly name: "query_principal";
867
+ readonly args: "";
868
+ readonly returns: "uuid";
869
+ readonly security: "invoker";
870
+ }, {
871
+ readonly name: "query_record_as_of";
872
+ 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";
873
+ readonly returns: "jsonb";
874
+ readonly security: "invoker";
875
+ }, {
876
+ readonly name: "query_relation_edges";
877
+ readonly args: "p_organization_id uuid, p_flavor text DEFAULT NULL::text, p_role text DEFAULT NULL::text";
878
+ readonly returns: "TABLE(parent_id uuid, child_id uuid, role text, flavor text)";
879
+ readonly security: "invoker";
880
+ }, {
881
+ readonly name: "query_rollup";
882
+ 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";
883
+ readonly returns: "TABLE(record_id uuid, depth integer)";
884
+ readonly security: "invoker";
885
+ }, {
886
+ readonly name: "query_rollup_sum";
887
+ 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";
888
+ readonly returns: "numeric";
889
+ readonly security: "invoker";
890
+ }, {
891
+ readonly name: "query_table_as_of";
892
+ 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";
893
+ readonly returns: "TABLE(record_id uuid, data jsonb)";
894
+ readonly security: "invoker";
895
+ }, {
896
+ readonly name: "query_table_homes";
897
+ readonly args: "p_organization_id uuid, p_table_id uuid";
898
+ readonly returns: "SETOF uuid";
899
+ readonly security: "invoker";
900
+ }, {
901
+ readonly name: "query_visible_ids";
902
+ readonly args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_required text DEFAULT 'viewer'::text";
903
+ readonly returns: "SETOF uuid";
904
+ readonly security: "invoker";
905
+ }, {
906
+ readonly name: "reachable_from";
907
+ readonly args: "p_organization_id uuid, p_roots uuid[]";
908
+ readonly returns: "TABLE(record_id uuid, depth integer, via text)";
909
+ readonly security: "invoker";
910
+ }, {
911
+ readonly name: "read_paths_outside_the_door";
912
+ readonly args: "";
913
+ readonly returns: "TABLE(object_name text, why text)";
914
+ readonly security: "invoker";
915
+ }, {
916
+ readonly name: "read_record";
917
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_by_id boolean DEFAULT false";
918
+ readonly returns: "jsonb";
919
+ readonly security: "definer";
920
+ }, {
921
+ readonly name: "read_records";
922
+ 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";
923
+ readonly returns: "TABLE(id uuid, document jsonb, level permission_level)";
924
+ readonly security: "definer";
925
+ }, {
926
+ readonly name: "record_aggregate";
927
+ 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";
928
+ readonly returns: "TABLE(groups jsonb, measures jsonb, row_count bigint)";
929
+ readonly security: "invoker";
930
+ }, {
931
+ readonly name: "record_applicability";
932
+ readonly args: "p_organization_id uuid, p_record_id uuid";
933
+ readonly returns: "TABLE(rule_id uuid, rule_name text, rule_version integer, applies boolean, answer jsonb)";
934
+ readonly security: "invoker";
935
+ }, {
936
+ readonly name: "record_delete";
937
+ readonly args: "p_organization_id uuid, p_record_id uuid";
938
+ readonly returns: "timestamp with time zone";
939
+ readonly security: "definer";
940
+ }, {
941
+ readonly name: "record_reparent";
942
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid";
943
+ readonly returns: "void";
944
+ readonly security: "invoker";
945
+ }, {
946
+ readonly name: "record_restore";
947
+ readonly args: "p_organization_id uuid, p_record_id uuid";
948
+ readonly returns: "void";
949
+ readonly security: "definer";
950
+ }, {
951
+ readonly name: "record_update";
952
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer";
953
+ readonly returns: "integer";
954
+ readonly security: "definer";
955
+ }, {
956
+ readonly name: "record_values";
957
+ readonly args: "p_organization_id uuid, p_record_id uuid";
958
+ readonly returns: "jsonb";
959
+ readonly security: "invoker";
960
+ }, {
961
+ readonly name: "record_values_versioned";
962
+ readonly args: "p_organization_id uuid, p_record_id uuid";
963
+ 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)";
964
+ readonly security: "invoker";
965
+ }, {
966
+ readonly name: "record_write";
967
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_data jsonb";
968
+ readonly returns: "uuid";
969
+ readonly security: "definer";
970
+ }, {
971
+ readonly name: "relation_own";
972
+ readonly args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid";
973
+ readonly returns: "uuid";
974
+ readonly security: "invoker";
975
+ }, {
976
+ readonly name: "relation_target_external";
977
+ readonly args: "p_connection_token text, p_external_table text, p_external_key text";
978
+ readonly returns: "jsonb";
979
+ readonly security: "definer";
980
+ }, {
981
+ readonly name: "relation_target_ours";
982
+ readonly args: "p_entity_token text, p_row_id uuid";
983
+ readonly returns: "jsonb";
984
+ readonly security: "definer";
985
+ }, {
986
+ readonly name: "relation_targets";
987
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_via_key text";
988
+ readonly returns: "SETOF uuid";
989
+ readonly security: "invoker";
990
+ }, {
991
+ readonly name: "reopen_declared_doors";
992
+ readonly args: "";
993
+ readonly returns: "TABLE(reopened text)";
994
+ readonly security: "definer";
995
+ }, {
996
+ readonly name: "required_epoch";
997
+ readonly args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid";
998
+ readonly returns: "bigint";
999
+ readonly security: "definer";
1000
+ }, {
1001
+ readonly name: "resolve_first_match";
1002
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1003
+ readonly returns: "jsonb";
1004
+ readonly security: "invoker";
1005
+ }, {
1006
+ readonly name: "resolve_id";
1007
+ readonly args: "p_organization_id uuid, p_id uuid";
1008
+ readonly returns: "uuid";
1009
+ readonly security: "invoker";
1010
+ }, {
1011
+ readonly name: "retired_actor_words";
1012
+ readonly args: "";
1013
+ readonly returns: "jsonb";
1014
+ readonly security: "invoker";
1015
+ }, {
1016
+ readonly name: "rollup_value";
1017
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb";
1018
+ readonly returns: "jsonb";
1019
+ readonly security: "invoker";
1020
+ }, {
1021
+ readonly name: "rule_applies";
1022
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid";
1023
+ readonly returns: "jsonb";
1024
+ readonly security: "invoker";
1025
+ }, {
1026
+ readonly name: "rule_context";
1027
+ readonly args: "p_organization_id uuid, p_record_id uuid";
1028
+ readonly returns: "jsonb";
1029
+ readonly security: "invoker";
1030
+ }, {
1031
+ readonly name: "rule_dependency_edges";
1032
+ readonly args: "p_organization_id uuid, p_row custom.record DEFAULT NULL::custom.record";
1033
+ readonly returns: "TABLE(needs text, needed text)";
1034
+ readonly security: "invoker";
1035
+ }, {
1036
+ readonly name: "rule_eval";
1037
+ readonly args: "p_organization_id uuid, p_expr jsonb, p_values jsonb, p_context jsonb DEFAULT '{}'::jsonb";
1038
+ readonly returns: "jsonb";
1039
+ readonly security: "invoker";
1040
+ }, {
1041
+ readonly name: "rule_field_key";
1042
+ readonly args: "p_organization_id uuid, p_field_id uuid";
1043
+ readonly returns: "text";
1044
+ readonly security: "invoker";
1045
+ }, {
1046
+ readonly name: "rule_field_label";
1047
+ readonly args: "p_organization_id uuid, p_field_id uuid";
1048
+ readonly returns: "text";
1049
+ readonly security: "invoker";
1050
+ }, {
1051
+ readonly name: "rule_kernel_id";
1052
+ readonly args: "";
1053
+ readonly returns: "uuid";
1054
+ readonly security: "invoker";
1055
+ }, {
1056
+ readonly name: "rule_members";
1057
+ readonly args: "p_organization_id uuid, p_rule_id uuid";
1058
+ readonly returns: "SETOF custom.record";
1059
+ readonly security: "invoker";
1060
+ }, {
1061
+ readonly name: "rule_membership";
1062
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_record_id uuid";
1063
+ readonly returns: "jsonb";
1064
+ readonly security: "invoker";
1065
+ }, {
1066
+ readonly name: "rule_node_kinds";
1067
+ readonly args: "";
1068
+ readonly returns: "TABLE(node text, evaluated_by text, note text)";
1069
+ readonly security: "invoker";
1070
+ }, {
1071
+ readonly name: "rule_run";
1072
+ readonly args: "p_organization_id uuid, p_rule_id uuid, p_values jsonb, p_context jsonb DEFAULT '{}'::jsonb";
1073
+ readonly returns: "jsonb";
1074
+ readonly security: "invoker";
1075
+ }, {
1076
+ readonly name: "rule_truth";
1077
+ readonly args: "p_answer jsonb";
1078
+ readonly returns: "boolean";
1079
+ readonly security: "invoker";
1080
+ }, {
1081
+ readonly name: "rule_uses";
1082
+ readonly args: "";
1083
+ readonly returns: "text[]";
1084
+ readonly security: "invoker";
1085
+ }, {
1086
+ readonly name: "rule_version";
1087
+ readonly args: "p_organization_id uuid, p_rule_id uuid";
1088
+ readonly returns: "integer";
1089
+ readonly security: "invoker";
1090
+ }, {
1091
+ readonly name: "size_refusal";
1092
+ readonly args: "p_organization_id uuid, p_data jsonb";
1093
+ readonly returns: "text";
1094
+ readonly security: "invoker";
1095
+ }, {
1096
+ readonly name: "source_next_pointer";
1097
+ readonly args: "p_sources jsonb";
1098
+ readonly returns: "text";
1099
+ readonly security: "invoker";
1100
+ }, {
1101
+ readonly name: "source_pointer";
1102
+ readonly args: "p_sources jsonb, p_source jsonb";
1103
+ readonly returns: "text";
1104
+ readonly security: "invoker";
1105
+ }, {
1106
+ readonly name: "stamp_value_envelopes";
1107
+ readonly args: "p_data jsonb, p_actor text, p_on_behalf_of text, p_at timestamp with time zone";
1108
+ readonly returns: "jsonb";
1109
+ readonly security: "invoker";
1110
+ }, {
1111
+ readonly name: "storage_modes";
1112
+ readonly args: "";
1113
+ readonly returns: "text[]";
1114
+ readonly security: "invoker";
1115
+ }, {
1116
+ readonly name: "store_is_open";
1117
+ readonly args: "p_organization_id uuid DEFAULT NULL::uuid";
1118
+ readonly returns: "boolean";
1119
+ readonly security: "invoker";
1120
+ }, {
1121
+ readonly name: "table_capacity";
1122
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1123
+ readonly returns: "jsonb";
1124
+ readonly security: "definer";
1125
+ }, {
1126
+ readonly name: "table_declare";
1127
+ readonly args: "p_organization_id uuid, p_spec jsonb";
1128
+ readonly returns: "uuid";
1129
+ readonly security: "definer";
1130
+ }, {
1131
+ readonly name: "table_kernel_id";
1132
+ readonly args: "";
1133
+ readonly returns: "uuid";
1134
+ readonly security: "invoker";
1135
+ }, {
1136
+ readonly name: "table_record_ceiling";
1137
+ readonly args: "";
1138
+ readonly returns: "integer";
1139
+ readonly security: "invoker";
1140
+ }, {
1141
+ readonly name: "table_record_ceiling";
1142
+ readonly args: "p_organization_id uuid";
1143
+ readonly returns: "integer";
1144
+ readonly security: "invoker";
1145
+ }, {
1146
+ readonly name: "table_rules";
1147
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_use text, p_record_type text DEFAULT NULL::text";
1148
+ readonly returns: "SETOF custom.record";
1149
+ readonly security: "invoker";
1150
+ }, {
1151
+ readonly name: "table_storage";
1152
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1153
+ readonly returns: "text";
1154
+ readonly security: "invoker";
1155
+ }, {
1156
+ readonly name: "table_type_field";
1157
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1158
+ readonly returns: "text";
1159
+ readonly security: "invoker";
1160
+ }, {
1161
+ readonly name: "tables_at_home";
1162
+ readonly args: "p_organization_id uuid, p_home_ids uuid[]";
1163
+ readonly returns: "TABLE(table_id uuid, home_record_id uuid, kind text)";
1164
+ readonly security: "invoker";
1165
+ }, {
1166
+ readonly name: "trg_associations_bump_visibility";
1167
+ readonly args: "";
1168
+ readonly returns: "trigger";
1169
+ readonly security: "definer";
1170
+ }, {
1171
+ readonly name: "validate_custom_fields";
1172
+ readonly args: "p_token text, p_organization_id uuid, p_values jsonb";
1173
+ readonly returns: "void";
1174
+ readonly security: "invoker";
1175
+ }, {
1176
+ readonly name: "validate_value_envelope";
1177
+ readonly args: "p_organization_id uuid, p_fields custom.record[], p_data jsonb";
1178
+ readonly returns: "void";
1179
+ readonly security: "invoker";
1180
+ }, {
1181
+ readonly name: "validate_values";
1182
+ readonly args: "p_organization_id uuid, p_fields custom.record[], p_values jsonb, p_record_type text DEFAULT NULL::text";
1183
+ readonly returns: "void";
1184
+ readonly security: "invoker";
1185
+ }, {
1186
+ readonly name: "value_alternate_keys";
1187
+ readonly args: "";
1188
+ readonly returns: "text[]";
1189
+ readonly security: "invoker";
1190
+ }, {
1191
+ readonly name: "value_envelope_keys";
1192
+ readonly args: "";
1193
+ readonly returns: "text[]";
1194
+ readonly security: "invoker";
1195
+ }, {
1196
+ readonly name: "value_envelope_ok";
1197
+ readonly args: "p_data jsonb";
1198
+ readonly returns: "boolean";
1199
+ readonly security: "invoker";
1200
+ }, {
1201
+ readonly name: "value_envelope_refusal";
1202
+ readonly args: "p_data jsonb";
1203
+ readonly returns: "text";
1204
+ readonly security: "invoker";
1205
+ }, {
1206
+ readonly name: "value_read";
1207
+ readonly args: "p_organization_id uuid, p_record_id uuid, p_key text";
1208
+ 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)";
1209
+ readonly security: "invoker";
1210
+ }, {
1211
+ readonly name: "value_versions";
1212
+ readonly args: "p_old jsonb, p_new jsonb";
1213
+ readonly returns: "jsonb";
1214
+ readonly security: "invoker";
1215
+ }, {
1216
+ readonly name: "visibility_ancestors";
1217
+ readonly args: "p_item_type text, p_item_id uuid";
1218
+ readonly returns: "TABLE(container_type text, container_id uuid, depth integer, max_level permission_level)";
1219
+ readonly security: "definer";
1220
+ }, {
1221
+ readonly name: "visibility_cache_rebuild";
1222
+ readonly args: "";
1223
+ readonly returns: "integer";
1224
+ readonly security: "definer";
1225
+ }, {
1226
+ readonly name: "visibility_parity";
1227
+ readonly args: "";
1228
+ 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)";
1229
+ readonly security: "definer";
1230
+ }, {
1231
+ readonly name: "visibility_warm";
1232
+ readonly args: "p_container_type text, p_container_id uuid";
1233
+ readonly returns: "integer";
1234
+ readonly security: "definer";
1235
+ }, {
1236
+ readonly name: "visible_record_ids";
1237
+ readonly args: "p_user_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level";
1238
+ readonly returns: "TABLE(id uuid)";
1239
+ readonly security: "definer";
1240
+ }, {
1241
+ readonly name: "work_assignment_fields";
1242
+ readonly args: "p_options_table_id uuid DEFAULT NULL::uuid";
1243
+ readonly returns: "TABLE(key text, label text, spec jsonb)";
1244
+ readonly security: "invoker";
1245
+ }, {
1246
+ readonly name: "work_has_assignment";
1247
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1248
+ readonly returns: "boolean";
1249
+ readonly security: "invoker";
1250
+ }, {
1251
+ readonly name: "work_instantiation_shape";
1252
+ readonly args: "p_organization_id uuid, p_instantiation_id uuid";
1253
+ readonly returns: "jsonb";
1254
+ readonly security: "invoker";
1255
+ }, {
1256
+ readonly name: "work_relation_kinds";
1257
+ readonly args: "";
1258
+ readonly returns: "TABLE(kind text, available boolean, why text)";
1259
+ readonly security: "invoker";
1260
+ }, {
1261
+ readonly name: "work_slot_expire";
1262
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1263
+ readonly returns: "integer";
1264
+ readonly security: "invoker";
1265
+ }, {
1266
+ readonly name: "work_slot_hold";
1267
+ 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";
1268
+ readonly returns: "jsonb";
1269
+ readonly security: "invoker";
1270
+ }, {
1271
+ readonly name: "work_slot_holds";
1272
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1273
+ readonly returns: "TABLE(hold_id uuid, slot_key text, holder text, expires_at timestamp with time zone, expired boolean)";
1274
+ readonly security: "invoker";
1275
+ }, {
1276
+ readonly name: "work_slot_index_name";
1277
+ readonly args: "p_table_id uuid";
1278
+ readonly returns: "text";
1279
+ readonly security: "invoker";
1280
+ }, {
1281
+ readonly name: "work_slot_release";
1282
+ readonly args: "p_organization_id uuid, p_hold_id uuid";
1283
+ readonly returns: "boolean";
1284
+ readonly security: "invoker";
1285
+ }, {
1286
+ readonly name: "work_slots_declare";
1287
+ readonly args: "p_organization_id uuid, p_name text, p_slug text, p_home_id uuid DEFAULT NULL::uuid";
1288
+ readonly returns: "jsonb";
1289
+ readonly security: "invoker";
1290
+ }, {
1291
+ readonly name: "work_states";
1292
+ readonly args: "";
1293
+ readonly returns: "TABLE(sort integer, name text, terminal boolean, next text[])";
1294
+ readonly security: "invoker";
1295
+ }, {
1296
+ readonly name: "work_take_assignment";
1297
+ readonly args: "p_organization_id uuid, p_table_id uuid";
1298
+ readonly returns: "jsonb";
1299
+ readonly security: "invoker";
1300
+ }, {
1301
+ readonly name: "work_template_declare";
1302
+ readonly args: "p_organization_id uuid, p_name text, p_graph jsonb";
1303
+ readonly returns: "uuid";
1304
+ readonly security: "invoker";
1305
+ }, {
1306
+ readonly name: "work_template_instantiate";
1307
+ readonly args: "p_organization_id uuid, p_template_id uuid, p_overrides jsonb DEFAULT '{}'::jsonb";
1308
+ readonly returns: "jsonb";
1309
+ readonly security: "invoker";
1310
+ }, {
1311
+ readonly name: "work_template_refusal";
1312
+ readonly args: "p_graph jsonb";
1313
+ readonly returns: "text";
1314
+ readonly security: "invoker";
1315
+ }, {
1316
+ readonly name: "work_template_shape";
1317
+ readonly args: "p_organization_id uuid, p_template_id uuid";
1318
+ readonly returns: "jsonb";
1319
+ readonly security: "invoker";
1320
+ }, {
1321
+ readonly name: "work_transition_refusal";
1322
+ readonly args: "p_organization_id uuid, p_from_state_id uuid, p_to_state_id uuid";
1323
+ readonly returns: "text";
1324
+ readonly security: "invoker";
1325
+ }, {
1326
+ readonly name: "work_whose_turn";
1327
+ readonly args: "p_organization_id uuid, p_table_id uuid, p_include_finished boolean DEFAULT false";
1328
+ 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)";
1329
+ readonly security: "invoker";
1330
+ }];
1331
+ /** The campaign's own knobs, with the value the store resolves them to today. */
1332
+ declare const STORE_KNOBS: readonly [{
1333
+ readonly key: "accessible_entity_ids_guard";
1334
+ readonly value: "false";
1335
+ readonly type: "boolean";
1336
+ }, {
1337
+ readonly key: "associations_guard";
1338
+ readonly value: "false";
1339
+ readonly type: "boolean";
1340
+ }, {
1341
+ readonly key: "code_paths_enabled";
1342
+ readonly value: "false";
1343
+ readonly type: "boolean";
1344
+ }, {
1345
+ readonly key: "containment_depth_ceiling";
1346
+ readonly value: "16";
1347
+ readonly type: "integer";
1348
+ }, {
1349
+ readonly key: "document_max_bytes";
1350
+ readonly value: "1048576";
1351
+ readonly type: "integer";
1352
+ }, {
1353
+ readonly key: "emergency_door_guard";
1354
+ readonly value: "false";
1355
+ readonly type: "boolean";
1356
+ }, {
1357
+ readonly key: "emergency_door_sweep_enabled";
1358
+ readonly value: "false";
1359
+ readonly type: "boolean";
1360
+ }, {
1361
+ readonly key: "entity_custom_fields_guard";
1362
+ readonly value: "false";
1363
+ readonly type: "boolean";
1364
+ }, {
1365
+ readonly key: "entity_types_guard";
1366
+ readonly value: "false";
1367
+ readonly type: "boolean";
1368
+ }, {
1369
+ readonly key: "external_principal_enabled";
1370
+ readonly value: "false";
1371
+ readonly type: "boolean";
1372
+ }, {
1373
+ readonly key: "field_index_guard";
1374
+ readonly value: "false";
1375
+ readonly type: "boolean";
1376
+ }, {
1377
+ readonly key: "field_sensitivity_levels";
1378
+ readonly value: "{\"edit\": {\"public\": \"editor\", \"internal\": \"editor\", \"restricted\": \"admin\", \"confidential\": \"admin\"}, \"read\": {\"public\": \"viewer\", \"internal\": \"viewer\", \"restricted\": \"admin\", \"confidential\": \"editor\"}}";
1379
+ readonly type: "json";
1380
+ }, {
1381
+ readonly key: "member_default_level";
1382
+ readonly value: "\"viewer\"";
1383
+ readonly type: "string";
1384
+ }, {
1385
+ readonly key: "row_versions_guard";
1386
+ readonly value: "false";
1387
+ readonly type: "boolean";
1388
+ }, {
1389
+ readonly key: "sandbox_expanded_frame_height_px";
1390
+ readonly value: "20000";
1391
+ readonly type: "integer";
1392
+ }, {
1393
+ readonly key: "sandbox_frame_height_px";
1394
+ readonly value: "4000";
1395
+ readonly type: "integer";
1396
+ }, {
1397
+ readonly key: "sandbox_message_bytes";
1398
+ readonly value: "65536";
1399
+ readonly type: "integer";
1400
+ }, {
1401
+ readonly key: "sandbox_org_components";
1402
+ readonly value: "true";
1403
+ readonly type: "boolean";
1404
+ }, {
1405
+ readonly key: "signup_provisioning_guard";
1406
+ readonly value: "false";
1407
+ readonly type: "boolean";
1408
+ }, {
1409
+ readonly key: "system_enabled";
1410
+ readonly value: "false";
1411
+ readonly type: "boolean";
1412
+ }, {
1413
+ readonly key: "table_record_ceiling";
1414
+ readonly value: "150000";
1415
+ readonly type: "integer";
1416
+ }, {
1417
+ readonly key: "value_max_bytes";
1418
+ readonly value: "100000";
1419
+ readonly type: "integer";
1420
+ }, {
1421
+ readonly key: "world_publish_enabled";
1422
+ readonly value: "false";
1423
+ readonly type: "boolean";
1424
+ }];
1425
+ /**
1426
+ * Every SQLSTATE the store's own function bodies raise, with the functions that
1427
+ * raise it. This is the list the client's refusal mapper is checked against: a
1428
+ * code the store can raise and the package cannot name is a hole, and the
1429
+ * real-door suite says so by name.
1430
+ */
1431
+ declare const STORE_REFUSAL_CODES: readonly [{
1432
+ readonly code: "02000";
1433
+ 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";
1434
+ }, {
1435
+ readonly code: "0A000";
1436
+ 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";
1437
+ }, {
1438
+ readonly code: "22004";
1439
+ 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";
1440
+ }, {
1441
+ readonly code: "22012";
1442
+ readonly raised_by: "rule_eval";
1443
+ }, {
1444
+ readonly code: "22023";
1445
+ 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";
1446
+ }, {
1447
+ readonly code: "23503";
1448
+ 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";
1449
+ }, {
1450
+ readonly code: "23505";
1451
+ readonly raised_by: "doc_sign,doc_signature_write,home_add,io_proposal_accept,work_slot_hold";
1452
+ }, {
1453
+ readonly code: "23514";
1454
+ 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";
1455
+ }, {
1456
+ readonly code: "40001";
1457
+ readonly raised_by: "has_visibility_at";
1458
+ }, {
1459
+ readonly code: "42501";
1460
+ 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";
1461
+ }, {
1462
+ readonly code: "53400";
1463
+ readonly raised_by: "anon_rate_take,promote_field";
1464
+ }, {
1465
+ readonly code: "PT409";
1466
+ readonly raised_by: "record_update";
1467
+ }];
1468
+ /** `platform.entity_types` — the registered tokens a Table or relation may name. */
1469
+ 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"];
1470
+ type StoreRefusalCode = (typeof STORE_REFUSAL_CODES)[number]["code"];
1471
+ type StoreDoorName = (typeof STORE_DOORS)[number]["name"];
1472
+ type EntityToken = (typeof ENTITY_TOKENS)[number];
1473
+ type KernelTableName = (typeof KERNEL_TABLES)[number]["name"];
1474
+
1475
+ /**
1476
+ * VAL-8. Who wrote a value. `user`, `agent`, `system` — enforced by every write
1477
+ * door, and the three retired words (`human`, `ai`, `code`) are translated by
1478
+ * the store's own `custom.actor_word`, never by a caller.
1479
+ */
1480
+ type Actor = (typeof ACTOR_VOCABULARY)[number];
1481
+ /** The words the store still accepts and rewrites, mapped to what they become. */
1482
+ type RetiredActorWord = keyof typeof RETIRED_ACTOR_WORDS;
1483
+ /**
1484
+ * VAL-2. Why a value is missing. A value is never blank for an unexplained
1485
+ * reason: it either holds something or it says one of these four words.
1486
+ */
1487
+ type AbsenceReason = (typeof ABSENCE_REASONS)[number];
1488
+ /** The closed key set of one value envelope (VAL-1 … VAL-4). */
1489
+ type ValueEnvelopeKey = (typeof VALUE_ENVELOPE_KEYS)[number];
1490
+ /** The closed key set of one ranked alternate (VAL-3). */
1491
+ type ValueAlternateKey = (typeof VALUE_ALTERNATE_KEYS)[number];
1492
+ /**
1493
+ * REC-4. `heavy` is indexed storage with Rules on write; `light` is
1494
+ * whole-document storage with Rules on read. Per Table, one store.
1495
+ */
1496
+ type StorageMode = (typeof STORAGE_MODES)[number];
1497
+ /** REC-15. One Rule object, four uses. */
1498
+ type RuleUse = (typeof RULE_USES)[number];
1499
+ /**
1500
+ * VAL-5 / VAL-6. The words that may NOT appear inside a value envelope:
1501
+ * visibility and access belong to a Field and to a Record, never to a value.
1502
+ * The store refuses each of them by name and so does this package's mirror.
1503
+ */
1504
+ type PerValueAccessWord = (typeof PER_VALUE_ACCESS_WORDS)[number];
1505
+ /** FLD-11. The parity floor: the field type a person picks in the UI. */
1506
+ type ParityFieldType = (typeof PARITY_FIELD_TYPES)[number]["parity_type"];
1507
+ /** FLD-1. The five behaviours a Field can have. One, exactly, and closed. */
1508
+ type FieldBehavior = (typeof PARITY_FIELD_TYPES)[number]["behavior"];
1509
+ /** The node kinds `custom.rule_eval` evaluates. */
1510
+ type RuleNodeKind = (typeof RULE_NODE_KINDS)[number]["node"];
1511
+ /**
1512
+ * REC-32. The seven table types, closed. The parenthesised names are the
1513
+ * retired ones the doctrine records; never coin an eighth.
1514
+ */
1515
+ declare const TABLE_TYPES: readonly ["entity", "detail", "reference", "ledger", "restricted", "system", "deprecated"];
1516
+ type TableType = (typeof TABLE_TYPES)[number];
1517
+ /** REC-33. The two origins. A table we ship in schema `custom` is `standard`. */
1518
+ declare const TABLE_ORIGINS: readonly ["standard", "custom"];
1519
+ type TableOrigin = (typeof TABLE_ORIGINS)[number];
1520
+ /** REL-1. Ownership is one fact, stored once, read from the field's side. */
1521
+ declare const RELATION_FLAVORS: readonly ["owned", "referenced"];
1522
+ type RelationFlavor = (typeof RELATION_FLAVORS)[number];
1523
+ /** REL-2. What happens to the far side, separate from flavour. */
1524
+ declare const ON_DELETE: readonly ["cascade", "set_null", "restrict"];
1525
+ type OnDelete = (typeof ON_DELETE)[number];
1526
+ /** REL-3. A snapshot is a frozen copy in the relation's payload, never a pointer. */
1527
+ declare const RELATION_BINDINGS: readonly ["live", "snapshot"];
1528
+ type RelationBinding = (typeof RELATION_BINDINGS)[number];
1529
+ /** REL-7. */
1530
+ declare const RELATION_CARDINALITIES: readonly ["one", "many"];
1531
+ type RelationCardinality = (typeof RELATION_CARDINALITIES)[number];
1532
+ /** FLD-7. Where a Field's values come from. */
1533
+ declare const FIELD_SOURCES: readonly ["manual", "formula", "agent", "synced"];
1534
+ type FieldSource = (typeof FIELD_SOURCES)[number];
1535
+ /** FLD-9. A Formula declares whether it computes on read or on write. */
1536
+ declare const COMPUTE_ON: readonly ["read", "write"];
1537
+ type ComputeOn = (typeof COMPUTE_ON)[number];
1538
+ /**
1539
+ * AGT-7 / FLD-12. A Field's sensitivity sets a ceiling a merge field can never
1540
+ * widen — and these are THE STORE'S four words, checked against its own guard.
1541
+ *
1542
+ * This list used to read `standard · sensitive · secret`, which the store has
1543
+ * never accepted: writing a Field with `sensitivity: "standard"` is refused
1544
+ * with "the field <name> has to say how sensitive its values are, and it says
1545
+ * standard". The knob `custom/field_sensitivity_levels` keys off these same
1546
+ * four words to decide which level may read and edit each one, so a package
1547
+ * carrying three different words could never have agreed with it. Corrected
1548
+ * against the live store, 2026-09-18.
1549
+ */
1550
+ declare const FIELD_SENSITIVITIES: readonly ["public", "internal", "confidential", "restricted"];
1551
+ type FieldSensitivity = (typeof FIELD_SENSITIVITIES)[number];
1552
+ /** DYN-17 / §D. Which tier a MERGE FIELD's value is delivered in. */
1553
+ declare const DELIVERIES: readonly ["inline", "on_demand", "auto"];
1554
+ type Delivery = (typeof DELIVERIES)[number];
1555
+ /**
1556
+ * FLD-12. WHETHER AN AGENT MAY SEE A FIELD'S VALUES, and these are the STORE'S
1557
+ * four words — not the merge field's delivery tiers.
1558
+ *
1559
+ * `Field.context_policy` used to be typed as `Delivery` here, which is a
1560
+ * different question with a different vocabulary: writing a Field with
1561
+ * `context_policy: "inline"` is refused with "the field <name> has to say
1562
+ * whether an agent may see its values, and it says inline". Delivery is about
1563
+ * HOW MUCH of a value a merge field carries into a turn; this is about WHETHER
1564
+ * the value reaches an agent at all, and conflating them let a screen offer a
1565
+ * word the store has never accepted. Corrected against the live store,
1566
+ * 2026-09-18.
1567
+ */
1568
+ declare const CONTEXT_POLICIES: readonly ["include", "summarize", "exclude", "on_request"];
1569
+ type ContextPolicy = (typeof CONTEXT_POLICIES)[number];
1570
+ /** DYN-3. The eight sources, closed. Relationships and rules are not sources. */
1571
+ declare const MERGE_FIELD_SOURCES: readonly ["literal", "record", "state", "actor", "platform", "user_input", "tool", "derived"];
1572
+ type MergeFieldSource = (typeof MERGE_FIELD_SOURCES)[number];
1573
+ /** DYN-4. What a merge field resolves INTO. The consumer never learns which. */
1574
+ declare const MERGE_FIELD_SEMANTIC_TYPES: readonly ["value", "reference", "resolver", "computed", "collection"];
1575
+ type MergeFieldSemanticType = (typeof MERGE_FIELD_SEMANTIC_TYPES)[number];
1576
+ /** DYNAMIC-VALUES §A. Any number of these; never fused into the source. */
1577
+ declare const MERGE_FIELD_MODIFIERS: readonly ["scoped", "temporal", "collection", "live", "fallback", "formatted", "required"];
1578
+ type MergeFieldModifier = (typeof MERGE_FIELD_MODIFIERS)[number];
1579
+ /** DYN-12. The five override policies. Exactly one, and it outranks the ladder. */
1580
+ declare const OVERRIDE_POLICIES: readonly ["must_supply", "shown_overridable", "shown_locked", "server_fixed", "derived"];
1581
+ type OverridePolicy = (typeof OVERRIDE_POLICIES)[number];
1582
+ /** DYNAMIC-VALUES §C. What a resolved merge field's freshness was. */
1583
+ declare const FRESHNESS: readonly ["live", "cached", "snapshot"];
1584
+ type Freshness = (typeof FRESHNESS)[number];
1585
+ /** REC-1. How a Table shows itself. */
1586
+ declare const TABLE_DISPLAYS: readonly ["list", "grid", "board", "calendar", "timeline"];
1587
+ type TableDisplay = (typeof TABLE_DISPLAYS)[number];
1588
+
1589
+ /** A `uuid` as the store writes it. */
1590
+ type Uuid = string;
1591
+ /** An ISO-8601 timestamp, as jsonb carries it. */
1592
+ type Timestamp = string;
1593
+ /**
1594
+ * VAL-1. WHERE a value came from, addressed by a pointer the STORE interns —
1595
+ * `s1`, `s2`, `s3`. A writer supplies the source itself and the store interns
1596
+ * it; a writer that invents a pointer is refused by name. Interned once per
1597
+ * save: two pointers holding the same description is the defect the word
1598
+ * "interned" exists to prevent, and the store refuses that too.
1599
+ */
1600
+ type ProvenancePointer = string;
1601
+ /** 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. */
1602
+ type ValueSource = Record<string, unknown>;
1603
+ /**
1604
+ * VAL-3 / VAL-4. Another candidate for the same value, with the source it came
1605
+ * from and the RANK — the order an organization trusts its sources in, never a
1606
+ * score or a confidence a machine invented. Ranks are whole, start at 1, and
1607
+ * two alternates never claim the same one. They live INSIDE this record's
1608
+ * document; there is never a row per value.
1609
+ */
1610
+ interface ValueAlternate {
1611
+ value: unknown;
1612
+ /** A pointer this record's `_sources` block resolves. */
1613
+ src?: ProvenancePointer | null;
1614
+ rank: number;
1615
+ }
1616
+ /**
1617
+ * The value envelope. One per field key, in the record's `_values` block, with
1618
+ * the value itself sitting at the top level under the same key.
1619
+ *
1620
+ * The key set is CLOSED (`custom.value_envelope_keys()`). In particular it can
1621
+ * never carry visibility, access, share, acl, permission, permissions or
1622
+ * secret: VAL-5 puts those on the Field and on the Record, and VAL-6 says a
1623
+ * value that must be secret goes in a contained record with its own visibility.
1624
+ * The store refuses each of those words by name.
1625
+ */
1626
+ interface ValueEnvelope {
1627
+ /** The per-value version, 1 or more. THE STORE WRITES IT — no caller sets it. */
1628
+ ver: number;
1629
+ /** A provenance pointer this record's `_sources` block resolves. */
1630
+ src?: ProvenancePointer | null;
1631
+ /** VAL-8. Who wrote it. */
1632
+ actor: Actor;
1633
+ /** Only an agent acts on behalf of a person; a person's id. */
1634
+ on_behalf_of?: Uuid | null;
1635
+ at?: Timestamp | null;
1636
+ /** VAL-2. Why it is missing. A value either holds something or says this. */
1637
+ absent?: AbsenceReason | null;
1638
+ alternates?: ValueAlternate[] | null;
1639
+ /**
1640
+ * FLD-2's `dated` modifier: the WORLD clock for this value — when it was true
1641
+ * of the world, which is a different question from when it was written. Added
1642
+ * to the store's closed key set after this package's first generation, and
1643
+ * caught by `pnpm check:store-registry` rather than by anybody noticing.
1644
+ */
1645
+ dated?: string | null;
1646
+ }
1647
+ /**
1648
+ * The one jsonb document. Field keys sit at the top level; the store's own
1649
+ * blocks are underscore-prefixed and are never a writer's value.
1650
+ */
1651
+ interface RecordDocument {
1652
+ /** The store's interned provenance table: pointer -> source. */
1653
+ _sources?: Record<ProvenancePointer, ValueSource>;
1654
+ /** The envelopes, keyed by field key. */
1655
+ _values?: Record<string, ValueEnvelope>;
1656
+ /** FLD-10. Which type of record this is, selecting the Fields and Rules that apply. */
1657
+ _type?: string;
1658
+ /** REC-7. Zero or one parent. Never two. */
1659
+ _parent?: Uuid | null;
1660
+ [fieldKey: string]: unknown;
1661
+ }
1662
+ /** `custom.record` as the store holds it — the row around the document. */
1663
+ interface StoredRecord {
1664
+ id: Uuid;
1665
+ organization_id: Uuid;
1666
+ table_id: Uuid | null;
1667
+ /** `record` for ordinary rows, `kernel` for the nine kernel Tables (REC-27). */
1668
+ data_class: string;
1669
+ data: RecordDocument;
1670
+ created_by: Uuid | null;
1671
+ updated_by: Uuid | null;
1672
+ created_at: Timestamp;
1673
+ updated_at: Timestamp;
1674
+ /** REC-23: soft, and reversible within `retention`. */
1675
+ deleted_at: Timestamp | null;
1676
+ /** The RECORD clock. `recordUpdate` writes against it (optimistic concurrency). */
1677
+ version: number;
1678
+ metadata: Record<string, unknown>;
1679
+ custom_fields: Record<string, unknown>;
1680
+ visibility: string;
1681
+ }
1682
+ /**
1683
+ * One value read back with everything the store knows about it — the shape
1684
+ * `custom.record_values_versioned` and `custom.value_read` answer in. This is
1685
+ * what a screen needs to explain a value (DYN-24) without a second query.
1686
+ */
1687
+ interface ReadValue {
1688
+ field_key: string;
1689
+ field_id: Uuid | null;
1690
+ value: unknown;
1691
+ value_version: number | null;
1692
+ source: ValueSource | null;
1693
+ absent_reason: AbsenceReason | null;
1694
+ actor: Actor | null;
1695
+ on_behalf_of: Uuid | null;
1696
+ written_at: Timestamp | null;
1697
+ alternates: ValueAlternate[] | null;
1698
+ }
1699
+ /**
1700
+ * Why one field of a record came back empty — `custom.hidden_field_notice`, as
1701
+ * the read door attaches it under `_hidden`. It is the store's own sentence, so
1702
+ * a screen says "you need X to see this" instead of drawing a blank cell.
1703
+ */
1704
+ interface HiddenFieldNotice {
1705
+ /** The field's sensitivity word. */
1706
+ reason: string | null;
1707
+ /** The level this person would need. */
1708
+ needs: string | null;
1709
+ /** The other way in — "a share of this one field with you". */
1710
+ or: string | null;
1711
+ }
1712
+ /**
1713
+ * One row as the read door `custom.read_records` answers it: the id, the
1714
+ * document the store decided this reader may see, and the reader's level on the
1715
+ * Table. A field this reader may not see is PRESENT and null, with its reason
1716
+ * in `hidden` — the masking is the store's, never this client's.
1717
+ */
1718
+ interface ReadRow {
1719
+ id: Uuid;
1720
+ document: RecordDocument;
1721
+ /** `public.permission_level` — the caller's level on the Table. */
1722
+ level: string;
1723
+ hidden: Record<string, HiddenFieldNotice>;
1724
+ }
1725
+ /**
1726
+ * One revision of one record, as `custom.io_revisions` answers it, newest
1727
+ * first. `version` is the record's own version at that point — the number a
1728
+ * screen hands back as `expectedVersion` so the store, not the screen, decides
1729
+ * whether someone else got there first.
1730
+ */
1731
+ interface RecordRevision {
1732
+ version: number;
1733
+ changed_at: string;
1734
+ changed_by: Uuid | null;
1735
+ summary: string | null;
1736
+ }
1737
+ /** A whole record as `recordRead` answers it, through `custom.read_record`. */
1738
+ interface RecordRead {
1739
+ record_id: Uuid;
1740
+ /** The masked document. A hidden field is present and null. */
1741
+ document: RecordDocument;
1742
+ /** Why each masked field is masked, in the store's words. */
1743
+ hidden: Record<string, HiddenFieldNotice>;
1744
+ /**
1745
+ * FLD-9 / REC-19. Which Rule version produced each computed value. Present
1746
+ * only where the store has computed provenance for this record.
1747
+ */
1748
+ computed: Array<{
1749
+ field_key: string;
1750
+ field_id: Uuid;
1751
+ value: unknown;
1752
+ rule_id: Uuid;
1753
+ rule_version: number;
1754
+ computed_at: Timestamp;
1755
+ }>;
1756
+ }
1757
+
1758
+ /**
1759
+ * REC-1. A Table declares its fields, exactly one Home, and the properties
1760
+ * `display`, `ordered`, `heavy` | `light`, `retention` and `detail`.
1761
+ */
1762
+ interface Table {
1763
+ id: Uuid;
1764
+ organization_id: Uuid;
1765
+ /** The token this Table is addressed by. */
1766
+ slug: string;
1767
+ name: string;
1768
+ label_singular: string | null;
1769
+ label_plural: string | null;
1770
+ icon: string | null;
1771
+ color: string | null;
1772
+ /** REC-32. One of the seven, closed. */
1773
+ type: TableType;
1774
+ /** REC-11. A detail Table inherits only: no direct shares, never a Home. */
1775
+ detail: boolean;
1776
+ parent_token: string | null;
1777
+ /** AGT-1 / AGT-2. On by default for a custom table; an organization turns it off. */
1778
+ agent_writable: boolean;
1779
+ display: TableDisplay | null;
1780
+ ordered: boolean;
1781
+ /** REC-4. `heavy` is indexed with Rules on write; `light` is the whole document with Rules on read. */
1782
+ weight: StorageMode;
1783
+ /** REC-23. How long a soft delete stays reversible. */
1784
+ retention_days: number | null;
1785
+ /** REC-2. Every Table has one; without it a record cannot be a chip. */
1786
+ title_field: string | null;
1787
+ /** The field ids this Table declares, in declaration order. */
1788
+ fields: Uuid[];
1789
+ default_sort: string | null;
1790
+ row_order: string | null;
1791
+ /** REC-14. Where this Table lives. Exactly one primary Home. */
1792
+ home_id: Uuid | null;
1793
+ /** REC-27. One of the nine, defined in code and not editable by Migration. */
1794
+ is_kernel: boolean;
1795
+ created_by: Uuid | null;
1796
+ updated_by: Uuid | null;
1797
+ created_at: Timestamp;
1798
+ updated_at: Timestamp;
1799
+ version: number;
1800
+ metadata: Record<string, unknown>;
1801
+ visibility: string;
1802
+ }
1803
+ /**
1804
+ * REC-33. `origin` is `standard` or `custom`, and it is orthogonal to `type`.
1805
+ * A Table we ship in schema `custom` is `standard` — the schema name is not the
1806
+ * origin.
1807
+ */
1808
+ interface RegisteredTable {
1809
+ token: string;
1810
+ type: TableType;
1811
+ origin: TableOrigin;
1812
+ /** REC-34. Carried per table type: true for Entity and Detail, false for the other five. */
1813
+ custom_fields_enabled: boolean;
1814
+ }
1815
+ /**
1816
+ * REC-3 / REC-26. A Home is where a Table appears. The declared organization
1817
+ * Home is the tree's root; every additional Home is a referenced carrying
1818
+ * relation from the Home record to the Table record, which is why this shape
1819
+ * names a relation id rather than a second placement column.
1820
+ */
1821
+ interface Home {
1822
+ table_id: Uuid;
1823
+ home_record_id: Uuid;
1824
+ organization_id: Uuid;
1825
+ /** `declared` for the Table's own Home, `carried` for an additional one. */
1826
+ kind: string;
1827
+ relation_id: Uuid | null;
1828
+ }
1829
+ /** What `tablePropose` / `tableList` hands back about how full a Table is (REC-N-5). */
1830
+ interface TableCapacity {
1831
+ records: number;
1832
+ ceiling: number;
1833
+ full: boolean;
1834
+ /** The knob that decides the ceiling, named so a person can act on it. */
1835
+ knob: string;
1836
+ }
1837
+
1838
+ /** FLD-3. A constraint attached to a Field. A Rule, never a behaviour. */
1839
+ interface FieldRule {
1840
+ kind: "min" | "max" | "length" | "pattern" | "equals_field" | "differs_from_field";
1841
+ value: string | number;
1842
+ /** FLD-10. Empty means "wherever the Field applies". */
1843
+ applies_to_types?: string[];
1844
+ }
1845
+ /**
1846
+ * `custom.field` — the ONE definitions table (FLD-8), organization-scoped, so
1847
+ * two organizations add different fields to the same standard table.
1848
+ */
1849
+ interface Field {
1850
+ id: Uuid;
1851
+ organization_id: Uuid;
1852
+ /** Set when this Field extends a standard entity rather than a custom Table. */
1853
+ entity_definition_id: Uuid | null;
1854
+ /** The token of the Table this Field belongs to. */
1855
+ table_token: string | null;
1856
+ key: string;
1857
+ label: string;
1858
+ name: string | null;
1859
+ /** FLD-1. Exactly one of five. */
1860
+ type: FieldBehavior;
1861
+ /** FLD-2. The shape of the value, never a second behaviour. */
1862
+ multi: boolean;
1863
+ /** FLD-2. The values carry their own dates — the world clock, not History. */
1864
+ dated: boolean;
1865
+ /** FLD-3. Any number of attached validation Rules. */
1866
+ rules: FieldRule[];
1867
+ config: Record<string, unknown>;
1868
+ required: boolean;
1869
+ default: unknown;
1870
+ sort: number | null;
1871
+ /** The Table this relation points at. */
1872
+ relation_target: Uuid | null;
1873
+ relation_max: number | null;
1874
+ on_target_delete: OnDelete | null;
1875
+ /** REL-9. The reverse is visible from both ends and is NOT a second Field. */
1876
+ inverse_key: string | null;
1877
+ source: FieldSource;
1878
+ source_config: Record<string, unknown>;
1879
+ /** FLD-9. A Formula declares whether it computes on read or on write. */
1880
+ compute_on: ComputeOn | null;
1881
+ /** The unit, on the Field, because it changes the meaning. Never presentation. */
1882
+ unit: string | null;
1883
+ format: string | null;
1884
+ /** AGT-7. A ceiling a merge field's delivery can never widen. */
1885
+ sensitivity: FieldSensitivity | null;
1886
+ /** FLD-12. Whether an agent may see this Field's values: include · summarize · exclude · on_request. */
1887
+ context_policy: ContextPolicy | null;
1888
+ /** AGT-6. How often a `source = agent` Field is refilled. */
1889
+ review_interval_days: number | null;
1890
+ /**
1891
+ * §D says this is on the wrong object and moves to the merge field. It is
1892
+ * still carried here because the live column is, and the client reads what
1893
+ * the store holds — never what the plan wishes it held.
1894
+ */
1895
+ depends_on: Uuid[] | null;
1896
+ /** FLD-10. Which record types this Field applies to. Empty means all of them. */
1897
+ applies_to_types: string[];
1898
+ /** FLD-5 / FLD-6. A list field's choices are the records of THIS Table. */
1899
+ options_table_id: Uuid | null;
1900
+ created_by: Uuid | null;
1901
+ updated_by: Uuid | null;
1902
+ created_at: Timestamp;
1903
+ updated_at: Timestamp;
1904
+ version: number;
1905
+ metadata: Record<string, unknown>;
1906
+ visibility: string;
1907
+ }
1908
+ /**
1909
+ * FLD-11. What the person picked, and what the store says it is made of. The
1910
+ * list itself is generated from `custom.parity_field_types()`; this is its type.
1911
+ */
1912
+ interface ParityFieldTypeDescriptor {
1913
+ parity_type: ParityFieldType;
1914
+ behavior: FieldBehavior;
1915
+ made_of: string;
1916
+ }
1917
+ /** AGT-8 / AGT-4. What an agent (or a person) proposes when a Field is missing. */
1918
+ interface FieldProposal {
1919
+ table_id: Uuid;
1920
+ key: string;
1921
+ label: string;
1922
+ type: FieldBehavior;
1923
+ multi?: boolean;
1924
+ required?: boolean;
1925
+ config?: Record<string, unknown>;
1926
+ relation_target?: Uuid;
1927
+ /** Why this Field should exist — what an approver reads before approving. */
1928
+ because: string;
1929
+ }
1930
+ /** AGT-8. What a table proposal looks like, same shape of question. */
1931
+ interface TableProposal {
1932
+ name: string;
1933
+ slug: string;
1934
+ title_field: string;
1935
+ fields: Array<Omit<FieldProposal, "table_id" | "because">>;
1936
+ because: string;
1937
+ }
1938
+
1939
+ /**
1940
+ * A rule expression as `custom.rule_eval` ACTUALLY evaluates it — read off the
1941
+ * door's own body, not invented here. A leaf is the node's name carrying its
1942
+ * payload (`{"const": 3}`, `{"field": "<uuid>"}`); an operator is
1943
+ * `{"op": "eq", "args": [...]}`.
1944
+ *
1945
+ * `field` / `parent_field` name a Field BY ID (REC-17 — the door refuses
1946
+ * `field_name`, `field_key` and `field_label` by name), and `merge_field` is
1947
+ * the resolver's seam, storable today and refused `0A000` until W5-MERGE-B.
1948
+ *
1949
+ * `p_values` is keyed by the Field's KEY: the door resolves the id to a key
1950
+ * (`custom.rule_field_key`) and then reads `p_values -> key`.
1951
+ */
1952
+ type RuleExpression = {
1953
+ const: unknown;
1954
+ } | {
1955
+ field: Uuid;
1956
+ } | {
1957
+ parent_field: Uuid;
1958
+ } | {
1959
+ merge_field: string;
1960
+ } | {
1961
+ op: RuleNodeKind;
1962
+ args: RuleExpression[];
1963
+ };
1964
+ /** REC-15. One Rule, four uses; a Rule may serve more than one. */
1965
+ interface Rule {
1966
+ id: Uuid;
1967
+ organization_id: Uuid;
1968
+ name: string;
1969
+ kind: string | null;
1970
+ /** The Table this Rule is scoped to. */
1971
+ scope_table_id: Uuid | null;
1972
+ uses: RuleUse[];
1973
+ validates: boolean;
1974
+ computes: boolean;
1975
+ defines_membership: boolean;
1976
+ /**
1977
+ * REC-16. An applicability Rule reads the record's own Values and its
1978
+ * parent's, ONE level up, and no further.
1979
+ */
1980
+ decides_applicability: boolean;
1981
+ applies_to_types: string[];
1982
+ use_types: string[];
1983
+ expr: RuleExpression;
1984
+ /** Which Field this Rule's answer is about (REC-17: by id). */
1985
+ target_field_id: Uuid | null;
1986
+ /** What a person reads when this Rule refuses. */
1987
+ message: string | null;
1988
+ sort: number | null;
1989
+ created_by: Uuid | null;
1990
+ updated_by: Uuid | null;
1991
+ created_at: Timestamp;
1992
+ updated_at: Timestamp;
1993
+ /** REC-19. Rules have versions, and History knows which one produced a Value. */
1994
+ version: number;
1995
+ metadata: Record<string, unknown>;
1996
+ visibility: string;
1997
+ }
1998
+ /** What the store answers when a Rule is run: the answer and the version that gave it. */
1999
+ interface RuleAnswer {
2000
+ rule_id: Uuid;
2001
+ rule_name: string;
2002
+ rule_version: number;
2003
+ applies: boolean;
2004
+ answer: unknown;
2005
+ }
2006
+
2007
+ /** The measures the store offers. Asked of `custom.agg_operations()` at run time too. */
2008
+ type AggregateOperation = "count" | "sum" | "avg" | "min" | "max";
2009
+ /** The periods a date Field can be bucketed into (`custom.agg_buckets()`). */
2010
+ type AggregateBucket = "day" | "week" | "month" | "quarter" | "year";
2011
+ /** One measure. `count` counts rows and needs no Field; the rest read one. */
2012
+ interface AggregateMeasure {
2013
+ op: AggregateOperation;
2014
+ /** The Field's key. Required for every operation except `count`. */
2015
+ key?: string;
2016
+ }
2017
+ /**
2018
+ * One row of an aggregate: which group it is, what each measure came to, and
2019
+ * how many records it was worked out from. The measure keys are the store's
2020
+ * own (`count`, `sum_amount`, `avg_amount`, …), never renamed on the way out.
2021
+ */
2022
+ interface AggregateRow {
2023
+ groups: Record<string, string | null>;
2024
+ measures: Record<string, number | null>;
2025
+ row_count: number;
2026
+ }
2027
+ /** The measure key the store answers with, so a chart can find its own series. */
2028
+ declare function measureKey(measure: AggregateMeasure): string;
2029
+
2030
+ /** One token found in a body, in the order it appears. */
2031
+ interface DocToken {
2032
+ ordinal: number;
2033
+ /** Exactly as it is written in the body. */
2034
+ raw: string;
2035
+ field_id: Uuid | null;
2036
+ }
2037
+ /** A token this Table cannot answer, with the store's own reason. */
2038
+ interface DocUnresolvedToken {
2039
+ raw: string;
2040
+ field_id: Uuid | null;
2041
+ /** The store's sentence. Shown verbatim — a template is not published over it. */
2042
+ why: string;
2043
+ }
2044
+ /** What the store says about a signature when it is asked whether it still holds. */
2045
+ interface DocSignatureCheck {
2046
+ intact: boolean;
2047
+ /** The store's own sentence when it is not. */
2048
+ reason?: string;
2049
+ signed_at?: Timestamp;
2050
+ }
2051
+ /** `custom.doc_template` — a body with tokens, and the Table it renders. */
2052
+ interface DocTemplateRow {
2053
+ id: Uuid;
2054
+ organization_id: Uuid;
2055
+ renders_table_id: Uuid;
2056
+ name: string;
2057
+ body: string;
2058
+ /** REC-68 / VAL-10: a seal is over a document VERSION, so the version is first-class. */
2059
+ template_version: number;
2060
+ token_count: number;
2061
+ updated_at: Timestamp;
2062
+ }
2063
+ /**
2064
+ * `custom.doc_render` — a rendered document, FROZEN. The bytes and their
2065
+ * SHA-256 are what a signature seals, which is why a render is never edited:
2066
+ * a further agreement is a further version with its own seal.
2067
+ */
2068
+ interface DocRenderRow {
2069
+ id: Uuid;
2070
+ template_id: Uuid;
2071
+ record_id: Uuid;
2072
+ table_id: Uuid;
2073
+ template_version: number;
2074
+ body: string;
2075
+ content_hash: string;
2076
+ rendered_at: Timestamp;
2077
+ }
2078
+ /** `custom.doc_signature` — one seal, immutable once made. */
2079
+ interface DocSignatureRow {
2080
+ id: Uuid;
2081
+ render_id: Uuid;
2082
+ record_id: Uuid;
2083
+ field_key: string;
2084
+ signer_name: string;
2085
+ signer_user_id: Uuid | null;
2086
+ signed_at: Timestamp;
2087
+ document_hash: string;
2088
+ document_version: number;
2089
+ }
2090
+
2091
+ /** `immediate` fires on the change; `digest` is collected and sent on a schedule. */
2092
+ type SubscriptionCadence = "immediate" | "digest";
2093
+ /** One subscription, exactly as `custom.agg_subscriptions` reports it. */
2094
+ interface Subscription {
2095
+ rule_id: Uuid;
2096
+ saved_view_id: Uuid | null;
2097
+ cadence: string;
2098
+ /** The digest's schedule. Null for `immediate`. */
2099
+ schedule: string | null;
2100
+ channel: string;
2101
+ /** Null means this subscription fires at nobody, and the store says so. */
2102
+ recipient_user_id: Uuid | null;
2103
+ event_key: string;
2104
+ name: string;
2105
+ }
2106
+ /** The `subscription` block a Rule record carries. Written through `record_write`. */
2107
+ interface SubscriptionBlock {
2108
+ saved_view_id: Uuid;
2109
+ cadence: SubscriptionCadence;
2110
+ schedule?: string | null;
2111
+ channel?: string;
2112
+ recipient_user_id?: Uuid | null;
2113
+ event_key?: string;
2114
+ }
2115
+
2116
+ /**
2117
+ * REL-6. Whether Visibility flows along this relation and the MAXIMUM access
2118
+ * level it carries. Default off on `referenced`, on for `owned`.
2119
+ */
2120
+ interface RelationCarries {
2121
+ carries: boolean;
2122
+ /** The ceiling — a relation never carries more access than this. */
2123
+ max_access: string | null;
2124
+ }
2125
+ /** The seven properties, each its own question. */
2126
+ interface RelationProperties {
2127
+ /** REL-1. Stored once on the contained table, read from the field's side. */
2128
+ flavor: RelationFlavor;
2129
+ /** REL-2. Separate from flavour. */
2130
+ on_delete: OnDelete;
2131
+ /** REL-3. A snapshot is a frozen copy in the relation's payload — never a pointer into History. */
2132
+ binding: RelationBinding;
2133
+ /** REL-4. */
2134
+ ordered: boolean;
2135
+ /** REL-5. */
2136
+ loops: "allowed" | "refused";
2137
+ /** REL-6. */
2138
+ carries: RelationCarries;
2139
+ /** REL-7. */
2140
+ cardinality: RelationCardinality;
2141
+ }
2142
+ /**
2143
+ * REL-8 / REL-N-1. A target is a REFERENCE, written that way from the first
2144
+ * line of code, because it may name a row outside our database. One Table,
2145
+ * several, or any — polymorphic without restriction. External targets are
2146
+ * read-only in v1.
2147
+ */
2148
+ type RelationTarget = {
2149
+ kind: "ours";
2150
+ entity_token: string;
2151
+ row_id: Uuid;
2152
+ } | {
2153
+ kind: "external";
2154
+ connection_token: string;
2155
+ external_table: string;
2156
+ external_key: string;
2157
+ } | {
2158
+ kind: "any";
2159
+ };
2160
+ /** One edge, as the store holds it in `platform.associations`. */
2161
+ interface Relation {
2162
+ id: Uuid;
2163
+ organization_id: Uuid;
2164
+ /** REL-10. The field key, which is what `role` holds. */
2165
+ role: string;
2166
+ source: RelationTarget;
2167
+ target: RelationTarget;
2168
+ properties: RelationProperties;
2169
+ /** REL-4. Meaningful only when `ordered`. */
2170
+ position: number | null;
2171
+ /** REL-3. The frozen copy, when `binding` is `snapshot`. */
2172
+ payload: Record<string, unknown> | null;
2173
+ /** REL-14. Hydrated from the target's title field AT READ — never stored. */
2174
+ label: string | null;
2175
+ created_at: Timestamp;
2176
+ updated_at: Timestamp;
2177
+ /** REL-13 / REL-16. Associations are versioned, so relation history exists. */
2178
+ version: number;
2179
+ }
2180
+ /**
2181
+ * DOOR-6. A query coordinate: "related to THIS, along THAT role, in that
2182
+ * direction". Any combination, and any subset of them.
2183
+ */
2184
+ interface RelationCoordinate {
2185
+ /** The record at the other end. */
2186
+ record_id: Uuid;
2187
+ /** The field key the edge carries as its role. Omit to mean any role. */
2188
+ role?: string;
2189
+ /** Which way to walk. `out` is this record's own relation fields. */
2190
+ direction?: "out" | "in" | "either";
2191
+ }
2192
+
2193
+ /**
2194
+ * DYN-14 / DYN-15. An ordered list of merge fields ENDING IN A LITERAL, or the
2195
+ * decision to block the turn, or a named absence. No unresolved value is ever
2196
+ * rendered blank or left as a literal placeholder.
2197
+ */
2198
+ type MissingBehavior = {
2199
+ kind: "fallback";
2200
+ chain: Array<{
2201
+ merge_field_key: string;
2202
+ } | {
2203
+ literal: unknown;
2204
+ }>;
2205
+ } | {
2206
+ kind: "block_turn";
2207
+ } | {
2208
+ kind: "named_absence";
2209
+ say: string;
2210
+ };
2211
+ /** DYN-16. Applied AFTER resolution, on the merge field and never on the Field. */
2212
+ interface MergeFieldTransform {
2213
+ /** e.g. `currency`, `upper`, `date`; the organization's own list. */
2214
+ name: string;
2215
+ options?: Record<string, unknown>;
2216
+ }
2217
+ /** DYN-1. A Record of the kernel Table `Merge Field`. */
2218
+ interface MergeField {
2219
+ id: Uuid;
2220
+ organization_id: Uuid;
2221
+ key: string;
2222
+ label: string;
2223
+ /** DYN-3. Exactly one of eight. Relationships and rules are NOT sources. */
2224
+ source: MergeFieldSource;
2225
+ /** DYN-4. What it resolves INTO. The consumer never learns which. */
2226
+ semantic_type: MergeFieldSemanticType;
2227
+ /** §A. Any number. Never fused into the source. */
2228
+ modifiers: MergeFieldModifier[];
2229
+ /**
2230
+ * DYN-12. Exactly one, and it drives the input surface. It OUTRANKS the
2231
+ * precedence ladder: `server_fixed` is not offered as an input at all, and a
2232
+ * value sent for one anyway is discarded and recorded — never merged.
2233
+ */
2234
+ override_policy: OverridePolicy;
2235
+ /**
2236
+ * DYN-13. Whether an override is POSSIBLE and WHO MAY perform it are two
2237
+ * settings. This is the second one: an access level or an organization role.
2238
+ */
2239
+ override_requires: string | null;
2240
+ /** DYN-16. */
2241
+ format: MergeFieldTransform | null;
2242
+ /** DYN-17. `inline`, `on_demand`, or `auto` by budget. A value in no tier is a defect. */
2243
+ delivery?: Delivery;
2244
+ /** DYN-14. Declared, always. */
2245
+ missing?: MissingBehavior;
2246
+ /**
2247
+ * What the source needs: for `record`, the starting record and the chain; for
2248
+ * `tool`, the connection token and the freshness ceiling (DYN-20); for
2249
+ * `literal`, the literal.
2250
+ */
2251
+ source_config: Record<string, unknown>;
2252
+ created_by: Uuid | null;
2253
+ updated_by: Uuid | null;
2254
+ created_at: Timestamp;
2255
+ updated_at: Timestamp;
2256
+ version: number;
2257
+ metadata: Record<string, unknown>;
2258
+ visibility: string;
2259
+ }
2260
+ /** DYN-8. The triple the RUN gets. Every audit question is answerable from it. */
2261
+ interface ResolutionTriple {
2262
+ record_id: Uuid | null;
2263
+ field_id: Uuid | null;
2264
+ value_version: number | null;
2265
+ }
2266
+ /** DYN-22. The one provenance row per merge field per turn. */
2267
+ interface MergeFieldProvenance {
2268
+ merge_field_id: Uuid;
2269
+ declared_source: MergeFieldSource;
2270
+ /** Which source actually answered — the fallback chain makes these differ. */
2271
+ actual_source: MergeFieldSource | null;
2272
+ record_id: Uuid | null;
2273
+ field_id: Uuid | null;
2274
+ value_version: number | null;
2275
+ rule_id: Uuid | null;
2276
+ rule_version: number | null;
2277
+ /** DYN-11. Who overrode it, and every LOSER of the ladder, not only the winner. */
2278
+ override_by: Uuid | null;
2279
+ losers?: Array<{
2280
+ source: MergeFieldSource;
2281
+ value: unknown;
2282
+ why_lost: string;
2283
+ }>;
2284
+ /** DYN-11/DYN-12. A value a client sent for a field it may not supply, discarded and recorded. */
2285
+ discarded_attempt?: {
2286
+ value: unknown;
2287
+ because: string;
2288
+ } | null;
2289
+ resolved_at: Timestamp;
2290
+ freshness: Freshness;
2291
+ outcome: string;
2292
+ }
2293
+ /**
2294
+ * What a consumer gets back. `pending` is a first-class answer, not a blank:
2295
+ * until the server's resolver exists, a merge field says so and says WHY
2296
+ * (AGT-N-7 — anything that could not be delivered is named, never omitted).
2297
+ */
2298
+ type MergeFieldResolution = {
2299
+ state: "resolved";
2300
+ /** The rendered string the prompt gets. */
2301
+ rendered: string;
2302
+ value: unknown;
2303
+ triple: ResolutionTriple;
2304
+ provenance: MergeFieldProvenance;
2305
+ } | {
2306
+ state: "absent";
2307
+ /** DYN-14's named absence — what the screen says instead of a blank. */
2308
+ say: string;
2309
+ reason: string;
2310
+ provenance: MergeFieldProvenance | null;
2311
+ } | {
2312
+ state: "pending";
2313
+ /** WHY it is pending, in the words a person can act on. Never empty. */
2314
+ reason: string;
2315
+ };
2316
+
2317
+ /**
2318
+ * One of the five states, as `custom.work_states()` lists them — with what it
2319
+ * may become next and whether it is the end. A screen that hardcoded these
2320
+ * would be a second source of truth for the one question the store answers.
2321
+ */
2322
+ interface WorkState {
2323
+ sort: number;
2324
+ name: string;
2325
+ terminal: boolean;
2326
+ next: string[];
2327
+ }
2328
+ /** One node of a template graph: a record-to-be, in a named Table, under a ref. */
2329
+ interface WorkTemplateNode {
2330
+ /** The name the graph refers to this node by, and the key an override is filed under. */
2331
+ ref: string;
2332
+ /** The Table the record lands in. */
2333
+ table: Uuid;
2334
+ /** The document it starts life with. An override merges on top at instantiation. */
2335
+ data?: Record<string, unknown>;
2336
+ }
2337
+ /** One edge. `owned` is what `custom.relation_own` makes; W1-REL owns the rest. */
2338
+ interface WorkTemplateRelation {
2339
+ from: string;
2340
+ to: string;
2341
+ kind?: string;
2342
+ }
2343
+ /**
2344
+ * THE WHOLE TEMPLATE, DECLARATIVELY. REC-70: the graph is created in ONE act
2345
+ * and judged before any of it is written, so an agent writes a twelve-step
2346
+ * checklist in a single call and a half-made checklist is not a state the store
2347
+ * can be in.
2348
+ */
2349
+ interface WorkGraph {
2350
+ nodes: WorkTemplateNode[];
2351
+ relations?: WorkTemplateRelation[];
2352
+ }
2353
+ /** What `custom.work_template_instantiate` answers: what it made, and how much. */
2354
+ interface WorkInstantiation {
2355
+ template_id: Uuid;
2356
+ /** The log row. Until W3-HIST lands, this row IS the log of the act, and says so. */
2357
+ instantiation_id: Uuid;
2358
+ records_created: number;
2359
+ relations_created: number;
2360
+ relation_kind: string;
2361
+ /** ref → the record it became, which is how a step finds its own record. */
2362
+ refs: Record<string, Uuid>;
2363
+ records: Uuid[];
2364
+ relations: Uuid[];
2365
+ ms?: number;
2366
+ }
2367
+ /** One row of `custom.work_whose_turn`: a record, whose turn it is, and where it is up to. */
2368
+ interface WorkTurn {
2369
+ record_id: Uuid;
2370
+ title: string | null;
2371
+ assignee_id: Uuid | null;
2372
+ turn: string | null;
2373
+ due_on: Timestamp | null;
2374
+ state: string | null;
2375
+ status: string | null;
2376
+ terminal: boolean | null;
2377
+ }
2378
+ /** A Field assignment is made of, as the store itself describes it. */
2379
+ interface WorkAssignmentField {
2380
+ key: string;
2381
+ label: string;
2382
+ spec: Record<string, unknown>;
2383
+ }
2384
+ /**
2385
+ * One hold on one slot. `expired` is the STORE's answer, not a clock comparison
2386
+ * a screen ran: a hold whose time is up is named as lapsed rather than quietly
2387
+ * disappearing, so a person can see why the slot came back.
2388
+ */
2389
+ interface WorkSlotHold {
2390
+ hold_id: Uuid;
2391
+ slot_key: string;
2392
+ holder: string;
2393
+ expires_at: Timestamp | null;
2394
+ expired: boolean;
2395
+ }
2396
+ /**
2397
+ * What an embed token is good for, from `custom.anon_token_verify`. A token
2398
+ * carries ONE decision: `read` or `write`, never both.
2399
+ */
2400
+ interface AnonTokenBinding {
2401
+ token_id: Uuid;
2402
+ organization_id: Uuid;
2403
+ form_id: Uuid | null;
2404
+ saved_view_id: Uuid | null;
2405
+ record_id: Uuid | null;
2406
+ mode: "read" | "write";
2407
+ }
2408
+
2409
+ /**
2410
+ * VIS-31. A signed-in OUTSIDER, with the reason in plain English.
2411
+ *
2412
+ * "No organization" cannot mean "no row in the membership table": signup mints
2413
+ * every account a PERSONAL organization, so under that reading nobody would
2414
+ * ever be external. It means no membership of a NON-personal organization, and
2415
+ * `iam.is_external_principal` says that once so no surface can invent a second
2416
+ * answer.
2417
+ */
2418
+ interface ExternalPrincipalCard {
2419
+ user_id: Uuid | null;
2420
+ /** The answer itself. */
2421
+ external: boolean;
2422
+ signed_in: boolean;
2423
+ /**
2424
+ * WHY, in the platform's own words — the sentence a portal shows instead of
2425
+ * an empty screen. `iam` writes it, not us, so the portal and the API and the
2426
+ * admin screen all say the same thing about the same person.
2427
+ */
2428
+ explanation: string;
2429
+ /** How many NON-personal organizations they belong to. Zero is what external means. */
2430
+ organization_memberships: number;
2431
+ [key: string]: unknown;
2432
+ }
2433
+ /** VIS-32. A record or a view bound to a public address, with a declared render mode. */
2434
+ interface PublishBinding {
2435
+ id: Uuid;
2436
+ slug: string;
2437
+ resource_type: string;
2438
+ resource_id: Uuid;
2439
+ organization_id: Uuid;
2440
+ render_mode: string;
2441
+ is_active: boolean;
2442
+ created_at?: Timestamp;
2443
+ [key: string]: unknown;
2444
+ }
2445
+ /**
2446
+ * What a SIGNED-OUT visitor resolves. An invented address, a revoked one and an
2447
+ * unpublished one all resolve to NOTHING — the same 404 — because an address
2448
+ * that answered differently for a revoked binding would be an existence oracle.
2449
+ *
2450
+ * `notice` is D-15's admission, carried on every read: nothing was scanned
2451
+ * before this was listed, and nothing here pretends otherwise.
2452
+ */
2453
+ interface ResolvedPublishBinding {
2454
+ slug: string;
2455
+ resource_type: string;
2456
+ resource_id: Uuid;
2457
+ organization_id: Uuid;
2458
+ render_mode: string;
2459
+ namespace: string | null;
2460
+ notice: string;
2461
+ }
2462
+
2463
+ /**
2464
+ * What KIND of refusal it was. The mapping from SQLSTATE to code lives in
2465
+ * `/core`, and it is checked against `STORE_REFUSAL_CODES` — the list of every
2466
+ * SQLSTATE the store's own bodies raise, generated from the live catalogue. A
2467
+ * code the store can raise and this union cannot name is a hole, and the
2468
+ * real-door suite fails on it.
2469
+ */
2470
+ type RecordsErrorCode =
2471
+ /** `PT409` — somebody else's write won. The record clock moved under you. */
2472
+ "stale_write"
2473
+ /** `42501` — a door. Either the schema is revoked, or the store is switched off, or this principal may not pass. */
2474
+ | "door"
2475
+ /** `23514` — a Rule, a shape guard, or a validation the store enforces refused it. */
2476
+ | "refused_by_rule"
2477
+ /** `22004` / `22023` — the call itself was malformed: a missing id, a patch that is not an object. */
2478
+ | "invalid_argument"
2479
+ /** `02000` — the record is not here (deleted, never existed, or another organization's). */
2480
+ | "not_found"
2481
+ /** `23503` — something it points at is not there. */
2482
+ | "missing_reference"
2483
+ /** `23505` — that thing is already here. */
2484
+ | "already_exists"
2485
+ /** `0A000` — the store does not do this yet, and says which part. */
2486
+ | "not_supported"
2487
+ /** `53400` / `22012` — the store ran out of something, or the arithmetic could not be done. */
2488
+ | "store_limit"
2489
+ /**
2490
+ * `40001` — the visibility snapshot this connection carries is older than a
2491
+ * write the reader has already observed, so the store refused to answer at
2492
+ * all rather than hand back something they just lost. Retry on a fresh
2493
+ * connection; it is the one refusal in this list that is worth repeating.
2494
+ */
2495
+ | "stale_read"
2496
+ /**
2497
+ * THE DOOR THAT DOES NOT EXIST YET. Not an error condition in the database —
2498
+ * this package asked for a door that is not in the live catalogue, so it
2499
+ * refused to guess. `door_absent` always names the door and the lane that
2500
+ * owns it; it is never a silent no-op and never an empty list.
2501
+ */
2502
+ | "door_absent"
2503
+ /**
2504
+ * `PGRST202` / `PGRST205` — PostgREST could not find the function or the
2505
+ * schema. The database this client is pointed at is not serving the record
2506
+ * store: the schema is not exposed, or the grants are not there.
2507
+ */
2508
+ | "store_not_served"
2509
+ /** Anything the mapper could not place. It still carries the store's own words. */
2510
+ | "internal";
2511
+ /** A refusal, in the store's own words. */
2512
+ interface RecordsError {
2513
+ code: RecordsErrorCode;
2514
+ /** THE STORE'S message, verbatim. Never paraphrased. */
2515
+ message: string;
2516
+ /** THE STORE'S hint, verbatim — this is where the remedy is written. */
2517
+ hint?: string;
2518
+ /** The SQLSTATE, so a caller can be exact when a code is not exact enough. */
2519
+ sqlstate?: string;
2520
+ /** Whatever the store put in DETAIL, parsed when it was json. */
2521
+ detail?: unknown;
2522
+ }
2523
+ type RecordsResult<T> = {
2524
+ ok: true;
2525
+ data: T;
2526
+ } | {
2527
+ ok: false;
2528
+ error: RecordsError;
2529
+ };
2530
+ /** Narrowing helper for hosts compiled without `strictNullChecks`. */
2531
+ declare function isRecordsErr<T>(result: RecordsResult<T>): result is {
2532
+ ok: false;
2533
+ error: RecordsError;
2534
+ };
2535
+ declare const ok: <T>(data: T) => RecordsResult<T>;
2536
+ declare const err: <T>(error: RecordsError) => RecordsResult<T>;
2537
+ /**
2538
+ * A `stale_write` carries everything the screen needs to show the conflict
2539
+ * rather than a toast: which version you wrote against, which one won, and the
2540
+ * value of every field you touched as it stands now. The store builds this and
2541
+ * this type is its shape — nothing is reconstructed on the client.
2542
+ */
2543
+ interface StaleWriteDetail {
2544
+ expected_version: number;
2545
+ current_version: number;
2546
+ contested_fields: Record<string, unknown>;
2547
+ }
2548
+ /** The parsed form of a `stale_write`, for `useRecordMutation`'s conflict state. */
2549
+ interface WriteConflict extends StaleWriteDetail {
2550
+ record_id: Uuid;
2551
+ /** The store's own sentence — what the screen shows. */
2552
+ message: string;
2553
+ /** The store's own remedy. */
2554
+ hint: string;
2555
+ }
2556
+ /**
2557
+ * The structural shape of a PostgREST failure as supabase-js resolves it: a
2558
+ * PLAIN OBJECT parsed from the response body, NOT an `Error`. Reading
2559
+ * `.message` off `instanceof Error` discards the real database message on every
2560
+ * genuine failure.
2561
+ */
2562
+ interface PgError {
2563
+ code?: string | null;
2564
+ message: string;
2565
+ details?: string | null;
2566
+ hint?: string | null;
2567
+ }
2568
+ /** What the validation mirror answers: the same sentence the trigger would raise. */
2569
+ interface PredictedRefusal {
2570
+ /** The field key the store would name, when it names one. */
2571
+ field_key?: string;
2572
+ /** The message the store's own body would raise, word for word. */
2573
+ message: string;
2574
+ hint?: string;
2575
+ sqlstate: string;
2576
+ /**
2577
+ * Which of the store's bodies would raise it, so a reader can go and check
2578
+ * that this mirror still tells the truth.
2579
+ */
2580
+ predicted_by: string;
2581
+ }
2582
+ /** VAL-5 / VAL-6, named so a caller can say which word was the problem. */
2583
+ interface ForbiddenEnvelopeWord {
2584
+ field_key: string;
2585
+ word: PerValueAccessWord;
2586
+ }
2587
+
2588
+ /**
2589
+ * The data seam: a structural subset of `SupabaseClient`. The package never
2590
+ * opens a database connection of its own and never holds a key — the HOST
2591
+ * supplies a client that already carries the operating person's session, which
2592
+ * is what makes DOOR-5 and AGT-N-4 true (the store sees the person, not us).
2593
+ */
2594
+ interface RecordsDataSource {
2595
+ /**
2596
+ * Call a door. The name is always a door the live catalogue has; `/core`
2597
+ * refuses `door_absent` before it ever reaches here for one that does not.
2598
+ */
2599
+ rpc(fn: string, args: Record<string, unknown>,
2600
+ /**
2601
+ * THE SCHEMA THE DOOR LIVES IN, always supplied: `custom` for the store's
2602
+ * own doors, `iam` for the trust doors (the external principal and the
2603
+ * publish binding, which are the PLATFORM's). A host binding supabase-js
2604
+ * routes this to `client.schema(options.schema).rpc(fn, args)`; a host that
2605
+ * ignores it calls its own default PostgREST profile — `public` — and is
2606
+ * refused by name, which is the failure we want rather than a silent answer
2607
+ * from the wrong system. (Before 2026-09-18 this was described as "only ever
2608
+ * `iam`" and the store's doors went unqualified; the extension's first real
2609
+ * turn proved that asks `public.store_is_open` and finds nothing.)
2610
+ */
2611
+ options?: {
2612
+ schema?: string;
2613
+ }): PromiseLike<{
2614
+ data: unknown;
2615
+ error: PgError | null;
2616
+ }>;
2617
+ /** Reads of `custom.*` go through the schema-qualified builder, never a bare `from`. */
2618
+ schema(name: string): {
2619
+ from(table: string): RecordsTableQuery;
2620
+ };
2621
+ }
2622
+ /** The read surface the list and query paths use. A real supabase-js client satisfies it. */
2623
+ interface RecordsTableQuery {
2624
+ select(columns: string, options?: {
2625
+ count?: "exact" | "planned" | "estimated";
2626
+ head?: boolean;
2627
+ }): RecordsFilter;
2628
+ }
2629
+ interface RecordsFilter extends PromiseLike<RecordsResponse> {
2630
+ eq(column: string, value: unknown): RecordsFilter;
2631
+ neq(column: string, value: unknown): RecordsFilter;
2632
+ in(column: string, values: readonly unknown[]): RecordsFilter;
2633
+ is(column: string, value: null | boolean): RecordsFilter;
2634
+ gte(column: string, value: unknown): RecordsFilter;
2635
+ lte(column: string, value: unknown): RecordsFilter;
2636
+ order(column: string, options?: {
2637
+ ascending?: boolean;
2638
+ }): RecordsFilter;
2639
+ range(from: number, to: number): RecordsFilter;
2640
+ limit(count: number): RecordsFilter;
2641
+ }
2642
+ interface RecordsResponse {
2643
+ data: unknown;
2644
+ error: PgError | null;
2645
+ count?: number | null;
2646
+ }
2647
+ /**
2648
+ * WHO IS ACTING. AGT-N-4: an agent carries the exact authority of the person
2649
+ * operating it — there is no agent identity and there are no service roles. So
2650
+ * the actor word and the person are two separate facts, and `on_behalf_of` is
2651
+ * meaningful only when the actor is `agent`.
2652
+ */
2653
+ interface RecordsActor {
2654
+ actor: Actor;
2655
+ /** The signed-in person. The store reads this from the session, not from us; this is for the client's own mirror. */
2656
+ user_id?: Uuid;
2657
+ /** Only an agent acts on behalf of a person (the store refuses it otherwise). */
2658
+ on_behalf_of?: Uuid;
2659
+ }
2660
+ /**
2661
+ * OPTIONAL. A live-updates seam. The default degradation is stated rather than
2662
+ * silent: with no port bound, `useRecords` reports `live: false` and the screen
2663
+ * can say "not live" instead of quietly going stale.
2664
+ *
2665
+ * A host binds this with `@ai-matrx/data/react`'s channel hygiene — the package
2666
+ * deliberately does NOT depend on it, so the headless core stays free of a
2667
+ * realtime client and a host that has one keeps using the one it already has.
2668
+ */
2669
+ interface RecordsRealtimePort {
2670
+ /**
2671
+ * Watch one organization's records of one table. Returns an unsubscribe. The
2672
+ * callback fires with the record id that changed; the hook re-reads through
2673
+ * the read door, because a realtime payload has NOT passed the door.
2674
+ */
2675
+ subscribeRecords(args: {
2676
+ organization_id: Uuid;
2677
+ table_id: Uuid;
2678
+ }, onChange: (recordId: Uuid) => void): () => void;
2679
+ }
2680
+ /**
2681
+ * OPTIONAL. Where a refusal that nobody asked about goes — the loud funnel.
2682
+ * Default degradation: `console.error` with the store's own words, never
2683
+ * silence.
2684
+ */
2685
+ type RecordsErrorSink = (error: {
2686
+ code: string;
2687
+ message: string;
2688
+ hint?: string;
2689
+ where: string;
2690
+ }) => void;
2691
+ /**
2692
+ * OPTIONAL. The merge-field resolver's server half (`W5-MERGE-B`). While it is
2693
+ * not bound, `useMergeField` answers `pending` WITH THE REASON — never a blank,
2694
+ * never a literal placeholder left in the text (DYN-14).
2695
+ */
2696
+ interface RecordsResolverPort {
2697
+ resolve(args: {
2698
+ organization_id: Uuid;
2699
+ merge_field_keys: string[];
2700
+ /** The live selection the `state` source reads (DYNAMIC-VALUES §C). */
2701
+ state?: Record<string, unknown>;
2702
+ }): Promise<unknown>;
2703
+ }
2704
+ /** The one config a host binds. */
2705
+ interface RecordsConfig {
2706
+ /** REQUIRED. */
2707
+ dataSource: RecordsDataSource;
2708
+ /** REQUIRED. */
2709
+ actor: RecordsActor;
2710
+ /**
2711
+ * REQUIRED. REC-29: organizations are hard walls, and the store is keyed
2712
+ * `(organization_id, id)`. There is no "current organization" this package
2713
+ * discovers for itself — the host says which one, every time.
2714
+ */
2715
+ organizationId: Uuid;
2716
+ realtime?: RecordsRealtimePort;
2717
+ onError?: RecordsErrorSink;
2718
+ resolver?: RecordsResolverPort;
2719
+ /**
2720
+ * The schema the record store lives in. Exists so a rehearsal branch and
2721
+ * production can differ without a fork; it is `custom` everywhere today.
2722
+ */
2723
+ schema?: string;
2724
+ }
2725
+
2726
+ /**
2727
+ * DOOR-8. As-of on EITHER clock, and they are different questions:
2728
+ * · `record` — the record clock: what this record looked like at version time.
2729
+ * · `world` — the world clock: which values were true of the world then
2730
+ * (the Field's `dated` modifier).
2731
+ */
2732
+ interface AsOf {
2733
+ clock: "record" | "world";
2734
+ at: Timestamp;
2735
+ }
2736
+ /** A predicate over a PROMOTED field (REC-5: promotion light -> heavy). */
2737
+ interface PromotedPredicate {
2738
+ field_key: string;
2739
+ /** The value as text, exactly as `custom.promoted_read` takes it. */
2740
+ equals: string;
2741
+ }
2742
+ interface RecordQuery {
2743
+ table_id: Uuid;
2744
+ /** DOOR-6. Any combination, any subset. An empty list means "no relation constraint". */
2745
+ relations?: RelationCoordinate[];
2746
+ /** Predicates the store can answer from an index. */
2747
+ promoted?: PromotedPredicate[];
2748
+ /** DOOR-8. */
2749
+ asOf?: AsOf;
2750
+ /** DOOR-9. Ask across EVERY Home of this Table in one answer. */
2751
+ acrossHomes?: boolean;
2752
+ /** REC-23. Soft-deleted rows are out unless you say otherwise. */
2753
+ includeDeleted?: boolean;
2754
+ /** FLD-10. */
2755
+ recordType?: string;
2756
+ orderBy?: {
2757
+ column: "created_at" | "updated_at";
2758
+ ascending?: boolean;
2759
+ };
2760
+ limit?: number;
2761
+ offset?: number;
2762
+ }
2763
+
2764
+ interface RecordsClient {
2765
+ /** The config this client was built with, so a screen can show who it is acting as. */
2766
+ readonly config: RecordsConfig;
2767
+ recordWrite(args: {
2768
+ table_id: Uuid;
2769
+ data: RecordDocument;
2770
+ }): Promise<RecordsResult<Uuid>>;
2771
+ recordUpdate(args: {
2772
+ record_id: Uuid;
2773
+ patch: Record<string, unknown>;
2774
+ /** Leave it out and the last writer wins; supply it and a loser is TOLD. */
2775
+ expectedVersion?: number;
2776
+ }): Promise<RecordsResult<number>>;
2777
+ /** REC-23. Soft, and reversible within `retention`. */
2778
+ recordDelete(args: {
2779
+ record_id: Uuid;
2780
+ }): Promise<RecordsResult<Timestamp>>;
2781
+ recordRestore(args: {
2782
+ record_id: Uuid;
2783
+ }): Promise<RecordsResult<void>>;
2784
+ recordRead(args: {
2785
+ record_id: Uuid;
2786
+ withComputed?: boolean;
2787
+ }): Promise<RecordsResult<RecordRead>>;
2788
+ /**
2789
+ * DOOR-1. A page of one Table's records THROUGH `custom.read_records`: the
2790
+ * store decides which rows this reader may see and which fields of them, and
2791
+ * a field it masked comes back present-and-null with its reason in `hidden`.
2792
+ * `total` is null because the door counts nothing it has not read — a count
2793
+ * of rows a person may not see is a leak with a number on it.
2794
+ */
2795
+ list(args: {
2796
+ table_id: Uuid;
2797
+ limit?: number;
2798
+ offset?: number;
2799
+ }): Promise<RecordsResult<{
2800
+ rows: ReadRow[];
2801
+ total: number | null;
2802
+ }>>;
2803
+ query(query: RecordQuery): Promise<RecordsResult<{
2804
+ rows: ReadRow[];
2805
+ total: number | null;
2806
+ }>>;
2807
+ tableList(): Promise<RecordsResult<Table[]>>;
2808
+ fields(args: {
2809
+ table_id: Uuid;
2810
+ recordType?: string;
2811
+ }): Promise<RecordsResult<Field[]>>;
2812
+ /**
2813
+ * FLD-5 / FLD-6: a list field stores the id of an option RECORD, because
2814
+ * every pick-list is already a Table. These are that Table's records — the
2815
+ * store resolves which Table from the Field's own config, so no caller has to
2816
+ * know it.
2817
+ */
2818
+ fieldOptions(args: {
2819
+ field_id: Uuid;
2820
+ }): Promise<RecordsResult<StoredRecord[]>>;
2821
+ tableCapacity(args: {
2822
+ table_id: Uuid;
2823
+ }): Promise<RecordsResult<TableCapacity>>;
2824
+ /**
2825
+ * REC-1: a Table has to live somewhere, so a Home comes first — and a Home is
2826
+ * an ordinary record in the person kernel. `homeId` is therefore required and
2827
+ * `personKernelId()` is how a caller gets a Table to write one into.
2828
+ */
2829
+ tableDeclare(args: {
2830
+ spec: Record<string, unknown>;
2831
+ homeId: Uuid;
2832
+ }): Promise<RecordsResult<Uuid>>;
2833
+ /** The kernel Tables a caller writes a Home, a Field or a Rule into. */
2834
+ personKernelId(): Promise<RecordsResult<Uuid>>;
2835
+ fieldKernelId(): Promise<RecordsResult<Uuid>>;
2836
+ ruleKernelId(): Promise<RecordsResult<Uuid>>;
2837
+ /** Every record the Rule says is a member. A saved view's list is this, not a filter a screen ran. */
2838
+ ruleMembers(args: {
2839
+ rule_id: Uuid;
2840
+ }): Promise<RecordsResult<StoredRecord[]>>;
2841
+ /** Is this one record a member, and WHY — the store's own answer. */
2842
+ ruleMembership(args: {
2843
+ rule_id: Uuid;
2844
+ record_id: Uuid;
2845
+ }): Promise<RecordsResult<unknown>>;
2846
+ /** Run a stored Rule against a document. */
2847
+ ruleRun(args: {
2848
+ rule_id: Uuid;
2849
+ values: Record<string, unknown>;
2850
+ context?: Record<string, unknown>;
2851
+ }): Promise<RecordsResult<unknown>>;
2852
+ /** Evaluate a Rule expression that has not been stored — the conditional logic a form runner asks about. */
2853
+ ruleEval(args: {
2854
+ expr: unknown;
2855
+ values: Record<string, unknown>;
2856
+ context?: Record<string, unknown>;
2857
+ }): Promise<RecordsResult<unknown>>;
2858
+ /**
2859
+ * Group, bucket, filter and measure INSIDE `custom.record_aggregate`. The
2860
+ * aggregate node sits above the visibility join, so what a chart draws is
2861
+ * exactly what this person may see — the rest is never fetched, let alone
2862
+ * summed and then hidden.
2863
+ */
2864
+ recordAggregate(args: {
2865
+ table_id: Uuid;
2866
+ /** Field keys whose values become the groups. */
2867
+ groupBy?: string[];
2868
+ /** `count` needs no key; every other operation reads one Field. */
2869
+ measures?: AggregateMeasure[];
2870
+ /** A date Field truncated to a period — a group whose expression is a date_trunc. */
2871
+ bucket?: {
2872
+ key: string;
2873
+ by: AggregateBucket;
2874
+ } | null;
2875
+ /** Equality only, and it lands in the SAME WHERE as visibility. */
2876
+ filter?: Record<string, string>;
2877
+ limit?: number;
2878
+ }): Promise<RecordsResult<AggregateRow[]>>;
2879
+ /** The measures the store itself offers. Asked, never hardcoded in a picker. */
2880
+ aggOperations(): Promise<RecordsResult<string[]>>;
2881
+ /** The periods the store itself buckets by. */
2882
+ aggBuckets(): Promise<RecordsResult<string[]>>;
2883
+ /**
2884
+ * Every subscription in this organization, optionally narrowed to one saved
2885
+ * view or one cadence. There is no subscription table: each one is a Rule
2886
+ * record carrying a `subscription` block, so a subscription is readable,
2887
+ * historied and agent-writable like anything else.
2888
+ */
2889
+ aggSubscriptions(args?: {
2890
+ saved_view_id?: Uuid | null;
2891
+ cadence?: string | null;
2892
+ }): Promise<RecordsResult<Subscription[]>>;
2893
+ /** The cadences the store itself offers. Asked, never hardcoded in a picker. */
2894
+ aggSubscriptionCadences(): Promise<RecordsResult<string[]>>;
2895
+ docTemplateSave(args: {
2896
+ table_id: Uuid;
2897
+ name: string;
2898
+ body: string;
2899
+ template_id?: Uuid | null;
2900
+ }): Promise<RecordsResult<Uuid>>;
2901
+ /** The body with every token resolved against one record. Read-only, no render row. */
2902
+ docRenderBody(args: {
2903
+ template_id: Uuid;
2904
+ record_id: Uuid;
2905
+ }): Promise<RecordsResult<string>>;
2906
+ /** Write the render — frozen bytes a signature can be checked against. */
2907
+ docRenderDocument(args: {
2908
+ template_id: Uuid;
2909
+ record_id: Uuid;
2910
+ }): Promise<RecordsResult<Uuid>>;
2911
+ /** Every token in a body, in order, with the Field id each one points at. */
2912
+ docTokens(args: {
2913
+ body: string;
2914
+ }): Promise<RecordsResult<DocToken[]>>;
2915
+ /** The tokens this Table cannot answer, each with the store's own reason. */
2916
+ docUnresolvedTokens(args: {
2917
+ table_id: Uuid;
2918
+ body: string;
2919
+ }): Promise<RecordsResult<DocUnresolvedToken[]>>;
2920
+ docSign(args: {
2921
+ render_id: Uuid;
2922
+ field_key: string;
2923
+ signer_name: string;
2924
+ signer_user_id?: Uuid | null;
2925
+ }): Promise<RecordsResult<Uuid>>;
2926
+ /** Is what was signed still what is there? The store answers, never the screen. */
2927
+ docSignatureIntact(args: {
2928
+ signature_id: Uuid;
2929
+ }): Promise<RecordsResult<unknown>>;
2930
+ /** Every template that renders one Table. */
2931
+ docTemplates(args: {
2932
+ table_id: Uuid;
2933
+ }): Promise<RecordsResult<DocTemplateRow[]>>;
2934
+ /** Every frozen render of one record, newest first. */
2935
+ docRenders(args: {
2936
+ record_id: Uuid;
2937
+ }): Promise<RecordsResult<DocRenderRow[]>>;
2938
+ /** Every signature on one record. */
2939
+ docSignatures(args: {
2940
+ record_id: Uuid;
2941
+ }): Promise<RecordsResult<DocSignatureRow[]>>;
2942
+ /**
2943
+ * DOOR-11. One record's revisions, newest first. The read door answers
2944
+ * documents and deliberately not versions, so a screen that wants to save
2945
+ * optimistically reads the version of the record it LOADED from here — for
2946
+ * the one record being edited, never for a list.
2947
+ */
2948
+ revisions(args: {
2949
+ record_id: Uuid;
2950
+ }): Promise<RecordsResult<RecordRevision[]>>;
2951
+ /**
2952
+ * Every value of one record WITH its envelope — its own version, who wrote
2953
+ * it, who they were acting for and when. The timeline IS the record (REC-19);
2954
+ * there is no second history table.
2955
+ */
2956
+ recordValuesVersioned(args: {
2957
+ record_id: Uuid;
2958
+ }): Promise<RecordsResult<ReadValue[]>>;
2959
+ metadataSearch(args: {
2960
+ text: string;
2961
+ }): Promise<RecordsResult<never>>;
2962
+ /**
2963
+ * Mint an embed token. `mode` is `read` OR `write` and never both — the store
2964
+ * refuses a token carrying two decisions. The secret comes back ONCE, because
2965
+ * only its digest is stored: a database read cannot produce a working token.
2966
+ * `allowedOrigins` is required and matched EXACTLY, so `example.com.evil.test`
2967
+ * fails a check that a suffix match would pass.
2968
+ */
2969
+ anonTokenIssue(args: {
2970
+ mode: "read" | "write";
2971
+ allowedOrigins: string[];
2972
+ formId?: Uuid | null;
2973
+ savedViewId?: Uuid | null;
2974
+ recordId?: Uuid | null;
2975
+ expiresAt?: Timestamp | null;
2976
+ }): Promise<RecordsResult<{
2977
+ token_id: Uuid;
2978
+ secret: string;
2979
+ }>>;
2980
+ /** What a secret is good for, from an origin. The store's sentence when it is not. */
2981
+ anonTokenVerify(args: {
2982
+ secret: string;
2983
+ origin: string;
2984
+ requiredMode?: "read" | "write" | null;
2985
+ }): Promise<RecordsResult<AnonTokenBinding>>;
2986
+ anonTokenRevoke(args: {
2987
+ token_id: Uuid;
2988
+ }): Promise<RecordsResult<boolean>>;
2989
+ /**
2990
+ * A STRANGER'S WRITE. The token supplies the organization, so this call names
2991
+ * none — and what it produces is a QUARANTINED SUBMISSION, not a record:
2992
+ * `custom.record` is never touched here. `clientKey` makes a replay free and
2993
+ * idempotent, which is what lets a flaky phone retry safely.
2994
+ */
2995
+ anonWrite(args: {
2996
+ secret: string;
2997
+ origin: string;
2998
+ payload: Record<string, unknown>;
2999
+ clientKey?: string | null;
3000
+ rawPayload?: Record<string, unknown>;
3001
+ }): Promise<RecordsResult<Uuid>>;
3002
+ /**
3003
+ * SCR-30, and it is the SIGNED-IN offline path, not the stranger's. The client
3004
+ * mints `clientKey` BEFORE the first attempt, offline, and the store's own
3005
+ * replay ledger dedupes on it — so a reconnect that fires the same capture
3006
+ * thirty times writes one record and returns the same id every time.
3007
+ */
3008
+ anonCapture(args: {
3009
+ table_id: Uuid;
3010
+ clientKey: string;
3011
+ payload: Record<string, unknown>;
3012
+ device?: string | null;
3013
+ capturedAt?: Timestamp | null;
3014
+ }): Promise<RecordsResult<Uuid>>;
3015
+ /** Open or close a form to strangers. An admin act on the Table, never an editor one. */
3016
+ anonPublish(args: {
3017
+ form_id: Uuid;
3018
+ published?: boolean;
3019
+ }): Promise<RecordsResult<Timestamp | null>>;
3020
+ /** The five states and what each one may become. Asked, never hardcoded in a picker. */
3021
+ workStates(): Promise<RecordsResult<WorkState[]>>;
3022
+ /** Why this graph would be refused — asked BEFORE it is written. `null` means it is fine. */
3023
+ workTemplateRefusal(args: {
3024
+ graph: WorkGraph;
3025
+ }): Promise<RecordsResult<string | null>>;
3026
+ workTemplateDeclare(args: {
3027
+ name: string;
3028
+ graph: WorkGraph;
3029
+ }): Promise<RecordsResult<Uuid>>;
3030
+ /**
3031
+ * REC-70: the WHOLE graph is created in one act, judged before any of it is
3032
+ * written, so a half-made checklist is not a state this store can be in.
3033
+ */
3034
+ workTemplateInstantiate(args: {
3035
+ template_id: Uuid;
3036
+ overrides?: Record<string, Record<string, unknown>>;
3037
+ }): Promise<RecordsResult<WorkInstantiation>>;
3038
+ workTemplateShape(args: {
3039
+ template_id: Uuid;
3040
+ }): Promise<RecordsResult<unknown>>;
3041
+ workInstantiationShape(args: {
3042
+ instantiation_id: Uuid;
3043
+ }): Promise<RecordsResult<unknown>>;
3044
+ /** Whose turn each record is, with its state and whether that state is terminal. */
3045
+ workWhoseTurn(args: {
3046
+ table_id: Uuid;
3047
+ includeFinished?: boolean;
3048
+ }): Promise<RecordsResult<WorkTurn[]>>;
3049
+ /** Does this Table carry assignment at all? A screen asks before it offers one. */
3050
+ workHasAssignment(args: {
3051
+ table_id: Uuid;
3052
+ }): Promise<RecordsResult<boolean>>;
3053
+ /** The Fields assignment is made of, so nothing here invents a column name. */
3054
+ workAssignmentFields(args?: {
3055
+ options_table_id?: Uuid | null;
3056
+ }): Promise<RecordsResult<WorkAssignmentField[]>>;
3057
+ /** Add assignment to a Table. */
3058
+ workTakeAssignment(args: {
3059
+ table_id: Uuid;
3060
+ }): Promise<RecordsResult<unknown>>;
3061
+ /** Why this move would be refused. `null` means it is allowed. */
3062
+ workTransitionRefusal(args: {
3063
+ from_state_id: Uuid;
3064
+ to_state_id: Uuid;
3065
+ }): Promise<RecordsResult<string | null>>;
3066
+ /** Declare the Table slots are held in. Idempotent — a second call finds the first. */
3067
+ workSlotsDeclare(args: {
3068
+ name: string;
3069
+ slug: string;
3070
+ homeId?: Uuid | null;
3071
+ }): Promise<RecordsResult<unknown>>;
3072
+ /**
3073
+ * SCR-29. Take a slot for a while. THE STORE decides, under a unique index —
3074
+ * two people racing for the same slot do not both get it, whatever either
3075
+ * screen believed a moment earlier.
3076
+ */
3077
+ workSlotHold(args: {
3078
+ table_id: Uuid;
3079
+ slotKey: string;
3080
+ holder: string;
3081
+ ttl?: string;
3082
+ }): Promise<RecordsResult<unknown>>;
3083
+ workSlotRelease(args: {
3084
+ hold_id: Uuid;
3085
+ }): Promise<RecordsResult<boolean>>;
3086
+ /** Every hold on this Table, with whether it has already lapsed. */
3087
+ workSlotHolds(args: {
3088
+ table_id: Uuid;
3089
+ }): Promise<RecordsResult<WorkSlotHold[]>>;
3090
+ workSlotExpire(args: {
3091
+ table_id: Uuid;
3092
+ }): Promise<RecordsResult<number>>;
3093
+ /** VIS-31. Is this account a signed-in outsider — no NON-personal organization? */
3094
+ isExternalPrincipal(args?: {
3095
+ user_id?: Uuid | null;
3096
+ }): Promise<RecordsResult<boolean>>;
3097
+ /** The same answer WITH the plain-English reason a screen shows. */
3098
+ externalPrincipalCard(args?: {
3099
+ user_id?: Uuid | null;
3100
+ }): Promise<RecordsResult<ExternalPrincipalCard>>;
3101
+ /** Exactly the resource ids Visibility gave that outsider. Never an organization's list. */
3102
+ externalPrincipalReach(args: {
3103
+ resourceType: string;
3104
+ user_id?: Uuid | null;
3105
+ }): Promise<RecordsResult<Array<{
3106
+ resource_id: Uuid;
3107
+ }>>>;
3108
+ /** VIS-32. Bind a record or a view to a public address with a declared render mode. */
3109
+ publishBindingCreate(args: {
3110
+ slug: string;
3111
+ resourceType: string;
3112
+ resource_id: Uuid;
3113
+ renderMode?: string;
3114
+ }): Promise<RecordsResult<PublishBinding>>;
3115
+ publishBindingRevoke(args: {
3116
+ slug: string;
3117
+ }): Promise<RecordsResult<unknown>>;
3118
+ /** What a SIGNED-OUT visitor resolves. Empty for an invented, revoked or unpublished address. */
3119
+ resolvePublishBinding(args: {
3120
+ slug: string;
3121
+ }): Promise<RecordsResult<ResolvedPublishBinding[]>>;
3122
+ /** D-15. The ONE sentence admitting nothing was scanned, so four surfaces cannot drift. */
3123
+ worldPublishGapNotice(): Promise<RecordsResult<string>>;
3124
+ /** Put a resource in the world lane. Refuses by name while the lane is closed. */
3125
+ publishToWorld(args: {
3126
+ resourceType: string;
3127
+ resource_id: Uuid;
3128
+ discoverable?: boolean;
3129
+ }): Promise<RecordsResult<unknown>>;
3130
+ /**
3131
+ * Declare a Rule. It is NOT `recordWrite` into the rule kernel, and that is
3132
+ * the whole point: `custom.record_write` inserts `data_class = 'record'`, so a
3133
+ * document written that way is not a Rule and the store's own rule doors
3134
+ * (`custom.rule_members`, `custom.agg_subscriptions`) never see it. Writing
3135
+ * one through the record door and calling it a Rule would be a silent
3136
+ * failure — a screen that looked like it had subscribed you to something.
3137
+ */
3138
+ ruleDeclare(args: {
3139
+ spec: Record<string, unknown>;
3140
+ }): Promise<RecordsResult<never>>;
3141
+ fieldPropose(proposal: FieldProposal): Promise<RecordsResult<never>>;
3142
+ tablePropose(proposal: TableProposal): Promise<RecordsResult<never>>;
3143
+ promoteTable(args: {
3144
+ table_id: Uuid;
3145
+ }): Promise<RecordsResult<unknown>>;
3146
+ promoteField(args: {
3147
+ table_id: Uuid;
3148
+ field_id: Uuid;
3149
+ }): Promise<RecordsResult<unknown>>;
3150
+ /** Is the store switched on for this organization? A product switch, never the boundary. */
3151
+ storeIsOpen(): Promise<RecordsResult<boolean>>;
3152
+ }
3153
+
3154
+ interface RecordsProviderProps {
3155
+ config: RecordsConfig;
3156
+ children: ReactNode;
3157
+ }
3158
+ declare function RecordsProvider({ config, children }: RecordsProviderProps): react.FunctionComponentElement<react.ProviderProps<RecordsClient | null>>;
3159
+ /**
3160
+ * The client, or a loud failure. A hook that quietly did nothing because nobody
3161
+ * mounted the provider is the silent failure this throws instead of.
3162
+ */
3163
+ declare function useRecordsClient(): RecordsClient;
3164
+ /** For a screen that wants to show who it is acting as (AGT-N-4). */
3165
+ declare function useRecordsActor(): RecordsActor;
3166
+
3167
+ interface Async<T> {
3168
+ data: T | null;
3169
+ loading: boolean;
3170
+ /** The store's own refusal. Never null-and-empty at the same time. */
3171
+ error: RecordsError | null;
3172
+ reload: () => void;
3173
+ }
3174
+ /** One Table's declaration. */
3175
+ declare function useTable(tableId: Uuid | null): Async<Table | null>;
3176
+ /** Every Table this person can see in this organization. */
3177
+ declare function useTables(): Async<Table[]>;
3178
+ /**
3179
+ * FLD-10. The Fields that APPLY — the store decides, from the record type, and
3180
+ * the client asks rather than filtering a list it has.
3181
+ */
3182
+ declare function useFields(tableId: Uuid | null, recordType?: string): Async<Field[]>;
3183
+ interface UseRecordsOptions {
3184
+ pageSize?: number;
3185
+ page?: number;
3186
+ }
3187
+ interface UseRecordsState extends Async<{
3188
+ rows: ReadRow[];
3189
+ total: number | null;
3190
+ }> {
3191
+ /**
3192
+ * Whether this list is actually live. FALSE with a reason is an answer a
3193
+ * screen can print; a list that silently stopped updating is not.
3194
+ */
3195
+ live: boolean;
3196
+ liveReason: string;
3197
+ }
3198
+ /** A page of records, realtime-aware when the host bound the port. */
3199
+ declare function useRecords(tableId: Uuid | null, options?: UseRecordsOptions): UseRecordsState;
3200
+ /** One record, its values and (optionally) which Rule version computed each. */
3201
+ declare function useRecord(recordId: Uuid | null, withComputed?: boolean): Async<RecordRead | null>;
3202
+ interface UseRecordMutation {
3203
+ write: (args: {
3204
+ table_id: Uuid;
3205
+ data: Record<string, unknown>;
3206
+ }) => Promise<Uuid | null>;
3207
+ update: (args: {
3208
+ record_id: Uuid;
3209
+ patch: Record<string, unknown>;
3210
+ expectedVersion?: number;
3211
+ }) => Promise<number | null>;
3212
+ remove: (args: {
3213
+ record_id: Uuid;
3214
+ }) => Promise<string | null>;
3215
+ restore: (args: {
3216
+ record_id: Uuid;
3217
+ }) => Promise<boolean>;
3218
+ saving: boolean;
3219
+ error: RecordsError | null;
3220
+ /**
3221
+ * THE CONFLICT, as something a screen can SHOW rather than a toast it flashes:
3222
+ * the version you wrote against, the version that won, and every field you
3223
+ * touched as it stands now. Nothing was overwritten and nothing was lost —
3224
+ * which is exactly what the store's own hint says, and it is carried here.
3225
+ */
3226
+ conflict: WriteConflict | null;
3227
+ clearConflict: () => void;
3228
+ }
3229
+ /** Writes, with optimistic concurrency surfaced instead of swallowed. */
3230
+ declare function useRecordMutation(): UseRecordMutation;
3231
+ /**
3232
+ * DYN-14 / AGT-N-7. A merge field's value — and while the resolver's server half
3233
+ * does not exist, `pending` WITH THE REASON. Never a blank, never a leftover
3234
+ * `{{brace}}`, never an empty string that a prompt would carry into a model.
3235
+ */
3236
+ declare function useMergeField(key: string | null, state?: Record<string, unknown>): MergeFieldResolution | null;
3237
+
3238
+ 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, RecordsProvider, type RecordsProviderProps, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type Subscription, type SubscriptionBlock, type SubscriptionCadence, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkAssignmentField, type WorkGraph, type WorkInstantiation, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, err, isRecordsErr, measureKey, ok, useFields, useMergeField, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };