@rytass/bpm-core-nestjs-module 0.1.2 → 0.1.3

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 (609) hide show
  1. package/eslint.config.mjs +20 -0
  2. package/jest.config.cts +15 -0
  3. package/package.json +3 -3
  4. package/project.json +58 -0
  5. package/src/lib/attachment/attachment-options.spec.ts +45 -0
  6. package/src/lib/attachment/attachment-options.ts +130 -0
  7. package/src/lib/attachment/attachment-storage.provider.spec.ts +79 -0
  8. package/src/lib/attachment/attachment-storage.provider.ts +60 -0
  9. package/src/lib/attachment/{attachment-storage.token.d.ts → attachment-storage.token.ts} +3 -1
  10. package/src/lib/attachment/attachment.controller.ts +39 -0
  11. package/src/lib/attachment/attachment.entity.ts +59 -0
  12. package/src/lib/attachment/attachment.module.ts +149 -0
  13. package/src/lib/attachment/attachment.mutations.ts +22 -0
  14. package/src/lib/attachment/attachment.queries.ts +65 -0
  15. package/src/lib/attachment/attachment.service.spec.ts +319 -0
  16. package/src/lib/attachment/attachment.service.ts +477 -0
  17. package/src/lib/attachment/dto/upload-attachment.input.ts +60 -0
  18. package/src/lib/bpm/bpm-root.module.spec.ts +138 -0
  19. package/src/lib/bpm/bpm-root.module.ts +320 -0
  20. package/src/lib/bpm-auth/bpm-auth-context.extractor.ts +106 -0
  21. package/src/lib/bpm-auth/bpm-auth-context.ts +40 -0
  22. package/src/lib/bpm-auth/bpm-auth.authorization.ts +80 -0
  23. package/src/lib/bpm-auth/bpm-auth.decorators.ts +19 -0
  24. package/src/lib/bpm-auth/bpm-auth.guard.ts +31 -0
  25. package/src/lib/bpm-auth/bpm-auth.module.spec.ts +106 -0
  26. package/src/lib/bpm-auth/bpm-auth.module.ts +69 -0
  27. package/src/lib/bpm-auth/bpm-auth.options.ts +21 -0
  28. package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.ts +55 -0
  29. package/src/lib/common/filters/all-exceptions.filter.ts +138 -0
  30. package/src/lib/common/iso-duration.ts +31 -0
  31. package/src/lib/condition/condition.module.ts +8 -0
  32. package/src/lib/condition/condition.service.spec.ts +50 -0
  33. package/src/lib/condition/condition.service.ts +141 -0
  34. package/src/lib/database/data-source.ts +7 -0
  35. package/src/lib/database/migration-runner.ts +24 -0
  36. package/src/lib/database/typeorm.config.ts +217 -0
  37. package/src/lib/delegation/delegation-rule.entity.ts +84 -0
  38. package/src/lib/delegation/delegation.enums.ts +21 -0
  39. package/src/lib/delegation/delegation.module.ts +14 -0
  40. package/src/lib/delegation/delegation.mutations.ts +92 -0
  41. package/src/lib/delegation/delegation.queries.ts +111 -0
  42. package/src/lib/delegation/delegation.service.spec.ts +295 -0
  43. package/src/lib/delegation/delegation.service.ts +482 -0
  44. package/src/lib/delegation/dto/delegation-rule.input.ts +125 -0
  45. package/src/lib/form/dto/form-definition.input.ts +73 -0
  46. package/src/lib/form/form-definition-version.entity.ts +66 -0
  47. package/src/lib/form/form-definition.entity.ts +54 -0
  48. package/src/lib/form/form-schema-lint.object.ts +10 -0
  49. package/src/lib/form/form-schema.validator.spec.ts +180 -0
  50. package/src/lib/form/form-schema.validator.ts +538 -0
  51. package/src/lib/form/form.enums.ts +20 -0
  52. package/src/lib/form/form.module.ts +19 -0
  53. package/src/lib/form/form.mutations.ts +68 -0
  54. package/src/lib/form/form.queries.ts +72 -0
  55. package/src/lib/form/form.service.spec.ts +144 -0
  56. package/src/lib/form/form.service.ts +490 -0
  57. package/src/lib/identity/identity-options.ts +41 -0
  58. package/src/lib/identity/identity.module.ts +96 -0
  59. package/src/lib/identity/identity.queries.ts +61 -0
  60. package/src/lib/identity/identity.service.spec.ts +105 -0
  61. package/src/lib/identity/identity.service.ts +200 -0
  62. package/src/lib/identity/member-base.adapter.spec.ts +77 -0
  63. package/src/lib/identity/member-base.adapter.ts +244 -0
  64. package/src/lib/identity/member-metadata-cache.entity.ts +27 -0
  65. package/src/lib/identity/member-profile.object.ts +28 -0
  66. package/src/lib/identity/{member-resolver.interface.d.ts → member-resolver.interface.ts} +11 -5
  67. package/src/lib/migrations/0000000000001-enable-postgres-extensions.ts +14 -0
  68. package/src/lib/migrations/{0000000001000-identity-organization-foundation.js → 0000000001000-identity-organization-foundation.ts} +38 -29
  69. package/src/lib/migrations/{0000000002000-form-builder-foundation.js → 0000000002000-form-builder-foundation.ts} +22 -21
  70. package/src/lib/migrations/{0000000003000-approval-template-foundation.js → 0000000003000-approval-template-foundation.ts} +24 -21
  71. package/src/lib/migrations/{0000000004000-workflow-engine-foundation.js → 0000000004000-workflow-engine-foundation.ts} +46 -34
  72. package/src/lib/migrations/{0000000005000-delegation-rules.js → 0000000005000-delegation-rules.ts} +20 -19
  73. package/src/lib/migrations/{0000000006000-notifications-sla.js → 0000000006000-notifications-sla.ts} +26 -23
  74. package/src/lib/migrations/{0000000007000-signatures-attachments.js → 0000000007000-signatures-attachments.ts} +28 -27
  75. package/src/lib/migrations/{0000000008000-approval-template-categories.js → 0000000008000-approval-template-categories.ts} +28 -25
  76. package/src/lib/migrations/{0000000009000-task-candidates.js → 0000000009000-task-candidates.ts} +26 -23
  77. package/src/lib/migrations/{0000000010000-notification-delivery-state.js → 0000000010000-notification-delivery-state.ts} +16 -17
  78. package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.ts +19 -0
  79. package/src/lib/migrations/0000000012000-notification-sla-idempotency.ts +22 -0
  80. package/src/lib/migrations/0000000013000-workflow-query-indexes.ts +113 -0
  81. package/src/lib/migrations/index.ts +47 -0
  82. package/src/lib/notification/dto/notification-preference.input.ts +46 -0
  83. package/src/lib/notification/notification-delivery-scheduler.service.ts +69 -0
  84. package/src/lib/notification/notification-delivery.service.spec.ts +315 -0
  85. package/src/lib/notification/notification-delivery.service.ts +339 -0
  86. package/src/lib/notification/notification-dispatcher.token.ts +13 -0
  87. package/src/lib/notification/notification-options.module.ts +67 -0
  88. package/src/lib/notification/notification-options.spec.ts +93 -0
  89. package/src/lib/notification/notification-options.ts +452 -0
  90. package/src/lib/notification/notification-preference.entity.ts +35 -0
  91. package/src/lib/notification/notification-sla-scheduler.service.ts +66 -0
  92. package/src/lib/notification/notification-template.spec.ts +33 -0
  93. package/src/lib/notification/notification-template.ts +97 -0
  94. package/src/lib/notification/notification.entity.ts +102 -0
  95. package/src/lib/notification/notification.enums.ts +45 -0
  96. package/src/lib/notification/notification.module.ts +37 -0
  97. package/src/lib/notification/notification.mutations.ts +47 -0
  98. package/src/lib/notification/notification.queries.ts +64 -0
  99. package/src/lib/notification/notification.service.spec.ts +412 -0
  100. package/src/lib/notification/notification.service.ts +974 -0
  101. package/src/lib/organization/dto/manager-resolution.input.ts +91 -0
  102. package/src/lib/organization/dto/membership.input.ts +77 -0
  103. package/src/lib/organization/dto/org-unit.input.ts +96 -0
  104. package/src/lib/organization/dto/position.input.ts +50 -0
  105. package/src/lib/organization/json-metadata.ts +15 -0
  106. package/src/lib/organization/manager-resolution.entity.ts +44 -0
  107. package/src/lib/organization/membership.entity.ts +50 -0
  108. package/src/lib/organization/org-unit-tree-commit-result.object.ts +8 -0
  109. package/src/lib/organization/org-unit.entity.ts +53 -0
  110. package/src/lib/organization/organization-summary.object.ts +16 -0
  111. package/src/lib/organization/organization.enums.ts +19 -0
  112. package/src/lib/organization/organization.module.ts +27 -0
  113. package/src/lib/organization/organization.mutations.ts +115 -0
  114. package/src/lib/organization/organization.queries.ts +188 -0
  115. package/src/lib/organization/organization.service.spec.ts +760 -0
  116. package/src/lib/organization/organization.service.ts +1216 -0
  117. package/src/lib/organization/position.entity.ts +39 -0
  118. package/src/lib/organization/resolved-manager.object.ts +10 -0
  119. package/src/lib/signature/signature-options.spec.ts +60 -0
  120. package/src/lib/signature/signature-options.ts +120 -0
  121. package/src/lib/signature/signature-verification.object.ts +16 -0
  122. package/src/lib/signature/signature.entity.ts +62 -0
  123. package/src/lib/signature/signature.module.ts +80 -0
  124. package/src/lib/signature/signature.queries.ts +37 -0
  125. package/src/lib/signature/signature.service.spec.ts +134 -0
  126. package/src/lib/signature/signature.service.ts +205 -0
  127. package/src/lib/template/approval-template-category.entity.ts +40 -0
  128. package/src/lib/template/approval-template-version.entity.ts +82 -0
  129. package/src/lib/template/approval-template.entity.ts +64 -0
  130. package/src/lib/template/dto/approval-template.input.ts +147 -0
  131. package/src/lib/template/template.enums.ts +30 -0
  132. package/src/lib/template/template.module.ts +25 -0
  133. package/src/lib/template/template.mutations.ts +106 -0
  134. package/src/lib/template/template.queries.ts +119 -0
  135. package/src/lib/template/template.service.spec.ts +476 -0
  136. package/src/lib/template/template.service.ts +820 -0
  137. package/src/lib/template/workflow-definition.validator.spec.ts +595 -0
  138. package/src/lib/template/workflow-definition.validator.ts +539 -0
  139. package/src/lib/testing/cel-js.jest.ts +46 -0
  140. package/src/lib/workflow-engine/activity-log.entity.ts +48 -0
  141. package/src/lib/workflow-engine/approval-instance-page-info.object.ts +22 -0
  142. package/src/lib/workflow-engine/approval-instance.entity.ts +86 -0
  143. package/src/lib/workflow-engine/dto/cancel-approval-instance.input.ts +18 -0
  144. package/src/lib/workflow-engine/dto/decide-task.input.ts +33 -0
  145. package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.ts +22 -0
  146. package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.ts +22 -0
  147. package/src/lib/workflow-engine/dto/submit-approval-instance.input.ts +27 -0
  148. package/src/lib/workflow-engine/task-candidate.entity.ts +56 -0
  149. package/src/lib/workflow-engine/task-decision.entity.ts +43 -0
  150. package/src/lib/workflow-engine/task.entity.ts +85 -0
  151. package/src/lib/workflow-engine/workflow-condition-evaluator.ts +168 -0
  152. package/src/lib/workflow-engine/workflow-dashboard-summary.object.ts +22 -0
  153. package/src/lib/workflow-engine/workflow-dry-run.object.ts +58 -0
  154. package/src/lib/workflow-engine/workflow-engine.enums.ts +99 -0
  155. package/src/lib/workflow-engine/workflow-engine.module.ts +75 -0
  156. package/src/lib/workflow-engine/workflow-engine.mutations.ts +85 -0
  157. package/src/lib/workflow-engine/workflow-engine.queries.ts +229 -0
  158. package/src/lib/workflow-engine/workflow-engine.service.spec.ts +2689 -0
  159. package/src/lib/workflow-engine/workflow-engine.service.ts +4707 -0
  160. package/src/lib/workflow-engine/{workflow-engine.tokens.d.ts → workflow-engine.tokens.ts} +9 -3
  161. package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.ts +69 -0
  162. package/src/lib/workflow-engine/workflow-token.entity.ts +40 -0
  163. package/tsconfig.json +24 -0
  164. package/tsconfig.lib.json +16 -0
  165. package/tsconfig.spec.json +16 -0
  166. package/LICENSE +0 -21
  167. package/src/index.js +0 -18
  168. package/src/index.js.map +0 -1
  169. package/src/lib/attachment/attachment-options.d.ts +0 -44
  170. package/src/lib/attachment/attachment-options.js +0 -62
  171. package/src/lib/attachment/attachment-options.js.map +0 -1
  172. package/src/lib/attachment/attachment-storage.provider.d.ts +0 -4
  173. package/src/lib/attachment/attachment-storage.provider.js +0 -35
  174. package/src/lib/attachment/attachment-storage.provider.js.map +0 -1
  175. package/src/lib/attachment/attachment-storage.token.js +0 -5
  176. package/src/lib/attachment/attachment-storage.token.js.map +0 -1
  177. package/src/lib/attachment/attachment.controller.d.ts +0 -8
  178. package/src/lib/attachment/attachment.controller.js +0 -38
  179. package/src/lib/attachment/attachment.controller.js.map +0 -1
  180. package/src/lib/attachment/attachment.entity.d.ts +0 -14
  181. package/src/lib/attachment/attachment.entity.js +0 -74
  182. package/src/lib/attachment/attachment.entity.js.map +0 -1
  183. package/src/lib/attachment/attachment.module.d.ts +0 -27
  184. package/src/lib/attachment/attachment.module.js +0 -103
  185. package/src/lib/attachment/attachment.module.js.map +0 -1
  186. package/src/lib/attachment/attachment.mutations.d.ts +0 -8
  187. package/src/lib/attachment/attachment.mutations.js +0 -35
  188. package/src/lib/attachment/attachment.mutations.js.map +0 -1
  189. package/src/lib/attachment/attachment.queries.d.ts +0 -9
  190. package/src/lib/attachment/attachment.queries.js +0 -78
  191. package/src/lib/attachment/attachment.queries.js.map +0 -1
  192. package/src/lib/attachment/attachment.service.d.ts +0 -49
  193. package/src/lib/attachment/attachment.service.js +0 -276
  194. package/src/lib/attachment/attachment.service.js.map +0 -1
  195. package/src/lib/attachment/dto/upload-attachment.input.d.ts +0 -11
  196. package/src/lib/attachment/dto/upload-attachment.input.js +0 -68
  197. package/src/lib/attachment/dto/upload-attachment.input.js.map +0 -1
  198. package/src/lib/attachment/index.js +0 -9
  199. package/src/lib/attachment/index.js.map +0 -1
  200. package/src/lib/bpm/bpm-root.module.d.ts +0 -155
  201. package/src/lib/bpm/bpm-root.module.js +0 -170
  202. package/src/lib/bpm/bpm-root.module.js.map +0 -1
  203. package/src/lib/bpm/index.js +0 -5
  204. package/src/lib/bpm/index.js.map +0 -1
  205. package/src/lib/bpm-auth/bpm-auth-context.d.ts +0 -24
  206. package/src/lib/bpm-auth/bpm-auth-context.extractor.d.ts +0 -4
  207. package/src/lib/bpm-auth/bpm-auth-context.extractor.js +0 -69
  208. package/src/lib/bpm-auth/bpm-auth-context.extractor.js.map +0 -1
  209. package/src/lib/bpm-auth/bpm-auth-context.js +0 -15
  210. package/src/lib/bpm-auth/bpm-auth-context.js.map +0 -1
  211. package/src/lib/bpm-auth/bpm-auth.authorization.d.ts +0 -12
  212. package/src/lib/bpm-auth/bpm-auth.authorization.js +0 -67
  213. package/src/lib/bpm-auth/bpm-auth.authorization.js.map +0 -1
  214. package/src/lib/bpm-auth/bpm-auth.decorators.d.ts +0 -3
  215. package/src/lib/bpm-auth/bpm-auth.decorators.js +0 -11
  216. package/src/lib/bpm-auth/bpm-auth.decorators.js.map +0 -1
  217. package/src/lib/bpm-auth/bpm-auth.guard.d.ts +0 -7
  218. package/src/lib/bpm-auth/bpm-auth.guard.js +0 -24
  219. package/src/lib/bpm-auth/bpm-auth.guard.js.map +0 -1
  220. package/src/lib/bpm-auth/bpm-auth.module.d.ts +0 -6
  221. package/src/lib/bpm-auth/bpm-auth.module.js +0 -69
  222. package/src/lib/bpm-auth/bpm-auth.module.js.map +0 -1
  223. package/src/lib/bpm-auth/bpm-auth.options.d.ts +0 -11
  224. package/src/lib/bpm-auth/bpm-auth.options.js +0 -3
  225. package/src/lib/bpm-auth/bpm-auth.options.js.map +0 -1
  226. package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.d.ts +0 -10
  227. package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.js +0 -40
  228. package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.js.map +0 -1
  229. package/src/lib/bpm-auth/index.js +0 -10
  230. package/src/lib/bpm-auth/index.js.map +0 -1
  231. package/src/lib/common/filters/all-exceptions.filter.d.ts +0 -25
  232. package/src/lib/common/filters/all-exceptions.filter.js +0 -93
  233. package/src/lib/common/filters/all-exceptions.filter.js.map +0 -1
  234. package/src/lib/common/index.js +0 -5
  235. package/src/lib/common/index.js.map +0 -1
  236. package/src/lib/common/iso-duration.d.ts +0 -1
  237. package/src/lib/common/iso-duration.js +0 -27
  238. package/src/lib/common/iso-duration.js.map +0 -1
  239. package/src/lib/condition/condition.module.d.ts +0 -2
  240. package/src/lib/condition/condition.module.js +0 -16
  241. package/src/lib/condition/condition.module.js.map +0 -1
  242. package/src/lib/condition/condition.service.d.ts +0 -16
  243. package/src/lib/condition/condition.service.js +0 -82
  244. package/src/lib/condition/condition.service.js.map +0 -1
  245. package/src/lib/condition/index.js +0 -6
  246. package/src/lib/condition/index.js.map +0 -1
  247. package/src/lib/database/data-source.d.ts +0 -4
  248. package/src/lib/database/data-source.js +0 -7
  249. package/src/lib/database/data-source.js.map +0 -1
  250. package/src/lib/database/index.js +0 -6
  251. package/src/lib/database/index.js.map +0 -1
  252. package/src/lib/database/migration-runner.d.ts +0 -1
  253. package/src/lib/database/migration-runner.js +0 -23
  254. package/src/lib/database/migration-runner.js.map +0 -1
  255. package/src/lib/database/typeorm.config.d.ts +0 -14
  256. package/src/lib/database/typeorm.config.js +0 -135
  257. package/src/lib/database/typeorm.config.js.map +0 -1
  258. package/src/lib/delegation/delegation-rule.entity.d.ts +0 -19
  259. package/src/lib/delegation/delegation-rule.entity.js +0 -99
  260. package/src/lib/delegation/delegation-rule.entity.js.map +0 -1
  261. package/src/lib/delegation/delegation.enums.d.ts +0 -10
  262. package/src/lib/delegation/delegation.enums.js +0 -23
  263. package/src/lib/delegation/delegation.enums.js.map +0 -1
  264. package/src/lib/delegation/delegation.module.d.ts +0 -2
  265. package/src/lib/delegation/delegation.module.js +0 -22
  266. package/src/lib/delegation/delegation.module.js.map +0 -1
  267. package/src/lib/delegation/delegation.mutations.d.ts +0 -11
  268. package/src/lib/delegation/delegation.mutations.js +0 -87
  269. package/src/lib/delegation/delegation.mutations.js.map +0 -1
  270. package/src/lib/delegation/delegation.queries.d.ts +0 -10
  271. package/src/lib/delegation/delegation.queries.js +0 -91
  272. package/src/lib/delegation/delegation.queries.js.map +0 -1
  273. package/src/lib/delegation/delegation.service.d.ts +0 -56
  274. package/src/lib/delegation/delegation.service.js +0 -268
  275. package/src/lib/delegation/delegation.service.js.map +0 -1
  276. package/src/lib/delegation/dto/delegation-rule.input.d.ts +0 -24
  277. package/src/lib/delegation/dto/delegation-rule.input.js +0 -143
  278. package/src/lib/delegation/dto/delegation-rule.input.js.map +0 -1
  279. package/src/lib/delegation/index.js +0 -9
  280. package/src/lib/delegation/index.js.map +0 -1
  281. package/src/lib/form/dto/form-definition.input.d.ts +0 -21
  282. package/src/lib/form/dto/form-definition.input.js +0 -103
  283. package/src/lib/form/dto/form-definition.input.js.map +0 -1
  284. package/src/lib/form/form-definition-version.entity.d.ts +0 -17
  285. package/src/lib/form/form-definition-version.entity.js +0 -84
  286. package/src/lib/form/form-definition-version.entity.js.map +0 -1
  287. package/src/lib/form/form-definition.entity.d.ts +0 -13
  288. package/src/lib/form/form-definition.entity.js +0 -66
  289. package/src/lib/form/form-definition.entity.js.map +0 -1
  290. package/src/lib/form/form-schema-lint.object.d.ts +0 -4
  291. package/src/lib/form/form-schema-lint.object.js +0 -20
  292. package/src/lib/form/form-schema-lint.object.js.map +0 -1
  293. package/src/lib/form/form-schema.validator.d.ts +0 -13
  294. package/src/lib/form/form-schema.validator.js +0 -354
  295. package/src/lib/form/form-schema.validator.js.map +0 -1
  296. package/src/lib/form/form.enums.d.ts +0 -9
  297. package/src/lib/form/form.enums.js +0 -22
  298. package/src/lib/form/form.enums.js.map +0 -1
  299. package/src/lib/form/form.module.d.ts +0 -2
  300. package/src/lib/form/form.module.js +0 -27
  301. package/src/lib/form/form.module.js.map +0 -1
  302. package/src/lib/form/form.mutations.d.ts +0 -14
  303. package/src/lib/form/form.mutations.js +0 -88
  304. package/src/lib/form/form.mutations.js.map +0 -1
  305. package/src/lib/form/form.queries.d.ts +0 -16
  306. package/src/lib/form/form.queries.js +0 -96
  307. package/src/lib/form/form.queries.js.map +0 -1
  308. package/src/lib/form/form.service.d.ts +0 -35
  309. package/src/lib/form/form.service.js +0 -297
  310. package/src/lib/form/form.service.js.map +0 -1
  311. package/src/lib/form/index.js +0 -12
  312. package/src/lib/form/index.js.map +0 -1
  313. package/src/lib/identity/identity-options.d.ts +0 -13
  314. package/src/lib/identity/identity-options.js +0 -20
  315. package/src/lib/identity/identity-options.js.map +0 -1
  316. package/src/lib/identity/identity.module.d.ts +0 -17
  317. package/src/lib/identity/identity.module.js +0 -65
  318. package/src/lib/identity/identity.module.js.map +0 -1
  319. package/src/lib/identity/identity.queries.d.ts +0 -12
  320. package/src/lib/identity/identity.queries.js +0 -79
  321. package/src/lib/identity/identity.queries.js.map +0 -1
  322. package/src/lib/identity/identity.service.d.ts +0 -22
  323. package/src/lib/identity/identity.service.js +0 -141
  324. package/src/lib/identity/identity.service.js.map +0 -1
  325. package/src/lib/identity/index.js +0 -7
  326. package/src/lib/identity/index.js.map +0 -1
  327. package/src/lib/identity/member-base.adapter.d.ts +0 -95
  328. package/src/lib/identity/member-base.adapter.js +0 -137
  329. package/src/lib/identity/member-base.adapter.js.map +0 -1
  330. package/src/lib/identity/member-metadata-cache.entity.d.ts +0 -8
  331. package/src/lib/identity/member-metadata-cache.entity.js +0 -39
  332. package/src/lib/identity/member-metadata-cache.entity.js.map +0 -1
  333. package/src/lib/identity/member-profile.object.d.ts +0 -8
  334. package/src/lib/identity/member-profile.object.js +0 -37
  335. package/src/lib/identity/member-profile.object.js.map +0 -1
  336. package/src/lib/identity/member-resolver.interface.js +0 -19
  337. package/src/lib/identity/member-resolver.interface.js.map +0 -1
  338. package/src/lib/migrations/0000000000001-enable-postgres-extensions.d.ts +0 -6
  339. package/src/lib/migrations/0000000000001-enable-postgres-extensions.js +0 -17
  340. package/src/lib/migrations/0000000000001-enable-postgres-extensions.js.map +0 -1
  341. package/src/lib/migrations/0000000001000-identity-organization-foundation.d.ts +0 -6
  342. package/src/lib/migrations/0000000001000-identity-organization-foundation.js.map +0 -1
  343. package/src/lib/migrations/0000000002000-form-builder-foundation.d.ts +0 -6
  344. package/src/lib/migrations/0000000002000-form-builder-foundation.js.map +0 -1
  345. package/src/lib/migrations/0000000003000-approval-template-foundation.d.ts +0 -6
  346. package/src/lib/migrations/0000000003000-approval-template-foundation.js.map +0 -1
  347. package/src/lib/migrations/0000000004000-workflow-engine-foundation.d.ts +0 -6
  348. package/src/lib/migrations/0000000004000-workflow-engine-foundation.js.map +0 -1
  349. package/src/lib/migrations/0000000005000-delegation-rules.d.ts +0 -6
  350. package/src/lib/migrations/0000000005000-delegation-rules.js.map +0 -1
  351. package/src/lib/migrations/0000000006000-notifications-sla.d.ts +0 -6
  352. package/src/lib/migrations/0000000006000-notifications-sla.js.map +0 -1
  353. package/src/lib/migrations/0000000007000-signatures-attachments.d.ts +0 -6
  354. package/src/lib/migrations/0000000007000-signatures-attachments.js.map +0 -1
  355. package/src/lib/migrations/0000000008000-approval-template-categories.d.ts +0 -6
  356. package/src/lib/migrations/0000000008000-approval-template-categories.js.map +0 -1
  357. package/src/lib/migrations/0000000009000-task-candidates.d.ts +0 -6
  358. package/src/lib/migrations/0000000009000-task-candidates.js.map +0 -1
  359. package/src/lib/migrations/0000000010000-notification-delivery-state.d.ts +0 -6
  360. package/src/lib/migrations/0000000010000-notification-delivery-state.js.map +0 -1
  361. package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.d.ts +0 -6
  362. package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.js +0 -22
  363. package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.js.map +0 -1
  364. package/src/lib/migrations/0000000012000-notification-sla-idempotency.d.ts +0 -6
  365. package/src/lib/migrations/0000000012000-notification-sla-idempotency.js +0 -21
  366. package/src/lib/migrations/0000000012000-notification-sla-idempotency.js.map +0 -1
  367. package/src/lib/migrations/0000000013000-workflow-query-indexes.d.ts +0 -6
  368. package/src/lib/migrations/0000000013000-workflow-query-indexes.js +0 -80
  369. package/src/lib/migrations/0000000013000-workflow-query-indexes.js.map +0 -1
  370. package/src/lib/migrations/index.d.ts +0 -16
  371. package/src/lib/migrations/index.js +0 -49
  372. package/src/lib/migrations/index.js.map +0 -1
  373. package/src/lib/notification/dto/notification-preference.input.d.ts +0 -9
  374. package/src/lib/notification/dto/notification-preference.input.js +0 -53
  375. package/src/lib/notification/dto/notification-preference.input.js.map +0 -1
  376. package/src/lib/notification/index.js +0 -11
  377. package/src/lib/notification/index.js.map +0 -1
  378. package/src/lib/notification/notification-delivery-scheduler.service.d.ts +0 -13
  379. package/src/lib/notification/notification-delivery-scheduler.service.js +0 -53
  380. package/src/lib/notification/notification-delivery-scheduler.service.js.map +0 -1
  381. package/src/lib/notification/notification-delivery.service.d.ts +0 -23
  382. package/src/lib/notification/notification-delivery.service.js +0 -245
  383. package/src/lib/notification/notification-delivery.service.js.map +0 -1
  384. package/src/lib/notification/notification-dispatcher.token.d.ts +0 -7
  385. package/src/lib/notification/notification-dispatcher.token.js +0 -5
  386. package/src/lib/notification/notification-dispatcher.token.js.map +0 -1
  387. package/src/lib/notification/notification-options.d.ts +0 -215
  388. package/src/lib/notification/notification-options.js +0 -128
  389. package/src/lib/notification/notification-options.js.map +0 -1
  390. package/src/lib/notification/notification-options.module.d.ts +0 -23
  391. package/src/lib/notification/notification-options.module.js +0 -41
  392. package/src/lib/notification/notification-options.module.js.map +0 -1
  393. package/src/lib/notification/notification-preference.entity.d.ts +0 -10
  394. package/src/lib/notification/notification-preference.entity.js +0 -50
  395. package/src/lib/notification/notification-preference.entity.js.map +0 -1
  396. package/src/lib/notification/notification-sla-scheduler.service.d.ts +0 -13
  397. package/src/lib/notification/notification-sla-scheduler.service.js +0 -51
  398. package/src/lib/notification/notification-sla-scheduler.service.js.map +0 -1
  399. package/src/lib/notification/notification-template.d.ts +0 -13
  400. package/src/lib/notification/notification-template.js +0 -61
  401. package/src/lib/notification/notification-template.js.map +0 -1
  402. package/src/lib/notification/notification.entity.d.ts +0 -23
  403. package/src/lib/notification/notification.entity.js +0 -122
  404. package/src/lib/notification/notification.entity.js.map +0 -1
  405. package/src/lib/notification/notification.enums.d.ts +0 -24
  406. package/src/lib/notification/notification.enums.js +0 -45
  407. package/src/lib/notification/notification.enums.js.map +0 -1
  408. package/src/lib/notification/notification.module.d.ts +0 -2
  409. package/src/lib/notification/notification.module.js +0 -45
  410. package/src/lib/notification/notification.module.js.map +0 -1
  411. package/src/lib/notification/notification.mutations.d.ts +0 -11
  412. package/src/lib/notification/notification.mutations.js +0 -64
  413. package/src/lib/notification/notification.mutations.js.map +0 -1
  414. package/src/lib/notification/notification.queries.d.ts +0 -11
  415. package/src/lib/notification/notification.queries.js +0 -77
  416. package/src/lib/notification/notification.queries.js.map +0 -1
  417. package/src/lib/notification/notification.service.d.ts +0 -81
  418. package/src/lib/notification/notification.service.js +0 -621
  419. package/src/lib/notification/notification.service.js.map +0 -1
  420. package/src/lib/organization/dto/manager-resolution.input.d.ts +0 -18
  421. package/src/lib/organization/dto/manager-resolution.input.js +0 -107
  422. package/src/lib/organization/dto/manager-resolution.input.js.map +0 -1
  423. package/src/lib/organization/dto/membership.input.d.ts +0 -16
  424. package/src/lib/organization/dto/membership.input.js +0 -99
  425. package/src/lib/organization/dto/membership.input.js.map +0 -1
  426. package/src/lib/organization/dto/org-unit.input.d.ts +0 -24
  427. package/src/lib/organization/dto/org-unit.input.js +0 -119
  428. package/src/lib/organization/dto/org-unit.input.js.map +0 -1
  429. package/src/lib/organization/dto/position.input.d.ts +0 -13
  430. package/src/lib/organization/dto/position.input.js +0 -70
  431. package/src/lib/organization/dto/position.input.js.map +0 -1
  432. package/src/lib/organization/index.js +0 -16
  433. package/src/lib/organization/index.js.map +0 -1
  434. package/src/lib/organization/json-metadata.d.ts +0 -1
  435. package/src/lib/organization/json-metadata.js +0 -14
  436. package/src/lib/organization/json-metadata.js.map +0 -1
  437. package/src/lib/organization/manager-resolution.entity.d.ts +0 -11
  438. package/src/lib/organization/manager-resolution.entity.js +0 -55
  439. package/src/lib/organization/manager-resolution.entity.js.map +0 -1
  440. package/src/lib/organization/membership.entity.d.ts +0 -11
  441. package/src/lib/organization/membership.entity.js +0 -60
  442. package/src/lib/organization/membership.entity.js.map +0 -1
  443. package/src/lib/organization/org-unit-tree-commit-result.object.d.ts +0 -4
  444. package/src/lib/organization/org-unit-tree-commit-result.object.js +0 -17
  445. package/src/lib/organization/org-unit-tree-commit-result.object.js.map +0 -1
  446. package/src/lib/organization/org-unit.entity.d.ts +0 -13
  447. package/src/lib/organization/org-unit.entity.js +0 -64
  448. package/src/lib/organization/org-unit.entity.js.map +0 -1
  449. package/src/lib/organization/organization-summary.object.d.ts +0 -6
  450. package/src/lib/organization/organization-summary.object.js +0 -28
  451. package/src/lib/organization/organization-summary.object.js.map +0 -1
  452. package/src/lib/organization/organization.enums.d.ts +0 -11
  453. package/src/lib/organization/organization.enums.js +0 -22
  454. package/src/lib/organization/organization.enums.js.map +0 -1
  455. package/src/lib/organization/organization.module.d.ts +0 -2
  456. package/src/lib/organization/organization.module.js +0 -35
  457. package/src/lib/organization/organization.module.js.map +0 -1
  458. package/src/lib/organization/organization.mutations.d.ts +0 -26
  459. package/src/lib/organization/organization.mutations.js +0 -148
  460. package/src/lib/organization/organization.mutations.js.map +0 -1
  461. package/src/lib/organization/organization.queries.d.ts +0 -23
  462. package/src/lib/organization/organization.queries.js +0 -202
  463. package/src/lib/organization/organization.queries.js.map +0 -1
  464. package/src/lib/organization/organization.service.d.ts +0 -102
  465. package/src/lib/organization/organization.service.js +0 -751
  466. package/src/lib/organization/organization.service.js.map +0 -1
  467. package/src/lib/organization/position.entity.d.ts +0 -9
  468. package/src/lib/organization/position.entity.js +0 -48
  469. package/src/lib/organization/position.entity.js.map +0 -1
  470. package/src/lib/organization/resolved-manager.object.d.ts +0 -4
  471. package/src/lib/organization/resolved-manager.object.js +0 -20
  472. package/src/lib/organization/resolved-manager.object.js.map +0 -1
  473. package/src/lib/signature/index.js +0 -8
  474. package/src/lib/signature/index.js.map +0 -1
  475. package/src/lib/signature/signature-options.d.ts +0 -33
  476. package/src/lib/signature/signature-options.js +0 -51
  477. package/src/lib/signature/signature-options.js.map +0 -1
  478. package/src/lib/signature/signature-verification.object.d.ts +0 -6
  479. package/src/lib/signature/signature-verification.object.js +0 -28
  480. package/src/lib/signature/signature-verification.object.js.map +0 -1
  481. package/src/lib/signature/signature.entity.d.ts +0 -16
  482. package/src/lib/signature/signature.entity.js +0 -88
  483. package/src/lib/signature/signature.entity.js.map +0 -1
  484. package/src/lib/signature/signature.module.d.ts +0 -11
  485. package/src/lib/signature/signature.module.js +0 -60
  486. package/src/lib/signature/signature.module.js.map +0 -1
  487. package/src/lib/signature/signature.queries.d.ts +0 -11
  488. package/src/lib/signature/signature.queries.js +0 -46
  489. package/src/lib/signature/signature.queries.js.map +0 -1
  490. package/src/lib/signature/signature.service.d.ts +0 -25
  491. package/src/lib/signature/signature.service.js +0 -124
  492. package/src/lib/signature/signature.service.js.map +0 -1
  493. package/src/lib/template/approval-template-category.entity.d.ts +0 -9
  494. package/src/lib/template/approval-template-category.entity.js +0 -49
  495. package/src/lib/template/approval-template-category.entity.js.map +0 -1
  496. package/src/lib/template/approval-template-version.entity.d.ts +0 -21
  497. package/src/lib/template/approval-template-version.entity.js +0 -106
  498. package/src/lib/template/approval-template-version.entity.js.map +0 -1
  499. package/src/lib/template/approval-template.entity.d.ts +0 -14
  500. package/src/lib/template/approval-template.entity.js +0 -74
  501. package/src/lib/template/approval-template.entity.js.map +0 -1
  502. package/src/lib/template/dto/approval-template.input.d.ts +0 -36
  503. package/src/lib/template/dto/approval-template.input.js +0 -187
  504. package/src/lib/template/dto/approval-template.input.js.map +0 -1
  505. package/src/lib/template/index.js +0 -12
  506. package/src/lib/template/index.js.map +0 -1
  507. package/src/lib/template/template.enums.d.ts +0 -14
  508. package/src/lib/template/template.enums.js +0 -31
  509. package/src/lib/template/template.enums.js.map +0 -1
  510. package/src/lib/template/template.module.d.ts +0 -2
  511. package/src/lib/template/template.module.js +0 -33
  512. package/src/lib/template/template.module.js.map +0 -1
  513. package/src/lib/template/template.mutations.d.ts +0 -20
  514. package/src/lib/template/template.mutations.js +0 -139
  515. package/src/lib/template/template.mutations.js.map +0 -1
  516. package/src/lib/template/template.queries.d.ts +0 -16
  517. package/src/lib/template/template.queries.js +0 -133
  518. package/src/lib/template/template.queries.js.map +0 -1
  519. package/src/lib/template/template.service.d.ts +0 -64
  520. package/src/lib/template/template.service.js +0 -521
  521. package/src/lib/template/template.service.js.map +0 -1
  522. package/src/lib/template/workflow-definition.validator.d.ts +0 -9
  523. package/src/lib/template/workflow-definition.validator.js +0 -362
  524. package/src/lib/template/workflow-definition.validator.js.map +0 -1
  525. package/src/lib/testing/cel-js.jest.d.ts +0 -15
  526. package/src/lib/testing/cel-js.jest.js +0 -27
  527. package/src/lib/testing/cel-js.jest.js.map +0 -1
  528. package/src/lib/workflow-engine/activity-log.entity.d.ts +0 -12
  529. package/src/lib/workflow-engine/activity-log.entity.js +0 -62
  530. package/src/lib/workflow-engine/activity-log.entity.js.map +0 -1
  531. package/src/lib/workflow-engine/approval-instance-page-info.object.d.ts +0 -8
  532. package/src/lib/workflow-engine/approval-instance-page-info.object.js +0 -36
  533. package/src/lib/workflow-engine/approval-instance-page-info.object.js.map +0 -1
  534. package/src/lib/workflow-engine/approval-instance.entity.d.ts +0 -22
  535. package/src/lib/workflow-engine/approval-instance.entity.js +0 -113
  536. package/src/lib/workflow-engine/approval-instance.entity.js.map +0 -1
  537. package/src/lib/workflow-engine/dto/cancel-approval-instance.input.d.ts +0 -5
  538. package/src/lib/workflow-engine/dto/cancel-approval-instance.input.js +0 -29
  539. package/src/lib/workflow-engine/dto/cancel-approval-instance.input.js.map +0 -1
  540. package/src/lib/workflow-engine/dto/decide-task.input.d.ts +0 -9
  541. package/src/lib/workflow-engine/dto/decide-task.input.js +0 -47
  542. package/src/lib/workflow-engine/dto/decide-task.input.js.map +0 -1
  543. package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.d.ts +0 -6
  544. package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.js +0 -34
  545. package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.js.map +0 -1
  546. package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.d.ts +0 -6
  547. package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.js +0 -34
  548. package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.js.map +0 -1
  549. package/src/lib/workflow-engine/dto/submit-approval-instance.input.d.ts +0 -7
  550. package/src/lib/workflow-engine/dto/submit-approval-instance.input.js +0 -40
  551. package/src/lib/workflow-engine/dto/submit-approval-instance.input.js.map +0 -1
  552. package/src/lib/workflow-engine/index.js +0 -24
  553. package/src/lib/workflow-engine/index.js.map +0 -1
  554. package/src/lib/workflow-engine/task-candidate.entity.d.ts +0 -14
  555. package/src/lib/workflow-engine/task-candidate.entity.js +0 -72
  556. package/src/lib/workflow-engine/task-candidate.entity.js.map +0 -1
  557. package/src/lib/workflow-engine/task-decision.entity.d.ts +0 -12
  558. package/src/lib/workflow-engine/task-decision.entity.js +0 -60
  559. package/src/lib/workflow-engine/task-decision.entity.js.map +0 -1
  560. package/src/lib/workflow-engine/task.entity.d.ts +0 -20
  561. package/src/lib/workflow-engine/task.entity.js +0 -109
  562. package/src/lib/workflow-engine/task.entity.js.map +0 -1
  563. package/src/lib/workflow-engine/workflow-condition-evaluator.d.ts +0 -5
  564. package/src/lib/workflow-engine/workflow-condition-evaluator.js +0 -107
  565. package/src/lib/workflow-engine/workflow-condition-evaluator.js.map +0 -1
  566. package/src/lib/workflow-engine/workflow-dashboard-summary.object.d.ts +0 -8
  567. package/src/lib/workflow-engine/workflow-dashboard-summary.object.js +0 -36
  568. package/src/lib/workflow-engine/workflow-dashboard-summary.object.js.map +0 -1
  569. package/src/lib/workflow-engine/workflow-dry-run.object.d.ts +0 -21
  570. package/src/lib/workflow-engine/workflow-dry-run.object.js +0 -86
  571. package/src/lib/workflow-engine/workflow-dry-run.object.js.map +0 -1
  572. package/src/lib/workflow-engine/workflow-engine.enums.d.ts +0 -58
  573. package/src/lib/workflow-engine/workflow-engine.enums.js +0 -95
  574. package/src/lib/workflow-engine/workflow-engine.enums.js.map +0 -1
  575. package/src/lib/workflow-engine/workflow-engine.module.d.ts +0 -9
  576. package/src/lib/workflow-engine/workflow-engine.module.js +0 -76
  577. package/src/lib/workflow-engine/workflow-engine.module.js.map +0 -1
  578. package/src/lib/workflow-engine/workflow-engine.mutations.d.ts +0 -19
  579. package/src/lib/workflow-engine/workflow-engine.mutations.js +0 -106
  580. package/src/lib/workflow-engine/workflow-engine.mutations.js.map +0 -1
  581. package/src/lib/workflow-engine/workflow-engine.queries.d.ts +0 -29
  582. package/src/lib/workflow-engine/workflow-engine.queries.js +0 -225
  583. package/src/lib/workflow-engine/workflow-engine.queries.js.map +0 -1
  584. package/src/lib/workflow-engine/workflow-engine.service.d.ts +0 -145
  585. package/src/lib/workflow-engine/workflow-engine.service.js +0 -2785
  586. package/src/lib/workflow-engine/workflow-engine.service.js.map +0 -1
  587. package/src/lib/workflow-engine/workflow-engine.tokens.js +0 -5
  588. package/src/lib/workflow-engine/workflow-engine.tokens.js.map +0 -1
  589. package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.d.ts +0 -18
  590. package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js +0 -39
  591. package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js.map +0 -1
  592. package/src/lib/workflow-engine/workflow-token.entity.d.ts +0 -10
  593. package/src/lib/workflow-engine/workflow-token.entity.js +0 -50
  594. package/src/lib/workflow-engine/workflow-token.entity.js.map +0 -1
  595. /package/src/{index.d.ts → index.ts} +0 -0
  596. /package/src/lib/attachment/{index.d.ts → index.ts} +0 -0
  597. /package/src/lib/bpm/{index.d.ts → index.ts} +0 -0
  598. /package/src/lib/bpm-auth/{index.d.ts → index.ts} +0 -0
  599. /package/src/lib/common/{index.d.ts → index.ts} +0 -0
  600. /package/src/lib/condition/{index.d.ts → index.ts} +0 -0
  601. /package/src/lib/database/{index.d.ts → index.ts} +0 -0
  602. /package/src/lib/delegation/{index.d.ts → index.ts} +0 -0
  603. /package/src/lib/form/{index.d.ts → index.ts} +0 -0
  604. /package/src/lib/identity/{index.d.ts → index.ts} +0 -0
  605. /package/src/lib/notification/{index.d.ts → index.ts} +0 -0
  606. /package/src/lib/organization/{index.d.ts → index.ts} +0 -0
  607. /package/src/lib/signature/{index.d.ts → index.ts} +0 -0
  608. /package/src/lib/template/{index.d.ts → index.ts} +0 -0
  609. /package/src/lib/workflow-engine/{index.d.ts → index.ts} +0 -0
