@icure/form 1.1.0 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/common/field-with-options.d.ts +9 -0
- package/components/common/field-with-options.js +50 -0
- package/components/common/field-with-options.js.map +1 -0
- package/components/common/field.d.ts +46 -0
- package/components/common/field.js +107 -0
- package/components/common/field.js.map +1 -0
- package/components/common/index.d.ts +1 -0
- package/components/{iqr-form-loader → common}/index.js +1 -3
- package/components/common/index.js.map +1 -0
- package/components/{iqr-text-field → common}/styles/paths.d.ts +3 -0
- package/components/{iqr-text-field → common}/styles/paths.js +28 -5
- package/components/common/styles/paths.js.map +1 -0
- package/components/common/utils.d.ts +8 -0
- package/components/common/utils.js +42 -0
- package/components/common/utils.js.map +1 -0
- package/components/icure-button-group/index.d.ts +12 -0
- package/components/icure-button-group/index.js +1140 -0
- package/components/icure-button-group/index.js.map +1 -0
- package/components/icure-date-picker/index.d.ts +16 -0
- package/components/icure-date-picker/index.js +1140 -0
- package/components/icure-date-picker/index.js.map +1 -0
- package/components/icure-dropdown-field/index.d.ts +16 -0
- package/components/icure-dropdown-field/index.js +1153 -0
- package/components/icure-dropdown-field/index.js.map +1 -0
- package/components/icure-form/fields/button-group/checkbox.d.ts +6 -0
- package/components/icure-form/fields/button-group/checkbox.js +61 -0
- package/components/icure-form/fields/button-group/checkbox.js.map +1 -0
- package/components/icure-form/fields/button-group/index.d.ts +2 -0
- package/components/icure-form/fields/button-group/index.js +19 -0
- package/components/icure-form/fields/button-group/index.js.map +1 -0
- package/components/icure-form/fields/button-group/radio-button.d.ts +6 -0
- package/components/icure-form/fields/button-group/radio-button.js +61 -0
- package/components/icure-form/fields/button-group/radio-button.js.map +1 -0
- package/components/icure-form/fields/date-picker/date-picker.d.ts +4 -0
- package/components/icure-form/fields/date-picker/date-picker.js +29 -0
- package/components/icure-form/fields/date-picker/date-picker.js.map +1 -0
- package/components/icure-form/fields/date-picker/date-time-picker.d.ts +4 -0
- package/components/icure-form/fields/date-picker/date-time-picker.js +29 -0
- package/components/icure-form/fields/date-picker/date-time-picker.js.map +1 -0
- package/components/icure-form/fields/date-picker/index.d.ts +3 -0
- package/components/icure-form/fields/date-picker/index.js +20 -0
- package/components/icure-form/fields/date-picker/index.js.map +1 -0
- package/components/icure-form/fields/date-picker/time-picker.d.ts +4 -0
- package/components/icure-form/fields/date-picker/time-picker.js +29 -0
- package/components/icure-form/fields/date-picker/time-picker.js.map +1 -0
- package/components/icure-form/fields/dropdown/dropdown-field.d.ts +11 -0
- package/components/icure-form/fields/dropdown/dropdown-field.js +65 -0
- package/components/icure-form/fields/dropdown/dropdown-field.js.map +1 -0
- package/components/icure-form/fields/dropdown/index.d.ts +1 -0
- package/components/icure-form/fields/dropdown/index.js +18 -0
- package/components/icure-form/fields/dropdown/index.js.map +1 -0
- package/components/icure-form/fields/index.d.ts +9 -0
- package/components/icure-form/fields/index.js +26 -0
- package/components/icure-form/fields/index.js.map +1 -0
- package/components/icure-form/fields/items-list-field/index.d.ts +1 -0
- package/components/icure-form/fields/items-list-field/index.js +18 -0
- package/components/icure-form/fields/items-list-field/index.js.map +1 -0
- package/components/icure-form/fields/items-list-field/items-list-field.d.ts +6 -0
- package/components/icure-form/fields/items-list-field/items-list-field.js +49 -0
- package/components/icure-form/fields/items-list-field/items-list-field.js.map +1 -0
- package/components/icure-form/fields/label/index.d.ts +1 -0
- package/components/icure-form/fields/label/index.js +18 -0
- package/components/icure-form/fields/label/index.js.map +1 -0
- package/components/{iqr-form/fields/multipleChoice.d.ts → icure-form/fields/label/label.d.ts} +5 -4
- package/components/{iqr-form/fields/multipleChoice.js → icure-form/fields/label/label.js} +18 -15
- package/components/icure-form/fields/label/label.js.map +1 -0
- package/components/icure-form/fields/measure-field/index.d.ts +1 -0
- package/components/icure-form/fields/measure-field/index.js +18 -0
- package/components/icure-form/fields/measure-field/index.js.map +1 -0
- package/components/icure-form/fields/measure-field/measure-field.d.ts +4 -0
- package/components/icure-form/fields/measure-field/measure-field.js +31 -0
- package/components/icure-form/fields/measure-field/measure-field.js.map +1 -0
- package/components/icure-form/fields/number-field/index.d.ts +1 -0
- package/components/icure-form/fields/number-field/index.js +18 -0
- package/components/icure-form/fields/number-field/index.js.map +1 -0
- package/components/icure-form/fields/number-field/number-field.d.ts +4 -0
- package/components/icure-form/fields/number-field/number-field.js +29 -0
- package/components/icure-form/fields/number-field/number-field.js.map +1 -0
- package/components/icure-form/fields/text-field/index.d.ts +1 -0
- package/components/icure-form/fields/text-field/index.js +18 -0
- package/components/icure-form/fields/text-field/index.js.map +1 -0
- package/components/icure-form/fields/text-field/text-field.d.ts +28 -0
- package/components/icure-form/fields/text-field/text-field.js +123 -0
- package/components/icure-form/fields/text-field/text-field.js.map +1 -0
- package/components/icure-form/fields/token-field/index.d.ts +1 -0
- package/components/icure-form/fields/token-field/index.js +18 -0
- package/components/icure-form/fields/token-field/index.js.map +1 -0
- package/components/icure-form/fields/token-field/token-field.d.ts +6 -0
- package/components/{iqr-form/fields/datePicker.js → icure-form/fields/token-field/token-field.js} +26 -34
- package/components/icure-form/fields/token-field/token-field.js.map +1 -0
- package/components/icure-form/fields/utils/index.d.ts +11 -0
- package/components/icure-form/fields/utils/index.js +48 -0
- package/components/icure-form/fields/utils/index.js.map +1 -0
- package/components/icure-form/index.d.ts +23 -0
- package/components/icure-form/index.js +1127 -0
- package/components/icure-form/index.js.map +1 -0
- package/components/icure-form/renderer/form/form-selection-button.d.ts +9 -0
- package/components/icure-form/renderer/form/form-selection-button.js +108 -0
- package/components/icure-form/renderer/form/form-selection-button.js.map +1 -0
- package/components/icure-form/renderer/form/form.d.ts +3 -0
- package/components/icure-form/renderer/form/form.js +399 -0
- package/components/icure-form/renderer/form/form.js.map +1 -0
- package/components/icure-form/renderer/index.d.ts +11 -0
- package/components/icure-form/renderer/index.js.map +1 -0
- package/components/icure-label/index.d.ts +8 -0
- package/components/icure-label/index.js +1072 -0
- package/components/icure-label/index.js.map +1 -0
- package/components/icure-text-field/index.d.ts +69 -0
- package/components/icure-text-field/index.js +1739 -0
- package/components/icure-text-field/index.js.map +1 -0
- package/components/icure-text-field/plugin/caret-fix-plugin.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/plugin/has-content-class-plugin.d.ts +1 -1
- package/components/icure-text-field/plugin/has-content-class-plugin.js.map +1 -0
- package/components/icure-text-field/plugin/mask-plugin.js.map +1 -0
- package/components/icure-text-field/plugin/regexp-plugin.js.map +1 -0
- package/components/icure-text-field/prosemirror-commands.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/prosemirror-utils.d.ts +1 -1
- package/components/icure-text-field/prosemirror-utils.js.map +1 -0
- package/components/icure-text-field/schema/common-marks.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/schema/date-time-schema.d.ts +3 -3
- package/components/icure-text-field/schema/date-time-schema.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/schema/decimal-schema.d.ts +1 -1
- package/components/icure-text-field/schema/decimal-schema.js.map +1 -0
- package/components/icure-text-field/schema/index.d.ts +6 -0
- package/components/{iqr-text-field → icure-text-field}/schema/index.js +6 -3
- package/components/icure-text-field/schema/index.js.map +1 -0
- package/components/icure-text-field/schema/items-list-schema.d.ts +3 -0
- package/components/icure-text-field/schema/items-list-schema.js +28 -0
- package/components/icure-text-field/schema/items-list-schema.js.map +1 -0
- package/components/icure-text-field/schema/items-list.d.ts +3 -0
- package/components/icure-text-field/schema/items-list.js +31 -0
- package/components/icure-text-field/schema/items-list.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/schema/markdown-schema.d.ts +3 -3
- package/components/icure-text-field/schema/markdown-schema.js.map +1 -0
- package/components/icure-text-field/schema/measure-schema.d.ts +7 -0
- package/components/icure-text-field/schema/measure-schema.js +81 -0
- package/components/icure-text-field/schema/measure-schema.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/schema/token-schema.d.ts +1 -1
- package/components/{iqr-text-field → icure-text-field}/schema/token-schema.js +3 -6
- package/components/icure-text-field/schema/token-schema.js.map +1 -0
- package/components/icure-text-field/schema/utils.js.map +1 -0
- package/components/icure-text-field/selection-companion.js.map +1 -0
- package/components/{iqr-text-field → icure-text-field}/suggestion-palette.d.ts +1 -6
- package/components/icure-text-field/suggestion-palette.js.map +1 -0
- package/components/index.d.ts +5 -2
- package/components/index.js +5 -2
- package/components/index.js.map +1 -1
- package/components/model/index.d.ts +782 -0
- package/components/model/index.js +632 -0
- package/components/model/index.js.map +1 -0
- package/components/themes/default/index.d.ts +1 -0
- package/components/themes/default/index.js +28 -0
- package/components/themes/default/index.js.map +1 -0
- package/components/themes/ehr-lite/index.d.ts +1 -0
- package/components/themes/ehr-lite/index.js +321 -0
- package/components/themes/ehr-lite/index.js.map +1 -0
- package/components/themes/kendo/index.d.ts +1 -0
- package/components/themes/kendo/index.js +285 -0
- package/components/themes/kendo/index.js.map +1 -0
- package/conversion/ckmeans-grouping.d.ts +4 -0
- package/conversion/ckmeans-grouping.js +53 -0
- package/conversion/ckmeans-grouping.js.map +1 -0
- package/conversion/ckmeans.d.ts +44 -0
- package/conversion/ckmeans.js +287 -0
- package/conversion/ckmeans.js.map +1 -0
- package/conversion/icure-convert.d.ts +3 -0
- package/conversion/icure-convert.js +165 -0
- package/conversion/icure-convert.js.map +1 -0
- package/generic/index.d.ts +1 -0
- package/generic/index.js +18 -0
- package/generic/index.js.map +1 -0
- package/generic/model.d.ts +39 -0
- package/{components/iqr-form-loader/models.js → generic/model.js} +1 -1
- package/generic/model.js.map +1 -0
- package/icure/form-values-container.d.ts +83 -0
- package/icure/form-values-container.js +445 -0
- package/icure/form-values-container.js.map +1 -0
- package/icure/index.d.ts +2 -0
- package/icure/index.js +19 -0
- package/icure/index.js.map +1 -0
- package/icure/model.d.ts +10 -0
- package/icure/model.js +3 -0
- package/icure/model.js.map +1 -0
- package/package.json +21 -16
- package/utils/code-utils.d.ts +18 -0
- package/utils/code-utils.js +36 -0
- package/utils/code-utils.js.map +1 -0
- package/utils/fields-values-provider.d.ts +18 -0
- package/utils/fields-values-provider.js +50 -0
- package/utils/fields-values-provider.js.map +1 -0
- package/utils/form-value-container.d.ts +3 -0
- package/utils/form-value-container.js +45 -0
- package/utils/form-value-container.js.map +1 -0
- package/utils/icure-utils.d.ts +8 -11
- package/utils/icure-utils.js +47 -48
- package/utils/icure-utils.js.map +1 -1
- package/utils/interpreter.d.ts +4 -0
- package/utils/interpreter.js +52 -0
- package/utils/interpreter.js.map +1 -0
- package/utils/languages.d.ts +3 -1
- package/utils/languages.js +4 -4
- package/utils/languages.js.map +1 -1
- package/utils/markdown.d.ts +8 -0
- package/utils/markdown.js +58 -0
- package/utils/markdown.js.map +1 -0
- package/utils/primitive.d.ts +7 -0
- package/utils/primitive.js +123 -0
- package/utils/primitive.js.map +1 -0
- package/components/iqr-form/fields/datePicker.d.ts +0 -10
- package/components/iqr-form/fields/datePicker.js.map +0 -1
- package/components/iqr-form/fields/dateTimePicker.d.ts +0 -10
- package/components/iqr-form/fields/dateTimePicker.js +0 -49
- package/components/iqr-form/fields/dateTimePicker.js.map +0 -1
- package/components/iqr-form/fields/measureField.d.ts +0 -8
- package/components/iqr-form/fields/measureField.js +0 -44
- package/components/iqr-form/fields/measureField.js.map +0 -1
- package/components/iqr-form/fields/multipleChoice.js.map +0 -1
- package/components/iqr-form/fields/numberField.d.ts +0 -8
- package/components/iqr-form/fields/numberField.js +0 -44
- package/components/iqr-form/fields/numberField.js.map +0 -1
- package/components/iqr-form/fields/textfield.d.ts +0 -1
- package/components/iqr-form/fields/textfield.js +0 -143
- package/components/iqr-form/fields/textfield.js.map +0 -1
- package/components/iqr-form/fields/timePicker.d.ts +0 -10
- package/components/iqr-form/fields/timePicker.js +0 -49
- package/components/iqr-form/fields/timePicker.js.map +0 -1
- package/components/iqr-form/index.d.ts +0 -7
- package/components/iqr-form/index.js +0 -147
- package/components/iqr-form/index.js.map +0 -1
- package/components/iqr-form/legacy/Content.d.ts +0 -28
- package/components/iqr-form/legacy/Content.js +0 -30
- package/components/iqr-form/legacy/Content.js.map +0 -1
- package/components/iqr-form/legacy/Data.d.ts +0 -14
- package/components/iqr-form/legacy/Data.js +0 -21
- package/components/iqr-form/legacy/Data.js.map +0 -1
- package/components/iqr-form/legacy/Editor.d.ts +0 -34
- package/components/iqr-form/legacy/Editor.js +0 -19
- package/components/iqr-form/legacy/Editor.js.map +0 -1
- package/components/iqr-form/legacy/FormColumn.d.ts +0 -18
- package/components/iqr-form/legacy/FormColumn.js +0 -10
- package/components/iqr-form/legacy/FormColumn.js.map +0 -1
- package/components/iqr-form/legacy/FormDataOption.d.ts +0 -16
- package/components/iqr-form/legacy/FormDataOption.js +0 -21
- package/components/iqr-form/legacy/FormDataOption.js.map +0 -1
- package/components/iqr-form/legacy/FormLayout.d.ts +0 -25
- package/components/iqr-form/legacy/FormLayout.js +0 -10
- package/components/iqr-form/legacy/FormLayout.js.map +0 -1
- package/components/iqr-form/legacy/FormLayoutData.d.ts +0 -42
- package/components/iqr-form/legacy/FormLayoutData.js +0 -10
- package/components/iqr-form/legacy/FormLayoutData.js.map +0 -1
- package/components/iqr-form/legacy/FormPlanning.d.ts +0 -22
- package/components/iqr-form/legacy/FormPlanning.js +0 -21
- package/components/iqr-form/legacy/FormPlanning.js.map +0 -1
- package/components/iqr-form/legacy/FormSection.d.ts +0 -19
- package/components/iqr-form/legacy/FormSection.js +0 -10
- package/components/iqr-form/legacy/FormSection.js.map +0 -1
- package/components/iqr-form/legacy/Formula.d.ts +0 -27
- package/components/iqr-form/legacy/Formula.js +0 -32
- package/components/iqr-form/legacy/Formula.js.map +0 -1
- package/components/iqr-form/legacy/GuiCode.d.ts +0 -16
- package/components/iqr-form/legacy/GuiCode.js +0 -21
- package/components/iqr-form/legacy/GuiCode.js.map +0 -1
- package/components/iqr-form/legacy/GuiCodeType.d.ts +0 -15
- package/components/iqr-form/legacy/GuiCodeType.js +0 -21
- package/components/iqr-form/legacy/GuiCodeType.js.map +0 -1
- package/components/iqr-form/legacy/Suggest.d.ts +0 -19
- package/components/iqr-form/legacy/Suggest.js +0 -21
- package/components/iqr-form/legacy/Suggest.js.map +0 -1
- package/components/iqr-form/legacy/Tag.d.ts +0 -16
- package/components/iqr-form/legacy/Tag.js +0 -21
- package/components/iqr-form/legacy/Tag.js.map +0 -1
- package/components/iqr-form/model/index.d.ts +0 -96
- package/components/iqr-form/model/index.js +0 -120
- package/components/iqr-form/model/index.js.map +0 -1
- package/components/iqr-form/renderer/cards.d.ts +0 -2
- package/components/iqr-form/renderer/cards.js +0 -55
- package/components/iqr-form/renderer/cards.js.map +0 -1
- package/components/iqr-form/renderer/form.d.ts +0 -2
- package/components/iqr-form/renderer/form.js +0 -93
- package/components/iqr-form/renderer/form.js.map +0 -1
- package/components/iqr-form/renderer/index.d.ts +0 -6
- package/components/iqr-form/renderer/index.js.map +0 -1
- package/components/iqr-form/utils.d.ts +0 -5
- package/components/iqr-form/utils.js +0 -91
- package/components/iqr-form/utils.js.map +0 -1
- package/components/iqr-form-loader/fieldsValuesProviders.d.ts +0 -13
- package/components/iqr-form-loader/fieldsValuesProviders.js +0 -49
- package/components/iqr-form-loader/fieldsValuesProviders.js.map +0 -1
- package/components/iqr-form-loader/formValuesContainer.d.ts +0 -33
- package/components/iqr-form-loader/formValuesContainer.js +0 -111
- package/components/iqr-form-loader/formValuesContainer.js.map +0 -1
- package/components/iqr-form-loader/index.d.ts +0 -3
- package/components/iqr-form-loader/index.js.map +0 -1
- package/components/iqr-form-loader/models.d.ts +0 -14
- package/components/iqr-form-loader/models.js.map +0 -1
- package/components/iqr-text-field/index.d.ts +0 -26
- package/components/iqr-text-field/index.js +0 -1242
- package/components/iqr-text-field/index.js.map +0 -1
- package/components/iqr-text-field/plugin/caret-fix-plugin.js.map +0 -1
- package/components/iqr-text-field/plugin/has-content-class-plugin.js.map +0 -1
- package/components/iqr-text-field/plugin/mask-plugin.js.map +0 -1
- package/components/iqr-text-field/plugin/regexp-plugin.js.map +0 -1
- package/components/iqr-text-field/prosemirror-commands.js.map +0 -1
- package/components/iqr-text-field/prosemirror-utils.js.map +0 -1
- package/components/iqr-text-field/schema/common-marks.js.map +0 -1
- package/components/iqr-text-field/schema/date-time-schema.js.map +0 -1
- package/components/iqr-text-field/schema/decimal-schema.js.map +0 -1
- package/components/iqr-text-field/schema/index.d.ts +0 -11
- package/components/iqr-text-field/schema/index.js.map +0 -1
- package/components/iqr-text-field/schema/markdown-schema.js.map +0 -1
- package/components/iqr-text-field/schema/measure-schema.d.ts +0 -3
- package/components/iqr-text-field/schema/measure-schema.js +0 -36
- package/components/iqr-text-field/schema/measure-schema.js.map +0 -1
- package/components/iqr-text-field/schema/token-schema.js.map +0 -1
- package/components/iqr-text-field/schema/utils.js.map +0 -1
- package/components/iqr-text-field/selection-companion.js.map +0 -1
- package/components/iqr-text-field/styles/paths.js.map +0 -1
- package/components/iqr-text-field/suggestion-palette.js.map +0 -1
- /package/components/{iqr-form → icure-form}/renderer/index.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/caret-fix-plugin.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/caret-fix-plugin.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/has-content-class-plugin.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/mask-plugin.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/mask-plugin.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/regexp-plugin.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/plugin/regexp-plugin.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/prosemirror-commands.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/prosemirror-commands.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/prosemirror-utils.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/common-marks.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/common-marks.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/date-time-schema.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/decimal-schema.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/markdown-schema.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/utils.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/schema/utils.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/selection-companion.d.ts +0 -0
- /package/components/{iqr-text-field → icure-text-field}/selection-companion.js +0 -0
- /package/components/{iqr-text-field → icure-text-field}/suggestion-palette.js +0 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Contact, Form as ICureForm, Service } from '@icure/api';
|
|
2
|
+
import { FormValuesContainer, FormValuesContainerMutation, ID, Version, VersionedData } from '../generic';
|
|
3
|
+
import { ServiceMetadata } from '../icure';
|
|
4
|
+
import { FieldMetadata, FieldValue } from '../components/model';
|
|
5
|
+
export declare class BridgedFormValuesContainer implements FormValuesContainer<FieldValue, FieldMetadata> {
|
|
6
|
+
private responsible;
|
|
7
|
+
private interpreter?;
|
|
8
|
+
private dependentValuesProvider;
|
|
9
|
+
private language;
|
|
10
|
+
private changeListeners;
|
|
11
|
+
private contact;
|
|
12
|
+
private contactFormValuesContainer;
|
|
13
|
+
private _children;
|
|
14
|
+
get children(): BridgedFormValuesContainer[];
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of BridgedFormValuesContainer.
|
|
17
|
+
* @param responsible
|
|
18
|
+
* @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day
|
|
19
|
+
* @param contactFormValuesContainer
|
|
20
|
+
* @param interpreter
|
|
21
|
+
* @param dependentValuesProvider
|
|
22
|
+
* @param language
|
|
23
|
+
* @param changeListeners
|
|
24
|
+
*/
|
|
25
|
+
constructor(responsible: string, contactFormValuesContainer: ContactFormValuesContainer, interpreter?: (<T, S extends {
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
[key: symbol]: unknown;
|
|
28
|
+
}>(formula: string, sandbox: S) => T | undefined) | undefined, contact?: Contact, dependentValuesProvider?: (anchorId: string | undefined, templateId: string) => {
|
|
29
|
+
metadata: FieldMetadata;
|
|
30
|
+
formula: string;
|
|
31
|
+
}[], language?: string, changeListeners?: ((newValue: BridgedFormValuesContainer) => void)[]);
|
|
32
|
+
getLabel(): string;
|
|
33
|
+
getFormId(): string | undefined;
|
|
34
|
+
getContactFormValuesContainer(): ContactFormValuesContainer;
|
|
35
|
+
registerChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void;
|
|
36
|
+
unregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void;
|
|
37
|
+
getValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue>;
|
|
38
|
+
getMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata>;
|
|
39
|
+
private mutateAndNotify;
|
|
40
|
+
private computeDependentValues;
|
|
41
|
+
setValue(label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata): FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, ID>;
|
|
42
|
+
setMetadata(label: string, meta: FieldMetadata, id?: string | undefined): FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, ID>;
|
|
43
|
+
delete(serviceId: string): FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, void>;
|
|
44
|
+
private getVersionedValuesForKey;
|
|
45
|
+
compute<T, S extends {
|
|
46
|
+
[key: string | symbol]: unknown;
|
|
47
|
+
}>(formula: string, sandbox?: S): T | undefined;
|
|
48
|
+
getChildren(): FormValuesContainer<FieldValue, FieldMetadata>[];
|
|
49
|
+
addChild(anchorId: string, templateId: string, label: string): Promise<FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, BridgedFormValuesContainer>>;
|
|
50
|
+
removeChild(container: BridgedFormValuesContainer): Promise<FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, void>>;
|
|
51
|
+
}
|
|
52
|
+
export declare class ContactFormValuesContainer implements FormValuesContainer<Service, ServiceMetadata> {
|
|
53
|
+
rootForm: ICureForm;
|
|
54
|
+
currentContact: Contact;
|
|
55
|
+
contactsHistory: Contact[];
|
|
56
|
+
children: ContactFormValuesContainer[];
|
|
57
|
+
serviceFactory: (label: string, serviceId?: string) => Service;
|
|
58
|
+
formFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>;
|
|
59
|
+
changeListeners: ((newValue: ContactFormValuesContainer) => void)[];
|
|
60
|
+
constructor(rootForm: ICureForm, currentContact: Contact, contactsHistory: Contact[], serviceFactory: (label: string, serviceId?: string) => Service, children: ContactFormValuesContainer[], formFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>, changeListeners?: ((newValue: ContactFormValuesContainer) => void)[]);
|
|
61
|
+
registerChildFormValuesContainer(childFVC: ContactFormValuesContainer): void;
|
|
62
|
+
static fromFormsHierarchy(rootForm: ICureForm, currentContact: Contact, contactsHistory: Contact[], serviceFactory: (label: string, serviceId?: string) => Service, formChildrenProvider: (parentId: string) => Promise<ICureForm[]>, formFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>, changeListeners?: ((newValue: ContactFormValuesContainer) => void)[]): Promise<ContactFormValuesContainer>;
|
|
63
|
+
getLabel(): string;
|
|
64
|
+
getFormId(): string | undefined;
|
|
65
|
+
registerChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void;
|
|
66
|
+
unregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void;
|
|
67
|
+
getChildren(): ContactFormValuesContainer[];
|
|
68
|
+
getValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service>;
|
|
69
|
+
getMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata>;
|
|
70
|
+
setMetadata(label: string, meta: ServiceMetadata, id?: string): FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, ID>;
|
|
71
|
+
setValue(label: string, language: string, value?: Service, id?: string, metadata?: ServiceMetadata): FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, ID>;
|
|
72
|
+
delete(serviceId: string): FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, void>;
|
|
73
|
+
compute<T>(): T | undefined;
|
|
74
|
+
/** returns all services in history that match a selector
|
|
75
|
+
*
|
|
76
|
+
* @private
|
|
77
|
+
* @param revisionsFilter
|
|
78
|
+
*/
|
|
79
|
+
private getServicesInHistory;
|
|
80
|
+
addChild(anchorId: string, templateId: string, label: string): Promise<FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, ContactFormValuesContainer>>;
|
|
81
|
+
private getServiceInCurrentContact;
|
|
82
|
+
removeChild(container: ContactFormValuesContainer): Promise<FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, void>>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
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("../utils/icure-utils");
|
|
16
|
+
const code_utils_1 = require("../utils/code-utils");
|
|
17
|
+
const primitive_1 = require("../utils/primitive");
|
|
18
|
+
class BridgedFormValuesContainer {
|
|
19
|
+
get children() {
|
|
20
|
+
var _a;
|
|
21
|
+
return ((_a = this._children) !== null && _a !== void 0 ? _a : (this._children = this.contactFormValuesContainer
|
|
22
|
+
.getChildren()
|
|
23
|
+
.map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.dependentValuesProvider, this.language, this.changeListeners))));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates an instance of BridgedFormValuesContainer.
|
|
27
|
+
* @param responsible
|
|
28
|
+
* @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day
|
|
29
|
+
* @param contactFormValuesContainer
|
|
30
|
+
* @param interpreter
|
|
31
|
+
* @param dependentValuesProvider
|
|
32
|
+
* @param language
|
|
33
|
+
* @param changeListeners
|
|
34
|
+
*/
|
|
35
|
+
constructor(responsible, contactFormValuesContainer, interpreter, contact, dependentValuesProvider = () => [], language = 'en', changeListeners = []) {
|
|
36
|
+
this.responsible = responsible;
|
|
37
|
+
this.interpreter = interpreter;
|
|
38
|
+
this.dependentValuesProvider = dependentValuesProvider;
|
|
39
|
+
this.language = language;
|
|
40
|
+
this.changeListeners = changeListeners;
|
|
41
|
+
//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values
|
|
42
|
+
this.contactFormValuesContainer = contactFormValuesContainer;
|
|
43
|
+
this.contact = contact !== null && contact !== void 0 ? contact : contactFormValuesContainer.currentContact;
|
|
44
|
+
this.computeDependentValues();
|
|
45
|
+
}
|
|
46
|
+
getLabel() {
|
|
47
|
+
return this.contactFormValuesContainer.getLabel();
|
|
48
|
+
}
|
|
49
|
+
getFormId() {
|
|
50
|
+
return this.contactFormValuesContainer.getFormId();
|
|
51
|
+
}
|
|
52
|
+
getContactFormValuesContainer() {
|
|
53
|
+
return this.contactFormValuesContainer;
|
|
54
|
+
}
|
|
55
|
+
registerChangeListener(listener) {
|
|
56
|
+
this.changeListeners.push(listener);
|
|
57
|
+
}
|
|
58
|
+
unregisterChangeListener(listener) {
|
|
59
|
+
this.changeListeners = this.changeListeners.filter((l) => l !== listener);
|
|
60
|
+
}
|
|
61
|
+
getValues(revisionsFilter) {
|
|
62
|
+
return Object.entries(this.contactFormValuesContainer.getValues((id, history) => {
|
|
63
|
+
return revisionsFilter(id, history
|
|
64
|
+
.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)
|
|
65
|
+
.map(({ revision, modified, value: sm }) => {
|
|
66
|
+
var _a;
|
|
67
|
+
return ({
|
|
68
|
+
revision,
|
|
69
|
+
modified,
|
|
70
|
+
value: {
|
|
71
|
+
label: sm.label,
|
|
72
|
+
owner: sm.owner,
|
|
73
|
+
tags: (_a = sm.tags) === null || _a === void 0 ? void 0 : _a.map(code_utils_1.codeStubToCode),
|
|
74
|
+
valueDate: sm.valueDate,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}));
|
|
78
|
+
})).reduce((acc, [id, history]) => {
|
|
79
|
+
return Object.assign(Object.assign({}, acc), { [id]: history.map(({ revision, modified, value: s }) => {
|
|
80
|
+
var _a, _b;
|
|
81
|
+
return ({
|
|
82
|
+
revision,
|
|
83
|
+
modified,
|
|
84
|
+
value: {
|
|
85
|
+
content: Object.entries((_a = s.content) !== null && _a !== void 0 ? _a : {}).reduce((acc, [lng, cnt]) => {
|
|
86
|
+
const converted = (0, primitive_1.contentToPrimitiveType)(lng, cnt);
|
|
87
|
+
return converted ? Object.assign(Object.assign({}, acc), { [lng]: converted }) : acc;
|
|
88
|
+
}, {}),
|
|
89
|
+
codes: (_b = s.codes) === null || _b === void 0 ? void 0 : _b.map(code_utils_1.codeStubToCode),
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}) });
|
|
93
|
+
}, {});
|
|
94
|
+
}
|
|
95
|
+
getMetadata(id, revisions) {
|
|
96
|
+
return Object.entries(this.contactFormValuesContainer.getMetadata(id, revisions)).reduce((acc, [id, history]) => (Object.assign(Object.assign({}, acc), { [id]: history.map(({ revision, modified, value: s }) => ({
|
|
97
|
+
revision,
|
|
98
|
+
modified,
|
|
99
|
+
value: {
|
|
100
|
+
label: s.label,
|
|
101
|
+
owner: s.owner,
|
|
102
|
+
valueDate: s.valueDate,
|
|
103
|
+
tags: s.tags,
|
|
104
|
+
},
|
|
105
|
+
})) })), {});
|
|
106
|
+
}
|
|
107
|
+
mutateAndNotify(newContactFormValuesContainer) {
|
|
108
|
+
const newBridgedFormValueContainer = new BridgedFormValuesContainer(this.responsible, newContactFormValuesContainer, this.interpreter, this.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact, this.dependentValuesProvider, this.language, this.changeListeners);
|
|
109
|
+
this.changeListeners.forEach((l) => l(newBridgedFormValueContainer));
|
|
110
|
+
return newBridgedFormValueContainer;
|
|
111
|
+
}
|
|
112
|
+
//This method mutates the BridgedFormValuesContainer but can only be called from the constructor
|
|
113
|
+
computeDependentValues() {
|
|
114
|
+
if (this.contactFormValuesContainer.rootForm.formTemplateId) {
|
|
115
|
+
this.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, formula }) => {
|
|
116
|
+
var _a;
|
|
117
|
+
try {
|
|
118
|
+
const currentValue = this.getVersionedValuesForKey(metadata.label);
|
|
119
|
+
const newValue = this.compute(formula);
|
|
120
|
+
if (newValue !== undefined || currentValue != undefined) {
|
|
121
|
+
const lng = (_a = this.language) !== null && _a !== void 0 ? _a : 'en';
|
|
122
|
+
if (newValue && !newValue.content[lng] && newValue.content['*']) {
|
|
123
|
+
newValue.content[lng] = newValue.content['*'];
|
|
124
|
+
}
|
|
125
|
+
if (newValue) {
|
|
126
|
+
delete newValue.content['*'];
|
|
127
|
+
}
|
|
128
|
+
const currentContact = this.contactFormValuesContainer.currentContact;
|
|
129
|
+
this.contactFormValuesContainer = setValueOnContactFormValuesContainer(this.contactFormValuesContainer, metadata.label, lng, newValue, Object.keys(currentValue !== null && currentValue !== void 0 ? currentValue : {})[0], metadata).formValuesContainer;
|
|
130
|
+
if (this.contact === currentContact) {
|
|
131
|
+
this.contact = this.contactFormValuesContainer.currentContact;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
console.log(`Error while computing formula : ${formula}`, e);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
setValue(label, language, fv, id, metadata) {
|
|
142
|
+
const mutation = setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata);
|
|
143
|
+
return { result: mutation.result, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) };
|
|
144
|
+
}
|
|
145
|
+
setMetadata(label, meta, id) {
|
|
146
|
+
const mutation = this.contactFormValuesContainer.setMetadata(label, {
|
|
147
|
+
label: meta.label,
|
|
148
|
+
responsible: this.responsible,
|
|
149
|
+
owner: meta.owner,
|
|
150
|
+
valueDate: meta.valueDate,
|
|
151
|
+
tags: meta.tags,
|
|
152
|
+
}, id);
|
|
153
|
+
return { result: mutation.result, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) };
|
|
154
|
+
}
|
|
155
|
+
delete(serviceId) {
|
|
156
|
+
const mutation = this.contactFormValuesContainer.delete(serviceId);
|
|
157
|
+
return { result: undefined, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) };
|
|
158
|
+
}
|
|
159
|
+
getVersionedValuesForKey(key) {
|
|
160
|
+
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] : []); });
|
|
161
|
+
}
|
|
162
|
+
compute(formula, sandbox) {
|
|
163
|
+
var _a;
|
|
164
|
+
// noinspection JSUnusedGlobalSymbols
|
|
165
|
+
const native = {
|
|
166
|
+
parseInt: parseInt,
|
|
167
|
+
parseFloat: parseFloat,
|
|
168
|
+
Date: Date,
|
|
169
|
+
Math: Math,
|
|
170
|
+
Number: Number,
|
|
171
|
+
String: String,
|
|
172
|
+
Boolean: Boolean,
|
|
173
|
+
Array: Array,
|
|
174
|
+
Object: Object,
|
|
175
|
+
parseContent: (content) => {
|
|
176
|
+
var _a, _b;
|
|
177
|
+
if (!content) {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
const primitive = (_b = (_a = content[this.language]) !== null && _a !== void 0 ? _a : content['*']) !== null && _b !== void 0 ? _b : content[Object.keys(content)[0]];
|
|
181
|
+
return primitive && (0, primitive_1.parsePrimitive)(primitive);
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const proxy = new Proxy({}, {
|
|
185
|
+
has: (target, key) => { var _a; return !!native[key] || key === 'self' || Object.keys((_a = this.getVersionedValuesForKey(key)) !== null && _a !== void 0 ? _a : {}).length > 0; },
|
|
186
|
+
get: (target, key) => {
|
|
187
|
+
if (key === 'undefined') {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const nativeValue = native[key];
|
|
191
|
+
if (!!nativeValue) {
|
|
192
|
+
return nativeValue;
|
|
193
|
+
}
|
|
194
|
+
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; });
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
return (_a = this.interpreter) === null || _a === void 0 ? void 0 : _a.call(this, formula, sandbox !== null && sandbox !== void 0 ? sandbox : proxy);
|
|
198
|
+
}
|
|
199
|
+
getChildren() {
|
|
200
|
+
return this.contactFormValuesContainer.getChildren().map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact));
|
|
201
|
+
}
|
|
202
|
+
addChild(anchorId, templateId, label) {
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
const mutation = yield this.contactFormValuesContainer.addChild(anchorId, templateId, label);
|
|
205
|
+
const newBridgedFormValueContainer = this.mutateAndNotify(mutation.formValuesContainer);
|
|
206
|
+
const newChild = newBridgedFormValueContainer.children.find((c) => c.contactFormValuesContainer === mutation.result);
|
|
207
|
+
if (!newChild) {
|
|
208
|
+
throw new Error('Illegal state, the new child must be found');
|
|
209
|
+
}
|
|
210
|
+
return { result: newChild, formValuesContainer: newBridgedFormValueContainer };
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
removeChild(container) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const mutation = yield this.contactFormValuesContainer.removeChild(container.contactFormValuesContainer);
|
|
216
|
+
return { result: undefined, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) };
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.BridgedFormValuesContainer = BridgedFormValuesContainer;
|
|
221
|
+
class ContactFormValuesContainer {
|
|
222
|
+
constructor(rootForm, currentContact, contactsHistory, serviceFactory, children, formFactory, changeListeners = []) {
|
|
223
|
+
if (contactsHistory.includes(currentContact)) {
|
|
224
|
+
throw new Error('Illegal argument, the history must not contain the currentContact');
|
|
225
|
+
}
|
|
226
|
+
this.rootForm = rootForm;
|
|
227
|
+
this.currentContact = currentContact;
|
|
228
|
+
this.contactsHistory = (0, no_lodash_1.sortedBy)(contactsHistory, 'created', 'desc');
|
|
229
|
+
this.children = children;
|
|
230
|
+
this.serviceFactory = serviceFactory;
|
|
231
|
+
this.formFactory = formFactory;
|
|
232
|
+
this.changeListeners = changeListeners;
|
|
233
|
+
}
|
|
234
|
+
registerChildFormValuesContainer(childFVC) {
|
|
235
|
+
childFVC.registerChangeListener((newValue) => {
|
|
236
|
+
const newContactFormValuesContainer = new ContactFormValuesContainer(this.rootForm, this.currentContact, this.contactsHistory, this.serviceFactory, this.children.map((c) => (c === childFVC ? newValue : c)), this.formFactory, this.changeListeners);
|
|
237
|
+
this.changeListeners.forEach((l) => l(newContactFormValuesContainer));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
static fromFormsHierarchy(rootForm, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory, changeListeners = []) {
|
|
241
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
const contactFormValuesContainer = new ContactFormValuesContainer(rootForm, currentContact, contactsHistory, serviceFactory, rootForm.id
|
|
243
|
+
? yield Promise.all((yield formChildrenProvider(rootForm.id)).map((f) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
// eslint-disable-next-line max-len
|
|
245
|
+
return yield ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory); })))
|
|
246
|
+
: [], formFactory, changeListeners);
|
|
247
|
+
contactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC));
|
|
248
|
+
return contactFormValuesContainer;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
getLabel() {
|
|
252
|
+
var _a;
|
|
253
|
+
return (_a = this.rootForm.descr) !== null && _a !== void 0 ? _a : '';
|
|
254
|
+
}
|
|
255
|
+
getFormId() {
|
|
256
|
+
var _a;
|
|
257
|
+
return (_a = this.rootForm) === null || _a === void 0 ? void 0 : _a.formTemplateId;
|
|
258
|
+
}
|
|
259
|
+
registerChangeListener(listener) {
|
|
260
|
+
this.changeListeners.push(listener);
|
|
261
|
+
}
|
|
262
|
+
unregisterChangeListener(listener) {
|
|
263
|
+
this.changeListeners = this.changeListeners.filter((l) => l !== listener);
|
|
264
|
+
}
|
|
265
|
+
getChildren() {
|
|
266
|
+
return this.children;
|
|
267
|
+
}
|
|
268
|
+
getValues(revisionsFilter) {
|
|
269
|
+
return Object.entries(this.getServicesInHistory(revisionsFilter)).reduce((acc, [id, history]) => history.length
|
|
270
|
+
? Object.assign(Object.assign({}, acc), { [id]: [...history].sort((a, b) => ((b === null || b === void 0 ? void 0 : b.modified) || +new Date()) - ((a === null || a === void 0 ? void 0 : a.modified) || +new Date())) }) : acc, {});
|
|
271
|
+
}
|
|
272
|
+
getMetadata(id, revisions) {
|
|
273
|
+
return [this.currentContact]
|
|
274
|
+
.concat(this.contactsHistory)
|
|
275
|
+
.filter((ctc) => ctc.rev !== undefined && revisions.includes(ctc.rev))
|
|
276
|
+
.reduce((acc, ctc) => {
|
|
277
|
+
var _a, _b;
|
|
278
|
+
return (_b = ((_a = ctc.services) !== null && _a !== void 0 ? _a : [])
|
|
279
|
+
.filter((s) => s.id === id)
|
|
280
|
+
.reduce((acc, s) => {
|
|
281
|
+
var _a, _b, _c;
|
|
282
|
+
return s.id
|
|
283
|
+
? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({
|
|
284
|
+
revision: (_b = ctc.rev) !== null && _b !== void 0 ? _b : null,
|
|
285
|
+
modified: s.modified,
|
|
286
|
+
value: {
|
|
287
|
+
label: (_c = s.label) !== null && _c !== void 0 ? _c : s.id,
|
|
288
|
+
owner: s.author,
|
|
289
|
+
responsible: s.responsible,
|
|
290
|
+
valueDate: s.valueDate,
|
|
291
|
+
tags: s.tags,
|
|
292
|
+
},
|
|
293
|
+
}) }) : acc;
|
|
294
|
+
}, acc)) !== null && _b !== void 0 ? _b : acc;
|
|
295
|
+
}, {}); //index services in history by id
|
|
296
|
+
}
|
|
297
|
+
setMetadata(label, meta, id) {
|
|
298
|
+
var _a;
|
|
299
|
+
const service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(label, id);
|
|
300
|
+
if (!service.id) {
|
|
301
|
+
throw new Error('Service id must be defined');
|
|
302
|
+
}
|
|
303
|
+
if ((meta.responsible && service.responsible !== meta.responsible) ||
|
|
304
|
+
(meta.owner && service.author !== meta.owner) ||
|
|
305
|
+
(meta.valueDate && service.valueDate !== meta.valueDate) ||
|
|
306
|
+
(meta.codes && service.codes !== meta.codes) ||
|
|
307
|
+
(meta.tags && service.tags !== meta.tags)) {
|
|
308
|
+
const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
309
|
+
meta.responsible && (newService.responsible = meta.responsible);
|
|
310
|
+
meta.owner && (newService.author = meta.owner);
|
|
311
|
+
meta.valueDate && (newService.valueDate = meta.valueDate);
|
|
312
|
+
meta.codes && (newService.codes = meta.codes);
|
|
313
|
+
meta.tags && (newService.tags = meta.tags);
|
|
314
|
+
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.changeListeners);
|
|
315
|
+
this.changeListeners.forEach((l) => l(newFormValuesContainer));
|
|
316
|
+
return { result: service.id, formValuesContainer: newFormValuesContainer };
|
|
317
|
+
}
|
|
318
|
+
return { result: service.id, formValuesContainer: this };
|
|
319
|
+
}
|
|
320
|
+
setValue(label, language, value, id, metadata) {
|
|
321
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
322
|
+
const service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(label, id);
|
|
323
|
+
if (!service.id) {
|
|
324
|
+
throw new Error('Service id must be defined');
|
|
325
|
+
}
|
|
326
|
+
console.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata);
|
|
327
|
+
const newContent = (_a = value === null || value === void 0 ? void 0 : value.content) === null || _a === void 0 ? void 0 : _a[language];
|
|
328
|
+
const newCodes = (_b = value === null || value === void 0 ? void 0 : value.codes) !== null && _b !== void 0 ? _b : [];
|
|
329
|
+
if (!(0, icure_utils_1.isContentEqual)((_c = service.content) === null || _c === void 0 ? void 0 : _c[language], newContent) || (newCodes && !(0, icure_utils_1.areCodesEqual)(newCodes, (_d = service.codes) !== null && _d !== void 0 ? _d : []))) {
|
|
330
|
+
const newService = new api_1.Service(Object.assign(Object.assign({}, service), { modified: Date.now() }));
|
|
331
|
+
const newContents = newContent ? Object.assign(Object.assign({}, (service.content || {})), { [language]: newContent }) : Object.assign({}, (service.content || {}));
|
|
332
|
+
if (!newContent) {
|
|
333
|
+
delete newContents[language];
|
|
334
|
+
}
|
|
335
|
+
let newCurrentContact;
|
|
336
|
+
if (!Object.entries(newContents).filter(([_, cnt]) => cnt !== undefined).length) {
|
|
337
|
+
newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { services: ((_e = this.currentContact.services) !== null && _e !== void 0 ? _e : []).some((s) => s.id === service.id)
|
|
338
|
+
? ((_f = this.currentContact.services) !== null && _f !== void 0 ? _f : []).filter((s) => s.id !== service.id)
|
|
339
|
+
: [...((_g = this.currentContact.services) !== null && _g !== void 0 ? _g : [])] });
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
newService.content = newContents;
|
|
343
|
+
newService.codes = newCodes;
|
|
344
|
+
if (metadata) {
|
|
345
|
+
newService.responsible = (_h = metadata.responsible) !== null && _h !== void 0 ? _h : newService.responsible;
|
|
346
|
+
newService.author = (_j = metadata.owner) !== null && _j !== void 0 ? _j : newService.author;
|
|
347
|
+
newService.valueDate = (_k = metadata.valueDate) !== null && _k !== void 0 ? _k : newService.valueDate;
|
|
348
|
+
newService.tags = (_l = metadata.tags) !== null && _l !== void 0 ? _l : newService.tags;
|
|
349
|
+
newService.label = (_m = metadata.label) !== null && _m !== void 0 ? _m : newService.label;
|
|
350
|
+
}
|
|
351
|
+
newCurrentContact = Object.assign(Object.assign({}, this.currentContact), { services: ((_o = this.currentContact.services) !== null && _o !== void 0 ? _o : []).some((s) => s.id === service.id)
|
|
352
|
+
? ((_p = this.currentContact.services) !== null && _p !== void 0 ? _p : []).map((s) => (s.id === service.id ? newService : s))
|
|
353
|
+
: [...((_q = this.currentContact.services) !== null && _q !== void 0 ? _q : []), newService] });
|
|
354
|
+
}
|
|
355
|
+
const newFormValuesContainer = new ContactFormValuesContainer(this.rootForm, newCurrentContact, this.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)), this.serviceFactory, this.children, this.formFactory, this.changeListeners);
|
|
356
|
+
this.changeListeners.forEach((l) => l(newFormValuesContainer));
|
|
357
|
+
return { result: service.id, formValuesContainer: newFormValuesContainer };
|
|
358
|
+
}
|
|
359
|
+
return { result: service.id, formValuesContainer: this };
|
|
360
|
+
}
|
|
361
|
+
delete(serviceId) {
|
|
362
|
+
var _a;
|
|
363
|
+
const service = this.getServiceInCurrentContact(serviceId);
|
|
364
|
+
if (service) {
|
|
365
|
+
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 ? new api_1.Service(Object.assign(Object.assign({}, service), { endOfLife: Date.now() })) : s)) }), this.contactsHistory, this.serviceFactory, this.children, this.formFactory, this.changeListeners);
|
|
366
|
+
this.changeListeners.forEach((l) => l(newFormValuesContainer));
|
|
367
|
+
return { result: undefined, formValuesContainer: newFormValuesContainer };
|
|
368
|
+
}
|
|
369
|
+
return { result: undefined, formValuesContainer: this };
|
|
370
|
+
}
|
|
371
|
+
compute() {
|
|
372
|
+
throw new Error('Compute not supported at contact level');
|
|
373
|
+
}
|
|
374
|
+
/** returns all services in history that match a selector
|
|
375
|
+
*
|
|
376
|
+
* @private
|
|
377
|
+
* @param revisionsFilter
|
|
378
|
+
*/
|
|
379
|
+
getServicesInHistory(revisionsFilter) {
|
|
380
|
+
const indexedServices = [this.currentContact]
|
|
381
|
+
.concat(this.contactsHistory)
|
|
382
|
+
.reduce((acc, ctc) => {
|
|
383
|
+
var _a, _b;
|
|
384
|
+
return (_b = (_a = ctc.services) === null || _a === void 0 ? void 0 : _a.reduce((acc, s) => { var _a, _b; return (s.id ? Object.assign(Object.assign({}, acc), { [s.id]: ((_a = acc[s.id]) !== null && _a !== void 0 ? _a : (acc[s.id] = [])).concat({ revision: (_b = ctc.rev) !== null && _b !== void 0 ? _b : null, modified: ctc.created, value: s }) }) : acc); }, acc)) !== null && _b !== void 0 ? _b : acc;
|
|
385
|
+
}, {}); //index services in history by id
|
|
386
|
+
return Object.entries(indexedServices)
|
|
387
|
+
.map(([id, history]) => {
|
|
388
|
+
const keptRevisions = revisionsFilter(id, history.map(({ revision, modified, value: s }) => {
|
|
389
|
+
var _a, _b;
|
|
390
|
+
return ({
|
|
391
|
+
revision,
|
|
392
|
+
modified,
|
|
393
|
+
value: {
|
|
394
|
+
label: (_b = (_a = s.label) !== null && _a !== void 0 ? _a : s.id) !== null && _b !== void 0 ? _b : '',
|
|
395
|
+
owner: s.author,
|
|
396
|
+
responsible: s.responsible,
|
|
397
|
+
valueDate: s.valueDate,
|
|
398
|
+
codes: s.codes,
|
|
399
|
+
tags: s.tags,
|
|
400
|
+
},
|
|
401
|
+
});
|
|
402
|
+
}));
|
|
403
|
+
return [id, history.filter(({ revision }) => keptRevisions.includes(revision))];
|
|
404
|
+
})
|
|
405
|
+
.reduce((acc, [id, history]) => (Object.assign(Object.assign({}, acc), { [id]: history })), {});
|
|
406
|
+
}
|
|
407
|
+
addChild(anchorId, templateId, label) {
|
|
408
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
409
|
+
const newForm = yield this.formFactory(anchorId, templateId, label);
|
|
410
|
+
const childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory);
|
|
411
|
+
const newContactFormValuesContainer = new ContactFormValuesContainer(this.rootForm, this.currentContact, this.contactsHistory, this.serviceFactory, [...this.children, childFVC], this.formFactory);
|
|
412
|
+
newContactFormValuesContainer.registerChildFormValuesContainer(childFVC);
|
|
413
|
+
this.changeListeners.forEach((l) => l(newContactFormValuesContainer));
|
|
414
|
+
return { result: childFVC, formValuesContainer: newContactFormValuesContainer };
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
getServiceInCurrentContact(id) {
|
|
418
|
+
var _a;
|
|
419
|
+
const service = (_a = (this.currentContact.services || [])) === null || _a === void 0 ? void 0 : _a.find((s) => s.id === id);
|
|
420
|
+
return service !== null && service !== void 0 ? service : undefined;
|
|
421
|
+
}
|
|
422
|
+
removeChild(container) {
|
|
423
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
424
|
+
const newContactFormValuesContainer = new ContactFormValuesContainer(this.rootForm, this.currentContact, this.contactsHistory, this.serviceFactory, this.children.filter((c) => c !== container), this.formFactory);
|
|
425
|
+
this.changeListeners.forEach((l) => l(newContactFormValuesContainer));
|
|
426
|
+
return { result: undefined, formValuesContainer: newContactFormValuesContainer };
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
exports.ContactFormValuesContainer = ContactFormValuesContainer;
|
|
431
|
+
const setValueOnContactFormValuesContainer = (cfvc, label, language, fv, id, metadata) => {
|
|
432
|
+
var _a;
|
|
433
|
+
const value = fv === null || fv === void 0 ? void 0 : fv.content[language];
|
|
434
|
+
const mutation = cfvc.setValue(label, language, {
|
|
435
|
+
id: id,
|
|
436
|
+
codes: (_a = fv === null || fv === void 0 ? void 0 : fv.codes) !== null && _a !== void 0 ? _a : [],
|
|
437
|
+
content: value
|
|
438
|
+
? {
|
|
439
|
+
[language]: (0, primitive_1.primitiveTypeToContent)(language, value),
|
|
440
|
+
}
|
|
441
|
+
: undefined,
|
|
442
|
+
}, id, metadata);
|
|
443
|
+
return mutation;
|
|
444
|
+
};
|
|
445
|
+
//# sourceMappingURL=form-values-container.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-values-container.js","sourceRoot":"","sources":["../../tmp/icure/form-values-container.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAgE;AAChE,kDAA6C;AAI7C,sDAAoE;AACpE,oDAAoD;AACpD,kDAAm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OAAO,CAAC,QAAQ,CAAC,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAC7B,KAAK,EACL,QAAQ,EACR;QACC,EAAE,EAAE,EAAE;QACN,KAAK,EAAE,MAAA,EAAE,aAAF,EAAE,uBAAF,EAAE,CAAE,KAAK,mCAAI,EAAE;QACtB,OAAO,EAAE,KAAK;YACb,CAAC,CAAC;gBACA,CAAC,QAAQ,CAAC,EAAE,IAAA,kCAAsB,EAAC,QAAQ,EAAE,KAAK,CAAC;aAClD;YACH,CAAC,CAAC,SAAS;KACZ,EACD,EAAE,EACF,QAAQ,CACR,CAAA;IACD,OAAO,QAAQ,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { Contact, Form as ICureForm, Service } from '@icure/api'\nimport { sortedBy } from '../utils/no-lodash'\nimport { FormValuesContainer, FormValuesContainerMutation, ID, Version, VersionedData } from '../generic'\nimport { ServiceMetadata } from '../icure'\nimport { FieldMetadata, FieldValue, PrimitiveType } from '../components/model'\nimport { areCodesEqual, isContentEqual } from '../utils/icure-utils'\nimport { codeStubToCode } from '../utils/code-utils'\nimport { contentToPrimitiveType, parsePrimitive, primitiveTypeToContent } from '../utils/primitive'\n\nexport class BridgedFormValuesContainer implements FormValuesContainer<FieldValue, FieldMetadata> {\n\tprivate contact: Contact\n\tprivate contactFormValuesContainer: ContactFormValuesContainer\n\tprivate _children: BridgedFormValuesContainer[] | undefined\n\tget children(): BridgedFormValuesContainer[] {\n\t\treturn (\n\t\t\tthis._children ??\n\t\t\t(this._children = this.contactFormValuesContainer\n\t\t\t\t.getChildren()\n\t\t\t\t.map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact, this.dependentValuesProvider, this.language, this.changeListeners)))\n\t\t)\n\t}\n\n\t/**\n\t * Creates an instance of BridgedFormValuesContainer.\n\t * @param responsible\n\t * @param contact The displayed contact (may be in the past). === to currentContact if the contact is the contact of the day\n\t * @param contactFormValuesContainer\n\t * @param interpreter\n\t * @param dependentValuesProvider\n\t * @param language\n\t * @param changeListeners\n\t */\n\tconstructor(\n\t\tprivate responsible: string,\n\t\tcontactFormValuesContainer: ContactFormValuesContainer,\n\t\tprivate interpreter?: <\n\t\t\tT,\n\t\t\tS extends {\n\t\t\t\t[key: string | symbol]: unknown\n\t\t\t},\n\t\t>(\n\t\t\tformula: string,\n\t\t\tsandbox: S,\n\t\t) => T | undefined,\n\t\tcontact?: Contact,\n\t\tprivate dependentValuesProvider: (anchorId: string | undefined, templateId: string) => { metadata: FieldMetadata; formula: string }[] = () => [],\n\t\tprivate language = 'en',\n\t\tprivate changeListeners: ((newValue: BridgedFormValuesContainer) => void)[] = [],\n\t) {\n\t\t//Before start to broadcast changes, we need to fill in the contactFormValuesContainer with the dependent values\n\t\tthis.contactFormValuesContainer = contactFormValuesContainer\n\t\tthis.contact = contact ?? contactFormValuesContainer.currentContact\n\t\tthis.computeDependentValues()\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.contactFormValuesContainer.getLabel()\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.contactFormValuesContainer.getFormId()\n\t}\n\n\tgetContactFormValuesContainer() {\n\t\treturn this.contactFormValuesContainer\n\t}\n\n\tregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: BridgedFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<FieldMetadata>[]) => (string | null)[]): VersionedData<FieldValue> {\n\t\treturn Object.entries(\n\t\t\tthis.contactFormValuesContainer.getValues((id, history) => {\n\t\t\t\treturn revisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory\n\t\t\t\t\t\t.filter(({ modified }) => !this.contact.created || !modified || modified <= this.contact.created)\n\t\t\t\t\t\t.map(({ revision, modified, value: sm }) => ({\n\t\t\t\t\t\t\trevision,\n\t\t\t\t\t\t\tmodified,\n\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\tlabel: sm.label,\n\t\t\t\t\t\t\t\towner: sm.owner,\n\t\t\t\t\t\t\t\ttags: sm.tags?.map(codeStubToCode),\n\t\t\t\t\t\t\t\tvalueDate: sm.valueDate,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t})),\n\t\t\t\t)\n\t\t\t}),\n\t\t).reduce((acc, [id, history]) => {\n\t\t\treturn {\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontent: Object.entries(s.content ?? {}).reduce((acc, [lng, cnt]) => {\n\t\t\t\t\t\t\tconst converted = contentToPrimitiveType(lng, cnt)\n\t\t\t\t\t\t\treturn converted ? { ...acc, [lng]: converted } : acc\n\t\t\t\t\t\t}, {}),\n\t\t\t\t\t\tcodes: s.codes?.map(codeStubToCode),\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}\n\t\t}, {} as VersionedData<FieldValue>)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<FieldMetadata> {\n\t\treturn Object.entries(this.contactFormValuesContainer.getMetadata(id, revisions)).reduce(\n\t\t\t(acc, [id, history]) => ({\n\t\t\t\t...acc,\n\t\t\t\t[id]: history.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\trevision,\n\t\t\t\t\tmodified,\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tlabel: s.label,\n\t\t\t\t\t\towner: s.owner,\n\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t},\n\t\t\t\t})),\n\t\t\t}),\n\t\t\t{},\n\t\t)\n\t}\n\n\tprivate mutateAndNotify(newContactFormValuesContainer: ContactFormValuesContainer) {\n\t\tconst newBridgedFormValueContainer = new BridgedFormValuesContainer(\n\t\t\tthis.responsible,\n\t\t\tnewContactFormValuesContainer,\n\t\t\tthis.interpreter,\n\t\t\tthis.contact === this.contactFormValuesContainer.currentContact ? newContactFormValuesContainer.currentContact : this.contact,\n\t\t\tthis.dependentValuesProvider,\n\t\t\tthis.language,\n\t\t\tthis.changeListeners,\n\t\t)\n\t\tthis.changeListeners.forEach((l) => l(newBridgedFormValueContainer))\n\t\treturn newBridgedFormValueContainer\n\t}\n\n\t//This method mutates the BridgedFormValuesContainer but can only be called from the constructor\n\tprivate computeDependentValues() {\n\t\tif (this.contactFormValuesContainer.rootForm.formTemplateId) {\n\t\t\tthis.dependentValuesProvider(this.contactFormValuesContainer.rootForm.descr, this.contactFormValuesContainer.rootForm.formTemplateId).forEach(({ metadata, formula }) => {\n\t\t\t\ttry {\n\t\t\t\t\tconst currentValue = this.getVersionedValuesForKey(metadata.label)\n\t\t\t\t\tconst newValue = this.compute(formula) as FieldValue | undefined\n\t\t\t\t\tif (newValue !== undefined || currentValue != undefined) {\n\t\t\t\t\t\tconst lng = this.language ?? 'en'\n\t\t\t\t\t\tif (newValue && !newValue.content[lng] && newValue.content['*']) {\n\t\t\t\t\t\t\tnewValue.content[lng] = newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (newValue) {\n\t\t\t\t\t\t\tdelete newValue.content['*']\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst currentContact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\tthis.contactFormValuesContainer = setValueOnContactFormValuesContainer(\n\t\t\t\t\t\t\tthis.contactFormValuesContainer,\n\t\t\t\t\t\t\tmetadata.label,\n\t\t\t\t\t\t\tlng,\n\t\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\t\tObject.keys(currentValue ?? {})[0],\n\t\t\t\t\t\t\tmetadata,\n\t\t\t\t\t\t).formValuesContainer\n\t\t\t\t\t\tif (this.contact === currentContact) {\n\t\t\t\t\t\t\tthis.contact = this.contactFormValuesContainer.currentContact\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.log(`Error while computing formula : ${formula}`, e)\n\t\t\t\t}\n\t\t\t})\n\t\t}\n\t}\n\n\tsetValue(\n\t\tlabel: string,\n\t\tlanguage: string,\n\t\tfv?: FieldValue,\n\t\tid?: string,\n\t\tmetadata?: FieldMetadata,\n\t): FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, ID> {\n\t\tconst mutation = setValueOnContactFormValuesContainer(this.contactFormValuesContainer, label, language, fv, id, metadata)\n\t\treturn { result: mutation.result, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) }\n\t}\n\n\tsetMetadata(label: string, meta: FieldMetadata, id?: string | undefined): FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, ID> {\n\t\tconst mutation = this.contactFormValuesContainer.setMetadata(\n\t\t\tlabel,\n\t\t\t{\n\t\t\t\tlabel: meta.label,\n\t\t\t\tresponsible: this.responsible,\n\t\t\t\towner: meta.owner,\n\t\t\t\tvalueDate: meta.valueDate,\n\t\t\t\ttags: meta.tags,\n\t\t\t},\n\t\t\tid,\n\t\t)\n\t\treturn { result: mutation.result, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) }\n\t}\n\n\tdelete(serviceId: string): FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, void> {\n\t\tconst mutation = this.contactFormValuesContainer.delete(serviceId)\n\t\treturn { result: undefined, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) }\n\t}\n\n\tprivate getVersionedValuesForKey(key: string | symbol) {\n\t\treturn this.getValues((id, history) => (history?.[0]?.value?.label && key === history[0].value.label ? [history?.[0]?.revision] : []))\n\t}\n\n\tcompute<T, S extends { [key: string | symbol]: unknown }>(formula: string, sandbox?: S): T | undefined {\n\t\t// noinspection JSUnusedGlobalSymbols\n\t\tconst native = {\n\t\t\tparseInt: parseInt,\n\t\t\tparseFloat: parseFloat,\n\t\t\tDate: Date,\n\t\t\tMath: Math,\n\t\t\tNumber: Number,\n\t\t\tString: String,\n\t\t\tBoolean: Boolean,\n\t\t\tArray: Array,\n\t\t\tObject: Object,\n\t\t\tparseContent: (content?: { [key: string]: PrimitiveType }) => {\n\t\t\t\tif (!content) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst primitive = content[this.language] ?? content['*'] ?? content[Object.keys(content)[0]]\n\t\t\t\treturn primitive && parsePrimitive(primitive)\n\t\t\t},\n\t\t}\n\t\tconst proxy: S = new Proxy({} as S, {\n\t\t\thas: (target: S, key: string | symbol) => !!native[key] || key === 'self' || Object.keys(this.getVersionedValuesForKey(key) ?? {}).length > 0,\n\t\t\tget: (target: S, key: string | symbol) => {\n\t\t\t\tif (key === 'undefined') {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\t\t\t\tconst nativeValue = native[key]\n\t\t\t\tif (!!nativeValue) {\n\t\t\t\t\treturn nativeValue\n\t\t\t\t}\n\t\t\t\treturn key === 'self' ? proxy : Object.values(this.getVersionedValuesForKey(key)).map((v) => v[0]?.value)\n\t\t\t},\n\t\t})\n\t\treturn this.interpreter?.(formula, sandbox ?? proxy)\n\t}\n\n\tgetChildren(): FormValuesContainer<FieldValue, FieldMetadata>[] {\n\t\treturn this.contactFormValuesContainer.getChildren().map((fvc) => new BridgedFormValuesContainer(this.responsible, fvc, this.interpreter, this.contact))\n\t}\n\n\tasync addChild(\n\t\tanchorId: string,\n\t\ttemplateId: string,\n\t\tlabel: string,\n\t): Promise<FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, BridgedFormValuesContainer>> {\n\t\tconst mutation = await this.contactFormValuesContainer.addChild(anchorId, templateId, label)\n\t\tconst newBridgedFormValueContainer = this.mutateAndNotify(mutation.formValuesContainer)\n\t\tconst newChild = newBridgedFormValueContainer.children.find((c) => c.contactFormValuesContainer === mutation.result)\n\t\tif (!newChild) {\n\t\t\tthrow new Error('Illegal state, the new child must be found')\n\t\t}\n\t\treturn { result: newChild, formValuesContainer: newBridgedFormValueContainer }\n\t}\n\n\tasync removeChild(container: BridgedFormValuesContainer): Promise<FormValuesContainerMutation<FieldValue, FieldMetadata, BridgedFormValuesContainer, void>> {\n\t\tconst mutation = await this.contactFormValuesContainer.removeChild(container.contactFormValuesContainer)\n\t\treturn { result: undefined, formValuesContainer: this.mutateAndNotify(mutation.formValuesContainer) }\n\t}\n}\n\nexport class ContactFormValuesContainer implements FormValuesContainer<Service, ServiceMetadata> {\n\trootForm: ICureForm\n\tcurrentContact: Contact //The contact of the moment, used to record new modifications\n\tcontactsHistory: Contact[] //Must be sorted (most recent first), contains all the contacts linked to this form\n\tchildren: ContactFormValuesContainer[] //Direct children of the ContactFormValuesContainer\n\tserviceFactory: (label: string, serviceId?: string) => Service\n\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>\n\n\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[]\n\n\tconstructor(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tchildren: ContactFormValuesContainer[],\n\t\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t) {\n\t\tif (contactsHistory.includes(currentContact)) {\n\t\t\tthrow new Error('Illegal argument, the history must not contain the currentContact')\n\t\t}\n\t\tthis.rootForm = rootForm\n\t\tthis.currentContact = currentContact\n\t\tthis.contactsHistory = sortedBy(contactsHistory, 'created', 'desc')\n\t\tthis.children = children\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.formFactory = formFactory\n\t\tthis.changeListeners = changeListeners\n\t}\n\n\tregisterChildFormValuesContainer(childFVC: ContactFormValuesContainer) {\n\t\tchildFVC.registerChangeListener((newValue) => {\n\t\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\tthis.currentContact,\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children.map((c) => (c === childFVC ? newValue : c)),\n\t\t\t\tthis.formFactory,\n\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\t\t\tthis.changeListeners.forEach((l) => l(newContactFormValuesContainer))\n\t\t})\n\t}\n\n\tstatic async fromFormsHierarchy(\n\t\trootForm: ICureForm,\n\t\tcurrentContact: Contact,\n\t\tcontactsHistory: Contact[],\n\t\tserviceFactory: (label: string, serviceId?: string) => Service,\n\t\tformChildrenProvider: (parentId: string) => Promise<ICureForm[]>,\n\t\tformFactory: (anchorId: string, formTemplateId: string, label: string) => Promise<ICureForm>,\n\t\tchangeListeners: ((newValue: ContactFormValuesContainer) => void)[] = [],\n\t): Promise<ContactFormValuesContainer> {\n\t\tconst contactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\trootForm,\n\t\t\tcurrentContact,\n\t\t\tcontactsHistory,\n\t\t\tserviceFactory,\n\t\t\trootForm.id\n\t\t\t\t? await Promise.all(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\tawait formChildrenProvider(rootForm.id)\n\t\t\t\t\t\t).map(\n\t\t\t\t\t\t\tasync (f) =>\n\t\t\t\t\t\t\t\t// eslint-disable-next-line max-len\n\t\t\t\t\t\t\t\tawait ContactFormValuesContainer.fromFormsHierarchy(f, currentContact, contactsHistory, serviceFactory, formChildrenProvider, formFactory),\n\t\t\t\t\t\t),\n\t\t\t\t )\n\t\t\t\t: [],\n\t\t\tformFactory,\n\n\t\t\tchangeListeners,\n\t\t)\n\t\tcontactFormValuesContainer.children.forEach((childFVC) => contactFormValuesContainer.registerChildFormValuesContainer(childFVC))\n\n\t\treturn contactFormValuesContainer\n\t}\n\n\tgetLabel(): string {\n\t\treturn this.rootForm.descr ?? ''\n\t}\n\n\tgetFormId(): string | undefined {\n\t\treturn this.rootForm?.formTemplateId\n\t}\n\n\tregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners.push(listener)\n\t}\n\n\tunregisterChangeListener(listener: (newValue: ContactFormValuesContainer) => void): void {\n\t\tthis.changeListeners = this.changeListeners.filter((l) => l !== listener)\n\t}\n\n\tgetChildren(): ContactFormValuesContainer[] {\n\t\treturn this.children\n\t}\n\n\tgetValues(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\treturn Object.entries(this.getServicesInHistory(revisionsFilter)).reduce(\n\t\t\t(acc, [id, history]) =>\n\t\t\t\thistory.length\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t[id]: [...history].sort((a, b) => (b?.modified || +new Date()) - (a?.modified || +new Date())),\n\t\t\t\t\t }\n\t\t\t\t\t: acc,\n\t\t\t{},\n\t\t)\n\t}\n\n\tgetMetadata(id: string, revisions: (string | null)[]): VersionedData<ServiceMetadata> {\n\t\treturn [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.filter((ctc) => ctc.rev !== undefined && revisions.includes(ctc.rev))\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\t(ctc.services ?? [])\n\t\t\t\t\t\t.filter((s) => s.id === id)\n\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t(acc, s) =>\n\t\t\t\t\t\t\t\ts.id\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t...acc,\n\t\t\t\t\t\t\t\t\t\t\t[s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({\n\t\t\t\t\t\t\t\t\t\t\t\trevision: ctc.rev ?? null,\n\t\t\t\t\t\t\t\t\t\t\t\tmodified: s.modified,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: s.label ?? s.id,\n\t\t\t\t\t\t\t\t\t\t\t\t\towner: s.author,\n\t\t\t\t\t\t\t\t\t\t\t\t\tresponsible: s.responsible,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t: acc,\n\t\t\t\t\t\t\tacc,\n\t\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as { [id: string]: Version<ServiceMetadata>[] },\n\t\t\t) //index services in history by id\n\t}\n\n\tsetMetadata(label: string, meta: ServiceMetadata, id?: string): FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, ID> {\n\t\tconst service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tif (\n\t\t\t(meta.responsible && service.responsible !== meta.responsible) ||\n\t\t\t(meta.owner && service.author !== meta.owner) ||\n\t\t\t(meta.valueDate && service.valueDate !== meta.valueDate) ||\n\t\t\t(meta.codes && service.codes !== meta.codes) ||\n\t\t\t(meta.tags && service.tags !== meta.tags)\n\t\t) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tmeta.responsible && (newService.responsible = meta.responsible)\n\t\t\tmeta.owner && (newService.author = meta.owner)\n\t\t\tmeta.valueDate && (newService.valueDate = meta.valueDate)\n\t\t\tmeta.codes && (newService.codes = meta.codes)\n\t\t\tmeta.tags && (newService.tags = meta.tags)\n\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{ ...this.currentContact, services: this.currentContact.services?.map((s) => (s.id === service.id ? newService : s)) },\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => l(newFormValuesContainer))\n\t\t\treturn { result: service.id, formValuesContainer: newFormValuesContainer }\n\t\t}\n\n\t\treturn { result: service.id, formValuesContainer: this }\n\t}\n\n\tsetValue(\n\t\tlabel: string,\n\t\tlanguage: string,\n\t\tvalue?: Service,\n\t\tid?: string,\n\t\tmetadata?: ServiceMetadata,\n\t): FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, ID> {\n\t\tconst service = (id && this.getServiceInCurrentContact(id)) || this.serviceFactory(label, id)\n\t\tif (!service.id) {\n\t\t\tthrow new Error('Service id must be defined')\n\t\t}\n\t\tconsole.log('Setting value of service', service.id, 'with', value, 'and metadata', metadata)\n\t\tconst newContent = value?.content?.[language]\n\t\tconst newCodes = value?.codes ?? []\n\t\tif (!isContentEqual(service.content?.[language], newContent) || (newCodes && !areCodesEqual(newCodes, service.codes ?? []))) {\n\t\t\tconst newService = new Service({ ...service, modified: Date.now() })\n\t\t\tconst newContents = newContent ? { ...(service.content || {}), [language]: newContent } : { ...(service.content || {}) }\n\t\t\tif (!newContent) {\n\t\t\t\tdelete newContents[language]\n\t\t\t}\n\n\t\t\tlet newCurrentContact: Contact\n\t\t\tif (!Object.entries(newContents).filter(([_, cnt]) => cnt !== undefined).length) {\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).filter((s) => s.id !== service.id)\n\t\t\t\t\t\t: [...(this.currentContact.services ?? [])],\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tnewService.content = newContents\n\t\t\t\tnewService.codes = newCodes\n\n\t\t\t\tif (metadata) {\n\t\t\t\t\tnewService.responsible = metadata.responsible ?? newService.responsible\n\t\t\t\t\tnewService.author = metadata.owner ?? newService.author\n\t\t\t\t\tnewService.valueDate = metadata.valueDate ?? newService.valueDate\n\t\t\t\t\tnewService.tags = metadata.tags ?? newService.tags\n\t\t\t\t\tnewService.label = metadata.label ?? newService.label\n\t\t\t\t}\n\n\t\t\t\tnewCurrentContact = {\n\t\t\t\t\t...this.currentContact,\n\t\t\t\t\tservices: (this.currentContact.services ?? []).some((s) => s.id === service.id)\n\t\t\t\t\t\t? (this.currentContact.services ?? []).map((s) => (s.id === service.id ? newService : s))\n\t\t\t\t\t\t: [...(this.currentContact.services ?? []), newService],\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\tnewCurrentContact,\n\t\t\t\tthis.contactsHistory.map((c) => (c === this.currentContact ? newCurrentContact : c)),\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => l(newFormValuesContainer))\n\n\t\t\treturn { result: service.id!, formValuesContainer: newFormValuesContainer }\n\t\t}\n\n\t\treturn { result: service.id, formValuesContainer: this }\n\t}\n\n\tdelete(serviceId: string): FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, void> {\n\t\tconst service = this.getServiceInCurrentContact(serviceId)\n\t\tif (service) {\n\t\t\tconst newFormValuesContainer = new ContactFormValuesContainer(\n\t\t\t\tthis.rootForm,\n\t\t\t\t{ ...this.currentContact, services: this.currentContact.services?.map((s) => (s.id === serviceId ? new Service({ ...service, endOfLife: Date.now() }) : s)) },\n\t\t\t\tthis.contactsHistory,\n\t\t\t\tthis.serviceFactory,\n\t\t\t\tthis.children,\n\t\t\t\tthis.formFactory,\n\n\t\t\t\tthis.changeListeners,\n\t\t\t)\n\n\t\t\tthis.changeListeners.forEach((l) => l(newFormValuesContainer))\n\t\t\treturn { result: undefined, formValuesContainer: newFormValuesContainer }\n\t\t}\n\t\treturn { result: undefined, formValuesContainer: this }\n\t}\n\n\tcompute<T>(): T | undefined {\n\t\tthrow new Error('Compute not supported at contact level')\n\t}\n\n\t/** returns all services in history that match a selector\n\t *\n\t * @private\n\t * @param revisionsFilter\n\t */\n\tprivate getServicesInHistory(revisionsFilter: (id: string, history: Version<ServiceMetadata>[]) => (string | null)[]): VersionedData<Service> {\n\t\tconst indexedServices = [this.currentContact]\n\t\t\t.concat(this.contactsHistory)\n\t\t\t.reduce(\n\t\t\t\t(acc, ctc) =>\n\t\t\t\t\tctc.services?.reduce(\n\t\t\t\t\t\t(acc, s) => (s.id ? { ...acc, [s.id]: (acc[s.id] ?? (acc[s.id] = [])).concat({ revision: ctc.rev ?? null, modified: ctc.created, value: s }) } : acc),\n\t\t\t\t\t\tacc,\n\t\t\t\t\t) ?? acc,\n\t\t\t\t{} as VersionedData<Service>,\n\t\t\t) //index services in history by id\n\t\treturn Object.entries(indexedServices)\n\t\t\t.map(([id, history]) => {\n\t\t\t\tconst keptRevisions = revisionsFilter(\n\t\t\t\t\tid,\n\t\t\t\t\thistory.map(({ revision, modified, value: s }) => ({\n\t\t\t\t\t\trevision,\n\t\t\t\t\t\tmodified,\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tlabel: s.label ?? s.id ?? '',\n\t\t\t\t\t\t\towner: s.author,\n\t\t\t\t\t\t\tresponsible: s.responsible,\n\t\t\t\t\t\t\tvalueDate: s.valueDate,\n\t\t\t\t\t\t\tcodes: s.codes,\n\t\t\t\t\t\t\ttags: s.tags,\n\t\t\t\t\t\t},\n\t\t\t\t\t})),\n\t\t\t\t)\n\t\t\t\treturn [id, history.filter(({ revision }) => keptRevisions.includes(revision))] as [string, Version<Service>[]]\n\t\t\t})\n\t\t\t.reduce((acc, [id, history]) => ({ ...acc, [id]: history }), {})\n\t}\n\n\tasync addChild(\n\t\tanchorId: string,\n\t\ttemplateId: string,\n\t\tlabel: string,\n\t): Promise<FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, ContactFormValuesContainer>> {\n\t\tconst newForm = await this.formFactory(anchorId, templateId, label)\n\t\tconst childFVC = new ContactFormValuesContainer(newForm, this.currentContact, this.contactsHistory, this.serviceFactory, [], this.formFactory)\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\t[...this.children, childFVC],\n\t\t\tthis.formFactory,\n\t\t)\n\t\tnewContactFormValuesContainer.registerChildFormValuesContainer(childFVC)\n\t\tthis.changeListeners.forEach((l) => l(newContactFormValuesContainer))\n\t\treturn { result: childFVC, formValuesContainer: newContactFormValuesContainer }\n\t}\n\n\tprivate getServiceInCurrentContact(id: string): Service | undefined {\n\t\tconst service = (this.currentContact.services || [])?.find((s) => s.id === id)\n\t\treturn service ?? undefined\n\t}\n\n\tasync removeChild(container: ContactFormValuesContainer): Promise<FormValuesContainerMutation<Service, ServiceMetadata, ContactFormValuesContainer, void>> {\n\t\tconst newContactFormValuesContainer = new ContactFormValuesContainer(\n\t\t\tthis.rootForm,\n\t\t\tthis.currentContact,\n\t\t\tthis.contactsHistory,\n\t\t\tthis.serviceFactory,\n\t\t\tthis.children.filter((c) => c !== container),\n\t\t\tthis.formFactory,\n\t\t)\n\t\tthis.changeListeners.forEach((l) => l(newContactFormValuesContainer))\n\t\treturn { result: undefined, formValuesContainer: newContactFormValuesContainer }\n\t}\n}\n\nconst setValueOnContactFormValuesContainer = (cfvc: ContactFormValuesContainer, label: string, language: string, fv?: FieldValue, id?: string, metadata?: FieldMetadata) => {\n\tconst value = fv?.content[language]\n\tconst mutation = cfvc.setValue(\n\t\tlabel,\n\t\tlanguage,\n\t\t{\n\t\t\tid: id,\n\t\t\tcodes: fv?.codes ?? [],\n\t\t\tcontent: value\n\t\t\t\t? {\n\t\t\t\t\t\t[language]: primitiveTypeToContent(language, value),\n\t\t\t\t }\n\t\t\t\t: undefined,\n\t\t},\n\t\tid,\n\t\tmetadata,\n\t)\n\treturn mutation\n}\n"]}
|
package/icure/index.d.ts
ADDED