@memberjunction/predictive-studio 6.2.2 → 6.3.0-edge.1

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 (391) hide show
  1. package/README.md +16 -11
  2. package/dist/actions/base-predictive-studio.action.d.ts +7 -0
  3. package/dist/actions/base-predictive-studio.action.d.ts.map +1 -1
  4. package/dist/actions/base-predictive-studio.action.js +22 -0
  5. package/dist/actions/base-predictive-studio.action.js.map +1 -1
  6. package/dist/actions/driver-classes.d.ts +2 -0
  7. package/dist/actions/driver-classes.d.ts.map +1 -1
  8. package/dist/actions/driver-classes.js +2 -0
  9. package/dist/actions/driver-classes.js.map +1 -1
  10. package/dist/actions/evaluate-drift.action.d.ts +100 -0
  11. package/dist/actions/evaluate-drift.action.d.ts.map +1 -0
  12. package/dist/actions/evaluate-drift.action.js +512 -0
  13. package/dist/actions/evaluate-drift.action.js.map +1 -0
  14. package/dist/actions/index.d.ts +3 -0
  15. package/dist/actions/index.d.ts.map +1 -1
  16. package/dist/actions/index.js +7 -0
  17. package/dist/actions/index.js.map +1 -1
  18. package/dist/actions/migrate-pipelines.action.d.ts +19 -0
  19. package/dist/actions/migrate-pipelines.action.d.ts.map +1 -0
  20. package/dist/actions/migrate-pipelines.action.js +51 -0
  21. package/dist/actions/migrate-pipelines.action.js.map +1 -0
  22. package/dist/actions/promote-model.action.d.ts +12 -1
  23. package/dist/actions/promote-model.action.d.ts.map +1 -1
  24. package/dist/actions/promote-model.action.js +7 -2
  25. package/dist/actions/promote-model.action.js.map +1 -1
  26. package/dist/actions/promote-model.gate.d.ts +31 -2
  27. package/dist/actions/promote-model.gate.d.ts.map +1 -1
  28. package/dist/actions/promote-model.gate.js +84 -5
  29. package/dist/actions/promote-model.gate.js.map +1 -1
  30. package/dist/actions/run-experiment.action.d.ts.map +1 -1
  31. package/dist/actions/run-experiment.action.js +5 -4
  32. package/dist/actions/run-experiment.action.js.map +1 -1
  33. package/dist/actions/schedule-model-scoring.action.js +2 -2
  34. package/dist/actions/schedule-model-scoring.action.js.map +1 -1
  35. package/dist/actions/score-record-set.action.js +1 -1
  36. package/dist/actions/score-record-set.action.js.map +1 -1
  37. package/dist/actions/score-record-set.runner.d.ts +2 -2
  38. package/dist/actions/score-record-set.runner.js +3 -3
  39. package/dist/actions/score-record-set.runner.js.map +1 -1
  40. package/dist/actions/train-model.action.d.ts +28 -25
  41. package/dist/actions/train-model.action.d.ts.map +1 -1
  42. package/dist/actions/train-model.action.js +50 -39
  43. package/dist/actions/train-model.action.js.map +1 -1
  44. package/dist/agent/index.d.ts +1 -1
  45. package/dist/agent/index.js +1 -1
  46. package/dist/agent/modeling-plan-to-pipeline.d.ts +0 -2
  47. package/dist/agent/modeling-plan-to-pipeline.d.ts.map +1 -1
  48. package/dist/agent/modeling-plan-to-pipeline.js +30 -39
  49. package/dist/agent/modeling-plan-to-pipeline.js.map +1 -1
  50. package/dist/agent/pipeline-builder-agent.d.ts +47 -18
  51. package/dist/agent/pipeline-builder-agent.d.ts.map +1 -1
  52. package/dist/agent/pipeline-builder-agent.js +161 -92
  53. package/dist/agent/pipeline-builder-agent.js.map +1 -1
  54. package/dist/agent/pipeline-builder.d.ts +178 -56
  55. package/dist/agent/pipeline-builder.d.ts.map +1 -1
  56. package/dist/agent/pipeline-builder.js +333 -234
  57. package/dist/agent/pipeline-builder.js.map +1 -1
  58. package/dist/experiment/budget.d.ts +61 -0
  59. package/dist/experiment/budget.d.ts.map +1 -0
  60. package/dist/experiment/budget.js +72 -0
  61. package/dist/experiment/budget.js.map +1 -0
  62. package/dist/experiment/experiment-orchestrator.d.ts +43 -7
  63. package/dist/experiment/experiment-orchestrator.d.ts.map +1 -1
  64. package/dist/experiment/experiment-orchestrator.js +130 -33
  65. package/dist/experiment/experiment-orchestrator.js.map +1 -1
  66. package/dist/experiment/index.d.ts +2 -0
  67. package/dist/experiment/index.d.ts.map +1 -1
  68. package/dist/experiment/index.js +2 -0
  69. package/dist/experiment/index.js.map +1 -1
  70. package/dist/experiment/leaderboard.d.ts +15 -15
  71. package/dist/experiment/leaderboard.d.ts.map +1 -1
  72. package/dist/experiment/leaderboard.js +44 -18
  73. package/dist/experiment/leaderboard.js.map +1 -1
  74. package/dist/experiment/scores.d.ts +32 -0
  75. package/dist/experiment/scores.d.ts.map +1 -0
  76. package/dist/experiment/scores.js +62 -0
  77. package/dist/experiment/scores.js.map +1 -0
  78. package/dist/experiment/seams.d.ts +23 -20
  79. package/dist/experiment/seams.d.ts.map +1 -1
  80. package/dist/experiment/seams.js +54 -56
  81. package/dist/experiment/seams.js.map +1 -1
  82. package/dist/experiment/types.d.ts +55 -10
  83. package/dist/experiment/types.d.ts.map +1 -1
  84. package/dist/experiment/types.js.map +1 -1
  85. package/dist/feature-assembly/as-of/as-of-assembler.d.ts +412 -0
  86. package/dist/feature-assembly/as-of/as-of-assembler.d.ts.map +1 -0
  87. package/dist/feature-assembly/as-of/as-of-assembler.js +1239 -0
  88. package/dist/feature-assembly/as-of/as-of-assembler.js.map +1 -0
  89. package/dist/feature-assembly/as-of/feature-resolution.d.ts +84 -0
  90. package/dist/feature-assembly/as-of/feature-resolution.d.ts.map +1 -0
  91. package/dist/feature-assembly/as-of/feature-resolution.js +229 -0
  92. package/dist/feature-assembly/as-of/feature-resolution.js.map +1 -0
  93. package/dist/feature-assembly/as-of/index.d.ts +15 -0
  94. package/dist/feature-assembly/as-of/index.d.ts.map +1 -0
  95. package/dist/feature-assembly/as-of/index.js +15 -0
  96. package/dist/feature-assembly/as-of/index.js.map +1 -0
  97. package/dist/feature-assembly/as-of/read-by-keys.d.ts +30 -0
  98. package/dist/feature-assembly/as-of/read-by-keys.d.ts.map +1 -0
  99. package/dist/feature-assembly/as-of/read-by-keys.js +51 -0
  100. package/dist/feature-assembly/as-of/read-by-keys.js.map +1 -0
  101. package/dist/feature-assembly/as-of/record-history.d.ts +256 -0
  102. package/dist/feature-assembly/as-of/record-history.d.ts.map +1 -0
  103. package/dist/feature-assembly/as-of/record-history.js +505 -0
  104. package/dist/feature-assembly/as-of/record-history.js.map +1 -0
  105. package/dist/feature-assembly/as-of/refusal.d.ts +19 -0
  106. package/dist/feature-assembly/as-of/refusal.d.ts.map +1 -0
  107. package/dist/feature-assembly/as-of/refusal.js +13 -0
  108. package/dist/feature-assembly/as-of/refusal.js.map +1 -0
  109. package/dist/feature-assembly/as-of/series-features.d.ts +65 -0
  110. package/dist/feature-assembly/as-of/series-features.d.ts.map +1 -0
  111. package/dist/feature-assembly/as-of/series-features.js +97 -0
  112. package/dist/feature-assembly/as-of/series-features.js.map +1 -0
  113. package/dist/feature-assembly/as-of/windowed-aggregate.d.ts +36 -0
  114. package/dist/feature-assembly/as-of/windowed-aggregate.d.ts.map +1 -0
  115. package/dist/feature-assembly/as-of/windowed-aggregate.js +99 -0
  116. package/dist/feature-assembly/as-of/windowed-aggregate.js.map +1 -0
  117. package/dist/feature-assembly/as-of.d.ts +1 -9
  118. package/dist/feature-assembly/as-of.d.ts.map +1 -1
  119. package/dist/feature-assembly/as-of.js +2 -19
  120. package/dist/feature-assembly/as-of.js.map +1 -1
  121. package/dist/feature-assembly/assembly-metadata.d.ts +34 -0
  122. package/dist/feature-assembly/assembly-metadata.d.ts.map +1 -0
  123. package/dist/feature-assembly/assembly-metadata.js +26 -0
  124. package/dist/feature-assembly/assembly-metadata.js.map +1 -0
  125. package/dist/feature-assembly/data-access.d.ts +21 -2
  126. package/dist/feature-assembly/data-access.d.ts.map +1 -1
  127. package/dist/feature-assembly/data-access.js +14 -0
  128. package/dist/feature-assembly/data-access.js.map +1 -1
  129. package/dist/feature-assembly/feature-assembly-executor.d.ts.map +1 -1
  130. package/dist/feature-assembly/feature-assembly-executor.js +5 -2
  131. package/dist/feature-assembly/feature-assembly-executor.js.map +1 -1
  132. package/dist/feature-assembly/index.d.ts +3 -0
  133. package/dist/feature-assembly/index.d.ts.map +1 -1
  134. package/dist/feature-assembly/index.js +3 -0
  135. package/dist/feature-assembly/index.js.map +1 -1
  136. package/dist/feature-assembly/leakage-guard.d.ts +1 -1
  137. package/dist/feature-assembly/leakage-guard.js +1 -1
  138. package/dist/feature-assembly/read-policy.d.ts +27 -0
  139. package/dist/feature-assembly/read-policy.d.ts.map +1 -0
  140. package/dist/feature-assembly/read-policy.js +63 -0
  141. package/dist/feature-assembly/read-policy.js.map +1 -0
  142. package/dist/feature-pipelines/feature-pipeline-engine.d.ts.map +1 -1
  143. package/dist/feature-pipelines/feature-pipeline-engine.js +3 -1
  144. package/dist/feature-pipelines/feature-pipeline-engine.js.map +1 -1
  145. package/dist/index.d.ts +5 -2
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +16 -4
  148. package/dist/index.js.map +1 -1
  149. package/dist/maintenance/index.d.ts +1 -0
  150. package/dist/maintenance/index.d.ts.map +1 -1
  151. package/dist/maintenance/index.js +1 -0
  152. package/dist/maintenance/index.js.map +1 -1
  153. package/dist/maintenance/maintenance-engine.d.ts +16 -19
  154. package/dist/maintenance/maintenance-engine.d.ts.map +1 -1
  155. package/dist/maintenance/maintenance-engine.js +53 -53
  156. package/dist/maintenance/maintenance-engine.js.map +1 -1
  157. package/dist/maintenance/metrics.d.ts +19 -15
  158. package/dist/maintenance/metrics.d.ts.map +1 -1
  159. package/dist/maintenance/metrics.js +29 -24
  160. package/dist/maintenance/metrics.js.map +1 -1
  161. package/dist/maintenance/psi-drift-detector.d.ts +246 -0
  162. package/dist/maintenance/psi-drift-detector.d.ts.map +1 -0
  163. package/dist/maintenance/psi-drift-detector.js +1002 -0
  164. package/dist/maintenance/psi-drift-detector.js.map +1 -0
  165. package/dist/maintenance/types.d.ts +11 -2
  166. package/dist/maintenance/types.d.ts.map +1 -1
  167. package/dist/maintenance/types.js.map +1 -1
  168. package/dist/migration/index.d.ts +8 -0
  169. package/dist/migration/index.d.ts.map +1 -0
  170. package/dist/migration/index.js +8 -0
  171. package/dist/migration/index.js.map +1 -0
  172. package/dist/migration/legacy-pipeline-migration.d.ts +138 -0
  173. package/dist/migration/legacy-pipeline-migration.d.ts.map +1 -0
  174. package/dist/migration/legacy-pipeline-migration.js +273 -0
  175. package/dist/migration/legacy-pipeline-migration.js.map +1 -0
  176. package/dist/operations/delegation.d.ts +58 -46
  177. package/dist/operations/delegation.d.ts.map +1 -1
  178. package/dist/operations/delegation.js +90 -77
  179. package/dist/operations/delegation.js.map +1 -1
  180. package/dist/operations/promote-model.operation.d.ts +2 -2
  181. package/dist/operations/promote-model.operation.d.ts.map +1 -1
  182. package/dist/operations/promote-model.operation.js +6 -2
  183. package/dist/operations/promote-model.operation.js.map +1 -1
  184. package/dist/operations/refusals.d.ts +5 -0
  185. package/dist/operations/refusals.d.ts.map +1 -1
  186. package/dist/operations/refusals.js +26 -1
  187. package/dist/operations/refusals.js.map +1 -1
  188. package/dist/operations/start-experiment-session.operation.js +3 -3
  189. package/dist/operations/train-model.mapping.d.ts +91 -0
  190. package/dist/operations/train-model.mapping.d.ts.map +1 -0
  191. package/dist/operations/train-model.mapping.js +145 -0
  192. package/dist/operations/train-model.mapping.js.map +1 -0
  193. package/dist/operations/train-model.operation.d.ts +14 -9
  194. package/dist/operations/train-model.operation.d.ts.map +1 -1
  195. package/dist/operations/train-model.operation.js +30 -51
  196. package/dist/operations/train-model.operation.js.map +1 -1
  197. package/dist/prediction-unit/decision-date-advance.d.ts +46 -0
  198. package/dist/prediction-unit/decision-date-advance.d.ts.map +1 -0
  199. package/dist/prediction-unit/decision-date-advance.js +79 -0
  200. package/dist/prediction-unit/decision-date-advance.js.map +1 -0
  201. package/dist/prediction-unit/index.d.ts +12 -0
  202. package/dist/prediction-unit/index.d.ts.map +1 -0
  203. package/dist/prediction-unit/index.js +12 -0
  204. package/dist/prediction-unit/index.js.map +1 -0
  205. package/dist/prediction-unit/target-validation.d.ts +21 -0
  206. package/dist/prediction-unit/target-validation.d.ts.map +1 -0
  207. package/dist/prediction-unit/target-validation.js +54 -0
  208. package/dist/prediction-unit/target-validation.js.map +1 -0
  209. package/dist/prediction-unit/unit-row-reader.d.ts +108 -0
  210. package/dist/prediction-unit/unit-row-reader.d.ts.map +1 -0
  211. package/dist/prediction-unit/unit-row-reader.js +348 -0
  212. package/dist/prediction-unit/unit-row-reader.js.map +1 -0
  213. package/dist/prediction-unit/unit-store.d.ts +28 -0
  214. package/dist/prediction-unit/unit-store.d.ts.map +1 -0
  215. package/dist/prediction-unit/unit-store.js +41 -0
  216. package/dist/prediction-unit/unit-store.js.map +1 -0
  217. package/dist/prediction-unit/unit-versioning.d.ts +43 -0
  218. package/dist/prediction-unit/unit-versioning.d.ts.map +1 -0
  219. package/dist/prediction-unit/unit-versioning.js +71 -0
  220. package/dist/prediction-unit/unit-versioning.js.map +1 -0
  221. package/dist/protocol/index.d.ts +9 -0
  222. package/dist/protocol/index.d.ts.map +1 -0
  223. package/dist/protocol/index.js +9 -0
  224. package/dist/protocol/index.js.map +1 -0
  225. package/dist/protocol/protocol-defaults.d.ts +37 -0
  226. package/dist/protocol/protocol-defaults.d.ts.map +1 -0
  227. package/dist/protocol/protocol-defaults.js +59 -0
  228. package/dist/protocol/protocol-defaults.js.map +1 -0
  229. package/dist/protocol/protocol-versioning.d.ts +46 -0
  230. package/dist/protocol/protocol-versioning.d.ts.map +1 -0
  231. package/dist/protocol/protocol-versioning.js +48 -0
  232. package/dist/protocol/protocol-versioning.js.map +1 -0
  233. package/dist/protocol/search-guard.d.ts +45 -0
  234. package/dist/protocol/search-guard.d.ts.map +1 -0
  235. package/dist/protocol/search-guard.js +50 -0
  236. package/dist/protocol/search-guard.js.map +1 -0
  237. package/dist/scoring/artifact-loader.d.ts +5 -32
  238. package/dist/scoring/artifact-loader.d.ts.map +1 -1
  239. package/dist/scoring/artifact-loader.js +4 -59
  240. package/dist/scoring/artifact-loader.js.map +1 -1
  241. package/dist/scoring/auto-train.d.ts +25 -5
  242. package/dist/scoring/auto-train.d.ts.map +1 -1
  243. package/dist/scoring/auto-train.js +48 -31
  244. package/dist/scoring/auto-train.js.map +1 -1
  245. package/dist/scoring/index.d.ts +3 -0
  246. package/dist/scoring/index.d.ts.map +1 -1
  247. package/dist/scoring/index.js +3 -0
  248. package/dist/scoring/index.js.map +1 -1
  249. package/dist/scoring/ml-model-inference-processor.d.ts +137 -10
  250. package/dist/scoring/ml-model-inference-processor.d.ts.map +1 -1
  251. package/dist/scoring/ml-model-inference-processor.js +383 -40
  252. package/dist/scoring/ml-model-inference-processor.js.map +1 -1
  253. package/dist/scoring/model-readiness.d.ts +45 -0
  254. package/dist/scoring/model-readiness.d.ts.map +1 -1
  255. package/dist/scoring/model-readiness.js +49 -0
  256. package/dist/scoring/model-readiness.js.map +1 -1
  257. package/dist/scoring/register.d.ts +8 -3
  258. package/dist/scoring/register.d.ts.map +1 -1
  259. package/dist/scoring/register.js +28 -4
  260. package/dist/scoring/register.js.map +1 -1
  261. package/dist/scoring/seams.d.ts +18 -2
  262. package/dist/scoring/seams.d.ts.map +1 -1
  263. package/dist/scoring/seams.js +35 -10
  264. package/dist/scoring/seams.js.map +1 -1
  265. package/dist/scoring/shadow-scoring.d.ts +245 -0
  266. package/dist/scoring/shadow-scoring.d.ts.map +1 -0
  267. package/dist/scoring/shadow-scoring.js +510 -0
  268. package/dist/scoring/shadow-scoring.js.map +1 -0
  269. package/dist/scoring/startup-register.d.ts +3 -3
  270. package/dist/scoring/startup-register.d.ts.map +1 -1
  271. package/dist/scoring/startup-register.js +10 -4
  272. package/dist/scoring/startup-register.js.map +1 -1
  273. package/dist/scoring/storage-provider-artifact-loader.d.ts +14 -0
  274. package/dist/scoring/storage-provider-artifact-loader.d.ts.map +1 -0
  275. package/dist/scoring/storage-provider-artifact-loader.js +47 -0
  276. package/dist/scoring/storage-provider-artifact-loader.js.map +1 -0
  277. package/dist/scoring/training-keys.d.ts +27 -0
  278. package/dist/scoring/training-keys.d.ts.map +1 -0
  279. package/dist/scoring/training-keys.js +54 -0
  280. package/dist/scoring/training-keys.js.map +1 -0
  281. package/dist/scoring/types.d.ts +72 -7
  282. package/dist/scoring/types.d.ts.map +1 -1
  283. package/dist/scoring/types.js +4 -0
  284. package/dist/scoring/types.js.map +1 -1
  285. package/dist/sidecar-provider.d.ts +2 -2
  286. package/dist/sidecar-provider.js +3 -3
  287. package/dist/snapshot/code-version.d.ts +16 -0
  288. package/dist/snapshot/code-version.d.ts.map +1 -0
  289. package/dist/snapshot/code-version.js +39 -0
  290. package/dist/snapshot/code-version.js.map +1 -0
  291. package/dist/snapshot/holdout-carver.d.ts +110 -0
  292. package/dist/snapshot/holdout-carver.d.ts.map +1 -0
  293. package/dist/snapshot/holdout-carver.js +171 -0
  294. package/dist/snapshot/holdout-carver.js.map +1 -0
  295. package/dist/snapshot/index.d.ts +17 -0
  296. package/dist/snapshot/index.d.ts.map +1 -0
  297. package/dist/snapshot/index.js +17 -0
  298. package/dist/snapshot/index.js.map +1 -0
  299. package/dist/snapshot/snapshot-builder.d.ts +152 -0
  300. package/dist/snapshot/snapshot-builder.d.ts.map +1 -0
  301. package/dist/snapshot/snapshot-builder.js +286 -0
  302. package/dist/snapshot/snapshot-builder.js.map +1 -0
  303. package/dist/snapshot/snapshot-file-store.d.ts +161 -0
  304. package/dist/snapshot/snapshot-file-store.d.ts.map +1 -0
  305. package/dist/snapshot/snapshot-file-store.js +204 -0
  306. package/dist/snapshot/snapshot-file-store.js.map +1 -0
  307. package/dist/snapshot/snapshot-hash.d.ts +6 -0
  308. package/dist/snapshot/snapshot-hash.d.ts.map +1 -0
  309. package/dist/snapshot/snapshot-hash.js +16 -0
  310. package/dist/snapshot/snapshot-hash.js.map +1 -0
  311. package/dist/snapshot/snapshot-manifest.d.ts +43 -0
  312. package/dist/snapshot/snapshot-manifest.d.ts.map +1 -0
  313. package/dist/snapshot/snapshot-manifest.js +43 -0
  314. package/dist/snapshot/snapshot-manifest.js.map +1 -0
  315. package/dist/snapshot/snapshot-retrainer.d.ts +107 -0
  316. package/dist/snapshot/snapshot-retrainer.d.ts.map +1 -0
  317. package/dist/snapshot/snapshot-retrainer.js +194 -0
  318. package/dist/snapshot/snapshot-retrainer.js.map +1 -0
  319. package/dist/snapshot/snapshot-serialization.d.ts +99 -0
  320. package/dist/snapshot/snapshot-serialization.d.ts.map +1 -0
  321. package/dist/snapshot/snapshot-serialization.js +191 -0
  322. package/dist/snapshot/snapshot-serialization.js.map +1 -0
  323. package/dist/snapshot/training-snapshot-store.d.ts +38 -0
  324. package/dist/snapshot/training-snapshot-store.d.ts.map +1 -0
  325. package/dist/snapshot/training-snapshot-store.js +41 -0
  326. package/dist/snapshot/training-snapshot-store.js.map +1 -0
  327. package/dist/storage/ps-storage-provider.d.ts +108 -0
  328. package/dist/storage/ps-storage-provider.d.ts.map +1 -0
  329. package/dist/storage/ps-storage-provider.js +154 -0
  330. package/dist/storage/ps-storage-provider.js.map +1 -0
  331. package/dist/training/artifact-store.d.ts +12 -103
  332. package/dist/training/artifact-store.d.ts.map +1 -1
  333. package/dist/training/artifact-store.js +13 -137
  334. package/dist/training/artifact-store.js.map +1 -1
  335. package/dist/training/compute-cost.d.ts +23 -0
  336. package/dist/training/compute-cost.d.ts.map +1 -0
  337. package/dist/training/compute-cost.js +36 -0
  338. package/dist/training/compute-cost.js.map +1 -0
  339. package/dist/training/evaluation-protocol-store.d.ts +53 -0
  340. package/dist/training/evaluation-protocol-store.d.ts.map +1 -0
  341. package/dist/training/evaluation-protocol-store.js +54 -0
  342. package/dist/training/evaluation-protocol-store.js.map +1 -0
  343. package/dist/training/index.d.ts +9 -1
  344. package/dist/training/index.d.ts.map +1 -1
  345. package/dist/training/index.js +9 -1
  346. package/dist/training/index.js.map +1 -1
  347. package/dist/training/locked-holdout.d.ts +19 -4
  348. package/dist/training/locked-holdout.d.ts.map +1 -1
  349. package/dist/training/locked-holdout.js +29 -5
  350. package/dist/training/locked-holdout.js.map +1 -1
  351. package/dist/training/seams.d.ts +34 -8
  352. package/dist/training/seams.d.ts.map +1 -1
  353. package/dist/training/seams.js +74 -18
  354. package/dist/training/seams.js.map +1 -1
  355. package/dist/training/storage-provider-artifact-store.d.ts +49 -0
  356. package/dist/training/storage-provider-artifact-store.d.ts.map +1 -0
  357. package/dist/training/storage-provider-artifact-store.js +147 -0
  358. package/dist/training/storage-provider-artifact-store.js.map +1 -0
  359. package/dist/training/trainer-model-lineage.d.ts +32 -0
  360. package/dist/training/trainer-model-lineage.d.ts.map +1 -0
  361. package/dist/training/trainer-model-lineage.js +62 -0
  362. package/dist/training/trainer-model-lineage.js.map +1 -0
  363. package/dist/training/trainer-request.d.ts +50 -0
  364. package/dist/training/trainer-request.d.ts.map +1 -0
  365. package/dist/training/trainer-request.js +65 -0
  366. package/dist/training/trainer-request.js.map +1 -0
  367. package/dist/training/trainer-result.d.ts +30 -0
  368. package/dist/training/trainer-result.d.ts.map +1 -0
  369. package/dist/training/trainer-result.js +40 -0
  370. package/dist/training/trainer-result.js.map +1 -0
  371. package/dist/training/training-engine.d.ts +417 -64
  372. package/dist/training/training-engine.d.ts.map +1 -1
  373. package/dist/training/training-engine.js +869 -178
  374. package/dist/training/training-engine.js.map +1 -1
  375. package/dist/training/training-refusal.d.ts +15 -0
  376. package/dist/training/training-refusal.d.ts.map +1 -0
  377. package/dist/training/training-refusal.js +62 -0
  378. package/dist/training/training-refusal.js.map +1 -0
  379. package/dist/training/types.d.ts +133 -41
  380. package/dist/training/types.d.ts.map +1 -1
  381. package/dist/training/types.js +4 -4
  382. package/dist/training/unit-model-lineage.d.ts +72 -0
  383. package/dist/training/unit-model-lineage.d.ts.map +1 -0
  384. package/dist/training/unit-model-lineage.js +288 -0
  385. package/dist/training/unit-model-lineage.js.map +1 -0
  386. package/dist/tsconfig.tsbuildinfo +1 -0
  387. package/package.json +16 -13
  388. package/dist/operations/__tests__/helpers.d.ts +0 -30
  389. package/dist/operations/__tests__/helpers.d.ts.map +0 -1
  390. package/dist/operations/__tests__/helpers.js +0 -44
  391. package/dist/operations/__tests__/helpers.js.map +0 -1
