@icure/form 2.0.11 → 2.1.1

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 (284) hide show
  1. package/.yarn/cache/@babel-runtime-npm-7.28.6-f40c99aeef-42d8a868c2.zip +0 -0
  2. package/.yarn/cache/@icure-api-npm-5.3.18-99d397b97c-0da319f009.zip +0 -0
  3. package/.yarn/cache/@icure-motss-app-datepicker-npm-6.0.0-rc.40-ca1da7abbb-9bbe2bed34.zip +0 -0
  4. package/.yarn/cache/@lit-labs-ssr-dom-shim-npm-1.5.1-3b3c832bd1-22c404c481.zip +0 -0
  5. package/.yarn/cache/@lit-reactive-element-npm-1.6.3-4828441e51-79b58631c3.zip +0 -0
  6. package/.yarn/cache/@lit-reactive-element-npm-2.1.2-2c713bebce-e0ed931b9c.zip +0 -0
  7. package/.yarn/cache/@lit-task-npm-1.0.3-48f265b3e9-790b6a2603.zip +0 -0
  8. package/.yarn/cache/@material-animation-npm-14.0.0-canary.53b3cad2f.0-06a813cdea-9b5190654c.zip +0 -0
  9. package/.yarn/cache/@material-base-npm-14.0.0-canary.53b3cad2f.0-d195c1fdc4-9f4928d115.zip +0 -0
  10. package/.yarn/cache/@material-button-npm-14.0.0-canary.53b3cad2f.0-d4b070f508-873295c56a.zip +0 -0
  11. package/.yarn/cache/@material-density-npm-14.0.0-canary.53b3cad2f.0-48c1f65059-a23f00edfe.zip +0 -0
  12. package/.yarn/cache/@material-dialog-npm-14.0.0-canary.53b3cad2f.0-96168fa294-c1a498b81a.zip +0 -0
  13. package/.yarn/cache/@material-dom-npm-14.0.0-canary.53b3cad2f.0-ac009dc871-f5817f76dd.zip +0 -0
  14. package/.yarn/cache/@material-elevation-npm-14.0.0-canary.53b3cad2f.0-3312f06793-2f8945c7b6.zip +0 -0
  15. package/.yarn/cache/@material-feature-targeting-npm-14.0.0-canary.53b3cad2f.0-a919042d50-e7a1ed68f9.zip +0 -0
  16. package/.yarn/cache/@material-floating-label-npm-14.0.0-canary.53b3cad2f.0-eb8f330f2f-5295dc481d.zip +0 -0
  17. package/.yarn/cache/@material-focus-ring-npm-14.0.0-canary.53b3cad2f.0-b22f851a2e-92273b1247.zip +0 -0
  18. package/.yarn/cache/@material-icon-button-npm-14.0.0-canary.53b3cad2f.0-e158d26048-19b51665f2.zip +0 -0
  19. package/.yarn/cache/@material-line-ripple-npm-14.0.0-canary.53b3cad2f.0-d089468db9-6518961487.zip +0 -0
  20. package/.yarn/cache/@material-list-npm-14.0.0-canary.53b3cad2f.0-df9ce05084-6c977f518d.zip +0 -0
  21. package/.yarn/cache/@material-menu-npm-14.0.0-canary.53b3cad2f.0-9489b592c8-71b6a1f4dd.zip +0 -0
  22. package/.yarn/cache/@material-menu-surface-npm-14.0.0-canary.53b3cad2f.0-52212f38f4-ad48e168ca.zip +0 -0
  23. package/.yarn/cache/@material-mwc-base-npm-0.27.0-79caf3ef2b-07af17edfc.zip +0 -0
  24. package/.yarn/cache/@material-mwc-button-npm-0.27.0-4b85f2b26f-2ef5cc0951.zip +0 -0
  25. package/.yarn/cache/@material-mwc-checkbox-npm-0.27.0-e837031d8e-ba53a6ea8c.zip +0 -0
  26. package/.yarn/cache/@material-mwc-dialog-npm-0.27.0-77c6071543-ffab528e8e.zip +0 -0
  27. package/.yarn/cache/@material-mwc-floating-label-npm-0.27.0-80e62b22c0-fbbf4f2e42.zip +0 -0
  28. package/.yarn/cache/@material-mwc-icon-button-npm-0.27.0-41f82f135b-7315c0735b.zip +0 -0
  29. package/.yarn/cache/@material-mwc-icon-npm-0.27.0-98c9e8509f-6dfa5115d5.zip +0 -0
  30. package/.yarn/cache/@material-mwc-line-ripple-npm-0.27.0-e6704221e0-6862ede0f4.zip +0 -0
  31. package/.yarn/cache/@material-mwc-list-npm-0.27.0-5344fc9de4-6c2ae4f1c6.zip +0 -0
  32. package/.yarn/cache/@material-mwc-menu-npm-0.27.0-7c2bb47797-126f733659.zip +0 -0
  33. package/.yarn/cache/@material-mwc-notched-outline-npm-0.27.0-0e0d1c4d5f-2739032f76.zip +0 -0
  34. package/.yarn/cache/@material-mwc-radio-npm-0.27.0-aa2098a280-0b0a0a6b99.zip +0 -0
  35. package/.yarn/cache/@material-mwc-ripple-npm-0.27.0-ed37672f08-9cd73fdfe4.zip +0 -0
  36. package/.yarn/cache/@material-mwc-textfield-npm-0.27.0-dabd704f55-978c893aca.zip +0 -0
  37. package/.yarn/cache/@material-notched-outline-npm-14.0.0-canary.53b3cad2f.0-ecacde98db-1a9f8db4d8.zip +0 -0
  38. package/.yarn/cache/@material-radio-npm-14.0.0-canary.53b3cad2f.0-c50de64d41-898554f2b3.zip +0 -0
  39. package/.yarn/cache/@material-ripple-npm-14.0.0-canary.53b3cad2f.0-49060bfe7e-08b71917e2.zip +0 -0
  40. package/.yarn/cache/@material-rtl-npm-14.0.0-canary.53b3cad2f.0-daca794b76-3c1b8b48c6.zip +0 -0
  41. package/.yarn/cache/@material-shape-npm-14.0.0-canary.53b3cad2f.0-5bcff722a6-6ad9b020c0.zip +0 -0
  42. package/.yarn/cache/@material-textfield-npm-14.0.0-canary.53b3cad2f.0-4414808dda-7072e3c9df.zip +0 -0
  43. package/.yarn/cache/@material-theme-npm-14.0.0-canary.53b3cad2f.0-9a24e7b046-fd44e92917.zip +0 -0
  44. package/.yarn/cache/@material-tokens-npm-14.0.0-canary.53b3cad2f.0-f1c87523da-efa909f861.zip +0 -0
  45. package/.yarn/cache/@material-touch-target-npm-14.0.0-canary.53b3cad2f.0-fa6a2d0875-dbc13cbe7a.zip +0 -0
  46. package/.yarn/cache/@material-typography-npm-14.0.0-canary.53b3cad2f.0-f4a58946f1-fa2671df40.zip +0 -0
  47. package/.yarn/cache/@types-linkify-it-npm-5.0.0-576a16b976-ec98e03aa8.zip +0 -0
  48. package/.yarn/cache/@types-markdown-it-npm-14.1.2-d0c4e12c49-ad66e0b377.zip +0 -0
  49. package/.yarn/cache/@types-mdurl-npm-2.0.0-2f4116c0b0-78746e96c6.zip +0 -0
  50. package/.yarn/cache/@types-trusted-types-npm-2.0.7-a07fc44f59-8e4202766a.zip +0 -0
  51. package/.yarn/cache/@webcomponents-webcomponentsjs-npm-2.8.0-36c07db4d2-186373c030.zip +0 -0
  52. package/.yarn/cache/argparse-npm-2.0.1-faff7999e6-83644b5649.zip +0 -0
  53. package/.yarn/cache/big-integer-npm-1.6.52-4bec75720c-6e86885787.zip +0 -0
  54. package/.yarn/cache/blocking-elements-npm-0.1.1-423f51c76e-9a34084405.zip +0 -0
  55. package/.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip +0 -0
  56. package/.yarn/cache/entities-npm-4.5.0-7cdb83b832-853f8ebd5b.zip +0 -0
  57. package/.yarn/cache/fast-deep-equal-npm-3.1.3-790edcfcf5-e21a9d8d84.zip +0 -0
  58. package/.yarn/cache/libphonenumber-js-npm-1.12.36-92f3728071-f39b5ed57b.zip +0 -0
  59. package/.yarn/cache/linkify-it-npm-5.0.0-adb5f9c96f-b0b86cadaf.zip +0 -0
  60. package/.yarn/cache/lit-element-npm-3.3.3-2f9f9e38c0-29a596fa55.zip +0 -0
  61. package/.yarn/cache/lit-element-npm-4.2.2-70d4af2233-554254b87c.zip +0 -0
  62. package/.yarn/cache/lit-html-npm-2.8.0-82f88d6ebf-2d70df0724.zip +0 -0
  63. package/.yarn/cache/lit-html-npm-3.3.2-4a3e00215f-7fe23502ca.zip +0 -0
  64. package/.yarn/cache/lit-npm-2.8.0-92bb1333a4-2480e733f7.zip +0 -0
  65. package/.yarn/cache/lit-npm-3.3.2-7dea58471e-2136d4beac.zip +0 -0
  66. package/.yarn/cache/lodash-npm-4.17.23-50bdb1c01a-7daad39758.zip +0 -0
  67. package/.yarn/cache/markdown-it-npm-14.1.0-e337d75bfe-07296b45eb.zip +0 -0
  68. package/.yarn/cache/mdurl-npm-2.0.0-3259713daf-880bc289ef.zip +0 -0
  69. package/.yarn/cache/moment-npm-2.30.1-1c51a5c631-859236bab1.zip +0 -0
  70. package/.yarn/cache/orderedmap-npm-2.1.1-64b8a0684f-082cf970b0.zip +0 -0
  71. package/.yarn/cache/prosemirror-commands-npm-1.7.1-5b2afb6640-2316c40ea2.zip +0 -0
  72. package/.yarn/cache/prosemirror-history-npm-1.5.0-e639d02880-6afb0e1d17.zip +0 -0
  73. package/.yarn/cache/prosemirror-keymap-npm-1.2.3-0e7e0c8195-0a2eed2771.zip +0 -0
  74. package/.yarn/cache/prosemirror-markdown-npm-1.13.4-1a47b172bd-3306b4eca0.zip +0 -0
  75. package/.yarn/cache/prosemirror-model-npm-1.25.4-e7ee2df3df-ab5aa609df.zip +0 -0
  76. package/.yarn/cache/prosemirror-schema-basic-npm-1.2.4-8f943ded01-10ed022990.zip +0 -0
  77. package/.yarn/cache/prosemirror-schema-list-npm-1.5.1-7b138c5fed-6c7041e5b8.zip +0 -0
  78. package/.yarn/cache/prosemirror-state-npm-1.4.4-8b7e3a396c-1b5dba46c2.zip +0 -0
  79. package/.yarn/cache/prosemirror-transform-npm-1.11.0-fa260ad6f3-71989931b8.zip +0 -0
  80. package/.yarn/cache/prosemirror-view-npm-1.41.6-a9d2feed27-68f6a8bd66.zip +0 -0
  81. package/.yarn/cache/punycode.js-npm-2.3.1-9084ecbbf5-13466d7ed5.zip +0 -0
  82. package/.yarn/cache/rope-sequence-npm-1.3.4-3b09587e5f-95cca2f99a.zip +0 -0
  83. package/.yarn/cache/text-encoding-npm-0.7.0-ff0c4af052-b6109a843f.zip +0 -0
  84. package/.yarn/cache/tslib-npm-2.8.1-66590b21b8-e4aba30e63.zip +0 -0
  85. package/.yarn/cache/uc.micro-npm-2.1.0-c45282c865-3719735824.zip +0 -0
  86. package/.yarn/cache/uuid-encoder-npm-1.2.0-6a9a810c6d-dd06230f08.zip +0 -0
  87. package/.yarn/cache/uuid-npm-8.3.2-eca0baba53-5575a8a75c.zip +0 -0
  88. package/.yarn/cache/uuid-npm-9.0.1-39a8442bc6-39931f6da7.zip +0 -0
  89. package/.yarn/cache/w3c-keyname-npm-2.2.8-66d7d5317a-95bafa4c04.zip +0 -0
  90. package/.yarn/cache/wicg-inert-npm-3.1.3-38590e83f2-45b3cfec63.zip +0 -0
  91. package/.yarn/install-state.gz +0 -0
  92. package/components/common/field-with-options.d.ts +2 -2
  93. package/components/common/field-with-options.js +8 -5
  94. package/components/common/field-with-options.js.map +1 -1
  95. package/components/common/field.d.ts +10 -3
  96. package/components/common/field.js +46 -21
  97. package/components/common/field.js.map +1 -1
  98. package/components/common/index.js +17 -1
  99. package/components/common/index.js.map +1 -1
  100. package/components/common/metadata-buttons-bar.d.ts +2 -1
  101. package/components/common/metadata-buttons-bar.js +113 -77
  102. package/components/common/metadata-buttons-bar.js.map +1 -1
  103. package/components/common/styles/paths.d.ts +1 -0
  104. package/components/common/styles/paths.js +41 -25
  105. package/components/common/styles/paths.js.map +1 -1
  106. package/components/common/utils.js +21 -11
  107. package/components/common/utils.js.map +1 -1
  108. package/components/icure-button/index.d.ts +1 -1
  109. package/components/icure-button/index.js +73 -29
  110. package/components/icure-button/index.js.map +1 -1
  111. package/components/icure-button-group/index.d.ts +5 -3
  112. package/components/icure-button-group/index.js +101 -61
  113. package/components/icure-button-group/index.js.map +1 -1
  114. package/components/icure-date-picker/index.d.ts +6 -3
  115. package/components/icure-date-picker/index.js +87 -43
  116. package/components/icure-date-picker/index.js.map +1 -1
  117. package/components/icure-dropdown-field/index.d.ts +5 -2
  118. package/components/icure-dropdown-field/index.js +82 -38
  119. package/components/icure-dropdown-field/index.js.map +1 -1
  120. package/components/icure-form/fields/button/button.js +17 -13
  121. package/components/icure-form/fields/button/button.js.map +1 -1
  122. package/components/icure-form/fields/button/index.js +17 -1
  123. package/components/icure-form/fields/button/index.js.map +1 -1
  124. package/components/icure-form/fields/button-group/checkbox.d.ts +2 -1
  125. package/components/icure-form/fields/button-group/checkbox.js +15 -11
  126. package/components/icure-form/fields/button-group/checkbox.js.map +1 -1
  127. package/components/icure-form/fields/button-group/index.js +18 -2
  128. package/components/icure-form/fields/button-group/index.js.map +1 -1
  129. package/components/icure-form/fields/button-group/radio-button.d.ts +2 -1
  130. package/components/icure-form/fields/button-group/radio-button.js +15 -11
  131. package/components/icure-form/fields/button-group/radio-button.js.map +1 -1
  132. package/components/icure-form/fields/date-picker/date-picker.d.ts +2 -1
  133. package/components/icure-form/fields/date-picker/date-picker.js +13 -9
  134. package/components/icure-form/fields/date-picker/date-picker.js.map +1 -1
  135. package/components/icure-form/fields/date-picker/date-time-picker.d.ts +2 -1
  136. package/components/icure-form/fields/date-picker/date-time-picker.js +13 -9
  137. package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -1
  138. package/components/icure-form/fields/date-picker/index.js +19 -3
  139. package/components/icure-form/fields/date-picker/index.js.map +1 -1
  140. package/components/icure-form/fields/date-picker/time-picker.d.ts +2 -1
  141. package/components/icure-form/fields/date-picker/time-picker.js +13 -9
  142. package/components/icure-form/fields/date-picker/time-picker.js.map +1 -1
  143. package/components/icure-form/fields/dropdown/dropdown-field.d.ts +1 -1
  144. package/components/icure-form/fields/dropdown/dropdown-field.js +15 -11
  145. package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -1
  146. package/components/icure-form/fields/dropdown/index.js +17 -1
  147. package/components/icure-form/fields/dropdown/index.js.map +1 -1
  148. package/components/icure-form/fields/index.js +26 -10
  149. package/components/icure-form/fields/index.js.map +1 -1
  150. package/components/icure-form/fields/items-list-field/index.js +17 -1
  151. package/components/icure-form/fields/items-list-field/index.js.map +1 -1
  152. package/components/icure-form/fields/items-list-field/items-list-field.d.ts +2 -1
  153. package/components/icure-form/fields/items-list-field/items-list-field.js +12 -8
  154. package/components/icure-form/fields/items-list-field/items-list-field.js.map +1 -1
  155. package/components/icure-form/fields/label/index.js +17 -1
  156. package/components/icure-form/fields/label/index.js.map +1 -1
  157. package/components/icure-form/fields/label/label.js +15 -11
  158. package/components/icure-form/fields/label/label.js.map +1 -1
  159. package/components/icure-form/fields/measure-field/index.js +17 -1
  160. package/components/icure-form/fields/measure-field/index.js.map +1 -1
  161. package/components/icure-form/fields/measure-field/measure-field.d.ts +2 -1
  162. package/components/icure-form/fields/measure-field/measure-field.js +14 -9
  163. package/components/icure-form/fields/measure-field/measure-field.js.map +1 -1
  164. package/components/icure-form/fields/number-field/index.js +17 -1
  165. package/components/icure-form/fields/number-field/index.js.map +1 -1
  166. package/components/icure-form/fields/number-field/number-field.d.ts +2 -1
  167. package/components/icure-form/fields/number-field/number-field.js +14 -9
  168. package/components/icure-form/fields/number-field/number-field.js.map +1 -1
  169. package/components/icure-form/fields/text-field/index.js +17 -1
  170. package/components/icure-form/fields/text-field/index.js.map +1 -1
  171. package/components/icure-form/fields/text-field/text-field.d.ts +2 -1
  172. package/components/icure-form/fields/text-field/text-field.js +26 -21
  173. package/components/icure-form/fields/text-field/text-field.js.map +1 -1
  174. package/components/icure-form/fields/token-field/index.js +17 -1
  175. package/components/icure-form/fields/token-field/index.js.map +1 -1
  176. package/components/icure-form/fields/token-field/token-field.d.ts +2 -1
  177. package/components/icure-form/fields/token-field/token-field.js +13 -9
  178. package/components/icure-form/fields/token-field/token-field.js.map +1 -1
  179. package/components/icure-form/fields/utils/index.js +13 -5
  180. package/components/icure-form/fields/utils/index.js.map +1 -1
  181. package/components/icure-form/index.d.ts +6 -2
  182. package/components/icure-form/index.js +138 -44
  183. package/components/icure-form/index.js.map +1 -1
  184. package/components/icure-form/renderer/form/form-selection-button.js +67 -27
  185. package/components/icure-form/renderer/form/form-selection-button.js.map +1 -1
  186. package/components/icure-form/renderer/form/form.js +264 -219
  187. package/components/icure-form/renderer/form/form.js.map +1 -1
  188. package/components/icure-form/renderer/index.d.ts +1 -1
  189. package/components/icure-form/renderer/index.js +2 -1
  190. package/components/icure-form/renderer/index.js.map +1 -1
  191. package/components/icure-label/index.js +70 -26
  192. package/components/icure-label/index.js.map +1 -1
  193. package/components/icure-text-field/index.d.ts +8 -2
  194. package/components/icure-text-field/index.js +309 -145
  195. package/components/icure-text-field/index.js.map +1 -1
  196. package/components/icure-text-field/plugin/caret-fix-plugin.js +7 -3
  197. package/components/icure-text-field/plugin/caret-fix-plugin.js.map +1 -1
  198. package/components/icure-text-field/plugin/has-content-class-plugin.js +7 -3
  199. package/components/icure-text-field/plugin/has-content-class-plugin.js.map +1 -1
  200. package/components/icure-text-field/plugin/mask-plugin.js +11 -7
  201. package/components/icure-text-field/plugin/mask-plugin.js.map +1 -1
  202. package/components/icure-text-field/plugin/regexp-plugin.js +9 -5
  203. package/components/icure-text-field/plugin/regexp-plugin.js.map +1 -1
  204. package/components/icure-text-field/prosemirror-commands.js +14 -10
  205. package/components/icure-text-field/prosemirror-commands.js.map +1 -1
  206. package/components/icure-text-field/prosemirror-utils.js +4 -1
  207. package/components/icure-text-field/prosemirror-utils.js.map +1 -1
  208. package/components/icure-text-field/schema/common-marks.js +7 -3
  209. package/components/icure-text-field/schema/common-marks.js.map +1 -1
  210. package/components/icure-text-field/schema/date-time-schema.js +8 -3
  211. package/components/icure-text-field/schema/date-time-schema.js.map +1 -1
  212. package/components/icure-text-field/schema/decimal-schema.js +4 -1
  213. package/components/icure-text-field/schema/decimal-schema.js.map +1 -1
  214. package/components/icure-text-field/schema/index.js +20 -17
  215. package/components/icure-text-field/schema/index.js.map +1 -1
  216. package/components/icure-text-field/schema/items-list-schema.js +6 -3
  217. package/components/icure-text-field/schema/items-list-schema.js.map +1 -1
  218. package/components/icure-text-field/schema/markdown-schema.js +10 -28
  219. package/components/icure-text-field/schema/markdown-schema.js.map +1 -1
  220. package/components/icure-text-field/schema/measure-schema.js +12 -6
  221. package/components/icure-text-field/schema/measure-schema.js.map +1 -1
  222. package/components/icure-text-field/schema/token-schema.js +8 -5
  223. package/components/icure-text-field/schema/token-schema.js.map +1 -1
  224. package/components/icure-text-field/schema/utils.js +6 -2
  225. package/components/icure-text-field/schema/utils.js.map +1 -1
  226. package/components/icure-text-field/selection-companion.js +5 -1
  227. package/components/icure-text-field/selection-companion.js.map +1 -1
  228. package/components/icure-text-field/suggestion-palette.js +10 -3
  229. package/components/icure-text-field/suggestion-palette.js.map +1 -1
  230. package/components/index.js +21 -5
  231. package/components/index.js.map +1 -1
  232. package/components/model/index.js +46 -22
  233. package/components/model/index.js.map +1 -1
  234. package/components/themes/default/index.js +32 -30
  235. package/components/themes/default/index.js.map +1 -1
  236. package/components/themes/icure-blue/index.js +104 -47
  237. package/components/themes/icure-blue/index.js.map +1 -1
  238. package/components/themes/kendo/index.js +55 -49
  239. package/components/themes/kendo/index.js.map +1 -1
  240. package/conversion/ckmeans-grouping.js +10 -3
  241. package/conversion/ckmeans-grouping.js.map +1 -1
  242. package/conversion/ckmeans.js +3 -1
  243. package/conversion/ckmeans.js.map +1 -1
  244. package/conversion/icure-convert.js +21 -18
  245. package/conversion/icure-convert.js.map +1 -1
  246. package/generic/index.js +17 -1
  247. package/generic/index.js.map +1 -1
  248. package/generic/model.d.ts +5 -4
  249. package/generic/model.js +2 -1
  250. package/generic/model.js.map +1 -1
  251. package/icure/form-values-container.d.ts +21 -13
  252. package/icure/form-values-container.js +263 -163
  253. package/icure/form-values-container.js.map +1 -1
  254. package/icure/icure-utils.js +21 -10
  255. package/icure/icure-utils.js.map +1 -1
  256. package/icure/index.js +18 -2
  257. package/icure/index.js.map +1 -1
  258. package/icure/model.js +2 -1
  259. package/index.d.ts +1 -0
  260. package/index.js +19 -1
  261. package/index.js.map +1 -1
  262. package/package.json +16 -13
  263. package/utils/code-utils.js +19 -11
  264. package/utils/code-utils.js.map +1 -1
  265. package/utils/dates.js +20 -9
  266. package/utils/dates.js.map +1 -1
  267. package/utils/fields-values-provider.d.ts +1 -1
  268. package/utils/fields-values-provider.js +28 -11
  269. package/utils/fields-values-provider.js.map +1 -1
  270. package/utils/interpreter.d.ts +2 -3
  271. package/utils/interpreter.js +16 -3
  272. package/utils/interpreter.js.map +1 -1
  273. package/utils/languages.js +8 -3
  274. package/utils/languages.js.map +1 -1
  275. package/utils/markdown.js +11 -6
  276. package/utils/markdown.js.map +1 -1
  277. package/utils/no-lodash.js +8 -3
  278. package/utils/no-lodash.js.map +1 -1
  279. package/utils/primitive.d.ts +1 -1
  280. package/utils/primitive.js +16 -11
  281. package/utils/primitive.js.map +1 -1
  282. package/utils/form-value-container.d.ts +0 -3
  283. package/utils/form-value-container.js +0 -30
  284. package/utils/form-value-container.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,15 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import { Service } from '@icure/api';
