oip-common 0.6.2 → 0.6.4

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
@@ -197,8 +197,9 @@ declare class L10nService {
197
197
  */
198
198
  get(key: string): Observable<any>;
199
199
  /**
200
- * Internal method to load translations from JSON files
201
- * @param component - Component or translation namespace
200
+ * Internal method to merge a namespace's statically-registered translations
201
+ * (see <c>registerTranslations</c>) into the active language dictionary.
202
+ * @param component - Translation namespace
202
203
  * @param lang - Language code to load translations for
203
204
  */
204
205
  private loadTranslations;
@@ -422,18 +423,8 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
422
423
  * @type {string}
423
424
  */
424
425
  title: string;
425
- /**
426
- * Translations bundled with the component, grouped by language code.
427
- * Declare it in a derived component to load translations from the component folder
428
- * instead of `assets/i18n`:
429
- *
430
- * ```ts
431
- * static override readonly translations = { en, ru };
432
- * ```
433
- */
434
- static readonly translations: TranslationsByLang | undefined;
426
+ private readonly baseTranslations;
435
427
  l10nService: L10nService;
436
- l10n$: Observable<Translation | TranslationObject>;
437
428
  canRead: boolean;
438
429
  canEdit: boolean;
439
430
  canDelete: boolean;
@@ -541,6 +532,7 @@ declare abstract class BaseModuleComponent<TBackendStoreSettings, TLocalStoreSet
541
532
  }
542
533
 
543
534
  declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
535
+ private readonly translations;
544
536
  private readonly msgService;
545
537
  private readonly translateService;
546
538
  private readonly httpClient;
