@rytass/bpm-core-nestjs-module 0.5.0 → 0.5.1
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.
- package/CHANGELOG.md +19 -0
- package/package.json +1 -1
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/attachment/attachment-options.d.ts +44 -0
- package/src/lib/attachment/attachment-options.js +62 -0
- package/src/lib/attachment/attachment-options.js.map +1 -0
- package/src/lib/attachment/attachment-storage.provider.d.ts +4 -0
- package/src/lib/attachment/attachment-storage.provider.js +35 -0
- package/src/lib/attachment/attachment-storage.provider.js.map +1 -0
- package/src/lib/attachment/{attachment-storage.token.ts → attachment-storage.token.d.ts} +1 -3
- package/src/lib/attachment/attachment-storage.token.js +5 -0
- package/src/lib/attachment/attachment-storage.token.js.map +1 -0
- package/src/lib/attachment/attachment.controller.d.ts +8 -0
- package/src/lib/attachment/attachment.controller.js +38 -0
- package/src/lib/attachment/attachment.controller.js.map +1 -0
- package/src/lib/attachment/attachment.entity.d.ts +14 -0
- package/src/lib/attachment/attachment.entity.js +74 -0
- package/src/lib/attachment/attachment.entity.js.map +1 -0
- package/src/lib/attachment/attachment.module.d.ts +27 -0
- package/src/lib/attachment/attachment.module.js +103 -0
- package/src/lib/attachment/attachment.module.js.map +1 -0
- package/src/lib/attachment/attachment.mutations.d.ts +8 -0
- package/src/lib/attachment/attachment.mutations.js +35 -0
- package/src/lib/attachment/attachment.mutations.js.map +1 -0
- package/src/lib/attachment/attachment.queries.d.ts +9 -0
- package/src/lib/attachment/attachment.queries.js +78 -0
- package/src/lib/attachment/attachment.queries.js.map +1 -0
- package/src/lib/attachment/attachment.service.d.ts +49 -0
- package/src/lib/attachment/attachment.service.js +276 -0
- package/src/lib/attachment/attachment.service.js.map +1 -0
- package/src/lib/attachment/dto/upload-attachment.input.d.ts +11 -0
- package/src/lib/attachment/dto/upload-attachment.input.js +68 -0
- package/src/lib/attachment/dto/upload-attachment.input.js.map +1 -0
- package/src/lib/attachment/index.js +9 -0
- package/src/lib/attachment/index.js.map +1 -0
- package/src/lib/bpm/bpm-root.module.d.ts +155 -0
- package/src/lib/bpm/bpm-root.module.js +170 -0
- package/src/lib/bpm/bpm-root.module.js.map +1 -0
- package/src/lib/bpm/index.js +5 -0
- package/src/lib/bpm/index.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth-context.d.ts +24 -0
- package/src/lib/bpm-auth/bpm-auth-context.extractor.d.ts +4 -0
- package/src/lib/bpm-auth/bpm-auth-context.extractor.js +69 -0
- package/src/lib/bpm-auth/bpm-auth-context.extractor.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth-context.js +15 -0
- package/src/lib/bpm-auth/bpm-auth-context.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth.authorization.d.ts +12 -0
- package/src/lib/bpm-auth/bpm-auth.authorization.js +67 -0
- package/src/lib/bpm-auth/bpm-auth.authorization.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth.decorators.d.ts +3 -0
- package/src/lib/bpm-auth/bpm-auth.decorators.js +11 -0
- package/src/lib/bpm-auth/bpm-auth.decorators.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth.guard.d.ts +7 -0
- package/src/lib/bpm-auth/bpm-auth.guard.js +24 -0
- package/src/lib/bpm-auth/bpm-auth.guard.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth.module.d.ts +6 -0
- package/src/lib/bpm-auth/bpm-auth.module.js +69 -0
- package/src/lib/bpm-auth/bpm-auth.module.js.map +1 -0
- package/src/lib/bpm-auth/bpm-auth.options.d.ts +11 -0
- package/src/lib/bpm-auth/bpm-auth.options.js +3 -0
- package/src/lib/bpm-auth/bpm-auth.options.js.map +1 -0
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.d.ts +10 -0
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.js +40 -0
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.js.map +1 -0
- package/src/lib/bpm-auth/index.js +10 -0
- package/src/lib/bpm-auth/index.js.map +1 -0
- package/src/lib/common/filters/all-exceptions.filter.d.ts +25 -0
- package/src/lib/common/filters/all-exceptions.filter.js +93 -0
- package/src/lib/common/filters/all-exceptions.filter.js.map +1 -0
- package/src/lib/common/index.js +5 -0
- package/src/lib/common/index.js.map +1 -0
- package/src/lib/common/iso-duration.d.ts +1 -0
- package/src/lib/common/iso-duration.js +27 -0
- package/src/lib/common/iso-duration.js.map +1 -0
- package/src/lib/condition/condition.module.d.ts +2 -0
- package/src/lib/condition/condition.module.js +16 -0
- package/src/lib/condition/condition.module.js.map +1 -0
- package/src/lib/condition/condition.service.d.ts +16 -0
- package/src/lib/condition/condition.service.js +82 -0
- package/src/lib/condition/condition.service.js.map +1 -0
- package/src/lib/condition/index.js +6 -0
- package/src/lib/condition/index.js.map +1 -0
- package/src/lib/database/data-source.d.ts +4 -0
- package/src/lib/database/data-source.js +7 -0
- package/src/lib/database/data-source.js.map +1 -0
- package/src/lib/database/index.js +6 -0
- package/src/lib/database/index.js.map +1 -0
- package/src/lib/database/migration-runner.d.ts +1 -0
- package/src/lib/database/migration-runner.js +25 -0
- package/src/lib/database/migration-runner.js.map +1 -0
- package/src/lib/database/reconcile-legacy-migrations.d.ts +13 -0
- package/src/lib/database/reconcile-legacy-migrations.js +70 -0
- package/src/lib/database/reconcile-legacy-migrations.js.map +1 -0
- package/src/lib/database/typeorm.config.d.ts +14 -0
- package/src/lib/database/typeorm.config.js +135 -0
- package/src/lib/database/typeorm.config.js.map +1 -0
- package/src/lib/delegation/delegation-rule.entity.d.ts +19 -0
- package/src/lib/delegation/delegation-rule.entity.js +99 -0
- package/src/lib/delegation/delegation-rule.entity.js.map +1 -0
- package/src/lib/delegation/delegation.enums.d.ts +10 -0
- package/src/lib/delegation/delegation.enums.js +23 -0
- package/src/lib/delegation/delegation.enums.js.map +1 -0
- package/src/lib/delegation/delegation.module.d.ts +2 -0
- package/src/lib/delegation/delegation.module.js +22 -0
- package/src/lib/delegation/delegation.module.js.map +1 -0
- package/src/lib/delegation/delegation.mutations.d.ts +11 -0
- package/src/lib/delegation/delegation.mutations.js +87 -0
- package/src/lib/delegation/delegation.mutations.js.map +1 -0
- package/src/lib/delegation/delegation.queries.d.ts +10 -0
- package/src/lib/delegation/delegation.queries.js +91 -0
- package/src/lib/delegation/delegation.queries.js.map +1 -0
- package/src/lib/delegation/delegation.service.d.ts +56 -0
- package/src/lib/delegation/delegation.service.js +268 -0
- package/src/lib/delegation/delegation.service.js.map +1 -0
- package/src/lib/delegation/dto/delegation-rule.input.d.ts +24 -0
- package/src/lib/delegation/dto/delegation-rule.input.js +143 -0
- package/src/lib/delegation/dto/delegation-rule.input.js.map +1 -0
- package/src/lib/delegation/index.js +9 -0
- package/src/lib/delegation/index.js.map +1 -0
- package/src/lib/form/dto/form-definition.input.d.ts +26 -0
- package/src/lib/form/dto/form-definition.input.js +126 -0
- package/src/lib/form/dto/form-definition.input.js.map +1 -0
- package/src/lib/form/form-definition-version.entity.d.ts +17 -0
- package/src/lib/form/form-definition-version.entity.js +84 -0
- package/src/lib/form/form-definition-version.entity.js.map +1 -0
- package/src/lib/form/form-definition.entity.d.ts +13 -0
- package/src/lib/form/form-definition.entity.js +66 -0
- package/src/lib/form/form-definition.entity.js.map +1 -0
- package/src/lib/form/form-schema-lint.object.d.ts +4 -0
- package/src/lib/form/form-schema-lint.object.js +20 -0
- package/src/lib/form/form-schema-lint.object.js.map +1 -0
- package/src/lib/form/form-schema.validator.d.ts +13 -0
- package/src/lib/form/form-schema.validator.js +354 -0
- package/src/lib/form/form-schema.validator.js.map +1 -0
- package/src/lib/form/form.enums.d.ts +9 -0
- package/src/lib/form/form.enums.js +22 -0
- package/src/lib/form/form.enums.js.map +1 -0
- package/src/lib/form/form.module.d.ts +2 -0
- package/src/lib/form/form.module.js +27 -0
- package/src/lib/form/form.module.js.map +1 -0
- package/src/lib/form/form.mutations.d.ts +14 -0
- package/src/lib/form/form.mutations.js +89 -0
- package/src/lib/form/form.mutations.js.map +1 -0
- package/src/lib/form/form.queries.d.ts +16 -0
- package/src/lib/form/form.queries.js +96 -0
- package/src/lib/form/form.queries.js.map +1 -0
- package/src/lib/form/form.service.d.ts +49 -0
- package/src/lib/form/form.service.js +346 -0
- package/src/lib/form/form.service.js.map +1 -0
- package/src/lib/form/index.js +12 -0
- package/src/lib/form/index.js.map +1 -0
- package/src/lib/identity/identity-options.d.ts +13 -0
- package/src/lib/identity/identity-options.js +20 -0
- package/src/lib/identity/identity-options.js.map +1 -0
- package/src/lib/identity/identity.module.d.ts +17 -0
- package/src/lib/identity/identity.module.js +65 -0
- package/src/lib/identity/identity.module.js.map +1 -0
- package/src/lib/identity/identity.queries.d.ts +12 -0
- package/src/lib/identity/identity.queries.js +79 -0
- package/src/lib/identity/identity.queries.js.map +1 -0
- package/src/lib/identity/identity.service.d.ts +31 -0
- package/src/lib/identity/identity.service.js +196 -0
- package/src/lib/identity/identity.service.js.map +1 -0
- package/src/lib/identity/index.js +8 -0
- package/src/lib/identity/index.js.map +1 -0
- package/src/lib/identity/member-base.adapter.d.ts +123 -0
- package/src/lib/identity/member-base.adapter.js +147 -0
- package/src/lib/identity/member-base.adapter.js.map +1 -0
- package/src/lib/identity/member-metadata-cache.entity.d.ts +8 -0
- package/src/lib/identity/member-metadata-cache.entity.js +39 -0
- package/src/lib/identity/member-metadata-cache.entity.js.map +1 -0
- package/src/lib/identity/{member-not-found.exception.ts → member-not-found.exception.d.ts} +3 -8
- package/src/lib/identity/member-not-found.exception.js +26 -0
- package/src/lib/identity/member-not-found.exception.js.map +1 -0
- package/src/lib/identity/member-profile.object.d.ts +8 -0
- package/src/lib/identity/member-profile.object.js +37 -0
- package/src/lib/identity/member-profile.object.js.map +1 -0
- package/src/lib/identity/{member-resolver.interface.ts → member-resolver.interface.d.ts} +41 -55
- package/src/lib/identity/member-resolver.interface.js +19 -0
- package/src/lib/identity/member-resolver.interface.js.map +1 -0
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.d.ts +6 -0
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.js +17 -0
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.js.map +1 -0
- package/src/lib/migrations/0000000001000-identity-organization-foundation.d.ts +6 -0
- package/src/lib/migrations/{0000000001000-identity-organization-foundation.ts → 0000000001000-identity-organization-foundation.js} +29 -38
- package/src/lib/migrations/0000000001000-identity-organization-foundation.js.map +1 -0
- package/src/lib/migrations/0000000002000-form-builder-foundation.d.ts +6 -0
- package/src/lib/migrations/{0000000002000-form-builder-foundation.ts → 0000000002000-form-builder-foundation.js} +21 -22
- package/src/lib/migrations/0000000002000-form-builder-foundation.js.map +1 -0
- package/src/lib/migrations/0000000003000-approval-template-foundation.d.ts +6 -0
- package/src/lib/migrations/{0000000003000-approval-template-foundation.ts → 0000000003000-approval-template-foundation.js} +21 -24
- package/src/lib/migrations/0000000003000-approval-template-foundation.js.map +1 -0
- package/src/lib/migrations/0000000004000-workflow-engine-foundation.d.ts +6 -0
- package/src/lib/migrations/{0000000004000-workflow-engine-foundation.ts → 0000000004000-workflow-engine-foundation.js} +34 -46
- package/src/lib/migrations/0000000004000-workflow-engine-foundation.js.map +1 -0
- package/src/lib/migrations/0000000005000-delegation-rules.d.ts +6 -0
- package/src/lib/migrations/{0000000005000-delegation-rules.ts → 0000000005000-delegation-rules.js} +19 -20
- package/src/lib/migrations/0000000005000-delegation-rules.js.map +1 -0
- package/src/lib/migrations/0000000006000-notifications-sla.d.ts +6 -0
- package/src/lib/migrations/{0000000006000-notifications-sla.ts → 0000000006000-notifications-sla.js} +23 -26
- package/src/lib/migrations/0000000006000-notifications-sla.js.map +1 -0
- package/src/lib/migrations/0000000007000-signatures-attachments.d.ts +6 -0
- package/src/lib/migrations/{0000000007000-signatures-attachments.ts → 0000000007000-signatures-attachments.js} +27 -28
- package/src/lib/migrations/0000000007000-signatures-attachments.js.map +1 -0
- package/src/lib/migrations/0000000008000-approval-template-categories.d.ts +6 -0
- package/src/lib/migrations/{0000000008000-approval-template-categories.ts → 0000000008000-approval-template-categories.js} +25 -28
- package/src/lib/migrations/0000000008000-approval-template-categories.js.map +1 -0
- package/src/lib/migrations/0000000009000-task-candidates.d.ts +6 -0
- package/src/lib/migrations/{0000000009000-task-candidates.ts → 0000000009000-task-candidates.js} +23 -26
- package/src/lib/migrations/0000000009000-task-candidates.js.map +1 -0
- package/src/lib/migrations/0000000010000-notification-delivery-state.d.ts +6 -0
- package/src/lib/migrations/{0000000010000-notification-delivery-state.ts → 0000000010000-notification-delivery-state.js} +17 -16
- package/src/lib/migrations/0000000010000-notification-delivery-state.js.map +1 -0
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.d.ts +6 -0
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.js +22 -0
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.js.map +1 -0
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.d.ts +6 -0
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.js +21 -0
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.js.map +1 -0
- package/src/lib/migrations/0000000013000-workflow-query-indexes.d.ts +6 -0
- package/src/lib/migrations/0000000013000-workflow-query-indexes.js +80 -0
- package/src/lib/migrations/0000000013000-workflow-query-indexes.js.map +1 -0
- package/src/lib/migrations/0000000014000-notification-resolution.d.ts +6 -0
- package/src/lib/migrations/0000000014000-notification-resolution.js +30 -0
- package/src/lib/migrations/0000000014000-notification-resolution.js.map +1 -0
- package/src/lib/migrations/0000000015000-backfill-stale-notification-resolution.d.ts +15 -0
- package/src/lib/migrations/{0000000015000-backfill-stale-notification-resolution.ts → 0000000015000-backfill-stale-notification-resolution.js} +16 -15
- package/src/lib/migrations/0000000015000-backfill-stale-notification-resolution.js.map +1 -0
- package/src/lib/migrations/0000000016000-archive-parallel-form-drafts.d.ts +15 -0
- package/src/lib/migrations/{0000000016000-archive-parallel-form-drafts.ts → 0000000016000-archive-parallel-form-drafts.js} +16 -15
- package/src/lib/migrations/0000000016000-archive-parallel-form-drafts.js.map +1 -0
- package/src/lib/migrations/0000000017000-adhoc-directives.d.ts +6 -0
- package/src/lib/migrations/{0000000017000-adhoc-directives.ts → 0000000017000-adhoc-directives.js} +19 -18
- package/src/lib/migrations/0000000017000-adhoc-directives.js.map +1 -0
- package/src/lib/migrations/index.d.ts +20 -0
- package/src/lib/migrations/index.js +61 -0
- package/src/lib/migrations/index.js.map +1 -0
- package/src/lib/notification/dto/notification-preference.input.d.ts +9 -0
- package/src/lib/notification/dto/notification-preference.input.js +53 -0
- package/src/lib/notification/dto/notification-preference.input.js.map +1 -0
- package/src/lib/notification/index.js +11 -0
- package/src/lib/notification/index.js.map +1 -0
- package/src/lib/notification/notification-delivery-scheduler.service.d.ts +13 -0
- package/src/lib/notification/notification-delivery-scheduler.service.js +53 -0
- package/src/lib/notification/notification-delivery-scheduler.service.js.map +1 -0
- package/src/lib/notification/notification-delivery.service.d.ts +23 -0
- package/src/lib/notification/notification-delivery.service.js +245 -0
- package/src/lib/notification/notification-delivery.service.js.map +1 -0
- package/src/lib/notification/notification-dispatcher.token.d.ts +7 -0
- package/src/lib/notification/notification-dispatcher.token.js +5 -0
- package/src/lib/notification/notification-dispatcher.token.js.map +1 -0
- package/src/lib/notification/notification-options.d.ts +215 -0
- package/src/lib/notification/notification-options.js +128 -0
- package/src/lib/notification/notification-options.js.map +1 -0
- package/src/lib/notification/notification-options.module.d.ts +23 -0
- package/src/lib/notification/notification-options.module.js +41 -0
- package/src/lib/notification/notification-options.module.js.map +1 -0
- package/src/lib/notification/notification-preference.entity.d.ts +10 -0
- package/src/lib/notification/notification-preference.entity.js +50 -0
- package/src/lib/notification/notification-preference.entity.js.map +1 -0
- package/src/lib/notification/notification-sla-scheduler.service.d.ts +13 -0
- package/src/lib/notification/notification-sla-scheduler.service.js +51 -0
- package/src/lib/notification/notification-sla-scheduler.service.js.map +1 -0
- package/src/lib/notification/notification-template.d.ts +13 -0
- package/src/lib/notification/notification-template.js +61 -0
- package/src/lib/notification/notification-template.js.map +1 -0
- package/src/lib/notification/notification.entity.d.ts +31 -0
- package/src/lib/notification/notification.entity.js +149 -0
- package/src/lib/notification/notification.entity.js.map +1 -0
- package/src/lib/notification/notification.enums.d.ts +38 -0
- package/src/lib/notification/notification.enums.js +63 -0
- package/src/lib/notification/notification.enums.js.map +1 -0
- package/src/lib/notification/notification.module.d.ts +2 -0
- package/src/lib/notification/notification.module.js +45 -0
- package/src/lib/notification/notification.module.js.map +1 -0
- package/src/lib/notification/notification.mutations.d.ts +11 -0
- package/src/lib/notification/notification.mutations.js +64 -0
- package/src/lib/notification/notification.mutations.js.map +1 -0
- package/src/lib/notification/notification.queries.d.ts +11 -0
- package/src/lib/notification/notification.queries.js +77 -0
- package/src/lib/notification/notification.queries.js.map +1 -0
- package/src/lib/notification/notification.service.d.ts +121 -0
- package/src/lib/notification/notification.service.js +713 -0
- package/src/lib/notification/notification.service.js.map +1 -0
- package/src/lib/organization/dto/manager-resolution.input.d.ts +18 -0
- package/src/lib/organization/dto/manager-resolution.input.js +107 -0
- package/src/lib/organization/dto/manager-resolution.input.js.map +1 -0
- package/src/lib/organization/dto/membership.input.d.ts +16 -0
- package/src/lib/organization/dto/membership.input.js +99 -0
- package/src/lib/organization/dto/membership.input.js.map +1 -0
- package/src/lib/organization/dto/org-unit.input.d.ts +24 -0
- package/src/lib/organization/dto/org-unit.input.js +119 -0
- package/src/lib/organization/dto/org-unit.input.js.map +1 -0
- package/src/lib/organization/dto/position.input.d.ts +13 -0
- package/src/lib/organization/dto/position.input.js +70 -0
- package/src/lib/organization/dto/position.input.js.map +1 -0
- package/src/lib/organization/index.js +16 -0
- package/src/lib/organization/index.js.map +1 -0
- package/src/lib/organization/json-metadata.d.ts +1 -0
- package/src/lib/organization/json-metadata.js +14 -0
- package/src/lib/organization/json-metadata.js.map +1 -0
- package/src/lib/organization/manager-resolution.entity.d.ts +11 -0
- package/src/lib/organization/manager-resolution.entity.js +55 -0
- package/src/lib/organization/manager-resolution.entity.js.map +1 -0
- package/src/lib/organization/membership.entity.d.ts +11 -0
- package/src/lib/organization/membership.entity.js +60 -0
- package/src/lib/organization/membership.entity.js.map +1 -0
- package/src/lib/organization/org-unit-tree-commit-result.object.d.ts +4 -0
- package/src/lib/organization/org-unit-tree-commit-result.object.js +17 -0
- package/src/lib/organization/org-unit-tree-commit-result.object.js.map +1 -0
- package/src/lib/organization/org-unit.entity.d.ts +13 -0
- package/src/lib/organization/org-unit.entity.js +64 -0
- package/src/lib/organization/org-unit.entity.js.map +1 -0
- package/src/lib/organization/organization-summary.object.d.ts +6 -0
- package/src/lib/organization/organization-summary.object.js +28 -0
- package/src/lib/organization/organization-summary.object.js.map +1 -0
- package/src/lib/organization/organization.enums.d.ts +11 -0
- package/src/lib/organization/organization.enums.js +22 -0
- package/src/lib/organization/organization.enums.js.map +1 -0
- package/src/lib/organization/organization.module.d.ts +2 -0
- package/src/lib/organization/organization.module.js +35 -0
- package/src/lib/organization/organization.module.js.map +1 -0
- package/src/lib/organization/organization.mutations.d.ts +26 -0
- package/src/lib/organization/organization.mutations.js +148 -0
- package/src/lib/organization/organization.mutations.js.map +1 -0
- package/src/lib/organization/organization.queries.d.ts +23 -0
- package/src/lib/organization/organization.queries.js +204 -0
- package/src/lib/organization/organization.queries.js.map +1 -0
- package/src/lib/organization/organization.service.d.ts +103 -0
- package/src/lib/organization/organization.service.js +768 -0
- package/src/lib/organization/organization.service.js.map +1 -0
- package/src/lib/organization/position.entity.d.ts +9 -0
- package/src/lib/organization/position.entity.js +48 -0
- package/src/lib/organization/position.entity.js.map +1 -0
- package/src/lib/organization/resolved-manager.object.d.ts +4 -0
- package/src/lib/organization/resolved-manager.object.js +20 -0
- package/src/lib/organization/resolved-manager.object.js.map +1 -0
- package/src/lib/signature/index.js +8 -0
- package/src/lib/signature/index.js.map +1 -0
- package/src/lib/signature/signature-options.d.ts +33 -0
- package/src/lib/signature/signature-options.js +51 -0
- package/src/lib/signature/signature-options.js.map +1 -0
- package/src/lib/signature/signature-verification.object.d.ts +6 -0
- package/src/lib/signature/signature-verification.object.js +28 -0
- package/src/lib/signature/signature-verification.object.js.map +1 -0
- package/src/lib/signature/signature.entity.d.ts +16 -0
- package/src/lib/signature/signature.entity.js +88 -0
- package/src/lib/signature/signature.entity.js.map +1 -0
- package/src/lib/signature/signature.module.d.ts +11 -0
- package/src/lib/signature/signature.module.js +60 -0
- package/src/lib/signature/signature.module.js.map +1 -0
- package/src/lib/signature/signature.queries.d.ts +11 -0
- package/src/lib/signature/signature.queries.js +46 -0
- package/src/lib/signature/signature.queries.js.map +1 -0
- package/src/lib/signature/signature.service.d.ts +25 -0
- package/src/lib/signature/signature.service.js +124 -0
- package/src/lib/signature/signature.service.js.map +1 -0
- package/src/lib/template/approval-template-category.entity.d.ts +9 -0
- package/src/lib/template/approval-template-category.entity.js +49 -0
- package/src/lib/template/approval-template-category.entity.js.map +1 -0
- package/src/lib/template/approval-template-version.entity.d.ts +21 -0
- package/src/lib/template/approval-template-version.entity.js +106 -0
- package/src/lib/template/approval-template-version.entity.js.map +1 -0
- package/src/lib/template/approval-template.entity.d.ts +14 -0
- package/src/lib/template/approval-template.entity.js +74 -0
- package/src/lib/template/approval-template.entity.js.map +1 -0
- package/src/lib/template/compose-approval-template.object.d.ts +11 -0
- package/src/lib/template/compose-approval-template.object.js +36 -0
- package/src/lib/template/compose-approval-template.object.js.map +1 -0
- package/src/lib/template/compose-template.mutations.d.ts +8 -0
- package/src/lib/template/compose-template.mutations.js +32 -0
- package/src/lib/template/compose-template.mutations.js.map +1 -0
- package/src/lib/template/dto/approval-template.input.d.ts +36 -0
- package/src/lib/template/dto/approval-template.input.js +187 -0
- package/src/lib/template/dto/approval-template.input.js.map +1 -0
- package/src/lib/template/dto/compose-approval-template.input.d.ts +17 -0
- package/src/lib/template/dto/compose-approval-template.input.js +99 -0
- package/src/lib/template/dto/compose-approval-template.input.js.map +1 -0
- package/src/lib/template/index.js +14 -0
- package/src/lib/template/index.js.map +1 -0
- package/src/lib/template/template.enums.d.ts +14 -0
- package/src/lib/template/template.enums.js +31 -0
- package/src/lib/template/template.enums.js.map +1 -0
- package/src/lib/template/template.module.d.ts +2 -0
- package/src/lib/template/template.module.js +41 -0
- package/src/lib/template/template.module.js.map +1 -0
- package/src/lib/template/template.mutations.d.ts +20 -0
- package/src/lib/template/template.mutations.js +139 -0
- package/src/lib/template/template.mutations.js.map +1 -0
- package/src/lib/template/template.queries.d.ts +16 -0
- package/src/lib/template/template.queries.js +133 -0
- package/src/lib/template/template.queries.js.map +1 -0
- package/src/lib/template/template.service.d.ts +83 -0
- package/src/lib/template/template.service.js +654 -0
- package/src/lib/template/template.service.js.map +1 -0
- package/src/lib/template/workflow-definition.validator.d.ts +9 -0
- package/src/lib/template/workflow-definition.validator.js +362 -0
- package/src/lib/template/workflow-definition.validator.js.map +1 -0
- package/src/lib/testing/cel-js.jest.d.ts +15 -0
- package/src/lib/testing/cel-js.jest.js +27 -0
- package/src/lib/testing/cel-js.jest.js.map +1 -0
- package/src/lib/workflow-engine/activity-log.entity.d.ts +12 -0
- package/src/lib/workflow-engine/activity-log.entity.js +62 -0
- package/src/lib/workflow-engine/activity-log.entity.js.map +1 -0
- package/src/lib/workflow-engine/adhoc-directive.entity.d.ts +31 -0
- package/src/lib/workflow-engine/adhoc-directive.entity.js +105 -0
- package/src/lib/workflow-engine/adhoc-directive.entity.js.map +1 -0
- package/src/lib/workflow-engine/adhoc.enums.d.ts +21 -0
- package/src/lib/workflow-engine/adhoc.enums.js +42 -0
- package/src/lib/workflow-engine/adhoc.enums.js.map +1 -0
- package/src/lib/workflow-engine/approval-instance-page-info.object.d.ts +8 -0
- package/src/lib/workflow-engine/approval-instance-page-info.object.js +36 -0
- package/src/lib/workflow-engine/approval-instance-page-info.object.js.map +1 -0
- package/src/lib/workflow-engine/approval-instance.entity.d.ts +22 -0
- package/src/lib/workflow-engine/approval-instance.entity.js +113 -0
- package/src/lib/workflow-engine/approval-instance.entity.js.map +1 -0
- package/src/lib/workflow-engine/dto/adhoc-notification.input.d.ts +6 -0
- package/src/lib/workflow-engine/dto/adhoc-notification.input.js +28 -0
- package/src/lib/workflow-engine/dto/adhoc-notification.input.js.map +1 -0
- package/src/lib/workflow-engine/dto/adhoc-target.input.d.ts +16 -0
- package/src/lib/workflow-engine/dto/adhoc-target.input.js +61 -0
- package/src/lib/workflow-engine/dto/adhoc-target.input.js.map +1 -0
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.d.ts +5 -0
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.js +29 -0
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.js.map +1 -0
- package/src/lib/workflow-engine/dto/decide-task.input.d.ts +9 -0
- package/src/lib/workflow-engine/dto/decide-task.input.js +47 -0
- package/src/lib/workflow-engine/dto/decide-task.input.js.map +1 -0
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.d.ts +6 -0
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.js +34 -0
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.js.map +1 -0
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.d.ts +6 -0
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.js +34 -0
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.js.map +1 -0
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.d.ts +7 -0
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.js +40 -0
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.js.map +1 -0
- package/src/lib/workflow-engine/index.js +28 -0
- package/src/lib/workflow-engine/index.js.map +1 -0
- package/src/lib/workflow-engine/task-candidate.entity.d.ts +14 -0
- package/src/lib/workflow-engine/task-candidate.entity.js +72 -0
- package/src/lib/workflow-engine/task-candidate.entity.js.map +1 -0
- package/src/lib/workflow-engine/task-decision.entity.d.ts +12 -0
- package/src/lib/workflow-engine/task-decision.entity.js +60 -0
- package/src/lib/workflow-engine/task-decision.entity.js.map +1 -0
- package/src/lib/workflow-engine/task.entity.d.ts +25 -0
- package/src/lib/workflow-engine/task.entity.js +130 -0
- package/src/lib/workflow-engine/task.entity.js.map +1 -0
- package/src/lib/workflow-engine/workflow-condition-evaluator.d.ts +5 -0
- package/src/lib/workflow-engine/workflow-condition-evaluator.js +107 -0
- package/src/lib/workflow-engine/workflow-condition-evaluator.js.map +1 -0
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.d.ts +8 -0
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.js +36 -0
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.js.map +1 -0
- package/src/lib/workflow-engine/workflow-dry-run.object.d.ts +21 -0
- package/src/lib/workflow-engine/workflow-dry-run.object.js +86 -0
- package/src/lib/workflow-engine/workflow-dry-run.object.js.map +1 -0
- package/src/lib/workflow-engine/workflow-engine.enums.d.ts +61 -0
- package/src/lib/workflow-engine/workflow-engine.enums.js +98 -0
- package/src/lib/workflow-engine/workflow-engine.enums.js.map +1 -0
- package/src/lib/workflow-engine/workflow-engine.module.d.ts +9 -0
- package/src/lib/workflow-engine/workflow-engine.module.js +78 -0
- package/src/lib/workflow-engine/workflow-engine.module.js.map +1 -0
- package/src/lib/workflow-engine/workflow-engine.mutations.d.ts +29 -0
- package/src/lib/workflow-engine/workflow-engine.mutations.js +218 -0
- package/src/lib/workflow-engine/workflow-engine.mutations.js.map +1 -0
- package/src/lib/workflow-engine/workflow-engine.queries.d.ts +31 -0
- package/src/lib/workflow-engine/workflow-engine.queries.js +237 -0
- package/src/lib/workflow-engine/workflow-engine.queries.js.map +1 -0
- package/src/lib/workflow-engine/workflow-engine.service.d.ts +188 -0
- package/src/lib/workflow-engine/workflow-engine.service.js +3561 -0
- package/src/lib/workflow-engine/workflow-engine.service.js.map +1 -0
- package/src/lib/workflow-engine/{workflow-engine.tokens.ts → workflow-engine.tokens.d.ts} +3 -9
- package/src/lib/workflow-engine/workflow-engine.tokens.js +5 -0
- package/src/lib/workflow-engine/workflow-engine.tokens.js.map +1 -0
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.d.ts +18 -0
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js +39 -0
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js.map +1 -0
- package/src/lib/workflow-engine/workflow-token.entity.d.ts +10 -0
- package/src/lib/workflow-engine/workflow-token.entity.js +50 -0
- package/src/lib/workflow-engine/workflow-token.entity.js.map +1 -0
- package/eslint.config.mjs +0 -20
- package/jest.config.cts +0 -15
- package/project.json +0 -58
- package/src/lib/attachment/attachment-options.spec.ts +0 -45
- package/src/lib/attachment/attachment-options.ts +0 -130
- package/src/lib/attachment/attachment-storage.provider.spec.ts +0 -79
- package/src/lib/attachment/attachment-storage.provider.ts +0 -60
- package/src/lib/attachment/attachment.controller.ts +0 -39
- package/src/lib/attachment/attachment.entity.ts +0 -59
- package/src/lib/attachment/attachment.module.ts +0 -149
- package/src/lib/attachment/attachment.mutations.ts +0 -22
- package/src/lib/attachment/attachment.queries.ts +0 -65
- package/src/lib/attachment/attachment.service.spec.ts +0 -319
- package/src/lib/attachment/attachment.service.ts +0 -477
- package/src/lib/attachment/dto/upload-attachment.input.ts +0 -60
- package/src/lib/bpm/bpm-root.module.spec.ts +0 -138
- package/src/lib/bpm/bpm-root.module.ts +0 -320
- package/src/lib/bpm-auth/bpm-auth-context.extractor.ts +0 -106
- package/src/lib/bpm-auth/bpm-auth-context.ts +0 -40
- package/src/lib/bpm-auth/bpm-auth.authorization.ts +0 -80
- package/src/lib/bpm-auth/bpm-auth.decorators.ts +0 -19
- package/src/lib/bpm-auth/bpm-auth.guard.ts +0 -31
- package/src/lib/bpm-auth/bpm-auth.module.spec.ts +0 -106
- package/src/lib/bpm-auth/bpm-auth.module.ts +0 -69
- package/src/lib/bpm-auth/bpm-auth.options.ts +0 -21
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.ts +0 -55
- package/src/lib/common/filters/all-exceptions.filter.ts +0 -138
- package/src/lib/common/iso-duration.ts +0 -31
- package/src/lib/condition/condition.module.ts +0 -8
- package/src/lib/condition/condition.service.spec.ts +0 -50
- package/src/lib/condition/condition.service.ts +0 -141
- package/src/lib/database/data-source.ts +0 -7
- package/src/lib/database/migration-runner.ts +0 -26
- package/src/lib/database/reconcile-legacy-migrations.ts +0 -87
- package/src/lib/database/typeorm.config.ts +0 -217
- package/src/lib/delegation/delegation-rule.entity.ts +0 -84
- package/src/lib/delegation/delegation.enums.ts +0 -21
- package/src/lib/delegation/delegation.module.ts +0 -14
- package/src/lib/delegation/delegation.mutations.ts +0 -92
- package/src/lib/delegation/delegation.queries.ts +0 -111
- package/src/lib/delegation/delegation.service.spec.ts +0 -295
- package/src/lib/delegation/delegation.service.ts +0 -482
- package/src/lib/delegation/dto/delegation-rule.input.ts +0 -125
- package/src/lib/form/dto/form-definition.input.ts +0 -90
- package/src/lib/form/form-definition-version.entity.ts +0 -66
- package/src/lib/form/form-definition.entity.ts +0 -54
- package/src/lib/form/form-schema-lint.object.ts +0 -10
- package/src/lib/form/form-schema.validator.spec.ts +0 -180
- package/src/lib/form/form-schema.validator.ts +0 -538
- package/src/lib/form/form.enums.ts +0 -20
- package/src/lib/form/form.module.ts +0 -19
- package/src/lib/form/form.mutations.ts +0 -73
- package/src/lib/form/form.queries.ts +0 -72
- package/src/lib/form/form.service.spec.ts +0 -371
- package/src/lib/form/form.service.ts +0 -607
- package/src/lib/identity/identity-options.ts +0 -41
- package/src/lib/identity/identity.module.ts +0 -96
- package/src/lib/identity/identity.queries.ts +0 -61
- package/src/lib/identity/identity.service.spec.ts +0 -328
- package/src/lib/identity/identity.service.ts +0 -277
- package/src/lib/identity/member-base.adapter.spec.ts +0 -122
- package/src/lib/identity/member-base.adapter.ts +0 -302
- package/src/lib/identity/member-metadata-cache.entity.ts +0 -27
- package/src/lib/identity/member-profile.object.ts +0 -28
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.ts +0 -14
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.ts +0 -19
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.ts +0 -22
- package/src/lib/migrations/0000000013000-workflow-query-indexes.ts +0 -113
- package/src/lib/migrations/0000000014000-notification-resolution.ts +0 -29
- package/src/lib/migrations/index.ts +0 -59
- package/src/lib/notification/dto/notification-preference.input.ts +0 -46
- package/src/lib/notification/notification-delivery-scheduler.service.ts +0 -69
- package/src/lib/notification/notification-delivery.service.spec.ts +0 -315
- package/src/lib/notification/notification-delivery.service.ts +0 -339
- package/src/lib/notification/notification-dispatcher.token.ts +0 -13
- package/src/lib/notification/notification-options.module.ts +0 -67
- package/src/lib/notification/notification-options.spec.ts +0 -93
- package/src/lib/notification/notification-options.ts +0 -452
- package/src/lib/notification/notification-preference.entity.ts +0 -35
- package/src/lib/notification/notification-sla-scheduler.service.ts +0 -66
- package/src/lib/notification/notification-template.spec.ts +0 -33
- package/src/lib/notification/notification-template.ts +0 -97
- package/src/lib/notification/notification.entity.ts +0 -129
- package/src/lib/notification/notification.enums.ts +0 -64
- package/src/lib/notification/notification.module.ts +0 -37
- package/src/lib/notification/notification.mutations.ts +0 -47
- package/src/lib/notification/notification.queries.ts +0 -64
- package/src/lib/notification/notification.service.spec.ts +0 -412
- package/src/lib/notification/notification.service.ts +0 -1129
- package/src/lib/organization/dto/manager-resolution.input.ts +0 -91
- package/src/lib/organization/dto/membership.input.ts +0 -77
- package/src/lib/organization/dto/org-unit.input.ts +0 -96
- package/src/lib/organization/dto/position.input.ts +0 -50
- package/src/lib/organization/json-metadata.ts +0 -15
- package/src/lib/organization/manager-resolution.entity.ts +0 -44
- package/src/lib/organization/membership.entity.ts +0 -50
- package/src/lib/organization/org-unit-tree-commit-result.object.ts +0 -8
- package/src/lib/organization/org-unit.entity.ts +0 -53
- package/src/lib/organization/organization-summary.object.ts +0 -16
- package/src/lib/organization/organization.enums.ts +0 -19
- package/src/lib/organization/organization.module.ts +0 -27
- package/src/lib/organization/organization.mutations.ts +0 -115
- package/src/lib/organization/organization.queries.ts +0 -191
- package/src/lib/organization/organization.service.spec.ts +0 -835
- package/src/lib/organization/organization.service.ts +0 -1245
- package/src/lib/organization/position.entity.ts +0 -39
- package/src/lib/organization/resolved-manager.object.ts +0 -10
- package/src/lib/signature/signature-options.spec.ts +0 -60
- package/src/lib/signature/signature-options.ts +0 -120
- package/src/lib/signature/signature-verification.object.ts +0 -16
- package/src/lib/signature/signature.entity.ts +0 -62
- package/src/lib/signature/signature.module.ts +0 -80
- package/src/lib/signature/signature.queries.ts +0 -37
- package/src/lib/signature/signature.service.spec.ts +0 -134
- package/src/lib/signature/signature.service.ts +0 -205
- package/src/lib/template/approval-template-category.entity.ts +0 -40
- package/src/lib/template/approval-template-version.entity.ts +0 -82
- package/src/lib/template/approval-template.entity.ts +0 -64
- package/src/lib/template/compose-approval-template.object.ts +0 -23
- package/src/lib/template/compose-template.mutations.ts +0 -22
- package/src/lib/template/dto/approval-template.input.ts +0 -147
- package/src/lib/template/dto/compose-approval-template.input.ts +0 -80
- package/src/lib/template/template.enums.ts +0 -30
- package/src/lib/template/template.module.ts +0 -33
- package/src/lib/template/template.mutations.ts +0 -106
- package/src/lib/template/template.queries.ts +0 -119
- package/src/lib/template/template.service.spec.ts +0 -822
- package/src/lib/template/template.service.ts +0 -1082
- package/src/lib/template/workflow-definition.validator.spec.ts +0 -595
- package/src/lib/template/workflow-definition.validator.ts +0 -539
- package/src/lib/testing/cel-js.jest.ts +0 -46
- package/src/lib/workflow-engine/activity-log.entity.ts +0 -48
- package/src/lib/workflow-engine/adhoc-directive.entity.ts +0 -90
- package/src/lib/workflow-engine/adhoc.enums.ts +0 -42
- package/src/lib/workflow-engine/approval-instance-page-info.object.ts +0 -22
- package/src/lib/workflow-engine/approval-instance.entity.ts +0 -86
- package/src/lib/workflow-engine/dto/adhoc-notification.input.ts +0 -18
- package/src/lib/workflow-engine/dto/adhoc-target.input.ts +0 -52
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.ts +0 -18
- package/src/lib/workflow-engine/dto/decide-task.input.ts +0 -33
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.ts +0 -22
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.ts +0 -22
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.ts +0 -27
- package/src/lib/workflow-engine/task-candidate.entity.ts +0 -56
- package/src/lib/workflow-engine/task-decision.entity.ts +0 -43
- package/src/lib/workflow-engine/task.entity.ts +0 -102
- package/src/lib/workflow-engine/workflow-condition-evaluator.ts +0 -168
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.ts +0 -22
- package/src/lib/workflow-engine/workflow-dry-run.object.ts +0 -58
- package/src/lib/workflow-engine/workflow-engine.enums.ts +0 -102
- package/src/lib/workflow-engine/workflow-engine.module.ts +0 -77
- package/src/lib/workflow-engine/workflow-engine.mutations.ts +0 -193
- package/src/lib/workflow-engine/workflow-engine.queries.ts +0 -241
- package/src/lib/workflow-engine/workflow-engine.service.spec.ts +0 -3345
- package/src/lib/workflow-engine/workflow-engine.service.ts +0 -6022
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.ts +0 -69
- package/src/lib/workflow-engine/workflow-token.entity.ts +0 -40
- package/tsconfig.json +0 -24
- package/tsconfig.lib.json +0 -16
- package/tsconfig.spec.json +0 -16
- /package/src/{index.ts → index.d.ts} +0 -0
- /package/src/lib/attachment/{index.ts → index.d.ts} +0 -0
- /package/src/lib/bpm/{index.ts → index.d.ts} +0 -0
- /package/src/lib/bpm-auth/{index.ts → index.d.ts} +0 -0
- /package/src/lib/common/{index.ts → index.d.ts} +0 -0
- /package/src/lib/condition/{index.ts → index.d.ts} +0 -0
- /package/src/lib/database/{index.ts → index.d.ts} +0 -0
- /package/src/lib/delegation/{index.ts → index.d.ts} +0 -0
- /package/src/lib/form/{index.ts → index.d.ts} +0 -0
- /package/src/lib/identity/{index.ts → index.d.ts} +0 -0
- /package/src/lib/notification/{index.ts → index.d.ts} +0 -0
- /package/src/lib/organization/{index.ts → index.d.ts} +0 -0
- /package/src/lib/signature/{index.ts → index.d.ts} +0 -0
- /package/src/lib/template/{index.ts → index.d.ts} +0 -0
- /package/src/lib/workflow-engine/{index.ts → index.d.ts} +0 -0
|
@@ -1,1082 +0,0 @@
|
|
|
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 {
|
|
10
|
-
EntityManager,
|
|
11
|
-
FindOptionsWhere,
|
|
12
|
-
ILike,
|
|
13
|
-
IsNull,
|
|
14
|
-
Not,
|
|
15
|
-
Repository,
|
|
16
|
-
} from 'typeorm';
|
|
17
|
-
import { ConditionService } from '../condition/condition.service';
|
|
18
|
-
import { FormDefinitionEntity } from '../form/form-definition.entity';
|
|
19
|
-
import { FormDefinitionVersionEntity } from '../form/form-definition-version.entity';
|
|
20
|
-
import { FormDefinitionVersionStatusEnum } from '../form/form.enums';
|
|
21
|
-
import { FormService } from '../form/form.service';
|
|
22
|
-
import { ComposeApprovalTemplateWithFormInput } from './dto/compose-approval-template.input';
|
|
23
|
-
import { ComposeApprovalTemplateWithFormObject } from './compose-approval-template.object';
|
|
24
|
-
import { ApprovalTemplateCategoryEntity } from './approval-template-category.entity';
|
|
25
|
-
import { ApprovalTemplateEntity } from './approval-template.entity';
|
|
26
|
-
import { ApprovalTemplateVersionEntity } from './approval-template-version.entity';
|
|
27
|
-
import {
|
|
28
|
-
CreateApprovalTemplateCategoryInput,
|
|
29
|
-
CreateApprovalTemplateInput,
|
|
30
|
-
UpdateApprovalTemplateCategoryInput,
|
|
31
|
-
UpdateApprovalTemplateDraftInput,
|
|
32
|
-
UpdateApprovalTemplateInput,
|
|
33
|
-
} from './dto/approval-template.input';
|
|
34
|
-
import {
|
|
35
|
-
ApprovalTemplateCategoryStatusEnum,
|
|
36
|
-
ApprovalTemplateListStatusEnum,
|
|
37
|
-
ApprovalTemplateVersionStatusEnum,
|
|
38
|
-
} from './template.enums';
|
|
39
|
-
import {
|
|
40
|
-
EMPTY_WORKFLOW_DEFINITION,
|
|
41
|
-
lintWorkflowDefinition,
|
|
42
|
-
parseWorkflowDefinitionJson,
|
|
43
|
-
} from './workflow-definition.validator';
|
|
44
|
-
|
|
45
|
-
interface MaxVersionRow {
|
|
46
|
-
readonly maxVersion?: number | string | null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
interface ListApprovalTemplatesOptions {
|
|
50
|
-
readonly page?: number;
|
|
51
|
-
readonly pageSize?: number;
|
|
52
|
-
readonly categoryId?: string;
|
|
53
|
-
readonly searchText?: string;
|
|
54
|
-
readonly status?: ApprovalTemplateListStatusEnum;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface ListApprovalTemplateCategoriesOptions {
|
|
58
|
-
readonly page?: number;
|
|
59
|
-
readonly pageSize?: number;
|
|
60
|
-
readonly searchText?: string;
|
|
61
|
-
readonly status?: ApprovalTemplateCategoryStatusEnum;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@Injectable()
|
|
65
|
-
export class TemplateService {
|
|
66
|
-
constructor(
|
|
67
|
-
@InjectRepository(ApprovalTemplateEntity)
|
|
68
|
-
private readonly templateRepository: Repository<ApprovalTemplateEntity>,
|
|
69
|
-
@InjectRepository(ApprovalTemplateCategoryEntity)
|
|
70
|
-
private readonly templateCategoryRepository: Repository<ApprovalTemplateCategoryEntity>,
|
|
71
|
-
@InjectRepository(ApprovalTemplateVersionEntity)
|
|
72
|
-
private readonly templateVersionRepository: Repository<ApprovalTemplateVersionEntity>,
|
|
73
|
-
@InjectRepository(FormDefinitionVersionEntity)
|
|
74
|
-
private readonly formDefinitionVersionRepository: Repository<FormDefinitionVersionEntity>,
|
|
75
|
-
private readonly conditionService: ConditionService,
|
|
76
|
-
private readonly formService: FormService,
|
|
77
|
-
) {}
|
|
78
|
-
|
|
79
|
-
async createApprovalTemplate(
|
|
80
|
-
input: CreateApprovalTemplateInput,
|
|
81
|
-
manager?: EntityManager,
|
|
82
|
-
): Promise<ApprovalTemplateEntity> {
|
|
83
|
-
const run = (txManager: EntityManager): Promise<ApprovalTemplateEntity> =>
|
|
84
|
-
this.createApprovalTemplateWithManager(txManager, input);
|
|
85
|
-
|
|
86
|
-
return manager
|
|
87
|
-
? run(manager)
|
|
88
|
-
: this.templateRepository.manager.transaction(run);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private async createApprovalTemplateWithManager(
|
|
92
|
-
manager: EntityManager,
|
|
93
|
-
input: CreateApprovalTemplateInput,
|
|
94
|
-
): Promise<ApprovalTemplateEntity> {
|
|
95
|
-
await this.validateOptionalFormDefinitionVersion(
|
|
96
|
-
input.formDefinitionVersionId,
|
|
97
|
-
manager,
|
|
98
|
-
);
|
|
99
|
-
const category = await this.validateOptionalTemplateCategory(
|
|
100
|
-
input.categoryId,
|
|
101
|
-
manager,
|
|
102
|
-
);
|
|
103
|
-
const templateRepository = manager.getRepository(ApprovalTemplateEntity);
|
|
104
|
-
const versionRepository = manager.getRepository(
|
|
105
|
-
ApprovalTemplateVersionEntity,
|
|
106
|
-
);
|
|
107
|
-
const template = await templateRepository.save(
|
|
108
|
-
templateRepository.create({
|
|
109
|
-
category: input.category ?? category?.name ?? null,
|
|
110
|
-
categoryId: category?.id ?? null,
|
|
111
|
-
createdByMemberId: input.createdByMemberId,
|
|
112
|
-
currentVersionId: null,
|
|
113
|
-
description: input.description,
|
|
114
|
-
name: input.name,
|
|
115
|
-
}),
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
await versionRepository.save(
|
|
119
|
-
versionRepository.create({
|
|
120
|
-
archivedAt: null,
|
|
121
|
-
formDefinitionVersionId: input.formDefinitionVersionId,
|
|
122
|
-
initiatorPolicyCel: null,
|
|
123
|
-
notificationConfig: null,
|
|
124
|
-
publishedAt: null,
|
|
125
|
-
publishedByMemberId: null,
|
|
126
|
-
slaDefaults: null,
|
|
127
|
-
status: ApprovalTemplateVersionStatusEnum.DRAFT,
|
|
128
|
-
templateId: template.id,
|
|
129
|
-
version: 1,
|
|
130
|
-
workflowDefinition: EMPTY_WORKFLOW_DEFINITION,
|
|
131
|
-
}),
|
|
132
|
-
);
|
|
133
|
-
|
|
134
|
-
return template;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Atomically build (and optionally publish) a form definition together with
|
|
139
|
-
* the approval template that binds it. The whole flow runs in a single DB
|
|
140
|
-
* transaction so a partial failure rolls back both sides.
|
|
141
|
-
*/
|
|
142
|
-
async composeApprovalTemplateWithForm(
|
|
143
|
-
input: ComposeApprovalTemplateWithFormInput,
|
|
144
|
-
currentMemberId: string | null,
|
|
145
|
-
): Promise<ComposeApprovalTemplateWithFormObject> {
|
|
146
|
-
return this.templateRepository.manager.transaction(
|
|
147
|
-
async (manager): Promise<ComposeApprovalTemplateWithFormObject> => {
|
|
148
|
-
const formDefinitionVersion = await this.resolveComposedFormVersion(
|
|
149
|
-
manager,
|
|
150
|
-
input,
|
|
151
|
-
currentMemberId,
|
|
152
|
-
);
|
|
153
|
-
const templateDraftVersion =
|
|
154
|
-
await this.resolveComposedTemplateDraftVersion(
|
|
155
|
-
manager,
|
|
156
|
-
input,
|
|
157
|
-
currentMemberId,
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
let templateVersion = await this.updateApprovalTemplateDraft(
|
|
161
|
-
{
|
|
162
|
-
formDefinitionVersionId: formDefinitionVersion.id,
|
|
163
|
-
initiatorPolicyCel: input.initiatorPolicyCel,
|
|
164
|
-
notificationConfigJson: input.notificationConfigJson,
|
|
165
|
-
slaDefaultsJson: input.slaDefaultsJson,
|
|
166
|
-
versionId: templateDraftVersion.id,
|
|
167
|
-
workflowDefinitionJson: input.workflowDefinitionJson,
|
|
168
|
-
},
|
|
169
|
-
manager,
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
if (input.publish) {
|
|
173
|
-
templateVersion = await this.publishApprovalTemplateVersion(
|
|
174
|
-
templateDraftVersion.id,
|
|
175
|
-
currentMemberId ?? undefined,
|
|
176
|
-
manager,
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const formDefinition = await manager
|
|
181
|
-
.getRepository(FormDefinitionEntity)
|
|
182
|
-
.findOneByOrFail({ id: formDefinitionVersion.formDefinitionId });
|
|
183
|
-
const template = await manager
|
|
184
|
-
.getRepository(ApprovalTemplateEntity)
|
|
185
|
-
.findOneByOrFail({ id: templateVersion.templateId });
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
formDefinition,
|
|
189
|
-
formDefinitionVersion,
|
|
190
|
-
published: input.publish,
|
|
191
|
-
template,
|
|
192
|
-
templateVersion,
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
private async resolveComposedFormVersion(
|
|
199
|
-
manager: EntityManager,
|
|
200
|
-
input: ComposeApprovalTemplateWithFormInput,
|
|
201
|
-
currentMemberId: string | null,
|
|
202
|
-
): Promise<FormDefinitionVersionEntity> {
|
|
203
|
-
if (!input.formDefinitionId) {
|
|
204
|
-
const definition = await this.formService.createFormDefinition(
|
|
205
|
-
{
|
|
206
|
-
createdByMemberId: currentMemberId,
|
|
207
|
-
description: input.formDescription,
|
|
208
|
-
name: input.formName,
|
|
209
|
-
schemaJson: input.schemaJson,
|
|
210
|
-
uiSchemaJson: input.uiSchemaJson,
|
|
211
|
-
},
|
|
212
|
-
manager,
|
|
213
|
-
);
|
|
214
|
-
const draft = await this.formService.findDraftVersion(
|
|
215
|
-
definition.id,
|
|
216
|
-
manager,
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
if (!draft) {
|
|
220
|
-
throw new NotFoundException(
|
|
221
|
-
`Form definition ${definition.id} draft version was not created`,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return input.publish
|
|
226
|
-
? this.formService.publishFormDefinitionVersion(
|
|
227
|
-
draft.id,
|
|
228
|
-
currentMemberId ?? undefined,
|
|
229
|
-
manager,
|
|
230
|
-
)
|
|
231
|
-
: draft;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const existingDraft = await this.formService.findDraftVersion(
|
|
235
|
-
input.formDefinitionId,
|
|
236
|
-
manager,
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
if (existingDraft) {
|
|
240
|
-
const updated = await this.formService.updateFormDefinitionDraft(
|
|
241
|
-
{
|
|
242
|
-
schemaJson: input.schemaJson ?? '',
|
|
243
|
-
uiSchemaJson: input.uiSchemaJson ?? '',
|
|
244
|
-
versionId: existingDraft.id,
|
|
245
|
-
},
|
|
246
|
-
manager,
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
return input.publish
|
|
250
|
-
? this.formService.publishFormDefinitionVersion(
|
|
251
|
-
updated.id,
|
|
252
|
-
currentMemberId ?? undefined,
|
|
253
|
-
manager,
|
|
254
|
-
)
|
|
255
|
-
: updated;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Published definitions no longer keep a parallel draft: edits publish a
|
|
259
|
-
// new version immediately (content-identical saves reuse the current
|
|
260
|
-
// version) so the template draft can bind a published form version.
|
|
261
|
-
return this.formService.publishFormDefinitionContent(
|
|
262
|
-
{
|
|
263
|
-
formDefinitionId: input.formDefinitionId,
|
|
264
|
-
schemaJson: input.schemaJson,
|
|
265
|
-
uiSchemaJson: input.uiSchemaJson,
|
|
266
|
-
},
|
|
267
|
-
currentMemberId ?? undefined,
|
|
268
|
-
manager,
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
private async resolveComposedTemplateDraftVersion(
|
|
273
|
-
manager: EntityManager,
|
|
274
|
-
input: ComposeApprovalTemplateWithFormInput,
|
|
275
|
-
currentMemberId: string | null,
|
|
276
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
277
|
-
if (!input.templateId) {
|
|
278
|
-
const template = await this.createApprovalTemplate(
|
|
279
|
-
{
|
|
280
|
-
category: input.category,
|
|
281
|
-
categoryId: input.categoryId,
|
|
282
|
-
createdByMemberId: currentMemberId,
|
|
283
|
-
description: input.templateDescription,
|
|
284
|
-
formDefinitionVersionId: null,
|
|
285
|
-
name: input.templateName,
|
|
286
|
-
},
|
|
287
|
-
manager,
|
|
288
|
-
);
|
|
289
|
-
const draft = await this.findDraftTemplateVersion(template.id, manager);
|
|
290
|
-
|
|
291
|
-
if (!draft) {
|
|
292
|
-
throw new NotFoundException(
|
|
293
|
-
`Approval template ${template.id} draft version was not created`,
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
return draft;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
return (
|
|
301
|
-
(await this.findDraftTemplateVersion(input.templateId, manager)) ??
|
|
302
|
-
(await this.forkApprovalTemplate(input.templateId, manager))
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
private async findDraftTemplateVersion(
|
|
307
|
-
templateId: string,
|
|
308
|
-
manager?: EntityManager,
|
|
309
|
-
): Promise<ApprovalTemplateVersionEntity | null> {
|
|
310
|
-
return this.templateVersions(manager).findOne({
|
|
311
|
-
where: {
|
|
312
|
-
status: ApprovalTemplateVersionStatusEnum.DRAFT,
|
|
313
|
-
templateId,
|
|
314
|
-
},
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
async updateApprovalTemplate(
|
|
319
|
-
input: UpdateApprovalTemplateInput,
|
|
320
|
-
): Promise<ApprovalTemplateEntity> {
|
|
321
|
-
const existing = await this.getTemplateOrThrow(input.id);
|
|
322
|
-
const category =
|
|
323
|
-
input.categoryId === undefined
|
|
324
|
-
? undefined
|
|
325
|
-
: await this.validateOptionalTemplateCategory(input.categoryId);
|
|
326
|
-
const next = this.templateRepository.merge(existing, {
|
|
327
|
-
category:
|
|
328
|
-
input.category !== undefined
|
|
329
|
-
? input.category
|
|
330
|
-
: category !== undefined
|
|
331
|
-
? (category?.name ?? null)
|
|
332
|
-
: existing.category,
|
|
333
|
-
categoryId:
|
|
334
|
-
input.categoryId === undefined
|
|
335
|
-
? existing.categoryId
|
|
336
|
-
: (category?.id ?? null),
|
|
337
|
-
description: input.description ?? existing.description,
|
|
338
|
-
name: input.name ?? existing.name,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
return this.templateRepository.save(next);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
async listApprovalTemplates(
|
|
345
|
-
options: ListApprovalTemplatesOptions = {},
|
|
346
|
-
): Promise<readonly ApprovalTemplateEntity[]> {
|
|
347
|
-
const isPaginated =
|
|
348
|
-
typeof options.page === 'number' || typeof options.pageSize === 'number';
|
|
349
|
-
const normalizedPageSize = isPaginated
|
|
350
|
-
? normalizePageSize(options.pageSize ?? 10)
|
|
351
|
-
: undefined;
|
|
352
|
-
|
|
353
|
-
return this.templateRepository.find({
|
|
354
|
-
order: { updatedAt: 'DESC', createdAt: 'DESC' },
|
|
355
|
-
relations: { categoryDetail: true },
|
|
356
|
-
...(normalizedPageSize
|
|
357
|
-
? {
|
|
358
|
-
skip: (normalizePage(options.page ?? 1) - 1) * normalizedPageSize,
|
|
359
|
-
take: normalizedPageSize,
|
|
360
|
-
}
|
|
361
|
-
: {}),
|
|
362
|
-
where: createApprovalTemplateWhere({
|
|
363
|
-
categoryId: options.categoryId,
|
|
364
|
-
searchText: options.searchText,
|
|
365
|
-
status: options.status,
|
|
366
|
-
}),
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
async countApprovalTemplates({
|
|
371
|
-
categoryId,
|
|
372
|
-
searchText,
|
|
373
|
-
status,
|
|
374
|
-
}: {
|
|
375
|
-
readonly categoryId?: string;
|
|
376
|
-
readonly searchText?: string;
|
|
377
|
-
readonly status?: ApprovalTemplateListStatusEnum;
|
|
378
|
-
} = {}): Promise<number> {
|
|
379
|
-
return this.templateRepository.count({
|
|
380
|
-
where: createApprovalTemplateWhere({ categoryId, searchText, status }),
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
async getApprovalTemplate(id: string): Promise<ApprovalTemplateEntity> {
|
|
385
|
-
return this.getTemplateOrThrow(id);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
async listApprovalTemplateCategories(
|
|
389
|
-
options: ListApprovalTemplateCategoriesOptions = {},
|
|
390
|
-
): Promise<readonly ApprovalTemplateCategoryEntity[]> {
|
|
391
|
-
const isPaginated =
|
|
392
|
-
typeof options.page === 'number' || typeof options.pageSize === 'number';
|
|
393
|
-
const normalizedPageSize = isPaginated
|
|
394
|
-
? normalizePageSize(options.pageSize ?? 10)
|
|
395
|
-
: undefined;
|
|
396
|
-
|
|
397
|
-
return this.templateCategoryRepository.find({
|
|
398
|
-
order: { sortOrder: 'ASC', name: 'ASC', createdAt: 'ASC' },
|
|
399
|
-
...(normalizedPageSize
|
|
400
|
-
? {
|
|
401
|
-
skip: (normalizePage(options.page ?? 1) - 1) * normalizedPageSize,
|
|
402
|
-
take: normalizedPageSize,
|
|
403
|
-
}
|
|
404
|
-
: {}),
|
|
405
|
-
where: createApprovalTemplateCategoryWhere({
|
|
406
|
-
searchText: options.searchText,
|
|
407
|
-
status: options.status,
|
|
408
|
-
}),
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
async countApprovalTemplateCategories({
|
|
413
|
-
searchText,
|
|
414
|
-
status,
|
|
415
|
-
}: {
|
|
416
|
-
readonly searchText?: string;
|
|
417
|
-
readonly status?: ApprovalTemplateCategoryStatusEnum;
|
|
418
|
-
} = {}): Promise<number> {
|
|
419
|
-
return this.templateCategoryRepository.count({
|
|
420
|
-
where: createApprovalTemplateCategoryWhere({ searchText, status }),
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
async createApprovalTemplateCategory(
|
|
425
|
-
input: CreateApprovalTemplateCategoryInput,
|
|
426
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
427
|
-
return this.templateCategoryRepository.save(
|
|
428
|
-
this.templateCategoryRepository.create({
|
|
429
|
-
description: input.description,
|
|
430
|
-
isActive: input.isActive ?? true,
|
|
431
|
-
name: input.name,
|
|
432
|
-
sortOrder: input.sortOrder ?? 0,
|
|
433
|
-
}),
|
|
434
|
-
);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
async updateApprovalTemplateCategory(
|
|
438
|
-
input: UpdateApprovalTemplateCategoryInput,
|
|
439
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
440
|
-
const existing = await this.getTemplateCategoryOrThrow(input.id);
|
|
441
|
-
|
|
442
|
-
return this.templateCategoryRepository.save(
|
|
443
|
-
this.templateCategoryRepository.merge(existing, {
|
|
444
|
-
description: input.description ?? existing.description,
|
|
445
|
-
isActive: input.isActive ?? existing.isActive,
|
|
446
|
-
name: input.name ?? existing.name,
|
|
447
|
-
sortOrder: input.sortOrder ?? existing.sortOrder,
|
|
448
|
-
}),
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
async activateApprovalTemplateCategory(
|
|
453
|
-
id: string,
|
|
454
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
455
|
-
return this.setApprovalTemplateCategoryActive(id, true);
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
async deactivateApprovalTemplateCategory(
|
|
459
|
-
id: string,
|
|
460
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
461
|
-
return this.setApprovalTemplateCategoryActive(id, false);
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
async deleteApprovalTemplateCategory(
|
|
465
|
-
id: string,
|
|
466
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
467
|
-
const category = await this.getTemplateCategoryOrThrow(id);
|
|
468
|
-
const templateCount = await this.templateRepository.count({
|
|
469
|
-
where: { categoryId: id, deletedAt: IsNull() },
|
|
470
|
-
});
|
|
471
|
-
|
|
472
|
-
if (templateCount > 0) {
|
|
473
|
-
return this.templateCategoryRepository.save(
|
|
474
|
-
this.templateCategoryRepository.merge(category, {
|
|
475
|
-
isActive: false,
|
|
476
|
-
}),
|
|
477
|
-
);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
await this.templateCategoryRepository.remove(category);
|
|
481
|
-
|
|
482
|
-
return category;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
async listApprovalTemplateVersions(
|
|
486
|
-
templateId: string,
|
|
487
|
-
): Promise<readonly ApprovalTemplateVersionEntity[]> {
|
|
488
|
-
await this.getTemplateOrThrow(templateId);
|
|
489
|
-
|
|
490
|
-
return this.templateVersionRepository.find({
|
|
491
|
-
order: { version: 'DESC' },
|
|
492
|
-
where: { templateId },
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
async getApprovalTemplateVersion(
|
|
497
|
-
id: string,
|
|
498
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
499
|
-
return this.getTemplateVersionOrThrow(id);
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
async updateApprovalTemplateDraft(
|
|
503
|
-
input: UpdateApprovalTemplateDraftInput,
|
|
504
|
-
manager?: EntityManager,
|
|
505
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
506
|
-
const versionRepository = this.templateVersions(manager);
|
|
507
|
-
const existing = await this.getTemplateVersionOrThrow(
|
|
508
|
-
input.versionId,
|
|
509
|
-
manager,
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
if (existing.status !== ApprovalTemplateVersionStatusEnum.DRAFT) {
|
|
513
|
-
throw new ConflictException(
|
|
514
|
-
'Only draft approval template versions can be updated',
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
await this.validateOptionalFormDefinitionVersion(
|
|
519
|
-
input.formDefinitionVersionId,
|
|
520
|
-
manager,
|
|
521
|
-
);
|
|
522
|
-
const workflowDefinition = this.parseWorkflowDefinitionOrThrow(
|
|
523
|
-
input.workflowDefinitionJson,
|
|
524
|
-
);
|
|
525
|
-
const next = versionRepository.merge(existing, {
|
|
526
|
-
formDefinitionVersionId: input.formDefinitionVersionId,
|
|
527
|
-
initiatorPolicyCel: input.initiatorPolicyCel,
|
|
528
|
-
notificationConfig: parseOptionalJsonObject(input.notificationConfigJson),
|
|
529
|
-
slaDefaults: parseOptionalJsonObject(input.slaDefaultsJson),
|
|
530
|
-
workflowDefinition,
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
return versionRepository.save(next);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
async forkApprovalTemplate(
|
|
537
|
-
templateId: string,
|
|
538
|
-
manager?: EntityManager,
|
|
539
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
540
|
-
const versionRepository = this.templateVersions(manager);
|
|
541
|
-
const template = await this.getTemplateOrThrow(templateId, manager);
|
|
542
|
-
const existingDraft = await versionRepository.findOne({
|
|
543
|
-
where: {
|
|
544
|
-
status: ApprovalTemplateVersionStatusEnum.DRAFT,
|
|
545
|
-
templateId: template.id,
|
|
546
|
-
},
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
if (existingDraft) {
|
|
550
|
-
throw new ConflictException(
|
|
551
|
-
'A draft approval template version already exists',
|
|
552
|
-
);
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
const source = template.currentVersionId
|
|
556
|
-
? await this.getTemplateVersionOrThrow(template.currentVersionId, manager)
|
|
557
|
-
: null;
|
|
558
|
-
const nextVersion = await this.readNextVersionNumber(template.id, manager);
|
|
559
|
-
|
|
560
|
-
return versionRepository.save(
|
|
561
|
-
versionRepository.create({
|
|
562
|
-
archivedAt: null,
|
|
563
|
-
formDefinitionVersionId: source?.formDefinitionVersionId ?? null,
|
|
564
|
-
initiatorPolicyCel: source?.initiatorPolicyCel ?? null,
|
|
565
|
-
notificationConfig: source?.notificationConfig ?? null,
|
|
566
|
-
publishedAt: null,
|
|
567
|
-
publishedByMemberId: null,
|
|
568
|
-
slaDefaults: source?.slaDefaults ?? null,
|
|
569
|
-
status: ApprovalTemplateVersionStatusEnum.DRAFT,
|
|
570
|
-
templateId: template.id,
|
|
571
|
-
version: nextVersion,
|
|
572
|
-
workflowDefinition:
|
|
573
|
-
source?.workflowDefinition ?? EMPTY_WORKFLOW_DEFINITION,
|
|
574
|
-
}),
|
|
575
|
-
);
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
async publishApprovalTemplateVersion(
|
|
579
|
-
versionId: string,
|
|
580
|
-
publishedByMemberId?: string,
|
|
581
|
-
manager?: EntityManager,
|
|
582
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
583
|
-
const version = await this.getTemplateVersionOrThrow(versionId, manager);
|
|
584
|
-
|
|
585
|
-
if (version.status !== ApprovalTemplateVersionStatusEnum.DRAFT) {
|
|
586
|
-
throw new ConflictException(
|
|
587
|
-
'Only draft approval template versions can be published',
|
|
588
|
-
);
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
await this.validatePublishableVersion(version, manager);
|
|
592
|
-
|
|
593
|
-
const run = (
|
|
594
|
-
txManager: EntityManager,
|
|
595
|
-
): Promise<ApprovalTemplateVersionEntity> =>
|
|
596
|
-
this.publishApprovalTemplateVersionWithManager(
|
|
597
|
-
txManager,
|
|
598
|
-
version,
|
|
599
|
-
publishedByMemberId,
|
|
600
|
-
);
|
|
601
|
-
|
|
602
|
-
return manager
|
|
603
|
-
? run(manager)
|
|
604
|
-
: this.templateRepository.manager.transaction(run);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
private async publishApprovalTemplateVersionWithManager(
|
|
608
|
-
manager: EntityManager,
|
|
609
|
-
version: ApprovalTemplateVersionEntity,
|
|
610
|
-
publishedByMemberId?: string,
|
|
611
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
612
|
-
const templateRepository = manager.getRepository(ApprovalTemplateEntity);
|
|
613
|
-
const versionRepository = manager.getRepository(
|
|
614
|
-
ApprovalTemplateVersionEntity,
|
|
615
|
-
);
|
|
616
|
-
const template = await templateRepository.findOne({
|
|
617
|
-
where: { deletedAt: IsNull(), id: version.templateId },
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
if (!template) {
|
|
621
|
-
throw new NotFoundException(
|
|
622
|
-
`Approval template ${version.templateId} was not found`,
|
|
623
|
-
);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
if (template.currentVersionId) {
|
|
627
|
-
await versionRepository.update(
|
|
628
|
-
{ id: template.currentVersionId },
|
|
629
|
-
{
|
|
630
|
-
archivedAt: new Date(),
|
|
631
|
-
status: ApprovalTemplateVersionStatusEnum.ARCHIVED,
|
|
632
|
-
},
|
|
633
|
-
);
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
const published = versionRepository.merge(version, {
|
|
637
|
-
archivedAt: null,
|
|
638
|
-
publishedAt: new Date(),
|
|
639
|
-
publishedByMemberId: publishedByMemberId ?? null,
|
|
640
|
-
status: ApprovalTemplateVersionStatusEnum.PUBLISHED,
|
|
641
|
-
});
|
|
642
|
-
const saved = await versionRepository.save(published);
|
|
643
|
-
await templateRepository.save(
|
|
644
|
-
templateRepository.merge(template, {
|
|
645
|
-
currentVersionId: saved.id,
|
|
646
|
-
}),
|
|
647
|
-
);
|
|
648
|
-
|
|
649
|
-
return saved;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
async rollbackApprovalTemplateVersion(
|
|
653
|
-
versionId: string,
|
|
654
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
655
|
-
const target = await this.getTemplateVersionOrThrow(versionId);
|
|
656
|
-
|
|
657
|
-
if (target.status === ApprovalTemplateVersionStatusEnum.DRAFT) {
|
|
658
|
-
throw new ConflictException(
|
|
659
|
-
'Draft approval template versions cannot be rollback targets',
|
|
660
|
-
);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
return this.templateRepository.manager.transaction(
|
|
664
|
-
async (manager): Promise<ApprovalTemplateVersionEntity> => {
|
|
665
|
-
const templateRepository = manager.getRepository(
|
|
666
|
-
ApprovalTemplateEntity,
|
|
667
|
-
);
|
|
668
|
-
const versionRepository = manager.getRepository(
|
|
669
|
-
ApprovalTemplateVersionEntity,
|
|
670
|
-
);
|
|
671
|
-
const template = await templateRepository.findOne({
|
|
672
|
-
where: { deletedAt: IsNull(), id: target.templateId },
|
|
673
|
-
});
|
|
674
|
-
|
|
675
|
-
if (!template) {
|
|
676
|
-
throw new NotFoundException(
|
|
677
|
-
`Approval template ${target.templateId} was not found`,
|
|
678
|
-
);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
if (
|
|
682
|
-
template.currentVersionId &&
|
|
683
|
-
template.currentVersionId !== target.id
|
|
684
|
-
) {
|
|
685
|
-
await versionRepository.update(
|
|
686
|
-
{ id: template.currentVersionId },
|
|
687
|
-
{
|
|
688
|
-
archivedAt: new Date(),
|
|
689
|
-
status: ApprovalTemplateVersionStatusEnum.ARCHIVED,
|
|
690
|
-
},
|
|
691
|
-
);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
const restored = versionRepository.merge(target, {
|
|
695
|
-
archivedAt: null,
|
|
696
|
-
status: ApprovalTemplateVersionStatusEnum.PUBLISHED,
|
|
697
|
-
});
|
|
698
|
-
const saved = await versionRepository.save(restored);
|
|
699
|
-
await templateRepository.save(
|
|
700
|
-
templateRepository.merge(template, {
|
|
701
|
-
currentVersionId: saved.id,
|
|
702
|
-
}),
|
|
703
|
-
);
|
|
704
|
-
|
|
705
|
-
return saved;
|
|
706
|
-
},
|
|
707
|
-
);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
private async validatePublishableVersion(
|
|
711
|
-
version: ApprovalTemplateVersionEntity,
|
|
712
|
-
manager?: EntityManager,
|
|
713
|
-
): Promise<void> {
|
|
714
|
-
if (!version.formDefinitionVersionId) {
|
|
715
|
-
throw new BadRequestException(
|
|
716
|
-
'Approval template version must bind a form definition version before publishing',
|
|
717
|
-
);
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
const formVersion = await this.formVersions(manager).findOne({
|
|
721
|
-
where: { id: version.formDefinitionVersionId },
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
if (!formVersion) {
|
|
725
|
-
throw new NotFoundException(
|
|
726
|
-
`Form definition version ${version.formDefinitionVersionId} was not found`,
|
|
727
|
-
);
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
if (formVersion.status !== FormDefinitionVersionStatusEnum.PUBLISHED) {
|
|
731
|
-
throw new BadRequestException(
|
|
732
|
-
'Approval template can only bind a published form definition version',
|
|
733
|
-
);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
const workflowResult = lintWorkflowDefinition(version.workflowDefinition);
|
|
737
|
-
const conditionErrors = this.conditionService.lintExpressions(
|
|
738
|
-
readConditionExpressions(
|
|
739
|
-
version.workflowDefinition,
|
|
740
|
-
version.initiatorPolicyCel,
|
|
741
|
-
),
|
|
742
|
-
{
|
|
743
|
-
allowedRootIdentifiers: [
|
|
744
|
-
'env',
|
|
745
|
-
'form',
|
|
746
|
-
'formData',
|
|
747
|
-
'initiator',
|
|
748
|
-
'instance',
|
|
749
|
-
'subject',
|
|
750
|
-
],
|
|
751
|
-
},
|
|
752
|
-
);
|
|
753
|
-
const errors = [...workflowResult.errors, ...conditionErrors];
|
|
754
|
-
|
|
755
|
-
if (errors.length) {
|
|
756
|
-
throw new BadRequestException(errors.join('; '));
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
private async validateOptionalFormDefinitionVersion(
|
|
761
|
-
formDefinitionVersionId: string | null | undefined,
|
|
762
|
-
manager?: EntityManager,
|
|
763
|
-
): Promise<void> {
|
|
764
|
-
if (!formDefinitionVersionId) {
|
|
765
|
-
return;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
const formVersion = await this.formVersions(manager).findOne({
|
|
769
|
-
where: { id: formDefinitionVersionId },
|
|
770
|
-
});
|
|
771
|
-
|
|
772
|
-
if (!formVersion) {
|
|
773
|
-
throw new NotFoundException(
|
|
774
|
-
`Form definition version ${formDefinitionVersionId} was not found`,
|
|
775
|
-
);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
private async validateOptionalTemplateCategory(
|
|
780
|
-
categoryId: string | null | undefined,
|
|
781
|
-
manager?: EntityManager,
|
|
782
|
-
): Promise<ApprovalTemplateCategoryEntity | null> {
|
|
783
|
-
if (!categoryId) {
|
|
784
|
-
return null;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
return this.getTemplateCategoryOrThrow(categoryId, manager);
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
private templates(manager?: EntityManager): Repository<ApprovalTemplateEntity> {
|
|
791
|
-
return manager
|
|
792
|
-
? manager.getRepository(ApprovalTemplateEntity)
|
|
793
|
-
: this.templateRepository;
|
|
794
|
-
}
|
|
795
|
-
|
|
796
|
-
private templateVersions(
|
|
797
|
-
manager?: EntityManager,
|
|
798
|
-
): Repository<ApprovalTemplateVersionEntity> {
|
|
799
|
-
return manager
|
|
800
|
-
? manager.getRepository(ApprovalTemplateVersionEntity)
|
|
801
|
-
: this.templateVersionRepository;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
private templateCategories(
|
|
805
|
-
manager?: EntityManager,
|
|
806
|
-
): Repository<ApprovalTemplateCategoryEntity> {
|
|
807
|
-
return manager
|
|
808
|
-
? manager.getRepository(ApprovalTemplateCategoryEntity)
|
|
809
|
-
: this.templateCategoryRepository;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
private formVersions(
|
|
813
|
-
manager?: EntityManager,
|
|
814
|
-
): Repository<FormDefinitionVersionEntity> {
|
|
815
|
-
return manager
|
|
816
|
-
? manager.getRepository(FormDefinitionVersionEntity)
|
|
817
|
-
: this.formDefinitionVersionRepository;
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
private async getTemplateOrThrow(
|
|
821
|
-
id: string,
|
|
822
|
-
manager?: EntityManager,
|
|
823
|
-
): Promise<ApprovalTemplateEntity> {
|
|
824
|
-
const entity = await this.templates(manager).findOne({
|
|
825
|
-
relations: { categoryDetail: true },
|
|
826
|
-
where: { deletedAt: IsNull(), id },
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
if (!entity) {
|
|
830
|
-
throw new NotFoundException(`Approval template ${id} was not found`);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
return entity;
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
private async getTemplateCategoryOrThrow(
|
|
837
|
-
id: string,
|
|
838
|
-
manager?: EntityManager,
|
|
839
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
840
|
-
const entity = await this.templateCategories(manager).findOne({
|
|
841
|
-
where: { id },
|
|
842
|
-
});
|
|
843
|
-
|
|
844
|
-
if (!entity) {
|
|
845
|
-
throw new NotFoundException(
|
|
846
|
-
`Approval template category ${id} was not found`,
|
|
847
|
-
);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
return entity;
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
private async setApprovalTemplateCategoryActive(
|
|
854
|
-
id: string,
|
|
855
|
-
isActive: boolean,
|
|
856
|
-
): Promise<ApprovalTemplateCategoryEntity> {
|
|
857
|
-
const category = await this.getTemplateCategoryOrThrow(id);
|
|
858
|
-
|
|
859
|
-
return this.templateCategoryRepository.save(
|
|
860
|
-
this.templateCategoryRepository.merge(category, {
|
|
861
|
-
isActive,
|
|
862
|
-
}),
|
|
863
|
-
);
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
private async getTemplateVersionOrThrow(
|
|
867
|
-
id: string,
|
|
868
|
-
manager?: EntityManager,
|
|
869
|
-
): Promise<ApprovalTemplateVersionEntity> {
|
|
870
|
-
const entity = await this.templateVersions(manager).findOne({
|
|
871
|
-
where: { id },
|
|
872
|
-
});
|
|
873
|
-
|
|
874
|
-
if (!entity) {
|
|
875
|
-
throw new NotFoundException(
|
|
876
|
-
`Approval template version ${id} was not found`,
|
|
877
|
-
);
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
return entity;
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
private async readNextVersionNumber(
|
|
884
|
-
templateId: string,
|
|
885
|
-
manager?: EntityManager,
|
|
886
|
-
): Promise<number> {
|
|
887
|
-
const row = await this.templateVersions(manager)
|
|
888
|
-
.createQueryBuilder('version')
|
|
889
|
-
.select('MAX(version.version)', 'maxVersion')
|
|
890
|
-
.where('version.template_id = :templateId', { templateId })
|
|
891
|
-
.getRawOne<MaxVersionRow>();
|
|
892
|
-
const maxVersion =
|
|
893
|
-
typeof row?.maxVersion === 'number'
|
|
894
|
-
? row.maxVersion
|
|
895
|
-
: Number(row?.maxVersion ?? 0);
|
|
896
|
-
|
|
897
|
-
return maxVersion + 1;
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
private parseWorkflowDefinitionOrThrow(value: string): WorkflowDefinition {
|
|
901
|
-
try {
|
|
902
|
-
return parseWorkflowDefinitionJson(value);
|
|
903
|
-
} catch (error: unknown) {
|
|
904
|
-
throw new BadRequestException(
|
|
905
|
-
error instanceof Error ? error.message : 'Invalid workflow definition',
|
|
906
|
-
);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
function parseOptionalJsonObject(
|
|
912
|
-
value: string | null | undefined,
|
|
913
|
-
): Readonly<Record<string, unknown>> | null {
|
|
914
|
-
if (!value) {
|
|
915
|
-
return null;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
const parsedValue = parseJson(value);
|
|
919
|
-
|
|
920
|
-
if (!isRecord(parsedValue)) {
|
|
921
|
-
throw new BadRequestException('JSON value must be an object');
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
return parsedValue;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
function parseJson(value: string): unknown {
|
|
928
|
-
try {
|
|
929
|
-
return JSON.parse(value) as unknown;
|
|
930
|
-
} catch (error: unknown) {
|
|
931
|
-
throw new BadRequestException(
|
|
932
|
-
error instanceof Error ? error.message : 'Invalid JSON value',
|
|
933
|
-
);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
function normalizePage(page: number): number {
|
|
938
|
-
return Number.isInteger(page) && page > 0 ? page : 1;
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
function normalizePageSize(pageSize: number): number {
|
|
942
|
-
if (!Number.isInteger(pageSize) || pageSize <= 0) {
|
|
943
|
-
return 10;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
return Math.min(pageSize, 100);
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
function createApprovalTemplateWhere(
|
|
950
|
-
options: Readonly<{
|
|
951
|
-
readonly categoryId?: string;
|
|
952
|
-
readonly searchText?: string;
|
|
953
|
-
readonly status?: ApprovalTemplateListStatusEnum;
|
|
954
|
-
}>,
|
|
955
|
-
):
|
|
956
|
-
| FindOptionsWhere<ApprovalTemplateEntity>
|
|
957
|
-
| FindOptionsWhere<ApprovalTemplateEntity>[] {
|
|
958
|
-
const activeTemplateWhere: FindOptionsWhere<ApprovalTemplateEntity> = {
|
|
959
|
-
deletedAt: IsNull(),
|
|
960
|
-
};
|
|
961
|
-
const statusWhere: FindOptionsWhere<ApprovalTemplateEntity> =
|
|
962
|
-
options.status === ApprovalTemplateListStatusEnum.DRAFT
|
|
963
|
-
? { currentVersionId: IsNull() }
|
|
964
|
-
: {};
|
|
965
|
-
const publicationWhere: FindOptionsWhere<ApprovalTemplateEntity> =
|
|
966
|
-
options.status === ApprovalTemplateListStatusEnum.PUBLISHED
|
|
967
|
-
? { currentVersionId: Not(IsNull()) }
|
|
968
|
-
: {};
|
|
969
|
-
const baseWhere: FindOptionsWhere<ApprovalTemplateEntity> = {
|
|
970
|
-
...activeTemplateWhere,
|
|
971
|
-
...(options.categoryId ? { categoryId: options.categoryId } : {}),
|
|
972
|
-
...statusWhere,
|
|
973
|
-
...publicationWhere,
|
|
974
|
-
};
|
|
975
|
-
|
|
976
|
-
const trimmedSearchText = options.searchText?.trim();
|
|
977
|
-
|
|
978
|
-
if (!trimmedSearchText) {
|
|
979
|
-
return baseWhere;
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
const searchPattern = `%${trimmedSearchText}%`;
|
|
983
|
-
|
|
984
|
-
return [
|
|
985
|
-
{ ...baseWhere, name: ILike(searchPattern) },
|
|
986
|
-
{ ...baseWhere, category: ILike(searchPattern) },
|
|
987
|
-
{ ...baseWhere, description: ILike(searchPattern) },
|
|
988
|
-
];
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
function createApprovalTemplateCategoryWhere(
|
|
992
|
-
options: Readonly<{
|
|
993
|
-
readonly searchText?: string;
|
|
994
|
-
readonly status?: ApprovalTemplateCategoryStatusEnum;
|
|
995
|
-
}>,
|
|
996
|
-
):
|
|
997
|
-
| FindOptionsWhere<ApprovalTemplateCategoryEntity>
|
|
998
|
-
| FindOptionsWhere<ApprovalTemplateCategoryEntity>[] {
|
|
999
|
-
const statusWhere: FindOptionsWhere<ApprovalTemplateCategoryEntity> =
|
|
1000
|
-
options.status === ApprovalTemplateCategoryStatusEnum.ALL
|
|
1001
|
-
? {}
|
|
1002
|
-
: options.status === ApprovalTemplateCategoryStatusEnum.INACTIVE
|
|
1003
|
-
? { isActive: false }
|
|
1004
|
-
: { isActive: true };
|
|
1005
|
-
const trimmedSearchText = options.searchText?.trim();
|
|
1006
|
-
|
|
1007
|
-
if (!trimmedSearchText) {
|
|
1008
|
-
return statusWhere;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
const searchPattern = `%${trimmedSearchText}%`;
|
|
1012
|
-
|
|
1013
|
-
return [
|
|
1014
|
-
{ ...statusWhere, name: ILike(searchPattern) },
|
|
1015
|
-
{ ...statusWhere, description: ILike(searchPattern) },
|
|
1016
|
-
];
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
function readConditionExpressions(
|
|
1020
|
-
definition: WorkflowDefinition,
|
|
1021
|
-
initiatorPolicyCel: string | null,
|
|
1022
|
-
): readonly {
|
|
1023
|
-
readonly expression: string | null | undefined;
|
|
1024
|
-
readonly label: string;
|
|
1025
|
-
}[] {
|
|
1026
|
-
return [
|
|
1027
|
-
{ expression: initiatorPolicyCel, label: 'initiatorPolicyCel' },
|
|
1028
|
-
...definition.edges.map((edge) => ({
|
|
1029
|
-
expression: edge.data.condition,
|
|
1030
|
-
label: `workflow.edges.${edge.id}.data.condition`,
|
|
1031
|
-
})),
|
|
1032
|
-
...definition.nodes.flatMap((node) => {
|
|
1033
|
-
if (node.type === 'userTask') {
|
|
1034
|
-
return [
|
|
1035
|
-
{
|
|
1036
|
-
expression: node.data.entryCondition,
|
|
1037
|
-
label: `workflow.nodes.${node.id}.data.entryCondition`,
|
|
1038
|
-
},
|
|
1039
|
-
...(node.data.approverResolver.type === 'EXPRESSION'
|
|
1040
|
-
? [
|
|
1041
|
-
{
|
|
1042
|
-
expression: node.data.approverResolver.expression,
|
|
1043
|
-
label: `workflow.nodes.${node.id}.data.approverResolver.expression`,
|
|
1044
|
-
},
|
|
1045
|
-
]
|
|
1046
|
-
: []),
|
|
1047
|
-
];
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
if (node.type === 'serviceTask') {
|
|
1051
|
-
return [
|
|
1052
|
-
{
|
|
1053
|
-
expression: node.data.entryCondition,
|
|
1054
|
-
label: `workflow.nodes.${node.id}.data.entryCondition`,
|
|
1055
|
-
},
|
|
1056
|
-
...(node.data.action.type === 'WEBHOOK'
|
|
1057
|
-
? [
|
|
1058
|
-
{
|
|
1059
|
-
expression: node.data.action.payload,
|
|
1060
|
-
label: `workflow.nodes.${node.id}.data.action.payload`,
|
|
1061
|
-
},
|
|
1062
|
-
]
|
|
1063
|
-
: []),
|
|
1064
|
-
...(node.data.action.type === 'SET_FORM_FIELD'
|
|
1065
|
-
? [
|
|
1066
|
-
{
|
|
1067
|
-
expression: node.data.action.value,
|
|
1068
|
-
label: `workflow.nodes.${node.id}.data.action.value`,
|
|
1069
|
-
},
|
|
1070
|
-
]
|
|
1071
|
-
: []),
|
|
1072
|
-
];
|
|
1073
|
-
}
|
|
1074
|
-
|
|
1075
|
-
return [];
|
|
1076
|
-
}),
|
|
1077
|
-
];
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
1081
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
1082
|
-
}
|