11
- import { sortedBy } from '../utils/no-lodash';
12
- import { areCodesEqual, codeStubToCode, contentToPrimitiveType, isContentEqual, primitiveTypeToContent } from './icure-utils';
13
- import { parsePrimitive } from '../utils/primitive';
14
- import { anyDateToDate } from '../utils/dates';
15
- import { v4 as uuidv4 } from 'uuid';
16
- import { normalizeCodes } from '../utils/code-utils';
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ContactFormValuesContainer = exports.BridgedFormValuesContainer = void 0;
13
+ const api_1 = require("@icure/api");
14
+ const no_lodash_1 = require("../utils/no-lodash");
15
+ const icure_utils_1 = require("./icure-utils");
16
+ const primitive_1 = require("../utils/primitive");
17
+ const dates_1 = require("../utils/dates");
18
+ const uuid_1 = require("uuid");
19
+ const code_utils_1 = require("../utils/code-utils");
17
20
  function notify(l, fvc) {
18
- //console.log('Notifying', l, fvc.toString())
19
21
  l(fvc);
20
22
  }
21
23
  /** This class is a bridge between the ICure API and the generic FormValuesContainer interface.
@@ -37,23 +39,24 @@ function notify(l, fvc) {
37
39
  *
38
40
  * This class is fairly generic and can be used as an inspiration or subclassed for other bridges
39
41
  */