@@ -0,0 +1,108 @@
1
+ /**
2
+ * @module storage/ps-storage-provider
3
+ *
4
+ * Where every Predictive Studio file lives: Training Snapshot files and trained model files are written through one MJ
5
+ * storage provider, the `MJ: File Storage Providers` row named by `PS_STORAGE_PROVIDER` (default "Local File System"),
6
+ * and each is recorded as an `MJ: Files` row whose `ProviderID` and `ProviderKey` say where its object is.
7
+ *
8
+ * The provider is read from `FileStorageEngine`'s cached providers and selected by name whatever its `IsActive` flag:
9
+ * an inactive provider is never picked by automatic provider selection, which is exactly why a caller that needs it
10
+ * names it. Its driver is resolved by `ServerDriverKey` and initialised from the server's environment configuration; a
11
+ * driver that is not configured on this server is refused. Predictive Studio has no storage accounts, so the driver is
12
+ * used directly, as the conversation-attachment blob store does for a provider without an account.
13
+ *
14
+ * A stored file is read through the provider its own `MJ: Files` row names ({@link PredictiveStudioStorage.DriverFor}),
15
+ * never the one configured today, so a file stays readable after `PS_STORAGE_PROVIDER` changes.
16
+ */
17
+ import { type IMetadataProvider, type UserInfo } from '@memberjunction/core';
18
+ import type { MJFileEntity, MJFileStorageProviderEntity } from '@memberjunction/core-entities';
19
+ import { type FileStorageBase } from '@memberjunction/storage';
20
+ import type { IEntityFactory } from '../training/types.js';
21
+ /** A storage provider row and its initialised driver. */
22
+ export interface StorageDriverBinding {
23
+ readonly Driver: FileStorageBase;
24
+ readonly Provider: MJFileStorageProviderEntity;
25
+ }
26
+ /** Where an `MJ: Files` row says its object is; a null or empty `ProviderKey` names no stored object. */
27
+ export interface StoredFileLocation {
28
+ readonly ProviderID: string;
29
+ readonly ProviderKey: string | null;
30
+ }
31
+ /** What a stored object's `MJ: Files` row records. */
32
+ export interface StoredFileRow {
33
+ readonly ObjectKey: string;
34
+ readonly Name: string;
35
+ readonly ContentType: string;
36
+ /** The row's `Description`. */
37
+ readonly Detail: string;
38
+ }
39
+ /** The outcome of saving an `MJ: Files` row: its ID, or the failed Save's CompleteMessage. */
40
+ export type StoredFileRowSave = {
41
+ readonly Saved: true;
42
+ readonly ID: string;
43
+ } | {
44
+ readonly Saved: false;
45
+ readonly Error: string;
46
+ };
47
+ /** The storage provider Predictive Studio writes its files to, and the providers its stored files name. */
48
+ export declare class PredictiveStudioStorage {
49
+ private readonly provider;
50
+ private readonly contextUser;
51
+ private readonly providerName;
52
+ /** The environment variable naming the provider Predictive Studio files are written to. */
53
+ static readonly ENV_VAR = "PS_STORAGE_PROVIDER";
54
+ /** The provider used when {@link ENV_VAR} is unset or empty. */
55
+ static readonly DEFAULT_PROVIDER_NAME = "Local File System";
56
+ private configured;
57
+ /** Drivers for the providers stored files name, by provider ID, resolved once each. */
58
+ private readonly readDrivers;
59
+ /**
60
+ * @param provider the provider the `MJ: Files` reads and the storage-provider cache load run on
61
+ * @param contextUser the acting user
62
+ * @param providerName the provider to write to (default: `PS_STORAGE_PROVIDER`, or "Local File System" when it is unset or empty)
63
+ */
64
+ constructor(provider: IMetadataProvider, contextUser: UserInfo | undefined, providerName?: string);
65
+ /**
66
+ * The configured provider's row and initialised driver, resolved once (a lazy promise, so concurrent writers share it).
67
+ *
68
+ * @throws Error naming the provider and `PS_STORAGE_PROVIDER` when no provider has that name or its driver is not configured here
69
+ */
70
+ ConfiguredDriver(): Promise<StorageDriverBinding>;
71
+ /**
72
+ * The row and initialised driver of the provider with this ID (the one a stored file's row names), resolved once per ID.
73
+ *
74
+ * @throws Error when no provider has the ID or its driver is not configured on this server
75
+ */
76
+ DriverFor(providerId: string): Promise<StorageDriverBinding>;
77
+ /**
78
+ * Where the `MJ: Files` row with this ID says its object is, or null when there is no such row (read-only: `'simple'`).
79
+ *
80
+ * @throws Error when the read fails
81
+ */
82
+ LocationOf(fileId: string): Promise<StoredFileLocation | null>;
83
+ /**
84
+ * Records an object stored through `binding` as an `MJ: Files` row (`Status` "Uploaded"), created through `entityFactory`.
85
+ *
86
+ * @returns the row's ID, or the failed Save's CompleteMessage
87
+ */
88
+ SaveFileRow(binding: StorageDriverBinding, row: StoredFileRow, entityFactory: IEntityFactory): Promise<StoredFileRowSave>;
89
+ /**
90
+ * The `MJ: Files` row with this ID, loaded for mutation as this storage's user through `entityFactory`, or null when
91
+ * there is no such row.
92
+ */
93
+ LoadFileRow(fileId: string, entityFactory: IEntityFactory): Promise<MJFileEntity | null>;
94
+ /**
95
+ * The `MJ: Files` row already recording this provider's object, or null (read-only: `'simple'`, one field). When
96
+ * several rows record one object, the earliest created wins (ties by ID), so every writer picks the same row.
97
+ *
98
+ * @throws Error when the read fails
99
+ */
100
+ FileRowIDFor(providerId: string, objectKey: string): Promise<string | null>;
101
+ private resolveConfigured;
102
+ private resolveById;
103
+ /** `FileStorageEngine`, its provider cache loaded through this storage's provider and user. */
104
+ private storageEngine;
105
+ /** The provider's driver, initialised from this server's environment. */
106
+ private static initializedDriver;
107
+ }
108
+ //# sourceMappingURL=ps-storage-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ps-storage-provider.d.ts","sourceRoot":"","sources":["../../src/storage/ps-storage-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAW,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAA2C,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACxG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;CAChD;AAED,yGAAyG;AACzG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,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AAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAKrG;;;;;OAKG;IACU,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;YAgB1E,iBAAiB;YAWjB,WAAW;IASzB,+FAA+F;YACjF,aAAa;IAM3B,yEAAyE;mBACpD,iBAAiB;CAKvC"}
@@ -0,0 +1,154 @@
1
+ /**
2
+ * @module storage/ps-storage-provider
3
+ *
4
+ * Where every Predictive Studio file lives: Training Snapshot files and trained model files are written through one MJ
5
+ * storage provider, the `MJ: File Storage Providers` row named by `PS_STORAGE_PROVIDER` (default "Local File System"),
6
+ * and each is recorded as an `MJ: Files` row whose `ProviderID` and `ProviderKey` say where its object is.
7
+ *
8
+ * The provider is read from `FileStorageEngine`'s cached providers and selected by name whatever its `IsActive` flag:
9
+ * an inactive provider is never picked by automatic provider selection, which is exactly why a caller that needs it
10
+ * names it. Its driver is resolved by `ServerDriverKey` and initialised from the server's environment configuration; a
11
+ * driver that is not configured on this server is refused. Predictive Studio has no storage accounts, so the driver is
12
+ * used directly, as the conversation-attachment blob store does for a provider without an account.
13
+ *
14
+ * A stored file is read through the provider its own `MJ: Files` row names ({@link PredictiveStudioStorage.DriverFor}),
15
+ * never the one configured today, so a file stays readable after `PS_STORAGE_PROVIDER` changes.
16
+ */
17
+ import { RunView } from '@memberjunction/core';
18
+ import { EscapeSQLString, UUIDMap } from '@memberjunction/global';
19
+ import { FileStorageEngine, ResolveStorageDriver } from '@memberjunction/storage';
20
+ /** The storage provider Predictive Studio writes its files to, and the providers its stored files name. */
21
+ export class PredictiveStudioStorage {
22
+ /** The environment variable naming the provider Predictive Studio files are written to. */
23
+ static { this.ENV_VAR = 'PS_STORAGE_PROVIDER'; }
24
+ /** The provider used when {@link ENV_VAR} is unset or empty. */
25
+ static { this.DEFAULT_PROVIDER_NAME = 'Local File System'; }
26
+ /**
27
+ * @param provider the provider the `MJ: Files` reads and the storage-provider cache load run on
28
+ * @param contextUser the acting user
29
+ * @param providerName the provider to write to (default: `PS_STORAGE_PROVIDER`, or "Local File System" when it is unset or empty)
30
+ */
31
+ constructor(provider, contextUser,
32
+ // An empty PS_STORAGE_PROVIDER means "not set" as well, hence `||`.
33
+ providerName = process.env[PredictiveStudioStorage.ENV_VAR] || PredictiveStudioStorage.DEFAULT_PROVIDER_NAME) {
34
+ this.provider = provider;
35
+ this.contextUser = contextUser;
36
+ this.providerName = providerName;
37
+ this.configured = null;
38
+ /** Drivers for the providers stored files name, by provider ID, resolved once each. */
39
+ this.readDrivers = new UUIDMap();
40
+ }
41
+ /**
42
+ * The configured provider's row and initialised driver, resolved once (a lazy promise, so concurrent writers share it).
43
+ *
44
+ * @throws Error naming the provider and `PS_STORAGE_PROVIDER` when no provider has that name or its driver is not configured here
45
+ */
46
+ ConfiguredDriver() {
47
+ this.configured ||= this.resolveConfigured();
48
+ return this.configured;
49
+ }
50
+ /**
51
+ * The row and initialised driver of the provider with this ID (the one a stored file's row names), resolved once per ID.
52
+ *
53
+ * @throws Error when no provider has the ID or its driver is not configured on this server
54
+ */
55
+ DriverFor(providerId) {
56
+ let binding = this.readDrivers.Get(providerId);
57
+ if (!binding) {
58
+ binding = this.resolveById(providerId);
59
+ this.readDrivers.Set(providerId, binding);
60
+ }
61
+ return binding;
62
+ }
63
+ /**
64
+ * Where the `MJ: Files` row with this ID says its object is, or null when there is no such row (read-only: `'simple'`).
65
+ *
66
+ * @throws Error when the read fails
67
+ */
68
+ async LocationOf(fileId) {
69
+ const r = await RunView.FromMetadataProvider(this.provider).RunView({ EntityName: 'MJ: Files', ExtraFilter: `ID='${EscapeSQLString(fileId)}'`, Fields: ['ID', 'ProviderID', 'ProviderKey'], ResultType: 'simple' }, this.contextUser);
70
+ if (!r.Success)
71
+ throw new Error(`Predictive Studio storage: reading the MJ: Files row ${fileId} failed: ${r.ErrorMessage}`);
72
+ const row = r.Results[0];
73
+ return row ? { ProviderID: row.ProviderID, ProviderKey: row.ProviderKey } : null;
74
+ }
75
+ /**
76
+ * Records an object stored through `binding` as an `MJ: Files` row (`Status` "Uploaded"), created through `entityFactory`.
77
+ *
78
+ * @returns the row's ID, or the failed Save's CompleteMessage
79
+ */
80
+ async SaveFileRow(binding, row, entityFactory) {
81
+ const file = await entityFactory.getEntityObject('MJ: Files', this.contextUser);
82
+ file.Name = row.Name;
83
+ file.ContentType = row.ContentType;
84
+ file.ProviderID = binding.Provider.ID;
85
+ file.ProviderKey = row.ObjectKey;
86
+ file.Status = 'Uploaded';
87
+ file.Description = row.Detail;
88
+ if (await file.Save())
89
+ return { Saved: true, ID: file.ID };
90
+ return { Saved: false, Error: file.LatestResult?.CompleteMessage || 'unknown error' };
91
+ }
92
+ /**
93
+ * The `MJ: Files` row with this ID, loaded for mutation as this storage's user through `entityFactory`, or null when
94
+ * there is no such row.
95
+ */
96
+ async LoadFileRow(fileId, entityFactory) {
97
+ const file = await entityFactory.getEntityObject('MJ: Files', this.contextUser);
98
+ return (await file.Load(fileId)) ? file : null;
99
+ }
100
+ /**
101
+ * The `MJ: Files` row already recording this provider's object, or null (read-only: `'simple'`, one field). When
102
+ * several rows record one object, the earliest created wins (ties by ID), so every writer picks the same row.
103
+ *
104
+ * @throws Error when the read fails
105
+ */
106
+ async FileRowIDFor(providerId, objectKey) {
107
+ const r = await RunView.FromMetadataProvider(this.provider).RunView({
108
+ EntityName: 'MJ: Files',
109
+ ExtraFilter: `ProviderID='${EscapeSQLString(providerId)}' AND ProviderKey='${EscapeSQLString(objectKey)}'`,
110
+ OrderBy: '__mj_CreatedAt ASC, ID ASC',
111
+ Fields: ['ID'],
112
+ MaxRows: 1,
113
+ ResultType: 'simple',
114
+ }, this.contextUser);
115
+ if (!r.Success)
116
+ throw new Error(`Predictive Studio storage: looking up the MJ: Files row for ${objectKey} failed: ${r.ErrorMessage}`);
117
+ return r.Results[0]?.ID || null;
118
+ }
119
+ async resolveConfigured() {
120
+ const engine = await this.storageEngine();
121
+ const wanted = this.providerName.trim().toLowerCase();
122
+ const row = engine.Providers.find((p) => p.Name.trim().toLowerCase() === wanted);
123
+ const setting = `${PredictiveStudioStorage.ENV_VAR} names the provider Predictive Studio files are written to`;
124
+ if (!row)
125
+ throw new Error(`Predictive Studio storage: no File Storage Provider named "${this.providerName}" (${setting})`);
126
+ const driver = await PredictiveStudioStorage.initializedDriver(row);
127
+ if (!driver.IsConfigured)
128
+ throw new Error(`Predictive Studio storage: storage provider "${row.Name}" is not configured on this server (${setting})`);
129
+ return { Driver: driver, Provider: row };
130
+ }
131
+ async resolveById(providerId) {
132
+ const engine = await this.storageEngine();
133
+ const row = engine.GetProviderById(providerId);
134
+ if (!row)
135
+ throw new Error(`Predictive Studio storage: no File Storage Provider with ID ${providerId}`);
136
+ const driver = await PredictiveStudioStorage.initializedDriver(row);
137
+ if (!driver.IsConfigured)
138
+ throw new Error(`Predictive Studio storage: storage provider "${row.Name}", which stores the file, is not configured on this server`);
139
+ return { Driver: driver, Provider: row };
140
+ }
141
+ /** `FileStorageEngine`, its provider cache loaded through this storage's provider and user. */
142
+ async storageEngine() {
143
+ const engine = FileStorageEngine.Instance;
144
+ await engine.Config(false, this.contextUser, this.provider);
145
+ return engine;
146
+ }
147
+ /** The provider's driver, initialised from this server's environment. */
148
+ static async initializedDriver(row) {
149
+ const driver = ResolveStorageDriver(row);
150
+ await driver.initialize();
151
+ return driver;
152
+ }
153
+ }
154
+ //# sourceMappingURL=ps-storage-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ps-storage-provider.js","sourceRoot":"","sources":["../../src/storage/ps-storage-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,OAAO,EAAyC,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAElE,OAAO,EAAE,iBAAiB,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,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,yEAAyE;IACjE,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAgC;QACrE,MAAM,MAAM,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAChB,CAAC"}
@@ -1,51 +1,25 @@
1
1
  /**
2
2
  * @module training/artifact-store
3
3
  *
4
- * Implementations of the {@link IArtifactStore} seam (plan §11). The serialized
5
- * model artifact is kept out of the `MJ: ML Models` row and referenced by file
6
- * id; this module provides:
7
- *
8
- * - {@link MJFilesArtifactStore} — the single coherent store: it records a real
9
- * `MJ: Files` row (so `MLModel.ArtifactFileID` satisfies its FK to `__mj.File`)
10
- * AND writes the serialized bytes to local disk at `<baseDir>/<file.ID>.bin`. It
11
- * returns the real File row id, which the matching loader uses to read the bytes
12
- * back. Kept dependency-light: it does not import MJStorage cloud drivers.
13
- * - {@link InMemoryArtifactStore} — an in-memory map used by unit tests (no DB).
14
- *
15
- * ## The real-File-id + local-bytes convention (dev / on-prem)
16
- *
17
- * `MLModel.ArtifactFileID` is a FK to `__mj.File`, so the fileId MUST be a genuine
18
- * `MJ: Files` row id — a bare random UUID would violate `FK_MLModel_ArtifactFile`.
19
- * Therefore the store ALWAYS creates the File row (stamped with the active storage
20
- * `ProviderID`) and returns `file.ID`. For this dev / on-prem mode the bytes are
21
- * persisted to **local disk** keyed by that same id (`<baseDir>/<file.ID>.bin`,
22
- * {@link resolveLocalArtifactBaseDir}); the scoring loader reads them back by id.
23
- *
24
- * **Production follow-up**: replace the local `writeFile` with a real storage
25
- * `PutObject` against the provider (and the loader with a `GetObject`); the File
26
- * row + id contract is unchanged, so only the byte transport moves to the cloud.
4
+ * The in-memory {@link IArtifactStore} for unit tests, and the local-disk layout model files trained before 6.3 were
5
+ * written to. Those files' `MJ: Files` rows have an empty `ProviderKey`; their bytes are at
6
+ * `<PS_ARTIFACT_DIR>/<fileId>.bin` ({@link ResolveLocalArtifactBaseDir}, {@link LocalArtifactPath}), where
7
+ * `StorageProviderArtifactLoader` reads them and `StorageProviderArtifactStore.Delete` removes them. Every model file
8
+ * trained since is stored through the configured MJ storage provider (`StorageProviderArtifactStore`).
27
9
  */