@@ -550,7 +542,6 @@ declare class SecurityComponent implements OnChanges, OnInit, OnDestroy {
550
542
  id?: number;
551
543
  controller?: string;
552
544
  roles: string[];
553
- constructor(l10nService: L10nService);
554
545
  ngOnDestroy(): void;
555
546
  ngOnChanges(changes: SimpleChanges): void;
556
547
  ngOnInit(): void;
@@ -615,12 +606,60 @@ declare class LogoService {
615
606
  static ɵprov: i0.ɵɵInjectableDeclaration<LogoService>;
616
607
  }
617
608
 
609
+ /**
610
+ * Application information value. A function or a signal is read on every change detection,
611
+ * so it can return a localized value.
612
+ */
613
+ type AppInfoValue = string | (() => string);
614
+ /**
615
+ * Application information displayed by the shell components.
616
+ */
617
+ interface AppInfo {
618
+ /**
619
+ * Application version, for example generated at build time from package.json.
620
+ */
621
+ version?: AppInfoValue;
622
+ /**
623
+ * Application name displayed in the footer.
624
+ */
625
+ footer?: AppInfoValue;
626
+ /**
627
+ * Application name displayed in the top bar.
628
+ */
629
+ title?: AppInfoValue;
630
+ }
631
+ declare const APP_INFO_TOKEN: InjectionToken<AppInfo>;
632
+ /**
633
+ * Provides application information instead of the `app-info.*` translation keys.
634
+ */
635
+ declare function provideAppInfo(appInfo: AppInfo): Provider;
636
+ declare class AppInfoService {
637
+ private appInfo;
638
+ /**
639
+ * Returns the provided version or null when it should be taken from translations.
640
+ */
641
+ getVersion(): string | null;
642
+ /**
643
+ * Returns the provided application name or null when it should be taken from translations.
644
+ */
645
+ getFooter(): string | null;
646
+ /**
647
+ * Returns the provided application name or null when it should be taken from translations.
648
+ */
649
+ getTitle(): string | null;
650
+ private resolve;
651
+ static ɵfac: i0.ɵɵFactoryDeclaration<AppInfoService, never>;
652
+ static ɵprov: i0.ɵɵInjectableDeclaration<AppInfoService>;
653
+ }
654
+
618
655
  declare class AppTopbar {
656
+ private readonly translations;
619
657
  securityService: SecurityService;
620
658
  topBarService: TopBarService;
621
659
  userService: UserService;
622
660
  layoutService: LayoutService;
623
661
  logoService: LogoService;
662
+ appInfoService: AppInfoService;
624
663
  private readonly confirmationService;
625
664
  private readonly translateService;
626
665
  onActiveTabChange(value: string | number | undefined): void;
@@ -633,6 +672,7 @@ declare class AppTopbar {
633
672
 
634
673
  declare class FooterComponent {
635
674
  protected logoService: LogoService;
675
+ protected appInfoService: AppInfoService;
636
676
  static ɵfac: i0.ɵɵFactoryDeclaration<FooterComponent, never>;
637
677
  static ɵcmp: i0.ɵɵComponentDeclaration<FooterComponent, "app-footer", never, {}, {}, never, never, true, never>;
638
678
  }
@@ -848,6 +888,7 @@ declare class MenuItemEditDialogComponent {
848
888
  }
849
889
 
850
890
  declare class MenuComponent implements OnInit {
891
+ private readonly translations;
851
892
  readonly menuService: MenuService;
852
893
  readonly securityService: SecurityService;
853
894
  readonly translateService: TranslateService;
@@ -900,12 +941,13 @@ declare class LogoComponent {
900
941
  }
901
942
 
902
943
  declare class NotfoundComponent {
903
- constructor(l10nService: L10nService);
944
+ private readonly translations;
904
945
  static ɵfac: i0.ɵɵFactoryDeclaration<NotfoundComponent, never>;
905
946
  static ɵcmp: i0.ɵɵComponentDeclaration<NotfoundComponent, "app-notfound", never, {}, {}, never, never, true, never>;
906
947
  }
907
948
 
908
949
  declare class UnauthorizedComponent implements OnInit {
950
+ private readonly translations;
909
951
  protected readonly securityService: SecurityService;
910
952
  private readonly route;
911
953
  ngOnInit(): void;
@@ -915,11 +957,13 @@ declare class UnauthorizedComponent implements OnInit {
915
957
  }
916
958
 
917
959
  declare class AccessComponent {
960
+ private readonly translations;
918
961
  static ɵfac: i0.ɵɵFactoryDeclaration<AccessComponent, never>;
919
962
  static ɵcmp: i0.ɵɵComponentDeclaration<AccessComponent, "app-access", never, {}, {}, never, never, true, never>;
920
963
  }
921
964
 
922
965
  declare class ErrorComponent {
966
+ private readonly translations;
923
967
  static ɵfac: i0.ɵɵFactoryDeclaration<ErrorComponent, never>;
924
968
  static ɵcmp: i0.ɵɵComponentDeclaration<ErrorComponent, "app-error", never, {}, {}, never, never, true, never>;
925
969
  }
@@ -954,12 +998,12 @@ declare class UserProfileApi<SecurityDataType = unknown> extends HttpClient<Secu
954
998
  }
955
999
 
956
1000
  declare class UserProfileComponent {
1001
+ private readonly translations;
957
1002
  readonly userService: UserService;
958
1003
  readonly msgService: MsgService;
959
1004
  readonly translateService: TranslateService;
960
1005
  readonly userProfileApi: UserProfileApi<any>;
961
1006
  private readonly confirmationService;
962
- constructor(l10nService: L10nService);
963
1007
  uploadPhoto(event: any): Promise<void>;
964
1008
  confirmDeletePhoto(event: Event): void;
965
1009
  private deletePhoto;
@@ -968,6 +1012,7 @@ declare class UserProfileComponent {
968
1012
  }
969
1013
 
970
1014
  declare class ConfigComponent {
1015
+ private readonly translations;
971
1016
  private readonly layoutService;
972
1017
  protected readonly l10nService: L10nService;
973
1018
  protected readonly userService: UserService;
@@ -1003,46 +1048,7 @@ interface MigrationDto {
1003
1048
  exist: boolean;
1004
1049
  }
1005
1050
  declare class DbMigrationComponent extends BaseModuleComponent<NoSettingsDto, NoSettingsDto> implements OnInit, OnDestroy {
1006
- static readonly translations: {
1007
- en: {
1008
- "db-migration": {
1009
- migrationManager: string;
1010
- actions: {
1011
- refresh: string;
1012
- cleanFilter: string;
1013
- applyMigration: string;
1014
- };
1015
- columns: {
1016
- name: string;
1017
- applied: string;
1018
- exist: string;
1019
- pending: string;
1020
- };
1021
- messages: {
1022
- errorRefreshing: string;
1023
- };
1024
- };
1025
- };
1026
- ru: {
1027
- "db-migration": {
1028
- migrationManager: string;
1029
- actions: {
1030
- refresh: string;
1031
- cleanFilter: string;
1032
- applyMigration: string;
1033
- };
1034
- columns: {
1035
- name: string;
1036
- applied: string;
1037
- exist: string;
1038
- pending: string;
1039
- };
1040
- messages: {
1041
- errorRefreshing: string;
1042
- };
1043
- };
1044
- };
1045
- };
1051
+ private readonly translations;
1046
1052
  data: MigrationDto[];
1047
1053
  ngOnInit(): Promise<void>;
1048
1054
  refreshAction(): Promise<void>;
@@ -1159,6 +1165,7 @@ declare type SurfacesType = {
1159
1165
  palette?: PaletteDesignToken;
1160
1166
  };
1161
1167
  declare class AppConfiguratorComponent implements OnInit {
1168
+ private readonly translations;
1162
1169
  router: Router;
1163
1170
  config: PrimeNG;
1164
1171
  layoutService: LayoutService;
@@ -1179,7 +1186,6 @@ declare class AppConfiguratorComponent implements OnInit {
1179
1186
  label: string;
1180
1187
  value: string;
1181
1188
  }[];
1182
- constructor(l10nService: L10nService);
1183
1189
  ngOnInit(): void;
1184
1190
  surfaces: SurfacesType[];
1185
1191
  selectedPrimaryColor: i0.Signal<string>;
@@ -1321,6 +1327,7 @@ type DiscussionComment = Omit<CommentDto, 'attachments' | 'reactions' | 'mention
1321
1327
  type DiscussionHistoryItem = Required<CommentHistoryDto>;
1322
1328
  declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1323
1329
  private readonly msgService;
1330
+ private readonly translations;
1324
1331
  private readonly discussionApi;
1325
1332
  private readonly sanitizer;
1326
1333
  private readonly translateService;
@@ -1341,7 +1348,6 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1341
1348
  historyByComment: Record<number, HistoryState>;
1342
1349
  emojiPalette: string[];
1343
1350
  private mentionSearchTimer;
1344
- constructor(l10nService: L10nService);
1345
1351
  ngOnChanges(changes: SimpleChanges): void;
1346
1352
  ngOnInit(): Promise<void>;
1347
1353
  ngOnDestroy(): void;
@@ -1382,28 +1388,7 @@ declare class DiscussionComponent implements OnChanges, OnDestroy, OnInit {
1382
1388
  }
1383
1389
 
1384
1390
  declare class IframeModuleComponent extends BaseModuleComponent<IframeModuleSettings, IframeModuleSettings> implements OnInit, OnDestroy {
1385
- static readonly translations: {
1386
- en: {
1387
- "iframe-module": {
1388
- iframeModule: {
1389
- urlPlaceholder: string;
1390
- settingSaveButtonLabel: string;
1391
- emptyUrlMessage: string;
1392
- siteLoadingMessage: string;
1393
- };
1394
- };
1395
- };
1396
- ru: {
1397
- "iframe-module": {
1398
- iframeModule: {
1399
- urlPlaceholder: string;
1400
- settingSaveButtonLabel: string;
1401
- emptyUrlMessage: string;
1402
- siteLoadingMessage: string;
1403
- };
1404
- };
1405
- };
1406
- };
1391
+ private readonly translations;
1407
1392
  private iframe?;
1408
1393
  private readonly renderer;
1409
1394
  private readonly translate;
@@ -1494,6 +1479,7 @@ interface GetNotificationByIdParams {
1494
1479
  }
1495
1480
 
1496
1481
  declare class UserNotificationsComponent {
1482
+ private readonly translations;
1497
1483
  private popover?;
1498
1484
  protected notifications: UserNotificationDto[];
1499
1485
  protected totalCount: number;
@@ -1507,7 +1493,6 @@ declare class UserNotificationsComponent {
1507
1493
  private readonly translateService;
1508
1494
  protected readonly unreadNotificationCount: i0.Signal<number>;
1509
1495
  protected readonly unreadNotificationBadge: i0.Signal<string>;
1510
- constructor(l10nService: L10nService);
1511
1496
  protected toggle(event: Event): Promise<void>;
1512
1497
  loadNotifications(): Promise<void>;
1513
1498
  onPageChange(event: PaginatorState): Promise<void>;
@@ -1782,6 +1767,27 @@ declare class ApplicationsApi<SecurityDataType = unknown> extends HttpClient<Sec
1782
1767
 
1783
1768
  declare function convertToPrimeNgDateFormat(dateformat: string): string;
1784
1769
 
1770
+ /**
1771
+ * Registers a component's co-located translations and merges them into the
1772
+ * active language. The namespace is derived from the JSON's own root key,
1773
+ * so callers never repeat it as a string literal.
1774
+ *
1775
+ * Must be called from an injection context - as a field initializer, or as
1776
+ * the first statement in a constructor - the same requirement as `inject()`
1777
+ * itself, which it uses internally.
1778
+ *
1779
+ * ```ts
1780
+ * import en from './l10n/menu.en.json';
1781
+ * import ru from './l10n/menu.ru.json';
1782
+ *
1783
+ * @Component({ ... })
1784
+ * export class MenuComponent {
1785
+ * private readonly translations = provideTranslations({ en, ru });
1786
+ * }
1787
+ * ```
1788
+ */
1789
+ declare function provideTranslations(byLang: TranslationsByLang): Observable<Translation | TranslationObject>;
1790
+
1785
1791
  declare class NotificationApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
1786
1792
  getNotificationByUser: (query: GetNotificationByUserParams, params?: RequestParams) => Promise<UserNotificationListResponse>;
1787
1793
  getNotificationCountByUser: (params?: RequestParams) => Promise<UserNotificationCountResponse>;
@@ -1833,5 +1839,5 @@ declare class CustomElementExtensionModuleHostComponent extends BaseModuleCompon
1833
1839
  static ɵcmp: i0.ɵɵComponentDeclaration<CustomElementExtensionModuleHostComponent, "ng-component", never, {}, {}, never, never, true, never>;
1834
1840
  }
1835
1841
 
1836
- export { APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, AccessComponent, AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppLayoutComponent, AppModulesComponent, AppTopbar, AppTopbarApplicationSwitcherComponent, ApplicationRegistryService, ApplicationsApi, ApplicationsComponent, AuthGuardService, BaseModuleComponent, BffSecurityService, ConfigComponent, ContentType, CustomElementExtensionModuleHostComponent, DbMigrationComponent, DiscussionComponent, ErrorComponent, ExtensionLoaderService, ExtensionModuleHostComponent, FolderModuleApi, FooterComponent, HttpClient, IframeModuleApi, IframeModuleComponent, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, ModuleInstanceRightsService, MsgService, NotfoundComponent, NotificationApi, NotificationService, OIP_EXTENSION_EVENTS, SecurityApi, SecurityComponent, SecurityService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserNotificationsComponent, UserProfileApi, UserProfileComponent, UserService, convertToPrimeNgDateFormat, defaultTheme, emitOipContextChange, emitOipError, emitOipNavigate, emitOipNotify, emitOipSettingsChange, emitOipTitleChange, langIntercept, mergeWithDefaults, moduleAccessGuard, provideAppThemes, provideLogoComponent, provideOip, replaceDefaults };
1837
- export type { AppConfig, AppThemePreset, AppThemePresetMergeMode, AuthCsrfToken, LanguageDto, MenuChangeEvent, ModuleAccessRouteData, NoSettingsDto, OipExtensionHostContext, OipExtensionLoadType, OipExtensionManifest, OipExtensionModuleMetadata, OipExtensionNavigateEvent, OipExtensionNotifyEvent, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
1842
+ export { APP_INFO_TOKEN, APP_THEME_PRESETS, APP_THEME_PRESETS_MERGE_MODE, AccessComponent, AppConfiguratorComponent, AppFloatingConfiguratorComponent, AppInfoService, AppLayoutComponent, AppModulesComponent, AppTopbar, AppTopbarApplicationSwitcherComponent, ApplicationRegistryService, ApplicationsApi, ApplicationsComponent, AuthGuardService, BaseModuleComponent, BffSecurityService, ConfigComponent, ContentType, CustomElementExtensionModuleHostComponent, DbMigrationComponent, DiscussionComponent, ErrorComponent, ExtensionLoaderService, ExtensionModuleHostComponent, FolderModuleApi, FooterComponent, HttpClient, IframeModuleApi, IframeModuleComponent, L10nService, LOGO_COMPONENT_TOKEN, LayoutService, LogoComponent, LogoService, MenuComponent, MenuService, ModuleInstanceRightsService, MsgService, NotfoundComponent, NotificationApi, NotificationService, OIP_EXTENSION_EVENTS, SecurityApi, SecurityComponent, SecurityService, SidebarComponent, TableFilterService, TopBarService, UnauthorizedComponent, UserNotificationsComponent, UserProfileApi, UserProfileComponent, UserService, convertToPrimeNgDateFormat, defaultTheme, emitOipContextChange, emitOipError, emitOipNavigate, emitOipNotify, emitOipSettingsChange, emitOipTitleChange, langIntercept, mergeWithDefaults, moduleAccessGuard, provideAppInfo, provideAppThemes, provideLogoComponent, provideOip, provideTranslations, replaceDefaults };
1843
+ export type { AppConfig, AppInfo, AppInfoValue, AppThemePreset, AppThemePresetMergeMode, AuthCsrfToken, LanguageDto, MenuChangeEvent, ModuleAccessRouteData, NoSettingsDto, OipExtensionHostContext, OipExtensionLoadType, OipExtensionManifest, OipExtensionModuleMetadata, OipExtensionNavigateEvent, OipExtensionNotifyEvent, PutSecurityDto, RequestParams, SecurityDto, TopBarDto };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oip-common",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "A template for cross-platform web applications based on sakai-ng and primeNG",
5
5
  "main": "index.js",
6
6
  "keywords": [