40
- export class BridgedFormValuesContainer {
42
+ class BridgedFormValuesContainer {
41
43
  toString() {
42
44
  return `Bridged(${this.contactFormValuesContainer.rootForm.formTemplateId}[${this.contactFormValuesContainer.rootForm.id}]) - ${this._id}`;
43
45
  }
44
46
  /**
45
47
  * Creates an instance of BridgedFormValuesContainer.
46
48
  * @param responsible The id of the data owner responsible for the creation of the values
47
- * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day
48
49
  * @param contactFormValuesContainer The wrapped ContactFormValuesContainer
49
50
  * @param interpreter A function that can interpret formulas
51
+ * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day
52
+ * @param initialValuesProvider A lambda that provides the initial values of the form
50
53
  * @param dependentValuesProvider A function that provides the dependent values (computed on the basis of other values) for a given anchorId and templateId
51
54
  * @param validatorsProvider A function that provides the validators for a given anchorId and templateId
52
55
  * @param language The language in which the values are displayed
53
56
  * @param changeListeners The listeners that will be notified when the values change
54
- * @param initialValuesProvider A lambda that provides the initial values of the form
57
+ * @param interpreterContext A map with keys that are the names of the variables and values that are the functions that return the values of the variables
55
58
  */
56
- constructor(responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider = () => [], dependentValuesProvider = () => [], validatorsProvider = () => [], language = 'en', changeListeners = []) {
59
+ constructor(responsible, contactFormValuesContainer, interpreter, contact, initialValuesProvider = () => [], dependentValuesProvider = () => [], validatorsProvider = () => [], language = 'en', changeListeners = [], interpreterContext = {}) {
57
60
  this.responsible = responsible;
58
61
  this.interpreter = interpreter;
59
62
  this.initialValuesProvider = initialValuesProvider;
@@ -61,22 +64,28 @@ export class BridgedFormValuesContainer {
61
64
  this.validatorsProvider = validatorsProvider;
62
65
  this.language = language;
63
66
  this.changeListeners = changeListeners;
64
- this._id = uuidv4();
67
+ this.interpreterContext = interpreterContext;
68
+ this._id = (0, uuid_1.v4)();
65
69
  console.log(`Creating bridge FVC (${contactFormValuesContainer.rootForm.formTemplateId}) with ${contactFormValuesContainer.children.length} children [${this._id}]`);
66
70
  //Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values
67
71
  this.contactFormValuesContainer = contactFormValuesContainer;
68
- this.mutateAndNotify = (newContactFormValuesContainer) => {
72
+ this.mutateAndNotify = (newContactFormValuesContainer) => __awaiter(this, void 0, void 0, function* () {
69
73
  newContactFormValuesContainer.unregisterChangeListener(this.mutateAndNotify);
70
- const newBridgedFormValueContainer = new BridgedFormValuesContainer(this.responsible, newContactFormValuesContainer, this.interpreter, this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, this.changeListeners);
74
+ const newBridgedFormValueContainer = yield new BridgedFormValuesContainer(this.responsible, newContactFormValuesContainer, this.interpreter, this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, this.changeListeners, this.interpreterContext).init();
71
75
  this.changeListeners.forEach((l) => notify(l, newBridgedFormValueContainer));
72
76
  return newBridgedFormValueContainer;
73
- };
77
+ });
74
78
  this.contactFormValuesContainer.registerChangeListener(this.mutateAndNotify);
75
79
  this.contact = contact !== null && contact !== void 0 ? contact : contactFormValuesContainer.currentContact;
76
- if (this.contactFormValuesContainer.mustBeInitialised()) {
77
- this.computeInitialValues();
78
- }
79
- this.computeDependentValues();
80
+ }
81
+ init() {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ if (this.contactFormValuesContainer.mustBeInitialised()) {
84
+ yield this.computeInitialValues();
85
+ }
86
+ yield this.computeDependentValues();
87
+ return this;
88
+ });
80
89
  }
81
90
  getLabel() {
82
91
  return this.contactFormValuesContainer.getLabel();
@@ -93,6 +102,11 @@ export class BridgedFormValuesContainer {
93
102
  unregisterChangeListener(listener) {
94
103
  this.changeListeners = this.changeListeners.filter((l) => l !== listener);
95
104
  }
105
+ getDefaultValueProvider(label) {
106
+ var _a;
107
+ const formula = (_a = this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).find(({ metadata }) => metadata.label === label)) === null || _a === void 0 ? void 0 : _a.formula;
108
+ return formula ? () => __awaiter(this, void 0, void 0, function* () { return this.convertRawValue(yield this.compute(formula)); }) : undefined;
109
+ }
96
110
  getValues(revisionsFilter) {
97
111
  return Object.entries(this.contactFormValuesContainer.getValues((id, history) => revisionsFilter(id, history
98
112
  .filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)
@@ -104,7 +118,7 @@ export class BridgedFormValuesContainer {
104
118
  value: {
105
119
  label: sm.label,
106
120
  owner: sm.responsible,
107
- tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(codeStubToCode),
121
+ tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(icure_utils_1.codeStubToCode),
108
122
  valueDate: sm.valueDate,
109
123
  },
110
124
  });
@@ -116,10 +130,10 @@ export class BridgedFormValuesContainer {
116
130
  modified,
117
131
  value: {
118
132
  content: Object.entries((_a = s.content) !== null && _a !== void 0 ? _a : {}).reduce((acc, [lng, cnt]) => {
119
- const converted = contentToPrimitiveType(lng, cnt);
133
+ const converted = (0, icure_utils_1.contentToPrimitiveType)(lng, cnt);
120
134
  return converted ? Object.assign(Object.assign({}, acc), { [lng]: converted }) : acc;
121
135
  }, {}),
122
- codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(codeStubToCode),
136
+ codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(icure_utils_1.codeStubToCode),
123
137
  },
124
138
  });
125
139
  }) });
