@owlmeans/server-planning 0.1.18-rc.21 → 0.1.18-rc.23

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 (313) hide show
  1. package/README.md +24 -17
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/server-planning/SKILL.md +28 -28
  4. package/build/actions/apply-schema-request.d.ts +8 -0
  5. package/build/actions/apply-schema-request.d.ts.map +1 -0
  6. package/build/actions/apply-schema-request.js +31 -0
  7. package/build/actions/apply-schema-request.js.map +1 -0
  8. package/build/actions/cards.d.ts +5 -3
  9. package/build/actions/cards.d.ts.map +1 -1
  10. package/build/actions/cards.js +1 -1
  11. package/build/actions/cards.js.map +1 -1
  12. package/build/actions/commit.d.ts +3 -3
  13. package/build/actions/commit.d.ts.map +1 -1
  14. package/build/actions/commit.js +5 -4
  15. package/build/actions/commit.js.map +1 -1
  16. package/build/actions/define-schemas.d.ts +13 -0
  17. package/build/actions/define-schemas.d.ts.map +1 -0
  18. package/build/actions/define-schemas.js +28 -0
  19. package/build/actions/define-schemas.js.map +1 -0
  20. package/build/actions/execute.d.ts +8 -28
  21. package/build/actions/execute.d.ts.map +1 -1
  22. package/build/actions/execute.js +17 -101
  23. package/build/actions/execute.js.map +1 -1
  24. package/build/actions/execution/types.d.ts +34 -0
  25. package/build/actions/execution/types.d.ts.map +1 -0
  26. package/build/actions/execution/types.js +2 -0
  27. package/build/actions/execution/types.js.map +1 -0
  28. package/build/actions/execution.d.ts +4 -0
  29. package/build/actions/execution.d.ts.map +1 -0
  30. package/build/actions/execution.js +79 -0
  31. package/build/actions/execution.js.map +1 -0
  32. package/build/actions/get-card.d.ts +6 -0
  33. package/build/actions/get-card.d.ts.map +1 -0
  34. package/build/actions/get-card.js +9 -0
  35. package/build/actions/get-card.js.map +1 -0
  36. package/build/actions/get-specification.d.ts +6 -0
  37. package/build/actions/get-specification.d.ts.map +1 -0
  38. package/build/actions/get-specification.js +9 -0
  39. package/build/actions/get-specification.js.map +1 -0
  40. package/build/actions/index.d.ts +12 -3
  41. package/build/actions/index.d.ts.map +1 -1
  42. package/build/actions/index.js +11 -3
  43. package/build/actions/index.js.map +1 -1
  44. package/build/actions/links.d.ts +3 -3
  45. package/build/actions/links.d.ts.map +1 -1
  46. package/build/actions/links.js +6 -5
  47. package/build/actions/links.js.map +1 -1
  48. package/build/actions/list-card-specifications.d.ts +6 -0
  49. package/build/actions/list-card-specifications.d.ts.map +1 -0
  50. package/build/actions/list-card-specifications.js +11 -0
  51. package/build/actions/list-card-specifications.js.map +1 -0
  52. package/build/actions/list-card-transitions.d.ts +6 -0
  53. package/build/actions/list-card-transitions.d.ts.map +1 -0
  54. package/build/actions/list-card-transitions.js +11 -0
  55. package/build/actions/list-card-transitions.js.map +1 -0
  56. package/build/actions/list-cards.d.ts +6 -0
  57. package/build/actions/list-cards.d.ts.map +1 -0
  58. package/build/actions/list-cards.js +10 -0
  59. package/build/actions/list-cards.js.map +1 -0
  60. package/build/actions/list-schemas.d.ts +13 -0
  61. package/build/actions/list-schemas.d.ts.map +1 -0
  62. package/build/actions/list-schemas.js +20 -0
  63. package/build/actions/list-schemas.js.map +1 -0
  64. package/build/actions/list-specification-revisions.d.ts +6 -0
  65. package/build/actions/list-specification-revisions.d.ts.map +1 -0
  66. package/build/actions/list-specification-revisions.js +10 -0
  67. package/build/actions/list-specification-revisions.js.map +1 -0
  68. package/build/actions/schemas.d.ts +5 -3
  69. package/build/actions/schemas.d.ts.map +1 -1
  70. package/build/actions/schemas.js.map +1 -1
  71. package/build/actions/specs.d.ts +4 -2
  72. package/build/actions/specs.d.ts.map +1 -1
  73. package/build/actions/specs.js.map +1 -1
  74. package/build/actions/summarize-cards.d.ts +6 -0
  75. package/build/actions/summarize-cards.d.ts.map +1 -0
  76. package/build/actions/summarize-cards.js +11 -0
  77. package/build/actions/summarize-cards.js.map +1 -0
  78. package/build/actions/transitions.d.ts +3 -3
  79. package/build/actions/transitions.d.ts.map +1 -1
  80. package/build/actions/transitions.js +4 -3
  81. package/build/actions/transitions.js.map +1 -1
  82. package/build/actions/types.d.ts +5 -3
  83. package/build/actions/types.d.ts.map +1 -1
  84. package/build/actions/watch.d.ts +2 -2
  85. package/build/actions/watch.d.ts.map +1 -1
  86. package/build/actions/watch.js +2 -2
  87. package/build/actions/watch.js.map +1 -1
  88. package/build/conformance/assert/types.d.ts +19 -0
  89. package/build/conformance/assert/types.d.ts.map +1 -0
  90. package/build/conformance/assert/types.js +2 -0
  91. package/build/conformance/assert/types.js.map +1 -0
  92. package/build/conformance/assert.d.ts +8 -13
  93. package/build/conformance/assert.d.ts.map +1 -1
  94. package/build/conformance/assert.js +41 -43
  95. package/build/conformance/assert.js.map +1 -1
  96. package/build/conformance/cases.d.ts.map +1 -1
  97. package/build/conformance/cases.js +86 -67
  98. package/build/conformance/cases.js.map +1 -1
  99. package/build/conformance/clock.d.ts +6 -0
  100. package/build/conformance/clock.d.ts.map +1 -0
  101. package/build/conformance/clock.js +12 -0
  102. package/build/conformance/clock.js.map +1 -0
  103. package/build/conformance/consts.d.ts +3 -1
  104. package/build/conformance/consts.d.ts.map +1 -1
  105. package/build/conformance/consts.js +84 -1
  106. package/build/conformance/consts.js.map +1 -1
  107. package/build/conformance/errors.d.ts +5 -0
  108. package/build/conformance/errors.d.ts.map +1 -0
  109. package/build/conformance/errors.js +8 -0
  110. package/build/conformance/errors.js.map +1 -0
  111. package/build/conformance/fixtures/types.d.ts +13 -0
  112. package/build/conformance/fixtures/types.d.ts.map +1 -0
  113. package/build/conformance/fixtures/types.js +2 -0
  114. package/build/conformance/fixtures/types.js.map +1 -0
  115. package/build/conformance/fixtures.d.ts +8 -8
  116. package/build/conformance/fixtures.d.ts.map +1 -1
  117. package/build/conformance/fixtures.js +24 -107
  118. package/build/conformance/fixtures.js.map +1 -1
  119. package/build/conformance/index.d.ts +3 -0
  120. package/build/conformance/index.d.ts.map +1 -1
  121. package/build/conformance/index.js +1 -0
  122. package/build/conformance/index.js.map +1 -1
  123. package/build/definitions.d.ts.map +1 -1
  124. package/build/definitions.js +9 -9
  125. package/build/definitions.js.map +1 -1
  126. package/build/executor/changes/types.d.ts +36 -0
  127. package/build/executor/changes/types.d.ts.map +1 -0
  128. package/build/executor/changes/types.js +2 -0
  129. package/build/executor/changes/types.js.map +1 -0
  130. package/build/executor/changes.d.ts +3 -30
  131. package/build/executor/changes.d.ts.map +1 -1
  132. package/build/executor/changes.js +42 -51
  133. package/build/executor/changes.js.map +1 -1
  134. package/build/executor/code/types.d.ts +17 -0
  135. package/build/executor/code/types.d.ts.map +1 -0
  136. package/build/executor/code/types.js +2 -0
  137. package/build/executor/code/types.js.map +1 -0
  138. package/build/executor/code.d.ts +3 -14
  139. package/build/executor/code.d.ts.map +1 -1
  140. package/build/executor/code.js +50 -54
  141. package/build/executor/code.js.map +1 -1
  142. package/build/executor/creator/types.d.ts +33 -0
  143. package/build/executor/creator/types.d.ts.map +1 -0
  144. package/build/executor/creator/types.js +2 -0
  145. package/build/executor/creator/types.js.map +1 -0
  146. package/build/executor/creator.d.ts +6 -25
  147. package/build/executor/creator.d.ts.map +1 -1
  148. package/build/executor/creator.js +26 -41
  149. package/build/executor/creator.js.map +1 -1
  150. package/build/executor/resolve/types.d.ts +30 -0
  151. package/build/executor/resolve/types.d.ts.map +1 -0
  152. package/build/executor/resolve/types.js +2 -0
  153. package/build/executor/resolve/types.js.map +1 -0
  154. package/build/executor/resolve.d.ts +4 -41
  155. package/build/executor/resolve.d.ts.map +1 -1
  156. package/build/executor/resolve.js +142 -157
  157. package/build/executor/resolve.js.map +1 -1
  158. package/build/executor/types.d.ts +0 -2
  159. package/build/executor/types.d.ts.map +1 -1
  160. package/build/executor/validate.d.ts +1 -1
  161. package/build/executor/validate.d.ts.map +1 -1
  162. package/build/executor/validate.js +16 -15
  163. package/build/executor/validate.js.map +1 -1
  164. package/build/executor.d.ts +4 -3
  165. package/build/executor.d.ts.map +1 -1
  166. package/build/executor.js +18 -17
  167. package/build/executor.js.map +1 -1
  168. package/build/facade.d.ts.map +1 -1
  169. package/build/facade.js +16 -16
  170. package/build/facade.js.map +1 -1
  171. package/build/helper.d.ts +1 -6
  172. package/build/helper.d.ts.map +1 -1
  173. package/build/helper.js +3 -8
  174. package/build/helper.js.map +1 -1
  175. package/build/projection.d.ts +2 -0
  176. package/build/projection.d.ts.map +1 -1
  177. package/build/projection.js +6 -4
  178. package/build/projection.js.map +1 -1
  179. package/build/queue/declare.d.ts +5 -0
  180. package/build/queue/declare.d.ts.map +1 -0
  181. package/build/queue/declare.js +5 -0
  182. package/build/queue/declare.js.map +1 -0
  183. package/build/queue/index.d.ts +1 -4
  184. package/build/queue/index.d.ts.map +1 -1
  185. package/build/queue/index.js +1 -4
  186. package/build/queue/index.js.map +1 -1
  187. package/build/store/composite.d.ts.map +1 -1
  188. package/build/store/composite.js +2 -2
  189. package/build/store/composite.js.map +1 -1
  190. package/build/store/fold/types.d.ts +43 -0
  191. package/build/store/fold/types.d.ts.map +1 -0
  192. package/build/store/fold/types.js +2 -0
  193. package/build/store/fold/types.js.map +1 -0
  194. package/build/store/fold.d.ts +7 -30
  195. package/build/store/fold.d.ts.map +1 -1
  196. package/build/store/fold.js +185 -203
  197. package/build/store/fold.js.map +1 -1
  198. package/build/store/index.d.ts +1 -0
  199. package/build/store/index.d.ts.map +1 -1
  200. package/build/store/index.js.map +1 -1
  201. package/build/store/memory.d.ts.map +1 -1
  202. package/build/store/memory.js +0 -0
  203. package/build/store/memory.js.map +1 -1
  204. package/build/store/types.local.d.ts +3 -1
  205. package/build/store/types.local.d.ts.map +1 -1
  206. package/build/types.d.ts +2 -1
  207. package/build/types.d.ts.map +1 -1
  208. package/build/utils/access/types.d.ts +30 -0
  209. package/build/utils/access/types.d.ts.map +1 -0
  210. package/build/utils/access/types.js +2 -0
  211. package/build/utils/access/types.js.map +1 -0
  212. package/build/utils/access.d.ts +4 -0
  213. package/build/utils/access.d.ts.map +1 -0
  214. package/build/utils/access.js +28 -0
  215. package/build/utils/access.js.map +1 -0
  216. package/build/utils/guard/types.d.ts +21 -0
  217. package/build/utils/guard/types.d.ts.map +1 -0
  218. package/build/utils/guard/types.js +2 -0
  219. package/build/utils/guard/types.js.map +1 -0
  220. package/build/utils/guard.d.ts +7 -10
  221. package/build/utils/guard.d.ts.map +1 -1
  222. package/build/utils/guard.js +33 -31
  223. package/build/utils/guard.js.map +1 -1
  224. package/build/utils/handler/types.d.ts +26 -0
  225. package/build/utils/handler/types.d.ts.map +1 -0
  226. package/build/utils/handler/types.js +2 -0
  227. package/build/utils/handler/types.js.map +1 -0
  228. package/build/utils/handler.d.ts +6 -0
  229. package/build/utils/handler.d.ts.map +1 -0
  230. package/build/utils/handler.js +21 -0
  231. package/build/utils/handler.js.map +1 -0
  232. package/build/utils/index.d.ts +8 -1
  233. package/build/utils/index.d.ts.map +1 -1
  234. package/build/utils/index.js +3 -0
  235. package/build/utils/index.js.map +1 -1
  236. package/build/utils/request/types.d.ts +23 -0
  237. package/build/utils/request/types.d.ts.map +1 -0
  238. package/build/utils/request/types.js +2 -0
  239. package/build/utils/request/types.js.map +1 -0
  240. package/build/utils/request.d.ts +4 -0
  241. package/build/utils/request.d.ts.map +1 -0
  242. package/build/utils/request.js +27 -0
  243. package/build/utils/request.js.map +1 -0
  244. package/build/utils/scope.d.ts +10 -43
  245. package/build/utils/scope.d.ts.map +1 -1
  246. package/build/utils/scope.js +21 -99
  247. package/build/utils/scope.js.map +1 -1
  248. package/package.json +18 -18
  249. package/src/actions/apply-schema-request.ts +35 -0
  250. package/src/actions/commit.ts +7 -5
  251. package/src/actions/define-schemas.ts +34 -0
  252. package/src/actions/execute.ts +30 -115
  253. package/src/actions/execution/types.ts +34 -0
  254. package/src/actions/execution.ts +96 -0
  255. package/src/actions/get-card.ts +14 -0
  256. package/src/actions/get-specification.ts +14 -0
  257. package/src/actions/index.ts +13 -3
  258. package/src/actions/links.ts +8 -6
  259. package/src/actions/list-card-specifications.ts +15 -0
  260. package/src/actions/list-card-transitions.ts +15 -0
  261. package/src/actions/list-cards.ts +14 -0
  262. package/src/actions/list-schemas.ts +29 -0
  263. package/src/actions/{specs.ts → list-specification-revisions.ts} +4 -11
  264. package/src/actions/summarize-cards.ts +15 -0
  265. package/src/actions/transitions.ts +6 -4
  266. package/src/actions/types.ts +4 -3
  267. package/src/actions/watch.ts +4 -3
  268. package/src/conformance/assert/types.ts +16 -0
  269. package/src/conformance/assert.ts +49 -41
  270. package/src/conformance/cases.ts +88 -67
  271. package/src/conformance/clock.ts +11 -0
  272. package/src/conformance/consts.ts +87 -1
  273. package/src/conformance/errors.ts +7 -0
  274. package/src/conformance/fixtures/types.ts +11 -0
  275. package/src/conformance/fixtures.ts +32 -107
  276. package/src/conformance/index.ts +3 -0
  277. package/src/definitions.ts +9 -9
  278. package/src/executor/changes/types.ts +38 -0
  279. package/src/executor/changes.ts +48 -63
  280. package/src/executor/code/types.ts +23 -0
  281. package/src/executor/code.ts +60 -61
  282. package/src/executor/creator/types.ts +33 -0
  283. package/src/executor/creator.ts +33 -41
  284. package/src/executor/resolve/types.ts +30 -0
  285. package/src/executor/resolve.ts +153 -167
  286. package/src/executor/types.ts +0 -3
  287. package/src/executor/validate.ts +17 -16
  288. package/src/executor.ts +20 -17
  289. package/src/facade.ts +16 -16
  290. package/src/helper.ts +3 -8
  291. package/src/projection.ts +8 -4
  292. package/src/queue/declare.ts +7 -0
  293. package/src/queue/index.ts +1 -8
  294. package/src/store/composite.ts +2 -2
  295. package/src/store/fold/types.ts +44 -0
  296. package/src/store/fold.ts +209 -212
  297. package/src/store/index.ts +1 -0
  298. package/src/store/memory.ts +0 -0
  299. package/src/store/types.local.ts +1 -1
  300. package/src/types.ts +1 -1
  301. package/src/utils/access/types.ts +30 -0
  302. package/src/utils/access.ts +33 -0
  303. package/src/utils/guard/types.ts +19 -0
  304. package/src/utils/guard.ts +41 -30
  305. package/src/utils/handler/types.ts +28 -0
  306. package/src/utils/handler.ts +35 -0
  307. package/src/utils/index.ts +9 -1
  308. package/src/utils/request/types.ts +23 -0
  309. package/src/utils/request.ts +40 -0
  310. package/src/utils/scope.ts +25 -108
  311. package/tests/creator.spec.ts +18 -18
  312. package/src/actions/cards.ts +0 -48
  313. package/src/actions/schemas.ts +0 -87
