@ai-matrx/records 0.21.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, NewFieldDeclaration, FieldPatch, EntityTableFacts, NewEntityFieldDeclaration, EntityFieldRights, EntityRecordRead, EntityRecordsFound, FormSummary, ImportPlan, ImportPolicy, ImportOpened, ImportBatchResult, ImportFinished, ImportReport, ImportRun, InboundDeclared, InboundAddress, PortalSummary, PortalCard, PortalInvitation, PortalRevocation, PortalPreviewRow, DashboardSummary, DashboardBlock, AggregateFilter, DashboardRunResult, StuckRow, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, MySubscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, RecordHistoryEntry, RecordScopeContext, ConversationScope, ConversationScopeContext, FieldHistoryEntry, RestorePreview, RestoreResult, CommentThreadRead, CommentWritten, ReadValue, 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, FieldProposal, TableProposal, MyLevel, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.cjs';
2
- export { ABSENCE_REASONS, ACTOR_VOCABULARY, AbsenceReason, Actor, AggregateOperation, AggregateWindow, COMPUTE_ON, CONTEXT_POLICIES, ChecklistRequirement, ChecklistRequirementKind, ChecklistRoleSpec, ChecklistStepSpec, ChecklistTrigger, ChecklistTriggerKind, ChoiceOption, ComputeOn, ContextPolicy, CustomFieldTableType, DELIVERIES, DashboardBlockKind, DashboardBlockResult, Delivery, DocSignatureCheck, ENTITY_TOKENS, EntityFieldValue, EntityRecordMatch, EntityToken, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, FieldBehavior, FieldRule, FieldSensitivity, FieldSource, FieldTypeWord, ForbiddenEnvelopeWord, Freshness, HiddenFieldNotice, HistoryActor, HistoryActorKind, HistoryChange, Home, ImportColumnPlan, ImportOutcome, ImportProposal, 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, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, ParityFieldType, ParityFieldTypeDescriptor, PerValueAccessWord, PermissionLevel, PortalPrincipal, PortalTableExposure, ProvenancePointer, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, RecordComment, RecordScopeComment, RecordScopeField, RecordScopeHistoryEntry, RecordScopeRelation, RecordScopeWithheld, 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, WorkDueState, WorkInboxKind, WorkOrigin, WorkTemplateNode, WorkTemplateRelation, asPermissionLevel, atLeast, choiceSlug, choiceValuesOf, choicesOf, err, highestLevel, holdsARetiredChoice, isRecordsErr, isTheChosen, looksLikeAnId, measureKey, ok, optionKey, optionLabel, portalPath, publicFormPath, scopeChip } from '../index.cjs';
1
+ import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, NewFieldDeclaration, FieldPatch, EntityTableFacts, NewEntityFieldDeclaration, EntityFieldRights, EntityRecordRead, EntityRecordsFound, FormSummary, ImportPlan, ImportPolicy, ImportOpened, ImportBatchResult, ImportFinished, ImportReport, ImportRun, InboundDeclared, InboundAddress, PortalSummary, PortalCard, PortalInvitation, PortalRevocation, PortalPreviewRow, DashboardSummary, DashboardBlock, AggregateFilter, DashboardRunResult, StuckRow, EnrichmentSummary, EnrichDeclared, EnrichDueRow, EnrichCell, EnrichRun, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, MySubscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, RecordHistoryEntry, RecordScopeContext, ConversationScope, ConversationScopeContext, FieldHistoryEntry, RestorePreview, RestoreResult, CommentThreadRead, CommentWritten, ReadValue, 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, FieldProposal, TableProposal, MyLevel, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.cjs';
2
+ export { ABSENCE_REASONS, ACTOR_VOCABULARY, AbsenceReason, Actor, AggregateOperation, AggregateWindow, COMPUTE_ON, CONTEXT_POLICIES, ChecklistRequirement, ChecklistRequirementKind, ChecklistRoleSpec, ChecklistStepSpec, ChecklistTrigger, ChecklistTriggerKind, ChoiceOption, ComputeOn, ContextPolicy, CustomFieldTableType, DELIVERIES, DashboardBlockKind, DashboardBlockResult, Delivery, DocSignatureCheck, ENTITY_TOKENS, EnrichAlternate, EnrichSource, Enrichment, EntityFieldValue, EntityRecordMatch, EntityToken, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, FieldBehavior, FieldRule, FieldSensitivity, FieldSource, FieldTypeWord, ForbiddenEnvelopeWord, Freshness, HiddenFieldNotice, HistoryActor, HistoryActorKind, HistoryChange, Home, ImportColumnPlan, ImportOutcome, ImportProposal, 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, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, ParityFieldType, ParityFieldTypeDescriptor, PerValueAccessWord, PermissionLevel, PortalPrincipal, PortalTableExposure, ProvenancePointer, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, RecordComment, RecordScopeComment, RecordScopeField, RecordScopeHistoryEntry, RecordScopeRelation, RecordScopeWithheld, 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, WorkDueState, WorkInboxKind, WorkOrigin, WorkTemplateNode, WorkTemplateRelation, asPermissionLevel, atLeast, choiceSlug, choiceValuesOf, choicesOf, err, highestLevel, holdsARetiredChoice, isRecordsErr, isTheChosen, looksLikeAnId, measureKey, ok, optionKey, optionLabel, portalPath, publicFormPath, scopeChip } from '../index.cjs';
3
3
 
