@things-factory/compliance 0.0.0-stage → 10.1.255
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/dist-client/bootstrap.d.ts +2 -0
- package/dist-client/bootstrap.js +28 -0
- package/dist-client/bootstrap.js.map +1 -0
- package/dist-client/components/compliance-case-form.d.ts +42 -0
- package/dist-client/components/compliance-case-form.js +313 -0
- package/dist-client/components/compliance-case-form.js.map +1 -0
- package/dist-client/components/compliance-case-sheet.d.ts +35 -0
- package/dist-client/components/compliance-case-sheet.js +335 -0
- package/dist-client/components/compliance-case-sheet.js.map +1 -0
- package/dist-client/components/compliance-my-inventions.d.ts +17 -0
- package/dist-client/components/compliance-my-inventions.js +133 -0
- package/dist-client/components/compliance-my-inventions.js.map +1 -0
- package/dist-client/components/compliance-my-privacy-requests.d.ts +34 -0
- package/dist-client/components/compliance-my-privacy-requests.js +232 -0
- package/dist-client/components/compliance-my-privacy-requests.js.map +1 -0
- package/dist-client/components/compliance-my-reports.d.ts +19 -0
- package/dist-client/components/compliance-my-reports.js +137 -0
- package/dist-client/components/compliance-my-reports.js.map +1 -0
- package/dist-client/components/guide-link.d.ts +13 -0
- package/dist-client/components/guide-link.js +55 -0
- package/dist-client/components/guide-link.js.map +1 -0
- package/dist-client/components/invention-report-form.d.ts +30 -0
- package/dist-client/components/invention-report-form.js +188 -0
- package/dist-client/components/invention-report-form.js.map +1 -0
- package/dist-client/components/legal-todo.d.ts +10 -0
- package/dist-client/components/legal-todo.js +43 -0
- package/dist-client/components/legal-todo.js.map +1 -0
- package/dist-client/components/my-trainings.d.ts +18 -0
- package/dist-client/components/my-trainings.js +149 -0
- package/dist-client/components/my-trainings.js.map +1 -0
- package/dist-client/components/regulation-form.d.ts +26 -0
- package/dist-client/components/regulation-form.js +161 -0
- package/dist-client/components/regulation-form.js.map +1 -0
- package/dist-client/components/seal-use-form.d.ts +47 -0
- package/dist-client/components/seal-use-form.js +300 -0
- package/dist-client/components/seal-use-form.js.map +1 -0
- package/dist-client/components/training-attendance-form.d.ts +37 -0
- package/dist-client/components/training-attendance-form.js +186 -0
- package/dist-client/components/training-attendance-form.js.map +1 -0
- package/dist-client/components/training-certificate-form.d.ts +41 -0
- package/dist-client/components/training-certificate-form.js +198 -0
- package/dist-client/components/training-certificate-form.js.map +1 -0
- package/dist-client/components/training-session-form.d.ts +39 -0
- package/dist-client/components/training-session-form.js +270 -0
- package/dist-client/components/training-session-form.js.map +1 -0
- package/dist-client/components/training-setting-form.d.ts +45 -0
- package/dist-client/components/training-setting-form.js +175 -0
- package/dist-client/components/training-setting-form.js.map +1 -0
- package/dist-client/index.d.ts +4 -0
- package/dist-client/index.js +8 -0
- package/dist-client/index.js.map +1 -0
- package/dist-client/legal-record/dispute-calendar-source.d.ts +1 -0
- package/dist-client/legal-record/dispute-calendar-source.js +51 -0
- package/dist-client/legal-record/dispute-calendar-source.js.map +1 -0
- package/dist-client/legal-record/legal-child-grid.d.ts +31 -0
- package/dist-client/legal-record/legal-child-grid.js +76 -0
- package/dist-client/legal-record/legal-child-grid.js.map +1 -0
- package/dist-client/legal-record/legal-codes.d.ts +3 -0
- package/dist-client/legal-record/legal-codes.js +5 -0
- package/dist-client/legal-record/legal-codes.js.map +1 -0
- package/dist-client/legal-record/legal-grid.d.ts +59 -0
- package/dist-client/legal-record/legal-grid.js +68 -0
- package/dist-client/legal-record/legal-grid.js.map +1 -0
- package/dist-client/legal-record/legal-record-files.d.ts +26 -0
- package/dist-client/legal-record/legal-record-files.js +162 -0
- package/dist-client/legal-record/legal-record-files.js.map +1 -0
- package/dist-client/pages/compliance-case-list.d.ts +35 -0
- package/dist-client/pages/compliance-case-list.js +112 -0
- package/dist-client/pages/compliance-case-list.js.map +1 -0
- package/dist-client/pages/dispute-list.d.ts +57 -0
- package/dist-client/pages/dispute-list.js +156 -0
- package/dist-client/pages/dispute-list.js.map +1 -0
- package/dist-client/pages/invention-list.d.ts +57 -0
- package/dist-client/pages/invention-list.js +166 -0
- package/dist-client/pages/invention-list.js.map +1 -0
- package/dist-client/pages/legal-registration-list.d.ts +63 -0
- package/dist-client/pages/legal-registration-list.js +206 -0
- package/dist-client/pages/legal-registration-list.js.map +1 -0
- package/dist-client/pages/privacy-record-list.d.ts +52 -0
- package/dist-client/pages/privacy-record-list.js +225 -0
- package/dist-client/pages/privacy-record-list.js.map +1 -0
- package/dist-client/pages/regulation-detail.d.ts +43 -0
- package/dist-client/pages/regulation-detail.js +370 -0
- package/dist-client/pages/regulation-detail.js.map +1 -0
- package/dist-client/pages/regulation-list.d.ts +52 -0
- package/dist-client/pages/regulation-list.js +144 -0
- package/dist-client/pages/regulation-list.js.map +1 -0
- package/dist-client/pages/regulations.d.ts +49 -0
- package/dist-client/pages/regulations.js +412 -0
- package/dist-client/pages/regulations.js.map +1 -0
- package/dist-client/pages/seal-use-list.d.ts +57 -0
- package/dist-client/pages/seal-use-list.js +168 -0
- package/dist-client/pages/seal-use-list.js.map +1 -0
- package/dist-client/pages/training-list.d.ts +51 -0
- package/dist-client/pages/training-list.js +333 -0
- package/dist-client/pages/training-list.js.map +1 -0
- package/dist-client/regulation/regulation-fragments.d.ts +1 -0
- package/dist-client/regulation/regulation-fragments.js +37 -0
- package/dist-client/regulation/regulation-fragments.js.map +1 -0
- package/dist-client/regulation/regulation-guide.d.ts +19 -0
- package/dist-client/regulation/regulation-guide.js +48 -0
- package/dist-client/regulation/regulation-guide.js.map +1 -0
- package/dist-client/route.d.ts +1 -0
- package/dist-client/route.js +36 -0
- package/dist-client/route.js.map +1 -0
- package/dist-client/training-words.d.ts +11 -0
- package/dist-client/training-words.js +11 -0
- package/dist-client/training-words.js.map +1 -0
- package/dist-client/tsconfig.tsbuildinfo +1 -0
- package/dist-client/words.d.ts +15 -0
- package/dist-client/words.js +20 -0
- package/dist-client/words.js.map +1 -0
- package/dist-server/activities/index.d.ts +6 -0
- package/dist-server/activities/index.js +37 -0
- package/dist-server/activities/index.js.map +1 -0
- package/dist-server/activities/legal-todo-activity-names.d.ts +1 -0
- package/dist-server/activities/legal-todo-activity-names.js +5 -0
- package/dist-server/activities/legal-todo-activity-names.js.map +1 -0
- package/dist-server/activities/legal-todo-activity.d.ts +37 -0
- package/dist-server/activities/legal-todo-activity.js +41 -0
- package/dist-server/activities/legal-todo-activity.js.map +1 -0
- package/dist-server/activities/regulation-activity-names.d.ts +1 -0
- package/dist-server/activities/regulation-activity-names.js +5 -0
- package/dist-server/activities/regulation-activity-names.js.map +1 -0
- package/dist-server/activities/regulation-activity.d.ts +48 -0
- package/dist-server/activities/regulation-activity.js +47 -0
- package/dist-server/activities/regulation-activity.js.map +1 -0
- package/dist-server/activities/seal-use-activity-names.d.ts +2 -0
- package/dist-server/activities/seal-use-activity-names.js +6 -0
- package/dist-server/activities/seal-use-activity-names.js.map +1 -0
- package/dist-server/activities/seal-use-activity.d.ts +48 -0
- package/dist-server/activities/seal-use-activity.js +47 -0
- package/dist-server/activities/seal-use-activity.js.map +1 -0
- package/dist-server/index.d.ts +2 -0
- package/dist-server/index.js +21 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/role-tasks.d.ts +2 -0
- package/dist-server/role-tasks.js +28 -0
- package/dist-server/role-tasks.js.map +1 -0
- package/dist-server/service/common/correction.d.ts +32 -0
- package/dist-server/service/common/correction.js +98 -0
- package/dist-server/service/common/correction.js.map +1 -0
- package/dist-server/service/common/employee-reader.d.ts +11 -0
- package/dist-server/service/common/employee-reader.js +46 -0
- package/dist-server/service/common/employee-reader.js.map +1 -0
- package/dist-server/service/common/legal-todo.d.ts +19 -0
- package/dist-server/service/common/legal-todo.js +37 -0
- package/dist-server/service/common/legal-todo.js.map +1 -0
- package/dist-server/service/compliance-case/compliance-case-mutation.d.ts +9 -0
- package/dist-server/service/compliance-case/compliance-case-mutation.js +73 -0
- package/dist-server/service/compliance-case/compliance-case-mutation.js.map +1 -0
- package/dist-server/service/compliance-case/compliance-case-query.d.ts +28 -0
- package/dist-server/service/compliance-case/compliance-case-query.js +212 -0
- package/dist-server/service/compliance-case/compliance-case-query.js.map +1 -0
- package/dist-server/service/compliance-case/compliance-case-rules.d.ts +71 -0
- package/dist-server/service/compliance-case/compliance-case-rules.js +111 -0
- package/dist-server/service/compliance-case/compliance-case-rules.js.map +1 -0
- package/dist-server/service/compliance-case/compliance-case-service.d.ts +76 -0
- package/dist-server/service/compliance-case/compliance-case-service.js +425 -0
- package/dist-server/service/compliance-case/compliance-case-service.js.map +1 -0
- package/dist-server/service/compliance-case/compliance-case-type.d.ts +56 -0
- package/dist-server/service/compliance-case/compliance-case-type.js +200 -0
- package/dist-server/service/compliance-case/compliance-case-type.js.map +1 -0
- package/dist-server/service/compliance-case/compliance-case.d.ts +76 -0
- package/dist-server/service/compliance-case/compliance-case.js +260 -0
- package/dist-server/service/compliance-case/compliance-case.js.map +1 -0
- package/dist-server/service/compliance-case/index.d.ts +7 -0
- package/dist-server/service/compliance-case/index.js +17 -0
- package/dist-server/service/compliance-case/index.js.map +1 -0
- package/dist-server/service/dispute/dispute-mutation.d.ts +9 -0
- package/dist-server/service/dispute/dispute-mutation.js +64 -0
- package/dist-server/service/dispute/dispute-mutation.js.map +1 -0
- package/dist-server/service/dispute/dispute-query.d.ts +16 -0
- package/dist-server/service/dispute/dispute-query.js +124 -0
- package/dist-server/service/dispute/dispute-query.js.map +1 -0
- package/dist-server/service/dispute/dispute-rules.d.ts +20 -0
- package/dist-server/service/dispute/dispute-rules.js +42 -0
- package/dist-server/service/dispute/dispute-rules.js.map +1 -0
- package/dist-server/service/dispute/dispute-service.d.ts +17 -0
- package/dist-server/service/dispute/dispute-service.js +96 -0
- package/dist-server/service/dispute/dispute-service.js.map +1 -0
- package/dist-server/service/dispute/dispute-type.d.ts +39 -0
- package/dist-server/service/dispute/dispute-type.js +149 -0
- package/dist-server/service/dispute/dispute-type.js.map +1 -0
- package/dist-server/service/dispute/dispute.d.ts +48 -0
- package/dist-server/service/dispute/dispute.js +198 -0
- package/dist-server/service/dispute/dispute.js.map +1 -0
- package/dist-server/service/dispute/index.d.ts +5 -0
- package/dist-server/service/dispute/index.js +9 -0
- package/dist-server/service/dispute/index.js.map +1 -0
- package/dist-server/service/index.d.ts +46 -0
- package/dist-server/service/index.js +112 -0
- package/dist-server/service/index.js.map +1 -0
- package/dist-server/service/invention/index.d.ts +5 -0
- package/dist-server/service/invention/index.js +9 -0
- package/dist-server/service/invention/index.js.map +1 -0
- package/dist-server/service/invention/invention-mutation.d.ts +10 -0
- package/dist-server/service/invention/invention-mutation.js +79 -0
- package/dist-server/service/invention/invention-mutation.js.map +1 -0
- package/dist-server/service/invention/invention-query.d.ts +18 -0
- package/dist-server/service/invention/invention-query.js +141 -0
- package/dist-server/service/invention/invention-query.js.map +1 -0
- package/dist-server/service/invention/invention-rules.d.ts +28 -0
- package/dist-server/service/invention/invention-rules.js +54 -0
- package/dist-server/service/invention/invention-rules.js.map +1 -0
- package/dist-server/service/invention/invention-service.d.ts +25 -0
- package/dist-server/service/invention/invention-service.js +176 -0
- package/dist-server/service/invention/invention-service.js.map +1 -0
- package/dist-server/service/invention/invention-type.d.ts +34 -0
- package/dist-server/service/invention/invention-type.js +129 -0
- package/dist-server/service/invention/invention-type.js.map +1 -0
- package/dist-server/service/invention/invention.d.ts +55 -0
- package/dist-server/service/invention/invention.js +214 -0
- package/dist-server/service/invention/invention.js.map +1 -0
- package/dist-server/service/legal-record/attachment-readers.d.ts +1 -0
- package/dist-server/service/legal-record/attachment-readers.js +27 -0
- package/dist-server/service/legal-record/attachment-readers.js.map +1 -0
- package/dist-server/service/legal-record/days.d.ts +7 -0
- package/dist-server/service/legal-record/days.js +26 -0
- package/dist-server/service/legal-record/days.js.map +1 -0
- package/dist-server/service/legal-record/legal-record-support.d.ts +24 -0
- package/dist-server/service/legal-record/legal-record-support.js +51 -0
- package/dist-server/service/legal-record/legal-record-support.js.map +1 -0
- package/dist-server/service/legal-registration/centre-change-subscriber.d.ts +9 -0
- package/dist-server/service/legal-registration/centre-change-subscriber.js +50 -0
- package/dist-server/service/legal-registration/centre-change-subscriber.js.map +1 -0
- package/dist-server/service/legal-registration/index.d.ts +7 -0
- package/dist-server/service/legal-registration/index.js +11 -0
- package/dist-server/service/legal-registration/index.js.map +1 -0
- package/dist-server/service/legal-registration/legal-registration-mutation.d.ts +10 -0
- package/dist-server/service/legal-registration/legal-registration-mutation.js +77 -0
- package/dist-server/service/legal-registration/legal-registration-mutation.js.map +1 -0
- package/dist-server/service/legal-registration/legal-registration-query.d.ts +26 -0
- package/dist-server/service/legal-registration/legal-registration-query.js +199 -0
- package/dist-server/service/legal-registration/legal-registration-query.js.map +1 -0
- package/dist-server/service/legal-registration/legal-registration-rules.d.ts +80 -0
- package/dist-server/service/legal-registration/legal-registration-rules.js +106 -0
- package/dist-server/service/legal-registration/legal-registration-rules.js.map +1 -0
- package/dist-server/service/legal-registration/legal-registration-service.d.ts +37 -0
- package/dist-server/service/legal-registration/legal-registration-service.js +248 -0
- package/dist-server/service/legal-registration/legal-registration-service.js.map +1 -0
- package/dist-server/service/legal-registration/legal-registration-type.d.ts +55 -0
- package/dist-server/service/legal-registration/legal-registration-type.js +207 -0
- package/dist-server/service/legal-registration/legal-registration-type.js.map +1 -0
- package/dist-server/service/legal-registration/legal-registration.d.ts +76 -0
- package/dist-server/service/legal-registration/legal-registration.js +311 -0
- package/dist-server/service/legal-registration/legal-registration.js.map +1 -0
- package/dist-server/service/privacy-record/index.d.ts +5 -0
- package/dist-server/service/privacy-record/index.js +9 -0
- package/dist-server/service/privacy-record/index.js.map +1 -0
- package/dist-server/service/privacy-record/privacy-record-mutation.d.ts +7 -0
- package/dist-server/service/privacy-record/privacy-record-mutation.js +56 -0
- package/dist-server/service/privacy-record/privacy-record-mutation.js.map +1 -0
- package/dist-server/service/privacy-record/privacy-record-query.d.ts +18 -0
- package/dist-server/service/privacy-record/privacy-record-query.js +131 -0
- package/dist-server/service/privacy-record/privacy-record-query.js.map +1 -0
- package/dist-server/service/privacy-record/privacy-record-rules.d.ts +52 -0
- package/dist-server/service/privacy-record/privacy-record-rules.js +91 -0
- package/dist-server/service/privacy-record/privacy-record-rules.js.map +1 -0
- package/dist-server/service/privacy-record/privacy-record-service.d.ts +33 -0
- package/dist-server/service/privacy-record/privacy-record-service.js +133 -0
- package/dist-server/service/privacy-record/privacy-record-service.js.map +1 -0
- package/dist-server/service/privacy-record/privacy-record-type.d.ts +40 -0
- package/dist-server/service/privacy-record/privacy-record-type.js +153 -0
- package/dist-server/service/privacy-record/privacy-record-type.js.map +1 -0
- package/dist-server/service/privacy-record/privacy-record.d.ts +69 -0
- package/dist-server/service/privacy-record/privacy-record.js +245 -0
- package/dist-server/service/privacy-record/privacy-record.js.map +1 -0
- package/dist-server/service/regulation/index.d.ts +5 -0
- package/dist-server/service/regulation/index.js +9 -0
- package/dist-server/service/regulation/index.js.map +1 -0
- package/dist-server/service/regulation/regulation-mutation.d.ts +15 -0
- package/dist-server/service/regulation/regulation-mutation.js +152 -0
- package/dist-server/service/regulation/regulation-mutation.js.map +1 -0
- package/dist-server/service/regulation/regulation-query.d.ts +10 -0
- package/dist-server/service/regulation/regulation-query.js +109 -0
- package/dist-server/service/regulation/regulation-query.js.map +1 -0
- package/dist-server/service/regulation/regulation-read.d.ts +21 -0
- package/dist-server/service/regulation/regulation-read.js +111 -0
- package/dist-server/service/regulation/regulation-read.js.map +1 -0
- package/dist-server/service/regulation/regulation-rules.d.ts +83 -0
- package/dist-server/service/regulation/regulation-rules.js +170 -0
- package/dist-server/service/regulation/regulation-rules.js.map +1 -0
- package/dist-server/service/regulation/regulation-service.d.ts +63 -0
- package/dist-server/service/regulation/regulation-service.js +365 -0
- package/dist-server/service/regulation/regulation-service.js.map +1 -0
- package/dist-server/service/regulation/regulation-type.d.ts +61 -0
- package/dist-server/service/regulation/regulation-type.js +226 -0
- package/dist-server/service/regulation/regulation-type.js.map +1 -0
- package/dist-server/service/regulation/regulation.d.ts +113 -0
- package/dist-server/service/regulation/regulation.js +382 -0
- package/dist-server/service/regulation/regulation.js.map +1 -0
- package/dist-server/service/seal-use/index.d.ts +5 -0
- package/dist-server/service/seal-use/index.js +9 -0
- package/dist-server/service/seal-use/index.js.map +1 -0
- package/dist-server/service/seal-use/seal-use-mutation.d.ts +8 -0
- package/dist-server/service/seal-use/seal-use-mutation.js +69 -0
- package/dist-server/service/seal-use/seal-use-mutation.js.map +1 -0
- package/dist-server/service/seal-use/seal-use-query.d.ts +14 -0
- package/dist-server/service/seal-use/seal-use-query.js +100 -0
- package/dist-server/service/seal-use/seal-use-query.js.map +1 -0
- package/dist-server/service/seal-use/seal-use-rules.d.ts +35 -0
- package/dist-server/service/seal-use/seal-use-rules.js +64 -0
- package/dist-server/service/seal-use/seal-use-rules.js.map +1 -0
- package/dist-server/service/seal-use/seal-use-service.d.ts +20 -0
- package/dist-server/service/seal-use/seal-use-service.js +168 -0
- package/dist-server/service/seal-use/seal-use-service.js.map +1 -0
- package/dist-server/service/seal-use/seal-use-type.d.ts +24 -0
- package/dist-server/service/seal-use/seal-use-type.js +93 -0
- package/dist-server/service/seal-use/seal-use-type.js.map +1 -0
- package/dist-server/service/seal-use/seal-use.d.ts +57 -0
- package/dist-server/service/seal-use/seal-use.js +181 -0
- package/dist-server/service/seal-use/seal-use.js.map +1 -0
- package/dist-server/service/training/index.d.ts +5 -0
- package/dist-server/service/training/index.js +9 -0
- package/dist-server/service/training/index.js.map +1 -0
- package/dist-server/service/training/training-checks.d.ts +20 -0
- package/dist-server/service/training/training-checks.js +56 -0
- package/dist-server/service/training/training-checks.js.map +1 -0
- package/dist-server/service/training/training-kinds.d.ts +24 -0
- package/dist-server/service/training/training-kinds.js +42 -0
- package/dist-server/service/training/training-kinds.js.map +1 -0
- package/dist-server/service/training/training-mutation.d.ts +14 -0
- package/dist-server/service/training/training-mutation.js +140 -0
- package/dist-server/service/training/training-mutation.js.map +1 -0
- package/dist-server/service/training/training-query.d.ts +21 -0
- package/dist-server/service/training/training-query.js +196 -0
- package/dist-server/service/training/training-query.js.map +1 -0
- package/dist-server/service/training/training-read.d.ts +5 -0
- package/dist-server/service/training/training-read.js +35 -0
- package/dist-server/service/training/training-read.js.map +1 -0
- package/dist-server/service/training/training-register.d.ts +1 -0
- package/dist-server/service/training/training-register.js +27 -0
- package/dist-server/service/training/training-register.js.map +1 -0
- package/dist-server/service/training/training-rules.d.ts +72 -0
- package/dist-server/service/training/training-rules.js +143 -0
- package/dist-server/service/training/training-rules.js.map +1 -0
- package/dist-server/service/training/training-service.d.ts +98 -0
- package/dist-server/service/training/training-service.js +455 -0
- package/dist-server/service/training/training-service.js.map +1 -0
- package/dist-server/service/training/training-type.d.ts +94 -0
- package/dist-server/service/training/training-type.js +352 -0
- package/dist-server/service/training/training-type.js.map +1 -0
- package/dist-server/service/training/training.d.ts +127 -0
- package/dist-server/service/training/training.js +448 -0
- package/dist-server/service/training/training.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/package.json +61 -4
- package/things-factory.config.js +19 -0
- package/translations/en.json +612 -0
- package/translations/es.json +612 -0
- package/translations/ja.json +612 -0
- package/translations/ko.json +612 -0
- package/translations/ms.json +612 -0
- package/translations/zh.json +612 -0
- package/README.md +0 -3
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SealUseQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
8
|
+
const organization_1 = require("@things-factory/organization");
|
|
9
|
+
const shell_1 = require("@things-factory/shell");
|
|
10
|
+
const seal_use_1 = require("./seal-use");
|
|
11
|
+
const seal_use_type_1 = require("./seal-use-type");
|
|
12
|
+
/** The list's own narrowings - a seal let out and not back, the certificates still accepted - asked by name, answered here. */
|
|
13
|
+
const OWN_FILTERS = ['unreturned', 'usable'];
|
|
14
|
+
let SealUseQuery = class SealUseQuery {
|
|
15
|
+
async sealUses(params, context) {
|
|
16
|
+
const { domain } = context.state;
|
|
17
|
+
const asked = (name) => params.filters?.some(one => one.name === name && one.value !== false);
|
|
18
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
19
|
+
domain,
|
|
20
|
+
params: { ...params, filters: params.filters?.filter(one => !OWN_FILTERS.includes(one.name)) },
|
|
21
|
+
repository: (0, shell_1.getRepository)(seal_use_1.SealUse),
|
|
22
|
+
searchables: ['document', 'purpose', 'submittedTo', 'notes'],
|
|
23
|
+
alias: 'use',
|
|
24
|
+
defaultSortings: [{ name: 'usedOn', desc: true }]
|
|
25
|
+
});
|
|
26
|
+
if (asked('unreturned'))
|
|
27
|
+
queryBuilder.andWhere('use.kind = :takeOut AND use.status = :approved AND use.returnedOn IS NULL', { takeOut: seal_use_1.SealUseKind.TAKE_OUT, approved: seal_use_1.SealUseStatus.APPROVED });
|
|
28
|
+
if (asked('usable'))
|
|
29
|
+
queryBuilder
|
|
30
|
+
.andWhere('use.kind = :certificate AND use.usableUntil >= :today', { certificate: seal_use_1.SealUseKind.CERTIFICATE, today: (0, shell_1.calendarDay)(domain.timezone) })
|
|
31
|
+
.andWhere('use.status IN (:...given)', { given: [seal_use_1.SealUseStatus.APPROVED, seal_use_1.SealUseStatus.RECORDED] });
|
|
32
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
33
|
+
return { items, total };
|
|
34
|
+
}
|
|
35
|
+
async seal(row) {
|
|
36
|
+
return row.sealId ? await (0, shell_1.getRepository)(biz_base_1.CompanySeal).findOne({ where: { id: row.sealId } }) : null;
|
|
37
|
+
}
|
|
38
|
+
async requester(row) {
|
|
39
|
+
return row.requesterId ? await (0, shell_1.getRepository)(organization_1.Employee).findOne({ where: { id: row.requesterId } }) : null;
|
|
40
|
+
}
|
|
41
|
+
async decidedBy(row) {
|
|
42
|
+
return row.decidedById ? await (0, shell_1.getRepository)(auth_base_1.User).findOne({ where: { id: row.decidedById } }) : null;
|
|
43
|
+
}
|
|
44
|
+
async creator(row) {
|
|
45
|
+
return row.creatorId ? await (0, shell_1.getRepository)(auth_base_1.User).findOne({ where: { id: row.creatorId } }) : null;
|
|
46
|
+
}
|
|
47
|
+
async updater(row) {
|
|
48
|
+
return row.updaterId ? await (0, shell_1.getRepository)(auth_base_1.User).findOne({ where: { id: row.updaterId } }) : null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.SealUseQuery = SealUseQuery;
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, type_graphql_1.Directive)('@privilege(category: "seal-use", privilege: "query", domainOwnerGranted: true)'),
|
|
54
|
+
(0, type_graphql_1.Query)(returns => seal_use_type_1.SealUseList, { description: '날인 기록 - the uses of the seals: stamped, taken out, certificates issued (ADR-0188)' }),
|
|
55
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
|
56
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
57
|
+
tslib_1.__metadata("design:type", Function),
|
|
58
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
59
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
60
|
+
], SealUseQuery.prototype, "sealUses", null);
|
|
61
|
+
tslib_1.__decorate([
|
|
62
|
+
(0, type_graphql_1.FieldResolver)(type => biz_base_1.CompanySeal, { nullable: true }),
|
|
63
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
64
|
+
tslib_1.__metadata("design:type", Function),
|
|
65
|
+
tslib_1.__metadata("design:paramtypes", [seal_use_1.SealUse]),
|
|
66
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
67
|
+
], SealUseQuery.prototype, "seal", null);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.FieldResolver)(type => organization_1.Employee, { nullable: true }),
|
|
70
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
71
|
+
tslib_1.__metadata("design:type", Function),
|
|
72
|
+
tslib_1.__metadata("design:paramtypes", [seal_use_1.SealUse]),
|
|
73
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
74
|
+
], SealUseQuery.prototype, "requester", null);
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
77
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
78
|
+
tslib_1.__metadata("design:type", Function),
|
|
79
|
+
tslib_1.__metadata("design:paramtypes", [seal_use_1.SealUse]),
|
|
80
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
81
|
+
], SealUseQuery.prototype, "decidedBy", null);
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
84
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
85
|
+
tslib_1.__metadata("design:type", Function),
|
|
86
|
+
tslib_1.__metadata("design:paramtypes", [seal_use_1.SealUse]),
|
|
87
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
88
|
+
], SealUseQuery.prototype, "creator", null);
|
|
89
|
+
tslib_1.__decorate([
|
|
90
|
+
(0, type_graphql_1.FieldResolver)(type => auth_base_1.User, { nullable: true }),
|
|
91
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
92
|
+
tslib_1.__metadata("design:type", Function),
|
|
93
|
+
tslib_1.__metadata("design:paramtypes", [seal_use_1.SealUse]),
|
|
94
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
95
|
+
], SealUseQuery.prototype, "updater", null);
|
|
96
|
+
exports.SealUseQuery = SealUseQuery = tslib_1.__decorate([
|
|
97
|
+
(0, type_graphql_1.Resolver)(seal_use_1.SealUse),
|
|
98
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
99
|
+
], SealUseQuery);
|
|
100
|
+
//# sourceMappingURL=seal-use-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal-use-query.js","sourceRoot":"","sources":["../../../server/service/seal-use/seal-use-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwG;AAExG,yDAAgD;AAChD,uDAAsD;AACtD,+DAAuD;AACvD,iDAA2H;AAE3H,yCAAgE;AAChE,mDAA6C;AAE7C,+HAA+H;AAC/H,MAAM,WAAW,GAAG,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;AAIrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAGjB,AAAN,KAAK,CAAC,QAAQ,CAA0B,MAAiB,EAAS,OAAwB;QACxF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;QACrG,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE;YAC9F,UAAU,EAAE,IAAA,qBAAa,EAAC,kBAAO,CAAC;YAClC,WAAW,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,OAAO,CAAC;YAC5D,KAAK,EAAE,KAAK;YACZ,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;SAClD,CAAC,CAAA;QACF,IAAI,KAAK,CAAC,YAAY,CAAC;YACrB,YAAY,CAAC,QAAQ,CAAC,2EAA2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I,EAAE,CAAC;IACnC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,kBAAO;;6CAEnC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/B,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,kBAAO;;6CAEnC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,kBAAO;;2CAEjC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAM,kBAAO;;2CAEjC;uBA/CU,YAAY;IAFxB,IAAA,uBAAQ,EAAC,kBAAO,CAAC;IACjB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,YAAY,CAgDxB","sourcesContent":["import { Args, Ctx, Directive, FieldResolver, Query, Resolver, Root, UseMiddleware } from 'type-graphql'\n\nimport { User } from '@things-factory/auth-base'\nimport { CompanySeal } from '@things-factory/biz-base'\nimport { Employee } from '@things-factory/organization'\nimport { calendarDay, getQueryBuilderFromListParams, getRepository, ListParam, SpeakRefusals } from '@things-factory/shell'\n\nimport { SealUse, SealUseKind, SealUseStatus } from './seal-use'\nimport { SealUseList } from './seal-use-type'\n\n/** The list's own narrowings - a seal let out and not back, the certificates still accepted - asked by name, answered here. */\nconst OWN_FILTERS = ['unreturned', 'usable']\n\n@Resolver(SealUse)\n@UseMiddleware(SpeakRefusals)\nexport class SealUseQuery {\n @Directive('@privilege(category: \"seal-use\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => SealUseList, { description: '날인 기록 - the uses of the seals: stamped, taken out, certificates issued (ADR-0188)' })\n async sealUses(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<SealUseList> {\n const { domain } = context.state\n const asked = (name: string) => params.filters?.some(one => one.name === name && one.value !== false)\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params: { ...params, filters: params.filters?.filter(one => !OWN_FILTERS.includes(one.name)) },\n repository: getRepository(SealUse),\n searchables: ['document', 'purpose', 'submittedTo', 'notes'],\n alias: 'use',\n defaultSortings: [{ name: 'usedOn', desc: true }]\n })\n if (asked('unreturned'))\n queryBuilder.andWhere('use.kind = :takeOut AND use.status = :approved AND use.returnedOn IS NULL', { takeOut: SealUseKind.TAKE_OUT, approved: SealUseStatus.APPROVED })\n if (asked('usable'))\n queryBuilder\n .andWhere('use.kind = :certificate AND use.usableUntil >= :today', { certificate: SealUseKind.CERTIFICATE, today: calendarDay(domain.timezone) })\n .andWhere('use.status IN (:...given)', { given: [SealUseStatus.APPROVED, SealUseStatus.RECORDED] })\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @FieldResolver(type => CompanySeal, { nullable: true })\n async seal(@Root() row: SealUse): Promise<CompanySeal | null> {\n return row.sealId ? await getRepository(CompanySeal).findOne({ where: { id: row.sealId } }) : null\n }\n\n @FieldResolver(type => Employee, { nullable: true })\n async requester(@Root() row: SealUse): Promise<Employee | null> {\n return row.requesterId ? await getRepository(Employee).findOne({ where: { id: row.requesterId } }) : null\n }\n\n @FieldResolver(type => User, { nullable: true })\n async decidedBy(@Root() row: SealUse): Promise<User | null> {\n return row.decidedById ? await getRepository(User).findOne({ where: { id: row.decidedById } }) : null\n }\n\n @FieldResolver(type => User, { nullable: true })\n async creator(@Root() row: SealUse): Promise<User | null> {\n return row.creatorId ? await getRepository(User).findOne({ where: { id: row.creatorId } }) : null\n }\n\n @FieldResolver(type => User, { nullable: true })\n async updater(@Root() row: SealUse): Promise<User | null> {\n return row.updaterId ? await getRepository(User).findOne({ where: { id: row.updaterId } }) : null\n }\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Refusal } from '@things-factory/shell';
|
|
2
|
+
export interface SealUseInput {
|
|
3
|
+
kind?: string | null;
|
|
4
|
+
usedOn?: string | null;
|
|
5
|
+
document?: string | null;
|
|
6
|
+
purpose?: string | null;
|
|
7
|
+
submittedTo?: string | null;
|
|
8
|
+
returnDueOn?: string | null;
|
|
9
|
+
copies?: number | null;
|
|
10
|
+
}
|
|
11
|
+
export interface SealOfUse {
|
|
12
|
+
kind: string;
|
|
13
|
+
name: string;
|
|
14
|
+
disposedOn?: string | null;
|
|
15
|
+
}
|
|
16
|
+
/** The corporate seal's every use, and every taking out, is approved; a use seal or the official stamp stamped in the office is written down. */
|
|
17
|
+
export declare function needsApproval(kind: string, sealKind: string): boolean;
|
|
18
|
+
/** What a recorded use asks for before it is written, or nothing. */
|
|
19
|
+
export declare function sealUseRefusal(input: SealUseInput, seal: SealOfUse | null): Refusal | null;
|
|
20
|
+
/**
|
|
21
|
+
* The day certificates are accepted until when nobody says otherwise - three months from their issue, the last day of
|
|
22
|
+
* the month when the month is shorter. A certificate has no validity in law; those it goes to mostly ask for one issued
|
|
23
|
+
* within three months.
|
|
24
|
+
*/
|
|
25
|
+
export declare function usableUntilOf(issuedOn: string): string;
|
|
26
|
+
/** A use taken out, let go, and not back yet. */
|
|
27
|
+
export declare function unreturned(row: {
|
|
28
|
+
kind: string;
|
|
29
|
+
status: string;
|
|
30
|
+
returnedOn?: string | null;
|
|
31
|
+
}): boolean;
|
|
32
|
+
/** What may still change on a written use: when it came back, and the notes. What the approvers saw stays. */
|
|
33
|
+
export declare const AFTER_WRITTEN: readonly ["returnedOn", "notes"];
|
|
34
|
+
/** A use that may be deleted - one nobody approved: written without approval, or rejected or withdrawn. */
|
|
35
|
+
export declare function deletable(status: string): boolean;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AFTER_WRITTEN = void 0;
|
|
4
|
+
exports.needsApproval = needsApproval;
|
|
5
|
+
exports.sealUseRefusal = sealUseRefusal;
|
|
6
|
+
exports.usableUntilOf = usableUntilOf;
|
|
7
|
+
exports.unreturned = unreturned;
|
|
8
|
+
exports.deletable = deletable;
|
|
9
|
+
const shell_1 = require("@things-factory/shell");
|
|
10
|
+
const KINDS = ['STAMP', 'TAKE_OUT', 'CERTIFICATE'];
|
|
11
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
12
|
+
/** The corporate seal's every use, and every taking out, is approved; a use seal or the official stamp stamped in the office is written down. */
|
|
13
|
+
function needsApproval(kind, sealKind) {
|
|
14
|
+
return sealKind === 'CORPORATE' || kind !== 'STAMP';
|
|
15
|
+
}
|
|
16
|
+
/** What a recorded use asks for before it is written, or nothing. */
|
|
17
|
+
function sealUseRefusal(input, seal) {
|
|
18
|
+
if (!KINDS.includes(input.kind ?? ''))
|
|
19
|
+
return new shell_1.Refusal('seal-use-kind-required', {}, 'pick what was done - stamped, taken out, or a certificate');
|
|
20
|
+
if (!seal)
|
|
21
|
+
return new shell_1.Refusal('seal-use-seal-required', {}, 'pick the seal');
|
|
22
|
+
if (seal.disposedOn)
|
|
23
|
+
return new shell_1.Refusal('seal-use-seal-disposed', { seal: seal.name }, `seal ${seal.name} is disposed of`);
|
|
24
|
+
if (input.kind === 'CERTIFICATE' && seal.kind !== 'CORPORATE')
|
|
25
|
+
return new shell_1.Refusal('seal-use-certificate-of-corporate', {}, 'a certificate is of the corporate seal');
|
|
26
|
+
if (!input.usedOn || !DAY.test(input.usedOn))
|
|
27
|
+
return new shell_1.Refusal('seal-use-day-required', {}, 'give the day, YYYY-MM-DD');
|
|
28
|
+
if (input.kind !== 'CERTIFICATE' && !input.document?.trim())
|
|
29
|
+
return new shell_1.Refusal('seal-use-document-required', {}, 'say which paper it is for');
|
|
30
|
+
if (!input.purpose?.trim())
|
|
31
|
+
return new shell_1.Refusal('seal-use-purpose-required', {}, 'say what it is for');
|
|
32
|
+
if (input.kind === 'TAKE_OUT') {
|
|
33
|
+
if (!input.returnDueOn || !DAY.test(input.returnDueOn))
|
|
34
|
+
return new shell_1.Refusal('seal-use-return-due-required', {}, 'give the day it is to be back, YYYY-MM-DD');
|
|
35
|
+
if (input.returnDueOn < input.usedOn)
|
|
36
|
+
return new shell_1.Refusal('seal-use-return-before-out', {}, 'it cannot be due back before it goes out');
|
|
37
|
+
}
|
|
38
|
+
if (input.kind === 'CERTIFICATE' && !(Number.isInteger(input.copies) && input.copies >= 1))
|
|
39
|
+
return new shell_1.Refusal('seal-use-copies-required', {}, 'say how many certificates were issued');
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The day certificates are accepted until when nobody says otherwise - three months from their issue, the last day of
|
|
44
|
+
* the month when the month is shorter. A certificate has no validity in law; those it goes to mostly ask for one issued
|
|
45
|
+
* within three months.
|
|
46
|
+
*/
|
|
47
|
+
function usableUntilOf(issuedOn) {
|
|
48
|
+
const [year, month, day] = issuedOn.split('-').map(Number);
|
|
49
|
+
const target = new Date(Date.UTC(year, month - 1 + 3, 1));
|
|
50
|
+
const last = new Date(Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate();
|
|
51
|
+
target.setUTCDate(Math.min(day, last));
|
|
52
|
+
return target.toISOString().slice(0, 10);
|
|
53
|
+
}
|
|
54
|
+
/** A use taken out, let go, and not back yet. */
|
|
55
|
+
function unreturned(row) {
|
|
56
|
+
return row.kind === 'TAKE_OUT' && row.status === 'APPROVED' && !row.returnedOn;
|
|
57
|
+
}
|
|
58
|
+
/** What may still change on a written use: when it came back, and the notes. What the approvers saw stays. */
|
|
59
|
+
exports.AFTER_WRITTEN = ['returnedOn', 'notes'];
|
|
60
|
+
/** A use that may be deleted - one nobody approved: written without approval, or rejected or withdrawn. */
|
|
61
|
+
function deletable(status) {
|
|
62
|
+
return status === 'RECORDED' || status === 'REJECTED' || status === 'WITHDRAWN';
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=seal-use-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal-use-rules.js","sourceRoot":"","sources":["../../../server/service/seal-use/seal-use-rules.ts"],"names":[],"mappings":";;;AA2BA,sCAEC;AAGD,wCAcC;AAOD,sCAMC;AAGD,gCAEC;AAMD,8BAEC;AAxED,iDAA+C;AAuB/C,MAAM,KAAK,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;AAClD,MAAM,GAAG,GAAG,qBAAqB,CAAA;AAEjC,iJAAiJ;AACjJ,SAAgB,aAAa,CAAC,IAAY,EAAE,QAAgB;IAC1D,OAAO,QAAQ,KAAK,WAAW,IAAI,IAAI,KAAK,OAAO,CAAA;AACrD,CAAC;AAED,qEAAqE;AACrE,SAAgB,cAAc,CAAC,KAAmB,EAAE,IAAsB;IACxE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAAE,OAAO,IAAI,eAAO,CAAC,wBAAwB,EAAE,EAAE,EAAE,2DAA2D,CAAC,CAAA;IACpJ,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,eAAO,CAAC,wBAAwB,EAAE,EAAE,EAAE,eAAe,CAAC,CAAA;IAC5E,IAAI,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,eAAO,CAAC,wBAAwB,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,QAAQ,IAAI,CAAC,IAAI,iBAAiB,CAAC,CAAA;IAC1H,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,eAAO,CAAC,mCAAmC,EAAE,EAAE,EAAE,wCAAwC,CAAC,CAAA;IACpK,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,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AAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACzD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE,EAAE,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAA;IAClG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IACtC,OAAO,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AAC1C,CAAC;AAED,iDAAiD;AACjD,SAAgB,UAAU,CAAC,GAAiE;IAC1F,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,IAAI,GAAG,CAAC,MAAM,KAAK,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAA;AAChF,CAAC;AAED,8GAA8G;AACjG,QAAA,aAAa,GAAG,CAAC,YAAY,EAAE,OAAO,CAAU,CAAA;AAE7D,2GAA2G;AAC3G,SAAgB,SAAS,CAAC,MAAc;IACtC,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,WAAW,CAAA;AACjF,CAAC","sourcesContent":["import { Refusal } from '@things-factory/shell'\n\n/*\n * What a use of a seal holds to (ADR-0188 decision 2). Pure - the service reads the seal and the people, these say yes\n * or no.\n */\n\nexport interface SealUseInput {\n kind?: string | null\n usedOn?: string | null\n document?: string | null\n purpose?: string | null\n submittedTo?: string | null\n returnDueOn?: string | null\n copies?: number | null\n}\n\nexport interface SealOfUse {\n kind: string\n name: string\n disposedOn?: string | null\n}\n\nconst KINDS = ['STAMP', 'TAKE_OUT', 'CERTIFICATE']\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/\n\n/** The corporate seal's every use, and every taking out, is approved; a use seal or the official stamp stamped in the office is written down. */\nexport function needsApproval(kind: string, sealKind: string): boolean {\n return sealKind === 'CORPORATE' || kind !== 'STAMP'\n}\n\n/** What a recorded use asks for before it is written, or nothing. */\nexport function sealUseRefusal(input: SealUseInput, seal: SealOfUse | null): Refusal | null {\n if (!KINDS.includes(input.kind ?? '')) return new Refusal('seal-use-kind-required', {}, 'pick what was done - stamped, taken out, or a certificate')\n if (!seal) return new Refusal('seal-use-seal-required', {}, 'pick the seal')\n if (seal.disposedOn) return new Refusal('seal-use-seal-disposed', { seal: seal.name }, `seal ${seal.name} is disposed of`)\n if (input.kind === 'CERTIFICATE' && seal.kind !== 'CORPORATE') return new Refusal('seal-use-certificate-of-corporate', {}, 'a certificate is of the corporate seal')\n if (!input.usedOn || !DAY.test(input.usedOn)) return new Refusal('seal-use-day-required', {}, 'give the day, YYYY-MM-DD')\n if (input.kind !== 'CERTIFICATE' && !input.document?.trim()) return new Refusal('seal-use-document-required', {}, 'say which paper it is for')\n if (!input.purpose?.trim()) return new Refusal('seal-use-purpose-required', {}, 'say what it is for')\n if (input.kind === 'TAKE_OUT') {\n if (!input.returnDueOn || !DAY.test(input.returnDueOn)) return new Refusal('seal-use-return-due-required', {}, 'give the day it is to be back, YYYY-MM-DD')\n if (input.returnDueOn < input.usedOn) return new Refusal('seal-use-return-before-out', {}, 'it cannot be due back before it goes out')\n }\n if (input.kind === 'CERTIFICATE' && !(Number.isInteger(input.copies) && (input.copies as number) >= 1)) return new Refusal('seal-use-copies-required', {}, 'say how many certificates were issued')\n return null\n}\n\n/**\n * The day certificates are accepted until when nobody says otherwise - three months from their issue, the last day of\n * the month when the month is shorter. A certificate has no validity in law; those it goes to mostly ask for one issued\n * within three months.\n */\nexport function usableUntilOf(issuedOn: string): string {\n const [year, month, day] = issuedOn.split('-').map(Number)\n const target = new Date(Date.UTC(year, month - 1 + 3, 1))\n const last = new Date(Date.UTC(target.getUTCFullYear(), target.getUTCMonth() + 1, 0)).getUTCDate()\n target.setUTCDate(Math.min(day, last))\n return target.toISOString().slice(0, 10)\n}\n\n/** A use taken out, let go, and not back yet. */\nexport function unreturned(row: { kind: string; status: string; returnedOn?: string | null }): boolean {\n return row.kind === 'TAKE_OUT' && row.status === 'APPROVED' && !row.returnedOn\n}\n\n/** What may still change on a written use: when it came back, and the notes. What the approvers saw stays. */\nexport const AFTER_WRITTEN = ['returnedOn', 'notes'] as const\n\n/** A use that may be deleted - one nobody approved: written without approval, or rejected or withdrawn. */\nexport function deletable(status: string): boolean {\n return status === 'RECORDED' || status === 'REJECTED' || status === 'WITHDRAWN'\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SealUse } from './seal-use';
|
|
2
|
+
import { NewSealUse, SealUsePatch } from './seal-use-type';
|
|
3
|
+
export declare function recordSealUse(input: NewSealUse, context: ResolverContext): Promise<SealUse>;
|
|
4
|
+
/** Take a use waiting on approval back - only the one who put it up. */
|
|
5
|
+
export declare function withdrawSealUse(id: string, context: ResolverContext): Promise<SealUse>;
|
|
6
|
+
/** The day it came back and the notes - nothing the approvers saw. */
|
|
7
|
+
export declare function updateSealUses(patches: SealUsePatch[], context: ResolverContext): Promise<SealUse[]>;
|
|
8
|
+
/** Delete uses nobody approved. */
|
|
9
|
+
export declare function deleteSealUses(ids: string[], context: ResolverContext): Promise<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* What an approver's decision does to the use - worklist calls it on every state change of the instance, more than once
|
|
12
|
+
* for one; a decision lands only on the use still waiting on that very instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare function decideSealUse(instance: {
|
|
15
|
+
id: string;
|
|
16
|
+
state: any;
|
|
17
|
+
input?: any;
|
|
18
|
+
}, causedBy: readonly {
|
|
19
|
+
state?: any;
|
|
20
|
+
}[], context: ResolverContext): Promise<void>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.recordSealUse = recordSealUse;
|
|
4
|
+
exports.withdrawSealUse = withdrawSealUse;
|
|
5
|
+
exports.updateSealUses = updateSealUses;
|
|
6
|
+
exports.deleteSealUses = deleteSealUses;
|
|
7
|
+
exports.decideSealUse = decideSealUse;
|
|
8
|
+
const worklist_1 = require("@things-factory/worklist");
|
|
9
|
+
const accounting_1 = require("@things-factory/accounting");
|
|
10
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
11
|
+
const organization_1 = require("@things-factory/organization");
|
|
12
|
+
const shell_1 = require("@things-factory/shell");
|
|
13
|
+
const seal_use_activity_names_1 = require("../../activities/seal-use-activity-names");
|
|
14
|
+
const seal_use_1 = require("./seal-use");
|
|
15
|
+
const seal_use_rules_1 = require("./seal-use-rules");
|
|
16
|
+
/*
|
|
17
|
+
* Writing down a use of a seal (ADR-0188 decision 2), and what an approval does to it. The one way a use is written: a
|
|
18
|
+
* use that needs approval is put up in the same transaction, so none is written that its approvers did not see.
|
|
19
|
+
*/
|
|
20
|
+
const KIND_WORDS = { STAMP: '날인', TAKE_OUT: '반출', CERTIFICATE: '인감증명서 발급' };
|
|
21
|
+
const text = (value) => (typeof value === 'string' && value.trim() ? value.trim() : null);
|
|
22
|
+
async function recordSealUse(input, context) {
|
|
23
|
+
const { domain, user, tx } = context.state;
|
|
24
|
+
const seal = await (0, biz_base_1.companySealOf)(domain, input.sealId, tx);
|
|
25
|
+
const refusal = (0, seal_use_rules_1.sealUseRefusal)(input, seal);
|
|
26
|
+
if (refusal)
|
|
27
|
+
throw refusal;
|
|
28
|
+
const requester = input.requesterId ? await tx.getRepository(organization_1.Employee).findOne({ where: { id: input.requesterId, domain: { id: domain.id } } }) : null;
|
|
29
|
+
if (input.requesterId && !requester)
|
|
30
|
+
throw new shell_1.Refusal('seal-use-requester-unknown', {}, 'the one who asked must be an employee of this domain');
|
|
31
|
+
const certificate = input.kind === seal_use_1.SealUseKind.CERTIFICATE;
|
|
32
|
+
const repository = tx.getRepository(seal_use_1.SealUse);
|
|
33
|
+
const row = repository.create({
|
|
34
|
+
domain,
|
|
35
|
+
kind: input.kind,
|
|
36
|
+
seal,
|
|
37
|
+
requester,
|
|
38
|
+
usedOn: input.usedOn,
|
|
39
|
+
document: text(input.document),
|
|
40
|
+
purpose: text(input.purpose),
|
|
41
|
+
submittedTo: text(input.submittedTo),
|
|
42
|
+
returnDueOn: input.kind === seal_use_1.SealUseKind.TAKE_OUT ? input.returnDueOn : null,
|
|
43
|
+
copies: certificate ? input.copies : null,
|
|
44
|
+
usableUntil: certificate ? text(input.usableUntil) ?? (0, seal_use_rules_1.usableUntilOf)(input.usedOn) : null,
|
|
45
|
+
notes: text(input.notes),
|
|
46
|
+
status: seal_use_1.SealUseStatus.RECORDED,
|
|
47
|
+
creator: user,
|
|
48
|
+
updater: user
|
|
49
|
+
});
|
|
50
|
+
if (!(0, seal_use_rules_1.needsApproval)(input.kind, seal.kind))
|
|
51
|
+
return await repository.save(row);
|
|
52
|
+
const carrier = await (0, worklist_1.activityNamed)(seal_use_activity_names_1.SEAL_USE_ACTIVITY, context);
|
|
53
|
+
if (!carrier)
|
|
54
|
+
throw new shell_1.Refusal('seal-use-approval-not-installed', { form: seal_use_activity_names_1.SEAL_USE_ACTIVITY }, `the approval '${seal_use_activity_names_1.SEAL_USE_ACTIVITY}' is not installed in this domain`);
|
|
55
|
+
const line = await (0, worklist_1.approvalLineStanding)(carrier, context);
|
|
56
|
+
if (line.refusal)
|
|
57
|
+
throw (0, worklist_1.approvalLineRefusal)(line.refusal);
|
|
58
|
+
row.status = seal_use_1.SealUseStatus.SUBMITTED;
|
|
59
|
+
const saved = await repository.save(row);
|
|
60
|
+
const what = `${seal.name} ${KIND_WORDS[input.kind]}`;
|
|
61
|
+
const who = requester?.name ?? user.name ?? '';
|
|
62
|
+
const instance = await (0, worklist_1.issue)({
|
|
63
|
+
name: `${what} ${saved.document ?? saved.purpose ?? ''}`.trim(),
|
|
64
|
+
description: [saved.purpose, saved.submittedTo].filter(Boolean).join(' · '),
|
|
65
|
+
activityId: carrier.id,
|
|
66
|
+
approvalLine: carrier.approvalLine,
|
|
67
|
+
input: {
|
|
68
|
+
sealUseId: saved.id,
|
|
69
|
+
requester: who,
|
|
70
|
+
headline: `${what} · ${saved.usedOn}${saved.document ? ` · ${saved.document}` : ''}`,
|
|
71
|
+
reason: [
|
|
72
|
+
`목적: ${saved.purpose ?? ''}`,
|
|
73
|
+
...(saved.submittedTo ? [`제출처: ${saved.submittedTo}`] : []),
|
|
74
|
+
...(saved.returnDueOn ? [`반납 예정일: ${saved.returnDueOn}`] : []),
|
|
75
|
+
...(saved.copies ? [`통수: ${saved.copies}`] : []),
|
|
76
|
+
...(seal.custodianId ? [] : ['보관자가 정해지지 않은 인감입니다'])
|
|
77
|
+
],
|
|
78
|
+
consequence: input.kind === seal_use_1.SealUseKind.TAKE_OUT ? `승인하면 ${seal.name}을(를) ${saved.returnDueOn}까지 내보냅니다` : `승인하면 ${seal.name}을(를) ${input.kind === seal_use_1.SealUseKind.CERTIFICATE ? '인감증명서 발급에' : '이 서류에'} 씁니다`
|
|
79
|
+
},
|
|
80
|
+
threadsMin: 1,
|
|
81
|
+
threadsMax: 1,
|
|
82
|
+
requireApproval: true
|
|
83
|
+
}, context);
|
|
84
|
+
saved.activityInstanceId = instance.id;
|
|
85
|
+
return await repository.save(saved);
|
|
86
|
+
}
|
|
87
|
+
/** Take a use waiting on approval back - only the one who put it up. */
|
|
88
|
+
async function withdrawSealUse(id, context) {
|
|
89
|
+
const { domain, user, tx } = context.state;
|
|
90
|
+
const repository = tx.getRepository(seal_use_1.SealUse);
|
|
91
|
+
const row = await repository.findOne({ where: { id, domain: { id: domain.id } } });
|
|
92
|
+
if (!row)
|
|
93
|
+
throw new shell_1.Refusal('seal-use-not-found', {}, 'the record was not found. reload and try again.');
|
|
94
|
+
if (row.creatorId !== user.id)
|
|
95
|
+
throw new shell_1.Refusal('seal-use-not-yours', {}, 'only the one who put it up can take it back');
|
|
96
|
+
if (row.status !== seal_use_1.SealUseStatus.SUBMITTED)
|
|
97
|
+
throw new shell_1.Refusal('seal-use-not-submitted', {}, 'only a use waiting on approval can be taken back');
|
|
98
|
+
if (row.activityInstanceId)
|
|
99
|
+
await (0, worklist_1.abort)({ id: row.activityInstanceId, reason: '올린 사람이 회수함' }, context);
|
|
100
|
+
row.status = seal_use_1.SealUseStatus.WITHDRAWN;
|
|
101
|
+
row.updater = user;
|
|
102
|
+
return await repository.save(row);
|
|
103
|
+
}
|
|
104
|
+
/** The day it came back and the notes - nothing the approvers saw. */
|
|
105
|
+
async function updateSealUses(patches, context) {
|
|
106
|
+
const { domain, user, tx } = context.state;
|
|
107
|
+
const repository = tx.getRepository(seal_use_1.SealUse);
|
|
108
|
+
const saved = [];
|
|
109
|
+
for (const patch of patches) {
|
|
110
|
+
const row = await repository.findOne({ where: { id: patch.id, domain: { id: domain.id } } });
|
|
111
|
+
if (!row)
|
|
112
|
+
throw new shell_1.Refusal('seal-use-not-found', {}, 'the record was not found. reload and try again.');
|
|
113
|
+
const changed = Object.keys(patch).filter(field => !['id', 'cuFlag'].includes(field) && patch[field] !== undefined);
|
|
114
|
+
if (changed.some(field => !seal_use_rules_1.AFTER_WRITTEN.includes(field)))
|
|
115
|
+
throw new shell_1.Refusal('seal-use-written', {}, 'what was written stays - only the day it came back and the notes change');
|
|
116
|
+
if (patch.returnedOn !== undefined) {
|
|
117
|
+
const day = text(patch.returnedOn);
|
|
118
|
+
if (day && (row.kind !== seal_use_1.SealUseKind.TAKE_OUT || row.status !== seal_use_1.SealUseStatus.APPROVED))
|
|
119
|
+
throw new shell_1.Refusal('seal-use-not-out', {}, 'only a seal let out comes back');
|
|
120
|
+
if (day && (!/^\d{4}-\d{2}-\d{2}$/.test(day) || day < row.usedOn))
|
|
121
|
+
throw new shell_1.Refusal('seal-use-returned-invalid', {}, 'it comes back on or after the day it went out, YYYY-MM-DD');
|
|
122
|
+
row.returnedOn = day;
|
|
123
|
+
}
|
|
124
|
+
if (patch.notes !== undefined)
|
|
125
|
+
row.notes = text(patch.notes);
|
|
126
|
+
row.updater = user;
|
|
127
|
+
saved.push(await repository.save(row));
|
|
128
|
+
}
|
|
129
|
+
return saved;
|
|
130
|
+
}
|
|
131
|
+
/** Delete uses nobody approved. */
|
|
132
|
+
async function deleteSealUses(ids, context) {
|
|
133
|
+
const { domain, tx } = context.state;
|
|
134
|
+
const repository = tx.getRepository(seal_use_1.SealUse);
|
|
135
|
+
for (const id of ids) {
|
|
136
|
+
const row = await repository.findOne({ where: { id, domain: { id: domain.id } } });
|
|
137
|
+
if (!row)
|
|
138
|
+
continue;
|
|
139
|
+
if (!(0, seal_use_rules_1.deletable)(row.status))
|
|
140
|
+
throw new shell_1.Refusal('seal-use-not-deletable', {}, 'a use that went through approval is kept - one waiting is taken back instead');
|
|
141
|
+
await repository.delete(row.id);
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* What an approver's decision does to the use - worklist calls it on every state change of the instance, more than once
|
|
147
|
+
* for one; a decision lands only on the use still waiting on that very instance.
|
|
148
|
+
*/
|
|
149
|
+
async function decideSealUse(instance, causedBy, context) {
|
|
150
|
+
const { domain, user, tx } = context.state;
|
|
151
|
+
const id = instance.input?.sealUseId;
|
|
152
|
+
if (!id)
|
|
153
|
+
return;
|
|
154
|
+
const repository = tx.getRepository(seal_use_1.SealUse);
|
|
155
|
+
const row = await repository.findOne({ where: { id, domain: { id: domain.id } } });
|
|
156
|
+
if (!row)
|
|
157
|
+
return;
|
|
158
|
+
const decision = (0, accounting_1.decisionOf)({ id: instance.id, state: String(instance.state) }, causedBy.map(one => ({ state: String(one.state) })), { status: row.status, activityInstanceId: row.activityInstanceId });
|
|
159
|
+
if (!decision)
|
|
160
|
+
return;
|
|
161
|
+
row.status = seal_use_1.SealUseStatus[decision];
|
|
162
|
+
if (decision !== 'WITHDRAWN') {
|
|
163
|
+
row.decidedAt = new Date();
|
|
164
|
+
row.decidedBy = user;
|
|
165
|
+
}
|
|
166
|
+
await repository.save(row);
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=seal-use-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal-use-service.js","sourceRoot":"","sources":["../../../server/service/seal-use/seal-use-service.ts"],"names":[],"mappings":";;AAoBA,sCAmEC;AAGD,0CAWC;AAGD,wCAoBC;AAGD,wCAUC;AAMD,sCAmBC;AAlKD,uDAAiH;AACjH,2DAAuD;AACvD,uDAAwD;AACxD,+DAAuD;AACvD,iDAA+C;AAE/C,sFAA4E;AAC5E,yCAAgE;AAChE,qDAAyG;AAGzG;;;GAGG;AAEH,MAAM,UAAU,GAA2B,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,CAAA;AAEnG,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAE3F,KAAK,UAAU,aAAa,CAAC,KAAiB,EAAE,OAAwB;IAC7E,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC1C,MAAM,IAAI,GAAG,MAAM,IAAA,wBAAa,EAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC1D,MAAM,OAAO,GAAG,IAAA,+BAAc,EAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC3C,IAAI,OAAO;QAAE,MAAM,OAAO,CAAA;IAE1B,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,uBAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAA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AA;IACtB,CAAC;IACD,MAAM,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC5B,CAAC","sourcesContent":["import { abort, activityNamed, approvalLineRefusal, approvalLineStanding, issue } from '@things-factory/worklist'\nimport { decisionOf } from '@things-factory/accounting'\nimport { companySealOf } from '@things-factory/biz-base'\nimport { Employee } from '@things-factory/organization'\nimport { Refusal } from '@things-factory/shell'\n\nimport { SEAL_USE_ACTIVITY } from '../../activities/seal-use-activity-names'\nimport { SealUse, SealUseKind, SealUseStatus } from './seal-use'\nimport { AFTER_WRITTEN, deletable, needsApproval, sealUseRefusal, usableUntilOf } from './seal-use-rules'\nimport { NewSealUse, SealUsePatch } from './seal-use-type'\n\n/*\n * Writing down a use of a seal (ADR-0188 decision 2), and what an approval does to it. The one way a use is written: a\n * use that needs approval is put up in the same transaction, so none is written that its approvers did not see.\n */\n\nconst KIND_WORDS: Record<string, string> = { STAMP: '날인', TAKE_OUT: '반출', CERTIFICATE: '인감증명서 발급' }\n\nconst text = (value: unknown) => (typeof value === 'string' && value.trim() ? value.trim() : null)\n\nexport async function recordSealUse(input: NewSealUse, context: ResolverContext): Promise<SealUse> {\n const { domain, user, tx } = context.state\n const seal = await companySealOf(domain, input.sealId, tx)\n const refusal = sealUseRefusal(input, seal)\n if (refusal) throw refusal\n\n const requester = input.requesterId ? await tx.getRepository(Employee).findOne({ where: { id: input.requesterId, domain: { id: domain.id } } as any }) : null\n if (input.requesterId && !requester) throw new Refusal('seal-use-requester-unknown', {}, 'the one who asked must be an employee of this domain')\n\n const certificate = input.kind === SealUseKind.CERTIFICATE\n const repository = tx.getRepository(SealUse)\n const row = repository.create({\n domain,\n kind: input.kind,\n seal,\n requester,\n usedOn: input.usedOn,\n document: text(input.document),\n purpose: text(input.purpose),\n submittedTo: text(input.submittedTo),\n returnDueOn: input.kind === SealUseKind.TAKE_OUT ? input.returnDueOn : null,\n copies: certificate ? input.copies : null,\n usableUntil: certificate ? text(input.usableUntil) ?? usableUntilOf(input.usedOn) : null,\n notes: text(input.notes),\n status: SealUseStatus.RECORDED,\n creator: user,\n updater: user\n } as any) as unknown as SealUse\n\n if (!needsApproval(input.kind, seal!.kind)) return await repository.save(row)\n\n const carrier = await activityNamed(SEAL_USE_ACTIVITY, context)\n if (!carrier) throw new Refusal('seal-use-approval-not-installed', { form: SEAL_USE_ACTIVITY }, `the approval '${SEAL_USE_ACTIVITY}' is not installed in this domain`)\n const line = await approvalLineStanding(carrier, context)\n if (line.refusal) throw approvalLineRefusal(line.refusal)\n\n row.status = SealUseStatus.SUBMITTED\n const saved = await repository.save(row)\n const what = `${seal!.name} ${KIND_WORDS[input.kind]}`\n const who = requester?.name ?? user.name ?? ''\n const instance = await issue(\n {\n name: `${what} ${saved.document ?? saved.purpose ?? ''}`.trim(),\n description: [saved.purpose, saved.submittedTo].filter(Boolean).join(' · '),\n activityId: carrier.id,\n approvalLine: carrier.approvalLine,\n input: {\n sealUseId: saved.id,\n requester: who,\n headline: `${what} · ${saved.usedOn}${saved.document ? ` · ${saved.document}` : ''}`,\n reason: [\n `목적: ${saved.purpose ?? ''}`,\n ...(saved.submittedTo ? [`제출처: ${saved.submittedTo}`] : []),\n ...(saved.returnDueOn ? [`반납 예정일: ${saved.returnDueOn}`] : []),\n ...(saved.copies ? [`통수: ${saved.copies}`] : []),\n ...(seal!.custodianId ? [] : ['보관자가 정해지지 않은 인감입니다'])\n ],\n consequence: input.kind === SealUseKind.TAKE_OUT ? `승인하면 ${seal!.name}을(를) ${saved.returnDueOn}까지 내보냅니다` : `승인하면 ${seal!.name}을(를) ${input.kind === SealUseKind.CERTIFICATE ? '인감증명서 발급에' : '이 서류에'} 씁니다`\n },\n threadsMin: 1,\n threadsMax: 1,\n requireApproval: true\n } as any,\n context\n )\n saved.activityInstanceId = instance.id\n return await repository.save(saved)\n}\n\n/** Take a use waiting on approval back - only the one who put it up. */\nexport async function withdrawSealUse(id: string, context: ResolverContext): Promise<SealUse> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(SealUse)\n const row = await repository.findOne({ where: { id, domain: { id: domain.id } } as any })\n if (!row) throw new Refusal('seal-use-not-found', {}, 'the record was not found. reload and try again.')\n if (row.creatorId !== user.id) throw new Refusal('seal-use-not-yours', {}, 'only the one who put it up can take it back')\n if (row.status !== SealUseStatus.SUBMITTED) throw new Refusal('seal-use-not-submitted', {}, 'only a use waiting on approval can be taken back')\n if (row.activityInstanceId) await abort({ id: row.activityInstanceId, reason: '올린 사람이 회수함' } as any, context)\n row.status = SealUseStatus.WITHDRAWN\n row.updater = user\n return await repository.save(row)\n}\n\n/** The day it came back and the notes - nothing the approvers saw. */\nexport async function updateSealUses(patches: SealUsePatch[], context: ResolverContext): Promise<SealUse[]> {\n const { domain, user, tx } = context.state\n const repository = tx.getRepository(SealUse)\n const saved: SealUse[] = []\n for (const patch of patches) {\n const row = await repository.findOne({ where: { id: patch.id, domain: { id: domain.id } } as any })\n if (!row) throw new Refusal('seal-use-not-found', {}, 'the record was not found. reload and try again.')\n const changed = Object.keys(patch).filter(field => !['id', 'cuFlag'].includes(field) && (patch as any)[field] !== undefined)\n if (changed.some(field => !(AFTER_WRITTEN as readonly string[]).includes(field))) throw new Refusal('seal-use-written', {}, 'what was written stays - only the day it came back and the notes change')\n if (patch.returnedOn !== undefined) {\n const day = text(patch.returnedOn)\n if (day && (row.kind !== SealUseKind.TAKE_OUT || row.status !== SealUseStatus.APPROVED)) throw new Refusal('seal-use-not-out', {}, 'only a seal let out comes back')\n if (day && (!/^\\d{4}-\\d{2}-\\d{2}$/.test(day) || day < row.usedOn)) throw new Refusal('seal-use-returned-invalid', {}, 'it comes back on or after the day it went out, YYYY-MM-DD')\n row.returnedOn = day\n }\n if (patch.notes !== undefined) row.notes = text(patch.notes)\n row.updater = user\n saved.push(await repository.save(row))\n }\n return saved\n}\n\n/** Delete uses nobody approved. */\nexport async function deleteSealUses(ids: string[], context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n const repository = tx.getRepository(SealUse)\n for (const id of ids) {\n const row = await repository.findOne({ where: { id, domain: { id: domain.id } } as any })\n if (!row) continue\n if (!deletable(row.status)) throw new Refusal('seal-use-not-deletable', {}, 'a use that went through approval is kept - one waiting is taken back instead')\n await repository.delete(row.id)\n }\n return true\n}\n\n/**\n * What an approver's decision does to the use - worklist calls it on every state change of the instance, more than once\n * for one; a decision lands only on the use still waiting on that very instance.\n */\nexport async function decideSealUse(instance: { id: string; state: any; input?: any }, causedBy: readonly { state?: any }[], context: ResolverContext) {\n const { domain, user, tx } = context.state\n const id = instance.input?.sealUseId\n if (!id) return\n const repository = tx.getRepository(SealUse)\n const row = await repository.findOne({ where: { id, domain: { id: domain.id } } as any })\n if (!row) return\n const decision = decisionOf(\n { id: instance.id, state: String(instance.state) },\n causedBy.map(one => ({ state: String(one.state) })),\n { status: row.status as any, activityInstanceId: row.activityInstanceId }\n )\n if (!decision) return\n row.status = SealUseStatus[decision]\n if (decision !== 'WITHDRAWN') {\n row.decidedAt = new Date()\n row.decidedBy = user\n }\n await repository.save(row)\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SealUse, SealUseKind } from './seal-use';
|
|
2
|
+
export declare class NewSealUse {
|
|
3
|
+
kind: SealUseKind;
|
|
4
|
+
sealId: string;
|
|
5
|
+
requesterId?: string;
|
|
6
|
+
usedOn: string;
|
|
7
|
+
document?: string;
|
|
8
|
+
purpose?: string;
|
|
9
|
+
submittedTo?: string;
|
|
10
|
+
returnDueOn?: string;
|
|
11
|
+
copies?: number;
|
|
12
|
+
usableUntil?: string;
|
|
13
|
+
notes?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class SealUsePatch {
|
|
16
|
+
id: string;
|
|
17
|
+
returnedOn?: string;
|
|
18
|
+
notes?: string;
|
|
19
|
+
cuFlag?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class SealUseList {
|
|
22
|
+
items: SealUse[];
|
|
23
|
+
total: number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SealUseList = exports.SealUsePatch = exports.NewSealUse = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const seal_use_1 = require("./seal-use");
|
|
7
|
+
let NewSealUse = class NewSealUse {
|
|
8
|
+
};
|
|
9
|
+
exports.NewSealUse = NewSealUse;
|
|
10
|
+
tslib_1.__decorate([
|
|
11
|
+
(0, type_graphql_1.Field)(type => seal_use_1.SealUseKind),
|
|
12
|
+
tslib_1.__metadata("design:type", String)
|
|
13
|
+
], NewSealUse.prototype, "kind", void 0);
|
|
14
|
+
tslib_1.__decorate([
|
|
15
|
+
(0, type_graphql_1.Field)({ description: 'The seal of the register' }),
|
|
16
|
+
tslib_1.__metadata("design:type", String)
|
|
17
|
+
], NewSealUse.prototype, "sealId", void 0);
|
|
18
|
+
tslib_1.__decorate([
|
|
19
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'The employee who asked for it' }),
|
|
20
|
+
tslib_1.__metadata("design:type", String)
|
|
21
|
+
], NewSealUse.prototype, "requesterId", void 0);
|
|
22
|
+
tslib_1.__decorate([
|
|
23
|
+
(0, type_graphql_1.Field)({ description: 'YYYY-MM-DD' }),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], NewSealUse.prototype, "usedOn", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], NewSealUse.prototype, "document", void 0);
|
|
30
|
+
tslib_1.__decorate([
|
|
31
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
32
|
+
tslib_1.__metadata("design:type", String)
|
|
33
|
+
], NewSealUse.prototype, "purpose", void 0);
|
|
34
|
+
tslib_1.__decorate([
|
|
35
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
36
|
+
tslib_1.__metadata("design:type", String)
|
|
37
|
+
], NewSealUse.prototype, "submittedTo", void 0);
|
|
38
|
+
tslib_1.__decorate([
|
|
39
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'YYYY-MM-DD - a taking out' }),
|
|
40
|
+
tslib_1.__metadata("design:type", String)
|
|
41
|
+
], NewSealUse.prototype, "returnDueOn", void 0);
|
|
42
|
+
tslib_1.__decorate([
|
|
43
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'A certificate' }),
|
|
44
|
+
tslib_1.__metadata("design:type", Number)
|
|
45
|
+
], NewSealUse.prototype, "copies", void 0);
|
|
46
|
+
tslib_1.__decorate([
|
|
47
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'YYYY-MM-DD - a certificate; three months from its issue when empty' }),
|
|
48
|
+
tslib_1.__metadata("design:type", String)
|
|
49
|
+
], NewSealUse.prototype, "usableUntil", void 0);
|
|
50
|
+
tslib_1.__decorate([
|
|
51
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
52
|
+
tslib_1.__metadata("design:type", String)
|
|
53
|
+
], NewSealUse.prototype, "notes", void 0);
|
|
54
|
+
exports.NewSealUse = NewSealUse = tslib_1.__decorate([
|
|
55
|
+
(0, type_graphql_1.InputType)({ description: 'A use of a seal as it is written down' })
|
|
56
|
+
], NewSealUse);
|
|
57
|
+
let SealUsePatch = class SealUsePatch {
|
|
58
|
+
};
|
|
59
|
+
exports.SealUsePatch = SealUsePatch;
|
|
60
|
+
tslib_1.__decorate([
|
|
61
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
62
|
+
tslib_1.__metadata("design:type", String)
|
|
63
|
+
], SealUsePatch.prototype, "id", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'YYYY-MM-DD' }),
|
|
66
|
+
tslib_1.__metadata("design:type", String)
|
|
67
|
+
], SealUsePatch.prototype, "returnedOn", void 0);
|
|
68
|
+
tslib_1.__decorate([
|
|
69
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
70
|
+
tslib_1.__metadata("design:type", String)
|
|
71
|
+
], SealUsePatch.prototype, "notes", void 0);
|
|
72
|
+
tslib_1.__decorate([
|
|
73
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'M changed' }),
|
|
74
|
+
tslib_1.__metadata("design:type", String)
|
|
75
|
+
], SealUsePatch.prototype, "cuFlag", void 0);
|
|
76
|
+
exports.SealUsePatch = SealUsePatch = tslib_1.__decorate([
|
|
77
|
+
(0, type_graphql_1.InputType)({ description: 'What changes on a written use - the day it came back and the notes' })
|
|
78
|
+
], SealUsePatch);
|
|
79
|
+
let SealUseList = class SealUseList {
|
|
80
|
+
};
|
|
81
|
+
exports.SealUseList = SealUseList;
|
|
82
|
+
tslib_1.__decorate([
|
|
83
|
+
(0, type_graphql_1.Field)(type => [seal_use_1.SealUse]),
|
|
84
|
+
tslib_1.__metadata("design:type", Array)
|
|
85
|
+
], SealUseList.prototype, "items", void 0);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.Int),
|
|
88
|
+
tslib_1.__metadata("design:type", Number)
|
|
89
|
+
], SealUseList.prototype, "total", void 0);
|
|
90
|
+
exports.SealUseList = SealUseList = tslib_1.__decorate([
|
|
91
|
+
(0, type_graphql_1.ObjectType)()
|
|
92
|
+
], SealUseList);
|
|
93
|
+
//# sourceMappingURL=seal-use-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal-use-type.js","sourceRoot":"","sources":["../../../server/service/seal-use/seal-use-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yCAAiD;AAG1C,IAAM,UAAU,GAAhB,MAAM,UAAU;CAYtB,CAAA;AAZY,gCAAU;AACO;IAA3B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAA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,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;;gDAAoB;AAC9C;IAA1B,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CAAe;AACY;IAApD,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;;4CAAgB;uBAJzD,YAAY;IADxB,IAAA,wBAAS,EAAC,EAAE,WAAW,EAAE,oEAAoE,EAAE,CAAC;GACpF,YAAY,CAKxB;AAGM,IAAM,WAAW,GAAjB,MAAM,WAAW;CAGvB,CAAA;AAHY,kCAAW;AACI;IAAzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,kBAAO,CAAC,CAAC;;0CAAiB;AACtB;IAAnB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;0CAAc;sBAFtB,WAAW;IADvB,IAAA,yBAAU,GAAE;GACA,WAAW,CAGvB","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { SealUse, SealUseKind } from './seal-use'\n\n@InputType({ description: 'A use of a seal as it is written down' })\nexport class NewSealUse {\n @Field(type => SealUseKind) kind: SealUseKind\n @Field({ description: 'The seal of the register' }) sealId: string\n @Field({ nullable: true, description: 'The employee who asked for it' }) requesterId?: string\n @Field({ description: 'YYYY-MM-DD' }) usedOn: string\n @Field({ nullable: true }) document?: string\n @Field({ nullable: true }) purpose?: string\n @Field({ nullable: true }) submittedTo?: string\n @Field({ nullable: true, description: 'YYYY-MM-DD - a taking out' }) returnDueOn?: string\n @Field(type => Int, { nullable: true, description: 'A certificate' }) copies?: number\n @Field({ nullable: true, description: 'YYYY-MM-DD - a certificate; three months from its issue when empty' }) usableUntil?: string\n @Field({ nullable: true }) notes?: string\n}\n\n@InputType({ description: 'What changes on a written use - the day it came back and the notes' })\nexport class SealUsePatch {\n @Field(type => ID) id: string\n @Field({ nullable: true, description: 'YYYY-MM-DD' }) returnedOn?: string\n @Field({ nullable: true }) notes?: string\n @Field({ nullable: true, description: 'M changed' }) cuFlag?: string\n}\n\n@ObjectType()\nexport class SealUseList {\n @Field(type => [SealUse]) items: SealUse[]\n @Field(type => Int) total: number\n}\n"]}
|