@lenne.tech/ng-base 13.6.5 → 13.6.6

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 (165) hide show
  1. package/base-components/components/checkbox/checkbox.component.d.ts +1 -1
  2. package/base-prototype/base-prototype.module.d.ts +6 -5
  3. package/base-prototype/pages/forgot-password/forgot-password.component.d.ts +7 -2
  4. package/base-prototype/pages/login/login.component.d.ts +8 -2
  5. package/base-prototype/pages/register/register.component.d.ts +8 -2
  6. package/esm2020/base-components/components/checkbox/checkbox.component.mjs +3 -3
  7. package/esm2020/base-components/components/input/input.component.mjs +3 -3
  8. package/esm2020/base-prototype/base-prototype.module.mjs +5 -4
  9. package/esm2020/base-prototype/pages/forgot-password/forgot-password.component.mjs +30 -9
  10. package/esm2020/base-prototype/pages/login/login.component.mjs +46 -9
  11. package/esm2020/base-prototype/pages/register/register.component.mjs +45 -11
  12. package/esm2020/public-api.mjs +1 -42
  13. package/esm2020/shared/classes/auth.class.mjs +16 -0
  14. package/esm2020/shared/classes/basic-user.class.mjs +51 -0
  15. package/esm2020/shared/classes/graphql-enum.class.mjs +9 -0
  16. package/esm2020/shared/classes/graphql-meta.class.mjs +171 -0
  17. package/esm2020/shared/classes/graphql-type.class.mjs +13 -0
  18. package/esm2020/shared/classes/helper.class.mjs +304 -0
  19. package/esm2020/shared/classes/standard.class.mjs +40 -0
  20. package/esm2020/{src → shared}/enums/comparison-operator.enum.mjs +1 -1
  21. package/esm2020/shared/enums/graphql-request-type.enum.mjs +10 -0
  22. package/esm2020/shared/enums/logical-operator.enum.mjs +10 -0
  23. package/esm2020/shared/enums/sort-order.enum.mjs +6 -0
  24. package/esm2020/shared/functions/ws-client.function.mjs +39 -0
  25. package/esm2020/shared/interfaces/base-module-config.interface.mjs +3 -0
  26. package/esm2020/shared/interfaces/can-component-deactivate.interface.mjs +2 -0
  27. package/esm2020/shared/interfaces/combined-filter-input.interface.mjs +2 -0
  28. package/esm2020/shared/interfaces/field-object.interface.mjs +2 -0
  29. package/esm2020/shared/interfaces/field.interface.mjs +2 -0
  30. package/esm2020/shared/interfaces/filter-input.interface.mjs +2 -0
  31. package/esm2020/shared/interfaces/find-args.interface.mjs +2 -0
  32. package/esm2020/shared/interfaces/graphql-fields-object.interface.mjs +2 -0
  33. package/esm2020/shared/interfaces/graphql-options.interface.mjs +2 -0
  34. package/esm2020/shared/interfaces/graphql-plus-options.interfacen.mjs +2 -0
  35. package/esm2020/shared/interfaces/graphql-type-collection.interface.mjs +2 -0
  36. package/esm2020/shared/interfaces/single-filter-input.interface.mjs +2 -0
  37. package/esm2020/shared/interfaces/sort-input.interface.mjs +2 -0
  38. package/esm2020/shared/interfaces/time-components.interface.mjs +2 -0
  39. package/esm2020/shared/lenne.tech-ng-base-shared.mjs +5 -0
  40. package/esm2020/shared/public-api.mjs +51 -0
  41. package/esm2020/shared/services/auth.service.mjs +71 -0
  42. package/esm2020/shared/services/forms.service.mjs +25 -0
  43. package/esm2020/shared/services/graphql-meta.service.mjs +123 -0
  44. package/esm2020/shared/services/graphql-plus.service.mjs +84 -0
  45. package/esm2020/shared/services/graphql.service.mjs +441 -0
  46. package/esm2020/shared/services/image.service.mjs +102 -0
  47. package/esm2020/shared/services/loader.service.mjs +29 -0
  48. package/esm2020/shared/services/scroll.service.mjs +179 -0
  49. package/esm2020/shared/services/storage.service.mjs +132 -0
  50. package/esm2020/shared/services/user.service.mjs +82 -0
  51. package/esm2020/shared/services/ws.service.mjs +16 -0
  52. package/esm2020/shared/types/graphql-fields.type.mjs +2 -0
  53. package/esm2020/shared/types/storage.type.mjs +2 -0
  54. package/esm2020/shared/validators/match.validator.mjs +19 -0
  55. package/esm2020/src/base.module.mjs +14 -11
  56. package/esm2020/src/directives/match-height.directive.mjs +2 -2
  57. package/esm2020/src/factories/apollo-options.factory.mjs +14 -12
  58. package/esm2020/src/guards/auth.guard.mjs +3 -3
  59. package/esm2020/src/guards/can-deactivate.guard.mjs +1 -1
  60. package/esm2020/src/guards/logout.guard.mjs +2 -2
  61. package/esm2020/src/services/theme.service.mjs +2 -2
  62. package/fesm2015/lenne.tech-ng-base-base-components.mjs +4 -4
  63. package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
  64. package/fesm2015/lenne.tech-ng-base-base-prototype.mjs +113 -22
  65. package/fesm2015/lenne.tech-ng-base-base-prototype.mjs.map +1 -1
  66. package/fesm2015/lenne.tech-ng-base-shared.mjs +1878 -0
  67. package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -0
  68. package/fesm2015/lenne.tech-ng-base.mjs +57 -1799
  69. package/fesm2015/lenne.tech-ng-base.mjs.map +1 -1
  70. package/fesm2020/lenne.tech-ng-base-base-components.mjs +4 -4
  71. package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
  72. package/fesm2020/lenne.tech-ng-base-base-prototype.mjs +111 -22
  73. package/fesm2020/lenne.tech-ng-base-base-prototype.mjs.map +1 -1
  74. package/fesm2020/lenne.tech-ng-base-shared.mjs +1939 -0
  75. package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -0
  76. package/fesm2020/lenne.tech-ng-base.mjs +57 -1854
  77. package/fesm2020/lenne.tech-ng-base.mjs.map +1 -1
  78. package/package.json +10 -2
  79. package/public-api.d.ts +0 -36
  80. package/shared/classes/auth.class.d.ts +9 -0
  81. package/{src → shared}/classes/basic-user.class.d.ts +0 -0
  82. package/{src → shared}/classes/graphql-enum.class.d.ts +0 -0
  83. package/{src → shared}/classes/graphql-meta.class.d.ts +0 -0
  84. package/{src → shared}/classes/graphql-type.class.d.ts +0 -0
  85. package/{src → shared}/classes/helper.class.d.ts +0 -0
  86. package/{src → shared}/classes/standard.class.d.ts +0 -0
  87. package/{src → shared}/enums/comparison-operator.enum.d.ts +0 -0
  88. package/{src → shared}/enums/graphql-request-type.enum.d.ts +0 -0
  89. package/{src → shared}/enums/logical-operator.enum.d.ts +0 -0
  90. package/{src → shared}/enums/sort-order.enum.d.ts +0 -0
  91. package/shared/functions/ws-client.function.d.ts +5 -0
  92. package/{src → shared}/interfaces/base-module-config.interface.d.ts +1 -1
  93. package/{src → shared}/interfaces/can-component-deactivate.interface.d.ts +0 -0
  94. package/{src → shared}/interfaces/combined-filter-input.interface.d.ts +0 -0
  95. package/{src → shared}/interfaces/field-object.interface.d.ts +0 -0
  96. package/{src → shared}/interfaces/field.interface.d.ts +0 -0
  97. package/{src → shared}/interfaces/filter-input.interface.d.ts +0 -0
  98. package/{src → shared}/interfaces/find-args.interface.d.ts +0 -0
  99. package/{src → shared}/interfaces/graphql-fields-object.interface.d.ts +0 -0
  100. package/{src → shared}/interfaces/graphql-options.interface.d.ts +0 -0
  101. package/{src → shared}/interfaces/graphql-plus-options.interfacen.d.ts +0 -0
  102. package/{src → shared}/interfaces/graphql-type-collection.interface.d.ts +0 -0
  103. package/{src → shared}/interfaces/single-filter-input.interface.d.ts +0 -0
  104. package/{src → shared}/interfaces/sort-input.interface.d.ts +0 -0
  105. package/shared/interfaces/time-components.interface.d.ts +6 -0
  106. package/shared/lenne.tech-ng-base-shared.d.ts +5 -0
  107. package/shared/package.json +10 -0
  108. package/shared/public-api.d.ts +43 -0
  109. package/{src → shared}/services/auth.service.d.ts +0 -0
  110. package/{src → shared}/services/forms.service.d.ts +0 -1
  111. package/{src → shared}/services/graphql-meta.service.d.ts +0 -0
  112. package/{src → shared}/services/graphql-plus.service.d.ts +0 -0
  113. package/{src → shared}/services/graphql.service.d.ts +0 -0
  114. package/{src → shared}/services/image.service.d.ts +0 -0
  115. package/{src → shared}/services/loader.service.d.ts +0 -0
  116. package/{src → shared}/services/scroll.service.d.ts +0 -0
  117. package/{src → shared}/services/storage.service.d.ts +0 -0
  118. package/shared/services/user.service.d.ts +42 -0
  119. package/{src → shared}/services/ws.service.d.ts +2 -2
  120. package/{src → shared}/types/graphql-fields.type.d.ts +0 -0
  121. package/{src → shared}/types/storage.type.d.ts +0 -0
  122. package/shared/validators/match.validator.d.ts +4 -0
  123. package/src/base.module.d.ts +4 -2
  124. package/src/directives/match-height.directive.d.ts +1 -1
  125. package/src/factories/apollo-options.factory.d.ts +1 -3
  126. package/src/guards/auth.guard.d.ts +1 -2
  127. package/src/guards/can-deactivate.guard.d.ts +1 -1
  128. package/src/guards/logout.guard.d.ts +1 -1
  129. package/src/services/theme.service.d.ts +1 -1
  130. package/esm2020/src/classes/basic-user.class.mjs +0 -51
  131. package/esm2020/src/classes/graphql-enum.class.mjs +0 -9
  132. package/esm2020/src/classes/graphql-meta.class.mjs +0 -171
  133. package/esm2020/src/classes/graphql-type.class.mjs +0 -13
  134. package/esm2020/src/classes/helper.class.mjs +0 -304
  135. package/esm2020/src/classes/standard.class.mjs +0 -40
  136. package/esm2020/src/enums/graphql-request-type.enum.mjs +0 -10
  137. package/esm2020/src/enums/logical-operator.enum.mjs +0 -10
  138. package/esm2020/src/enums/sort-order.enum.mjs +0 -6
  139. package/esm2020/src/interfaces/base-module-config.interface.mjs +0 -3
  140. package/esm2020/src/interfaces/can-component-deactivate.interface.mjs +0 -2
  141. package/esm2020/src/interfaces/combined-filter-input.interface.mjs +0 -2
  142. package/esm2020/src/interfaces/field-object.interface.mjs +0 -2
  143. package/esm2020/src/interfaces/field.interface.mjs +0 -2
  144. package/esm2020/src/interfaces/filter-input.interface.mjs +0 -2
  145. package/esm2020/src/interfaces/find-args.interface.mjs +0 -2
  146. package/esm2020/src/interfaces/graphql-fields-object.interface.mjs +0 -2
  147. package/esm2020/src/interfaces/graphql-options.interface.mjs +0 -2
  148. package/esm2020/src/interfaces/graphql-plus-options.interfacen.mjs +0 -2
  149. package/esm2020/src/interfaces/graphql-type-collection.interface.mjs +0 -2
  150. package/esm2020/src/interfaces/single-filter-input.interface.mjs +0 -2
  151. package/esm2020/src/interfaces/sort-input.interface.mjs +0 -2
  152. package/esm2020/src/services/auth.service.mjs +0 -71
  153. package/esm2020/src/services/forms.service.mjs +0 -26
  154. package/esm2020/src/services/graphql-meta.service.mjs +0 -123
  155. package/esm2020/src/services/graphql-plus.service.mjs +0 -84
  156. package/esm2020/src/services/graphql.service.mjs +0 -441
  157. package/esm2020/src/services/image.service.mjs +0 -102
  158. package/esm2020/src/services/loader.service.mjs +0 -29
  159. package/esm2020/src/services/scroll.service.mjs +0 -179
  160. package/esm2020/src/services/storage.service.mjs +0 -132
  161. package/esm2020/src/services/ws.service.mjs +0 -17
  162. package/esm2020/src/types/graphql-fields.type.mjs +0 -2
  163. package/esm2020/src/types/storage.type.mjs +0 -2
  164. package/esm2020/src/validators/must-match.validator.mjs +0 -22
  165. package/src/validators/must-match.validator.d.ts +0 -6
