@plyaz/types 1.22.0 → 1.22.2
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/api/index.cjs.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/core/domain/crud.d.ts +27 -0
- package/dist/core/domain/index.d.ts +2 -1
- package/dist/core/domain/types.d.ts +34 -0
- package/dist/core/events/payloads.d.ts +1 -0
- package/dist/core/frontend/featureFlags.d.ts +3 -3
- package/dist/core/frontend/index.d.ts +1 -1
- package/dist/core/frontend/types.d.ts +544 -8
- package/dist/core/index.d.ts +1 -0
- package/dist/core/init/index.d.ts +1 -1
- package/dist/core/init/types.d.ts +133 -3
- package/dist/core/services/index.d.ts +1 -0
- package/dist/core/services/keys.d.ts +40 -0
- package/dist/errors/codes.d.ts +11 -0
- package/dist/errors/index.cjs +13 -1
- package/dist/errors/index.cjs.map +1 -1
- package/dist/errors/index.js +13 -1
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/middleware.d.ts +23 -4
- package/dist/examples/types.d.ts +9 -5
- package/dist/features/cache/index.cjs +6 -0
- package/dist/features/cache/index.cjs.map +1 -1
- package/dist/features/cache/index.d.ts +1 -0
- package/dist/features/cache/index.js +5 -0
- package/dist/features/cache/index.js.map +1 -1
- package/dist/features/cache/types.d.ts +9 -1
- package/dist/features/index.cjs +6 -0
- package/dist/features/index.cjs.map +1 -1
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.js +5 -0
- package/dist/features/index.js.map +1 -1
- package/dist/index.cjs +30 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CRUD Operation Types
|
|
3
|
+
* Type definitions for CRUD operations in @plyaz/core domain services
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Cache-specific options for CRUD operations
|
|
7
|
+
*/
|
|
8
|
+
export interface CrudCacheOptions {
|
|
9
|
+
/** Enable/disable caching for this operation (default: true if cache available) */
|
|
10
|
+
useCache?: boolean;
|
|
11
|
+
/** TTL override for this specific operation (in seconds) */
|
|
12
|
+
cacheTtl?: number;
|
|
13
|
+
/** Force cache invalidation after operation (useful for updates/deletes) */
|
|
14
|
+
invalidateCache?: boolean;
|
|
15
|
+
/** Custom cache key (will still be prefixed with cachePrefix) */
|
|
16
|
+
customKey?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Options for CRUD operations (create, getById, patch, delete, getAll)
|
|
20
|
+
*
|
|
21
|
+
* Provides extensible configuration for CRUD operations with cache support
|
|
22
|
+
* and room for future additions like pagination, sorting, filtering, etc.
|
|
23
|
+
*/
|
|
24
|
+
export interface CrudOperationOptions {
|
|
25
|
+
/** Cache-related options */
|
|
26
|
+
cache?: CrudCacheOptions;
|
|
27
|
+
}
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
* Core Domain Types
|
|
3
3
|
* Type definitions for @plyaz/core domain services
|
|
4
4
|
*/
|
|
5
|
-
export type { CoreBaseDomainServiceInterface, CoreEventSubscribable, CoreProviderSubscribable, CoreValidationResult, CoreValidatorConfig, CoreBaseValidatorInstance, CoreBaseMapperInstance, CoreBaseDomainServiceConfig, CoreMapperClass, CoreValidatorClass, CoreBaseServiceConfig, } from './types';
|
|
5
|
+
export type { CoreBaseDomainServiceInterface, CoreEventSubscribable, CoreProviderSubscribable, CoreValidationResult, CoreValidatorConfig, CoreBaseValidatorInstance, CoreBaseMapperInstance, CoreBaseDomainServiceConfig, CoreBaseBackendServiceConfig, CoreMapperClass, CoreValidatorClass, CoreBaseServiceConfig, CoreInjectedServices, } from './types';
|
|
6
|
+
export type { CrudCacheOptions, CrudOperationOptions, } from './crud';
|
|
@@ -77,6 +77,7 @@ export interface CoreBaseValidatorInstance<TCreate = unknown, TUpdate = unknown,
|
|
|
77
77
|
export interface CoreBaseMapperInstance<TDomain = unknown, TResponseDTO = unknown, TCreateDTO = unknown, TUpdateDTO = TCreateDTO, TPatchDTO = Partial<TCreateDTO>, TQueryDTO = unknown, TStoreState = TDomain> {
|
|
78
78
|
toDomain(dto: TResponseDTO): TDomain;
|
|
79
79
|
toDomainList(dtos: TResponseDTO[]): TDomain[];
|
|
80
|
+
toResponseDTO?(row: unknown): TResponseDTO;
|
|
80
81
|
toCreateDTO?(data: Partial<TDomain>): TCreateDTO;
|
|
81
82
|
toUpdateDTO?(data: Partial<TDomain>): TUpdateDTO;
|
|
82
83
|
toPatchDTO?(data: Partial<TDomain>): TPatchDTO;
|
|
@@ -102,6 +103,18 @@ export type CoreMapperClass<T extends CoreBaseMapperInstance<unknown, unknown> =
|
|
|
102
103
|
* Type for validator class constructor
|
|
103
104
|
*/
|
|
104
105
|
export type CoreValidatorClass<T extends CoreBaseValidatorInstance = CoreBaseValidatorInstance> = new () => T;
|
|
106
|
+
/**
|
|
107
|
+
* Injected services/dependencies for domain services.
|
|
108
|
+
* These are created/managed by ServiceRegistry and injected into services.
|
|
109
|
+
*/
|
|
110
|
+
export interface CoreInjectedServices {
|
|
111
|
+
/** Cache manager instance */
|
|
112
|
+
cache?: unknown;
|
|
113
|
+
/** Database service instance */
|
|
114
|
+
db?: unknown;
|
|
115
|
+
/** API client instance */
|
|
116
|
+
api?: unknown;
|
|
117
|
+
}
|
|
105
118
|
/**
|
|
106
119
|
* Base service configuration passed to constructor
|
|
107
120
|
*/
|
|
@@ -120,4 +133,25 @@ export interface CoreBaseServiceConfig<TConfig extends CoreBaseDomainServiceConf
|
|
|
120
133
|
mapperClass?: CoreMapperClass<TMapper>;
|
|
121
134
|
/** Validator class for input validation */
|
|
122
135
|
validatorClass?: CoreValidatorClass<TValidator>;
|
|
136
|
+
/** Injected services (cache, db, api) */
|
|
137
|
+
injected?: CoreInjectedServices;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Configuration for backend domain services
|
|
141
|
+
* Extends base config with backend-specific options
|
|
142
|
+
*/
|
|
143
|
+
export interface CoreBaseBackendServiceConfig extends CoreBaseDomainServiceConfig {
|
|
144
|
+
/** Throw on validation errors (default: true) */
|
|
145
|
+
throwOnValidationError?: boolean;
|
|
146
|
+
/** Throw on repository errors (default: true) */
|
|
147
|
+
throwOnRepositoryError?: boolean;
|
|
148
|
+
/** Emit lifecycle events (default: true) */
|
|
149
|
+
emitEvents?: boolean;
|
|
150
|
+
/** Cache configuration */
|
|
151
|
+
cache?: {
|
|
152
|
+
/** Enable/disable cache for this service (default: true) */
|
|
153
|
+
enabled?: boolean;
|
|
154
|
+
/** Default TTL in seconds for cache entries (default: 300 = 5 minutes) */
|
|
155
|
+
defaultTtl?: number;
|
|
156
|
+
};
|
|
123
157
|
}
|
|
@@ -154,6 +154,7 @@ export interface CoreEntityDeletingPayload {
|
|
|
154
154
|
export interface CoreEntityErrorPayload {
|
|
155
155
|
error: unknown;
|
|
156
156
|
entityId?: string;
|
|
157
|
+
data?: Record<string, unknown>;
|
|
157
158
|
}
|
|
158
159
|
/**
|
|
159
160
|
* Payload for entity:*:complete events (regardless of success/failure)
|
|
@@ -88,11 +88,11 @@ export interface CoreFeatureFlagServiceInterface extends CoreBaseFrontendService
|
|
|
88
88
|
/** Fetch all flags and sync to stores */
|
|
89
89
|
fetchAndSyncAll(context?: FeatureFlagContext): Promise<Record<string, FeatureFlagValue>>;
|
|
90
90
|
/** Create a new flag */
|
|
91
|
-
|
|
91
|
+
createFlag<TKey extends string = string>(data: CreateFlagRequest<TKey>): Promise<FeatureFlag<TKey>>;
|
|
92
92
|
/** Update an existing flag */
|
|
93
|
-
|
|
93
|
+
updateFlag<TKey extends string = string>(key: TKey, data: Partial<CreateFlagRequest<TKey>>): Promise<FeatureFlag<TKey>>;
|
|
94
94
|
/** Delete a flag */
|
|
95
|
-
|
|
95
|
+
deleteFlag<TKey extends string = string>(key: TKey): Promise<void>;
|
|
96
96
|
/** Get rules for a flag */
|
|
97
97
|
getRules<TKey extends string = string>(key: TKey): Promise<FeatureFlagRule<TKey>[]>;
|
|
98
98
|
/** Get all rules */
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Core Frontend Types
|
|
3
3
|
* Type definitions for @plyaz/core frontend services
|
|
4
4
|
*/
|
|
5
|
-
export type { CoreBaseFrontendStore, CoreBaseFrontendServiceConfig, CoreBaseFrontendServiceInterface, CorePlyazApiConfig, FrontendFeatureFlagProvider, CorePlyazFeatureFlagConfig, CorePlyazStoreConfig, CorePlyazConfig, CoreFeatureFlagServiceLike, CoreFeatureFlagFetcherOptions, CoreFeatureFlagStoreInitConfig, CoreBaseFrontendServiceConstructorConfig, CoreInitializationErrorProps, CoreInitializationLoadingProps, CorePlyazServices, CorePlyazContextValue, CorePlyazProviderProps, } from './types';
|
|
5
|
+
export type { CoreBaseFrontendStore, CoreBaseFrontendServiceConfig, CoreBaseFrontendServiceInterface, CoreStoreHandlers, CoreFetcherFunction, CoreServiceFetchers, CorePlyazApiConfig, FrontendFeatureFlagProvider, CorePlyazFeatureFlagConfig, CorePlyazStoreConfig, CorePlyazConfig, CoreFeatureFlagServiceLike, CoreFeatureFlagFetcherOptions, CoreFeatureFlagStoreInitConfig, CoreBaseFrontendServiceConstructorConfig, CoreInitializationErrorProps, CoreInitializationLoadingProps, CorePlyazServices, CorePlyazContextValue, CorePlyazProviderProps, } from './types';
|
|
6
6
|
export type { CoreFrontendFeatureFlagEventType, CoreFeatureFlagStore, CoreFeatureFlagServiceConfig, CoreFeatureFlagServiceInitConfig, CoreFeatureFlagServiceInterface, } from './featureFlags';
|