@memberjunction/record-set-processor-base 5.43.0 → 5.44.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/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@
6
6
  export * from './types.js';
7
7
  export * from './interfaces.js';
8
8
  export * from './sources/index.js';
9
+ export * from './registry.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  export * from './types.js';
7
7
  export * from './interfaces.js';
8
8
  export * from './sources/index.js';
9
+ export * from './registry.js';
9
10
  // The RecordProcess.RunNow Remote Operation base + RecordProcessScopeOverride/RecordProcessRunNowInput/Output
10
11
  // are now CodeGen-emitted into @memberjunction/core-entities (generated/remote_operations.ts) from the
11
12
  // MJ: Remote Operations metadata row.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,8GAA8G;AAC9G,uGAAuG;AACvG,sCAAsC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,8GAA8G;AAC9G,uGAAuG;AACvG,sCAAsC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * @fileoverview The **processor registry** — the open seam that lets external packages teach the
3
+ * Record Set Processing substrate about new work types WITHOUT the base package depending on them.
4
+ *
5
+ * The engine's `RecordProcessExecutor.buildProcessor()` handles the built-in work types
6
+ * (`FieldRules` / `Action` / `Agent` / `Infer`) directly, then consults this registry for any work
7
+ * type its switch doesn't recognize before failing. A consumer package (e.g. Predictive Studio's
8
+ * `'ML Model'` scoring) registers a factory keyed by its work-type string; the factory closes over
9
+ * whatever injected dependencies that consumer needs (sidecars, loaders, etc.) and constructs its
10
+ * `IRecordProcessor` from the per-run build context.
11
+ *
12
+ * @module @memberjunction/record-set-processor-base
13
+ */
14
+ import { BaseSingleton } from '@memberjunction/global';
15
+ import { IRecordProcessor } from './interfaces.js';
16
+ /**
17
+ * The per-run context handed to a registered factory. Carries the resolved Record Process fields the
18
+ * factory needs to build its processor, plus the dry-run flag, WITHOUT coupling the base package to
19
+ * the `MJRecordProcessEntity` type (the base package depends only on `@memberjunction/core` +
20
+ * `@memberjunction/global`). The engine populates this from the loaded Record Process; the registered
21
+ * factory reads `Configuration` / `InputMapping` to build itself.
22
+ */
23
+ export interface RecordProcessorBuildContext {
24
+ /** The work-type key being built (the registry lookup key). */
25
+ WorkType: string;
26
+ /** The Record Process's `Configuration` JSON string (work-type-specific config), if any. */
27
+ Configuration?: string | null;
28
+ /** The Record Process's `InputMapping` JSON string, if any. */
29
+ InputMapping?: string | null;
30
+ /** The Record Process's `OutputMapping` JSON string, if any (write-back targets). */
31
+ OutputMapping?: string | null;
32
+ /** The target entity id of the Record Process. */
33
+ EntityID?: string;
34
+ /** The Record Process id (lineage / diagnostics). */
35
+ RecordProcessID?: string;
36
+ /** The Record Process name (diagnostics). */
37
+ RecordProcessName?: string;
38
+ /** True when this is a dry-run (compute-only) pass — the factory should honor it when supported. */
39
+ DryRun?: boolean;
40
+ /**
41
+ * The loaded Record Process record itself, as an opaque object. The engine passes the real
42
+ * `MJRecordProcessEntity`; a factory that needs fields beyond those projected above can read them
43
+ * off this with its own typing. Typed as `unknown` so the base package stays free of
44
+ * `@memberjunction/core-entities`.
45
+ */
46
+ RecordProcess?: unknown;
47
+ }
48
+ /**
49
+ * Factory that builds an {@link IRecordProcessor} for a registered work type. Returning `null` (or
50
+ * `undefined`) signals "not applicable" so the executor can continue (defensive — normally a factory
51
+ * registered for a work type always builds for it). The factory may throw to surface a configuration
52
+ * error (e.g. a missing required id), exactly as the built-in work types do.
53
+ */
54
+ export type RecordProcessorFactory = (context: RecordProcessorBuildContext) => IRecordProcessor | null | undefined;
55
+ /**
56
+ * Process-wide registry of work-type → processor factory, used by the engine's `buildProcessor()` to
57
+ * resolve work types beyond its built-ins. A {@link BaseSingleton} so there is exactly one instance
58
+ * across the process even when a bundler duplicates the module (per CLAUDE.md rule 7).
59
+ *
60
+ * Work-type keys are matched case-insensitively (trimmed), so a consumer can register `'ML Model'`
61
+ * and the executor resolves it whether the Record Process row stores `'ML Model'` or `'ml model'`.
62
+ */
63
+ export declare class RecordProcessorRegistry extends BaseSingleton<RecordProcessorRegistry> {
64
+ /** work-type (normalized) → factory. */
65
+ private readonly factories;
66
+ /** @internal — use {@link RecordProcessorRegistry.Instance}. */
67
+ protected constructor();
68
+ /** The single process-wide registry instance. */
69
+ static get Instance(): RecordProcessorRegistry;
70
+ /** Normalize a work-type key for case/whitespace-insensitive matching. */
71
+ private normalize;
72
+ /**
73
+ * Register a factory for a work-type key. A later registration for the same key overrides the
74
+ * earlier one (last-wins), which lets a consumer replace a default.
75
+ *
76
+ * @param workType the work-type string (e.g. `'ML Model'`), matched case-insensitively
77
+ * @param factory builds the processor for that work type from the per-run context
78
+ */
79
+ Register(workType: string, factory: RecordProcessorFactory): void;
80
+ /** Whether a factory is registered for the given work type (case-insensitive). */
81
+ Has(workType: string | null | undefined): boolean;
82
+ /**
83
+ * Resolve and invoke the factory for a work type, returning the built processor or `null` when no
84
+ * factory is registered (or the factory itself declined by returning null/undefined).
85
+ *
86
+ * @param context the per-run build context (work type + Record Process fields)
87
+ */
88
+ Resolve(context: RecordProcessorBuildContext): IRecordProcessor | null;
89
+ /** The set of registered work-type keys (normalized). Primarily for diagnostics/tests. */
90
+ get RegisteredWorkTypes(): string[];
91
+ /** Remove a registration (case-insensitive). Returns whether one was present. Primarily for tests. */
92
+ Unregister(workType: string): boolean;
93
+ }
94
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B;IACxC,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,qFAAqF;IACrF,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oGAAoG;IACpG,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,EAAE,2BAA2B,KAAK,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;AAEnH;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,aAAa,CAAC,uBAAuB,CAAC;IAC/E,wCAAwC;IACxC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6C;IAEvE,gEAAgE;IAChE,SAAS;IAIT,iDAAiD;IACjD,WAAkB,QAAQ,IAAI,uBAAuB,CAEpD;IAED,0EAA0E;IAC1E,OAAO,CAAC,SAAS;IAIjB;;;;;;OAMG;IACI,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,IAAI;IAOxE,kFAAkF;IAC3E,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;IAIxD;;;;;OAKG;IACI,OAAO,CAAC,OAAO,EAAE,2BAA2B,GAAG,gBAAgB,GAAG,IAAI;IAQ7E,0FAA0F;IAC1F,IAAW,mBAAmB,IAAI,MAAM,EAAE,CAEzC;IAED,sGAAsG;IAC/F,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAG/C"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @fileoverview The **processor registry** — the open seam that lets external packages teach the
3
+ * Record Set Processing substrate about new work types WITHOUT the base package depending on them.
4
+ *
5
+ * The engine's `RecordProcessExecutor.buildProcessor()` handles the built-in work types
6
+ * (`FieldRules` / `Action` / `Agent` / `Infer`) directly, then consults this registry for any work
7
+ * type its switch doesn't recognize before failing. A consumer package (e.g. Predictive Studio's
8
+ * `'ML Model'` scoring) registers a factory keyed by its work-type string; the factory closes over
9
+ * whatever injected dependencies that consumer needs (sidecars, loaders, etc.) and constructs its
10
+ * `IRecordProcessor` from the per-run build context.
11
+ *
12
+ * @module @memberjunction/record-set-processor-base
13
+ */
14
+ import { BaseSingleton } from '@memberjunction/global';
15
+ /**
16
+ * Process-wide registry of work-type → processor factory, used by the engine's `buildProcessor()` to
17
+ * resolve work types beyond its built-ins. A {@link BaseSingleton} so there is exactly one instance
18
+ * across the process even when a bundler duplicates the module (per CLAUDE.md rule 7).
19
+ *
20
+ * Work-type keys are matched case-insensitively (trimmed), so a consumer can register `'ML Model'`
21
+ * and the executor resolves it whether the Record Process row stores `'ML Model'` or `'ml model'`.
22
+ */
23
+ export class RecordProcessorRegistry extends BaseSingleton {
24
+ /** @internal — use {@link RecordProcessorRegistry.Instance}. */
25
+ constructor() {
26
+ super();
27
+ /** work-type (normalized) → factory. */
28
+ this.factories = new Map();
29
+ }
30
+ /** The single process-wide registry instance. */
31
+ static get Instance() {
32
+ return super.getInstance();
33
+ }
34
+ /** Normalize a work-type key for case/whitespace-insensitive matching. */
35
+ normalize(workType) {
36
+ return workType.trim().toLowerCase();
37
+ }
38
+ /**
39
+ * Register a factory for a work-type key. A later registration for the same key overrides the
40
+ * earlier one (last-wins), which lets a consumer replace a default.
41
+ *
42
+ * @param workType the work-type string (e.g. `'ML Model'`), matched case-insensitively
43
+ * @param factory builds the processor for that work type from the per-run context
44
+ */
45
+ Register(workType, factory) {
46
+ if (!workType || !workType.trim()) {
47
+ throw new Error('RecordProcessorRegistry.Register: workType must be a non-empty string');
48
+ }
49
+ this.factories.set(this.normalize(workType), factory);
50
+ }
51
+ /** Whether a factory is registered for the given work type (case-insensitive). */
52
+ Has(workType) {
53
+ return workType != null && this.factories.has(this.normalize(workType));
54
+ }
55
+ /**
56
+ * Resolve and invoke the factory for a work type, returning the built processor or `null` when no
57
+ * factory is registered (or the factory itself declined by returning null/undefined).
58
+ *
59
+ * @param context the per-run build context (work type + Record Process fields)
60
+ */
61
+ Resolve(context) {
62
+ const factory = context.WorkType != null ? this.factories.get(this.normalize(context.WorkType)) : undefined;
63
+ if (!factory) {
64
+ return null;
65
+ }
66
+ return factory(context) ?? null;
67
+ }
68
+ /** The set of registered work-type keys (normalized). Primarily for diagnostics/tests. */
69
+ get RegisteredWorkTypes() {
70
+ return Array.from(this.factories.keys());
71
+ }
72
+ /** Remove a registration (case-insensitive). Returns whether one was present. Primarily for tests. */
73
+ Unregister(workType) {
74
+ return this.factories.delete(this.normalize(workType));
75
+ }
76
+ }
77
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA4CvD;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAAsC;IAI/E,gEAAgE;IAChE;QACI,KAAK,EAAE,CAAC;QALZ,wCAAwC;QACvB,cAAS,GAAG,IAAI,GAAG,EAAkC,CAAC;IAKvE,CAAC;IAED,iDAAiD;IAC1C,MAAM,KAAK,QAAQ;QACtB,OAAO,KAAK,CAAC,WAAW,EAA2B,CAAC;IACxD,CAAC;IAED,0EAA0E;IAClE,SAAS,CAAC,QAAgB;QAC9B,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,QAAQ,CAAC,QAAgB,EAAE,OAA+B;QAC7D,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAED,kFAAkF;IAC3E,GAAG,CAAC,QAAmC;QAC1C,OAAO,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED;;;;;OAKG;IACI,OAAO,CAAC,OAAoC;QAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5G,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IACpC,CAAC;IAED,0FAA0F;IAC1F,IAAW,mBAAmB;QAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED,sGAAsG;IAC/F,UAAU,CAAC,QAAgB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/record-set-processor-base",
3
3
  "type": "module",
4
- "version": "5.43.0",
4
+ "version": "5.44.0",
5
5
  "description": "MemberJunction: Record Set Processor Base - interfaces, types, and source adapters for batched, resumable record-set processing. Client-safe.",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,8 +17,8 @@
17
17
  "author": "MemberJunction.com",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@memberjunction/core": "5.43.0",
21
- "@memberjunction/global": "5.43.0"
20
+ "@memberjunction/core": "5.44.0",
21
+ "@memberjunction/global": "5.44.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "24.10.11",