@sankhyalabs/core 5.20.0-dev.53 → 5.20.0-dev.55

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 (37) hide show
  1. package/.docs/classes/Change.md +11 -11
  2. package/.docs/classes/DataUnit.md +32 -24
  3. package/.docs/classes/SelectionInfo.md +12 -12
  4. package/.docs/classes/ServiceUtils.md +67 -0
  5. package/.docs/enumerations/ChangeOperation.md +4 -4
  6. package/.docs/enumerations/SelectionMode.md +2 -2
  7. package/.docs/enumerations/StorageType.md +37 -0
  8. package/.docs/globals.md +2 -0
  9. package/.docs/interfaces/DUActionInterceptor.md +1 -1
  10. package/.docs/interfaces/PageRequest.md +3 -3
  11. package/.docs/interfaces/QuickFilter.md +3 -3
  12. package/.docs/interfaces/Record.md +4 -4
  13. package/.docs/interfaces/SavedRecord.md +5 -5
  14. package/.docs/interfaces/WaitingChange.md +3 -3
  15. package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
  16. package/dist/dataunit/DataUnit.d.ts +4 -4
  17. package/dist/dataunit/DataUnit.js +25 -12
  18. package/dist/dataunit/DataUnit.js.map +1 -1
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.js +3 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/utils/CacheManager/index.d.ts +52 -0
  23. package/dist/utils/CacheManager/index.js +101 -0
  24. package/dist/utils/CacheManager/index.js.map +1 -0
  25. package/dist/utils/CacheManager/interfaces/index.d.ts +5 -0
  26. package/dist/utils/CacheManager/interfaces/index.js +7 -0
  27. package/dist/utils/CacheManager/interfaces/index.js.map +1 -0
  28. package/dist/utils/ServiceUtils.d.ts +24 -0
  29. package/dist/utils/ServiceUtils.js +40 -0
  30. package/dist/utils/ServiceUtils.js.map +1 -0
  31. package/package.json +1 -1
  32. package/reports/test-report.xml +96 -96
  33. package/src/dataunit/DataUnit.ts +25 -13
  34. package/src/index.ts +4 -0
  35. package/src/utils/CacheManager/index.ts +103 -0
  36. package/src/utils/CacheManager/interfaces/index.ts +5 -0
  37. package/src/utils/ServiceUtils.ts +36 -0
@@ -1,148 +1,153 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <unitTest version="1">
3
3
  <file path="/builds/dti/design-system/sankhyacore/test/http/HttpProvider.spec.ts">
4
- <testCase name="HttpProvider Metodo GET" duration="70"/>
4
+ <testCase name="HttpProvider Metodo GET" duration="12"/>
5
5
  </file>
6
6
  <file path="/builds/dti/design-system/sankhyacore/test/http/SkwHttpProvider.ts.spec.ts">
7
- <testCase name="HttpProvider Metodo POST" duration="89"/>
7
+ <testCase name="HttpProvider Metodo POST" duration="16"/>
8
+ </file>
9
+ <file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaParameter.spec.ts">
10
+ <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the constructor" duration="3"/>
11
+ <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the setters methods" duration="0"/>
12
+ <testCase name="StringUtils it should return the correct JSON/Object value through the buildParam method" duration="1"/>
8
13
  </file>
9
14
  <file path="/builds/dti/design-system/sankhyacore/src/utils/test/objectUtils.spec.ts">
10
- <testCase name="ObjectUtils hasEquivalentValues should return true if both objects have the same property value" duration="14"/>
11
- <testCase name="ObjectUtils hasEquivalentValues should return false if both objects have different property values" duration="77"/>
15
+ <testCase name="ObjectUtils hasEquivalentValues should return true if both objects have the same property value" duration="6"/>
16
+ <testCase name="ObjectUtils hasEquivalentValues should return false if both objects have different property values" duration="1"/>
12
17
  <testCase name="ObjectUtils hasEquivalentValues should return true if both objects are equivalent with custom property to compare" duration="1"/>
13
- <testCase name="ObjectUtils hasEquivalentValues should return false if both objects are not equivalent with custom property to compare" duration="1"/>
18
+ <testCase name="ObjectUtils hasEquivalentValues should return false if both objects are not equivalent with custom property to compare" duration="190"/>
14
19
  <testCase name="ObjectUtils hasEquivalentValues should return false if one object does not have the property" duration="1"/>
