@plyaz/types 1.22.2 → 1.22.3
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/core/init/types.d.ts +81 -2
- package/dist/core/modules.d.ts +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,8 +9,9 @@ import type { StoreKey } from '../../store';
|
|
|
9
9
|
import type { FeatureFlagValue, FeatureFlagPollingConfig, CacheStrategyType } from '../../features';
|
|
10
10
|
import type { PackageErrorLike } from '../../errors';
|
|
11
11
|
import type { GlobalErrorHandlerConfig, ErrorHandlerLogger } from '../../errors/middleware';
|
|
12
|
-
import type { CoreAppEnvironment, CoreAppContext, CoreRuntimeEnvironment } from '../modules';
|
|
12
|
+
import type { CoreAppEnvironment, CoreAppContext, CoreRuntimeEnvironment, CoreServiceRuntime } from '../modules';
|
|
13
13
|
import type { CoreDbServiceConfig } from '../services';
|
|
14
|
+
import type { CoreInjectedServices } from '../domain';
|
|
14
15
|
/**
|
|
15
16
|
* Base interface that all domain service instances must implement.
|
|
16
17
|
* This allows the registry to manage services generically.
|
|
@@ -184,11 +185,57 @@ export interface CoreServiceInitConfig {
|
|
|
184
185
|
* ```
|
|
185
186
|
*/
|
|
186
187
|
dedicatedCache?: boolean | CoreCacheConfig;
|
|
188
|
+
/**
|
|
189
|
+
* Service-level cache configuration.
|
|
190
|
+
* Controls caching behavior for this specific service's operations.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* {
|
|
195
|
+
* service: ExampleService,
|
|
196
|
+
* config: {
|
|
197
|
+
* cache: {
|
|
198
|
+
* enabled: true,
|
|
199
|
+
* defaultTtl: 300, // 5 minutes
|
|
200
|
+
* },
|
|
201
|
+
* },
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
cache?: {
|
|
206
|
+
/** Enable cache for this service (default: true) */
|
|
207
|
+
enabled?: boolean;
|
|
208
|
+
/** Default TTL in seconds for cached operations */
|
|
209
|
+
defaultTtl?: number;
|
|
210
|
+
};
|
|
187
211
|
}
|
|
188
212
|
/**
|
|
189
213
|
* Options passed to the service factory method
|
|
190
214
|
*/
|
|
191
|
-
export interface CoreServiceCreateOptions {
|
|
215
|
+
export interface CoreServiceCreateOptions<TConfig = unknown, TMapper = unknown, TValidator = unknown> {
|
|
216
|
+
/**
|
|
217
|
+
* The service-specific configuration object.
|
|
218
|
+
* Optional when passed from ServiceRegistry (services build their own).
|
|
219
|
+
*/
|
|
220
|
+
serviceConfig?: TConfig;
|
|
221
|
+
/**
|
|
222
|
+
* Mapper class to use for DTO transformations.
|
|
223
|
+
*/
|
|
224
|
+
MapperClass?: new () => TMapper;
|
|
225
|
+
/**
|
|
226
|
+
* Validator class to use for validation.
|
|
227
|
+
*/
|
|
228
|
+
ValidatorClass?: new () => TValidator;
|
|
229
|
+
/**
|
|
230
|
+
* Service name for logging and identification.
|
|
231
|
+
* Optional when passed from ServiceRegistry (services provide their own).
|
|
232
|
+
*/
|
|
233
|
+
serviceName?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Supported runtime environments.
|
|
236
|
+
* Optional when passed from ServiceRegistry (services provide their own).
|
|
237
|
+
*/
|
|
238
|
+
supportedRuntimes?: readonly CoreServiceRuntime[];
|
|
192
239
|
/**
|
|
193
240
|
* API client configuration and mode.
|
|
194
241
|
*/
|
|
@@ -261,6 +308,11 @@ export interface CoreServiceCreateOptions {
|
|
|
261
308
|
* Passed from the service config to the create method.
|
|
262
309
|
*/
|
|
263
310
|
storeKeys?: StoreKey[];
|
|
311
|
+
/**
|
|
312
|
+
* Injected service instances (cache, db, api).
|
|
313
|
+
* Services built by ServiceRegistry will receive these automatically.
|
|
314
|
+
*/
|
|
315
|
+
injected?: CoreInjectedServices;
|
|
264
316
|
}
|
|
265
317
|
/**
|
|
266
318
|
* Static interface that service classes must implement.
|
|
@@ -393,6 +445,33 @@ export interface CoreErrorHandlerInitConfig extends Omit<GlobalErrorHandlerConfi
|
|
|
393
445
|
* Set to false to disable logging.
|
|
394
446
|
*/
|
|
395
447
|
logger?: ErrorHandlerLogger | boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Localization configuration for error messages.
|
|
450
|
+
* Configure how error messages are translated and which locales are available.
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* ```typescript
|
|
454
|
+
* errorHandler: {
|
|
455
|
+
* localization: {
|
|
456
|
+
* defaultLocale: 'es',
|
|
457
|
+
* fallbackLocale: 'en',
|
|
458
|
+
* additionalCatalogs: {
|
|
459
|
+
* es: { errors: { custom_error: 'Error personalizado' } }
|
|
460
|
+
* }
|
|
461
|
+
* }
|
|
462
|
+
* }
|
|
463
|
+
* ```
|
|
464
|
+
*/
|
|
465
|
+
localization?: {
|
|
466
|
+
/** Default locale to use for error messages (default: 'en') */
|
|
467
|
+
defaultLocale?: string;
|
|
468
|
+
/** Fallback locale if translation not found (default: 'en') */
|
|
469
|
+
fallbackLocale?: string;
|
|
470
|
+
/** Additional message catalogs to merge with built-in messages */
|
|
471
|
+
additionalCatalogs?: Record<string, unknown>;
|
|
472
|
+
/** Replace built-in catalogs entirely (default: false) */
|
|
473
|
+
replaceBuiltIn?: boolean;
|
|
474
|
+
};
|
|
396
475
|
}
|
|
397
476
|
/**
|
|
398
477
|
* Cache initialization configuration
|
package/dist/core/modules.d.ts
CHANGED
|
@@ -311,7 +311,7 @@ export interface CoreApiInitOptions {
|
|
|
311
311
|
/**
|
|
312
312
|
* Core initialization options
|
|
313
313
|
*/
|
|
314
|
-
export interface CoreInitOptions<TDbConfig = unknown, TApiConfig = CoreApiInitOptions> {
|
|
314
|
+
export interface CoreInitOptions<TDbConfig = unknown, TApiConfig = CoreApiInitOptions, TCacheConfig = unknown> {
|
|
315
315
|
/** Path to .env file */
|
|
316
316
|
envPath?: string;
|
|
317
317
|
/** Global application environment */
|
|
@@ -324,19 +324,24 @@ export interface CoreInitOptions<TDbConfig = unknown, TApiConfig = CoreApiInitOp
|
|
|
324
324
|
db?: TDbConfig;
|
|
325
325
|
/** API client configuration */
|
|
326
326
|
api?: TApiConfig;
|
|
327
|
+
/** Cache configuration */
|
|
328
|
+
cache?: TCacheConfig;
|
|
327
329
|
/** Skip database initialization */
|
|
328
330
|
skipDb?: boolean;
|
|
329
331
|
/** Skip API client initialization */
|
|
330
332
|
skipApi?: boolean;
|
|
333
|
+
/** Skip cache initialization */
|
|
334
|
+
skipCache?: boolean;
|
|
331
335
|
/** Enable verbose logging */
|
|
332
336
|
verbose?: boolean;
|
|
333
337
|
}
|
|
334
338
|
/**
|
|
335
339
|
* Core initialization result
|
|
336
340
|
*/
|
|
337
|
-
export interface CoreServicesResult<TDb = unknown, TApi = unknown> {
|
|
341
|
+
export interface CoreServicesResult<TDb = unknown, TApi = unknown, TCache = unknown> {
|
|
338
342
|
db: TDb | null;
|
|
339
343
|
api: TApi | null;
|
|
344
|
+
cache: TCache | null;
|
|
340
345
|
env: CoreEnvVars;
|
|
341
346
|
runtime: CoreRuntimeEnvironment;
|
|
342
347
|
appContext: CoreAppContext;
|