@truedat/dq 4.41.3 → 4.42.1

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.
Files changed (22) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/package.json +5 -5
  3. package/src/components/ConditionSummary.js +41 -27
  4. package/src/components/ImplementationSummary.js +5 -5
  5. package/src/components/NewRuleImplementation.js +76 -17
  6. package/src/components/RuleImplementationProperties.js +2 -1
  7. package/src/components/__test_samples__/NewRuleImplementationProps.js +44 -42
  8. package/src/components/__tests__/ImplementationSummary.spec.js +4 -4
  9. package/src/components/__tests__/__snapshots__/ImplementationSummary.spec.js.snap +68 -3
  10. package/src/components/__tests__/__snapshots__/NewRuleImplementation.spec.js.snap +108 -100
  11. package/src/components/__tests__/__snapshots__/RuleImplementationProperties.spec.js.snap +1 -1
  12. package/src/components/ruleImplementationForm/PopulationForm.js +1 -27
  13. package/src/components/ruleImplementationForm/RuleImplementationForm.js +69 -20
  14. package/src/components/ruleImplementationForm/RuleImplementationRawForm.js +163 -177
  15. package/src/components/ruleImplementationForm/__tests__/RuleImplementationRawForm.spec.js +3 -3
  16. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationForm.spec.js.snap +1 -1
  17. package/src/components/ruleImplementationForm/__tests__/__snapshots__/RuleImplementationRawForm.spec.js.snap +159 -156
  18. package/src/messages/en.js +4 -2
  19. package/src/messages/es.js +3 -1
  20. package/src/reducers/ruleImplementation.js +1 -1
  21. package/src/sagas/__tests__/createRuleImplementation.spec.js +12 -10
  22. package/src/sagas/__tests__/updateRuleImplementation.spec.js +8 -6
@@ -28,6 +28,7 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
28
28
  stretched={true}
29
29
  >
30
30
  <Connect(RuleImplementationForm)
31
+ addPopulation={[Function]}
31
32
  handleSubmit={[Function]}
32
33
  onChange={[Function]}
