celitech-sdk 1.3.64 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -9
- package/dist/index.d.ts +189 -62
- package/dist/index.js +440 -159
- package/dist/index.mjs +440 -159
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -281,7 +281,11 @@ var TransportHookAdapter = class {
|
|
|
281
281
|
method: newRequest.method,
|
|
282
282
|
path: newRequest.path,
|
|
283
283
|
body: newRequest.body,
|
|
284
|
-
queryParams: this.hookParamsToTransportParams(
|
|
284
|
+
queryParams: this.hookParamsToTransportParams(
|
|
285
|
+
newRequest.queryParams,
|
|
286
|
+
request.queryParams,
|
|
287
|
+
true
|
|
288
|
+
),
|
|
285
289
|
headers: this.hookParamsToTransportParams(newRequest.headers, request.headers, false),
|
|
286
290
|
pathParams: this.hookParamsToTransportParams(newRequest.pathParams, request.headers, false)
|
|
287
291
|
});
|
|
@@ -445,7 +449,9 @@ var HookHandler = class {
|
|
|
445
449
|
if (error) {
|
|
446
450
|
const decodedBody2 = new TextDecoder().decode(arrayBuffer);
|
|
447
451
|
const json = JSON.parse(decodedBody2);
|
|
448
|
-
new error.error((json == null ? void 0 : json.message) || "", json)
|
|
452
|
+
const customError = new error.error((json == null ? void 0 : json.message) || "", json);
|
|
453
|
+
customError.metadata = response.metadata;
|
|
454
|
+
customError.throw();
|
|
449
455
|
}
|
|
450
456
|
const decodedBody = new TextDecoder().decode(arrayBuffer);
|
|
451
457
|
throw new HttpError(
|
|
@@ -648,8 +654,8 @@ var ResponseValidationHandler = class {
|
|
|
648
654
|
* @returns The validated data (parsed if validation enabled, raw otherwise)
|
|
649
655
|
*/
|
|
650
656
|
validate(request, response, data) {
|
|
651
|
-
var _a;
|
|
652
|
-
if ((_a = request.validation) == null ? void 0 : _a.responseValidation) {
|
|
657
|
+
var _a, _b;
|
|
658
|
+
if ((_b = (_a = request.config.validation) == null ? void 0 : _a.responseValidation) != null ? _b : true) {
|
|
653
659
|
return response.schema.parse(data);
|
|
654
660
|
}
|
|
655
661
|
return data;
|
|
@@ -722,7 +728,9 @@ var ValidationError = class extends Error {
|
|
|
722
728
|
}
|
|
723
729
|
const error = [
|
|
724
730
|
`ValidationError:`,
|
|
725
|
-
...zodError.issues.map(
|
|
731
|
+
...zodError.issues.map(
|
|
732
|
+
(issue) => ` Property: ${issue.path.join(".")}. Message: ${issue.message}`
|
|
733
|
+
),
|
|
726
734
|
" Validated:",
|
|
727
735
|
...actual.split("\n").map((line) => ` ${line}`)
|
|
728
736
|
].join("\n");
|
|
@@ -1030,7 +1038,10 @@ var RequestFetchAdapter = class {
|
|
|
1030
1038
|
return headers;
|
|
1031
1039
|
}
|
|
1032
1040
|
toArrayBuffer(uint8Array) {
|
|
1033
|
-
return uint8Array.buffer.slice(
|
|
1041
|
+
return uint8Array.buffer.slice(
|
|
1042
|
+
uint8Array.byteOffset,
|
|
1043
|
+
uint8Array.byteOffset + uint8Array.byteLength
|
|
1044
|
+
);
|
|
1034
1045
|
}
|
|
1035
1046
|
};
|
|
1036
1047
|
|
|
@@ -1061,23 +1072,27 @@ var RetryHandler = class {
|
|
|
1061
1072
|
/**
|
|
1062
1073
|
* Handles a standard HTTP request with retry logic.
|
|
1063
1074
|
* Retries failed requests based on the configured retry settings.
|
|
1075
|
+
* Implements exponential backoff with optional jitter between retry attempts.
|
|
1064
1076
|
* @template T - The expected response data type
|
|
1065
1077
|
* @param request - The HTTP request to process
|
|
1066
1078
|
* @returns A promise that resolves to the HTTP response
|
|
1067
1079
|
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1068
1080
|
*/
|
|
1069
1081
|
async handle(request) {
|
|
1082
|
+
var _a, _b;
|
|
1070
1083
|
if (!this.next) {
|
|
1071
1084
|
throw new Error("No next handler set in retry handler.");
|
|
1072
1085
|
}
|
|
1073
|
-
|
|
1086
|
+
const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
|
|
1087
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
1074
1088
|
try {
|
|
1075
1089
|
return await this.next.handle(request);
|
|
1076
1090
|
} catch (error) {
|
|
1077
|
-
if (!this.shouldRetry(error) || attempt ===
|
|
1091
|
+
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1078
1092
|
throw error;
|
|
1079
1093
|
}
|
|
1080
|
-
|
|
1094
|
+
const delayMs = this.calculateDelay(attempt, request);
|
|
1095
|
+
await this.delay(delayMs);
|
|
1081
1096
|
}
|
|
1082
1097
|
}
|
|
1083
1098
|
throw new Error("Error retrying request.");
|
|
@@ -1090,38 +1105,78 @@ var RetryHandler = class {
|
|
|
1090
1105
|
* @throws Error if no next handler is set, or if all retry attempts fail
|
|
1091
1106
|
*/
|
|
1092
1107
|
async *stream(request) {
|
|
1108
|
+
var _a, _b;
|
|
1093
1109
|
if (!this.next) {
|
|
1094
1110
|
throw new Error("No next handler set in retry handler.");
|
|
1095
1111
|
}
|
|
1096
|
-
|
|
1112
|
+
const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
|
|
1113
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
1097
1114
|
try {
|
|
1098
1115
|
yield* this.next.stream(request);
|
|
1099
1116
|
return;
|
|
1100
1117
|
} catch (error) {
|
|
1101
|
-
if (!this.shouldRetry(error) || attempt ===
|
|
1118
|
+
if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
|
|
1102
1119
|
throw error;
|
|
1103
1120
|
}
|
|
1104
|
-
|
|
1121
|
+
const delayMs = this.calculateDelay(attempt, request);
|
|
1122
|
+
await this.delay(delayMs);
|
|
1105
1123
|
}
|
|
1106
1124
|
}
|
|
1107
1125
|
throw new Error("Error retrying request.");
|
|
1108
1126
|
}
|
|
1109
1127
|
/**
|
|
1110
1128
|
* Determines if an error should trigger a retry.
|
|
1111
|
-
*
|
|
1129
|
+
* Checks both HTTP status codes and HTTP methods against the configured retry settings.
|
|
1130
|
+
* By default, retries all 5xx server errors and specific 4xx client errors (408 Timeout, 429 Rate Limit).
|
|
1112
1131
|
* @param error - The error to check
|
|
1132
|
+
* @param request - The HTTP request being retried
|
|
1113
1133
|
* @returns True if the request should be retried, false otherwise
|
|
1114
1134
|
*/
|
|
1115
|
-
shouldRetry(error) {
|
|
1116
|
-
|
|
1135
|
+
shouldRetry(error, request) {
|
|
1136
|
+
var _a, _b, _c;
|
|
1137
|
+
if (!(error instanceof HttpError)) {
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
const httpMethodsToRetry = (_b = (_a = request.config.retry) == null ? void 0 : _a.httpMethodsToRetry) != null ? _b : [
|
|
1141
|
+
"GET",
|
|
1142
|
+
"POST",
|
|
1143
|
+
"PUT",
|
|
1144
|
+
"DELETE",
|
|
1145
|
+
"PATCH",
|
|
1146
|
+
"HEAD",
|
|
1147
|
+
"OPTIONS"
|
|
1148
|
+
];
|
|
1149
|
+
const shouldRetryStatus = ((_c = request.config.retry) == null ? void 0 : _c.statusCodesToRetry) ? request.config.retry.statusCodesToRetry.includes(error.metadata.status) : error.metadata.status >= 500 || [408, 429].includes(error.metadata.status);
|
|
1150
|
+
const shouldRetryMethod = httpMethodsToRetry.includes(request.method);
|
|
1151
|
+
return shouldRetryStatus && shouldRetryMethod;
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Calculates the delay before the next retry attempt using exponential backoff.
|
|
1155
|
+
* Optionally adds jitter to prevent thundering herd problems.
|
|
1156
|
+
* @param attempt - The current retry attempt number (1-indexed)
|
|
1157
|
+
* @param request - The HTTP request being retried
|
|
1158
|
+
* @returns The delay in milliseconds, capped at the configured maximum delay
|
|
1159
|
+
*/
|
|
1160
|
+
calculateDelay(attempt, request) {
|
|
1161
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1162
|
+
const baseDelay = (_b = (_a = request.config.retry) == null ? void 0 : _a.delayMs) != null ? _b : 150;
|
|
1163
|
+
const backoffFactor = (_d = (_c = request.config.retry) == null ? void 0 : _c.backoffFactor) != null ? _d : 2;
|
|
1164
|
+
const maxDelay = (_f = (_e = request.config.retry) == null ? void 0 : _e.maxDelayMs) != null ? _f : 5e3;
|
|
1165
|
+
const jitter = (_h = (_g = request.config.retry) == null ? void 0 : _g.jitterMs) != null ? _h : 50;
|
|
1166
|
+
let delay = baseDelay * Math.pow(backoffFactor, attempt - 1);
|
|
1167
|
+
delay = Math.min(delay, maxDelay);
|
|
1168
|
+
if (jitter > 0) {
|
|
1169
|
+
delay += Math.random() * jitter;
|
|
1170
|
+
}
|
|
1171
|
+
return Math.floor(delay);
|
|
1117
1172
|
}
|
|
1118
1173
|
/**
|
|
1119
1174
|
* Delays execution for a specified duration before retrying.
|
|
1120
|
-
* @param delayMs - The delay in milliseconds
|
|
1175
|
+
* @param delayMs - The delay in milliseconds
|
|
1121
1176
|
* @returns A promise that resolves after the delay
|
|
1122
1177
|
*/
|
|
1123
1178
|
delay(delayMs) {
|
|
1124
|
-
if (
|
|
1179
|
+
if (delayMs <= 0) {
|
|
1125
1180
|
return Promise.resolve();
|
|
1126
1181
|
}
|
|
1127
1182
|
return new Promise((resolve, reject) => {
|
|
@@ -1232,6 +1287,15 @@ var HttpClient = class {
|
|
|
1232
1287
|
call(request) {
|
|
1233
1288
|
return this.requestHandlerChain.callChain(request);
|
|
1234
1289
|
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Executes a standard HTTP request and returns only the data directly.
|
|
1292
|
+
* @template T - The expected response data type
|
|
1293
|
+
* @param request - The HTTP request to execute
|
|
1294
|
+
* @returns A promise that resolves to the response data
|
|
1295
|
+
*/
|
|
1296
|
+
callDirect(request) {
|
|
1297
|
+
return this.call(request).then((response) => response.data);
|
|
1298
|
+
}
|
|
1235
1299
|
/**
|
|
1236
1300
|
* Executes a streaming HTTP request that yields responses incrementally.
|
|
1237
1301
|
* @template T - The expected response data type for each chunk
|
|
@@ -1352,6 +1416,61 @@ var BaseService = class {
|
|
|
1352
1416
|
this.tokenManager = tokenManager;
|
|
1353
1417
|
this.client = new HttpClient(this.config);
|
|
1354
1418
|
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Sets service-level configuration that applies to all methods in this service.
|
|
1421
|
+
* @param config - Partial configuration to override SDK-level defaults
|
|
1422
|
+
* @returns This service instance for method chaining
|
|
1423
|
+
*/
|
|
1424
|
+
setConfig(config) {
|
|
1425
|
+
this.serviceConfig = config;
|
|
1426
|
+
return this;
|
|
1427
|
+
}
|
|
1428
|
+
/**
|
|
1429
|
+
* Recursively merges two objects. Plain nested objects are merged key-by-key so a
|
|
1430
|
+
* partial override (e.g. `{ retry: { attempts: 5 } }`) only overwrites the specified
|
|
1431
|
+
* keys instead of replacing the whole nested object. Arrays and non-plain values are
|
|
1432
|
+
* replaced wholesale.
|
|
1433
|
+
*
|
|
1434
|
+
* Override keys with the value `undefined` are skipped so the base value is preserved,
|
|
1435
|
+
* matching the common JS merge idiom (e.g. lodash.merge). To explicitly clear a key,
|
|
1436
|
+
* assign `null` or omit the key from the override entirely.
|
|
1437
|
+
*/
|
|
1438
|
+
static deepMerge(base, override) {
|
|
1439
|
+
const result = { ...base };
|
|
1440
|
+
for (const [key, value] of Object.entries(override)) {
|
|
1441
|
+
const existing = result[key];
|
|
1442
|
+
if (BaseService.isPlainObject(value) && BaseService.isPlainObject(existing)) {
|
|
1443
|
+
result[key] = BaseService.deepMerge(existing, value);
|
|
1444
|
+
} else if (value !== void 0) {
|
|
1445
|
+
result[key] = value;
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
return result;
|
|
1449
|
+
}
|
|
1450
|
+
static isPlainObject(value) {
|
|
1451
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
1452
|
+
}
|
|
1453
|
+
/**
|
|
1454
|
+
* Resolves configuration from the hierarchy: requestConfig > methodConfig > serviceConfig > sdkConfig
|
|
1455
|
+
* Deep-merges all config levels so partial nested overrides (e.g. `{ retry: { attempts: 5 } }`)
|
|
1456
|
+
* preserve unoverridden sibling keys from the SDK default.
|
|
1457
|
+
* @param methodConfig - Method-level configuration override
|
|
1458
|
+
* @param requestConfig - Request-level configuration override
|
|
1459
|
+
* @returns Merged configuration with all overrides applied
|
|
1460
|
+
*/
|
|
1461
|
+
getResolvedConfig(methodConfig, requestConfig) {
|
|
1462
|
+
let merged = { ...this.config };
|
|
1463
|
+
if (this.serviceConfig) {
|
|
1464
|
+
merged = BaseService.deepMerge(merged, this.serviceConfig);
|
|
1465
|
+
}
|
|
1466
|
+
if (methodConfig) {
|
|
1467
|
+
merged = BaseService.deepMerge(merged, methodConfig);
|
|
1468
|
+
}
|
|
1469
|
+
if (requestConfig) {
|
|
1470
|
+
merged = BaseService.deepMerge(merged, requestConfig);
|
|
1471
|
+
}
|
|
1472
|
+
return merged;
|
|
1473
|
+
}
|
|
1355
1474
|
set baseUrl(baseUrl) {
|
|
1356
1475
|
this.config.baseUrl = baseUrl;
|
|
1357
1476
|
}
|
|
@@ -1528,8 +1647,6 @@ var Request = class {
|
|
|
1528
1647
|
this.queryParams = /* @__PURE__ */ new Map();
|
|
1529
1648
|
this.pathParams = /* @__PURE__ */ new Map();
|
|
1530
1649
|
this.cookies = /* @__PURE__ */ new Map();
|
|
1531
|
-
this.validation = {};
|
|
1532
|
-
this.retry = {};
|
|
1533
1650
|
this.baseUrl = params.baseUrl;
|
|
1534
1651
|
this.method = params.method;
|
|
1535
1652
|
this.pathPattern = params.path;
|
|
@@ -1544,8 +1661,6 @@ var Request = class {
|
|
|
1544
1661
|
this.errors = params.errors;
|
|
1545
1662
|
this.requestSchema = params.requestSchema;
|
|
1546
1663
|
this.requestContentType = params.requestContentType;
|
|
1547
|
-
this.retry = params.retry;
|
|
1548
|
-
this.validation = params.validation;
|
|
1549
1664
|
this.pagination = params.pagination;
|
|
1550
1665
|
this.filename = params.filename;
|
|
1551
1666
|
this.filenames = params.filenames;
|
|
@@ -1658,7 +1773,7 @@ var Request = class {
|
|
|
1658
1773
|
* @returns A new Request instance with the specified overrides
|
|
1659
1774
|
*/
|
|
1660
1775
|
copy(overrides) {
|
|
1661
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o
|
|
1776
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
1662
1777
|
const createRequestParams = {
|
|
1663
1778
|
baseUrl: (_a = overrides == null ? void 0 : overrides.baseUrl) != null ? _a : this.baseUrl,
|
|
1664
1779
|
errors: (_b = overrides == null ? void 0 : overrides.errors) != null ? _b : this.errors,
|
|
@@ -1673,10 +1788,8 @@ var Request = class {
|
|
|
1673
1788
|
responses: (_k = overrides == null ? void 0 : overrides.responses) != null ? _k : this.responses,
|
|
1674
1789
|
requestSchema: (_l = overrides == null ? void 0 : overrides.requestSchema) != null ? _l : this.requestSchema,
|
|
1675
1790
|
requestContentType: (_m = overrides == null ? void 0 : overrides.requestContentType) != null ? _m : this.requestContentType,
|
|
1676
|
-
|
|
1677
|
-
|
|
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,
|
|
1791
|
+
filename: (_n = overrides == null ? void 0 : overrides.filename) != null ? _n : this.filename,
|
|
1792
|
+
filenames: (_o = overrides == null ? void 0 : overrides.filenames) != null ? _o : this.filenames,
|
|
1680
1793
|
scopes: overrides == null ? void 0 : overrides.scopes,
|
|
1681
1794
|
tokenManager: this.tokenManager
|
|
1682
1795
|
};
|
|
@@ -1778,55 +1891,73 @@ var RequestBuilder = class {
|
|
|
1778
1891
|
baseUrl: "https://api.celitech.net/v1" /* DEFAULT */,
|
|
1779
1892
|
method: "GET",
|
|
1780
1893
|
path: "",
|
|
1781
|
-
config: {
|
|
1894
|
+
config: {
|
|
1895
|
+
clientId: "",
|
|
1896
|
+
clientSecret: "",
|
|
1897
|
+
retry: {
|
|
1898
|
+
attempts: 3,
|
|
1899
|
+
delayMs: 150,
|
|
1900
|
+
maxDelayMs: 5e3,
|
|
1901
|
+
backoffFactor: 2,
|
|
1902
|
+
jitterMs: 50,
|
|
1903
|
+
httpMethodsToRetry: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]
|
|
1904
|
+
},
|
|
1905
|
+
validation: { responseValidation: true }
|
|
1906
|
+
},
|
|
1782
1907
|
responses: [],
|
|
1783
1908
|
errors: [],
|
|
1784
1909
|
requestSchema: import_zod3.default.any(),
|
|
1785
1910
|
requestContentType: "json" /* Json */,
|
|
1786
|
-
retry: {
|
|
1787
|
-
attempts: 3,
|
|
1788
|
-
delayMs: 150
|
|
1789
|
-
},
|
|
1790
|
-
validation: {
|
|
1791
|
-
responseValidation: true
|
|
1792
|
-
},
|
|
1793
1911
|
pathParams: /* @__PURE__ */ new Map(),
|
|
1794
1912
|
queryParams: /* @__PURE__ */ new Map(),
|
|
1795
1913
|
headers: /* @__PURE__ */ new Map(),
|
|
1796
1914
|
cookies: /* @__PURE__ */ new Map(),
|
|
1797
1915
|
tokenManager: new OAuthTokenManager()
|
|
1798
1916
|
};
|
|
1917
|
+
this.addHeaderParam({
|
|
1918
|
+
key: "User-Agent",
|
|
1919
|
+
value: "postman-codegen/1.1.2 celitech-sdk/2.0.0 (typescript)"
|
|
1920
|
+
});
|
|
1799
1921
|
}
|
|
1800
|
-
|
|
1922
|
+
setConfig(config) {
|
|
1801
1923
|
var _a, _b;
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
this.params.retry.attempts = sdkConfig.retry.attempts;
|
|
1924
|
+
let mergedRetry = (_a = config.retry) != null ? _a : this.params.config.retry;
|
|
1925
|
+
if (config.retry !== void 0 && this.params.config.retry !== void 0) {
|
|
1926
|
+
mergedRetry = { ...this.params.config.retry, ...config.retry };
|
|
1806
1927
|
}
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
var _a, _b;
|
|
1811
|
-
if (((_a = requestConfig == null ? void 0 : requestConfig.retry) == null ? void 0 : _a.delayMs) !== void 0) {
|
|
1812
|
-
this.params.retry.delayMs = requestConfig.retry.delayMs;
|
|
1813
|
-
} else if (((_b = sdkConfig == null ? void 0 : sdkConfig.retry) == null ? void 0 : _b.delayMs) !== void 0) {
|
|
1814
|
-
this.params.retry.delayMs = sdkConfig.retry.delayMs;
|
|
1928
|
+
let mergedValidation = (_b = config.validation) != null ? _b : this.params.config.validation;
|
|
1929
|
+
if (config.validation !== void 0 && this.params.config.validation !== void 0) {
|
|
1930
|
+
mergedValidation = { ...this.params.config.validation, ...config.validation };
|
|
1815
1931
|
}
|
|
1932
|
+
this.params.config = {
|
|
1933
|
+
...this.params.config,
|
|
1934
|
+
...config,
|
|
1935
|
+
...mergedRetry !== void 0 && { retry: mergedRetry },
|
|
1936
|
+
...mergedValidation !== void 0 && { validation: mergedValidation }
|
|
1937
|
+
};
|
|
1816
1938
|
return this;
|
|
1817
1939
|
}
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1940
|
+
/**
|
|
1941
|
+
* Sets the base URL for the request using hierarchical configuration resolution.
|
|
1942
|
+
*
|
|
1943
|
+
* Resolution logic:
|
|
1944
|
+
* 1. First tries to resolve 'baseUrl' (string) from the resolved config
|
|
1945
|
+
* 2. If no 'baseUrl' found, falls back to 'environment' (enum) from the resolved config
|
|
1946
|
+
* 3. 'baseUrl' always takes precedence over 'environment'
|
|
1947
|
+
*
|
|
1948
|
+
* @param config - Resolved configuration from all hierarchy levels
|
|
1949
|
+
* @returns This builder instance for method chaining
|
|
1950
|
+
*/
|
|
1951
|
+
setBaseUrl(config) {
|
|
1952
|
+
if (!config) {
|
|
1953
|
+
return this;
|
|
1824
1954
|
}
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1955
|
+
if ("baseUrl" in config && typeof config.baseUrl === "string" && config.baseUrl) {
|
|
1956
|
+
this.params.baseUrl = config.baseUrl;
|
|
1957
|
+
return this;
|
|
1958
|
+
}
|
|
1959
|
+
if ("environment" in config && config.environment) {
|
|
1960
|
+
this.params.baseUrl = config.environment;
|
|
1830
1961
|
}
|
|
1831
1962
|
return this;
|
|
1832
1963
|
}
|
|
@@ -1838,10 +1969,6 @@ var RequestBuilder = class {
|
|
|
1838
1969
|
this.params.path = path;
|
|
1839
1970
|
return this;
|
|
1840
1971
|
}
|
|
1841
|
-
setConfig(config) {
|
|
1842
|
-
this.params.config = config;
|
|
1843
|
-
return this;
|
|
1844
|
-
}
|
|
1845
1972
|
setRequestContentType(contentType) {
|
|
1846
1973
|
this.params.requestContentType = contentType;
|
|
1847
1974
|
return this;
|
|
@@ -1884,7 +2011,7 @@ var RequestBuilder = class {
|
|
|
1884
2011
|
}
|
|
1885
2012
|
this.params.headers.set("Authorization", {
|
|
1886
2013
|
key: "Authorization",
|
|
1887
|
-
value: `${prefix != null ? prefix : "
|
|
2014
|
+
value: `${prefix != null ? prefix : "Bearer"} ${accessToken}`,
|
|
1888
2015
|
explode: false,
|
|
1889
2016
|
style: "simple" /* SIMPLE */,
|
|
1890
2017
|
encode: true,
|
|
@@ -2031,66 +2158,66 @@ var RequestBuilder = class {
|
|
|
2031
2158
|
}
|
|
2032
2159
|
};
|
|
2033
2160
|
|
|
2034
|
-
// src/services/o-auth/models/
|
|
2161
|
+
// src/services/o-auth/models/o-auth-token-request.ts
|
|
2035
2162
|
var import_zod4 = require("zod");
|
|
2036
|
-
var
|
|
2163
|
+
var oAuthTokenRequest = import_zod4.z.lazy(() => {
|
|
2037
2164
|
return import_zod4.z.object({
|
|
2038
|
-
grantType: import_zod4.z.string()
|
|
2039
|
-
clientId: import_zod4.z.string()
|
|
2040
|
-
clientSecret: import_zod4.z.string()
|
|
2165
|
+
grantType: import_zod4.z.string(),
|
|
2166
|
+
clientId: import_zod4.z.string(),
|
|
2167
|
+
clientSecret: import_zod4.z.string(),
|
|
2168
|
+
scope: import_zod4.z.string()
|
|
2041
2169
|
});
|
|
2042
2170
|
});
|
|
2043
|
-
var
|
|
2171
|
+
var oAuthTokenRequestResponse = import_zod4.z.lazy(() => {
|
|
2044
2172
|
return import_zod4.z.object({
|
|
2045
|
-
grant_type: import_zod4.z.string()
|
|
2046
|
-
client_id: import_zod4.z.string()
|
|
2047
|
-
client_secret: import_zod4.z.string()
|
|
2173
|
+
grant_type: import_zod4.z.string(),
|
|
2174
|
+
client_id: import_zod4.z.string(),
|
|
2175
|
+
client_secret: import_zod4.z.string(),
|
|
2176
|
+
scope: import_zod4.z.string()
|
|
2048
2177
|
}).transform((data) => ({
|
|
2049
2178
|
grantType: data["grant_type"],
|
|
2050
2179
|
clientId: data["client_id"],
|
|
2051
|
-
clientSecret: data["client_secret"]
|
|
2180
|
+
clientSecret: data["client_secret"],
|
|
2181
|
+
scope: data["scope"]
|
|
2052
2182
|
}));
|
|
2053
2183
|
});
|
|
2054
|
-
var
|
|
2184
|
+
var oAuthTokenRequestRequest = import_zod4.z.lazy(() => {
|
|
2055
2185
|
return import_zod4.z.object({
|
|
2056
|
-
grantType: import_zod4.z.string()
|
|
2057
|
-
clientId: import_zod4.z.string()
|
|
2058
|
-
clientSecret: import_zod4.z.string()
|
|
2186
|
+
grantType: import_zod4.z.string(),
|
|
2187
|
+
clientId: import_zod4.z.string(),
|
|
2188
|
+
clientSecret: import_zod4.z.string(),
|
|
2189
|
+
scope: import_zod4.z.string()
|
|
2059
2190
|
}).transform((data) => ({
|
|
2060
2191
|
grant_type: data["grantType"],
|
|
2061
2192
|
client_id: data["clientId"],
|
|
2062
|
-
client_secret: data["clientSecret"]
|
|
2193
|
+
client_secret: data["clientSecret"],
|
|
2194
|
+
scope: data["scope"]
|
|
2063
2195
|
}));
|
|
2064
2196
|
});
|
|
2065
2197
|
|
|
2066
|
-
// src/services/o-auth/models/
|
|
2198
|
+
// src/services/o-auth/models/o-auth-token-response.ts
|
|
2067
2199
|
var import_zod5 = require("zod");
|
|
2068
|
-
var
|
|
2200
|
+
var oAuthTokenResponse = import_zod5.z.lazy(() => {
|
|
2069
2201
|
return import_zod5.z.object({
|
|
2070
2202
|
accessToken: import_zod5.z.string().optional(),
|
|
2071
|
-
|
|
2072
|
-
expiresIn: import_zod5.z.number().optional()
|
|
2203
|
+
expiresIn: import_zod5.z.number().optional().nullable()
|
|
2073
2204
|
});
|
|
2074
2205
|
});
|
|
2075
|
-
var
|
|
2206
|
+
var oAuthTokenResponseResponse = import_zod5.z.lazy(() => {
|
|
2076
2207
|
return import_zod5.z.object({
|
|
2077
2208
|
access_token: import_zod5.z.string().optional(),
|
|
2078
|
-
|
|
2079
|
-
expires_in: import_zod5.z.number().optional()
|
|
2209
|
+
expires_in: import_zod5.z.number().optional().nullable()
|
|
2080
2210
|
}).transform((data) => ({
|
|
2081
2211
|
accessToken: data["access_token"],
|
|
2082
|
-
tokenType: data["token_type"],
|
|
2083
2212
|
expiresIn: data["expires_in"]
|
|
2084
2213
|
}));
|
|
2085
2214
|
});
|
|
2086
|
-
var
|
|
2215
|
+
var oAuthTokenResponseRequest = import_zod5.z.lazy(() => {
|
|
2087
2216
|
return import_zod5.z.object({
|
|
2088
2217
|
accessToken: import_zod5.z.string().optional(),
|
|
2089
|
-
|
|
2090
|
-
expiresIn: import_zod5.z.number().optional()
|
|
2218
|
+
expiresIn: import_zod5.z.number().optional().nullable()
|
|
2091
2219
|
}).transform((data) => ({
|
|
2092
2220
|
access_token: data["accessToken"],
|
|
2093
|
-
token_type: data["tokenType"],
|
|
2094
2221
|
expires_in: data["expiresIn"]
|
|
2095
2222
|
}));
|
|
2096
2223
|
});
|
|
@@ -2098,17 +2225,27 @@ var getAccessTokenOkResponseRequest = import_zod5.z.lazy(() => {
|
|
|
2098
2225
|
// src/services/o-auth/o-auth-service.ts
|
|
2099
2226
|
var OAuthService = class extends BaseService {
|
|
2100
2227
|
/**
|
|
2101
|
-
*
|
|
2102
|
-
* @param
|
|
2103
|
-
* @returns
|
|
2228
|
+
* Sets method-level configuration for getAccessToken.
|
|
2229
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2230
|
+
* @returns This service instance for method chaining
|
|
2231
|
+
*/
|
|
2232
|
+
setGetAccessTokenConfig(config) {
|
|
2233
|
+
this.getAccessTokenConfig = config;
|
|
2234
|
+
return this;
|
|
2235
|
+
}
|
|
2236
|
+
/**
|
|
2237
|
+
*
|
|
2238
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2239
|
+
* @returns {Promise<HttpResponse<OAuthTokenResponse>>} - OAuth token
|
|
2104
2240
|
*/
|
|
2105
2241
|
async getAccessToken(body, requestConfig) {
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2242
|
+
const resolvedConfig = this.getResolvedConfig(this.getAccessTokenConfig, requestConfig);
|
|
2243
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/oauth2/token").setRequestSchema(oAuthTokenRequestRequest).setTokenManager(this.tokenManager).setRequestContentType("form" /* FormUrlEncoded */).addResponse({
|
|
2244
|
+
schema: oAuthTokenResponseResponse,
|
|
2108
2245
|
contentType: "json" /* Json */,
|
|
2109
2246
|
status: 200
|
|
2110
|
-
}).
|
|
2111
|
-
return this.client.
|
|
2247
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/x-www-form-urlencoded" }).addBody(body).build();
|
|
2248
|
+
return this.client.callDirect(request);
|
|
2112
2249
|
}
|
|
2113
2250
|
};
|
|
2114
2251
|
|
|
@@ -2155,7 +2292,7 @@ var OAuthTokenManager = class {
|
|
|
2155
2292
|
* @throws Error if client credentials are missing or token request fails
|
|
2156
2293
|
*/
|
|
2157
2294
|
async getToken(scopes, config) {
|
|
2158
|
-
var _a, _b, _c
|
|
2295
|
+
var _a, _b, _c;
|
|
2159
2296
|
if (((_a = this.token) == null ? void 0 : _a.hasAllScopes(scopes)) && ((_b = this.token) == null ? void 0 : _b.expiresAt) && this.token.expiresAt - Date.now() > 5e3) {
|
|
2160
2297
|
return this.token;
|
|
2161
2298
|
}
|
|
@@ -2170,23 +2307,21 @@ var OAuthTokenManager = class {
|
|
|
2170
2307
|
},
|
|
2171
2308
|
this
|
|
2172
2309
|
);
|
|
2173
|
-
const response = await oAuth.getAccessToken(
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
);
|
|
2181
|
-
if (!((_d = response.data) == null ? void 0 : _d.accessToken)) {
|
|
2310
|
+
const response = await oAuth.getAccessToken({
|
|
2311
|
+
grantType: "client_credentials",
|
|
2312
|
+
clientId: config.clientId,
|
|
2313
|
+
clientSecret: config.clientSecret,
|
|
2314
|
+
scope: Array.from(scopes).join(" ")
|
|
2315
|
+
});
|
|
2316
|
+
if (!(response == null ? void 0 : response.accessToken)) {
|
|
2182
2317
|
throw new Error(
|
|
2183
2318
|
`OAuthError: token endpoint response did not return access token. Response: ${JSON.stringify(response), void 0, 2}.`
|
|
2184
2319
|
);
|
|
2185
2320
|
}
|
|
2186
2321
|
this.token = new OAuthToken(
|
|
2187
|
-
response.
|
|
2322
|
+
response.accessToken,
|
|
2188
2323
|
updatedScopes,
|
|
2189
|
-
(
|
|
2324
|
+
(response == null ? void 0 : response.expiresIn) ? (response == null ? void 0 : response.expiresIn) * 1e3 + Date.now() : null
|
|
2190
2325
|
);
|
|
2191
2326
|
return this.token;
|
|
2192
2327
|
}
|
|
@@ -2298,7 +2433,9 @@ var BadRequest = class extends ThrowableError {
|
|
|
2298
2433
|
this.message = parsedResponse.message || "";
|
|
2299
2434
|
}
|
|
2300
2435
|
throw() {
|
|
2301
|
-
|
|
2436
|
+
const error = new BadRequest(this.message, this.response);
|
|
2437
|
+
error.metadata = this.metadata;
|
|
2438
|
+
throw error;
|
|
2302
2439
|
}
|
|
2303
2440
|
};
|
|
2304
2441
|
|
|
@@ -2320,19 +2457,31 @@ var Unauthorized = class extends ThrowableError {
|
|
|
2320
2457
|
this.message = parsedResponse.message || "";
|
|
2321
2458
|
}
|
|
2322
2459
|
throw() {
|
|
2323
|
-
|
|
2460
|
+
const error = new Unauthorized(this.message, this.response);
|
|
2461
|
+
error.metadata = this.metadata;
|
|
2462
|
+
throw error;
|
|
2324
2463
|
}
|
|
2325
2464
|
};
|
|
2326
2465
|
|
|
2327
2466
|
// src/services/destinations/destinations-service.ts
|
|
2328
2467
|
var DestinationsService = class extends BaseService {
|
|
2468
|
+
/**
|
|
2469
|
+
* Sets method-level configuration for listDestinations.
|
|
2470
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2471
|
+
* @returns This service instance for method chaining
|
|
2472
|
+
*/
|
|
2473
|
+
setListDestinationsConfig(config) {
|
|
2474
|
+
this.listDestinationsConfig = config;
|
|
2475
|
+
return this;
|
|
2476
|
+
}
|
|
2329
2477
|
/**
|
|
2330
2478
|
* List Destinations
|
|
2331
|
-
* @param {
|
|
2479
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2332
2480
|
* @returns {Promise<HttpResponse<ListDestinationsOkResponse>>} - Successful Response
|
|
2333
2481
|
*/
|
|
2334
2482
|
async listDestinations(requestConfig) {
|
|
2335
|
-
const
|
|
2483
|
+
const resolvedConfig = this.getResolvedConfig(this.listDestinationsConfig, requestConfig);
|
|
2484
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/destinations").setRequestSchema(import_zod10.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
2336
2485
|
schema: listDestinationsOkResponseResponse,
|
|
2337
2486
|
contentType: "json" /* Json */,
|
|
2338
2487
|
status: 200
|
|
@@ -2344,8 +2493,8 @@ var DestinationsService = class extends BaseService {
|
|
|
2344
2493
|
error: Unauthorized,
|
|
2345
2494
|
contentType: "json" /* Json */,
|
|
2346
2495
|
status: 401
|
|
2347
|
-
}).
|
|
2348
|
-
return this.client.
|
|
2496
|
+
}).build();
|
|
2497
|
+
return this.client.callDirect(request);
|
|
2349
2498
|
}
|
|
2350
2499
|
};
|
|
2351
2500
|
|
|
@@ -2440,6 +2589,15 @@ var listPackagesOkResponseRequest = import_zod12.z.lazy(() => {
|
|
|
2440
2589
|
|
|
2441
2590
|
// src/services/packages/packages-service.ts
|
|
2442
2591
|
var PackagesService = class extends BaseService {
|
|
2592
|
+
/**
|
|
2593
|
+
* Sets method-level configuration for listPackages.
|
|
2594
|
+
* @param config - Partial configuration to override service-level defaults
|
|
2595
|
+
* @returns This service instance for method chaining
|
|
2596
|
+
*/
|
|
2597
|
+
setListPackagesConfig(config) {
|
|
2598
|
+
this.listPackagesConfig = config;
|
|
2599
|
+
return this;
|
|
2600
|
+
}
|
|
2443
2601
|
/**
|
|
2444
2602
|
* List Packages
|
|
2445
2603
|
* @param {string} [params.destination] - ISO representation of the package's destination. Supports both ISO2 (e.g., 'FR') and ISO3 (e.g., 'FRA') country codes.
|
|
@@ -2449,11 +2607,21 @@ var PackagesService = class extends BaseService {
|
|
|
2449
2607
|
* @param {number} [params.limit] - Maximum number of packages to be returned in the response. The value must be greater than 0 and less than or equal to 160. If not provided, the default value is 20
|
|
2450
2608
|
* @param {number} [params.startTime] - Epoch value representing the start time of the package's validity. This timestamp can be set to the current time or any time within the next 12 months
|
|
2451
2609
|
* @param {number} [params.endTime] - Epoch value representing the end time of the package's validity. End time can be maximum 90 days after Start time
|
|
2452
|
-
* @param {
|
|
2610
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
2453
2611
|
* @returns {Promise<HttpResponse<ListPackagesOkResponse>>} - Successful Response
|
|
2454
2612
|
*/
|
|
2455
2613
|
async listPackages(params, requestConfig) {
|
|
2456
|
-
const
|
|
2614
|
+
const resolvedConfig = this.getResolvedConfig(this.listPackagesConfig, requestConfig);
|
|
2615
|
+
import_zod13.z.object({
|
|
2616
|
+
destination: import_zod13.z.string().optional(),
|
|
2617
|
+
startDate: import_zod13.z.string().optional(),
|
|
2618
|
+
endDate: import_zod13.z.string().optional(),
|
|
2619
|
+
afterCursor: import_zod13.z.string().optional(),
|
|
2620
|
+
limit: import_zod13.z.number().optional(),
|
|
2621
|
+
startTime: import_zod13.z.number().optional(),
|
|
2622
|
+
endTime: import_zod13.z.number().optional()
|
|
2623
|
+
}).parse(params != null ? params : {});
|
|
2624
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/packages").setRequestSchema(import_zod13.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
2457
2625
|
schema: listPackagesOkResponseResponse,
|
|
2458
2626
|
contentType: "json" /* Json */,
|
|
2459
2627
|
status: 200
|
|
@@ -2465,7 +2633,7 @@ var PackagesService = class extends BaseService {
|
|
|
2465
2633
|
error: Unauthorized,
|
|
2466
2634
|
contentType: "json" /* Json */,
|
|
2467
2635
|
status: 401
|
|
2468
|
-
}).
|
|
2636
|
+
}).addQueryParam({
|
|
2469
2637
|
key: "destination",
|
|
2470
2638
|
value: params == null ? void 0 : params.destination
|
|
2471
2639
|
}).addQueryParam({
|
|
@@ -2487,7 +2655,7 @@ var PackagesService = class extends BaseService {
|
|
|
2487
2655
|
key: "endTime",
|
|
2488
2656
|
value: params == null ? void 0 : params.endTime
|
|
2489
2657
|
}).build();
|
|
2490
|
-
return this.client.
|
|
2658
|
+
return this.client.callDirect(request);
|
|
2491
2659
|
}
|
|
2492
2660
|
};
|
|
2493
2661
|
|
|
@@ -3329,13 +3497,68 @@ var getPurchaseConsumptionOkResponseRequest = import_zod32.z.lazy(() => {
|
|
|
3329
3497
|
|
|
3330
3498
|
// src/services/purchases/purchases-service.ts
|
|
3331
3499
|
var PurchasesService = class extends BaseService {
|
|
3500
|
+
/**
|
|
3501
|
+
* Sets method-level configuration for createPurchaseV2.
|
|
3502
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3503
|
+
* @returns This service instance for method chaining
|
|
3504
|
+
*/
|
|
3505
|
+
setCreatePurchaseV2Config(config) {
|
|
3506
|
+
this.createPurchaseV2Config = config;
|
|
3507
|
+
return this;
|
|
3508
|
+
}
|
|
3509
|
+
/**
|
|
3510
|
+
* Sets method-level configuration for listPurchases.
|
|
3511
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3512
|
+
* @returns This service instance for method chaining
|
|
3513
|
+
*/
|
|
3514
|
+
setListPurchasesConfig(config) {
|
|
3515
|
+
this.listPurchasesConfig = config;
|
|
3516
|
+
return this;
|
|
3517
|
+
}
|
|
3518
|
+
/**
|
|
3519
|
+
* Sets method-level configuration for createPurchase.
|
|
3520
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3521
|
+
* @returns This service instance for method chaining
|
|
3522
|
+
*/
|
|
3523
|
+
setCreatePurchaseConfig(config) {
|
|
3524
|
+
this.createPurchaseConfig = config;
|
|
3525
|
+
return this;
|
|
3526
|
+
}
|
|
3527
|
+
/**
|
|
3528
|
+
* Sets method-level configuration for topUpEsim.
|
|
3529
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3530
|
+
* @returns This service instance for method chaining
|
|
3531
|
+
*/
|
|
3532
|
+
setTopUpEsimConfig(config) {
|
|
3533
|
+
this.topUpEsimConfig = config;
|
|
3534
|
+
return this;
|
|
3535
|
+
}
|
|
3536
|
+
/**
|
|
3537
|
+
* Sets method-level configuration for editPurchase.
|
|
3538
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3539
|
+
* @returns This service instance for method chaining
|
|
3540
|
+
*/
|
|
3541
|
+
setEditPurchaseConfig(config) {
|
|
3542
|
+
this.editPurchaseConfig = config;
|
|
3543
|
+
return this;
|
|
3544
|
+
}
|
|
3545
|
+
/**
|
|
3546
|
+
* Sets method-level configuration for getPurchaseConsumption.
|
|
3547
|
+
* @param config - Partial configuration to override service-level defaults
|
|
3548
|
+
* @returns This service instance for method chaining
|
|
3549
|
+
*/
|
|
3550
|
+
setGetPurchaseConsumptionConfig(config) {
|
|
3551
|
+
this.getPurchaseConsumptionConfig = config;
|
|
3552
|
+
return this;
|
|
3553
|
+
}
|
|
3332
3554
|
/**
|
|
3333
3555
|
* This endpoint is used to purchase a new eSIM by providing the package details.
|
|
3334
|
-
* @param {
|
|
3556
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3335
3557
|
* @returns {Promise<HttpResponse<CreatePurchaseV2OkResponse[]>>} - Successful Response
|
|
3336
3558
|
*/
|
|
3337
3559
|
async createPurchaseV2(body, requestConfig) {
|
|
3338
|
-
const
|
|
3560
|
+
const resolvedConfig = this.getResolvedConfig(this.createPurchaseV2Config, requestConfig);
|
|
3561
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/v2").setRequestSchema(createPurchaseV2RequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3339
3562
|
schema: import_zod33.z.array(createPurchaseV2OkResponseResponse),
|
|
3340
3563
|
contentType: "json" /* Json */,
|
|
3341
3564
|
status: 200
|
|
@@ -3347,8 +3570,8 @@ var PurchasesService = class extends BaseService {
|
|
|
3347
3570
|
error: Unauthorized,
|
|
3348
3571
|
contentType: "json" /* Json */,
|
|
3349
3572
|
status: 401
|
|
3350
|
-
}).
|
|
3351
|
-
return this.client.
|
|
3573
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3574
|
+
return this.client.callDirect(request);
|
|
3352
3575
|
}
|
|
3353
3576
|
/**
|
|
3354
3577
|
* This endpoint can be used to list all the successful purchases made between a given interval.
|
|
@@ -3362,11 +3585,24 @@ var PurchasesService = class extends BaseService {
|
|
|
3362
3585
|
* @param {number} [params.limit] - Maximum number of purchases to be returned in the response. The value must be greater than 0 and less than or equal to 100. If not provided, the default value is 20
|
|
3363
3586
|
* @param {number} [params.after] - Epoch value representing the start of the time interval for filtering purchases
|
|
3364
3587
|
* @param {number} [params.before] - Epoch value representing the end of the time interval for filtering purchases
|
|
3365
|
-
* @param {
|
|
3588
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3366
3589
|
* @returns {Promise<HttpResponse<ListPurchasesOkResponse>>} - Successful Response
|
|
3367
3590
|
*/
|
|
3368
3591
|
async listPurchases(params, requestConfig) {
|
|
3369
|
-
const
|
|
3592
|
+
const resolvedConfig = this.getResolvedConfig(this.listPurchasesConfig, requestConfig);
|
|
3593
|
+
import_zod33.z.object({
|
|
3594
|
+
purchaseId: import_zod33.z.string().optional(),
|
|
3595
|
+
iccid: import_zod33.z.string().optional(),
|
|
3596
|
+
afterDate: import_zod33.z.string().optional(),
|
|
3597
|
+
beforeDate: import_zod33.z.string().optional(),
|
|
3598
|
+
email: import_zod33.z.string().optional(),
|
|
3599
|
+
referenceId: import_zod33.z.string().optional(),
|
|
3600
|
+
afterCursor: import_zod33.z.string().optional(),
|
|
3601
|
+
limit: import_zod33.z.number().optional(),
|
|
3602
|
+
after: import_zod33.z.number().optional(),
|
|
3603
|
+
before: import_zod33.z.number().optional()
|
|
3604
|
+
}).parse(params != null ? params : {});
|
|
3605
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/purchases").setRequestSchema(import_zod33.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3370
3606
|
schema: listPurchasesOkResponseResponse,
|
|
3371
3607
|
contentType: "json" /* Json */,
|
|
3372
3608
|
status: 200
|
|
@@ -3378,7 +3614,7 @@ var PurchasesService = class extends BaseService {
|
|
|
3378
3614
|
error: Unauthorized,
|
|
3379
3615
|
contentType: "json" /* Json */,
|
|
3380
3616
|
status: 401
|
|
3381
|
-
}).
|
|
3617
|
+
}).addQueryParam({
|
|
3382
3618
|
key: "purchaseId",
|
|
3383
3619
|
value: params == null ? void 0 : params.purchaseId
|
|
3384
3620
|
}).addQueryParam({
|
|
@@ -3409,15 +3645,16 @@ var PurchasesService = class extends BaseService {
|
|
|
3409
3645
|
key: "before",
|
|
3410
3646
|
value: params == null ? void 0 : params.before
|
|
3411
3647
|
}).build();
|
|
3412
|
-
return this.client.
|
|
3648
|
+
return this.client.callDirect(request);
|
|
3413
3649
|
}
|
|
3414
3650
|
/**
|
|
3415
3651
|
* This endpoint is used to purchase a new eSIM by providing the package details.
|
|
3416
|
-
* @param {
|
|
3652
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3417
3653
|
* @returns {Promise<HttpResponse<CreatePurchaseOkResponse>>} - Successful Response
|
|
3418
3654
|
*/
|
|
3419
3655
|
async createPurchase(body, requestConfig) {
|
|
3420
|
-
const
|
|
3656
|
+
const resolvedConfig = this.getResolvedConfig(this.createPurchaseConfig, requestConfig);
|
|
3657
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases").setRequestSchema(createPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3421
3658
|
schema: createPurchaseOkResponseResponse,
|
|
3422
3659
|
contentType: "json" /* Json */,
|
|
3423
3660
|
status: 200
|
|
@@ -3429,16 +3666,17 @@ var PurchasesService = class extends BaseService {
|
|
|
3429
3666
|
error: Unauthorized,
|
|
3430
3667
|
contentType: "json" /* Json */,
|
|
3431
3668
|
status: 401
|
|
3432
|
-
}).
|
|
3433
|
-
return this.client.
|
|
3669
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3670
|
+
return this.client.callDirect(request);
|
|
3434
3671
|
}
|
|
3435
3672
|
/**
|
|
3436
3673
|
* This endpoint is used to top-up an existing eSIM with the previously associated destination by providing its ICCID and package details. To determine if an eSIM can be topped up, use the Get eSIM endpoint, which returns the `isTopUpAllowed` flag.
|
|
3437
|
-
* @param {
|
|
3674
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3438
3675
|
* @returns {Promise<HttpResponse<TopUpEsimOkResponse>>} - Successful Response
|
|
3439
3676
|
*/
|
|
3440
3677
|
async topUpEsim(body, requestConfig) {
|
|
3441
|
-
const
|
|
3678
|
+
const resolvedConfig = this.getResolvedConfig(this.topUpEsimConfig, requestConfig);
|
|
3679
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/topup").setRequestSchema(topUpEsimRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3442
3680
|
schema: topUpEsimOkResponseResponse,
|
|
3443
3681
|
contentType: "json" /* Json */,
|
|
3444
3682
|
status: 200
|
|
@@ -3450,8 +3688,8 @@ var PurchasesService = class extends BaseService {
|
|
|
3450
3688
|
error: Unauthorized,
|
|
3451
3689
|
contentType: "json" /* Json */,
|
|
3452
3690
|
status: 401
|
|
3453
|
-
}).
|
|
3454
|
-
return this.client.
|
|
3691
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3692
|
+
return this.client.callDirect(request);
|
|
3455
3693
|
}
|
|
3456
3694
|
/**
|
|
3457
3695
|
* This endpoint allows you to modify the validity dates of an existing purchase.
|
|
@@ -3462,11 +3700,12 @@ var PurchasesService = class extends BaseService {
|
|
|
3462
3700
|
|
|
3463
3701
|
The end date can be extended or shortened as long as it adheres to the same pricing category and does not exceed the allowed duration limits.
|
|
3464
3702
|
|
|
3465
|
-
* @param {
|
|
3703
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3466
3704
|
* @returns {Promise<HttpResponse<EditPurchaseOkResponse>>} - Successful Response
|
|
3467
3705
|
*/
|
|
3468
3706
|
async editPurchase(body, requestConfig) {
|
|
3469
|
-
const
|
|
3707
|
+
const resolvedConfig = this.getResolvedConfig(this.editPurchaseConfig, requestConfig);
|
|
3708
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/edit").setRequestSchema(editPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3470
3709
|
schema: editPurchaseOkResponseResponse,
|
|
3471
3710
|
contentType: "json" /* Json */,
|
|
3472
3711
|
status: 200
|
|
@@ -3478,17 +3717,18 @@ var PurchasesService = class extends BaseService {
|
|
|
3478
3717
|
error: Unauthorized,
|
|
3479
3718
|
contentType: "json" /* Json */,
|
|
3480
3719
|
status: 401
|
|
3481
|
-
}).
|
|
3482
|
-
return this.client.
|
|
3720
|
+
}).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
|
|
3721
|
+
return this.client.callDirect(request);
|
|
3483
3722
|
}
|
|
3484
3723
|
/**
|
|
3485
3724
|
* This endpoint can be called for consumption notifications (e.g. every 1 hour or when the user clicks a button). It returns the data balance (consumption) of purchased packages.
|
|
3486
3725
|
* @param {string} purchaseId - ID of the purchase
|
|
3487
|
-
* @param {
|
|
3726
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3488
3727
|
* @returns {Promise<HttpResponse<GetPurchaseConsumptionOkResponse>>} - Successful Response
|
|
3489
3728
|
*/
|
|
3490
3729
|
async getPurchaseConsumption(purchaseId, requestConfig) {
|
|
3491
|
-
const
|
|
3730
|
+
const resolvedConfig = this.getResolvedConfig(this.getPurchaseConsumptionConfig, requestConfig);
|
|
3731
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/purchases/{purchaseId}/consumption").setRequestSchema(import_zod33.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3492
3732
|
schema: getPurchaseConsumptionOkResponseResponse,
|
|
3493
3733
|
contentType: "json" /* Json */,
|
|
3494
3734
|
status: 200
|
|
@@ -3500,11 +3740,11 @@ var PurchasesService = class extends BaseService {
|
|
|
3500
3740
|
error: Unauthorized,
|
|
3501
3741
|
contentType: "json" /* Json */,
|
|
3502
3742
|
status: 401
|
|
3503
|
-
}).
|
|
3743
|
+
}).addPathParam({
|
|
3504
3744
|
key: "purchaseId",
|
|
3505
3745
|
value: purchaseId
|
|
3506
3746
|
}).build();
|
|
3507
|
-
return this.client.
|
|
3747
|
+
return this.client.callDirect(request);
|
|
3508
3748
|
}
|
|
3509
3749
|
};
|
|
3510
3750
|
|
|
@@ -3755,14 +3995,43 @@ var getEsimHistoryOkResponseRequest = import_zod40.z.lazy(() => {
|
|
|
3755
3995
|
|
|
3756
3996
|
// src/services/e-sim/e-sim-service.ts
|
|
3757
3997
|
var ESimService = class extends BaseService {
|
|
3998
|
+
/**
|
|
3999
|
+
* Sets method-level configuration for getEsim.
|
|
4000
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4001
|
+
* @returns This service instance for method chaining
|
|
4002
|
+
*/
|
|
4003
|
+
setGetEsimConfig(config) {
|
|
4004
|
+
this.getEsimConfig = config;
|
|
4005
|
+
return this;
|
|
4006
|
+
}
|
|
4007
|
+
/**
|
|
4008
|
+
* Sets method-level configuration for getEsimDevice.
|
|
4009
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4010
|
+
* @returns This service instance for method chaining
|
|
4011
|
+
*/
|
|
4012
|
+
setGetEsimDeviceConfig(config) {
|
|
4013
|
+
this.getEsimDeviceConfig = config;
|
|
4014
|
+
return this;
|
|
4015
|
+
}
|
|
4016
|
+
/**
|
|
4017
|
+
* Sets method-level configuration for getEsimHistory.
|
|
4018
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4019
|
+
* @returns This service instance for method chaining
|
|
4020
|
+
*/
|
|
4021
|
+
setGetEsimHistoryConfig(config) {
|
|
4022
|
+
this.getEsimHistoryConfig = config;
|
|
4023
|
+
return this;
|
|
4024
|
+
}
|
|
3758
4025
|
/**
|
|
3759
4026
|
* Get eSIM
|
|
3760
4027
|
* @param {string} params.iccid - ID of the eSIM
|
|
3761
|
-
* @param {
|
|
4028
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3762
4029
|
* @returns {Promise<HttpResponse<GetEsimOkResponse>>} - Successful Response
|
|
3763
4030
|
*/
|
|
3764
4031
|
async getEsim(params, requestConfig) {
|
|
3765
|
-
const
|
|
4032
|
+
const resolvedConfig = this.getResolvedConfig(this.getEsimConfig, requestConfig);
|
|
4033
|
+
import_zod41.z.object({ iccid: import_zod41.z.string() }).parse(params != null ? params : {});
|
|
4034
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/esim").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3766
4035
|
schema: getEsimOkResponseResponse,
|
|
3767
4036
|
contentType: "json" /* Json */,
|
|
3768
4037
|
status: 200
|
|
@@ -3774,20 +4043,21 @@ var ESimService = class extends BaseService {
|
|
|
3774
4043
|
error: Unauthorized,
|
|
3775
4044
|
contentType: "json" /* Json */,
|
|
3776
4045
|
status: 401
|
|
3777
|
-
}).
|
|
4046
|
+
}).addQueryParam({
|
|
3778
4047
|
key: "iccid",
|
|
3779
4048
|
value: params == null ? void 0 : params.iccid
|
|
3780
4049
|
}).build();
|
|
3781
|
-
return this.client.
|
|
4050
|
+
return this.client.callDirect(request);
|
|
3782
4051
|
}
|
|
3783
4052
|
/**
|
|
3784
4053
|
* Get eSIM Device
|
|
3785
4054
|
* @param {string} iccid - ID of the eSIM
|
|
3786
|
-
* @param {
|
|
4055
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3787
4056
|
* @returns {Promise<HttpResponse<GetEsimDeviceOkResponse>>} - Successful Response
|
|
3788
4057
|
*/
|
|
3789
4058
|
async getEsimDevice(iccid, requestConfig) {
|
|
3790
|
-
const
|
|
4059
|
+
const resolvedConfig = this.getResolvedConfig(this.getEsimDeviceConfig, requestConfig);
|
|
4060
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/esim/{iccid}/device").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3791
4061
|
schema: getEsimDeviceOkResponseResponse,
|
|
3792
4062
|
contentType: "json" /* Json */,
|
|
3793
4063
|
status: 200
|
|
@@ -3799,20 +4069,21 @@ var ESimService = class extends BaseService {
|
|
|
3799
4069
|
error: Unauthorized,
|
|
3800
4070
|
contentType: "json" /* Json */,
|
|
3801
4071
|
status: 401
|
|
3802
|
-
}).
|
|
4072
|
+
}).addPathParam({
|
|
3803
4073
|
key: "iccid",
|
|
3804
4074
|
value: iccid
|
|
3805
4075
|
}).build();
|
|
3806
|
-
return this.client.
|
|
4076
|
+
return this.client.callDirect(request);
|
|
3807
4077
|
}
|
|
3808
4078
|
/**
|
|
3809
4079
|
* Get eSIM History
|
|
3810
4080
|
* @param {string} iccid - ID of the eSIM
|
|
3811
|
-
* @param {
|
|
4081
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3812
4082
|
* @returns {Promise<HttpResponse<GetEsimHistoryOkResponse>>} - Successful Response
|
|
3813
4083
|
*/
|
|
3814
4084
|
async getEsimHistory(iccid, requestConfig) {
|
|
3815
|
-
const
|
|
4085
|
+
const resolvedConfig = this.getResolvedConfig(this.getEsimHistoryConfig, requestConfig);
|
|
4086
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/esim/{iccid}/history").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3816
4087
|
schema: getEsimHistoryOkResponseResponse,
|
|
3817
4088
|
contentType: "json" /* Json */,
|
|
3818
4089
|
status: 200
|
|
@@ -3824,11 +4095,11 @@ var ESimService = class extends BaseService {
|
|
|
3824
4095
|
error: Unauthorized,
|
|
3825
4096
|
contentType: "json" /* Json */,
|
|
3826
4097
|
status: 401
|
|
3827
|
-
}).
|
|
4098
|
+
}).addPathParam({
|
|
3828
4099
|
key: "iccid",
|
|
3829
4100
|
value: iccid
|
|
3830
4101
|
}).build();
|
|
3831
|
-
return this.client.
|
|
4102
|
+
return this.client.callDirect(request);
|
|
3832
4103
|
}
|
|
3833
4104
|
};
|
|
3834
4105
|
|
|
@@ -3859,13 +4130,23 @@ var tokenOkResponseRequest = import_zod42.z.lazy(() => {
|
|
|
3859
4130
|
|
|
3860
4131
|
// src/services/i-frame/i-frame-service.ts
|
|
3861
4132
|
var IFrameService = class extends BaseService {
|
|
4133
|
+
/**
|
|
4134
|
+
* Sets method-level configuration for token.
|
|
4135
|
+
* @param config - Partial configuration to override service-level defaults
|
|
4136
|
+
* @returns This service instance for method chaining
|
|
4137
|
+
*/
|
|
4138
|
+
setTokenConfig(config) {
|
|
4139
|
+
this.tokenConfig = config;
|
|
4140
|
+
return this;
|
|
4141
|
+
}
|
|
3862
4142
|
/**
|
|
3863
4143
|
* Generate a new token to be used in the iFrame
|
|
3864
|
-
* @param {
|
|
4144
|
+
* @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
|
|
3865
4145
|
* @returns {Promise<HttpResponse<TokenOkResponse>>} - Successful Response
|
|
3866
4146
|
*/
|
|
3867
4147
|
async token(requestConfig) {
|
|
3868
|
-
const
|
|
4148
|
+
const resolvedConfig = this.getResolvedConfig(this.tokenConfig, requestConfig);
|
|
4149
|
+
const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/iframe/token").setRequestSchema(import_zod43.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
|
|
3869
4150
|
schema: tokenOkResponseResponse,
|
|
3870
4151
|
contentType: "json" /* Json */,
|
|
3871
4152
|
status: 200
|
|
@@ -3877,8 +4158,8 @@ var IFrameService = class extends BaseService {
|
|
|
3877
4158
|
error: Unauthorized,
|
|
3878
4159
|
contentType: "json" /* Json */,
|
|
3879
4160
|
status: 401
|
|
3880
|
-
}).
|
|
3881
|
-
return this.client.
|
|
4161
|
+
}).build();
|
|
4162
|
+
return this.client.callDirect(request);
|
|
3882
4163
|
}
|
|
3883
4164
|
};
|
|
3884
4165
|
|