@memberjunction/record-set-processor 6.2.0-edge.4 → 6.2.0-edge.6

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.
Files changed (62) hide show
  1. package/README.md +36 -1
  2. package/dist/RecordProcessExecutor.d.ts +35 -17
  3. package/dist/RecordProcessExecutor.d.ts.map +1 -1
  4. package/dist/RecordProcessExecutor.js +79 -63
  5. package/dist/RecordProcessExecutor.js.map +1 -1
  6. package/dist/RecordSetProcessor.d.ts +15 -0
  7. package/dist/RecordSetProcessor.d.ts.map +1 -1
  8. package/dist/RecordSetProcessor.js +161 -81
  9. package/dist/RecordSetProcessor.js.map +1 -1
  10. package/dist/index.d.ts +0 -4
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +0 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/operations/RecordProcessControlOperations.d.ts.map +1 -1
  15. package/dist/operations/RecordProcessControlOperations.js +9 -7
  16. package/dist/operations/RecordProcessControlOperations.js.map +1 -1
  17. package/dist/processors/ActionRecordProcessor.d.ts.map +1 -1
  18. package/dist/processors/ActionRecordProcessor.js +6 -2
  19. package/dist/processors/ActionRecordProcessor.js.map +1 -1
  20. package/dist/processors/AgentRecordProcessor.d.ts.map +1 -1
  21. package/dist/processors/AgentRecordProcessor.js +5 -2
  22. package/dist/processors/AgentRecordProcessor.js.map +1 -1
  23. package/dist/processors/FieldRulesProcessor.d.ts +22 -7
  24. package/dist/processors/FieldRulesProcessor.d.ts.map +1 -1
  25. package/dist/processors/FieldRulesProcessor.js +24 -13
  26. package/dist/processors/FieldRulesProcessor.js.map +1 -1
  27. package/dist/processors/WriteBackProcessor.d.ts +62 -2
  28. package/dist/processors/WriteBackProcessor.d.ts.map +1 -1
  29. package/dist/processors/WriteBackProcessor.js +134 -58
  30. package/dist/processors/WriteBackProcessor.js.map +1 -1
  31. package/dist/trackers/GenericProcessRunTracker.d.ts.map +1 -1
  32. package/dist/trackers/GenericProcessRunTracker.js +22 -3
  33. package/dist/trackers/GenericProcessRunTracker.js.map +1 -1
  34. package/dist/watermark/WatermarkService.d.ts +62 -24
  35. package/dist/watermark/WatermarkService.d.ts.map +1 -1
  36. package/dist/watermark/WatermarkService.js +123 -70
  37. package/dist/watermark/WatermarkService.js.map +1 -1
  38. package/dist/writeBack.d.ts +358 -42
  39. package/dist/writeBack.d.ts.map +1 -1
  40. package/dist/writeBack.js +848 -208
  41. package/dist/writeBack.js.map +1 -1
  42. package/package.json +16 -17
  43. package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.d.ts +0 -92
  44. package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.d.ts.map +0 -1
  45. package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.js +0 -26
  46. package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.js.map +0 -1
  47. package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.d.ts +0 -79
  48. package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.d.ts.map +0 -1
  49. package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.js +0 -257
  50. package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.js.map +0 -1
  51. package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.d.ts +0 -23
  52. package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.d.ts.map +0 -1
  53. package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.js +0 -85
  54. package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.js.map +0 -1
  55. package/dist/processors/FeaturePipelineEscalation.d.ts +0 -155
  56. package/dist/processors/FeaturePipelineEscalation.d.ts.map +0 -1
  57. package/dist/processors/FeaturePipelineEscalation.js +0 -208
  58. package/dist/processors/FeaturePipelineEscalation.js.map +0 -1
  59. package/dist/processors/InferProcessor.d.ts +0 -306
  60. package/dist/processors/InferProcessor.d.ts.map +0 -1
  61. package/dist/processors/InferProcessor.js +0 -1210
  62. package/dist/processors/InferProcessor.js.map +0 -1
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * @fileoverview Output-mapping write-back — applies a work's structured result back onto the data
3
- * model per an `OutputMapping` config: update fields on the processed record and/or create a child
4
- * record. Reads from the result use the generic value-mapping resolver (`$` = the result root).
3
+ * model per an `OutputMapping` config: update fields on the processed record and/or write child
4
+ * records (inserted, or reconciled on their key so a re-run is idempotent), in one entity transaction.
5
+ * Reads from the result use the generic value-mapping resolver (`$` = the result root).
5
6
  * @module @memberjunction/record-set-processor
