oip-common 0.1.7 → 0.2.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.
package/index.d.ts CHANGED
@@ -1,10 +1,10 @@
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 { OnDestroy, OnInit, DestroyRef, 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
- import { Subscription, Subject, Observable, BehaviorSubject } from 'rxjs';
7
+ import { Observable, BehaviorSubject, Subscription, Subject } from 'rxjs';
8
8
  import { LoginResponse, AuthOptions, OidcSecurityService, LogoutAuthOptions, AbstractSecurityStorage, StsConfigHttpLoader } from 'angular-auth-oidc-client';
9
9
  import { ContextMenu } from 'primeng/contextmenu';
10
10
  import { PaletteDesignToken, Preset } from '@primeuix/themes/types';
@@ -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,163 @@ 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
+
231
+ interface PutSecurityDto {
232
+ id: number;
233
+ securities: SecurityDto[];
234
+ }
235
+
236
+ declare class SecurityDataService extends BaseDataService {
237
+ getSecurity(controller: string, id: number): Promise<SecurityDto[]>;
238
+ saveSecurity(controller: string, request: PutSecurityDto): Promise<any>;
239
+ getRealmRoles(): Promise<string[]>;
240
+ static ɵfac: i0.ɵɵFactoryDeclaration<SecurityDataService, never>;
241
+ static ɵprov: i0.ɵɵInjectableDeclaration<SecurityDataService>;
242
+ }
243
+
244
+ declare abstract class SecurityService {
245
+ abstract auth(): void;
246
+ abstract logout(): void;
247
+ abstract isAuthenticated(): Observable<boolean>;
248
+ abstract getAccessToken(): Observable<string>;
249
+ abstract isTokenExpired(): Observable<boolean>;
250
+ abstract getCurrentUser(): any;
251
+ abstract getCurrentUser$(): Observable<any>;
252
+ abstract forceRefreshSession(): Observable<LoginResponse>;
253
+ abstract isAdmin(): boolean;
254
+ abstract authorize(configId?: string, authOptions?: AuthOptions): void;
255
+ abstract payload: BehaviorSubject<any>;
256
+ }
257
+ /**
258
+ * SecurityService extends OidcSecurityService to manage authentication,
259
+ * token handling, and user role access in an Angular application.
260
+ *
261
+ * It provides helper methods for checking authentication, managing tokens,
262
+ * determining user roles, and performing logout and refresh operations.
263
+ */
264
+ declare class KeycloakSecurityService extends OidcSecurityService implements OnDestroy, SecurityService {
265
+ /**
266
+ * Handles angular OIDC events.
267
+ */
268
+ private readonly publicEventsService;
269
+ /**
270
+ * Stores the latest login response from checkAuth().
271
+ */
272
+ loginResponse: BehaviorSubject<LoginResponse>;
273
+ /**
274
+ * Stores the decoded access token payload.
275
+ */
276
+ readonly payload: BehaviorSubject<any>;
277
+ /**
278
+ * Stores user-specific data from the login response.
279
+ */
280
+ private readonly currentUser;
281
+ /**
282
+ * Emits access token updates from initial auth check, manual refresh,
283
+ * and library authentication events.
284
+ */
285
+ private accessToken;
286
+ /**
287
+ * Initializes service and subscribes to authentication events.
288
+ * When a 'NewAuthenticationResult' event is received, the `auth` method is called.
289
+ */
290
+ constructor();
291
+ getCurrentUser(): any;
292
+ getCurrentUser$(): Observable<any>;
293
+ /**
294
+ * Returns the ID token for the sign-in.
295
+ * @returns A string with the id token.
296
+ */
297
+ getAccessToken(configId?: string): Observable<string>;
298
+ /**
299
+ * Indicates whether the current user has the 'admin' role.
300
+ *
301
+ * @returns {boolean} True if the user is an admin, false otherwise.
302
+ */
303
+ isAdmin(): boolean;
304
+ /**
305
+ * Initiates authentication check and updates login response, user data,
306
+ * and decoded token payload if authenticated.
307
+ */
308
+ auth(): void;
309
+ /**
310
+ * Performs logout and clears the local token payload.
311
+ *
312
+ * @param {string} [configId] Optional configuration ID for logout.
313
+ * @param {LogoutAuthOptions} [logoutAuthOptions] Optional logout options.
314
+ */
315
+ logout(configId?: string, logoutAuthOptions?: LogoutAuthOptions): void;
316
+ /**
317
+ * Completes the BehaviorSubjects when the service is destroyed to avoid memory leaks.
318
+ */
319
+ ngOnDestroy(): void;
320
+ /**
321
+ * Checks whether the current access token is expired based on the 'exp' claim.
322
+ *
323
+ * @returns {Observable<boolean>} Observable that emits true if the token is expired.
324
+ */
325
+ isTokenExpired(): Observable<boolean>;
326
+ static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakSecurityService, never>;
327
+ static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakSecurityService>;
328
+ }
329
+
180
330
  declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSettings> implements OnInit, OnDestroy {
331
+ private static readonly readRight;
332
+ private static readonly editRight;
333
+ private static readonly deleteRight;
181
334
  private isInitialized;
182
335
  private moduleInstanceReloadPromise;
336
+ private rightsSubscription?;
337
+ protected readonly destroyRef: DestroyRef;
338
+ protected readonly securityDataService: SecurityDataService;
339
+ protected readonly securityService: SecurityService;
183
340
  /**
184
341
  * Provide access to app settings
185
342
  */
@@ -247,6 +404,12 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
247
404
  * @type {string}
248
405
  */
249
406
  title: string;
407
+ l10nService: L10nService;
408
+ l10n$: Observable<Translation | TranslationObject>;
409
+ canRead: boolean;
410
+ canEdit: boolean;
411
+ canDelete: boolean;
412
+ securityRightsLoaded: boolean;
250
413
  /**
251
414
  * Updates local settings and persists them to local storage.
252
415
  * @return {void}
@@ -282,6 +445,10 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
282
445
  * Defines the top bar items.
283
446
  */
284
447
  topBarItems: TopBarDto[];
448
+ /**
449
+ * Gets an instant translation for a key or an array of keys.
450
+ */
451
+ t(key: string | string[], interpolateParams?: InterpolationParameters): Translation | TranslationObject;
285
452
  /**
286
453
  * Initializes the component and subscribes to local settings updates.
287
454
  */
@@ -316,113 +483,41 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
316
483
  * Derived components can override this to refresh module-specific data.
317
484
  */
318
485
  protected onModuleInstanceChange(): Promise<void>;
486
+ /**
487
+ * Called whenever current user rights for the active module instance are recalculated.
488
+ */
489
+ protected onSecurityRightsChange(): void;
490
+ /**
491
+ * Starts watching current token roles and maps them to module instance security settings.
492
+ */
493
+ protected watchSecurityRights(controller?: string, id?: number | undefined): void;
494
+ private resetRightsState;
495
+ private updateRightsState;
496
+ protected hasSecurityRight(roles: string[], securitySettings: SecurityDto[], code: string): boolean;
319
497
  private reloadModuleInstance;
320
498
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseModuleComponent<any, any>, never>;
321
499
  static ɵcmp: i0.ɵɵComponentDeclaration<BaseModuleComponent<any, any>, "ng-component", never, {}, {}, never, never, true, never>;
322
500
  }
323
501
 
324
- declare class SecurityComponent implements OnInit, OnDestroy {
502
+ declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
325
503
  private readonly msgService;
326
504
  private readonly dataService;
327
505
  private readonly translateService;
506
+ private securityLoadToken;
328
507
  securityData: any[];
329
- id: number;
330
- controller: string;
508
+ id?: number;
509
+ controller?: string;
331
510
  roles: string[];
332
511
  ngOnDestroy(): void;
512
+ ngOnChanges(changes: SimpleChanges): void;
333
513
  ngOnInit(): void;
334
514
  saveClick(): void;
335
515
  saveKeyDown($event: KeyboardEvent): void;
516
+ private loadSecurity;
336
517
  static ɵfac: i0.ɵɵFactoryDeclaration<SecurityComponent, never>;
337
518
  static ɵcmp: i0.ɵɵComponentDeclaration<SecurityComponent, "security", never, { "id": { "alias": "id"; "required": false; }; "controller": { "alias": "controller"; "required": false; }; }, {}, never, never, true, never>;
338
519
  }
339
520
 
340
- declare abstract class SecurityService {
341
- abstract auth(): void;
342
- abstract logout(): void;
343
- abstract isAuthenticated(): Observable<boolean>;
344
- abstract getAccessToken(): Observable<string>;
345
- abstract isTokenExpired(): Observable<boolean>;
346
- abstract getCurrentUser(): any;
347
- abstract getCurrentUser$(): Observable<any>;
348
- abstract forceRefreshSession(): Observable<LoginResponse>;
349
- abstract isAdmin(): boolean;
350
- abstract authorize(configId?: string, authOptions?: AuthOptions): void;
351
- abstract payload: BehaviorSubject<any>;
352
- }
353
- /**
354
- * SecurityService extends OidcSecurityService to manage authentication,
355
- * token handling, and user role access in an Angular application.
356
- *
357
- * It provides helper methods for checking authentication, managing tokens,
358
- * determining user roles, and performing logout and refresh operations.
359
- */
360
- declare class KeycloakSecurityService extends OidcSecurityService implements OnDestroy, SecurityService {
361
- /**
362
- * Handles angular OIDC events.
363
- */
364
- private readonly publicEventsService;
365
- /**
366
- * Stores the latest login response from checkAuth().
367
- */
368
- loginResponse: BehaviorSubject<LoginResponse>;
369
- /**
370
- * Stores the decoded access token payload.
371
- */
372
- readonly payload: BehaviorSubject<any>;
373
- /**
374
- * Stores user-specific data from the login response.
375
- */
376
- private readonly currentUser;
377
- /**
378
- * Emits access token updates from initial auth check, manual refresh,
379
- * and library authentication events.
380
- */
381
- private accessToken;
382
- /**
383
- * Initializes service and subscribes to authentication events.
384
- * When a 'NewAuthenticationResult' event is received, the `auth` method is called.
385
- */
386
- constructor();
387
- getCurrentUser(): any;
388
- getCurrentUser$(): Observable<any>;
389
- /**
390
- * Returns the ID token for the sign-in.
391
- * @returns A string with the id token.
392
- */
393
- getAccessToken(configId?: string): Observable<string>;
394
- /**
395
- * Indicates whether the current user has the 'admin' role.
396
- *
397
- * @returns {boolean} True if the user is an admin, false otherwise.
398
- */
399
- isAdmin(): boolean;
400
- /**
401
- * Initiates authentication check and updates login response, user data,
402
- * and decoded token payload if authenticated.
403
- */
404
- auth(): void;
405
- /**
406
- * Performs logout and clears the local token payload.
407
- *
408
- * @param {string} [configId] Optional configuration ID for logout.
409
- * @param {LogoutAuthOptions} [logoutAuthOptions] Optional logout options.
410
- */
411
- logout(configId?: string, logoutAuthOptions?: LogoutAuthOptions): void;
412
- /**
413
- * Completes the BehaviorSubjects when the service is destroyed to avoid memory leaks.
414
- */
415
- ngOnDestroy(): void;
416
- /**
417
- * Checks whether the current access token is expired based on the 'exp' claim.
418
- *
419
- * @returns {Observable<boolean>} Observable that emits true if the token is expired.
420
- */
421
- isTokenExpired(): Observable<boolean>;
422
- static ɵfac: i0.ɵɵFactoryDeclaration<KeycloakSecurityService, never>;
423
- static ɵprov: i0.ɵɵInjectableDeclaration<KeycloakSecurityService>;
424
- }
425
-
426
521
  /**
427
522
  * UserService is responsible for retrieving and handling user-related data,
428
523
  * including the user's photo and short label for avatar display.
@@ -532,6 +627,9 @@ interface EditModuleInstanceDto {
532
627
  */
533
628
  moduleId?: number | null;
534
629
  }
