@plyaz/types 1.9.2 → 1.9.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/api/index.d.ts +1 -0
- package/dist/api/services/types.d.ts +63 -0
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export type * from './config/types';
|
|
|
38
38
|
export type * from './utils/types';
|
|
39
39
|
export type * from './pubsub/types';
|
|
40
40
|
export type * from './hooks/types';
|
|
41
|
+
export type * from './services/types';
|
|
41
42
|
export type * from './endpoints/types';
|
|
42
43
|
export type * from './endpoints/health/types';
|
|
43
44
|
export type * from './endpoints/campaigns/types';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Layer Types
|
|
3
|
+
* Core types for service functions and configuration
|
|
4
|
+
*/
|
|
5
|
+
import type { ApiClientWithEvents, UpdateConfigOptions } from '../client/types';
|
|
6
|
+
import type { ApiConfig } from '../config';
|
|
7
|
+
/**
|
|
8
|
+
* Options for service functions
|
|
9
|
+
* Allows overriding the API client instance, temporary config updates, and update strategy
|
|
10
|
+
*
|
|
11
|
+
* By default, services use a shared client instance with all available endpoints.
|
|
12
|
+
* This interface allows customization of the client behavior per-request or permanently.
|
|
13
|
+
*
|
|
14
|
+
* @template TEndpoints - The endpoints type for the API client
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* // Use default client (has access to all endpoints internally)
|
|
19
|
+
* const campaign = await fetchCampaign('123');
|
|
20
|
+
*
|
|
21
|
+
* // Override timeout temporarily (uses temporary config mode by default)
|
|
22
|
+
* const campaign = await fetchCampaign('123', {
|
|
23
|
+
* apiConfig: { timeout: 5000 }
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Override with different update strategy
|
|
27
|
+
* const campaign = await fetchCampaign('123', {
|
|
28
|
+
* apiConfig: { timeout: 5000 },
|
|
29
|
+
* updateConfigOptions: { strategy: 'merge', scope: 'client' }
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Use custom client instance (rare - usually for testing)
|
|
33
|
+
* const customClient = await createApiClient({ baseURL: 'https://staging.api.com' });
|
|
34
|
+
* const campaign = await fetchCampaign('123', {
|
|
35
|
+
* apiClient: customClient,
|
|
36
|
+
* apiConfig: { retry: { attempts: 5 } }
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export interface ServiceOptions<TEndpoints = unknown, TEventManager = unknown> {
|
|
41
|
+
/**
|
|
42
|
+
* Optional API client instance override
|
|
43
|
+
* Use this when you need a different client configuration
|
|
44
|
+
* The client should have all required endpoints for the service
|
|
45
|
+
*/
|
|
46
|
+
apiClient?: ApiClientWithEvents<TEventManager, TEndpoints>;
|
|
47
|
+
/**
|
|
48
|
+
* Optional API configuration updates
|
|
49
|
+
* By default applied with { strategy: 'temporary' } mode (affects only this request)
|
|
50
|
+
* Can be overridden via updateConfigOptions
|
|
51
|
+
*/
|
|
52
|
+
apiConfig?: Partial<ApiConfig>;
|
|
53
|
+
/**
|
|
54
|
+
* Optional update config options
|
|
55
|
+
* Controls how apiConfig is applied to the client
|
|
56
|
+
*
|
|
57
|
+
* Defaults to: { strategy: 'temporary' }
|
|
58
|
+
* - 'temporary': Only affects this request (highest priority)
|
|
59
|
+
* - 'merge': Merges with client config (persists)
|
|
60
|
+
* - 'replace': Replaces client config (persists)
|
|
61
|
+
*/
|
|
62
|
+
updateConfigOptions?: UpdateConfigOptions;
|
|
63
|
+
}
|
package/package.json
CHANGED