celitech-sdk 1.3.64 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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(newRequest.queryParams, request.queryParams, true),
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
  });
@@ -444,8 +448,16 @@ var HookHandler = class {
444
448
  });
445
449
  if (error) {
446
450
  const decodedBody2 = new TextDecoder().decode(arrayBuffer);
447
- const json = JSON.parse(decodedBody2);
448
- new error.error((json == null ? void 0 : json.message) || "", json).throw();
451
+ let json = void 0;
452
+ if (decodedBody2.trim().length > 0) {
453
+ try {
454
+ json = JSON.parse(decodedBody2);
455
+ } catch (e) {
456
+ }
457
+ }
458
+ const customError = new error.error((json == null ? void 0 : json.message) || "", json);
459
+ customError.metadata = response.metadata;
460
+ customError.throw();
449
461
  }
450
462
  const decodedBody = new TextDecoder().decode(arrayBuffer);
451
463
  throw new HttpError(
@@ -625,20 +637,36 @@ var ResponseValidationHandler = class {
625
637
  if (decodedBody.startsWith("data: ")) {
626
638
  decodedBody = decodedBody.substring(6);
627
639
  }
628
- const json = JSON.parse(decodedBody);
640
+ if (decodedBody.trim().length === 0) {
641
+ return { ...response, data: void 0 };
642
+ }
629
643
  return {
630
644
  ...response,
631
- data: this.validate(request, responseDefinition, json)
645
+ data: this.validate(request, responseDefinition, this.parseJson(decodedBody))
632
646
  };
633
647
  }
634
648
  decodeJson(request, responseDefinition, response) {
635
649
  const decodedBody = new TextDecoder().decode(response.raw);
636
- const json = JSON.parse(decodedBody);
650
+ if (decodedBody.trim().length === 0) {
651
+ return { ...response, data: void 0 };
652
+ }
637
653
  return {
638
654
  ...response,
639
- data: this.validate(request, responseDefinition, json)
655
+ data: this.validate(request, responseDefinition, this.parseJson(decodedBody))
640
656
  };
641
657
  }
658
+ /**
659
+ * Parses a JSON response body, rethrowing parse failures as a plain Error
660
+ * so callers don't have to special-case SyntaxError.
661
+ */
662
+ parseJson(decodedBody) {
663
+ try {
664
+ return JSON.parse(decodedBody);
665
+ } catch (e) {
666
+ const message = e instanceof Error ? e.message : String(e);
667
+ throw new Error(`Failed to parse JSON response body: ${message}`);
668
+ }
669
+ }
642
670
  /**
643
671
  * Validates response data against the expected schema if validation is enabled.
644
672
  * @template T - The expected data type
@@ -648,8 +676,8 @@ var ResponseValidationHandler = class {
648
676
  * @returns The validated data (parsed if validation enabled, raw otherwise)
649
677
  */
650
678
  validate(request, response, data) {
651
- var _a;
652
- if ((_a = request.validation) == null ? void 0 : _a.responseValidation) {
679
+ var _a, _b;
680
+ if ((_b = (_a = request.config.validation) == null ? void 0 : _a.responseValidation) != null ? _b : true) {
653
681
  return response.schema.parse(data);
654
682
  }
655
683
  return data;
@@ -722,7 +750,9 @@ var ValidationError = class extends Error {
722
750
  }
723
751
  const error = [
724
752
  `ValidationError:`,
725
- ...zodError.issues.map((issue) => ` Property: ${issue.path.join(".")}. Message: ${issue.message}`),
753
+ ...zodError.issues.map(
754
+ (issue) => ` Property: ${issue.path.join(".")}. Message: ${issue.message}`
755
+ ),
726
756
  " Validated:",
727
757
  ...actual.split("\n").map((line) => ` ${line}`)
728
758
  ].join("\n");
@@ -1030,7 +1060,10 @@ var RequestFetchAdapter = class {
1030
1060
  return headers;
1031
1061
  }
1032
1062
  toArrayBuffer(uint8Array) {
1033
- return uint8Array.buffer.slice(uint8Array.byteOffset, uint8Array.byteOffset + uint8Array.byteLength);
1063
+ return uint8Array.buffer.slice(
1064
+ uint8Array.byteOffset,
1065
+ uint8Array.byteOffset + uint8Array.byteLength
1066
+ );
1034
1067
  }
1035
1068
  };
1036
1069
 
@@ -1061,23 +1094,27 @@ var RetryHandler = class {
1061
1094
  /**
1062
1095
  * Handles a standard HTTP request with retry logic.
1063
1096
  * Retries failed requests based on the configured retry settings.
1097
+ * Implements exponential backoff with optional jitter between retry attempts.
1064
1098
  * @template T - The expected response data type
1065
1099
  * @param request - The HTTP request to process
1066
1100
  * @returns A promise that resolves to the HTTP response
1067
1101
  * @throws Error if no next handler is set, or if all retry attempts fail
1068
1102
  */
1069
1103
  async handle(request) {
1104
+ var _a, _b;
1070
1105
  if (!this.next) {
1071
1106
  throw new Error("No next handler set in retry handler.");
1072
1107
  }
1073
- for (let attempt = 1; attempt <= request.retry.attempts; attempt++) {
1108
+ const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
1109
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1074
1110
  try {
1075
1111
  return await this.next.handle(request);
1076
1112
  } catch (error) {
1077
- if (!this.shouldRetry(error) || attempt === request.retry.attempts) {
1113
+ if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
1078
1114
  throw error;
1079
1115
  }
1080
- await this.delay(request.retry.delayMs);
1116
+ const delayMs = this.calculateDelay(attempt, request);
1117
+ await this.delay(delayMs);
1081
1118
  }
1082
1119
  }
1083
1120
  throw new Error("Error retrying request.");
@@ -1090,38 +1127,78 @@ var RetryHandler = class {
1090
1127
  * @throws Error if no next handler is set, or if all retry attempts fail
1091
1128
  */
1092
1129
  async *stream(request) {
1130
+ var _a, _b;
1093
1131
  if (!this.next) {
1094
1132
  throw new Error("No next handler set in retry handler.");
1095
1133
  }
1096
- for (let attempt = 1; attempt <= request.retry.attempts; attempt++) {
1134
+ const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
1135
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1097
1136
  try {
1098
1137
  yield* this.next.stream(request);
1099
1138
  return;
1100
1139
  } catch (error) {
1101
- if (!this.shouldRetry(error) || attempt === request.retry.attempts) {
1140
+ if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
1102
1141
  throw error;
1103
1142
  }
1104
- await this.delay(request.retry.delayMs);
1143
+ const delayMs = this.calculateDelay(attempt, request);
1144
+ await this.delay(delayMs);
1105
1145
  }
1106
1146
  }
1107
1147
  throw new Error("Error retrying request.");
1108
1148
  }
1109
1149
  /**
1110
1150
  * Determines if an error should trigger a retry.
1111
- * Retries server errors (5xx), request timeouts (408), and rate limits (429).
1151
+ * Checks both HTTP status codes and HTTP methods against the configured retry settings.
1152
+ * By default, retries all 5xx server errors and specific 4xx client errors (408 Timeout, 429 Rate Limit).
1112
1153
  * @param error - The error to check
1154
+ * @param request - The HTTP request being retried
1113
1155
  * @returns True if the request should be retried, false otherwise
1114
1156
  */
1115
- shouldRetry(error) {
1116
- return error instanceof HttpError && (error.metadata.status >= 500 || error.metadata.status === 408 || error.metadata.status === 429);
1157
+ shouldRetry(error, request) {
1158
+ var _a, _b, _c;
1159
+ if (!(error instanceof HttpError)) {
1160
+ return false;
1161
+ }
1162
+ const httpMethodsToRetry = (_b = (_a = request.config.retry) == null ? void 0 : _a.httpMethodsToRetry) != null ? _b : [
1163
+ "GET",
1164
+ "POST",
1165
+ "PUT",
1166
+ "DELETE",
1167
+ "PATCH",
1168
+ "HEAD",
1169
+ "OPTIONS"
1170
+ ];
1171
+ 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);
1172
+ const shouldRetryMethod = httpMethodsToRetry.includes(request.method);
1173
+ return shouldRetryStatus && shouldRetryMethod;
1174
+ }
1175
+ /**
1176
+ * Calculates the delay before the next retry attempt using exponential backoff.
1177
+ * Optionally adds jitter to prevent thundering herd problems.
1178
+ * @param attempt - The current retry attempt number (1-indexed)
1179
+ * @param request - The HTTP request being retried
1180
+ * @returns The delay in milliseconds, capped at the configured maximum delay
1181
+ */
1182
+ calculateDelay(attempt, request) {
1183
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1184
+ const baseDelay = (_b = (_a = request.config.retry) == null ? void 0 : _a.delayMs) != null ? _b : 150;
1185
+ const backoffFactor = (_d = (_c = request.config.retry) == null ? void 0 : _c.backoffFactor) != null ? _d : 2;
1186
+ const maxDelay = (_f = (_e = request.config.retry) == null ? void 0 : _e.maxDelayMs) != null ? _f : 5e3;
1187
+ const jitter = (_h = (_g = request.config.retry) == null ? void 0 : _g.jitterMs) != null ? _h : 50;
1188
+ let delay = baseDelay * Math.pow(backoffFactor, attempt - 1);
1189
+ delay = Math.min(delay, maxDelay);
1190
+ if (jitter > 0) {
1191
+ delay += Math.random() * jitter;
1192
+ }
1193
+ return Math.floor(delay);
1117
1194
  }
1118
1195
  /**
1119
1196
  * Delays execution for a specified duration before retrying.
1120
- * @param delayMs - The delay in milliseconds (optional)
1197
+ * @param delayMs - The delay in milliseconds
1121
1198
  * @returns A promise that resolves after the delay
1122
1199
  */
1123
1200
  delay(delayMs) {
1124
- if (!delayMs) {
1201
+ if (delayMs <= 0) {
1125
1202
  return Promise.resolve();
1126
1203
  }
1127
1204
  return new Promise((resolve, reject) => {
@@ -1232,6 +1309,15 @@ var HttpClient = class {
1232
1309
  call(request) {
1233
1310
  return this.requestHandlerChain.callChain(request);
1234
1311
  }
1312
+ /**
1313
+ * Executes a standard HTTP request and returns only the data directly.
1314
+ * @template T - The expected response data type
1315
+ * @param request - The HTTP request to execute
1316
+ * @returns A promise that resolves to the response data
1317
+ */
1318
+ callDirect(request) {
1319
+ return this.call(request).then((response) => response.data);
1320
+ }
1235
1321
  /**
1236
1322
  * Executes a streaming HTTP request that yields responses incrementally.
1237
1323
  * @template T - The expected response data type for each chunk
@@ -1352,6 +1438,61 @@ var BaseService = class {
1352
1438
  this.tokenManager = tokenManager;
1353
1439
  this.client = new HttpClient(this.config);
1354
1440
  }
1441
+ /**
1442
+ * Sets service-level configuration that applies to all methods in this service.
1443
+ * @param config - Partial configuration to override SDK-level defaults
1444
+ * @returns This service instance for method chaining
1445
+ */
1446
+ setConfig(config) {
1447
+ this.serviceConfig = config;
1448
+ return this;
1449
+ }
1450
+ /**
1451
+ * Recursively merges two objects. Plain nested objects are merged key-by-key so a
1452
+ * partial override (e.g. `{ retry: { attempts: 5 } }`) only overwrites the specified
1453
+ * keys instead of replacing the whole nested object. Arrays and non-plain values are
1454
+ * replaced wholesale.
1455
+ *
1456
+ * Override keys with the value `undefined` are skipped so the base value is preserved,
1457
+ * matching the common JS merge idiom (e.g. lodash.merge). To explicitly clear a key,
1458
+ * assign `null` or omit the key from the override entirely.
1459
+ */
1460
+ static deepMerge(base, override) {
1461
+ const result = { ...base };
1462
+ for (const [key, value] of Object.entries(override)) {
1463
+ const existing = result[key];
1464
+ if (BaseService.isPlainObject(value) && BaseService.isPlainObject(existing)) {
1465
+ result[key] = BaseService.deepMerge(existing, value);
1466
+ } else if (value !== void 0) {
1467
+ result[key] = value;
1468
+ }
1469
+ }
1470
+ return result;
1471
+ }
1472
+ static isPlainObject(value) {
1473
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
1474
+ }
1475
+ /**
1476
+ * Resolves configuration from the hierarchy: requestConfig > methodConfig > serviceConfig > sdkConfig
1477
+ * Deep-merges all config levels so partial nested overrides (e.g. `{ retry: { attempts: 5 } }`)
1478
+ * preserve unoverridden sibling keys from the SDK default.
1479
+ * @param methodConfig - Method-level configuration override
1480
+ * @param requestConfig - Request-level configuration override
1481
+ * @returns Merged configuration with all overrides applied
1482
+ */
1483
+ getResolvedConfig(methodConfig, requestConfig) {
1484
+ let merged = { ...this.config };
1485
+ if (this.serviceConfig) {
1486
+ merged = BaseService.deepMerge(merged, this.serviceConfig);
1487
+ }
1488
+ if (methodConfig) {
1489
+ merged = BaseService.deepMerge(merged, methodConfig);
1490
+ }
1491
+ if (requestConfig) {
1492
+ merged = BaseService.deepMerge(merged, requestConfig);
1493
+ }
1494
+ return merged;
1495
+ }
1355
1496
  set baseUrl(baseUrl) {
1356
1497
  this.config.baseUrl = baseUrl;
1357
1498
  }
@@ -1528,8 +1669,6 @@ var Request = class {
1528
1669
  this.queryParams = /* @__PURE__ */ new Map();
1529
1670
  this.pathParams = /* @__PURE__ */ new Map();
1530
1671
  this.cookies = /* @__PURE__ */ new Map();
1531
- this.validation = {};
1532
- this.retry = {};
1533
1672
  this.baseUrl = params.baseUrl;
1534
1673
  this.method = params.method;
1535
1674
  this.pathPattern = params.path;
@@ -1544,8 +1683,6 @@ var Request = class {
1544
1683
  this.errors = params.errors;
1545
1684
  this.requestSchema = params.requestSchema;
1546
1685
  this.requestContentType = params.requestContentType;
1547
- this.retry = params.retry;
1548
- this.validation = params.validation;
1549
1686
  this.pagination = params.pagination;
1550
1687
  this.filename = params.filename;
1551
1688
  this.filenames = params.filenames;
@@ -1658,7 +1795,7 @@ var Request = class {
1658
1795
  * @returns A new Request instance with the specified overrides
1659
1796
  */
1660
1797
  copy(overrides) {
1661
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1798
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1662
1799
  const createRequestParams = {
1663
1800
  baseUrl: (_a = overrides == null ? void 0 : overrides.baseUrl) != null ? _a : this.baseUrl,
1664
1801
  errors: (_b = overrides == null ? void 0 : overrides.errors) != null ? _b : this.errors,
@@ -1673,10 +1810,8 @@ var Request = class {
1673
1810
  responses: (_k = overrides == null ? void 0 : overrides.responses) != null ? _k : this.responses,
1674
1811
  requestSchema: (_l = overrides == null ? void 0 : overrides.requestSchema) != null ? _l : this.requestSchema,
1675
1812
  requestContentType: (_m = overrides == null ? void 0 : overrides.requestContentType) != null ? _m : this.requestContentType,
1676
- retry: (_n = overrides == null ? void 0 : overrides.retry) != null ? _n : this.retry,
1677
- validation: (_o = overrides == null ? void 0 : overrides.validation) != null ? _o : this.validation,
1678
- filename: (_p = overrides == null ? void 0 : overrides.filename) != null ? _p : this.filename,
1679
- filenames: (_q = overrides == null ? void 0 : overrides.filenames) != null ? _q : this.filenames,
1813
+ filename: (_n = overrides == null ? void 0 : overrides.filename) != null ? _n : this.filename,
1814
+ filenames: (_o = overrides == null ? void 0 : overrides.filenames) != null ? _o : this.filenames,
1680
1815
  scopes: overrides == null ? void 0 : overrides.scopes,
1681
1816
  tokenManager: this.tokenManager
1682
1817
  };
@@ -1778,55 +1913,73 @@ var RequestBuilder = class {
1778
1913
  baseUrl: "https://api.celitech.net/v1" /* DEFAULT */,
1779
1914
  method: "GET",
1780
1915
  path: "",
1781
- config: {},
1916
+ config: {
1917
+ clientId: "",
1918
+ clientSecret: "",
1919
+ retry: {
1920
+ attempts: 3,
1921
+ delayMs: 150,
1922
+ maxDelayMs: 5e3,
1923
+ backoffFactor: 2,
1924
+ jitterMs: 50,
1925
+ httpMethodsToRetry: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]
1926
+ },
1927
+ validation: { responseValidation: true }
1928
+ },
1782
1929
  responses: [],
1783
1930
  errors: [],
1784
1931
  requestSchema: import_zod3.default.any(),
1785
1932
  requestContentType: "json" /* Json */,
1786
- retry: {
1787
- attempts: 3,
1788
- delayMs: 150
1789
- },
1790
- validation: {
1791
- responseValidation: true
1792
- },
1793
1933
  pathParams: /* @__PURE__ */ new Map(),
1794
1934
  queryParams: /* @__PURE__ */ new Map(),
1795
1935
  headers: /* @__PURE__ */ new Map(),
1796
1936
  cookies: /* @__PURE__ */ new Map(),
1797
1937
  tokenManager: new OAuthTokenManager()
1798
1938
  };
1939
+ this.addHeaderParam({
1940
+ key: "User-Agent",
1941
+ value: "postman-codegen/1.4.0 celitech-sdk/2.0.2 (typescript)"
1942
+ });
1799
1943
  }
1800
- setRetryAttempts(sdkConfig, requestConfig) {
1944
+ setConfig(config) {
1801
1945
  var _a, _b;
1802
- if (((_a = requestConfig == null ? void 0 : requestConfig.retry) == null ? void 0 : _a.attempts) !== void 0) {
1803
- this.params.retry.attempts = requestConfig.retry.attempts;
1804
- } else if (((_b = sdkConfig == null ? void 0 : sdkConfig.retry) == null ? void 0 : _b.attempts) !== void 0) {
1805
- this.params.retry.attempts = sdkConfig.retry.attempts;
1946
+ let mergedRetry = (_a = config.retry) != null ? _a : this.params.config.retry;
1947
+ if (config.retry !== void 0 && this.params.config.retry !== void 0) {
1948
+ mergedRetry = { ...this.params.config.retry, ...config.retry };
1806
1949
  }
1807
- return this;
1808
- }
1809
- setRetryDelayMs(sdkConfig, requestConfig) {
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;
1950
+ let mergedValidation = (_b = config.validation) != null ? _b : this.params.config.validation;
1951
+ if (config.validation !== void 0 && this.params.config.validation !== void 0) {
1952
+ mergedValidation = { ...this.params.config.validation, ...config.validation };
1815
1953
  }
1954
+ this.params.config = {
1955
+ ...this.params.config,
1956
+ ...config,
1957
+ ...mergedRetry !== void 0 && { retry: mergedRetry },
1958
+ ...mergedValidation !== void 0 && { validation: mergedValidation }
1959
+ };
1816
1960
  return this;
1817
1961
  }
1818
- setResponseValidation(sdkConfig, requestConfig) {
1819
- var _a, _b;
1820
- if (((_a = requestConfig == null ? void 0 : requestConfig.validation) == null ? void 0 : _a.responseValidation) !== void 0) {
1821
- this.params.validation.responseValidation = requestConfig.validation.responseValidation;
1822
- } else if (((_b = sdkConfig == null ? void 0 : sdkConfig.validation) == null ? void 0 : _b.responseValidation) !== void 0) {
1823
- this.params.validation.responseValidation = sdkConfig.validation.responseValidation;
1962
+ /**
1963
+ * Sets the base URL for the request using hierarchical configuration resolution.
1964
+ *
1965
+ * Resolution logic:
1966
+ * 1. First tries to resolve 'baseUrl' (string) from the resolved config
1967
+ * 2. If no 'baseUrl' found, falls back to 'environment' (enum) from the resolved config
1968
+ * 3. 'baseUrl' always takes precedence over 'environment'
1969
+ *
1970
+ * @param config - Resolved configuration from all hierarchy levels
1971
+ * @returns This builder instance for method chaining
1972
+ */
1973
+ setBaseUrl(config) {
1974
+ if (!config) {
1975
+ return this;
1824
1976
  }
1825
- return this;
1826
- }
1827
- setBaseUrl(baseUrl) {
1828
- if (baseUrl) {
1829
- this.params.baseUrl = baseUrl;
1977
+ if ("baseUrl" in config && typeof config.baseUrl === "string" && config.baseUrl) {
1978
+ this.params.baseUrl = config.baseUrl;
1979
+ return this;
1980
+ }
1981
+ if ("environment" in config && config.environment) {
1982
+ this.params.baseUrl = config.environment;
1830
1983
  }
1831
1984
  return this;
1832
1985
  }
@@ -1838,10 +1991,6 @@ var RequestBuilder = class {
1838
1991
  this.params.path = path;
1839
1992
  return this;
1840
1993
  }
1841
- setConfig(config) {
1842
- this.params.config = config;
1843
- return this;
1844
- }
1845
1994
  setRequestContentType(contentType) {
1846
1995
  this.params.requestContentType = contentType;
1847
1996
  return this;
@@ -1884,7 +2033,7 @@ var RequestBuilder = class {
1884
2033
  }
1885
2034
  this.params.headers.set("Authorization", {
1886
2035
  key: "Authorization",
1887
- value: `${prefix != null ? prefix : "BEARER"} ${accessToken}`,
2036
+ value: `${prefix != null ? prefix : "Bearer"} ${accessToken}`,
1888
2037
  explode: false,
1889
2038
  style: "simple" /* SIMPLE */,
1890
2039
  encode: true,
@@ -1910,20 +2059,30 @@ var RequestBuilder = class {
1910
2059
  });
1911
2060
  return this;
1912
2061
  }
1913
- addApiKeyAuth(apiKey, keyName) {
2062
+ addApiKeyAuth(apiKey, keyName, location) {
1914
2063
  if (apiKey === void 0) {
1915
2064
  return this;
1916
2065
  }
1917
- this.params.headers.set(keyName != null ? keyName : "X-API-KEY", {
1918
- key: keyName != null ? keyName : "X-API-KEY",
2066
+ const resolvedKeyName = keyName != null ? keyName : "X-API-KEY";
2067
+ const resolvedLocation = location != null ? location : "header";
2068
+ const isQuery = resolvedLocation === "query";
2069
+ const param = {
2070
+ key: resolvedKeyName,
1919
2071
  value: apiKey,
1920
- explode: false,
1921
- style: "simple" /* SIMPLE */,
2072
+ explode: isQuery,
2073
+ style: isQuery ? "form" /* FORM */ : "simple" /* SIMPLE */,
1922
2074
  encode: true,
1923
2075
  isLimit: false,
1924
2076
  isOffset: false,
1925
2077
  isCursor: false
1926
- });
2078
+ };
2079
+ if (resolvedLocation === "query") {
2080
+ this.params.queryParams.set(resolvedKeyName, param);
2081
+ } else if (resolvedLocation === "cookie") {
2082
+ this.params.cookies.set(resolvedKeyName, param);
2083
+ } else {
2084
+ this.params.headers.set(resolvedKeyName, param);
2085
+ }
1927
2086
  return this;
1928
2087
  }
1929
2088
  addResponse(response) {
@@ -2031,66 +2190,66 @@ var RequestBuilder = class {
2031
2190
  }
2032
2191
  };
2033
2192
 
2034
- // src/services/o-auth/models/get-access-token-request.ts
2193
+ // src/services/o-auth/models/o-auth-token-request.ts
2035
2194
  var import_zod4 = require("zod");
2036
- var getAccessTokenRequest = import_zod4.z.lazy(() => {
2195
+ var oAuthTokenRequest = import_zod4.z.lazy(() => {
2037
2196
  return import_zod4.z.object({
2038
- grantType: import_zod4.z.string().optional(),
2039
- clientId: import_zod4.z.string().optional(),
2040
- clientSecret: import_zod4.z.string().optional()
2197
+ grantType: import_zod4.z.string(),
2198
+ clientId: import_zod4.z.string(),
2199
+ clientSecret: import_zod4.z.string(),
2200
+ scope: import_zod4.z.string()
2041
2201
  });
2042
2202
  });
2043
- var getAccessTokenRequestResponse = import_zod4.z.lazy(() => {
2203
+ var oAuthTokenRequestResponse = import_zod4.z.lazy(() => {
2044
2204
  return import_zod4.z.object({
2045
- grant_type: import_zod4.z.string().optional(),
2046
- client_id: import_zod4.z.string().optional(),
2047
- client_secret: import_zod4.z.string().optional()
2205
+ grant_type: import_zod4.z.string(),
2206
+ client_id: import_zod4.z.string(),
2207
+ client_secret: import_zod4.z.string(),
2208
+ scope: import_zod4.z.string()
2048
2209
  }).transform((data) => ({
2049
2210
  grantType: data["grant_type"],
2050
2211
  clientId: data["client_id"],
2051
- clientSecret: data["client_secret"]
2212
+ clientSecret: data["client_secret"],
2213
+ scope: data["scope"]
2052
2214
  }));
2053
2215
  });
2054
- var getAccessTokenRequestRequest = import_zod4.z.lazy(() => {
2216
+ var oAuthTokenRequestRequest = import_zod4.z.lazy(() => {
2055
2217
  return import_zod4.z.object({
2056
- grantType: import_zod4.z.string().optional(),
2057
- clientId: import_zod4.z.string().optional(),
2058
- clientSecret: import_zod4.z.string().optional()
2218
+ grantType: import_zod4.z.string(),
2219
+ clientId: import_zod4.z.string(),
2220
+ clientSecret: import_zod4.z.string(),
2221
+ scope: import_zod4.z.string()
2059
2222
  }).transform((data) => ({
2060
2223
  grant_type: data["grantType"],
2061
2224
  client_id: data["clientId"],
2062
- client_secret: data["clientSecret"]
2225
+ client_secret: data["clientSecret"],
2226
+ scope: data["scope"]
2063
2227
  }));
2064
2228
  });
2065
2229
 
2066
- // src/services/o-auth/models/get-access-token-ok-response.ts
2230
+ // src/services/o-auth/models/o-auth-token-response.ts
2067
2231
  var import_zod5 = require("zod");
2068
- var getAccessTokenOkResponse = import_zod5.z.lazy(() => {
2232
+ var oAuthTokenResponse = import_zod5.z.lazy(() => {
2069
2233
  return import_zod5.z.object({
2070
2234
  accessToken: import_zod5.z.string().optional(),
2071
- tokenType: import_zod5.z.string().optional(),
2072
- expiresIn: import_zod5.z.number().optional()
2235
+ expiresIn: import_zod5.z.number().optional().nullable()
2073
2236
  });
2074
2237
  });
2075
- var getAccessTokenOkResponseResponse = import_zod5.z.lazy(() => {
2238
+ var oAuthTokenResponseResponse = import_zod5.z.lazy(() => {
2076
2239
  return import_zod5.z.object({
2077
2240
  access_token: import_zod5.z.string().optional(),
2078
- token_type: import_zod5.z.string().optional(),
2079
- expires_in: import_zod5.z.number().optional()
2241
+ expires_in: import_zod5.z.number().optional().nullable()
2080
2242
  }).transform((data) => ({
2081
2243
  accessToken: data["access_token"],
2082
- tokenType: data["token_type"],
2083
2244
  expiresIn: data["expires_in"]
2084
2245
  }));
2085
2246
  });
2086
- var getAccessTokenOkResponseRequest = import_zod5.z.lazy(() => {
2247
+ var oAuthTokenResponseRequest = import_zod5.z.lazy(() => {
2087
2248
  return import_zod5.z.object({
2088
2249
  accessToken: import_zod5.z.string().optional(),
2089
- tokenType: import_zod5.z.string().optional(),
2090
- expiresIn: import_zod5.z.number().optional()
2250
+ expiresIn: import_zod5.z.number().optional().nullable()
2091
2251
  }).transform((data) => ({
2092
2252
  access_token: data["accessToken"],
2093
- token_type: data["tokenType"],
2094
2253
  expires_in: data["expiresIn"]
2095
2254
  }));
2096
2255
  });
@@ -2098,17 +2257,27 @@ var getAccessTokenOkResponseRequest = import_zod5.z.lazy(() => {
2098
2257
  // src/services/o-auth/o-auth-service.ts
2099
2258
  var OAuthService = class extends BaseService {
2100
2259
  /**
2101
- * This endpoint was added by liblab
2102
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
2103
- * @returns {Promise<HttpResponse<GetAccessTokenOkResponse>>} - Successful Response
2260
+ * Sets method-level configuration for getAccessToken.
2261
+ * @param config - Partial configuration to override service-level defaults
2262
+ * @returns This service instance for method chaining
2263
+ */
2264
+ setGetAccessTokenConfig(config) {
2265
+ this.getAccessTokenConfig = config;
2266
+ return this;
2267
+ }
2268
+ /**
2269
+ *
2270
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
2271
+ * @returns {Promise<HttpResponse<OAuthTokenResponse>>} - OAuth token
2104
2272
  */
2105
2273
  async getAccessToken(body, requestConfig) {
2106
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/oauth2/token").setRequestSchema(getAccessTokenRequestRequest).setTokenManager(this.tokenManager).setRequestContentType("form" /* FormUrlEncoded */).addResponse({
2107
- schema: getAccessTokenOkResponseResponse,
2274
+ const resolvedConfig = this.getResolvedConfig(this.getAccessTokenConfig, requestConfig);
2275
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/oauth2/token").setRequestSchema(oAuthTokenRequestRequest).setTokenManager(this.tokenManager).setRequestContentType("form" /* FormUrlEncoded */).addResponse({
2276
+ schema: oAuthTokenResponseResponse,
2108
2277
  contentType: "json" /* Json */,
2109
2278
  status: 200
2110
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/x-www-form-urlencoded" }).addBody(body).build();
2111
- return this.client.call(request);
2279
+ }).addHeaderParam({ key: "Content-Type", value: "application/x-www-form-urlencoded" }).addBody(body).build();
2280
+ return this.client.callDirect(request);
2112
2281
  }
2113
2282
  };
2114
2283
 
@@ -2155,7 +2324,7 @@ var OAuthTokenManager = class {
2155
2324
  * @throws Error if client credentials are missing or token request fails
2156
2325
  */
2157
2326
  async getToken(scopes, config) {
2158
- var _a, _b, _c, _d, _e, _f;
2327
+ var _a, _b, _c;
2159
2328
  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
2329
  return this.token;
2161
2330
  }
@@ -2170,23 +2339,21 @@ var OAuthTokenManager = class {
2170
2339
  },
2171
2340
  this
2172
2341
  );
2173
- const response = await oAuth.getAccessToken(
2174
- {
2175
- grantType: "client_credentials",
2176
- clientId: config.clientId,
2177
- clientSecret: config.clientSecret
2178
- },
2179
- {}
2180
- );
2181
- if (!((_d = response.data) == null ? void 0 : _d.accessToken)) {
2342
+ const response = await oAuth.getAccessToken({
2343
+ grantType: "client_credentials",
2344
+ clientId: config.clientId,
2345
+ clientSecret: config.clientSecret,
2346
+ scope: Array.from(scopes).join(" ")
2347
+ });
2348
+ if (!(response == null ? void 0 : response.accessToken)) {
2182
2349
  throw new Error(
2183
2350
  `OAuthError: token endpoint response did not return access token. Response: ${JSON.stringify(response), void 0, 2}.`
2184
2351
  );
2185
2352
  }
2186
2353
  this.token = new OAuthToken(
2187
- response.data.accessToken,
2354
+ response.accessToken,
2188
2355
  updatedScopes,
2189
- ((_e = response.data) == null ? void 0 : _e.expiresIn) ? ((_f = response.data) == null ? void 0 : _f.expiresIn) * 1e3 + Date.now() : null
2356
+ (response == null ? void 0 : response.expiresIn) ? (response == null ? void 0 : response.expiresIn) * 1e3 + Date.now() : null
2190
2357
  );
2191
2358
  return this.token;
2192
2359
  }
@@ -2298,7 +2465,9 @@ var BadRequest = class extends ThrowableError {
2298
2465
  this.message = parsedResponse.message || "";
2299
2466
  }
2300
2467
  throw() {
2301
- throw new BadRequest(this.message, this.response);
2468
+ const error = new BadRequest(this.message, this.response);
2469
+ error.metadata = this.metadata;
2470
+ throw error;
2302
2471
  }
2303
2472
  };
2304
2473
 
@@ -2320,19 +2489,31 @@ var Unauthorized = class extends ThrowableError {
2320
2489
  this.message = parsedResponse.message || "";
2321
2490
  }
2322
2491
  throw() {
2323
- throw new Unauthorized(this.message, this.response);
2492
+ const error = new Unauthorized(this.message, this.response);
2493
+ error.metadata = this.metadata;
2494
+ throw error;
2324
2495
  }
2325
2496
  };
2326
2497
 
2327
2498
  // src/services/destinations/destinations-service.ts
2328
2499
  var DestinationsService = class extends BaseService {
2500
+ /**
2501
+ * Sets method-level configuration for listDestinations.
2502
+ * @param config - Partial configuration to override service-level defaults
2503
+ * @returns This service instance for method chaining
2504
+ */
2505
+ setListDestinationsConfig(config) {
2506
+ this.listDestinationsConfig = config;
2507
+ return this;
2508
+ }
2329
2509
  /**
2330
2510
  * List Destinations
2331
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
2511
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
2332
2512
  * @returns {Promise<HttpResponse<ListDestinationsOkResponse>>} - Successful Response
2333
2513
  */
2334
2514
  async listDestinations(requestConfig) {
2335
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/destinations").setRequestSchema(import_zod10.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
2515
+ const resolvedConfig = this.getResolvedConfig(this.listDestinationsConfig, requestConfig);
2516
+ 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
2517
  schema: listDestinationsOkResponseResponse,
2337
2518
  contentType: "json" /* Json */,
2338
2519
  status: 200
@@ -2344,8 +2525,8 @@ var DestinationsService = class extends BaseService {
2344
2525
  error: Unauthorized,
2345
2526
  contentType: "json" /* Json */,
2346
2527
  status: 401
2347
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).build();
2348
- return this.client.call(request);
2528
+ }).build();
2529
+ return this.client.callDirect(request);
2349
2530
  }
2350
2531
  };
2351
2532
 
@@ -2440,6 +2621,15 @@ var listPackagesOkResponseRequest = import_zod12.z.lazy(() => {
2440
2621
 
2441
2622
  // src/services/packages/packages-service.ts
2442
2623
  var PackagesService = class extends BaseService {
2624
+ /**
2625
+ * Sets method-level configuration for listPackages.
2626
+ * @param config - Partial configuration to override service-level defaults
2627
+ * @returns This service instance for method chaining
2628
+ */
2629
+ setListPackagesConfig(config) {
2630
+ this.listPackagesConfig = config;
2631
+ return this;
2632
+ }
2443
2633
  /**
2444
2634
  * List Packages
2445
2635
  * @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 +2639,21 @@ var PackagesService = class extends BaseService {
2449
2639
  * @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
2640
  * @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
2641
  * @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 {RequestConfig} [requestConfig] - The request configuration for retry and validation.
2642
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
2453
2643
  * @returns {Promise<HttpResponse<ListPackagesOkResponse>>} - Successful Response
2454
2644
  */
2455
2645
  async listPackages(params, requestConfig) {
2456
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/packages").setRequestSchema(import_zod13.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
2646
+ const resolvedConfig = this.getResolvedConfig(this.listPackagesConfig, requestConfig);
2647
+ import_zod13.z.object({
2648
+ destination: import_zod13.z.string().optional(),
2649
+ startDate: import_zod13.z.string().optional(),
2650
+ endDate: import_zod13.z.string().optional(),
2651
+ afterCursor: import_zod13.z.string().optional(),
2652
+ limit: import_zod13.z.number().optional(),
2653
+ startTime: import_zod13.z.number().optional(),
2654
+ endTime: import_zod13.z.number().optional()
2655
+ }).parse(params != null ? params : {});
2656
+ 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
2657
  schema: listPackagesOkResponseResponse,
2458
2658
  contentType: "json" /* Json */,
2459
2659
  status: 200
@@ -2465,7 +2665,7 @@ var PackagesService = class extends BaseService {
2465
2665
  error: Unauthorized,
2466
2666
  contentType: "json" /* Json */,
2467
2667
  status: 401
2468
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
2668
+ }).addQueryParam({
2469
2669
  key: "destination",
2470
2670
  value: params == null ? void 0 : params.destination
2471
2671
  }).addQueryParam({
@@ -2487,7 +2687,7 @@ var PackagesService = class extends BaseService {
2487
2687
  key: "endTime",
2488
2688
  value: params == null ? void 0 : params.endTime
2489
2689
  }).build();
2490
- return this.client.call(request);
2690
+ return this.client.callDirect(request);
2491
2691
  }
2492
2692
  };
2493
2693
 
@@ -3329,13 +3529,68 @@ var getPurchaseConsumptionOkResponseRequest = import_zod32.z.lazy(() => {
3329
3529
 
3330
3530
  // src/services/purchases/purchases-service.ts
3331
3531
  var PurchasesService = class extends BaseService {
3532
+ /**
3533
+ * Sets method-level configuration for createPurchaseV2.
3534
+ * @param config - Partial configuration to override service-level defaults
3535
+ * @returns This service instance for method chaining
3536
+ */
3537
+ setCreatePurchaseV2Config(config) {
3538
+ this.createPurchaseV2Config = config;
3539
+ return this;
3540
+ }
3541
+ /**
3542
+ * Sets method-level configuration for listPurchases.
3543
+ * @param config - Partial configuration to override service-level defaults
3544
+ * @returns This service instance for method chaining
3545
+ */
3546
+ setListPurchasesConfig(config) {
3547
+ this.listPurchasesConfig = config;
3548
+ return this;
3549
+ }
3550
+ /**
3551
+ * Sets method-level configuration for createPurchase.
3552
+ * @param config - Partial configuration to override service-level defaults
3553
+ * @returns This service instance for method chaining
3554
+ */
3555
+ setCreatePurchaseConfig(config) {
3556
+ this.createPurchaseConfig = config;
3557
+ return this;
3558
+ }
3559
+ /**
3560
+ * Sets method-level configuration for topUpEsim.
3561
+ * @param config - Partial configuration to override service-level defaults
3562
+ * @returns This service instance for method chaining
3563
+ */
3564
+ setTopUpEsimConfig(config) {
3565
+ this.topUpEsimConfig = config;
3566
+ return this;
3567
+ }
3568
+ /**
3569
+ * Sets method-level configuration for editPurchase.
3570
+ * @param config - Partial configuration to override service-level defaults
3571
+ * @returns This service instance for method chaining
3572
+ */
3573
+ setEditPurchaseConfig(config) {
3574
+ this.editPurchaseConfig = config;
3575
+ return this;
3576
+ }
3577
+ /**
3578
+ * Sets method-level configuration for getPurchaseConsumption.
3579
+ * @param config - Partial configuration to override service-level defaults
3580
+ * @returns This service instance for method chaining
3581
+ */
3582
+ setGetPurchaseConsumptionConfig(config) {
3583
+ this.getPurchaseConsumptionConfig = config;
3584
+ return this;
3585
+ }
3332
3586
  /**
3333
3587
  * This endpoint is used to purchase a new eSIM by providing the package details.
3334
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3588
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3335
3589
  * @returns {Promise<HttpResponse<CreatePurchaseV2OkResponse[]>>} - Successful Response
3336
3590
  */
3337
3591
  async createPurchaseV2(body, requestConfig) {
3338
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases/v2").setRequestSchema(createPurchaseV2RequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3592
+ const resolvedConfig = this.getResolvedConfig(this.createPurchaseV2Config, requestConfig);
3593
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/v2").setRequestSchema(createPurchaseV2RequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3339
3594
  schema: import_zod33.z.array(createPurchaseV2OkResponseResponse),
3340
3595
  contentType: "json" /* Json */,
3341
3596
  status: 200
@@ -3347,8 +3602,8 @@ var PurchasesService = class extends BaseService {
3347
3602
  error: Unauthorized,
3348
3603
  contentType: "json" /* Json */,
3349
3604
  status: 401
3350
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3351
- return this.client.call(request);
3605
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3606
+ return this.client.callDirect(request);
3352
3607
  }
3353
3608
  /**
3354
3609
  * This endpoint can be used to list all the successful purchases made between a given interval.
@@ -3362,11 +3617,24 @@ var PurchasesService = class extends BaseService {
3362
3617
  * @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
3618
  * @param {number} [params.after] - Epoch value representing the start of the time interval for filtering purchases
3364
3619
  * @param {number} [params.before] - Epoch value representing the end of the time interval for filtering purchases
3365
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3620
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3366
3621
  * @returns {Promise<HttpResponse<ListPurchasesOkResponse>>} - Successful Response
3367
3622
  */
3368
3623
  async listPurchases(params, requestConfig) {
3369
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/purchases").setRequestSchema(import_zod33.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3624
+ const resolvedConfig = this.getResolvedConfig(this.listPurchasesConfig, requestConfig);
3625
+ import_zod33.z.object({
3626
+ purchaseId: import_zod33.z.string().optional(),
3627
+ iccid: import_zod33.z.string().optional(),
3628
+ afterDate: import_zod33.z.string().optional(),
3629
+ beforeDate: import_zod33.z.string().optional(),
3630
+ email: import_zod33.z.string().optional(),
3631
+ referenceId: import_zod33.z.string().optional(),
3632
+ afterCursor: import_zod33.z.string().optional(),
3633
+ limit: import_zod33.z.number().optional(),
3634
+ after: import_zod33.z.number().optional(),
3635
+ before: import_zod33.z.number().optional()
3636
+ }).parse(params != null ? params : {});
3637
+ 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
3638
  schema: listPurchasesOkResponseResponse,
3371
3639
  contentType: "json" /* Json */,
3372
3640
  status: 200
@@ -3378,7 +3646,7 @@ var PurchasesService = class extends BaseService {
3378
3646
  error: Unauthorized,
3379
3647
  contentType: "json" /* Json */,
3380
3648
  status: 401
3381
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
3649
+ }).addQueryParam({
3382
3650
  key: "purchaseId",
3383
3651
  value: params == null ? void 0 : params.purchaseId
3384
3652
  }).addQueryParam({
@@ -3409,15 +3677,16 @@ var PurchasesService = class extends BaseService {
3409
3677
  key: "before",
3410
3678
  value: params == null ? void 0 : params.before
3411
3679
  }).build();
3412
- return this.client.call(request);
3680
+ return this.client.callDirect(request);
3413
3681
  }
3414
3682
  /**
3415
3683
  * This endpoint is used to purchase a new eSIM by providing the package details.
3416
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3684
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3417
3685
  * @returns {Promise<HttpResponse<CreatePurchaseOkResponse>>} - Successful Response
3418
3686
  */
3419
3687
  async createPurchase(body, requestConfig) {
3420
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases").setRequestSchema(createPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3688
+ const resolvedConfig = this.getResolvedConfig(this.createPurchaseConfig, requestConfig);
3689
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases").setRequestSchema(createPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3421
3690
  schema: createPurchaseOkResponseResponse,
3422
3691
  contentType: "json" /* Json */,
3423
3692
  status: 200
@@ -3429,16 +3698,17 @@ var PurchasesService = class extends BaseService {
3429
3698
  error: Unauthorized,
3430
3699
  contentType: "json" /* Json */,
3431
3700
  status: 401
3432
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3433
- return this.client.call(request);
3701
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3702
+ return this.client.callDirect(request);
3434
3703
  }
3435
3704
  /**
3436
3705
  * 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 {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3706
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3438
3707
  * @returns {Promise<HttpResponse<TopUpEsimOkResponse>>} - Successful Response
3439
3708
  */
3440
3709
  async topUpEsim(body, requestConfig) {
3441
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases/topup").setRequestSchema(topUpEsimRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3710
+ const resolvedConfig = this.getResolvedConfig(this.topUpEsimConfig, requestConfig);
3711
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/topup").setRequestSchema(topUpEsimRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3442
3712
  schema: topUpEsimOkResponseResponse,
3443
3713
  contentType: "json" /* Json */,
3444
3714
  status: 200
@@ -3450,8 +3720,8 @@ var PurchasesService = class extends BaseService {
3450
3720
  error: Unauthorized,
3451
3721
  contentType: "json" /* Json */,
3452
3722
  status: 401
3453
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3454
- return this.client.call(request);
3723
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3724
+ return this.client.callDirect(request);
3455
3725
  }
3456
3726
  /**
3457
3727
  * This endpoint allows you to modify the validity dates of an existing purchase.
@@ -3462,11 +3732,12 @@ var PurchasesService = class extends BaseService {
3462
3732
 
3463
3733
  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
3734
 
3465
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3735
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3466
3736
  * @returns {Promise<HttpResponse<EditPurchaseOkResponse>>} - Successful Response
3467
3737
  */
3468
3738
  async editPurchase(body, requestConfig) {
3469
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/purchases/edit").setRequestSchema(editPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3739
+ const resolvedConfig = this.getResolvedConfig(this.editPurchaseConfig, requestConfig);
3740
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/edit").setRequestSchema(editPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3470
3741
  schema: editPurchaseOkResponseResponse,
3471
3742
  contentType: "json" /* Json */,
3472
3743
  status: 200
@@ -3478,17 +3749,18 @@ var PurchasesService = class extends BaseService {
3478
3749
  error: Unauthorized,
3479
3750
  contentType: "json" /* Json */,
3480
3751
  status: 401
3481
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3482
- return this.client.call(request);
3752
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3753
+ return this.client.callDirect(request);
3483
3754
  }
3484
3755
  /**
3485
3756
  * 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
3757
  * @param {string} purchaseId - ID of the purchase
3487
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3758
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3488
3759
  * @returns {Promise<HttpResponse<GetPurchaseConsumptionOkResponse>>} - Successful Response
3489
3760
  */
3490
3761
  async getPurchaseConsumption(purchaseId, requestConfig) {
3491
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/purchases/{purchaseId}/consumption").setRequestSchema(import_zod33.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3762
+ const resolvedConfig = this.getResolvedConfig(this.getPurchaseConsumptionConfig, requestConfig);
3763
+ 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
3764
  schema: getPurchaseConsumptionOkResponseResponse,
3493
3765
  contentType: "json" /* Json */,
3494
3766
  status: 200
@@ -3500,11 +3772,11 @@ var PurchasesService = class extends BaseService {
3500
3772
  error: Unauthorized,
3501
3773
  contentType: "json" /* Json */,
3502
3774
  status: 401
3503
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addPathParam({
3775
+ }).addPathParam({
3504
3776
  key: "purchaseId",
3505
3777
  value: purchaseId
3506
3778
  }).build();
3507
- return this.client.call(request);
3779
+ return this.client.callDirect(request);
3508
3780
  }
3509
3781
  };
3510
3782
 
@@ -3755,14 +4027,43 @@ var getEsimHistoryOkResponseRequest = import_zod40.z.lazy(() => {
3755
4027
 
3756
4028
  // src/services/e-sim/e-sim-service.ts
3757
4029
  var ESimService = class extends BaseService {
4030
+ /**
4031
+ * Sets method-level configuration for getEsim.
4032
+ * @param config - Partial configuration to override service-level defaults
4033
+ * @returns This service instance for method chaining
4034
+ */
4035
+ setGetEsimConfig(config) {
4036
+ this.getEsimConfig = config;
4037
+ return this;
4038
+ }
4039
+ /**
4040
+ * Sets method-level configuration for getEsimDevice.
4041
+ * @param config - Partial configuration to override service-level defaults
4042
+ * @returns This service instance for method chaining
4043
+ */
4044
+ setGetEsimDeviceConfig(config) {
4045
+ this.getEsimDeviceConfig = config;
4046
+ return this;
4047
+ }
4048
+ /**
4049
+ * Sets method-level configuration for getEsimHistory.
4050
+ * @param config - Partial configuration to override service-level defaults
4051
+ * @returns This service instance for method chaining
4052
+ */
4053
+ setGetEsimHistoryConfig(config) {
4054
+ this.getEsimHistoryConfig = config;
4055
+ return this;
4056
+ }
3758
4057
  /**
3759
4058
  * Get eSIM
3760
4059
  * @param {string} params.iccid - ID of the eSIM
3761
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4060
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3762
4061
  * @returns {Promise<HttpResponse<GetEsimOkResponse>>} - Successful Response
3763
4062
  */
3764
4063
  async getEsim(params, requestConfig) {
3765
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/esim").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4064
+ const resolvedConfig = this.getResolvedConfig(this.getEsimConfig, requestConfig);
4065
+ import_zod41.z.object({ iccid: import_zod41.z.string() }).parse(params != null ? params : {});
4066
+ 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
4067
  schema: getEsimOkResponseResponse,
3767
4068
  contentType: "json" /* Json */,
3768
4069
  status: 200
@@ -3774,20 +4075,21 @@ var ESimService = class extends BaseService {
3774
4075
  error: Unauthorized,
3775
4076
  contentType: "json" /* Json */,
3776
4077
  status: 401
3777
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
4078
+ }).addQueryParam({
3778
4079
  key: "iccid",
3779
4080
  value: params == null ? void 0 : params.iccid
3780
4081
  }).build();
3781
- return this.client.call(request);
4082
+ return this.client.callDirect(request);
3782
4083
  }
3783
4084
  /**
3784
4085
  * Get eSIM Device
3785
4086
  * @param {string} iccid - ID of the eSIM
3786
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4087
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3787
4088
  * @returns {Promise<HttpResponse<GetEsimDeviceOkResponse>>} - Successful Response
3788
4089
  */
3789
4090
  async getEsimDevice(iccid, requestConfig) {
3790
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/esim/{iccid}/device").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4091
+ const resolvedConfig = this.getResolvedConfig(this.getEsimDeviceConfig, requestConfig);
4092
+ 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
4093
  schema: getEsimDeviceOkResponseResponse,
3792
4094
  contentType: "json" /* Json */,
3793
4095
  status: 200
@@ -3799,20 +4101,21 @@ var ESimService = class extends BaseService {
3799
4101
  error: Unauthorized,
3800
4102
  contentType: "json" /* Json */,
3801
4103
  status: 401
3802
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addPathParam({
4104
+ }).addPathParam({
3803
4105
  key: "iccid",
3804
4106
  value: iccid
3805
4107
  }).build();
3806
- return this.client.call(request);
4108
+ return this.client.callDirect(request);
3807
4109
  }
3808
4110
  /**
3809
4111
  * Get eSIM History
3810
4112
  * @param {string} iccid - ID of the eSIM
3811
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4113
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3812
4114
  * @returns {Promise<HttpResponse<GetEsimHistoryOkResponse>>} - Successful Response
3813
4115
  */
3814
4116
  async getEsimHistory(iccid, requestConfig) {
3815
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("GET").setPath("/esim/{iccid}/history").setRequestSchema(import_zod41.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4117
+ const resolvedConfig = this.getResolvedConfig(this.getEsimHistoryConfig, requestConfig);
4118
+ 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
4119
  schema: getEsimHistoryOkResponseResponse,
3817
4120
  contentType: "json" /* Json */,
3818
4121
  status: 200
@@ -3824,11 +4127,11 @@ var ESimService = class extends BaseService {
3824
4127
  error: Unauthorized,
3825
4128
  contentType: "json" /* Json */,
3826
4129
  status: 401
3827
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addPathParam({
4130
+ }).addPathParam({
3828
4131
  key: "iccid",
3829
4132
  value: iccid
3830
4133
  }).build();
3831
- return this.client.call(request);
4134
+ return this.client.callDirect(request);
3832
4135
  }
3833
4136
  };
3834
4137
 
@@ -3859,13 +4162,23 @@ var tokenOkResponseRequest = import_zod42.z.lazy(() => {
3859
4162
 
3860
4163
  // src/services/i-frame/i-frame-service.ts
3861
4164
  var IFrameService = class extends BaseService {
4165
+ /**
4166
+ * Sets method-level configuration for token.
4167
+ * @param config - Partial configuration to override service-level defaults
4168
+ * @returns This service instance for method chaining
4169
+ */
4170
+ setTokenConfig(config) {
4171
+ this.tokenConfig = config;
4172
+ return this;
4173
+ }
3862
4174
  /**
3863
4175
  * Generate a new token to be used in the iFrame
3864
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4176
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3865
4177
  * @returns {Promise<HttpResponse<TokenOkResponse>>} - Successful Response
3866
4178
  */
3867
4179
  async token(requestConfig) {
3868
- const request = new RequestBuilder().setBaseUrl((requestConfig == null ? void 0 : requestConfig.baseUrl) || this.config.baseUrl || this.config.environment || "https://api.celitech.net/v1" /* DEFAULT */).setConfig(this.config).setMethod("POST").setPath("/iframe/token").setRequestSchema(import_zod43.z.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4180
+ const resolvedConfig = this.getResolvedConfig(this.tokenConfig, requestConfig);
4181
+ 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
4182
  schema: tokenOkResponseResponse,
3870
4183
  contentType: "json" /* Json */,
3871
4184
  status: 200
@@ -3877,8 +4190,8 @@ var IFrameService = class extends BaseService {
3877
4190
  error: Unauthorized,
3878
4191
  contentType: "json" /* Json */,
3879
4192
  status: 401
3880
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).build();
3881
- return this.client.call(request);
4193
+ }).build();
4194
+ return this.client.callDirect(request);
3882
4195
  }
3883
4196
  };
3884
4197