@flusys/ng-shared 3.0.1 → 4.0.0-rc

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  ## Package Information
10
10
 
11
11
  - **Package:** `@flusys/ng-shared`
12
- - **Version:** 3.0.1
12
+ - **Version:** 4.0.0-rc
13
13
  - **Dependencies:** ng-core
14
14
  - **Dependents:** ng-layout, ng-auth, ng-iam, ng-storage, flusysng
15
15
  - **Build Command:** `npm run build:ng-shared`
@@ -1268,28 +1268,18 @@ interface IUserPermissionProvider {
1268
1268
 
1269
1269
  **Token Error Message:** `'USER_PERMISSION_PROVIDER not configured. Please provide an implementation in app.config.ts'`
1270
1270
 
1271
- #### IProfileUploadProvider / `PROFILE_UPLOAD_PROVIDER`
1271
+ #### IFileProvider / `FILE_PROVIDER`
1272
1272
 
1273
- Profile picture upload for ng-auth profile page. Implemented by ng-storage. **Optional token** - use with `inject(..., { optional: true })`.
1273
+ File operations provider for file selection and upload. Implemented by ng-storage. **Optional token** - use with `inject(..., { optional: true })`.
1274
1274
 
1275
1275
  ```typescript
1276
- interface IProfileUploadResult {
1277
- id: string; // File manager ID (UUID)
1278
- name: string; // Original file name
1279
- key: string; // Storage key/path
1280
- size: number; // File size in bytes
1281
- contentType: string; // MIME type
1282
- }
1283
-
1284
- interface IProfileUploadOptions {
1285
- folderPath?: string;
1286
- compress?: boolean;
1287
- maxWidth?: number;
1288
- maxHeight?: number;
1289
- }
1290
-
1291
- interface IProfileUploadProvider {
1292
- uploadProfilePicture(file: File, options?: IProfileUploadOptions): Observable<ISingleResponse<IProfileUploadResult>>;
1276
+ interface IFileProvider {
1277
+ loadFiles(filter: IFileSelectFilter): Observable<IListResponse<IFileBasicInfo>>;
1278
+ uploadFile(file: File, options?: IFileUploadOptions): Observable<ISingleResponse<IUploadedFile>>;
1279
+ uploadMultipleFiles?(files: File[], options?: IFileUploadOptions): Observable<ISingleResponse<IUploadedFile[]>>;
1280
+ getFileUrls?(fileIds: string[]): Observable<ISingleResponse<IFileBasicInfo[]>>;
1281
+ loadFolders?(filter: ISelectFilter): Observable<IListResponse<IFolderBasicInfo>>;
1282
+ loadStorageConfigs?(filter: ISelectFilter): Observable<IListResponse<IStorageConfigBasicInfo>>;
1293
1283
  }
1294
1284
  ```
1295
1285
 
@@ -1635,11 +1625,16 @@ providers: [...provideAuthProviders()];
1635
1625
  | `IUserSelectFilter` | User select filter params |
1636
1626
  | `LoadUsersFn` | User loading function type |
1637
1627
  | `IFileBasicInfo` | Basic file info for selectors |
1628
+ | `IFolderBasicInfo` | Folder info for selectors |
1629
+ | `IStorageConfigBasicInfo` | Storage config info for selectors |
1638
1630
  | `IFileUploadOptions` | Upload options (compression, etc.) |
1639
1631
  | `IUploadedFile` | Uploaded file response |
1640
1632
  | `IFileSelectFilter` | File select filter params |
1633
+ | `ISelectFilter` | Filter params for folder/config selectors |
1641
1634
  | `LoadFilesFn` | File loading function type |
1642
- | `UploadFileFn` | File upload function type |
1635
+ | `UploadFileFn` | Single file upload function type |
1636
+ | `UploadMultipleFilesFn` | Multiple files upload function type |
1637
+ | `IFileProvider` | File operations provider interface |
1643
1638
  | `FilesResponseDto` | File URL service response |
1644
1639
  | `IAuthStateProvider` | Auth state provider interface |
1645
1640
  | `IUserListProvider` | User list extensions provider |
@@ -1658,10 +1653,153 @@ providers: [...provideAuthProviders()];
1658
1653
  | `COMPANY_API_PROVIDER` | `ICompanyApiProvider` | No | Company list for IAM |
1659
1654
  | `USER_PERMISSION_PROVIDER` | `IUserPermissionProvider` | No | User permission queries |
1660
1655
  | `AUTH_STATE_PROVIDER` | `IAuthStateProvider` | No | Auth state for feature packages |
1661
- | `PROFILE_UPLOAD_PROVIDER` | `IProfileUploadProvider` | Yes | Profile picture upload (ng-storage) |
1656
+ | `FILE_PROVIDER` | `IFileProvider` | Yes | File operations (ng-storage) |
1662
1657
  | `PROFILE_PERMISSION_PROVIDER` | `IProfilePermissionProvider` | Yes | User permissions for profile (ng-iam) |
1663
1658
  | `USER_LIST_PROVIDER` | `IUserListProvider` | Yes | User list extensions |
1664
1659
 
1660
+ ---
1661
+
1662
+ ## 10. Translation & Localization
1663
+
1664
+ ### Overview
1665
+
1666
+ The ng-shared package provides optional localization support via two modes:
1667
+
1668
+ 1. **Fallback-Only Mode** - Hardcoded fallback messages (no API)
1669
+ 2. **Full API Mode** - Dynamic translations from API with fallback safety net
1670
+
1671
+ ### Fallback-Only Mode
1672
+
1673
+ Use when you want simple hardcoded translations without a localization system:
1674
+
1675
+ ```typescript
1676
+ // app.config.ts
1677
+ import { provideFallbackLocalization } from '@flusys/ng-shared';
1678
+
1679
+ export const appConfig: ApplicationConfig = {
1680
+ providers: [
1681
+ // ... other providers
1682
+ ...provideFallbackLocalization(), // ← One-liner setup
1683
+ ],
1684
+ };
1685
+ ```
1686
+
1687
+ **What it provides:**
1688
+ - `FALLBACK_MESSAGES_REGISTRY` - Token for storing hardcoded messages
1689
+ - `TRANSLATE_ADAPTER` - Fallback implementation that reads from registry
1690
+ - Works with route resolvers that register fallback messages
1691
+
1692
+ **Message flow:**
1693
+ ```
1694
+ Route with resolveTranslationModule({
1695
+ modules: ['email'],
1696
+ fallbackMessages: EMAIL_MESSAGES
1697
+ })
1698
+
1699
+ Resolver registers in FALLBACK_MESSAGES_REGISTRY
1700
+
1701
+ TRANSLATE_ADAPTER reads from registry
1702
+
1703
+ Components/TranslatePipe render values
1704
+ ```
1705
+
1706
+ ### Full API Mode
1707
+
1708
+ Use when you need dynamic translations, language switching, and management UI:
1709
+
1710
+ ```typescript
1711
+ // app.config.ts
1712
+ import { provideLocalization, getLocalizationConfig } from '@flusys/ng-localization';
1713
+
1714
+ export const appConfig: ApplicationConfig = {
1715
+ providers: [
1716
+ // ... other providers
1717
+ ...provideLocalization(
1718
+ getLocalizationConfig({
1719
+ defaultLanguageCode: 'en',
1720
+ enableLayoutSelector: true, // Show language switcher
1721
+ })
1722
+ ),
1723
+ ],
1724
+ };
1725
+ ```
1726
+
1727
+ **What it provides:**
1728
+ - `LocalizationStateService` - Manages current language and translations
1729
+ - `LocalizationApiService` - Fetches translations from backend
1730
+ - `TranslateService` - Registered as `TRANSLATE_ADAPTER`
1731
+ - Language selector component (if `enableLayoutSelector: true`)
1732
+ - Management pages for languages and translations
1733
+
1734
+ ### Route Resolver Setup
1735
+
1736
+ All routes should use `resolveTranslationModule` with fallback messages:
1737
+
1738
+ ```typescript
1739
+ // email.routes.ts
1740
+ import { resolveTranslationModule, EMAIL_MESSAGES, SHARED_MESSAGES } from '@flusys/ng-shared';
1741
+
1742
+ export const EMAIL_ROUTES: Routes = [
1743
+ {
1744
+ path: '',
1745
+ resolve: {
1746
+ translations: resolveTranslationModule({
1747
+ modules: ['email'],
1748
+ fallbackMessages: { ...EMAIL_MESSAGES, ...SHARED_MESSAGES }
1749
+ })
1750
+ },
1751
+ // ... route definition
1752
+ }
1753
+ ];
1754
+ ```
1755
+
1756
+ ### TranslatePipe Usage
1757
+
1758
+ Works identically in both modes:
1759
+
1760
+ ```typescript
1761
+ // Template
1762
+ <h1>{{ 'email.title' | translate }}</h1>
1763
+ <p>{{ 'email.message' | translate: { count: itemCount } }}</p>
1764
+
1765
+ // Component
1766
+ const title = this.translateAdapter.translate('email.title');
1767
+ ```
1768
+
1769
+ ### Configuration (Full API Mode Only)
1770
+
1771
+ ```typescript
1772
+ interface ILocalizationConfig {
1773
+ defaultLanguageCode: string; // Required: 'en', 'ar', etc.
1774
+ loadStrategy?: 'all' | 'modules'; // Default: 'modules'
1775
+ initialModules?: string[]; // Default: []
1776
+ enableLayoutSelector?: boolean; // Default: false
1777
+ }
1778
+ ```
1779
+
1780
+ ### Key Files
1781
+
1782
+ | File | Purpose |
1783
+ |------|---------|
1784
+ | `providers/fallback-localization.providers.ts` | Fallback mode setup |
1785
+ | `resolvers/translation-module.resolver.ts` | Route resolver for both modes |
1786
+ | `pipes/translate.pipe.ts` | Translation pipe |
1787
+
1788
+ ### When to Use Each Mode
1789
+
1790
+ **Use Fallback-Only:**
1791
+ - Simple applications with static content
1792
+ - No language switching needed
1793
+ - No translation management UI
1794
+ - Lightweight setup
1795
+
1796
+ **Use Full API:**
1797
+ - Multi-language support required
1798
+ - User can switch languages
1799
+ - Admin manages translations
1800
+ - Real-time translation updates
1801
+ - Translation management UI needed
1802
+
1665
1803
  ## See Also
1666
1804
 
1667
1805
  - **[CORE-GUIDE.md](./CORE-GUIDE.md)** - Configuration, interceptors
@@ -1671,6 +1809,6 @@ providers: [...provideAuthProviders()];
1671
1809
 
1672
1810
  ---
1673
1811
 
1674
- **Last Updated:** 2026-02-25
1812
+ **Last Updated:** 2026-03-01
1675
1813
  **Version:** 3.0.1
1676
1814
  **Angular Version:** 21