celitech-sdk 1.3.61 → 1.3.64
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 +602 -41
- package/dist/index.js +695 -19
- package/dist/index.mjs +693 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,6 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
Celitech: () => Celitech,
|
|
34
|
+
CreatePurchaseRequestLanguage: () => CreatePurchaseRequestLanguage,
|
|
35
|
+
CreatePurchaseV2RequestLanguage: () => CreatePurchaseV2RequestLanguage,
|
|
34
36
|
DestinationsService: () => DestinationsService,
|
|
35
37
|
ESimService: () => ESimService,
|
|
36
38
|
Environment: () => Environment,
|
|
@@ -45,8 +47,14 @@ module.exports = __toCommonJS(src_exports);
|
|
|
45
47
|
// src/http/handlers/handler-chain.ts
|
|
46
48
|
var RequestHandlerChain = class {
|
|
47
49
|
constructor() {
|
|
50
|
+
/** Array of handlers in the chain */
|
|
48
51
|
this.handlers = [];
|
|
49
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Adds a handler to the end of the chain.
|
|
55
|
+
* Links the new handler to the previous one in the chain.
|
|
56
|
+
* @param handler - The request handler to add
|
|
57
|
+
*/
|
|
50
58
|
addHandler(handler) {
|
|
51
59
|
if (this.handlers.length > 0) {
|
|
52
60
|
const previousHandler = this.handlers[this.handlers.length - 1];
|
|
@@ -54,12 +62,26 @@ var RequestHandlerChain = class {
|
|
|
54
62
|
}
|
|
55
63
|
this.handlers.push(handler);
|
|
56
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Executes the handler chain for a standard request.
|
|
67
|
+
* @template T - The expected response data type
|
|
68
|
+
* @param request - The HTTP request to process
|
|
69
|
+
* @returns A promise that resolves to the HTTP response
|
|
70
|
+
* @throws Error if no handlers are added to the chain
|
|
71
|
+
*/
|
|
57
72
|
async callChain(request) {
|
|
58
73
|
if (!this.handlers.length) {
|
|
59
74
|
throw new Error("No handlers added to the chain");
|
|
60
75
|
}
|
|
61
76
|
return this.handlers[0].handle(request);
|
|
62
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Executes the handler chain for a streaming request.
|
|
80
|
+
* @template T - The expected response data type for each chunk
|
|
81
|
+
* @param request - The HTTP request to process
|
|
82
|
+
* @returns An async generator that yields HTTP responses
|
|
83
|
+
* @throws Error if no handlers are added to the chain
|
|
84
|
+
*/
|
|
63
85
|
async *streamChain(request) {
|
|
64
86
|
if (!this.handlers.length) {
|
|
65
87
|
throw new Error("No handlers added to the chain");
|
|
@@ -70,6 +92,12 @@ var RequestHandlerChain = class {
|
|
|
70
92
|
|
|
71
93
|
// src/http/error.ts
|
|
72
94
|
var HttpError = class extends Error {
|
|
95
|
+
/**
|
|
96
|
+
* Creates a new HTTP error.
|
|
97
|
+
* @param metadata - HTTP response metadata
|
|
98
|
+
* @param raw - Raw response object (optional)
|
|
99
|
+
* @param error - Custom error message (optional, defaults to status text)
|
|
100
|
+
*/
|
|
73
101
|
constructor(metadata, raw, error) {
|
|
74
102
|
super(error);
|
|
75
103
|
this.error = metadata.statusText;
|
|
@@ -80,12 +108,35 @@ var HttpError = class extends Error {
|
|
|
80
108
|
|
|
81
109
|
// src/http/hooks/custom-hook.ts
|
|
82
110
|
var CustomHook = class {
|
|
111
|
+
/**
|
|
112
|
+
* Called before an HTTP request is sent.
|
|
113
|
+
* Default implementation returns the request unchanged.
|
|
114
|
+
* @param request - The HTTP request to be sent
|
|
115
|
+
* @param params - Additional custom parameters
|
|
116
|
+
* @returns A promise that resolves to the unmodified request
|
|
117
|
+
*/
|
|
83
118
|
async beforeRequest(request, params) {
|
|
84
119
|
return request;
|
|
85
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Called after a successful HTTP response is received.
|
|
123
|
+
* Default implementation returns the response unchanged.
|
|
124
|
+
* @param request - The original HTTP request
|
|
125
|
+
* @param response - The HTTP response received
|
|
126
|
+
* @param params - Additional custom parameters
|
|
127
|
+
* @returns A promise that resolves to the unmodified response
|
|
128
|
+
*/
|
|
86
129
|
async afterResponse(request, response, params) {
|
|
87
130
|
return response;
|
|
88
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Called when an HTTP request results in an error.
|
|
134
|
+
* Default implementation wraps the error response in an HttpError object.
|
|
135
|
+
* @param request - The original HTTP request
|
|
136
|
+
* @param response - The error response received
|
|
137
|
+
* @param params - Additional custom parameters
|
|
138
|
+
* @returns A promise that resolves to an HttpError object
|
|
139
|
+
*/
|
|
89
140
|
async onError(request, response, params) {
|
|
90
141
|
return new HttpError(response.metadata, response.raw);
|
|
91
142
|
}
|
|
@@ -93,6 +144,11 @@ var CustomHook = class {
|
|
|
93
144
|
|
|
94
145
|
// src/http/serialization/base-serializer.ts
|
|
95
146
|
var Serializer = class {
|
|
147
|
+
/**
|
|
148
|
+
* Serializes a parameter value based on its type and serialization style.
|
|
149
|
+
* @param param - The request parameter to serialize
|
|
150
|
+
* @returns The serialized string representation
|
|
151
|
+
*/
|
|
96
152
|
serializeValue(param) {
|
|
97
153
|
if (Array.isArray(param.value)) {
|
|
98
154
|
return this.serializeArray(param.value, param);
|
|
@@ -102,6 +158,11 @@ var Serializer = class {
|
|
|
102
158
|
}
|
|
103
159
|
return this.serializePrimitive(param);
|
|
104
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Serializes a primitive value (string, number, boolean).
|
|
163
|
+
* @param param - The request parameter containing the primitive value
|
|
164
|
+
* @returns The serialized primitive string
|
|
165
|
+
*/
|
|
105
166
|
serializePrimitive(param) {
|
|
106
167
|
if (param.style === "label" /* LABEL */) {
|
|
107
168
|
return `.${param.value}`;
|
|
@@ -112,6 +173,12 @@ var Serializer = class {
|
|
|
112
173
|
}
|
|
113
174
|
return `${param.value}`;
|
|
114
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Serializes an array value according to the specified style.
|
|
178
|
+
* @param value - The array to serialize
|
|
179
|
+
* @param param - The request parameter configuration
|
|
180
|
+
* @returns The serialized array string
|
|
181
|
+
*/
|
|
115
182
|
serializeArray(value, param) {
|
|
116
183
|
if (param.explode) {
|
|
117
184
|
this.serializeArrayExploded(value, param);
|
|
@@ -132,6 +199,12 @@ var Serializer = class {
|
|
|
132
199
|
}
|
|
133
200
|
return `${value.join(",")}`;
|
|
134
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* Serializes an array in exploded format where each value is a separate parameter.
|
|
204
|
+
* @param value - The array to serialize
|
|
205
|
+
* @param param - The request parameter configuration
|
|
206
|
+
* @returns The serialized exploded array string
|
|
207
|
+
*/
|
|
135
208
|
serializeArrayExploded(value, param) {
|
|
136
209
|
if (param.style === "simple" /* SIMPLE */) {
|
|
137
210
|
return value.map((val) => `${val}`).join(",");
|
|
@@ -144,6 +217,12 @@ var Serializer = class {
|
|
|
144
217
|
}
|
|
145
218
|
return `${value.join(",")}`;
|
|
146
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Serializes an object value according to the specified style.
|
|
222
|
+
* @param obj - The object to serialize
|
|
223
|
+
* @param param - The request parameter configuration
|
|
224
|
+
* @returns The serialized object string
|
|
225
|
+
*/
|
|
147
226
|
serializeObject(obj, param) {
|
|
148
227
|
if (param.explode) {
|
|
149
228
|
if (param.style === "simple" /* SIMPLE */) {
|
|
@@ -171,6 +250,11 @@ var Serializer = class {
|
|
|
171
250
|
}
|
|
172
251
|
return Object.entries(obj).map(([key, val]) => `${key}=${val}`).join("&");
|
|
173
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Type guard to check if a value is a non-null object.
|
|
255
|
+
* @param value - The value to check
|
|
256
|
+
* @returns True if the value is an object and not null
|
|
257
|
+
*/
|
|
174
258
|
isNonNullObject(value) {
|
|
175
259
|
return typeof value === "object" && value !== null;
|
|
176
260
|
}
|
|
@@ -181,6 +265,14 @@ var TransportHookAdapter = class {
|
|
|
181
265
|
constructor() {
|
|
182
266
|
this.hook = new CustomHook();
|
|
183
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Invokes the custom hook before sending the request.
|
|
270
|
+
* Converts the Request to HttpRequest format, calls the hook, then converts back.
|
|
271
|
+
*
|
|
272
|
+
* @param request - The internal Request object
|
|
273
|
+
* @param params - Additional parameters to pass to the hook
|
|
274
|
+
* @returns The modified Request after hook processing
|
|
275
|
+
*/
|
|
184
276
|
async beforeRequest(request, params) {
|
|
185
277
|
const hookRequest = this.requestToHookRequest(request);
|
|
186
278
|
const newRequest = await this.hook.beforeRequest(hookRequest, params);
|
|
@@ -195,14 +287,39 @@ var TransportHookAdapter = class {
|
|
|
195
287
|
});
|
|
196
288
|
return newTransportRequest;
|
|
197
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Invokes the custom hook after receiving a response.
|
|
292
|
+
* Converts the Request to HttpRequest format and calls the hook with the response.
|
|
293
|
+
*
|
|
294
|
+
* @param request - The internal Request object
|
|
295
|
+
* @param response - The HTTP response received
|
|
296
|
+
* @param params - Additional parameters to pass to the hook
|
|
297
|
+
* @returns The potentially modified response after hook processing
|
|
298
|
+
*/
|
|
198
299
|
async afterResponse(request, response, params) {
|
|
199
300
|
const hookRequest = this.requestToHookRequest(request);
|
|
200
301
|
return this.hook.afterResponse(hookRequest, response, params);
|
|
201
302
|
}
|
|
303
|
+
/**
|
|
304
|
+
* Invokes the custom hook when an error occurs.
|
|
305
|
+
* Converts the Request to HttpRequest format and calls the error hook.
|
|
306
|
+
*
|
|
307
|
+
* @param request - The internal Request object
|
|
308
|
+
* @param response - The HTTP response that triggered the error
|
|
309
|
+
* @param params - Additional parameters to pass to the hook
|
|
310
|
+
* @returns The HttpError from the hook
|
|
311
|
+
*/
|
|
202
312
|
async onError(request, response, params) {
|
|
203
313
|
const hookRequest = this.requestToHookRequest(request);
|
|
204
314
|
return this.hook.onError(hookRequest, response, params);
|
|
205
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Converts the internal Request representation to the hook's HttpRequest format.
|
|
318
|
+
* Extracts parameter values from RequestParameter wrappers.
|
|
319
|
+
*
|
|
320
|
+
* @param request - The internal Request object
|
|
321
|
+
* @returns An HttpRequest object for hook processing
|
|
322
|
+
*/
|
|
206
323
|
requestToHookRequest(request) {
|
|
207
324
|
const hookHeaders = /* @__PURE__ */ new Map();
|
|
208
325
|
request.headers.forEach((header, key) => {
|
|
@@ -227,6 +344,16 @@ var TransportHookAdapter = class {
|
|
|
227
344
|
};
|
|
228
345
|
return hookRequest;
|
|
229
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Converts hook parameter maps back to RequestParameter format.
|
|
349
|
+
* Preserves serialization metadata from the original parameters.
|
|
350
|
+
*
|
|
351
|
+
* @template T - The parameter value type
|
|
352
|
+
* @param hookParams - The parameter map from hook processing
|
|
353
|
+
* @param originalTransportParams - The original RequestParameter map for metadata
|
|
354
|
+
* @param encode - Whether to encode the parameters
|
|
355
|
+
* @returns A map of RequestParameter objects for transport
|
|
356
|
+
*/
|
|
230
357
|
hookParamsToTransportParams(hookParams, originalTransportParams, encode) {
|
|
231
358
|
const transportParams = /* @__PURE__ */ new Map();
|
|
232
359
|
hookParams.forEach((hookParamValue, hookParamKey) => {
|
|
@@ -288,6 +415,14 @@ var HookHandler = class {
|
|
|
288
415
|
constructor(hook) {
|
|
289
416
|
this.hook = hook;
|
|
290
417
|
}
|
|
418
|
+
/**
|
|
419
|
+
* Handles a standard HTTP request with hook invocation.
|
|
420
|
+
* Calls beforeRequest hook, processes the request, and calls afterResponse or onError hooks.
|
|
421
|
+
* @template T - The expected response data type
|
|
422
|
+
* @param request - The HTTP request to process
|
|
423
|
+
* @returns A promise that resolves to the HTTP response
|
|
424
|
+
* @throws Error if no next handler is set, or if error handling fails
|
|
425
|
+
*/
|
|
291
426
|
async handle(request) {
|
|
292
427
|
var _a;
|
|
293
428
|
if (!this.next) {
|
|
@@ -321,6 +456,14 @@ StatusCode: ${response.metadata.status}
|
|
|
321
456
|
Body: ${decodedBody}`
|
|
322
457
|
);
|
|
323
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Handles a streaming HTTP request with hook invocation.
|
|
461
|
+
* Calls beforeRequest hook and afterResponse/onError hooks for each chunk.
|
|
462
|
+
* @template T - The expected response data type for each chunk
|
|
463
|
+
* @param request - The HTTP request to process
|
|
464
|
+
* @returns An async generator that yields HTTP responses
|
|
465
|
+
* @throws Error if no next handler is set, or if error handling fails
|
|
466
|
+
*/
|
|
324
467
|
async *stream(request) {
|
|
325
468
|
if (!this.next) {
|
|
326
469
|
throw new Error("No next handler set in hook handler.");
|
|
@@ -337,6 +480,12 @@ Body: ${decodedBody}`
|
|
|
337
480
|
}
|
|
338
481
|
}
|
|
339
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Extracts hook parameters from the request configuration.
|
|
485
|
+
* @template T - The response data type
|
|
486
|
+
* @param request - The HTTP request
|
|
487
|
+
* @returns A map of hook parameter names to values
|
|
488
|
+
*/
|
|
340
489
|
getHookParams(_request) {
|
|
341
490
|
const hookParams = /* @__PURE__ */ new Map();
|
|
342
491
|
return hookParams;
|
|
@@ -348,9 +497,19 @@ var import_zod = require("zod");
|
|
|
348
497
|
|
|
349
498
|
// src/http/utils/response-matcher.ts
|
|
350
499
|
var ResponseMatcher = class {
|
|
500
|
+
/**
|
|
501
|
+
* Creates a new response matcher.
|
|
502
|
+
* @param responses - Array of possible response definitions for an endpoint
|
|
503
|
+
*/
|
|
351
504
|
constructor(responses) {
|
|
352
505
|
this.responses = responses;
|
|
353
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Finds the matching response definition for an HTTP response.
|
|
509
|
+
* Matches based on status code and content type from the response headers.
|
|
510
|
+
* @param response - The HTTP response to match
|
|
511
|
+
* @returns The matching response definition, or undefined if no match found
|
|
512
|
+
*/
|
|
354
513
|
getResponseDefinition(response) {
|
|
355
514
|
var _a;
|
|
356
515
|
const rawContentType = ((_a = response.metadata.headers["content-type"]) == null ? void 0 : _a.toLocaleLowerCase()) || "";
|
|
@@ -370,10 +529,23 @@ var ResponseMatcher = class {
|
|
|
370
529
|
|
|
371
530
|
// src/http/handlers/response-validation-handler.ts
|
|
372
531
|
var ResponseValidationHandler = class {
|
|
532
|
+
/**
|
|
533
|
+
* Handles a standard HTTP request and validates its response.
|
|
534
|
+
* @template T - The expected response data type
|
|
535
|
+
* @param request - The HTTP request to process
|
|
536
|
+
* @returns A promise that resolves to the validated HTTP response
|
|
537
|
+
*/
|
|
373
538
|
async handle(request) {
|
|
374
539
|
const response = await this.next.handle(request);
|
|
375
540
|
return this.decodeBody(request, response);
|
|
376
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Handles a streaming HTTP request and validates response chunks.
|
|
544
|
+
* @template T - The expected response data type for each chunk
|
|
545
|
+
* @param request - The HTTP request to process
|
|
546
|
+
* @returns An async generator that yields validated HTTP responses
|
|
547
|
+
* @throws Error if response headers are enabled (streaming not supported with headers)
|
|
548
|
+
*/
|
|
377
549
|
async *stream(request) {
|
|
378
550
|
const stream = this.next.stream(request);
|
|
379
551
|
for await (const response of stream) {
|
|
@@ -467,6 +639,14 @@ var ResponseValidationHandler = class {
|
|
|
467
639
|
data: this.validate(request, responseDefinition, json)
|
|
468
640
|
};
|
|
469
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Validates response data against the expected schema if validation is enabled.
|
|
644
|
+
* @template T - The expected data type
|
|
645
|
+
* @param request - The HTTP request containing validation settings
|
|
646
|
+
* @param response - The response definition with schema
|
|
647
|
+
* @param data - The data to validate
|
|
648
|
+
* @returns The validated data (parsed if validation enabled, raw otherwise)
|
|
649
|
+
*/
|
|
470
650
|
validate(request, response, data) {
|
|
471
651
|
var _a;
|
|
472
652
|
if ((_a = request.validation) == null ? void 0 : _a.responseValidation) {
|
|
@@ -474,9 +654,21 @@ var ResponseValidationHandler = class {
|
|
|
474
654
|
}
|
|
475
655
|
return data;
|
|
476
656
|
}
|
|
657
|
+
/**
|
|
658
|
+
* Checks if a response should contain data based on its schema and status.
|
|
659
|
+
* @template T - The response data type
|
|
660
|
+
* @param responseDefinition - The response definition
|
|
661
|
+
* @param response - The HTTP response
|
|
662
|
+
* @returns True if the response should have content, false otherwise
|
|
663
|
+
*/
|
|
477
664
|
hasContent(responseDefinition, response) {
|
|
478
665
|
return !!responseDefinition.schema && !(responseDefinition.schema instanceof import_zod.ZodUndefined) && response.metadata.status !== 204;
|
|
479
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* Parses URL-encoded data into an object.
|
|
669
|
+
* @param urlEncodedData - The URL-encoded string
|
|
670
|
+
* @returns An object with decoded key-value pairs
|
|
671
|
+
*/
|
|
480
672
|
fromUrlEncoded(urlEncodedData) {
|
|
481
673
|
const pairs = urlEncodedData.split("&");
|
|
482
674
|
const result = {};
|
|
@@ -488,6 +680,11 @@ var ResponseValidationHandler = class {
|
|
|
488
680
|
});
|
|
489
681
|
return result;
|
|
490
682
|
}
|
|
683
|
+
/**
|
|
684
|
+
* Parses multipart form data into an object.
|
|
685
|
+
* @param arrayBuffer - The raw form data as ArrayBuffer
|
|
686
|
+
* @returns An object with form field names and values
|
|
687
|
+
*/
|
|
491
688
|
fromFormData(arrayBuffer) {
|
|
492
689
|
const decoder = new TextDecoder();
|
|
493
690
|
const text = decoder.decode(arrayBuffer);
|
|
@@ -511,6 +708,11 @@ var import_zod2 = require("zod");
|
|
|
511
708
|
|
|
512
709
|
// src/http/errors/validation-error.ts
|
|
513
710
|
var ValidationError = class extends Error {
|
|
711
|
+
/**
|
|
712
|
+
* Creates a new validation error from a Zod error.
|
|
713
|
+
* @param zodError - The Zod validation error containing issue details
|
|
714
|
+
* @param object - The object that failed validation
|
|
715
|
+
*/
|
|
514
716
|
constructor(zodError, object) {
|
|
515
717
|
let actual;
|
|
516
718
|
try {
|
|
@@ -531,6 +733,13 @@ var ValidationError = class extends Error {
|
|
|
531
733
|
|
|
532
734
|
// src/http/handlers/request-validation-handler.ts
|
|
533
735
|
var RequestValidationHandler = class {
|
|
736
|
+
/**
|
|
737
|
+
* Handles a standard HTTP request with validation.
|
|
738
|
+
* @template T - The expected response data type
|
|
739
|
+
* @param request - The HTTP request to validate
|
|
740
|
+
* @returns A promise that resolves to the HTTP response
|
|
741
|
+
* @throws Error if no next handler is set
|
|
742
|
+
*/
|
|
534
743
|
async handle(request) {
|
|
535
744
|
if (!this.next) {
|
|
536
745
|
throw new Error("No next handler set in ContentTypeHandler.");
|
|
@@ -538,6 +747,13 @@ var RequestValidationHandler = class {
|
|
|
538
747
|
this.validateRequest(request);
|
|
539
748
|
return this.next.handle(request);
|
|
540
749
|
}
|
|
750
|
+
/**
|
|
751
|
+
* Handles a streaming HTTP request with validation.
|
|
752
|
+
* @template T - The expected response data type for each chunk
|
|
753
|
+
* @param request - The HTTP request to validate
|
|
754
|
+
* @returns An async generator that yields HTTP responses
|
|
755
|
+
* @throws Error if no next handler is set
|
|
756
|
+
*/
|
|
541
757
|
async *stream(request) {
|
|
542
758
|
if (!this.next) {
|
|
543
759
|
throw new Error("No next handler set in ContentTypeHandler.");
|
|
@@ -545,6 +761,11 @@ var RequestValidationHandler = class {
|
|
|
545
761
|
this.validateRequest(request);
|
|
546
762
|
yield* this.next.stream(request);
|
|
547
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Validates and serializes the request body based on its content type.
|
|
766
|
+
* @param request - The HTTP request to validate
|
|
767
|
+
* @throws ValidationError if Zod schema validation fails
|
|
768
|
+
*/
|
|
548
769
|
validateRequest(request) {
|
|
549
770
|
var _a, _b;
|
|
550
771
|
if (request.requestContentType === "json" /* Json */) {
|
|
@@ -567,6 +788,11 @@ var RequestValidationHandler = class {
|
|
|
567
788
|
request.body = JSON.stringify((_b = request.requestSchema) == null ? void 0 : _b.parse(request.body));
|
|
568
789
|
}
|
|
569
790
|
}
|
|
791
|
+
/**
|
|
792
|
+
* Converts request body to URL-encoded form data format.
|
|
793
|
+
* @param request - The HTTP request with body to convert
|
|
794
|
+
* @returns URL-encoded string representation of the body
|
|
795
|
+
*/
|
|
570
796
|
toFormUrlEncoded(request) {
|
|
571
797
|
var _a;
|
|
572
798
|
if (request.body === void 0) {
|
|
@@ -599,6 +825,14 @@ var RequestValidationHandler = class {
|
|
|
599
825
|
}
|
|
600
826
|
return "";
|
|
601
827
|
}
|
|
828
|
+
/**
|
|
829
|
+
* Converts request body to multipart form data format.
|
|
830
|
+
* Handles files (ArrayBuffer), arrays, and regular values.
|
|
831
|
+
* @param body - The request body object
|
|
832
|
+
* @param filename - Optional filename for single file uploads
|
|
833
|
+
* @param filenames - Optional filenames array for array of file uploads
|
|
834
|
+
* @returns FormData object with serialized body
|
|
835
|
+
*/
|
|
602
836
|
toFormData(body, filename, filenames) {
|
|
603
837
|
const formData = new FormData();
|
|
604
838
|
Object.keys(body).forEach((key) => {
|
|
@@ -633,6 +867,9 @@ var LineDecoder = class {
|
|
|
633
867
|
/**
|
|
634
868
|
* Splits the given chunk into lines.
|
|
635
869
|
* Stores incomplete lines in a buffer and returns them when the next chunk arrives.
|
|
870
|
+
*
|
|
871
|
+
* @param chunk - The data chunk to split into lines
|
|
872
|
+
* @returns An array of complete lines as Uint8Array
|
|
636
873
|
*/
|
|
637
874
|
splitLines(chunk) {
|
|
638
875
|
this.lineBuffer += this.decoder.decode(chunk);
|
|
@@ -647,7 +884,12 @@ var LineDecoder = class {
|
|
|
647
884
|
}
|
|
648
885
|
return lines;
|
|
649
886
|
}
|
|
650
|
-
/**
|
|
887
|
+
/**
|
|
888
|
+
* Returns the remaining lines in the buffer.
|
|
889
|
+
* Call this after the stream ends to get any incomplete final line.
|
|
890
|
+
*
|
|
891
|
+
* @returns An array containing the buffered line, or empty if buffer is empty
|
|
892
|
+
*/
|
|
651
893
|
flush() {
|
|
652
894
|
if (this.lineBuffer.length === 0) {
|
|
653
895
|
return [];
|
|
@@ -665,9 +907,16 @@ var RequestFetchAdapter = class {
|
|
|
665
907
|
this.requestInit = {};
|
|
666
908
|
this.setMethod(request.method);
|
|
667
909
|
this.setHeaders(request.getHeaders());
|
|
910
|
+
this.setCookies(request.getCookies());
|
|
668
911
|
this.setBody(request.body);
|
|
669
912
|
this.setTimeout(request.config.timeoutMs);
|
|
670
913
|
}
|
|
914
|
+
/**
|
|
915
|
+
* Executes the HTTP request and returns the response.
|
|
916
|
+
* Fetches the full response body as an ArrayBuffer.
|
|
917
|
+
*
|
|
918
|
+
* @returns A promise resolving to the HTTP response with metadata and body
|
|
919
|
+
*/
|
|
671
920
|
async send() {
|
|
672
921
|
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
673
922
|
const metadata = {
|
|
@@ -680,6 +929,13 @@ var RequestFetchAdapter = class {
|
|
|
680
929
|
raw: await response.clone().arrayBuffer()
|
|
681
930
|
};
|
|
682
931
|
}
|
|
932
|
+
/**
|
|
933
|
+
* Executes the HTTP request as a stream, yielding chunks as they arrive.
|
|
934
|
+
* Uses the Fetch API's ReadableStream and LineDecoder to split into lines.
|
|
935
|
+
*
|
|
936
|
+
* @returns An async generator yielding HTTP response chunks
|
|
937
|
+
* @throws Error if responseHeaders is enabled (streaming not supported with responseHeaders)
|
|
938
|
+
*/
|
|
683
939
|
async *stream() {
|
|
684
940
|
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
685
941
|
const metadata = {
|
|
@@ -744,6 +1000,19 @@ var RequestFetchAdapter = class {
|
|
|
744
1000
|
headers
|
|
745
1001
|
};
|
|
746
1002
|
}
|
|
1003
|
+
setCookies(cookies) {
|
|
1004
|
+
if (!cookies || Object.keys(cookies).length === 0) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
const cookieString = Object.entries(cookies).map(([key, value]) => `${key}=${value}`).join("; ");
|
|
1008
|
+
this.requestInit = {
|
|
1009
|
+
...this.requestInit,
|
|
1010
|
+
headers: {
|
|
1011
|
+
...this.requestInit.headers,
|
|
1012
|
+
Cookie: cookieString
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
747
1016
|
setTimeout(timeoutMs) {
|
|
748
1017
|
if (!timeoutMs) {
|
|
749
1018
|
return;
|
|
@@ -767,9 +1036,21 @@ var RequestFetchAdapter = class {
|
|
|
767
1036
|
|
|
768
1037
|
// src/http/handlers/terminating-handler.ts
|
|
769
1038
|
var TerminatingHandler = class {
|
|
1039
|
+
/**
|
|
1040
|
+
* Executes the actual HTTP request using the configured client adapter.
|
|
1041
|
+
* @template T - The expected response data type
|
|
1042
|
+
* @param request - The HTTP request to execute
|
|
1043
|
+
* @returns A promise that resolves to the HTTP response
|
|
1044
|
+
*/
|
|
770
1045
|
async handle(request) {
|
|
771
1046
|
return new RequestFetchAdapter(request).send();
|
|
772
1047
|
}
|
|
1048
|
+
/**
|
|
1049
|
+
* Executes a streaming HTTP request using the configured client adapter.
|
|
1050
|
+
* @template T - The expected response data type for each chunk
|
|
1051
|
+
* @param request - The HTTP request to execute
|
|
1052
|
+
* @returns An async generator that yields HTTP responses
|
|
1053
|
+
*/
|
|
773
1054
|
async *stream(request) {
|
|
774
1055
|
yield* new RequestFetchAdapter(request).stream();
|
|
775
1056
|
}
|
|
@@ -777,6 +1058,14 @@ var TerminatingHandler = class {
|
|
|
777
1058
|
|
|
778
1059
|
// src/http/handlers/retry-handler.ts
|
|
779
1060
|
var RetryHandler = class {
|
|
1061
|
+
/**
|
|
1062
|
+
* Handles a standard HTTP request with retry logic.
|
|
1063
|
+
* Retries failed requests based on the configured retry settings.
|
|
1064
|
+
* @template T - The expected response data type
|
|
1065
|
+
* @param request - The HTTP request to process
|
|
1066
|
+
* @returns A promise that resolves to the HTTP response
|
|
1067
|
+
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1068
|
+
*/
|
|
780
1069
|
async handle(request) {
|
|
781
1070
|
if (!this.next) {
|
|
782
1071
|
throw new Error("No next handler set in retry handler.");
|
|
@@ -793,6 +1082,13 @@ var RetryHandler = class {
|
|
|
793
1082
|
}
|
|
794
1083
|
throw new Error("Error retrying request.");
|
|
795
1084
|
}
|
|
1085
|
+
/**
|
|
1086
|
+
* Handles a streaming HTTP request with retry logic.
|
|
1087
|
+
* @template T - The expected response data type for each chunk
|
|
1088
|
+
* @param request - The HTTP request to process
|
|
1089
|
+
* @returns An async generator that yields HTTP responses
|
|
1090
|
+
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1091
|
+
*/
|
|
796
1092
|
async *stream(request) {
|
|
797
1093
|
if (!this.next) {
|
|
798
1094
|
throw new Error("No next handler set in retry handler.");
|
|
@@ -810,9 +1106,20 @@ var RetryHandler = class {
|
|
|
810
1106
|
}
|
|
811
1107
|
throw new Error("Error retrying request.");
|
|
812
1108
|
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Determines if an error should trigger a retry.
|
|
1111
|
+
* Retries server errors (5xx), request timeouts (408), and rate limits (429).
|
|
1112
|
+
* @param error - The error to check
|
|
1113
|
+
* @returns True if the request should be retried, false otherwise
|
|
1114
|
+
*/
|
|
813
1115
|
shouldRetry(error) {
|
|
814
1116
|
return error instanceof HttpError && (error.metadata.status >= 500 || error.metadata.status === 408 || error.metadata.status === 429);
|
|
815
1117
|
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Delays execution for a specified duration before retrying.
|
|
1120
|
+
* @param delayMs - The delay in milliseconds (optional)
|
|
1121
|
+
* @returns A promise that resolves after the delay
|
|
1122
|
+
*/
|
|
816
1123
|
delay(delayMs) {
|
|
817
1124
|
if (!delayMs) {
|
|
818
1125
|
return Promise.resolve();
|
|
@@ -830,6 +1137,14 @@ function isRequestCursorPagination(pagination) {
|
|
|
830
1137
|
|
|
831
1138
|
// src/http/handlers/oauth-handler.ts
|
|
832
1139
|
var OAuthHandler = class {
|
|
1140
|
+
/**
|
|
1141
|
+
* Handles a standard HTTP request with OAuth authentication.
|
|
1142
|
+
* Manages access tokens and adds Authorization headers.
|
|
1143
|
+
* @template T - The expected response data type
|
|
1144
|
+
* @param request - The HTTP request to process
|
|
1145
|
+
* @returns A promise that resolves to the HTTP response
|
|
1146
|
+
* @throws Error if no next handler is set
|
|
1147
|
+
*/
|
|
833
1148
|
async handle(request) {
|
|
834
1149
|
if (!this.next) {
|
|
835
1150
|
throw new Error(`No next handler set in OAuthHandler`);
|
|
@@ -844,6 +1159,13 @@ var OAuthHandler = class {
|
|
|
844
1159
|
await this.manageToken(request);
|
|
845
1160
|
return this.next.handle(request);
|
|
846
1161
|
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Handles a streaming HTTP request with OAuth authentication.
|
|
1164
|
+
* @template T - The expected response data type for each chunk
|
|
1165
|
+
* @param request - The HTTP request to process
|
|
1166
|
+
* @returns An async generator that yields HTTP responses
|
|
1167
|
+
* @throws Error if no next handler is set
|
|
1168
|
+
*/
|
|
847
1169
|
async *stream(request) {
|
|
848
1170
|
if (!this.next) {
|
|
849
1171
|
throw new Error(`No next handler set in OAuthHandler`);
|
|
@@ -851,6 +1173,10 @@ var OAuthHandler = class {
|
|
|
851
1173
|
await this.manageToken(request);
|
|
852
1174
|
yield* this.next.stream(request);
|
|
853
1175
|
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Retrieves an access token for the required scopes and adds it to the request.
|
|
1178
|
+
* @param request - The HTTP request to add the token to
|
|
1179
|
+
*/
|
|
854
1180
|
async manageToken(request) {
|
|
855
1181
|
if (!request.scopes) {
|
|
856
1182
|
return;
|
|
@@ -860,6 +1186,11 @@ var OAuthHandler = class {
|
|
|
860
1186
|
this.addAccessTokenHeader(request, token.accessToken);
|
|
861
1187
|
}
|
|
862
1188
|
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Adds the OAuth access token to the request's Authorization header.
|
|
1191
|
+
* @param request - The HTTP request to modify
|
|
1192
|
+
* @param token - The access token to add
|
|
1193
|
+
*/
|
|
863
1194
|
addAccessTokenHeader(request, token) {
|
|
864
1195
|
request.addHeaderParam("Authorization", {
|
|
865
1196
|
key: "Authorization",
|
|
@@ -876,8 +1207,14 @@ var OAuthHandler = class {
|
|
|
876
1207
|
|
|
877
1208
|
// src/http/client.ts
|
|
878
1209
|
var HttpClient = class {
|
|
1210
|
+
/**
|
|
1211
|
+
* Creates a new HTTP client with configured request handlers.
|
|
1212
|
+
* @param config - SDK configuration including base URL and authentication
|
|
1213
|
+
* @param hook - Optional custom hook for request/response interception
|
|
1214
|
+
*/
|
|
879
1215
|
constructor(config, hook = new CustomHook()) {
|
|
880
1216
|
this.config = config;
|
|
1217
|
+
/** Chain of request handlers that process requests in sequence */
|
|
881
1218
|
this.requestHandlerChain = new RequestHandlerChain();
|
|
882
1219
|
this.requestHandlerChain.addHandler(new ResponseValidationHandler());
|
|
883
1220
|
this.requestHandlerChain.addHandler(new RequestValidationHandler());
|
|
@@ -886,12 +1223,32 @@ var HttpClient = class {
|
|
|
886
1223
|
this.requestHandlerChain.addHandler(new HookHandler(hook));
|
|
887
1224
|
this.requestHandlerChain.addHandler(new TerminatingHandler());
|
|
888
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Executes a standard HTTP request.
|
|
1228
|
+
* @template T - The expected response data type
|
|
1229
|
+
* @param request - The HTTP request to execute
|
|
1230
|
+
* @returns A promise that resolves to the HTTP response
|
|
1231
|
+
*/
|
|
889
1232
|
call(request) {
|
|
890
1233
|
return this.requestHandlerChain.callChain(request);
|
|
891
1234
|
}
|
|
1235
|
+
/**
|
|
1236
|
+
* Executes a streaming HTTP request that yields responses incrementally.
|
|
1237
|
+
* @template T - The expected response data type for each chunk
|
|
1238
|
+
* @param request - The HTTP request to execute
|
|
1239
|
+
* @returns An async generator that yields HTTP responses
|
|
1240
|
+
*/
|
|
892
1241
|
async *stream(request) {
|
|
893
1242
|
yield* this.requestHandlerChain.streamChain(request);
|
|
894
1243
|
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Executes a paginated HTTP request and extracts the page data from the response.
|
|
1246
|
+
* @template FullResponse - The complete response type from the API
|
|
1247
|
+
* @template Page - The type of a single page of data
|
|
1248
|
+
* @param request - The paginated HTTP request to execute
|
|
1249
|
+
* @returns A promise that resolves to the paginated HTTP response
|
|
1250
|
+
* @throws Error if the response contains no data to paginate through
|
|
1251
|
+
*/
|
|
895
1252
|
async callPaginated(request) {
|
|
896
1253
|
const response = await this.call(request);
|
|
897
1254
|
if (!response.data) {
|
|
@@ -903,6 +1260,14 @@ var HttpClient = class {
|
|
|
903
1260
|
data: page
|
|
904
1261
|
};
|
|
905
1262
|
}
|
|
1263
|
+
/**
|
|
1264
|
+
* Executes a cursor-paginated HTTP request and extracts both page data and the next cursor.
|
|
1265
|
+
* @template FullResponse - The complete response type from the API
|
|
1266
|
+
* @template Page - The type of a single page of data
|
|
1267
|
+
* @param request - The cursor-paginated HTTP request to execute
|
|
1268
|
+
* @returns A promise that resolves to the cursor-paginated HTTP response with next cursor
|
|
1269
|
+
* @throws Error if the response contains no data to paginate through
|
|
1270
|
+
*/
|
|
906
1271
|
async callCursorPaginated(request) {
|
|
907
1272
|
const response = await this.call(request);
|
|
908
1273
|
if (!response.data) {
|
|
@@ -916,12 +1281,29 @@ var HttpClient = class {
|
|
|
916
1281
|
nextCursor
|
|
917
1282
|
};
|
|
918
1283
|
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Updates the base URL for all subsequent requests.
|
|
1286
|
+
* @param url - The new base URL to use
|
|
1287
|
+
*/
|
|
919
1288
|
setBaseUrl(url) {
|
|
920
1289
|
this.config.baseUrl = url;
|
|
921
1290
|
}
|
|
1291
|
+
/**
|
|
1292
|
+
* Updates the SDK configuration.
|
|
1293
|
+
* @param config - The new SDK configuration
|
|
1294
|
+
*/
|
|
922
1295
|
setConfig(config) {
|
|
923
1296
|
this.config = config;
|
|
924
1297
|
}
|
|
1298
|
+
/**
|
|
1299
|
+
* Extracts page data from a full API response using the configured pagination path.
|
|
1300
|
+
* @template FullResponse - The complete response type from the API
|
|
1301
|
+
* @template Page - The type of a single page of data
|
|
1302
|
+
* @param request - The request containing pagination configuration
|
|
1303
|
+
* @param data - The full response data to extract the page from
|
|
1304
|
+
* @returns The extracted and parsed page data
|
|
1305
|
+
* @throws Error if pagination is not configured or page extraction fails
|
|
1306
|
+
*/
|
|
925
1307
|
getPage(request, data) {
|
|
926
1308
|
var _a;
|
|
927
1309
|
if (!request.pagination) {
|
|
@@ -939,6 +1321,14 @@ var HttpClient = class {
|
|
|
939
1321
|
}
|
|
940
1322
|
return page;
|
|
941
1323
|
}
|
|
1324
|
+
/**
|
|
1325
|
+
* Extracts the next cursor from a full API response for cursor-based pagination.
|
|
1326
|
+
* @template FullResponse - The complete response type from the API
|
|
1327
|
+
* @template Page - The type of a single page of data
|
|
1328
|
+
* @param request - The request containing cursor pagination configuration
|
|
1329
|
+
* @param data - The full response data to extract the cursor from
|
|
1330
|
+
* @returns The next cursor string, null if no more pages, or undefined if not cursor pagination
|
|
1331
|
+
*/
|
|
942
1332
|
getNextCursor(request, data) {
|
|
943
1333
|
var _a, _b;
|
|
944
1334
|
if (!isRequestCursorPagination(request.pagination)) {
|
|
@@ -990,6 +1380,14 @@ var import_zod3 = __toESM(require("zod"));
|
|
|
990
1380
|
|
|
991
1381
|
// src/http/serialization/path-serializer.ts
|
|
992
1382
|
var PathSerializer = class extends Serializer {
|
|
1383
|
+
/**
|
|
1384
|
+
* Serializes path parameters into a URL path by replacing template placeholders.
|
|
1385
|
+
* @param pathPattern - The URL path pattern with {placeholders}
|
|
1386
|
+
* @param pathArguments - Map of parameter names to their values
|
|
1387
|
+
* @returns The path with placeholders replaced by serialized values
|
|
1388
|
+
* @example
|
|
1389
|
+
* serialize("/users/{id}", Map([["id", {key: "id", value: 123}]])) returns "/users/123"
|
|
1390
|
+
*/
|
|
993
1391
|
serialize(pathPattern, pathArguments) {
|
|
994
1392
|
let serializedPath = pathPattern;
|
|
995
1393
|
pathArguments.forEach((param) => {
|
|
@@ -1001,6 +1399,13 @@ var PathSerializer = class extends Serializer {
|
|
|
1001
1399
|
|
|
1002
1400
|
// src/http/serialization/query-serializer.ts
|
|
1003
1401
|
var QuerySerializer = class extends Serializer {
|
|
1402
|
+
/**
|
|
1403
|
+
* Serializes query parameters into a URL query string.
|
|
1404
|
+
* @param queryParams - Map of query parameter names to their values
|
|
1405
|
+
* @returns A query string starting with "?" if parameters exist, empty string otherwise
|
|
1406
|
+
* @example
|
|
1407
|
+
* serialize(Map([["name", {...}], ["age", {...}]])) returns "?name=John&age=30"
|
|
1408
|
+
*/
|
|
1004
1409
|
serialize(queryParams) {
|
|
1005
1410
|
if (!queryParams || !queryParams.size) {
|
|
1006
1411
|
return "";
|
|
@@ -1018,6 +1423,11 @@ var QuerySerializer = class extends Serializer {
|
|
|
1018
1423
|
|
|
1019
1424
|
// src/http/serialization/header-serializer.ts
|
|
1020
1425
|
var HeaderSerializer = class extends Serializer {
|
|
1426
|
+
/**
|
|
1427
|
+
* Serializes header parameters into a headers object.
|
|
1428
|
+
* @param headerParams - Map of header names to their parameter values
|
|
1429
|
+
* @returns A HeadersInit object with serialized header values, or undefined if no headers
|
|
1430
|
+
*/
|
|
1021
1431
|
serialize(headerParams) {
|
|
1022
1432
|
if (!headerParams || !headerParams.size) {
|
|
1023
1433
|
return void 0;
|
|
@@ -1033,6 +1443,83 @@ var HeaderSerializer = class extends Serializer {
|
|
|
1033
1443
|
}
|
|
1034
1444
|
};
|
|
1035
1445
|
|
|
1446
|
+
// src/http/serialization/cookie-serializer.ts
|
|
1447
|
+
var CookieSerializer = class {
|
|
1448
|
+
/**
|
|
1449
|
+
* Serializes cookie parameters into a cookie object.
|
|
1450
|
+
* @param cookieParams - Map of cookie names to their parameter values
|
|
1451
|
+
* @returns A record of cookie names to serialized values, or undefined if no cookies
|
|
1452
|
+
*/
|
|
1453
|
+
serialize(cookieParams) {
|
|
1454
|
+
if (!cookieParams || !cookieParams.size) {
|
|
1455
|
+
return void 0;
|
|
1456
|
+
}
|
|
1457
|
+
const cookies = {};
|
|
1458
|
+
cookieParams.forEach((param) => {
|
|
1459
|
+
if (!param.key || param.value === void 0) {
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
cookies[param.key] = this.serializeCookieValue(param);
|
|
1463
|
+
});
|
|
1464
|
+
return cookies;
|
|
1465
|
+
}
|
|
1466
|
+
/**
|
|
1467
|
+
* Serializes a single cookie value based on its type.
|
|
1468
|
+
* @param param - The cookie parameter to serialize
|
|
1469
|
+
* @returns The serialized cookie value string
|
|
1470
|
+
*/
|
|
1471
|
+
serializeCookieValue(param) {
|
|
1472
|
+
if (Array.isArray(param.value)) {
|
|
1473
|
+
return this.serializeArray(param.value, param);
|
|
1474
|
+
}
|
|
1475
|
+
if (this.isNonNullObject(param.value)) {
|
|
1476
|
+
return this.serializeObject(param.value, param);
|
|
1477
|
+
}
|
|
1478
|
+
return this.serializePrimitive(param.value);
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Serializes a primitive cookie value.
|
|
1482
|
+
* @param value - The primitive value to serialize
|
|
1483
|
+
* @returns The string representation of the value
|
|
1484
|
+
*/
|
|
1485
|
+
serializePrimitive(value) {
|
|
1486
|
+
return `${value}`;
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* Serializes an array cookie value.
|
|
1490
|
+
* @param value - The array to serialize
|
|
1491
|
+
* @param param - The cookie parameter configuration
|
|
1492
|
+
* @returns The serialized array string
|
|
1493
|
+
*/
|
|
1494
|
+
serializeArray(value, param) {
|
|
1495
|
+
if (param.explode) {
|
|
1496
|
+
if (value.length === 0)
|
|
1497
|
+
return "";
|
|
1498
|
+
const first = value[0];
|
|
1499
|
+
const rest = value.slice(1).map((v) => `${param.key}=${v}`).join("; ");
|
|
1500
|
+
return rest ? `${first}; ${rest}` : `${first}`;
|
|
1501
|
+
}
|
|
1502
|
+
return value.join(",");
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Serializes an object cookie value as JSON.
|
|
1506
|
+
* @param obj - The object to serialize
|
|
1507
|
+
* @param param - The cookie parameter configuration
|
|
1508
|
+
* @returns The JSON string representation of the object
|
|
1509
|
+
*/
|
|
1510
|
+
serializeObject(obj, param) {
|
|
1511
|
+
return JSON.stringify(obj);
|
|
1512
|
+
}
|
|
1513
|
+
/**
|
|
1514
|
+
* Type guard to check if a value is a non-null object.
|
|
1515
|
+
* @param value - The value to check
|
|
1516
|
+
* @returns True if the value is an object and not null
|
|
1517
|
+
*/
|
|
1518
|
+
isNonNullObject(value) {
|
|
1519
|
+
return typeof value === "object" && value !== null;
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1036
1523
|
// src/http/transport/request.ts
|
|
1037
1524
|
var Request = class {
|
|
1038
1525
|
constructor(params) {
|
|
@@ -1040,6 +1527,7 @@ var Request = class {
|
|
|
1040
1527
|
this.headers = /* @__PURE__ */ new Map();
|
|
1041
1528
|
this.queryParams = /* @__PURE__ */ new Map();
|
|
1042
1529
|
this.pathParams = /* @__PURE__ */ new Map();
|
|
1530
|
+
this.cookies = /* @__PURE__ */ new Map();
|
|
1043
1531
|
this.validation = {};
|
|
1044
1532
|
this.retry = {};
|
|
1045
1533
|
this.baseUrl = params.baseUrl;
|
|
@@ -1051,6 +1539,7 @@ var Request = class {
|
|
|
1051
1539
|
this.pathParams = params.pathParams;
|
|
1052
1540
|
this.headers = params.headers;
|
|
1053
1541
|
this.queryParams = params.queryParams;
|
|
1542
|
+
this.cookies = params.cookies;
|
|
1054
1543
|
this.responses = params.responses;
|
|
1055
1544
|
this.errors = params.errors;
|
|
1056
1545
|
this.requestSchema = params.requestSchema;
|
|
@@ -1063,6 +1552,12 @@ var Request = class {
|
|
|
1063
1552
|
this.scopes = params.scopes;
|
|
1064
1553
|
this.tokenManager = params.tokenManager;
|
|
1065
1554
|
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Adds a header parameter to the request with OpenAPI serialization rules.
|
|
1557
|
+
*
|
|
1558
|
+
* @param key - The header name
|
|
1559
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1560
|
+
*/
|
|
1066
1561
|
addHeaderParam(key, param) {
|
|
1067
1562
|
if (param.value === void 0) {
|
|
1068
1563
|
return;
|
|
@@ -1078,6 +1573,12 @@ var Request = class {
|
|
|
1078
1573
|
}
|
|
1079
1574
|
this.headers.set(key, param);
|
|
1080
1575
|
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Adds a query parameter to the request with OpenAPI serialization rules.
|
|
1578
|
+
*
|
|
1579
|
+
* @param key - The query parameter name
|
|
1580
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1581
|
+
*/
|
|
1081
1582
|
addQueryParam(key, param) {
|
|
1082
1583
|
if (param.value === void 0) {
|
|
1083
1584
|
return;
|
|
@@ -1093,6 +1594,12 @@ var Request = class {
|
|
|
1093
1594
|
}
|
|
1094
1595
|
this.queryParams.set(key, param);
|
|
1095
1596
|
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Adds a path parameter to the request with OpenAPI serialization rules.
|
|
1599
|
+
*
|
|
1600
|
+
* @param key - The path parameter name (matches template variable in path pattern)
|
|
1601
|
+
* @param param - The parameter configuration including value, style, and encoding options
|
|
1602
|
+
*/
|
|
1096
1603
|
addPathParam(key, param) {
|
|
1097
1604
|
if (param.value === void 0) {
|
|
1098
1605
|
return;
|
|
@@ -1108,26 +1615,50 @@ var Request = class {
|
|
|
1108
1615
|
}
|
|
1109
1616
|
this.pathParams.set(key, param);
|
|
1110
1617
|
}
|
|
1618
|
+
/**
|
|
1619
|
+
* Sets the request body if the value is defined.
|
|
1620
|
+
*
|
|
1621
|
+
* @param body - The request body to send
|
|
1622
|
+
*/
|
|
1111
1623
|
addBody(body) {
|
|
1112
1624
|
if (body === void 0) {
|
|
1113
1625
|
return;
|
|
1114
1626
|
}
|
|
1115
1627
|
this.body = body;
|
|
1116
1628
|
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Updates this request from a modified hook request.
|
|
1631
|
+
* Used after hooks modify the request to sync changes back to the internal Request object.
|
|
1632
|
+
*
|
|
1633
|
+
* @param hookRequest - The modified request from hook processing
|
|
1634
|
+
*/
|
|
1117
1635
|
updateFromHookRequest(hookRequest) {
|
|
1118
1636
|
this.baseUrl = hookRequest.baseUrl;
|
|
1119
1637
|
this.method = hookRequest.method;
|
|
1120
1638
|
this.path = hookRequest.path;
|
|
1121
1639
|
this.body = hookRequest.body;
|
|
1122
1640
|
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Constructs the complete URL by combining base URL, path with substituted parameters,
|
|
1643
|
+
* and serialized query string.
|
|
1644
|
+
*
|
|
1645
|
+
* @returns The fully constructed URL ready for HTTP execution
|
|
1646
|
+
*/
|
|
1123
1647
|
constructFullUrl() {
|
|
1124
1648
|
const queryString = new QuerySerializer().serialize(this.queryParams);
|
|
1125
1649
|
const path = this.constructPath();
|
|
1126
1650
|
let baseUrl = this.baseUrl;
|
|
1127
1651
|
return `${baseUrl}${path}${queryString}`;
|
|
1128
1652
|
}
|
|
1653
|
+
/**
|
|
1654
|
+
* Creates a copy of this request with optional parameter overrides.
|
|
1655
|
+
* Useful for pagination where you need to modify parameters while keeping the rest intact.
|
|
1656
|
+
*
|
|
1657
|
+
* @param overrides - Optional parameters to override in the copied request
|
|
1658
|
+
* @returns A new Request instance with the specified overrides
|
|
1659
|
+
*/
|
|
1129
1660
|
copy(overrides) {
|
|
1130
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
1661
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
1131
1662
|
const createRequestParams = {
|
|
1132
1663
|
baseUrl: (_a = overrides == null ? void 0 : overrides.baseUrl) != null ? _a : this.baseUrl,
|
|
1133
1664
|
errors: (_b = overrides == null ? void 0 : overrides.errors) != null ? _b : this.errors,
|
|
@@ -1138,13 +1669,14 @@ var Request = class {
|
|
|
1138
1669
|
pathParams: (_g = overrides == null ? void 0 : overrides.pathParams) != null ? _g : this.pathParams,
|
|
1139
1670
|
queryParams: (_h = overrides == null ? void 0 : overrides.queryParams) != null ? _h : this.queryParams,
|
|
1140
1671
|
headers: (_i = overrides == null ? void 0 : overrides.headers) != null ? _i : this.headers,
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1672
|
+
cookies: (_j = overrides == null ? void 0 : overrides.cookies) != null ? _j : this.cookies,
|
|
1673
|
+
responses: (_k = overrides == null ? void 0 : overrides.responses) != null ? _k : this.responses,
|
|
1674
|
+
requestSchema: (_l = overrides == null ? void 0 : overrides.requestSchema) != null ? _l : this.requestSchema,
|
|
1675
|
+
requestContentType: (_m = overrides == null ? void 0 : overrides.requestContentType) != null ? _m : this.requestContentType,
|
|
1676
|
+
retry: (_n = overrides == null ? void 0 : overrides.retry) != null ? _n : this.retry,
|
|
1677
|
+
validation: (_o = overrides == null ? void 0 : overrides.validation) != null ? _o : this.validation,
|
|
1678
|
+
filename: (_p = overrides == null ? void 0 : overrides.filename) != null ? _p : this.filename,
|
|
1679
|
+
filenames: (_q = overrides == null ? void 0 : overrides.filenames) != null ? _q : this.filenames,
|
|
1148
1680
|
scopes: overrides == null ? void 0 : overrides.scopes,
|
|
1149
1681
|
tokenManager: this.tokenManager
|
|
1150
1682
|
};
|
|
@@ -1153,12 +1685,34 @@ var Request = class {
|
|
|
1153
1685
|
...overrides
|
|
1154
1686
|
});
|
|
1155
1687
|
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Serializes headers to a format suitable for HTTP execution.
|
|
1690
|
+
*
|
|
1691
|
+
* @returns Serialized headers as HeadersInit, or undefined if no headers
|
|
1692
|
+
*/
|
|
1156
1693
|
getHeaders() {
|
|
1157
1694
|
if (!this.headers || !this.headers.size) {
|
|
1158
1695
|
return void 0;
|
|
1159
1696
|
}
|
|
1160
1697
|
return new HeaderSerializer().serialize(this.headers);
|
|
1161
1698
|
}
|
|
1699
|
+
/**
|
|
1700
|
+
* Serializes cookies to a format suitable for HTTP execution.
|
|
1701
|
+
*
|
|
1702
|
+
* @returns Serialized cookies as a record, or undefined if no cookies
|
|
1703
|
+
*/
|
|
1704
|
+
getCookies() {
|
|
1705
|
+
if (!this.cookies || !this.cookies.size) {
|
|
1706
|
+
return void 0;
|
|
1707
|
+
}
|
|
1708
|
+
return new CookieSerializer().serialize(this.cookies);
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Advances pagination parameters to fetch the next page.
|
|
1712
|
+
* Handles both cursor-based and limit-offset pagination strategies.
|
|
1713
|
+
*
|
|
1714
|
+
* @param cursor - The cursor value for cursor-based pagination (optional for limit-offset)
|
|
1715
|
+
*/
|
|
1162
1716
|
nextPage(cursor) {
|
|
1163
1717
|
if (!this.pagination) {
|
|
1164
1718
|
return;
|
|
@@ -1200,6 +1754,9 @@ var Request = class {
|
|
|
1200
1754
|
this.pathParams.forEach((val, _) => {
|
|
1201
1755
|
allParams.push(val);
|
|
1202
1756
|
});
|
|
1757
|
+
this.cookies.forEach((val, _) => {
|
|
1758
|
+
allParams.push(val);
|
|
1759
|
+
});
|
|
1203
1760
|
return allParams;
|
|
1204
1761
|
}
|
|
1205
1762
|
};
|
|
@@ -1212,6 +1769,10 @@ var Environment = /* @__PURE__ */ ((Environment2) => {
|
|
|
1212
1769
|
|
|
1213
1770
|
// src/http/transport/request-builder.ts
|
|
1214
1771
|
var RequestBuilder = class {
|
|
1772
|
+
/**
|
|
1773
|
+
* Creates a new request builder with default configuration.
|
|
1774
|
+
* Initializes retry settings, validation options, and empty parameter collections.
|
|
1775
|
+
*/
|
|
1215
1776
|
constructor() {
|
|
1216
1777
|
this.params = {
|
|
1217
1778
|
baseUrl: "https://api.celitech.net/v1" /* DEFAULT */,
|
|
@@ -1232,6 +1793,7 @@ var RequestBuilder = class {
|
|
|
1232
1793
|
pathParams: /* @__PURE__ */ new Map(),
|
|
1233
1794
|
queryParams: /* @__PURE__ */ new Map(),
|
|
1234
1795
|
headers: /* @__PURE__ */ new Map(),
|
|
1796
|
+
cookies: /* @__PURE__ */ new Map(),
|
|
1235
1797
|
tokenManager: new OAuthTokenManager()
|
|
1236
1798
|
};
|
|
1237
1799
|
}
|
|
@@ -1429,9 +1991,37 @@ var RequestBuilder = class {
|
|
|
1429
1991
|
});
|
|
1430
1992
|
return this;
|
|
1431
1993
|
}
|
|
1994
|
+
addCookieParam(param) {
|
|
1995
|
+
var _a, _b, _c;
|
|
1996
|
+
if (param.value === void 0 || param.key === void 0) {
|
|
1997
|
+
return this;
|
|
1998
|
+
}
|
|
1999
|
+
this.params.cookies.set(param.key, {
|
|
2000
|
+
key: param.key,
|
|
2001
|
+
value: param.value,
|
|
2002
|
+
explode: (_a = param.explode) != null ? _a : true,
|
|
2003
|
+
style: (_b = param.style) != null ? _b : "form" /* FORM */,
|
|
2004
|
+
encode: (_c = param.encode) != null ? _c : false,
|
|
2005
|
+
isLimit: !!param.isLimit,
|
|
2006
|
+
isOffset: !!param.isOffset,
|
|
2007
|
+
isCursor: !!param.isCursor
|
|
2008
|
+
});
|
|
2009
|
+
return this;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Builds and returns the configured Request object.
|
|
2013
|
+
* Call this method after configuring all request parameters.
|
|
2014
|
+
* @returns A new Request instance with all configured parameters
|
|
2015
|
+
*/
|
|
1432
2016
|
build() {
|
|
1433
2017
|
return new Request(this.params);
|
|
1434
2018
|
}
|
|
2019
|
+
/**
|
|
2020
|
+
* Converts a string to Base64 encoding.
|
|
2021
|
+
* Works in both Node.js and browser environments.
|
|
2022
|
+
* @param str - The string to encode
|
|
2023
|
+
* @returns The Base64-encoded string
|
|
2024
|
+
*/
|
|
1435
2025
|
toBase64(str) {
|
|
1436
2026
|
if (typeof window === "undefined") {
|
|
1437
2027
|
return Buffer.from(str, "utf-8").toString("base64");
|
|
@@ -1530,11 +2120,22 @@ var GrantType = /* @__PURE__ */ ((GrantType2) => {
|
|
|
1530
2120
|
|
|
1531
2121
|
// src/http/oauth/token-manager.ts
|
|
1532
2122
|
var OAuthToken = class {
|
|
2123
|
+
/**
|
|
2124
|
+
* Creates a new OAuth token.
|
|
2125
|
+
* @param accessToken - The access token string
|
|
2126
|
+
* @param scopes - Set of OAuth scopes granted to this token
|
|
2127
|
+
* @param expiresAt - Timestamp when the token expires (milliseconds since epoch), or null if no expiration
|
|
2128
|
+
*/
|
|
1533
2129
|
constructor(accessToken, scopes, expiresAt) {
|
|
1534
2130
|
this.accessToken = accessToken;
|
|
1535
2131
|
this.scopes = scopes;
|
|
1536
2132
|
this.expiresAt = expiresAt;
|
|
1537
2133
|
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Checks if this token has all the required scopes.
|
|
2136
|
+
* @param scopes - Set of scopes to check for
|
|
2137
|
+
* @returns True if the token has all required scopes, false otherwise
|
|
2138
|
+
*/
|
|
1538
2139
|
hasAllScopes(scopes) {
|
|
1539
2140
|
for (const scope of scopes) {
|
|
1540
2141
|
if (!this.scopes.has(scope)) {
|
|
@@ -1545,6 +2146,14 @@ var OAuthToken = class {
|
|
|
1545
2146
|
}
|
|
1546
2147
|
};
|
|
1547
2148
|
var OAuthTokenManager = class {
|
|
2149
|
+
/**
|
|
2150
|
+
* Gets a valid access token for the specified scopes.
|
|
2151
|
+
* Returns a cached token if available and not expired, otherwise requests a new one.
|
|
2152
|
+
* @param scopes - Set of OAuth scopes required for the token
|
|
2153
|
+
* @param config - SDK configuration containing client credentials
|
|
2154
|
+
* @returns A promise that resolves to a valid OAuth token
|
|
2155
|
+
* @throws Error if client credentials are missing or token request fails
|
|
2156
|
+
*/
|
|
1548
2157
|
async getToken(scopes, config) {
|
|
1549
2158
|
var _a, _b, _c, _d, _e, _f;
|
|
1550
2159
|
if (((_a = this.token) == null ? void 0 : _a.hasAllScopes(scopes)) && ((_b = this.token) == null ? void 0 : _b.expiresAt) && this.token.expiresAt - Date.now() > 5e3) {
|
|
@@ -1652,11 +2261,21 @@ var import_zod8 = require("zod");
|
|
|
1652
2261
|
|
|
1653
2262
|
// src/http/errors/throwable-error.ts
|
|
1654
2263
|
var ThrowableError = class extends Error {
|
|
2264
|
+
/**
|
|
2265
|
+
* Creates a new throwable error.
|
|
2266
|
+
* @param message - The error message
|
|
2267
|
+
* @param response - Optional response data associated with the error
|
|
2268
|
+
*/
|
|
1655
2269
|
constructor(message, response) {
|
|
1656
2270
|
super(message);
|
|
1657
2271
|
this.message = message;
|
|
1658
2272
|
this.response = response;
|
|
1659
2273
|
}
|
|
2274
|
+
/**
|
|
2275
|
+
* Throws this error instance.
|
|
2276
|
+
* Convenience method for explicitly throwing the error.
|
|
2277
|
+
* @throws This error instance
|
|
2278
|
+
*/
|
|
1660
2279
|
throw() {
|
|
1661
2280
|
throw this;
|
|
1662
2281
|
}
|
|
@@ -1744,6 +2363,7 @@ var packages = import_zod11.z.lazy(() => {
|
|
|
1744
2363
|
destination: import_zod11.z.string(),
|
|
1745
2364
|
destinationIso2: import_zod11.z.string(),
|
|
1746
2365
|
dataLimitInBytes: import_zod11.z.number(),
|
|
2366
|
+
dataLimitInGb: import_zod11.z.number(),
|
|
1747
2367
|
minDays: import_zod11.z.number(),
|
|
1748
2368
|
maxDays: import_zod11.z.number(),
|
|
1749
2369
|
priceInCents: import_zod11.z.number()
|
|
@@ -1755,6 +2375,7 @@ var packagesResponse = import_zod11.z.lazy(() => {
|
|
|
1755
2375
|
destination: import_zod11.z.string(),
|
|
1756
2376
|
destinationISO2: import_zod11.z.string(),
|
|
1757
2377
|
dataLimitInBytes: import_zod11.z.number(),
|
|
2378
|
+
dataLimitInGB: import_zod11.z.number(),
|
|
1758
2379
|
minDays: import_zod11.z.number(),
|
|
1759
2380
|
maxDays: import_zod11.z.number(),
|
|
1760
2381
|
priceInCents: import_zod11.z.number()
|
|
@@ -1763,6 +2384,7 @@ var packagesResponse = import_zod11.z.lazy(() => {
|
|
|
1763
2384
|
destination: data["destination"],
|
|
1764
2385
|
destinationIso2: data["destinationISO2"],
|
|
1765
2386
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2387
|
+
dataLimitInGb: data["dataLimitInGB"],
|
|
1766
2388
|
minDays: data["minDays"],
|
|
1767
2389
|
maxDays: data["maxDays"],
|
|
1768
2390
|
priceInCents: data["priceInCents"]
|
|
@@ -1774,6 +2396,7 @@ var packagesRequest = import_zod11.z.lazy(() => {
|
|
|
1774
2396
|
destination: import_zod11.z.string(),
|
|
1775
2397
|
destinationIso2: import_zod11.z.string(),
|
|
1776
2398
|
dataLimitInBytes: import_zod11.z.number(),
|
|
2399
|
+
dataLimitInGb: import_zod11.z.number(),
|
|
1777
2400
|
minDays: import_zod11.z.number(),
|
|
1778
2401
|
maxDays: import_zod11.z.number(),
|
|
1779
2402
|
priceInCents: import_zod11.z.number()
|
|
@@ -1782,6 +2405,7 @@ var packagesRequest = import_zod11.z.lazy(() => {
|
|
|
1782
2405
|
destination: data["destination"],
|
|
1783
2406
|
destinationISO2: data["destinationIso2"],
|
|
1784
2407
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2408
|
+
dataLimitInGB: data["dataLimitInGb"],
|
|
1785
2409
|
minDays: data["minDays"],
|
|
1786
2410
|
maxDays: data["maxDays"],
|
|
1787
2411
|
priceInCents: data["priceInCents"]
|
|
@@ -1883,7 +2507,8 @@ var createPurchaseV2Request = import_zod14.z.lazy(() => {
|
|
|
1883
2507
|
email: import_zod14.z.string().optional(),
|
|
1884
2508
|
referenceId: import_zod14.z.string().optional(),
|
|
1885
2509
|
networkBrand: import_zod14.z.string().optional(),
|
|
1886
|
-
emailBrand: import_zod14.z.string().optional()
|
|
2510
|
+
emailBrand: import_zod14.z.string().optional(),
|
|
2511
|
+
language: import_zod14.z.string().optional()
|
|
1887
2512
|
});
|
|
1888
2513
|
});
|
|
1889
2514
|
var createPurchaseV2RequestResponse = import_zod14.z.lazy(() => {
|
|
@@ -1897,7 +2522,8 @@ var createPurchaseV2RequestResponse = import_zod14.z.lazy(() => {
|
|
|
1897
2522
|
email: import_zod14.z.string().optional(),
|
|
1898
2523
|
referenceId: import_zod14.z.string().optional(),
|
|
1899
2524
|
networkBrand: import_zod14.z.string().optional(),
|
|
1900
|
-
emailBrand: import_zod14.z.string().optional()
|
|
2525
|
+
emailBrand: import_zod14.z.string().optional(),
|
|
2526
|
+
language: import_zod14.z.string().optional()
|
|
1901
2527
|
}).transform((data) => ({
|
|
1902
2528
|
destination: data["destination"],
|
|
1903
2529
|
dataLimitInGb: data["dataLimitInGB"],
|
|
@@ -1908,7 +2534,8 @@ var createPurchaseV2RequestResponse = import_zod14.z.lazy(() => {
|
|
|
1908
2534
|
email: data["email"],
|
|
1909
2535
|
referenceId: data["referenceId"],
|
|
1910
2536
|
networkBrand: data["networkBrand"],
|
|
1911
|
-
emailBrand: data["emailBrand"]
|
|
2537
|
+
emailBrand: data["emailBrand"],
|
|
2538
|
+
language: data["language"]
|
|
1912
2539
|
}));
|
|
1913
2540
|
});
|
|
1914
2541
|
var createPurchaseV2RequestRequest = import_zod14.z.lazy(() => {
|
|
@@ -1922,7 +2549,8 @@ var createPurchaseV2RequestRequest = import_zod14.z.lazy(() => {
|
|
|
1922
2549
|
email: import_zod14.z.string().optional(),
|
|
1923
2550
|
referenceId: import_zod14.z.string().optional(),
|
|
1924
2551
|
networkBrand: import_zod14.z.string().optional(),
|
|
1925
|
-
emailBrand: import_zod14.z.string().optional()
|
|
2552
|
+
emailBrand: import_zod14.z.string().optional(),
|
|
2553
|
+
language: import_zod14.z.string().optional()
|
|
1926
2554
|
}).transform((data) => ({
|
|
1927
2555
|
destination: data["destination"],
|
|
1928
2556
|
dataLimitInGB: data["dataLimitInGb"],
|
|
@@ -1933,7 +2561,8 @@ var createPurchaseV2RequestRequest = import_zod14.z.lazy(() => {
|
|
|
1933
2561
|
email: data["email"],
|
|
1934
2562
|
referenceId: data["referenceId"],
|
|
1935
2563
|
networkBrand: data["networkBrand"],
|
|
1936
|
-
emailBrand: data["emailBrand"]
|
|
2564
|
+
emailBrand: data["emailBrand"],
|
|
2565
|
+
language: data["language"]
|
|
1937
2566
|
}));
|
|
1938
2567
|
});
|
|
1939
2568
|
|
|
@@ -1978,29 +2607,39 @@ var createPurchaseV2OkResponseProfile = import_zod16.z.lazy(() => {
|
|
|
1978
2607
|
return import_zod16.z.object({
|
|
1979
2608
|
iccid: import_zod16.z.string().min(18).max(22),
|
|
1980
2609
|
activationCode: import_zod16.z.string().min(1e3).max(8e3),
|
|
1981
|
-
manualActivationCode: import_zod16.z.string()
|
|
2610
|
+
manualActivationCode: import_zod16.z.string(),
|
|
2611
|
+
iosActivationLink: import_zod16.z.string(),
|
|
2612
|
+
androidActivationLink: import_zod16.z.string()
|
|
1982
2613
|
});
|
|
1983
2614
|
});
|
|
1984
2615
|
var createPurchaseV2OkResponseProfileResponse = import_zod16.z.lazy(() => {
|
|
1985
2616
|
return import_zod16.z.object({
|
|
1986
2617
|
iccid: import_zod16.z.string().min(18).max(22),
|
|
1987
2618
|
activationCode: import_zod16.z.string().min(1e3).max(8e3),
|
|
1988
|
-
manualActivationCode: import_zod16.z.string()
|
|
2619
|
+
manualActivationCode: import_zod16.z.string(),
|
|
2620
|
+
iosActivationLink: import_zod16.z.string(),
|
|
2621
|
+
androidActivationLink: import_zod16.z.string()
|
|
1989
2622
|
}).transform((data) => ({
|
|
1990
2623
|
iccid: data["iccid"],
|
|
1991
2624
|
activationCode: data["activationCode"],
|
|
1992
|
-
manualActivationCode: data["manualActivationCode"]
|
|
2625
|
+
manualActivationCode: data["manualActivationCode"],
|
|
2626
|
+
iosActivationLink: data["iosActivationLink"],
|
|
2627
|
+
androidActivationLink: data["androidActivationLink"]
|
|
1993
2628
|
}));
|
|
1994
2629
|
});
|
|
1995
2630
|
var createPurchaseV2OkResponseProfileRequest = import_zod16.z.lazy(() => {
|
|
1996
2631
|
return import_zod16.z.object({
|
|
1997
2632
|
iccid: import_zod16.z.string().min(18).max(22),
|
|
1998
2633
|
activationCode: import_zod16.z.string().min(1e3).max(8e3),
|
|
1999
|
-
manualActivationCode: import_zod16.z.string()
|
|
2634
|
+
manualActivationCode: import_zod16.z.string(),
|
|
2635
|
+
iosActivationLink: import_zod16.z.string(),
|
|
2636
|
+
androidActivationLink: import_zod16.z.string()
|
|
2000
2637
|
}).transform((data) => ({
|
|
2001
2638
|
iccid: data["iccid"],
|
|
2002
2639
|
activationCode: data["activationCode"],
|
|
2003
|
-
manualActivationCode: data["manualActivationCode"]
|
|
2640
|
+
manualActivationCode: data["manualActivationCode"],
|
|
2641
|
+
iosActivationLink: data["iosActivationLink"],
|
|
2642
|
+
androidActivationLink: data["androidActivationLink"]
|
|
2004
2643
|
}));
|
|
2005
2644
|
});
|
|
2006
2645
|
|
|
@@ -2042,6 +2681,7 @@ var package_ = import_zod18.z.lazy(() => {
|
|
|
2042
2681
|
return import_zod18.z.object({
|
|
2043
2682
|
id: import_zod18.z.string(),
|
|
2044
2683
|
dataLimitInBytes: import_zod18.z.number(),
|
|
2684
|
+
dataLimitInGb: import_zod18.z.number(),
|
|
2045
2685
|
destination: import_zod18.z.string(),
|
|
2046
2686
|
destinationIso2: import_zod18.z.string(),
|
|
2047
2687
|
destinationName: import_zod18.z.string(),
|
|
@@ -2052,6 +2692,7 @@ var packageResponse = import_zod18.z.lazy(() => {
|
|
|
2052
2692
|
return import_zod18.z.object({
|
|
2053
2693
|
id: import_zod18.z.string(),
|
|
2054
2694
|
dataLimitInBytes: import_zod18.z.number(),
|
|
2695
|
+
dataLimitInGB: import_zod18.z.number(),
|
|
2055
2696
|
destination: import_zod18.z.string(),
|
|
2056
2697
|
destinationISO2: import_zod18.z.string(),
|
|
2057
2698
|
destinationName: import_zod18.z.string(),
|
|
@@ -2059,6 +2700,7 @@ var packageResponse = import_zod18.z.lazy(() => {
|
|
|
2059
2700
|
}).transform((data) => ({
|
|
2060
2701
|
id: data["id"],
|
|
2061
2702
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2703
|
+
dataLimitInGb: data["dataLimitInGB"],
|
|
2062
2704
|
destination: data["destination"],
|
|
2063
2705
|
destinationIso2: data["destinationISO2"],
|
|
2064
2706
|
destinationName: data["destinationName"],
|
|
@@ -2069,6 +2711,7 @@ var packageRequest = import_zod18.z.lazy(() => {
|
|
|
2069
2711
|
return import_zod18.z.object({
|
|
2070
2712
|
id: import_zod18.z.string(),
|
|
2071
2713
|
dataLimitInBytes: import_zod18.z.number(),
|
|
2714
|
+
dataLimitInGb: import_zod18.z.number(),
|
|
2072
2715
|
destination: import_zod18.z.string(),
|
|
2073
2716
|
destinationIso2: import_zod18.z.string(),
|
|
2074
2717
|
destinationName: import_zod18.z.string(),
|
|
@@ -2076,6 +2719,7 @@ var packageRequest = import_zod18.z.lazy(() => {
|
|
|
2076
2719
|
}).transform((data) => ({
|
|
2077
2720
|
id: data["id"],
|
|
2078
2721
|
dataLimitInBytes: data["dataLimitInBytes"],
|
|
2722
|
+
dataLimitInGB: data["dataLimitInGb"],
|
|
2079
2723
|
destination: data["destination"],
|
|
2080
2724
|
destinationISO2: data["destinationIso2"],
|
|
2081
2725
|
destinationName: data["destinationName"],
|
|
@@ -2224,6 +2868,7 @@ var createPurchaseRequest = import_zod22.z.lazy(() => {
|
|
|
2224
2868
|
referenceId: import_zod22.z.string().optional(),
|
|
2225
2869
|
networkBrand: import_zod22.z.string().optional(),
|
|
2226
2870
|
emailBrand: import_zod22.z.string().optional(),
|
|
2871
|
+
language: import_zod22.z.string().optional(),
|
|
2227
2872
|
startTime: import_zod22.z.number().optional(),
|
|
2228
2873
|
endTime: import_zod22.z.number().optional()
|
|
2229
2874
|
});
|
|
@@ -2238,6 +2883,7 @@ var createPurchaseRequestResponse = import_zod22.z.lazy(() => {
|
|
|
2238
2883
|
referenceId: import_zod22.z.string().optional(),
|
|
2239
2884
|
networkBrand: import_zod22.z.string().optional(),
|
|
2240
2885
|
emailBrand: import_zod22.z.string().optional(),
|
|
2886
|
+
language: import_zod22.z.string().optional(),
|
|
2241
2887
|
startTime: import_zod22.z.number().optional(),
|
|
2242
2888
|
endTime: import_zod22.z.number().optional()
|
|
2243
2889
|
}).transform((data) => ({
|
|
@@ -2249,6 +2895,7 @@ var createPurchaseRequestResponse = import_zod22.z.lazy(() => {
|
|
|
2249
2895
|
referenceId: data["referenceId"],
|
|
2250
2896
|
networkBrand: data["networkBrand"],
|
|
2251
2897
|
emailBrand: data["emailBrand"],
|
|
2898
|
+
language: data["language"],
|
|
2252
2899
|
startTime: data["startTime"],
|
|
2253
2900
|
endTime: data["endTime"]
|
|
2254
2901
|
}));
|
|
@@ -2263,6 +2910,7 @@ var createPurchaseRequestRequest = import_zod22.z.lazy(() => {
|
|
|
2263
2910
|
referenceId: import_zod22.z.string().optional(),
|
|
2264
2911
|
networkBrand: import_zod22.z.string().optional(),
|
|
2265
2912
|
emailBrand: import_zod22.z.string().optional(),
|
|
2913
|
+
language: import_zod22.z.string().optional(),
|
|
2266
2914
|
startTime: import_zod22.z.number().optional(),
|
|
2267
2915
|
endTime: import_zod22.z.number().optional()
|
|
2268
2916
|
}).transform((data) => ({
|
|
@@ -2274,6 +2922,7 @@ var createPurchaseRequestRequest = import_zod22.z.lazy(() => {
|
|
|
2274
2922
|
referenceId: data["referenceId"],
|
|
2275
2923
|
networkBrand: data["networkBrand"],
|
|
2276
2924
|
emailBrand: data["emailBrand"],
|
|
2925
|
+
language: data["language"],
|
|
2277
2926
|
startTime: data["startTime"],
|
|
2278
2927
|
endTime: data["endTime"]
|
|
2279
2928
|
}));
|
|
@@ -2651,24 +3300,29 @@ var import_zod32 = require("zod");
|
|
|
2651
3300
|
var getPurchaseConsumptionOkResponse = import_zod32.z.lazy(() => {
|
|
2652
3301
|
return import_zod32.z.object({
|
|
2653
3302
|
dataUsageRemainingInBytes: import_zod32.z.number(),
|
|
3303
|
+
dataUsageRemainingInGb: import_zod32.z.number(),
|
|
2654
3304
|
status: import_zod32.z.string()
|
|
2655
3305
|
});
|
|
2656
3306
|
});
|
|
2657
3307
|
var getPurchaseConsumptionOkResponseResponse = import_zod32.z.lazy(() => {
|
|
2658
3308
|
return import_zod32.z.object({
|
|
2659
3309
|
dataUsageRemainingInBytes: import_zod32.z.number(),
|
|
3310
|
+
dataUsageRemainingInGB: import_zod32.z.number(),
|
|
2660
3311
|
status: import_zod32.z.string()
|
|
2661
3312
|
}).transform((data) => ({
|
|
2662
3313
|
dataUsageRemainingInBytes: data["dataUsageRemainingInBytes"],
|
|
3314
|
+
dataUsageRemainingInGb: data["dataUsageRemainingInGB"],
|
|
2663
3315
|
status: data["status"]
|
|
2664
3316
|
}));
|
|
2665
3317
|
});
|
|
2666
3318
|
var getPurchaseConsumptionOkResponseRequest = import_zod32.z.lazy(() => {
|
|
2667
3319
|
return import_zod32.z.object({
|
|
2668
3320
|
dataUsageRemainingInBytes: import_zod32.z.number(),
|
|
3321
|
+
dataUsageRemainingInGb: import_zod32.z.number(),
|
|
2669
3322
|
status: import_zod32.z.string()
|
|
2670
3323
|
}).transform((data) => ({
|
|
2671
3324
|
dataUsageRemainingInBytes: data["dataUsageRemainingInBytes"],
|
|
3325
|
+
dataUsageRemainingInGB: data["dataUsageRemainingInGb"],
|
|
2672
3326
|
status: data["status"]
|
|
2673
3327
|
}));
|
|
2674
3328
|
});
|
|
@@ -2854,6 +3508,26 @@ var PurchasesService = class extends BaseService {
|
|
|
2854
3508
|
}
|
|
2855
3509
|
};
|
|
2856
3510
|
|
|
3511
|
+
// src/services/purchases/models/create-purchase-v2-request-language.ts
|
|
3512
|
+
var CreatePurchaseV2RequestLanguage = /* @__PURE__ */ ((CreatePurchaseV2RequestLanguage2) => {
|
|
3513
|
+
CreatePurchaseV2RequestLanguage2["EN"] = "en";
|
|
3514
|
+
CreatePurchaseV2RequestLanguage2["ES"] = "es";
|
|
3515
|
+
CreatePurchaseV2RequestLanguage2["FR"] = "fr";
|
|
3516
|
+
CreatePurchaseV2RequestLanguage2["DE"] = "de";
|
|
3517
|
+
CreatePurchaseV2RequestLanguage2["PT_BR"] = "pt-br";
|
|
3518
|
+
return CreatePurchaseV2RequestLanguage2;
|
|
3519
|
+
})(CreatePurchaseV2RequestLanguage || {});
|
|
3520
|
+
|
|
3521
|
+
// src/services/purchases/models/create-purchase-request-language.ts
|
|
3522
|
+
var CreatePurchaseRequestLanguage = /* @__PURE__ */ ((CreatePurchaseRequestLanguage2) => {
|
|
3523
|
+
CreatePurchaseRequestLanguage2["EN"] = "en";
|
|
3524
|
+
CreatePurchaseRequestLanguage2["ES"] = "es";
|
|
3525
|
+
CreatePurchaseRequestLanguage2["FR"] = "fr";
|
|
3526
|
+
CreatePurchaseRequestLanguage2["DE"] = "de";
|
|
3527
|
+
CreatePurchaseRequestLanguage2["PT_BR"] = "pt-br";
|
|
3528
|
+
return CreatePurchaseRequestLanguage2;
|
|
3529
|
+
})(CreatePurchaseRequestLanguage || {});
|
|
3530
|
+
|
|
2857
3531
|
// src/services/e-sim/e-sim-service.ts
|
|
2858
3532
|
var import_zod41 = require("zod");
|
|
2859
3533
|
|
|
@@ -3272,6 +3946,8 @@ var Celitech = class {
|
|
|
3272
3946
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3273
3947
|
0 && (module.exports = {
|
|
3274
3948
|
Celitech,
|
|
3949
|
+
CreatePurchaseRequestLanguage,
|
|
3950
|
+
CreatePurchaseV2RequestLanguage,
|
|
3275
3951
|
DestinationsService,
|
|
3276
3952
|
ESimService,
|
|
3277
3953
|
Environment,
|