@ai-matrx/records 0.57.0 → 0.57.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,5 +1,5 @@
1
- import { T as Timestamp, p as Uuid, R as RecordDocument, q as RecordsResult, r as RecordGraphWritten, s as RecordRead, t as ReadRow, u as Field, S as StoredRecord, v as NewFieldDeclaration, w as FieldPatch, x as RecordRevision, y as ReadValue, z as FieldProposal, A as TableProposal, C as RecordsError, W as WriteConflict, D as PgError, E as StaleWriteDetail, G as PredictedRefusal } from '../types-DC2tYa4w.cjs';
2
- export { H as ABSENCE_REASONS, I as ACTOR_VOCABULARY, J as AbsenceReason, K as Actor, L as COMPUTE_ON, M as CONTEXT_POLICIES, O as ComputeOn, Q as ContextPolicy, V as DECLARABLE_FIELD_KINDS, X as DELIVERIES, Y as DeclarableFieldKind, Z as Delivery, _ as ENTITY_TOKENS, $ as EntityToken, a0 as FIELD_SENSITIVITIES, a1 as FIELD_SOURCES, a2 as FRESHNESS, a3 as FieldBehavior, a4 as FieldRule, a5 as FieldSensitivity, a6 as FieldSource, a7 as FieldTypeWord, a8 as ForbiddenEnvelopeWord, a9 as Freshness, aa as HiddenFieldNotice, ab as KERNEL_TABLES, ac as KernelTableName, ad as MERGE_FIELD_MODIFIERS, ae as MERGE_FIELD_SEMANTIC_TYPES, af as MERGE_FIELD_SOURCES, ag as MergeFieldModifier, ah as MergeFieldSemanticType, ai as MergeFieldSource, aj as ON_DELETE, ak as OVERRIDE_POLICIES, al as OnDelete, am as OverridePolicy, an as PARITY_FIELD_TYPES, ao as PER_VALUE_ACCESS_WORDS, ap as ParityFieldType, aq as ParityFieldTypeDescriptor, ar as PerValueAccessWord, as as ProvenancePointer, at as RELATION_BINDINGS, au as RELATION_CARDINALITIES, av as RELATION_FLAVORS, aw as RETIRED_ACTOR_WORDS, ax as RULE_NODE_KINDS, ay as RULE_USES, az as RecordsErrorCode, aA as RelationBinding, aB as RelationCardinality, aC as RelationDisplay, aD as RelationFlavor, aE as RetiredActorWord, aF as RuleNodeKind, aG as RuleUse, aH as STORAGE_MODES, aI as STORE_DOORS, aJ as STORE_KNOBS, aK as STORE_REFUSAL_CODES, aL as StorageMode, aM as StoreDoorName, aN as StoreRefusalCode, aO as TABLE_DISPLAYS, aP as TABLE_ORIGINS, aQ as TABLE_TYPES, aR as TableDisplay, aS as TableOrigin, aT as TableType, aU as VALUE_ALTERNATE_KEYS, aV as VALUE_ENVELOPE_KEYS, aW as ValueAlternate, aX as ValueAlternateKey, aY as ValueEnvelope, aZ as ValueEnvelopeKey, a_ as ValueSource, a$ as err, b0 as isRecordsErr, b1 as ok } from '../types-DC2tYa4w.cjs';
1
+ import { T as Timestamp, p as Uuid, R as RecordsErrorCode, q as RecordDocument, r as RecordsResult, s as RecordGraphWritten, t as RecordRead, u as ReadRow, v as Field, S as StoredRecord, w as NewFieldDeclaration, x as FieldPatch, y as RecordRevision, z as ReadValue, A as FieldProposal, C as TableProposal, D as RecordsError, W as WriteConflict, E as PgError, G as StaleWriteDetail, H as PredictedRefusal } from '../types-BpBSMhYq.cjs';
2
+ export { I as ABSENCE_REASONS, J as ACTOR_VOCABULARY, K as AbsenceReason, L as Actor, M as COMPUTE_ON, O as CONTEXT_POLICIES, Q as ComputeOn, V as ContextPolicy, X as DECLARABLE_FIELD_KINDS, Y as DELIVERIES, Z as DeclarableFieldKind, _ as Delivery, $ as ENTITY_TOKENS, a0 as EntityToken, a1 as FIELD_SENSITIVITIES, a2 as FIELD_SOURCES, a3 as FRESHNESS, a4 as FieldBehavior, a5 as FieldRule, a6 as FieldSensitivity, a7 as FieldSource, a8 as FieldTypeWord, a9 as ForbiddenEnvelopeWord, aa as Freshness, ab as HiddenFieldNotice, ac as KERNEL_TABLES, ad as KernelTableName, ae as MERGE_FIELD_MODIFIERS, af as MERGE_FIELD_SEMANTIC_TYPES, ag as MERGE_FIELD_SOURCES, ah as MergeFieldModifier, ai as MergeFieldSemanticType, aj as MergeFieldSource, ak as ON_DELETE, al as OVERRIDE_POLICIES, am as OnDelete, an as OverridePolicy, ao as PARITY_FIELD_TYPES, ap as PER_VALUE_ACCESS_WORDS, aq as ParityFieldType, ar as ParityFieldTypeDescriptor, as as PerValueAccessWord, at as ProvenancePointer, au as RELATION_BINDINGS, av as RELATION_CARDINALITIES, aw as RELATION_FLAVORS, ax as RETIRED_ACTOR_WORDS, ay as RULE_NODE_KINDS, az as RULE_USES, aA as RelationBinding, aB as RelationCardinality, aC as RelationDisplay, aD as RelationFlavor, aE as RetiredActorWord, aF as RuleNodeKind, aG as RuleUse, aH as STORAGE_MODES, aI as STORE_DOORS, aJ as STORE_KNOBS, aK as STORE_REFUSAL_CODES, aL as StorageMode, aM as StoreDoorName, aN as StoreRefusalCode, aO as TABLE_DISPLAYS, aP as TABLE_ORIGINS, aQ as TABLE_TYPES, aR as TableDisplay, aS as TableOrigin, aT as TableType, aU as VALUE_ALTERNATE_KEYS, aV as VALUE_ENVELOPE_KEYS, aW as ValueAlternate, aX as ValueAlternateKey, aY as ValueEnvelope, aZ as ValueEnvelopeKey, a_ as ValueSource, a$ as allowsOtherValues, b0 as err, b1 as isRecordsErr, b2 as ok } from '../types-BpBSMhYq.cjs';
3
3
  import { RelationCoordinate, RecordsConfig, TableArchiveProgress, RecordFilter, ArchiveLane, ArchivedRow, Table, TableCapacity, RelationWordsManyArgs, EntityTableFacts, NewEntityFieldDeclaration, EntityFieldRights, EntityRecordRead, EntityRecordsFound, Pipeline, PipelineColumn, PipelineVerdict, PipelineMoveResult, PipelineSpec, PipelineDeclared, StageRuleOnFail, StageRuleEnforcement, StagePending, StagePendingOnBoard, PipelineGate, PipelineGatePreview, FormSummary, BookingSummary, BookingAvailability, BookingDeclared, ImportPlan, ImportPolicy, ImportOpened, ImportColumnsDeclared, ImportBatchResult, ImportFinished, ImportReport, ImportRun, InboundDeclared, InboundAddress, PortalSummary, PortalArchiveFilter, PortalArchiveAnswer, PortalTableRef, PortalCard, PortalInvitation, PortalRevocation, PortalPreviewRow, DashboardSummary, DashboardBlock, DashboardRunResult, StuckRow, CaptureSheetSummary, CaptureSheetFace, CaptureFileRef, CaptureOutcome, EnrichmentSummary, EnrichDeclared, EnrichDueRow, EnrichCell, EnrichRun, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, MySubscription, SubscriptionSpec, DigestPreview, SavedViewRow, SavedViewSpecIn, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordHistoryEntry, RecordScopeContext, ConversationScope, ConversationScopeContext, FieldHistoryEntry, RestorePreview, RestoreResult, CommentThreadRead, CommentWritten, AnonTokenBinding, ChecklistSpec, ChecklistDeclared, ChecklistTemplateSummary, ChecklistTemplateShape, ChecklistRunStarted, ChecklistRunStep, ChecklistRunSummary, ChecklistStepCompleted, WorkState, WorkGraph, WorkInstantiation, WorkTurn, WorkAssignmentField, WorkSlotHold, WorkInboxItem, WorkListFlavour, WorkListItem, WorkAssignment, WorkRecordState, WorkApprover, WorkChange, WorkApprovalFiled, WorkApprovalDecision, ExternalPrincipalCard, PublishBinding, ResolvedPublishBinding, MyLevel, DecorationPath, TableDecorations, GridLayout, FormulaParse, RowAction, ActionRunResult, RecordEvent, TableWebhookDeclared, TableWebhook, ExampleBuilt, IoExportPage, RecordsDataSource } from '../index.cjs';
