@inseefr/lunatic 3.7.7 → 3.8.0-rc.ucq-options-variable.0
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/esm/type.source.d.ts +18 -3
- package/esm/use-lunatic/commons/compile-controls.js +2 -16
- package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
- package/esm/use-lunatic/commons/component.d.ts +33 -0
- package/esm/use-lunatic/commons/component.js +37 -0
- package/esm/use-lunatic/commons/component.js.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-components.js +10 -2
- package/esm/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/global-variables.d.ts +5 -0
- package/esm/use-lunatic/commons/variables/global-variables.js +7 -0
- package/esm/use-lunatic/commons/variables/global-variables.js.map +1 -0
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +21 -9
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +67 -49
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +137 -6
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/commons/variables/models.d.ts +1 -0
- package/esm/use-lunatic/commons/variables/models.js +2 -0
- package/esm/use-lunatic/commons/variables/models.js.map +1 -0
- package/esm/use-lunatic/commons/variables/pairwise-variables.d.ts +29 -0
- package/esm/use-lunatic/commons/variables/pairwise-variables.js +196 -0
- package/esm/use-lunatic/commons/variables/pairwise-variables.js.map +1 -0
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +1 -1
- package/esm/use-lunatic/props/propOptions.d.ts +9 -1
- package/esm/use-lunatic/props/propOptions.js +56 -1
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.spec.js +220 -56
- package/esm/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js +5 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/package.json +26 -1
- package/src/stories/checkbox/checkbox.stories.tsx +13 -0
- package/src/stories/checkbox/sourceOneDynamicOptions.json +496 -0
- package/src/stories/dropdown/dropdown.stories.tsx +12 -0
- package/src/stories/dropdown/sourceDynamicOptions.json +496 -0
- package/src/stories/pairwise/pairwise.stories.tsx +7 -0
- package/src/stories/pairwise/sourceGlobalVariables.json +337 -0
- package/src/stories/radio/radio.stories.tsx +13 -0
- package/src/stories/radio/sourceDynamicOptions.json +496 -0
- package/src/type.source.ts +18 -3
- package/src/use-lunatic/commons/compile-controls.ts +10 -42
- package/src/use-lunatic/commons/component.ts +79 -0
- package/src/use-lunatic/commons/fill-components/fill-component-expressions.ts +2 -1
- package/src/use-lunatic/commons/fill-components/fill-components.ts +9 -10
- package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +2 -4
- package/src/use-lunatic/commons/variables/global-variables.ts +9 -0
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +149 -6
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +113 -50
- package/src/use-lunatic/commons/variables/models.ts +1 -0
- package/src/use-lunatic/commons/variables/pairwise-variables.ts +251 -0
- package/src/use-lunatic/props/propOptions.spec.ts +217 -147
- package/src/use-lunatic/props/propOptions.ts +97 -8
- package/src/use-lunatic/reducer/reducerInitializer.tsx +5 -7
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +18 -3
- package/use-lunatic/commons/compile-controls.js +4 -18
- package/use-lunatic/commons/compile-controls.js.map +1 -1
- package/use-lunatic/commons/component.d.ts +33 -0
- package/use-lunatic/commons/component.js +42 -0
- package/use-lunatic/commons/component.js.map +1 -1
- package/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +1 -1
- package/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/use-lunatic/commons/fill-components/fill-components.js +9 -1
- package/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/global-variables.d.ts +5 -0
- package/use-lunatic/commons/variables/global-variables.js +11 -0
- package/use-lunatic/commons/variables/global-variables.js.map +1 -0
- package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +21 -9
- package/use-lunatic/commons/variables/lunatic-variables-store.js +72 -50
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +137 -6
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/commons/variables/models.d.ts +1 -0
- package/use-lunatic/commons/variables/models.js +3 -0
- package/use-lunatic/commons/variables/models.js.map +1 -0
- package/use-lunatic/commons/variables/pairwise-variables.d.ts +29 -0
- package/use-lunatic/commons/variables/pairwise-variables.js +199 -0
- package/use-lunatic/commons/variables/pairwise-variables.js.map +1 -0
- package/use-lunatic/props/getComponentTypeProps.d.ts +1 -1
- package/use-lunatic/props/propOptions.d.ts +9 -1
- package/use-lunatic/props/propOptions.js +57 -2
- package/use-lunatic/props/propOptions.js.map +1 -1
- package/use-lunatic/props/propOptions.spec.js +217 -55
- package/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/use-lunatic/reducer/reducerInitializer.js +5 -1
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
package/esm/type.source.d.ts
CHANGED
|
@@ -124,7 +124,9 @@ export type ComponentCheckboxBooleanDefinition = ComponentDefinitionBaseWithResp
|
|
|
124
124
|
export type ComponentRadioDefinition = ComponentDefinitionBaseWithResponse & {
|
|
125
125
|
componentType: 'Radio';
|
|
126
126
|
orientation?: 'horizontal' | 'vertical';
|
|
127
|
-
options
|
|
127
|
+
options?: OptionsWithDetail;
|
|
128
|
+
optionSource?: string;
|
|
129
|
+
optionFilter?: VTLExpression;
|
|
128
130
|
};
|
|
129
131
|
export type OptionsWithDetail = {
|
|
130
132
|
value: string | boolean;
|
|
@@ -140,7 +142,9 @@ export type OptionsWithDetail = {
|
|
|
140
142
|
}[];
|
|
141
143
|
export type ComponentDropdownDefinition = ComponentDefinitionBaseWithResponse & {
|
|
142
144
|
componentType: 'Dropdown';
|
|
143
|
-
options
|
|
145
|
+
options?: Options;
|
|
146
|
+
optionSource?: string;
|
|
147
|
+
optionFilter?: VTLExpression;
|
|
144
148
|
};
|
|
145
149
|
export type ComponentQuestionDefinition = ComponentDefinitionBase & {
|
|
146
150
|
componentType: 'Question';
|
|
@@ -148,7 +152,9 @@ export type ComponentQuestionDefinition = ComponentDefinitionBase & {
|
|
|
148
152
|
};
|
|
149
153
|
export type ComponentCheckboxOneDefinition = ComponentDefinitionBaseWithResponse & {
|
|
150
154
|
componentType: 'CheckboxOne';
|
|
151
|
-
options
|
|
155
|
+
options?: OptionsWithDetail;
|
|
156
|
+
optionSource?: string;
|
|
157
|
+
optionFilter?: VTLExpression;
|
|
152
158
|
};
|
|
153
159
|
export type ComponentSuggesterDefinition = ComponentDefinitionBaseWithResponse & {
|
|
154
160
|
componentType: 'Suggester';
|
|
@@ -185,6 +191,15 @@ export type ComponentPairWiseLinksDefinition = ComponentDefinitionBase & {
|
|
|
185
191
|
[k: string]: string | null;
|
|
186
192
|
};
|
|
187
193
|
};
|
|
194
|
+
sourceVariables?: {
|
|
195
|
+
/** Name of the variable containing the name of the respondent */
|
|
196
|
+
name?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Name of the variable containing the gender of the respondent
|
|
199
|
+
* (value of variable -> 1:male, 2: female)
|
|
200
|
+
*/
|
|
201
|
+
gender?: string;
|
|
202
|
+
};
|
|
188
203
|
components: ComponentDefinition[];
|
|
189
204
|
};
|
|
190
205
|
export type ComponentSummaryDefinition = ComponentDefinitionBase & {
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import { fillComponentExpressions
|
|
1
|
+
import { fillComponentExpressions } from './fill-components/fill-component-expressions';
|
|
2
2
|
import { checkRoundaboutControl } from '../reducer/controls/check-roundabout-control';
|
|
3
3
|
import { checkBaseControl } from '../reducer/controls/check-base-control';
|
|
4
4
|
import { getComponentsFromState } from './get-components-from-state';
|
|
5
|
-
|
|
6
|
-
* Check if the component is a Loop or a RosterForLoop
|
|
7
|
-
*/
|
|
8
|
-
const isLoopComponent = (component) => {
|
|
9
|
-
return ['Loop', 'RosterForLoop'].includes(component.componentType);
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Check if the component is a Roundabout
|
|
13
|
-
*/
|
|
14
|
-
const isRoundaboutComponent = (component) => {
|
|
15
|
-
return component.componentType === 'Roundabout';
|
|
16
|
-
};
|
|
17
|
-
const isQuestionComponent = (component) => {
|
|
18
|
-
return 'Question' === component.componentType;
|
|
19
|
-
};
|
|
5
|
+
import { isLoopComponent, isQuestionComponent, isRoundaboutComponent, } from './component';
|
|
20
6
|
/**
|
|
21
7
|
* Check if components of the current page have errors, and return a map of
|
|
22
8
|
* errors (indexed by component ID).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-controls.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/compile-controls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-controls.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/compile-controls.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAGN,eAAe,EACf,mBAAmB,EACnB,qBAAqB,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IACJ,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,OAAO;QACN,aAAa;QACb,UAAU,EAAE,gBAAgB,CAAC,aAAa,CAAC;KAC3C,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LunaticComponentDefinition } from '../type';
|
|
3
|
+
import { type DeepTranslateExpression } from './fill-components/fill-component-expressions';
|
|
4
|
+
export type ComponentDefinition = LunaticComponentDefinition;
|
|
5
|
+
export type InterpretedComponent = DeepTranslateExpression<LunaticComponentDefinition>;
|
|
6
|
+
export type InterpretedLoopComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
7
|
+
componentType: 'Loop' | 'RosterForLoop';
|
|
8
|
+
}>;
|
|
9
|
+
export type InterpretedRoundaboutComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
10
|
+
componentType: 'Roundabout';
|
|
11
|
+
}>;
|
|
12
|
+
export type InterpretedQuestionComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
13
|
+
componentType: 'Question';
|
|
14
|
+
}>;
|
|
15
|
+
export type InterpretedPairwiseLinksComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
16
|
+
componentType: 'PairwiseLinks';
|
|
17
|
+
}>;
|
|
18
|
+
/** Whether the component has a response attribute. */
|
|
3
19
|
export declare function hasResponse(component: unknown): component is {
|
|
4
20
|
response: {
|
|
5
21
|
name: string;
|
|
6
22
|
};
|
|
7
23
|
};
|
|
24
|
+
/** Whether the component has a responses attribute. */
|
|
8
25
|
export declare function hasResponses(component: unknown): component is {
|
|
9
26
|
responses?: Array<{
|
|
10
27
|
label: ReactNode;
|
|
@@ -14,9 +31,25 @@ export declare function hasResponses(component: unknown): component is {
|
|
|
14
31
|
};
|
|
15
32
|
}>;
|
|
16
33
|
};
|
|
34
|
+
/** Whether the component has a body attribute. */
|
|
17
35
|
export declare function hasBody(component: unknown): component is {
|
|
18
36
|
body: LunaticComponentDefinition<'Table'>['body'];
|
|
19
37
|
};
|
|
38
|
+
/** Whether the component has a componentType attribute. */
|
|
20
39
|
export declare function hasComponentType(component: unknown): component is {
|
|
21
40
|
componentType: string;
|
|
22
41
|
};
|
|
42
|
+
/** Whether the component is a Loop or a RosterForLoop. */
|
|
43
|
+
export declare function isLoopComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedLoopComponent;
|
|
44
|
+
/** Whether the component is a Roundabout. */
|
|
45
|
+
export declare function isRoundaboutComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedRoundaboutComponent;
|
|
46
|
+
/** Whether the component is a Question. */
|
|
47
|
+
export declare function isQuestionComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedQuestionComponent;
|
|
48
|
+
/** Whether the component is a PairwiseLinks. */
|
|
49
|
+
export declare function isPairwiseLinksComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedPairwiseLinksComponent;
|
|
50
|
+
/**
|
|
51
|
+
* Get the pairwise component if it exists.
|
|
52
|
+
*
|
|
53
|
+
* There should only be one so we return the first one we find.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getPairwiseComponent(components: ComponentDefinition[]): InterpretedPairwiseLinksComponent | undefined;
|
|
@@ -1,22 +1,59 @@
|
|
|
1
|
+
/** Whether the component has a response attribute. */
|
|
1
2
|
export function hasResponse(component) {
|
|
2
3
|
return (!!component &&
|
|
3
4
|
typeof component === 'object' &&
|
|
4
5
|
'response' in component &&
|
|
5
6
|
'name' in component.response);
|
|
6
7
|
}
|
|
8
|
+
/** Whether the component has a responses attribute. */
|
|
7
9
|
export function hasResponses(component) {
|
|
8
10
|
return (!!component && typeof component === 'object' && 'responses' in component);
|
|
9
11
|
}
|
|
12
|
+
/** Whether the component has a body attribute. */
|
|
10
13
|
export function hasBody(component) {
|
|
11
14
|
return (!!component &&
|
|
12
15
|
typeof component === 'object' &&
|
|
13
16
|
'body' in component &&
|
|
14
17
|
Array.isArray(component.body));
|
|
15
18
|
}
|
|
19
|
+
/** Whether the component has a componentType attribute. */
|
|
16
20
|
export function hasComponentType(component) {
|
|
17
21
|
return (!!component &&
|
|
18
22
|
typeof component === 'object' &&
|
|
19
23
|
'componentType' in component &&
|
|
20
24
|
typeof component.componentType === 'string');
|
|
21
25
|
}
|
|
26
|
+
/** Whether the component is a Loop or a RosterForLoop. */
|
|
27
|
+
export function isLoopComponent(component) {
|
|
28
|
+
return ['Loop', 'RosterForLoop'].includes(component.componentType);
|
|
29
|
+
}
|
|
30
|
+
/** Whether the component is a Roundabout. */
|
|
31
|
+
export function isRoundaboutComponent(component) {
|
|
32
|
+
return component.componentType === 'Roundabout';
|
|
33
|
+
}
|
|
34
|
+
/** Whether the component is a Question. */
|
|
35
|
+
export function isQuestionComponent(component) {
|
|
36
|
+
return component.componentType === 'Question';
|
|
37
|
+
}
|
|
38
|
+
/** Whether the component is a PairwiseLinks. */
|
|
39
|
+
export function isPairwiseLinksComponent(component) {
|
|
40
|
+
return component.componentType === 'PairwiseLinks';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the pairwise component if it exists.
|
|
44
|
+
*
|
|
45
|
+
* There should only be one so we return the first one we find.
|
|
46
|
+
*/
|
|
47
|
+
export function getPairwiseComponent(components) {
|
|
48
|
+
for (const component of components) {
|
|
49
|
+
if (isPairwiseLinksComponent(component))
|
|
50
|
+
return component;
|
|
51
|
+
if (isQuestionComponent(component)) {
|
|
52
|
+
const childComponent = getPairwiseComponent(component.components);
|
|
53
|
+
if (childComponent)
|
|
54
|
+
return childComponent;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
22
59
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/component.ts"],"names":[],"mappings":"AA+BA,sDAAsD;AACtD,MAAM,UAAU,WAAW,CAC1B,SAAkB;IAElB,OAAO,CACN,CAAC,CAAC,SAAS;QACX,OAAO,SAAS,KAAK,QAAQ;QAC7B,UAAU,IAAI,SAAS;QACvB,MAAM,IAAK,SAAS,CAAC,QAAmB,CACxC,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,SAAkB;IAO9C,OAAO,CACN,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,IAAI,SAAS,CACxE,CAAC;AACH,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,OAAO,CAAC,SAAkB;IAGzC,OAAO,CACN,CAAC,CAAC,SAAS;QACX,OAAO,SAAS,KAAK,QAAQ;QAC7B,MAAM,IAAI,SAAS;QACnB,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAC7B,CAAC;AACH,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAC/B,SAAkB;IAElB,OAAO,CACN,CAAC,CAAC,SAAS;QACX,OAAO,SAAS,KAAK,QAAQ;QAC7B,eAAe,IAAI,SAAS;QAC5B,OAAO,SAAS,CAAC,aAAa,KAAK,QAAQ,CAC3C,CAAC;AACH,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,eAAe,CAC9B,SAAqD;IAErD,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AACpE,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,qBAAqB,CACpC,SAAqD;IAErD,OAAO,SAAS,CAAC,aAAa,KAAK,YAAY,CAAC;AACjD,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,mBAAmB,CAClC,SAAqD;IAErD,OAAO,SAAS,CAAC,aAAa,KAAK,UAAU,CAAC;AAC/C,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,wBAAwB,CACvC,SAAqD;IAErD,OAAO,SAAS,CAAC,aAAa,KAAK,eAAe,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CACnC,UAAiC;IAEjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,wBAAwB,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;QAC1D,IAAI,mBAAmB,CAAC,SAAS,CAAC,EAAE,CAAC;YACpC,MAAM,cAAc,GAAG,oBAAoB,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAClE,IAAI,cAAc;gBAAE,OAAO,cAAc,CAAC;QAC3C,CAAC;IACF,CAAC;IAED,OAAO,SAAS,CAAC;AAClB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LunaticComponentDefinition, LunaticExpression, LunaticReducerState } from '../../type';
|
|
3
|
-
type UntranslatedProperties = 'expressions' | 'sections' | 'body' | 'item' | 'controls' | 'conditionFilter' | 'conditionReadOnly' | 'components';
|
|
3
|
+
type UntranslatedProperties = 'expressions' | 'sections' | 'body' | 'item' | 'controls' | 'conditionFilter' | 'conditionReadOnly' | 'components' | 'optionFilter';
|
|
4
4
|
export type DeepTranslateExpression<T> = T extends LunaticExpression ? ReactNode : T extends (infer ElementType)[] ? DeepTranslateExpression<ElementType>[] : T extends {
|
|
5
5
|
[k: string | number]: unknown;
|
|
6
6
|
} ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill-component-expressions.js","sourceRoot":"","sources":["../../../../src/use-lunatic/commons/fill-components/fill-component-expressions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,Q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AAE,CAAC;QACR,OAAO,EAAE,CAAC;IACX,CAAC;IACD,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;AACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"fill-component-expressions.js","sourceRoot":"","sources":["../../../../src/use-lunatic/commons/fill-components/fill-component-expressions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,MAAM,cAAc,GAAG;IACtB,CAAC,OAAO,EAAE,IAAI,CAAC;IACf,CAAC,MAAM,EAAE,IAAI,CAAC;IACd,CAAC,eAAe,EAAE,IAAI,CAAC;IACvB,CAAC,oBAAoB,EAAE,IAAI,CAAC;IAC5B,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,YAAY,EAAE,UAAU,CAAC;IAC1B,CAAC,iBAAiB,EAAE,IAAI,CAAC;IACzB,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAC/B,CAAC,wBAAwB,EAAE,IAAI,CAAC;IAChC,CAAC,qBAAqB,EAAE,IAAI,CAAC;IAC7B,CAAC,sBAAsB,EAAE,IAAI,CAAC;IAC9B,CAAC,qBAAqB,EAAE,UAAU,CAAC;IACnC,CAAC,aAAa,EAAE,IAAI,CAAC;IACrB,CAAC,YAAY,EAAE,IAAI,CAAC;IACpB,CAAC,WAAW,EAAE,UAAU,CAAC;IACzB,CAAC,WAAW,EAAE,UAAU,CAAC;IACzB,CAAC,iBAAiB,EAAE,UAAU,CAAC;IAC/B,CAAC,iBAAiB,EAAE,UAAU,CAAC;IAC/B,CAAC,iBAAiB,EAAE,QAAQ,CAAC;IAC7B,CAAC,cAAc,EAAE,IAAI,CAAC;IACtB,CAAC,UAAU,EAAE,QAAQ,CAAC;IACtB,CAAC,mBAAmB,EAAE,QAAQ,CAAC;IAC/B,iBAAiB;IACjB,CAAC,iBAAiB,EAAE,UAAU,CAAC;IAC/B,CAAC,sBAAsB,EAAE,UAAU,CAAC;CAC3B,CAAC;AAEX,oEA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,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC;KACrE,CAAC;AACH,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { getComponentTypeProps } from '../../props/getComponentTypeProps';
|
|
|
3
3
|
import { getMissingResponseProp } from '../../props/propMissingResponse';
|
|
4
4
|
import { getValueProp } from '../../props/propValue';
|
|
5
5
|
import { getIterationsProp } from '../../props/propIterations';
|
|
6
|
-
import {
|
|
6
|
+
import { computeOptionsFromComponent } from '../../props/propOptions';
|
|
7
7
|
/**
|
|
8
8
|
* To make this work with TypeScript we need to call function in succession, we prefer expressiveness here over generalized approach
|
|
9
9
|
*/
|
|
@@ -43,7 +43,15 @@ parentReadOnly) => {
|
|
|
43
43
|
missingResponse: getMissingResponseProp(component, state),
|
|
44
44
|
management: state.management,
|
|
45
45
|
iterations: getIterationsProp(component, state),
|
|
46
|
-
options:
|
|
46
|
+
options: computeOptionsFromComponent(interpretedProps, {
|
|
47
|
+
variables: state.variables,
|
|
48
|
+
handleChanges: state.handleChanges,
|
|
49
|
+
pagerIteration: state.pager.iteration,
|
|
50
|
+
value,
|
|
51
|
+
logger: state.logger,
|
|
52
|
+
disableFilters: state.disableFilters,
|
|
53
|
+
shouldParentBeFiltered: shouldBeFiltered,
|
|
54
|
+
}),
|
|
47
55
|
...getComponentTypeProps(interpretedProps, state),
|
|
48
56
|
// This is too dynamic to be typed correctly, so we allow any here
|
|
49
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill-components.js","sourceRoot":"","sources":["../../../../src/use-lunatic/commons/fill-components/fill-components.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fill-components.js","sourceRoot":"","sources":["../../../../src/use-lunatic/commons/fill-components/fill-components.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAoBtE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC5B,SAAqC,EACrC,KAAwB;AACxB,4GAA4G;AAC5G,qBAA2B;AAC3B,qGAAqG;AACrG,cAAoB,EACoC,EAAE;IAC1D,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAEpE,MAAM,sBAAsB,GAAG,qBAAqB,KAAK,KAAK,CAAC;IAE/D,MAAM,gBAAgB,GAAG,cAAc,KAAK,IAAI,CAAC;IAEjD,gEAAgE;IAChE,MAAM,QAAQ,GACb,gBAAgB;QAChB,CAAC,mBAAmB,IAAI,gBAAgB;YACvC,CAAC,CAAC,gBAAgB,CAAC,iBAAiB;YACpC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEX,gEAAgE;IAChE,MAAM,gBAAgB,GACrB,sBAAsB;QACtB,CAAC,iBAAiB,IAAI,gBAAgB;YACrC,CAAC,CAAC,CAAC,gBAAgB,CAAC,eAAe;YACnC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEX,MAAM,KAAK,GAAG,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC7C,OAAO;QACN,GAAG,gBAAgB;Q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,IACC,SAAS,CAAC,aAAa,KAAK,mBAAmB;YAC/C,KAAK,CAAC,yBAAyB,EAC9B,CAAC;YACF,OAAO,EAAE,CAAC;QACX,CAAC;QAED,OAAO;YACN,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,qBAAqB,EAAE,cAAc,CAAC;SACtE,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO,gBAAgB,CAAC;IACzB,CAAC;IAED,sEAAsE;IACtE,IAAI,UAAU,KAAK,eAAe,EAAE,CAAC;QACpC,OAAO,gBAAgB,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE;;YAC/C,OAAA,CAAC,MAAA,eAAe,CAAC,eAAe,mCAAI,IAAI,CAAC;gBACxC,CAAC,CAAC,eAAe;gBACjB,CAAC,CAAC,mDAAmD;oBACnD;wBACA,GAAG,eAAe;wBAClB,KAAK,EAAE,EAAE;wBACT,aAAa,EAAE,MAAM;qBACK,CAAA;SAAA,CAC7B,CAAC;IACH,CAAC;IAED,+EAA+E;IAC/E,OAAO,gBAAgB,CAAC,MAAM,CAC7B,CAAC,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,eAAe,aAAf,eAAe,cAAf,eAAe,GAAI,IAAI,CAChD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cleaning-behaviour.js","sourceRoot":"","sources":["../../../../../src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleaning-behaviour.js","sourceRoot":"","sources":["../../../../../src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBA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 -0,0 +1,5 @@
|
|
|
1
|
+
import { IterationLevel } from './models';
|
|
2
|
+
/** Special variable that will take the current iteration value. */
|
|
3
|
+
export declare const GLOBAL_ITERATION_INDEX = "GLOBAL_ITERATION_INDEX";
|
|
4
|
+
/** Manually compute the global iteration index from current iteration level. */
|
|
5
|
+
export declare function computeGlobalIterationIndexValue(iteration: IterationLevel): (string | number)[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Special variable that will take the current iteration value. */
|
|
2
|
+
export const GLOBAL_ITERATION_INDEX = 'GLOBAL_ITERATION_INDEX';
|
|
3
|
+
/** Manually compute the global iteration index from current iteration level. */
|
|
4
|
+
export function computeGlobalIterationIndexValue(iteration) {
|
|
5
|
+
return [GLOBAL_ITERATION_INDEX, iteration[0] + 1];
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=global-variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-variables.js","sourceRoot":"","sources":["../../../../src/use-lunatic/commons/variables/global-variables.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,gFAAgF;AAChF,MAAM,UAAU,gCAAgC,CAAC,SAAyB;IACzE,OAAO,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LunaticData, LunaticOptions, LunaticSource } from '../../type';
|
|
2
2
|
import type { RefObject } from 'react';
|
|
3
|
-
|
|
3
|
+
import { IterationLevel } from './models';
|
|
4
4
|
export type EventArgs = {
|
|
5
5
|
change: {
|
|
6
6
|
/** Name of the changed variable. */
|
|
@@ -35,7 +35,11 @@ export declare class LunaticVariablesStore {
|
|
|
35
35
|
autoCommit: boolean;
|
|
36
36
|
updatedAt: Timekey;
|
|
37
37
|
constructor();
|
|
38
|
-
static makeFromSource(source: LunaticSource, data: LunaticData,
|
|
38
|
+
static makeFromSource(source: LunaticSource, data: LunaticData, options?: {
|
|
39
|
+
changeHandler?: RefObject<LunaticOptions['onVariableChange']>;
|
|
40
|
+
disableCleaning?: boolean;
|
|
41
|
+
autoCommit?: boolean;
|
|
42
|
+
}): LunaticVariablesStore;
|
|
39
43
|
/**
|
|
40
44
|
* Create a new store from an object (useful for testing)
|
|
41
45
|
*/
|
|
@@ -65,6 +69,14 @@ export declare class LunaticVariablesStore {
|
|
|
65
69
|
shapeFrom?: string | string[];
|
|
66
70
|
dimension?: number;
|
|
67
71
|
}): LunaticVariable;
|
|
72
|
+
/**
|
|
73
|
+
* Register global variable
|
|
74
|
+
*/
|
|
75
|
+
setGlobal(name: string, { dependencies, globalDependencies, shapeFrom, }: {
|
|
76
|
+
dependencies?: string[];
|
|
77
|
+
globalDependencies?: Map<unknown, string>;
|
|
78
|
+
shapeFrom?: string | string[];
|
|
79
|
+
}): LunaticVariable;
|
|
68
80
|
/**
|
|
69
81
|
* Run a VTL expression
|
|
70
82
|
*/
|
|
@@ -84,7 +96,7 @@ export declare class LunaticVariablesStore {
|
|
|
84
96
|
get interpretCount(): number;
|
|
85
97
|
debug(): void;
|
|
86
98
|
}
|
|
87
|
-
declare class LunaticVariable {
|
|
99
|
+
export declare class LunaticVariable {
|
|
88
100
|
/** Last time the value was updated (changed). */
|
|
89
101
|
updatedAt: Map<string | undefined, number>;
|
|
90
102
|
/** Last time the store was updated (changed). */
|
|
@@ -95,8 +107,6 @@ declare class LunaticVariable {
|
|
|
95
107
|
private value;
|
|
96
108
|
/** List of direct dependencies, ex: ['FULLNAME', 'FIRSTNAME', 'LASTNAME']. */
|
|
97
109
|
private dependencies?;
|
|
98
|
-
/** List of deep dependencies, exploring the variables used in calculated variables, ex: ['FIRSTNAME', 'LASTNAME']. */
|
|
99
|
-
private baseDependencies?;
|
|
100
110
|
/** Expression for calculated variable. */
|
|
101
111
|
readonly expression?: string;
|
|
102
112
|
/** Dictionary holding all the available variables. */
|
|
@@ -105,6 +115,10 @@ declare class LunaticVariable {
|
|
|
105
115
|
private readonly iterationDepth?;
|
|
106
116
|
/** For calculated variable, shape is copied from another variable. */
|
|
107
117
|
private readonly shapeFrom?;
|
|
118
|
+
/** Whether this is a global variable with custom computation rules. */
|
|
119
|
+
private readonly isGlobal?;
|
|
120
|
+
/** Name of variables needed for global variables computation rules. */
|
|
121
|
+
private readonly globalDependencies?;
|
|
108
122
|
/** Keep a record of variable name (optional, used for debug). */
|
|
109
123
|
readonly name?: string;
|
|
110
124
|
/** Count the number of calculation. */
|
|
@@ -120,6 +134,8 @@ declare class LunaticVariable {
|
|
|
120
134
|
name?: string;
|
|
121
135
|
dimension?: number;
|
|
122
136
|
storeUpdatedAt: Timekey;
|
|
137
|
+
isGlobal?: boolean;
|
|
138
|
+
globalDependencies?: Map<unknown, string>;
|
|
123
139
|
});
|
|
124
140
|
getValue(iteration?: IterationLevel): unknown;
|
|
125
141
|
/**
|
|
@@ -132,10 +148,6 @@ declare class LunaticVariable {
|
|
|
132
148
|
private updateTimestamps;
|
|
133
149
|
private setValueForArray;
|
|
134
150
|
private getSavedValue;
|
|
135
|
-
/**
|
|
136
|
-
* Get a list of transitive dependencies (leaf of the dependency tree)
|
|
137
|
-
*/
|
|
138
|
-
private getBaseDependencies;
|
|
139
151
|
private getDependencies;
|
|
140
152
|
private getDependenciesValues;
|
|
141
153
|
/**
|
|
@@ -7,10 +7,10 @@ import { missingBehaviour } from './behaviours/missing-behaviour';
|
|
|
7
7
|
import { findLongest, setAtIndex, subArrays, times, } from '../../../utils/array';
|
|
8
8
|
import { isNumber } from '../../../utils/number';
|
|
9
9
|
import { VTLInterpretationError, VTLMissingDependencies, VTLMissingDependency, } from './errors';
|
|
10
|
+
import { computePairwiseGlobalVariables, computePairwiseGlobalVariableValue, } from './pairwise-variables';
|
|
11
|
+
import { computeGlobalIterationIndexValue, GLOBAL_ITERATION_INDEX, } from './global-variables';
|
|
10
12
|
/** Interpret counter. Used for testing purpose. */
|
|
11
13
|
let interpretCount = 0;
|
|
12
|
-
/** Special variable that will take the current iteration value. */
|
|
13
|
-
const iterationVariableName = 'GLOBAL_ITERATION_INDEX';
|
|
14
14
|
/**
|
|
15
15
|
* Represent a point in time (more precise than Date)
|
|
16
16
|
*/
|
|
@@ -34,12 +34,9 @@ export class LunaticVariablesStore {
|
|
|
34
34
|
this.updatedAt = new Timekey();
|
|
35
35
|
interpretCount = 0;
|
|
36
36
|
}
|
|
37
|
-
static makeFromSource(source, data,
|
|
38
|
-
// Disable cleaning
|
|
39
|
-
disableCleaning,
|
|
40
|
-
// Do not delay resizing / cleaning
|
|
41
|
-
autoCommit) {
|
|
37
|
+
static makeFromSource(source, data, options = {}) {
|
|
42
38
|
var _a, _b;
|
|
39
|
+
const { changeHandler, disableCleaning, autoCommit } = options;
|
|
43
40
|
const store = new LunaticVariablesStore();
|
|
44
41
|
if (typeof window !== 'undefined') {
|
|
45
42
|
window.lunaticStore = store; // Allow access to the store from the console
|
|
@@ -50,6 +47,12 @@ export class LunaticVariablesStore {
|
|
|
50
47
|
if (autoCommit) {
|
|
51
48
|
store.autoCommit = autoCommit;
|
|
52
49
|
}
|
|
50
|
+
// Setup pairwise global variables if there is a pairwise component
|
|
51
|
+
const pairwiseVariables = computePairwiseGlobalVariables(source);
|
|
52
|
+
for (const pairwiseVariable of pairwiseVariables) {
|
|
53
|
+
const { name, dependencies, globalDependencies, shapeFrom } = pairwiseVariable;
|
|
54
|
+
store.setGlobal(name, { dependencies, globalDependencies, shapeFrom });
|
|
55
|
+
}
|
|
53
56
|
// Source data (picked from "variables" in the source.json)s
|
|
54
57
|
const sourceValues = {};
|
|
55
58
|
// Starting data for the form (merged with data.json or injected data)
|
|
@@ -69,6 +72,9 @@ export class LunaticVariablesStore {
|
|
|
69
72
|
for (const variable of source.variables) {
|
|
70
73
|
switch (variable.variableType) {
|
|
71
74
|
case 'CALCULATED':
|
|
75
|
+
// In some cases, we have calculated variables in the source that are
|
|
76
|
+
// not used in the questionnaire (those variables are executed out of
|
|
77
|
+
// Lunatic.), so there is no need to add them to the dictionary.
|
|
72
78
|
if (variable.isIgnoredByLunatic)
|
|
73
79
|
break;
|
|
74
80
|
store.setCalculated(variable.name, variable.expression.value, {
|
|
@@ -184,6 +190,26 @@ export class LunaticVariablesStore {
|
|
|
184
190
|
this.updatedAt.touch();
|
|
185
191
|
return variable;
|
|
186
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Register global variable
|
|
195
|
+
*/
|
|
196
|
+
setGlobal(name, { dependencies, globalDependencies, shapeFrom, }) {
|
|
197
|
+
if (this.dictionary.has(name)) {
|
|
198
|
+
return this.dictionary.get(name);
|
|
199
|
+
}
|
|
200
|
+
const variable = new LunaticVariable({
|
|
201
|
+
dictionary: this.dictionary,
|
|
202
|
+
shapeFrom,
|
|
203
|
+
dependencies,
|
|
204
|
+
name,
|
|
205
|
+
storeUpdatedAt: this.updatedAt,
|
|
206
|
+
isGlobal: true,
|
|
207
|
+
globalDependencies,
|
|
208
|
+
});
|
|
209
|
+
this.dictionary.set(name, variable);
|
|
210
|
+
this.updatedAt.touch();
|
|
211
|
+
return variable;
|
|
212
|
+
}
|
|
187
213
|
/**
|
|
188
214
|
* Run a VTL expression
|
|
189
215
|
*/
|
|
@@ -223,7 +249,7 @@ export class LunaticVariablesStore {
|
|
|
223
249
|
Array.from(this.dictionary.values()).map((v) => (v.calculatedCount = 0));
|
|
224
250
|
}
|
|
225
251
|
}
|
|
226
|
-
class LunaticVariable {
|
|
252
|
+
export class LunaticVariable {
|
|
227
253
|
constructor(args) {
|
|
228
254
|
var _a;
|
|
229
255
|
/** Last time the value was updated (changed). */
|
|
@@ -233,7 +259,13 @@ class LunaticVariable {
|
|
|
233
259
|
/** Count the number of calculation. */
|
|
234
260
|
this.calculatedCount = 0;
|
|
235
261
|
if (args.expression && !args.dictionary) {
|
|
236
|
-
throw new Error(
|
|
262
|
+
throw new Error('A calculated variable needs a dictionary to retrieve his deps');
|
|
263
|
+
}
|
|
264
|
+
if (args.isGlobal && args.dependencies && !args.dictionary) {
|
|
265
|
+
throw new Error('A global variable with dependencies needs a dictionary to retrieve its deps');
|
|
266
|
+
}
|
|
267
|
+
if (args.isGlobal && !args.name) {
|
|
268
|
+
throw new Error('A global variable needs a name to fetch its logic');
|
|
237
269
|
}
|
|
238
270
|
this.expression = args.expression;
|
|
239
271
|
this.dictionary = args.dictionary;
|
|
@@ -244,10 +276,12 @@ class LunaticVariable {
|
|
|
244
276
|
this.name = (_a = args.name) !== null && _a !== void 0 ? _a : args.expression;
|
|
245
277
|
this.dimension = args.dimension;
|
|
246
278
|
this.storeUpdatedAt = args.storeUpdatedAt;
|
|
279
|
+
this.isGlobal = args.isGlobal || false;
|
|
280
|
+
this.globalDependencies = args.globalDependencies || undefined;
|
|
247
281
|
}
|
|
248
282
|
getValue(iteration) {
|
|
249
|
-
// The variable is not calculated
|
|
250
|
-
if (!this.expression) {
|
|
283
|
+
// The variable is not calculated or a global variable
|
|
284
|
+
if (!this.expression && !this.isGlobal) {
|
|
251
285
|
return this.getSavedValue(iteration);
|
|
252
286
|
}
|
|
253
287
|
const shapeFromValue = this.shapeFrom
|
|
@@ -295,16 +329,24 @@ class LunaticVariable {
|
|
|
295
329
|
shapeDimension < iteration.length) {
|
|
296
330
|
iteration = iteration.slice(0, shapeDimension);
|
|
297
331
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
332
|
+
if (this.isGlobal) {
|
|
333
|
+
// compute global variable thanks to specific rule
|
|
334
|
+
const value = computePairwiseGlobalVariableValue(this.name, iteration, this.globalDependencies, this.dictionary);
|
|
335
|
+
this.setValue(value, { iteration });
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
// compute thanks to VTL expression
|
|
339
|
+
// Uncomment this if you want to track the number of calculation
|
|
340
|
+
// this.calculatedCount++;
|
|
341
|
+
// Remember the value
|
|
342
|
+
try {
|
|
343
|
+
this.setValue(interpretVTL(this.expression, bindings), {
|
|
344
|
+
iteration: iteration,
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
catch (_a) {
|
|
348
|
+
throw new VTLInterpretationError(this.expression, bindings);
|
|
349
|
+
}
|
|
308
350
|
}
|
|
309
351
|
this.updateTimestamps(iteration, 'calculatedAt');
|
|
310
352
|
return this.getSavedValue(iteration);
|
|
@@ -372,32 +414,6 @@ class LunaticVariable {
|
|
|
372
414
|
}
|
|
373
415
|
return current;
|
|
374
416
|
}
|
|
375
|
-
/**
|
|
376
|
-
* Get a list of transitive dependencies (leaf of the dependency tree)
|
|
377
|
-
*/
|
|
378
|
-
getBaseDependencies() {
|
|
379
|
-
// Find the dependencies of the dependencies
|
|
380
|
-
const reducer = (acc, variableName) => {
|
|
381
|
-
var _a, _b;
|
|
382
|
-
if (acc.has(variableName)) {
|
|
383
|
-
return acc;
|
|
384
|
-
}
|
|
385
|
-
const deps = (_b = (_a = this.dictionary) === null || _a === void 0 ? void 0 : _a.get(variableName)) === null || _b === void 0 ? void 0 : _b.getDependencies();
|
|
386
|
-
if (!deps || deps.length === 0) {
|
|
387
|
-
acc.add(variableName);
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
deps === null || deps === void 0 ? void 0 : deps.reduce(reducer, acc);
|
|
391
|
-
}
|
|
392
|
-
return acc;
|
|
393
|
-
};
|
|
394
|
-
if (this.baseDependencies === undefined) {
|
|
395
|
-
this.baseDependencies = [
|
|
396
|
-
...this.getDependencies().reduce(reducer, new Set()),
|
|
397
|
-
];
|
|
398
|
-
}
|
|
399
|
-
return this.baseDependencies;
|
|
400
|
-
}
|
|
401
417
|
getDependencies() {
|
|
402
418
|
// Calculate dependencies from expression on the fly if necessary
|
|
403
419
|
if (this.dependencies === undefined) {
|
|
@@ -409,8 +425,10 @@ class LunaticVariable {
|
|
|
409
425
|
try {
|
|
410
426
|
return Object.fromEntries(this.getDependencies().map((dep) => {
|
|
411
427
|
var _a, _b;
|
|
412
|
-
|
|
413
|
-
|
|
428
|
+
// The variable is a global variable with no dependency that we can
|
|
429
|
+
// manually compute on the fly.
|
|
430
|
+
if (dep === GLOBAL_ITERATION_INDEX && iteration) {
|
|
431
|
+
return computeGlobalIterationIndexValue(iteration);
|
|
414
432
|
}
|
|
415
433
|
const dependencyIteration = isNumber(this.iterationDepth) && Array.isArray(iteration)
|
|
416
434
|
? [iteration[this.iterationDepth]]
|