oip-common 0.1.7 → 0.1.8

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.
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { OnInit, OnDestroy, WritableSignal, Type, Provider, InjectionToken, EventEmitter, Renderer2, OnChanges, SimpleChanges, EnvironmentProviders, PipeTransform } from '@angular/core';
2
+ import { OnInit, OnDestroy, WritableSignal, OnChanges, SimpleChanges, Type, Provider, InjectionToken, EventEmitter, Renderer2, EnvironmentProviders, PipeTransform } from '@angular/core';
3
3
  import { MessageService, ToastMessageOptions, MenuItem, ConfirmationService, FilterMetadata } from 'primeng/api';
4
4
  import { ActivatedRoute, QueryParamsHandling, IsActiveMatchOptions, Params, Router, UrlTree } from '@angular/router';
5
- import { TranslateService, InterpolationParameters, Translation, TranslationObject } from '@ngx-translate/core';
5
+ import { InterpolationParameters, Translation, TranslationObject, TranslateService } from '@ngx-translate/core';
6
6
  import * as rxjs from 'rxjs';
7
7
  import { Subscription, Subject, Observable, BehaviorSubject } from 'rxjs';
8
8
  import { LoginResponse, AuthOptions, OidcSecurityService, LogoutAuthOptions, AbstractSecurityStorage, StsConfigHttpLoader } from 'angular-auth-oidc-client';
