@owlmeans/server-planning 0.1.18-rc.9 → 0.1.18

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 (438) hide show
  1. package/README.md +92 -19
  2. package/agent-meta/manifest.json +105 -4
  3. package/agent-meta/skills/server-planning/SKILL.md +89 -138
  4. package/agent-meta/skills/server-planning/parts/auxiliary.md +54 -0
  5. package/agent-meta/skills/server-planning/parts/executor.md +82 -0
  6. package/agent-meta/skills/server-planning/parts/schemas.md +26 -0
  7. package/agent-meta/skills/server-planning/parts/serving.md +88 -0
  8. package/agent-meta/skills/server-planning/parts/stores.md +91 -0
  9. package/build/actions/apply-schema-request.d.ts +8 -0
  10. package/build/actions/apply-schema-request.d.ts.map +1 -0
  11. package/build/actions/apply-schema-request.js +33 -0
  12. package/build/actions/apply-schema-request.js.map +1 -0
  13. package/build/actions/commit.d.ts +3 -3
  14. package/build/actions/commit.d.ts.map +1 -1
  15. package/build/actions/commit.js +5 -4
  16. package/build/actions/commit.js.map +1 -1
  17. package/build/actions/define-schemas.d.ts +13 -0
  18. package/build/actions/define-schemas.d.ts.map +1 -0
  19. package/build/actions/define-schemas.js +28 -0
  20. package/build/actions/define-schemas.js.map +1 -0
  21. package/build/actions/execute.d.ts +11 -10
  22. package/build/actions/execute.d.ts.map +1 -1
  23. package/build/actions/execute.js +17 -27
  24. package/build/actions/execute.js.map +1 -1
  25. package/build/actions/execution/types.d.ts +34 -0
  26. package/build/actions/execution/types.d.ts.map +1 -0
  27. package/build/actions/execution/types.js +2 -0
  28. package/build/actions/execution/types.js.map +1 -0
  29. package/build/actions/execution.d.ts +4 -0
  30. package/build/actions/execution.d.ts.map +1 -0
  31. package/build/actions/execution.js +88 -0
  32. package/build/actions/execution.js.map +1 -0
  33. package/build/actions/get-card.d.ts +6 -0
  34. package/build/actions/get-card.d.ts.map +1 -0
  35. package/build/actions/get-card.js +9 -0
  36. package/build/actions/get-card.js.map +1 -0
  37. package/build/actions/get-specification.d.ts +6 -0
  38. package/build/actions/get-specification.d.ts.map +1 -0
  39. package/build/actions/get-specification.js +9 -0
  40. package/build/actions/get-specification.js.map +1 -0
  41. package/build/actions/index.d.ts +12 -3
  42. package/build/actions/index.d.ts.map +1 -1
  43. package/build/actions/index.js +11 -3
  44. package/build/actions/index.js.map +1 -1
  45. package/build/actions/links.d.ts +3 -3
  46. package/build/actions/links.d.ts.map +1 -1
  47. package/build/actions/links.js +6 -5
  48. package/build/actions/links.js.map +1 -1
  49. package/build/actions/list-card-specifications.d.ts +6 -0
  50. package/build/actions/list-card-specifications.d.ts.map +1 -0
  51. package/build/actions/list-card-specifications.js +11 -0
  52. package/build/actions/list-card-specifications.js.map +1 -0
  53. package/build/actions/list-card-transitions.d.ts +6 -0
  54. package/build/actions/list-card-transitions.d.ts.map +1 -0
  55. package/build/actions/list-card-transitions.js +11 -0
  56. package/build/actions/list-card-transitions.js.map +1 -0
  57. package/build/actions/list-cards.d.ts +6 -0
  58. package/build/actions/list-cards.d.ts.map +1 -0
  59. package/build/actions/list-cards.js +10 -0
  60. package/build/actions/list-cards.js.map +1 -0
  61. package/build/actions/list-schemas.d.ts +13 -0
  62. package/build/actions/list-schemas.d.ts.map +1 -0
  63. package/build/actions/list-schemas.js +20 -0
  64. package/build/actions/list-schemas.js.map +1 -0
  65. package/build/actions/list-specification-revisions.d.ts +6 -0
  66. package/build/actions/list-specification-revisions.d.ts.map +1 -0
  67. package/build/actions/list-specification-revisions.js +10 -0
  68. package/build/actions/list-specification-revisions.js.map +1 -0
  69. package/build/actions/resources.d.ts +5 -0
  70. package/build/actions/resources.d.ts.map +1 -0
  71. package/build/actions/resources.js +111 -0
  72. package/build/actions/resources.js.map +1 -0
  73. package/build/actions/summarize-cards.d.ts +6 -0
  74. package/build/actions/summarize-cards.d.ts.map +1 -0
  75. package/build/actions/summarize-cards.js +11 -0
  76. package/build/actions/summarize-cards.js.map +1 -0
  77. package/build/actions/transitions.d.ts +3 -3
  78. package/build/actions/transitions.d.ts.map +1 -1
  79. package/build/actions/transitions.js +4 -3
  80. package/build/actions/transitions.js.map +1 -1
  81. package/build/actions/types.d.ts +6 -0
  82. package/build/actions/types.d.ts.map +1 -0
  83. package/build/actions/types.js +2 -0
  84. package/build/actions/types.js.map +1 -0
  85. package/build/actions/watch.d.ts +2 -2
  86. package/build/actions/watch.d.ts.map +1 -1
  87. package/build/actions/watch.js +8 -6
  88. package/build/actions/watch.js.map +1 -1
  89. package/build/conformance/assert/types.d.ts +19 -0
  90. package/build/conformance/assert/types.d.ts.map +1 -0
  91. package/build/conformance/assert/types.js +2 -0
  92. package/build/conformance/assert/types.js.map +1 -0
  93. package/build/conformance/assert.d.ts +15 -0
  94. package/build/conformance/assert.d.ts.map +1 -0
  95. package/build/conformance/assert.js +52 -0
  96. package/build/conformance/assert.js.map +1 -0
  97. package/build/conformance/cases.d.ts +7 -0
  98. package/build/conformance/cases.d.ts.map +1 -0
  99. package/build/conformance/cases.js +544 -0
  100. package/build/conformance/cases.js.map +1 -0
  101. package/build/conformance/clock.d.ts +6 -0
  102. package/build/conformance/clock.d.ts.map +1 -0
  103. package/build/conformance/clock.js +12 -0
  104. package/build/conformance/clock.js.map +1 -0
  105. package/build/conformance/consts.d.ts +30 -0
  106. package/build/conformance/consts.d.ts.map +1 -0
  107. package/build/conformance/consts.js +159 -0
  108. package/build/conformance/consts.js.map +1 -0
  109. package/build/conformance/errors.d.ts +5 -0
  110. package/build/conformance/errors.d.ts.map +1 -0
  111. package/build/conformance/errors.js +8 -0
  112. package/build/conformance/errors.js.map +1 -0
  113. package/build/conformance/fixtures/types.d.ts +13 -0
  114. package/build/conformance/fixtures/types.d.ts.map +1 -0
  115. package/build/conformance/fixtures/types.js +2 -0
  116. package/build/conformance/fixtures/types.js.map +1 -0
  117. package/build/conformance/fixtures.d.ts +14 -0
  118. package/build/conformance/fixtures.d.ts.map +1 -0
  119. package/build/conformance/fixtures.js +26 -0
  120. package/build/conformance/fixtures.js.map +1 -0
  121. package/build/conformance/index.d.ts +15 -0
  122. package/build/conformance/index.d.ts.map +1 -0
  123. package/build/conformance/index.js +12 -0
  124. package/build/conformance/index.js.map +1 -0
  125. package/build/conformance/resources.d.ts +4 -0
  126. package/build/conformance/resources.d.ts.map +1 -0
  127. package/build/conformance/resources.js +228 -0
  128. package/build/conformance/resources.js.map +1 -0
  129. package/build/conformance/types.d.ts +18 -0
  130. package/build/conformance/types.d.ts.map +1 -0
  131. package/build/conformance/types.js +2 -0
  132. package/build/conformance/types.js.map +1 -0
  133. package/build/consts.d.ts +5 -0
  134. package/build/consts.d.ts.map +1 -1
  135. package/build/consts.js +5 -0
  136. package/build/consts.js.map +1 -1
  137. package/build/definitions.d.ts +18 -0
  138. package/build/definitions.d.ts.map +1 -0
  139. package/build/definitions.js +225 -0
  140. package/build/definitions.js.map +1 -0
  141. package/build/executor/changes/types.d.ts +36 -0
  142. package/build/executor/changes/types.d.ts.map +1 -0
  143. package/build/executor/changes/types.js +2 -0
  144. package/build/executor/changes/types.js.map +1 -0
  145. package/build/executor/changes.d.ts +3 -30
  146. package/build/executor/changes.d.ts.map +1 -1
  147. package/build/executor/changes.js +42 -51
  148. package/build/executor/changes.js.map +1 -1
  149. package/build/executor/code/types.d.ts +17 -0
  150. package/build/executor/code/types.d.ts.map +1 -0
  151. package/build/executor/code/types.js +2 -0
  152. package/build/executor/code/types.js.map +1 -0
  153. package/build/executor/code.d.ts +3 -14
  154. package/build/executor/code.d.ts.map +1 -1
  155. package/build/executor/code.js +50 -54
  156. package/build/executor/code.js.map +1 -1
  157. package/build/executor/consts.local.d.ts +5 -0
  158. package/build/executor/consts.local.d.ts.map +1 -0
  159. package/build/executor/consts.local.js +6 -0
  160. package/build/executor/consts.local.js.map +1 -0
  161. package/build/executor/creator/types.d.ts +33 -0
  162. package/build/executor/creator/types.d.ts.map +1 -0
  163. package/build/executor/creator/types.js +2 -0
  164. package/build/executor/creator/types.js.map +1 -0
  165. package/build/executor/creator.d.ts +11 -0
  166. package/build/executor/creator.d.ts.map +1 -0
  167. package/build/executor/creator.js +32 -0
  168. package/build/executor/creator.js.map +1 -0
  169. package/build/executor/resolve/types.d.ts +30 -0
  170. package/build/executor/resolve/types.d.ts.map +1 -0
  171. package/build/executor/resolve/types.js +2 -0
  172. package/build/executor/resolve/types.js.map +1 -0
  173. package/build/executor/resolve.d.ts +5 -34
  174. package/build/executor/resolve.d.ts.map +1 -1
  175. package/build/executor/resolve.js +169 -110
  176. package/build/executor/resolve.js.map +1 -1
  177. package/build/executor/types.d.ts +23 -0
  178. package/build/executor/types.d.ts.map +1 -0
  179. package/build/executor/types.js +2 -0
  180. package/build/executor/types.js.map +1 -0
  181. package/build/executor/validate.d.ts +6 -5
  182. package/build/executor/validate.d.ts.map +1 -1
  183. package/build/executor/validate.js +38 -27
  184. package/build/executor/validate.js.map +1 -1
  185. package/build/executor.d.ts +11 -7
  186. package/build/executor.d.ts.map +1 -1
  187. package/build/executor.js +27 -21
  188. package/build/executor.js.map +1 -1
  189. package/build/facade.d.ts +20 -2
  190. package/build/facade.d.ts.map +1 -1
  191. package/build/facade.js +144 -22
  192. package/build/facade.js.map +1 -1
  193. package/build/helper.d.ts +5 -9
  194. package/build/helper.d.ts.map +1 -1
  195. package/build/helper.js +12 -11
  196. package/build/helper.js.map +1 -1
  197. package/build/hierarchy/types.d.ts +20 -0
  198. package/build/hierarchy/types.d.ts.map +1 -0
  199. package/build/hierarchy/types.js +2 -0
  200. package/build/hierarchy/types.js.map +1 -0
  201. package/build/hierarchy.d.ts +5 -0
  202. package/build/hierarchy.d.ts.map +1 -0
  203. package/build/hierarchy.js +133 -0
  204. package/build/hierarchy.js.map +1 -0
  205. package/build/index.d.ts +1 -0
  206. package/build/index.d.ts.map +1 -1
  207. package/build/index.js +1 -0
  208. package/build/index.js.map +1 -1
  209. package/build/invariants/types.d.ts +6 -0
  210. package/build/invariants/types.d.ts.map +1 -0
  211. package/build/invariants/types.js +2 -0
  212. package/build/invariants/types.js.map +1 -0
  213. package/build/invariants.d.ts +5 -0
  214. package/build/invariants.d.ts.map +1 -0
  215. package/build/invariants.js +126 -0
  216. package/build/invariants.js.map +1 -0
  217. package/build/projection.d.ts +4 -10
  218. package/build/projection.d.ts.map +1 -1
  219. package/build/projection.js +7 -5
  220. package/build/projection.js.map +1 -1
  221. package/build/queue/consts.d.ts +5 -0
  222. package/build/queue/consts.d.ts.map +1 -0
  223. package/build/queue/consts.js +5 -0
  224. package/build/queue/consts.js.map +1 -0
  225. package/build/queue/declare.d.ts +5 -0
  226. package/build/queue/declare.d.ts.map +1 -0
  227. package/build/queue/declare.js +5 -0
  228. package/build/queue/declare.js.map +1 -0
  229. package/build/queue/index.d.ts +3 -18
  230. package/build/queue/index.d.ts.map +1 -1
  231. package/build/queue/index.js +2 -7
  232. package/build/queue/index.js.map +1 -1
  233. package/build/queue/types.d.ts +13 -0
  234. package/build/queue/types.d.ts.map +1 -0
  235. package/build/queue/types.js +2 -0
  236. package/build/queue/types.js.map +1 -0
  237. package/build/registry.d.ts +5 -22
  238. package/build/registry.d.ts.map +1 -1
  239. package/build/registry.js +16 -10
  240. package/build/registry.js.map +1 -1
  241. package/build/resources.d.ts +5 -0
  242. package/build/resources.d.ts.map +1 -0
  243. package/build/resources.js +287 -0
  244. package/build/resources.js.map +1 -0
  245. package/build/service.d.ts +3 -16
  246. package/build/service.d.ts.map +1 -1
  247. package/build/service.js +12 -0
  248. package/build/service.js.map +1 -1
  249. package/build/store/commits.d.ts.map +1 -1
  250. package/build/store/commits.js +3 -1
  251. package/build/store/commits.js.map +1 -1
  252. package/build/store/composite.d.ts +1 -0
  253. package/build/store/composite.d.ts.map +1 -1
  254. package/build/store/composite.js +7 -2
  255. package/build/store/composite.js.map +1 -1
  256. package/build/store/consts.local.d.ts +2 -0
  257. package/build/store/consts.local.d.ts.map +1 -0
  258. package/build/store/consts.local.js +2 -0
  259. package/build/store/consts.local.js.map +1 -0
  260. package/build/store/fold/types.d.ts +43 -0
  261. package/build/store/fold/types.d.ts.map +1 -0
  262. package/build/store/fold/types.js +2 -0
  263. package/build/store/fold/types.js.map +1 -0
  264. package/build/store/fold.d.ts +8 -30
  265. package/build/store/fold.d.ts.map +1 -1
  266. package/build/store/fold.js +190 -198
  267. package/build/store/fold.js.map +1 -1
  268. package/build/store/index.d.ts +1 -0
  269. package/build/store/index.d.ts.map +1 -1
  270. package/build/store/index.js.map +1 -1
  271. package/build/store/memory.d.ts +12 -0
  272. package/build/store/memory.d.ts.map +1 -1
  273. package/build/store/memory.js +0 -0
  274. package/build/store/memory.js.map +1 -1
  275. package/build/store/types.d.ts +15 -1
  276. package/build/store/types.d.ts.map +1 -1
  277. package/build/store/types.local.d.ts +5 -0
  278. package/build/store/types.local.d.ts.map +1 -0
  279. package/build/store/types.local.js +2 -0
  280. package/build/store/types.local.js.map +1 -0
  281. package/build/types.d.ts +126 -2
  282. package/build/types.d.ts.map +1 -1
  283. package/build/types.local.d.ts +7 -0
  284. package/build/types.local.d.ts.map +1 -0
  285. package/build/types.local.js +2 -0
  286. package/build/types.local.js.map +1 -0
  287. package/build/utils/access/types.d.ts +30 -0
  288. package/build/utils/access/types.d.ts.map +1 -0
  289. package/build/utils/access/types.js +2 -0
  290. package/build/utils/access/types.js.map +1 -0
  291. package/build/utils/access.d.ts +4 -0
  292. package/build/utils/access.d.ts.map +1 -0
  293. package/build/utils/access.js +28 -0
  294. package/build/utils/access.js.map +1 -0
  295. package/build/utils/guard/types.d.ts +23 -0
  296. package/build/utils/guard/types.d.ts.map +1 -0
  297. package/build/utils/guard/types.js +2 -0
  298. package/build/utils/guard/types.js.map +1 -0
  299. package/build/utils/guard.d.ts +7 -10
  300. package/build/utils/guard.d.ts.map +1 -1
  301. package/build/utils/guard.js +36 -32
  302. package/build/utils/guard.js.map +1 -1
  303. package/build/utils/handler/types.d.ts +26 -0
  304. package/build/utils/handler/types.d.ts.map +1 -0
  305. package/build/utils/handler/types.js +2 -0
  306. package/build/utils/handler/types.js.map +1 -0
  307. package/build/utils/handler.d.ts +6 -0
  308. package/build/utils/handler.d.ts.map +1 -0
  309. package/build/utils/handler.js +21 -0
  310. package/build/utils/handler.js.map +1 -0
  311. package/build/utils/index.d.ts +8 -0
  312. package/build/utils/index.d.ts.map +1 -1
  313. package/build/utils/index.js +3 -0
  314. package/build/utils/index.js.map +1 -1
  315. package/build/utils/request/types.d.ts +23 -0
  316. package/build/utils/request/types.d.ts.map +1 -0
  317. package/build/utils/request/types.js +2 -0
  318. package/build/utils/request/types.js.map +1 -0
  319. package/build/utils/request.d.ts +4 -0
  320. package/build/utils/request.d.ts.map +1 -0
  321. package/build/utils/request.js +27 -0
  322. package/build/utils/request.js.map +1 -0
  323. package/build/utils/scope.d.ts +17 -13
  324. package/build/utils/scope.d.ts.map +1 -1
  325. package/build/utils/scope.js +21 -35
  326. package/build/utils/scope.js.map +1 -1
  327. package/build/utils/types.d.ts +8 -0
  328. package/build/utils/types.d.ts.map +1 -0
  329. package/build/utils/types.js +2 -0
  330. package/build/utils/types.js.map +1 -0
  331. package/package.json +30 -22
  332. package/src/actions/apply-schema-request.ts +36 -0
  333. package/src/actions/commit.ts +7 -5
  334. package/src/actions/define-schemas.ts +34 -0
  335. package/src/actions/execute.ts +32 -34
  336. package/src/actions/execution/types.ts +34 -0
  337. package/src/actions/execution.ts +100 -0
  338. package/src/actions/get-card.ts +14 -0
  339. package/src/actions/get-specification.ts +14 -0
  340. package/src/actions/index.ts +13 -3
  341. package/src/actions/links.ts +8 -6
  342. package/src/actions/list-card-specifications.ts +15 -0
  343. package/src/actions/list-card-transitions.ts +15 -0
  344. package/src/actions/list-cards.ts +14 -0
  345. package/src/actions/list-schemas.ts +29 -0
  346. package/src/actions/list-specification-revisions.ts +15 -0
  347. package/src/actions/resources.ts +79 -0
  348. package/src/actions/summarize-cards.ts +15 -0
  349. package/src/actions/transitions.ts +6 -4
  350. package/src/actions/types.ts +5 -0
  351. package/src/actions/watch.ts +11 -7
  352. package/src/conformance/assert/types.ts +16 -0
  353. package/src/conformance/assert.ts +67 -0
  354. package/src/conformance/cases.ts +631 -0
  355. package/src/conformance/clock.ts +11 -0
  356. package/src/conformance/consts.ts +165 -0
  357. package/src/conformance/errors.ts +7 -0
  358. package/src/conformance/fixtures/types.ts +11 -0
  359. package/src/conformance/fixtures.ts +46 -0
  360. package/src/conformance/index.ts +14 -0
  361. package/src/conformance/resources.ts +227 -0
  362. package/src/conformance/types.ts +20 -0
  363. package/src/consts.ts +6 -0
  364. package/src/definitions.ts +264 -0
  365. package/src/executor/changes/types.ts +38 -0
  366. package/src/executor/changes.ts +49 -68
  367. package/src/executor/code/types.ts +23 -0
  368. package/src/executor/code.ts +62 -69
  369. package/src/executor/consts.local.ts +8 -0
  370. package/src/executor/creator/types.ts +33 -0
  371. package/src/executor/creator.ts +43 -0
  372. package/src/executor/resolve/types.ts +30 -0
  373. package/src/executor/resolve.ts +181 -139
  374. package/src/executor/types.ts +23 -0
  375. package/src/executor/validate.ts +40 -38
  376. package/src/executor.ts +33 -27
  377. package/src/facade.ts +132 -29
  378. package/src/helper.ts +12 -11
  379. package/src/hierarchy/types.ts +20 -0
  380. package/src/hierarchy.ts +113 -0
  381. package/src/index.ts +1 -0
  382. package/src/invariants/types.ts +6 -0
  383. package/src/invariants.ts +106 -0
  384. package/src/projection.ts +12 -18
  385. package/src/queue/consts.ts +5 -0
  386. package/src/queue/declare.ts +7 -0
  387. package/src/queue/index.ts +3 -25
  388. package/src/queue/types.ts +14 -0
  389. package/src/registry.ts +18 -36
  390. package/src/resources.ts +256 -0
  391. package/src/service.ts +16 -20
  392. package/src/store/commits.ts +5 -4
  393. package/src/store/composite.ts +7 -2
  394. package/src/store/consts.local.ts +1 -0
  395. package/src/store/fold/types.ts +44 -0
  396. package/src/store/fold.ts +214 -212
  397. package/src/store/index.ts +1 -0
  398. package/src/store/memory.ts +0 -0
  399. package/src/store/types.local.ts +3 -0
  400. package/src/store/types.ts +16 -1
  401. package/src/types.local.ts +7 -0
  402. package/src/types.ts +139 -6
  403. package/src/utils/access/types.ts +30 -0
  404. package/src/utils/access.ts +33 -0
  405. package/src/utils/guard/types.ts +21 -0
  406. package/src/utils/guard.ts +44 -31
  407. package/src/utils/handler/types.ts +28 -0
  408. package/src/utils/handler.ts +35 -0
  409. package/src/utils/index.ts +9 -0
  410. package/src/utils/request/types.ts +23 -0
  411. package/src/utils/request.ts +40 -0
  412. package/src/utils/scope.ts +39 -42
  413. package/src/utils/types.ts +8 -0
  414. package/tests/access.spec.ts +160 -0
  415. package/tests/app.spec.ts +112 -0
  416. package/tests/conformance.spec.ts +47 -0
  417. package/tests/create-example.spec.ts +202 -0
  418. package/tests/creator.spec.ts +257 -0
  419. package/tests/entrypoints.spec.ts +5 -0
  420. package/tests/memory-store.spec.ts +52 -0
  421. package/tests/narrowing.spec.ts +94 -0
  422. package/tests/plugins.spec.ts +4 -3
  423. package/tests/writes.spec.ts +140 -0
  424. package/build/actions/cards.d.ts +0 -16
  425. package/build/actions/cards.d.ts.map +0 -1
  426. package/build/actions/cards.js +0 -32
  427. package/build/actions/cards.js.map +0 -1
  428. package/build/actions/schemas.d.ts +0 -6
  429. package/build/actions/schemas.d.ts.map +0 -1
  430. package/build/actions/schemas.js +0 -9
  431. package/build/actions/schemas.js.map +0 -1
  432. package/build/actions/specs.d.ts +0 -10
  433. package/build/actions/specs.d.ts.map +0 -1
  434. package/build/actions/specs.js +0 -14
  435. package/build/actions/specs.js.map +0 -1
  436. package/src/actions/cards.ts +0 -52
  437. package/src/actions/schemas.ts +0 -15
  438. package/src/actions/specs.ts +0 -23
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: executor
3
+ description: The transition executor step by step (refusal order, actor and createdBy stamping) and the plugin seam (registration, order, store routing, before/after hooks).
4
+ metadata:
5
+ purposes: planning, server-api
6
+ mentions: executeTransition, creatorHelper, makePluginRegistry, ensurePlanningService, PlanningRefused, mintCode, WorkcardConflict
7
+ ---
8
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
9
+
10
+ # @owlmeans/server-planning — The executor and the plugin seam
11
+
12
+ ## The executor, step by step
13
+
14
+ Nothing is appended before step 11 — every refusal leaves the log untouched.
15
+
16
+ 1. **Normalize** — deep copy, trimmed text, `parents ∋ parent` (first); a create's draft without
17
+ `createdBy` gets `creatorHelper.creatorOf(scope)` (below).
18
+ 2. **Scope** — `entityId` must be present.
19
+ 3. **Idempotency** — a `key` already in the entity's log answers ITS receipt, before any
20
+ validation or middleware.
21
+ 4. **Resolve** — the card (`WorkcardNotFound`; another entity's card is `PlanningScopeMismatch`;
22
+ one outside the scope's `projects` is `WorkcardNotFound`), its type and flow, every draft parent
23
+ (`ParentNotFound` — loaded through the facade, so an invisible parent is absent) and the parent
24
+ project's `cardTypes`/`projectTypes` (`CardTypeNotAllowed`), the specification slot. Where the
25
+ default store holds data-defined schemas, the card's project is found first and everything
26
+ after reads that project's resolved layer (`Resolved.schemas`): a data-defined type of a
27
+ project with `scopedCardTypes` is admitted, a retired type creates nothing
28
+ (`UnknownWorkcardType('retired:…')`). Without the port `Resolved.schemas` IS the code registry.
29
+ 5. **`before` chain** — in plugin order; re-resolved once when it changed the card, type or parent.
30
+ 6. **Validate** — shape (`planning:malformed:*`), the flow rule (`IllegalTransition`), immutables
31
+ (`planning:immutable:*`, `createdBy` among them — `creatorHelper.assertCreatorFixed`), merged `fields` against the
32
+ type's `fieldsSchema` — its own `fields` plus the app's base card fields (`FieldsInvalid`; the fold re-checks it), labels (`LabelNotAllowed`), a moved
33
+ parent, the slot (`SpecificationSlotUnknown`, `SpecificationRevisionConflict`, JSON body schema
34
+ → `FieldsInvalid`), relationships (`RelationshipRefused`: undeclared type, `from` not the card,
35
+ missing target, type constraints, `single`, unlinking an absent edge).
36
+ 7. **Card id** — `store.newId?.() ?? options.ids?.() ?? idHelper.uuid()`. Ids are the store's.
37
+ 8. **Code** — a supplied code is checked; else the plugins' `mintCode` (first answer wins, checked);
38
+ else the type's `CodePolicy` (a slug policy derives from the title) → `CodeTaken`.
39
+ 9. **Changes** — `changesHelper.computeChanges`. An `update` that changes nothing answers the card's latest
40
+ receipt and appends nothing.
41
+ 10. **Seq** — `transitions.nextSeq(card, expectSeq)`, a CAS against `head` (`WorkcardConflict`).
42
+ 11. **Append** — `commit: pending`. A lost race on the key answers the winner's receipt.
43
+ 12. **Project** — `store.cards.project(card)`: a sync store folds now, a queued one enqueues.
44
+ 13. **Receipt** — `{ transition, card? (once committed), committed(opts) }`.
45
+ 14. **`wait: true`** — `committed()` before returning (`CommitTimeout`, `CommitFailed`).
46
+
47
+ `actor` is the SCOPE's: `profileId`/`userId`/`service`/`channel` come from the scope only; an
48
+ in-process caller may add `agent`/`runId` on the execution. A handler never passes a wire `actor`.
49
+
50
+ A create's `createdBy` is the scope's subject too — `creatorHelper.creatorOf(scope)`: `profileId`, else `userId`,
51
+ else the same two of `scope.actor`. The executor stamps it on every path, so an in-process facade
52
+ create and the HTTP `execute` produce the same owner. An in-process draft that names `createdBy`
53
+ keeps it (explicit wins — a manager creating on someone's behalf); a scope naming nobody (a service
54
+ or system scope) leaves it unset; the wire drops a draft's `createdBy` before the stamp.
55
+
56
+ `createdBy` never moves after the create (the rule is `planning` → The record model). The executor
57
+ enforces it itself with `creatorHelper.assertCreatorFixed` at step 6, after the `before` chain, so a wire body, an
58
+ in-process caller and a plugin are refused alike, whatever `@owlmeans/planning` build the host
59
+ resolves. The conformance suite checks a store folds a stored row naming it as the pure fold does.
60
+
61
+ ## The plugin seam
62
+
63
+ | Concern | Rule |
64
+ |---|---|
65
+ | Registration | `use(plugin)` replaces by `name`; schemas are contributed at `use` time (later type/flow id wins); `schemas.app` is re-merged from the service's own and every registered plugin's in plugin order on each `use` (`appSchemaHelper.merge`) — a malformed one refuses the plugin (`SchemaInvalid`) and changes nothing |
66
+ | Order | `order ?? 50` ascending, registration order among equals |
67
+ | Store routing | `store(type)` = the first plugin whose `owns(type)` is true AND that supplies a `store`; else the default store. A store factory is resolved once |
68
+ | Reads | By id: the default store, then each owned store. A list naming one owned type (or several owned by one store) goes there; any other list — a cross-type query — is the default store's alone |
69
+ | `mintCode` | First non-`undefined` answer wins |
70
+ | `before` | Every plugin in order; may return a replaced execution; a `ResilientError` passes through, anything else becomes `PlanningRefused('<plugin>:<message>')` |
71
+ | `after` | Every plugin in order, once per COMMITTED transition; errors logged, never rethrown |
72
+
73
+ **Where `after` runs.** The service's `committed(event)` runs the chain, and it is called by the
74
+ process that FOLDS the transition — the memory store inside `project()`, a queued store's projection
75
+ job after marking the commit. Never subscribe a process to the commit bus to run hooks: that fires
76
+ once per subscribed process. Every process that folds registers the same plugins; each commit is
77
+ folded by one of them, so each hook fires once. `hooks: false` makes a process fold without running
78
+ them. A hook sees `ctx.transition` (read back, so `actor.channel` is available) and a facade scoped
79
+ to the event's entity acting as this process's `cfg.service`.
80
+
81
+ The service hands `committed` to a store through `store.bind?.(listener)` the first time it resolves
82
+ the store; `bind` replaces the listener, so a store has exactly one.
@@ -0,0 +1,26 @@
1
+ ---
2
+ name: schemas
3
+ description: Data-defined card types and flows — the resolved layer per organization and project, the facade's definitions, retiring a flow.
4
+ metadata:
5
+ purposes: data, planning, config
6
+ mentions: makeDefinitions, makeSchemaViews, schemasFor, scopedSchemaHelper, definitions, SchemaInUse
7
+ ---
8
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
9
+
10
+ # @owlmeans/server-planning — Data-defined types and flows
11
+
12
+ ## Data-defined types and flows
13
+
14
+ Where the default store has the schema port, `runtime.schemasFor(entityId, project?)` answers the
15
+ resolved layer (`scopedSchemaHelper.resolveScopedBundle` over the code bundle and the organization's and project's
16
+ records), cached per (organization, project) and keyed by the store's `revision()` and the plugin
17
+ registry's version — a write anywhere moves the revision the next lookup reads, so a cached layer is
18
+ never stale; a store's `watch` evicts early. Without the port it answers the code registry itself.
19
+ `makeDefinitions` gives the facade `definitions`: every write checks the project (a project card the
20
+ scope can see), the seal, the closed-form checks (a type's flows resolve in its layer, counting flows
21
+ written beside it; a type's and a flow's `app` bag against the code registry's `app()`), then the
22
+ store's compare-and-set. A layer's registry carries the code declarations, so a data-defined card
23
+ type validates the app's base card fields too. `retire` of a flow refuses with `SchemaInUse`
24
+ while a live type of the layer — or of any project layer, for an organization record — still runs
25
+ it. `facade.model(card)` builds over the layer of the card's own project, and `schema.list` answers
26
+ the scoped bundle (`?project=`) where `definitions` exists, the code bundle otherwise.
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: serving
3
+ description: The commit feed, request scope and security, the access resolver (projects, writes, grants), and mounting the handlers in a target.
4
+ metadata:
5
+ purposes: server-api, auth, planning
6
+ mentions: servePlanningEntrypoints, planningHandlerOf, PlanningAccessResolver, makeRequestScope, makePlanningAccessModel, guardHelper, executionHelper, PlanningForbidden
7
+ ---
8
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
9
+
10
+ # @owlmeans/server-planning — Serving the protocol tree
11
+
12
+ ## The commit feed
13
+
14
+ - **Poll** — `commit.get` answers the status; with `?wait=<s>` (clamped to `maxPoll`, default 55)
15
+ it subscribes, re-polls, and holds until the commit settles or the time is up, answering `pending`
16
+ then — never an error.
17
+ - **Notify** — `commit.events` pushes `planning-commit` frames (or `opts.event`) filtered by the
18
+ authenticated entity and optional `project`/`card` query values; a frame without `record` gets the
19
+ card as it reads now. The subscription is released on the socket's `close` frame.
20
+ - `execute` with `wait: true` holds at most `maxPoll` seconds whatever `timeout` the body asked for.
21
+
22
+ ## Scope and security
23
+
24
+ - Without `opts.access`: `entityId` is `makeEntityScope(req).requireEntityKey()`; `opts.scope(req, ctx)` adds a
25
+ `channel` or `service` and can never replace the entity. `actor` and a create's `createdBy` come
26
+ from the request, never the body (`executionHelper.wireExecution` drops a draft's claim, `creatorHelper.withCreator` stamps the
27
+ subject, `creatorHelper.assertCreatorFixed` refuses a body naming `createdBy` — an update never re-owns a card).
28
+ - The organization of a scope is the one the request ACTS IN. `makeEntityScope(req).requireEntityKey()` answers
29
+ `req.entity.id`, the stable record id (the token's `entitySlug` only where no entity resolver is
30
+ registered). Behind an OIDC relying party (`@owlmeans/server-oidc-rp`) the acting organization is
31
+ session state: the guard attaches `req.entity` with `id` = the organization claim's frozen
32
+ `entityKey`, so the tenant key survives a rename and follows a switch. Take it in the handler and
33
+ pass it down; never read it from the context or from a body.
34
+ - Another entity's card, specification or transition answers `WorkcardNotFound` — the same as an
35
+ absent id — on reads and writes alike (`guardHelper.concealed`).
36
+ - Queries arrive in their wire form and are decoded with `wireHelper.decode*Query` before `queryHelper.criteriaOf`, which
37
+ always adds the scope's `entityId`.
38
+
39
+ ### The access resolver
40
+
41
+ `opts.access: (req, ctx) => Promise<{ entityId, projects?, writes?, grants? }>` is the hosting app's
42
+ decision per request; a throw is the request's answer (an `AuthForbidden` answers 403).
43
+
44
+ - `entityId` is the resolver's — never the token's, never `opts.scope`'s.
45
+ - `projects` becomes `PlanningScope.projects`, which the server facade enforces on reads and
46
+ writes. A card is visible when at least one project reached through its recursive parent paths
47
+ is allowed; specifications follow their containing cards. Anything else reads as absent
48
+ (`WorkcardNotFound`, `null`, an empty list); a create under an invisible parent is
49
+ `ParentNotFound`. Links, transitions and commits use current endpoint/card ancestry, with a
50
+ cached project fallback only for purged records. Subscriptions and commit waits enforce the
51
+ same visibility.
52
+ - **Narrowed lists, counts and summaries use the allowed recursive descendant IDs before paging.**
53
+ A specification is admitted through the same containing-card hierarchy as a single read.
54
+ Do not replace this with a direct-parent query or a filter applied after pagination.
55
+ `tests/narrowing.spec.ts` and shared hierarchy conformance pin this behavior.
56
+ - A person who may see only SOME projects of their organization (a tool-shed volunteer given one
57
+ shed) is expressed here: the resolver answers the project ids the person's grants list as
58
+ `projects`, and omits the key when a grant covers every project — never a hand-written filter in
59
+ each handler.
60
+ - `writes` is the subset of projects the person may WRITE in (`projects` are the ones they VIEW).
61
+ `execute` on a card, specification or link needs it to be writable — the recursive ancestor
62
+ rule over `writes`: a card admitted directly or through a writable parent path. A create needs
63
+ every named parent writable; reparenting checks every supplied destination parent. A create at the root
64
+ (no parent, not a project) is refused. `schema.define` of a project layer needs the project in
65
+ `writes`. A refusal is `PlanningForbidden` (403, `forbidden:writes:<id>`), checked before the grants
66
+ and before the executor. NOT governed by it: a project create (`grants.createProjects` alone) and
67
+ the organization layer (`grants.defineSchemas`). A card the scope cannot see is still answered
68
+ as absent by the executor. Omitted — every visible project is writable.
69
+ `tests/writes.spec.ts` pins viewer, writer and omitted.
70
+ - `grants` gates the stock handlers' writes: `createProjects` (a project create — `true` for the
71
+ root, a list names the parent projects), `deleteProjects` (the delete of a project card — a list
72
+ names the projects), `defineSchemas` (`schema.define` — `true` for the organization's layer, a
73
+ list names project layers). A `grants` object refuses every flag it leaves out with
74
+ `PlanningForbidden` (403); no `grants` gates nothing. In-process facade writes are not gated.
75
+
76
+ ## Mounting in a target
77
+
78
+ The api half of the target mount (the common tree and the kit literals: `planning` → Mounting in a
79
+ target, its `mounting` part).
80
+
81
+ - Bind `servePlanningEntrypoints(tree, { access })` WITHOUT the commit socket —
82
+ `.filter(entrypoint => entrypoint.protocol !== tree.commit.events)`: nothing authenticates a
83
+ target's socket after it opens, so the client long-polls (`commit.get` with `wait`, `execute`
84
+ with `wait: true`). Never write card, transition or schema routes beside it.
85
+ - The resolver maps container permissions onto the access: `projects` = the containers the person
86
+ may view, `writes` = those they may modify, `grants` = `createProjects` / `deleteProjects` /
87
+ `defineSchemas` from their create and admin rights. A creator sees what they created — stamp
88
+ ownership in a `before` hook and add the card to both lists.
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: stores
3
+ description: The in-memory store, writing a durable or foreign store (ports, foldHelper.foldPending, the commit hub, the conformance suite), and testing against the memory store.
4
+ metadata:
5
+ purposes: data, planning, test
6
+ mentions: makeMemoryPlanningStore, PlanningStore, foldHelper, makeCommitHub, makeCompositeStore, planningConformance, conformanceCasesFor, planningConformancePlugin, makeProjectionProcessor, @owlmeans/server-planning/store, @owlmeans/server-planning/conformance
7
+ ---
8
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
9
+
10
+ # @owlmeans/server-planning — Stores
11
+
12
+ ## The memory store
13
+
14
+ `makeMemoryPlanningStore({ sync?, ids?, now?, seed?, onCommitted?, alias?, schemas? })`
15
+
16
+ - Cards and projects in one map, specifications in their own, relationships in a third; every read
17
+ goes through the `@owlmeans/resource` query engine. A card list includes specifications only when
18
+ the criteria asks for `kind: specification` or a `category` (`wantsSpecifications`, the rule every
19
+ store routes by).
20
+ - `schemas: true` adds the data-defined schema port (records per layer, a revision per
21
+ organization, synchronous `watch`); off by default — without it every type and flow resolves
22
+ from code.
23
+ - `sync` (default) folds, publishes and runs `committed` inside `project()`, serialized per card.
24
+ `sync: false` folds nothing until `flush(card?)` — a queued store's shape, for tests that need a
25
+ commit to stay pending.
26
+ - A project `delete` purges the project, everything whose `parents` reach it, their specifications,
27
+ links and log; the commit hub remembers the settled event so the waiter still gets its answer.
28
+ - Any other `delete` folds as `cards.drop`: the card, its comments and mentions, and its own
29
+ documents (specifications whose primary parent is it, transitively) with their links, comments,
30
+ mentions and log. The card's own log stays — its delete row is the tombstone.
31
+ - **It is wrong for more than one process or a restart** — the log, the cards and the commit feed
32
+ are this process's heap. Use it for tests, tools and single-process demos.
33
+
34
+ ## Writing a durable store
35
+
36
+ - Implement `PlanningStore` (`transitions`, `cards`, `specs`, `links`, `commits`, `newId`). `newId`
37
+ answers the id format the host's references need (ObjectId hex for Mongo).
38
+ - `transitions.list` treats `sinceSeq` as `seq > sinceSeq`; `nextSeq` is the CAS against `head` and
39
+ answers 1 for a card that has no log.
40
+ - The projection body is `foldHelper.foldPending(store, cardId, entityId, { onCommitted, publish, touch, limit })`:
41
+ it applies pending transitions with `applyHelper.applyTransition` only, marks each committed or failed,
42
+ publishes, then runs `onCommitted`. The caller owns single flight per card. Strip `record` from
43
+ the event before a cross-process bus.
44
+ - **A failed transition never blocks the card.** The fold marks it `failed`, publishes a failed
45
+ event, and goes PAST it: the card's `seq` advances to that transition with every other value as
46
+ it was, and the next transition folds normally. Without that, every later transition fails as
47
+ out of order and the card is stuck for good. Only two cases stop short: a failed `create` leaves
48
+ no card to advance, and a store that refuses the advancing write stops the fold with `followUp`,
49
+ leaving the rest pending for a retry. `foldHelper.revisionsFromLog` replays past failed transitions the same
50
+ way.
51
+ - A transactional store passes `FoldOptions.unit` — it wraps each transition's writes (a
52
+ savepoint), so a write the database refuses is undone whole and the fold marks that transition
53
+ failed and goes past it. `foldHelper.foldPending` folds PAST a failure it produces; a row that is ALREADY
54
+ failed at the cursor, or a gap in the seqs, is the store's to step over before calling it
55
+ (`planning-postgres` does it in a prelude).
56
+ - `foldHelper.failPending` is what a dead projection job must do, or waiters hang to their timeout.
57
+ - `cards.drop(id, entityId)` is the fold of a non-project `delete` and takes the record's own
58
+ documents with it (the `ProjectionStore.drop` contract): the executor admits a delete whose only
59
+ descendants are those documents, so a store that leaves them behind orphans them. The
60
+ conformance case `deletes a card with its own documents and refuses one with a child card` pins it.
61
+ - The data-defined schema port (`schemas`) is optional; `makeCompositeStore` passes the default
62
+ store's through. A store that has it must purge a project's layer with the project.
63
+ - **Run the conformance suite.** `@owlmeans/server-planning/conformance` exports
64
+ `planningConformance` — named cases with no test runner inside (each throws
65
+ `ConformanceFailure`) — and `conformanceCasesFor(store)`, which drops the data-defined cases for a
66
+ store without the port. Boot a service with `planningConformancePlugin` and `conformanceClock()`
67
+ and hand each case `{ service, store, facade }`; every case works in its own organization, so one
68
+ boot serves them all. A case that needs extra declarations `use`s a plugin on `service` and
69
+ replaces it by name with an empty one when it ends (`CONFORMANCE_APP_PLUGIN`: a stored layer
70
+ keeps a definition's `app` bag inside `definition` and a card's base fields inside `fields`) —
71
+ the cases run in order on one service, never concurrently.
72
+ - `makeCommitHub({ status, remember?, ladder? })` is the `CommitSource`: feed `publish` from the bus,
73
+ answer `status` from transition rows. `wait` subscribes first, polls once, then climbs the ladder.
74
+ - `foldHelper.revisionsFromLog(transitions, limit?)` answers `specs.revisions`.
75
+ - `makeProjectionProcessor(ctx)` + `makePlanningQueueHooks(ctx)` are the store-agnostic job body and
76
+ `onJobDead`; a store with an admission CAS wraps its own around them.
77
+
78
+ ## A foreign provider
79
+
80
+ Only `cards` is required. A plugin that `owns` its types and supplies a store without
81
+ `transitions` can be read through the facade; writes to it refuse with `PlanningUnsupported` —
82
+ mapping external records (`mappers`) belongs to that plugin's own store adapter.
83
+
84
+ ## Testing
85
+
86
+ Category A. Build one real context with `makeBasicContext` + `appendPlanningService({ store:
87
+ makeMemoryPlanningStore({ now }), plugins: [fixtures] })`, and run a handler through
88
+ `handler.bind({ ref: { ctx } })(req, res)` with a request carrying `auth` and `entity`. A monotonic
89
+ `now` keeps log order deterministic; `sync: false` + `flush()` pins pending and hook-count cases.
90
+ `tests/conformance.spec.ts` runs the conformance suite against the memory store with and without
91
+ `schemas: true`; a durable store's own tests run the same cases against a real database.
@@ -0,0 +1,8 @@
1
+ import { type PlanningDefinitions, type SchemaDefineReply, type SchemaDefineRequest } from '@owlmeans/planning';
2
+ /**
3
+ * Apply one `schema.define` request to a facade's definitions: the declarations in the request's
4
+ * mode (flows before types), then the retirements — answering what was written and the layer as it
5
+ * resolves afterwards.
6
+ */
7
+ export declare const applySchemaRequest: (definitions: PlanningDefinitions, request: SchemaDefineRequest) => Promise<SchemaDefineReply>;
8
+ //# sourceMappingURL=apply-schema-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-schema-request.d.ts","sourceRoot":"","sources":["../../src/actions/apply-schema-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAA2B,MAAM,oBAAoB,CAAA;AAEzJ;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,gBAChB,mBAAmB,WAAW,mBAAmB,KAC7D,OAAO,CAAC,iBAAiB,CA0B3B,CAAA"}
@@ -0,0 +1,33 @@
1
+ import { SchemaWriteMode } from '@owlmeans/planning';
2
+ /**
3
+ * Apply one `schema.define` request to a facade's definitions: the declarations in the request's
4
+ * mode (flows before types), then the retirements — answering what was written and the layer as it
5
+ * resolves afterwards.
6
+ */
7
+ export const applySchemaRequest = async (definitions, request) => {
8
+ const layer = request.project != null ? { project: request.project } : {};
9
+ const declarations = { types: request.types ?? [], flows: request.flows ?? [], assigneeTypes: request.assigneeTypes ?? [] };
10
+ const records = [];
11
+ switch (request.mode ?? SchemaWriteMode.Define) {
12
+ case SchemaWriteMode.Put:
13
+ for (const schema of declarations.assigneeTypes)
14
+ records.push(await definitions.putAssigneeType(schema));
15
+ for (const flow of declarations.flows) {
16
+ records.push(await definitions.putFlow(flow, layer));
17
+ }
18
+ for (const type of declarations.types) {
19
+ records.push(await definitions.putType(type, layer));
20
+ }
21
+ break;
22
+ case SchemaWriteMode.Seed:
23
+ records.push(...await definitions.seed(declarations, layer));
24
+ break;
25
+ default:
26
+ records.push(...await definitions.define(declarations, layer));
27
+ }
28
+ for (const key of request.retire ?? []) {
29
+ records.push(await definitions.retire(key.kind, key.key, layer));
30
+ }
31
+ return { records, bundle: await definitions.bundle(request.project) };
32
+ };
33
+ //# sourceMappingURL=apply-schema-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-schema-request.js","sourceRoot":"","sources":["../../src/actions/apply-schema-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAuG,MAAM,oBAAoB,CAAA;AAEzJ;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EACrC,WAAgC,EAAE,OAA4B,EAClC,EAAE;IAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACzE,MAAM,YAAY,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,aAAa,EAAE,O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,EAAE,CAAA;AACvE,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import { handlers } from '@owlmeans/server-api';
2
1
  import type { PlanningProtocols } from '@owlmeans/planning';
