@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,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegulationMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
|
|
6
|
+
const type_graphql_1 = require("type-graphql");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const regulation_1 = require("./regulation");
|
|
9
|
+
const regulation_service_1 = require("./regulation-service");
|
|
10
|
+
const regulation_type_1 = require("./regulation-type");
|
|
11
|
+
const KEEP = '@privilege(category: "regulation", privilege: "mutation", domainOwnerGranted: true)';
|
|
12
|
+
let RegulationMutation = class RegulationMutation {
|
|
13
|
+
async createRegulation(regulation, context) {
|
|
14
|
+
return await (0, regulation_service_1.createRegulation)(regulation, context);
|
|
15
|
+
}
|
|
16
|
+
async updateRegulation(id, patch, context) {
|
|
17
|
+
return await (0, regulation_service_1.updateRegulation)(id, patch, context);
|
|
18
|
+
}
|
|
19
|
+
async deleteRegulations(ids, context) {
|
|
20
|
+
return await (0, regulation_service_1.deleteRegulations)(ids, context);
|
|
21
|
+
}
|
|
22
|
+
async newRegulationVersion(regulationId, context) {
|
|
23
|
+
return await (0, regulation_service_1.newRegulationVersion)(regulationId, context);
|
|
24
|
+
}
|
|
25
|
+
async updateRegulationVersion(id, patch, context) {
|
|
26
|
+
return await (0, regulation_service_1.updateRegulationVersion)(id, patch, context);
|
|
27
|
+
}
|
|
28
|
+
async deleteRegulationVersion(id, context) {
|
|
29
|
+
return await (0, regulation_service_1.deleteRegulationVersion)(id, context);
|
|
30
|
+
}
|
|
31
|
+
async recordRegulationProcedure(procedure, files, context) {
|
|
32
|
+
return await (0, regulation_service_1.recordRegulationProcedure)(procedure, files, context);
|
|
33
|
+
}
|
|
34
|
+
async deleteRegulationProcedure(id, context) {
|
|
35
|
+
return await (0, regulation_service_1.deleteRegulationProcedure)(id, context);
|
|
36
|
+
}
|
|
37
|
+
async submitRegulationVersion(id, context) {
|
|
38
|
+
return await (0, regulation_service_1.submitRegulationVersion)(id, context);
|
|
39
|
+
}
|
|
40
|
+
async withdrawRegulationVersion(id, context) {
|
|
41
|
+
return await (0, regulation_service_1.withdrawRegulationVersion)(id, context);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.RegulationMutation = RegulationMutation;
|
|
45
|
+
tslib_1.__decorate([
|
|
46
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
47
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
48
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.Regulation, { description: 'To write a new company rule, with its first version to write (ADR-0187)' }),
|
|
49
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('regulation', type => regulation_type_1.NewRegulation)),
|
|
50
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
51
|
+
tslib_1.__metadata("design:type", Function),
|
|
52
|
+
tslib_1.__metadata("design:paramtypes", [regulation_type_1.NewRegulation, Object]),
|
|
53
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
54
|
+
], RegulationMutation.prototype, "createRegulation", null);
|
|
55
|
+
tslib_1.__decorate([
|
|
56
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
57
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
58
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.Regulation, { description: 'To change the name, topics or place of a rule - its kind while none of its versions is adopted' }),
|
|
59
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
60
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', type => regulation_type_1.RegulationPatch)),
|
|
61
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
62
|
+
tslib_1.__metadata("design:type", Function),
|
|
63
|
+
tslib_1.__metadata("design:paramtypes", [String, regulation_type_1.RegulationPatch, Object]),
|
|
64
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
65
|
+
], RegulationMutation.prototype, "updateRegulation", null);
|
|
66
|
+
tslib_1.__decorate([
|
|
67
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
68
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
69
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete rules none of whose versions was adopted or is in approval' }),
|
|
70
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
71
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
72
|
+
tslib_1.__metadata("design:type", Function),
|
|
73
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
74
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
75
|
+
], RegulationMutation.prototype, "deleteRegulations", null);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
78
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
79
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.RegulationVersion, { description: "To start the next version of a rule from the latest one's text" }),
|
|
80
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('regulationId')),
|
|
81
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
82
|
+
tslib_1.__metadata("design:type", Function),
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
84
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
85
|
+
], RegulationMutation.prototype, "newRegulationVersion", null);
|
|
86
|
+
tslib_1.__decorate([
|
|
87
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
88
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
89
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.RegulationVersion, { description: 'To change a version being written' }),
|
|
90
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
91
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('patch', type => regulation_type_1.RegulationVersionPatch)),
|
|
92
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
93
|
+
tslib_1.__metadata("design:type", Function),
|
|
94
|
+
tslib_1.__metadata("design:paramtypes", [String, regulation_type_1.RegulationVersionPatch, Object]),
|
|
95
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
96
|
+
], RegulationMutation.prototype, "updateRegulationVersion", null);
|
|
97
|
+
tslib_1.__decorate([
|
|
98
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
99
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
100
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete a version being written' }),
|
|
101
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
102
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
103
|
+
tslib_1.__metadata("design:type", Function),
|
|
104
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
105
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
106
|
+
], RegulationMutation.prototype, "deleteRegulationVersion", null);
|
|
107
|
+
tslib_1.__decorate([
|
|
108
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
109
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
110
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.RegulationProcedure, { description: 'To record an opinion heard, a consent given or the filing of a version, with its papers' }),
|
|
111
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('procedure', type => regulation_type_1.NewRegulationProcedure)),
|
|
112
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('files', type => [GraphQLUpload_js_1.default], { nullable: true })),
|
|
113
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
114
|
+
tslib_1.__metadata("design:type", Function),
|
|
115
|
+
tslib_1.__metadata("design:paramtypes", [regulation_type_1.NewRegulationProcedure, Array, Object]),
|
|
116
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
117
|
+
], RegulationMutation.prototype, "recordRegulationProcedure", null);
|
|
118
|
+
tslib_1.__decorate([
|
|
119
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
120
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
121
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To take a procedure off a version being written' }),
|
|
122
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
123
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
124
|
+
tslib_1.__metadata("design:type", Function),
|
|
125
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
126
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
127
|
+
], RegulationMutation.prototype, "deleteRegulationProcedure", null);
|
|
128
|
+
tslib_1.__decorate([
|
|
129
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
130
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
131
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.RegulationVersion, { description: 'To put a version up for adoption - checked against the procedure the law asks; adopted at once where no approver is named' }),
|
|
132
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
133
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
134
|
+
tslib_1.__metadata("design:type", Function),
|
|
135
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
136
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
137
|
+
], RegulationMutation.prototype, "submitRegulationVersion", null);
|
|
138
|
+
tslib_1.__decorate([
|
|
139
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
140
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
141
|
+
(0, type_graphql_1.Mutation)(returns => regulation_1.RegulationVersion, { description: 'To take a version in approval back to writing' }),
|
|
142
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
143
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
144
|
+
tslib_1.__metadata("design:type", Function),
|
|
145
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
146
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
147
|
+
], RegulationMutation.prototype, "withdrawRegulationVersion", null);
|
|
148
|
+
exports.RegulationMutation = RegulationMutation = tslib_1.__decorate([
|
|
149
|
+
(0, type_graphql_1.Resolver)(regulation_1.Regulation),
|
|
150
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
151
|
+
], RegulationMutation);
|
|
152
|
+
//# sourceMappingURL=regulation-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regulation-mutation.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-mutation.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;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AAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEAE5D;6BAzEU,kBAAkB;IAF9B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;IACpB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,kBAAkB,CA0E9B","sourcesContent":["import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\nimport { Arg, Ctx, Directive, Mutation, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { SpeakRefusals } from '@things-factory/shell'\n\nimport { Regulation, RegulationProcedure, RegulationVersion } from './regulation'\nimport {\n createRegulation,\n deleteRegulationProcedure,\n deleteRegulations,\n deleteRegulationVersion,\n newRegulationVersion,\n recordRegulationProcedure,\n submitRegulationVersion,\n updateRegulation,\n updateRegulationVersion,\n withdrawRegulationVersion\n} from './regulation-service'\nimport { NewRegulation, NewRegulationProcedure, RegulationPatch, RegulationVersionPatch } from './regulation-type'\n\nconst KEEP = '@privilege(category: \"regulation\", privilege: \"mutation\", domainOwnerGranted: true)'\n\n@Resolver(Regulation)\n@UseMiddleware(SpeakRefusals)\nexport class RegulationMutation {\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => Regulation, { description: 'To write a new company rule, with its first version to write (ADR-0187)' })\n async createRegulation(@Arg('regulation', type => NewRegulation) regulation: NewRegulation, @Ctx() context: ResolverContext): Promise<Regulation> {\n return await createRegulation(regulation, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => Regulation, { description: 'To change the name, topics or place of a rule - its kind while none of its versions is adopted' })\n async updateRegulation(@Arg('id') id: string, @Arg('patch', type => RegulationPatch) patch: RegulationPatch, @Ctx() context: ResolverContext): Promise<Regulation> {\n return await updateRegulation(id, patch, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete rules none of whose versions was adopted or is in approval' })\n async deleteRegulations(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {\n return await deleteRegulations(ids, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => RegulationVersion, { description: \"To start the next version of a rule from the latest one's text\" })\n async newRegulationVersion(@Arg('regulationId') regulationId: string, @Ctx() context: ResolverContext): Promise<RegulationVersion> {\n return await newRegulationVersion(regulationId, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => RegulationVersion, { description: 'To change a version being written' })\n async updateRegulationVersion(@Arg('id') id: string, @Arg('patch', type => RegulationVersionPatch) patch: RegulationVersionPatch, @Ctx() context: ResolverContext): Promise<RegulationVersion> {\n return await updateRegulationVersion(id, patch, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete a version being written' })\n async deleteRegulationVersion(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n return await deleteRegulationVersion(id, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => RegulationProcedure, { description: 'To record an opinion heard, a consent given or the filing of a version, with its papers' })\n async recordRegulationProcedure(\n @Arg('procedure', type => NewRegulationProcedure) procedure: NewRegulationProcedure,\n @Arg('files', type => [GraphQLUpload], { nullable: true }) files: FileUpload[],\n @Ctx() context: ResolverContext\n ): Promise<RegulationProcedure> {\n return await recordRegulationProcedure(procedure, files, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To take a procedure off a version being written' })\n async deleteRegulationProcedure(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n return await deleteRegulationProcedure(id, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => RegulationVersion, { description: 'To put a version up for adoption - checked against the procedure the law asks; adopted at once where no approver is named' })\n async submitRegulationVersion(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<RegulationVersion> {\n return await submitRegulationVersion(id, context)\n }\n\n @Directive(KEEP)\n @Directive('@transaction')\n @Mutation(returns => RegulationVersion, { description: 'To take a version in approval back to writing' })\n async withdrawRegulationVersion(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<RegulationVersion> {\n return await withdrawRegulationVersion(id, context)\n }\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ListParam } from '@things-factory/shell';
|
|
2
|
+
import { RegulationList, RegulationView } from './regulation-type';
|
|
3
|
+
export declare class RegulationQuery {
|
|
4
|
+
regulations(params: ListParam, context: ResolverContext): Promise<RegulationList>;
|
|
5
|
+
companyRegulations(topic: string, context: ResolverContext): Promise<RegulationView[]>;
|
|
6
|
+
companyRegulation(id: string, code: string, context: ResolverContext): Promise<RegulationView>;
|
|
7
|
+
amIComplianceEmployee(context: ResolverContext): Promise<boolean>;
|
|
8
|
+
regulationKeeper(context: ResolverContext): Promise<boolean>;
|
|
9
|
+
activeEmployeeCount(context: ResolverContext): Promise<number>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RegulationQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const organization_1 = require("@things-factory/organization");
|
|
7
|
+
const employee_profile_rules_js_1 = require("@things-factory/organization/dist-server/service/employee-profile/employee-profile-rules.js");
|
|
8
|
+
const shell_1 = require("@things-factory/shell");
|
|
9
|
+
const employee_reader_1 = require("../common/employee-reader");
|
|
10
|
+
const regulation_1 = require("./regulation");
|
|
11
|
+
const regulation_read_1 = require("./regulation-read");
|
|
12
|
+
const regulation_type_1 = require("./regulation-type");
|
|
13
|
+
const KEEP = '@privilege(category: "regulation", privilege: "query", domainOwnerGranted: true)';
|
|
14
|
+
let RegulationQuery = class RegulationQuery {
|
|
15
|
+
async regulations(params, context) {
|
|
16
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
17
|
+
domain: context.state.domain,
|
|
18
|
+
params,
|
|
19
|
+
repository: (0, shell_1.getRepository)(regulation_1.Regulation),
|
|
20
|
+
searchables: ['code', 'name'],
|
|
21
|
+
alias: 'regulation',
|
|
22
|
+
defaultSortings: [{ name: 'rank' }, { name: 'name' }]
|
|
23
|
+
});
|
|
24
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
25
|
+
return { items, total };
|
|
26
|
+
}
|
|
27
|
+
async companyRegulations(topic, context) {
|
|
28
|
+
const keeper = await (0, regulation_read_1.requireRuleReader)(context);
|
|
29
|
+
const rows = await (0, shell_1.getRepository)(regulation_1.Regulation).find({ where: { domain: { id: context.state.domain.id } }, order: { rank: 'ASC', name: 'ASC' } });
|
|
30
|
+
const views = await Promise.all(rows.filter(one => !topic || (one.topics ?? []).includes(topic)).map(one => (0, regulation_read_1.viewOfRegulation)(undefined, context, one, keeper)));
|
|
31
|
+
return views.filter(one => keeper || one.versions.length);
|
|
32
|
+
}
|
|
33
|
+
async companyRegulation(id, code, context) {
|
|
34
|
+
const keeper = await (0, regulation_read_1.requireRuleReader)(context);
|
|
35
|
+
const where = id ? { id } : { code };
|
|
36
|
+
const row = await (0, shell_1.getRepository)(regulation_1.Regulation).findOne({ where: { ...where, domain: { id: context.state.domain.id } } });
|
|
37
|
+
const view = row ? await (0, regulation_read_1.viewOfRegulation)(undefined, context, row, keeper) : null;
|
|
38
|
+
if (!view || (!keeper && !view.versions.length))
|
|
39
|
+
throw new shell_1.Refusal('regulation-not-found', {}, 'the rule was not found. reload and try again.');
|
|
40
|
+
return view;
|
|
41
|
+
}
|
|
42
|
+
async amIComplianceEmployee(context) {
|
|
43
|
+
return !!(await (0, employee_reader_1.workingEmployeeOf)(context));
|
|
44
|
+
}
|
|
45
|
+
async regulationKeeper(context) {
|
|
46
|
+
return await (0, regulation_read_1.keepsRules)(context);
|
|
47
|
+
}
|
|
48
|
+
async activeEmployeeCount(context) {
|
|
49
|
+
const { domain } = context.state;
|
|
50
|
+
const today = (0, employee_reader_1.todayIn)(domain);
|
|
51
|
+
return (await (0, shell_1.getRepository)(organization_1.Employee).find({ where: { domain: { id: domain.id } } })).filter(one => (0, employee_profile_rules_js_1.isActiveEmployee)(one, today)).length;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.RegulationQuery = RegulationQuery;
|
|
55
|
+
tslib_1.__decorate([
|
|
56
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
57
|
+
(0, type_graphql_1.Query)(returns => regulation_type_1.RegulationList, { description: '규정 관리 - the rules of the company, to their keepers (ADR-0187)' }),
|
|
58
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)(type => shell_1.ListParam)),
|
|
59
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
60
|
+
tslib_1.__metadata("design:type", Function),
|
|
61
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
62
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
63
|
+
], RegulationQuery.prototype, "regulations", null);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, type_graphql_1.Query)(returns => [regulation_type_1.RegulationView], {
|
|
66
|
+
description: "회사 규정 - every rule with its versions as the request may read them: adopted ones to the domain's employees, the rest to the keepers; a partner is refused. `topic` narrows to the rules answering a section of the guide."
|
|
67
|
+
}),
|
|
68
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('topic', { nullable: true })),
|
|
69
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
70
|
+
tslib_1.__metadata("design:type", Function),
|
|
71
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
72
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
73
|
+
], RegulationQuery.prototype, "companyRegulations", null);
|
|
74
|
+
tslib_1.__decorate([
|
|
75
|
+
(0, type_graphql_1.Query)(returns => regulation_type_1.RegulationView, { description: 'One rule as the request may read it, by id or by code' }),
|
|
76
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id', { nullable: true })),
|
|
77
|
+
tslib_1.__param(1, (0, type_graphql_1.Arg)('code', { nullable: true })),
|
|
78
|
+
tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
|
|
79
|
+
tslib_1.__metadata("design:type", Function),
|
|
80
|
+
tslib_1.__metadata("design:paramtypes", [String, String, Object]),
|
|
81
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
82
|
+
], RegulationQuery.prototype, "companyRegulation", null);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, type_graphql_1.Query)(returns => Boolean, { description: 'Whether the request is an employee of the domain - who reads its rules and opens 「회사 규정과 안내」' }),
|
|
85
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
86
|
+
tslib_1.__metadata("design:type", Function),
|
|
87
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
88
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
89
|
+
], RegulationQuery.prototype, "amIComplianceEmployee", null);
|
|
90
|
+
tslib_1.__decorate([
|
|
91
|
+
(0, type_graphql_1.Query)(returns => Boolean, { description: 'Whether the request keeps the rules - the screens offer managing them' }),
|
|
92
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
93
|
+
tslib_1.__metadata("design:type", Function),
|
|
94
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
95
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
96
|
+
], RegulationQuery.prototype, "regulationKeeper", null);
|
|
97
|
+
tslib_1.__decorate([
|
|
98
|
+
(0, type_graphql_1.Directive)(KEEP),
|
|
99
|
+
(0, type_graphql_1.Query)(returns => type_graphql_1.Int, { description: "How many employees work here today - shown beside the workers' count a procedure is of, for reference only" }),
|
|
100
|
+
tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
|
|
101
|
+
tslib_1.__metadata("design:type", Function),
|
|
102
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
103
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
104
|
+
], RegulationQuery.prototype, "activeEmployeeCount", null);
|
|
105
|
+
exports.RegulationQuery = RegulationQuery = tslib_1.__decorate([
|
|
106
|
+
(0, type_graphql_1.Resolver)(regulation_1.Regulation),
|
|
107
|
+
(0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
|
|
108
|
+
], RegulationQuery);
|
|
109
|
+
//# sourceMappingURL=regulation-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regulation-query.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6F;AAE7F,+DAAuD;AACvD,2IAA8H;AAC9H,iDAAuH;AAEvH,+DAAsE;AACtE,6CAAyC;AACzC,uDAAmF;AACnF,uDAAkE;AAElE,MAAM,IAAI,GAAG,kFAAkF,CAAA;AAIxF,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,WAAW,CAA0B,MAAiB,EAAS,OAAwB;QAC3F,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM;YAC5B,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,uBAAU,CAAC;YACrC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;YAC7B,KAAK,EAAE,YAAY;YACnB,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SACtD,CAAC,CAAA;QACF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAC3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAKK,AAAN,KAAK,CAAC,kBAAkB,CAAmC,KAAa,EAAS,OAAwB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,EAAE,WAAW,EAAE,4GAA4G,EAAE,CAAC;IAC1H,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;0DAI/B;0BApDU,eAAe;IAF3B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;IACpB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,eAAe,CAqD3B","sourcesContent":["import { Arg, Args, Ctx, Directive, Int, Query, Resolver, UseMiddleware } from 'type-graphql'\n\nimport { Employee } from '@things-factory/organization'\nimport { isActiveEmployee } from '@things-factory/organization/dist-server/service/employee-profile/employee-profile-rules.js'\nimport { getQueryBuilderFromListParams, getRepository, ListParam, Refusal, SpeakRefusals } from '@things-factory/shell'\n\nimport { todayIn, workingEmployeeOf } from '../common/employee-reader'\nimport { Regulation } from './regulation'\nimport { keepsRules, requireRuleReader, viewOfRegulation } from './regulation-read'\nimport { RegulationList, RegulationView } from './regulation-type'\n\nconst KEEP = '@privilege(category: \"regulation\", privilege: \"query\", domainOwnerGranted: true)'\n\n@Resolver(Regulation)\n@UseMiddleware(SpeakRefusals)\nexport class RegulationQuery {\n @Directive(KEEP)\n @Query(returns => RegulationList, { description: '규정 관리 - the rules of the company, to their keepers (ADR-0187)' })\n async regulations(@Args(type => ListParam) params: ListParam, @Ctx() context: ResolverContext): Promise<RegulationList> {\n const queryBuilder = getQueryBuilderFromListParams({\n domain: context.state.domain,\n params,\n repository: getRepository(Regulation),\n searchables: ['code', 'name'],\n alias: 'regulation',\n defaultSortings: [{ name: 'rank' }, { name: 'name' }]\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n return { items, total }\n }\n\n @Query(returns => [RegulationView], {\n description: \"회사 규정 - every rule with its versions as the request may read them: adopted ones to the domain's employees, the rest to the keepers; a partner is refused. `topic` narrows to the rules answering a section of the guide.\"\n })\n async companyRegulations(@Arg('topic', { nullable: true }) topic: string, @Ctx() context: ResolverContext): Promise<RegulationView[]> {\n const keeper = await requireRuleReader(context)\n const rows = await getRepository(Regulation).find({ where: { domain: { id: context.state.domain.id } } as any, order: { rank: 'ASC', name: 'ASC' } as any })\n const views = await Promise.all(rows.filter(one => !topic || (one.topics ?? []).includes(topic)).map(one => viewOfRegulation(undefined, context, one, keeper)))\n return views.filter(one => keeper || one.versions.length)\n }\n\n @Query(returns => RegulationView, { description: 'One rule as the request may read it, by id or by code' })\n async companyRegulation(@Arg('id', { nullable: true }) id: string, @Arg('code', { nullable: true }) code: string, @Ctx() context: ResolverContext): Promise<RegulationView> {\n const keeper = await requireRuleReader(context)\n const where = id ? { id } : { code }\n const row = await getRepository(Regulation).findOne({ where: { ...where, domain: { id: context.state.domain.id } } as any })\n const view = row ? await viewOfRegulation(undefined, context, row, keeper) : null\n if (!view || (!keeper && !view.versions.length)) throw new Refusal('regulation-not-found', {}, 'the rule was not found. reload and try again.')\n return view\n }\n\n @Query(returns => Boolean, { description: 'Whether the request is an employee of the domain - who reads its rules and opens 「회사 규정과 안내」' })\n async amIComplianceEmployee(@Ctx() context: ResolverContext): Promise<boolean> {\n return !!(await workingEmployeeOf(context))\n }\n\n @Query(returns => Boolean, { description: 'Whether the request keeps the rules - the screens offer managing them' })\n async regulationKeeper(@Ctx() context: ResolverContext): Promise<boolean> {\n return await keepsRules(context)\n }\n\n @Directive(KEEP)\n @Query(returns => Int, { description: \"How many employees work here today - shown beside the workers' count a procedure is of, for reference only\" })\n async activeEmployeeCount(@Ctx() context: ResolverContext): Promise<number> {\n const { domain } = context.state\n const today = todayIn(domain)\n return (await getRepository(Employee).find({ where: { domain: { id: domain.id } } as any })).filter(one => isActiveEmployee(one as any, today)).length\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { type HelpPart } from '@things-factory/help';
|
|
3
|
+
import { Regulation, RegulationVersion } from './regulation';
|
|
4
|
+
import { RegulationVersionView, RegulationView } from './regulation-type';
|
|
5
|
+
/** Whether the request keeps the rules. */
|
|
6
|
+
export declare const keepsRules: (context: any) => Promise<boolean>;
|
|
7
|
+
/** Whether the request may read the adopted rules - an employee of the domain, or a keeper. */
|
|
8
|
+
export declare function readsRules(context: any): Promise<boolean>;
|
|
9
|
+
/** A version as the request sees it, or nothing when it may not. */
|
|
10
|
+
export declare function viewOfVersion(tx: EntityManager | undefined, context: any, version: RegulationVersion, siblings: RegulationVersion[], keeper: boolean): Promise<RegulationVersionView | null>;
|
|
11
|
+
/** A rule as the request sees it - its versions, the one in force and the one due. */
|
|
12
|
+
export declare function viewOfRegulation(tx: EntityManager | undefined, context: any, regulation: Regulation, keeper: boolean): Promise<RegulationView>;
|
|
13
|
+
/** The request may read the rules, or is refused - a partner is told so. */
|
|
14
|
+
export declare function requireRuleReader(context: any): Promise<boolean>;
|
|
15
|
+
/** The help's parts of the rules: an article of each version in force or due is a part (ADR-0187 decision 12). */
|
|
16
|
+
export declare function regulationParts(domain: {
|
|
17
|
+
id: string;
|
|
18
|
+
timezone?: string;
|
|
19
|
+
}): Promise<HelpPart[]>;
|
|
20
|
+
/** The rules' articles in the help's search, and the papers of a procedure to its keepers only. */
|
|
21
|
+
export declare function registerRegulationReaders(): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keepsRules = void 0;
|
|
4
|
+
exports.readsRules = readsRules;
|
|
5
|
+
exports.viewOfVersion = viewOfVersion;
|
|
6
|
+
exports.viewOfRegulation = viewOfRegulation;
|
|
7
|
+
exports.requireRuleReader = requireRuleReader;
|
|
8
|
+
exports.regulationParts = regulationParts;
|
|
9
|
+
exports.registerRegulationReaders = registerRegulationReaders;
|
|
10
|
+
const typeorm_1 = require("typeorm");
|
|
11
|
+
const announcement_1 = require("@things-factory/announcement");
|
|
12
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
13
|
+
const help_1 = require("@things-factory/help");
|
|
14
|
+
const shell_1 = require("@things-factory/shell");
|
|
15
|
+
const employee_reader_1 = require("../common/employee-reader");
|
|
16
|
+
const regulation_1 = require("./regulation");
|
|
17
|
+
const regulation_rules_1 = require("./regulation-rules");
|
|
18
|
+
const regulation_service_1 = require("./regulation-service");
|
|
19
|
+
/*
|
|
20
|
+
* Who reads a company rule (ADR-0187 decision 7), asked by every door - the list, one rule, its papers, the help's search:
|
|
21
|
+
* an adopted version, past ones too, is read by the domain's employees; a version being written or in approval, the
|
|
22
|
+
* procedure and its papers by the keepers of the rules (`regulation`) only. A partner reads none.
|
|
23
|
+
*/
|
|
24
|
+
/** Whether the request keeps the rules. */
|
|
25
|
+
const keepsRules = (context) => (0, employee_reader_1.holds)(context, 'regulation', 'query');
|
|
26
|
+
exports.keepsRules = keepsRules;
|
|
27
|
+
/** Whether the request may read the adopted rules - an employee of the domain, or a keeper. */
|
|
28
|
+
async function readsRules(context) {
|
|
29
|
+
return !!(await (0, employee_reader_1.workingEmployeeOf)(context)) || (await (0, exports.keepsRules)(context));
|
|
30
|
+
}
|
|
31
|
+
/** A version as the request sees it, or nothing when it may not. */
|
|
32
|
+
async function viewOfVersion(tx, context, version, siblings, keeper) {
|
|
33
|
+
const { domain, user } = context.state;
|
|
34
|
+
if (version.status !== regulation_1.RegulationVersionStatus.ADOPTED && !keeper)
|
|
35
|
+
return null;
|
|
36
|
+
const today = (0, employee_reader_1.todayIn)(domain);
|
|
37
|
+
const standing = (0, regulation_rules_1.standingOf)(siblings, today);
|
|
38
|
+
const adopted = siblings.filter(one => one.status === regulation_1.RegulationVersionStatus.ADOPTED && one.effectiveOn).sort((a, b) => (a.effectiveOn < b.effectiveOn ? -1 : 1));
|
|
39
|
+
const next = adopted.find(one => one.effectiveOn > (version.effectiveOn ?? '') && one.id !== version.id);
|
|
40
|
+
const clauses = version.status === regulation_1.RegulationVersionStatus.ADOPTED
|
|
41
|
+
? await (0, shell_1.getRepository)(regulation_1.RegulationClause, tx).find({ where: { version: { id: version.id } }, order: { rank: 'ASC' } })
|
|
42
|
+
: (0, regulation_rules_1.clausesOf)(version.body).map((one, rank) => ({ id: `${version.id}:${rank}`, rank, versionId: version.id, ...one }));
|
|
43
|
+
const before = await (0, regulation_service_1.previousAdopted)((0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).manager, version);
|
|
44
|
+
const changes = (0, regulation_rules_1.clauseChanges)(before ? (0, regulation_rules_1.clausesOf)(before.body) : [], (0, regulation_rules_1.clausesOf)(version.body)).map(one => ({ ...one, title: one.title ?? undefined }));
|
|
45
|
+
const announcement = version.announcementId ? (await (0, regulation_service_1.announcementsOfVersions)((0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).manager, domain, [version.id])).get(version.id) : undefined;
|
|
46
|
+
const receipt = announcement ? (await (0, announcement_1.receiptsOf)([announcement.id], user.id, tx)).get(announcement.id) : undefined;
|
|
47
|
+
return {
|
|
48
|
+
version,
|
|
49
|
+
period: (0, regulation_rules_1.periodOfVersion)(version, standing, today),
|
|
50
|
+
endsOn: version.status === regulation_1.RegulationVersionStatus.ADOPTED ? next?.effectiveOn : undefined,
|
|
51
|
+
clauses,
|
|
52
|
+
changes,
|
|
53
|
+
procedures: keeper ? (await (0, regulation_service_1.proceduresOf)((0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).manager, domain, [version.id])) : undefined,
|
|
54
|
+
announcement: keeper ? announcement : undefined,
|
|
55
|
+
told: announcement?.status === 'PUBLISHED',
|
|
56
|
+
readAt: receipt?.acknowledgedAt ?? undefined
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** A rule as the request sees it - its versions, the one in force and the one due. */
|
|
60
|
+
async function viewOfRegulation(tx, context, regulation, keeper) {
|
|
61
|
+
const today = (0, employee_reader_1.todayIn)(context.state.domain);
|
|
62
|
+
const siblings = await (0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).find({ where: { regulation: { id: regulation.id } }, order: { version: 'DESC' } });
|
|
63
|
+
const views = (await Promise.all(siblings.map(one => viewOfVersion(tx, context, one, siblings, keeper)))).filter(Boolean);
|
|
64
|
+
const standing = (0, regulation_rules_1.standingOf)(siblings, today);
|
|
65
|
+
return { regulation, inForce: views.find(one => one.version.id === standing.inForce?.id), due: views.find(one => one.version.id === standing.due?.id), versions: views };
|
|
66
|
+
}
|
|
67
|
+
/** The request may read the rules, or is refused - a partner is told so. */
|
|
68
|
+
async function requireRuleReader(context) {
|
|
69
|
+
const keeper = await (0, exports.keepsRules)(context);
|
|
70
|
+
if (!keeper && !(await (0, employee_reader_1.workingEmployeeOf)(context)))
|
|
71
|
+
throw new shell_1.Refusal('compliance-employees-only', {}, 'only an employee of this company reads its rules');
|
|
72
|
+
return keeper;
|
|
73
|
+
}
|
|
74
|
+
/** The help's parts of the rules: an article of each version in force or due is a part (ADR-0187 decision 12). */
|
|
75
|
+
async function regulationParts(domain) {
|
|
76
|
+
const today = (0, employee_reader_1.todayIn)(domain);
|
|
77
|
+
const regulations = await (0, shell_1.getRepository)(regulation_1.Regulation).find({ where: { domain: { id: domain.id } } });
|
|
78
|
+
if (!regulations.length)
|
|
79
|
+
return [];
|
|
80
|
+
const versions = await (0, shell_1.getRepository)(regulation_1.RegulationVersion).find({ where: { regulation: { id: (0, typeorm_1.In)(regulations.map(one => one.id)) }, status: regulation_1.RegulationVersionStatus.ADOPTED } });
|
|
81
|
+
const parts = [];
|
|
82
|
+
for (const regulation of regulations) {
|
|
83
|
+
const { inForce, due } = (0, regulation_rules_1.standingOf)(versions.filter(one => one.regulationId === regulation.id), today);
|
|
84
|
+
for (const version of [inForce, due].filter(Boolean)) {
|
|
85
|
+
const clauses = await (0, shell_1.getRepository)(regulation_1.RegulationClause).find({ where: { version: { id: version.id } }, order: { rank: 'ASC' } });
|
|
86
|
+
const when = version === due ? `${version.effectiveOn} 시행 예정` : `${version.effectiveOn} 시행`;
|
|
87
|
+
for (const clause of clauses)
|
|
88
|
+
parts.push({
|
|
89
|
+
topic: `${regulation_service_1.REGULATION_HELP_SOURCE}/${regulation.code}`,
|
|
90
|
+
section: clause.number,
|
|
91
|
+
lang: '',
|
|
92
|
+
title: `${regulation.name} 제${clause.number}조${clause.title ? `(${clause.title})` : ''}`,
|
|
93
|
+
documentTitle: regulation.name,
|
|
94
|
+
summary: `제${version.version}판 · ${when}.`,
|
|
95
|
+
text: `제${version.version}판 · ${when}. ${clause.text}`,
|
|
96
|
+
link: `regulations?regulation=${encodeURIComponent(regulation.code)}&clause=${encodeURIComponent(clause.number)}`
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return parts;
|
|
101
|
+
}
|
|
102
|
+
/** The rules' articles in the help's search, and the papers of a procedure to its keepers only. */
|
|
103
|
+
function registerRegulationReaders() {
|
|
104
|
+
(0, help_1.registerHelpSource)({ name: regulation_service_1.REGULATION_HELP_SOURCE, partsOf: domain => regulationParts(domain), mayRead: readsRules });
|
|
105
|
+
(0, attachment_base_1.registerAttachmentReader)(regulation_service_1.REGULATION_PROCEDURE_REF_TYPE, async (attachment, context) => {
|
|
106
|
+
if (!attachment.refBy || !(await (0, exports.keepsRules)(context)))
|
|
107
|
+
return false;
|
|
108
|
+
return !!(await (0, shell_1.getRepository)(regulation_1.RegulationProcedure).findOne({ where: { id: attachment.refBy, domain: { id: context.state.domain.id } } }));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=regulation-read.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regulation-read.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-read.ts"],"names":[],"mappings":";;;AAuBA,gCAEC;AAGD,sCA0BC;AAGD,4CAMC;AAGD,8CAIC;AAGD,0CAyBC;AAGD,8DAMC;AA3GD,qCAA2C;AAE3C,+DAAyD;AACzD,qEAA0E;AAC1E,+CAAwE;AACxE,iDAA8D;AAE9D,+DAA6E;AAC7E,6CAA4H;AAC5H,yDAA0F;AAC1F,6DAAoJ;AAGpJ;;;;GAIG;AAEH,2CAA2C;AACpC,MAAM,UAAU,GAAG,CAAC,OAAY,EAAE,EAAE,CAAC,IAAA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O,KAAK,CAAA;QACnE,OAAO,CAAC,CAAC,CAAC,MAAM,IAAA,qBAAa,EAAC,gCAAmB,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAG,OAAe,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,EAAS,EAAE,CAAC,CAAC,CAAA;IAC3J,CAAC,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { EntityManager, In } from 'typeorm'\n\nimport { receiptsOf } from '@things-factory/announcement'\nimport { registerAttachmentReader } from '@things-factory/attachment-base'\nimport { registerHelpSource, type HelpPart } from '@things-factory/help'\nimport { getRepository, Refusal } from '@things-factory/shell'\n\nimport { holds, todayIn, workingEmployeeOf } from '../common/employee-reader'\nimport { Regulation, RegulationClause, RegulationProcedure, RegulationVersion, RegulationVersionStatus } from './regulation'\nimport { clauseChanges, clausesOf, periodOfVersion, standingOf } from './regulation-rules'\nimport { announcementsOfVersions, previousAdopted, proceduresOf, REGULATION_HELP_SOURCE, REGULATION_PROCEDURE_REF_TYPE } from './regulation-service'\nimport { RegulationVersionView, RegulationView } from './regulation-type'\n\n/*\n * Who reads a company rule (ADR-0187 decision 7), asked by every door - the list, one rule, its papers, the help's search:\n * an adopted version, past ones too, is read by the domain's employees; a version being written or in approval, the\n * procedure and its papers by the keepers of the rules (`regulation`) only. A partner reads none.\n */\n\n/** Whether the request keeps the rules. */\nexport const keepsRules = (context: any) => holds(context, 'regulation', 'query')\n\n/** Whether the request may read the adopted rules - an employee of the domain, or a keeper. */\nexport async function readsRules(context: any): Promise<boolean> {\n return !!(await workingEmployeeOf(context)) || (await keepsRules(context))\n}\n\n/** A version as the request sees it, or nothing when it may not. */\nexport async function viewOfVersion(tx: EntityManager | undefined, context: any, version: RegulationVersion, siblings: RegulationVersion[], keeper: boolean): Promise<RegulationVersionView | null> {\n const { domain, user } = context.state\n if (version.status !== RegulationVersionStatus.ADOPTED && !keeper) return null\n const today = todayIn(domain)\n const standing = standingOf(siblings, today)\n const adopted = siblings.filter(one => one.status === RegulationVersionStatus.ADOPTED && one.effectiveOn).sort((a, b) => (a.effectiveOn! < b.effectiveOn! ? -1 : 1))\n const next = adopted.find(one => one.effectiveOn! > (version.effectiveOn ?? '') && one.id !== version.id)\n const clauses =\n version.status === RegulationVersionStatus.ADOPTED\n ? await getRepository(RegulationClause, tx).find({ where: { version: { id: version.id } } as any, order: { rank: 'ASC' } as any })\n : (clausesOf(version.body).map((one, rank) => ({ id: `${version.id}:${rank}`, rank, versionId: version.id, ...one })) as any[])\n const before = await previousAdopted(getRepository(RegulationVersion, tx).manager, version)\n const changes = clauseChanges(before ? clausesOf(before.body) : [], clausesOf(version.body)).map(one => ({ ...one, title: one.title ?? undefined }))\n const announcement = version.announcementId ? (await announcementsOfVersions(getRepository(RegulationVersion, tx).manager, domain, [version.id])).get(version.id) : undefined\n const receipt = announcement ? (await receiptsOf([announcement.id], user.id, tx)).get(announcement.id) : undefined\n return {\n version,\n period: periodOfVersion(version, standing, today),\n endsOn: version.status === RegulationVersionStatus.ADOPTED ? next?.effectiveOn : undefined,\n clauses,\n changes,\n procedures: keeper ? ((await proceduresOf(getRepository(RegulationVersion, tx).manager, domain, [version.id])) as any) : undefined,\n announcement: keeper ? announcement : undefined,\n told: announcement?.status === 'PUBLISHED',\n readAt: receipt?.acknowledgedAt ?? undefined\n }\n}\n\n/** A rule as the request sees it - its versions, the one in force and the one due. */\nexport async function viewOfRegulation(tx: EntityManager | undefined, context: any, regulation: Regulation, keeper: boolean): Promise<RegulationView> {\n const today = todayIn(context.state.domain)\n const siblings = await getRepository(RegulationVersion, tx).find({ where: { regulation: { id: regulation.id } } as any, order: { version: 'DESC' } as any })\n const views = (await Promise.all(siblings.map(one => viewOfVersion(tx, context, one, siblings, keeper)))).filter(Boolean) as RegulationVersionView[]\n const standing = standingOf(siblings, today)\n return { regulation, inForce: views.find(one => one.version.id === standing.inForce?.id), due: views.find(one => one.version.id === standing.due?.id), versions: views }\n}\n\n/** The request may read the rules, or is refused - a partner is told so. */\nexport async function requireRuleReader(context: any): Promise<boolean> {\n const keeper = await keepsRules(context)\n if (!keeper && !(await workingEmployeeOf(context))) throw new Refusal('compliance-employees-only', {}, 'only an employee of this company reads its rules')\n return keeper\n}\n\n/** The help's parts of the rules: an article of each version in force or due is a part (ADR-0187 decision 12). */\nexport async function regulationParts(domain: { id: string; timezone?: string }): Promise<HelpPart[]> {\n const today = todayIn(domain)\n const regulations = await getRepository(Regulation).find({ where: { domain: { id: domain.id } } as any })\n if (!regulations.length) return []\n const versions = await getRepository(RegulationVersion).find({ where: { regulation: { id: In(regulations.map(one => one.id)) }, status: RegulationVersionStatus.ADOPTED } as any })\n const parts: HelpPart[] = []\n for (const regulation of regulations) {\n const { inForce, due } = standingOf(versions.filter(one => one.regulationId === regulation.id), today)\n for (const version of [inForce, due].filter(Boolean) as RegulationVersion[]) {\n const clauses = await getRepository(RegulationClause).find({ where: { version: { id: version.id } } as any, order: { rank: 'ASC' } as any })\n const when = version === due ? `${version.effectiveOn} 시행 예정` : `${version.effectiveOn} 시행`\n for (const clause of clauses)\n parts.push({\n topic: `${REGULATION_HELP_SOURCE}/${regulation.code}`,\n section: clause.number,\n lang: '',\n title: `${regulation.name} 제${clause.number}조${clause.title ? `(${clause.title})` : ''}`,\n documentTitle: regulation.name,\n summary: `제${version.version}판 · ${when}.`,\n text: `제${version.version}판 · ${when}. ${clause.text}`,\n link: `regulations?regulation=${encodeURIComponent(regulation.code)}&clause=${encodeURIComponent(clause.number)}`\n })\n }\n }\n return parts\n}\n\n/** The rules' articles in the help's search, and the papers of a procedure to its keepers only. */\nexport function registerRegulationReaders(): void {\n registerHelpSource({ name: REGULATION_HELP_SOURCE, partsOf: domain => regulationParts(domain as any), mayRead: readsRules })\n registerAttachmentReader(REGULATION_PROCEDURE_REF_TYPE, async (attachment, context) => {\n if (!attachment.refBy || !(await keepsRules(context))) return false\n return !!(await getRepository(RegulationProcedure).findOne({ where: { id: attachment.refBy, domain: { id: (context as any).state.domain.id } } as any }))\n })\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Refusal } from '@things-factory/shell';
|
|
2
|
+
/** Each kind, and the procedure the law asks before a version of it is adopted. */
|
|
3
|
+
export declare const REGULATION_KINDS: Record<string, {
|
|
4
|
+
opinion: boolean;
|
|
5
|
+
consentWhenUnfavourable: boolean;
|
|
6
|
+
filing: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
/** How an opinion, a consent or a filing was taken. */
|
|
9
|
+
export declare const PROCEDURE_METHODS: Record<string, string[]>;
|
|
10
|
+
export interface Clause {
|
|
11
|
+
number: string;
|
|
12
|
+
title: string | null;
|
|
13
|
+
chapter: string | null;
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The articles of a text, each from its `제n조(제목)` head up to the next article or chapter. The words before the first
|
|
18
|
+
* article are no article. A chapter head (`제2장 근로시간`) is kept as the chapter of the articles after it.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clausesOf(body: string | null | undefined): Clause[];
|
|
21
|
+
export interface ClauseChange {
|
|
22
|
+
number: string;
|
|
23
|
+
title: string | null;
|
|
24
|
+
change: 'ADDED' | 'CHANGED' | 'REMOVED';
|
|
25
|
+
}
|
|
26
|
+
/** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */
|
|
27
|
+
export declare function clauseChanges(before: Clause[], after: Clause[]): ClauseChange[];
|
|
28
|
+
export interface ProcedureFacts {
|
|
29
|
+
kind: string;
|
|
30
|
+
day?: string | null;
|
|
31
|
+
workersCount?: number | null;
|
|
32
|
+
consentCount?: number | null;
|
|
33
|
+
files: number;
|
|
34
|
+
}
|
|
35
|
+
export interface VersionFacts {
|
|
36
|
+
kind: string;
|
|
37
|
+
body?: string | null;
|
|
38
|
+
effectiveOn?: string | null;
|
|
39
|
+
unfavourable?: boolean | null;
|
|
40
|
+
}
|
|
41
|
+
/** What a regulation asks before it is written. */
|
|
42
|
+
export declare function regulationRefusal(input: {
|
|
43
|
+
code?: string | null;
|
|
44
|
+
name?: string | null;
|
|
45
|
+
kind?: string | null;
|
|
46
|
+
}): Refusal | null;
|
|
47
|
+
/**
|
|
48
|
+
* What a version asks before it is put up for adoption (decision 4). The writer must say whether the change is against
|
|
49
|
+
* the workers - there is no default. A rule of working conditions needs the majority's opinion with its papers; against
|
|
50
|
+
* them, the consent of more than half with its papers.
|
|
51
|
+
*/
|
|
52
|
+
export declare function adoptionRefusal(version: VersionFacts, procedures: ProcedureFacts[], today: string): Refusal | null;
|
|
53
|
+
/** What a procedure record asks before it is written. */
|
|
54
|
+
export declare function procedureRefusal(input: {
|
|
55
|
+
kind?: string | null;
|
|
56
|
+
day?: string | null;
|
|
57
|
+
method?: string | null;
|
|
58
|
+
workersCount?: number | null;
|
|
59
|
+
consentCount?: number | null;
|
|
60
|
+
}): Refusal | null;
|
|
61
|
+
/** Adopted versions as they stand on `today`: the one in force is the latest whose day has come. */
|
|
62
|
+
export declare function standingOf<V extends {
|
|
63
|
+
status: string;
|
|
64
|
+
effectiveOn?: string | null;
|
|
65
|
+
version: number;
|
|
66
|
+
}>(versions: V[], today: string): {
|
|
67
|
+
inForce: V | null;
|
|
68
|
+
due: V | null;
|
|
69
|
+
};
|
|
70
|
+
/** Where an adopted version stands on `today`. */
|
|
71
|
+
export declare function periodOfVersion(version: {
|
|
72
|
+
status: string;
|
|
73
|
+
effectiveOn?: string | null;
|
|
74
|
+
id: string;
|
|
75
|
+
}, standing: {
|
|
76
|
+
inForce: {
|
|
77
|
+
id: string;
|
|
78
|
+
} | null;
|
|
79
|
+
}, today: string): 'DRAFT' | 'IN_APPROVAL' | 'DUE' | 'IN_FORCE' | 'PAST';
|
|
80
|
+
/** What may change on an adopted version - nothing but the workers count the filing reads. A draft changes freely. */
|
|
81
|
+
export declare function changeRefusal(status: string): Refusal | null;
|
|
82
|
+
/** A procedure is recorded on a draft; a filing also after adoption, since it follows it. */
|
|
83
|
+
export declare function procedureWriteRefusal(status: string, kind: string): Refusal | null;
|