@@ -136,75 +150,114 @@ export class BridgedFormValuesContainer {
136
150
  tags: s.tags,
137
151
  discordantMetadata: () => {
138
152
  var _a, _b;
139
- return (Object.assign(Object.assign({}, (s.responsible !== this.responsible ? { owner: this.responsible } : {})), (Math.abs(+((_a = anyDateToDate(s.valueDate)) !== null && _a !== void 0 ? _a : 0) - +((_b = anyDateToDate(this.contact.created)) !== null && _b !== void 0 ? _b : 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {})));
153
+ return (Object.assign(Object.assign({}, (s.responsible !== this.responsible ? { owner: this.responsible } : {})), (Math.abs(+((_a = (0, dates_1.anyDateToDate)(s.valueDate)) !== null && _a !== void 0 ? _a : 0) - +((_b = (0, dates_1.anyDateToDate)(this.contact.created)) !== null && _b !== void 0 ? _b : 0)) > 24 * 3600000 ? { valueDate: s.valueDate } : {})));
140
154
  },
141
155
  },
142
156
  })) })), {});
143
157
  }
158
+ convertRawValue(rawValue) {
159
+ var _a, _b;
160
+ if (rawValue && typeof rawValue === 'object' && 'content' in rawValue) {
161
+ return rawValue;
162
+ }
163
+ if (Array.isArray(rawValue)) {
164
+ return rawValue.reduce((acc, it, idx) => {
165
+ var _a, _b, _c, _d, _e;
166
+ const fv = this.convertRawValue(it);
167
+ if (fv === undefined) {
168
+ return acc;
169
+ }
170
+ acc.codes = [...((_a = fv.codes) !== null && _a !== void 0 ? _a : []), ...((_b = acc.codes) !== null && _b !== void 0 ? _b : [])];
171
+ acc.content['*'] = ((_c = fv.content['*']) === null || _c === void 0 ? void 0 : _c.value)
172
+ ? Object.assign(Object.assign({}, acc.content['*']), { [(_e = ((_d = fv.codes) !== null && _d !== void 0 ? _d : [])[0].id) !== null && _e !== void 0 ? _e : idx.toString()]: fv.content['*'].value }) : acc.content['*'];
173
+ return acc;
174
+ }, { content: { '*': { type: 'compound', value: {} } } });
175
+ }
176
+ if (typeof rawValue === 'number') {
177
+ return { content: { '*': { type: 'number', value: rawValue } } };
178
+ }
179
+ if (typeof rawValue === 'string') {
180
+ return { content: { '*': { type: 'string', value: rawValue } } };
181
+ }
182
+ if (typeof rawValue === 'boolean') {
183
+ return { content: { '*': { type: 'boolean', value: rawValue } } };
184
+ }
185
+ if (rawValue instanceof Date) {
186
+ return { content: { '*': { type: 'timestamp', value: (0, dates_1.dateToFuzzyDate)(rawValue) } } };
187
+ }
188
+ if (rawValue && typeof rawValue === 'object' && 'unit' in rawValue && 'value' in rawValue && typeof rawValue.value === 'number') {
189
+ return { content: { '*': { type: 'measure', value: rawValue.value, unit: (_b = (_a = rawValue.unit) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '' } } };
190
+ }
191
+ return undefined;
192
+ }
144
193
  //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
145
194
  computeInitialValues() {
146
- if (this.contactFormValuesContainer.rootForm.formTemplateId) {
147
- this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {
148
- var _a;
149
- try {
150
- const currentValue = this.getValues(revisionsFilter);
151
- if (!currentValue || !Object.keys(currentValue).length) {
152
- const newValue = this.compute(formula);
153
- if (newValue !== undefined) {
154
- const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ if (this.contactFormValuesContainer.rootForm.formTemplateId) {
197
+ yield Promise.all(this.initialValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).map((_a) => __awaiter(this, [_a], void 0, function* ({ metadata, revisionsFilter, formula }) {
198
+ var _b;
199
+ try {
200
+ const currentValue = this.getValues(revisionsFilter);
201
+ if (!currentValue || !Object.keys(currentValue).length) {
202
+ const newValue = this.convertRawValue((yield this.compute(formula)));
203
+ if (newValue !== undefined) {
204
+ const lng = (_b = this.language) !== null && _b !== void 0 ? _b : 'en';
205
+ if (newValue && !newValue.content[lng] && newValue.content['*']) {
206
+ newValue.content[lng] = newValue.content['*'];
207
+ }
208
+ if (newValue) {
209
+ delete newValue.content['*'];
210
+ }
211
+ setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc) => {
212
+ const currentContact = this.contactFormValuesContainer.currentContact;
213
+ this.contactFormValuesContainer = fvc;
214
+ if (this.contact === currentContact) {
215
+ this.contact = fvc.currentContact;
216
+ }
217
+ });
218
+ }
219
+ }
220
+ }
221
+ catch (e) {
222
+ console.log(`Error while computing formula : ${formula}`, e);
223
+ }
224
+ })));
225
+ }
226
+ });
227
+ }
228
+ //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
229
+ computeDependentValues() {
230
+ return __awaiter(this, void 0, void 0, function* () {
231
+ if (this.contactFormValuesContainer.rootForm.formTemplateId) {
232
+ yield Promise.all(this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).map((_a) => __awaiter(this, [_a], void 0, function* ({ metadata, revisionsFilter, formula }) {
233
+ var _b;
234
+ try {
235
+ const currentValue = this.getValues(revisionsFilter);
236
+ const newValue = this.convertRawValue((yield this.compute(formula)));
237
+ if (newValue !== undefined || currentValue != undefined) {
238
+ const lng = (_b = this.language) !== null && _b !== void 0 ? _b : 'en';
155
239
  if (newValue && !newValue.content[lng] && newValue.content['*']) {
156
240
  newValue.content[lng] = newValue.content['*'];
157
241
  }
158
242
  if (newValue) {
159
243
  delete newValue.content['*'];
160
244
  }
161
- setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, undefined, metadata, (fvc) => {
245
+ const interceptor = (fvc) => {
162
246
  const currentContact = this.contactFormValuesContainer.currentContact;
163
247
  this.contactFormValuesContainer = fvc;
164
248
  if (this.contact === currentContact) {
165
249
  this.contact = fvc.currentContact;
166
250
  }
167
- });
251
+ };
252
+ setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata, interceptor);
168
253
  }
169
254
  }
170
- }
171
- catch (e) {
172
- console.log(`Error while computing formula : ${formula}`, e);
173
- }
174
- });
175
- }
176
- }
177
- //This method mutates the BridgedFormValuesContainer but can only be called from the constructor
178
- computeDependentValues() {
179
- if (this.contactFormValuesContainer.rootForm.formTemplateId) {
180
- this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, revisionsFilter, formula }) => {
181
- var _a;
182
- try {
183
- const currentValue = this.getValues(revisionsFilter);
184
- const newValue = this.compute(formula);
185
- if (newValue !== undefined || currentValue != undefined) {
186
- const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
187
- if (newValue && !newValue.content[lng] && newValue.content['*']) {
188
- newValue.content[lng] = newValue.content['*'];
189
- }
190
- if (newValue) {
191
- delete newValue.content['*'];
192
- }
193
- const interceptor = (fvc) => {
194
- const currentContact = this.contactFormValuesContainer.currentContact;
195
- this.contactFormValuesContainer = fvc;
196
- if (this.contact === currentContact) {
197
- this.contact = fvc.currentContact;
198
- }
199
- };
200
- setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata, interceptor);
255
+ catch (e) {
256
+ console.log(`Error while computing formula : ${formula}`, e);
201
257
  }
202
- }
203
- catch (e) {
204
- console.log(`Error while computing formula : ${formula}`, e);
205
- }
206
- });
207
- }
258
+ })));
259
+ }
260
+ });
208
261
  }
