@lenne.tech/ng-base 0.3.11 → 12.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 (30) hide show
  1. package/bundles/lenne.tech-ng-base-src-lib-base.umd.js +28 -10
  2. package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
  3. package/bundles/lenne.tech-ng-base.umd.js +28 -10
  4. package/bundles/lenne.tech-ng-base.umd.js.map +1 -1
  5. package/esm2015/lib/base/base.module.js +4 -3
  6. package/esm2015/lib/base/factories/apollo-options.factory.js +3 -3
  7. package/esm2015/lib/base/public-api.js +2 -1
  8. package/esm2015/lib/base/services/auth.service.js +9 -7
  9. package/esm2015/lib/base/services/ws.service.js +16 -0
  10. package/esm2015/src/lib/base/base.module.js +4 -3
  11. package/esm2015/src/lib/base/factories/apollo-options.factory.js +3 -3
  12. package/esm2015/src/lib/base/public-api.js +2 -1
  13. package/esm2015/src/lib/base/services/auth.service.js +9 -7
  14. package/esm2015/src/lib/base/services/ws.service.js +16 -0
  15. package/fesm2015/lenne.tech-ng-base-src-lib-base.js +25 -11
  16. package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
  17. package/fesm2015/lenne.tech-ng-base.js +25 -11
  18. package/fesm2015/lenne.tech-ng-base.js.map +1 -1
  19. package/lib/base/base.module.d.ts +1 -1
  20. package/lib/base/factories/apollo-options.factory.d.ts +2 -1
  21. package/lib/base/public-api.d.ts +1 -0
  22. package/lib/base/services/auth.service.d.ts +3 -3
  23. package/lib/base/services/ws.service.d.ts +5 -0
  24. package/package.json +1 -1
  25. package/src/lib/base/base.module.d.ts +1 -1
  26. package/src/lib/base/factories/apollo-options.factory.d.ts +2 -1
  27. package/src/lib/base/lenne.tech-ng-base-src-lib-base.metadata.json +1 -1
  28. package/src/lib/base/public-api.d.ts +1 -0
  29. package/src/lib/base/services/auth.service.d.ts +3 -3
  30. package/src/lib/base/services/ws.service.d.ts +5 -0
@@ -146,6 +146,20 @@ StorageService.ctorParameters = () => [
146
146
  { type: undefined, decorators: [{ type: Inject, args: [BASE_MODULE_CONFIG,] }] }
147
147
  ];
148
148
 
149
+ class WsService {
150
+ reconnect() {
151
+ var _a, _b;
152
+ (_a = this.client) === null || _a === void 0 ? void 0 : _a.close();
153
+ (_b = this.client) === null || _b === void 0 ? void 0 : _b.connect();
154
+ }
155
+ }
156
+ WsService.ɵprov = i0.ɵɵdefineInjectable({ factory: function WsService_Factory() { return new WsService(); }, token: WsService, providedIn: "root" });
157
+ WsService.decorators = [
158
+ { type: Injectable, args: [{
159
+ providedIn: 'root',
160
+ },] }
161
+ ];
162
+
149
163
  /**
150
164
  * Authentication service
151
165
  */