@@ -1,245 +1,27 @@
1
- import * as i1$2 from 'apollo-angular';
2
- import { APOLLO_OPTIONS, gql } from 'apollo-angular';
1
+ import { APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
3
2
  import { HttpLink } from 'apollo-angular/http';
4
3
  import * as i0 from '@angular/core';
5
- import { InjectionToken, Injectable, Inject, Directive, Input, Output, HostBinding, PLATFORM_ID, HostListener, Pipe, NgModule } from '@angular/core';
6
- import { BehaviorSubject, Observable, of, throwError } from 'rxjs';
4
+ import { Directive, Input, Output, HostBinding, PLATFORM_ID, Inject, HostListener, Pipe, NgModule, Injectable } from '@angular/core';
7
5
  import { ApolloLink, split, concat } from '@apollo/client/core';
8
6
  import { InMemoryCache } from '@apollo/client/cache';
9
- import { WebSocketLink } from '@apollo/client/link/ws';
10
7
  import { getMainDefinition } from '@apollo/client/utilities';
8
+ import * as i2 from '@lenne.tech/ng-base/shared';
9
+ import { createRestartableClient, BASE_MODULE_CONFIG, AuthService, WsService } from '@lenne.tech/ng-base/shared';
10
+ import { GraphQLWsLink } from '@apollo/client/link/subscriptions';
11
11
  import { __awaiter } from 'tslib';
12
12
  import { isPlatformBrowser } from '@angular/common';
13
13
  import * as i1 from '@angular/platform-browser';
14
+ import { HttpClientModule } from '@angular/common/http';
15
+ import { Observable, BehaviorSubject } from 'rxjs';
14
16
  import * as i1$1 from '@angular/router';
15
- import { FormControl, FormGroup } from '@angular/forms';
16
- import { buildClientSchema, getIntrospectionQuery } from 'graphql';
17
- import { map } from 'rxjs/operators';
18
-
19
- const BASE_MODULE_CONFIG = new InjectionToken('BASE_MODULE_CONFIG');
20
-
21
- /**
22
- * Storage service for local data storage
23
- */
24
- class StorageService {
25
- /**
26
- * Initializations
27
- */
28
- constructor(moduleConfig) {
29
- this.moduleConfig = moduleConfig;
30
- /**
31
- * Storage
32
- */
33
- this.storage = null;
34
- /**
35
- * Prefix for storage keys
36
- */
37
- this.prefix = '';
38
- // Set storage
39
- const type = moduleConfig.storageType ? moduleConfig.storageType : 'local';
40
- if (window[type + 'Storage']) {
41
- this.storage = window[type + 'Storage'];
42
- }
43
- // Set prefix
44
- this.prefix = '';
45
- if (moduleConfig.prefix) {
46
- this.prefix += moduleConfig.prefix + '_';
47
- }
48
- if (moduleConfig.version) {
49
- this.prefix += moduleConfig.version + '_';
50
- }
51
- }
52
- /**
53
- * Save itemKeys
54
- *
55
- * If you want to save one item, use itemKeys and value parameters like these:
56
- * save('KEY_OF_THE_ITEM', ITEM)
57
- *
58
- * If you want to save multiple items, use itemKeys only (value parameter will be ignored):
59
- * save({'KEY_OF_ITEM_1': ITEM_1, 'KEY_OF_ITEM_2': ITEM_2, ...})
60
- */
61
- save(itemKeys, value) {
62
- // Check local storage
63
- if (!this.storage) {
64
- return false;
65
- }
66
- // Check item keys and value
67
- if (!itemKeys ||
68
- (typeof itemKeys === 'object' && !Object.keys(itemKeys).length) ||
69
- (typeof itemKeys === 'string' && value === undefined)) {
70
- return false;
71
- }
72
- if (typeof itemKeys === 'object') {
73
- for (const [itemKey, itemValue] of Object.entries(itemKeys)) {
74
- this.storage.setItem(this.prefix + itemKey, JSON.stringify(itemValue));
75
- }
76
- return true;
77
- }
78
- this.storage.setItem(this.prefix + itemKeys, JSON.stringify(value));
79
- return true;
80
- }
81
- /**
82
- * Load items via key(s)
83
- */
84
- load(itemKeys) {
85
- // Check local storage
86
- if (!this.storage) {
87
- return;
88
- }
89
- // Check item keys
90
- if (!itemKeys || (Array.isArray(itemKeys) && !itemKeys.length)) {
91
- return null;
92
- }
93
- if (Array.isArray(itemKeys)) {
94
- const back = {};
95
- itemKeys.forEach((itemKey) => {
96
- const loadedItem = this.storage.getItem(this.prefix + itemKey);
97
- if (loadedItem) {
98
- back[itemKey] = JSON.parse(loadedItem);
99
- }
100
- else {
101
- back[itemKey] = null;
102
- }
103
- });
104
- return back;
105
- }
106
- let value = this.storage.getItem(this.prefix + itemKeys);
107
- if (value) {
108
- value = JSON.parse(value);
109
- }
110
- return value;
111
- }
112
- /**
113
- * Remove item from storage
114
- *
115
- * @param itemKeys keys or key to remove
116
- */
117
- remove(itemKeys) {
118
- // Check local storage
119
- if (!this.storage) {
120
- return false;
121
- }
122
- if (Array.isArray(itemKeys)) {
123
- itemKeys.forEach((key) => {
124
- this.storage.removeItem(this.prefix + key);
125
- });
126
- return true;
127
- }
128
- this.storage.removeItem(this.prefix + itemKeys);
129
- return true;
130
- }
131
- /**
132
- * Clear local storage
133
- */
134
- reset() {
135
- this.storage.clear();
136
- }
137
- }
138
- StorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: StorageService, deps: [{ token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
139
- StorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: StorageService, providedIn: 'root' });
140
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: StorageService, decorators: [{
141
- type: Injectable,
142
- args: [{
143
- providedIn: 'root',
144
- }]
145
- }], ctorParameters: function () {
146
- return [{ type: undefined, decorators: [{
147
- type: Inject,
148
- args: [BASE_MODULE_CONFIG]
149
- }] }];
150
- } });
151
-
152
- class WsService {
153
- reconnect() {
154
- var _a, _b;
155
- (_a = this.client) === null || _a === void 0 ? void 0 : _a.close();
156
- (_b = this.client) === null || _b === void 0 ? void 0 : _b.connect();
157
- }
158
- }
159
- WsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: WsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
160
- WsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: WsService, providedIn: 'root' });
161
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: WsService, decorators: [{
162
- type: Injectable,
163
- args: [{
164
- providedIn: 'root',
165
- }]
166
- }] });
167
-
168
- /**
169
- * Authentication service
170
- */
171
- class AuthService {
172
- /**
173
- * Constructor
174
- */
175
- constructor(moduleConfig, storageService, wsService) {
176
- this.moduleConfig = moduleConfig;
177
- this.storageService = storageService;
178
- this.wsService = wsService;
179
- // Subjects
180
- this._currentUser = new BehaviorSubject(null);
181
- this._token = new BehaviorSubject(null);
182
- this.token = this.storageService.load('token');
183
- this.currentUser = this.storageService.load('currentUser');
184
- }
185
- /**
186
- * Logout
187
- */
188
- logout() {
189
- this.storageService.remove(['token', 'currentUser']);
190
- this.currentUser = null;
191
- this.token = null;
192
- }
193
- // #################################################################
194
- // Current User
195
- // #################################################################
196
- get currentUser() {
197
- return this._currentUser.value;
198
- }
199
- set currentUser(user) {
200
- this._currentUser.next(user);
201
- this.storageService.save('currentUser', user);
202
- }
203
- get currentUserObservable() {
204
- return this._currentUser.asObservable();
205
- }
206
- // #################################################################
207
- // Token
208
- // #################################################################
209
- get token() {
210
- return this._token.value;
211
- }
212
- set token(token) {
213
- this._token.next(token);
214
- this.storageService.save('token', token);
215
- this.wsService.reconnect();
216
- }
217
- get tokenObservable() {
218
- return this._token.asObservable();
219
- }
220
- }
221
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthService, deps: [{ token: BASE_MODULE_CONFIG }, { token: StorageService }, { token: WsService }], target: i0.ɵɵFactoryTarget.Injectable });
222
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthService, providedIn: 'root' });
223
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthService, decorators: [{
224
- type: Injectable,
225
- args: [{
226
- providedIn: 'root',
227
- }]
228
- }], ctorParameters: function () {
229
- return [{ type: undefined, decorators: [{
230
- type: Inject,
231
- args: [BASE_MODULE_CONFIG]
232
- }] }, { type: StorageService }, { type: WsService }];
233
- } });
234
17
 
