@defra/forms-model 3.0.10 → 3.0.12
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/dist/module/components/component-types.js +1 -5
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/conditional-component-types.js +1 -5
- package/dist/module/components/conditional-component-types.js.map +1 -1
- package/dist/module/components/enums.js +1 -5
- package/dist/module/components/enums.js.map +1 -1
- package/dist/module/components/index.js +3 -24
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/types.js +1 -1
- package/dist/module/conditions/condition-abstract.js +3 -8
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -8
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +1 -6
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +4 -9
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-model.js +20 -25
- package/dist/module/conditions/condition-model.js.map +1 -1
- package/dist/module/conditions/condition-operators.js +15 -23
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -7
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +3 -8
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -6
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +12 -20
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +9 -14
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/enums.js +1 -5
- package/dist/module/conditions/enums.js.map +1 -1
- package/dist/module/conditions/helpers.js +2 -7
- package/dist/module/conditions/helpers.js.map +1 -1
- package/dist/module/conditions/index.js +10 -139
- package/dist/module/conditions/index.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +15 -26
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-operators.js +15 -23
- package/dist/module/conditions/inline-condition-operators.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +9 -17
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/conditions/types.js +1 -1
- package/dist/module/conditions/types.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -8
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/enums.js +1 -5
- package/dist/module/data-model/enums.js.map +1 -1
- package/dist/module/data-model/index.js +3 -24
- package/dist/module/data-model/index.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +3 -8
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/data-model/types.js +1 -5
- package/dist/module/data-model/types.js.map +1 -1
- package/dist/module/form/form-configuration.js +1 -6
- package/dist/module/form/form-configuration.js.map +1 -1
- package/dist/module/form/index.js +1 -10
- package/dist/module/form/index.js.map +1 -1
- package/dist/module/index.js +8 -91
- package/dist/module/index.js.map +1 -1
- package/dist/module/migration/index.js +1 -10
- package/dist/module/migration/index.js.map +1 -1
- package/dist/module/migration/migration.0-2.js +1 -5
- package/dist/module/migration/migration.0-2.js.map +1 -1
- package/dist/module/migration/migration.1-2.js +3 -6
- package/dist/module/migration/migration.1-2.js.map +1 -1
- package/dist/module/migration/types.js +1 -1
- package/dist/module/migration/whichMigrations.js +5 -9
- package/dist/module/migration/whichMigrations.js.map +1 -1
- package/dist/module/schema/index.js +1 -16
- package/dist/module/schema/index.js.map +1 -1
- package/dist/module/schema/schema.js +163 -167
- package/dist/module/schema/schema.js.map +1 -1
- package/dist/module/utils/helpers.js +5 -13
- package/dist/module/utils/helpers.js.map +1 -1
- package/dist/module/utils/logger.js +1 -6
- package/dist/module/utils/logger.js.map +1 -1
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/conditional-component-types.d.ts +1 -1
- package/dist/types/components/conditional-component-types.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/conditions/condition-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-field.d.ts +1 -1
- package/dist/types/conditions/condition-field.d.ts.map +1 -1
- package/dist/types/conditions/condition-group-def.d.ts +2 -2
- package/dist/types/conditions/condition-group-def.d.ts.map +1 -1
- package/dist/types/conditions/condition-group.d.ts +2 -2
- package/dist/types/conditions/condition-group.d.ts.map +1 -1
- package/dist/types/conditions/condition-model.d.ts +5 -5
- package/dist/types/conditions/condition-model.d.ts.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +2 -2
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/conditions/condition-ref.d.ts +2 -2
- package/dist/types/conditions/condition-ref.d.ts.map +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-values.d.ts +3 -3
- package/dist/types/conditions/condition-values.d.ts.map +1 -1
- package/dist/types/conditions/condition.d.ts +4 -4
- package/dist/types/conditions/condition.d.ts.map +1 -1
- package/dist/types/conditions/index.d.ts +10 -10
- package/dist/types/conditions/index.d.ts.map +1 -1
- package/dist/types/conditions/types.d.ts +3 -3
- package/dist/types/conditions/types.d.ts.map +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/index.d.ts +3 -3
- package/dist/types/data-model/index.d.ts.map +1 -1
- package/dist/types/data-model/input-wrapper.d.ts +2 -2
- package/dist/types/data-model/input-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/types.d.ts +3 -3
- package/dist/types/data-model/types.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migration/index.d.ts +1 -1
- package/dist/types/migration/index.d.ts.map +1 -1
- package/dist/types/migration/migration.0-2.d.ts +1 -1
- package/dist/types/migration/migration.0-2.d.ts.map +1 -1
- package/dist/types/migration/migration.1-2.d.ts +1 -1
- package/dist/types/migration/migration.1-2.d.ts.map +1 -1
- package/dist/types/migration/whichMigrations.d.ts +1 -1
- package/dist/types/migration/whichMigrations.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/package.json +3 -4
- package/src/components/component-types.ts +1 -1
- package/src/components/conditional-component-types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/conditions/condition-abstract.ts +1 -1
- package/src/conditions/condition-field.ts +2 -2
- package/src/conditions/condition-group-def.ts +1 -1
- package/src/conditions/condition-group.ts +3 -3
- package/src/conditions/condition-model.ts +9 -9
- package/src/conditions/condition-operators.ts +6 -3
- package/src/conditions/condition-ref.ts +2 -2
- package/src/conditions/condition-value-abstract.ts +1 -1
- package/src/conditions/condition-values.ts +3 -3
- package/src/conditions/condition.ts +6 -6
- package/src/conditions/index.ts +10 -10
- package/src/conditions/inline-condition-model.ts +3 -3
- package/src/conditions/inline-condition-operators.ts +1 -1
- package/src/conditions/types.ts +3 -3
- package/src/data-model/conditions-wrapper.ts +2 -2
- package/src/data-model/index.ts +3 -3
- package/src/data-model/input-wrapper.ts +3 -3
- package/src/data-model/types.ts +3 -3
- package/src/form/index.ts +1 -1
- package/src/index.ts +11 -11
- package/src/migration/index.ts +1 -1
- package/src/migration/migration.0-2.ts +1 -1
- package/src/migration/migration.1-2.ts +2 -2
- package/src/migration/whichMigrations.ts +3 -3
- package/src/schema/index.ts +1 -1
- package/dist/browser/components/component-types.js +0 -220
- package/dist/browser/components/component-types.js.map +0 -1
- package/dist/browser/components/conditional-component-types.js +0 -28
- package/dist/browser/components/conditional-component-types.js.map +0 -1
- package/dist/browser/components/enums.js +0 -46
- package/dist/browser/components/enums.js.map +0 -1
- package/dist/browser/components/index.js +0 -36
- package/dist/browser/components/index.js.map +0 -1
- package/dist/browser/components/types.js +0 -16
- package/dist/browser/components/types.js.map +0 -1
- package/dist/browser/conditions/condition-abstract.js +0 -62
- package/dist/browser/conditions/condition-abstract.js.map +0 -1
- package/dist/browser/conditions/condition-field.js +0 -45
- package/dist/browser/conditions/condition-field.js.map +0 -1
- package/dist/browser/conditions/condition-group-def.js +0 -45
- package/dist/browser/conditions/condition-group-def.js.map +0 -1
- package/dist/browser/conditions/condition-group.js +0 -64
- package/dist/browser/conditions/condition-group.js.map +0 -1
- package/dist/browser/conditions/condition-model.js +0 -214
- package/dist/browser/conditions/condition-model.js.map +0 -1
- package/dist/browser/conditions/condition-operators.js +0 -132
- package/dist/browser/conditions/condition-operators.js.map +0 -1
- package/dist/browser/conditions/condition-ref.js +0 -51
- package/dist/browser/conditions/condition-ref.js.map +0 -1
- package/dist/browser/conditions/condition-value-abstract.js +0 -41
- package/dist/browser/conditions/condition-value-abstract.js.map +0 -1
- package/dist/browser/conditions/condition-value-registration.js +0 -37
- package/dist/browser/conditions/condition-value-registration.js.map +0 -1
- package/dist/browser/conditions/condition-values.js +0 -127
- package/dist/browser/conditions/condition-values.js.map +0 -1
- package/dist/browser/conditions/condition.js +0 -56
- package/dist/browser/conditions/condition.js.map +0 -1
- package/dist/browser/conditions/enums.js +0 -24
- package/dist/browser/conditions/enums.js.map +0 -1
- package/dist/browser/conditions/helpers.js +0 -26
- package/dist/browser/conditions/helpers.js.map +0 -1
- package/dist/browser/conditions/index.js +0 -144
- package/dist/browser/conditions/index.js.map +0 -1
- package/dist/browser/conditions/inline-condition-model.js +0 -418
- package/dist/browser/conditions/inline-condition-model.js.map +0 -1
- package/dist/browser/conditions/inline-condition-operators.js +0 -132
- package/dist/browser/conditions/inline-condition-operators.js.map +0 -1
- package/dist/browser/conditions/inline-condition-values.js +0 -159
- package/dist/browser/conditions/inline-condition-values.js.map +0 -1
- package/dist/browser/conditions/types.js +0 -16
- package/dist/browser/conditions/types.js.map +0 -1
- package/dist/browser/data-model/conditions-wrapper.js +0 -49
- package/dist/browser/data-model/conditions-wrapper.js.map +0 -1
- package/dist/browser/data-model/enums.js +0 -25
- package/dist/browser/data-model/enums.js.map +0 -1
- package/dist/browser/data-model/index.js +0 -36
- package/dist/browser/data-model/index.js.map +0 -1
- package/dist/browser/data-model/input-wrapper.js +0 -49
- package/dist/browser/data-model/input-wrapper.js.map +0 -1
- package/dist/browser/data-model/types.js +0 -27
- package/dist/browser/data-model/types.js.map +0 -1
- package/dist/browser/form/form-configuration.js +0 -38
- package/dist/browser/form/form-configuration.js.map +0 -1
- package/dist/browser/form/index.js +0 -24
- package/dist/browser/form/index.js.map +0 -1
- package/dist/browser/index.js +0 -98
- package/dist/browser/index.js.map +0 -1
- package/dist/browser/migration/index.js +0 -24
- package/dist/browser/migration/index.js.map +0 -1
- package/dist/browser/migration/migration.0-2.js +0 -65
- package/dist/browser/migration/migration.0-2.js.map +0 -1
- package/dist/browser/migration/migration.1-2.js +0 -108
- package/dist/browser/migration/migration.1-2.js.map +0 -1
- package/dist/browser/migration/types.js +0 -16
- package/dist/browser/migration/types.js.map +0 -1
- package/dist/browser/migration/whichMigrations.js +0 -38
- package/dist/browser/migration/whichMigrations.js.map +0 -1
- package/dist/browser/schema/index.js +0 -30
- package/dist/browser/schema/index.js.map +0 -1
- package/dist/browser/schema/schema.js +0 -255
- package/dist/browser/schema/schema.js.map +0 -1
- package/dist/browser/utils/helpers.js +0 -48
- package/dist/browser/utils/helpers.js.map +0 -1
- package/dist/browser/utils/logger.js +0 -46
- package/dist/browser/utils/logger.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"component-types.js","names":["ComponentTypes","
|
1
|
+
{"version":3,"file":"component-types.js","names":["ComponentTypes","name","type","title","subType","hint","options","schema","list","content"],"sources":["../../../src/components/component-types.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\n\nexport const ComponentTypes: ComponentDef[] = [\n {\n name: 'TextField',\n type: 'TextField',\n title: 'Text field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MultilineTextField',\n type: 'MultilineTextField',\n title: 'Multiline text field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'YesNoField',\n type: 'YesNoField',\n title: 'Yes/No field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateField',\n type: 'DateField',\n title: 'Date field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TimeField',\n type: 'TimeField',\n title: 'Time field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateTimeField',\n type: 'DateTimeField',\n title: 'Date time field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DatePartsField',\n type: 'DatePartsField',\n title: 'Date parts field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'DateTimePartsField',\n type: 'DateTimePartsField',\n title: 'Date time parts field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'MonthYearField',\n type: 'MonthYearField',\n title: 'Month year field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'SelectField',\n type: 'SelectField',\n title: 'Select field',\n subType: 'listField',\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'AutocompleteField',\n type: 'AutocompleteField',\n title: 'Autocomplete field',\n subType: 'listField',\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'RadiosField',\n type: 'RadiosField',\n title: 'Radios field',\n subType: 'listField',\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'CheckboxesField',\n type: 'CheckboxesField',\n title: 'Checkboxes field',\n subType: 'listField',\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'NumberField',\n type: 'NumberField',\n title: 'Number field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'UkAddressField',\n type: 'UkAddressField',\n title: 'UK address field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'TelephoneNumberField',\n type: 'TelephoneNumberField',\n title: 'Telephone number field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'EmailAddressField',\n type: 'EmailAddressField',\n title: 'Email address field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'FileUploadField',\n type: 'FileUploadField',\n title: 'File upload field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n },\n {\n name: 'Para',\n type: 'Para',\n title: 'Paragraph',\n subType: 'content',\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'Html',\n type: 'Html',\n title: 'Html',\n subType: 'content',\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'InsetText',\n type: 'InsetText',\n title: 'Inset text',\n subType: 'content',\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'Details',\n type: 'Details',\n title: 'Details',\n subType: 'content',\n content: '',\n options: {},\n schema: {}\n },\n {\n name: 'FlashCard',\n type: 'FlashCard',\n title: 'Flash card',\n subType: 'content',\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'List',\n type: 'List',\n title: 'List',\n subType: 'content',\n options: {},\n schema: {},\n list: ''\n },\n {\n name: 'WebsiteField',\n type: 'WebsiteField',\n title: 'Website field',\n subType: 'field',\n hint: '',\n options: {},\n schema: {}\n }\n]\n"],"mappings":"AAEA,OAAO,MAAMA,cAA8B,GAAG,CAC5C;EACEC,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE,OAAO;EAChBC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,oBAAoB;EAC1BC,IAAI,EAAE,oBAAo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XC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE,SAAS;EAClBK,OAAO,EAAE,EAAE;EACXH,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,SAAS;EACfC,IAAI,EAAE,SAAS;EACfC,KAAK,EAAE,SAAS;EAChBC,OAAO,EAAE,SAAS;EAClBK,OAAO,EAAE,EAAE;EACXH,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,EACD;EACEN,IAAI,EAAE,WAAW;EACjBC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE,SAAS;EAClBE,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE;AACR,CAAC,EACD;EACEP,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,MAAM;EACZC,KAAK,EAAE,MAAM;EACbC,OAAO,EAAE,SAAS;EAClBE,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC,CAAC;EACVC,IAAI,EAAE;AACR,CAAC,EACD;EACEP,IAAI,EAAE,cAAc;EACpBC,IAAI,EAAE,cAAc;EACpBC,KAAK,EAAE,eAAe;EACtBC,OAAO,EAAE,OAAO;EAChBC,IAAI,EAAE,EAAE;EACRC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,CAAC;AACX,CAAC,CACF"}
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.ConditionalComponentTypes = void 0;
|
5
|
-
const ConditionalComponentTypes = exports.ConditionalComponentTypes = [{
|
1
|
+
export const ConditionalComponentTypes = [{
|
6
2
|
name: 'TextField',
|
7
3
|
title: 'Text field',
|
8
4
|
subType: 'field'
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"conditional-component-types.js","names":["ConditionalComponentTypes","
|
1
|
+
{"version":3,"file":"conditional-component-types.js","names":["ConditionalComponentTypes","name","title","subType"],"sources":["../../../src/components/conditional-component-types.ts"],"sourcesContent":["import { type ConditionalComponent } from '~/src/components/types.js'\n\nexport const ConditionalComponentTypes: ConditionalComponent[] = [\n {\n name: 'TextField',\n title: 'Text field',\n subType: 'field'\n },\n {\n name: 'NumberField',\n title: 'Number field',\n subType: 'field'\n }\n]\n"],"mappings":"AAEA,OAAO,MAAMA,yBAAiD,GAAG,CAC/D;EACEC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,OAAO,EAAE;AACX,CAAC,EACD;EACEF,IAAI,EAAE,aAAa;EACnBC,KAAK,EAAE,cAAc;EACrBC,OAAO,EAAE;AACX,CAAC,CACF"}
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.ComponentTypeEnum = void 0;
|
5
|
-
let ComponentTypeEnum = exports.ComponentTypeEnum = /*#__PURE__*/function (ComponentTypeEnum) {
|
1
|
+
export let ComponentTypeEnum = /*#__PURE__*/function (ComponentTypeEnum) {
|
6
2
|
ComponentTypeEnum["TextField"] = "TextField";
|
7
3
|
ComponentTypeEnum["MultilineTextField"] = "MultilineTextField";
|
8
4
|
ComponentTypeEnum["YesNoField"] = "YesNoField";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"enums.js","names":["ComponentTypeEnum"
|
1
|
+
{"version":3,"file":"enums.js","names":["ComponentTypeEnum"],"sources":["../../../src/components/enums.ts"],"sourcesContent":["export enum ComponentTypeEnum {\n TextField = 'TextField',\n MultilineTextField = 'MultilineTextField',\n YesNoField = 'YesNoField',\n DateField = 'DateField',\n TimeField = 'TimeField',\n DateTimeField = 'DateTimeField',\n DatePartsField = 'DatePartsField',\n MonthYearField = 'MonthYearField',\n DateTimePartsField = 'DateTimePartsField',\n SelectField = 'SelectField',\n AutocompleteField = 'AutocompleteField',\n RadiosField = 'RadiosField',\n CheckboxesField = 'CheckboxesField',\n NumberField = 'NumberField',\n UkAddressField = 'UkAddressField',\n TelephoneNumberField = 'TelephoneNumberField',\n EmailAddressField = 'EmailAddressField',\n FileUploadField = 'FileUploadField',\n Para = 'Para',\n Html = 'Html',\n InsetText = 'InsetText',\n Details = 'Details',\n FlashCard = 'FlashCard',\n List = 'List'\n}\n"],"mappings":"AAAA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
|
@@ -1,25 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
Object.defineProperty(exports, "ComponentTypeEnum", {
|
5
|
-
enumerable: true,
|
6
|
-
get: function () {
|
7
|
-
return _enums.ComponentTypeEnum;
|
8
|
-
}
|
9
|
-
});
|
10
|
-
Object.defineProperty(exports, "ComponentTypes", {
|
11
|
-
enumerable: true,
|
12
|
-
get: function () {
|
13
|
-
return _componentTypes.ComponentTypes;
|
14
|
-
}
|
15
|
-
});
|
16
|
-
Object.defineProperty(exports, "ConditionalComponentTypes", {
|
17
|
-
enumerable: true,
|
18
|
-
get: function () {
|
19
|
-
return _conditionalComponentTypes.ConditionalComponentTypes;
|
20
|
-
}
|
21
|
-
});
|
22
|
-
var _componentTypes = require("./component-types");
|
23
|
-
var _conditionalComponentTypes = require("./conditional-component-types");
|
24
|
-
var _enums = require("./enums");
|
1
|
+
export { ComponentTypes } from "./component-types.js";
|
2
|
+
export { ConditionalComponentTypes } from "./conditional-component-types.js";
|
3
|
+
export { ComponentTypeEnum } from "./enums.js";
|
25
4
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
1
|
+
{"version":3,"file":"index.js","names":["ComponentTypes","ConditionalComponentTypes","ComponentTypeEnum"],"sources":["../../../src/components/index.ts"],"sourcesContent":["export { ComponentTypes } from '~/src/components/component-types.js'\nexport { ConditionalComponentTypes } from '~/src/components/conditional-component-types.js'\nexport { ComponentTypeEnum } from '~/src/components/enums.js'\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,yBAAyB;AAClC,SAASC,iBAAiB"}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
export {};
|
2
2
|
//# sourceMappingURL=types.js.map
|
@@ -1,11 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.ConditionAbstract = void 0;
|
5
|
-
var _enums = require("./enums");
|
6
|
-
class ConditionAbstract {
|
1
|
+
import { Coordinator } from "./enums.js";
|
2
|
+
export class ConditionAbstract {
|
7
3
|
constructor(coordinator) {
|
8
|
-
if (coordinator && !Object.values(
|
4
|
+
if (coordinator && !Object.values(Coordinator).includes(coordinator)) {
|
9
5
|
throw Error(`coordinator ${coordinator} is not a valid coordinator`);
|
10
6
|
}
|
11
7
|
this.coordinator = coordinator;
|
@@ -41,5 +37,4 @@ class ConditionAbstract {
|
|
41
37
|
throw Error('Unsupported Operation. Method conditionExpression have not been implemented');
|
42
38
|
}
|
43
39
|
}
|
44
|
-
exports.ConditionAbstract = ConditionAbstract;
|
45
40
|
//# sourceMappingURL=condition-abstract.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-abstract.js","names":["
|
1
|
+
{"version":3,"file":"condition-abstract.js","names":["Coordinator","ConditionAbstract","constructor","coordinator","Object","values","includes","Error","coordinatorString","getCoordinator","setCoordinator","isGroup","getGroupedConditions","_asFirstCondition","asFirstCondition","clone","conditionString","conditionExpression"],"sources":["../../../src/conditions/condition-abstract.ts"],"sourcesContent":["import { Coordinator } from '~/src/conditions/enums.js'\n\nexport class ConditionAbstract {\n coordinator: Coordinator | undefined\n\n constructor(coordinator: Coordinator | undefined) {\n if (coordinator && !Object.values(Coordinator).includes(coordinator)) {\n throw Error(`coordinator ${coordinator} is not a valid coordinator`)\n }\n\n this.coordinator = coordinator\n }\n\n coordinatorString() {\n return this.coordinator ? `${this.coordinator} ` : ''\n }\n\n getCoordinator() {\n return this.coordinator\n }\n\n setCoordinator(coordinator: Coordinator | undefined) {\n this.coordinator = coordinator\n }\n\n isGroup() {\n return false\n }\n\n getGroupedConditions() {\n return [this]\n }\n\n _asFirstCondition() {\n delete this.coordinator\n }\n\n asFirstCondition() {\n throw Error(\n 'Unsupported Operation. Method asFirstCondition have not been implemented'\n )\n }\n\n clone() {\n throw Error('Unsupported Operation. Method clone have not been implemented')\n }\n\n conditionString() {\n throw Error(\n 'Unsupported Operation. Method conditionString have not been implemented'\n )\n }\n\n conditionExpression() {\n throw Error(\n 'Unsupported Operation. Method conditionExpression have not been implemented'\n )\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW;AAEpB,OAAO,MAAMC,iBAAiB,CAAC;EAG7BC,WAAWA,CAACC,WAAoC,EAAE;IAChD,IAAIA,WAAW,IAAI,CAACC,MAAM,CAACC,MAAM,CAACL,WAAW,CAAC,CAACM,QAAQ,CAACH,WAAW,CAAC,EAAE;MACpE,MAAMI,KAAK,CAAE,eAAcJ,WAAY,6BAA4B,CAAC;IACtE;IAEA,IAAI,CAACA,WAAW,GAAGA,WAAW;EAChC;EAEAK,iBAAiBA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACL,WAAW,GAAI,GAAE,IAAI,CAACA,WAAY,GAAE,GAAG,EAAE;EACvD;EAEAM,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACN,WAAW;EACzB;EAEAO,cAAcA,CAACP,WAAoC,EAAE;IACnD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAChC;EAEAQ,OAAOA,CAAA,EAAG;IACR,OAAO,KAAK;EACd;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,CAAC,IAAI,CAAC;EACf;EAEAC,iBAAiBA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACV,WAAW;EACzB;EAEAW,gBAAgBA,CAAA,EAAG;IACjB,MAAMP,KAAK,CACT,0EACF,CAAC;EACH;EAEAQ,KAAKA,CAAA,EAAG;IACN,MAAMR,KAAK,CAAC,+DAA+D,CAAC;EAC9E;EAEAS,eAAeA,CAAA,EAAG;IAChB,MAAMT,KAAK,CACT,yEACF,CAAC;EACH;EAEAU,mBAAmBA,CAAA,EAAG;IACpB,MAAMV,KAAK,CACT,6EACF,CAAC;EACH;AACF"}
|
@@ -1,14 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.ConditionField = void 0;
|
5
|
-
var _components = require("../components");
|
6
|
-
class ConditionField {
|
1
|
+
import { ComponentTypes } from "../components/index.js";
|
2
|
+
export class ConditionField {
|
7
3
|
constructor(name, type, display) {
|
8
4
|
if (!name || typeof name !== 'string') {
|
9
5
|
throw Error(`name ${name} is not valid`);
|
10
6
|
}
|
11
|
-
if (!
|
7
|
+
if (!ComponentTypes.find(componentType => componentType.type === type)) {
|
12
8
|
throw Error(`type ${type} is not valid`);
|
13
9
|
}
|
14
10
|
if (!display || typeof display !== 'string') {
|
@@ -22,5 +18,4 @@ class ConditionField {
|
|
22
18
|
return new ConditionField(obj.name, obj.type, obj.display);
|
23
19
|
}
|
24
20
|
}
|
25
|
-
exports.ConditionField = ConditionField;
|
26
21
|
//# sourceMappingURL=condition-field.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-field.js","names":["
|
1
|
+
{"version":3,"file":"condition-field.js","names":["ComponentTypes","ConditionField","constructor","name","type","display","Error","find","componentType","from","obj"],"sources":["../../../src/conditions/condition-field.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/index.js'\nimport { type ComponentType } from '~/src/components/types.js'\n\nexport class ConditionField {\n name: string\n type: ComponentType\n display: string\n\n constructor(name: string, type: ComponentType, display: string) {\n if (!name || typeof name !== 'string') {\n throw Error(`name ${name} is not valid`)\n }\n\n if (!ComponentTypes.find((componentType) => componentType.type === type)) {\n throw Error(`type ${type} is not valid`)\n }\n\n if (!display || typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n\n this.name = name\n this.type = type\n this.display = display\n }\n\n static from(obj: { name: string; type: ComponentType; display: string }) {\n return new ConditionField(obj.name, obj.type, obj.display)\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc;AAGvB,OAAO,MAAMC,cAAc,CAAC;EAK1BC,WAAWA,CAACC,IAAY,EAAEC,IAAmB,EAAEC,OAAe,EAAE;IAC9D,IAAI,CAACF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACrC,MAAMG,KAAK,CAAE,QAAOH,IAAK,eAAc,CAAC;IAC1C;IAEA,IAAI,CAACH,cAAc,CAACO,IAAI,CAAEC,aAAa,IAAKA,aAAa,CAACJ,IAAI,KAAKA,IAAI,CAAC,EAAE;MACxE,MAAME,KAAK,CAAE,QAAOF,IAAK,eAAc,CAAC;IAC1C;IAEA,IAAI,CAACC,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC3C,MAAMC,KAAK,CAAE,WAAUD,OAAQ,eAAc,CAAC;IAChD;IAEA,IAAI,CAACF,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;EAEA,OAAOI,IAAIA,CAACC,GAA2D,EAAE;IACvE,OAAO,IAAIT,cAAc,CAACS,GAAG,CAACP,IAAI,EAAEO,GAAG,CAACN,IAAI,EAAEM,GAAG,CAACL,OAAO,CAAC;EAC5D;AACF"}
|
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.ConditionGroupDef = void 0;
|
5
|
-
class ConditionGroupDef {
|
1
|
+
export class ConditionGroupDef {
|
6
2
|
constructor(first, last) {
|
7
3
|
if (typeof first !== 'number' || typeof last !== 'number') {
|
8
4
|
throw Error(`Cannot construct a group from ${first} and ${last}`);
|
@@ -22,5 +18,4 @@ class ConditionGroupDef {
|
|
22
18
|
return [...conditions].splice(this.first, this.last - this.first + 1);
|
23
19
|
}
|
24
20
|
}
|
25
|
-
exports.ConditionGroupDef = ConditionGroupDef;
|
26
21
|
//# sourceMappingURL=condition-group-def.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-group-def.js","names":["ConditionGroupDef","constructor","first","last","Error","contains","index","startsWith","applyTo","conditions","splice"
|
1
|
+
{"version":3,"file":"condition-group-def.js","names":["ConditionGroupDef","constructor","first","last","Error","contains","index","startsWith","applyTo","conditions","splice"],"sources":["../../../src/conditions/condition-group-def.ts"],"sourcesContent":["import { type ConditionsArray } from '~/src/conditions/types.js'\n\nexport class ConditionGroupDef {\n first: number\n last: number\n\n constructor(first: number, last: number) {\n if (typeof first !== 'number' || typeof last !== 'number') {\n throw Error(`Cannot construct a group from ${first} and ${last}`)\n } else if (first >= last) {\n throw Error(`Last (${last}) must be greater than first (${first})`)\n }\n\n this.first = first\n this.last = last\n }\n\n contains(index: number) {\n return this.first <= index && this.last >= index\n }\n\n startsWith(index: number) {\n return this.first === index\n }\n\n applyTo(conditions: ConditionsArray) {\n return [...conditions].splice(this.first, this.last - this.first + 1)\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,iBAAiB,CAAC;EAI7BC,WAAWA,CAACC,KAAa,EAAEC,IAAY,EAAE;IACvC,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAI,OAAOC,IAAI,KAAK,QAAQ,EAAE;MACzD,MAAMC,KAAK,CAAE,iCAAgCF,KAAM,QAAOC,IAAK,EAAC,CAAC;IACnE,CAAC,MAAM,IAAID,KAAK,IAAIC,IAAI,EAAE;MACxB,MAAMC,KAAK,CAAE,SAAQD,IAAK,iCAAgCD,KAAM,GAAE,CAAC;IACrE;IAEA,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,IAAI,GAAGA,IAAI;EAClB;EAEAE,QAAQA,CAACC,KAAa,EAAE;IACtB,OAAO,IAAI,CAACJ,KAAK,IAAII,KAAK,IAAI,IAAI,CAACH,IAAI,IAAIG,KAAK;EAClD;EAEAC,UAAUA,CAACD,KAAa,EAAE;IACxB,OAAO,IAAI,CAACJ,KAAK,KAAKI,KAAK;EAC7B;EAEAE,OAAOA,CAACC,UAA2B,EAAE;IACnC,OAAO,CAAC,GAAGA,UAAU,CAAC,CAACC,MAAM,CAAC,IAAI,CAACR,KAAK,EAAE,IAAI,CAACC,IAAI,GAAG,IAAI,CAACD,KAAK,GAAG,CAAC,CAAC;EACvE;AACF"}
|
@@ -1,9 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.ConditionGroup = void 0;
|
5
|
-
var _helpers = require("./helpers");
|
6
|
-
class ConditionGroup {
|
1
|
+
import { toPresentationString, toExpression } from "./helpers.js";
|
2
|
+
export class ConditionGroup {
|
7
3
|
constructor(conditions = []) {
|
8
4
|
if (!Array.isArray(conditions) || conditions.length < 2) {
|
9
5
|
throw Error('Cannot construct a condition group from a single condition');
|
@@ -16,12 +12,12 @@ class ConditionGroup {
|
|
16
12
|
conditionString() {
|
17
13
|
const copy = [...this.conditions];
|
18
14
|
copy.splice(0, 1);
|
19
|
-
return `(${this.conditions[0].conditionString()} ${copy.map(condition =>
|
15
|
+
return `(${this.conditions[0].conditionString()} ${copy.map(condition => toPresentationString(condition)).join(' ')})`;
|
20
16
|
}
|
21
17
|
conditionExpression() {
|
22
18
|
const copy = [...this.conditions];
|
23
19
|
copy.splice(0, 1);
|
24
|
-
return `(${this.conditions[0].conditionExpression()} ${copy.map(condition =>
|
20
|
+
return `(${this.conditions[0].conditionExpression()} ${copy.map(condition => toExpression(condition)).join(' ')})`;
|
25
21
|
}
|
26
22
|
asFirstCondition() {
|
27
23
|
this.conditions[0].asFirstCondition();
|
@@ -43,5 +39,4 @@ class ConditionGroup {
|
|
43
39
|
return new ConditionGroup(this.conditions.map(condition => condition.clone()));
|
44
40
|
}
|
45
41
|
}
|
46
|
-
exports.ConditionGroup = ConditionGroup;
|
47
42
|
//# sourceMappingURL=condition-group.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-group.js","names":["
|
1
|
+
{"version":3,"file":"condition-group.js","names":["toPresentationString","toExpression","ConditionGroup","constructor","conditions","Array","isArray","length","Error","coordinatorString","conditionString","copy","splice","map","condition","join","conditionExpression","asFirstCondition","getCoordinator","setCoordinator","coordinator","isGroup","getGroupedConditions","clone"],"sources":["../../../src/conditions/condition-group.ts"],"sourcesContent":["import { Coordinator } from '~/src/conditions/enums.js'\nimport { toPresentationString, toExpression } from '~/src/conditions/helpers.js'\nimport { type ConditionsArray } from '~/src/conditions/types.js'\n\nexport class ConditionGroup {\n conditions: ConditionsArray\n\n constructor(conditions: ConditionsArray = []) {\n if (!Array.isArray(conditions) || conditions.length < 2) {\n throw Error('Cannot construct a condition group from a single condition')\n }\n\n this.conditions = conditions\n }\n\n coordinatorString() {\n return this.conditions[0].coordinatorString()\n }\n\n conditionString() {\n const copy = [...this.conditions]\n copy.splice(0, 1)\n return `(${this.conditions[0].conditionString()} ${copy\n .map((condition) => toPresentationString(condition))\n .join(' ')})`\n }\n\n conditionExpression() {\n const copy = [...this.conditions]\n copy.splice(0, 1)\n return `(${this.conditions[0].conditionExpression()} ${copy\n .map((condition) => toExpression(condition))\n .join(' ')})`\n }\n\n asFirstCondition() {\n this.conditions[0].asFirstCondition()\n return this\n }\n\n getCoordinator() {\n return this.conditions[0].getCoordinator()\n }\n\n setCoordinator(coordinator: Coordinator | undefined) {\n this.conditions[0].setCoordinator(coordinator)\n }\n\n isGroup() {\n return true\n }\n\n getGroupedConditions() {\n return this.conditions.map((condition) => condition.clone())\n }\n\n clone() {\n return new ConditionGroup(\n this.conditions.map((condition) => condition.clone())\n )\n }\n}\n"],"mappings":"AACA,SAASA,oBAAoB,EAAEC,YAAY;AAG3C,OAAO,MAAMC,cAAc,CAAC;EAG1BC,WAAWA,CAACC,UAA2B,GAAG,EAAE,EAAE;IAC5C,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,IAAIA,UAAU,CAACG,MAAM,GAAG,CAAC,EAAE;MACvD,MAAMC,KAAK,CAAC,4DAA4D,CAAC;IAC3E;IAEA,IAAI,CAACJ,UAAU,GAAGA,UAAU;EAC9B;EAEAK,iBAAiBA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACL,UAAU,CAAC,CAAC,CAAC,CAACK,iBAAiB,CAAC,CAAC;EAC/C;EAEAC,eAAeA,CAAA,EAAG;IAChB,MAAMC,IAAI,GAAG,CAAC,GAAG,IAAI,CAACP,UAAU,CAAC;IACjCO,IAAI,CAACC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACjB,OAAQ,IAAG,IAAI,CAACR,UAAU,CAAC,CAAC,CAAC,CAACM,eAAe,CAAC,CAAE,IAAGC,IAAI,CACpDE,GAAG,CAAEC,SAAS,IAAKd,oBAAoB,CAACc,SAAS,CAAC,CAAC,CACnDC,IAAI,CAAC,GAAG,CAAE,GAAE;EACjB;EAEAC,mBAAmBA,CAAA,EAAG;IACpB,MAAML,IAAI,GAAG,CAAC,GAAG,IAAI,CAACP,UAAU,CAAC;IACjCO,IAAI,CAACC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IACjB,OAAQ,IAAG,IAAI,CAACR,UAAU,CAAC,CAAC,CAAC,CAACY,mBAAmB,CAAC,CAAE,IAAGL,IAAI,CACxDE,GAAG,CAAEC,SAAS,IAAKb,YAAY,CAACa,SAAS,CAAC,CAAC,CAC3CC,IAAI,CAAC,GAAG,CAAE,GAAE;EACjB;EAEAE,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACb,UAAU,CAAC,CAAC,CAAC,CAACa,gBAAgB,CAAC,CAAC;IACrC,OAAO,IAAI;EACb;EAEAC,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACd,UAAU,CAAC,CAAC,CAAC,CAACc,cAAc,CAAC,CAAC;EAC5C;EAEAC,cAAcA,CAACC,WAAoC,EAAE;IACnD,IAAI,CAAChB,UAAU,CAAC,CAAC,CAAC,CAACe,cAAc,CAACC,WAAW,CAAC;EAChD;EAEAC,OAAOA,CAAA,EAAG;IACR,OAAO,IAAI;EACb;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAAClB,UAAU,CAACS,GAAG,CAAEC,SAAS,IAAKA,SAAS,CAACS,KAAK,CAAC,CAAC,CAAC;EAC9D;EAEAA,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIrB,cAAc,CACvB,IAAI,CAACE,UAAU,CAACS,GAAG,CAAEC,SAAS,IAAKA,SAAS,CAACS,KAAK,CAAC,CAAC,CACtD,CAAC;EACH;AACF"}
|
@@ -1,16 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
var _conditionValues = require("./condition-values");
|
11
|
-
var _enums = require("./enums");
|
12
|
-
var _helpers = require("./helpers");
|
13
|
-
class ConditionsModel {
|
1
|
+
import { ConditionField } from "./condition-field.js";
|
2
|
+
import { ConditionGroupDef } from "./condition-group-def.js";
|
3
|
+
import { Condition } from "./condition.js";
|
4
|
+
import { ConditionRef } from "./condition-ref.js";
|
5
|
+
import { ConditionGroup } from "./condition-group.js";
|
6
|
+
import { conditionValueFrom } from "./condition-values.js";
|
7
|
+
import { Coordinator } from "./enums.js";
|
8
|
+
import { toPresentationString, toExpression } from "./helpers.js";
|
9
|
+
export class ConditionsModel {
|
14
10
|
#groupedConditions = [];
|
15
11
|
#userGroupedConditions = [];
|
16
12
|
#conditionName = undefined;
|
@@ -107,13 +103,13 @@ class ConditionsModel {
|
|
107
103
|
return this.#userGroupedConditions.length - 1;
|
108
104
|
}
|
109
105
|
toPresentationString() {
|
110
|
-
return this.#groupedConditions.map(condition =>
|
106
|
+
return this.#groupedConditions.map(condition => toPresentationString(condition)).join(' ');
|
111
107
|
}
|
112
108
|
toExpression() {
|
113
|
-
return this.#groupedConditions.map(condition =>
|
109
|
+
return this.#groupedConditions.map(condition => toExpression(condition)).join(' ');
|
114
110
|
}
|
115
111
|
_applyGroups(userGroupedConditions) {
|
116
|
-
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof
|
112
|
+
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof ConditionGroup && condition.conditions.length > 2 ? new ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
117
113
|
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
118
114
|
}
|
119
115
|
_group(conditions, groupDefs) {
|
@@ -122,7 +118,7 @@ class ConditionsModel {
|
|
122
118
|
if (groupDef) {
|
123
119
|
if (groupDef.startsWith(index)) {
|
124
120
|
const groupConditions = groupDef.applyTo(conditions);
|
125
|
-
groups.push(new
|
121
|
+
groups.push(new ConditionGroup(groupConditions));
|
126
122
|
}
|
127
123
|
} else {
|
128
124
|
groups.push(condition);
|
@@ -141,23 +137,23 @@ class ConditionsModel {
|
|
141
137
|
_autoGroupDefs(conditions) {
|
142
138
|
const orPositions = [];
|
143
139
|
conditions.forEach((condition, index) => {
|
144
|
-
if (condition.getCoordinator() ===
|
140
|
+
if (condition.getCoordinator() === Coordinator.OR) {
|
145
141
|
orPositions.push(index);
|
146
142
|
}
|
147
143
|
});
|
148
144
|
const hasOr = orPositions.length > 0;
|
149
|
-
const hasAnd = !!conditions.find(condition => condition.getCoordinator() ===
|
145
|
+
const hasAnd = !!conditions.find(condition => condition.getCoordinator() === Coordinator.AND);
|
150
146
|
if (hasAnd && hasOr) {
|
151
147
|
let start = 0;
|
152
148
|
const groupDefs = [];
|
153
149
|
orPositions.forEach((position, index) => {
|
154
150
|
if (start < position - 1) {
|
155
|
-
groupDefs.push(new
|
151
|
+
groupDefs.push(new ConditionGroupDef(start, position - 1));
|
156
152
|
}
|
157
153
|
const thisIsTheLastOr = orPositions.length === index + 1;
|
158
154
|
const thereAreMoreConditions = conditions.length - 1 > position;
|
159
155
|
if (thisIsTheLastOr && thereAreMoreConditions) {
|
160
|
-
groupDefs.push(new
|
156
|
+
groupDefs.push(new ConditionGroupDef(position, conditions.length - 1));
|
161
157
|
}
|
162
158
|
start = position;
|
163
159
|
});
|
@@ -186,14 +182,13 @@ class ConditionsModel {
|
|
186
182
|
return toReturn;
|
187
183
|
}
|
188
184
|
}
|
189
|
-
exports.ConditionsModel = ConditionsModel;
|
190
185
|
const conditionFrom = function (it) {
|
191
186
|
if ('conditions' in it) {
|
192
|
-
return new
|
187
|
+
return new ConditionGroup(it.conditions.map(condition => conditionFrom(condition)));
|
193
188
|
}
|
194
189
|
if ('conditionName' in it) {
|
195
|
-
return new
|
190
|
+
return new ConditionRef(it.conditionName, it.conditionDisplayName, it.coordinator);
|
196
191
|
}
|
197
|
-
return new
|
192
|
+
return new Condition(ConditionField.from(it.field), it.operator, conditionValueFrom(it.value), it.coordinator);
|
198
193
|
};
|
199
194
|
//# sourceMappingURL=condition-model.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-model.js","names":["_conditionField","require","_conditionGroupDef","_condition2","_conditionRef","_conditionGroup","_conditionValues","_enums","_helpers","ConditionsModel","groupedConditions","userGroupedConditions","conditionName","undefined","constructor","_conditionsObject","clone","toReturn","map","it","clear","name","add","condition","coordinatorExpected","length","getCoordinator","Error","push","_applyGroups","replace","index","splice","remove","indexes","filter","_condition","includes","asFirstCondition","addGroups","groupDefs","_group","splitGroup","_ungroup","moveEarlier","switchCoordinators","moveLater","setCoordinator","asPerUserGroupings","hasConditions","lastIndex","toPresentationString","join","toExpression","correctedUserGroups","ConditionGroup","conditions","_autoGroupDefs","reduce","groups","groupDef","find","contains","startsWith","groupConditions","applyTo","splitIndex","isGroup","copy","getGroupedConditions","orPositions","forEach","Coordinator","OR","hasOr","hasAnd","AND","start","position","ConditionGroupDef","thisIsTheLastOr","thereAreMoreConditions","toJSON","from","obj","conditionFrom","exports","ConditionRef","conditionDisplayName","coordinator","Condition","ConditionField","field","operator","conditionValueFrom","value"],"sources":["../../../src/conditions/condition-model.ts"],"sourcesContent":["import { ConditionField } from '~/src/conditions/condition-field'\nimport { ConditionGroupDef } from '~/src/conditions/condition-group-def'\nimport { Condition } from '~/src/conditions/condition'\nimport { ConditionRef } from '~/src/conditions/condition-ref'\nimport { ConditionGroup } from '~/src/conditions/condition-group'\nimport { conditionValueFrom } from '~/src/conditions/condition-values'\nimport { Coordinator } from '~/src/conditions/enums'\nimport { toPresentationString, toExpression } from '~/src/conditions/helpers'\nimport { type ConditionsArray } from '~/src/conditions/types'\n\ntype ConditionRawObject =\n | ConditionsModel\n | {\n name: string\n conditions: Condition[]\n }\n\nexport class ConditionsModel {\n #groupedConditions: ConditionsArray = []\n #userGroupedConditions: ConditionsArray = []\n #conditionName: string | undefined = undefined\n\n constructor(_conditionsObject?: ConditionRawObject) {}\n\n clone() {\n const toReturn = new ConditionsModel()\n toReturn.#groupedConditions = this.#groupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#userGroupedConditions = this.#userGroupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#conditionName = this.#conditionName\n return toReturn\n }\n\n clear() {\n this.#userGroupedConditions = []\n this.#groupedConditions = []\n this.#conditionName = undefined\n return this\n }\n\n set name(name) {\n this.#conditionName = name\n }\n\n get name() {\n return this.#conditionName\n }\n\n add(condition: Condition) {\n const coordinatorExpected = this.#userGroupedConditions.length !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n }\n\n this.#userGroupedConditions.push(condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n replace(index: number, condition: Condition) {\n const coordinatorExpected = index !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n } else if (index >= this.#userGroupedConditions.length) {\n throw Error(\n `Cannot replace condition ${index} as no such condition exists`\n )\n }\n\n this.#userGroupedConditions.splice(index, 1, condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n remove(indexes: number[]) {\n this.#userGroupedConditions = this.#userGroupedConditions\n .filter((_condition, index) => !indexes.includes(index))\n .map((condition, index) =>\n index === 0 ? condition.asFirstCondition() : condition\n )\n\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n addGroups(groupDefs: ConditionGroupDef[]) {\n this.#userGroupedConditions = this._group(\n this.#userGroupedConditions,\n groupDefs\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n splitGroup(index: number) {\n this.#userGroupedConditions = this._ungroup(\n this.#userGroupedConditions,\n index\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n moveEarlier(index: number) {\n if (index > 0 && index < this.#userGroupedConditions.length) {\n this.#userGroupedConditions.splice(\n index - 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 1) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n moveLater(index: number) {\n if (index >= 0 && index < this.#userGroupedConditions.length - 1) {\n this.#userGroupedConditions.splice(\n index + 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 0) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n switchCoordinators() {\n this.#userGroupedConditions[1].setCoordinator(\n this.#userGroupedConditions[0].getCoordinator()\n )\n this.#userGroupedConditions[0].setCoordinator(undefined)\n }\n\n get asPerUserGroupings() {\n return [...this.#userGroupedConditions]\n }\n\n get hasConditions() {\n return this.#userGroupedConditions.length > 0\n }\n\n get lastIndex() {\n return this.#userGroupedConditions.length - 1\n }\n\n toPresentationString() {\n return this.#groupedConditions\n .map((condition) => toPresentationString(condition))\n .join(' ')\n }\n\n toExpression() {\n return this.#groupedConditions\n .map((condition) => toExpression(condition))\n .join(' ')\n }\n\n _applyGroups(\n userGroupedConditions: (Condition | ConditionGroup | ConditionRef)[]\n ) {\n const correctedUserGroups = userGroupedConditions.map((condition) =>\n condition instanceof ConditionGroup && condition.conditions.length > 2\n ? new ConditionGroup(\n this._group(\n condition.conditions,\n this._autoGroupDefs(condition.conditions)\n )\n )\n : condition\n )\n\n return this._group(\n correctedUserGroups,\n this._autoGroupDefs(correctedUserGroups)\n )\n }\n\n _group(conditions: ConditionsArray, groupDefs: ConditionGroupDef[]) {\n return conditions.reduce((groups, condition, index, conditions) => {\n const groupDef = groupDefs.find((groupDef) => groupDef.contains(index))\n\n if (groupDef) {\n if (groupDef.startsWith(index)) {\n const groupConditions = groupDef.applyTo(conditions)\n groups.push(new ConditionGroup(groupConditions))\n }\n } else {\n groups.push(condition)\n }\n\n return groups\n }, [] as ConditionsArray)\n }\n\n _ungroup(conditions: ConditionsArray, splitIndex: number) {\n if (conditions[splitIndex].isGroup()) {\n const copy = [...conditions]\n copy.splice(\n splitIndex,\n 1,\n ...conditions[splitIndex].getGroupedConditions()\n )\n return copy\n }\n return conditions\n }\n\n _autoGroupDefs(conditions: ConditionsArray) {\n const orPositions: number[] = []\n\n conditions.forEach((condition, index) => {\n if (condition.getCoordinator() === Coordinator.OR) {\n orPositions.push(index)\n }\n })\n\n const hasOr = orPositions.length > 0\n const hasAnd = !!conditions.find(\n (condition) => condition.getCoordinator() === Coordinator.AND\n )\n\n if (hasAnd && hasOr) {\n let start = 0\n const groupDefs: ConditionGroupDef[] = []\n orPositions.forEach((position, index) => {\n if (start < position - 1) {\n groupDefs.push(new ConditionGroupDef(start, position - 1))\n }\n const thisIsTheLastOr = orPositions.length === index + 1\n const thereAreMoreConditions = conditions.length - 1 > position\n if (thisIsTheLastOr && thereAreMoreConditions) {\n groupDefs.push(new ConditionGroupDef(position, conditions.length - 1))\n }\n start = position\n })\n return groupDefs\n }\n\n return []\n }\n\n toJSON() {\n const name = this.#conditionName\n const conditions = this.#userGroupedConditions\n return {\n name,\n conditions: conditions.map((it) => it.clone())\n }\n }\n\n // TODO:- why is this not a constructor?\n static from(obj: ConditionRawObject | ConditionsModel) {\n if (obj instanceof ConditionsModel) {\n return obj\n }\n const toReturn = new ConditionsModel()\n toReturn.#conditionName = obj.name\n toReturn.#userGroupedConditions = obj.conditions.map((condition) =>\n conditionFrom(condition)\n )\n toReturn.#groupedConditions = toReturn._applyGroups(\n toReturn.#userGroupedConditions\n )\n return toReturn\n }\n}\n\ninterface ConditionFrom {\n (\n it: Condition | ConditionRef | ConditionGroup\n ): Condition | ConditionRef | ConditionGroup\n}\n\nconst conditionFrom: ConditionFrom = function (it) {\n if ('conditions' in it) {\n return new ConditionGroup(\n (it as ConditionGroup).conditions.map((condition) =>\n conditionFrom(condition)\n )\n )\n }\n\n if ('conditionName' in it) {\n return new ConditionRef(\n it.conditionName,\n it.conditionDisplayName,\n it.coordinator\n )\n }\n\n return new Condition(\n ConditionField.from(it.field),\n it.operator,\n conditionValueFrom(it.value),\n it.coordinator\n )\n}\n"],"mappings":";;;;AAAA,IAAAA,eAAA,GAA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AS,CACzB,CAAC;IACDN,QAAQ,CAAC,CAACP,iBAAiB,GAAGO,QAAQ,CAACY,YAAY,CACjDZ,QAAQ,CAAC,CAACN,qBACZ,CAAC;IACD,OAAOM,QAAQ;EACjB;AACF;AAACqE,OAAA,CAAA7E,eAAA,GAAAA,eAAA;AAQD,MAAM4E,aAA4B,GAAG,SAAAA,CAAUlE,EAAE,EAAE;EACjD,IAAI,YAAY,IAAIA,EAAE,EAAE;IACtB,OAAO,IAAIoC,8BAAc,CACtBpC,EAAE,CAAoBqC,UAAU,CAACtC,GAAG,CAAEK,SAAS,IAC9C8D,aAAa,CAAC9D,SAAS,CACzB,CACF,CAAC;EACH;EAEA,IAAI,eAAe,IAAIJ,EAAE,EAAE;IACzB,OAAO,IAAIoE,0BAAY,CACrBpE,EAAE,CAACP,aAAa,EAChBO,EAAE,CAACqE,oBAAoB,EACvBrE,EAAE,CAACsE,WACL,CAAC;EACH;EAEA,OAAO,IAAIC,qBAAS,CAClBC,8BAAc,CAACR,IAAI,CAAChE,EAAE,CAACyE,KAAK,CAAC,EAC7BzE,EAAE,CAAC0E,QAAQ,EACX,IAAAC,mCAAkB,EAAC3E,EAAE,CAAC4E,KAAK,CAAC,EAC5B5E,EAAE,CAACsE,WACL,CAAC;AACH,CAAC"}
|
1
|
+
{"version":3,"file":"condition-model.js","names":["ConditionField","ConditionGroupDef","Condition","ConditionRef","ConditionGroup","conditionValueFrom","Coordinator","toPresentationString","toExpression","ConditionsModel","groupedConditions","userGroupedConditions","conditionName","undefined","constructor","_conditionsObject","clone","toReturn","map","it","clear","name","add","condition","coordinatorExpected","length","getCoordinator","Error","push","_applyGroups","replace","index","splice","remove","indexes","filter","_condition","includes","asFirstCondition","addGroups","groupDefs","_group","splitGroup","_ungroup","moveEarlier","switchCoordinators","moveLater","setCoordinator","asPerUserGroupings","hasConditions","lastIndex","join","correctedUserGroups","conditions","_autoGroupDefs","reduce","groups","groupDef","find","contains","startsWith","groupConditions","applyTo","splitIndex","isGroup","copy","getGroupedConditions","orPositions","forEach","OR","hasOr","hasAnd","AND","start","position","thisIsTheLastOr","thereAreMoreConditions","toJSON","from","obj","conditionFrom","conditionDisplayName","coordinator","field","operator","value"],"sources":["../../../src/conditions/condition-model.ts"],"sourcesContent":["import { ConditionField } from '~/src/conditions/condition-field.js'\nimport { ConditionGroupDef } from '~/src/conditions/condition-group-def.js'\nimport { Condition } from '~/src/conditions/condition.js'\nimport { ConditionRef } from '~/src/conditions/condition-ref.js'\nimport { ConditionGroup } from '~/src/conditions/condition-group.js'\nimport { conditionValueFrom } from '~/src/conditions/condition-values.js'\nimport { Coordinator } from '~/src/conditions/enums.js'\nimport { toPresentationString, toExpression } from '~/src/conditions/helpers.js'\nimport { type ConditionsArray } from '~/src/conditions/types.js'\n\ntype ConditionRawObject =\n | ConditionsModel\n | {\n name: string\n conditions: Condition[]\n }\n\nexport class ConditionsModel {\n #groupedConditions: ConditionsArray = []\n #userGroupedConditions: ConditionsArray = []\n #conditionName: string | undefined = undefined\n\n constructor(_conditionsObject?: ConditionRawObject) {}\n\n clone() {\n const toReturn = new ConditionsModel()\n toReturn.#groupedConditions = this.#groupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#userGroupedConditions = this.#userGroupedConditions.map((it) =>\n it.clone()\n )\n toReturn.#conditionName = this.#conditionName\n return toReturn\n }\n\n clear() {\n this.#userGroupedConditions = []\n this.#groupedConditions = []\n this.#conditionName = undefined\n return this\n }\n\n set name(name) {\n this.#conditionName = name\n }\n\n get name() {\n return this.#conditionName\n }\n\n add(condition: Condition) {\n const coordinatorExpected = this.#userGroupedConditions.length !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n }\n\n this.#userGroupedConditions.push(condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n replace(index: number, condition: Condition) {\n const coordinatorExpected = index !== 0\n\n if (condition.getCoordinator() && !coordinatorExpected) {\n throw Error('No coordinator allowed on the first condition')\n } else if (!condition.getCoordinator() && coordinatorExpected) {\n throw Error('Coordinator must be present on subsequent conditions')\n } else if (index >= this.#userGroupedConditions.length) {\n throw Error(\n `Cannot replace condition ${index} as no such condition exists`\n )\n }\n\n this.#userGroupedConditions.splice(index, 1, condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n\n return this\n }\n\n remove(indexes: number[]) {\n this.#userGroupedConditions = this.#userGroupedConditions\n .filter((_condition, index) => !indexes.includes(index))\n .map((condition, index) =>\n index === 0 ? condition.asFirstCondition() : condition\n )\n\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n addGroups(groupDefs: ConditionGroupDef[]) {\n this.#userGroupedConditions = this._group(\n this.#userGroupedConditions,\n groupDefs\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n splitGroup(index: number) {\n this.#userGroupedConditions = this._ungroup(\n this.#userGroupedConditions,\n index\n )\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n moveEarlier(index: number) {\n if (index > 0 && index < this.#userGroupedConditions.length) {\n this.#userGroupedConditions.splice(\n index - 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 1) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n moveLater(index: number) {\n if (index >= 0 && index < this.#userGroupedConditions.length - 1) {\n this.#userGroupedConditions.splice(\n index + 1,\n 0,\n this.#userGroupedConditions.splice(index, 1)[0]\n )\n if (index === 0) {\n this.switchCoordinators()\n }\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n }\n return this\n }\n\n switchCoordinators() {\n this.#userGroupedConditions[1].setCoordinator(\n this.#userGroupedConditions[0].getCoordinator()\n )\n this.#userGroupedConditions[0].setCoordinator(undefined)\n }\n\n get asPerUserGroupings() {\n return [...this.#userGroupedConditions]\n }\n\n get hasConditions() {\n return this.#userGroupedConditions.length > 0\n }\n\n get lastIndex() {\n return this.#userGroupedConditions.length - 1\n }\n\n toPresentationString() {\n return this.#groupedConditions\n .map((condition) => toPresentationString(condition))\n .join(' ')\n }\n\n toExpression() {\n return this.#groupedConditions\n .map((condition) => toExpression(condition))\n .join(' ')\n }\n\n _applyGroups(\n userGroupedConditions: (Condition | ConditionGroup | ConditionRef)[]\n ) {\n const correctedUserGroups = userGroupedConditions.map((condition) =>\n condition instanceof ConditionGroup && condition.conditions.length > 2\n ? new ConditionGroup(\n this._group(\n condition.conditions,\n this._autoGroupDefs(condition.conditions)\n )\n )\n : condition\n )\n\n return this._group(\n correctedUserGroups,\n this._autoGroupDefs(correctedUserGroups)\n )\n }\n\n _group(conditions: ConditionsArray, groupDefs: ConditionGroupDef[]) {\n return conditions.reduce((groups, condition, index, conditions) => {\n const groupDef = groupDefs.find((groupDef) => groupDef.contains(index))\n\n if (groupDef) {\n if (groupDef.startsWith(index)) {\n const groupConditions = groupDef.applyTo(conditions)\n groups.push(new ConditionGroup(groupConditions))\n }\n } else {\n groups.push(condition)\n }\n\n return groups\n }, [] as ConditionsArray)\n }\n\n _ungroup(conditions: ConditionsArray, splitIndex: number) {\n if (conditions[splitIndex].isGroup()) {\n const copy = [...conditions]\n copy.splice(\n splitIndex,\n 1,\n ...conditions[splitIndex].getGroupedConditions()\n )\n return copy\n }\n return conditions\n }\n\n _autoGroupDefs(conditions: ConditionsArray) {\n const orPositions: number[] = []\n\n conditions.forEach((condition, index) => {\n if (condition.getCoordinator() === Coordinator.OR) {\n orPositions.push(index)\n }\n })\n\n const hasOr = orPositions.length > 0\n const hasAnd = !!conditions.find(\n (condition) => condition.getCoordinator() === Coordinator.AND\n )\n\n if (hasAnd && hasOr) {\n let start = 0\n const groupDefs: ConditionGroupDef[] = []\n orPositions.forEach((position, index) => {\n if (start < position - 1) {\n groupDefs.push(new ConditionGroupDef(start, position - 1))\n }\n const thisIsTheLastOr = orPositions.length === index + 1\n const thereAreMoreConditions = conditions.length - 1 > position\n if (thisIsTheLastOr && thereAreMoreConditions) {\n groupDefs.push(new ConditionGroupDef(position, conditions.length - 1))\n }\n start = position\n })\n return groupDefs\n }\n\n return []\n }\n\n toJSON() {\n const name = this.#conditionName\n const conditions = this.#userGroupedConditions\n return {\n name,\n conditions: conditions.map((it) => it.clone())\n }\n }\n\n // TODO:- why is this not a constructor?\n static from(obj: ConditionRawObject | ConditionsModel) {\n if (obj instanceof ConditionsModel) {\n return obj\n }\n const toReturn = new ConditionsModel()\n toReturn.#conditionName = obj.name\n toReturn.#userGroupedConditions = obj.conditions.map((condition) =>\n conditionFrom(condition)\n )\n toReturn.#groupedConditions = toReturn._applyGroups(\n toReturn.#userGroupedConditions\n )\n return toReturn\n }\n}\n\ninterface ConditionFrom {\n (\n it: Condition | ConditionRef | ConditionGroup\n ): Condition | ConditionRef | ConditionGroup\n}\n\nconst conditionFrom: ConditionFrom = function (it) {\n if ('conditions' in it) {\n return new ConditionGroup(\n (it as ConditionGroup).conditions.map((condition) =>\n conditionFrom(condition)\n )\n )\n }\n\n if ('conditionName' in it) {\n return new ConditionRef(\n it.conditionName,\n it.conditionDisplayName,\n it.coordinator\n )\n }\n\n return new Condition(\n ConditionField.from(it.field),\n it.operator,\n conditionValueFrom(it.value),\n it.coordinator\n )\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,iBAAiB;AAC1B,SAASC,SAAS;AAClB,SAASC,YAAY;AACrB,SAASC,cAAc;AACvB,SAASC,kBAAkB;AAC3B,SAASC,WAAW;AACpB,SAASC,oBAAoB,EAAEC,YAAY;AAU3C,OAAO,MAAMC,eAAe,CAAC;EAC3B,CAACC,iBAAiB,GAAoB,EAAE;EACxC,CAACC,qBAAqB,GAAoB,EAAE;EAC5C,CAACC,aAAa,GAAuBC,SAAS;EAE9CC,WAAWA,CAACC,iBAAsC,EAAE,CAAC;EAErDC,KAAKA,CAAA,E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B,EAAE,CAACP,aAAa,EAChBO,EAAE,CAAC8D,oBAAoB,EACvB9D,EAAE,CAAC+D,WACL,CAAC;EACH;EAEA,OAAO,IAAIhF,SAAS,CAClBF,cAAc,CAAC8E,IAAI,CAAC3D,EAAE,CAACgE,KAAK,CAAC,EAC7BhE,EAAE,CAACiE,QAAQ,EACX/E,kBAAkB,CAACc,EAAE,CAACkE,KAAK,CAAC,EAC5BlE,EAAE,CAAC+D,WACL,CAAC;AACH,CAAC"}
|
@@ -1,12 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
exports.customOperators = exports.absoluteDateOrTimeOperatorNames = void 0;
|
5
|
-
exports.getExpression = getExpression;
|
6
|
-
exports.getOperatorConfig = getOperatorConfig;
|
7
|
-
exports.getOperatorNames = getOperatorNames;
|
8
|
-
exports.relativeDateOrTimeOperatorNames = void 0;
|
9
|
-
var _conditionValues = require("./condition-values");
|
1
|
+
import { timeUnits, dateUnits, dateTimeUnits, ConditionValue, DateDirections, RelativeTimeValue } from "./condition-values.js";
|
10
2
|
const defaultOperators = {
|
11
3
|
is: inline('=='),
|
12
4
|
'is not': inline('!=')
|
@@ -31,7 +23,7 @@ const relativeTimeOperators = units => ({
|
|
31
23
|
'is less than': relativeTime('>', '<', units),
|
32
24
|
'is more than': relativeTime('<', '>', units)
|
33
25
|
});
|
34
|
-
const customOperators =
|
26
|
+
export const customOperators = {
|
35
27
|
CheckboxesField: {
|
36
28
|
contains: reverseInline('in'),
|
37
29
|
'does not contain': not(reverseInline('in'))
|
@@ -42,25 +34,25 @@ const customOperators = exports.customOperators = {
|
|
42
34
|
'is less than': inline('<'),
|
43
35
|
'is more than': inline('>')
|
44
36
|
}),
|
45
|
-
DateField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(
|
46
|
-
TimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(
|
47
|
-
DatePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(
|
48
|
-
DateTimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(
|
49
|
-
DateTimePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(
|
37
|
+
DateField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateUnits)),
|
38
|
+
TimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(timeUnits)),
|
39
|
+
DatePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateUnits)),
|
40
|
+
DateTimeField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateTimeUnits)),
|
41
|
+
DateTimePartsField: Object.assign({}, absoluteDateTimeOperators, relativeTimeOperators(dateTimeUnits)),
|
50
42
|
TextField: withDefaults(textBasedFieldCustomisations),
|
51
43
|
MultilineTextField: withDefaults(textBasedFieldCustomisations),
|
52
44
|
EmailAddressField: withDefaults(textBasedFieldCustomisations)
|
53
45
|
};
|
54
|
-
function getOperatorNames(fieldType) {
|
46
|
+
export function getOperatorNames(fieldType) {
|
55
47
|
return Object.keys(getConditionals(fieldType)).sort();
|
56
48
|
}
|
57
|
-
function getExpression(fieldType, fieldName, operator, value) {
|
49
|
+
export function getExpression(fieldType, fieldName, operator, value) {
|
58
50
|
return getConditionals(fieldType)[operator].expression({
|
59
51
|
type: fieldType,
|
60
52
|
name: fieldName
|
61
53
|
}, value);
|
62
54
|
}
|
63
|
-
function getOperatorConfig(fieldType, operator) {
|
55
|
+
export function getOperatorConfig(fieldType, operator) {
|
64
56
|
return getConditionals(fieldType)[operator];
|
65
57
|
}
|
66
58
|
function getConditionals(fieldType) {
|
@@ -92,12 +84,12 @@ function formatValue(fieldType, value) {
|
|
92
84
|
}
|
93
85
|
return `'${value}'`;
|
94
86
|
}
|
95
|
-
const absoluteDateOrTimeOperatorNames =
|
96
|
-
const relativeDateOrTimeOperatorNames =
|
87
|
+
export const absoluteDateOrTimeOperatorNames = Object.keys(absoluteDateTimeOperators);
|
88
|
+
export const relativeDateOrTimeOperatorNames = Object.keys(relativeTimeOperators(dateTimeUnits));
|
97
89
|
function absoluteDateTime(operator) {
|
98
90
|
return {
|
99
91
|
expression: (field, value) => {
|
100
|
-
if (value instanceof
|
92
|
+
if (value instanceof ConditionValue) {
|
101
93
|
return `${field.name} ${operator} '${value.toExpression()}'`;
|
102
94
|
}
|
103
95
|
throw Error('only Value types are supported');
|
@@ -108,8 +100,8 @@ function relativeTime(pastOperator, futureOperator, units) {
|
|
108
100
|
return {
|
109
101
|
units,
|
110
102
|
expression: (field, value) => {
|
111
|
-
if (value instanceof
|
112
|
-
const operator = value.direction ===
|
103
|
+
if (value instanceof RelativeTimeValue) {
|
104
|
+
const operator = value.direction === DateDirections.PAST ? pastOperator : futureOperator;
|
113
105
|
return `${field.name} ${operator} ${value.toExpression()}`;
|
114
106
|
}
|
115
107
|
throw Error('time shift requires a TimeShiftValue');
|