@ai-matrx/records 0.4.1 → 0.6.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.
@@ -1,4 +1,4 @@
1
- import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, ReadValue, AnonTokenBinding, WorkState, WorkGraph, WorkInstantiation, WorkTurn, WorkAssignmentField, WorkSlotHold, ExternalPrincipalCard, PublishBinding, ResolvedPublishBinding, FieldProposal, TableProposal, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.cjs';
1
+ import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, NewFieldDeclaration, FieldPatch, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, ReadValue, AnonTokenBinding, WorkState, WorkGraph, WorkInstantiation, WorkTurn, WorkAssignmentField, WorkSlotHold, ExternalPrincipalCard, PublishBinding, ResolvedPublishBinding, FieldProposal, TableProposal, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.cjs';
2
2
  export { ABSENCE_REASONS, ACTOR_VOCABULARY, AbsenceReason, Actor, AggregateOperation, COMPUTE_ON, CONTEXT_POLICIES, ComputeOn, ContextPolicy, DELIVERIES, Delivery, DocSignatureCheck, ENTITY_TOKENS, EntityToken, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, FieldBehavior, FieldRule, FieldSensitivity, FieldSource, ForbiddenEnvelopeWord, Freshness, HiddenFieldNotice, Home, KERNEL_TABLES, KernelTableName, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, MergeField, MergeFieldModifier, MergeFieldProvenance, MergeFieldResolution, MergeFieldSemanticType, MergeFieldSource, MergeFieldTransform, MissingBehavior, ON_DELETE, OVERRIDE_POLICIES, OnDelete, OverridePolicy, PARITY_FIELD_TYPES, PER_VALUE_ACCESS_WORDS, ParityFieldType, ParityFieldTypeDescriptor, PerValueAccessWord, ProvenancePointer, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, RecordsActor, RecordsErrorCode, RecordsErrorSink, RecordsFilter, RecordsRealtimePort, RecordsResolverPort, RecordsResponse, RecordsTableQuery, RegisteredTable, Relation, RelationBinding, RelationCardinality, RelationCarries, RelationFlavor, RelationProperties, RelationTarget, ResolutionTriple, RetiredActorWord, Rule, RuleAnswer, RuleExpression, RuleNodeKind, RuleUse, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, StorageMode, StoreDoorName, StoreRefusalCode, SubscriptionBlock, SubscriptionCadence, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, TableDisplay, TableOrigin, TableType, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, ValueAlternate, ValueAlternateKey, ValueEnvelope, ValueEnvelopeKey, ValueSource, WorkTemplateNode, WorkTemplateRelation, err, isRecordsErr, measureKey, ok } from '../index.cjs';
3
3
 
4
4
  /**
@@ -152,6 +152,33 @@ interface RecordsClient {
152
152
  spec: Record<string, unknown>;
153
153
  homeId: Uuid;
154
154
  }): Promise<RecordsResult<Uuid>>;
155
+ /**
156
+ * ADD A FIELD TO A TABLE. One call, and the store does the three things no
157
+ * client can do for itself: it turns a parity type into the behaviour,
158
+ * modifiers, format, unit, relation target and Rules its own guards demand;
159
+ * it tells the TABLE about the field (REC-1 / FLD-8 — a definition for a
160
+ * field the table never declared is refused, which is the sentence every
161
+ * "Add field" used to end on); and it stores the definition as a FIELD
162
+ * rather than as a plain record, so the delete rules and the
163
+ * formula-dependency check can see it.
164
+ *
165
+ * A choice list carries its `options` as words. The store keeps them the only
166
+ * way FLD-5 / FLD-6 allows — as the records of a Table it declares for them —
167
+ * so nobody is made to build a table before they can have a dropdown.
168
+ */
169
+ fieldDeclare(args: {
170
+ table_id: Uuid;
171
+ spec: NewFieldDeclaration;
172
+ }): Promise<RecordsResult<Uuid>>;
173
+ /** One field's own settings. What it HOLDS is a conversion and is refused here by name. */
174
+ fieldUpdate(args: {
175
+ field_id: Uuid;
176
+ patch: FieldPatch;
177
+ }): Promise<RecordsResult<Uuid>>;
178
+ /** Take a field off a table. Refuses the title field, the last field, and one another field reads through. */
179
+ fieldRetire(args: {
180
+ field_id: Uuid;
181
+ }): Promise<RecordsResult<boolean>>;
155
182
  /** The kernel Tables a caller writes a Home, a Field or a Rule into. */
156
183
  personKernelId(): Promise<RecordsResult<Uuid>>;
157
184
  fieldKernelId(): Promise<RecordsResult<Uuid>>;
