@things-factory/compliance 10.1.255 → 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 (42) 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-server/index.d.ts +1 -0
  10. package/dist-server/index.js +1 -0
  11. package/dist-server/index.js.map +1 -1
  12. package/dist-server/service/index.d.ts +1 -1
  13. package/dist-server/service/index.js +2 -1
  14. package/dist-server/service/index.js.map +1 -1
  15. package/dist-server/service/regulation/regulation-mutation.d.ts +1 -0
  16. package/dist-server/service/regulation/regulation-mutation.js +14 -0
  17. package/dist-server/service/regulation/regulation-mutation.js.map +1 -1
  18. package/dist-server/service/regulation/regulation-read.js +11 -2
  19. package/dist-server/service/regulation/regulation-read.js.map +1 -1
  20. package/dist-server/service/regulation/regulation-rules.d.ts +22 -3
  21. package/dist-server/service/regulation/regulation-rules.js +69 -13
  22. package/dist-server/service/regulation/regulation-rules.js.map +1 -1
  23. package/dist-server/service/regulation/regulation-service.d.ts +12 -0
  24. package/dist-server/service/regulation/regulation-service.js +48 -7
  25. package/dist-server/service/regulation/regulation-service.js.map +1 -1
  26. package/dist-server/service/regulation/regulation-type.d.ts +4 -0
  27. package/dist-server/service/regulation/regulation-type.js +16 -0
  28. package/dist-server/service/regulation/regulation-type.js.map +1 -1
  29. package/dist-server/service/regulation/regulation.d.ts +2 -0
  30. package/dist-server/service/regulation/regulation.js +11 -1
  31. package/dist-server/service/regulation/regulation.js.map +1 -1
  32. package/dist-server/tsconfig.tsbuildinfo +1 -1
  33. package/dist-server/work-doors.d.ts +1 -0
  34. package/dist-server/work-doors.js +15 -0
  35. package/dist-server/work-doors.js.map +1 -0
  36. package/package.json +14 -14
  37. package/translations/en.json +20 -1
  38. package/translations/es.json +20 -1
  39. package/translations/ja.json +20 -1
  40. package/translations/ko.json +20 -1
  41. package/translations/ms.json +20 -1
  42. package/translations/zh.json +20 -1