4
4
  /**
5
5
  * DOOR-8. As-of on EITHER clock, and they are different questions:
@@ -450,6 +450,53 @@ interface RecordsClient {
450
450
  filter?: Record<string, AggregateFilter>;
451
451
  limit?: number;
452
452
  }): Promise<RecordsResult<StuckRow[]>>;
453
+ /** Every agent-owned column, with how many cells are filled, stale or pinned, and what it has cost. */
454
+ enrichments(args?: {
455
+ table_id?: Uuid | null;
456
+ }): Promise<RecordsResult<EnrichmentSummary[]>>;
457
+ /**
458
+ * Define, change or TURN ON an Enrichment on one Field. Admin on the Table.
459
+ * `{enabled: true}` on its own turns an existing one on without resetting it —
460
+ * and turning it on is what authorises every value it writes afterwards.
461
+ */
462
+ enrichDeclare(args: {
463
+ field_id: Uuid;
464
+ spec: Record<string, unknown>;
465
+ }): Promise<RecordsResult<EnrichDeclared>>;
466
+ /**
467
+ * The rows that need this column filled in, each with what the instruction may
468
+ * read. A cell somebody pinned is never returned. This is what a PREVIEW shows
469
+ * before anybody enables anything.
470
+ */
471
+ enrichDue(args: {
472
+ field_id: Uuid;
473
+ limit?: number;
474
+ include_fresh?: boolean;
475
+ }): Promise<RecordsResult<EnrichDueRow[]>>;
476
+ /**
477
+ * THE BADGE DATA FOR A WHOLE PAGE, in one call. Who wrote each value, when, out
478
+ * of what source, its candidates, whether a person pinned it and whether it is
479
+ * past its freshness date. Asked per cell this would be one round trip per badge.
480
+ */
481
+ enrichCells(args: {
482
+ table_id: Uuid;
483
+ field_keys?: string[] | null;
484
+ record_ids?: Uuid[] | null;
485
+ }): Promise<RecordsResult<EnrichCell[]>>;
486
+ /** Hold one cell against the model that fills its column, or hand it back. */
487
+ enrichPin(args: {
488
+ record_id: Uuid;
489
+ field_key: string;
490
+ pinned?: boolean;
491
+ }): Promise<RecordsResult<{
492
+ pinned: boolean;
493
+ says: string;
494
+ }>>;
495
+ /** What this column has cost, run by run. */
496
+ enrichRuns(args?: {
497
+ field_id?: Uuid | null;
498
+ limit?: number;
499
+ }): Promise<RecordsResult<EnrichRun[]>>;
453
500
  /** Take a dashboard away. The records it counted are untouched — a canvas owns nothing. */