6
7
  */
7
- import { IMetadataProvider, UserInfo } from '@memberjunction/core';
8
- import { RecordRef } from '@memberjunction/record-set-processor-base';
8
+ import { BaseEntity, type EntityFieldInfo, type EntityInfo, IMetadataProvider, type IRunViewProvider, UserInfo } from '@memberjunction/core';
9
+ import { type RecordProcessorContext, type RecordRef, type RecordResult, type WriteBackResult } from '@memberjunction/record-set-processor-base';
9
10
  /** Provenance information about the executing process run, passed down to write-back and mapped via `$run.*`. */
10
11
  export interface RunProvenance {
11
12
  ProcessRunID?: string;
@@ -16,6 +17,56 @@ export interface RunProvenance {
16
17
  ExecutedAt?: string;
17
18
  FeatureValueCacheID?: string;
18
19
  }
20
+ /** One ownership question write-back asks a {@link HumanValueGuard} about a field that holds a value and is about to change. */
21
+ export interface HumanValueQuestion {
22
+ /** The mapped (config-named) field. */
23
+ FieldName: string;
24
+ /** The field's current value; never empty (an empty field holds no human value and is not asked about). `unknown`: the field is config-named, so its value has no static type. */
25
+ CurrentValue: unknown;
26
+ /** Read-only: the stored form of a value the pipeline produced (a lookup miss is null; nothing is created). `unknown` in and out: the mapped value comes from `ResolveMappingRef`, the stored form is the config-named field's. */
27
+ Resolve: (pipelineValue: unknown) => Promise<unknown>;
28
+ /** Whether a stored value equals a resolved pipeline value by the field's type ({@link OutputMappingWriter.OwnedValuesEqual}). `unknown`: both are values of the config-named field. */
29
+ Equals: (stored: unknown, resolved: unknown) => boolean;
30
+ /** The write-back unit's provider: the guard's reads and writes run on it, inside the unit's transaction. */
31
+ Provider: IMetadataProvider;
32
+ }
33
+ /** Decides whether a target field's current value was entered by a person, records it, and retires it. */
34
+ export interface HumanValueGuard {
35
+ /** True when the field's current value must be preserved. */
36
+ IsHumanOwned(question: HumanValueQuestion): Promise<boolean>;
37
+ /** Records the preserved human value (a `Source='Human'` Feature Value) on the unit's provider. `currentValue` is `unknown`: the config-named field's value. */
38
+ RecordPreserved(fieldName: string, currentValue: unknown, provider: IMetadataProvider): Promise<void>;
39
+ /** Retires the record's Human value of the field (an overwriting run made it the pipeline's); true when one existed. */
40
+ RetireHumanValue(fieldName: string, provider: IMetadataProvider): Promise<boolean>;
41
+ }
42
+ /** The targets a record's result withheld (outputs below their confidence floor): fields to clear, child mappings to skip. */
43
+ export interface WithheldWriteBackTargets {
44
+ /** Fields of the processed record mapped to null, through the human-value guard (names compare case-insensitively). */
45
+ Fields: string[];
46
+ /** Child entities whose mappings to skip (names compare case-insensitively). */
47
+ ChildEntities: string[];
48
+ }
49
+ /** A processor whose results can withhold some of their write-back targets (InferProcessor's confidence floors). */
50
+ export interface WithheldTargetSource {
51
+ /** The targets one successful result withholds; undefined when it withholds none. */
52
+ WithheldWriteBackTargets(result: RecordResult): WithheldWriteBackTargets | undefined;
53
+ }
54
+ /** Membership checks on {@link WithheldWriteBackTargets}. */
55
+ export declare class WithheldTargets {
56
+ /** Whether `field` is withheld (case-insensitive); false without withheld targets. */
57
+ static HasField(withheld: WithheldWriteBackTargets | undefined, field: string): boolean;
58
+ /** Whether the entity's column `field` does not allow null (names compare case-insensitively); false for an undeclared field. */
59
+ static ColumnRequiresValue(entity: EntityInfo, field: string): boolean;
60
+ /** Whether the child entity `entity` is withheld (case-insensitive); false without withheld targets. */
61
+ static HasChildEntity(withheld: WithheldWriteBackTargets | undefined, entity: string): boolean;
62
+ /** Whether a name list holds `name`, trimmed and case-insensitively, as metadata names compare. */
63
+ private static includes;
64
+ }
65
+ /** A processor that can say which of its target values a person entered (InferProcessor). */
66
+ export interface HumanValueGuardSource {
67
+ /** The guard for one record, or undefined when the run cannot tell (no pipeline, entity or spec). */
68
+ CreateHumanValueGuard(record: RecordRef, context: RecordProcessorContext): HumanValueGuard | undefined;
69
+ }
19
70
  /** Foreign-key lookup configuration for resolving a name or match field to a foreign-key ID. */
20
71
  export interface FieldLookupConfig {
21
72
  /** Target related entity name or ID to look up against. Derived from field metadata if omitted. */
@@ -33,8 +84,21 @@ export interface ChildRecordMapping {
33
84
  parentField: string;
34
85
  /** Map of `ChildFieldName -> resultRef`. */
35
86
  map: Record<string, string>;
36
- /** Optional ref resolving to an array for fan-out (one child created per array element). */
87
+ /** Optional ref resolving to an array for fan-out (one child row per array element). */
37
88
  fanOutRef?: string;
89
+ /** Reconcile this mapping's rows on their key instead of always inserting. */
90
+ reconcile?: ChildReconcileConfig;
91
+ }
92
+ /** How a child mapping's rows are reconciled with existing rows under the same parent (idempotent re-runs). */
93
+ export interface ChildReconcileConfig {
94
+ /** Child fields identifying a row within its parent, e.g. ["JobFunctionID"]. */
95
+ keyFields: string[];
96
+ /** Field naming who wrote a row, e.g. "Source". A row whose value differs from derivedSourceValue is human-owned. Without it every row counts as pipeline-written. */
97
+ sourceField?: string;
98
+ /** The sourceField value of pipeline-written rows, e.g. "Derived". */
99
+ derivedSourceValue?: string;
100
+ /** Delete pipeline-written rows the new result no longer contains (default true; needs `sourceField` and `derivedSourceValue`). */
101
+ deleteStale?: boolean;
38
102
  }
39
103
  /** Tag output mapping configuration for taxonomy linking. */
40
104
  export interface TagOutputMapping {
@@ -57,49 +121,291 @@ export interface OutputMappingConfig {
57
121
  fields?: Record<string, string>;
58
122
  /** Optional foreign-key lookup configurations per target field name. */
59
123
  fieldLookups?: Record<string, FieldLookupConfig>;
60
- /** Optional single child record to create from the result (kept for backward compatibility). */
124
+ /** Optional single child record to write from the result (kept for backward compatibility). */
61
125
  childRecord?: ChildRecordMapping;
62
- /** Optional child records to create from the result, supporting fan-out over arrays. */
126
+ /** Optional child records to write from the result, supporting fan-out over arrays and reconcile on a key. */
63
127
  childRecords?: ChildRecordMapping[];
64
128
  /** Optional tags to link or create via the MJ Tagging system. */
65
129
  tags?: TagOutputMapping[];
66
130
  }
67
- /** Preview outcome for a single resolved tag. */
68
- export interface TagWriteBackPreview {
69
- tagText: string;
70
- resolvedTagID?: string;
71
- resolvedTagName?: string;
72
- matched: boolean;
73
- created: boolean;
74
- rootTagID: string;
75
- depth?: number;
76
- error?: string;
77
- }
78
- /** Outcome of {@link applyOutputMapping}. */
79
- export interface WriteBackResult {
80
- /** True if the processed record's fields were actually updated (always false on a dry-run). */
81
- updatedRecord: boolean;
82
- /** ID of the created child record, when a single child mapping was applied (absent on a dry-run). */
83
- createdChildID?: string;
84
- /** IDs of created child records when childRecords (or fan-out) was applied (absent on a dry-run). */
85
- createdChildIDs?: string[];
86
- /** IDs of created tagged item records (absent on a dry-run). */
87
- createdTaggedItemIDs?: string[];
88
- /** True when this was a dry-run: values were computed (and field names validated) but NOTHING was saved. */
89
- dryRun?: boolean;
90
- /** On a dry-run, the resolved field values that WOULD be written to the processed record — the write-back preview. */
91
- previewFields?: Record<string, unknown>;
92
- /** On a dry-run with a single child mapping, the resolved child values that WOULD be created. */
93
- previewChild?: Record<string, unknown>;
94
- /** On a dry-run with childRecords (or fan-out), the array of resolved child records that WOULD be created. */
95
- previewChildren?: Array<Record<string, unknown>>;
96
- /** On a dry-run with tag mappings, the resolved tag previews. */
97
- previewTags?: TagWriteBackPreview[];
131
+ /** One resolved child row to write, and the mapping it came from. */
132
+ export interface ChildToWrite {
133
+ /** The child entity name. */
134
+ Entity: string;
135
+ /** Field values, the parent foreign key included. */
136
+ Data: Record<string, unknown>;
137
+ /** Whether the row came from the single `childRecord` mapping (reported as `createdChildID`). */
138
+ IsLegacySingle: boolean;
139
+ /** The mapping that produced the row. */
140
+ Config: ChildRecordMapping;
141
+ }
142
+ /** One child mapping's answer: the rows the result proposes for it (empty for an explicit "none"). */
143
+ export interface ChildMappingAnswer {
144
+ /** The mapping. */
145
+ Config: ChildRecordMapping;
146
+ /** The rows proposed for it, in result order; may be empty. */
147
+ Rows: ChildToWrite[];
148
+ }
149
+ /** What an {@link OutputMappingWriter} writes for. */
150
+ export interface OutputMappingWriterOptions {
151
+ /** The processed record. */
152
+ Record: RecordRef;
153
+ /** The write-back unit's provider (`MetadataProviderCapabilities.RunIsolated`): every read, save and the transaction run on it. */
154
+ Provider: IMetadataProvider;
155
+ /** The caller's provider: foreign-key lookups (and a lookup row created on a miss) run on it, outside the unit. */
156
+ LookupProvider: IMetadataProvider;
157
+ /** The user every read and write runs as. */
158
+ ContextUser: UserInfo;
159
+ /** The result being built; the writer fills its write fields. */
160
+ Result: WriteBackResult;
161
+ /** Overwrite values a person entered. */
162
+ OverwriteHumanValues: boolean;
163
+ /** Decides which current values a person entered; absent = no guard. */
164
+ HumanGuard?: HumanValueGuard;
165
+ /** The mapping's foreign-key lookup settings per field. */
166
+ FieldLookups?: Record<string, FieldLookupConfig>;
167
+ /** Positive lookup hits shared by every record of the run ({@link CanCacheLookups}). */
168
+ LookupCache: Map<string, string | number>;
169
+ /** Compute-only: an `onLookupMiss: 'create'` miss is previewed, not created. */
170
+ DryRun: boolean;
171
+ /** Withheld targets: the guard always decides a withheld field (without one it is kept), and its Human value is never retired. */
172
+ Withheld?: WithheldWriteBackTargets;
173
+ }
174
+ /** A value the real write stores in a foreign-key field, so it must exist as a row of the related entity. */
175
+ interface ForeignKeyRef {
176
+ /** The entity being written (the processed record's, or a child's). */
177
+ Entity: string;
178
+ /** The foreign-key field. */
179
+ Field: string;
180
+ /** The value written to it, as the write sends it. */
181
+ Value: string | number;
182
+ }
183
+ /** The related column a database foreign-key constraint checks, and the written values it must find there. */
184
+ interface ForeignKeyTarget {
185
+ /** The related entity. */
186
+ Related: EntityInfo;
187
+ /** The related column the constraint references (`RelatedEntityFieldName`, else the related primary key). */
188
+ Column: string;
189
+ /** The values written to fields that reference that column. */
190
+ Refs: ForeignKeyRef[];
191
+ }
192
+ /** One child row's values the real write stores: every value of an inserted row, the differing ones of an updated row. */
193
+ export interface PlannedChildWrite {
194
+ /** The proposal the row comes from. */
195
+ Item: ChildToWrite;
196
+ /** The values written. */
197
+ Values: Record<string, unknown>;
198
+ }
199
+ /** What the write does with an existing child row a proposal matches ({@link OutputMappingWriter.RowDecision}). */
200
+ type ChildRowDecision = {
201
+ Kind: 'human';
202
+ } | {
203
+ Kind: 'unchanged';
204
+ } | {
205
+ Kind: 'update';
206
+ Changes: Array<[string, unknown]>;
207
+ };
208
+ /** Writes one record's resolved output mapping: child rows (inserted, or reconciled on their key), then the record's own fields. */
209
+ export declare class OutputMappingWriter {
210
+ protected readonly Options: OutputMappingWriterOptions;
211
+ constructor(Options: OutputMappingWriterOptions);
212
+ /** Whether the metadata provider can also run views (narrows the type without a cast). */
213
+ static IsRunViewProvider(p: IMetadataProvider): p is IMetadataProvider & IRunViewProvider;
214
+ /**
215
+ * Normalises one part of a reconcile key as a case-insensitive key column compares it: null is '', a
216
+ * uniqueidentifier is `NormalizeUUID`d, anything else is lower-cased with trailing spaces removed.
217
+ * @param field - the key field's metadata, when the entity declares it
218
+ * @param v - a mapped value or an entity field value; `unknown` because config-named fields carry no compile-time type
219
+ */
220
+ static NormalizeKeyPart(field: EntityFieldInfo | undefined, v: unknown): string;
221
+ /**
222
+ * Whether a stored field value already equals a proposed one, by the field's type: UUIDs case-insensitively, dates
223
+ * by instant, decimals at the column's scale, numbers numerically, booleans by truth, anything else as exact text.
224
+ * @param stored - the record's current value (`BaseEntity.Get`)
225
+ * @param proposed - the mapped value; both `unknown` for the reason given on {@link NormalizeKeyPart}
226
+ */
227
+ static ValuesEqual(field: EntityFieldInfo | undefined, stored: unknown, proposed: unknown): boolean;
228
+ /** Dates compare by instant; a value that is not a date compares as exact text. */
229
+ protected static DatesEqual(stored: unknown, proposed: unknown): boolean;
230
+ /** Numbers compare numerically, rounded to the column's scale for scaled decimal types. */
231
+ protected static NumbersEqual(field: EntityFieldInfo, stored: unknown, proposed: unknown): boolean;
232
+ /** Rounds half away from zero to `scale` digits, as SQL Server stores it (the epsilon corrects binary halves). */
233
+ protected static RoundToScale(x: number, scale: number): number;
234
+ /** A bit value's truth: true, 1, '1' and 'true' (any case) are true. */
235
+ protected static TruthOf(v: unknown): boolean;
236
+ /** Writes every answered child mapping: reconciled mappings on their key, the others as inserts. */
237
+ WriteChildren(answers: ChildMappingAnswer[]): Promise<void>;
238
+ /**
239
+ * Saves the record's mapped fields that differ from its current values and hold no value a person entered. A run
240
+ * that overwrites human values then retires the Human value of every mapped field.
241
+ * @param entity - the processed record's entity
242
+ * @param fields - the resolved field values (foreign keys already resolved)
243
+ */
244
+ WriteRecordFields(entity: EntityInfo, fields: Record<string, unknown>): Promise<void>;
245
+ /** The processed record, loaded on the writer's provider; null when it does not exist. */
246
+ protected LoadRecord(entity: EntityInfo): Promise<BaseEntity | null>;
247
+ /** On a run that overwrites human values, retires each mapped field's Human value (sequentially, in the unit's transaction). */
248
+ protected RetireHumanValues(fieldNames: string[]): Promise<void>;
249
+ /**
250
+ * The mapped fields whose value differs from the record's ({@link ValuesEqual}) and holds no value a person entered,
251
+ * for the real write and the dry-run preview ({@link PreviewFields}).
252
+ * @param recordPreserved - record each preserved human value (the real write); false for the preview
253
+ */
254
+ protected FieldChanges(entity: EntityInfo, obj: BaseEntity, fields: Record<string, unknown>, recordPreserved: boolean): Promise<Array<[string, unknown]>>;
255
+ /**
256
+ * True when the field holds a value a person entered and the run does not overwrite it (see
257
+ * {@link OutputMappingWriterOptions.Withheld}); with `recordPreserved` the value is recorded and reported. An empty
258
+ * field is never asked about.
259
+ */
260
+ protected PreservesHumanValue(entity: EntityInfo, field: string, current: unknown, recordPreserved: boolean): Promise<boolean>;
261
+ /**
262
+ * Whether a stored value equals a value the pipeline wrote, for the ownership question: typed fields by
263
+ * {@link ValuesEqual}, text (and undeclared fields) with case and trailing spaces ignored, as the collation compares.
264
+ * @param stored - the field's value; `unknown` for the reason given on {@link NormalizeKeyPart}
265
+ * @param resolved - the pipeline's resolved value; likewise `unknown`
266
+ */
267
+ static OwnedValuesEqual(field: EntityFieldInfo | undefined, stored: unknown, resolved: unknown): boolean;
268
+ /**
269
+ * The stored form of one mapped field value: a match string becomes the related row's key by the mapping's lookup
270
+ * rules; a UUID, or a value of a field that is not a foreign key, is returned unchanged.
271
+ * @param val - the mapped value; `unknown` because it comes from `ResolveMappingRef`
272
+ */
273
+ ResolveFieldValue(entity: EntityInfo, field: string, val: unknown): Promise<unknown>;
274
+ /**
275
+ * The stored form of a value the pipeline wrote earlier, read-only: any lookup miss is null; nothing is created.
276
+ * @param val - an earlier pipeline answer (a stored Feature Value); `unknown` as on {@link ResolveFieldValue}
277
+ */
278
+ ResolveStoredForm(entity: EntityInfo, field: string, val: unknown): Promise<unknown>;
279
+ /**
280
+ * Shared body of {@link ResolveFieldValue} and {@link ResolveStoredForm} (`readOnly`: every miss is null).
281
+ * @param val - a mapped value or an earlier pipeline answer; `unknown` because config-named refs carry no type
282
+ */
283
+ protected ResolveKey(entity: EntityInfo, field: string, val: unknown, readOnly: boolean): Promise<unknown>;
284
+ /** Whether the run-wide lookup cache may be used: not inside a caller's transaction, whose rollback would undo a cached row. */
285
+ protected get CanCacheLookups(): boolean;
286
+ /** The match value inside a mapped value (an array's first element, an object's `Name`); null when not a string or number. */
287
+ protected static MatchValueOf(val: unknown): string | number | null;
288
+ /** A foreign key that cannot be resolved: null, or an error under `onLookupMiss: 'fail'`. */
289
+ protected UnresolvedKey(field: string, onMiss: NonNullable<FieldLookupConfig['onLookupMiss']>, reason: string): null;
290
+ /** The entity a foreign-key field points at: the lookup's `relatedEntity`, else the field's metadata. */
291
+ protected RelatedEntityNameOf(fieldInfo: EntityFieldInfo | undefined, lookup: FieldLookupConfig | undefined): string | undefined;
292
+ /** The entity a foreign-key field points at: the lookup's `relatedEntity`, else the field's metadata; undefined for a non-key. */
293
+ static RelatedEntityNameFor(provider: IMetadataProvider, fieldInfo: EntityFieldInfo | undefined, lookup: FieldLookupConfig | undefined): string | undefined;
294
+ /** The key column of a lookup's related entity; throws when it is not in metadata or has no primary key. */
295
+ protected PrimaryKeyNameOf(related: string): string;
296
+ /**
297
+ * Looks up the related row whose match field equals `text` and returns its key (a hit is cached for the run); a miss
298
+ * follows `onMiss`: null (never cached), an error, or a new row.
299
+ */
300
+ protected LookupRelatedKey(field: string, related: string, matchField: string, text: string, onMiss: NonNullable<FieldLookupConfig['onLookupMiss']>): Promise<string | number | null>;
301
+ /** Caches a lookup's key for the run, when {@link CanCacheLookups} allows. */
302
+ protected CacheLookup(cacheKey: string, key: string | number): void;
303
+ /** Creates the related row a `create` miss asks for (match field only) and caches its key; a dry run returns a preview key. */
304
+ protected CreateLookupRow(related: string, matchField: string, text: string, keyName: string, cacheKey: string): Promise<string | number>;
305
+ /** A config-named field's metadata (names compare case-insensitively), or undefined when the entity does not declare it. */
306
+ protected FieldInfoOf(entity: EntityInfo | undefined, field: string): EntityFieldInfo | undefined;
307
+ /** A config-named field's metadata, names compared case-insensitively; undefined when the entity does not declare it. */
308
+ static FieldInfoFor(entity: EntityInfo | undefined, field: string): EntityFieldInfo | undefined;
309
+ /** Every child mapping of an output mapping, in write order: the single `childRecord` (flagged) first, then `childRecords`. */
310
+ static ChildMappingsOf(outputMapping: OutputMappingConfig): Array<{
311
+ Config: ChildRecordMapping;
312
+ IsLegacySingle: boolean;
313
+ }>;
314
+ /**
315
+ * A child mapping's parent field, checked to be a plain identifier (it is written into a view filter).
316
+ * @throws Error when the parent field is not a plain identifier
317
+ */
318
+ static ParentFieldOf(config: ChildRecordMapping): string;
319
+ /** The entity a mapping's tags are linked on (its `taggedEntityName`'s, else the record's); undefined when unknown. */
320
+ static TaggedEntityIDOf(provider: IMetadataProvider, mapping: TagOutputMapping, record: RecordRef): string | undefined;
321
+ /** Inserts one child row; throws with the save's CompleteMessage when the save fails. */
322
+ protected InsertChild(item: ChildToWrite): Promise<string>;
323
+ /** Reports the inserted rows on the result (`createdChildID` = the single legacy mapping's row). */
324
+ protected RecordCreated(items: ChildToWrite[], created: Map<ChildToWrite, string>): void;
325
+ /**
326
+ * Reconciles one mapping's proposed rows with the parent's existing rows: inserts new keys, updates or keeps existing
327
+ * ones (human rows only when overwriting), then deletes stale pipeline rows.
328
+ */
329
+ protected ReconcileChildren(config: ChildRecordMapping, rc: ChildReconcileConfig, items: ChildToWrite[], created: Map<ChildToWrite, string>): Promise<void>;
330
+ /** The parent's existing rows of a mapping, and each keyed proposal paired with the existing row of its key. */
331
+ protected MatchExisting(config: ChildRecordMapping, rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, keyed: Map<string, ChildToWrite>): Promise<{
332
+ Existing: BaseEntity[];
333
+ Matches: Array<{
334
+ Item: ChildToWrite;
335
+ Row: BaseEntity | undefined;
336
+ }>;
337
+ }>;
338
+ /** Refuses a reconcile config that cannot work: no key fields, a key field the map does not set, or `deleteStale` without a source. */
339
+ protected ValidateReconcileConfig(config: ChildRecordMapping, rc: ChildReconcileConfig): void;
340
+ /** The proposals keyed by their reconcile key; throws when the answer proposes one key twice (it would hit the unique key). */
341
+ protected KeyProposals(config: ChildRecordMapping, rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, items: ChildToWrite[]): Map<string, ChildToWrite>;
342
+ /** The proposals keyed by their reconcile key (the first of a key kept), and each key proposed more than once. */
343
+ protected KeyedProposals(rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, items: ChildToWrite[]): {
344
+ Keyed: Map<string, ChildToWrite>;
345
+ Repeated: string[];
346
+ };
347
+ /** The parent's existing rows of a child mapping, read fresh (they are updated or deleted in this transaction). */
348
+ protected LoadExistingChildren(config: ChildRecordMapping): Promise<BaseEntity[]>;
349
+ /** A row's key within its parent: its key fields, normalised and joined. */
350
+ protected KeyOfRow(rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, row: BaseEntity): string;
351
+ /** A proposed row's key within its parent. */
352
+ protected KeyOfData(rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, data: Record<string, unknown>): string;
353
+ /** Whether a person owns the row: its source field holds anything but the pipeline's value (exact, as stored). */
354
+ protected IsHumanRow(rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, row: BaseEntity): boolean;
355
+ /**
356
+ * What the write does with an existing row a proposal matches: leaves a human row alone (unless overwriting),
357
+ * keeps an identical row, or updates the differing fields. Shared by the write and {@link PlanChildren}.
358
+ */
359
+ protected RowDecision(rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, row: BaseEntity, data: Record<string, unknown>): ChildRowDecision;
360
+ /** Applies a {@link RowDecision}: records a preserved human row or an unchanged row, or saves the differing fields. */
361
+ protected ReconcileRow(config: ChildRecordMapping, row: BaseEntity, decision: ChildRowDecision): Promise<void>;
362
+ /** The existing pipeline rows (never human rows) whose key the result no longer proposes; none with `deleteStale: false`. */
363
+ protected StaleRows(rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, existing: BaseEntity[], proposed: Set<string>): BaseEntity[];
364
+ /** Deletes the pipeline's rows the new result no longer proposes (sequentially, in the unit's transaction). */
365
+ protected DeleteStaleChildren(config: ChildRecordMapping, rc: ChildReconcileConfig, childEntity: EntityInfo | undefined, existing: BaseEntity[], proposed: Set<string>): Promise<void>;
366
+ /**
367
+ * The child values the real write stores ({@link PlanChildren}) and what it would fail on: a reconcile key proposed
368
+ * twice, or a stored value with no row in its related entity ({@link MissingForeignKeys}). Writes nothing.
369
+ */
370
+ PreviewChildren(answers: ChildMappingAnswer[]): Promise<{
371
+ Writes: PlannedChildWrite[];
372
+ Problems: string[];
373
+ }>;
374
+ /**
375
+ * The record's fields the real write changes ({@link FieldChanges}) and what it would fail on: a changed UUID value
376
+ * with no row in its related entity, or a record that does not exist. Writes nothing.
377
+ */
378
+ PreviewFields(entity: EntityInfo, fields: Record<string, unknown>): Promise<{
379
+ Changes: Record<string, unknown>;
380
+ Problems: string[];
381
+ }>;
382
+ /** Reconcile keys a mapping's answer proposes more than once: the real write refuses them (unique key). */
383
+ protected DuplicateKeyProblems(answers: ChildMappingAnswer[]): string[];
384
+ /**
385
+ * The child values the real write stores, by its own decisions: every row of a plain mapping; a reconciled
386
+ * proposal's values when no existing row has its key, else only the fields {@link RowDecision} updates.
387
+ */
388
+ protected PlanChildren(answers: ChildMappingAnswer[]): Promise<PlannedChildWrite[]>;
389
+ /** Every written child value of a constrained foreign-key field (the parent key excepted), grouped by related column. */
390
+ protected CollectForeignKeyRefs(writes: PlannedChildWrite[], problems: string[]): Map<string, ForeignKeyTarget>;
391
+ /** Whether the database checks the field with a foreign-key constraint (a related entity in metadata, not a soft key). */
392
+ protected IsConstrainedForeignKey(fieldInfo: EntityFieldInfo | undefined): fieldInfo is EntityFieldInfo;
393
+ /** Adds a written value to the group of the related column its constraint references, or reports a missing one. */
394
+ protected AddForeignKeyRef(targets: Map<string, ForeignKeyTarget>, problems: string[], fieldInfo: EntityFieldInfo, ref: ForeignKeyRef): void;
395
+ /** {@link MissingForeignKeys} of every related column, in parallel. */
396
+ protected MissingForeignKeyProblems(targets: Map<string, ForeignKeyTarget>): Promise<string[]>;
397
+ /**
398
+ * The written values with no row in their related entity: one `RunView` of the related column per entity. A value
399
+ * that is not a UUID cannot be a key of a uniqueidentifier column; a related column of another type is not checked.
400
+ */
401
+ protected MissingForeignKeys(target: ForeignKeyTarget): Promise<string[]>;
98
402
  }
99
403
  /**
100
404
  * Applies an {@link OutputMappingConfig} against a work result.
101
- * Supports updating fields (both single-key and composite-key entities), creating child records
102
- * (with array fan-out), and linking/creating tags via TagEngine.
405
+ * Supports updating fields (both single-key and composite-key entities), writing child records
406
+ * (with array fan-out; a `reconcile` mapping is matched to existing rows on its key), and linking/creating
407
+ * tags via TagEngine. `unitWork`, the child rows and the fields are written in one entity transaction on its
408
+ * own provider instance; tags after it. A field a person entered is kept unless `overwriteHumanValues` is set.
103
409
  *
104
410
  * Values resolve from `$` (result), `record` (parent row) and `$run` (provenance).
105
411
  */
@@ -108,13 +414,22 @@ export declare function ApplyOutputMapping(opts: {
108
414
  result: unknown;
109
415
  record: RecordRef;
110
416
  contextUser: UserInfo;
111
- provider?: IMetadataProvider;
417
+ /** The caller's provider: lookups and tags run on it, the write unit on an instance minted from it. */
418
+ provider: IMetadataProvider;
112
419
  /** When true, compute + validate the mapping but do NOT save anything (returns a preview instead). */
113
420
  dryRun?: boolean;
114
421
  /** Optional run provenance information mapped via `$run.*`. */
115
422
  run?: RunProvenance;
116
423
  /** Optional memoization cache mapping `${relatedEntityName}|${matchField}|${matchValue}` -> resolved PK. Caches positive hits only to prevent downgrading onLookupMiss policies. */
117
424
  lookupCache?: Map<string, string | number>;
425
+ /** Overwrite values a person entered (default false), and retire their Human values. */
426
+ overwriteHumanValues?: boolean;
427
+ /** Decides which of the record's current field values a person entered; absent = every value may be overwritten. */
428
+ humanGuard?: HumanValueGuard;
429
+ /** Work that commits or rolls back with this write-back, run first in its unit (a pipeline's Feature Values); not on a dry run. */
430
+ unitWork?: (unitProvider: IMetadataProvider) => Promise<void>;
431
+ /** Targets to leave as they are: the answer withheld them (see {@link WithheldWriteBackTargets}). */
432
+ withheld?: WithheldWriteBackTargets;
118
433
  }): Promise<WriteBackResult>;
119
434
  /** @deprecated Use {@link ApplyOutputMapping}. */
120
435
  export declare function applyOutputMapping(opts: {
@@ -122,8 +437,9 @@ export declare function applyOutputMapping(opts: {
122
437
  result: unknown;
123
438
  record: RecordRef;
124
439
  contextUser: UserInfo;
125
- provider?: IMetadataProvider;
440
+ provider: IMetadataProvider;
126
441
  /** When true, compute + validate the mapping but do NOT save anything (returns a preview instead). */
127
442
  dryRun?: boolean;
128
443
  }): Promise<WriteBackResult>;
444
+ export {};
129
445
  //# sourceMappingURL=writeBack.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writeBack.d.ts","sourceRoot":"","sources":["../src/writeBack.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA4B,iBAAiB,EAAgC,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAErI,OAAO,EAAE,SAAS,EAAE,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