4
4
  export { ARCHIVE_LANES, ARCHIVE_LANE_LABEL, ARCHIVE_LANE_MEANS, ActionRefusal, AggregateFilter, AggregateOperation, AggregateWindow, ArchivedDoorRow, BookingWindow, CaptureField, CaptureQuestion, CaptureQueue, CaptureQueueCounts, CaptureQueueOptions, CaptureQueuePorts, CaptureQueueStore, CaptureSyncReport, ChecklistRequirement, ChecklistRequirementKind, ChecklistRoleSpec, ChecklistStepSpec, ChecklistTrigger, ChecklistTriggerKind, ChoiceOption, ChoiceOptions, CoerceOptions, Coerced, CoercedAnswers, CoercibleField, CustomFieldTableType, DEFAULT_ARCHIVE_LANE, DEFAULT_PORTAL_ARCHIVE_FILTER, DashboardBlockKind, DashboardBlockResult, DecorationColor, DecorationRule, DecorationRuleOp, DecorationTarget, DocSignatureCheck, EnrichAlternate, EnrichSource, Enrichment, EntityFieldValue, EntityRecordMatch, ExampleSpec, FIELD_KINDS, FieldKind, GridLayoutMode, GridRowHeight, HistoryActor, HistoryActorKind, HistoryChange, Home, ImportColumnPlan, ImportOutcome, ImportProposal, KernelTargets, MergeField, MergeFieldProvenance, MergeFieldResolution, MergeFieldTransform, MissingBehavior, PERMISSION_LEVELS, PIPELINE_RULE_KINDS, PORTAL_ARCHIVE_FILTERS, PermissionLevel, PipelineMissingField, PipelineRule, PipelineRuleKind, PipelineStage, PortalPrincipal, PortalTableExposure, QueuedCapture, QueuedCaptureFile, QueuedCaptureState, QuietHours, REFUSALS_WORTH_REPEATING, RecordChangeAction, RecordComment, RecordScopeComment, RecordScopeField, RecordScopeHistoryEntry, RecordScopeRelation, RecordScopeWithheld, RecordsActor, RecordsChangeSink, RecordsErrorSink, RecordsFilter, RecordsRealtimePort, RecordsResolverPort, RecordsResponse, RecordsTableQuery, RegisteredTable, Relation, RelationCarries, RelationDisplaySpec, RelationProperties, RelationStore, RelationTarget, ResolutionTriple, RowActionStep, Rule, RuleAnswer, RuleExpression, STAGE_RULE_ENFORCEMENT, STAGE_RULE_ON_FAIL, StageRuleWarning, SubscriptionBlock, SubscriptionCadence, ViewLayout, WorkDueState, WorkInboxKind, WorkOrigin, WorkTemplateNode, WorkTemplateRelation, actionRefusals, archivedByLine, archivedWhen, asPermissionLevel, atLeast, bookingPath, choiceSlug, choiceValuesOf, choicesOf, coerceTypedAnswer, coerceTypedAnswers, coercionLabel, emptyArchiveLine, emptyPortalArchiveLine, exampleSpec, exportPageXlsx, fieldKindFor, forgetAllOps, highestLevel, holdsARetiredChoice, indexedDbStore, isArchiveLane, isDecided, isOwnOp, isPortalArchiveFilter, isTheChosen, looksLikeAnId, mayDrag, measureKey, memoryStore, mintClientKey, mintOpId, openCaptureQueue, optionKey, optionLabel, portalArchiveConsequence, portalConfirmLine, portalPath, portalTitleTypedBack, publicFormPath, recordChangeTrigger, rememberedOpCount, sameDocument, scopeChip, stableFilterKey } from '../index.cjs';
5
5
 
@@ -85,6 +85,23 @@ declare function planQuery(query: RecordQuery): QueryPlan;
85
85
  /** The intersection of the id sets a plan's calls produced. Order is preserved from the first set. */
86
86
  declare function intersectIds(sets: Uuid[][]): Uuid[];
87
87
 