235
18
  /**
236
19
  * Factory for apollo-angular options
237
20
  */
238
21
  function apolloOptionsFactory(baseModuleConfig, httpLink, authService, wsService) {
239
22
  const links = [];
240
- const defaultUrl = 'api.' + window.location.href + '/graphql';
241
23
  const http = httpLink.create({
242
- uri: baseModuleConfig.apiUrl ? baseModuleConfig.apiUrl : 'https://' + defaultUrl,
24
+ uri: baseModuleConfig.apiUrl,
243
25
  });
244
26
  const authMiddleware = new ApolloLink((operation, forward) => {
245
27
  const headers = {};
@@ -252,18 +34,20 @@ function apolloOptionsFactory(baseModuleConfig, httpLink, authService, wsService
252
34
  }
253
35
  return forward(operation);
254
36
  });
37
+ if (baseModuleConfig.logging) {
38
+ console.log(baseModuleConfig);
39
+ }
255
40
  if (baseModuleConfig.wsUrl) {
256
- const wsLink = new WebSocketLink({
257
- uri: baseModuleConfig.wsUrl,
258
- options: {
259
- reconnect: true,
260
- connectionParams: () => ({
41
+ const wsLink = new GraphQLWsLink(createRestartableClient({
42
+ url: baseModuleConfig.wsUrl,
43
+ connectionParams: () => {
44
+ return {
261
45
  Authorization: authService.token ? 'Bearer ' + authService.token : undefined,
262
- }),
46
+ };
263
47
  },
264
- });
48
+ }));
265
49
  // Set client for reconnection on logout/login
266
- wsService.client = wsLink.subscriptionClient;
50
+ wsService.client = wsLink.client;
267
51
  // using the ability to split links, you can send data to each link
268
52
  // depending on what kind of operation is being sent
269
53
  links.push(split(
@@ -440,402 +224,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
440
224
  type: Input
441
225
  }] } });
442
226
 
443
- /**
444
- * Helper class
445
- */
446
- class Helper {
447
- /**
448
- * Simple filter function for plain objects
449
- */
450
- static filter(objects, filter) {
451
- return ((objects === null || objects === void 0 ? void 0 : objects.filter((element) => {
452
- for (const [key, value] of Object.entries(filter)) {
453
- if (Array.isArray(element[key])) {
454
- for (const item of element[key]) {
455
- if (!element[key].includs(value)) {
456
- return false;
457
- }
458
- }
459
- }
460
- else if (element[key] !== value) {
461
- return false;
462
- }
463
- }
464
- return true;
465
- })) || []);
466
- }
467
- /**
468
- * Convert to a url/uri conform string
469
- * Only:
470
- * - lower case
471
- * - chars, numbers and hyphens
472
- */
473
- static urlString(str, options = {}) {
474
- // Config
475
- const config = Object.assign({ allowAll: false }, options);
476
- // To string
477
- str = str + '';
478
- // Trim
479
- str = str.trim();
480
- // Lower case
481
- str = str.toLowerCase();
482
- if (!config.allowAll) {
483
- // Replace spaces
484
- str = str.trim().replace(/\s+/g, '-');
485
- // Replace some special chars
486
- str = str.replace('ä', 'ae');
487
- str = str.replace('ö', 'oe');
488
- str = str.replace('ü', 'ue');
489
- str = str.replace('ß', 'ss');
490
- // Remove other special chars
491
- str = str.replace(/[^a-zA-Z0-9-]/g, '');
492
- }
493
- // Return url conform string
494
- return encodeURI(str);
495
- }
496
- /**
497
- * Simple map function
498
- */
499
- static map(source, target, options = {}) {
500
- // Set config
501
- const config = Object.assign({ funcAllowed: false, dateStringToDate: true }, options);
502
- // Check source
503
- if (!source || typeof source !== 'object' || Array.isArray(source)) {
504
- return target;
505
- }
506
- // Update properties
507
- for (const key of Object.keys(target)) {
508
- if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
509
- if (typeof source[key] === 'string' && config.dateStringToDate) {
510
- if (Array.isArray(config.dateStringToDate)) {
511
- if (config.dateStringToDate.includes(key)) {
512
- target[key] = Helper.parseDate(source[key]);
513
- }
514
- }
515
- else {
516
- target[key] = Helper.parseDate(source[key]);
517
- }
518
- }
519
- else {
520
- target[key] = source[key];
521
- }
522
- }
523
- }
524
- // Return target
525
- return target;
526
- }
527
- /**
528
- * Create Object or Objects of specified type with specified data
529
- */
530
- static maps(data, targetClass) {
531
- // Check data
532
- if (!data || typeof data !== 'object') {
533
- return undefined;
534
- }
535
- // Check array
536
- if (!Array.isArray(data)) {
537
- data = [data];
538
- }
539
- // Map
540
- return data.map((item) => {
541
- return targetClass.map(item);
542
- });
543
- }
544
- /**
545
- * Get plain parameter
546
- */
547
- static getPlainParameter(parameter) {
548
- var _a, _b, _c;
549
- if (!parameter) {
550
- return parameter;
551
- }
552
- 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();
553
- }
554
- /**
555
- * Get ID of an url parameter
556
- */
557
- static getParameterId(parameter) {
558
- var _a;
559
- if (!parameter) {
560
- return parameter;
561
- }
562
- return (_a = Helper.getPlainParameter(parameter)) === null || _a === void 0 ? void 0 : _a.split('-').pop();
563
- }
564
- /**
565
- * Delay
566
- */
567
- static delay(ms) {
568
- const promise = new Promise((resolve) => setTimeout(resolve, ms));
569
- return promise;
570
- }
571
- /**
572
- * Deep freeze
573
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
574
- */
575
- static deepFreeze(object, preparedObjects = []) {
576
- // Prevent infinit regress
577
- if (preparedObjects.includes(object)) {
578
- return object;
579
- }
580
- preparedObjects.push(object);
581
- // Retrieve the property names defined on object
582
- const propNames = Object.getOwnPropertyNames(object);
583
- // Freeze properties before freezing self
584
- for (const name of propNames) {
585
- const value = object[name];
586
- if (value && typeof value === 'object') {
587
- Helper.deepFreeze(value, preparedObjects);
588
- }
589
- }
590
- return Object.freeze(object);
591
- }
592
- /**
593
- * Generates an unique identifier with 24 characters
594
- */
595
- static getUID() {
596
- let dt = new Date().getTime();
597
- const uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
598
- // eslint-disable-next-line no-bitwise
599
- const r = (dt + Math.random() * 16) % 16 | 0;
600
- dt = Math.floor(dt / 16);
601
- // eslint-disable-next-line no-bitwise
602
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
603
- });
604
- return uuid;
605
- }
606
- /**
607
- * Parse date string to date object
608
- */
609
- static parseDate(dateString) {
610
- const reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
611
- const reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
612
- if (typeof dateString === 'string') {
613
- const isoExec = reISO.exec(dateString);
614
- if (isoExec) {
615
- return new Date(dateString);
616
- }
617
- const msAjaxExec = reMsAjax.exec(dateString);
618
- if (msAjaxExec) {
619
- const cleaned = msAjaxExec[1].split(/[-+,.]/);
620
- return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
621
- }
622
- }
623
- return dateString;
624
- }
625
- /**
626
- * Get browser name and version
627
- */
628
- static getBrowser() {
629
- const userAgent = navigator.userAgent;
630
- let data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
631
- let version;
632
- if (/trident/i.test(data[1])) {
633
- version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
634
- return { name: 'IE', version: version[1] || '' };
635
- }
636
- if (data[1] === 'Chrome') {
637
- version = userAgent.match(/\bOPR|Edge\/(\d+)/);
638
- if (version != null) {
639
- return { name: 'Opera', version: version[1] };
640
- }
641
- }
642
- data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
643
- version = userAgent.match(/version\/(\d+)/i);
644
- if (version !== null) {
645
- data.splice(1, 1, version[1]);
646
- }
647
- return {
648
- name: data[0],
649
- version: data[1],
650
- };
651
- }
652
- /**
653
- * Whether first parameter is a deep subset of second parameter
654
- * Hint: functions will be ignored
655
- */
656
- static isSubset(a, b) {
657
- // Equal
658
- if (a === b) {
659
- return true;
660
- }
661
- // Different type
662
- if (typeof a !== typeof b) {
663
- return false;
664
- }
665
- // Process array
666
- if (Array.isArray(a)) {
667
- for (const [key, value] of Object.entries(a)) {
668
- if (Helper.isSubset(value, b[key])) {
669
- return false;
670
- }
671
- }
672
- return true;
673
- }
674
- // Process object
675
- if (typeof a === 'object') {
676
- const plain = JSON.parse(JSON.stringify(a));
677
- for (const [key, value] of Object.entries(plain)) {
678
- if (Helper.isSubset(value, b[key])) {
679
- return false;
680
- }
681
- }
682
- return true;
683
- }
684
- // Else
685
- return true;
686
- }
687
- /**
688
- * Whether parameters are equal (have equal properties)
689
- * Hint: functions will be ignored
690
- */
691
- static isEqual(a, b) {
692
- return Helper.isSubset(a, b) && Helper.isSubset(b, a);
693
- }
694
- /**
695
- * First level difference of two objects
696
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
697
- *
698
- * @returns Record<string, any> Object with properties from first object
699
- */
700
- static getDiff(a, b, clone = true) {
701
- const result = {};
702
- let firstObject = a;
703
- if (clone) {
704
- firstObject = JSON.parse(JSON.stringify(a));
705
- }
706
- for (const [key, value] of Object.entries(firstObject)) {
707
- if (!Helper.isSubset(value, b[key])) {
708
- result[key] = value;
709
- }
710
- }
711
- return result;
712
- }
713
- /**
714
- * Check if propertie is type of HTMLCollection or NodeList
715
- * See https://stackoverflow.com/a/7238344
716
- *
717
- * @param nodes
718
- */
719
- static isNodeList(nodes) {
720
- try {
721
- const stringRepr = Object.prototype.toString.call(nodes);
722
- return (typeof nodes === 'object' &&
723
- /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
724
- typeof nodes.length === 'number' &&
725
- (nodes.length === 0 || (typeof nodes[0] === 'object' && nodes[0].nodeType > 0)));
726
- }
727
- catch (e) {
728
- return false;
729
- }
730
- }
731
- static arrayBufferToBase64(buffer) {
732
- let binary = '';
733
- const bytes = new Uint8Array(buffer);
734
- const len = bytes.byteLength;
735
- for (let i = 0; i < len; i++) {
736
- binary += String.fromCharCode(bytes[i]);
737
- }
738
- return `data:image/*;base64, ${window.btoa(binary)}`;
739
- }
740
- }
741
-
742
- /**
743
- * Image service
744
- */
745
- class ImageService {
746
- /**
747
- * Preaload images (for lazy handling)
748
- *
749
- * @param options
750
- * @protected
751
- */
752
- preLoadImages(options) {
753
- // Init configuration
754
- const config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined }, options);
755
- return new Promise((resolve) => {
756
- var _a;
757
- // Convert element(s) into array
758
- if (!Array.isArray(config.elements)) {
759
- // NodeList or HTMLCollection
760
- if (Helper.isNodeList(config.elements)) {
761
- config.elements = Array.from(config.elements);
762
- }
763
- // Single element
764
- else {
765
- config.elements = [config.elements];
766
- }
767
- }
768
- // Init loading
769
- const promises = [];
770
- // Get all images
771
- let images = [];
772
- config.elements.forEach((element) => {
773
- images = images.concat(Array.from(element.getElementsByTagName('img')));
774
- });
775
- // Prepare images
776
- for (let image of images) {
777
- const src = image.getAttribute('src');
778
- // Check if changes are necessary and possible
779
- if ((image.complete && image.naturalHeight !== 0) || // already laoded
780
- !src || // Image has no src
781
- ((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
782
- ) {
783
- continue;
784
- }
785
- // Replace lazy loading image with immediately loading image
786
- if (image.getAttribute('loading') === 'lazy') {
787
- const newImage = document.createElement('img');
788
- Array.from(image.attributes).forEach((attr) => {
789
- if (attr.name !== 'loading' && attr.name !== 'src') {
790
- newImage.setAttribute(attr.name, attr.value);
791
- }
792
- });
793
- image.replaceWith(newImage);
794
- image = newImage;
795
- }
796
- // Wait for laoding
797
- promises.push(this.loadImage(image, src));
798
- }
799
- // Wait until all images loaded
800
- Promise.all(promises)
801
- .catch((e) => console.error('Error during image loading', e))
802
- .finally(() => __awaiter(this, void 0, void 0, function* () {
803
- // Return result
804
- let result;
805
- if (config.doneFunnction) {
806
- result = yield config.doneFunction();
807
- }
808
- resolve(result);
809
- }));
810
- });
811
- }
812
- /**
813
- * Load image for image element
814
- *
815
- * @param imageElement
816
- * @param src
817
- * @protected
818
- */
819
- loadImage(imageElement, src) {
820
- return __awaiter(this, void 0, void 0, function* () {
821
- src = src || imageElement.src;
822
- return new Promise((resolve, reject) => {
823
- imageElement.onload = () => resolve(imageElement);
824
- imageElement.onerror = reject;
825
- imageElement.src = src;
826
- });
827
- });
828
- }
829
- }
830
- ImageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ImageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
831
- ImageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ImageService, providedIn: 'root' });
832
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ImageService, decorators: [{
833
- type: Injectable,
834
- args: [{
835
- providedIn: 'root',
836
- }]
837
- }] });
838
-
839
227
  /**
840
228
  * Set same height (maximum) to different elements
841
229
  */