@@ -0,0 +1,820 @@
1
+ import {
2
+ BadRequestException,
3
+ ConflictException,
4
+ Injectable,
5
+ NotFoundException,
6
+ } from '@nestjs/common';
7
+ import { InjectRepository } from '@nestjs/typeorm';
8
+ import { WorkflowDefinition } from '@rytass/bpm-core-shared/workflow';
9
+ import { FindOptionsWhere, ILike, IsNull, Not, Repository } from 'typeorm';
10
+ import { ConditionService } from '../condition/condition.service';
11
+ import { FormDefinitionVersionEntity } from '../form/form-definition-version.entity';
12
+ import { FormDefinitionVersionStatusEnum } from '../form/form.enums';
13
+ import { ApprovalTemplateCategoryEntity } from './approval-template-category.entity';
14
+ import { ApprovalTemplateEntity } from './approval-template.entity';
15
+ import { ApprovalTemplateVersionEntity } from './approval-template-version.entity';
16
+ import {
17
+ CreateApprovalTemplateCategoryInput,
18
+ CreateApprovalTemplateInput,
19
+ UpdateApprovalTemplateCategoryInput,
20
+ UpdateApprovalTemplateDraftInput,
21
+ UpdateApprovalTemplateInput,
22
+ } from './dto/approval-template.input';
23
+ import {
24
+ ApprovalTemplateCategoryStatusEnum,
25
+ ApprovalTemplateListStatusEnum,
26
+ ApprovalTemplateVersionStatusEnum,
27
+ } from './template.enums';
28
+ import {
29
+ EMPTY_WORKFLOW_DEFINITION,
30
+ lintWorkflowDefinition,
31
+ parseWorkflowDefinitionJson,
32
+ } from './workflow-definition.validator';
33
+
34
+ interface MaxVersionRow {
35
+ readonly maxVersion?: number | string | null;
36
+ }
37
+
38
+ interface ListApprovalTemplatesOptions {
39
+ readonly page?: number;
40
+ readonly pageSize?: number;
41
+ readonly categoryId?: string;
42
+ readonly searchText?: string;
43
+ readonly status?: ApprovalTemplateListStatusEnum;
44
+ }
45
+
46
+ interface ListApprovalTemplateCategoriesOptions {
47
+ readonly page?: number;
48
+ readonly pageSize?: number;
49
+ readonly searchText?: string;
50
+ readonly status?: ApprovalTemplateCategoryStatusEnum;
51
+ }
52
+
53
+ @Injectable()
54
+ export class TemplateService {
55
+ constructor(
56
+ @InjectRepository(ApprovalTemplateEntity)
57
+ private readonly templateRepository: Repository<ApprovalTemplateEntity>,
58
+ @InjectRepository(ApprovalTemplateCategoryEntity)
59
+ private readonly templateCategoryRepository: Repository<ApprovalTemplateCategoryEntity>,
60
+ @InjectRepository(ApprovalTemplateVersionEntity)
61
+ private readonly templateVersionRepository: Repository<ApprovalTemplateVersionEntity>,
62
+ @InjectRepository(FormDefinitionVersionEntity)
63
+ private readonly formDefinitionVersionRepository: Repository<FormDefinitionVersionEntity>,
64
+ private readonly conditionService: ConditionService,
65
+ ) {}
66
+
67
+ async createApprovalTemplate(
68
+ input: CreateApprovalTemplateInput,
69
+ ): Promise<ApprovalTemplateEntity> {
70
+ await this.validateOptionalFormDefinitionVersion(
71
+ input.formDefinitionVersionId,
72
+ );
73
+ const category = await this.validateOptionalTemplateCategory(
74
+ input.categoryId,
75
+ );
76
+
77
+ return this.templateRepository.manager.transaction(
78
+ async (manager): Promise<ApprovalTemplateEntity> => {
79
+ const templateRepository = manager.getRepository(
80
+ ApprovalTemplateEntity,
81
+ );
82
+ const versionRepository = manager.getRepository(
83
+ ApprovalTemplateVersionEntity,
84
+ );
85
+ const template = await templateRepository.save(
86
+ templateRepository.create({
87
+ category: input.category ?? category?.name ?? null,
88
+ categoryId: category?.id ?? null,
89
+ createdByMemberId: input.createdByMemberId,
90
+ currentVersionId: null,
91
+ description: input.description,
92
+ name: input.name,
93
+ }),
94
+ );
95
+
96
+ await versionRepository.save(
97
+ versionRepository.create({
98
+ archivedAt: null,
99
+ formDefinitionVersionId: input.formDefinitionVersionId,
100
+ initiatorPolicyCel: null,
101
+ notificationConfig: null,
102
+ publishedAt: null,
103
+ publishedByMemberId: null,
104
+ slaDefaults: null,
105
+ status: ApprovalTemplateVersionStatusEnum.DRAFT,
106
+ templateId: template.id,
107
+ version: 1,
108
+ workflowDefinition: EMPTY_WORKFLOW_DEFINITION,
109
+ }),
110
+ );
111
+
112
+ return template;
113
+ },
114
+ );
115
+ }
116
+
117
+ async updateApprovalTemplate(
118
+ input: UpdateApprovalTemplateInput,
119
+ ): Promise<ApprovalTemplateEntity> {
120
+ const existing = await this.getTemplateOrThrow(input.id);
121
+ const category =
122
+ input.categoryId === undefined
123
+ ? undefined
124
+ : await this.validateOptionalTemplateCategory(input.categoryId);
125
+ const next = this.templateRepository.merge(existing, {
126
+ category:
127
+ input.category !== undefined
128
+ ? input.category
129
+ : category !== undefined
130
+ ? (category?.name ?? null)
131
+ : existing.category,
132
+ categoryId:
133
+ input.categoryId === undefined
134
+ ? existing.categoryId
135
+ : (category?.id ?? null),
136
+ description: input.description ?? existing.description,
137
+ name: input.name ?? existing.name,
138
+ });
139
+
140
+ return this.templateRepository.save(next);
141
+ }
142
+
143
+ async listApprovalTemplates(
144
+ options: ListApprovalTemplatesOptions = {},
145
+ ): Promise<readonly ApprovalTemplateEntity[]> {
146
+ const isPaginated =
147
+ typeof options.page === 'number' || typeof options.pageSize === 'number';
148
+ const normalizedPageSize = isPaginated
149
+ ? normalizePageSize(options.pageSize ?? 10)
150
+ : undefined;
151
+
152
+ return this.templateRepository.find({
153
+ order: { updatedAt: 'DESC', createdAt: 'DESC' },
154
+ relations: { categoryDetail: true },
155
+ ...(normalizedPageSize
156
+ ? {
157
+ skip: (normalizePage(options.page ?? 1) - 1) * normalizedPageSize,
158
+ take: normalizedPageSize,
159
+ }
160
+ : {}),
161
+ where: createApprovalTemplateWhere({
162
+ categoryId: options.categoryId,
163
+ searchText: options.searchText,
164
+ status: options.status,
165
+ }),
166
+ });
167
+ }
168
+
169
+ async countApprovalTemplates({
170
+ categoryId,
171
+ searchText,
172
+ status,
173
+ }: {
174
+ readonly categoryId?: string;
175
+ readonly searchText?: string;
176
+ readonly status?: ApprovalTemplateListStatusEnum;
177
+ } = {}): Promise<number> {
178
+ return this.templateRepository.count({
179
+ where: createApprovalTemplateWhere({ categoryId, searchText, status }),
180
+ });
181
+ }
182
+
183
+ async getApprovalTemplate(id: string): Promise<ApprovalTemplateEntity> {
184
+ return this.getTemplateOrThrow(id);
185
+ }
186
+
187
+ async listApprovalTemplateCategories(
188
+ options: ListApprovalTemplateCategoriesOptions = {},
189
+ ): Promise<readonly ApprovalTemplateCategoryEntity[]> {
190
+ const isPaginated =
191
+ typeof options.page === 'number' || typeof options.pageSize === 'number';
192
+ const normalizedPageSize = isPaginated
193
+ ? normalizePageSize(options.pageSize ?? 10)
194
+ : undefined;
195
+
196
+ return this.templateCategoryRepository.find({
197
+ order: { sortOrder: 'ASC', name: 'ASC', createdAt: 'ASC' },
198
+ ...(normalizedPageSize
199
+ ? {
200
+ skip: (normalizePage(options.page ?? 1) - 1) * normalizedPageSize,
201
+ take: normalizedPageSize,
202
+ }
203
+ : {}),
204
+ where: createApprovalTemplateCategoryWhere({
205
+ searchText: options.searchText,
206
+ status: options.status,
207
+ }),
208
+ });
209
+ }
210
+
211
+ async countApprovalTemplateCategories({
212
+ searchText,
213
+ status,
214
+ }: {
215
+ readonly searchText?: string;
216
+ readonly status?: ApprovalTemplateCategoryStatusEnum;
217
+ } = {}): Promise<number> {
218
+ return this.templateCategoryRepository.count({
219
+ where: createApprovalTemplateCategoryWhere({ searchText, status }),
220
+ });
221
+ }
222
+
223
+ async createApprovalTemplateCategory(
224
+ input: CreateApprovalTemplateCategoryInput,
225
+ ): Promise<ApprovalTemplateCategoryEntity> {
226
+ return this.templateCategoryRepository.save(
227
+ this.templateCategoryRepository.create({
228
+ description: input.description,
229
+ isActive: input.isActive ?? true,
230
+ name: input.name,
231
+ sortOrder: input.sortOrder ?? 0,
232
+ }),
233
+ );
234
+ }
235
+
236
+ async updateApprovalTemplateCategory(
237
+ input: UpdateApprovalTemplateCategoryInput,
238
+ ): Promise<ApprovalTemplateCategoryEntity> {
239
+ const existing = await this.getTemplateCategoryOrThrow(input.id);
240
+
241
+ return this.templateCategoryRepository.save(
242
+ this.templateCategoryRepository.merge(existing, {
243
+ description: input.description ?? existing.description,
244
+ isActive: input.isActive ?? existing.isActive,
245
+ name: input.name ?? existing.name,
246
+ sortOrder: input.sortOrder ?? existing.sortOrder,
247
+ }),
248
+ );
249
+ }
250
+
251
+ async activateApprovalTemplateCategory(
252
+ id: string,
253
+ ): Promise<ApprovalTemplateCategoryEntity> {
254
+ return this.setApprovalTemplateCategoryActive(id, true);
255
+ }
256
+
257
+ async deactivateApprovalTemplateCategory(
258
+ id: string,
259
+ ): Promise<ApprovalTemplateCategoryEntity> {
260
+ return this.setApprovalTemplateCategoryActive(id, false);
261
+ }
262
+
263
+ async deleteApprovalTemplateCategory(
264
+ id: string,
265
+ ): Promise<ApprovalTemplateCategoryEntity> {
266
+ const category = await this.getTemplateCategoryOrThrow(id);
267
+ const templateCount = await this.templateRepository.count({
268
+ where: { categoryId: id, deletedAt: IsNull() },
269
+ });
270
+
271
+ if (templateCount > 0) {
272
+ return this.templateCategoryRepository.save(
273
+ this.templateCategoryRepository.merge(category, {
274
+ isActive: false,
275
+ }),
276
+ );
277
+ }
278
+
279
+ await this.templateCategoryRepository.remove(category);
280
+
281
+ return category;
282
+ }
283
+
284
+ async listApprovalTemplateVersions(
285
+ templateId: string,
286
+ ): Promise<readonly ApprovalTemplateVersionEntity[]> {
287
+ await this.getTemplateOrThrow(templateId);
288
+
289
+ return this.templateVersionRepository.find({
290
+ order: { version: 'DESC' },
291
+ where: { templateId },
292
+ });
293
+ }
294
+
295
+ async getApprovalTemplateVersion(
296
+ id: string,
297
+ ): Promise<ApprovalTemplateVersionEntity> {
298
+ return this.getTemplateVersionOrThrow(id);
299
+ }
300
+
301
+ async updateApprovalTemplateDraft(
302
+ input: UpdateApprovalTemplateDraftInput,
303
+ ): Promise<ApprovalTemplateVersionEntity> {
304
+ const existing = await this.getTemplateVersionOrThrow(input.versionId);
305
+
306
+ if (existing.status !== ApprovalTemplateVersionStatusEnum.DRAFT) {
307
+ throw new ConflictException(
308
+ 'Only draft approval template versions can be updated',
309
+ );
310
+ }
311
+
312
+ await this.validateOptionalFormDefinitionVersion(
313
+ input.formDefinitionVersionId,
314
+ );
315
+ const workflowDefinition = this.parseWorkflowDefinitionOrThrow(
316
+ input.workflowDefinitionJson,
317
+ );
318
+ const next = this.templateVersionRepository.merge(existing, {
319
+ formDefinitionVersionId: input.formDefinitionVersionId,
320
+ initiatorPolicyCel: input.initiatorPolicyCel,
321
+ notificationConfig: parseOptionalJsonObject(input.notificationConfigJson),
322
+ slaDefaults: parseOptionalJsonObject(input.slaDefaultsJson),
323
+ workflowDefinition,
324
+ });
325
+
326
+ return this.templateVersionRepository.save(next);
327
+ }
328
+
329
+ async forkApprovalTemplate(
330
+ templateId: string,
331
+ ): Promise<ApprovalTemplateVersionEntity> {
332
+ const template = await this.getTemplateOrThrow(templateId);
333
+ const existingDraft = await this.templateVersionRepository.findOne({
334
+ where: {
335
+ status: ApprovalTemplateVersionStatusEnum.DRAFT,
336
+ templateId: template.id,
337
+ },
338
+ });
339
+
340
+ if (existingDraft) {
341
+ throw new ConflictException(
342
+ 'A draft approval template version already exists',
343
+ );
344
+ }
345
+
346
+ const source = template.currentVersionId
347
+ ? await this.getTemplateVersionOrThrow(template.currentVersionId)
348
+ : null;
349
+ const nextVersion = await this.readNextVersionNumber(template.id);
350
+
351
+ return this.templateVersionRepository.save(
352
+ this.templateVersionRepository.create({
353
+ archivedAt: null,
354
+ formDefinitionVersionId: source?.formDefinitionVersionId ?? null,
355
+ initiatorPolicyCel: source?.initiatorPolicyCel ?? null,
356
+ notificationConfig: source?.notificationConfig ?? null,
357
+ publishedAt: null,
358
+ publishedByMemberId: null,
359
+ slaDefaults: source?.slaDefaults ?? null,
360
+ status: ApprovalTemplateVersionStatusEnum.DRAFT,
361
+ templateId: template.id,
362
+ version: nextVersion,
363
+ workflowDefinition:
364
+ source?.workflowDefinition ?? EMPTY_WORKFLOW_DEFINITION,
365
+ }),
366
+ );
367
+ }
368
+
369
+ async publishApprovalTemplateVersion(
370
+ versionId: string,
371
+ publishedByMemberId?: string,
372
+ ): Promise<ApprovalTemplateVersionEntity> {
373
+ const version = await this.getTemplateVersionOrThrow(versionId);
374
+
375
+ if (version.status !== ApprovalTemplateVersionStatusEnum.DRAFT) {
376
+ throw new ConflictException(
377
+ 'Only draft approval template versions can be published',
378
+ );
379
+ }
380
+
381
+ await this.validatePublishableVersion(version);
382
+
383
+ return this.templateRepository.manager.transaction(
384
+ async (manager): Promise<ApprovalTemplateVersionEntity> => {
385
+ const templateRepository = manager.getRepository(
386
+ ApprovalTemplateEntity,
387
+ );
388
+ const versionRepository = manager.getRepository(
389
+ ApprovalTemplateVersionEntity,
390
+ );
391
+ const template = await templateRepository.findOne({
392
+ where: { deletedAt: IsNull(), id: version.templateId },
393
+ });
394
+
395
+ if (!template) {
396
+ throw new NotFoundException(
397
+ `Approval template ${version.templateId} was not found`,
398
+ );
399
+ }
400
+
401
+ if (template.currentVersionId) {
402
+ await versionRepository.update(
403
+ { id: template.currentVersionId },
404
+ {
405
+ archivedAt: new Date(),
406
+ status: ApprovalTemplateVersionStatusEnum.ARCHIVED,
407
+ },
408
+ );
409
+ }
410
+
411
+ const published = versionRepository.merge(version, {
412
+ archivedAt: null,
413
+ publishedAt: new Date(),
414
+ publishedByMemberId: publishedByMemberId ?? null,
415
+ status: ApprovalTemplateVersionStatusEnum.PUBLISHED,
416
+ });
417
+ const saved = await versionRepository.save(published);
418
+ await templateRepository.save(
419
+ templateRepository.merge(template, {
420
+ currentVersionId: saved.id,
421
+ }),
422
+ );
423
+
424
+ return saved;
425
+ },
426
+ );
427
+ }
428
+
429
+ async rollbackApprovalTemplateVersion(
430
+ versionId: string,
431
+ ): Promise<ApprovalTemplateVersionEntity> {
432
+ const target = await this.getTemplateVersionOrThrow(versionId);
433
+
434
+ if (target.status === ApprovalTemplateVersionStatusEnum.DRAFT) {
435
+ throw new ConflictException(
436
+ 'Draft approval template versions cannot be rollback targets',
437
+ );
438
+ }
439
+
440
+ return this.templateRepository.manager.transaction(
441
+ async (manager): Promise<ApprovalTemplateVersionEntity> => {
442
+ const templateRepository = manager.getRepository(
443
+ ApprovalTemplateEntity,
444
+ );
445
+ const versionRepository = manager.getRepository(
446
+ ApprovalTemplateVersionEntity,
447
+ );
448
+ const template = await templateRepository.findOne({
449
+ where: { deletedAt: IsNull(), id: target.templateId },
450
+ });
451
+
452
+ if (!template) {
453
+ throw new NotFoundException(
454
+ `Approval template ${target.templateId} was not found`,
455
+ );
456
+ }
457
+
458
+ if (
459
+ template.currentVersionId &&
460
+ template.currentVersionId !== target.id
461
+ ) {
462
+ await versionRepository.update(
463
+ { id: template.currentVersionId },
464
+ {
465
+ archivedAt: new Date(),
466
+ status: ApprovalTemplateVersionStatusEnum.ARCHIVED,
467
+ },
468
+ );
469
+ }
470
+
471
+ const restored = versionRepository.merge(target, {
472
+ archivedAt: null,
473
+ status: ApprovalTemplateVersionStatusEnum.PUBLISHED,
474
+ });
475
+ const saved = await versionRepository.save(restored);
476
+ await templateRepository.save(
477
+ templateRepository.merge(template, {
478
+ currentVersionId: saved.id,
479
+ }),
480
+ );
481
+
482
+ return saved;
483
+ },
484
+ );
485
+ }
486
+
487
+ private async validatePublishableVersion(
488
+ version: ApprovalTemplateVersionEntity,
489
+ ): Promise<void> {
490
+ if (!version.formDefinitionVersionId) {
491
+ throw new BadRequestException(
492
+ 'Approval template version must bind a form definition version before publishing',
493
+ );
494
+ }
495
+
496
+ const formVersion = await this.formDefinitionVersionRepository.findOne({
497
+ where: { id: version.formDefinitionVersionId },
498
+ });
499
+
500
+ if (!formVersion) {
501
+ throw new NotFoundException(
502
+ `Form definition version ${version.formDefinitionVersionId} was not found`,
503
+ );
504
+ }
505
+
506
+ if (formVersion.status !== FormDefinitionVersionStatusEnum.PUBLISHED) {
507
+ throw new BadRequestException(
508
+ 'Approval template can only bind a published form definition version',
509
+ );
510
+ }
511
+
512
+ const workflowResult = lintWorkflowDefinition(version.workflowDefinition);
513
+ const conditionErrors = this.conditionService.lintExpressions(
514
+ readConditionExpressions(
515
+ version.workflowDefinition,
516
+ version.initiatorPolicyCel,
517
+ ),
518
+ {
519
+ allowedRootIdentifiers: [
520
+ 'env',
521
+ 'form',
522
+ 'formData',
523
+ 'initiator',
524
+ 'instance',
525
+ 'subject',
526
+ ],
527
+ },
528
+ );
529
+ const errors = [...workflowResult.errors, ...conditionErrors];
530
+
531
+ if (errors.length) {
532
+ throw new BadRequestException(errors.join('; '));
533
+ }
534
+ }
535
+
536
+ private async validateOptionalFormDefinitionVersion(
537
+ formDefinitionVersionId: string | null | undefined,
538
+ ): Promise<void> {
539
+ if (!formDefinitionVersionId) {
540
+ return;
541
+ }
542
+
543
+ const formVersion = await this.formDefinitionVersionRepository.findOne({
544
+ where: { id: formDefinitionVersionId },
545
+ });
546
+
547
+ if (!formVersion) {
548
+ throw new NotFoundException(
549
+ `Form definition version ${formDefinitionVersionId} was not found`,
550
+ );
551
+ }
552
+ }
553
+
554
+ private async validateOptionalTemplateCategory(
555
+ categoryId: string | null | undefined,
556
+ ): Promise<ApprovalTemplateCategoryEntity | null> {
557
+ if (!categoryId) {
558
+ return null;
559
+ }
560
+
561
+ return this.getTemplateCategoryOrThrow(categoryId);
562
+ }
563
+
564
+ private async getTemplateOrThrow(
565
+ id: string,
566
+ ): Promise<ApprovalTemplateEntity> {
567
+ const entity = await this.templateRepository.findOne({
568
+ relations: { categoryDetail: true },
569
+ where: { deletedAt: IsNull(), id },
570
+ });
571
+
572
+ if (!entity) {
573
+ throw new NotFoundException(`Approval template ${id} was not found`);
574
+ }
575
+
576
+ return entity;
577
+ }
578
+
579
+ private async getTemplateCategoryOrThrow(
580
+ id: string,
581
+ ): Promise<ApprovalTemplateCategoryEntity> {
582
+ const entity = await this.templateCategoryRepository.findOne({
583
+ where: { id },
584
+ });
585
+
586
+ if (!entity) {
587
+ throw new NotFoundException(
588
+ `Approval template category ${id} was not found`,
589
+ );
590
+ }
591
+
592
+ return entity;
593
+ }
594
+
595
+ private async setApprovalTemplateCategoryActive(
596
+ id: string,
597
+ isActive: boolean,
598
+ ): Promise<ApprovalTemplateCategoryEntity> {
599
+ const category = await this.getTemplateCategoryOrThrow(id);
600
+
601
+ return this.templateCategoryRepository.save(
602
+ this.templateCategoryRepository.merge(category, {
603
+ isActive,
604
+ }),
605
+ );
606
+ }
607
+
608
+ private async getTemplateVersionOrThrow(
609
+ id: string,
610
+ ): Promise<ApprovalTemplateVersionEntity> {
611
+ const entity = await this.templateVersionRepository.findOne({
612
+ where: { id },
613
+ });
614
+
615
+ if (!entity) {
616
+ throw new NotFoundException(
617
+ `Approval template version ${id} was not found`,
618
+ );
619
+ }
620
+
621
+ return entity;
622
+ }
623
+
624
+ private async readNextVersionNumber(templateId: string): Promise<number> {
625
+ const row = await this.templateVersionRepository
626
+ .createQueryBuilder('version')
627
+ .select('MAX(version.version)', 'maxVersion')
628
+ .where('version.template_id = :templateId', { templateId })
629
+ .getRawOne<MaxVersionRow>();
630
+ const maxVersion =
631
+ typeof row?.maxVersion === 'number'
632
+ ? row.maxVersion
633
+ : Number(row?.maxVersion ?? 0);
634
+
635
+ return maxVersion + 1;
636
+ }
637
+
638
+ private parseWorkflowDefinitionOrThrow(value: string): WorkflowDefinition {
639
+ try {
640
+ return parseWorkflowDefinitionJson(value);
641
+ } catch (error: unknown) {
642
+ throw new BadRequestException(
643
+ error instanceof Error ? error.message : 'Invalid workflow definition',
644
+ );
645
+ }
646
+ }
647
+ }
648
+
649
+ function parseOptionalJsonObject(
650
+ value: string | null | undefined,
651
+ ): Readonly<Record<string, unknown>> | null {
652
+ if (!value) {
653
+ return null;
654
+ }
655
+
656
+ const parsedValue = parseJson(value);
657
+
658
+ if (!isRecord(parsedValue)) {
659
+ throw new BadRequestException('JSON value must be an object');
660
+ }
661
+
662
+ return parsedValue;
663
+ }
664
+
665
+ function parseJson(value: string): unknown {
666
+ try {
667
+ return JSON.parse(value) as unknown;
668
+ } catch (error: unknown) {
669
+ throw new BadRequestException(
670
+ error instanceof Error ? error.message : 'Invalid JSON value',
671
+ );
672
+ }
673
+ }
674
+
675
+ function normalizePage(page: number): number {
676
+ return Number.isInteger(page) && page > 0 ? page : 1;
677
+ }
678
+
679
+ function normalizePageSize(pageSize: number): number {
680
+ if (!Number.isInteger(pageSize) || pageSize <= 0) {
681
+ return 10;
682
+ }
683
+
684
+ return Math.min(pageSize, 100);
685
+ }
686
+
687
+ function createApprovalTemplateWhere(
688
+ options: Readonly<{
689
+ readonly categoryId?: string;
690
+ readonly searchText?: string;
691
+ readonly status?: ApprovalTemplateListStatusEnum;
692
+ }>,
693
+ ):
694
+ | FindOptionsWhere<ApprovalTemplateEntity>
695
+ | FindOptionsWhere<ApprovalTemplateEntity>[] {
696
+ const activeTemplateWhere: FindOptionsWhere<ApprovalTemplateEntity> = {
697
+ deletedAt: IsNull(),
698
+ };
699
+ const statusWhere: FindOptionsWhere<ApprovalTemplateEntity> =
700
+ options.status === ApprovalTemplateListStatusEnum.DRAFT
701
+ ? { currentVersionId: IsNull() }
702
+ : {};
703
+ const publicationWhere: FindOptionsWhere<ApprovalTemplateEntity> =
704
+ options.status === ApprovalTemplateListStatusEnum.PUBLISHED
705
+ ? { currentVersionId: Not(IsNull()) }
706
+ : {};
707
+ const baseWhere: FindOptionsWhere<ApprovalTemplateEntity> = {
708
+ ...activeTemplateWhere,
709
+ ...(options.categoryId ? { categoryId: options.categoryId } : {}),
710
+ ...statusWhere,
711
+ ...publicationWhere,
712
+ };
713
+
714
+ const trimmedSearchText = options.searchText?.trim();
715
+
716
+ if (!trimmedSearchText) {
717
+ return baseWhere;
718
+ }
719
+
720
+ const searchPattern = `%${trimmedSearchText}%`;
721
+
722
+ return [
723
+ { ...baseWhere, name: ILike(searchPattern) },
724
+ { ...baseWhere, category: ILike(searchPattern) },
725
+ { ...baseWhere, description: ILike(searchPattern) },
726
+ ];
727
+ }
728
+
729
+ function createApprovalTemplateCategoryWhere(
730
+ options: Readonly<{
731
+ readonly searchText?: string;
732
+ readonly status?: ApprovalTemplateCategoryStatusEnum;
733
+ }>,
734
+ ):
735
+ | FindOptionsWhere<ApprovalTemplateCategoryEntity>
736
+ | FindOptionsWhere<ApprovalTemplateCategoryEntity>[] {
737
+ const statusWhere: FindOptionsWhere<ApprovalTemplateCategoryEntity> =
738
+ options.status === ApprovalTemplateCategoryStatusEnum.ALL
739
+ ? {}
740
+ : options.status === ApprovalTemplateCategoryStatusEnum.INACTIVE
741
+ ? { isActive: false }
742
+ : { isActive: true };
743
+ const trimmedSearchText = options.searchText?.trim();
744
+
745
+ if (!trimmedSearchText) {
746
+ return statusWhere;
747
+ }
748
+
749
+ const searchPattern = `%${trimmedSearchText}%`;
750
+
751
+ return [
752
+ { ...statusWhere, name: ILike(searchPattern) },
753
+ { ...statusWhere, description: ILike(searchPattern) },
754
+ ];
755
+ }
756
+
757
+ function readConditionExpressions(
758
+ definition: WorkflowDefinition,
759
+ initiatorPolicyCel: string | null,
760
+ ): readonly {
761
+ readonly expression: string | null | undefined;
762
+ readonly label: string;
763
+ }[] {
764
+ return [
765
+ { expression: initiatorPolicyCel, label: 'initiatorPolicyCel' },
766
+ ...definition.edges.map((edge) => ({
767
+ expression: edge.data.condition,
768
+ label: `workflow.edges.${edge.id}.data.condition`,
769
+ })),
770
+ ...definition.nodes.flatMap((node) => {
771
+ if (node.type === 'userTask') {
772
+ return [
773
+ {
774
+ expression: node.data.entryCondition,
775
+ label: `workflow.nodes.${node.id}.data.entryCondition`,
776
+ },
777
+ ...(node.data.approverResolver.type === 'EXPRESSION'
778
+ ? [
779
+ {
780
+ expression: node.data.approverResolver.expression,
781
+ label: `workflow.nodes.${node.id}.data.approverResolver.expression`,
782
+ },
783
+ ]
784
+ : []),
785
+ ];
786
+ }
787
+
788
+ if (node.type === 'serviceTask') {
789
+ return [
790
+ {
791
+ expression: node.data.entryCondition,
792
+ label: `workflow.nodes.${node.id}.data.entryCondition`,
793
+ },
794
+ ...(node.data.action.type === 'WEBHOOK'
795
+ ? [
796
+ {
797
+ expression: node.data.action.payload,
798
+ label: `workflow.nodes.${node.id}.data.action.payload`,
799
+ },
800
+ ]
801
+ : []),
802
+ ...(node.data.action.type === 'SET_FORM_FIELD'
803
+ ? [
804
+ {
805
+ expression: node.data.action.value,
806
+ label: `workflow.nodes.${node.id}.data.action.value`,
807
+ },
808
+ ]
809
+ : []),
810
+ ];
811
+ }
812
+
813
+ return [];
814
+ }),
815
+ ];
816
+ }
817
+
818
+ function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
819
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
820
+ }