@rytass/bpm-core-nestjs-module 0.4.0 → 0.5.0
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 +27 -0
- package/eslint.config.mjs +20 -0
- package/jest.config.cts +15 -0
- package/package.json +2 -2
- package/project.json +58 -0
- package/src/lib/attachment/attachment-options.spec.ts +45 -0
- package/src/lib/attachment/attachment-options.ts +130 -0
- package/src/lib/attachment/attachment-storage.provider.spec.ts +79 -0
- package/src/lib/attachment/attachment-storage.provider.ts +60 -0
- package/src/lib/attachment/{attachment-storage.token.d.ts → attachment-storage.token.ts} +3 -1
- package/src/lib/attachment/attachment.controller.ts +39 -0
- package/src/lib/attachment/attachment.entity.ts +59 -0
- package/src/lib/attachment/attachment.module.ts +149 -0
- package/src/lib/attachment/attachment.mutations.ts +22 -0
- package/src/lib/attachment/attachment.queries.ts +65 -0
- package/src/lib/attachment/attachment.service.spec.ts +319 -0
- package/src/lib/attachment/attachment.service.ts +477 -0
- package/src/lib/attachment/dto/upload-attachment.input.ts +60 -0
- package/src/lib/bpm/bpm-root.module.spec.ts +138 -0
- package/src/lib/bpm/bpm-root.module.ts +320 -0
- package/src/lib/bpm-auth/bpm-auth-context.extractor.ts +106 -0
- package/src/lib/bpm-auth/bpm-auth-context.ts +40 -0
- package/src/lib/bpm-auth/bpm-auth.authorization.ts +80 -0
- package/src/lib/bpm-auth/bpm-auth.decorators.ts +19 -0
- package/src/lib/bpm-auth/bpm-auth.guard.ts +31 -0
- package/src/lib/bpm-auth/bpm-auth.module.spec.ts +106 -0
- package/src/lib/bpm-auth/bpm-auth.module.ts +69 -0
- package/src/lib/bpm-auth/bpm-auth.options.ts +21 -0
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.ts +55 -0
- package/src/lib/common/filters/all-exceptions.filter.ts +138 -0
- package/src/lib/common/iso-duration.ts +31 -0
- package/src/lib/condition/condition.module.ts +8 -0
- package/src/lib/condition/condition.service.spec.ts +50 -0
- package/src/lib/condition/condition.service.ts +141 -0
- package/src/lib/database/data-source.ts +7 -0
- package/src/lib/database/migration-runner.ts +26 -0
- package/src/lib/database/reconcile-legacy-migrations.ts +87 -0
- package/src/lib/database/typeorm.config.ts +217 -0
- package/src/lib/delegation/delegation-rule.entity.ts +84 -0
- package/src/lib/delegation/delegation.enums.ts +21 -0
- package/src/lib/delegation/delegation.module.ts +14 -0
- package/src/lib/delegation/delegation.mutations.ts +92 -0
- package/src/lib/delegation/delegation.queries.ts +111 -0
- package/src/lib/delegation/delegation.service.spec.ts +295 -0
- package/src/lib/delegation/delegation.service.ts +482 -0
- package/src/lib/delegation/dto/delegation-rule.input.ts +125 -0
- package/src/lib/form/dto/form-definition.input.ts +90 -0
- package/src/lib/form/form-definition-version.entity.ts +66 -0
- package/src/lib/form/form-definition.entity.ts +54 -0
- package/src/lib/form/form-schema-lint.object.ts +10 -0
- package/src/lib/form/form-schema.validator.spec.ts +180 -0
- package/src/lib/form/form-schema.validator.ts +538 -0
- package/src/lib/form/form.enums.ts +20 -0
- package/src/lib/form/form.module.ts +19 -0
- package/src/lib/form/form.mutations.ts +73 -0
- package/src/lib/form/form.queries.ts +72 -0
- package/src/lib/form/form.service.spec.ts +371 -0
- package/src/lib/form/form.service.ts +607 -0
- package/src/lib/identity/identity-options.ts +41 -0
- package/src/lib/identity/identity.module.ts +96 -0
- package/src/lib/identity/identity.queries.ts +61 -0
- package/src/lib/identity/identity.service.spec.ts +328 -0
- package/src/lib/identity/identity.service.ts +277 -0
- package/src/lib/identity/member-base.adapter.spec.ts +122 -0
- package/src/lib/identity/member-base.adapter.ts +302 -0
- package/src/lib/identity/member-metadata-cache.entity.ts +27 -0
- package/src/lib/identity/{member-not-found.exception.d.ts → member-not-found.exception.ts} +8 -3
- package/src/lib/identity/member-profile.object.ts +28 -0
- package/src/lib/identity/member-resolver.interface.ts +140 -0
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.ts +14 -0
- package/src/lib/migrations/{0000000001000-identity-organization-foundation.js → 0000000001000-identity-organization-foundation.ts} +38 -29
- package/src/lib/migrations/{0000000002000-form-builder-foundation.js → 0000000002000-form-builder-foundation.ts} +22 -21
- package/src/lib/migrations/{0000000003000-approval-template-foundation.js → 0000000003000-approval-template-foundation.ts} +24 -21
- package/src/lib/migrations/{0000000004000-workflow-engine-foundation.js → 0000000004000-workflow-engine-foundation.ts} +46 -34
- package/src/lib/migrations/{0000000005000-delegation-rules.js → 0000000005000-delegation-rules.ts} +20 -19
- package/src/lib/migrations/{0000000006000-notifications-sla.js → 0000000006000-notifications-sla.ts} +26 -23
- package/src/lib/migrations/{0000000007000-signatures-attachments.js → 0000000007000-signatures-attachments.ts} +28 -27
- package/src/lib/migrations/{0000000008000-approval-template-categories.js → 0000000008000-approval-template-categories.ts} +28 -25
- package/src/lib/migrations/{0000000009000-task-candidates.js → 0000000009000-task-candidates.ts} +26 -23
- package/src/lib/migrations/{0000000010000-notification-delivery-state.js → 0000000010000-notification-delivery-state.ts} +16 -17
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.ts +19 -0
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.ts +22 -0
- package/src/lib/migrations/0000000013000-workflow-query-indexes.ts +113 -0
- package/src/lib/migrations/0000000014000-notification-resolution.ts +29 -0
- package/src/lib/migrations/{0000000015000-backfill-stale-notification-resolution.js → 0000000015000-backfill-stale-notification-resolution.ts} +15 -16
- package/src/lib/migrations/{0000000016000-archive-parallel-form-drafts.js → 0000000016000-archive-parallel-form-drafts.ts} +15 -16
- package/src/lib/migrations/{0000000017000-adhoc-directives.js → 0000000017000-adhoc-directives.ts} +18 -19
- package/src/lib/migrations/index.ts +59 -0
- package/src/lib/notification/dto/notification-preference.input.ts +46 -0
- package/src/lib/notification/notification-delivery-scheduler.service.ts +69 -0
- package/src/lib/notification/notification-delivery.service.spec.ts +315 -0
- package/src/lib/notification/notification-delivery.service.ts +339 -0
- package/src/lib/notification/notification-dispatcher.token.ts +13 -0
- package/src/lib/notification/notification-options.module.ts +67 -0
- package/src/lib/notification/notification-options.spec.ts +93 -0
- package/src/lib/notification/notification-options.ts +452 -0
- package/src/lib/notification/notification-preference.entity.ts +35 -0
- package/src/lib/notification/notification-sla-scheduler.service.ts +66 -0
- package/src/lib/notification/notification-template.spec.ts +33 -0
- package/src/lib/notification/notification-template.ts +97 -0
- package/src/lib/notification/notification.entity.ts +129 -0
- package/src/lib/notification/notification.enums.ts +64 -0
- package/src/lib/notification/notification.module.ts +37 -0
- package/src/lib/notification/notification.mutations.ts +47 -0
- package/src/lib/notification/notification.queries.ts +64 -0
- package/src/lib/notification/notification.service.spec.ts +412 -0
- package/src/lib/notification/notification.service.ts +1129 -0
- package/src/lib/organization/dto/manager-resolution.input.ts +91 -0
- package/src/lib/organization/dto/membership.input.ts +77 -0
- package/src/lib/organization/dto/org-unit.input.ts +96 -0
- package/src/lib/organization/dto/position.input.ts +50 -0
- package/src/lib/organization/json-metadata.ts +15 -0
- package/src/lib/organization/manager-resolution.entity.ts +44 -0
- package/src/lib/organization/membership.entity.ts +50 -0
- package/src/lib/organization/org-unit-tree-commit-result.object.ts +8 -0
- package/src/lib/organization/org-unit.entity.ts +53 -0
- package/src/lib/organization/organization-summary.object.ts +16 -0
- package/src/lib/organization/organization.enums.ts +19 -0
- package/src/lib/organization/organization.module.ts +27 -0
- package/src/lib/organization/organization.mutations.ts +115 -0
- package/src/lib/organization/organization.queries.ts +191 -0
- package/src/lib/organization/organization.service.spec.ts +835 -0
- package/src/lib/organization/organization.service.ts +1245 -0
- package/src/lib/organization/position.entity.ts +39 -0
- package/src/lib/organization/resolved-manager.object.ts +10 -0
- package/src/lib/signature/signature-options.spec.ts +60 -0
- package/src/lib/signature/signature-options.ts +120 -0
- package/src/lib/signature/signature-verification.object.ts +16 -0
- package/src/lib/signature/signature.entity.ts +62 -0
- package/src/lib/signature/signature.module.ts +80 -0
- package/src/lib/signature/signature.queries.ts +37 -0
- package/src/lib/signature/signature.service.spec.ts +134 -0
- package/src/lib/signature/signature.service.ts +205 -0
- package/src/lib/template/approval-template-category.entity.ts +40 -0
- package/src/lib/template/approval-template-version.entity.ts +82 -0
- package/src/lib/template/approval-template.entity.ts +64 -0
- package/src/lib/template/compose-approval-template.object.ts +23 -0
- package/src/lib/template/compose-template.mutations.ts +22 -0
- package/src/lib/template/dto/approval-template.input.ts +147 -0
- package/src/lib/template/dto/compose-approval-template.input.ts +80 -0
- package/src/lib/template/template.enums.ts +30 -0
- package/src/lib/template/template.module.ts +33 -0
- package/src/lib/template/template.mutations.ts +106 -0
- package/src/lib/template/template.queries.ts +119 -0
- package/src/lib/template/template.service.spec.ts +822 -0
- package/src/lib/template/template.service.ts +1082 -0
- package/src/lib/template/workflow-definition.validator.spec.ts +595 -0
- package/src/lib/template/workflow-definition.validator.ts +539 -0
- package/src/lib/testing/cel-js.jest.ts +46 -0
- package/src/lib/workflow-engine/activity-log.entity.ts +48 -0
- package/src/lib/workflow-engine/adhoc-directive.entity.ts +90 -0
- package/src/lib/workflow-engine/adhoc.enums.ts +42 -0
- package/src/lib/workflow-engine/approval-instance-page-info.object.ts +22 -0
- package/src/lib/workflow-engine/approval-instance.entity.ts +86 -0
- package/src/lib/workflow-engine/dto/adhoc-notification.input.ts +18 -0
- package/src/lib/workflow-engine/dto/adhoc-target.input.ts +52 -0
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.ts +18 -0
- package/src/lib/workflow-engine/dto/decide-task.input.ts +33 -0
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.ts +22 -0
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.ts +22 -0
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.ts +27 -0
- package/src/lib/workflow-engine/task-candidate.entity.ts +56 -0
- package/src/lib/workflow-engine/task-decision.entity.ts +43 -0
- package/src/lib/workflow-engine/task.entity.ts +102 -0
- package/src/lib/workflow-engine/workflow-condition-evaluator.ts +168 -0
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.ts +22 -0
- package/src/lib/workflow-engine/workflow-dry-run.object.ts +58 -0
- package/src/lib/workflow-engine/workflow-engine.enums.ts +102 -0
- package/src/lib/workflow-engine/workflow-engine.module.ts +77 -0
- package/src/lib/workflow-engine/workflow-engine.mutations.ts +193 -0
- package/src/lib/workflow-engine/workflow-engine.queries.ts +241 -0
- package/src/lib/workflow-engine/workflow-engine.service.spec.ts +3345 -0
- package/src/lib/workflow-engine/workflow-engine.service.ts +6022 -0
- package/src/lib/workflow-engine/{workflow-engine.tokens.d.ts → workflow-engine.tokens.ts} +9 -3
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.ts +69 -0
- package/src/lib/workflow-engine/workflow-token.entity.ts +40 -0
- package/tsconfig.json +24 -0
- package/tsconfig.lib.json +16 -0
- package/tsconfig.spec.json +16 -0
- package/src/index.js +0 -18
- package/src/index.js.map +0 -1
- package/src/lib/attachment/attachment-options.d.ts +0 -44
- package/src/lib/attachment/attachment-options.js +0 -62
- package/src/lib/attachment/attachment-options.js.map +0 -1
- package/src/lib/attachment/attachment-storage.provider.d.ts +0 -4
- package/src/lib/attachment/attachment-storage.provider.js +0 -35
- package/src/lib/attachment/attachment-storage.provider.js.map +0 -1
- package/src/lib/attachment/attachment-storage.token.js +0 -5
- package/src/lib/attachment/attachment-storage.token.js.map +0 -1
- package/src/lib/attachment/attachment.controller.d.ts +0 -8
- package/src/lib/attachment/attachment.controller.js +0 -38
- package/src/lib/attachment/attachment.controller.js.map +0 -1
- package/src/lib/attachment/attachment.entity.d.ts +0 -14
- package/src/lib/attachment/attachment.entity.js +0 -74
- package/src/lib/attachment/attachment.entity.js.map +0 -1
- package/src/lib/attachment/attachment.module.d.ts +0 -27
- package/src/lib/attachment/attachment.module.js +0 -103
- package/src/lib/attachment/attachment.module.js.map +0 -1
- package/src/lib/attachment/attachment.mutations.d.ts +0 -8
- package/src/lib/attachment/attachment.mutations.js +0 -35
- package/src/lib/attachment/attachment.mutations.js.map +0 -1
- package/src/lib/attachment/attachment.queries.d.ts +0 -9
- package/src/lib/attachment/attachment.queries.js +0 -78
- package/src/lib/attachment/attachment.queries.js.map +0 -1
- package/src/lib/attachment/attachment.service.d.ts +0 -49
- package/src/lib/attachment/attachment.service.js +0 -276
- package/src/lib/attachment/attachment.service.js.map +0 -1
- package/src/lib/attachment/dto/upload-attachment.input.d.ts +0 -11
- package/src/lib/attachment/dto/upload-attachment.input.js +0 -68
- package/src/lib/attachment/dto/upload-attachment.input.js.map +0 -1
- package/src/lib/attachment/index.js +0 -9
- package/src/lib/attachment/index.js.map +0 -1
- package/src/lib/bpm/bpm-root.module.d.ts +0 -155
- package/src/lib/bpm/bpm-root.module.js +0 -170
- package/src/lib/bpm/bpm-root.module.js.map +0 -1
- package/src/lib/bpm/index.js +0 -5
- package/src/lib/bpm/index.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth-context.d.ts +0 -24
- package/src/lib/bpm-auth/bpm-auth-context.extractor.d.ts +0 -4
- package/src/lib/bpm-auth/bpm-auth-context.extractor.js +0 -69
- package/src/lib/bpm-auth/bpm-auth-context.extractor.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth-context.js +0 -15
- package/src/lib/bpm-auth/bpm-auth-context.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth.authorization.d.ts +0 -12
- package/src/lib/bpm-auth/bpm-auth.authorization.js +0 -67
- package/src/lib/bpm-auth/bpm-auth.authorization.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth.decorators.d.ts +0 -3
- package/src/lib/bpm-auth/bpm-auth.decorators.js +0 -11
- package/src/lib/bpm-auth/bpm-auth.decorators.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth.guard.d.ts +0 -7
- package/src/lib/bpm-auth/bpm-auth.guard.js +0 -24
- package/src/lib/bpm-auth/bpm-auth.guard.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth.module.d.ts +0 -6
- package/src/lib/bpm-auth/bpm-auth.module.js +0 -69
- package/src/lib/bpm-auth/bpm-auth.module.js.map +0 -1
- package/src/lib/bpm-auth/bpm-auth.options.d.ts +0 -11
- package/src/lib/bpm-auth/bpm-auth.options.js +0 -3
- package/src/lib/bpm-auth/bpm-auth.options.js.map +0 -1
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.d.ts +0 -10
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.js +0 -40
- package/src/lib/bpm-auth/configurable-bpm-auth-context.accessor.js.map +0 -1
- package/src/lib/bpm-auth/index.js +0 -10
- package/src/lib/bpm-auth/index.js.map +0 -1
- package/src/lib/common/filters/all-exceptions.filter.d.ts +0 -25
- package/src/lib/common/filters/all-exceptions.filter.js +0 -93
- package/src/lib/common/filters/all-exceptions.filter.js.map +0 -1
- package/src/lib/common/index.js +0 -5
- package/src/lib/common/index.js.map +0 -1
- package/src/lib/common/iso-duration.d.ts +0 -1
- package/src/lib/common/iso-duration.js +0 -27
- package/src/lib/common/iso-duration.js.map +0 -1
- package/src/lib/condition/condition.module.d.ts +0 -2
- package/src/lib/condition/condition.module.js +0 -16
- package/src/lib/condition/condition.module.js.map +0 -1
- package/src/lib/condition/condition.service.d.ts +0 -16
- package/src/lib/condition/condition.service.js +0 -82
- package/src/lib/condition/condition.service.js.map +0 -1
- package/src/lib/condition/index.js +0 -6
- package/src/lib/condition/index.js.map +0 -1
- package/src/lib/database/data-source.d.ts +0 -4
- package/src/lib/database/data-source.js +0 -7
- package/src/lib/database/data-source.js.map +0 -1
- package/src/lib/database/index.js +0 -6
- package/src/lib/database/index.js.map +0 -1
- package/src/lib/database/migration-runner.d.ts +0 -1
- package/src/lib/database/migration-runner.js +0 -25
- package/src/lib/database/migration-runner.js.map +0 -1
- package/src/lib/database/reconcile-legacy-migrations.d.ts +0 -13
- package/src/lib/database/reconcile-legacy-migrations.js +0 -70
- package/src/lib/database/reconcile-legacy-migrations.js.map +0 -1
- package/src/lib/database/typeorm.config.d.ts +0 -14
- package/src/lib/database/typeorm.config.js +0 -135
- package/src/lib/database/typeorm.config.js.map +0 -1
- package/src/lib/delegation/delegation-rule.entity.d.ts +0 -19
- package/src/lib/delegation/delegation-rule.entity.js +0 -99
- package/src/lib/delegation/delegation-rule.entity.js.map +0 -1
- package/src/lib/delegation/delegation.enums.d.ts +0 -10
- package/src/lib/delegation/delegation.enums.js +0 -23
- package/src/lib/delegation/delegation.enums.js.map +0 -1
- package/src/lib/delegation/delegation.module.d.ts +0 -2
- package/src/lib/delegation/delegation.module.js +0 -22
- package/src/lib/delegation/delegation.module.js.map +0 -1
- package/src/lib/delegation/delegation.mutations.d.ts +0 -11
- package/src/lib/delegation/delegation.mutations.js +0 -87
- package/src/lib/delegation/delegation.mutations.js.map +0 -1
- package/src/lib/delegation/delegation.queries.d.ts +0 -10
- package/src/lib/delegation/delegation.queries.js +0 -91
- package/src/lib/delegation/delegation.queries.js.map +0 -1
- package/src/lib/delegation/delegation.service.d.ts +0 -56
- package/src/lib/delegation/delegation.service.js +0 -268
- package/src/lib/delegation/delegation.service.js.map +0 -1
- package/src/lib/delegation/dto/delegation-rule.input.d.ts +0 -24
- package/src/lib/delegation/dto/delegation-rule.input.js +0 -143
- package/src/lib/delegation/dto/delegation-rule.input.js.map +0 -1
- package/src/lib/delegation/index.js +0 -9
- package/src/lib/delegation/index.js.map +0 -1
- package/src/lib/form/dto/form-definition.input.d.ts +0 -26
- package/src/lib/form/dto/form-definition.input.js +0 -126
- package/src/lib/form/dto/form-definition.input.js.map +0 -1
- package/src/lib/form/form-definition-version.entity.d.ts +0 -17
- package/src/lib/form/form-definition-version.entity.js +0 -84
- package/src/lib/form/form-definition-version.entity.js.map +0 -1
- package/src/lib/form/form-definition.entity.d.ts +0 -13
- package/src/lib/form/form-definition.entity.js +0 -66
- package/src/lib/form/form-definition.entity.js.map +0 -1
- package/src/lib/form/form-schema-lint.object.d.ts +0 -4
- package/src/lib/form/form-schema-lint.object.js +0 -20
- package/src/lib/form/form-schema-lint.object.js.map +0 -1
- package/src/lib/form/form-schema.validator.d.ts +0 -13
- package/src/lib/form/form-schema.validator.js +0 -354
- package/src/lib/form/form-schema.validator.js.map +0 -1
- package/src/lib/form/form.enums.d.ts +0 -9
- package/src/lib/form/form.enums.js +0 -22
- package/src/lib/form/form.enums.js.map +0 -1
- package/src/lib/form/form.module.d.ts +0 -2
- package/src/lib/form/form.module.js +0 -27
- package/src/lib/form/form.module.js.map +0 -1
- package/src/lib/form/form.mutations.d.ts +0 -14
- package/src/lib/form/form.mutations.js +0 -89
- package/src/lib/form/form.mutations.js.map +0 -1
- package/src/lib/form/form.queries.d.ts +0 -16
- package/src/lib/form/form.queries.js +0 -96
- package/src/lib/form/form.queries.js.map +0 -1
- package/src/lib/form/form.service.d.ts +0 -49
- package/src/lib/form/form.service.js +0 -346
- package/src/lib/form/form.service.js.map +0 -1
- package/src/lib/form/index.js +0 -12
- package/src/lib/form/index.js.map +0 -1
- package/src/lib/identity/identity-options.d.ts +0 -13
- package/src/lib/identity/identity-options.js +0 -20
- package/src/lib/identity/identity-options.js.map +0 -1
- package/src/lib/identity/identity.module.d.ts +0 -17
- package/src/lib/identity/identity.module.js +0 -65
- package/src/lib/identity/identity.module.js.map +0 -1
- package/src/lib/identity/identity.queries.d.ts +0 -12
- package/src/lib/identity/identity.queries.js +0 -79
- package/src/lib/identity/identity.queries.js.map +0 -1
- package/src/lib/identity/identity.service.d.ts +0 -22
- package/src/lib/identity/identity.service.js +0 -141
- package/src/lib/identity/identity.service.js.map +0 -1
- package/src/lib/identity/index.js +0 -8
- package/src/lib/identity/index.js.map +0 -1
- package/src/lib/identity/member-base.adapter.d.ts +0 -95
- package/src/lib/identity/member-base.adapter.js +0 -137
- package/src/lib/identity/member-base.adapter.js.map +0 -1
- package/src/lib/identity/member-metadata-cache.entity.d.ts +0 -8
- package/src/lib/identity/member-metadata-cache.entity.js +0 -39
- package/src/lib/identity/member-metadata-cache.entity.js.map +0 -1
- package/src/lib/identity/member-not-found.exception.js +0 -26
- package/src/lib/identity/member-not-found.exception.js.map +0 -1
- package/src/lib/identity/member-profile.object.d.ts +0 -8
- package/src/lib/identity/member-profile.object.js +0 -37
- package/src/lib/identity/member-profile.object.js.map +0 -1
- package/src/lib/identity/member-resolver.interface.d.ts +0 -79
- package/src/lib/identity/member-resolver.interface.js +0 -19
- package/src/lib/identity/member-resolver.interface.js.map +0 -1
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.d.ts +0 -6
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.js +0 -17
- package/src/lib/migrations/0000000000001-enable-postgres-extensions.js.map +0 -1
- package/src/lib/migrations/0000000001000-identity-organization-foundation.d.ts +0 -6
- package/src/lib/migrations/0000000001000-identity-organization-foundation.js.map +0 -1
- package/src/lib/migrations/0000000002000-form-builder-foundation.d.ts +0 -6
- package/src/lib/migrations/0000000002000-form-builder-foundation.js.map +0 -1
- package/src/lib/migrations/0000000003000-approval-template-foundation.d.ts +0 -6
- package/src/lib/migrations/0000000003000-approval-template-foundation.js.map +0 -1
- package/src/lib/migrations/0000000004000-workflow-engine-foundation.d.ts +0 -6
- package/src/lib/migrations/0000000004000-workflow-engine-foundation.js.map +0 -1
- package/src/lib/migrations/0000000005000-delegation-rules.d.ts +0 -6
- package/src/lib/migrations/0000000005000-delegation-rules.js.map +0 -1
- package/src/lib/migrations/0000000006000-notifications-sla.d.ts +0 -6
- package/src/lib/migrations/0000000006000-notifications-sla.js.map +0 -1
- package/src/lib/migrations/0000000007000-signatures-attachments.d.ts +0 -6
- package/src/lib/migrations/0000000007000-signatures-attachments.js.map +0 -1
- package/src/lib/migrations/0000000008000-approval-template-categories.d.ts +0 -6
- package/src/lib/migrations/0000000008000-approval-template-categories.js.map +0 -1
- package/src/lib/migrations/0000000009000-task-candidates.d.ts +0 -6
- package/src/lib/migrations/0000000009000-task-candidates.js.map +0 -1
- package/src/lib/migrations/0000000010000-notification-delivery-state.d.ts +0 -6
- package/src/lib/migrations/0000000010000-notification-delivery-state.js.map +0 -1
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.d.ts +0 -6
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.js +0 -22
- package/src/lib/migrations/0000000011000-remove-attachment-encryption-key.js.map +0 -1
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.d.ts +0 -6
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.js +0 -21
- package/src/lib/migrations/0000000012000-notification-sla-idempotency.js.map +0 -1
- package/src/lib/migrations/0000000013000-workflow-query-indexes.d.ts +0 -6
- package/src/lib/migrations/0000000013000-workflow-query-indexes.js +0 -80
- package/src/lib/migrations/0000000013000-workflow-query-indexes.js.map +0 -1
- package/src/lib/migrations/0000000014000-notification-resolution.d.ts +0 -6
- package/src/lib/migrations/0000000014000-notification-resolution.js +0 -30
- package/src/lib/migrations/0000000014000-notification-resolution.js.map +0 -1
- package/src/lib/migrations/0000000015000-backfill-stale-notification-resolution.d.ts +0 -15
- package/src/lib/migrations/0000000015000-backfill-stale-notification-resolution.js.map +0 -1
- package/src/lib/migrations/0000000016000-archive-parallel-form-drafts.d.ts +0 -15
- package/src/lib/migrations/0000000016000-archive-parallel-form-drafts.js.map +0 -1
- package/src/lib/migrations/0000000017000-adhoc-directives.d.ts +0 -6
- package/src/lib/migrations/0000000017000-adhoc-directives.js.map +0 -1
- package/src/lib/migrations/index.d.ts +0 -20
- package/src/lib/migrations/index.js +0 -61
- package/src/lib/migrations/index.js.map +0 -1
- package/src/lib/notification/dto/notification-preference.input.d.ts +0 -9
- package/src/lib/notification/dto/notification-preference.input.js +0 -53
- package/src/lib/notification/dto/notification-preference.input.js.map +0 -1
- package/src/lib/notification/index.js +0 -11
- package/src/lib/notification/index.js.map +0 -1
- package/src/lib/notification/notification-delivery-scheduler.service.d.ts +0 -13
- package/src/lib/notification/notification-delivery-scheduler.service.js +0 -53
- package/src/lib/notification/notification-delivery-scheduler.service.js.map +0 -1
- package/src/lib/notification/notification-delivery.service.d.ts +0 -23
- package/src/lib/notification/notification-delivery.service.js +0 -245
- package/src/lib/notification/notification-delivery.service.js.map +0 -1
- package/src/lib/notification/notification-dispatcher.token.d.ts +0 -7
- package/src/lib/notification/notification-dispatcher.token.js +0 -5
- package/src/lib/notification/notification-dispatcher.token.js.map +0 -1
- package/src/lib/notification/notification-options.d.ts +0 -215
- package/src/lib/notification/notification-options.js +0 -128
- package/src/lib/notification/notification-options.js.map +0 -1
- package/src/lib/notification/notification-options.module.d.ts +0 -23
- package/src/lib/notification/notification-options.module.js +0 -41
- package/src/lib/notification/notification-options.module.js.map +0 -1
- package/src/lib/notification/notification-preference.entity.d.ts +0 -10
- package/src/lib/notification/notification-preference.entity.js +0 -50
- package/src/lib/notification/notification-preference.entity.js.map +0 -1
- package/src/lib/notification/notification-sla-scheduler.service.d.ts +0 -13
- package/src/lib/notification/notification-sla-scheduler.service.js +0 -51
- package/src/lib/notification/notification-sla-scheduler.service.js.map +0 -1
- package/src/lib/notification/notification-template.d.ts +0 -13
- package/src/lib/notification/notification-template.js +0 -61
- package/src/lib/notification/notification-template.js.map +0 -1
- package/src/lib/notification/notification.entity.d.ts +0 -31
- package/src/lib/notification/notification.entity.js +0 -149
- package/src/lib/notification/notification.entity.js.map +0 -1
- package/src/lib/notification/notification.enums.d.ts +0 -38
- package/src/lib/notification/notification.enums.js +0 -63
- package/src/lib/notification/notification.enums.js.map +0 -1
- package/src/lib/notification/notification.module.d.ts +0 -2
- package/src/lib/notification/notification.module.js +0 -45
- package/src/lib/notification/notification.module.js.map +0 -1
- package/src/lib/notification/notification.mutations.d.ts +0 -11
- package/src/lib/notification/notification.mutations.js +0 -64
- package/src/lib/notification/notification.mutations.js.map +0 -1
- package/src/lib/notification/notification.queries.d.ts +0 -11
- package/src/lib/notification/notification.queries.js +0 -77
- package/src/lib/notification/notification.queries.js.map +0 -1
- package/src/lib/notification/notification.service.d.ts +0 -121
- package/src/lib/notification/notification.service.js +0 -713
- package/src/lib/notification/notification.service.js.map +0 -1
- package/src/lib/organization/dto/manager-resolution.input.d.ts +0 -18
- package/src/lib/organization/dto/manager-resolution.input.js +0 -107
- package/src/lib/organization/dto/manager-resolution.input.js.map +0 -1
- package/src/lib/organization/dto/membership.input.d.ts +0 -16
- package/src/lib/organization/dto/membership.input.js +0 -99
- package/src/lib/organization/dto/membership.input.js.map +0 -1
- package/src/lib/organization/dto/org-unit.input.d.ts +0 -24
- package/src/lib/organization/dto/org-unit.input.js +0 -119
- package/src/lib/organization/dto/org-unit.input.js.map +0 -1
- package/src/lib/organization/dto/position.input.d.ts +0 -13
- package/src/lib/organization/dto/position.input.js +0 -70
- package/src/lib/organization/dto/position.input.js.map +0 -1
- package/src/lib/organization/index.js +0 -16
- package/src/lib/organization/index.js.map +0 -1
- package/src/lib/organization/json-metadata.d.ts +0 -1
- package/src/lib/organization/json-metadata.js +0 -14
- package/src/lib/organization/json-metadata.js.map +0 -1
- package/src/lib/organization/manager-resolution.entity.d.ts +0 -11
- package/src/lib/organization/manager-resolution.entity.js +0 -55
- package/src/lib/organization/manager-resolution.entity.js.map +0 -1
- package/src/lib/organization/membership.entity.d.ts +0 -11
- package/src/lib/organization/membership.entity.js +0 -60
- package/src/lib/organization/membership.entity.js.map +0 -1
- package/src/lib/organization/org-unit-tree-commit-result.object.d.ts +0 -4
- package/src/lib/organization/org-unit-tree-commit-result.object.js +0 -17
- package/src/lib/organization/org-unit-tree-commit-result.object.js.map +0 -1
- package/src/lib/organization/org-unit.entity.d.ts +0 -13
- package/src/lib/organization/org-unit.entity.js +0 -64
- package/src/lib/organization/org-unit.entity.js.map +0 -1
- package/src/lib/organization/organization-summary.object.d.ts +0 -6
- package/src/lib/organization/organization-summary.object.js +0 -28
- package/src/lib/organization/organization-summary.object.js.map +0 -1
- package/src/lib/organization/organization.enums.d.ts +0 -11
- package/src/lib/organization/organization.enums.js +0 -22
- package/src/lib/organization/organization.enums.js.map +0 -1
- package/src/lib/organization/organization.module.d.ts +0 -2
- package/src/lib/organization/organization.module.js +0 -35
- package/src/lib/organization/organization.module.js.map +0 -1
- package/src/lib/organization/organization.mutations.d.ts +0 -26
- package/src/lib/organization/organization.mutations.js +0 -148
- package/src/lib/organization/organization.mutations.js.map +0 -1
- package/src/lib/organization/organization.queries.d.ts +0 -23
- package/src/lib/organization/organization.queries.js +0 -204
- package/src/lib/organization/organization.queries.js.map +0 -1
- package/src/lib/organization/organization.service.d.ts +0 -103
- package/src/lib/organization/organization.service.js +0 -768
- package/src/lib/organization/organization.service.js.map +0 -1
- package/src/lib/organization/position.entity.d.ts +0 -9
- package/src/lib/organization/position.entity.js +0 -48
- package/src/lib/organization/position.entity.js.map +0 -1
- package/src/lib/organization/resolved-manager.object.d.ts +0 -4
- package/src/lib/organization/resolved-manager.object.js +0 -20
- package/src/lib/organization/resolved-manager.object.js.map +0 -1
- package/src/lib/signature/index.js +0 -8
- package/src/lib/signature/index.js.map +0 -1
- package/src/lib/signature/signature-options.d.ts +0 -33
- package/src/lib/signature/signature-options.js +0 -51
- package/src/lib/signature/signature-options.js.map +0 -1
- package/src/lib/signature/signature-verification.object.d.ts +0 -6
- package/src/lib/signature/signature-verification.object.js +0 -28
- package/src/lib/signature/signature-verification.object.js.map +0 -1
- package/src/lib/signature/signature.entity.d.ts +0 -16
- package/src/lib/signature/signature.entity.js +0 -88
- package/src/lib/signature/signature.entity.js.map +0 -1
- package/src/lib/signature/signature.module.d.ts +0 -11
- package/src/lib/signature/signature.module.js +0 -60
- package/src/lib/signature/signature.module.js.map +0 -1
- package/src/lib/signature/signature.queries.d.ts +0 -11
- package/src/lib/signature/signature.queries.js +0 -46
- package/src/lib/signature/signature.queries.js.map +0 -1
- package/src/lib/signature/signature.service.d.ts +0 -25
- package/src/lib/signature/signature.service.js +0 -124
- package/src/lib/signature/signature.service.js.map +0 -1
- package/src/lib/template/approval-template-category.entity.d.ts +0 -9
- package/src/lib/template/approval-template-category.entity.js +0 -49
- package/src/lib/template/approval-template-category.entity.js.map +0 -1
- package/src/lib/template/approval-template-version.entity.d.ts +0 -21
- package/src/lib/template/approval-template-version.entity.js +0 -106
- package/src/lib/template/approval-template-version.entity.js.map +0 -1
- package/src/lib/template/approval-template.entity.d.ts +0 -14
- package/src/lib/template/approval-template.entity.js +0 -74
- package/src/lib/template/approval-template.entity.js.map +0 -1
- package/src/lib/template/compose-approval-template.object.d.ts +0 -11
- package/src/lib/template/compose-approval-template.object.js +0 -36
- package/src/lib/template/compose-approval-template.object.js.map +0 -1
- package/src/lib/template/compose-template.mutations.d.ts +0 -8
- package/src/lib/template/compose-template.mutations.js +0 -32
- package/src/lib/template/compose-template.mutations.js.map +0 -1
- package/src/lib/template/dto/approval-template.input.d.ts +0 -36
- package/src/lib/template/dto/approval-template.input.js +0 -187
- package/src/lib/template/dto/approval-template.input.js.map +0 -1
- package/src/lib/template/dto/compose-approval-template.input.d.ts +0 -17
- package/src/lib/template/dto/compose-approval-template.input.js +0 -99
- package/src/lib/template/dto/compose-approval-template.input.js.map +0 -1
- package/src/lib/template/index.js +0 -14
- package/src/lib/template/index.js.map +0 -1
- package/src/lib/template/template.enums.d.ts +0 -14
- package/src/lib/template/template.enums.js +0 -31
- package/src/lib/template/template.enums.js.map +0 -1
- package/src/lib/template/template.module.d.ts +0 -2
- package/src/lib/template/template.module.js +0 -41
- package/src/lib/template/template.module.js.map +0 -1
- package/src/lib/template/template.mutations.d.ts +0 -20
- package/src/lib/template/template.mutations.js +0 -139
- package/src/lib/template/template.mutations.js.map +0 -1
- package/src/lib/template/template.queries.d.ts +0 -16
- package/src/lib/template/template.queries.js +0 -133
- package/src/lib/template/template.queries.js.map +0 -1
- package/src/lib/template/template.service.d.ts +0 -83
- package/src/lib/template/template.service.js +0 -654
- package/src/lib/template/template.service.js.map +0 -1
- package/src/lib/template/workflow-definition.validator.d.ts +0 -9
- package/src/lib/template/workflow-definition.validator.js +0 -362
- package/src/lib/template/workflow-definition.validator.js.map +0 -1
- package/src/lib/testing/cel-js.jest.d.ts +0 -15
- package/src/lib/testing/cel-js.jest.js +0 -27
- package/src/lib/testing/cel-js.jest.js.map +0 -1
- package/src/lib/workflow-engine/activity-log.entity.d.ts +0 -12
- package/src/lib/workflow-engine/activity-log.entity.js +0 -62
- package/src/lib/workflow-engine/activity-log.entity.js.map +0 -1
- package/src/lib/workflow-engine/adhoc-directive.entity.d.ts +0 -31
- package/src/lib/workflow-engine/adhoc-directive.entity.js +0 -105
- package/src/lib/workflow-engine/adhoc-directive.entity.js.map +0 -1
- package/src/lib/workflow-engine/adhoc.enums.d.ts +0 -21
- package/src/lib/workflow-engine/adhoc.enums.js +0 -42
- package/src/lib/workflow-engine/adhoc.enums.js.map +0 -1
- package/src/lib/workflow-engine/approval-instance-page-info.object.d.ts +0 -8
- package/src/lib/workflow-engine/approval-instance-page-info.object.js +0 -36
- package/src/lib/workflow-engine/approval-instance-page-info.object.js.map +0 -1
- package/src/lib/workflow-engine/approval-instance.entity.d.ts +0 -22
- package/src/lib/workflow-engine/approval-instance.entity.js +0 -113
- package/src/lib/workflow-engine/approval-instance.entity.js.map +0 -1
- package/src/lib/workflow-engine/dto/adhoc-notification.input.d.ts +0 -6
- package/src/lib/workflow-engine/dto/adhoc-notification.input.js +0 -28
- package/src/lib/workflow-engine/dto/adhoc-notification.input.js.map +0 -1
- package/src/lib/workflow-engine/dto/adhoc-target.input.d.ts +0 -16
- package/src/lib/workflow-engine/dto/adhoc-target.input.js +0 -61
- package/src/lib/workflow-engine/dto/adhoc-target.input.js.map +0 -1
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.d.ts +0 -5
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.js +0 -29
- package/src/lib/workflow-engine/dto/cancel-approval-instance.input.js.map +0 -1
- package/src/lib/workflow-engine/dto/decide-task.input.d.ts +0 -9
- package/src/lib/workflow-engine/dto/decide-task.input.js +0 -47
- package/src/lib/workflow-engine/dto/decide-task.input.js.map +0 -1
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.d.ts +0 -6
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.js +0 -34
- package/src/lib/workflow-engine/dto/dry-run-approval-workflow.input.js.map +0 -1
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.d.ts +0 -6
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.js +0 -34
- package/src/lib/workflow-engine/dto/resubmit-approval-instance.input.js.map +0 -1
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.d.ts +0 -7
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.js +0 -40
- package/src/lib/workflow-engine/dto/submit-approval-instance.input.js.map +0 -1
- package/src/lib/workflow-engine/index.js +0 -28
- package/src/lib/workflow-engine/index.js.map +0 -1
- package/src/lib/workflow-engine/task-candidate.entity.d.ts +0 -14
- package/src/lib/workflow-engine/task-candidate.entity.js +0 -72
- package/src/lib/workflow-engine/task-candidate.entity.js.map +0 -1
- package/src/lib/workflow-engine/task-decision.entity.d.ts +0 -12
- package/src/lib/workflow-engine/task-decision.entity.js +0 -60
- package/src/lib/workflow-engine/task-decision.entity.js.map +0 -1
- package/src/lib/workflow-engine/task.entity.d.ts +0 -25
- package/src/lib/workflow-engine/task.entity.js +0 -130
- package/src/lib/workflow-engine/task.entity.js.map +0 -1
- package/src/lib/workflow-engine/workflow-condition-evaluator.d.ts +0 -5
- package/src/lib/workflow-engine/workflow-condition-evaluator.js +0 -107
- package/src/lib/workflow-engine/workflow-condition-evaluator.js.map +0 -1
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.d.ts +0 -8
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.js +0 -36
- package/src/lib/workflow-engine/workflow-dashboard-summary.object.js.map +0 -1
- package/src/lib/workflow-engine/workflow-dry-run.object.d.ts +0 -21
- package/src/lib/workflow-engine/workflow-dry-run.object.js +0 -86
- package/src/lib/workflow-engine/workflow-dry-run.object.js.map +0 -1
- package/src/lib/workflow-engine/workflow-engine.enums.d.ts +0 -61
- package/src/lib/workflow-engine/workflow-engine.enums.js +0 -98
- package/src/lib/workflow-engine/workflow-engine.enums.js.map +0 -1
- package/src/lib/workflow-engine/workflow-engine.module.d.ts +0 -9
- package/src/lib/workflow-engine/workflow-engine.module.js +0 -78
- package/src/lib/workflow-engine/workflow-engine.module.js.map +0 -1
- package/src/lib/workflow-engine/workflow-engine.mutations.d.ts +0 -29
- package/src/lib/workflow-engine/workflow-engine.mutations.js +0 -218
- package/src/lib/workflow-engine/workflow-engine.mutations.js.map +0 -1
- package/src/lib/workflow-engine/workflow-engine.queries.d.ts +0 -31
- package/src/lib/workflow-engine/workflow-engine.queries.js +0 -237
- package/src/lib/workflow-engine/workflow-engine.queries.js.map +0 -1
- package/src/lib/workflow-engine/workflow-engine.service.d.ts +0 -188
- package/src/lib/workflow-engine/workflow-engine.service.js +0 -3561
- package/src/lib/workflow-engine/workflow-engine.service.js.map +0 -1
- package/src/lib/workflow-engine/workflow-engine.tokens.js +0 -5
- package/src/lib/workflow-engine/workflow-engine.tokens.js.map +0 -1
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.d.ts +0 -18
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js +0 -39
- package/src/lib/workflow-engine/workflow-service-task-dispatcher.token.js.map +0 -1
- package/src/lib/workflow-engine/workflow-token.entity.d.ts +0 -10
- package/src/lib/workflow-engine/workflow-token.entity.js +0 -50
- package/src/lib/workflow-engine/workflow-token.entity.js.map +0 -1
- /package/src/{index.d.ts → index.ts} +0 -0
- /package/src/lib/attachment/{index.d.ts → index.ts} +0 -0
- /package/src/lib/bpm/{index.d.ts → index.ts} +0 -0
- /package/src/lib/bpm-auth/{index.d.ts → index.ts} +0 -0
- /package/src/lib/common/{index.d.ts → index.ts} +0 -0
- /package/src/lib/condition/{index.d.ts → index.ts} +0 -0
- /package/src/lib/database/{index.d.ts → index.ts} +0 -0
- /package/src/lib/delegation/{index.d.ts → index.ts} +0 -0
- /package/src/lib/form/{index.d.ts → index.ts} +0 -0
- /package/src/lib/identity/{index.d.ts → index.ts} +0 -0
- /package/src/lib/notification/{index.d.ts → index.ts} +0 -0
- /package/src/lib/organization/{index.d.ts → index.ts} +0 -0
- /package/src/lib/signature/{index.d.ts → index.ts} +0 -0
- /package/src/lib/template/{index.d.ts → index.ts} +0 -0
- /package/src/lib/workflow-engine/{index.d.ts → index.ts} +0 -0
|
@@ -1,713 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var NotificationService_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.NotificationService = void 0;
|
|
5
|
-
exports.calculateTaskSlaDueAt = calculateTaskSlaDueAt;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const common_1 = require("@nestjs/common");
|
|
8
|
-
const core_1 = require("@nestjs/core");
|
|
9
|
-
const typeorm_1 = require("@nestjs/typeorm");
|
|
10
|
-
const typeorm_2 = require("typeorm");
|
|
11
|
-
const iso_duration_1 = require("../common/iso-duration");
|
|
12
|
-
const activity_log_entity_1 = require("../workflow-engine/activity-log.entity");
|
|
13
|
-
const approval_instance_entity_1 = require("../workflow-engine/approval-instance.entity");
|
|
14
|
-
const organization_service_1 = require("../organization/organization.service");
|
|
15
|
-
const task_candidate_entity_1 = require("../workflow-engine/task-candidate.entity");
|
|
16
|
-
const task_entity_1 = require("../workflow-engine/task.entity");
|
|
17
|
-
const workflow_engine_tokens_1 = require("../workflow-engine/workflow-engine.tokens");
|
|
18
|
-
const workflow_engine_enums_1 = require("../workflow-engine/workflow-engine.enums");
|
|
19
|
-
const notification_delivery_service_1 = require("./notification-delivery.service");
|
|
20
|
-
const notification_preference_entity_1 = require("./notification-preference.entity");
|
|
21
|
-
const notification_entity_1 = require("./notification.entity");
|
|
22
|
-
const notification_enums_1 = require("./notification.enums");
|
|
23
|
-
const ACTIONABLE_NOTIFICATION_TYPES = [
|
|
24
|
-
notification_enums_1.NotificationTypeEnum.TASK_ASSIGNED,
|
|
25
|
-
notification_enums_1.NotificationTypeEnum.TASK_TRANSFERRED,
|
|
26
|
-
];
|
|
27
|
-
const notification_options_1 = require("./notification-options");
|
|
28
|
-
const notification_template_1 = require("./notification-template");
|
|
29
|
-
let NotificationService = NotificationService_1 = class NotificationService {
|
|
30
|
-
constructor(notificationRepository, notificationPreferenceRepository, taskRepository, taskCandidateRepository, approvalInstanceRepository, activityLogRepository, deliveryService, moduleRef, notificationOptions = notification_options_1.DEFAULT_BPM_NOTIFICATION_OPTIONS) {
|
|
31
|
-
this.notificationRepository = notificationRepository;
|
|
32
|
-
this.notificationPreferenceRepository = notificationPreferenceRepository;
|
|
33
|
-
this.taskRepository = taskRepository;
|
|
34
|
-
this.taskCandidateRepository = taskCandidateRepository;
|
|
35
|
-
this.approvalInstanceRepository = approvalInstanceRepository;
|
|
36
|
-
this.activityLogRepository = activityLogRepository;
|
|
37
|
-
this.deliveryService = deliveryService;
|
|
38
|
-
this.moduleRef = moduleRef;
|
|
39
|
-
this.notificationOptions = notificationOptions;
|
|
40
|
-
this.logger = new common_1.Logger(NotificationService_1.name);
|
|
41
|
-
}
|
|
42
|
-
async listNotifications({ includeRead = false, page = 1, pageSize = 10, recipientMemberId, }) {
|
|
43
|
-
const normalizedPageSize = normalizePageSize(pageSize);
|
|
44
|
-
return this.notificationRepository.find({
|
|
45
|
-
order: { createdAt: 'DESC' },
|
|
46
|
-
skip: (normalizePage(page) - 1) * normalizedPageSize,
|
|
47
|
-
take: normalizedPageSize,
|
|
48
|
-
where: {
|
|
49
|
-
channel: notification_enums_1.NotificationChannelEnum.IN_APP,
|
|
50
|
-
recipientMemberId,
|
|
51
|
-
...(includeRead ? {} : { status: (0, typeorm_2.Not)(notification_enums_1.NotificationStatusEnum.READ) }),
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
async countNotifications({ includeRead = false, recipientMemberId, }) {
|
|
56
|
-
return this.notificationRepository.count({
|
|
57
|
-
where: {
|
|
58
|
-
channel: notification_enums_1.NotificationChannelEnum.IN_APP,
|
|
59
|
-
recipientMemberId,
|
|
60
|
-
...(includeRead ? {} : { status: (0, typeorm_2.Not)(notification_enums_1.NotificationStatusEnum.READ) }),
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async countUnreadNotifications(recipientMemberId) {
|
|
65
|
-
return this.notificationRepository.count({
|
|
66
|
-
where: {
|
|
67
|
-
channel: notification_enums_1.NotificationChannelEnum.IN_APP,
|
|
68
|
-
recipientMemberId,
|
|
69
|
-
status: (0, typeorm_2.Not)(notification_enums_1.NotificationStatusEnum.READ),
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
async markAllNotificationsRead({ recipientMemberId, }) {
|
|
74
|
-
const trimmedRecipientMemberId = recipientMemberId.trim();
|
|
75
|
-
if (!trimmedRecipientMemberId) {
|
|
76
|
-
return 0;
|
|
77
|
-
}
|
|
78
|
-
const result = await this.notificationRepository.update({
|
|
79
|
-
channel: notification_enums_1.NotificationChannelEnum.IN_APP,
|
|
80
|
-
recipientMemberId: trimmedRecipientMemberId,
|
|
81
|
-
status: (0, typeorm_2.Not)(notification_enums_1.NotificationStatusEnum.READ),
|
|
82
|
-
}, {
|
|
83
|
-
readAt: new Date(),
|
|
84
|
-
status: notification_enums_1.NotificationStatusEnum.READ,
|
|
85
|
-
});
|
|
86
|
-
return result.affected ?? 0;
|
|
87
|
-
}
|
|
88
|
-
async markNotificationRead({ id, readerMemberId, }) {
|
|
89
|
-
const notification = await this.notificationRepository.findOne({
|
|
90
|
-
where: { id },
|
|
91
|
-
});
|
|
92
|
-
if (!notification) {
|
|
93
|
-
throw new common_1.NotFoundException(`Notification ${id} was not found`);
|
|
94
|
-
}
|
|
95
|
-
if (readerMemberId &&
|
|
96
|
-
notification.recipientMemberId !== readerMemberId.trim()) {
|
|
97
|
-
throw new common_1.NotFoundException(`Notification ${id} was not found`);
|
|
98
|
-
}
|
|
99
|
-
return this.notificationRepository.save(this.notificationRepository.create({
|
|
100
|
-
...notification,
|
|
101
|
-
readAt: notification.readAt ?? new Date(),
|
|
102
|
-
status: notification_enums_1.NotificationStatusEnum.READ,
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
async getPreference(memberId) {
|
|
106
|
-
const existingPreference = await this.notificationPreferenceRepository.findOne({
|
|
107
|
-
where: { memberId },
|
|
108
|
-
});
|
|
109
|
-
return (existingPreference ??
|
|
110
|
-
createDefaultPreference(memberId, this.notificationOptions));
|
|
111
|
-
}
|
|
112
|
-
async updatePreference(input) {
|
|
113
|
-
const currentPreference = await this.getPreference(input.memberId);
|
|
114
|
-
return this.notificationPreferenceRepository.save({
|
|
115
|
-
...currentPreference,
|
|
116
|
-
emailDigestMode: input.emailDigestMode,
|
|
117
|
-
emailEnabled: input.emailEnabled,
|
|
118
|
-
inAppEnabled: input.inAppEnabled,
|
|
119
|
-
memberId: input.memberId,
|
|
120
|
-
quietHoursEnd: normalizeTimeInput(input.quietHoursEnd),
|
|
121
|
-
quietHoursStart: normalizeTimeInput(input.quietHoursStart),
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
async createTaskAssignedNotification({ instance, manager, node, task, transferred = false, }) {
|
|
125
|
-
if (!task.assigneeMemberId) {
|
|
126
|
-
return [];
|
|
127
|
-
}
|
|
128
|
-
return this.createNotifications({
|
|
129
|
-
channels: readNodeNotificationChannels(node, this.notificationOptions),
|
|
130
|
-
customTemplate: node.data.notification?.customTemplate ?? null,
|
|
131
|
-
instanceId: instance.id,
|
|
132
|
-
payload: {
|
|
133
|
-
assigneeMemberId: task.assigneeMemberId,
|
|
134
|
-
instanceId: instance.id,
|
|
135
|
-
instanceTitle: instance.title,
|
|
136
|
-
nodeId: node.id,
|
|
137
|
-
nodeLabel: node.data.label,
|
|
138
|
-
originalAssigneeMemberId: task.originalAssigneeMemberId,
|
|
139
|
-
slaDueAt: task.slaDueAt?.toISOString() ?? null,
|
|
140
|
-
taskId: task.id,
|
|
141
|
-
},
|
|
142
|
-
recipientMemberId: task.assigneeMemberId,
|
|
143
|
-
taskId: task.id,
|
|
144
|
-
type: transferred
|
|
145
|
-
? notification_enums_1.NotificationTypeEnum.TASK_TRANSFERRED
|
|
146
|
-
: notification_enums_1.NotificationTypeEnum.TASK_ASSIGNED,
|
|
147
|
-
}, manager);
|
|
148
|
-
}
|
|
149
|
-
async createServiceTaskNotifications({ instance, manager, node, recipientMemberIds, }) {
|
|
150
|
-
if (node.data.action.type !== 'NOTIFY') {
|
|
151
|
-
return [];
|
|
152
|
-
}
|
|
153
|
-
const action = node.data.action;
|
|
154
|
-
const channels = normalizeNotificationChannels(action.channels);
|
|
155
|
-
const uniqueRecipientMemberIds = uniqueStrings(recipientMemberIds);
|
|
156
|
-
return uniqueRecipientMemberIds.reduce(async (previousPromise, recipientMemberId) => {
|
|
157
|
-
const previous = await previousPromise;
|
|
158
|
-
const created = await this.createNotifications({
|
|
159
|
-
channels,
|
|
160
|
-
customTemplate: action.template ?? null,
|
|
161
|
-
instanceId: instance.id,
|
|
162
|
-
payload: {
|
|
163
|
-
instanceId: instance.id,
|
|
164
|
-
instanceTitle: instance.title,
|
|
165
|
-
message: action.template ??
|
|
166
|
-
`案件 ${instance.title} 的 ${node.data.label} 已送出通知。`,
|
|
167
|
-
nodeId: node.id,
|
|
168
|
-
nodeLabel: node.data.label,
|
|
169
|
-
recipientMemberId,
|
|
170
|
-
},
|
|
171
|
-
recipientMemberId,
|
|
172
|
-
taskId: null,
|
|
173
|
-
type: notification_enums_1.NotificationTypeEnum.WORKFLOW_NOTIFICATION,
|
|
174
|
-
}, manager);
|
|
175
|
-
return [...previous, ...created];
|
|
176
|
-
}, Promise.resolve([]));
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Deliver an ad-hoc directive notification (STAGE_NOTIFY /
|
|
180
|
-
* COMPLETION_NOTIFY) to resolved member recipients. Runs inside the
|
|
181
|
-
* caller's transaction `manager` so it commits atomically with the
|
|
182
|
-
* workflow state change that triggered it.
|
|
183
|
-
*/
|
|
184
|
-
async createAdhocWorkflowNotifications({ channels, instance, manager, message, payload, recipientMemberIds, }) {
|
|
185
|
-
const normalizedChannels = channels?.length
|
|
186
|
-
? channels
|
|
187
|
-
: [notification_enums_1.NotificationChannelEnum.IN_APP];
|
|
188
|
-
const uniqueRecipientMemberIds = uniqueStrings(recipientMemberIds);
|
|
189
|
-
return uniqueRecipientMemberIds.reduce(async (previousPromise, recipientMemberId) => {
|
|
190
|
-
const previous = await previousPromise;
|
|
191
|
-
const created = await this.createNotifications({
|
|
192
|
-
channels: normalizedChannels,
|
|
193
|
-
instanceId: instance.id,
|
|
194
|
-
payload: {
|
|
195
|
-
...payload,
|
|
196
|
-
instanceId: instance.id,
|
|
197
|
-
instanceTitle: instance.title,
|
|
198
|
-
message,
|
|
199
|
-
recipientMemberId,
|
|
200
|
-
},
|
|
201
|
-
recipientMemberId,
|
|
202
|
-
taskId: null,
|
|
203
|
-
type: notification_enums_1.NotificationTypeEnum.WORKFLOW_NOTIFICATION,
|
|
204
|
-
}, manager);
|
|
205
|
-
return [...previous, ...created];
|
|
206
|
-
}, Promise.resolve([]));
|
|
207
|
-
}
|
|
208
|
-
async createInstanceCompletedNotification({ instance, manager, }) {
|
|
209
|
-
const repository = manager.getRepository(notification_entity_1.NotificationEntity);
|
|
210
|
-
const existingNotification = await repository.findOne({
|
|
211
|
-
where: {
|
|
212
|
-
channel: notification_enums_1.NotificationChannelEnum.IN_APP,
|
|
213
|
-
instanceId: instance.id,
|
|
214
|
-
recipientMemberId: instance.initiatorMemberId,
|
|
215
|
-
taskId: (0, typeorm_2.IsNull)(),
|
|
216
|
-
type: notification_enums_1.NotificationTypeEnum.INSTANCE_COMPLETED,
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
if (existingNotification) {
|
|
220
|
-
return [];
|
|
221
|
-
}
|
|
222
|
-
return this.createNotifications({
|
|
223
|
-
channels: [notification_enums_1.NotificationChannelEnum.IN_APP],
|
|
224
|
-
instanceId: instance.id,
|
|
225
|
-
payload: {
|
|
226
|
-
completedAt: instance.completedAt?.toISOString() ?? null,
|
|
227
|
-
instanceId: instance.id,
|
|
228
|
-
instanceTitle: instance.title,
|
|
229
|
-
recipientMemberId: instance.initiatorMemberId,
|
|
230
|
-
},
|
|
231
|
-
recipientMemberId: instance.initiatorMemberId,
|
|
232
|
-
taskId: null,
|
|
233
|
-
type: notification_enums_1.NotificationTypeEnum.INSTANCE_COMPLETED,
|
|
234
|
-
}, manager);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Resolve the open task-assignment notifications for a decided task, so the
|
|
238
|
-
* inline 同意/拒絕 actions stop being offered once the task no longer needs
|
|
239
|
-
* the recipient. The acting member's notification records the actual
|
|
240
|
-
* decision (`resolution`); every other candidate's notification is marked
|
|
241
|
-
* `SUPERSEDED` when the task has ended. Runs inside the caller's
|
|
242
|
-
* transaction `manager` so it commits atomically with the decision.
|
|
243
|
-
*/
|
|
244
|
-
async resolveTaskNotifications({ actingMemberId, manager, resolution, supersedeOthers, taskId, }) {
|
|
245
|
-
const repository = manager.getRepository(notification_entity_1.NotificationEntity);
|
|
246
|
-
const resolvedAt = new Date();
|
|
247
|
-
await repository.update({
|
|
248
|
-
recipientMemberId: actingMemberId,
|
|
249
|
-
resolvedAt: (0, typeorm_2.IsNull)(),
|
|
250
|
-
taskId,
|
|
251
|
-
type: (0, typeorm_2.In)(ACTIONABLE_NOTIFICATION_TYPES),
|
|
252
|
-
}, {
|
|
253
|
-
readAt: resolvedAt,
|
|
254
|
-
resolution,
|
|
255
|
-
resolvedAt,
|
|
256
|
-
status: notification_enums_1.NotificationStatusEnum.READ,
|
|
257
|
-
});
|
|
258
|
-
if (supersedeOthers) {
|
|
259
|
-
await repository.update({
|
|
260
|
-
recipientMemberId: (0, typeorm_2.Not)(actingMemberId),
|
|
261
|
-
resolvedAt: (0, typeorm_2.IsNull)(),
|
|
262
|
-
taskId,
|
|
263
|
-
type: (0, typeorm_2.In)(ACTIONABLE_NOTIFICATION_TYPES),
|
|
264
|
-
}, {
|
|
265
|
-
readAt: resolvedAt,
|
|
266
|
-
resolution: notification_enums_1.NotificationResolutionEnum.SUPERSEDED,
|
|
267
|
-
resolvedAt,
|
|
268
|
-
status: notification_enums_1.NotificationStatusEnum.READ,
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Mark every still-open task-assignment notification for an instance as
|
|
274
|
-
* `SUPERSEDED` — used when the whole instance is cancelled, so lingering
|
|
275
|
-
* "待簽" notifications can no longer be actioned. Runs inside the caller's
|
|
276
|
-
* transaction `manager`.
|
|
277
|
-
*/
|
|
278
|
-
async supersedeInstanceTaskNotifications({ instanceId, manager, }) {
|
|
279
|
-
const repository = manager.getRepository(notification_entity_1.NotificationEntity);
|
|
280
|
-
const resolvedAt = new Date();
|
|
281
|
-
await repository.update({
|
|
282
|
-
instanceId,
|
|
283
|
-
resolvedAt: (0, typeorm_2.IsNull)(),
|
|
284
|
-
type: (0, typeorm_2.In)(ACTIONABLE_NOTIFICATION_TYPES),
|
|
285
|
-
}, {
|
|
286
|
-
readAt: resolvedAt,
|
|
287
|
-
resolution: notification_enums_1.NotificationResolutionEnum.SUPERSEDED,
|
|
288
|
-
resolvedAt,
|
|
289
|
-
status: notification_enums_1.NotificationStatusEnum.READ,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
async runSlaScan(now = new Date()) {
|
|
293
|
-
const candidateTasks = await this.taskRepository.find({
|
|
294
|
-
order: { slaDueAt: 'ASC' },
|
|
295
|
-
where: [
|
|
296
|
-
{
|
|
297
|
-
slaDueAt: (0, typeorm_2.LessThanOrEqual)(now),
|
|
298
|
-
status: workflow_engine_enums_1.TaskStatusEnum.PENDING,
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
slaDueAt: (0, typeorm_2.LessThanOrEqual)(now),
|
|
302
|
-
status: workflow_engine_enums_1.TaskStatusEnum.IN_PROGRESS,
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
slaDueAt: (0, typeorm_2.MoreThan)(now),
|
|
306
|
-
status: workflow_engine_enums_1.TaskStatusEnum.PENDING,
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
slaDueAt: (0, typeorm_2.MoreThan)(now),
|
|
310
|
-
status: workflow_engine_enums_1.TaskStatusEnum.IN_PROGRESS,
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
});
|
|
314
|
-
const results = await candidateTasks.reduce(async (resultPromise, task) => {
|
|
315
|
-
const currentResult = await resultPromise;
|
|
316
|
-
if (!(await this.tryClaimSlaTask(task.id))) {
|
|
317
|
-
return currentResult;
|
|
318
|
-
}
|
|
319
|
-
const instance = await this.approvalInstanceRepository.findOne({
|
|
320
|
-
where: { id: task.instanceId },
|
|
321
|
-
});
|
|
322
|
-
if (!instance) {
|
|
323
|
-
return currentResult;
|
|
324
|
-
}
|
|
325
|
-
const node = readUserTaskNode(instance, task.nodeId);
|
|
326
|
-
if (!node?.data.sla || !task.slaDueAt) {
|
|
327
|
-
return currentResult;
|
|
328
|
-
}
|
|
329
|
-
if (task.slaDueAt.getTime() <= now.getTime()) {
|
|
330
|
-
const created = await this.createSlaNotificationOnce({
|
|
331
|
-
instance,
|
|
332
|
-
node,
|
|
333
|
-
task,
|
|
334
|
-
type: notification_enums_1.NotificationTypeEnum.SLA_OVERDUE,
|
|
335
|
-
});
|
|
336
|
-
if (created) {
|
|
337
|
-
await this.recordSlaActivity({
|
|
338
|
-
instance,
|
|
339
|
-
node,
|
|
340
|
-
task,
|
|
341
|
-
trigger: 'OVERDUE',
|
|
342
|
-
});
|
|
343
|
-
await this.runSlaTimeoutHook({ instance, node, task });
|
|
344
|
-
}
|
|
345
|
-
return {
|
|
346
|
-
overdueCount: currentResult.overdueCount + (created ? 1 : 0),
|
|
347
|
-
warningCount: currentResult.warningCount,
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
const warningAt = node.data.sla.warningAt;
|
|
351
|
-
if (!warningAt || warningAt <= 0 || warningAt >= 1) {
|
|
352
|
-
return currentResult;
|
|
353
|
-
}
|
|
354
|
-
const warningAtTime = task.createdAt.getTime() +
|
|
355
|
-
(task.slaDueAt.getTime() - task.createdAt.getTime()) * warningAt;
|
|
356
|
-
if (warningAtTime > now.getTime()) {
|
|
357
|
-
return currentResult;
|
|
358
|
-
}
|
|
359
|
-
const created = await this.createSlaNotificationOnce({
|
|
360
|
-
instance,
|
|
361
|
-
node,
|
|
362
|
-
task,
|
|
363
|
-
type: notification_enums_1.NotificationTypeEnum.SLA_WARNING,
|
|
364
|
-
});
|
|
365
|
-
if (created) {
|
|
366
|
-
await this.recordSlaActivity({
|
|
367
|
-
instance,
|
|
368
|
-
node,
|
|
369
|
-
task,
|
|
370
|
-
trigger: 'WARNING',
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
return {
|
|
374
|
-
overdueCount: currentResult.overdueCount,
|
|
375
|
-
warningCount: currentResult.warningCount + (created ? 1 : 0),
|
|
376
|
-
};
|
|
377
|
-
}, Promise.resolve({ overdueCount: 0, warningCount: 0 }));
|
|
378
|
-
return results;
|
|
379
|
-
}
|
|
380
|
-
async tryClaimSlaTask(taskId) {
|
|
381
|
-
if (!this.taskRepository.query) {
|
|
382
|
-
return true;
|
|
383
|
-
}
|
|
384
|
-
const rows = (await this.taskRepository.query('SELECT pg_try_advisory_xact_lock(hashtext($1)) AS claimed', [`bpm-sla:${taskId}`]));
|
|
385
|
-
return rows[0]?.claimed !== false;
|
|
386
|
-
}
|
|
387
|
-
async createSlaNotificationOnce({ instance, node, task, type, }) {
|
|
388
|
-
const recipientMemberIds = await this.resolveTaskRecipientMemberIds(task);
|
|
389
|
-
if (recipientMemberIds.length === 0) {
|
|
390
|
-
return false;
|
|
391
|
-
}
|
|
392
|
-
const createdNotifications = await recipientMemberIds.reduce(async (countPromise, recipientMemberId) => {
|
|
393
|
-
const count = await countPromise;
|
|
394
|
-
const existingNotification = await this.notificationRepository.findOne({
|
|
395
|
-
where: {
|
|
396
|
-
channel: notification_enums_1.NotificationChannelEnum.IN_APP,
|
|
397
|
-
recipientMemberId,
|
|
398
|
-
taskId: task.id,
|
|
399
|
-
type,
|
|
400
|
-
},
|
|
401
|
-
});
|
|
402
|
-
if (existingNotification) {
|
|
403
|
-
return count;
|
|
404
|
-
}
|
|
405
|
-
try {
|
|
406
|
-
await this.createNotifications({
|
|
407
|
-
channels: [notification_enums_1.NotificationChannelEnum.IN_APP],
|
|
408
|
-
customTemplate: node.data.notification?.customTemplate ?? null,
|
|
409
|
-
instanceId: instance.id,
|
|
410
|
-
payload: {
|
|
411
|
-
assigneeMemberId: task.assigneeMemberId,
|
|
412
|
-
instanceId: instance.id,
|
|
413
|
-
instanceTitle: instance.title,
|
|
414
|
-
nodeId: node.id,
|
|
415
|
-
nodeLabel: node.data.label,
|
|
416
|
-
onTimeout: node.data.sla?.onTimeout ?? 'REMIND',
|
|
417
|
-
recipientMemberId,
|
|
418
|
-
slaDueAt: task.slaDueAt?.toISOString() ?? null,
|
|
419
|
-
taskId: task.id,
|
|
420
|
-
},
|
|
421
|
-
recipientMemberId,
|
|
422
|
-
taskId: task.id,
|
|
423
|
-
type,
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
catch (error) {
|
|
427
|
-
if (isUniqueConstraintViolation(error)) {
|
|
428
|
-
return count;
|
|
429
|
-
}
|
|
430
|
-
throw error;
|
|
431
|
-
}
|
|
432
|
-
return count + 1;
|
|
433
|
-
}, Promise.resolve(0));
|
|
434
|
-
return createdNotifications > 0;
|
|
435
|
-
}
|
|
436
|
-
async createNotifications(input, manager) {
|
|
437
|
-
const preference = await this.getPreference(input.recipientMemberId);
|
|
438
|
-
const repository = manager
|
|
439
|
-
? manager.getRepository(notification_entity_1.NotificationEntity)
|
|
440
|
-
: this.notificationRepository;
|
|
441
|
-
const notifications = input.channels.flatMap((channel) => isChannelEnabled(channel, preference, this.notificationOptions)
|
|
442
|
-
? [
|
|
443
|
-
createNotificationEntity({
|
|
444
|
-
channel,
|
|
445
|
-
input,
|
|
446
|
-
options: this.notificationOptions,
|
|
447
|
-
repository,
|
|
448
|
-
}),
|
|
449
|
-
]
|
|
450
|
-
: []);
|
|
451
|
-
if (notifications.length === 0) {
|
|
452
|
-
return [];
|
|
453
|
-
}
|
|
454
|
-
const savedNotifications = await repository.save(notifications);
|
|
455
|
-
await Promise.all(savedNotifications
|
|
456
|
-
.filter((notification) => notification.channel !== notification_enums_1.NotificationChannelEnum.IN_APP)
|
|
457
|
-
.map((notification) => manager
|
|
458
|
-
? Promise.resolve(false)
|
|
459
|
-
: this.deliveryService.deliverNotification(notification, this.notificationOptions)));
|
|
460
|
-
return savedNotifications;
|
|
461
|
-
}
|
|
462
|
-
async recordSlaActivity({ instance, node, task, trigger, }) {
|
|
463
|
-
await this.activityLogRepository.save(this.activityLogRepository.create({
|
|
464
|
-
actorMemberId: null,
|
|
465
|
-
eventType: workflow_engine_enums_1.ActivityLogEventTypeEnum.SLA_TRIGGERED,
|
|
466
|
-
instanceId: instance.id,
|
|
467
|
-
nodeId: task.nodeId,
|
|
468
|
-
payload: {
|
|
469
|
-
assigneeMemberId: task.assigneeMemberId,
|
|
470
|
-
nodeLabel: node.data.label,
|
|
471
|
-
onTimeout: node.data.sla?.onTimeout ?? 'REMIND',
|
|
472
|
-
slaDueAt: task.slaDueAt?.toISOString() ?? null,
|
|
473
|
-
trigger,
|
|
474
|
-
},
|
|
475
|
-
taskId: task.id,
|
|
476
|
-
}));
|
|
477
|
-
}
|
|
478
|
-
async runSlaTimeoutHook({ instance, node, task, }) {
|
|
479
|
-
const timeoutAction = node.data.sla?.onTimeout ?? 'REMIND';
|
|
480
|
-
if (!isSlaTimeoutActionEnabled(timeoutAction, this.notificationOptions)) {
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
await this.executeSlaTimeoutAction({
|
|
484
|
-
instance,
|
|
485
|
-
node,
|
|
486
|
-
task,
|
|
487
|
-
timeoutAction,
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
async executeSlaTimeoutAction({ instance, node, task, timeoutAction, }) {
|
|
491
|
-
if (timeoutAction === 'REMIND') {
|
|
492
|
-
this.logger.log(`SLA reminder processed for task ${task.id}`);
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
const workflowEngine = this.moduleRef.get(workflow_engine_tokens_1.BPM_WORKFLOW_ENGINE_SERVICE, { strict: false });
|
|
496
|
-
if (timeoutAction === 'AUTO_APPROVE') {
|
|
497
|
-
const actorMemberId = await this.resolveTaskActorMemberId(task);
|
|
498
|
-
await workflowEngine.decideTask({
|
|
499
|
-
action: workflow_engine_enums_1.TaskDecisionActionEnum.APPROVED,
|
|
500
|
-
comment: 'SLA timeout auto-approved this task.',
|
|
501
|
-
decidedByMemberId: actorMemberId,
|
|
502
|
-
taskId: task.id,
|
|
503
|
-
});
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
if (timeoutAction === 'ESCALATE') {
|
|
507
|
-
const actorMemberId = await this.resolveTaskActorMemberId(task);
|
|
508
|
-
const targetMemberId = await this.resolveEscalationTargetMemberId({
|
|
509
|
-
actorMemberId,
|
|
510
|
-
node,
|
|
511
|
-
});
|
|
512
|
-
if (!targetMemberId || targetMemberId === actorMemberId) {
|
|
513
|
-
this.logger.warn(`SLA escalation skipped for task ${task.id}`);
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
await workflowEngine.decideTask({
|
|
517
|
-
action: workflow_engine_enums_1.TaskDecisionActionEnum.TRANSFERRED,
|
|
518
|
-
comment: 'SLA timeout escalated this task.',
|
|
519
|
-
decidedByMemberId: actorMemberId,
|
|
520
|
-
taskId: task.id,
|
|
521
|
-
transferToMemberId: targetMemberId,
|
|
522
|
-
});
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
await workflowEngine.cancelApprovalInstance({
|
|
526
|
-
cancelledByMemberId: instance.initiatorMemberId,
|
|
527
|
-
comment: 'SLA timeout terminated this instance.',
|
|
528
|
-
instanceId: instance.id,
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
async resolveTaskActorMemberId(task) {
|
|
532
|
-
if (task.assigneeMemberId) {
|
|
533
|
-
return task.assigneeMemberId;
|
|
534
|
-
}
|
|
535
|
-
const candidate = await this.taskCandidateRepository.findOne({
|
|
536
|
-
order: { createdAt: 'ASC' },
|
|
537
|
-
where: { taskId: task.id },
|
|
538
|
-
});
|
|
539
|
-
if (!candidate) {
|
|
540
|
-
throw new common_1.NotFoundException(`Task ${task.id} has no actor candidate`);
|
|
541
|
-
}
|
|
542
|
-
return candidate.memberId;
|
|
543
|
-
}
|
|
544
|
-
async resolveTaskRecipientMemberIds(task) {
|
|
545
|
-
if (task.assigneeMemberId) {
|
|
546
|
-
return [task.assigneeMemberId];
|
|
547
|
-
}
|
|
548
|
-
const candidates = await this.taskCandidateRepository.find({
|
|
549
|
-
order: { createdAt: 'ASC' },
|
|
550
|
-
where: { taskId: task.id },
|
|
551
|
-
});
|
|
552
|
-
return uniqueStrings(candidates
|
|
553
|
-
.filter((candidate) => candidate.status === workflow_engine_enums_1.TaskCandidateStatusEnum.PENDING ||
|
|
554
|
-
candidate.status === workflow_engine_enums_1.TaskCandidateStatusEnum.CLAIMED)
|
|
555
|
-
.map((candidate) => candidate.memberId));
|
|
556
|
-
}
|
|
557
|
-
async resolveEscalationTargetMemberId({ actorMemberId, node, }) {
|
|
558
|
-
const organizationService = this.moduleRef.get(organization_service_1.OrganizationService, {
|
|
559
|
-
strict: false,
|
|
560
|
-
});
|
|
561
|
-
const levelsUp = Math.max(node.data.sla?.escalateLevelsUp ?? 1, 1);
|
|
562
|
-
let currentMemberId = actorMemberId;
|
|
563
|
-
for (let level = 0; level < levelsUp && currentMemberId; level += 1) {
|
|
564
|
-
currentMemberId =
|
|
565
|
-
await organizationService.resolveManagerMemberId(currentMemberId);
|
|
566
|
-
}
|
|
567
|
-
return currentMemberId;
|
|
568
|
-
}
|
|
569
|
-
};
|
|
570
|
-
exports.NotificationService = NotificationService;
|
|
571
|
-
exports.NotificationService = NotificationService = NotificationService_1 = tslib_1.__decorate([
|
|
572
|
-
(0, common_1.Injectable)(),
|
|
573
|
-
tslib_1.__param(0, (0, typeorm_1.InjectRepository)(notification_entity_1.NotificationEntity)),
|
|
574
|
-
tslib_1.__param(1, (0, typeorm_1.InjectRepository)(notification_preference_entity_1.NotificationPreferenceEntity)),
|
|
575
|
-
tslib_1.__param(2, (0, typeorm_1.InjectRepository)(task_entity_1.TaskEntity)),
|
|
576
|
-
tslib_1.__param(3, (0, typeorm_1.InjectRepository)(task_candidate_entity_1.TaskCandidateEntity)),
|
|
577
|
-
tslib_1.__param(4, (0, typeorm_1.InjectRepository)(approval_instance_entity_1.ApprovalInstanceEntity)),
|
|
578
|
-
tslib_1.__param(5, (0, typeorm_1.InjectRepository)(activity_log_entity_1.ActivityLogEntity)),
|
|
579
|
-
tslib_1.__param(8, (0, common_1.Optional)()),
|
|
580
|
-
tslib_1.__param(8, (0, common_1.Inject)(notification_options_1.BPM_NOTIFICATION_OPTIONS)),
|
|
581
|
-
tslib_1.__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
582
|
-
typeorm_2.Repository,
|
|
583
|
-
typeorm_2.Repository,
|
|
584
|
-
typeorm_2.Repository,
|
|
585
|
-
typeorm_2.Repository,
|
|
586
|
-
typeorm_2.Repository,
|
|
587
|
-
notification_delivery_service_1.NotificationDeliveryService,
|
|
588
|
-
core_1.ModuleRef, Object])
|
|
589
|
-
], NotificationService);
|
|
590
|
-
function calculateTaskSlaDueAt({ node, now, }) {
|
|
591
|
-
const duration = node.data.sla?.duration;
|
|
592
|
-
if (!duration) {
|
|
593
|
-
return null;
|
|
594
|
-
}
|
|
595
|
-
const durationMs = (0, iso_duration_1.parseIsoDurationToMilliseconds)(duration);
|
|
596
|
-
return durationMs ? new Date(now.getTime() + durationMs) : null;
|
|
597
|
-
}
|
|
598
|
-
function createDefaultPreference(memberId, options) {
|
|
599
|
-
return Object.assign(new notification_preference_entity_1.NotificationPreferenceEntity(), {
|
|
600
|
-
emailDigestMode: options.defaultEmailDigestMode,
|
|
601
|
-
emailEnabled: options.defaultEmailPreferenceEnabled,
|
|
602
|
-
inAppEnabled: options.defaultInAppPreferenceEnabled,
|
|
603
|
-
memberId,
|
|
604
|
-
quietHoursEnd: null,
|
|
605
|
-
quietHoursStart: null,
|
|
606
|
-
updatedAt: new Date(0),
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
function normalizeTimeInput(value) {
|
|
610
|
-
const trimmedValue = value?.trim() ?? '';
|
|
611
|
-
return trimmedValue || null;
|
|
612
|
-
}
|
|
613
|
-
function readNodeNotificationChannels(node, options) {
|
|
614
|
-
const configuredChannels = node.data.notification?.channels ?? [];
|
|
615
|
-
const channels = configuredChannels
|
|
616
|
-
.map((channel) => channel === 'EMAIL'
|
|
617
|
-
? notification_enums_1.NotificationChannelEnum.EMAIL
|
|
618
|
-
: channel === 'WEBHOOK'
|
|
619
|
-
? notification_enums_1.NotificationChannelEnum.WEBHOOK
|
|
620
|
-
: channel === 'IN_APP'
|
|
621
|
-
? notification_enums_1.NotificationChannelEnum.IN_APP
|
|
622
|
-
: null)
|
|
623
|
-
.filter((channel) => Boolean(channel));
|
|
624
|
-
return channels.length ? channels : options.defaultChannels;
|
|
625
|
-
}
|
|
626
|
-
function normalizeNotificationChannels(channels) {
|
|
627
|
-
const normalizedChannels = channels
|
|
628
|
-
.map((channel) => channel === notification_enums_1.NotificationChannelEnum.EMAIL
|
|
629
|
-
? notification_enums_1.NotificationChannelEnum.EMAIL
|
|
630
|
-
: channel === notification_enums_1.NotificationChannelEnum.IN_APP
|
|
631
|
-
? notification_enums_1.NotificationChannelEnum.IN_APP
|
|
632
|
-
: null)
|
|
633
|
-
.filter((channel) => Boolean(channel));
|
|
634
|
-
return normalizedChannels.length
|
|
635
|
-
? normalizedChannels
|
|
636
|
-
: [notification_enums_1.NotificationChannelEnum.IN_APP];
|
|
637
|
-
}
|
|
638
|
-
function uniqueStrings(values) {
|
|
639
|
-
return Array.from(new Set(values));
|
|
640
|
-
}
|
|
641
|
-
function isUniqueConstraintViolation(error) {
|
|
642
|
-
return (typeof error === 'object' &&
|
|
643
|
-
error !== null &&
|
|
644
|
-
'code' in error &&
|
|
645
|
-
error.code === '23505');
|
|
646
|
-
}
|
|
647
|
-
function isChannelEnabled(channel, preference, options) {
|
|
648
|
-
if (channel === notification_enums_1.NotificationChannelEnum.IN_APP) {
|
|
649
|
-
return options.inAppEnabled && preference.inAppEnabled;
|
|
650
|
-
}
|
|
651
|
-
if (channel === notification_enums_1.NotificationChannelEnum.EMAIL) {
|
|
652
|
-
return options.emailEnabled && preference.emailEnabled;
|
|
653
|
-
}
|
|
654
|
-
return options.webhookEnabled;
|
|
655
|
-
}
|
|
656
|
-
function isSlaTimeoutActionEnabled(action, options) {
|
|
657
|
-
if (action === 'AUTO_APPROVE') {
|
|
658
|
-
return options.slaTimeoutAutoApproveEnabled;
|
|
659
|
-
}
|
|
660
|
-
if (action === 'ESCALATE') {
|
|
661
|
-
return options.slaTimeoutEscalateEnabled;
|
|
662
|
-
}
|
|
663
|
-
if (action === 'TERMINATE_INSTANCE') {
|
|
664
|
-
return options.slaTimeoutTerminateInstanceEnabled;
|
|
665
|
-
}
|
|
666
|
-
return options.slaTimeoutRemindEnabled;
|
|
667
|
-
}
|
|
668
|
-
function createNotificationEntity({ channel, input, options, repository, }) {
|
|
669
|
-
const renderedTemplate = (0, notification_template_1.renderNotificationTemplate)({
|
|
670
|
-
customTemplate: input.customTemplate,
|
|
671
|
-
engine: options.templateEngine,
|
|
672
|
-
payload: input.payload,
|
|
673
|
-
type: input.type,
|
|
674
|
-
});
|
|
675
|
-
const isInApp = channel === notification_enums_1.NotificationChannelEnum.IN_APP;
|
|
676
|
-
return repository.create({
|
|
677
|
-
attemptCount: 0,
|
|
678
|
-
body: renderedTemplate.body,
|
|
679
|
-
channel,
|
|
680
|
-
deliveredAt: isInApp ? new Date() : null,
|
|
681
|
-
deliveryError: null,
|
|
682
|
-
deliveryTarget: null,
|
|
683
|
-
instanceId: input.instanceId,
|
|
684
|
-
lastAttemptAt: null,
|
|
685
|
-
nextRetryAt: null,
|
|
686
|
-
payload: input.payload,
|
|
687
|
-
readAt: null,
|
|
688
|
-
recipientMemberId: input.recipientMemberId,
|
|
689
|
-
resolution: null,
|
|
690
|
-
resolvedAt: null,
|
|
691
|
-
sentAt: isInApp ? new Date() : null,
|
|
692
|
-
status: isInApp
|
|
693
|
-
? notification_enums_1.NotificationStatusEnum.SENT
|
|
694
|
-
: notification_enums_1.NotificationStatusEnum.PENDING,
|
|
695
|
-
taskId: input.taskId,
|
|
696
|
-
title: renderedTemplate.title,
|
|
697
|
-
type: input.type,
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
function readUserTaskNode(instance, nodeId) {
|
|
701
|
-
const node = instance.workflowSnapshot.nodes.find((candidate) => candidate.id === nodeId);
|
|
702
|
-
return node?.type === 'userTask' ? node : null;
|
|
703
|
-
}
|
|
704
|
-
function normalizePage(page) {
|
|
705
|
-
return Number.isInteger(page) && page > 0 ? page : 1;
|
|
706
|
-
}
|
|
707
|
-
function normalizePageSize(pageSize) {
|
|
708
|
-
if (!Number.isInteger(pageSize)) {
|
|
709
|
-
return 10;
|
|
710
|
-
}
|
|
711
|
-
return Math.min(Math.max(pageSize, 1), 100);
|
|
712
|
-
}
|
|
713
|
-
//# sourceMappingURL=notification.service.js.map
|