@@ -894,7 +282,7 @@ class MatchHeightDirective {
894
282
  });
895
283
  }
896
284
  }
897
- MatchHeightDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: MatchHeightDirective, deps: [{ token: i0.ElementRef }, { token: ImageService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Directive });
285
+ MatchHeightDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: MatchHeightDirective, deps: [{ token: i0.ElementRef }, { token: i2.ImageService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Directive });
898
286
  MatchHeightDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.3", type: MatchHeightDirective, selector: "[ltMatchHeight]", inputs: { ltMatchHeight: "ltMatchHeight", loadImages: "loadImages" }, host: { listeners: { "window:resize": "onResize()" } }, ngImport: i0 });
899
287
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: MatchHeightDirective, decorators: [{
900
288
  type: Directive,
@@ -902,7 +290,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
902
290
  selector: '[ltMatchHeight]',
903
291
  }]
904
292
  }], ctorParameters: function () {
905
- return [{ type: i0.ElementRef }, { type: ImageService }, { type: undefined, decorators: [{
293
+ return [{ type: i0.ElementRef }, { type: i2.ImageService }, { type: undefined, decorators: [{
906
294
  type: Inject,
907
295
  args: [PLATFORM_ID]
908
296
  }] }];
@@ -1125,12 +513,15 @@ class BaseModule {
1125
513
  */
1126
514
  static forRoot(baseModuleConfig = {}, AppAuthService) {
1127
515
  // Default config
1128
- const config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
516
+ const config = Object.assign({ apiUrl: '', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
517
+ if (config.logging) {
518
+ console.log('Config:', config);
519
+ }
1129
520
  // Prepare providers
1130
521
  const providers = [
1131
522
  {
1132
523
  provide: BASE_MODULE_CONFIG,
1133
- useValue: baseModuleConfig,
524
+ useValue: config,
1134
525
  },
1135
526
  ];
1136
527
  // Add apollo features if API URL is set
@@ -1162,7 +553,7 @@ BaseModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13
1162
553
  EllipsesPipe,
1163
554
  SafeHtmlPipe,
1164
555
  DateAgoPipe
1165
- ], exports: [
556
+ ], imports: [ApolloModule, HttpClientModule], exports: [
1166
557
  // Directives
1167
558
  ContextMenuDirective,
1168
559
  LazyLoadDirective,
@@ -1171,306 +562,44 @@ BaseModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13
1171
562
  // Pipes
1172
563
  EllipsesPipe,
1173
564
  SafeHtmlPipe,
1174
- DateAgoPipe
565
+ DateAgoPipe, ApolloModule, HttpClientModule
1175
566
  ] });
1176
- BaseModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseModule });
567
+ BaseModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseModule, imports: [[ApolloModule, HttpClientModule], ApolloModule, HttpClientModule] });
1177
568
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseModule, decorators: [{
1178
569
  type: NgModule,
1179
570
  args: [{
571
+ imports: [ApolloModule, HttpClientModule],
1180
572
  declarations: elements,
1181
- exports: elements,
573
+ exports: [...elements, ApolloModule, HttpClientModule],
1182
574
  }]
1183
575
  }] });
1184
576
 
577
+ function debounce(delay = 300) {
578
+ return function (target, propertyKey, descriptor) {
579
+ let timeout = null;
580
+ const original = descriptor.value;
581
+ descriptor.value = function (...args) {
582
+ clearTimeout(timeout);
583
+ timeout = setTimeout(() => original.apply(this, args), delay);
584
+ };
585
+ return descriptor;
586
+ };
587
+ }
588
+
1185
589
  /**
1186
- * Standard class
1187
- * Other classes should extend the Standard class, if they offer own functions
1188
- * If the extended class uses object properties with own map functions, it should implement its own map function
590
+ * Authentication guard
1189
591
  */