15
20
  <testCase name="ObjectUtils hasEquivalentValues should return true if comparing primitive values directly" duration="1"/>
16
21
  <testCase name="ObjectUtils hasEquivalentValues should return false if comparing different primitive values" duration="0"/>
17
22
  <testCase name="ObjectUtils hasEquivalentValues should return true when comparing object with a null value" duration="0"/>
18
23
  <testCase name="ObjectUtils hasEquivalentValues should return false when comparing object with null and non-null value" duration="1"/>
19
24
  <testCase name="ObjectUtils hasEquivalentValues should return true when comparing non-object values that are equal" duration="1"/>
20
- <testCase name="ObjectUtils should get an object value based on its path" duration="1"/>
21
- <testCase name="ObjectUtils should get an object value based on its path" duration="1"/>
25
+ <testCase name="ObjectUtils should get an object value based on its path" duration="0"/>
26
+ <testCase name="ObjectUtils should get an object value based on its path" duration="0"/>
22
27
  <testCase name="ObjectUtils should return undefined if the path doesn&apos;t exist in the object" duration="1"/>
23
28
  </file>
24
- <file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaParameter.spec.ts">
25
- <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the constructor" duration="6"/>
26
- <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the setters methods" duration="5"/>
27
- <testCase name="StringUtils it should return the correct JSON/Object value through the buildParam method" duration="1"/>
28
- </file>
29
29
  <file path="/builds/dti/design-system/sankhyacore/test/util/MaskFormatter.spec.ts">
30
- <testCase name="Mask Formatter mask:CPF complete valid" duration="8"/>
30
+ <testCase name="Mask Formatter mask:CPF complete valid" duration="84"/>
31
31
  <testCase name="Mask Formatter mask:CPF complete valid literals" duration="1"/>
32
- <testCase name="Mask Formatter mask:CPF incomplete valid" duration="1"/>
32
+ <testCase name="Mask Formatter mask:CPF incomplete valid" duration="0"/>
33
33
  <testCase name="Mask Formatter mask:CPF incomplete valid placeholder" duration="1"/>
34
- <testCase name="Mask Formatter mask:CPF too long valid" duration="1"/>
35
- <testCase name="Mask Formatter mask:CPF invalid for string" duration="285"/>
34
+ <testCase name="Mask Formatter mask:CPF too long valid" duration="0"/>
35
+ <testCase name="Mask Formatter mask:CPF invalid for string" duration="112"/>
36
36
  <testCase name="Mask Formatter mask:CPF invalid for being too long" duration="0"/>
37
37
  <testCase name="Mask Formatter mask:Licence plate valid uppercase" duration="1"/>
38
38
  <testCase name="Mask Formatter mask:Licence plate valid lowercase" duration="1"/>
39
- <testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
40
- <testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="0"/>
39
+ <testCase name="Mask Formatter mask:Licence plate invalid" duration="78"/>
40
+ <testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="1"/>
41
41
  <testCase name="Mask Formatter mask:Licence plate invalid for being too short with placeholder" duration="1"/>
42
- <testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
43
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="2"/>
44
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="4"/>
45
- <testCase name="Mask Formatter mask:Licence plate invalid" duration="18"/>
46
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="0"/>
42
+ <testCase name="Mask Formatter mask:Licence plate invalid" duration="3"/>
43
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
44
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
45
+ <testCase name="Mask Formatter mask:Licence plate invalid" duration="2"/>
46
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
47
47
  <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="1"/>
48
48
  <testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
49
49
  <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="0"/>
50
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="1"/>
51
- <testCase name="Mask Formatter mask:Licence plate invalid" duration="65"/>
50
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
51
+ <testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
52
52
  </file>
53
53
  <file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaModel.spec.ts">
