@inseefr/lunatic 2.6.3-rc.1 → 2.6.4
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/README.md +49 -3
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +7 -1
- package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -1
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
- package/lib/components/checkbox/commons/checkbox-option.js +3 -1
- package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box.js +2 -2
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
- package/lib/components/commons/components/combo-box/selection/input.js +3 -1
- package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
- package/lib/components/commons/components/errors/errors.js +12 -10
- package/lib/components/commons/components/errors/errors.spec.js +6 -6
- package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
- package/lib/components/component-set/html/component-set.js +2 -2
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +2 -0
- package/lib/components/datepicker/html/datepicker-input.js +4 -2
- package/lib/components/datepicker/html/datepicker.js +3 -3
- package/lib/components/datepicker/lunatic-datepicker.js +2 -1
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/index.js +4 -4
- package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
- package/lib/components/input/html/input.js +3 -3
- package/lib/components/input/lunatic-input.js +2 -1
- package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
- package/lib/components/input-number/html/input-number-thousand.js +4 -17
- package/lib/components/input-number/html/input-number.js +3 -5
- package/lib/components/input-number/lunatic-input-number.js +2 -3
- package/lib/components/loop/block-for-loop.js +10 -6
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +35 -27
- package/lib/components/loop/utils/get-initial-nb-rows.js +17 -0
- package/lib/components/lunatic-components.js +7 -27
- package/lib/components/pairwise-links/index.js +13 -0
- package/lib/components/pairwise-links/orchestrator.js +71 -0
- package/lib/components/pairwise-links/pairwise-links.js +30 -27
- package/lib/components/pairwise-links/row.js +74 -0
- package/lib/components/radio/html/radio-group-content.js +4 -2
- package/lib/components/radio/html/radio-group.js +3 -3
- package/lib/components/radio/html/radio-option.js +3 -1
- package/lib/components/radio/lunatic-radio-group.js +2 -1
- package/lib/components/suggester/find-best-label/find-best-label.js +6 -6
- package/lib/components/suggester/idb-suggester/idb-suggester.js +4 -3
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +20 -39
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/cell.js +89 -0
- package/lib/components/table/{table-header.js → header.js} +5 -3
- package/lib/components/table/index.js +13 -0
- package/lib/components/table/lunatic-table.js +15 -24
- package/lib/components/table/row.js +40 -0
- package/lib/components/table/table-orchestrator.js +35 -0
- package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
- package/lib/components/textarea/html/textarea.js +6 -4
- package/lib/components/textarea/lunatic-textarea.js +6 -3
- package/lib/hooks/use-auto-focus.js +26 -0
- package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
- package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +4 -6
- package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
- package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +2 -1
- package/lib/src/components/datepicker/html/datepicker.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
- package/lib/src/components/index.d.ts +2 -2
- package/lib/src/components/input/html/input.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number.d.ts +2 -3
- package/lib/src/components/loop/block-for-loop.d.ts +4 -3
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -3
- package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +4 -0
- package/lib/src/components/lunatic-components.d.ts +3 -5
- package/lib/src/components/pairwise-links/index.d.ts +1 -0
- package/lib/src/components/pairwise-links/orchestrator.d.ts +6 -0
- package/lib/src/components/pairwise-links/pairwise-links.d.ts +2 -1
- package/lib/src/components/pairwise-links/row.d.ts +7 -0
- package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
- package/lib/src/components/radio/html/radio-group.d.ts +1 -1
- package/lib/src/components/radio/html/radio-option.d.ts +1 -0
- package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
- package/lib/src/components/switch/html/switch.d.ts +1 -1
- package/lib/src/components/table/cell.d.ts +19 -0
- package/lib/src/components/table/{table-header.d.ts → header.d.ts} +2 -2
- package/lib/src/components/table/index.d.ts +1 -0
- package/lib/src/components/table/lunatic-table.d.ts +1 -1
- package/lib/src/components/table/row.d.ts +18 -0
- package/lib/src/components/table/table-orchestrator.d.ts +4 -0
- package/lib/src/components/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +9 -7
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +19 -3
- package/lib/src/use-lunatic/commons/calculated-variables.d.ts +8 -0
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +2 -3
- package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +9 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-memoizer.d.ts +8 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +24 -0
- package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +11 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.d.ts +7 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +6 -0
- package/lib/src/use-lunatic/commons/execute-expression/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +418 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +3 -2
- package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +0 -6
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +142 -107
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +89 -53
- package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +0 -1
- package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +6 -0
- package/lib/src/use-lunatic/commons/get-component-value/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/get-data.d.ts +26 -0
- package/lib/src/use-lunatic/commons/index.d.ts +3 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +9 -10
- package/lib/src/use-lunatic/reducer/reduce-handle-change/index.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +15 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +14 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +9 -0
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +12 -1
- package/lib/src/use-lunatic/reducer/reduce-on-init.spec.d.ts +1 -0
- package/lib/src/use-lunatic/type-source.d.ts +21 -7
- package/lib/src/use-lunatic/type.d.ts +12 -13
- package/lib/src/use-lunatic/use-lunatic.d.ts +62 -36
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/array.d.ts +1 -6
- package/lib/src/utils/number.d.ts +0 -4
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +1 -1
- package/lib/src/utils/suggester-workers/searching/meloto-order.d.ts +2 -1
- package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
- package/lib/src/utils/vtl/dataset-builder.d.ts +5 -0
- package/lib/src/utils/vtl/index.d.ts +1 -0
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +84 -0
- package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
- package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
- package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +3 -3
- package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +3 -3
- package/lib/stories/suggester/suggester-workers.stories.js +36 -1
- package/lib/stories/suggester/suggester.stories.js +8 -4
- package/lib/use-lunatic/actions.js +3 -3
- package/lib/use-lunatic/commons/calculated-variables.js +104 -0
- package/lib/use-lunatic/commons/compile-controls.js +5 -3
- package/lib/use-lunatic/commons/execute-condition-filter.js +9 -1
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +233 -0
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +155 -0
- package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +63 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +149 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +130 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +90 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.spec.js +38 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +40 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.spec.js +31 -0
- package/lib/use-lunatic/commons/{fill-components/fill-iterations.js → execute-expression/get-safety-expression.js} +20 -30
- package/lib/use-lunatic/commons/execute-expression/index.js +13 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +3 -2
- package/lib/use-lunatic/{reducer/reduce-handle-change.js → commons/fill-components/fill-component-required.js} +8 -14
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +7 -21
- package/lib/use-lunatic/commons/fill-components/fill-components.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +13 -6
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +5 -58
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +0 -1
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +174 -0
- package/lib/use-lunatic/commons/get-component-value/index.js +13 -0
- package/lib/use-lunatic/commons/get-data.js +80 -0
- package/lib/use-lunatic/commons/index.js +21 -0
- package/lib/use-lunatic/initial-state.js +4 -6
- package/lib/use-lunatic/reducer/overview/overview-on-change.js +1 -1
- package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +792 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/index.js +13 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +78 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.js +46 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +115 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +89 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +88 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +119 -0
- package/lib/use-lunatic/{commons/variables/get-questionnaire-data.js → reducer/reduce-handle-change/reduce-variables-array.js} +32 -53
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +28 -0
- package/lib/use-lunatic/reducer/reduce-on-init.js +184 -90
- package/lib/use-lunatic/reducer/reduce-on-init.spec.js +17 -0
- package/lib/use-lunatic/reducer/reducer.js +2 -2
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +29 -22
- package/lib/use-lunatic/use-lunatic.test.js +36 -133
- package/lib/use-lunatic/use-suggesters.js +4 -3
- package/lib/utils/array.js +6 -57
- package/lib/utils/get-component-value.js +9 -3
- package/lib/utils/number.js +1 -13
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +4 -3
- package/lib/utils/suggester-workers/searching/meloto-order.js +6 -5
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/lib/utils/vtl/dataset-builder.js +27 -0
- package/lib/utils/vtl/index.js +13 -0
- package/package.json +15 -10
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +44 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/lib/hooks/use-track-changes.js +0 -50
- package/lib/src/hooks/use-track-changes.d.ts +0 -9
- package/lib/src/use-lunatic/commons/component.d.ts +0 -22
- package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +0 -112
- package/lib/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/missing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/get-questionnaire-data.d.ts +0 -4
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +0 -77
- package/lib/src/use-lunatic/reducer/reduce-handle-change.d.ts +0 -6
- package/lib/src/utils/env.d.ts +0 -1
- package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/src/utils/variables.d.ts +0 -5
- package/lib/src/utils/vtl.d.ts +0 -14
- package/lib/use-lunatic/commons/component.js +0 -22
- package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +0 -39
- package/lib/use-lunatic/commons/variables/behaviours/missing-behaviour.js +0 -47
- package/lib/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +0 -78
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +0 -330
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +0 -216
- package/lib/utils/array.spec.js +0 -30
- package/lib/utils/env.js +0 -10
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker.js +0 -55
- package/lib/utils/variables.js +0 -37
- package/lib/utils/vtl.js +0 -100
- /package/lib/src/use-lunatic/commons/{variables/lunatic-variables-store.spec.d.ts → execute-expression/create-refresh-calculated.spec.d.ts} +0 -0
- /package/lib/src/{utils/array.spec.d.ts → use-lunatic/commons/execute-expression/execute-expression.spec.d.ts} +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
- /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
- /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
|
@@ -43,6 +43,30 @@ function fetchFake() {
|
|
|
43
43
|
return r.json();
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
function fetchPCS2020() {
|
|
47
|
+
return fetch('/libelles-pcs-2020.json').then(function (r) {
|
|
48
|
+
return r.json();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
var infoPCS2020 = {
|
|
52
|
+
name: 'libelle-pcs2020',
|
|
53
|
+
fields: [{
|
|
54
|
+
name: 'id',
|
|
55
|
+
rules: ['[\\w]+'],
|
|
56
|
+
language: 'French',
|
|
57
|
+
min: 2
|
|
58
|
+
}],
|
|
59
|
+
queryParser: {
|
|
60
|
+
type: 'tokenized',
|
|
61
|
+
params: {
|
|
62
|
+
language: 'French',
|
|
63
|
+
pattern: '[\\w]+'
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
meloto: true,
|
|
67
|
+
version: '1',
|
|
68
|
+
stopWords: ['a', 'au', 'dans', 'de', 'des', 'du', 'en', 'er', 'la', 'le', 'ou', 'sur', 'd', 'l', 'aux', 'dans', 'un', 'une', 'pour', 'avec', 'chez', 'par', 'les']
|
|
69
|
+
};
|
|
46
70
|
var infoFake = {
|
|
47
71
|
name: 'fake',
|
|
48
72
|
fields: [{
|
|
@@ -78,7 +102,7 @@ var infoNaf = {
|
|
|
78
102
|
}
|
|
79
103
|
},
|
|
80
104
|
version: '1',
|
|
81
|
-
meloto:
|
|
105
|
+
meloto: true
|
|
82
106
|
};
|
|
83
107
|
function loadOne(_x, _x2) {
|
|
84
108
|
return _loadOne.apply(this, arguments);
|
|
@@ -187,6 +211,17 @@ var Template = function Template(args) {
|
|
|
187
211
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
188
212
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
189
213
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
214
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
215
|
+
type: "button",
|
|
216
|
+
value: "load PCS2020",
|
|
217
|
+
onClick: function onClick() {
|
|
218
|
+
return loadOne(infoPCS2020, fetchPCS2020);
|
|
219
|
+
}
|
|
220
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Search, {
|
|
221
|
+
storeInfo: infoPCS2020,
|
|
222
|
+
defaultValue: "st"
|
|
223
|
+
})]
|
|
224
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
190
225
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
191
226
|
type: "button",
|
|
192
227
|
value: "load NAF",
|
|
@@ -42,19 +42,23 @@ function _getReferentiel() {
|
|
|
42
42
|
while (1) switch (_context.prev = _context.next) {
|
|
43
43
|
case 0:
|
|
44
44
|
_context.t0 = name;
|
|
45
|
-
_context.next = _context.t0 === '
|
|
45
|
+
_context.next = _context.t0 === 'libelle-pcs2020' ? 3 : _context.t0 === 'naf-rev2' ? 4 : _context.t0 === 'cog-communes' ? 5 : 6;
|
|
46
46
|
break;
|
|
47
47
|
case 3:
|
|
48
|
-
return _context.abrupt("return", fetch('
|
|
48
|
+
return _context.abrupt("return", fetch('/libelles-pcs-2020.json').then(function (r) {
|
|
49
49
|
return r.json();
|
|
50
50
|
}));
|
|
51
51
|
case 4:
|
|
52
|
-
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/
|
|
52
|
+
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/naf-rev2.json').then(function (r) {
|
|
53
53
|
return r.json();
|
|
54
54
|
}));
|
|
55
55
|
case 5:
|
|
56
|
-
|
|
56
|
+
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/communes-2019.json').then(function (r) {
|
|
57
|
+
return r.json();
|
|
58
|
+
}));
|
|
57
59
|
case 6:
|
|
60
|
+
throw new Error("Unkonw r\xE9f\xE9rentiel ".concat(name));
|
|
61
|
+
case 7:
|
|
58
62
|
case "end":
|
|
59
63
|
return _context.stop();
|
|
60
64
|
}
|
|
@@ -36,13 +36,13 @@ var goToPage = actionCreator(ActionKind.GO_TO_PAGE);
|
|
|
36
36
|
exports.goToPage = goToPage;
|
|
37
37
|
var onInit = actionCreator(ActionKind.ON_INIT);
|
|
38
38
|
exports.onInit = onInit;
|
|
39
|
-
var handleChange = function handleChange(
|
|
39
|
+
var handleChange = function handleChange(response, value, args) {
|
|
40
40
|
return {
|
|
41
41
|
type: ActionKind.HANDLE_CHANGE,
|
|
42
42
|
payload: {
|
|
43
|
-
|
|
43
|
+
response: response,
|
|
44
44
|
value: value,
|
|
45
|
-
|
|
45
|
+
args: args
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.interpretAllCalculatedVariables = void 0;
|
|
8
|
+
var _executeExpression = require("./execute-expression/execute-expression");
|
|
9
|
+
var _vtl = _interopRequireDefault(require("../../utils/vtl"));
|
|
10
|
+
var _constants = require("../../constants");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
22
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
23
|
+
var interpretAllCalculatedVariables = function interpretAllCalculatedVariables(_ref) {
|
|
24
|
+
var variables = _ref.variables,
|
|
25
|
+
partialVariables = _ref.partialVariables,
|
|
26
|
+
builtVariables = _ref.builtVariables;
|
|
27
|
+
return Object.entries(partialVariables !== null && partialVariables !== void 0 ? partialVariables : variables).reduce(function (acc, _ref2) {
|
|
28
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
29
|
+
k = _ref3[0],
|
|
30
|
+
v = _ref3[1];
|
|
31
|
+
if (k in acc) return acc;
|
|
32
|
+
if (v.type === _constants.CALCULATED) {
|
|
33
|
+
var _v$variable = v.variable,
|
|
34
|
+
expression = _v$variable.expression.value,
|
|
35
|
+
shapeFrom = _v$variable.shapeFrom,
|
|
36
|
+
_v$variable$bindingDe = _v$variable.bindingDependencies,
|
|
37
|
+
bindingDependencies = _v$variable$bindingDe === void 0 ? [] : _v$variable$bindingDe;
|
|
38
|
+
var bindings = buildBindings({
|
|
39
|
+
builtVariables: acc,
|
|
40
|
+
bindingDependencies: bindingDependencies,
|
|
41
|
+
variables: variables
|
|
42
|
+
});
|
|
43
|
+
var shapeTarget = shapeFrom ? acc[shapeFrom] : null;
|
|
44
|
+
if (shapeFrom && Array.isArray(shapeTarget)) {
|
|
45
|
+
var result = shapeTarget.map(function (_, index) {
|
|
46
|
+
var scopedBindings = buildScopedBindings({
|
|
47
|
+
bindings: bindings,
|
|
48
|
+
index: index
|
|
49
|
+
});
|
|
50
|
+
return (0, _executeExpression.executeVtlExpression)(expression, scopedBindings);
|
|
51
|
+
});
|
|
52
|
+
return _objectSpread(_objectSpread(_objectSpread({}, acc), bindings), {}, _defineProperty({}, k, result));
|
|
53
|
+
}
|
|
54
|
+
var vectorialBindings = buildVectorialBindings({
|
|
55
|
+
bindings: bindings
|
|
56
|
+
});
|
|
57
|
+
return _objectSpread(_objectSpread(_objectSpread({}, acc), bindings), {}, _defineProperty({}, k, (0, _executeExpression.executeVtlExpression)(expression, vectorialBindings)));
|
|
58
|
+
}
|
|
59
|
+
return acc;
|
|
60
|
+
}, builtVariables);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Build a map of values for each variables
|
|
65
|
+
*/
|
|
66
|
+
exports.interpretAllCalculatedVariables = interpretAllCalculatedVariables;
|
|
67
|
+
var buildBindings = function buildBindings(_ref4) {
|
|
68
|
+
var builtVariables = _ref4.builtVariables,
|
|
69
|
+
bindingDependencies = _ref4.bindingDependencies,
|
|
70
|
+
variables = _ref4.variables;
|
|
71
|
+
return bindingDependencies.reduce(function (acc, b) {
|
|
72
|
+
if (builtVariables[b] === undefined) {
|
|
73
|
+
var unresolvedVariable = _defineProperty({}, b, variables[b]);
|
|
74
|
+
var result = interpretAllCalculatedVariables({
|
|
75
|
+
partialVariables: unresolvedVariable,
|
|
76
|
+
variables: variables,
|
|
77
|
+
builtVariables: builtVariables
|
|
78
|
+
})[b];
|
|
79
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, b, result));
|
|
80
|
+
}
|
|
81
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, b, builtVariables[b]));
|
|
82
|
+
}, {});
|
|
83
|
+
};
|
|
84
|
+
var buildScopedBindings = function buildScopedBindings(_ref5) {
|
|
85
|
+
var bindings = _ref5.bindings,
|
|
86
|
+
index = _ref5.index;
|
|
87
|
+
return Object.entries(bindings).reduce(function (acc, _ref6) {
|
|
88
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
89
|
+
k = _ref7[0],
|
|
90
|
+
v = _ref7[1];
|
|
91
|
+
if (Array.isArray(v)) return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, v[index] !== undefined ? v[index] : null));
|
|
92
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, v));
|
|
93
|
+
}, {});
|
|
94
|
+
};
|
|
95
|
+
var buildVectorialBindings = function buildVectorialBindings(_ref8) {
|
|
96
|
+
var bindings = _ref8.bindings;
|
|
97
|
+
return Object.entries(bindings).reduce(function (acc, _ref9) {
|
|
98
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
|
99
|
+
k = _ref10[0],
|
|
100
|
+
v = _ref10[1];
|
|
101
|
+
if (Array.isArray(v)) return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, (0, _vtl["default"])(v)));
|
|
102
|
+
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, v));
|
|
103
|
+
}, {});
|
|
104
|
+
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports["default"] = void 0;
|
|
7
7
|
var _commons = require("../reducer/commons");
|
|
8
8
|
var _resolveComponentControls = require("../reducer/resolve-component-controls");
|
|
9
9
|
var _replaceComponentSequence = require("../replace-component-sequence");
|
|
@@ -53,7 +53,7 @@ function isCriticalErrors(errors) {
|
|
|
53
53
|
}
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function computeErrors(state) {
|
|
57
57
|
var components = (0, _replaceComponentSequence.replaceComponentSequence)((0, _getComponentsFromState["default"])(state));
|
|
58
58
|
var componentFiltered = components.map(function (component) {
|
|
59
59
|
return (0, _fillComponentExpressions["default"])(component, state);
|
|
@@ -68,4 +68,6 @@ function compileControls(state) {
|
|
|
68
68
|
currentErrors: currentErrors,
|
|
69
69
|
isCritical: isCritical
|
|
70
70
|
};
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
|
+
var _default = computeErrors;
|
|
73
|
+
exports["default"] = _default;
|
|
@@ -9,8 +9,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
9
9
|
function executeConditionFilter(filter, execute, iteration) {
|
|
10
10
|
if (filter && typeof execute === 'function') {
|
|
11
11
|
var value = filter.value;
|
|
12
|
+
var logging = function logging() {
|
|
13
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
|
+
args[_key] = arguments[_key];
|
|
15
|
+
}
|
|
16
|
+
console.warn(args);
|
|
17
|
+
console.warn('executeConditionFilter:', filter);
|
|
18
|
+
};
|
|
12
19
|
return execute((0, _getCompatibleVtlExpression["default"])(value), {
|
|
13
|
-
iteration: iteration
|
|
20
|
+
iteration: iteration,
|
|
21
|
+
logging: logging
|
|
14
22
|
});
|
|
15
23
|
}
|
|
16
24
|
return undefined;
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _executeExpression = _interopRequireDefault(require("./execute-expression"));
|
|
8
|
+
var _getSafetyExpression = _interopRequireDefault(require("./get-safety-expression"));
|
|
9
|
+
var _getExpressionsVariables = _interopRequireDefault(require("./get-expressions-variables"));
|
|
10
|
+
var _createMemoizer3 = _interopRequireDefault(require("./create-memoizer"));
|
|
11
|
+
var _createRefreshCalculated = _interopRequireDefault(require("./create-refresh-calculated"));
|
|
12
|
+
var _vtl = _interopRequireDefault(require("../../../utils/vtl"));
|
|
13
|
+
var _constants = require("../../../utils/constants");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
22
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
24
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
25
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
27
|
+
/**
|
|
28
|
+
* Check the shape of the expression and convert it into an expression
|
|
29
|
+
*/
|
|
30
|
+
function validateExpression(expObject) {
|
|
31
|
+
if (_typeof(expObject) === 'object' && expObject && 'type' in expObject) {
|
|
32
|
+
var type = expObject.type;
|
|
33
|
+
if (type === _constants.VTL || type === _constants.VTL_MD) {
|
|
34
|
+
return expObject;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (typeof expObject === 'string') return {
|
|
38
|
+
value: expObject,
|
|
39
|
+
type: _constants.VTL
|
|
40
|
+
};
|
|
41
|
+
console.warn("Non-VTL compatible expression");
|
|
42
|
+
console.warn(expObject);
|
|
43
|
+
throw new Error("Uncompatible VTL typeof element : ".concat(_typeof(expObject)));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Extract values for every variables
|
|
48
|
+
*/
|
|
49
|
+
function createBindings(variables) {
|
|
50
|
+
return Object.entries(variables).reduce(function (bindings, _ref) {
|
|
51
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
52
|
+
name = _ref2[0],
|
|
53
|
+
value = _ref2[1].value;
|
|
54
|
+
return _objectSpread(_objectSpread({}, bindings), {}, _defineProperty({}, name, value));
|
|
55
|
+
}, {});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Generates methods to interact with variables
|
|
60
|
+
*/
|
|
61
|
+
function createExecuteExpression(variables, features) {
|
|
62
|
+
// on aimerait map d'expression, avec les bindings
|
|
63
|
+
var bindings = createBindings(variables);
|
|
64
|
+
var tokensMap = new Map();
|
|
65
|
+
var _createMemoizer = (0, _createMemoizer3["default"])(),
|
|
66
|
+
_createMemoizer2 = _slicedToArray(_createMemoizer, 2),
|
|
67
|
+
memoize = _createMemoizer2[0],
|
|
68
|
+
getMemoizedValue = _createMemoizer2[1];
|
|
69
|
+
var _createRefreshCalcula = (0, _createRefreshCalculated["default"])({
|
|
70
|
+
variables: variables,
|
|
71
|
+
execute: execute,
|
|
72
|
+
bindings: bindings
|
|
73
|
+
}),
|
|
74
|
+
_createRefreshCalcula2 = _slicedToArray(_createRefreshCalcula, 2),
|
|
75
|
+
refreshCalculated = _createRefreshCalcula2[0],
|
|
76
|
+
setToRefreshCalculated = _createRefreshCalcula2[1];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Mark all linked variables to be refreshed
|
|
80
|
+
*/
|
|
81
|
+
function pushToLazy(name) {
|
|
82
|
+
if (name in variables) {
|
|
83
|
+
var _variables$name$Calcu = variables[name].CalculatedLinked,
|
|
84
|
+
CalculatedLinked = _variables$name$Calcu === void 0 ? [] : _variables$name$Calcu;
|
|
85
|
+
CalculatedLinked.forEach(function (variable) {
|
|
86
|
+
var name = variable.name;
|
|
87
|
+
setToRefreshCalculated(name, variable);
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
console.warn("".concat(name, " is not identified as varaible!"));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Update the value of a variable
|
|
96
|
+
*/
|
|
97
|
+
function updateBindings(name, value) {
|
|
98
|
+
if (name in bindings) {
|
|
99
|
+
bindings[name] = value;
|
|
100
|
+
}
|
|
101
|
+
pushToLazy(name);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Extract variables from an expression
|
|
106
|
+
*/
|
|
107
|
+
function getVariablesAndCatch(expression) {
|
|
108
|
+
// If we have an expression we can't have tokens
|
|
109
|
+
if (typeof expression !== 'string') {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
if (tokensMap.has(expression)) {
|
|
113
|
+
return tokensMap.get(expression);
|
|
114
|
+
}
|
|
115
|
+
var tokens = (0, _getExpressionsVariables["default"])(expression, variables);
|
|
116
|
+
tokensMap.set(expression, tokens);
|
|
117
|
+
return tokens;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Retrieve variable affected by the dependencies
|
|
122
|
+
*/
|
|
123
|
+
function collecteVariables(dependencies) {
|
|
124
|
+
if (Array.isArray(dependencies)) {
|
|
125
|
+
return dependencies.reduce(function (map, name) {
|
|
126
|
+
if (name in variables) {
|
|
127
|
+
var data = variables[name];
|
|
128
|
+
var variable = data.variable;
|
|
129
|
+
if (!(name in map)) {
|
|
130
|
+
if (variable.variableType === 'CALCULATED') {
|
|
131
|
+
var _expression = variable.expression;
|
|
132
|
+
var subDependencies = getVariablesAndCatch(_expression);
|
|
133
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, name, _objectSpread({}, variable)), collecteVariables(subDependencies));
|
|
134
|
+
}
|
|
135
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, name, _objectSpread({}, variable)));
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
throw new Error("Unknown variable ".concat(name));
|
|
139
|
+
}
|
|
140
|
+
return map;
|
|
141
|
+
}, {});
|
|
142
|
+
}
|
|
143
|
+
return {};
|
|
144
|
+
}
|
|
145
|
+
function resolveUseContext(name, _ref3) {
|
|
146
|
+
var iteration = _ref3.iteration,
|
|
147
|
+
linksIterations = _ref3.linksIterations;
|
|
148
|
+
var value = bindings[name];
|
|
149
|
+
if ([_constants.X_AXIS, _constants.Y_AXIS].includes(name) && linksIterations !== undefined) {
|
|
150
|
+
pushToLazy(name);
|
|
151
|
+
var _linksIterations = _slicedToArray(linksIterations, 2),
|
|
152
|
+
x = _linksIterations[0],
|
|
153
|
+
y = _linksIterations[1];
|
|
154
|
+
if (Array.isArray(value) && x < value.length) {
|
|
155
|
+
return value[name === _constants.X_AXIS ? x : y];
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
if (iteration !== undefined && Array.isArray(value)) {
|
|
160
|
+
pushToLazy(name);
|
|
161
|
+
if (iteration < value.length) {
|
|
162
|
+
return value[iteration];
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (linksIterations !== undefined) {
|
|
167
|
+
var _linksIterations2 = _slicedToArray(linksIterations, 2),
|
|
168
|
+
_x2 = _linksIterations2[0],
|
|
169
|
+
_y = _linksIterations2[1];
|
|
170
|
+
if (Array.isArray(value) && _x2 < value.length) {
|
|
171
|
+
var sub = value[_x2];
|
|
172
|
+
if (Array.isArray(sub) && _y < sub.length) {
|
|
173
|
+
return sub[_y];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return (0, _vtl["default"])(value);
|
|
179
|
+
}
|
|
180
|
+
function fillVariablesValues(map, _ref4) {
|
|
181
|
+
var iteration = _ref4.iteration,
|
|
182
|
+
linksIterations = _ref4.linksIterations;
|
|
183
|
+
return Object.entries(map).reduce(function (sub, _ref5) {
|
|
184
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
185
|
+
name = _ref6[0],
|
|
186
|
+
_ = _ref6[1];
|
|
187
|
+
return _objectSpread(_objectSpread({}, sub), {}, _defineProperty({}, name, resolveUseContext(name, {
|
|
188
|
+
iteration: iteration,
|
|
189
|
+
linksIterations: linksIterations
|
|
190
|
+
})));
|
|
191
|
+
}, {});
|
|
192
|
+
}
|
|
193
|
+
function execute(expObject) {
|
|
194
|
+
var _args$iteration;
|
|
195
|
+
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
196
|
+
var _validateExpression = validateExpression((0, _getSafetyExpression["default"])(expObject)),
|
|
197
|
+
expression = _validateExpression.value,
|
|
198
|
+
type = _validateExpression.type;
|
|
199
|
+
var iteration = args.iteration,
|
|
200
|
+
linksIterations = args.linksIterations,
|
|
201
|
+
logging = args.logging;
|
|
202
|
+
var bindingDependencies = getVariablesAndCatch(expression);
|
|
203
|
+
function loggingDefault(_, bindings, e) {
|
|
204
|
+
if (process.env.NODE_ENV === 'development') {
|
|
205
|
+
console.warn("VTL error : ".concat(expression), _objectSpread({}, args), {
|
|
206
|
+
bindings: bindings
|
|
207
|
+
});
|
|
208
|
+
console.warn(e);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
var vtlBindings = refreshCalculated(fillVariablesValues(collecteVariables(bindingDependencies), {
|
|
212
|
+
iteration: iteration,
|
|
213
|
+
linksIterations: linksIterations
|
|
214
|
+
}), {
|
|
215
|
+
rootExpression: expression,
|
|
216
|
+
iteration: iteration,
|
|
217
|
+
linksIterations: linksIterations
|
|
218
|
+
});
|
|
219
|
+
// Add index has a specific variable
|
|
220
|
+
vtlBindings['GLOBAL_ITERATION_INDEX'] = (((_args$iteration = args === null || args === void 0 ? void 0 : args.iteration) !== null && _args$iteration !== void 0 ? _args$iteration : 0) + 1).toString();
|
|
221
|
+
var memoized = getMemoizedValue(expression, vtlBindings);
|
|
222
|
+
if (memoized === undefined) {
|
|
223
|
+
var result = (0, _executeExpression["default"])(vtlBindings, expression, type, features, logging || loggingDefault);
|
|
224
|
+
memoize(expression, vtlBindings, result);
|
|
225
|
+
return result; // We need to force this type to match with the signature
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return memoized;
|
|
229
|
+
}
|
|
230
|
+
return [execute, updateBindings];
|
|
231
|
+
}
|
|
232
|
+
var _default = createExecuteExpression;
|
|
233
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _createExecuteExpression = _interopRequireDefault(require("./create-execute-expression"));
|
|
4
|
+
var _vitest = require("vitest");
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
var variables = {
|
|
13
|
+
LASTNAME: {
|
|
14
|
+
CalculatedLinked: [],
|
|
15
|
+
type: 'COLLECTED',
|
|
16
|
+
value: 'Doe',
|
|
17
|
+
variable: {
|
|
18
|
+
name: 'LASTNAME',
|
|
19
|
+
variableType: 'COLLECTED'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
GREETING: {
|
|
23
|
+
CalculatedLinked: [],
|
|
24
|
+
value: 'Hello Doe',
|
|
25
|
+
type: 'CALCULATED',
|
|
26
|
+
variable: {
|
|
27
|
+
name: 'GREETING',
|
|
28
|
+
variableType: 'COLLECTED',
|
|
29
|
+
expression: {
|
|
30
|
+
value: '"Hello " || LASTNAME',
|
|
31
|
+
type: 'VTL'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
PAIRWISE: {
|
|
36
|
+
CalculatedLinked: [],
|
|
37
|
+
type: 'COLLECTED',
|
|
38
|
+
value: [['a1', 'a2'], ['b1', 'b2']],
|
|
39
|
+
variable: {
|
|
40
|
+
name: 'PAIRWISE',
|
|
41
|
+
variableType: 'COLLECTED'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
PRENOMS: {
|
|
45
|
+
CalculatedLinked: [],
|
|
46
|
+
type: 'COLLECTED',
|
|
47
|
+
value: [],
|
|
48
|
+
variable: {
|
|
49
|
+
name: 'PRENOMS',
|
|
50
|
+
variableType: 'COLLECTED'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
PRENOMVIDE: {
|
|
54
|
+
CalculatedLinked: [],
|
|
55
|
+
type: 'CALCULATED',
|
|
56
|
+
variable: {
|
|
57
|
+
name: 'PRENOMVIDE',
|
|
58
|
+
variableType: 'CALCULATED',
|
|
59
|
+
expression: {
|
|
60
|
+
value: '"empty"',
|
|
61
|
+
type: 'VTL'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
PRENOMS_WITH_DEFAULTS: {
|
|
66
|
+
CalculatedLinked: [],
|
|
67
|
+
variable: {
|
|
68
|
+
variableType: 'CALCULATED',
|
|
69
|
+
name: 'PRENOMS_WITH_DEFAULTS',
|
|
70
|
+
expression: {
|
|
71
|
+
value: 'if (isnull(PRENOMS)) then PRENOMVIDE else PRENOMS',
|
|
72
|
+
type: 'VTL'
|
|
73
|
+
},
|
|
74
|
+
bindingDependencies: ['PRENOMS', 'PRENOMVIDE'],
|
|
75
|
+
shapeFrom: 'PRENOMS'
|
|
76
|
+
},
|
|
77
|
+
type: 'CALCULATED'
|
|
78
|
+
},
|
|
79
|
+
PRENOMS_SIZE: {
|
|
80
|
+
CalculatedLinked: [],
|
|
81
|
+
variable: {
|
|
82
|
+
variableType: 'CALCULATED',
|
|
83
|
+
name: 'PRENOMS_SIZE',
|
|
84
|
+
expression: {
|
|
85
|
+
value: 'count(PRENOMS)',
|
|
86
|
+
type: 'VTL'
|
|
87
|
+
},
|
|
88
|
+
bindingDependencies: ['PRENOMS']
|
|
89
|
+
},
|
|
90
|
+
type: 'CALCULATED'
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
variables.PRENOMS.CalculatedLinked = [variables.PRENOMS_WITH_DEFAULTS.variable, variables.PRENOMS_SIZE.variable];
|
|
94
|
+
variables.LASTNAME.CalculatedLinked = [variables.GREETING.variable];
|
|
95
|
+
(0, _vitest.describe)('createExecuteExpression', function () {
|
|
96
|
+
var execute, update;
|
|
97
|
+
(0, _vitest.beforeEach)(function () {
|
|
98
|
+
var _createExecuteExpress = (0, _createExecuteExpression["default"])(variables, ['VTL', 'VTL|MD']);
|
|
99
|
+
var _createExecuteExpress2 = _slicedToArray(_createExecuteExpress, 2);
|
|
100
|
+
execute = _createExecuteExpress2[0];
|
|
101
|
+
update = _createExecuteExpress2[1];
|
|
102
|
+
});
|
|
103
|
+
(0, _vitest.it)('should retrieve collected value', function () {
|
|
104
|
+
(0, _vitest.expect)(execute('LASTNAME')).toBe('Doe');
|
|
105
|
+
(0, _vitest.expect)(execute('"John " || LASTNAME')).toBe('John Doe');
|
|
106
|
+
});
|
|
107
|
+
_vitest.it.skip('should hangle calculated value', function () {
|
|
108
|
+
(0, _vitest.expect)(execute('GREETING')).toBe('Hello Doe');
|
|
109
|
+
update('LASTNAME', 'Doee');
|
|
110
|
+
(0, _vitest.expect)(execute('GREETING')).toBe('Hello Doee');
|
|
111
|
+
});
|
|
112
|
+
(0, _vitest.it)('should handle updated value', function () {
|
|
113
|
+
(0, _vitest.expect)(execute('LASTNAME')).toBe('Doe');
|
|
114
|
+
update('LASTNAME', 'John');
|
|
115
|
+
(0, _vitest.expect)(execute('LASTNAME')).toBe('John');
|
|
116
|
+
});
|
|
117
|
+
(0, _vitest.it)('should handle 1D vectors', function () {
|
|
118
|
+
update('PRENOMS', ['Jane', 'John', 'James']);
|
|
119
|
+
(0, _vitest.expect)(execute('PRENOMS', {
|
|
120
|
+
iteration: 1
|
|
121
|
+
})).toBe('John');
|
|
122
|
+
(0, _vitest.expect)(execute('PRENOMS', {
|
|
123
|
+
iteration: 0
|
|
124
|
+
})).toBe('Jane');
|
|
125
|
+
(0, _vitest.expect)(execute('PRENOMS_SIZE', {
|
|
126
|
+
iteration: 1
|
|
127
|
+
})).toBe(3);
|
|
128
|
+
(0, _vitest.expect)(execute('PRENOMS_WITH_DEFAULTS', {
|
|
129
|
+
iteration: 1
|
|
130
|
+
})).toBe('John');
|
|
131
|
+
update('PRENOMS', [null, null]);
|
|
132
|
+
(0, _vitest.expect)(execute('PRENOMS', {
|
|
133
|
+
iteration: 1
|
|
134
|
+
})).toBe(null);
|
|
135
|
+
(0, _vitest.expect)(execute('PRENOMS_WITH_DEFAULTS', {
|
|
136
|
+
iteration: 1
|
|
137
|
+
})).toBe('empty');
|
|
138
|
+
(0, _vitest.expect)(execute('PRENOMS_SIZE')).toBe(2);
|
|
139
|
+
});
|
|
140
|
+
(0, _vitest.it)('should handle 2D Vectors', function () {
|
|
141
|
+
(0, _vitest.expect)(execute('PAIRWISE', {
|
|
142
|
+
linksIterations: [0, 1]
|
|
143
|
+
})).toBe('a2');
|
|
144
|
+
(0, _vitest.expect)(execute('PAIRWISE', {
|
|
145
|
+
linksIterations: [1, 1]
|
|
146
|
+
})).toBe('b2');
|
|
147
|
+
});
|
|
148
|
+
(0, _vitest.it)('should handle direct expression', function () {
|
|
149
|
+
update('PRENOMS', ['Jane', 'John', 'James']);
|
|
150
|
+
(0, _vitest.expect)(execute('count(PRENOMS)')).toBe(3);
|
|
151
|
+
(0, _vitest.expect)(execute('PRENOMS || " Doe"', {
|
|
152
|
+
iteration: 0
|
|
153
|
+
})).toBe('Jane Doe');
|
|
154
|
+
});
|
|
155
|
+
});
|