@ai-matrx/records 0.44.1 → 0.45.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.
- package/CHANGELOG.md +36 -0
- package/dist/core/index.cjs +208 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +208 -0
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +208 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -1
- package/dist/index.d.ts +124 -1
- package/dist/index.js +208 -0
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +208 -0
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +124 -1
- package/dist/react/index.d.ts +124 -1
- package/dist/react/index.js +208 -0
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -4114,6 +4114,129 @@ declare function holdsARetiredChoice(document: RecordDocument | undefined, field
|
|
|
4114
4114
|
/** True when a token looks like a uuid — which a choice value is no longer allowed to be. */
|
|
4115
4115
|
declare function looksLikeAnId(value: unknown): boolean;
|
|
4116
4116
|
|
|
4117
|
+
/**
|
|
4118
|
+
* EVERYTHING THIS FILE NEEDS TO KNOW ABOUT A FIELD, AND NOTHING ELSE.
|
|
4119
|
+
*
|
|
4120
|
+
* A full `Field` satisfies it, and so does every narrower shape the store
|
|
4121
|
+
* hands to a screen — `CaptureField` on a phone with no network, the Field
|
|
4122
|
+
* documents `custom.form_public` and `custom.booking_public` publish to a
|
|
4123
|
+
* stranger. Asking for the whole `Field` would have meant the capture sheet
|
|
4124
|
+
* keeping its own `Number(raw)`, which is exactly the duplication this file
|
|
4125
|
+
* exists to end.
|
|
4126
|
+
*/
|
|
4127
|
+
interface CoercibleField {
|
|
4128
|
+
/** Named so the doc above is checkable: a full {@link Field} satisfies this. */
|
|
4129
|
+
key: string;
|
|
4130
|
+
label?: string | null;
|
|
4131
|
+
name?: string | null;
|
|
4132
|
+
/** FLD-1. One of five behaviours; an unknown word is treated as text. */
|
|
4133
|
+
type?: string | null;
|
|
4134
|
+
multi?: boolean | null;
|
|
4135
|
+
unit?: string | null;
|
|
4136
|
+
format?: string | null;
|
|
4137
|
+
config?: Record<string, unknown> | null | undefined;
|
|
4138
|
+
relation_target?: string | null;
|
|
4139
|
+
}
|
|
4140
|
+
/**
|
|
4141
|
+
* The kind of value one Field holds, resolved from its DECLARATION only — the
|
|
4142
|
+
* behaviour, the modifiers, the format, the relation target and the config,
|
|
4143
|
+
* because those are what the store stores. A screen that guessed from a value
|
|
4144
|
+
* would answer differently for an empty record.
|
|
4145
|
+
*
|
|
4146
|
+
* `plain_text`, `long_text`, `number` and `boolean` are behaviours that carry
|
|
4147
|
+
* no parity type of their own; every other word here is a parity type.
|
|
4148
|
+
*/
|
|
4149
|
+
declare const FIELD_KINDS: readonly ["attachment", "checkbox", "currency", "datetime", "email", "formula", "json", "long_text", "lookup", "member", "multi_select", "number", "percent", "phone", "relation", "rollup", "select", "text", "url"];
|
|
4150
|
+
/**
|
|
4151
|
+
* 🚨 THE UNION IS DERIVED FROM THE LIST ABOVE, and the list is what the
|
|
4152
|
+
* coverage test walks. Add a kind here and the test drives it; give it no arm
|
|
4153
|
+
* in `coerceTypedAnswer` and the test says so, instead of the new kind falling
|
|
4154
|
+
* quietly through `default:` and a value of the wrong shape reaching the store
|
|
4155
|
+
* — which is the whole defect this file closes.
|
|
4156
|
+
*/
|
|
4157
|
+
type FieldKind = (typeof FIELD_KINDS)[number];
|
|
4158
|
+
/** The kernel Table ids REC-31 pins the two special relations to. */
|
|
4159
|
+
interface KernelTargets {
|
|
4160
|
+
/** The kernel `File` Table — a relation pointing here is an attachment. */
|
|
4161
|
+
file?: string | undefined;
|
|
4162
|
+
/** The kernel `Person` Table — a relation pointing here names a person. */
|
|
4163
|
+
person?: string | undefined;
|
|
4164
|
+
}
|
|
4165
|
+
/**
|
|
4166
|
+
* Which kind of value this Field holds.
|
|
4167
|
+
*
|
|
4168
|
+
* This is the ONE classifier. `@ai-matrx/records-ui`'s `editorKindFor` — which
|
|
4169
|
+
* decides which editor to DRAW — delegates to it, so the editor a person types
|
|
4170
|
+
* into and the coercion applied to what they typed can never disagree about
|
|
4171
|
+
* the same column. They did disagree before this moved here; that is the whole
|
|
4172
|
+
* class of grid defect September was spent closing.
|
|
4173
|
+
*/
|
|
4174
|
+
declare function fieldKindFor(field: CoercibleField, kernel?: KernelTargets): FieldKind;
|
|
4175
|
+
/** One Field's options, indexed the way a typed word has to be looked up. */
|
|
4176
|
+
interface ChoiceOptions {
|
|
4177
|
+
/**
|
|
4178
|
+
* Lower-cased label, option key and option id, each pointing at the OPTION
|
|
4179
|
+
* RECORD'S ID — which is what a list Field stores (FLD-5/FLD-6).
|
|
4180
|
+
*/
|
|
4181
|
+
byWord: Map<string, string>;
|
|
4182
|
+
/** The labels, in order, so a refusal can say what is on offer. */
|
|
4183
|
+
labels: string[];
|
|
4184
|
+
}
|
|
4185
|
+
/** What one answer became, or the sentence saying why it did not. */
|
|
4186
|
+
type Coerced = {
|
|
4187
|
+
value: unknown;
|
|
4188
|
+
} | {
|
|
4189
|
+
refusal: string;
|
|
4190
|
+
unmatched?: string[];
|
|
4191
|
+
};
|
|
4192
|
+
interface CoerceOptions {
|
|
4193
|
+
/** This Field's choices, when the caller has loaded them. */
|
|
4194
|
+
options?: ChoiceOptions | undefined;
|
|
4195
|
+
/** The kernel File/Person Table ids, for classifying relations. */
|
|
4196
|
+
kernel?: KernelTargets | undefined;
|
|
4197
|
+
/**
|
|
4198
|
+
* The Field's name as this caller writes it. Defaults to the Field's own
|
|
4199
|
+
* label. A screen passes the same words it printed above the box.
|
|
4200
|
+
*/
|
|
4201
|
+
label?: string | undefined;
|
|
4202
|
+
}
|
|
4203
|
+
/** The Field's name in plain words — never its key on a screen. */
|
|
4204
|
+
declare function coercionLabel(field: CoercibleField): string;
|
|
4205
|
+
/**
|
|
4206
|
+
* Turn ONE typed-in string into the value this Field holds — or say, in a
|
|
4207
|
+
* sentence a person can act on, why it is not one.
|
|
4208
|
+
*
|
|
4209
|
+
* An empty answer is `null` for every kind: a blank means "no answer here",
|
|
4210
|
+
* and clearing a value is a thing a person means to do. Whether the Field may
|
|
4211
|
+
* be blank is the store's question, asked with the Field's `required` and its
|
|
4212
|
+
* Rules, not this one's.
|
|
4213
|
+
*/
|
|
4214
|
+
declare function coerceTypedAnswer(field: CoercibleField, raw: string, opts?: CoerceOptions): Coerced;
|
|
4215
|
+
/** What a whole set of typed-in answers became. */
|
|
4216
|
+
interface CoercedAnswers {
|
|
4217
|
+
/** Ready to send to the store. Only the keys that coerced cleanly. */
|
|
4218
|
+
values: Record<string, unknown>;
|
|
4219
|
+
/** Field key → the sentence saying why that answer was not written. */
|
|
4220
|
+
refusals: Record<string, string>;
|
|
4221
|
+
/** The field keys the caller sent that this table has no Field for. */
|
|
4222
|
+
unknownKeys: string[];
|
|
4223
|
+
}
|
|
4224
|
+
/**
|
|
4225
|
+
* Every typed-in answer on one screen, coerced together — the shape the two
|
|
4226
|
+
* public doors and the import wizard actually need.
|
|
4227
|
+
*
|
|
4228
|
+
* Keys the table has no Field for are reported rather than dropped: the store
|
|
4229
|
+
* refuses an unknown key by name and a caller that quietly deleted it would
|
|
4230
|
+
* hide a real mismatch between a page and its table.
|
|
4231
|
+
*/
|
|
4232
|
+
declare function coerceTypedAnswers(fields: readonly CoercibleField[], answers: Readonly<Record<string, unknown>>, opts?: {
|
|
4233
|
+
kernel?: KernelTargets | undefined;
|
|
4234
|
+
/** Choices per Field key, for the list columns. */
|
|
4235
|
+
options?: ReadonlyMap<string, ChoiceOptions> | undefined;
|
|
4236
|
+
/** Field key → the words that screen printed above the box. */
|
|
4237
|
+
labels?: Readonly<Record<string, string>> | undefined;
|
|
4238
|
+
}): CoercedAnswers;
|
|
4239
|
+
|
|
4117
4240
|
/** The seven table types. Only these two carry custom fields (REC-34, DD-011). */
|
|
4118
4241
|
type CustomFieldTableType = "entity" | "detail";
|
|
4119
4242
|
/** What `custom.entity_table` answers about a registry token. */
|
|
@@ -8361,4 +8484,4 @@ declare function useFieldMutation(): UseFieldMutation;
|
|
|
8361
8484
|
*/
|
|
8362
8485
|
declare function useMergeField(key: string | null, state?: Record<string, unknown>): MergeFieldResolution | null;
|
|
8363
8486
|
|
|
8364
|
-
export { ABSENCE_REASONS, ACTOR_VOCABULARY, type AbsenceReason, type Actor, type AggregateBucket, type AggregateFilter, type AggregateMeasure, type AggregateOperation, type AggregateRow, type AggregateWindow, type AnonTokenBinding, type BookingAvailability, type BookingDeclared, type BookingSummary, type BookingWindow, COMPUTE_ON, CONTEXT_POLICIES, type CaptureField, type CaptureFileRef, type CaptureOutcome, type CaptureQuestion, type CaptureQueue, type CaptureQueueCounts, type CaptureQueueOptions, type CaptureQueuePorts, type CaptureQueueStore, type CaptureSheetFace, type CaptureSheetSummary, type CaptureSyncReport, type ChecklistDeclared, type ChecklistRequirement, type ChecklistRequirementKind, type ChecklistRoleSpec, type ChecklistRunStarted, type ChecklistRunStep, type ChecklistRunSummary, type ChecklistSpec, type ChecklistStepCompleted, type ChecklistStepSpec, type ChecklistTemplateShape, type ChecklistTemplateSummary, type ChecklistTrigger, type ChecklistTriggerKind, type ChoiceOption, type CommentThreadRead, type CommentWritten, type ComputeOn, type ContextPolicy, type ConversationScope, type ConversationScopeContext, type CustomFieldTableType, DELIVERIES, type DashboardBlock, type DashboardBlockKind, type DashboardBlockResult, type DashboardRunResult, type DashboardSummary, type Delivery, type DigestPreview, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, type EnrichAlternate, type EnrichCell, type EnrichDeclared, type EnrichDueRow, type EnrichRun, type EnrichSource, type Enrichment, type EnrichmentSummary, type EntityFieldRights, type EntityFieldValue, type EntityRecordMatch, type EntityRecordRead, type EntityRecordsFound, type EntityTableFacts, type EntityToken, type ExternalPrincipalCard, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, type Field, type FieldBehavior, type FieldHistoryEntry, type FieldPatch, type FieldProposal, type FieldRule, type FieldSensitivity, type FieldSource, type FieldTypeWord, type ForbiddenEnvelopeWord, type FormSummary, type Freshness, type HiddenFieldNotice, type HistoryActor, type HistoryActorKind, type HistoryChange, type Home, type ImportBatchResult, type ImportColumnPlan, type ImportFinished, type ImportOpened, type ImportOutcome, type ImportPlan, type ImportPolicy, type ImportProposal, type ImportReport, type ImportRun, type InboundAddress, type InboundDeclared, KERNEL_TABLES, type KernelTableName, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, type MergeField, type MergeFieldModifier, type MergeFieldProvenance, type MergeFieldResolution, type MergeFieldSemanticType, type MergeFieldSource, type MergeFieldTransform, type MissingBehavior, type MyLevel, type MySubscription, type NewEntityFieldDeclaration, type NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, PIPELINE_RULE_KINDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, type PermissionLevel, type PgError, type Pipeline, type PipelineColumn, type PipelineDeclared, type PipelineGate, type PipelineGatePreview, type PipelineMissingField, type PipelineMoveResult, type PipelineRule, type PipelineRuleKind, type PipelineSpec, type PipelineStage, type PipelineVerdict, type PortalCard, type PortalInvitation, type PortalPreviewRow, type PortalPrincipal, type PortalRevocation, type PortalSummary, type PortalTableExposure, type PredictedRefusal, type ProvenancePointer, type PublishBinding, type QueuedCapture, type QueuedCaptureFile, type QueuedCaptureState, type QuietHours, REFUSALS_WORTH_REPEATING, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, type ReadRow, type ReadValue, type RecordComment, type RecordDocument, type RecordHistoryEntry, type RecordRead, type RecordRevision, type RecordScopeComment, type RecordScopeContext, type RecordScopeField, type RecordScopeHistoryEntry, type RecordScopeRelation, type RecordScopeWithheld, type RecordsActor, type RecordsChangeSink, type RecordsConfig, type RecordsDataSource, type RecordsError, type RecordsErrorCode, type RecordsErrorSink, type RecordsFilter, RecordsProvider, type RecordsProviderProps, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationDisplay, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RestorePreview, type RestoreResult, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STAGE_RULE_ENFORCEMENT, STAGE_RULE_ON_FAIL, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type SavedViewRow, type SavedViewSpecIn, type StagePending, type StagePendingOnBoard, type StageRuleEnforcement, type StageRuleOnFail, type StageRuleWarning, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type StuckRow, type Subscription, type SubscriptionBlock, type SubscriptionCadence, type SubscriptionSpec, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type UseEntityFieldMutation, type UseFieldMutation, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkApprovalDecision, type WorkApprovalFiled, type WorkApprover, type WorkAssignment, type WorkAssignmentField, type WorkChange, type WorkDueState, type WorkGraph, type WorkInboxItem, type WorkInboxKind, type WorkInstantiation, type WorkListFlavour, type WorkListItem, type WorkOrigin, type WorkRecordState, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, bookingPath, choiceSlug, choiceValuesOf, choicesOf, err, forgetAllOps, highestLevel, holdsARetiredChoice, indexedDbStore, isDecided, isOwnOp, isRecordsErr, isTheChosen, looksLikeAnId, mayDrag, measureKey, memoryStore, mintClientKey, mintOpId, ok, openCaptureQueue, optionKey, optionLabel, portalPath, publicFormPath, rememberedOpCount, scopeChip, tableShapeChanged, useEntityFieldMutation, useEntityFieldRights, useEntityFields, useEntityRecord, useEntityTable, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useOptionalRecordsClient, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };
|
|
8487
|
+
export { ABSENCE_REASONS, ACTOR_VOCABULARY, type AbsenceReason, type Actor, type AggregateBucket, type AggregateFilter, type AggregateMeasure, type AggregateOperation, type AggregateRow, type AggregateWindow, type AnonTokenBinding, type BookingAvailability, type BookingDeclared, type BookingSummary, type BookingWindow, COMPUTE_ON, CONTEXT_POLICIES, type CaptureField, type CaptureFileRef, type CaptureOutcome, type CaptureQuestion, type CaptureQueue, type CaptureQueueCounts, type CaptureQueueOptions, type CaptureQueuePorts, type CaptureQueueStore, type CaptureSheetFace, type CaptureSheetSummary, type CaptureSyncReport, type ChecklistDeclared, type ChecklistRequirement, type ChecklistRequirementKind, type ChecklistRoleSpec, type ChecklistRunStarted, type ChecklistRunStep, type ChecklistRunSummary, type ChecklistSpec, type ChecklistStepCompleted, type ChecklistStepSpec, type ChecklistTemplateShape, type ChecklistTemplateSummary, type ChecklistTrigger, type ChecklistTriggerKind, type ChoiceOption, type ChoiceOptions, type CoerceOptions, type Coerced, type CoercedAnswers, type CoercibleField, type CommentThreadRead, type CommentWritten, type ComputeOn, type ContextPolicy, type ConversationScope, type ConversationScopeContext, type CustomFieldTableType, DELIVERIES, type DashboardBlock, type DashboardBlockKind, type DashboardBlockResult, type DashboardRunResult, type DashboardSummary, type Delivery, type DigestPreview, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, type EnrichAlternate, type EnrichCell, type EnrichDeclared, type EnrichDueRow, type EnrichRun, type EnrichSource, type Enrichment, type EnrichmentSummary, type EntityFieldRights, type EntityFieldValue, type EntityRecordMatch, type EntityRecordRead, type EntityRecordsFound, type EntityTableFacts, type EntityToken, type ExternalPrincipalCard, FIELD_KINDS, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, type Field, type FieldBehavior, type FieldHistoryEntry, type FieldKind, type FieldPatch, type FieldProposal, type FieldRule, type FieldSensitivity, type FieldSource, type FieldTypeWord, type ForbiddenEnvelopeWord, type FormSummary, type Freshness, type HiddenFieldNotice, type HistoryActor, type HistoryActorKind, type HistoryChange, type Home, type ImportBatchResult, type ImportColumnPlan, type ImportFinished, type ImportOpened, type ImportOutcome, type ImportPlan, type ImportPolicy, type ImportProposal, type ImportReport, type ImportRun, type InboundAddress, type InboundDeclared, KERNEL_TABLES, type KernelTableName, type KernelTargets, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, type MergeField, type MergeFieldModifier, type MergeFieldProvenance, type MergeFieldResolution, type MergeFieldSemanticType, type MergeFieldSource, type MergeFieldTransform, type MissingBehavior, type MyLevel, type MySubscription, type NewEntityFieldDeclaration, type NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, PIPELINE_RULE_KINDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, type PermissionLevel, type PgError, type Pipeline, type PipelineColumn, type PipelineDeclared, type PipelineGate, type PipelineGatePreview, type PipelineMissingField, type PipelineMoveResult, type PipelineRule, type PipelineRuleKind, type PipelineSpec, type PipelineStage, type PipelineVerdict, type PortalCard, type PortalInvitation, type PortalPreviewRow, type PortalPrincipal, type PortalRevocation, type PortalSummary, type PortalTableExposure, type PredictedRefusal, type ProvenancePointer, type PublishBinding, type QueuedCapture, type QueuedCaptureFile, type QueuedCaptureState, type QuietHours, REFUSALS_WORTH_REPEATING, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, type ReadRow, type ReadValue, type RecordComment, type RecordDocument, type RecordHistoryEntry, type RecordRead, type RecordRevision, type RecordScopeComment, type RecordScopeContext, type RecordScopeField, type RecordScopeHistoryEntry, type RecordScopeRelation, type RecordScopeWithheld, type RecordsActor, type RecordsChangeSink, type RecordsConfig, type RecordsDataSource, type RecordsError, type RecordsErrorCode, type RecordsErrorSink, type RecordsFilter, RecordsProvider, type RecordsProviderProps, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationDisplay, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RestorePreview, type RestoreResult, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STAGE_RULE_ENFORCEMENT, STAGE_RULE_ON_FAIL, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type SavedViewRow, type SavedViewSpecIn, type StagePending, type StagePendingOnBoard, type StageRuleEnforcement, type StageRuleOnFail, type StageRuleWarning, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type StuckRow, type Subscription, type SubscriptionBlock, type SubscriptionCadence, type SubscriptionSpec, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type UseEntityFieldMutation, type UseFieldMutation, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkApprovalDecision, type WorkApprovalFiled, type WorkApprover, type WorkAssignment, type WorkAssignmentField, type WorkChange, type WorkDueState, type WorkGraph, type WorkInboxItem, type WorkInboxKind, type WorkInstantiation, type WorkListFlavour, type WorkListItem, type WorkOrigin, type WorkRecordState, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, bookingPath, choiceSlug, choiceValuesOf, choicesOf, coerceTypedAnswer, coerceTypedAnswers, coercionLabel, err, fieldKindFor, forgetAllOps, highestLevel, holdsARetiredChoice, indexedDbStore, isDecided, isOwnOp, isRecordsErr, isTheChosen, looksLikeAnId, mayDrag, measureKey, memoryStore, mintClientKey, mintOpId, ok, openCaptureQueue, optionKey, optionLabel, portalPath, publicFormPath, rememberedOpCount, scopeChip, tableShapeChanged, useEntityFieldMutation, useEntityFieldRights, useEntityFields, useEntityRecord, useEntityTable, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useOptionalRecordsClient, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -4114,6 +4114,129 @@ declare function holdsARetiredChoice(document: RecordDocument | undefined, field
|
|
|
4114
4114
|
/** True when a token looks like a uuid — which a choice value is no longer allowed to be. */
|
|
4115
4115
|
declare function looksLikeAnId(value: unknown): boolean;
|
|
4116
4116
|
|
|
4117
|
+
/**
|
|
4118
|
+
* EVERYTHING THIS FILE NEEDS TO KNOW ABOUT A FIELD, AND NOTHING ELSE.
|
|
4119
|
+
*
|
|
4120
|
+
* A full `Field` satisfies it, and so does every narrower shape the store
|
|
4121
|
+
* hands to a screen — `CaptureField` on a phone with no network, the Field
|
|
4122
|
+
* documents `custom.form_public` and `custom.booking_public` publish to a
|
|
4123
|
+
* stranger. Asking for the whole `Field` would have meant the capture sheet
|
|
4124
|
+
* keeping its own `Number(raw)`, which is exactly the duplication this file
|
|
4125
|
+
* exists to end.
|
|
4126
|
+
*/
|
|
4127
|
+
interface CoercibleField {
|
|
4128
|
+
/** Named so the doc above is checkable: a full {@link Field} satisfies this. */
|
|
4129
|
+
key: string;
|
|
4130
|
+
label?: string | null;
|
|
4131
|
+
name?: string | null;
|
|
4132
|
+
/** FLD-1. One of five behaviours; an unknown word is treated as text. */
|
|
4133
|
+
type?: string | null;
|
|
4134
|
+
multi?: boolean | null;
|
|
4135
|
+
unit?: string | null;
|
|
4136
|
+
format?: string | null;
|
|
4137
|
+
config?: Record<string, unknown> | null | undefined;
|
|
4138
|
+
relation_target?: string | null;
|
|
4139
|
+
}
|
|
4140
|
+
/**
|
|
4141
|
+
* The kind of value one Field holds, resolved from its DECLARATION only — the
|
|
4142
|
+
* behaviour, the modifiers, the format, the relation target and the config,
|
|
4143
|
+
* because those are what the store stores. A screen that guessed from a value
|
|
4144
|
+
* would answer differently for an empty record.
|
|
4145
|
+
*
|
|
4146
|
+
* `plain_text`, `long_text`, `number` and `boolean` are behaviours that carry
|
|
4147
|
+
* no parity type of their own; every other word here is a parity type.
|
|
4148
|
+
*/
|
|
4149
|
+
declare const FIELD_KINDS: readonly ["attachment", "checkbox", "currency", "datetime", "email", "formula", "json", "long_text", "lookup", "member", "multi_select", "number", "percent", "phone", "relation", "rollup", "select", "text", "url"];
|
|
4150
|
+
/**
|
|
4151
|
+
* 🚨 THE UNION IS DERIVED FROM THE LIST ABOVE, and the list is what the
|
|
4152
|
+
* coverage test walks. Add a kind here and the test drives it; give it no arm
|
|
4153
|
+
* in `coerceTypedAnswer` and the test says so, instead of the new kind falling
|
|
4154
|
+
* quietly through `default:` and a value of the wrong shape reaching the store
|
|
4155
|
+
* — which is the whole defect this file closes.
|
|
4156
|
+
*/
|
|
4157
|
+
type FieldKind = (typeof FIELD_KINDS)[number];
|
|
4158
|
+
/** The kernel Table ids REC-31 pins the two special relations to. */
|
|
4159
|
+
interface KernelTargets {
|
|
4160
|
+
/** The kernel `File` Table — a relation pointing here is an attachment. */
|
|
4161
|
+
file?: string | undefined;
|
|
4162
|
+
/** The kernel `Person` Table — a relation pointing here names a person. */
|
|
4163
|
+
person?: string | undefined;
|
|
4164
|
+
}
|
|
4165
|
+
/**
|
|
4166
|
+
* Which kind of value this Field holds.
|
|
4167
|
+
*
|
|
4168
|
+
* This is the ONE classifier. `@ai-matrx/records-ui`'s `editorKindFor` — which
|
|
4169
|
+
* decides which editor to DRAW — delegates to it, so the editor a person types
|
|
4170
|
+
* into and the coercion applied to what they typed can never disagree about
|
|
4171
|
+
* the same column. They did disagree before this moved here; that is the whole
|
|
4172
|
+
* class of grid defect September was spent closing.
|
|
4173
|
+
*/
|
|
4174
|
+
declare function fieldKindFor(field: CoercibleField, kernel?: KernelTargets): FieldKind;
|
|
4175
|
+
/** One Field's options, indexed the way a typed word has to be looked up. */
|
|
4176
|
+
interface ChoiceOptions {
|
|
4177
|
+
/**
|
|
4178
|
+
* Lower-cased label, option key and option id, each pointing at the OPTION
|
|
4179
|
+
* RECORD'S ID — which is what a list Field stores (FLD-5/FLD-6).
|
|
4180
|
+
*/
|
|
4181
|
+
byWord: Map<string, string>;
|
|
4182
|
+
/** The labels, in order, so a refusal can say what is on offer. */
|
|
4183
|
+
labels: string[];
|
|
4184
|
+
}
|
|
4185
|
+
/** What one answer became, or the sentence saying why it did not. */
|
|
4186
|
+
type Coerced = {
|
|
4187
|
+
value: unknown;
|
|
4188
|
+
} | {
|
|
4189
|
+
refusal: string;
|
|
4190
|
+
unmatched?: string[];
|
|
4191
|
+
};
|
|
4192
|
+
interface CoerceOptions {
|
|
4193
|
+
/** This Field's choices, when the caller has loaded them. */
|
|
4194
|
+
options?: ChoiceOptions | undefined;
|
|
4195
|
+
/** The kernel File/Person Table ids, for classifying relations. */
|
|
4196
|
+
kernel?: KernelTargets | undefined;
|
|
4197
|
+
/**
|
|
4198
|
+
* The Field's name as this caller writes it. Defaults to the Field's own
|
|
4199
|
+
* label. A screen passes the same words it printed above the box.
|
|
4200
|
+
*/
|
|
4201
|
+
label?: string | undefined;
|
|
4202
|
+
}
|
|
4203
|
+
/** The Field's name in plain words — never its key on a screen. */
|
|
4204
|
+
declare function coercionLabel(field: CoercibleField): string;
|
|
4205
|
+
/**
|
|
4206
|
+
* Turn ONE typed-in string into the value this Field holds — or say, in a
|
|
4207
|
+
* sentence a person can act on, why it is not one.
|
|
4208
|
+
*
|
|
4209
|
+
* An empty answer is `null` for every kind: a blank means "no answer here",
|
|
4210
|
+
* and clearing a value is a thing a person means to do. Whether the Field may
|
|
4211
|
+
* be blank is the store's question, asked with the Field's `required` and its
|
|
4212
|
+
* Rules, not this one's.
|
|
4213
|
+
*/
|
|
4214
|
+
declare function coerceTypedAnswer(field: CoercibleField, raw: string, opts?: CoerceOptions): Coerced;
|
|
4215
|
+
/** What a whole set of typed-in answers became. */
|
|
4216
|
+
interface CoercedAnswers {
|
|
4217
|
+
/** Ready to send to the store. Only the keys that coerced cleanly. */
|
|
4218
|
+
values: Record<string, unknown>;
|
|
4219
|
+
/** Field key → the sentence saying why that answer was not written. */
|
|
4220
|
+
refusals: Record<string, string>;
|
|
4221
|
+
/** The field keys the caller sent that this table has no Field for. */
|
|
4222
|
+
unknownKeys: string[];
|
|
4223
|
+
}
|
|
4224
|
+
/**
|
|
4225
|
+
* Every typed-in answer on one screen, coerced together — the shape the two
|
|
4226
|
+
* public doors and the import wizard actually need.
|
|
4227
|
+
*
|
|
4228
|
+
* Keys the table has no Field for are reported rather than dropped: the store
|
|
4229
|
+
* refuses an unknown key by name and a caller that quietly deleted it would
|
|
4230
|
+
* hide a real mismatch between a page and its table.
|
|
4231
|
+
*/
|
|
4232
|
+
declare function coerceTypedAnswers(fields: readonly CoercibleField[], answers: Readonly<Record<string, unknown>>, opts?: {
|
|
4233
|
+
kernel?: KernelTargets | undefined;
|
|
4234
|
+
/** Choices per Field key, for the list columns. */
|
|
4235
|
+
options?: ReadonlyMap<string, ChoiceOptions> | undefined;
|
|
4236
|
+
/** Field key → the words that screen printed above the box. */
|
|
4237
|
+
labels?: Readonly<Record<string, string>> | undefined;
|
|
4238
|
+
}): CoercedAnswers;
|
|
4239
|
+
|
|
4117
4240
|
/** The seven table types. Only these two carry custom fields (REC-34, DD-011). */
|
|
4118
4241
|
type CustomFieldTableType = "entity" | "detail";
|
|
4119
4242
|
/** What `custom.entity_table` answers about a registry token. */
|
|
@@ -8361,4 +8484,4 @@ declare function useFieldMutation(): UseFieldMutation;
|
|
|
8361
8484
|
*/
|
|
8362
8485
|
declare function useMergeField(key: string | null, state?: Record<string, unknown>): MergeFieldResolution | null;
|
|
8363
8486
|
|
|
8364
|
-
export { ABSENCE_REASONS, ACTOR_VOCABULARY, type AbsenceReason, type Actor, type AggregateBucket, type AggregateFilter, type AggregateMeasure, type AggregateOperation, type AggregateRow, type AggregateWindow, type AnonTokenBinding, type BookingAvailability, type BookingDeclared, type BookingSummary, type BookingWindow, COMPUTE_ON, CONTEXT_POLICIES, type CaptureField, type CaptureFileRef, type CaptureOutcome, type CaptureQuestion, type CaptureQueue, type CaptureQueueCounts, type CaptureQueueOptions, type CaptureQueuePorts, type CaptureQueueStore, type CaptureSheetFace, type CaptureSheetSummary, type CaptureSyncReport, type ChecklistDeclared, type ChecklistRequirement, type ChecklistRequirementKind, type ChecklistRoleSpec, type ChecklistRunStarted, type ChecklistRunStep, type ChecklistRunSummary, type ChecklistSpec, type ChecklistStepCompleted, type ChecklistStepSpec, type ChecklistTemplateShape, type ChecklistTemplateSummary, type ChecklistTrigger, type ChecklistTriggerKind, type ChoiceOption, type CommentThreadRead, type CommentWritten, type ComputeOn, type ContextPolicy, type ConversationScope, type ConversationScopeContext, type CustomFieldTableType, DELIVERIES, type DashboardBlock, type DashboardBlockKind, type DashboardBlockResult, type DashboardRunResult, type DashboardSummary, type Delivery, type DigestPreview, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, type EnrichAlternate, type EnrichCell, type EnrichDeclared, type EnrichDueRow, type EnrichRun, type EnrichSource, type Enrichment, type EnrichmentSummary, type EntityFieldRights, type EntityFieldValue, type EntityRecordMatch, type EntityRecordRead, type EntityRecordsFound, type EntityTableFacts, type EntityToken, type ExternalPrincipalCard, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, type Field, type FieldBehavior, type FieldHistoryEntry, type FieldPatch, type FieldProposal, type FieldRule, type FieldSensitivity, type FieldSource, type FieldTypeWord, type ForbiddenEnvelopeWord, type FormSummary, type Freshness, type HiddenFieldNotice, type HistoryActor, type HistoryActorKind, type HistoryChange, type Home, type ImportBatchResult, type ImportColumnPlan, type ImportFinished, type ImportOpened, type ImportOutcome, type ImportPlan, type ImportPolicy, type ImportProposal, type ImportReport, type ImportRun, type InboundAddress, type InboundDeclared, KERNEL_TABLES, type KernelTableName, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, type MergeField, type MergeFieldModifier, type MergeFieldProvenance, type MergeFieldResolution, type MergeFieldSemanticType, type MergeFieldSource, type MergeFieldTransform, type MissingBehavior, type MyLevel, type MySubscription, type NewEntityFieldDeclaration, type NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, PIPELINE_RULE_KINDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, type PermissionLevel, type PgError, type Pipeline, type PipelineColumn, type PipelineDeclared, type PipelineGate, type PipelineGatePreview, type PipelineMissingField, type PipelineMoveResult, type PipelineRule, type PipelineRuleKind, type PipelineSpec, type PipelineStage, type PipelineVerdict, type PortalCard, type PortalInvitation, type PortalPreviewRow, type PortalPrincipal, type PortalRevocation, type PortalSummary, type PortalTableExposure, type PredictedRefusal, type ProvenancePointer, type PublishBinding, type QueuedCapture, type QueuedCaptureFile, type QueuedCaptureState, type QuietHours, REFUSALS_WORTH_REPEATING, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, type ReadRow, type ReadValue, type RecordComment, type RecordDocument, type RecordHistoryEntry, type RecordRead, type RecordRevision, type RecordScopeComment, type RecordScopeContext, type RecordScopeField, type RecordScopeHistoryEntry, type RecordScopeRelation, type RecordScopeWithheld, type RecordsActor, type RecordsChangeSink, type RecordsConfig, type RecordsDataSource, type RecordsError, type RecordsErrorCode, type RecordsErrorSink, type RecordsFilter, RecordsProvider, type RecordsProviderProps, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationDisplay, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RestorePreview, type RestoreResult, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STAGE_RULE_ENFORCEMENT, STAGE_RULE_ON_FAIL, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type SavedViewRow, type SavedViewSpecIn, type StagePending, type StagePendingOnBoard, type StageRuleEnforcement, type StageRuleOnFail, type StageRuleWarning, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type StuckRow, type Subscription, type SubscriptionBlock, type SubscriptionCadence, type SubscriptionSpec, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type UseEntityFieldMutation, type UseFieldMutation, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkApprovalDecision, type WorkApprovalFiled, type WorkApprover, type WorkAssignment, type WorkAssignmentField, type WorkChange, type WorkDueState, type WorkGraph, type WorkInboxItem, type WorkInboxKind, type WorkInstantiation, type WorkListFlavour, type WorkListItem, type WorkOrigin, type WorkRecordState, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, bookingPath, choiceSlug, choiceValuesOf, choicesOf, err, forgetAllOps, highestLevel, holdsARetiredChoice, indexedDbStore, isDecided, isOwnOp, isRecordsErr, isTheChosen, looksLikeAnId, mayDrag, measureKey, memoryStore, mintClientKey, mintOpId, ok, openCaptureQueue, optionKey, optionLabel, portalPath, publicFormPath, rememberedOpCount, scopeChip, tableShapeChanged, useEntityFieldMutation, useEntityFieldRights, useEntityFields, useEntityRecord, useEntityTable, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useOptionalRecordsClient, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };
|
|
8487
|
+
export { ABSENCE_REASONS, ACTOR_VOCABULARY, type AbsenceReason, type Actor, type AggregateBucket, type AggregateFilter, type AggregateMeasure, type AggregateOperation, type AggregateRow, type AggregateWindow, type AnonTokenBinding, type BookingAvailability, type BookingDeclared, type BookingSummary, type BookingWindow, COMPUTE_ON, CONTEXT_POLICIES, type CaptureField, type CaptureFileRef, type CaptureOutcome, type CaptureQuestion, type CaptureQueue, type CaptureQueueCounts, type CaptureQueueOptions, type CaptureQueuePorts, type CaptureQueueStore, type CaptureSheetFace, type CaptureSheetSummary, type CaptureSyncReport, type ChecklistDeclared, type ChecklistRequirement, type ChecklistRequirementKind, type ChecklistRoleSpec, type ChecklistRunStarted, type ChecklistRunStep, type ChecklistRunSummary, type ChecklistSpec, type ChecklistStepCompleted, type ChecklistStepSpec, type ChecklistTemplateShape, type ChecklistTemplateSummary, type ChecklistTrigger, type ChecklistTriggerKind, type ChoiceOption, type ChoiceOptions, type CoerceOptions, type Coerced, type CoercedAnswers, type CoercibleField, type CommentThreadRead, type CommentWritten, type ComputeOn, type ContextPolicy, type ConversationScope, type ConversationScopeContext, type CustomFieldTableType, DELIVERIES, type DashboardBlock, type DashboardBlockKind, type DashboardBlockResult, type DashboardRunResult, type DashboardSummary, type Delivery, type DigestPreview, type DocRenderRow, type DocSignatureCheck, type DocSignatureRow, type DocTemplateRow, type DocToken, type DocUnresolvedToken, ENTITY_TOKENS, type EnrichAlternate, type EnrichCell, type EnrichDeclared, type EnrichDueRow, type EnrichRun, type EnrichSource, type Enrichment, type EnrichmentSummary, type EntityFieldRights, type EntityFieldValue, type EntityRecordMatch, type EntityRecordRead, type EntityRecordsFound, type EntityTableFacts, type EntityToken, type ExternalPrincipalCard, FIELD_KINDS, FIELD_SENSITIVITIES, FIELD_SOURCES, FRESHNESS, type Field, type FieldBehavior, type FieldHistoryEntry, type FieldKind, type FieldPatch, type FieldProposal, type FieldRule, type FieldSensitivity, type FieldSource, type FieldTypeWord, type ForbiddenEnvelopeWord, type FormSummary, type Freshness, type HiddenFieldNotice, type HistoryActor, type HistoryActorKind, type HistoryChange, type Home, type ImportBatchResult, type ImportColumnPlan, type ImportFinished, type ImportOpened, type ImportOutcome, type ImportPlan, type ImportPolicy, type ImportProposal, type ImportReport, type ImportRun, type InboundAddress, type InboundDeclared, KERNEL_TABLES, type KernelTableName, type KernelTargets, MERGE_FIELD_MODIFIERS, MERGE_FIELD_SEMANTIC_TYPES, MERGE_FIELD_SOURCES, type MergeField, type MergeFieldModifier, type MergeFieldProvenance, type MergeFieldResolution, type MergeFieldSemanticType, type MergeFieldSource, type MergeFieldTransform, type MissingBehavior, type MyLevel, type MySubscription, type NewEntityFieldDeclaration, type NewFieldDeclaration, ON_DELETE, OVERRIDE_POLICIES, type OnDelete, type OverridePolicy, PARITY_FIELD_TYPES, PERMISSION_LEVELS, PER_VALUE_ACCESS_WORDS, PIPELINE_RULE_KINDS, type ParityFieldType, type ParityFieldTypeDescriptor, type PerValueAccessWord, type PermissionLevel, type PgError, type Pipeline, type PipelineColumn, type PipelineDeclared, type PipelineGate, type PipelineGatePreview, type PipelineMissingField, type PipelineMoveResult, type PipelineRule, type PipelineRuleKind, type PipelineSpec, type PipelineStage, type PipelineVerdict, type PortalCard, type PortalInvitation, type PortalPreviewRow, type PortalPrincipal, type PortalRevocation, type PortalSummary, type PortalTableExposure, type PredictedRefusal, type ProvenancePointer, type PublishBinding, type QueuedCapture, type QueuedCaptureFile, type QueuedCaptureState, type QuietHours, REFUSALS_WORTH_REPEATING, RELATION_BINDINGS, RELATION_CARDINALITIES, RELATION_FLAVORS, RETIRED_ACTOR_WORDS, RULE_NODE_KINDS, RULE_USES, type ReadRow, type ReadValue, type RecordComment, type RecordDocument, type RecordHistoryEntry, type RecordRead, type RecordRevision, type RecordScopeComment, type RecordScopeContext, type RecordScopeField, type RecordScopeHistoryEntry, type RecordScopeRelation, type RecordScopeWithheld, type RecordsActor, type RecordsChangeSink, type RecordsConfig, type RecordsDataSource, type RecordsError, type RecordsErrorCode, type RecordsErrorSink, type RecordsFilter, RecordsProvider, type RecordsProviderProps, type RecordsRealtimePort, type RecordsResolverPort, type RecordsResponse, type RecordsResult, type RecordsTableQuery, type RegisteredTable, type Relation, type RelationBinding, type RelationCardinality, type RelationCarries, type RelationCoordinate, type RelationDisplay, type RelationFlavor, type RelationProperties, type RelationTarget, type ResolutionTriple, type ResolvedPublishBinding, type RestorePreview, type RestoreResult, type RetiredActorWord, type Rule, type RuleAnswer, type RuleExpression, type RuleNodeKind, type RuleUse, STAGE_RULE_ENFORCEMENT, STAGE_RULE_ON_FAIL, STORAGE_MODES, STORE_DOORS, STORE_KNOBS, STORE_REFUSAL_CODES, type SavedViewRow, type SavedViewSpecIn, type StagePending, type StagePendingOnBoard, type StageRuleEnforcement, type StageRuleOnFail, type StageRuleWarning, type StaleWriteDetail, type StorageMode, type StoreDoorName, type StoreRefusalCode, type StoredRecord, type StuckRow, type Subscription, type SubscriptionBlock, type SubscriptionCadence, type SubscriptionSpec, TABLE_DISPLAYS, TABLE_ORIGINS, TABLE_TYPES, type Table, type TableCapacity, type TableDisplay, type TableOrigin, type TableProposal, type TableType, type Timestamp, type UseEntityFieldMutation, type UseFieldMutation, type UseRecordMutation, type UseRecordsOptions, type UseRecordsState, type Uuid, VALUE_ALTERNATE_KEYS, VALUE_ENVELOPE_KEYS, type ValueAlternate, type ValueAlternateKey, type ValueEnvelope, type ValueEnvelopeKey, type ValueSource, type WorkApprovalDecision, type WorkApprovalFiled, type WorkApprover, type WorkAssignment, type WorkAssignmentField, type WorkChange, type WorkDueState, type WorkGraph, type WorkInboxItem, type WorkInboxKind, type WorkInstantiation, type WorkListFlavour, type WorkListItem, type WorkOrigin, type WorkRecordState, type WorkSlotHold, type WorkState, type WorkTemplateNode, type WorkTemplateRelation, type WorkTurn, type WriteConflict, asPermissionLevel, atLeast, bookingPath, choiceSlug, choiceValuesOf, choicesOf, coerceTypedAnswer, coerceTypedAnswers, coercionLabel, err, fieldKindFor, forgetAllOps, highestLevel, holdsARetiredChoice, indexedDbStore, isDecided, isOwnOp, isRecordsErr, isTheChosen, looksLikeAnId, mayDrag, measureKey, memoryStore, mintClientKey, mintOpId, ok, openCaptureQueue, optionKey, optionLabel, portalPath, publicFormPath, rememberedOpCount, scopeChip, tableShapeChanged, useEntityFieldMutation, useEntityFieldRights, useEntityFields, useEntityRecord, useEntityTable, useFieldMutation, useFields, useMergeField, useMyLevel, useMyLevels, useOptionalRecordsClient, useRecord, useRecordMutation, useRecords, useRecordsActor, useRecordsClient, useTable, useTables };
|
package/dist/react/index.js
CHANGED
|
@@ -4716,6 +4716,209 @@ function looksLikeAnId(value) {
|
|
|
4716
4716
|
return typeof value === "string" && UUID.test(value);
|
|
4717
4717
|
}
|
|
4718
4718
|
|
|
4719
|
+
// src/coerce.ts
|
|
4720
|
+
var FIELD_KINDS = [
|
|
4721
|
+
"attachment",
|
|
4722
|
+
"checkbox",
|
|
4723
|
+
"currency",
|
|
4724
|
+
"datetime",
|
|
4725
|
+
"email",
|
|
4726
|
+
"formula",
|
|
4727
|
+
"json",
|
|
4728
|
+
"long_text",
|
|
4729
|
+
"lookup",
|
|
4730
|
+
"member",
|
|
4731
|
+
"multi_select",
|
|
4732
|
+
"number",
|
|
4733
|
+
"percent",
|
|
4734
|
+
"phone",
|
|
4735
|
+
"relation",
|
|
4736
|
+
"rollup",
|
|
4737
|
+
"select",
|
|
4738
|
+
"text",
|
|
4739
|
+
"url"
|
|
4740
|
+
];
|
|
4741
|
+
function fieldKindFor(field, kernel) {
|
|
4742
|
+
const format = (field.format ?? "").toLowerCase();
|
|
4743
|
+
const config = field.config ?? {};
|
|
4744
|
+
switch (field.type) {
|
|
4745
|
+
case "boolean":
|
|
4746
|
+
return "checkbox";
|
|
4747
|
+
case "text":
|
|
4748
|
+
if (format === "email") return "email";
|
|
4749
|
+
if (format === "phone") return "phone";
|
|
4750
|
+
if (format === "url") return "url";
|
|
4751
|
+
if (format === "json" || config["json"] === true) return "json";
|
|
4752
|
+
if (format === "long" || config["multiline"] === true) return "long_text";
|
|
4753
|
+
return "text";
|
|
4754
|
+
case "range": {
|
|
4755
|
+
const kind = String(config["kind"] ?? "number");
|
|
4756
|
+
if (kind === "date" || kind === "datetime") return "datetime";
|
|
4757
|
+
if (format === "currency") return "currency";
|
|
4758
|
+
if (format === "percent" || field.unit === "%") return "percent";
|
|
4759
|
+
return "number";
|
|
4760
|
+
}
|
|
4761
|
+
case "list":
|
|
4762
|
+
return field.multi ? "multi_select" : "select";
|
|
4763
|
+
case "relation": {
|
|
4764
|
+
const parity = String(config["parity"] ?? "");
|
|
4765
|
+
if (parity === "attachment" || parity === "member") return parity;
|
|
4766
|
+
if (kernel?.file && field.relation_target === kernel.file) return "attachment";
|
|
4767
|
+
if (kernel?.person && field.relation_target === kernel.person) return "member";
|
|
4768
|
+
return "relation";
|
|
4769
|
+
}
|
|
4770
|
+
case "formula": {
|
|
4771
|
+
const via = config["via"];
|
|
4772
|
+
if (via && config["agg"]) return "rollup";
|
|
4773
|
+
if (via) return "lookup";
|
|
4774
|
+
return "formula";
|
|
4775
|
+
}
|
|
4776
|
+
default:
|
|
4777
|
+
return "text";
|
|
4778
|
+
}
|
|
4779
|
+
}
|
|
4780
|
+
var TRUE_WORDS = /* @__PURE__ */ new Set(["true", "yes", "y", "1", "\u2713", "x", "checked", "on"]);
|
|
4781
|
+
var FALSE_WORDS = /* @__PURE__ */ new Set(["false", "no", "n", "0", "", "unchecked", "off"]);
|
|
4782
|
+
function coercionLabel(field) {
|
|
4783
|
+
const label = (field.label ?? "").trim();
|
|
4784
|
+
if (label !== "") return label;
|
|
4785
|
+
const name = (field.name ?? "").trim();
|
|
4786
|
+
if (name !== "") return name;
|
|
4787
|
+
return field.key.replace(/[_-]+/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()).trim();
|
|
4788
|
+
}
|
|
4789
|
+
function coerceTypedAnswer(field, raw, opts = {}) {
|
|
4790
|
+
const label = opts.label ?? coercionLabel(field);
|
|
4791
|
+
const text = raw.trim();
|
|
4792
|
+
const kind = fieldKindFor(field, opts.kernel);
|
|
4793
|
+
if (text === "" && kind !== "checkbox") return { value: null };
|
|
4794
|
+
switch (kind) {
|
|
4795
|
+
case "checkbox": {
|
|
4796
|
+
const word = text.toLowerCase();
|
|
4797
|
+
if (TRUE_WORDS.has(word)) return { value: true };
|
|
4798
|
+
if (FALSE_WORDS.has(word)) return { value: word === "" ? null : false };
|
|
4799
|
+
return {
|
|
4800
|
+
refusal: `${label} is a tick box, so it takes yes or no \u2014 \u201C${raw}\u201D is neither. Write TRUE/FALSE, yes/no or 1/0.`
|
|
4801
|
+
};
|
|
4802
|
+
}
|
|
4803
|
+
case "number":
|
|
4804
|
+
case "currency":
|
|
4805
|
+
case "percent": {
|
|
4806
|
+
const negative = /^\(.*\)$/.test(text);
|
|
4807
|
+
const bare = text.replace(/^\(|\)$/g, "").replace(/[\s,]/g, "").replace(/^[^\d.\-+]+/, "").replace(/[^\d.\-+eE]+$/, "");
|
|
4808
|
+
const n = Number(bare);
|
|
4809
|
+
if (bare === "" || Number.isNaN(n)) {
|
|
4810
|
+
return {
|
|
4811
|
+
refusal: `${label} holds a number, and \u201C${raw}\u201D is not one. Write digits \u2014 a currency symbol, a percent sign, commas and brackets for a negative are all fine.`
|
|
4812
|
+
};
|
|
4813
|
+
}
|
|
4814
|
+
return { value: negative ? -n : n };
|
|
4815
|
+
}
|
|
4816
|
+
case "datetime": {
|
|
4817
|
+
const wantsTime = String(field.config?.["kind"] ?? "date") === "datetime";
|
|
4818
|
+
const plainDay = /^\s*(\d{4})-(\d{2})-(\d{2})\s*$/.exec(raw);
|
|
4819
|
+
if (!wantsTime && plainDay) return { value: `${plainDay[1]}-${plainDay[2]}-${plainDay[3]}` };
|
|
4820
|
+
const at = Date.parse(text);
|
|
4821
|
+
if (Number.isNaN(at)) {
|
|
4822
|
+
return {
|
|
4823
|
+
refusal: `${label} holds a date, and \u201C${raw}\u201D is not one this can read. Write it as 2026-09-21, or the way your spreadsheet writes dates.`
|
|
4824
|
+
};
|
|
4825
|
+
}
|
|
4826
|
+
const parsed = new Date(at);
|
|
4827
|
+
if (wantsTime) return { value: parsed.toISOString() };
|
|
4828
|
+
const y = parsed.getFullYear();
|
|
4829
|
+
const m = String(parsed.getMonth() + 1).padStart(2, "0");
|
|
4830
|
+
const d = String(parsed.getDate()).padStart(2, "0");
|
|
4831
|
+
return { value: `${y}-${m}-${d}` };
|
|
4832
|
+
}
|
|
4833
|
+
case "json": {
|
|
4834
|
+
try {
|
|
4835
|
+
return { value: JSON.parse(text) };
|
|
4836
|
+
} catch {
|
|
4837
|
+
return {
|
|
4838
|
+
refusal: `${label} holds a document, and \u201C${raw}\u201D is not valid JSON. Write the whole object, braces and all.`
|
|
4839
|
+
};
|
|
4840
|
+
}
|
|
4841
|
+
}
|
|
4842
|
+
case "select":
|
|
4843
|
+
case "multi_select": {
|
|
4844
|
+
if (!opts.options) {
|
|
4845
|
+
return {
|
|
4846
|
+
refusal: `${label} is a list and its options have not been read yet, so nothing can be matched to \u201C${raw}\u201D. Try again once the column's choices have loaded.`
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
const wanted = kind === "multi_select" ? text.split(/[,;]/).map((w) => w.trim()).filter((w) => w.length > 0) : [text];
|
|
4850
|
+
if (wanted.length === 0) return { value: kind === "multi_select" ? [] : null };
|
|
4851
|
+
const matched = [];
|
|
4852
|
+
const unmatched = [];
|
|
4853
|
+
for (const word of wanted) {
|
|
4854
|
+
const hit = opts.options.byWord.get(word.toLowerCase());
|
|
4855
|
+
if (hit === void 0) unmatched.push(word);
|
|
4856
|
+
else matched.push(hit);
|
|
4857
|
+
}
|
|
4858
|
+
if (unmatched.length > 0) {
|
|
4859
|
+
const offered = opts.options.labels.length > 0 ? opts.options.labels.join(", ") : "it has none yet";
|
|
4860
|
+
return {
|
|
4861
|
+
refusal: `${label} does not have ${unmatched.map((w) => `\u201C${w}\u201D`).join(" or ")} among its options. It offers: ${offered}.`,
|
|
4862
|
+
unmatched
|
|
4863
|
+
};
|
|
4864
|
+
}
|
|
4865
|
+
return { value: kind === "multi_select" ? matched : matched[0] };
|
|
4866
|
+
}
|
|
4867
|
+
// AN IDENTITY IS NOT A WORD. Writing the word would put a string where an
|
|
4868
|
+
// id belongs, and every filter, colour and rollup built on that column
|
|
4869
|
+
// would stop agreeing with it. So it is refused and the person is told
|
|
4870
|
+
// which control does hold it.
|
|
4871
|
+
case "member":
|
|
4872
|
+
return {
|
|
4873
|
+
refusal: `${label} names a person in this organization, so it is chosen rather than typed. Open it and pick them.`
|
|
4874
|
+
};
|
|
4875
|
+
case "attachment":
|
|
4876
|
+
return {
|
|
4877
|
+
refusal: `${label} holds a file, which cannot arrive as typed-in text. Open it and attach the file.`
|
|
4878
|
+
};
|
|
4879
|
+
case "relation":
|
|
4880
|
+
return {
|
|
4881
|
+
refusal: `${label} points at another record, so it is chosen rather than typed. Open it and pick the record.`
|
|
4882
|
+
};
|
|
4883
|
+
case "formula":
|
|
4884
|
+
case "lookup":
|
|
4885
|
+
case "rollup":
|
|
4886
|
+
return {
|
|
4887
|
+
refusal: `${label} is worked out by the system, so nothing can be written into it.`
|
|
4888
|
+
};
|
|
4889
|
+
default:
|
|
4890
|
+
return { value: raw };
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
function coerceTypedAnswers(fields, answers, opts = {}) {
|
|
4894
|
+
const byKey = new Map(fields.map((f) => [f.key, f]));
|
|
4895
|
+
const values = {};
|
|
4896
|
+
const refusals = {};
|
|
4897
|
+
const unknownKeys = [];
|
|
4898
|
+
for (const [key, given] of Object.entries(answers)) {
|
|
4899
|
+
const field = byKey.get(key);
|
|
4900
|
+
if (!field) {
|
|
4901
|
+
unknownKeys.push(key);
|
|
4902
|
+
values[key] = given;
|
|
4903
|
+
continue;
|
|
4904
|
+
}
|
|
4905
|
+
if (typeof given !== "string") {
|
|
4906
|
+
values[key] = given;
|
|
4907
|
+
continue;
|
|
4908
|
+
}
|
|
4909
|
+
const opt = {};
|
|
4910
|
+
const choices = opts.options?.get(key);
|
|
4911
|
+
if (choices) opt.options = choices;
|
|
4912
|
+
if (opts.kernel) opt.kernel = opts.kernel;
|
|
4913
|
+
const label = opts.labels?.[key];
|
|
4914
|
+
if (label) opt.label = label;
|
|
4915
|
+
const answered = coerceTypedAnswer(field, given, opt);
|
|
4916
|
+
if ("refusal" in answered) refusals[key] = answered.refusal;
|
|
4917
|
+
else values[key] = answered.value;
|
|
4918
|
+
}
|
|
4919
|
+
return { values, refusals, unknownKeys };
|
|
4920
|
+
}
|
|
4921
|
+
|
|
4719
4922
|
// src/pipeline.ts
|
|
4720
4923
|
var PIPELINE_RULE_KINDS = ["moves", "requires", "who", "limit", "entry"];
|
|
4721
4924
|
var STAGE_RULE_ON_FAIL = ["refuse", "require_approval"];
|
|
@@ -5032,6 +5235,7 @@ export {
|
|
|
5032
5235
|
CONTEXT_POLICIES,
|
|
5033
5236
|
DELIVERIES,
|
|
5034
5237
|
ENTITY_TOKENS,
|
|
5238
|
+
FIELD_KINDS,
|
|
5035
5239
|
FIELD_SENSITIVITIES,
|
|
5036
5240
|
FIELD_SOURCES,
|
|
5037
5241
|
FRESHNESS,
|
|
@@ -5070,7 +5274,11 @@ export {
|
|
|
5070
5274
|
choiceSlug,
|
|
5071
5275
|
choiceValuesOf,
|
|
5072
5276
|
choicesOf,
|
|
5277
|
+
coerceTypedAnswer,
|
|
5278
|
+
coerceTypedAnswers,
|
|
5279
|
+
coercionLabel,
|
|
5073
5280
|
err,
|
|
5281
|
+
fieldKindFor,
|
|
5074
5282
|
forgetAllOps,
|
|
5075
5283
|
highestLevel,
|
|
5076
5284
|
holdsARetiredChoice,
|