@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.
- package/README.md +36 -1
- package/dist/RecordProcessExecutor.d.ts +35 -17
- package/dist/RecordProcessExecutor.d.ts.map +1 -1
- package/dist/RecordProcessExecutor.js +79 -63
- package/dist/RecordProcessExecutor.js.map +1 -1
- package/dist/RecordSetProcessor.d.ts +15 -0
- package/dist/RecordSetProcessor.d.ts.map +1 -1
- package/dist/RecordSetProcessor.js +161 -81
- package/dist/RecordSetProcessor.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/operations/RecordProcessControlOperations.d.ts.map +1 -1
- package/dist/operations/RecordProcessControlOperations.js +9 -7
- package/dist/operations/RecordProcessControlOperations.js.map +1 -1
- package/dist/processors/ActionRecordProcessor.d.ts.map +1 -1
- package/dist/processors/ActionRecordProcessor.js +6 -2
- package/dist/processors/ActionRecordProcessor.js.map +1 -1
- package/dist/processors/AgentRecordProcessor.d.ts.map +1 -1
- package/dist/processors/AgentRecordProcessor.js +5 -2
- package/dist/processors/AgentRecordProcessor.js.map +1 -1
- package/dist/processors/FieldRulesProcessor.d.ts +22 -7
- package/dist/processors/FieldRulesProcessor.d.ts.map +1 -1
- package/dist/processors/FieldRulesProcessor.js +24 -13
- package/dist/processors/FieldRulesProcessor.js.map +1 -1
- package/dist/processors/WriteBackProcessor.d.ts +62 -2
- package/dist/processors/WriteBackProcessor.d.ts.map +1 -1
- package/dist/processors/WriteBackProcessor.js +134 -58
- package/dist/processors/WriteBackProcessor.js.map +1 -1
- package/dist/trackers/GenericProcessRunTracker.d.ts.map +1 -1
- package/dist/trackers/GenericProcessRunTracker.js +22 -3
- package/dist/trackers/GenericProcessRunTracker.js.map +1 -1
- package/dist/watermark/WatermarkService.d.ts +62 -24
- package/dist/watermark/WatermarkService.d.ts.map +1 -1
- package/dist/watermark/WatermarkService.js +123 -70
- package/dist/watermark/WatermarkService.js.map +1 -1
- package/dist/writeBack.d.ts +358 -42
- package/dist/writeBack.d.ts.map +1 -1
- package/dist/writeBack.js +848 -208
- package/dist/writeBack.js.map +1 -1
- package/package.json +16 -17
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.d.ts +0 -92
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.d.ts.map +0 -1
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.js +0 -26
- package/dist/feature-pipeline-drivers/BaseFeaturePipelineDriver.js.map +0 -1
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.d.ts +0 -79
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.d.ts.map +0 -1
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.js +0 -257
- package/dist/feature-pipeline-drivers/DecisionFeaturePipelineDriver.js.map +0 -1
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.d.ts +0 -23
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.d.ts.map +0 -1
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.js +0 -85
- package/dist/feature-pipeline-drivers/LLMFeaturePipelineDriver.js.map +0 -1
- package/dist/processors/FeaturePipelineEscalation.d.ts +0 -155
- package/dist/processors/FeaturePipelineEscalation.d.ts.map +0 -1
- package/dist/processors/FeaturePipelineEscalation.js +0 -208
- package/dist/processors/FeaturePipelineEscalation.js.map +0 -1
- package/dist/processors/InferProcessor.d.ts +0 -306
- package/dist/processors/InferProcessor.d.ts.map +0 -1
- package/dist/processors/InferProcessor.js +0 -1210
- package/dist/processors/InferProcessor.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,14 @@ pluggable seams defined in [`@memberjunction/record-set-processor-base`](../base
|
|
|
10
10
|
- **Batching** with a configurable batch size
|
|
11
11
|
- **Bounded concurrency** within a batch (`maxConcurrency`)
|
|
12
12
|
- **Rate limiting** (optional, token-bucket with a sliding window)
|
|
13
|
-
- **Error-rate circuit breaker** — auto-fails a run when the error rate exceeds a
|
|
13
|
+
- **Error-rate circuit breaker** — auto-fails a run when the error rate of the records it attempted exceeds a
|
|
14
|
+
threshold (records skipped on their watermark are left out)
|
|
15
|
+
- **Strict record-error runs** (`Processor.FailRunOnRecordError = true`) — the run ends `Failed`
|
|
16
|
+
when any record failed, and when the processor implements `BuildRunSummary` its `ResultSummary` (and `WouldRefuse` on a
|
|
17
|
+
dry run) is persisted on `MJ: Process Runs`
|
|
18
|
+
- **Skipping unchanged records** (`skipUnchanged`, by `Checksum` or `UpdatedAt`) — unless the run overwrites human
|
|
19
|
+
values. A real `Checksum` run that does not skip (e.g. a version backfill) still writes the watermark of each
|
|
20
|
+
succeeded record whose processor computes a basis hash (Infer), so the next skipping run skips it
|
|
14
21
|
- **Budget gate** — an `onAfterBatch` hook to pause when a cost/item budget is exhausted
|
|
15
22
|
- **Progress events** after each batch
|
|
16
23
|
- **Pause / cancel handshake** — the tracker re-checks its row's cancellation flag at each checkpoint
|
|
@@ -43,6 +50,33 @@ By default the engine persists to `MJ: Process Runs` / `MJ: Process Run Details`
|
|
|
43
50
|
`GenericProcessRunTracker`. Pass `tracker: new NoOpTracker()` for fire-and-forget single-record work,
|
|
44
51
|
or your own `IProcessRunTracker` to persist into domain-specific tables.
|
|
45
52
|
|
|
53
|
+
## Output-mapping write-back
|
|
54
|
+
|
|
55
|
+
`ApplyOutputMapping` writes a result's `fields` onto the processed record and its child rows through an
|
|
56
|
+
`OutputMappingWriter`, in one entity transaction, children first, on its own provider instance
|
|
57
|
+
(`MetadataProviderCapabilities.RunIsolated`), or as a savepoint of the caller's transaction when one is open. A field is
|
|
58
|
+
saved only when its value differs by the field's type (`OutputMappingWriter.ValuesEqual`). A lookup row created by
|
|
59
|
+
`onLookupMiss: 'create'` and tag links are written outside the transaction.
|
|
60
|
+
|
|
61
|
+
A child mapping with `reconcile` is matched to the parent's existing rows on its key, so a re-run is idempotent:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{ "entity": "MJ_BizApps_Common: Person Job Functions", "parentField": "PersonID", "fanOutRef": "$.Functions",
|
|
65
|
+
"map": { "JobFunctionID": "$.JobFunctionID", "Sequence": "$.Sequence", "Source": "static:Derived" },
|
|
66
|
+
"reconcile": { "keyFields": ["JobFunctionID"], "sourceField": "Source", "derivedSourceValue": "Derived", "deleteStale": true } }
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Existing row with the proposed key | Outcome (`WriteBackResult` list) |
|
|
70
|
+
|---|---|
|
|
71
|
+
| none | inserted (`createdChildIDs`) |
|
|
72
|
+
| pipeline row (`sourceField` = `derivedSourceValue`), same values | left as is (`unchangedChildIDs`) |
|
|
73
|
+
| pipeline row, different values | the differing fields saved (`updatedChildIDs`) |
|
|
74
|
+
| human row (any other `sourceField` value) | left as is (`preservedHumanChildIDs`), unless the call sets `overwriteHumanValues` |
|
|
75
|
+
| pipeline row whose key the result no longer proposes | deleted when `deleteStale` (default true) (`deletedChildIDs`); human rows are never deleted |
|
|
76
|
+
|
|
77
|
+
An explicit empty answer (`[]`) deletes every pipeline row of the mapping; a missing or null answer changes nothing.
|
|
78
|
+
Keys match as a case-insensitive unique index would (`OutputMappingWriter.NormalizeKeyPart`).
|
|
79
|
+
|
|
46
80
|
## Exports
|
|
47
81
|
|
|
48
82
|
| Export | Purpose |
|
|
@@ -51,6 +85,7 @@ or your own `IProcessRunTracker` to persist into domain-specific tables.
|
|
|
51
85
|
| `GenericProcessRunTracker` | default tracker writing the generic Process Run tables |
|
|
52
86
|
| `NoOpTracker` | a tracker that persists nothing |
|
|
53
87
|
| `FunctionRecordProcessor` | a processor backed by a function |
|
|
88
|
+
| `ApplyOutputMapping` / `OutputMappingWriter` | the output-mapping write-back (see above) |
|
|
54
89
|
| `RateLimiter` | the token-bucket limiter used when `rateLimit` is configured |
|
|
55
90
|
|
|
56
91
|
Source adapters, the seam interfaces, and all shared types are re-exported from
|
|
@@ -6,34 +6,46 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
8
8
|
import { MJRecordProcessEntity } from '@memberjunction/core-entities';
|
|
9
|
-
import { IRecordProcessor, IRecordSetSource, ProcessRunResult, ProgressInfo, TriggeredByValue } from '@memberjunction/record-set-processor-base';
|
|
9
|
+
import { IRecordProcessor, IRecordSetSource, IProcessRunTracker, ProcessRunResult, ProgressInfo, TriggeredByValue } from '@memberjunction/record-set-processor-base';
|
|
10
10
|
import { type RecordProcessScopeOverride } from '@memberjunction/core-entities';
|
|
11
11
|
/** Options for executing a Record Process. */
|
|
12
12
|
export interface RunRecordProcessOptions {
|
|
13
13
|
/** The acting user. */
|
|
14
|
-
|
|
14
|
+
ContextUser: UserInfo;
|
|
15
15
|
/** The owning provider (defaults to the active provider). */
|
|
16
|
-
|
|
16
|
+
Provider?: IMetadataProvider;
|
|
17
17
|
/** What triggered the run (default `OnDemand`). */
|
|
18
|
-
|
|
18
|
+
TriggeredBy?: TriggeredByValue;
|
|
19
19
|
/** Process a single record (the on-change / on-demand single-record case) instead of the scope. */
|
|
20
|
-
|
|
20
|
+
SingleRecordID?: string;
|
|
21
21
|
/**
|
|
22
22
|
* Runtime scope override (selected rows / a view / a list / a filter), used instead of the stored
|
|
23
23
|
* Scope. This is how a grid/list UI runs a process against exactly what the user is looking at.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
Scope?: RecordProcessScopeOverride;
|
|
26
26
|
/**
|
|
27
|
-
* Compute-only:
|
|
28
|
-
*
|
|
27
|
+
* Compute-only: produce each record's result and the write-back preview WITHOUT writing (see
|
|
28
|
+
* {@link RecordProcessExecutor.BuildProcessor} for what each work type does). Powers the preview step of the
|
|
29
|
+
* bulk-update UX.
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
DryRun?: boolean;
|
|
32
|
+
/** Dry runs preview at most this many records when no scope or single record is given and the processor declares a default sample size. */
|
|
33
|
+
DryRunSampleSize?: number;
|
|
31
34
|
/** FK to the owning `ScheduledJobRun` when launched by the scheduler (links the Process Run back). */
|
|
32
|
-
|
|
35
|
+
ScheduledJobRunID?: string;
|
|
33
36
|
/** Optional timestamp of the previous run, used for 'UpdatedAt' watermark strategy. */
|
|
34
|
-
|
|
37
|
+
LastRunAt?: Date | null;
|
|
35
38
|
/** Progress callback. */
|
|
36
|
-
|
|
39
|
+
OnProgress?: (progress: ProgressInfo) => void;
|
|
40
|
+
/** The tracker to record this run with. Defaults to the work type's registered tracker, else `GenericProcessRunTracker`. */
|
|
41
|
+
Tracker?: IProcessRunTracker;
|
|
42
|
+
/** Overwrite values a person entered, and retire their Human values (default false). */
|
|
43
|
+
OverwriteHumanValues?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the run skips records its watermark says are unchanged (default: the Record Process's `SkipUnchanged`).
|
|
46
|
+
* A version backfill passes false; it still refreshes the watermarks of the records it processes.
|
|
47
|
+
*/
|
|
48
|
+
SkipUnchanged?: boolean;
|
|
37
49
|
}
|
|
38
50
|
/** Builds and runs a RecordSetProcessor pass from a Record Process definition. */
|
|
39
51
|
export declare class RecordProcessExecutor {
|
|
@@ -41,6 +53,13 @@ export declare class RecordProcessExecutor {
|
|
|
41
53
|
RunByID(recordProcessID: string, options: RunRecordProcessOptions): Promise<ProcessRunResult>;
|
|
42
54
|
/** Runs an already-loaded Record Process. */
|
|
43
55
|
Run(rp: MJRecordProcessEntity, options: RunRecordProcessOptions): Promise<ProcessRunResult>;
|
|
56
|
+
/** The tracker a work type's processor is paired with, if it registered one. */
|
|
57
|
+
private resolveTracker;
|
|
58
|
+
/**
|
|
59
|
+
* The record cap of a dry run over the stored scope (`DryRunSampleSize`, else `processor?.DefaultDryRunSampleSize`);
|
|
60
|
+
* undefined for a real run, a processor without a default sample size, or a caller-chosen scope or record.
|
|
61
|
+
*/
|
|
62
|
+
protected DryRunMaxRecords(_rp: MJRecordProcessEntity, options: RunRecordProcessOptions, processor?: IRecordProcessor): number | undefined;
|
|
44
63
|
/** Builds the record-set source from a single-record override, a runtime scope override, or the process's stored Scope. */
|
|
45
64
|
BuildSource(rp: MJRecordProcessEntity, provider: IMetadataProvider, singleRecordID?: string, scope?: RecordProcessScopeOverride): IRecordSetSource;
|
|
46
65
|
/** @deprecated Use {@link BuildSource}. */
|
|
@@ -49,12 +68,11 @@ export declare class RecordProcessExecutor {
|
|
|
49
68
|
private buildSourceFromScope;
|
|
50
69
|
/**
|
|
51
70
|
* Builds the processor from the process's Work. `FieldRules` reads its rule set from `Configuration`
|
|
52
|
-
* and writes itself (honoring `dryRun`);
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* dry-run is side-effect-free, not just FieldRules.
|
|
71
|
+
* and writes itself (honoring `dryRun`); `Action` and `Agent` build their built-in processors; other work
|
|
72
|
+
* types (including `Infer` and `'ML Model'`) resolve through {@link RecordProcessorRegistry}, then wrap
|
|
73
|
+
* with output-mapping write-back when configured.
|
|
56
74
|
*/
|
|
57
|
-
BuildProcessor(rp: MJRecordProcessEntity, dryRun?: boolean, provider?: IMetadataProvider): IRecordProcessor;
|
|
75
|
+
BuildProcessor(rp: MJRecordProcessEntity, dryRun?: boolean, provider?: IMetadataProvider, tracker?: IProcessRunTracker): IRecordProcessor;
|
|
58
76
|
/** @deprecated Use {@link BuildProcessor}. */
|
|
59
77
|
buildProcessor(rp: MJRecordProcessEntity, dryRun?: boolean, provider?: IMetadataProvider): IRecordProcessor;
|
|
60
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordProcessExecutor.d.ts","sourceRoot":"","sources":["../src/RecordProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAA+B,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhG,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EA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
10
10
|
import { RecordSetProcessor } from './RecordSetProcessor.js';
|
|
11
11
|
import { ActionRecordProcessor } from './processors/ActionRecordProcessor.js';
|
|
12
12
|
import { AgentRecordProcessor } from './processors/AgentRecordProcessor.js';
|
|
13
|
-
import { InferProcessor } from './processors/InferProcessor.js';
|
|
14
13
|
import { FieldRulesProcessor } from './processors/FieldRulesProcessor.js';
|
|
15
14
|
import { WriteBackProcessor } from './processors/WriteBackProcessor.js';
|
|
16
15
|
/** Builds and runs a RecordSetProcessor pass from a Record Process definition. */
|
|
17
16
|
export class RecordProcessExecutor {
|
|
18
17
|
/** Loads the Record Process by ID and runs it. */
|
|
19
18
|
async RunByID(recordProcessID, options) {
|
|
20
|
-
const provider = options.
|
|
21
|
-
const rp = await provider.GetEntityObject('MJ: Record Processes', options.
|
|
19
|
+
const provider = options.Provider ?? Metadata.Provider;
|
|
20
|
+
const rp = await provider.GetEntityObject('MJ: Record Processes', options.ContextUser);
|
|
22
21
|
const loaded = await rp.Load(recordProcessID);
|
|
23
22
|
if (!loaded) {
|
|
24
23
|
throw new Error(`Record Process '${recordProcessID}' not found`);
|
|
@@ -27,9 +26,11 @@ export class RecordProcessExecutor {
|
|
|
27
26
|
}
|
|
28
27
|
/** Runs an already-loaded Record Process. */
|
|
29
28
|
async Run(rp, options) {
|
|
30
|
-
const provider = options.
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const provider = options.Provider ?? Metadata.Provider;
|
|
30
|
+
// `??`: false is a deliberate override of the Record Process's setting
|
|
31
|
+
const skipUnchanged = options.SkipUnchanged ?? rp.SkipUnchanged;
|
|
32
|
+
let lastRunAt = options.LastRunAt;
|
|
33
|
+
if (!lastRunAt && skipUnchanged && rp.WatermarkStrategy === 'UpdatedAt') {
|
|
33
34
|
try {
|
|
34
35
|
const rv = RunView.FromMetadataProvider(provider);
|
|
35
36
|
const lastRunRes = await rv.RunView({
|
|
@@ -37,7 +38,7 @@ export class RecordProcessExecutor {
|
|
|
37
38
|
ExtraFilter: `RecordProcessID = '${EscapeSQLString(rp.ID)}' AND Status = 'Completed'`,
|
|
38
39
|
OrderBy: 'StartedAt DESC',
|
|
39
40
|
MaxRows: 1,
|
|
40
|
-
}, options.
|
|
41
|
+
}, options.ContextUser);
|
|
41
42
|
if (lastRunRes.Success && lastRunRes.Results && lastRunRes.Results.length > 0) {
|
|
42
43
|
lastRunAt = lastRunRes.Results[0].StartedAt ?? null;
|
|
43
44
|
}
|
|
@@ -46,25 +47,56 @@ export class RecordProcessExecutor {
|
|
|
46
47
|
LogError(`RecordProcessExecutor: failed to query last run for RecordProcess '${rp.ID}': ${err instanceof Error ? err.message : String(err)}`);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
// Resolved here, not at each call site, so scheduled and on-change runs get the same tracker as manual ones.
|
|
51
|
+
const tracker = options.Tracker ?? this.resolveTracker(rp, options.DryRun, provider);
|
|
52
|
+
const processor = this.BuildProcessor(rp, options.DryRun, provider, tracker);
|
|
49
53
|
return RecordSetProcessor.Instance.Process({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
54
|
+
Source: this.BuildSource(rp, provider, options.SingleRecordID, options.Scope),
|
|
55
|
+
Processor: processor,
|
|
56
|
+
Tracker: tracker,
|
|
57
|
+
ContextUser: options.ContextUser,
|
|
58
|
+
Provider: provider,
|
|
59
|
+
DryRun: options.DryRun,
|
|
60
|
+
MaxRecords: this.DryRunMaxRecords(rp, options, processor),
|
|
61
|
+
RecordProcessID: rp.ID,
|
|
62
|
+
ScheduledJobRunID: options.ScheduledJobRunID,
|
|
63
|
+
EntityID: rp.EntityID,
|
|
64
|
+
TriggeredBy: options.TriggeredBy ?? 'OnDemand',
|
|
65
|
+
BatchSize: rp.BatchSize ?? undefined,
|
|
66
|
+
MaxConcurrency: rp.MaxConcurrency ?? undefined,
|
|
67
|
+
SkipUnchanged: skipUnchanged,
|
|
68
|
+
WatermarkStrategy: rp.WatermarkStrategy ?? 'Checksum',
|
|
69
|
+
LastRunAt: lastRunAt,
|
|
70
|
+
OnProgress: options.OnProgress,
|
|
71
|
+
OverwriteHumanValues: options.OverwriteHumanValues,
|
|
72
|
+
Configuration: { recordProcessName: rp.Name, workType: rp.WorkType, scopeType: rp.ScopeType },
|
|
66
73
|
});
|
|
67
74
|
}
|
|
75
|
+
/** The tracker a work type's processor is paired with, if it registered one. */
|
|
76
|
+
resolveTracker(rp, dryRun, provider) {
|
|
77
|
+
return RecordProcessorRegistry.Instance.ResolveTracker({
|
|
78
|
+
WorkType: rp.WorkType,
|
|
79
|
+
Configuration: rp.Configuration,
|
|
80
|
+
InputMapping: rp.InputMapping,
|
|
81
|
+
OutputMapping: rp.OutputMapping,
|
|
82
|
+
EntityID: rp.EntityID,
|
|
83
|
+
RecordProcessID: rp.ID,
|
|
84
|
+
RecordProcessName: rp.Name,
|
|
85
|
+
DryRun: dryRun,
|
|
86
|
+
Provider: provider,
|
|
87
|
+
RecordProcess: rp,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The record cap of a dry run over the stored scope (`DryRunSampleSize`, else `processor?.DefaultDryRunSampleSize`);
|
|
92
|
+
* undefined for a real run, a processor without a default sample size, or a caller-chosen scope or record.
|
|
93
|
+
*/
|
|
94
|
+
DryRunMaxRecords(_rp, options, processor) {
|
|
95
|
+
if (options.DryRun !== true || options.Scope || options.SingleRecordID) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return options.DryRunSampleSize || processor?.DefaultDryRunSampleSize;
|
|
99
|
+
}
|
|
68
100
|
/** Builds the record-set source from a single-record override, a runtime scope override, or the process's stored Scope. */
|
|
69
101
|
BuildSource(rp, provider, singleRecordID, scope) {
|
|
70
102
|
if (singleRecordID) {
|
|
@@ -92,7 +124,7 @@ export class RecordProcessExecutor {
|
|
|
92
124
|
return new FilterSource(entity.Name, rp.ScopeFilter ?? undefined);
|
|
93
125
|
}
|
|
94
126
|
case 'SingleRecord':
|
|
95
|
-
throw new Error(`Record Process '${rp.Name}': ScopeType=SingleRecord requires a record ID (pass
|
|
127
|
+
throw new Error(`Record Process '${rp.Name}': ScopeType=SingleRecord requires a record ID (pass SingleRecordID)`);
|
|
96
128
|
default:
|
|
97
129
|
throw new Error(`Record Process '${rp.Name}': unsupported ScopeType '${rp.ScopeType}'`);
|
|
98
130
|
}
|
|
@@ -121,12 +153,11 @@ export class RecordProcessExecutor {
|
|
|
121
153
|
}
|
|
122
154
|
/**
|
|
123
155
|
* Builds the processor from the process's Work. `FieldRules` reads its rule set from `Configuration`
|
|
124
|
-
* and writes itself (honoring `dryRun`);
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* dry-run is side-effect-free, not just FieldRules.
|
|
156
|
+
* and writes itself (honoring `dryRun`); `Action` and `Agent` build their built-in processors; other work
|
|
157
|
+
* types (including `Infer` and `'ML Model'`) resolve through {@link RecordProcessorRegistry}, then wrap
|
|
158
|
+
* with output-mapping write-back when configured.
|
|
128
159
|
*/
|
|
129
|
-
BuildProcessor(rp, dryRun, provider) {
|
|
160
|
+
BuildProcessor(rp, dryRun, provider, tracker) {
|
|
130
161
|
if (rp.WorkType === 'FieldRules') {
|
|
131
162
|
const ruleSet = rp.Configuration ? SafeJSONParse(rp.Configuration) : undefined;
|
|
132
163
|
if (!ruleSet || !Array.isArray(ruleSet.Rules)) {
|
|
@@ -135,9 +166,9 @@ export class RecordProcessExecutor {
|
|
|
135
166
|
// FieldRules owns its own write / dry-run preview — no output-mapping write-back wrapper.
|
|
136
167
|
return new FieldRulesProcessor({ RuleSet: ruleSet, DryRun: dryRun });
|
|
137
168
|
}
|
|
138
|
-
|
|
169
|
+
// unparseable mapping JSON (SafeJSONParse answers null) falls back to the default mapping, as an absent one does
|
|
170
|
+
const inputMapping = (rp.InputMapping ? SafeJSONParse(rp.InputMapping) : null) || undefined;
|
|
139
171
|
let base;
|
|
140
|
-
let spec;
|
|
141
172
|
if (rp.WorkType === 'Action') {
|
|
142
173
|
if (!rp.ActionID) {
|
|
143
174
|
throw new Error(`Record Process '${rp.Name}': WorkType=Action requires ActionID`);
|
|
@@ -150,45 +181,28 @@ export class RecordProcessExecutor {
|
|
|
150
181
|
}
|
|
151
182
|
base = new AgentRecordProcessor(rp.AgentID, inputMapping);
|
|
152
183
|
}
|
|
153
|
-
else if (rp.WorkType === 'Infer') {
|
|
154
|
-
// Shared with a Decision pipeline's escalation target, which is built the same way
|
|
155
|
-
const infer = InferProcessor.FromRecordProcess(rp, provider);
|
|
156
|
-
spec = infer.Spec;
|
|
157
|
-
base = infer;
|
|
158
|
-
}
|
|
159
184
|
else {
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
// factory for their own work type WITHOUT this package depending on them.
|
|
163
|
-
base = this.resolveFromRegistry(rp, dryRun);
|
|
164
|
-
}
|
|
165
|
-
const outputMapping = rp.OutputMapping ? SafeJSONParse(rp.OutputMapping) : undefined;
|
|
166
|
-
if (outputMapping?.fields && spec?.Outputs) {
|
|
167
|
-
for (const out of spec.Outputs) {
|
|
168
|
-
if (out.Target && out.Target.Mode === 'field') {
|
|
169
|
-
const fieldName = out.Target.EntityFieldName;
|
|
170
|
-
if (outputMapping.fields[fieldName] && (out.Target.LookupMatchField || out.Target.OnLookupMiss)) {
|
|
171
|
-
outputMapping.fieldLookups = outputMapping.fieldLookups ?? {};
|
|
172
|
-
if (!outputMapping.fieldLookups[fieldName]) {
|
|
173
|
-
outputMapping.fieldLookups[fieldName] = {
|
|
174
|
-
matchField: out.Target.LookupMatchField ?? 'Name',
|
|
175
|
-
onLookupMiss: out.Target.OnLookupMiss ?? 'null',
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
185
|
+
// Consult the pluggable registry. This open seam lets external packages (e.g.
|
|
186
|
+
// FeaturePipelinesEngine's 'Infer' and Predictive Studio's 'ML Model' scoring) register
|
|
187
|
+
// a processor factory for their own work type WITHOUT this package depending on them.
|
|
188
|
+
base = this.resolveFromRegistry(rp, dryRun, provider, tracker);
|
|
181
189
|
}
|
|
182
|
-
|
|
183
|
-
|
|
190
|
+
const rawOutputMapping = rp.OutputMapping ? SafeJSONParse(rp.OutputMapping) ?? undefined : undefined;
|
|
191
|
+
const prepared = base.PrepareOutputMapping?.(rawOutputMapping);
|
|
192
|
+
const outputMapping = prepared?.OutputMapping ?? rawOutputMapping;
|
|
193
|
+
const hasMappedWrites = !!outputMapping &&
|
|
194
|
+
!!(outputMapping.fields ||
|
|
184
195
|
outputMapping.childRecord ||
|
|
185
196
|
(outputMapping.childRecords && outputMapping.childRecords.length > 0) ||
|
|
186
|
-
(outputMapping.tags && outputMapping.tags.length > 0))
|
|
197
|
+
(outputMapping.tags && outputMapping.tags.length > 0));
|
|
198
|
+
const hasUnmappedWrites = prepared?.HasUnmappedWrites === true;
|
|
199
|
+
if (hasMappedWrites || hasUnmappedWrites) {
|
|
187
200
|
const run = {
|
|
188
201
|
RecordProcessID: rp.ID,
|
|
189
202
|
PromptID: rp.PromptID ?? undefined,
|
|
190
203
|
};
|
|
191
|
-
|
|
204
|
+
const mapping = outputMapping ?? {};
|
|
205
|
+
return new WriteBackProcessor(base, mapping, dryRun, run);
|
|
192
206
|
}
|
|
193
207
|
return base;
|
|
194
208
|
}
|
|
@@ -203,7 +217,7 @@ export class RecordProcessExecutor {
|
|
|
203
217
|
* per-run context. Throws the same "unsupported WorkType" error as before when nothing is registered,
|
|
204
218
|
* so behavior is unchanged for genuinely-unknown work types.
|
|
205
219
|
*/
|
|
206
|
-
resolveFromRegistry(rp, dryRun) {
|
|
220
|
+
resolveFromRegistry(rp, dryRun, provider, tracker) {
|
|
207
221
|
const context = {
|
|
208
222
|
WorkType: rp.WorkType,
|
|
209
223
|
Configuration: rp.Configuration,
|
|
@@ -213,6 +227,8 @@ export class RecordProcessExecutor {
|
|
|
213
227
|
RecordProcessID: rp.ID,
|
|
214
228
|
RecordProcessName: rp.Name,
|
|
215
229
|
DryRun: dryRun,
|
|
230
|
+
Provider: provider,
|
|
231
|
+
Tracker: tracker,
|
|
216
232
|
RecordProcess: rp,
|
|
217
233
|
};
|
|
218
234
|
const resolved = RecordProcessorRegistry.Instance.Resolve(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordProcessExecutor.js","sourceRoot":"","sources":["../src/RecordProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,aAAa,EAAqB,MAAM,wBAAwB,CAAC;AAE3F,OAAO,EACH,WAAW,EACX,YAAY,
|
|
1
|
+
{"version":3,"file":"RecordProcessExecutor.js","sourceRoot":"","sources":["../src/RecordProcessExecutor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,aAAa,EAAqB,MAAM,wBAAwB,CAAC;AAE3F,OAAO,EACH,WAAW,EACX,YAAY,EAIZ,UAAU,EAIV,uBAAuB,EAEvB,UAAU,GACb,MAAM,2CAA2C,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AA2CrE,kFAAkF;AAClF,MAAM,OAAO,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GAAwB,aAAa,IAAI,EAAE,CAAC;YACzD,OAAO,IAAI,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,8CAA8C;IACvC,cAAc,CAAC,EAAyB,EAAE,MAAgB,EAAE,QAA4B;QAC3F,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED;;;;;;OAMG;IACK,mBAAmB,CACvB,EAAyB,EACzB,MAAgB,EAChB,QAA4B,EAC5B,OAA4B;QAE5B,MAAM,OAAO,GAAgC;YACzC,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,aAAa,EAAE,EAAE,CAAC,aAAa;YAC/B,YAAY,EAAE,EAAE,CAAC,YAAY;YAC7B,aAAa,EAAE,EAAE,CAAC,aAAa;YAC/B,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,eAAe,EAAE,EAAE,CAAC,EAAE;YACtB,iBAAiB,EAAE,EAAE,CAAC,IAAI;YAC1B,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,QAAQ;YAClB,OAAO,EAAE,OAAO;YAChB,aAAa,EAAE,EAAE;SACpB,CAAC;QACF,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACnE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,EAAE,CAAC,IAAI,4BAA4B,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ"}
|
|
@@ -27,6 +27,21 @@ export declare class RecordSetProcessor extends BaseSingleton<RecordSetProcessor
|
|
|
27
27
|
private runBatchLoop;
|
|
28
28
|
/** Processes one batch with bounded concurrency, isolating per-record failures. */
|
|
29
29
|
private processBatch;
|
|
30
|
+
/**
|
|
31
|
+
* Whether a batch's watermarks are read: a run that skips unchanged records, or a real run that does not (its
|
|
32
|
+
* succeeded records' watermarks are refreshed). A dry run without skipping writes no watermark.
|
|
33
|
+
*/
|
|
34
|
+
private readsWatermarks;
|
|
35
|
+
/** Records the processor was handed: every processed record except those skipped on their watermark. */
|
|
36
|
+
private attemptedOf;
|
|
37
|
+
/**
|
|
38
|
+
* Keeps a result's pending Action log row in the run's in-flight set until it settles, so Process() can await
|
|
39
|
+
* it before CompleteRun without the per-record loop ever waiting. Each entry removes itself, so the set holds
|
|
40
|
+
* only rows still in flight.
|
|
41
|
+
*/
|
|
42
|
+
private holdRunForLogRow;
|
|
43
|
+
/** Adds one record's outcome to the run's tally. */
|
|
44
|
+
private tallyRecord;
|
|
30
45
|
/** Runs `worker` over `items` with at most `limit` in flight at once. */
|
|
31
46
|
private runWithConcurrency;
|
|
32
47
|
/** Invokes the budget-gate hook, treating a thrown hook as non-fatal (continue). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordSetProcessor.d.ts","sourceRoot":"","sources":["../src/RecordSetProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAIH,gBAAgB,
|
|
1
|
+
{"version":3,"file":"RecordSetProcessor.d.ts","sourceRoot":"","sources":["../src/RecordSetProcessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAIH,gBAAgB,EAMhB,uBAAuB,EAI1B,MAAM,2CAA2C,CAAC;AAWnD;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,aAAa,CAAC,kBAAkB,CAAC;IACrE,2CAA2C;IAC3C,WAAkB,QAAQ,IAAI,kBAAkB,CAE/C;IAED;;;;;;OAMG;IACU,OAAO,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgHjF,wDAAwD;YAC1C,YAAY;IAqE1B,mFAAmF;YACrE,YAAY;IA6K1B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAOvB,wGAAwG;IACxG,OAAO,CAAC,WAAW;IAInB;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IASxB,oDAAoD;IACpD,OAAO,CAAC,WAAW;IAMnB,yEAAyE;YAC3D,kBAAkB;IAiBhC,oFAAoF;YACtE,cAAc;IAa5B,OAAO,CAAC,KAAK;CAGhB"}
|