54
- <testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="105"/>
55
- <testCase name="StringUtils it should modify &quot;expressions&quot; and &quot;parameters&quot; properties through Setters methods" duration="1"/>
56
- <testCase name="StringUtils it should return &quot;expression&quot; and &quot;parameters&quot; setted through constructor method" duration="1"/>
57
- <testCase name="StringUtils it should return a Criteria class with &quot;expression&quot; and &quot;parameters&quot; as needed setted through &quot;append&quot; method" duration="207"/>
58
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;append&quot; method" duration="82"/>
59
- <testCase name="StringUtils it should return undefined as &quot;expression&quot; and &quot;[]&quot; as parameters as we use an empty criteria as first entry in the constructor" duration="3"/>
54
+ <testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="14"/>
55
+ <testCase name="StringUtils it should modify &quot;expressions&quot; and &quot;parameters&quot; properties through Setters methods" duration="2"/>
56
+ <testCase name="StringUtils it should return &quot;expression&quot; and &quot;parameters&quot; setted through constructor method" duration="2"/>
57
+ <testCase name="StringUtils it should return a Criteria class with &quot;expression&quot; and &quot;parameters&quot; as needed setted through &quot;append&quot; method" duration="87"/>
58
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;append&quot; method" duration="1"/>
59
+ <testCase name="StringUtils it should return undefined as &quot;expression&quot; and &quot;[]&quot; as parameters as we use an empty criteria as first entry in the constructor" duration="1"/>
60
60
  <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="1"/>
61
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="11"/>
62
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="1"/>
63
- <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="3"/>
64
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="0"/>
61
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="0"/>
62
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="0"/>
63
+ <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="91"/>
65
64
  <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="1"/>
66
- <testCase name="StringUtils it should return a toJSON object with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="79"/>
67
- <testCase name="StringUtils it should return a toJSON object with through empty constructor" duration="0"/>
68
- </file>
69
- <file path="/builds/dti/design-system/sankhyacore/test/util/TimeFormatter.spec.ts">
70
- <testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="79"/>
71
- <testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="1"/>
72
- <testCase name="TimeFormatter Case: validateTime" duration="1"/>
65
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="2"/>
66
+ <testCase name="StringUtils it should return a toJSON object with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="1"/>
67
+ <testCase name="StringUtils it should return a toJSON object with through empty constructor" duration="1"/>
73
68
  </file>
74
- <file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
75
- <testCase name="StringUtils stringToNumber" duration="92"/>
76
- <testCase name="StringUtils format" duration="202"/>
77
- <testCase name="StringUtils format without formatnumber parameter" duration="96"/>
78
- <testCase name="StringUtils format without formatnumber parameter" duration="1"/>
79
- <testCase name="StringUtils format round number" duration="2"/>
69
+ <file path="/builds/dti/design-system/sankhyacore/src/dataunit/state/slice/test/RecordsSlice.spec.ts">
70
+ <testCase name="RecordsSlice should return newlines at the end" duration="3"/>
80
71
  </file>
81
72
  <file path="/builds/dti/design-system/sankhyacore/test/util/StringUtils.spec.ts">
82
- <testCase name="StringUtils valor vazio" duration="82"/>
83
- <testCase name="StringUtils valor em branco" duration="0"/>
73
+ <testCase name="StringUtils valor vazio" duration="24"/>
74
+ <testCase name="StringUtils valor em branco" duration="1"/>
84
75
  <testCase name="StringUtils valor null" duration="0"/>
85
- <testCase name="StringUtils valor undefined" duration="1"/>
86
- <testCase name="StringUtils valor 0" duration="0"/>
76
+ <testCase name="StringUtils valor undefined" duration="0"/>
77
+ <testCase name="StringUtils valor 0" duration="1"/>
87
78
  <testCase name="StringUtils com valor" duration="0"/>
88
- <testCase name="StringUtils substitui vogais com acento por vogais sem acento" duration="98"/>
89
- <testCase name="StringUtils should return the original value when called with an object without a toString method" duration="2"/>
79
+ <testCase name="StringUtils substitui vogais com acento por vogais sem acento" duration="3"/>
80
+ <testCase name="StringUtils should return the original value when called with an object without a toString method" duration="70"/>
90
81
  <testCase name="StringUtils should return the original value when called with undefined" duration="1"/>
91
82
  </file>
