@aifabrix/miso-client 2.1.2 → 2.2.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/README.md +45 -0
- package/dist/index.d.ts +24 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/dist/services/auth.service.d.ts +22 -5
- package/dist/services/auth.service.d.ts.map +1 -1
- package/dist/services/auth.service.js +89 -11
- package/dist/services/auth.service.js.map +1 -1
- package/dist/types/config.types.d.ts +20 -1
- package/dist/types/config.types.d.ts.map +1 -1
- package/dist/types/config.types.js.map +1 -1
- package/dist/types/data-client.types.d.ts +267 -0
- package/dist/types/data-client.types.d.ts.map +1 -0
- package/dist/types/data-client.types.js +53 -0
- package/dist/types/data-client.types.js.map +1 -0
- package/dist/utils/data-client.d.ts +113 -0
- package/dist/utils/data-client.d.ts.map +1 -0
- package/dist/utils/data-client.js +703 -0
- package/dist/utils/data-client.js.map +1 -0
- package/dist/utils/internal-http-client.d.ts +6 -1
- package/dist/utils/internal-http-client.d.ts.map +1 -1
- package/dist/utils/internal-http-client.js +61 -7
- package/dist/utils/internal-http-client.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for DataClient browser wrapper
|
|
3
|
+
*/
|
|
4
|
+
import { MisoClientConfig } from "./config.types";
|
|
5
|
+
/**
|
|
6
|
+
* ISO 27001 audit logging configuration
|
|
7
|
+
*/
|
|
8
|
+
export interface AuditConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Audit detail level
|
|
11
|
+
* - minimal: Only method, URL, status, duration, userId
|
|
12
|
+
* - standard: Includes headers and bodies (masked)
|
|
13
|
+
* - detailed: Includes sizes and more metadata
|
|
14
|
+
* - full: Complete audit trail with all details
|
|
15
|
+
*/
|
|
16
|
+
level?: "minimal" | "standard" | "detailed" | "full";
|
|
17
|
+
/**
|
|
18
|
+
* Batch size for queued audit logs (default: 10)
|
|
19
|
+
*/
|
|
20
|
+
batchSize?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Maximum response size to include in audit logs (default: 10000)
|
|
23
|
+
*/
|
|
24
|
+
maxResponseSize?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum size before skipping masking (default: 50000)
|
|
27
|
+
*/
|
|
28
|
+
maxMaskingSize?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Endpoints to skip audit logging (e.g., ['/health', '/metrics'])
|
|
31
|
+
*/
|
|
32
|
+
skipEndpoints?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Enable/disable audit logging (default: true)
|
|
35
|
+
*/
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Cache configuration
|
|
40
|
+
*/
|
|
41
|
+
export interface CacheConfig {
|
|
42
|
+
/**
|
|
43
|
+
* Default TTL in seconds (default: 300 = 5 minutes)
|
|
44
|
+
*/
|
|
45
|
+
defaultTTL?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Maximum cache size in entries (default: 100)
|
|
48
|
+
*/
|
|
49
|
+
maxSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Enable cache (default: true)
|
|
52
|
+
*/
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Retry configuration
|
|
57
|
+
*/
|
|
58
|
+
export interface RetryConfig {
|
|
59
|
+
/**
|
|
60
|
+
* Maximum number of retries (default: 3)
|
|
61
|
+
*/
|
|
62
|
+
maxRetries?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Base delay in milliseconds for exponential backoff (default: 1000)
|
|
65
|
+
*/
|
|
66
|
+
baseDelay?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Maximum delay in milliseconds (default: 10000)
|
|
69
|
+
*/
|
|
70
|
+
maxDelay?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Enable retry logic (default: true)
|
|
73
|
+
*/
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* DataClient configuration
|
|
78
|
+
*/
|
|
79
|
+
export interface DataClientConfig {
|
|
80
|
+
/**
|
|
81
|
+
* Base URL for API requests
|
|
82
|
+
*/
|
|
83
|
+
baseUrl: string;
|
|
84
|
+
/**
|
|
85
|
+
* MisoClient configuration (required for authentication and audit logging)
|
|
86
|
+
*/
|
|
87
|
+
misoConfig: MisoClientConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Token storage keys in localStorage (default: ['token', 'accessToken', 'authToken'])
|
|
90
|
+
*/
|
|
91
|
+
tokenKeys?: string[];
|
|
92
|
+
/**
|
|
93
|
+
* Login redirect URL (default: '/login')
|
|
94
|
+
*/
|
|
95
|
+
loginUrl?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Cache configuration
|
|
98
|
+
*/
|
|
99
|
+
cache?: CacheConfig;
|
|
100
|
+
/**
|
|
101
|
+
* Retry configuration
|
|
102
|
+
*/
|
|
103
|
+
retry?: RetryConfig;
|
|
104
|
+
/**
|
|
105
|
+
* ISO 27001 audit logging configuration
|
|
106
|
+
*/
|
|
107
|
+
audit?: AuditConfig;
|
|
108
|
+
/**
|
|
109
|
+
* Default request timeout in milliseconds (default: 30000)
|
|
110
|
+
*/
|
|
111
|
+
timeout?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Default headers to include in all requests
|
|
114
|
+
*/
|
|
115
|
+
defaultHeaders?: Record<string, string>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Extended RequestInit with DataClient-specific options
|
|
119
|
+
*/
|
|
120
|
+
export interface ApiRequestOptions extends RequestInit {
|
|
121
|
+
/**
|
|
122
|
+
* Skip authentication for this request
|
|
123
|
+
*/
|
|
124
|
+
skipAuth?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Override retry count for this request
|
|
127
|
+
*/
|
|
128
|
+
retries?: number;
|
|
129
|
+
/**
|
|
130
|
+
* AbortController signal for cancellation
|
|
131
|
+
*/
|
|
132
|
+
signal?: AbortSignal;
|
|
133
|
+
/**
|
|
134
|
+
* Request timeout in milliseconds
|
|
135
|
+
*/
|
|
136
|
+
timeout?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Cache options
|
|
139
|
+
*/
|
|
140
|
+
cache?: {
|
|
141
|
+
/**
|
|
142
|
+
* Enable caching for this request (default: true for GET requests)
|
|
143
|
+
*/
|
|
144
|
+
enabled?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Cache TTL in seconds
|
|
147
|
+
*/
|
|
148
|
+
ttl?: number;
|
|
149
|
+
/**
|
|
150
|
+
* Cache key (auto-generated if not provided)
|
|
151
|
+
*/
|
|
152
|
+
key?: string;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Skip audit logging for this request
|
|
156
|
+
*/
|
|
157
|
+
skipAudit?: boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Request interceptor function
|
|
161
|
+
*/
|
|
162
|
+
export type RequestInterceptor = (url: string, options: ApiRequestOptions) => Promise<ApiRequestOptions> | ApiRequestOptions;
|
|
163
|
+
/**
|
|
164
|
+
* Response interceptor function
|
|
165
|
+
*/
|
|
166
|
+
export type ResponseInterceptor = <T>(response: Response, data: T) => Promise<T> | T;
|
|
167
|
+
/**
|
|
168
|
+
* Error interceptor function
|
|
169
|
+
*/
|
|
170
|
+
export type ErrorInterceptor = (error: Error, response?: Response) => Promise<Error> | Error;
|
|
171
|
+
/**
|
|
172
|
+
* Interceptor configuration
|
|
173
|
+
*/
|
|
174
|
+
export interface InterceptorConfig {
|
|
175
|
+
/**
|
|
176
|
+
* Request interceptor
|
|
177
|
+
*/
|
|
178
|
+
onRequest?: RequestInterceptor;
|
|
179
|
+
/**
|
|
180
|
+
* Response interceptor
|
|
181
|
+
*/
|
|
182
|
+
onResponse?: ResponseInterceptor;
|
|
183
|
+
/**
|
|
184
|
+
* Error interceptor
|
|
185
|
+
*/
|
|
186
|
+
onError?: ErrorInterceptor;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Request metrics structure
|
|
190
|
+
*/
|
|
191
|
+
export interface RequestMetrics {
|
|
192
|
+
/**
|
|
193
|
+
* Total number of requests
|
|
194
|
+
*/
|
|
195
|
+
totalRequests: number;
|
|
196
|
+
/**
|
|
197
|
+
* Total number of failed requests
|
|
198
|
+
*/
|
|
199
|
+
totalFailures: number;
|
|
200
|
+
/**
|
|
201
|
+
* Average response time in milliseconds
|
|
202
|
+
*/
|
|
203
|
+
averageResponseTime: number;
|
|
204
|
+
/**
|
|
205
|
+
* Response time distribution (in milliseconds)
|
|
206
|
+
*/
|
|
207
|
+
responseTimeDistribution: {
|
|
208
|
+
min: number;
|
|
209
|
+
max: number;
|
|
210
|
+
p50: number;
|
|
211
|
+
p95: number;
|
|
212
|
+
p99: number;
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Error rate (0-1)
|
|
216
|
+
*/
|
|
217
|
+
errorRate: number;
|
|
218
|
+
/**
|
|
219
|
+
* Cache hit rate (0-1)
|
|
220
|
+
*/
|
|
221
|
+
cacheHitRate: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Cache entry structure
|
|
225
|
+
*/
|
|
226
|
+
export interface CacheEntry {
|
|
227
|
+
/**
|
|
228
|
+
* Cached data
|
|
229
|
+
*/
|
|
230
|
+
data: unknown;
|
|
231
|
+
/**
|
|
232
|
+
* Expiration timestamp
|
|
233
|
+
*/
|
|
234
|
+
expiresAt: number;
|
|
235
|
+
/**
|
|
236
|
+
* Cache key
|
|
237
|
+
*/
|
|
238
|
+
key: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Base API error class
|
|
242
|
+
*/
|
|
243
|
+
export declare class ApiError extends Error {
|
|
244
|
+
readonly statusCode?: number;
|
|
245
|
+
readonly response?: Response;
|
|
246
|
+
readonly originalError?: Error;
|
|
247
|
+
constructor(message: string, statusCode?: number, response?: Response, originalError?: Error);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Network error (connection failures, CORS, etc.)
|
|
251
|
+
*/
|
|
252
|
+
export declare class NetworkError extends ApiError {
|
|
253
|
+
constructor(message: string, originalError?: Error);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Timeout error
|
|
257
|
+
*/
|
|
258
|
+
export declare class TimeoutError extends ApiError {
|
|
259
|
+
constructor(message: string, _timeout: number);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Authentication error (401 Unauthorized)
|
|
263
|
+
*/
|
|
264
|
+
export declare class AuthenticationError extends ApiError {
|
|
265
|
+
constructor(message: string, response?: Response);
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=data-client.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-client.types.d.ts","sourceRoot":"","sources":["../../src/types/data-client.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;IAErD;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IAEzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE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,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpC,SAAgB,aAAa,CAAC,EAAE,KAAK,CAAC;gBAGpC,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,QAAQ,EACnB,aAAa,CAAC,EAAE,KAAK;CAYxB;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,OAAO,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,KAAK;CAInD;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI9C;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ;CAIjD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for DataClient browser wrapper
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AuthenticationError = exports.TimeoutError = exports.NetworkError = exports.ApiError = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Base API error class
|
|
9
|
+
*/
|
|
10
|
+
class ApiError extends Error {
|
|
11
|
+
constructor(message, statusCode, response, originalError) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "ApiError";
|
|
14
|
+
this.statusCode = statusCode;
|
|
15
|
+
this.response = response;
|
|
16
|
+
this.originalError = originalError;
|
|
17
|
+
if (Error.captureStackTrace) {
|
|
18
|
+
Error.captureStackTrace(this, ApiError);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ApiError = ApiError;
|
|
23
|
+
/**
|
|
24
|
+
* Network error (connection failures, CORS, etc.)
|
|
25
|
+
*/
|
|
26
|
+
class NetworkError extends ApiError {
|
|
27
|
+
constructor(message, originalError) {
|
|
28
|
+
super(message, 0, undefined, originalError);
|
|
29
|
+
this.name = "NetworkError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.NetworkError = NetworkError;
|
|
33
|
+
/**
|
|
34
|
+
* Timeout error
|
|
35
|
+
*/
|
|
36
|
+
class TimeoutError extends ApiError {
|
|
37
|
+
constructor(message, _timeout) {
|
|
38
|
+
super(message, 408);
|
|
39
|
+
this.name = "TimeoutError";
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.TimeoutError = TimeoutError;
|
|
43
|
+
/**
|
|
44
|
+
* Authentication error (401 Unauthorized)
|
|
45
|
+
*/
|
|
46
|
+
class AuthenticationError extends ApiError {
|
|
47
|
+
constructor(message, response) {
|
|
48
|
+
super(message, 401, response);
|
|
49
|
+
this.name = "AuthenticationError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.AuthenticationError = AuthenticationError;
|
|
53
|
+
//# sourceMappingURL=data-client.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-client.types.js","sourceRoot":"","sources":["../../src/types/data-client.types.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAqSH;;GAEG;AACH,MAAa,QAAS,SAAQ,KAAK;IAKjC,YACE,OAAe,EACf,UAAmB,EACnB,QAAmB,EACnB,aAAqB;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF;AArBD,4BAqBC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,QAAQ;IACxC,YAAY,OAAe,EAAE,aAAqB;QAChD,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;GAEG;AACH,MAAa,YAAa,SAAQ,QAAQ;IACxC,YAAY,OAAe,EAAE,QAAgB;QAC3C,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AALD,oCAKC;AAED;;GAEG;AACH,MAAa,mBAAoB,SAAQ,QAAQ;IAC/C,YAAY,OAAe,EAAE,QAAmB;QAC9C,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataClient - Browser-compatible HTTP client wrapper around MisoClient
|
|
3
|
+
* Provides enhanced HTTP capabilities with ISO 27001 compliance, caching, retry, and more
|
|
4
|
+
*/
|
|
5
|
+
import { DataClientConfig, ApiRequestOptions, InterceptorConfig, RequestMetrics, AuditConfig } from "../types/data-client.types";
|
|
6
|
+
export declare class DataClient {
|
|
7
|
+
private config;
|
|
8
|
+
private misoClient;
|
|
9
|
+
private cache;
|
|
10
|
+
private pendingRequests;
|
|
11
|
+
private interceptors;
|
|
12
|
+
private metrics;
|
|
13
|
+
constructor(config: DataClientConfig);
|
|
14
|
+
/**
|
|
15
|
+
* Get authentication token from localStorage
|
|
16
|
+
*/
|
|
17
|
+
private getToken;
|
|
18
|
+
/**
|
|
19
|
+
* Check if user is authenticated
|
|
20
|
+
*/
|
|
21
|
+
isAuthenticated(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Redirect to login page
|
|
24
|
+
*/
|
|
25
|
+
redirectToLogin(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Set interceptors
|
|
28
|
+
*/
|
|
29
|
+
setInterceptors(config: InterceptorConfig): void;
|
|
30
|
+
/**
|
|
31
|
+
* Set audit configuration
|
|
32
|
+
*/
|
|
33
|
+
setAuditConfig(config: Partial<AuditConfig>): void;
|
|
34
|
+
/**
|
|
35
|
+
* Set log level for MisoClient logger
|
|
36
|
+
* Note: This updates the MisoClient config logLevel if MisoClient is initialized
|
|
37
|
+
* @param level - Log level ('debug' | 'info' | 'warn' | 'error')
|
|
38
|
+
*/
|
|
39
|
+
setLogLevel(level: "debug" | "info" | "warn" | "error"): void;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all cached responses
|
|
42
|
+
*/
|
|
43
|
+
clearCache(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get request metrics
|
|
46
|
+
*/
|
|
47
|
+
getMetrics(): RequestMetrics;
|
|
48
|
+
/**
|
|
49
|
+
* Check if endpoint should skip audit logging
|
|
50
|
+
*/
|
|
51
|
+
private shouldSkipAudit;
|
|
52
|
+
/**
|
|
53
|
+
* Log audit event (ISO 27001 compliance)
|
|
54
|
+
*/
|
|
55
|
+
private logAuditEvent;
|
|
56
|
+
/**
|
|
57
|
+
* Make HTTP request with all features (caching, retry, deduplication, audit)
|
|
58
|
+
*/
|
|
59
|
+
private request;
|
|
60
|
+
/**
|
|
61
|
+
* Execute HTTP request with retry logic
|
|
62
|
+
*/
|
|
63
|
+
private executeRequest;
|
|
64
|
+
/**
|
|
65
|
+
* Make fetch request with timeout and authentication
|
|
66
|
+
*/
|
|
67
|
+
private makeFetchRequest;
|
|
68
|
+
/**
|
|
69
|
+
* Merge AbortSignals
|
|
70
|
+
*/
|
|
71
|
+
private mergeSignals;
|
|
72
|
+
/**
|
|
73
|
+
* Parse response based on content type
|
|
74
|
+
*/
|
|
75
|
+
private parseResponse;
|
|
76
|
+
/**
|
|
77
|
+
* Extract headers from Headers object or Record
|
|
78
|
+
*/
|
|
79
|
+
private extractHeaders;
|
|
80
|
+
/**
|
|
81
|
+
* Handle authentication error
|
|
82
|
+
*/
|
|
83
|
+
private handleAuthError;
|
|
84
|
+
/**
|
|
85
|
+
* Apply request interceptor
|
|
86
|
+
*/
|
|
87
|
+
private applyRequestInterceptor;
|
|
88
|
+
/**
|
|
89
|
+
* GET request
|
|
90
|
+
*/
|
|
91
|
+
get<T>(endpoint: string, options?: ApiRequestOptions): Promise<T>;
|
|
92
|
+
/**
|
|
93
|
+
* POST request
|
|
94
|
+
*/
|
|
95
|
+
post<T>(endpoint: string, data?: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* PUT request
|
|
98
|
+
*/
|
|
99
|
+
put<T>(endpoint: string, data?: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
100
|
+
/**
|
|
101
|
+
* PATCH request (uses fetch fallback since MisoClient doesn't support PATCH)
|
|
102
|
+
*/
|
|
103
|
+
patch<T>(endpoint: string, data?: unknown, options?: ApiRequestOptions): Promise<T>;
|
|
104
|
+
/**
|
|
105
|
+
* DELETE request
|
|
106
|
+
*/
|
|
107
|
+
delete<T>(endpoint: string, options?: ApiRequestOptions): Promise<T>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get or create default DataClient instance
|
|
111
|
+
*/
|
|
112
|
+
export declare function dataClient(config?: DataClientConfig): DataClient;
|
|
113
|
+
//# sourceMappingURL=data-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data-client.d.ts","sourceRoot":"","sources":["../../src/utils/data-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,gBAAgB,EAChB,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