@things-factory/compliance 10.1.254 → 10.1.256

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.
Files changed (46) hide show
  1. package/dist-client/pages/regulation-detail.d.ts +3 -0
  2. package/dist-client/pages/regulation-detail.js +45 -3
  3. package/dist-client/pages/regulation-detail.js.map +1 -1
  4. package/dist-client/pages/regulations.js +41 -12
  5. package/dist-client/pages/regulations.js.map +1 -1
  6. package/dist-client/regulation/regulation-fragments.js +5 -0
  7. package/dist-client/regulation/regulation-fragments.js.map +1 -1
  8. package/dist-client/tsconfig.tsbuildinfo +1 -1
  9. package/dist-client/words.js +1 -1
  10. package/dist-client/words.js.map +1 -1
  11. package/dist-server/activities/index.js +9 -7
  12. package/dist-server/activities/index.js.map +1 -1
  13. package/dist-server/index.d.ts +1 -0
  14. package/dist-server/index.js +1 -0
  15. package/dist-server/index.js.map +1 -1
  16. package/dist-server/service/index.d.ts +1 -1
  17. package/dist-server/service/index.js +2 -1
  18. package/dist-server/service/index.js.map +1 -1
  19. package/dist-server/service/regulation/regulation-mutation.d.ts +1 -0
  20. package/dist-server/service/regulation/regulation-mutation.js +14 -0
  21. package/dist-server/service/regulation/regulation-mutation.js.map +1 -1
  22. package/dist-server/service/regulation/regulation-read.js +11 -2
  23. package/dist-server/service/regulation/regulation-read.js.map +1 -1
  24. package/dist-server/service/regulation/regulation-rules.d.ts +22 -3
  25. package/dist-server/service/regulation/regulation-rules.js +69 -13
  26. package/dist-server/service/regulation/regulation-rules.js.map +1 -1
  27. package/dist-server/service/regulation/regulation-service.d.ts +12 -0
  28. package/dist-server/service/regulation/regulation-service.js +48 -7
  29. package/dist-server/service/regulation/regulation-service.js.map +1 -1
  30. package/dist-server/service/regulation/regulation-type.d.ts +4 -0
  31. package/dist-server/service/regulation/regulation-type.js +16 -0
  32. package/dist-server/service/regulation/regulation-type.js.map +1 -1
  33. package/dist-server/service/regulation/regulation.d.ts +2 -0
  34. package/dist-server/service/regulation/regulation.js +11 -1
  35. package/dist-server/service/regulation/regulation.js.map +1 -1
  36. package/dist-server/tsconfig.tsbuildinfo +1 -1
  37. package/dist-server/work-doors.d.ts +1 -0
  38. package/dist-server/work-doors.js +15 -0
  39. package/dist-server/work-doors.js.map +1 -0
  40. package/package.json +14 -14
  41. package/translations/en.json +22 -1
  42. package/translations/es.json +22 -1
  43. package/translations/ja.json +22 -1
  44. package/translations/ko.json +78 -57
  45. package/translations/ms.json +22 -1
  46. package/translations/zh.json +22 -1
@@ -2,7 +2,7 @@ import { i18next } from '@operato/i18n';
2
2
  /* What the seal use codes read as, in the reader's words. */
3
3
  export const USE_KINDS = ['STAMP', 'TAKE_OUT', 'CERTIFICATE'];
4
4
  export const USE_STATUSES = ['RECORDED', 'SUBMITTED', 'APPROVED', 'REJECTED', 'WITHDRAWN'];
5
- export const SEAL_KINDS = ['CORPORATE', 'USE', 'OFFICIAL'];
5
+ export const SEAL_KINDS = ['CORPORATE', 'USE', 'OFFICIAL', 'NAMEPLATE', 'CONFIDENTIAL'];
6
6
  export const REGULATION_KINDS = ['WORK_RULES', 'WORK_RULES_ANNEX', 'PRIVACY_POLICY', 'PRIVACY_PLAN', 'OTHER'];
7
7
  export const PROCEDURE_KINDS = ['OPINION', 'CONSENT', 'FILING'];