28
- import { type IMetadataProvider, type UserInfo } from '@memberjunction/core';
29
- import type { IArtifactStore, IEntityFactory } from './types.js';
10
+ import type { IArtifactStore } from './types.js';
30
11
  /**
31
- * Resolve the base directory artifact bytes are written to: env `PS_ARTIFACT_DIR`
32
- * when set, else `<os.tmpdir()>/mj-ps-artifacts`. Centralized so the store (write)
33
- * and the loader (read) agree on the location (bytes live at `<baseDir>/<file.ID>.bin`).
12
+ * The base directory model files trained before 6.3 were written to: env `PS_ARTIFACT_DIR`
13
+ * when set, else `<os.tmpdir()>/mj-ps-artifacts` (bytes at `<baseDir>/<file.ID>.bin`).
34
14
  */
35
15
  export declare function ResolveLocalArtifactBaseDir(): string;
36
- /** @deprecated Use {@link ResolveLocalArtifactBaseDir}. */
37
- export declare function resolveLocalArtifactBaseDir(): string;
38
16
  /**
39
- * Build the absolute path an artifact with the given File-row fileId lives at:
40
- * `<baseDir>/<fileId>.bin`. Shared by the store (write) and the loader (read) so
41
- * they agree on the on-disk layout.
17
+ * The absolute path a model file trained before 6.3 lives at: `<baseDir>/<fileId>.bin`.
42
18
  *
43
19
  * @param baseDir the resolved artifact base directory
44
20
  * @param fileId the `MJ: Files` row id the artifact was stored under
45
21
  */