1190
- class Standard {
1191
- /**
1192
- * Static map method
1193
- */
1194
- static map(data, item = new this()) {
1195
- return item.map(data);
1196
- }
1197
- /**
1198
- * Map data into an object
1199
- */
1200
- map(data) {
1201
- return Helper.map(data, this);
1202
- }
592
+ class AuthGuard {
1203
593
  /**
1204
- * Clone object (and map additional data)
594
+ * Imports
1205
595
  */
1206
- clone(mapData) {
1207
- const current = JSON.parse(JSON.stringify(this));
1208
- if (mapData) {
1209
- Object.assign(current, mapData);
1210
- }
1211
- return new this.constructor().map(current);
596
+ constructor(router, authService, moduleConfig) {
597
+ this.router = router;
598
+ this.authService = authService;
599
+ this.moduleConfig = moduleConfig;
1212
600
  }
1213
601
  /**
1214
- * Compare this with another object
1215
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
1216
- *
1217
- * @return Record<string, any> with properties of this object which are different
1218
- */
1219
- getDiff(compare, clone = true) {
1220
- return Helper.getDiff(this, compare, clone);
1221
- }
1222
- }
1223
-
1224
- /**
1225
- * User class
1226
- */
1227
- class BasicUser extends Standard {
1228
- constructor() {
1229
- super(...arguments);
1230
- this.id = undefined;
1231
- this.email = undefined;
1232
- this.firstName = undefined;
1233
- this.lastName = undefined;
1234
- this.roles = [];
1235
- this.username = undefined;
1236
- }
1237
- // ===================================================================================================================
1238
- // Methods
1239
- // ===================================================================================================================
1240
- /**
1241
- * Mapping
1242
- */
1243
- map(data) {
1244
- Helper.map(data, this);
1245
- return this;
1246
- }
1247
- /**
1248
- * Checks whether the user has at least one of the required roles
1249
- */
1250
- hasRole(roles) {
1251
- if (typeof roles === 'string') {
1252
- roles = [roles];
1253
- }
1254
- if (!this.roles || this.roles.length < 1) {
1255
- return false;
1256
- }
1257
- return !roles || roles.length < 1 ? true : this.roles.some((role) => roles.includes(role));
1258
- }
1259
- /**
1260
- * Checks whether the user has all required roles
1261
- */
1262
- hasAllRoles(roles) {
1263
- if (typeof roles === 'string') {
1264
- roles = [roles];
1265
- }
1266
- if (!this.roles || this.roles.length < 1) {
1267
- return false;
1268
- }
1269
- return !roles ? true : roles.every((role) => this.roles.includes(role));
1270
- }
1271
- }
1272
-
1273
- /**
1274
- * GraphQL enum
1275
- */
1276
- class GraphQLEnum {
1277
- constructor(value) {
1278
- this.value = value;
1279
- }
1280
- }
1281
-
1282
- /**
1283
- * GraphQL type
1284
- */
1285
- class GraphQLType extends Standard {
1286
- constructor() {
1287
- super(...arguments);
1288
- this.type = '';
1289
- this.isEnum = false;
1290
- this.validEnums = [];
1291
- }
1292
- }
1293
-
1294
- /**
1295
- * GraphQL meta
1296
- */
1297
- class GraphQLMeta {
1298
- /**
1299
- * Integrate schema
1300
- */
1301
- constructor(schema) {
1302
- this.schema = schema;
1303
- // Frozen caches
1304
- this.args = {};
1305
- this.fields = {};
1306
- if (!schema) {
1307
- throw Error('Missing schema');
1308
- }
1309
- }
1310
- /**
1311
- * Get arguments of GraphQL function
1312
- */
1313
- getArgs(functionName, options = {}) {
1314
- const { cache, freeze, type } = Object.assign({ cache: true, freeze: true, type: undefined }, options);
1315
- // Get cache
1316
- if (cache && freeze) {
1317
- const args = this.args[functionName + type];
1318
- if (args) {
1319
- return args;
1320
- }
1321
- }
1322
- const func = this.getFunction(functionName, { type });
1323
- const result = {};
1324
- if (func === null || func === void 0 ? void 0 : func.args) {
1325
- func.args.forEach((item) => {
1326
- result[item.name] = this.getDeepType(item.type);
1327
- });
1328
- }
1329
- // Set cache
1330
- if (freeze) {
1331
- this.args[functionName + type] = Helper.deepFreeze(result);
1332
- }
1333
- return result;
1334
- }
1335
- /**
1336
- * Get fields of GraphQL function
1337
- */
1338
- getFields(functionName, options = {}) {
1339
- const { cache, freeze, type } = Object.assign({ cache: true, freeze: true, type: undefined }, options);
1340
- // Get cache
1341
- if (cache && freeze) {
1342
- const args = this.fields[functionName + type];
1343
- if (args) {
1344
- return args;
1345
- }
1346
- }
1347
- const func = this.getFunction(functionName, options);
1348
- const result = this.getDeepType(func.type);
1349
- // Set cache
1350
- if (freeze) {
1351
- this.fields[functionName + type] = Helper.deepFreeze(result);
1352
- }
1353
- return result;
1354
- }
1355
- /**
1356
- * Get GraphQL function
1357
- */
1358
- getFunction(name, options = {}) {
1359
- // Set config
1360
- const config = Object.assign({}, options);
1361
- // Init possible functions
1362
- let functions = {};
1363
- // If function type is set
1364
- if (config.type) {
1365
- const graphQLType = config.type.charAt(0).toUpperCase() + config.type.slice(1);
1366
- const type = this.schema.getType(graphQLType);
1367
- if (type) {
1368
- functions = type.getFields();
1369
- }
1370
- }
1371
- // If function type is not set
1372
- else {
1373
- ['Subscription', 'Mutation', 'Query'].forEach((item) => {
1374
- const type = this.schema.getType(item);
1375
- if (type) {
1376
- functions = Object.assign(Object.assign({}, functions), (type.getFields() || {}));
1377
- }
1378
- });
1379
- }
1380
- // Get function via name
1381
- return functions[name];
1382
- }
1383
- /**
1384
- * Get type
1385
- */
1386
- getType(name) {
1387
- return this.schema.getType(name);
1388
- }
1389
- /**
1390
- * Get deep type data
1391
- */
1392
- getDeepType(type, prepared = new WeakMap()) {
1393
- // Check type
1394
- if (!type) {
1395
- return type;
1396
- }
1397
- // Infinite regress protection
1398
- const preparedObject = {};
1399
- // Check prepared
1400
- if (typeof type === 'object') {
1401
- const preparedType = prepared.get(type);
1402
- if (preparedType) {
1403
- return preparedType;
1404
- }
1405
- // Set prepared
1406
- prepared.set(type, preparedObject);
1407
- }
1408
- // Search deeper
1409
- if (type.ofType) {
1410
- const ofTypeResult = this.getDeepType(type.ofType, prepared);
1411
- Object.assign(preparedObject, ofTypeResult);
1412
- return ofTypeResult;
1413
- }
1414
- // Process fields
1415
- if (type._fields) {
1416
- const result = {};
1417
- for (const [key, value] of Object.entries(type._fields)) {
1418
- result[key] = this.getDeepType(value, prepared);
1419
- }
1420
- Object.assign(preparedObject, result);
1421
- return result;
1422
- }
1423
- // Get type name
1424
- if (type.type) {
1425
- const typeResult = this.getDeepType(type.type, prepared);
1426
- Object.assign(preparedObject, typeResult);
1427
- return typeResult;
1428
- }
1429
- // Initialize GraphQLType
1430
- const graphqlType = GraphQLType.map({
1431
- type: type.name,
1432
- });
1433
- // Set enum values
1434
- if (!!type._values) {
1435
- graphqlType.isEnum = true;
1436
- for (const [key, value] of Object.entries(type._nameLookup)) {
1437
- if (!value.isDeprecated) {
1438
- graphqlType.validEnums.push(key);
1439
- }
1440
- }
1441
- }
1442
- // Finish
1443
- prepared.set(type, graphqlType);
1444
- return graphqlType;
1445
- }
1446
- }
1447
-
1448
- function debounce(delay = 300) {
1449
- return function (target, propertyKey, descriptor) {
1450
- let timeout = null;
1451
- const original = descriptor.value;
1452
- descriptor.value = function (...args) {
1453
- clearTimeout(timeout);
1454
- timeout = setTimeout(() => original.apply(this, args), delay);
1455
- };
1456
- return descriptor;
1457
- };
1458
- }
1459
-
1460
- /**
1461
- * Authentication guard
1462
- */
1463
- class AuthGuard {
1464
- /**
1465
- * Imports
1466
- */
1467
- constructor(router, authService, moduleConfig) {
1468
- this.router = router;
1469
- this.authService = authService;
1470
- this.moduleConfig = moduleConfig;
1471
- }
1472
- /**
1473
- * Can activate main route
602
+ * Can activate main route
1474
603
  */
1475
604
  canActivate(route, state) {
1476
605
  return new Observable((subscriber) => {
@@ -1504,12 +633,12 @@ class AuthGuard {
1504
633
  return this.canActivate(route, state);
1505
634
  }
1506
635
  }
1507
- AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthGuard, deps: [{ token: i1$1.Router }, { token: AuthService }, { token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
636
+ AuthGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthGuard, deps: [{ token: i1$1.Router }, { token: i2.AuthService }, { token: BASE_MODULE_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable });
1508
637
  AuthGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthGuard });
1509
638
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: AuthGuard, decorators: [{
1510
639
  type: Injectable
1511
640
  }], ctorParameters: function () {
1512
- return [{ type: i1$1.Router }, { type: AuthService }, { type: undefined, decorators: [{
641
+ return [{ type: i1$1.Router }, { type: i2.AuthService }, { type: undefined, decorators: [{
1513
642
  type: Inject,
1514
643
  args: [BASE_MODULE_CONFIG]
1515
644
  }] }];
@@ -1550,76 +679,11 @@ class LogoutGuard {
1550
679
  return this.canActivate(route, state);
1551
680
  }
1552
681
  }
1553
- LogoutGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LogoutGuard, deps: [{ token: i1$1.Router }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
682
+ LogoutGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LogoutGuard, deps: [{ token: i1$1.Router }, { token: i2.AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
1554
683
  LogoutGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LogoutGuard });
1555
684
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LogoutGuard, decorators: [{
1556
685
  type: Injectable
1557
- }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: AuthService }]; } });
1558
-
1559
- /**
1560
- * Comparison operator enum
1561
- */
1562
- var ComparisonOperatorEnum;
1563
- (function (ComparisonOperatorEnum) {
1564
- ComparisonOperatorEnum["EQ"] = "EQ";
1565
- ComparisonOperatorEnum["GT"] = "GT";
1566
- ComparisonOperatorEnum["GTE"] = "GTE";
1567
- ComparisonOperatorEnum["IN"] = "IN";
1568
- ComparisonOperatorEnum["LT"] = "LT";
1569
- ComparisonOperatorEnum["LTE"] = "LTE";
1570
- ComparisonOperatorEnum["NE"] = "NE";
1571
- ComparisonOperatorEnum["NIN"] = "NIN";
1572
- ComparisonOperatorEnum["REGEX"] = "REGEX";
1573
- })(ComparisonOperatorEnum || (ComparisonOperatorEnum = {}));
1574
-
1575
- /**
1576
- * GraphQL request type enum
1577
- */
1578
- var GraphQLRequestType;
1579
- (function (GraphQLRequestType) {
1580
- GraphQLRequestType["QUERY"] = "query";
1581
- GraphQLRequestType["MUTATION"] = "mutation";
1582
- GraphQLRequestType["SUBSCRIPTION"] = "subscription";
1583
- })(GraphQLRequestType || (GraphQLRequestType = {}));
1584
-
1585
- /**
1586
- * Logical operator enum
1587
- */
1588
- var LogicalOperatorEnum;
1589
- (function (LogicalOperatorEnum) {
1590
- LogicalOperatorEnum["AND"] = "AND";
1591
- LogicalOperatorEnum["NOR"] = "NOR";
1592
- LogicalOperatorEnum["OR"] = "OR";
1593
- })(LogicalOperatorEnum || (LogicalOperatorEnum = {}));
1594
-
1595
- var SortOrderEnum;
1596
- (function (SortOrderEnum) {
1597
- SortOrderEnum["ASC"] = "ASC";
1598
- SortOrderEnum["DESC"] = "DESC";
1599
- })(SortOrderEnum || (SortOrderEnum = {}));
1600
-
1601
- class FormsService {
1602
- constructor() { }
1603
- validateAllFormFields(formGroup) {
1604
- Object.keys(formGroup.controls).forEach((field) => {
1605
- const control = formGroup.get(field);
1606
- if (control instanceof FormControl) {
1607
- control.markAsTouched({ onlySelf: true });
1608
- }
1609
- else if (control instanceof FormGroup) {
1610
- this.validateAllFormFields(control);
1611
- }
1612
- });
1613
- }
1614
- }
1615
- FormsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: FormsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1616
- FormsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: FormsService, providedIn: 'root' });
1617
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: FormsService, decorators: [{
1618
- type: Injectable,
1619
- args: [{
1620
- providedIn: 'root',
1621
- }]
1622
- }], ctorParameters: function () { return []; } });
686
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i2.AuthService }]; } });
1623
687
 
