ng-easycommerce-v18 0.3.17 → 0.3.18-beta.1

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.
@@ -7,6 +7,7 @@ import * as i0 from "@angular/core";
7
7
  export declare class ApiConstantsService {
8
8
  private _localStorage;
9
9
  private _translate;
10
+ private _runtimeConfig;
10
11
  /**
11
12
  * Contiene los datos provisto por el frontend en el archivo environment.ts
12
13
  */
@@ -0,0 +1,64 @@
1
+ import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { RuntimeConfigService } from './runtime-config.service';
4
+ import * as i0 from "@angular/core";
5
+ export interface ApiRequestOptions {
6
+ headers?: HttpHeaders | {
7
+ [header: string]: string | string[];
8
+ };
9
+ params?: HttpParams | {
10
+ [param: string]: string | string[];
11
+ };
12
+ withCredentials?: boolean;
13
+ }
14
+ /**
15
+ * Servicio base para realizar peticiones HTTP usando configuración dinámica
16
+ * Todos los servicios de la aplicación deben extender este servicio o usar sus métodos
17
+ */
18
+ export declare class BaseApiService {
19
+ protected http: HttpClient;
20
+ protected runtimeConfigService: RuntimeConfigService;
21
+ constructor(http: HttpClient, runtimeConfigService: RuntimeConfigService);
22
+ /**
23
+ * Construye una URL completa usando la API_URL del runtime
24
+ */
25
+ protected buildApiUrl(endpoint: string): string;
26
+ /**
27
+ * Obtiene headers comunes que incluyen información del runtime
28
+ */
29
+ protected getCommonHeaders(): HttpHeaders;
30
+ /**
31
+ * Método GET genérico
32
+ */
33
+ get<T>(endpoint: string, options?: ApiRequestOptions): Observable<T>;
34
+ /**
35
+ * Método POST genérico
36
+ */
37
+ post<T>(endpoint: string, data: any, options?: ApiRequestOptions): Observable<T>;
38
+ /**
39
+ * Método PUT genérico
40
+ */
41
+ put<T>(endpoint: string, data: any, options?: ApiRequestOptions): Observable<T>;
42
+ /**
43
+ * Método PATCH genérico
44
+ */
45
+ patch<T>(endpoint: string, data: any, options?: ApiRequestOptions): Observable<T>;
46
+ /**
47
+ * Método DELETE genérico
48
+ */
49
+ delete<T>(endpoint: string, options?: ApiRequestOptions): Observable<T>;
50
+ /**
51
+ * Método para peticiones que necesitan esperar a que la config esté cargada
52
+ */
53
+ getWithConfig<T>(endpoint: string, options?: ApiRequestOptions): Observable<T>;
54
+ /**
55
+ * Método para POST que necesitan esperar a que la config esté cargada
56
+ */
57
+ postWithConfig<T>(endpoint: string, data: any, options?: ApiRequestOptions): Observable<T>;
58
+ /**
59
+ * Combina headers personalizados con los headers comunes
60
+ */
61
+ private mergeHeaders;
62
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseApiService, never>;
63
+ static ɵprov: i0.ɵɵInjectableDeclaration<BaseApiService>;
64
+ }
@@ -24,3 +24,5 @@ export * from './order-utility.service';
24
24
  export * from './payment.service';
25
25
  export * from './test.service';
26
26
  export * from './orders.service';
27
+ export * from './runtime-config.service';
28
+ export * from './base-api.service';
@@ -0,0 +1,56 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { RuntimeConfig } from '../interfaces/runtime-config';
4
+ import * as i0 from "@angular/core";
5
+ export declare class RuntimeConfigService {
6
+ private platformId;
7
+ private http;
8
+ private configSubject;
9
+ config$: Observable<RuntimeConfig | null>;
10
+ private _config;
11
+ constructor(platformId: Object, http: HttpClient);
12
+ /**
13
+ * Carga la configuración en runtime
14
+ * - En SSR: Lee desde el objeto window inyectado por el servidor
15
+ * - En Browser: Hace petición HTTP a /runtime-config.json
16
+ */
17
+ loadConfig(): Observable<RuntimeConfig>;
18
+ /**
19
+ * Obtiene la configuración actual (síncrono)
20
+ */
21
+ getConfig(): RuntimeConfig | null;
22
+ /**
23
+ * Obtiene la API URL actual
24
+ */
25
+ getApiUrl(): string;
26
+ /**
27
+ * Obtiene la Frontend URL actual
28
+ */
29
+ getFrontendUrl(): string | undefined;
30
+ /**
31
+ * Obtiene el entorno actual
32
+ */
33
+ getAppEnv(): string;
34
+ /**
35
+ * Verifica si estamos en producción
36
+ */
37
+ isProduction(): boolean;
38
+ /**
39
+ * Obtiene el locale actual
40
+ */
41
+ getLocale(): string;
42
+ /**
43
+ * Obtiene el canal actual
44
+ */
45
+ getChannel(): string;
46
+ /**
47
+ * Método helper para construir URLs de API
48
+ */
49
+ buildApiUrl(endpoint: string): string;
50
+ /**
51
+ * Método helper para construir URLs del frontend
52
+ */
53
+ buildFrontendUrl(path: string): string;
54
+ static ɵfac: i0.ɵɵFactoryDeclaration<RuntimeConfigService, never>;
55
+ static ɵprov: i0.ɵɵInjectableDeclaration<RuntimeConfigService>;
56
+ }
@@ -4,4 +4,5 @@ export interface Environment {
4
4
  frontendUrl?: string;
5
5
  locale: string;
6
6
  channel: string;
7
+ appEnv?: string;
7
8
  }
@@ -16,3 +16,4 @@ export * from './coupon';
16
16
  export * from './step';
17
17
  export * from './checkout';
18
18
  export * from './faqs';
19
+ export * from './runtime-config';
@@ -0,0 +1,22 @@
1
+ export interface RuntimeConfig {
2
+ apiUrl: string;
3
+ frontendUrl?: string;
4
+ /** Ambiente de la aplicación. Valores válidos: 'prod', 'preprod', 'test' */
5
+ appEnv: 'prod' | 'preprod' | 'test';
6
+ production: boolean;
7
+ locale: string;
8
+ channel: string;
9
+ port?: number;
10
+ host?: string;
11
+ }
12
+ export interface ServerEnvironmentVariables {
13
+ API_URL?: string;
14
+ FRONTEND_URL?: string;
15
+ /** Ambiente de la aplicación. Valores válidos: 'prod', 'preprod', 'test' */
16
+ APP_ENV?: 'prod' | 'preprod' | 'test';
17
+ PORT?: string;
18
+ HOST?: string;
19
+ NODE_ENV?: 'development' | 'production';
20
+ LOCALE?: string;
21
+ CHANNEL?: string;
22
+ }
@@ -1 +1,2 @@
1
1
  export * from './provideEnvironment';
2
+ export * from './provideRuntimeConfig';
@@ -0,0 +1,12 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { RuntimeConfigService } from '../ec-services/runtime-config.service';
3
+ /**
4
+ * Factory function para APP_INITIALIZER
5
+ * Carga la configuración runtime antes de que Angular bootstrap la aplicación
6
+ */
7
+ export declare function initializeRuntimeConfig(runtimeConfigService: RuntimeConfigService): () => Promise<any>;
8
+ /**
9
+ * Función que configura el RuntimeConfigService y su inicialización
10
+ * Debe ser usado en app.config.ts junto con provideEnvironment
11
+ */
12
+ export declare function provideRuntimeConfig(): EnvironmentProviders;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-easycommerce-v18",
3
- "version": "0.3.17",
3
+ "version": "0.3.18-beta.1",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^18.2.0",
6
6
  "@angular/core": "^18.2.0"