@suntelecoms/ngx-dynamic-form 1.2.9 → 1.3.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![Angular](https://img.shields.io/badge/Angular-19-red?logo=angular)](https://angular.dev)
6
6
  [![Angular Material](https://img.shields.io/badge/Angular_Material-19-blue?logo=material-design)](https://material.angular.io)
7
- [![Version](https://img.shields.io/badge/version-1.2.9-brightgreen)](CHANGELOG.md)
7
+ [![Version](https://img.shields.io/badge/version-1.3.0-brightgreen)](CHANGELOG.md)
8
8
  [![License](https://img.shields.io/badge/License-MIT-green)](LICENSE)
9
9
  [![Author](https://img.shields.io/badge/Author-Amadou%20Diallo-purple)](mailto:amadoumacbookpro38@gmail.com)
10
10
 
@@ -68,6 +68,7 @@ Résultat : dans n'importe quel projet Angular, il suffit de **2 lignes** pour a
68
68
  - **Masque de saisie** — propriété `mask` (`#` = chiffre, autres chars = séparateurs) _(v1.2.7)_
69
69
  - **Préfixe / suffixe texte** — propriétés `prefix` et `suffix` _(v1.2.7)_
70
70
  - **Code unique par formulaire** — propriété `code` saisie par l'utilisateur, utilisée pour l'URL de partage et la récupération par code _(v1.2.9)_
71
+ - **Authentification Bearer token** — `auth` dans `provideNgxForms` + intercepteur `ngxFormsAuthInterceptor` pour les APIs sécurisées (login/mot de passe → JWT) _(v1.3.0)_
71
72
  - **Floating label** Angular Material (`mat-form-field appearance="outline"`)
72
73
  - **Validation déclarative** — `required`, `email`, `minLength`, `maxLength`, `min`, `max`, `pattern`, validateur personnalisé
73
74
  - **Messages d'erreur personnalisés** par champ
@@ -821,7 +822,7 @@ providers: [
821
822
  ]
822
823
  ```
823
824
 
824
- ### Stockage API REST (Spring Boot)
825
+ ### Stockage API REST (Spring Boot) — API ouverte
825
826
 
826
827
  ```typescript
827
828
  // app.config.ts
@@ -835,6 +836,34 @@ providers: [
835
836
  ]
836
837
  ```
837
838
 
839
+ ### Stockage API REST — API sécurisée (Bearer token) _(v1.3.0)_
840
+
841
+ Si votre API exige un token JWT, ajoutez `auth` et enregistrez l'intercepteur fourni :
842
+
843
+ ```typescript
844
+ // app.config.ts
845
+ import { provideHttpClient, withInterceptors } from '@angular/common/http';
846
+ import { ngxFormsAuthInterceptor, provideNgxForms } from '@suntelecoms/ngx-dynamic-form';
847
+
848
+ providers: [
849
+ provideHttpClient(withInterceptors([ngxFormsAuthInterceptor])),
850
+ provideNgxForms({
851
+ storage: 'http',
852
+ apiUrl: 'https://api.monprojet.com/api/forms',
853
+ dataUrl: 'https://api.monprojet.com',
854
+ auth: {
855
+ loginUrl: 'https://api.monprojet.com/security-service/api/login',
856
+ username: 'admin',
857
+ password: 'secret',
858
+ },
859
+ }),
860
+ ]
861
+ ```
862
+
863
+ > L'intercepteur est **no-op** si `auth` n'est pas configuré. Les APIs ouvertes ne nécessitent aucune modification.
864
+ >
865
+ > Le token est mis en cache en mémoire et renouvelé automatiquement avant expiration (`expiresIn - 10s`).
866
+
838
867
  ### Options de configuration
839
868
 
840
869
  | Option | Type | Description |
@@ -842,6 +871,9 @@ providers: [
842
871
  | `storage` | `'local' \| 'http'` | Moteur de stockage des schémas |
843
872
  | `apiUrl` | `string` | _(mode `http` uniquement)_ URL de base de l'API de stockage |
844
873
  | `dataUrl` | `string` | _(optionnel)_ Base URL pour le chargement des options de champs |
874
+ | `auth.loginUrl` | `string` | _(optionnel)_ Endpoint de login retournant `{ data: { accessToken, expiresIn } }` |
875
+ | `auth.username` | `string` | Identifiant pour le login |
876
+ | `auth.password` | `string` | Mot de passe pour le login |
845
877
 
846
878
  ### Endpoints REST attendus
847
879
 
@@ -1363,9 +1395,13 @@ export { HttpStorageAdapter } // implémentation API REST
1363
1395
  export { FORM_API_URL } // InjectionToken<string>
1364
1396
  export { provideNgxForms } // function(options) → EnvironmentProviders
1365
1397
  export { NGX_DATA_API_URL } // InjectionToken<string> — base URL pour les options dynamiques ← v1.2.5
1398
+ export { ngxFormsAuthInterceptor } // HttpInterceptorFn — ajoute Authorization: Bearer ← v1.3.0
1399
+ export { NgxFormsAuthService } // service token/cache ← v1.3.0
1400
+ export { NGX_FORMS_AUTH } // InjectionToken<NgxFormsAuthOptions> ← v1.3.0
1366
1401
 
1367
1402
  // Types
1368
- export type { NgxFormsOptions } // { storage: 'local' } | { storage: 'http', apiUrl: string }
1403
+ export type { NgxFormsOptions } // { storage: 'local' } | { storage: 'http', apiUrl: string }
1404
+ export type { NgxFormsAuthOptions } // { loginUrl, username, password } ← v1.3.0
1369
1405
  export type { AnyFormConfig } // DynamicFormConfig | StepperFormConfig ← v1.2.0
1370
1406
  export type { SavedFormSchema } // { id, code, title, config, createdAt, updatedAt } ← v1.2.9
1371
1407
  export type { DynamicFormConfig }
@@ -1383,6 +1419,13 @@ export type { SelectOption }
1383
1419
 
1384
1420
  ## Changelog
1385
1421
 
1422
+ ### v1.3.0
1423
+ - **Authentification Bearer token** : nouvelle option `auth` dans `provideNgxForms({ auth: { loginUrl, username, password } })`
1424
+ - **`ngxFormsAuthInterceptor`** : intercepteur HTTP fonctionnel à ajouter dans `provideHttpClient(withInterceptors([ngxFormsAuthInterceptor]))` — injecte automatiquement le header `Authorization: Bearer <token>` sur toutes les requêtes
1425
+ - **`NgxFormsAuthService`** : service de gestion du token JWT — login automatique au premier appel, cache en mémoire, renouvellement automatique 10 secondes avant expiration
1426
+ - **No-op sans auth** : l'intercepteur est transparent si `auth` n'est pas configuré — aucune modification requise pour les APIs ouvertes
1427
+ - **Compatibilité** : fonctionne avec les modes `storage: 'local'` et `storage: 'http'`
1428
+
1386
1429
  ### v1.2.9
1387
1430
  - **Code unique par formulaire** : nouvelle propriété `code` dans `SavedFormSchema` — identifiant court saisi par l'utilisateur (ex : `"contact-form"`), unique dans le stockage
1388
1431
  - **Date de création** : nouvelle propriété `createdAt` dans `SavedFormSchema` — ISO 8601, non modifiable après création