454
501
  dashboardDelete(args: {
455
502
  dashboard_id: Uuid;
@@ -1140,6 +1187,13 @@ declare const DOORS: {
1140
1187
  readonly dashboardRun: "dashboard_run";
1141
1188
  readonly dashboardStuck: "dashboard_stuck";
1142
1189
  readonly dashboardDelete: "dashboard_delete";
1190
+ readonly enrichments: "enrichments";
1191
+ readonly enrichDeclare: "enrich_declare";
1192
+ readonly enrichDue: "enrich_due";
1193
+ readonly enrichCells: "enrich_cells";
1194
+ readonly enrichLand: "enrich_land";
1195
+ readonly enrichPin: "enrich_pin";
1196
+ readonly enrichRuns: "enrich_runs";
1143
1197
  readonly recordHistory: "record_history";
1144
1198
  readonly fieldHistory: "field_history";
1145
1199
  readonly restorePreview: "record_restore_preview";
@@ -1319,24 +1373,34 @@ declare function toAoa(fields: Field[], rows: ExportRow[]): string[][];
1319
1373
  * the same way, and for the same reason.
1320
1374
  */
1321
1375
  declare function exportXlsx(fields: Field[], rows: ExportRow[], sheetLabel?: string): Promise<Uint8Array>;
1322
- /** A parsed import: the header row mapped onto field keys, and the rows. */
1376
+ /**
1377
+ * A PARSED FILE, AND NOTHING ELSE: its headings, and every row keyed by them.
1378
+ *
1379
+ * 🚨 THERE IS NO `field`, NO `unmapped` AND NO WAY TO ASK FOR ONE, and that is
1380
+ * the point. Until 2026-09-20 this parse ALSO decided which Field each heading
1381
+ * meant — it took `fields`, matched each header by key or label, keyed the rows
1382
+ * by whatever it matched, and **dropped every column it did not**. That cannot
1383
+ * be the input to `custom.io_import_plan` / `custom.io_import_rows`, whose whole
1384
+ * job is to decide the mapping and to OFFER what they could not match as a new
1385
+ * column: the store can only offer a column whose values reached it.
1386
+ *
1387
+ * Measured by looking at the screen: every unmapped column's samples came back
1388
+ * empty and its proposal read "every row in this column is empty, so there is
1389
+ * nothing to go on" — for columns plainly full of values.
1390
+ *
1391
+ * The fix is the SHAPE, not a second field beside the first. These functions no
1392
+ * longer take `fields`, so a parse cannot decide a mapping even by accident, and
1393
+ * there is no safe path left beside the unsafe one.
1394
+ */
1323
1395
  interface ParsedImport {
1324
- /** Header text -> the Field it matched, or null when nothing matched. */
1325
- columns: Array<{
1326
- header: string;
1327
- field: Field | null;
1328
- }>;
1396
+ /** The file's own headings, in the file's own order and spelling. */
1397
+ headers: string[];
1398
+ /** Every row, keyed by heading. Every column is here; nothing is dropped. */
1329
1399
  rows: Array<Record<string, string>>;
1330
- /**
1331
- * DOOR-14 / AGT-N-7. Headers that matched no Field. They are NEVER dropped
1332
- * quietly: an unmapped key becomes a field proposal a person approves, and the
1333
- * import surface shows this list.
1334
- */
1335
- unmapped: string[];
1336
1400
  }
1337
1401
  /** RFC-4180 enough for what the canonical table writes, quotes and embedded newlines included. */
1338
1402
  declare function parseCsv(text: string): string[][];
1339
- declare function importCsv(fields: Field[], text: string): ParsedImport;
1340
- declare function importXlsx(fields: Field[], bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1403
+ declare function importCsv(text: string): ParsedImport;
1404
+ declare function importXlsx(bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1341
1405
 
1342
- export { AggregateBucket, AggregateFilter, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, 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, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, ImportBatchResult, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, RestorePreview, RestoreResult, StaleWriteDetail, StoredRecord, StuckRow, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, 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 };
1406
+ export { AggregateBucket, AggregateFilter, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, 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, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EnrichCell, EnrichDeclared, EnrichDueRow, EnrichRun, EnrichmentSummary, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, ImportBatchResult, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, RestorePreview, RestoreResult, StaleWriteDetail, StoredRecord, StuckRow, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, 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 };
@@ -1,5 +1,5 @@
1
- import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, NewFieldDeclaration, FieldPatch, EntityTableFacts, NewEntityFieldDeclaration, EntityFieldRights, EntityRecordRead, EntityRecordsFound, FormSummary, ImportPlan, ImportPolicy, ImportOpened, ImportBatchResult, ImportFinished, ImportReport, ImportRun, InboundDeclared, InboundAddress, PortalSummary, PortalCard, PortalInvitation, PortalRevocation, PortalPreviewRow, DashboardSummary, DashboardBlock, AggregateFilter, DashboardRunResult, StuckRow, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, MySubscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, RecordHistoryEntry, RecordScopeContext, ConversationScope, ConversationScopeContext, FieldHistoryEntry, RestorePreview, RestoreResult, CommentThreadRead, CommentWritten, ReadValue, 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, FieldProposal, TableProposal, MyLevel, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.js';
2
- export { ABSENCE_REASONS, ACTOR_VOCABULARY, AbsenceReason, Actor, AggregateOperation, AggregateWindow, COMPUTE_ON, CONTEXT_POLICIES, ChecklistRequirement, ChecklistRequirementKind, ChecklistRoleSpec, ChecklistStepSpec, ChecklistTrigger, ChecklistTriggerKind, ChoiceOption, ComputeOn, ContextPolicy, CustomFieldTableType, DELIVERIES, DashboardBlockKind, DashboardBlockResult, Delivery, DocSignatureCheck, ENTITY_TOKENS, EntityFieldValue, EntityRecordMatch, EntityToken, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, FieldBehavior, FieldRule, FieldSensitivity, FieldSource, FieldTypeWord, ForbiddenEnvelopeWord, Freshness, HiddenFieldNotice, HistoryActor, HistoryActorKind, HistoryChange, Home, ImportColumnPlan, ImportOutcome, ImportProposal, 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, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, ParityFieldType, ParityFieldTypeDescriptor, PerValueAccessWord, PermissionLevel, PortalPrincipal, PortalTableExposure, ProvenancePointer, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, RecordComment, RecordScopeComment, RecordScopeField, RecordScopeHistoryEntry, RecordScopeRelation, RecordScopeWithheld, 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, WorkDueState, WorkInboxKind, WorkOrigin, WorkTemplateNode, WorkTemplateRelation, asPermissionLevel, atLeast, choiceSlug, choiceValuesOf, choicesOf, err, highestLevel, holdsARetiredChoice, isRecordsErr, isTheChosen, looksLikeAnId, measureKey, ok, optionKey, optionLabel, portalPath, publicFormPath, scopeChip } from '../index.js';
1
+ import { Timestamp, Uuid, RelationCoordinate, RecordsConfig, RecordDocument, RecordsResult, RecordRead, ReadRow, Table, Field, StoredRecord, TableCapacity, NewFieldDeclaration, FieldPatch, EntityTableFacts, NewEntityFieldDeclaration, EntityFieldRights, EntityRecordRead, EntityRecordsFound, FormSummary, ImportPlan, ImportPolicy, ImportOpened, ImportBatchResult, ImportFinished, ImportReport, ImportRun, InboundDeclared, InboundAddress, PortalSummary, PortalCard, PortalInvitation, PortalRevocation, PortalPreviewRow, DashboardSummary, DashboardBlock, AggregateFilter, DashboardRunResult, StuckRow, EnrichmentSummary, EnrichDeclared, EnrichDueRow, EnrichCell, EnrichRun, AggregateMeasure, AggregateBucket, AggregateRow, Subscription, MySubscription, DocToken, DocUnresolvedToken, DocTemplateRow, DocRenderRow, DocSignatureRow, RecordRevision, RecordHistoryEntry, RecordScopeContext, ConversationScope, ConversationScopeContext, FieldHistoryEntry, RestorePreview, RestoreResult, CommentThreadRead, CommentWritten, ReadValue, 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, FieldProposal, TableProposal, MyLevel, RecordsError, WriteConflict, PgError, RecordsDataSource, StaleWriteDetail, PredictedRefusal } from '../index.js';
2
+ export { ABSENCE_REASONS, ACTOR_VOCABULARY, AbsenceReason, Actor, AggregateOperation, AggregateWindow, COMPUTE_ON, CONTEXT_POLICIES, ChecklistRequirement, ChecklistRequirementKind, ChecklistRoleSpec, ChecklistStepSpec, ChecklistTrigger, ChecklistTriggerKind, ChoiceOption, ComputeOn, ContextPolicy, CustomFieldTableType, DELIVERIES, DashboardBlockKind, DashboardBlockResult, Delivery, DocSignatureCheck, ENTITY_TOKENS, EnrichAlternate, EnrichSource, Enrichment, EntityFieldValue, EntityRecordMatch, EntityToken, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, FieldBehavior, FieldRule, FieldSensitivity, FieldSource, FieldTypeWord, ForbiddenEnvelopeWord, Freshness, HiddenFieldNotice, HistoryActor, HistoryActorKind, HistoryChange, Home, ImportColumnPlan, ImportOutcome, ImportProposal, 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, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, ParityFieldType, ParityFieldTypeDescriptor, PerValueAccessWord, PermissionLevel, PortalPrincipal, PortalTableExposure, ProvenancePointer, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, RecordComment, RecordScopeComment, RecordScopeField, RecordScopeHistoryEntry, RecordScopeRelation, RecordScopeWithheld, 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, WorkDueState, WorkInboxKind, WorkOrigin, WorkTemplateNode, WorkTemplateRelation, asPermissionLevel, atLeast, choiceSlug, choiceValuesOf, choicesOf, err, highestLevel, holdsARetiredChoice, isRecordsErr, isTheChosen, looksLikeAnId, measureKey, ok, optionKey, optionLabel, portalPath, publicFormPath, scopeChip } from '../index.js';
3
3
 
4
4
  /**
5
5
  * DOOR-8. As-of on EITHER clock, and they are different questions:
@@ -450,6 +450,53 @@ interface RecordsClient {
450
450
  filter?: Record<string, AggregateFilter>;
451
451
  limit?: number;
452
452
  }): Promise<RecordsResult<StuckRow[]>>;
453
+ /** Every agent-owned column, with how many cells are filled, stale or pinned, and what it has cost. */
454
+ enrichments(args?: {
455
+ table_id?: Uuid | null;
456
+ }): Promise<RecordsResult<EnrichmentSummary[]>>;
457
+ /**
458
+ * Define, change or TURN ON an Enrichment on one Field. Admin on the Table.
459
+ * `{enabled: true}` on its own turns an existing one on without resetting it —
460
+ * and turning it on is what authorises every value it writes afterwards.
461
+ */
462
+ enrichDeclare(args: {
463
+ field_id: Uuid;
464
+ spec: Record<string, unknown>;
465
+ }): Promise<RecordsResult<EnrichDeclared>>;
466
+ /**
467
+ * The rows that need this column filled in, each with what the instruction may
468
+ * read. A cell somebody pinned is never returned. This is what a PREVIEW shows
469
+ * before anybody enables anything.
470
+ */
471
+ enrichDue(args: {
472
+ field_id: Uuid;
473
+ limit?: number;
474
+ include_fresh?: boolean;
475
+ }): Promise<RecordsResult<EnrichDueRow[]>>;
476
+ /**
477
+ * THE BADGE DATA FOR A WHOLE PAGE, in one call. Who wrote each value, when, out
478
+ * of what source, its candidates, whether a person pinned it and whether it is
479
+ * past its freshness date. Asked per cell this would be one round trip per badge.
480
+ */
481
+ enrichCells(args: {
482
+ table_id: Uuid;
483
+ field_keys?: string[] | null;
484
+ record_ids?: Uuid[] | null;
485
+ }): Promise<RecordsResult<EnrichCell[]>>;
486
+ /** Hold one cell against the model that fills its column, or hand it back. */
487
+ enrichPin(args: {
488
+ record_id: Uuid;
489
+ field_key: string;
490
+ pinned?: boolean;
491
+ }): Promise<RecordsResult<{
492
+ pinned: boolean;
493
+ says: string;
494
+ }>>;
495
+ /** What this column has cost, run by run. */
496
+ enrichRuns(args?: {
497
+ field_id?: Uuid | null;
498
+ limit?: number;
499
+ }): Promise<RecordsResult<EnrichRun[]>>;
453
500
  /** Take a dashboard away. The records it counted are untouched — a canvas owns nothing. */
454
501
  dashboardDelete(args: {
455
502
  dashboard_id: Uuid;
@@ -1140,6 +1187,13 @@ declare const DOORS: {
1140
1187
  readonly dashboardRun: "dashboard_run";
1141
1188
  readonly dashboardStuck: "dashboard_stuck";
1142
1189
  readonly dashboardDelete: "dashboard_delete";
1190
+ readonly enrichments: "enrichments";
1191
+ readonly enrichDeclare: "enrich_declare";
1192
+ readonly enrichDue: "enrich_due";
1193
+ readonly enrichCells: "enrich_cells";
1194
+ readonly enrichLand: "enrich_land";
1195
+ readonly enrichPin: "enrich_pin";
1196
+ readonly enrichRuns: "enrich_runs";
1143
1197
  readonly recordHistory: "record_history";
1144
1198
  readonly fieldHistory: "field_history";
1145
1199
  readonly restorePreview: "record_restore_preview";
@@ -1319,24 +1373,34 @@ declare function toAoa(fields: Field[], rows: ExportRow[]): string[][];
1319
1373
  * the same way, and for the same reason.
1320
1374
  */
1321
1375
  declare function exportXlsx(fields: Field[], rows: ExportRow[], sheetLabel?: string): Promise<Uint8Array>;
1322
- /** A parsed import: the header row mapped onto field keys, and the rows. */
1376
+ /**
1377
+ * A PARSED FILE, AND NOTHING ELSE: its headings, and every row keyed by them.
1378
+ *
1379
+ * 🚨 THERE IS NO `field`, NO `unmapped` AND NO WAY TO ASK FOR ONE, and that is
1380
+ * the point. Until 2026-09-20 this parse ALSO decided which Field each heading
1381
+ * meant — it took `fields`, matched each header by key or label, keyed the rows
1382
+ * by whatever it matched, and **dropped every column it did not**. That cannot
1383
+ * be the input to `custom.io_import_plan` / `custom.io_import_rows`, whose whole
1384
+ * job is to decide the mapping and to OFFER what they could not match as a new
1385
+ * column: the store can only offer a column whose values reached it.
1386
+ *
1387
+ * Measured by looking at the screen: every unmapped column's samples came back
1388
+ * empty and its proposal read "every row in this column is empty, so there is
1389
+ * nothing to go on" — for columns plainly full of values.
1390
+ *
1391
+ * The fix is the SHAPE, not a second field beside the first. These functions no
1392
+ * longer take `fields`, so a parse cannot decide a mapping even by accident, and
1393
+ * there is no safe path left beside the unsafe one.
1394
+ */
1323
1395
  interface ParsedImport {
1324
- /** Header text -> the Field it matched, or null when nothing matched. */
1325
- columns: Array<{
1326
- header: string;
1327
- field: Field | null;
1328
- }>;
1396
+ /** The file's own headings, in the file's own order and spelling. */
1397
+ headers: string[];
1398
+ /** Every row, keyed by heading. Every column is here; nothing is dropped. */
1329
1399
  rows: Array<Record<string, string>>;
1330
- /**
1331
- * DOOR-14 / AGT-N-7. Headers that matched no Field. They are NEVER dropped
1332
- * quietly: an unmapped key becomes a field proposal a person approves, and the
1333
- * import surface shows this list.
1334
- */
1335
- unmapped: string[];
1336
1400
  }
1337
1401
  /** RFC-4180 enough for what the canonical table writes, quotes and embedded newlines included. */
1338
1402
  declare function parseCsv(text: string): string[][];
1339
- declare function importCsv(fields: Field[], text: string): ParsedImport;
1340
- declare function importXlsx(fields: Field[], bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1403
+ declare function importCsv(text: string): ParsedImport;
1404
+ declare function importXlsx(bytes: ArrayBuffer | Uint8Array): Promise<ParsedImport>;
1341
1405
 
1342
- export { AggregateBucket, AggregateFilter, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, 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, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, ImportBatchResult, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, RestorePreview, RestoreResult, StaleWriteDetail, StoredRecord, StuckRow, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, 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 };
1406
+ export { AggregateBucket, AggregateFilter, AggregateMeasure, AggregateRow, AnonTokenBinding, type AsOf, 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, DocRenderRow, DocSignatureRow, DocTemplateRow, DocToken, DocUnresolvedToken, type DoorKey, EnrichCell, EnrichDeclared, EnrichDueRow, EnrichRun, EnrichmentSummary, EntityFieldRights, EntityRecordRead, EntityRecordsFound, EntityTableFacts, type ExportRow, ExternalPrincipalCard, Field, FieldHistoryEntry, FieldPatch, FieldProposal, FormSummary, ImportBatchResult, ImportFinished, ImportOpened, ImportPlan, ImportPolicy, ImportReport, ImportRun, InboundAddress, InboundDeclared, MAPPED_SQLSTATES, type MirrorLimits, MyLevel, MySubscription, NewEntityFieldDeclaration, NewFieldDeclaration, type ParsedImport, PgError, PortalCard, PortalInvitation, PortalPreviewRow, PortalRevocation, PortalSummary, PredictedRefusal, type PromotedPredicate, PublishBinding, type QueryPlan, ReadRow, ReadValue, RecordDocument, RecordHistoryEntry, type RecordQuery, RecordRead, RecordRevision, RecordScopeContext, type RecordsClient, RecordsConfig, RecordsDataSource, RecordsError, RecordsResult, RelationCoordinate, ResolvedPublishBinding, RestorePreview, RestoreResult, StaleWriteDetail, StoredRecord, StuckRow, Subscription, type SupabaseLike, Table, TableCapacity, TableProposal, 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 };
@@ -1973,6 +1973,22 @@ var DOORS = {
1973
1973
  dashboardRun: "dashboard_run",
1974
1974
  dashboardStuck: "dashboard_stuck",
1975
1975
  dashboardDelete: "dashboard_delete",
1976
+ // PRODUCTS row 10 — "fill in each company's industry and headcount, and keep
1977
+ // it fresh". An Enrichment is not an object of its own: it is a Field saying
1978
+ // `source = agent`, with its instruction, inputs, model, confidence floor and
1979
+ // freshness in `source_config` (AGT-6). `enrichCells` is the one a GRID calls —
1980
+ // the badge data for a whole page in one round trip, because a badge asked per
1981
+ // cell is fifty round trips to draw fifty badges. `enrichPin` is the half of
1982
+ // this product that decides whether anybody ever trusts it: the moment a
1983
+ // person types over an agent-owned cell the store pins it, and the next run
1984
+ // leaves it exactly as they left it.
1985
+ enrichments: "enrichments",
1986
+ enrichDeclare: "enrich_declare",
1987
+ enrichDue: "enrich_due",
1988
+ enrichCells: "enrich_cells",
1989
+ enrichLand: "enrich_land",
1990
+ enrichPin: "enrich_pin",
1991
+ enrichRuns: "enrich_runs",
1976
1992
  // PRODUCTS row 4 — "Who changed this price, and can I put it back?" The
1977
1993
  // history has been in the store since W3-HIST; until 2026-09-20 the only way
1978
1994
  // to ask for it was `io_revisions`, which answers a raw uuid for the author
@@ -2890,6 +2906,67 @@ function createRecordsClient(config) {
2890
2906
  "ruleEval"
2891
2907
  );
2892
2908
  },
2909
+ async enrichments(args) {
2910
+ return callDoor(
2911
+ DOORS.enrichments,
2912
+ { p_organization_id: org, p_table_id: args?.table_id ?? null },
2913
+ "enrichments"
2914
+ );
2915
+ },
2916
+ async enrichDeclare(args) {
2917
+ return callDoor(
2918
+ DOORS.enrichDeclare,
2919
+ { p_organization_id: org, p_field_id: args.field_id, p_spec: args.spec },
2920
+ "enrichDeclare"
2921
+ );
2922
+ },
2923
+ async enrichDue(args) {
2924
+ return callDoor(
2925
+ DOORS.enrichDue,
2926
+ {
2927
+ p_organization_id: org,
2928
+ p_field_id: args.field_id,
2929
+ p_limit: args.limit ?? 50,
2930
+ p_include_fresh: args.include_fresh ?? false
2931
+ },
2932
+ "enrichDue"
2933
+ );
2934
+ },
2935
+ async enrichCells(args) {
2936
+ return callDoor(
2937
+ DOORS.enrichCells,
2938
+ {
2939
+ p_organization_id: org,
2940
+ p_table_id: args.table_id,
2941
+ p_field_keys: args.field_keys ?? null,
2942
+ p_record_ids: args.record_ids ?? null
2943
+ },
2944
+ "enrichCells"
2945
+ );
2946
+ },
2947
+ async enrichPin(args) {
2948
+ return callDoor(
2949
+ DOORS.enrichPin,
2950
+ {
2951
+ p_organization_id: org,
2952
+ p_record_id: args.record_id,
2953
+ p_field_key: args.field_key,
2954
+ p_pinned: args.pinned ?? true
2955
+ },
2956
+ "enrichPin"
2957
+ );
2958
+ },
2959
+ async enrichRuns(args) {
2960
+ return callDoor(
2961
+ DOORS.enrichRuns,
2962
+ {
2963
+ p_organization_id: org,
2964
+ p_field_id: args?.field_id ?? null,
2965
+ p_limit: args?.limit ?? 50
2966
+ },
2967
+ "enrichRuns"
2968
+ );
2969
+ },
2893
2970
  async dashboards(args) {
2894
2971
  return callDoor(
2895
2972
  DOORS.dashboards,
@@ -4188,10 +4265,6 @@ async function exportXlsx(fields, rows, sheetLabel = "Records") {
4188
4265
  XLSX.utils.book_append_sheet(workbook, worksheet, name);
4189
4266
  return XLSX.write(workbook, { type: "array", bookType: "xlsx", compression: true });
4190
4267
  }
4191
- function matchField(header, fields) {
4192
- const wanted = header.trim().toLowerCase();
4193
- return fields.find((f) => f.key.toLowerCase() === wanted) ?? fields.find((f) => (f.label ?? "").toLowerCase() === wanted) ?? null;
4194
- }
4195
4268
  function parseCsv(text) {
4196
4269
  const rows = [];
4197
4270
  let row = [];
@@ -4226,32 +4299,31 @@ function parseCsv(text) {
4226
4299
  }
4227
4300
  return rows;
4228
4301
  }
4229
- function importCsv(fields, text) {
4230
- return fromMatrix(fields, parseCsv(text));
4302
+ function importCsv(text) {
4303
+ return fromMatrix(parseCsv(text));
4231
4304
  }
4232
- async function importXlsx(fields, bytes) {
4305
+ async function importXlsx(bytes) {
4233
4306
  const XLSX = await import("xlsx");
4234
4307
  const workbook = XLSX.read(bytes, { type: "array" });
4235
4308
  const first = workbook.SheetNames[0];
4236
- if (!first) return { columns: [], rows: [], unmapped: [] };
4309
+ if (!first) return { headers: [], rows: [] };
4237
4310
  const sheet = workbook.Sheets[first];
4238
- if (!sheet) return { columns: [], rows: [], unmapped: [] };
4311
+ if (!sheet) return { headers: [], rows: [] };
4239
4312
  const matrix = XLSX.utils.sheet_to_json(sheet, { header: 1, raw: false, defval: "" });
4240
- return fromMatrix(fields, matrix);
4313
+ return fromMatrix(matrix);
4241
4314
  }
4242
- function fromMatrix(fields, matrix) {
4315
+ function fromMatrix(matrix) {
4243
4316
  const [header, ...body] = matrix;
4244
- if (!header) return { columns: [], rows: [], unmapped: [] };
4245
- const columns = header.map((text) => ({ header: text, field: matchField(text, fields) }));
4246
- const unmapped = columns.filter((c) => c.field === null).map((c) => c.header).filter((h) => h.trim().length > 0);
4317
+ if (!header) return { headers: [], rows: [] };
4318
+ const headers = header.map((text) => String(text ?? ""));
4247
4319
  const rows = body.filter((line) => line.some((cell) => String(cell ?? "").trim().length > 0)).map((line) => {
4248
4320
  const record = {};
4249
- columns.forEach((column, index) => {
4250
- if (column.field) record[column.field.key] = String(line[index] ?? "");
4321
+ headers.forEach((heading, index) => {
4322
+ if (heading.trim().length > 0) record[heading] = String(line[index] ?? "");
4251
4323
  });
4252
4324
  return record;
4253
4325
  });
4254
- return { columns, rows, unmapped };
4326
+ return { headers, rows };
4255
4327
  }
4256
4328
  export {
4257
4329
  ABSENCE_REASONS,