@@ -1,55 +1,46 @@
1
- import { CommitState, computeChanges, isEmptyChange, TransitionAction } from '@owlmeans/planning';
1
+ import { changesHelper, CommitState, TransitionAction } from '@owlmeans/planning';
2
2
  const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined));
3
- /**
4
- * Step 9: the recorded `changes`/`unset`, and whether an update wrote nothing.
5
- *
6
- * @throws {IllegalTransition | PlanningError}
7
- */
8
- export const changeSetOf = (exec, resolved, schemas, at) => {
9
- const set = computeChanges(resolved.card, exec, resolved.type, schemas, at, { slot: resolved.slot });
10
- const empty = exec.action === TransitionAction.Update && isEmptyChange(set);
11
- return { set, empty };
12
- };
13
- /**
14
- * Who wrote it — the SCOPE's identity, never the execution's.
15
- *
16
- * `profileId`, `userId`, `service` and `channel` come only from the scope (the server builds it
17
- * from the authenticated request); the descriptive `agent`/`runId` an in-process caller passes on
18
- * the execution are kept unless the scope's own actor names them.
19
- */
20
- export const actorOf = (scope, exec) => clean({
21
- agent: exec.actor?.agent,
22
- runId: exec.actor?.runId,
23
- ...clean({ profileId: scope.profileId, userId: scope.userId, service: scope.service }),
24
- ...clean(scope.actor ?? {}),
25
- channel: scope.channel ?? scope.actor?.channel,
26
- });
27
- const withFrom = (link, card) => ({ ...link, from: link.from ?? card });
28
- /** Step 11's record: the event as it is appended, `pending`. */
29
- export const transitionOf = (params) => {
30
- const { exec, resolved, scope, set, cardId, seq, project, at } = params;
31
- const kind = resolved.create ? exec.card.kind : resolved.card.kind;
32
- return clean({
33
- entityId: scope.entityId,
34
- card: cardId,
35
- kind,
36
- type: resolved.type.type,
37
- project,
38
- seq,
39
- action: exec.action,
40
- flow: set.flow,
41
- transition: exec.action === TransitionAction.Transit ? exec.transition : undefined,
42
- from: set.from,
43
- to: set.to,
44
- changes: set.changes,
45
- unset: set.unset.length > 0 ? set.unset : undefined,
46
- link: exec.link != null && exec.action !== TransitionAction.Create ? withFrom(exec.link, cardId) : undefined,
47
- links: resolved.create && (exec.links?.length ?? 0) > 0 ? exec.links.map(link => withFrom(link, cardId)) : undefined,
48
- actor: actorOf(scope, exec),
49
- cause: exec.cause,
50
- key: exec.key,
51
- at,
52
- commit: { state: CommitState.Pending },
3
+ export const createChangesUtils = () => {
4
+ const changeSetOf = (exec, resolved, schemas, at) => {
5
+ const set = changesHelper.computeChanges(resolved.card, exec, resolved.type, schemas, at, { slot: resolved.slot });
6
+ const empty = exec.action === TransitionAction.Update && changesHelper.isEmptyChange(set);
7
+ return { set, empty };
8
+ };
9
+ const actorOf = (scope, exec) => clean({
10
+ agent: exec.actor?.agent,
11
+ runId: exec.actor?.runId,
12
+ ...clean({ profileId: scope.profileId, userId: scope.userId, service: scope.service }),
13
+ ...clean(scope.actor ?? {}),
14
+ channel: scope.channel ?? scope.actor?.channel,
53
15
  });
16
+ const withFrom = (link, card) => ({ ...link, from: link.from ?? card });
17
+ const transitionOf = (params) => {
18
+ const { exec, resolved, scope, set, cardId, seq, project, at } = params;
19
+ const kind = resolved.create ? exec.card.kind : resolved.card.kind;
20
+ return clean({
21
+ entityId: scope.entityId,
22
+ card: cardId,
23
+ kind,
24
+ type: resolved.type.type,
25
+ project,
26
+ seq,
27
+ action: exec.action,
28
+ flow: set.flow,
29
+ transition: exec.action === TransitionAction.Transit ? exec.transition : undefined,
30
+ from: set.from,
31
+ to: set.to,
32
+ changes: set.changes,
33
+ unset: set.unset.length > 0 ? set.unset : undefined,
34
+ link: exec.link != null && exec.action !== TransitionAction.Create ? withFrom(exec.link, cardId) : undefined,
35
+ links: resolved.create && (exec.links?.length ?? 0) > 0 ? exec.links.map(link => withFrom(link, cardId)) : undefined,
36
+ actor: actorOf(scope, exec),
37
+ cause: exec.cause,
38
+ key: exec.key,
39
+ at,
40
+ commit: { state: CommitState.Pending },
41
+ });
42
+ };
43
+ return { changeSetOf, actorOf, transitionOf };
54
44
  };
45
+ export const changesUtils = createChangesUtils();
55
46
  //# sourceMappingURL=changes.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"changes.js","sourceRoot":"","sources":["../../src/executor/changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,aAAa,EAAE,gBAAgB,EAAgL,MAAM,oBAAoB,CAAA;AAG/Q,MAAM,KAAK,GAAG,CAAmB,MAAS,EAAK,EAAE,CAC/C,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAM,CAAA;AAE5F;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAyB,EAAE,QAAkB,EAAE,OAA+B,EAAE,EAAU,EACtD,EAAE;IACtC,MAAM,GAAG,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IACpG,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,IAAI,aAAa,CAAC,GAAG,CAAC,CAAA;IAE3E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAA;AACvB,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAoB,EAAE,IAAyB,EAAmB,EAAE,CAAC,KAAK,CAAC;IACjG,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK;IACxB,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK;IACxB,GAAG,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,CA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K,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,EAAE;YACF,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,OAAO,EAAE;SACvC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,17 @@
1
+ import type { PlanningExecContext, PlanningPlugin, PlanningScope, TransitionExecution } from '@owlmeans/planning';
2
+ import type { PluginRegistry } from '../../types.js';
3
+ import type { Resolved } from '../types.js';
4
+ /** Step 8 of the write path: the code a card gets, unique within its policy's scope. */
5
+ export interface CodeUtils {
6
+ /**
7
+ * Step 8: the code a new card gets, or the check a changed code passes.
8
+ *
9
+ * A caller-supplied code is checked for uniqueness; otherwise the plugins' `mintCode` chain answers
10
+ * (first answer wins, and is checked too); otherwise the type's policy mints one — a slug policy
11
+ * derives it from the title. A type with no policy and no supplied code gets none.
12
+ *
13
+ * @throws {CodeTaken}
14
+ */
15
+ assignCode: (exec: TransitionExecution, resolved: Resolved, scope: PlanningScope, registry: PluginRegistry, contextOf: (plugin: PlanningPlugin) => PlanningExecContext) => Promise<TransitionExecution>;
16
+ }
17
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/code/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AACjH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,wFAAwF;AACxF,MAAM,WAAW,SAAS;IACxB;;;;;;;;OAQG;IACH,UAAU,EAAE,CACV,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,mBAAmB,KACvD,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/code/types.ts"],"names":[],"mappings":""}
@@ -1,15 +1,4 @@
1
- import { type PlanningExecContext, type PlanningPlugin, type PlanningScope, type TransitionExecution } from '@owlmeans/planning';
2
- import type { PluginRegistry } from '../types.js';
3
- import type { Resolved } from './types.js';
4
- export declare const takenProbe: (resolved: Resolved, scope: PlanningScope, parent: string | undefined) => (code: string) => Promise<boolean>;
5
- /**
6
- * Step 8: the code a new card gets, or the check a changed code passes.
7
- *
8
- * A caller-supplied code is checked for uniqueness; otherwise the plugins' `mintCode` chain answers
9
- * (first answer wins, and is checked too); otherwise the type's policy mints one — a slug policy
10
- * derives it from the title. A type with no policy and no supplied code gets none.
11
- *
12
- * @throws {CodeTaken}
13
- */
14
- export declare const assignCode: (exec: TransitionExecution, resolved: Resolved, scope: PlanningScope, registry: PluginRegistry, contextOf: (plugin: PlanningPlugin) => PlanningExecContext) => Promise<TransitionExecution>;
1
+ import type { CodeUtils } from './code/types.js';
2
+ export declare const createCodeUtils: () => CodeUtils;
3
+ export declare const codeUtils: CodeUtils;
15
4
  //# sourceMappingURL=code.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoG,KAAK,mBAAmB,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAqC,MAAM,oBAAoB,CAAA;AAErQ,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAW1C,eAAO,MAAM,UAAU,aAAc,QAAQ,SAAS,aAAa,UAAU,MAAM,GAAG,SAAS,YAGzE,MAAM,KAAG,OAAO,CAAC,OAAO,CAE7C,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,SACf,mBAAmB,YACf,QAAQ,SACX,aAAa,YACV,cAAc,aACb,CAAC,MAAM,EAAE,cAAc,KAAK,mBAAmB,KACzD,OAAO,CAAC,mBAAmB,CAwC7B,CAAA"}
1
+ {"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAGhD,eAAO,MAAM,eAAe,QAAO,SAmElC,CAAA;AAED,eAAO,MAAM,SAAS,WAAoB,CAAA"}
@@ -1,59 +1,55 @@
1
- import { CODE_MINT_ATTEMPTS, CodeScope, CodeStyle, CodeTaken, mintCode, TransitionAction } from '@owlmeans/planning';
2
- /** The criteria a code must be unique within — the policy's scope, `parent` when there is none. */
3
- const scopeCriteria = (scope, type, parent, policy) => ({
4
- entityId: scope.entityId,
5
- type,
6
- ...((policy?.uniqueWithin ?? CodeScope.Parent) === CodeScope.Parent ? { parent: parent ?? null } : {}),
7
- });
8
- export const takenProbe = (resolved, scope, parent) => {
9
- const base = scopeCriteria(scope, resolved.type.type, parent, resolved.type.code);
10
- return async (code) => await resolved.store.cards.count({ ...base, code }) > 0;
11
- };
12
- /**
13
- * Step 8: the code a new card gets, or the check a changed code passes.
14
- *
15
- * A caller-supplied code is checked for uniqueness; otherwise the plugins' `mintCode` chain answers
16
- * (first answer wins, and is checked too); otherwise the type's policy mints one — a slug policy
17
- * derives it from the title. A type with no policy and no supplied code gets none.
18
- *
19
- * @throws {CodeTaken}
20
- */
21
- export const assignCode = async (exec, resolved, scope, registry, contextOf) => {
22
- const policy = resolved.type.code;
23
- if (exec.action !== TransitionAction.Create) {
24
- const code = exec.changes?.code;
25
- if (code != null && code !== resolved.card?.code
26
- && await takenProbe(resolved, scope, exec.changes?.parent ?? resolved.card?.parent)(code)) {
27
- throw new CodeTaken(code);
1
+ import { CODE_MINT_ATTEMPTS, codeHelper, CodeScope, CodeStyle, CodeTaken, TransitionAction } from '@owlmeans/planning';
2
+ export const createCodeUtils = () => {
3
+ /** The criteria a code must be unique within — the policy's scope, `parent` when there is none. */
4
+ const scopeCriteria = (scope, type, parent, policy) => ({
5
+ entityId: scope.entityId,
6
+ type,
7
+ ...((policy?.uniqueWithin ?? CodeScope.Parent) === CodeScope.Parent ? { parent: parent ?? null } : {}),
8
+ });
9
+ /** Is a code taken within the scope the type's policy names (its parent when it names none)? */
10
+ const takenProbe = (resolved, scope, parent) => {
11
+ const base = scopeCriteria(scope, resolved.type.type, parent, resolved.type.code);
12
+ return async (code) => await resolved.store.cards.count({ ...base, code }) > 0;
13
+ };
14
+ const assignCode = async (exec, resolved, scope, registry, contextOf) => {
15
+ const policy = resolved.type.code;
16
+ if (exec.action !== TransitionAction.Create) {
17
+ const code = exec.changes?.code;
18
+ if (code != null && code !== resolved.card?.code
19
+ && await takenProbe(resolved, scope, exec.changes?.parent ?? resolved.card?.parent)(code)) {
20
+ throw new CodeTaken(code);
21
+ }
22
+ return exec;
23
+ }
24
+ const draft = exec.card;
25
+ const taken = takenProbe(resolved, scope, draft.parent);
26
+ if (draft.code != null && draft.code !== '') {
27
+ if (await taken(draft.code)) {
28
+ throw new CodeTaken(draft.code);
29
+ }
30
+ return exec;
31
+ }
32
+ if (policy == null) {
33
+ return exec;
28
34
  }
29
- return exec;
30
- }
31
- const draft = exec.card;
32
- const taken = takenProbe(resolved, scope, draft.parent);
33
- if (draft.code != null && draft.code !== '') {
34
- if (await taken(draft.code)) {
35
- throw new CodeTaken(draft.code);
35
+ let code = await registry.mintCode(draft, taken, contextOf);
36
+ if (code != null) {
37
+ if (await taken(code)) {
38
+ throw new CodeTaken(code);
39
+ }
36
40
  }
37
- return exec;
38
- }
39
- if (policy == null) {
40
- return exec;
41
- }
42
- let code = await registry.mintCode(draft, taken, contextOf);
43
- if (code != null) {
44
- if (await taken(code)) {
45
- throw new CodeTaken(code);
41
+ else {
42
+ const count = policy.style === CodeStyle.Sequential
43
+ ? await resolved.store.cards.count(scopeCriteria(scope, draft.type, draft.parent, policy))
44
+ : undefined;
45
+ code = await codeHelper.mintCode(policy, taken, CODE_MINT_ATTEMPTS, {
46
+ ...(policy.style === CodeStyle.Slug ? { seed: draft.title } : {}),
47
+ ...(count != null ? { count } : {}),
48
+ });
46
49
  }
47
- }
48
- else {
49
- const count = policy.style === CodeStyle.Sequential
50
- ? await resolved.store.cards.count(scopeCriteria(scope, draft.type, draft.parent, policy))
51
- : undefined;
52
- code = await mintCode(policy, taken, CODE_MINT_ATTEMPTS, {
53
- ...(policy.style === CodeStyle.Slug ? { seed: draft.title } : {}),
54
- ...(count != null ? { count } : {}),
55
- });
56
- }
57
- return { ...exec, card: { ...draft, code } };
50
+ return { ...exec, card: { ...draft, code } };
51
+ };
52
+ return { assignCode };
58
53
  };
54
+ export const codeUtils = createCodeUtils();
59
55
  //# sourceMappingURL=code.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/executor/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAmJ,MAAM,oBAAoB,CAAA;AAKrQ,mGAAmG;AACnG,MAAM,aAAa,GAAG,CACpB,KAAoB,EAAE,IAAY,EAAE,MAA0B,EAAE,MAAmB,EAC/D,EAAE,CAAC,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;IACxB,IAAI;IACJ,GAAG,CAAC,CAAC,MAAM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CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAA;QAC3D,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,SAAS,CAAC,IAAI,CAAC,CAAA;YAC3B,CAAC;QACH,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,UAAU;gBACjD,CAAC,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAC1F,CAAC,CAAC,SAAS,CAAA;YACb,IAAI,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,kBAAkB,EAAE;gBAClE,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpC,CAAC,CAAA;QACJ,CAAC;QAED,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,EAAE,CAAA;IAC9C,CAAC,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,EAAE,CAAA"}
@@ -0,0 +1,33 @@
1
+ import type { PlanningScope, TransitionExecution } from '@owlmeans/planning';
2
+ /** Who owns a card: `createdBy`, stamped from the scope on a create and fixed after it. */
3
+ export interface CreatorHelper {
4
+ /**
5
+ * The subject a create made under `scope` is stamped with as its `createdBy`: the scope's
6
+ * `profileId`, else its `userId`, else the same two of its `actor` — the authenticated subject an
7
+ * HTTP scope carries, in the same format. `undefined` for a scope that names nobody (a service or a
8
+ * system scope).
9
+ */
10
+ creatorOf: (scope: PlanningScope) => string | undefined;
11
+ /**
12
+ * A create's draft with `createdBy` defaulted to {@link CreatorHelper.creatorOf} the scope. A
13
+ * `createdBy` the caller supplied wins; a scope that names nobody leaves the draft as it is;
14
+ * anything but a create is returned untouched. Never mutates `exec`.
15
+ *
16
+ * The executor applies it to every execution, so an in-process facade create and a wire create
17
+ * stamp the same value.
18
+ */
19
+ withCreator: (exec: TransitionExecution, scope: PlanningScope) => TransitionExecution;
20
+ /**
21
+ * Refuse an execution that names `createdBy` in `changes` or `unset`, whatever the action — a
22
+ * create included, whose owner is its draft's. After the create it never moves, so an ownership
23
+ * check (`card.createdBy === profileId`) cannot be bypassed by anyone allowed to update the card.
24
+ *
25
+ * The executor runs it with the immutables of step 6, after the `before` chain, so a wire body, an
26
+ * in-process caller and a plugin are refused alike. It is the executor's own check, whatever
27
+ * `@owlmeans/planning` build `changesHelper.assertMutable` comes from.
28
+ *
29
+ * @throws {PlanningError} `planning:immutable:createdBy`
30
+ */
31
+ assertCreatorFixed: (exec: TransitionExecution) => void;
32
+ }
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/creator/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAE5E,2FAA2F;AAC3F,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,MAAM,GAAG,SAAS,CAAA;IACvD;;;;;;;OAOG;IACH,WAAW,EAAE,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,aAAa,KAAK,mBAAmB,CAAA;IACrF;;;;;;;;;;OAUG;IACH,kBAAkB,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACxD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/creator/types.ts"],"names":[],"mappings":""}
@@ -1,30 +1,11 @@
1
1
  import { type PlanningScope, type TransitionExecution } from '@owlmeans/planning';
2
- /**
3
- * The subject a create made under `scope` is stamped with as its `createdBy`: the scope's
4
- * `profileId`, else its `userId`, else the same two of its `actor` — the authenticated subject an
5
- * HTTP scope carries, in the same format. `undefined` for a scope that names nobody (a service or a
6
- * system scope).
7
- */
2
+ import type { CreatorHelper } from './creator/types.js';
3
+ export declare const createCreatorHelper: () => CreatorHelper;
4
+ export declare const creatorHelper: CreatorHelper;
5
+ /** @deprecated compat:factory-refactor — use `creatorHelper.creatorOf(…)` */
8
6
  export declare const creatorOf: (scope: PlanningScope) => string | undefined;
9
- /**
10
- * A create's draft with `createdBy` defaulted to {@link creatorOf} the scope. A `createdBy` the
11
- * caller supplied wins; a scope that names nobody leaves the draft as it is; anything but a create
12
- * is returned untouched. Never mutates `exec`.
13
- *
14
- * The executor applies it to every execution, so an in-process facade create and a wire create
15
- * stamp the same value.
16
- */
7
+ /** @deprecated compat:factory-refactor — use `creatorHelper.withCreator(…)` */
17
8
  export declare const withCreator: (exec: TransitionExecution, scope: PlanningScope) => TransitionExecution;
18
- /**
19
- * Refuse an execution that names `createdBy` in `changes` or `unset`, whatever the action — a
20
- * create included, whose owner is its draft's. After the create it never moves, so an ownership
21
- * check (`card.createdBy === profileId`) cannot be bypassed by anyone allowed to update the card.
22
- *
23
- * The executor runs it with the immutables of step 6, after the `before` chain, so a wire body, an
24
- * in-process caller and a plugin are refused alike. It is the executor's own check, whatever
25
- * `@owlmeans/planning` build `assertMutable` comes from.
26
- *
27
- * @throws {PlanningError} `planning:immutable:createdBy`
28
- */
9
+ /** @deprecated compat:factory-refactor — use `creatorHelper.assertCreatorFixed(…)` */
29
10
  export declare const assertCreatorFixed: (exec: TransitionExecution) => void;
30
11
  //# sourceMappingURL=creator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"creator.d.ts","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAKlH;;;;;GAKG;AACH,eAAO,MAAM,SAAS,UAAW,aAAa,KAAG,MAAM,GAAG,SACgC,CAAA;AAE1F;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,SAAU,mBAAmB,SAAS,aAAa,KAAG,mBAU7E,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,SAAU,mBAAmB,KAAG,IAK9D,CAAA"}
1
+ {"version":3,"file":"creator.d.ts","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAElH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,eAAO,MAAM,mBAAmB,QAAO,aAwBtC,CAAA;AAED,eAAO,MAAM,aAAa,eAAwB,CAAA;AAElD,6EAA6E;AAC7E,eAAO,MAAM,SAAS,UAAW,aAAa,KAAG,MAAM,GAAG,SAA2C,CAAA;AAErG,+EAA+E;AAC/E,eAAO,MAAM,WAAW,SAAU,mBAAmB,SAAS,aAAa,KAAG,mBACtC,CAAA;AAExC,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,SAAU,mBAAmB,KAAG,IAA8C,CAAA"}
@@ -1,46 +1,31 @@
1
1
  import { PlanningError, TransitionAction } from '@owlmeans/planning';
2
2
  import { CREATOR } from './consts.local.js';
3
3
  const named = (value) => value != null && value !== '';
4
- /**
5
- * The subject a create made under `scope` is stamped with as its `createdBy`: the scope's
6
- * `profileId`, else its `userId`, else the same two of its `actor` — the authenticated subject an
7
- * HTTP scope carries, in the same format. `undefined` for a scope that names nobody (a service or a
8
- * system scope).
9
- */
10
- export const creatorOf = (scope) => [scope.profileId, scope.userId, scope.actor?.profileId, scope.actor?.userId].find(named);
11
- /**
12
- * A create's draft with `createdBy` defaulted to {@link creatorOf} the scope. A `createdBy` the
13
- * caller supplied wins; a scope that names nobody leaves the draft as it is; anything but a create
14
- * is returned untouched. Never mutates `exec`.
15
- *
16
- * The executor applies it to every execution, so an in-process facade create and a wire create
17
- * stamp the same value.
18
- */
19
- export const withCreator = (exec, scope) => {
20
- if (exec.action !== TransitionAction.Create || exec.card == null || typeof exec.card !== 'object') {
21
- return exec;
22
- }
23
- if (named(exec.card.createdBy)) {
24
- return exec;
25
- }
26
- const creator = creatorOf(scope);
27
- return creator == null ? exec : { ...exec, card: { ...exec.card, createdBy: creator } };
28
- };
29
- /**
30
- * Refuse an execution that names `createdBy` in `changes` or `unset`, whatever the action — a
31
- * create included, whose owner is its draft's. After the create it never moves, so an ownership
32
- * check (`card.createdBy === profileId`) cannot be bypassed by anyone allowed to update the card.
33
- *
34
- * The executor runs it with the immutables of step 6, after the `before` chain, so a wire body, an
35
- * in-process caller and a plugin are refused alike. It is the executor's own check, whatever
36
- * `@owlmeans/planning` build `assertMutable` comes from.
37
- *
38
- * @throws {PlanningError} `planning:immutable:createdBy`
39
- */
40
- export const assertCreatorFixed = (exec) => {
41
- if (exec.changes?.[CREATOR] !== undefined
42
- || (exec.unset ?? []).some(path => path.split('.')[0] === CREATOR)) {
43
- throw new PlanningError(`immutable:${CREATOR}`);
44
- }
4
+ export const createCreatorHelper = () => {
5
+ const creatorOf = (scope) => [scope.profileId, scope.userId, scope.actor?.profileId, scope.actor?.userId].find(named);
6
+ const withCreator = (exec, scope) => {
7
+ if (exec.action !== TransitionAction.Create || exec.card == null || typeof exec.card !== 'object') {
8
+ return exec;
9
+ }
10
+ if (named(exec.card.createdBy)) {
11
+ return exec;
12
+ }
13
+ const creator = creatorOf(scope);
14
+ return creator == null ? exec : { ...exec, card: { ...exec.card, createdBy: creator } };
15
+ };
16
+ const assertCreatorFixed = (exec) => {
17
+ if (exec.changes?.[CREATOR] !== undefined
18
+ || (exec.unset ?? []).some(path => path.split('.')[0] === CREATOR)) {
19
+ throw new PlanningError(`immutable:${CREATOR}`);
20
+ }
21
+ };
22
+ return { creatorOf, withCreator, assertCreatorFixed };
45
23
  };
24
+ export const creatorHelper = createCreatorHelper();
25
+ /** @deprecated compat:factory-refactor — use `creatorHelper.creatorOf(…)` */
26
+ export const creatorOf = (scope) => creatorHelper.creatorOf(scope);
27
+ /** @deprecated compat:factory-refactor — use `creatorHelper.withCreator(…)` */
28
+ export const withCreator = (exec, scope) => creatorHelper.withCreator(exec, scope);
29
+ /** @deprecated compat:factory-refactor — use `creatorHelper.assertCreatorFixed(…)` */
30
+ export const assertCreatorFixed = (exec) => creatorHelper.assertCreatorFixed(exec);
46
31
  //# sourceMappingURL=creator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"creator.js","sourceRoot":"","sources":["../../src/executor/creator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAgD,MAAM,oBAAoB,CAAA;AAClH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,MAAM,KAAK,GAAG,CAAC,KAAqB,EAAmB,EAAE,CAAC,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,CAAA;AAEvF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAsB,EAAE,CACpE,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AAE1F;;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CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,aAAa,CAAC,aAAa,OAAO,EAAE,CAAC,CAAA;QACjD,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAA;AACvD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,EAAE,CAAA;AAElD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAoB,EAAsB,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAErG,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAyB,EAAE,KAAoB,EAAuB,EAAE,CAClG,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AAExC,sFAAsF;AACtF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAyB,EAAQ,EAAE,CAAC,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA"}
@@ -0,0 +1,30 @@
1
+ import type { PlanningFacade, PlanningSchemaRegistry, TransitionExecution, Workcard, WorkcardKind } from '@owlmeans/planning';
2
+ import type { Resolved } from '../types.js';
3
+ /** Steps 1 and 4 of the write path, over one service runtime. */
4
+ export interface ResolveUtils {
5
+ /**
6
+ * Step 1: a deep copy with trimmed text, `parents ∋ parent` on a draft, and no duplicate `unset`
7
+ * paths. The caller's object is never touched.
8
+ */
9
+ normalizeExecution: (input: TransitionExecution) => TransitionExecution;
10
+ /**
11
+ * The parent type's rule for a child of `kind`/`type`: a project lists the `cardTypes` (and
12
+ * `projectTypes`) it admits, and one declaring `scopedCardTypes` also admits a card type its layer
13
+ * (`view`, the parent project's resolved schemas) defines as data. Project types are code's alone.
14
+ *
15
+ * @throws {CardTypeNotAllowed}
16
+ */
17
+ assertChildAllowed: (parent: Workcard, kind: WorkcardKind, type: string, view?: PlanningSchemaRegistry) => void;
18
+ /** The layer a parent project admits data-defined children through — `undefined` without a schema port. */
19
+ childViewOf: (entityId: string, parent: Workcard) => Promise<PlanningSchemaRegistry | undefined>;
20
+ /**
21
+ * Step 4: the card, its type and flow, its parent and — for a specification — its slot.
22
+ *
23
+ * @throws {WorkcardNotFound | PlanningScopeMismatch | UnknownWorkcardType | UnknownStatusFlow}
24
+ * @throws {ParentNotFound | CardTypeNotAllowed | PlanningError}
25
+ */
26
+ resolveExecution: (facade: PlanningFacade, exec: TransitionExecution) => Promise<Resolved>;
27
+ /** The project a transition is filed under: a project's own id, else its parent's project. */
28
+ projectFor: (resolved: Resolved, exec: TransitionExecution, cardId: string) => string | undefined;
29
+ }
30
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/executor/resolve/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAC7H,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,kBAAkB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,mBAAmB,CAAA;IACvE;;;;;;OAMG;IACH,kBAAkB,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,sBAAsB,KAAK,IAAI,CAAA;IAC/G,2GAA2G;IAC3G,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,KAAK,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CAAA;IAChG;;;;;OAKG;IACH,gBAAgB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC1F,8FAA8F;IAC9F,UAAU,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;CAClG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/executor/resolve/types.ts"],"names":[],"mappings":""}
@@ -1,43 +1,6 @@
1
- import { WorkcardKind, type PlanningFacade, type PlanningSchemaRegistry, type TransitionExecution, type Workcard } from '@owlmeans/planning';
2
1
  import type { PlanningRuntime } from '../types.js';
3
- import type { Resolved } from './types.js';
4
- /**
5
- * Step 1: a deep copy with trimmed text, `parents ∋ parent` on a draft, and no duplicate `unset`
6
- * paths. The caller's object is never touched.
7
- */
8
- declare const normalizeExecution: (input: TransitionExecution) => TransitionExecution;
9
- /**
10
- * The parent type's rule for a child of `kind`/`type`: a project lists the `cardTypes` (and
11
- * `projectTypes`) it admits, and one declaring `scopedCardTypes` also admits a card type its layer
12
- * (`view`, the parent project's resolved schemas) defines as data. Project types are code's alone.
13
- *
14
- * @throws {CardTypeNotAllowed}
15
- */
16
- declare const assertChildAllowed: (runtime: PlanningRuntime, parent: Workcard, kind: WorkcardKind, type: string, view?: PlanningSchemaRegistry) => void;
17
- /** The layer a parent project admits data-defined children through — `undefined` without a schema port. */
18
- declare const childViewOf: (runtime: PlanningRuntime, entityId: string, parent: Workcard) => Promise<PlanningSchemaRegistry | undefined>;
19
- /**
20
- * Step 4: the card, its type and flow, its parent and — for a specification — its slot.
21
- *
22
- * @throws {WorkcardNotFound | PlanningScopeMismatch | UnknownWorkcardType | UnknownStatusFlow}
23
- * @throws {ParentNotFound | CardTypeNotAllowed | PlanningError}
24
- */
25
- declare const resolveExecution: (runtime: PlanningRuntime, facade: PlanningFacade, exec: TransitionExecution) => Promise<Resolved>;
26
- /** The project a transition is filed under: a project's own id, else its parent's project. */
27
- declare const projectFor: (resolved: Resolved, exec: TransitionExecution, cardId: string) => string | undefined;
28
- export declare const createResolveHelper: () => {
29
- normalizeExecution: typeof normalizeExecution;
30
- assertChildAllowed: typeof assertChildAllowed;
31
- childViewOf: typeof childViewOf;
32
- resolveExecution: typeof resolveExecution;
33
- projectFor: typeof projectFor;
34
- };
35
- export declare const resolveHelper: {
36
- normalizeExecution: typeof normalizeExecution;
37
- assertChildAllowed: typeof assertChildAllowed;
38
- childViewOf: typeof childViewOf;
39
- resolveExecution: typeof resolveExecution;
40
- projectFor: typeof projectFor;
41
- };
42
- export {};
2
+ import type { ResolveUtils } from './resolve/types.js';
3
+ export declare const makeResolveUtils: (runtime: PlanningRuntime) => ResolveUtils;
4
+ /** The resolution steps of one service runtime — one per runtime. */
5
+ export declare const resolveUtilsOf: (target: PlanningRuntime) => ResolveUtils;
43
6
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/executor/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuO,YAAY,EAAwC,KAAK,cAAc,EAAE,KAAK,sBAAsB,EAAyE,KAAK,mBAAmB,EAAE,KAAK,QAAQ,EAAsB,MAAM,oBAAoB,CAAA;AAClf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AA6B1C;;;GAGG;AACH,QAAA,MAAM,kBAAkB,UAAW,mBAAmB,KAAG,mBAcxD,CAAA;AAED;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,YACb,eAAe,UAAU,QAAQ,QAAQ,YAAY,QAAQ,MAAM,SAAS,sBAAsB,KAC1G,IAgBF,CAAA;AAED,2GAA2G;AAC3G,QAAA,MAAM,WAAW,YACN,eAAe,YAAY,MAAM,UAAU,QAAQ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