@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.
@@ -0,0 +1,24 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import * as i0 from "@angular/core";
4
+ export interface NgxFormsAuthOptions {
5
+ /** URL du endpoint de login, ex : 'https://api.example.com/security-service/api/login' */
6
+ loginUrl: string;
7
+ /** Identifiant utilisateur */
8
+ username: string;
9
+ /** Mot de passe */
10
+ password: string;
11
+ }
12
+ export declare const NGX_FORMS_AUTH: InjectionToken<NgxFormsAuthOptions>;
13
+ export declare class NgxFormsAuthService {
14
+ private http;
15
+ private config;
16
+ private token;
17
+ private expiresAt;
18
+ /** Retourne un token valide — se connecte si absent ou expiré */
19
+ getToken(): Observable<string>;
20
+ /** Force une ré-authentification au prochain appel */
21
+ clearToken(): void;
22
+ static ɵfac: i0.ɵɵFactoryDeclaration<NgxFormsAuthService, never>;
23
+ static ɵprov: i0.ɵɵInjectableDeclaration<NgxFormsAuthService>;
24
+ }
@@ -1,21 +1,35 @@
1
1
  import { EnvironmentProviders, InjectionToken } from '@angular/core';
2
+ import { HttpInterceptorFn } from '@angular/common/http';
3
+ import { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH } from './auth/ngx-forms-auth.service';
4
+ export { NgxFormsAuthService, NgxFormsAuthOptions, NGX_FORMS_AUTH };
2
5
  /**
3
6
  * URL de base utilisée pour charger les options des champs select/multiselect/radio
4
7
  * via la propriété `url` d'un DynamicFormField.
5
- * Ex : 'https://api.monprojet.com' → url: 'comptes' → GET https://api.monprojet.com/comptes
6
8
  */
7
9
  export declare const NGX_DATA_API_URL: InjectionToken<string>;
10
+ /**
11
+ * Intercepteur HTTP fonctionnel — ajoute `Authorization: Bearer <token>` si
12
+ * NgxFormsAuthService est fourni (via `auth` dans provideNgxForms).
13
+ * No-op si l'auth n'est pas configurée.
14
+ *
15
+ * À ajouter dans `provideHttpClient(withInterceptors([ngxFormsAuthInterceptor]))`.
16
+ */
17
+ export declare const ngxFormsAuthInterceptor: HttpInterceptorFn;
8
18
  export interface NgxFormsLocalOptions {
9
19
  storage: 'local';
10
- /** URL de base pour le chargement dynamique des options de champs (select, multiselect, radio) */
20
+ /** URL de base pour le chargement dynamique des options de champs */
11
21
  dataUrl?: string;
22
+ /** Configuration d'authentification par token (optionnel) */
23
+ auth?: NgxFormsAuthOptions;
12
24
  }
13
25
  export interface NgxFormsHttpOptions {
14
26
  storage: 'http';
15
- /** URL de base de l'API de stockage des formulaires, ex: 'https://api.example.com/forms' */
27
+ /** URL de base de l'API de stockage des formulaires */
16
28
  apiUrl: string;
17
- /** URL de base pour le chargement dynamique des options de champs (select, multiselect, radio) */
29
+ /** URL de base pour le chargement dynamique des options de champs */
18
30
  dataUrl?: string;
31
+ /** Configuration d'authentification par token (optionnel) */
32
+ auth?: NgxFormsAuthOptions;
19
33
  }
20
34
  export type NgxFormsOptions = NgxFormsLocalOptions | NgxFormsHttpOptions;
21
35
  export declare function provideNgxForms(options: NgxFormsOptions): EnvironmentProviders;
@@ -7,6 +7,8 @@ export declare const FORM_API_URL: InjectionToken<string>;
7
7
  export declare class HttpStorageAdapter extends FormStorageAdapter {
8
8
  private http;
9
9
  private apiUrl;
10
+ /** Mappe le format API vers SavedFormSchema */
11
+ private toSchema;
10
12
  list(): Observable<SavedFormSchema[]>;
11
13
  get(id: string): Observable<SavedFormSchema | null>;
12
14
  getByCode(code: string): Observable<SavedFormSchema | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@suntelecoms/ngx-dynamic-form",
3
- "version": "1.2.9",
3
+ "version": "1.3.0",
4
4
  "description": "Générateur de formulaires Angular dynamiques — SUNTELECOMS",
5
5
  "author": "Amadou Diallo <amadoumacbookpro38@gmail.com>",
6
6
  "license": "MIT",
package/public-api.d.ts CHANGED
@@ -10,7 +10,9 @@ export { FormConfigService } from './lib/services/form-config.service';
10
10
  export { FormStorageAdapter } from './lib/storage/form-storage.adapter';
11
11
  export { LocalStorageAdapter } from './lib/storage/local-storage.adapter';
12
12
  export { HttpStorageAdapter, FORM_API_URL } from './lib/storage/http-storage.adapter';
13
- export { provideNgxForms, NGX_DATA_API_URL } from './lib/providers';
13
+ export { provideNgxForms, NGX_DATA_API_URL, ngxFormsAuthInterceptor } from './lib/providers';
14
14
  export type { NgxFormsOptions, NgxFormsLocalOptions, NgxFormsHttpOptions } from './lib/providers';
15
+ export { NgxFormsAuthService, NGX_FORMS_AUTH } from './lib/auth/ngx-forms-auth.service';
16
+ export type { NgxFormsAuthOptions } from './lib/auth/ngx-forms-auth.service';
15
17
  export type { DynamicFormField, DynamicFormConfig, StepperFormConfig, FormStep, DynamicFormSubmitEvent, FieldType, FieldValidation, FieldCondition, SelectOption, } from './lib/models/form-field.model';
16
18
  export type { SavedFormSchema, AnyFormConfig } from './lib/models/saved-form.model';