@inverted-tech/fragments 0.10.9 → 0.11.1
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/esm/client.js
DELETED
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import { create, toJsonString } from '@bufbuild/protobuf';
|
|
2
|
-
import { getValidator } from './validation.js';
|
|
3
|
-
// Safe logging function that works in all environments
|
|
4
|
-
const safeLog = {
|
|
5
|
-
error: (...args) => {
|
|
6
|
-
// Use globalThis to safely access console in all environments
|
|
7
|
-
const globalConsole = globalThis?.console;
|
|
8
|
-
if (globalConsole && globalConsole.error) {
|
|
9
|
-
globalConsole.error(...args);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Shared client class for standardized API communication with protobuf serialization
|
|
15
|
-
*
|
|
16
|
-
* This client encapsulates common patterns found in action functions like:
|
|
17
|
-
* - Token retrieval and authentication headers
|
|
18
|
-
* - Protobuf serialization using create() and toJsonString()
|
|
19
|
-
* - Consistent error handling with protobuf error responses
|
|
20
|
-
* - Next.js cache invalidation support (framework-agnostic)
|
|
21
|
-
* - Pre-request validation using protovalidate
|
|
22
|
-
*/
|
|
23
|
-
export class FragmentsClient {
|
|
24
|
-
config;
|
|
25
|
-
validator;
|
|
26
|
-
// Expose config for testing purposes
|
|
27
|
-
get _config() {
|
|
28
|
-
return this.config;
|
|
29
|
-
}
|
|
30
|
-
constructor(config = {}) {
|
|
31
|
-
this.config = {
|
|
32
|
-
baseUrl: config.baseUrl ?? 'http://localhost:8001',
|
|
33
|
-
getToken: config.getToken ?? (() => undefined),
|
|
34
|
-
onCacheInvalidate: config.onCacheInvalidate ?? (() => { }),
|
|
35
|
-
validateRequests: config.validateRequests ?? false,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Create a new client instance with modified configuration
|
|
40
|
-
* @param config Partial configuration to override
|
|
41
|
-
* @returns New FragmentsClient instance
|
|
42
|
-
*/
|
|
43
|
-
withConfig(config) {
|
|
44
|
-
return new FragmentsClient({
|
|
45
|
-
...this.config,
|
|
46
|
-
...config,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Generic request method that handles all HTTP operations
|
|
51
|
-
* @param endpoint API endpoint (relative to baseUrl)
|
|
52
|
-
* @param reqSchema Request protobuf schema
|
|
53
|
-
* @param resSchema Response protobuf schema
|
|
54
|
-
* @param data Request data (optional for GET requests)
|
|
55
|
-
* @param options Request options
|
|
56
|
-
* @returns Promise resolving to typed response
|
|
57
|
-
*/
|
|
58
|
-
async request(endpoint, reqSchema, resSchema, data, options = {}) {
|
|
59
|
-
const method = options.method ?? 'POST';
|
|
60
|
-
const shouldValidate = options.validate ?? this.config.validateRequests;
|
|
61
|
-
// Get authentication token
|
|
62
|
-
const token = await this.config.getToken();
|
|
63
|
-
// Create request message if data is provided
|
|
64
|
-
let requestMessage;
|
|
65
|
-
let requestBody;
|
|
66
|
-
if (data && method !== 'GET') {
|
|
67
|
-
requestMessage = create(reqSchema, data);
|
|
68
|
-
// Validate request if enabled
|
|
69
|
-
if (shouldValidate) {
|
|
70
|
-
const validationResult = await this.validateMessage(reqSchema, requestMessage);
|
|
71
|
-
if (!validationResult.success) {
|
|
72
|
-
// Return error response instead of making HTTP request
|
|
73
|
-
return this.createValidationErrorResponse(resSchema, validationResult.violations);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
requestBody = toJsonString(reqSchema, requestMessage);
|
|
77
|
-
}
|
|
78
|
-
// Prepare fetch options
|
|
79
|
-
const fetchOptions = {
|
|
80
|
-
method,
|
|
81
|
-
headers: {
|
|
82
|
-
'Content-Type': 'application/json',
|
|
83
|
-
...(token && { Authorization: `Bearer ${token}` }),
|
|
84
|
-
},
|
|
85
|
-
...(requestBody && { body: requestBody }),
|
|
86
|
-
};
|
|
87
|
-
// Add Next.js cache options if provided
|
|
88
|
-
if (options.cacheTags || options.revalidate !== undefined) {
|
|
89
|
-
fetchOptions.next = {
|
|
90
|
-
...(options.cacheTags && { tags: options.cacheTags }),
|
|
91
|
-
...(options.revalidate !== undefined && { revalidate: options.revalidate }),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
const url = `${this.config.baseUrl}${endpoint}`;
|
|
96
|
-
const response = await fetch(url, fetchOptions);
|
|
97
|
-
// Handle null response like existing action functions
|
|
98
|
-
if (!response) {
|
|
99
|
-
safeLog.error('FragmentsClient: Network request failed - no response received');
|
|
100
|
-
return this.createNetworkErrorResponse(resSchema);
|
|
101
|
-
}
|
|
102
|
-
// Handle HTTP errors like existing action functions
|
|
103
|
-
if (!response.ok) {
|
|
104
|
-
safeLog.error(`FragmentsClient: HTTP error ${response.status}: ${response.statusText}`);
|
|
105
|
-
return this.createHttpErrorResponse(resSchema, response.status, response.statusText);
|
|
106
|
-
}
|
|
107
|
-
const responseData = await response.json();
|
|
108
|
-
// Handle cache invalidation for successful mutations
|
|
109
|
-
if (method !== 'GET' && (options.cacheTags || options.revalidatePaths)) {
|
|
110
|
-
this.config.onCacheInvalidate(options.cacheTags ?? [], options.revalidatePaths ?? []);
|
|
111
|
-
}
|
|
112
|
-
return responseData;
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
// Log errors like existing action functions using console.error
|
|
116
|
-
safeLog.error('FragmentsClient request failed:', error);
|
|
117
|
-
// Return error response instead of throwing, matching existing patterns
|
|
118
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
119
|
-
return this.createErrorResponse(resSchema, errorMessage);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Convenience method for GET requests
|
|
124
|
-
* @param endpoint API endpoint
|
|
125
|
-
* @param resSchema Response protobuf schema
|
|
126
|
-
* @param options Request options
|
|
127
|
-
* @returns Promise resolving to typed response
|
|
128
|
-
*/
|
|
129
|
-
async get(endpoint, resSchema, options = {}) {
|
|
130
|
-
return this.request(endpoint, {}, resSchema, undefined, {
|
|
131
|
-
...options,
|
|
132
|
-
method: 'GET',
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Convenience method for POST requests
|
|
137
|
-
* @param endpoint API endpoint
|
|
138
|
-
* @param reqSchema Request protobuf schema
|
|
139
|
-
* @param resSchema Response protobuf schema
|
|
140
|
-
* @param data Request data
|
|
141
|
-
* @param options Request options
|
|
142
|
-
* @returns Promise resolving to typed response
|
|
143
|
-
*/
|
|
144
|
-
async post(endpoint, reqSchema, resSchema, data, options = {}) {
|
|
145
|
-
return this.request(endpoint, reqSchema, resSchema, data, {
|
|
146
|
-
...options,
|
|
147
|
-
method: 'POST',
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Static utility method to create protobuf request messages
|
|
152
|
-
* @param schema Protobuf message schema
|
|
153
|
-
* @param data Optional partial data to initialize the message
|
|
154
|
-
* @returns Created message instance
|
|
155
|
-
*/
|
|
156
|
-
static createRequest(schema, data) {
|
|
157
|
-
return create(schema, data);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Static utility method to create protobuf response messages
|
|
161
|
-
* @param schema Protobuf message schema
|
|
162
|
-
* @param data Optional partial data to initialize the message
|
|
163
|
-
* @returns Created message instance
|
|
164
|
-
*/
|
|
165
|
-
static createResponse(schema, data) {
|
|
166
|
-
return create(schema, data);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Static utility method to serialize protobuf messages to JSON strings
|
|
170
|
-
* @param schema Protobuf message schema
|
|
171
|
-
* @param data Message data to serialize
|
|
172
|
-
* @returns JSON string representation
|
|
173
|
-
*/
|
|
174
|
-
static serialize(schema, data) {
|
|
175
|
-
return toJsonString(schema, data);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Static utility method to validate protobuf messages using protovalidate
|
|
179
|
-
* @param schema Protobuf message schema
|
|
180
|
-
* @param data Message data to validate
|
|
181
|
-
* @returns Promise resolving to validation result
|
|
182
|
-
*/
|
|
183
|
-
static async validate(schema, data) {
|
|
184
|
-
try {
|
|
185
|
-
const validator = await getValidator();
|
|
186
|
-
const result = validator.validate(schema, data);
|
|
187
|
-
return {
|
|
188
|
-
success: result.kind === 'valid',
|
|
189
|
-
violations: result.kind === 'invalid' ? result.violations : undefined,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
safeLog.error('Validation error:', error);
|
|
194
|
-
return {
|
|
195
|
-
success: false,
|
|
196
|
-
violations: [{ message: 'Validation system error' }],
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Private method to validate messages using the instance validator
|
|
202
|
-
*/
|
|
203
|
-
async validateMessage(schema, data) {
|
|
204
|
-
if (!this.validator) {
|
|
205
|
-
this.validator = await getValidator();
|
|
206
|
-
}
|
|
207
|
-
try {
|
|
208
|
-
const result = this.validator.validate(schema, data);
|
|
209
|
-
return {
|
|
210
|
-
success: result.kind === 'valid',
|
|
211
|
-
violations: result.kind === 'invalid' ? result.violations : undefined,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
catch (error) {
|
|
215
|
-
safeLog.error('Validation error:', error);
|
|
216
|
-
return {
|
|
217
|
-
success: false,
|
|
218
|
-
violations: [{ message: 'Validation system error' }],
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Private method to create error responses matching existing action function patterns
|
|
224
|
-
* This creates a generic error response structure that matches the patterns used in
|
|
225
|
-
* existing action functions like modifyPublicSubscriptionSettings
|
|
226
|
-
*/
|
|
227
|
-
createErrorResponse(schema, message) {
|
|
228
|
-
// Create error response matching existing action function patterns
|
|
229
|
-
// The structure matches what's used in functions like modifyPublicSubscriptionSettings
|
|
230
|
-
return create(schema, {
|
|
231
|
-
Error: {
|
|
232
|
-
Message: message,
|
|
233
|
-
Type: 'SETTINGS_ERROR_UNKNOWN', // Matches SettingsErrorReason.SETTINGS_ERROR_UNKNOWN
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Private method to create validation error responses
|
|
239
|
-
* This preserves ValidationIssue[] arrays in error responses as required
|
|
240
|
-
*/
|
|
241
|
-
createValidationErrorResponse(schema, violations) {
|
|
242
|
-
return create(schema, {
|
|
243
|
-
Error: {
|
|
244
|
-
Message: 'Request validation failed',
|
|
245
|
-
Type: 'SETTINGS_ERROR_VALIDATION_FAILED', // Matches validation error type
|
|
246
|
-
Validation: violations ?? [], // Preserve ValidationIssue[] arrays
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Private method to create HTTP error responses
|
|
252
|
-
* Handles HTTP errors uniformly like existing action functions
|
|
253
|
-
*/
|
|
254
|
-
createHttpErrorResponse(schema, status, statusText) {
|
|
255
|
-
const message = `HTTP ${status}: ${statusText}`;
|
|
256
|
-
return create(schema, {
|
|
257
|
-
Error: {
|
|
258
|
-
Message: message,
|
|
259
|
-
Type: 'SETTINGS_ERROR_UNKNOWN',
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Private method to create network error responses
|
|
265
|
-
* Handles network failures like existing action functions
|
|
266
|
-
*/
|
|
267
|
-
createNetworkErrorResponse(schema) {
|
|
268
|
-
return create(schema, {
|
|
269
|
-
Error: {
|
|
270
|
-
Message: 'Network request failed',
|
|
271
|
-
Type: 'SETTINGS_ERROR_UNKNOWN',
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Static method to create error responses for use in action functions
|
|
277
|
-
* This allows consumers to create consistent error responses outside of the client
|
|
278
|
-
* @param schema Response schema to create error for
|
|
279
|
-
* @param message Error message
|
|
280
|
-
* @param errorType Error type (defaults to SETTINGS_ERROR_UNKNOWN)
|
|
281
|
-
* @param validationIssues Optional validation issues array
|
|
282
|
-
* @returns Error response matching existing action function patterns
|
|
283
|
-
*/
|
|
284
|
-
static createErrorResponse(schema, message, errorType = 'SETTINGS_ERROR_UNKNOWN', validationIssues) {
|
|
285
|
-
const errorData = {
|
|
286
|
-
Message: message,
|
|
287
|
-
Type: errorType,
|
|
288
|
-
};
|
|
289
|
-
// Include validation issues if provided (preserves ValidationIssue[] arrays)
|
|
290
|
-
if (validationIssues && validationIssues.length > 0) {
|
|
291
|
-
errorData.Validation = validationIssues;
|
|
292
|
-
}
|
|
293
|
-
return create(schema, {
|
|
294
|
-
Error: errorData,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
}
|
package/dist/protos/client.d.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { type Message } from '@bufbuild/protobuf';
|
|
2
|
-
import { type GenMessage } from '@bufbuild/protobuf/codegenv2';
|
|
3
|
-
declare global {
|
|
4
|
-
function fetch(input: string, init?: any): Promise<any>;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* HTTP methods supported by the client
|
|
8
|
-
*/
|
|
9
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
10
|
-
/**
|
|
11
|
-
* Token getter function type - can be sync or async
|
|
12
|
-
*/
|
|
13
|
-
export type TokenGetter = () => Promise<string | undefined> | string | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Cache invalidation callback function type
|
|
16
|
-
*/
|
|
17
|
-
export type CacheInvalidator = (tags: string[], paths: string[]) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Simplified validation result interface
|
|
20
|
-
*/
|
|
21
|
-
export interface SimpleValidationResult {
|
|
22
|
-
success: boolean;
|
|
23
|
-
violations?: any[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Configuration interface for the FragmentsClient
|
|
27
|
-
*/
|
|
28
|
-
export interface ClientConfig {
|
|
29
|
-
/**
|
|
30
|
-
* Base URL for API requests
|
|
31
|
-
* @default 'http://localhost:8001'
|
|
32
|
-
*/
|
|
33
|
-
baseUrl?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Function to retrieve authentication tokens (sync or async)
|
|
36
|
-
*/
|
|
37
|
-
getToken?: TokenGetter;
|
|
38
|
-
/**
|
|
39
|
-
* Callback for cache invalidation (Next.js can pass revalidateTag/revalidatePath)
|
|
40
|
-
*/
|
|
41
|
-
onCacheInvalidate?: CacheInvalidator;
|
|
42
|
-
/**
|
|
43
|
-
* Enable pre-request validation using protovalidate
|
|
44
|
-
* @default false
|
|
45
|
-
*/
|
|
46
|
-
validateRequests?: boolean;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Per-request options that can override client configuration
|
|
50
|
-
*/
|
|
51
|
-
export interface RequestOptions {
|
|
52
|
-
/**
|
|
53
|
-
* HTTP method for the request
|
|
54
|
-
*/
|
|
55
|
-
method?: HttpMethod;
|
|
56
|
-
/**
|
|
57
|
-
* Cache tags for Next.js caching
|
|
58
|
-
*/
|
|
59
|
-
cacheTags?: string[];
|
|
60
|
-
/**
|
|
61
|
-
* Paths to revalidate after mutations
|
|
62
|
-
*/
|
|
63
|
-
revalidatePaths?: string[];
|
|
64
|
-
/**
|
|
65
|
-
* Cache revalidation time in seconds
|
|
66
|
-
*/
|
|
67
|
-
revalidate?: number;
|
|
68
|
-
/**
|
|
69
|
-
* Override client-level validation setting for this request
|
|
70
|
-
*/
|
|
71
|
-
validate?: boolean;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Shared client class for standardized API communication with protobuf serialization
|
|
75
|
-
*
|
|
76
|
-
* This client encapsulates common patterns found in action functions like:
|
|
77
|
-
* - Token retrieval and authentication headers
|
|
78
|
-
* - Protobuf serialization using create() and toJsonString()
|
|
79
|
-
* - Consistent error handling with protobuf error responses
|
|
80
|
-
* - Next.js cache invalidation support (framework-agnostic)
|
|
81
|
-
* - Pre-request validation using protovalidate
|
|
82
|
-
*/
|
|
83
|
-
export declare class FragmentsClient {
|
|
84
|
-
private readonly config;
|
|
85
|
-
private validator?;
|
|
86
|
-
get _config(): Required<ClientConfig>;
|
|
87
|
-
constructor(config?: ClientConfig);
|
|
88
|
-
/**
|
|
89
|
-
* Create a new client instance with modified configuration
|
|
90
|
-
* @param config Partial configuration to override
|
|
91
|
-
* @returns New FragmentsClient instance
|
|
92
|
-
*/
|
|
93
|
-
withConfig(config: Partial<ClientConfig>): FragmentsClient;
|
|
94
|
-
/**
|
|
95
|
-
* Generic request method that handles all HTTP operations
|
|
96
|
-
* @param endpoint API endpoint (relative to baseUrl)
|
|
97
|
-
* @param reqSchema Request protobuf schema
|
|
98
|
-
* @param resSchema Response protobuf schema
|
|
99
|
-
* @param data Request data (optional for GET requests)
|
|
100
|
-
* @param options Request options
|
|
101
|
-
* @returns Promise resolving to typed response
|
|
102
|
-
*/
|
|
103
|
-
request<TReq extends Message, TRes extends Message>(endpoint: string, reqSchema: GenMessage<TReq>, resSchema: GenMessage<TRes>, data?: Partial<TReq>, options?: RequestOptions): Promise<TRes>;
|
|
104
|
-
/**
|
|
105
|
-
* Convenience method for GET requests
|
|
106
|
-
* @param endpoint API endpoint
|
|
107
|
-
* @param resSchema Response protobuf schema
|
|
108
|
-
* @param options Request options
|
|
109
|
-
* @returns Promise resolving to typed response
|
|
110
|
-
*/
|
|
111
|
-
get<TRes extends Message>(endpoint: string, resSchema: GenMessage<TRes>, options?: Omit<RequestOptions, 'method'>): Promise<TRes>;
|
|
112
|
-
/**
|
|
113
|
-
* Convenience method for POST requests
|
|
114
|
-
* @param endpoint API endpoint
|
|
115
|
-
* @param reqSchema Request protobuf schema
|
|
116
|
-
* @param resSchema Response protobuf schema
|
|
117
|
-
* @param data Request data
|
|
118
|
-
* @param options Request options
|
|
119
|
-
* @returns Promise resolving to typed response
|
|
120
|
-
*/
|
|
121
|
-
post<TReq extends Message, TRes extends Message>(endpoint: string, reqSchema: GenMessage<TReq>, resSchema: GenMessage<TRes>, data: Partial<TReq>, options?: Omit<RequestOptions, 'method'>): Promise<TRes>;
|
|
122
|
-
/**
|
|
123
|
-
* Static utility method to create protobuf request messages
|
|
124
|
-
* @param schema Protobuf message schema
|
|
125
|
-
* @param data Optional partial data to initialize the message
|
|
126
|
-
* @returns Created message instance
|
|
127
|
-
*/
|
|
128
|
-
static createRequest<T extends Message>(schema: GenMessage<T>, data?: Partial<T>): T;
|
|
129
|
-
/**
|
|
130
|
-
* Static utility method to create protobuf response messages
|
|
131
|
-
* @param schema Protobuf message schema
|
|
132
|
-
* @param data Optional partial data to initialize the message
|
|
133
|
-
* @returns Created message instance
|
|
134
|
-
*/
|
|
135
|
-
static createResponse<T extends Message>(schema: GenMessage<T>, data?: Partial<T>): T;
|
|
136
|
-
/**
|
|
137
|
-
* Static utility method to serialize protobuf messages to JSON strings
|
|
138
|
-
* @param schema Protobuf message schema
|
|
139
|
-
* @param data Message data to serialize
|
|
140
|
-
* @returns JSON string representation
|
|
141
|
-
*/
|
|
142
|
-
static serialize<T extends Message>(schema: GenMessage<T>, data: T): string;
|
|
143
|
-
/**
|
|
144
|
-
* Static utility method to validate protobuf messages using protovalidate
|
|
145
|
-
* @param schema Protobuf message schema
|
|
146
|
-
* @param data Message data to validate
|
|
147
|
-
* @returns Promise resolving to validation result
|
|
148
|
-
*/
|
|
149
|
-
static validate<T extends Message>(schema: GenMessage<T>, data: T): Promise<SimpleValidationResult>;
|
|
150
|
-
/**
|
|
151
|
-
* Private method to validate messages using the instance validator
|
|
152
|
-
*/
|
|
153
|
-
private validateMessage;
|
|
154
|
-
/**
|
|
155
|
-
* Private method to create error responses matching existing action function patterns
|
|
156
|
-
* This creates a generic error response structure that matches the patterns used in
|
|
157
|
-
* existing action functions like modifyPublicSubscriptionSettings
|
|
158
|
-
*/
|
|
159
|
-
private createErrorResponse;
|
|
160
|
-
/**
|
|
161
|
-
* Private method to create validation error responses
|
|
162
|
-
* This preserves ValidationIssue[] arrays in error responses as required
|
|
163
|
-
*/
|
|
164
|
-
private createValidationErrorResponse;
|
|
165
|
-
/**
|
|
166
|
-
* Private method to create HTTP error responses
|
|
167
|
-
* Handles HTTP errors uniformly like existing action functions
|
|
168
|
-
*/
|
|
169
|
-
private createHttpErrorResponse;
|
|
170
|
-
/**
|
|
171
|
-
* Private method to create network error responses
|
|
172
|
-
* Handles network failures like existing action functions
|
|
173
|
-
*/
|
|
174
|
-
private createNetworkErrorResponse;
|
|
175
|
-
/**
|
|
176
|
-
* Static method to create error responses for use in action functions
|
|
177
|
-
* This allows consumers to create consistent error responses outside of the client
|
|
178
|
-
* @param schema Response schema to create error for
|
|
179
|
-
* @param message Error message
|
|
180
|
-
* @param errorType Error type (defaults to SETTINGS_ERROR_UNKNOWN)
|
|
181
|
-
* @param validationIssues Optional validation issues array
|
|
182
|
-
* @returns Error response matching existing action function patterns
|
|
183
|
-
*/
|
|
184
|
-
static createErrorResponse<T extends Message>(schema: GenMessage<T>, message: string, errorType?: string, validationIssues?: any[]): T;
|
|
185
|
-
}
|