@@ -153,9 +167,10 @@ class AuthService {
153
167
  /**
154
168
  * Constructor
155
169
  */
156
- constructor(moduleConfig, storageService) {
170
+ constructor(moduleConfig, storageService, wsService) {
157
171
  this.moduleConfig = moduleConfig;
158
172
  this.storageService = storageService;
173
+ this.wsService = wsService;
159
174
  // Subjects
160
175
  this._currentUser = new BehaviorSubject(null);
161
176
  this._token = new BehaviorSubject(null);
@@ -190,17 +205,15 @@ class AuthService {
190
205
  return this._token.value;
191
206
  }
192
207
  set token(token) {
193
- var _a, _b;
194
208
  this._token.next(token);
195
209
  this.storageService.save('token', token);
196
- (_a = this.subscriptionClient) === null || _a === void 0 ? void 0 : _a.close();
197
- (_b = this.subscriptionClient) === null || _b === void 0 ? void 0 : _b.connect();
210
+ this.wsService.reconnect();
198
211
  }
199
212
  get tokenObservable() {
200
213
  return this._token.asObservable();
201
214
  }
202
215
  }
203
- AuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AuthService_Factory() { return new AuthService(i0.ɵɵinject(BASE_MODULE_CONFIG), i0.ɵɵinject(StorageService)); }, token: AuthService, providedIn: "root" });
216
+ AuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AuthService_Factory() { return new AuthService(i0.ɵɵinject(BASE_MODULE_CONFIG), i0.ɵɵinject(StorageService), i0.ɵɵinject(WsService)); }, token: AuthService, providedIn: "root" });
204
217
  AuthService.decorators = [
205
218
  { type: Injectable, args: [{
206
219
  providedIn: 'root',
@@ -208,13 +221,14 @@ AuthService.decorators = [
208
221
  ];
209
222
  AuthService.ctorParameters = () => [
210
223
  { type: undefined, decorators: [{ type: Inject, args: [BASE_MODULE_CONFIG,] }] },
211
- { type: StorageService }
224
+ { type: StorageService },
225
+ { type: WsService }
212
226
  ];
213
227
 
214
228
  /**
215
229
  * Factory for apollo-angular options
216
230
  */
217
- function apolloOptionsFactory(baseModuleConfig, httpLink, authService) {
231
+ function apolloOptionsFactory(baseModuleConfig, httpLink, authService, wsService) {
218
232
  const links = [];
219
233
  const defaultUrl = 'api.' + window.location.href + '/graphql';
220
234
  const http = httpLink.create({
@@ -242,7 +256,7 @@ function apolloOptionsFactory(baseModuleConfig, httpLink, authService) {
242
256
  },
243
257
  });
244
258
  // Set client for reconnection on logout/login
245
- authService.subscriptionClient = wsLink.subscriptionClient;
259
+ wsService.client = wsLink.subscriptionClient;
246
260
  // using the ability to split links, you can send data to each link
247
261
  // depending on what kind of operation is being sent
248
262
  links.push(split(
@@ -1013,7 +1027,7 @@ class BaseModule {
1013
1027
  /**
1014
1028
  * Set configuration of base module in root module of the app
1015
1029
  */
1016
- static forRoot(baseModuleConfig = {}) {
1030
+ static forRoot(baseModuleConfig = {}, AppAuthService) {
1017
1031
  // Default config
1018
1032
  const config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
1019
1033
  // Prepare providers
@@ -1028,7 +1042,7 @@ class BaseModule {
1028
1042
  providers.push({
1029
1043
  provide: APOLLO_OPTIONS,
1030
1044
  useFactory: apolloOptionsFactory,
1031
- deps: [BASE_MODULE_CONFIG, HttpLink, AuthService],
1045
+ deps: [BASE_MODULE_CONFIG, HttpLink, AppAuthService ? AppAuthService : AuthService, WsService],
1032
1046
  });
1033
1047
  }
1034
1048
  else if (config.logging) {
@@ -2411,5 +2425,5 @@ function MustMatch(controlName, matchingControlName) {
2411
2425
  * Generated bundle index. Do not edit.
2412
2426
  */
2413
2427
 
2414
- export { AuthGuard, AuthService, BASE_MODULE_CONFIG, BaseModule, BasicUser, CanDeactivateGuard, ComparisonOperatorEnum, ContextMenuDirective, EllipsesPipe, FullscreenService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LazyLoadDirective, LoaderService, LogicalOperatorEnum, LogoutGuard, MatchHeightDirective, MustMatch, ResizableDirective, SEOService, SafeHtmlPipe, ScrollService, SortOrderEnum, Standard, StorageService, apolloOptionsFactory };
2428
+ export { AuthGuard, AuthService, BASE_MODULE_CONFIG, BaseModule, BasicUser, CanDeactivateGuard, ComparisonOperatorEnum, ContextMenuDirective, EllipsesPipe, FullscreenService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LazyLoadDirective, LoaderService, LogicalOperatorEnum, LogoutGuard, MatchHeightDirective, MustMatch, ResizableDirective, SEOService, SafeHtmlPipe, ScrollService, SortOrderEnum, Standard, StorageService, WsService, apolloOptionsFactory };
2415
2429
  //# sourceMappingURL=lenne.tech-ng-base.js.map