1624
688
  /**
1625
689
  * Fullscreen service
@@ -1669,790 +733,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
1669
733
  }]
1670
734
  }], ctorParameters: function () { return []; } });
1671
735
 
1672
- /**
1673
- * GraphQL meta service
1674
- *
1675
- * For collecting meta information of the GraphQL API
1676
- */
1677
- class GraphQLMetaService {
1678
- /**
1679
- * Include services
1680
- */
1681
- constructor(apollo) {
1682
- this.apollo = apollo;
1683
- }
1684
- /**
1685
- * Getter of introspectionQuery
1686
- */
1687
- get introspectionQuery() {
1688
- return JSON.parse(JSON.stringify(this._introspectionQuery));
1689
- }
1690
- /**
1691
- * Get schema for API
1692
- * See https://www.apollographql.com/blog/three-ways-to-represent-your-graphql-schema-a41f4175100d
1693
- */
1694
- getSchema(options = {}) {
1695
- // Get configurations
1696
- const config = Object.assign({ cache: true, freeze: true }, options);
1697
- // Use caching
1698
- if (config.cache) {
1699
- if (config.freeze && this._frozenSchema) {
1700
- return of(this._frozenSchema);
1701
- }
1702
- if (this._introspectionQuery) {
1703
- return of(buildClientSchema(this.introspectionQuery));
1704
- }
1705
- if (config.freeze && this._frozenSchemaObservable) {
1706
- return this._frozenSchemaObservable;
1707
- }
1708
- else if (!config.freeze && this._schemaObservable) {
1709
- return this._schemaObservable;
1710
- }
1711
- }
1712
- // Request schema from server
1713
- const observable = this.apollo
1714
- .query({
1715
- query: gql(getIntrospectionQuery({ descriptions: false })),
1716
- })
1717
- .pipe(map((schema) => {
1718
- // Cache introspectionQuery
1719
- this._introspectionQuery = schema.data;
1720
- // Convert schema to GraphQLSchema
1721
- this._frozenSchema = Helper.deepFreeze(buildClientSchema(this.introspectionQuery));
1722
- // Return GraphQLSchema
1723
- if (config.freeze) {
1724
- return this._frozenSchema;
1725
- }
1726
- return buildClientSchema(schema.data);
1727
- }));
1728
- // Set observables
1729
- if (config.freeze) {
1730
- this._frozenSchemaObservable = observable;
1731
- }
1732
- else {
1733
- this._schemaObservable = observable;
1734
- }
1735
- // Return result
1736
- return observable;
1737
- }
1738
- /**
1739
- * Get meta for API
1740
- * See https://www.apollographql.com/blog/three-ways-to-represent-your-graphql-schema-a41f4175100d
1741
- */
1742
- getMeta(options = {}) {
1743
- // Get configurations
1744
- const config = Object.assign({ cache: true, log: false }, options);
1745
- // Use caching
1746
- if (config.cache) {
1747
- if (this._meta) {
1748
- return of(this._meta);
1749
- }
1750
- else if (this._metaObservable) {
1751
- return this._metaObservable;
1752
- }
1753
- }
1754
- // Request schema from server
1755
- const observable = this.getSchema(options).pipe(map((schema) => {
1756
- // Log
1757
- if (config.log) {
1758
- console.log({ schema });
1759
- }
1760
- this._meta = new GraphQLMeta(schema);
1761
- return this._meta;
1762
- }));
1763
- // Set observables
1764
- this._metaObservable = observable;
1765
- // Return result
1766
- return observable;
1767
- }
1768
- }
1769
- GraphQLMetaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLMetaService, deps: [{ token: i1$2.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
1770
- GraphQLMetaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLMetaService, providedIn: 'root' });
1771
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLMetaService, decorators: [{
1772
- type: Injectable,
1773
- args: [{
1774
- providedIn: 'root',
1775
- }]
1776
- }], ctorParameters: function () { return [{ type: i1$2.Apollo }]; } });
1777
-
1778
- /**
1779
- * GraphQL service
1780
- */
1781
- class GraphQLService {
1782
- /**
1783
- * Include services
1784
- */
1785
- constructor(apollo, graphQLMetaService) {
1786
- this.apollo = apollo;
1787
- this.graphQLMetaService = graphQLMetaService;
1788
- }
1789
- /**
1790
- * GraphQL request
1791
- */
1792
- graphQl(graphql, options = {}) {
1793
- // Check arguments
1794
- if (!graphql) {
1795
- throwError('Missing graphql argument');
1796
- }
1797
- // Get config
1798
- const config = Object.assign({ arguments: null, fields: null, log: false, model: null, type: GraphQLRequestType.QUERY }, options);
1799
- // Convert class to Object for arguments
1800
- if (typeof config.arguments === 'function') {
1801
- config.arguments = new config.arguments();
1802
- }
1803
- // Convert class to Object for fields
1804
- if (typeof config.fields === 'function') {
1805
- config.fields = new config.fields();
1806
- }
1807
- // Log
1808
- if (config.log) {
1809
- console.log({ config });
1810
- }
1811
- // Send request
1812
- return new Observable((subscriber) => {
1813
- // Get meta
1814
- this.graphQLMetaService.getMeta({ log: config.log }).subscribe((meta) => {
1815
- // Prepare fields
1816
- let fields;
1817
- let allowedFields;
1818
- // Log meta
1819
- if (config.log) {
1820
- console.log({ meta });
1821
- }
1822
- if (config.fields) {
1823
- allowedFields = meta.getFields(graphql, { type: config.type });
1824
- // Log meta
1825
- if (config.log) {
1826
- console.log({ allowedFields });
1827
- }
1828
- const fieldsData = this.prepareFields(config.fields, {
1829
- allowed: allowedFields,
1830
- });
1831
- // Log fields data
1832
- if (config.log) {
1833
- fieldsData.usedFields.sort();
1834
- fieldsData.schemaFields.sort();
1835
- const filtered = fieldsData.schemaFields.filter((field) => !fieldsData.usedFields.includes(field));
1836
- const unused = this.graphQLTypeCollectionToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1837
- console.log({ fieldsData, filtered, unused });
1838
- }
1839
- fields = fieldsData.fieldsString;
1840
- }
1841
- if (fields && !fields.startsWith('{')) {
1842
- fields = '{' + fields + '\n}';
1843
- }
1844
- // Log fields
1845
- if (config.log) {
1846
- console.log({ fields });
1847
- }
1848
- // Get allowed args
1849
- const allowedArgs = meta.getArgs(graphql, { type: config.type });
1850
- // Log allowed args
1851
- if (config.log) {
1852
- console.log({ allowedArgs });
1853
- }
1854
- const argsData = this.prepareArguments(config.arguments, {
1855
- allowed: allowedArgs,
1856
- });
1857
- // Log args data
1858
- if (config.log) {
1859
- argsData.usedArgs.sort();
1860
- argsData.schemaArgs.sort();
1861
- const filtered = argsData.schemaArgs.filter((field) => !argsData.usedArgs.includes(field));
1862
- const unused = this.graphQLTypeCollectionToStringArray(allowedArgs)
1863
- .sort()
1864
- .filter((field) => !argsData.usedArgs.includes(field));
1865
- console.log({ argsData, filtered, unused });
1866
- }
1867
- const args = (argsData === null || argsData === void 0 ? void 0 : argsData.argsString) || '';
1868
- // Log
1869
- if (config.log) {
1870
- console.log({ graphQL: graphql, args, fields, type: config.type });
1871
- }
1872
- // Prepare request
1873
- const documentNode = fields
1874
- ? gql(config.type + '{\n' + graphql + args + fields + '\n}')
1875
- : gql(config.type + '{\n' + graphql + args + '\n}');
1876
- // Log
1877
- if (config.log) {
1878
- console.log({ documentNode });
1879
- }
1880
- const request = {};
1881
- request[config.type] = documentNode;
1882
- // Log
1883
- if (config.log) {
1884
- console.log({ request });
1885
- }
1886
- let func;
1887
- if (config.type === GraphQLRequestType.MUTATION) {
1888
- func = 'mutate';
1889
- request[config.type] = documentNode;
1890
- }
1891
- else if (config.type === GraphQLRequestType.SUBSCRIPTION) {
1892
- func = 'subscribe';
1893
- request.query = documentNode;
1894
- }
1895
- else {
1896
- func = config.type;
1897
- request[config.type] = documentNode;
1898
- }
1899
- this.apollo[func](request).subscribe((result) => {
1900
- var _a;
1901
- const data = ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a[graphql]) !== undefined ? result.data[graphql] : result;
1902
- // Direct data
1903
- if (!config.model) {
1904
- subscriber.next(data);
1905
- }
1906
- // Map data as array
1907
- else if (Array.isArray(data)) {
1908
- subscriber.next(data.map((item) => {
1909
- return config.model.map(item);
1910
- }));
1911
- }
1912
- // Map data
1913
- else {
1914
- subscriber.next(config.model.map(data));
1915
- }
1916
- if (config.type !== GraphQLRequestType.SUBSCRIPTION) {
1917
- // Done
1918
- subscriber.complete();
1919
- }
1920
- }, (error) => {
1921
- subscriber.error(error);
1922
- subscriber.complete();
1923
- });
1924
- });
1925
- });
1926
- }
1927
- /**
1928
- * Get fields / args from IGraphQLTypeCollection
1929
- */
1930
- graphQLTypeCollectionToStringArray(collection, current = '', result = [], cacheNode = []) {
1931
- if (collection) {
1932
- if (collection instanceof GraphQLType) {
1933
- result.push(current);
1934
- }
1935
- else {
1936
- if (current === null || current === void 0 ? void 0 : current.includes('.')) {
1937
- cacheNode.push(current.split('.')[1]);
1938
- }
1939
- else if (current) {
1940
- cacheNode.push(current);
1941
- }
1942
- for (const key of Object.keys(collection)) {
1943
- if (current === key || cacheNode.includes(key)) {
1944
- continue;
1945
- }
1946
- this.graphQLTypeCollectionToStringArray(collection[key], current ? current + '.' + key : key, result, cacheNode);
1947
- }
1948
- }
1949
- }
1950
- return result;
1951
- }
1952
- /**
1953
- * Prepare arguments for GraphQL request
1954
- */
1955
- prepareArguments(args, options = {}) {
1956
- // Init config variables
1957
- const { allowed, level, parent, schemaArgs, usedArgs } = Object.assign({ allowed: null, level: 1, parent: '', schemaArgs: [], usedArgs: [] }, options);
1958
- // Check args
1959
- if (args === undefined || args === null) {
1960
- return { argsString: '', schemaArgs, usedArgs };
1961
- }
1962
- // Init args
1963
- const result = [];
1964
- // Process array
1965
- if (Array.isArray(args)) {
1966
- const allowedKeys = allowed ? Object.keys(allowed) : null;
1967
- for (const item of args) {
1968
- let key = null;
1969
- if (allowed) {
1970
- if (allowed.length < 1) {
1971
- break;
1972
- }
1973
- key = allowedKeys === null || allowedKeys === void 0 ? void 0 : allowedKeys.shift();
1974
- }
1975
- // Process value
1976
- result.push(this.prepareArguments(item, {
1977
- allowed: key ? allowed[key] : null,
1978
- level: level + 1,
1979
- parent: parent + key + '.',
1980
- schemaArgs,
1981
- usedArgs,
1982
- }).argsString);
1983
- }
1984
- // Encapsulation of the array result
1985
- if (result.length) {
1986
- // Complete result, encapsulated via round brackets
1987
- if (level === 1) {
1988
- return { argsString: '(' + result.join(', ') + ')', schemaArgs, usedArgs };
1989
- }
1990
- // Deeper result part, encapsulated via square brackets
1991
- else {
1992
- return { argsString: '[' + result.join(', ') + ']', schemaArgs, usedArgs };
1993
- }
1994
- }
1995
- }
1996
- // Process object
1997
- else if (typeof args === 'object') {
1998
- // Check object is empty
1999
- if (args && Object.keys(args).length === 0 && Object.getPrototypeOf(args) === Object.prototype) {
2000
- return { argsString: '{}', schemaArgs, usedArgs };
2001
- }
2002
- // Process all object entries
2003
- for (const [key, value] of Object.entries(args)) {
2004
- // Init data for current entry
2005
- const currentKey = parent + key;
2006
- schemaArgs.push(currentKey);
2007
- // If the allowed key handling is enabled and the current key is not included in the list of allowed keys,
2008
- // the current key will be skipped
2009
- if (allowed && !allowed[key]) {
2010
- continue;
2011
- }
2012
- // Skip value if not exists
2013
- if (value === undefined || value === null) {
2014
- continue;
2015
- }
2016
- // Add current key to metadata
2017
- usedArgs.push(currentKey);
2018
- // Process GraphQLEnum
2019
- if (value instanceof GraphQLEnum) {
2020
- result.push(key + ':' + value.value);
2021
- continue;
2022
- }
2023
- // Process array
2024
- else if (Array.isArray(value)) {
2025
- result.push(key +
2026
- ': [' +
2027
- value.map((item) => this.prepareArguments(item, {
2028
- allowed: allowed[key],
2029
- level: level + 1,
2030
- parent: currentKey + '.',
2031
- schemaArgs,
2032
- usedArgs,
2033
- }).argsString) +
2034
- ']');
2035
- continue;
2036
- }
2037
- // Prepare additional result string
2038
- let additionalResult = key + ': ';
2039
- // Value is a date object
2040
- if (typeof value === 'object' && Object.prototype.toString.call(value) === '[object Date]') {
2041
- additionalResult += `"""${value.toString()}"""`;
2042
- }
2043
- // Value is a string
2044
- else if (typeof value === 'string') {
2045
- // Enum (doesn't need quotation marks)
2046
- if (allowed[key].isEnum) {
2047
- additionalResult += value;
2048
- }
2049
- // String
2050
- else {
2051
- additionalResult += `"""${value.replace(/"/g, '\\"')}"""`;
2052
- }
2053
- }
2054
- // Value is a simple boolean or a number
2055
- else if (typeof value === 'boolean' || typeof value === 'number') {
2056
- additionalResult += value;
2057
- }
2058
- // Others
2059
- else {
2060
- additionalResult += this.prepareArguments(value, {
2061
- allowed: allowed[key],
2062
- level: level + 1,
2063
- parent: currentKey + '.',
2064
- schemaArgs,
2065
- usedArgs,
2066
- }).argsString;
2067
- }
2068
- // Push deeper part into result array
2069
- result.push(additionalResult);
2070
- }
2071
- // Encapsulation of the object result
2072
- if (result.length) {
2073
- // Complete result, encapsulated via round brackets
2074
- if (level === 1) {
2075
- return { argsString: '(' + result.join(', ') + ')', schemaArgs, usedArgs };
2076
- }
2077
- // Deeper result part, encapsulated via curly brackets
2078
- else {
2079
- return { argsString: '{' + result.join(', ') + '}', schemaArgs, usedArgs };
2080
- }
2081
- }
2082
- }
2083
- // Prepare and process other / unknown values as JSON
2084
- else {
2085
- return { argsString: JSON.stringify(args), schemaArgs, usedArgs };
2086
- }
2087
- }
2088
- /**
2089
- * Prepare fields for GraphQL request
2090
- */
2091
- prepareFields(fields, options = {}) {
2092
- // Config
2093
- const { allowed, parent, schemaFields, spaces, tab, usedFields } = Object.assign({ allowed: null, parent: '', schemaFields: [], spaces: 2, tab: 1, usedFields: [] }, options);
2094
- // Init fields string
2095
- let fieldsString = '';
2096
- // Check fields
2097
- if (!fields) {
2098
- return { fieldsString, schemaFields, usedFields };
2099
- }
2100
- // Process string
2101
- if (typeof fields === 'string') {
2102
- if (allowed &&
2103
- ((typeof allowed === 'string' && allowed !== fields) || (typeof allowed === 'object' && !allowed[fields]))) {
2104
- return { fieldsString, schemaFields, usedFields };
2105
- }
2106
- return { fieldsString: '\n' + ' '.repeat(spaces).repeat(tab) + fields, schemaFields, usedFields };
2107
- }
2108
- // Process array
2109
- else if (Array.isArray(fields)) {
2110
- for (const item of fields) {
2111
- if (typeof item === 'object') {
2112
- fieldsString =
2113
- fieldsString +
2114
- this.prepareFields(item, {
2115
- allowed,
2116
- parent,
2117
- spaces,
2118
- schemaFields,
2119
- tab: tab + 1,
2120
- usedFields,
2121
- }).fieldsString;
2122
- continue;
2123
- }
2124
- const currentPath = parent + item;
2125
- schemaFields.push(currentPath);
2126
- if (allowed && !(allowed === null || allowed === void 0 ? void 0 : allowed[item])) {
2127
- continue;
2128
- }
2129
- usedFields.push(currentPath);
2130
- fieldsString =
2131
- fieldsString +
2132
- this.prepareFields(item, {
2133
- allowed: typeof (allowed === null || allowed === void 0 ? void 0 : allowed[item]) === 'object' && !((allowed === null || allowed === void 0 ? void 0 : allowed[item]) instanceof GraphQLType) ? allowed === null || allowed === void 0 ? void 0 : allowed[item] : item,
2134
- parent: currentPath + '.',
2135
- spaces,
2136
- schemaFields,
2137
- tab: tab + 1,
2138
- usedFields,
2139
- }).fieldsString;
2140
- }
2141
- }
2142
- // Process object
2143
- else if (typeof fields === 'object') {
2144
- for (const [key, val] of Object.entries(fields)) {
2145
- const currentPath = parent + key;
2146
- schemaFields.push(currentPath);
2147
- if (allowed && !allowed[key]) {
2148
- continue;
2149
- }
2150
- usedFields.push(currentPath);
2151
- if (typeof val !== 'object' || !Object.keys(val).length) {
2152
- fieldsString = fieldsString + '\n' + ' '.repeat(spaces).repeat(tab) + key;
2153
- }
2154
- else {
2155
- fieldsString =
2156
- fieldsString +
2157
- '\n' +
2158
- ' '.repeat(spaces).repeat(tab) +
2159
- key +
2160
- ' ' +
2161
- '{' +
2162
- this.prepareFields(val, {
2163
- allowed: typeof (allowed === null || allowed === void 0 ? void 0 : allowed[key]) === 'object' && !((allowed === null || allowed === void 0 ? void 0 : allowed[key]) instanceof GraphQLType) ? allowed === null || allowed === void 0 ? void 0 : allowed[key] : key,
2164
- parent: currentPath + '.',
2165
- spaces,
2166
- schemaFields,
2167
- tab: tab + 1,
2168
- usedFields,
2169
- }).fieldsString +
2170
- '\n' +
2171
- ' '.repeat(spaces).repeat(tab) +
2172
- '}';
2173
- }
2174
- }
2175
- }
2176
- // Return result
2177
- return { fieldsString, schemaFields, usedFields };
2178
- }
2179
- }
2180
- GraphQLService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLService, deps: [{ token: i1$2.Apollo }, { token: GraphQLMetaService }], target: i0.ɵɵFactoryTarget.Injectable });
2181
- GraphQLService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLService, providedIn: 'root' });
2182
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLService, decorators: [{
2183
- type: Injectable,
2184
- args: [{
2185
- providedIn: 'root',
2186
- }]
2187
- }], ctorParameters: function () { return [{ type: i1$2.Apollo }, { type: GraphQLMetaService }]; } });
2188
-
2189
- /**
2190
- * Loader service for loading indication
2191
- */
2192
- class LoaderService {
2193
- constructor() {
2194
- this.isLoading = new BehaviorSubject(false);
2195
- }
2196
- start() {
2197
- this.isLoading.next(true);
2198
- }
2199
- stop() {
2200
- this.isLoading.next(false);
2201
- }
2202
- getAsObservable() {
2203
- return this.isLoading.asObservable();
2204
- }
2205
- }
2206
- LoaderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LoaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2207
- LoaderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LoaderService, providedIn: 'root' });
2208
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: LoaderService, decorators: [{
2209
- type: Injectable,
2210
- args: [{
2211
- providedIn: 'root',
2212
- }]
2213
- }] });
2214
-
2215
- /**
2216
- * GraphQL plus service, for extra error handling and loading indication
2217
- */
2218
- class GraphQLPlusService extends GraphQLService {
2219
- /**
2220
- * Include services
2221
- */
2222
- constructor(apollo, graphqlMetaService, loaderService) {
2223
- super(apollo, graphqlMetaService);
2224
- this.apollo = apollo;
2225
- this.graphqlMetaService = graphqlMetaService;
2226
- this.loaderService = loaderService;
2227
- }
2228
- graphQl(graphql, options = {}) {
2229
- this.handleLoader('start', options);
2230
- return new Observable((subscriber) => {
2231
- super.graphQl(graphql, options).subscribe((response) => {
2232
- if (response && response.errors) {
2233
- this.handleError(response.errors, options.excludedErrors);
2234
- subscriber.error(response);
2235
- this.handleLoader('stop', options);
2236
- subscriber.complete();
2237
- }
2238
- subscriber.next(response);
2239
- this.handleLoader('stop', options);
2240
- if (options.type !== GraphQLRequestType.SUBSCRIPTION) {
2241
- subscriber.complete();
2242
- }
2243
- }, (error) => {
2244
- if (!options.ignoreErrors) {
2245
- this.handleError(error, options.excludedErrors);
2246
- }
2247
- subscriber.error(error);
2248
- this.handleLoader('stop', options);
2249
- subscriber.complete();
2250
- });
2251
- });
2252
- }
2253
- handleLoader(state, options) {
2254
- if (options.loading) {
2255
- if (state === 'start') {
2256
- this.loaderService.start();
2257
- }
2258
- else if (state === 'stop') {
2259
- this.loaderService.stop();
2260
- }
2261
- }
2262
- }
2263
- handleError(error, excludedErrors = null) {
2264
- if (excludedErrors) {
2265
- if (Array.isArray(excludedErrors)) {
2266
- excludedErrors.forEach((excludedError) => {
2267
- if (error.message.includes(excludedError.toLowerCase())) {
2268
- return;
2269
- }
2270
- });
2271
- }
2272
- else if (error.message.toLowerCase().includes(excludedErrors === null || excludedErrors === void 0 ? void 0 : excludedErrors.toLowerCase())) {
2273
- return;
2274
- }
2275
- }
2276
- this.displayError(error);
2277
- }
2278
- displayError(error) {
2279
- console.error(error);
2280
- }
2281
- }
2282
- GraphQLPlusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLPlusService, deps: [{ token: i1$2.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }], target: i0.ɵɵFactoryTarget.Injectable });
2283
- GraphQLPlusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLPlusService, providedIn: 'root' });
2284
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: GraphQLPlusService, decorators: [{
2285
- type: Injectable,
2286
- args: [{
2287
- providedIn: 'root',
2288
- }]
2289
- }], ctorParameters: function () { return [{ type: i1$2.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
2290
-
2291
- /**
2292
- * Scroll service for autoscroll to specific fragments
2293
- */
2294
- class ScrollService {
2295
- /**
2296
- * Initializer
2297
- */
2298
- constructor(router, moduleConfig, imageService) {
2299
- this.router = router;
2300
- this.moduleConfig = moduleConfig;
2301
- this.imageService = imageService;
2302
- /**
2303
- * Is a scroll listener set
2304
- *
2305
- * @protected
2306
- */
2307
- this.scrollListener = false;
2308
- /**
2309
- * Current scroll timer;
2310
- *
2311
- * @protected
2312
- */
2313
- this.scrollTimer = -1;
2314
- const config = Object.assign({ scrollDetectionOffset: 200, scrollOffset: 100, scrollSamplingRate: 100 }, moduleConfig);
2315
- this.detectionOffset = config.scrollDetectionOffset;
2316
- this.scrollOffset = config.scrollOffset;
2317
- this.scrollSamplingRate = config.scrollSamplingRate;
2318
- }
2319
- /**
2320
- * Scroll to structureElement with specific ID
2321
- */
2322
- scrollTo(id, options = {}) {
2323
- return __awaiter(this, void 0, void 0, function* () {
2324
- // Prepare config
2325
- const config = Object.assign({ checkUrl: false, loadImagesBefore: true, resetStyles: false, setOverflow: true, stopPropagation: true }, options);
2326
- // Check current URL
2327
- if (config.checkUrl && this.router.url !== '/' && !this.router.url.startsWith('/#')) {
2328
- yield this.router.navigate(['/'], { fragment: id });
2329
- return !config.stopPropagation;
2330
- }
2331
- // Check if target element exits
2332
- const el = document.getElementById(id);
2333
- if (!el) {
2334
- console.error('Missing scroll element with ID:', id);
2335
- return !config.stopPropagation;
2336
- }
2337
- // Check if body overflow is visible
2338
- // This is necessary for scroll handling
2339
- const body = document.querySelector('body');
2340
- let undoOverflowChanges = false;
2341
- const scrollBodyStyles = JSON.parse(JSON.stringify(window.getComputedStyle(body)));
2342
- if (config.setOverflow && (scrollBodyStyles.overflowX !== 'visible' || scrollBodyStyles.overflowY !== 'visible')) {
2343
- // Set body overflow to visible
2344
- console.warn('Style of body element for overflowX and overflowY will be set to "visible" for scrolling!');
2345
- body.style.overflowX = 'visible';
2346
- body.style.overflowY = 'visible';
2347
- undoOverflowChanges = true;
2348
- }
2349
- // Load images before scrolling (once)
2350
- if (config.loadImagesBefore) {
2351
- yield this.imageService.preLoadImages();
2352
- }
2353
- // Get get bounding rect of target element
2354
- const cords = el.getBoundingClientRect();
2355
- // Scroll to element
2356
- window.scrollBy({ top: cords.top - this.scrollOffset, behavior: 'smooth' });
2357
- yield this.scrollDone({
2358
- doneFunction: () => {
2359
- // Undo changes
2360
- if (undoOverflowChanges && config.resetStyles) {
2361
- body.style.overflowX = scrollBodyStyles.overflowX;
2362
- body.style.overflowY = scrollBodyStyles.overflowY;
2363
- console.warn('Original style of body element for overflowX and overflowY is set.');
2364
- }
2365
- },
2366
- });
2367
- // Return stop propagation configuration
2368
- return !config.stopPropagation;
2369
- });
2370
- }
2371
- /**
2372
- * Get last active structureElement
2373
- */
2374
- getLastActiveElement(list) {
2375
- const currentScrollPosition = window.scrollY;
2376
- const elementsWithId = document.querySelectorAll('[id]');
2377
- let lastId = null;
2378
- let lastPosition = 0 - this.detectionOffset - 1;
2379
- elementsWithId.forEach((element) => {
2380
- const cords = element.getBoundingClientRect();
2381
- const top = cords.top + window.pageYOffset - this.detectionOffset;
2382
- if ((!list || !list.length || list.includes(element.id)) && // In list
2383
- top < currentScrollPosition && // In active area
2384
- lastPosition < top // Higher than the last one
2385
- ) {
2386
- lastId = element.id;
2387
- lastPosition = top;
2388
- }
2389
- });
2390
- return lastId;
2391
- }
2392
- /**
2393
- * Check if ID is active
2394
- */
2395
- isActive(id, list, isFirst) {
2396
- const lastActiveElement = this.getLastActiveElement(list);
2397
- return id === lastActiveElement || (lastActiveElement === null && isFirst);
2398
- }
2399
- /**
2400
- * Scroll done promise
2401
- */
2402
- scrollDone(options = {}) {
2403
- return __awaiter(this, void 0, void 0, function* () {
2404
- // Init configuration
2405
- const config = Object.assign({ doneFunction: undefined }, options);
2406
- // Wait for scroll done
2407
- yield this.scrollDoneDetection();
2408
- // Get result
2409
- if (config.doneFunction) {
2410
- return config.doneFunction();
2411
- }
2412
- });
2413
- }
2414
- /**
2415
- * Scroll done detecton
2416
- *
2417
- * @protected
2418
- */
2419
- scrollDoneDetection() {
2420
- // Return current scroll promise (Singelton)
2421
- if (this.scrollPromise) {
2422
- return this.scrollPromise;
2423
- }
2424
- // Create current scroll promise
2425
- this.scrollPromise = new Promise((resolve) => {
2426
- this.scrollPromiseResolve = resolve;
2427
- if (this.scrollTimer !== -1) {
2428
- window.clearTimeout(this.scrollTimer);
2429
- }
2430
- this.scrollTimer = window.setTimeout(() => {
2431
- window.removeEventListener('scroll', this.scrollDoneDetection.bind(this));
2432
- this.scrollPromise = undefined;
2433
- resolve();
2434
- }, this.scrollSamplingRate);
2435
- });
2436
- // Lisitening to scroll event;
2437
- window.addEventListener('scroll', this.scrollDoneDetection.bind(this));
2438
- // Return promise
2439
- return this.scrollPromise;
2440
- }
2441
- }
2442
- ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ScrollService, deps: [{ token: i1$1.Router }, { token: BASE_MODULE_CONFIG }, { token: ImageService }], target: i0.ɵɵFactoryTarget.Injectable });
2443
- ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ScrollService, providedIn: 'root' });
2444
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ScrollService, decorators: [{
2445
- type: Injectable,
2446
- args: [{
2447
- providedIn: 'root',
2448
- }]
2449
- }], ctorParameters: function () {
2450
- return [{ type: i1$1.Router }, { type: undefined, decorators: [{
2451
- type: Inject,
2452
- args: [BASE_MODULE_CONFIG]
2453
- }] }, { type: ImageService }];
2454
- } });
2455
-
2456
736
  /**
2457
737
  * SEO service for setting HTML meta data
2458
738
  */