33
34
  operators={
@@ -799,64 +800,66 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
799
800
  "implementationKey": "impl_example_1",
800
801
  "implementationType": "default",
801
802
  "minimum": 2010,
802
- "population": Array [
803
- Object {
804
- "modifier": undefined,
805
- "operator": Object {
806
- "group": "eq",
807
- "id": 23,
808
- "name": "eq",
809
- "value_type": "field",
810
- },
811
- "structure": Object {
812
- "external_id": "https://glue.eu-west-1.amazonaws.com/#/576759405678/cepsa-demo-s3/02_es_provincias/descripcion",
813
- "field_type": "string",
814
- "id": 4817544,
815
- "metadata": Object {
816
- "account": "576759405678",
817
- "data_type_class": "string",
818
- "database": "cepsa-demo-s3",
819
- "order": "2.0",
820
- "region": "eu-west-1",
821
- "tablename": "02_es_provincias",
822
- "type": "string",
803
+ "populations": Array [
804
+ Array [
805
+ Object {
806
+ "modifier": undefined,
807
+ "operator": Object {
808
+ "group": "eq",
809
+ "id": 23,
810
+ "name": "eq",
811
+ "value_type": "field",
823
812
  },
824
- "name": "descripcion",
825
- "parent_index": 1,
826
- "path": Array [
827
- "cepsa-demo-s3",
828
- "02_es_provincias",
829
- ],
830
- "system": Object {
831
- "external_id": "glue",
832
- "id": 94,
833
- "name": "Glue",
834
- },
835
- "type": "Column",
836
- },
837
- "value": Array [
838
- Object {
839
- "external_id": "/home/alberto/projects/connectors/td-connector-txt-files/data/########_D_PELAYO_POLIZAS_20201202033016_I.txt[Aux. Externo]",
840
- "id": 4814767,
813
+ "structure": Object {
814
+ "external_id": "https://glue.eu-west-1.amazonaws.com/#/576759405678/cepsa-demo-s3/02_es_provincias/descripcion",
815
+ "field_type": "string",
816
+ "id": 4817544,
841
817
  "metadata": Object {
842
- "order": "8",
818
+ "account": "576759405678",
819
+ "data_type_class": "string",
820
+ "database": "cepsa-demo-s3",
821
+ "order": "2.0",
822
+ "region": "eu-west-1",
823
+ "tablename": "02_es_provincias",
824
+ "type": "string",
843
825
  },
844
- "name": "Aux. Externo",
845
- "parent_index": 0,
826
+ "name": "descripcion",
827
+ "parent_index": 1,
846
828
  "path": Array [
847
- "Area_Vida",
848
- "########_D_PELAYO_POLIZAS_20201202033016_I.txt",
829
+ "cepsa-demo-s3",
830
+ "02_es_provincias",
849
831
  ],
850
832
  "system": Object {
851
- "external_id": "file_system",
852
- "id": 33,
853
- "name": "File System",
833
+ "external_id": "glue",
834
+ "id": 94,
835
+ "name": "Glue",
854
836
  },
855
837
  "type": "Column",
856
838
  },
857
- ],
858
- "value_modifier": undefined,
859
- },
839
+ "value": Array [
840
+ Object {
841
+ "external_id": "/home/alberto/projects/connectors/td-connector-txt-files/data/########_D_PELAYO_POLIZAS_20201202033016_I.txt[Aux. Externo]",
842
+ "id": 4814767,
843
+ "metadata": Object {
844
+ "order": "8",
845
+ },
846
+ "name": "Aux. Externo",
847
+ "parent_index": 0,
848
+ "path": Array [
849
+ "Area_Vida",
850
+ "########_D_PELAYO_POLIZAS_20201202033016_I.txt",
851
+ ],
852
+ "system": Object {
853
+ "external_id": "file_system",
854
+ "id": 33,
855
+ "name": "File System",
856
+ },
857
+ "type": "Column",
858
+ },
859
+ ],
860
+ "value_modifier": undefined,
861
+ },
862
+ ],
860
863
  ],
861
864
  "rawContent": Object {},
862
865
  "result_type": "errors_number",
@@ -901,7 +904,7 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
901
904
  }
902
905
  }
903
906
  setImplementationKey={[Function]}
904
- setPopulation={[Function]}
907
+ setPopulations={[Function]}
905
908
  setStructures={[Function]}
906
909
  setValidations={[Function]}
907
910
  />
@@ -1022,64 +1025,66 @@ exports[`<NewRuleImplementation /> calculate aliases when not informed 1`] = `
1022
1025
  "implementationKey": "impl_example_1",
1023
1026
  "implementationType": "default",
1024
1027
  "minimum": 2010,
1025
- "population": Array [
1026
- Object {
1027
- "modifier": undefined,
1028
- "operator": Object {
1029
- "group": "eq",
1030
- "id": 23,
1031
- "name": "eq",
1032
- "value_type": "field",
1033
- },
1034
- "structure": Object {
1035
- "external_id": "https://glue.eu-west-1.amazonaws.com/#/576759405678/cepsa-demo-s3/02_es_provincias/descripcion",
1036
- "field_type": "string",
1037
- "id": 4817544,
1038
- "metadata": Object {
1039
- "account": "576759405678",
1040
- "data_type_class": "string",
1041
- "database": "cepsa-demo-s3",
1042
- "order": "2.0",
1043
- "region": "eu-west-1",
1044
- "tablename": "02_es_provincias",
1045
- "type": "string",
1046
- },
1047
- "name": "descripcion",
1048
- "parent_index": 1,
1049
- "path": Array [
1050
- "cepsa-demo-s3",
1051
- "02_es_provincias",
1052
- ],
1053
- "system": Object {
1054
- "external_id": "glue",
1055
- "id": 94,
1056
- "name": "Glue",
1028
+ "populations": Array [
1029
+ Array [
1030
+ Object {
1031
+ "modifier": undefined,
1032
+ "operator": Object {
1033
+ "group": "eq",
1034
+ "id": 23,
1035
+ "name": "eq",
1036
+ "value_type": "field",
1057
1037
  },
1058
- "type": "Column",
1059
- },
1060
- "value": Array [
1061
- Object {
1062
- "external_id": "/home/alberto/projects/connectors/td-connector-txt-files/data/########_D_PELAYO_POLIZAS_20201202033016_I.txt[Aux. Externo]",
1063
- "id": 4814767,
1038
+ "structure": Object {
1039
+ "external_id": "https://glue.eu-west-1.amazonaws.com/#/576759405678/cepsa-demo-s3/02_es_provincias/descripcion",
1040
+ "field_type": "string",
1041
+ "id": 4817544,
1064
1042
  "metadata": Object {
1065
- "order": "8",
1043
+ "account": "576759405678",
1044
+ "data_type_class": "string",
1045
+ "database": "cepsa-demo-s3",
1046
+ "order": "2.0",
1047
+ "region": "eu-west-1",
1048
+ "tablename": "02_es_provincias",
1049
+ "type": "string",
1066
1050
  },
1067
- "name": "Aux. Externo",
1068
- "parent_index": 0,
1051
+ "name": "descripcion",
1052
+ "parent_index": 1,
1069
1053
  "path": Array [
1070
- "Area_Vida",
1071
- "########_D_PELAYO_POLIZAS_20201202033016_I.txt",
1054
+ "cepsa-demo-s3",
1055
+ "02_es_provincias",
1072
1056
  ],
1073
1057
  "system": Object {
1074
- "external_id": "file_system",
1075
- "id": 33,
1076
- "name": "File System",
1058
+ "external_id": "glue",
1059
+ "id": 94,
1060
+ "name": "Glue",
1077
1061
  },
1078
1062
  "type": "Column",
1079
1063
  },
1080
- ],
1081
- "value_modifier": undefined,
1082
- },
1064
+ "value": Array [
1065
+ Object {
1066
+ "external_id": "/home/alberto/projects/connectors/td-connector-txt-files/data/########_D_PELAYO_POLIZAS_20201202033016_I.txt[Aux. Externo]",
1067
+ "id": 4814767,
1068
+ "metadata": Object {
1069
+ "order": "8",
1070
+ },
1071
+ "name": "Aux. Externo",
1072
+ "parent_index": 0,
1073
+ "path": Array [
1074
+ "Area_Vida",
1075
+ "########_D_PELAYO_POLIZAS_20201202033016_I.txt",
1076
+ ],
1077
+ "system": Object {
1078
+ "external_id": "file_system",
1079
+ "id": 33,
1080
+ "name": "File System",
1081
+ },
1082
+ "type": "Column",
1083
+ },
1084
+ ],
1085
+ "value_modifier": undefined,
1086
+ },
1087
+ ],
1083
1088
  ],
1084
1089
  "rawContent": Object {},
1085
1090
  "result_type": "errors_number",
@@ -1157,6 +1162,7 @@ exports[`<NewRuleImplementation /> matches the latest snapshot 1`] = `
1157
1162
  stretched={true}
1158
1163
  >
1159
1164
  <Connect(RuleImplementationForm)
1165
+ addPopulation={[Function]}
1160
1166
  handleSubmit={[Function]}
1161
1167
  onChange={[Function]}
1162
1168
  ruleImplementation={
@@ -1172,6 +1178,7 @@ exports[`<NewRuleImplementation /> matches the latest snapshot 1`] = `
1172
1178
  "implementationType": "default",
1173
1179
  "minimum": null,
1174
1180
  "population": Array [],
1181
+ "populations": Array [],
1175
1182
  "rawContent": Object {
1176
1183
  "database": "",
1177
1184
  "dataset": "",
@@ -1186,7 +1193,7 @@ exports[`<NewRuleImplementation /> matches the latest snapshot 1`] = `
1186
1193
  }
1187
1194
  }
1188
1195
  setImplementationKey={[Function]}
1189
- setPopulation={[Function]}
1196
+ setPopulations={[Function]}
1190
1197
  setStructures={[Function]}
1191
1198
  setValidations={[Function]}
1192
1199
  />
@@ -1209,6 +1216,7 @@ exports[`<NewRuleImplementation /> matches the latest snapshot 1`] = `
1209
1216
  "implementationType": "default",
1210
1217
  "minimum": null,
1211
1218
  "population": Array [],
1219
+ "populations": Array [],
1212
1220
  "rawContent": Object {
1213
1221
  "database": "",
1214
1222
  "dataset": "",
@@ -63,7 +63,7 @@ exports[`<RuleImplementationProperties /> matches the latest snapshot 1`] = `
63
63
  activeSteps={
64
64
  Array [
65
65
  "dataset",
66
- "population",
66
+ "populations",
67
67
  "validations",
68
68
  ]
69
69
  }
@@ -6,30 +6,6 @@ import { Grid, Icon, Segment } from "semantic-ui-react";
6
6
  import { dropAt, replaceAt } from "@truedat/core/services/arrays";
7
7
  import { FiltersGrid } from "./FiltersGrid";
8
8
 
9
- const PopulationTypeForm = ({ createFilter }) => (
10
- <Grid columns={2} textAlign="center">
11
- <Grid.Column>
12
- <Segment className={`population active`}>
13
- <FormattedMessage id="populationForm.selectAll.text" />
14
- <Icon circular name="check" color="green" />
15
- </Segment>
16
- </Grid.Column>
17
- <Grid.Column>
18
- <Segment
19
- className={`population selectable`}
20
- onClick={() => createFilter()}
21
- >
22
- <Icon name="plus circle" />
23
- <FormattedMessage id="populationForm.createFilters.text" />
24
- </Segment>
25
- </Grid.Column>
26
- </Grid>
27
- );
28
-
29
- PopulationTypeForm.propTypes = {
30
- createFilter: PropTypes.func,
31
- };
32
-
33
9
  export default function PopulationForm({
34
10
  typeOperators,
35
11
  population,
@@ -45,9 +21,7 @@ export default function PopulationForm({
45
21
  } else setPopulation(dropAt(index)(population));
46
22
  };
47
23
 
48
- return _.isEmpty(population) ? (
49
- <PopulationTypeForm createFilter={() => setPopulation([{}])} />
50
- ) : (
24
+ return _.isEmpty(population) ? null : (
51
25
  <FiltersGrid
52
26
  rows={population}
53
27
  setRowValue={setPopulationField}
@@ -4,7 +4,15 @@ import PropTypes from "prop-types";
4
4
  import { connect } from "react-redux";
5
5
  import { useHistory } from "react-router-dom";
6
6
  import { FormattedMessage, useIntl } from "react-intl";
7
- import { Button, Divider, Form, Grid, Icon, Step } from "semantic-ui-react";
7
+ import {
8
+ Button,
9
+ Divider,
10
+ Form,
11
+ Grid,
12
+ Icon,
13
+ Step,
14
+ Segment,
15
+ } from "semantic-ui-react";
8
16
  import { validateContent } from "@truedat/df/utils";
9
17
  import PopulationForm from "./PopulationForm";
10
18
  import DatasetForm from "./DatasetForm";
@@ -32,7 +40,8 @@ RuleImplementationStep.propTypes = {
32
40
  export const RuleImplementationForm = ({
33
41
  ruleImplementation,
34
42
  setStructures,
35
- setPopulation,
43
+ addPopulation,
44
+ setPopulations,
36
45
  setImplementationKey,
37
46
  setValidations,
38
47
  isSubmitting,
@@ -46,7 +55,7 @@ export const RuleImplementationForm = ({
46
55
  const steps = [
47
56
  { name: "information", icon: "info", isValid: () => validInformation() },
48
57
  { name: "dataset", icon: "database", isValid: () => validDataSet() },
49
- { name: "population", icon: "user", isValid: () => validPopulation() },
58
+ { name: "populations", icon: "user", isValid: () => validPopulations() },
50
59
  { name: "validations", icon: "setting", isValid: () => validValidations() },
51
60
  ];
52
61
 
@@ -55,7 +64,7 @@ export const RuleImplementationForm = ({
55
64
 
56
65
  const {
57
66
  dataset: structures,
58
- population,
67
+ populations,
59
68
  validations,
60
69
  dfContent,
61
70
  } = ruleImplementation || {};
@@ -66,8 +75,8 @@ export const RuleImplementationForm = ({
66
75
  _.size(validateContent(template)(dfContent)) == 0 &&
67
76
  areLimitsValid(ruleImplementation);
68
77
 
69
- const validPopulation = () =>
70
- _.every(_.isEmpty)(population) || populationComplete();
78
+ const validPopulations = () =>
79
+ _.every((population) => populationComplete(population))(populations);
71
80
 
72
81
  const validValidations = () =>
73
82
  _.every(_.negate(_.isEmpty))(validations) && validationsComplete();
@@ -90,11 +99,9 @@ export const RuleImplementationForm = ({
90
99
  _.size(clauses) > 0 &&
91
100
  _.every((c) => itemComplete(c, ["left", "right"]))(clauses);
92
101
 
93
- const populationComplete = () =>
94
- _.flow(
95
- _.filter(_.negate(_.isEmpty)),
96
- _.every((p) => itemComplete(p, attrsFromProfile(p)))
97
- )(population);
102
+ const populationComplete = (population) =>
103
+ _.every(_.negate(_.isEmpty))(population) &&
104
+ _.every((p) => itemComplete(p, attrsFromProfile(p)))(population);
98
105
 
99
106
  const validationsComplete = () =>
100
107
  _.every((v) => itemComplete(v, attrsFromProfile(v)))(validations);
@@ -231,14 +238,31 @@ export const RuleImplementationForm = ({
231
238
  }}
232
239
  />
233
240
  )}
234
- {activeStep == "population" && (
235
- <PopulationForm
236
- population={population}
237
- setPopulation={setPopulation}
238
- structures={structures}
239
- typeOperators={operators}
240
- />
241
- )}
241
+ {activeStep == "populations" ? (
242
+ <>
243
+ {populations.map((population, i) => (
244
+ <Segment key={i}>
245
+ <PopulationForm
246
+ population={population}
247
+ setPopulation={(p) => setPopulations(p, i)}
248
+ structures={structures}
249
+ typeOperators={operators}
250
+ />
251
+ </Segment>
252
+ ))}
253
+ {_.flow(_.flatten, _.isEmpty)(populations) ? (
254
+ <PopulationTypeForm createFilter={() => addPopulation()} />
255
+ ) : validPopulations() ? (
256
+ <Button
257
+ secondary
258
+ onClick={() => addPopulation()}
259
+ content={formatMessage({
260
+ id: "ruleImplementationForm.populations.add",
261
+ })}
262
+ />
263
+ ) : null}
264
+ </>
265
+ ) : null}
242
266
  {activeStep == "validations" && (
243
267
  <ValidationsForm
244
268
  validations={validations}
@@ -291,7 +315,8 @@ RuleImplementationForm.propTypes = {
291
315
  handleSubmit: PropTypes.func.isRequired,
292
316
  isSubmitting: PropTypes.bool.isRequired,
293
317
  setStructures: PropTypes.func,
294
- setPopulation: PropTypes.func,
318
+ addPopulation: PropTypes.func,
319
+ setPopulations: PropTypes.func,
295
320
  setImplementationKey: PropTypes.func,
296
321
  setValidations: PropTypes.func,
297
322
  operators: PropTypes.object,
@@ -305,3 +330,27 @@ const mapStateToProps = (state) => ({
305
330
  });
306
331
 
307
332
  export default connect(mapStateToProps)(RuleImplementationForm);
333
+
334
+ const PopulationTypeForm = ({ createFilter }) => (
335
+ <Grid columns={2} textAlign="center">
336
+ <Grid.Column>
337
+ <Segment className={`population active`}>
338
+ <FormattedMessage id="populationForm.selectAll.text" />
339
+ <Icon circular name="check" color="green" />
340
+ </Segment>
341
+ </Grid.Column>
342
+ <Grid.Column>
343
+ <Segment
344
+ className={`population selectable`}
345
+ onClick={() => createFilter()}
346
+ >
347
+ <Icon name="plus circle" />
348
+ <FormattedMessage id="populationForm.createFilters.text" />
349
+ </Segment>
350
+ </Grid.Column>
351
+ </Grid>
352
+ );
353
+
354
+ PopulationTypeForm.propTypes = {
355
+ createFilter: PropTypes.func,
356
+ };