@lenne.tech/ng-base 18.1.3 → 22.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (416) hide show
  1. package/CLAUDE.md +55 -0
  2. package/LICENSE +2 -2
  3. package/README.md +237 -44
  4. package/fesm2022/lenne.tech-ng-base-ai.mjs +771 -0
  5. package/fesm2022/lenne.tech-ng-base-ai.mjs.map +1 -0
  6. package/fesm2022/lenne.tech-ng-base-auth-provide.mjs +945 -0
  7. package/fesm2022/lenne.tech-ng-base-auth-provide.mjs.map +1 -0
  8. package/fesm2022/lenne.tech-ng-base-auth.mjs +454 -0
  9. package/fesm2022/lenne.tech-ng-base-auth.mjs.map +1 -0
  10. package/fesm2022/lenne.tech-ng-base-bug-bug-report-dialog-BRzVmKJr.mjs +825 -0
  11. package/fesm2022/lenne.tech-ng-base-bug-bug-report-dialog-BRzVmKJr.mjs.map +1 -0
  12. package/fesm2022/lenne.tech-ng-base-bug-bug-report-service-DWoTb_iw.mjs +351 -0
  13. package/fesm2022/lenne.tech-ng-base-bug-bug-report-service-DWoTb_iw.mjs.map +1 -0
  14. package/fesm2022/lenne.tech-ng-base-bug-capture-engine-TkjMDdqj.mjs +1046 -0
  15. package/fesm2022/lenne.tech-ng-base-bug-capture-engine-TkjMDdqj.mjs.map +1 -0
  16. package/fesm2022/lenne.tech-ng-base-bug-constants-Brm2KGHi.mjs +4 -0
  17. package/fesm2022/lenne.tech-ng-base-bug-constants-Brm2KGHi.mjs.map +1 -0
  18. package/fesm2022/lenne.tech-ng-base-bug-messages-BsP4fRQU.mjs +179 -0
  19. package/fesm2022/lenne.tech-ng-base-bug-messages-BsP4fRQU.mjs.map +1 -0
  20. package/fesm2022/lenne.tech-ng-base-bug-provide.mjs +26 -0
  21. package/fesm2022/lenne.tech-ng-base-bug-provide.mjs.map +1 -0
  22. package/fesm2022/lenne.tech-ng-base-bug-report-Tzlhe1Cm.mjs +62 -0
  23. package/fesm2022/lenne.tech-ng-base-bug-report-Tzlhe1Cm.mjs.map +1 -0
  24. package/fesm2022/lenne.tech-ng-base-bug-server.mjs +818 -0
  25. package/fesm2022/lenne.tech-ng-base-bug-server.mjs.map +1 -0
  26. package/fesm2022/lenne.tech-ng-base-bug.mjs +196 -0
  27. package/fesm2022/lenne.tech-ng-base-bug.mjs.map +1 -0
  28. package/fesm2022/lenne.tech-ng-base-files-ui.mjs +445 -0
  29. package/fesm2022/lenne.tech-ng-base-files-ui.mjs.map +1 -0
  30. package/fesm2022/lenne.tech-ng-base-files.mjs +474 -0
  31. package/fesm2022/lenne.tech-ng-base-files.mjs.map +1 -0
  32. package/fesm2022/lenne.tech-ng-base-server.mjs +408 -0
  33. package/fesm2022/lenne.tech-ng-base-server.mjs.map +1 -0
  34. package/fesm2022/lenne.tech-ng-base-share.mjs +76 -0
  35. package/fesm2022/lenne.tech-ng-base-share.mjs.map +1 -0
  36. package/fesm2022/lenne.tech-ng-base-sync.mjs +1096 -0
  37. package/fesm2022/lenne.tech-ng-base-sync.mjs.map +1 -0
  38. package/fesm2022/lenne.tech-ng-base-testing.mjs +171 -0
  39. package/fesm2022/lenne.tech-ng-base-testing.mjs.map +1 -0
  40. package/fesm2022/lenne.tech-ng-base-ui-provide.mjs +124 -0
  41. package/fesm2022/lenne.tech-ng-base-ui-provide.mjs.map +1 -0
  42. package/fesm2022/lenne.tech-ng-base-ui.mjs +34645 -0
  43. package/fesm2022/lenne.tech-ng-base-ui.mjs.map +1 -0
  44. package/fesm2022/lenne.tech-ng-base-utils.mjs +287 -0
  45. package/fesm2022/lenne.tech-ng-base-utils.mjs.map +1 -0
  46. package/fesm2022/lenne.tech-ng-base.mjs +615 -910
  47. package/fesm2022/lenne.tech-ng-base.mjs.map +1 -1
  48. package/i18n/auth/de.json +17 -0
  49. package/i18n/auth/en.json +17 -0
  50. package/i18n/bug/de.json +85 -0
  51. package/i18n/bug/en.json +85 -0
  52. package/i18n/de.json +8 -0
  53. package/i18n/en.json +8 -0
  54. package/i18n/files/de.json +27 -0
  55. package/i18n/files/en.json +27 -0
  56. package/i18n/share/de.json +8 -0
  57. package/i18n/share/en.json +8 -0
  58. package/i18n/ui/de.json +38 -0
  59. package/i18n/ui/en.json +38 -0
  60. package/package.json +127 -58
  61. package/types/lenne.tech-ng-base-ai.d.ts +845 -0
  62. package/types/lenne.tech-ng-base-auth-provide.d.ts +604 -0
  63. package/types/lenne.tech-ng-base-auth.d.ts +320 -0
  64. package/types/lenne.tech-ng-base-bug-provide.d.ts +272 -0
  65. package/types/lenne.tech-ng-base-bug-rolldown-runtime-C25Le4-w.d.ts +1 -0
  66. package/types/lenne.tech-ng-base-bug-server.d.ts +316 -0
  67. package/types/lenne.tech-ng-base-bug.d.ts +202 -0
  68. package/types/lenne.tech-ng-base-files-ui.d.ts +116 -0
  69. package/types/lenne.tech-ng-base-files.d.ts +288 -0
  70. package/types/lenne.tech-ng-base-server.d.ts +262 -0
  71. package/types/lenne.tech-ng-base-share.d.ts +21 -0
  72. package/types/lenne.tech-ng-base-sync.d.ts +380 -0
  73. package/types/lenne.tech-ng-base-testing.d.ts +327 -0
  74. package/types/lenne.tech-ng-base-ui-provide.d.ts +65 -0
  75. package/types/lenne.tech-ng-base-ui.d.ts +7744 -0
  76. package/types/lenne.tech-ng-base-utils.d.ts +150 -0
  77. package/types/lenne.tech-ng-base.d.ts +503 -0
  78. package/ui/styles/components/accordion.css +3 -0
  79. package/ui/styles/components/alert-dialog.css +4 -0
  80. package/ui/styles/components/alert.css +3 -0
  81. package/ui/styles/components/aspect-ratio.css +3 -0
  82. package/ui/styles/components/attachment.css +4 -0
  83. package/ui/styles/components/autocomplete.css +4 -0
  84. package/ui/styles/components/avatar.css +3 -0
  85. package/ui/styles/components/badge.css +3 -0
  86. package/ui/styles/components/breadcrumb.css +3 -0
  87. package/ui/styles/components/bubble.css +3 -0
  88. package/ui/styles/components/button-group.css +3 -0
  89. package/ui/styles/components/button.css +3 -0
  90. package/ui/styles/components/calendar.css +5 -0
  91. package/ui/styles/components/card.css +3 -0
  92. package/ui/styles/components/checkbox.css +3 -0
  93. package/ui/styles/components/code-block.css +4 -0
  94. package/ui/styles/components/collapsible.css +3 -0
  95. package/ui/styles/components/combobox.css +5 -0
  96. package/ui/styles/components/command.css +5 -0
  97. package/ui/styles/components/context-menu.css +3 -0
  98. package/ui/styles/components/date-picker.css +7 -0
  99. package/ui/styles/components/dialog.css +4 -0
  100. package/ui/styles/components/drawer.css +3 -0
  101. package/ui/styles/components/dropdown-menu.css +3 -0
  102. package/ui/styles/components/empty.css +3 -0
  103. package/ui/styles/components/field.css +5 -0
  104. package/ui/styles/components/hover-card.css +3 -0
  105. package/ui/styles/components/index.css +91 -0
  106. package/ui/styles/components/input-group.css +6 -0
  107. package/ui/styles/components/input-otp.css +3 -0
  108. package/ui/styles/components/input.css +3 -0
  109. package/ui/styles/components/item.css +4 -0
  110. package/ui/styles/components/kbd.css +3 -0
  111. package/ui/styles/components/label.css +3 -0
  112. package/ui/styles/components/lt-breadcrumb.css +3 -0
  113. package/ui/styles/components/lt-bug-attachments.css +5 -0
  114. package/ui/styles/components/lt-bug-journey-timeline.css +5 -0
  115. package/ui/styles/components/lt-bug-report-dialog.css +15 -0
  116. package/ui/styles/components/lt-bug-report.css +4 -0
  117. package/ui/styles/components/lt-color-mode-button.css +3 -0
  118. package/ui/styles/components/lt-confirm-dialog.css +4 -0
  119. package/ui/styles/components/lt-data-view.css +5 -0
  120. package/ui/styles/components/lt-date-picker.css +3 -0
  121. package/ui/styles/components/lt-date-time-picker.css +5 -0
  122. package/ui/styles/components/lt-enter-action.css +2 -0
  123. package/ui/styles/components/lt-footer.css +3 -0
  124. package/ui/styles/components/lt-form-field.css +4 -0
  125. package/ui/styles/components/lt-header.css +5 -0
  126. package/ui/styles/components/lt-imports.css +21 -0
  127. package/ui/styles/components/lt-navigation-menu.css +3 -0
  128. package/ui/styles/components/lt-notice.css +3 -0
  129. package/ui/styles/components/lt-overlay-defaults.css +3 -0
  130. package/ui/styles/components/lt-page-card.css +3 -0
  131. package/ui/styles/components/lt-page-title.css +2 -0
  132. package/ui/styles/components/lt-password-input.css +4 -0
  133. package/ui/styles/components/lt-readonly-field.css +2 -0
  134. package/ui/styles/components/lt-select.css +4 -0
  135. package/ui/styles/components/lt-text-field.css +5 -0
  136. package/ui/styles/components/lt-toolbar-item.css +2 -0
  137. package/ui/styles/components/lt-toolbar.css +3 -0
  138. package/ui/styles/components/lt-tus-upload-component.css +5 -0
  139. package/ui/styles/components/marker.css +3 -0
  140. package/ui/styles/components/menubar.css +3 -0
  141. package/ui/styles/components/message-scroller.css +4 -0
  142. package/ui/styles/components/message.css +3 -0
  143. package/ui/styles/components/native-select.css +3 -0
  144. package/ui/styles/components/navigation-menu.css +3 -0
  145. package/ui/styles/components/pagination.css +4 -0
  146. package/ui/styles/components/popover.css +3 -0
  147. package/ui/styles/components/progress.css +3 -0
  148. package/ui/styles/components/questionnaire.css +4 -0
  149. package/ui/styles/components/radio-group.css +3 -0
  150. package/ui/styles/components/resizable.css +3 -0
  151. package/ui/styles/components/select.css +3 -0
  152. package/ui/styles/components/separator.css +3 -0
  153. package/ui/styles/components/sheet.css +4 -0
  154. package/ui/styles/components/sidebar.css +9 -0
  155. package/ui/styles/components/skeleton.css +3 -0
  156. package/ui/styles/components/slider.css +3 -0
  157. package/ui/styles/components/sonner.css +4 -0
  158. package/ui/styles/components/spinner.css +3 -0
  159. package/ui/styles/components/switch.css +3 -0
  160. package/ui/styles/components/table.css +3 -0
  161. package/ui/styles/components/tabs.css +4 -0
  162. package/ui/styles/components/textarea.css +3 -0
  163. package/ui/styles/components/toggle-group.css +4 -0
  164. package/ui/styles/components/toggle.css +3 -0
  165. package/ui/styles/components/tooltip.css +3 -0
  166. package/ui/styles/components/trace.css +3 -0
  167. package/ui/styles/components/typography.css +3 -0
  168. package/ui/styles/components/utils.css +2 -0
  169. package/ui/styles/core.css +137 -0
  170. package/ui/styles/palette.css +94 -0
  171. package/ui/styles/theme.css +14 -0
  172. package/ui/styles/transitions.css +131 -0
  173. package/base-cms/index.d.ts +0 -5
  174. package/base-cms/interfaces/base-cms-module-config.interface.d.ts +0 -16
  175. package/base-cms/pages/base-cms/base-cms.component.d.ts +0 -92
  176. package/base-cms/public-api.d.ts +0 -5
  177. package/base-components/components/breadcrumb/breadcrumb.component.d.ts +0 -10
  178. package/base-components/components/change-password/change-password.component.d.ts +0 -24
  179. package/base-components/components/checkbox/checkbox.component.d.ts +0 -12
  180. package/base-components/components/delete-account/delete-account.component.d.ts +0 -15
  181. package/base-components/components/fab-button/fab-button.component.d.ts +0 -16
  182. package/base-components/components/input/input.component.d.ts +0 -27
  183. package/base-components/components/loading-bar/loading-bar.component.d.ts +0 -17
  184. package/base-components/components/model-form/model-form-base.component.d.ts +0 -64
  185. package/base-components/components/model-form/model-form.component.d.ts +0 -139
  186. package/base-components/components/model-form-sub/model-form-sub.component.d.ts +0 -56
  187. package/base-components/components/model-table/model-table.component.d.ts +0 -115
  188. package/base-components/components/refence-input/refence-input.component.d.ts +0 -84
  189. package/base-components/components/select/select.component.d.ts +0 -25
  190. package/base-components/components/skeleton-loader/skeleton-loader.component.d.ts +0 -10
  191. package/base-components/components/tags/tags.component.d.ts +0 -60
  192. package/base-components/components/textarea/textarea.component.d.ts +0 -21
  193. package/base-components/components/toast/toast.component.d.ts +0 -19
  194. package/base-components/components/upload-image/upload-image.component.d.ts +0 -111
  195. package/base-components/directives/back-button.directive.d.ts +0 -9
  196. package/base-components/directives/context-menu.directive.d.ts +0 -22
  197. package/base-components/directives/sort.directive.d.ts +0 -15
  198. package/base-components/directives/stop-propagation.directive.d.ts +0 -10
  199. package/base-components/index.d.ts +0 -5
  200. package/base-components/pipes/ellipses.pipe.d.ts +0 -10
  201. package/base-components/public-api.d.ts +0 -26
  202. package/base-prototype/index.d.ts +0 -5
  203. package/base-prototype/pages/email-verification/email-verification.component.d.ts +0 -18
  204. package/base-prototype/pages/forgot-password/forgot-password.component.d.ts +0 -26
  205. package/base-prototype/pages/login/login.component.d.ts +0 -33
  206. package/base-prototype/pages/profile/profile.component.d.ts +0 -24
  207. package/base-prototype/pages/register/register.component.d.ts +0 -31
  208. package/base-prototype/pages/set-password/set-password.component.d.ts +0 -29
  209. package/base-prototype/public-api.d.ts +0 -9
  210. package/esm2022/base-cms/interfaces/base-cms-module-config.interface.mjs +0 -3
  211. package/esm2022/base-cms/lenne.tech-ng-base-base-cms.mjs +0 -5
  212. package/esm2022/base-cms/pages/base-cms/base-cms.component.mjs +0 -238
  213. package/esm2022/base-cms/public-api.mjs +0 -8
  214. package/esm2022/base-components/components/breadcrumb/breadcrumb.component.mjs +0 -23
  215. package/esm2022/base-components/components/change-password/change-password.component.mjs +0 -97
  216. package/esm2022/base-components/components/checkbox/checkbox.component.mjs +0 -38
  217. package/esm2022/base-components/components/delete-account/delete-account.component.mjs +0 -59
  218. package/esm2022/base-components/components/fab-button/fab-button.component.mjs +0 -24
  219. package/esm2022/base-components/components/input/input.component.mjs +0 -75
  220. package/esm2022/base-components/components/loading-bar/loading-bar.component.mjs +0 -37
  221. package/esm2022/base-components/components/model-form/model-form-base.component.mjs +0 -145
  222. package/esm2022/base-components/components/model-form/model-form.component.mjs +0 -591
  223. package/esm2022/base-components/components/model-form-sub/model-form-sub.component.mjs +0 -117
  224. package/esm2022/base-components/components/model-table/model-table.component.mjs +0 -478
  225. package/esm2022/base-components/components/refence-input/refence-input.component.mjs +0 -278
  226. package/esm2022/base-components/components/select/select.component.mjs +0 -62
  227. package/esm2022/base-components/components/skeleton-loader/skeleton-loader.component.mjs +0 -33
  228. package/esm2022/base-components/components/tags/tags.component.mjs +0 -227
  229. package/esm2022/base-components/components/textarea/textarea.component.mjs +0 -79
  230. package/esm2022/base-components/components/toast/toast.component.mjs +0 -69
  231. package/esm2022/base-components/components/upload-image/upload-image.component.mjs +0 -346
  232. package/esm2022/base-components/directives/back-button.directive.mjs +0 -25
  233. package/esm2022/base-components/directives/context-menu.directive.mjs +0 -112
  234. package/esm2022/base-components/directives/sort.directive.mjs +0 -61
  235. package/esm2022/base-components/directives/stop-propagation.directive.mjs +0 -24
  236. package/esm2022/base-components/lenne.tech-ng-base-base-components.mjs +0 -5
  237. package/esm2022/base-components/pipes/ellipses.pipe.mjs +0 -23
  238. package/esm2022/base-components/public-api.mjs +0 -30
  239. package/esm2022/base-prototype/lenne.tech-ng-base-base-prototype.mjs +0 -5
  240. package/esm2022/base-prototype/pages/email-verification/email-verification.component.mjs +0 -60
  241. package/esm2022/base-prototype/pages/forgot-password/forgot-password.component.mjs +0 -78
  242. package/esm2022/base-prototype/pages/login/login.component.mjs +0 -114
  243. package/esm2022/base-prototype/pages/profile/profile.component.mjs +0 -87
  244. package/esm2022/base-prototype/pages/register/register.component.mjs +0 -100
  245. package/esm2022/base-prototype/pages/set-password/set-password.component.mjs +0 -91
  246. package/esm2022/base-prototype/public-api.mjs +0 -11
  247. package/esm2022/lenne.tech-ng-base.mjs +0 -5
  248. package/esm2022/public-api.mjs +0 -25
  249. package/esm2022/shared/classes/auth.class.mjs +0 -14
  250. package/esm2022/shared/classes/basic-user.class.mjs +0 -49
  251. package/esm2022/shared/classes/graphql-enum.class.mjs +0 -10
  252. package/esm2022/shared/classes/graphql-meta.class.mjs +0 -345
  253. package/esm2022/shared/classes/graphql-type.class.mjs +0 -14
  254. package/esm2022/shared/classes/helper.class.mjs +0 -307
  255. package/esm2022/shared/classes/sort.class.mjs +0 -38
  256. package/esm2022/shared/classes/standard.class.mjs +0 -40
  257. package/esm2022/shared/decorators/debounce.decorator.mjs +0 -12
  258. package/esm2022/shared/enums/comparison-operator.enum.mjs +0 -16
  259. package/esm2022/shared/enums/graphql-request-type.enum.mjs +0 -10
  260. package/esm2022/shared/enums/logical-operator.enum.mjs +0 -10
  261. package/esm2022/shared/enums/skeleton-type.enum.mjs +0 -7
  262. package/esm2022/shared/enums/sort-order.enum.mjs +0 -6
  263. package/esm2022/shared/enums/toast-type.enum.mjs +0 -8
  264. package/esm2022/shared/functions/ws-client.function.mjs +0 -39
  265. package/esm2022/shared/interfaces/base-module-config.interface.mjs +0 -3
  266. package/esm2022/shared/interfaces/breadcrumb.interface.mjs +0 -2
  267. package/esm2022/shared/interfaces/can-component-deactivate.interface.mjs +0 -2
  268. package/esm2022/shared/interfaces/cms-enum-values.interface.mjs +0 -2
  269. package/esm2022/shared/interfaces/cms-field-config.interface.mjs +0 -2
  270. package/esm2022/shared/interfaces/cms-model-config.interface.mjs +0 -2
  271. package/esm2022/shared/interfaces/cms-table-field.interface.mjs +0 -2
  272. package/esm2022/shared/interfaces/combined-filter-input.interface.mjs +0 -2
  273. package/esm2022/shared/interfaces/compress-options.interface.mjs +0 -2
  274. package/esm2022/shared/interfaces/cropping-options.interface.mjs +0 -2
  275. package/esm2022/shared/interfaces/field-object.interface.mjs +0 -2
  276. package/esm2022/shared/interfaces/field.interface.mjs +0 -2
  277. package/esm2022/shared/interfaces/filter-input.interface.mjs +0 -2
  278. package/esm2022/shared/interfaces/find-args.interface.mjs +0 -2
  279. package/esm2022/shared/interfaces/graphql-crud-type.interface.mjs +0 -2
  280. package/esm2022/shared/interfaces/graphql-fields-object.interface.mjs +0 -2
  281. package/esm2022/shared/interfaces/graphql-options.interface.mjs +0 -2
  282. package/esm2022/shared/interfaces/graphql-plus-options.interfacen.mjs +0 -2
  283. package/esm2022/shared/interfaces/graphql-type-collection.interface.mjs +0 -2
  284. package/esm2022/shared/interfaces/login-config.interface.mjs +0 -2
  285. package/esm2022/shared/interfaces/register-config.interface.mjs +0 -2
  286. package/esm2022/shared/interfaces/single-filter-input.interface.mjs +0 -2
  287. package/esm2022/shared/interfaces/sort-input.interface.mjs +0 -2
  288. package/esm2022/shared/interfaces/time-components.interface.mjs +0 -2
  289. package/esm2022/shared/interfaces/toast.interface.mjs +0 -2
  290. package/esm2022/shared/lenne.tech-ng-base-shared.mjs +0 -5
  291. package/esm2022/shared/public-api.mjs +0 -74
  292. package/esm2022/shared/services/auth.service.mjs +0 -152
  293. package/esm2022/shared/services/breadcrumb.service.mjs +0 -69
  294. package/esm2022/shared/services/cms.service.mjs +0 -82
  295. package/esm2022/shared/services/file.service.mjs +0 -86
  296. package/esm2022/shared/services/forms.service.mjs +0 -61
  297. package/esm2022/shared/services/graphql-meta.service.mjs +0 -132
  298. package/esm2022/shared/services/graphql-plus.service.mjs +0 -93
  299. package/esm2022/shared/services/graphql.service.mjs +0 -510
  300. package/esm2022/shared/services/image.service.mjs +0 -102
  301. package/esm2022/shared/services/loader.service.mjs +0 -78
  302. package/esm2022/shared/services/navigation.service.mjs +0 -38
  303. package/esm2022/shared/services/scroll.service.mjs +0 -207
  304. package/esm2022/shared/services/storage.service.mjs +0 -149
  305. package/esm2022/shared/services/toast.service.mjs +0 -39
  306. package/esm2022/shared/services/user.service.mjs +0 -160
  307. package/esm2022/shared/services/ws.service.mjs +0 -17
  308. package/esm2022/shared/types/graphql-fields.type.mjs +0 -2
  309. package/esm2022/shared/types/storage.type.mjs +0 -2
  310. package/esm2022/shared/validators/email.validator.mjs +0 -7
  311. package/esm2022/shared/validators/match.validator.mjs +0 -22
  312. package/esm2022/shared/validators/secure-password.validator.mjs +0 -7
  313. package/esm2022/src/base.module.mjs +0 -64
  314. package/esm2022/src/decorators/auto-unsubscribe.decorator.mjs +0 -23
  315. package/esm2022/src/directives/lazy-load.directive.mjs +0 -48
  316. package/esm2022/src/directives/match-height.directive.mjs +0 -92
  317. package/esm2022/src/directives/resizable.directive.mjs +0 -92
  318. package/esm2022/src/factories/apollo-options.factory.mjs +0 -108
  319. package/esm2022/src/functions/extract-files.function.mjs +0 -87
  320. package/esm2022/src/guards/auth.guard.mjs +0 -91
  321. package/esm2022/src/guards/can-deactivate.guard.mjs +0 -16
  322. package/esm2022/src/guards/logout.guard.mjs +0 -34
  323. package/esm2022/src/pipes/date-ago.pipe.mjs +0 -64
  324. package/esm2022/src/pipes/safe-html.pipe.mjs +0 -22
  325. package/esm2022/src/services/fullscreen.service.mjs +0 -51
  326. package/esm2022/src/services/seo.service.mjs +0 -117
  327. package/esm2022/src/services/theme.service.mjs +0 -44
  328. package/fesm2022/lenne.tech-ng-base-base-cms.mjs +0 -251
  329. package/fesm2022/lenne.tech-ng-base-base-cms.mjs.map +0 -1
  330. package/fesm2022/lenne.tech-ng-base-base-components.mjs +0 -2917
  331. package/fesm2022/lenne.tech-ng-base-base-components.mjs.map +0 -1
  332. package/fesm2022/lenne.tech-ng-base-base-prototype.mjs +0 -505
  333. package/fesm2022/lenne.tech-ng-base-base-prototype.mjs.map +0 -1
  334. package/fesm2022/lenne.tech-ng-base-shared.mjs +0 -2863
  335. package/fesm2022/lenne.tech-ng-base-shared.mjs.map +0 -1
  336. package/index.d.ts +0 -5
  337. package/public-api.d.ts +0 -17
  338. package/shared/classes/auth.class.d.ts +0 -10
  339. package/shared/classes/basic-user.class.d.ts +0 -27
  340. package/shared/classes/graphql-enum.class.d.ts +0 -7
  341. package/shared/classes/graphql-meta.class.d.ts +0 -66
  342. package/shared/classes/graphql-type.class.d.ts +0 -13
  343. package/shared/classes/helper.class.d.ts +0 -99
  344. package/shared/classes/sort.class.d.ts +0 -12
  345. package/shared/classes/standard.class.d.ts +0 -32
  346. package/shared/decorators/debounce.decorator.d.ts +0 -1
  347. package/shared/enums/comparison-operator.enum.d.ts +0 -14
  348. package/shared/enums/graphql-request-type.enum.d.ts +0 -8
  349. package/shared/enums/logical-operator.enum.d.ts +0 -8
  350. package/shared/enums/skeleton-type.enum.d.ts +0 -5
  351. package/shared/enums/sort-order.enum.d.ts +0 -4
  352. package/shared/enums/toast-type.enum.d.ts +0 -6
  353. package/shared/functions/ws-client.function.d.ts +0 -5
  354. package/shared/index.d.ts +0 -5
  355. package/shared/interfaces/base-module-config.interface.d.ts +0 -61
  356. package/shared/interfaces/breadcrumb.interface.d.ts +0 -4
  357. package/shared/interfaces/can-component-deactivate.interface.d.ts +0 -7
  358. package/shared/interfaces/cms-enum-values.interface.d.ts +0 -4
  359. package/shared/interfaces/cms-field-config.interface.d.ts +0 -45
  360. package/shared/interfaces/cms-model-config.interface.d.ts +0 -14
  361. package/shared/interfaces/cms-table-field.interface.d.ts +0 -10
  362. package/shared/interfaces/combined-filter-input.interface.d.ts +0 -9
  363. package/shared/interfaces/compress-options.interface.d.ts +0 -15
  364. package/shared/interfaces/cropping-options.interface.d.ts +0 -12
  365. package/shared/interfaces/field-object.interface.d.ts +0 -6
  366. package/shared/interfaces/field.interface.d.ts +0 -5
  367. package/shared/interfaces/filter-input.interface.d.ts +0 -9
  368. package/shared/interfaces/find-args.interface.d.ts +0 -11
  369. package/shared/interfaces/graphql-crud-type.interface.d.ts +0 -7
  370. package/shared/interfaces/graphql-fields-object.interface.d.ts +0 -6
  371. package/shared/interfaces/graphql-options.interface.d.ts +0 -11
  372. package/shared/interfaces/graphql-plus-options.interfacen.d.ts +0 -9
  373. package/shared/interfaces/graphql-type-collection.interface.d.ts +0 -7
  374. package/shared/interfaces/login-config.interface.d.ts +0 -6
  375. package/shared/interfaces/register-config.interface.d.ts +0 -4
  376. package/shared/interfaces/single-filter-input.interface.d.ts +0 -11
  377. package/shared/interfaces/sort-input.interface.d.ts +0 -5
  378. package/shared/interfaces/time-components.interface.d.ts +0 -6
  379. package/shared/interfaces/toast.interface.d.ts +0 -8
  380. package/shared/public-api.d.ts +0 -65
  381. package/shared/services/auth.service.d.ts +0 -44
  382. package/shared/services/breadcrumb.service.d.ts +0 -32
  383. package/shared/services/cms.service.d.ts +0 -27
  384. package/shared/services/file.service.d.ts +0 -22
  385. package/shared/services/forms.service.d.ts +0 -14
  386. package/shared/services/graphql-meta.service.d.ts +0 -45
  387. package/shared/services/graphql-plus.service.d.ts +0 -27
  388. package/shared/services/graphql.service.d.ts +0 -71
  389. package/shared/services/image.service.d.ts +0 -27
  390. package/shared/services/loader.service.d.ts +0 -32
  391. package/shared/services/navigation.service.d.ts +0 -15
  392. package/shared/services/scroll.service.d.ts +0 -85
  393. package/shared/services/storage.service.d.ts +0 -49
  394. package/shared/services/toast.service.d.ts +0 -15
  395. package/shared/services/user.service.d.ts +0 -77
  396. package/shared/services/ws.service.d.ts +0 -8
  397. package/shared/types/graphql-fields.type.d.ts +0 -5
  398. package/shared/types/storage.type.d.ts +0 -4
  399. package/shared/validators/email.validator.d.ts +0 -1
  400. package/shared/validators/match.validator.d.ts +0 -4
  401. package/shared/validators/secure-password.validator.d.ts +0 -1
  402. package/src/base.module.d.ts +0 -16
  403. package/src/decorators/auto-unsubscribe.decorator.d.ts +0 -5
  404. package/src/directives/lazy-load.directive.d.ts +0 -17
  405. package/src/directives/match-height.directive.d.ts +0 -20
  406. package/src/directives/resizable.directive.d.ts +0 -26
  407. package/src/factories/apollo-options.factory.d.ts +0 -16
  408. package/src/functions/extract-files.function.d.ts +0 -15
  409. package/src/guards/auth.guard.d.ts +0 -27
  410. package/src/guards/can-deactivate.guard.d.ts +0 -10
  411. package/src/guards/logout.guard.d.ts +0 -16
  412. package/src/pipes/date-ago.pipe.d.ts +0 -34
  413. package/src/pipes/safe-html.pipe.d.ts +0 -13
  414. package/src/services/fullscreen.service.d.ts +0 -18
  415. package/src/services/seo.service.d.ts +0 -61
  416. package/src/services/theme.service.d.ts +0 -17
@@ -1,2863 +0,0 @@
1
- import { GraphQLInputObjectType, GraphQLScalarType, GraphQLEnumType, GraphQLNonNull, GraphQLList, buildClientSchema, getIntrospectionQuery } from 'graphql';
2
- import * as i0 from '@angular/core';
3
- import { InjectionToken, Injectable, Inject, PLATFORM_ID } from '@angular/core';
4
- import { of, throwError, Observable, BehaviorSubject, map as map$1, filter } from 'rxjs';
5
- import * as i1 from 'apollo-angular';
6
- import { gql } from 'apollo-angular';
7
- import { sha256 } from 'js-sha256';
8
- import { map } from 'rxjs/operators';
9
- import * as i2 from '@angular/common';
10
- import { isPlatformBrowser, DOCUMENT } from '@angular/common';
11
- import * as i1$1 from '@angular/router';
12
- import { NavigationEnd } from '@angular/router';
13
- import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
14
- import Compressor from 'compressorjs';
15
- import * as i2$1 from '@angular/common/http';
16
- import { HttpHeaders } from '@angular/common/http';
17
- import { createClient } from 'graphql-ws';
18
-
19
- /**
20
- * Helper class
21
- */
22
- class Helper {
23
- /**
24
- * Simple filter function for plain objects
25
- */
26
- static filter(objects, filter) {
27
- return (objects?.filter((element) => {
28
- for (const [key, value] of Object.entries(filter)) {
29
- if (Array.isArray(element[key])) {
30
- for (const item of element[key]) {
31
- if (!element[key].includs(value)) {
32
- return false;
33
- }
34
- }
35
- }
36
- else if (element[key] !== value) {
37
- return false;
38
- }
39
- }
40
- return true;
41
- }) || []);
42
- }
43
- /**
44
- * Convert to a url/uri conform string
45
- * Only:
46
- * - lower case
47
- * - chars, numbers and hyphens
48
- */
49
- static urlString(str, options = {}) {
50
- // Config
51
- const config = {
52
- allowAll: false,
53
- ...options,
54
- };
55
- // To string
56
- str = str + '';
57
- // Trim
58
- str = str.trim();
59
- // Lower case
60
- str = str.toLowerCase();
61
- if (!config.allowAll) {
62
- // Replace spaces
63
- str = str.trim().replace(/\s+/g, '-');
64
- // Replace some special chars
65
- str = str.replace('ä', 'ae');
66
- str = str.replace('ö', 'oe');
67
- str = str.replace('ü', 'ue');
68
- str = str.replace('ß', 'ss');
69
- // Remove double characters
70
- str = str.replace('---', '-');
71
- str = str.replace('--', '-');
72
- // Remove other special chars
73
- str = str.replace(/[^a-zA-Z0-9-]/g, '');
74
- }
75
- // Return url conform string
76
- return encodeURI(str);
77
- }
78
- /**
79
- * Simple map function
80
- */
81
- static map(source, target, options = {}) {
82
- // Set config
83
- const config = {
84
- funcAllowed: false,
85
- dateStringToDate: true,
86
- ...options,
87
- };
88
- // Check source
89
- if (!source || typeof source !== 'object' || Array.isArray(source)) {
90
- return target;
91
- }
92
- // Update properties
93
- for (const key of Object.keys(target)) {
94
- if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
95
- if (typeof source[key] === 'string' && config.dateStringToDate) {
96
- if (Array.isArray(config.dateStringToDate)) {
97
- if (config.dateStringToDate.includes(key)) {
98
- target[key] = Helper.parseDate(source[key]);
99
- }
100
- }
101
- else {
102
- target[key] = Helper.parseDate(source[key]);
103
- }
104
- }
105
- else {
106
- target[key] = source[key];
107
- }
108
- }
109
- }
110
- // Return target
111
- return target;
112
- }
113
- /**
114
- * Create Object or Objects of specified type with specified data
115
- */
116
- static maps(data, targetClass) {
117
- // Check data
118
- if (!data || typeof data !== 'object') {
119
- return undefined;
120
- }
121
- // Check array
122
- if (!Array.isArray(data)) {
123
- data = [data];
124
- }
125
- // Map
126
- return data.map((item) => {
127
- return targetClass.map(item);
128
- });
129
- }
130
- /**
131
- * Get plain parameter
132
- */
133
- static getPlainParameter(parameter) {
134
- if (!parameter) {
135
- return parameter;
136
- }
137
- return parameter?.split('?')?.shift()?.split('#')?.shift();
138
- }
139
- /**
140
- * Get ID of an url parameter
141
- */
142
- static getParameterId(parameter) {
143
- if (!parameter) {
144
- return parameter;
145
- }
146
- return Helper.getPlainParameter(parameter)?.split('-').pop();
147
- }
148
- /**
149
- * Delay
150
- */
151
- static delay(ms) {
152
- const promise = new Promise((resolve) => setTimeout(resolve, ms));
153
- return promise;
154
- }
155
- /**
156
- * Deep freeze
157
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
158
- */
159
- static deepFreeze(object, preparedObjects = []) {
160
- // Prevent infinit regress
161
- if (preparedObjects.includes(object)) {
162
- return object;
163
- }
164
- preparedObjects.push(object);
165
- // Retrieve the property names defined on object
166
- const propNames = Object.getOwnPropertyNames(object);
167
- // Freeze properties before freezing self
168
- for (const name of propNames) {
169
- const value = object[name];
170
- if (value && typeof value === 'object') {
171
- Helper.deepFreeze(value, preparedObjects);
172
- }
173
- }
174
- return Object.freeze(object);
175
- }
176
- /**
177
- * Generates an unique identifier with a specific length
178
- */
179
- static getUID(length = 24) {
180
- let dt = new Date().getTime();
181
- const uuid = 'x'.repeat(length).replace(/[xy]/g, (c) => {
182
- // eslint-disable-next-line no-bitwise
183
- const r = (dt + Math.random() * 16) % 16 | 0;
184
- dt = Math.floor(dt / 16);
185
- // eslint-disable-next-line no-bitwise
186
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
187
- });
188
- return uuid;
189
- }
190
- /**
191
- * Parse date string to date object
192
- */
193
- static parseDate(dateString) {
194
- const reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
195
- const reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
196
- if (typeof dateString === 'string') {
197
- const isoExec = reISO.exec(dateString);
198
- if (isoExec) {
199
- return new Date(dateString);
200
- }
201
- const msAjaxExec = reMsAjax.exec(dateString);
202
- if (msAjaxExec) {
203
- const cleaned = msAjaxExec[1].split(/[-+,.]/);
204
- return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
205
- }
206
- }
207
- return dateString;
208
- }
209
- /**
210
- * Get browser name and version
211
- */
212
- static getBrowser() {
213
- const userAgent = navigator.userAgent;
214
- let data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
215
- let version;
216
- if (/trident/i.test(data[1])) {
217
- version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
218
- return { name: 'IE', version: version[1] || '' };
219
- }
220
- if (data[1] === 'Chrome') {
221
- version = userAgent.match(/\bOPR|Edge\/(\d+)/);
222
- if (version != null) {
223
- return { name: 'Opera', version: version[1] };
224
- }
225
- }
226
- data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
227
- version = userAgent.match(/version\/(\d+)/i);
228
- if (version !== null) {
229
- data.splice(1, 1, version[1]);
230
- }
231
- return {
232
- name: data[0],
233
- version: data[1],
234
- };
235
- }
236
- /**
237
- * Whether first parameter is a deep subset of second parameter
238
- * Hint: functions will be ignored
239
- */
240
- static isSubset(a, b) {
241
- // Equal
242
- if (a === b) {
243
- return true;
244
- }
245
- // Different type
246
- if (typeof a !== typeof b) {
247
- return false;
248
- }
249
- // Process array
250
- if (Array.isArray(a)) {
251
- for (const [key, value] of Object.entries(a)) {
252
- if (Helper.isSubset(value, b[key])) {
253
- return false;
254
- }
255
- }
256
- return true;
257
- }
258
- // Process object
259
- if (typeof a === 'object') {
260
- const plain = JSON.parse(JSON.stringify(a));
261
- for (const [key, value] of Object.entries(plain)) {
262
- if (Helper.isSubset(value, b[key])) {
263
- return false;
264
- }
265
- }
266
- return true;
267
- }
268
- // Else
269
- return true;
270
- }
271
- /**
272
- * Whether parameters are equal (have equal properties)
273
- * Hint: functions will be ignored
274
- */
275
- static isEqual(a, b) {
276
- return Helper.isSubset(a, b) && Helper.isSubset(b, a);
277
- }
278
- /**
279
- * First level difference of two objects
280
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
281
- *
282
- * @returns Record<string, any> Object with properties from first object
283
- */
284
- static getDiff(a, b, clone = true) {
285
- const result = {};
286
- let firstObject = a;
287
- if (clone) {
288
- firstObject = JSON.parse(JSON.stringify(a));
289
- }
290
- for (const [key, value] of Object.entries(firstObject)) {
291
- if (!Helper.isSubset(value, b[key])) {
292
- result[key] = value;
293
- }
294
- }
295
- return result;
296
- }
297
- /**
298
- * Check if propertie is type of HTMLCollection or NodeList
299
- * See https://stackoverflow.com/a/7238344
300
- *
301
- * @param nodes
302
- */
303
- static isNodeList(nodes) {
304
- try {
305
- const stringRepr = Object.prototype.toString.call(nodes);
306
- return (typeof nodes === 'object' &&
307
- /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
308
- typeof nodes.length === 'number' &&
309
- (nodes.length === 0 || (typeof nodes[0] === 'object' && nodes[0].nodeType > 0)));
310
- }
311
- catch (e) {
312
- return false;
313
- }
314
- }
315
- static arrayBufferToBase64(buffer) {
316
- let binary = '';
317
- const bytes = new Uint8Array(buffer);
318
- const len = bytes.byteLength;
319
- for (let i = 0; i < len; i++) {
320
- binary += String.fromCharCode(bytes[i]);
321
- }
322
- return `data:image/*;base64, ${window.btoa(binary)}`;
323
- }
324
- }
325
-
326
- /**
327
- * Standard class
328
- * Other classes should extend the Standard class, if they offer own functions
329
- * If the extended class uses object properties with own map functions, it should implement its own map function
330
- */
331
- class Standard {
332
- /**
333
- * Static map method
334
- */
335
- static map(data, item = new this()) {
336
- return item.map(data);
337
- }
338
- /**
339
- * Map data into an object
340
- */
341
- map(data) {
342
- return Helper.map(data, this);
343
- }
344
- /**
345
- * Clone object (and map additional data)
346
- */
347
- clone(mapData) {
348
- const current = JSON.parse(JSON.stringify(this));
349
- if (mapData) {
350
- Object.assign(current, mapData);
351
- }
352
- return new this.constructor().map(current);
353
- }
354
- /**
355
- * Compare this with another object
356
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
357
- *
358
- * @return Record<string, any> with properties of this object which are different
359
- */
360
- getDiff(compare, clone = true) {
361
- return Helper.getDiff(this, compare, clone);
362
- }
363
- }
364
-
365
- /**
366
- * User class
367
- */
368
- class BasicUser extends Standard {
369
- id = undefined;
370
- email = undefined;
371
- avatar = undefined;
372
- firstName = undefined;
373
- lastName = undefined;
374
- roles = [];
375
- username = undefined;
376
- // ===================================================================================================================
377
- // Methods
378
- // ===================================================================================================================
379
- /**
380
- * Mapping
381
- */
382
- map(data) {
383
- Helper.map(data, this);
384
- return this;
385
- }
386
- /**
387
- * Checks whether the user has at least one of the required roles
388
- */
389
- hasRole(roles) {
390
- if (typeof roles === 'string') {
391
- roles = [roles];
392
- }
393
- if (!this.roles || this.roles.length < 1) {
394
- return false;
395
- }
396
- return !roles || roles.length < 1 ? true : this.roles.some((role) => roles.includes(role));
397
- }
398
- /**
399
- * Checks whether the user has all required roles
400
- */
401
- hasAllRoles(roles) {
402
- if (typeof roles === 'string') {
403
- roles = [roles];
404
- }
405
- if (!this.roles || this.roles.length < 1) {
406
- return false;
407
- }
408
- return !roles ? true : roles.every((role) => this.roles.includes(role));
409
- }
410
- }
411
-
412
- /**
413
- * GraphQL enum
414
- */
415
- class GraphQLEnum {
416
- value;
417
- constructor(value) {
418
- this.value = value;
419
- }
420
- }
421
-
422
- /**
423
- * GraphQL type
424
- */
425
- class GraphQLType extends Standard {
426
- type = '';
427
- fields = {};
428
- isRequired = false;
429
- isItemRequired = false;
430
- isList = false;
431
- isEnum = false;
432
- validEnums = [];
433
- }
434
-
435
- /**
436
- * GraphQL meta
437
- */
438
- class GraphQLMeta {
439
- schema;
440
- // Frozen caches
441
- args = {};
442
- fields = {};
443
- /**
444
- * Integrate schema
445
- */
446
- constructor(schema) {
447
- this.schema = schema;
448
- if (!schema) {
449
- throw Error('Missing schema');
450
- }
451
- }
452
- /**
453
- * Get an object with GraphQLRequestType (operation type) as keys and method (fields) names as value
454
- */
455
- getMethodNames() {
456
- return {
457
- query: Object.keys(this.schema.getQueryType()?.getFields() || {}),
458
- mutation: Object.keys(this.schema.getMutationType()?.getFields() || {}),
459
- subscription: Object.keys(this.schema.getSubscriptionType()?.getFields() || {}),
460
- };
461
- }
462
- /**
463
- * Get GraphQLRequestTypes (operation types) via method (field) name
464
- */
465
- getRequestTypesViaMethod(methodName) {
466
- const result = [];
467
- const methodNames = this.getMethodNames();
468
- for (const [key, value] of Object.entries(methodNames)) {
469
- if (value.includes(methodName)) {
470
- result.push(key);
471
- }
472
- }
473
- return result;
474
- }
475
- /**
476
- * We're going to get the query and mutation types from the schema, then we're going to loop through the fields of each
477
- * type and check if the field name starts with `find`, `create`, `update`, or `delete`. If it does, we're going to add
478
- * the model name to the `possibleTypes` array
479
- *
480
- * @returns An array of objects with the name of the model, and the CRUD operations that are available for that model.
481
- */
482
- getTypes(logging = false) {
483
- const possibleTypes = [];
484
- const mutationType = this.schema.getMutationType();
485
- const queryType = this.schema.getQueryType();
486
- if (logging) {
487
- console.log('GraphQLMeta::getTypes->queryTypeFields', queryType.getFields());
488
- }
489
- for (const [key, value] of Object.entries(queryType.getFields())) {
490
- if (key.startsWith('find')) {
491
- possibleTypes.push({
492
- name: key.split('find').pop().slice(0, -1),
493
- create: false,
494
- update: false,
495
- delete: false,
496
- duplicate: false,
497
- });
498
- }
499
- }
500
- if (logging) {
501
- console.log('GraphQLMeta::getTypes->mutationTypeFields', mutationType.getFields());
502
- console.log('GraphQLMeta::getTypes->possibleTypes', possibleTypes);
503
- }
504
- for (const [key, value] of Object.entries(mutationType.getFields())) {
505
- if (key.startsWith('create')) {
506
- const model = key.split('create').pop();
507
- if (possibleTypes.find((e) => e.name === model)) {
508
- possibleTypes.find((item) => item.name === model).create = true;
509
- }
510
- }
511
- if (key.startsWith('update')) {
512
- const model = key.split('update').pop();
513
- if (possibleTypes.find((e) => e.name === model)) {
514
- possibleTypes.find((item) => item.name === model).update = true;
515
- }
516
- }
517
- if (key.startsWith('delete')) {
518
- const model = key.split('delete').pop();
519
- if (possibleTypes.find((e) => e.name === model)) {
520
- possibleTypes.find((item) => item.name === model).delete = true;
521
- }
522
- }
523
- if (key.startsWith('duplicate')) {
524
- const model = key.split('duplicate').pop();
525
- if (possibleTypes.find((e) => e.name === model)) {
526
- possibleTypes.find((item) => item.name === model).duplicate = true;
527
- }
528
- }
529
- }
530
- if (logging) {
531
- console.log('GraphQLMeta::getTypes->possibleTypes', possibleTypes);
532
- console.log('GraphQLMeta::getTypes->filteredPossibleTypes', possibleTypes.filter((e) => e.create || e.update));
533
- }
534
- return possibleTypes.filter((e) => e.create || e.update);
535
- }
536
- /**
537
- * Get arguments of GraphQL function
538
- */
539
- getArgs(functionName, options = {}) {
540
- const { cache, freeze, type } = {
541
- cache: true,
542
- freeze: true,
543
- type: undefined,
544
- ...options,
545
- };
546
- // Get cache
547
- if (cache && freeze) {
548
- const args = this.args[functionName + type];
549
- if (args) {
550
- return args;
551
- }
552
- }
553
- const func = this.getFunction(functionName, { type });
554
- const result = new GraphQLType();
555
- if (func?.args) {
556
- func.args.forEach((item) => {
557
- result.fields[item.name] = this.getDeepType(item.type);
558
- });
559
- }
560
- // Set cache
561
- if (freeze) {
562
- this.args[functionName + type] = Helper.deepFreeze(result);
563
- }
564
- return result;
565
- }
566
- /**
567
- * Get fields of GraphQL function
568
- */
569
- getFields(functionName, options = {}) {
570
- const { cache, freeze, type } = {
571
- cache: true,
572
- freeze: true,
573
- type: undefined,
574
- ...options,
575
- };
576
- // Get cache
577
- if (cache && freeze) {
578
- const args = this.fields[functionName + type];
579
- if (args) {
580
- return args;
581
- }
582
- }
583
- const func = this.getFunction(functionName, options);
584
- const result = this.getDeepType(func.type);
585
- // Set cache
586
- if (freeze) {
587
- this.fields[functionName + type] = Helper.deepFreeze(result);
588
- }
589
- return result;
590
- }
591
- /**
592
- * Get GraphQL function
593
- */
594
- getFunction(name, options = {}) {
595
- // Set config
596
- const config = {
597
- ...options,
598
- };
599
- // Init possible functions
600
- let functions = {};
601
- // If function type is set
602
- if (config.type) {
603
- const graphQLType = config.type.charAt(0).toUpperCase() + config.type.slice(1);
604
- const type = this.schema.getType(graphQLType);
605
- if (type) {
606
- functions = type.getFields();
607
- }
608
- }
609
- // If function type is not set
610
- else {
611
- ['Subscription', 'Mutation', 'Query'].forEach((item) => {
612
- const type = this.schema.getType(item);
613
- if (type) {
614
- functions = {
615
- ...functions,
616
- ...(type.getFields() || {}),
617
- };
618
- }
619
- });
620
- }
621
- // Get function via name
622
- return functions[name];
623
- }
624
- /**
625
- * Get type
626
- */
627
- getType(name) {
628
- return this.schema.getType(name);
629
- }
630
- /**
631
- * Get (deep) type name
632
- */
633
- getTypeName(type) {
634
- if (type instanceof GraphQLInputObjectType ||
635
- type instanceof GraphQLScalarType ||
636
- type instanceof GraphQLEnumType) {
637
- return type.name;
638
- }
639
- else if (type.type) {
640
- return this.getTypeName(type.type);
641
- }
642
- else if (type.ofType) {
643
- return this.getTypeName(type.ofType);
644
- }
645
- else {
646
- return type.name;
647
- }
648
- }
649
- /**
650
- * Get deep type data
651
- */
652
- getDeepType(type, prepared = {}, setMetaData = false) {
653
- // Check type
654
- if (!type) {
655
- return type;
656
- }
657
- // Infinite regress protection
658
- const typeName = this.getTypeName(type);
659
- const graphQLType = GraphQLType.map({
660
- type: this.getTypeName(type),
661
- });
662
- // Check prepared
663
- if (typeof type === 'object') {
664
- const preparedType = prepared[typeName];
665
- // Work with cached type
666
- if (preparedType) {
667
- // Create a new object to protect own isXXX information
668
- const clone = Object.assign({}, preparedType);
669
- // But use fields as reference to get future changes via prepared caching
670
- clone.fields = preparedType.fields;
671
- // Disable meta flags for sub objects
672
- if (type?.type instanceof GraphQLInputObjectType ||
673
- (type?.type instanceof GraphQLNonNull && type?.type?.ofType instanceof GraphQLInputObjectType && setMetaData)) {
674
- setMetaData = false;
675
- }
676
- // Check for meta flags
677
- if (type.type && setMetaData) {
678
- if (type.type instanceof GraphQLNonNull) {
679
- clone.isRequired = true;
680
- if (type.type.ofType instanceof GraphQLList) {
681
- clone.isList = true;
682
- clone.isItemRequired = type.type.ofType.ofType instanceof GraphQLNonNull;
683
- }
684
- else {
685
- clone.isList = false;
686
- clone.isItemRequired = false;
687
- }
688
- }
689
- else {
690
- clone.isRequired = false;
691
- // List first
692
- if (type.type instanceof GraphQLList) {
693
- clone.isList = true;
694
- clone.isItemRequired = type.ofType instanceof GraphQLNonNull;
695
- }
696
- else {
697
- clone.isList = false;
698
- clone.isItemRequired = false;
699
- }
700
- }
701
- }
702
- return clone;
703
- }
704
- // Set prepared cache for GraphQL types
705
- // (type names start with uppercase letters as opposed to property names that start with lowercase letters)
706
- if (type.name && type.name[0].toUpperCase() === type.name[0] && !prepared[type.name]) {
707
- prepared[type.name] = graphQLType;
708
- }
709
- }
710
- // Search deeper
711
- if (type.ofType) {
712
- const ofTypeResult = this.getDeepType(type.ofType, prepared, setMetaData);
713
- Object.assign(graphQLType, ofTypeResult);
714
- return graphQLType;
715
- }
716
- // Process fields
717
- if (type._fields) {
718
- const fields = {};
719
- for (const [key, value] of Object.entries(type._fields)) {
720
- fields[key] = this.getDeepType(value, prepared, true);
721
- }
722
- // Assign and not replace to preserve updates in the cache
723
- Object.assign(graphQLType.fields, fields);
724
- return graphQLType;
725
- }
726
- // Process type
727
- if (type.type) {
728
- const typeResult = this.getDeepType(type.type, prepared, setMetaData);
729
- // Disable meta flags for sub objects
730
- if (type?.type instanceof GraphQLInputObjectType ||
731
- (type?.type instanceof GraphQLNonNull && type?.type?.ofType instanceof GraphQLInputObjectType && setMetaData)) {
732
- setMetaData = false;
733
- }
734
- // Check for meta flags
735
- if (setMetaData) {
736
- if (type.type instanceof GraphQLNonNull) {
737
- typeResult.isRequired = true;
738
- if (type.type.ofType instanceof GraphQLList) {
739
- typeResult.isList = true;
740
- typeResult.isItemRequired = type.type.ofType.ofType instanceof GraphQLNonNull;
741
- }
742
- else {
743
- typeResult.isList = false;
744
- typeResult.isItemRequired = false;
745
- }
746
- }
747
- else {
748
- typeResult.isRequired = false;
749
- // List first
750
- if (type.type instanceof GraphQLList) {
751
- typeResult.isList = true;
752
- typeResult.isItemRequired = type.ofType instanceof GraphQLNonNull;
753
- }
754
- else {
755
- typeResult.isList = false;
756
- typeResult.isItemRequired = false;
757
- }
758
- }
759
- }
760
- Object.assign(graphQLType, typeResult);
761
- return graphQLType;
762
- }
763
- // Set enum values
764
- if (!!type._values) {
765
- graphQLType.isEnum = true;
766
- for (const [key, value] of Object.entries(type._nameLookup)) {
767
- if (!value.isDeprecated) {
768
- graphQLType.validEnums.push(key);
769
- }
770
- }
771
- }
772
- // Finish
773
- return graphQLType;
774
- }
775
- }
776
-
777
- class Auth extends Standard {
778
- refreshToken = undefined;
779
- token = undefined;
780
- user = undefined;
781
- map(data) {
782
- Helper.map(data, this);
783
- this.user = data?.user ? BasicUser.map(data.user) : this.user;
784
- return this;
785
- }
786
- }
787
-
788
- class Sort {
789
- sortOrder = 1;
790
- collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
791
- /**
792
- * Sorts clicked column
793
- */
794
- startSort(property, order, type = '') {
795
- if (order === 'desc') {
796
- this.sortOrder = -1;
797
- }
798
- return (a, b) => {
799
- if (type === 'date') {
800
- return this.sortDate(new Date(a.latestStep[property]), new Date(b.latestStep[property]));
801
- }
802
- else if (type === 'position') {
803
- return this.collator.compare(a.position.Value[property], b.position.Value[property]) * this.sortOrder;
804
- }
805
- else {
806
- return this.collator.compare(a[property], b[property]) * this.sortOrder;
807
- }
808
- };
809
- }
810
- /**
811
- * Sorts dates
812
- */
813
- sortDate(a, b) {
814
- if (a < b) {
815
- return -1 * this.sortOrder;
816
- }
817
- else if (a > b) {
818
- return 1 * this.sortOrder;
819
- }
820
- else {
821
- return 0 * this.sortOrder;
822
- }
823
- }
824
- }
825
-
826
- function debounce(delay = 300) {
827
- return function (target, propertyKey, descriptor) {
828
- let timeout = null;
829
- const original = descriptor.value;
830
- descriptor.value = function (...args) {
831
- clearTimeout(timeout);
832
- timeout = setTimeout(() => original.apply(this, args), delay);
833
- };
834
- return descriptor;
835
- };
836
- }
837
-
838
- /**
839
- * GraphQL request type enum
840
- */
841
- var GraphQLRequestType;
842
- (function (GraphQLRequestType) {
843
- GraphQLRequestType["QUERY"] = "query";
844
- GraphQLRequestType["MUTATION"] = "mutation";
845
- GraphQLRequestType["SUBSCRIPTION"] = "subscription";
846
- })(GraphQLRequestType || (GraphQLRequestType = {}));
847
-
848
- const BASE_MODULE_CONFIG = new InjectionToken('BASE_MODULE_CONFIG');
849
-
850
- /**
851
- * GraphQL meta service
852
- *
853
- * For collecting meta information of the GraphQL API
854
- */
855
- class GraphQLMetaService {
856
- apollo;
857
- // Caches
858
- _frozenSchema;
859
- _frozenSchemaObservable;
860
- _meta;
861
- _metaObservable;
862
- _schemaObservable;
863
- // Private caches
864
- _introspectionQuery;
865
- /**
866
- * Include services
867
- */
868
- constructor(apollo) {
869
- this.apollo = apollo;
870
- }
871
- /**
872
- * Getter of introspectionQuery
873
- */
874
- get introspectionQuery() {
875
- return JSON.parse(JSON.stringify(this._introspectionQuery));
876
- }
877
- /**
878
- * Get schema for API
879
- * See https://www.apollographql.com/blog/three-ways-to-represent-your-graphql-schema-a41f4175100d
880
- */
881
- getSchema(options = {}) {
882
- // Get configurations
883
- const config = {
884
- cache: true,
885
- freeze: true,
886
- ...options,
887
- };
888
- // Use caching
889
- if (config.cache) {
890
- if (config.freeze && this._frozenSchema) {
891
- return of(this._frozenSchema);
892
- }
893
- if (this._introspectionQuery) {
894
- return of(buildClientSchema(this.introspectionQuery));
895
- }
896
- if (config.freeze && this._frozenSchemaObservable) {
897
- return this._frozenSchemaObservable;
898
- }
899
- else if (!config.freeze && this._schemaObservable) {
900
- return this._schemaObservable;
901
- }
902
- }
903
- // Request schema from server
904
- const observable = this.apollo
905
- .query({
906
- query: gql(getIntrospectionQuery({ descriptions: false })),
907
- })
908
- .pipe(map((schema) => {
909
- // Cache introspectionQuery
910
- this._introspectionQuery = schema.data;
911
- // Convert schema to GraphQLSchema
912
- this._frozenSchema = Helper.deepFreeze(buildClientSchema(this.introspectionQuery));
913
- // Return GraphQLSchema
914
- if (config.freeze) {
915
- return this._frozenSchema;
916
- }
917
- return buildClientSchema(schema.data);
918
- }));
919
- // Set observables
920
- if (config.freeze) {
921
- this._frozenSchemaObservable = observable;
922
- }
923
- else {
924
- this._schemaObservable = observable;
925
- }
926
- // Return result
927
- return observable;
928
- }
929
- /**
930
- * Get meta for API
931
- * See https://www.apollographql.com/blog/three-ways-to-represent-your-graphql-schema-a41f4175100d
932
- */
933
- getMeta(options = {}) {
934
- // Get configurations
935
- const config = {
936
- cache: true,
937
- log: false,
938
- ...options,
939
- };
940
- // Use caching
941
- if (config.cache) {
942
- if (this._meta) {
943
- return of(this._meta);
944
- }
945
- else if (this._metaObservable) {
946
- return this._metaObservable;
947
- }
948
- }
949
- // Request schema from server
950
- const observable = this.getSchema(options).pipe(map((schema) => {
951
- // Log
952
- if (config.log) {
953
- console.log({ schema });
954
- }
955
- this._meta = new GraphQLMeta(schema);
956
- return this._meta;
957
- }));
958
- // Set observables
959
- this._metaObservable = observable;
960
- // Return result
961
- return observable;
962
- }
963
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLMetaService, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
964
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLMetaService, providedIn: 'root' });
965
- }
966
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLMetaService, decorators: [{
967
- type: Injectable,
968
- args: [{
969
- providedIn: 'root',
970
- }]
971
- }], ctorParameters: () => [{ type: i1.Apollo }] });
972
-
973
- /**
974
- * GraphQL service
975
- */
976
- class GraphQLService {
977
- apollo;
978
- graphQLMetaService;
979
- moduleConfig;
980
- /**
981
- * Include services
982
- */
983
- constructor(apollo, graphQLMetaService, moduleConfig) {
984
- this.apollo = apollo;
985
- this.graphQLMetaService = graphQLMetaService;
986
- this.moduleConfig = moduleConfig;
987
- }
988
- /**
989
- * GraphQL request
990
- */
991
- graphQl(graphqlMethodName, options = {}) {
992
- // Check parameters
993
- if (!graphqlMethodName) {
994
- throwError(() => new Error('Missing graphql method name'));
995
- }
996
- // Get config
997
- const config = {
998
- arguments: null,
999
- fields: null,
1000
- log: false,
1001
- model: null,
1002
- ...options,
1003
- };
1004
- // Convert class to Object for arguments
1005
- if (typeof config.arguments === 'function') {
1006
- config.arguments = new config.arguments();
1007
- }
1008
- // Convert class to Object for fields
1009
- if (typeof config.fields === 'function') {
1010
- config.fields = new config.fields();
1011
- }
1012
- // Log
1013
- if (config.log) {
1014
- console.log({ config });
1015
- }
1016
- // Send request
1017
- return new Observable((subscriber) => {
1018
- // Get meta
1019
- this.graphQLMetaService.getMeta({ log: config.log }).subscribe((meta) => {
1020
- // Set GraphQLRequestType automatically
1021
- if (!config.type) {
1022
- const types = meta.getRequestTypesViaMethod(graphqlMethodName);
1023
- if (!types?.length) {
1024
- throwError(() => new Error('No GraphQLRequestType detected'));
1025
- }
1026
- config.type = types[0];
1027
- if (config.type) {
1028
- throwError(() => new Error('No GraphQLRequestType detected'));
1029
- }
1030
- if (types.length > 1) {
1031
- // eslint-disable-next-line no-console
1032
- console.debug('GraphQLRequestType ' + config.type + ' used for ' + graphqlMethodName, types);
1033
- }
1034
- }
1035
- // Prepare fields
1036
- let fields;
1037
- let allowedFields;
1038
- // Log meta
1039
- if (config.log) {
1040
- console.log({ meta });
1041
- }
1042
- if (config.fields) {
1043
- allowedFields = meta.getFields(graphqlMethodName, { type: config.type });
1044
- // Log meta
1045
- if (config.log) {
1046
- console.log({ allowedFields });
1047
- }
1048
- const fieldsData = this.prepareFields(config.fields, {
1049
- allowed: allowedFields,
1050
- });
1051
- fields = fieldsData.fieldsString;
1052
- }
1053
- if (fields && !fields.startsWith('{')) {
1054
- fields = '{' + fields + '\n}';
1055
- }
1056
- // Log fields
1057
- if (config.log) {
1058
- console.log({ fields });
1059
- }
1060
- // Get allowed args
1061
- const allowedArgs = meta.getArgs(graphqlMethodName, { type: config.type });
1062
- // Log allowed args
1063
- if (config.log) {
1064
- console.log({ allowedArgs });
1065
- }
1066
- const argsData = this.prepareArguments(config.arguments, {
1067
- allowed: allowedArgs,
1068
- });
1069
- // Log args data
1070
- if (config.log) {
1071
- argsData.usedArgs.sort();
1072
- argsData.schemaArgs.sort();
1073
- const filtered = argsData.schemaArgs.filter((field) => !argsData.usedArgs.includes(field));
1074
- const unused = this.graphQLTypeToStringArray(allowedArgs)
1075
- .sort()
1076
- .filter((field) => !argsData.usedArgs.includes(field));
1077
- console.log({ argsData, filtered, unused });
1078
- }
1079
- let args = argsData?.argsString || '';
1080
- if (args === '{}') {
1081
- args = '';
1082
- }
1083
- // Log
1084
- if (config.log) {
1085
- console.log({ graphQL: graphqlMethodName, args, fields, type: config.type });
1086
- }
1087
- // Prepare request
1088
- const request = {};
1089
- // Prepare GraphQL
1090
- const gQlFuncBody = fields
1091
- ? ' {\n' + graphqlMethodName + args + fields + '\n}'
1092
- : ' {\n' + graphqlMethodName + args + '\n}';
1093
- let gQlBody = config.type + gQlFuncBody;
1094
- // Handling for variables (e.g. for file uploads)
1095
- if (Object.keys(argsData.variables).length) {
1096
- // Preparations
1097
- request.variables = {};
1098
- let multipart = false;
1099
- // Add surrounding
1100
- gQlBody = config.type + ' Request(';
1101
- for (const [key, item] of Object.entries(argsData.variables)) {
1102
- gQlBody += '\n$' + key + ':' + item.type + ',';
1103
- request.variables[key] = item.value;
1104
- if (item.type.startsWith('Upload')) {
1105
- multipart = true;
1106
- }
1107
- }
1108
- gQlBody = gQlBody.slice(0, -1) + '\n)' + gQlFuncBody;
1109
- // Set Multipart
1110
- if (multipart) {
1111
- request.context = {
1112
- useMultipart: true,
1113
- };
1114
- }
1115
- }
1116
- const documentNode = gql(gQlBody);
1117
- // Log
1118
- if (config.log) {
1119
- console.log({ documentNode });
1120
- }
1121
- // Set document node
1122
- request[config.type] = documentNode;
1123
- // Log
1124
- if (config.log) {
1125
- console.log({ request });
1126
- }
1127
- let func;
1128
- if (config.type === GraphQLRequestType.MUTATION) {
1129
- func = 'mutate';
1130
- request[config.type] = documentNode;
1131
- }
1132
- else if (config.type === GraphQLRequestType.SUBSCRIPTION) {
1133
- func = 'subscribe';
1134
- request.query = documentNode;
1135
- }
1136
- else {
1137
- func = config.type;
1138
- request[config.type] = documentNode;
1139
- }
1140
- this.apollo[func](request).subscribe((result) => {
1141
- const data = result?.data?.[graphqlMethodName] !== undefined ? result.data[graphqlMethodName] : result;
1142
- // Direct data
1143
- if (!config.model) {
1144
- subscriber.next(data);
1145
- }
1146
- // Map data as array
1147
- else if (Array.isArray(data)) {
1148
- subscriber.next(data.map((item) => {
1149
- return config.model.map(item);
1150
- }));
1151
- }
1152
- // Map data
1153
- else {
1154
- subscriber.next(config.model.map(data));
1155
- }
1156
- if (config.type !== GraphQLRequestType.SUBSCRIPTION) {
1157
- // Done
1158
- subscriber.complete();
1159
- }
1160
- }, (error) => {
1161
- subscriber.error(error);
1162
- subscriber.complete();
1163
- });
1164
- });
1165
- });
1166
- }
1167
- /**
1168
- * Get fields / args from IGraphQLTypeCollection
1169
- */
1170
- graphQLTypeToStringArray(graphQLType, current = '', result = [], cacheNode = []) {
1171
- if (!graphQLType) {
1172
- return result;
1173
- }
1174
- if (current?.includes('.')) {
1175
- cacheNode.push(current.split('.')[1]);
1176
- }
1177
- else if (current) {
1178
- cacheNode.push(current);
1179
- }
1180
- for (const key of Object.keys(graphQLType.fields)) {
1181
- if (current === key || cacheNode.includes(key)) {
1182
- continue;
1183
- }
1184
- this.graphQLTypeToStringArray(graphQLType.fields[key], current ? current + '.' + key : key, result, cacheNode);
1185
- }
1186
- return result;
1187
- }
1188
- /**
1189
- * Prepare arguments for GraphQL request
1190
- */
1191
- prepareArguments(args, options = {}) {
1192
- // Init config variables
1193
- const { allowed, levelKey, level, parent, schemaArgs, usedArgs, variables } = {
1194
- allowed: null,
1195
- levelKey: '',
1196
- level: 1,
1197
- parent: '',
1198
- schemaArgs: [],
1199
- usedArgs: [],
1200
- variables: {},
1201
- ...options,
1202
- };
1203
- // Check args
1204
- if (args === undefined || args === null) {
1205
- return { argsString: '', schemaArgs, usedArgs, variables };
1206
- }
1207
- // Init args
1208
- const result = [];
1209
- // Process array
1210
- if (Array.isArray(args)) {
1211
- const allowedKeys = allowed ? Object.keys(allowed.fields) : null;
1212
- for (const item of args) {
1213
- let key = null;
1214
- if (allowed) {
1215
- if (!allowedKeys || allowedKeys.length < 1) {
1216
- break;
1217
- }
1218
- key = allowedKeys.shift();
1219
- }
1220
- // Process value
1221
- result.push(this.prepareArguments(item, {
1222
- allowed: key ? allowed.fields[key] : null,
1223
- levelKey: key,
1224
- level: level + 1,
1225
- parent: parent + key + '.',
1226
- schemaArgs,
1227
- usedArgs,
1228
- variables,
1229
- }).argsString);
1230
- }
1231
- // Encapsulation of the array result
1232
- if (result.length) {
1233
- // Complete result, encapsulated via round brackets
1234
- if (level === 1) {
1235
- return { argsString: '(' + result.join(', ') + ')', schemaArgs, usedArgs, variables };
1236
- }
1237
- // Deeper result part, encapsulated via square brackets
1238
- else {
1239
- return { argsString: '[' + result.join(', ') + ']', schemaArgs, usedArgs, variables };
1240
- }
1241
- }
1242
- }
1243
- // Process object
1244
- else if (typeof args === 'object') {
1245
- // Check for Upload type for variable handling
1246
- if (allowed?.type === 'Upload') {
1247
- const name = levelKey + '_' + Helper.getUID(6);
1248
- variables[name] = { type: allowed.type + (allowed.isRequired ? '!' : ''), value: args };
1249
- return { argsString: '$' + name, schemaArgs, usedArgs, variables };
1250
- }
1251
- // Check object is empty
1252
- if (args && Object.keys(args).length === 0 && Object.getPrototypeOf(args) === Object.prototype) {
1253
- return { argsString: '{}', schemaArgs, usedArgs, variables };
1254
- }
1255
- // Process all object entries
1256
- for (const [key, value] of Object.entries(args)) {
1257
- // Init data for current entry
1258
- const currentKey = parent + key;
1259
- schemaArgs.push(currentKey);
1260
- // If the allowed key handling is enabled and the current key is not included in the list of allowed keys,
1261
- // the current key will be skipped
1262
- if (allowed && !allowed.fields[key]) {
1263
- continue;
1264
- }
1265
- // Skip value if not exists
1266
- if (value === undefined) {
1267
- continue;
1268
- }
1269
- // Set null e.g. for resetting
1270
- if (value === null) {
1271
- result.push(key + ':' + null);
1272
- continue;
1273
- }
1274
- // Add current key to metadata
1275
- usedArgs.push(currentKey);
1276
- // Process GraphQLEnum
1277
- if (value instanceof GraphQLEnum) {
1278
- result.push(key + ':' + value.value);
1279
- continue;
1280
- }
1281
- if (this.moduleConfig.securePasswordTransfer && key === 'password') {
1282
- result.push(key + ':' + `"${sha256(value)}"`);
1283
- continue;
1284
- }
1285
- // Process array
1286
- else if (Array.isArray(value)) {
1287
- result.push(key +
1288
- ': [' +
1289
- value.map((item) => this.prepareArguments(item, {
1290
- allowed: allowed.fields[key],
1291
- levelKey: key,
1292
- level: level + 1,
1293
- parent: currentKey + '.',
1294
- schemaArgs,
1295
- usedArgs,
1296
- variables,
1297
- }).argsString) +
1298
- ']');
1299
- continue;
1300
- }
1301
- // Prepare additional result string
1302
- let additionalResult = key + ': ';
1303
- // Value is a date object
1304
- if (typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]') {
1305
- additionalResult += `"""${value.toString()}"""`;
1306
- }
1307
- // Value is a string
1308
- else if (typeof value === 'string') {
1309
- // Enum (doesn't need quotation marks)
1310
- if (allowed.fields[key].isEnum) {
1311
- additionalResult += value;
1312
- }
1313
- // String
1314
- else {
1315
- additionalResult += `"${value.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`;
1316
- }
1317
- }
1318
- // Value is a simple boolean or a number
1319
- else if (typeof value === 'boolean' || typeof value === 'number') {
1320
- additionalResult += value;
1321
- }
1322
- // Others
1323
- else {
1324
- const prepareOptions = {
1325
- allowed: allowed.fields[key],
1326
- levelKey: key,
1327
- level: level + 1,
1328
- parent: currentKey + '.',
1329
- schemaArgs,
1330
- usedArgs,
1331
- variables,
1332
- };
1333
- try {
1334
- additionalResult += this.prepareArguments(value, prepareOptions).argsString;
1335
- }
1336
- catch (e) {
1337
- console.error('Error during preparing arguments', value, prepareOptions);
1338
- throw e;
1339
- }
1340
- }
1341
- // Push deeper part into result array
1342
- result.push(additionalResult);
1343
- }
1344
- // Encapsulation of the object result
1345
- if (result.length) {
1346
- // Complete result, encapsulated via round brackets
1347
- if (level === 1) {
1348
- return { argsString: '(' + result.join(', ') + ')', schemaArgs, usedArgs, variables };
1349
- }
1350
- // Deeper result part, encapsulated via curly brackets
1351
- else {
1352
- return { argsString: '{' + result.join(', ') + '}', schemaArgs, usedArgs, variables };
1353
- }
1354
- }
1355
- }
1356
- // Prepare and process other / unknown values as JSON
1357
- else {
1358
- return { argsString: JSON.stringify(args), schemaArgs, usedArgs, variables };
1359
- }
1360
- }
1361
- /**
1362
- * Prepare fields for GraphQL request
1363
- */
1364
- prepareFields(fields, options = {}) {
1365
- // Config
1366
- const { allowed, parent, schemaFields, spaces, tab, usedFields } = {
1367
- allowed: null,
1368
- parent: '',
1369
- schemaFields: [],
1370
- spaces: 2,
1371
- tab: 1,
1372
- usedFields: [],
1373
- ...options,
1374
- };
1375
- // Init fields string
1376
- let fieldsString = '';
1377
- // Check fields
1378
- if (!fields) {
1379
- return { fieldsString, schemaFields, usedFields };
1380
- }
1381
- // Process string
1382
- if (typeof fields === 'string') {
1383
- if (allowed && !allowed.fields[fields]) {
1384
- return { fieldsString, schemaFields, usedFields };
1385
- }
1386
- return { fieldsString: '\n' + ' '.repeat(spaces).repeat(tab) + fields, schemaFields, usedFields };
1387
- }
1388
- // Process array
1389
- else if (Array.isArray(fields)) {
1390
- for (const item of fields) {
1391
- if (typeof item === 'object') {
1392
- fieldsString =
1393
- fieldsString +
1394
- this.prepareFields(item, {
1395
- allowed, // item is object or array
1396
- parent,
1397
- spaces,
1398
- schemaFields,
1399
- tab: tab + 1,
1400
- usedFields,
1401
- }).fieldsString;
1402
- continue;
1403
- }
1404
- const currentPath = parent + item;
1405
- schemaFields.push(currentPath);
1406
- if (allowed && !allowed.fields[item]) {
1407
- continue;
1408
- }
1409
- usedFields.push(currentPath);
1410
- fieldsString =
1411
- fieldsString +
1412
- this.prepareFields(item, {
1413
- allowed: null, // item is string
1414
- parent: currentPath + '.',
1415
- spaces,
1416
- schemaFields,
1417
- tab: tab + 1,
1418
- usedFields,
1419
- }).fieldsString;
1420
- }
1421
- }
1422
- // Process object
1423
- else if (typeof fields === 'object') {
1424
- for (const [key, val] of Object.entries(fields)) {
1425
- const currentPath = parent + key;
1426
- schemaFields.push(currentPath);
1427
- if (allowed && !allowed.fields[key]) {
1428
- continue;
1429
- }
1430
- usedFields.push(currentPath);
1431
- if (typeof val !== 'object' || !Object.keys(val).length) {
1432
- fieldsString = fieldsString + '\n' + ' '.repeat(spaces).repeat(tab) + key;
1433
- }
1434
- else {
1435
- fieldsString =
1436
- fieldsString +
1437
- '\n' +
1438
- ' '.repeat(spaces).repeat(tab) +
1439
- key +
1440
- ' ' +
1441
- '{' +
1442
- this.prepareFields(val, {
1443
- allowed: allowed.fields[key], // val is object or array
1444
- parent: currentPath + '.',
1445
- spaces,
1446
- schemaFields,
1447
- tab: tab + 1,
1448
- usedFields,
1449
- }).fieldsString +
1450
- '\n' +
1451
- ' '.repeat(spaces).repeat(tab) +
1452
- '}';
1453
- }
1454
- }
1455
- }
1456
- // Return result
1457
- return { fieldsString, schemaFields, usedFields };
1458
- }
1459
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLService, deps: [{ token: i1.Apollo }, { token: GraphQLMetaService }, { token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
1460
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLService, providedIn: 'root' });
1461
- }
1462
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLService, decorators: [{
1463
- type: Injectable,
1464
- args: [{
1465
- providedIn: 'root',
1466
- }]
1467
- }], ctorParameters: () => [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: undefined, decorators: [{
1468
- type: Inject,
1469
- args: [BASE_MODULE_CONFIG]
1470
- }] }] });
1471
-
1472
- /**
1473
- * Storage service for local data storage
1474
- */
1475
- class StorageService {
1476
- moduleConfig;
1477
- platformId;
1478
- /**
1479
- * Storage
1480
- */
1481
- storage = null;
1482
- /**
1483
- * Prefix for storage keys
1484
- */
1485
- prefix = '';
1486
- /**
1487
- * Initializations
1488
- */
1489
- constructor(moduleConfig, platformId) {
1490
- this.moduleConfig = moduleConfig;
1491
- this.platformId = platformId;
1492
- // Set storage
1493
- const type = moduleConfig.storageType ? moduleConfig.storageType : 'local';
1494
- if (isPlatformBrowser(this.platformId)) {
1495
- if (type === 'session') {
1496
- this.storage = sessionStorage;
1497
- }
1498
- else {
1499
- if (localStorage) {
1500
- this.storage = localStorage;
1501
- }
1502
- else {
1503
- this.storage = null;
1504
- }
1505
- }
1506
- }
1507
- // Set prefix
1508
- this.prefix = '';
1509
- if (moduleConfig.prefix) {
1510
- this.prefix += moduleConfig.prefix + '_';
1511
- }
1512
- if (moduleConfig.version) {
1513
- this.prefix += moduleConfig.version + '_';
1514
- }
1515
- }
1516
- /**
1517
- * Save itemKeys
1518
- *
1519
- * If you want to save one item, use itemKeys and value parameters like these:
1520
- * save('KEY_OF_THE_ITEM', ITEM)
1521
- *
1522
- * If you want to save multiple items, use itemKeys only (value parameter will be ignored):
1523
- * save({'KEY_OF_ITEM_1': ITEM_1, 'KEY_OF_ITEM_2': ITEM_2, ...})
1524
- */
1525
- save(itemKeys, value) {
1526
- // Check local storage
1527
- if (!this.storage) {
1528
- return false;
1529
- }
1530
- // Check item keys and value
1531
- if (!itemKeys ||
1532
- (typeof itemKeys === 'object' && !Object.keys(itemKeys).length) ||
1533
- (typeof itemKeys === 'string' && value === undefined)) {
1534
- return false;
1535
- }
1536
- if (typeof itemKeys === 'object') {
1537
- for (const [itemKey, itemValue] of Object.entries(itemKeys)) {
1538
- this.storage.setItem(this.prefix + itemKey, JSON.stringify(itemValue));
1539
- }
1540
- return true;
1541
- }
1542
- this.storage.setItem(this.prefix + itemKeys, JSON.stringify(value));
1543
- return true;
1544
- }
1545
- /**
1546
- * Load items via key(s)
1547
- */
1548
- load(itemKeys) {
1549
- // Check local storage
1550
- if (!this.storage) {
1551
- return;
1552
- }
1553
- // Check item keys
1554
- if (!itemKeys || (Array.isArray(itemKeys) && !itemKeys.length)) {
1555
- return null;
1556
- }
1557
- if (Array.isArray(itemKeys)) {
1558
- const back = {};
1559
- itemKeys.forEach((itemKey) => {
1560
- const loadedItem = this.storage.getItem(this.prefix + itemKey);
1561
- if (loadedItem) {
1562
- back[itemKey] = JSON.parse(loadedItem);
1563
- }
1564
- else {
1565
- back[itemKey] = null;
1566
- }
1567
- });
1568
- return back;
1569
- }
1570
- let value = this.storage.getItem(this.prefix + itemKeys);
1571
- if (value) {
1572
- value = JSON.parse(value);
1573
- }
1574
- return value;
1575
- }
1576
- /**
1577
- * Remove item from storage
1578
- *
1579
- * @param itemKeys keys or key to remove
1580
- */
1581
- remove(itemKeys) {
1582
- // Check local storage
1583
- if (!this.storage) {
1584
- return false;
1585
- }
1586
- if (Array.isArray(itemKeys)) {
1587
- itemKeys.forEach((key) => {
1588
- this.storage.removeItem(this.prefix + key);
1589
- });
1590
- return true;
1591
- }
1592
- this.storage.removeItem(this.prefix + itemKeys);
1593
- return true;
1594
- }
1595
- /**
1596
- * Clear local storage
1597
- */
1598
- reset() {
1599
- this.storage.clear();
1600
- }
1601
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: StorageService, deps: [{ token: BASE_MODULE_CONFIG }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
1602
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: StorageService, providedIn: 'root' });
1603
- }
1604
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: StorageService, decorators: [{
1605
- type: Injectable,
1606
- args: [{
1607
- providedIn: 'root',
1608
- }]
1609
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1610
- type: Inject,
1611
- args: [BASE_MODULE_CONFIG]
1612
- }] }, { type: undefined, decorators: [{
1613
- type: Inject,
1614
- args: [PLATFORM_ID]
1615
- }] }] });
1616
-
1617
- class WsService {
1618
- client;
1619
- reconnect() {
1620
- this.client?.restart();
1621
- }
1622
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: WsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1623
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: WsService, providedIn: 'root' });
1624
- }
1625
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: WsService, decorators: [{
1626
- type: Injectable,
1627
- args: [{
1628
- providedIn: 'root',
1629
- }]
1630
- }] });
1631
-
1632
- /**
1633
- * Authentication service
1634
- */
1635
- class AuthService {
1636
- storageService;
1637
- wsService;
1638
- injector;
1639
- router;
1640
- // Subjects
1641
- _currentUser = new BehaviorSubject(null);
1642
- _token = new BehaviorSubject(null);
1643
- _refreshToken = new BehaviorSubject(null);
1644
- /**
1645
- * Constructor
1646
- */
1647
- constructor(storageService, wsService, injector, router) {
1648
- this.storageService = storageService;
1649
- this.wsService = wsService;
1650
- this.injector = injector;
1651
- this.router = router;
1652
- this.loadFromStorage();
1653
- }
1654
- requestNewToken() {
1655
- return new Observable((subscriber) => {
1656
- this.injector
1657
- .get(GraphQLService)
1658
- .graphQl('refreshToken', {
1659
- fields: ['token', 'refreshToken'],
1660
- })
1661
- .subscribe({
1662
- next: (response) => {
1663
- this.token = response.token;
1664
- this.refreshToken = response.refreshToken;
1665
- subscriber.next(response);
1666
- subscriber.complete();
1667
- },
1668
- error: (err) => {
1669
- subscriber.error(err);
1670
- },
1671
- });
1672
- });
1673
- }
1674
- loadFromStorage() {
1675
- if (localStorage) {
1676
- this.token = this.storageService.load('token');
1677
- this.refreshToken = this.storageService.load('refreshToken');
1678
- this.currentUser = this.storageService.load('currentUser');
1679
- }
1680
- }
1681
- /**
1682
- * Logout
1683
- */
1684
- logout(redirect = true) {
1685
- return new Observable((subscriber) => {
1686
- this.injector
1687
- .get(GraphQLService)
1688
- .graphQl('logout', {
1689
- fields: [],
1690
- })
1691
- .subscribe({
1692
- next: () => {
1693
- this.clearSession(redirect);
1694
- subscriber.next(true);
1695
- subscriber.complete();
1696
- },
1697
- error: (err) => {
1698
- subscriber.error(err);
1699
- },
1700
- });
1701
- });
1702
- }
1703
- clearSession(redirect = true) {
1704
- this.storageService.remove(['token', 'refreshToken', 'currentUser']);
1705
- this.currentUser = null;
1706
- this.token = null;
1707
- this.refreshToken = null;
1708
- if (redirect) {
1709
- this.router.navigate(['/auth']);
1710
- }
1711
- }
1712
- // #################################################################
1713
- // Current User
1714
- // #################################################################
1715
- get currentUser() {
1716
- if (!localStorage) {
1717
- return undefined;
1718
- }
1719
- return this._currentUser.value;
1720
- }
1721
- set currentUser(user) {
1722
- this._currentUser.next(user);
1723
- this.storageService.save('currentUser', user);
1724
- }
1725
- get currentUserObservable() {
1726
- return this._currentUser.asObservable();
1727
- }
1728
- // #################################################################
1729
- // Token
1730
- // #################################################################
1731
- get token() {
1732
- if (!localStorage) {
1733
- return undefined;
1734
- }
1735
- return this._token.value;
1736
- }
1737
- set token(token) {
1738
- this._token.next(token);
1739
- this.storageService.save('token', token);
1740
- this.wsService.reconnect();
1741
- }
1742
- get tokenObservable() {
1743
- if (!this._token.value) {
1744
- this.loadFromStorage();
1745
- }
1746
- return this._token.asObservable();
1747
- }
1748
- // #################################################################
1749
- // refreshToken
1750
- // #################################################################
1751
- get refreshToken() {
1752
- if (!localStorage) {
1753
- return undefined;
1754
- }
1755
- return this._refreshToken.value;
1756
- }
1757
- set refreshToken(refreshToken) {
1758
- this._refreshToken.next(refreshToken);
1759
- this.storageService.save('refreshToken', refreshToken);
1760
- }
1761
- get refreshTokenObservable() {
1762
- if (!this._refreshToken.value) {
1763
- this.loadFromStorage();
1764
- }
1765
- return this._refreshToken.asObservable();
1766
- }
1767
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AuthService, deps: [{ token: StorageService }, { token: WsService }, { token: i0.Injector }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
1768
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AuthService, providedIn: 'root' });
1769
- }
1770
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: AuthService, decorators: [{
1771
- type: Injectable,
1772
- args: [{
1773
- providedIn: 'root',
1774
- }]
1775
- }], ctorParameters: () => [{ type: StorageService }, { type: WsService }, { type: i0.Injector }, { type: i1$1.Router }] });
1776
-
1777
- /**
1778
- * Loader service for loading indication
1779
- */
1780
- class LoaderService {
1781
- isLoading = new BehaviorSubject(false);
1782
- lastStartTime;
1783
- /**
1784
- * Start loading manually
1785
- */
1786
- start() {
1787
- if (!this.isLoading.value) {
1788
- this.isLoading.next(true);
1789
- this.lastStartTime = new Date().getTime();
1790
- }
1791
- }
1792
- /**
1793
- * Stop loading manually
1794
- *
1795
- * @param duration
1796
- */
1797
- stop(duration = 1800) {
1798
- const diffMs = new Date().getTime() - this.lastStartTime;
1799
- if (diffMs >= duration) {
1800
- this.isLoading.next(false);
1801
- return;
1802
- }
1803
- setTimeout(() => {
1804
- this.isLoading.next(false);
1805
- }, duration - diffMs);
1806
- }
1807
- /**
1808
- * Get loader as observable
1809
- */
1810
- getAsObservable() {
1811
- return this.isLoading.asObservable();
1812
- }
1813
- /**
1814
- * Load until observable done
1815
- *
1816
- * @param observable
1817
- * @param duration
1818
- */
1819
- loadUntilObservable(observable, duration = 1800) {
1820
- return new Observable((subscriber) => {
1821
- const startFrom = new Date().getTime();
1822
- this.isLoading.next(true);
1823
- observable.subscribe({
1824
- next: (value) => {
1825
- const diffMs = new Date().getTime() - startFrom;
1826
- if (diffMs >= duration) {
1827
- subscriber.next(value);
1828
- subscriber.complete();
1829
- this.isLoading.next(false);
1830
- return;
1831
- }
1832
- setTimeout(() => {
1833
- subscriber.next(value);
1834
- subscriber.complete();
1835
- this.isLoading.next(false);
1836
- }, duration - diffMs);
1837
- },
1838
- error: (error) => subscriber.error(error),
1839
- });
1840
- });
1841
- }
1842
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: LoaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1843
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: LoaderService, providedIn: 'root' });
1844
- }
1845
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: LoaderService, decorators: [{
1846
- type: Injectable,
1847
- args: [{
1848
- providedIn: 'root',
1849
- }]
1850
- }] });
1851
-
1852
- /**
1853
- * GraphQL plus service, for extra error handling and loading indication
1854
- */
1855
- class GraphQLPlusService extends GraphQLService {
1856
- apollo;
1857
- graphqlMetaService;
1858
- loaderService;
1859
- moduleConfig;
1860
- /**
1861
- * Include services
1862
- */
1863
- constructor(apollo, graphqlMetaService, loaderService, moduleConfig) {
1864
- super(apollo, graphqlMetaService, moduleConfig);
1865
- this.apollo = apollo;
1866
- this.graphqlMetaService = graphqlMetaService;
1867
- this.loaderService = loaderService;
1868
- this.moduleConfig = moduleConfig;
1869
- }
1870
- graphQl(graphql, options = {}) {
1871
- this.handleLoader('start', options);
1872
- return new Observable((subscriber) => {
1873
- super.graphQl(graphql, options).subscribe((response) => {
1874
- if (response && response.errors) {
1875
- this.handleError(response.errors, options.excludedErrors);
1876
- subscriber.error(response);
1877
- this.handleLoader('stop', options);
1878
- subscriber.complete();
1879
- }
1880
- subscriber.next(response);
1881
- this.handleLoader('stop', options);
1882
- if (options.type !== GraphQLRequestType.SUBSCRIPTION) {
1883
- subscriber.complete();
1884
- }
1885
- }, (error) => {
1886
- if (!options.ignoreErrors) {
1887
- this.handleError(error, options.excludedErrors);
1888
- }
1889
- subscriber.error(error);
1890
- this.handleLoader('stop', options);
1891
- subscriber.complete();
1892
- });
1893
- });
1894
- }
1895
- handleLoader(state, options) {
1896
- if (options.loading) {
1897
- if (state === 'start') {
1898
- this.loaderService.start();
1899
- }
1900
- else if (state === 'stop') {
1901
- this.loaderService.stop();
1902
- }
1903
- }
1904
- }
1905
- handleError(error, excludedErrors = null) {
1906
- if (excludedErrors) {
1907
- if (Array.isArray(excludedErrors)) {
1908
- excludedErrors.forEach((excludedError) => {
1909
- if (error.message.includes(excludedError.toLowerCase())) {
1910
- return;
1911
- }
1912
- });
1913
- }
1914
- else if (error.message.toLowerCase().includes(excludedErrors?.toLowerCase())) {
1915
- return;
1916
- }
1917
- }
1918
- this.displayError(error);
1919
- }
1920
- displayError(error) {
1921
- console.error(error);
1922
- }
1923
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLPlusService, deps: [{ token: i1.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }, { token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
1924
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLPlusService, providedIn: 'root' });
1925
- }
1926
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: GraphQLPlusService, decorators: [{
1927
- type: Injectable,
1928
- args: [{
1929
- providedIn: 'root',
1930
- }]
1931
- }], ctorParameters: () => [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: undefined, decorators: [{
1932
- type: Inject,
1933
- args: [BASE_MODULE_CONFIG]
1934
- }] }] });
1935
-
1936
- /**
1937
- * Image service
1938
- */
1939
- class ImageService {
1940
- /**
1941
- * Preaload images (for lazy handling)
1942
- *
1943
- * @param options
1944
- * @protected
1945
- */
1946
- preLoadImages(options) {
1947
- // Init configuration
1948
- const config = {
1949
- doneFunnction: undefined,
1950
- elements: document,
1951
- regExp: undefined,
1952
- ...options,
1953
- };
1954
- return new Promise((resolve) => {
1955
- // Convert element(s) into array
1956
- if (!Array.isArray(config.elements)) {
1957
- // NodeList or HTMLCollection
1958
- if (Helper.isNodeList(config.elements)) {
1959
- config.elements = Array.from(config.elements);
1960
- }
1961
- // Single element
1962
- else {
1963
- config.elements = [config.elements];
1964
- }
1965
- }
1966
- // Init loading
1967
- const promises = [];
1968
- // Get all images
1969
- let images = [];
1970
- config.elements.forEach((element) => {
1971
- images = images.concat(Array.from(element.getElementsByTagName('img')));
1972
- });
1973
- // Prepare images
1974
- for (let image of images) {
1975
- const src = image.getAttribute('src');
1976
- // Check if changes are necessary and possible
1977
- if ((image.complete && image.naturalHeight !== 0) || // already laoded
1978
- !src || // Image has no src
1979
- config.regExp?.test(src) // Test if src matches regular expression
1980
- ) {
1981
- continue;
1982
- }
1983
- // Replace lazy loading image with immediately loading image
1984
- if (image.getAttribute('loading') === 'lazy') {
1985
- const newImage = document.createElement('img');
1986
- Array.from(image.attributes).forEach((attr) => {
1987
- if (attr.name !== 'loading' && attr.name !== 'src') {
1988
- newImage.setAttribute(attr.name, attr.value);
1989
- }
1990
- });
1991
- image.replaceWith(newImage);
1992
- image = newImage;
1993
- }
1994
- // Wait for laoding
1995
- promises.push(this.loadImage(image, src));
1996
- }
1997
- // Wait until all images loaded
1998
- Promise.all(promises)
1999
- .catch((e) => console.error('Error during image loading', e))
2000
- .finally(async () => {
2001
- // Return result
2002
- let result;
2003
- if (config.doneFunnction) {
2004
- result = await config.doneFunction();
2005
- }
2006
- resolve(result);
2007
- });
2008
- });
2009
- }
2010
- /**
2011
- * Load image for image element
2012
- *
2013
- * @param imageElement
2014
- * @param src
2015
- * @protected
2016
- */
2017
- async loadImage(imageElement, src) {
2018
- src = src || imageElement.src;
2019
- return new Promise((resolve, reject) => {
2020
- imageElement.onload = () => resolve(imageElement);
2021
- imageElement.onerror = reject;
2022
- imageElement.src = src;
2023
- });
2024
- }
2025
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2026
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ImageService, providedIn: 'root' });
2027
- }
2028
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ImageService, decorators: [{
2029
- type: Injectable,
2030
- args: [{
2031
- providedIn: 'root',
2032
- }]
2033
- }] });
2034
-
2035
- /**
2036
- * Scroll service for autoscroll to specific fragments
2037
- */
2038
- class ScrollService {
2039
- router;
2040
- moduleConfig;
2041
- imageService;
2042
- /**
2043
- * Current scroll promise
2044
- *
2045
- * @protected
2046
- */
2047
- scrollPromise;
2048
- /**
2049
- * Resolve function of current scroll promise
2050
- *
2051
- * @protected
2052
- */
2053
- scrollPromiseResolve;
2054
- /**
2055
- * Is a scroll listener set
2056
- *
2057
- * @protected
2058
- */
2059
- scrollListener = false;
2060
- /**
2061
- * Current scroll timer;
2062
- *
2063
- * @protected
2064
- */
2065
- scrollTimer = -1;
2066
- /**
2067
- * Scroll offset
2068
- */
2069
- scrollOffset;
2070
- /**
2071
- * Detection offset
2072
- * Should be >= scrollOffset
2073
- */
2074
- detectionOffset;
2075
- /**
2076
- * Sampling rate for scroll done detection
2077
- */
2078
- scrollSamplingRate;
2079
- /**
2080
- * Initializer
2081
- */
2082
- constructor(router, moduleConfig, imageService) {
2083
- this.router = router;
2084
- this.moduleConfig = moduleConfig;
2085
- this.imageService = imageService;
2086
- const config = {
2087
- scrollDetectionOffset: 200,
2088
- scrollOffset: 100,
2089
- scrollSamplingRate: 100,
2090
- ...moduleConfig,
2091
- };
2092
- this.detectionOffset = config.scrollDetectionOffset;
2093
- this.scrollOffset = config.scrollOffset;
2094
- this.scrollSamplingRate = config.scrollSamplingRate;
2095
- }
2096
- /**
2097
- * Scroll to structureElement with specific ID
2098
- */
2099
- async scrollTo(id, options = {}) {
2100
- // Prepare config
2101
- const config = {
2102
- checkUrl: false,
2103
- loadImagesBefore: true,
2104
- resetStyles: false,
2105
- setOverflow: true,
2106
- stopPropagation: true,
2107
- ...options,
2108
- };
2109
- // Check current URL
2110
- if (config.checkUrl && this.router.url !== '/' && !this.router.url.startsWith('/#')) {
2111
- await this.router.navigate(['/'], { fragment: id });
2112
- return !config.stopPropagation;
2113
- }
2114
- // Check if target element exits
2115
- const el = document.getElementById(id);
2116
- if (!el) {
2117
- console.error('Missing scroll element with ID:', id);
2118
- return !config.stopPropagation;
2119
- }
2120
- // Check if body overflow is visible
2121
- // This is necessary for scroll handling
2122
- const body = document.querySelector('body');
2123
- let undoOverflowChanges = false;
2124
- const scrollBodyStyles = JSON.parse(JSON.stringify(window.getComputedStyle(body)));
2125
- if (config.setOverflow && (scrollBodyStyles.overflowX !== 'visible' || scrollBodyStyles.overflowY !== 'visible')) {
2126
- // Set body overflow to visible
2127
- console.warn('Style of body element for overflowX and overflowY will be set to "visible" for scrolling!');
2128
- body.style.overflowX = 'visible';
2129
- body.style.overflowY = 'visible';
2130
- undoOverflowChanges = true;
2131
- }
2132
- // Load images before scrolling (once)
2133
- if (config.loadImagesBefore) {
2134
- await this.imageService.preLoadImages();
2135
- }
2136
- // Get get bounding rect of target element
2137
- const cords = el.getBoundingClientRect();
2138
- // Scroll to element
2139
- window.scrollBy({ top: cords.top - this.scrollOffset, behavior: 'smooth' });
2140
- await this.scrollDone({
2141
- doneFunction: () => {
2142
- // Undo changes
2143
- if (undoOverflowChanges && config.resetStyles) {
2144
- body.style.overflowX = scrollBodyStyles.overflowX;
2145
- body.style.overflowY = scrollBodyStyles.overflowY;
2146
- console.warn('Original style of body element for overflowX and overflowY is set.');
2147
- }
2148
- },
2149
- });
2150
- // Return stop propagation configuration
2151
- return !config.stopPropagation;
2152
- }
2153
- /**
2154
- * Get last active structureElement
2155
- */
2156
- getLastActiveElement(list) {
2157
- const currentScrollPosition = window.scrollY;
2158
- const elementsWithId = document.querySelectorAll('[id]');
2159
- let lastId = null;
2160
- let lastPosition = 0 - this.detectionOffset - 1;
2161
- elementsWithId.forEach((element) => {
2162
- const cords = element.getBoundingClientRect();
2163
- const top = cords.top + window.pageYOffset - this.detectionOffset;
2164
- if ((!list || !list.length || list.includes(element.id)) && // In list
2165
- top < currentScrollPosition && // In active area
2166
- lastPosition < top // Higher than the last one
2167
- ) {
2168
- lastId = element.id;
2169
- lastPosition = top;
2170
- }
2171
- });
2172
- return lastId;
2173
- }
2174
- /**
2175
- * Check if ID is active
2176
- */
2177
- isActive(id, list, isFirst) {
2178
- const lastActiveElement = this.getLastActiveElement(list);
2179
- return id === lastActiveElement || (lastActiveElement === null && isFirst);
2180
- }
2181
- /**
2182
- * Scroll done promise
2183
- */
2184
- async scrollDone(options = {}) {
2185
- // Init configuration
2186
- const config = {
2187
- doneFunction: undefined,
2188
- ...options,
2189
- };
2190
- // Wait for scroll done
2191
- await this.scrollDoneDetection();
2192
- // Get result
2193
- if (config.doneFunction) {
2194
- return config.doneFunction();
2195
- }
2196
- }
2197
- /**
2198
- * Scroll done detecton
2199
- *
2200
- * @protected
2201
- */
2202
- scrollDoneDetection() {
2203
- // Return current scroll promise (Singelton)
2204
- if (this.scrollPromise) {
2205
- return this.scrollPromise;
2206
- }
2207
- // Create current scroll promise
2208
- this.scrollPromise = new Promise((resolve) => {
2209
- this.scrollPromiseResolve = resolve;
2210
- if (this.scrollTimer !== -1) {
2211
- window.clearTimeout(this.scrollTimer);
2212
- }
2213
- this.scrollTimer = window.setTimeout(() => {
2214
- window.removeEventListener('scroll', this.scrollDoneDetection.bind(this));
2215
- this.scrollPromise = undefined;
2216
- resolve();
2217
- }, this.scrollSamplingRate);
2218
- });
2219
- // Lisitening to scroll event;
2220
- window.addEventListener('scroll', this.scrollDoneDetection.bind(this));
2221
- // Return promise
2222
- return this.scrollPromise;
2223
- }
2224
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ScrollService, deps: [{ token: i1$1.Router }, { token: BASE_MODULE_CONFIG }, { token: ImageService }], target: i0.ɵɵFactoryTarget.Injectable });
2225
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ScrollService, providedIn: 'root' });
2226
- }
2227
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ScrollService, decorators: [{
2228
- type: Injectable,
2229
- args: [{
2230
- providedIn: 'root',
2231
- }]
2232
- }], ctorParameters: () => [{ type: i1$1.Router }, { type: undefined, decorators: [{
2233
- type: Inject,
2234
- args: [BASE_MODULE_CONFIG]
2235
- }] }, { type: ImageService }] });
2236
-
2237
- class FormsService {
2238
- document;
2239
- scrollService;
2240
- constructor(document, scrollService) {
2241
- this.document = document;
2242
- this.scrollService = scrollService;
2243
- }
2244
- validateAllFormFields(formGroup) {
2245
- Object.keys(formGroup.controls).forEach((field) => {
2246
- const control = formGroup.get(field);
2247
- if (control instanceof UntypedFormControl) {
2248
- control.markAsTouched({ onlySelf: true });
2249
- }
2250
- else if (control instanceof UntypedFormGroup) {
2251
- this.validateAllFormFields(control);
2252
- }
2253
- });
2254
- }
2255
- findInvalidControls(formGroup) {
2256
- return this.getInvalidControl(formGroup);
2257
- }
2258
- getInvalidControl(formGroup, invalid, parents = []) {
2259
- let result = invalid ? [...invalid] : [];
2260
- let nestedParents = [...[], ...parents];
2261
- const controls = formGroup.controls;
2262
- Object.keys(formGroup.controls).forEach((name) => {
2263
- if (controls[name].invalid) {
2264
- if (controls[name]?.controls) {
2265
- nestedParents.push(name);
2266
- result = this.getInvalidControl(controls[name], result, nestedParents);
2267
- nestedParents = [];
2268
- }
2269
- else {
2270
- result.push(nestedParents.length ? nestedParents.join('.') + '.' + name : name);
2271
- }
2272
- }
2273
- });
2274
- return result;
2275
- }
2276
- scrollToInvalidControl(form) {
2277
- const invalidForm = this.findInvalidControls(form)[0];
2278
- this.scrollService.scrollTo(invalidForm);
2279
- }
2280
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FormsService, deps: [{ token: DOCUMENT }, { token: ScrollService }], target: i0.ɵɵFactoryTarget.Injectable });
2281
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FormsService, providedIn: 'root' });
2282
- }
2283
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FormsService, decorators: [{
2284
- type: Injectable,
2285
- args: [{
2286
- providedIn: 'root',
2287
- }]
2288
- }], ctorParameters: () => [{ type: Document, decorators: [{
2289
- type: Inject,
2290
- args: [DOCUMENT]
2291
- }] }, { type: ScrollService }] });
2292
-
2293
- class UserService extends GraphQLPlusService {
2294
- apollo;
2295
- graphqlMetaService;
2296
- loaderService;
2297
- authService;
2298
- moduleConfig;
2299
- constructor(apollo, graphqlMetaService, loaderService, authService, moduleConfig) {
2300
- super(apollo, graphqlMetaService, loaderService, moduleConfig);
2301
- this.apollo = apollo;
2302
- this.graphqlMetaService = graphqlMetaService;
2303
- this.loaderService = loaderService;
2304
- this.authService = authService;
2305
- this.moduleConfig = moduleConfig;
2306
- }
2307
- /**
2308
- * Login
2309
- *
2310
- * @param input
2311
- */
2312
- login(input) {
2313
- return this.graphQl('signIn', {
2314
- arguments: { input: { ...input, deviceDescription: navigator?.userAgent } },
2315
- fields: ['refreshToken', 'token', { user: ['id', 'firstName', 'lastName', 'email', 'roles', 'avatar'] }],
2316
- loading: true,
2317
- }).pipe(map$1((response) => {
2318
- this.authService.token = response.token;
2319
- this.authService.refreshToken = response.refreshToken;
2320
- this.authService.currentUser = response.user;
2321
- return Auth.map({
2322
- token: response.token,
2323
- refreshToken: response.refreshToken,
2324
- user: BasicUser.map(response.user),
2325
- });
2326
- }));
2327
- }
2328
- /**
2329
- * Register
2330
- *
2331
- * @param input
2332
- */
2333
- register(input) {
2334
- return this.graphQl('signUp', {
2335
- arguments: { input: { ...input, deviceDescription: navigator?.userAgent } },
2336
- fields: ['refreshToken', 'token', { user: ['id', 'firstName', 'lastName', 'email', 'roles', 'avatar'] }],
2337
- loading: true,
2338
- }).pipe(map$1((response) => {
2339
- this.authService.token = response.token;
2340
- this.authService.refreshToken = response.refreshToken;
2341
- this.authService.currentUser = response.user;
2342
- return Auth.map({
2343
- token: response.token,
2344
- refreshToken: response.refreshToken,
2345
- user: BasicUser.map(response.user),
2346
- });
2347
- }));
2348
- }
2349
- /**
2350
- * This function will make a GraphQL query to the server, and return the result
2351
- *
2352
- * @param id - The id of the user you want to get
2353
- * @returns A GraphQLRequest object.
2354
- */
2355
- get(id) {
2356
- return this.graphQl('getUser', {
2357
- arguments: { id },
2358
- fields: ['id', 'firstName', 'lastName', 'email', 'roles', 'avatar'],
2359
- type: GraphQLRequestType.QUERY,
2360
- loading: true,
2361
- });
2362
- }
2363
- /**
2364
- * Request password reset mail
2365
- *
2366
- * @param email
2367
- */
2368
- requestPasswordResetMail(email) {
2369
- return this.graphQl('requestPasswordResetMail', {
2370
- arguments: { email },
2371
- fields: [],
2372
- type: GraphQLRequestType.QUERY,
2373
- loading: true,
2374
- });
2375
- }
2376
- /**
2377
- * Change password of current user
2378
- *
2379
- * @param id
2380
- * @param password
2381
- */
2382
- changePassword(id, password) {
2383
- return this.graphQl('updateUser', {
2384
- arguments: { id, input: { password } },
2385
- fields: ['id'],
2386
- type: GraphQLRequestType.MUTATION,
2387
- loading: true,
2388
- });
2389
- }
2390
- /**
2391
- * Set new password by token
2392
- *
2393
- * @param token
2394
- * @param password
2395
- */
2396
- resetPassword(token, password) {
2397
- return this.graphQl('resetPassword', {
2398
- arguments: { token, password },
2399
- type: GraphQLRequestType.MUTATION,
2400
- loading: true,
2401
- });
2402
- }
2403
- /**
2404
- * Delete user by id
2405
- *
2406
- * @param id
2407
- */
2408
- delete(id) {
2409
- return this.graphQl('deleteUser', {
2410
- arguments: { id },
2411
- fields: ['id'],
2412
- type: GraphQLRequestType.MUTATION,
2413
- loading: true,
2414
- });
2415
- }
2416
- /**
2417
- * Verify user by token
2418
- *
2419
- * @param token
2420
- */
2421
- verifyUser(token) {
2422
- return this.graphQl('verifyUser', {
2423
- arguments: { token },
2424
- type: GraphQLRequestType.MUTATION,
2425
- loading: true,
2426
- });
2427
- }
2428
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: UserService, deps: [{ token: i1.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }, { token: AuthService }, { token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
2429
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: UserService, providedIn: 'root' });
2430
- }
2431
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: UserService, decorators: [{
2432
- type: Injectable,
2433
- args: [{
2434
- providedIn: 'root',
2435
- }]
2436
- }], ctorParameters: () => [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }, { type: undefined, decorators: [{
2437
- type: Inject,
2438
- args: [BASE_MODULE_CONFIG]
2439
- }] }] });
2440
-
2441
- class ToastService {
2442
- toastsObservables = new BehaviorSubject([]);
2443
- get toastsAsObservable() {
2444
- return this.toastsObservables.asObservable();
2445
- }
2446
- /**
2447
- * Show new toast
2448
- *
2449
- * @param toast
2450
- * @param duration
2451
- */
2452
- show(toast, duration = 2300) {
2453
- const value = this.toastsObservables.value;
2454
- value.push(toast);
2455
- this.toastsObservables.next(value);
2456
- if (duration) {
2457
- setTimeout(() => {
2458
- const currentToasts = this.toastsObservables.value;
2459
- const foundIndex = currentToasts.findIndex((e) => e.id === toast.id);
2460
- if (foundIndex > -1) {
2461
- currentToasts.splice(foundIndex, 1);
2462
- this.toastsObservables.next(currentToasts);
2463
- }
2464
- }, duration);
2465
- }
2466
- }
2467
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2468
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ToastService, providedIn: 'root' });
2469
- }
2470
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: ToastService, decorators: [{
2471
- type: Injectable,
2472
- args: [{
2473
- providedIn: 'root',
2474
- }]
2475
- }] });
2476
-
2477
- class BreadcrumbService {
2478
- router;
2479
- _breadcrumbs = new BehaviorSubject([]);
2480
- set breadcrumbs(value) {
2481
- this._breadcrumbs.next(value);
2482
- }
2483
- get breadcrumbsObservable() {
2484
- return this._breadcrumbs.asObservable();
2485
- }
2486
- constructor(router) {
2487
- this.router = router;
2488
- this.subscribeToRouteChanges();
2489
- }
2490
- /**
2491
- * Subscribe to route changes and add element to breadcrumb
2492
- */
2493
- subscribeToRouteChanges() {
2494
- this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe((event) => {
2495
- const root = this.router.routerState.snapshot.root;
2496
- const breadcrumbs = [];
2497
- this.addBreadcrumb(root, [], breadcrumbs);
2498
- this.breadcrumbs = breadcrumbs;
2499
- });
2500
- }
2501
- /**
2502
- * Add element to breadcrumb
2503
- *
2504
- * @param route
2505
- * @param parentUrl
2506
- * @param breadcrumbs
2507
- * @private
2508
- */
2509
- addBreadcrumb(route, parentUrl, breadcrumbs) {
2510
- if (route) {
2511
- const routeUrl = parentUrl.concat(route.url.map((url) => url.path));
2512
- if (route.data?.breadcrumb) {
2513
- const breadcrumb = {
2514
- label: this.getLabel(route.data),
2515
- url: '/' + routeUrl.join('/'),
2516
- };
2517
- breadcrumbs.push(breadcrumb);
2518
- }
2519
- this.addBreadcrumb(route.firstChild, routeUrl, breadcrumbs);
2520
- }
2521
- }
2522
- /**
2523
- * Get label for breadcrumb
2524
- *
2525
- * @param data
2526
- * @private
2527
- */
2528
- getLabel(data) {
2529
- return typeof data.breadcrumb === 'function' ? data.breadcrumb(data) : data.breadcrumb;
2530
- }
2531
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: BreadcrumbService, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2532
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: BreadcrumbService, providedIn: 'root' });
2533
- }
2534
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: BreadcrumbService, decorators: [{
2535
- type: Injectable,
2536
- args: [{
2537
- providedIn: 'root',
2538
- }]
2539
- }], ctorParameters: () => [{ type: i1$1.Router }] });
2540
-
2541
- class NavigationService {
2542
- router;
2543
- location;
2544
- history = [];
2545
- constructor(router, location) {
2546
- this.router = router;
2547
- this.location = location;
2548
- this.router.events.subscribe((event) => {
2549
- if (event instanceof NavigationEnd) {
2550
- this.history.push(event.urlAfterRedirects);
2551
- }
2552
- });
2553
- }
2554
- /**
2555
- * If the history stack is empty, navigate to the home page, otherwise go back to the previous page
2556
- */
2557
- back() {
2558
- this.history.pop();
2559
- if (this.history.length > 0) {
2560
- this.location.back();
2561
- }
2562
- else {
2563
- this.router.navigateByUrl('/');
2564
- }
2565
- }
2566
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NavigationService, deps: [{ token: i1$1.Router }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
2567
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NavigationService, providedIn: 'root' });
2568
- }
2569
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: NavigationService, decorators: [{
2570
- type: Injectable,
2571
- args: [{ providedIn: 'root' }]
2572
- }], ctorParameters: () => [{ type: i1$1.Router }, { type: i2.Location }] });
2573
-
2574
- class CmsService {
2575
- graphQLService;
2576
- constructor(graphQLService) {
2577
- this.graphQLService = graphQLService;
2578
- }
2579
- /**
2580
- * It calls the graphQLService to delete the object with the id of the object that is currently being edited
2581
- */
2582
- deleteObject(id, modelName) {
2583
- return new Promise((resolve, reject) => {
2584
- if (confirm('Möchtest du das Objekt wirklich löschen?')) {
2585
- this.graphQLService
2586
- .graphQl('delete' + this.capitalizeFirstLetter(modelName), {
2587
- arguments: { id },
2588
- fields: ['id'],
2589
- type: GraphQLRequestType.MUTATION,
2590
- })
2591
- .subscribe({
2592
- next: (value) => {
2593
- resolve(value);
2594
- },
2595
- error: (err) => {
2596
- reject(err);
2597
- console.error('Error on delete object', err);
2598
- },
2599
- });
2600
- }
2601
- });
2602
- }
2603
- /**
2604
- * It sends a GraphQL mutation to the server to duplicate the object
2605
- */
2606
- async duplicateObject(id, modelName) {
2607
- return new Promise((resolve, reject) => {
2608
- if (confirm('Möchtest du das Objekt wirklich duplizieren?')) {
2609
- this.graphQLService
2610
- .graphQl('duplicate' + this.capitalizeFirstLetter(modelName), {
2611
- arguments: { id },
2612
- fields: ['id'],
2613
- type: GraphQLRequestType.MUTATION,
2614
- })
2615
- .subscribe({
2616
- next: (value) => {
2617
- resolve(value);
2618
- },
2619
- error: (err) => {
2620
- reject(err);
2621
- console.error('Error on duplicate object', err);
2622
- },
2623
- });
2624
- }
2625
- });
2626
- }
2627
- /**
2628
- * It takes a string, capitalizes the first letter, and returns the modified string
2629
- *
2630
- * @param value - The string to capitalize.
2631
- * @returns The first letter of the string is being capitalized and the rest of the string is being returned.
2632
- */
2633
- capitalizeFirstLetter(value) {
2634
- return value.charAt(0).toUpperCase() + value.slice(1);
2635
- }
2636
- /**
2637
- * Transform first letter to lowercase
2638
- */
2639
- lowerCaseFirstLetter(value) {
2640
- return value.charAt(0).toLowerCase() + value.slice(1);
2641
- }
2642
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: CmsService, deps: [{ token: GraphQLService }], target: i0.ɵɵFactoryTarget.Injectable });
2643
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: CmsService, providedIn: 'root' });
2644
- }
2645
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: CmsService, decorators: [{
2646
- type: Injectable,
2647
- args: [{
2648
- providedIn: 'root',
2649
- }]
2650
- }], ctorParameters: () => [{ type: GraphQLService }] });
2651
-
2652
- class FileService {
2653
- authService;
2654
- httpClient;
2655
- constructor(authService, httpClient) {
2656
- this.authService = authService;
2657
- this.httpClient = httpClient;
2658
- }
2659
- /**
2660
- * Compress file with options and return file
2661
- */
2662
- compress(file, options) {
2663
- const config = {
2664
- quality: 0.6,
2665
- checkOrientation: false,
2666
- ...options,
2667
- };
2668
- return new Promise((resolve, reject) => {
2669
- new Compressor(file, {
2670
- success(result) {
2671
- // Check if result is blob for convert to file
2672
- if (result instanceof Blob) {
2673
- resolve(new File([result], result.name));
2674
- }
2675
- else {
2676
- resolve(result);
2677
- }
2678
- },
2679
- error(err) {
2680
- reject(err.message);
2681
- },
2682
- ...config,
2683
- });
2684
- });
2685
- }
2686
- /**
2687
- * Upload file to server
2688
- */
2689
- async upload(url, path, file, compressOptions) {
2690
- return new Promise(async (resolve, reject) => {
2691
- if (compressOptions) {
2692
- file = await this.compress(file, compressOptions);
2693
- }
2694
- const data = new FormData();
2695
- data.append('file', file);
2696
- const httpOptions = {
2697
- headers: new HttpHeaders({
2698
- Authorization: 'Bearer ' + this.authService.token,
2699
- }),
2700
- };
2701
- this.httpClient.post(url + path, data, httpOptions).subscribe((result) => {
2702
- resolve(result);
2703
- }, (err) => {
2704
- reject(err);
2705
- });
2706
- });
2707
- }
2708
- delete(url, path, id) {
2709
- return new Promise(async (resolve, reject) => {
2710
- const httpOptions = {
2711
- headers: new HttpHeaders({
2712
- Authorization: 'Bearer ' + this.authService.token,
2713
- }),
2714
- };
2715
- this.httpClient.delete(url + path + id, httpOptions).subscribe((result) => {
2716
- resolve(result);
2717
- }, (err) => {
2718
- reject(err);
2719
- });
2720
- });
2721
- }
2722
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FileService, deps: [{ token: AuthService }, { token: i2$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
2723
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FileService, providedIn: 'root' });
2724
- }
2725
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: FileService, decorators: [{
2726
- type: Injectable,
2727
- args: [{
2728
- providedIn: 'root',
2729
- }]
2730
- }], ctorParameters: () => [{ type: AuthService }, { type: i2$1.HttpClient }] });
2731
-
2732
- /**
2733
- * Comparison operator enum
2734
- */
2735
- var ComparisonOperatorEnum;
2736
- (function (ComparisonOperatorEnum) {
2737
- ComparisonOperatorEnum["EQ"] = "EQ";
2738
- ComparisonOperatorEnum["GT"] = "GT";
2739
- ComparisonOperatorEnum["GTE"] = "GTE";
2740
- ComparisonOperatorEnum["IN"] = "IN";
2741
- ComparisonOperatorEnum["LT"] = "LT";
2742
- ComparisonOperatorEnum["LTE"] = "LTE";
2743
- ComparisonOperatorEnum["NE"] = "NE";
2744
- ComparisonOperatorEnum["NIN"] = "NIN";
2745
- ComparisonOperatorEnum["REGEX"] = "REGEX";
2746
- })(ComparisonOperatorEnum || (ComparisonOperatorEnum = {}));
2747
-
2748
- /**
2749
- * Logical operator enum
2750
- */
2751
- var LogicalOperatorEnum;
2752
- (function (LogicalOperatorEnum) {
2753
- LogicalOperatorEnum["AND"] = "AND";
2754
- LogicalOperatorEnum["NOR"] = "NOR";
2755
- LogicalOperatorEnum["OR"] = "OR";
2756
- })(LogicalOperatorEnum || (LogicalOperatorEnum = {}));
2757
-
2758
- var SortOrderEnum;
2759
- (function (SortOrderEnum) {
2760
- SortOrderEnum["ASC"] = "ASC";
2761
- SortOrderEnum["DESC"] = "DESC";
2762
- })(SortOrderEnum || (SortOrderEnum = {}));
2763
-
2764
- var ToastType;
2765
- (function (ToastType) {
2766
- ToastType["ERROR"] = "error";
2767
- ToastType["WARNING"] = "warning";
2768
- ToastType["INFO"] = "info";
2769
- ToastType["SUCCESS"] = "success";
2770
- })(ToastType || (ToastType = {}));
2771
-
2772
- var SkeletonType;
2773
- (function (SkeletonType) {
2774
- SkeletonType["LINE"] = "LINE";
2775
- SkeletonType["RECTANGLE"] = "RECTANGLE";
2776
- SkeletonType["AVATAR"] = "AVATAR";
2777
- })(SkeletonType || (SkeletonType = {}));
2778
-
2779
- class Validation {
2780
- static match(controlName, checkControlName) {
2781
- return (controls) => {
2782
- const control = controls.get(controlName);
2783
- const checkControl = controls.get(checkControlName);
2784
- if (checkControl?.errors && !checkControl.errors?.matching) {
2785
- return null;
2786
- }
2787
- if (control?.value !== checkControl?.value) {
2788
- controls.get(checkControlName)?.setErrors({ matching: true });
2789
- return { matching: true };
2790
- }
2791
- else {
2792
- if (controls.get(checkControlName)?.errors && controls.get(checkControlName)?.errors['matching']) {
2793
- delete controls.get(checkControlName)?.errors['matching'];
2794
- }
2795
- return null;
2796
- }
2797
- };
2798
- }
2799
- }
2800
-
2801
- function fullEmail() {
2802
- return (control) => {
2803
- const EMAIL_REGEXP = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
2804
- return !EMAIL_REGEXP.test(control.value) ? { invalidEmail: true } : null;
2805
- };
2806
- }
2807
-
2808
- function securePasswordValidator() {
2809
- return (control) => {
2810
- const PASSWORD_REGEX = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9]).{8,}$/i;
2811
- return !PASSWORD_REGEX.test(control.value) ? { invalidSecurePassword: true } : null;
2812
- };
2813
- }
2814
-
2815
- function createRestartableClient(options) {
2816
- let restartRequested = false;
2817
- let restart = () => {
2818
- restartRequested = true;
2819
- };
2820
- const { on = undefined } = options;
2821
- const client = createClient({
2822
- ...options,
2823
- on: {
2824
- ...on,
2825
- connected: (socket) => {
2826
- // @ts-ignore
2827
- on?.connected?.(socket);
2828
- restart = () => {
2829
- if (socket.readyState === WebSocket.OPEN) {
2830
- // if the socket is still open for the restart, do the restart
2831
- socket.close(4205, 'Client Restart');
2832
- }
2833
- else {
2834
- // otherwise the socket might've closed, indicate that you want
2835
- // a restart on the next connected event
2836
- restartRequested = true;
2837
- }
2838
- };
2839
- // just in case you were eager to restart
2840
- if (restartRequested) {
2841
- restartRequested = false;
2842
- restart();
2843
- }
2844
- },
2845
- },
2846
- });
2847
- return {
2848
- ...client,
2849
- restart: () => restart(),
2850
- };
2851
- }
2852
-
2853
- /**
2854
- * Exports for public API
2855
- */
2856
- // Classes
2857
-
2858
- /**
2859
- * Generated bundle index. Do not edit.
2860
- */
2861
-
2862
- export { Auth, AuthService, BASE_MODULE_CONFIG, BasicUser, BreadcrumbService, CmsService, ComparisonOperatorEnum, FileService, FormsService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LoaderService, LogicalOperatorEnum, NavigationService, ScrollService, SkeletonType, Sort, SortOrderEnum, Standard, StorageService, ToastService, ToastType, UserService, Validation, WsService, createRestartableClient, debounce, fullEmail, securePasswordValidator };
2863
- //# sourceMappingURL=lenne.tech-ng-base-shared.mjs.map