celitech-sdk 1.3.60 → 1.3.63
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/LICENSE +1 -1
- package/README.md +7 -7
- package/dist/index.d.ts +667 -91
- package/dist/index.js +819 -89
- package/dist/index.mjs +819 -89
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -45,8 +45,14 @@ module.exports = __toCommonJS(src_exports);
|
|
|
45
45
|
// src/http/handlers/handler-chain.ts
|
|
46
46
|
var RequestHandlerChain = class {
|
|
47
47
|
constructor() {
|
|
48
|
+
/** Array of handlers in the chain */
|
|
48
49
|
this.handlers = [];
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Adds a handler to the end of the chain.
|
|
53
|
+
* Links the new handler to the previous one in the chain.
|
|
54
|
+
* @param handler - The request handler to add
|
|
55
|
+
*/
|
|
50
56
|
addHandler(handler) {
|
|
51
57
|
if (this.handlers.length > 0) {
|
|
52
58
|
const previousHandler = this.handlers[this.handlers.length - 1];
|
|
@@ -54,12 +60,26 @@ var RequestHandlerChain = class {
|
|
|
54
60
|
}
|
|
55
61
|
this.handlers.push(handler);
|
|
56
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Executes the handler chain for a standard request.
|
|
65
|
+
* @template T - The expected response data type
|
|
66
|
+
* @param request - The HTTP request to process
|
|
67
|
+
* @returns A promise that resolves to the HTTP response
|
|
68
|
+
* @throws Error if no handlers are added to the chain
|
|
69
|
+
*/
|
|
57
70
|
async callChain(request) {
|
|
58
71
|
if (!this.handlers.length) {
|
|
59
72
|
throw new Error("No handlers added to the chain");
|
|
60
73
|
}
|
|
61
74
|
return this.handlers[0].handle(request);
|
|
62
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Executes the handler chain for a streaming request.
|
|
78
|
+
* @template T - The expected response data type for each chunk
|
|
79
|
+
* @param request - The HTTP request to process
|
|
80
|
+
* @returns An async generator that yields HTTP responses
|
|
81
|
+
* @throws Error if no handlers are added to the chain
|
|
82
|
+
*/
|
|
63
83
|
async *streamChain(request) {
|
|
64
84
|
if (!this.handlers.length) {
|
|
65
85
|
throw new Error("No handlers added to the chain");
|
|
@@ -70,6 +90,12 @@ var RequestHandlerChain = class {
|
|
|
70
90
|
|
|
71
91
|
// src/http/error.ts
|
|
72
92
|
var HttpError = class extends Error {
|
|
93
|
+
/**
|
|
94
|
+
* Creates a new HTTP error.
|
|
95
|
+
* @param metadata - HTTP response metadata
|
|
96
|
+
* @param raw - Raw response object (optional)
|
|
97
|
+
* @param error - Custom error message (optional, defaults to status text)
|
|
98
|
+
*/
|
|
73
99
|
constructor(metadata, raw, error) {
|
|
74
100
|
super(error);
|
|
75
101
|
this.error = metadata.statusText;
|
|
@@ -80,12 +106,35 @@ var HttpError = class extends Error {
|
|
|
80
106
|
|
|
81
107
|
// src/http/hooks/custom-hook.ts
|
|
82
108
|
var CustomHook = class {
|
|
109
|
+
/**
|
|
110
|
+
* Called before an HTTP request is sent.
|
|
111
|
+
* Default implementation returns the request unchanged.
|
|
112
|
+
* @param request - The HTTP request to be sent
|
|
113
|
+
* @param params - Additional custom parameters
|
|
114
|
+
* @returns A promise that resolves to the unmodified request
|
|
115
|
+
*/
|
|
83
116
|
async beforeRequest(request, params) {
|
|
84
117
|
return request;
|
|
85
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Called after a successful HTTP response is received.
|
|
121
|
+
* Default implementation returns the response unchanged.
|
|
122
|
+
* @param request - The original HTTP request
|
|
123
|
+
* @param response - The HTTP response received
|
|
124
|
+
* @param params - Additional custom parameters
|
|
125
|
+
* @returns A promise that resolves to the unmodified response
|
|
126
|
+
*/
|
|
86
127
|
async afterResponse(request, response, params) {
|
|
87
128
|
return response;
|
|
88
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Called when an HTTP request results in an error.
|
|
132
|
+
* Default implementation wraps the error response in an HttpError object.
|
|
133
|
+
* @param request - The original HTTP request
|
|
134
|
+
* @param response - The error response received
|
|
135
|
+
* @param params - Additional custom parameters
|
|
136
|
+
* @returns A promise that resolves to an HttpError object
|
|
137
|
+
*/
|
|
89
138
|
async onError(request, response, params) {
|
|
90
139
|
return new HttpError(response.metadata, response.raw);
|
|
91
140
|
}
|
|
@@ -93,6 +142,11 @@ var CustomHook = class {
|
|
|
93
142
|
|
|
94
143
|
// src/http/serialization/base-serializer.ts
|
|
95
144
|
var Serializer = class {
|
|
145
|
+
/**
|
|
146
|
+
* Serializes a parameter value based on its type and serialization style.
|
|
147
|
+
* @param param - The request parameter to serialize
|
|
148
|
+
* @returns The serialized string representation
|
|
149
|
+
*/
|
|
96
150
|
serializeValue(param) {
|
|
97
151
|
if (Array.isArray(param.value)) {
|
|
98
152
|
return this.serializeArray(param.value, param);
|
|
@@ -102,6 +156,11 @@ var Serializer = class {
|
|
|
102
156
|
}
|
|
103
157
|
return this.serializePrimitive(param);
|
|
104
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Serializes a primitive value (string, number, boolean).
|
|
161
|
+
* @param param - The request parameter containing the primitive value
|
|
162
|
+
* @returns The serialized primitive string
|
|
163
|
+
*/
|
|
105
164
|
serializePrimitive(param) {
|
|
106
165
|
if (param.style === "label" /* LABEL */) {
|
|
107
166
|
return `.${param.value}`;
|
|
@@ -112,6 +171,12 @@ var Serializer = class {
|
|
|
112
171
|
}
|
|
113
172
|
return `${param.value}`;
|
|
114
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Serializes an array value according to the specified style.
|
|
176
|
+
* @param value - The array to serialize
|
|
177
|
+
* @param param - The request parameter configuration
|
|
178
|
+
* @returns The serialized array string
|
|
179
|
+
*/
|
|
115
180
|
serializeArray(value, param) {
|
|
116
181
|
if (param.explode) {
|
|
117
182
|
this.serializeArrayExploded(value, param);
|
|
@@ -132,6 +197,12 @@ var Serializer = class {
|
|
|
132
197
|
}
|
|
133
198
|
return `${value.join(",")}`;
|
|
134
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Serializes an array in exploded format where each value is a separate parameter.
|
|
202
|
+
* @param value - The array to serialize
|
|
203
|
+
* @param param - The request parameter configuration
|
|
204
|
+
* @returns The serialized exploded array string
|
|
205
|
+
*/
|
|
135
206
|
serializeArrayExploded(value, param) {
|
|
136
207
|
if (param.style === "simple" /* SIMPLE */) {
|
|
137
208
|
return value.map((val) => `${val}`).join(",");
|
|
@@ -144,6 +215,12 @@ var Serializer = class {
|
|
|
144
215
|
}
|
|
145
216
|
return `${value.join(",")}`;
|
|
146
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* Serializes an object value according to the specified style.
|
|
220
|
+
* @param obj - The object to serialize
|
|
221
|
+
* @param param - The request parameter configuration
|
|
222
|
+
* @returns The serialized object string
|
|
223
|
+
*/
|
|
147
224
|
serializeObject(obj, param) {
|
|
148
225
|
if (param.explode) {
|
|
149
226
|
if (param.style === "simple" /* SIMPLE */) {
|
|
@@ -171,6 +248,11 @@ var Serializer = class {
|
|
|
171
248
|
}
|
|
172
249
|
return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join("&");
|
|
173
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Type guard to check if a value is a non-null object.
|
|
253
|
+
* @param value - The value to check
|
|
254
|
+
* @returns True if the value is an object and not null
|
|
255
|
+
*/
|
|
174
256
|
isNonNullObject(value) {
|
|
175
257
|
return typeof value === "object" && value !== null;
|
|
176
258
|
}
|
|
@@ -181,6 +263,14 @@ var TransportHookAdapter = class {
|
|
|
181
263
|
constructor() {
|
|
182
264
|
this.hook = new CustomHook();
|
|
183
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* Invokes the custom hook before sending the request.
|
|
268
|
+
* Converts the Request to HttpRequest format, calls the hook, then converts back.
|
|
269
|
+
*
|
|
270
|
+
* @param request - The internal Request object
|
|
271
|
+
* @param params - Additional parameters to pass to the hook
|
|
272
|
+
* @returns The modified Request after hook processing
|
|
273
|
+
*/
|
|
184
274
|
async beforeRequest(request, params) {
|
|
185
275
|
const hookRequest = this.requestToHookRequest(request);
|
|
186
276
|
const newRequest = await this.hook.beforeRequest(hookRequest, params);
|
|
@@ -195,14 +285,39 @@ var TransportHookAdapter = class {
|
|
|
195
285
|
});
|
|
196
286
|
return newTransportRequest;
|
|
197
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Invokes the custom hook after receiving a response.
|
|
290
|
+
* Converts the Request to HttpRequest format and calls the hook with the response.
|
|
291
|
+
*
|
|
292
|
+
* @param request - The internal Request object
|
|
293
|
+
* @param response - The HTTP response received
|
|
294
|
+
* @param params - Additional parameters to pass to the hook
|
|
295
|
+
* @returns The potentially modified response after hook processing
|
|
296
|
+
*/
|
|
198
297
|
async afterResponse(request, response, params) {
|
|
199
298
|
const hookRequest = this.requestToHookRequest(request);
|
|
200
299
|
return this.hook.afterResponse(hookRequest, response, params);
|
|
201
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Invokes the custom hook when an error occurs.
|
|
303
|
+
* Converts the Request to HttpRequest format and calls the error hook.
|
|
304
|
+
*
|
|
305
|
+
* @param request - The internal Request object
|
|
306
|
+
* @param response - The HTTP response that triggered the error
|
|
307
|
+
* @param params - Additional parameters to pass to the hook
|
|
308
|
+
* @returns The HttpError from the hook
|
|
309
|
+
*/
|
|
202
310
|
async onError(request, response, params) {
|
|
203
311
|
const hookRequest = this.requestToHookRequest(request);
|
|
204
312
|
return this.hook.onError(hookRequest, response, params);
|
|
205
313
|
}
|
|
314
|
+
/**
|
|
315
|
+
* Converts the internal Request representation to the hook's HttpRequest format.
|
|
316
|
+
* Extracts parameter values from RequestParameter wrappers.
|
|
317
|
+
*
|
|
318
|
+
* @param request - The internal Request object
|
|
319
|
+
* @returns An HttpRequest object for hook processing
|
|
320
|
+
*/
|
|
206
321
|
requestToHookRequest(request) {
|
|
207
322
|
const hookHeaders = /* @__PURE__ */ new Map();
|
|
208
323
|
request.headers.forEach((header, key) => {
|
|
@@ -227,10 +342,20 @@ var TransportHookAdapter = class {
|
|
|
227
342
|
};
|
|
228
343
|
return hookRequest;
|
|
229
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Converts hook parameter maps back to RequestParameter format.
|
|
347
|
+
* Preserves serialization metadata from the original parameters.
|
|
348
|
+
*
|
|
349
|
+
* @template T - The parameter value type
|
|
350
|
+
* @param hookParams - The parameter map from hook processing
|
|
351
|
+
* @param originalTransportParams - The original RequestParameter map for metadata
|
|
352
|
+
* @param encode - Whether to encode the parameters
|
|
353
|
+
* @returns A map of RequestParameter objects for transport
|
|
354
|
+
*/
|
|
230
355
|
hookParamsToTransportParams(hookParams, originalTransportParams, encode) {
|
|
231
356
|
const transportParams = /* @__PURE__ */ new Map();
|
|
232
357
|
hookParams.forEach((hookParamValue, hookParamKey) => {
|
|
233
|
-
var _a, _b, _c, _d;
|
|
358
|
+
var _a, _b, _c, _d, _e;
|
|
234
359
|
const requestParam = originalTransportParams.get(hookParamKey);
|
|
235
360
|
transportParams.set(hookParamKey, {
|
|
236
361
|
key: hookParamKey,
|
|
@@ -239,7 +364,8 @@ var TransportHookAdapter = class {
|
|
|
239
364
|
style: (requestParam == null ? void 0 : requestParam.style) || "none" /* NONE */,
|
|
240
365
|
explode: (_b = requestParam == null ? void 0 : requestParam.explode) != null ? _b : false,
|
|
241
366
|
isLimit: (_c = requestParam == null ? void 0 : requestParam.isLimit) != null ? _c : false,
|
|
242
|
-
isOffset: (_d = requestParam == null ? void 0 : requestParam.isOffset) != null ? _d : false
|
|
367
|
+
isOffset: (_d = requestParam == null ? void 0 : requestParam.isOffset) != null ? _d : false,
|
|
368
|
+
isCursor: (_e = requestParam == null ? void 0 : requestParam.isCursor) != null ? _e : false
|
|
243
369
|
});
|
|
244
370
|
});
|
|
245
371
|
return transportParams;
|
|
@@ -258,19 +384,28 @@ function getContentTypeDefinition(contentType) {
|
|
|
258
384
|
if (ct === "text/event-stream") {
|
|
259
385
|
return "eventStream" /* EventStream */;
|
|
260
386
|
}
|
|
387
|
+
if (ct === "application/json" || ct === "text/json" || ct.includes("+json")) {
|
|
388
|
+
return "json" /* Json */;
|
|
389
|
+
}
|
|
390
|
+
if (ct === "application/javascript") {
|
|
391
|
+
return "text" /* Text */;
|
|
392
|
+
}
|
|
261
393
|
if (ct.startsWith("text/")) {
|
|
262
394
|
return "text" /* Text */;
|
|
263
395
|
}
|
|
396
|
+
if (ct === "image/svg+xml") {
|
|
397
|
+
return "text" /* Text */;
|
|
398
|
+
}
|
|
264
399
|
if (ct.startsWith("image/")) {
|
|
265
400
|
return "image" /* Image */;
|
|
266
401
|
}
|
|
267
402
|
if (ct === "application/octet-stream" || ct === "application/pdf") {
|
|
268
403
|
return "binary" /* Binary */;
|
|
269
404
|
}
|
|
270
|
-
if (ct === "
|
|
271
|
-
return "
|
|
405
|
+
if (ct === "*/*") {
|
|
406
|
+
return "binary" /* Binary */;
|
|
272
407
|
}
|
|
273
|
-
return "
|
|
408
|
+
return "binary" /* Binary */;
|
|
274
409
|
}
|
|
275
410
|
|
|
276
411
|
// src/http/handlers/hook-handler.ts
|
|
@@ -278,6 +413,14 @@ var HookHandler = class {
|
|
|
278
413
|
constructor(hook) {
|
|
279
414
|
this.hook = hook;
|
|
280
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* Handles a standard HTTP request with hook invocation.
|
|
418
|
+
* Calls beforeRequest hook, processes the request, and calls afterResponse or onError hooks.
|
|
419
|
+
* @template T - The expected response data type
|
|
420
|
+
* @param request - The HTTP request to process
|
|
421
|
+
* @returns A promise that resolves to the HTTP response
|
|
422
|
+
* @throws Error if no next handler is set, or if error handling fails
|
|
423
|
+
*/
|
|
281
424
|
async handle(request) {
|
|
282
425
|
var _a;
|
|
283
426
|
if (!this.next) {
|
|
@@ -290,6 +433,7 @@ var HookHandler = class {
|
|
|
290
433
|
if (response.metadata.status < 400) {
|
|
291
434
|
return await hook.afterResponse(nextRequest, response, hookParams);
|
|
292
435
|
}
|
|
436
|
+
const arrayBuffer = response.raw;
|
|
293
437
|
const rawContentType = ((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.toLocaleLowerCase()) || "";
|
|
294
438
|
const contentType = getContentTypeDefinition(rawContentType);
|
|
295
439
|
const statusCode = response.metadata.status;
|
|
@@ -297,19 +441,27 @@ var HookHandler = class {
|
|
|
297
441
|
return error2.contentType === contentType && error2.status === statusCode;
|
|
298
442
|
});
|
|
299
443
|
if (error) {
|
|
300
|
-
const decodedBody2 = new TextDecoder().decode(
|
|
444
|
+
const decodedBody2 = new TextDecoder().decode(arrayBuffer);
|
|
301
445
|
const json = JSON.parse(decodedBody2);
|
|
302
446
|
new error.error((json == null ? void 0 : json.message) || "", json).throw();
|
|
303
447
|
}
|
|
304
|
-
const decodedBody = new TextDecoder().decode(
|
|
448
|
+
const decodedBody = new TextDecoder().decode(arrayBuffer);
|
|
305
449
|
throw new HttpError(
|
|
306
450
|
response.metadata,
|
|
307
|
-
|
|
451
|
+
arrayBuffer,
|
|
308
452
|
`Unexpected response body for error status.
|
|
309
453
|
StatusCode: ${response.metadata.status}
|
|
310
454
|
Body: ${decodedBody}`
|
|
311
455
|
);
|
|
312
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Handles a streaming HTTP request with hook invocation.
|
|
459
|
+
* Calls beforeRequest hook and afterResponse/onError hooks for each chunk.
|
|
460
|
+
* @template T - The expected response data type for each chunk
|
|
461
|
+
* @param request - The HTTP request to process
|
|
462
|
+
* @returns An async generator that yields HTTP responses
|
|
463
|
+
* @throws Error if no next handler is set, or if error handling fails
|
|
464
|
+
*/
|
|
313
465
|
async *stream(request) {
|
|
314
466
|
if (!this.next) {
|
|
315
467
|
throw new Error("No next handler set in hook handler.");
|
|
@@ -326,6 +478,12 @@ Body: ${decodedBody}`
|
|
|
326
478
|
}
|
|
327
479
|
}
|
|
328
480
|
}
|
|
481
|
+
/**
|
|
482
|
+
* Extracts hook parameters from the request configuration.
|
|
483
|
+
* @template T - The response data type
|
|
484
|
+
* @param request - The HTTP request
|
|
485
|
+
* @returns A map of hook parameter names to values
|
|
486
|
+
*/
|
|
329
487
|
getHookParams(_request) {
|
|
330
488
|
const hookParams = /* @__PURE__ */ new Map();
|
|
331
489
|
return hookParams;
|
|
@@ -337,9 +495,19 @@ var import_zod = require("zod");
|
|
|
337
495
|
|
|
338
496
|
// src/http/utils/response-matcher.ts
|
|
339
497
|
var ResponseMatcher = class {
|
|
498
|
+
/**
|
|
499
|
+
* Creates a new response matcher.
|
|
500
|
+
* @param responses - Array of possible response definitions for an endpoint
|
|
501
|
+
*/
|
|
340
502
|
constructor(responses) {
|
|
341
503
|
this.responses = responses;
|
|
342
504
|
}
|
|
505
|
+
/**
|
|
506
|
+
* Finds the matching response definition for an HTTP response.
|
|
507
|
+
* Matches based on status code and content type from the response headers.
|
|
508
|
+
* @param response - The HTTP response to match
|
|
509
|
+
* @returns The matching response definition, or undefined if no match found
|
|
510
|
+
*/
|
|
343
511
|
getResponseDefinition(response) {
|
|
344
512
|
var _a;
|
|
345
513
|
const rawContentType = ((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.toLocaleLowerCase()) || "";
|
|
@@ -359,10 +527,23 @@ var ResponseMatcher = class {
|
|
|
359
527
|
|
|
360
528
|
// src/http/handlers/response-validation-handler.ts
|
|
361
529
|
var ResponseValidationHandler = class {
|
|
530
|
+
/**
|
|
531
|
+
* Handles a standard HTTP request and validates its response.
|
|
532
|
+
* @template T - The expected response data type
|
|
533
|
+
* @param request - The HTTP request to process
|
|
534
|
+
* @returns A promise that resolves to the validated HTTP response
|
|
535
|
+
*/
|
|
362
536
|
async handle(request) {
|
|
363
537
|
const response = await this.next.handle(request);
|
|
364
538
|
return this.decodeBody(request, response);
|
|
365
539
|
}
|
|
540
|
+
/**
|
|
541
|
+
* Handles a streaming HTTP request and validates response chunks.
|
|
542
|
+
* @template T - The expected response data type for each chunk
|
|
543
|
+
* @param request - The HTTP request to process
|
|
544
|
+
* @returns An async generator that yields validated HTTP responses
|
|
545
|
+
* @throws Error if response headers are enabled (streaming not supported with headers)
|
|
546
|
+
*/
|
|
366
547
|
async *stream(request) {
|
|
367
548
|
const stream = this.next.stream(request);
|
|
368
549
|
for await (const response of stream) {
|
|
@@ -373,7 +554,8 @@ var ResponseValidationHandler = class {
|
|
|
373
554
|
}
|
|
374
555
|
}
|
|
375
556
|
splitByDataChunks(response) {
|
|
376
|
-
|
|
557
|
+
var _a;
|
|
558
|
+
if (!((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.includes("text/event-stream"))) {
|
|
377
559
|
return [response];
|
|
378
560
|
}
|
|
379
561
|
const text = new TextDecoder().decode(response.raw);
|
|
@@ -455,6 +637,14 @@ var ResponseValidationHandler = class {
|
|
|
455
637
|
data: this.validate(request, responseDefinition, json)
|
|
456
638
|
};
|
|
457
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Validates response data against the expected schema if validation is enabled.
|
|
642
|
+
* @template T - The expected data type
|
|
643
|
+
* @param request - The HTTP request containing validation settings
|
|
644
|
+
* @param response - The response definition with schema
|
|
645
|
+
* @param data - The data to validate
|
|
646
|
+
* @returns The validated data (parsed if validation enabled, raw otherwise)
|
|
647
|
+
*/
|
|
458
648
|
validate(request, response, data) {
|
|
459
649
|
var _a;
|
|
460
650
|
if ((_a = request.validation) == null ? void 0 : _a.responseValidation) {
|
|
@@ -462,9 +652,21 @@ var ResponseValidationHandler = class {
|
|
|
462
652
|
}
|
|
463
653
|
return data;
|
|
464
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* Checks if a response should contain data based on its schema and status.
|
|
657
|
+
* @template T - The response data type
|
|
658
|
+
* @param responseDefinition - The response definition
|
|
659
|
+
* @param response - The HTTP response
|
|
660
|
+
* @returns True if the response should have content, false otherwise
|
|
661
|
+
*/
|
|
465
662
|
hasContent(responseDefinition, response) {
|
|
466
663
|
return !!responseDefinition.schema && !(responseDefinition.schema instanceof import_zod.ZodUndefined) && response.metadata.status !== 204;
|
|
467
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* Parses URL-encoded data into an object.
|
|
667
|
+
* @param urlEncodedData - The URL-encoded string
|
|
668
|
+
* @returns An object with decoded key-value pairs
|
|
669
|
+
*/
|
|
468
670
|
fromUrlEncoded(urlEncodedData) {
|
|
469
671
|
const pairs = urlEncodedData.split("&");
|
|
470
672
|
const result = {};
|
|
@@ -476,6 +678,11 @@ var ResponseValidationHandler = class {
|
|
|
476
678
|
});
|
|
477
679
|
return result;
|
|
478
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* Parses multipart form data into an object.
|
|
683
|
+
* @param arrayBuffer - The raw form data as ArrayBuffer
|
|
684
|
+
* @returns An object with form field names and values
|
|
685
|
+
*/
|
|
479
686
|
fromFormData(arrayBuffer) {
|
|
480
687
|
const decoder = new TextDecoder();
|
|
481
688
|
const text = decoder.decode(arrayBuffer);
|
|
@@ -499,6 +706,11 @@ var import_zod2 = require("zod");
|
|
|
499
706
|
|
|
500
707
|
// src/http/errors/validation-error.ts
|
|
501
708
|
var ValidationError = class extends Error {
|
|
709
|
+
/**
|
|
710
|
+
* Creates a new validation error from a Zod error.
|
|
711
|
+
* @param zodError - The Zod validation error containing issue details
|
|
712
|
+
* @param object - The object that failed validation
|
|
713
|
+
*/
|
|
502
714
|
constructor(zodError, object) {
|
|
503
715
|
let actual;
|
|
504
716
|
try {
|
|
@@ -519,6 +731,13 @@ var ValidationError = class extends Error {
|
|
|
519
731
|
|
|
520
732
|
// src/http/handlers/request-validation-handler.ts
|
|
521
733
|
var RequestValidationHandler = class {
|
|
734
|
+
/**
|
|
735
|
+
* Handles a standard HTTP request with validation.
|
|
736
|
+
* @template T - The expected response data type
|
|
737
|
+
* @param request - The HTTP request to validate
|
|
738
|
+
* @returns A promise that resolves to the HTTP response
|
|
739
|
+
* @throws Error if no next handler is set
|
|
740
|
+
*/
|
|
522
741
|
async handle(request) {
|
|
523
742
|
if (!this.next) {
|
|
524
743
|
throw new Error("No next handler set in ContentTypeHandler.");
|
|
@@ -526,6 +745,13 @@ var RequestValidationHandler = class {
|
|
|
526
745
|
this.validateRequest(request);
|
|
527
746
|
return this.next.handle(request);
|
|
528
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Handles a streaming HTTP request with validation.
|
|
750
|
+
* @template T - The expected response data type for each chunk
|
|
751
|
+
* @param request - The HTTP request to validate
|
|
752
|
+
* @returns An async generator that yields HTTP responses
|
|
753
|
+
* @throws Error if no next handler is set
|
|
754
|
+
*/
|
|
529
755
|
async *stream(request) {
|
|
530
756
|
if (!this.next) {
|
|
531
757
|
throw new Error("No next handler set in ContentTypeHandler.");
|
|
@@ -533,6 +759,11 @@ var RequestValidationHandler = class {
|
|
|
533
759
|
this.validateRequest(request);
|
|
534
760
|
yield* this.next.stream(request);
|
|
535
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* Validates and serializes the request body based on its content type.
|
|
764
|
+
* @param request - The HTTP request to validate
|
|
765
|
+
* @throws ValidationError if Zod schema validation fails
|
|
766
|
+
*/
|
|
536
767
|
validateRequest(request) {
|
|
537
768
|
var _a, _b;
|
|
538
769
|
if (request.requestContentType === "json" /* Json */) {
|
|
@@ -555,6 +786,11 @@ var RequestValidationHandler = class {
|
|
|
555
786
|
request.body = JSON.stringify((_b = request.requestSchema) == null ? void 0 : _b.parse(request.body));
|
|
556
787
|
}
|
|
557
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* Converts request body to URL-encoded form data format.
|
|
791
|
+
* @param request - The HTTP request with body to convert
|
|
792
|
+
* @returns URL-encoded string representation of the body
|
|
793
|
+
*/
|
|
558
794
|
toFormUrlEncoded(request) {
|
|
559
795
|
var _a;
|
|
560
796
|
if (request.body === void 0) {
|
|
@@ -587,6 +823,14 @@ var RequestValidationHandler = class {
|
|
|
587
823
|
}
|
|
588
824
|
return "";
|
|
589
825
|
}
|
|
826
|
+
/**
|
|
827
|
+
* Converts request body to multipart form data format.
|
|
828
|
+
* Handles files (ArrayBuffer), arrays, and regular values.
|
|
829
|
+
* @param body - The request body object
|
|
830
|
+
* @param filename - Optional filename for single file uploads
|
|
831
|
+
* @param filenames - Optional filenames array for array of file uploads
|
|
832
|
+
* @returns FormData object with serialized body
|
|
833
|
+
*/
|
|
590
834
|
toFormData(body, filename, filenames) {
|
|
591
835
|
const formData = new FormData();
|
|
592
836
|
Object.keys(body).forEach((key) => {
|
|
@@ -621,6 +865,9 @@ var LineDecoder = class {
|
|
|
621
865
|
/**
|
|
622
866
|
* Splits the given chunk into lines.
|
|
623
867
|
* Stores incomplete lines in a buffer and returns them when the next chunk arrives.
|
|
868
|
+
*
|
|
869
|
+
* @param chunk - The data chunk to split into lines
|
|
870
|
+
* @returns An array of complete lines as Uint8Array
|
|
624
871
|
*/
|
|
625
872
|
splitLines(chunk) {
|
|
626
873
|
this.lineBuffer += this.decoder.decode(chunk);
|
|
@@ -635,7 +882,12 @@ var LineDecoder = class {
|
|
|
635
882
|
}
|
|
636
883
|
return lines;
|
|
637
884
|
}
|
|
638
|
-
/**
|
|
885
|
+
/**
|
|
886
|
+
* Returns the remaining lines in the buffer.
|
|
887
|
+
* Call this after the stream ends to get any incomplete final line.
|
|
888
|
+
*
|
|
889
|
+
* @returns An array containing the buffered line, or empty if buffer is empty
|
|
890
|
+
*/
|
|
639
891
|
flush() {
|
|
640
892
|
if (this.lineBuffer.length === 0) {
|
|
641
893
|
return [];
|
|
@@ -653,9 +905,16 @@ var RequestFetchAdapter = class {
|
|
|
653
905
|
this.requestInit = {};
|
|
654
906
|
this.setMethod(request.method);
|
|
655
907
|
this.setHeaders(request.getHeaders());
|
|
908
|
+
this.setCookies(request.getCookies());
|
|
656
909
|
this.setBody(request.body);
|
|
657
910
|
this.setTimeout(request.config.timeoutMs);
|
|
658
911
|
}
|
|
912
|
+
/**
|
|
913
|
+
* Executes the HTTP request and returns the response.
|
|
914
|
+
* Fetches the full response body as an ArrayBuffer.
|
|
915
|
+
*
|
|
916
|
+
* @returns A promise resolving to the HTTP response with metadata and body
|
|
917
|
+
*/
|
|
659
918
|
async send() {
|
|
660
919
|
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
661
920
|
const metadata = {
|
|
@@ -668,6 +927,13 @@ var RequestFetchAdapter = class {
|
|
|
668
927
|
raw: await response.clone().arrayBuffer()
|
|
669
928
|
};
|
|
670
929
|
}
|
|
930
|
+
/**
|
|
931
|
+
* Executes the HTTP request as a stream, yielding chunks as they arrive.
|
|
932
|
+
* Uses the Fetch API's ReadableStream and LineDecoder to split into lines.
|
|
933
|
+
*
|
|
934
|
+
* @returns An async generator yielding HTTP response chunks
|
|
935
|
+
* @throws Error if responseHeaders is enabled (streaming not supported with responseHeaders)
|
|
936
|
+
*/
|
|
671
937
|
async *stream() {
|
|
672
938
|
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
673
939
|
const metadata = {
|
|
@@ -732,6 +998,19 @@ var RequestFetchAdapter = class {
|
|
|
732
998
|
headers
|
|
733
999
|
};
|
|
734
1000
|
}
|
|
1001
|
+
setCookies(cookies) {
|
|
1002
|
+
if (!cookies || Object.keys(cookies).length === 0) {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const cookieString = Object.entries(cookies).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
1006
|
+
this.requestInit = {
|
|
1007
|
+
...this.requestInit,
|
|
1008
|
+
headers: {
|
|
1009
|
+
...this.requestInit.headers,
|
|
1010
|
+
Cookie: cookieString
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
735
1014
|
setTimeout(timeoutMs) {
|
|
736
1015
|
if (!timeoutMs) {
|
|
737
1016
|
return;
|
|
@@ -755,9 +1034,21 @@ var RequestFetchAdapter = class {
|
|
|
755
1034
|
|
|
756
1035
|
// src/http/handlers/terminating-handler.ts
|
|
757
1036
|
var TerminatingHandler = class {
|
|
1037
|
+
/**
|
|
1038
|
+
* Executes the actual HTTP request using the configured client adapter.
|
|
1039
|
+
* @template T - The expected response data type
|
|
1040
|
+
* @param request - The HTTP request to execute
|
|
1041
|
+
* @returns A promise that resolves to the HTTP response
|
|
1042
|
+
*/
|
|
758
1043
|
async handle(request) {
|
|
759
1044
|
return new RequestFetchAdapter(request).send();
|
|
760
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Executes a streaming HTTP request using the configured client adapter.
|
|
1048
|
+
* @template T - The expected response data type for each chunk
|
|
1049
|
+
* @param request - The HTTP request to execute
|
|
1050
|
+
* @returns An async generator that yields HTTP responses
|
|
1051
|
+
*/
|
|
761
1052
|
async *stream(request) {
|
|
762
1053
|
yield* new RequestFetchAdapter(request).stream();
|
|
763
1054
|
}
|
|
@@ -765,6 +1056,14 @@ var TerminatingHandler = class {
|
|
|
765
1056
|
|
|
766
1057
|
// src/http/handlers/retry-handler.ts
|
|
767
1058
|
var RetryHandler = class {
|
|
1059
|
+
/**
|
|
1060
|
+
* Handles a standard HTTP request with retry logic.
|
|
1061
|
+
* Retries failed requests based on the configured retry settings.
|
|
1062
|
+
* @template T - The expected response data type
|
|
1063
|
+
* @param request - The HTTP request to process
|
|
1064
|
+
* @returns A promise that resolves to the HTTP response
|
|
1065
|
+
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1066
|
+
*/
|
|
768
1067
|
async handle(request) {
|
|
769
1068
|
if (!this.next) {
|
|
770
1069
|
throw new Error("No next handler set in retry handler.");
|
|
@@ -781,6 +1080,13 @@ var RetryHandler = class {
|
|
|
781
1080
|
}
|
|
782
1081
|
throw new Error("Error retrying request.");
|
|
783
1082
|
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Handles a streaming HTTP request with retry logic.
|
|
1085
|
+
* @template T - The expected response data type for each chunk
|
|
1086
|
+
* @param request - The HTTP request to process
|
|
1087
|
+
* @returns An async generator that yields HTTP responses
|
|
1088
|
+
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1089
|
+
*/
|
|
784
1090
|
async *stream(request) {
|
|
785
1091
|
if (!this.next) {
|
|
786
1092
|
throw new Error("No next handler set in retry handler.");
|
|
@@ -798,9 +1104,20 @@ var RetryHandler = class {
|
|
|
798
1104
|
}
|
|
799
1105
|
throw new Error("Error retrying request.");
|
|
800
1106
|
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Determines if an error should trigger a retry.
|
|
1109
|
+
* Retries server errors (5xx), request timeouts (408), and rate limits (429).
|
|
1110
|
+
* @param error - The error to check
|
|
1111
|
+
* @returns True if the request should be retried, false otherwise
|
|
1112
|
+
*/
|
|
801
1113
|
shouldRetry(error) {
|
|
802
|
-
return error instanceof HttpError && (error.metadata.status >= 500 || error.metadata.status === 408);
|
|
1114
|
+
return error instanceof HttpError && (error.metadata.status >= 500 || error.metadata.status === 408 || error.metadata.status === 429);
|
|
803
1115
|
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Delays execution for a specified duration before retrying.
|
|
1118
|
+
* @param delayMs - The delay in milliseconds (optional)
|
|
1119
|
+
* @returns A promise that resolves after the delay
|
|
1120
|
+
*/
|
|
804
1121
|
delay(delayMs) {
|
|
805
1122
|
if (!delayMs) {
|
|
806
1123
|
return Promise.resolve();
|
|
@@ -811,8 +1128,21 @@ var RetryHandler = class {
|
|
|
811
1128
|
}
|
|
812
1129
|
};
|
|
813
1130
|
|
|
1131
|
+
// src/http/transport/types.ts
|
|
1132
|
+
function isRequestCursorPagination(pagination) {
|
|
1133
|
+
return !!pagination && "cursorPath" in pagination;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
814
1136
|
// src/http/handlers/oauth-handler.ts
|
|
815
1137
|
var OAuthHandler = class {
|
|
1138
|
+
/**
|
|
1139
|
+
* Handles a standard HTTP request with OAuth authentication.
|
|
1140
|
+
* Manages access tokens and adds Authorization headers.
|
|
1141
|
+
* @template T - The expected response data type
|
|
1142
|
+
* @param request - The HTTP request to process
|
|
1143
|
+
* @returns A promise that resolves to the HTTP response
|
|
1144
|
+
* @throws Error if no next handler is set
|
|
1145
|
+
*/
|
|
816
1146
|
async handle(request) {
|
|
817
1147
|
if (!this.next) {
|
|
818
1148
|
throw new Error(`No next handler set in OAuthHandler`);
|
|
@@ -827,6 +1157,13 @@ var OAuthHandler = class {
|
|
|
827
1157
|
await this.manageToken(request);
|
|
828
1158
|
return this.next.handle(request);
|
|
829
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Handles a streaming HTTP request with OAuth authentication.
|
|
1162
|
+
* @template T - The expected response data type for each chunk
|
|
1163
|
+
* @param request - The HTTP request to process
|
|
1164
|
+
* @returns An async generator that yields HTTP responses
|
|
1165
|
+
* @throws Error if no next handler is set
|
|
1166
|
+
*/
|
|
830
1167
|
async *stream(request) {
|
|
831
1168
|
if (!this.next) {
|
|
832
1169
|
throw new Error(`No next handler set in OAuthHandler`);
|
|
@@ -834,6 +1171,10 @@ var OAuthHandler = class {
|
|
|
834
1171
|
await this.manageToken(request);
|
|
835
1172
|
yield* this.next.stream(request);
|
|
836
1173
|
}
|
|
1174
|
+
/**
|
|
1175
|
+
* Retrieves an access token for the required scopes and adds it to the request.
|
|
1176
|
+
* @param request - The HTTP request to add the token to
|
|
1177
|
+
*/
|
|
837
1178
|
async manageToken(request) {
|
|
838
1179
|
if (!request.scopes) {
|
|
839
1180
|
return;
|
|
@@ -843,6 +1184,11 @@ var OAuthHandler = class {
|
|
|
843
1184
|
this.addAccessTokenHeader(request, token.accessToken);
|
|
844
1185
|
}
|
|
845
1186
|
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Adds the OAuth access token to the request's Authorization header.
|
|
1189
|
+
* @param request - The HTTP request to modify
|
|
1190
|
+
* @param token - The access token to add
|
|
1191
|
+
*/
|
|
846
1192
|
addAccessTokenHeader(request, token) {
|
|
847
1193
|
request.addHeaderParam("Authorization", {
|
|
848
1194
|
key: "Authorization",
|
|
@@ -851,15 +1197,22 @@ var OAuthHandler = class {
|
|
|
851
1197
|
encode: false,
|
|
852
1198
|
style: "simple" /* SIMPLE */,
|
|
853
1199
|
isLimit: false,
|
|
854
|
-
isOffset: false
|
|
1200
|
+
isOffset: false,
|
|
1201
|
+
isCursor: false
|
|
855
1202
|
});
|
|
856
1203
|
}
|
|
857
1204
|
};
|
|
858
1205
|
|
|
859
1206
|
// src/http/client.ts
|
|
860
1207
|
var HttpClient = class {
|
|
1208
|
+
/**
|
|
1209
|
+
* Creates a new HTTP client with configured request handlers.
|
|
1210
|
+
* @param config - SDK configuration including base URL and authentication
|
|
1211
|
+
* @param hook - Optional custom hook for request/response interception
|
|
1212
|
+
*/
|
|
861
1213
|
constructor(config, hook = new CustomHook()) {
|
|
862
1214
|
this.config = config;
|
|
1215
|
+
/** Chain of request handlers that process requests in sequence */
|
|
863
1216
|
this.requestHandlerChain = new RequestHandlerChain();
|
|
864
1217
|
this.requestHandlerChain.addHandler(new ResponseValidationHandler());
|
|
865
1218
|
this.requestHandlerChain.addHandler(new RequestValidationHandler());
|
|
@@ -868,45 +1221,126 @@ var HttpClient = class {
|
|
|
868
1221
|
this.requestHandlerChain.addHandler(new HookHandler(hook));
|
|
869
1222
|
this.requestHandlerChain.addHandler(new TerminatingHandler());
|
|
870
1223
|
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Executes a standard HTTP request.
|
|
1226
|
+
* @template T - The expected response data type
|
|
1227
|
+
* @param request - The HTTP request to execute
|
|
1228
|
+
* @returns A promise that resolves to the HTTP response
|
|
1229
|
+
*/
|
|
871
1230
|
call(request) {
|
|
872
1231
|
return this.requestHandlerChain.callChain(request);
|
|
873
1232
|
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Executes a streaming HTTP request that yields responses incrementally.
|
|
1235
|
+
* @template T - The expected response data type for each chunk
|
|
1236
|
+
* @param request - The HTTP request to execute
|
|
1237
|
+
* @returns An async generator that yields HTTP responses
|
|
1238
|
+
*/
|
|
874
1239
|
async *stream(request) {
|
|
875
1240
|
yield* this.requestHandlerChain.streamChain(request);
|
|
876
1241
|
}
|
|
1242
|
+
/**
|
|
1243
|
+
* Executes a paginated HTTP request and extracts the page data from the response.
|
|
1244
|
+
* @template FullResponse - The complete response type from the API
|
|
1245
|
+
* @template Page - The type of a single page of data
|
|
1246
|
+
* @param request - The paginated HTTP request to execute
|
|
1247
|
+
* @returns A promise that resolves to the paginated HTTP response
|
|
1248
|
+
* @throws Error if the response contains no data to paginate through
|
|
1249
|
+
*/
|
|
877
1250
|
async callPaginated(request) {
|
|
878
1251
|
const response = await this.call(request);
|
|
879
1252
|
if (!response.data) {
|
|
880
1253
|
throw new Error("no response data to paginate through");
|
|
881
1254
|
}
|
|
1255
|
+
const page = this.getPage(request, response.data);
|
|
882
1256
|
return {
|
|
883
1257
|
...response,
|
|
884
|
-
data:
|
|
1258
|
+
data: page
|
|
885
1259
|
};
|
|
886
1260
|
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Executes a cursor-paginated HTTP request and extracts both page data and the next cursor.
|
|
1263
|
+
* @template FullResponse - The complete response type from the API
|
|
1264
|
+
* @template Page - The type of a single page of data
|
|
1265
|
+
* @param request - The cursor-paginated HTTP request to execute
|
|
1266
|
+
* @returns A promise that resolves to the cursor-paginated HTTP response with next cursor
|
|
1267
|
+
* @throws Error if the response contains no data to paginate through
|
|
1268
|
+
*/
|
|
1269
|
+
async callCursorPaginated(request) {
|
|
1270
|
+
const response = await this.call(request);
|
|
1271
|
+
if (!response.data) {
|
|
1272
|
+
throw new Error("no response data to paginate through");
|
|
1273
|
+
}
|
|
1274
|
+
const page = this.getPage(request, response.data);
|
|
1275
|
+
const nextCursor = this.getNextCursor(request, response.data);
|
|
1276
|
+
return {
|
|
1277
|
+
...response,
|
|
1278
|
+
data: page,
|
|
1279
|
+
nextCursor
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Updates the base URL for all subsequent requests.
|
|
1284
|
+
* @param url - The new base URL to use
|
|
1285
|
+
*/
|
|
887
1286
|
setBaseUrl(url) {
|
|
888
1287
|
this.config.baseUrl = url;
|
|
889
1288
|
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Updates the SDK configuration.
|
|
1291
|
+
* @param config - The new SDK configuration
|
|
1292
|
+
*/
|
|
890
1293
|
setConfig(config) {
|
|
891
1294
|
this.config = config;
|
|
892
1295
|
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Extracts page data from a full API response using the configured pagination path.
|
|
1298
|
+
* @template FullResponse - The complete response type from the API
|
|
1299
|
+
* @template Page - The type of a single page of data
|
|
1300
|
+
* @param request - The request containing pagination configuration
|
|
1301
|
+
* @param data - The full response data to extract the page from
|
|
1302
|
+
* @returns The extracted and parsed page data
|
|
1303
|
+
* @throws Error if pagination is not configured or page extraction fails
|
|
1304
|
+
*/
|
|
893
1305
|
getPage(request, data) {
|
|
894
|
-
var _a
|
|
1306
|
+
var _a;
|
|
895
1307
|
if (!request.pagination) {
|
|
896
1308
|
throw new Error("getPage called for request without pagination property");
|
|
897
1309
|
}
|
|
898
1310
|
let curr = data;
|
|
899
|
-
for (const segment of
|
|
1311
|
+
for (const segment of request.pagination.pagePath || []) {
|
|
900
1312
|
curr = curr[segment];
|
|
901
1313
|
}
|
|
902
|
-
const page = (
|
|
1314
|
+
const page = (_a = request.pagination.pageSchema) == null ? void 0 : _a.parse(curr);
|
|
903
1315
|
if (!page) {
|
|
904
1316
|
throw new Error(
|
|
905
|
-
`error getting page data. Curr: ${JSON.stringify(curr)}. PagePath: ${
|
|
1317
|
+
`error getting page data. Curr: ${JSON.stringify(curr)}. PagePath: ${request.pagination.pagePath}. Data: ${JSON.stringify(data)}`
|
|
906
1318
|
);
|
|
907
1319
|
}
|
|
908
1320
|
return page;
|
|
909
1321
|
}
|
|
1322
|
+
/**
|
|
1323
|
+
* Extracts the next cursor from a full API response for cursor-based pagination.
|
|
1324
|
+
* @template FullResponse - The complete response type from the API
|
|
1325
|
+
* @template Page - The type of a single page of data
|
|
1326
|
+
* @param request - The request containing cursor pagination configuration
|
|
1327
|
+
* @param data - The full response data to extract the cursor from
|
|
1328
|
+
* @returns The next cursor string, null if no more pages, or undefined if not cursor pagination
|
|
1329
|
+
*/
|
|
1330
|
+
getNextCursor(request, data) {
|
|
1331
|
+
var _a, _b;
|
|
1332
|
+
if (!isRequestCursorPagination(request.pagination)) {
|
|
1333
|
+
return void 0;
|
|
1334
|
+
}
|
|
1335
|
+
let curr = data;
|
|
1336
|
+
for (const segment of request.pagination.cursorPath) {
|
|
1337
|
+
if (curr === null || curr === void 0) {
|
|
1338
|
+
return null;
|
|
1339
|
+
}
|
|
1340
|
+
curr = curr[segment];
|
|
1341
|
+
}
|
|
1342
|
+
return (_b = (_a = request.pagination.cursorSchema) == null ? void 0 : _a.parse(curr)) != null ? _b : null;
|
|
1343
|
+
}
|
|
910
1344
|
};
|
|
911
1345
|
|
|
912
1346
|
// src/services/base-service.ts
|
|
@@ -944,6 +1378,14 @@ var import_zod3 = __toESM(require("zod"));
|
|
|
944
1378
|
|
|
945
1379
|
// src/http/serialization/path-serializer.ts
|
|
946
1380
|
var PathSerializer = class extends Serializer {
|
|
1381
|
+
/**
|
|
1382
|
+
* Serializes path parameters into a URL path by replacing template placeholders.
|
|
1383
|
+
* @param pathPattern - The URL path pattern with {placeholders}
|
|
1384
|
+
* @param pathArguments - Map of parameter names to their values
|
|
1385
|
+
* @returns The path with placeholders replaced by serialized values
|
|
1386
|
+
* @example
|
|
1387
|
+
* serialize("/users/{id}", Map([["id", {key: "id", value: 123}]])) returns "/users/123"
|
|
1388
|
+
*/
|
|
947
1389
|
serialize(pathPattern, pathArguments) {
|
|
948
1390
|
let serializedPath = pathPattern;
|
|
949
1391
|
pathArguments.forEach((param) => {
|
|
@@ -955,12 +1397,22 @@ var PathSerializer = class extends Serializer {
|
|
|
955
1397
|
|
|
956
1398
|
// src/http/serialization/query-serializer.ts
|
|
957
1399
|
var QuerySerializer = class extends Serializer {
|
|
1400
|
+
/**
|
|
1401
|
+
* Serializes query parameters into a URL query string.
|
|
1402
|
+
* @param queryParams - Map of query parameter names to their values
|
|
1403
|
+
* @returns A query string starting with "?" if parameters exist, empty string otherwise
|
|
1404
|
+
* @example
|
|
1405
|
+
* serialize(Map([["name", {...}], ["age", {...}]])) returns "?name=John&age=30"
|
|
1406
|
+
*/
|
|
958
1407
|
serialize(queryParams) {
|
|
959
1408
|
if (!queryParams || !queryParams.size) {
|
|
960
1409
|
return "";
|
|
961
1410
|
}
|
|
962
1411
|
const query = [];
|
|
963
1412
|
queryParams.forEach((param) => {
|
|
1413
|
+
if (param.value === void 0) {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
964
1416
|
return query.push(`${this.serializeValue(param)}`);
|
|
965
1417
|
});
|
|
966
1418
|
return query.length ? `?${query.join("&")}` : "";
|
|
@@ -969,6 +1421,11 @@ var QuerySerializer = class extends Serializer {
|
|
|
969
1421
|
|
|
970
1422
|
// src/http/serialization/header-serializer.ts
|
|
971
1423
|
var HeaderSerializer = class extends Serializer {
|
|
1424
|
+
/**
|
|
1425
|
+
* Serializes header parameters into a headers object.
|
|
1426
|
+
* @param headerParams - Map of header names to their parameter values
|
|
1427
|
+
* @returns A HeadersInit object with serialized header values, or undefined if no headers
|
|
1428
|
+
*/
|
|
972
1429
|
serialize(headerParams) {
|
|
973
1430
|
if (!headerParams || !headerParams.size) {
|
|
974
1431
|
return void 0;
|
|
@@ -984,6 +1441,83 @@ var HeaderSerializer = class extends Serializer {
|
|
|
984
1441
|
}
|
|
985
1442
|
};
|
|
986
1443
|
|
|
1444
|
+
// src/http/serialization/cookie-serializer.ts
|
|
1445
|
+
var CookieSerializer = class {
|
|
1446
|
+
/**
|
|
1447
|
+
* Serializes cookie parameters into a cookie object.
|
|
1448
|
+
* @param cookieParams - Map of cookie names to their parameter values
|
|
1449
|
+
* @returns A record of cookie names to serialized values, or undefined if no cookies
|
|
1450
|
+
*/
|
|
1451
|
+
serialize(cookieParams) {
|
|
1452
|
+
if (!cookieParams || !cookieParams.size) {
|
|
1453
|
+
return void 0;
|
|
1454
|
+
}
|
|
1455
|
+
const cookies = {};
|
|
1456
|
+
cookieParams.forEach((param) => {
|
|
1457
|
+
if (!param.key || param.value === void 0) {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
cookies[param.key] = this.serializeCookieValue(param);
|
|
1461
|
+
});
|
|
1462
|
+
return cookies;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Serializes a single cookie value based on its type.
|
|
1466
|
+
* @param param - The cookie parameter to serialize
|
|
1467
|
+
* @returns The serialized cookie value string
|
|
1468
|
+
*/
|
|
1469
|
+
serializeCookieValue(param) {
|
|
1470
|
+
if (Array.isArray(param.value)) {
|
|
1471
|
+
return this.serializeArray(param.value, param);
|
|
1472
|
+
}
|
|
1473
|
+
if (this.isNonNullObject(param.value)) {
|
|
1474
|
+
return this.serializeObject(param.value, param);
|
|
1475
|
+
}
|
|
1476
|
+
return this.serializePrimitive(param.value);
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Serializes a primitive cookie value.
|
|
1480
|
+
* @param value - The primitive value to serialize
|
|
1481
|
+
* @returns The string representation of the value
|
|
1482
|
+
*/
|
|
1483
|
+
serializePrimitive(value) {
|
|
1484
|
+
return `${value}`;
|
|
1485
|
+
}
|
|
1486
|
+
/**
|
|
1487
|
+
* Serializes an array cookie value.
|
|
1488
|
+
* @param value - The array to serialize
|
|
1489
|
+
* @param param - The cookie parameter configuration
|
|
1490
|
+
* @returns The serialized array string
|
|
1491
|
+
*/
|
|
1492
|
+
serializeArray(value, param) {
|
|
1493
|
+
if (param.explode) {
|
|
1494
|
+
if (value.length === 0)
|
|
1495
|
+
return "";
|
|
1496
|
+
const first = value[0];
|
|
1497
|
+
const rest = value.slice(1).map((v) => `${param.key}=${v}`).join("; ");
|
|
1498
|
+
return rest ? `${first}; ${rest}` : `${first}`;
|
|
1499
|
+
}
|
|
1500
|
+
return value.join(",");
|
|
1501
|
+
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Serializes an object cookie value as JSON.
|
|
1504
|
+
* @param obj - The object to serialize
|
|
1505
|
+
* @param param - The cookie parameter configuration
|
|
1506
|
+
* @returns The JSON string representation of the object
|
|
1507
|
+
*/
|
|
1508
|
+
serializeObject(obj, param) {
|
|
1509
|
+
return JSON.stringify(obj);
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Type guard to check if a value is a non-null object.
|
|
1513
|
+
* @param value - The value to check
|
|
1514
|
+
* @returns True if the value is an object and not null
|
|
1515
|
+
*/
|
|
1516
|
+
isNonNullObject(value) {
|
|
1517
|
+
return typeof value === "object" && value !== null;
|
|
1518
|
+
}
|
|
1519
|
+
};
|
|
1520
|
+
|
|
987
1521
|
// src/http/transport/request.ts
|
|
988
1522
|
var Request = class {
|
|
989
1523
|
constructor(params) {
|
|
@@ -991,6 +1525,7 @@ var Request = class {
|
|
|
991
1525
|
this.headers = /* @__PURE__ */ new Map();
|
|
992
1526
|
this.queryParams = /* @__PURE__ */ new Map();
|
|
993
1527
|
this.pathParams = /* @__PURE__ */ new Map();
|
|
1528
|
+
this.cookies = /* @__PURE__ */ new Map();
|
|
994
1529
|
this.validation = {};
|
|
995
1530
|
this.retry = {};
|
|
996
1531
|
this.baseUrl = params.baseUrl;
|
|
@@ -1002,6 +1537,7 @@ var Request = class {
|
|
|
1002
1537
|
this.pathParams = params.pathParams;
|
|
1003
1538
|
this.headers = params.headers;
|
|
1004
1539
|
this.queryParams = params.queryParams;
|
|
1540
|
+
this.cookies = params.cookies;
|
|
1005
1541
|
this.responses = params.responses;
|
|
1006
1542
|
this.errors = params.errors;
|
|
1007
1543
|
this.requestSchema = params.requestSchema;
|
|
@@ -1014,6 +1550,12 @@ var Request = class {
|
|
|
1014
1550
|
this.scopes = params.scopes;
|
|
1015
1551
|
this.tokenManager = params.tokenManager;
|
|
1016
1552
|
}
|
|
1553
|
+
/**
|
|
1554
|
+
* Adds a header parameter to the request with OpenAPI serialization rules.
|
|
1555
|
+
*
|
|
1556
|
+
* @param key - The header name
|
|
1557
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1558
|
+
*/
|
|
1017
1559
|
addHeaderParam(key, param) {
|
|
1018
1560
|
if (param.value === void 0) {
|
|
1019
1561
|
return;
|
|
@@ -1029,6 +1571,12 @@ var Request = class {
|
|
|
1029
1571
|
}
|
|
1030
1572
|
this.headers.set(key, param);
|
|
1031
1573
|
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Adds a query parameter to the request with OpenAPI serialization rules.
|
|
1576
|
+
*
|
|
1577
|
+
* @param key - The query parameter name
|
|
1578
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1579
|
+
*/
|
|
1032
1580
|
addQueryParam(key, param) {
|
|
1033
1581
|
if (param.value === void 0) {
|
|
1034
1582
|
return;
|
|
@@ -1044,6 +1592,12 @@ var Request = class {
|
|
|
1044
1592
|
}
|
|
1045
1593
|
this.queryParams.set(key, param);
|
|
1046
1594
|
}
|
|
1595
|
+
/**
|
|
1596
|
+
* Adds a path parameter to the request with OpenAPI serialization rules.
|
|
1597
|
+
*
|
|
1598
|
+
* @param key - The path parameter name (matches template variable in path pattern)
|
|
1599
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1600
|
+
*/
|
|
1047
1601
|
addPathParam(key, param) {
|
|
1048
1602
|
if (param.value === void 0) {
|
|
1049
1603
|
return;
|
|
@@ -1059,26 +1613,50 @@ var Request = class {
|
|
|
1059
1613
|
}
|
|
1060
1614
|
this.pathParams.set(key, param);
|
|
1061
1615
|
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Sets the request body if the value is defined.
|
|
1618
|
+
*
|
|
1619
|
+
* @param body - The request body to send
|
|
1620
|
+
*/
|
|
1062
1621
|
addBody(body) {
|
|
1063
1622
|
if (body === void 0) {
|
|
1064
1623
|
return;
|
|
1065
1624
|
}
|
|
1066
1625
|
this.body = body;
|
|
1067
1626
|
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Updates this request from a modified hook request.
|
|
1629
|
+
* Used after hooks modify the request to sync changes back to the internal Request object.
|
|
1630
|
+
*
|
|
1631
|
+
* @param hookRequest - The modified request from hook processing
|
|
1632
|
+
*/
|
|
1068
1633
|
updateFromHookRequest(hookRequest) {
|
|
1069
1634
|
this.baseUrl = hookRequest.baseUrl;
|
|
1070
1635
|
this.method = hookRequest.method;
|
|
1071
1636
|
this.path = hookRequest.path;
|
|
1072
1637
|
this.body = hookRequest.body;
|
|
1073
1638
|
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Constructs the complete URL by combining base URL, path with substituted parameters,
|
|
1641
|
+
* and serialized query string.
|
|
1642
|
+
*
|
|
1643
|
+
* @returns The fully constructed URL ready for HTTP execution
|
|
1644
|
+
*/
|
|
1074
1645
|
constructFullUrl() {
|
|
1075
1646
|
const queryString = new QuerySerializer().serialize(this.queryParams);
|
|
1076
1647
|
const path = this.constructPath();
|
|
1077
1648
|
let baseUrl = this.baseUrl;
|
|
1078
1649
|
return `${baseUrl}${path}${queryString}`;
|
|
1079
1650
|
}
|
|
1651
|
+
/**
|
|
1652
|
+
* Creates a copy of this request with optional parameter overrides.
|
|
1653
|
+
* Useful for pagination where you need to modify parameters while keeping the rest intact.
|
|
1654
|
+
*
|
|
1655
|
+
* @param overrides - Optional parameters to override in the copied request
|
|
1656
|
+
* @returns A new Request instance with the specified overrides
|
|
1657
|
+
*/
|
|
1080
1658
|
copy(overrides) {
|
|
1081
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1659
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1082
1660
|
const createRequestParams = {
|
|
1083
1661
|
baseUrl: (_a = overrides == null ? void 0 : overrides.baseUrl) != null ? _a : this.baseUrl,
|
|
1084
1662
|
errors: (_b = overrides == null ? void 0 : overrides.errors) != null ? _b : this.errors,
|
|
@@ -1089,13 +1667,14 @@ var Request = class {
|
|
|
1089
1667
|
pathParams: (_g = overrides == null ? void 0 : overrides.pathParams) != null ? _g : this.pathParams,
|
|
1090
1668
|
queryParams: (_h = overrides == null ? void 0 : overrides.queryParams) != null ? _h : this.queryParams,
|
|
1091
1669
|
headers: (_i = overrides == null ? void 0 : overrides.headers) != null ? _i : this.headers,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1670
|
+
cookies: (_j = overrides == null ? void 0 : overrides.cookies) != null ? _j : this.cookies,
|
|
1671
|
+
responses: (_k = overrides == null ? void 0 : overrides.responses) != null ? _k : this.responses,
|
|
1672
|
+
requestSchema: (_l = overrides == null ? void 0 : overrides.requestSchema) != null ? _l : this.requestSchema,
|
|
1673
|
+
requestContentType: (_m = overrides == null ? void 0 : overrides.requestContentType) != null ? _m : this.requestContentType,
|
|
1674
|
+
retry: (_n = overrides == null ? void 0 : overrides.retry) != null ? _n : this.retry,
|
|
1675
|
+
validation: (_o = overrides == null ? void 0 : overrides.validation) != null ? _o : this.validation,
|
|
1676
|
+
filename: (_p = overrides == null ? void 0 : overrides.filename) != null ? _p : this.filename,
|
|
1677
|
+
filenames: (_q = overrides == null ? void 0 : overrides.filenames) != null ? _q : this.filenames,
|
|
1099
1678
|
scopes: overrides == null ? void 0 : overrides.scopes,
|
|
1100
1679
|
tokenManager: this.tokenManager
|
|
1101
1680
|
};
|
|
@@ -1104,21 +1683,52 @@ var Request = class {
|
|
|
1104
1683
|
...overrides
|
|
1105
1684
|
});
|
|
1106
1685
|
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Serializes headers to a format suitable for HTTP execution.
|
|
1688
|
+
*
|
|
1689
|
+
* @returns Serialized headers as HeadersInit, or undefined if no headers
|
|
1690
|
+
*/
|
|
1107
1691
|
getHeaders() {
|
|
1108
1692
|
if (!this.headers || !this.headers.size) {
|
|
1109
1693
|
return void 0;
|
|
1110
1694
|
}
|
|
1111
1695
|
return new HeaderSerializer().serialize(this.headers);
|
|
1112
1696
|
}
|
|
1113
|
-
|
|
1697
|
+
/**
|
|
1698
|
+
* Serializes cookies to a format suitable for HTTP execution.
|
|
1699
|
+
*
|
|
1700
|
+
* @returns Serialized cookies as a record, or undefined if no cookies
|
|
1701
|
+
*/
|
|
1702
|
+
getCookies() {
|
|
1703
|
+
if (!this.cookies || !this.cookies.size) {
|
|
1704
|
+
return void 0;
|
|
1705
|
+
}
|
|
1706
|
+
return new CookieSerializer().serialize(this.cookies);
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Advances pagination parameters to fetch the next page.
|
|
1710
|
+
* Handles both cursor-based and limit-offset pagination strategies.
|
|
1711
|
+
*
|
|
1712
|
+
* @param cursor - The cursor value for cursor-based pagination (optional for limit-offset)
|
|
1713
|
+
*/
|
|
1714
|
+
nextPage(cursor) {
|
|
1114
1715
|
if (!this.pagination) {
|
|
1115
1716
|
return;
|
|
1116
1717
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1718
|
+
if (isRequestCursorPagination(this.pagination)) {
|
|
1719
|
+
const cursorParam = this.getCursorParam();
|
|
1720
|
+
if (cursorParam && cursor !== void 0) {
|
|
1721
|
+
cursorParam.value = cursor;
|
|
1722
|
+
}
|
|
1119
1723
|
return;
|
|
1120
1724
|
}
|
|
1121
|
-
offsetParam
|
|
1725
|
+
const offsetParam = this.getOffsetParam();
|
|
1726
|
+
if (offsetParam) {
|
|
1727
|
+
if (this.pagination.pageSize === void 0) {
|
|
1728
|
+
throw new Error("pageSize is required for limit-offset pagination");
|
|
1729
|
+
}
|
|
1730
|
+
offsetParam.value = Number(offsetParam.value) + this.pagination.pageSize;
|
|
1731
|
+
}
|
|
1122
1732
|
}
|
|
1123
1733
|
constructPath() {
|
|
1124
1734
|
return new PathSerializer().serialize(this.pathPattern, this.pathParams);
|
|
@@ -1127,6 +1737,10 @@ var Request = class {
|
|
|
1127
1737
|
const offsetParam = this.getAllParams().find((param) => param.isOffset);
|
|
1128
1738
|
return offsetParam;
|
|
1129
1739
|
}
|
|
1740
|
+
getCursorParam() {
|
|
1741
|
+
const cursorParam = this.getAllParams().find((param) => param.isCursor);
|
|
1742
|
+
return cursorParam;
|
|
1743
|
+
}
|
|
1130
1744
|
getAllParams() {
|
|
1131
1745
|
const allParams = [];
|
|
1132
1746
|
this.headers.forEach((val, _) => {
|
|
@@ -1138,6 +1752,9 @@ var Request = class {
|
|
|
1138
1752
|
this.pathParams.forEach((val, _) => {
|
|
1139
1753
|
allParams.push(val);
|
|
1140
1754
|
});
|
|
1755
|
+
this.cookies.forEach((val, _) => {
|
|
1756
|
+
allParams.push(val);
|
|
1757
|
+
});
|
|
1141
1758
|
return allParams;
|
|
1142
1759
|
}
|
|
1143
1760
|
};
|
|
@@ -1150,6 +1767,10 @@ var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
|
1150
1767
|
|
|
1151
1768
|
// src/http/transport/request-builder.ts
|
|
1152
1769
|
var RequestBuilder = class {
|
|
1770
|
+
/**
|
|
1771
|
+
* Creates a new request builder with default configuration.
|
|
1772
|
+
* Initializes retry settings, validation options, and empty parameter collections.
|
|
1773
|
+
*/
|
|
1153
1774
|
constructor() {
|
|
1154
1775
|
this.params = {
|
|
1155
1776
|
baseUrl: "https://api.celitech.net/v1" /* DEFAULT */,
|
|
@@ -1170,6 +1791,7 @@ var RequestBuilder = class {
|
|
|
1170
1791
|
pathParams: /* @__PURE__ */ new Map(),
|
|
1171
1792
|
queryParams: /* @__PURE__ */ new Map(),
|
|
1172
1793
|
headers: /* @__PURE__ */ new Map(),
|
|
1794
|
+
cookies: /* @__PURE__ */ new Map(),
|
|
1173
1795
|
tokenManager: new OAuthTokenManager()
|
|
1174
1796
|
};
|
|
1175
1797
|
}
|
|
@@ -1242,6 +1864,10 @@ var RequestBuilder = class {
|
|
|
1242
1864
|
this.params.pagination = pagination;
|
|
1243
1865
|
return this;
|
|
1244
1866
|
}
|
|
1867
|
+
setCursorPagination(pagination) {
|
|
1868
|
+
this.params.pagination = pagination;
|
|
1869
|
+
return this;
|
|
1870
|
+
}
|
|
1245
1871
|
setScopes(scopes) {
|
|
1246
1872
|
this.params.scopes = new Set(scopes);
|
|
1247
1873
|
return this;
|
|
@@ -1261,7 +1887,8 @@ var RequestBuilder = class {
|
|
|
1261
1887
|
style: "simple" /* SIMPLE */,
|
|
1262
1888
|
encode: true,
|
|
1263
1889
|
isLimit: false,
|
|
1264
|
-
isOffset: false
|
|
1890
|
+
isOffset: false,
|
|
1891
|
+
isCursor: false
|
|
1265
1892
|
});
|
|
1266
1893
|
return this;
|
|
1267
1894
|
}
|
|
@@ -1276,7 +1903,8 @@ var RequestBuilder = class {
|
|
|
1276
1903
|
style: "simple" /* SIMPLE */,
|
|
1277
1904
|
encode: true,
|
|
1278
1905
|
isLimit: false,
|
|
1279
|
-
isOffset: false
|
|
1906
|
+
isOffset: false,
|
|
1907
|
+
isCursor: false
|
|
1280
1908
|
});
|
|
1281
1909
|
return this;
|
|
1282
1910
|
}
|
|
@@ -1291,7 +1919,8 @@ var RequestBuilder = class {
|
|
|
1291
1919
|
style: "simple" /* SIMPLE */,
|
|
1292
1920
|
encode: true,
|
|
1293
1921
|
isLimit: false,
|
|
1294
|
-
isOffset: false
|
|
1922
|
+
isOffset: false,
|
|
1923
|
+
isCursor: false
|
|
1295
1924
|
});
|
|
1296
1925
|
return this;
|
|
1297
1926
|
}
|
|
@@ -1321,13 +1950,14 @@ var RequestBuilder = class {
|
|
|
1321
1950
|
style: (_b = param.style) != null ? _b : "simple" /* SIMPLE */,
|
|
1322
1951
|
encode: (_c = param.encode) != null ? _c : true,
|
|
1323
1952
|
isLimit: !!param.isLimit,
|
|
1324
|
-
isOffset: !!param.isOffset
|
|
1953
|
+
isOffset: !!param.isOffset,
|
|
1954
|
+
isCursor: !!param.isCursor
|
|
1325
1955
|
});
|
|
1326
1956
|
return this;
|
|
1327
1957
|
}
|
|
1328
1958
|
addQueryParam(param) {
|
|
1329
1959
|
var _a, _b, _c;
|
|
1330
|
-
if (param.
|
|
1960
|
+
if (param.key === void 0) {
|
|
1331
1961
|
return this;
|
|
1332
1962
|
}
|
|
1333
1963
|
this.params.queryParams.set(param.key, {
|
|
@@ -1337,7 +1967,8 @@ var RequestBuilder = class {
|
|
|
1337
1967
|
style: (_b = param.style) != null ? _b : "form" /* FORM */,
|
|
1338
1968
|
encode: (_c = param.encode) != null ? _c : true,
|
|
1339
1969
|
isLimit: !!param.isLimit,
|
|
1340
|
-
isOffset: !!param.isOffset
|
|
1970
|
+
isOffset: !!param.isOffset,
|
|
1971
|
+
isCursor: !!param.isCursor
|
|
1341
1972
|
});
|
|
1342
1973
|
return this;
|
|
1343
1974
|
}
|
|
@@ -1353,13 +1984,42 @@ var RequestBuilder = class {
|
|
|
1353
1984
|
style: (_b = param.style) != null ? _b : "simple" /* SIMPLE */,
|
|
1354
1985
|
encode: (_c = param.encode) != null ? _c : false,
|
|
1355
1986
|
isLimit: !!param.isLimit,
|
|
1356
|
-
isOffset: !!param.isOffset
|
|
1987
|
+
isOffset: !!param.isOffset,
|
|
1988
|
+
isCursor: !!param.isCursor
|
|
1989
|
+
});
|
|
1990
|
+
return this;
|
|
1991
|
+
}
|
|
1992
|
+
addCookieParam(param) {
|
|
1993
|
+
var _a, _b, _c;
|
|
1994
|
+
if (param.value === void 0 || param.key === void 0) {
|
|
1995
|
+
return this;
|
|
1996
|
+
}
|
|
1997
|
+
this.params.cookies.set(param.key, {
|
|
1998
|
+
key: param.key,
|
|
1999
|
+
value: param.value,
|
|
2000
|
+
explode: (_a = param.explode) != null ? _a : true,
|
|
2001
|
+
style: (_b = param.style) != null ? _b : "form" /* FORM */,
|
|
2002
|
+
encode: (_c = param.encode) != null ? _c : false,
|
|
2003
|
+
isLimit: !!param.isLimit,
|
|
2004
|
+
isOffset: !!param.isOffset,
|
|
2005
|
+
isCursor: !!param.isCursor
|
|
1357
2006
|
});
|
|
1358
2007
|
return this;
|
|
1359
2008
|
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Builds and returns the configured Request object.
|
|
2011
|
+
* Call this method after configuring all request parameters.
|
|
2012
|
+
* @returns A new Request instance with all configured parameters
|
|
2013
|
+
*/
|
|
1360
2014
|
build() {
|
|
1361
2015
|
return new Request(this.params);
|
|
1362
2016
|
}
|
|
2017
|
+
/**
|
|
2018
|
+
* Converts a string to Base64 encoding.
|
|
2019
|
+
* Works in both Node.js and browser environments.
|
|
2020
|
+
* @param str - The string to encode
|
|
2021
|
+
* @returns The Base64-encoded string
|
|
2022
|
+
*/
|
|
1363
2023
|
toBase64(str) {
|
|
1364
2024
|
if (typeof window === "undefined") {
|
|
1365
2025
|
return Buffer.from(str, "utf-8").toString("base64");
|
|
@@ -1437,8 +2097,8 @@ var getAccessTokenOkResponseRequest = import_zod5.z.lazy(() => {
|
|
|
1437
2097
|
var OAuthService = class extends BaseService {
|
|
1438
2098
|
/**
|
|
1439
2099
|
* This endpoint was added by liblab
|
|
1440
|
-
* @param {RequestConfig} requestConfig -
|
|
1441
|
-
* @returns {Promise<HttpResponse<GetAccessTokenOkResponse>>} Successful Response
|
|
2100
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
2101
|
+
* @returns {Promise<HttpResponse<GetAccessTokenOkResponse>>} - Successful Response
|
|
1442
2102
|
*/
|
|
1443
2103
|
async getAccessToken(body, requestConfig) {
|
|
1444
2104
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/oauth2/token").setRequestSchema(getAccessTokenRequestRequest).setTokenManager(this.tokenManager).setRequestContentType("form" /* FormUrlEncoded */).addResponse({
|
|
@@ -1458,11 +2118,22 @@ var GrantType = /* @__PURE__ */ ((GrantType2) => {
|
|
|
1458
2118
|
|
|
1459
2119
|
// src/http/oauth/token-manager.ts
|
|
1460
2120
|
var OAuthToken = class {
|
|
2121
|
+
/**
|
|
2122
|
+
* Creates a new OAuth token.
|
|
2123
|
+
* @param accessToken - The access token string
|
|
2124
|
+
* @param scopes - Set of OAuth scopes granted to this token
|
|
2125
|
+
* @param expiresAt - Timestamp when the token expires (milliseconds since epoch), or null if no expiration
|
|
2126
|
+
*/
|
|
1461
2127
|
constructor(accessToken, scopes, expiresAt) {
|
|
1462
2128
|
this.accessToken = accessToken;
|
|
1463
2129
|
this.scopes = scopes;
|
|
1464
2130
|
this.expiresAt = expiresAt;
|
|
1465
2131
|
}
|
|
2132
|
+
/**
|
|
2133
|
+
* Checks if this token has all the required scopes.
|
|
2134
|
+
* @param scopes - Set of scopes to check for
|
|
2135
|
+
* @returns True if the token has all required scopes, false otherwise
|
|
2136
|
+
*/
|
|
1466
2137
|
hasAllScopes(scopes) {
|
|
1467
2138
|
for (const scope of scopes) {
|
|
1468
2139
|
if (!this.scopes.has(scope)) {
|
|
@@ -1473,6 +2144,14 @@ var OAuthToken = class {
|
|
|
1473
2144
|
}
|
|
1474
2145
|
};
|
|
1475
2146
|
var OAuthTokenManager = class {
|
|
2147
|
+
/**
|
|
2148
|
+
* Gets a valid access token for the specified scopes.
|
|
2149
|
+
* Returns a cached token if available and not expired, otherwise requests a new one.
|
|
2150
|
+
* @param scopes - Set of OAuth scopes required for the token
|
|
2151
|
+
* @param config - SDK configuration containing client credentials
|
|
2152
|
+
* @returns A promise that resolves to a valid OAuth token
|
|
2153
|
+
* @throws Error if client credentials are missing or token request fails
|
|
2154
|
+
*/
|
|
1476
2155
|
async getToken(scopes, config) {
|
|
1477
2156
|
var _a, _b, _c, _d, _e, _f;
|
|
1478
2157
|
if (((_a = this.token) == null ? void 0 : _a.hasAllScopes(scopes)) && ((_b = this.token) == null ? void 0 : _b.expiresAt) && this.token.expiresAt - Date.now() > 5e3) {
|
|
@@ -1580,11 +2259,21 @@ var import_zod8 = require("zod");
|
|
|
1580
2259
|
|
|
1581
2260
|
// src/http/errors/throwable-error.ts
|
|
1582
2261
|
var ThrowableError = class extends Error {
|
|
2262
|
+
/**
|
|
2263
|
+
* Creates a new throwable error.
|
|
2264
|
+
* @param message - The error message
|
|
2265
|
+
* @param response - Optional response data associated with the error
|
|
2266
|
+
*/
|
|
1583
2267
|
constructor(message, response) {
|
|
1584
2268
|
super(message);
|
|
1585
2269
|
this.message = message;
|
|
1586
2270
|
this.response = response;
|
|
1587
2271
|
}
|
|
2272
|
+
/**
|
|
2273
|
+
* Throws this error instance.
|
|
2274
|
+
* Convenience method for explicitly throwing the error.
|
|
2275
|
+
* @throws This error instance
|
|
2276
|
+
*/
|
|
1588
2277
|
throw() {
|
|
1589
2278
|
throw this;
|
|
1590
2279
|
}
|
|
@@ -1637,8 +2326,8 @@ var Unauthorized = class extends ThrowableError {
|
|
|
1637
2326
|
var DestinationsService = class extends BaseService {
|
|
1638
2327
|
/**
|
|
1639
2328
|
* List Destinations
|
|
1640
|
-
* @param {RequestConfig} requestConfig -
|
|
1641
|
-
* @returns {Promise<HttpResponse<ListDestinationsOkResponse>>} Successful Response
|
|
2329
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
2330
|
+
* @returns {Promise<HttpResponse<ListDestinationsOkResponse>>} - Successful Response
|
|
1642
2331
|
*/
|
|
1643
2332
|
async listDestinations(requestConfig) {
|
|
1644
2333
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/destinations").setRequestSchema(import_zod10.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -1672,6 +2361,7 @@ var packages = import_zod11.z.lazy(() => {
|
|
|
1672
2361
|
destination: import_zod11.z.string(),
|
|
1673
2362
|
destinationIso2: import_zod11.z.string(),
|
|
1674
2363
|
dataLimitInBytes: import_zod11.z.number(),
|
|
2364
|
+
dataLimitInGb: import_zod11.z.number(),
|
|
1675
2365
|
minDays: import_zod11.z.number(),
|
|
1676
2366
|
maxDays: import_zod11.z.number(),
|
|
1677
2367
|
priceInCents: import_zod11.z.number()
|
|
@@ -1683,6 +2373,7 @@ var packagesResponse = import_zod11.z.lazy(() => {
|
|
|
1683
2373
|
destination: import_zod11.z.string(),
|
|
1684
2374
|
destinationISO2: import_zod11.z.string(),
|
|
1685
2375
|
dataLimitInBytes: import_zod11.z.number(),
|
|
2376
|
+
dataLimitInGB: import_zod11.z.number(),
|
|
1686
2377
|
minDays: import_zod11.z.number(),
|
|
1687
2378
|
maxDays: import_zod11.z.number(),
|
|
1688
2379
|
priceInCents: import_zod11.z.number()
|
|
@@ -1691,6 +2382,7 @@ var packagesResponse = import_zod11.z.lazy(() => {
|
|
|
1691
2382
|
destination: data["destination"],
|
|
1692
2383
|
destinationIso2: data["destinationISO2"],
|
|
1693
2384
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2385
|
+
dataLimitInGb: data["dataLimitInGB"],
|
|
1694
2386
|
minDays: data["minDays"],
|
|
1695
2387
|
maxDays: data["maxDays"],
|
|
1696
2388
|
priceInCents: data["priceInCents"]
|
|
@@ -1702,6 +2394,7 @@ var packagesRequest = import_zod11.z.lazy(() => {
|
|
|
1702
2394
|
destination: import_zod11.z.string(),
|
|
1703
2395
|
destinationIso2: import_zod11.z.string(),
|
|
1704
2396
|
dataLimitInBytes: import_zod11.z.number(),
|
|
2397
|
+
dataLimitInGb: import_zod11.z.number(),
|
|
1705
2398
|
minDays: import_zod11.z.number(),
|
|
1706
2399
|
maxDays: import_zod11.z.number(),
|
|
1707
2400
|
priceInCents: import_zod11.z.number()
|
|
@@ -1710,6 +2403,7 @@ var packagesRequest = import_zod11.z.lazy(() => {
|
|
|
1710
2403
|
destination: data["destination"],
|
|
1711
2404
|
destinationISO2: data["destinationIso2"],
|
|
1712
2405
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2406
|
+
dataLimitInGB: data["dataLimitInGb"],
|
|
1713
2407
|
minDays: data["minDays"],
|
|
1714
2408
|
maxDays: data["maxDays"],
|
|
1715
2409
|
priceInCents: data["priceInCents"]
|
|
@@ -1753,9 +2447,8 @@ var PackagesService = class extends BaseService {
|
|
|
1753
2447
|
* @param {number} [params.limit] - Maximum number of packages to be returned in the response. The value must be greater than 0 and less than or equal to 160. If not provided, the default value is 20
|
|
1754
2448
|
* @param {number} [params.startTime] - Epoch value representing the start time of the package's validity. This timestamp can be set to the current time or any time within the next 12 months
|
|
1755
2449
|
* @param {number} [params.endTime] - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time
|
|
1756
|
-
* @param {
|
|
1757
|
-
* @
|
|
1758
|
-
* @returns {Promise<HttpResponse<ListPackagesOkResponse>>} Successful Response
|
|
2450
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
2451
|
+
* @returns {Promise<HttpResponse<ListPackagesOkResponse>>} - Successful Response
|
|
1759
2452
|
*/
|
|
1760
2453
|
async listPackages(params, requestConfig) {
|
|
1761
2454
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/packages").setRequestSchema(import_zod13.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -1791,9 +2484,6 @@ var PackagesService = class extends BaseService {
|
|
|
1791
2484
|
}).addQueryParam({
|
|
1792
2485
|
key: "endTime",
|
|
1793
2486
|
value: params == null ? void 0 : params.endTime
|
|
1794
|
-
}).addQueryParam({
|
|
1795
|
-
key: "duration",
|
|
1796
|
-
value: params == null ? void 0 : params.duration
|
|
1797
2487
|
}).build();
|
|
1798
2488
|
return this.client.call(request);
|
|
1799
2489
|
}
|
|
@@ -1808,8 +2498,9 @@ var createPurchaseV2Request = import_zod14.z.lazy(() => {
|
|
|
1808
2498
|
return import_zod14.z.object({
|
|
1809
2499
|
destination: import_zod14.z.string(),
|
|
1810
2500
|
dataLimitInGb: import_zod14.z.number(),
|
|
1811
|
-
startDate: import_zod14.z.string(),
|
|
1812
|
-
endDate: import_zod14.z.string(),
|
|
2501
|
+
startDate: import_zod14.z.string().optional(),
|
|
2502
|
+
endDate: import_zod14.z.string().optional(),
|
|
2503
|
+
duration: import_zod14.z.number().optional(),
|
|
1813
2504
|
quantity: import_zod14.z.number().gte(1).lte(5),
|
|
1814
2505
|
email: import_zod14.z.string().optional(),
|
|
1815
2506
|
referenceId: import_zod14.z.string().optional(),
|
|
@@ -1821,8 +2512,9 @@ var createPurchaseV2RequestResponse = import_zod14.z.lazy(() => {
|
|
|
1821
2512
|
return import_zod14.z.object({
|
|
1822
2513
|
destination: import_zod14.z.string(),
|
|
1823
2514
|
dataLimitInGB: import_zod14.z.number(),
|
|
1824
|
-
startDate: import_zod14.z.string(),
|
|
1825
|
-
endDate: import_zod14.z.string(),
|
|
2515
|
+
startDate: import_zod14.z.string().optional(),
|
|
2516
|
+
endDate: import_zod14.z.string().optional(),
|
|
2517
|
+
duration: import_zod14.z.number().optional(),
|
|
1826
2518
|
quantity: import_zod14.z.number().gte(1).lte(5),
|
|
1827
2519
|
email: import_zod14.z.string().optional(),
|
|
1828
2520
|
referenceId: import_zod14.z.string().optional(),
|
|
@@ -1833,6 +2525,7 @@ var createPurchaseV2RequestResponse = import_zod14.z.lazy(() => {
|
|
|
1833
2525
|
dataLimitInGb: data["dataLimitInGB"],
|
|
1834
2526
|
startDate: data["startDate"],
|
|
1835
2527
|
endDate: data["endDate"],
|
|
2528
|
+
duration: data["duration"],
|
|
1836
2529
|
quantity: data["quantity"],
|
|
1837
2530
|
email: data["email"],
|
|
1838
2531
|
referenceId: data["referenceId"],
|
|
@@ -1844,8 +2537,9 @@ var createPurchaseV2RequestRequest = import_zod14.z.lazy(() => {
|
|
|
1844
2537
|
return import_zod14.z.object({
|
|
1845
2538
|
destination: import_zod14.z.string(),
|
|
1846
2539
|
dataLimitInGb: import_zod14.z.number(),
|
|
1847
|
-
startDate: import_zod14.z.string(),
|
|
1848
|
-
endDate: import_zod14.z.string(),
|
|
2540
|
+
startDate: import_zod14.z.string().optional(),
|
|
2541
|
+
endDate: import_zod14.z.string().optional(),
|
|
2542
|
+
duration: import_zod14.z.number().optional(),
|
|
1849
2543
|
quantity: import_zod14.z.number().gte(1).lte(5),
|
|
1850
2544
|
email: import_zod14.z.string().optional(),
|
|
1851
2545
|
referenceId: import_zod14.z.string().optional(),
|
|
@@ -1856,6 +2550,7 @@ var createPurchaseV2RequestRequest = import_zod14.z.lazy(() => {
|
|
|
1856
2550
|
dataLimitInGB: data["dataLimitInGb"],
|
|
1857
2551
|
startDate: data["startDate"],
|
|
1858
2552
|
endDate: data["endDate"],
|
|
2553
|
+
duration: data["duration"],
|
|
1859
2554
|
quantity: data["quantity"],
|
|
1860
2555
|
email: data["email"],
|
|
1861
2556
|
referenceId: data["referenceId"],
|
|
@@ -1905,29 +2600,39 @@ var createPurchaseV2OkResponseProfile = import_zod16.z.lazy(() => {
|
|
|
1905
2600
|
return import_zod16.z.object({
|
|
1906
2601
|
iccid: import_zod16.z.string().min(18).max(22),
|
|
1907
2602
|
activationCode: import_zod16.z.string().min(1e3).max(8e3),
|
|
1908
|
-
manualActivationCode: import_zod16.z.string()
|
|
2603
|
+
manualActivationCode: import_zod16.z.string(),
|
|
2604
|
+
iosActivationLink: import_zod16.z.string(),
|
|
2605
|
+
androidActivationLink: import_zod16.z.string()
|
|
1909
2606
|
});
|
|
1910
2607
|
});
|
|
1911
2608
|
var createPurchaseV2OkResponseProfileResponse = import_zod16.z.lazy(() => {
|
|
1912
2609
|
return import_zod16.z.object({
|
|
1913
2610
|
iccid: import_zod16.z.string().min(18).max(22),
|
|
1914
2611
|
activationCode: import_zod16.z.string().min(1e3).max(8e3),
|
|
1915
|
-
manualActivationCode: import_zod16.z.string()
|
|
2612
|
+
manualActivationCode: import_zod16.z.string(),
|
|
2613
|
+
iosActivationLink: import_zod16.z.string(),
|
|
2614
|
+
androidActivationLink: import_zod16.z.string()
|
|
1916
2615
|
}).transform((data) => ({
|
|
1917
2616
|
iccid: data["iccid"],
|
|
1918
2617
|
activationCode: data["activationCode"],
|
|
1919
|
-
manualActivationCode: data["manualActivationCode"]
|
|
2618
|
+
manualActivationCode: data["manualActivationCode"],
|
|
2619
|
+
iosActivationLink: data["iosActivationLink"],
|
|
2620
|
+
androidActivationLink: data["androidActivationLink"]
|
|
1920
2621
|
}));
|
|
1921
2622
|
});
|
|
1922
2623
|
var createPurchaseV2OkResponseProfileRequest = import_zod16.z.lazy(() => {
|
|
1923
2624
|
return import_zod16.z.object({
|
|
1924
2625
|
iccid: import_zod16.z.string().min(18).max(22),
|
|
1925
2626
|
activationCode: import_zod16.z.string().min(1e3).max(8e3),
|
|
1926
|
-
manualActivationCode: import_zod16.z.string()
|
|
2627
|
+
manualActivationCode: import_zod16.z.string(),
|
|
2628
|
+
iosActivationLink: import_zod16.z.string(),
|
|
2629
|
+
androidActivationLink: import_zod16.z.string()
|
|
1927
2630
|
}).transform((data) => ({
|
|
1928
2631
|
iccid: data["iccid"],
|
|
1929
2632
|
activationCode: data["activationCode"],
|
|
1930
|
-
manualActivationCode: data["manualActivationCode"]
|
|
2633
|
+
manualActivationCode: data["manualActivationCode"],
|
|
2634
|
+
iosActivationLink: data["iosActivationLink"],
|
|
2635
|
+
androidActivationLink: data["androidActivationLink"]
|
|
1931
2636
|
}));
|
|
1932
2637
|
});
|
|
1933
2638
|
|
|
@@ -1969,6 +2674,7 @@ var package_ = import_zod18.z.lazy(() => {
|
|
|
1969
2674
|
return import_zod18.z.object({
|
|
1970
2675
|
id: import_zod18.z.string(),
|
|
1971
2676
|
dataLimitInBytes: import_zod18.z.number(),
|
|
2677
|
+
dataLimitInGb: import_zod18.z.number(),
|
|
1972
2678
|
destination: import_zod18.z.string(),
|
|
1973
2679
|
destinationIso2: import_zod18.z.string(),
|
|
1974
2680
|
destinationName: import_zod18.z.string(),
|
|
@@ -1979,6 +2685,7 @@ var packageResponse = import_zod18.z.lazy(() => {
|
|
|
1979
2685
|
return import_zod18.z.object({
|
|
1980
2686
|
id: import_zod18.z.string(),
|
|
1981
2687
|
dataLimitInBytes: import_zod18.z.number(),
|
|
2688
|
+
dataLimitInGB: import_zod18.z.number(),
|
|
1982
2689
|
destination: import_zod18.z.string(),
|
|
1983
2690
|
destinationISO2: import_zod18.z.string(),
|
|
1984
2691
|
destinationName: import_zod18.z.string(),
|
|
@@ -1986,6 +2693,7 @@ var packageResponse = import_zod18.z.lazy(() => {
|
|
|
1986
2693
|
}).transform((data) => ({
|
|
1987
2694
|
id: data["id"],
|
|
1988
2695
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2696
|
+
dataLimitInGb: data["dataLimitInGB"],
|
|
1989
2697
|
destination: data["destination"],
|
|
1990
2698
|
destinationIso2: data["destinationISO2"],
|
|
1991
2699
|
destinationName: data["destinationName"],
|
|
@@ -1996,6 +2704,7 @@ var packageRequest = import_zod18.z.lazy(() => {
|
|
|
1996
2704
|
return import_zod18.z.object({
|
|
1997
2705
|
id: import_zod18.z.string(),
|
|
1998
2706
|
dataLimitInBytes: import_zod18.z.number(),
|
|
2707
|
+
dataLimitInGb: import_zod18.z.number(),
|
|
1999
2708
|
destination: import_zod18.z.string(),
|
|
2000
2709
|
destinationIso2: import_zod18.z.string(),
|
|
2001
2710
|
destinationName: import_zod18.z.string(),
|
|
@@ -2003,6 +2712,7 @@ var packageRequest = import_zod18.z.lazy(() => {
|
|
|
2003
2712
|
}).transform((data) => ({
|
|
2004
2713
|
id: data["id"],
|
|
2005
2714
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2715
|
+
dataLimitInGB: data["dataLimitInGb"],
|
|
2006
2716
|
destination: data["destination"],
|
|
2007
2717
|
destinationISO2: data["destinationIso2"],
|
|
2008
2718
|
destinationName: data["destinationName"],
|
|
@@ -2038,6 +2748,7 @@ var purchases = import_zod20.z.lazy(() => {
|
|
|
2038
2748
|
id: import_zod20.z.string(),
|
|
2039
2749
|
startDate: import_zod20.z.string().nullable(),
|
|
2040
2750
|
endDate: import_zod20.z.string().nullable(),
|
|
2751
|
+
duration: import_zod20.z.number().optional().nullable(),
|
|
2041
2752
|
createdDate: import_zod20.z.string(),
|
|
2042
2753
|
startTime: import_zod20.z.number().optional().nullable(),
|
|
2043
2754
|
endTime: import_zod20.z.number().optional().nullable(),
|
|
@@ -2054,6 +2765,7 @@ var purchasesResponse = import_zod20.z.lazy(() => {
|
|
|
2054
2765
|
id: import_zod20.z.string(),
|
|
2055
2766
|
startDate: import_zod20.z.string().nullable(),
|
|
2056
2767
|
endDate: import_zod20.z.string().nullable(),
|
|
2768
|
+
duration: import_zod20.z.number().optional().nullable(),
|
|
2057
2769
|
createdDate: import_zod20.z.string(),
|
|
2058
2770
|
startTime: import_zod20.z.number().optional().nullable(),
|
|
2059
2771
|
endTime: import_zod20.z.number().optional().nullable(),
|
|
@@ -2067,6 +2779,7 @@ var purchasesResponse = import_zod20.z.lazy(() => {
|
|
|
2067
2779
|
id: data["id"],
|
|
2068
2780
|
startDate: data["startDate"],
|
|
2069
2781
|
endDate: data["endDate"],
|
|
2782
|
+
duration: data["duration"],
|
|
2070
2783
|
createdDate: data["createdDate"],
|
|
2071
2784
|
startTime: data["startTime"],
|
|
2072
2785
|
endTime: data["endTime"],
|
|
@@ -2083,6 +2796,7 @@ var purchasesRequest = import_zod20.z.lazy(() => {
|
|
|
2083
2796
|
id: import_zod20.z.string(),
|
|
2084
2797
|
startDate: import_zod20.z.string().nullable(),
|
|
2085
2798
|
endDate: import_zod20.z.string().nullable(),
|
|
2799
|
+
duration: import_zod20.z.number().optional().nullable(),
|
|
2086
2800
|
createdDate: import_zod20.z.string(),
|
|
2087
2801
|
startTime: import_zod20.z.number().optional().nullable(),
|
|
2088
2802
|
endTime: import_zod20.z.number().optional().nullable(),
|
|
@@ -2096,6 +2810,7 @@ var purchasesRequest = import_zod20.z.lazy(() => {
|
|
|
2096
2810
|
id: data["id"],
|
|
2097
2811
|
startDate: data["startDate"],
|
|
2098
2812
|
endDate: data["endDate"],
|
|
2813
|
+
duration: data["duration"],
|
|
2099
2814
|
createdDate: data["createdDate"],
|
|
2100
2815
|
startTime: data["startTime"],
|
|
2101
2816
|
endTime: data["endTime"],
|
|
@@ -2320,8 +3035,9 @@ var topUpEsimRequest = import_zod26.z.lazy(() => {
|
|
|
2320
3035
|
return import_zod26.z.object({
|
|
2321
3036
|
iccid: import_zod26.z.string().min(18).max(22),
|
|
2322
3037
|
dataLimitInGb: import_zod26.z.number(),
|
|
2323
|
-
startDate: import_zod26.z.string(),
|
|
2324
|
-
endDate: import_zod26.z.string(),
|
|
3038
|
+
startDate: import_zod26.z.string().optional(),
|
|
3039
|
+
endDate: import_zod26.z.string().optional(),
|
|
3040
|
+
duration: import_zod26.z.number().optional(),
|
|
2325
3041
|
email: import_zod26.z.string().optional(),
|
|
2326
3042
|
referenceId: import_zod26.z.string().optional(),
|
|
2327
3043
|
emailBrand: import_zod26.z.string().optional(),
|
|
@@ -2333,8 +3049,9 @@ var topUpEsimRequestResponse = import_zod26.z.lazy(() => {
|
|
|
2333
3049
|
return import_zod26.z.object({
|
|
2334
3050
|
iccid: import_zod26.z.string().min(18).max(22),
|
|
2335
3051
|
dataLimitInGB: import_zod26.z.number(),
|
|
2336
|
-
startDate: import_zod26.z.string(),
|
|
2337
|
-
endDate: import_zod26.z.string(),
|
|
3052
|
+
startDate: import_zod26.z.string().optional(),
|
|
3053
|
+
endDate: import_zod26.z.string().optional(),
|
|
3054
|
+
duration: import_zod26.z.number().optional(),
|
|
2338
3055
|
email: import_zod26.z.string().optional(),
|
|
2339
3056
|
referenceId: import_zod26.z.string().optional(),
|
|
2340
3057
|
emailBrand: import_zod26.z.string().optional(),
|
|
@@ -2345,6 +3062,7 @@ var topUpEsimRequestResponse = import_zod26.z.lazy(() => {
|
|
|
2345
3062
|
dataLimitInGb: data["dataLimitInGB"],
|
|
2346
3063
|
startDate: data["startDate"],
|
|
2347
3064
|
endDate: data["endDate"],
|
|
3065
|
+
duration: data["duration"],
|
|
2348
3066
|
email: data["email"],
|
|
2349
3067
|
referenceId: data["referenceId"],
|
|
2350
3068
|
emailBrand: data["emailBrand"],
|
|
@@ -2356,8 +3074,9 @@ var topUpEsimRequestRequest = import_zod26.z.lazy(() => {
|
|
|
2356
3074
|
return import_zod26.z.object({
|
|
2357
3075
|
iccid: import_zod26.z.string().min(18).max(22),
|
|
2358
3076
|
dataLimitInGb: import_zod26.z.number(),
|
|
2359
|
-
startDate: import_zod26.z.string(),
|
|
2360
|
-
endDate: import_zod26.z.string(),
|
|
3077
|
+
startDate: import_zod26.z.string().optional(),
|
|
3078
|
+
endDate: import_zod26.z.string().optional(),
|
|
3079
|
+
duration: import_zod26.z.number().optional(),
|
|
2361
3080
|
email: import_zod26.z.string().optional(),
|
|
2362
3081
|
referenceId: import_zod26.z.string().optional(),
|
|
2363
3082
|
emailBrand: import_zod26.z.string().optional(),
|
|
@@ -2368,6 +3087,7 @@ var topUpEsimRequestRequest = import_zod26.z.lazy(() => {
|
|
|
2368
3087
|
dataLimitInGB: data["dataLimitInGb"],
|
|
2369
3088
|
startDate: data["startDate"],
|
|
2370
3089
|
endDate: data["endDate"],
|
|
3090
|
+
duration: data["duration"],
|
|
2371
3091
|
email: data["email"],
|
|
2372
3092
|
referenceId: data["referenceId"],
|
|
2373
3093
|
emailBrand: data["emailBrand"],
|
|
@@ -2568,24 +3288,29 @@ var import_zod32 = require("zod");
|
|
|
2568
3288
|
var getPurchaseConsumptionOkResponse = import_zod32.z.lazy(() => {
|
|
2569
3289
|
return import_zod32.z.object({
|
|
2570
3290
|
dataUsageRemainingInBytes: import_zod32.z.number(),
|
|
3291
|
+
dataUsageRemainingInGb: import_zod32.z.number(),
|
|
2571
3292
|
status: import_zod32.z.string()
|
|
2572
3293
|
});
|
|
2573
3294
|
});
|
|
2574
3295
|
var getPurchaseConsumptionOkResponseResponse = import_zod32.z.lazy(() => {
|
|
2575
3296
|
return import_zod32.z.object({
|
|
2576
3297
|
dataUsageRemainingInBytes: import_zod32.z.number(),
|
|
3298
|
+
dataUsageRemainingInGB: import_zod32.z.number(),
|
|
2577
3299
|
status: import_zod32.z.string()
|
|
2578
3300
|
}).transform((data) => ({
|
|
2579
3301
|
dataUsageRemainingInBytes: data["dataUsageRemainingInBytes"],
|
|
3302
|
+
dataUsageRemainingInGb: data["dataUsageRemainingInGB"],
|
|
2580
3303
|
status: data["status"]
|
|
2581
3304
|
}));
|
|
2582
3305
|
});
|
|
2583
3306
|
var getPurchaseConsumptionOkResponseRequest = import_zod32.z.lazy(() => {
|
|
2584
3307
|
return import_zod32.z.object({
|
|
2585
3308
|
dataUsageRemainingInBytes: import_zod32.z.number(),
|
|
3309
|
+
dataUsageRemainingInGb: import_zod32.z.number(),
|
|
2586
3310
|
status: import_zod32.z.string()
|
|
2587
3311
|
}).transform((data) => ({
|
|
2588
3312
|
dataUsageRemainingInBytes: data["dataUsageRemainingInBytes"],
|
|
3313
|
+
dataUsageRemainingInGB: data["dataUsageRemainingInGb"],
|
|
2589
3314
|
status: data["status"]
|
|
2590
3315
|
}));
|
|
2591
3316
|
});
|
|
@@ -2594,8 +3319,8 @@ var getPurchaseConsumptionOkResponseRequest = import_zod32.z.lazy(() => {
|
|
|
2594
3319
|
var PurchasesService = class extends BaseService {
|
|
2595
3320
|
/**
|
|
2596
3321
|
* This endpoint is used to purchase a new eSIM by providing the package details.
|
|
2597
|
-
* @param {RequestConfig} requestConfig -
|
|
2598
|
-
* @returns {Promise<HttpResponse<CreatePurchaseV2OkResponse[]>>} Successful Response
|
|
3322
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3323
|
+
* @returns {Promise<HttpResponse<CreatePurchaseV2OkResponse[]>>} - Successful Response
|
|
2599
3324
|
*/
|
|
2600
3325
|
async createPurchaseV2(body, requestConfig) {
|
|
2601
3326
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases/v2").setRequestSchema(createPurchaseV2RequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -2615,6 +3340,7 @@ var PurchasesService = class extends BaseService {
|
|
|
2615
3340
|
}
|
|
2616
3341
|
/**
|
|
2617
3342
|
* This endpoint can be used to list all the successful purchases made between a given interval.
|
|
3343
|
+
* @param {string} [params.purchaseId] - ID of the purchase
|
|
2618
3344
|
* @param {string} [params.iccid] - ID of the eSIM
|
|
2619
3345
|
* @param {string} [params.afterDate] - Start date of the interval for filtering purchases in the format 'yyyy-MM-dd'
|
|
2620
3346
|
* @param {string} [params.beforeDate] - End date of the interval for filtering purchases in the format 'yyyy-MM-dd'
|
|
@@ -2624,9 +3350,8 @@ var PurchasesService = class extends BaseService {
|
|
|
2624
3350
|
* @param {number} [params.limit] - Maximum number of purchases to be returned in the response. The value must be greater than 0 and less than or equal to 100. If not provided, the default value is 20
|
|
2625
3351
|
* @param {number} [params.after] - Epoch value representing the start of the time interval for filtering purchases
|
|
2626
3352
|
* @param {number} [params.before] - Epoch value representing the end of the time interval for filtering purchases
|
|
2627
|
-
* @param {
|
|
2628
|
-
* @
|
|
2629
|
-
* @returns {Promise<HttpResponse<ListPurchasesOkResponse>>} Successful Response
|
|
3353
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3354
|
+
* @returns {Promise<HttpResponse<ListPurchasesOkResponse>>} - Successful Response
|
|
2630
3355
|
*/
|
|
2631
3356
|
async listPurchases(params, requestConfig) {
|
|
2632
3357
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/purchases").setRequestSchema(import_zod33.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -2642,6 +3367,9 @@ var PurchasesService = class extends BaseService {
|
|
|
2642
3367
|
contentType: "json" /* Json */,
|
|
2643
3368
|
status: 401
|
|
2644
3369
|
}).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
|
|
3370
|
+
key: "purchaseId",
|
|
3371
|
+
value: params == null ? void 0 : params.purchaseId
|
|
3372
|
+
}).addQueryParam({
|
|
2645
3373
|
key: "iccid",
|
|
2646
3374
|
value: params == null ? void 0 : params.iccid
|
|
2647
3375
|
}).addQueryParam({
|
|
@@ -2668,16 +3396,13 @@ var PurchasesService = class extends BaseService {
|
|
|
2668
3396
|
}).addQueryParam({
|
|
2669
3397
|
key: "before",
|
|
2670
3398
|
value: params == null ? void 0 : params.before
|
|
2671
|
-
}).addQueryParam({
|
|
2672
|
-
key: "purchaseId",
|
|
2673
|
-
value: params == null ? void 0 : params.purchaseId
|
|
2674
3399
|
}).build();
|
|
2675
3400
|
return this.client.call(request);
|
|
2676
3401
|
}
|
|
2677
3402
|
/**
|
|
2678
3403
|
* This endpoint is used to purchase a new eSIM by providing the package details.
|
|
2679
|
-
* @param {RequestConfig} requestConfig -
|
|
2680
|
-
* @returns {Promise<HttpResponse<CreatePurchaseOkResponse>>} Successful Response
|
|
3404
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3405
|
+
* @returns {Promise<HttpResponse<CreatePurchaseOkResponse>>} - Successful Response
|
|
2681
3406
|
*/
|
|
2682
3407
|
async createPurchase(body, requestConfig) {
|
|
2683
3408
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases").setRequestSchema(createPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -2696,9 +3421,9 @@ var PurchasesService = class extends BaseService {
|
|
|
2696
3421
|
return this.client.call(request);
|
|
2697
3422
|
}
|
|
2698
3423
|
/**
|
|
2699
|
-
* This endpoint is used to top-up an existing eSIM with the previously associated destination by providing its ICCID and package details. To determine if an eSIM can be topped up, use the Get eSIM
|
|
2700
|
-
* @param {RequestConfig} requestConfig -
|
|
2701
|
-
* @returns {Promise<HttpResponse<TopUpEsimOkResponse>>} Successful Response
|
|
3424
|
+
* This endpoint is used to top-up an existing eSIM with the previously associated destination by providing its ICCID and package details. To determine if an eSIM can be topped up, use the Get eSIM endpoint, which returns the `isTopUpAllowed` flag.
|
|
3425
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3426
|
+
* @returns {Promise<HttpResponse<TopUpEsimOkResponse>>} - Successful Response
|
|
2702
3427
|
*/
|
|
2703
3428
|
async topUpEsim(body, requestConfig) {
|
|
2704
3429
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases/topup").setRequestSchema(topUpEsimRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -2725,8 +3450,8 @@ var PurchasesService = class extends BaseService {
|
|
|
2725
3450
|
|
|
2726
3451
|
The end date can be extended or shortened as long as it adheres to the same pricing category and does not exceed the allowed duration limits.
|
|
2727
3452
|
|
|
2728
|
-
* @param {RequestConfig} requestConfig -
|
|
2729
|
-
* @returns {Promise<HttpResponse<EditPurchaseOkResponse>>} Successful Response
|
|
3453
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3454
|
+
* @returns {Promise<HttpResponse<EditPurchaseOkResponse>>} - Successful Response
|
|
2730
3455
|
*/
|
|
2731
3456
|
async editPurchase(body, requestConfig) {
|
|
2732
3457
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases/edit").setRequestSchema(editPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -2747,8 +3472,8 @@ var PurchasesService = class extends BaseService {
|
|
|
2747
3472
|
/**
|
|
2748
3473
|
* This endpoint can be called for consumption notifications (e.g. every 1 hour or when the user clicks a button). It returns the data balance (consumption) of purchased packages.
|
|
2749
3474
|
* @param {string} purchaseId - ID of the purchase
|
|
2750
|
-
* @param {RequestConfig} requestConfig -
|
|
2751
|
-
* @returns {Promise<HttpResponse<GetPurchaseConsumptionOkResponse>>} Successful Response
|
|
3475
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3476
|
+
* @returns {Promise<HttpResponse<GetPurchaseConsumptionOkResponse>>} - Successful Response
|
|
2752
3477
|
*/
|
|
2753
3478
|
async getPurchaseConsumption(purchaseId, requestConfig) {
|
|
2754
3479
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/purchases/{purchaseId}/consumption").setRequestSchema(import_zod33.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -2786,6 +3511,7 @@ var getEsimOkResponseEsim = import_zod34.z.lazy(() => {
|
|
|
2786
3511
|
activationCode: import_zod34.z.string().min(1e3).max(8e3),
|
|
2787
3512
|
manualActivationCode: import_zod34.z.string(),
|
|
2788
3513
|
status: import_zod34.z.string(),
|
|
3514
|
+
connectivityStatus: import_zod34.z.string(),
|
|
2789
3515
|
isTopUpAllowed: import_zod34.z.boolean()
|
|
2790
3516
|
});
|
|
2791
3517
|
});
|
|
@@ -2796,6 +3522,7 @@ var getEsimOkResponseEsimResponse = import_zod34.z.lazy(() => {
|
|
|
2796
3522
|
activationCode: import_zod34.z.string().min(1e3).max(8e3),
|
|
2797
3523
|
manualActivationCode: import_zod34.z.string(),
|
|
2798
3524
|
status: import_zod34.z.string(),
|
|
3525
|
+
connectivityStatus: import_zod34.z.string(),
|
|
2799
3526
|
isTopUpAllowed: import_zod34.z.boolean()
|
|
2800
3527
|
}).transform((data) => ({
|
|
2801
3528
|
iccid: data["iccid"],
|
|
@@ -2803,6 +3530,7 @@ var getEsimOkResponseEsimResponse = import_zod34.z.lazy(() => {
|
|
|
2803
3530
|
activationCode: data["activationCode"],
|
|
2804
3531
|
manualActivationCode: data["manualActivationCode"],
|
|
2805
3532
|
status: data["status"],
|
|
3533
|
+
connectivityStatus: data["connectivityStatus"],
|
|
2806
3534
|
isTopUpAllowed: data["isTopUpAllowed"]
|
|
2807
3535
|
}));
|
|
2808
3536
|
});
|
|
@@ -2813,6 +3541,7 @@ var getEsimOkResponseEsimRequest = import_zod34.z.lazy(() => {
|
|
|
2813
3541
|
activationCode: import_zod34.z.string().min(1e3).max(8e3),
|
|
2814
3542
|
manualActivationCode: import_zod34.z.string(),
|
|
2815
3543
|
status: import_zod34.z.string(),
|
|
3544
|
+
connectivityStatus: import_zod34.z.string(),
|
|
2816
3545
|
isTopUpAllowed: import_zod34.z.boolean()
|
|
2817
3546
|
}).transform((data) => ({
|
|
2818
3547
|
iccid: data["iccid"],
|
|
@@ -2820,6 +3549,7 @@ var getEsimOkResponseEsimRequest = import_zod34.z.lazy(() => {
|
|
|
2820
3549
|
activationCode: data["activationCode"],
|
|
2821
3550
|
manualActivationCode: data["manualActivationCode"],
|
|
2822
3551
|
status: data["status"],
|
|
3552
|
+
connectivityStatus: data["connectivityStatus"],
|
|
2823
3553
|
isTopUpAllowed: data["isTopUpAllowed"]
|
|
2824
3554
|
}));
|
|
2825
3555
|
});
|
|
@@ -2995,9 +3725,9 @@ var getEsimHistoryOkResponseRequest = import_zod40.z.lazy(() => {
|
|
|
2995
3725
|
var ESimService = class extends BaseService {
|
|
2996
3726
|
/**
|
|
2997
3727
|
* Get eSIM
|
|
2998
|
-
* @param {string} iccid - ID of the eSIM
|
|
2999
|
-
* @param {RequestConfig} requestConfig -
|
|
3000
|
-
* @returns {Promise<HttpResponse<GetEsimOkResponse>>} Successful Response
|
|
3728
|
+
* @param {string} params.iccid - ID of the eSIM
|
|
3729
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3730
|
+
* @returns {Promise<HttpResponse<GetEsimOkResponse>>} - Successful Response
|
|
3001
3731
|
*/
|
|
3002
3732
|
async getEsim(params, requestConfig) {
|
|
3003
3733
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/esim").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -3021,8 +3751,8 @@ var ESimService = class extends BaseService {
|
|
|
3021
3751
|
/**
|
|
3022
3752
|
* Get eSIM Device
|
|
3023
3753
|
* @param {string} iccid - ID of the eSIM
|
|
3024
|
-
* @param {RequestConfig} requestConfig -
|
|
3025
|
-
* @returns {Promise<HttpResponse<GetEsimDeviceOkResponse>>} Successful Response
|
|
3754
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3755
|
+
* @returns {Promise<HttpResponse<GetEsimDeviceOkResponse>>} - Successful Response
|
|
3026
3756
|
*/
|
|
3027
3757
|
async getEsimDevice(iccid, requestConfig) {
|
|
3028
3758
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/esim/{iccid}/device").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -3046,8 +3776,8 @@ var ESimService = class extends BaseService {
|
|
|
3046
3776
|
/**
|
|
3047
3777
|
* Get eSIM History
|
|
3048
3778
|
* @param {string} iccid - ID of the eSIM
|
|
3049
|
-
* @param {RequestConfig} requestConfig -
|
|
3050
|
-
* @returns {Promise<HttpResponse<GetEsimHistoryOkResponse>>} Successful Response
|
|
3779
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3780
|
+
* @returns {Promise<HttpResponse<GetEsimHistoryOkResponse>>} - Successful Response
|
|
3051
3781
|
*/
|
|
3052
3782
|
async getEsimHistory(iccid, requestConfig) {
|
|
3053
3783
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/esim/{iccid}/history").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
@@ -3099,8 +3829,8 @@ var tokenOkResponseRequest = import_zod42.z.lazy(() => {
|
|
|
3099
3829
|
var IFrameService = class extends BaseService {
|
|
3100
3830
|
/**
|
|
3101
3831
|
* Generate a new token to be used in the iFrame
|
|
3102
|
-
* @param {RequestConfig} requestConfig -
|
|
3103
|
-
* @returns {Promise<HttpResponse<TokenOkResponse>>} Successful Response
|
|
3832
|
+
* @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
|
|
3833
|
+
* @returns {Promise<HttpResponse<TokenOkResponse>>} - Successful Response
|
|
3104
3834
|
*/
|
|
3105
3835
|
async token(requestConfig) {
|
|
3106
3836
|
const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/iframe/token").setRequestSchema(import_zod43.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|