88
+ /**
89
+ * 🚨 A REFUSAL IS NOT AN APP ERROR (lane RECORDS-UI-FIX, guide re-walk 2026-09-23).
90
+ *
91
+ * A person typing `-3` into a column that takes "at least 0" is the store WORKING: the
92
+ * rule said no, the screen said so in the one notice, and the person fixed it. The default
93
+ * sink printed every one of those through `console.error`, and the app's error capture
94
+ * (matrx-frontend `lib/diagnostics/globalErrorCapture.ts`) counts every `console.error` —
95
+ * so one refused value lit a red "2 errors" pill in the corner, telling an admin the
96
+ * product had failed when a person had simply been told no.
97
+ *
98
+ * These are the codes a PERSON causes by what they typed or when they typed it; each one
99
+ * is already drawn on the screen that asked. They are still said (`console.info`), never
100
+ * silenced. Everything else — a door, the store switched off, a timeout, a class this
101
+ * package did not recognise — is a failure of the system and stays `console.error`.
102
+ */
103
+ declare const A_PERSONS_REFUSAL: ReadonlySet<RecordsErrorCode>;
104
+ declare function isAPersonsRefusal(code: RecordsErrorCode | string): boolean;
88
105
  interface RecordsClient {
89
106
  /** The config this client was built with, so a screen can show who it is acting as. */
90
107
  readonly config: RecordsConfig;
@@ -286,6 +303,16 @@ interface RecordsClient {
286
303
  total: number | null;
287
304
  }>>;
288
305
  tableList(): Promise<RecordsResult<Table[]>>;
306
+ /**
307
+ * IS THIS TABLE IN THE ARCHIVE? (lane HUB-FIX, 2026-09-23.) The archived row for one
308
+ * Table of this organization, or `null` when the archive does not hold it — which
309
+ * is an ANSWER, never "it may have been deleted". A table page that cannot find a
310
+ * Table asks this before saying anything: an archived Table's own address used to
311
+ * read "…or it may have been deleted" when it was archived and one click from back.
312
+ */
313
+ tableArchived(args: {
314
+ table_id: Uuid;
315
+ }): Promise<RecordsResult<ArchivedRow | null>>;
289
316
  fields(args: {
290
317
  table_id: Uuid;
291
318
  recordType?: string;
@@ -1704,6 +1731,7 @@ declare const DOORS: {
1704
1731
  readonly inboundSet: "inbound_set";
1705
1732
  readonly portals: "portals";
1706
1733
  readonly portalTables: "portal_tables";
1734
+ readonly tableFacts: "table_facts";
1707
1735
  readonly portalCard: "portal_card";
1708
1736
  readonly portalDeclare: "portal_declare";
1709
1737
  readonly portalInvite: "portal_invite";
@@ -1838,6 +1866,12 @@ declare function doorCensus(): {
1838
1866
  absent: string[];
1839
1867
  };
1840
1868
 
1869
+ type Listener = (recordId: string) => void;
1870
+ /** Called by the client after a write door answered yes. */
1871
+ declare function announceRecordChanged(recordId: string): void;
1872
+ /** Hear every record this page writes. Returns the unsubscribe. */
1873
+ declare function onRecordChanged(listener: Listener): () => void;
1874
+
1841
1875
  /**
1842
1876
  * The structural shape of the supabase client this adapter needs. Deliberately
1843
1877
  * NOT `SupabaseClient<Database>`: a generated `Database` type makes
@@ -1955,4 +1989,4 @@ declare function parseCsv(text: string): string[][];
1955
1989
  declare function importCsv(text: string): ParsedImport;
1956
1990
  declare function importXlsx(bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1957
1991
 
1958
- export { ActionRunResult, AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, ArchiveLane, ArchivedRow, type AsOf, BookingAvailability, BookingDeclared, BookingSummary, CaptureFileRef, CaptureOutcome, CaptureSheetFace, CaptureSheetSummary, ChecklistDeclared, ChecklistRunStarted, ChecklistRunStep, ChecklistRunSummary, ChecklistSpec, ChecklistStepCompleted, ChecklistTemplateShape, ChecklistTemplateSummary, CommentThreadRead, CommentWritten, ConversationScope, ConversationScopeContext, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DashboardBlock, DashboardRunResult, DashboardSummary, DecorationPath, DigestPreview, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EnrichCell, EnrichDeclared, EnrichDueRow, EnrichRun, EnrichmentSummary, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, ExampleBuilt, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, FormulaParse, GridLayout, ImportBatchResult, ImportColumnsDeclared, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, IoExportPage, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, Pipeline, PipelineColumn, PipelineDeclared, PipelineGate, PipelineGatePreview, PipelineMoveResult, PipelineSpec, PipelineVerdict, PortalArchiveAnswer, PortalArchiveFilter, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PortalTableRef, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordEvent, RecordFilter, RecordGraphWritten, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, RelationWordsManyArgs, ResolvedPublishBinding, RestorePreview, RestoreResult, RowAction, SavedViewRow, SavedViewSpecIn, StagePending, StagePendingOnBoard, StageRuleEnforcement, StageRuleOnFail, StaleWriteDetail, StoredRecord, StuckRow, Subscription, SubscriptionSpec, type SupabaseLike, Table, TableArchiveProgress, TableCapacity, TableDecorations, TableProposal, TableWebhook, TableWebhookDeclared, Timestamp, Uuid, WorkApprovalDecision, WorkApprovalFiled, WorkApprover, WorkAssignment, WorkAssignmentField, WorkChange, WorkGraph, WorkInboxItem, WorkInstantiation, WorkListFlavour, WorkListItem, WorkRecordState, 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 };
1992
+ export { A_PERSONS_REFUSAL, ActionRunResult, AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, ArchiveLane, ArchivedRow, type AsOf, BookingAvailability, BookingDeclared, BookingSummary, CaptureFileRef, CaptureOutcome, CaptureSheetFace, CaptureSheetSummary, ChecklistDeclared, ChecklistRunStarted, ChecklistRunStep, ChecklistRunSummary, ChecklistSpec, ChecklistStepCompleted, ChecklistTemplateShape, ChecklistTemplateSummary, CommentThreadRead, CommentWritten, ConversationScope, ConversationScopeContext, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DashboardBlock, DashboardRunResult, DashboardSummary, DecorationPath, DigestPreview, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EnrichCell, EnrichDeclared, EnrichDueRow, EnrichRun, EnrichmentSummary, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, ExampleBuilt, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, FormulaParse, GridLayout, ImportBatchResult, ImportColumnsDeclared, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, IoExportPage, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, Pipeline, PipelineColumn, PipelineDeclared, PipelineGate, PipelineGatePreview, PipelineMoveResult, PipelineSpec, PipelineVerdict, PortalArchiveAnswer, PortalArchiveFilter, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PortalTableRef, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordEvent, RecordFilter, RecordGraphWritten, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsErrorCode, RecordsResult, RelationCoordinate, RelationWordsManyArgs, ResolvedPublishBinding, RestorePreview, RestoreResult, RowAction, SavedViewRow, SavedViewSpecIn, StagePending, StagePendingOnBoard, StageRuleEnforcement, StageRuleOnFail, StaleWriteDetail, StoredRecord, StuckRow, Subscription, SubscriptionSpec, type SupabaseLike, Table, TableArchiveProgress, TableCapacity, TableDecorations, TableProposal, TableWebhook, TableWebhookDeclared, Timestamp, Uuid, WorkApprovalDecision, WorkApprovalFiled, WorkApprover, WorkAssignment, WorkAssignmentField, WorkChange, WorkGraph, WorkInboxItem, WorkInstantiation, WorkListFlavour, WorkListItem, WorkRecordState, WorkSlotHold, WorkState, WorkTurn, WriteConflict, announceRecordChanged, asWriteConflict, cellText, createRecordsClient, doorAbsent, doorCensus, doorExists, exportCsv, exportXlsx, importCsv, importXlsx, intersectIds, isAPersonsRefusal, mapPgError, onRecordChanged, parseCsv, planQuery, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, toAoa };
@@ -1,5 +1,5 @@
1
- import { T as Timestamp, p as Uuid, R as RecordDocument, q as RecordsResult, r as RecordGraphWritten, s as RecordRead, t as ReadRow, u as Field, S as StoredRecord, v as NewFieldDeclaration, w as FieldPatch, x as RecordRevision, y as ReadValue, z as FieldProposal, A as TableProposal, C as RecordsError, W as WriteConflict, D as PgError, E as StaleWriteDetail, G as PredictedRefusal } from '../types-DC2tYa4w.js';
2
- export { H as ABSENCE_REASONS, I as ACTOR_VOCABULARY, J as AbsenceReason, K as Actor, L as COMPUTE_ON, M as CONTEXT_POLICIES, O as ComputeOn, Q as ContextPolicy, V as DECLARABLE_FIELD_KINDS, X as DELIVERIES, Y as DeclarableFieldKind, Z as Delivery, _ as ENTITY_TOKENS, $ as EntityToken, a0 as FIELD_SENSITIVITIES, a1 as FIELD_SOURCES, a2 as FRESHNESS, a3 as FieldBehavior, a4 as FieldRule, a5 as FieldSensitivity, a6 as FieldSource, a7 as FieldTypeWord, a8 as ForbiddenEnvelopeWord, a9 as Freshness, aa as HiddenFieldNotice, ab as KERNEL_TABLES, ac as KernelTableName, ad as MERGE_FIELD_MODIFIERS, ae as MERGE_FIELD_SEMANTIC_TYPES, af as MERGE_FIELD_SOURCES, ag as MergeFieldModifier, ah as MergeFieldSemanticType, ai as MergeFieldSource, aj as ON_DELETE, ak as OVERRIDE_POLICIES, al as OnDelete, am as OverridePolicy, an as PARITY_FIELD_TYPES, ao as PER_VALUE_ACCESS_WORDS, ap as ParityFieldType, aq as ParityFieldTypeDescriptor, ar as PerValueAccessWord, as as ProvenancePointer, at as RELATION_BINDINGS, au as RELATION_CARDINALITIES, av as RELATION_FLAVORS, aw as RETIRED_ACTOR_WORDS, ax as RULE_NODE_KINDS, ay as RULE_USES, az as RecordsErrorCode, aA as RelationBinding, aB as RelationCardinality, aC as RelationDisplay, aD as RelationFlavor, aE as RetiredActorWord, aF as RuleNodeKind, aG as RuleUse, aH as STORAGE_MODES, aI as STORE_DOORS, aJ as STORE_KNOBS, aK as STORE_REFUSAL_CODES, aL as StorageMode, aM as StoreDoorName, aN as StoreRefusalCode, aO as TABLE_DISPLAYS, aP as TABLE_ORIGINS, aQ as TABLE_TYPES, aR as TableDisplay, aS as TableOrigin, aT as TableType, aU as VALUE_ALTERNATE_KEYS, aV as VALUE_ENVELOPE_KEYS, aW as ValueAlternate, aX as ValueAlternateKey, aY as ValueEnvelope, aZ as ValueEnvelopeKey, a_ as ValueSource, a$ as err, b0 as isRecordsErr, b1 as ok } from '../types-DC2tYa4w.js';
1
+ import { T as Timestamp, p as Uuid, R as RecordsErrorCode, q as RecordDocument, r as RecordsResult, s as RecordGraphWritten, t as RecordRead, u as ReadRow, v as Field, S as StoredRecord, w as NewFieldDeclaration, x as FieldPatch, y as RecordRevision, z as ReadValue, A as FieldProposal, C as TableProposal, D as RecordsError, W as WriteConflict, E as PgError, G as StaleWriteDetail, H as PredictedRefusal } from '../types-BpBSMhYq.js';
2
+ export { I as ABSENCE_REASONS, J as ACTOR_VOCABULARY, K as AbsenceReason, L as Actor, M as COMPUTE_ON, O as CONTEXT_POLICIES, Q as ComputeOn, V as ContextPolicy, X as DECLARABLE_FIELD_KINDS, Y as DELIVERIES, Z as DeclarableFieldKind, _ as Delivery, $ as ENTITY_TOKENS, a0 as EntityToken, a1 as FIELD_SENSITIVITIES, a2 as FIELD_SOURCES, a3 as FRESHNESS, a4 as FieldBehavior, a5 as FieldRule, a6 as FieldSensitivity, a7 as FieldSource, a8 as FieldTypeWord, a9 as ForbiddenEnvelopeWord, aa as Freshness, ab as HiddenFieldNotice, ac as KERNEL_TABLES, ad as KernelTableName, ae as MERGE_FIELD_MODIFIERS, af as MERGE_FIELD_SEMANTIC_TYPES, ag as MERGE_FIELD_SOURCES, ah as MergeFieldModifier, ai as MergeFieldSemanticType, aj as MergeFieldSource, ak as ON_DELETE, al as OVERRIDE_POLICIES, am as OnDelete, an as OverridePolicy, ao as PARITY_FIELD_TYPES, ap as PER_VALUE_ACCESS_WORDS, aq as ParityFieldType, ar as ParityFieldTypeDescriptor, as as PerValueAccessWord, at as ProvenancePointer, au as RELATION_BINDINGS, av as RELATION_CARDINALITIES, aw as RELATION_FLAVORS, ax as RETIRED_ACTOR_WORDS, ay as RULE_NODE_KINDS, az as RULE_USES, aA as RelationBinding, aB as RelationCardinality, aC as RelationDisplay, aD as RelationFlavor, aE as RetiredActorWord, aF as RuleNodeKind, aG as RuleUse, aH as STORAGE_MODES, aI as STORE_DOORS, aJ as STORE_KNOBS, aK as STORE_REFUSAL_CODES, aL as StorageMode, aM as StoreDoorName, aN as StoreRefusalCode, aO as TABLE_DISPLAYS, aP as TABLE_ORIGINS, aQ as TABLE_TYPES, aR as TableDisplay, aS as TableOrigin, aT as TableType, aU as VALUE_ALTERNATE_KEYS, aV as VALUE_ENVELOPE_KEYS, aW as ValueAlternate, aX as ValueAlternateKey, aY as ValueEnvelope, aZ as ValueEnvelopeKey, a_ as ValueSource, a$ as allowsOtherValues, b0 as err, b1 as isRecordsErr, b2 as ok } from '../types-BpBSMhYq.js';
3
3
  import { RelationCoordinate, RecordsConfig, TableArchiveProgress, RecordFilter, ArchiveLane, ArchivedRow, Table, TableCapacity, RelationWordsManyArgs, EntityTableFacts, NewEntityFieldDeclaration, EntityFieldRights, EntityRecordRead, EntityRecordsFound, Pipeline, PipelineColumn, PipelineVerdict, PipelineMoveResult, PipelineSpec, PipelineDeclared, StageRuleOnFail, StageRuleEnforcement, StagePending, StagePendingOnBoard, PipelineGate, PipelineGatePreview, FormSummary, BookingSummary, BookingAvailability, BookingDeclared, ImportPlan, ImportPolicy, ImportOpened, ImportColumnsDeclared, ImportBatchResult, ImportFinished, ImportReport, ImportRun, InboundDeclared, InboundAddress, PortalSummary, PortalArchiveFilter, PortalArchiveAnswer, PortalTableRef, PortalCard, PortalInvitation, PortalRevocation, PortalPreviewRow, DashboardSummary, DashboardBlock, DashboardRunResult, StuckRow, CaptureSheetSummary, CaptureSheetFace, CaptureFileRef, CaptureOutcome, EnrichmentSummary, EnrichDeclared, EnrichDueRow, EnrichCell, EnrichRun, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, MySubscription, SubscriptionSpec, DigestPreview, SavedViewRow, SavedViewSpecIn, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordHistoryEntry, RecordScopeContext, ConversationScope, ConversationScopeContext, FieldHistoryEntry, RestorePreview, RestoreResult, CommentThreadRead, CommentWritten, AnonTokenBinding, ChecklistSpec, ChecklistDeclared, ChecklistTemplateSummary, ChecklistTemplateShape, ChecklistRunStarted, ChecklistRunStep, ChecklistRunSummary, ChecklistStepCompleted, WorkState, WorkGraph, WorkInstantiation, WorkTurn, WorkAssignmentField, WorkSlotHold, WorkInboxItem, WorkListFlavour, WorkListItem, WorkAssignment, WorkRecordState, WorkApprover, WorkChange, WorkApprovalFiled, WorkApprovalDecision, ExternalPrincipalCard, PublishBinding, ResolvedPublishBinding, MyLevel, DecorationPath, TableDecorations, GridLayout, FormulaParse, RowAction, ActionRunResult, RecordEvent, TableWebhookDeclared, TableWebhook, ExampleBuilt, IoExportPage, RecordsDataSource } from '../index.js';
4
4
  export { ARCHIVE_LANES, ARCHIVE_LANE_LABEL, ARCHIVE_LANE_MEANS, ActionRefusal, AggregateFilter, AggregateOperation, AggregateWindow, ArchivedDoorRow, BookingWindow, CaptureField, CaptureQuestion, CaptureQueue, CaptureQueueCounts, CaptureQueueOptions, CaptureQueuePorts, CaptureQueueStore, CaptureSyncReport, ChecklistRequirement, ChecklistRequirementKind, ChecklistRoleSpec, ChecklistStepSpec, ChecklistTrigger, ChecklistTriggerKind, ChoiceOption, ChoiceOptions, CoerceOptions, Coerced, CoercedAnswers, CoercibleField, CustomFieldTableType, DEFAULT_ARCHIVE_LANE, DEFAULT_PORTAL_ARCHIVE_FILTER, DashboardBlockKind, DashboardBlockResult, DecorationColor, DecorationRule, DecorationRuleOp, DecorationTarget, DocSignatureCheck, EnrichAlternate, EnrichSource, Enrichment, EntityFieldValue, EntityRecordMatch, ExampleSpec, FIELD_KINDS, FieldKind, GridLayoutMode, GridRowHeight, HistoryActor, HistoryActorKind, HistoryChange, Home, ImportColumnPlan, ImportOutcome, ImportProposal, KernelTargets, MergeField, MergeFieldProvenance, MergeFieldResolution, MergeFieldTransform, MissingBehavior, PERMISSION_LEVELS, PIPELINE_RULE_KINDS, PORTAL_ARCHIVE_FILTERS, PermissionLevel, PipelineMissingField, PipelineRule, PipelineRuleKind, PipelineStage, PortalPrincipal, PortalTableExposure, QueuedCapture, QueuedCaptureFile, QueuedCaptureState, QuietHours, REFUSALS_WORTH_REPEATING, RecordChangeAction, RecordComment, RecordScopeComment, RecordScopeField, RecordScopeHistoryEntry, RecordScopeRelation, RecordScopeWithheld, RecordsActor, RecordsChangeSink, RecordsErrorSink, RecordsFilter, RecordsRealtimePort, RecordsResolverPort, RecordsResponse, RecordsTableQuery, RegisteredTable, Relation, RelationCarries, RelationDisplaySpec, RelationProperties, RelationStore, RelationTarget, ResolutionTriple, RowActionStep, Rule, RuleAnswer, RuleExpression, STAGE_RULE_ENFORCEMENT, STAGE_RULE_ON_FAIL, StageRuleWarning, SubscriptionBlock, SubscriptionCadence, ViewLayout, WorkDueState, WorkInboxKind, WorkOrigin, WorkTemplateNode, WorkTemplateRelation, actionRefusals, archivedByLine, archivedWhen, asPermissionLevel, atLeast, bookingPath, choiceSlug, choiceValuesOf, choicesOf, coerceTypedAnswer, coerceTypedAnswers, coercionLabel, emptyArchiveLine, emptyPortalArchiveLine, exampleSpec, exportPageXlsx, fieldKindFor, forgetAllOps, highestLevel, holdsARetiredChoice, indexedDbStore, isArchiveLane, isDecided, isOwnOp, isPortalArchiveFilter, isTheChosen, looksLikeAnId, mayDrag, measureKey, memoryStore, mintClientKey, mintOpId, openCaptureQueue, optionKey, optionLabel, portalArchiveConsequence, portalConfirmLine, portalPath, portalTitleTypedBack, publicFormPath, recordChangeTrigger, rememberedOpCount, sameDocument, scopeChip, stableFilterKey } from '../index.js';
5
5
 
@@ -85,6 +85,23 @@ declare function planQuery(query: RecordQuery): QueryPlan;
85
85
  /** The intersection of the id sets a plan's calls produced. Order is preserved from the first set. */
86
86
  declare function intersectIds(sets: Uuid[][]): Uuid[];
87
87
 
88
+ /**
89
+ * 🚨 A REFUSAL IS NOT AN APP ERROR (lane RECORDS-UI-FIX, guide re-walk 2026-09-23).
90
+ *
91
+ * A person typing `-3` into a column that takes "at least 0" is the store WORKING: the
92
+ * rule said no, the screen said so in the one notice, and the person fixed it. The default
93
+ * sink printed every one of those through `console.error`, and the app's error capture
94
+ * (matrx-frontend `lib/diagnostics/globalErrorCapture.ts`) counts every `console.error` —
95
+ * so one refused value lit a red "2 errors" pill in the corner, telling an admin the
96
+ * product had failed when a person had simply been told no.
97
+ *
98
+ * These are the codes a PERSON causes by what they typed or when they typed it; each one
99
+ * is already drawn on the screen that asked. They are still said (`console.info`), never
100
+ * silenced. Everything else — a door, the store switched off, a timeout, a class this
101
+ * package did not recognise — is a failure of the system and stays `console.error`.
102
+ */
103
+ declare const A_PERSONS_REFUSAL: ReadonlySet<RecordsErrorCode>;
104
+ declare function isAPersonsRefusal(code: RecordsErrorCode | string): boolean;
88
105
  interface RecordsClient {
89
106
  /** The config this client was built with, so a screen can show who it is acting as. */
90
107
  readonly config: RecordsConfig;
@@ -286,6 +303,16 @@ interface RecordsClient {
286
303
  total: number | null;
287
304
  }>>;
288
305
  tableList(): Promise<RecordsResult<Table[]>>;
306
+ /**
307
+ * IS THIS TABLE IN THE ARCHIVE? (lane HUB-FIX, 2026-09-23.) The archived row for one
308
+ * Table of this organization, or `null` when the archive does not hold it — which
309
+ * is an ANSWER, never "it may have been deleted". A table page that cannot find a
310
+ * Table asks this before saying anything: an archived Table's own address used to
311
+ * read "…or it may have been deleted" when it was archived and one click from back.
312
+ */
313
+ tableArchived(args: {
314
+ table_id: Uuid;
315
+ }): Promise<RecordsResult<ArchivedRow | null>>;
289
316
  fields(args: {
290
317
  table_id: Uuid;
291
318
  recordType?: string;
@@ -1704,6 +1731,7 @@ declare const DOORS: {
1704
1731
  readonly inboundSet: "inbound_set";
1705
1732
  readonly portals: "portals";
1706
1733
  readonly portalTables: "portal_tables";
1734
+ readonly tableFacts: "table_facts";
1707
1735
  readonly portalCard: "portal_card";
1708
1736
  readonly portalDeclare: "portal_declare";
1709
1737
  readonly portalInvite: "portal_invite";
@@ -1838,6 +1866,12 @@ declare function doorCensus(): {
1838
1866
  absent: string[];
1839
1867
  };
1840
1868
 
1869
+ type Listener = (recordId: string) => void;
1870
+ /** Called by the client after a write door answered yes. */
1871
+ declare function announceRecordChanged(recordId: string): void;
1872
+ /** Hear every record this page writes. Returns the unsubscribe. */
1873
+ declare function onRecordChanged(listener: Listener): () => void;
1874
+
1841
1875
  /**
1842
1876
  * The structural shape of the supabase client this adapter needs. Deliberately
1843
1877
  * NOT `SupabaseClient<Database>`: a generated `Database` type makes
@@ -1955,4 +1989,4 @@ declare function parseCsv(text: string): string[][];
1955
1989
  declare function importCsv(text: string): ParsedImport;
1956
1990
  declare function importXlsx(bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1957
1991
 
1958
- export { ActionRunResult, AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, ArchiveLane, ArchivedRow, type AsOf, BookingAvailability, BookingDeclared, BookingSummary, CaptureFileRef, CaptureOutcome, CaptureSheetFace, CaptureSheetSummary, ChecklistDeclared, ChecklistRunStarted, ChecklistRunStep, ChecklistRunSummary, ChecklistSpec, ChecklistStepCompleted, ChecklistTemplateShape, ChecklistTemplateSummary, CommentThreadRead, CommentWritten, ConversationScope, ConversationScopeContext, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DashboardBlock, DashboardRunResult, DashboardSummary, DecorationPath, DigestPreview, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EnrichCell, EnrichDeclared, EnrichDueRow, EnrichRun, EnrichmentSummary, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, ExampleBuilt, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, FormulaParse, GridLayout, ImportBatchResult, ImportColumnsDeclared, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, IoExportPage, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, Pipeline, PipelineColumn, PipelineDeclared, PipelineGate, PipelineGatePreview, PipelineMoveResult, PipelineSpec, PipelineVerdict, PortalArchiveAnswer, PortalArchiveFilter, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PortalTableRef, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordEvent, RecordFilter, RecordGraphWritten, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, RelationWordsManyArgs, ResolvedPublishBinding, RestorePreview, RestoreResult, RowAction, SavedViewRow, SavedViewSpecIn, StagePending, StagePendingOnBoard, StageRuleEnforcement, StageRuleOnFail, StaleWriteDetail, StoredRecord, StuckRow, Subscription, SubscriptionSpec, type SupabaseLike, Table, TableArchiveProgress, TableCapacity, TableDecorations, TableProposal, TableWebhook, TableWebhookDeclared, Timestamp, Uuid, WorkApprovalDecision, WorkApprovalFiled, WorkApprover, WorkAssignment, WorkAssignmentField, WorkChange, WorkGraph, WorkInboxItem, WorkInstantiation, WorkListFlavour, WorkListItem, WorkRecordState, 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 };
1992
+ export { A_PERSONS_REFUSAL, ActionRunResult, AggregateBucket, AggregateMeasure, AggregateRow, AnonTokenBinding, ArchiveLane, ArchivedRow, type AsOf, BookingAvailability, BookingDeclared, BookingSummary, CaptureFileRef, CaptureOutcome, CaptureSheetFace, CaptureSheetSummary, ChecklistDeclared, ChecklistRunStarted, ChecklistRunStep, ChecklistRunSummary, ChecklistSpec, ChecklistStepCompleted, ChecklistTemplateShape, ChecklistTemplateSummary, CommentThreadRead, CommentWritten, ConversationScope, ConversationScopeContext, DEFAULT_DOCUMENT_MAX_BYTES, DEFAULT_PAGE_SIZE, DEFAULT_VALUE_MAX_BYTES, DOORS, DashboardBlock, DashboardRunResult, DashboardSummary, DecorationPath, DigestPreview, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EnrichCell, EnrichDeclared, EnrichDueRow, EnrichRun, EnrichmentSummary, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, ExampleBuilt, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, FormulaParse, GridLayout, ImportBatchResult, ImportColumnsDeclared, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, IoExportPage, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, Pipeline, PipelineColumn, PipelineDeclared, PipelineGate, PipelineGatePreview, PipelineMoveResult, PipelineSpec, PipelineVerdict, PortalArchiveAnswer, PortalArchiveFilter, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PortalTableRef, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordEvent, RecordFilter, RecordGraphWritten, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsErrorCode, RecordsResult, RelationCoordinate, RelationWordsManyArgs, ResolvedPublishBinding, RestorePreview, RestoreResult, RowAction, SavedViewRow, SavedViewSpecIn, StagePending, StagePendingOnBoard, StageRuleEnforcement, StageRuleOnFail, StaleWriteDetail, StoredRecord, StuckRow, Subscription, SubscriptionSpec, type SupabaseLike, Table, TableArchiveProgress, TableCapacity, TableDecorations, TableProposal, TableWebhook, TableWebhookDeclared, Timestamp, Uuid, WorkApprovalDecision, WorkApprovalFiled, WorkApprover, WorkAssignment, WorkAssignmentField, WorkChange, WorkGraph, WorkInboxItem, WorkInstantiation, WorkListFlavour, WorkListItem, WorkRecordState, WorkSlotHold, WorkState, WorkTurn, WriteConflict, announceRecordChanged, asWriteConflict, cellText, createRecordsClient, doorAbsent, doorCensus, doorExists, exportCsv, exportXlsx, importCsv, importXlsx, intersectIds, isAPersonsRefusal, mapPgError, onRecordChanged, parseCsv, planQuery, predictEnvelopeRefusal, predictSizeRefusal, predictValueRefusals, predictWriteRefusals, staleWriteDetail, supabaseDataSource, toAoa };
@@ -2292,6 +2292,11 @@ function highestLevel(left, right) {
2292
2292
  return ORDINAL[left] >= ORDINAL[right] ? left : right;
2293
2293
  }
2294
2294
 
2295
+ // src/field.ts
2296
+ function allowsOtherValues(field) {
2297
+ return field.type === "list" && field.config?.["allow_other"] === true;
2298
+ }
2299
+
2295
2300
  // src/choice.ts
2296
2301
  var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
2297
2302
  function optionKey(option) {
@@ -3666,6 +3671,7 @@ var STORE_DOORS = [
3666
3671
  { name: "table_declare", args: "p_organization_id uuid, p_spec jsonb", returns: "uuid", security: "definer" },
3667
3672
  { name: "table_decorate", args: "p_organization_id uuid, p_table_id uuid, p_path text[], p_value jsonb DEFAULT NULL::jsonb", returns: "jsonb", security: "definer" },
3668
3673
  { name: "table_decorations", args: "p_organization_id uuid, p_table_id uuid", returns: "jsonb", security: "definer" },
3674
+ { name: "table_facts", args: "p_organization_id uuid", returns: "TABLE(table_id uuid, visibility text, mine boolean)", security: "definer" },
3669
3675
  { name: "table_from_example", args: "p_organization_id uuid, p_home_id uuid, p_example jsonb", returns: "jsonb", security: "definer" },
3670
3676
  { name: "table_has_a_visible_record", args: "p_user uuid, p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "definer" },
3671
3677
  { name: "table_is_live", args: "p_organization_id uuid, p_table_id uuid", returns: "boolean", security: "invoker" },
@@ -5166,6 +5172,7 @@ var DOORS = {
5166
5172
  // everywhere in that organization. This is the one question the rail has to
5167
5173
  // ask, under the same wall and visibility gate as `portals` itself.
5168
5174
  portalTables: "portal_tables",
5175
+ tableFacts: "table_facts",
5169
5176
  portalCard: "portal_card",
5170
5177
  portalDeclare: "portal_declare",
5171
5178
  portalInvite: "portal_invite",
@@ -5550,6 +5557,22 @@ function staleWriteDetail(error) {
5550
5557
  };
5551
5558
  }
5552
5559
 
5560
+ // src/core/recordChanges.ts
5561
+ var listeners = /* @__PURE__ */ new Set();
5562
+ function announceRecordChanged(recordId) {
5563
+ for (const listener of [...listeners]) {
5564
+ try {
5565
+ listener(recordId);
5566
+ } catch (thrown) {
5567
+ console.error("[@ai-matrx/records] a record-change listener threw", thrown);
5568
+ }
5569
+ }
5570
+ }
5571
+ function onRecordChanged(listener) {
5572
+ listeners.add(listener);
5573
+ return () => listeners.delete(listener);
5574
+ }
5575
+
5553
5576
  // src/core/query.ts
5554
5577
  var DEFAULT_PAGE_SIZE = 50;
5555
5578
  function planQuery(query) {
@@ -5591,12 +5614,22 @@ function intersectIds(sets) {
5591
5614
 
5592
5615
  // src/core/client.ts
5593
5616
  var DEFAULT_SCHEMA = "custom";
5617
+ var A_PERSONS_REFUSAL = /* @__PURE__ */ new Set([
5618
+ "refused_by_rule",
5619
+ "stale_write",
5620
+ "invalid_argument",
5621
+ "already_exists",
5622
+ "missing_reference"
5623
+ ]);
5624
+ function isAPersonsRefusal(code) {
5625
+ return A_PERSONS_REFUSAL.has(code);
5626
+ }
5594
5627
  function sink(config) {
5595
- return config.onError ?? ((e) => (
5596
- // The defined degradation, stated: loud, with the store's own words, and
5597
- // naming where it happened. Never silence.
5598
- console.error(`[@ai-matrx/records] ${e.where}: ${e.code} \u2014 ${e.message}${e.hint ? ` (${e.hint})` : ""}`)
5599
- ));
5628
+ return config.onError ?? ((e) => {
5629
+ const line = `[@ai-matrx/records] ${e.where}: ${e.code} \u2014 ${e.message}${e.hint ? ` (${e.hint})` : ""}`;
5630
+ if (isAPersonsRefusal(e.code)) console.info(line);
5631
+ else console.error(line);
5632
+ });
5600
5633
  }
5601
5634
  function createRecordsClient(config) {
5602
5635
  const schema = config.schema ?? DEFAULT_SCHEMA;
@@ -5703,21 +5736,26 @@ function createRecordsClient(config) {
5703
5736
  },
5704
5737
  "recordUpdate"
5705
5738
  );
5739
+ if (result.ok) announceRecordChanged(record_id);
5706
5740
  return result;
5707
5741
  },
5708
5742
  async recordDelete({ record_id }) {
5709
- return callDoor(
5743
+ const result = await callDoor(
5710
5744
  DOORS.recordDelete,
5711
5745
  { p_organization_id: org, p_record_id: record_id },
5712
5746
  "recordDelete"
5713
5747
  );
5748
+ if (result.ok) announceRecordChanged(record_id);
5749
+ return result;
5714
5750
  },
5715
5751
  async recordRestore({ record_id }) {
5716
- return callDoor(
5752
+ const result = await callDoor(
5717
5753
  DOORS.recordRestore,
5718
5754
  { p_organization_id: org, p_record_id: record_id },
5719
5755
  "recordRestore"
5720
5756
  );
5757
+ if (result.ok) announceRecordChanged(record_id);
5758
+ return result;
5721
5759
  },
5722
5760
  async tableArchive({ table_id, chunk, includeTable }) {
5723
5761
  return callDoor(
@@ -5767,6 +5805,24 @@ function createRecordsClient(config) {
5767
5805
  })
5768
5806
  );
5769
5807
  },
5808
+ async tableArchived({ table_id }) {
5809
+ const kernel = await callDoor(DOORS.tableKernelId, {}, "tableArchived.kernel");
5810
+ if (!kernel.ok) return err(kernel.error);
5811
+ const PAGE = 200;
5812
+ for (let page = 0; page < 25; page += 1) {
5813
+ const answered = await this.listArchived({
5814
+ table_id: kernel.data,
5815
+ lane: "org",
5816
+ limit: PAGE,
5817
+ offset: page * PAGE
5818
+ });
5819
+ if (!answered.ok) return err(answered.error);
5820
+ const hit = answered.data.rows.find((row) => row.id === table_id);
5821
+ if (hit) return ok(hit);
5822
+ if (answered.data.total !== null) return ok(null);
5823
+ }
5824
+ return ok(null);
5825
+ },
5770
5826
  async listArchived({ table_id, lane = DEFAULT_ARCHIVE_LANE, limit = 50, offset = 0 }) {
5771
5827
  const door = await callDoor(
5772
5828
  DOORS.readRecordsArchived,
@@ -5932,6 +5988,23 @@ function createRecordsClient(config) {
5932
5988
  const { document } = unfold(row.document);
5933
5989
  return { ...document, id: row.id, organization_id: org };
5934
5990
  });
5991
+ if (doorExists(DOORS.tableFacts)) {
5992
+ const facts = await callDoor(
5993
+ DOORS.tableFacts,
5994
+ { p_organization_id: org },
5995
+ "tableList.facts"
5996
+ );
5997
+ if (facts.ok) {
5998
+ const byId = new Map((facts.data ?? []).map((f) => [f.table_id, f]));
5999
+ const me = config.actor.user_id ?? null;
6000
+ for (const table of tables) {
6001
+ const fact = byId.get(table.id);
6002
+ if (!fact) continue;
6003
+ table.visibility = fact.visibility;
6004
+ if (fact.mine && me) table.created_by = me;
6005
+ }
6006
+ }
6007
+ }
5935
6008
  tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
5936
6009
  return ok(tables);
5937
6010
  },
@@ -5968,9 +6041,11 @@ function createRecordsClient(config) {
5968
6041
  );
5969
6042
  },
5970
6043
  async fieldDeclare({ table_id, spec }) {
6044
+ const { allow_other, ...rest } = spec;
6045
+ const p_spec = allow_other === void 0 ? rest : { ...rest, config: { ...rest.config ?? {}, allow_other } };
5971
6046
  return callDoor(
5972
6047
  DOORS.fieldDeclare,
5973
- { p_organization_id: org, p_table_id: table_id, p_spec: spec },
6048
+ { p_organization_id: org, p_table_id: table_id, p_spec },
5974
6049
  "fieldDeclare"
5975
6050
  );
5976
6051
  },
@@ -6938,14 +7013,16 @@ function createRecordsClient(config) {
6938
7013
  );
6939
7014
  },
6940
7015
  async restoreVersion({ record_id, version }) {
6941
- return callDoor(
7016
+ const result = await callDoor(
6942
7017
  DOORS.restoreVersion,
6943
7018
  { p_organization_id: org, p_record_id: record_id, p_version: version },
6944
7019
  "restoreVersion"
6945
7020
  );
7021
+ if (result.ok) announceRecordChanged(record_id);
7022
+ return result;
6946
7023
  },
6947
7024
  async valueRestore({ record_id, field_key, version }) {
6948
- return callDoor(
7025
+ const answered = await callDoor(
6949
7026
  DOORS.valueRestore,
6950
7027
  {
6951
7028
  p_organization_id: org,
@@ -6955,6 +7032,8 @@ function createRecordsClient(config) {
6955
7032
  },
6956
7033
  "valueRestore"
6957
7034
  );
7035
+ if (answered.ok) announceRecordChanged(record_id);
7036
+ return answered;
6958
7037
  },
6959
7038
  async commentThread({ record_id, include_resolved }) {
6960
7039
  return callDoor(
@@ -7736,12 +7815,30 @@ function ruleRefusal(field, rule, item, values) {
7736
7815
  }
7737
7816
  return null;
7738
7817
  case "length":
7739
- if (typeof item === "string" && item.length > Number(rule.value)) {
7818
+ if (typeof item !== "string") return null;
7819
+ if (rule.value !== void 0 && rule.value !== null && rule.value !== "" && item.length > Number(rule.value)) {
7740
7820
  return { ...base, message: `${label} is longer than ${rule.value} characters`, hint: "FLD-3." };
7741
7821
  }
7822
+ if (typeof rule.min === "number" && item !== "" && item.length < rule.min) {
7823
+ return {
7824
+ ...base,
7825
+ message: `${label} has to be at least ${rule.min} characters long`,
7826
+ hint: "FLD-3.",
7827
+ detail: { field_key: field.key, rule: "length", min: rule.min }
7828
+ };
7829
+ }
7742
7830
  return null;
7743
7831
  case "pattern":
7744
7832
  if (typeof item === "string" && !new RegExp(String(rule.value)).test(item)) {
7833
+ const example = typeof rule.example === "string" ? rule.example.trim() : "";
7834
+ if (example !== "") {
7835
+ return {
7836
+ ...base,
7837
+ message: `${label} is not written the way this field expects`,
7838
+ hint: `Enter it like ${example}.`,
7839
+ detail: { field_key: field.key, rule: "pattern", example }
7840
+ };
7841
+ }
7745
7842
  return { ...base, message: `${label} is not written the way this field expects`, hint: "FLD-3." };
7746
7843
  }
7747
7844
  return null;
@@ -7826,12 +7923,6 @@ function predictValueRefusals(fields, values, recordType) {
7826
7923
  message: `${label} takes one of its choices, and it was given a ${jsonType(item)}`,
7827
7924
  hint: "FLD-5 / FLD-6: a list field stores the id of the option RECORD, because every pick-list is already a Table."
7828
7925
  });
7829
- } else if (!UUID2.test(item)) {
7830
- found.push({
7831
- ...base,
7832
- message: `${label} was given a choice that is not one of its choices`,
7833
- hint: `REC-51: option membership. ${label} stores the id of an option record, and what it was given is not an id at all.`
7834
- });
7835
7926
  }
7836
7927
  } else if (field.type === "relation") {
7837
7928
  if (typeof item !== "string") {
@@ -8126,6 +8217,7 @@ export {
8126
8217
  ARCHIVE_LANES,
8127
8218
  ARCHIVE_LANE_LABEL,
8128
8219
  ARCHIVE_LANE_MEANS,
8220
+ A_PERSONS_REFUSAL,
8129
8221
  COMPUTE_ON,
8130
8222
  CONTEXT_POLICIES,
8131
8223
  DECLARABLE_FIELD_KINDS,
@@ -8172,6 +8264,8 @@ export {
8172
8264
  VALUE_ALTERNATE_KEYS,
8173
8265
  VALUE_ENVELOPE_KEYS,
8174
8266
  actionRefusals,
8267
+ allowsOtherValues,
8268
+ announceRecordChanged,
8175
8269
  archivedByLine,
8176
8270
  archivedWhen,
8177
8271
  asPermissionLevel,
@@ -8204,6 +8298,7 @@ export {
8204
8298
  importXlsx,
8205
8299
  indexedDbStore,
8206
8300
  intersectIds,
8301
+ isAPersonsRefusal,
8207
8302
  isArchiveLane,
8208
8303
  isDecided,
8209
8304
  isOwnOp,
@@ -8218,6 +8313,7 @@ export {
8218
8313
  mintClientKey,
8219
8314
  mintOpId,
8220
8315
  ok,
8316
+ onRecordChanged,
8221
8317
  openCaptureQueue,
8222
8318
  optionKey,
8223
8319
  optionLabel,