46
22
  export declare function LocalArtifactPath(baseDir: string, fileId: string): string;
47
- /** @deprecated Use {@link LocalArtifactPath}. */
48
- export declare function localArtifactPath(baseDir: string, fileId: string): string;
49
23
  /**
50
24
  * In-memory {@link IArtifactStore} for unit tests. Stores bytes in a map keyed by
51
25
  * a generated id and returns that id. No database, no MJStorage.
@@ -59,74 +33,9 @@ export declare class InMemoryArtifactStore implements IArtifactStore {
59
33
  private seq;
60
34
  /** @inheritdoc */
61
35
  save(bytes: Uint8Array, name: string): Promise<string>;
62
- }
63
- /**
64
- * Options for {@link MJFilesArtifactStore}.
65
- */
66
- export interface MJFilesArtifactStoreOptions {
67
- /**
68
- * Storage-provider id to stamp on the `MJ: Files` row (`ProviderID`). Required in
69
- * practice — the column is NOT NULL — and supplied by {@link buildArtifactStore}
70
- * from the active `MJ: File Storage Providers` row.
71
- */
72
- providerId?: string;
73
- /** MIME content type recorded on the file (defaults to `application/octet-stream`). */
74
- contentType?: string;
75
- /**
76
- * Base directory the serialized bytes are written to. Defaults to
77
- * {@link resolveLocalArtifactBaseDir} (env `PS_ARTIFACT_DIR`, else
78
- * `<os.tmpdir()>/mj-ps-artifacts`). Injectable so tests target a scratch dir.
79
- */
80
- baseDir?: string;
81
- }
82
- /**
83
- * The single coherent {@link IArtifactStore}: it creates a real `MJ: Files` row
84
- * (through the injected {@link IEntityFactory}, stamped with the active storage
85
- * `ProviderID`) AND persists the serialized artifact bytes to local disk at
86
- * `<baseDir>/<file.ID>.bin`. It returns the real File row id so
87
- * `MLModel.ArtifactFileID` satisfies its FK to `__mj.File`, and the matching
88
- * {@link LocalArtifactLoader} reads the bytes back by that id.
89
- *
90
- * Why both halves: the FK forces a genuine File row id, but `MJ: Files.Save()` only
91
- * records the metadata row — it never moves bytes — so for this dev / on-prem mode
92
- * we write the bytes ourselves, keyed by the File id. **Production follow-up**:
93
- * swap the local `writeFile` for a real provider `PutObject`; the id contract is
94
- * unchanged.
95
- */
96
- export declare class MJFilesArtifactStore implements IArtifactStore {
97
- private readonly entityFactory;
98
- private readonly options;
99
- private readonly baseDir;
100
- constructor(entityFactory: IEntityFactory, options?: MJFilesArtifactStoreOptions);
36
+ /** @inheritdoc An in-memory store can always write. */
37
+ AssertWritable(): Promise<void>;
101
38
  /** @inheritdoc */
102
- save(bytes: Uint8Array, name: string, contextUser?: UserInfo): Promise<string>;
39
+ delete(fileId: string): Promise<void>;
103
40
  }