209
262
  setValue(label, language, fv, id, metadata) {
210
263
  setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata);
@@ -224,76 +277,111 @@ export class BridgedFormValuesContainer {
224
277
  return this.getValues((id, history) => { var _a, _b, _c; return (((_b = (_a = history === null || history === void 0 ? void 0 : history[0]) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.label) && key === history[0].value.label ? [(_c = history === null || history === void 0 ? void 0 : history[0]) === null || _c === void 0 ? void 0 : _c.revision] : []); });
225
278
  }
226
279
  compute(formula, sandbox) {
227
- var _a;
228
- // noinspection JSUnusedGlobalSymbols
229
- const parseContent = (content) => {
230
- var _a, _b;
231
- if (!content) {
232
- return undefined;
233
- }
234
- const primitive = (_b = (_a = content[this.language]) !== null && _a !== void 0 ? _a : content['*']) !== null && _b !== void 0 ? _b : content[Object.keys(content)[0]];
235
- return primitive && parsePrimitive(primitive);
236
- };
237
- const log = console.log;
238
- const native = {
239
- parseInt: parseInt,
240
- parseFloat: parseFloat,
241
- Date: Date,
242
- Math: Math,
243
- Number: Number,
244
- String: String,
245
- Boolean: Boolean,
246
- Array: Array,
247
- Object: Object,
248
- parseContent,
249
- validate: {
250
- notBlank: (self, label) => {
251
- var _a, _b, _c;
252
- const value = parseContent((_b = (_a = self[label]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content);
253
- return !!((_c = value === null || value === void 0 ? void 0 : value.trim()) === null || _c === void 0 ? void 0 : _c.length);
254
- },
255
- },
256
- log,
257
- };
258
- const proxy = new Proxy({}, {
259
- has: (target, key) => { var _a; return !!native[key] || key === 'self' || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
260
- get: (target, key) => {
261
- if (key === 'undefined') {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ var _a;
282
+ // noinspection JSUnusedGlobalSymbols
283
+ const parseContent = (content, toString = false) => {
284
+ var _a, _b;
285
+ if (!content) {
262
286
  return undefined;
263
287
  }
264
- const nativeValue = native[key];
265
- if (!!nativeValue) {
266
- return nativeValue;
288
+ const primitive = (_b = (_a = content[this.language]) !== null && _a !== void 0 ? _a : content['*']) !== null && _b !== void 0 ? _b : content[Object.keys(content)[0]];
289
+ return primitive && (0, primitive_1.parsePrimitive)(primitive, toString);
290
+ };
291
+ const text = (item) => {
292
+ if (!item) {
293
+ return undefined;
267
294
  }
268
- return key === 'self' ? proxy : Object.values(this.getVersionedValuesForKey(key)).map((v) => { var _a; return (_a = v[0]) === null || _a === void 0 ? void 0 : _a.value; });
269
- },
295
+ const items = Array.isArray(item) ? item : [item];
296
+ return items
297
+ .map((it) => { var _a; return (_a = parseContent(it.content, true)) === null || _a === void 0 ? void 0 : _a.toString(); })
298
+ .filter((it) => !!it)
299
+ .join(', ');
300
+ };
301
+ const log = console.log;
302
+ const native = {
303
+ parseInt: parseInt,
304
+ parseFloat: parseFloat,
305
+ Date: Date,
306
+ Math: Math,
307
+ Number: Number,
308
+ String: String,
309
+ Boolean: Boolean,
310
+ Array: Array,
311
+ Object: Object,
312
+ hasOption: (it, option) => { var _a; return it && ((_a = it.codes) === null || _a === void 0 ? void 0 : _a.some((c) => { var _a, _b; return c.id === option || ((_b = (_a = c.id) === null || _a === void 0 ? void 0 : _a.split('|')) === null || _b === void 0 ? void 0 : _b[1]) === option; })); },
313
+ score: (it) => {
314
+ var _a;
315
+ return it
316
+ ? ((_a = it.codes) !== null && _a !== void 0 ? _a : []).reduce((acc, c) => {
317
+ var _a, _b, _c;
318
+ try {
319
+ return acc + parseInt((_c = (_b = (_a = c.id) === null || _a === void 0 ? void 0 : _a.split('|')) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : '0');
320
+ }
321
+ catch (e) {
322
+ return acc;
323
+ }
324
+ }, 0)
325
+ : 0;
326
+ },
327
+ parseContent,
328
+ validate: {
329
+ notBlank: (self, label) => {
330
+ var _a, _b, _c;
331
+ const value = parseContent((_b = (_a = self[label]) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.content);
332
+ return !!((_c = value === null || value === void 0 ? void 0 : value.trim()) === null || _c === void 0 ? void 0 : _c.length);
333
+ },
334
+ },
335
+ text,
336
+ log,
337
+ Promise,
338
+ };
339
+ const proxy = new Proxy({}, {
340
+ has: (target, key) => { var _a; return !!native[key] || key === 'self' || !!this.interpreterContext[key] || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
341
+ get: (target, key) => {
342
+ if (key === 'undefined') {
343
+ return undefined;
344
+ }
345
+ const nativeValue = native[key];
346
+ if (!!nativeValue) {
347
+ return nativeValue;
348
+ }
349
+ return key === 'self' ? proxy : this.interpreterContext[key] ? this.interpreterContext[key]() : Object.values(this.getVersionedValuesForKey(key)).map((v) => { var _a; return (_a = v[0]) === null || _a === void 0 ? void 0 : _a.value; });
350
+ },
351
+ });
352
+ return (_a = this.interpreter) === null || _a === void 0 ? void 0 : _a.call(this, formula, sandbox !== null && sandbox !== void 0 ? sandbox : proxy);
270
353
  });
271
- return (_a = this.interpreter) === null || _a === void 0 ? void 0 : _a.call(this, formula, sandbox !== null && sandbox !== void 0 ? sandbox : proxy);
272
354
  }
273
355
  getChildren() {
274
- const children = this.contactFormValuesContainer
275
- .getChildren()
276
- .map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, []));
277
- console.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider);
278
- return children;
356
+ return __awaiter(this, void 0, void 0, function* () {
357
+ const children = yield Promise.all((yield this.contactFormValuesContainer.getChildren()).map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.initialValuesProvider, this.dependentValuesProvider, this.validatorsProvider, this.language, [], this.interpreterContext).init()));
358
+ console.log(`${children.length} children found in ${this.contactFormValuesContainer.rootForm.formTemplateId} initialised with `, this.initialValuesProvider);
359
+ return children;
360
+ });
279
361
  }
280
362
  getValidationErrors() {
281
- if (this.contactFormValuesContainer.rootForm.formTemplateId) {
282
- return this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).flatMap(({ metadata, validators }) => validators
283
- .map(({ validation, message }) => {
284
- try {
285
- return this.compute(validation) ? undefined : [metadata, message];
286
- }
287
- catch (e) {
288
- console.log(`Error while computing validation : ${validation}`, e);
289
- return undefined;
290
- }
291
- })
292
- .filter((x) => !!x));
293
- }
294
- else {
295
- return [];
296
- }
363
+ return __awaiter(this, void 0, void 0, function* () {
364
+ if (this.contactFormValuesContainer.rootForm.formTemplateId) {
365
+ // noinspection ES6MissingAwait
366
+ return yield this.validatorsProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).reduce((resPromise_1, _a) => __awaiter(this, [resPromise_1, _a], void 0, function* (resPromise, { metadata, validators }) {
367
+ return yield validators.reduce((resPromise_2, _a) => __awaiter(this, [resPromise_2, _a], void 0, function* (resPromise, { validation, message }) {
368
+ const res = yield resPromise;
369
+ try {
370
+ if (!(yield this.compute(validation))) {
371
+ res.push([metadata, message]);
372
+ }
373
+ }
374
+ catch (e) {
375
+ console.log(`Error while computing validation : ${validation}`, e);
376
+ }
377
+ return res;
378
+ }), resPromise);
379
+ }), Promise.resolve([]));
380
+ }
381
+ else {
382
+ return [];
383
+ }
384
+ });
297
385
  }
298
386
  addChild(anchorId, templateId, label) {
299
387
  return __awaiter(this, void 0, void 0, function* () {
@@ -310,6 +398,7 @@ export class BridgedFormValuesContainer {
310
398
  return this;
311
399
  }
312
400
  }
401
+ exports.BridgedFormValuesContainer = BridgedFormValuesContainer;
313
402
  /**
314
403
  * This class is a form values container that uses a hierarchy of forms as a data source. The actual values are extracted from the services of the contacts.
315
404
  * The `currentContact` is the contact that has been selected by the user, any later contact should be ignored.
@@ -318,7 +407,7 @@ export class BridgedFormValuesContainer {
318
407
  * Each ContactFormValuesContainer has a reference to its `rootForm`.
319
408
  * The `serviceFactory` and `formFactory` are used to create new services and add sub-forms.
320
409
  */
321
- export class ContactFormValuesContainer {
410
+ class ContactFormValuesContainer {
322
411
  toString() {
323
412
  return `Contact(${this.rootForm.formTemplateId}[${this.rootForm.id}]) - ${this._id}`;
324
413
  }
@@ -343,7 +432,7 @@ export class ContactFormValuesContainer {
343
432
  return [this.rootForm].concat(this.children.flatMap((c) => c.allForms()));
344
433
  }
345
434
  constructor(rootForm, currentContact, contactsHistory, serviceFactory, children, formFactory, formRecycler, changeListeners = [], initialised = true) {
346
- this._id = uuidv4();
435
+ this._id = (0, uuid_1.v4)();
347
436
  this._initialised = false;
348
437
  console.log(`Creating contact FVC (${rootForm.formTemplateId}) with ${children.length} children [${this._id}]`);
349
438
  if (contactsHistory.includes(currentContact)) {
@@ -351,13 +440,26 @@ export class ContactFormValuesContainer {
351
440
  }
352
441
  this.rootForm = rootForm;
353
442
  this.currentContact = currentContact;
354
- this.contactsHistory = sortedBy(contactsHistory, 'created', 'desc');
443
+ this.contactsHistory = (0, no_lodash_1.sortedBy)(contactsHistory, 'created', 'desc');
355
444
  this.children = children;
356
445
  this.serviceFactory = serviceFactory;
357
446
  this.formFactory = formFactory;
358
447
  this.formRecycler = formRecycler;
359
448
  this.changeListeners = changeListeners;
360
449
  this._initialised = initialised;
450
+ this.indexedServices = [this.currentContact].concat(this.contactsHistory).reduce((acc, ctc) => {
451
+ var _a, _b, _c;
452
+ const services = (_c = (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter((s) => { var _a; return (_a = ctc.subContacts) === null || _a === void 0 ? void 0 : _a.some((sc) => { var _a; return sc.formId === this.rootForm.id && ((_a = sc.services) === null || _a === void 0 ? void 0 : _a.some((sss) => sss.serviceId === s.id)); }); })) === null || _b === void 0 ? void 0 : _b.reduce((acc, s) => {
453
+ var _a, _b;
454
+ return s.id
455
+ ? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({
456
+ revision: (_b = ctc.rev) !== null && _b !== void 0 ? _b : null,
457
+ modified: ctc.created,
458
+ value: s,
459
+ }) }) : acc;
460
+ }, acc)) !== null && _c !== void 0 ? _c : acc;
461
+ return services;
462
+ }, {});
361
463
  this.synchronise();
362
464
  }
363
465
  synchronise() {
@@ -404,10 +506,17 @@ export class ContactFormValuesContainer {
404
506
  this.changeListeners = this.changeListeners.filter((l) => l !== listener);
405
507
  }
406
508
  getChildren() {
407
- return this.children;
509
+ return __awaiter(this, void 0, void 0, function* () {
510
+ return this.children;
511
+ });
408
512
  }
409
513
  getValidationErrors() {
410
- throw new Error('Validation not supported at contact level');
514
+ return __awaiter(this, void 0, void 0, function* () {
515
+ throw new Error('Validation not supported at contact level');
516
+ });
517
+ }
518
+ getDefaultValueProvider() {
519
+ return undefined;
411
520
  }
412
521
  getValues(revisionsFilter) {
413
522
  return Object.entries(this.getServicesInHistory(revisionsFilter)).reduce((acc, [id, history]) => history.length
@@ -447,11 +556,11 @@ export class ContactFormValuesContainer {
447
556
  (meta.valueDate && service.valueDate !== meta.valueDate) ||
448
557
  (meta.codes && service.codes !== meta.codes) ||
449
558
  (meta.tags && service.tags !== meta.tags)) {
450
- const newService = new Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
559
+ const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
451
560
  meta.responsible && (newService.responsible = meta.responsible);
452
561
  meta.valueDate && (newService.valueDate = meta.valueDate);
453
- meta.codes && (newService.codes = normalizeCodes(meta.codes));
454
- meta.tags && (newService.tags = normalizeCodes(meta.tags));
562
+ meta.codes && (newService.codes = (0, code_utils_1.normalizeCodes)(meta.codes));
563
+ meta.tags && (newService.tags = (0, code_utils_1.normalizeCodes)(meta.tags));
455
564
  const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => (s.id === service.id ? newService : s)) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
456
565
  this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
457
566
  }
@@ -464,9 +573,9 @@ export class ContactFormValuesContainer {
464
573
  }
465
574
  console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata);
466
575
  const newContent = (_c = value === null || value === void 0 ? void 0 : value.content) === null || _c === void 0 ? void 0 : _c[language];
467
- const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? normalizeCodes(value.codes) : [];
468
- if (!isContentEqual((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !areCodesEqual(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
469
- const newService = new Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
576
+ const newCodes = (value === null || value === void 0 ? void 0 : value.codes) ? (0, code_utils_1.normalizeCodes)(value.codes) : [];
577
+ if (!(0, icure_utils_1.isContentEqual)((_d = service.content) === null || _d === void 0 ? void 0 : _d[language], newContent) || (newCodes && !(0, icure_utils_1.areCodesEqual)(newCodes, (_e = service.codes) !== null && _e !== void 0 ? _e : []))) {
578
+ const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
470
579
  const newContents = newContent
471
580
  ? Object.assign(Object.assign({}, (service.content || {})), { [language]: newContent }) : Object.assign({}, (service.content || {}));
472
581
  if (!newContent) {
@@ -494,7 +603,7 @@ export class ContactFormValuesContainer {
494
603
  if (metadata) {
495
604
  newService.responsible = (_m = metadata.responsible) !== null && _m !== void 0 ? _m : newService.responsible;
496
605
  newService.valueDate = (_o = metadata.valueDate) !== null && _o !== void 0 ? _o : newService.valueDate;
497
- newService.tags = metadata.tags ? normalizeCodes(metadata.tags) : newService.tags;
606
+ newService.tags = metadata.tags ? (0, code_utils_1.normalizeCodes)(metadata.tags) : newService.tags;
498
607
  newService.label = (_p = metadata.label) !== null && _p !== void 0 ? _p : newService.label;
499
608
  }
500
609
  newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { subContacts: ((_q = this.currentContact.subContacts) !== null && _q !== void 0 ? _q : []).some((sc) => sc.formId === this.rootForm.id)
@@ -520,13 +629,15 @@ export class ContactFormValuesContainer {
520
629
  const service = this.getServiceInCurrentContact(serviceId);
521
630
  if (service) {
522
631
  const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, Object.assign(Object.assign({}, this.currentContact), { services: (_a = this.currentContact.services) === null || _a === void 0 ? void 0 : _a.map((s) => s.id === serviceId
523
- ? new Service(Object.assign(Object.assign({}, service), { endOfLife: Date.now() }))
632
+ ? new api_1.Service(Object.assign(Object.assign({}, service), { endOfLife: Date.now() }))
524
633
  : s) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.formRecycler, this.changeListeners);
525
634
  this.changeListeners.forEach((l) => notify(l, newFormValuesContainer));
526
635
  }
527
636
  }
528
637
  compute() {
529
- throw new Error('Compute not supported at contact level');
638
+ return __awaiter(this, void 0, void 0, function* () {
639
+ throw new Error('Compute not supported at contact level');
640
+ });
530
641
  }
531
642
  /** returns all services in history that match a selector
532
643
  *
@@ -534,20 +645,8 @@ export class ContactFormValuesContainer {
534
645
  * @param revisionsFilter
535
646
  */
536
647
  getServicesInHistory(revisionsFilter) {
537
- const indexedServices = [this.currentContact].concat(this.contactsHistory).reduce((acc, ctc) => {
538
- var _a, _b, _c;
539
- const services = (_c = (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.filter((s) => { var _a; return (_a = ctc.subContacts) === null || _a === void 0 ? void 0 : _a.some((sc) => { var _a; return sc.formId === this.rootForm.id && ((_a = sc.services) === null || _a === void 0 ? void 0 : _a.some((sss) => sss.serviceId === s.id)); }); })) === null || _b === void 0 ? void 0 : _b.reduce((acc, s) => {
540
- var _a, _b;
541
- return s.id
542
- ? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({
543
- revision: (_b = ctc.rev) !== null && _b !== void 0 ? _b : null,
544
- modified: ctc.created,
545
- value: s,
546
- }) }) : acc;
547
- }, acc)) !== null && _c !== void 0 ? _c : acc;
548
- return services;
549
- }, {}); //index services in history by id
550
- return Object.entries(indexedServices)
648
+ //index services in history by id
649
+ return Object.entries(this.indexedServices)
551
650
  .map(([id, history]) => {
552
651
  const keptRevisions = revisionsFilter(id, history.map(({ revision, modified, value: s }) => {
553
652
  var _a, _b;
@@ -591,6 +690,7 @@ export class ContactFormValuesContainer {
591
690
  });
592
691
  }
593
692
  }
693
+ exports.ContactFormValuesContainer = ContactFormValuesContainer;
594
694
  const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, metadata, changeListenersOverrider) => {
595
695
  var _a, _b;
596
696
  const value = fv === null || fv === void 0 ? void 0 : fv.content[language];
@@ -599,7 +699,7 @@ const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, met
599
699
  codes: (_a = fv === null || fv === void 0 ? void 0 : fv.codes) !== null && _a !== void 0 ? _a : [],
600
700
  content: value
601
701
  ? {
602
- [language]: primitiveTypeToContent(language, value),
702
+ [language]: (0, icure_utils_1.primitiveTypeToContent)(language, value),
603
703
  }
604
704
  : undefined,
605
705
  }, id, metadata