palistor 0.0.24 → 0.0.26

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 (278) hide show
  1. package/README.md +574 -542
  2. package/README.ru.md +979 -0
  3. package/dist/index.d.ts +19 -28
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +21 -28
  6. package/dist/index.js.map +1 -1
  7. package/dist/react/createTrackingProxy.d.ts +27 -27
  8. package/dist/react/createTrackingProxy.d.ts.map +1 -1
  9. package/dist/react/createTrackingProxy.js +92 -42
  10. package/dist/react/createTrackingProxy.js.map +1 -1
  11. package/dist/react/useForm.d.ts +42 -43
  12. package/dist/react/useForm.d.ts.map +1 -1
  13. package/dist/react/useForm.js +38 -38
  14. package/dist/react/useForm.js.map +1 -1
  15. package/dist/react/usePersist.d.ts +14 -14
  16. package/dist/react/usePersist.js +18 -18
  17. package/dist/react/usePersist.js.map +1 -1
  18. package/dist/react/useStoreContext.d.ts +11 -11
  19. package/dist/react/useStoreContext.js +11 -11
  20. package/dist/react/useTranslator.d.ts +12 -12
  21. package/dist/react/useTranslator.js +12 -12
  22. package/dist/store/applyPatch/applyPatch.d.ts +8 -8
  23. package/dist/store/applyPatch/applyPatch.js +12 -12
  24. package/dist/store/applyPatch/applyPatch.js.map +1 -1
  25. package/dist/store/buildProxy/buildEntityProjectionProxy.js +6 -6
  26. package/dist/store/buildProxy/buildEntityProjectionProxy.js.map +1 -1
  27. package/dist/store/buildProxy/buildListProxy.d.ts +8 -8
  28. package/dist/store/buildProxy/buildListProxy.js +30 -30
  29. package/dist/store/buildProxy/buildListProxy.js.map +1 -1
  30. package/dist/store/buildProxy/buildProxy.d.ts +8 -8
  31. package/dist/store/buildProxy/buildProxy.d.ts.map +1 -1
  32. package/dist/store/buildProxy/buildProxy.js +84 -33
  33. package/dist/store/buildProxy/buildProxy.js.map +1 -1
  34. package/dist/store/buildProxy/computeProxyKeys.d.ts +8 -8
  35. package/dist/store/buildProxy/computeProxyKeys.d.ts.map +1 -1
  36. package/dist/store/buildProxy/computeProxyKeys.js +18 -13
  37. package/dist/store/buildProxy/computeProxyKeys.js.map +1 -1
  38. package/dist/store/buildProxy/handleLazyResolve.d.ts +3 -3
  39. package/dist/store/buildProxy/handleLazyResolve.js +3 -3
  40. package/dist/store/buildProxy/initProxyCaches.d.ts +5 -5
  41. package/dist/store/buildProxy/initProxyCaches.js +5 -5
  42. package/dist/store/compute/computeFieldState.d.ts +3 -3
  43. package/dist/store/compute/computeFieldState.js +8 -8
  44. package/dist/store/compute/computeFieldState.js.map +1 -1
  45. package/dist/store/compute/fieldStateChanged.d.ts +1 -1
  46. package/dist/store/compute/fieldStateChanged.js +1 -1
  47. package/dist/store/compute/recompute/collectGroupComputeNodes.d.ts +4 -4
  48. package/dist/store/compute/recompute/collectGroupComputeNodes.js +7 -7
  49. package/dist/store/compute/recompute/collectGroupComputeNodes.js.map +1 -1
  50. package/dist/store/compute/recompute/recomputeAndNotify.d.ts +3 -3
  51. package/dist/store/compute/recompute/recomputeAndNotify.js +3 -3
  52. package/dist/store/compute/recompute/recomputeLeaves.d.ts +11 -10
  53. package/dist/store/compute/recompute/recomputeLeaves.d.ts.map +1 -1
  54. package/dist/store/compute/recompute/recomputeLeaves.js +26 -27
  55. package/dist/store/compute/recompute/recomputeLeaves.js.map +1 -1
  56. package/dist/store/compute/recompute/recomputeTargeted.d.ts +7 -7
  57. package/dist/store/compute/recompute/recomputeTargeted.js +12 -12
  58. package/dist/store/compute/recompute/recomputeTargeted.js.map +1 -1
  59. package/dist/store/compute/recompute/topologicalSortComputed.d.ts +4 -4
  60. package/dist/store/compute/recompute/topologicalSortComputed.d.ts.map +1 -1
  61. package/dist/store/compute/recompute/topologicalSortComputed.js +11 -13
  62. package/dist/store/compute/recompute/topologicalSortComputed.js.map +1 -1
  63. package/dist/store/compute/recompute/types.d.ts +4 -4
  64. package/dist/store/compute/resolveFlag.d.ts +2 -2
  65. package/dist/store/compute/resolveFlag.js +2 -2
  66. package/dist/store/compute/resolveString.d.ts +5 -5
  67. package/dist/store/compute/resolveString.js +6 -6
  68. package/dist/store/compute/resolveString.js.map +1 -1
  69. package/dist/store/compute/types.d.ts +3 -3
  70. package/dist/store/constants.d.ts +57 -38
  71. package/dist/store/constants.d.ts.map +1 -1
  72. package/dist/store/constants.js +70 -35
  73. package/dist/store/constants.js.map +1 -1
  74. package/dist/store/defineFieldMapping.d.ts +21 -19
  75. package/dist/store/defineFieldMapping.d.ts.map +1 -1
  76. package/dist/store/defineFieldMapping.js +21 -19
  77. package/dist/store/defineFieldMapping.js.map +1 -1
  78. package/dist/store/dirtyTracking/collectInitialSnapshot.js +1 -1
  79. package/dist/store/dirtyTracking/collectInitialSnapshot.js.map +1 -1
  80. package/dist/store/dirtyTracking/recomputeDirtyTargeted.d.ts +3 -3
  81. package/dist/store/dirtyTracking/recomputeDirtyTargeted.js +11 -11
  82. package/dist/store/dirtyTracking/recomputeDirtyTargeted.js.map +1 -1
  83. package/dist/store/dirtyTracking/setGroupRevalidate.d.ts +6 -6
  84. package/dist/store/dirtyTracking/setGroupRevalidate.js +7 -7
  85. package/dist/store/dirtyTracking/setGroupRevalidate.js.map +1 -1
  86. package/dist/store/entityRegistry/entityRegistry.d.ts +72 -72
  87. package/dist/store/entityRegistry/entityRegistry.d.ts.map +1 -1
  88. package/dist/store/entityRegistry/entityRegistry.js +91 -91
  89. package/dist/store/entityRegistry/entityRegistry.js.map +1 -1
  90. package/dist/store/entityRegistry/generateId.d.ts +3 -3
  91. package/dist/store/entityRegistry/generateId.js +3 -3
  92. package/dist/store/entityRegistry/types.d.ts +17 -17
  93. package/dist/store/entityRegistry/types.d.ts.map +1 -1
  94. package/dist/store/flow/buildFlowStepsProxy.d.ts +17 -0
  95. package/dist/store/flow/buildFlowStepsProxy.d.ts.map +1 -0
  96. package/dist/store/flow/buildFlowStepsProxy.js +72 -0
  97. package/dist/store/flow/buildFlowStepsProxy.js.map +1 -0
  98. package/dist/store/flow/defineFlow.d.ts +92 -0
  99. package/dist/store/flow/defineFlow.d.ts.map +1 -0
  100. package/dist/store/flow/defineFlow.js +99 -0
  101. package/dist/store/flow/defineFlow.js.map +1 -0
  102. package/dist/store/flow/flowApi.d.ts +18 -0
  103. package/dist/store/flow/flowApi.d.ts.map +1 -0
  104. package/dist/store/flow/flowApi.js +18 -0
  105. package/dist/store/flow/flowApi.js.map +1 -0
  106. package/dist/store/flow/flowNavigation.d.ts +137 -0
  107. package/dist/store/flow/flowNavigation.d.ts.map +1 -0
  108. package/dist/store/flow/flowNavigation.js +384 -0
  109. package/dist/store/flow/flowNavigation.js.map +1 -0
  110. package/dist/store/flow/flowState.d.ts +41 -0
  111. package/dist/store/flow/flowState.d.ts.map +1 -0
  112. package/dist/store/flow/flowState.js +51 -0
  113. package/dist/store/flow/flowState.js.map +1 -0
  114. package/dist/store/flow/index.d.ts +10 -0
  115. package/dist/store/flow/index.d.ts.map +1 -0
  116. package/dist/store/flow/index.js +6 -0
  117. package/dist/store/flow/index.js.map +1 -0
  118. package/dist/store/groupDeps/createGroupDeps.d.ts +3 -3
  119. package/dist/store/groupDeps/createGroupDeps.js +6 -6
  120. package/dist/store/groupDeps/createGroupDeps.js.map +1 -1
  121. package/dist/store/groupDeps/createTrackingValues.d.ts +9 -9
  122. package/dist/store/groupDeps/createTrackingValues.js +11 -11
  123. package/dist/store/groupDeps/createTrackingValues.js.map +1 -1
  124. package/dist/store/groupDeps/getNodeGroupPath.d.ts +3 -3
  125. package/dist/store/groupDeps/getNodeGroupPath.js +5 -5
  126. package/dist/store/groupDeps/getNodeGroupPath.js.map +1 -1
  127. package/dist/store/groupDeps/getRecipientGroups.d.ts +1 -1
  128. package/dist/store/groupDeps/getRecipientGroups.js +1 -1
  129. package/dist/store/groupDeps/groupDeps.d.ts +7 -7
  130. package/dist/store/groupDeps/groupDeps.js +7 -7
  131. package/dist/store/groupDeps/pairKey.d.ts +3 -3
  132. package/dist/store/groupDeps/pairKey.d.ts.map +1 -1
  133. package/dist/store/groupDeps/pairKey.js +4 -4
  134. package/dist/store/groupDeps/pairKey.js.map +1 -1
  135. package/dist/store/groupDeps/resolveGroupByPath.d.ts +3 -3
  136. package/dist/store/groupDeps/resolveGroupByPath.js +3 -3
  137. package/dist/store/init/createNotificationHub.d.ts +31 -31
  138. package/dist/store/init/createNotificationHub.d.ts.map +1 -1
  139. package/dist/store/init/createNotificationHub.js +36 -37
  140. package/dist/store/init/createNotificationHub.js.map +1 -1
  141. package/dist/store/init/createResolveManager.d.ts +72 -69
  142. package/dist/store/init/createResolveManager.d.ts.map +1 -1
  143. package/dist/store/init/createResolveManager.js +101 -98
  144. package/dist/store/init/createResolveManager.js.map +1 -1
  145. package/dist/store/init/initGroupSubmitting.d.ts +2 -2
  146. package/dist/store/init/initGroupSubmitting.js +4 -4
  147. package/dist/store/init/initGroupSubmitting.js.map +1 -1
  148. package/dist/store/normalizeConfig.d.ts +20 -18
  149. package/dist/store/normalizeConfig.d.ts.map +1 -1
  150. package/dist/store/normalizeConfig.js +31 -29
  151. package/dist/store/normalizeConfig.js.map +1 -1
  152. package/dist/store/onChangePipeline/computeFieldKey.d.ts +2 -2
  153. package/dist/store/onChangePipeline/computeFieldKey.js +2 -2
  154. package/dist/store/onChangePipeline/findOnChangeAncestors.d.ts +2 -2
  155. package/dist/store/onChangePipeline/findOnChangeAncestors.js +4 -4
  156. package/dist/store/onChangePipeline/findOnChangeAncestors.js.map +1 -1
  157. package/dist/store/onChangePipeline/onChangePipeline.d.ts +13 -12
  158. package/dist/store/onChangePipeline/onChangePipeline.d.ts.map +1 -1
  159. package/dist/store/onChangePipeline/onChangePipeline.js +14 -13
  160. package/dist/store/onChangePipeline/onChangePipeline.js.map +1 -1
  161. package/dist/store/persist/drivers.d.ts +7 -7
  162. package/dist/store/persist/drivers.js +8 -8
  163. package/dist/store/persist/drivers.js.map +1 -1
  164. package/dist/store/persist/index.d.ts +1 -1
  165. package/dist/store/persist/persistManager.d.ts +23 -23
  166. package/dist/store/persist/persistManager.d.ts.map +1 -1
  167. package/dist/store/persist/persistManager.js +73 -42
  168. package/dist/store/persist/persistManager.js.map +1 -1
  169. package/dist/store/persist/types.d.ts +23 -23
  170. package/dist/store/persist/types.d.ts.map +1 -1
  171. package/dist/store/persist/types.js +4 -4
  172. package/dist/store/resetPipeline/buildResetPatch.d.ts +5 -5
  173. package/dist/store/resetPipeline/buildResetPatch.js +5 -5
  174. package/dist/store/resetPipeline/collectDefaults.d.ts +5 -5
  175. package/dist/store/resetPipeline/collectDefaults.js +6 -6
  176. package/dist/store/resetPipeline/collectDefaults.js.map +1 -1
  177. package/dist/store/resetPipeline/resetPipeline.d.ts +7 -7
  178. package/dist/store/resetPipeline/resetPipeline.d.ts.map +1 -1
  179. package/dist/store/resetPipeline/resetPipeline.js +17 -12
  180. package/dist/store/resetPipeline/resetPipeline.js.map +1 -1
  181. package/dist/store/resolvePipeline/applyPendingWrites.d.ts +10 -10
  182. package/dist/store/resolvePipeline/applyPendingWrites.d.ts.map +1 -1
  183. package/dist/store/resolvePipeline/applyPendingWrites.js +35 -38
  184. package/dist/store/resolvePipeline/applyPendingWrites.js.map +1 -1
  185. package/dist/store/resolvePipeline/createContextTrackingProxy.d.ts +8 -7
  186. package/dist/store/resolvePipeline/createContextTrackingProxy.d.ts.map +1 -1
  187. package/dist/store/resolvePipeline/createContextTrackingProxy.js +6 -5
  188. package/dist/store/resolvePipeline/createContextTrackingProxy.js.map +1 -1
  189. package/dist/store/resolvePipeline/createValuesTrackingProxy.d.ts +43 -43
  190. package/dist/store/resolvePipeline/createValuesTrackingProxy.d.ts.map +1 -1
  191. package/dist/store/resolvePipeline/createValuesTrackingProxy.js +70 -70
  192. package/dist/store/resolvePipeline/createValuesTrackingProxy.js.map +1 -1
  193. package/dist/store/resolvePipeline/executeListResolve.d.ts +14 -14
  194. package/dist/store/resolvePipeline/executeListResolve.js +27 -27
  195. package/dist/store/resolvePipeline/executeListResolve.js.map +1 -1
  196. package/dist/store/resolvePipeline/executeResolve.d.ts +15 -15
  197. package/dist/store/resolvePipeline/executeResolve.js +46 -46
  198. package/dist/store/resolvePipeline/executeResolve.js.map +1 -1
  199. package/dist/store/store/NodeRegistry/nodeRegistry.d.ts +69 -56
  200. package/dist/store/store/NodeRegistry/nodeRegistry.d.ts.map +1 -1
  201. package/dist/store/store/NodeRegistry/nodeRegistry.js +94 -78
  202. package/dist/store/store/NodeRegistry/nodeRegistry.js.map +1 -1
  203. package/dist/store/store/NodeRegistry/nodeUtils.d.ts +5 -5
  204. package/dist/store/store/NodeRegistry/nodeUtils.d.ts.map +1 -1
  205. package/dist/store/store/NodeRegistry/nodeUtils.js +5 -5
  206. package/dist/store/store/NodeRegistry/nodeUtils.js.map +1 -1
  207. package/dist/store/store/groupDepsMap.d.ts +23 -23
  208. package/dist/store/store/groupDepsMap.d.ts.map +1 -1
  209. package/dist/store/store/groupDepsMap.js +40 -34
  210. package/dist/store/store/groupDepsMap.js.map +1 -1
  211. package/dist/store/store/hasComputedProps.d.ts +2 -2
  212. package/dist/store/store/hasComputedProps.js +2 -2
  213. package/dist/store/store/nodeMap.d.ts +5 -5
  214. package/dist/store/store/nodeMap.js +7 -7
  215. package/dist/store/store/nodeMap.js.map +1 -1
  216. package/dist/store/store/palistor.d.ts +80 -80
  217. package/dist/store/store/palistor.d.ts.map +1 -1
  218. package/dist/store/store/palistor.js +151 -165
  219. package/dist/store/store/palistor.js.map +1 -1
  220. package/dist/store/store/registerNodes.d.ts +10 -10
  221. package/dist/store/store/registerNodes.d.ts.map +1 -1
  222. package/dist/store/store/registerNodes.js +33 -18
  223. package/dist/store/store/registerNodes.js.map +1 -1
  224. package/dist/store/store/serviceRegistry.d.ts +8 -8
  225. package/dist/store/store/serviceRegistry.d.ts.map +1 -1
  226. package/dist/store/store/serviceRegistry.js +8 -8
  227. package/dist/store/store/serviceRegistry.js.map +1 -1
  228. package/dist/store/store/types.d.ts +277 -223
  229. package/dist/store/store/types.d.ts.map +1 -1
  230. package/dist/store/submitPipeline/applyLeafBeforeSubmit.d.ts +2 -2
  231. package/dist/store/submitPipeline/applyLeafBeforeSubmit.js +2 -2
  232. package/dist/store/submitPipeline/collectLeafStates.d.ts +2 -2
  233. package/dist/store/submitPipeline/collectLeafStates.js +2 -2
  234. package/dist/store/submitPipeline/submitPipeline.d.ts +8 -8
  235. package/dist/store/submitPipeline/submitPipeline.d.ts.map +1 -1
  236. package/dist/store/submitPipeline/submitPipeline.js +15 -11
  237. package/dist/store/submitPipeline/submitPipeline.js.map +1 -1
  238. package/dist/store/submitPipeline/types.d.ts +1 -1
  239. package/dist/store/submitPipeline/types.d.ts.map +1 -1
  240. package/dist/store/traversal/nodeClassifier.d.ts +9 -9
  241. package/dist/store/traversal/nodeClassifier.d.ts.map +1 -1
  242. package/dist/store/traversal/nodeClassifier.js +11 -11
  243. package/dist/store/traversal/nodeClassifier.js.map +1 -1
  244. package/dist/store/traversal/walkFull.d.ts +14 -14
  245. package/dist/store/traversal/walkFull.js +2 -2
  246. package/dist/store/valuesCache/valuesCache.d.ts +9 -9
  247. package/dist/store/valuesCache/valuesCache.d.ts.map +1 -1
  248. package/dist/store/valuesCache/valuesCache.js +6 -6
  249. package/dist/store/writePipeline/formatPatch.d.ts +5 -5
  250. package/dist/store/writePipeline/formatPatch.js +7 -7
  251. package/dist/store/writePipeline/formatPatch.js.map +1 -1
  252. package/dist/store/writePipeline/formatValue.d.ts +5 -5
  253. package/dist/store/writePipeline/formatValue.js +5 -5
  254. package/dist/store/writePipeline/mergeChanged.d.ts +4 -4
  255. package/dist/store/writePipeline/mergeChanged.js +4 -4
  256. package/dist/store/writePipeline/runSetter.d.ts +6 -6
  257. package/dist/store/writePipeline/runSetter.js +8 -8
  258. package/dist/store/writePipeline/storeValue.d.ts +3 -3
  259. package/dist/store/writePipeline/storeValue.js +3 -3
  260. package/dist/store/writePipeline/types.d.ts +4 -4
  261. package/dist/store/writePipeline/types.d.ts.map +1 -1
  262. package/dist/store/writePipeline/writePipeline.d.ts +7 -7
  263. package/dist/store/writePipeline/writePipeline.d.ts.map +1 -1
  264. package/dist/store/writePipeline/writePipeline.js +15 -15
  265. package/dist/store/writePipeline/writePipeline.js.map +1 -1
  266. package/package.json +11 -4
  267. package/dist/store/compute/recompute/collectGroupLeafNodes.d.ts +0 -11
  268. package/dist/store/compute/recompute/collectGroupLeafNodes.d.ts.map +0 -1
  269. package/dist/store/compute/recompute/collectGroupLeafNodes.js +0 -26
  270. package/dist/store/compute/recompute/collectGroupLeafNodes.js.map +0 -1
  271. package/dist/store/fieldMapping.typecheck.d.ts +0 -2
  272. package/dist/store/fieldMapping.typecheck.d.ts.map +0 -1
  273. package/dist/store/fieldMapping.typecheck.js +0 -71
  274. package/dist/store/fieldMapping.typecheck.js.map +0 -1
  275. package/dist/store/submitPipeline/getSubValues.d.ts +0 -9
  276. package/dist/store/submitPipeline/getSubValues.d.ts.map +0 -1
  277. package/dist/store/submitPipeline/getSubValues.js +0 -26
  278. package/dist/store/submitPipeline/getSubValues.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ import { CONFIG_NODE, FLOW_STATE } from "../constants";