104
- /**
105
- * Resolve the id of the first **active** `MJ: File Storage Providers` row, or
106
- * `null` when none is active. The provider id is stamped on every artifact's
107
- * `MJ: Files` row (its `ProviderID` is NOT NULL); a seeded active provider (e.g.
108
- * "Local Storage") is what lets {@link MJFilesArtifactStore} create a valid File row
109
- * in dev / on-prem deployments.
110
- *
111
- * @param contextUser the acting user (server-side data access is user-scoped)
112
- * @param provider the provider the read runs on (no global fallback)
113
- * @returns the active provider id, or `null` when none is active
114
- */
115
- export declare function ResolveActiveFileStorageProviderId(contextUser: UserInfo, provider: IMetadataProvider): Promise<string | null>;
116
- /** @deprecated Use {@link ResolveActiveFileStorageProviderId}. */
117
- export declare function resolveActiveFileStorageProviderId(contextUser: UserInfo, provider: IMetadataProvider): Promise<string | null>;
118
- /**
119
- * Build the training-side {@link IArtifactStore}, stamping the resolved active
120
- * storage `providerId` on every File row. The store creates a real `MJ: Files` row
121
- * (FK-valid `ArtifactFileID`) and writes the bytes to local disk keyed by that id
122
- * (dev / on-prem). When no active provider exists the File row's NOT-NULL
123
- * `ProviderID` cannot be set and `Save()` will fail with a clear error — seed an
124
- * active provider (e.g. "Local Storage") to enable artifact persistence.
125
- *
126
- * @param providerId the active storage-provider id (or `null` when none is active)
127
- * @param entityFactory the entity-creation seam the store records the File row through
128
- */
129
- export declare function BuildArtifactStore(providerId: string | null, entityFactory: IEntityFactory): IArtifactStore;
130
- /** @deprecated Use {@link BuildArtifactStore}. */
131
- export declare function buildArtifactStore(providerId: string | null, entityFactory: IEntityFactory): IArtifactStore;
132
41
  //# sourceMappingURL=artifact-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-store.d.ts","sourceRoot":"","sources":["../../src/training/artifact-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,OAAO,EAAqB,KAAK,iBAAiB,EAAE,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhG,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM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Q,EACrB,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmBxB;AAED,kEAAkE;AAClE,wBAAsB,kCAAkC,CACtD,WAAW,EAAE,QAAQ,EACrB,QAAQ,EAAE,iBAAiB,GAC1B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAExB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,aAAa,EAAE,cAAc,GAAG,cAAc,CAE3G;AAED,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,aAAa,EAAE,cAAc,GAAG,cAAc,CAE3G"}
