celitech-sdk 2.0.6 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts +200 -211
- package/dist/index.js +117 -30
- package/dist/index.mjs +117 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Celitech TypeScript SDK 2.0.
|
|
1
|
+
# Celitech TypeScript SDK 2.0.7
|
|
2
2
|
|
|
3
3
|
Welcome to the Celitech SDK documentation. This guide will help you get started with integrating and using the Celitech SDK in your project.
|
|
4
4
|
|
|
5
5
|
## Versions
|
|
6
6
|
|
|
7
|
-
- API version: `2.0.
|
|
8
|
-
- SDK version: `2.0.
|
|
7
|
+
- API version: `2.0.7`
|
|
8
|
+
- SDK version: `2.0.7`
|
|
9
9
|
|
|
10
10
|
## About the API
|
|
11
11
|
|
package/dist/index.d.ts
CHANGED
|
@@ -182,6 +182,20 @@ declare class ThrowableError extends Error {
|
|
|
182
182
|
* @param response - Optional response data associated with the error
|
|
183
183
|
*/
|
|
184
184
|
constructor(message: string, response?: unknown);
|
|
185
|
+
/**
|
|
186
|
+
* Creates an error instance from a response body.
|
|
187
|
+
* Parsing (which can throw) is kept out of the constructor so that constructing
|
|
188
|
+
* an error while handling an error response never throws. The base implementation
|
|
189
|
+
* simply constructs the instance; subclasses may override to populate typed fields.
|
|
190
|
+
*
|
|
191
|
+
* Contract: every subclass constructor must accept `(message, response?)`. The base
|
|
192
|
+
* uses `new this(message, response)`, so a subclass with a different constructor
|
|
193
|
+
* signature must override `from()`.
|
|
194
|
+
* @param message - The error message
|
|
195
|
+
* @param response - Optional response data associated with the error
|
|
196
|
+
* @returns A new error instance
|
|
197
|
+
*/
|
|
198
|
+
static from(message: string, response?: unknown): ThrowableError;
|
|
185
199
|
/**
|
|
186
200
|
* Throws this error instance.
|
|
187
201
|
* Convenience method for explicitly throwing the error.
|
|
@@ -207,8 +221,10 @@ interface ResponseDefinition {
|
|
|
207
221
|
* Used to throw typed errors based on content type and status code.
|
|
208
222
|
*/
|
|
209
223
|
interface ErrorDefinition {
|
|
210
|
-
/**
|
|
211
|
-
error: new (...args: any[]) => ThrowableError
|
|
224
|
+
/** The error class to instantiate, exposing a static `from` factory */
|
|
225
|
+
error: (new (...args: any[]) => ThrowableError) & {
|
|
226
|
+
from(message: string, response?: unknown): ThrowableError;
|
|
227
|
+
};
|
|
212
228
|
/** The content type of this error response */
|
|
213
229
|
contentType: ContentType;
|
|
214
230
|
/** The HTTP status code this error applies to */
|
|
@@ -469,8 +485,11 @@ interface CursorPaginatedHttpResponse<T = unknown> extends HttpResponse<T> {
|
|
|
469
485
|
declare enum ContentType {
|
|
470
486
|
/** JSON format (application/json) */
|
|
471
487
|
Json = "json",
|
|
472
|
-
/**
|
|
473
|
-
|
|
488
|
+
/**
|
|
489
|
+
* @deprecated XML is handled as text. Use {@link ContentType.Text} instead.
|
|
490
|
+
* Kept as an alias for backward compatibility; will be removed in a future major version.
|
|
491
|
+
*/
|
|
492
|
+
Xml = "text",
|
|
474
493
|
/** PDF document (application/pdf) */
|
|
475
494
|
Pdf = "pdf",
|
|
476
495
|
/** Image file (image/*) */
|
|
@@ -496,6 +515,7 @@ interface RetryOptions {
|
|
|
496
515
|
maxDelayMs?: number;
|
|
497
516
|
backoffFactor?: number;
|
|
498
517
|
jitterMs?: number;
|
|
518
|
+
maxRetryAfterDelayMs?: number;
|
|
499
519
|
statusCodesToRetry?: number[];
|
|
500
520
|
httpMethodsToRetry?: HttpMethod[];
|
|
501
521
|
}
|
|
@@ -726,9 +746,8 @@ declare const listDestinationsOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
726
746
|
}[];
|
|
727
747
|
}>>;
|
|
728
748
|
/**
|
|
729
|
-
*
|
|
730
|
-
* @
|
|
731
|
-
* @property {Destinations[]}
|
|
749
|
+
* @typedef {ListDestinationsOkResponse} listDestinationsOkResponse
|
|
750
|
+
* @property {Destinations[]} destinations
|
|
732
751
|
*/
|
|
733
752
|
type ListDestinationsOkResponse = z.infer<typeof listDestinationsOkResponse>;
|
|
734
753
|
|
|
@@ -775,12 +794,11 @@ declare const destinations: z.ZodLazy<z.ZodObject<{
|
|
|
775
794
|
supportedCountries: string[];
|
|
776
795
|
}>>;
|
|
777
796
|
/**
|
|
778
|
-
*
|
|
779
|
-
* @
|
|
780
|
-
* @property {string} -
|
|
781
|
-
* @property {string} -
|
|
782
|
-
* @property {string} -
|
|
783
|
-
* @property {string[]} - This array indicates the geographical area covered by a specific destination. If the destination represents a single country, the array will include that country. However, if the destination represents a broader regional scope, the array will be populated with the names of the countries belonging to that region.
|
|
797
|
+
* @typedef {Destinations} destinations
|
|
798
|
+
* @property {string} name - Name of the destination
|
|
799
|
+
* @property {string} destination - ISO3 representation of the destination
|
|
800
|
+
* @property {string} destinationIso2 - ISO2 representation of the destination
|
|
801
|
+
* @property {string[]} supportedCountries - This array indicates the geographical area covered by a specific destination. If the destination represents a single country, the array will include that country. However, if the destination represents a broader regional scope, the array will be populated with the names of the countries belonging to that region.
|
|
784
802
|
*/
|
|
785
803
|
type Destinations = z.infer<typeof destinations>;
|
|
786
804
|
|
|
@@ -845,10 +863,9 @@ declare const listPackagesOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
845
863
|
afterCursor: string | null;
|
|
846
864
|
}>>;
|
|
847
865
|
/**
|
|
848
|
-
*
|
|
849
|
-
* @
|
|
850
|
-
* @property {
|
|
851
|
-
* @property {string} - The cursor value representing the end of the current page of results. Use this cursor value as the "afterCursor" parameter in your next request to retrieve the subsequent page of results. It ensures that you continue fetching data from where you left off, facilitating smooth pagination
|
|
866
|
+
* @typedef {ListPackagesOkResponse} listPackagesOkResponse
|
|
867
|
+
* @property {Packages[]} packages
|
|
868
|
+
* @property {string} afterCursor - The cursor value representing the end of the current page of results. Use this cursor value as the "afterCursor" parameter in your next request to retrieve the subsequent page of results. It ensures that you continue fetching data from where you left off, facilitating smooth pagination
|
|
852
869
|
*/
|
|
853
870
|
type ListPackagesOkResponse = z.infer<typeof listPackagesOkResponse>;
|
|
854
871
|
|
|
@@ -928,16 +945,15 @@ declare const packages: z.ZodLazy<z.ZodObject<{
|
|
|
928
945
|
priceInCents: number;
|
|
929
946
|
}>>;
|
|
930
947
|
/**
|
|
931
|
-
*
|
|
932
|
-
* @
|
|
933
|
-
* @property {string} -
|
|
934
|
-
* @property {string} -
|
|
935
|
-
* @property {
|
|
936
|
-
* @property {number} - Size of the package in
|
|
937
|
-
* @property {number} -
|
|
938
|
-
* @property {number} -
|
|
939
|
-
* @property {number} -
|
|
940
|
-
* @property {number} - Price of the package in cents
|
|
948
|
+
* @typedef {Packages} packages
|
|
949
|
+
* @property {string} id - ID of the package
|
|
950
|
+
* @property {string} destination - ISO3 representation of the package's destination.
|
|
951
|
+
* @property {string} destinationIso2 - ISO2 representation of the package's destination.
|
|
952
|
+
* @property {number} dataLimitInBytes - Size of the package in Bytes. A value of `-1` indicates an unlimited package.
|
|
953
|
+
* @property {number} dataLimitInGb - Size of the package in GB. A value of `-1` indicates an unlimited (date-based) package.
|
|
954
|
+
* @property {number} minDays - Min number of days for the package
|
|
955
|
+
* @property {number} maxDays - Max number of days for the package
|
|
956
|
+
* @property {number} priceInCents - Price of the package in cents
|
|
941
957
|
*/
|
|
942
958
|
type Packages = z.infer<typeof packages>;
|
|
943
959
|
|
|
@@ -984,19 +1000,18 @@ declare const createPurchaseV2Request: z.ZodLazy<z.ZodObject<{
|
|
|
984
1000
|
language?: string | undefined;
|
|
985
1001
|
}>>;
|
|
986
1002
|
/**
|
|
987
|
-
*
|
|
988
|
-
* @
|
|
989
|
-
* @property {
|
|
990
|
-
* @property {
|
|
991
|
-
* @property {string} -
|
|
992
|
-
* @property {
|
|
993
|
-
* @property {number} -
|
|
994
|
-
* @property {
|
|
995
|
-
* @property {string} -
|
|
996
|
-
* @property {string} -
|
|
997
|
-
* @property {string} - Customize the
|
|
998
|
-
* @property {
|
|
999
|
-
* @property {CreatePurchaseV2RequestLanguage} - Language of the confirmation email sent to the customer.
|
|
1003
|
+
* @typedef {CreatePurchaseV2Request} createPurchaseV2Request
|
|
1004
|
+
* @property {string} destination - ISO representation of the package's destination. Supports both ISO2 (e.g., 'FR') and ISO3 (e.g., 'FRA') country codes.
|
|
1005
|
+
* @property {number} dataLimitInGb - Size of the package in GB. The available options are 0.5, 1, 2, 3, 5, 8, 20, 50GB. Use `-1` to purchase an unlimited (date-based) package — provide `startDate`/`endDate` spanning 3 to 30 days (`duration` is not supported for unlimited packages).
|
|
1006
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-dd'. This date can be set to the current day or any day within the next 12 months.
|
|
1007
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-dd'. End date can be maximum 90 days after Start date.
|
|
1008
|
+
* @property {number} duration - Duration of the package in days. Available values are 1, 2, 7, 14, 30, or 90. Either provide startDate/endDate or duration. Not supported for unlimited packages (`dataLimitInGB` = -1), which are date-based — provide startDate/endDate instead.
|
|
1009
|
+
* @property {number} quantity - Number of eSIMs to purchase.
|
|
1010
|
+
* @property {string} email - Email address where the purchase confirmation email will be sent (including QR Code & activation steps)
|
|
1011
|
+
* @property {string} referenceId - An identifier provided by the partner to link this purchase to their booking or transaction for analytics and debugging purposes.
|
|
1012
|
+
* @property {string} networkBrand - Customize the network brand of the issued eSIM. The `networkBrand` parameter cannot exceed 15 characters in length and must contain only letters, numbers, dots (.), ampersands (&), and spaces. This feature is available to platforms with Diamond tier only.
|
|
1013
|
+
* @property {string} emailBrand - Customize the email subject brand. The `emailBrand` parameter cannot exceed 25 characters in length and must contain only letters, numbers, and spaces. This feature is available to platforms with Diamond tier only.
|
|
1014
|
+
* @property {CreatePurchaseV2RequestLanguage} language - Language of the confirmation email sent to the customer.
|
|
1000
1015
|
*/
|
|
1001
1016
|
type CreatePurchaseV2Request = z.infer<typeof createPurchaseV2Request>;
|
|
1002
1017
|
|
|
@@ -1066,10 +1081,9 @@ declare const createPurchaseV2OkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
1066
1081
|
};
|
|
1067
1082
|
}>>;
|
|
1068
1083
|
/**
|
|
1069
|
-
*
|
|
1070
|
-
* @
|
|
1071
|
-
* @property {
|
|
1072
|
-
* @property {CreatePurchaseV2OkResponseProfile}
|
|
1084
|
+
* @typedef {CreatePurchaseV2OkResponse} createPurchaseV2OkResponse
|
|
1085
|
+
* @property {CreatePurchaseV2OkResponsePurchase} purchase
|
|
1086
|
+
* @property {CreatePurchaseV2OkResponseProfile} profile
|
|
1073
1087
|
*/
|
|
1074
1088
|
type CreatePurchaseV2OkResponse = z.infer<typeof createPurchaseV2OkResponse>;
|
|
1075
1089
|
|
|
@@ -1229,10 +1243,9 @@ declare const listPurchasesOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
1229
1243
|
}[];
|
|
1230
1244
|
}>>;
|
|
1231
1245
|
/**
|
|
1232
|
-
*
|
|
1233
|
-
* @
|
|
1234
|
-
* @property {
|
|
1235
|
-
* @property {string} - The cursor value representing the end of the current page of results. Use this cursor value as the "afterCursor" parameter in your next request to retrieve the subsequent page of results. It ensures that you continue fetching data from where you left off, facilitating smooth pagination.
|
|
1246
|
+
* @typedef {ListPurchasesOkResponse} listPurchasesOkResponse
|
|
1247
|
+
* @property {Purchases[]} purchases
|
|
1248
|
+
* @property {string} afterCursor - The cursor value representing the end of the current page of results. Use this cursor value as the "afterCursor" parameter in your next request to retrieve the subsequent page of results. It ensures that you continue fetching data from where you left off, facilitating smooth pagination.
|
|
1236
1249
|
*/
|
|
1237
1250
|
type ListPurchasesOkResponse = z.infer<typeof listPurchasesOkResponse>;
|
|
1238
1251
|
|
|
@@ -1292,19 +1305,18 @@ declare const createPurchaseRequest: z.ZodLazy<z.ZodObject<{
|
|
|
1292
1305
|
endTime?: number | undefined;
|
|
1293
1306
|
}>>;
|
|
1294
1307
|
/**
|
|
1295
|
-
*
|
|
1296
|
-
* @
|
|
1297
|
-
* @property {
|
|
1298
|
-
* @property {
|
|
1299
|
-
* @property {string} -
|
|
1300
|
-
* @property {string} -
|
|
1301
|
-
* @property {string} -
|
|
1302
|
-
* @property {string} -
|
|
1303
|
-
* @property {string} - Customize the
|
|
1304
|
-
* @property {
|
|
1305
|
-
* @property {
|
|
1306
|
-
* @property {number} - Epoch value representing the
|
|
1307
|
-
* @property {number} - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time.
|
|
1308
|
+
* @typedef {CreatePurchaseRequest} createPurchaseRequest
|
|
1309
|
+
* @property {string} destination - ISO representation of the package's destination. Supports both ISO2 (e.g., 'FR') and ISO3 (e.g., 'FRA') country codes.
|
|
1310
|
+
* @property {number} dataLimitInGb - Size of the package in GB. The available options are 0.5, 1, 2, 3, 5, 8, 20, 50GB. Use `-1` to purchase an unlimited (date-based) package — provide `startDate`/`endDate` spanning 3 to 30 days.
|
|
1311
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-dd'. This date can be set to the current day or any day within the next 12 months.
|
|
1312
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-dd'. End date can be maximum 90 days after Start date.
|
|
1313
|
+
* @property {string} email - Email address where the purchase confirmation email will be sent (including QR Code & activation steps)
|
|
1314
|
+
* @property {string} referenceId - An identifier provided by the partner to link this purchase to their booking or transaction for analytics and debugging purposes.
|
|
1315
|
+
* @property {string} networkBrand - Customize the network brand of the issued eSIM. The `networkBrand` parameter cannot exceed 15 characters in length and must contain only letters, numbers, dots (.), ampersands (&), and spaces. This feature is available to platforms with Diamond tier only.
|
|
1316
|
+
* @property {string} emailBrand - Customize the email subject brand. The `emailBrand` parameter cannot exceed 25 characters in length and must contain only letters, numbers, and spaces. This feature is available to platforms with Diamond tier only.
|
|
1317
|
+
* @property {CreatePurchaseRequestLanguage} language - Language of the confirmation email sent to the customer.
|
|
1318
|
+
* @property {number} 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.
|
|
1319
|
+
* @property {number} endTime - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time.
|
|
1308
1320
|
*/
|
|
1309
1321
|
type CreatePurchaseRequest = z.infer<typeof createPurchaseRequest>;
|
|
1310
1322
|
|
|
@@ -1384,10 +1396,9 @@ declare const createPurchaseOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
1384
1396
|
};
|
|
1385
1397
|
}>>;
|
|
1386
1398
|
/**
|
|
1387
|
-
*
|
|
1388
|
-
* @
|
|
1389
|
-
* @property {
|
|
1390
|
-
* @property {CreatePurchaseOkResponseProfile}
|
|
1399
|
+
* @typedef {CreatePurchaseOkResponse} createPurchaseOkResponse
|
|
1400
|
+
* @property {CreatePurchaseOkResponsePurchase} purchase
|
|
1401
|
+
* @property {CreatePurchaseOkResponseProfile} profile
|
|
1391
1402
|
*/
|
|
1392
1403
|
type CreatePurchaseOkResponse = z.infer<typeof createPurchaseOkResponse>;
|
|
1393
1404
|
|
|
@@ -1431,18 +1442,17 @@ declare const topUpEsimRequest: z.ZodLazy<z.ZodObject<{
|
|
|
1431
1442
|
endTime?: number | undefined;
|
|
1432
1443
|
}>>;
|
|
1433
1444
|
/**
|
|
1434
|
-
*
|
|
1435
|
-
* @
|
|
1436
|
-
* @property {
|
|
1437
|
-
* @property {
|
|
1438
|
-
* @property {string} -
|
|
1439
|
-
* @property {
|
|
1440
|
-
* @property {
|
|
1441
|
-
* @property {string} -
|
|
1442
|
-
* @property {string} -
|
|
1443
|
-
* @property {
|
|
1444
|
-
* @property {number} - Epoch value representing the
|
|
1445
|
-
* @property {number} - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time.
|
|
1445
|
+
* @typedef {TopUpEsimRequest} topUpEsimRequest
|
|
1446
|
+
* @property {string} iccid - ID of the eSIM
|
|
1447
|
+
* @property {number} dataLimitInGb - Size of the package in GB. The available options are 0.5, 1, 2, 3, 5, 8, 20, 50GB. Use `-1` to top up with an unlimited (date-based) package — provide `startDate`/`endDate` spanning 3 to 30 days (`duration` is not supported for unlimited packages).
|
|
1448
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-dd'. This date can be set to the current day or any day within the next 12 months.
|
|
1449
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-dd'. End date can be maximum 90 days after Start date.
|
|
1450
|
+
* @property {number} duration - Duration of the package in days. Available values are 1, 2, 7, 14, 30, or 90. Either provide startDate/endDate or duration. Not supported for unlimited packages (`dataLimitInGB` = -1), which are date-based — provide startDate/endDate instead.
|
|
1451
|
+
* @property {string} email - Email address where the purchase confirmation email will be sent (excluding QR Code & activation steps).
|
|
1452
|
+
* @property {string} referenceId - An identifier provided by the partner to link this purchase to their booking or transaction for analytics and debugging purposes.
|
|
1453
|
+
* @property {string} emailBrand - Customize the email subject brand. The `emailBrand` parameter cannot exceed 25 characters in length and must contain only letters, numbers, and spaces. This feature is available to platforms with Diamond tier only.
|
|
1454
|
+
* @property {number} 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.
|
|
1455
|
+
* @property {number} endTime - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time.
|
|
1446
1456
|
*/
|
|
1447
1457
|
type TopUpEsimRequest = z.infer<typeof topUpEsimRequest>;
|
|
1448
1458
|
|
|
@@ -1512,10 +1522,9 @@ declare const topUpEsimOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
1512
1522
|
};
|
|
1513
1523
|
}>>;
|
|
1514
1524
|
/**
|
|
1515
|
-
*
|
|
1516
|
-
* @
|
|
1517
|
-
* @property {
|
|
1518
|
-
* @property {TopUpEsimOkResponseProfile}
|
|
1525
|
+
* @typedef {TopUpEsimOkResponse} topUpEsimOkResponse
|
|
1526
|
+
* @property {TopUpEsimOkResponsePurchase} purchase
|
|
1527
|
+
* @property {TopUpEsimOkResponseProfile} profile
|
|
1519
1528
|
*/
|
|
1520
1529
|
type TopUpEsimOkResponse = z.infer<typeof topUpEsimOkResponse>;
|
|
1521
1530
|
|
|
@@ -1544,13 +1553,12 @@ declare const editPurchaseRequest: z.ZodLazy<z.ZodObject<{
|
|
|
1544
1553
|
endTime?: number | undefined;
|
|
1545
1554
|
}>>;
|
|
1546
1555
|
/**
|
|
1547
|
-
*
|
|
1548
|
-
* @
|
|
1549
|
-
* @property {string} -
|
|
1550
|
-
* @property {string} -
|
|
1551
|
-
* @property {
|
|
1552
|
-
* @property {number} - Epoch value representing the
|
|
1553
|
-
* @property {number} - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time.
|
|
1556
|
+
* @typedef {EditPurchaseRequest} editPurchaseRequest
|
|
1557
|
+
* @property {string} purchaseId - ID of the purchase
|
|
1558
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-dd'. This date can be set to the current day or any day within the next 12 months.
|
|
1559
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-dd'. End date can be maximum 90 days after Start date.
|
|
1560
|
+
* @property {number} 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.
|
|
1561
|
+
* @property {number} endTime - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time.
|
|
1554
1562
|
*/
|
|
1555
1563
|
type EditPurchaseRequest = z.infer<typeof editPurchaseRequest>;
|
|
1556
1564
|
|
|
@@ -1579,13 +1587,12 @@ declare const editPurchaseOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
1579
1587
|
newEndTime?: number | null | undefined;
|
|
1580
1588
|
}>>;
|
|
1581
1589
|
/**
|
|
1582
|
-
*
|
|
1583
|
-
* @
|
|
1584
|
-
* @property {string} -
|
|
1585
|
-
* @property {string} -
|
|
1586
|
-
* @property {
|
|
1587
|
-
* @property {number} - Epoch value representing the new
|
|
1588
|
-
* @property {number} - Epoch value representing the new end time of the package's validity
|
|
1590
|
+
* @typedef {EditPurchaseOkResponse} editPurchaseOkResponse
|
|
1591
|
+
* @property {string} purchaseId - ID of the purchase
|
|
1592
|
+
* @property {string} newStartDate - Start date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1593
|
+
* @property {string} newEndDate - End date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1594
|
+
* @property {number} newStartTime - Epoch value representing the new start time of the package's validity
|
|
1595
|
+
* @property {number} newEndTime - Epoch value representing the new end time of the package's validity
|
|
1589
1596
|
*/
|
|
1590
1597
|
type EditPurchaseOkResponse = z.infer<typeof editPurchaseOkResponse>;
|
|
1591
1598
|
|
|
@@ -1608,11 +1615,10 @@ declare const getPurchaseConsumptionOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
1608
1615
|
dataUsageRemainingInGb: number;
|
|
1609
1616
|
}>>;
|
|
1610
1617
|
/**
|
|
1611
|
-
*
|
|
1612
|
-
* @
|
|
1613
|
-
* @property {number} - Remaining balance of the package in
|
|
1614
|
-
* @property {
|
|
1615
|
-
* @property {string} - Status of the connectivity, possible values are 'ACTIVE' or 'NOT_ACTIVE'
|
|
1618
|
+
* @typedef {GetPurchaseConsumptionOkResponse} getPurchaseConsumptionOkResponse
|
|
1619
|
+
* @property {number} dataUsageRemainingInBytes - Remaining balance of the package in bytes. Returns `-1` for unlimited packages.
|
|
1620
|
+
* @property {number} dataUsageRemainingInGb - Remaining balance of the package in GB. Returns `-1` for unlimited packages.
|
|
1621
|
+
* @property {string} status - Status of the connectivity, possible values are 'ACTIVE' or 'NOT_ACTIVE'
|
|
1616
1622
|
*/
|
|
1617
1623
|
type GetPurchaseConsumptionOkResponse = z.infer<typeof getPurchaseConsumptionOkResponse>;
|
|
1618
1624
|
|
|
@@ -1739,11 +1745,10 @@ declare const createPurchaseV2OkResponsePurchase: z.ZodLazy<z.ZodObject<{
|
|
|
1739
1745
|
createdDate: string;
|
|
1740
1746
|
}>>;
|
|
1741
1747
|
/**
|
|
1742
|
-
*
|
|
1743
|
-
* @
|
|
1744
|
-
* @property {string} - ID of the
|
|
1745
|
-
* @property {string} -
|
|
1746
|
-
* @property {string} - Creation date of the purchase in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1748
|
+
* @typedef {CreatePurchaseV2OkResponsePurchase} createPurchaseV2OkResponsePurchase
|
|
1749
|
+
* @property {string} id - ID of the purchase
|
|
1750
|
+
* @property {string} packageId - ID of the package
|
|
1751
|
+
* @property {string} createdDate - Creation date of the purchase in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1747
1752
|
*/
|
|
1748
1753
|
type CreatePurchaseV2OkResponsePurchase = z.infer<typeof createPurchaseV2OkResponsePurchase>;
|
|
1749
1754
|
|
|
@@ -1772,13 +1777,12 @@ declare const createPurchaseV2OkResponseProfile: z.ZodLazy<z.ZodObject<{
|
|
|
1772
1777
|
androidActivationLink: string;
|
|
1773
1778
|
}>>;
|
|
1774
1779
|
/**
|
|
1775
|
-
*
|
|
1776
|
-
* @
|
|
1777
|
-
* @property {string} -
|
|
1778
|
-
* @property {string} -
|
|
1779
|
-
* @property {string} -
|
|
1780
|
-
* @property {string} -
|
|
1781
|
-
* @property {string} - Android Activation Link of the eSIM
|
|
1780
|
+
* @typedef {CreatePurchaseV2OkResponseProfile} createPurchaseV2OkResponseProfile
|
|
1781
|
+
* @property {string} iccid - ID of the eSIM
|
|
1782
|
+
* @property {string} activationCode - QR Code of the eSIM as base64
|
|
1783
|
+
* @property {string} manualActivationCode - Manual Activation Code of the eSIM
|
|
1784
|
+
* @property {string} iosActivationLink - iOS Activation Link of the eSIM
|
|
1785
|
+
* @property {string} androidActivationLink - Android Activation Link of the eSIM
|
|
1782
1786
|
*/
|
|
1783
1787
|
type CreatePurchaseV2OkResponseProfile = z.infer<typeof createPurchaseV2OkResponseProfile>;
|
|
1784
1788
|
|
|
@@ -1889,21 +1893,20 @@ declare const purchases: z.ZodLazy<z.ZodObject<{
|
|
|
1889
1893
|
referenceId?: string | null | undefined;
|
|
1890
1894
|
}>>;
|
|
1891
1895
|
/**
|
|
1892
|
-
*
|
|
1893
|
-
* @
|
|
1894
|
-
* @property {string} -
|
|
1895
|
-
* @property {string} -
|
|
1896
|
-
* @property {
|
|
1897
|
-
* @property {
|
|
1898
|
-
* @property {
|
|
1899
|
-
* @property {number} - Epoch value representing the
|
|
1900
|
-
* @property {number} - Epoch value representing the
|
|
1901
|
-
* @property {
|
|
1902
|
-
* @property {
|
|
1903
|
-
* @property {
|
|
1904
|
-
* @property {string} - The `
|
|
1905
|
-
* @property {string} - The `
|
|
1906
|
-
* @property {string} - The `referenceId` that was provided by the partner during the purchase or top-up flow. This identifier can be used for analytics and debugging purposes.
|
|
1896
|
+
* @typedef {Purchases} purchases
|
|
1897
|
+
* @property {string} id - ID of the purchase
|
|
1898
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1899
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1900
|
+
* @property {number} duration - Duration of the package in days. Possible values are 1, 2, 7, 14, 30, or 90. `null` for unlimited (date-based) packages.
|
|
1901
|
+
* @property {string} createdDate - Creation date of the purchase in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
1902
|
+
* @property {number} startTime - Epoch value representing the start time of the package's validity
|
|
1903
|
+
* @property {number} endTime - Epoch value representing the end time of the package's validity
|
|
1904
|
+
* @property {number} createdAt - Epoch value representing the date of creation of the purchase
|
|
1905
|
+
* @property {Package_} package
|
|
1906
|
+
* @property {PurchasesEsim} esim
|
|
1907
|
+
* @property {string} source - The `source` indicates whether the purchase was made from the API, dashboard, landing-page, promo-page or iframe. For purchases made before September 8, 2023, the value will be displayed as 'Not available'.
|
|
1908
|
+
* @property {string} purchaseType - The `purchaseType` indicates whether this is the initial purchase that creates the eSIM (First Purchase) or a subsequent top-up on an existing eSIM (Top-up Purchase).
|
|
1909
|
+
* @property {string} referenceId - The `referenceId` that was provided by the partner during the purchase or top-up flow. This identifier can be used for analytics and debugging purposes.
|
|
1907
1910
|
*/
|
|
1908
1911
|
type Purchases = z.infer<typeof purchases>;
|
|
1909
1912
|
|
|
@@ -1938,15 +1941,14 @@ declare const package_: z.ZodLazy<z.ZodObject<{
|
|
|
1938
1941
|
destinationName: string;
|
|
1939
1942
|
}>>;
|
|
1940
1943
|
/**
|
|
1941
|
-
*
|
|
1942
|
-
* @
|
|
1943
|
-
* @property {
|
|
1944
|
-
* @property {number} - Size of the package in
|
|
1945
|
-
* @property {
|
|
1946
|
-
* @property {string} -
|
|
1947
|
-
* @property {string} -
|
|
1948
|
-
* @property {
|
|
1949
|
-
* @property {number} - Price of the package in cents
|
|
1944
|
+
* @typedef {Package_} package_
|
|
1945
|
+
* @property {string} id - ID of the package
|
|
1946
|
+
* @property {number} dataLimitInBytes - Size of the package in Bytes. A value of `-1` indicates an unlimited package.
|
|
1947
|
+
* @property {number} dataLimitInGb - Size of the package in GB. A value of `-1` indicates an unlimited (date-based) package.
|
|
1948
|
+
* @property {string} destination - ISO3 representation of the package's destination.
|
|
1949
|
+
* @property {string} destinationIso2 - ISO2 representation of the package's destination.
|
|
1950
|
+
* @property {string} destinationName - Name of the package's destination
|
|
1951
|
+
* @property {number} priceInCents - Price of the package in cents
|
|
1950
1952
|
*/
|
|
1951
1953
|
type Package_ = z.infer<typeof package_>;
|
|
1952
1954
|
|
|
@@ -1963,9 +1965,8 @@ declare const purchasesEsim: z.ZodLazy<z.ZodObject<{
|
|
|
1963
1965
|
iccid: string;
|
|
1964
1966
|
}>>;
|
|
1965
1967
|
/**
|
|
1966
|
-
*
|
|
1967
|
-
* @
|
|
1968
|
-
* @property {string} - ID of the eSIM
|
|
1968
|
+
* @typedef {PurchasesEsim} purchasesEsim
|
|
1969
|
+
* @property {string} iccid - ID of the eSIM
|
|
1969
1970
|
*/
|
|
1970
1971
|
type PurchasesEsim = z.infer<typeof purchasesEsim>;
|
|
1971
1972
|
|
|
@@ -2000,15 +2001,14 @@ declare const createPurchaseOkResponsePurchase: z.ZodLazy<z.ZodObject<{
|
|
|
2000
2001
|
endTime?: number | null | undefined;
|
|
2001
2002
|
}>>;
|
|
2002
2003
|
/**
|
|
2003
|
-
*
|
|
2004
|
-
* @
|
|
2005
|
-
* @property {string} - ID of the
|
|
2006
|
-
* @property {string} -
|
|
2007
|
-
* @property {string} -
|
|
2008
|
-
* @property {string} -
|
|
2009
|
-
* @property {
|
|
2010
|
-
* @property {number} - Epoch value representing the
|
|
2011
|
-
* @property {number} - Epoch value representing the end time of the package's validity
|
|
2004
|
+
* @typedef {CreatePurchaseOkResponsePurchase} createPurchaseOkResponsePurchase
|
|
2005
|
+
* @property {string} id - ID of the purchase
|
|
2006
|
+
* @property {string} packageId - ID of the package
|
|
2007
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2008
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2009
|
+
* @property {string} createdDate - Creation date of the purchase in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2010
|
+
* @property {number} startTime - Epoch value representing the start time of the package's validity
|
|
2011
|
+
* @property {number} endTime - Epoch value representing the end time of the package's validity
|
|
2012
2012
|
*/
|
|
2013
2013
|
type CreatePurchaseOkResponsePurchase = z.infer<typeof createPurchaseOkResponsePurchase>;
|
|
2014
2014
|
|
|
@@ -2031,11 +2031,10 @@ declare const createPurchaseOkResponseProfile: z.ZodLazy<z.ZodObject<{
|
|
|
2031
2031
|
manualActivationCode: string;
|
|
2032
2032
|
}>>;
|
|
2033
2033
|
/**
|
|
2034
|
-
*
|
|
2035
|
-
* @
|
|
2036
|
-
* @property {string} -
|
|
2037
|
-
* @property {string} -
|
|
2038
|
-
* @property {string} - Manual Activation Code of the eSIM
|
|
2034
|
+
* @typedef {CreatePurchaseOkResponseProfile} createPurchaseOkResponseProfile
|
|
2035
|
+
* @property {string} iccid - ID of the eSIM
|
|
2036
|
+
* @property {string} activationCode - QR Code of the eSIM as base64
|
|
2037
|
+
* @property {string} manualActivationCode - Manual Activation Code of the eSIM
|
|
2039
2038
|
*/
|
|
2040
2039
|
type CreatePurchaseOkResponseProfile = z.infer<typeof createPurchaseOkResponseProfile>;
|
|
2041
2040
|
|
|
@@ -2078,15 +2077,14 @@ declare const topUpEsimOkResponsePurchase: z.ZodLazy<z.ZodObject<{
|
|
|
2078
2077
|
endTime?: number | null | undefined;
|
|
2079
2078
|
}>>;
|
|
2080
2079
|
/**
|
|
2081
|
-
*
|
|
2082
|
-
* @
|
|
2083
|
-
* @property {string} - ID of the
|
|
2084
|
-
* @property {string} -
|
|
2085
|
-
* @property {string} -
|
|
2086
|
-
* @property {string} -
|
|
2087
|
-
* @property {
|
|
2088
|
-
* @property {number} - Epoch value representing the
|
|
2089
|
-
* @property {number} - Epoch value representing the end time of the package's validity
|
|
2080
|
+
* @typedef {TopUpEsimOkResponsePurchase} topUpEsimOkResponsePurchase
|
|
2081
|
+
* @property {string} id - ID of the purchase
|
|
2082
|
+
* @property {string} packageId - ID of the package
|
|
2083
|
+
* @property {string} startDate - Start date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2084
|
+
* @property {string} endDate - End date of the package's validity in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2085
|
+
* @property {string} createdDate - Creation date of the purchase in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2086
|
+
* @property {number} startTime - Epoch value representing the start time of the package's validity
|
|
2087
|
+
* @property {number} endTime - Epoch value representing the end time of the package's validity
|
|
2090
2088
|
*/
|
|
2091
2089
|
type TopUpEsimOkResponsePurchase = z.infer<typeof topUpEsimOkResponsePurchase>;
|
|
2092
2090
|
|
|
@@ -2103,9 +2101,8 @@ declare const topUpEsimOkResponseProfile: z.ZodLazy<z.ZodObject<{
|
|
|
2103
2101
|
iccid: string;
|
|
2104
2102
|
}>>;
|
|
2105
2103
|
/**
|
|
2106
|
-
*
|
|
2107
|
-
* @
|
|
2108
|
-
* @property {string} - ID of the eSIM
|
|
2104
|
+
* @typedef {TopUpEsimOkResponseProfile} topUpEsimOkResponseProfile
|
|
2105
|
+
* @property {string} iccid - ID of the eSIM
|
|
2109
2106
|
*/
|
|
2110
2107
|
type TopUpEsimOkResponseProfile = z.infer<typeof topUpEsimOkResponseProfile>;
|
|
2111
2108
|
|
|
@@ -2162,9 +2159,8 @@ declare const getEsimOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
2162
2159
|
};
|
|
2163
2160
|
}>>;
|
|
2164
2161
|
/**
|
|
2165
|
-
*
|
|
2166
|
-
* @
|
|
2167
|
-
* @property {GetEsimOkResponseEsim}
|
|
2162
|
+
* @typedef {GetEsimOkResponse} getEsimOkResponse
|
|
2163
|
+
* @property {GetEsimOkResponseEsim} esim
|
|
2168
2164
|
*/
|
|
2169
2165
|
type GetEsimOkResponse = z.infer<typeof getEsimOkResponse>;
|
|
2170
2166
|
|
|
@@ -2210,9 +2206,8 @@ declare const getEsimDeviceOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
2210
2206
|
};
|
|
2211
2207
|
}>>;
|
|
2212
2208
|
/**
|
|
2213
|
-
*
|
|
2214
|
-
* @
|
|
2215
|
-
* @property {Device}
|
|
2209
|
+
* @typedef {GetEsimDeviceOkResponse} getEsimDeviceOkResponse
|
|
2210
|
+
* @property {Device} device
|
|
2216
2211
|
*/
|
|
2217
2212
|
type GetEsimDeviceOkResponse = z.infer<typeof getEsimDeviceOkResponse>;
|
|
2218
2213
|
|
|
@@ -2272,9 +2267,8 @@ declare const getEsimHistoryOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
2272
2267
|
};
|
|
2273
2268
|
}>>;
|
|
2274
2269
|
/**
|
|
2275
|
-
*
|
|
2276
|
-
* @
|
|
2277
|
-
* @property {GetEsimHistoryOkResponseEsim}
|
|
2270
|
+
* @typedef {GetEsimHistoryOkResponse} getEsimHistoryOkResponse
|
|
2271
|
+
* @property {GetEsimHistoryOkResponseEsim} esim
|
|
2278
2272
|
*/
|
|
2279
2273
|
type GetEsimHistoryOkResponse = z.infer<typeof getEsimHistoryOkResponse>;
|
|
2280
2274
|
|
|
@@ -2359,15 +2353,14 @@ declare const getEsimOkResponseEsim: z.ZodLazy<z.ZodObject<{
|
|
|
2359
2353
|
isTopUpAllowed: boolean;
|
|
2360
2354
|
}>>;
|
|
2361
2355
|
/**
|
|
2362
|
-
*
|
|
2363
|
-
* @
|
|
2364
|
-
* @property {string} -
|
|
2365
|
-
* @property {string}
|
|
2366
|
-
* @property {string} -
|
|
2367
|
-
* @property {string} -
|
|
2368
|
-
* @property {string} - Status of the eSIM, possible values are '
|
|
2369
|
-
* @property {
|
|
2370
|
-
* @property {boolean} - Indicates whether the eSIM is currently eligible for a top-up. This flag should be checked before attempting a top-up request.
|
|
2356
|
+
* @typedef {GetEsimOkResponseEsim} getEsimOkResponseEsim
|
|
2357
|
+
* @property {string} iccid - ID of the eSIM
|
|
2358
|
+
* @property {string} smdpAddress - SM-DP+ Address
|
|
2359
|
+
* @property {string} activationCode - QR Code of the eSIM as base64
|
|
2360
|
+
* @property {string} manualActivationCode - The manual activation code
|
|
2361
|
+
* @property {string} status - Status of the eSIM, possible values are 'RELEASED', 'DOWNLOADED', 'INSTALLED', 'ENABLED', 'DELETED', or 'ERROR'
|
|
2362
|
+
* @property {string} connectivityStatus - Status of the eSIM connectivity, possible values are 'ACTIVE' or 'NOT_ACTIVE'
|
|
2363
|
+
* @property {boolean} isTopUpAllowed - Indicates whether the eSIM is currently eligible for a top-up. This flag should be checked before attempting a top-up request.
|
|
2371
2364
|
*/
|
|
2372
2365
|
type GetEsimOkResponseEsim = z.infer<typeof getEsimOkResponseEsim>;
|
|
2373
2366
|
|
|
@@ -2393,12 +2386,11 @@ declare const device: z.ZodLazy<z.ZodObject<{
|
|
|
2393
2386
|
eid: string;
|
|
2394
2387
|
}>>;
|
|
2395
2388
|
/**
|
|
2396
|
-
*
|
|
2397
|
-
* @
|
|
2398
|
-
* @property {string} - Name of the
|
|
2399
|
-
* @property {string} -
|
|
2400
|
-
* @property {string} -
|
|
2401
|
-
* @property {string} - Serial Number of the eSIM
|
|
2389
|
+
* @typedef {Device} device
|
|
2390
|
+
* @property {string} oem - Name of the OEM
|
|
2391
|
+
* @property {string} hardwareName - Name of the Device
|
|
2392
|
+
* @property {string} hardwareModel - Model of the Device
|
|
2393
|
+
* @property {string} eid - Serial Number of the eSIM
|
|
2402
2394
|
*/
|
|
2403
2395
|
type Device = z.infer<typeof device>;
|
|
2404
2396
|
|
|
@@ -2438,10 +2430,9 @@ declare const getEsimHistoryOkResponseEsim: z.ZodLazy<z.ZodObject<{
|
|
|
2438
2430
|
}[];
|
|
2439
2431
|
}>>;
|
|
2440
2432
|
/**
|
|
2441
|
-
*
|
|
2442
|
-
* @
|
|
2443
|
-
* @property {
|
|
2444
|
-
* @property {History[]}
|
|
2433
|
+
* @typedef {GetEsimHistoryOkResponseEsim} getEsimHistoryOkResponseEsim
|
|
2434
|
+
* @property {string} iccid - ID of the eSIM
|
|
2435
|
+
* @property {History[]} history
|
|
2445
2436
|
*/
|
|
2446
2437
|
type GetEsimHistoryOkResponseEsim = z.infer<typeof getEsimHistoryOkResponseEsim>;
|
|
2447
2438
|
|
|
@@ -2464,11 +2455,10 @@ declare const history: z.ZodLazy<z.ZodObject<{
|
|
|
2464
2455
|
date?: number | undefined;
|
|
2465
2456
|
}>>;
|
|
2466
2457
|
/**
|
|
2467
|
-
*
|
|
2468
|
-
* @
|
|
2469
|
-
* @property {string} - The
|
|
2470
|
-
* @property {
|
|
2471
|
-
* @property {number} - Epoch value representing the date when the eSIM status changed
|
|
2458
|
+
* @typedef {History} history
|
|
2459
|
+
* @property {string} status - The status of the eSIM at a given time, possible values are 'RELEASED', 'DOWNLOADED', 'INSTALLED', 'ENABLED', 'DELETED', or 'ERROR'
|
|
2460
|
+
* @property {string} statusDate - The date when the eSIM status changed in the format 'yyyy-MM-ddThh:mm:ssZZ'
|
|
2461
|
+
* @property {number} date - Epoch value representing the date when the eSIM status changed
|
|
2472
2462
|
*/
|
|
2473
2463
|
type History = z.infer<typeof history>;
|
|
2474
2464
|
|
|
@@ -2485,9 +2475,8 @@ declare const tokenOkResponse: z.ZodLazy<z.ZodObject<{
|
|
|
2485
2475
|
token: string;
|
|
2486
2476
|
}>>;
|
|
2487
2477
|
/**
|
|
2488
|
-
*
|
|
2489
|
-
* @
|
|
2490
|
-
* @property {string} - The generated token
|
|
2478
|
+
* @typedef {TokenOkResponse} tokenOkResponse
|
|
2479
|
+
* @property {string} token - The generated token
|
|
2491
2480
|
*/
|
|
2492
2481
|
type TokenOkResponse = z.infer<typeof tokenOkResponse>;
|
|
2493
2482
|
|
|
@@ -2534,12 +2523,11 @@ declare const oAuthTokenRequest: z.ZodLazy<z.ZodObject<{
|
|
|
2534
2523
|
scope: string;
|
|
2535
2524
|
}>>;
|
|
2536
2525
|
/**
|
|
2537
|
-
*
|
|
2538
|
-
* @
|
|
2539
|
-
* @property {
|
|
2540
|
-
* @property {string}
|
|
2541
|
-
* @property {string}
|
|
2542
|
-
* @property {string}
|
|
2526
|
+
* @typedef {OAuthTokenRequest} oAuthTokenRequest
|
|
2527
|
+
* @property {GrantType} grantType
|
|
2528
|
+
* @property {string} clientId
|
|
2529
|
+
* @property {string} clientSecret
|
|
2530
|
+
* @property {string} scope
|
|
2543
2531
|
*/
|
|
2544
2532
|
type OAuthTokenRequest = z.infer<typeof oAuthTokenRequest>;
|
|
2545
2533
|
|
|
@@ -2559,10 +2547,9 @@ declare const oAuthTokenResponse: z.ZodLazy<z.ZodObject<{
|
|
|
2559
2547
|
expiresIn?: number | null | undefined;
|
|
2560
2548
|
}>>;
|
|
2561
2549
|
/**
|
|
2562
|
-
*
|
|
2563
|
-
* @
|
|
2564
|
-
* @property {
|
|
2565
|
-
* @property {number}
|
|
2550
|
+
* @typedef {OAuthTokenResponse} oAuthTokenResponse
|
|
2551
|
+
* @property {string} accessToken
|
|
2552
|
+
* @property {number} expiresIn
|
|
2566
2553
|
*/
|
|
2567
2554
|
type OAuthTokenResponse = z.infer<typeof oAuthTokenResponse>;
|
|
2568
2555
|
|
|
@@ -2595,6 +2582,7 @@ declare class BadRequest extends ThrowableError {
|
|
|
2595
2582
|
message: string;
|
|
2596
2583
|
protected response?: unknown;
|
|
2597
2584
|
constructor(message: string, response?: unknown);
|
|
2585
|
+
static from(message: string, response?: unknown): BadRequest;
|
|
2598
2586
|
throw(): void;
|
|
2599
2587
|
}
|
|
2600
2588
|
|
|
@@ -2602,6 +2590,7 @@ declare class Unauthorized extends ThrowableError {
|
|
|
2602
2590
|
message: string;
|
|
2603
2591
|
protected response?: unknown;
|
|
2604
2592
|
constructor(message: string, response?: unknown);
|
|
2593
|
+
static from(message: string, response?: unknown): Unauthorized;
|
|
2605
2594
|
throw(): void;
|
|
2606
2595
|
}
|
|
2607
2596
|
|
package/dist/index.js
CHANGED
|
@@ -382,7 +382,7 @@ var TransportHookAdapter = class {
|
|
|
382
382
|
function getContentTypeDefinition(contentType) {
|
|
383
383
|
const ct = contentType.toLowerCase();
|
|
384
384
|
if (ct.startsWith("application/") && ct.includes("xml")) {
|
|
385
|
-
return "
|
|
385
|
+
return "text" /* Text */;
|
|
386
386
|
}
|
|
387
387
|
if (ct === "application/x-www-form-urlencoded") {
|
|
388
388
|
return "form" /* FormUrlEncoded */;
|
|
@@ -455,7 +455,7 @@ var HookHandler = class {
|
|
|
455
455
|
} catch (e) {
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
const customError =
|
|
458
|
+
const customError = error.error.from((json == null ? void 0 : json.message) || "", json);
|
|
459
459
|
customError.metadata = response.metadata;
|
|
460
460
|
customError.throw();
|
|
461
461
|
}
|
|
@@ -592,7 +592,6 @@ var ResponseValidationHandler = class {
|
|
|
592
592
|
["image" /* Image */]: this.decodeFile,
|
|
593
593
|
["multipartFormData" /* MultipartFormData */]: this.decodeMultipartFormData,
|
|
594
594
|
["text" /* Text */]: this.decodeText,
|
|
595
|
-
["xml" /* Xml */]: this.decodeText,
|
|
596
595
|
["form" /* FormUrlEncoded */]: this.decodeFormUrlEncoded,
|
|
597
596
|
["eventStream" /* EventStream */]: this.decodeEventStream
|
|
598
597
|
};
|
|
@@ -808,7 +807,7 @@ var RequestValidationHandler = class {
|
|
|
808
807
|
}
|
|
809
808
|
throw error;
|
|
810
809
|
}
|
|
811
|
-
} else if (request.requestContentType === "
|
|
810
|
+
} else if (request.requestContentType === "text" /* Text */ || request.requestContentType === "image" /* Image */ || request.requestContentType === "binary" /* Binary */) {
|
|
812
811
|
request.body = request.body;
|
|
813
812
|
} else if (request.requestContentType === "form" /* FormUrlEncoded */) {
|
|
814
813
|
request.body = this.toFormUrlEncoded(request);
|
|
@@ -844,7 +843,7 @@ var RequestValidationHandler = class {
|
|
|
844
843
|
});
|
|
845
844
|
return params.toString();
|
|
846
845
|
}
|
|
847
|
-
if (typeof validatedBody === "object" && !Array.isArray(validatedBody)) {
|
|
846
|
+
if (typeof validatedBody === "object" && validatedBody !== null && !Array.isArray(validatedBody)) {
|
|
848
847
|
const params = new URLSearchParams();
|
|
849
848
|
for (const [key, value] of Object.entries(validatedBody)) {
|
|
850
849
|
if (value != null) {
|
|
@@ -1060,10 +1059,7 @@ var RequestFetchAdapter = class {
|
|
|
1060
1059
|
return headers;
|
|
1061
1060
|
}
|
|
1062
1061
|
toArrayBuffer(uint8Array) {
|
|
1063
|
-
return uint8Array.buffer
|
|
1064
|
-
uint8Array.byteOffset,
|
|
1065
|
-
uint8Array.byteOffset + uint8Array.byteLength
|
|
1066
|
-
);
|
|
1062
|
+
return new Uint8Array(uint8Array).buffer;
|
|
1067
1063
|
}
|
|
1068
1064
|
};
|
|
1069
1065
|
|
|
@@ -1113,7 +1109,7 @@ var RetryHandler = class {
|
|
|
1113
1109
|
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1114
1110
|
throw error;
|
|
1115
1111
|
}
|
|
1116
|
-
const delayMs = this.calculateDelay(attempt, request);
|
|
1112
|
+
const delayMs = this.calculateDelay(attempt, request, error);
|
|
1117
1113
|
await this.delay(delayMs);
|
|
1118
1114
|
}
|
|
1119
1115
|
}
|
|
@@ -1140,7 +1136,7 @@ var RetryHandler = class {
|
|
|
1140
1136
|
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1141
1137
|
throw error;
|
|
1142
1138
|
}
|
|
1143
|
-
const delayMs = this.calculateDelay(attempt, request);
|
|
1139
|
+
const delayMs = this.calculateDelay(attempt, request, error);
|
|
1144
1140
|
await this.delay(delayMs);
|
|
1145
1141
|
}
|
|
1146
1142
|
}
|
|
@@ -1173,18 +1169,25 @@ var RetryHandler = class {
|
|
|
1173
1169
|
return shouldRetryStatus && shouldRetryMethod;
|
|
1174
1170
|
}
|
|
1175
1171
|
/**
|
|
1176
|
-
* Calculates the delay before the next retry attempt
|
|
1177
|
-
*
|
|
1172
|
+
* Calculates the delay before the next retry attempt. A server rate-limit timing header
|
|
1173
|
+
* (Retry-After / X-RateLimit-Reset) on the error, when present, overrides the computed
|
|
1174
|
+
* exponential backoff; otherwise falls back to exponential backoff with optional jitter.
|
|
1178
1175
|
* @param attempt - The current retry attempt number (1-indexed)
|
|
1179
1176
|
* @param request - The HTTP request being retried
|
|
1177
|
+
* @param error - The error that triggered the retry (carries the response headers)
|
|
1180
1178
|
* @returns The delay in milliseconds, capped at the configured maximum delay
|
|
1181
1179
|
*/
|
|
1182
|
-
calculateDelay(attempt, request) {
|
|
1183
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1184
|
-
const
|
|
1185
|
-
const
|
|
1186
|
-
|
|
1187
|
-
|
|
1180
|
+
calculateDelay(attempt, request, error) {
|
|
1181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1182
|
+
const maxRetryAfterDelay = (_b = (_a = request.config.retry) == null ? void 0 : _a.maxRetryAfterDelayMs) != null ? _b : 6e4;
|
|
1183
|
+
const headerDelay = this.retryAfterDelay(error, maxRetryAfterDelay);
|
|
1184
|
+
if (headerDelay !== null) {
|
|
1185
|
+
return Math.floor(headerDelay);
|
|
1186
|
+
}
|
|
1187
|
+
const baseDelay = (_d = (_c = request.config.retry) == null ? void 0 : _c.delayMs) != null ? _d : 150;
|
|
1188
|
+
const backoffFactor = (_f = (_e = request.config.retry) == null ? void 0 : _e.backoffFactor) != null ? _f : 2;
|
|
1189
|
+
const maxDelay = (_h = (_g = request.config.retry) == null ? void 0 : _g.maxDelayMs) != null ? _h : 5e3;
|
|
1190
|
+
const jitter = (_j = (_i = request.config.retry) == null ? void 0 : _i.jitterMs) != null ? _j : 50;
|
|
1188
1191
|
let delay = baseDelay * Math.pow(backoffFactor, attempt - 1);
|
|
1189
1192
|
delay = Math.min(delay, maxDelay);
|
|
1190
1193
|
if (jitter > 0) {
|
|
@@ -1192,6 +1195,65 @@ var RetryHandler = class {
|
|
|
1192
1195
|
}
|
|
1193
1196
|
return Math.floor(delay);
|
|
1194
1197
|
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Returns the server-directed retry delay (ms) from rate-limit response headers,
|
|
1200
|
+
* honoring Retry-After (delta-seconds or HTTP-date) and, when absent, X-RateLimit-Reset
|
|
1201
|
+
* (epoch seconds), clamped to maxRetryAfterDelayMs. Returns null when no usable header is
|
|
1202
|
+
* present so the caller falls back to the computed exponential backoff.
|
|
1203
|
+
* @param error - The error that triggered the retry (carries the response headers)
|
|
1204
|
+
* @param maxRetryAfterDelayMs - Upper bound for a server-directed delay
|
|
1205
|
+
* @returns The delay in milliseconds, or null to use exponential backoff
|
|
1206
|
+
*/
|
|
1207
|
+
retryAfterDelay(error, maxRetryAfterDelayMs) {
|
|
1208
|
+
var _a;
|
|
1209
|
+
const headers = (_a = error == null ? void 0 : error.metadata) == null ? void 0 : _a.headers;
|
|
1210
|
+
if (!headers || maxRetryAfterDelayMs <= 0) {
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
const retryAfterMs = headers["retry-after-ms"];
|
|
1214
|
+
if (retryAfterMs !== void 0 && /^\d+(\.\d+)?$/.test(retryAfterMs.trim())) {
|
|
1215
|
+
return Math.min(Number(retryAfterMs.trim()), maxRetryAfterDelayMs);
|
|
1216
|
+
}
|
|
1217
|
+
const seconds = this.parseRetryAfter(headers["retry-after"]);
|
|
1218
|
+
if (seconds !== null) {
|
|
1219
|
+
return Math.min(Math.max(seconds * 1e3, 0), maxRetryAfterDelayMs);
|
|
1220
|
+
}
|
|
1221
|
+
const reset = headers["x-ratelimit-reset"];
|
|
1222
|
+
if (reset !== void 0 && reset.trim() !== "") {
|
|
1223
|
+
const epoch = Number(reset);
|
|
1224
|
+
if (Number.isFinite(epoch)) {
|
|
1225
|
+
const deltaMs = epoch * 1e3 - Date.now();
|
|
1226
|
+
if (deltaMs > 0) {
|
|
1227
|
+
return Math.min(deltaMs, maxRetryAfterDelayMs);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
return null;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Parses a Retry-After header value: an integer/float number of seconds, or an HTTP-date
|
|
1235
|
+
* (a past date yields 0). Returns the delay in seconds, or null if empty/unparseable.
|
|
1236
|
+
* @param value - The raw Retry-After header value
|
|
1237
|
+
* @returns The delay in seconds, or null
|
|
1238
|
+
*/
|
|
1239
|
+
parseRetryAfter(value) {
|
|
1240
|
+
if (value === void 0) {
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
const trimmed = value.trim();
|
|
1244
|
+
if (trimmed === "") {
|
|
1245
|
+
return null;
|
|
1246
|
+
}
|
|
1247
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
1248
|
+
return Number(trimmed);
|
|
1249
|
+
}
|
|
1250
|
+
const dateMs = Date.parse(trimmed);
|
|
1251
|
+
if (!Number.isNaN(dateMs)) {
|
|
1252
|
+
const deltaSeconds = (dateMs - Date.now()) / 1e3;
|
|
1253
|
+
return deltaSeconds > 0 ? deltaSeconds : 0;
|
|
1254
|
+
}
|
|
1255
|
+
return null;
|
|
1256
|
+
}
|
|
1195
1257
|
/**
|
|
1196
1258
|
* Delays execution for a specified duration before retrying.
|
|
1197
1259
|
* @param delayMs - The delay in milliseconds
|
|
@@ -1553,7 +1615,7 @@ var QuerySerializer = class extends Serializer {
|
|
|
1553
1615
|
}
|
|
1554
1616
|
const query = [];
|
|
1555
1617
|
queryParams.forEach((param) => {
|
|
1556
|
-
if (param.value === void 0) {
|
|
1618
|
+
if (param.value === void 0 || param.value === null) {
|
|
1557
1619
|
return;
|
|
1558
1620
|
}
|
|
1559
1621
|
return query.push(`${this.serializeValue(param)}`);
|
|
@@ -1575,7 +1637,7 @@ var HeaderSerializer = class extends Serializer {
|
|
|
1575
1637
|
}
|
|
1576
1638
|
const headers = {};
|
|
1577
1639
|
headerParams.forEach((param) => {
|
|
1578
|
-
if (!param.key) {
|
|
1640
|
+
if (!param.key || param.value === void 0 || param.value === null) {
|
|
1579
1641
|
return;
|
|
1580
1642
|
}
|
|
1581
1643
|
headers[param.key] = this.serializeValue(param);
|
|
@@ -1597,7 +1659,7 @@ var CookieSerializer = class {
|
|
|
1597
1659
|
}
|
|
1598
1660
|
const cookies = {};
|
|
1599
1661
|
cookieParams.forEach((param) => {
|
|
1600
|
-
if (!param.key || param.value === void 0) {
|
|
1662
|
+
if (!param.key || param.value === void 0 || param.value === null) {
|
|
1601
1663
|
return;
|
|
1602
1664
|
}
|
|
1603
1665
|
cookies[param.key] = this.serializeCookieValue(param);
|
|
@@ -1917,7 +1979,6 @@ var RequestBuilder = class {
|
|
|
1917
1979
|
clientId: "",
|
|
1918
1980
|
clientSecret: "",
|
|
1919
1981
|
retry: {
|
|
1920
|
-
attempts: 3,
|
|
1921
1982
|
delayMs: 150,
|
|
1922
1983
|
maxDelayMs: 5e3,
|
|
1923
1984
|
backoffFactor: 2,
|
|
@@ -1938,7 +1999,7 @@ var RequestBuilder = class {
|
|
|
1938
1999
|
};
|
|
1939
2000
|
this.addHeaderParam({
|
|
1940
2001
|
key: "User-Agent",
|
|
1941
|
-
value: "postman-codegen/
|
|
2002
|
+
value: "postman-codegen/2.6.0 celitech-sdk/2.0.7 (typescript)"
|
|
1942
2003
|
});
|
|
1943
2004
|
}
|
|
1944
2005
|
setConfig(config) {
|
|
@@ -2438,6 +2499,22 @@ var ThrowableError = class extends Error {
|
|
|
2438
2499
|
this.message = message;
|
|
2439
2500
|
this.response = response;
|
|
2440
2501
|
}
|
|
2502
|
+
/**
|
|
2503
|
+
* Creates an error instance from a response body.
|
|
2504
|
+
* Parsing (which can throw) is kept out of the constructor so that constructing
|
|
2505
|
+
* an error while handling an error response never throws. The base implementation
|
|
2506
|
+
* simply constructs the instance; subclasses may override to populate typed fields.
|
|
2507
|
+
*
|
|
2508
|
+
* Contract: every subclass constructor must accept `(message, response?)`. The base
|
|
2509
|
+
* uses `new this(message, response)`, so a subclass with a different constructor
|
|
2510
|
+
* signature must override `from()`.
|
|
2511
|
+
* @param message - The error message
|
|
2512
|
+
* @param response - Optional response data associated with the error
|
|
2513
|
+
* @returns A new error instance
|
|
2514
|
+
*/
|
|
2515
|
+
static from(message, response) {
|
|
2516
|
+
return new this(message, response);
|
|
2517
|
+
}
|
|
2441
2518
|
/**
|
|
2442
2519
|
* Throws this error instance.
|
|
2443
2520
|
* Convenience method for explicitly throwing the error.
|
|
@@ -2461,11 +2538,16 @@ var BadRequest = class extends ThrowableError {
|
|
|
2461
2538
|
super(message);
|
|
2462
2539
|
this.message = message;
|
|
2463
2540
|
this.response = response;
|
|
2464
|
-
|
|
2465
|
-
|
|
2541
|
+
}
|
|
2542
|
+
static from(message, response) {
|
|
2543
|
+
const error = new BadRequest(message, response);
|
|
2544
|
+
const result = badRequestResponse.safeParse(response);
|
|
2545
|
+
const parsedResponse = result.success ? result.data : response || {};
|
|
2546
|
+
error.message = parsedResponse.message || "";
|
|
2547
|
+
return error;
|
|
2466
2548
|
}
|
|
2467
2549
|
throw() {
|
|
2468
|
-
const error =
|
|
2550
|
+
const error = BadRequest.from(this.message, this.response);
|
|
2469
2551
|
error.metadata = this.metadata;
|
|
2470
2552
|
throw error;
|
|
2471
2553
|
}
|
|
@@ -2485,11 +2567,16 @@ var Unauthorized = class extends ThrowableError {
|
|
|
2485
2567
|
super(message);
|
|
2486
2568
|
this.message = message;
|
|
2487
2569
|
this.response = response;
|
|
2488
|
-
|
|
2489
|
-
|
|
2570
|
+
}
|
|
2571
|
+
static from(message, response) {
|
|
2572
|
+
const error = new Unauthorized(message, response);
|
|
2573
|
+
const result = unauthorizedResponse.safeParse(response);
|
|
2574
|
+
const parsedResponse = result.success ? result.data : response || {};
|
|
2575
|
+
error.message = parsedResponse.message || "";
|
|
2576
|
+
return error;
|
|
2490
2577
|
}
|
|
2491
2578
|
throw() {
|
|
2492
|
-
const error =
|
|
2579
|
+
const error = Unauthorized.from(this.message, this.response);
|
|
2493
2580
|
error.metadata = this.metadata;
|
|
2494
2581
|
throw error;
|
|
2495
2582
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -336,7 +336,7 @@ var TransportHookAdapter = class {
|
|
|
336
336
|
function getContentTypeDefinition(contentType) {
|
|
337
337
|
const ct = contentType.toLowerCase();
|
|
338
338
|
if (ct.startsWith("application/") && ct.includes("xml")) {
|
|
339
|
-
return "
|
|
339
|
+
return "text" /* Text */;
|
|
340
340
|
}
|
|
341
341
|
if (ct === "application/x-www-form-urlencoded") {
|
|
342
342
|
return "form" /* FormUrlEncoded */;
|
|
@@ -409,7 +409,7 @@ var HookHandler = class {
|
|
|
409
409
|
} catch (e) {
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
const customError =
|
|
412
|
+
const customError = error.error.from((json == null ? void 0 : json.message) || "", json);
|
|
413
413
|
customError.metadata = response.metadata;
|
|
414
414
|
customError.throw();
|
|
415
415
|
}
|
|
@@ -546,7 +546,6 @@ var ResponseValidationHandler = class {
|
|
|
546
546
|
["image" /* Image */]: this.decodeFile,
|
|
547
547
|
["multipartFormData" /* MultipartFormData */]: this.decodeMultipartFormData,
|
|
548
548
|
["text" /* Text */]: this.decodeText,
|
|
549
|
-
["xml" /* Xml */]: this.decodeText,
|
|
550
549
|
["form" /* FormUrlEncoded */]: this.decodeFormUrlEncoded,
|
|
551
550
|
["eventStream" /* EventStream */]: this.decodeEventStream
|
|
552
551
|
};
|
|
@@ -762,7 +761,7 @@ var RequestValidationHandler = class {
|
|
|
762
761
|
}
|
|
763
762
|
throw error;
|
|
764
763
|
}
|
|
765
|
-
} else if (request.requestContentType === "
|
|
764
|
+
} else if (request.requestContentType === "text" /* Text */ || request.requestContentType === "image" /* Image */ || request.requestContentType === "binary" /* Binary */) {
|
|
766
765
|
request.body = request.body;
|
|
767
766
|
} else if (request.requestContentType === "form" /* FormUrlEncoded */) {
|
|
768
767
|
request.body = this.toFormUrlEncoded(request);
|
|
@@ -798,7 +797,7 @@ var RequestValidationHandler = class {
|
|
|
798
797
|
});
|
|
799
798
|
return params.toString();
|
|
800
799
|
}
|
|
801
|
-
if (typeof validatedBody === "object" && !Array.isArray(validatedBody)) {
|
|
800
|
+
if (typeof validatedBody === "object" && validatedBody !== null && !Array.isArray(validatedBody)) {
|
|
802
801
|
const params = new URLSearchParams();
|
|
803
802
|
for (const [key, value] of Object.entries(validatedBody)) {
|
|
804
803
|
if (value != null) {
|
|
@@ -1014,10 +1013,7 @@ var RequestFetchAdapter = class {
|
|
|
1014
1013
|
return headers;
|
|
1015
1014
|
}
|
|
1016
1015
|
toArrayBuffer(uint8Array) {
|
|
1017
|
-
return uint8Array.buffer
|
|
1018
|
-
uint8Array.byteOffset,
|
|
1019
|
-
uint8Array.byteOffset + uint8Array.byteLength
|
|
1020
|
-
);
|
|
1016
|
+
return new Uint8Array(uint8Array).buffer;
|
|
1021
1017
|
}
|
|
1022
1018
|
};
|
|
1023
1019
|
|
|
@@ -1067,7 +1063,7 @@ var RetryHandler = class {
|
|
|
1067
1063
|
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1068
1064
|
throw error;
|
|
1069
1065
|
}
|
|
1070
|
-
const delayMs = this.calculateDelay(attempt, request);
|
|
1066
|
+
const delayMs = this.calculateDelay(attempt, request, error);
|
|
1071
1067
|
await this.delay(delayMs);
|
|
1072
1068
|
}
|
|
1073
1069
|
}
|
|
@@ -1094,7 +1090,7 @@ var RetryHandler = class {
|
|
|
1094
1090
|
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1095
1091
|
throw error;
|
|
1096
1092
|
}
|
|
1097
|
-
const delayMs = this.calculateDelay(attempt, request);
|
|
1093
|
+
const delayMs = this.calculateDelay(attempt, request, error);
|
|
1098
1094
|
await this.delay(delayMs);
|
|
1099
1095
|
}
|
|
1100
1096
|
}
|
|
@@ -1127,18 +1123,25 @@ var RetryHandler = class {
|
|
|
1127
1123
|
return shouldRetryStatus && shouldRetryMethod;
|
|
1128
1124
|
}
|
|
1129
1125
|
/**
|
|
1130
|
-
* Calculates the delay before the next retry attempt
|
|
1131
|
-
*
|
|
1126
|
+
* Calculates the delay before the next retry attempt. A server rate-limit timing header
|
|
1127
|
+
* (Retry-After / X-RateLimit-Reset) on the error, when present, overrides the computed
|
|
1128
|
+
* exponential backoff; otherwise falls back to exponential backoff with optional jitter.
|
|
1132
1129
|
* @param attempt - The current retry attempt number (1-indexed)
|
|
1133
1130
|
* @param request - The HTTP request being retried
|
|
1131
|
+
* @param error - The error that triggered the retry (carries the response headers)
|
|
1134
1132
|
* @returns The delay in milliseconds, capped at the configured maximum delay
|
|
1135
1133
|
*/
|
|
1136
|
-
calculateDelay(attempt, request) {
|
|
1137
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1138
|
-
const
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
|
|
1134
|
+
calculateDelay(attempt, request, error) {
|
|
1135
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1136
|
+
const maxRetryAfterDelay = (_b = (_a = request.config.retry) == null ? void 0 : _a.maxRetryAfterDelayMs) != null ? _b : 6e4;
|
|
1137
|
+
const headerDelay = this.retryAfterDelay(error, maxRetryAfterDelay);
|
|
1138
|
+
if (headerDelay !== null) {
|
|
1139
|
+
return Math.floor(headerDelay);
|
|
1140
|
+
}
|
|
1141
|
+
const baseDelay = (_d = (_c = request.config.retry) == null ? void 0 : _c.delayMs) != null ? _d : 150;
|
|
1142
|
+
const backoffFactor = (_f = (_e = request.config.retry) == null ? void 0 : _e.backoffFactor) != null ? _f : 2;
|
|
1143
|
+
const maxDelay = (_h = (_g = request.config.retry) == null ? void 0 : _g.maxDelayMs) != null ? _h : 5e3;
|
|
1144
|
+
const jitter = (_j = (_i = request.config.retry) == null ? void 0 : _i.jitterMs) != null ? _j : 50;
|
|
1142
1145
|
let delay = baseDelay * Math.pow(backoffFactor, attempt - 1);
|
|
1143
1146
|
delay = Math.min(delay, maxDelay);
|
|
1144
1147
|
if (jitter > 0) {
|
|
@@ -1146,6 +1149,65 @@ var RetryHandler = class {
|
|
|
1146
1149
|
}
|
|
1147
1150
|
return Math.floor(delay);
|
|
1148
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Returns the server-directed retry delay (ms) from rate-limit response headers,
|
|
1154
|
+
* honoring Retry-After (delta-seconds or HTTP-date) and, when absent, X-RateLimit-Reset
|
|
1155
|
+
* (epoch seconds), clamped to maxRetryAfterDelayMs. Returns null when no usable header is
|
|
1156
|
+
* present so the caller falls back to the computed exponential backoff.
|
|
1157
|
+
* @param error - The error that triggered the retry (carries the response headers)
|
|
1158
|
+
* @param maxRetryAfterDelayMs - Upper bound for a server-directed delay
|
|
1159
|
+
* @returns The delay in milliseconds, or null to use exponential backoff
|
|
1160
|
+
*/
|
|
1161
|
+
retryAfterDelay(error, maxRetryAfterDelayMs) {
|
|
1162
|
+
var _a;
|
|
1163
|
+
const headers = (_a = error == null ? void 0 : error.metadata) == null ? void 0 : _a.headers;
|
|
1164
|
+
if (!headers || maxRetryAfterDelayMs <= 0) {
|
|
1165
|
+
return null;
|
|
1166
|
+
}
|
|
1167
|
+
const retryAfterMs = headers["retry-after-ms"];
|
|
1168
|
+
if (retryAfterMs !== void 0 && /^\d+(\.\d+)?$/.test(retryAfterMs.trim())) {
|
|
1169
|
+
return Math.min(Number(retryAfterMs.trim()), maxRetryAfterDelayMs);
|
|
1170
|
+
}
|
|
1171
|
+
const seconds = this.parseRetryAfter(headers["retry-after"]);
|
|
1172
|
+
if (seconds !== null) {
|
|
1173
|
+
return Math.min(Math.max(seconds * 1e3, 0), maxRetryAfterDelayMs);
|
|
1174
|
+
}
|
|
1175
|
+
const reset = headers["x-ratelimit-reset"];
|
|
1176
|
+
if (reset !== void 0 && reset.trim() !== "") {
|
|
1177
|
+
const epoch = Number(reset);
|
|
1178
|
+
if (Number.isFinite(epoch)) {
|
|
1179
|
+
const deltaMs = epoch * 1e3 - Date.now();
|
|
1180
|
+
if (deltaMs > 0) {
|
|
1181
|
+
return Math.min(deltaMs, maxRetryAfterDelayMs);
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return null;
|
|
1186
|
+
}
|
|
1187
|
+
/**
|
|
1188
|
+
* Parses a Retry-After header value: an integer/float number of seconds, or an HTTP-date
|
|
1189
|
+
* (a past date yields 0). Returns the delay in seconds, or null if empty/unparseable.
|
|
1190
|
+
* @param value - The raw Retry-After header value
|
|
1191
|
+
* @returns The delay in seconds, or null
|
|
1192
|
+
*/
|
|
1193
|
+
parseRetryAfter(value) {
|
|
1194
|
+
if (value === void 0) {
|
|
1195
|
+
return null;
|
|
1196
|
+
}
|
|
1197
|
+
const trimmed = value.trim();
|
|
1198
|
+
if (trimmed === "") {
|
|
1199
|
+
return null;
|
|
1200
|
+
}
|
|
1201
|
+
if (/^\d+(\.\d+)?$/.test(trimmed)) {
|
|
1202
|
+
return Number(trimmed);
|
|
1203
|
+
}
|
|
1204
|
+
const dateMs = Date.parse(trimmed);
|
|
1205
|
+
if (!Number.isNaN(dateMs)) {
|
|
1206
|
+
const deltaSeconds = (dateMs - Date.now()) / 1e3;
|
|
1207
|
+
return deltaSeconds > 0 ? deltaSeconds : 0;
|
|
1208
|
+
}
|
|
1209
|
+
return null;
|
|
1210
|
+
}
|
|
1149
1211
|
/**
|
|
1150
1212
|
* Delays execution for a specified duration before retrying.
|
|
1151
1213
|
* @param delayMs - The delay in milliseconds
|
|
@@ -1507,7 +1569,7 @@ var QuerySerializer = class extends Serializer {
|
|
|
1507
1569
|
}
|
|
1508
1570
|
const query = [];
|
|
1509
1571
|
queryParams.forEach((param) => {
|
|
1510
|
-
if (param.value === void 0) {
|
|
1572
|
+
if (param.value === void 0 || param.value === null) {
|
|
1511
1573
|
return;
|
|
1512
1574
|
}
|
|
1513
1575
|
return query.push(`${this.serializeValue(param)}`);
|
|
@@ -1529,7 +1591,7 @@ var HeaderSerializer = class extends Serializer {
|
|
|
1529
1591
|
}
|
|
1530
1592
|
const headers = {};
|
|
1531
1593
|
headerParams.forEach((param) => {
|
|
1532
|
-
if (!param.key) {
|
|
1594
|
+
if (!param.key || param.value === void 0 || param.value === null) {
|
|
1533
1595
|
return;
|
|
1534
1596
|
}
|
|
1535
1597
|
headers[param.key] = this.serializeValue(param);
|
|
@@ -1551,7 +1613,7 @@ var CookieSerializer = class {
|
|
|
1551
1613
|
}
|
|
1552
1614
|
const cookies = {};
|
|
1553
1615
|
cookieParams.forEach((param) => {
|
|
1554
|
-
if (!param.key || param.value === void 0) {
|
|
1616
|
+
if (!param.key || param.value === void 0 || param.value === null) {
|
|
1555
1617
|
return;
|
|
1556
1618
|
}
|
|
1557
1619
|
cookies[param.key] = this.serializeCookieValue(param);
|
|
@@ -1871,7 +1933,6 @@ var RequestBuilder = class {
|
|
|
1871
1933
|
clientId: "",
|
|
1872
1934
|
clientSecret: "",
|
|
1873
1935
|
retry: {
|
|
1874
|
-
attempts: 3,
|
|
1875
1936
|
delayMs: 150,
|
|
1876
1937
|
maxDelayMs: 5e3,
|
|
1877
1938
|
backoffFactor: 2,
|
|
@@ -1892,7 +1953,7 @@ var RequestBuilder = class {
|
|
|
1892
1953
|
};
|
|
1893
1954
|
this.addHeaderParam({
|
|
1894
1955
|
key: "User-Agent",
|
|
1895
|
-
value: "postman-codegen/
|
|
1956
|
+
value: "postman-codegen/2.6.0 celitech-sdk/2.0.7 (typescript)"
|
|
1896
1957
|
});
|
|
1897
1958
|
}
|
|
1898
1959
|
setConfig(config) {
|
|
@@ -2392,6 +2453,22 @@ var ThrowableError = class extends Error {
|
|
|
2392
2453
|
this.message = message;
|
|
2393
2454
|
this.response = response;
|
|
2394
2455
|
}
|
|
2456
|
+
/**
|
|
2457
|
+
* Creates an error instance from a response body.
|
|
2458
|
+
* Parsing (which can throw) is kept out of the constructor so that constructing
|
|
2459
|
+
* an error while handling an error response never throws. The base implementation
|
|
2460
|
+
* simply constructs the instance; subclasses may override to populate typed fields.
|
|
2461
|
+
*
|
|
2462
|
+
* Contract: every subclass constructor must accept `(message, response?)`. The base
|
|
2463
|
+
* uses `new this(message, response)`, so a subclass with a different constructor
|
|
2464
|
+
* signature must override `from()`.
|
|
2465
|
+
* @param message - The error message
|
|
2466
|
+
* @param response - Optional response data associated with the error
|
|
2467
|
+
* @returns A new error instance
|
|
2468
|
+
*/
|
|
2469
|
+
static from(message, response) {
|
|
2470
|
+
return new this(message, response);
|
|
2471
|
+
}
|
|
2395
2472
|
/**
|
|
2396
2473
|
* Throws this error instance.
|
|
2397
2474
|
* Convenience method for explicitly throwing the error.
|
|
@@ -2415,11 +2492,16 @@ var BadRequest = class extends ThrowableError {
|
|
|
2415
2492
|
super(message);
|
|
2416
2493
|
this.message = message;
|
|
2417
2494
|
this.response = response;
|
|
2418
|
-
|
|
2419
|
-
|
|
2495
|
+
}
|
|
2496
|
+
static from(message, response) {
|
|
2497
|
+
const error = new BadRequest(message, response);
|
|
2498
|
+
const result = badRequestResponse.safeParse(response);
|
|
2499
|
+
const parsedResponse = result.success ? result.data : response || {};
|
|
2500
|
+
error.message = parsedResponse.message || "";
|
|
2501
|
+
return error;
|
|
2420
2502
|
}
|
|
2421
2503
|
throw() {
|
|
2422
|
-
const error =
|
|
2504
|
+
const error = BadRequest.from(this.message, this.response);
|
|
2423
2505
|
error.metadata = this.metadata;
|
|
2424
2506
|
throw error;
|
|
2425
2507
|
}
|
|
@@ -2439,11 +2521,16 @@ var Unauthorized = class extends ThrowableError {
|
|
|
2439
2521
|
super(message);
|
|
2440
2522
|
this.message = message;
|
|
2441
2523
|
this.response = response;
|
|
2442
|
-
|
|
2443
|
-
|
|
2524
|
+
}
|
|
2525
|
+
static from(message, response) {
|
|
2526
|
+
const error = new Unauthorized(message, response);
|
|
2527
|
+
const result = unauthorizedResponse.safeParse(response);
|
|
2528
|
+
const parsedResponse = result.success ? result.data : response || {};
|
|
2529
|
+
error.message = parsedResponse.message || "";
|
|
2530
|
+
return error;
|
|
2444
2531
|
}
|
|
2445
2532
|
throw() {
|
|
2446
|
-
const error =
|
|
2533
|
+
const error = Unauthorized.from(this.message, this.response);
|
|
2447
2534
|
error.metadata = this.metadata;
|
|
2448
2535
|
throw error;
|
|
2449
2536
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "celitech-sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Welcome to the CELITECH API documentation! Useful links: [Homepage](https://www.celitech.com) | [Support email](mailto:support@celitech.com) | [Blog](https://www.celitech.com/blog/)",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|