cmat 0.0.111 → 0.0.112

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 (256) hide show
  1. package/fesm2022/cmat-components-adapter.mjs +531 -536
  2. package/fesm2022/cmat-components-adapter.mjs.map +1 -1
  3. package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
  4. package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
  5. package/fesm2022/cmat-components-card.mjs +150 -42
  6. package/fesm2022/cmat-components-card.mjs.map +1 -1
  7. package/fesm2022/cmat-components-carousel.mjs +1120 -629
  8. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  9. package/fesm2022/cmat-components-cascade.mjs +861 -441
  10. package/fesm2022/cmat-components-cascade.mjs.map +1 -1
  11. package/fesm2022/cmat-components-chip-input.mjs +580 -335
  12. package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
  13. package/fesm2022/cmat-components-code-editor.mjs +197 -105
  14. package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
  15. package/fesm2022/cmat-components-color-picker.mjs +1762 -825
  16. package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
  17. package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
  18. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  19. package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
  20. package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
  21. package/fesm2022/cmat-components-date-range.mjs +701 -456
  22. package/fesm2022/cmat-components-date-range.mjs.map +1 -1
  23. package/fesm2022/cmat-components-date-time-display.mjs +137 -30
  24. package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
  25. package/fesm2022/cmat-components-drawer.mjs +410 -258
  26. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  27. package/fesm2022/cmat-components-empty-state.mjs +201 -41
  28. package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
  29. package/fesm2022/cmat-components-file-preview.mjs +198 -35
  30. package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
  31. package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
  32. package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
  33. package/fesm2022/cmat-components-form-actions.mjs +102 -26
  34. package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
  35. package/fesm2022/cmat-components-fullscreen.mjs +167 -47
  36. package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
  37. package/fesm2022/cmat-components-highlight.mjs +203 -112
  38. package/fesm2022/cmat-components-highlight.mjs.map +1 -1
  39. package/fesm2022/cmat-components-image-viewer.mjs +489 -215
  40. package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
  41. package/fesm2022/cmat-components-inline-loading.mjs +117 -27
  42. package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
  43. package/fesm2022/cmat-components-json-editor.mjs +276 -230
  44. package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
  45. package/fesm2022/cmat-components-knob-input.mjs +615 -420
  46. package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
  47. package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
  48. package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
  49. package/fesm2022/cmat-components-masonry.mjs +120 -40
  50. package/fesm2022/cmat-components-masonry.mjs.map +1 -1
  51. package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
  52. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  53. package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
  54. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  55. package/fesm2022/cmat-components-navigation.mjs +3080 -1404
  56. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  57. package/fesm2022/cmat-components-opt-input.mjs +540 -466
  58. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  59. package/fesm2022/cmat-components-org-chart.mjs +528 -125
  60. package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
  61. package/fesm2022/cmat-components-page-header.mjs +141 -32
  62. package/fesm2022/cmat-components-page-header.mjs.map +1 -1
  63. package/fesm2022/cmat-components-pagination.mjs +866 -534
  64. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  65. package/fesm2022/cmat-components-password-strength.mjs +873 -434
  66. package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
  67. package/fesm2022/cmat-components-popover.mjs +1012 -731
  68. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  69. package/fesm2022/cmat-components-progress-bar.mjs +98 -35
  70. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  71. package/fesm2022/cmat-components-qrcode.mjs +463 -287
  72. package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
  73. package/fesm2022/cmat-components-rating.mjs +377 -203
  74. package/fesm2022/cmat-components-rating.mjs.map +1 -1
  75. package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
  76. package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
  77. package/fesm2022/cmat-components-select-search.mjs +926 -496
  78. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  79. package/fesm2022/cmat-components-select-table.mjs +1280 -842
  80. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  81. package/fesm2022/cmat-components-select-tree.mjs +998 -690
  82. package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
  83. package/fesm2022/cmat-components-skeleton.mjs +143 -57
  84. package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
  85. package/fesm2022/cmat-components-speed-dial.mjs +457 -303
  86. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  87. package/fesm2022/cmat-components-status-tag.mjs +136 -44
  88. package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
  89. package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
  90. package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
  91. package/fesm2022/cmat-components-timeline.mjs +464 -168
  92. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  93. package/fesm2022/cmat-components-toast.mjs +346 -262
  94. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  95. package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
  96. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  97. package/fesm2022/cmat-components-treetable.mjs +372 -112
  98. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  99. package/fesm2022/cmat-components-upload.mjs +904 -410
  100. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  101. package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
  102. package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
  103. package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
  104. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  105. package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
  106. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  107. package/fesm2022/cmat-directives-autofocus.mjs +43 -25
  108. package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
  109. package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
  110. package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
  111. package/fesm2022/cmat-directives-debounce.mjs +162 -76
  112. package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
  113. package/fesm2022/cmat-directives-digit-only.mjs +457 -356
  114. package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
  115. package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
  116. package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
  117. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
  118. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
  119. package/fesm2022/cmat-lib-mock-api.mjs +207 -195
  120. package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
  121. package/fesm2022/cmat-pipes-bytes.mjs +50 -30
  122. package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
  123. package/fesm2022/cmat-pipes-date-format.mjs +41 -25
  124. package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
  125. package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
  126. package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
  127. package/fesm2022/cmat-pipes-group-by.mjs +50 -38
  128. package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
  129. package/fesm2022/cmat-pipes-keys.mjs +44 -31
  130. package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
  131. package/fesm2022/cmat-pipes-secure.mjs +60 -49
  132. package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
  133. package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
  134. package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
  135. package/fesm2022/cmat-reports.mjs +2751 -0
  136. package/fesm2022/cmat-reports.mjs.map +1 -0
  137. package/fesm2022/cmat-services-alert.mjs +249 -277
  138. package/fesm2022/cmat-services-alert.mjs.map +1 -1
  139. package/fesm2022/cmat-services-config.mjs +110 -81
  140. package/fesm2022/cmat-services-config.mjs.map +1 -1
  141. package/fesm2022/cmat-services-confirmation.mjs +184 -73
  142. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  143. package/fesm2022/cmat-services-data.mjs +136 -125
  144. package/fesm2022/cmat-services-data.mjs.map +1 -1
  145. package/fesm2022/cmat-services-export-as.mjs +165 -183
  146. package/fesm2022/cmat-services-export-as.mjs.map +1 -1
  147. package/fesm2022/cmat-services-loading.mjs +116 -95
  148. package/fesm2022/cmat-services-loading.mjs.map +1 -1
  149. package/fesm2022/cmat-services-local-storage.mjs +75 -66
  150. package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
  151. package/fesm2022/cmat-services-media-watcher.mjs +69 -64
  152. package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
  153. package/fesm2022/cmat-services-platform.mjs +48 -45
  154. package/fesm2022/cmat-services-platform.mjs.map +1 -1
  155. package/fesm2022/cmat-services-print.mjs +984 -1109
  156. package/fesm2022/cmat-services-print.mjs.map +1 -1
  157. package/fesm2022/cmat-services-splash-screen.mjs +53 -38
  158. package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
  159. package/fesm2022/cmat-services-title.mjs +57 -47
  160. package/fesm2022/cmat-services-title.mjs.map +1 -1
  161. package/fesm2022/cmat-services-translation.mjs +79 -68
  162. package/fesm2022/cmat-services-translation.mjs.map +1 -1
  163. package/fesm2022/cmat-services-utils.mjs +424 -517
  164. package/fesm2022/cmat-services-utils.mjs.map +1 -1
  165. package/fesm2022/cmat-validators.mjs +23 -33
  166. package/fesm2022/cmat-validators.mjs.map +1 -1
  167. package/fesm2022/cmat-version.mjs +12 -16
  168. package/fesm2022/cmat-version.mjs.map +1 -1
  169. package/fesm2022/cmat.mjs +39805 -22511
  170. package/fesm2022/cmat.mjs.map +1 -1
  171. package/package.json +5 -1
  172. package/types/cmat-components-adapter.d.ts +145 -156
  173. package/types/cmat-components-breadcrumb.d.ts +108 -86
  174. package/types/cmat-components-card.d.ts +34 -18
  175. package/types/cmat-components-carousel.d.ts +251 -134
  176. package/types/cmat-components-cascade.d.ts +158 -117
  177. package/types/cmat-components-chip-input.d.ts +105 -71
  178. package/types/cmat-components-code-editor.d.ts +59 -34
  179. package/types/cmat-components-color-picker.d.ts +378 -236
  180. package/types/cmat-components-custom-formly.d.ts +776 -814
  181. package/types/cmat-components-data-picker.d.ts +502 -360
  182. package/types/cmat-components-date-range.d.ts +106 -77
  183. package/types/cmat-components-date-time-display.d.ts +36 -13
  184. package/types/cmat-components-drawer.d.ts +91 -61
  185. package/types/cmat-components-empty-state.d.ts +47 -17
  186. package/types/cmat-components-file-preview.d.ts +42 -14
  187. package/types/cmat-components-filter-toolbar.d.ts +57 -25
  188. package/types/cmat-components-form-actions.d.ts +18 -10
  189. package/types/cmat-components-fullscreen.d.ts +21 -13
  190. package/types/cmat-components-highlight.d.ts +33 -26
  191. package/types/cmat-components-image-viewer.d.ts +119 -58
  192. package/types/cmat-components-inline-loading.d.ts +24 -11
  193. package/types/cmat-components-json-editor.d.ts +39 -28
  194. package/types/cmat-components-knob-input.d.ts +172 -101
  195. package/types/cmat-components-loading-overlay.d.ts +8 -11
  196. package/types/cmat-components-masonry.d.ts +27 -14
  197. package/types/cmat-components-material-color-picker.d.ts +56 -42
  198. package/types/cmat-components-material-datetimepicker.d.ts +817 -454
  199. package/types/cmat-components-navigation.d.ts +295 -221
  200. package/types/cmat-components-opt-input.d.ts +111 -90
  201. package/types/cmat-components-org-chart.d.ts +53 -35
  202. package/types/cmat-components-page-header.d.ts +37 -14
  203. package/types/cmat-components-pagination.d.ts +144 -107
  204. package/types/cmat-components-password-strength.d.ts +197 -86
  205. package/types/cmat-components-popover.d.ts +264 -166
  206. package/types/cmat-components-progress-bar.d.ts +17 -14
  207. package/types/cmat-components-qrcode.d.ts +111 -42
  208. package/types/cmat-components-rating.d.ts +105 -59
  209. package/types/cmat-components-rich-text-editor.d.ts +39 -16
  210. package/types/cmat-components-select-search.d.ts +195 -99
  211. package/types/cmat-components-select-table.d.ts +241 -142
  212. package/types/cmat-components-select-tree.d.ts +185 -118
  213. package/types/cmat-components-skeleton.d.ts +55 -32
  214. package/types/cmat-components-speed-dial.d.ts +86 -61
  215. package/types/cmat-components-status-tag.d.ts +42 -24
  216. package/types/cmat-components-table-toolbar.d.ts +30 -12
  217. package/types/cmat-components-timeline.d.ts +83 -51
  218. package/types/cmat-components-toast.d.ts +84 -85
  219. package/types/cmat-components-transfer-picker.d.ts +228 -181
  220. package/types/cmat-components-treetable.d.ts +63 -39
  221. package/types/cmat-components-upload.d.ts +205 -106
  222. package/types/cmat-components-x6-angular-shape.d.ts +29 -37
  223. package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
  224. package/types/cmat-directives-arrow-cursor.d.ts +55 -35
  225. package/types/cmat-directives-autofocus.d.ts +8 -11
  226. package/types/cmat-directives-data-exporter.d.ts +71 -40
  227. package/types/cmat-directives-debounce.d.ts +31 -28
  228. package/types/cmat-directives-digit-only.d.ts +90 -53
  229. package/types/cmat-directives-equal-validator.d.ts +11 -14
  230. package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
  231. package/types/cmat-lib-mock-api.d.ts +46 -55
  232. package/types/cmat-pipes-bytes.d.ts +7 -10
  233. package/types/cmat-pipes-date-format.d.ts +7 -10
  234. package/types/cmat-pipes-find-by-key.d.ts +8 -12
  235. package/types/cmat-pipes-group-by.d.ts +11 -15
  236. package/types/cmat-pipes-keys.d.ts +10 -13
  237. package/types/cmat-pipes-secure.d.ts +14 -17
  238. package/types/cmat-pipes-uppercase.d.ts +7 -10
  239. package/types/cmat-reports.d.ts +1131 -0
  240. package/types/cmat-services-alert.d.ts +80 -87
  241. package/types/cmat-services-config.d.ts +37 -43
  242. package/types/cmat-services-confirmation.d.ts +31 -37
  243. package/types/cmat-services-data.d.ts +18 -21
  244. package/types/cmat-services-export-as.d.ts +28 -33
  245. package/types/cmat-services-loading.d.ts +27 -31
  246. package/types/cmat-services-local-storage.d.ts +17 -21
  247. package/types/cmat-services-media-watcher.d.ts +14 -18
  248. package/types/cmat-services-platform.d.ts +8 -11
  249. package/types/cmat-services-print.d.ts +97 -102
  250. package/types/cmat-services-splash-screen.d.ts +11 -14
  251. package/types/cmat-services-title.d.ts +9 -12
  252. package/types/cmat-services-translation.d.ts +19 -22
  253. package/types/cmat-services-utils.d.ts +76 -80
  254. package/types/cmat-validators.d.ts +5 -8
  255. package/types/cmat-version.d.ts +8 -10
  256. package/types/cmat.d.ts +7551 -5204
@@ -1,126 +1,137 @@
1
- import { HttpClient, HttpParams } from '@angular/common/http';
2
- import * as i0 from '@angular/core';
3
- import { inject, effect, Injectable } from '@angular/core';
4
- import { CmatUrlStateConfigService } from 'cmat/services/config';
5
- import { CmatUtilsService } from 'cmat/services/utils';
6
- import { retry, map, catchError } from 'rxjs/operators';
7
-
8
- class CmatDataService {
9
- constructor() {
10
- this._http = inject(HttpClient);
11
- this._urlStateConfigService = inject(CmatUrlStateConfigService);
12
- this._enableDataProtect = false;
13
- effect(() => {
14
- this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;
15
- });
16
- }
17
- get(url, params = {}, auth = true) {
18
- const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders('');
19
- const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
20
- if (this._enableDataProtect) {
21
- return this._http.get(url, { ...options, headers: headers })
22
- .pipe(retry({ count: 3, delay: 1000 }), map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
23
- }
24
- else {
25
- return this._http.get(url, { ...options, headers: headers })
26
- .pipe(retry({ count: 3, delay: 1000 }), catchError((err) => CmatUtilsService.handleError(err)));
27
- }
28
- }
29
- post(url, data, params = {}, auth = true, idempotent = false) {
30
- const headers = auth ? (idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders()) : (idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders('') : CmatUtilsService.getRequestCryptoBypassHeaders(''));
31
- const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
32
- if (this._enableDataProtect) {
33
- data = CmatUtilsService.getEncryptData(JSON.stringify(data));
34
- return this._http.post(url, data, { ...options, headers: headers })
35
- .pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
36
- }
37
- else {
38
- return this._http.post(url, data, { ...options, headers: headers })
39
- .pipe(catchError((err) => CmatUtilsService.handleError(err)));
40
- }
41
- }
42
- put(url, data, params = {}, auth = true) {
43
- const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');
44
- const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
45
- if (this._enableDataProtect) {
46
- data = CmatUtilsService.getEncryptData(JSON.stringify(data));
47
- return this._http.put(url, data, { ...options, headers: headers })
48
- .pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
49
- }
50
- else {
51
- return this._http.put(url, data, { ...options, headers: headers })
52
- .pipe(catchError((err) => CmatUtilsService.handleError(err)));
53
- }
54
- }
55
- delete(url, params = {}, auth = true) {
56
- const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');
57
- const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
58
- return this._http.delete(url, {
59
- ...options,
60
- headers: headers
61
- })
62
- .pipe(catchError((err) => CmatUtilsService.handleError(err)));
63
- }
64
- patch(url, data, params = {}, auth = true) {
65
- const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');
66
- const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
67
- if (this._enableDataProtect) {
68
- data = CmatUtilsService.getEncryptData(JSON.stringify(data));
69
- return this._http.patch(url, data, { ...options, headers: headers })
70
- .pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
71
- }
72
- else {
73
- return this._http.patch(url, data, { ...options, headers: headers })
74
- .pipe(catchError((err) => CmatUtilsService.handleError(err)));
75
- }
76
- }
77
- _buildHttpParams(params, encrypted) {
78
- if (Object.keys(params).length === 0) {
79
- return new HttpParams();
80
- }
81
- if (encrypted) {
82
- return new HttpParams().set('params', CmatUtilsService.getEncryptData(JSON.stringify(params)));
83
- }
84
- const normalizedParams = {};
85
- Object.entries(params).forEach(([key, value]) => {
86
- const normalizedValue = this._normalizeParamValue(value);
87
- if (normalizedValue !== undefined) {
88
- normalizedParams[key] = normalizedValue;
89
- }
90
- });
91
- return new HttpParams({ fromObject: normalizedParams });
92
- }
93
- _decryptResponse(res) {
94
- if (!res) {
95
- return res;
96
- }
97
- return JSON.parse(CmatUtilsService.getDecryptData(res));
98
- }
99
- _normalizeParamValue(value) {
100
- if (value === null || value === undefined) {
101
- return undefined;
102
- }
103
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
104
- return `${value}`;
105
- }
106
- if (value instanceof Date) {
107
- return value.toISOString();
108
- }
109
- return JSON.stringify(value);
110
- }
111
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDataService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
112
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDataService, providedIn: 'root' }); }
113
- }
114
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDataService, decorators: [{
115
- type: Injectable,
116
- args: [{
117
- providedIn: 'root'
118
- }]
119
- }], ctorParameters: () => [] });
120
-
121
- /**
122
- * Generated bundle index. Do not edit.
123
- */
124
-
1
+ import { HttpClient, HttpParams } from "@angular/common/http";
2
+ import * as i0 from "@angular/core";
3
+ import { Injectable, effect, inject } from "@angular/core";
4
+ import { CmatUrlStateConfigService } from "cmat/services/config";
5
+ import { CmatUtilsService } from "cmat/services/utils";
6
+ import { catchError, map, retry } from "rxjs/operators";
7
+ var CmatDataService = class CmatDataService {
8
+ constructor() {
9
+ this._http = inject(HttpClient);
10
+ this._urlStateConfigService = inject(CmatUrlStateConfigService);
11
+ this._enableDataProtect = false;
12
+ effect(() => {
13
+ this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;
14
+ });
15
+ }
16
+ get(url, params = {}, auth = true) {
17
+ const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders("");
18
+ const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
19
+ if (this._enableDataProtect) return this._http.get(url, {
20
+ ...options,
21
+ headers
22
+ }).pipe(retry({
23
+ count: 3,
24
+ delay: 1e3
25
+ }), map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
26
+ else return this._http.get(url, {
27
+ ...options,
28
+ headers
29
+ }).pipe(retry({
30
+ count: 3,
31
+ delay: 1e3
32
+ }), catchError((err) => CmatUtilsService.handleError(err)));
33
+ }
34
+ post(url, data, params = {}, auth = true, idempotent = false) {
35
+ const headers = auth ? idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders() : idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders("") : CmatUtilsService.getRequestCryptoBypassHeaders("");
36
+ const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
37
+ if (this._enableDataProtect) {
38
+ data = CmatUtilsService.getEncryptData(JSON.stringify(data));
39
+ return this._http.post(url, data, {
40
+ ...options,
41
+ headers
42
+ }).pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
43
+ } else return this._http.post(url, data, {
44
+ ...options,
45
+ headers
46
+ }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
47
+ }
48
+ put(url, data, params = {}, auth = true) {
49
+ const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders("");
50
+ const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
51
+ if (this._enableDataProtect) {
52
+ data = CmatUtilsService.getEncryptData(JSON.stringify(data));
53
+ return this._http.put(url, data, {
54
+ ...options,
55
+ headers
56
+ }).pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
57
+ } else return this._http.put(url, data, {
58
+ ...options,
59
+ headers
60
+ }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
61
+ }
62
+ delete(url, params = {}, auth = true) {
63
+ const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders("");
64
+ const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
65
+ return this._http.delete(url, {
66
+ ...options,
67
+ headers
68
+ }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
69
+ }
70
+ patch(url, data, params = {}, auth = true) {
71
+ const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders("");
72
+ const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
73
+ if (this._enableDataProtect) {
74
+ data = CmatUtilsService.getEncryptData(JSON.stringify(data));
75
+ return this._http.patch(url, data, {
76
+ ...options,
77
+ headers
78
+ }).pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
79
+ } else return this._http.patch(url, data, {
80
+ ...options,
81
+ headers
82
+ }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
83
+ }
84
+ _buildHttpParams(params, encrypted) {
85
+ if (Object.keys(params).length === 0) return new HttpParams();
86
+ if (encrypted) return new HttpParams().set("params", CmatUtilsService.getEncryptData(JSON.stringify(params)));
87
+ const normalizedParams = {};
88
+ Object.entries(params).forEach(([key, value]) => {
89
+ const normalizedValue = this._normalizeParamValue(value);
90
+ if (normalizedValue !== void 0) normalizedParams[key] = normalizedValue;
91
+ });
92
+ return new HttpParams({ fromObject: normalizedParams });
93
+ }
94
+ _decryptResponse(res) {
95
+ if (!res) return res;
96
+ return JSON.parse(CmatUtilsService.getDecryptData(res));
97
+ }
98
+ _normalizeParamValue(value) {
99
+ if (value === null || value === void 0) return;
100
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return `${value}`;
101
+ if (value instanceof Date) return value.toISOString();
102
+ return JSON.stringify(value);
103
+ }
104
+ static {
105
+ this.ɵfac = i0.ɵɵngDeclareFactory({
106
+ minVersion: "12.0.0",
107
+ version: "22.2.3",
108
+ ngImport: i0,
109
+ type: CmatDataService,
110
+ deps: [],
111
+ target: i0.ɵɵFactoryTarget.Injectable
112
+ });
113
+ }
114
+ static {
115
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
116
+ minVersion: "12.0.0",
117
+ version: "22.2.3",
118
+ ngImport: i0,
119
+ type: CmatDataService,
120
+ providedIn: "root"
121
+ });
122
+ }
123
+ };
124
+ i0.ɵɵngDeclareClassMetadata({
125
+ minVersion: "12.0.0",
126
+ version: "22.2.3",
127
+ ngImport: i0,
128
+ type: CmatDataService,
129
+ decorators: [{
130
+ type: Injectable,
131
+ args: [{ providedIn: "root" }]
132
+ }],
133
+ ctorParameters: () => []
134
+ });
125
135
  export { CmatDataService };
126
- //# sourceMappingURL=cmat-services-data.mjs.map
136
+
137
+ //# sourceMappingURL=cmat-services-data.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"cmat-services-data.mjs","sources":["../../../projects/cmat/services/data/data.service.ts","../../../projects/cmat/services/data/cmat-services-data.ts"],"sourcesContent":["import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';\r\nimport { Injectable, effect, inject } from '@angular/core';\r\nimport { CmatUrlStateConfigService } from 'cmat/services/config';\r\nimport { CmatUtilsService } from 'cmat/services/utils';\r\nimport { Observable } from 'rxjs';\r\nimport { catchError, map, retry } from 'rxjs/operators';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CmatDataService {\r\n private readonly _http = inject(HttpClient);\r\n private readonly _urlStateConfigService = inject(CmatUrlStateConfigService);\r\n\r\n private _enableDataProtect: boolean = false;\r\n\r\n constructor() {\r\n effect(() => {\r\n this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;\r\n });\r\n }\r\n\r\n get<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n return this._http.get<string>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.get<T>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n }\r\n\r\n post<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true, idempotent: boolean = false): Observable<T> {\r\n const headers = auth ? (idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders()) : (idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders('') : CmatUtilsService.getRequestCryptoBypassHeaders(''));\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.post<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.post<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n put<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.put<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.put<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n delete<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n return this._http.delete<T>(url, {\r\n ...options,\r\n headers: headers\r\n })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n patch<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.patch<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.patch<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n private _buildHttpParams(params: Record<string, unknown>, encrypted: boolean): HttpParams {\r\n if (Object.keys(params).length === 0) {\r\n return new HttpParams();\r\n }\r\n\r\n if (encrypted) {\r\n return new HttpParams().set('params', CmatUtilsService.getEncryptData(JSON.stringify(params)));\r\n }\r\n\r\n const normalizedParams: Record<string, string> = {};\r\n\r\n Object.entries(params).forEach(([key, value]) => {\r\n const normalizedValue = this._normalizeParamValue(value);\r\n\r\n if (normalizedValue !== undefined) {\r\n normalizedParams[key] = normalizedValue;\r\n }\r\n });\r\n\r\n return new HttpParams({ fromObject: normalizedParams });\r\n }\r\n\r\n private _decryptResponse<T>(res: string): T | string {\r\n if (!res) {\r\n return res;\r\n }\r\n\r\n return JSON.parse(CmatUtilsService.getDecryptData(res)) as T;\r\n }\r\n\r\n private _normalizeParamValue(value: unknown): string | undefined {\r\n if (value === null || value === undefined) {\r\n return undefined;\r\n }\r\n\r\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\r\n return `${value}`;\r\n }\r\n\r\n if (value instanceof Date) {\r\n return value.toISOString();\r\n }\r\n\r\n return JSON.stringify(value);\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAUa,eAAe,CAAA;AAMxB,IAAA,WAAA,GAAA;AALiB,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;AAC1B,QAAA,IAAA,CAAA,sBAAsB,GAAG,MAAM,CAAC,yBAAyB,CAAC;QAEnE,IAAA,CAAA,kBAAkB,GAAY,KAAK;QAGvC,MAAM,CAAC,MAAK;YACR,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC,iBAAiB;AACpF,QAAA,CAAC,CAAC;IACN;AAEA,IAAA,GAAG,CAAI,GAAW,EAAE,SAAkC,EAAE,EAAE,OAAgB,IAAI,EAAA;AAC1E,QAAA,MAAM,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAAC,iBAAiB,EAAE,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,EAAE,CAAC;AAC1G,QAAA,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,EAAE;AAElF,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE;AACzB,YAAA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAS,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;iBAC9D,IAAI,CACD,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAChC,GAAG,CAAC,CAAC,GAA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U,CAAC,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC3D;AAEQ,IAAA,gBAAgB,CAAI,GAAW,EAAA;QACnC,IAAI,CAAC,GAAG,EAAE;AACN,YAAA,OAAO,GAAG;QACd;QAEA,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAM;IAChE;AAEQ,IAAA,oBAAoB,CAAC,KAAc,EAAA;QACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;AACvC,YAAA,OAAO,SAAS;QACpB;AAEA,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YACtF,OAAO,CAAA,EAAG,KAAK,CAAA,CAAE;QACrB;AAEA,QAAA,IAAI,KAAK,YAAY,IAAI,EAAE;AACvB,YAAA,OAAO,KAAK,CAAC,WAAW,EAAE;QAC9B;AAEA,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;IAChC;8GAtJS,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAf,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFZ,MAAM,EAAA,CAAA,CAAA;;2FAET,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE;AACf,iBAAA;;;ACTD;;AAEG;;"}
1
+ {"version":3,"file":"cmat-services-data.mjs","names":[],"sources":["../../../projects/cmat/services/data/data.service.ts"],"sourcesContent":["import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';\r\nimport { Injectable, effect, inject } from '@angular/core';\r\nimport { CmatUrlStateConfigService } from 'cmat/services/config';\r\nimport { CmatUtilsService } from 'cmat/services/utils';\r\nimport { Observable } from 'rxjs';\r\nimport { catchError, map, retry } from 'rxjs/operators';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CmatDataService {\r\n private readonly _http = inject(HttpClient);\r\n private readonly _urlStateConfigService = inject(CmatUrlStateConfigService);\r\n\r\n private _enableDataProtect: boolean = false;\r\n\r\n constructor() {\r\n effect(() => {\r\n this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;\r\n });\r\n }\r\n\r\n get<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n return this._http.get<string>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.get<T>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n }\r\n\r\n post<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true, idempotent: boolean = false): Observable<T> {\r\n const headers = auth ? (idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders()) : (idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders('') : CmatUtilsService.getRequestCryptoBypassHeaders(''));\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.post<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.post<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n put<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.put<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.put<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n delete<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n return this._http.delete<T>(url, {\r\n ...options,\r\n headers: headers\r\n })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n patch<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.patch<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.patch<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n private _buildHttpParams(params: Record<string, unknown>, encrypted: boolean): HttpParams {\r\n if (Object.keys(params).length === 0) {\r\n return new HttpParams();\r\n }\r\n\r\n if (encrypted) {\r\n return new HttpParams().set('params', CmatUtilsService.getEncryptData(JSON.stringify(params)));\r\n }\r\n\r\n const normalizedParams: Record<string, string> = {};\r\n\r\n Object.entries(params).forEach(([key, value]) => {\r\n const normalizedValue = this._normalizeParamValue(value);\r\n\r\n if (normalizedValue !== undefined) {\r\n normalizedParams[key] = normalizedValue;\r\n }\r\n });\r\n\r\n return new HttpParams({ fromObject: normalizedParams });\r\n }\r\n\r\n private _decryptResponse<T>(res: string): T | string {\r\n if (!res) {\r\n return res;\r\n }\r\n\r\n return JSON.parse(CmatUtilsService.getDecryptData(res)) as T;\r\n }\r\n\r\n private _normalizeParamValue(value: unknown): string | undefined {\r\n if (value === null || value === undefined) {\r\n return undefined;\r\n }\r\n\r\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\r\n return `${value}`;\r\n }\r\n\r\n if (value instanceof Date) {\r\n return value.toISOString();\r\n }\r\n\r\n return JSON.stringify(value);\r\n }\r\n}\r\n"],"mappings":";;;;;;AAUA,IAAa,kBAAb,MAAa,gBAAe;CAMxB,cAAA;EALiB,KAAA,QAAQ,OAAO,UAAU;EACzB,KAAA,y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