@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,65 @@
1
+ /**
2
+ * @module feature-assembly/as-of/series-features
3
+ *
4
+ * Series features declared once in the unit's Temporal Spec: lag k reads the value k periods back; rolling windows
5
+ * aggregate periods [t − endLag − periods + 1, t − endLag]. Every lag and endLag is >= the horizon (the parser
6
+ * refuses otherwise), so nothing inside the horizon is ever read. A period's value is its resolved outcome, so a row
7
+ * reads it only when that period's outcome window had closed by the row's own decision day and by the assembly day (a
8
+ * row scored ahead of its decision date never reads a window still open at scoring); training and scoring both compute
9
+ * every lag here, so they null exactly the same cells.
10
+ */
11
+ import { type DatedSource, type TemporalSpec } from '@memberjunction/predictive-studio-core';
12
+ /** A series feature reference, derived from the contract's `series` source (never restated). */
13
+ export type SeriesFeatureRef = Extract<DatedSource, {
14
+ kind: 'series';
15
+ }>['feature'];
16
+ /**
17
+ * One observed period of one entity's series. `WindowEnd` is the last day of its outcome window (decision + gap +
18
+ * window): its value is known from the end of that day on.
19
+ */
20
+ export interface SeriesPoint {
21
+ readonly EntityKey: string;
22
+ readonly Period: Date;
23
+ readonly Value: number;
24
+ readonly RowID: string;
25
+ readonly WindowEnd: Date;
26
+ }
27
+ /** Series points keyed by lower-cased entity key, then by calendar period index. */
28
+ export type SeriesHistory = {
29
+ readonly Spec: TemporalSpec;
30
+ readonly ByEntity: ReadonlyMap<string, ReadonlyMap<number, SeriesPoint>>;
31
+ };
32
+ /** Series lags and rolling windows. */
33
+ export declare class SeriesFeatures {
34
+ /**
35
+ * Calendar index of a period, monotonic in time so consecutive periods differ by one: days since the epoch for daily,
36
+ * ISO weeks (Monday to Sunday, as the holdout carve and the trainer bucket weeks) for weekly, year * 12 + month for
37
+ * monthly, the year for yearly.
38
+ */
39
+ static PeriodIndex(period: Date, unit: TemporalSpec['period']): number;
40
+ /** Indexes series points by entity and period; a later point for the same period replaces an earlier one. */
41
+ static BuildSeriesHistory(points: readonly SeriesPoint[], spec: TemporalSpec): SeriesHistory;
42
+ /**
43
+ * One lag or rolling-window value for an entity at `period`, for a row decided on `decision` and assembled at
44
+ * `assembledAt`; null when any period it reads is missing or its outcome window had not closed by the earlier of the
45
+ * decision day and the assembly day (its window end is after that day).
46
+ *
47
+ * The assembly day matters only for a row decided after it, which only scoring builds (a row scored ahead of its
48
+ * decision date): its history keeps periods whose window is still open, and such a period's value is not yet its
49
+ * resolved outcome, so it is never read before its window has closed. A row decided on or before the assembly day,
50
+ * every row training reads included, keeps the decision-day rule, so training and scoring agree on it.
51
+ */
52
+ static ComputeSeriesFeature(history: SeriesHistory, entityKey: string, period: Date, spec: TemporalSpec, feature: SeriesFeatureRef, decision: Date, assembledAt: Date): {
53
+ readonly Value: number | null;
54
+ readonly SourceRowIDs: readonly string[];
55
+ };
56
+ /**
57
+ * An instant as its UTC day: a row's decision (the assembly validates decision dates before any feature is read) or the
58
+ * assembly's own clock. A window end is a UTC day too, so a window ending on that day counts as closed, exactly as the
59
+ * unit reader's cutoff keeps a row whose window ends on the cutoff day.
60
+ */
61
+ private static requireDay;
62
+ /** Feature resolution refuses an out-of-range index; this guards the computation against a caller that skipped it. */
63
+ private static indexError;
64
+ }
65
+ //# sourceMappingURL=series-features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"series-features.d.ts","sourceRoot":"","sources":["../../../src/feature-assembly/as-of/series-features.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAsB,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAKjH,gGAAgG;AAEhG,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC,SAAS,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,WAAW;IAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE;AAC5J,oFAAoF;AACpF,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;CAAE,CAAC;AAEtI,uCAAuC;AACvC,qBAAa,cAAc;IACzB;;;;OAIG;WACW,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC,QAAQ,CAAC,GAAG,MAAM;IAS7E,6GAA6G;WAC/F,kBAAkB,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,IAAI,EAAE,YAAY,GAAG,aAAa;IAWnG;;;;;;;;;OASG;WACW,oBAAoB,CAChC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,GACxI;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE;IA6B9E;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAMzB,sHAAsH;IACtH,OAAO,CAAC,MAAM,CAAC,UAAU;CAG1B"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @module feature-assembly/as-of/series-features
3
+ *
4
+ * Series features declared once in the unit's Temporal Spec: lag k reads the value k periods back; rolling windows
5
+ * aggregate periods [t − endLag − periods + 1, t − endLag]. Every lag and endLag is >= the horizon (the parser
6
+ * refuses otherwise), so nothing inside the horizon is ever read. A period's value is its resolved outcome, so a row
7
+ * reads it only when that period's outcome window had closed by the row's own decision day and by the assembly day (a
8
+ * row scored ahead of its decision date never reads a window still open at scoring); training and scoring both compute
9
+ * every lag here, so they null exactly the same cells.
10
+ */
11
+ import { MS_PER_DAY, UtcDay } from '@memberjunction/predictive-studio-core';
12
+ /** 1970-01-01 was a Thursday: shifting by three days makes whole weeks counted from the epoch start on Mondays. */
13
+ const EPOCH_TO_MONDAY_MS = 3 * MS_PER_DAY;
14
+ /** Series lags and rolling windows. */
15
+ export class SeriesFeatures {
16
+ /**
17
+ * Calendar index of a period, monotonic in time so consecutive periods differ by one: days since the epoch for daily,
18
+ * ISO weeks (Monday to Sunday, as the holdout carve and the trainer bucket weeks) for weekly, year * 12 + month for
19
+ * monthly, the year for yearly.
20
+ */
21
+ static PeriodIndex(period, unit) {
22
+ switch (unit) {
23
+ case 'day': return Math.floor(period.getTime() / MS_PER_DAY);
24
+ case 'week': return Math.floor((period.getTime() + EPOCH_TO_MONDAY_MS) / (7 * MS_PER_DAY));
25
+ case 'month': return period.getUTCFullYear() * 12 + period.getUTCMonth();
26
+ case 'year': return period.getUTCFullYear();
27
+ }
28
+ }
29
+ /** Indexes series points by entity and period; a later point for the same period replaces an earlier one. */
30
+ static BuildSeriesHistory(points, spec) {
31
+ const byEntity = new Map();
32
+ for (const p of points) {
33
+ const k = p.EntityKey.toLowerCase();
34
+ const m = byEntity.get(k) || new Map();
35
+ m.set(SeriesFeatures.PeriodIndex(p.Period, spec.period), p);
36
+ byEntity.set(k, m);
37
+ }
38
+ return { Spec: spec, ByEntity: byEntity };
39
+ }
40
+ /**
41
+ * One lag or rolling-window value for an entity at `period`, for a row decided on `decision` and assembled at
42
+ * `assembledAt`; null when any period it reads is missing or its outcome window had not closed by the earlier of the
43
+ * decision day and the assembly day (its window end is after that day).
44
+ *
45
+ * The assembly day matters only for a row decided after it, which only scoring builds (a row scored ahead of its
46
+ * decision date): its history keeps periods whose window is still open, and such a period's value is not yet its
47
+ * resolved outcome, so it is never read before its window has closed. A row decided on or before the assembly day,
48
+ * every row training reads included, keeps the decision-day rule, so training and scoring agree on it.
49
+ */
50
+ static ComputeSeriesFeature(history, entityKey, period, spec, feature, decision, assembledAt) {
51
+ const declared = feature.kind === 'lag' ? spec.lags.length : spec.rollingWindows.length;
52
+ if (!Number.isInteger(feature.index) || feature.index < 0 || feature.index >= declared)
53
+ throw SeriesFeatures.indexError(feature, declared);
54
+ const series = history.ByEntity.get(entityKey.toLowerCase());
55
+ const t = SeriesFeatures.PeriodIndex(period, spec.period);
56
+ if (!series)
57
+ return { Value: null, SourceRowIDs: [] };
58
+ const knownBy = Math.min(SeriesFeatures.requireDay(decision, 'decision date').getTime(), SeriesFeatures.requireDay(assembledAt, 'assembly instant').getTime());
59
+ const known = (i) => {
60
+ const p = series.get(i);
61
+ return p && p.WindowEnd.getTime() <= knownBy ? p : null;
62
+ };
63
+ if (feature.kind === 'lag') {
64
+ const p = known(t - spec.lags[feature.index]);
65
+ return p ? { Value: p.Value, SourceRowIDs: [p.RowID] } : { Value: null, SourceRowIDs: [] };
66
+ }
67
+ const w = spec.rollingWindows[feature.index];
68
+ const pts = [];
69
+ for (let i = t - w.endLag - w.periods + 1; i <= t - w.endLag; i++) {
70
+ const p = known(i);
71
+ if (!p)
72
+ return { Value: null, SourceRowIDs: [] };
73
+ pts.push(p);
74
+ }
75
+ const values = pts.map((p) => p.Value);
76
+ const value = w.aggregate === 'mean' ? values.reduce((s, v) => s + v, 0) / values.length
77
+ : w.aggregate === 'sum' ? values.reduce((s, v) => s + v, 0)
78
+ : w.aggregate === 'min' ? Math.min(...values) : Math.max(...values);
79
+ return { Value: value, SourceRowIDs: pts.map((p) => p.RowID) };
80
+ }
81
+ /**
82
+ * An instant as its UTC day: a row's decision (the assembly validates decision dates before any feature is read) or the
83
+ * assembly's own clock. A window end is a UTC day too, so a window ending on that day counts as closed, exactly as the
84
+ * unit reader's cutoff keeps a row whose window ends on the cutoff day.
85
+ */
86
+ static requireDay(instant, what) {
87
+ const day = UtcDay.ToUtcDay(instant);
88
+ if (day === null)
89
+ throw new Error(`Series features: a row has an invalid ${what}`);
90
+ return day;
91
+ }
92
+ /** Feature resolution refuses an out-of-range index; this guards the computation against a caller that skipped it. */
93
+ static indexError(feature, declared) {
94
+ return new Error(`Series ${feature.kind} feature index ${feature.index} is outside the Temporal Spec, which declares ${declared}`);
95
+ }
96
+ }
97
+ //# sourceMappingURL=series-features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"series-features.js","sourceRoot":"","sources":["../../../src/feature-assembly/as-of/series-features.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAuC,MAAM,wCAAwC,CAAC;AAEjH,mHAAmH;AACnH,MAAM,kBAAkB,GAAG,CAAC,GAAG,UAAU,CAAC;AAc1C,uCAAuC;AACvC,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,MAAY,EAAE,IAA4B;QAClE,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,KAAK,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC,CAAC;YAC7D,KAAK,MAAM,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;YAC3F,KAAK,OAAO,CAAC,CAAC,OAAO,MAAM,CAAC,cAAc,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;YACzE,KAAK,MAAM,CAAC,CAAC,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,6GAA6G;IACtG,MAAM,CAAC,kBAAkB,CAAC,MAA8B,EAAE,IAAkB;QACjF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAoC,CAAC;QAC7D,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,WAAW,E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AAO,CAAC,IAAI,kBAAkB,OAAO,CAAC,KAAK,iDAAiD,QAAQ,EAAE,CAAC,CAAC;IACrI,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { type CellValue, type WindowedAggregateSource } from '@memberjunction/predictive-studio-core';
2
+ import type { SourceRow } from '../data-access.js';
3
+ /** One child row reduced to what an as-of aggregate reads: its day, end and void days, value and change stamp. */
4
+ export interface ChildRow {
5
+ readonly Id: string;
6
+ readonly Day: Date;
7
+ readonly EndDay: Date | null;
8
+ readonly VoidedDay: Date | null;
9
+ readonly Value: CellValue;
10
+ readonly UpdatedAt: string;
11
+ }
12
+ /** Child rows keyed by lower-cased owner key, each list sorted by day then ID. */
13
+ export type ChildRowIndex = ReadonlyMap<string, readonly ChildRow[]>;
14
+ /** Windowed aggregates over a dated child table. */
15
+ export declare class WindowedAggregates {
16
+ /** Indexes the filtered, dated child rows by owner key; rows without a parseable date are skipped. */
17
+ static BuildChildRowIndex(rows: readonly SourceRow[], spec: WindowedAggregateSource, primaryKey: string): ChildRowIndex;
18
+ /** The order of an owner's child rows in a {@link ChildRowIndex}: by day, then by ID (ordinal). */
19
+ static CompareChildRows(a: ChildRow, b: ChildRow): number;
20
+ /**
21
+ * The aggregate for one owner as of `decision`, read as its UTC day so a time of day never shifts the window.
22
+ * `Contributors` are the child rows the aggregate read (the window, or the rows active on the day; the latest row for
23
+ * days-since), including rows whose value a sum or mean skipped as missing.
24
+ */
25
+ static ComputeWindowedAggregate(index: ChildRowIndex, ownerKey: string, decision: Date, spec: WindowedAggregateSource): {
26
+ readonly Value: number | null;
27
+ readonly Contributors: readonly ChildRow[];
28
+ };
29
+ /**
30
+ * The numbers a sum or mean reads: a missing value (null, undefined or a blank string) is skipped so it neither adds
31
+ * nor counts in a mean's denominator. A number is a finite number or a non-blank string that parses to one; any
32
+ * other present value (a date, a boolean, text) refuses, so it is never silently dropped or read as epoch ms / 1 / 0.
33
+ */
34
+ private static numericValues;
35
+ }
36
+ //# sourceMappingURL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IG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAa7B"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @module feature-assembly/as-of/windowed-aggregate
3
+ *
4
+ * Summaries of a dated child table as of a decision date: rows dated in (d − windowDays, d] (or on/before d when no
5
+ * window), minus rows voided on or before d, then count | sum | mean | distinct | days-since, or active-at
6
+ * (dateField <= d and (endDateField null or >= d)). Generalises the executor's two hard-coded aggregates. sum and
7
+ * mean skip a missing value (null, undefined or blank) and refuse a present value that is not a number (a date, a
8
+ * boolean or text).
9
+ */
10
+ import { OrdinalCompare } from '@memberjunction/global';
11
+ import { MS_PER_DAY, UtcDay } from '@memberjunction/predictive-studio-core';
12
+ import { PredictionUnitRowReader } from '../../prediction-unit/unit-row-reader.js';
13
+ import { AssemblyRefused } from './refusal.js';
14
+ /** Windowed aggregates over a dated child table. */
15
+ export class WindowedAggregates {
16
+ /** Indexes the filtered, dated child rows by owner key; rows without a parseable date are skipped. */
17
+ static BuildChildRowIndex(rows, spec, primaryKey) {
18
+ const out = new Map();
19
+ for (const r of rows) {
20
+ if (!PredictionUnitRowReader.MatchesRowFilters(r, spec.filter))
21
+ continue;
22
+ const day = UtcDay.ToUtcDay(r[spec.dateField]);
23
+ if (day === null)
24
+ continue;
25
+ // `??`: a numeric 0 owner key is a real key; only an absent one becomes ''.
26
+ const owner = String(r[spec.foreignKey] ?? '').toLowerCase();
27
+ const list = out.get(owner) || [];
28
+ const updated = r.__mj_UpdatedAt;
29
+ list.push({
30
+ Id: String(r[primaryKey]),
31
+ Day: day,
32
+ EndDay: spec.endDateField ? UtcDay.ToUtcDay(r[spec.endDateField]) : null,
33
+ VoidedDay: spec.voidedAtField ? UtcDay.ToUtcDay(r[spec.voidedAtField]) : null,
34
+ Value: spec.valueField ? r[spec.valueField] : null,
35
+ UpdatedAt: updated instanceof Date ? updated.toISOString() : String(updated || ''),
36
+ });
37
+ out.set(owner, list);
38
+ }
39
+ for (const list of out.values())
40
+ list.sort(WindowedAggregates.CompareChildRows);
41
+ return out;
42
+ }
43
+ /** The order of an owner's child rows in a {@link ChildRowIndex}: by day, then by ID (ordinal). */
44
+ static CompareChildRows(a, b) {
45
+ return a.Day.getTime() - b.Day.getTime() || OrdinalCompare(a.Id, b.Id);
46
+ }
47
+ /**
48
+ * The aggregate for one owner as of `decision`, read as its UTC day so a time of day never shifts the window.
49
+ * `Contributors` are the child rows the aggregate read (the window, or the rows active on the day; the latest row for
50
+ * days-since), including rows whose value a sum or mean skipped as missing.
51
+ */
52
+ static ComputeWindowedAggregate(index, ownerKey, decision, spec) {
53
+ const decisionDay = UtcDay.ToUtcDay(decision);
54
+ if (decisionDay === null)
55
+ throw new Error(`Windowed aggregate ${spec.childEntity}: the decision date is not a valid date`);
56
+ const d = decisionDay.getTime();
57
+ const all = index.get(ownerKey.toLowerCase()) || [];
58
+ const live = all.filter((c) => c.VoidedDay === null || c.VoidedDay.getTime() > d);
59
+ if (spec.aggregate === 'active-at') {
60
+ const active = live.filter((c) => c.Day.getTime() <= d && (c.EndDay === null || c.EndDay.getTime() >= d));
61
+ return { Value: active.length, Contributors: active };
62
+ }
63
+ const from = spec.windowDays === null ? Number.NEGATIVE_INFINITY : d - spec.windowDays * MS_PER_DAY;
64
+ const inWindow = live.filter((c) => c.Day.getTime() > from && c.Day.getTime() <= d);
65
+ switch (spec.aggregate) {
66
+ case 'count': return { Value: inWindow.length, Contributors: inWindow };
67
+ case 'sum': return { Value: WindowedAggregates.numericValues(inWindow, spec).reduce((s, n) => s + n, 0), Contributors: inWindow };
68
+ case 'mean': {
69
+ const numbers = WindowedAggregates.numericValues(inWindow, spec);
70
+ return { Value: numbers.length > 0 ? numbers.reduce((s, n) => s + n, 0) / numbers.length : null, Contributors: inWindow };
71
+ }
72
+ case 'distinct': return { Value: new Set(inWindow.map((c) => String(c.Value))).size, Contributors: inWindow };
73
+ case 'days-since': {
74
+ const latest = inWindow[inWindow.length - 1];
75
+ return { Value: latest ? Math.round((d - latest.Day.getTime()) / MS_PER_DAY) : null, Contributors: latest ? [latest] : [] };
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * The numbers a sum or mean reads: a missing value (null, undefined or a blank string) is skipped so it neither adds
81
+ * nor counts in a mean's denominator. A number is a finite number or a non-blank string that parses to one; any
82
+ * other present value (a date, a boolean, text) refuses, so it is never silently dropped or read as epoch ms / 1 / 0.
83
+ */
84
+ static numericValues(rows, spec) {
85
+ const out = [];
86
+ for (const c of rows) {
87
+ const v = c.Value;
88
+ if (v === null || v === undefined || (typeof v === 'string' && v.trim() === ''))
89
+ continue;
90
+ const n = typeof v === 'number' ? v : typeof v === 'string' ? Number(v) : Number.NaN;
91
+ if (!Number.isFinite(n)) {
92
+ throw new AssemblyRefused({ kind: 'non-numeric-in-numeric-column', column: `${spec.childEntity}.${spec.valueField}`, sampleValue: String(v) });
93
+ }
94
+ out.push(n);
95
+ }
96
+ return out;
97
+ }
98
+ }
99
+ //# sourceMappingURL=windowed-aggregate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"windowed-aggregate.js","sourceRoot":"","sources":["../../../src/feature-assembly/as-of/windowed-aggregate.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAgD,MAAM,wCAAwC,CAAC;AAE1H,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAe5C,oDAAoD;AACpD,MAAM,OAAO,kBAAkB;IAC7B,sGAAsG;IAC/F,MAAM,CAAC,kBAAkB,CAAC,IAA0B,EAAE,IAA6B,EAAE,UAAkB;QAC5G,MAAM,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,CAAC,EA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IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,+BAA+B,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACjJ,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -13,7 +13,7 @@
13
13
  * and provides helpers that filter dated source rows to those at-or-before that
14
14
  * date, then compute recency/aggregate features only over the surviving rows.
15
15
  */
16
- import type { AsOfStrategy } from '@memberjunction/predictive-studio-core';
16
+ import { type AsOfStrategy } from '@memberjunction/predictive-studio-core';
17
17
  import type { SourceRow } from './data-access.js';
18
18
  /** A single dated event/activity row scoped to a target record. */
19
19
  export interface DatedRow {
@@ -37,8 +37,6 @@ export interface DatedRow {
37
37
  * @returns the resolved as-of cutoff, or `null` when no filtering applies
38
38
  */
39
39
  export declare function ResolveAsOfDate(strategy: AsOfStrategy, record: SourceRow, labelEventDate?: Date | null): Date | null;
40
- /** @deprecated Use {@link ResolveAsOfDate}. */
41
- export declare function resolveAsOfDate(strategy: AsOfStrategy, record: SourceRow, labelEventDate?: Date | null): Date | null;
42
40
  /**
43
41
  * Filters dated rows to those occurring at-or-before the as-of cutoff. A `null`
44
42
  * cutoff (i.e. `Mode='none'`) is the identity filter — all rows survive.
@@ -51,8 +49,6 @@ export declare function resolveAsOfDate(strategy: AsOfStrategy, record: SourceRo
51
49
  * @returns the rows at-or-before the cutoff
52
50
  */
53
51
  export declare function FilterAsOf(rows: DatedRow[], asOfDate: Date | null): DatedRow[];
54
- /** @deprecated Use {@link FilterAsOf}. */
55
- export declare function filterAsOf(rows: DatedRow[], asOfDate: Date | null): DatedRow[];
56
52
  /**
57
53
  * Computes `days_since_last_activity` as of the cutoff: the whole-day gap
58
54
  * between the cutoff date and the most recent surviving event. Returns `null`
@@ -66,8 +62,6 @@ export declare function filterAsOf(rows: DatedRow[], asOfDate: Date | null): Dat
66
62
  * @param asOfDate the resolved cutoff; when `null`, recency is measured from "now"
67
63
  */
68
64
  export declare function DaysSinceLastActivityAsOf(rows: DatedRow[], asOfDate: Date | null): number | null;
69
- /** @deprecated Use {@link DaysSinceLastActivityAsOf}. */
70
- export declare function daysSinceLastActivityAsOf(rows: DatedRow[], asOfDate: Date | null): number | null;
71
65
  /**
72
66
  * Counts surviving activity rows as of the cutoff — a generic point-in-time
73
67
  * aggregate (e.g. `activity_count_asof`). Only rows at-or-before the cutoff are
@@ -77,6 +71,4 @@ export declare function daysSinceLastActivityAsOf(rows: DatedRow[], asOfDate: Da
77
71
  * @param asOfDate the resolved cutoff, or `null` for no filtering
78
72
  */
79
73
  export declare function ActivityCountAsOf(rows: DatedRow[], asOfDate: Date | null): number;
80
- /** @deprecated Use {@link ActivityCountAsOf}. */
81
- export declare function activityCountAsOf(rows: DatedRow[], asOfDate: Date | null): number;
82
74
  //# sourceMappingURL=as-of.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"as-of.d.ts","sourceRoot":"","sources":["../../src/feature-assembly/as-of.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,6BAA6B;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,8EAA8E;IAC9E,GAAG,EAAE,SAAS,CAAC;CAChB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG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AW,QAAQ;IACvB,6BAA6B;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,8EAA8E;IAC9E,GAAG,EAAE,SAAS,CAAC;CAChB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAgCpH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,QAAQ,EAAE,CAM9E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAehG;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAEjF"}
@@ -13,6 +13,7 @@
13
13
  * and provides helpers that filter dated source rows to those at-or-before that
14
14
  * date, then compute recency/aggregate features only over the surviving rows.
15
15
  */
16
+ import { MS_PER_DAY } from '@memberjunction/predictive-studio-core';
16
17
  /**
17
18
  * Resolves the per-record as-of date from the configured {@link AsOfStrategy}.
18
19
  *
@@ -43,7 +44,7 @@ export function ResolveAsOfDate(strategy, record, labelEventDate) {
43
44
  return parsed;
44
45
  }
45
46
  case 'offset': {
46
- if (strategy.OffsetDays == null) {
47
+ if ((strategy.OffsetDays === null || strategy.OffsetDays === undefined)) {
47
48
  throw new Error(`AsOfStrategy.Mode='offset' requires OffsetDays.`);
48
49
  }
49
50
  if (!labelEventDate) {
@@ -60,10 +61,6 @@ export function ResolveAsOfDate(strategy, record, labelEventDate) {
60
61
  }
61
62
  }
62
63
  }
63
- /** @deprecated Use {@link ResolveAsOfDate}. */
64
- export function resolveAsOfDate(strategy, record, labelEventDate) {
65
- return ResolveAsOfDate(strategy, record, labelEventDate);
66
- }
67
64
  /**
68
65
  * Filters dated rows to those occurring at-or-before the as-of cutoff. A `null`
69
66
  * cutoff (i.e. `Mode='none'`) is the identity filter — all rows survive.
@@ -82,10 +79,6 @@ export function FilterAsOf(rows, asOfDate) {
82
79
  const cutoff = asOfDate.getTime();
83
80
  return rows.filter((r) => r.Date.getTime() <= cutoff);
84
81
  }
85
- /** @deprecated Use {@link FilterAsOf}. */
86
- export function filterAsOf(rows, asOfDate) {
87
- return FilterAsOf(rows, asOfDate);
88
- }
89
82
  /**
90
83
  * Computes `days_since_last_activity` as of the cutoff: the whole-day gap
91
84
  * between the cutoff date and the most recent surviving event. Returns `null`
@@ -114,10 +107,6 @@ export function DaysSinceLastActivityAsOf(rows, asOfDate) {
114
107
  const diffMs = reference.getTime() - mostRecent;
115
108
  return Math.floor(diffMs / MS_PER_DAY);
116
109
  }
117
- /** @deprecated Use {@link DaysSinceLastActivityAsOf}. */
118
- export function daysSinceLastActivityAsOf(rows, asOfDate) {
119
- return DaysSinceLastActivityAsOf(rows, asOfDate);
120
- }
121
110
  /**
122
111
  * Counts surviving activity rows as of the cutoff — a generic point-in-time
123
112
  * aggregate (e.g. `activity_count_asof`). Only rows at-or-before the cutoff are
@@ -129,12 +118,6 @@ export function daysSinceLastActivityAsOf(rows, asOfDate) {
129
118
  export function ActivityCountAsOf(rows, asOfDate) {
130
119
  return FilterAsOf(rows, asOfDate).length;
131
120
  }
132
- /** @deprecated Use {@link ActivityCountAsOf}. */
133
- export function activityCountAsOf(rows, asOfDate) {
134
- return ActivityCountAsOf(rows, asOfDate);
135
- }
136
- /** Milliseconds in one day. */
137
- const MS_PER_DAY = 24 * 60 * 60 * 1000;
138
121
  /**
139
122
  * Coerces a loosely-typed source value into a `Date`, or `null` when it cannot
140
123
  * be interpreted as a valid date.
@@ -1 +1 @@
1
- {"version":3,"file":"as-of.js","sourceRoot":"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IACH,CAAC;IACD,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,GAAG,UAAU,CAAC;IAChD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAgB,EAAE,QAAqB;IACvE,OAAO,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CAAC,KAAc;IAChC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACtD,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @module feature-assembly/assembly-metadata
3
+ *
4
+ * The narrow view of entity metadata the unit reader and the as-of assembly need, so both are testable with plain
5
+ * objects. `ProviderAssemblyMetadata` adapts the provider's `EntityInfo`.
6
+ */
7
+ import type { EntityFieldTSType, IMetadataProvider } from '@memberjunction/core';
8
+ export interface AssemblyFieldInfo {
9
+ readonly Name: string;
10
+ readonly SqlType: string;
11
+ readonly TSType: EntityFieldTSType;
12
+ /** `false` = declared immutable after creation (`MJ: Entity Fields.AllowUpdateAPI`). */
13
+ readonly AllowUpdateAPI: boolean;
14
+ readonly IsPrimaryKey: boolean;
15
+ readonly RelatedEntity: string | null;
16
+ readonly IsVirtual: boolean;
17
+ }
18
+ export interface AssemblyEntityInfo {
19
+ readonly ID: string;
20
+ readonly Name: string;
21
+ readonly PrimaryKey: string;
22
+ readonly TrackRecordChanges: boolean;
23
+ readonly Fields: readonly AssemblyFieldInfo[];
24
+ }
25
+ export interface IAssemblyMetadata {
26
+ /** The entity, or null when it is not registered or has a composite primary key (PS units need one key). */
27
+ Entity(name: string): AssemblyEntityInfo | null;
28
+ }
29
+ export declare class ProviderAssemblyMetadata implements IAssemblyMetadata {
30
+ private readonly provider;
31
+ constructor(provider: IMetadataProvider);
32
+ Entity(name: string): AssemblyEntityInfo | null;
33
+ }
34
+ //# sourceMappingURL=assembly-metadata.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assembly-metadata.d.ts","sourceRoot":"","sources":["../../src/feature-assembly/assembly-metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,wFAAwF;IACxF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC,4GAA4G;IAC5G,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAAC;CACjD;AAED,qBAAa,wBAAyB,YAAW,iBAAiB;IACpD,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,iBAAiB;IAEjD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;CAmBvD"}
@@ -0,0 +1,26 @@
1
+ export class ProviderAssemblyMetadata {
2
+ constructor(provider) {
3
+ this.provider = provider;
4
+ }
5
+ Entity(name) {
6
+ const e = this.provider.EntityByName(name);
7
+ if (!e || e.PrimaryKeys.length !== 1)
8
+ return null;
9
+ return {
10
+ ID: e.ID,
11
+ Name: e.Name,
12
+ PrimaryKey: e.FirstPrimaryKey.Name, // first-pk-ok: entities with a composite key return null above (PS units need one key)
13
+ TrackRecordChanges: e.TrackRecordChanges === true,
14
+ Fields: e.Fields.map((f) => ({
15
+ Name: f.Name,
16
+ SqlType: f.Type,
17
+ TSType: f.TSType,
18
+ AllowUpdateAPI: f.AllowUpdateAPI !== false,
19
+ IsPrimaryKey: f.IsPrimaryKey === true,
20
+ RelatedEntity: f.RelatedEntity || null,
21
+ IsVirtual: f.IsVirtual === true,
22
+ })),
23
+ };
24
+ }
25
+ }
26
+ //# sourceMappingURL=assembly-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assembly-metadata.js","sourceRoot":"","sources":["../../src/feature-assembly/assembly-metadata.ts"],"names":[],"mappings":"AAgCA,MAAM,OAAO,wBAAwB;IACnC,YAA6B,QAA2B;QAA3B,aAAQ,GAAR,QAAQ,CAAmB;IAAG,CAAC;IAErD,MAAM,CAAC,IAAY;QACxB,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAClD,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,UAAU,EAAE,CAAC,CAAC,eAAe,CAAC,IAAI,EAAE,uFAAuF;YAC3H,kBAAkB,EAAE,CAAC,CAAC,kBAAkB,KAAK,IAAI;YACjD,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC3B,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,OAAO,EAAE,CAAC,CAAC,IAAI;gBACf,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,cAAc,EAAE,CAAC,CAAC,cAAc,KAAK,KAAK;gBAC1C,YAAY,EAAE,CAAC,CAAC,YAAY,KAAK,IAAI;gBACrC,aAAa,EAAE,CAAC,CAAC,aAAa,IAAI,IAAI;gBACtC,SAAS,EAAE,CAAC,CAAC,SAAS,KAAK,IAAI;aAChC,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF"}
@@ -22,7 +22,7 @@ import { type UserInfo, type IMetadataProvider } from '@memberjunction/core';
22
22
  * because sources come from heterogeneous entities/queries; the executor selects
23
23
  * and types the columns it needs downstream.
24
24
  */
25
- export type SourceRow = Record<string, string | number | boolean | null | undefined>;
25
+ export type SourceRow = Record<string, string | number | boolean | Date | null | undefined>;
26
26
  /**
27
27
  * Read parameters for fetching rows from a named source. A subset of MJ's
28
28
  * `RunViewParams`, narrowed to what FeatureAssembly needs (read-only).
@@ -85,13 +85,27 @@ export interface IFeatureDataAccess {
85
85
  */
86
86
  fetchEmbedding(entity: string, recordId: string, embeddingModelRef: string, dims: number): Promise<number[] | null>;
87
87
  }
88
+ /** Result of {@link ICountingDataAccess.CountRows}. */
89
+ export interface CountRowsResult {
90
+ readonly Success: boolean;
91
+ readonly Count: number;
92
+ readonly ErrorMessage?: string;
93
+ }
94
+ /** Data access that can also count a source exactly, as complete reads require. */
95
+ export interface ICountingDataAccess extends IFeatureDataAccess {
96
+ /** The number of rows `fetchRows` with the same entity and filter must return. */
97
+ CountRows(params: {
98
+ readonly EntityName: string;
99
+ readonly ExtraFilter?: string;
100
+ }): Promise<CountRowsResult>;
101
+ }
88
102
  /**
89
103
  * Production {@link IFeatureDataAccess} backed by `@memberjunction/core`'s
90
104
  * `RunView`. Always passes `contextUser` so server-side reads honor per-user
91
105
  * data isolation, and always reads through the caller's `IMetadataProvider`
92
106
  * (multi-provider correctness — there is no global-provider fallback).
93
107
  */
94
- export declare class RunViewDataAccess implements IFeatureDataAccess {
108
+ export declare class RunViewDataAccess implements ICountingDataAccess {
95
109
  private readonly runView;
96
110
  private readonly contextUser;
97
111
  /**
@@ -114,5 +128,10 @@ export declare class RunViewDataAccess implements IFeatureDataAccess {
114
128
  * via an in-memory `IFeatureDataAccess`, so this stub never blocks them.
115
129
  */
116
130
  fetchEmbedding(_entity: string, _recordId: string, _embeddingModelRef: string, _dims: number): Promise<number[] | null>;
131
+ /** @inheritdoc */
132
+ CountRows(params: {
133
+ readonly EntityName: string;
134
+ readonly ExtraFilter?: string;
135
+ }): Promise<CountRowsResult>;
117
136
  }
118
137
  //# sourceMappingURL=data-access.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"data-access.d.ts","sourceRoot":"","sources":["../../src/feature-assembly/data-access.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEtF;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAErF;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B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// The read does not skip the count, so RunView reports it; a read without one cannot be checked for truncation.
53
+ if (result.TotalRowCount === undefined) {
54
+ return { Success: false, Rows: [], TotalRowCount: 0, ErrorMessage: `${params.EntityName}: the read returned no total row count, so it cannot be checked for truncation` };
55
+ }
52
56
  return { Success: true, Rows: result.Results || [], TotalRowCount: result.TotalRowCount };
53
57
  }
54
58
  /**
@@ -66,5 +70,15 @@ export class RunViewDataAccess {
66
70
  async fetchEmbedding(_entity, _recordId, _embeddingModelRef, _dims) {
67
71
  return null;
68
72
  }
73
+ /** @inheritdoc */
74
+ async CountRows(params) {
75
+ const result = await this.runView.RunView({ EntityName: params.EntityName, ExtraFilter: params.ExtraFilter || '', ResultType: 'count_only', IgnoreMaxRows: true }, this.contextUser);
76
+ if (!result.Success)
77
+ return { Success: false, Count: 0, ErrorMessage: result.ErrorMessage };
78
+ // A count_only read always counts; a result without one is not a count.
79
+ if (result.TotalRowCount === undefined)
80
+ return { Success: false, Count: 0, ErrorMessage: `${params.EntityName}: the count read returned no total row count` };
81
+ return { Success: true, Count: result.TotalRowCount };
82
+ }
69
83
  }
70
84
  //# sourceMappingURL=data-access.js.map