83
+ <file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
84
+ <testCase name="StringUtils stringToNumber" duration="102"/>
85
+ <testCase name="StringUtils format" duration="199"/>
86
+ <testCase name="StringUtils format without formatnumber parameter" duration="2"/>
87
+ <testCase name="StringUtils format without formatnumber parameter" duration="1"/>
88
+ <testCase name="StringUtils format round number" duration="3"/>
89
+ </file>
90
+ <file path="/builds/dti/design-system/sankhyacore/test/util/TimeFormatter.spec.ts">
91
+ <testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="1"/>
92
+ <testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="0"/>
93
+ <testCase name="TimeFormatter Case: validateTime" duration="1"/>
94
+ </file>
92
95
  <file path="/builds/dti/design-system/sankhyacore/test/util/OverflowWatcher.spec.ts">
93
- <testCase name="OverflowWatcher should initialize with provided parameters" duration="8"/>
96
+ <testCase name="OverflowWatcher should initialize with provided parameters" duration="9"/>
94
97
  <testCase name="OverflowWatcher should disconect ResizeObserver when destroy is called" duration="2"/>
95
- <testCase name="OverflowWatcher Should call callback on forceUpdate" duration="481"/>
96
- <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="100"/>
97
- <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="14"/>
98
- <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="88"/>
99
- <testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="5"/>
100
- <testCase name="OverflowWatcher should ignore elements that can not overflow" duration="95"/>
98
+ <testCase name="OverflowWatcher Should call callback on forceUpdate" duration="292"/>
99
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="26"/>
100
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="99"/>
101
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="78"/>
102
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="4"/>
103
+ <testCase name="OverflowWatcher should ignore elements that can not overflow" duration="97"/>
101
104
  <testCase name="OverflowWatcher Should not call callback on forceUpdate" duration="1"/>
102
105
  </file>
103
- <file path="/builds/dti/design-system/sankhyacore/src/dataunit/state/slice/test/RecordsSlice.spec.ts">
104
- <testCase name="RecordsSlice should return newlines at the end" duration="2"/>
105
- </file>
106
106
  <file path="/builds/dti/design-system/sankhyacore/test/util/DataUnitStorage.spec.ts">
107
- <testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="7"/>
107
+ <testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="72"/>
108
108
  <testCase name="DataUnitStorage get should return the stored DataUnit instance from the DataUnitStorage" duration="0"/>
109
- <testCase name="DataUnitStorage get should return undefined if the DataUnit instance is not found in the DataUnitStorage" duration="1"/>
110
- <testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="0"/>
111
- <testCase name="DataUnitStorage remove should remove the DataUnit instance with the specified name from the DataUnitStorage" duration="73"/>
112
- <testCase name="DataUnitStorage remove should not remove any DataUnit instance if the specified DataUnit instance or name is not found in the DataUnitStorage" duration="1"/>
109
+ <testCase name="DataUnitStorage get should return undefined if the DataUnit instance is not found in the DataUnitStorage" duration="0"/>
110
+ <testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="1"/>
111
+ <testCase name="DataUnitStorage remove should remove the DataUnit instance with the specified name from the DataUnitStorage" duration="1"/>
112
+ <testCase name="DataUnitStorage remove should not remove any DataUnit instance if the specified DataUnit instance or name is not found in the DataUnitStorage" duration="0"/>
113
113
  </file>
114
114
  <file path="/builds/dti/design-system/sankhyacore/src/dataunit/test/DataUnit.spec.ts">
115
- <testCase name="DataUnit should return false when not waiting to reload" duration="3"/>
116
- <testCase name="DataUnit should set waitingToReload to true" duration="1"/>
115
+ <testCase name="DataUnit should return false when not waiting to reload" duration="4"/>
116
+ <testCase name="DataUnit should set waitingToReload to true" duration="0"/>
117
117
  <testCase name="DataUnit should set waitingToReload to false" duration="1"/>
118
- <testCase name="DataUnit should dispatch SAVING_CANCELED action with correct fields and recordId" duration="2"/>
118
+ <testCase name="DataUnit should dispatch SAVING_CANCELED action with correct fields and recordId" duration="4"/>
119
119
  </file>
120
120
  <file path="/builds/dti/design-system/sankhyacore/test/util/ElementIDUtils.spec.ts">