@@ -502,6 +529,9 @@ declare const DOORS: {
502
529
  readonly fieldOptions: "field_options";
503
530
  readonly parityValues: "parity_values";
504
531
  readonly tableDeclare: "table_declare";
532
+ readonly fieldDeclare: "field_declare";
533
+ readonly fieldUpdate: "field_update";
534
+ readonly fieldRetire: "field_retire";
505
535
  readonly tableCapacity: "table_capacity";
506
536
  readonly tableStorage: "table_storage";
507
537
  readonly promoteTable: "promote_table";
@@ -681,4 +711,4 @@ declare function parseCsv(text: string): string[][];
681
711
  declare function importCsv(fields: Field[], text: string): ParsedImport;
682
712
  declare function importXlsx(fields: Field[], bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
683
713
 
684
- export { AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, type ExportRow, ExternalPrincipalCard, Field, FieldProposal, MAPPED_SQLSTATES, type MirrorLimits, type ParsedImport, PgError, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, type RecordQuery, RecordRead, RecordRevision, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, StaleWriteDetail, StoredRecord, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, Timestamp, Uuid, WorkAssignmentField, WorkGraph, WorkInstantiation, WorkSlotHold, WorkState, WorkTurn, WriteConflict, asWriteConflict, cellText, createRecordsClient, doorAbsent, doorCensus, doorExists, exportCsv, exportXlsx, importCsv, importXlsx, intersectIds, mapPgError, parseCsv, planQuery, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, toAoa };
714
+ export { AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, type ExportRow, ExternalPrincipalCard, Field, FieldPatch, FieldProposal, MAPPED_SQLSTATES, type MirrorLimits, NewFieldDeclaration, type ParsedImport, PgError, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, type RecordQuery, RecordRead, RecordRevision, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, StaleWriteDetail, StoredRecord, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, Timestamp, Uuid, WorkAssignmentField, WorkGraph, WorkInstantiation, WorkSlotHold, WorkState, WorkTurn, WriteConflict, asWriteConflict, cellText, createRecordsClient, doorAbsent, doorCensus, doorExists, exportCsv, exportXlsx, importCsv, importXlsx, intersectIds, mapPgError, parseCsv, planQuery, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, toAoa };
@@ -1,4 +1,4 @@
1
- import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, ReadValue, AnonTokenBinding, WorkState, WorkGraph, WorkInstantiation, WorkTurn, WorkAssignmentField, WorkSlotHold, ExternalPrincipalCard, PublishBinding, ResolvedPublishBinding, FieldProposal, TableProposal, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.js';
1
+ import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, NewFieldDeclaration, FieldPatch, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, ReadValue, AnonTokenBinding, WorkState, WorkGraph, WorkInstantiation, WorkTurn, WorkAssignmentField, WorkSlotHold, ExternalPrincipalCard, PublishBinding, ResolvedPublishBinding, FieldProposal, TableProposal, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.js';
2
2
  export { ABSENCE_REASONS, ACTOR_VOCABULARY, AbsenceReason, Actor, AggregateOperation, COMPUTE_ON, CONTEXT_POLICIES, ComputeOn, ContextPolicy, DELIVERIES, Delivery, DocSignatureCheck, ENTITY_TOKENS, EntityToken, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, FieldBehavior, FieldRule, FieldSensitivity, FieldSource, ForbiddenEnvelopeWord, Freshness, HiddenFieldNotice, Home, KERNEL_TABLES, KernelTableName, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, MergeField, MergeFieldModifier, MergeFieldProvenance, MergeFieldResolution, MergeFieldSemanticType, MergeFieldSource, MergeFieldTransform, MissingBehavior, ON_DELETE, OVERRIDE_POLICIES, OnDelete, OverridePolicy, PARITY_FIELD_TYPES, PER_VALUE_ACCESS_WORDS, ParityFieldType, ParityFieldTypeDescriptor, PerValueAccessWord, ProvenancePointer, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, RecordsActor, RecordsErrorCode, RecordsErrorSink, RecordsFilter, RecordsRealtimePort, RecordsResolverPort, RecordsResponse, RecordsTableQuery, RegisteredTable, Relation, RelationBinding, RelationCardinality, RelationCarries, RelationFlavor, RelationProperties, RelationTarget, ResolutionTriple, RetiredActorWord, Rule, RuleAnswer, RuleExpression, RuleNodeKind, RuleUse, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, StorageMode, StoreDoorName, StoreRefusalCode, SubscriptionBlock, SubscriptionCadence, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, TableDisplay, TableOrigin, TableType, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, ValueAlternate, ValueAlternateKey, ValueEnvelope, ValueEnvelopeKey, ValueSource, WorkTemplateNode, WorkTemplateRelation, err, isRecordsErr, measureKey, ok } from '../index.js';
3
3
 
4
4
  /**
@@ -152,6 +152,33 @@ interface RecordsClient {
152
152
  spec: Record<string, unknown>;
153
153
  homeId: Uuid;
154
154
  }): Promise<RecordsResult<Uuid>>;
155
+ /**
156
+ * ADD A FIELD TO A TABLE. One call, and the store does the three things no
157
+ * client can do for itself: it turns a parity type into the behaviour,
158
+ * modifiers, format, unit, relation target and Rules its own guards demand;
159
+ * it tells the TABLE about the field (REC-1 / FLD-8 — a definition for a
160
+ * field the table never declared is refused, which is the sentence every
161
+ * "Add field" used to end on); and it stores the definition as a FIELD
162
+ * rather than as a plain record, so the delete rules and the
163
+ * formula-dependency check can see it.
164
+ *
165
+ * A choice list carries its `options` as words. The store keeps them the only
166
+ * way FLD-5 / FLD-6 allows — as the records of a Table it declares for them —
167
+ * so nobody is made to build a table before they can have a dropdown.
168
+ */
169
+ fieldDeclare(args: {
170
+ table_id: Uuid;
171
+ spec: NewFieldDeclaration;
172
+ }): Promise<RecordsResult<Uuid>>;
173
+ /** One field's own settings. What it HOLDS is a conversion and is refused here by name. */
174
+ fieldUpdate(args: {
175
+ field_id: Uuid;
176
+ patch: FieldPatch;
177
+ }): Promise<RecordsResult<Uuid>>;
178
+ /** Take a field off a table. Refuses the title field, the last field, and one another field reads through. */
179
+ fieldRetire(args: {
180
+ field_id: Uuid;
181
+ }): Promise<RecordsResult<boolean>>;
155
182
  /** The kernel Tables a caller writes a Home, a Field or a Rule into. */
156
183
  personKernelId(): Promise<RecordsResult<Uuid>>;
157
184
  fieldKernelId(): Promise<RecordsResult<Uuid>>;
@@ -502,6 +529,9 @@ declare const DOORS: {
502
529
  readonly fieldOptions: "field_options";
503
530
  readonly parityValues: "parity_values";
504
531
  readonly tableDeclare: "table_declare";
532
+ readonly fieldDeclare: "field_declare";
533
+ readonly fieldUpdate: "field_update";
534
+ readonly fieldRetire: "field_retire";
505
535
  readonly tableCapacity: "table_capacity";
506
536
  readonly tableStorage: "table_storage";
507
537
  readonly promoteTable: "promote_table";
@@ -681,4 +711,4 @@ declare function parseCsv(text: string): string[][];
681
711
  declare function importCsv(fields: Field[], text: string): ParsedImport;
682
712
  declare function importXlsx(fields: Field[], bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
683
713
 
684
- export { AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, type ExportRow, ExternalPrincipalCard, Field, FieldProposal, MAPPED_SQLSTATES, type MirrorLimits, type ParsedImport, PgError, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, type RecordQuery, RecordRead, RecordRevision, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, StaleWriteDetail, StoredRecord, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, Timestamp, Uuid, WorkAssignmentField, WorkGraph, WorkInstantiation, WorkSlotHold, WorkState, WorkTurn, WriteConflict, asWriteConflict, cellText, createRecordsClient, doorAbsent, doorCensus, doorExists, exportCsv, exportXlsx, importCsv, importXlsx, intersectIds, mapPgError, parseCsv, planQuery, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, toAoa };
714
+ export { AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, type ExportRow, ExternalPrincipalCard, Field, FieldPatch, FieldProposal, MAPPED_SQLSTATES, type MirrorLimits, NewFieldDeclaration, type ParsedImport, PgError, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, type RecordQuery, RecordRead, RecordRevision, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, StaleWriteDetail, StoredRecord, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, Timestamp, Uuid, WorkAssignmentField, WorkGraph, WorkInstantiation, WorkSlotHold, WorkState, WorkTurn, WriteConflict, asWriteConflict, cellText, createRecordsClient, doorAbsent, doorCensus, doorExists, exportCsv, exportXlsx, importCsv, importXlsx, intersectIds, mapPgError, parseCsv, planQuery, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, toAoa };
@@ -133,7 +133,7 @@ var STORE_DOORS = [
133
133
  { name: "agg_buckets", args: "", returns: "text[]", security: "invoker" },
134
134
  { 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" },
135
135
  { 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" },
136
- { 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" },
136
+ { 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" },
137
137
  { name: "agg_operations", args: "", returns: "text[]", security: "invoker" },
138
138
  { 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" },
139
139
  { name: "agg_subscription_cadences", args: "", returns: "text[]", security: "invoker" },
@@ -152,7 +152,10 @@ var STORE_DOORS = [
152
152
  { 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" },
153
153
  { 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" },
154
154
  { 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" },
155
+ { 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" },
155
156
  { name: "assert_client_may_reach", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
157
+ { name: "assert_may_know_table", args: "p_organization_id uuid, p_table_id uuid, p_door text", returns: "void", security: "invoker" },
158
+ { name: "assert_organization_admin", args: "p_organization_id uuid, p_door text, p_what text", returns: "void", security: "invoker" },
156
159
  { name: "assert_organization_wall", args: "p_kind text, p_organization_id uuid, p_row jsonb", returns: "void", security: "invoker" },
157
160
  { name: "assert_store_door", args: "p_organization_id uuid, p_door text", returns: "void", security: "invoker" },
158
161
  { name: "bump_epoch", args: "p_entity_type text, p_entity_id uuid, p_organization_id uuid DEFAULT NULL::uuid", returns: "bigint", security: "definer" },
@@ -164,7 +167,10 @@ var STORE_DOORS = [
164
167
  { name: "containment_depth_ceiling", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "integer", security: "invoker" },
165
168
  { name: "containment_edges", args: "p_organization_id uuid", returns: "TABLE(parent_id uuid, child_id uuid, via text)", security: "invoker" },
166
169
  { name: "containment_parent", args: "p_data jsonb", returns: "uuid", security: "invoker" },
170
+ { name: "cross_organization_links_open", args: "p_source_organization_id uuid, p_target_organization_id uuid", returns: "boolean", security: "invoker" },
167
171
  { name: "custom_fields_tables", args: "", returns: "TABLE(token text, schema_name text, table_name text)", security: "invoker" },
172
+ { name: "delete_cascade_closure", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid[]", security: "invoker" },
173
+ { name: "delete_rule", args: "p_organization_id uuid, p_record_id uuid, p_apply boolean DEFAULT true", returns: "jsonb", security: "definer" },
168
174
  { name: "dependency_cycle", args: "p_organization_id uuid, p_row custom.record", returns: "text[]", security: "invoker" },
169
175
  { name: "dependency_label", args: "p_organization_id uuid, p_node text", returns: "text", security: "invoker" },
170
176
  { 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" },
@@ -185,6 +191,8 @@ var STORE_DOORS = [
185
191
  { name: "doc_unresolved_tokens", args: "p_organization_id uuid, p_table_id uuid, p_body text", returns: "TABLE(raw text, field_id uuid, why text)", security: "invoker" },
186
192
  { name: "doors_not_deciding_the_caller", args: "", returns: "TABLE(function_name text, identity_args text)", security: "invoker" },
187
193
  { name: "doors_not_deciding_the_record", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
194
+ { name: "doors_not_on_one_ladder", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
195
+ { name: "effective_level", args: "p_user_id uuid, p_organization_id uuid, p_id uuid, p_type text DEFAULT 'record'::text", returns: "permission_level", security: "definer" },
188
196
  { name: "export_records", args: "p_organization_id uuid, p_table_id uuid, p_limit integer DEFAULT 1000", returns: "TABLE(id uuid, document jsonb)", security: "invoker" },
189
197
  { name: "external_foreign_table_findings", args: "", returns: "SETOF text", security: "definer" },
190
198
  { name: "external_history_event", args: "p_organization_id uuid, p_link_id uuid, p_operation text", returns: "bigint", security: "definer" },
@@ -194,16 +202,25 @@ var STORE_DOORS = [
194
202
  { name: "external_tier_contract", args: "", returns: "jsonb", security: "definer" },
195
203
  { name: "external_write_through", args: "p_organization_id uuid, p_record_id uuid, p_patch jsonb", returns: "void", security: "definer" },
196
204
  { name: "external_writes_set", args: "p_organization_id uuid, p_source_id uuid, p_enabled boolean", returns: "boolean", security: "definer" },
205
+ { name: "field_behaviour", args: "p_field_data jsonb", returns: "text", security: "invoker" },
206
+ { name: "field_declare", args: "p_organization_id uuid, p_table_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
197
207
  { 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" },
198
208
  { name: "field_kernel_id", args: "", returns: "uuid", security: "invoker" },
199
- { name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "invoker" },
209
+ { name: "field_options", args: "p_organization_id uuid, p_field_id uuid", returns: "SETOF custom.record", security: "definer" },
210
+ { name: "field_retire", args: "p_organization_id uuid, p_field_id uuid", returns: "boolean", security: "definer" },
200
211
  { name: "field_rules", args: "p_field_data jsonb", returns: "TABLE(kind text, spec jsonb)", security: "invoker" },
212
+ { name: "field_update", args: "p_organization_id uuid, p_field_id uuid, p_patch jsonb", returns: "uuid", security: "definer" },
213
+ { name: "field_value_convert", args: "p_to jsonb, p_value jsonb", returns: "jsonb", security: "invoker" },
201
214
  { name: "file_kernel_id", args: "", returns: "uuid", security: "invoker" },
202
215
  { 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" },
203
216
  { 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" },
204
217
  { 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" },
205
218
  { name: "hidden_field_notice", args: "p_field custom.record, p_action text DEFAULT 'read'::text", returns: "jsonb", security: "invoker" },
206
- { name: "home_add", args: "p_organization_id uuid, p_table_id uuid, p_home_record_id uuid", returns: "uuid", security: "invoker" },
219
+ { 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" },
220
+ { name: "history_retention", args: "p_organization_id uuid, p_table_id uuid DEFAULT NULL::uuid", returns: "jsonb", security: "definer" },
221
+ { name: "history_retention_floor_raise", args: "p_organization_id uuid, p_days integer", returns: "integer", security: "definer" },
222
+ { name: "history_retention_set", args: "p_organization_id uuid, p_table_id uuid, p_days integer", returns: "integer", security: "definer" },
223
+ { name: "home_add", args: "p_organization_id uuid, p_table_id uuid, p_home_record_id uuid", returns: "uuid", security: "definer" },
207
224
  { name: "home_relations", args: "", returns: "TABLE(table_id uuid, home_record_id uuid, organization_id uuid, relation_id uuid)", security: "invoker" },
208
225
  { 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" },
209
226
  { name: "intern_provenance", args: "p_data jsonb", returns: "jsonb", security: "invoker" },
@@ -215,7 +232,7 @@ var STORE_DOORS = [
215
232
  { name: "io_csv_escape", args: "p_value text, p_delimiter text DEFAULT ','::text", returns: "text", security: "invoker" },
216
233
  { name: "io_csv_parse", args: "p_text text, p_delimiter text DEFAULT NULL::text", returns: "TABLE(row_number integer, cells text[])", security: "invoker" },
217
234
  { 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" },
218
- { 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" },
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 chr(44), p_required text DEFAULT 'viewer'::text", returns: "text", security: "definer" },
219
236
  { 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" },
220
237
  { 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" },
221
238
  { name: "io_infer_type", args: "p_samples jsonb", returns: "text", security: "invoker" },
@@ -226,23 +243,26 @@ var STORE_DOORS = [
226
243
  { name: "io_proposal_reject", args: "p_organization_id uuid, p_import_id uuid, p_column text", returns: "boolean", security: "definer" },
227
244
  { name: "io_record_changed", args: "", returns: "trigger", security: "definer" },
228
245
  { name: "io_restore", args: "p_organization_id uuid, p_record_id uuid, p_version integer", returns: "integer", security: "definer" },
229
- { 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" },
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, operation text, changed_fields jsonb)", security: "definer" },
230
247
  { name: "lookup_value", args: "p_organization_id uuid, p_record_id uuid, p_field_data jsonb", returns: "jsonb", security: "invoker" },
231
248
  { 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" },
232
249
  { 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" },
233
250
  { name: "merge_field_kernel_id", args: "", returns: "uuid", security: "invoker" },
234
- { name: "migrate_delete", args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
235
- { name: "migrate_demote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
236
- { 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" },
237
- { 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" },
238
- { name: "migrate_promote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
239
- { 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" },
240
- { name: "migrate_rename", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "invoker" },
241
- { 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" },
251
+ { name: "migrate_delete", args: "p_organization_id uuid, p_record_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
252
+ { name: "migrate_demote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
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: "definer" },
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: "definer" },
255
+ { name: "migrate_promote", args: "p_organization_id uuid, p_table_id uuid, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
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: "definer" },
257
+ { name: "migrate_rename", args: "p_organization_id uuid, p_id uuid, p_to text, p_note text DEFAULT NULL::text", returns: "jsonb", security: "definer" },
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: "definer" },
242
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" },
243
- { 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" },
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: "definer" },
261
+ { name: "migrate_undo", args: "p_organization_id uuid, p_log_id uuid", returns: "jsonb", security: "definer" },
244
262
  { name: "organization_kernel_id", args: "", returns: "uuid", security: "invoker" },
245
263
  { 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" },
264
+ { name: "owning_table", args: "p_organization_id uuid, p_record_id uuid", returns: "uuid", security: "invoker" },
265
+ { name: "owning_table_gone", args: "p_organization_id uuid, p_record_id uuid", returns: "boolean", security: "invoker" },
246
266
  { name: "parity_field_types", args: "", returns: "TABLE(parity_type text, behavior text, made_of text)", security: "invoker" },
247
267
  { name: "parity_type", args: "p_field_data jsonb", returns: "text", security: "invoker" },
248
268
  { 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" },
@@ -262,38 +282,47 @@ var STORE_DOORS = [
262
282
  { name: "promoted_value_path", args: "p_field_data jsonb", returns: "text", security: "invoker" },
263
283
  { name: "promotion_inline_ceiling", args: "", returns: "integer", security: "invoker" },
264
284
  { name: "query_access_ids", args: "p_organization_id uuid, p_required text DEFAULT 'viewer'::text", returns: "uuid[]", security: "invoker" },
265
- { 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" },
266
- { 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" },
267
- { name: "query_can_see", args: "p_organization_id uuid, p_record_id uuid, p_required text DEFAULT 'viewer'::text", returns: "boolean", security: "invoker" },
285
+ { 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" },
286
+ { 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" },
287
+ { name: "query_can_see", args: "p_organization_id uuid, p_record_id uuid, p_required text DEFAULT 'viewer'::text", returns: "boolean", security: "definer" },
268
288
  { name: "query_hot_paths", args: "", returns: "TABLE(name text, statement text)", security: "invoker" },
269
289
  { name: "query_hot_paths_prepared", args: "", returns: "TABLE(name text, prepared boolean, generic_plans bigint)", security: "invoker" },
270
290
  { name: "query_is_store_owner", args: "", returns: "boolean", security: "invoker" },
271
291
  { name: "query_prepare_hot", args: "", returns: "integer", security: "invoker" },
272
292
  { name: "query_principal", args: "", returns: "uuid", security: "invoker" },
273
- { 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" },
274
- { 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" },
275
- { 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" },
276
- { 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" },
277
- { 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" },
278
- { name: "query_table_homes", args: "p_organization_id uuid, p_table_id uuid", returns: "SETOF uuid", security: "invoker" },
279
- { 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" },
293
+ { 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" },
294
+ { 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" },
295
+ { 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" },
296
+ { 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" },
297
+ { 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" },
298
+ { name: "query_table_homes", args: "p_organization_id uuid, p_table_id uuid", returns: "SETOF uuid", security: "definer" },
299
+ { 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" },
300
+ { 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" },
280
301
  { name: "reachable_from", args: "p_organization_id uuid, p_roots uuid[]", returns: "TABLE(record_id uuid, depth integer, via text)", security: "invoker" },
281
302
  { name: "read_paths_outside_the_door", args: "", returns: "TABLE(object_name text, why text)", security: "invoker" },
282
303
  { name: "read_record", args: "p_organization_id uuid, p_record_id uuid, p_by_id boolean DEFAULT false", returns: "jsonb", security: "definer" },
283
304
  { 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" },
284
- { 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" },
305
+ { 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" },
285
306
  { 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" },
307
+ { name: "record_card", args: "p_viewer uuid, p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "definer" },
308
+ { 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" },
286
309
  { name: "record_delete", args: "p_organization_id uuid, p_record_id uuid", returns: "timestamp with time zone", security: "definer" },
287
- { name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "invoker" },
310
+ { 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" },
311
+ { name: "record_reparent", args: "p_organization_id uuid, p_record_id uuid, p_parent_id uuid", returns: "void", security: "definer" },
312
+ { name: "record_resolve", args: "p_organization_id uuid, p_id uuid", returns: "jsonb", security: "definer" },
288
313
  { name: "record_restore", args: "p_organization_id uuid, p_record_id uuid", returns: "void", security: "definer" },
314
+ { name: "record_state_as_of", args: "p_record_id uuid, p_at timestamp with time zone", returns: "TABLE(state jsonb, replayed boolean)", security: "definer" },
289
315
  { 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" },
290
316
  { name: "record_values", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
291
- { 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" },
317
+ { 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" },
292
318
  { name: "record_write", args: "p_organization_id uuid, p_table_id uuid, p_data jsonb", returns: "uuid", security: "definer" },
293
- { name: "relation_own", args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid", returns: "uuid", security: "invoker" },
319
+ { name: "relation_carry", args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid", returns: "uuid", security: "definer" },
320
+ { name: "relation_own", args: "p_organization_id uuid, p_owner_id uuid, p_target_id uuid", returns: "uuid", security: "definer" },
321
+ { 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" },
294
322
  { name: "relation_target_external", args: "p_connection_token text, p_external_table text, p_external_key text", returns: "jsonb", security: "definer" },
295
323
  { name: "relation_target_ours", args: "p_entity_token text, p_row_id uuid", returns: "jsonb", security: "definer" },
296
- { name: "relation_targets", args: "p_organization_id uuid, p_record_id uuid, p_via_key text", returns: "SETOF uuid", security: "invoker" },
324
+ { name: "relation_targets", args: "p_organization_id uuid, p_record_id uuid, p_via_key text", returns: "SETOF uuid", security: "definer" },
325
+ { name: "relation_uncarry", args: "p_organization_id uuid, p_container_id uuid, p_item_id uuid", returns: "integer", security: "definer" },
297
326
  { name: "reopen_declared_doors", args: "", returns: "TABLE(reopened text)", security: "definer" },
298
327
  { name: "required_epoch", args: "p_container_type text, p_container_id uuid, p_item_type text, p_item_id uuid", returns: "bigint", security: "definer" },
299
328
  { name: "resolve_first_match", args: "p_organization_id uuid, p_record_id uuid", returns: "jsonb", security: "invoker" },
@@ -314,6 +343,14 @@ var STORE_DOORS = [
314
343
  { name: "rule_truth", args: "p_answer jsonb", returns: "boolean", security: "invoker" },
315
344
  { name: "rule_uses", args: "", returns: "text[]", security: "invoker" },
316
345
  { name: "rule_version", args: "p_organization_id uuid, p_rule_id uuid", returns: "integer", security: "invoker" },
346
+ { 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" },
347
+ { 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" },
348
+ { 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" },
349
+ { name: "share_lanes", args: "", returns: "TABLE(choice text, lane text, discoverable boolean, label text, means text)", security: "definer" },
350
+ { name: "share_levels", args: "", returns: "TABLE(level permission_level, ordinal integer, label text, means text)", security: "definer" },
351
+ { 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" },
352
+ { name: "share_revoke", args: "p_organization_id uuid, p_subject_id uuid, p_principal_kind text, p_principal_id uuid", returns: "jsonb", security: "definer" },
353
+ { name: "share_subject_name", args: "p_organization_id uuid, p_type text, p_id uuid", returns: "text", security: "definer" },
317
354
  { name: "size_refusal", args: "p_organization_id uuid, p_data jsonb", returns: "text", security: "invoker" },
318
355
  { name: "source_next_pointer", args: "p_sources jsonb", returns: "text", security: "invoker" },
319
356
  { name: "source_pointer", args: "p_sources jsonb, p_source jsonb", returns: "text", security: "invoker" },
@@ -321,14 +358,17 @@ var STORE_DOORS = [
321
358
  { name: "storage_modes", args: "", returns: "text[]", security: "invoker" },
322
359
  { name: "store_is_open", args: "p_organization_id uuid DEFAULT NULL::uuid", returns: "boolean", security: "invoker" },
323
360
  { name: "table_capacity", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
361
+ { name: "table_contents", args: "p_organization_id uuid, p_table_id uuid", returns: "TABLE(record_id uuid, kind text, goes_at integer)", security: "invoker" },
324
362
  { name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
363
+ { name: "table_is_live", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
325
364
  { name: "table_kernel_id", args: "", returns: "uuid", security: "invoker" },
326
365
  { name: "table_record_ceiling", args: "", returns: "integer", security: "invoker" },
327
366
  { name: "table_record_ceiling", args: "p_organization_id uuid", returns: "integer", security: "invoker" },
328
367
  { 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" },
329
368
  { name: "table_storage", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
330
369
  { name: "table_type_field", args: "p_organization_id uuid, p_table_id uuid", returns: "text", security: "invoker" },
331
- { 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" },
370
+ { 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" },
371
+ { name: "tables_described_without_asking", args: "", returns: "TABLE(function_name text, identity_args text, why text)", security: "invoker" },
332
372
  { name: "trg_associations_bump_visibility", args: "", returns: "trigger", security: "definer" },
333
373
  { name: "validate_custom_fields", args: "p_token text, p_organization_id uuid, p_values jsonb", returns: "void", security: "invoker" },
334
374
  { name: "validate_value_envelope", args: "p_organization_id uuid, p_fields custom.record[], p_data jsonb", returns: "void", security: "invoker" },
@@ -340,6 +380,7 @@ var STORE_DOORS = [
340
380
  { 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" },
341
381
  { name: "value_versions", args: "p_old jsonb, p_new jsonb", returns: "jsonb", security: "invoker" },
342
382
  { 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" },
383
+ { 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" },
343
384
  { name: "visibility_cache_rebuild", args: "", returns: "integer", security: "definer" },
344
385
  { 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" },
345
386
  { name: "visibility_warm", args: "p_container_type text, p_container_id uuid", returns: "integer", security: "definer" },
@@ -378,6 +419,7 @@ var STORE_KNOBS = [
378
419
  { key: "consumer_saved_ai_outputs_enabled", value: "false", type: "boolean" },
379
420
  { key: "consumer_scopes_enabled", value: "false", type: "boolean" },
380
421
  { key: "containment_depth_ceiling", value: "16", type: "integer" },
422
+ { key: "cross_organization_links", value: "false", type: "boolean" },
381
423
  { key: "document_max_bytes", value: "1048576", type: "integer" },
382
424
  { key: "emergency_door_guard", value: "false", type: "boolean" },
383
425
  { key: "emergency_door_sweep_enabled", value: "false", type: "boolean" },
@@ -387,6 +429,8 @@ var STORE_KNOBS = [
387
429
  { key: "field_index_guard", value: "false", type: "boolean" },
388
430
  { 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" },
389
431
  { key: "member_default_level", value: '"viewer"', type: "string" },
432
+ { key: "member_default_visibility", value: '"all_records"', type: "enum" },
433
+ { key: "records_tool_default", value: "true", type: "boolean" },
390
434
  { key: "row_versions_guard", value: "false", type: "boolean" },
391
435
  { key: "sandbox_expanded_frame_height_px", value: "20000", type: "integer" },
392
436
  { key: "sandbox_frame_height_px", value: "4000", type: "integer" },
@@ -399,17 +443,18 @@ var STORE_KNOBS = [
399
443
  { key: "world_publish_enabled", value: "false", type: "boolean" }
400
444
  ];
401
445
  var STORE_REFUSAL_CODES = [
402
- { 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" },
446
+ { 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" },
403
447
  { 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" },
404
- { 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" },
448
+ { 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" },
405
449
  { code: "22012", raised_by: "rule_eval" },
406
- { 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" },
407
- { 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" },
408
- { code: "23505", raised_by: "doc_sign,doc_signature_write,home_add,io_proposal_accept,work_slot_hold" },
409
- { 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" },
450
+ { 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,relation_carry,rule_eval,rule_members,share_grant,share_lane_set,table_rules,visibility_as_of,work_slot_hold" },
451
+ { 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" },
452
+ { code: "23505", raised_by: "doc_sign,doc_signature_write,field_declare,home_add,io_proposal_accept,relation_carry,relation_own,share_grant,work_slot_hold" },
453
+ { 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,_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" },
410
454
  { code: "40001", raised_by: "has_visibility_at" },
411
- { 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" },
412
- { code: "53400", raised_by: "anon_rate_take,promote_field" },
455
+ { 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_organization_admin,assert_store_door,external_write_through,io_comment_resolve,io_comment_write,io_restore,migrate_purge,promote_table,query_visibility_parity,read_record,read_records,share_grant,visibility_as_of" },
456
+ { code: "53400", raised_by: "anon_rate_take,delete_cascade_closure,promote_field" },
457
+ { code: "54001", raised_by: "record_delete" },
413
458
  { code: "PT409", raised_by: "record_update" }
414
459
  ];
415
460
  var ENTITY_TOKENS = [
@@ -620,6 +665,7 @@ var ENTITY_TOKENS = [
620
665
  "content_ir_kind_example",
621
666
  "content_ir_kind_instance",
622
667
  "content_ir_kind_surface",
668
+ "content_lane",
623
669
  "context_access_log",
624
670
  "context_item",
625
671
  "context_item_suggestion",
@@ -1054,6 +1100,7 @@ var ENTITY_TOKENS = [
1054
1100
  "part_config_sub",
1055
1101
  "party",
1056
1102
  "party_contact_point",
1103
+ "passkey_credential",
1057
1104
  "path_drift_repair_2026_09",
1058
1105
  "pc_article",
1059
1106
  "pc_episode",
@@ -1501,6 +1548,20 @@ var DOORS = {
1501
1548
  fieldOptions: "field_options",
1502
1549
  parityValues: "parity_values",
1503
1550
  tableDeclare: "table_declare",
1551
+ // ADDING A COLUMN — the first thing anybody does with a table, and until
1552
+ // 2026-09-19 there was no door for it. A Field is a record (REC-25), so a
1553
+ // screen wrote one with `record_write`; that door writes ONE row with
1554
+ // `data_class = 'record'` and cannot also add the key to the Table record's
1555
+ // `fields` array, which the field guard requires before it accepts any
1556
+ // definition at all. So every "Add field" ended on "the table does not
1557
+ // declare a field called … — declare it there first". These three doors take
1558
+ // what a person knows — a field type, a name, and for a choice list the
1559
+ // choices themselves — and the STORE turns that into the document its own
1560
+ // guards demand, so every client inherits one answer instead of each one
1561
+ // re-deriving thirteen and getting them wrong.
1562
+ fieldDeclare: "field_declare",
1563
+ fieldUpdate: "field_update",
1564
+ fieldRetire: "field_retire",
1504
1565
  tableCapacity: "table_capacity",
1505
1566
  tableStorage: "table_storage",
1506
1567
  promoteTable: "promote_table",
@@ -1616,17 +1677,37 @@ var BY_SQLSTATE = {
1616
1677
  "23514": "refused_by_rule",
1617
1678
  "22004": "invalid_argument",
1618
1679
  "22023": "invalid_argument",
1680
+ // 22P02 — a value does not fit the type the store holds for it. The class is
1681
+ // real and was hit live: an organization whose copy of a package table grew
1682
+ // `status` as a uuid-valued Field was sent the text "open", and the store
1683
+ // answered `invalid input syntax for type uuid: "open"`. It is the CALL that
1684
+ // is wrong for the shape the store holds, which is what `invalid_argument`
1685
+ // already means — the store's own sentence names the value and the type.
1686
+ "22P02": "invalid_argument",
1619
1687
  "02000": "not_found",
1620
1688
  "23503": "missing_reference",
1621
1689
  "23505": "already_exists",
1622
1690
  "0A000": "not_supported",
1623
1691
  "53400": "store_limit",
1624
1692
  "22012": "store_limit",
1693
+ // 54001 — `custom.record_delete` stops a cascade that nests past sixty-four
1694
+ // levels of containment, because that is a loop somebody built rather than a
1695
+ // hierarchy, and saying so beats recursing until the server runs out of
1696
+ // stack. It is a LIMIT of the store, and the store's own sentence names what
1697
+ // to do about it, so it reads as one.
1698
+ "54001": "store_limit",
1625
1699
  // VIS: `custom.has_visibility_at` refuses to answer from a snapshot older
1626
1700
  // than a write this reader has already seen, rather than returning something
1627
1701
  // they just lost access to. It is retryable on a fresher connection, which is
1628
1702
  // a different instruction from every other refusal here.
1629
1703
  "40001": "stale_read",
1704
+ // 57014 — the store cancelled the statement at its own timeout. Like
1705
+ // `stale_read` and unlike every other refusal here, the call was never
1706
+ // refused on its merits: the same call on a smaller page, or once the
1707
+ // organization's kernel is not being rewritten, can succeed. It gets its own
1708
+ // code so a screen can offer "try again" honestly instead of showing a
1709
+ // failure sentence the caller cannot act on.
1710
+ "57014": "timed_out",
1630
1711
  // PostgREST's own two: the store is not being SERVED, which is a different
1631
1712
  // thing from the store refusing. `custom` absent from `pgrst.db_schemas`, or
1632
1713
  // the grants not copied, land here.
@@ -1990,6 +2071,27 @@ function createRecordsClient(config) {
1990
2071
  "tableCapacity"
1991
2072
  );
1992
2073
  },
2074
+ async fieldDeclare({ table_id, spec }) {
2075
+ return callDoor(
2076
+ DOORS.fieldDeclare,
2077
+ { p_organization_id: org, p_table_id: table_id, p_spec: spec },
2078
+ "fieldDeclare"
2079
+ );
2080
+ },
2081
+ async fieldUpdate({ field_id, patch }) {
2082
+ return callDoor(
2083
+ DOORS.fieldUpdate,
2084
+ { p_organization_id: org, p_field_id: field_id, p_patch: patch },
2085
+ "fieldUpdate"
2086
+ );
2087
+ },
2088
+ async fieldRetire({ field_id }) {
2089
+ return callDoor(
2090
+ DOORS.fieldRetire,
2091
+ { p_organization_id: org, p_field_id: field_id },
2092
+ "fieldRetire"
2093
+ );
2094
+ },
1993
2095
  async tableDeclare({ spec, homeId }) {
1994
2096
  return callDoor(
1995
2097
  DOORS.tableDeclare,