630
+ interface IframeModuleSettings {
631
+ url?: string | null;
632
+ }
535
633
  /** Represents a key-value pair where the key is an integer and the value is a string. */
536
634
  interface IntKeyValueDto {
537
635
  /** @format int32 */
@@ -926,47 +1024,6 @@ declare class LogoComponent {
926
1024
  static ɵcmp: i0.ɵɵComponentDeclaration<LogoComponent, "logo", never, { "width": { "alias": "width"; "required": false; }; "height": { "alias": "height"; "required": false; }; }, {}, never, never, true, never>;
927
1025
  }
928
1026
 
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
1027
  declare class NotfoundComponent {
971
1028
  constructor(l10nService: L10nService);
972
1029
  static ɵfac: i0.ɵɵFactoryDeclaration<NotfoundComponent, never>;
@@ -1042,7 +1099,6 @@ interface MigrationDto {
1042
1099
  }
1043
1100
  declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, NoSettingsDto> implements OnInit, OnDestroy {
1044
1101
  data: MigrationDto[];
1045
- l10nService: L10nService;
1046
1102
  constructor();
1047
1103
  ngOnInit(): Promise<void>;
1048
1104
  refreshAction(): Promise<void>;
@@ -1413,24 +1469,20 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1413
1469
  static ɵcmp: i0.ɵɵComponentDeclaration<DiscussionComponent, "discussion", never, { "objectTypeId": { "alias": "objectTypeId"; "required": true; }; "objectId": { "alias": "objectId"; "required": true; }; }, {}, never, never, true, never>;
1414
1470
  }
1415
1471
 
1416
- interface SecurityDto {
1417
- code: string;
1418
- name: string;
1419
- description: string;
1420
- roles: string[];
1421
- }
1422
-
1423
- interface PutSecurityDto {
1424
- id: number;
1425
- securities: SecurityDto[];
1426
- }
1427
-
1428
- declare class SecurityDataService extends BaseDataService {
1429
- getSecurity(controller: string, id: number): Promise<SecurityDto[]>;
1430
- saveSecurity(controller: string, request: PutSecurityDto): Promise<any>;
1431
- getRealmRoles(): Promise<string[]>;
1432
- static ɵfac: i0.ɵɵFactoryDeclaration<SecurityDataService, never>;
1433
- static ɵprov: i0.ɵɵInjectableDeclaration<SecurityDataService>;
1472
+ declare class IframeModuleComponent extends BaseModuleComponent<IframeModuleSettings, IframeModuleSettings> implements OnInit, OnDestroy {
1473
+ private iframe?;
1474
+ private readonly renderer;
1475
+ private readonly translate;
1476
+ protected iframeUrl: string | null;
1477
+ constructor();
1478
+ private set iframeElement(value);
1479
+ private setIframeUrl;
1480
+ private isAllowedIframeUrl;
1481
+ protected onModuleInstanceChange(): Promise<void>;
1482
+ private updateIframeSrc;
1483
+ onIframeError(): void;
1484
+ static ɵfac: i0.ɵɵFactoryDeclaration<IframeModuleComponent, never>;
1485
+ static ɵcmp: i0.ɵɵComponentDeclaration<IframeModuleComponent, "ng-component", never, {}, {}, never, never, true, never>;
1434
1486
  }
1435
1487
 
1436
1488
  /**
@@ -1556,5 +1608,5 @@ declare class SecurePipe implements PipeTransform {
1556
1608
  */
1557
1609
  declare const httpLoaderAuthFactory: (httpClient: HttpClient$1) => StsConfigHttpLoader;
1558
1610
 
1559
- export { APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, ContentType, DEFAULT_OIP_FRONTEND_CONFIG, DbMigrationComponent, DiscussionComponent, ErrorComponent, FooterComponent, HttpClient, KeycloakSecurityService, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, MsgService, NotfoundComponent, NotificationService, OIP_FRONTEND_CONFIG, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept, mergeWithDefaults, provideAppThemes, provideLogoComponent, replaceDefaults };
1611
+ export { APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AuthGuardService, BaseDataService, BaseModuleComponent, ConfigComponent, ContentType, DEFAULT_OIP_FRONTEND_CONFIG, DbMigrationComponent, DiscussionComponent, ErrorComponent, FooterComponent, HttpClient, IframeModuleComponent, KeycloakSecurityService, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, MsgService, NotfoundComponent, NotificationService, OIP_FRONTEND_CONFIG, ProfileComponent, SecurePipe, SecurityComponent, SecurityDataService, SecurityService, SecurityStorageService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserService, httpLoaderAuthFactory, langIntercept, mergeWithDefaults, provideAppThemes, provideLogoComponent, replaceDefaults };
1560
1612
  export type { AppConfig, AppThemePreset, AppThemePresetMergeMode, LanguageDto, MenuChangeEvent, NoSettingsDto, OipFrontendAppMode, OipFrontendConfig, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.1.7",
3
+ "version": "0.2.0",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [