@sankhyalabs/core 0.0.0-bugfix-dev-KB-6165.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/.docs/.nojekyll +1 -0
  2. package/.docs/README.md +63 -0
  3. package/.docs/classes/ApplicationContext.md +90 -0
  4. package/.docs/classes/ArrayUtils.md +99 -0
  5. package/.docs/classes/AuthorizedServiceCaller.md +76 -0
  6. package/.docs/classes/Change.md +190 -0
  7. package/.docs/classes/DataUnit.md +2453 -0
  8. package/.docs/classes/DataUnitAction.md +96 -0
  9. package/.docs/classes/DataUnitStorage.md +116 -0
  10. package/.docs/classes/DateUtils.md +327 -0
  11. package/.docs/classes/ElementIDUtils.md +308 -0
  12. package/.docs/classes/ErrorException.md +214 -0
  13. package/.docs/classes/ErrorTracking.md +62 -0
  14. package/.docs/classes/FloatingManager.md +530 -0
  15. package/.docs/classes/HTMLBuilder.md +45 -0
  16. package/.docs/classes/HttpProvider.md +96 -0
  17. package/.docs/classes/JSUtils.md +115 -0
  18. package/.docs/classes/MaskFormatter-1.md +347 -0
  19. package/.docs/classes/NumberUtils.md +335 -0
  20. package/.docs/classes/ObjectUtils.md +160 -0
  21. package/.docs/classes/OnboardingUtils.md +126 -0
  22. package/.docs/classes/PromiseSync.md +91 -0
  23. package/.docs/classes/ReadyUtil.md +115 -0
  24. package/.docs/classes/RequestMetadata.md +84 -0
  25. package/.docs/classes/SelectionInfo.md +168 -0
  26. package/.docs/classes/SkwHttpProvider.md +109 -0
  27. package/.docs/classes/StringUtils.md +562 -0
  28. package/.docs/classes/TimeFormatter.md +98 -0
  29. package/.docs/classes/UserAgentUtils.md +58 -0
  30. package/.docs/classes/VersionUtils.md +42 -0
  31. package/.docs/classes/WaitingChangeException.md +200 -0
  32. package/.docs/classes/WarningException.md +214 -0
  33. package/.docs/enums/Action.md +294 -0
  34. package/.docs/enums/ChangeOperation.md +52 -0
  35. package/.docs/enums/DataType.md +63 -0
  36. package/.docs/enums/DependencyType.md +41 -0
  37. package/.docs/enums/SelectionMode.md +30 -0
  38. package/.docs/enums/SortMode.md +30 -0
  39. package/.docs/enums/UserInterface.md +195 -0
  40. package/.docs/interfaces/ChildDescriptor.md +41 -0
  41. package/.docs/interfaces/ChildLink.md +30 -0
  42. package/.docs/interfaces/DUActionInterceptor.md +29 -0
  43. package/.docs/interfaces/ExecutionContext.md +58 -0
  44. package/.docs/interfaces/FieldDescriptor.md +140 -0
  45. package/.docs/interfaces/Filter.md +41 -0
  46. package/.docs/interfaces/IElementIDInfo.md +30 -0
  47. package/.docs/interfaces/LoadDataRequest.md +101 -0
  48. package/.docs/interfaces/LoadDataResponse.md +36 -0
  49. package/.docs/interfaces/PageRequest.md +41 -0
  50. package/.docs/interfaces/PaginationInfo.md +75 -0
  51. package/.docs/interfaces/PromiseSyncCallback.md +39 -0
  52. package/.docs/interfaces/QuickFilter.md +41 -0
  53. package/.docs/interfaces/Record.md +62 -0
  54. package/.docs/interfaces/SavedRecord.md +85 -0
  55. package/.docs/interfaces/Sort.md +41 -0
  56. package/.docs/interfaces/SortingProvider.md +29 -0
  57. package/.docs/interfaces/UnitMetadata.md +52 -0
  58. package/.docs/interfaces/WaitingChange.md +41 -0
  59. package/.docs/modules/MaskFormatter.md +37 -0
  60. package/.docs/modules.md +74 -0
  61. package/.docs/package.json +15 -0
  62. package/.eslintignore +2 -0
  63. package/.eslintrc.cjs +35 -0
  64. package/.husky/commit-msg +4 -0
  65. package/.releaserc +58 -0
  66. package/README.md +62 -0
  67. package/commitlint.config.cjs +14 -0
  68. package/dist/async/PromiseSync.d.ts +29 -0
  69. package/dist/async/PromiseSync.js +31 -0
  70. package/dist/async/PromiseSync.js.map +1 -0
  71. package/dist/dataunit/DataUnit.d.ts +924 -0
  72. package/dist/dataunit/DataUnit.js +1621 -0
  73. package/dist/dataunit/DataUnit.js.map +1 -0
  74. package/dist/dataunit/DataUnitStorage.d.ts +24 -0
  75. package/dist/dataunit/DataUnitStorage.js +39 -0
  76. package/dist/dataunit/DataUnitStorage.js.map +1 -0
  77. package/dist/dataunit/formatting/PrettyFormatter.d.ts +2 -0
  78. package/dist/dataunit/formatting/PrettyFormatter.js +94 -0
  79. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -0
  80. package/dist/dataunit/loading/LoadDataRequest.d.ts +19 -0
  81. package/dist/dataunit/loading/LoadDataRequest.js +2 -0
  82. package/dist/dataunit/loading/LoadDataRequest.js.map +1 -0
  83. package/dist/dataunit/loading/LoadDataResponse.d.ts +9 -0
  84. package/dist/dataunit/loading/LoadDataResponse.js +2 -0
  85. package/dist/dataunit/loading/LoadDataResponse.js.map +1 -0
  86. package/dist/dataunit/loading/PaginationInfo.d.ts +13 -0
  87. package/dist/dataunit/loading/PaginationInfo.js +2 -0
  88. package/dist/dataunit/loading/PaginationInfo.js.map +1 -0
  89. package/dist/dataunit/metadata/DataType.d.ts +54 -0
  90. package/dist/dataunit/metadata/DataType.js +124 -0
  91. package/dist/dataunit/metadata/DataType.js.map +1 -0
  92. package/dist/dataunit/metadata/UnitMetadata.d.ts +88 -0
  93. package/dist/dataunit/metadata/UnitMetadata.js +36 -0
  94. package/dist/dataunit/metadata/UnitMetadata.js.map +1 -0
  95. package/dist/dataunit/state/HistReducer.d.ts +10 -0
  96. package/dist/dataunit/state/HistReducer.js +28 -0
  97. package/dist/dataunit/state/HistReducer.js.map +1 -0
  98. package/dist/dataunit/state/StateManager.d.ts +57 -0
  99. package/dist/dataunit/state/StateManager.js +97 -0
  100. package/dist/dataunit/state/StateManager.js.map +1 -0
  101. package/dist/dataunit/state/action/DataUnitAction.d.ts +40 -0
  102. package/dist/dataunit/state/action/DataUnitAction.js +42 -0
  103. package/dist/dataunit/state/action/DataUnitAction.js.map +1 -0
  104. package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +12 -0
  105. package/dist/dataunit/state/slice/AddedRecordsSlice.js +30 -0
  106. package/dist/dataunit/state/slice/AddedRecordsSlice.js.map +1 -0
  107. package/dist/dataunit/state/slice/ChangesSlice.d.ts +13 -0
  108. package/dist/dataunit/state/slice/ChangesSlice.js +105 -0
  109. package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -0
  110. package/dist/dataunit/state/slice/InvalidFieldsSlice.d.ts +10 -0
  111. package/dist/dataunit/state/slice/InvalidFieldsSlice.js +66 -0
  112. package/dist/dataunit/state/slice/InvalidFieldsSlice.js.map +1 -0
  113. package/dist/dataunit/state/slice/LoadingControlSlice.d.ts +19 -0
  114. package/dist/dataunit/state/slice/LoadingControlSlice.js +45 -0
  115. package/dist/dataunit/state/slice/LoadingControlSlice.js.map +1 -0
  116. package/dist/dataunit/state/slice/RecordsSlice.d.ts +11 -0
  117. package/dist/dataunit/state/slice/RecordsSlice.js +62 -0
  118. package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -0
  119. package/dist/dataunit/state/slice/RemovedRecordsSlice.d.ts +9 -0
  120. package/dist/dataunit/state/slice/RemovedRecordsSlice.js +25 -0
  121. package/dist/dataunit/state/slice/RemovedRecordsSlice.js.map +1 -0
  122. package/dist/dataunit/state/slice/SelectionSlice.d.ts +19 -0
  123. package/dist/dataunit/state/slice/SelectionSlice.js +155 -0
  124. package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -0
  125. package/dist/dataunit/state/slice/SnapshotSlice.d.ts +19 -0
  126. package/dist/dataunit/state/slice/SnapshotSlice.js +106 -0
  127. package/dist/dataunit/state/slice/SnapshotSlice.js.map +1 -0
  128. package/dist/dataunit/state/slice/UnitMetadataSlice.d.ts +11 -0
  129. package/dist/dataunit/state/slice/UnitMetadataSlice.js +21 -0
  130. package/dist/dataunit/state/slice/UnitMetadataSlice.js.map +1 -0
  131. package/dist/dataunit/state/slice/WaitingChangesSlice.d.ts +12 -0
  132. package/dist/dataunit/state/slice/WaitingChangesSlice.js +56 -0
  133. package/dist/dataunit/state/slice/WaitingChangesSlice.js.map +1 -0
  134. package/dist/exceptions/ErrorException.d.ts +14 -0
  135. package/dist/exceptions/ErrorException.js +13 -0
  136. package/dist/exceptions/ErrorException.js.map +1 -0
  137. package/dist/exceptions/WaitingChangeException.d.ts +12 -0
  138. package/dist/exceptions/WaitingChangeException.js +12 -0
  139. package/dist/exceptions/WaitingChangeException.js.map +1 -0
  140. package/dist/exceptions/WarningException.d.ts +14 -0
  141. package/dist/exceptions/WarningException.js +13 -0
  142. package/dist/exceptions/WarningException.js.map +1 -0
  143. package/dist/html/HTMLBuilder.d.ts +3 -0
  144. package/dist/html/HTMLBuilder.js +9 -0
  145. package/dist/html/HTMLBuilder.js.map +1 -0
  146. package/dist/http/AuthorizedServiceCaller.d.ts +11 -0
  147. package/dist/http/AuthorizedServiceCaller.js +54 -0
  148. package/dist/http/AuthorizedServiceCaller.js.map +1 -0
  149. package/dist/http/HttpProvider.d.ts +25 -0
  150. package/dist/http/HttpProvider.js +74 -0
  151. package/dist/http/HttpProvider.js.map +1 -0
  152. package/dist/http/RequestMetadata.d.ts +30 -0
  153. package/dist/http/RequestMetadata.js +25 -0
  154. package/dist/http/RequestMetadata.js.map +1 -0
  155. package/dist/http/SkwHttpProvider.d.ts +9 -0
  156. package/dist/http/SkwHttpProvider.js +67 -0
  157. package/dist/http/SkwHttpProvider.js.map +1 -0
  158. package/dist/index.d.ts +34 -0
  159. package/dist/index.js +33 -0
  160. package/dist/index.js.map +1 -0
  161. package/dist/traking/ErrorTraking.d.ts +19 -0
  162. package/dist/traking/ErrorTraking.js +34 -0
  163. package/dist/traking/ErrorTraking.js.map +1 -0
  164. package/dist/ui/FloatingManager.d.ts +164 -0
  165. package/dist/ui/FloatingManager.js +358 -0
  166. package/dist/ui/FloatingManager.js.map +1 -0
  167. package/dist/utils/ApplicationContext.d.ts +26 -0
  168. package/dist/utils/ApplicationContext.js +38 -0
  169. package/dist/utils/ApplicationContext.js.map +1 -0
  170. package/dist/utils/ArrayUtils.d.ts +29 -0
  171. package/dist/utils/ArrayUtils.js +57 -0
  172. package/dist/utils/ArrayUtils.js.map +1 -0
  173. package/dist/utils/CriteriaModel.d.ts +107 -0
  174. package/dist/utils/CriteriaModel.js +172 -0
  175. package/dist/utils/CriteriaModel.js.map +1 -0
  176. package/dist/utils/CriteriaParameter.d.ts +69 -0
  177. package/dist/utils/CriteriaParameter.js +83 -0
  178. package/dist/utils/CriteriaParameter.js.map +1 -0
  179. package/dist/utils/DateUtils.d.ts +97 -0
  180. package/dist/utils/DateUtils.js +171 -0
  181. package/dist/utils/DateUtils.js.map +1 -0
  182. package/dist/utils/ElementIDUtils.d.ts +72 -0
  183. package/dist/utils/ElementIDUtils.js +161 -0
  184. package/dist/utils/ElementIDUtils.js.map +1 -0
  185. package/dist/utils/JSUtils.d.ts +36 -0
  186. package/dist/utils/JSUtils.js +66 -0
  187. package/dist/utils/JSUtils.js.map +1 -0
  188. package/dist/utils/MaskFormatter.d.ts +148 -0
  189. package/dist/utils/MaskFormatter.js +356 -0
  190. package/dist/utils/MaskFormatter.js.map +1 -0
  191. package/dist/utils/NumberUtils.d.ts +127 -0
  192. package/dist/utils/NumberUtils.js +245 -0
  193. package/dist/utils/NumberUtils.js.map +1 -0
  194. package/dist/utils/ObjectUtils.d.ts +47 -0
  195. package/dist/utils/ObjectUtils.js +68 -0
  196. package/dist/utils/ObjectUtils.js.map +1 -0
  197. package/dist/utils/OnboardingUtils.d.ts +17 -0
  198. package/dist/utils/OnboardingUtils.js +41 -0
  199. package/dist/utils/OnboardingUtils.js.map +1 -0
  200. package/dist/utils/ReadyUtil.d.ts +24 -0
  201. package/dist/utils/ReadyUtil.js +41 -0
  202. package/dist/utils/ReadyUtil.js.map +1 -0
  203. package/dist/utils/StringUtils.d.ts +167 -0
  204. package/dist/utils/StringUtils.js +328 -0
  205. package/dist/utils/StringUtils.js.map +1 -0
  206. package/dist/utils/TimeFormatter.d.ts +33 -0
  207. package/dist/utils/TimeFormatter.js +98 -0
  208. package/dist/utils/TimeFormatter.js.map +1 -0
  209. package/dist/utils/UserAgentUtils/index.d.ts +15 -0
  210. package/dist/utils/UserAgentUtils/index.js +48 -0
  211. package/dist/utils/UserAgentUtils/index.js.map +1 -0
  212. package/dist/utils/UserAgentUtils/navigatorAgentList.d.ts +17 -0
  213. package/dist/utils/UserAgentUtils/navigatorAgentList.js +40 -0
  214. package/dist/utils/UserAgentUtils/navigatorAgentList.js.map +1 -0
  215. package/dist/utils/VersionUtils.d.ts +7 -0
  216. package/dist/utils/VersionUtils.js +31 -0
  217. package/dist/utils/VersionUtils.js.map +1 -0
  218. package/jest.config.ts +17 -0
  219. package/mock/http/XMLHttpRequest-mock.js +26 -0
  220. package/package.json +52 -0
  221. package/scripts/runlink.bat +1 -0
  222. package/scripts/runlink.sh +1 -0
  223. package/src/async/PromiseSync.ts +49 -0
  224. package/src/dataunit/DataUnit.ts +1835 -0
  225. package/src/dataunit/DataUnitStorage.ts +43 -0
  226. package/src/dataunit/formatting/PrettyFormatter.ts +113 -0
  227. package/src/dataunit/loading/LoadDataRequest.ts +26 -0
  228. package/src/dataunit/loading/LoadDataResponse.ts +11 -0
  229. package/src/dataunit/loading/PaginationInfo.ts +18 -0
  230. package/src/dataunit/metadata/DataType.ts +127 -0
  231. package/src/dataunit/metadata/UnitMetadata.ts +102 -0
  232. package/src/dataunit/state/HistReducer.ts +34 -0
  233. package/src/dataunit/state/StateManager.ts +142 -0
  234. package/src/dataunit/state/action/DataUnitAction.ts +67 -0
  235. package/src/dataunit/state/slice/AddedRecordsSlice.ts +48 -0
  236. package/src/dataunit/state/slice/ChangesSlice.ts +125 -0
  237. package/src/dataunit/state/slice/InvalidFieldsSlice.ts +85 -0
  238. package/src/dataunit/state/slice/LoadingControlSlice.ts +60 -0
  239. package/src/dataunit/state/slice/RecordsSlice.ts +74 -0
  240. package/src/dataunit/state/slice/RemovedRecordsSlice.ts +30 -0
  241. package/src/dataunit/state/slice/SelectionSlice.ts +193 -0
  242. package/src/dataunit/state/slice/SnapshotSlice.ts +139 -0
  243. package/src/dataunit/state/slice/UnitMetadataSlice.ts +30 -0
  244. package/src/dataunit/state/slice/WaitingChangesSlice.ts +74 -0
  245. package/src/exceptions/ErrorException.ts +25 -0
  246. package/src/exceptions/WaitingChangeException.ts +21 -0
  247. package/src/exceptions/WarningException.ts +26 -0
  248. package/src/html/HTMLBuilder.ts +8 -0
  249. package/src/http/AuthorizedServiceCaller.ts +58 -0
  250. package/src/http/HttpProvider.ts +94 -0
  251. package/src/http/RequestMetadata.ts +42 -0
  252. package/src/http/SkwHttpProvider.ts +78 -0
  253. package/src/index.ts +93 -0
  254. package/src/traking/ErrorTraking.ts +37 -0
  255. package/src/ui/FloatingManager.ts +417 -0
  256. package/src/utils/ApplicationContext.ts +42 -0
  257. package/src/utils/ArrayUtils.ts +61 -0
  258. package/src/utils/CriteriaModel.ts +205 -0
  259. package/src/utils/CriteriaParameter.ts +108 -0
  260. package/src/utils/DateUtils.ts +195 -0
  261. package/src/utils/ElementIDUtils.ts +184 -0
  262. package/src/utils/JSUtils.ts +69 -0
  263. package/src/utils/MaskFormatter.ts +407 -0
  264. package/src/utils/NumberUtils.ts +283 -0
  265. package/src/utils/ObjectUtils.ts +76 -0
  266. package/src/utils/OnboardingUtils.ts +46 -0
  267. package/src/utils/ReadyUtil.ts +45 -0
  268. package/src/utils/StringUtils.ts +359 -0
  269. package/src/utils/TimeFormatter.ts +98 -0
  270. package/src/utils/UserAgentUtils/index.ts +62 -0
  271. package/src/utils/UserAgentUtils/navigatorAgentList.ts +39 -0
  272. package/src/utils/VersionUtils.ts +37 -0
  273. package/test/http/HttpProvider.spec.ts +35 -0
  274. package/test/http/SkwHttpProvider.ts.spec.ts +34 -0
  275. package/test/util/CriteriaModel.spec.ts +232 -0
  276. package/test/util/CriteriaParameter.spec.ts +52 -0
  277. package/test/util/DataUnitStorage.spec.ts +63 -0
  278. package/test/util/ElementIDUtils.spec.ts +272 -0
  279. package/test/util/MaskFormatter.spec.ts +138 -0
  280. package/test/util/NumberUtils.spec.ts +182 -0
  281. package/test/util/StringUtils.spec.ts +51 -0
  282. package/test/util/TimeFormatter.spec.ts +26 -0
  283. package/tsconfig.json +16 -0
@@ -0,0 +1,205 @@
1
+ import { CriteriaParameter, InputCriteria } from './CriteriaParameter.js'
2
+
3
+ interface OutputJSON {
4
+ expression: string | undefined;
5
+ parameters: Array<InputCriteria>;
6
+ }
7
+
8
+ /**
9
+ * `CriteriaParameter`: Utilizado para validar e manipular os critérios da requisição.
10
+ *
11
+ */
12
+ export class Criteria {
13
+
14
+ //Internal Properties
15
+ //================================================================
16
+ private _expression: string | undefined = undefined;
17
+ private _parameters: Array<CriteriaParameter> = [];
18
+
19
+ //Constructor
20
+ //================================================================
21
+ constructor(exp?: string, params?: Array<CriteriaParameter>) {
22
+ this._expression = exp ? exp : undefined;
23
+ this._parameters = params ? params : [];
24
+ }
25
+
26
+ //Getters and Setters
27
+ //================================================================
28
+
29
+ /**
30
+ * @ngdoc
31
+ * @Setter_______________
32
+ * @name sankhyalabs.core.src:Criteria#parameters
33
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
34
+ * @description Setter para "parameters". Trata-se de uma Array de parametros da classe Criteria.
35
+ * @param {Array<CriteriaParameter>} [parameters] Array de parametros da classe Criteria.
36
+ */
37
+ public set parameters(parameters: Array<CriteriaParameter>) {
38
+ this._parameters = parameters;
39
+ }
40
+
41
+ /**
42
+ * @ngdoc
43
+ * @Getter_______________
44
+ * @name sankhyalabs.core.src:Criteria#parameters
45
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
46
+ * @description Getter para parameters
47
+ * @returns {Array<CriteriaParameter>}
48
+ */
49
+ public get parameters(): Array<CriteriaParameter> {
50
+ return this._parameters;
51
+ }
52
+
53
+ /**
54
+ * @ngdoc
55
+ * @Setter_______________
56
+ * @name sankhyalabs.core.src:Criteria#expression
57
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
58
+ * @description Setter para "expression". Trata-se do expressão da classe Criteria.
59
+ * @param {string} [expression] Expressão da classe Criteria.
60
+ */
61
+ public set expression(expression: string | undefined) {
62
+ this._expression = expression;
63
+ }
64
+
65
+ /**
66
+ * @ngdoc
67
+ * @Getter_______________
68
+ * @name sankhyalabs.core.src:Criteria#expression
69
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
70
+ * @description Getter para expression
71
+ * @returns {string} expression em formato string.
72
+ */
73
+ public get expression(): string | undefined {
74
+ return this._expression;
75
+ }
76
+
77
+
78
+
79
+ //Methods
80
+ //================================================================
81
+
82
+ /**
83
+ * @ngdoc
84
+ * @name sankhyalabs.core.src:Criteria#getSize
85
+ * @methodOf sankhyalabs.core.src:Criteria
86
+ * @description Método que retorna o Número de caracteres da expressão da classe Criteria.
87
+ * @returns {number} Número de caracteres da expressão da classe Criteria.
88
+ */
89
+ public getSize = (): number => {
90
+ return this._expression === undefined ? 0 : this._expression.length;
91
+ };
92
+
93
+ /**
94
+ * @ngdoc
95
+ * @name sankhyalabs.core.src:Criteria#or
96
+ * @methodOf sankhyalabs.core.src:Criteria
97
+ * @description Concatena a expressão ' OR ' ao critério.
98
+ * @param {Criteria | string} [exp] Expressão a ser concatenada
99
+ * @param {Array<CriteriaParameter>} [param] Parâmetros a serem concatenados.
100
+ * @returns {Criteria} Retorna a própria instância do Criterio para encadeamento.
101
+ */
102
+ public or = (exp: Criteria | string, param?: Array<CriteriaParameter>): Criteria => {
103
+ if (this.getSize() > 0) {
104
+ this.append(' OR ');
105
+ }
106
+
107
+ this.append(exp, param);
108
+
109
+ return this;
110
+ };
111
+
112
+ /**
113
+ * @ngdoc
114
+ * @name sankhyalabs.core.src:Criteria#and
115
+ * @methodOf sankhyalabs.core.src:Criteria
116
+ * @description Concatena a expressão ' AND ' ao critério.
117
+ * @param {Criteria | string} [exp] Expressão a ser concatenada
118
+ * @param {Array<CriteriaParameter>} [param] Parâmetros a serem concatenados.
119
+ * @returns {Criteria} Retorna a própria instância do Criterio para encadeamento.
120
+ */
121
+ public and = (exp: Criteria | string, param?: Array<CriteriaParameter>): Criteria => {
122
+ if (this.getSize() > 0) {
123
+ this.append(' AND ');
124
+ }
125
+
126
+ this.append(exp, param);
127
+
128
+ return this;
129
+ }
130
+
131
+
132
+ /**
133
+ * @ngdoc
134
+ * @name sankhyalabs.core.src:Criteria#toJSON
135
+ * @methodOf sankhyalabs.core.src:Criteria
136
+ * @description Retorna um JSON que representa o objeto Criteria.
137
+ * @returns {Object} Retorna um JSON que representa o objeto Criteria.
138
+ */
139
+ public toJSON = (): OutputJSON | undefined => {
140
+
141
+ const parametersArray: Array<InputCriteria> = [];
142
+ this.parameters.map(function (param) {
143
+ parametersArray.push(param.buildParam());
144
+ })
145
+
146
+ let result = undefined;
147
+ if (this.getSize() > 0) {
148
+ result = {
149
+ expression: this.expression,
150
+ parameters: parametersArray,
151
+ }
152
+ }
153
+
154
+ return result;
155
+ }
156
+
157
+
158
+ /**
159
+ * @ngdoc
160
+ * @name sankhyalabs.core.src:Criteria#append
161
+ * @methodOf sankhyalabs.core.src:Criteria
162
+ * @description Concatena uma expressão e parâmetros ao critério.
163
+ * @param {string} [exp=undefined] Expressão a ser concatenada
164
+ * @param {array} [param=undefined] Parâmetros a serem concatenados.
165
+ * @returns {Criteria} Retorna a própria instância do Criterio para encadeamento.
166
+ */
167
+ public append(exp: Criteria | string, param?: Array<CriteriaParameter>): Criteria {
168
+
169
+ if (exp instanceof Criteria) {
170
+ if (exp.getSize() > 0) {
171
+ param = exp.parameters
172
+ exp = '(' + exp.expression + ')';
173
+ } else {
174
+ return this;
175
+ }
176
+ }
177
+
178
+ if (this.expression === undefined) {
179
+ this.expression = exp;
180
+ } else {
181
+ this.expression += exp;
182
+ }
183
+
184
+ if (param) { this.addParameter(param); }
185
+
186
+
187
+ return this;
188
+ }
189
+
190
+ /**
191
+ * @ngdoc
192
+ * @name sankhyalabs.core.src:Criteria#addParameter
193
+ * @methodOf sankhyalabs.core.src:Criteria
194
+ * @description Concatena parâmetros ao critério.
195
+ * - Se passado um array, o metodo iterará no array e adicionará cada um dos itens.
196
+ * - É possível passar um Objeto CriteriaParameter, um número, string ou uma instancia de data, eles serão inferidos para o tipo certo.
197
+ * @param {CriteriaParameter} Parâmetro a ser adicionado.
198
+ */
199
+ private addParameter(param: Array<CriteriaParameter>): void {
200
+ for (const index in param) {
201
+ this.parameters.push(param[index]);
202
+ }
203
+ }
204
+
205
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Possible values of CriteriaType
3
+ */
4
+ export enum CriteriaType {
5
+ TYPE_STRING = 'S',
6
+ TYPE_DATE = 'D',
7
+ TYPE_NUMBER = 'N',
8
+ }
9
+
10
+ /**
11
+ * Interface: return of method "buildParam" of CriteriaParameter class
12
+ */
13
+ export interface InputCriteria {
14
+ type: CriteriaType;
15
+ value: any;
16
+ }
17
+
18
+
19
+
20
+ /**
21
+ * CriteriaParameter:
22
+ */
23
+ export class CriteriaParameter {
24
+
25
+ //Internal Properties
26
+ //================================================================
27
+
28
+ private _type: CriteriaType;
29
+ private _value: any;
30
+
31
+ //Constructor
32
+ //================================================================
33
+ constructor(type: CriteriaType, value: any) {
34
+ this._type = type;
35
+ this._value = value;
36
+ }
37
+
38
+ //Getters and Setters
39
+ //================================================================
40
+
41
+ /**
42
+ * @ngdoc
43
+ * @Getter_______________
44
+ * @name sankhyalabs.core.src:CriteriaParameter#value
45
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
46
+ * @description Setter para "value". Trata-se do valor do Parâmetro.
47
+ * @param {any} [value] Valor do Parâmetro.
48
+ * @returns {void}
49
+ */
50
+ public set value(value: any) {
51
+ this._value = value;
52
+ }
53
+
54
+ /**
55
+ * @ngdoc
56
+ * @Setter_______________
57
+ * @name sankhyalabs.core.src:CriteriaParameter#value
58
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
59
+ * @description Getter para "value". Trata-se do valor do Parâmetro.
60
+ * @returns {any} Retorna valor do Parâmetro da classe Criteria
61
+ */
62
+ public get value(): any {
63
+ return this._value;
64
+ }
65
+
66
+
67
+ /**
68
+ * @ngdoc
69
+ * @Getter_______________
70
+ * @name sankhyalabs.core.src:CriteriaParameter#type
71
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
72
+ * @description Setter para "type". Trata-se do tipo do valor do Parâmetro.
73
+ * @param {CriteriaType} [type] Tipo do valor do Parâmetro.
74
+ * @returns {void}
75
+ */
76
+ public set type(type: CriteriaType) {
77
+ this._type = type;
78
+ }
79
+
80
+ /**
81
+ * @ngdoc
82
+ * @Setter_______________
83
+ * @name sankhyalabs.core.src:CriteriaParameter#type
84
+ * @methodOf sankhyalabs.core.src:CriteriaProvider
85
+ * @description Getter para "type". Trata-se do valor do Parâmetro.
86
+ * @returns {CriteriaType} Retorna o tipo do Parâmetro da classe Criteria
87
+ */
88
+ public get type(): CriteriaType {
89
+ return this._type;
90
+ }
91
+
92
+
93
+ /**
94
+ * @sankhyalabscore
95
+ * @name sankhyalabs.core.src:CriteriaParameter#buildParam
96
+ * @methodOf sankhyalabscore src.utils.CriteriaParameter
97
+ * @description Cria um JSON/Objeto de acordo com as propriedades internas "value" e "type" da classe CriteriaParameter
98
+ * @returns {InputCriteria} Retorna JSON/Objeto no formato InputCriteria.
99
+ */
100
+ public buildParam = (): InputCriteria => {
101
+ const paramObj = {
102
+ type: this._type,
103
+ value: this._value,
104
+ }
105
+ return paramObj;
106
+ }
107
+
108
+ }
@@ -0,0 +1,195 @@
1
+ import { number } from "yargs";
2
+
3
+ /**
4
+ * `DateUtils`: Utilizado para formatação, padronização e cálculos de datas.
5
+ */
6
+ export default class DateUtils{
7
+
8
+ /**
9
+ * Zerar o horário de uma data.
10
+ *
11
+ * @param date - Data a ser manipulada.
12
+ * @param adjustDayLightSavingTime - Ajusta horário de verão na data recebida.
13
+ * @returns - Data sem as informações de horário.
14
+ * @example
15
+ * Informo: 2023-03-09 12:42:40 | Obtenho: 2023-03-09 00:00:00
16
+ */
17
+ public static clearTime(date:Date, adjustDayLightSavingTime:boolean = true): Date {
18
+ const newDate: Date = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0, 0);
19
+ return adjustDayLightSavingTime ? DateUtils.adjustDLST(newDate) : newDate;
20
+ }
21
+
22
+ /**
23
+ * Converte data para uma string no formato pt-BR.
24
+ *
25
+ * @param date - Data a ser convertida.
26
+ * @param options - Opções de formatação da data.
27
+ * @returns - Uma string com a data no formato pt-BR DD/MM/YYYY.
28
+ */
29
+ public static formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string{
30
+ return date ? new Intl.DateTimeFormat("pt-BR", options ?? {}).format(date) : "";
31
+ }
32
+
33
+ /**
34
+ * Converte as horas de uma data para uma string pt-BR.
35
+ *
36
+ * @param date - Data a ser convertida.
37
+ * @param showSeconds - define se devemos considerar os segundos.
38
+ * @returns - Uma string com as horas no formato HH:MM ou HH:MM:SS.
39
+ */
40
+ public static formatTime(date: Date, showSeconds: boolean = false): string{
41
+ const timeOptions:Intl.DateTimeFormatOptions = {hour: "2-digit", minute: "2-digit", second: showSeconds ? "2-digit" : undefined};
42
+ return new Intl.DateTimeFormat("pt-BR", timeOptions).format(date);
43
+ }
44
+
45
+ /**
46
+ * Converte a data e hora para uma string no formato pt-BR.
47
+ *
48
+ * @param date - Data a ser convertida.
49
+ * @param showSeconds - define se devemos considerar os segundos.
50
+ * @returns - Uma string com as horas no formato DD/MM/YYYY HH:MM ou DD/MM/YYYY HH:MM:SS.
51
+ */
52
+ public static formatDateTime(date: Date, showSeconds: boolean = false): string{
53
+ return `${DateUtils.formatDate(date)} ${DateUtils.formatTime(date, showSeconds)}`;
54
+ }
55
+
56
+ /**
57
+ * Converte String para Date.
58
+ *
59
+ * @param strValue - Texto a ser convertido para data.
60
+ * @param adjustDayLightSavingTime - Se verdadeiro, ativa regra de horário de verão.
61
+ * @param monthYearMode - Quando ativado, retorna o primeiro dia do mês apenas para construir a data.
62
+ * @returns - Data sem as informações de horário.
63
+ */
64
+ public static strToDate(strValue:string, adjustDayLightSavingTime:boolean = true, monthYearMode:boolean = false): Date | undefined {
65
+ /** monthYearMode é um booleano para usar o formato MM/YYYY.
66
+ * Quando ativado, é retornado o primeiro dia do mês apenas para construir a data.
67
+ * Não há necessidade de verificar o horário de verão quando utilizado esse modo. */
68
+
69
+ let parts;
70
+
71
+ if (monthYearMode) {
72
+ parts = /^(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
73
+ }else {
74
+ parts = /^(3[01]|[1-2]\d|0[1-9]|[1-9])[^\d]?(1[0-2]|0[1-9]|[1-9])[^\d]?(\d{2}|\d{4})(?:\s(\d{1,2}):(\d{1,2}):?(\d{0,2}))?$/.exec(strValue);
75
+ }
76
+ if (!parts) {
77
+ return undefined;
78
+ }
79
+
80
+ const day:number = monthYearMode ? 1 : Number(parts[1]);
81
+ const month:number = Number(parts[(monthYearMode ? 1 : 2)]);
82
+ let year:number = Number(parts[(monthYearMode ? 2 : 3)]);
83
+ const hour:number = Number(parts[(monthYearMode ? 3 : 4 )] || 0);
84
+ const min:number = Number(parts[(monthYearMode ? 4 : 5 )] || 0);
85
+ const sec:number = Number(parts[(monthYearMode ? 5 : 6 )] || 0);
86
+
87
+ if (year < 100) {
88
+ year += year < 30 ? 2000 : 1900;
89
+ }
90
+
91
+ let date: Date = new Date(year, month - 1, day, hour, min, sec, 0);
92
+
93
+ if (adjustDayLightSavingTime === true && !monthYearMode && hour == 0) {
94
+ date = DateUtils.adjustDLST(date);
95
+ }
96
+
97
+ return date;
98
+ }
99
+
100
+ /**
101
+ * Obtém a data atual.
102
+ *
103
+ * @param withTime - Caso true retorna a data com informações de horário.
104
+ * @returns - Data atual sem informação de horário.
105
+ */
106
+ public static getToday(withTime: boolean = false): Date {
107
+ const today = new Date();
108
+
109
+ if (withTime) {
110
+ return today;
111
+ } else {
112
+ return DateUtils.clearTime(today);
113
+ }
114
+ }
115
+
116
+ /**
117
+ * Retorna se a data é válida.
118
+ *
119
+ * @param value - Data a ser validada.
120
+ * @param hasTime - Determina se a data retornada deve conter informação de horário ou não. Por padrão não retorna a hora.
121
+ * @returns - Caso válida, retorna a própria data.
122
+ */
123
+ public static validateDate(value: Date, hasTime: boolean = false): Date | undefined {
124
+ return value instanceof Date && !isNaN(value.valueOf())
125
+ ? hasTime ? value : DateUtils.clearTime(value)
126
+ : undefined;
127
+ }
128
+
129
+ /**
130
+ * Realiza correção do horário de verão.
131
+ *
132
+ * @param date - Data a ser ajustada.
133
+ * @returns - Data informada ajustada para horário de verão.
134
+ */
135
+ private static adjustDLST(date:Date): Date {
136
+
137
+ if(date.getHours() == 23){
138
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1, 1, 0, 0, 0);
139
+ }
140
+
141
+ return date;
142
+ }
143
+
144
+ /**
145
+ * Adiciona uma casa decimal a esquerda de uma unidade.
146
+ *
147
+ * @param n - Número a ser ajustado
148
+ * @returns - O número informado, com uma casa decimal a esquerda.
149
+ * @example
150
+ * Informo: 15 | Obtenho: 15
151
+ * @example
152
+ * Informo: 2 | Obtenho: "02"
153
+ */
154
+ private static pad(n: number): string | number {
155
+ return n < 10 ? "0" + n : n;
156
+ }
157
+
158
+ /**
159
+ * Retorna timezone da data.
160
+ *
161
+ * @param offset - Valor do timezone desejado.
162
+ * @returns Timezone da data.
163
+ */
164
+ private static timezoneOffset(offset: number): string {
165
+ let sign;
166
+
167
+ if (offset === 0) {
168
+ return "Z";
169
+ }
170
+
171
+ sign = (offset > 0) ? "-" : "+";
172
+ offset = Math.abs(offset);
173
+
174
+ return sign + this.pad(Math.floor(offset / 60)) + ":" + this.pad(offset % 60);
175
+ }
176
+
177
+ /**
178
+ * Converte a data para o formato RFC3339.
179
+ *
180
+ * @param date - Data a ser convertida
181
+ * @returns - Data informada no formato RFC3339.
182
+ * * @example
183
+ * Informo: 2023-03-09 12:42:40 | Obtenho: 2023-03-09T12:42:47-03:00
184
+ */
185
+ public static formatRfc3339(date: Date): string {
186
+
187
+ return date.getFullYear() + "-" +
188
+ this.pad(date.getMonth() + 1) + "-" +
189
+ this.pad(date.getDate()) + "T" +
190
+ this.pad(date.getHours()) + ":" +
191
+ this.pad(date.getMinutes()) + ":" +
192
+ this.pad(date.getSeconds()) +
193
+ this.timezoneOffset(date.getTimezoneOffset());
194
+ }
195
+ }
@@ -0,0 +1,184 @@
1
+
2
+ import { StringUtils } from "./StringUtils.js";
3
+ import DataUnit from "../dataunit/DataUnit.js";
4
+
5
+ export interface IElementIDInfo {
6
+ id?: string,
7
+ dataUnit?: DataUnit
8
+ }
9
+ /**
10
+ * `ElementIDUtils`: O ElementIDUtils é um utilitário responsável por criar e adicionar identificadores únicos aos componentes através do atributo data-element-id.
11
+ * A finalidade dele é otimizar a automação dos testes e melhorar a eficiência na manipulação dos componentes do Design System, garantindo seleções precisas e seguras.
12
+ */
13
+ export class ElementIDUtils {
14
+ public static DATA_ELEMENT_ID_ATTRIBUTE_NAME: string = "data-element-id";
15
+ public static INTERNAL_INPUT_NAME: string = "embedded";
16
+ private static REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
17
+
18
+ /**
19
+ * Cria e adiciona a propriedade `data-element-id` em um elemento.
20
+ *
21
+ * @param element - Elemento HTML a ser modificado (HTMLElement).
22
+ * @param suffix - Sufixo/Texto para ser adicionado.
23
+ * @param iDInfo - ID para ser adicionado.
24
+ * @returns - O data-element-id gerado.
25
+ */
26
+ public static addIDInfo(element: HTMLElement, suffix?: string, iDInfo?: IElementIDInfo): string {
27
+ try{
28
+ let dataElementID = this.getDataElementID(element, suffix, iDInfo);
29
+ dataElementID = StringUtils.replaceAccentuatedChars(dataElementID, false);
30
+ dataElementID = this.addPrefix(iDInfo, dataElementID);
31
+ element.setAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME, dataElementID);
32
+ return dataElementID;
33
+ }catch(e){
34
+ console.warn(`Erro ao gerar data-element-id: ${element.tagName}`, e);
35
+ }
36
+ return "";
37
+ }
38
+
39
+ public static addIDInfoIfNotExists(element: HTMLElement, suffix?: string, iDInfo?: IElementIDInfo): string {
40
+ try{
41
+ let dataElementID = element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
42
+
43
+ if(dataElementID == undefined){
44
+ dataElementID = ElementIDUtils.addIDInfo(element, suffix, iDInfo)
45
+ }
46
+
47
+ return dataElementID;
48
+ }catch(e){
49
+ console.warn(`Erro ao gerar data-element-id: ${element.tagName}`, e);
50
+ }
51
+ return "";
52
+ }
53
+
54
+ public static getInternalIDInfo(sufix: string){
55
+ return `${ElementIDUtils.INTERNAL_INPUT_NAME}_${sufix}`;
56
+ }
57
+
58
+ /**
59
+ * Obtém o `data-element-id` do elemento com adição do sufixo e ID.
60
+ *
61
+ * @param element - Elemento HTML a ser modificado (HTMLElement).
62
+ * @param suffix - Sufixo/Texto para ser adicionado.
63
+ * @param iDInfo - ID para ser adicionado.
64
+ * @returns - Atributo `data-element-id` do elemento modificado com sufixo e/ou ID.
65
+ */
66
+ private static getDataElementID(element: HTMLElement, suffix?: string, iDInfo?: IElementIDInfo) {
67
+ let dataElementID = ElementIDUtils.getDataElementIDAttribute(element);
68
+ if(dataElementID != null){
69
+ return this.addSuffix(StringUtils.toCamelCase((dataElementID as string)), suffix, element);
70
+ }
71
+
72
+ const validAttribute = this.getAttributeValid(element, iDInfo);
73
+
74
+ if(validAttribute) return this.addSuffix(validAttribute, suffix, element);
75
+ if(suffix) return String(suffix);
76
+
77
+ let tagName = StringUtils.toCamelCase(element.tagName);
78
+ element.setAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME, tagName);
79
+
80
+ return tagName;
81
+ }
82
+
83
+ /**
84
+ * Obtém ID válido para o elemento.
85
+ *
86
+ * @param element - Elemento HTML a ser modificado (HTMLElement).
87
+ * @param iDInfo - ID para ser adicionado.
88
+ * @returns - ID para ser adicionado ao elemento conforme ordem de prioridade.
89
+ */
90
+ private static getAttributeValid(element: HTMLElement, iDInfo?: IElementIDInfo): string | null{
91
+ if(iDInfo?.id){
92
+ return this.formatDescription(iDInfo?.id);
93
+ }
94
+
95
+ if(element.hasAttribute("data-field-name")){
96
+ return StringUtils.toCamelCase(element.getAttribute("data-field-name") as string);
97
+ }
98
+
99
+ if(element?.id){
100
+ return StringUtils.toCamelCase(element?.id);
101
+ }
102
+
103
+ if(element.hasAttribute("name")){
104
+ return this.formatDescription(element.getAttribute("name"));
105
+ }
106
+
107
+ if(element.hasAttribute("label")){
108
+ return this.formatDescription(element.getAttribute("label"));
109
+ }
110
+
111
+ if(element.hasAttribute("title")){
112
+ return this.formatDescription(element.getAttribute("title"));
113
+ }
114
+
115
+ return null;
116
+ }
117
+
118
+ /**
119
+ * Adiciona sufixo ao atributo `data-element-id` de um elemento, utilizado para montar a hierarquia dos ids dos componentes em tela.
120
+ *
121
+ * @param dataElementID - ID para ser adicionado ao `data-element-id`.
122
+ * @param suffix - Sufixo/Texto para ser adicionado ao `data-element-id`.
123
+ * @param element - Elemento HTML a ser modificado (HTMLElement).
124
+ * @returns - `data-element-id` com sufixo.
125
+ *
126
+ * @example
127
+ * Um ez-combo-box tem data-element-id = codparc_input_embedded_combo.
128
+ * Dentro desse ez-combo-box existe um ez-text-input. O data-element-id teria como sufixo o id 'codparc_input_embedded_combo' referente ao seu pai.
129
+ */
130
+ private static addSuffix(dataElementID: string | null, suffix: string | undefined, element: HTMLElement): string{
131
+ if(suffix){
132
+ return `${dataElementID}_${StringUtils.toCamelCase(suffix)}`;
133
+ }
134
+ if(StringUtils.isEmpty(dataElementID)){
135
+ return `${StringUtils.toCamelCase(element.tagName)}`;
136
+ }
137
+ return `${dataElementID}_${StringUtils.toCamelCase(element.tagName)}`;
138
+ }
139
+
140
+ /**
141
+ * Adiciona a propriedade name do DataUnit como prefixo do data-element-id do elemento.
142
+ *
143
+ * @param iDInfo - ID para ser adicionado ao `data-element-id`.
144
+ * @param dataElementID - Sufixo/Texto para ser adicionado ao `data-element-id`.
145
+ * @returns - String contendo informação para ser usada no `data-element-id` do elemento.
146
+ */
147
+ private static addPrefix(iDInfo: IElementIDInfo | undefined, dataElementID: string): string {
148
+ let dataUnitName: string = iDInfo?.dataUnit?.name || "";
149
+ dataUnitName = this.parseDataUnitName(dataUnitName);
150
+ if (iDInfo?.dataUnit && !dataElementID?.startsWith(dataUnitName)) {
151
+ dataElementID = `${StringUtils.toCamelCase(dataUnitName)}_${dataElementID}`
152
+ }
153
+ return dataElementID;
154
+ }
155
+
156
+ /**
157
+ * Remove caracteres especiais.
158
+ *
159
+ * @param value - Texto que terá os caracteres especiais removidos.
160
+ * @returns - Retorna a string sem caracteres especiais e em camelCase.
161
+ */
162
+ private static formatDescription(value: string | null): string{
163
+ if(!value) return "";
164
+ value = StringUtils.replaceAccentuatedChars(value, false);
165
+ return StringUtils.toCamelCase((value.replace(/[^\w\sÀ-ÖØ-öø-ÿ]/gi, " ")).replace(/\s+/g, ' ').trim());
166
+ }
167
+
168
+ private static getDataElementIDAttribute(element: HTMLElement): string | null {
169
+ if((element as any)[ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME] || element.hasAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME)) {
170
+ return (element as any)[ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME] || element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
171
+ }
172
+ return null;
173
+ }
174
+
175
+ private static parseDataUnitName(uri:string):string{
176
+ if(StringUtils.isEmpty(uri)){
177
+ return uri;
178
+ }
179
+
180
+ const matcher:RegExpExecArray|null = this.REGEX_DATAUNIT_NAME.exec(uri);
181
+ return matcher?.[1] ?? uri;
182
+ }
183
+
184
+ }