@@ -45,6 +45,9 @@ declare class MsgService {
45
45
  warn(detail: any, summary?: any, life?: number): void;
46
46
  error(detail: any, summary?: any, life?: number): void;
47
47
  extractErrorMessage(error: unknown, fallback: string): string;
48
+ private extractValidationMessage;
49
+ private toValidationMessages;
50
+ private getObjectProperty;
48
51
  errorFromException(error: unknown, fallback: string, summary?: string, life?: number): void;
49
52
  contrast(detail: any, summary?: any, life?: number): void;
50
53
  secondary(detail: any, summary?: any, life?: number): void;
@@ -177,9 +180,64 @@ declare class LayoutService {
177
180
  static ɵprov: i0.ɵɵInjectableDeclaration<LayoutService>;
178
181
  }
179
182
 
183
+ interface LanguageDto {
184
+ code: string;
185
+ name: string;
186
+ icon: string;
187
+ }
188
+ /**
189
+ * Service for managing translation loading in the application
190
+ */
191
+ declare class L10nService {
192
+ private loadedTranslations;
193
+ private httpClient;
194
+ private translateService;
195
+ private readonly primeNg;
196
+ private readonly layoutService;
197
+ availableLanguages: LanguageDto[];
198
+ /**
199
+ * Loads translations for a specific component
200
+ * @param component - Name of the component to load translations for
201
+ */
202
+ loadComponentTranslations(component: string): void;
203
+ /**
204
+ * Gets the translated value of a key (or an array of keys)
205
+ * @returns the translated key, or an object of translated keys
206
+ */
207
+ get(key: string): rxjs.Observable<any>;
208
+ /**
209
+ * Internal method to load translations from JSON files
210
+ * @param component - Component or translation namespace
211
+ * @param lang - Language code to load translations for
212
+ */
213
+ private loadTranslations;
214
+ /**
215
+ * Changes the lang currently used
216
+ */
217
+ use(selectedLanguage: string, key?: string): void;
218
+ init(languages: LanguageDto[]): void;
219
+ instant(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
220
+ static ɵfac: i0.ɵɵFactoryDeclaration<L10nService, never>;
221
+ static ɵprov: i0.ɵɵInjectableDeclaration<L10nService>;
222
+ }
223
+
224
+ interface SecurityDto {
225
+ code: string;
226
+ name: string;
227
+ description: string;
228
+ roles: string[];
229
+ }
230
+
180
231
  declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSettings> implements OnInit, OnDestroy {
232
+ private static readonly readRight;
233
+ private static readonly editRight;
234
+ private static readonly deleteRight;
181
235
  private isInitialized;
182
236
  private moduleInstanceReloadPromise;
237
+ private rightsSubscription?;
238
+ private readonly destroyRef;
239
+ private readonly securityDataService;
240
+ private readonly securityService;
183
241
  /**
184
242
  * Provide access to app settings
185
243
  */
@@ -247,6 +305,12 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
247
305
  * @type {string}
248
306
  */
249
307
  title: string;
308
+ l10nService: L10nService;
309
+ l10n$: Observable<Translation | TranslationObject>;
310
+ canRead: boolean;
311
+ canEdit: boolean;
312
+ canDelete: boolean;
313
+ securityRightsLoaded: boolean;
250
314
  /**
251
315
  * Updates local settings and persists them to local storage.
252
316
  * @return {void}
@@ -282,6 +346,10 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
282
346
  * Defines the top bar items.
283
347
  */
284
348
  topBarItems: TopBarDto[];
349
+ /**
350
+ * Gets an instant translation for a key or an array of keys.
351
+ */
352
+ t(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
285
353
  /**
286
354
  * Initializes the component and subscribes to local settings updates.
287
355
  */
@@ -316,23 +384,37 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
316
384
  * Derived components can override this to refresh module-specific data.
317
385
  */
318
386
  protected onModuleInstanceChange(): Promise<void>;
387
+ /**
388
+ * Called whenever current user rights for the active module instance are recalculated.
389
+ */
390
+ protected onSecurityRightsChange(): void;
391
+ /**
392
+ * Starts watching current token roles and maps them to module instance security settings.
393
+ */
394
+ protected watchSecurityRights(controller?: string, id?: number | undefined): void;
395
+ private resetRightsState;
396
+ private updateRightsState;
397
+ protected hasSecurityRight(roles: string[], securitySettings: SecurityDto[], code: string): boolean;
319
398
  private reloadModuleInstance;
320
399
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseModuleComponent<any, any>, never>;
321
400
  static ɵcmp: i0.ɵɵComponentDeclaration<BaseModuleComponent<any, any>, "ng-component", never, {}, {}, never, never, true, never>;
322
401
  }
323
402
 
324
- declare class SecurityComponent implements OnInit, OnDestroy {
403
+ declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
325
404
  private readonly msgService;
326
405
  private readonly dataService;
327
406
  private readonly translateService;
407
+ private securityLoadToken;
328
408
  securityData: any[];
329
- id: number;
330
- controller: string;
409
+ id?: number;
410
+ controller?: string;
331
411
  roles: string[];
332
412
  ngOnDestroy(): void;
413
+ ngOnChanges(changes: SimpleChanges): void;
333
414
  ngOnInit(): void;
334
415
  saveClick(): void;
335
416
  saveKeyDown($event: KeyboardEvent): void;
417
+ private loadSecurity;
336
418
  static ɵfac: i0.ɵɵFactoryDeclaration<SecurityComponent, never>;
337
419
  static ɵcmp: i0.ɵɵComponentDeclaration<SecurityComponent, "security", never, { "id": { "alias": "id"; "required": false; }; "controller": { "alias": "controller"; "required": false; }; }, {}, never, never, true, never>;
338
420
  }
@@ -926,47 +1008,6 @@ declare class LogoComponent {
926
1008
  static ɵcmp: i0.ɵɵComponentDeclaration<LogoComponent, "logo", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, {}, never, never, true, never>;
927
1009
  }
928
1010
 
929
- interface LanguageDto {
930
- code: string;
931
- name: string;
932
- icon: string;
933
- }
934
- /**
935
- * Service for managing translation loading in the application
936
- */
937
- declare class L10nService {
938
- private loadedTranslations;
939
- private httpClient;
940
- private translateService;
941
- private readonly primeNg;
942
- private readonly layoutService;
943
- availableLanguages: LanguageDto[];
944
- /**
945
- * Loads translations for a specific component
946
- * @param component - Name of the component to load translations for
947
- */
948
- loadComponentTranslations(component: string): void;
949
- /**
950
- * Gets the translated value of a key (or an array of keys)
951
- * @returns the translated key, or an object of translated keys
952
- */
953
- get(key: string): rxjs.Observable<any>;
954
- /**
955
- * Internal method to load translations from JSON files
956
- * @param component - Component or translation namespace
957
- * @param lang - Language code to load translations for
958
- */
959
- private loadTranslations;
960
- /**
961
- * Changes the lang currently used
962
- */
963
- use(selectedLanguage: string, key?: string): void;
964
- init(languages: LanguageDto[]): void;
965
- instant(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
966
- static ɵfac: i0.ɵɵFactoryDeclaration<L10nService, never>;
967
- static ɵprov: i0.ɵɵInjectableDeclaration<L10nService>;
968
- }
969
-
970
1011
  declare class NotfoundComponent {
971
1012
  constructor(l10nService: L10nService);
972
1013
  static ɵfac: i0.ɵɵFactoryDeclaration<NotfoundComponent, never>;
@@ -1042,7 +1083,6 @@ interface MigrationDto {
1042
1083
  }
1043
1084
  declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, NoSettingsDto> implements OnInit, OnDestroy {
1044
1085
  data: MigrationDto[];
1045
- l10nService: L10nService;
1046
1086
  constructor();
1047
1087
  ngOnInit(): Promise<void>;
1048
1088
  refreshAction(): Promise<void>;
@@ -1413,13 +1453,6 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1413
1453
  static ɵcmp: i0.ɵɵComponentDeclaration<DiscussionComponent, "discussion", never, { "objectTypeId": { "alias": "objectTypeId"; "required": true; }; "objectId": { "alias": "objectId"; "required": true; }; }, {}, never, never, true, never>;
1414
1454
  }
1415
1455
 
1416
- interface SecurityDto {
1417
- code: string;
1418
- name: string;
1419
- description: string;
1420
- roles: string[];
1421
- }
1422
-
1423
1456
  interface PutSecurityDto {
1424
1457
  id: number;
1425
1458
  securities: SecurityDto[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [