@lenne.tech/ng-base 15.0.0-beta-3 → 16.1.0

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