@ai-matrx/records 0.57.2 → 0.57.3

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.
@@ -313,6 +313,23 @@ interface RecordsClient {
313
313
  tableArchived(args: {
314
314
  table_id: Uuid;
315
315
  }): Promise<RecordsResult<ArchivedRow | null>>;
316
+ /**
317
+ * WHO CAN SEE EACH TABLE, AND WHETHER THE CALLER MADE IT — `custom.table_facts`
318
+ * (lane HUB-FIX). `visibility` and `created_by` are record COLUMNS the Table document
319
+ * never carried, so a screen that sorts Tables into lanes asks this and folds the
320
+ * answer onto `tableList()`'s Tables with `withTableFacts`.
321
+ *
322
+ * 🚨 IT IS ITS OWN CALL, NOT PART OF `tableList()` (0.57.3). 0.57.2 folded it into
323
+ * every table list, so every screen that merely LISTS tables (the field editor's
324
+ * relation target, the import wizard, settings) paid a second round trip it never
325
+ * used — and every test double that answers a table list had to answer it too
326
+ * (records-ui 0.84.5's gate: 47 tests in 15 files red). Only the lane-sorting
327
+ * screens ask.
328
+ *
329
+ * The door-presence pattern: when the store's catalogue does not carry the door the
330
+ * answer is `null` — nothing asked, nothing invented.
331
+ */
332
+ tableFacts(): Promise<RecordsResult<TableFact[] | null>>;
316
333
  fields(args: {
317
334
  table_id: Uuid;
318
335
  recordType?: string;
@@ -1629,6 +1646,22 @@ interface RecordsClient {
1629
1646
  sheetLabel?: string;
1630
1647
  }): Promise<RecordsResult<Uint8Array>>;
1631
1648
  }
1649
+ /** One Table's two lane facts, as `custom.table_facts` answers them. */
1650
+ interface TableFact {
1651
+ table_id: Uuid;
1652
+ /** The record's own `visibility` column: personal · internal · link · public. */
1653
+ visibility: string;
1654
+ /** Whether the person signed in MADE this Table. Never who did. */
1655
+ mine: boolean;
1656
+ }
1657
+ /**
1658
+ * The facts folded onto a table list: `visibility` on every Table the facts name,
1659
+ * `created_by` ONLY as the caller's own id and only on the Tables the caller made.
1660
+ * Pure — returns new objects and leaves the list it was given alone.
1661
+ */
1662
+ declare function withTableFacts<T extends {
1663
+ id: Uuid;
1664
+ }>(tables: readonly T[], facts: readonly TableFact[] | null | undefined, me: Uuid | null | undefined): T[];
1632
1665
  declare function createRecordsClient(config: RecordsConfig): RecordsClient;
1633
1666
  /**
1634
1667
  * Turn a refusal into the conflict a screen can SHOW: which version you wrote
@@ -1989,4 +2022,4 @@ declare function parseCsv(text: string): string[][];
1989
2022
  declare function importCsv(text: string): ParsedImport;
1990
2023
  declare function importXlsx(bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1991
2024
 
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 };
2025
+ 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, type TableFact, 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, withTableFacts };
@@ -313,6 +313,23 @@ interface RecordsClient {
313
313
  tableArchived(args: {
314
314
  table_id: Uuid;
315
315
  }): Promise<RecordsResult<ArchivedRow | null>>;
316
+ /**
317
+ * WHO CAN SEE EACH TABLE, AND WHETHER THE CALLER MADE IT — `custom.table_facts`
318
+ * (lane HUB-FIX). `visibility` and `created_by` are record COLUMNS the Table document
319
+ * never carried, so a screen that sorts Tables into lanes asks this and folds the
320
+ * answer onto `tableList()`'s Tables with `withTableFacts`.
321
+ *
322
+ * 🚨 IT IS ITS OWN CALL, NOT PART OF `tableList()` (0.57.3). 0.57.2 folded it into
323
+ * every table list, so every screen that merely LISTS tables (the field editor's
324
+ * relation target, the import wizard, settings) paid a second round trip it never
325
+ * used — and every test double that answers a table list had to answer it too
326
+ * (records-ui 0.84.5's gate: 47 tests in 15 files red). Only the lane-sorting
327
+ * screens ask.
328
+ *
329
+ * The door-presence pattern: when the store's catalogue does not carry the door the
330
+ * answer is `null` — nothing asked, nothing invented.
331
+ */
332
+ tableFacts(): Promise<RecordsResult<TableFact[] | null>>;
316
333
  fields(args: {
317
334
  table_id: Uuid;
318
335
  recordType?: string;
@@ -1629,6 +1646,22 @@ interface RecordsClient {
1629
1646
  sheetLabel?: string;
1630
1647
  }): Promise<RecordsResult<Uint8Array>>;
1631
1648
  }
1649
+ /** One Table's two lane facts, as `custom.table_facts` answers them. */
1650
+ interface TableFact {
1651
+ table_id: Uuid;
1652
+ /** The record's own `visibility` column: personal · internal · link · public. */
1653
+ visibility: string;
1654
+ /** Whether the person signed in MADE this Table. Never who did. */
1655
+ mine: boolean;
1656
+ }
1657
+ /**
1658
+ * The facts folded onto a table list: `visibility` on every Table the facts name,
1659
+ * `created_by` ONLY as the caller's own id and only on the Tables the caller made.
1660
+ * Pure — returns new objects and leaves the list it was given alone.
1661
+ */
1662
+ declare function withTableFacts<T extends {
1663
+ id: Uuid;
1664
+ }>(tables: readonly T[], facts: readonly TableFact[] | null | undefined, me: Uuid | null | undefined): T[];
1632
1665
  declare function createRecordsClient(config: RecordsConfig): RecordsClient;
1633
1666
  /**
1634
1667
  * Turn a refusal into the conflict a screen can SHOW: which version you wrote
@@ -1989,4 +2022,4 @@ declare function parseCsv(text: string): string[][];
1989
2022
  declare function importCsv(text: string): ParsedImport;
1990
2023
  declare function importXlsx(bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1991
2024
 
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 };
2025
+ 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, type TableFact, 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, withTableFacts };
@@ -5631,6 +5631,19 @@ function sink(config) {
5631
5631
  else console.error(line);
5632
5632
  });
5633
5633
  }
5634
+ function withTableFacts(tables, facts, me) {
5635
+ if (!facts) return [...tables];
5636
+ const byId = new Map(facts.map((f) => [f.table_id, f]));
5637
+ return tables.map((table) => {
5638
+ const fact = byId.get(table.id);
5639
+ if (!fact) return table;
5640
+ return {
5641
+ ...table,
5642
+ visibility: fact.visibility,
5643
+ ...fact.mine && me ? { created_by: me } : {}
5644
+ };
5645
+ });
5646
+ }
5634
5647
  function createRecordsClient(config) {
5635
5648
  const schema = config.schema ?? DEFAULT_SCHEMA;
5636
5649
  const org = config.organizationId;
@@ -5805,6 +5818,10 @@ function createRecordsClient(config) {
5805
5818
  })
5806
5819
  );
5807
5820
  },
5821
+ async tableFacts() {
5822
+ if (!doorExists(DOORS.tableFacts)) return ok(null);
5823
+ return callDoor(DOORS.tableFacts, { p_organization_id: org }, "tableFacts");
5824
+ },
5808
5825
  async tableArchived({ table_id }) {
5809
5826
  const kernel = await callDoor(DOORS.tableKernelId, {}, "tableArchived.kernel");
5810
5827
  if (!kernel.ok) return err(kernel.error);
@@ -5988,23 +6005,6 @@ function createRecordsClient(config) {
5988
6005
  const { document } = unfold(row.document);
5989
6006
  return { ...document, id: row.id, organization_id: org };
5990
6007
  });
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
- }
6008
6008
  tables.sort((a, b) => (a.name ?? "").localeCompare(b.name ?? ""));
6009
6009
  return ok(tables);
6010
6010
  },
@@ -8335,6 +8335,7 @@ export {
8335
8335
  stableFilterKey,
8336
8336
  staleWriteDetail,
8337
8337
  supabaseDataSource,
8338
- toAoa
8338
+ toAoa,
8339
+ withTableFacts
8339
8340
  };
8340
8341
  //# sourceMappingURL=index.js.map