3
- import type { Context, PlanningHandlerOptions } from '../types.js';
2
+ import type { PlanningHandlerOptions } from '../types.js';
3
+ import type { RequestHandler } from './types.js';
4
4
  /**
5
5
  * The poll tool: a commit's status, held open up to `wait` seconds (clamped to `maxPoll`).
6
6
  *
@@ -10,5 +10,5 @@ import type { Context, PlanningHandlerOptions } from '../types.js';
10
10
  *
11
11
  * @throws {WorkcardNotFound} for another entity's transition
12
12
  */
13
- export declare const getCommit: (protocol: PlanningProtocols['commit']['get'], opts?: PlanningHandlerOptions) => ReturnType<ReturnType<typeof handlers<Context>>['request']>;
13
+ export declare const getCommit: (protocol: PlanningProtocols['commit']['get'], opts?: PlanningHandlerOptions) => RequestHandler;
14
14
  //# sourceMappingURL=commit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../src/actions/commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAGlE;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,aACV,iBAAiB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,SAAS,sBAAsB,KAC1E,UAAU,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAqCxD,CAAA"}
1
+ {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../src/actions/commit.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAgB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,KAAK,EAAW,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAGlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,aACV,iBAAiB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,SAAS,sBAAsB,KAC1E,cAqCE,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { handlers } from '@owlmeans/server-api';
2
2
  import { CommitState, MAX_COMMIT_POLL } from '@owlmeans/planning';
3
- import { clampSeconds, concealed, handlerFacade } from '../utils/index.js';
3
+ import { guardHelper } from '../utils/guard.js';
4
+ import { planningHandlerOf } from '../utils/handler.js';
4
5
  /**
5
6
  * The poll tool: a commit's status, held open up to `wait` seconds (clamped to `maxPoll`).
6
7
  *
@@ -10,11 +11,11 @@ import { clampSeconds, concealed, handlerFacade } from '../utils/index.js';
10
11
  *
11
12
  * @throws {WorkcardNotFound} for another entity's transition
12
13
  */
13
- export const getCommit = (protocol, opts) => handlers().request(protocol, async (req, ctx) => concealed(async () => {
14
- const facade = await handlerFacade(ctx, req, opts);
14
+ export const getCommit = (protocol, opts) => handlers().request(protocol, async (req, ctx) => guardHelper.reply(async () => {
15
+ const facade = await planningHandlerOf(ctx).handlerFacade(req, opts);
15
16
  const transition = `${req.params.transition}`;
16
17
  let status = await facade.commits.status(transition);
17
- const wait = clampSeconds(req.query?.wait, opts?.maxPoll ?? MAX_COMMIT_POLL);
18
+ const wait = guardHelper.clampSeconds(req.query?.wait, opts?.maxPoll ?? MAX_COMMIT_POLL);
18
19
  if (status.state !== CommitState.Pending || wait <= 0) {
19
20
  return status;
20
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"commit.js","sourceRoot":"","sources":["../../src/actions/commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAGjE,OAAO,EAAE,YAAY,EAAE,S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AM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;YAAS,CAAC;QACT,WAAW,EAAE,CAAA;IACf,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAC,CAAC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { type PlanningProtocols } from '@owlmeans/planning';
2
+ import type { PlanningHandlerOptions } from '../types.js';
3
+ import type { RequestHandler } from './types.js';
4
+ /**
5
+ * The write of data-defined types and flows. A project layer needs the project in the access's
6
+ * `writes` when the resolver answers it; then `grants.defineSchemas` gates when the resolver answers
7
+ * grants (the organization-wide layer needs `true`, a project layer its id).
8
+ *
9
+ * @throws {PlanningUnsupported} where the store holds no data-defined schemas
10
+ * @throws {PlanningForbidden | SchemaConflict | SchemaSealed | SchemaInvalid | SchemaInUse | WorkcardNotFound}
11
+ */
12
+ export declare const defineSchemas: (protocol: NonNullable<PlanningProtocols['schema']['define']>, opts?: PlanningHandlerOptions) => RequestHandler;
13
+ //# sourceMappingURL=define-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-schemas.d.ts","sourceRoot":"","sources":["../../src/actions/define-schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,iBAAiB,EAAoD,MAAM,oBAAoB,CAAA;AAClI,OAAO,KAAK,EAAW,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAKlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,aACd,WAAW,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,CAAC,SAAS,sBAAsB,KAC1F,cAcE,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { handlers } from '@owlmeans/server-api';
2
+ import { PlanningUnsupported } from '@owlmeans/planning';
3
+ import { makePlanningAccessModel } from '../utils/access.js';
4
+ import { guardHelper } from '../utils/guard.js';
5
+ import { planningHandlerOf } from '../utils/handler.js';
6
+ import { applySchemaRequest } from './apply-schema-request.js';
7
+ /**
8
+ * The write of data-defined types and flows. A project layer needs the project in the access's
9
+ * `writes` when the resolver answers it; then `grants.defineSchemas` gates when the resolver answers
10
+ * grants (the organization-wide layer needs `true`, a project layer its id).
11
+ *
12
+ * @throws {PlanningUnsupported} where the store holds no data-defined schemas
13
+ * @throws {PlanningForbidden | SchemaConflict | SchemaSealed | SchemaInvalid | SchemaInUse | WorkcardNotFound}
14
+ */
15
+ export const defineSchemas = (protocol, opts) => handlers().request(protocol, async (req, ctx) => guardHelper.reply(async () => {
16
+ const { facade, access } = await planningHandlerOf(ctx).handlerScopeOf(req, opts);
17
+ const request = (req.body ?? {});
18
+ if (facade.definitions == null) {
19
+ throw new PlanningUnsupported('definitions');
20
+ }
21
+ const model = makePlanningAccessModel(access);
22
+ if (request.project != null) {
23
+ model.assertWrites(request.project);
24
+ }
25
+ model.assertGranted('defineSchemas', request.project);
26
+ return await applySchemaRequest(facade.definitions, request);
27
+ }));
28
+ //# sourceMappingURL=define-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-schemas.js","sourceRoot":"","sources":["../../src/actions/define-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAA4E,MAAM,oBAAoB,CAAA;AAElI,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAG9D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,QAA4D,EAAE,IAA6B,EAC3E,EAAE,CAClB,QAAQ,EAAW,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,IAAgC,EAAE;IACjH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,iBAAiB,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACjF,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAwB,CAAA;IACvD,IAAI,MAAM,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,IAAI,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAC9C,CAAC;IACD,MAAM,KAAK,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAA;IAC7C,IAAI,OAAO,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QAC5B,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IACD,KAAK,CAAC,aAAa,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;IAErD,OAAO,MAAM,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC9D,CAAC,CAAC,CAAC,CAAA"}
@@ -1,13 +1,14 @@
1
- import { handlers } from '@owlmeans/server-api';
2
- import type { ExecuteOptions, ExecuteRequest, PlanningProtocols, PlanningScope, TransitionExecution } from '@owlmeans/planning';
3
- import type { Context, PlanningHandlerOptions } from '../types.js';
4
- /**
5
- * What a wire execution may say. `actor` is dropped — the scope names the writer — and a create's
6
- * `createdBy` is the authenticated subject, whatever the body claimed.
7
- */
1
+ import type { ExecuteOptions, ExecuteRequest, PlanningFacade, PlanningProtocols, PlanningScope, TransitionExecution } from '@owlmeans/planning';
2
+ import type { PlanningAccess, PlanningHandlerOptions } from '../types.js';
3
+ import type { RequestHandler } from './types.js';
4
+ /** The one write route. */
5
+ export declare const executePlanning: (protocol: PlanningProtocols['execute'], opts?: PlanningHandlerOptions) => RequestHandler;
6
+ /** @deprecated compat:factory-refactor — use `executionHelper.wireExecution(…)` */
8
7
  export declare const wireExecution: (body: ExecuteRequest, scope: PlanningScope) => TransitionExecution;
9
- /** `wait`/`timeout` as a server grants them: the timeout never holds a request past `maxPoll`. */
8
+ /** @deprecated compat:factory-refactor — use `executionHelper.executeOptionsOf(…)` */
10
9
  export declare const executeOptionsOf: (body: Pick<ExecuteRequest, 'wait' | 'timeout'>, maxPoll: number) => ExecuteOptions;
11
- /** The one write route. */
12
- export declare const executePlanning: (protocol: PlanningProtocols['execute'], opts?: PlanningHandlerOptions) => ReturnType<ReturnType<typeof handlers<Context>>['request']>;
10
+ /** @deprecated compat:factory-refactor — use `executionHelper.assertExecutionWrites(…)` */
11
+ export declare const assertExecutionWrites: (facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess) => Promise<void>;
12
+ /** @deprecated compat:factory-refactor — use `executionHelper.assertExecutionGranted(…)` */
13
+ export declare const assertExecutionGranted: (facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess) => Promise<void>;
13
14
  //# sourceMappingURL=execute.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/actions/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C,OAAO,KAAK,EACV,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EACtF,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAGlE;;;GAGG;AACH,eAAO,MAAM,aAAa,SAAU,cAAc,SAAS,aAAa,KAAG,mBAQ1E,CAAA;AAED,kGAAkG;AAClG,eAAO,MAAM,gBAAgB,SAAU,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC,WAAW,MAAM,KAAG,cAOlG,CAAA;AAED,2BAA2B;AAC3B,eAAO,MAAM,eAAe,aAChB,iBAAiB,CAAC,SAAS,CAAC,SAAS,sBAAsB,KACpE,UAAU,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAWxD,CAAA"}
1
+ {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/actions/execute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,mBAAmB,EAEtG,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAW,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAIlF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD,2BAA2B;AAC3B,eAAO,MAAM,eAAe,aAChB,iBAAiB,CAAC,SAAS,CAAC,SAAS,sBAAsB,KACpE,cAWE,CAAA;AAEL,mFAAmF;AACnF,eAAO,MAAM,aAAa,SAAU,cAAc,SAAS,aAAa,KAAG,mBAC/B,CAAA;AAE5C,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,SAAU,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC,WAAW,MAAM,KAAG,cAClD,CAAA;AAEjD,2FAA2F;AAC3F,eAAO,MAAM,qBAAqB,WACxB,cAAc,QAAQ,mBAAmB,WAAW,cAAc,KACzE,OAAO,CAAC,IAAI,CAAsE,CAAA;AAErF,4FAA4F;AAC5F,eAAO,MAAM,sBAAsB,WACzB,cAAc,QAAQ,mBAAmB,WAAW,cAAc,KACzE,OAAO,CAAC,IAAI,CAAuE,CAAA"}
@@ -1,35 +1,25 @@
1
1
  import { handlers } from '@owlmeans/server-api';
2
- import { DEFAULT_COMMIT_TIMEOUT, MAX_COMMIT_POLL, TransitionAction } from '@owlmeans/planning';
3
- import { concealed, handlerFacade } from '../utils/index.js';
4
- /**
5
- * What a wire execution may say. `actor` is dropped — the scope names the writer — and a create's
6
- * `createdBy` is the authenticated subject, whatever the body claimed.
7
- */
8
- export const wireExecution = (body, scope) => {
9
- const { wait: _wait, timeout: _timeout, actor: _actor, ...exec } = body;
10
- if (exec.action === TransitionAction.Create && exec.card != null && typeof exec.card === 'object') {
11
- const { createdBy: _createdBy, ...draft } = exec.card;
12
- const subject = scope.profileId ?? scope.userId;
13
- exec.card = subject != null ? { ...draft, createdBy: subject } : draft;
14
- }
15
- return exec;
16
- };
17
- /** `wait`/`timeout` as a server grants them: the timeout never holds a request past `maxPoll`. */
18
- export const executeOptionsOf = (body, maxPoll) => {
19
- const ceiling = maxPoll * 1000;
20
- if (body.wait !== true) {
21
- return {};
22
- }
23
- const asked = Number(body.timeout ?? DEFAULT_COMMIT_TIMEOUT);
24
- return { wait: true, timeout: Math.min(Number.isFinite(asked) && asked > 0 ? asked : DEFAULT_COMMIT_TIMEOUT, ceiling) };
25
- };
2
+ import { MAX_COMMIT_POLL } from '@owlmeans/planning';
3
+ import { guardHelper } from '../utils/guard.js';
4
+ import { planningHandlerOf } from '../utils/handler.js';
5
+ import { executionHelper } from './execution.js';
26
6
  /** The one write route. */
27
- export const executePlanning = (protocol, opts) => handlers().request(protocol, async (req, ctx) => concealed(async () => {
28
- const facade = await handlerFacade(ctx, req, opts);
7
+ export const executePlanning = (protocol, opts) => handlers().request(protocol, async (req, ctx) => guardHelper.reply(async () => {
8
+ const { facade, access } = await planningHandlerOf(ctx).handlerScopeOf(req, opts);
29
9
  const body = (req.body ?? {});
30
- const receipt = await facade.execute(wireExecution(body, facade.scope), executeOptionsOf(body, opts?.maxPoll ?? MAX_COMMIT_POLL));
10
+ const exec = executionHelper.wireExecution(body, facade.scope);
11
+ await executionHelper.assertExecutionGranted(facade, exec, access);
12
+ const receipt = await facade.execute(exec, executionHelper.executeOptionsOf(body, opts?.maxPoll ?? MAX_COMMIT_POLL));
31
13
  return receipt.card !== undefined
32
14
  ? { transition: receipt.transition, card: receipt.card }
33
15
  : { transition: receipt.transition };
34
16
  }));
17
+ /** @deprecated compat:factory-refactor — use `executionHelper.wireExecution(…)` */
18
+ export const wireExecution = (body, scope) => executionHelper.wireExecution(body, scope);
19
+ /** @deprecated compat:factory-refactor — use `executionHelper.executeOptionsOf(…)` */
20
+ export const executeOptionsOf = (body, maxPoll) => executionHelper.executeOptionsOf(body, maxPoll);
21
+ /** @deprecated compat:factory-refactor — use `executionHelper.assertExecutionWrites(…)` */
22
+ export const assertExecutionWrites = async (facade, exec, access) => await executionHelper.assertExecutionWrites(facade, exec, access);
23
+ /** @deprecated compat:factory-refactor — use `executionHelper.assertExecutionGranted(…)` */
24
+ export const assertExecutionGranted = async (facade, exec, access) => await executionHelper.assertExecutionGranted(facade, exec, access);
35
25
  //# sourceMappingURL=execute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"execute.js","sourceRoot":"","sources":["../../src/actions/execute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK9F,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAoB,EAAE,KAAoB,EAAuB,EAAE;IAC/F,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;IACvE,IAAI,IAAI,CAAC,MAAM,KAAK,gBAAgB,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAClG,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,CAAA;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anningFacade, PlanningScope, TransitionExecution } from '@owlmeans/planning';
2
+ import type { PlanningAccess } from '../../types.js';
3
+ /** What a wire execution may say, how long it may hold, and what access it needs. */
4
+ export interface ExecutionHelper {
5
+ /**
6
+ * What a wire execution may say. `actor` is dropped — the scope names the writer — and a create's
7
+ * `createdBy` claim is dropped too: the executor's `creatorHelper.withCreator` stamps the
8
+ * authenticated subject, the same rule an in-process create follows. Applied here as well, so the
9
+ * returned execution already carries it. A `createdBy` in `changes` or `unset` is not dropped: the
10
+ * executor refuses it on every action (`assertCreatorFixed`), so no body moves an owner.
11
+ */
12
+ wireExecution: (body: ExecuteRequest, scope: PlanningScope) => TransitionExecution;
13
+ /** `wait`/`timeout` as a server grants them: the timeout never holds a request past `maxPoll`. */
14
+ executeOptionsOf: (body: Pick<ExecuteRequest, 'wait' | 'timeout'>, maxPoll: number) => ExecuteOptions;
15
+ /**
16
+ * Refuse an execution outside the access's `writes`: the card it acts on (a specification through
17
+ * its parent card), or every parent a create names, must be one `writableIn` admits. A create
18
+ * of a project is `grants.createProjects`' alone. A card or parent this scope cannot see is left to
19
+ * the executor, which answers it as absent.
20
+ *
21
+ * @throws {PlanningForbidden}
22
+ */
23
+ assertExecutionWrites: (facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess) => Promise<void>;
24
+ /**
25
+ * The access a wire execution needs. `writes` first ({@link ExecutionHelper.assertExecutionWrites});
26
+ * then the grants: `createProjects` for a project create (its primary parent, or the root),
27
+ * `deleteProjects` for the delete of a project card. A card this scope cannot see is left to the
28
+ * executor, which answers it as absent.
29
+ *
30
+ * @throws {PlanningForbidden}
31
+ */
32
+ assertExecutionGranted: (facade: PlanningFacade, exec: TransitionExecution, access?: PlanningAccess) => Promise<void>;
33
+ }
34
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actions/execution/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC5H,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,aAAa,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,KAAK,mBAAmB,CAAA;IAClF,kGAAkG;IAClG,gBAAgB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,KAAK,cAAc,CAAA;IACrG;;;;;;;OAOG;IACH,qBAAqB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpH;;;;;;;OAOG;IACH,sBAAsB,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtH"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map