1
+ {"version":3,"file":"artifact-store.d.ts","sourceRoot":"","sources":["../../src/training/artifact-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,CAMpD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzE;AAED;;;GAGG;AACH,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,sDAAsD;IACtD,SAAgB,KAAK;cAA2B,MAAM;eAAS,UAAU;OAAM;IAC/E,OAAO,CAAC,GAAG,CAAK;IAEhB,kBAAkB;IACL,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAMnE,uDAAuD;IAC1C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAE5C,kBAAkB;IACL,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGnD"}
@@ -1,38 +1,17 @@
1
1
  /**
2
2
  * @module training/artifact-store
3
3
  *
4
- * Implementations of the {@link IArtifactStore} seam (plan §11). The serialized
5
- * model artifact is kept out of the `MJ: ML Models` row and referenced by file
6
- * id; this module provides:
7
- *
8
- * - {@link MJFilesArtifactStore} — the single coherent store: it records a real
9
- * `MJ: Files` row (so `MLModel.ArtifactFileID` satisfies its FK to `__mj.File`)
10
- * AND writes the serialized bytes to local disk at `<baseDir>/<file.ID>.bin`. It
11
- * returns the real File row id, which the matching loader uses to read the bytes
12
- * back. Kept dependency-light: it does not import MJStorage cloud drivers.
13
- * - {@link InMemoryArtifactStore} — an in-memory map used by unit tests (no DB).
14
- *
15
- * ## The real-File-id + local-bytes convention (dev / on-prem)
16
- *
17
- * `MLModel.ArtifactFileID` is a FK to `__mj.File`, so the fileId MUST be a genuine
18
- * `MJ: Files` row id — a bare random UUID would violate `FK_MLModel_ArtifactFile`.
19
- * Therefore the store ALWAYS creates the File row (stamped with the active storage
20
- * `ProviderID`) and returns `file.ID`. For this dev / on-prem mode the bytes are
21
- * persisted to **local disk** keyed by that same id (`<baseDir>/<file.ID>.bin`,
22
- * {@link resolveLocalArtifactBaseDir}); the scoring loader reads them back by id.
23
- *
24
- * **Production follow-up**: replace the local `writeFile` with a real storage
25
- * `PutObject` against the provider (and the loader with a `GetObject`); the File
26
- * row + id contract is unchanged, so only the byte transport moves to the cloud.
4
+ * The in-memory {@link IArtifactStore} for unit tests, and the local-disk layout model files trained before 6.3 were
5
+ * written to. Those files' `MJ: Files` rows have an empty `ProviderKey`; their bytes are at
6
+ * `<PS_ARTIFACT_DIR>/<fileId>.bin` ({@link ResolveLocalArtifactBaseDir}, {@link LocalArtifactPath}), where
7
+ * `StorageProviderArtifactLoader` reads them and `StorageProviderArtifactStore.Delete` removes them. Every model file
8
+ * trained since is stored through the configured MJ storage provider (`StorageProviderArtifactStore`).
27
9
  */
28
- import { mkdir, writeFile } from 'node:fs/promises';
29
10
  import { tmpdir } from 'node:os';
30
11
  import { join } from 'node:path';
31
- import { RunView, LogError } from '@memberjunction/core';
32
12
  /**
33
- * Resolve the base directory artifact bytes are written to: env `PS_ARTIFACT_DIR`
34
- * when set, else `<os.tmpdir()>/mj-ps-artifacts`. Centralized so the store (write)
35
- * and the loader (read) agree on the location (bytes live at `<baseDir>/<file.ID>.bin`).
13
+ * The base directory model files trained before 6.3 were written to: env `PS_ARTIFACT_DIR`
14
+ * when set, else `<os.tmpdir()>/mj-ps-artifacts` (bytes at `<baseDir>/<file.ID>.bin`).
36
15
  */
37
16
  export function ResolveLocalArtifactBaseDir() {
38
17
  const fromEnv = process.env.PS_ARTIFACT_DIR;
@@ -41,14 +20,8 @@ export function ResolveLocalArtifactBaseDir() {
41
20
  }
42
21
  return join(tmpdir(), 'mj-ps-artifacts');
43
22
  }
44
- /** @deprecated Use {@link ResolveLocalArtifactBaseDir}. */
45
- export function resolveLocalArtifactBaseDir() {
46
- return ResolveLocalArtifactBaseDir();
47
- }
48
23
  /**
49
- * Build the absolute path an artifact with the given File-row fileId lives at:
50
- * `<baseDir>/<fileId>.bin`. Shared by the store (write) and the loader (read) so
51
- * they agree on the on-disk layout.
24
+ * The absolute path a model file trained before 6.3 lives at: `<baseDir>/<fileId>.bin`.
52
25
  *
53
26
  * @param baseDir the resolved artifact base directory
54
27
  * @param fileId the `MJ: Files` row id the artifact was stored under
@@ -56,10 +29,6 @@ export function resolveLocalArtifactBaseDir() {
56
29
  export function LocalArtifactPath(baseDir, fileId) {
57
30
  return join(baseDir, `${fileId}.bin`);
58
31
  }
59
- /** @deprecated Use {@link LocalArtifactPath}. */
60
- export function localArtifactPath(baseDir, fileId) {
61
- return LocalArtifactPath(baseDir, fileId);
62
- }
63
32
  /**
64
33
  * In-memory {@link IArtifactStore} for unit tests. Stores bytes in a map keyed by
65
34
  * a generated id and returns that id. No database, no MJStorage.
@@ -76,105 +45,12 @@ export class InMemoryArtifactStore {
76
45
  this.Saved.set(id, { Name: name, Bytes: bytes });
77
46
  return id;
78
47
  }
79
- }
80
- /**
81
- * The single coherent {@link IArtifactStore}: it creates a real `MJ: Files` row
82
- * (through the injected {@link IEntityFactory}, stamped with the active storage
83
- * `ProviderID`) AND persists the serialized artifact bytes to local disk at
84
- * `<baseDir>/<file.ID>.bin`. It returns the real File row id so
85
- * `MLModel.ArtifactFileID` satisfies its FK to `__mj.File`, and the matching
86
- * {@link LocalArtifactLoader} reads the bytes back by that id.
87
- *
88
- * Why both halves: the FK forces a genuine File row id, but `MJ: Files.Save()` only
89
- * records the metadata row — it never moves bytes — so for this dev / on-prem mode
90
- * we write the bytes ourselves, keyed by the File id. **Production follow-up**:
91
- * swap the local `writeFile` for a real provider `PutObject`; the id contract is
92
- * unchanged.
93
- */
94
- export class MJFilesArtifactStore {
95
- constructor(entityFactory, options = {}) {
96
- this.entityFactory = entityFactory;
97
- this.options = options;
98
- this.baseDir = options.baseDir ?? ResolveLocalArtifactBaseDir();
99
- }
48
+ /** @inheritdoc An in-memory store can always write. */
49
+ async AssertWritable() { }
100
50
  /** @inheritdoc */
101
- async save(bytes, name, contextUser) {
102
- const file = await this.entityFactory.getEntityObject('MJ: Files', contextUser);
103
- file.Name = name;
104
- file.ContentType = this.options.contentType ?? 'application/octet-stream';
105
- if (this.options.providerId) {
106
- file.ProviderID = this.options.providerId;
107
- }
108
- file.Description = `Predictive Studio model artifact (${bytes.byteLength} bytes)`;
109
- const saved = await file.Save();
110
- if (!saved) {
111
- const message = file.LatestResult?.CompleteMessage ?? 'unknown error';
112
- LogError(`MJFilesArtifactStore: failed to persist artifact file row '${name}': ${message}`);
113
- throw new Error(`Failed to persist model artifact file: ${message}`);
114
- }
115
- // The File row exists but holds no bytes; persist them locally keyed by the real
116
- // File id (dev/on-prem). Production follow-up: a provider PutObject instead.
117
- try {
118
- await mkdir(this.baseDir, { recursive: true });
119
- await writeFile(LocalArtifactPath(this.baseDir, file.ID), bytes);
120
- }
121
- catch (error) {
122
- const message = error instanceof Error ? error.message : String(error);
123
- LogError(`MJFilesArtifactStore: persisted File row '${file.ID}' but failed to write bytes under '${this.baseDir}': ${message}`);
124
- throw new Error(`Failed to persist model artifact bytes: ${message}`);
125
- }
126
- return file.ID;
51
+ async delete(fileId) {
52
+ if (!this.Saved.delete(fileId))
53
+ throw new Error(`InMemoryArtifactStore: no artifact ${fileId}`);
127
54
  }
128
55
  }
129
- // ----- Store wiring (shared by every training wiring site) ---------------------
130
- /**
131
- * Resolve the id of the first **active** `MJ: File Storage Providers` row, or
132
- * `null` when none is active. The provider id is stamped on every artifact's
133
- * `MJ: Files` row (its `ProviderID` is NOT NULL); a seeded active provider (e.g.
134
- * "Local Storage") is what lets {@link MJFilesArtifactStore} create a valid File row
135
- * in dev / on-prem deployments.
136
- *
137
- * @param contextUser the acting user (server-side data access is user-scoped)
138
- * @param provider the provider the read runs on (no global fallback)
139
- * @returns the active provider id, or `null` when none is active
140
- */
141
- export async function ResolveActiveFileStorageProviderId(contextUser, provider) {
142
- const rv = RunView.FromMetadataProvider(provider);
143
- const result = await rv.RunView({
144
- EntityName: 'MJ: File Storage Providers',
145
- ExtraFilter: 'IsActive = 1',
146
- Fields: ['ID'],
147
- // Priority is "lower numbers are preferred" — take the most-preferred active provider.
148
- OrderBy: 'Priority ASC',
149
- MaxRows: 1,
150
- SkipTotalRowCount: true,
151
- ResultType: 'simple',
152
- }, contextUser);
153
- if (!result.Success || result.Results.length === 0) {
154
- return null;
155
- }
156
- return result.Results[0].ID ?? null;
157
- }
158
- /** @deprecated Use {@link ResolveActiveFileStorageProviderId}. */
159
- export async function resolveActiveFileStorageProviderId(contextUser, provider) {
160
- return ResolveActiveFileStorageProviderId(contextUser, provider);
161
- }
162
- /**
163
- * Build the training-side {@link IArtifactStore}, stamping the resolved active
164
- * storage `providerId` on every File row. The store creates a real `MJ: Files` row
165
- * (FK-valid `ArtifactFileID`) and writes the bytes to local disk keyed by that id
166
- * (dev / on-prem). When no active provider exists the File row's NOT-NULL
167
- * `ProviderID` cannot be set and `Save()` will fail with a clear error — seed an
168
- * active provider (e.g. "Local Storage") to enable artifact persistence.
169
- *
170
- * @param providerId the active storage-provider id (or `null` when none is active)
171
- * @param entityFactory the entity-creation seam the store records the File row through
172
- */
173
- export function BuildArtifactStore(providerId, entityFactory) {
174
- return new MJFilesArtifactStore(entityFactory, { providerId: providerId ?? undefined });
175
- }
176
- /** @deprecated Use {@link BuildArtifactStore}. */
177
- export function buildArtifactStore(providerId, entityFactory) {
178
- return BuildArtifactStore(providerId, entityFactory);
179
- }
180
56
  //# sourceMappingURL=artifact-store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-store.js","sourceRoot":"","sources":["../../src/training/artifact-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAyC,MAAM,sBAAsB,CAAC;AAIhG;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC5C,IAAI,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IACD,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,iBAAiB,CAAC,CAAC;AAC3C,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,2BAA2B;IACzC,OAAO,2BAA2B,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,MAAc;IAC/D,OAAO,IAAI,CAAC,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,iBAAiB,C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