@kern0x1b/penstock-cli 26.11.1 → 26.11.2

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 (302) hide show
  1. package/THIRD-PARTY-NOTICES.md +16 -16
  2. package/dist/chunk-account-BaYNvO18.js +1 -0
  3. package/dist/{chunk-agentLaunch-D21uPuMr.js → chunk-agentLaunch-BnrpVME4.js} +1 -1
  4. package/dist/chunk-agentServe-BeOh1rjE.js +10 -0
  5. package/dist/chunk-agents-CZJoU2u2.js +1 -0
  6. package/dist/chunk-agentsMigrate-DnrqoXNz.js +2 -0
  7. package/dist/{chunk-analyze-BG-rlggA.js → chunk-analyze-ClE2LBCj.js} +1 -1
  8. package/dist/chunk-analyze-DgQqzEgb.js +1 -0
  9. package/dist/{chunk-analyzeFlow-2cYPgjh-.js → chunk-analyzeFlow-F2ZFmJhv.js} +1 -1
  10. package/dist/chunk-apiTemplates-Cl_z63FA.js +1 -0
  11. package/dist/{chunk-bot-DlhStBoG.js → chunk-bot-C2k8yaXA.js} +5 -5
  12. package/dist/chunk-cmmnFindings-DKpYqUZN.js +1 -0
  13. package/dist/{chunk-codeFactSet-LxSnQy8K.js → chunk-codeFactSet-DiAYqvbb.js} +1 -1
  14. package/dist/{chunk-codeIndex-N1gnP_sW.js → chunk-codeIndex-vStNh6Bm.js} +1 -1
  15. package/dist/chunk-codeLinks-BVpn4_Sr.js +1 -0
  16. package/dist/chunk-codeLinks-BrGduhsm.js +1 -0
  17. package/dist/chunk-command-8s6m3ZUw.js +5 -0
  18. package/dist/chunk-command-aMxPQdiV.js +1 -0
  19. package/dist/chunk-command-vH1_y5F0.js +1 -0
  20. package/dist/chunk-commands-B8YVT41b.js +5 -0
  21. package/dist/{chunk-commands-DcjlDt7B.js → chunk-commands-CJCSznbv.js} +1 -1
  22. package/dist/chunk-compose-BUJTvoFX.js +4 -0
  23. package/dist/chunk-connections-Drr67X9U.js +1 -0
  24. package/dist/chunk-connectors-DcMqy0u8.js +1 -0
  25. package/dist/chunk-convert-Ce1MZmsE.js +3 -0
  26. package/dist/chunk-convert-FkMnlxyi.js +1 -0
  27. package/dist/chunk-deploy-BHg8pB9x.js +1 -0
  28. package/dist/chunk-deploy-DZgCTgaY.js +6 -0
  29. package/dist/{chunk-diagrams-BukAOL0g.js → chunk-diagrams-CtGMGTa8.js} +1 -1
  30. package/dist/chunk-diff-9hjavV6V.js +1 -0
  31. package/dist/chunk-diff-Dp3fUALc.js +1 -0
  32. package/dist/chunk-dispatch-o-eqJb9Y.js +7 -0
  33. package/dist/chunk-dmnTests-BOxutoRs.js +1 -0
  34. package/dist/{chunk-dmnTests-ChwX1YVo.js → chunk-dmnTests-BzNA-u2k.js} +1 -1
  35. package/dist/{chunk-docs-D7yEDpa4.js → chunk-docs-B3C3pZpY.js} +17 -17
  36. package/dist/chunk-doctor-CRxbsAm7.js +1 -0
  37. package/dist/{chunk-editPreview-CC2vwhIW.js → chunk-editPreview-DCUnMkTU.js} +1 -1
  38. package/dist/chunk-evidence-ny_2ltVe.js +23 -0
  39. package/dist/{chunk-examples-0HkF-frb.js → chunk-examples-BG0lGXcZ.js} +9 -9
  40. package/dist/chunk-export-Blwjf23H.js +1 -0
  41. package/dist/chunk-export-kt3sBTZu.js +20 -0
  42. package/dist/{chunk-facts-DSVaURw5.js → chunk-facts-Dl5lLriU.js} +1 -1
  43. package/dist/chunk-failure-BRyRvObj.js +1 -0
  44. package/dist/{chunk-file-BswMa3FN.js → chunk-file-1YhfNmPn.js} +1 -1
  45. package/dist/chunk-import-Dh3az4BC.js +6 -0
  46. package/dist/chunk-importCommand-Dhikkmo0.js +1 -0
  47. package/dist/chunk-incident-LJe2-ohi.js +1 -0
  48. package/dist/chunk-init-D34Q4YA8.js +227 -0
  49. package/dist/chunk-lint-CnEhoYRB.js +1 -0
  50. package/dist/{chunk-lsp-7vA_mIt1.js → chunk-lsp-BzeJkpmf.js} +1 -1
  51. package/dist/chunk-main-BZF-ErAx.js +1 -0
  52. package/dist/chunk-mcp-B_B9bet5.js +95 -0
  53. package/dist/{chunk-mcpLaunch-LyfmIF_Z.js → chunk-mcpLaunch-BS709697.js} +1 -1
  54. package/dist/chunk-migrate-DVfXC-iJ.js +1 -0
  55. package/dist/chunk-migrate-DwWg0k5_.js +16 -0
  56. package/dist/{chunk-migrateApply-CzOkgKhB.js → chunk-migrateApply-e8O9oZXP.js} +3 -3
  57. package/dist/chunk-migrateVerify-oIBf-PM3.js +1 -0
  58. package/dist/{chunk-model-f8AzYUK7.js → chunk-model-BulEKnY1.js} +2 -2
  59. package/dist/{chunk-parse-B-uKGDy-.js → chunk-parse-DiOcpdOU.js} +1 -1
  60. package/dist/{chunk-penstockCli-CKMvaZ0O.js → chunk-penstockCli-C41P_G7i.js} +1 -1
  61. package/dist/chunk-policy-BVb7c7G_.js +1 -0
  62. package/dist/chunk-policyGate-BOgKsqLq.js +2 -0
  63. package/dist/chunk-pr-1jKcTNnP.js +1 -0
  64. package/dist/{chunk-project-DBYOlYRi.js → chunk-project-COaBZhMt.js} +1 -1
  65. package/dist/chunk-project-lO_6DX8G.js +1 -0
  66. package/dist/chunk-promotion-CTMPjXjZ.js +2 -0
  67. package/dist/chunk-promotion-DDLrgBqZ.js +1 -0
  68. package/dist/{chunk-promotion-DchO6xoC.js → chunk-promotion-NeRj4uTP.js} +1 -1
  69. package/dist/chunk-receipt-C4NqnSkH.js +1 -0
  70. package/dist/chunk-receiptDeps-B7MehyHT.js +1 -0
  71. package/dist/chunk-receiptGate-BZCKCMTV.js +1 -0
  72. package/dist/chunk-receiptGate-DRcw327y.js +1 -0
  73. package/dist/{chunk-receiptSnapshot-B6ruXw8z.js → chunk-receiptSnapshot-CHSk3_4N.js} +1 -1
  74. package/dist/{chunk-receiptStore-Cy-L0H1u.js → chunk-receiptStore-DhROtI2h.js} +1 -1
  75. package/dist/chunk-refactor-CO3qyIEv.js +17 -0
  76. package/dist/chunk-refactor-CWeCOl7w.js +1 -0
  77. package/dist/{chunk-render-Ci5d6mg4.js → chunk-render-DZd5hScS.js} +1 -1
  78. package/dist/chunk-report-w7YZwhyg.js +1 -0
  79. package/dist/chunk-review-DYMgFDSy.js +1 -0
  80. package/dist/chunk-say-CP1IyOSv.js +1 -0
  81. package/dist/{chunk-security-VgKwtohm.js → chunk-security-pgip-kdY.js} +2 -2
  82. package/dist/chunk-serve-CKt2rO05.js +10 -0
  83. package/dist/{chunk-share-CBV2FuKq.js → chunk-share-rsL0itIM.js} +18 -18
  84. package/dist/chunk-stages-B2sBBxUc.js +3 -0
  85. package/dist/chunk-systemError-O3vQ8hLb.js +1 -0
  86. package/dist/chunk-systemError-n2E6isvg.js +1 -0
  87. package/dist/chunk-taskTest-DWoME1mY.js +2 -0
  88. package/dist/chunk-taskTest-JErgWO6t.js +1 -0
  89. package/dist/{chunk-templateDiagnostics-BwH7RNkz.js → chunk-templateDiagnostics-6txfKwas.js} +2 -2
  90. package/dist/chunk-templates-Y3xfCO_3.js +1 -0
  91. package/dist/chunk-testCases-BwimUfDC.js +4 -0
  92. package/dist/chunk-testCases-DO2Rkyvd.js +1 -0
  93. package/dist/chunk-tests-Cy325OGw.js +1 -0
  94. package/dist/chunk-tests-DNkORsqB.js +23 -0
  95. package/dist/{chunk-trust-DXcsUJaK.js → chunk-trust-DSX-k3by.js} +1 -1
  96. package/dist/{chunk-trust-DubjEjlN.js → chunk-trust-Di4EYPah.js} +1 -1
  97. package/dist/{chunk-variableChecks-KnECGMR3.js → chunk-variableChecks-CBDpmI4d.js} +1 -1
  98. package/dist/{chunk-workerVariables-CajAcbwl.js → chunk-workerVariables-CNnCRijJ.js} +1 -1
  99. package/dist/{chunk-workerVariables-DIDoUpHF.js → chunk-workerVariables-CulLc3YH.js} +1 -1
  100. package/dist/chunk-wrapper-CGYED7G2.js +1 -0
  101. package/dist/chunk-wrapper-CK7Xtes6.js +3 -0
  102. package/dist/grammars/web-tree-sitter.wasm +0 -0
  103. package/dist/penstock.js +1 -1
  104. package/dist/web/assets/{AgentSettings-Cn5Vcph3.js → AgentSettings-D24jOuht.js} +1 -1
  105. package/dist/web/assets/{AgentsDialog-C6WqzlxZ.js → AgentsDialog-BMWv3Gyk.js} +1 -1
  106. package/dist/web/assets/{AgentsDialog-dpbwVSxk.js → AgentsDialog-DbY2O6O5.js} +1 -1
  107. package/dist/web/assets/{AgentsTab-C34OhVkw.js → AgentsTab-D6LbK6sG.js} +2 -2
  108. package/dist/web/assets/{BpmnCanvas-yur9daZa.js → BpmnCanvas-BcQRQ2Br.js} +27 -27
  109. package/dist/web/assets/BpmnDocument-Ce5F4K1e.js +27 -0
  110. package/dist/web/assets/CmmnDocument-C_UlPowC.js +17 -0
  111. package/dist/web/assets/{ConflictDialog-Bb5kduaR.js → ConflictDialog-DfFp8F7n.js} +1 -1
  112. package/dist/web/assets/{ConnectionsDialog-qtF7yDFw.js → ConnectionsDialog-BaYtHD5h.js} +1 -1
  113. package/dist/web/assets/{DiffDocument-LHOif5Ac.js → DiffDocument-BOPdBEN3.js} +1 -1
  114. package/dist/web/assets/{DmnDocument-0f5uS67x.css → DmnDocument-DZ9u2uk2.css} +1 -1
  115. package/dist/web/assets/DmnDocument-vtnARy7Q.js +41 -0
  116. package/dist/web/assets/{DriftDialog-Chl6BX6k.js → DriftDialog-dIbCbSK2.js} +1 -1
  117. package/dist/web/assets/FormDocument-B0q8DF9v.css +1 -0
  118. package/dist/web/assets/FormDocument-DHBUBUzO.js +32 -0
  119. package/dist/web/assets/FormStepView-CbHb32_8.js +1 -0
  120. package/dist/web/assets/{GraphAwareLayoutService-wsos3yPD.js → GraphAwareLayoutService-C5N8K9dm.js} +1 -1
  121. package/dist/web/assets/{MigrationDialog-CBJU7Oe3.js → MigrationDialog-DA3Vrzgw.js} +1 -1
  122. package/dist/web/assets/{NewFileDialog-B7075LWG.js → NewFileDialog-Dev41oA1.js} +1 -1
  123. package/dist/web/assets/PolicyDialog-qR19Csji.js +1 -0
  124. package/dist/web/assets/{QuickOpen-DJQrI7Od.js → QuickOpen-ps-rMjiS.js} +1 -1
  125. package/dist/web/assets/ScriptPane-BQLMNYzc.js +2 -0
  126. package/dist/web/assets/{ScriptRunDialog-BwE4cXnp.js → ScriptRunDialog-YivjHB6j.js} +1 -1
  127. package/dist/web/assets/{SettingsDialog-c307wPsg.js → SettingsDialog-DI0vZ6Ay.js} +1 -1
  128. package/dist/web/assets/ShortcutsDialog-DLXnv4Vm.js +1 -0
  129. package/dist/web/assets/SourceDocument-Cj8cGsoS.js +1 -0
  130. package/dist/web/assets/TemplateDocument-BRyFsofH.js +7 -0
  131. package/dist/web/assets/TextDocument-DB2hEuMA.js +1 -0
  132. package/dist/web/assets/{UnreadableFileLayer-CUP_30X8.js → UnreadableFileLayer-CRW3MM7w.js} +1 -1
  133. package/dist/web/assets/{UploadDialog-CaVBOxUL.js → UploadDialog-D-X6GG98.js} +1 -1
  134. package/dist/web/assets/Viewer-BcpDlvg_.js +4 -0
  135. package/dist/web/assets/apply-Nsj6ek02.js +1 -0
  136. package/dist/web/assets/{bpmnTheme-CZ7xp4R5.js → bpmnTheme-pKgl9Mrn.js} +2 -2
  137. package/dist/web/assets/{data-ZauKnQ2Z.js → data-CdiToGOq.js} +2 -2
  138. package/dist/web/assets/{data-Da5Nxzev.js → data-wU6sw6RY.js} +1 -1
  139. package/dist/web/assets/{dialog-DSLu1Bbo.js → dialog-BDJ5dDiU.js} +1 -1
  140. package/dist/web/assets/{diff-C4hitkRR.js → diff-BhYqTg4l.js} +1 -1
  141. package/dist/web/assets/dist-27z6Phtg.js +23 -0
  142. package/dist/web/assets/{dist-CofBTWz1.js → dist-B7TL-7R3.js} +4 -4
  143. package/dist/web/assets/dist-BEpeEbIu.js +1 -0
  144. package/dist/web/assets/{dist-CYCbBoYQ.js → dist-BTf7NfeQ.js} +1 -1
  145. package/dist/web/assets/{dist-CJKVV2_S.js → dist-BqGv7f4M.js} +10 -10
  146. package/dist/web/assets/dist-C-q1IWjr.js +6 -0
  147. package/dist/web/assets/{dist-Blylfrak.js → dist-CJx_2eBF.js} +2 -2
  148. package/dist/web/assets/dist-COUY_jv5.js +1 -0
  149. package/dist/web/assets/{dist-DpDu6Wz_.js → dist-CWjAtsKe.js} +1 -1
  150. package/dist/web/assets/{dist-gb3IfUZi.js → dist-Cv8_A_95.js} +2 -2
  151. package/dist/web/assets/dist-DDE6BjgI.js +5 -0
  152. package/dist/web/assets/{dist-7VC_hKpw.js → dist-DDNYYQtV.js} +1 -1
  153. package/dist/web/assets/dist-DW-S9iZN.js +1 -0
  154. package/dist/web/assets/dist-OnU5n5o1.js +1 -0
  155. package/dist/web/assets/dmn-Cgoh6wXm.js +3 -0
  156. package/dist/web/assets/{documentBridge-1Eg7H9yI.js → documentBridge-CHw4XsZH.js} +3 -3
  157. package/dist/web/assets/{documents-LG-7CTrn.js → documents-CEtohzAC.js} +1 -1
  158. package/dist/web/assets/duplicate-D_ic-m62.js +342 -0
  159. package/dist/web/assets/{engines-DhO6OW1S.js → engines-lyEvb0pH.js} +1 -1
  160. package/dist/web/assets/{executable-BTarDLry.js → executable--4381_Lf.js} +1 -1
  161. package/dist/web/assets/{file-CIeVSOHy.js → file-BbVBUuIH.js} +1 -1
  162. package/dist/web/assets/formChecks-CSClH9sH.js +1 -0
  163. package/dist/web/assets/frontend-uXAWaalt.js +1 -0
  164. package/dist/web/assets/{httpHost-DBSjdVth.js → httpHost-C973OTRe.js} +1 -1
  165. package/dist/web/assets/{index.es-pigASDxC.js → index.es-CMvq8Bhe.js} +3 -3
  166. package/dist/web/assets/index.es-GbdJvMnO.js +78 -0
  167. package/dist/web/assets/{index.esm-CTLpq4ik.js → index.esm-Ba6q0zSu.js} +1 -1
  168. package/dist/web/assets/{intelligence-_1C71hkQ.js → intelligence-DNqJNmdB.js} +3 -3
  169. package/dist/web/assets/{jspdf.es.min-PgZzOmkT.js → jspdf.es.min-C0L4zezU.js} +6 -6
  170. package/dist/web/assets/{kind-X3_nabTt.js → kind-DDHnk6dW.js} +1 -1
  171. package/dist/web/assets/{lib-BmLAen_d.js → lib-DrkEMJ65.js} +1 -1
  172. package/dist/web/assets/{list-DovB9lWV.js → list-TmXvCwja.js} +1 -1
  173. package/dist/web/assets/{migrationHost-BcguK4K5.js → migrationHost-DCWBb3L6.js} +1 -1
  174. package/dist/web/assets/moddle-f0Q4Guwd.js +1 -0
  175. package/dist/web/assets/{model--Bj28IOj.js → model-afHgSxJs.js} +1 -1
  176. package/dist/web/assets/{nudges-UF9_cBuO.js → nudges-DPG3WpyV.js} +1 -1
  177. package/dist/web/assets/{open-C9Kt9JLw.js → open-Vkx72dYx.js} +1 -1
  178. package/dist/web/assets/platform-G53Cenyw.js +2 -0
  179. package/dist/web/assets/{preload-helper-VRuDKI9K.js → preload-helper-DExCAR_V.js} +1 -1
  180. package/dist/web/assets/{run-BZgz1U9U.js → run-BMfRBe5O.js} +1 -1
  181. package/dist/web/assets/samples-BL3jA_Vd.js +1 -0
  182. package/dist/web/assets/{say-WvEHqIbO.js → say-BkdZMivA.js} +1 -1
  183. package/dist/web/assets/{say-ChFGKK2E.js → say-C7KqKcFr.js} +1 -1
  184. package/dist/web/assets/{sections-N6WYk7b8.js → sections-LJKSRDTS.js} +1 -1
  185. package/dist/web/assets/sharedReader-BsXfiBT8.js +1 -0
  186. package/dist/web/assets/{source-frame-DcptKpVq.js → source-frame-DC4W0A5-.js} +2 -2
  187. package/dist/web/assets/{syntax-DW10Wzg4.js → syntax-00Hk6Xv7.js} +4 -4
  188. package/dist/web/assets/{template-CMl68jPp.js → template-BQP7ZXdK.js} +1 -1
  189. package/dist/web/assets/testCaseRuns-liAhWMg7.js +1 -0
  190. package/dist/web/assets/{trace-DLziNpe2.js → trace-DXQU2N_l.js} +1 -1
  191. package/dist/web/assets/{translator-DLDFsUlE.js → translator-BLCeE6UY.js} +1 -1
  192. package/dist/web/assets/ui-BLtm3Y1J.js +1 -0
  193. package/dist/web/assets/{useTrace-UYBskc2k.js → useTrace-dZdQ805W.js} +1 -1
  194. package/dist/web/assets/web-C4k0NLZ9.js +982 -0
  195. package/dist/web/assets/web-CnDpD6qy.css +1 -0
  196. package/dist/web/assets/{workerVariables-DURgyUbG.js → workerVariables-O6VqwDzr.js} +1 -1
  197. package/dist/web/assets/xml-DIWt4von.js +1 -0
  198. package/dist/web/index.html +39 -40
  199. package/package.json +5 -5
  200. package/dist/chunk-account-CpZu-RTg.js +0 -1
  201. package/dist/chunk-agentServe-BYRtgGGD.js +0 -10
  202. package/dist/chunk-agents-B9oxdPTA.js +0 -1
  203. package/dist/chunk-agentsMigrate-BV8TeRXq.js +0 -2
  204. package/dist/chunk-analyze-pgzR-Cx-.js +0 -1
  205. package/dist/chunk-apiTemplates-cU7C8vap.js +0 -1
  206. package/dist/chunk-cmmnFindings-S2TGSnEp.js +0 -1
  207. package/dist/chunk-codeLinks-C8N6e8k3.js +0 -1
  208. package/dist/chunk-codeLinks-o0a8tBGk.js +0 -1
  209. package/dist/chunk-command-Bqlbgo-2.js +0 -1
  210. package/dist/chunk-command-DT84ioJb.js +0 -5
  211. package/dist/chunk-command-DrGP2kg8.js +0 -1
  212. package/dist/chunk-commands-B4PoZbpX.js +0 -5
  213. package/dist/chunk-compose-CWKKVtN5.js +0 -4
  214. package/dist/chunk-connections-DQpKbIGD.js +0 -1
  215. package/dist/chunk-connectors-PtAvE91B.js +0 -1
  216. package/dist/chunk-convert-CpgtOlZk.js +0 -1
  217. package/dist/chunk-convert-HbFpg8ab.js +0 -3
  218. package/dist/chunk-deploy-l4MdFfn8.js +0 -6
  219. package/dist/chunk-deploy-qRaaKGZb.js +0 -1
  220. package/dist/chunk-diff-BhTFlCE3.js +0 -1
  221. package/dist/chunk-diff-kBF83vzM.js +0 -1
  222. package/dist/chunk-dispatch-BnO-QhMh.js +0 -7
  223. package/dist/chunk-dmnTests-0x_yUH6S.js +0 -1
  224. package/dist/chunk-doctor-BuHK1dTm.js +0 -1
  225. package/dist/chunk-evidence-oLw_C6j8.js +0 -23
  226. package/dist/chunk-export-cIFHDXug.js +0 -1
  227. package/dist/chunk-export-jBVxtmCH.js +0 -20
  228. package/dist/chunk-failure-D5brrYW2.js +0 -1
  229. package/dist/chunk-import-BBOe-5RZ.js +0 -6
  230. package/dist/chunk-importCommand-DRjYoljA.js +0 -1
  231. package/dist/chunk-incident-BK1h37CD.js +0 -1
  232. package/dist/chunk-init-_OALJuKm.js +0 -227
  233. package/dist/chunk-lint-7KJFxyCN.js +0 -1
  234. package/dist/chunk-main-Cw2JXCil.js +0 -1
  235. package/dist/chunk-mcp-K63bhqnF.js +0 -95
  236. package/dist/chunk-migrate-BMwBV5sc.js +0 -16
  237. package/dist/chunk-migrate-CxfVmKt0.js +0 -1
  238. package/dist/chunk-migrateVerify-DSEXSpfR.js +0 -1
  239. package/dist/chunk-policy-BX0Ftdws.js +0 -1
  240. package/dist/chunk-policyGate-dmcufnwB.js +0 -2
  241. package/dist/chunk-pr-ByrGcfam.js +0 -1
  242. package/dist/chunk-project-DA3KnAZH.js +0 -1
  243. package/dist/chunk-promotion-Boedyq43.js +0 -1
  244. package/dist/chunk-promotion-D8Ti-vxp.js +0 -2
  245. package/dist/chunk-receipt-CusJaqNn.js +0 -1
  246. package/dist/chunk-receiptDeps-oVbX156d.js +0 -1
  247. package/dist/chunk-receiptGate-DrGChj7i.js +0 -1
  248. package/dist/chunk-receiptGate-xldHKMyJ.js +0 -1
  249. package/dist/chunk-refactor-B1W_MGTp.js +0 -1
  250. package/dist/chunk-refactor-BJXxEtVs.js +0 -17
  251. package/dist/chunk-report-D9pM09Nu.js +0 -1
  252. package/dist/chunk-review-UcqS5AAi.js +0 -1
  253. package/dist/chunk-say-CYb4HeJD.js +0 -1
  254. package/dist/chunk-serve-Dmqen1yd.js +0 -10
  255. package/dist/chunk-stages-BTQJrAMF.js +0 -3
  256. package/dist/chunk-systemError-BYrMzp2o.js +0 -1
  257. package/dist/chunk-systemError-CXvnhNPK.js +0 -1
  258. package/dist/chunk-taskTest-9gMsx0zu.js +0 -2
  259. package/dist/chunk-taskTest-BjXYpG5p.js +0 -1
  260. package/dist/chunk-templates-D3ouIwHD.js +0 -1
  261. package/dist/chunk-testCases-9jwT_Y7z.js +0 -4
  262. package/dist/chunk-testCases-BcpBPg9L.js +0 -1
  263. package/dist/chunk-tests-CEEXnWOp.js +0 -23
  264. package/dist/chunk-tests-CRVosdWp.js +0 -1
  265. package/dist/chunk-wrapper-B2WnOIoB.js +0 -3
  266. package/dist/chunk-wrapper-DiKCKZti.js +0 -1
  267. package/dist/web/assets/BpmnDocument-C247Rqim.js +0 -27
  268. package/dist/web/assets/CmmnDocument-Dj48bsUd.js +0 -17
  269. package/dist/web/assets/DmnDocument-Cb9Zi9fS.js +0 -41
  270. package/dist/web/assets/FormDocument-DoZaxWd-.js +0 -32
  271. package/dist/web/assets/FormDocument-URLcKn84.css +0 -1
  272. package/dist/web/assets/FormStepView-D8MFcpeI.js +0 -1
  273. package/dist/web/assets/PolicyDialog-CGdglmDn.js +0 -1
  274. package/dist/web/assets/ScriptPane-T6M5f6fc.js +0 -2
  275. package/dist/web/assets/ShortcutsDialog-BAoL9EHu.js +0 -1
  276. package/dist/web/assets/SourceDocument-C9KIzBA5.js +0 -1
  277. package/dist/web/assets/TemplateDocument-CNt2turg.js +0 -7
  278. package/dist/web/assets/TextDocument-CtkHoEqN.js +0 -1
  279. package/dist/web/assets/Viewer-DZske1C5.js +0 -4
  280. package/dist/web/assets/apply-nnKP9HIM.js +0 -1
  281. package/dist/web/assets/dist--PmHUHDp.js +0 -1
  282. package/dist/web/assets/dist-BoPrKCf2.js +0 -5
  283. package/dist/web/assets/dist-C1m02xAO.js +0 -1
  284. package/dist/web/assets/dist-CLqJMzT-.js +0 -1
  285. package/dist/web/assets/dist-D3jqq0XS.js +0 -1
  286. package/dist/web/assets/dist-DA-9F0U9.js +0 -1
  287. package/dist/web/assets/dist-DojzF5q2.js +0 -6
  288. package/dist/web/assets/dist-yvjzrXXf.js +0 -23
  289. package/dist/web/assets/dmn-DwdcYXGr.js +0 -3
  290. package/dist/web/assets/duplicate-D-ilQqKz.js +0 -342
  291. package/dist/web/assets/formChecks-CGox1z7R.js +0 -1
  292. package/dist/web/assets/frontend-Qq5hBH0U.js +0 -1
  293. package/dist/web/assets/index.es-CcNNw3VB.js +0 -78
  294. package/dist/web/assets/moddle-DJxj0oEU.js +0 -1
  295. package/dist/web/assets/platform-BLPhsye9.js +0 -2
  296. package/dist/web/assets/samples-oeXBsJ9Y.js +0 -1
  297. package/dist/web/assets/sharedReader-Bopy7Uk9.js +0 -1
  298. package/dist/web/assets/testCaseRuns-B_XdqGFh.js +0 -1
  299. package/dist/web/assets/ui-BTKMbWYG.js +0 -1
  300. package/dist/web/assets/web-FzNBw1kZ.css +0 -1
  301. package/dist/web/assets/web-jPMZVwbQ.js +0 -982
  302. package/dist/web/assets/xml-DTgZ-B-l.js +0 -1