2
+ /** Stable steps-proxy cache — one per FlowState (like listProxyCache). */
3
+ const stepsProxyCache = new WeakMap();
4
+ const NUMERIC_KEY = /^\d+$/;
5
+ /**
6
+ * Proxy over the flow's step collection (flow.steps).
7
+ *
8
+ * Access:
9
+ * steps[0] — by index (step array order)
10
+ * steps.welcome — by key
11
+ * steps.current — live reference to the active step's proxy
12
+ * steps.length — number of steps
13
+ * [...steps] — iteration over step proxies
14
+ *
15
+ * Step proxies are regular group proxies of the step nodes (cached in
16
+ * proxyCache), enriched with `status` in the group GET trap (via stepToFlow).
17
+ */
18
+ export function buildFlowStepsProxy(flowState, kernel) {
19
+ const cached = stepsProxyCache.get(flowState);
20
+ if (cached)
21
+ return cached;
22
+ const buildStep = (index) => kernel.proxyBuilder.build(flowState.stepNodes[index]);
23
+ const spreadKeys = () => [...flowState.stepKeys, "current", "length"];
24
+ const proxy = new Proxy({}, {
25
+ get(_target, key) {
26
+ // Tracking brand: navigation bumps the FlowState version.
27
+ if (key === FLOW_STATE)
28
+ return flowState;
29
+ // steps is not a config node; transparent to the tracking proxy.
30
+ if (key === CONFIG_NODE)
31
+ return undefined;
32
+ if (typeof key === "symbol") {
33
+ if (key === Symbol.iterator) {
34
+ return function* () {
35
+ for (let i = 0; i < flowState.stepNodes.length; i++)
36
+ yield buildStep(i);
37
+ };
38
+ }
39
+ return undefined;
40
+ }
41
+ if (key === "length")
42
+ return flowState.stepNodes.length;
43
+ if (key === "current")
44
+ return buildStep(flowState.currentIndex);
45
+ if (NUMERIC_KEY.test(key)) {
46
+ const index = Number(key);
47
+ return index < flowState.stepNodes.length ? buildStep(index) : undefined;
48
+ }
49
+ const index = flowState.stepKeys.indexOf(key);
50
+ if (index !== -1)
51
+ return buildStep(index);
52
+ return undefined;
53
+ },
54
+ set() {
55
+ // The step set is static — writes are forbidden.
56
+ return false;
57
+ },
58
+ ownKeys() {
59
+ return spreadKeys();
60
+ },
61
+ getOwnPropertyDescriptor(_target, key) {
62
+ if (typeof key === "symbol")
63
+ return undefined;
64
+ if (!spreadKeys().includes(key))
65
+ return undefined;
66
+ return { configurable: true, enumerable: true, writable: false };
67
+ },
68
+ });
69
+ stepsProxyCache.set(flowState, proxy);
70
+ return proxy;
71
+ }
72
+ //# sourceMappingURL=buildFlowStepsProxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildFlowStepsProxy.js","sourceRoot":"","sources":["../../../store/flow/buildFlowStepsProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAIvD,0EAA0E;AAC1E,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkB,CAAC;AAEtD,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAoB,EAAE,MAA0B;IAClF,MAAM,MAAM,GAAG,eAA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AS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC3E,CAAC;YAED,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9C,IAAI,KAAK,KAAK,CAAC,CAAC;gBAAE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC;YAE1C,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,GAAG;YACD,iDAAiD;YACjD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO;YACL,OAAO,UAAU,EAAE,CAAC;QACtB,CAAC;QAED,wBAAwB,CAAC,OAAO,EAAE,GAAoB;YACpD,IAAI,OAAO,GAAG,KAAK,QAAQ;gBAAE,OAAO,SAAS,CAAC;YAC9C,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,OAAO,SAAS,CAAC;YAClD,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QACnE,CAAC;KACF,CAAC,CAAC;IAEH,eAAe,CAAC,GAAG,CAAC,SAA8B,EAAE,KAAK,CAAC,CAAC;IAC3D,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,92 @@
1
+ import type { ExtractValues, ProxyStore } from "../store/types";
2
+ /**
3
+ * Flow step status — a computed step-proxy property derived from navigation
4
+ * state (currentStepKey + visited set). Not a leaf node: never appears in
5
+ * values, submit payloads or persisted state.
6
+ *
7
+ * - `null` — the step has not been visited yet
8
+ * - `"active"` — the current step
9
+ * - `"completed"` — was active, then left (forward or back)
10
+ */
11
+ export type StepStatus = "active" | "completed" | null;
12
+ /** Flow validation error — same shape as in SubmitResult. */
13
+ export interface FlowError {
14
+ path: string;
15
+ message: string;
16
+ }
17
+ /**
18
+ * Result of defineStep: the step's group config + its key within the flow.
19
+ * defineFlow expands steps into regular child groups of the flow node.
20
+ */
21
+ export interface FlowStep<K extends string = string, C extends Record<string, any> = Record<string, any>> {
22
+ readonly key: K;
23
+ readonly config: C;
24
+ }
25
+ export type AnyFlowStep = FlowStep<string, Record<string, any>>;
26
+ /** Flow values — all steps by key (accumulated state). */
27
+ export type FlowValues<S extends readonly AnyFlowStep[]> = {
28
+ [Step in S[number] as Step["key"]]: ExtractValues<Step["config"]>;
29
+ };
30
+ declare const __flowBrand: unique symbol;
31
+ /**
32
+ * A flow node in the config tree: a regular group (steps are child groups by
33
+ * key), branded with the step tuple for proxy type inference.
34
+ */
35
+ export type FlowNode<S extends readonly AnyFlowStep[]> = {
36
+ readonly [__flowBrand]: S;
37
+ } & {
38
+ [Step in S[number] as Step["key"]]: Step["config"];
39
+ };
40
+ /** Extract the step tuple from a FlowNode (never when the node is not a flow). */
41
+ export type InferFlowSteps<T> = T extends {
42
+ readonly [__flowBrand]: infer S extends readonly AnyFlowStep[];
43
+ } ? S : never;
44
+ /**
45
+ * Wrap a group config into a flow step.
46
+ *
47
+ * A step config is a regular Palistor group node (fields, isVisible,
48
+ * validate, resolve, onSubmit, …) plus the flow lifecycle callbacks
49
+ * `onEnter` / `onReady`.
50
+ *
51
+ * @example
52
+ * defineStep("welcome", {
53
+ * name: { value: "", isRequired: true },
54
+ * onSubmit: async (values, store, { nextStep }) => { nextStep(); },
55
+ * })
56
+ */
57
+ export declare function defineStep<const K extends string, const C extends Record<string, any>>(key: K, config: C & {
58
+ status?: never;
59
+ }): FlowStep<K, C>;
60
+ export interface DefineFlowOptions<S extends readonly AnyFlowStep[]> {
61
+ /** Ordered array of steps (defineStep). The order drives nextStep(). */
62
+ steps: S;
63
+ /** Flow-level submit: invoked by the standard submit pipeline over all steps. */
64
+ onSubmit?: (values: FlowValues<S>, store: ProxyStore<any>, parent?: any) => Promise<unknown> | unknown;
65
+ /** Group-level value transformation before submit. */
66
+ beforeSubmit?: (values: FlowValues<S>) => FlowValues<S> | Promise<FlowValues<S>>;
67
+ /** Post-processing after a successful onSubmit. */
68
+ afterSubmit?: (result: unknown, actions: {
69
+ reset: () => void;
70
+ }) => void | Promise<void>;
71
+ }
72
+ /**
73
+ * Build a flow node from an ordered array of steps.
74
+ *
75
+ * The returned node is a regular group in the config tree (steps become child
76
+ * groups under their keys), stamped with the {@link FLOW_STEPS_PROP} marker
77
+ * holding the step order. It participates in values / persist / dirty like
78
+ * any group; NodeRegistry creates a FlowState (navigation, statuses, history)
79
+ * based on the marker.
80
+ *
81
+ * @example
82
+ * const onboarding = defineFlow({
83
+ * steps: [
84
+ * defineStep("welcome", { name: { value: "", isRequired: true } }),
85
+ * defineStep("summary", {}),
86
+ * ],
87
+ * onSubmit: async (allValues, store) => api.completeOnboarding(allValues),
88
+ * });
89
+ */
90
+ export declare function defineFlow<const S extends readonly AnyFlowStep[]>(options: DefineFlowOptions<S>): FlowNode<S>;
91
+ export {};
92
+ //# sourceMappingURL=defineFlow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineFlow.d.ts","sourceRoot":"","sources":["../../../store/flow/defineFlow.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIhE;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,IAAI,CAAC;AAEvD,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ,CACvB,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAEnD,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC;IAChB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;CACpB;AAED,MA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iF;IACjF,QAAQ,CAAC,EAAE,CACT,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,EACrB,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,EACtB,MAAM,CAAC,EAAE,GAAG,KACT,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAChC,sDAAsD;IACtD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,mDAAmD;IACnD,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,WAAW,EAAE,EAC/D,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,QAAQ,CAAC,CAAC,CAAC,CAgCb"}
@@ -0,0 +1,99 @@
1
+ import { CONFIG_PROPS, FLOW_SPREAD_KEYS, FLOW_STEPS_PROP, GROUP_SPREAD_KEYS, } from "../constants";
2
+ // ─── defineStep ───────────────────────────────────────────────────────────────
3
+ /**
4
+ * The name `status` is reserved on the step proxy for the computed step
5
+ * status — a config field with that name is forbidden (like dirty/loading).
6
+ */
7
+ const RESERVED_STEP_CONFIG_KEYS = new Set(["status"]);
8
+ /**
9
+ * Wrap a group config into a flow step.
10
+ *
11
+ * A step config is a regular Palistor group node (fields, isVisible,
12
+ * validate, resolve, onSubmit, …) plus the flow lifecycle callbacks
13
+ * `onEnter` / `onReady`.
14
+ *
15
+ * @example
16
+ * defineStep("welcome", {
17
+ * name: { value: "", isRequired: true },
18
+ * onSubmit: async (values, store, { nextStep }) => { nextStep(); },
19
+ * })
20
+ */
21
+ export function defineStep(key, config) {
22
+ if (typeof key !== "string" || key.length === 0) {
23
+ throw new Error("[palistor] defineStep: key must be a non-empty string.");
24
+ }
25
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
26
+ throw new Error(`[palistor] defineStep("${key}"): config must be a plain object (group node).`);
27
+ }
28
+ if ("value" in config) {
29
+ throw new Error(`[palistor] defineStep("${key}"): step config must be a group node — a "value" key makes it a leaf.`);
30
+ }
31
+ for (const reserved of RESERVED_STEP_CONFIG_KEYS) {
32
+ if (reserved in config) {
33
+ throw new Error(`[palistor] defineStep("${key}"): "${reserved}" is reserved — the flow exposes it as a computed step property.`);
34
+ }
35
+ }
36
+ return { key, config: config };
37
+ }
38
+ // ─── defineFlow ───────────────────────────────────────────────────────────────
39
+ /**
40
+ * Step keys that conflict with flow-proxy / steps-proxy properties or service
41
+ * config keys — forbidden as step names.
42
+ */
43
+ const RESERVED_STEP_KEYS = new Set([
44
+ ...CONFIG_PROPS,
45
+ ...GROUP_SPREAD_KEYS,
46
+ ...FLOW_SPREAD_KEYS,
47
+ "setValues",
48
+ "current",
49
+ "length",
50
+ ]);
51
+ /**
52
+ * Build a flow node from an ordered array of steps.
53
+ *
54
+ * The returned node is a regular group in the config tree (steps become child
55
+ * groups under their keys), stamped with the {@link FLOW_STEPS_PROP} marker
56
+ * holding the step order. It participates in values / persist / dirty like
57
+ * any group; NodeRegistry creates a FlowState (navigation, statuses, history)
58
+ * based on the marker.
59
+ *
60
+ * @example
61
+ * const onboarding = defineFlow({
62
+ * steps: [
63
+ * defineStep("welcome", { name: { value: "", isRequired: true } }),
64
+ * defineStep("summary", {}),
65
+ * ],
66
+ * onSubmit: async (allValues, store) => api.completeOnboarding(allValues),
67
+ * });
68
+ */
69
+ export function defineFlow(options) {
70
+ const { steps, onSubmit, beforeSubmit, afterSubmit } = options;
71
+ if (!Array.isArray(steps) || steps.length === 0) {
72
+ throw new Error("[palistor] defineFlow: `steps` must be a non-empty array of defineStep(...) results.");
73
+ }
74
+ const node = {};
75
+ const stepKeys = [];
76
+ for (const step of steps) {
77
+ if (!step || typeof step !== "object" || typeof step.key !== "string" || !step.config) {
78
+ throw new Error("[palistor] defineFlow: each entry of `steps` must be created via defineStep(key, config).");
79
+ }
80
+ if (RESERVED_STEP_KEYS.has(step.key)) {
81
+ throw new Error(`[palistor] defineFlow: step key "${step.key}" is reserved by the flow/group proxy API.`);
82
+ }
83
+ if (stepKeys.includes(step.key)) {
84
+ throw new Error(`[palistor] defineFlow: duplicate step key "${step.key}".`);
85
+ }
86
+ node[step.key] = step.config;
87
+ stepKeys.push(step.key);
88
+ }
89
+ if (onSubmit)
90
+ node.onSubmit = onSubmit;
91
+ if (beforeSubmit)
92
+ node.beforeSubmit = beforeSubmit;
93
+ if (afterSubmit)
94
+ node.afterSubmit = afterSubmit;
95
+ // Flow marker: part of CONFIG_PROPS → all tree walks skip it.
96
+ node[FLOW_STEPS_PROP] = stepKeys;
97
+ return node;
98
+ }
99
+ //# sourceMappingURL=defineFlow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineFlow.js","sourceRoot":"","sources":["../../../store/flow/defineFlow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,iBAAiB,GAClB,MAAM,cAAc,CAAC;AA4DtB,iFAAiF;AAEjF;;;GAGG;AACH,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CACxB,GAAM,EACN,MAA8B;IAE9B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,C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M,EAAE,CAAC;YACtF,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;QAC/G,CAAC;QACD,IAAI,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,GAAG,4CAA4C,CAAC,CAAC;QAC5G,CAAC;QACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CAAC,8CAA8C,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC7B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;IAED,IAAI,QAAQ;QAAE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IACvC,IAAI,YAAY;QAAE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnD,IAAI,WAAW;QAAE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAEhD,8DAA8D;IAC9D,IAAI,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC;IAEjC,OAAO,IAA8B,CAAC;AACxC,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Palistor } from "../store/palistor";
2
+ import type { SubmitResult } from "../submitPipeline/types";
3
+ import type { FlowError } from "./defineFlow";
4
+ import type { FlowState } from "./flowState";
5
+ /**
6
+ * Navigation methods of the flow proxy. All are closures bound over
7
+ * (kernel, flowState), so destructuring in onSubmit works:
8
+ * `(values, store, { nextStep }) => …`.
9
+ */
10
+ export interface FlowApi {
11
+ nextStep: () => void;
12
+ back: () => void;
13
+ goTo: (keyOrIndex: string | number) => void;
14
+ validate: () => FlowError[];
15
+ submit: () => Promise<SubmitResult>;
16
+ }
17
+ export declare function getFlowApi(kernel: Palistor<any, any>, flowState: FlowState): FlowApi;
18
+ //# sourceMappingURL=flowApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowApi.d.ts","sourceRoot":"","sources":["../../../store/flow/flowApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAS7C;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,SAAS,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC;CACrC;AAKD,wBAAgB,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAcpF"}
@@ -0,0 +1,18 @@
1
+ import { flowBack, flowGoTo, flowNextStep, flowSubmit, flowValidate, } from "./flowNavigation";
2
+ /** Stable method references — one FlowApi per FlowState (for React). */
3
+ const flowApiCache = new WeakMap();
4
+ export function getFlowApi(kernel, flowState) {
5
+ const cached = flowApiCache.get(flowState);
6
+ if (cached)
7
+ return cached;
8
+ const api = {
9
+ nextStep: () => flowNextStep(kernel, flowState),
10
+ back: () => flowBack(kernel, flowState),
11
+ goTo: (keyOrIndex) => flowGoTo(kernel, flowState, keyOrIndex),
12
+ validate: () => flowValidate(kernel, flowState),
13
+ submit: () => flowSubmit(kernel, flowState),
14
+ };
15
+ flowApiCache.set(flowState, api);
16
+ return api;
17
+ }
18
+ //# sourceMappingURL=flowApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowApi.js","sourceRoot":"","sources":["../../../store/flow/flowApi.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,kBAAkB,CAAC;AAe1B,wEAAwE;AACxE,MAAM,YAAY,GAAG,IAAI,OAAO,EAAmB,CAAC;AAEpD,MAAM,UAAU,UAAU,CAAC,MAA0B,EAAE,SAAoB;IACzE,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,SAA8B,CAAC,CAAC;IAChE,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,MAAM,GAAG,GAAY;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;QAC/C,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;QACvC,IAAI,EAAE,CAAC,UAA2B,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;QAC9E,QAAQ,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC;QAC/C,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC;KAC5C,CAAC;IAEF,YAAY,CAAC,GAAG,CAAC,SAA8B,EAAE,GAAG,CAAC,CAAC;IACtD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,137 @@
1
+ import type { AnyConfigNode } from "../store/types";
2
+ import type { Palistor } from "../store/palistor";
3
+ import type { SubmitResult } from "../submitPipeline/types";
4
+ import type { FlowError, StepStatus } from "./defineFlow";
5
+ import type { FlowState } from "./flowState";
6
+ type Kernel = Palistor<any, any>;
7
+ /** Step status — derived from navigation state (not stored). */
8
+ export declare function getStepStatus(flowState: FlowState, stepNode: object): StepStatus;
9
+ /** Step visibility — from the group's computed FieldState (isVisible is reactive). */
10
+ export declare function isStepVisible(kernel: Kernel, stepNode: object): boolean;
11
+ /** Composite flow loading: true when at least one step is resolving. */
12
+ export declare function flowLoading(kernel: Kernel, flowState: FlowState): boolean;
13
+ /**
14
+ * Collect leaf errors of a step's subtree. Validation is computed "live" via
15
+ * computeFieldState(revalidate=true) — independent of the group's revalidate
16
+ * flag (which only the submit pipeline sets). Hidden leaves are skipped.
17
+ * Lists inside a step are skipped (parity with collectLeafStates).
18
+ *
19
+ * `basePath` — prefix for error paths. The flow passes the step KEY: paths
20
+ * come out relative to the flow node ("welcome.name") — the same base the
21
+ * submit pipeline uses for errors on flow.submit() (collectLeafStates builds
22
+ * paths from the submitted node).
23
+ */
24
+ export declare function collectStepErrors(kernel: Kernel, stepNode: AnyConfigNode, basePath?: string): FlowError[];
25
+ /** Live aggregate of step validity (flow.steps.x.isInvalid). */
26
+ export declare function stepIsInvalid(kernel: Kernel, stepNode: AnyConfigNode): boolean;
27
+ /**
28
+ * Flow errors over visited visible steps (the scope of flow.validate()).
29
+ * Hidden steps are always excluded — an untaken branch must not block.
30
+ * Error paths are relative to the flow node ("stepKey.field") — same as
31
+ * SubmitResult on flow.submit().
32
+ */
33
+ export declare function collectFlowErrors(kernel: Kernel, flowState: FlowState): FlowError[];
34
+ /** Aggregate flow.isInvalid: any errors in visited visible steps. */
35
+ export declare function flowIsInvalid(kernel: Kernel, flowState: FlowState): boolean;
36
+ /**
37
+ * flow.validate(): collect errors of the visited steps, write them into the
38
+ * reactive flow.errors and return them. Empty array = all valid.
39
+ */
40
+ export declare function flowValidate(kernel: Kernel, flowState: FlowState): FlowError[];
41
+ /**
42
+ * Filter out submit-pipeline errors from leaves under HIDDEN steps of any
43
+ * flow: the base pipeline validates all leaves regardless of visibility, and
44
+ * without this filter an untaken branch with isRequired fields would block
45
+ * finalization forever.
46
+ *
47
+ * `submittedNode` — the node the submit ran for: pipeline error paths are
48
+ * RELATIVE to it (collectLeafStates builds paths from the submitted node),
49
+ * so the absolute paths of hidden steps are rebased to the same base.
50
+ */
51
+ export declare function filterHiddenFlowStepErrors(kernel: Kernel, errors: Array<{
52
+ path: string;
53
+ message: string;
54
+ }>, submittedNode: AnyConfigNode): Array<{
55
+ path: string;
56
+ message: string;
57
+ }>;
58
+ /**
59
+ * flow.submit(): the standard group-submit pipeline over the flow node
60
+ * (submitting → beforeSubmit → validate → onSubmit → afterSubmit; leaves of
61
+ * hidden steps are filtered by the pipeline). Validation errors land in the
62
+ * reactive flow.errors; on success errors are cleared.
63
+ */
64
+ export declare function flowSubmit(kernel: Kernel, flowState: FlowState): Promise<SubmitResult>;
65
+ /**
66
+ * Step entry lifecycle: onEnter → resolve (eager) → onReady.
67
+ *
68
+ * - `onEnter` / `onReady` receive FLOW-scoped values (all steps by key) —
69
+ * the flow's live groupSlot reference; fire-and-forget.
70
+ * - the step's resolve is a standard group resolve; the flow triggers it ON
71
+ * ENTRY (equivalent to first access). Already resolved/error (cached) — not
72
+ * re-run, and onReady is NOT invoked again.
73
+ * - Without resolve — onReady fires right after onEnter.
74
+ */
75
+ export declare function runEntryLifecycle(kernel: Kernel, flowState: FlowState, stepNode: AnyConfigNode): void;
76
+ /**
77
+ * nextStep(): the next VISIBLE step in array order; hidden ones are skipped.
78
+ * When no visible steps remain ahead — finalize via flow.submit() (on
79
+ * validation errors onSubmit is not called, errors land in flow.errors, the
80
+ * step does not change).
81
+ */
82
+ export declare function flowNextStep(kernel: Kernel, flowState: FlowState): void;
83
+ /** back(): go back along the visit stack. No-op when the stack is empty (canGoBack). */
84
+ export declare function flowBack(kernel: Kernel, flowState: FlowState): void;
85
+ /**
86
+ * goTo(keyOrIndex): arbitrary jump by key or index.
87
+ * Unknown key/index — throws (catches typos during development).
88
+ * Jumping to the current step is a no-op.
89
+ */
90
+ export declare function flowGoTo(kernel: Kernel, flowState: FlowState, keyOrIndex: string | number): void;
91
+ /**
92
+ * Reset flow navigation: the first step is active, the stack and visited set
93
+ * are cleared, step resolve states go back to idle. The first step's entry
94
+ * lifecycle (onEnter → resolve → onReady) runs anew — mirroring initialization.
95
+ */
96
+ export declare function resetFlowNav(kernel: Kernel, flowState: FlowState): void;
97
+ /**
98
+ * Reset navigation of all flows that fall into the reset subtree.
99
+ * Called from ResetPipeline (root reset → all flows; group reset → flows inside it).
100
+ */
101
+ export declare function resetFlowNavForSubtree(kernel: Kernel, groupNode: AnyConfigNode): void;
102
+ /**
103
+ * Initialization lifecycle: the first step of every flow is "entered" at
104
+ * store creation (onEnter → resolve → onReady). Called from the Palistor
105
+ * constructor.
106
+ *
107
+ * Also pre-warms the proxyCache of flow nodes: a step's identity view reads
108
+ * parent.proxy from the cache on the first step.submit(), and the flow proxy
109
+ * must already exist by then — otherwise the step's onSubmit would receive
110
+ * undefined as its third argument.
111
+ */
112
+ export declare function initFlows(kernel: Kernel): void;
113
+ /** Flow navigation snapshot in the persist payload (field values are stored separately). */
114
+ export interface FlowNavSnapshot {
115
+ currentStepKey: string;
116
+ visitStack: string[];
117
+ visitedKeys: string[];
118
+ }
119
+ /**
120
+ * Serialize navigation of all flows for persist: key — the flow node's dot-path.
121
+ * Step statuses are not saved — they are derived from navigation on hydrate.
122
+ */
123
+ export declare function serializeFlowNav(kernel: Kernel): Record<string, FlowNavSnapshot> | null;
124
+ /**
125
+ * Restore flow navigation from a persist snapshot. Unknown step keys (the
126
+ * config changed) are dropped; an incompatible currentStepKey leaves the flow
127
+ * in its current state. Returns the changed nodes for notify and the flows
128
+ * whose active step changed (for a repeated entry lifecycle).
129
+ */
130
+ export declare function restoreFlowNav(kernel: Kernel, snapshots: Record<string, FlowNavSnapshot>): {
131
+ changed: Set<object>;
132
+ entered: FlowState[];
133
+ };
134
+ /** Entry lifecycle of the current step (used by persist after hydration). */
135
+ export declare function runFlowEntryLifecycle(kernel: Kernel, flowState: FlowState): void;
136
+ export {};
137
+ //# sourceMappingURL=flowNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"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