@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,822 +0,0 @@
|
|
|
1
|
-
import { EntityManager, ObjectLiteral, Repository } from 'typeorm';
|
|
2
|
-
import { ConditionService } from '../condition/condition.service';
|
|
3
|
-
import { FormDefinitionEntity } from '../form/form-definition.entity';
|
|
4
|
-
import { FormDefinitionVersionEntity } from '../form/form-definition-version.entity';
|
|
5
|
-
import { FormDefinitionVersionStatusEnum } from '../form/form.enums';
|
|
6
|
-
import { FormService } from '../form/form.service';
|
|
7
|
-
import { ApprovalTemplateCategoryEntity } from './approval-template-category.entity';
|
|
8
|
-
import { ApprovalTemplateEntity } from './approval-template.entity';
|
|
9
|
-
import { ApprovalTemplateVersionEntity } from './approval-template-version.entity';
|
|
10
|
-
import {
|
|
11
|
-
ApprovalTemplateCategoryStatusEnum,
|
|
12
|
-
ApprovalTemplateListStatusEnum,
|
|
13
|
-
ApprovalTemplateVersionStatusEnum,
|
|
14
|
-
} from './template.enums';
|
|
15
|
-
import { TemplateService } from './template.service';
|
|
16
|
-
import { EMPTY_WORKFLOW_DEFINITION } from './workflow-definition.validator';
|
|
17
|
-
|
|
18
|
-
describe('TemplateService', () => {
|
|
19
|
-
it('applies backend pagination when listing approval templates and counts active records', async (): Promise<void> => {
|
|
20
|
-
const templates = Array.from({ length: 13 }, (_, index) =>
|
|
21
|
-
createApprovalTemplate(`template-${index + 1}`),
|
|
22
|
-
);
|
|
23
|
-
const find = jest.fn(
|
|
24
|
-
({
|
|
25
|
-
skip = 0,
|
|
26
|
-
take = 10,
|
|
27
|
-
}: {
|
|
28
|
-
readonly skip?: number;
|
|
29
|
-
readonly take?: number;
|
|
30
|
-
}): Promise<readonly ApprovalTemplateEntity[]> =>
|
|
31
|
-
Promise.resolve(templates.slice(skip, skip + take)),
|
|
32
|
-
);
|
|
33
|
-
const count = jest.fn(
|
|
34
|
-
(): Promise<number> => Promise.resolve(templates.length),
|
|
35
|
-
);
|
|
36
|
-
const service = new TemplateService(
|
|
37
|
-
{
|
|
38
|
-
count,
|
|
39
|
-
find,
|
|
40
|
-
} as unknown as Repository<ApprovalTemplateEntity>,
|
|
41
|
-
createRepository<ApprovalTemplateCategoryEntity>(),
|
|
42
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
43
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
44
|
-
new ConditionService(),
|
|
45
|
-
{} as unknown as FormService,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const pageTwo = await service.listApprovalTemplates({
|
|
49
|
-
page: 2,
|
|
50
|
-
pageSize: 5,
|
|
51
|
-
});
|
|
52
|
-
const totalCount = await service.countApprovalTemplates();
|
|
53
|
-
|
|
54
|
-
expect(find).toHaveBeenCalledWith(
|
|
55
|
-
expect.objectContaining({
|
|
56
|
-
order: { createdAt: 'DESC', updatedAt: 'DESC' },
|
|
57
|
-
skip: 5,
|
|
58
|
-
take: 5,
|
|
59
|
-
where: expect.objectContaining({
|
|
60
|
-
deletedAt: expect.any(Object),
|
|
61
|
-
}),
|
|
62
|
-
}),
|
|
63
|
-
);
|
|
64
|
-
expect(pageTwo.map((template) => template.id)).toEqual([
|
|
65
|
-
'template-6',
|
|
66
|
-
'template-7',
|
|
67
|
-
'template-8',
|
|
68
|
-
'template-9',
|
|
69
|
-
'template-10',
|
|
70
|
-
]);
|
|
71
|
-
expect(totalCount).toBe(13);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('filters approval templates by derived publication status', async (): Promise<void> => {
|
|
75
|
-
const find = jest.fn(
|
|
76
|
-
(): Promise<readonly ApprovalTemplateEntity[]> => Promise.resolve([]),
|
|
77
|
-
);
|
|
78
|
-
const count = jest.fn((): Promise<number> => Promise.resolve(0));
|
|
79
|
-
const service = new TemplateService(
|
|
80
|
-
{
|
|
81
|
-
count,
|
|
82
|
-
find,
|
|
83
|
-
} as unknown as Repository<ApprovalTemplateEntity>,
|
|
84
|
-
createRepository<ApprovalTemplateCategoryEntity>(),
|
|
85
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
86
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
87
|
-
new ConditionService(),
|
|
88
|
-
{} as unknown as FormService,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
await service.listApprovalTemplates({
|
|
92
|
-
status: ApprovalTemplateListStatusEnum.PUBLISHED,
|
|
93
|
-
});
|
|
94
|
-
await service.countApprovalTemplates({
|
|
95
|
-
status: ApprovalTemplateListStatusEnum.DRAFT,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
expect(find).toHaveBeenCalledWith(
|
|
99
|
-
expect.objectContaining({
|
|
100
|
-
where: expect.objectContaining({
|
|
101
|
-
currentVersionId: expect.any(Object),
|
|
102
|
-
deletedAt: expect.any(Object),
|
|
103
|
-
}),
|
|
104
|
-
}),
|
|
105
|
-
);
|
|
106
|
-
expect(count).toHaveBeenCalledWith(
|
|
107
|
-
expect.objectContaining({
|
|
108
|
-
where: expect.objectContaining({
|
|
109
|
-
currentVersionId: expect.any(Object),
|
|
110
|
-
deletedAt: expect.any(Object),
|
|
111
|
-
}),
|
|
112
|
-
}),
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('pushes search text into server-side template filters', async (): Promise<void> => {
|
|
117
|
-
const find = jest.fn(
|
|
118
|
-
(): Promise<readonly ApprovalTemplateEntity[]> => Promise.resolve([]),
|
|
119
|
-
);
|
|
120
|
-
const count = jest.fn((): Promise<number> => Promise.resolve(0));
|
|
121
|
-
const service = new TemplateService(
|
|
122
|
-
{
|
|
123
|
-
count,
|
|
124
|
-
find,
|
|
125
|
-
} as unknown as Repository<ApprovalTemplateEntity>,
|
|
126
|
-
createRepository<ApprovalTemplateCategoryEntity>(),
|
|
127
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
128
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
129
|
-
new ConditionService(),
|
|
130
|
-
{} as unknown as FormService,
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
await service.listApprovalTemplates({
|
|
134
|
-
searchText: '費用',
|
|
135
|
-
status: ApprovalTemplateListStatusEnum.PUBLISHED,
|
|
136
|
-
});
|
|
137
|
-
await service.countApprovalTemplates({
|
|
138
|
-
searchText: '費用',
|
|
139
|
-
status: ApprovalTemplateListStatusEnum.PUBLISHED,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
expect(find).toHaveBeenCalledWith(
|
|
143
|
-
expect.objectContaining({
|
|
144
|
-
where: expect.arrayContaining([
|
|
145
|
-
expect.objectContaining({
|
|
146
|
-
currentVersionId: expect.any(Object),
|
|
147
|
-
deletedAt: expect.any(Object),
|
|
148
|
-
name: expect.any(Object),
|
|
149
|
-
}),
|
|
150
|
-
expect.objectContaining({
|
|
151
|
-
category: expect.any(Object),
|
|
152
|
-
currentVersionId: expect.any(Object),
|
|
153
|
-
deletedAt: expect.any(Object),
|
|
154
|
-
}),
|
|
155
|
-
expect.objectContaining({
|
|
156
|
-
currentVersionId: expect.any(Object),
|
|
157
|
-
deletedAt: expect.any(Object),
|
|
158
|
-
description: expect.any(Object),
|
|
159
|
-
}),
|
|
160
|
-
]),
|
|
161
|
-
}),
|
|
162
|
-
);
|
|
163
|
-
expect(count).toHaveBeenCalledWith(
|
|
164
|
-
expect.objectContaining({
|
|
165
|
-
where: expect.any(Array),
|
|
166
|
-
}),
|
|
167
|
-
);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('filters approval templates by category id', async (): Promise<void> => {
|
|
171
|
-
const find = jest.fn(
|
|
172
|
-
(): Promise<readonly ApprovalTemplateEntity[]> => Promise.resolve([]),
|
|
173
|
-
);
|
|
174
|
-
const count = jest.fn((): Promise<number> => Promise.resolve(0));
|
|
175
|
-
const service = new TemplateService(
|
|
176
|
-
{
|
|
177
|
-
count,
|
|
178
|
-
find,
|
|
179
|
-
} as unknown as Repository<ApprovalTemplateEntity>,
|
|
180
|
-
createRepository<ApprovalTemplateCategoryEntity>(),
|
|
181
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
182
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
183
|
-
new ConditionService(),
|
|
184
|
-
{} as unknown as FormService,
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
await service.listApprovalTemplates({
|
|
188
|
-
categoryId: 'category-1',
|
|
189
|
-
});
|
|
190
|
-
await service.countApprovalTemplates({
|
|
191
|
-
categoryId: 'category-1',
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
expect(find).toHaveBeenCalledWith(
|
|
195
|
-
expect.objectContaining({
|
|
196
|
-
where: expect.objectContaining({
|
|
197
|
-
categoryId: 'category-1',
|
|
198
|
-
deletedAt: expect.any(Object),
|
|
199
|
-
}),
|
|
200
|
-
}),
|
|
201
|
-
);
|
|
202
|
-
expect(count).toHaveBeenCalledWith(
|
|
203
|
-
expect.objectContaining({
|
|
204
|
-
where: expect.objectContaining({
|
|
205
|
-
categoryId: 'category-1',
|
|
206
|
-
deletedAt: expect.any(Object),
|
|
207
|
-
}),
|
|
208
|
-
}),
|
|
209
|
-
);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('lists active approval template categories by default', async (): Promise<void> => {
|
|
213
|
-
const find = jest.fn(
|
|
214
|
-
(): Promise<readonly ApprovalTemplateCategoryEntity[]> =>
|
|
215
|
-
Promise.resolve([]),
|
|
216
|
-
);
|
|
217
|
-
const count = jest.fn((): Promise<number> => Promise.resolve(0));
|
|
218
|
-
const service = new TemplateService(
|
|
219
|
-
createRepository<ApprovalTemplateEntity>(),
|
|
220
|
-
{
|
|
221
|
-
count,
|
|
222
|
-
find,
|
|
223
|
-
} as unknown as Repository<ApprovalTemplateCategoryEntity>,
|
|
224
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
225
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
226
|
-
new ConditionService(),
|
|
227
|
-
{} as unknown as FormService,
|
|
228
|
-
);
|
|
229
|
-
|
|
230
|
-
await service.listApprovalTemplateCategories({
|
|
231
|
-
page: 1,
|
|
232
|
-
pageSize: 20,
|
|
233
|
-
searchText: '財務',
|
|
234
|
-
});
|
|
235
|
-
await service.countApprovalTemplateCategories({
|
|
236
|
-
status: ApprovalTemplateCategoryStatusEnum.ALL,
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
expect(find).toHaveBeenCalledWith(
|
|
240
|
-
expect.objectContaining({
|
|
241
|
-
order: { createdAt: 'ASC', name: 'ASC', sortOrder: 'ASC' },
|
|
242
|
-
take: 20,
|
|
243
|
-
where: expect.arrayContaining([
|
|
244
|
-
expect.objectContaining({
|
|
245
|
-
isActive: true,
|
|
246
|
-
name: expect.any(Object),
|
|
247
|
-
}),
|
|
248
|
-
expect.objectContaining({
|
|
249
|
-
description: expect.any(Object),
|
|
250
|
-
isActive: true,
|
|
251
|
-
}),
|
|
252
|
-
]),
|
|
253
|
-
}),
|
|
254
|
-
);
|
|
255
|
-
expect(count).toHaveBeenCalledWith(
|
|
256
|
-
expect.objectContaining({
|
|
257
|
-
where: {},
|
|
258
|
-
}),
|
|
259
|
-
);
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('validates category existence when creating approval templates', async (): Promise<void> => {
|
|
263
|
-
const category = createApprovalTemplateCategory('category-1');
|
|
264
|
-
const categoryFindOne = jest.fn(
|
|
265
|
-
(): Promise<ApprovalTemplateCategoryEntity | null> =>
|
|
266
|
-
Promise.resolve(category),
|
|
267
|
-
);
|
|
268
|
-
const templateCreate = jest.fn(
|
|
269
|
-
(value: Partial<ApprovalTemplateEntity>): ApprovalTemplateEntity =>
|
|
270
|
-
Object.assign(new ApprovalTemplateEntity(), value),
|
|
271
|
-
);
|
|
272
|
-
const templateSave = jest.fn(
|
|
273
|
-
(value: ApprovalTemplateEntity): Promise<ApprovalTemplateEntity> =>
|
|
274
|
-
Promise.resolve({ ...value, id: 'template-1' }),
|
|
275
|
-
);
|
|
276
|
-
const versionSave = jest.fn(
|
|
277
|
-
(
|
|
278
|
-
value: ApprovalTemplateVersionEntity,
|
|
279
|
-
): Promise<ApprovalTemplateVersionEntity> => Promise.resolve(value),
|
|
280
|
-
);
|
|
281
|
-
const versionCreate = jest.fn(
|
|
282
|
-
(
|
|
283
|
-
value: Partial<ApprovalTemplateVersionEntity>,
|
|
284
|
-
): ApprovalTemplateVersionEntity =>
|
|
285
|
-
Object.assign(new ApprovalTemplateVersionEntity(), value),
|
|
286
|
-
);
|
|
287
|
-
const manager = {
|
|
288
|
-
getRepository: jest.fn((entity: unknown): unknown => {
|
|
289
|
-
if (entity === ApprovalTemplateEntity) {
|
|
290
|
-
return {
|
|
291
|
-
create: templateCreate,
|
|
292
|
-
save: templateSave,
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (entity === ApprovalTemplateCategoryEntity) {
|
|
297
|
-
return {
|
|
298
|
-
findOne: categoryFindOne,
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (entity === FormDefinitionVersionEntity) {
|
|
303
|
-
return {
|
|
304
|
-
findOne: jest.fn(
|
|
305
|
-
(): Promise<FormDefinitionVersionEntity | null> =>
|
|
306
|
-
Promise.resolve(null),
|
|
307
|
-
),
|
|
308
|
-
};
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
create: versionCreate,
|
|
313
|
-
save: versionSave,
|
|
314
|
-
};
|
|
315
|
-
}),
|
|
316
|
-
transaction: jest.fn(
|
|
317
|
-
<TResult>(
|
|
318
|
-
operation: (manager: {
|
|
319
|
-
readonly getRepository: (entity: unknown) => unknown;
|
|
320
|
-
}) => Promise<TResult>,
|
|
321
|
-
): Promise<TResult> => operation(manager),
|
|
322
|
-
),
|
|
323
|
-
};
|
|
324
|
-
const service = new TemplateService(
|
|
325
|
-
{ manager } as unknown as Repository<ApprovalTemplateEntity>,
|
|
326
|
-
createRepository<ApprovalTemplateCategoryEntity>(),
|
|
327
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
328
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
329
|
-
new ConditionService(),
|
|
330
|
-
{} as unknown as FormService,
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
await service.createApprovalTemplate({
|
|
334
|
-
category: null,
|
|
335
|
-
categoryId: 'category-1',
|
|
336
|
-
createdByMemberId: null,
|
|
337
|
-
description: null,
|
|
338
|
-
formDefinitionVersionId: null,
|
|
339
|
-
name: '費用簽核',
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
expect(categoryFindOne).toHaveBeenCalledWith({
|
|
343
|
-
where: { id: 'category-1' },
|
|
344
|
-
});
|
|
345
|
-
expect(templateCreate).toHaveBeenCalledWith(
|
|
346
|
-
expect.objectContaining({
|
|
347
|
-
category: '財務',
|
|
348
|
-
categoryId: 'category-1',
|
|
349
|
-
}),
|
|
350
|
-
);
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it('rejects publishing a draft with workflow lint errors before mutating template state', async (): Promise<void> => {
|
|
354
|
-
const draftVersion = Object.assign(new ApprovalTemplateVersionEntity(), {
|
|
355
|
-
archivedAt: null,
|
|
356
|
-
createdAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
357
|
-
formDefinitionVersionId: 'form-version-1',
|
|
358
|
-
id: 'template-version-1',
|
|
359
|
-
initiatorPolicyCel: null,
|
|
360
|
-
notificationConfig: null,
|
|
361
|
-
publishedAt: null,
|
|
362
|
-
publishedByMemberId: null,
|
|
363
|
-
slaDefaults: null,
|
|
364
|
-
status: ApprovalTemplateVersionStatusEnum.DRAFT,
|
|
365
|
-
templateId: 'template-1',
|
|
366
|
-
updatedAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
367
|
-
version: 1,
|
|
368
|
-
workflowDefinition: EMPTY_WORKFLOW_DEFINITION,
|
|
369
|
-
});
|
|
370
|
-
const formVersion = Object.assign(new FormDefinitionVersionEntity(), {
|
|
371
|
-
archivedAt: null,
|
|
372
|
-
createdAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
373
|
-
formDefinitionId: 'form-1',
|
|
374
|
-
id: 'form-version-1',
|
|
375
|
-
publishedAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
376
|
-
publishedByMemberId: 'member-admin',
|
|
377
|
-
schema: { fields: [], schemaVersion: 1 },
|
|
378
|
-
status: FormDefinitionVersionStatusEnum.PUBLISHED,
|
|
379
|
-
uiSchema: { fieldOrder: [] },
|
|
380
|
-
updatedAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
381
|
-
version: 1,
|
|
382
|
-
});
|
|
383
|
-
const transaction = jest.fn(
|
|
384
|
-
<TResult>(
|
|
385
|
-
operation: (
|
|
386
|
-
manager: Readonly<Record<string, unknown>>,
|
|
387
|
-
) => Promise<TResult>,
|
|
388
|
-
): Promise<TResult> => operation({}),
|
|
389
|
-
);
|
|
390
|
-
const service = new TemplateService(
|
|
391
|
-
{
|
|
392
|
-
manager: { transaction },
|
|
393
|
-
} as unknown as Repository<ApprovalTemplateEntity>,
|
|
394
|
-
createRepository<ApprovalTemplateCategoryEntity>(),
|
|
395
|
-
{
|
|
396
|
-
findOne: jest.fn(
|
|
397
|
-
(): Promise<ApprovalTemplateVersionEntity | null> =>
|
|
398
|
-
Promise.resolve(draftVersion),
|
|
399
|
-
),
|
|
400
|
-
} as unknown as Repository<ApprovalTemplateVersionEntity>,
|
|
401
|
-
{
|
|
402
|
-
findOne: jest.fn(
|
|
403
|
-
(): Promise<FormDefinitionVersionEntity | null> =>
|
|
404
|
-
Promise.resolve(formVersion),
|
|
405
|
-
),
|
|
406
|
-
} as unknown as Repository<FormDefinitionVersionEntity>,
|
|
407
|
-
new ConditionService(),
|
|
408
|
-
{} as unknown as FormService,
|
|
409
|
-
);
|
|
410
|
-
|
|
411
|
-
await expect(
|
|
412
|
-
service.publishApprovalTemplateVersion('template-version-1'),
|
|
413
|
-
).rejects.toThrow(
|
|
414
|
-
'workflow.nodes.start does not have a path to an endEvent',
|
|
415
|
-
);
|
|
416
|
-
expect(transaction).not.toHaveBeenCalled();
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it('deactivates categories on delete when templates still use them', async (): Promise<void> => {
|
|
420
|
-
const category = createApprovalTemplateCategory('category-1');
|
|
421
|
-
const categorySave = jest.fn(
|
|
422
|
-
(
|
|
423
|
-
value: ApprovalTemplateCategoryEntity,
|
|
424
|
-
): Promise<ApprovalTemplateCategoryEntity> => Promise.resolve(value),
|
|
425
|
-
);
|
|
426
|
-
const service = new TemplateService(
|
|
427
|
-
{
|
|
428
|
-
count: jest.fn((): Promise<number> => Promise.resolve(2)),
|
|
429
|
-
} as unknown as Repository<ApprovalTemplateEntity>,
|
|
430
|
-
{
|
|
431
|
-
findOne: jest.fn(
|
|
432
|
-
(): Promise<ApprovalTemplateCategoryEntity | null> =>
|
|
433
|
-
Promise.resolve(category),
|
|
434
|
-
),
|
|
435
|
-
merge: jest.fn(
|
|
436
|
-
(
|
|
437
|
-
entity: ApprovalTemplateCategoryEntity,
|
|
438
|
-
value: Partial<ApprovalTemplateCategoryEntity>,
|
|
439
|
-
): ApprovalTemplateCategoryEntity => Object.assign(entity, value),
|
|
440
|
-
),
|
|
441
|
-
save: categorySave,
|
|
442
|
-
} as unknown as Repository<ApprovalTemplateCategoryEntity>,
|
|
443
|
-
createRepository<ApprovalTemplateVersionEntity>(),
|
|
444
|
-
createRepository<FormDefinitionVersionEntity>(),
|
|
445
|
-
new ConditionService(),
|
|
446
|
-
{} as unknown as FormService,
|
|
447
|
-
);
|
|
448
|
-
|
|
449
|
-
const deleted = await service.deleteApprovalTemplateCategory('category-1');
|
|
450
|
-
|
|
451
|
-
expect(deleted.isActive).toBe(false);
|
|
452
|
-
expect(categorySave).toHaveBeenCalledWith(
|
|
453
|
-
expect.objectContaining({
|
|
454
|
-
isActive: false,
|
|
455
|
-
}),
|
|
456
|
-
);
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
describe('TemplateService.composeApprovalTemplateWithForm', () => {
|
|
461
|
-
it('publishes form and template atomically when publish is true', async (): Promise<void> => {
|
|
462
|
-
const { manager, store } = createInMemoryManager();
|
|
463
|
-
const service = createComposingService(manager);
|
|
464
|
-
|
|
465
|
-
const result = await service.composeApprovalTemplateWithForm(
|
|
466
|
-
{
|
|
467
|
-
category: null,
|
|
468
|
-
categoryId: null,
|
|
469
|
-
formDefinitionId: null,
|
|
470
|
-
formDescription: null,
|
|
471
|
-
formName: '請款表單',
|
|
472
|
-
initiatorPolicyCel: null,
|
|
473
|
-
notificationConfigJson: null,
|
|
474
|
-
publish: true,
|
|
475
|
-
schemaJson: JSON.stringify(SAMPLE_FORM_SCHEMA),
|
|
476
|
-
slaDefaultsJson: null,
|
|
477
|
-
templateDescription: null,
|
|
478
|
-
templateId: null,
|
|
479
|
-
templateName: '請款簽核',
|
|
480
|
-
uiSchemaJson: JSON.stringify(SAMPLE_FORM_UI_SCHEMA),
|
|
481
|
-
workflowDefinitionJson: JSON.stringify(VALID_WORKFLOW_DEFINITION),
|
|
482
|
-
},
|
|
483
|
-
'member-admin',
|
|
484
|
-
);
|
|
485
|
-
|
|
486
|
-
expect(result.published).toBe(true);
|
|
487
|
-
expect(result.formDefinitionVersion.status).toBe(
|
|
488
|
-
FormDefinitionVersionStatusEnum.PUBLISHED,
|
|
489
|
-
);
|
|
490
|
-
expect(result.templateVersion.status).toBe(
|
|
491
|
-
ApprovalTemplateVersionStatusEnum.PUBLISHED,
|
|
492
|
-
);
|
|
493
|
-
// The template version binds the freshly published form version.
|
|
494
|
-
expect(result.templateVersion.formDefinitionVersionId).toBe(
|
|
495
|
-
result.formDefinitionVersion.id,
|
|
496
|
-
);
|
|
497
|
-
// Both parents now point at the published versions.
|
|
498
|
-
expect(result.formDefinition.currentVersionId).toBe(
|
|
499
|
-
result.formDefinitionVersion.id,
|
|
500
|
-
);
|
|
501
|
-
expect(result.template.currentVersionId).toBe(result.templateVersion.id);
|
|
502
|
-
|
|
503
|
-
const formVersions = [
|
|
504
|
-
...store(FormDefinitionVersionEntity).values(),
|
|
505
|
-
] as FormDefinitionVersionEntity[];
|
|
506
|
-
expect(formVersions).toHaveLength(1);
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
it('keeps both sides as drafts when publish is false', async (): Promise<void> => {
|
|
510
|
-
const { manager } = createInMemoryManager();
|
|
511
|
-
const service = createComposingService(manager);
|
|
512
|
-
|
|
513
|
-
const result = await service.composeApprovalTemplateWithForm(
|
|
514
|
-
{
|
|
515
|
-
category: null,
|
|
516
|
-
categoryId: null,
|
|
517
|
-
formDefinitionId: null,
|
|
518
|
-
formDescription: null,
|
|
519
|
-
formName: '請款表單',
|
|
520
|
-
initiatorPolicyCel: null,
|
|
521
|
-
notificationConfigJson: null,
|
|
522
|
-
publish: false,
|
|
523
|
-
schemaJson: JSON.stringify(SAMPLE_FORM_SCHEMA),
|
|
524
|
-
slaDefaultsJson: null,
|
|
525
|
-
templateDescription: null,
|
|
526
|
-
templateId: null,
|
|
527
|
-
templateName: '請款簽核',
|
|
528
|
-
uiSchemaJson: JSON.stringify(SAMPLE_FORM_UI_SCHEMA),
|
|
529
|
-
workflowDefinitionJson: JSON.stringify(VALID_WORKFLOW_DEFINITION),
|
|
530
|
-
},
|
|
531
|
-
'member-admin',
|
|
532
|
-
);
|
|
533
|
-
|
|
534
|
-
expect(result.published).toBe(false);
|
|
535
|
-
expect(result.formDefinitionVersion.status).toBe(
|
|
536
|
-
FormDefinitionVersionStatusEnum.DRAFT,
|
|
537
|
-
);
|
|
538
|
-
expect(result.templateVersion.status).toBe(
|
|
539
|
-
ApprovalTemplateVersionStatusEnum.DRAFT,
|
|
540
|
-
);
|
|
541
|
-
// Draft template binds the draft form version so condition fields resolve.
|
|
542
|
-
expect(result.templateVersion.formDefinitionVersionId).toBe(
|
|
543
|
-
result.formDefinitionVersion.id,
|
|
544
|
-
);
|
|
545
|
-
expect(result.formDefinition.currentVersionId).toBeNull();
|
|
546
|
-
expect(result.template.currentVersionId).toBeNull();
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
it('rolls back inside the single transaction when the workflow fails to lint', async (): Promise<void> => {
|
|
550
|
-
const { manager, store } = createInMemoryManager();
|
|
551
|
-
const service = createComposingService(manager);
|
|
552
|
-
|
|
553
|
-
await expect(
|
|
554
|
-
service.composeApprovalTemplateWithForm(
|
|
555
|
-
{
|
|
556
|
-
category: null,
|
|
557
|
-
categoryId: null,
|
|
558
|
-
formDefinitionId: null,
|
|
559
|
-
formDescription: null,
|
|
560
|
-
formName: '請款表單',
|
|
561
|
-
initiatorPolicyCel: null,
|
|
562
|
-
notificationConfigJson: null,
|
|
563
|
-
publish: true,
|
|
564
|
-
schemaJson: JSON.stringify(SAMPLE_FORM_SCHEMA),
|
|
565
|
-
slaDefaultsJson: null,
|
|
566
|
-
templateDescription: null,
|
|
567
|
-
templateId: null,
|
|
568
|
-
templateName: '請款簽核',
|
|
569
|
-
uiSchemaJson: JSON.stringify(SAMPLE_FORM_UI_SCHEMA),
|
|
570
|
-
// EMPTY workflow cannot reach an endEvent and must fail publish lint.
|
|
571
|
-
workflowDefinitionJson: JSON.stringify(EMPTY_WORKFLOW_DEFINITION),
|
|
572
|
-
},
|
|
573
|
-
'member-admin',
|
|
574
|
-
),
|
|
575
|
-
).rejects.toThrow('does not have a path to an endEvent');
|
|
576
|
-
|
|
577
|
-
// The single manager.transaction wraps every write, so a real DataSource
|
|
578
|
-
// would roll back the form rows created before the failing publish step.
|
|
579
|
-
expect(store(ApprovalTemplateEntity).size).toBeGreaterThanOrEqual(1);
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
function createApprovalTemplate(id: string): ApprovalTemplateEntity {
|
|
584
|
-
return Object.assign(new ApprovalTemplateEntity(), {
|
|
585
|
-
category: null,
|
|
586
|
-
categoryDetail: null,
|
|
587
|
-
categoryId: null,
|
|
588
|
-
createdAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
589
|
-
createdByMemberId: null,
|
|
590
|
-
currentVersionId: null,
|
|
591
|
-
deletedAt: null,
|
|
592
|
-
description: null,
|
|
593
|
-
id,
|
|
594
|
-
name: `簽核模板 ${id}`,
|
|
595
|
-
updatedAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
function createApprovalTemplateCategory(
|
|
600
|
-
id: string,
|
|
601
|
-
): ApprovalTemplateCategoryEntity {
|
|
602
|
-
return Object.assign(new ApprovalTemplateCategoryEntity(), {
|
|
603
|
-
createdAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
604
|
-
description: null,
|
|
605
|
-
id,
|
|
606
|
-
isActive: true,
|
|
607
|
-
name: '財務',
|
|
608
|
-
sortOrder: 0,
|
|
609
|
-
updatedAt: new Date('2026-05-10T00:00:00.000Z'),
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
function createRepository<
|
|
614
|
-
TEntity extends ObjectLiteral,
|
|
615
|
-
>(): Repository<TEntity> {
|
|
616
|
-
return {} as Repository<TEntity>;
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
const SAMPLE_FORM_SCHEMA = {
|
|
620
|
-
fields: [
|
|
621
|
-
{
|
|
622
|
-
fieldKey: 'amount',
|
|
623
|
-
label: '金額',
|
|
624
|
-
required: true,
|
|
625
|
-
type: 'number',
|
|
626
|
-
},
|
|
627
|
-
],
|
|
628
|
-
schemaVersion: 1,
|
|
629
|
-
};
|
|
630
|
-
|
|
631
|
-
const SAMPLE_FORM_UI_SCHEMA = {
|
|
632
|
-
layout: [{ fieldKey: 'amount', width: 'FULL' }],
|
|
633
|
-
schemaVersion: 1,
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
const VALID_WORKFLOW_DEFINITION = {
|
|
637
|
-
edges: [
|
|
638
|
-
{
|
|
639
|
-
data: {},
|
|
640
|
-
id: 'edge_start_task',
|
|
641
|
-
source: 'start',
|
|
642
|
-
target: 'task_manager',
|
|
643
|
-
type: 'smoothstep',
|
|
644
|
-
},
|
|
645
|
-
{
|
|
646
|
-
data: {},
|
|
647
|
-
id: 'edge_task_end',
|
|
648
|
-
source: 'task_manager',
|
|
649
|
-
target: 'end',
|
|
650
|
-
type: 'smoothstep',
|
|
651
|
-
},
|
|
652
|
-
],
|
|
653
|
-
meta: { schemaVersion: 1 },
|
|
654
|
-
nodes: [
|
|
655
|
-
{
|
|
656
|
-
data: { label: '開始' },
|
|
657
|
-
id: 'start',
|
|
658
|
-
position: { x: 80, y: 160 },
|
|
659
|
-
type: 'startEvent',
|
|
660
|
-
},
|
|
661
|
-
{
|
|
662
|
-
data: {
|
|
663
|
-
allowAddSigner: false,
|
|
664
|
-
allowReject: true,
|
|
665
|
-
allowTransfer: true,
|
|
666
|
-
approverResolver: {
|
|
667
|
-
baseFromInitiator: true,
|
|
668
|
-
levelsUp: 1,
|
|
669
|
-
type: 'ORG_MANAGER',
|
|
670
|
-
},
|
|
671
|
-
decisionPolicy: { type: 'SINGLE' },
|
|
672
|
-
label: '主管簽核',
|
|
673
|
-
returnBehavior: { allowReturn: true, allowedTargets: 'INITIATOR' },
|
|
674
|
-
},
|
|
675
|
-
id: 'task_manager',
|
|
676
|
-
position: { x: 300, y: 160 },
|
|
677
|
-
type: 'userTask',
|
|
678
|
-
},
|
|
679
|
-
{
|
|
680
|
-
data: { endState: 'APPROVED', label: '完成' },
|
|
681
|
-
id: 'end',
|
|
682
|
-
position: { x: 520, y: 160 },
|
|
683
|
-
type: 'endEvent',
|
|
684
|
-
},
|
|
685
|
-
],
|
|
686
|
-
};
|
|
687
|
-
|
|
688
|
-
function createComposingService(manager: EntityManager): TemplateService {
|
|
689
|
-
const formService = new FormService(
|
|
690
|
-
{} as Repository<FormDefinitionEntity>,
|
|
691
|
-
{} as Repository<FormDefinitionVersionEntity>,
|
|
692
|
-
);
|
|
693
|
-
|
|
694
|
-
return new TemplateService(
|
|
695
|
-
{ manager } as unknown as Repository<ApprovalTemplateEntity>,
|
|
696
|
-
{} as Repository<ApprovalTemplateCategoryEntity>,
|
|
697
|
-
{} as Repository<ApprovalTemplateVersionEntity>,
|
|
698
|
-
{} as Repository<FormDefinitionVersionEntity>,
|
|
699
|
-
new ConditionService(),
|
|
700
|
-
formService,
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
/**
|
|
705
|
-
* Minimal in-memory EntityManager that backs the composed-mutation tests. It
|
|
706
|
-
* supports the create/find/update surface the compose flow exercises and runs
|
|
707
|
-
* `transaction(op)` by invoking `op` with itself, mirroring a single DB
|
|
708
|
-
* transaction boundary.
|
|
709
|
-
*/
|
|
710
|
-
function createInMemoryManager(): {
|
|
711
|
-
readonly manager: EntityManager;
|
|
712
|
-
readonly store: (entity: unknown) => Map<string, ObjectLiteral>;
|
|
713
|
-
} {
|
|
714
|
-
const stores = new Map<unknown, Map<string, ObjectLiteral>>();
|
|
715
|
-
let sequence = 0;
|
|
716
|
-
|
|
717
|
-
const storeFor = (entity: unknown): Map<string, ObjectLiteral> => {
|
|
718
|
-
const existing = stores.get(entity);
|
|
719
|
-
|
|
720
|
-
if (existing) {
|
|
721
|
-
return existing;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
const created = new Map<string, ObjectLiteral>();
|
|
725
|
-
stores.set(entity, created);
|
|
726
|
-
|
|
727
|
-
return created;
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
const matches = (
|
|
731
|
-
row: ObjectLiteral,
|
|
732
|
-
where: Readonly<Record<string, unknown>>,
|
|
733
|
-
): boolean =>
|
|
734
|
-
Object.entries(where).every(([key, value]) => {
|
|
735
|
-
if (key === 'relations') {
|
|
736
|
-
return true;
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
if (value !== null && typeof value === 'object' && '_type' in value) {
|
|
740
|
-
// Treat any FindOperator (e.g. IsNull()) as a null match.
|
|
741
|
-
return row[key] === null || row[key] === undefined;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
return row[key] === value;
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
const makeRepository = (
|
|
748
|
-
entity: new () => ObjectLiteral,
|
|
749
|
-
): Record<string, unknown> => {
|
|
750
|
-
const store = storeFor(entity);
|
|
751
|
-
|
|
752
|
-
return {
|
|
753
|
-
create: (value: ObjectLiteral): ObjectLiteral =>
|
|
754
|
-
Object.assign(new entity(), value),
|
|
755
|
-
findOne: ({
|
|
756
|
-
where,
|
|
757
|
-
}: {
|
|
758
|
-
readonly where:
|
|
759
|
-
| Readonly<Record<string, unknown>>
|
|
760
|
-
| readonly Readonly<Record<string, unknown>>[];
|
|
761
|
-
}): Promise<ObjectLiteral | null> => {
|
|
762
|
-
const clauses = Array.isArray(where) ? where : [where];
|
|
763
|
-
|
|
764
|
-
for (const row of store.values()) {
|
|
765
|
-
if (clauses.some((clause) => matches(row, clause))) {
|
|
766
|
-
return Promise.resolve(row);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
return Promise.resolve(null);
|
|
771
|
-
},
|
|
772
|
-
findOneByOrFail: (
|
|
773
|
-
where: Readonly<Record<string, unknown>>,
|
|
774
|
-
): Promise<ObjectLiteral> => {
|
|
775
|
-
for (const row of store.values()) {
|
|
776
|
-
if (matches(row, where)) {
|
|
777
|
-
return Promise.resolve(row);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
return Promise.reject(new Error(`${entity.name} was not found`));
|
|
782
|
-
},
|
|
783
|
-
merge: (target: ObjectLiteral, patch: ObjectLiteral): ObjectLiteral =>
|
|
784
|
-
Object.assign(target, patch),
|
|
785
|
-
save: (value: ObjectLiteral): Promise<ObjectLiteral> => {
|
|
786
|
-
if (!value.id) {
|
|
787
|
-
sequence += 1;
|
|
788
|
-
value.id = `${entity.name}-${sequence}`;
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
store.set(value.id as string, value);
|
|
792
|
-
|
|
793
|
-
return Promise.resolve(value);
|
|
794
|
-
},
|
|
795
|
-
update: (
|
|
796
|
-
criteria: Readonly<Record<string, unknown>>,
|
|
797
|
-
patch: ObjectLiteral,
|
|
798
|
-
): Promise<void> => {
|
|
799
|
-
for (const row of store.values()) {
|
|
800
|
-
if (matches(row, criteria)) {
|
|
801
|
-
Object.assign(row, patch);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
return Promise.resolve();
|
|
806
|
-
},
|
|
807
|
-
};
|
|
808
|
-
};
|
|
809
|
-
|
|
810
|
-
const manager = {
|
|
811
|
-
getRepository: (entity: new () => ObjectLiteral): Record<string, unknown> =>
|
|
812
|
-
makeRepository(entity),
|
|
813
|
-
transaction: <TResult>(
|
|
814
|
-
operation: (manager: EntityManager) => Promise<TResult>,
|
|
815
|
-
): Promise<TResult> => operation(manager as unknown as EntityManager),
|
|
816
|
-
} as unknown as EntityManager;
|
|
817
|
-
|
|
818
|
-
return {
|
|
819
|
-
manager,
|
|
820
|
-
store: (entity: unknown): Map<string, ObjectLiteral> => storeFor(entity),
|
|
821
|
-
};
|
|
822
|
-
}
|