@@ -1,2 +1,2 @@
1
- import{r as e}from"./chunk-translator-DNm9zRpP.js";import{i as t,n,o as r,r as i}from"./chunk-variables-CXAMjZIR.js";import{a,t as o}from"./chunk-moddle-D3Ym38EZ.js";import{n as s}from"./chunk-unreadableDiagram-CcrctihL.js";import{migrateDiagram as c}from"@bpmn-io/dmn-migrate";const l=[[/spec\/DMN\/20151101\//,`1.1`],[/spec\/DMN\/20180521\//,`1.2`],[/spec\/DMN\/20191111\//,`1.3`],[/spec\/DMN\/20211108\//,`1.4`],[/spec\/DMN\/20230324\//,`1.5`]],u=/<((?:\w+:)?)definitions\b([^>]*)>/;function d(e){let t=u.exec(e);if(!t)return null;let n=t[1].slice(0,-1),r=RegExp(`\\sxmlns${n?`:${n}`:``}\\s*=\\s*["']([^"']*)["']`).exec(t[2]);return r?l.find(([e])=>e.test(r[1]))?.[1]??null:null}async function f(e){let t=d(e);if(t!==`1.1`&&t!==`1.2`)return{xml:e,from:null};try{let n=await c(e);return d(n)===`1.3`?{xml:n,from:t}:{xml:e,from:null}}catch{return{xml:e,from:null}}}function p(t,n){return e(`app.migration.dmn.savedAsNotice`,{name:n,from:t})}var m=class extends Error{line;constructor(t,n){super(n===void 0?t:e(`app.dmn.readErrorAtLine`,{reason:t,line:n})),this.name=`DmnReadError`,this.line=n}};function ee(t){let n=String(t?.warnings?.[0]?.message??t?.message??t),r=/line:\s*(\d+)/.exec(n)?.[1],i=/nested error:\s*(.+)$/m.exec(n)?.[1]?.trim();return i?new m(e(`app.dmn.notValid`,{reason:s(i)}),r===void 0?void 0:Number(r)+1):new m(e(`app.dmn.notADocument`))}const te=/\sid\s*=\s*(["'])(.*?)\1/g;function ne(t){let n=/* @__PURE__ */ new Set;for(let r of t.matchAll(te)){let i=r[2];if(i!==``){if(n.has(i))return new m(e(`app.dmn.duplicateId`,{id:i}),t.slice(0,r.index).split(`
2
- `).length);n.add(i)}}return null}async function h(e){let t=o(`plain`),{xml:n,from:r}=await f(e),i=ne(n);if(i)throw i;try{let{rootElement:e}=await t.fromXML(n,`dmn:Definitions`);return{rootElement:e,xml:n,from:r}}catch(e){throw ee(e)}}const g={"bpmn:MessageEventDefinition":`message`,"bpmn:TimerEventDefinition":`timer`,"bpmn:ErrorEventDefinition":`error`,"bpmn:SignalEventDefinition":`signal`,"bpmn:EscalationEventDefinition":`escalation`,"bpmn:ConditionalEventDefinition":`conditional`};function _(e,t){return e?.extensionElements?.values?.find(e=>e.$type===t)}function v(e,t){try{return e.get?.(t)}catch{return}}function y(e){return typeof e==`string`&&e!==``?e:void 0}function b(e){let t={id:e.id??``,type:e.$type};y(e.name)&&(t.name=e.name);let n=e.eventDefinitions?.[0];if(n){t.event=g[n.$type]??n.$type.replace(`bpmn:`,``),t.message=n.messageRef?.name,t.correlationKey=n.messageRef?_(n.messageRef,`zeebe:Subscription`)?.correlationKey:void 0,t.signal=n.signalRef?.name,t.errorCode=n.errorRef?.errorCode;let e=n.timeDuration?`duration`:n.timeCycle?`cycle`:n.timeDate?`date`:void 0;e&&(t.timerKind=e,t.timer=(n.timeDuration??n.timeCycle??n.timeDate)?.body)}if(e.$type===`bpmn:ReceiveTask`){let n=e.messageRef;t.event=`message`,t.message=n?.name,t.correlationKey=n?_(n,`zeebe:Subscription`)?.correlationKey:void 0}e.attachedToRef&&(t.host=e.attachedToRef.id,t.interrupting=e.cancelActivity!==!1);let r=(e.outgoing??[]).map(e=>e.targetRef?.id).filter(e=>typeof e==`string`);r.length>0&&(t.follows=r),e.loopCharacteristics&&(t.repeats=!0),t.job=_(e,`zeebe:TaskDefinition`)?.type,t.zeebeUserTask=!!_(e,`zeebe:UserTask`),t.calledProcess=_(e,`zeebe:CalledElement`)?.processId??e.calledElement,t.decision=_(e,`zeebe:CalledDecision`)?.decisionId??v(e,`camunda:decisionRef`),t.form=_(e,`zeebe:FormDefinition`)?.formId;let i=y(_(e,`zeebe:CalledDecision`)?.resultVariable)??y(v(e,`camunda:resultVariable`));i&&(t.resultVariable=i);let a=y(v(e,`camunda:formRef`))??y(v(e,`camunda:formKey`))??y(_(e,`zeebe:FormDefinition`)?.formKey);return a&&(t.formKey=a),v(e,`camunda:type`)===`external`&&(t.external=String(v(e,`camunda:topic`)??``)),t.delegateClass=y(v(e,`camunda:class`)),t.delegateExpression=y(v(e,`camunda:delegateExpression`)),t.expression=y(v(e,`camunda:expression`)),t.delegateExpression&&(t.delegateBean=/^[$#]\{\s*([A-Za-z_]\w*)\s*\}$/.exec(t.delegateExpression)?.[1]),t.asyncBefore=v(e,`camunda:asyncBefore`)===!0,t.asyncAfter=v(e,`camunda:asyncAfter`)===!0,t}function x(e,t,n){for(let r of e??[])r?.id&&(n.set(r.id,{...b(r),processId:t}),r.flowElements&&x(r.flowElements,t,n))}function S(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let t of e?.rootElements??[])if(t.$type===`bpmn:Process`&&n.set(t.id,t),t.$type===`bpmn:Collaboration`)for(let e of t.participants??[])e.processRef?.id&&n.set(e.processRef.id,e.processRef);return n.forEach((e,n)=>x(e.flowElements,n,t)),t}function C(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=[];for(let t of e?.rootElements??[])if(t.$type===`bpmn:Process`&&r.push(t),t.$type===`bpmn:Collaboration`)for(let e of t.participants??[])e.processRef&&r.push(e.processRef);let i=(e,r,a)=>{for(let o of e??[])o.id&&(o.$type===`bpmn:SequenceFlow`?n.set(o.id,{id:o.id,name:o.name?.replace(/\s+/g,` `).trim()??``,condition:o.conditionExpression?.body?.trim()||void 0,source:o.sourceRef?.id??``,target:o.targetRef?.id??``}):(t.set(o.id,{id:o.id,name:o.name?.replace(/\s+/g,` `).trim()??``,type:o.$type,outgoing:[],incoming:[],defaultFlow:o.default?.id??null,process:r,parent:a}),o.flowElements&&i(o.flowElements,r,o.id)))};for(let e of r)i(e.flowElements,e.id??``,null);for(let e of n.values())t.get(e.source)?.outgoing.push(e.id),t.get(e.target)?.incoming.push(e.id);return{nodes:t,flows:n,steps:S(e)}}var w=class extends Map{index;constructor(e){super(),this.index=e}has(e){return this.index.nodes.has(e)}get(e){let t=super.get(e);if(t||!this.index.nodes.has(e))return t;let n=E(this.index,e);return this.set(e,n),n}};function T(e){return new w(C(e))}function E(e,t){let n=/* @__PURE__ */ new Set,r=[t];for(let t=0;t<r.length;t+=1)e.nodes.get(r[t])?.outgoing.forEach(t=>{let i=e.flows.get(t)?.target;i&&!n.has(i)&&(n.add(i),r.push(i))});return n}function D(e){let t=/* @__PURE__ */ new Map;return e.nodes.forEach(e=>{let n=t.get(e.process)??[];n.push(e.id),t.set(e.process,n)}),[...t.values()].flatMap(t=>O(e,t))}function O(e,t){let n=[],r=/* @__PURE__ */ new Set;return t.filter(t=>e.nodes.get(t)?.incoming.length===0).forEach(t=>{r.has(t)||k(e,t,r,n)}),t.forEach(e=>{r.has(e)||(r.add(e),n.push(e))}),n}function k(e,t,n,r){n.add(t),r.push(t);let i=[t];for(let t=0;t<i.length;t+=1)e.nodes.get(i[t])?.outgoing.forEach(t=>{let a=e.flows.get(t)?.target;a&&e.nodes.has(a)&&!n.has(a)&&(n.add(a),r.push(a),i.push(a))})}function A(e,t,n){return t===n?!1:e.get(t)?.has(n)??!1}const re={"camunda:ExecutionListener":`EXECUTION_LISTENER`,"camunda:TaskListener":`TASK_LISTENER`},ie=2**53-1;function j(e){let t=e.split(`:`).pop()??e;return t.charAt(0).toLowerCase()+t.slice(1)}function M(e){return typeof e.name==`string`?e.name.replace(/\s+/g,` `).trim():``}function N(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`?n:void 0}function P(e){let t=e.slice(1);return t.startsWith(` `)?t.slice(1):t}function F(e){if(!e||e.resource)return null;let t=r(e.scriptFormat);return t?{language:t,value:e.value??``}:null}var I=class{drafts=[];names=/* @__PURE__ */ new Map;seq=0;process(e){this.elements(e.flowElements,e.id??``,[])}elements(e,t,n){(e??[]).forEach(e=>{e.id&&(this.names.set(e.id,M(e)),e.$type===`bpmn:SequenceFlow`?this.flow(e,t,n):(this.element(e,t,n),this.elements(e.flowElements,t,[...n,e.id])))})}element(e,t,n){let i=e.id??``,a=j(e.$type);if(e.$type===`bpmn:ScriptTask`){let o=r(e.scriptFormat);o&&this.add(i,`TASK_BODY`,0,{processId:t,containers:n,type:a,language:o,value:typeof e.script==`string`?e.script:``})}let o={};(e.extensionElements?.values??[]).forEach(e=>{let r=re[e.$type];if(!r)return;let s=o[r]??0;o[r]=s+1;let c=F(e.script);c&&this.add(i,r,s,{processId:t,containers:n,type:a,...c,event:e.event})});let s=e.extensionElements?.values?.find(e=>e.$type===`camunda:InputOutput`);[...(s?.inputParameters??[]).map(e=>[e,`input`]),...(s?.outputParameters??[]).map(e=>[e,`output`])].forEach(([e,r],o)=>{let s=F(e.definition);s&&this.add(i,`PARAMETER`,o,{processId:t,containers:n,type:a,...s,parameter:{name:e.name??``,direction:r}})});let c=e.extensionElements?.values?.find(e=>e.$type===`zeebe:IoMapping`),l={processId:t,containers:n,type:a};(c?.inputParameters??[]).forEach((e,t)=>this.mapping(i,`INPUT_MAPPING`,t,e,`input`,l)),(c?.outputParameters??[]).forEach((e,t)=>this.mapping(i,`OUTPUT_MAPPING`,t,e,`output`,l))}mapping(e,t,n,r,i,a){let o=N(r,`source`);o?.startsWith(`=`)&&this.add(e,t,n,{...a,language:`feel`,value:P(o),parameter:{name:N(r,`target`)??``,direction:i}})}flow(e,t,n){let i=e.id??``,a=e.conditionExpression;if(!a)return;let o={source:e.sourceRef?.id??``,target:e.targetRef?.id??``},s={processId:t,containers:n,type:j(e.$type)},c=N(a,`language`);if(c===void 0&&a.body?.startsWith(`=`)){this.add(i,`FEEL_CONDITION`,0,{...s,language:`feel`,value:P(a.body)},o);return}let l=r(c);l&&this.add(i,`CONDITION`,0,{...s,language:l,value:a.body??``},o)}add(e,t,n,r,i=null){this.drafts.push({site:{slot:{elementId:e,owner:t,index:n},...r},ends:i,seq:this.seq+=1})}};function L(e,t){return e.get(t)??ie}function R(e,t){let n=e.site.containers.map(e=>[L(t,e),0]);return e.ends?[...n,[L(t,e.ends.source),1]]:[...n,[L(t,e.site.slot.elementId),0]]}function z(e,t){for(let n=0;n<Math.min(e.length,t.length);n+=1){let[r,i]=e[n],[a,o]=t[n];if(r!==a)return r<a?-1:1;if(i!==o)return i<o?-1:1}return e.length-t.length}function B(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>{e&&t.set(e,(t.get(e)??0)+1)}),t}function V(e,t,n){let r=e.site.slot.elementId,i=e=>t.get(e)||e,a=t.get(r)??``,o=e.ends?a||`${i(e.ends.source)} -> ${i(e.ends.target)}`:i(r),s=a!==``&&(n.get(a)??0)>1;return{...e.site,name:o,shared:s}}function H(e){return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`)}function U(e){let t=new Map(D(C(e)).map((e,t)=>[e,t])),n=new I;H(e).forEach(e=>n.process(e));let r=B(n.names);return n.drafts.map(e=>({draft:e,path:R(e,t)})).sort((e,t)=>z(e.path,t.path)||e.draft.seq-t.draft.seq).map(({draft:e})=>V(e,n.names,r))}const W=/* @__PURE__ */ new Set([`startEvent`,`intermediateCatchEvent`,`boundaryEvent`,`receiveTask`]),G=/^=|\$\{|#\{/,K={"zeebe:ExecutionListeners":`execution`,"zeebe:TaskListeners":`task`};function q(e){let t=/^[$#]\{\s*([A-Za-z_][A-Za-z0-9_]*)/.exec(e.trim());return t?t[1]:null}function J(){return{processes:[],elements:[],workers:[],calls:[],messages:[],messageUses:[],decisions:[],decisionUses:[],formKeys:[],formUses:[],variables:[],variableForms:[],dynamic:[],embeddedForms:[],errors:[],scripts:[]}}function ae(e){let t=e.split(`:`).pop()??e;return t.charAt(0).toLowerCase()+t.slice(1)}function Y(e,t){return typeof t==`string`&&t.trim()?t:e}function X(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`&&n.trim()?n:void 0}function Z(e){return e?.extensionElements?.values??[]}function Q(e,t,n){if(!t?.id)return;let r=ae(t.$type),i=t.id;e.elements.push({id:i,name:t.name,type:r,processId:n,label:Y(i,t.name)});let a=(t,n)=>{t&&(G.test(t)?e.dynamic.push(t):n(t))};a(X(t,`camunda:topic`),t=>e.workers.push({kind:`TOPIC`,value:t,elementId:i})),a(X(t,`camunda:class`),t=>e.workers.push({kind:`JAVA_CLASS`,value:t,elementId:i}));let o=q(X(t,`camunda:delegateExpression`)??``);o&&e.workers.push({kind:`BEAN`,value:o,elementId:i}),a(X(t,`camunda:decisionRef`),t=>e.decisionUses.push({decisionId:t,elementId:i})),a(X(t,`camunda:formRef`),t=>e.formUses.push({formId:t,linked:!0,elementId:i})),a(X(t,`camunda:formKey`),t=>e.formUses.push({formId:t,linked:!1,elementId:i})),a(typeof t.calledElement==`string`?t.calledElement:void 0,t=>e.calls.push({calledProcessId:t,elementId:i})),Z(t).forEach(t=>{switch(t.$type){case`zeebe:TaskDefinition`:a(t.type,t=>e.workers.push({kind:`JOB_TYPE`,value:t,elementId:i}));break;case`zeebe:CalledElement`:a(t.processId,t=>e.calls.push({calledProcessId:t,elementId:i}));break;case`zeebe:CalledDecision`:a(t.decisionId,t=>e.decisionUses.push({decisionId:t,elementId:i}));break;case`zeebe:FormDefinition`:a(t.formId,t=>e.formUses.push({formId:t,linked:!0,elementId:i})),a(t.formKey,t=>e.formUses.push(t.startsWith(`camunda-forms:bpmn:`)?{formId:t.slice(19),linked:!1,embedded:!0,elementId:i}:{formId:t,linked:!1,elementId:i}));break;case`zeebe:ExecutionListeners`:case`zeebe:TaskListeners`:(t.listeners??[]).forEach(n=>a(n.type,n=>{e.workers.push({kind:`JOB_TYPE`,value:n,elementId:i,listener:K[t.$type]})}))}}),(t.eventDefinitions??[]).filter(e=>e.$type===`bpmn:ErrorEventDefinition`).forEach(t=>{let n=typeof t.errorRef?.errorCode==`string`&&t.errorRef.errorCode.trim()?t.errorRef.errorCode:null;n&&G.test(n)?e.dynamic.push(n):e.errors.push({code:n,catches:W.has(r),elementId:i})}),[t.messageRef,...(t.eventDefinitions??[]).map(e=>e.messageRef)].filter(e=>e?.id).forEach(t=>{e.messageUses.push({messageId:t.id,catches:W.has(r),elementId:i})}),(t.flowElements??[]).forEach(t=>Q(e,t,n))}async function oe(e){let n=J(),r=await a(e);if(!r)return n;let i=/* @__PURE__ */ new Map;(r.rootElements??[]).filter(e=>e.$type===`bpmn:Collaboration`).forEach(e=>{(e.participants??[]).forEach(e=>{e.processRef?.id&&e.name&&i.set(e.processRef.id,e.name)})}),(r.rootElements??[]).forEach(e=>{if(e.$type===`bpmn:Message`&&n.messages.push({id:e.id,name:e.name,label:Y(e.id,e.name)}),e.$type!==`bpmn:Process`)return;let t=e.name?.trim()?e.name:i.get(e.id);n.processes.push({id:e.id,name:t,executable:e.isExecutable===!0,label:Y(e.id,t)}),Z(e).filter(e=>e.$type===`zeebe:UserTaskForm`&&e.id).forEach(e=>n.embeddedForms.push(e.id)),(e.flowElements??[]).forEach(t=>Q(n,t,e.id))});let{uses:o,forms:s}=t(r);return n.variables=o,n.variableForms=s,n.scripts=U(r),n}function se(e){return e.decisionLogic?.$type===`dmn:DecisionTable`?(e.decisionLogic.output??[]).map(e=>typeof e.name==`string`?e.name.trim():``).filter(e=>e!==``):[]}async function ce(e){let t=J();try{let{rootElement:n}=await h(e);(n?.drgElement??[]).filter(e=>e.$type===`dmn:Decision`).forEach(e=>{t.decisions.push({id:e.id,name:e.name,type:`decision`,label:Y(e.id,e.name),outputs:se(e)})})}catch{return t}return t}function le(e){let t=J();try{let r=JSON.parse(e);t.formId=n(r),t.formKeys=i(r)}catch{return t}return t}function $(e){let t=e.toLowerCase();return t.endsWith(`.bpmn`)||t.endsWith(`.bpmn.xml`)?`bpmn`:t.endsWith(`.dmn`)?`dmn`:t.endsWith(`.form`)?`form`:null}const ue={bpmn:`BPMN XML`,dmn:`DMN`,form:`JSON`};function de(e){return ue[$(e)??`bpmn`]}async function fe(e,t){switch($(e)){case`bpmn`:return oe(t);case`dmn`:return ce(t);case`form`:return le(t);default:return J()}}export{T as a,b as c,h as d,f,U as i,S as l,$ as n,A as o,p,fe as r,C as s,de as t,m as u};
1
+ import{r as e}from"./chunk-translator-DNm9zRpP.js";import{a as t,t as n}from"./chunk-moddle-D3Ym38EZ.js";import{n as r}from"./chunk-unreadableDiagram-CcrctihL.js";import{i,n as a,o,r as s}from"./chunk-variables-CXAMjZIR.js";import{migrateDiagram as c}from"@bpmn-io/dmn-migrate";const l=[[/spec\/DMN\/20151101\//,`1.1`],[/spec\/DMN\/20180521\//,`1.2`],[/spec\/DMN\/20191111\//,`1.3`],[/spec\/DMN\/20211108\//,`1.4`],[/spec\/DMN\/20230324\//,`1.5`]],u=/<((?:\w+:)?)definitions\b([^>]*)>/;function d(e){let t=u.exec(e);if(!t)return null;let n=t[1].slice(0,-1),r=RegExp(`\\sxmlns${n?`:${n}`:``}\\s*=\\s*["']([^"']*)["']`).exec(t[2]);return r?l.find(([e])=>e.test(r[1]))?.[1]??null:null}async function f(e){let t=d(e);if(t!==`1.1`&&t!==`1.2`)return{xml:e,from:null};try{let n=await c(e);return d(n)===`1.3`?{xml:n,from:t}:{xml:e,from:null}}catch{return{xml:e,from:null}}}function p(t,n){return e(`app.migration.dmn.savedAsNotice`,{name:n,from:t})}var m=class extends Error{line;constructor(t,n){super(n===void 0?t:e(`app.dmn.readErrorAtLine`,{reason:t,line:n})),this.name=`DmnReadError`,this.line=n}};function ee(t){let n=String(t?.warnings?.[0]?.message??t?.message??t),i=/line:\s*(\d+)/.exec(n)?.[1],a=/nested error:\s*(.+)$/m.exec(n)?.[1]?.trim();return a?new m(e(`app.dmn.notValid`,{reason:r(a)}),i===void 0?void 0:Number(i)+1):new m(e(`app.dmn.notADocument`))}const te=/\sid\s*=\s*(["'])(.*?)\1/g;function ne(t){let n=/* @__PURE__ */ new Set;for(let r of t.matchAll(te)){let i=r[2];if(i!==``){if(n.has(i))return new m(e(`app.dmn.duplicateId`,{id:i}),t.slice(0,r.index).split(`
2
+ `).length);n.add(i)}}return null}async function h(e){let t=n(`plain`),{xml:r,from:i}=await f(e),a=ne(r);if(a)throw a;try{let{rootElement:e}=await t.fromXML(r,`dmn:Definitions`);return{rootElement:e,xml:r,from:i}}catch(e){throw ee(e)}}const g={"bpmn:MessageEventDefinition":`message`,"bpmn:TimerEventDefinition":`timer`,"bpmn:ErrorEventDefinition":`error`,"bpmn:SignalEventDefinition":`signal`,"bpmn:EscalationEventDefinition":`escalation`,"bpmn:ConditionalEventDefinition":`conditional`};function _(e,t){return e?.extensionElements?.values?.find(e=>e.$type===t)}function v(e,t){try{return e.get?.(t)}catch{return}}function y(e){return typeof e==`string`&&e!==``?e:void 0}function b(e){let t={id:e.id??``,type:e.$type};y(e.name)&&(t.name=e.name);let n=e.eventDefinitions?.[0];if(n){t.event=g[n.$type]??n.$type.replace(`bpmn:`,``),t.message=n.messageRef?.name,t.correlationKey=n.messageRef?_(n.messageRef,`zeebe:Subscription`)?.correlationKey:void 0,t.signal=n.signalRef?.name,t.errorCode=n.errorRef?.errorCode;let e=n.timeDuration?`duration`:n.timeCycle?`cycle`:n.timeDate?`date`:void 0;e&&(t.timerKind=e,t.timer=(n.timeDuration??n.timeCycle??n.timeDate)?.body)}if(e.$type===`bpmn:ReceiveTask`){let n=e.messageRef;t.event=`message`,t.message=n?.name,t.correlationKey=n?_(n,`zeebe:Subscription`)?.correlationKey:void 0}e.attachedToRef&&(t.host=e.attachedToRef.id,t.interrupting=e.cancelActivity!==!1);let r=(e.outgoing??[]).map(e=>e.targetRef?.id).filter(e=>typeof e==`string`);r.length>0&&(t.follows=r),e.loopCharacteristics&&(t.repeats=!0),t.job=_(e,`zeebe:TaskDefinition`)?.type,t.zeebeUserTask=!!_(e,`zeebe:UserTask`),t.calledProcess=_(e,`zeebe:CalledElement`)?.processId??e.calledElement,t.decision=_(e,`zeebe:CalledDecision`)?.decisionId??v(e,`camunda:decisionRef`),t.form=_(e,`zeebe:FormDefinition`)?.formId;let i=y(_(e,`zeebe:CalledDecision`)?.resultVariable)??y(v(e,`camunda:resultVariable`));i&&(t.resultVariable=i);let a=y(v(e,`camunda:formRef`))??y(v(e,`camunda:formKey`))??y(_(e,`zeebe:FormDefinition`)?.formKey);return a&&(t.formKey=a),v(e,`camunda:type`)===`external`&&(t.external=String(v(e,`camunda:topic`)??``)),t.delegateClass=y(v(e,`camunda:class`)),t.delegateExpression=y(v(e,`camunda:delegateExpression`)),t.expression=y(v(e,`camunda:expression`)),t.delegateExpression&&(t.delegateBean=/^[$#]\{\s*([A-Za-z_]\w*)\s*\}$/.exec(t.delegateExpression)?.[1]),t.asyncBefore=v(e,`camunda:asyncBefore`)===!0,t.asyncAfter=v(e,`camunda:asyncAfter`)===!0,t}function x(e,t,n){for(let r of e??[])r?.id&&(n.set(r.id,{...b(r),processId:t}),r.flowElements&&x(r.flowElements,t,n))}function S(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map;for(let t of e?.rootElements??[])if(t.$type===`bpmn:Process`&&n.set(t.id,t),t.$type===`bpmn:Collaboration`)for(let e of t.participants??[])e.processRef?.id&&n.set(e.processRef.id,e.processRef);return n.forEach((e,n)=>x(e.flowElements,n,t)),t}function C(e){let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=[];for(let t of e?.rootElements??[])if(t.$type===`bpmn:Process`&&r.push(t),t.$type===`bpmn:Collaboration`)for(let e of t.participants??[])e.processRef&&r.push(e.processRef);let i=(e,r,a)=>{for(let o of e??[])o.id&&(o.$type===`bpmn:SequenceFlow`?n.set(o.id,{id:o.id,name:o.name?.replace(/\s+/g,` `).trim()??``,condition:o.conditionExpression?.body?.trim()||void 0,source:o.sourceRef?.id??``,target:o.targetRef?.id??``}):(t.set(o.id,{id:o.id,name:o.name?.replace(/\s+/g,` `).trim()??``,type:o.$type,outgoing:[],incoming:[],defaultFlow:o.default?.id??null,process:r,parent:a}),o.flowElements&&i(o.flowElements,r,o.id)))};for(let e of r)i(e.flowElements,e.id??``,null);for(let e of n.values())t.get(e.source)?.outgoing.push(e.id),t.get(e.target)?.incoming.push(e.id);return{nodes:t,flows:n,steps:S(e)}}var w=class extends Map{index;constructor(e){super(),this.index=e}has(e){return this.index.nodes.has(e)}get(e){let t=super.get(e);if(t||!this.index.nodes.has(e))return t;let n=E(this.index,e);return this.set(e,n),n}};function T(e){return new w(C(e))}function E(e,t){let n=/* @__PURE__ */ new Set,r=[t];for(let t=0;t<r.length;t+=1)e.nodes.get(r[t])?.outgoing.forEach(t=>{let i=e.flows.get(t)?.target;i&&!n.has(i)&&(n.add(i),r.push(i))});return n}function D(e){let t=/* @__PURE__ */ new Map;return e.nodes.forEach(e=>{let n=t.get(e.process)??[];n.push(e.id),t.set(e.process,n)}),[...t.values()].flatMap(t=>O(e,t))}function O(e,t){let n=[],r=/* @__PURE__ */ new Set;return t.filter(t=>e.nodes.get(t)?.incoming.length===0).forEach(t=>{r.has(t)||k(e,t,r,n)}),t.forEach(e=>{r.has(e)||(r.add(e),n.push(e))}),n}function k(e,t,n,r){n.add(t),r.push(t);let i=[t];for(let t=0;t<i.length;t+=1)e.nodes.get(i[t])?.outgoing.forEach(t=>{let a=e.flows.get(t)?.target;a&&e.nodes.has(a)&&!n.has(a)&&(n.add(a),r.push(a),i.push(a))})}function A(e,t,n){return t===n?!1:e.get(t)?.has(n)??!1}const re={"camunda:ExecutionListener":`EXECUTION_LISTENER`,"camunda:TaskListener":`TASK_LISTENER`},ie=2**53-1;function j(e){let t=e.split(`:`).pop()??e;return t.charAt(0).toLowerCase()+t.slice(1)}function M(e){return typeof e.name==`string`?e.name.replace(/\s+/g,` `).trim():``}function N(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`?n:void 0}function P(e){let t=e.slice(1);return t.startsWith(` `)?t.slice(1):t}function F(e){if(!e||e.resource)return null;let t=o(e.scriptFormat);return t?{language:t,value:e.value??``}:null}var I=class{drafts=[];names=/* @__PURE__ */ new Map;seq=0;process(e){this.elements(e.flowElements,e.id??``,[])}elements(e,t,n){(e??[]).forEach(e=>{e.id&&(this.names.set(e.id,M(e)),e.$type===`bpmn:SequenceFlow`?this.flow(e,t,n):(this.element(e,t,n),this.elements(e.flowElements,t,[...n,e.id])))})}element(e,t,n){let r=e.id??``,i=j(e.$type);if(e.$type===`bpmn:ScriptTask`){let a=o(e.scriptFormat);a&&this.add(r,`TASK_BODY`,0,{processId:t,containers:n,type:i,language:a,value:typeof e.script==`string`?e.script:``})}let a={};(e.extensionElements?.values??[]).forEach(e=>{let o=re[e.$type];if(!o)return;let s=a[o]??0;a[o]=s+1;let c=F(e.script);c&&this.add(r,o,s,{processId:t,containers:n,type:i,...c,event:e.event})});let s=e.extensionElements?.values?.find(e=>e.$type===`camunda:InputOutput`);[...(s?.inputParameters??[]).map(e=>[e,`input`]),...(s?.outputParameters??[]).map(e=>[e,`output`])].forEach(([e,a],o)=>{let s=F(e.definition);s&&this.add(r,`PARAMETER`,o,{processId:t,containers:n,type:i,...s,parameter:{name:e.name??``,direction:a}})});let c=e.extensionElements?.values?.find(e=>e.$type===`zeebe:IoMapping`),l={processId:t,containers:n,type:i};(c?.inputParameters??[]).forEach((e,t)=>this.mapping(r,`INPUT_MAPPING`,t,e,`input`,l)),(c?.outputParameters??[]).forEach((e,t)=>this.mapping(r,`OUTPUT_MAPPING`,t,e,`output`,l))}mapping(e,t,n,r,i,a){let o=N(r,`source`);o?.startsWith(`=`)&&this.add(e,t,n,{...a,language:`feel`,value:P(o),parameter:{name:N(r,`target`)??``,direction:i}})}flow(e,t,n){let r=e.id??``,i=e.conditionExpression;if(!i)return;let a={source:e.sourceRef?.id??``,target:e.targetRef?.id??``},s={processId:t,containers:n,type:j(e.$type)},c=N(i,`language`);if(c===void 0&&i.body?.startsWith(`=`)){this.add(r,`FEEL_CONDITION`,0,{...s,language:`feel`,value:P(i.body)},a);return}let l=o(c);l&&this.add(r,`CONDITION`,0,{...s,language:l,value:i.body??``},a)}add(e,t,n,r,i=null){this.drafts.push({site:{slot:{elementId:e,owner:t,index:n},...r},ends:i,seq:this.seq+=1})}};function L(e,t){return e.get(t)??ie}function R(e,t){let n=e.site.containers.map(e=>[L(t,e),0]);return e.ends?[...n,[L(t,e.ends.source),1]]:[...n,[L(t,e.site.slot.elementId),0]]}function z(e,t){for(let n=0;n<Math.min(e.length,t.length);n+=1){let[r,i]=e[n],[a,o]=t[n];if(r!==a)return r<a?-1:1;if(i!==o)return i<o?-1:1}return e.length-t.length}function B(e){let t=/* @__PURE__ */ new Map;return e.forEach(e=>{e&&t.set(e,(t.get(e)??0)+1)}),t}function V(e,t,n){let r=e.site.slot.elementId,i=e=>t.get(e)||e,a=t.get(r)??``,o=e.ends?a||`${i(e.ends.source)} -> ${i(e.ends.target)}`:i(r),s=a!==``&&(n.get(a)??0)>1;return{...e.site,name:o,shared:s}}function H(e){return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`)}function U(e){let t=new Map(D(C(e)).map((e,t)=>[e,t])),n=new I;H(e).forEach(e=>n.process(e));let r=B(n.names);return n.drafts.map(e=>({draft:e,path:R(e,t)})).sort((e,t)=>z(e.path,t.path)||e.draft.seq-t.draft.seq).map(({draft:e})=>V(e,n.names,r))}const W=/* @__PURE__ */ new Set([`startEvent`,`intermediateCatchEvent`,`boundaryEvent`,`receiveTask`]),G=/^=|\$\{|#\{/,K={"zeebe:ExecutionListeners":`execution`,"zeebe:TaskListeners":`task`};function q(e){let t=/^[$#]\{\s*([A-Za-z_][A-Za-z0-9_]*)/.exec(e.trim());return t?t[1]:null}function J(){return{processes:[],elements:[],workers:[],calls:[],messages:[],messageUses:[],decisions:[],decisionUses:[],formKeys:[],formUses:[],variables:[],variableForms:[],dynamic:[],embeddedForms:[],errors:[],scripts:[]}}function ae(e){let t=e.split(`:`).pop()??e;return t.charAt(0).toLowerCase()+t.slice(1)}function Y(e,t){return typeof t==`string`&&t.trim()?t:e}function X(e,t){let n=e?.get?.(t)??e?.$attrs?.[t];return typeof n==`string`&&n.trim()?n:void 0}function Z(e){return e?.extensionElements?.values??[]}function Q(e,t,n){if(!t?.id)return;let r=ae(t.$type),i=t.id;e.elements.push({id:i,name:t.name,type:r,processId:n,label:Y(i,t.name)});let a=(t,n)=>{t&&(G.test(t)?e.dynamic.push(t):n(t))};a(X(t,`camunda:topic`),t=>e.workers.push({kind:`TOPIC`,value:t,elementId:i})),a(X(t,`camunda:class`),t=>e.workers.push({kind:`JAVA_CLASS`,value:t,elementId:i}));let o=q(X(t,`camunda:delegateExpression`)??``);o&&e.workers.push({kind:`BEAN`,value:o,elementId:i}),a(X(t,`camunda:decisionRef`),t=>e.decisionUses.push({decisionId:t,elementId:i})),a(X(t,`camunda:formRef`),t=>e.formUses.push({formId:t,linked:!0,elementId:i})),a(X(t,`camunda:formKey`),t=>e.formUses.push({formId:t,linked:!1,elementId:i})),a(typeof t.calledElement==`string`?t.calledElement:void 0,t=>e.calls.push({calledProcessId:t,elementId:i})),Z(t).forEach(t=>{switch(t.$type){case`zeebe:TaskDefinition`:a(t.type,t=>e.workers.push({kind:`JOB_TYPE`,value:t,elementId:i}));break;case`zeebe:CalledElement`:a(t.processId,t=>e.calls.push({calledProcessId:t,elementId:i}));break;case`zeebe:CalledDecision`:a(t.decisionId,t=>e.decisionUses.push({decisionId:t,elementId:i}));break;case`zeebe:FormDefinition`:a(t.formId,t=>e.formUses.push({formId:t,linked:!0,elementId:i})),a(t.formKey,t=>e.formUses.push(t.startsWith(`camunda-forms:bpmn:`)?{formId:t.slice(19),linked:!1,embedded:!0,elementId:i}:{formId:t,linked:!1,elementId:i}));break;case`zeebe:ExecutionListeners`:case`zeebe:TaskListeners`:(t.listeners??[]).forEach(n=>a(n.type,n=>{e.workers.push({kind:`JOB_TYPE`,value:n,elementId:i,listener:K[t.$type]})}))}}),(t.eventDefinitions??[]).filter(e=>e.$type===`bpmn:ErrorEventDefinition`).forEach(t=>{let n=typeof t.errorRef?.errorCode==`string`&&t.errorRef.errorCode.trim()?t.errorRef.errorCode:null;n&&G.test(n)?e.dynamic.push(n):e.errors.push({code:n,catches:W.has(r),elementId:i})}),[t.messageRef,...(t.eventDefinitions??[]).map(e=>e.messageRef)].filter(e=>e?.id).forEach(t=>{e.messageUses.push({messageId:t.id,catches:W.has(r),elementId:i})}),(t.flowElements??[]).forEach(t=>Q(e,t,n))}async function oe(e){let n=J(),r=await t(e);if(!r)return n;let a=/* @__PURE__ */ new Map;(r.rootElements??[]).filter(e=>e.$type===`bpmn:Collaboration`).forEach(e=>{(e.participants??[]).forEach(e=>{e.processRef?.id&&e.name&&a.set(e.processRef.id,e.name)})}),(r.rootElements??[]).forEach(e=>{if(e.$type===`bpmn:Message`&&n.messages.push({id:e.id,name:e.name,label:Y(e.id,e.name)}),e.$type!==`bpmn:Process`)return;let t=e.name?.trim()?e.name:a.get(e.id);n.processes.push({id:e.id,name:t,executable:e.isExecutable===!0,label:Y(e.id,t)}),Z(e).filter(e=>e.$type===`zeebe:UserTaskForm`&&e.id).forEach(e=>n.embeddedForms.push(e.id)),(e.flowElements??[]).forEach(t=>Q(n,t,e.id))});let{uses:o,forms:s}=i(r);return n.variables=o,n.variableForms=s,n.scripts=U(r),n}function se(e){return e.decisionLogic?.$type===`dmn:DecisionTable`?(e.decisionLogic.output??[]).map(e=>typeof e.name==`string`?e.name.trim():``).filter(e=>e!==``):[]}async function ce(e){let t=J();try{let{rootElement:n}=await h(e);(n?.drgElement??[]).filter(e=>e.$type===`dmn:Decision`).forEach(e=>{t.decisions.push({id:e.id,name:e.name,type:`decision`,label:Y(e.id,e.name),outputs:se(e)})})}catch{return t}return t}function le(e){let t=J();try{let n=JSON.parse(e);t.formId=a(n),t.formKeys=s(n)}catch{return t}return t}function $(e){let t=e.toLowerCase();return t.endsWith(`.bpmn`)||t.endsWith(`.bpmn.xml`)?`bpmn`:t.endsWith(`.dmn`)?`dmn`:t.endsWith(`.form`)?`form`:null}const ue={bpmn:`BPMN XML`,dmn:`DMN`,form:`JSON`};function de(e){return ue[$(e)??`bpmn`]}async function fe(e,t){switch($(e)){case`bpmn`:return oe(t);case`dmn`:return ce(t);case`form`:return le(t);default:return J()}}export{T as a,b as c,h as d,f,U as i,S as l,$ as n,A as o,p,fe as r,C as s,de as t,m as u};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-translator-DNm9zRpP.js";import{n as t,o as n}from"./chunk-xml-rMelkRIV.js";const r=1e4,i={stage:`stage`,humanTask:`humanTask`,processTask:`processTask`,caseTask:`caseTask`,decisionTask:`decisionTask`,task:`task`,milestone:`milestone`,timerEventListener:`timerListener`,userEventListener:`userListener`,eventListener:`eventListener`,genericEventListener:`eventListener`},a={processTask:[`processRef`,`processRefExpression`,`processDefinitionKey`],caseTask:[`caseRef`,`caseRefExpression`,`caseDefinitionKey`],decisionTask:[`decisionRef`,`decisionRefExpression`,`decisionTableKey`]};function o(e){let t=e.indexOf(`:`);return t<0?e:e.slice(t+1)}function s(e,t){for(let[n,r]of Object.entries(e.attrs))if(o(n)===t&&!n.startsWith(`xmlns`)&&r.trim()!==``)return r.trim();return null}function c(e){return e?e.text.trim().slice(0,500):``}function l(e,t){return e.children.find(e=>e.local===t)}function u(e){return i[e.local]||(e.local.endsWith(`EventListener`)?`eventListener`:null)}function d(e,t,n){let r=[e];for(let e=r.pop();e;e=r.pop())if(t(e),!n(e))for(let t=e.children.length-1;t>=0;--t)r.push(e.children[t])}function f(e){let t=e===void 0?NaN:Number(e);return Number.isFinite(t)?t:null}function p(e){let n={shapes:/* @__PURE__ */ new Map,shapeRefs:/* @__PURE__ */ new Map,edges:[]},r=e.children.find(e=>e.local===`CMMNDI`),i=r?l(r,`CMMNDiagram`):void 0;if(!i)return n;for(let e of i.children){let r=s(e,`cmmnElementRef`);if(r){if(e.local===`CMMNShape`){let t=l(e,`Bounds`),i=f(t?.attrs.x),a=f(t?.attrs.y),o=f(t?.attrs.width),c=f(t?.attrs.height);if(i===null||a===null||o===null||c===null||o<=0||c<=0)continue;let u={x:i,y:a,width:o,height:c};n.shapes.has(r)||n.shapes.set(r,u);let d=s(e,`id`);d&&n.shapeRefs.set(d,r)}else if(e.local===`CMMNEdge`){let i=[];for(let n of t(e,`waypoint`)){let e=f(n.attrs.x),t=f(n.attrs.y);e!==null&&t!==null&&i.push({x:e,y:t})}i.length>=2&&n.edges.push({ref:r,target:s(e,`targetCMMNElementRef`),points:i})}}}return n}function m(e){let t=[...e.scope.values()].join(` `);return/flowable/i.test(t)?`flowable`:/camunda/i.test(t)?`camunda`:`plain`}function h(e,t){return{id:s(e,`id`)??``,kind:t,sentryRef:s(e,`sentryRef`)}}function g(e,t){let n=l(e,`itemControl`)??(t?l(t,`defaultControl`):void 0);if(!n)return[];let r=[];for(let[e,t]of[[`requiredRule`,`required`],[`repetitionRule`,`repetition`],[`manualActivationRule`,`manualActivation`]]){let i=l(n,e);i&&r.push({kind:t,condition:c(l(i,`condition`))||null})}return r}function _(...e){let t=/* @__PURE__ */ new Map;for(let n of e)if(n)for(let[e,r]of Object.entries(n.attrs)){let n=o(e);e.startsWith(`xmlns`)||[`id`,`name`,`definitionRef`,`sentryRef`].includes(n)||r.trim()===``||!t.has(n)&&t.size<40&&t.set(n,r.slice(0,500))}return[...t]}function v(e,t){return(e?s(e,`name`):null)??(t?s(t,`name`):null)??``}function y(r){let i=n(r);if(i.local!==`definitions`||!t(i,`case`).length&&!/cmmn/i.test(i.ns))throw Error(e(`app.cmmn.notCmmn`));let o=[],f=/* @__PURE__ */ new Map,y=/* @__PURE__ */ new Map,x=/* @__PURE__ */ new Map,S=/* @__PURE__ */ new Map,C=/* @__PURE__ */ new Map,w=[];d(i,e=>{let n=s(e,`id`);if(n&&e.local!==`CMMNDI`&&(C.set(n,(C.get(n)??0)+1),C.get(n)===2&&w.push(n)),u(e)&&n&&!f.has(n)&&f.set(n,e),e.local===`planItem`&&n&&!y.has(n)&&y.set(n,e),e.local===`sentry`&&n&&!x.has(n)){let r=t(e,`planItemOnPart`).map(e=>({id:s(e,`id`)??``,sourceRef:s(e,`sourceRef`),event:c(l(e,`standardEvent`))||null,exitCriterionRef:s(e,`exitCriterionRef`)})),i=t(e,`ifPart`).map(e=>c(l(e,`condition`))).filter(e=>e!==``);x.set(n,{id:n,name:s(e,`name`)??``,onParts:r,conditions:i})}if(e.local===`entryCriterion`||e.local===`exitCriterion`){let t=h(e,e.local===`entryCriterion`?`entry`:`exit`);t.sentryRef&&S.set(t.sentryRef,[...S.get(t.sentryRef)??[],t])}},e=>e.local===`CMMNDI`||e.local===`extensionElements`);for(let e of w)o.push({rule:`duplicate-id`,id:e,target:null,focus:e});let T=0,E=!1,D=(e,n,r)=>{let i=s(e,`id`),d=s(e,`definitionRef`),p=d?f.get(d):void 0,m=p?u(p)??`unknown`:`unknown`,y=i??d??``;p||o.push({rule:`definition-ref-missing`,id:y,target:d,focus:i});let b=t(e,`entryCriterion`).map(e=>h(e,`entry`)),x=t(e,`exitCriterion`).map(e=>h(e,`exit`));p&&m!==`unknown`&&a[m]&&((a[m]??[]).some(t=>s(p,t)!==null||s(e,t)!==null||l(p,t)!==void 0)||o.push({rule:`task-without-target`,id:y,target:m,focus:i}));let S=m===`stage`&&d!==null&&r.has(d);S&&o.push({rule:`plan-truncated`,id:y,target:d,focus:i});let C=p&&m===`stage`&&d!==null&&!S&&n<40;return{key:y,itemId:i,definitionId:d,kind:m,name:v(e,p),documentation:c(l(e,`documentation`))||c(p?l(p,`documentation`):void 0),attrs:_(p,e),rules:g(e,p),entry:b,exit:x,children:C?O(p,n+1,/* @__PURE__ */ new Set([...r,d])):[]}},O=(e,n,r)=>{let i=[];for(let a of t(e,`planItem`)){if(T>=1e4){E||o.push({rule:`plan-truncated`,id:``,target:null,focus:null}),E=!0;break}T+=1,i.push(D(a,n,r))}return i},k=t(i,`case`).map((e,n)=>{let r=s(e,`id`)??`case${n+1}`,i=l(e,`casePlanModel`);if(!i)return o.push({rule:`no-case-plan-model`,id:r,target:null,focus:null}),{id:r,name:s(e,`name`)??``,plan:null};let a=s(i,`id`)??`${r}-plan`,u={key:a,itemId:null,definitionId:a,kind:`casePlanModel`,name:s(i,`name`)??s(e,`name`)??``,documentation:c(l(i,`documentation`)),attrs:_(i),rules:[],entry:[],exit:t(i,`exitCriterion`).map(e=>h(e,`exit`)),children:O(i,1,/* @__PURE__ */ new Set)};return{id:r,name:s(e,`name`)??``,plan:u}}),A={dialect:m(i),cases:k,sentries:x,issues:o,diagram:p(i)};for(let e of b(A))for(let t of[...e.entry,...e.exit])t.sentryRef&&x.has(t.sentryRef)||o.push({rule:`dangling-sentry-ref`,id:t.id||e.key,target:t.sentryRef,focus:t.id||e.key});for(let e of x.values())for(let t of e.onParts){if(t.sourceRef&&y.has(t.sourceRef))continue;let n=S.get(e.id)?.[0];o.push({rule:`dangling-on-part`,id:t.id||e.id,target:t.sourceRef,focus:n?.id??null})}return k.length===0&&o.push({rule:`no-case-plan-model`,id:``,target:null,focus:null}),A}function b(e){let t=[],n=e.cases.flatMap(e=>e.plan?[e.plan]:[]).reverse();for(let e=n.pop();e;e=n.pop()){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}return t}export{b as n,y as r,r as t};
1
+ import{n as e,o as t}from"./chunk-xml-rMelkRIV.js";import{r as n}from"./chunk-translator-DNm9zRpP.js";const r=1e4,i={stage:`stage`,humanTask:`humanTask`,processTask:`processTask`,caseTask:`caseTask`,decisionTask:`decisionTask`,task:`task`,milestone:`milestone`,timerEventListener:`timerListener`,userEventListener:`userListener`,eventListener:`eventListener`,genericEventListener:`eventListener`},a={processTask:[`processRef`,`processRefExpression`,`processDefinitionKey`],caseTask:[`caseRef`,`caseRefExpression`,`caseDefinitionKey`],decisionTask:[`decisionRef`,`decisionRefExpression`,`decisionTableKey`]};function o(e){let t=e.indexOf(`:`);return t<0?e:e.slice(t+1)}function s(e,t){for(let[n,r]of Object.entries(e.attrs))if(o(n)===t&&!n.startsWith(`xmlns`)&&r.trim()!==``)return r.trim();return null}function c(e){return e?e.text.trim().slice(0,500):``}function l(e,t){return e.children.find(e=>e.local===t)}function u(e){return i[e.local]||(e.local.endsWith(`EventListener`)?`eventListener`:null)}function d(e,t,n){let r=[e];for(let e=r.pop();e;e=r.pop())if(t(e),!n(e))for(let t=e.children.length-1;t>=0;--t)r.push(e.children[t])}function f(e){let t=e===void 0?NaN:Number(e);return Number.isFinite(t)?t:null}function p(t){let n={shapes:/* @__PURE__ */ new Map,shapeRefs:/* @__PURE__ */ new Map,edges:[]},r=t.children.find(e=>e.local===`CMMNDI`),i=r?l(r,`CMMNDiagram`):void 0;if(!i)return n;for(let t of i.children){let r=s(t,`cmmnElementRef`);if(r){if(t.local===`CMMNShape`){let e=l(t,`Bounds`),i=f(e?.attrs.x),a=f(e?.attrs.y),o=f(e?.attrs.width),c=f(e?.attrs.height);if(i===null||a===null||o===null||c===null||o<=0||c<=0)continue;let u={x:i,y:a,width:o,height:c};n.shapes.has(r)||n.shapes.set(r,u);let d=s(t,`id`);d&&n.shapeRefs.set(d,r)}else if(t.local===`CMMNEdge`){let i=[];for(let n of e(t,`waypoint`)){let e=f(n.attrs.x),t=f(n.attrs.y);e!==null&&t!==null&&i.push({x:e,y:t})}i.length>=2&&n.edges.push({ref:r,target:s(t,`targetCMMNElementRef`),points:i})}}}return n}function m(e){let t=[...e.scope.values()].join(` `);return/flowable/i.test(t)?`flowable`:/camunda/i.test(t)?`camunda`:`plain`}function h(e,t){return{id:s(e,`id`)??``,kind:t,sentryRef:s(e,`sentryRef`)}}function g(e,t){let n=l(e,`itemControl`)??(t?l(t,`defaultControl`):void 0);if(!n)return[];let r=[];for(let[e,t]of[[`requiredRule`,`required`],[`repetitionRule`,`repetition`],[`manualActivationRule`,`manualActivation`]]){let i=l(n,e);i&&r.push({kind:t,condition:c(l(i,`condition`))||null})}return r}function _(...e){let t=/* @__PURE__ */ new Map;for(let n of e)if(n)for(let[e,r]of Object.entries(n.attrs)){let n=o(e);e.startsWith(`xmlns`)||[`id`,`name`,`definitionRef`,`sentryRef`].includes(n)||r.trim()===``||!t.has(n)&&t.size<40&&t.set(n,r.slice(0,500))}return[...t]}function v(e,t){return(e?s(e,`name`):null)??(t?s(t,`name`):null)??``}function y(r){let i=t(r);if(i.local!==`definitions`||!e(i,`case`).length&&!/cmmn/i.test(i.ns))throw Error(n(`app.cmmn.notCmmn`));let o=[],f=/* @__PURE__ */ new Map,y=/* @__PURE__ */ new Map,x=/* @__PURE__ */ new Map,S=/* @__PURE__ */ new Map,C=/* @__PURE__ */ new Map,w=[];d(i,t=>{let n=s(t,`id`);if(n&&t.local!==`CMMNDI`&&(C.set(n,(C.get(n)??0)+1),C.get(n)===2&&w.push(n)),u(t)&&n&&!f.has(n)&&f.set(n,t),t.local===`planItem`&&n&&!y.has(n)&&y.set(n,t),t.local===`sentry`&&n&&!x.has(n)){let r=e(t,`planItemOnPart`).map(e=>({id:s(e,`id`)??``,sourceRef:s(e,`sourceRef`),event:c(l(e,`standardEvent`))||null,exitCriterionRef:s(e,`exitCriterionRef`)})),i=e(t,`ifPart`).map(e=>c(l(e,`condition`))).filter(e=>e!==``);x.set(n,{id:n,name:s(t,`name`)??``,onParts:r,conditions:i})}if(t.local===`entryCriterion`||t.local===`exitCriterion`){let e=h(t,t.local===`entryCriterion`?`entry`:`exit`);e.sentryRef&&S.set(e.sentryRef,[...S.get(e.sentryRef)??[],e])}},e=>e.local===`CMMNDI`||e.local===`extensionElements`);for(let e of w)o.push({rule:`duplicate-id`,id:e,target:null,focus:e});let T=0,E=!1,D=(t,n,r)=>{let i=s(t,`id`),d=s(t,`definitionRef`),p=d?f.get(d):void 0,m=p?u(p)??`unknown`:`unknown`,y=i??d??``;p||o.push({rule:`definition-ref-missing`,id:y,target:d,focus:i});let b=e(t,`entryCriterion`).map(e=>h(e,`entry`)),x=e(t,`exitCriterion`).map(e=>h(e,`exit`));p&&m!==`unknown`&&a[m]&&((a[m]??[]).some(e=>s(p,e)!==null||s(t,e)!==null||l(p,e)!==void 0)||o.push({rule:`task-without-target`,id:y,target:m,focus:i}));let S=m===`stage`&&d!==null&&r.has(d);S&&o.push({rule:`plan-truncated`,id:y,target:d,focus:i});let C=p&&m===`stage`&&d!==null&&!S&&n<40;return{key:y,itemId:i,definitionId:d,kind:m,name:v(t,p),documentation:c(l(t,`documentation`))||c(p?l(p,`documentation`):void 0),attrs:_(p,t),rules:g(t,p),entry:b,exit:x,children:C?O(p,n+1,/* @__PURE__ */ new Set([...r,d])):[]}},O=(t,n,r)=>{let i=[];for(let a of e(t,`planItem`)){if(T>=1e4){E||o.push({rule:`plan-truncated`,id:``,target:null,focus:null}),E=!0;break}T+=1,i.push(D(a,n,r))}return i},k=e(i,`case`).map((t,n)=>{let r=s(t,`id`)??`case${n+1}`,i=l(t,`casePlanModel`);if(!i)return o.push({rule:`no-case-plan-model`,id:r,target:null,focus:null}),{id:r,name:s(t,`name`)??``,plan:null};let a=s(i,`id`)??`${r}-plan`,u={key:a,itemId:null,definitionId:a,kind:`casePlanModel`,name:s(i,`name`)??s(t,`name`)??``,documentation:c(l(i,`documentation`)),attrs:_(i),rules:[],entry:[],exit:e(i,`exitCriterion`).map(e=>h(e,`exit`)),children:O(i,1,/* @__PURE__ */ new Set)};return{id:r,name:s(t,`name`)??``,plan:u}}),A={dialect:m(i),cases:k,sentries:x,issues:o,diagram:p(i)};for(let e of b(A))for(let t of[...e.entry,...e.exit])t.sentryRef&&x.has(t.sentryRef)||o.push({rule:`dangling-sentry-ref`,id:t.id||e.key,target:t.sentryRef,focus:t.id||e.key});for(let e of x.values())for(let t of e.onParts){if(t.sourceRef&&y.has(t.sourceRef))continue;let n=S.get(e.id)?.[0];o.push({rule:`dangling-on-part`,id:t.id||e.id,target:t.sourceRef,focus:n?.id??null})}return k.length===0&&o.push({rule:`no-case-plan-model`,id:``,target:null,focus:null}),A}function b(e){let t=[],n=e.cases.flatMap(e=>e.plan?[e.plan]:[]).reverse();for(let e=n.pop();e;e=n.pop()){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}return t}export{b as n,y as r,r as t};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./chunk-moddle-D3Ym38EZ.js";import{_ as t,f as n,o as r,r as i,u as a}from"./chunk-engine-CxgdJ2wO.js";import{n as o}from"./chunk-types-mxHL9XQt.js";import{n as s}from"./chunk-file-BswMa3FN.js";const c=`https://raw.githubusercontent.com/kern0x1b/penstock-release/main/docs/schema/penstock.schema.json`;function l(e){return e===`camunda-8`?{name:o,version:`8.9.0`,namespaces:`xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"`}:{name:i[e].platform,version:r[e].version,namespaces:`xmlns:${n(e)}="${i[e].bpmn}"`}}const u={approve:{attributes:``,extension:`
1
+ import{c as e}from"./chunk-moddle-D3Ym38EZ.js";import{_ as t,f as n,o as r,r as i,u as a}from"./chunk-engine-CxgdJ2wO.js";import{n as o}from"./chunk-types-mxHL9XQt.js";import{n as s}from"./chunk-file-1YhfNmPn.js";const c=`https://raw.githubusercontent.com/kern0x1b/penstock-release/main/docs/schema/penstock.schema.json`;function l(e){return e===`camunda-8`?{name:o,version:`8.9.0`,namespaces:`xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"`}:{name:i[e].platform,version:r[e].version,namespaces:`xmlns:${n(e)}="${i[e].bpmn}"`}}const u={approve:{attributes:``,extension:`
2
2
  <bpmn:extensionElements>
3
3
  <zeebe:userTask />
4
4
  <zeebe:formDefinition formId="approve-order" />
@@ -0,0 +1 @@
1
+ import{r as e}from"./chunk-translator-DNm9zRpP.js";import{t}from"./chunk-context-rCJvBM9p.js";import{a as n}from"./chunk-features-C6o8of19.js";import{p as r}from"./chunk-license-BG88gpDZ.js";import{C as i,E as a,O as o,S as s,_ as c,b as l,g as u,h as d,m as f,p,t as m,w as h,x as g}from"./chunk-load-rfn3E0t5.js";import{t as _}from"./chunk-atomicWrite-C6J1gDtO.js";import{a as v,i as y,n as b}from"./chunk-policyGate-BOgKsqLq.js";import{n as x}from"./chunk-receiptGate-BZCKCMTV.js";import S from"node:path";import{existsSync as C,lstatSync as w,mkdirSync as T,mkdtempSync as E,readFileSync as D,renameSync as O,rmSync as k}from"node:fs";import{execFile as A}from"node:child_process";import{parseDocument as j}from"yaml";function M(e){return e.split(S.sep).join(`/`)}function N(e){let t=S.basename(e).toLowerCase(),n=``;for(let e of t)n+=e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`-`||e===`.`?e:`-`;return n=n.slice(0,40).replace(/^-+|-+$/g,``),n?`${n}-bpmn-standards`:`team-bpmn-standards`}function P(t,n,r={}){let i=p(t,n);if(!c(i.dir,[t]))return{ok:!1,lines:[e(`app.policy.refuse.outside`,{path:i.relative})]};let s=S.join(i.dir,g);if(C(s))return{ok:!1,lines:[e(`app.policy.init.exists`,{file:M(S.relative(t,s))})]};let l={name:r.name??N(t),version:1,rules:Object.create(null),conventions:null,palette:null,templates:[],baselines:[],requiredChecks:{check:!0,scenarios:!1,dmnTests:!1,receipt:!1}},u=a(o(l));return`refused`in u?{ok:!1,lines:u.refused}:(_(s,o(l)),{ok:!0,lines:[e(`app.policy.init.wrote`,{file:M(S.relative(t,s))}),e(`app.policy.init.next`)]})}function F(t,n,r){let s=p(t,n);if(!h(r.rule))return{ok:!1,lines:[e(`app.policy.refuse.rule`,{rule:r.rule.slice(0,60)})]};if(!i.includes(r.severity))return{ok:!1,lines:[e(`app.policy.addRule.severity`,{given:r.severity.slice(0,20),allowed:i.join(`, `)})]};if(r.severity===`off`&&r.forced)return{ok:!1,lines:[e(`app.policy.refuse.forcedOff`,{rule:r.rule})]};let c=d(s.dir,t);if(c.manifest===null)return{ok:!1,lines:c.refused.length>0?c.refused:[e(`app.policy.refuse.manifestMissing`,{file:g})]};let l=c.manifest,u=Object.create(null);for(let e of Object.keys(l.rules))u[e]=l.rules[e];u[r.rule]={severity:r.severity,forced:r.forced};let f={...l,rules:u},m=o(f),v=a(m);return`refused`in v?{ok:!1,lines:v.refused}:(_(S.join(s.dir,g),m),{ok:!0,lines:[e(`app.policy.addRule.wrote`,{rule:r.rule,severity:r.severity,forced:r.forced?e(`app.policy.addRule.forced`):``}).trim(),e(`app.policy.pin.again`)]})}function I(t,n){let r=p(t,n),i=d(r.dir,t);if(i.hash===null)return{ok:!1,lines:i.refused.length>0?i.refused:[e(`app.policy.refuse.manifestMissing`,{file:g})]};let a=m.map(e=>S.join(t,e)).find(e=>C(e));if(a!==void 0&&/\.json$/i.test(a))return{ok:!1,lines:[e(`app.policy.pin.jsonConfig`,{file:S.basename(a)})]};if(a===void 0)return _(S.join(t,l),`${JSON.stringify({pin:i.hash},null,2)}\n`),{ok:!0,lines:[e(`app.policy.pin.wroteLock`,{file:l,pin:i.hash})]};let o=j(D(a,`utf8`));return o.errors.length>0?{ok:!1,lines:[e(`app.policy.pin.configBroken`,{file:S.basename(a)})]}:(o.setIn([`policy`,`pin`],i.hash),_(a,o.toString()),{ok:!0,lines:[e(`app.policy.pin.wrote`,{file:S.basename(a),pin:i.hash})]})}function L(t,n){let r=f(t,n);return r.present?r.refused.length>0?{ok:!1,lines:[e(`app.policy.verify.refused`),...r.refused.map(e=>` ${e}`)]}:r.pin===`unpinned`?{ok:!1,lines:[e(`app.policy.verify.unpinned`,{hash:r.hash??``})]}:r.pin===`mismatch`?{ok:!1,lines:[e(`app.policy.verify.mismatch`,{expected:r.expected??``,actual:r.hash??``})]}:{ok:!0,lines:[e(`app.policy.verify.ok`,{name:r.name??``,version:r.version??0,files:r.files})]}:{ok:!1,lines:[e(`app.policy.verify.none`)]}}function R(e,t=process.platform){return e.startsWith(`//`)||e.startsWith(`\\\\`)||/^[\\/]{2}[?.][\\/]/.test(e)?!1:t===`win32`?/^[A-Za-z]:[\\/]/.test(e):e.startsWith(`/`)&&!e.includes(`://`)}function z(e){let t=e.includes(`://`)?e.slice(e.indexOf(`://`)+3):e.slice(e.indexOf(`@`)+1);return!t.slice(t.lastIndexOf(`@`)+1).startsWith(`-`)&&!t.startsWith(`-`)}function B(e,t={}){if(e.length===0||e.length>500||e.startsWith(`-`))return!1;for(let t of e){let e=t.codePointAt(0)??0;if(e<=32||e===127)return!1}return e.includes(`::`)?!1:e.startsWith(`https://`)||e.startsWith(`ssh://`)||e.startsWith(`git@`)&&e.includes(`:`)&&!e.includes(`://`)?z(e):t.allowLocal===!0&&R(e,t.platform)}function V(e){if(e.length===0||e.length>100||e.startsWith(`-`)||e.includes(`..`)||e.endsWith(`/`)||e.endsWith(`.lock`))return!1;for(let t of e)if(!(t>=`a`&&t<=`z`||t>=`A`&&t<=`Z`||t>=`0`&&t<=`9`||t===`.`||t===`_`||t===`-`||t===`/`))return!1;return!0}const H=(e,t,n)=>new Promise(r=>{A(`git`,e,{cwd:t,env:n,timeout:12e4,maxBuffer:1048576,windowsHide:!0},(e,t,n)=>{r({code:e?typeof e.code==`number`?e.code:1:0,stderr:String(n??``)})})});function U(e,t=process.env){let n={};for(let e of[`PATH`,`HOME`,`USERPROFILE`,`SystemRoot`,`SSH_AUTH_SOCK`,`TMPDIR`,`TEMP`,`TMP`,`LANG`])t[e]!==void 0&&(n[e]=t[e]);return{...n,GIT_ALLOW_PROTOCOL:e?`https:ssh:file`:`https:ssh`,GIT_TERMINAL_PROMPT:`0`,GIT_CONFIG_NOSYSTEM:`1`}}async function W(t,n,r=H,i={}){let a=p(t,n),o=i.source??a.source;if(o===null)return{ok:!1,lines:[e(`app.policy.sync.noSource`)]};let l=i.source!==void 0||i.allowLocal===!0;if(!B(o,{allowLocal:l,platform:i.platform}))return{ok:!1,lines:[e(`app.policy.sync.badUrl`)]};if(a.ref!==null&&!V(a.ref))return{ok:!1,lines:[e(`app.policy.sync.badRef`)]};let u=S.join(t,s),m=S.dirname(u);if(!c(u,[t]))return{ok:!1,lines:[e(`app.policy.refuse.outside`,{path:s})]};if(C(u)&&w(u).isSymbolicLink())return{ok:!1,lines:[e(`app.policy.refuse.symlink`,{file:s})]};T(m,{recursive:!0});let h=E(S.join(m,`policy-sync-`)),g=S.join(h,`pack`);try{if((await r([`-c`,`protocol.ext.allow=never`,`-c`,`protocol.file.allow=${l?`always`:`never`}`,`-c`,`core.hooksPath=/dev/null`,`-c`,`core.fsmonitor=false`,`-c`,`core.symlinks=false`,`clone`,`--depth`,`1`,`--no-tags`,`--single-branch`,`--no-recurse-submodules`,...a.ref===null?[]:[`--branch`,a.ref],`--`,o,g],h,U(l))).code!==0)return{ok:!1,lines:[e(`app.policy.sync.failed`)]};k(S.join(g,`.git`),{recursive:!0,force:!0});let i=d(g,h);if(i.hash===null)return{ok:!1,lines:[e(`app.policy.sync.refused`),...i.refused.map(e=>` ${e}`)]};if(a.pin!==null&&i.hash!==a.pin)return{ok:!1,lines:[e(`app.policy.sync.pinRefused`,{expected:a.pin,actual:i.hash})]};k(u,{recursive:!0,force:!0}),O(g,u);let c=f(t,n),p=[e(`app.policy.sync.done`,{name:i.manifest?.name??``,version:i.manifest?.version??0,dir:s})];return c.pin===`pinned`?p.push(e(`app.policy.sync.pinned`)):c.pin===`mismatch`?p.push(e(`app.policy.sync.mismatch`,{expected:c.expected??``,actual:c.hash??``})):p.push(e(`app.policy.sync.unpinned`)),{ok:!0,lines:p}}finally{k(h,{recursive:!0,force:!0})}}const G=[`show`,`init`,`add-rule`,`pin`,`verify`,`sync`];function K(e){return t(S.resolve(e??process.cwd())).root}function q(t){return t.length>0?t.join(`, `):e(`app.policy.show.nothing`)}function J(n){let r=t(n),i=r.policy??f(n,r.own),a=u(i);if(!a.present)return{ok:!0,lines:[e(`app.policy.show.none`)]};let o=[a.header??``];if(o.push(e(`app.policy.show.folder`,{dir:a.dir})),a.hash&&o.push(e(`app.policy.show.hash`,{hash:a.hash})),a.refused.length>0)return{ok:!1,lines:[...o,...a.refused.map(e=>` ${e}`)]};o.push(e(`app.policy.show.forced`,{rules:q(a.rules.filter(e=>e.forced).map(e=>`${e.rule} (${e.severity})`))})),o.push(e(`app.policy.show.defaults`,{rules:q(a.rules.filter(e=>!e.forced).map(e=>`${e.rule} (${e.severity})`))})),a.palette&&o.push(e(`app.policy.show.palette`,{names:a.palette.join(`, `)}));let s=a.requiredChecks;return o.push(e(`app.policy.show.required`,{names:q(s?[`check`,`scenarios`,`dmnTests`,`receipt`].filter(e=>s[e]):[])})),{ok:!0,lines:o}}async function Y(n,r){let i=n[0]??`show`;if(!G.includes(i))return{ok:!1,lines:[e(`app.cli.policy.unknownAction`,{action:n[0].slice(0,40),actions:G.join(`, `)})]};let a=K(r.project),o=t(a).own;if(i===`show`){if(r.format===`json`){let e=t(a);return{ok:!0,lines:[JSON.stringify(u(e.policy??f(a,e.own)),null,2)]}}return J(a)}if(i===`init`)return P(a,o,{name:r.name});if(i===`add-rule`){let t=n[1];return t?r.severity===void 0?{ok:!1,lines:[e(`app.cli.policy.needsSeverity`)]}:F(a,o,{rule:t,severity:r.severity,forced:r.forced}):{ok:!1,lines:[e(`app.cli.policy.needsRule`)]}}return i===`pin`?I(a,o):i===`sync`?W(a,o,void 0,{source:r.source,allowLocal:r.allowLocal}):L(a,o)}function X(e,t=process.env){return r(t)||e}async function Z(e){let r=t(e.target),i=r.policy;if(!i||!i.present)return null;let a=await n(`policy-pack`);if(a)return{refused:a};let o=i.manifest?.requiredChecks.receipt===!0,s=b({root:r.root,status:i,own:r.own,rules:y(r.root,r.own),checkOk:e.checkOk,receipt:o?()=>x(r.root,e.base,{...e.settings,requireReceipt:!0}):void 0});return{lines:s.lines,ok:s.ok}}function Q(e,n,r){if(r.refused===!0)return;let i=t(e);i.policy?.present&&C(i.root)&&v(i.root,n,{ok:r.ok,count:+!!r.ok})}export{Z as enforcePolicy,X as enforcing,Y as policyCommand,Q as recordRun};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./chunk-translator-DNm9zRpP.js";import{_ as t,k as n,y as r}from"./chunk-load-rfn3E0t5.js";import{t as i}from"./chunk-atomicWrite-C6J1gDtO.js";import{t as a}from"./chunk-diagrams-CtGMGTa8.js";import o from"node:path";import{existsSync as s,lstatSync as c,readFileSync as l}from"node:fs";import{createHash as u}from"node:crypto";function d(e){let n=a(e,[`process`,`decision`,`form`,`case`]).filter(n=>t(n,[e]));if(n.length>5e3)return null;let r=u(`sha256`),i=0;for(let t of n.sort()){let n;try{let e=c(t);if(e.isSymbolicLink()||!e.isFile())continue;n=e.size}catch{continue}if(i+=n,i>67108864)return null;r.update(`${o.relative(e,t).split(o.sep).join(`/`)}\0`),r.update(u(`sha256`).update(l(t)).digest(`hex`)),r.update(`
2
+ `)}return r.digest(`hex`)}function f(e){let t=o.join(e,r);try{let e=c(t);if(e.isSymbolicLink()||!e.isFile()||e.size>8192)return null;let n=JSON.parse(l(t,`utf8`));return typeof n!=`object`||!n||Array.isArray(n)?null:n}catch{return null}}function p(e,n,a,l=()=>/* @__PURE__ */ new Date){let u=d(e);if(u===null)return!1;let p=o.join(e,r);if(!t(p,[e])||s(p)&&c(p).isSymbolicLink())return!1;let m=f(e)??{version:1},h={version:1,...m.scenarios?{scenarios:m.scenarios}:{},...m.dmnTests?{dmnTests:m.dmnTests}:{}};return h[n]={ok:a.ok,count:a.count,at:l().toISOString(),digest:u},i(p,`${JSON.stringify(h,null,2)}\n`),!0}function m(e,t){let n=f(e)?.[t];if(!n||typeof n.ok!=`boolean`||typeof n.digest!=`string`||typeof n.count!=`number`)return`missing`;let r=d(e);return r===null||n.digest!==r?`stale`:!n.ok||n.count<1?`failed`:`ok`}function h(e,n){let r=n.lint&&typeof n.lint==`object`&&!Array.isArray(n.lint)?n.lint:{},i=typeof r.configPath==`string`&&r.configPath.trim()?r.configPath.trim():`.bpmnlintrc`,a=o.resolve(e,i);try{let n=c(a);return n.isSymbolicLink()||!n.isFile()||n.size>1048576||!t(a,[e])?null:JSON.parse(l(a,`utf8`))}catch{return null}}function g(t){return t.kind===`ruleOff`?e(`app.policy.gate.ruleOff`,{rule:t.subject}):t.kind===`severity`?e(`app.policy.gate.severity`,{rule:t.subject,change:t.detail??``}):t.kind===`unreadable`?e(`app.policy.gate.ruleUnreadable`,{rule:t.subject}):e(`app.policy.gate.palette`,{name:t.subject})}function _(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):null}function v(t){let{status:r}=t,i=[];if(!r.present)return{ok:!0,lines:[],problems:i};if(r.refused.length>0)return i.push(e(`app.policy.gate.refused`),...r.refused.map(e=>` ${e}`)),y(r,i);r.pin===`unpinned`&&i.push(e(`app.policy.gate.unpinned`)),r.pin===`mismatch`&&i.push(e(`app.policy.gate.mismatch`,{expected:r.expected??``,actual:r.hash??``}));let a=r.manifest;if(a===null)return y(r,i);for(let e of n({rules:t.rules,palette:_(t.own.palette),manifest:a}))i.push(g(e));let o=a.requiredChecks;o.check&&!t.checkOk&&i.push(e(`app.policy.gate.checkFailed`));let s=[[`scenarios`,o.scenarios,`scenarios`],[`dmnTests`,o.dmnTests,`dmnTests`]];for(let[n,r,a]of s){if(!r)continue;let o=m(t.root,n);o!==`ok`&&i.push(e(`app.policy.gate.required.${o}`,{check:e(`app.policy.check.${a}`)}))}if(o.receipt){let n=t.receipt?.();n?n.ok||i.push(e(`app.policy.gate.required.failed`,{check:e(`app.policy.check.receipt`)})):i.push(e(`app.policy.gate.required.missing`,{check:e(`app.policy.check.receipt`)}))}return y(r,i)}function y(t,n){return n.length===0?{ok:!0,lines:[e(`app.policy.gate.ok`,{name:t.name??``,version:t.version??0})],problems:n}:{ok:!1,lines:[e(`app.policy.gate.failed`,{name:t.name??``,version:t.version??0}),...n.map(e=>e.startsWith(` `)?e:` ${e}`)],problems:n}}export{p as a,h as i,v as n,d as r,m as t};
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-compose-BUJTvoFX.js";import{t}from"./chunk-context-rCJvBM9p.js";import{t as n}from"./chunk-export-kt3sBTZu.js";import{d as r,i,l as a}from"./chunk-git-57LoLvY3.js";import{r as o}from"./chunk-translator-DNm9zRpP.js";import{n as s}from"./chunk-project-lO_6DX8G.js";import c from"node:path";import{mkdirSync as l,writeFileSync as u}from"node:fs";async function d(d,f){let{root:p}=t(d);if(!a(p))return{ok:!1,lines:[o(`app.cli.notAGitRepository`)]};if(!r(p,f.base))return{ok:!1,lines:[o(`app.cli.report.baseNotFound`,{base:f.base})]};let{changed:m,removed:h}=i(p,f.base);l(f.imagesDir,{recursive:!0});let g=await e({changed:m,removed:h,picturesLink:f.imagesLink,picture:async(e,t)=>{let r=s(e.relative,`.svg`);try{await n(e.after,c.join(f.imagesDir,r),t)}catch{return null}return f.imageBase?`${f.imageBase.replace(/\/$/,``)}/${r}`:f.imagesLink?null:c.join(f.imagesDir,r)}});return u(f.out,g.markdown),{ok:g.clean,refused:!1,lines:[o(`app.cli.wrote`,{file:f.out})]}}export{d as reportCommand};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-moddle-D3Ym38EZ.js";import{a as t,n,r}from"./chunk-model-f8AzYUK7.js";const i=[[`ational`,`ate`],[`tional`,`tion`],[`enci`,`ence`],[`anci`,`ance`],[`izer`,`ize`],[`abli`,`able`],[`alli`,`al`],[`entli`,`ent`],[`eli`,`e`],[`ousli`,`ous`],[`ization`,`ize`],[`ation`,`ate`],[`ator`,`ate`],[`alism`,`al`],[`iveness`,`ive`],[`fulness`,`ful`],[`ousness`,`ous`],[`aliti`,`al`],[`iviti`,`ive`],[`biliti`,`ble`]],a=[[`icate`,`ic`],[`ative`,``],[`alize`,`al`],[`iciti`,`ic`],[`ical`,`ic`],[`ful`,``],[`ness`,``]],o=[`al`,`ance`,`ence`,`er`,`ic`,`able`,`ible`,`ant`,`ement`,`ment`,`ent`,`ion`,`ou`,`ism`,`ate`,`iti`,`ous`,`ive`,`ize`],s=/* @__PURE__ */ new Set([`s`,`t`]);function c(e,t){return`aeiou`.includes(e[t])?!1:e[t]!==`y`||t===0||!c(e,t-1)}function l(e){let t=0,n=0;for(;n<e.length&&c(e,n);)n+=1;for(;n<e.length;){for(;n<e.length&&!c(e,n);)n+=1;if(n>=e.length)break;for(;n<e.length&&c(e,n);)n+=1;t+=1}return t}function u(e){return[...e].some((t,n)=>!c(e,n))}function d(e){let t=e.length;return t>=2&&e[t-1]===e[t-2]&&c(e,t-1)}function f(e){let t=e.length;return t>=3&&c(e,t-3)&&!c(e,t-2)&&c(e,t-1)&&!`wxy`.includes(e[t-1])}function p(e,t,n){return e.slice(0,e.length-t.length)+n}function m(e){return e.endsWith(`sses`)?p(e,`sses`,`ss`):e.endsWith(`ies`)?p(e,`ies`,`i`):e.endsWith(`ss`)||e.endsWith(`us`)||e.endsWith(`is`)?e:e.endsWith(`s`)?e.slice(0,-1):e}function h(e){return[`at`,`bl`,`iz`].some(t=>e.endsWith(t))?e+`e`:d(e)&&!`lsz`.includes(e[e.length-1])?e.slice(0,-1):l(e)===1&&f(e)?e+`e`:e}function g(e){if(e.endsWith(`eed`)){let t=e.slice(0,-3);return l(t)>0?t+`ee`:e}for(let t of[`ed`,`ing`])if(e.endsWith(t)&&u(e.slice(0,-t.length)))return h(e.slice(0,-t.length));return e}function ee(e){return e.endsWith(`y`)&&u(e.slice(0,-1))?e.slice(0,-1)+`i`:e}function _(e,t){let n=t.find(([t])=>e.endsWith(t));if(!n)return e;let r=e.slice(0,e.length-n[0].length);return l(r)>0?r+n[1]:e}function te(e){let t=o.find(t=>e.endsWith(t));if(!t)return e;let n=e.slice(0,e.length-t.length);return l(n)<=1||t===`ion`&&!s.has(n.slice(-1))?e:n}function ne(e){let t=e;if(t.endsWith(`e`)){let e=t.slice(0,-1),n=l(e);(n>1||n===1&&!f(e))&&(t=e)}return l(t)>1&&t.endsWith(`ll`)&&(t=t.slice(0,-1)),t}const v=/* @__PURE__ */ new Map;function y(e){if(e.length<=2)return e;let t=v.get(e);if(t!==void 0)return t;let n=ne(te(_(_(ee(g(m(e))),i),a)));return v.size>=1e4&&v.clear(),v.set(e,n),n}var re={version:1,stopWords:[`a`,`an`,`the`,`of`],abbreviations:{addr:[`address`],amt:[`amount`],cnt:[`count`],desc:[`description`],dob:[`birth`,`date`],dt:[`date`],id:[`identifier`],img:[`image`],max:[`maximum`],min:[`minimum`],msg:[`message`],no:[`number`],nr:[`number`],num:[`number`],pct:[`percent`],perc:[`percent`],qty:[`quantity`],tel:[`telephone`],tot:[`total`],ts:[`timestamp`],val:[`value`]},families:{number:[`int`,`integer`,`int32`,`int64`,`long`,`short`,`byte`,`double`,`float`,`float32`,`float64`,`decimal`,`bigdecimal`,`biginteger`,`number`],string:[`string`,`str`,`charsequence`,`char`,`character`],boolean:[`boolean`,`bool`],date:[`date`,`localdate`,`localdatetime`,`datetime`,`instant`,`zoneddatetime`,`offsetdatetime`,`time`,`localtime`,`timestamp`],duration:[`duration`,`timespan`],list:[`list`,`arraylist`,`linkedlist`,`array`,`collection`,`set`,`hashset`,`iterable`,`sequence`]},concepts:[{name:`email`,role:`content`,words:[`email`,`mail`,`e mail`],family:`string`,unit:null},{name:`identifier`,role:`attribute`,words:[`identifier`,`key`,`number`,`code`,`uuid`,`guid`],family:null,unit:null},{name:`flag`,role:`marker`,words:[`flag`,`is`,`has`,`can`,`should`,`was`,`will`,`does`],family:`boolean`,unit:null},{name:`percent`,role:`content`,words:[`percent`,`percentage`],family:`number`,unit:`%`},{name:`rate`,role:`content`,words:[`rate`,`factor`,`ratio`],family:`number`,unit:null},{name:`timeout`,role:`content`,words:[`timeout`,`expiry`,`expiration`,`ttl`],family:`duration`,unit:null},{name:`duration`,role:`content`,words:[`duration`,`period`,`elapsed`,`span`],family:`duration`,unit:null},{name:`count`,role:`content`,words:[`count`,`quantity`,`tally`],family:`number`,unit:null},{name:`amount`,role:`content`,words:[`amount`,`total`,`sum`,`price`,`cost`,`fee`],family:`number`,unit:null},{name:`date`,role:`content`,words:[`date`,`day`],family:`date`,unit:null},{name:`name`,role:`content`,words:[`name`,`title`,`label`],family:`string`,unit:null},{name:`address`,role:`content`,words:[`address`],family:`string`,unit:null},{name:`phone`,role:`content`,words:[`phone`,`telephone`,`mobile`],family:`string`,unit:null},{name:`status`,role:`content`,words:[`status`,`state`],family:`string`,unit:null},{name:`url`,role:`content`,words:[`url`,`link`,`uri`,`href`],family:`string`,unit:null},{name:`description`,role:`content`,words:[`description`,`summary`],family:`string`,unit:null}]};const b=[`content`,`attribute`,`marker`],x=[`number`,`string`,`boolean`,`date`,`duration`,`list`],S=/^[\p{Ll}\p{Lo}\p{N}]+(?: [\p{Ll}\p{Lo}\p{N}]+)*$/u,ie=/^[\p{Ll}\p{Lo}\p{N}]+$/u;var C=class e extends Error{problems;constructor(t){super(JSON.stringify(t)),this.name=e.name,this.problems=t}};const w=e=>typeof e==`object`&&!!e&&!Array.isArray(e),T=e=>b.includes(e),E=e=>x.includes(e),D=e=>typeof e==`string`&&ie.test(e),O=e=>e.map(e=>y(e)).join(` `);function ae(e,t){let n=/* @__PURE__ */ new Set;return Array.isArray(e)?(e.forEach((e,r)=>{let i=`stopWords[${r}]`;D(e)?n.has(e)?t.push({code:`repeated`,path:i,value:e}):n.add(e):t.push({code:`notWord`,path:i,value:e})}),n):(t.push({code:`notList`,path:`stopWords`}),n)}function k(e,t){let n=/* @__PURE__ */ new Map;if(!w(e))return t.push({code:`notObject`,path:`abbreviations`}),n;for(let[r,i]of Object.entries(e)){let e=`abbreviations.${r}`;D(r)?Array.isArray(i)?i.length===0?t.push({code:`emptyList`,path:e}):i.every(D)?n.set(r,i):t.push({code:`notWord`,path:e,value:i}):t.push({code:`notList`,path:e}):t.push({code:`notWord`,path:`abbreviations`,value:r})}return n}function A(e,t){let n=/* @__PURE__ */ new Map;if(!w(e))return t.push({code:`notObject`,path:`families`}),n;for(let[r,i]of Object.entries(e)){let e=`families.${r}`;E(r)?Array.isArray(i)?i.forEach((i,a)=>{let o=`${e}[${a}]`;D(i)?n.has(i)?t.push({code:n.get(i)===r?`repeated`:`owned`,path:o,value:i,other:n.get(i)}):n.set(i,r):t.push({code:`notWord`,path:o,value:i})}):t.push({code:`notList`,path:e}):t.push({code:`unknownFamily`,path:e,value:r})}return n}function j(e,t,n){return Array.isArray(e)?e.length===0?(n.push({code:`emptyList`,path:t}),[]):e.flatMap((e,r)=>typeof e==`string`&&S.test(e)?[e]:(n.push({code:`notPhrase`,path:`${t}[${r}]`,value:e}),[])):(n.push({code:`notList`,path:t}),[])}function M(e,t,n){let r=`concepts[${t}]`;if(!w(e))return n.push({code:`notObject`,path:r}),null;let i=typeof e.name==`string`&&S.test(e.name)?e.name:null;i===null&&n.push({code:`notPhrase`,path:`${r}.name`,value:e.name});let a=T(e.role)?e.role:null;a===null&&n.push({code:`unknownRole`,path:`${r}.role`,value:e.role});let o=j(e.words,`${r}.words`,n);i!==null&&!o.includes(i)&&n.push({code:`nameNotAmongWords`,path:r,value:i});let s=e.family===null||e.family===void 0?null:e.family;s!==null&&!E(s)&&n.push({code:`unknownFamily`,path:`${r}.family`,value:s});let c=e.unit===null||e.unit===void 0?null:e.unit;return c!==null&&(typeof c!=`string`||c.trim()===``)&&n.push({code:`notText`,path:`${r}.unit`,value:c}),i===null||a===null||s!==null&&!E(s)||c!==null&&typeof c!=`string`?null:{name:i,role:a,words:o,family:s,unit:c}}function N(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;return Array.isArray(e)?(e.forEach((e,i)=>{let a=M(e,i,t);a&&(n.has(a.name)&&t.push({code:`repeated`,path:`concepts[${i}]`,value:a.name}),n.set(a.name,a),a.words.forEach((e,n)=>{let o=O(e.split(` `)),s=r.get(o);s&&s.name!==a.name?t.push({code:`owned`,path:`concepts[${i}].words[${n}]`,value:e,other:s.name}):r.set(o,a)}))}),{concepts:n,phrases:r}):(t.push({code:`notList`,path:`concepts`}),{concepts:n,phrases:r})}function P(e){if(!w(e))throw new C([{code:`notObject`,path:`$`}]);let t=[];e.version!==1&&t.push({code:`version`,path:`version`,value:e.version});let n=ae(e.stopWords,t),r=k(e.abbreviations,t),i=A(e.families,t),{concepts:a,phrases:o}=N(e.concepts,t);if(t.length>0)throw new C(t);return{stopWords:n,abbreviations:r,typeNames:i,concepts:a,phrases:o,longestPhrase:Math.max(1,...[...o.keys()].map(e=>e.split(` `).length))}}const F=P(re),I=/^([A-Za-z_]\w*)(?:\.[A-Za-z_]\w*|\[\s*\d+\s*\])*$/,L=/^[$#]\{([\s\S]*)\}$/,R=[`camunda`,`operaton`];function z(e){return typeof e==`string`?(e.split(`:`).pop()??``).toLowerCase():``}function B(e){return typeof e==`string`&&e.trim()!==``?e.trim():null}function V(e){return e!==null&&e.startsWith(`=`)?B(e.slice(1)):null}function H(e){let t=e===null?null:L.exec(e.trim());return t?B(t[1]):null}function U(e){let t=e===null?null:I.exec(e);return t?t[1]:null}function W(e,t,n,r,i=U(r)){return{elementId:e,direction:t,target:n,expression:r,variable:i}}function G(e){for(let t of R){let n=e?.get?.(`${t}:resultVariable`)??e?.$attrs?.[`${t}:resultVariable`];if(B(n)!==null)return B(n)}return null}function K(e,t){switch(z(t?.$type)){case`iomapping`:return[...(t.inputParameters??[]).map(t=>W(e,`input`,B(t.target),V(B(t.source)))),...(t.outputParameters??[]).map(t=>W(e,`output`,B(t.target),V(B(t.source)),null))];case`inputoutput`:return[...(t.inputParameters??[]).map(t=>W(e,`input`,B(t.name),H(B(t.value)))),...(t.outputParameters??[]).map(t=>W(e,`output`,B(t.name),H(B(t.value)),null))];case`connector`:return t.inputOutput?K(e,t.inputOutput):[];case`in`:{let n=B(t.source);return[W(e,`input`,B(t.target),n??H(B(t.sourceExpression)))]}case`out`:return[W(e,`output`,B(t.target),B(t.source),null)];case`script`:case`calleddecision`:return B(t.resultVariable)===null?[]:[W(e,`result`,B(t.resultVariable),null)];default:return[]}}function q(e){let t=String(e.id),n=G(e);return[...(e.extensionElements?.values??[]).flatMap(e=>K(t,e)),...n===null?[]:[W(t,`result`,n,null)]]}function J(e,t){e?.id&&(t.push(...q(e)),(e.flowElements??[]).forEach(e=>J(e,t)))}function Y(e){let t=[];return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>(e.flowElements??[]).forEach(e=>J(e,t))),t}const oe=/\p{Lu}+(?=\p{Lu}\p{Ll})|\p{Lu}?[\p{Ll}\p{M}]+|\p{Lu}+|\p{N}+|[\p{Lo}\p{Lm}\p{M}]+/gu,se=/\[\s*\d+\s*\]/g,ce=/^\p{N}+$/u;function le(e){return e.replace(se,`.`).split(`.`).filter(e=>e.length>0)}function ue(e){return[...e.matchAll(oe)].map(e=>e[0].toLowerCase())}function de(e,t){return e.flatMap(e=>t.stopWords.has(e)?[]:[...t.abbreviations.get(e)??[e]])}function fe(e,t,n){for(let r=Math.min(n.longestPhrase,e.length-t);r>=1;--r){let i=n.phrases.get(O(e.slice(t,t+r)));if(i)return{concept:i,length:r}}return null}function pe(e,t,n){let r=[],i=0;for(;i<e.length;){let a=fe(e,i,n);if(a)r.push({key:a.concept.name,text:e.slice(i,i+a.length).join(` `),role:a.concept.role,segment:t}),i+=a.length;else{let n=e[i];r.push({key:y(n),text:n,role:ce.test(n)?`attribute`:`content`,segment:t}),i+=1}}return r}function me(e,t){return le(e).flatMap((e,n)=>pe(de(ue(e),t),n,t))}const X={names:0,content:0,last:0};function he(e,t){let n=me(e,t),r=n.filter(e=>e.role===`content`);return{keys:[...new Set(n.map(e=>e.key))],contentKeys:[...new Set(r.map(e=>e.key))],last:r.at(-1)?.key??null,weight:0}}var ge=class{lexicon;sources=/* @__PURE__ */ new Map;sourceWeights=/* @__PURE__ */ new Map;holders=/* @__PURE__ */ new Map;facts=/* @__PURE__ */ new Map;statistics=/* @__PURE__ */ new Map;mass=/* @__PURE__ */ new Map;total=0;constructor(e=F){this.lexicon=e}get size(){return this.facts.size}replaceSource(e,t){let n=this.sources.get(e)??/* @__PURE__ */ new Set,r=new Set(t);for(let t of n)r.has(t)||this.release(t,e);for(let t of r)n.has(t)||this.retain(t,e);r.size===0?this.sources.delete(e):this.sources.set(e,r)}removeSource(e){this.replaceSource(e,[])}setSourceWeight(e,t){if(!Number.isFinite(t)||t<0)throw RangeError(`sourceWeight:${t}`);this.sourceWeights.set(e,t);for(let t of this.sources.get(e)??[])this.refresh(t)}statisticsOf(e){return{...this.statistics.get(e)??X}}weight(e){return 1+Math.log((this.total+1)/((this.mass.get(e)??0)+1))}headness(e){let{content:t,last:n}=this.statisticsOf(e);return(n+1)/(t+2)}retain(e,t){let n=this.holders.get(e)??/* @__PURE__ */ new Set;n.add(t),this.holders.set(e,n),this.facts.has(e)||this.enter(e),this.refresh(e)}release(e,t){let n=this.holders.get(e);n?.delete(t),n?.size===0?(this.holders.delete(e),this.leave(e)):this.refresh(e)}enter(e){let t=he(e,this.lexicon);this.facts.set(e,t),t.keys.forEach(e=>this.bump(e,`names`,1)),t.contentKeys.forEach(e=>this.bump(e,`content`,1)),t.last!==null&&this.bump(t.last,`last`,1)}leave(e){let t=this.facts.get(e);t&&(this.reweigh(t,0),t.keys.forEach(e=>this.bump(e,`names`,-1)),t.contentKeys.forEach(e=>this.bump(e,`content`,-1)),t.last!==null&&this.bump(t.last,`last`,-1),this.facts.delete(e))}refresh(e){let t=this.facts.get(e);t&&this.reweigh(t,this.heaviestOf(e))}heaviestOf(e){return[...this.holders.get(e)??[]].reduce((e,t)=>Math.max(e,this.sourceWeights.get(t)??1),0)}reweigh(e,t){let n=t-e.weight;n!==0&&(e.weight=t,this.total+=n,e.keys.forEach(e=>this.mass.set(e,(this.mass.get(e)??0)+n)))}bump(e,t,n){let r=this.statistics.get(e)??{...X};r[t]+=n,this.statistics.set(e,r)}};const _e=/^P(?!$)(?:\d+(?:\.\d+)?[YMWD])*(?:T(?=\d)(?:\d+(?:\.\d+)?[HMS])+)?$/;function ve(e){return _e.test(e)}function Z(e,t){for(let n of e?.eventDefinitions??[]){if(n?.$type!==`bpmn:TimerEventDefinition`)continue;let e=typeof n.timeDuration?.body==`string`?n.timeDuration.body.trim():``;ve(e)&&t.push(e)}(e?.flowElements??[]).forEach(e=>Z(e,t))}function ye(e){let t=[];return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>Z(e,t)),t}function be(e){return e.flatMap(e=>{let t=/* @__PURE__ */ new Map;return e.mappings.filter(e=>e.direction!==`input`&&e.target!==null).forEach(e=>t.set(e.elementId,[...t.get(e.elementId)??[],e.target])),[...t].map(([t,n])=>({diagram:e.path,elementId:t,label:e.elementNames.get(t)??``,outputs:n}))})}function xe(e){return new Map([...e].map(e=>[e.id,[...e.outputs]]))}const Q=e=>e.filter(e=>typeof e==`string`&&e!==``);function Se(e,t){return[...Q(t.map(e=>e.name)),...Q(e.workers.map(e=>e.value)),...Q(e.processes.map(e=>e.id)),...Q(e.calls.map(e=>e.calledProcessId)),...Q(e.decisions.map(e=>e.id)),...Q(e.decisionUses.map(e=>e.decisionId))]}function Ce(e){return{name:e.name,writes:e.writes,elementId:e.elementId,where:e.where,type:e.type??null}}function we(e){let t=/* @__PURE__ */ new Map;for(let n of e)n.writes&&t.set(n.elementId,[...t.get(n.elementId)??[],n.name]);return t}function Te(e){let t=/* @__PURE__ */ new Map;for(let n of e.workers)t.set(n.elementId,[...t.get(n.elementId)??[],`${n.kind}:${n.value}`]);return t}function Ee(e,t,n){let r=new Set(t.model.workers.map(e=>e.elementId)),i=(n?.variables??[]).filter(e=>r.has(e.elementId)).map(Ce),a=[...t.model.variables,...i];return{path:e,kind:t.kind,model:t.model,order:t.order,mappings:t.mappings,elementNames:new Map(t.model.elements.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])),variables:a,decisionUses:t.model.decisionUses,codeWrites:we(i),workerKeys:Te(t.model),names:Se(t.model,a),timers:t.timers}}function De(e){return e.mappings.filter(e=>e.direction!==`input`&&e.target!==null).flatMap(t=>(e.workerKeys.get(t.elementId)??[]).map(n=>({diagram:e.path,elementId:t.elementId,workerKey:n,outputs:[t.target]})))}function Oe(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let e of n.variables)!e.writes&&e.where!==`output`&&t.set(e.name,(t.get(e.name)??0)+1);return t}function $(e,t){return e.path<t.path?-1:+(e.path>t.path)}function ke(e,t){let r=/* @__PURE__ */ new Map;for(let i of e.filter(e=>n(e.path)===`bpmn`||n(e.path)===`dmn`).sort($))r.has(i.text)&&i.path!==t||r.set(i.text,i);return[...r.values()].sort($)}async function Ae(i){let a=n(i.path);if(a!==`bpmn`&&a!==`dmn`)return null;try{let n=a===`bpmn`?await e(i.text):null;return a===`bpmn`&&n===null?null:{kind:a,model:await r(i.path,i.text),order:n?t(n):/* @__PURE__ */ new Map,mappings:n?Y(n):[],timers:n?ye(n):[]}}catch{return null}}function je(e){let t=new ge(F);return e.forEach(e=>t.replaceSource(e.path,e.names)),t}var Me=class{cache=/* @__PURE__ */ new Map;async build(e,t=null,n={}){let r=ke(e,n.focus),i=new Set(r.map(e=>e.path));for(let e of[...this.cache.keys()])i.has(e)||this.cache.delete(e);let a=[],o=Date.now();for(let e of r){let t=await this.parse(e);t!==null&&a.push({path:e.path,file:t}),n.pause&&Date.now()-o>=8&&(await n.pause(),o=Date.now())}let s=a.map(({path:e,file:n})=>Ee(e,n,t)),c=s.filter(e=>e.kind===`bpmn`);return{diagrams:s,project:{types:t?.types??[],...t?.variableChecks?{inputs:t.variableChecks.inputs}:{},decisionOutputs:xe(s.flatMap(e=>e.model.decisions)),taskOutputs:c.flatMap(De),peers:be(c.map(e=>({path:e.path,elementNames:e.elementNames,mappings:e.mappings}))),names:c.flatMap(e=>e.variables.map(t=>({name:t.name,diagram:e.path,elementId:t.elementId}))),reads:Oe(s),timers:c.flatMap(e=>e.timers.map(t=>({diagram:e.path,text:t})))},vocabulary:je(s)}}async parse(e){let t=this.cache.get(e.path);if(t!==void 0&&t.text===e.text)return t.parsed;let n=await Ae(e);return this.cache.set(e.path,{text:e.text,parsed:n}),n}};export{Me as t};
1
+ import{a as e}from"./chunk-moddle-D3Ym38EZ.js";import{a as t,n,r}from"./chunk-model-BulEKnY1.js";const i=[[`ational`,`ate`],[`tional`,`tion`],[`enci`,`ence`],[`anci`,`ance`],[`izer`,`ize`],[`abli`,`able`],[`alli`,`al`],[`entli`,`ent`],[`eli`,`e`],[`ousli`,`ous`],[`ization`,`ize`],[`ation`,`ate`],[`ator`,`ate`],[`alism`,`al`],[`iveness`,`ive`],[`fulness`,`ful`],[`ousness`,`ous`],[`aliti`,`al`],[`iviti`,`ive`],[`biliti`,`ble`]],a=[[`icate`,`ic`],[`ative`,``],[`alize`,`al`],[`iciti`,`ic`],[`ical`,`ic`],[`ful`,``],[`ness`,``]],o=[`al`,`ance`,`ence`,`er`,`ic`,`able`,`ible`,`ant`,`ement`,`ment`,`ent`,`ion`,`ou`,`ism`,`ate`,`iti`,`ous`,`ive`,`ize`],s=/* @__PURE__ */ new Set([`s`,`t`]);function c(e,t){return`aeiou`.includes(e[t])?!1:e[t]!==`y`||t===0||!c(e,t-1)}function l(e){let t=0,n=0;for(;n<e.length&&c(e,n);)n+=1;for(;n<e.length;){for(;n<e.length&&!c(e,n);)n+=1;if(n>=e.length)break;for(;n<e.length&&c(e,n);)n+=1;t+=1}return t}function u(e){return[...e].some((t,n)=>!c(e,n))}function d(e){let t=e.length;return t>=2&&e[t-1]===e[t-2]&&c(e,t-1)}function f(e){let t=e.length;return t>=3&&c(e,t-3)&&!c(e,t-2)&&c(e,t-1)&&!`wxy`.includes(e[t-1])}function p(e,t,n){return e.slice(0,e.length-t.length)+n}function m(e){return e.endsWith(`sses`)?p(e,`sses`,`ss`):e.endsWith(`ies`)?p(e,`ies`,`i`):e.endsWith(`ss`)||e.endsWith(`us`)||e.endsWith(`is`)?e:e.endsWith(`s`)?e.slice(0,-1):e}function h(e){return[`at`,`bl`,`iz`].some(t=>e.endsWith(t))?e+`e`:d(e)&&!`lsz`.includes(e[e.length-1])?e.slice(0,-1):l(e)===1&&f(e)?e+`e`:e}function g(e){if(e.endsWith(`eed`)){let t=e.slice(0,-3);return l(t)>0?t+`ee`:e}for(let t of[`ed`,`ing`])if(e.endsWith(t)&&u(e.slice(0,-t.length)))return h(e.slice(0,-t.length));return e}function ee(e){return e.endsWith(`y`)&&u(e.slice(0,-1))?e.slice(0,-1)+`i`:e}function _(e,t){let n=t.find(([t])=>e.endsWith(t));if(!n)return e;let r=e.slice(0,e.length-n[0].length);return l(r)>0?r+n[1]:e}function te(e){let t=o.find(t=>e.endsWith(t));if(!t)return e;let n=e.slice(0,e.length-t.length);return l(n)<=1||t===`ion`&&!s.has(n.slice(-1))?e:n}function ne(e){let t=e;if(t.endsWith(`e`)){let e=t.slice(0,-1),n=l(e);(n>1||n===1&&!f(e))&&(t=e)}return l(t)>1&&t.endsWith(`ll`)&&(t=t.slice(0,-1)),t}const v=/* @__PURE__ */ new Map;function y(e){if(e.length<=2)return e;let t=v.get(e);if(t!==void 0)return t;let n=ne(te(_(_(ee(g(m(e))),i),a)));return v.size>=1e4&&v.clear(),v.set(e,n),n}var re={version:1,stopWords:[`a`,`an`,`the`,`of`],abbreviations:{addr:[`address`],amt:[`amount`],cnt:[`count`],desc:[`description`],dob:[`birth`,`date`],dt:[`date`],id:[`identifier`],img:[`image`],max:[`maximum`],min:[`minimum`],msg:[`message`],no:[`number`],nr:[`number`],num:[`number`],pct:[`percent`],perc:[`percent`],qty:[`quantity`],tel:[`telephone`],tot:[`total`],ts:[`timestamp`],val:[`value`]},families:{number:[`int`,`integer`,`int32`,`int64`,`long`,`short`,`byte`,`double`,`float`,`float32`,`float64`,`decimal`,`bigdecimal`,`biginteger`,`number`],string:[`string`,`str`,`charsequence`,`char`,`character`],boolean:[`boolean`,`bool`],date:[`date`,`localdate`,`localdatetime`,`datetime`,`instant`,`zoneddatetime`,`offsetdatetime`,`time`,`localtime`,`timestamp`],duration:[`duration`,`timespan`],list:[`list`,`arraylist`,`linkedlist`,`array`,`collection`,`set`,`hashset`,`iterable`,`sequence`]},concepts:[{name:`email`,role:`content`,words:[`email`,`mail`,`e mail`],family:`string`,unit:null},{name:`identifier`,role:`attribute`,words:[`identifier`,`key`,`number`,`code`,`uuid`,`guid`],family:null,unit:null},{name:`flag`,role:`marker`,words:[`flag`,`is`,`has`,`can`,`should`,`was`,`will`,`does`],family:`boolean`,unit:null},{name:`percent`,role:`content`,words:[`percent`,`percentage`],family:`number`,unit:`%`},{name:`rate`,role:`content`,words:[`rate`,`factor`,`ratio`],family:`number`,unit:null},{name:`timeout`,role:`content`,words:[`timeout`,`expiry`,`expiration`,`ttl`],family:`duration`,unit:null},{name:`duration`,role:`content`,words:[`duration`,`period`,`elapsed`,`span`],family:`duration`,unit:null},{name:`count`,role:`content`,words:[`count`,`quantity`,`tally`],family:`number`,unit:null},{name:`amount`,role:`content`,words:[`amount`,`total`,`sum`,`price`,`cost`,`fee`],family:`number`,unit:null},{name:`date`,role:`content`,words:[`date`,`day`],family:`date`,unit:null},{name:`name`,role:`content`,words:[`name`,`title`,`label`],family:`string`,unit:null},{name:`address`,role:`content`,words:[`address`],family:`string`,unit:null},{name:`phone`,role:`content`,words:[`phone`,`telephone`,`mobile`],family:`string`,unit:null},{name:`status`,role:`content`,words:[`status`,`state`],family:`string`,unit:null},{name:`url`,role:`content`,words:[`url`,`link`,`uri`,`href`],family:`string`,unit:null},{name:`description`,role:`content`,words:[`description`,`summary`],family:`string`,unit:null}]};const b=[`content`,`attribute`,`marker`],x=[`number`,`string`,`boolean`,`date`,`duration`,`list`],S=/^[\p{Ll}\p{Lo}\p{N}]+(?: [\p{Ll}\p{Lo}\p{N}]+)*$/u,ie=/^[\p{Ll}\p{Lo}\p{N}]+$/u;var C=class e extends Error{problems;constructor(t){super(JSON.stringify(t)),this.name=e.name,this.problems=t}};const w=e=>typeof e==`object`&&!!e&&!Array.isArray(e),T=e=>b.includes(e),E=e=>x.includes(e),D=e=>typeof e==`string`&&ie.test(e),O=e=>e.map(e=>y(e)).join(` `);function ae(e,t){let n=/* @__PURE__ */ new Set;return Array.isArray(e)?(e.forEach((e,r)=>{let i=`stopWords[${r}]`;D(e)?n.has(e)?t.push({code:`repeated`,path:i,value:e}):n.add(e):t.push({code:`notWord`,path:i,value:e})}),n):(t.push({code:`notList`,path:`stopWords`}),n)}function k(e,t){let n=/* @__PURE__ */ new Map;if(!w(e))return t.push({code:`notObject`,path:`abbreviations`}),n;for(let[r,i]of Object.entries(e)){let e=`abbreviations.${r}`;D(r)?Array.isArray(i)?i.length===0?t.push({code:`emptyList`,path:e}):i.every(D)?n.set(r,i):t.push({code:`notWord`,path:e,value:i}):t.push({code:`notList`,path:e}):t.push({code:`notWord`,path:`abbreviations`,value:r})}return n}function A(e,t){let n=/* @__PURE__ */ new Map;if(!w(e))return t.push({code:`notObject`,path:`families`}),n;for(let[r,i]of Object.entries(e)){let e=`families.${r}`;E(r)?Array.isArray(i)?i.forEach((i,a)=>{let o=`${e}[${a}]`;D(i)?n.has(i)?t.push({code:n.get(i)===r?`repeated`:`owned`,path:o,value:i,other:n.get(i)}):n.set(i,r):t.push({code:`notWord`,path:o,value:i})}):t.push({code:`notList`,path:e}):t.push({code:`unknownFamily`,path:e,value:r})}return n}function j(e,t,n){return Array.isArray(e)?e.length===0?(n.push({code:`emptyList`,path:t}),[]):e.flatMap((e,r)=>typeof e==`string`&&S.test(e)?[e]:(n.push({code:`notPhrase`,path:`${t}[${r}]`,value:e}),[])):(n.push({code:`notList`,path:t}),[])}function M(e,t,n){let r=`concepts[${t}]`;if(!w(e))return n.push({code:`notObject`,path:r}),null;let i=typeof e.name==`string`&&S.test(e.name)?e.name:null;i===null&&n.push({code:`notPhrase`,path:`${r}.name`,value:e.name});let a=T(e.role)?e.role:null;a===null&&n.push({code:`unknownRole`,path:`${r}.role`,value:e.role});let o=j(e.words,`${r}.words`,n);i!==null&&!o.includes(i)&&n.push({code:`nameNotAmongWords`,path:r,value:i});let s=e.family===null||e.family===void 0?null:e.family;s!==null&&!E(s)&&n.push({code:`unknownFamily`,path:`${r}.family`,value:s});let c=e.unit===null||e.unit===void 0?null:e.unit;return c!==null&&(typeof c!=`string`||c.trim()===``)&&n.push({code:`notText`,path:`${r}.unit`,value:c}),i===null||a===null||s!==null&&!E(s)||c!==null&&typeof c!=`string`?null:{name:i,role:a,words:o,family:s,unit:c}}function N(e,t){let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;return Array.isArray(e)?(e.forEach((e,i)=>{let a=M(e,i,t);a&&(n.has(a.name)&&t.push({code:`repeated`,path:`concepts[${i}]`,value:a.name}),n.set(a.name,a),a.words.forEach((e,n)=>{let o=O(e.split(` `)),s=r.get(o);s&&s.name!==a.name?t.push({code:`owned`,path:`concepts[${i}].words[${n}]`,value:e,other:s.name}):r.set(o,a)}))}),{concepts:n,phrases:r}):(t.push({code:`notList`,path:`concepts`}),{concepts:n,phrases:r})}function P(e){if(!w(e))throw new C([{code:`notObject`,path:`$`}]);let t=[];e.version!==1&&t.push({code:`version`,path:`version`,value:e.version});let n=ae(e.stopWords,t),r=k(e.abbreviations,t),i=A(e.families,t),{concepts:a,phrases:o}=N(e.concepts,t);if(t.length>0)throw new C(t);return{stopWords:n,abbreviations:r,typeNames:i,concepts:a,phrases:o,longestPhrase:Math.max(1,...[...o.keys()].map(e=>e.split(` `).length))}}const F=P(re),I=/^([A-Za-z_]\w*)(?:\.[A-Za-z_]\w*|\[\s*\d+\s*\])*$/,L=/^[$#]\{([\s\S]*)\}$/,R=[`camunda`,`operaton`];function z(e){return typeof e==`string`?(e.split(`:`).pop()??``).toLowerCase():``}function B(e){return typeof e==`string`&&e.trim()!==``?e.trim():null}function V(e){return e!==null&&e.startsWith(`=`)?B(e.slice(1)):null}function H(e){let t=e===null?null:L.exec(e.trim());return t?B(t[1]):null}function U(e){let t=e===null?null:I.exec(e);return t?t[1]:null}function W(e,t,n,r,i=U(r)){return{elementId:e,direction:t,target:n,expression:r,variable:i}}function G(e){for(let t of R){let n=e?.get?.(`${t}:resultVariable`)??e?.$attrs?.[`${t}:resultVariable`];if(B(n)!==null)return B(n)}return null}function K(e,t){switch(z(t?.$type)){case`iomapping`:return[...(t.inputParameters??[]).map(t=>W(e,`input`,B(t.target),V(B(t.source)))),...(t.outputParameters??[]).map(t=>W(e,`output`,B(t.target),V(B(t.source)),null))];case`inputoutput`:return[...(t.inputParameters??[]).map(t=>W(e,`input`,B(t.name),H(B(t.value)))),...(t.outputParameters??[]).map(t=>W(e,`output`,B(t.name),H(B(t.value)),null))];case`connector`:return t.inputOutput?K(e,t.inputOutput):[];case`in`:{let n=B(t.source);return[W(e,`input`,B(t.target),n??H(B(t.sourceExpression)))]}case`out`:return[W(e,`output`,B(t.target),B(t.source),null)];case`script`:case`calleddecision`:return B(t.resultVariable)===null?[]:[W(e,`result`,B(t.resultVariable),null)];default:return[]}}function q(e){let t=String(e.id),n=G(e);return[...(e.extensionElements?.values??[]).flatMap(e=>K(t,e)),...n===null?[]:[W(t,`result`,n,null)]]}function J(e,t){e?.id&&(t.push(...q(e)),(e.flowElements??[]).forEach(e=>J(e,t)))}function Y(e){let t=[];return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>(e.flowElements??[]).forEach(e=>J(e,t))),t}const oe=/\p{Lu}+(?=\p{Lu}\p{Ll})|\p{Lu}?[\p{Ll}\p{M}]+|\p{Lu}+|\p{N}+|[\p{Lo}\p{Lm}\p{M}]+/gu,se=/\[\s*\d+\s*\]/g,ce=/^\p{N}+$/u;function le(e){return e.replace(se,`.`).split(`.`).filter(e=>e.length>0)}function ue(e){return[...e.matchAll(oe)].map(e=>e[0].toLowerCase())}function de(e,t){return e.flatMap(e=>t.stopWords.has(e)?[]:[...t.abbreviations.get(e)??[e]])}function fe(e,t,n){for(let r=Math.min(n.longestPhrase,e.length-t);r>=1;--r){let i=n.phrases.get(O(e.slice(t,t+r)));if(i)return{concept:i,length:r}}return null}function pe(e,t,n){let r=[],i=0;for(;i<e.length;){let a=fe(e,i,n);if(a)r.push({key:a.concept.name,text:e.slice(i,i+a.length).join(` `),role:a.concept.role,segment:t}),i+=a.length;else{let n=e[i];r.push({key:y(n),text:n,role:ce.test(n)?`attribute`:`content`,segment:t}),i+=1}}return r}function me(e,t){return le(e).flatMap((e,n)=>pe(de(ue(e),t),n,t))}const X={names:0,content:0,last:0};function he(e,t){let n=me(e,t),r=n.filter(e=>e.role===`content`);return{keys:[...new Set(n.map(e=>e.key))],contentKeys:[...new Set(r.map(e=>e.key))],last:r.at(-1)?.key??null,weight:0}}var ge=class{lexicon;sources=/* @__PURE__ */ new Map;sourceWeights=/* @__PURE__ */ new Map;holders=/* @__PURE__ */ new Map;facts=/* @__PURE__ */ new Map;statistics=/* @__PURE__ */ new Map;mass=/* @__PURE__ */ new Map;total=0;constructor(e=F){this.lexicon=e}get size(){return this.facts.size}replaceSource(e,t){let n=this.sources.get(e)??/* @__PURE__ */ new Set,r=new Set(t);for(let t of n)r.has(t)||this.release(t,e);for(let t of r)n.has(t)||this.retain(t,e);r.size===0?this.sources.delete(e):this.sources.set(e,r)}removeSource(e){this.replaceSource(e,[])}setSourceWeight(e,t){if(!Number.isFinite(t)||t<0)throw RangeError(`sourceWeight:${t}`);this.sourceWeights.set(e,t);for(let t of this.sources.get(e)??[])this.refresh(t)}statisticsOf(e){return{...this.statistics.get(e)??X}}weight(e){return 1+Math.log((this.total+1)/((this.mass.get(e)??0)+1))}headness(e){let{content:t,last:n}=this.statisticsOf(e);return(n+1)/(t+2)}retain(e,t){let n=this.holders.get(e)??/* @__PURE__ */ new Set;n.add(t),this.holders.set(e,n),this.facts.has(e)||this.enter(e),this.refresh(e)}release(e,t){let n=this.holders.get(e);n?.delete(t),n?.size===0?(this.holders.delete(e),this.leave(e)):this.refresh(e)}enter(e){let t=he(e,this.lexicon);this.facts.set(e,t),t.keys.forEach(e=>this.bump(e,`names`,1)),t.contentKeys.forEach(e=>this.bump(e,`content`,1)),t.last!==null&&this.bump(t.last,`last`,1)}leave(e){let t=this.facts.get(e);t&&(this.reweigh(t,0),t.keys.forEach(e=>this.bump(e,`names`,-1)),t.contentKeys.forEach(e=>this.bump(e,`content`,-1)),t.last!==null&&this.bump(t.last,`last`,-1),this.facts.delete(e))}refresh(e){let t=this.facts.get(e);t&&this.reweigh(t,this.heaviestOf(e))}heaviestOf(e){return[...this.holders.get(e)??[]].reduce((e,t)=>Math.max(e,this.sourceWeights.get(t)??1),0)}reweigh(e,t){let n=t-e.weight;n!==0&&(e.weight=t,this.total+=n,e.keys.forEach(e=>this.mass.set(e,(this.mass.get(e)??0)+n)))}bump(e,t,n){let r=this.statistics.get(e)??{...X};r[t]+=n,this.statistics.set(e,r)}};const _e=/^P(?!$)(?:\d+(?:\.\d+)?[YMWD])*(?:T(?=\d)(?:\d+(?:\.\d+)?[HMS])+)?$/;function ve(e){return _e.test(e)}function Z(e,t){for(let n of e?.eventDefinitions??[]){if(n?.$type!==`bpmn:TimerEventDefinition`)continue;let e=typeof n.timeDuration?.body==`string`?n.timeDuration.body.trim():``;ve(e)&&t.push(e)}(e?.flowElements??[]).forEach(e=>Z(e,t))}function ye(e){let t=[];return(e?.rootElements??[]).filter(e=>e.$type===`bpmn:Process`).forEach(e=>Z(e,t)),t}function be(e){return e.flatMap(e=>{let t=/* @__PURE__ */ new Map;return e.mappings.filter(e=>e.direction!==`input`&&e.target!==null).forEach(e=>t.set(e.elementId,[...t.get(e.elementId)??[],e.target])),[...t].map(([t,n])=>({diagram:e.path,elementId:t,label:e.elementNames.get(t)??``,outputs:n}))})}function xe(e){return new Map([...e].map(e=>[e.id,[...e.outputs]]))}const Q=e=>e.filter(e=>typeof e==`string`&&e!==``);function Se(e,t){return[...Q(t.map(e=>e.name)),...Q(e.workers.map(e=>e.value)),...Q(e.processes.map(e=>e.id)),...Q(e.calls.map(e=>e.calledProcessId)),...Q(e.decisions.map(e=>e.id)),...Q(e.decisionUses.map(e=>e.decisionId))]}function Ce(e){return{name:e.name,writes:e.writes,elementId:e.elementId,where:e.where,type:e.type??null}}function we(e){let t=/* @__PURE__ */ new Map;for(let n of e)n.writes&&t.set(n.elementId,[...t.get(n.elementId)??[],n.name]);return t}function Te(e){let t=/* @__PURE__ */ new Map;for(let n of e.workers)t.set(n.elementId,[...t.get(n.elementId)??[],`${n.kind}:${n.value}`]);return t}function Ee(e,t,n){let r=new Set(t.model.workers.map(e=>e.elementId)),i=(n?.variables??[]).filter(e=>r.has(e.elementId)).map(Ce),a=[...t.model.variables,...i];return{path:e,kind:t.kind,model:t.model,order:t.order,mappings:t.mappings,elementNames:new Map(t.model.elements.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])),variables:a,decisionUses:t.model.decisionUses,codeWrites:we(i),workerKeys:Te(t.model),names:Se(t.model,a),timers:t.timers}}function De(e){return e.mappings.filter(e=>e.direction!==`input`&&e.target!==null).flatMap(t=>(e.workerKeys.get(t.elementId)??[]).map(n=>({diagram:e.path,elementId:t.elementId,workerKey:n,outputs:[t.target]})))}function Oe(e){let t=/* @__PURE__ */ new Map;for(let n of e)for(let e of n.variables)!e.writes&&e.where!==`output`&&t.set(e.name,(t.get(e.name)??0)+1);return t}function $(e,t){return e.path<t.path?-1:+(e.path>t.path)}function ke(e,t){let r=/* @__PURE__ */ new Map;for(let i of e.filter(e=>n(e.path)===`bpmn`||n(e.path)===`dmn`).sort($))r.has(i.text)&&i.path!==t||r.set(i.text,i);return[...r.values()].sort($)}async function Ae(i){let a=n(i.path);if(a!==`bpmn`&&a!==`dmn`)return null;try{let n=a===`bpmn`?await e(i.text):null;return a===`bpmn`&&n===null?null:{kind:a,model:await r(i.path,i.text),order:n?t(n):/* @__PURE__ */ new Map,mappings:n?Y(n):[],timers:n?ye(n):[]}}catch{return null}}function je(e){let t=new ge(F);return e.forEach(e=>t.replaceSource(e.path,e.names)),t}var Me=class{cache=/* @__PURE__ */ new Map;async build(e,t=null,n={}){let r=ke(e,n.focus),i=new Set(r.map(e=>e.path));for(let e of[...this.cache.keys()])i.has(e)||this.cache.delete(e);let a=[],o=Date.now();for(let e of r){let t=await this.parse(e);t!==null&&a.push({path:e.path,file:t}),n.pause&&Date.now()-o>=8&&(await n.pause(),o=Date.now())}let s=a.map(({path:e,file:n})=>Ee(e,n,t)),c=s.filter(e=>e.kind===`bpmn`);return{diagrams:s,project:{types:t?.types??[],...t?.variableChecks?{inputs:t.variableChecks.inputs}:{},decisionOutputs:xe(s.flatMap(e=>e.model.decisions)),taskOutputs:c.flatMap(De),peers:be(c.map(e=>({path:e.path,elementNames:e.elementNames,mappings:e.mappings}))),names:c.flatMap(e=>e.variables.map(t=>({name:t.name,diagram:e.path,elementId:t.elementId}))),reads:Oe(s),timers:c.flatMap(e=>e.timers.map(t=>({diagram:e.path,text:t})))},vocabulary:je(s)}}async parse(e){let t=this.cache.get(e.path);if(t!==void 0&&t.text===e.text)return t.parsed;let n=await Ae(e);return this.cache.set(e.path,{text:e.text,parsed:n}),n}};export{Me as t};
@@ -0,0 +1 @@
1
+ import{i as e,r as t}from"./chunk-folders-C7ae1oPV.js";import{t as n}from"./chunk-load-rfn3E0t5.js";import r from"node:path";import{existsSync as i,readdirSync as a,statSync as o}from"node:fs";const s=/\.bpmn(20\.xml)?$/,c=/\.(cmmn11\.xml|cmmn)$/i;function l(e){for(let t of n){let n=r.join(e,t);try{if(i(n)&&o(n).isFile())return n}catch{continue}}return null}const u=e=>e.startsWith(`.`)||e===`node_modules`;function d(e,t=``){return`${r.basename(e).replace(s,``).replace(c,``)}${t}`}function f(n,o,s=u){let c=[],l=i(n)?e(n):()=>{},d=e=>{for(let n of a(e,{withFileTypes:!0})){if(l(),s(n.name))continue;let i=r.join(e,n.name);n.isDirectory()?t(i)&&d(i):o(n.name)&&c.push(i)}};return i(n)&&d(n),c.sort()}export{d as n,f as r,l as t};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./chunk-context-rCJvBM9p.js";import{a as t,f as n,v as r,y as i}from"./chunk-promotion-DDLrgBqZ.js";import{t as a}from"./chunk-list-XuNpvC6j.js";import{r as o}from"./chunk-translator-DNm9zRpP.js";import{t as s}from"./chunk-plural-Dn-7ulHf.js";import{t as c}from"./chunk-table-BOiaGWwY.js";import{n as l}from"./chunk-status-CmYxwOCn.js";import{existsSync as u,statSync as d}from"node:fs";function f(e){let t=[o(`app.promotion.text.driftTitle`,{names:a(e.environments.map(e=>e.name))})];for(let n of e.environments){let e=n.place??o(`app.promotion.text.noAddress`),r=n.engineVersion?` ${n.engineVersion}`:``,i=[n.protected?o(`app.promotion.text.protected`):``,n.forTests?o(`app.promotion.text.forTests`):``].filter(Boolean).join(`, `);t.push(` ${n.name} ${e}${r}${i?` (${i})`:``}`),n.status!==`read`&&t.push(` ${o(`app.promotion.status.${n.status}`)}${n.reason?`: ${n.reason}`:``}`)}let n=e.environments.filter(e=>e.status===`read`);if(e.rows.length>0&&n.length>0){t.push(``),t.push(...c(e.rows,{columns:[{name:`resource`,header:o(`app.promotion.text.header.resource`),value:e=>`${e.kind} ${e.key}`},{name:`file`,header:o(`app.promotion.text.header.file`),value:e=>e.file??`-`},...n.map(e=>({name:`env-${e.name}`,header:e.name,value:t=>{let n=t.cells[e.name];return n?`${o(`app.promotion.state.${n.state}`)}${n.version===null?``:` v${n.version}`}`:`-`}}))]}));let r=i.filter(t=>e.counts[t]>0).map(t=>`${e.counts[t]} ${o(`app.promotion.state.${t}`)}`);t.push(``,r.join(`, `))}else n.length>0&&t.push(``,o(`app.promotion.text.nothingFound`));if(e.comparison){let{a:n,b:r,rows:i}=e.comparison;t.push(``,o(`app.promotion.text.comparison`,{a:n,b:r}));let a=i.filter(e=>e.state!==`same`);a.length===0&&t.push(` ${o(`app.promotion.text.sameEverywhere`,{a:n,b:r})}`);for(let e of a)t.push(` ${e.kind} ${e.key}: ${o(`app.promotion.compare.${e.state}`,{a:n,b:r})}`)}for(let n of e.duplicates)t.push(``,o(`app.promotion.promote.duplicate`,{key:n.key,files:n.files.join(`, `)}));return e.unreadable.length>0&&t.push(``,o(`app.promotion.text.unreadable`,{files:a(e.unreadable)})),e.forms.length>0&&t.push(``,o(`app.promotion.text.formsNotCompared`,{count:e.forms.length})),t}function p(e){let t=e.plan,n=[o(e.wrote?`app.promotion.text.promotingNow`:`app.promotion.text.dryRun`,{from:t.from.name,to:t.to.name})];n.push(` ${t.from.name} ${t.from.place??``}${t.from.engineVersion?` ${t.from.engineVersion}`:``}`),n.push(` ${t.to.name} ${t.to.place??``}${t.to.engineVersion?` ${t.to.engineVersion}`:``}${t.to.protected?` (${o(`app.promotion.text.protected`)})`:``}`);let r=[...t.items.map(e=>({what:`${e.kind} ${e.key}`,file:e.file,action:e.action,detail:e.reason??(e.action===`unchanged`?o(`app.promotion.text.sameOnTarget`,{to:t.to.name}):e.toVersion===null?``:`v${e.toVersion} -> v${e.toVersion+1}`)})),...t.forms.map(e=>({what:`form`,file:e.file,action:e.action===`send`?`create`:`skipped`,detail:e.reason??``}))];r.length>0&&n.push(``,...c(r,{columns:[{name:`action`,header:o(`app.promotion.text.header.action`),value:e=>o(`app.promotion.action.${e.action}`)},{name:`what`,header:o(`app.promotion.text.header.resource`),value:e=>e.what},{name:`file`,header:o(`app.promotion.text.header.file`),value:e=>e.file},{name:`detail`,header:o(`app.promotion.text.header.details`),value:e=>e.detail}]})),n.push(``,s(t.files.length,`app.promotion.count.file`)),n.push(``,o(`app.promotion.text.secretsTitle`,{to:t.to.name})),t.secrets.missing.length===0&&n.push(` ${o(`app.promotion.text.noSecretsMissing`)}`);for(let e of t.secrets.missing)n.push(` ${l(`fail`)} ${e.kind} ${e.name}`);for(let e of t.secrets.unverifiable)n.push(` ${l(`note`)} ${e.kind} ${e.name} ${o(`app.promotion.text.cannotVerify`)}`);n.push(``,o(`app.promotion.text.compatTitle`,{to:t.to.name,version:t.to.engineVersion??o(`app.promotion.text.unknownVersion`)})),t.compatibility.length===0&&n.push(` ${o(`app.promotion.text.compatOk`)}`);for(let e of t.compatibility)n.push(` ${l(e.severity)} ${o(`app.promotion.compat.${e.code}`,{file:e.file,subject:e.subject,found:e.found,wanted:e.wanted,target:t.to.name})}`);if(n.push(``,o(`app.promotion.text.policyTitle`)),!t.policy.present)n.push(` ${o(`app.promotion.text.noPolicy`)}`);else{n.push(` ${o(`app.promotion.text.policyLine`,{name:t.policy.name??``,version:t.policy.version??0,pin:o(`app.promotion.text.pin.${t.policy.pin}`)})}`),n.push(` ${t.policy.enforced?t.policy.ok?o(`app.promotion.text.policyEnforcedOk`):o(`app.promotion.text.policyEnforcedFailed`):o(`app.promotion.text.policyNotEnforced`)}`);for(let e of t.policy.problems)n.push(` ${e}`)}if(t.protection.protected&&(n.push(``,o(`app.promotion.text.protectionTitle`,{to:t.to.name})),n.push(` ${t.protection.confirmed?o(`app.promotion.text.confirmed`):o(`app.promotion.text.notConfirmed`,{name:t.to.name})}`),t.protection.inPipeline)){let e=t.protection.approval;n.push(` ${e===null?o(`app.promotion.text.noApproval`):e.ok?o(`app.promotion.text.approvalOk`,{by:e.approvedBy??``,at:e.approvedAt??``,until:e.validUntil??``}):o(`app.promotion.text.approvalNotOk`)}`),n.push(` ${o(`app.promotion.text.approvalIsARecord`)}`)}return t.blockers.length>0&&n.push(``,o(`app.promotion.text.blocked`),...t.blockers.map(e=>e.startsWith(` `)?e:` ${e}`)),e.outcome?n.push(``,e.outcome.ok?o(`app.promotion.text.deployed`,{message:e.outcome.message}):o(`app.promotion.text.deployFailed`,{message:e.outcome.message.split(`
2
+ `)[0]}),...e.outcome.lines):!e.wrote&&t.blockers.length===0?n.push(``,t.files.length===0?o(`app.promotion.text.nothingToPromote`):o(`app.promotion.text.runWrite`,{from:t.from.name,to:t.to.name})):e.wrote&&t.files.length===0&&t.blockers.length===0&&n.push(``,o(`app.promotion.text.nothingToPromote`)),n}async function m(n,i,a={}){if(!u(n)||!d(n).isDirectory())return{ok:!1,lines:[o(`app.cli.web.notAFolder`,{folder:n})],code:2};let s=e(n).root,c=await t(s,{environment:i.environment,against:i.against},a),l=i.format===`json`;if(c.report===null)return{ok:!1,lines:l?[JSON.stringify(c,null,2)]:c.refused,code:2,refused:!0};let p=c.report.environments.some(e=>e.status!==`read`),m=r(c.report);return{ok:m,refused:!1,code:p?2:+!m,lines:l?[JSON.stringify(c,null,2)]:f(c.report)}}async function h(t,r,i={}){if(!u(t)||!d(t).isDirectory())return{ok:!1,lines:[o(`app.cli.web.notAFolder`,{folder:t})],code:2};if(r.from===void 0||r.to===void 0)return{ok:!1,lines:[o(`app.promotion.promote.needsBoth`)],code:2};let a=e(t).root,s=r.write&&!r.dryRun,c=await n({root:a,from:r.from,to:r.to,write:s,confirm:r.confirm,approveFile:r.approveFile},i);return c.plan===null?{ok:!1,lines:r.format===`json`?[JSON.stringify({refused:c.refused},null,2)]:c.refused,code:c.code,refused:!0}:r.format===`json`?{ok:c.ok,refused:!1,code:c.code,lines:[JSON.stringify({plan:c.plan,wrote:c.wrote,deployed:c.outcome?{ok:c.outcome.ok,message:c.outcome.message,definitions:c.outcome.definitions}:null},null,2)]}:{ok:c.ok,refused:!1,code:c.code,lines:p(c)}}export{m as driftCommand,h as promoteCommand};
@@ -0,0 +1 @@
1
+ import{M as e,P as t,_ as n,m as r,s as i}from"./chunk-load-rfn3E0t5.js";import{b as a,g as o}from"./chunk-engine-CxgdJ2wO.js";import{g as s,i as c,l,p as u,r as d}from"./chunk-deploy-DZgCTgaY.js";import{r as f}from"./chunk-translator-DNm9zRpP.js";import{n as p,r as m}from"./chunk-templateDiagnostics-6txfKwas.js";import{a as h,o as g}from"./chunk-xml-rMelkRIV.js";import{i as _}from"./chunk-normalise-C2VYP6jn.js";import{a as v,i as y,t as b}from"./chunk-context-rCJvBM9p.js";import{t as x}from"./chunk-connections-D_wC6d0W.js";import{t as S}from"./chunk-atomicWrite-C6J1gDtO.js";import{t as C}from"./chunk-diagrams-CtGMGTa8.js";import{p as w}from"./chunk-license-BG88gpDZ.js";import{i as ee,n as te}from"./chunk-policyGate-BOgKsqLq.js";import T from"node:path";import{existsSync as E,lstatSync as D,readFileSync as O}from"node:fs";const k=2e3,A=/* @__PURE__ */ new Set([`version`,`environment`,`files`,`approvedBy`,`approvedAt`,`validUntil`,`note`]);function j(e,t){return typeof e==`string`&&e.trim()!==``&&e.length<=t?e.trim():null}function M(e){let t=j(e,40);if(t===null||!/^\d{4}-\d{2}-\d{2}T/.test(t))return null;let n=Date.parse(t);return Number.isFinite(n)?n:null}function N(e){if(e.length>262144)return{reasons:[f(`app.promotion.approval.tooLarge`)]};let t;try{t=JSON.parse(e)}catch{return{reasons:[f(`app.promotion.approval.notJson`)]}}if(typeof t!=`object`||!t||Array.isArray(t))return{reasons:[f(`app.promotion.approval.notObject`)]};let n=t,r=[];for(let e of Object.keys(n))A.has(e)||r.push(f(`app.promotion.approval.unknownKey`,{key:e.slice(0,40)}));n.version!==1&&r.push(f(`app.promotion.approval.version`));let i=j(n.environment,200),a=j(n.approvedBy,200),o=M(n.approvedAt)===null?null:j(n.approvedAt,40),s=M(n.validUntil)===null?null:j(n.validUntil,40);i===null&&r.push(f(`app.promotion.approval.missing`,{field:`environment`})),a===null&&r.push(f(`app.promotion.approval.missing`,{field:`approvedBy`})),o===null&&r.push(f(`app.promotion.approval.missing`,{field:`approvedAt`})),s===null&&r.push(f(`app.promotion.approval.missing`,{field:`validUntil`}));let c=/* @__PURE__ */ new Map,l=n.files;if(typeof l!=`object`||!l||Array.isArray(l))r.push(f(`app.promotion.approval.missing`,{field:`files`}));else{let e=Object.keys(l);e.length>2e3&&r.push(f(`app.promotion.approval.tooManyFiles`,{limit:k}));for(let t of e.slice(0,k)){let e=l[t];typeof e!=`string`||!/^[0-9a-f]{64}$/.test(e)?r.push(f(`app.promotion.approval.badHash`,{file:t.slice(0,120)})):c.set(t,e)}}return r.length>0||i===null||a===null||o===null||s===null?{reasons:r}:{environment:i,files:c,approvedBy:a,approvedAt:o,validUntil:s}}function P(e,t){let n=N(e);if(`reasons`in n)return{ok:!1,reasons:n.reasons,approvedBy:null,approvedAt:null,validUntil:null};let r=[];n.environment!==t.environment&&r.push(f(`app.promotion.approval.otherEnvironment`,{approved:n.environment.slice(0,80),target:t.environment}));let i=Date.parse(n.approvedAt),a=Date.parse(n.validUntil),o=t.now.getTime();a<=i?r.push(f(`app.promotion.approval.windowBackwards`)):a-i>2592e6&&r.push(f(`app.promotion.approval.windowTooLong`,{days:30})),i>o+3e5&&r.push(f(`app.promotion.approval.inTheFuture`)),o>a&&r.push(f(`app.promotion.approval.expired`,{until:n.validUntil}));for(let e of t.files){let t=n.files.get(e.name);t===void 0?r.push(f(`app.promotion.approval.fileNotApproved`,{file:e.name})):t!==e.hash&&r.push(f(`app.promotion.approval.fileChanged`,{file:e.name}))}return t.files.length===0&&r.push(f(`app.promotion.approval.nothingToApprove`)),{ok:r.length===0,reasons:r,approvedBy:n.approvedBy,approvedAt:n.approvedAt,validUntil:n.validUntil}}const F={"Camunda Cloud":`camunda-8`,"Camunda Platform":`camunda-7`};function I(e){let t=/^\s*v?(\d+)\.(\d+)/.exec(e);return t?Number(t[1])*1e3+Number(t[2]):null}function L(e){try{let t=g(e.replace(/^/,``)),n=e=>{let n=Object.keys(t.attrs).find(t=>t.endsWith(`:${e}`));return n!==void 0&&t.attrs[n].trim()!==``?t.attrs[n].trim():null},r=/* @__PURE__ */ new Set,i=[t];for(let e=i.pop();e;e=i.pop()){for(let[t,n]of Object.entries(e.attrs))t.endsWith(`:modelerTemplate`)&&n!==``&&r.add(n);i.push(...e.children)}return{platform:n(`executionPlatform`),version:n(`executionPlatformVersion`),templates:[...r].sort()}}catch{return{platform:null,version:null,templates:[]}}}function ne(e){try{let t=[g(e.replace(/^/,``))],n=!1,r=!1;for(let e=t.pop();e;e=t.pop()){let i=[e.ns,...Object.keys(e.attrs).filter(e=>e.includes(`:`)&&!e.startsWith(`xmlns:`)).map(t=>e.scope.get(t.slice(0,t.indexOf(`:`)))??``)];i.includes(`http://camunda.org/schema/zeebe/1.0`)&&(n=!0),i.includes(`http://camunda.org/schema/1.0/bpmn`)&&(r=!0),t.push(...e.children)}return n===r?null:n?`camunda-8`:`camunda-7`}catch{return null}}function re(e,t,n){let r=[],i=n.version===null?null:I(n.version),a=/* @__PURE__ */ new Map;for(let e of t)a.has(e.id)||a.set(e.id,e.range);for(let t of e){if(!/\.bpmn$/i.test(t.file)&&!/\.bpmn20\.xml$/i.test(t.file))continue;let e=L(t.text),o=(e.platform===null?null:F[e.platform]??null)??(e.platform===null?ne(t.text):null);if(o!==null&&n.family!==null&&o!==n.family)r.push({severity:`error`,code:`family`,file:t.file,subject:e.platform??(o===`camunda-8`?`Camunda Cloud`:`Camunda Platform`),found:o,wanted:n.family});else if(e.version!==null&&n.version!==null&&n.family===o){let a=I(e.version);a===null||i===null?r.push({severity:`warning`,code:`unknown-version`,file:t.file,subject:`executionPlatformVersion`,found:e.version,wanted:n.version}):a>i&&r.push({severity:`error`,code:`newer`,file:t.file,subject:`executionPlatformVersion`,found:e.version,wanted:n.version})}if(n.version!==null)for(let i of e.templates){let e=a.get(i);e!==void 0&&m(n.version,e)===!1&&r.push({severity:`error`,code:`template`,file:t.file,subject:i,found:e,wanted:n.version})}}return r}const ie=[`in-sync`,`local-ahead`,`engine-ahead`,`differs`,`only-local`,`only-engine`];function R(e,t){return`${e}:${t}`}function ae(e,t,n,r){return r.local&&!r.engine?`only-local`:r.local?e!==null&&t!==null&&e===t?`in-sync`:n===null||t===null||e===null?`differs`:e===n&&t!==n?`engine-ahead`:t===n&&e!==n?`local-ahead`:`differs`:`only-engine`}function oe(e){return new Set(e.resources.map(e=>R(e.kind,e.key)))}function se(e,t,n=null){let r=/* @__PURE__ */ new Map;for(let t of e.resources)r.set(R(t.kind,t.key),{kind:t.kind,key:t.key,file:t.file,localHash:t.hash,readable:t.readable,cells:{}});for(let e of t)if(e.snapshot!==null)for(let t of e.snapshot.definitions){let e=R(t.kind,t.key);r.has(e)||r.set(e,{kind:t.kind,key:t.key,file:null,localHash:null,readable:!0,cells:{}})}let i=Object.fromEntries(ie.map(e=>[e,0]));for(let[e,n]of r)for(let r of t){let t=r.column.name;if(r.snapshot===null){n.cells[t]=null;continue}let a=r.snapshot.definitions.find(t=>R(t.kind,t.key)===e),o={local:n.file!==null,engine:a!==void 0},s={state:ae(n.localHash,a?.hash??null,r.records[e]?.hash??null,o),version:a?.version??null,engineHash:a?.hash??null};n.cells[t]=s,i[s.state]+=1}let a=[...r.values()].sort((e,t)=>e.kind===t.kind?e.key<t.key?-1:+(e.key>t.key):e.kind<t.kind?-1:1);return{environments:t.map(e=>e.column),rows:a,duplicates:e.duplicates,forms:e.files.filter(e=>e.kind===`form`).map(e=>e.file),unreadable:e.files.filter(e=>!e.readable).map(e=>e.file),comparison:n===null?null:ce(a,n.a,n.b),counts:i}}function ce(e,t,n){let r=[];for(let i of e){let e=i.cells[t],a=i.cells[n];if(e===void 0||a===void 0)continue;let o=e!==null&&e.state!==`only-local`,s=a!==null&&a.state!==`only-local`;if(!o&&!s)continue;let c;c=o&&!s?`only-a`:!o&&s?`only-b`:e?.engineHash!==null&&e?.engineHash===a?.engineHash?`same`:`different`,o&&s&&i.file===null||r.push({kind:i.kind,key:i.key,state:c})}return{a:t,b:n,rows:r}}function le(e){return e.duplicates.length>0||e.unreadable.length>0||e.environments.some(e=>e.status!==`read`)||e.comparison?.rows.some(e=>e.state!==`same`)?!1:e.rows.every(e=>Object.values(e.cells).every(e=>e===null||e.state===`in-sync`))}var z=class extends Error{unreachable;constructor(e,t=!1){super(e),this.name=`EngineReadRefused`,this.unreachable=t}};function B(e,t){return e===0?new z(f(`app.promotion.read.unreachable`,{reason:t.slice(0,200)}),!0):e===401||e===403?new z(f(`app.promotion.read.credentials`,{status:e})):new z(f(`app.promotion.read.status`,{status:e}))}async function V(e,t){let n=await e(t);if(n.status<200||n.status>=300)throw B(n.status,n.body);try{return JSON.parse(n.body)}catch{throw new z(f(`app.promotion.read.notJson`))}}function H(e){return typeof e==`string`&&e!==``?e:null}function U(e){let t=Number(e??0);return Number.isFinite(t)?t:0}async function ue(e,t){try{return H(e===`CAMUNDA_8`?(await V(t,{method:`GET`,path:`/topology`}))?.gatewayVersion:(await V(t,{method:`GET`,path:`/version`}))?.version)}catch(e){if(e instanceof z&&e.unreachable)throw e;return null}}async function de(e,t,n,r){let i=e===`process`?`/process-definition`:`/decision-definition`,a=n.tenantId?`&tenantIdIn=${encodeURIComponent(n.tenantId)}`:`&withoutTenantId=true`,o=[];for(let n=0;;n+=100){let s=await V(t,{method:`GET`,path:`${i}?latestVersion=true&sortBy=key&sortOrder=asc&firstResult=${n}&maxResults=100${a}`});if(!Array.isArray(s))throw new z(f(`app.promotion.read.notJson`));for(let t of s){let n=H(t?.key),r=H(t?.id);n!==null&&r!==null&&o.push({kind:e,key:n,id:r,version:U(t?.version),resource:H(t?.resource)})}if(o.length>r)throw new z(f(`app.promotion.read.tooMany`,{limit:r}));if(s.length<100)return o}}async function fe(e,t,n,r){let i=e===`process`?`/process-definitions`:`/decision-definitions`,a=[],o=null;for(;;){let s=e===`process`?{isLatestVersion:!0}:{};n.tenantId&&(s.tenantId=n.tenantId);let c=o===null?{limit:100}:{limit:100,after:o},l=await V(t,{method:`POST`,path:`${i}/search`,body:JSON.stringify({filter:s,page:c})}),u=Array.isArray(l?.items)?l.items:[];for(let t of u){let n=H(e===`process`?t.processDefinitionId:t.decisionDefinitionId),r=H(e===`process`?t.processDefinitionKey:t.decisionDefinitionKey);n!==null&&r!==null&&a.push({kind:e,key:n,id:String(r),version:U(t.version),resource:H(t.resourceName)})}if(a.length>r)throw new z(f(`app.promotion.read.tooMany`,{limit:r}));let d=l?.page?.endCursor;if(u.length<100)return e===`process`?a:pe(a);if(typeof d!=`string`||d===``||d===o)throw new z(f(`app.promotion.read.notJson`));o=d}}function pe(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.key);(!e||n.version>e.version)&&t.set(n.key,n)}return[...t.values()]}async function me(e,t,n){let r=encodeURIComponent(t.id);if(e===`CAMUNDA_8`){let e=await n({method:`GET`,path:`/${t.kind}-definitions/${r}/xml`});if(e.status<200||e.status>=300)throw B(e.status,e.body);let i=e.body.trim();if(i.startsWith(`{`))try{let e=JSON.parse(i);if(typeof e.xml==`string`)return e.xml}catch{return e.body}return e.body}let i=await V(n,{method:`GET`,path:`/${t.kind}-definition/${r}/xml`}),a=t.kind===`process`?i?.bpmn20Xml:i?.dmnXml;if(typeof a!=`string`)throw new z(f(`app.promotion.read.noResource`,{key:t.key}));return a}async function he(e,t){let n=Array(e.length),r=0;return await Promise.all(Array.from({length:Math.min(4,e.length)},async()=>{for(;;){let i=r;if(r+=1,i>=e.length)return;n[i]=await t(e[i])}})),n}async function ge(e,t,n={}){let r=n.maxDefinitions??2e3,i=e===`CAMUNDA_8`?fe:de,a=await ue(e,t),o=[...await i(`process`,t,n,r),...await i(`decision`,t,n,r)],s=n.wanted??null,c=o.filter(e=>s===null||s.has(`${e.kind}:${e.key}`));if(c.length>(n.maxFetched??400))throw new z(f(`app.promotion.read.tooManyToRead`,{limit:n.maxFetched??400}));let l=/* @__PURE__ */ new Map;return await he(c,async n=>{let r=await me(e,n,t);if(r.length>20971520)throw new z(f(`app.promotion.read.tooLarge`,{key:n.key}));l.set(`${n.kind}:${n.key}`,_(n.kind,r))}),{version:a,definitions:o.map(e=>{let t=l.get(`${e.kind}:${e.key}`);return{...e,hash:t?.hash??null,readable:t?.readable??!1}})}}function _e(e){return/\.bpmn$/i.test(e)||/\.bpmn20\.xml$/i.test(e)?`process`:/\.dmn$/i.test(e)||/\.dmn11\.xml$/i.test(e)?`decision`:/\.form$/i.test(e)?`form`:null}function ve(e,t){if(e===`form`)return[];try{let n=g(t.replace(/^/,``)),r=e===`process`?`process`:`decision`;return[n,...h(n,r)].filter(e=>e.local===r).filter(t=>e!==`process`||t.attrs.isExecutable!==`false`).map(e=>e.attrs.id).filter(e=>typeof e==`string`&&e!==``)}catch{return null}}function W(e){let t=[],n=[],r=/* @__PURE__ */ new Map;for(let t of[...e].sort((e,t)=>e.path<t.path?-1:1)){let e=_e(t.path);if(e===null)continue;let{hash:i,readable:a}=_(e,t.text),o=ve(e,t.text);if(n.push({file:t.path,kind:e,hash:i,readable:a&&o!==null,keys:o??[]}),e!==`form`&&o!==null)for(let n of o){let o={kind:e,key:n,file:t.path,hash:i,readable:a},s=`${o.kind}:${n}`;r.set(s,[...r.get(s)??[],o])}}let i=[];for(let e of r.values())t.push(e[0]),e.length>1&&i.push({kind:e[0].kind,key:e[0].key,files:e.map(e=>e.file)});return{resources:t,files:n,duplicates:i}}function ye(e,t,n,r){let i=[],a=[];for(let o of r){let r=e.files.find(e=>e.file===o);if(r===void 0||!r.readable){a.push(o);continue}let s;if(r.kind===`form`)s=n[`form:${r.file}`]?.hash===r.hash;else{let n=e.resources.filter(e=>e.file===r.file);s=n.length>0&&n.length===r.keys.length&&n.every(e=>t.definitions.some(t=>t.kind===e.kind&&t.key===e.key&&t.hash===e.hash))}s?i.push({file:o,reason:f(`app.promotion.onlyChanged.unchanged`)}):a.push(o)}return{send:a,skipped:i,note:null}}const G=`.penstock/deployments.json`,be=5e3;function xe(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.hash==`string`&&/^[0-9a-f]{64}$/.test(t.hash)&&typeof t.at==`string`&&t.at.length<=40&&(t.version===null||typeof t.version==`number`)}function Se(e){let t={version:1,environments:Object.create(null)},r=T.join(e,G);try{let i=D(r);if(i.isSymbolicLink()||!i.isFile()||i.size>4194304||!n(r,[e]))return t;let a=JSON.parse(O(r,`utf8`));if(a.version!==1||a.environments===null||typeof a.environments!=`object`||Array.isArray(a.environments))return t;let o={version:1,environments:Object.create(null)};for(let e of Object.keys(a.environments).slice(0,100)){let t=a.environments[e];if(typeof t!=`object`||!t||Array.isArray(t))continue;let n=Object.create(null);for(let e of Object.keys(t).slice(0,be)){let r=t[e];xe(r)&&(n[e]={hash:r.hash,version:r.version,at:r.at})}o.environments[e]=n}return o}catch{return t}}function K(e,t){return Se(e).environments[t]??Object.create(null)}function Ce(e,t,r,i=/* @__PURE__ */ new Date){if(r.length===0)return!0;let a=T.join(e,G);if(!n(a,[e])||E(a)&&D(a).isSymbolicLink())return!1;let o=Se(e),s=Object.create(null);for(let e of Object.keys(o.environments[t]??{}))s[e]=o.environments[t][e];let c=!1;for(let e of r){let t=s[e.key];(t===void 0||t.hash!==e.hash||e.version!==null&&t.version!==e.version)&&(s[e.key]={hash:e.hash,version:e.version,at:i.toISOString()},c=!0)}if(!c)return!0;if(Object.keys(s).length>be)return!1;let l=Object.create(null);for(let e of Object.keys(o.environments))l[e]=e===t?s:o.environments[e];if(t in l||(l[t]=s),Object.keys(l).length>100)return!1;let u=Object.create(null);for(let e of Object.keys(l).sort()){u[e]=Object.create(null);for(let t of Object.keys(l[e]).sort())u[e][t]=l[e][t]}return S(a,`${JSON.stringify({version:1,environments:u},null,2)}\n`),!0}const we=`default`,Te=5e3,Ee=[`PENSTOCK_DEPLOYMENT_URL`,`PENSTOCK_DEPLOYMENT_TENANTID`,`PENSTOCK_DEPLOYMENT_FORTESTS`];var q=class extends Error{};function J(e){try{let t=new URL(e);return`${t.protocol}//${t.host}${t.pathname.replace(/\/+$/,``)}`}catch{let t=e.includes(`://`)?e.slice(e.indexOf(`://`)+3):e;return t.split(`/`)[0].slice(t.split(`/`)[0].lastIndexOf(`@`)+1)}}function De(e,t){let n={};for(let[t,r]of Object.entries(e))Ee.includes(t.toUpperCase())||(n[t]=r);return t===null?delete n.PENSTOCK_PROFILE:n.PENSTOCK_PROFILE=t,n}function Y(e,t,n,r){return{name:e,place:t===null?null:J(t.url),engine:t?.engine??null,engineVersion:null,status:n,reason:r,protected:t?.protected??!1,forTests:t?.forTests??!1}}function X(n,r=process.env){let s=b(n).merged,c=y(s.profiles),l=[],d=(e,t,s)=>{let c=i(n,De(r,t)),d=u(c.values),p=`read`,m=null;d===null||!s?(p=`not-configured`,m=f(d===null?`app.promotion.environment.noUrl`:`app.promotion.environment.inheritedUrl`)):(o(d.engine)||a(d.engine)===null)&&(p=`refused`,m=f(`app.promotion.environment.noEngineApi`)),l.push({name:e,target:s?d:null,column:Y(e,s?d:null,p,m)})};for(let e of t(s))d(e,e,v(y(y(c[e]).deployment).url)!==void 0);return e(s,De(r,null))===null&&v(y(s.deployment).url)!==void 0&&d(we,null,!0),l}function Oe(t,n=process.env){return e(b(t).merged,n)??`default`}function Z(e){let t=C(e,[`process`,`decision`,`form`]);if(t.length>5e3)throw new q(f(`app.promotion.project.tooMany`,{limit:Te}));let r=[],i=[];for(let a of t){let t=T.relative(e,a).split(T.sep).join(`/`);try{let o=D(a);if(o.isSymbolicLink()||!o.isFile()||o.size>20971520||!n(a,[e])){i.push(t);continue}r.push({path:t,text:O(a,`utf8`)})}catch{i.push(t)}}return{files:r,refused:i}}async function Q(e,t,n,r){let i=e.column,a=e.target;if(a===null||i.status===`not-configured`||i.status===`refused`)return{column:i,snapshot:null,records:n};let o=r.askFor?{problem:null}:c(a.auth,r.env??process.env);if(o.problem)return{column:{...i,status:`refused`,reason:o.problem},snapshot:null,records:n};let s=(r.askFor??(e=>d(e)))(a,e.name);try{let e=await ge(l(a),s,{tenantId:a.tenantId??null,wanted:oe(t)});return{column:{...i,engineVersion:e.version},snapshot:e,records:n}}catch(e){if(e instanceof z)return{column:{...i,status:e.unreachable?`unreachable`:`refused`,reason:e.message},snapshot:null,records:n};throw e}}async function ke(e,t={}){let n=X(e.root,t.env??process.env),r=[...e.environments,...e.against===void 0?[]:[e.against]],i=r.filter(e=>!n.some(t=>t.name===e));if(i.length>0||r.length===0)return{report:null,refused:[r.length===0?f(`app.promotion.drift.needsEnvironment`,{known:n.map(e=>e.name).join(`, `)||`-`}):f(`app.promotion.environment.unknown`,{name:i[0].slice(0,60),known:n.map(e=>e.name).join(`, `)||`-`})]};let a;try{a=W(Z(e.root).files)}catch(e){if(e instanceof q)return{report:null,refused:[e.message]};throw e}let o=[];for(let i of[...new Set(r)]){let r=n.find(e=>e.name===i);o.push(await Q(r,a,K(e.root,i),t))}let s=e.against===void 0?null:{a:e.environments[0],b:e.against};return{report:se(a,o,s),refused:[]}}function Ae(t,n){let r=X(t,n),i=e(b(t).merged,n);return r.length===1?r[0].name:i!==null&&r.some(e=>e.name===i)?i:r.find(e=>e.name==="default")?.name??null}async function je(e,t,n={}){let r=n.env??process.env,i=X(e,r).map(e=>e.name),a=t.environment??Ae(e,r);if(a===null)return{declared:i,selected:a,report:null,refused:[f(`app.promotion.drift.needsEnvironment`,{known:i.join(`, `)||`-`})]};let o=await ke({root:e,environments:[a],against:t.against},n);return{declared:i,selected:a,report:o.report,refused:o.refused}}function Me(e,t){let r=T.resolve(e,t);try{let t=D(r);return t.isSymbolicLink()||!t.isFile()||!n(r,[e])?{reason:f(`app.promotion.approval.outside`)}:t.size>262144?{reason:f(`app.promotion.approval.tooLarge`)}:{text:O(r,`utf8`)}}catch{return{reason:f(`app.promotion.approval.unreadable`)}}}function Ne(e,t={}){let n=w(t.env??process.env),r={protected:e.isProtected,confirmed:!1,inPipeline:n,approval:null},i=[];if(!e.isProtected||(r.confirmed=e.confirm===e.name,r.confirmed||i.push(f(`app.promotion.promote.needsConfirm`,{name:e.name})),!n))return{protection:r,blockers:i};if(e.approveFile===void 0)return i.push(f(`app.promotion.promote.needsApproval`,{name:e.name})),{protection:r,blockers:i};let a=Me(e.root,e.approveFile),o=`reason`in a?{ok:!1,reasons:[a.reason],approvedBy:null,approvedAt:null,validUntil:null}:P(a.text,{environment:e.name,files:e.files,now:(t.now??(()=>/* @__PURE__ */ new Date))()});return r.approval={...o,file:e.approveFile},o.ok||i.push(f(`app.promotion.promote.approvalRefused`,{file:e.approveFile}),...o.reasons.map(e=>` ${e}`)),{protection:r,blockers:i}}function Pe(e){return e.slice(e.lastIndexOf(`/`)+1)}async function Fe(e,t,n){let r=x(e,{environment:t}),i=new Set(n),a=r.rows.filter(e=>e.uses.some(e=>i.has(e.file))),o=e=>a.filter(t=>t.status===e).map(e=>({kind:e.kind,name:e.name}));return{checked:!0,missing:o(`undefined`),unverifiable:o(`unverifiable`)}}async function Ie(e,t={}){let n=t.env??process.env,i=/* @__PURE__ */ new Map,o=X(e.root,n),s=o.find(t=>t.name===e.from),c=o.find(t=>t.name===e.to),l=o.map(e=>e.name).join(`, `)||`-`,u=(...e)=>({plan:null,refused:e,code:2,contents:i});if(!s)return u(f(`app.promotion.environment.unknown`,{name:e.from.slice(0,60),known:l}));if(!c)return u(f(`app.promotion.environment.unknown`,{name:e.to.slice(0,60),known:l}));if(s.name===c.name)return u(f(`app.promotion.promote.sameEnvironment`));if(s.target&&c.target&&s.target.url===c.target.url&&(s.target.tenantId??``)===(c.target.tenantId??``))return u(f(`app.promotion.promote.sameEngine`,{place:J(c.target.url)}));for(let e of[s,c])if(e.column.status!==`read`)return u(f(`app.promotion.promote.notReady`,{name:e.name,reason:e.column.reason??``}));let d;try{d=Z(e.root)}catch(e){if(e instanceof q)return u(e.message);throw e}let m=W(d.files);for(let e of d.files)i.set(e.path,e.text);let h=K(e.root,s.name),[g,v]=[await Q(s,m,h,t),await Q(c,m,K(e.root,c.name),t)];for(let e of[g,v])if(e.snapshot===null)return u(f(`app.promotion.promote.notRead`,{name:e.column.name,reason:e.column.reason??``}));let y=se(m,[g,v]),x=[];for(let e of y.rows){if(e.file===null)continue;let t=e.cells[s.name],n=e.cells[c.name],r={kind:e.kind,key:e.key,file:e.file,fromVersion:t?.version??null,toVersion:n?.version??null};t==null||t.state!==`in-sync`?x.push({...r,action:`skipped`,reason:f(`app.promotion.promote.notVerified`,{from:s.name,state:f(`app.promotion.state.${t?.state??`only-local`}`)})}):n?.state===`in-sync`?x.push({...r,action:`unchanged`,reason:null}):x.push({...r,action:n?.state===`only-local`||n==null?`create`:`update`,reason:null})}let S=m.files.filter(e=>e.kind===`form`).map(e=>{let t=h[`form:${e.file}`];return t!==void 0&&t.hash===e.hash&&e.readable?{file:e.file,action:`send`,reason:null}:{file:e.file,action:`skipped`,reason:f(`app.promotion.promote.formNotRecorded`,{from:s.name})}}),C=[.../* @__PURE__ */ new Set([...x.filter(e=>e.action===`create`||e.action===`update`).map(e=>e.file),...S.filter(e=>e.action===`send`).map(e=>e.file)])].sort(),E=[],D=/* @__PURE__ */ new Map;for(let e of C){let t=Pe(e),n=D.get(t);n!==void 0&&n!==e&&E.push(f(`app.promotion.promote.sameFileName`,{name:t,first:n,second:e})),D.set(t,e)}for(let e of y.duplicates)E.push(f(`app.promotion.promote.duplicate`,{key:e.key,files:e.files.join(`, `)}));for(let e of y.unreadable)C.includes(e)&&E.push(f(`app.promotion.promote.unreadable`,{file:e}));let O=a(c.target?.engine)?.family??null,k=p(e.root).flatMap(e=>{try{let t=JSON.parse(e.text);return(Array.isArray(t)?t:[t]).flatMap(e=>{let t=e;return t&&typeof t.id==`string`&&typeof t.engines?.camunda==`string`?[{id:t.id,range:t.engines.camunda}]:[]})}catch{return[]}}),A=re(C.map(e=>({file:e,text:i.get(e)??``})),k,{family:O===`camunda-7`||O===`camunda-8`?O:null,version:v.column.engineVersion});for(let e of A)e.severity===`error`&&E.push(f(`app.promotion.compat.${e.code}`,{file:e.file,subject:e.subject,found:e.found,wanted:e.wanted,target:c.name}));let j=await Fe(e.root,c.name,C);for(let e of j.missing)E.push(f(`app.promotion.promote.secretMissing`,{name:e.name,target:c.name}));let M=w(n),N=b(e.root).policy??r(e.root,b(e.root).own),P={present:N.present,name:N.name,version:N.version,pin:N.present?N.pin:null,enforced:M&&N.present,ok:null,problems:[]};if(N.present){let n=await(t.checkOk??Le)(C.map(t=>T.join(e.root,t)).filter(e=>/\.(bpmn|dmn|form)$/i.test(e))),r=te({root:e.root,status:N,own:b(e.root).own,rules:ee(e.root,b(e.root).own),checkOk:n});P.ok=r.ok,P.problems=r.problems,M&&!r.ok&&E.push(f(`app.promotion.promote.policyFailed`,{name:N.name??``,version:N.version??0}))}let F=C.map(e=>({name:e,hash:_(/\.form$/i.test(e)?`form`:/\.dmn$/i.test(e)?`decision`:`process`,i.get(e)??``).hash})),I=Ne({root:e.root,name:c.name,isProtected:c.column.protected,files:F,confirm:e.confirm,approveFile:e.approveFile},t),L=I.protection;return E.push(...I.blockers),{plan:{from:g.column,to:v.column,items:x,forms:S,files:C,secrets:j,compatibility:A,policy:P,protection:L,blockers:E,deployable:E.length===0&&C.length>0},refused:[],code:+(E.length>0),contents:i}}async function Le(e){if(e.length===0)return!0;let{checkCommand:t,sectionsOf:n}=await import(`./chunk-commands-CJCSznbv.js`);try{return(await t(e,{format:`json`,baseline:!1,updateBaseline:!1,sections:n(void 0).sections})).ok}catch{return!1}}function $(e,t,n){let r=[];for(let i of e.resources){if(!t.includes(i.file)||!i.readable)continue;let e=n?.definitions.find(e=>e.kind===i.kind&&e.key===i.key);r.push({key:R(i.kind,i.key),hash:i.hash,version:e?.version??null})}for(let n of e.files)n.kind===`form`&&n.readable&&t.includes(n.file)&&r.push({key:`form:${n.file}`,hash:n.hash,version:null});return r}async function Re(e,t={}){let n=await Ie(e,t);if(n.plan===null)return{ok:!1,code:n.code,refused:n.refused,plan:null,outcome:null,wrote:!1};let r=n.plan;if(!e.write)return{ok:r.blockers.length===0,code:n.code,refused:[],plan:r,outcome:null,wrote:!1};if(r.blockers.length>0)return{ok:!1,code:1,refused:[],plan:r,outcome:null,wrote:!1};if(r.files.length===0)return{ok:!0,code:0,refused:[],plan:r,outcome:null,wrote:!1};let i=X(e.root,t.env??process.env),a=i.find(t=>t.name===e.to);if(!a||a.target===null)return{ok:!1,code:2,refused:[f(`app.promotion.environment.unknown`,{name:e.to.slice(0,60),known:i.map(e=>e.name).join(`, `)})],plan:r,outcome:null,wrote:!1};let o=a.target,c=r.files.map(e=>({name:Pe(e),content:n.contents.get(e)??``})),u=(t.askFor??(e=>d(e)))(o,e.to),p=await(t.deployer??s)({engine:l(o),name:o.name,source:o.source,tenantId:o.tenantId??null,changedOnly:!0},c,{ask:u,wait:!0});if(p.ok){let i=W([...n.contents].map(([e,t])=>({path:e,text:t})));Ce(e.root,e.to,$(i,r.files,p),(t.now??(()=>/* @__PURE__ */ new Date))())}return{ok:p.ok,code:+!p.ok,refused:[],plan:r,outcome:p,wrote:!0}}async function ze(e,t,n,r,i={}){let a=r.map(e=>T.resolve(e)),o=[];for(let t of a)try{let n=D(t);if(n.isSymbolicLink()||!n.isFile()||n.size>20971520)continue;o.push({path:T.relative(e,t).split(T.sep).join(`/`),text:O(t,`utf8`)})}catch{continue}let s=W(o),c=K(e,t),l=await Q({name:t,target:n,column:Y(t,n,`read`,null)},s,c,i),u=l.snapshot,d=e=>({send:r,skipped:[],note:e});if(u===null&&s.resources.length>0)return d(f(`app.promotion.onlyChanged.notCompared`,{reason:l.column.reason??``}));if(u===null)return{send:r,skipped:[],note:null};let p=r.map(t=>T.relative(e,T.resolve(t)).split(T.sep).join(`/`)),m=ye(s,u,c,p),h=new Set(m.send);return{send:r.filter((e,t)=>h.has(p[t])),skipped:r.flatMap((e,t)=>h.has(p[t])?[]:[{file:e,reason:f(`app.promotion.onlyChanged.unchanged`)}]),note:null}}function Be(e,t,n,r){let i=[];for(let t of n)try{let n=D(t);if(n.isSymbolicLink()||!n.isFile()||n.size>20971520)continue;i.push({path:T.relative(e,T.resolve(t)).split(T.sep).join(`/`),text:O(t,`utf8`)})}catch{continue}Ce(e,t,$(W(i),i.map(e=>e.path),r))}export{$ as _,je as a,X as c,Ie as d,Re as f,Be as g,Z as h,Ae as i,ze as l,Q as m,Te as n,ke as o,Ne as p,q as r,Oe as s,we as t,J as u,le as v,ie as y};
@@ -1 +1 @@
1
- export{s as environmentName,l as onlyChanged,p as protect,g as recordAfterDeploy}from"./chunk-promotion-Boedyq43.js";
1
+ export{s as environmentName,l as onlyChanged,p as protect,g as recordAfterDeploy}from"./chunk-promotion-DDLrgBqZ.js";
@@ -0,0 +1 @@
1
+ import{n as e}from"./chunk-aiVerify-DPNBNhx4.js";import{r as t,t as n}from"./chunk-context-rCJvBM9p.js";import{r}from"./chunk-failure-BRyRvObj.js";import{_ as i,o as a,v as o}from"./chunk-load-rfn3E0t5.js";import{a as s,n as c,o as l,r as u,t as d}from"./chunk-receiptStore-DhROtI2h.js";import{a as f}from"./chunk-build-BsqW8Yp8.js";import{i as p,n as m,r as h,t as g}from"./chunk-say-CP1IyOSv.js";import{r as _}from"./chunk-translator-DNm9zRpP.js";import{l as v,m as y,p as b,r as x}from"./chunk-git-57LoLvY3.js";import{t as S}from"./chunk-receiptDeps-B7MehyHT.js";import C from"node:path";import{existsSync as w,statSync as T}from"node:fs";function E(){return{ok:!1,lines:[_(`app.cli.receipt.usage`)]}}async function D(c,d){if(c.length===0)return{ok:!1,lines:[_(`app.cli.receipt.needsFiles`)]};let p=d.against??`HEAD`;if(!b(p))return{ok:!1,lines:[_(`app.cli.receipt.badRef`,{ref:p.slice(0,80)})]};let m=c.map(e=>C.resolve(e)),E=o(a(m[0])),D=v(E);if(d.against!==void 0&&(!D||x(E,p)===null))return{ok:!1,lines:[_(`app.cli.receipt.unknownRef`,{ref:p})]};let O=[];for(let e of m){if(!i(e,[E]))return{ok:!1,lines:[_(`app.cli.receipt.differentProject`,{file:t(e),root:t(E)})]};let n=w(e);if(n&&!T(e).isFile())return{ok:!1,lines:[_(`app.cli.receipt.notAFile`,{file:t(e)})]};let a=C.relative(E,o(e)).split(C.sep).join(`/`),s=D?y(E,p,a):null;if(!n&&s===null)return{ok:!1,lines:[r(t(e))]};O.push({path:e,before:s})}let k=e(n(E).values),A;try{A=await l(O,{root:E,source:`cli`,maxAttempts:k.attempts,scenarios:d.scenarios,approveExecutable:d.runScenarios===!0},S({scenarios:d.scenarios}))}catch(e){if(e instanceof s)return{ok:!1,lines:[_(`app.cli.receipt.differentProject`,{file:t(e.file),root:t(E)})]};throw e}let j=A.verdict.status===`verified`,M=[];if(d.format===`json`?M.push(JSON.stringify(d.licensed?A:f(A),null,2)):M.push(...d.licensed?h(A):g(f(A))),d.licensed&&(d.write||k.keepReceipts)){let e=u(E,A);d.format===`json`?process.stderr.write(`${_(`app.cli.receipt.written`,{file:t(e)})}\n`):M.push(_(`app.cli.receipt.written`,{file:t(e)}))}return{ok:j,refused:!1,lines:M}}function O(e,n){if(e===void 0)return{ok:!1,lines:[_(`app.cli.receipt.needsReceipt`)]};if(!w(e))return{ok:!1,lines:[r(e)]};let i=o(a(C.dirname(C.resolve(e)))),s=c(i,e);if(`outside`in s)return{ok:!1,lines:[_(`app.cli.receipt.receiptOutside`,{file:t(e)})]};if(`unreadable`in s)return{ok:!1,lines:[_(`app.cli.receipt.receiptUnreadable`,{file:t(e)})]};if(`problems`in s)return{ok:!1,lines:[_(`app.cli.receipt.receiptInvalid`,{file:t(e),problems:m(s.problems)})]};let l=d(s.receipt,i),u=l.length===0;if(n.format===`json`)return{ok:u,refused:!1,lines:[JSON.stringify({ok:u,verdict:s.receipt.verdict.status,files:s.receipt.files.length,mismatches:l},null,2)]};let f=[_(u?`app.cli.receipt.matches`:`app.cli.receipt.differs`,{file:t(e),count:s.receipt.files.length}),p(s.receipt.verdict.status)];for(let e of l)f.push(` ${e.path}: ${_(`app.cli.receipt.mismatch.${e.reason}`)}`);return{ok:u,refused:!1,lines:f}}async function k(e,t){let[n,...r]=e;return n===`verify`?D(r,t):n===`check`?O(r[0],t):E()}export{k as receiptCommand};
@@ -0,0 +1 @@
1
+ import{s as e}from"./chunk-receiptStore-DhROtI2h.js";import{o as t}from"./chunk-model-C5VKsEOw.js";import{u as n}from"./chunk-file-1YhfNmPn.js";import{r}from"./chunk-context-rCJvBM9p.js";import{t as i}from"./chunk-features-C6o8of19.js";import{u as a}from"./chunk-license-BG88gpDZ.js";import{c as o,n as s}from"./chunk-testCases-BwimUfDC.js";import{n as c}from"./chunk-diff-Dp3fUALc.js";import{c as l,s as u}from"./chunk-trust-Di4EYPah.js";import d from"node:path";import{existsSync as f,lstatSync as p,readFileSync as m,readdirSync as h}from"node:fs";function g(e){return d.resolve(n(d.resolve(e)))}function _(e){try{let n=p(e);if(!n.isFile()||n.size>2097152)return[];let r=JSON.parse(m(e,`utf8`));return Array.isArray(r.results)?r.results.flatMap(e=>{let n=e;return typeof n.file==`string`&&typeof n.testCase==`string`&&t.includes(n.outcome)?[{file:n.file,testCase:n.testCase,outcome:n.outcome}]:[]}):[]}catch{return[]}}function v(e){let t=d.join(e,`.penstock`,`runs`);try{return h(t,{withFileTypes:!0}).filter(e=>e.isDirectory()&&f(d.join(t,e.name,`run.json`))).map(e=>e.name).sort().slice(-200)}catch{return[]}}function y(e,t,n){let r=/* @__PURE__ */ new Map;for(let i of[...t].reverse())for(let t of _(d.join(e,`.penstock`,`runs`,i,`run.json`))){let e=`${t.file}\u0000${t.testCase}`;n.has(t.file)&&!r.has(e)&&r.set(e,t.outcome)}return r}function b(e){return{status:`skipped`,reason:e,results:[]}}async function x(e,t,n={}){if(e.length===0)return b(`no-processes`);if(!await(n.licensed??(async()=>i(await a())))())return b(`not-licensed`);let c=e.filter(e=>f(g(e)));if(c.length===0)return b(`no-cases`);let l=n.engineFor??s,u=c.map(e=>l(e));if(u.some(e=>e===null))return b(`no-engine`);if(u.some(e=>!e?.forTests))return b(`not-for-tests`);let p=new Map(c.map(e=>[g(e),e])),m=v(t),h=e=>r(e),x=y(t,m,new Set([...p.keys()].flatMap(e=>[e,h(e)]))),S=n.run??o,C=new AbortController,w=setTimeout(()=>C.abort(),n.runMs??12e4);try{await S(c,{teamcity:!1,write:()=>void 0,confirm:void 0,ci:!1,signal:C.signal})}catch{return b(`failed`)}finally{clearTimeout(w)}let T=v(t).filter(e=>!m.includes(e)),E=T[T.length-1];if(E===void 0)return b(C.signal.aborted?`stopped`:`failed`);let D=/* @__PURE__ */ new Map;for(let[e,t]of p)D.set(e,t),D.set(h(e),t);let O=_(d.join(t,`.penstock`,`runs`,E,`run.json`)).filter(e=>D.has(e.file)).slice(0,100).map(e=>({diagram:d.relative(t,D.get(e.file)).split(d.sep).join(`/`),name:e.testCase.slice(0,400),outcome:e.outcome,previous:x.get(`${e.file}\u0000${e.testCase}`)??null}));return O.length===0?b(C.signal.aborted?`stopped`:`failed`):{status:`ran`,reason:C.signal.aborted?`stopped`:null,results:O}}async function S(t,n,r){let i=await c(t,n,r);return i===null?{unreadable:!0}:{diff:e(i.entries,i.moved)}}function C(e={}){return{projectRulesTrusted:e=>u()||l(e),diffOf:(e,t,n)=>e===`process`||e===`decision`||e===`form`?S(e,t,n):Promise.resolve({unreadable:!0}),...e.scenarios===!1?{}:{scenarios:(e,t)=>x(e,t)}}}export{C as t};
@@ -0,0 +1 @@
1
+ import"./chunk-model-C5VKsEOw.js";import{c as e,i as t,l as n,n as r}from"./chunk-receiptStore-DhROtI2h.js";import{_ as i,v as a}from"./chunk-load-rfn3E0t5.js";import{r as o}from"./chunk-translator-DNm9zRpP.js";import{p as s,s as c,u as l}from"./chunk-git-57LoLvY3.js";import u from"node:path";import{lstatSync as d,readFileSync as f}from"node:fs";const p=/^(co-authored-by|assisted-by):[ \t]*(.*)$/i;function m(e,t){for(let n of e.slice(0,2e4).split(/\r?\n/)){let e=p.exec(n);if(e===null)continue;let r=e[2].toLowerCase();if(t.some(e=>e!==``&&r.includes(e)))return!0}return!1}function h(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n===e||n.startsWith(`${e}/`))}function g(e){return n(e)!==`other`}function _(t,n){if(n===``||u.isAbsolute(n)||n.split(/[\\/]/).includes(`..`)||n.includes(`\0`))return;let r=u.join(t,...n.split(`/`));if(i(r,[t]))try{let t=a(r),n=d(t);return!n.isFile()||n.size>8388608?void 0:e(f(t,`utf8`))}catch{return null}}function v(e,n){let i=a(e),o=Object.create(null),s=0;for(let e of t(i)){let t=r(i,e);if(!(`receipt`in t))s+=1;else for(let e of t.receipt.files)(o[e.path]??=/* @__PURE__ */ new Set).add(e.after)}let c=[],l=[];for(let e of n){let t=_(i,e),n=o[e];t!==void 0&&n!==void 0&&n.has(t)?c.push(e):l.push(e)}return{covered:c,missing:l,invalidReceipts:s}}function y(e){return(e??``).split(`\0`).filter(e=>e!==``).slice(0,5e3)}function b(e,t,n){if(!s(t))return{reason:`badBase`};let r=l(e,t);if(r===null)return{reason:`noHistory`};let i=new Set(y(c(e,[`diff`,`--name-only`,`-z`,r,`HEAD`,`--`]))),a=/* @__PURE__ */ new Set,o=c(e,[`log`,`--max-count=2000`,`--no-merges`,`--format=%H%x1f%B%x1e`,`${r}..HEAD`]);if(o===null)return{reason:`noHistory`};for(let t of o.split(``)){let[r,i]=t.split(``),o=(r??``).trim();if(/^[0-9a-f]{40,64}$/.test(o)&&m(i??``,n.agents))for(let t of y(c(e,[`diff-tree`,`--no-commit-id`,`--name-only`,`-r`,`-z`,`--root`,o])))a.add(t)}for(let e of i)h(e,n.agentPaths)&&a.add(e);return{files:[...a].filter(e=>i.has(e)&&g(e)).sort()}}function x(e,t,n){let r=b(a(e),t,n);if(`reason`in r)return{ok:!1,lines:[o(r.reason===`badBase`?`app.cli.receipt.gateBadBase`:`app.cli.receipt.gateNoHistory`,{base:t.slice(0,80)})]};if(r.files.length===0)return{ok:!0,lines:[o(`app.cli.receipt.gateNone`,{base:t})]};let i=v(e,r.files);if(i.missing.length===0)return{ok:!0,lines:[o(`app.cli.receipt.gateOk`,{count:r.files.length})]};let s=[o(`app.cli.receipt.gateMissing`,{count:i.missing.length})];for(let e of i.missing.slice(0,20))s.push(` ${e}`);return i.missing.length>20&&s.push(` ${o(`app.cli.receipt.gateMore`,{count:i.missing.length-20})}`),i.invalidReceipts>0&&s.push(o(`app.cli.receipt.gateInvalid`,{count:i.invalidReceipts})),s.push(o(`app.cli.receipt.gateHow`)),{ok:!1,lines:s}}export{x as n,b as t};
@@ -0,0 +1 @@
1
+ export{n as requireReceiptGate}from"./chunk-receiptGate-BZCKCMTV.js";
@@ -1,2 +1,2 @@
1
- import{r as e}from"./chunk-translator-DNm9zRpP.js";import"./chunk-model-C5VKsEOw.js";import{_ as t,v as n}from"./chunk-load-rfn3E0t5.js";import{i as r,n as i,r as a}from"./chunk-build-BsqW8Yp8.js";import{l as o}from"./chunk-receiptStore-Cy-L0H1u.js";import s from"node:path";import{lstatSync as c,readFileSync as l,readdirSync as u}from"node:fs";function d(e){return e.filter(e=>e.handedBack).length}function f(e,t,n){let o=a(e).length,s=n.repair&&o>0&&e.maxAttempts>0&&d(t)<e.maxAttempts,c={n:t.length+1,at:(n.now??/* @__PURE__ */ new Date).toISOString(),newErrors:o,newFindings:r(e),handedBack:s},l=[...t,c];return{receipt:{...e,attempts:l,exhausted:i(o,e.maxAttempts,l)},handBack:s}}function p(t){let n=a(t),r=d(t.attempts),i=[e(`app.receipt.repair.intro`,{count:n.length,n:r,max:t.maxAttempts})];for(let t of n.slice(0,20)){let n=t.elements.length===0?``:` (${t.elements.slice(0,5).join(`, `)})`;i.push(e(`app.receipt.repair.line`,{rule:t.rule,file:t.file,where:n,message:t.message}))}return n.length>20&&i.push(e(`app.receipt.repair.more`,{count:n.length-20})),i.push(e(`app.receipt.repair.outro`)),i.join(`
1
+ import{r as e}from"./chunk-translator-DNm9zRpP.js";import"./chunk-model-C5VKsEOw.js";import{_ as t,v as n}from"./chunk-load-rfn3E0t5.js";import{i as r,n as i,r as a}from"./chunk-build-BsqW8Yp8.js";import{l as o}from"./chunk-receiptStore-DhROtI2h.js";import s from"node:path";import{lstatSync as c,readFileSync as l,readdirSync as u}from"node:fs";function d(e){return e.filter(e=>e.handedBack).length}function f(e,t,n){let o=a(e).length,s=n.repair&&o>0&&e.maxAttempts>0&&d(t)<e.maxAttempts,c={n:t.length+1,at:(n.now??/* @__PURE__ */ new Date).toISOString(),newErrors:o,newFindings:r(e),handedBack:s},l=[...t,c];return{receipt:{...e,attempts:l,exhausted:i(o,e.maxAttempts,l)},handBack:s}}function p(t){let n=a(t),r=d(t.attempts),i=[e(`app.receipt.repair.intro`,{count:n.length,n:r,max:t.maxAttempts})];for(let t of n.slice(0,20)){let n=t.elements.length===0?``:` (${t.elements.slice(0,5).join(`, `)})`;i.push(e(`app.receipt.repair.line`,{rule:t.rule,file:t.file,where:n,message:t.message}))}return n.length>20&&i.push(e(`app.receipt.repair.more`,{count:n.length-20})),i.push(e(`app.receipt.repair.outro`)),i.join(`
2
2
  `)}const m=/* @__PURE__ */ new Set([`node_modules`,`.git`,`.penstock`,`dist`,`build`,`target`,`.idea`,`.vscode`]);function h(e){try{let t=c(e);return t.isFile()?t.size>8388608?{text:null,big:!0}:{text:l(e,`utf8`),big:!1}:{text:null,big:!1}}catch{return{text:null,big:!1}}}function g(e,t,n,r,i=0){if(i>12){r.incomplete=!0;return}let a;try{a=u(e,{withFileTypes:!0})}catch{return}for(let c of a.sort((e,t)=>e.name<t.name?-1:1)){if(r.seen+=1,r.seen>2e4){r.incomplete=!0;return}let a=s.join(e,c.name);c.isSymbolicLink()||(c.isDirectory()?m.has(c.name)||g(a,t,n,r,i+1):c.isFile()&&o(a)!==`other`&&n.push(a))}}function _(e,n){let r={seen:0,incomplete:!1},i=[];for(let a of e)t(a,[n])&&g(a,n,i,r);return{files:i,incomplete:r.incomplete}}function v(e,r){let i=n(r),a=(e.folders??[]).map(e=>n(e)).filter(e=>t(e,[i])),o=(e.files??[]).map(e=>s.resolve(e)).filter(e=>t(e,[i])),c=_(a,i),l=/* @__PURE__ */ new Map,u=c.incomplete,d=0;for(let e of[.../* @__PURE__ */ new Set([...o,...c.files])]){if(l.size>=500||d>67108864){u=!0;break}let t=h(e);t.big&&(u=!0),l.set(e,t.text),d+=t.text===null?0:Buffer.byteLength(t.text)}return{root:i,files:o,folders:a,texts:l,incomplete:u}}function y(e){let t=_(e.folders,e.root),n=[.../* @__PURE__ */ new Set([...e.texts.keys(),...e.files,...t.files])],r=[];for(let t of n){let n=e.texts.get(t)??null;n!==h(t).text&&r.push({path:t,before:n})}return{changes:r,incomplete:e.incomplete||t.incomplete}}export{p as i,v as n,f as r,y as t};
@@ -1 +1 @@
1
- import{c as e,t}from"./chunk-model-C5VKsEOw.js";import{t as n}from"./chunk-schema-CnfTvRZG.js";import{t as r}from"./chunk-executable-q_b3dHgQ.js";import{_ as i,v as a}from"./chunk-load-rfn3E0t5.js";import{t as o}from"./chunk-build-BsqW8Yp8.js";import{a as s,i as c,t as l}from"./chunk-context-rCJvBM9p.js";import{r as u}from"./chunk-commands-B4PoZbpX.js";import{n as d}from"./chunk-diagrams-BukAOL0g.js";import{a as f,r as p}from"./chunk-safeWrite-RgLbdyzl.js";import m from"node:path";import{closeSync as h,existsSync as g,lstatSync as _,openSync as v,readFileSync as y,readdirSync as b,realpathSync as x,rmSync as S,statSync as C,writeFileSync as w}from"node:fs";import{createHash as T,randomBytes as E}from"node:crypto";const D=/\.(cmmn|cmmn11\.xml)$/i;function O(e){return T(`sha256`).update(e,`utf8`).digest(`hex`)}function k(e){let t=m.basename(e),n=d(e);return n===null?D.test(t)?`case`:/\.dmn\.tests\.json$/i.test(t)||/(?:^|[\\/])test-cases[\\/][^\\/]+\.json$/i.test(e)?`tests`:/\.json$/i.test(t)&&/(?:^|[\\/])element-templates[\\/]/i.test(e)?`template`:/^penstock\.(local\.)?(yaml|yml|json)$/i.test(t)?`config`:`other`:n}function A(e,t){return m.relative(e,a(t)).split(m.sep).join(`/`)}function j(e){return e.slice(0,25)}function M(e,t){let n=t=>e.filter(e=>e.change===t).map(({id:e,type:t,name:n})=>({id:e,type:t,...n?{name:n}:{}})),r=n(`added`),i=n(`removed`),a=n(`changed`);return{added:r.length,removed:i.length,changed:a.length,moved:t,addedElements:j(r),removedElements:j(i),changedElements:j(a)}}function N(e,t,n){return{file:A(e,n.get(m.resolve(t.file))??t.file),rule:t.ruleId??t.rule,severity:t.severity,elements:t.elements??[],message:t.message}}async function P(e,t={builtInRulesOnly:!1}){return(await u(e,{format:`json`,baseline:!1,updateBaseline:!1,builtInRulesOnly:t.builtInRulesOnly})).findings}const F=/^(penstock(\.local)?\.(ya?ml|json)|\.bpmnlintrc(\..*)?|package(-lock)?\.json|penstock-rules\.[cm]?js|yarn\.lock|pnpm-lock\.yaml|\.npmrc)$/i,I=/(^|\/)(node_modules|rules|plugins|\.bpmnlint|\.penstock\/rules)\//i;function L(e){try{let t=s(c(l(m.join(e,`penstock.yaml`)).values.lint).configPath);return t?m.relative(e,m.resolve(e,t)).split(m.sep).join(`/`):null}catch{return null}}function R(e,t){let n=L(t);return e.some(e=>F.test(m.posix.basename(e))||I.test(e)||n!==null&&e===n)}function z(e){return m.join(m.dirname(e),`.penstock-before-${E(6).toString(`hex`)}-${m.basename(e)}`)}async function B(e,t,n){let r=[],i=x(e);try{let e=[];for(let n of t){if(!p(n.file,i))continue;let t=z(n.file),a=v(t,`wx`,384);r.push(t);try{w(a,n.text)}finally{h(a)}e.push({file:n.file,copy:t})}return await n(e)}finally{for(let e of r)S(e,{force:!0})}}function V(e){try{let t=_(e);return!t.isFile()||t.size>8388608?null:y(e,`utf8`)}catch{return null}}var H=class extends Error{file;constructor(e){super(e),this.file=e}};const U=[`process`,`decision`,`form`,`case`],W=[`process`,`decision`,`form`];async function G(e,n,s={}){let c=a(n.root),l=[],u=[],d=[],f=e.length>200;for(let t of e.slice(0,200)){let e=m.resolve(t.path);if(!i(e,[c]))throw new H(t.path);let n=A(c,e),r=t.after===void 0?g(e)?V(e):null:t.after;if(t.after===void 0&&r===null&&g(e)){let t=C(e,{throwIfNoEntry:!1});t?.isFile()&&t.size>8388608?u.push(n):l.push(n)}else t.before!==null&&t.before.length>8388608||r!==null&&r.length>8388608?u.push(n):t.before!==r&&d.push({absolute:e,relative:n,kind:k(e),change:t.before===null?`added`:r===null?`removed`:`changed`,before:t.before,after:r})}let p=s.diffOf,h=[],_=[],v=s.executable??r;for(let e of d){let n=null;if(p&&W.includes(e.kind)&&e.before!==null&&e.after!==null){let t=await p(e.kind,e.before,e.after);`unreadable`in t?l.push(e.relative):n=t.diff}if(e.kind===`process`&&e.after!==null)for(let n of await v(e.before??``,e.after))n.element===``?l.push(e.relative):_.push({file:e.relative,kind:t.includes(n.kind)?n.kind:`other`,element:n.element});let r=n!==null&&n.added+n.removed+n.changed+n.moved===0;h.push({path:e.relative,kind:e.kind,change:e.change,before:e.before===null?null:O(e.before),after:e.after===null?null:O(e.after),diff:n,formattingOnly:r})}let y=s.check??P,b=[...e.map(e=>{try{return A(c,m.resolve(e.path))}catch{return e.path}}),...d.map(e=>e.relative),...l,...u],x=f||n.incomplete===!0||l.length>0||u.length>0,S=s.projectRulesTrusted?.(c)===!0,w=R(b,c)?`project-changed`:x?`not-inspected`:S?null:`untrusted`,T=/* @__PURE__ */ new Map,E=!0,D=null,j=[],M=[],F=d.filter(e=>U.includes(e.kind)&&e.after!==null);try{if(F.length>0){M=(await y(F.map(e=>e.absolute),{builtInRulesOnly:w!==null})).map(e=>N(c,e,T));let e=F.filter(e=>e.before!==null);e.length>0&&(j=await B(c,e.map(e=>({file:e.absolute,text:e.before})),async e=>{for(let{file:t,copy:n}of e)T.set(m.resolve(n),t);return(await y(e.map(({copy:e})=>e),{builtInRulesOnly:w!==null})).map(e=>N(c,e,T))}))}}catch{E=!1,D=`failed`}let I=s.scenarios,L={status:`skipped`,reason:null,results:[]},z=d.filter(e=>e.kind===`process`&&e.after!==null).map(e=>e.absolute);if(z.length>0){let e=d.some(e=>e.kind===`config`||e.kind===`tests`),t=d.find(e=>[`decision`,`form`,`case`,`template`].includes(e.kind)),r=l[0]??u[0]??null;if(n.scenarios===!1)L={status:`skipped`,reason:`not-asked`,results:[]};else if(!n.approveExecutable&&x)L={status:`skipped`,reason:`not-inspected`,about:r,results:[]};else if(!n.approveExecutable&&_.length>0)L={status:`skipped`,reason:`executable-added`,about:_[0].file,results:[]};else if(!n.approveExecutable&&t)L={status:`skipped`,reason:`deployable-changed`,about:t.relative,results:[]};else if(!n.approveExecutable&&e)L={status:`skipped`,reason:`project-changed`,about:d.find(e=>e.kind===`config`||e.kind===`tests`)?.relative??null,results:[]};else if(I)try{L=await I(z,c)}catch{L={status:`skipped`,reason:`failed`,results:[]}}}return o({createdAt:n.now??/* @__PURE__ */ new Date,source:n.source,tool:n.tool??null,agent:n.agent??null,files:h,checks:{ran:E,reason:D,builtInOnly:F.length>0?w:null,before:j,after:M},scenarios:L,executable:_,layoutApplied:n.layoutApplied??!1,unreadable:[...new Set(l)],tooMany:f||n.incomplete===!0,tooLarge:u,attempts:n.attempts??[],maxAttempts:n.maxAttempts})}function K(e){let t=m.basename(e).replace(/\.[^.]+$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40).replace(/-+$/g,``);return t===``?`change`:t}function q(e){return e.toISOString().replace(/[-:]/g,``).replace(/\.\d+Z$/,`Z`)}function J(t){return m.join(a(t),...e.split(`/`))}function Y(e,t){let n=J(e),r=t.files[0]?.path??`change`,i=`${q(new Date(t.createdAt))}-${K(r)}`;for(let r=1;;r+=1){let o=m.join(n,`${i}${r===1?``:`-${r}`}.json`);try{return f([{path:o,content:`${JSON.stringify(t,null,2)}\n`}],a(e),{replace:!1}),o}catch(e){if(e.files?.every(e=>e.reason===`exists`)&&r<100)continue;throw e}}}function X(e,t){let r=a(t);if(!i(r,[e]))return{outside:!0};let o;try{let e=_(r);if(!e.isFile())return{unreadable:!0};if(e.size>1048576)return{problems:[{at:`$`,code:`tooLarge`}]};o=y(r,`utf8`)}catch{return{unreadable:!0}}return n(o)}function Z(e){let t=J(e);try{return b(t,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>m.join(t,e.name)).sort().slice(-2e3)}catch{return[]}}function Q(e,t){if(t===``||m.isAbsolute(t)||/^[A-Za-z]:/.test(t)||t.includes(`\0`)||t.split(/[\\/]/).includes(`..`))return null;let n=m.join(e,...t.split(`/`));return i(n,[e])?a(n):null}function $(e,t){let n=a(t),r=[];for(let t of e.files){let e=Q(n,t.path);if(e===null){r.push({path:t.path.slice(0,200),reason:`outside`});continue}let i;try{i=_(e)}catch{t.after!==null&&r.push({path:t.path,reason:`missing`});continue}if(t.after===null){r.push({path:t.path,reason:`exists`});continue}if(!i.isFile()||i.size>67108864){r.push({path:t.path,reason:`unreadable`});continue}let a;try{a=y(e,`utf8`)}catch{r.push({path:t.path,reason:`unreadable`});continue}O(a)!==t.after&&r.push({path:t.path,reason:`changed`})}return r}export{H as a,O as c,Z as i,k as l,X as n,G as o,Y as r,M as s,$ as t};
1
+ import{c as e,t}from"./chunk-model-C5VKsEOw.js";import{t as n}from"./chunk-schema-CnfTvRZG.js";import{t as r}from"./chunk-executable-q_b3dHgQ.js";import{t as i}from"./chunk-build-BsqW8Yp8.js";import{r as a}from"./chunk-commands-B8YVT41b.js";import{a as o,i as s,t as c}from"./chunk-context-rCJvBM9p.js";import{n as l}from"./chunk-diagrams-CtGMGTa8.js";import{_ as u,v as d}from"./chunk-load-rfn3E0t5.js";import{a as f,r as p}from"./chunk-safeWrite-RgLbdyzl.js";import m from"node:path";import{closeSync as h,existsSync as g,lstatSync as _,openSync as v,readFileSync as y,readdirSync as b,realpathSync as x,rmSync as S,statSync as C,writeFileSync as w}from"node:fs";import{createHash as T,randomBytes as E}from"node:crypto";const D=/\.(cmmn|cmmn11\.xml)$/i;function O(e){return T(`sha256`).update(e,`utf8`).digest(`hex`)}function k(e){let t=m.basename(e),n=l(e);return n===null?D.test(t)?`case`:/\.dmn\.tests\.json$/i.test(t)||/(?:^|[\\/])test-cases[\\/][^\\/]+\.json$/i.test(e)?`tests`:/\.json$/i.test(t)&&/(?:^|[\\/])element-templates[\\/]/i.test(e)?`template`:/^penstock\.(local\.)?(yaml|yml|json)$/i.test(t)?`config`:`other`:n}function A(e,t){return m.relative(e,d(t)).split(m.sep).join(`/`)}function j(e){return e.slice(0,25)}function M(e,t){let n=t=>e.filter(e=>e.change===t).map(({id:e,type:t,name:n})=>({id:e,type:t,...n?{name:n}:{}})),r=n(`added`),i=n(`removed`),a=n(`changed`);return{added:r.length,removed:i.length,changed:a.length,moved:t,addedElements:j(r),removedElements:j(i),changedElements:j(a)}}function N(e,t,n){return{file:A(e,n.get(m.resolve(t.file))??t.file),rule:t.ruleId??t.rule,severity:t.severity,elements:t.elements??[],message:t.message}}async function P(e,t={builtInRulesOnly:!1}){return(await a(e,{format:`json`,baseline:!1,updateBaseline:!1,builtInRulesOnly:t.builtInRulesOnly})).findings}const F=/^(penstock(\.local)?\.(ya?ml|json)|\.bpmnlintrc(\..*)?|package(-lock)?\.json|penstock-rules\.[cm]?js|yarn\.lock|pnpm-lock\.yaml|\.npmrc)$/i,I=/(^|\/)(node_modules|rules|plugins|\.bpmnlint|\.penstock\/rules)\//i;function L(e){try{let t=o(s(c(m.join(e,`penstock.yaml`)).values.lint).configPath);return t?m.relative(e,m.resolve(e,t)).split(m.sep).join(`/`):null}catch{return null}}function R(e,t){let n=L(t);return e.some(e=>F.test(m.posix.basename(e))||I.test(e)||n!==null&&e===n)}function z(e){return m.join(m.dirname(e),`.penstock-before-${E(6).toString(`hex`)}-${m.basename(e)}`)}async function B(e,t,n){let r=[],i=x(e);try{let e=[];for(let n of t){if(!p(n.file,i))continue;let t=z(n.file),a=v(t,`wx`,384);r.push(t);try{w(a,n.text)}finally{h(a)}e.push({file:n.file,copy:t})}return await n(e)}finally{for(let e of r)S(e,{force:!0})}}function V(e){try{let t=_(e);return!t.isFile()||t.size>8388608?null:y(e,`utf8`)}catch{return null}}var H=class extends Error{file;constructor(e){super(e),this.file=e}};const U=[`process`,`decision`,`form`,`case`],W=[`process`,`decision`,`form`];async function G(e,n,a={}){let o=d(n.root),s=[],c=[],l=[],f=e.length>200;for(let t of e.slice(0,200)){let e=m.resolve(t.path);if(!u(e,[o]))throw new H(t.path);let n=A(o,e),r=t.after===void 0?g(e)?V(e):null:t.after;if(t.after===void 0&&r===null&&g(e)){let t=C(e,{throwIfNoEntry:!1});t?.isFile()&&t.size>8388608?c.push(n):s.push(n)}else t.before!==null&&t.before.length>8388608||r!==null&&r.length>8388608?c.push(n):t.before!==r&&l.push({absolute:e,relative:n,kind:k(e),change:t.before===null?`added`:r===null?`removed`:`changed`,before:t.before,after:r})}let p=a.diffOf,h=[],_=[],v=a.executable??r;for(let e of l){let n=null;if(p&&W.includes(e.kind)&&e.before!==null&&e.after!==null){let t=await p(e.kind,e.before,e.after);`unreadable`in t?s.push(e.relative):n=t.diff}if(e.kind===`process`&&e.after!==null)for(let n of await v(e.before??``,e.after))n.element===``?s.push(e.relative):_.push({file:e.relative,kind:t.includes(n.kind)?n.kind:`other`,element:n.element});let r=n!==null&&n.added+n.removed+n.changed+n.moved===0;h.push({path:e.relative,kind:e.kind,change:e.change,before:e.before===null?null:O(e.before),after:e.after===null?null:O(e.after),diff:n,formattingOnly:r})}let y=a.check??P,b=[...e.map(e=>{try{return A(o,m.resolve(e.path))}catch{return e.path}}),...l.map(e=>e.relative),...s,...c],x=f||n.incomplete===!0||s.length>0||c.length>0,S=a.projectRulesTrusted?.(o)===!0,w=R(b,o)?`project-changed`:x?`not-inspected`:S?null:`untrusted`,T=/* @__PURE__ */ new Map,E=!0,D=null,j=[],M=[],F=l.filter(e=>U.includes(e.kind)&&e.after!==null);try{if(F.length>0){M=(await y(F.map(e=>e.absolute),{builtInRulesOnly:w!==null})).map(e=>N(o,e,T));let e=F.filter(e=>e.before!==null);e.length>0&&(j=await B(o,e.map(e=>({file:e.absolute,text:e.before})),async e=>{for(let{file:t,copy:n}of e)T.set(m.resolve(n),t);return(await y(e.map(({copy:e})=>e),{builtInRulesOnly:w!==null})).map(e=>N(o,e,T))}))}}catch{E=!1,D=`failed`}let I=a.scenarios,L={status:`skipped`,reason:null,results:[]},z=l.filter(e=>e.kind===`process`&&e.after!==null).map(e=>e.absolute);if(z.length>0){let e=l.some(e=>e.kind===`config`||e.kind===`tests`),t=l.find(e=>[`decision`,`form`,`case`,`template`].includes(e.kind)),r=s[0]??c[0]??null;if(n.scenarios===!1)L={status:`skipped`,reason:`not-asked`,results:[]};else if(!n.approveExecutable&&x)L={status:`skipped`,reason:`not-inspected`,about:r,results:[]};else if(!n.approveExecutable&&_.length>0)L={status:`skipped`,reason:`executable-added`,about:_[0].file,results:[]};else if(!n.approveExecutable&&t)L={status:`skipped`,reason:`deployable-changed`,about:t.relative,results:[]};else if(!n.approveExecutable&&e)L={status:`skipped`,reason:`project-changed`,about:l.find(e=>e.kind===`config`||e.kind===`tests`)?.relative??null,results:[]};else if(I)try{L=await I(z,o)}catch{L={status:`skipped`,reason:`failed`,results:[]}}}return i({createdAt:n.now??/* @__PURE__ */ new Date,source:n.source,tool:n.tool??null,agent:n.agent??null,files:h,checks:{ran:E,reason:D,builtInOnly:F.length>0?w:null,before:j,after:M},scenarios:L,executable:_,layoutApplied:n.layoutApplied??!1,unreadable:[...new Set(s)],tooMany:f||n.incomplete===!0,tooLarge:c,attempts:n.attempts??[],maxAttempts:n.maxAttempts})}function K(e){let t=m.basename(e).replace(/\.[^.]+$/,``).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40).replace(/-+$/g,``);return t===``?`change`:t}function q(e){return e.toISOString().replace(/[-:]/g,``).replace(/\.\d+Z$/,`Z`)}function J(t){return m.join(d(t),...e.split(`/`))}function Y(e,t){let n=J(e),r=t.files[0]?.path??`change`,i=`${q(new Date(t.createdAt))}-${K(r)}`;for(let r=1;;r+=1){let a=m.join(n,`${i}${r===1?``:`-${r}`}.json`);try{return f([{path:a,content:`${JSON.stringify(t,null,2)}\n`}],d(e),{replace:!1}),a}catch(e){if(e.files?.every(e=>e.reason===`exists`)&&r<100)continue;throw e}}}function X(e,t){let r=d(t);if(!u(r,[e]))return{outside:!0};let i;try{let e=_(r);if(!e.isFile())return{unreadable:!0};if(e.size>1048576)return{problems:[{at:`$`,code:`tooLarge`}]};i=y(r,`utf8`)}catch{return{unreadable:!0}}return n(i)}function Z(e){let t=J(e);try{return b(t,{withFileTypes:!0}).filter(e=>e.isFile()&&e.name.endsWith(`.json`)).map(e=>m.join(t,e.name)).sort().slice(-2e3)}catch{return[]}}function Q(e,t){if(t===``||m.isAbsolute(t)||/^[A-Za-z]:/.test(t)||t.includes(`\0`)||t.split(/[\\/]/).includes(`..`))return null;let n=m.join(e,...t.split(`/`));return u(n,[e])?d(n):null}function $(e,t){let n=d(t),r=[];for(let t of e.files){let e=Q(n,t.path);if(e===null){r.push({path:t.path.slice(0,200),reason:`outside`});continue}let i;try{i=_(e)}catch{t.after!==null&&r.push({path:t.path,reason:`missing`});continue}if(t.after===null){r.push({path:t.path,reason:`exists`});continue}if(!i.isFile()||i.size>67108864){r.push({path:t.path,reason:`unreadable`});continue}let a;try{a=y(e,`utf8`)}catch{r.push({path:t.path,reason:`unreadable`});continue}O(a)!==t.after&&r.push({path:t.path,reason:`changed`})}return r}export{H as a,O as c,Z as i,k as l,X as n,G as o,Y as r,M as s,$ as t};