@plyaz/core 1.8.4 → 1.9.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/dist/domain/base/BaseDomainService.d.ts +8 -3
- package/dist/domain/base/BaseDomainService.d.ts.map +1 -1
- package/dist/entry-backend.js +303 -204
- package/dist/entry-backend.js.map +1 -1
- package/dist/entry-backend.mjs +240 -141
- package/dist/entry-backend.mjs.map +1 -1
- package/dist/entry-frontend-browser.js +228 -138
- package/dist/entry-frontend-browser.js.map +1 -1
- package/dist/entry-frontend-browser.mjs +230 -140
- package/dist/entry-frontend-browser.mjs.map +1 -1
- package/dist/entry-frontend.js +228 -138
- package/dist/entry-frontend.js.map +1 -1
- package/dist/entry-frontend.mjs +230 -140
- package/dist/entry-frontend.mjs.map +1 -1
- package/dist/frontend/providers/PlyazProvider.d.ts.map +1 -1
- package/dist/index.js +305 -204
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +241 -141
- package/dist/index.mjs.map +1 -1
- package/dist/init/CoreInitializer.d.ts +13 -2
- package/dist/init/CoreInitializer.d.ts.map +1 -1
- package/dist/init/nestjs/index.js +217 -136
- package/dist/init/nestjs/index.js.map +1 -1
- package/dist/init/nestjs/index.mjs +219 -138
- package/dist/init/nestjs/index.mjs.map +1 -1
- package/dist/services/ApiClientService.d.ts +43 -0
- package/dist/services/ApiClientService.d.ts.map +1 -1
- package/dist/services/CacheService.d.ts +5 -0
- package/dist/services/CacheService.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import type { ApiClientWithEvents, ApiClientOptions } from '@plyaz/types/api';
|
|
11
11
|
import { type ClientEventManager, type EndpointsList } from '@plyaz/api/frontend';
|
|
12
12
|
import type { CoreApiEnvironmentConfig } from '@plyaz/types/core';
|
|
13
|
+
import type { ResponseError } from 'fetchff';
|
|
13
14
|
/**
|
|
14
15
|
* API Client Singleton Service
|
|
15
16
|
* Manages API client instance lifecycle with environment-specific configurations
|
|
@@ -48,6 +49,19 @@ export declare class ApiClientService {
|
|
|
48
49
|
private static instance;
|
|
49
50
|
private static isInitializing;
|
|
50
51
|
private static initPromise;
|
|
52
|
+
/**
|
|
53
|
+
* Build the core error handler for API clients.
|
|
54
|
+
* This handler emits errors to CoreEventManager for global error handling.
|
|
55
|
+
*
|
|
56
|
+
* Handles:
|
|
57
|
+
* - Single errors (network, timeout)
|
|
58
|
+
* - Array of errors from API responses (validation, business logic)
|
|
59
|
+
* - Serialization to unified SerializedError format
|
|
60
|
+
* - Event emission to CORE_EVENTS.SYSTEM.ERROR and CORE_EVENTS.API.REQUEST_ERROR
|
|
61
|
+
*
|
|
62
|
+
* @returns Error handler function compatible with ApiClientOptions.onError
|
|
63
|
+
*/
|
|
64
|
+
static buildCoreErrorHandler(): (error: ResponseError<unknown, unknown, unknown, unknown>) => Promise<void>;
|
|
51
65
|
/**
|
|
52
66
|
* Initialize the API client with environment config and API options
|
|
53
67
|
*
|
|
@@ -171,8 +185,37 @@ export declare class ApiClientService {
|
|
|
171
185
|
* ```
|
|
172
186
|
*/
|
|
173
187
|
static createInstance(envConfig: CoreApiEnvironmentConfig, apiConfig?: Partial<ApiClientOptions>): Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
188
|
+
/**
|
|
189
|
+
* Create a standalone API client with Core error handling.
|
|
190
|
+
*
|
|
191
|
+
* This is a simpler alternative to `createInstance()` that doesn't require
|
|
192
|
+
* environment config. Use this when you just need the error handling without
|
|
193
|
+
* environment-specific defaults (production validation, etc.).
|
|
194
|
+
*
|
|
195
|
+
* **Use cases:**
|
|
196
|
+
* - Domain services that need their own API client
|
|
197
|
+
* - Testing with isolated API clients
|
|
198
|
+
* - Simple client creation without environment setup
|
|
199
|
+
*
|
|
200
|
+
* @param apiConfig - API configuration (baseURL, timeout, etc.)
|
|
201
|
+
* @returns Promise that resolves to a client with Core error handling
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* // In BaseDomainService or any service
|
|
206
|
+
* const client = await ApiClientService.createStandaloneClient({
|
|
207
|
+
* baseURL: '/api/examples',
|
|
208
|
+
* timeout: 10000,
|
|
209
|
+
* });
|
|
210
|
+
*
|
|
211
|
+
* // Errors are automatically emitted to CoreEventManager
|
|
212
|
+
* const response = await client.get('/items');
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
static createStandaloneClient(apiConfig: ApiClientOptions): Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
174
216
|
}
|
|
175
217
|
export declare const getApiClient: () => ApiClientWithEvents<ClientEventManager, EndpointsList>;
|
|
176
218
|
export declare const initApiClient: (envConfig: CoreApiEnvironmentConfig, apiConfig?: Partial<ApiClientOptions>) => Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
177
219
|
export declare const createApiClientInstance: (envConfig: CoreApiEnvironmentConfig, apiConfig?: Partial<ApiClientOptions>) => Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
220
|
+
export declare const createStandaloneApiClient: (apiConfig: ApiClientOptions) => Promise<ApiClientWithEvents<ClientEventManager, EndpointsList>>;
|
|
178
221
|
//# sourceMappingURL=ApiClientService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiClientService.d.ts","sourceRoot":"","sources":["../../src/services/ApiClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAa,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAmB,MAAM,qBAAqB,CAAC;AAWnG,OAAO,KAAK,EAA8B,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiClientService.d.ts","sourceRoot":"","sources":["../../src/services/ApiClientService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,O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|
|
100
100
|
private logger;
|
|
101
101
|
/** Private constructor to enforce singleton */
|
|
102
102
|
private constructor();
|
|
103
|
+
/**
|
|
104
|
+
* Emits a cache error event via CoreEventManager.
|
|
105
|
+
* Called when cache operations fail to integrate with global error handling.
|
|
106
|
+
*/
|
|
107
|
+
private emitCacheError;
|
|
103
108
|
/**
|
|
104
109
|
* Initialize the cache service with configuration
|
|
105
110
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CacheService.d.ts","sourceRoot":"","sources":["../../src/services/CacheService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"CacheService.d.ts","sourceRoot":"","sources":["../../src/services/CacheService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAQnF;;;;;GAKG;AACH,qBAAa,YAAa,YAAW,wBAAwB;IAC3D,yBAAyB;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA6B;IAEpD,6BAA6B;IAC7B,OAAO,CAAC,YAAY,CAA6B;IAEjD,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAAgC;IAE9C,sBAAsB;IACtB,OAAO,CAAC,MAAM,CAA+C;IAE7D,+CAA+C;IAC/C,OAAO;IAMP;;;OAGG;IACH,OAAO,CAAC,cAAc;IActB;;;;;;;;;;;;;;;;OAgBG;WACU,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA4C/D;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,WAAW,IAAI,YAAY;IAUlC;;;;;;;;;;;;OAYG;IACH,eAAe,IAAI,YAAY;IAU/B;;;;OAIG;IACH,SAAS,IAAI,eAAe,GAAG,IAAI;IAInC;;;;OAIG;IACH,aAAa,IAAI,OAAO;IAIxB;;;;OAIG;IACH,MAAM,CAAC,KAAK,IAAI,IAAI;IAWpB;;;;;;OAMG;IAEH,OAAO,CAAC,cAAc;CA6BvB;AAGD,eAAO,MAAM,eAAe,QAAO,YAA0C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plyaz/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Shared core logic and utilities for Plyaz apps, services, and future SDKs – centralized, reusable, and scalable.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [],
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@plyaz/logger": "^1.4.1",
|
|
57
57
|
"@plyaz/store": "^1.1.3",
|
|
58
58
|
"@plyaz/translations": "^1.4.5",
|
|
59
|
-
"@plyaz/types": "^1.29.
|
|
59
|
+
"@plyaz/types": "^1.29.3",
|
|
60
60
|
"dotenv": "^17.2.3",
|
|
61
61
|
"fetchff": "^4.1.0",
|
|
62
62
|
"yaml": "^2.8.0",
|