@@ -2577,36 +857,14 @@ class ThemeService {
2577
857
  }
2578
858
  }
2579
859
  }
2580
- ThemeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ThemeService, deps: [{ token: StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
860
+ ThemeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ThemeService, deps: [{ token: i2.StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
2581
861
  ThemeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ThemeService, providedIn: 'root' });
2582
862
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ThemeService, decorators: [{
2583
863
  type: Injectable,
2584
864
  args: [{
2585
865
  providedIn: 'root',
2586
866
  }]
2587
- }], ctorParameters: function () { return [{ type: StorageService }]; } });
2588
-
2589
- /**
2590
- * Custom validator to check that two fields match
2591
- * (inspirated by https://jasonwatmore.com/post/2018/11/07/angular-7-reactive-forms-validation-example)
2592
- */
2593
- const MustMatch = (control) => {
2594
- return (formGroup) => {
2595
- const baseControl = control.get('password');
2596
- const matchingControl = control.get('passwordConfirm');
2597
- if (matchingControl.errors && !matchingControl.errors.mustMatch) {
2598
- // return if another validator has already found an error on the matchingControl
2599
- return null;
2600
- }
2601
- // set error on matchingControl if validation fails
2602
- if (baseControl.value !== matchingControl.value) {
2603
- return { mustMatch: true };
2604
- }
2605
- else {
2606
- return null;
2607
- }
2608
- };
2609
- };
867
+ }], ctorParameters: function () { return [{ type: i2.StorageService }]; } });
2610
868
 
2611
869
  /**
2612
870
  * Exports for public API
@@ -2616,5 +874,5 @@ const MustMatch = (control) => {
2616
874
  * Generated bundle index. Do not edit.
2617
875
  */
2618
876
 
2619
- export { AuthGuard, AuthService, BASE_MODULE_CONFIG, BaseModule, BasicUser, CanDeactivateGuard, ComparisonOperatorEnum, ContextMenuDirective, DateAgoPipe, EllipsesPipe, FormsService, FullscreenService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LazyLoadDirective, LoaderService, LogicalOperatorEnum, LogoutGuard, MatchHeightDirective, MustMatch, ResizableDirective, SEOService, SafeHtmlPipe, ScrollService, SortOrderEnum, Standard, StorageService, ThemeService, WsService, apolloOptionsFactory, debounce };
877
+ export { AuthGuard, BaseModule, CanDeactivateGuard, ContextMenuDirective, DateAgoPipe, EllipsesPipe, FullscreenService, LazyLoadDirective, LogoutGuard, MatchHeightDirective, ResizableDirective, SEOService, SafeHtmlPipe, ThemeService, apolloOptionsFactory, debounce };
2620
878
  //# sourceMappingURL=lenne.tech-ng-base.mjs.map