@defra/forms-model 3.0.138 → 3.0.139
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/conditions/condition-abstract.js +1 -0
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -0
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +2 -0
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +1 -0
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -0
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +1 -0
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -0
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +6 -0
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +3 -0
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +12 -0
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +8 -0
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -0
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +2 -0
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/form/form-configuration/index.js +4 -0
- package/dist/module/form/form-configuration/index.js.map +1 -1
- package/dist/module/utils/logger.js +2 -0
- package/dist/module/utils/logger.js.map +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-abstract.js","names":["Coordinator","ConditionAbstract","
|
1
|
+
{"version":3,"file":"condition-abstract.js","names":["Coordinator","ConditionAbstract","coordinator","constructor","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;EAC7BC,WAAW;EAEXC,WAAWA,CAACD,WAAoC,EAAE;IAChD,IAAIA,WAAW,IAAI,CAACE,MAAM,CAACC,MAAM,CAACL,WAAW,CAAC,CAACM,QAAQ,CAACJ,WAAW,CAAC,EAAE;MACpE,MAAMK,KAAK,CAAE,eAAcL,WAAY,6BAA4B,CAAC;IACtE;IAEA,IAAI,CAACA,WAAW,GAAGA,WAAW;EAChC;EAEAM,iBAAiBA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACN,WAAW,GAAI,GAAE,IAAI,CAACA,WAAY,GAAE,GAAG,EAAE;EACvD;EAEAO,cAAcA,CAAA,EAAG;IACf,OAAO,IAAI,CAACP,WAAW;EACzB;EAEAQ,cAAcA,CAACR,WAAoC,EAAE;IACnD,IAAI,CAACA,WAAW,GAAGA,WAAW;EAChC;EAEAS,OAAOA,CAAA,EAAG;IACR,OAAO,KAAK;EACd;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,CAAC,IAAI,CAAC;EACf;EAEAC,iBAAiBA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACX,WAAW;EACzB;EAEAY,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","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-field.js","names":["ComponentTypes","ConditionField","
|
1
|
+
{"version":3,"file":"condition-field.js","names":["ComponentTypes","ConditionField","name","type","display","constructor","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;EAC1BC,IAAI;EACJC,IAAI;EACJC,OAAO;EAEPC,WAAWA,CAACH,IAAY,EAAEC,IAAmB,EAAEC,OAAe,EAAE;IAC9D,IAAI,CAACF,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACrC,MAAMI,KAAK,CAAE,QAAOJ,IAAK,eAAc,CAAC;IAC1C;IAEA,IAAI,CAACF,cAAc,CAACO,IAAI,CAAEC,aAAa,IAAKA,aAAa,CAACL,IAAI,KAAKA,IAAI,CAAC,EAAE;MACxE,MAAMG,KAAK,CAAE,QAAOH,IAAK,eAAc,CAAC;IAC1C;IAEA,IAAI,CAACC,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC3C,MAAME,KAAK,CAAE,WAAUF,OAAQ,eAAc,CAAC;IAChD;IAEA,IAAI,CAACF,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,OAAO,GAAGA,OAAO;EACxB;EAEA,OAAOK,IAAIA,CAACC,GAA2D,EAAE;IACvE,OAAO,IAAIT,cAAc,CAACS,GAAG,CAACR,IAAI,EAAEQ,GAAG,CAACP,IAAI,EAAEO,GAAG,CAACN,OAAO,CAAC;EAC5D;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-group-def.js","names":["ConditionGroupDef","
|
1
|
+
{"version":3,"file":"condition-group-def.js","names":["ConditionGroupDef","first","last","constructor","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;EAC7BC,KAAK;EACLC,IAAI;EAEJC,WAAWA,CAACF,KAAa,EAAEC,IAAY,EAAE;IACvC,IAAI,OAAOD,KAAK,KAAK,QAAQ,IAAI,OAAOC,IAAI,KAAK,QAAQ,EAAE;MACzD,MAAME,KAAK,CAAE,iCAAgCH,KAAM,QAAOC,IAAK,EAAC,CAAC;IACnE,CAAC,MAAM,IAAID,KAAK,IAAIC,IAAI,EAAE;MACxB,MAAME,KAAK,CAAE,SAAQF,IAAK,iCAAgCD,KAAM,GAAE,CAAC;IACrE;IAEA,IAAI,CAACA,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACC,IAAI,GAAGA,IAAI;EAClB;EAEAG,QAAQA,CAACC,KAAa,EAAE;IACtB,OAAO,IAAI,CAACL,KAAK,IAAIK,KAAK,IAAI,IAAI,CAACJ,IAAI,IAAII,KAAK;EAClD;EAEAC,UAAUA,CAACD,KAAa,EAAE;IACxB,OAAO,IAAI,CAACL,KAAK,KAAKK,KAAK;EAC7B;EAEAE,OAAOA,CAACC,UAA2B,EAAE;IACnC,OAAO,CAAC,GAAGA,UAAU,CAAC,CAACC,MAAM,CAAC,IAAI,CAACT,KAAK,EAAE,IAAI,CAACC,IAAI,GAAG,IAAI,CAACD,KAAK,GAAG,CAAC,CAAC;EACvE;AACF","ignoreList":[]}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { toPresentationString, toExpression } from "./helpers.js";
|
2
2
|
export class ConditionGroup {
|
3
|
+
conditions;
|
3
4
|
constructor(conditions = []) {
|
4
5
|
if (!Array.isArray(conditions) || conditions.length < 2) {
|
5
6
|
throw Error('Cannot construct a condition group from a single condition');
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-group.js","names":["toPresentationString","toExpression","ConditionGroup","
|
1
|
+
{"version":3,"file":"condition-group.js","names":["toPresentationString","toExpression","ConditionGroup","conditions","constructor","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 { type 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;EAC1BC,UAAU;EAEVC,WAAWA,CAACD,UAA2B,GAAG,EAAE,EAAE;IAC5C,IAAI,CAACE,KAAK,CAACC,OAAO,CAACH,UAAU,CAAC,IAAIA,UAAU,CAACI,MAAM,GAAG,CAAC,E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AC;EAChD;EAEAC,OAAOA,CAAA,EAAG;IACR,OAAO,IAAI;EACb;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACnB,UAAU,CAACU,GAAG,CAAEC,SAAS,IAAKA,SAAS,CAACS,KAAK,CAAC,CAAC,CAAC;EAC9D;EAEAA,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIrB,cAAc,CACvB,IAAI,CAACC,UAAU,CAACU,GAAG,CAAEC,SAAS,IAAKA,SAAS,CAACS,KAAK,CAAC,CAAC,CACtD,CAAC;EACH;AACF","ignoreList":[]}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { ConditionAbstract } from "./condition-abstract.js";
|
2
2
|
export class ConditionRef extends ConditionAbstract {
|
3
|
+
conditionName;
|
4
|
+
conditionDisplayName;
|
3
5
|
constructor(conditionName, conditionDisplayName, coordinator) {
|
4
6
|
super(coordinator);
|
5
7
|
if (typeof conditionName !== 'string') {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-ref.js","names":["ConditionAbstract","ConditionRef","
|
1
|
+
{"version":3,"file":"condition-ref.js","names":["ConditionAbstract","ConditionRef","conditionName","conditionDisplayName","constructor","coordinator","Error","asFirstCondition","_asFirstCondition","conditionString","conditionExpression","clone"],"sources":["../../../src/conditions/condition-ref.ts"],"sourcesContent":["import { ConditionAbstract } from '~/src/conditions/condition-abstract.js'\nimport { type Coordinator } from '~/src/conditions/enums.js'\n\nexport class ConditionRef extends ConditionAbstract {\n conditionName: string\n conditionDisplayName: string\n\n constructor(\n conditionName: string,\n conditionDisplayName: string,\n coordinator: Coordinator | undefined\n ) {\n super(coordinator)\n\n if (typeof conditionName !== 'string') {\n throw Error(`condition name ${conditionName} is not valid`)\n }\n\n if (typeof conditionDisplayName !== 'string') {\n throw Error(`condition display name ${conditionDisplayName} is not valid`)\n }\n\n this.conditionName = conditionName\n this.conditionDisplayName = conditionDisplayName\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.conditionDisplayName}'`\n }\n\n conditionExpression() {\n return this.conditionName\n }\n\n clone() {\n return new ConditionRef(\n this.conditionName,\n this.conditionDisplayName,\n this.coordinator\n )\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB;AAG1B,OAAO,MAAMC,YAAY,SAASD,iBAAiB,CAAC;EAClDE,aAAa;EACbC,oBAAoB;EAEpBC,WAAWA,CACTF,aAAqB,EACrBC,oBAA4B,EAC5BE,WAAoC,EACpC;IACA,KAAK,CAACA,WAAW,CAAC;IAElB,IAAI,OAAOH,aAAa,KAAK,QAAQ,EAAE;MACrC,MAAMI,KAAK,CAAE,kBAAiBJ,aAAc,eAAc,CAAC;IAC7D;IAEA,IAAI,OAAOC,oBAAoB,KAAK,QAAQ,EAAE;MAC5C,MAAMG,KAAK,CAAE,0BAAyBH,oBAAqB,eAAc,CAAC;IAC5E;IAEA,IAAI,CAACD,aAAa,GAAGA,aAAa;IAClC,IAAI,CAACC,oBAAoB,GAAGA,oBAAoB;EAClD;EAEAI,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACC,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI;EACb;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAQ,IAAG,IAAI,CAACN,oBAAqB,GAAE;EACzC;EAEAO,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACR,aAAa;EAC3B;EAEAS,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIV,YAAY,CACrB,IAAI,CAACC,aAAa,EAClB,IAAI,CAACC,oBAAoB,EACzB,IAAI,CAACE,WACP,CAAC;EACH;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-value-abstract.js","names":["Registration","ConditionValueAbstract","constructor","registration","new","target","TypeError","
|
1
|
+
{"version":3,"file":"condition-value-abstract.js","names":["Registration","ConditionValueAbstract","type","constructor","registration","new","target","TypeError","toPresentationString","Error","toExpression"],"sources":["../../../src/conditions/condition-value-abstract.ts"],"sourcesContent":["import { Registration } from '~/src/conditions/condition-value-registration.js'\n\nexport class ConditionValueAbstract {\n type: string\n\n constructor(registration: Registration) {\n if (new.target === ConditionValueAbstract) {\n throw new TypeError('Cannot construct ConditionValue instances directly')\n }\n\n if (!(registration instanceof Registration)) {\n throw new TypeError(\n 'You must register your value type! Call registerValueType!'\n )\n }\n\n this.type = registration.type\n }\n\n toPresentationString() {\n throw new Error(\n 'Unsupported Operation. Method toPresentationString have not been implemented'\n )\n }\n\n toExpression() {\n throw new Error(\n 'Unsupported Operation. Method toExpression have not been implemented'\n )\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY;AAErB,OAAO,MAAMC,sBAAsB,CAAC;EAClCC,IAAI;EAEJC,WAAWA,CAACC,YAA0B,EAAE;IACtC,IAAIC,GAAG,CAACC,MAAM,KAAKL,sBAAsB,EAAE;MACzC,MAAM,IAAIM,SAAS,CAAC,oDAAoD,CAAC;IAC3E;IAEA,IAAI,EAAEH,YAAY,YAAYJ,YAAY,CAAC,EAAE;MAC3C,MAAM,IAAIO,SAAS,CACjB,4DACF,CAAC;IACH;IAEA,IAAI,CAACL,IAAI,GAAGE,YAAY,CAACF,IAAI;EAC/B;EAEAM,oBAAoBA,CAAA,EAAG;IACrB,MAAM,IAAIC,KAAK,CACb,8EACF,CAAC;EACH;EAEAC,YAAYA,CAAA,EAAG;IACb,MAAM,IAAID,KAAK,CACb,sEACF,CAAC;EACH;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-value-registration.js","names":["conditionValueFactories","Registration","
|
1
|
+
{"version":3,"file":"condition-value-registration.js","names":["conditionValueFactories","Registration","type","constructor","factory","register","conditionValueFrom","obj"],"sources":["../../../src/conditions/condition-value-registration.ts"],"sourcesContent":["const conditionValueFactories = {}\n\nexport class Registration {\n type: string\n\n constructor(type: string, factory: (obj: any) => Registration) {\n conditionValueFactories[type] = factory\n this.type = type\n }\n\n static register(type: string, factory: (obj: any) => Registration) {\n return new Registration(type, factory)\n }\n\n static conditionValueFrom(obj: { type: string; [prop: string]: any }) {\n return conditionValueFactories[obj.type](obj)\n }\n}\n"],"mappings":"AAAA,MAAMA,uBAAuB,GAAG,CAAC,CAAC;AAElC,OAAO,MAAMC,YAAY,CAAC;EACxBC,IAAI;EAEJC,WAAWA,CAACD,IAAY,EAAEE,OAAmC,EAAE;IAC7DJ,uBAAuB,CAACE,IAAI,CAAC,GAAGE,OAAO;IACvC,IAAI,CAACF,IAAI,GAAGA,IAAI;EAClB;EAEA,OAAOG,QAAQA,CAACH,IAAY,EAAEE,OAAmC,EAAE;IACjE,OAAO,IAAIH,YAAY,CAACC,IAAI,EAAEE,OAAO,CAAC;EACxC;EAEA,OAAOE,kBAAkBA,CAACC,GAA0C,EAAE;IACpE,OAAOP,uBAAuB,CAACO,GAAG,CAACL,IAAI,CAAC,CAACK,GAAG,CAAC;EAC/C;AACF","ignoreList":[]}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { ConditionValueAbstract } from "./condition-value-abstract.js";
|
2
2
|
import { Registration } from "./condition-value-registration.js";
|
3
3
|
export class ConditionValue extends ConditionValueAbstract {
|
4
|
+
value;
|
5
|
+
display;
|
4
6
|
constructor(value, display) {
|
5
7
|
super(valueType);
|
6
8
|
if (!value || typeof value !== 'string') {
|
@@ -61,6 +63,10 @@ export const timeUnits = {
|
|
61
63
|
};
|
62
64
|
export const dateTimeUnits = Object.assign({}, dateUnits, timeUnits);
|
63
65
|
export class RelativeTimeValue extends ConditionValueAbstract {
|
66
|
+
timePeriod;
|
67
|
+
timeUnit;
|
68
|
+
direction;
|
69
|
+
timeOnly;
|
64
70
|
constructor(timePeriod, timeUnit, direction, timeOnly = false) {
|
65
71
|
super(relativeTimeValueType);
|
66
72
|
if (typeof timePeriod !== 'string') {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition-values.js","names":["ConditionValueAbstract","Registration","ConditionValue","
|
1
|
+
{"version":3,"file":"condition-values.js","names":["ConditionValueAbstract","Registration","ConditionValue","value","display","constructor","valueType","Error","toPresentationString","toExpression","from","obj","clone","register","DateDirections","dateUnits","YEARS","MONTHS","DAYS","timeUnits","HOURS","MINUTES","SECONDS","dateTimeUnits","Object","assign","RelativeTimeValue","timePeriod","timeUnit","direction","timeOnly","relativeTimeValueType","values","map","unit","includes","PAST","Number","conditionValueFrom"],"sources":["../../../src/conditions/condition-values.ts"],"sourcesContent":["import { ConditionValueAbstract } from '~/src/conditions/condition-value-abstract.js'\nimport { Registration } from '~/src/conditions/condition-value-registration.js'\nimport {\n type DateTimeUnitValues,\n type DateUnits,\n type TimeUnits\n} from '~/src/conditions/types.js'\n\nexport class ConditionValue extends ConditionValueAbstract {\n value: string\n display: string\n\n constructor(value: string, display?: string) {\n super(valueType)\n\n if (!value || typeof value !== 'string') {\n throw Error(`value ${value} is not valid`)\n }\n\n if (display && typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n\n this.value = value\n this.display = display || value\n }\n\n toPresentationString() {\n return this.display\n }\n\n toExpression() {\n return this.value\n }\n\n static from(obj: { value: string; display?: string }) {\n return new ConditionValue(obj.value, obj.display)\n }\n\n clone() {\n return ConditionValue.from(this)\n }\n}\n\nconst valueType = Registration.register('Value', (obj) =>\n ConditionValue.from(obj)\n)\n\nexport enum DateDirections {\n FUTURE = 'in the future',\n PAST = 'in the past'\n}\n\nexport const dateUnits: DateUnits = {\n YEARS: { display: 'year(s)', value: 'years' },\n MONTHS: { display: 'month(s)', value: 'months' },\n DAYS: { display: 'day(s)', value: 'days' }\n}\n\nexport const timeUnits: TimeUnits = {\n HOURS: { display: 'hour(s)', value: 'hours' },\n MINUTES: { display: 'minute(s)', value: 'minutes' },\n SECONDS: { display: 'second(s)', value: 'seconds' }\n}\n\nexport const dateTimeUnits: DateUnits & TimeUnits = Object.assign(\n {},\n dateUnits,\n timeUnits\n)\n\nexport class RelativeTimeValue extends ConditionValueAbstract {\n timePeriod: string\n timeUnit: DateTimeUnitValues\n direction: DateDirections\n timeOnly: boolean\n\n constructor(\n timePeriod: string,\n timeUnit: DateTimeUnitValues,\n direction: DateDirections,\n timeOnly = false\n ) {\n super(relativeTimeValueType)\n\n if (typeof timePeriod !== 'string') {\n throw Error(`time period ${timePeriod} is not valid`)\n }\n\n if (\n !Object.values(dateTimeUnits)\n .map((unit) => unit.value)\n .includes(timeUnit)\n ) {\n throw Error(`time unit ${timeUnit} is not valid`)\n }\n\n if (!Object.values(DateDirections).includes(direction)) {\n throw Error(`direction ${direction} is not valid`)\n }\n\n this.timePeriod = timePeriod\n this.timeUnit = timeUnit\n this.direction = direction\n this.timeOnly = timeOnly\n }\n\n toPresentationString() {\n return `${this.timePeriod} ${this.timeUnit} ${this.direction}`\n }\n\n toExpression(): string {\n const timePeriod =\n this.direction === DateDirections.PAST\n ? 0 - Number(this.timePeriod)\n : this.timePeriod\n return this.timeOnly\n ? `timeForComparison(${timePeriod}, '${this.timeUnit}')`\n : `dateForComparison(${timePeriod}, '${this.timeUnit}')`\n }\n\n static from(obj) {\n return new RelativeTimeValue(\n obj.timePeriod,\n obj.timeUnit,\n obj.direction,\n obj.timeOnly\n )\n }\n\n clone() {\n return RelativeTimeValue.from(this)\n }\n}\n\nexport const relativeTimeValueType = Registration.register(\n 'RelativeTime',\n (obj): RelativeTimeValue => RelativeTimeValue.from(obj)\n)\n\ntype ConditionValueFrom =\n | Pick<ConditionValue, 'type' | 'value' | 'display'>\n | Pick<\n RelativeTimeValue,\n 'type' | 'timePeriod' | 'timeUnit' | 'direction' | 'timeOnly'\n >\n\nexport function conditionValueFrom(obj: ConditionValueFrom) {\n return Registration.conditionValueFrom(obj)\n}\n"],"mappings":"AAAA,SAASA,sBAAsB;AAC/B,SAASC,YAAY;AAOrB,OAAO,MAAMC,cAAc,SAASF,sBAAsB,CAAC;EACzDG,KAAK;EACLC,OAAO;EAEPC,WAAWA,CAACF,KAAa,EAAEC,OAAgB,EAAE;IAC3C,KAAK,CAACE,SAAS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AAG,IAAI,CAACC,QAAS,IAAG,IAAI,CAACC,SAAU,EAAC;EAChE;EAEApB,YAAYA,CAAA,EAAW;IACrB,MAAMkB,UAAU,GACd,IAAI,CAACE,SAAS,KAAKf,cAAc,CAACsB,IAAI,GAClC,CAAC,GAAGC,MAAM,CAAC,IAAI,CAACV,UAAU,CAAC,GAC3B,IAAI,CAACA,UAAU;IACrB,OAAO,IAAI,CAACG,QAAQ,GACf,qBAAoBH,UAAW,MAAK,IAAI,CAACC,QAAS,IAAG,GACrD,qBAAoBD,UAAW,MAAK,IAAI,CAACC,QAAS,IAAG;EAC5D;EAEA,OAAOlB,IAAIA,CAACC,GAAG,EAAE;IACf,OAAO,IAAIe,iBAAiB,CAC1Bf,GAAG,CAACgB,UAAU,EACdhB,GAAG,CAACiB,QAAQ,EACZjB,GAAG,CAACkB,SAAS,EACblB,GAAG,CAACmB,QACN,CAAC;EACH;EAEAlB,KAAKA,CAAA,EAAG;IACN,OAAOc,iBAAiB,CAAChB,IAAI,CAAC,IAAI,CAAC;EACrC;AACF;AAEA,OAAO,MAAMqB,qBAAqB,GAAG9B,YAAY,CAACY,QAAQ,CACxD,cAAc,EACbF,GAAG,IAAwBe,iBAAiB,CAAChB,IAAI,CAACC,GAAG,CACxD,CAAC;AASD,OAAO,SAAS2B,kBAAkBA,CAAC3B,GAAuB,EAAE;EAC1D,OAAOV,YAAY,CAACqC,kBAAkB,CAAC3B,GAAG,CAAC;AAC7C","ignoreList":[]}
|
@@ -3,6 +3,9 @@ import { ConditionField } from "./condition-field.js";
|
|
3
3
|
import { getExpression } from "./condition-operators.js";
|
4
4
|
import { ConditionValueAbstract } from "./condition-value-abstract.js";
|
5
5
|
export class Condition extends ConditionAbstract {
|
6
|
+
field;
|
7
|
+
operator;
|
8
|
+
value;
|
6
9
|
constructor(field, operator, value, coordinator) {
|
7
10
|
super(coordinator);
|
8
11
|
if (!(field instanceof ConditionField)) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"condition.js","names":["ConditionAbstract","ConditionField","getExpression","ConditionValueAbstract","Condition","
|
1
|
+
{"version":3,"file":"condition.js","names":["ConditionAbstract","ConditionField","getExpression","ConditionValueAbstract","Condition","field","operator","value","constructor","coordinator","Error","asFirstCondition","_asFirstCondition","conditionString","display","toPresentationString","conditionExpression","type","name","clone","from"],"sources":["../../../src/conditions/condition.ts"],"sourcesContent":["import { ConditionAbstract } from '~/src/conditions/condition-abstract.js'\nimport { ConditionField } from '~/src/conditions/condition-field.js'\nimport { getExpression } from '~/src/conditions/condition-operators.js'\nimport { ConditionValueAbstract } from '~/src/conditions/condition-value-abstract.js'\nimport {\n type ConditionValue,\n type RelativeTimeValue\n} from '~/src/conditions/condition-values.js'\nimport { type Coordinator } from '~/src/conditions/enums.js'\n\nexport class Condition extends ConditionAbstract {\n field: ConditionField\n operator: string\n value: ConditionValue | RelativeTimeValue\n\n constructor(\n field: ConditionField,\n operator: string,\n value: ConditionValue | RelativeTimeValue,\n coordinator?: Coordinator\n ) {\n super(coordinator)\n\n if (!(field instanceof ConditionField)) {\n throw Error(`field ${field} is not a valid ConditionField object`)\n }\n if (typeof operator !== 'string') {\n throw Error(`operator ${operator} is not a valid operator`)\n }\n if (!(value instanceof ConditionValueAbstract)) {\n throw Error(`value ${value} is not a valid value type`)\n }\n\n this.field = field\n this.operator = operator\n this.value = value\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.field.display}' ${\n this.operator\n } '${this.value.toPresentationString()}'`\n }\n\n conditionExpression() {\n return getExpression(\n this.field.type,\n this.field.name,\n this.operator,\n this.value\n )\n }\n\n clone() {\n return new Condition(\n ConditionField.from(this.field),\n this.operator,\n this.value.clone(),\n this.coordinator\n )\n }\n}\n"],"mappings":"AAAA,SAASA,iBAAiB;AAC1B,SAASC,cAAc;AACvB,SAASC,aAAa;AACtB,SAASC,sBAAsB;AAO/B,OAAO,MAAMC,SAAS,SAASJ,iBAAiB,CAAC;EAC/CK,KAAK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ACF","ignoreList":[]}
|
@@ -192,6 +192,8 @@ function conditionFrom(it) {
|
|
192
192
|
return new Condition(Field.from(it.field), it.operator, valueFrom(it.value), it.coordinator);
|
193
193
|
}
|
194
194
|
export class GroupDef {
|
195
|
+
first;
|
196
|
+
last;
|
195
197
|
constructor(first, last) {
|
196
198
|
if (typeof first !== 'number' || typeof last !== 'number') {
|
197
199
|
throw Error(`Cannot construct a group from ${first} and ${last}`);
|
@@ -212,6 +214,7 @@ export class GroupDef {
|
|
212
214
|
}
|
213
215
|
}
|
214
216
|
class ConditionGroup {
|
217
|
+
conditions;
|
215
218
|
constructor(conditions) {
|
216
219
|
if (!Array.isArray(conditions) || conditions.length < 2) {
|
217
220
|
throw Error('Cannot construct a condition group from a single condition');
|
@@ -258,6 +261,9 @@ export function toExpression(condition) {
|
|
258
261
|
return `${condition.coordinatorString()}${condition.conditionExpression()}`;
|
259
262
|
}
|
260
263
|
export class Field {
|
264
|
+
name;
|
265
|
+
type;
|
266
|
+
display;
|
261
267
|
constructor(name, type, display) {
|
262
268
|
if (!name || typeof name !== 'string') {
|
263
269
|
throw Error(`name ${name} is not valid`);
|
@@ -277,6 +283,7 @@ export class Field {
|
|
277
283
|
}
|
278
284
|
}
|
279
285
|
class AbstractCondition {
|
286
|
+
coordinator;
|
280
287
|
constructor(coordinator) {
|
281
288
|
if (coordinator && !Object.values(coordinators).includes(coordinator)) {
|
282
289
|
throw Error(`coordinator ${coordinator} is not a valid coordinator`);
|
@@ -315,6 +322,9 @@ class AbstractCondition {
|
|
315
322
|
}
|
316
323
|
}
|
317
324
|
export class Condition extends AbstractCondition {
|
325
|
+
field;
|
326
|
+
operator;
|
327
|
+
value;
|
318
328
|
constructor(field, operator, value, coordinator) {
|
319
329
|
super(coordinator);
|
320
330
|
if (!(field instanceof Field)) {
|
@@ -345,6 +355,8 @@ export class Condition extends AbstractCondition {
|
|
345
355
|
}
|
346
356
|
}
|
347
357
|
export class ConditionRef extends AbstractCondition {
|
358
|
+
conditionName;
|
359
|
+
conditionDisplayName;
|
348
360
|
constructor(conditionName, conditionDisplayName, coordinator) {
|
349
361
|
super(coordinator);
|
350
362
|
if (typeof conditionName !== 'string') {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"inline-condition-model.js","names":["ComponentTypes","getExpression","AbstractConditionValue","valueFrom","coordinators","AND","OR","ConditionsModel","groupedConditions","userGroupedConditions","conditionName","constructor","clone","toReturn","map","it","clear","undefined","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","hasAnd","hasOr","start","position","GroupDef","thisIsTheLastOr","thereAreMoreConditions","toJSON","from","obj","conditionFrom","ConditionRef","conditionDisplayName","coordinator","Condition","Field","field","operator","value","first","last","Array","isArray","coordinatorString","conditionString","conditionExpression","type","display","componentType","AbstractCondition","Object","values","_asFirstCondition"],"sources":["../../../src/conditions/inline-condition-model.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { getExpression } from '~/src/conditions/inline-condition-operators.js'\nimport {\n AbstractConditionValue,\n valueFrom\n} from '~/src/conditions/inline-condition-values.js'\n\nexport const coordinators = {\n AND: 'and',\n OR: 'or'\n}\n\nexport class ConditionsModel {\n #groupedConditions\n #userGroupedConditions\n #conditionName\n\n constructor() {\n this.#groupedConditions = []\n this.#userGroupedConditions = []\n }\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) {\n const coordinatorExpected = this.#userGroupedConditions.length !== 0\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 this.#userGroupedConditions.push(condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n replace(index, condition) {\n const coordinatorExpected = index !== 0\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 this.#userGroupedConditions.splice(index, 1, condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n remove(indexes) {\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) {\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) {\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) {\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) {\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(userGroupedConditions) {\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 return this._group(\n correctedUserGroups,\n this._autoGroupDefs(correctedUserGroups)\n )\n }\n\n _group(conditions, groupDefs) {\n return conditions.reduce((groups, condition, index, conditions) => {\n const groupDef = groupDefs.find((groupDef) => groupDef.contains(index))\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 return groups\n }, [])\n }\n\n _ungroup(conditions, splitIndex) {\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) {\n const orPositions: number[] = []\n conditions.forEach((condition, index) => {\n if (condition.getCoordinator() === coordinators.OR) {\n orPositions.push(index)\n }\n })\n const hasAnd = !!conditions.find(\n (condition) => condition.getCoordinator() === coordinators.AND\n )\n const hasOr = orPositions.length > 0\n if (hasAnd && hasOr) {\n let start = 0\n const groupDefs: GroupDef[] = []\n orPositions.forEach((position, index) => {\n if (start < position - 1) {\n groupDefs.push(new GroupDef(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 GroupDef(position, conditions.length - 1))\n }\n start = position\n })\n return groupDefs\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 static from(obj) {\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((it) =>\n conditionFrom(it)\n )\n toReturn.#groupedConditions = toReturn._applyGroups(\n toReturn.#userGroupedConditions\n )\n return toReturn\n }\n}\n\nfunction conditionFrom(it) {\n if (it.conditions) {\n return new ConditionGroup(\n it.conditions.map((condition) => conditionFrom(condition))\n )\n }\n if (it.conditionName) {\n return new ConditionRef(\n it.conditionName,\n it.conditionDisplayName,\n it.coordinator\n )\n }\n return new Condition(\n Field.from(it.field),\n it.operator,\n valueFrom(it.value),\n it.coordinator\n )\n}\n\nexport class GroupDef {\n first\n last\n\n constructor(first, last) {\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 this.first = first\n this.last = last\n }\n\n contains(index) {\n return this.first <= index && this.last >= index\n }\n\n startsWith(index) {\n return this.first === index\n }\n\n applyTo(conditions) {\n return [...conditions].splice(this.first, this.last - this.first + 1)\n }\n}\n\nclass ConditionGroup {\n conditions\n\n constructor(conditions) {\n if (!Array.isArray(conditions) || conditions.length < 2) {\n throw Error('Cannot construct a condition group from a single condition')\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) {\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\nexport function toPresentationString(condition) {\n return `${condition.coordinatorString()}${condition.conditionString()}`\n}\n\nexport function toExpression(condition) {\n return `${condition.coordinatorString()}${condition.conditionExpression()}`\n}\n\nexport class Field {\n name\n type\n display\n\n constructor(name, type, display) {\n if (!name || typeof name !== 'string') {\n throw Error(`name ${name} is not valid`)\n }\n if (!ComponentTypes.find((componentType) => componentType.name === type)) {\n throw Error(`type ${type} is not valid`)\n }\n if (!display || typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n this.name = name\n this.type = type\n this.display = display\n }\n\n static from(obj) {\n return new Field(obj.name, obj.type, obj.display)\n }\n}\n\nclass AbstractCondition {\n coordinator\n\n constructor(coordinator) {\n if (coordinator && !Object.values(coordinators).includes(coordinator)) {\n throw Error(`coordinator ${coordinator} is not a valid coordinator`)\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) {\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 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n\n clone() {\n throw Error(\n 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n\n conditionString() {\n throw Error(\n 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n\n conditionExpression() {\n throw Error(\n 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n}\n\nexport class Condition extends AbstractCondition {\n field\n operator\n value\n\n constructor(field, operator, value, coordinator) {\n super(coordinator)\n if (!(field instanceof Field)) {\n throw Error(`field ${field} is not a valid Field object`)\n }\n if (typeof operator !== 'string') {\n throw Error(`operator ${operator} is not a valid operator`)\n }\n if (!(value instanceof AbstractConditionValue)) {\n throw Error(`value ${value} is not a valid value type`)\n }\n this.field = field\n this.operator = operator\n this.value = value\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.field.display}' ${\n this.operator\n } '${this.value.toPresentationString()}'`\n }\n\n conditionExpression() {\n return getExpression(\n this.field.type,\n this.field.name,\n this.operator,\n this.value\n )\n }\n\n clone() {\n return new Condition(\n Field.from(this.field),\n this.operator,\n this.value.clone(),\n this.coordinator\n )\n }\n}\n\nexport class ConditionRef extends AbstractCondition {\n conditionName\n conditionDisplayName\n\n constructor(conditionName, conditionDisplayName, coordinator) {\n super(coordinator)\n if (typeof conditionName !== 'string') {\n throw Error(`condition name ${conditionName} is not valid`)\n }\n if (typeof conditionDisplayName !== 'string') {\n throw Error(`condition display name ${conditionDisplayName} is not valid`)\n }\n this.conditionName = conditionName\n this.conditionDisplayName = conditionDisplayName\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.conditionDisplayName}'`\n }\n\n conditionExpression() {\n return this.conditionName\n }\n\n clone() {\n return new ConditionRef(\n this.conditionName,\n this.conditionDisplayName,\n this.coordinator\n )\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AACtB,SACEC,sBAAsB,EACtBC,SAAS;AAGX,OAAO,MAAMC,YAAY,GAAG;EAC1BC,GAAG,EAAE,KAAK;EACVC,EAAE,EAAE;AACN,CAAC;AAED,OAAO,MAAMC,eAAe,CAAC;EAC3B,CAACC,iBAAiB;EAClB,CAACC,qBAAqB;EACtB,CAACC,aAAa;EAEdC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAAC,CAACH,iBAAiB,GAAG,EAAE;IAC5B,IAAI,CAAC,CAACC,qBAAqB,GAAG,EAAE;EAClC;EAEAG,KAAKA,CAAA,EAAG;IACN,MAAMC,QAAQ,GAAG,IAAIN,eAAe,CAAC,CAAC;IACtCM,QAAQ,CAAC,CAACL,iBAAiB,GAAG,IAAI,CAAC,CAACA,iBAAiB,CAACM,GAAG,CAAEC,EAAE,IAC3DA,EAAE,CAACH,KAAK,CAAC,CACX,CAAC;IACDC,QAAQ,CAAC,CAACJ,qBAAqB,GAAG,IAAI,CAAC,CAACA,qBAAqB,CAACK,GAAG,CAAEC,EAAE,IACnEA,EAAE,CAACH,KAAK,CAAC,CACX,CAAC;IACDC,QAAQ,CAAC,CAACH,aAAa,GAAG,IAAI,CAAC,CAACA,aAAa;IAC7C,OAAOG,QAAQ;EACjB;EAEAG,KAAKA,CAAA,EAAG;IACN,IAAI,CAAC,CAACP,qBAAqB,GAAG,EAAE;IAChC,IAAI,CAAC,CAACD,iBAAiB,GAAG,EAAE;IAC5B,IAAI,CAAC,CAACE,aAAa,GAAGO,SAAS;IAC/B,OAAO,IAAI;EACb;EAEA,IAAIC,IAAIA,CAACA,IAAI,EAAE;IACb,IAAI,CAAC,CAACR,aAAa,GAAGQ,IAAI;EAC5B;EAEA,IAAIA,IAAIA,CAAA,EAAG;IACT,OAAO,IAA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AAO,IAAI,CAACpF,aAAa;EAC3B;EAEAE,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIoE,YAAY,CACrB,IAAI,CAACtE,aAAa,EAClB,IAAI,CAACuE,oBAAoB,EACzB,IAAI,CAACC,WACP,CAAC;EACH;AACF","ignoreList":[]}
|
1
|
+
{"version":3,"file":"inline-condition-model.js","names":["ComponentTypes","getExpression","AbstractConditionValue","valueFrom","coordinators","AND","OR","ConditionsModel","groupedConditions","userGroupedConditions","conditionName","constructor","clone","toReturn","map","it","clear","undefined","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","hasAnd","hasOr","start","position","GroupDef","thisIsTheLastOr","thereAreMoreConditions","toJSON","from","obj","conditionFrom","ConditionRef","conditionDisplayName","coordinator","Condition","Field","field","operator","value","first","last","Array","isArray","coordinatorString","conditionString","conditionExpression","type","display","componentType","AbstractCondition","Object","values","_asFirstCondition"],"sources":["../../../src/conditions/inline-condition-model.ts"],"sourcesContent":["import { ComponentTypes } from '~/src/components/component-types.js'\nimport { getExpression } from '~/src/conditions/inline-condition-operators.js'\nimport {\n AbstractConditionValue,\n valueFrom\n} from '~/src/conditions/inline-condition-values.js'\n\nexport const coordinators = {\n AND: 'and',\n OR: 'or'\n}\n\nexport class ConditionsModel {\n #groupedConditions\n #userGroupedConditions\n #conditionName\n\n constructor() {\n this.#groupedConditions = []\n this.#userGroupedConditions = []\n }\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) {\n const coordinatorExpected = this.#userGroupedConditions.length !== 0\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 this.#userGroupedConditions.push(condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n replace(index, condition) {\n const coordinatorExpected = index !== 0\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 this.#userGroupedConditions.splice(index, 1, condition)\n this.#groupedConditions = this._applyGroups(this.#userGroupedConditions)\n return this\n }\n\n remove(indexes) {\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) {\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) {\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) {\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) {\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(userGroupedConditions) {\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 return this._group(\n correctedUserGroups,\n this._autoGroupDefs(correctedUserGroups)\n )\n }\n\n _group(conditions, groupDefs) {\n return conditions.reduce((groups, condition, index, conditions) => {\n const groupDef = groupDefs.find((groupDef) => groupDef.contains(index))\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 return groups\n }, [])\n }\n\n _ungroup(conditions, splitIndex) {\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) {\n const orPositions: number[] = []\n conditions.forEach((condition, index) => {\n if (condition.getCoordinator() === coordinators.OR) {\n orPositions.push(index)\n }\n })\n const hasAnd = !!conditions.find(\n (condition) => condition.getCoordinator() === coordinators.AND\n )\n const hasOr = orPositions.length > 0\n if (hasAnd && hasOr) {\n let start = 0\n const groupDefs: GroupDef[] = []\n orPositions.forEach((position, index) => {\n if (start < position - 1) {\n groupDefs.push(new GroupDef(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 GroupDef(position, conditions.length - 1))\n }\n start = position\n })\n return groupDefs\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 static from(obj) {\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((it) =>\n conditionFrom(it)\n )\n toReturn.#groupedConditions = toReturn._applyGroups(\n toReturn.#userGroupedConditions\n )\n return toReturn\n }\n}\n\nfunction conditionFrom(it) {\n if (it.conditions) {\n return new ConditionGroup(\n it.conditions.map((condition) => conditionFrom(condition))\n )\n }\n if (it.conditionName) {\n return new ConditionRef(\n it.conditionName,\n it.conditionDisplayName,\n it.coordinator\n )\n }\n return new Condition(\n Field.from(it.field),\n it.operator,\n valueFrom(it.value),\n it.coordinator\n )\n}\n\nexport class GroupDef {\n first\n last\n\n constructor(first, last) {\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 this.first = first\n this.last = last\n }\n\n contains(index) {\n return this.first <= index && this.last >= index\n }\n\n startsWith(index) {\n return this.first === index\n }\n\n applyTo(conditions) {\n return [...conditions].splice(this.first, this.last - this.first + 1)\n }\n}\n\nclass ConditionGroup {\n conditions\n\n constructor(conditions) {\n if (!Array.isArray(conditions) || conditions.length < 2) {\n throw Error('Cannot construct a condition group from a single condition')\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) {\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\nexport function toPresentationString(condition) {\n return `${condition.coordinatorString()}${condition.conditionString()}`\n}\n\nexport function toExpression(condition) {\n return `${condition.coordinatorString()}${condition.conditionExpression()}`\n}\n\nexport class Field {\n name\n type\n display\n\n constructor(name, type, display) {\n if (!name || typeof name !== 'string') {\n throw Error(`name ${name} is not valid`)\n }\n if (!ComponentTypes.find((componentType) => componentType.name === type)) {\n throw Error(`type ${type} is not valid`)\n }\n if (!display || typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n this.name = name\n this.type = type\n this.display = display\n }\n\n static from(obj) {\n return new Field(obj.name, obj.type, obj.display)\n }\n}\n\nclass AbstractCondition {\n coordinator\n\n constructor(coordinator) {\n if (coordinator && !Object.values(coordinators).includes(coordinator)) {\n throw Error(`coordinator ${coordinator} is not a valid coordinator`)\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) {\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 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n\n clone() {\n throw Error(\n 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n\n conditionString() {\n throw Error(\n 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n\n conditionExpression() {\n throw Error(\n 'Implement on the subclass (Why do we have to have this method here at all?!)'\n )\n }\n}\n\nexport class Condition extends AbstractCondition {\n field\n operator\n value\n\n constructor(field, operator, value, coordinator) {\n super(coordinator)\n if (!(field instanceof Field)) {\n throw Error(`field ${field} is not a valid Field object`)\n }\n if (typeof operator !== 'string') {\n throw Error(`operator ${operator} is not a valid operator`)\n }\n if (!(value instanceof AbstractConditionValue)) {\n throw Error(`value ${value} is not a valid value type`)\n }\n this.field = field\n this.operator = operator\n this.value = value\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.field.display}' ${\n this.operator\n } '${this.value.toPresentationString()}'`\n }\n\n conditionExpression() {\n return getExpression(\n this.field.type,\n this.field.name,\n this.operator,\n this.value\n )\n }\n\n clone() {\n return new Condition(\n Field.from(this.field),\n this.operator,\n this.value.clone(),\n this.coordinator\n )\n }\n}\n\nexport class ConditionRef extends AbstractCondition {\n conditionName\n conditionDisplayName\n\n constructor(conditionName, conditionDisplayName, coordinator) {\n super(coordinator)\n if (typeof conditionName !== 'string') {\n throw Error(`condition name ${conditionName} is not valid`)\n }\n if (typeof conditionDisplayName !== 'string') {\n throw Error(`condition display name ${conditionDisplayName} is not valid`)\n }\n this.conditionName = conditionName\n this.conditionDisplayName = conditionDisplayName\n }\n\n asFirstCondition() {\n this._asFirstCondition()\n return this\n }\n\n conditionString() {\n return `'${this.conditionDisplayName}'`\n }\n\n conditionExpression() {\n return this.conditionName\n }\n\n clone() {\n return new ConditionRef(\n this.conditionName,\n this.conditionDisplayName,\n this.coordinator\n )\n }\n}\n"],"mappings":"AAAA,SAASA,cAAc;AACvB,SAASC,aAAa;AACtB,SACEC,sBAAsB,EACtBC,SAAS;AAGX,OAAO,MAAMC,YAAY,GAAG;EAC1BC,GAAG,EAAE,KAAK;EACVC,EAAE,EAAE;AACN,CAAC;AAED,OAAO,MAAMC,eAAe,CAAC;EAC3B,CAACC,iBAAiB;EAClB,CAACC,qBAAqB;EACtB,CAACC,aAAa;EAEdC,WAAWA,CAAA,EAAG;IACZ,IAAI,CAAC,CAACH,iBAAiB,GAAG,EAAE;IAC5B,IAAI,CAAC,CAACC,qBAAqB,GAAG,EAAE;EAClC;EAEAG,KAAKA,CAAA,EAAG;IACN,MAAMC,QAAQ,GAAG,IAAIN,eAAe,CAAC,CAAC;IACtCM,QAAQ,CAAC,CAACL,iBAAiB,GAAG,IAAI,CAAC,CAACA,iBAAiB,CAACM,GAAG,CAAEC,EAAE,IAC3DA,EAAE,CAACH,KAAK,CAAC,CACX,CAAC;IACDC,QAAQ,CAAC,CAACJ,qBAAqB,GAAG,IAAI,CAAC,CAACA,qBAAqB,CAACK,GAAG,CAAEC,EAAE,IACnEA,EAAE,CAACH,KAAK,CAAC,CACX,CAAC;IACDC,QAAQ,CAAC,CAACH,aAAa,GAAG,IAAI,CAAC,CAACA,aAAa;IAC7C,OAAOG,QAAQ;EACjB;EAEAG,KAAKA,CAAA,EAAG;IACN,IAAI,CAAC,CAACP,qBAAqB,GAAG,EAAE;IAChC,IAAI,CAAC,CAACD,iBAAiB,GAAG,EAAE;IAC5B,IAAI,CAAC,CAACE,aAAa,GAAGO,SAAS;IAC/B,OAAO,IAAI;EACb;EAEA,IAAIC,IAAIA,CAACA,IAAI,EAAE;IACb,IAAI,CAAC,CAACR,aAAa,GAAGQ,IAAI;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EAClD;EAEA9C,gBAAgBA,CAAA,EAAG;IACjB,IAAI,CAACkE,iBAAiB,CAAC,CAAC;IACxB,OAAO,IAAI;EACb;EAEAR,eAAeA,CAAA,EAAG;IAChB,OAAQ,IAAG,IAAI,CAACZ,oBAAqB,GAAE;EACzC;EAEAa,mBAAmBA,CAAA,EAAG;IACpB,OAAO,IAAI,CAACpF,aAAa;EAC3B;EAEAE,KAAKA,CAAA,EAAG;IACN,OAAO,IAAIoE,YAAY,CACrB,IAAI,CAACtE,aAAa,EAClB,IAAI,CAACuE,oBAAoB,EACzB,IAAI,CAACC,WACP,CAAC;EACH;AACF","ignoreList":[]}
|
@@ -1,11 +1,13 @@
|
|
1
1
|
const conditionValueFactories = {};
|
2
2
|
class Registration {
|
3
|
+
type;
|
3
4
|
constructor(type, factory) {
|
4
5
|
conditionValueFactories[type] = factory;
|
5
6
|
this.type = type;
|
6
7
|
}
|
7
8
|
}
|
8
9
|
export class AbstractConditionValue {
|
10
|
+
type;
|
9
11
|
constructor(registration) {
|
10
12
|
if (new.target === AbstractConditionValue) {
|
11
13
|
throw new TypeError('Cannot construct ConditionValue instances directly');
|
@@ -20,6 +22,8 @@ export class AbstractConditionValue {
|
|
20
22
|
}
|
21
23
|
const valueType = registerValueType('Value', obj => ConditionValue.from(obj));
|
22
24
|
export class ConditionValue extends AbstractConditionValue {
|
25
|
+
value;
|
26
|
+
display;
|
23
27
|
constructor(value, display) {
|
24
28
|
super(valueType);
|
25
29
|
if (!value || typeof value !== 'string') {
|
@@ -79,6 +83,10 @@ export const timeUnits = {
|
|
79
83
|
export const dateTimeUnits = Object.assign({}, dateUnits, timeUnits);
|
80
84
|
export const relativeTimeValueType = registerValueType('RelativeTime', obj => RelativeTimeValue.from(obj));
|
81
85
|
export class RelativeTimeValue extends AbstractConditionValue {
|
86
|
+
timePeriod;
|
87
|
+
timeUnit;
|
88
|
+
direction;
|
89
|
+
timeOnly;
|
82
90
|
constructor(timePeriod, timeUnit, direction, timeOnly = false) {
|
83
91
|
super(relativeTimeValueType);
|
84
92
|
if (typeof timePeriod !== 'string') {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"inline-condition-values.js","names":["conditionValueFactories","Registration","
|
1
|
+
{"version":3,"file":"inline-condition-values.js","names":["conditionValueFactories","Registration","type","constructor","factory","AbstractConditionValue","registration","new","target","TypeError","toPresentationString","toExpression","valueType","registerValueType","obj","ConditionValue","from","value","display","Error","clone","dateDirections","FUTURE","PAST","dateUnits","YEARS","MONTHS","DAYS","timeUnits","HOURS","MINUTES","SECONDS","dateTimeUnits","Object","assign","relativeTimeValueType","RelativeTimeValue","timePeriod","timeUnit","direction","timeOnly","values","map","it","includes","Number","valueFrom"],"sources":["../../../src/conditions/inline-condition-values.ts"],"sourcesContent":["const conditionValueFactories = {}\n\nclass Registration {\n type\n\n constructor(type, factory) {\n conditionValueFactories[type] = factory\n this.type = type\n }\n}\n\nexport class AbstractConditionValue {\n type\n\n constructor(registration) {\n if (new.target === AbstractConditionValue) {\n throw new TypeError('Cannot construct ConditionValue instances directly')\n }\n if (!(registration instanceof Registration)) {\n throw new TypeError(\n 'You must register your value type! Call registerValueType!'\n )\n }\n this.type = registration.type\n }\n\n toPresentationString() {}\n toExpression() {}\n}\n\nconst valueType = registerValueType('Value', (obj) => ConditionValue.from(obj))\nexport class ConditionValue extends AbstractConditionValue {\n value\n display\n\n constructor(value, display) {\n super(valueType)\n if (!value || typeof value !== 'string') {\n throw Error(`value ${value} is not valid`)\n }\n if (display && typeof display !== 'string') {\n throw Error(`display ${display} is not valid`)\n }\n this.value = value\n this.display = display || value\n }\n\n toPresentationString() {\n return this.display\n }\n\n toExpression() {\n return this.value\n }\n\n static from(obj) {\n return new ConditionValue(obj.value, obj.display)\n }\n\n clone() {\n return ConditionValue.from(this)\n }\n}\n\nexport const dateDirections = {\n FUTURE: 'in the future',\n PAST: 'in the past'\n}\n\nexport const dateUnits = {\n YEARS: { display: 'year(s)', value: 'years' },\n MONTHS: { display: 'month(s)', value: 'months' },\n DAYS: { display: 'day(s)', value: 'days' }\n}\nexport const timeUnits = {\n HOURS: { display: 'hour(s)', value: 'hours' },\n MINUTES: { display: 'minute(s)', value: 'minutes' },\n SECONDS: { display: 'second(s)', value: 'seconds' }\n}\nexport const dateTimeUnits = Object.assign({}, dateUnits, timeUnits)\n\nexport const relativeTimeValueType = registerValueType('RelativeTime', (obj) =>\n RelativeTimeValue.from(obj)\n)\nexport class RelativeTimeValue extends AbstractConditionValue {\n timePeriod\n timeUnit\n direction\n timeOnly\n\n constructor(timePeriod, timeUnit, direction, timeOnly = false) {\n super(relativeTimeValueType)\n if (typeof timePeriod !== 'string') {\n throw Error(`time period ${timePeriod} is not valid`)\n }\n if (\n !Object.values(dateTimeUnits)\n .map((it) => it.value)\n .includes(timeUnit)\n ) {\n throw Error(`time unit ${timeUnit} is not valid`)\n }\n if (!Object.values(dateDirections).includes(direction)) {\n throw Error(`direction ${direction} is not valid`)\n }\n this.timePeriod = timePeriod\n this.timeUnit = timeUnit\n this.direction = direction\n this.timeOnly = timeOnly\n }\n\n toPresentationString() {\n return `${this.timePeriod} ${this.timeUnit} ${this.direction}`\n }\n\n toExpression() {\n const timePeriod =\n this.direction === dateDirections.PAST\n ? 0 - Number(this.timePeriod)\n : this.timePeriod\n return this.timeOnly\n ? `timeForComparison(${timePeriod}, '${this.timeUnit}')`\n : `dateForComparison(${timePeriod}, '${this.timeUnit}')`\n }\n\n static from(obj) {\n return new RelativeTimeValue(\n obj.timePeriod,\n obj.timeUnit,\n obj.direction,\n obj.timeOnly\n )\n }\n\n clone() {\n return RelativeTimeValue.from(this)\n }\n}\n\n/**\n * All value types should call this, and should be located in this file.\n * Furthermore the types should be registered without the classes needing to be instantiated.\n *\n * Otherwise we can't guarantee they've been registered for deserialization before\n * valueFrom is called\n */\nfunction registerValueType(type, factory) {\n return new Registration(type, factory)\n}\n\nexport function valueFrom(obj) {\n return conditionValueFactories[obj.type](obj)\n}\n"],"mappings":"AAAA,MAAMA,uB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OAAOtB,IAAIA,CAACF,GAAG,EAAE;IACf,OAAO,IAAIsB,iBAAiB,CAC1BtB,GAAG,CAACuB,UAAU,EACdvB,GAAG,CAACwB,QAAQ,EACZxB,GAAG,CAACyB,SAAS,EACbzB,GAAG,CAAC0B,QACN,CAAC;EACH;EAEApB,KAAKA,CAAA,EAAG;IACN,OAAOgB,iBAAiB,CAACpB,IAAI,CAAC,IAAI,CAAC;EACrC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASH,iBAAiBA,CAACX,IAAI,EAAEE,OAAO,EAAE;EACxC,OAAO,IAAIH,YAAY,CAACC,IAAI,EAAEE,OAAO,CAAC;AACxC;AAEA,OAAO,SAAS0C,SAASA,CAAChC,GAAG,EAAE;EAC7B,OAAOd,uBAAuB,CAACc,GAAG,CAACZ,IAAI,CAAC,CAACY,GAAG,CAAC;AAC/C","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"conditions-wrapper.js","names":["ConditionsModel","ConditionsWrapper","
|
1
|
+
{"version":3,"file":"conditions-wrapper.js","names":["ConditionsModel","ConditionsWrapper","name","displayName","value","constructor","rawData","expression","from","toExpression","clone"],"sources":["../../../src/data-model/conditions-wrapper.ts"],"sourcesContent":["import { ConditionsModel } from '~/src/conditions/condition-model.js'\nimport {\n type ConditionRawData,\n type ConditionWrapperValue\n} from '~/src/form/types.js'\n\nexport class ConditionsWrapper {\n name: string\n displayName: string\n value: ConditionWrapperValue\n\n constructor(rawData: ConditionRawData) {\n const { name, displayName, value } = rawData\n this.displayName = displayName || name\n this.value = value\n this.name = name\n }\n\n get expression() {\n if (typeof this.value === 'string') {\n // Previously conditions were defined as strings, e.g: \"section.age < 18\"\n // keep this so application can support legacy forms exports.\n return this.value\n }\n\n return ConditionsModel.from(this.value).toExpression()\n }\n\n clone(): ConditionsWrapper {\n return new ConditionsWrapper(this)\n }\n}\n"],"mappings":"AAAA,SAASA,eAAe;AAMxB,OAAO,MAAMC,iBAAiB,CAAC;EAC7BC,IAAI;EACJC,WAAW;EACXC,KAAK;EAELC,WAAWA,CAACC,OAAyB,EAAE;IACrC,MAAM;MAAEJ,IAAI;MAAEC,WAAW;MAAEC;IAAM,CAAC,GAAGE,OAAO;IAC5C,IAAI,CAACH,WAAW,GAAGA,WAAW,IAAID,IAAI;IACtC,IAAI,CAACE,KAAK,GAAGA,KAAK;IAClB,IAAI,CAACF,IAAI,GAAGA,IAAI;EAClB;EAEA,IAAIK,UAAUA,CAAA,EAAG;IACf,IAAI,OAAO,IAAI,CAACH,KAAK,KAAK,QAAQ,EAAE;MAClC;MACA;MACA,OAAO,IAAI,CAACA,KAAK;IACnB;IAEA,OAAOJ,eAAe,CAACQ,IAAI,CAAC,IAAI,CAACJ,KAAK,CAAC,CAACK,YAAY,CAAC,CAAC;EACxD;EAEAC,KAAKA,CAAA,EAAsB;IACzB,OAAO,IAAIT,iBAAiB,CAAC,IAAI,CAAC;EACpC;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"input-wrapper.js","names":["clone","InputWrapper","name","undefined","title","type","parentItemName","
|
1
|
+
{"version":3,"file":"input-wrapper.js","names":["clone","InputWrapper","name","undefined","title","type","propertyPath","parentItemName","page","constructor","rawData","options","Object","assign","myPage","components","ignoreSection","section","displayName","titleWithContext"],"sources":["../../../src/data-model/input-wrapper.ts"],"sourcesContent":["import { type ComponentDef } from '~/src/components/types.js'\nimport { type Page } from '~/src/form/types.js'\nimport { clone } from '~/src/utils/helpers.js'\n\nexport class InputWrapper {\n name: string | undefined = undefined\n title: string | undefined = undefined\n type: string | undefined = undefined\n propertyPath: string | undefined\n #parentItemName: string | undefined\n page: Page\n\n constructor(\n rawData: ComponentDef,\n page: Page,\n options: { ignoreSection?: boolean; parentItemName?: string }\n ) {\n Object.assign(this, rawData)\n const myPage = clone(page)\n\n delete myPage.components\n\n this.page = myPage\n this.propertyPath =\n !options.ignoreSection && page.section\n ? `${page.section}.${this.name}`\n : this.name\n this.#parentItemName = options.parentItemName\n }\n\n get displayName(): string | undefined {\n const titleWithContext = this.#parentItemName\n ? `${this.title} under ${this.#parentItemName}`\n : this.title\n\n return this.page.section\n ? `${titleWithContext} in ${this.page.section}`\n : titleWithContext\n }\n}\n"],"mappings":"AAEA,SAASA,KAAK;AAEd,OAAO,MAAMC,YAAY,CAAC;EACxBC,IAAI,GAAuBC,SAAS;EACpCC,KAAK,GAAuBD,SAAS;EACrCE,IAAI,GAAuBF,SAAS;EACpCG,YAAY;EACZ,CAACC,cAAc;EACfC,IAAI;EAEJC,WAAWA,CACTC,OAAqB,EACrBF,IAAU,EACVG,OAA6D,EAC7D;IACAC,MAAM,CAACC,MAAM,CAAC,IAAI,EAAEH,OAAO,CAAC;IAC5B,MAAMI,MAAM,GAAGd,KAAK,CAACQ,IAAI,CAAC;IAE1B,OAAOM,MAAM,CAACC,UAAU;IAExB,IAAI,CAACP,IAAI,GAAGM,MAAM;IAClB,IAAI,CAACR,YAAY,GACf,CAACK,OAAO,CAACK,aAAa,IAAIR,IAAI,CAACS,OAAO,GACjC,GAAET,IAAI,CAACS,OAAQ,IAAG,IAAI,CAACf,IAAK,EAAC,GAC9B,IAAI,CAACA,IAAI;IACf,IAAI,CAAC,CAACK,cAAc,GAAGI,OAAO,CAACJ,cAAc;EAC/C;EAEA,IAAIW,WAAWA,CAAA,EAAuB;IACpC,MAAMC,gBAAgB,GAAG,IAAI,CAAC,CAACZ,cAAc,GACxC,GAAE,IAAI,CAACH,KAAM,UAAS,IAAI,CAAC,CAACG,cAAe,EAAC,GAC7C,IAAI,CAACH,KAAK;IAEd,OAAO,IAAI,CAACI,IAAI,CAACS,OAAO,GACnB,GAAEE,gBAAiB,OAAM,IAAI,CAACX,IAAI,CAACS,OAAQ,EAAC,GAC7CE,gBAAgB;EACtB;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","names":["FormConfiguration","
|
1
|
+
{"version":3,"file":"index.js","names":["FormConfiguration","Key","DisplayName","LastModified","feedbackForm","constructor","Error"],"sources":["../../../../src/form/form-configuration/index.ts"],"sourcesContent":["export class FormConfiguration {\n Key: string\n DisplayName: string\n LastModified: string | undefined\n feedbackForm: boolean | undefined\n\n constructor(\n Key: string,\n DisplayName?: string,\n LastModified?: string,\n feedbackForm?: boolean\n ) {\n if (!Key) {\n throw Error('Form configuration must have a key')\n }\n this.Key = Key\n this.DisplayName = DisplayName || Key\n this.LastModified = LastModified\n this.feedbackForm = feedbackForm || false\n }\n}\n"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,CAAC;EAC7BC,GAAG;EACHC,WAAW;EACXC,YAAY;EACZC,YAAY;EAEZC,WAAWA,CACTJ,GAAW,EACXC,WAAoB,EACpBC,YAAqB,EACrBC,YAAsB,EACtB;IACA,IAAI,CAACH,GAAG,EAAE;MACR,MAAMK,KAAK,CAAC,oCAAoC,CAAC;IACnD;IACA,IAAI,CAACL,GAAG,GAAGA,GAAG;IACd,IAAI,CAACC,WAAW,GAAGA,WAAW,IAAID,GAAG;IACrC,IAAI,CAACE,YAAY,GAAGA,YAAY;IAChC,IAAI,CAACC,YAAY,GAAGA,YAAY,IAAI,KAAK;EAC3C;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.js","names":["Logger","
|
1
|
+
{"version":3,"file":"logger.js","names":["Logger","server","name","constructor","error","message","log","warn","info","debug","level"],"sources":["../../../src/utils/logger.ts"],"sourcesContent":["export class Logger {\n server: any\n name: string\n\n constructor(server: any, name: string) {\n this.server = server\n this.name = name\n }\n\n error(message: string) {\n this.log('error', message)\n }\n\n warn(message: string) {\n this.log('warn', message)\n }\n\n info(message: string) {\n this.log('info', message)\n }\n\n debug(message: string) {\n this.log('debug', message)\n }\n\n log(level: string, message: string) {\n this.server.log([level, this.name], message)\n }\n}\n"],"mappings":"AAAA,OAAO,MAAMA,MAAM,CAAC;EAClBC,MAAM;EACNC,IAAI;EAEJC,WAAWA,CAACF,MAAW,EAAEC,IAAY,EAAE;IACrC,IAAI,CAACD,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACC,IAAI,GAAGA,IAAI;EAClB;EAEAE,KAAKA,CAACC,OAAe,EAAE;IACrB,IAAI,CAACC,GAAG,CAAC,OAAO,EAAED,OAAO,CAAC;EAC5B;EAEAE,IAAIA,CAACF,OAAe,EAAE;IACpB,IAAI,CAACC,GAAG,CAAC,MAAM,EAAED,OAAO,CAAC;EAC3B;EAEAG,IAAIA,CAACH,OAAe,EAAE;IACpB,IAAI,CAACC,GAAG,CAAC,MAAM,EAAED,OAAO,CAAC;EAC3B;EAEAI,KAAKA,CAACJ,OAAe,EAAE;IACrB,IAAI,CAACC,GAAG,CAAC,OAAO,EAAED,OAAO,CAAC;EAC5B;EAEAC,GAAGA,CAACI,KAAa,EAAEL,OAAe,EAAE;IAClC,IAAI,CAACJ,MAAM,CAACK,GAAG,CAAC,CAACI,KAAK,EAAE,IAAI,CAACR,IAAI,CAAC,EAAEG,OAAO,CAAC;EAC9C;AACF","ignoreList":[]}
|
package/package.json
CHANGED