121
- <testCase name="addIDInfo 1 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="86"/>
122
- <testCase name="addIDInfo 2 - should add data-element-id with valid id &quot;brComSankhyaFinCadMovimentacaofinanceira_snkApplication&quot;" duration="3"/>
121
+ <testCase name="addIDInfo 1 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="13"/>
122
+ <testCase name="addIDInfo 2 - should add data-element-id with valid id &quot;brComSankhyaFinCadMovimentacaofinanceira_snkApplication&quot;" duration="2"/>
123
123
  <testCase name="addIDInfo 3 - should add data-element-id with valid id &quot;movFinanceira_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="2"/>
124
124
  <testCase name="addIDInfo 4 - should add data-element-id with valid id &quot;meuID2_snkApplication&quot;" duration="1"/>
125
125
  <testCase name="addIDInfo 5 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="1"/>
126
- <testCase name="addIDInfo 6 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="9"/>
126
+ <testCase name="addIDInfo 6 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="2"/>
127
127
  <testCase name="addIDInfo 7 - should add data-element-id with valid id &quot;componenteNameTest_snkApplication&quot;" duration="1"/>
128
128
  <testCase name="addIDInfo 8 - should add data-element-id with valid id &quot;componentLabel_snkApplication&quot;" duration="1"/>
129
- <testCase name="addIDInfo 9 - should add data-element-id with valid id &quot;dataunitFinanceiro_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="1"/>
130
- <testCase name="addIDInfo 10 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="2"/>
131
- <testCase name="addIDInfo 11 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="2"/>
132
- <testCase name="addIDInfo 12 - should add data-element-id with valid id &quot;dataunitFinanceiro_movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
133
- <testCase name="addIDInfo 13 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="1"/>
134
- <testCase name="addIDInfo 14 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira&quot;" duration="73"/>
129
+ <testCase name="addIDInfo 9 - should add data-element-id with valid id &quot;dataunitFinanceiro_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="2"/>
130
+ <testCase name="addIDInfo 10 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="62"/>
131
+ <testCase name="addIDInfo 11 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="1"/>
132
+ <testCase name="addIDInfo 12 - should add data-element-id with valid id &quot;dataunitFinanceiro_movFinanceira_movimentacaoFinanceira&quot;" duration="2"/>
133
+ <testCase name="addIDInfo 13 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="2"/>
134
+ <testCase name="addIDInfo 14 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira&quot;" duration="1"/>
135
135
  <testCase name="addIDInfo 15 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_snkApplication&quot;" duration="1"/>
136
- <testCase name="addIDInfo 16 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_snkApplication&quot;" duration="1"/>
136
+ <testCase name="addIDInfo 16 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_snkApplication&quot;" duration="8"/>
137
137
  <testCase name="addIDInfo 17 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
138
138
  <testCase name="addIDInfo 18 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
139
139
  <testCase name="addIDInfo 19 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="0"/>
140
- <testCase name="addIDInfo 20 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
141
- <testCase name="addIDInfo 21 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="0"/>
140
+ <testCase name="addIDInfo 20 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="0"/>
141
+ <testCase name="addIDInfo 21 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="2"/>
142
142
  <testCase name="addIDInfo 22 - should add data-element-id with valid id &quot;bancoObrigatorio_movimentacaoFinanceira&quot;" duration="1"/>
143
143
  </file>
144
+ <file path="/builds/dti/design-system/sankhyacore/test/util/ElementUtils.spec.ts">
145
+ <testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="53"/>
146
+ <testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="2"/>
147
+ <testCase name="calcMarginSize should threat values defined as zero" duration="3"/>
148
+ </file>
144
149
  <file path="/builds/dti/design-system/sankhyacore/test/dataunit/formatting/PrettyFormatter.spec.ts">
145
- <testCase name="getFormattedValue should return empty string when value is null" duration="4"/>
150
+ <testCase name="getFormattedValue should return empty string when value is null" duration="5"/>
146
151
  <testCase name="getFormattedValue should return empty string when value is not an array" duration="1"/>
147
152
  <testCase name="getFormattedValue should return empty string when value is an empty array" duration="0"/>
148
153
  <testCase name="getFormattedValue should return file name when value is an array with one file object" duration="1"/>
