@ai-matrx/records 0.5.1 → 0.7.2

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.
@@ -38,6 +38,7 @@ __export(react_exports, {
38
38
  ON_DELETE: () => ON_DELETE,
39
39
  OVERRIDE_POLICIES: () => OVERRIDE_POLICIES,
40
40
  PARITY_FIELD_TYPES: () => PARITY_FIELD_TYPES,
41
+ PERMISSION_LEVELS: () => PERMISSION_LEVELS,
41
42
  PER_VALUE_ACCESS_WORDS: () => PER_VALUE_ACCESS_WORDS,
42
43
  RELATION_BINDINGS: () => RELATION_BINDINGS,
43
44
  RELATION_CARDINALITIES: () => RELATION_CARDINALITIES,
@@ -55,12 +56,18 @@ __export(react_exports, {
55
56
  TABLE_TYPES: () => TABLE_TYPES,
56
57
  VALUE_ALTERNATE_KEYS: () => VALUE_ALTERNATE_KEYS,
57
58
  VALUE_ENVELOPE_KEYS: () => VALUE_ENVELOPE_KEYS,
59
+ asPermissionLevel: () => asPermissionLevel,
60
+ atLeast: () => atLeast,
58
61
  err: () => err,
62
+ highestLevel: () => highestLevel,
59
63
  isRecordsErr: () => isRecordsErr,
60
64
  measureKey: () => measureKey,
61
65
  ok: () => ok,
66
+ useFieldMutation: () => useFieldMutation,
62
67
  useFields: () => useFields,
63
68
  useMergeField: () => useMergeField,
69
+ useMyLevel: () => useMyLevel,
70
+ useMyLevels: () => useMyLevels,
64
71
  useRecord: () => useRecord,
65
72
  useRecordMutation: () => useRecordMutation,
66
73
  useRecords: () => useRecords,
@@ -74,6 +81,33 @@ module.exports = __toCommonJS(react_exports);
74
81
  // src/react/context.tsx
75
82
  var import_react = require("react");
76
83
 
84
+ // src/level.ts
85
+ var PERMISSION_LEVELS = [
86
+ "viewer",
87
+ "commenter",
88
+ "editor",
89
+ "admin"
90
+ ];
91
+ var ORDINAL = {
92
+ viewer: 1,
93
+ commenter: 2,
94
+ editor: 3,
95
+ admin: 4
96
+ };
97
+ function atLeast(held, needed) {
98
+ if (!held) return false;
99
+ const have = ORDINAL[held];
100
+ return have !== void 0 && have >= ORDINAL[needed];
101
+ }
102
+ function asPermissionLevel(word) {
103
+ return typeof word === "string" && word in ORDINAL ? word : null;
104
+ }
105
+ function highestLevel(left, right) {
106
+ if (!left) return right ?? null;
107
+ if (!right) return left;
108
+ return ORDINAL[left] >= ORDINAL[right] ? left : right;
109
+ }
110
+
77
111
  // src/results.ts
78
112
  function isRecordsErr(result) {
79
113
  return result.ok === false;
@@ -143,12 +177,14 @@ var STORE_DOORS = [
143
177
  { name: "absence_reasons", args: "", returns: "text[]", security: "invoker" },
144
178
  { name: "actor_vocabulary", args: "", returns: "text[]", security: "invoker" },
145
179
  { name: "actor_word", args: "p_declared text", returns: "text", security: "invoker" },
180
+ { name: "agent_change_approval", args: "p_organization uuid, p_conversation uuid DEFAULT NULL::uuid, p_table uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
146
181
  { name: "agent_context", args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 50", returns: "jsonb", security: "invoker" },
182
+ { name: "agent_table_claim", args: "p_organization uuid, p_table uuid, p_conversation uuid DEFAULT NULL::uuid", returns: "void", security: "definer" },
147
183
  { name: "agg_assert_key", args: "p_key text", returns: "text", security: "invoker" },
148
184
  { name: "agg_buckets", args: "", returns: "text[]", security: "invoker" },
149
185
  { name: "agg_deliver", 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", returns: "uuid", security: "invoker" },
150
186
  { name: "agg_digest_run", args: "p_organization_id uuid, p_rule_id uuid DEFAULT NULL::uuid, p_since timestamp with time zone DEFAULT NULL::timestamp with time zone", returns: "integer", security: "invoker" },
151
- { name: "agg_explain", 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", returns: "jsonb", security: "invoker" },
187
+ { name: "agg_explain", 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", returns: "jsonb", security: "definer" },
152
188
  { name: "agg_operations", args: "", returns: "text[]", security: "invoker" },
153
189
  { name: "agg_sql", 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", returns: "text", security: "invoker" },
154
190
  { name: "agg_subscription_cadences", args: "", returns: "text[]", security: "invoker" },
@@ -161,25 +197,35 @@ var STORE_DOORS = [
161
197
  { name: "anon_inbound_land", args: "p_address text, p_secret text, p_payload jsonb, p_raw_payload jsonb DEFAULT '{}'::jsonb, p_client_key text DEFAULT NULL::text", returns: "uuid", security: "definer" },
162
198
  { name: "anon_publish", args: "p_organization_id uuid, p_form_id uuid, p_published boolean DEFAULT true", returns: "timestamp with time zone", security: "definer" },
163
199
  { name: "anon_rate_take", args: "p_organization_id uuid, p_form_id uuid, p_bucket text, p_token_id uuid DEFAULT NULL::uuid", returns: "integer", security: "definer" },
200
+ { name: "anon_submissions", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_state text DEFAULT NULL::text, p_limit integer DEFAULT 100, p_offset integer DEFAULT 0", returns: "TABLE(id uuid, form_id uuid, inbound_id uuid, table_id uuid, source text, state text, payload jsonb, raw_payload jsonb, client_key text, record_id uuid, remote_origin text, rejection_reason text, created_at timestamp with time zone, cleared_at timestamp with time zone)", security: "definer" },
164
201
  { name: "anon_token_issue", 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", returns: "TABLE(token_id uuid, secret text)", security: "definer" },
165
202
  { name: "anon_token_revoke", args: "p_organization_id uuid, p_token_id uuid", returns: "boolean", security: "definer" },
166
203
  { name: "anon_token_verify", args: "p_secret text, p_origin text, p_required_mode text", returns: "TABLE(token_id uuid, organization_id uuid, form_id uuid, saved_view_id uuid, record_id uuid, mode text)", security: "definer" },
167
204
  { name: "anon_write", args: "p_secret text, p_origin text, p_payload jsonb, p_client_key text DEFAULT NULL::text, p_raw_payload jsonb DEFAULT '{}'::jsonb", returns: "uuid", security: "definer" },
168
205
  { name: "applicable_fields", args: "p_organization_id uuid, p_table_id uuid, p_record_type text DEFAULT NULL::text", returns: "SETOF custom.record", security: "definer" },
169
206
  { name: "assert_client_may_change", args: "p_organization_id uuid, p_subject_id uuid, p_door text, p_required permission_level DEFAULT 'editor'::permission_level, p_subject_word text DEFAULT 'record'::text", returns: "void", security: "invoker" },
207
+ { name: "assert_client_may_open", args: "p_organization_id uuid, p_subject_id uuid, p_door text, p_required permission_level DEFAULT 'viewer'::permission_level, p_subject_word text DEFAULT 'record'::text", returns: "void", security: "invoker" },
170
208
  { name: "assert_client_may_reach", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
209
+ { name: "assert_may_know_table", args: "p_organization_id uuid, p_table_id uuid, p_door text", returns: "void", security: "invoker" },
210
+ { name: "assert_organization_admin", args: "p_organization_id uuid, p_door text, p_what text", returns: "void", security: "invoker" },
171
211
  { name: "assert_organization_wall", args: "p_kind text, p_organization_id uuid, p_row jsonb", returns: "void", security: "invoker" },
172
212
  { name: "assert_store_door", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
173
213
  { name: "bump_epoch", args: "p_entity_type text, p_entity_id uuid, p_organization_id uuid DEFAULT NULL::uuid", returns: "bigint", security: "definer" },
174
214
  { name: "cache_lookup", args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid", returns: "permission_level", security: "definer" },
175
215
  { name: "caller_role", args: "", returns: "name", security: "invoker" },
216
+ { name: "carrying_edges_in", args: "p_organization_id uuid", returns: "TABLE(container_type text, container_id uuid, item_type text, item_id uuid, conveys_max permission_level)", security: "definer" },
217
+ { name: "carrying_edges_of", args: "p_item_type text, p_item_id uuid", returns: "TABLE(container_type text, container_id uuid, conveys_max permission_level)", security: "definer" },
176
218
  { name: "client_write_grants", args: "", returns: "TABLE(role_name text, object_name text, privilege text)", security: "invoker" },
177
219
  { name: "computed_provenance", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(field_key text, field_id uuid, value jsonb, rule_id uuid, rule_version integer, computed_at timestamp with time zone)", security: "invoker" },
178
220
  { name: "containment_chain", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(ancestor_id uuid, depth integer)", security: "invoker" },
179
221
  { name: "containment_depth_ceiling", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "integer", security: "invoker" },
180
222
  { name: "containment_edges", args: "p_organization_id uuid", returns: "TABLE(parent_id uuid, child_id uuid, via text)", security: "invoker" },
181
223
  { name: "containment_parent", args: "p_data jsonb", returns: "uuid", security: "invoker" },
224
+ { name: "cross_organization_links_open", args: "p_source_organization_id uuid, p_target_organization_id uuid", returns: "boolean", security: "invoker" },
182
225
  { name: "custom_fields_tables", args: "", returns: "TABLE(token text, schema_name text, table_name text)", security: "invoker" },
226
+ { name: "delete_cascade_closure", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid[]", security: "invoker" },
227
+ { name: "delete_preview", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
228
+ { name: "delete_rule", args: "p_organization_id uuid, p_record_id uuid, p_apply boolean DEFAULT true", returns: "jsonb", security: "definer" },
183
229
  { name: "dependency_cycle", args: "p_organization_id uuid, p_row custom.record", returns: "text[]", security: "invoker" },
184
230
  { name: "dependency_label", args: "p_organization_id uuid, p_node text", returns: "text", security: "invoker" },
185
231
  { name: "derive_visibility", args: "p_container_type text, p_container_id uuid", returns: "TABLE(item_type text, item_id uuid, depth integer, max_level permission_level)", security: "definer" },
@@ -211,16 +257,26 @@ var STORE_DOORS = [
211
257
  { name: "external_tier_contract", args: "", returns: "jsonb", security: "definer" },
212
258
  { name: "external_write_through", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb", returns: "void", security: "definer" },
213
259
  { name: "external_writes_set", args: "p_organization_id uuid, p_source_id uuid, p_enabled boolean", returns: "boolean", security: "definer" },
214
- { name: "field_dependants", args: "p_organization_id uuid, p_field_id uuid", returns: "TABLE(kind text, dependant_id uuid, label text, how text)", security: "invoker" },
260
+ { name: "field_behaviour", args: "p_field_data jsonb", returns: "text", security: "invoker" },
261
+ { name: "field_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
262
+ { name: "field_dependants", args: "p_organization_id uuid, p_field_id uuid", returns: "TABLE(kind text, dependant_id uuid, label text, how text)", security: "definer" },
215
263
  { name: "field_kernel_id", args: "", returns: "uuid", security: "invoker" },
216
- { name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "invoker" },
264
+ { name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "definer" },
265
+ { name: "field_retire", args: "p_organization_id uuid, p_field_id uuid", returns: "boolean", security: "definer" },
217
266
  { name: "field_rules", args: "p_field_data jsonb", returns: "TABLE(kind text, spec jsonb)", security: "invoker" },
267
+ { name: "field_update", args: "p_organization_id uuid, p_field_id uuid, p_patch jsonb", returns: "uuid", security: "definer" },
268
+ { name: "field_value_convert", args: "p_to jsonb, p_value jsonb", returns: "jsonb", security: "invoker" },
218
269
  { name: "file_kernel_id", args: "", returns: "uuid", security: "invoker" },
219
270
  { name: "formula_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb, p_values jsonb DEFAULT NULL::jsonb", returns: "jsonb", security: "invoker" },
271
+ { name: "guard_refusals_are_complete", args: "", returns: "TABLE(guard text, said text)", security: "invoker" },
220
272
  { name: "has_visibility", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
221
273
  { name: "has_visibility_at", 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", returns: "boolean", security: "definer" },
222
274
  { name: "hidden_field_notice", args: "p_field custom.record, p_action text DEFAULT 'read'::text", returns: "jsonb", security: "invoker" },
223
- { name: "home_add", args: "p_organization_id uuid, p_table_id uuid, p_home_record_id uuid", returns: "uuid", security: "invoker" },
275
+ { name: "history_prune", args: "p_organization_id uuid, p_scope text DEFAULT 'values'::text, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true", returns: "jsonb", security: "definer" },
276
+ { name: "history_retention", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
277
+ { name: "history_retention_floor_raise", args: "p_organization_id uuid, p_days integer", returns: "integer", security: "definer" },
278
+ { name: "history_retention_set", args: "p_organization_id uuid, p_table_id uuid, p_days integer", returns: "integer", security: "definer" },
279
+ { name: "home_add", args: "p_organization_id uuid, p_table_id uuid, p_home_record_id uuid", returns: "uuid", security: "definer" },
224
280
  { name: "home_relations", args: "", returns: "TABLE(table_id uuid, home_record_id uuid, organization_id uuid, relation_id uuid)", security: "invoker" },
225
281
  { name: "index_payload", args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000", returns: "TABLE(id uuid, searchable text)", security: "invoker" },
226
282
  { name: "intern_provenance", args: "p_data jsonb", returns: "jsonb", security: "invoker" },
@@ -232,7 +288,7 @@ var STORE_DOORS = [
232
288
  { name: "io_csv_escape", args: "p_value text, p_delimiter text DEFAULT ','::text", returns: "text", security: "invoker" },
233
289
  { name: "io_csv_parse", args: "p_text text, p_delimiter text DEFAULT NULL::text", returns: "TABLE(row_number integer, cells text[])", security: "invoker" },
234
290
  { name: "io_export", 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", returns: "jsonb", security: "definer" },
235
- { name: "io_export_csv", 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", returns: "text", security: "definer" },
291
+ { name: "io_export_csv", args: "p_organization_id uuid, p_table_id uuid, p_columns text[] DEFAULT NULL::text[], p_limit integer DEFAULT 10000, p_delimiter text DEFAULT chr(44), p_required text DEFAULT 'viewer'::text", returns: "text", security: "definer" },
236
292
  { name: "io_import_open", 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", returns: "uuid", security: "definer" },
237
293
  { name: "io_import_rows", args: "p_organization_id uuid, p_import_id uuid, p_rows jsonb, p_mapping jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "definer" },
238
294
  { name: "io_infer_type", args: "p_samples jsonb", returns: "text", security: "invoker" },
@@ -243,23 +299,30 @@ var STORE_DOORS = [
243
299
  { name: "io_proposal_reject", args: "p_organization_id uuid, p_import_id uuid, p_column text", returns: "boolean", security: "definer" },
244
300
  { name: "io_record_changed", args: "", returns: "trigger", security: "definer" },
245
301
  { name: "io_restore", args: "p_organization_id uuid, p_record_id uuid, p_version integer", returns: "integer", security: "definer" },
246
- { name: "io_revisions", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(version integer, changed_at timestamp with time zone, changed_by uuid, summary text)", security: "definer" },
302
+ { name: "io_revisions", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(version integer, changed_at timestamp with time zone, changed_by uuid, summary text, operation text, changed_fields jsonb)", security: "definer" },
303
+ { name: "is_a_retirement", args: "p_old_deleted timestamp with time zone, p_new_deleted timestamp with time zone, p_old_data jsonb, p_new_data jsonb, p_old_table uuid, p_new_table uuid, p_old_org uuid, p_new_org uuid, p_old_class text, p_new_class text", returns: "boolean", security: "invoker" },
247
304
  { name: "lookup_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb", returns: "jsonb", security: "invoker" },
248
305
  { name: "mask_document", args: "p_document jsonb, p_visible_keys text[], p_notices jsonb, p_by_id boolean DEFAULT false, p_key_ids jsonb DEFAULT '{}'::jsonb", returns: "jsonb", security: "invoker" },
249
306
  { name: "mask_document", 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[]", returns: "jsonb", security: "invoker" },
250
307
  { name: "merge_field_kernel_id", args: "", returns: "uuid", security: "invoker" },
251
- { name: "migrate_delete", args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
252
- { name: "migrate_demote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
253
- { name: "migrate_extract_parent", args: "p_organization_id uuid, p_id uuid, p_parent_table_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
254
- { name: "migrate_merge", args: "p_organization_id uuid, p_winner_id uuid, p_loser_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
255
- { name: "migrate_promote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
256
- { name: "migrate_purge", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true", returns: "jsonb", security: "invoker" },
257
- { name: "migrate_rename", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
258
- { name: "migrate_reparent", args: "p_organization_id uuid, p_id uuid, p_parent_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
259
- { name: "migrate_retype", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
260
- { name: "migrate_split", args: "p_organization_id uuid, p_record_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
308
+ { name: "migrate_delete", args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
309
+ { name: "migrate_demote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
310
+ { name: "migrate_extract_parent", args: "p_organization_id uuid, p_id uuid, p_parent_table_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
311
+ { name: "migrate_merge", args: "p_organization_id uuid, p_winner_id uuid, p_loser_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
312
+ { name: "migrate_promote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
313
+ { name: "migrate_purge", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_dry_run boolean DEFAULT true", returns: "jsonb", security: "definer" },
314
+ { name: "migrate_rename", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
315
+ { name: "migrate_reparent", args: "p_organization_id uuid, p_id uuid, p_parent_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
316
+ { name: "migrate_retype", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
317
+ { name: "migrate_split", args: "p_organization_id uuid, p_record_id uuid, p_moved_keys text[], p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
318
+ { name: "migrate_undo", args: "p_organization_id uuid, p_log_id uuid", returns: "jsonb", security: "definer" },
319
+ { name: "migrations", args: "p_organization_id uuid, p_target_id uuid DEFAULT NULL::uuid, p_limit integer DEFAULT 100", returns: "TABLE(id uuid, verb text, target_kind text, target_id uuid, note text, applied_at timestamp with time zone, applied_by uuid, undone_at timestamp with time zone)", security: "definer" },
320
+ { name: "my_level", args: "p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text", returns: "permission_level", security: "definer" },
321
+ { name: "my_levels", args: "p_organization_id uuid, p_ids jsonb, p_type text DEFAULT 'record'::text", returns: "TABLE(id uuid, level permission_level)", security: "definer" },
261
322
  { name: "organization_kernel_id", args: "", returns: "uuid", security: "invoker" },
262
323
  { name: "organization_references", args: "p_kind text, p_organization_id uuid, p_row jsonb", returns: "TABLE(site text, what text, ref_id uuid, openable boolean)", security: "invoker" },
324
+ { name: "owning_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "invoker" },
325
+ { name: "owning_table_gone", args: "p_organization_id uuid, p_record_id uuid", returns: "boolean", security: "invoker" },
263
326
  { name: "parity_field_types", args: "", returns: "TABLE(parity_type text, behavior text, made_of text)", security: "invoker" },
264
327
  { name: "parity_type", args: "p_field_data jsonb", returns: "text", security: "invoker" },
265
328
  { name: "parity_values", args: "p_organization_id uuid, p_record_id uuid", 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)", security: "invoker" },
@@ -279,38 +342,53 @@ var STORE_DOORS = [
279
342
  { name: "promoted_value_path", args: "p_field_data jsonb", returns: "text", security: "invoker" },
280
343
  { name: "promotion_inline_ceiling", args: "", returns: "integer", security: "invoker" },
281
344
  { name: "query_access_ids", args: "p_organization_id uuid, p_required text DEFAULT 'viewer'::text", returns: "uuid[]", security: "invoker" },
282
- { name: "query_across_homes", 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", returns: "TABLE(record_id uuid, home_record_id uuid, data jsonb, created_at timestamp with time zone)", security: "invoker" },
283
- { name: "query_by_coordinates", 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", returns: "TABLE(record_id uuid, table_id uuid, data jsonb, coordinates_matched integer)", security: "invoker" },
284
- { name: "query_can_see", args: "p_organization_id uuid, p_record_id uuid, p_required text DEFAULT 'viewer'::text", returns: "boolean", security: "invoker" },
345
+ { name: "query_across_homes", 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", returns: "TABLE(record_id uuid, home_record_id uuid, data jsonb, created_at timestamp with time zone)", security: "definer" },
346
+ { name: "query_by_coordinates", 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", returns: "TABLE(record_id uuid, table_id uuid, data jsonb, coordinates_matched integer)", security: "definer" },
347
+ { name: "query_can_see", args: "p_organization_id uuid, p_record_id uuid, p_required text DEFAULT 'viewer'::text", returns: "boolean", security: "definer" },
285
348
  { name: "query_hot_paths", args: "", returns: "TABLE(name text, statement text)", security: "invoker" },
286
349
  { name: "query_hot_paths_prepared", args: "", returns: "TABLE(name text, prepared boolean, generic_plans bigint)", security: "invoker" },
287
350
  { name: "query_is_store_owner", args: "", returns: "boolean", security: "invoker" },
288
351
  { name: "query_prepare_hot", args: "", returns: "integer", security: "invoker" },
289
352
  { name: "query_principal", args: "", returns: "uuid", security: "invoker" },
290
- { name: "query_record_as_of", 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", returns: "jsonb", security: "invoker" },
291
- { name: "query_relation_edges", args: "p_organization_id uuid, p_flavor text DEFAULT NULL::text, p_role text DEFAULT NULL::text", returns: "TABLE(parent_id uuid, child_id uuid, role text, flavor text)", security: "invoker" },
292
- { name: "query_rollup", 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", returns: "TABLE(record_id uuid, depth integer)", security: "invoker" },
293
- { name: "query_rollup_sum", 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", returns: "numeric", security: "invoker" },
294
- { name: "query_table_as_of", 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", returns: "TABLE(record_id uuid, data jsonb)", security: "invoker" },
295
- { name: "query_table_homes", args: "p_organization_id uuid, p_table_id uuid", returns: "SETOF uuid", security: "invoker" },
296
- { name: "query_visible_ids", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_required text DEFAULT 'viewer'::text", returns: "SETOF uuid", security: "invoker" },
353
+ { name: "query_record_as_of", 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", returns: "jsonb", security: "definer" },
354
+ { name: "query_relation_edges", args: "p_organization_id uuid, p_flavor text DEFAULT NULL::text, p_role text DEFAULT NULL::text", returns: "TABLE(parent_id uuid, child_id uuid, role text, flavor text)", security: "definer" },
355
+ { name: "query_rollup", 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", returns: "TABLE(record_id uuid, depth integer)", security: "definer" },
356
+ { name: "query_rollup_sum", 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", returns: "numeric", security: "definer" },
357
+ { name: "query_table_as_of", 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", returns: "TABLE(record_id uuid, data jsonb)", security: "definer" },
358
+ { name: "query_table_homes", args: "p_organization_id uuid, p_table_id uuid", returns: "SETOF uuid", security: "definer" },
359
+ { name: "query_visibility_parity", args: "p_organization_id uuid", 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)", security: "definer" },
360
+ { name: "query_visible_ids", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid, p_required text DEFAULT 'viewer'::text", returns: "SETOF uuid", security: "definer" },
297
361
  { name: "reachable_from", args: "p_organization_id uuid, p_roots uuid[]", returns: "TABLE(record_id uuid, depth integer, via text)", security: "invoker" },
362
+ { name: "reaches_directly", args: "p_user_id uuid, p_type text, p_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "boolean", security: "definer" },
363
+ { name: "read_door_carried_ids", args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level, OUT o_ids uuid[], OUT o_containers integer", returns: "record", security: "definer" },
364
+ { name: "read_door_granted_ids", args: "p_organization_id uuid, p_table_id uuid", returns: "uuid[]", security: "definer" },
365
+ { name: "read_door_ladder_ceiling", args: "", returns: "integer", security: "invoker" },
366
+ { name: "read_door_parity", args: "p_organization_id uuid, p_table_id uuid, p_user uuid, p_required permission_level, p_sample integer", returns: "TABLE(record_id uuid, set_based boolean, per_row boolean, verdict text)", security: "definer" },
298
367
  { name: "read_paths_outside_the_door", args: "", returns: "TABLE(object_name text, why text)", security: "invoker" },
299
368
  { name: "read_record", args: "p_organization_id uuid, p_record_id uuid, p_by_id boolean DEFAULT false", returns: "jsonb", security: "definer" },
300
369
  { name: "read_records", 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", returns: "TABLE(id uuid, document jsonb, level permission_level)", security: "definer" },
301
- { name: "record_aggregate", 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", returns: "TABLE(groups jsonb, measures jsonb, row_count bigint)", security: "invoker" },
370
+ { name: "record_aggregate", 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", returns: "TABLE(groups jsonb, measures jsonb, row_count bigint)", security: "definer" },
302
371
  { name: "record_applicability", args: "p_organization_id uuid, p_record_id uuid", returns: "TABLE(rule_id uuid, rule_name text, rule_version integer, applies boolean, answer jsonb)", security: "invoker" },
372
+ { name: "record_as_of", args: "p_organization_id uuid, p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
373
+ { name: "record_card", args: "p_viewer uuid, p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
374
+ { name: "record_carrying_edges", args: "p_id uuid, p_data_class text, p_data jsonb, p_deleted_at timestamp with time zone", returns: "TABLE(container_id uuid, item_id uuid, edge_role text)", security: "invoker" },
303
375
  { name: "record_delete", args: "p_organization_id uuid, p_record_id uuid", returns: "timestamp with time zone", security: "definer" },
304
- { name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "invoker" },
376
+ { name: "record_relation_edges", args: "p_organization_id uuid, p_id uuid, p_table_id uuid, p_data_class text, p_data jsonb, p_deleted_at timestamp with time zone", returns: "TABLE(target_id uuid, edge_role text, field_id uuid, ord integer)", security: "invoker" },
377
+ { name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
378
+ { name: "record_resolve", args: "p_organization_id uuid, p_id uuid", returns: "jsonb", security: "definer" },
305
379
  { name: "record_restore", args: "p_organization_id uuid, p_record_id uuid", returns: "void", security: "definer" },
380
+ { name: "record_state_as_of", args: "p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
306
381
  { name: "record_update", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb, p_expected_version integer DEFAULT NULL::integer", returns: "integer", security: "definer" },
307
382
  { name: "record_values", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
308
- { name: "record_values_versioned", args: "p_organization_id uuid, p_record_id uuid", 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)", security: "invoker" },
383
+ { name: "record_values_versioned", args: "p_organization_id uuid, p_record_id uuid", 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)", security: "definer" },
309
384
  { name: "record_write", args: "p_organization_id uuid, p_table_id uuid, p_data jsonb", returns: "uuid", security: "definer" },
310
- { name: "relation_own", args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid", returns: "uuid", security: "invoker" },
385
+ { name: "relation_carry", args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid", returns: "uuid", security: "definer" },
386
+ { name: "relation_own", args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid", returns: "uuid", security: "definer" },
387
+ { name: "relation_target_card", args: "p_organization_id uuid, p_record_id uuid, p_via_key text DEFAULT NULL::text", returns: "TABLE(target_id uuid, target_organization_id uuid, is_foreign boolean, masked boolean, reader_level permission_level, card jsonb, why text)", security: "definer" },
311
388
  { name: "relation_target_external", args: "p_connection_token text, p_external_table text, p_external_key text", returns: "jsonb", security: "definer" },
312
389
  { name: "relation_target_ours", args: "p_entity_token text, p_row_id uuid", returns: "jsonb", security: "definer" },
313
- { name: "relation_targets", args: "p_organization_id uuid, p_record_id uuid, p_via_key text", returns: "SETOF uuid", security: "invoker" },
390
+ { name: "relation_targets", args: "p_organization_id uuid, p_record_id uuid, p_via_key text", returns: "SETOF uuid", security: "definer" },
391
+ { name: "relation_uncarry", args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid", returns: "integer", security: "definer" },
314
392
  { name: "reopen_declared_doors", args: "", returns: "TABLE(reopened text)", security: "definer" },
315
393
  { name: "required_epoch", args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid", returns: "bigint", security: "definer" },
316
394
  { name: "resolve_first_match", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
@@ -331,6 +409,16 @@ var STORE_DOORS = [
331
409
  { name: "rule_truth", args: "p_answer jsonb", returns: "boolean", security: "invoker" },
332
410
  { name: "rule_uses", args: "", returns: "text[]", security: "invoker" },
333
411
  { name: "rule_version", args: "p_organization_id uuid, p_rule_id uuid", returns: "integer", security: "invoker" },
412
+ { name: "said", args: "p_value text, p_when_there_is_none text", returns: "text", security: "invoker" },
413
+ { name: "share_access", args: "p_organization_id uuid, p_subject_id uuid", returns: "TABLE(principal_kind text, principal_id uuid, principal_label text, level permission_level, reason text, reason_detail text, via_type text, via_id uuid, revocable boolean)", security: "definer" },
414
+ { name: "share_grant", args: "p_organization_id uuid, p_subject_id uuid, p_principal_kind text, p_principal_id uuid, p_level permission_level DEFAULT 'viewer'::permission_level", returns: "jsonb", security: "definer" },
415
+ { name: "share_lane_set", args: "p_organization_id uuid, p_subject_id uuid, p_choice text, p_level permission_level DEFAULT NULL::permission_level", returns: "jsonb", security: "definer" },
416
+ { name: "share_lanes", args: "", returns: "TABLE(choice text, lane text, discoverable boolean, label text, means text)", security: "definer" },
417
+ { name: "share_levels", args: "", returns: "TABLE(level permission_level, ordinal integer, label text, means text)", security: "definer" },
418
+ { name: "share_people", args: "p_organization_id uuid, p_subject_id uuid DEFAULT NULL::uuid, p_query text DEFAULT NULL::text, p_limit integer DEFAULT 25", returns: "TABLE(user_id uuid, email text, display_name text, membership text, already_at permission_level, already_why text)", security: "definer" },
419
+ { name: "share_revoke", args: "p_organization_id uuid, p_subject_id uuid, p_principal_kind text, p_principal_id uuid", returns: "jsonb", security: "definer" },
420
+ { name: "share_subject_name", args: "p_organization_id uuid, p_type text, p_id uuid", returns: "text", security: "definer" },
421
+ { name: "shared_only_disagreements", args: "p_pretend text DEFAULT NULL::text", returns: "TABLE(organization_id uuid, organization_name text, member_id uuid, record_id uuid, table_id uuid, ladder boolean, read_door boolean, rls_mirror boolean, why text)", security: "invoker" },
334
422
  { name: "size_refusal", args: "p_organization_id uuid, p_data jsonb", returns: "text", security: "invoker" },
335
423
  { name: "source_next_pointer", args: "p_sources jsonb", returns: "text", security: "invoker" },
336
424
  { name: "source_pointer", args: "p_sources jsonb, p_source jsonb", returns: "text", security: "invoker" },
@@ -338,14 +426,18 @@ var STORE_DOORS = [
338
426
  { name: "storage_modes", args: "", returns: "text[]", security: "invoker" },
339
427
  { name: "store_is_open", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "invoker" },
340
428
  { name: "table_capacity", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
429
+ { name: "table_contents", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(record_id uuid, kind text, goes_at integer)", security: "invoker" },
341
430
  { name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
431
+ { name: "table_has_a_visible_record", args: "p_user uuid, p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
432
+ { name: "table_is_live", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
342
433
  { name: "table_kernel_id", args: "", returns: "uuid", security: "invoker" },
343
434
  { name: "table_record_ceiling", args: "", returns: "integer", security: "invoker" },
344
435
  { name: "table_record_ceiling", args: "p_organization_id uuid", returns: "integer", security: "invoker" },
345
436
  { name: "table_rules", args: "p_organization_id uuid, p_table_id uuid, p_use text, p_record_type text DEFAULT NULL::text", returns: "SETOF custom.record", security: "invoker" },
346
437
  { name: "table_storage", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
347
- { name: "table_type_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
348
- { name: "tables_at_home", args: "p_organization_id uuid, p_home_ids uuid[]", returns: "TABLE(table_id uuid, home_record_id uuid, kind text)", security: "invoker" },
438
+ { name: "table_type_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "definer" },
439
+ { name: "tables_at_home", args: "p_organization_id uuid, p_home_ids uuid[]", returns: "TABLE(table_id uuid, home_record_id uuid, kind text)", security: "definer" },
440
+ { name: "tables_described_without_asking", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
349
441
  { name: "trg_associations_bump_visibility", args: "", returns: "trigger", security: "definer" },
350
442
  { name: "validate_custom_fields", args: "p_token text, p_organization_id uuid, p_values jsonb", returns: "void", security: "invoker" },
351
443
  { name: "validate_value_envelope", args: "p_organization_id uuid, p_fields custom.record[], p_data jsonb", returns: "void", security: "invoker" },
@@ -354,13 +446,16 @@ var STORE_DOORS = [
354
446
  { name: "value_envelope_keys", args: "", returns: "text[]", security: "invoker" },
355
447
  { name: "value_envelope_ok", args: "p_data jsonb", returns: "boolean", security: "invoker" },
356
448
  { name: "value_envelope_refusal", args: "p_data jsonb", returns: "text", security: "invoker" },
357
- { name: "value_read", args: "p_organization_id uuid, p_record_id uuid, p_key text", 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)", security: "invoker" },
449
+ { name: "value_read", args: "p_organization_id uuid, p_record_id uuid, p_key text", 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)", security: "definer" },
358
450
  { name: "value_versions", args: "p_old jsonb, p_new jsonb", returns: "jsonb", security: "invoker" },
359
451
  { name: "visibility_ancestors", args: "p_item_type text, p_item_id uuid", returns: "TABLE(container_type text, container_id uuid, depth integer, max_level permission_level)", security: "definer" },
452
+ { name: "visibility_as_of", args: "p_organization_id uuid, p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(principal_kind text, principal_id uuid, level permission_level, through_kind text, through_id uuid, reason text, replayed boolean, held_from timestamp with time zone, held_to timestamp with time zone)", security: "definer" },
360
453
  { name: "visibility_cache_rebuild", args: "", returns: "integer", security: "definer" },
361
454
  { name: "visibility_parity", args: "", 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)", security: "definer" },
362
455
  { name: "visibility_warm", args: "p_container_type text, p_container_id uuid", returns: "integer", security: "definer" },
456
+ { name: "visible_predicate_sql", args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, p_alias text DEFAULT 'r'::text", returns: "text", security: "definer" },
363
457
  { name: "visible_record_ids", args: "p_user_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level", returns: "TABLE(id uuid)", security: "definer" },
458
+ { name: "visible_set", args: "p_user uuid, p_organization_id uuid, p_table_id uuid, p_required permission_level DEFAULT 'viewer'::permission_level, OUT o_all_visible boolean, OUT o_true_visibility platform.visibility[], OUT o_granted_all uuid[], OUT o_granted_visible uuid[], OUT o_carried_visible uuid[], OUT o_ladder_calls integer, OUT o_fallback boolean, OUT o_note text", returns: "record", security: "definer" },
364
459
  { name: "widget_kernel_id", args: "", returns: "uuid", security: "invoker" },
365
460
  { name: "work_assignment_fields", args: "p_options_table_id uuid DEFAULT NULL::uuid", returns: "TABLE(key text, label text, spec jsonb)", security: "invoker" },
366
461
  { name: "work_has_assignment", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
@@ -382,9 +477,9 @@ var STORE_DOORS = [
382
477
  { name: "work_whose_turn", args: "p_organization_id uuid, p_table_id uuid, p_include_finished boolean DEFAULT false", returns: "TABLE(record_id uuid, title text, assignee_id uuid, turn text, due_on timestamp with time zone, state text, status text, terminal boolean)", security: "invoker" }
383
478
  ];
384
479
  var STORE_KNOBS = [
385
- { key: "accessible_entity_ids_guard", value: "false", type: "boolean" },
386
- { key: "agent_schema_changes", value: '"propose"', type: "string" },
387
- { key: "associations_guard", value: "false", type: "boolean" },
480
+ { key: "accessible_entity_ids_guard", value: "true", type: "boolean" },
481
+ { key: "agent_schema_changes", value: '"ask"', type: "string" },
482
+ { key: "associations_guard", value: "true", type: "boolean" },
388
483
  { key: "code_paths_enabled", value: "false", type: "boolean" },
389
484
  { key: "consumer_chat_seeding_enabled", value: "false", type: "boolean" },
390
485
  { key: "consumer_checkout_enabled", value: "false", type: "boolean" },
@@ -395,6 +490,7 @@ var STORE_KNOBS = [
395
490
  { key: "consumer_saved_ai_outputs_enabled", value: "false", type: "boolean" },
396
491
  { key: "consumer_scopes_enabled", value: "false", type: "boolean" },
397
492
  { key: "containment_depth_ceiling", value: "16", type: "integer" },
493
+ { key: "cross_organization_links", value: "false", type: "boolean" },
398
494
  { key: "document_max_bytes", value: "1048576", type: "integer" },
399
495
  { key: "emergency_door_guard", value: "false", type: "boolean" },
400
496
  { key: "emergency_door_sweep_enabled", value: "false", type: "boolean" },
@@ -403,7 +499,9 @@ var STORE_KNOBS = [
403
499
  { key: "external_principal_enabled", value: "false", type: "boolean" },
404
500
  { key: "field_index_guard", value: "false", type: "boolean" },
405
501
  { key: "field_sensitivity_levels", value: '{"edit": {"public": "editor", "internal": "editor", "restricted": "admin", "confidential": "admin"}, "read": {"public": "viewer", "internal": "viewer", "restricted": "admin", "confidential": "editor"}}', type: "json" },
406
- { key: "member_default_level", value: '"viewer"', type: "string" },
502
+ { key: "member_default_level", value: '"viewer"', type: "enum" },
503
+ { key: "member_default_visibility", value: '"all_records"', type: "enum" },
504
+ { key: "records_tool_default", value: "true", type: "boolean" },
407
505
  { key: "row_versions_guard", value: "false", type: "boolean" },
408
506
  { key: "sandbox_expanded_frame_height_px", value: "20000", type: "integer" },
409
507
  { key: "sandbox_frame_height_px", value: "4000", type: "integer" },
@@ -416,17 +514,18 @@ var STORE_KNOBS = [
416
514
  { key: "world_publish_enabled", value: "false", type: "boolean" }
417
515
  ];
418
516
  var STORE_REFUSAL_CODES = [
419
- { code: "02000", 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" },
517
+ { code: "02000", raised_by: "doc_render_body,doc_render_document,doc_sign,doc_signature_intact,doc_template_save,external_history_event,external_rows,external_stub_upsert,external_writes_set,migrate_delete,migrate_extract_parent,migrate_merge,migrate_rename,migrate_reparent,migrate_retype,migrate_split,migrate_undo,read_record,record_delete,record_restore,record_update,relation_uncarry,share_access,share_grant,share_lane_set,share_people,share_revoke,visibility_as_of" },
420
518
  { code: "0A000", 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" },
421
- { code: "22004", 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" },
519
+ { code: "22004", raised_by: "_value_envelope,actor_word,agg_assert_key,agg_sql,anon_capture,anon_token_issue,anon_write,assert_client_may_reach,doc_render_write,doc_sign,doc_signature_write,doc_template_save,external_history_event,external_rows,external_source_declare,external_stub_upsert,external_write_through,external_writes_set,home_add,io_comment_write,io_import_open,io_outbox_drain,io_restore,migrate_purge,migrate_split,migrate_undo,query_across_homes,query_by_coordinates,query_rollup,record_delete,record_reparent,record_resolve,record_restore,record_update,record_write,relation_carry,relation_own,share_grant,table_declare,work_template_declare" },
422
520
  { code: "22012", raised_by: "rule_eval" },
423
- { code: "22023", 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" },
424
- { code: "23503", 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" },
425
- { code: "23505", raised_by: "doc_sign,doc_signature_write,home_add,io_proposal_accept,work_slot_hold" },
426
- { code: "23514", 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" },
521
+ { code: "22023", 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,my_levels,query_by_coordinates,query_rollup,record_update,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_slot_hold" },
522
+ { code: "23503", raised_by: "_containment_guard,_record_rule_uses,anon_publish,anon_rate_take,anon_token_issue,anon_write,assert_organization_wall,delete_rule,doc_sign,doc_template_save,home_add,io_comment_write,io_import_rows,io_proposal_accept,migrate_demote,migrate_promote,promote_field,promote_table,record_applicability,record_reparent,relation_carry,relation_own,resolve_first_match,rule_applies,rule_eval,rule_members,rule_run,work_take_assignment,work_template_instantiate" },
523
+ { code: "23505", raised_by: "_unique_rule_holds,doc_sign,doc_signature_write,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_slot_hold" },
524
+ { code: "23514", raised_by: "_containment_guard,_dated_values_guard,_derived_fields,_field_document_for,_field_shape_guard,_field_type_parity_guard,_merge_field_shape_guard,_merge_field_temporal_guard,_promoted_field_cap_guard,_record_rule_uses,_resolve_choice_words,_rule_shape_guard,_rule_topology_guard,_store_relation_edge_names_its_field,_table_shape_guard,_value_envelope,_work_shape_guard,doc_sign,doc_signature_write,doc_template_save,field_declare,field_retire,field_update,home_add,migrate_merge,relation_carry,relation_own,validate_value_envelope,validate_values,work_slots_declare,work_take_assignment,work_template_instantiate" },
427
525
  { code: "40001", raised_by: "has_visibility_at" },
428
- { code: "42501", raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_reach,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,promote_table,read_record,read_records" },
429
- { code: "53400", raised_by: "anon_rate_take,promote_field" },
526
+ { code: "42501", raised_by: "_doc_render_immutable,_doc_signature_immutable,_field_definition_write,_field_write_door,_rule_definition_write,_store_door,anon_capture,anon_inbound_land,anon_publish,anon_token_issue,anon_token_verify,anon_write,assert_client_may_change,assert_client_may_open,assert_client_may_reach,assert_may_know_table,assert_organization_admin,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,my_levels,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of" },
527
+ { code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,promote_field" },
528
+ { code: "54001", raised_by: "record_delete" },
430
529
  { code: "PT409", raised_by: "record_update" }
431
530
  ];
432
531
  var ENTITY_TOKENS = [
@@ -637,6 +736,7 @@ var ENTITY_TOKENS = [
637
736
  "content_ir_kind_example",
638
737
  "content_ir_kind_instance",
639
738
  "content_ir_kind_surface",
739
+ "content_lane",
640
740
  "context_access_log",
641
741
  "context_item",
642
742
  "context_item_suggestion",
@@ -1071,6 +1171,7 @@ var ENTITY_TOKENS = [
1071
1171
  "part_config_sub",
1072
1172
  "party",
1073
1173
  "party_contact_point",
1174
+ "passkey_credential",
1074
1175
  "path_drift_repair_2026_09",
1075
1176
  "pc_article",
1076
1177
  "pc_episode",
@@ -1518,6 +1619,20 @@ var DOORS = {
1518
1619
  fieldOptions: "field_options",
1519
1620
  parityValues: "parity_values",
1520
1621
  tableDeclare: "table_declare",
1622
+ // ADDING A COLUMN — the first thing anybody does with a table, and until
1623
+ // 2026-09-19 there was no door for it. A Field is a record (REC-25), so a
1624
+ // screen wrote one with `record_write`; that door writes ONE row with
1625
+ // `data_class = 'record'` and cannot also add the key to the Table record's
1626
+ // `fields` array, which the field guard requires before it accepts any
1627
+ // definition at all. So every "Add field" ended on "the table does not
1628
+ // declare a field called … — declare it there first". These three doors take
1629
+ // what a person knows — a field type, a name, and for a choice list the
1630
+ // choices themselves — and the STORE turns that into the document its own
1631
+ // guards demand, so every client inherits one answer instead of each one
1632
+ // re-deriving thirteen and getting them wrong.
1633
+ fieldDeclare: "field_declare",
1634
+ fieldUpdate: "field_update",
1635
+ fieldRetire: "field_retire",
1521
1636
  tableCapacity: "table_capacity",
1522
1637
  tableStorage: "table_storage",
1523
1638
  promoteTable: "promote_table",
@@ -1530,6 +1645,10 @@ var DOORS = {
1530
1645
  recordReparent: "record_reparent",
1531
1646
  containmentChain: "containment_chain",
1532
1647
  storeIsOpen: "store_is_open",
1648
+ // DOOR-1, from the screen's side. What level the CALLER holds on the subjects
1649
+ // they name — the one question a screen has to answer BEFORE it draws a
1650
+ // control, and the only one the store had no client answer to.
1651
+ myLevels: "my_levels",
1533
1652
  // DOOR-11. The record's own revision list. A screen that offers an optimistic
1534
1653
  // save needs the version it LOADED, and the read door answers documents, not
1535
1654
  // versions — so the version comes from here, once, for the one record being
@@ -1638,6 +1757,12 @@ var BY_SQLSTATE = {
1638
1757
  "0A000": "not_supported",
1639
1758
  "53400": "store_limit",
1640
1759
  "22012": "store_limit",
1760
+ // 54001 — `custom.record_delete` stops a cascade that nests past sixty-four
1761
+ // levels of containment, because that is a loop somebody built rather than a
1762
+ // hierarchy, and saying so beats recursing until the server runs out of
1763
+ // stack. It is a LIMIT of the store, and the store's own sentence names what
1764
+ // to do about it, so it reads as one.
1765
+ "54001": "store_limit",
1641
1766
  // VIS: `custom.has_visibility_at` refuses to answer from a snapshot older
1642
1767
  // than a write this reader has already seen, rather than returning something
1643
1768
  // they just lost access to. It is retryable on a fresher connection, which is
@@ -2013,6 +2138,27 @@ function createRecordsClient(config) {
2013
2138
  "tableCapacity"
2014
2139
  );
2015
2140
  },
2141
+ async fieldDeclare({ table_id, spec }) {
2142
+ return callDoor(
2143
+ DOORS.fieldDeclare,
2144
+ { p_organization_id: org, p_table_id: table_id, p_spec: spec },
2145
+ "fieldDeclare"
2146
+ );
2147
+ },
2148
+ async fieldUpdate({ field_id, patch }) {
2149
+ return callDoor(
2150
+ DOORS.fieldUpdate,
2151
+ { p_organization_id: org, p_field_id: field_id, p_patch: patch },
2152
+ "fieldUpdate"
2153
+ );
2154
+ },
2155
+ async fieldRetire({ field_id }) {
2156
+ return callDoor(
2157
+ DOORS.fieldRetire,
2158
+ { p_organization_id: org, p_field_id: field_id },
2159
+ "fieldRetire"
2160
+ );
2161
+ },
2016
2162
  async tableDeclare({ spec, homeId }) {
2017
2163
  return callDoor(
2018
2164
  DOORS.tableDeclare,
@@ -2487,6 +2633,18 @@ function createRecordsClient(config) {
2487
2633
  },
2488
2634
  async storeIsOpen() {
2489
2635
  return callDoor(DOORS.storeIsOpen, { p_organization_id: org }, "storeIsOpen");
2636
+ },
2637
+ async myLevels({ ids, subject }) {
2638
+ if (ids.length === 0) return ok([]);
2639
+ const answered = await callDoor(
2640
+ DOORS.myLevels,
2641
+ { p_organization_id: org, p_ids: ids, p_type: subject ?? "record" },
2642
+ "myLevels"
2643
+ );
2644
+ if (!answered.ok) return err(answered.error);
2645
+ return ok(
2646
+ (answered.data ?? []).map((row) => ({ id: row.id, level: asPermissionLevel(row.level) }))
2647
+ );
2490
2648
  }
2491
2649
  };
2492
2650
  return client;
@@ -2581,6 +2739,31 @@ function useTable(tableId) {
2581
2739
  function useTables() {
2582
2740
  return useAsync((client) => client.tableList(), []);
2583
2741
  }
2742
+ function useMyLevels(ids) {
2743
+ const key = ids.join(",");
2744
+ return useAsync(
2745
+ async (client) => {
2746
+ const asked = key === "" ? [] : key.split(",");
2747
+ const answered = await client.myLevels({ ids: asked });
2748
+ if (!answered.ok) return answered;
2749
+ const held = {};
2750
+ for (const row of answered.data) held[row.id] = row.level;
2751
+ return { ok: true, data: held };
2752
+ },
2753
+ [key]
2754
+ );
2755
+ }
2756
+ function useMyLevel(id) {
2757
+ return useAsync(
2758
+ async (client) => {
2759
+ if (!id) return { ok: true, data: null };
2760
+ const answered = await client.myLevels({ ids: [id] });
2761
+ if (!answered.ok) return answered;
2762
+ return { ok: true, data: answered.data[0]?.level ?? null };
2763
+ },
2764
+ [id]
2765
+ );
2766
+ }
2584
2767
  function useFields(tableId, recordType) {
2585
2768
  return useAsync(
2586
2769
  async (client) => {
@@ -2675,6 +2858,40 @@ function useRecordMutation() {
2675
2858
  [client, run, saving, error, conflict]
2676
2859
  );
2677
2860
  }
2861
+ function useFieldMutation() {
2862
+ const client = useRecordsClient();
2863
+ const [saving, setSaving] = (0, import_react2.useState)(false);
2864
+ const [error, setError] = (0, import_react2.useState)(null);
2865
+ const run = (0, import_react2.useCallback)(
2866
+ async (call, whenRefused) => {
2867
+ setSaving(true);
2868
+ setError(null);
2869
+ try {
2870
+ const result = await call();
2871
+ if (result.ok) return result.data;
2872
+ setError(result.error);
2873
+ return whenRefused;
2874
+ } finally {
2875
+ setSaving(false);
2876
+ }
2877
+ },
2878
+ []
2879
+ );
2880
+ return (0, import_react2.useMemo)(
2881
+ () => ({
2882
+ declare: (args) => run(
2883
+ () => client.fieldDeclare({ table_id: args.table_id, spec: args.spec }),
2884
+ null
2885
+ ),
2886
+ update: (args) => run(() => client.fieldUpdate({ field_id: args.field_id, patch: args.patch }), null),
2887
+ retire: (args) => run(() => client.fieldRetire({ field_id: args.field_id }), false),
2888
+ saving,
2889
+ error,
2890
+ clearError: () => setError(null)
2891
+ }),
2892
+ [client, run, saving, error]
2893
+ );
2894
+ }
2678
2895
  function useMergeField(key, state) {
2679
2896
  const client = useRecordsClient();
2680
2897
  const [resolution, setResolution] = (0, import_react2.useState)(null);