@@ -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"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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,oEAAyC;AACzC,mEAAwC;AACxC,sEAA2C;AAC3C,qEAA0C;AAC1C,0DAAyF;AAAhF,wHAAA,uBAAuB,OAAA;AAAE,sHAAA,qBAAqB,OAAA;AACvD,kEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AA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sB;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,OAAO,MAAM,IAAA,yCAAoB,EAAC,YAAY,EAAE,OAAO,CAAC,CAAA;IAC1D,CAAC;IAKK,AAAN,KAAK,CAAC,uBAAuB,CAAY,EAAU,EAAgD,KAA6B,EAAS,OAAwB;QAC/J,OAAO,MAAM,IAA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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,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,EAA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ACxE,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,MAAM,KAAK,oCAAuB,CAAC,OAAO,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAA;IAC9E,MAAM,KAAK,GAAG,IAAA,yBAAO,EAAC,MAAM,CAAC,CAAA;IAC7B,MAAM,QAAQ,GAAG,IAAA,6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BACtD,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,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,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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;IACF,IAAA,0CAAwB,EAAC,iDAA4B,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE;QACnF,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,8BAAiB,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;IACzJ,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, 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 ?? ''])
@@ -1 +1 @@
1
- {"version":3,"file":"regulation-rules.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-rules.ts"],"names":[],"mappings":";;;AAuCA,8BA0BC;AASD,sCAWC;AAkBD,8CAKC;AAOD,0CAkBC;AAGD,4CAUC;AAGD,gCAIC;AAGD,0CAIC;AAGD,sCAIC;AAGD,sDAIC;AA9KD,iDAA+C;AAE/C;;GAEG;AAEH,mFAAmF;AACtE,QAAA,gBAAgB,GAA4F;IACvH,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1E,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,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Ac,EAAE,IAAY;IAChE,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IACnC,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAC1D,OAAO,IAAI,eAAO,CAAC,4BAA4B,EAAE,EAAE,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,mEAAmE,CAAC,CAAA;AACpM,CAAC","sourcesContent":["import { Refusal } from '@things-factory/shell'\n\n/*\n * What a company rule holds to (ADR-0187 decisions 2-4). Pure - the service reads the rows, these say yes or no.\n */\n\n/** Each kind, and the procedure the law asks before a version of it is adopted. */\nexport const REGULATION_KINDS: Record<string, { opinion: boolean; consentWhenUnfavourable: boolean; filing: boolean }> = {\n WORK_RULES: { opinion: true, consentWhenUnfavourable: true, filing: true },\n WORK_RULES_ANNEX: { opinion: true, consentWhenUnfavourable: true, filing: true },\n PRIVACY_POLICY: { opinion: false, consentWhenUnfavourable: false, filing: false },\n PRIVACY_PLAN: { opinion: false, consentWhenUnfavourable: false, filing: false },\n OTHER: { opinion: false, consentWhenUnfavourable: false, filing: false }\n}\n\n/** How an opinion, a consent or a filing was taken. */\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 DAY = /^\\d{4}-\\d{2}-\\d{2}$/\nconst CODE = /^[A-Za-z0-9_-]{1,40}$/\n\nexport interface Clause {\n number: string\n title: string | null\n chapter: string | null\n text: string\n}\n\nconst ARTICLE = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?제\\s*(\\d+(?:의\\s*\\d+)?)\\s*조\\s*(?:[((]([^))]*)[))])?(?:\\*\\*)?\\s*(.*)$/\nconst CHAPTER = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?(제\\s*\\d+\\s*장.*?)(?:\\*\\*)?\\s*$/\n\n/**\n * The articles of a text, each from its `제n조(제목)` head up to the next article or chapter. The words before the first\n * article are no article. A chapter head (`제2장 근로시간`) is kept as the chapter of the articles after it.\n */\nexport function clausesOf(body: string | null | undefined): Clause[] {\n const clauses: Clause[] = []\n let chapter: string | null = null\n let current: (Clause & { lines: string[] }) | null = null\n const close = () => {\n if (!current) return\n clauses.push({ number: current.number, title: current.title, chapter: current.chapter, text: current.lines.join('\\n').trim() })\n current = null\n }\n for (const line of (body ?? '').split(/\\r?\\n/)) {\n const article = ARTICLE.exec(line)\n if (article) {\n close()\n current = { number: article[1].replace(/\\s+/g, ''), title: article[2]?.trim() || null, chapter, text: '', lines: article[3] ? [article[3]] : [] }\n continue\n }\n const head = CHAPTER.exec(line)\n if (head) {\n close()\n chapter = head[1].replace(/\\s+/g, ' ').trim()\n continue\n }\n current?.lines.push(line)\n }\n close()\n return clauses\n}\n\nexport interface ClauseChange {\n number: string\n title: string | null\n change: 'ADDED' | 'CHANGED' | 'REMOVED'\n}\n\n/** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */\nexport function clauseChanges(before: Clause[], after: Clause[]): ClauseChange[] {\n const old = new Map(before.map(one => [one.number, one]))\n const fresh = new Map(after.map(one => [one.number, one]))\n const changes: ClauseChange[] = []\n for (const one of after) {\n const was = old.get(one.number)\n if (!was) changes.push({ number: one.number, title: one.title, change: 'ADDED' })\n else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? '')) changes.push({ number: one.number, title: one.title, change: 'CHANGED' })\n }\n for (const one of before) if (!fresh.has(one.number)) changes.push({ number: one.number, title: one.title, change: 'REMOVED' })\n return changes\n}\n\nexport interface ProcedureFacts {\n kind: string\n day?: string | null\n workersCount?: number | null\n consentCount?: number | null\n files: number\n}\n\nexport interface VersionFacts {\n kind: string\n body?: string | null\n effectiveOn?: string | null\n unfavourable?: boolean | null\n}\n\n/** What a regulation asks before it is written. */\nexport function regulationRefusal(input: { code?: string | null; name?: string | null; kind?: string | null }): Refusal | null {\n if (!input.code || !CODE.test(input.code)) return new Refusal('regulation-code-required', {}, 'give the code - letters, digits, - and _, up to 40')\n if (!input.name?.trim()) return new Refusal('regulation-name-required', {}, 'give the name')\n if (!REGULATION_KINDS[input.kind ?? '']) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n return null\n}\n\n/**\n * What a version asks before it is put up for adoption (decision 4). The writer must say whether the change is against\n * the workers - there is no default. A rule of working conditions needs the majority's opinion with its papers; against\n * them, the consent of more than half with its papers.\n */\nexport function adoptionRefusal(version: VersionFacts, procedures: ProcedureFacts[], today: string): Refusal | null {\n if (!clausesOf(version.body).length) return new Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)')\n if (!version.effectiveOn || !DAY.test(version.effectiveOn)) return new Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD')\n if (version.effectiveOn < today) return new Refusal('regulation-effective-past', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is before today ${today}`)\n if (version.unfavourable == null) return new Refusal('regulation-unfavourable-required', {}, 'say whether the change is against the workers')\n const asks = REGULATION_KINDS[version.kind]\n if (!asks) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n if (asks.opinion && !procedures.some(one => one.kind === 'OPINION' && one.files > 0))\n return new Refusal('regulation-opinion-required', {}, \"record the workers' majority opinion with its paper attached\")\n if (asks.consentWhenUnfavourable && version.unfavourable) {\n const consent = procedures.find(one => one.kind === 'CONSENT' && one.files > 0)\n if (!consent) return new Refusal('regulation-consent-required', {}, \"a change against the workers needs the majority's consent recorded with its paper attached\")\n const workers = Number(consent.workersCount ?? 0)\n const consented = Number(consent.consentCount ?? 0)\n if (!(workers > 0) || !(consented * 2 > workers))\n return new Refusal('regulation-consent-short', { consented, workers }, `a change against the workers - the consent (${consented}) is not more than half of the workers (${workers})`)\n }\n return null\n}\n\n/** What a procedure record asks before it is written. */\nexport function procedureRefusal(input: { kind?: string | null; day?: string | null; method?: string | null; workersCount?: number | null; consentCount?: number | null }): Refusal | null {\n if (!PROCEDURE_METHODS[input.kind ?? '']) return new Refusal('regulation-procedure-kind-required', {}, 'pick opinion, consent or filing')\n if (!input.day || !DAY.test(input.day)) return new Refusal('regulation-procedure-day-required', {}, 'give the day, YYYY-MM-DD')\n if (input.method && !PROCEDURE_METHODS[input.kind!].includes(input.method)) return new Refusal('regulation-procedure-method-unknown', {}, 'pick how it was taken')\n if (input.kind === 'CONSENT') {\n if (!(Number.isInteger(input.workersCount) && (input.workersCount as number) > 0)) return new Refusal('regulation-procedure-workers-required', {}, 'give how many workers it was of')\n if (!(Number.isInteger(input.consentCount) && (input.consentCount as number) >= 0 && (input.consentCount as number) <= (input.workersCount as number)))\n return new Refusal('regulation-procedure-consent-invalid', { workers: input.workersCount }, `the consent count is from 0 to the workers (${input.workersCount})`)\n }\n return null\n}\n\n/** Adopted versions as they stand on `today`: the one in force is the latest whose day has come. */\nexport function standingOf<V extends { status: string; effectiveOn?: string | null; version: number }>(versions: V[], today: string): { inForce: V | null; due: V | null } {\n const adopted = versions.filter(one => one.status === 'ADOPTED' && one.effectiveOn).sort((a, b) => (a.effectiveOn! < b.effectiveOn! ? -1 : a.effectiveOn! > b.effectiveOn! ? 1 : a.version - b.version))\n const come = adopted.filter(one => one.effectiveOn! <= today)\n return { inForce: come[come.length - 1] ?? null, due: adopted.find(one => one.effectiveOn! > today) ?? null }\n}\n\n/** Where an adopted version stands on `today`. */\nexport function periodOfVersion(version: { status: string; effectiveOn?: string | null; id: string }, standing: { inForce: { id: string } | null }, today: string): 'DRAFT' | 'IN_APPROVAL' | 'DUE' | 'IN_FORCE' | 'PAST' {\n if (version.status !== 'ADOPTED') return version.status as 'DRAFT' | 'IN_APPROVAL'\n if (standing.inForce?.id === version.id) return 'IN_FORCE'\n return version.effectiveOn! > today ? 'DUE' : 'PAST'\n}\n\n/** What may change on an adopted version - nothing but the workers count the filing reads. A draft changes freely. */\nexport function changeRefusal(status: string): Refusal | null {\n if (status === 'ADOPTED') return new Refusal('regulation-adopted-fixed', {}, 'an adopted version stays as it was - put up a new version to change it')\n if (status === 'IN_APPROVAL') return new Refusal('regulation-in-approval', {}, 'a version in approval is taken back before it changes')\n return null\n}\n\n/** A procedure is recorded on a draft; a filing also after adoption, since it follows it. */\nexport function procedureWriteRefusal(status: string, kind: string): Refusal | null {\n if (status === 'DRAFT') return null\n if (status === 'ADOPTED' && kind === 'FILING') return null\n return new Refusal('regulation-procedure-fixed', {}, kind === 'FILING' ? 'a filing is recorded once the version is adopted' : 'the procedure of a version in approval or adopted stays as it was')\n}\n"]}
1
+ {"version":3,"file":"regulation-rules.js","sourceRoot":"","sources":["../../../server/service/regulation/regulation-rules.ts"],"names":[],"mappings":";;;AAmDA,0BAgDC;AAaD,sCAWC;AAkBD,8CAKC;AAOD,0CAkBC;AAOD,wCAQC;AAGD,4CAUC;AAGD,gCAIC;AAGD,0CAIC;AAGD,sCAIC;AAGD,sDAIC;AAnOD,iDAA+C;AAE/C;;GAEG;AAEH,mFAAmF;AACtE,QAAA,gBAAgB,GAA4F;IACvH,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAC1E,gBAAgB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE;IAChF,cAAc,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;IACjF,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;IAC/E,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE;CACzE,CAAA;AA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AE,uDAAuD,CAAC,CAAA;IACvI,OAAO,IAAI,CAAA;AACb,CAAC;AAED,6FAA6F;AAC7F,SAAgB,qBAAqB,CAAC,MAAc,EAAE,IAAY;IAChE,IAAI,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAA;IACnC,IAAI,MAAM,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAA;IAC1D,OAAO,IAAI,eAAO,CAAC,4BAA4B,EAAE,EAAE,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,mEAAmE,CAAC,CAAA;AACpM,CAAC","sourcesContent":["import { Refusal } from '@things-factory/shell'\n\n/*\n * What a company rule holds to (ADR-0187 decisions 2-4). Pure - the service reads the rows, these say yes or no.\n */\n\n/** Each kind, and the procedure the law asks before a version of it is adopted. */\nexport const REGULATION_KINDS: Record<string, { opinion: boolean; consentWhenUnfavourable: boolean; filing: boolean }> = {\n WORK_RULES: { opinion: true, consentWhenUnfavourable: true, filing: true },\n WORK_RULES_ANNEX: { opinion: true, consentWhenUnfavourable: true, filing: true },\n PRIVACY_POLICY: { opinion: false, consentWhenUnfavourable: false, filing: false },\n PRIVACY_PLAN: { opinion: false, consentWhenUnfavourable: false, filing: false },\n OTHER: { opinion: false, consentWhenUnfavourable: false, filing: false }\n}\n\n/** How an opinion, a consent or a filing was taken. */\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 DAY = /^\\d{4}-\\d{2}-\\d{2}$/\nconst CODE = /^[A-Za-z0-9_-]{1,40}$/\n\nexport interface Clause {\n number: string\n title: string | null\n chapter: string | null\n heading: string\n text: string\n}\n\nconst ARTICLE = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?제\\s*(\\d+(?:의\\s*\\d+)?)\\s*조\\s*(?:[((]([^))]*)[))])?(?:\\*\\*)?\\s*(.*)$/\nconst CHAPTER = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?(제\\s*\\d+\\s*장.*?)(?:\\*\\*)?\\s*$/\nconst SECTION = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?<?\\s*(제\\s*\\d+\\s*절[^>]*?)\\s*>?(?:\\*\\*)?\\s*$/\nconst ADDENDA = /^\\s*(?:#{1,6}\\s*)?(?:\\*\\*)?부\\s*칙(?:\\*\\*)?\\s*(?:<[^>]*>)?\\s*$/\nconst APPENDIX = /^\\s*(?:#{1,6}\\s*)?\\[[^\\]]+\\]/\n\n/** How an article is named on the page - 「제3조(휴게)」, in the addenda 「부칙 제1조(시행일)」. */\nconst headingOf = (number: string, title: string | null) => {\n const addenda = number.startsWith('부칙')\n return `${addenda ? '부칙 ' : ''}제${addenda ? number.slice(2) : number}조${title ? `(${title})` : ''}`\n}\n\n/**\n * The parts of a text (ADR-0187 decision 2): its articles, each from its `제n조(제목)` head up to the next article or\n * head, and the appendix - from the first line headed in brackets (`[별표 1]`) to the end. The words before the first\n * article are no article. A chapter (`제2장 근로시간`) and a section (`제1절 근로시간`) are kept as the chapter of the\n * articles after them. The articles after 「부칙」 are numbered `부칙1`, `부칙2` - apart from the body's.\n */\nexport function partsOf(body: string | null | undefined): { clauses: Clause[]; appendix: string | null } {\n const clauses: Clause[] = []\n let chapter: string | null = null\n let section: string | null = null\n let addenda = false\n let current: (Omit<Clause, 'text' | 'heading'> & { lines: string[] }) | null = null\n const close = () => {\n if (!current) return\n clauses.push({ number: current.number, title: current.title, chapter: current.chapter, heading: headingOf(current.number, current.title), text: current.lines.join('\\n').trim() })\n current = null\n }\n const lines = (body ?? '').split(/\\r?\\n/)\n for (const [index, line] of lines.entries()) {\n if (APPENDIX.test(line)) {\n close()\n return { clauses, appendix: lines.slice(index).join('\\n').trim() || null }\n }\n const article = ARTICLE.exec(line)\n if (article) {\n close()\n const number = article[1].replace(/\\s+/g, '')\n current = { number: addenda ? `부칙${number}` : number, title: article[2]?.trim() || null, chapter: [chapter, section].filter(Boolean).join(' · ') || null, lines: article[3] ? [article[3]] : [] }\n continue\n }\n const head = CHAPTER.exec(line)\n if (head) {\n close()\n chapter = head[1].replace(/\\s+/g, ' ').trim()\n section = null\n continue\n }\n const part = SECTION.exec(line)\n if (part) {\n close()\n section = part[1].replace(/\\s+/g, ' ').trim()\n continue\n }\n if (ADDENDA.test(line)) {\n close()\n addenda = true\n chapter = '부칙'\n section = null\n continue\n }\n current?.lines.push(line)\n }\n close()\n return { clauses, appendix: null }\n}\n\n/** The articles of a text. */\nexport const clausesOf = (body: string | null | undefined): Clause[] => partsOf(body).clauses\n\nexport interface ClauseChange {\n number: string\n title: string | null\n heading: string\n change: 'ADDED' | 'CHANGED' | 'REMOVED'\n}\n\n/** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */\nexport function clauseChanges(before: Clause[], after: Clause[]): ClauseChange[] {\n const old = new Map(before.map(one => [one.number, one]))\n const fresh = new Map(after.map(one => [one.number, one]))\n const changes: ClauseChange[] = []\n for (const one of after) {\n const was = old.get(one.number)\n if (!was) changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'ADDED' })\n else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? '')) changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'CHANGED' })\n }\n for (const one of before) if (!fresh.has(one.number)) changes.push({ number: one.number, title: one.title, heading: one.heading, change: 'REMOVED' })\n return changes\n}\n\nexport interface ProcedureFacts {\n kind: string\n day?: string | null\n workersCount?: number | null\n consentCount?: number | null\n files: number\n}\n\nexport interface VersionFacts {\n kind: string\n body?: string | null\n effectiveOn?: string | null\n unfavourable?: boolean | null\n}\n\n/** What a regulation asks before it is written. */\nexport function regulationRefusal(input: { code?: string | null; name?: string | null; kind?: string | null }): Refusal | null {\n if (!input.code || !CODE.test(input.code)) return new Refusal('regulation-code-required', {}, 'give the code - letters, digits, - and _, up to 40')\n if (!input.name?.trim()) return new Refusal('regulation-name-required', {}, 'give the name')\n if (!REGULATION_KINDS[input.kind ?? '']) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n return null\n}\n\n/**\n * What a version asks before it is put up for adoption (decision 4). The writer must say whether the change is against\n * the workers - there is no default. A rule of working conditions needs the majority's opinion with its papers; against\n * them, the consent of more than half with its papers.\n */\nexport function adoptionRefusal(version: VersionFacts, procedures: ProcedureFacts[], today: string): Refusal | null {\n if (!clausesOf(version.body).length) return new Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)')\n if (!version.effectiveOn || !DAY.test(version.effectiveOn)) return new Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD')\n if (version.effectiveOn < today) return new Refusal('regulation-effective-past', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is before today ${today}`)\n if (version.unfavourable == null) return new Refusal('regulation-unfavourable-required', {}, 'say whether the change is against the workers')\n const asks = REGULATION_KINDS[version.kind]\n if (!asks) return new Refusal('regulation-kind-required', {}, 'pick what the rule is')\n if (asks.opinion && !procedures.some(one => one.kind === 'OPINION' && one.files > 0))\n return new Refusal('regulation-opinion-required', {}, \"record the workers' majority opinion with its paper attached\")\n if (asks.consentWhenUnfavourable && version.unfavourable) {\n const consent = procedures.find(one => one.kind === 'CONSENT' && one.files > 0)\n if (!consent) return new Refusal('regulation-consent-required', {}, \"a change against the workers needs the majority's consent recorded with its paper attached\")\n const workers = Number(consent.workersCount ?? 0)\n const consented = Number(consent.consentCount ?? 0)\n if (!(workers > 0) || !(consented * 2 > workers))\n return new Refusal('regulation-consent-short', { consented, workers }, `a change against the workers - the consent (${consented}) is not more than half of the workers (${workers})`)\n }\n return null\n}\n\n/**\n * What a version asks before it is registered as in force already (ADR-0187 decision 3, amendment 2): the first version\n * of its rule to be adopted, still being written, with a text, a day come by today and the original attached. No article\n * is asked - a table of amounts has none; no procedure is asked - it was taken before the system.\n */\nexport function inForceRefusal(version: { status: string; body?: string | null; effectiveOn?: string | null }, adoptedBefore: number, originals: number, today: string): Refusal | null {\n if (version.status !== 'DRAFT') return new Refusal('regulation-register-not-draft', {}, 'only a version being written is registered')\n if (adoptedBefore) return new Refusal('regulation-in-force-first-only', {}, 'the rule has a version adopted or in approval - a change of it goes through approval')\n if (!version.body?.trim()) return new Refusal('regulation-body-empty', {}, 'write the text of the rule')\n if (!version.effectiveOn || !DAY.test(version.effectiveOn)) return new Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD')\n if (version.effectiveOn > today) return new 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`)\n if (!originals) return new Refusal('regulation-original-required', {}, 'attach the original of the rule')\n return null\n}\n\n/** What a procedure record asks before it is written. */\nexport function procedureRefusal(input: { kind?: string | null; day?: string | null; method?: string | null; workersCount?: number | null; consentCount?: number | null }): Refusal | null {\n if (!PROCEDURE_METHODS[input.kind ?? '']) return new Refusal('regulation-procedure-kind-required', {}, 'pick opinion, consent or filing')\n if (!input.day || !DAY.test(input.day)) return new Refusal('regulation-procedure-day-required', {}, 'give the day, YYYY-MM-DD')\n if (input.method && !PROCEDURE_METHODS[input.kind!].includes(input.method)) return new Refusal('regulation-procedure-method-unknown', {}, 'pick how it was taken')\n if (input.kind === 'CONSENT') {\n if (!(Number.isInteger(input.workersCount) && (input.workersCount as number) > 0)) return new Refusal('regulation-procedure-workers-required', {}, 'give how many workers it was of')\n if (!(Number.isInteger(input.consentCount) && (input.consentCount as number) >= 0 && (input.consentCount as number) <= (input.workersCount as number)))\n return new Refusal('regulation-procedure-consent-invalid', { workers: input.workersCount }, `the consent count is from 0 to the workers (${input.workersCount})`)\n }\n return null\n}\n\n/** Adopted versions as they stand on `today`: the one in force is the latest whose day has come. */\nexport function standingOf<V extends { status: string; effectiveOn?: string | null; version: number }>(versions: V[], today: string): { inForce: V | null; due: V | null } {\n const adopted = versions.filter(one => one.status === 'ADOPTED' && one.effectiveOn).sort((a, b) => (a.effectiveOn! < b.effectiveOn! ? -1 : a.effectiveOn! > b.effectiveOn! ? 1 : a.version - b.version))\n const come = adopted.filter(one => one.effectiveOn! <= today)\n return { inForce: come[come.length - 1] ?? null, due: adopted.find(one => one.effectiveOn! > today) ?? null }\n}\n\n/** Where an adopted version stands on `today`. */\nexport function periodOfVersion(version: { status: string; effectiveOn?: string | null; id: string }, standing: { inForce: { id: string } | null }, today: string): 'DRAFT' | 'IN_APPROVAL' | 'DUE' | 'IN_FORCE' | 'PAST' {\n if (version.status !== 'ADOPTED') return version.status as 'DRAFT' | 'IN_APPROVAL'\n if (standing.inForce?.id === version.id) return 'IN_FORCE'\n return version.effectiveOn! > today ? 'DUE' : 'PAST'\n}\n\n/** What may change on an adopted version - nothing but the workers count the filing reads. A draft changes freely. */\nexport function changeRefusal(status: string): Refusal | null {\n if (status === 'ADOPTED') return new Refusal('regulation-adopted-fixed', {}, 'an adopted version stays as it was - put up a new version to change it')\n if (status === 'IN_APPROVAL') return new Refusal('regulation-in-approval', {}, 'a version in approval is taken back before it changes')\n return null\n}\n\n/** A procedure is recorded on a draft; a filing also after adoption, since it follows it. */\nexport function procedureWriteRefusal(status: string, kind: string): Refusal | null {\n if (status === 'DRAFT') return null\n if (status === 'ADOPTED' && kind === 'FILING') return null\n return new Refusal('regulation-procedure-fixed', {}, kind === 'FILING' ? 'a filing is recorded once the version is adopted' : 'the procedure of a version in approval or adopted stays as it was')\n}\n"]}