8
8
  export const PROCEDURE_METHODS = {
@@ -1 +1 @@
1
- {"version":3,"file":"words.js","sourceRoot":"","sources":["../client/words.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,CAAA;AAC1F,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,WAAW,EAAE,KAAK,EAAE,UAAU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AAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import { i18next } from '@operato/i18n'\n\n/* What the seal use codes read as, in the reader's words. */\nexport const USE_KINDS = ['STAMP', 'TAKE_OUT', 'CERTIFICATE']\nexport const USE_STATUSES = ['RECORDED', 'SUBMITTED', 'APPROVED', 'REJECTED', 'WITHDRAWN']\nexport const SEAL_KINDS = ['CORPORATE', 'USE', 'OFFICIAL']\nexport const REGULATION_KINDS = ['WORK_RULES', 'WORK_RULES_ANNEX', 'PRIVACY_POLICY', 'PRIVACY_PLAN', 'OTHER']\nexport const PROCEDURE_KINDS = ['OPINION', 'CONSENT', 'FILING']\nexport const PROCEDURE_METHODS: Record<string, string[]> = {\n OPINION: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],\n CONSENT: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],\n FILING: ['ONLINE', 'VISIT', 'MAIL']\n}\n\nconst kebab = (code: string) => code.toLowerCase().replace(/_/g, '-')\n/** The word for a code of a set - `text.seal-use-kind-stamp`. */\nexport const wordOf = (set: string, code?: string | null) => (code ? i18next.t(`text.${set}-${kebab(code)}`) : '')\n/** A grid's select options for a set. */\nexport const optionsOf = (set: string, codes: string[]) => codes.map(value => ({ value, display: wordOf(set, value) }))\n\n/** What a failed call says, in the server's words. */\nexport const failureOf = (error: any) => error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n"]}
1
+ {"version":3,"file":"words.js","sourceRoot":"","sources":["../client/words.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC,6DAA6D;AAC7D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,UAAU,EAAE,WAA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MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA","sourcesContent":["import { i18next } from '@operato/i18n'\n\n/* What the seal use codes read as, in the reader's words. */\nexport const USE_KINDS = ['STAMP', 'TAKE_OUT', 'CERTIFICATE']\nexport const USE_STATUSES = ['RECORDED', 'SUBMITTED', 'APPROVED', 'REJECTED', 'WITHDRAWN']\nexport const SEAL_KINDS = ['CORPORATE', 'USE', 'OFFICIAL', 'NAMEPLATE', 'CONFIDENTIAL']\nexport const REGULATION_KINDS = ['WORK_RULES', 'WORK_RULES_ANNEX', 'PRIVACY_POLICY', 'PRIVACY_PLAN', 'OTHER']\nexport const PROCEDURE_KINDS = ['OPINION', 'CONSENT', 'FILING']\nexport const PROCEDURE_METHODS: Record<string, string[]> = {\n OPINION: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],\n CONSENT: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],\n FILING: ['ONLINE', 'VISIT', 'MAIL']\n}\n\nconst kebab = (code: string) => code.toLowerCase().replace(/_/g, '-')\n/** The word for a code of a set - `text.seal-use-kind-stamp`. */\nexport const wordOf = (set: string, code?: string | null) => (code ? i18next.t(`text.${set}-${kebab(code)}`) : '')\n/** A grid's select options for a set. */\nexport const optionsOf = (set: string, codes: string[]) => codes.map(value => ({ value, display: wordOf(set, value) }))\n\n/** What a failed call says, in the server's words. */\nexport const failureOf = (error: any) => error?.graphQLErrors?.[0]?.message ?? error?.errors?.[0]?.message ?? error?.message ?? String(error)\n"]}
@@ -22,14 +22,16 @@ Object.defineProperty(exports, "REGULATION_ACTIVITIES", { enumerable: true, get:
22
22
  legal_todo_activity_1.LEGAL_TODO_ACTIVITIES.forEach(template => worklist_1.ActivityInstallations.installActivityTemplate(template));
23
23
  seal_use_activity_1.SEAL_USE_ACTIVITIES.forEach(template => worklist_1.ActivityInstallations.installActivityTemplate(template));
24
24
  regulation_activity_1.REGULATION_ACTIVITIES.forEach(template => worklist_1.ActivityInstallations.installActivityTemplate(template));
25
- /* Using the corporate seal is what the approval decides, so with no approver named it is refused (ADR-0077, ADR-0188). */
26
- (0, worklist_1.registerWorkDoors)({
27
- module: 'compliance',
28
- doors: seal_use_activity_1.SEAL_USE_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval', whenNoLine: 'refuse', because: 'approval-is-the-act' }))
29
- });
30
- /* Adopting a version where nobody approves adopts it, and the worklist writes down it ran without a line (ADR-0187 decision 5). */
25
+ /*
26
+ * One registration for the module - worklist keeps one per module, so a second call would replace the first.
27
+ * Using the corporate seal is what the approval decides, so with no approver named it is refused (ADR-0077, ADR-0188).
28
+ * Adopting a version where nobody approves adopts it, and the worklist writes down it ran without a line (ADR-0187 decision 5).
29
+ */
31
30
  (0, worklist_1.registerWorkDoors)({
32
31
  module: 'compliance',
33
- doors: regulation_activity_1.REGULATION_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval', whenNoLine: 'run' }))
32
+ doors: [
33
+ ...seal_use_activity_1.SEAL_USE_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval', whenNoLine: 'refuse', because: 'approval-is-the-act' })),
34
+ ...regulation_activity_1.REGULATION_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval', whenNoLine: 'run' }))
35
+ ]
34
36
  });
35
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/activities/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAmF;AAEnF,+DAA6D;AAC7D,+DAA6D;AAC7D,2DAAyD;AAEzD,oEAAyC;AACzC,yDAAyD;AAAhD,wHAAA,mBAAmB,OAAA;AAC5B,sEAA2C;AAC3C,6DAA6D;AAApD,4HAAA,qBAAqB,OAAA;AAC9B,sEAA2C;AAC3C,6DAA6D;AAApD,4HAAA,qBAAqB,OAAA;AAE9B;;;GAGG;AACH,2CAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gCAAqB,CAAC,uBAAuB,CAAC,QAAe,CAAC,CAAC,CAAA;AACzG,uCAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gCAAqB,CAAC,uBAAuB,CAAC,QAAe,CAAC,CAAC,CAAA;AACvG,2CAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gCAAqB,CAAC,uBAAuB,CAAC,QAAe,CAAC,CAAC,CAAA;AAEzG,0HAA0H;AAC1H,IAAA,4BAAiB,EAAC;IAChB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,uCAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAmB,EAAE,UAAU,EAAE,QAAiB,EAAE,OAAO,EAAE,qBAA8B,EAAE,CAAC,CAAC;CAC/J,CAAC,CAAA;AAEF,mIAAmI;AACnI,IAAA,4BAAiB,EAAC;IAChB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE,2CAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAmB,EAAE,UAAU,EAAE,KAAc,EAAE,CAAC,CAAC;CACrH,CAAC,CAAA","sourcesContent":["import { ActivityInstallations, registerWorkDoors } from '@things-factory/worklist'\n\nimport { LEGAL_TODO_ACTIVITIES } from './legal-todo-activity'\nimport { REGULATION_ACTIVITIES } from './regulation-activity'\nimport { SEAL_USE_ACTIVITIES } from './seal-use-activity'\n\nexport * from './seal-use-activity-names'\nexport { SEAL_USE_ACTIVITIES } from './seal-use-activity'\nexport * from './legal-todo-activity-names'\nexport { LEGAL_TODO_ACTIVITIES } from './legal-todo-activity'\nexport * from './regulation-activity-names'\nexport { REGULATION_ACTIVITIES } from './regulation-activity'\n\n/*\n * **Importing this file registers the approval template** - a bootstrap hook would be too late for worklist to find the\n * callback. Which domains have it is the application's call: it installs `SEAL_USE_ACTIVITIES`.\n */\nLEGAL_TODO_ACTIVITIES.forEach(template => ActivityInstallations.installActivityTemplate(template as any))\nSEAL_USE_ACTIVITIES.forEach(template => ActivityInstallations.installActivityTemplate(template as any))\nREGULATION_ACTIVITIES.forEach(template => ActivityInstallations.installActivityTemplate(template as any))\n\n/* Using the corporate seal is what the approval decides, so with no approver named it is refused (ADR-0077, ADR-0188). */\nregisterWorkDoors({\n module: 'compliance',\n doors: SEAL_USE_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval' as const, whenNoLine: 'refuse' as const, because: 'approval-is-the-act' as const }))\n})\n\n/* Adopting a version where nobody approves adopts it, and the worklist writes down it ran without a line (ADR-0187 decision 5). */\nregisterWorkDoors({\n module: 'compliance',\n doors: REGULATION_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval' as const, whenNoLine: 'run' as const }))\n})\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/activities/index.ts"],"names":[],"mappings":";;;;AAAA,uDAAmF;AAEnF,+DAA6D;AAC7D,+DAA6D;AAC7D,2DAAyD;AAEzD,oEAAyC;AACzC,yDAAyD;AAAhD,wHAAA,mBAAmB,OAAA;AAC5B,sEAA2C;AAC3C,6DAA6D;AAApD,4HAAA,qBAAqB,OAAA;AAC9B,sEAA2C;AAC3C,6DAA6D;AAApD,4HAAA,qBAAqB,OAAA;AAE9B;;;GAGG;AACH,2CAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gCAAqB,CAAC,uBAAuB,CAAC,QAAe,CAAC,CAAC,CAAA;AACzG,uCAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gCAAqB,CAAC,uBAAuB,CAAC,QAAe,CAAC,CAAC,CAAA;AACvG,2CAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,gCAAqB,CAAC,uBAAuB,CAAC,QAAe,CAAC,CAAC,CAAA;AAEzG;;;;GAIG;AACH,IAAA,4BAAiB,EAAC;IAChB,MAAM,EAAE,YAAY;IACpB,KAAK,EAAE;QACL,GAAG,uCAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAmB,EAAE,UAAU,EAAE,QAAiB,EAAE,OAAO,EAAE,qBAA8B,EAAE,CAAC,CAAC;QAC1J,GAAG,2CAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAmB,EAAE,UAAU,EAAE,KAAc,EAAE,CAAC,CAAC;KACjH;CACF,CAAC,CAAA","sourcesContent":["import { ActivityInstallations, registerWorkDoors } from '@things-factory/worklist'\n\nimport { LEGAL_TODO_ACTIVITIES } from './legal-todo-activity'\nimport { REGULATION_ACTIVITIES } from './regulation-activity'\nimport { SEAL_USE_ACTIVITIES } from './seal-use-activity'\n\nexport * from './seal-use-activity-names'\nexport { SEAL_USE_ACTIVITIES } from './seal-use-activity'\nexport * from './legal-todo-activity-names'\nexport { LEGAL_TODO_ACTIVITIES } from './legal-todo-activity'\nexport * from './regulation-activity-names'\nexport { REGULATION_ACTIVITIES } from './regulation-activity'\n\n/*\n * **Importing this file registers the approval template** - a bootstrap hook would be too late for worklist to find the\n * callback. Which domains have it is the application's call: it installs `SEAL_USE_ACTIVITIES`.\n */\nLEGAL_TODO_ACTIVITIES.forEach(template => ActivityInstallations.installActivityTemplate(template as any))\nSEAL_USE_ACTIVITIES.forEach(template => ActivityInstallations.installActivityTemplate(template as any))\nREGULATION_ACTIVITIES.forEach(template => ActivityInstallations.installActivityTemplate(template as any))\n\n/*\n * One registration for the module - worklist keeps one per module, so a second call would replace the first.\n * Using the corporate seal is what the approval decides, so with no approver named it is refused (ADR-0077, ADR-0188).\n * Adopting a version where nobody approves adopts it, and the worklist writes down it ran without a line (ADR-0187 decision 5).\n */\nregisterWorkDoors({\n module: 'compliance',\n doors: [\n ...SEAL_USE_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval' as const, whenNoLine: 'refuse' as const, because: 'approval-is-the-act' as const })),\n ...REGULATION_ACTIVITIES.map(one => ({ name: one.name, kind: 'approval' as const, whenNoLine: 'run' as const }))\n ]\n})\n"]}
@@ -1,2 +1,3 @@
1
1
  export * from './service';
2
2
  export * from './activities';
3
+ import './work-doors';
@@ -18,4 +18,5 @@ for (const task of role_tasks_1.ROLE_TASKS)
18
18
  (0, training_register_1.registerTrainings)();
19
19
  (0, compliance_case_1.registerComplianceCaseFiles)();
20
20
  (0, attachment_readers_1.registerLegalRecordFiles)();
21
+ require("./work-doors");
21
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B;AAE5B,+DAA0E;AAC1E,yDAA4D;AAE5D,6CAAyC;AACzC,4EAAwE;AACxE,+DAAuE;AACvE,kFAAoF;AACpF,0EAAgF;AAChF,gFAAoF;AAEpF,KAAK,MAAM,IAAI,IAAI,uBAAU;IAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAA;AAErD,IAAA,2CAAyB,GAAE,CAAA;AAC3B,IAAA,0CAA2B,EAAC,EAAE,IAAI,EAAE,+CAA0B,EAAE,WAAW,EAAE,0HAA0H,EAAE,CAAC,CAAA;AAC1M,IAAA,qCAAiB,GAAE,CAAA;AACnB,IAAA,6CAA2B,GAAE,CAAA;AAC7B,IAAA,6CAAwB,GAAE,CAAA","sourcesContent":["export * from './service'\nexport * from './activities'\n\nimport { registerAnnouncementTrigger } from '@things-factory/announcement'\nimport { registerRoleTask } from '@things-factory/auth-base'\n\nimport { ROLE_TASKS } from './role-tasks'\nimport { registerTrainings } from './service/training/training-register'\nimport { registerComplianceCaseFiles } from './service/compliance-case'\nimport { registerLegalRecordFiles } from './service/legal-record/attachment-readers'\nimport { registerRegulationReaders } from './service/regulation/regulation-read'\nimport { REGULATION_ADOPTED_TRIGGER } from './service/regulation/regulation-service'\n\nfor (const task of ROLE_TASKS) registerRoleTask(task)\n\nregisterRegulationReaders()\nregisterAnnouncementTrigger({ name: REGULATION_ADOPTED_TRIGGER, description: 'a version of a company rule adopted - its employees are told and asked to acknowledge they read it (ADR-0187 decision 6)' })\nregisterTrainings()\nregisterComplianceCaseFiles()\nregisterLegalRecordFiles()\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,uDAA4B;AAE5B,+DAA0E;AAC1E,yDAA4D;AAE5D,6CAAyC;AACzC,4EAAwE;AACxE,+DAAuE;AACvE,kFAAoF;AACpF,0EAAgF;AAChF,gFAAoF;AAEpF,KAAK,MAAM,IAAI,IAAI,uBAAU;IAAE,IAAA,4BAAgB,EAAC,IAAI,CAAC,CAAA;AAErD,IAAA,2CAAyB,GAAE,CAAA;AAC3B,IAAA,0CAA2B,EAAC,EAAE,IAAI,EAAE,+CAA0B,EAAE,WAAW,EAAE,0HAA0H,EAAE,CAAC,CAAA;AAC1M,IAAA,qCAAiB,GAAE,CAAA;AACnB,IAAA,6CAA2B,GAAE,CAAA;AAC7B,IAAA,6CAAwB,GAAE,CAAA;AAC1B,wBAAqB","sourcesContent":["export * from './service'\nexport * from './activities'\n\nimport { registerAnnouncementTrigger } from '@things-factory/announcement'\nimport { registerRoleTask } from '@things-factory/auth-base'\n\nimport { ROLE_TASKS } from './role-tasks'\nimport { registerTrainings } from './service/training/training-register'\nimport { registerComplianceCaseFiles } from './service/compliance-case'\nimport { registerLegalRecordFiles } from './service/legal-record/attachment-readers'\nimport { registerRegulationReaders } from './service/regulation/regulation-read'\nimport { REGULATION_ADOPTED_TRIGGER } from './service/regulation/regulation-service'\n\nfor (const task of ROLE_TASKS) registerRoleTask(task)\n\nregisterRegulationReaders()\nregisterAnnouncementTrigger({ name: REGULATION_ADOPTED_TRIGGER, description: 'a version of a company rule adopted - its employees are told and asked to acknowledge they read it (ADR-0187 decision 6)' })\nregisterTrainings()\nregisterComplianceCaseFiles()\nregisterLegalRecordFiles()\nimport './work-doors'\n"]}
@@ -5,7 +5,7 @@ export * from './seal-use/seal-use-service';
5
5
  export * from './regulation/regulation';
6
6
  export * from './regulation/regulation-rules';
7
7
  export * from './regulation/regulation-type';
8
- export { REGULATION_ADOPTED_TRIGGER, REGULATION_HELP_SOURCE, REGULATION_PROCEDURE_REF_TYPE, regulationsWithoutFiling } from './regulation/regulation-service';
8
+ export { REGULATION_ADOPTED_TRIGGER, REGULATION_HELP_SOURCE, REGULATION_ORIGINAL_REF_TYPE, REGULATION_PROCEDURE_REF_TYPE, regulationsWithoutFiling } from './regulation/regulation-service';
9
9
  export * from './training/training';
10
10
  export * from './training/training-kinds';
11
11
  export * from './training/training-rules';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.subscribers = exports.schema = exports.entities = exports.registerLegalRecordFiles = exports.DISPUTE_REF_TYPE = exports.disputeHearingsSoon = exports.saveDisputeHearings = exports.saveDisputes = exports.INVENTION_REF_TYPE = exports.inventionDecisionsDue = exports.saveInventionRewards = exports.updateInventions = exports.visibleInvention = exports.reportInvention = exports.LEGAL_REGISTRATION_REF_TYPE = exports.legalCentreChangesNotFiled = exports.legalRegistrationFeesDue = exports.legalRegistrationsInRenewalWindow = exports.legalRegistrationsExpiring = exports.noteCentreEmployeeChange = exports.fileCentreChanges = exports.saveLegalResearchers = exports.saveLegalRegistrations = exports.registerComplianceCaseFiles = exports.registerTrainings = exports.TRAINING_READ_TARGETS = exports.TRAINING_STANDINGS_READ = exports.regulationsWithoutFiling = exports.REGULATION_PROCEDURE_REF_TYPE = exports.REGULATION_HELP_SOURCE = exports.REGULATION_ADOPTED_TRIGGER = void 0;
3
+ exports.subscribers = exports.schema = exports.entities = exports.registerLegalRecordFiles = exports.DISPUTE_REF_TYPE = exports.disputeHearingsSoon = exports.saveDisputeHearings = exports.saveDisputes = exports.INVENTION_REF_TYPE = exports.inventionDecisionsDue = exports.saveInventionRewards = exports.updateInventions = exports.visibleInvention = exports.reportInvention = exports.LEGAL_REGISTRATION_REF_TYPE = exports.legalCentreChangesNotFiled = exports.legalRegistrationFeesDue = exports.legalRegistrationsInRenewalWindow = exports.legalRegistrationsExpiring = exports.noteCentreEmployeeChange = exports.fileCentreChanges = exports.saveLegalResearchers = exports.saveLegalRegistrations = exports.registerComplianceCaseFiles = exports.registerTrainings = exports.TRAINING_READ_TARGETS = exports.TRAINING_STANDINGS_READ = exports.regulationsWithoutFiling = exports.REGULATION_PROCEDURE_REF_TYPE = exports.REGULATION_ORIGINAL_REF_TYPE = exports.REGULATION_HELP_SOURCE = exports.REGULATION_ADOPTED_TRIGGER = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /* EXPORT ENTITY TYPES */
6
6
  tslib_1.__exportStar(require("./seal-use/seal-use"), exports);
@@ -13,6 +13,7 @@ tslib_1.__exportStar(require("./regulation/regulation-type"), exports);
13
13
  var regulation_service_1 = require("./regulation/regulation-service");
14
14
  Object.defineProperty(exports, "REGULATION_ADOPTED_TRIGGER", { enumerable: true, get: function () { return regulation_service_1.REGULATION_ADOPTED_TRIGGER; } });
15
15
  Object.defineProperty(exports, "REGULATION_HELP_SOURCE", { enumerable: true, get: function () { return regulation_service_1.REGULATION_HELP_SOURCE; } });
16
+ Object.defineProperty(exports, "REGULATION_ORIGINAL_REF_TYPE", { enumerable: true, get: function () { return regulation_service_1.REGULATION_ORIGINAL_REF_TYPE; } });
16
17
  Object.defineProperty(exports, "REGULATION_PROCEDURE_REF_TYPE", { enumerable: true, get: function () { return regulation_service_1.REGULATION_PROCEDURE_REF_TYPE; } });
17
18
  Object.defineProperty(exports, "regulationsWithoutFiling", { enumerable: true, get: function () { return regulation_service_1.regulationsWithoutFiling; } });
18
19
  tslib_1.__exportStar(require("./training/training"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,8DAAmC;AACnC,oEAAyC;AACzC,mEAAwC;AACxC,sEAA2C;AAC3C,kEAAuC;AACvC,wEAA6C;AAC7C,uEAA4C;AAC5C,sEAA6J;AAApJ,gIAAA,0BAA0B,OAAA;AAAE,4HAAA,sBAAsB,OAAA;AAAE,mIAAA,6BAA6B,OAAA;AAAE,8HAAA,wBAAwB,OAAA;AACpH,8DAAmC;AACnC,oEAAyC;AACzC,oEAAyC;AACzC,mEAAwC;AACxC,sEAA2C;AAC3C,qEAA0C;AAC1C,0DAAyF;AAAhF,wHAAA,uBAAuB,OAAA;AAAE,sHAAA,qBAAqB,OAAA;AACvD,kEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AAC1B,8DAAmC;AACnC,4EAAiD;AACjD,kFAAuD;AACvD,iFAAsD;AACtD,oFAAyD;AACzD,qDAA+D;AAAtD,8HAAA,2BAA2B,OAAA;AACpC,0EAA+C;AAC/C,gFAAqD;AACrD,+EAAoD;AACpD,kFAAuD;AACvD,kFAAuD;AACvD,wFAA6D;AAC7D,uFAA4D;AAC5D,8FAA6S;AAApS,oIAAA,sBAAsB,OAAA;AAAE,kIAAA,oBAAoB,OAAA;AAAE,+HAAA,iBAAiB,OAAA;AAAE,sIAAA,wBAAwB,OAAA;AAAE,wIAAA,0BAA0B,OAAA;AAAE,+IAAA,iCAAiC,OAAA;AAAE,sIAAA,wBAAwB,OAAA;AAAE,wIAAA,0BAA0B,OAAA;AAAE,yIAAA,2BAA2B,OAAA;AACpP,gEAAqC;AACrC,sEAA2C;AAC3C,qEAA0C;AAC1C,mEAAoK;AAA3J,oHAAA,eAAe,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAAE,yHAAA,oBAAoB,OAAA;AAAE,0HAAA,qBAAqB,OAAA;AAAE,uHAAA,kBAAkB,OAAA;AAC7H,4DAAiC;AACjC,kEAAuC;AACvC,iEAAsC;AACtC,6DAAoH;AAA3G,+GAAA,YAAY,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAAE,sHAAA,mBAAmB,OAAA;AAAE,mHAAA,gBAAgB,OAAA;AACjF,wEAA4E;AAAnE,8HAAA,wBAAwB,OAAA;AACjC,mEAAwC;AACxC,8DAAmC;AAEnC,mCAAmC;AACnC,yCAAuF;AACvF,6CAA+F;AAC/F,yCAAyF;AACzF,oDAAoE;AACpE,uDAA4G;AAC5G,qDAAyG;AACzG,6DAAkK;AAClK,2CAA4F;AAC5F,uCAAsF;AAEzE,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,mBAAe;IAClB,GAAG,qBAAkB;IACrB,GAAG,mBAAgB;IACnB,GAAG,qBAAkB;IACrB,GAAG,0BAAsB;IACzB,GAAG,yBAAqB;IACxB,GAAG,6BAAyB;IAC5B,GAAG,oBAAiB;IACpB,GAAG,kBAAe;CACnB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,oBAAgB;QACnB,GAAG,sBAAmB;QACtB,GAAG,oBAAiB;QACpB,GAAG,2BAAuB;QAC1B,GAAG,0BAAsB;QACzB,GAAG,8BAA0B;QAC7B,GAAG,qBAAkB;QACrB,GAAG,mBAAgB;KACpB;CACF,CAAA;AAED,iHAAiH;AACpG,QAAA,WAAW,GAAG,CAAC,GAAG,gCAA4B,CAAC,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './seal-use/seal-use'\nexport * from './seal-use/seal-use-rules'\nexport * from './seal-use/seal-use-type'\nexport * from './seal-use/seal-use-service'\nexport * from './regulation/regulation'\nexport * from './regulation/regulation-rules'\nexport * from './regulation/regulation-type'\nexport { REGULATION_ADOPTED_TRIGGER, REGULATION_HELP_SOURCE, REGULATION_PROCEDURE_REF_TYPE, regulationsWithoutFiling } from './regulation/regulation-service'\nexport * from './training/training'\nexport * from './training/training-kinds'\nexport * from './training/training-rules'\nexport * from './training/training-type'\nexport * from './training/training-service'\nexport * from './training/training-checks'\nexport { TRAINING_STANDINGS_READ, TRAINING_READ_TARGETS } from './training/training-read'\nexport { registerTrainings } from './training/training-register'\nexport * from './common/correction'\nexport * from './compliance-case/compliance-case'\nexport * from './compliance-case/compliance-case-rules'\nexport * from './compliance-case/compliance-case-type'\nexport * from './compliance-case/compliance-case-service'\nexport { registerComplianceCaseFiles } from './compliance-case'\nexport * from './privacy-record/privacy-record'\nexport * from './privacy-record/privacy-record-rules'\nexport * from './privacy-record/privacy-record-type'\nexport * from './privacy-record/privacy-record-service'\nexport * from './legal-registration/legal-registration'\nexport * from './legal-registration/legal-registration-rules'\nexport * from './legal-registration/legal-registration-type'\nexport { saveLegalRegistrations, saveLegalResearchers, fileCentreChanges, noteCentreEmployeeChange, legalRegistrationsExpiring, legalRegistrationsInRenewalWindow, legalRegistrationFeesDue, legalCentreChangesNotFiled, LEGAL_REGISTRATION_REF_TYPE } from './legal-registration/legal-registration-service'\nexport * from './invention/invention'\nexport * from './invention/invention-rules'\nexport * from './invention/invention-type'\nexport { reportInvention, visibleInvention, updateInventions, saveInventionRewards, inventionDecisionsDue, INVENTION_REF_TYPE } from './invention/invention-service'\nexport * from './dispute/dispute'\nexport * from './dispute/dispute-rules'\nexport * from './dispute/dispute-type'\nexport { saveDisputes, saveDisputeHearings, disputeHearingsSoon, DISPUTE_REF_TYPE } from './dispute/dispute-service'\nexport { registerLegalRecordFiles } from './legal-record/attachment-readers'\nexport * from './common/employee-reader'\nexport * from './common/legal-todo'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as SealUseEntities, resolvers as SealUseResolvers } from './seal-use'\nimport { entities as RegulationEntities, resolvers as RegulationResolvers } from './regulation'\nimport { entities as TrainingEntities, resolvers as TrainingResolvers } from './training'\nimport { entities as CorrectionEntities } from './common/correction'\nimport { entities as ComplianceCaseEntities, resolvers as ComplianceCaseResolvers } from './compliance-case'\nimport { entities as PrivacyRecordEntities, resolvers as PrivacyRecordResolvers } from './privacy-record'\nimport { entities as LegalRegistrationEntities, resolvers as LegalRegistrationResolvers, subscribers as LegalRegistrationSubscribers } from './legal-registration'\nimport { entities as InventionEntities, resolvers as InventionResolvers } from './invention'\nimport { entities as DisputeEntities, resolvers as DisputeResolvers } from './dispute'\n\nexport const entities = [\n /* ENTITIES */\n ...SealUseEntities,\n ...RegulationEntities,\n ...TrainingEntities,\n ...CorrectionEntities,\n ...ComplianceCaseEntities,\n ...PrivacyRecordEntities,\n ...LegalRegistrationEntities,\n ...InventionEntities,\n ...DisputeEntities\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...SealUseResolvers,\n ...RegulationResolvers,\n ...TrainingResolvers,\n ...ComplianceCaseResolvers,\n ...PrivacyRecordResolvers,\n ...LegalRegistrationResolvers,\n ...InventionResolvers,\n ...DisputeResolvers\n ]\n}\n\n/* A research centre's change of staff is caught where organization saves the employee (ADR-0187 decision 23). */\nexport const subscribers = [...LegalRegistrationSubscribers]\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,8DAAmC;AACnC,oEAAyC;AACzC,mEAAwC;AACxC,sEAA2C;AAC3C,kEAAuC;AACvC,wEAA6C;AAC7C,uEAA4C;AAC5C,sEAA2L;AAAlL,gIAAA,0BAA0B,OAAA;AAAE,4HAAA,sBAAsB,OAAA;AAAE,kIAAA,4BAA4B,OAAA;AAAE,mIAAA,6BAA6B,OAAA;AAAE,8HAAA,wBAAwB,OAAA;AAClJ,8DAAmC;AACnC,oEAAyC;AACzC,oE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kK;AAClK,2CAA4F;AAC5F,uCAAsF;AAEzE,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,mBAAe;IAClB,GAAG,qBAAkB;IACrB,GAAG,mBAAgB;IACnB,GAAG,qBAAkB;IACrB,GAAG,0BAAsB;IACzB,GAAG,yBAAqB;IACxB,GAAG,6BAAyB;IAC5B,GAAG,oBAAiB;IACpB,GAAG,kBAAe;CACnB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,oBAAgB;QACnB,GAAG,sBAAmB;QACtB,GAAG,oBAAiB;QACpB,GAAG,2BAAuB;QAC1B,GAAG,0BAAsB;QACzB,GAAG,8BAA0B;QAC7B,GAAG,qBAAkB;QACrB,GAAG,mBAAgB;KACpB;CACF,CAAA;AAED,iHAAiH;AACpG,QAAA,WAAW,GAAG,CAAC,GAAG,gCAA4B,CAAC,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './seal-use/seal-use'\nexport * from './seal-use/seal-use-rules'\nexport * from './seal-use/seal-use-type'\nexport * from './seal-use/seal-use-service'\nexport * from './regulation/regulation'\nexport * from './regulation/regulation-rules'\nexport * from './regulation/regulation-type'\nexport { REGULATION_ADOPTED_TRIGGER, REGULATION_HELP_SOURCE, REGULATION_ORIGINAL_REF_TYPE, REGULATION_PROCEDURE_REF_TYPE, regulationsWithoutFiling } from './regulation/regulation-service'\nexport * from './training/training'\nexport * from './training/training-kinds'\nexport * from './training/training-rules'\nexport * from './training/training-type'\nexport * from './training/training-service'\nexport * from './training/training-checks'\nexport { TRAINING_STANDINGS_READ, TRAINING_READ_TARGETS } from './training/training-read'\nexport { registerTrainings } from './training/training-register'\nexport * from './common/correction'\nexport * from './compliance-case/compliance-case'\nexport * from './compliance-case/compliance-case-rules'\nexport * from './compliance-case/compliance-case-type'\nexport * from './compliance-case/compliance-case-service'\nexport { registerComplianceCaseFiles } from './compliance-case'\nexport * from './privacy-record/privacy-record'\nexport * from './privacy-record/privacy-record-rules'\nexport * from './privacy-record/privacy-record-type'\nexport * from './privacy-record/privacy-record-service'\nexport * from './legal-registration/legal-registration'\nexport * from './legal-registration/legal-registration-rules'\nexport * from './legal-registration/legal-registration-type'\nexport { saveLegalRegistrations, saveLegalResearchers, fileCentreChanges, noteCentreEmployeeChange, legalRegistrationsExpiring, legalRegistrationsInRenewalWindow, legalRegistrationFeesDue, legalCentreChangesNotFiled, LEGAL_REGISTRATION_REF_TYPE } from './legal-registration/legal-registration-service'\nexport * from './invention/invention'\nexport * from './invention/invention-rules'\nexport * from './invention/invention-type'\nexport { reportInvention, visibleInvention, updateInventions, saveInventionRewards, inventionDecisionsDue, INVENTION_REF_TYPE } from './invention/invention-service'\nexport * from './dispute/dispute'\nexport * from './dispute/dispute-rules'\nexport * from './dispute/dispute-type'\nexport { saveDisputes, saveDisputeHearings, disputeHearingsSoon, DISPUTE_REF_TYPE } from './dispute/dispute-service'\nexport { registerLegalRecordFiles } from './legal-record/attachment-readers'\nexport * from './common/employee-reader'\nexport * from './common/legal-todo'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as SealUseEntities, resolvers as SealUseResolvers } from './seal-use'\nimport { entities as RegulationEntities, resolvers as RegulationResolvers } from './regulation'\nimport { entities as TrainingEntities, resolvers as TrainingResolvers } from './training'\nimport { entities as CorrectionEntities } from './common/correction'\nimport { entities as ComplianceCaseEntities, resolvers as ComplianceCaseResolvers } from './compliance-case'\nimport { entities as PrivacyRecordEntities, resolvers as PrivacyRecordResolvers } from './privacy-record'\nimport { entities as LegalRegistrationEntities, resolvers as LegalRegistrationResolvers, subscribers as LegalRegistrationSubscribers } from './legal-registration'\nimport { entities as InventionEntities, resolvers as InventionResolvers } from './invention'\nimport { entities as DisputeEntities, resolvers as DisputeResolvers } from './dispute'\n\nexport const entities = [\n /* ENTITIES */\n ...SealUseEntities,\n ...RegulationEntities,\n ...TrainingEntities,\n ...CorrectionEntities,\n ...ComplianceCaseEntities,\n ...PrivacyRecordEntities,\n ...LegalRegistrationEntities,\n ...InventionEntities,\n ...DisputeEntities\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...SealUseResolvers,\n ...RegulationResolvers,\n ...TrainingResolvers,\n ...ComplianceCaseResolvers,\n ...PrivacyRecordResolvers,\n ...LegalRegistrationResolvers,\n ...InventionResolvers,\n ...DisputeResolvers\n ]\n}\n\n/* A research centre's change of staff is caught where organization saves the employee (ADR-0187 decision 23). */\nexport const subscribers = [...LegalRegistrationSubscribers]\n"]}
@@ -11,5 +11,6 @@ export declare class RegulationMutation {
11
11
  recordRegulationProcedure(procedure: NewRegulationProcedure, files: FileUpload[], context: ResolverContext): Promise<RegulationProcedure>;
12
12
  deleteRegulationProcedure(id: string, context: ResolverContext): Promise<boolean>;
13
13
  submitRegulationVersion(id: string, context: ResolverContext): Promise<RegulationVersion>;
14
+ registerRegulationInForce(id: string, files: FileUpload[], context: ResolverContext): Promise<RegulationVersion>;
14
15
  withdrawRegulationVersion(id: string, context: ResolverContext): Promise<RegulationVersion>;
15
16
  }
@@ -37,6 +37,9 @@ let RegulationMutation = class RegulationMutation {
37
37
  async submitRegulationVersion(id, context) {
38
38
  return await (0, regulation_service_1.submitRegulationVersion)(id, context);
39
39
  }
40
+ async registerRegulationInForce(id, files, context) {
41
+ return await (0, regulation_service_1.registerRegulationInForce)(id, files, context);
42
+ }
40
43
  async withdrawRegulationVersion(id, context) {
41
44
  return await (0, regulation_service_1.withdrawRegulationVersion)(id, context);
42
45
  }
@@ -135,6 +138,17 @@ tslib_1.__decorate([
135
138
  tslib_1.__metadata("design:paramtypes", [String, Object]),
136
139
  tslib_1.__metadata("design:returntype", Promise)
137
140
  ], RegulationMutation.prototype, "submitRegulationVersion", null);
141
+ tslib_1.__decorate([
142
+ (0, type_graphql_1.Directive)(KEEP),
143
+ (0, type_graphql_1.Directive)('@transaction'),
144
+ (0, type_graphql_1.Mutation)(returns => regulation_1.RegulationVersion, { description: 'To register the first version of a rule as in force already, from its own day, with its original attached - no approval, no announcement (ADR-0187 amendment 2)' }),
145
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
146
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('files', type => [GraphQLUpload_js_1.default], { description: 'The original of the rule' })),
147
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
148
+ tslib_1.__metadata("design:type", Function),
149
+ tslib_1.__metadata("design:paramtypes", [String, Array, Object]),
150
+ tslib_1.__metadata("design:returntype", Promise)
151
+ ], RegulationMutation.prototype, "registerRegulationInForce", null);
138
152
  tslib_1.__decorate([
139
153
  (0, type_graphql_1.Directive)(KEEP),
140
154
  (0, type_graphql_1.Directive)('@transaction'),
@@ -1 +1 @@
1
- {"version":3,"file":"regulation-mutation.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-mutation.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAqF;AAErF,iDAAqD;AAErD,6CAAiF;AACjF,6DAW6B;AAC7B,uDAAkH;AAElH,MAAM,IAAI,GAAG,qFAAqF,CAAA;AAI3F,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAIvB,AAAN,KAAK,CAAC,gBAAgB,CAA2C,UAAyB,EAAS,OAAwB;QACzH,OAAO,MAAM,IAAA,qCAAgB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;IAKK,AAAN,KAAK,CAAC,gBAAgB,CAAY,EAAU,EAAyC,KAAsB,EAAS,OAAwB;QAC1I,OAAO,MAAM,IAAA,qCAAgB,EAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IACnD,CAAC;IAKK,AAAN,KAAK,CAAC,iBAAiB,CAA+B,GAAa,EAAS,OAAwB;QAClG,OAAO,MAAM,IAAA,sCAAiB,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAKK,AAAN,KAAK,CAAC,oBAAoB,CAAsB,YAAoB,EAAS,OAAwB;QACnG,OA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CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEAE5D;AAKK;IAHL,IAAA,wBAAS,EAAC,IAAI,CAAC;IACf,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAiB,EAAE,EAAE,WAAW,EAAE,2HAA2H,EAAE,CAAC;IACtJ,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAE1D;AAKK;IAHL,IAAA,wBAAS,EAAC,IAAI,CAAC;IACf,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAiB,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;IACxE,mBAAA,IAAA,kBAAG,EAAC,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"]}
1
+ {"version":3,"file":"regulation-mutation.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-mutation.ts"],"names":[],"mappings":";;;;AACA,+FAA2D;AAC3D,+CAAqF;AAErF,iDAAqD;AAErD,6CAAiF;AACjF,6DAY6B;AAC7B,uDAAkH;AAElH,MAAM,IAAI,GAAG,qFAAqF,CAAA;AAI3F,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAIvB,AAAN,KAAK,CAAC,gBAAgB,CAA2C,UAAyB,EAAS,OAAwB;QACzH,OAAO,MAAM,IAAA,qCAAgB,EAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;IAKK,AAAN,KAAK,CAAC,gBAAgB,CAAY,EAAU,EAAyC,KAAsB,EAAS,OAAwB;QAC1I,OAAO,MAAM,I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A,wBAAS,EAAC,IAAI,CAAC;IACf,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAiB,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE,CAAC;IACxE,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mEAE5D;6BApFU,kBAAkB;IAF9B,IAAA,uBAAQ,EAAC,uBAAU,CAAC;IACpB,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,kBAAkB,CAqF9B","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 registerRegulationInForce,\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 register the first version of a rule as in force already, from its own day, with its original attached - no approval, no announcement (ADR-0187 amendment 2)' })\n async registerRegulationInForce(\n @Arg('id') id: string,\n @Arg('files', type => [GraphQLUpload], { description: 'The original of the rule' }) files: FileUpload[],\n @Ctx() context: ResolverContext\n ): Promise<RegulationVersion> {\n return await registerRegulationInForce(id, files, 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"]}
@@ -37,9 +37,10 @@ async function viewOfVersion(tx, context, version, siblings, keeper) {
37
37
  const standing = (0, regulation_rules_1.standingOf)(siblings, today);
38
38
  const adopted = siblings.filter(one => one.status === regulation_1.RegulationVersionStatus.ADOPTED && one.effectiveOn).sort((a, b) => (a.effectiveOn < b.effectiveOn ? -1 : 1));
39
39
  const next = adopted.find(one => one.effectiveOn > (version.effectiveOn ?? '') && one.id !== version.id);
40
+ const parts = (0, regulation_rules_1.partsOf)(version.body);
40
41
  const clauses = version.status === regulation_1.RegulationVersionStatus.ADOPTED
41
42
  ? 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
+ : parts.clauses.map((one, rank) => ({ id: `${version.id}:${rank}`, rank, versionId: version.id, ...one }));
43
44
  const before = await (0, regulation_service_1.previousAdopted)((0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).manager, version);
44
45
  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
46
  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;
@@ -49,7 +50,10 @@ async function viewOfVersion(tx, context, version, siblings, keeper) {
49
50
  period: (0, regulation_rules_1.periodOfVersion)(version, standing, today),
50
51
  endsOn: version.status === regulation_1.RegulationVersionStatus.ADOPTED ? next?.effectiveOn : undefined,
51
52
  clauses,
53
+ appendix: parts.appendix ?? undefined,
54
+ text: parts.clauses.length ? undefined : version.body?.trim() || undefined,
52
55
  changes,
56
+ originals: keeper && version.registeredInForce ? ((await (0, regulation_service_1.originalsOf)((0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).manager, domain, [version.id])).get(version.id) ?? 0) : undefined,
53
57
  procedures: keeper ? (await (0, regulation_service_1.proceduresOf)((0, shell_1.getRepository)(regulation_1.RegulationVersion, tx).manager, domain, [version.id])) : undefined,
54
58
  announcement: keeper ? announcement : undefined,
55
59
  told: announcement?.status === 'PUBLISHED',
@@ -89,7 +93,7 @@ async function regulationParts(domain) {
89
93
  topic: `${regulation_service_1.REGULATION_HELP_SOURCE}/${regulation.code}`,
90
94
  section: clause.number,
91
95
  lang: '',
92
- title: `${regulation.name} 제${clause.number}조${clause.title ? `(${clause.title})` : ''}`,
96
+ title: `${regulation.name} ${clause.heading}`,
93
97
  documentTitle: regulation.name,
94
98
  summary: `제${version.version}판 · ${when}.`,
95
99
  text: `제${version.version}판 · ${when}. ${clause.text}`,
@@ -107,5 +111,10 @@ function registerRegulationReaders() {
107
111
  return false;
108
112
  return !!(await (0, shell_1.getRepository)(regulation_1.RegulationProcedure).findOne({ where: { id: attachment.refBy, domain: { id: context.state.domain.id } } }));
109
113
  });
114
+ (0, attachment_base_1.registerAttachmentReader)(regulation_service_1.REGULATION_ORIGINAL_REF_TYPE, async (attachment, context) => {
115
+ if (!attachment.refBy || !(await (0, exports.keepsRules)(context)))
116
+ return false;
117
+ return !!(await (0, shell_1.getRepository)(regulation_1.RegulationVersion).findOne({ where: { id: attachment.refBy, domain: { id: context.state.domain.id } } }));
118
+ });
110
119
  }
111
120
  //# sourceMappingURL=regulation-read.js.map
@@ -1 +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,uBAAK,EAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,CAAA;AAApE,QAAA,UAAU,cAA0D;AAEjF,+FAA+F;AACxF,KAAK,UAAU,UAAU,CAAC,OAAY;IAC3C,OAAO,CAAC,CAAC,CAAC,MAAM,IAAA,mCAAiB,EAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC,CAAA;AAC5E,CAAC;AAED,oEAAoE;AAC7D,KAAK,UAAU,aAAa,CAAC,EAA6B,EAAE,OAAY,EAAE,OAA0B,EAAE,QAA6B,EAAE,MAAe;IACzJ,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IACtC,IAAI,OAAO,CAAC,MA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UAAU,CAAC,IAAI;oBAC9B,OAAO,EAAE,IAAI,OAAO,CAAC,OAAO,OAAO,IAAI,GAAG;oBAC1C,IAAI,EAAE,IAAI,OAAO,CAAC,OAAO,OAAO,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE;oBACtD,IAAI,EAAE,0BAA0B,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;iBAClH,CAAC,CAAA;QACN,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,mGAAmG;AACnG,SAAgB,yBAAyB;IACvC,IAAA,yBAAkB,EAAC,EAAE,IAAI,EAAE,2CAAsB,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,MAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAA;IAC5H,IAAA,0CAAwB,EAAC,kDAA6B,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QACpF,IAAI,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,IAAA,kBAAU,EAAC,OAAO,CAAC,CAAC;YAAE,OAAO,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"]}
1
+ {"version":3,"file":"regulation-read.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-read.ts"],"names":[],"mappings":";;;AAuBA,gCAEC;AAGD,sCA8BC;AAGD,4CAMC;AAGD,8CAIC;AAGD,0CAyBC;AAGD,8DAUC;AAnHD,qCAA2C;AAE3C,+DAAyD;AACzD,qEAA0E;AAC1E,+CAAwE;AACxE,iDAA8D;AAE9D,+DAA6E;AAC7E,6CAA4H;AAC5H,yDAAmG;AACnG,6DAA+L;AAG/L;;;;GAIG;AAEH,2CAA2C;AACpC,MAAM,UAAU,GAAG,CAAC,OAAY,EAAE,EAAE,CAAC,IAAA,uBAAK,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AAC","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, partsOf, periodOfVersion, standingOf } from './regulation-rules'\nimport { announcementsOfVersions, originalsOf, previousAdopted, proceduresOf, REGULATION_HELP_SOURCE, REGULATION_ORIGINAL_REF_TYPE, 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 parts = partsOf(version.body)\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 : (parts.clauses.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 appendix: parts.appendix ?? undefined,\n text: parts.clauses.length ? undefined : version.body?.trim() || undefined,\n changes,\n originals: keeper && version.registeredInForce ? ((await originalsOf(getRepository(RegulationVersion, tx).manager, domain, [version.id])).get(version.id) ?? 0) : undefined,\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.heading}`,\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 registerAttachmentReader(REGULATION_ORIGINAL_REF_TYPE, async (attachment, context) => {\n if (!attachment.refBy || !(await keepsRules(context))) return false\n return !!(await getRepository(RegulationVersion).findOne({ where: { id: attachment.refBy, domain: { id: (context as any).state.domain.id } } as any }))\n })\n}\n"]}
@@ -11,16 +11,25 @@ export interface Clause {
11
11
  number: string;
12
12
  title: string | null;
13
13
  chapter: string | null;
14
+ heading: string;
14
15
  text: string;
15
16
  }