@@ -152,24 +157,19 @@
152
157
  <testCase name="getFormattedValue should return empty string when value is undefined" duration="0"/>
153
158
  <testCase name="getFormattedValue should return value as string when value is not an object" duration="1"/>
154
159
  <testCase name="getFormattedValue should return value.toString() when value is an object without value property" duration="0"/>
155
- <testCase name="getFormattedValue should handle BOOLEAN type" duration="0"/>
156
- <testCase name="getFormattedValue should format numbers correctly" duration="10"/>
160
+ <testCase name="getFormattedValue should handle BOOLEAN type" duration="1"/>
161
+ <testCase name="getFormattedValue should format numbers correctly" duration="15"/>
157
162
  <testCase name="getFormattedValue should format dates correctly" duration="4"/>
158
- <testCase name="getFormattedValue should format times correctly" duration="1"/>
163
+ <testCase name="getFormattedValue should format times correctly" duration="0"/>
159
164
  <testCase name="getFormattedValue should format datetime correctly" duration="0"/>
160
165
  <testCase name="getFormattedValue should call toString with correct parameters" duration="1"/>
161
- <testCase name="getFormattedValue should handle undefined descriptor gracefully" duration="0"/>
162
- <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and matching option" duration="1"/>
166
+ <testCase name="getFormattedValue should handle undefined descriptor gracefully" duration="1"/>
167
+ <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and matching option" duration="0"/>
163
168
  <testCase name="getFormattedValue should return value with OPTIONSELECTOR and no matching option" duration="0"/>
164
169
  <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and value as object" duration="0"/>
165
170
  <testCase name="getFormattedValue should return empty string with OPTIONSELECTOR and value as null" duration="0"/>
166
- <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and options as JSON string" duration="1"/>
171
+ <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and options as JSON string" duration="0"/>
167
172
  <testCase name="getFormattedValue should return value with OPTIONSELECTOR and options as empty array" duration="0"/>
168
173
  <testCase name="getFormattedValue should format masked values correctly" duration="1"/>
169
174
  </file>
170
- <file path="/builds/dti/design-system/sankhyacore/test/util/ElementUtils.spec.ts">
171
- <testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="29"/>
172
- <testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="1"/>
173
- <testCase name="calcMarginSize should threat values defined as zero" duration="3"/>
174
- </file>
175
175
  </unitTest>
@@ -40,7 +40,7 @@ export default class DataUnit {
40
40
 
41
41
  private _uuid: string;
42
42
  private _name: string;
43
- private _observers: Array<(action: DataUnitAction, options?: DataUnitEventOptions) => void>;
43
+ private _observers: Map<string, (action: DataUnitAction, options?: DataUnitEventOptions) => void>;
44
44
  private _sortingProvider?: SortingProvider;
45
45
  private _filterProviders: Map<string, FilterProvider>;
46
46
  private _stateManager: StateManager;
@@ -81,7 +81,7 @@ export default class DataUnit {
81
81
  SnapshotReducer
82
82
  ]
83
83
  );
84
- this._observers = [];
84
+ this._observers = new Map();
85
85
  this._filterProviders = new Map<string, FilterProvider>();
86
86
  this._sortingProvider = undefined;
87
87
  this._defaultSorting = [];
