@memberjunction/predictive-studio 0.0.1 → 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.
Files changed (266) hide show
  1. package/README.md +101 -28
  2. package/dist/actions/base-predictive-studio.action.d.ts +63 -0
  3. package/dist/actions/base-predictive-studio.action.d.ts.map +1 -0
  4. package/dist/actions/base-predictive-studio.action.js +125 -0
  5. package/dist/actions/base-predictive-studio.action.js.map +1 -0
  6. package/dist/actions/index.d.ts +38 -0
  7. package/dist/actions/index.d.ts.map +1 -0
  8. package/dist/actions/index.js +49 -0
  9. package/dist/actions/index.js.map +1 -0
  10. package/dist/actions/model-scoring-action-generator.d.ts +108 -0
  11. package/dist/actions/model-scoring-action-generator.d.ts.map +1 -0
  12. package/dist/actions/model-scoring-action-generator.js +316 -0
  13. package/dist/actions/model-scoring-action-generator.js.map +1 -0
  14. package/dist/actions/promote-model.action.d.ts +102 -0
  15. package/dist/actions/promote-model.action.d.ts.map +1 -0
  16. package/dist/actions/promote-model.action.js +132 -0
  17. package/dist/actions/promote-model.action.js.map +1 -0
  18. package/dist/actions/promote-model.gate.d.ts +77 -0
  19. package/dist/actions/promote-model.gate.d.ts.map +1 -0
  20. package/dist/actions/promote-model.gate.js +205 -0
  21. package/dist/actions/promote-model.gate.js.map +1 -0
  22. package/dist/actions/run-experiment.action.d.ts +60 -0
  23. package/dist/actions/run-experiment.action.d.ts.map +1 -0
  24. package/dist/actions/run-experiment.action.js +134 -0
  25. package/dist/actions/run-experiment.action.js.map +1 -0
  26. package/dist/actions/run-experiment.deps.d.ts +47 -0
  27. package/dist/actions/run-experiment.deps.d.ts.map +1 -0
  28. package/dist/actions/run-experiment.deps.js +71 -0
  29. package/dist/actions/run-experiment.deps.js.map +1 -0
  30. package/dist/actions/schedule-model-scoring.action.d.ts +71 -0
  31. package/dist/actions/schedule-model-scoring.action.d.ts.map +1 -0
  32. package/dist/actions/schedule-model-scoring.action.js +148 -0
  33. package/dist/actions/schedule-model-scoring.action.js.map +1 -0
  34. package/dist/actions/score-record-set.action.d.ts +133 -0
  35. package/dist/actions/score-record-set.action.d.ts.map +1 -0
  36. package/dist/actions/score-record-set.action.js +136 -0
  37. package/dist/actions/score-record-set.action.js.map +1 -0
  38. package/dist/actions/score-record-set.runner.d.ts +192 -0
  39. package/dist/actions/score-record-set.runner.d.ts.map +1 -0
  40. package/dist/actions/score-record-set.runner.js +416 -0
  41. package/dist/actions/score-record-set.runner.js.map +1 -0
  42. package/dist/actions/train-model.action.d.ts +57 -0
  43. package/dist/actions/train-model.action.d.ts.map +1 -0
  44. package/dist/actions/train-model.action.js +111 -0
  45. package/dist/actions/train-model.action.js.map +1 -0
  46. package/dist/agent/index.d.ts +14 -0
  47. package/dist/agent/index.d.ts.map +1 -0
  48. package/dist/agent/index.js +14 -0
  49. package/dist/agent/index.js.map +1 -0
  50. package/dist/agent/model-dev-orchestrator-agent.d.ts +42 -0
  51. package/dist/agent/model-dev-orchestrator-agent.d.ts.map +1 -0
  52. package/dist/agent/model-dev-orchestrator-agent.js +76 -0
  53. package/dist/agent/model-dev-orchestrator-agent.js.map +1 -0
  54. package/dist/agent/modeling-plan-to-pipeline.d.ts +49 -0
  55. package/dist/agent/modeling-plan-to-pipeline.d.ts.map +1 -0
  56. package/dist/agent/modeling-plan-to-pipeline.js +101 -0
  57. package/dist/agent/modeling-plan-to-pipeline.js.map +1 -0
  58. package/dist/agent/pipeline-builder-agent.d.ts +58 -0
  59. package/dist/agent/pipeline-builder-agent.d.ts.map +1 -0
  60. package/dist/agent/pipeline-builder-agent.js +101 -0
  61. package/dist/agent/pipeline-builder-agent.js.map +1 -0
  62. package/dist/agent/pipeline-builder.d.ts +67 -0
  63. package/dist/agent/pipeline-builder.d.ts.map +1 -0
  64. package/dist/agent/pipeline-builder.js +114 -0
  65. package/dist/agent/pipeline-builder.js.map +1 -0
  66. package/dist/experiment/concurrency.d.ts +41 -0
  67. package/dist/experiment/concurrency.d.ts.map +1 -0
  68. package/dist/experiment/concurrency.js +54 -0
  69. package/dist/experiment/concurrency.js.map +1 -0
  70. package/dist/experiment/experiment-orchestrator.d.ts +136 -0
  71. package/dist/experiment/experiment-orchestrator.d.ts.map +1 -0
  72. package/dist/experiment/experiment-orchestrator.js +408 -0
  73. package/dist/experiment/experiment-orchestrator.js.map +1 -0
  74. package/dist/experiment/index.d.ts +17 -0
  75. package/dist/experiment/index.d.ts.map +1 -0
  76. package/dist/experiment/index.js +17 -0
  77. package/dist/experiment/index.js.map +1 -0
  78. package/dist/experiment/leaderboard.d.ts +50 -0
  79. package/dist/experiment/leaderboard.d.ts.map +1 -0
  80. package/dist/experiment/leaderboard.js +91 -0
  81. package/dist/experiment/leaderboard.js.map +1 -0
  82. package/dist/experiment/seams.d.ts +95 -0
  83. package/dist/experiment/seams.d.ts.map +1 -0
  84. package/dist/experiment/seams.js +126 -0
  85. package/dist/experiment/seams.js.map +1 -0
  86. package/dist/experiment/types.d.ts +228 -0
  87. package/dist/experiment/types.d.ts.map +1 -0
  88. package/dist/experiment/types.js +19 -0
  89. package/dist/experiment/types.js.map +1 -0
  90. package/dist/experiment/wave-strategist.d.ts +31 -0
  91. package/dist/experiment/wave-strategist.d.ts.map +1 -0
  92. package/dist/experiment/wave-strategist.js +50 -0
  93. package/dist/experiment/wave-strategist.js.map +1 -0
  94. package/dist/feature-assembly/as-of.d.ts +74 -0
  95. package/dist/feature-assembly/as-of.d.ts.map +1 -0
  96. package/dist/feature-assembly/as-of.js +136 -0
  97. package/dist/feature-assembly/as-of.js.map +1 -0
  98. package/dist/feature-assembly/data-access.d.ts +114 -0
  99. package/dist/feature-assembly/data-access.d.ts.map +1 -0
  100. package/dist/feature-assembly/data-access.js +68 -0
  101. package/dist/feature-assembly/data-access.js.map +1 -0
  102. package/dist/feature-assembly/feature-assembly-executor.d.ts +273 -0
  103. package/dist/feature-assembly/feature-assembly-executor.d.ts.map +1 -0
  104. package/dist/feature-assembly/feature-assembly-executor.js +521 -0
  105. package/dist/feature-assembly/feature-assembly-executor.js.map +1 -0
  106. package/dist/feature-assembly/index.d.ts +13 -0
  107. package/dist/feature-assembly/index.d.ts.map +1 -0
  108. package/dist/feature-assembly/index.js +13 -0
  109. package/dist/feature-assembly/index.js.map +1 -0
  110. package/dist/feature-assembly/leakage-guard.d.ts +86 -0
  111. package/dist/feature-assembly/leakage-guard.d.ts.map +1 -0
  112. package/dist/feature-assembly/leakage-guard.js +111 -0
  113. package/dist/feature-assembly/leakage-guard.js.map +1 -0
  114. package/dist/feature-assembly/vision-llm.d.ts +125 -0
  115. package/dist/feature-assembly/vision-llm.d.ts.map +1 -0
  116. package/dist/feature-assembly/vision-llm.js +211 -0
  117. package/dist/feature-assembly/vision-llm.js.map +1 -0
  118. package/dist/feature-pipelines/feature-pipeline-engine.d.ts +159 -0
  119. package/dist/feature-pipelines/feature-pipeline-engine.d.ts.map +1 -0
  120. package/dist/feature-pipelines/feature-pipeline-engine.js +298 -0
  121. package/dist/feature-pipelines/feature-pipeline-engine.js.map +1 -0
  122. package/dist/feature-pipelines/index.d.ts +13 -0
  123. package/dist/feature-pipelines/index.d.ts.map +1 -0
  124. package/dist/feature-pipelines/index.js +13 -0
  125. package/dist/feature-pipelines/index.js.map +1 -0
  126. package/dist/feature-pipelines/types.d.ts +72 -0
  127. package/dist/feature-pipelines/types.d.ts.map +1 -0
  128. package/dist/feature-pipelines/types.js +17 -0
  129. package/dist/feature-pipelines/types.js.map +1 -0
  130. package/dist/index.d.ts +37 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +80 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/maintenance/index.d.ts +19 -0
  135. package/dist/maintenance/index.d.ts.map +1 -0
  136. package/dist/maintenance/index.js +19 -0
  137. package/dist/maintenance/index.js.map +1 -0
  138. package/dist/maintenance/maintenance-engine.d.ts +152 -0
  139. package/dist/maintenance/maintenance-engine.d.ts.map +1 -0
  140. package/dist/maintenance/maintenance-engine.js +412 -0
  141. package/dist/maintenance/maintenance-engine.js.map +1 -0
  142. package/dist/maintenance/metrics.d.ts +37 -0
  143. package/dist/maintenance/metrics.d.ts.map +1 -0
  144. package/dist/maintenance/metrics.js +85 -0
  145. package/dist/maintenance/metrics.js.map +1 -0
  146. package/dist/maintenance/seams.d.ts +85 -0
  147. package/dist/maintenance/seams.d.ts.map +1 -0
  148. package/dist/maintenance/seams.js +166 -0
  149. package/dist/maintenance/seams.js.map +1 -0
  150. package/dist/maintenance/types.d.ts +318 -0
  151. package/dist/maintenance/types.d.ts.map +1 -0
  152. package/dist/maintenance/types.js +27 -0
  153. package/dist/maintenance/types.js.map +1 -0
  154. package/dist/operations/__tests__/helpers.d.ts +30 -0
  155. package/dist/operations/__tests__/helpers.d.ts.map +1 -0
  156. package/dist/operations/__tests__/helpers.js +44 -0
  157. package/dist/operations/__tests__/helpers.js.map +1 -0
  158. package/dist/operations/control-experiment-session.operation.d.ts +33 -0
  159. package/dist/operations/control-experiment-session.operation.d.ts.map +1 -0
  160. package/dist/operations/control-experiment-session.operation.js +71 -0
  161. package/dist/operations/control-experiment-session.operation.js.map +1 -0
  162. package/dist/operations/create-scoring-process.operation.d.ts +30 -0
  163. package/dist/operations/create-scoring-process.operation.d.ts.map +1 -0
  164. package/dist/operations/create-scoring-process.operation.js +65 -0
  165. package/dist/operations/create-scoring-process.operation.js.map +1 -0
  166. package/dist/operations/delegation.d.ts +113 -0
  167. package/dist/operations/delegation.d.ts.map +1 -0
  168. package/dist/operations/delegation.js +139 -0
  169. package/dist/operations/delegation.js.map +1 -0
  170. package/dist/operations/index.d.ts +40 -0
  171. package/dist/operations/index.d.ts.map +1 -0
  172. package/dist/operations/index.js +55 -0
  173. package/dist/operations/index.js.map +1 -0
  174. package/dist/operations/promote-model.operation.d.ts +57 -0
  175. package/dist/operations/promote-model.operation.d.ts.map +1 -0
  176. package/dist/operations/promote-model.operation.js +113 -0
  177. package/dist/operations/promote-model.operation.js.map +1 -0
  178. package/dist/operations/run-feature-pipeline.operation.d.ts +56 -0
  179. package/dist/operations/run-feature-pipeline.operation.d.ts.map +1 -0
  180. package/dist/operations/run-feature-pipeline.operation.js +94 -0
  181. package/dist/operations/run-feature-pipeline.operation.js.map +1 -0
  182. package/dist/operations/score-record-set.operation.d.ts +47 -0
  183. package/dist/operations/score-record-set.operation.d.ts.map +1 -0
  184. package/dist/operations/score-record-set.operation.js +113 -0
  185. package/dist/operations/score-record-set.operation.js.map +1 -0
  186. package/dist/operations/start-experiment-session.operation.d.ts +66 -0
  187. package/dist/operations/start-experiment-session.operation.d.ts.map +1 -0
  188. package/dist/operations/start-experiment-session.operation.js +132 -0
  189. package/dist/operations/start-experiment-session.operation.js.map +1 -0
  190. package/dist/operations/train-model.operation.d.ts +50 -0
  191. package/dist/operations/train-model.operation.d.ts.map +1 -0
  192. package/dist/operations/train-model.operation.js +114 -0
  193. package/dist/operations/train-model.operation.js.map +1 -0
  194. package/dist/scheduling/index.d.ts +13 -0
  195. package/dist/scheduling/index.d.ts.map +1 -0
  196. package/dist/scheduling/index.js +13 -0
  197. package/dist/scheduling/index.js.map +1 -0
  198. package/dist/scheduling/scheduled-model-scoring.d.ts +169 -0
  199. package/dist/scheduling/scheduled-model-scoring.d.ts.map +1 -0
  200. package/dist/scheduling/scheduled-model-scoring.js +189 -0
  201. package/dist/scheduling/scheduled-model-scoring.js.map +1 -0
  202. package/dist/scoring/artifact-loader.d.ts +65 -0
  203. package/dist/scoring/artifact-loader.d.ts.map +1 -0
  204. package/dist/scoring/artifact-loader.js +97 -0
  205. package/dist/scoring/artifact-loader.js.map +1 -0
  206. package/dist/scoring/index.d.ts +26 -0
  207. package/dist/scoring/index.d.ts.map +1 -0
  208. package/dist/scoring/index.js +26 -0
  209. package/dist/scoring/index.js.map +1 -0
  210. package/dist/scoring/ml-model-inference-processor.d.ts +154 -0
  211. package/dist/scoring/ml-model-inference-processor.d.ts.map +1 -0
  212. package/dist/scoring/ml-model-inference-processor.js +320 -0
  213. package/dist/scoring/ml-model-inference-processor.js.map +1 -0
  214. package/dist/scoring/ml-model-score-enricher.d.ts +80 -0
  215. package/dist/scoring/ml-model-score-enricher.d.ts.map +1 -0
  216. package/dist/scoring/ml-model-score-enricher.js +139 -0
  217. package/dist/scoring/ml-model-score-enricher.js.map +1 -0
  218. package/dist/scoring/register.d.ts +81 -0
  219. package/dist/scoring/register.d.ts.map +1 -0
  220. package/dist/scoring/register.js +105 -0
  221. package/dist/scoring/register.js.map +1 -0
  222. package/dist/scoring/scoring-binding.d.ts +72 -0
  223. package/dist/scoring/scoring-binding.d.ts.map +1 -0
  224. package/dist/scoring/scoring-binding.js +76 -0
  225. package/dist/scoring/scoring-binding.js.map +1 -0
  226. package/dist/scoring/scoring-process-shared.d.ts +105 -0
  227. package/dist/scoring/scoring-process-shared.d.ts.map +1 -0
  228. package/dist/scoring/scoring-process-shared.js +141 -0
  229. package/dist/scoring/scoring-process-shared.js.map +1 -0
  230. package/dist/scoring/scoring-process.d.ts +128 -0
  231. package/dist/scoring/scoring-process.d.ts.map +1 -0
  232. package/dist/scoring/scoring-process.js +146 -0
  233. package/dist/scoring/scoring-process.js.map +1 -0
  234. package/dist/scoring/seams.d.ts +40 -0
  235. package/dist/scoring/seams.d.ts.map +1 -0
  236. package/dist/scoring/seams.js +66 -0
  237. package/dist/scoring/seams.js.map +1 -0
  238. package/dist/scoring/startup-register.d.ts +49 -0
  239. package/dist/scoring/startup-register.d.ts.map +1 -0
  240. package/dist/scoring/startup-register.js +72 -0
  241. package/dist/scoring/startup-register.js.map +1 -0
  242. package/dist/scoring/types.d.ts +134 -0
  243. package/dist/scoring/types.d.ts.map +1 -0
  244. package/dist/scoring/types.js +26 -0
  245. package/dist/scoring/types.js.map +1 -0
  246. package/dist/training/artifact-store.d.ts +124 -0
  247. package/dist/training/artifact-store.d.ts.map +1 -0
  248. package/dist/training/artifact-store.js +163 -0
  249. package/dist/training/artifact-store.js.map +1 -0
  250. package/dist/training/index.d.ts +13 -0
  251. package/dist/training/index.d.ts.map +1 -0
  252. package/dist/training/index.js +13 -0
  253. package/dist/training/index.js.map +1 -0
  254. package/dist/training/seams.d.ts +57 -0
  255. package/dist/training/seams.d.ts.map +1 -0
  256. package/dist/training/seams.js +103 -0
  257. package/dist/training/seams.js.map +1 -0
  258. package/dist/training/training-engine.d.ts +96 -0
  259. package/dist/training/training-engine.d.ts.map +1 -0
  260. package/dist/training/training-engine.js +300 -0
  261. package/dist/training/training-engine.js.map +1 -0
  262. package/dist/training/types.d.ts +159 -0
  263. package/dist/training/types.d.ts.map +1 -0
  264. package/dist/training/types.js +16 -0
  265. package/dist/training/types.js.map +1 -0
  266. package/package.json +44 -7
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @module actions/schedule-model-scoring.action
3
+ *
4
+ * **Schedule Model Scoring** action — the thin Action boundary over the PS2-6
5
+ * {@link createScheduledModelScoring} helper (plan PS2-6 / §12). It lets an agent /
6
+ * workflow / UI bind a trained model to write its prediction into a target entity
7
+ * column on a recurring schedule, conversationally: "build a model, write the
8
+ * renewal probability back into the member record, and re-score it monthly."
9
+ *
10
+ * Per CLAUDE.md "Actions are boundaries": this action does NOT do any scheduling /
11
+ * Record-Process-assembly logic. It validates + extracts its params (`ModelID`,
12
+ * `TargetEntityName`, `OutputField`, `ScopeFilter`, `Cadence`, `PrimaryKeyField`,
13
+ * `ValueKind`), delegates to the helper (which creates + saves the scheduled
14
+ * `MJ: Record Processes` row, whose owned `MJ: Scheduled Jobs` row is auto-created
15
+ * on save), then maps the new Record Process id + cron onto output params.
16
+ *
17
+ * `OutputField` is **optional**: supply it for write-back (the prediction is written
18
+ * into that target column and a `MJ: ML Model Scoring Bindings` lineage row is
19
+ * created), or omit it for **generic output** (predictions land in the process run
20
+ * history / `MJ: Process Run Details` only — no write-back column, no binding). The
21
+ * output params reflect which mode ran (`WroteColumn` + a `ScoringBindingID` only when
22
+ * a binding was created).
23
+ *
24
+ * The helper is invoked behind an overridable factory seam so unit tests substitute
25
+ * a mock with no live DB.
26
+ */
27
+ import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
28
+ import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
29
+ import { type ScheduleModelScoringOptions, type ScheduledModelScoringResult, type ScoringCadence, type ScoringValueKind } from '../scheduling/scheduled-model-scoring.js';
30
+ /** The driver-class key this action registers under (matches the metadata row). */
31
+ export declare const SCHEDULE_MODEL_SCORING_DRIVER_CLASS = "PredictiveStudioScheduleModelScoringAction";
32
+ /**
33
+ * The scheduling seam this action depends on — "create + save a scheduled scoring
34
+ * Record Process (and its lineage binding) for these options, give me the saved
35
+ * rows". The production implementation is {@link createScheduledModelScoring}; tests
36
+ * inject a fake.
37
+ */
38
+ export type ScheduleModelScoringFn = (opts: ScheduleModelScoringOptions) => Promise<ScheduledModelScoringResult>;
39
+ /**
40
+ * Binds a trained `MJ: ML Models` to a recurring scoring run: scores the target
41
+ * entity's rows on a cadence (default monthly). The `OutputField` param is optional —
42
+ * supply it to write the prediction into that target column (write-back mode), or omit
43
+ * it for generic output (predictions recorded in `MJ: Process Run Details` only).
44
+ * Outputs: `RecordProcessID` (string), `CronExpression` (string), `WroteColumn`
45
+ * (boolean), and — write-back mode only — `ScoringBindingID` (string).
46
+ */
47
+ export declare class PredictiveStudioScheduleModelScoringAction extends BasePredictiveStudioAction {
48
+ /** @inheritdoc */
49
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
50
+ /**
51
+ * Map the saved Record Process (+ optional scoring binding) onto output params + a
52
+ * human-readable message. Always outputs the Record Process id + cron (the scheduled
53
+ * run) and `WroteColumn` (whether a write-back column was bound). In write-back mode
54
+ * it also outputs `ScoringBindingID` (the lineage row the model-prediction panel /
55
+ * "Models in Production" dashboard read); in generic mode `binding` is `null`, so no
56
+ * `ScoringBindingID` is emitted and the message reflects run-history-only output.
57
+ */
58
+ protected mapResult(params: RunActionParams, result: ScheduledModelScoringResult): ActionResultSimple;
59
+ /**
60
+ * Parse the optional `Cadence` param. A named cadence (`Monthly` / `Weekly` /
61
+ * `Daily`, case-insensitive) is passed through; any other non-empty value is
62
+ * treated as a raw cron expression (`{ cron }`). Returns `undefined` (helper
63
+ * defaults to Monthly) when omitted.
64
+ */
65
+ protected parseCadence(params: RunActionParams): ScoringCadence | undefined;
66
+ /** Parse the optional `ValueKind` param (`score` | `class`); `undefined` defaults to score. */
67
+ protected parseValueKind(params: RunActionParams): ScoringValueKind | undefined;
68
+ /** The scheduling function. Overridable so tests inject a fake with no live DB. */
69
+ protected schedule(): ScheduleModelScoringFn;
70
+ }
71
+ //# sourceMappingURL=schedule-model-scoring.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule-model-scoring.action.d.ts","sourceRoot":"","sources":["../../src/actions/schedule-model-scoring.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAKxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAEL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,uCAAuC,CAAC;AAE/C,mFAAmF;AACnF,eAAO,MAAM,mCAAmC,+CAA+C,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE,2BAA2B,KAAK,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAEjH;;;;;;;GAOG;AACH,qBACa,0CAA2C,SAAQ,0BAA0B;IACxF,kBAAkB;cACF,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2CvF;;;;;;;OAOG;IACH,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,2BAA2B,GAAG,kBAAkB;IAgBrG;;;;;OAKG;IACH,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,GAAG,SAAS;IAY3E,+FAA+F;IAC/F,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS;IAO/E,mFAAmF;IACnF,SAAS,CAAC,QAAQ,IAAI,sBAAsB;CAG7C"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @module actions/schedule-model-scoring.action
3
+ *
4
+ * **Schedule Model Scoring** action — the thin Action boundary over the PS2-6
5
+ * {@link createScheduledModelScoring} helper (plan PS2-6 / §12). It lets an agent /
6
+ * workflow / UI bind a trained model to write its prediction into a target entity
7
+ * column on a recurring schedule, conversationally: "build a model, write the
8
+ * renewal probability back into the member record, and re-score it monthly."
9
+ *
10
+ * Per CLAUDE.md "Actions are boundaries": this action does NOT do any scheduling /
11
+ * Record-Process-assembly logic. It validates + extracts its params (`ModelID`,
12
+ * `TargetEntityName`, `OutputField`, `ScopeFilter`, `Cadence`, `PrimaryKeyField`,
13
+ * `ValueKind`), delegates to the helper (which creates + saves the scheduled
14
+ * `MJ: Record Processes` row, whose owned `MJ: Scheduled Jobs` row is auto-created
15
+ * on save), then maps the new Record Process id + cron onto output params.
16
+ *
17
+ * `OutputField` is **optional**: supply it for write-back (the prediction is written
18
+ * into that target column and a `MJ: ML Model Scoring Bindings` lineage row is
19
+ * created), or omit it for **generic output** (predictions land in the process run
20
+ * history / `MJ: Process Run Details` only — no write-back column, no binding). The
21
+ * output params reflect which mode ran (`WroteColumn` + a `ScoringBindingID` only when
22
+ * a binding was created).
23
+ *
24
+ * The helper is invoked behind an overridable factory seam so unit tests substitute
25
+ * a mock with no live DB.
26
+ */
27
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
28
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ };
33
+ import { RegisterClass } from '@memberjunction/global';
34
+ import { LogError } from '@memberjunction/core';
35
+ import { BaseAction } from '@memberjunction/actions';
36
+ import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
37
+ import { createScheduledModelScoring, } from '../scheduling/scheduled-model-scoring.js';
38
+ /** The driver-class key this action registers under (matches the metadata row). */
39
+ export const SCHEDULE_MODEL_SCORING_DRIVER_CLASS = 'PredictiveStudioScheduleModelScoringAction';
40
+ /**
41
+ * Binds a trained `MJ: ML Models` to a recurring scoring run: scores the target
42
+ * entity's rows on a cadence (default monthly). The `OutputField` param is optional —
43
+ * supply it to write the prediction into that target column (write-back mode), or omit
44
+ * it for generic output (predictions recorded in `MJ: Process Run Details` only).
45
+ * Outputs: `RecordProcessID` (string), `CronExpression` (string), `WroteColumn`
46
+ * (boolean), and — write-back mode only — `ScoringBindingID` (string).
47
+ */
48
+ let PredictiveStudioScheduleModelScoringAction = class PredictiveStudioScheduleModelScoringAction extends BasePredictiveStudioAction {
49
+ /** @inheritdoc */
50
+ async InternalRunAction(params) {
51
+ try {
52
+ const modelId = this.getStringParam(params, 'ModelID');
53
+ if (!modelId) {
54
+ return this.fail('VALIDATION_ERROR', 'ModelID parameter is required');
55
+ }
56
+ const targetEntityName = this.getStringParam(params, 'TargetEntityName');
57
+ if (!targetEntityName) {
58
+ return this.fail('VALIDATION_ERROR', 'TargetEntityName parameter is required');
59
+ }
60
+ // OutputField is OPTIONAL: present → write-back into that column (+ lineage
61
+ // binding); omitted → generic output (predictions in run history only).
62
+ const outputField = this.getStringParam(params, 'OutputField');
63
+ const scopeFilter = this.getStringParam(params, 'ScopeFilter');
64
+ if (!scopeFilter) {
65
+ return this.fail('VALIDATION_ERROR', 'ScopeFilter parameter is required (the SQL predicate selecting rows to score)');
66
+ }
67
+ // Server-side: creating + saving the Record Process is user-scoped (audit + isolation).
68
+ if (!params.ContextUser) {
69
+ return this.fail('VALIDATION_ERROR', 'ContextUser is required to schedule model scoring (server-side data access is user-scoped)');
70
+ }
71
+ const result = await this.schedule()({
72
+ modelId,
73
+ targetEntityName,
74
+ outputField,
75
+ scope: { filter: scopeFilter },
76
+ cadence: this.parseCadence(params),
77
+ primaryKeyField: this.getStringParam(params, 'PrimaryKeyField'),
78
+ valueKind: this.parseValueKind(params),
79
+ name: this.getStringParam(params, 'Name'),
80
+ timezone: this.getStringParam(params, 'Timezone'),
81
+ contextUser: params.ContextUser,
82
+ provider: params.Provider,
83
+ });
84
+ return this.mapResult(params, result);
85
+ }
86
+ catch (e) {
87
+ LogError(e);
88
+ return this.fail('SCHEDULE_FAILED', `Scheduling model scoring failed: ${e instanceof Error ? e.message : String(e)}`);
89
+ }
90
+ }
91
+ /**
92
+ * Map the saved Record Process (+ optional scoring binding) onto output params + a
93
+ * human-readable message. Always outputs the Record Process id + cron (the scheduled
94
+ * run) and `WroteColumn` (whether a write-back column was bound). In write-back mode
95
+ * it also outputs `ScoringBindingID` (the lineage row the model-prediction panel /
96
+ * "Models in Production" dashboard read); in generic mode `binding` is `null`, so no
97
+ * `ScoringBindingID` is emitted and the message reflects run-history-only output.
98
+ */
99
+ mapResult(params, result) {
100
+ const { recordProcess: rp, binding } = result;
101
+ this.addOutputParam(params, 'RecordProcessID', rp.ID);
102
+ this.addOutputParam(params, 'CronExpression', rp.CronExpression);
103
+ this.addOutputParam(params, 'WroteColumn', binding !== null);
104
+ if (binding !== null) {
105
+ this.addOutputParam(params, 'ScoringBindingID', binding.ID);
106
+ }
107
+ const outcome = binding !== null
108
+ ? 'it will score and write back on its cadence.'
109
+ : 'it will score on its cadence, recording predictions in the process run history.';
110
+ return this.ok(params, `Scheduled scoring Record Process '${rp.Name}' (${rp.CronExpression}); ${outcome}`);
111
+ }
112
+ // ----- param parsing -------------------------------------------------------
113
+ /**
114
+ * Parse the optional `Cadence` param. A named cadence (`Monthly` / `Weekly` /
115
+ * `Daily`, case-insensitive) is passed through; any other non-empty value is
116
+ * treated as a raw cron expression (`{ cron }`). Returns `undefined` (helper
117
+ * defaults to Monthly) when omitted.
118
+ */
119
+ parseCadence(params) {
120
+ const raw = this.getStringParam(params, 'Cadence');
121
+ if (!raw) {
122
+ return undefined;
123
+ }
124
+ const named = raw.trim().toLowerCase();
125
+ if (named === 'monthly')
126
+ return 'Monthly';
127
+ if (named === 'weekly')
128
+ return 'Weekly';
129
+ if (named === 'daily')
130
+ return 'Daily';
131
+ return { cron: raw };
132
+ }
133
+ /** Parse the optional `ValueKind` param (`score` | `class`); `undefined` defaults to score. */
134
+ parseValueKind(params) {
135
+ const raw = this.getStringParam(params, 'ValueKind');
136
+ return raw?.trim().toLowerCase() === 'class' ? 'class' : undefined;
137
+ }
138
+ // ----- injectable scheduling seam (overridden in tests) --------------------
139
+ /** The scheduling function. Overridable so tests inject a fake with no live DB. */
140
+ schedule() {
141
+ return createScheduledModelScoring;
142
+ }
143
+ };
144
+ PredictiveStudioScheduleModelScoringAction = __decorate([
145
+ RegisterClass(BaseAction, SCHEDULE_MODEL_SCORING_DRIVER_CLASS)
146
+ ], PredictiveStudioScheduleModelScoringAction);
147
+ export { PredictiveStudioScheduleModelScoringAction };
148
+ //# sourceMappingURL=schedule-model-scoring.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule-model-scoring.action.js","sourceRoot":"","sources":["../../src/actions/schedule-model-scoring.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;;;;;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EACL,2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,0CAA0C,CAmGtD"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @module actions/score-record-set.action
3
+ *
4
+ * **Score Record Set** action — the thin Action boundary over the scoring work
5
+ * type {@link MLModelInferenceProcessor} (plan §10 / §12). It lets an agent /
6
+ * workflow / UI score a set of records with a trained model and either read the
7
+ * predictions back ephemerally or confirm a write-back.
8
+ *
9
+ * Per CLAUDE.md "Actions are boundaries": this action does NOT do any scoring
10
+ * logic. It validates `ModelID` + `Scope`, parses the optional `WriteBack`
11
+ * directive, delegates to an injectable {@link IScoreRecordSetRunner} (whose
12
+ * production implementation resolves the scope into records and drives the
13
+ * `MLModelInferenceProcessor`'s batch path), then maps `ScoredCount` +
14
+ * (ephemeral) `Predictions` / write-back confirmation onto output params.
15
+ *
16
+ * The runner is an injectable seam so unit tests substitute a mock with no live DB
17
+ * and no sidecar.
18
+ */
19
+ import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
20
+ import { type UserInfo, type IMetadataProvider } from '@memberjunction/core';
21
+ import { BasePredictiveStudioAction, type JsonObject } from './base-predictive-studio.action.js';
22
+ /** The driver-class key this action registers under (matches the metadata row). */
23
+ export declare const SCORE_RECORD_SET_DRIVER_CLASS = "PredictiveStudioScoreRecordSetAction";
24
+ /**
25
+ * The scope of records to score. Mirrors the Record Set Processing scope shapes
26
+ * (records / view / list / filter / single). Exactly one shape should be
27
+ * populated; the runner resolves it into a concrete record set.
28
+ */
29
+ export interface ScoringScope {
30
+ /** Explicit record refs / primary keys to score. */
31
+ records?: Array<string | JsonObject>;
32
+ /** A `User Views` id whose rows are scored. */
33
+ viewId?: string;
34
+ /** A `Lists` id whose member rows are scored. */
35
+ listId?: string;
36
+ /** An entity name + SQL filter selecting the rows to score. */
37
+ filter?: {
38
+ entityName: string;
39
+ extraFilter?: string;
40
+ maxRows?: number;
41
+ };
42
+ /** A single record (entity + primary key) to score. */
43
+ single?: {
44
+ entityName: string;
45
+ primaryKey: JsonObject;
46
+ };
47
+ }
48
+ /**
49
+ * The optional write-back directive. `true` enables write-back with the model's
50
+ * default mapping; an object supplies an explicit `OutputMapping` (target column /
51
+ * child record) handled by the write-back wrapper in the higher Record Process
52
+ * layer.
53
+ */
54
+ export type WriteBackDirective = boolean | {
55
+ OutputMapping: JsonObject;
56
+ };
57
+ /** The model id + resolved scope + write-back directive handed to the runner. */
58
+ export interface ScoreRecordSetRequest {
59
+ modelId: string;
60
+ scope: ScoringScope;
61
+ writeBack?: WriteBackDirective;
62
+ /**
63
+ * When `true`, predictions are computed but NOT persisted — even if `writeBack`
64
+ * supplies an `OutputMapping`. The run summary still reports the scored/failed
65
+ * counts and surfaces the (ephemeral) predictions, but `wroteBack` stays `false`.
66
+ * Mirrors the first-class `ProcessRun.DryRun` flag in the Record Set Processing
67
+ * substrate so "preview without mutating" works the same way through this action.
68
+ */
69
+ dryRun?: boolean;
70
+ contextUser?: UserInfo;
71
+ provider?: IMetadataProvider;
72
+ }
73
+ /** A single ephemeral prediction surfaced when write-back is NOT requested. */
74
+ export interface EphemeralPrediction {
75
+ /** The scored record's id (when known). */
76
+ recordId?: string;
77
+ /** Numeric model output (probability or value). */
78
+ score: number;
79
+ /** Predicted class (classification only). */
80
+ class?: string;
81
+ }
82
+ /** The runner's result — counts + (ephemeral) predictions or write-back confirmation. */
83
+ export interface ScoreRecordSetResult {
84
+ /** Number of records successfully scored. */
85
+ scoredCount: number;
86
+ /** Number of records that failed to score. */
87
+ failedCount: number;
88
+ /** Number of records the processor skipped (e.g. ineligible / filtered out). */
89
+ skippedCount: number;
90
+ /** Ephemeral predictions (present when write-back was NOT requested). */
91
+ predictions?: EphemeralPrediction[];
92
+ /** True when the runner applied a write-back instead of returning predictions. */
93
+ wroteBack: boolean;
94
+ }
95
+ /**
96
+ * The single scoring-execution seam this action depends on — "score this scope
97
+ * with this model, give me the counts + predictions / write-back confirmation".
98
+ * The production implementation ({@link ProductionScoreRecordSetRunner}) resolves
99
+ * the scope into records and drives the {@link MLModelInferenceProcessor}; tests
100
+ * inject a deterministic fake.
101
+ */
102
+ export interface IScoreRecordSetRunner {
103
+ /** Score the requested scope and return the run summary. */
104
+ run(request: ScoreRecordSetRequest): Promise<ScoreRecordSetResult>;
105
+ }
106
+ /**
107
+ * Scores a set of records with a trained `MJ: ML Models`. Outputs: `ScoredCount`
108
+ * (number), `Predictions` (JSON array, ephemeral only), `WroteBack` (boolean).
109
+ */
110
+ export declare class PredictiveStudioScoreRecordSetAction extends BasePredictiveStudioAction {
111
+ /** @inheritdoc */
112
+ protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
113
+ /** Map the runner result onto output params + a human-readable message. */
114
+ protected mapResult(params: RunActionParams, result: ScoreRecordSetResult): ActionResultSimple;
115
+ /** Parse the `Scope` JSON param into a {@link ScoringScope}. */
116
+ protected parseScope(params: RunActionParams): ScoringScope | undefined;
117
+ /**
118
+ * Whether the scope populates EXACTLY ONE selector. More than one is ambiguous
119
+ * (which would the runner honor?) and is rejected the same as none, so the
120
+ * caller's intent is always unambiguous.
121
+ */
122
+ protected scopeHasTarget(scope: ScoringScope): boolean;
123
+ /** Count how many of the mutually-exclusive scope selectors are populated. */
124
+ protected countScopeSelectors(scope: ScoringScope): number;
125
+ /**
126
+ * Parse the optional `WriteBack` param. Accepts a boolean, or a JSON object with
127
+ * an `OutputMapping`. Returns `undefined` when not requested.
128
+ */
129
+ protected parseWriteBack(params: RunActionParams): WriteBackDirective | undefined;
130
+ /** Construct the production scoring runner. Overridable so tests inject a mock. */
131
+ protected createRunner(): IScoreRecordSetRunner;
132
+ }
133
+ //# sourceMappingURL=score-record-set.action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score-record-set.action.d.ts","sourceRoot":"","sources":["../../src/actions/score-record-set.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,EAAY,KAAK,QAAQ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M,CAAC;CAChB;AAED,yFAAyF;AACzF,MAAM,WAAW,oBAAoB;IACnC,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,gFAAgF;IAChF,YAAY,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,WAAW,CAAC,EAAE,mBAAmB,EAAE,CAAC;IACpC,kFAAkF;IAClF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB;IACpC,4DAA4D;IAC5D,GAAG,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpE;AAED;;;GAGG;AACH,qBACa,oCAAqC,SAAQ,0BAA0B;IAClF,kBAAkB;cACF,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA8CvF,2EAA2E;IAC3E,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,oBAAoB,GAAG,kBAAkB;IAc9F,gEAAgE;IAChE,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,YAAY,GAAG,SAAS;IAKvE;;;;OAIG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAItD,8EAA8E;IAC9E,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM;IAU1D;;;OAGG;IACH,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,eAAe,GAAG,kBAAkB,GAAG,SAAS;IAWjF,mFAAmF;IACnF,SAAS,CAAC,YAAY,IAAI,qBAAqB;CAGhD"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @module actions/score-record-set.action
3
+ *
4
+ * **Score Record Set** action — the thin Action boundary over the scoring work
5
+ * type {@link MLModelInferenceProcessor} (plan §10 / §12). It lets an agent /
6
+ * workflow / UI score a set of records with a trained model and either read the
7
+ * predictions back ephemerally or confirm a write-back.
8
+ *
9
+ * Per CLAUDE.md "Actions are boundaries": this action does NOT do any scoring
10
+ * logic. It validates `ModelID` + `Scope`, parses the optional `WriteBack`
11
+ * directive, delegates to an injectable {@link IScoreRecordSetRunner} (whose
12
+ * production implementation resolves the scope into records and drives the
13
+ * `MLModelInferenceProcessor`'s batch path), then maps `ScoredCount` +
14
+ * (ephemeral) `Predictions` / write-back confirmation onto output params.
15
+ *
16
+ * The runner is an injectable seam so unit tests substitute a mock with no live DB
17
+ * and no sidecar.
18
+ */
19
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
20
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
22
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
23
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
24
+ };
25
+ import { RegisterClass } from '@memberjunction/global';
26
+ import { LogError } from '@memberjunction/core';
27
+ import { BaseAction } from '@memberjunction/actions';
28
+ import { BasePredictiveStudioAction } from './base-predictive-studio.action.js';
29
+ import { ProductionScoreRecordSetRunner } from './score-record-set.runner.js';
30
+ /** The driver-class key this action registers under (matches the metadata row). */
31
+ export const SCORE_RECORD_SET_DRIVER_CLASS = 'PredictiveStudioScoreRecordSetAction';
32
+ /**
33
+ * Scores a set of records with a trained `MJ: ML Models`. Outputs: `ScoredCount`
34
+ * (number), `Predictions` (JSON array, ephemeral only), `WroteBack` (boolean).
35
+ */
36
+ let PredictiveStudioScoreRecordSetAction = class PredictiveStudioScoreRecordSetAction extends BasePredictiveStudioAction {
37
+ /** @inheritdoc */
38
+ async InternalRunAction(params) {
39
+ try {
40
+ const modelId = this.getStringParam(params, 'ModelID');
41
+ if (!modelId) {
42
+ return this.fail('VALIDATION_ERROR', 'ModelID parameter is required');
43
+ }
44
+ // Scoring runs server-side and resolves/scores records on behalf of a user
45
+ // — a ContextUser is mandatory for data isolation + audit (CLAUDE.md). Fail
46
+ // loudly rather than letting the runner force-cast an absent user.
47
+ if (!params.ContextUser) {
48
+ return this.fail('VALIDATION_ERROR', 'ContextUser is required to score records (server-side data access is user-scoped)');
49
+ }
50
+ const scope = this.parseScope(params);
51
+ if (!scope) {
52
+ return this.fail('VALIDATION_ERROR', 'Scope parameter is required and must be a JSON object describing records/view/list/filter/single');
53
+ }
54
+ if (!this.scopeHasTarget(scope)) {
55
+ return this.fail('VALIDATION_ERROR', 'Scope must populate exactly one of: records, viewId, listId, filter, single');
56
+ }
57
+ const writeBack = this.parseWriteBack(params);
58
+ const runner = this.createRunner();
59
+ const result = await runner.run({
60
+ modelId,
61
+ scope,
62
+ writeBack,
63
+ contextUser: params.ContextUser,
64
+ provider: params.Provider,
65
+ });
66
+ return this.mapResult(params, result);
67
+ }
68
+ catch (e) {
69
+ LogError(e);
70
+ return this.fail('SCORING_FAILED', `Scoring failed: ${e instanceof Error ? e.message : String(e)}`);
71
+ }
72
+ }
73
+ /** Map the runner result onto output params + a human-readable message. */
74
+ mapResult(params, result) {
75
+ this.addOutputParam(params, 'ScoredCount', result.scoredCount);
76
+ this.addOutputParam(params, 'FailedCount', result.failedCount);
77
+ this.addOutputParam(params, 'SkippedCount', result.skippedCount);
78
+ this.addOutputParam(params, 'WroteBack', result.wroteBack);
79
+ if (result.wroteBack) {
80
+ return this.ok(params, `Scored ${result.scoredCount} record(s); predictions written back to the target.`);
81
+ }
82
+ this.addOutputParam(params, 'Predictions', JSON.stringify(result.predictions ?? []));
83
+ return this.ok(params, `Scored ${result.scoredCount} record(s); returned ephemeral predictions.`);
84
+ }
85
+ // ----- param parsing -------------------------------------------------------
86
+ /** Parse the `Scope` JSON param into a {@link ScoringScope}. */
87
+ parseScope(params) {
88
+ const raw = this.getJsonObjectParam(params, 'Scope');
89
+ return raw ? raw : undefined;
90
+ }
91
+ /**
92
+ * Whether the scope populates EXACTLY ONE selector. More than one is ambiguous
93
+ * (which would the runner honor?) and is rejected the same as none, so the
94
+ * caller's intent is always unambiguous.
95
+ */
96
+ scopeHasTarget(scope) {
97
+ return this.countScopeSelectors(scope) === 1;
98
+ }
99
+ /** Count how many of the mutually-exclusive scope selectors are populated. */
100
+ countScopeSelectors(scope) {
101
+ let count = 0;
102
+ if (Array.isArray(scope.records) && scope.records.length > 0)
103
+ count++;
104
+ if (scope.viewId)
105
+ count++;
106
+ if (scope.listId)
107
+ count++;
108
+ if (scope.filter)
109
+ count++;
110
+ if (scope.single)
111
+ count++;
112
+ return count;
113
+ }
114
+ /**
115
+ * Parse the optional `WriteBack` param. Accepts a boolean, or a JSON object with
116
+ * an `OutputMapping`. Returns `undefined` when not requested.
117
+ */
118
+ parseWriteBack(params) {
119
+ const obj = this.getJsonObjectParam(params, 'WriteBack');
120
+ if (obj && 'OutputMapping' in obj && obj.OutputMapping && typeof obj.OutputMapping === 'object') {
121
+ return { OutputMapping: obj.OutputMapping };
122
+ }
123
+ const flag = this.getBooleanParam(params, 'WriteBack', false);
124
+ return flag ? true : undefined;
125
+ }
126
+ // ----- injectable runner seam (overridden in tests) ------------------------
127
+ /** Construct the production scoring runner. Overridable so tests inject a mock. */
128
+ createRunner() {
129
+ return new ProductionScoreRecordSetRunner();
130
+ }
131
+ };
132
+ PredictiveStudioScoreRecordSetAction = __decorate([
133
+ RegisterClass(BaseAction, SCORE_RECORD_SET_DRIVER_CLASS)
134
+ ], PredictiveStudioScoreRecordSetAction);
135
+ export { PredictiveStudioScoreRecordSetAction };
136
+ //# sourceMappingURL=score-record-set.action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"score-record-set.action.js","sourceRoot":"","sources":["../../src/actions/score-record-set.action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;AAGH,OAAO,EAAE,aAAa,EAA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