16
17
  /**
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.
18
+ * The parts of a text (ADR-0187 decision 2): its articles, each from its `제n조(제목)` head up to the next article or
19
+ * head, and the appendix - from the first line headed in brackets (`[별표 1]`) to the end. The words before the first
20
+ * article are no article. A chapter (`제2장 근로시간`) and a section (`제1절 근로시간`) are kept as the chapter of the
21
+ * articles after them. The articles after 「부칙」 are numbered `부칙1`, `부칙2` - apart from the body's.
19
22
  */
20
- export declare function clausesOf(body: string | null | undefined): Clause[];
23
+ export declare function partsOf(body: string | null | undefined): {
24
+ clauses: Clause[];
25
+ appendix: string | null;
26
+ };
27
+ /** The articles of a text. */
28
+ export declare const clausesOf: (body: string | null | undefined) => Clause[];
21
29
  export interface ClauseChange {
22
30
  number: string;
23
31
  title: string | null;
32
+ heading: string;
24
33
  change: 'ADDED' | 'CHANGED' | 'REMOVED';
25
34
  }
26
35
  /** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */
@@ -50,6 +59,16 @@ export declare function regulationRefusal(input: {
50
59
  * them, the consent of more than half with its papers.
51
60
  */
52
61
  export declare function adoptionRefusal(version: VersionFacts, procedures: ProcedureFacts[], today: string): Refusal | null;
62
+ /**
63
+ * What a version asks before it is registered as in force already (ADR-0187 decision 3, amendment 2): the first version
64
+ * of its rule to be adopted, still being written, with a text, a day come by today and the original attached. No article
65
+ * is asked - a table of amounts has none; no procedure is asked - it was taken before the system.
66
+ */
67
+ export declare function inForceRefusal(version: {
68
+ status: string;
69
+ body?: string | null;
70
+ effectiveOn?: string | null;
71
+ }, adoptedBefore: number, originals: number, today: string): Refusal | null;
53
72
  /** What a procedure record asks before it is written. */
54
73
  export declare function procedureRefusal(input: {
55
74
  kind?: string | null;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROCEDURE_METHODS = exports.REGULATION_KINDS = void 0;
4
- exports.clausesOf = clausesOf;
3
+ exports.clausesOf = exports.PROCEDURE_METHODS = exports.REGULATION_KINDS = void 0;
4
+ exports.partsOf = partsOf;
5
5
  exports.clauseChanges = clauseChanges;
6
6
  exports.regulationRefusal = regulationRefusal;
7
7
  exports.adoptionRefusal = adoptionRefusal;
8
+ exports.inForceRefusal = inForceRefusal;
8
9
  exports.procedureRefusal = procedureRefusal;
9
10
  exports.standingOf = standingOf;
10
11
  exports.periodOfVersion = periodOfVersion;
@@ -32,38 +33,73 @@ const DAY = /^\d{4}-\d{2}-\d{2}$/;
32
33
  const CODE = /^[A-Za-z0-9_-]{1,40}$/;
33
34
  const ARTICLE = /^\s*(?:#{1,6}\s*)?(?:\*\*)?제\s*(\d+(?:의\s*\d+)?)\s*조\s*(?:[((]([^))]*)[))])?(?:\*\*)?\s*(.*)$/;
34
35
  const CHAPTER = /^\s*(?:#{1,6}\s*)?(?:\*\*)?(제\s*\d+\s*장.*?)(?:\*\*)?\s*$/;
36
+ const SECTION = /^\s*(?:#{1,6}\s*)?(?:\*\*)?<?\s*(제\s*\d+\s*절[^>]*?)\s*>?(?:\*\*)?\s*$/;
37
+ const ADDENDA = /^\s*(?:#{1,6}\s*)?(?:\*\*)?부\s*칙(?:\*\*)?\s*(?:<[^>]*>)?\s*$/;
38
+ const APPENDIX = /^\s*(?:#{1,6}\s*)?\[[^\]]+\]/;
39
+ /** How an article is named on the page - 「제3조(휴게)」, in the addenda 「부칙 제1조(시행일)」. */
40
+ const headingOf = (number, title) => {
41
+ const addenda = number.startsWith('부칙');
42
+ return `${addenda ? '부칙 ' : ''}제${addenda ? number.slice(2) : number}조${title ? `(${title})` : ''}`;
43
+ };
35
44
  /**
36
- * The articles of a text, each from its `제n조(제목)` head up to the next article or chapter. The words before the first
37
- * article are no article. A chapter head (`제2장 근로시간`) is kept as the chapter of the articles after it.
45
+ * The parts of a text (ADR-0187 decision 2): its articles, each from its `제n조(제목)` head up to the next article or
46
+ * head, and the appendix - from the first line headed in brackets (`[별표 1]`) to the end. The words before the first
47
+ * article are no article. A chapter (`제2장 근로시간`) and a section (`제1절 근로시간`) are kept as the chapter of the
48
+ * articles after them. The articles after 「부칙」 are numbered `부칙1`, `부칙2` - apart from the body's.
38
49
  */
39
- function clausesOf(body) {
50
+ function partsOf(body) {
40
51
  const clauses = [];
41
52
  let chapter = null;
53
+ let section = null;
54
+ let addenda = false;
42
55
  let current = null;
43
56
  const close = () => {
44
57
  if (!current)
45
58
  return;
46
- clauses.push({ number: current.number, title: current.title, chapter: current.chapter, text: current.lines.join('\n').trim() });
59
+ clauses.push({ number: current.number, title: current.title, chapter: current.chapter, heading: headingOf(current.number, current.title), text: current.lines.join('\n').trim() });
47
60
  current = null;
48
61
  };
49
- for (const line of (body ?? '').split(/\r?\n/)) {
62
+ const lines = (body ?? '').split(/\r?\n/);
63
+ for (const [index, line] of lines.entries()) {
64
+ if (APPENDIX.test(line)) {
65
+ close();
66
+ return { clauses, appendix: lines.slice(index).join('\n').trim() || null };
67
+ }
50
68
  const article = ARTICLE.exec(line);
51
69
  if (article) {
52
70
  close();
53
- current = { number: article[1].replace(/\s+/g, ''), title: article[2]?.trim() || null, chapter, text: '', lines: article[3] ? [article[3]] : [] };
71
+ const number = article[1].replace(/\s+/g, '');
72
+ current = { number: addenda ? `부칙${number}` : number, title: article[2]?.trim() || null, chapter: [chapter, section].filter(Boolean).join(' · ') || null, lines: article[3] ? [article[3]] : [] };
54
73
  continue;
55
74
  }
56
75
  const head = CHAPTER.exec(line);
57
76
  if (head) {
58
77
  close();
59
78
  chapter = head[1].replace(/\s+/g, ' ').trim();
79
+ section = null;
80
+ continue;
81
+ }
82
+ const part = SECTION.exec(line);
83
+ if (part) {
84
+ close();
85
+ section = part[1].replace(/\s+/g, ' ').trim();
86
+ continue;
87
+ }
88
+ if (ADDENDA.test(line)) {
89
+ close();
90
+ addenda = true;
91
+ chapter = '부칙';
92
+ section = null;
60
93
  continue;
61
94
  }
62
95
  current?.lines.push(line);
63
96
  }
64
97
  close();
65
- return clauses;
98
+ return { clauses, appendix: null };
66
99
  }
100
+ /** The articles of a text. */
101
+ const clausesOf = (body) => partsOf(body).clauses;
102
+ exports.clausesOf = clausesOf;
67
103
  /** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */
68
104
  function clauseChanges(before, after) {
69
105
  const old = new Map(before.map(one => [one.number, one]));
@@ -72,13 +108,13 @@ function clauseChanges(before, after) {
72
108
  for (const one of after) {
73
109
  const was = old.get(one.number);
74
110
  if (!was)
75
- changes.push({ number: one.number, title: one.title, change: 'ADDED' });
111
+ changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'ADDED' });
76
112
  else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? ''))
77
- changes.push({ number: one.number, title: one.title, change: 'CHANGED' });
113
+ changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'CHANGED' });
78
114
  }
79
115
  for (const one of before)
80
116
  if (!fresh.has(one.number))
81
- changes.push({ number: one.number, title: one.title, change: 'REMOVED' });
117
+ changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'REMOVED' });
82
118
  return changes;
83
119
  }
84
120
  /** What a regulation asks before it is written. */
@@ -97,7 +133,7 @@ function regulationRefusal(input) {
97
133
  * them, the consent of more than half with its papers.
98
134
  */
99
135
  function adoptionRefusal(version, procedures, today) {
100
- if (!clausesOf(version.body).length)
136
+ if (!(0, exports.clausesOf)(version.body).length)
101
137
  return new shell_1.Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)');
102
138
  if (!version.effectiveOn || !DAY.test(version.effectiveOn))
103
139
  return new shell_1.Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD');
@@ -121,6 +157,26 @@ function adoptionRefusal(version, procedures, today) {
121
157
  }
122
158
  return null;
123
159
  }
160
+ /**
161
+ * What a version asks before it is registered as in force already (ADR-0187 decision 3, amendment 2): the first version
162
+ * of its rule to be adopted, still being written, with a text, a day come by today and the original attached. No article
163
+ * is asked - a table of amounts has none; no procedure is asked - it was taken before the system.
164
+ */
165
+ function inForceRefusal(version, adoptedBefore, originals, today) {
166
+ if (version.status !== 'DRAFT')
167
+ return new shell_1.Refusal('regulation-register-not-draft', {}, 'only a version being written is registered');
168
+ if (adoptedBefore)
169
+ return new shell_1.Refusal('regulation-in-force-first-only', {}, 'the rule has a version adopted or in approval - a change of it goes through approval');
170
+ if (!version.body?.trim())
171
+ return new shell_1.Refusal('regulation-body-empty', {}, 'write the text of the rule');
172
+ if (!version.effectiveOn || !DAY.test(version.effectiveOn))
173
+ return new shell_1.Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD');
174
+ if (version.effectiveOn > today)
175
+ return new shell_1.Refusal('regulation-in-force-future', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is after today ${today} - a rule to take effect later is adopted through approval`);
176
+ if (!originals)
177
+ return new shell_1.Refusal('regulation-original-required', {}, 'attach the original of the rule');
178
+ return null;
179
+ }
124
180
  /** What a procedure record asks before it is written. */
125
181
  function procedureRefusal(input) {
126
182
  if (!exports.PROCEDURE_METHODS[input.kind ?? ''])