@@ -119,7 +119,7 @@ export default class DataUnit {
119
119
  public releaseCallbacks(){
120
120
  if(!this._allowReleaseCallbacks) return;
121
121
 
122
- this._observers = [];
122
+ this._observers = new Map();
123
123
  this._filterProviders = new Map<string, FilterProvider>();
124
124
  this._sortingProvider = undefined;
125
125
  this._interceptors = new Map();
@@ -1579,10 +1579,7 @@ export default class DataUnit {
1579
1579
  this._stateManager.process(action);
1580
1580
  this?._parentDataUnit?.dispatchAction(Action.CHILD_CHANGED, { srcAction: action, srcDataUnit: this });
1581
1581
  this._observers.forEach(f => {
1582
- /*
1583
- if some observer throws exceptions,
1584
- should be continued
1585
- */
1582
+ //if some observer throws exceptions, should be continued
1586
1583
  try {
1587
1584
  f(action, options);
1588
1585
  } catch (e) {
@@ -1621,10 +1618,17 @@ export default class DataUnit {
1621
1618
  * Ela vai ser chamada sempre que uma ação for despachada (dispatchAction()).
1622
1619
  *
1623
1620
  * @param observer - Função que recebe como parâmetro as ações que serão monitoradas.
1624
- *
1621
+ * @param uuid - Identificador do observer. Quando não informado, será gerado um identificador aleatório.
1625
1622
  */
1626
- public subscribe(observer: (action: DataUnitAction, options?:DataUnitEventOptions) => void | Promise<void>) {
1627
- this._observers.push(observer);
1623
+ public subscribe(observer: (action: DataUnitAction, options?: DataUnitEventOptions) => void | Promise<void>, uuid?: string): string {
1624
+ if (uuid) {
1625
+ this._observers.set(uuid, observer);
1626
+ } else {
1627
+ uuid = StringUtils.generateUUID();
1628
+ this._observers.set(uuid, observer);
1629
+ }
1630
+
1631
+ return uuid;
1628
1632
  }
1629
1633
 
1630
1634
  /**
@@ -1632,10 +1636,18 @@ export default class DataUnit {
1632
1636
  * Remove um observer existente.
1633
1637
  *
1634
1638
  * @param observer - Observer que se deseja remover.
1635
- *
1639
+ * @param uuid - Identificador do observer. Quando não informado o delete removera com base no equals do observer.
1636
1640
  */
1637
- public unsubscribe(observer: Function) {
1638
- this._observers = this._observers.filter(f => f !== observer);
1641
+ public unsubscribe(observer: Function, uuid?: string) {
1642
+ if (uuid) {
1643
+ this._observers.delete(uuid);
1644
+ } else {
1645
+ this._observers.forEach((valor, chave) => {
1646
+ if (valor == observer) {
1647
+ this._observers.delete(chave);
1648
+ }
1649
+ });
1650
+ }
1639
1651
  }
1640
1652
 
1641
1653
  /**
package/src/index.ts CHANGED
@@ -40,6 +40,8 @@ import { IRepositoryIndex } from "./repository/indexeddb/IRepositoryIndex.js"
40
40
  import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
41
41
  import { KeyboardManager } from "./utils/KeyboardManager/index.js";
42
42
  import { SearchUtils } from "./utils/SearchUtils.js";
43
+ import { ServiceUtils } from "./utils/ServiceUtils.js";
44
+ import { StorageType } from "./utils/CacheManager/index.js";
43
45
  import OverflowWatcher, { OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
44
46
 
45
47
  /*Classes públicas no pacote*/
@@ -108,6 +110,8 @@ export {
108
110
  defaultDataLoader,
109
111
  KeyboardManager,
110
112
  SearchUtils,
113
+ ServiceUtils,
114
+ StorageType,
111
115
  OverflowWatcher,
112
116
  OnOverflowCallBack,
113
117
  OverflowDirection,
@@ -0,0 +1,103 @@
1
+ import { StorageType } from './interfaces/index.js';
2
+
3
+ export * from "./interfaces/index.js";
4
+
5
+ export class CacheManager {
6
+ /**
7
+ * Nome da chave utilizada para armazenar o cache no armazenamento.
8
+ */
9
+ private static readonly storageKey = 'cacheManager';
10
+
11
+ /**
12
+ * Estrutura de armazenamento em memória.
13
+ */
14
+ private static inMemoryCache = new Map<string, any>();
15
+
16
+ /**
17
+ * Recupera ou define o valor no cache.
18
+ *
19
+ * @param key Identificador único para armazenar e recuperar o valor.
20
+ * @param fetchCallback Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
21
+ * @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
22
+ * @returns Uma `Promise` com o valor armazenado ou obtido via `fetchCallback`.
23
+ */
24
+ public static async getOrSet<T>(
25
+ key: string,
26
+ fetchCallback: () => Promise<T>,
27
+ storageType: StorageType = StorageType.IN_MEMORY_CACHE
28
+ ): Promise<T> {
29
+ const cache = this.getCache(storageType);
30
+
31
+ if (cache[key]) {
32
+ return cache[key].data;
33
+ }
34
+
35
+ const data = await fetchCallback();
36
+ cache[key] = { data };
37
+ this.saveCache(cache, storageType);
38
+ return data;
39
+ }
40
+
41
+ /**
42
+ * Remove uma entrada específica do cache.
43
+ *
44
+ * @param key Identificador único da entrada a ser removida.
45
+ * @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
46
+ */
47
+ public static clear(key: string, storageType: StorageType = StorageType.IN_MEMORY_CACHE): void {
48
+ const cache = this.getCache(storageType);
49
+ delete cache[key];
50
+ this.saveCache(cache, storageType);
51
+ }
52
+
53
+ /**
54
+ * Remove todas as entradas do cache.
55
+ *
56
+ * @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
57
+ */
58
+ public static clearAll(storageType: StorageType = StorageType.IN_MEMORY_CACHE): void {
59
+ if (storageType === StorageType.IN_MEMORY_CACHE) {
60
+ this.inMemoryCache.clear();
61
+ } else {
62
+ this.getStorage(storageType).removeItem(this.storageKey);
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Obtém o cache armazenado no armazenamento especificado.
68
+ * @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
69
+ * @returns Um objeto representando o cache armazenado.
70
+ */
71
+ private static getCache(storageType: StorageType): Record<string, any> {
72
+ if (storageType === StorageType.IN_MEMORY_CACHE) {
73
+ return Object.fromEntries(this.inMemoryCache);
74
+ }
75
+
76
+ const storage = this.getStorage(storageType);
77
+ const cache = storage.getItem(this.storageKey);
78
+ return cache ? JSON.parse(cache) : {};
79
+ }
80
+
81
+ /**
82
+ * Salva o cache no armazenamento especificado.
83
+ * @param cache O objeto representando o cache a ser salvo.
84
+ * @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
85
+ */
86
+ private static saveCache(cache: Record<string, any>, storageType: StorageType): void {
87
+ if (storageType === StorageType.IN_MEMORY_CACHE) {
88
+ this.inMemoryCache = new Map(Object.entries(cache));
89
+ } else {
90
+ const storage = this.getStorage(storageType);
91
+ storage.setItem(this.storageKey, JSON.stringify(cache));
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Retorna o armazenamento correspondente ao tipo especificado.
97
+ * @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`.
98
+ * @returns O objeto de armazenamento correspondente.
99
+ */
100
+ private static getStorage(storageType: StorageType): Storage {
101
+ return storageType === StorageType.LOCAL_STORAGE ? localStorage : sessionStorage;
102
+ }
103
+ }
@@ -0,0 +1,5 @@
1
+ export enum StorageType{
2
+ IN_MEMORY_CACHE = 'inMemoryCache',
3
+ SESSION_STORAGE = 'sessionStorage',
4
+ LOCAL_STORAGE = 'localStorage'
5
+ }
@@ -0,0 +1,36 @@
1
+ import { CacheManager } from './CacheManager/index.js';
2
+ import { StorageType } from './CacheManager/interfaces/index.js';
3
+
4
+
5
+ export class ServiceUtils {
6
+
7
+
8
+ /**
9
+ * Auxilia no uso do CacheManager, gerando automaticamente uma chave de cache com base no identificador.
10
+ *
11
+ * @template T Tipo do dado a ser retornado.
12
+ * @param identifier Identificadores únicos usados para compor a chave de cache.
13
+ * @param fetchFunction Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
14
+ * @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`. O padrão é `'sessionStorage'`.
15
+ * @returns Uma `Promise` com o valor armazenado ou obtido via `fetchFunction`.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const actions = await useCacheWithService(
20
+ * `${this.entityName} - ${this.resourceID}`,
21
+ * async () => {
22
+ * return await fetchActionsFromAPI();
23
+ * }
24
+ * );
25
+ * console.log(actions);
26
+ * ```
27
+ */
28
+ public static async useCacheWithService<T>(
29
+ identifier: string,
30
+ fetchFunction: () => Promise<T>,
31
+ storageType: StorageType = StorageType.IN_MEMORY_CACHE
32
+ ): Promise<T> {
33
+ const cacheKey = `${identifier}`;
34
+ return CacheManager.getOrSet(cacheKey, fetchFunction, storageType);
35
+ }
36
+ }