@things-factory/compliance 0.0.0-stage → 10.1.255

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/dist-client/bootstrap.d.ts +2 -0
  2. package/dist-client/bootstrap.js +28 -0
  3. package/dist-client/bootstrap.js.map +1 -0
  4. package/dist-client/components/compliance-case-form.d.ts +42 -0
  5. package/dist-client/components/compliance-case-form.js +313 -0
  6. package/dist-client/components/compliance-case-form.js.map +1 -0
  7. package/dist-client/components/compliance-case-sheet.d.ts +35 -0
  8. package/dist-client/components/compliance-case-sheet.js +335 -0
  9. package/dist-client/components/compliance-case-sheet.js.map +1 -0
  10. package/dist-client/components/compliance-my-inventions.d.ts +17 -0
  11. package/dist-client/components/compliance-my-inventions.js +133 -0
  12. package/dist-client/components/compliance-my-inventions.js.map +1 -0
  13. package/dist-client/components/compliance-my-privacy-requests.d.ts +34 -0
  14. package/dist-client/components/compliance-my-privacy-requests.js +232 -0
  15. package/dist-client/components/compliance-my-privacy-requests.js.map +1 -0
  16. package/dist-client/components/compliance-my-reports.d.ts +19 -0
  17. package/dist-client/components/compliance-my-reports.js +137 -0
  18. package/dist-client/components/compliance-my-reports.js.map +1 -0
  19. package/dist-client/components/guide-link.d.ts +13 -0
  20. package/dist-client/components/guide-link.js +55 -0
  21. package/dist-client/components/guide-link.js.map +1 -0
  22. package/dist-client/components/invention-report-form.d.ts +30 -0
  23. package/dist-client/components/invention-report-form.js +188 -0
  24. package/dist-client/components/invention-report-form.js.map +1 -0
  25. package/dist-client/components/legal-todo.d.ts +10 -0
  26. package/dist-client/components/legal-todo.js +43 -0
  27. package/dist-client/components/legal-todo.js.map +1 -0
  28. package/dist-client/components/my-trainings.d.ts +18 -0
  29. package/dist-client/components/my-trainings.js +149 -0
  30. package/dist-client/components/my-trainings.js.map +1 -0
  31. package/dist-client/components/regulation-form.d.ts +26 -0
  32. package/dist-client/components/regulation-form.js +161 -0
  33. package/dist-client/components/regulation-form.js.map +1 -0
  34. package/dist-client/components/seal-use-form.d.ts +47 -0
  35. package/dist-client/components/seal-use-form.js +300 -0
  36. package/dist-client/components/seal-use-form.js.map +1 -0
  37. package/dist-client/components/training-attendance-form.d.ts +37 -0
  38. package/dist-client/components/training-attendance-form.js +186 -0
  39. package/dist-client/components/training-attendance-form.js.map +1 -0
  40. package/dist-client/components/training-certificate-form.d.ts +41 -0
  41. package/dist-client/components/training-certificate-form.js +198 -0
  42. package/dist-client/components/training-certificate-form.js.map +1 -0
  43. package/dist-client/components/training-session-form.d.ts +39 -0
  44. package/dist-client/components/training-session-form.js +270 -0
  45. package/dist-client/components/training-session-form.js.map +1 -0
  46. package/dist-client/components/training-setting-form.d.ts +45 -0
  47. package/dist-client/components/training-setting-form.js +175 -0
  48. package/dist-client/components/training-setting-form.js.map +1 -0
  49. package/dist-client/index.d.ts +4 -0
  50. package/dist-client/index.js +8 -0
  51. package/dist-client/index.js.map +1 -0
  52. package/dist-client/legal-record/dispute-calendar-source.d.ts +1 -0
  53. package/dist-client/legal-record/dispute-calendar-source.js +51 -0
  54. package/dist-client/legal-record/dispute-calendar-source.js.map +1 -0
  55. package/dist-client/legal-record/legal-child-grid.d.ts +31 -0
  56. package/dist-client/legal-record/legal-child-grid.js +76 -0
  57. package/dist-client/legal-record/legal-child-grid.js.map +1 -0
  58. package/dist-client/legal-record/legal-codes.d.ts +3 -0
  59. package/dist-client/legal-record/legal-codes.js +5 -0
  60. package/dist-client/legal-record/legal-codes.js.map +1 -0
  61. package/dist-client/legal-record/legal-grid.d.ts +59 -0
  62. package/dist-client/legal-record/legal-grid.js +68 -0
  63. package/dist-client/legal-record/legal-grid.js.map +1 -0
  64. package/dist-client/legal-record/legal-record-files.d.ts +26 -0
  65. package/dist-client/legal-record/legal-record-files.js +162 -0
  66. package/dist-client/legal-record/legal-record-files.js.map +1 -0
  67. package/dist-client/pages/compliance-case-list.d.ts +35 -0
  68. package/dist-client/pages/compliance-case-list.js +112 -0
  69. package/dist-client/pages/compliance-case-list.js.map +1 -0
  70. package/dist-client/pages/dispute-list.d.ts +57 -0
  71. package/dist-client/pages/dispute-list.js +156 -0
  72. package/dist-client/pages/dispute-list.js.map +1 -0
  73. package/dist-client/pages/invention-list.d.ts +57 -0
  74. package/dist-client/pages/invention-list.js +166 -0
  75. package/dist-client/pages/invention-list.js.map +1 -0
  76. package/dist-client/pages/legal-registration-list.d.ts +63 -0
  77. package/dist-client/pages/legal-registration-list.js +206 -0
  78. package/dist-client/pages/legal-registration-list.js.map +1 -0
  79. package/dist-client/pages/privacy-record-list.d.ts +52 -0
  80. package/dist-client/pages/privacy-record-list.js +225 -0
  81. package/dist-client/pages/privacy-record-list.js.map +1 -0
  82. package/dist-client/pages/regulation-detail.d.ts +43 -0
  83. package/dist-client/pages/regulation-detail.js +370 -0
  84. package/dist-client/pages/regulation-detail.js.map +1 -0
  85. package/dist-client/pages/regulation-list.d.ts +52 -0
  86. package/dist-client/pages/regulation-list.js +144 -0
  87. package/dist-client/pages/regulation-list.js.map +1 -0
  88. package/dist-client/pages/regulations.d.ts +49 -0
  89. package/dist-client/pages/regulations.js +412 -0
  90. package/dist-client/pages/regulations.js.map +1 -0
  91. package/dist-client/pages/seal-use-list.d.ts +57 -0
  92. package/dist-client/pages/seal-use-list.js +168 -0
  93. package/dist-client/pages/seal-use-list.js.map +1 -0
  94. package/dist-client/pages/training-list.d.ts +51 -0
  95. package/dist-client/pages/training-list.js +333 -0
  96. package/dist-client/pages/training-list.js.map +1 -0
  97. package/dist-client/regulation/regulation-fragments.d.ts +1 -0
  98. package/dist-client/regulation/regulation-fragments.js +37 -0
  99. package/dist-client/regulation/regulation-fragments.js.map +1 -0
  100. package/dist-client/regulation/regulation-guide.d.ts +19 -0
  101. package/dist-client/regulation/regulation-guide.js +48 -0
  102. package/dist-client/regulation/regulation-guide.js.map +1 -0
  103. package/dist-client/route.d.ts +1 -0
  104. package/dist-client/route.js +36 -0
  105. package/dist-client/route.js.map +1 -0
  106. package/dist-client/training-words.d.ts +11 -0
  107. package/dist-client/training-words.js +11 -0
  108. package/dist-client/training-words.js.map +1 -0
  109. package/dist-client/tsconfig.tsbuildinfo +1 -0
  110. package/dist-client/words.d.ts +15 -0
  111. package/dist-client/words.js +20 -0
  112. package/dist-client/words.js.map +1 -0
  113. package/dist-server/activities/index.d.ts +6 -0
  114. package/dist-server/activities/index.js +37 -0
  115. package/dist-server/activities/index.js.map +1 -0
  116. package/dist-server/activities/legal-todo-activity-names.d.ts +1 -0
  117. package/dist-server/activities/legal-todo-activity-names.js +5 -0
  118. package/dist-server/activities/legal-todo-activity-names.js.map +1 -0
  119. package/dist-server/activities/legal-todo-activity.d.ts +37 -0
  120. package/dist-server/activities/legal-todo-activity.js +41 -0
  121. package/dist-server/activities/legal-todo-activity.js.map +1 -0
  122. package/dist-server/activities/regulation-activity-names.d.ts +1 -0
  123. package/dist-server/activities/regulation-activity-names.js +5 -0
  124. package/dist-server/activities/regulation-activity-names.js.map +1 -0
  125. package/dist-server/activities/regulation-activity.d.ts +48 -0
  126. package/dist-server/activities/regulation-activity.js +47 -0
  127. package/dist-server/activities/regulation-activity.js.map +1 -0
  128. package/dist-server/activities/seal-use-activity-names.d.ts +2 -0
  129. package/dist-server/activities/seal-use-activity-names.js +6 -0
  130. package/dist-server/activities/seal-use-activity-names.js.map +1 -0
  131. package/dist-server/activities/seal-use-activity.d.ts +48 -0
  132. package/dist-server/activities/seal-use-activity.js +47 -0
  133. package/dist-server/activities/seal-use-activity.js.map +1 -0
  134. package/dist-server/index.d.ts +2 -0
  135. package/dist-server/index.js +21 -0
  136. package/dist-server/index.js.map +1 -0
  137. package/dist-server/role-tasks.d.ts +2 -0
  138. package/dist-server/role-tasks.js +28 -0
  139. package/dist-server/role-tasks.js.map +1 -0
  140. package/dist-server/service/common/correction.d.ts +32 -0
  141. package/dist-server/service/common/correction.js +98 -0
  142. package/dist-server/service/common/correction.js.map +1 -0
  143. package/dist-server/service/common/employee-reader.d.ts +11 -0
  144. package/dist-server/service/common/employee-reader.js +46 -0
  145. package/dist-server/service/common/employee-reader.js.map +1 -0
  146. package/dist-server/service/common/legal-todo.d.ts +19 -0
  147. package/dist-server/service/common/legal-todo.js +37 -0
  148. package/dist-server/service/common/legal-todo.js.map +1 -0
  149. package/dist-server/service/compliance-case/compliance-case-mutation.d.ts +9 -0
  150. package/dist-server/service/compliance-case/compliance-case-mutation.js +73 -0
  151. package/dist-server/service/compliance-case/compliance-case-mutation.js.map +1 -0
  152. package/dist-server/service/compliance-case/compliance-case-query.d.ts +28 -0
  153. package/dist-server/service/compliance-case/compliance-case-query.js +212 -0
  154. package/dist-server/service/compliance-case/compliance-case-query.js.map +1 -0
  155. package/dist-server/service/compliance-case/compliance-case-rules.d.ts +71 -0
  156. package/dist-server/service/compliance-case/compliance-case-rules.js +111 -0
  157. package/dist-server/service/compliance-case/compliance-case-rules.js.map +1 -0
  158. package/dist-server/service/compliance-case/compliance-case-service.d.ts +76 -0
  159. package/dist-server/service/compliance-case/compliance-case-service.js +425 -0
  160. package/dist-server/service/compliance-case/compliance-case-service.js.map +1 -0
  161. package/dist-server/service/compliance-case/compliance-case-type.d.ts +56 -0
  162. package/dist-server/service/compliance-case/compliance-case-type.js +200 -0
  163. package/dist-server/service/compliance-case/compliance-case-type.js.map +1 -0
  164. package/dist-server/service/compliance-case/compliance-case.d.ts +76 -0
  165. package/dist-server/service/compliance-case/compliance-case.js +260 -0
  166. package/dist-server/service/compliance-case/compliance-case.js.map +1 -0
  167. package/dist-server/service/compliance-case/index.d.ts +7 -0
  168. package/dist-server/service/compliance-case/index.js +17 -0
  169. package/dist-server/service/compliance-case/index.js.map +1 -0
  170. package/dist-server/service/dispute/dispute-mutation.d.ts +9 -0
  171. package/dist-server/service/dispute/dispute-mutation.js +64 -0
  172. package/dist-server/service/dispute/dispute-mutation.js.map +1 -0
  173. package/dist-server/service/dispute/dispute-query.d.ts +16 -0
  174. package/dist-server/service/dispute/dispute-query.js +124 -0
  175. package/dist-server/service/dispute/dispute-query.js.map +1 -0
  176. package/dist-server/service/dispute/dispute-rules.d.ts +20 -0
  177. package/dist-server/service/dispute/dispute-rules.js +42 -0
  178. package/dist-server/service/dispute/dispute-rules.js.map +1 -0
  179. package/dist-server/service/dispute/dispute-service.d.ts +17 -0
  180. package/dist-server/service/dispute/dispute-service.js +96 -0
  181. package/dist-server/service/dispute/dispute-service.js.map +1 -0
  182. package/dist-server/service/dispute/dispute-type.d.ts +39 -0
  183. package/dist-server/service/dispute/dispute-type.js +149 -0
  184. package/dist-server/service/dispute/dispute-type.js.map +1 -0
  185. package/dist-server/service/dispute/dispute.d.ts +48 -0
  186. package/dist-server/service/dispute/dispute.js +198 -0
  187. package/dist-server/service/dispute/dispute.js.map +1 -0
  188. package/dist-server/service/dispute/index.d.ts +5 -0
  189. package/dist-server/service/dispute/index.js +9 -0
  190. package/dist-server/service/dispute/index.js.map +1 -0
  191. package/dist-server/service/index.d.ts +46 -0
  192. package/dist-server/service/index.js +112 -0
  193. package/dist-server/service/index.js.map +1 -0
  194. package/dist-server/service/invention/index.d.ts +5 -0
  195. package/dist-server/service/invention/index.js +9 -0
  196. package/dist-server/service/invention/index.js.map +1 -0
  197. package/dist-server/service/invention/invention-mutation.d.ts +10 -0
  198. package/dist-server/service/invention/invention-mutation.js +79 -0
  199. package/dist-server/service/invention/invention-mutation.js.map +1 -0
  200. package/dist-server/service/invention/invention-query.d.ts +18 -0
  201. package/dist-server/service/invention/invention-query.js +141 -0
  202. package/dist-server/service/invention/invention-query.js.map +1 -0
  203. package/dist-server/service/invention/invention-rules.d.ts +28 -0
  204. package/dist-server/service/invention/invention-rules.js +54 -0
  205. package/dist-server/service/invention/invention-rules.js.map +1 -0
  206. package/dist-server/service/invention/invention-service.d.ts +25 -0
  207. package/dist-server/service/invention/invention-service.js +176 -0
  208. package/dist-server/service/invention/invention-service.js.map +1 -0
  209. package/dist-server/service/invention/invention-type.d.ts +34 -0
  210. package/dist-server/service/invention/invention-type.js +129 -0
  211. package/dist-server/service/invention/invention-type.js.map +1 -0
  212. package/dist-server/service/invention/invention.d.ts +55 -0
  213. package/dist-server/service/invention/invention.js +214 -0
  214. package/dist-server/service/invention/invention.js.map +1 -0
  215. package/dist-server/service/legal-record/attachment-readers.d.ts +1 -0
  216. package/dist-server/service/legal-record/attachment-readers.js +27 -0
  217. package/dist-server/service/legal-record/attachment-readers.js.map +1 -0
  218. package/dist-server/service/legal-record/days.d.ts +7 -0
  219. package/dist-server/service/legal-record/days.js +26 -0
  220. package/dist-server/service/legal-record/days.js.map +1 -0
  221. package/dist-server/service/legal-record/legal-record-support.d.ts +24 -0
  222. package/dist-server/service/legal-record/legal-record-support.js +51 -0
  223. package/dist-server/service/legal-record/legal-record-support.js.map +1 -0
  224. package/dist-server/service/legal-registration/centre-change-subscriber.d.ts +9 -0
  225. package/dist-server/service/legal-registration/centre-change-subscriber.js +50 -0
  226. package/dist-server/service/legal-registration/centre-change-subscriber.js.map +1 -0
  227. package/dist-server/service/legal-registration/index.d.ts +7 -0
  228. package/dist-server/service/legal-registration/index.js +11 -0
  229. package/dist-server/service/legal-registration/index.js.map +1 -0
  230. package/dist-server/service/legal-registration/legal-registration-mutation.d.ts +10 -0
  231. package/dist-server/service/legal-registration/legal-registration-mutation.js +77 -0
  232. package/dist-server/service/legal-registration/legal-registration-mutation.js.map +1 -0
  233. package/dist-server/service/legal-registration/legal-registration-query.d.ts +26 -0
  234. package/dist-server/service/legal-registration/legal-registration-query.js +199 -0
  235. package/dist-server/service/legal-registration/legal-registration-query.js.map +1 -0
  236. package/dist-server/service/legal-registration/legal-registration-rules.d.ts +80 -0
  237. package/dist-server/service/legal-registration/legal-registration-rules.js +106 -0
  238. package/dist-server/service/legal-registration/legal-registration-rules.js.map +1 -0
  239. package/dist-server/service/legal-registration/legal-registration-service.d.ts +37 -0
  240. package/dist-server/service/legal-registration/legal-registration-service.js +248 -0
  241. package/dist-server/service/legal-registration/legal-registration-service.js.map +1 -0
  242. package/dist-server/service/legal-registration/legal-registration-type.d.ts +55 -0
  243. package/dist-server/service/legal-registration/legal-registration-type.js +207 -0
  244. package/dist-server/service/legal-registration/legal-registration-type.js.map +1 -0
  245. package/dist-server/service/legal-registration/legal-registration.d.ts +76 -0
  246. package/dist-server/service/legal-registration/legal-registration.js +311 -0
  247. package/dist-server/service/legal-registration/legal-registration.js.map +1 -0
  248. package/dist-server/service/privacy-record/index.d.ts +5 -0
  249. package/dist-server/service/privacy-record/index.js +9 -0
  250. package/dist-server/service/privacy-record/index.js.map +1 -0
  251. package/dist-server/service/privacy-record/privacy-record-mutation.d.ts +7 -0
  252. package/dist-server/service/privacy-record/privacy-record-mutation.js +56 -0
  253. package/dist-server/service/privacy-record/privacy-record-mutation.js.map +1 -0
  254. package/dist-server/service/privacy-record/privacy-record-query.d.ts +18 -0
  255. package/dist-server/service/privacy-record/privacy-record-query.js +131 -0
  256. package/dist-server/service/privacy-record/privacy-record-query.js.map +1 -0
  257. package/dist-server/service/privacy-record/privacy-record-rules.d.ts +52 -0
  258. package/dist-server/service/privacy-record/privacy-record-rules.js +91 -0
  259. package/dist-server/service/privacy-record/privacy-record-rules.js.map +1 -0
  260. package/dist-server/service/privacy-record/privacy-record-service.d.ts +33 -0
  261. package/dist-server/service/privacy-record/privacy-record-service.js +133 -0
  262. package/dist-server/service/privacy-record/privacy-record-service.js.map +1 -0
  263. package/dist-server/service/privacy-record/privacy-record-type.d.ts +40 -0
  264. package/dist-server/service/privacy-record/privacy-record-type.js +153 -0
  265. package/dist-server/service/privacy-record/privacy-record-type.js.map +1 -0
  266. package/dist-server/service/privacy-record/privacy-record.d.ts +69 -0
  267. package/dist-server/service/privacy-record/privacy-record.js +245 -0
  268. package/dist-server/service/privacy-record/privacy-record.js.map +1 -0
  269. package/dist-server/service/regulation/index.d.ts +5 -0
  270. package/dist-server/service/regulation/index.js +9 -0
  271. package/dist-server/service/regulation/index.js.map +1 -0
  272. package/dist-server/service/regulation/regulation-mutation.d.ts +15 -0
  273. package/dist-server/service/regulation/regulation-mutation.js +152 -0
  274. package/dist-server/service/regulation/regulation-mutation.js.map +1 -0
  275. package/dist-server/service/regulation/regulation-query.d.ts +10 -0
  276. package/dist-server/service/regulation/regulation-query.js +109 -0
  277. package/dist-server/service/regulation/regulation-query.js.map +1 -0
  278. package/dist-server/service/regulation/regulation-read.d.ts +21 -0
  279. package/dist-server/service/regulation/regulation-read.js +111 -0
  280. package/dist-server/service/regulation/regulation-read.js.map +1 -0
  281. package/dist-server/service/regulation/regulation-rules.d.ts +83 -0
  282. package/dist-server/service/regulation/regulation-rules.js +170 -0
  283. package/dist-server/service/regulation/regulation-rules.js.map +1 -0
  284. package/dist-server/service/regulation/regulation-service.d.ts +63 -0
  285. package/dist-server/service/regulation/regulation-service.js +365 -0
  286. package/dist-server/service/regulation/regulation-service.js.map +1 -0
  287. package/dist-server/service/regulation/regulation-type.d.ts +61 -0
  288. package/dist-server/service/regulation/regulation-type.js +226 -0
  289. package/dist-server/service/regulation/regulation-type.js.map +1 -0
  290. package/dist-server/service/regulation/regulation.d.ts +113 -0
  291. package/dist-server/service/regulation/regulation.js +382 -0
  292. package/dist-server/service/regulation/regulation.js.map +1 -0
  293. package/dist-server/service/seal-use/index.d.ts +5 -0
  294. package/dist-server/service/seal-use/index.js +9 -0
  295. package/dist-server/service/seal-use/index.js.map +1 -0
  296. package/dist-server/service/seal-use/seal-use-mutation.d.ts +8 -0
  297. package/dist-server/service/seal-use/seal-use-mutation.js +69 -0
  298. package/dist-server/service/seal-use/seal-use-mutation.js.map +1 -0
  299. package/dist-server/service/seal-use/seal-use-query.d.ts +14 -0
  300. package/dist-server/service/seal-use/seal-use-query.js +100 -0
  301. package/dist-server/service/seal-use/seal-use-query.js.map +1 -0
  302. package/dist-server/service/seal-use/seal-use-rules.d.ts +35 -0
  303. package/dist-server/service/seal-use/seal-use-rules.js +64 -0
  304. package/dist-server/service/seal-use/seal-use-rules.js.map +1 -0
  305. package/dist-server/service/seal-use/seal-use-service.d.ts +20 -0
  306. package/dist-server/service/seal-use/seal-use-service.js +168 -0
  307. package/dist-server/service/seal-use/seal-use-service.js.map +1 -0
  308. package/dist-server/service/seal-use/seal-use-type.d.ts +24 -0
  309. package/dist-server/service/seal-use/seal-use-type.js +93 -0
  310. package/dist-server/service/seal-use/seal-use-type.js.map +1 -0
  311. package/dist-server/service/seal-use/seal-use.d.ts +57 -0
  312. package/dist-server/service/seal-use/seal-use.js +181 -0
  313. package/dist-server/service/seal-use/seal-use.js.map +1 -0
  314. package/dist-server/service/training/index.d.ts +5 -0
  315. package/dist-server/service/training/index.js +9 -0
  316. package/dist-server/service/training/index.js.map +1 -0
  317. package/dist-server/service/training/training-checks.d.ts +20 -0
  318. package/dist-server/service/training/training-checks.js +56 -0
  319. package/dist-server/service/training/training-checks.js.map +1 -0
  320. package/dist-server/service/training/training-kinds.d.ts +24 -0
  321. package/dist-server/service/training/training-kinds.js +42 -0
  322. package/dist-server/service/training/training-kinds.js.map +1 -0
  323. package/dist-server/service/training/training-mutation.d.ts +14 -0
  324. package/dist-server/service/training/training-mutation.js +140 -0
  325. package/dist-server/service/training/training-mutation.js.map +1 -0
  326. package/dist-server/service/training/training-query.d.ts +21 -0
  327. package/dist-server/service/training/training-query.js +196 -0
  328. package/dist-server/service/training/training-query.js.map +1 -0
  329. package/dist-server/service/training/training-read.d.ts +5 -0
  330. package/dist-server/service/training/training-read.js +35 -0
  331. package/dist-server/service/training/training-read.js.map +1 -0
  332. package/dist-server/service/training/training-register.d.ts +1 -0
  333. package/dist-server/service/training/training-register.js +27 -0
  334. package/dist-server/service/training/training-register.js.map +1 -0
  335. package/dist-server/service/training/training-rules.d.ts +72 -0
  336. package/dist-server/service/training/training-rules.js +143 -0
  337. package/dist-server/service/training/training-rules.js.map +1 -0
  338. package/dist-server/service/training/training-service.d.ts +98 -0
  339. package/dist-server/service/training/training-service.js +455 -0
  340. package/dist-server/service/training/training-service.js.map +1 -0
  341. package/dist-server/service/training/training-type.d.ts +94 -0
  342. package/dist-server/service/training/training-type.js +352 -0
  343. package/dist-server/service/training/training-type.js.map +1 -0
  344. package/dist-server/service/training/training.d.ts +127 -0
  345. package/dist-server/service/training/training.js +448 -0
  346. package/dist-server/service/training/training.js.map +1 -0
  347. package/dist-server/tsconfig.tsbuildinfo +1 -0
  348. package/package.json +61 -4
  349. package/things-factory.config.js +19 -0
  350. package/translations/en.json +612 -0
  351. package/translations/es.json +612 -0
  352. package/translations/ja.json +612 -0
  353. package/translations/ko.json +612 -0
  354. package/translations/ms.json +612 -0
  355. package/translations/zh.json +612 -0
  356. package/README.md +0 -3
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROCEDURE_METHODS = exports.REGULATION_KINDS = void 0;
4
+ exports.clausesOf = clausesOf;
5
+ exports.clauseChanges = clauseChanges;
6
+ exports.regulationRefusal = regulationRefusal;
7
+ exports.adoptionRefusal = adoptionRefusal;
8
+ exports.procedureRefusal = procedureRefusal;
9
+ exports.standingOf = standingOf;
10
+ exports.periodOfVersion = periodOfVersion;
11
+ exports.changeRefusal = changeRefusal;
12
+ exports.procedureWriteRefusal = procedureWriteRefusal;
13
+ const shell_1 = require("@things-factory/shell");
14
+ /*
15
+ * What a company rule holds to (ADR-0187 decisions 2-4). Pure - the service reads the rows, these say yes or no.
16
+ */
17
+ /** Each kind, and the procedure the law asks before a version of it is adopted. */
18
+ exports.REGULATION_KINDS = {
19
+ WORK_RULES: { opinion: true, consentWhenUnfavourable: true, filing: true },
20
+ WORK_RULES_ANNEX: { opinion: true, consentWhenUnfavourable: true, filing: true },
21
+ PRIVACY_POLICY: { opinion: false, consentWhenUnfavourable: false, filing: false },
22
+ PRIVACY_PLAN: { opinion: false, consentWhenUnfavourable: false, filing: false },
23
+ OTHER: { opinion: false, consentWhenUnfavourable: false, filing: false }
24
+ };
25
+ /** How an opinion, a consent or a filing was taken. */
26
+ exports.PROCEDURE_METHODS = {
27
+ OPINION: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],
28
+ CONSENT: ['MAJORITY_UNION', 'WORKERS_MEETING', 'SIGNATURES'],
29
+ FILING: ['ONLINE', 'VISIT', 'MAIL']
30
+ };
31
+ const DAY = /^\d{4}-\d{2}-\d{2}$/;
32
+ const CODE = /^[A-Za-z0-9_-]{1,40}$/;
33
+ const ARTICLE = /^\s*(?:#{1,6}\s*)?(?:\*\*)?제\s*(\d+(?:의\s*\d+)?)\s*조\s*(?:[((]([^))]*)[))])?(?:\*\*)?\s*(.*)$/;
34
+ const CHAPTER = /^\s*(?:#{1,6}\s*)?(?:\*\*)?(제\s*\d+\s*장.*?)(?:\*\*)?\s*$/;
35
+ /**
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.
38
+ */
39
+ function clausesOf(body) {
40
+ const clauses = [];
41
+ let chapter = null;
42
+ let current = null;
43
+ const close = () => {
44
+ if (!current)
45
+ return;
46
+ clauses.push({ number: current.number, title: current.title, chapter: current.chapter, text: current.lines.join('\n').trim() });
47
+ current = null;
48
+ };
49
+ for (const line of (body ?? '').split(/\r?\n/)) {
50
+ const article = ARTICLE.exec(line);
51
+ if (article) {
52
+ close();
53
+ current = { number: article[1].replace(/\s+/g, ''), title: article[2]?.trim() || null, chapter, text: '', lines: article[3] ? [article[3]] : [] };
54
+ continue;
55
+ }
56
+ const head = CHAPTER.exec(line);
57
+ if (head) {
58
+ close();
59
+ chapter = head[1].replace(/\s+/g, ' ').trim();
60
+ continue;
61
+ }
62
+ current?.lines.push(line);
63
+ }
64
+ close();
65
+ return clauses;
66
+ }
67
+ /** What a version changed of the one before, article by article - by number; a heading or words that differ is a change. */
68
+ function clauseChanges(before, after) {
69
+ const old = new Map(before.map(one => [one.number, one]));
70
+ const fresh = new Map(after.map(one => [one.number, one]));
71
+ const changes = [];
72
+ for (const one of after) {
73
+ const was = old.get(one.number);
74
+ if (!was)
75
+ changes.push({ number: one.number, title: one.title, change: 'ADDED' });
76
+ else if (was.text !== one.text || (was.title ?? '') !== (one.title ?? ''))
77
+ changes.push({ number: one.number, title: one.title, change: 'CHANGED' });
78
+ }
79
+ for (const one of before)
80
+ if (!fresh.has(one.number))
81
+ changes.push({ number: one.number, title: one.title, change: 'REMOVED' });
82
+ return changes;
83
+ }
84
+ /** What a regulation asks before it is written. */
85
+ function regulationRefusal(input) {
86
+ if (!input.code || !CODE.test(input.code))
87
+ return new shell_1.Refusal('regulation-code-required', {}, 'give the code - letters, digits, - and _, up to 40');
88
+ if (!input.name?.trim())
89
+ return new shell_1.Refusal('regulation-name-required', {}, 'give the name');
90
+ if (!exports.REGULATION_KINDS[input.kind ?? ''])
91
+ return new shell_1.Refusal('regulation-kind-required', {}, 'pick what the rule is');
92
+ return null;
93
+ }
94
+ /**
95
+ * What a version asks before it is put up for adoption (decision 4). The writer must say whether the change is against
96
+ * the workers - there is no default. A rule of working conditions needs the majority's opinion with its papers; against
97
+ * them, the consent of more than half with its papers.
98
+ */
99
+ function adoptionRefusal(version, procedures, today) {
100
+ if (!clausesOf(version.body).length)
101
+ return new shell_1.Refusal('regulation-body-required', {}, 'the text has no article - begin each with 제n조(제목)');
102
+ if (!version.effectiveOn || !DAY.test(version.effectiveOn))
103
+ return new shell_1.Refusal('regulation-effective-required', {}, 'give the day it takes effect, YYYY-MM-DD');
104
+ if (version.effectiveOn < today)
105
+ return new shell_1.Refusal('regulation-effective-past', { effectiveOn: version.effectiveOn, today }, `the effective day ${version.effectiveOn} is before today ${today}`);
106
+ if (version.unfavourable == null)
107
+ return new shell_1.Refusal('regulation-unfavourable-required', {}, 'say whether the change is against the workers');
108
+ const asks = exports.REGULATION_KINDS[version.kind];
109
+ if (!asks)
110
+ return new shell_1.Refusal('regulation-kind-required', {}, 'pick what the rule is');
111
+ if (asks.opinion && !procedures.some(one => one.kind === 'OPINION' && one.files > 0))
112
+ return new shell_1.Refusal('regulation-opinion-required', {}, "record the workers' majority opinion with its paper attached");
113
+ if (asks.consentWhenUnfavourable && version.unfavourable) {
114
+ const consent = procedures.find(one => one.kind === 'CONSENT' && one.files > 0);
115
+ if (!consent)
116
+ return new shell_1.Refusal('regulation-consent-required', {}, "a change against the workers needs the majority's consent recorded with its paper attached");
117
+ const workers = Number(consent.workersCount ?? 0);
118
+ const consented = Number(consent.consentCount ?? 0);
119
+ if (!(workers > 0) || !(consented * 2 > workers))
120
+ return new shell_1.Refusal('regulation-consent-short', { consented, workers }, `a change against the workers - the consent (${consented}) is not more than half of the workers (${workers})`);
121
+ }
122
+ return null;
123
+ }
124
+ /** What a procedure record asks before it is written. */
125
+ function procedureRefusal(input) {
126
+ if (!exports.PROCEDURE_METHODS[input.kind ?? ''])
127
+ return new shell_1.Refusal('regulation-procedure-kind-required', {}, 'pick opinion, consent or filing');
128
+ if (!input.day || !DAY.test(input.day))
129
+ return new shell_1.Refusal('regulation-procedure-day-required', {}, 'give the day, YYYY-MM-DD');
130
+ if (input.method && !exports.PROCEDURE_METHODS[input.kind].includes(input.method))
131
+ return new shell_1.Refusal('regulation-procedure-method-unknown', {}, 'pick how it was taken');
132
+ if (input.kind === 'CONSENT') {
133
+ if (!(Number.isInteger(input.workersCount) && input.workersCount > 0))
134
+ return new shell_1.Refusal('regulation-procedure-workers-required', {}, 'give how many workers it was of');
135
+ if (!(Number.isInteger(input.consentCount) && input.consentCount >= 0 && input.consentCount <= input.workersCount))
136
+ return new shell_1.Refusal('regulation-procedure-consent-invalid', { workers: input.workersCount }, `the consent count is from 0 to the workers (${input.workersCount})`);
137
+ }
138
+ return null;
139
+ }
140
+ /** Adopted versions as they stand on `today`: the one in force is the latest whose day has come. */
141
+ function standingOf(versions, today) {
142
+ 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));
143
+ const come = adopted.filter(one => one.effectiveOn <= today);
144
+ return { inForce: come[come.length - 1] ?? null, due: adopted.find(one => one.effectiveOn > today) ?? null };
145
+ }
146
+ /** Where an adopted version stands on `today`. */
147
+ function periodOfVersion(version, standing, today) {
148
+ if (version.status !== 'ADOPTED')
149
+ return version.status;
150
+ if (standing.inForce?.id === version.id)
151
+ return 'IN_FORCE';
152
+ return version.effectiveOn > today ? 'DUE' : 'PAST';
153
+ }
154
+ /** What may change on an adopted version - nothing but the workers count the filing reads. A draft changes freely. */
155
+ function changeRefusal(status) {
156
+ if (status === 'ADOPTED')
157
+ return new shell_1.Refusal('regulation-adopted-fixed', {}, 'an adopted version stays as it was - put up a new version to change it');
158
+ if (status === 'IN_APPROVAL')
159
+ return new shell_1.Refusal('regulation-in-approval', {}, 'a version in approval is taken back before it changes');
160
+ return null;
161
+ }
162
+ /** A procedure is recorded on a draft; a filing also after adoption, since it follows it. */
163
+ function procedureWriteRefusal(status, kind) {
164
+ if (status === 'DRAFT')
165
+ return null;
166
+ if (status === 'ADOPTED' && kind === 'FILING')
167
+ return null;
168
+ return new shell_1.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');
169
+ }
170
+ //# sourceMappingURL=regulation-rules.js.map
@@ -0,0 +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,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AC,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 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"]}
@@ -0,0 +1,63 @@
1
+ import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
2
+ import { EntityManager } from 'typeorm';
3
+ import { Regulation, RegulationProcedure, RegulationVersion } from './regulation';
4
+ import { NewRegulation, NewRegulationProcedure, RegulationPatch, RegulationVersionPatch } from './regulation-type';
5
+ /** The papers of a procedure hang on it under this `refType` (attachment-base). */
6
+ export declare const REGULATION_PROCEDURE_REF_TYPE = "RegulationProcedure";
7
+ /** The help source of the articles (ADR-0187 decision 12). */
8
+ export declare const REGULATION_HELP_SOURCE = "regulation";
9
+ /** The announcement trigger of an adoption (ADR-0187 decision 6). */
10
+ export declare const REGULATION_ADOPTED_TRIGGER = "compliance.regulation-adopted";
11
+ export declare function versionOf(tx: EntityManager, domain: {
12
+ id: string;
13
+ }, id: string): Promise<RegulationVersion>;
14
+ /** A new rule, with its first version to write. */
15
+ export declare function createRegulation(input: NewRegulation, context: ResolverContext): Promise<Regulation>;
16
+ /** The name, topics and place of a rule; its kind only while none of its versions is adopted. */
17
+ export declare function updateRegulation(id: string, patch: RegulationPatch, context: ResolverContext): Promise<Regulation>;
18
+ /** A rule with no adopted version is deleted with its drafts; one adopted once is kept - its employees were told of it. */
19
+ export declare function deleteRegulations(ids: string[], context: ResolverContext): Promise<boolean>;
20
+ /** The next version to write, its text the latest version's. One is written at a time. */
21
+ export declare function newRegulationVersion(regulationId: string, context: ResolverContext): Promise<RegulationVersion>;
22
+ /** The text, day, summary, whether it is against the workers and how many workers - of a version being written. */
23
+ export declare function updateRegulationVersion(id: string, patch: RegulationVersionPatch, context: ResolverContext): Promise<RegulationVersion>;
24
+ /** A version being written is deleted; one put up or adopted is kept. */
25
+ export declare function deleteRegulationVersion(id: string, context: ResolverContext): Promise<boolean>;
26
+ /** Records an opinion heard, a consent or a filing, with its papers. */
27
+ export declare function recordRegulationProcedure(input: NewRegulationProcedure, files: FileUpload[] | undefined, context: ResolverContext): Promise<RegulationProcedure>;
28
+ /** A procedure of a version being written is taken off; once put up it is the evidence and stays. */
29
+ export declare function deleteRegulationProcedure(id: string, context: ResolverContext): Promise<boolean>;
30
+ /** The procedures of versions, each with how many papers it carries. */
31
+ export declare function proceduresOf(tx: EntityManager, domain: {
32
+ id: string;
33
+ }, versionIds: string[]): Promise<(RegulationProcedure & {
34
+ files: number;
35
+ })[]>;
36
+ /** The version adopted before this one, whose articles it is told against. */
37
+ export declare function previousAdopted(tx: EntityManager, version: RegulationVersion): Promise<RegulationVersion | null>;
38
+ /** Puts a version up for adoption - or adopts it at once where the domain names no approver (decision 5). */
39
+ export declare function submitRegulationVersion(id: string, context: ResolverContext): Promise<RegulationVersion>;
40
+ /** Takes back a version in approval - it is being written again. */
41
+ export declare function withdrawRegulationVersion(id: string, context: ResolverContext): Promise<RegulationVersion>;
42
+ /**
43
+ * What an approver's decision does to the version - worklist calls it on every state change of the instance; a decision
44
+ * lands only on the version still waiting on that very instance. Rejected or withdrawn, it is written again.
45
+ */
46
+ export declare function decideRegulationVersion(instance: {
47
+ id: string;
48
+ state: any;
49
+ input?: any;
50
+ }, causedBy: readonly {
51
+ state?: any;
52
+ }[], context: ResolverContext): Promise<any>;
53
+ /** The announcement of each version, by version - drafts too, the keeper reads whether it went out. */
54
+ export declare function announcementsOfVersions(tx: EntityManager, domain: {
55
+ id: string;
56
+ }, versionIds: string[]): Promise<Map<string, import("@things-factory/announcement").Announcement>>;
57
+ /** Every regulation of a kind whose version in force has no filing - a work rule must be filed (근로기준법 §93). */
58
+ export declare function regulationsWithoutFiling(manager: EntityManager, domain: {
59
+ id: string;
60
+ }, today: string): Promise<{
61
+ regulation: Regulation;
62
+ version: RegulationVersion;
63
+ }[]>;
@@ -0,0 +1,365 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.REGULATION_ADOPTED_TRIGGER = exports.REGULATION_HELP_SOURCE = exports.REGULATION_PROCEDURE_REF_TYPE = void 0;
4
+ exports.versionOf = versionOf;
5
+ exports.createRegulation = createRegulation;
6
+ exports.updateRegulation = updateRegulation;
7
+ exports.deleteRegulations = deleteRegulations;
8
+ exports.newRegulationVersion = newRegulationVersion;
9
+ exports.updateRegulationVersion = updateRegulationVersion;
10
+ exports.deleteRegulationVersion = deleteRegulationVersion;
11
+ exports.recordRegulationProcedure = recordRegulationProcedure;
12
+ exports.deleteRegulationProcedure = deleteRegulationProcedure;
13
+ exports.proceduresOf = proceduresOf;
14
+ exports.previousAdopted = previousAdopted;
15
+ exports.submitRegulationVersion = submitRegulationVersion;
16
+ exports.withdrawRegulationVersion = withdrawRegulationVersion;
17
+ exports.decideRegulationVersion = decideRegulationVersion;
18
+ exports.announcementsOfVersions = announcementsOfVersions;
19
+ exports.regulationsWithoutFiling = regulationsWithoutFiling;
20
+ const typeorm_1 = require("typeorm");
21
+ const accounting_1 = require("@things-factory/accounting");
22
+ const announcement_1 = require("@things-factory/announcement");
23
+ const attachment_base_1 = require("@things-factory/attachment-base");
24
+ const help_1 = require("@things-factory/help");
25
+ const shell_1 = require("@things-factory/shell");
26
+ const worklist_1 = require("@things-factory/worklist");
27
+ const regulation_activity_names_1 = require("../../activities/regulation-activity-names");
28
+ const employee_reader_1 = require("../common/employee-reader");
29
+ const regulation_1 = require("./regulation");
30
+ const regulation_rules_1 = require("./regulation-rules");
31
+ /*
32
+ * Writing a company rule and adopting its versions (ADR-0187 decisions 2-6). The one way a version is adopted: through
33
+ * the work door `Compliance Regulation Adopt` - raised for approval where the domain names approvers, adopted at once
34
+ * and written down where it names none. Adopting cuts its articles, tells the employees through the announcement of
35
+ * the trigger `compliance.regulation-adopted`, and has the help index the articles again.
36
+ */
37
+ /** The papers of a procedure hang on it under this `refType` (attachment-base). */
38
+ exports.REGULATION_PROCEDURE_REF_TYPE = 'RegulationProcedure';
39
+ /** The help source of the articles (ADR-0187 decision 12). */
40
+ exports.REGULATION_HELP_SOURCE = 'regulation';
41
+ /** The announcement trigger of an adoption (ADR-0187 decision 6). */
42
+ exports.REGULATION_ADOPTED_TRIGGER = 'compliance.regulation-adopted';
43
+ const text = (value) => (typeof value === 'string' && value.trim() ? value.trim() : null);
44
+ const NOT_FOUND = () => new shell_1.Refusal('regulation-not-found', {}, 'the rule was not found. reload and try again.');
45
+ async function regulationOf(tx, domain, id) {
46
+ const row = await tx.getRepository(regulation_1.Regulation).findOne({ where: { id, domain: { id: domain.id } } });
47
+ if (!row)
48
+ throw NOT_FOUND();
49
+ return row;
50
+ }
51
+ async function versionOf(tx, domain, id) {
52
+ const row = await tx.getRepository(regulation_1.RegulationVersion).findOne({ where: { id, domain: { id: domain.id } }, relations: ['regulation'] });
53
+ if (!row)
54
+ throw NOT_FOUND();
55
+ return row;
56
+ }
57
+ /** A new rule, with its first version to write. */
58
+ async function createRegulation(input, context) {
59
+ const { domain, user, tx } = context.state;
60
+ const refusal = (0, regulation_rules_1.regulationRefusal)(input);
61
+ if (refusal)
62
+ throw refusal;
63
+ const code = input.code.trim();
64
+ if (await tx.getRepository(regulation_1.Regulation).findOne({ where: { domain: { id: domain.id }, code } }))
65
+ throw new shell_1.Refusal('regulation-code-taken', { code }, `the code ${code} is taken - give another`);
66
+ const regulation = await tx.getRepository(regulation_1.Regulation).save({
67
+ domain,
68
+ code,
69
+ name: input.name.trim(),
70
+ kind: input.kind,
71
+ topics: [...new Set((input.topics ?? []).map(one => one.trim()).filter(Boolean))],
72
+ rank: input.rank ?? 0,
73
+ creator: user,
74
+ updater: user
75
+ });
76
+ await tx.getRepository(regulation_1.RegulationVersion).save({ domain, regulation, version: 1, body: input.body ?? null, status: regulation_1.RegulationVersionStatus.DRAFT, creator: user, updater: user });
77
+ return regulation;
78
+ }
79
+ /** The name, topics and place of a rule; its kind only while none of its versions is adopted. */
80
+ async function updateRegulation(id, patch, context) {
81
+ const { domain, user, tx } = context.state;
82
+ const regulation = await regulationOf(tx, domain, id);
83
+ if (patch.kind !== undefined && patch.kind !== regulation.kind) {
84
+ const adopted = await tx.getRepository(regulation_1.RegulationVersion).count({ where: { regulation: { id }, status: (0, typeorm_1.In)([regulation_1.RegulationVersionStatus.ADOPTED, regulation_1.RegulationVersionStatus.IN_APPROVAL]) } });
85
+ if (adopted)
86
+ throw new shell_1.Refusal('regulation-kind-fixed', {}, 'the kind of a rule with an adopted version stays - its procedure was taken for it');
87
+ }
88
+ const refusal = (0, regulation_rules_1.regulationRefusal)({ code: regulation.code, name: patch.name ?? regulation.name, kind: patch.kind ?? regulation.kind });
89
+ if (refusal)
90
+ throw refusal;
91
+ if (patch.name !== undefined)
92
+ regulation.name = patch.name.trim();
93
+ if (patch.kind !== undefined)
94
+ regulation.kind = patch.kind;
95
+ if (patch.topics !== undefined)
96
+ regulation.topics = [...new Set((patch.topics ?? []).map(one => one.trim()).filter(Boolean))];
97
+ if (patch.rank !== undefined)
98
+ regulation.rank = patch.rank ?? 0;
99
+ regulation.updater = user;
100
+ const saved = await tx.getRepository(regulation_1.Regulation).save(regulation);
101
+ (0, help_1.invalidateHelpSource)(exports.REGULATION_HELP_SOURCE, domain.id);
102
+ return saved;
103
+ }
104
+ /** A rule with no adopted version is deleted with its drafts; one adopted once is kept - its employees were told of it. */
105
+ async function deleteRegulations(ids, context) {
106
+ const { domain, tx } = context.state;
107
+ for (const id of ids) {
108
+ const regulation = await tx.getRepository(regulation_1.Regulation).findOne({ where: { id, domain: { id: domain.id } } });
109
+ if (!regulation)
110
+ continue;
111
+ const kept = await tx.getRepository(regulation_1.RegulationVersion).count({ where: { regulation: { id }, status: (0, typeorm_1.In)([regulation_1.RegulationVersionStatus.ADOPTED, regulation_1.RegulationVersionStatus.IN_APPROVAL]) } });
112
+ if (kept)
113
+ throw new shell_1.Refusal('regulation-adopted-kept', { name: regulation.name }, `${regulation.name} has a version adopted or in approval - a rule its employees were told of is kept`);
114
+ await tx.getRepository(regulation_1.Regulation).delete(regulation.id);
115
+ }
116
+ return true;
117
+ }
118
+ /** The next version to write, its text the latest version's. One is written at a time. */
119
+ async function newRegulationVersion(regulationId, context) {
120
+ const { domain, user, tx } = context.state;
121
+ const regulation = await regulationOf(tx, domain, regulationId);
122
+ const versions = await tx.getRepository(regulation_1.RegulationVersion).find({ where: { regulation: { id: regulationId } }, order: { version: 'DESC' } });
123
+ if (versions.some(one => one.status !== regulation_1.RegulationVersionStatus.ADOPTED))
124
+ throw new shell_1.Refusal('regulation-version-open', { name: regulation.name }, `${regulation.name} has a version being written or in approval - finish it first`);
125
+ return await tx.getRepository(regulation_1.RegulationVersion).save({
126
+ domain,
127
+ regulation,
128
+ version: (versions[0]?.version ?? 0) + 1,
129
+ body: versions[0]?.body ?? null,
130
+ status: regulation_1.RegulationVersionStatus.DRAFT,
131
+ creator: user,
132
+ updater: user
133
+ });
134
+ }
135
+ /** The text, day, summary, whether it is against the workers and how many workers - of a version being written. */
136
+ async function updateRegulationVersion(id, patch, context) {
137
+ const { domain, user, tx } = context.state;
138
+ const version = await versionOf(tx, domain, id);
139
+ const refusal = (0, regulation_rules_1.changeRefusal)(version.status);
140
+ if (refusal)
141
+ throw refusal;
142
+ if (patch.body !== undefined)
143
+ version.body = patch.body ?? null;
144
+ if (patch.effectiveOn !== undefined)
145
+ version.effectiveOn = text(patch.effectiveOn);
146
+ if (patch.changeSummary !== undefined)
147
+ version.changeSummary = text(patch.changeSummary);
148
+ if (patch.unfavourable !== undefined)
149
+ version.unfavourable = patch.unfavourable;
150
+ if (patch.workersCount !== undefined)
151
+ version.workersCount = patch.workersCount ?? null;
152
+ version.updater = user;
153
+ return await tx.getRepository(regulation_1.RegulationVersion).save(version);
154
+ }
155
+ /** A version being written is deleted; one put up or adopted is kept. */
156
+ async function deleteRegulationVersion(id, context) {
157
+ const { domain, tx } = context.state;
158
+ const version = await versionOf(tx, domain, id);
159
+ if (version.status !== regulation_1.RegulationVersionStatus.DRAFT)
160
+ throw new shell_1.Refusal('regulation-version-kept', {}, 'a version put up or adopted is kept');
161
+ await tx.getRepository(regulation_1.RegulationVersion).delete(version.id);
162
+ return true;
163
+ }
164
+ /** Records an opinion heard, a consent or a filing, with its papers. */
165
+ async function recordRegulationProcedure(input, files, context) {
166
+ const { domain, user, tx } = context.state;
167
+ const version = await versionOf(tx, domain, input.versionId);
168
+ const refusal = (0, regulation_rules_1.procedureWriteRefusal)(version.status, input.kind) ?? (0, regulation_rules_1.procedureRefusal)(input);
169
+ if (refusal)
170
+ throw refusal;
171
+ if (input.kind === regulation_1.RegulationProcedureKind.FILING && !files?.length)
172
+ throw new shell_1.Refusal('regulation-filing-paper-required', {}, 'attach the filing or its receipt');
173
+ const saved = await tx.getRepository(regulation_1.RegulationProcedure).save({
174
+ domain,
175
+ version,
176
+ kind: input.kind,
177
+ day: input.day,
178
+ method: text(input.method),
179
+ workersCount: input.workersCount ?? null,
180
+ consentCount: input.kind === regulation_1.RegulationProcedureKind.CONSENT ? input.consentCount : null,
181
+ notes: text(input.notes),
182
+ creator: user
183
+ });
184
+ for (const file of files ?? [])
185
+ await (0, attachment_base_1.createAttachment)(null, { attachment: { file, refType: exports.REGULATION_PROCEDURE_REF_TYPE, refBy: saved.id } }, context);
186
+ return saved;
187
+ }
188
+ /** A procedure of a version being written is taken off; once put up it is the evidence and stays. */
189
+ async function deleteRegulationProcedure(id, context) {
190
+ const { domain, tx } = context.state;
191
+ const row = await tx.getRepository(regulation_1.RegulationProcedure).findOne({ where: { id, domain: { id: domain.id } } });
192
+ if (!row)
193
+ return true;
194
+ const version = await versionOf(tx, domain, row.versionId);
195
+ if (version.status !== regulation_1.RegulationVersionStatus.DRAFT)
196
+ throw new shell_1.Refusal('regulation-procedure-fixed', {}, 'the procedure of a version put up or adopted stays as it was');
197
+ const files = await tx.getRepository(attachment_base_1.Attachment).find({ where: { domain: { id: domain.id }, refType: exports.REGULATION_PROCEDURE_REF_TYPE, refBy: id } });
198
+ if (files.length)
199
+ await tx.getRepository(attachment_base_1.Attachment).delete(files.map(one => one.id));
200
+ await tx.getRepository(regulation_1.RegulationProcedure).delete(id);
201
+ return true;
202
+ }
203
+ /** The procedures of versions, each with how many papers it carries. */
204
+ async function proceduresOf(tx, domain, versionIds) {
205
+ if (!versionIds.length)
206
+ return [];
207
+ const rows = await tx.getRepository(regulation_1.RegulationProcedure).find({ where: { domain: { id: domain.id }, version: { id: (0, typeorm_1.In)(versionIds) } }, order: { day: 'ASC' } });
208
+ const files = rows.length ? await tx.getRepository(attachment_base_1.Attachment).find({ where: { domain: { id: domain.id }, refType: exports.REGULATION_PROCEDURE_REF_TYPE, refBy: (0, typeorm_1.In)(rows.map(one => one.id)) } }) : [];
209
+ return rows.map(one => Object.assign(one, { files: files.filter(file => file.refBy === one.id).length }));
210
+ }
211
+ /** The version adopted before this one, whose articles it is told against. */
212
+ async function previousAdopted(tx, version) {
213
+ const adopted = await tx.getRepository(regulation_1.RegulationVersion).find({ where: { regulation: { id: version.regulationId }, status: regulation_1.RegulationVersionStatus.ADOPTED }, order: { version: 'DESC' } });
214
+ return adopted.find(one => one.version < version.version) ?? null;
215
+ }
216
+ /** Puts a version up for adoption - or adopts it at once where the domain names no approver (decision 5). */
217
+ async function submitRegulationVersion(id, context) {
218
+ const { domain, user, tx } = context.state;
219
+ const version = await versionOf(tx, domain, id);
220
+ if (version.status !== regulation_1.RegulationVersionStatus.DRAFT)
221
+ throw new shell_1.Refusal('regulation-not-draft', {}, 'only a version being written is put up');
222
+ const regulation = version.regulation;
223
+ const procedures = await proceduresOf(tx, domain, [version.id]);
224
+ const refusal = (0, regulation_rules_1.adoptionRefusal)({ kind: regulation.kind, body: version.body, effectiveOn: version.effectiveOn, unfavourable: version.unfavourable }, procedures, (0, employee_reader_1.todayIn)(domain));
225
+ if (refusal)
226
+ throw refusal;
227
+ const door = (0, worklist_1.declaredDoor)(regulation_activity_names_1.REGULATION_ADOPT_ACTIVITY);
228
+ const carrier = await (0, worklist_1.activityNamed)(regulation_activity_names_1.REGULATION_ADOPT_ACTIVITY, context);
229
+ const notUsed = !!(await tx.getRepository(worklist_1.WorkDoorNotUsed).findOne({ where: { domain: { id: domain.id }, doorName: regulation_activity_names_1.REGULATION_ADOPT_ACTIVITY } }));
230
+ const verdict = await (0, worklist_1.passWorkDoor)({ door, activity: carrier, subject: { kind: 'RegulationVersion', id: version.id }, notUsed }, { tx, domain, user, seats: (0, worklist_1.seatReader)(tx) });
231
+ if (verdict.go === 'refuse')
232
+ throw verdict.refusal;
233
+ if (verdict.go === 'run')
234
+ return await adopt(version, context);
235
+ if (!carrier)
236
+ throw new shell_1.Refusal('regulation-approval-not-installed', { form: regulation_activity_names_1.REGULATION_ADOPT_ACTIVITY }, `the approval '${regulation_activity_names_1.REGULATION_ADOPT_ACTIVITY}' is not installed in this domain`);
237
+ const before = await previousAdopted(tx, version);
238
+ const changes = (0, regulation_rules_1.clauseChanges)(before ? (0, regulation_rules_1.clausesOf)(before.body) : [], (0, regulation_rules_1.clausesOf)(version.body));
239
+ const words = { ADDED: '신설', CHANGED: '개정', REMOVED: '삭제' };
240
+ version.status = regulation_1.RegulationVersionStatus.IN_APPROVAL;
241
+ version.adoptionNote = null;
242
+ version.updater = user;
243
+ const saved = await tx.getRepository(regulation_1.RegulationVersion).save(version);
244
+ const headline = `${regulation.name} 제${version.version}판 · 시행 ${version.effectiveOn}`;
245
+ const instance = await (0, worklist_1.issue)({
246
+ name: headline,
247
+ description: version.changeSummary ?? '',
248
+ activityId: carrier.id,
249
+ approvalLine: carrier.approvalLine,
250
+ input: {
251
+ versionId: saved.id,
252
+ regulation: regulation.name,
253
+ requester: user.name ?? '',
254
+ sourceHref: `regulation-detail?id=${regulation.id}&version=${saved.id}`,
255
+ headline,
256
+ reason: [
257
+ ...(version.changeSummary ? [`바뀐 곳: ${version.changeSummary}`] : []),
258
+ ...(changes.length ? [`조문: ${changes.map(one => `제${one.number}조 ${words[one.change]}`).join(', ')}`] : []),
259
+ `불리한 변경: ${version.unfavourable ? '예' : '아니오'}`,
260
+ ...procedures.map(one => `${{ OPINION: '의견 청취', CONSENT: '동의', FILING: '신고' }[one.kind]} ${one.day}${one.kind === 'CONSENT' ? ` · ${one.consentCount}/${one.workersCount}` : ''} · 첨부 ${one.files}`)
261
+ ],
262
+ consequence: `승인하면 ${regulation.name} 제${version.version}판이 채택되어 ${version.effectiveOn}부터 시행됩니다`
263
+ },
264
+ threadsMin: 1,
265
+ threadsMax: 1,
266
+ requireApproval: true
267
+ }, context);
268
+ saved.activityInstanceId = instance.id;
269
+ return await tx.getRepository(regulation_1.RegulationVersion).save(saved);
270
+ }
271
+ /** Takes back a version in approval - it is being written again. */
272
+ async function withdrawRegulationVersion(id, context) {
273
+ const { domain, user, tx } = context.state;
274
+ const version = await versionOf(tx, domain, id);
275
+ if (version.status !== regulation_1.RegulationVersionStatus.IN_APPROVAL)
276
+ throw new shell_1.Refusal('regulation-not-in-approval', {}, 'only a version in approval is taken back');
277
+ if (version.activityInstanceId)
278
+ await (0, worklist_1.abort)({ id: version.activityInstanceId, reason: '올린 사람이 회수함' }, context);
279
+ version.status = regulation_1.RegulationVersionStatus.DRAFT;
280
+ version.activityInstanceId = null;
281
+ version.updater = user;
282
+ return await tx.getRepository(regulation_1.RegulationVersion).save(version);
283
+ }
284
+ /**
285
+ * What an approver's decision does to the version - worklist calls it on every state change of the instance; a decision
286
+ * lands only on the version still waiting on that very instance. Rejected or withdrawn, it is written again.
287
+ */
288
+ async function decideRegulationVersion(instance, causedBy, context) {
289
+ const { domain, tx } = context.state;
290
+ const id = instance.input?.versionId;
291
+ if (!id)
292
+ return;
293
+ const version = await tx.getRepository(regulation_1.RegulationVersion).findOne({ where: { id, domain: { id: domain.id } }, relations: ['regulation'] });
294
+ if (!version)
295
+ return;
296
+ const decision = (0, accounting_1.decisionOf)({ id: instance.id, state: String(instance.state) }, causedBy.map(one => ({ state: String(one.state) })), { status: version.status === regulation_1.RegulationVersionStatus.IN_APPROVAL ? 'SUBMITTED' : version.status, activityInstanceId: version.activityInstanceId });
297
+ if (!decision)
298
+ return;
299
+ if (decision === 'APPROVED')
300
+ return void (await adopt(version, context));
301
+ version.status = regulation_1.RegulationVersionStatus.DRAFT;
302
+ version.activityInstanceId = null;
303
+ await tx.getRepository(regulation_1.RegulationVersion).save(version);
304
+ }
305
+ /**
306
+ * Adopts a version: its effective day must not have passed by the day it is decided - an approval that ended late leaves
307
+ * it to be put up again with a new day. Its articles are cut and kept, the employees are told, the help indexes again.
308
+ */
309
+ async function adopt(version, context) {
310
+ const { domain, user, tx } = context.state;
311
+ const today = (0, employee_reader_1.todayIn)(domain);
312
+ if (!version.effectiveOn || version.effectiveOn < today) {
313
+ version.status = regulation_1.RegulationVersionStatus.DRAFT;
314
+ version.activityInstanceId = null;
315
+ version.adoptionNote = `시행일 ${version.effectiveOn ?? ''}이(가) 결재가 끝난 ${today}보다 앞서 채택되지 않았습니다 — 시행일을 고쳐 다시 올리세요`;
316
+ return await tx.getRepository(regulation_1.RegulationVersion).save(version);
317
+ }
318
+ version.status = regulation_1.RegulationVersionStatus.ADOPTED;
319
+ version.adoptedAt = new Date();
320
+ version.adoptedBy = user;
321
+ version.adoptionNote = null;
322
+ const saved = await tx.getRepository(regulation_1.RegulationVersion).save(version);
323
+ const clauses = (0, regulation_rules_1.clausesOf)(saved.body);
324
+ await tx.getRepository(regulation_1.RegulationClause).delete({ version: { id: saved.id } });
325
+ for (const [rank, one] of clauses.entries())
326
+ await tx.getRepository(regulation_1.RegulationClause).save({ domain, version: saved, rank, ...one });
327
+ const regulation = version.regulation;
328
+ const announcement = await (0, announcement_1.announce)(context, {
329
+ trigger: exports.REGULATION_ADOPTED_TRIGGER,
330
+ sourceKind: 'RegulationVersion',
331
+ sourceId: saved.id,
332
+ title: `${regulation.name} 제${saved.version}판 시행 안내 (${saved.effectiveOn})`,
333
+ body: [`**${regulation.name}** 제${saved.version}판이 채택되어 **${saved.effectiveOn}**부터 시행됩니다.`, saved.changeSummary ? `\n바뀐 곳: ${saved.changeSummary}` : ''].join(''),
334
+ links: [{ label: regulation.name, url: `regulations?regulation=${encodeURIComponent(regulation.code)}&version=${saved.id}` }]
335
+ });
336
+ if (announcement) {
337
+ saved.announcementId = announcement.id;
338
+ await tx.getRepository(regulation_1.RegulationVersion).save(saved);
339
+ }
340
+ (0, help_1.invalidateHelpSource)(exports.REGULATION_HELP_SOURCE, domain.id);
341
+ return saved;
342
+ }
343
+ /** The announcement of each version, by version - drafts too, the keeper reads whether it went out. */
344
+ async function announcementsOfVersions(tx, domain, versionIds) {
345
+ const rows = await (0, announcement_1.announcementsOfSource)(domain, 'RegulationVersion', versionIds, tx);
346
+ return new Map(rows.map(one => [one.sourceId, one]));
347
+ }
348
+ /** Every regulation of a kind whose version in force has no filing - a work rule must be filed (근로기준법 §93). */
349
+ async function regulationsWithoutFiling(manager, domain, today) {
350
+ const regulations = await manager.getRepository(regulation_1.Regulation).find({ where: { domain: { id: domain.id }, kind: (0, typeorm_1.In)([regulation_1.RegulationKind.WORK_RULES, regulation_1.RegulationKind.WORK_RULES_ANNEX]) } });
351
+ if (!regulations.length)
352
+ return [];
353
+ const versions = await manager.getRepository(regulation_1.RegulationVersion).find({ where: { regulation: { id: (0, typeorm_1.In)(regulations.map(one => one.id)) }, status: regulation_1.RegulationVersionStatus.ADOPTED } });
354
+ const out = [];
355
+ for (const regulation of regulations) {
356
+ const { inForce } = (0, regulation_rules_1.standingOf)(versions.filter(one => one.regulationId === regulation.id), today);
357
+ if (!inForce)
358
+ continue;
359
+ const filed = await manager.getRepository(regulation_1.RegulationProcedure).count({ where: { version: { id: inForce.id }, kind: regulation_1.RegulationProcedureKind.FILING } });
360
+ if (!filed)
361
+ out.push({ regulation, version: inForce });
362
+ }
363
+ return out;
364
+ }
365
+ //# sourceMappingURL=regulation-service.js.map