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.mjs CHANGED
@@ -235,7 +235,11 @@ var TransportHookAdapter = class {
235
235
  method: newRequest.method,
236
236
  path: newRequest.path,
237
237
  body: newRequest.body,
238
- queryParams: this.hookParamsToTransportParams(newRequest.queryParams, request.queryParams, true),
238
+ queryParams: this.hookParamsToTransportParams(
239
+ newRequest.queryParams,
240
+ request.queryParams,
241
+ true
242
+ ),
239
243
  headers: this.hookParamsToTransportParams(newRequest.headers, request.headers, false),
240
244
  pathParams: this.hookParamsToTransportParams(newRequest.pathParams, request.headers, false)
241
245
  });
@@ -398,8 +402,16 @@ var HookHandler = class {
398
402
  });
399
403
  if (error) {
400
404
  const decodedBody2 = new TextDecoder().decode(arrayBuffer);
401
- const json = JSON.parse(decodedBody2);
402
- new error.error((json == null ? void 0 : json.message) || "", json).throw();
405
+ let json = void 0;
406
+ if (decodedBody2.trim().length > 0) {
407
+ try {
408
+ json = JSON.parse(decodedBody2);
409
+ } catch (e) {
410
+ }
411
+ }
412
+ const customError = new error.error((json == null ? void 0 : json.message) || "", json);
413
+ customError.metadata = response.metadata;
414
+ customError.throw();
403
415
  }
404
416
  const decodedBody = new TextDecoder().decode(arrayBuffer);
405
417
  throw new HttpError(
@@ -579,20 +591,36 @@ var ResponseValidationHandler = class {
579
591
  if (decodedBody.startsWith("data: ")) {
580
592
  decodedBody = decodedBody.substring(6);
581
593
  }
582
- const json = JSON.parse(decodedBody);
594
+ if (decodedBody.trim().length === 0) {
595
+ return { ...response, data: void 0 };
596
+ }
583
597
  return {
584
598
  ...response,
585
- data: this.validate(request, responseDefinition, json)
599
+ data: this.validate(request, responseDefinition, this.parseJson(decodedBody))
586
600
  };
587
601
  }
588
602
  decodeJson(request, responseDefinition, response) {
589
603
  const decodedBody = new TextDecoder().decode(response.raw);
590
- const json = JSON.parse(decodedBody);
604
+ if (decodedBody.trim().length === 0) {
605
+ return { ...response, data: void 0 };
606
+ }
591
607
  return {
592
608
  ...response,
593
- data: this.validate(request, responseDefinition, json)
609
+ data: this.validate(request, responseDefinition, this.parseJson(decodedBody))
594
610
  };
595
611
  }
612
+ /**
613
+ * Parses a JSON response body, rethrowing parse failures as a plain Error
614
+ * so callers don't have to special-case SyntaxError.
615
+ */
616
+ parseJson(decodedBody) {
617
+ try {
618
+ return JSON.parse(decodedBody);
619
+ } catch (e) {
620
+ const message = e instanceof Error ? e.message : String(e);
621
+ throw new Error(`Failed to parse JSON response body: ${message}`);
622
+ }
623
+ }
596
624
  /**
597
625
  * Validates response data against the expected schema if validation is enabled.
598
626
  * @template T - The expected data type
@@ -602,8 +630,8 @@ var ResponseValidationHandler = class {
602
630
  * @returns The validated data (parsed if validation enabled, raw otherwise)
603
631
  */
604
632
  validate(request, response, data) {
605
- var _a;
606
- if ((_a = request.validation) == null ? void 0 : _a.responseValidation) {
633
+ var _a, _b;
634
+ if ((_b = (_a = request.config.validation) == null ? void 0 : _a.responseValidation) != null ? _b : true) {
607
635
  return response.schema.parse(data);
608
636
  }
609
637
  return data;
@@ -676,7 +704,9 @@ var ValidationError = class extends Error {
676
704
  }
677
705
  const error = [
678
706
  `ValidationError:`,
679
- ...zodError.issues.map((issue) => ` Property: ${issue.path.join(".")}. Message: ${issue.message}`),
707
+ ...zodError.issues.map(
708
+ (issue) => ` Property: ${issue.path.join(".")}. Message: ${issue.message}`
709
+ ),
680
710
  " Validated:",
681
711
  ...actual.split("\n").map((line) => ` ${line}`)
682
712
  ].join("\n");
@@ -984,7 +1014,10 @@ var RequestFetchAdapter = class {
984
1014
  return headers;
985
1015
  }
986
1016
  toArrayBuffer(uint8Array) {
987
- return uint8Array.buffer.slice(uint8Array.byteOffset, uint8Array.byteOffset + uint8Array.byteLength);
1017
+ return uint8Array.buffer.slice(
1018
+ uint8Array.byteOffset,
1019
+ uint8Array.byteOffset + uint8Array.byteLength
1020
+ );
988
1021
  }
989
1022
  };
990
1023
 
@@ -1015,23 +1048,27 @@ var RetryHandler = class {
1015
1048
  /**
1016
1049
  * Handles a standard HTTP request with retry logic.
1017
1050
  * Retries failed requests based on the configured retry settings.
1051
+ * Implements exponential backoff with optional jitter between retry attempts.
1018
1052
  * @template T - The expected response data type
1019
1053
  * @param request - The HTTP request to process
1020
1054
  * @returns A promise that resolves to the HTTP response
1021
1055
  * @throws Error if no next handler is set, or if all retry attempts fail
1022
1056
  */
1023
1057
  async handle(request) {
1058
+ var _a, _b;
1024
1059
  if (!this.next) {
1025
1060
  throw new Error("No next handler set in retry handler.");
1026
1061
  }
1027
- for (let attempt = 1; attempt <= request.retry.attempts; attempt++) {
1062
+ const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
1063
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1028
1064
  try {
1029
1065
  return await this.next.handle(request);
1030
1066
  } catch (error) {
1031
- if (!this.shouldRetry(error) || attempt === request.retry.attempts) {
1067
+ if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
1032
1068
  throw error;
1033
1069
  }
1034
- await this.delay(request.retry.delayMs);
1070
+ const delayMs = this.calculateDelay(attempt, request);
1071
+ await this.delay(delayMs);
1035
1072
  }
1036
1073
  }
1037
1074
  throw new Error("Error retrying request.");
@@ -1044,38 +1081,78 @@ var RetryHandler = class {
1044
1081
  * @throws Error if no next handler is set, or if all retry attempts fail
1045
1082
  */
1046
1083
  async *stream(request) {
1084
+ var _a, _b;
1047
1085
  if (!this.next) {
1048
1086
  throw new Error("No next handler set in retry handler.");
1049
1087
  }
1050
- for (let attempt = 1; attempt <= request.retry.attempts; attempt++) {
1088
+ const maxAttempts = (_b = (_a = request.config.retry) == null ? void 0 : _a.attempts) != null ? _b : 3;
1089
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
1051
1090
  try {
1052
1091
  yield* this.next.stream(request);
1053
1092
  return;
1054
1093
  } catch (error) {
1055
- if (!this.shouldRetry(error) || attempt === request.retry.attempts) {
1094
+ if (!this.shouldRetry(error, request) || attempt === maxAttempts) {
1056
1095
  throw error;
1057
1096
  }
1058
- await this.delay(request.retry.delayMs);
1097
+ const delayMs = this.calculateDelay(attempt, request);
1098
+ await this.delay(delayMs);
1059
1099
  }
1060
1100
  }
1061
1101
  throw new Error("Error retrying request.");
1062
1102
  }
1063
1103
  /**
1064
1104
  * Determines if an error should trigger a retry.
1065
- * Retries server errors (5xx), request timeouts (408), and rate limits (429).
1105
+ * Checks both HTTP status codes and HTTP methods against the configured retry settings.
1106
+ * By default, retries all 5xx server errors and specific 4xx client errors (408 Timeout, 429 Rate Limit).
1066
1107
  * @param error - The error to check
1108
+ * @param request - The HTTP request being retried
1067
1109
  * @returns True if the request should be retried, false otherwise
1068
1110
  */
1069
- shouldRetry(error) {
1070
- return error instanceof HttpError && (error.metadata.status >= 500 || error.metadata.status === 408 || error.metadata.status === 429);
1111
+ shouldRetry(error, request) {
1112
+ var _a, _b, _c;
1113
+ if (!(error instanceof HttpError)) {
1114
+ return false;
1115
+ }
1116
+ const httpMethodsToRetry = (_b = (_a = request.config.retry) == null ? void 0 : _a.httpMethodsToRetry) != null ? _b : [
1117
+ "GET",
1118
+ "POST",
1119
+ "PUT",
1120
+ "DELETE",
1121
+ "PATCH",
1122
+ "HEAD",
1123
+ "OPTIONS"
1124
+ ];
1125
+ 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);
1126
+ const shouldRetryMethod = httpMethodsToRetry.includes(request.method);
1127
+ return shouldRetryStatus && shouldRetryMethod;
1128
+ }
1129
+ /**
1130
+ * Calculates the delay before the next retry attempt using exponential backoff.
1131
+ * Optionally adds jitter to prevent thundering herd problems.
1132
+ * @param attempt - The current retry attempt number (1-indexed)
1133
+ * @param request - The HTTP request being retried
1134
+ * @returns The delay in milliseconds, capped at the configured maximum delay
1135
+ */
1136
+ calculateDelay(attempt, request) {
1137
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1138
+ const baseDelay = (_b = (_a = request.config.retry) == null ? void 0 : _a.delayMs) != null ? _b : 150;
1139
+ const backoffFactor = (_d = (_c = request.config.retry) == null ? void 0 : _c.backoffFactor) != null ? _d : 2;
1140
+ const maxDelay = (_f = (_e = request.config.retry) == null ? void 0 : _e.maxDelayMs) != null ? _f : 5e3;
1141
+ const jitter = (_h = (_g = request.config.retry) == null ? void 0 : _g.jitterMs) != null ? _h : 50;
1142
+ let delay = baseDelay * Math.pow(backoffFactor, attempt - 1);
1143
+ delay = Math.min(delay, maxDelay);
1144
+ if (jitter > 0) {
1145
+ delay += Math.random() * jitter;
1146
+ }
1147
+ return Math.floor(delay);
1071
1148
  }
1072
1149
  /**
1073
1150
  * Delays execution for a specified duration before retrying.
1074
- * @param delayMs - The delay in milliseconds (optional)
1151
+ * @param delayMs - The delay in milliseconds
1075
1152
  * @returns A promise that resolves after the delay
1076
1153
  */
1077
1154
  delay(delayMs) {
1078
- if (!delayMs) {
1155
+ if (delayMs <= 0) {
1079
1156
  return Promise.resolve();
1080
1157
  }
1081
1158
  return new Promise((resolve, reject) => {
@@ -1186,6 +1263,15 @@ var HttpClient = class {
1186
1263
  call(request) {
1187
1264
  return this.requestHandlerChain.callChain(request);
1188
1265
  }
1266
+ /**
1267
+ * Executes a standard HTTP request and returns only the data directly.
1268
+ * @template T - The expected response data type
1269
+ * @param request - The HTTP request to execute
1270
+ * @returns A promise that resolves to the response data
1271
+ */
1272
+ callDirect(request) {
1273
+ return this.call(request).then((response) => response.data);
1274
+ }
1189
1275
  /**
1190
1276
  * Executes a streaming HTTP request that yields responses incrementally.
1191
1277
  * @template T - The expected response data type for each chunk
@@ -1306,6 +1392,61 @@ var BaseService = class {
1306
1392
  this.tokenManager = tokenManager;
1307
1393
  this.client = new HttpClient(this.config);
1308
1394
  }
1395
+ /**
1396
+ * Sets service-level configuration that applies to all methods in this service.
1397
+ * @param config - Partial configuration to override SDK-level defaults
1398
+ * @returns This service instance for method chaining
1399
+ */
1400
+ setConfig(config) {
1401
+ this.serviceConfig = config;
1402
+ return this;
1403
+ }
1404
+ /**
1405
+ * Recursively merges two objects. Plain nested objects are merged key-by-key so a
1406
+ * partial override (e.g. `{ retry: { attempts: 5 } }`) only overwrites the specified
1407
+ * keys instead of replacing the whole nested object. Arrays and non-plain values are
1408
+ * replaced wholesale.
1409
+ *
1410
+ * Override keys with the value `undefined` are skipped so the base value is preserved,
1411
+ * matching the common JS merge idiom (e.g. lodash.merge). To explicitly clear a key,
1412
+ * assign `null` or omit the key from the override entirely.
1413
+ */
1414
+ static deepMerge(base, override) {
1415
+ const result = { ...base };
1416
+ for (const [key, value] of Object.entries(override)) {
1417
+ const existing = result[key];
1418
+ if (BaseService.isPlainObject(value) && BaseService.isPlainObject(existing)) {
1419
+ result[key] = BaseService.deepMerge(existing, value);
1420
+ } else if (value !== void 0) {
1421
+ result[key] = value;
1422
+ }
1423
+ }
1424
+ return result;
1425
+ }
1426
+ static isPlainObject(value) {
1427
+ return typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
1428
+ }
1429
+ /**
1430
+ * Resolves configuration from the hierarchy: requestConfig > methodConfig > serviceConfig > sdkConfig
1431
+ * Deep-merges all config levels so partial nested overrides (e.g. `{ retry: { attempts: 5 } }`)
1432
+ * preserve unoverridden sibling keys from the SDK default.
1433
+ * @param methodConfig - Method-level configuration override
1434
+ * @param requestConfig - Request-level configuration override
1435
+ * @returns Merged configuration with all overrides applied
1436
+ */
1437
+ getResolvedConfig(methodConfig, requestConfig) {
1438
+ let merged = { ...this.config };
1439
+ if (this.serviceConfig) {
1440
+ merged = BaseService.deepMerge(merged, this.serviceConfig);
1441
+ }
1442
+ if (methodConfig) {
1443
+ merged = BaseService.deepMerge(merged, methodConfig);
1444
+ }
1445
+ if (requestConfig) {
1446
+ merged = BaseService.deepMerge(merged, requestConfig);
1447
+ }
1448
+ return merged;
1449
+ }
1309
1450
  set baseUrl(baseUrl) {
1310
1451
  this.config.baseUrl = baseUrl;
1311
1452
  }
@@ -1482,8 +1623,6 @@ var Request = class {
1482
1623
  this.queryParams = /* @__PURE__ */ new Map();
1483
1624
  this.pathParams = /* @__PURE__ */ new Map();
1484
1625
  this.cookies = /* @__PURE__ */ new Map();
1485
- this.validation = {};
1486
- this.retry = {};
1487
1626
  this.baseUrl = params.baseUrl;
1488
1627
  this.method = params.method;
1489
1628
  this.pathPattern = params.path;
@@ -1498,8 +1637,6 @@ var Request = class {
1498
1637
  this.errors = params.errors;
1499
1638
  this.requestSchema = params.requestSchema;
1500
1639
  this.requestContentType = params.requestContentType;
1501
- this.retry = params.retry;
1502
- this.validation = params.validation;
1503
1640
  this.pagination = params.pagination;
1504
1641
  this.filename = params.filename;
1505
1642
  this.filenames = params.filenames;
@@ -1612,7 +1749,7 @@ var Request = class {
1612
1749
  * @returns A new Request instance with the specified overrides
1613
1750
  */
1614
1751
  copy(overrides) {
1615
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
1752
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1616
1753
  const createRequestParams = {
1617
1754
  baseUrl: (_a = overrides == null ? void 0 : overrides.baseUrl) != null ? _a : this.baseUrl,
1618
1755
  errors: (_b = overrides == null ? void 0 : overrides.errors) != null ? _b : this.errors,
@@ -1627,10 +1764,8 @@ var Request = class {
1627
1764
  responses: (_k = overrides == null ? void 0 : overrides.responses) != null ? _k : this.responses,
1628
1765
  requestSchema: (_l = overrides == null ? void 0 : overrides.requestSchema) != null ? _l : this.requestSchema,
1629
1766
  requestContentType: (_m = overrides == null ? void 0 : overrides.requestContentType) != null ? _m : this.requestContentType,
1630
- retry: (_n = overrides == null ? void 0 : overrides.retry) != null ? _n : this.retry,
1631
- validation: (_o = overrides == null ? void 0 : overrides.validation) != null ? _o : this.validation,
1632
- filename: (_p = overrides == null ? void 0 : overrides.filename) != null ? _p : this.filename,
1633
- filenames: (_q = overrides == null ? void 0 : overrides.filenames) != null ? _q : this.filenames,
1767
+ filename: (_n = overrides == null ? void 0 : overrides.filename) != null ? _n : this.filename,
1768
+ filenames: (_o = overrides == null ? void 0 : overrides.filenames) != null ? _o : this.filenames,
1634
1769
  scopes: overrides == null ? void 0 : overrides.scopes,
1635
1770
  tokenManager: this.tokenManager
1636
1771
  };
@@ -1732,55 +1867,73 @@ var RequestBuilder = class {
1732
1867
  baseUrl: "https://api.celitech.net/v1" /* DEFAULT */,
1733
1868
  method: "GET",
1734
1869
  path: "",
1735
- config: {},
1870
+ config: {
1871
+ clientId: "",
1872
+ clientSecret: "",
1873
+ retry: {
1874
+ attempts: 3,
1875
+ delayMs: 150,
1876
+ maxDelayMs: 5e3,
1877
+ backoffFactor: 2,
1878
+ jitterMs: 50,
1879
+ httpMethodsToRetry: ["GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS"]
1880
+ },
1881
+ validation: { responseValidation: true }
1882
+ },
1736
1883
  responses: [],
1737
1884
  errors: [],
1738
1885
  requestSchema: z.any(),
1739
1886
  requestContentType: "json" /* Json */,
1740
- retry: {
1741
- attempts: 3,
1742
- delayMs: 150
1743
- },
1744
- validation: {
1745
- responseValidation: true
1746
- },
1747
1887
  pathParams: /* @__PURE__ */ new Map(),
1748
1888
  queryParams: /* @__PURE__ */ new Map(),
1749
1889
  headers: /* @__PURE__ */ new Map(),
1750
1890
  cookies: /* @__PURE__ */ new Map(),
1751
1891
  tokenManager: new OAuthTokenManager()
1752
1892
  };
1893
+ this.addHeaderParam({
1894
+ key: "User-Agent",
1895
+ value: "postman-codegen/1.4.0 celitech-sdk/2.0.2 (typescript)"
1896
+ });
1753
1897
  }
1754
- setRetryAttempts(sdkConfig, requestConfig) {
1898
+ setConfig(config) {
1755
1899
  var _a, _b;
1756
- if (((_a = requestConfig == null ? void 0 : requestConfig.retry) == null ? void 0 : _a.attempts) !== void 0) {
1757
- this.params.retry.attempts = requestConfig.retry.attempts;
1758
- } else if (((_b = sdkConfig == null ? void 0 : sdkConfig.retry) == null ? void 0 : _b.attempts) !== void 0) {
1759
- this.params.retry.attempts = sdkConfig.retry.attempts;
1900
+ let mergedRetry = (_a = config.retry) != null ? _a : this.params.config.retry;
1901
+ if (config.retry !== void 0 && this.params.config.retry !== void 0) {
1902
+ mergedRetry = { ...this.params.config.retry, ...config.retry };
1760
1903
  }
1761
- return this;
1762
- }
1763
- setRetryDelayMs(sdkConfig, requestConfig) {
1764
- var _a, _b;
1765
- if (((_a = requestConfig == null ? void 0 : requestConfig.retry) == null ? void 0 : _a.delayMs) !== void 0) {
1766
- this.params.retry.delayMs = requestConfig.retry.delayMs;
1767
- } else if (((_b = sdkConfig == null ? void 0 : sdkConfig.retry) == null ? void 0 : _b.delayMs) !== void 0) {
1768
- this.params.retry.delayMs = sdkConfig.retry.delayMs;
1904
+ let mergedValidation = (_b = config.validation) != null ? _b : this.params.config.validation;
1905
+ if (config.validation !== void 0 && this.params.config.validation !== void 0) {
1906
+ mergedValidation = { ...this.params.config.validation, ...config.validation };
1769
1907
  }
1908
+ this.params.config = {
1909
+ ...this.params.config,
1910
+ ...config,
1911
+ ...mergedRetry !== void 0 && { retry: mergedRetry },
1912
+ ...mergedValidation !== void 0 && { validation: mergedValidation }
1913
+ };
1770
1914
  return this;
1771
1915
  }
1772
- setResponseValidation(sdkConfig, requestConfig) {
1773
- var _a, _b;
1774
- if (((_a = requestConfig == null ? void 0 : requestConfig.validation) == null ? void 0 : _a.responseValidation) !== void 0) {
1775
- this.params.validation.responseValidation = requestConfig.validation.responseValidation;
1776
- } else if (((_b = sdkConfig == null ? void 0 : sdkConfig.validation) == null ? void 0 : _b.responseValidation) !== void 0) {
1777
- this.params.validation.responseValidation = sdkConfig.validation.responseValidation;
1916
+ /**
1917
+ * Sets the base URL for the request using hierarchical configuration resolution.
1918
+ *
1919
+ * Resolution logic:
1920
+ * 1. First tries to resolve 'baseUrl' (string) from the resolved config
1921
+ * 2. If no 'baseUrl' found, falls back to 'environment' (enum) from the resolved config
1922
+ * 3. 'baseUrl' always takes precedence over 'environment'
1923
+ *
1924
+ * @param config - Resolved configuration from all hierarchy levels
1925
+ * @returns This builder instance for method chaining
1926
+ */
1927
+ setBaseUrl(config) {
1928
+ if (!config) {
1929
+ return this;
1778
1930
  }
1779
- return this;
1780
- }
1781
- setBaseUrl(baseUrl) {
1782
- if (baseUrl) {
1783
- this.params.baseUrl = baseUrl;
1931
+ if ("baseUrl" in config && typeof config.baseUrl === "string" && config.baseUrl) {
1932
+ this.params.baseUrl = config.baseUrl;
1933
+ return this;
1934
+ }
1935
+ if ("environment" in config && config.environment) {
1936
+ this.params.baseUrl = config.environment;
1784
1937
  }
1785
1938
  return this;
1786
1939
  }
@@ -1792,10 +1945,6 @@ var RequestBuilder = class {
1792
1945
  this.params.path = path;
1793
1946
  return this;
1794
1947
  }
1795
- setConfig(config) {
1796
- this.params.config = config;
1797
- return this;
1798
- }
1799
1948
  setRequestContentType(contentType) {
1800
1949
  this.params.requestContentType = contentType;
1801
1950
  return this;
@@ -1838,7 +1987,7 @@ var RequestBuilder = class {
1838
1987
  }
1839
1988
  this.params.headers.set("Authorization", {
1840
1989
  key: "Authorization",
1841
- value: `${prefix != null ? prefix : "BEARER"} ${accessToken}`,
1990
+ value: `${prefix != null ? prefix : "Bearer"} ${accessToken}`,
1842
1991
  explode: false,
1843
1992
  style: "simple" /* SIMPLE */,
1844
1993
  encode: true,
@@ -1864,20 +2013,30 @@ var RequestBuilder = class {
1864
2013
  });
1865
2014
  return this;
1866
2015
  }
1867
- addApiKeyAuth(apiKey, keyName) {
2016
+ addApiKeyAuth(apiKey, keyName, location) {
1868
2017
  if (apiKey === void 0) {
1869
2018
  return this;
1870
2019
  }
1871
- this.params.headers.set(keyName != null ? keyName : "X-API-KEY", {
1872
- key: keyName != null ? keyName : "X-API-KEY",
2020
+ const resolvedKeyName = keyName != null ? keyName : "X-API-KEY";
2021
+ const resolvedLocation = location != null ? location : "header";
2022
+ const isQuery = resolvedLocation === "query";
2023
+ const param = {
2024
+ key: resolvedKeyName,
1873
2025
  value: apiKey,
1874
- explode: false,
1875
- style: "simple" /* SIMPLE */,
2026
+ explode: isQuery,
2027
+ style: isQuery ? "form" /* FORM */ : "simple" /* SIMPLE */,
1876
2028
  encode: true,
1877
2029
  isLimit: false,
1878
2030
  isOffset: false,
1879
2031
  isCursor: false
1880
- });
2032
+ };
2033
+ if (resolvedLocation === "query") {
2034
+ this.params.queryParams.set(resolvedKeyName, param);
2035
+ } else if (resolvedLocation === "cookie") {
2036
+ this.params.cookies.set(resolvedKeyName, param);
2037
+ } else {
2038
+ this.params.headers.set(resolvedKeyName, param);
2039
+ }
1881
2040
  return this;
1882
2041
  }
1883
2042
  addResponse(response) {
@@ -1985,66 +2144,66 @@ var RequestBuilder = class {
1985
2144
  }
1986
2145
  };
1987
2146
 
1988
- // src/services/o-auth/models/get-access-token-request.ts
2147
+ // src/services/o-auth/models/o-auth-token-request.ts
1989
2148
  import { z as z2 } from "zod";
1990
- var getAccessTokenRequest = z2.lazy(() => {
2149
+ var oAuthTokenRequest = z2.lazy(() => {
1991
2150
  return z2.object({
1992
- grantType: z2.string().optional(),
1993
- clientId: z2.string().optional(),
1994
- clientSecret: z2.string().optional()
2151
+ grantType: z2.string(),
2152
+ clientId: z2.string(),
2153
+ clientSecret: z2.string(),
2154
+ scope: z2.string()
1995
2155
  });
1996
2156
  });
1997
- var getAccessTokenRequestResponse = z2.lazy(() => {
2157
+ var oAuthTokenRequestResponse = z2.lazy(() => {
1998
2158
  return z2.object({
1999
- grant_type: z2.string().optional(),
2000
- client_id: z2.string().optional(),
2001
- client_secret: z2.string().optional()
2159
+ grant_type: z2.string(),
2160
+ client_id: z2.string(),
2161
+ client_secret: z2.string(),
2162
+ scope: z2.string()
2002
2163
  }).transform((data) => ({
2003
2164
  grantType: data["grant_type"],
2004
2165
  clientId: data["client_id"],
2005
- clientSecret: data["client_secret"]
2166
+ clientSecret: data["client_secret"],
2167
+ scope: data["scope"]
2006
2168
  }));
2007
2169
  });
2008
- var getAccessTokenRequestRequest = z2.lazy(() => {
2170
+ var oAuthTokenRequestRequest = z2.lazy(() => {
2009
2171
  return z2.object({
2010
- grantType: z2.string().optional(),
2011
- clientId: z2.string().optional(),
2012
- clientSecret: z2.string().optional()
2172
+ grantType: z2.string(),
2173
+ clientId: z2.string(),
2174
+ clientSecret: z2.string(),
2175
+ scope: z2.string()
2013
2176
  }).transform((data) => ({
2014
2177
  grant_type: data["grantType"],
2015
2178
  client_id: data["clientId"],
2016
- client_secret: data["clientSecret"]
2179
+ client_secret: data["clientSecret"],
2180
+ scope: data["scope"]
2017
2181
  }));
2018
2182
  });
2019
2183
 
2020
- // src/services/o-auth/models/get-access-token-ok-response.ts
2184
+ // src/services/o-auth/models/o-auth-token-response.ts
2021
2185
  import { z as z3 } from "zod";
2022
- var getAccessTokenOkResponse = z3.lazy(() => {
2186
+ var oAuthTokenResponse = z3.lazy(() => {
2023
2187
  return z3.object({
2024
2188
  accessToken: z3.string().optional(),
2025
- tokenType: z3.string().optional(),
2026
- expiresIn: z3.number().optional()
2189
+ expiresIn: z3.number().optional().nullable()
2027
2190
  });
2028
2191
  });
2029
- var getAccessTokenOkResponseResponse = z3.lazy(() => {
2192
+ var oAuthTokenResponseResponse = z3.lazy(() => {
2030
2193
  return z3.object({
2031
2194
  access_token: z3.string().optional(),
2032
- token_type: z3.string().optional(),
2033
- expires_in: z3.number().optional()
2195
+ expires_in: z3.number().optional().nullable()
2034
2196
  }).transform((data) => ({
2035
2197
  accessToken: data["access_token"],
2036
- tokenType: data["token_type"],
2037
2198
  expiresIn: data["expires_in"]
2038
2199
  }));
2039
2200
  });
2040
- var getAccessTokenOkResponseRequest = z3.lazy(() => {
2201
+ var oAuthTokenResponseRequest = z3.lazy(() => {
2041
2202
  return z3.object({
2042
2203
  accessToken: z3.string().optional(),
2043
- tokenType: z3.string().optional(),
2044
- expiresIn: z3.number().optional()
2204
+ expiresIn: z3.number().optional().nullable()
2045
2205
  }).transform((data) => ({
2046
2206
  access_token: data["accessToken"],
2047
- token_type: data["tokenType"],
2048
2207
  expires_in: data["expiresIn"]
2049
2208
  }));
2050
2209
  });
@@ -2052,17 +2211,27 @@ var getAccessTokenOkResponseRequest = z3.lazy(() => {
2052
2211
  // src/services/o-auth/o-auth-service.ts
2053
2212
  var OAuthService = class extends BaseService {
2054
2213
  /**
2055
- * This endpoint was added by liblab
2056
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
2057
- * @returns {Promise<HttpResponse<GetAccessTokenOkResponse>>} - Successful Response
2214
+ * Sets method-level configuration for getAccessToken.
2215
+ * @param config - Partial configuration to override service-level defaults
2216
+ * @returns This service instance for method chaining
2217
+ */
2218
+ setGetAccessTokenConfig(config) {
2219
+ this.getAccessTokenConfig = config;
2220
+ return this;
2221
+ }
2222
+ /**
2223
+ *
2224
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
2225
+ * @returns {Promise<HttpResponse<OAuthTokenResponse>>} - OAuth token
2058
2226
  */
2059
2227
  async getAccessToken(body, requestConfig) {
2060
- 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({
2061
- schema: getAccessTokenOkResponseResponse,
2228
+ const resolvedConfig = this.getResolvedConfig(this.getAccessTokenConfig, requestConfig);
2229
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/oauth2/token").setRequestSchema(oAuthTokenRequestRequest).setTokenManager(this.tokenManager).setRequestContentType("form" /* FormUrlEncoded */).addResponse({
2230
+ schema: oAuthTokenResponseResponse,
2062
2231
  contentType: "json" /* Json */,
2063
2232
  status: 200
2064
- }).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();
2065
- return this.client.call(request);
2233
+ }).addHeaderParam({ key: "Content-Type", value: "application/x-www-form-urlencoded" }).addBody(body).build();
2234
+ return this.client.callDirect(request);
2066
2235
  }
2067
2236
  };
2068
2237
 
@@ -2109,7 +2278,7 @@ var OAuthTokenManager = class {
2109
2278
  * @throws Error if client credentials are missing or token request fails
2110
2279
  */
2111
2280
  async getToken(scopes, config) {
2112
- var _a, _b, _c, _d, _e, _f;
2281
+ var _a, _b, _c;
2113
2282
  if (((_a = this.token) == null ? void 0 : _a.hasAllScopes(scopes)) && ((_b = this.token) == null ? void 0 : _b.expiresAt) && this.token.expiresAt - Date.now() > 5e3) {
2114
2283
  return this.token;
2115
2284
  }
@@ -2124,23 +2293,21 @@ var OAuthTokenManager = class {
2124
2293
  },
2125
2294
  this
2126
2295
  );
2127
- const response = await oAuth.getAccessToken(
2128
- {
2129
- grantType: "client_credentials",
2130
- clientId: config.clientId,
2131
- clientSecret: config.clientSecret
2132
- },
2133
- {}
2134
- );
2135
- if (!((_d = response.data) == null ? void 0 : _d.accessToken)) {
2296
+ const response = await oAuth.getAccessToken({
2297
+ grantType: "client_credentials",
2298
+ clientId: config.clientId,
2299
+ clientSecret: config.clientSecret,
2300
+ scope: Array.from(scopes).join(" ")
2301
+ });
2302
+ if (!(response == null ? void 0 : response.accessToken)) {
2136
2303
  throw new Error(
2137
2304
  `OAuthError: token endpoint response did not return access token. Response: ${JSON.stringify(response), void 0, 2}.`
2138
2305
  );
2139
2306
  }
2140
2307
  this.token = new OAuthToken(
2141
- response.data.accessToken,
2308
+ response.accessToken,
2142
2309
  updatedScopes,
2143
- ((_e = response.data) == null ? void 0 : _e.expiresIn) ? ((_f = response.data) == null ? void 0 : _f.expiresIn) * 1e3 + Date.now() : null
2310
+ (response == null ? void 0 : response.expiresIn) ? (response == null ? void 0 : response.expiresIn) * 1e3 + Date.now() : null
2144
2311
  );
2145
2312
  return this.token;
2146
2313
  }
@@ -2252,7 +2419,9 @@ var BadRequest = class extends ThrowableError {
2252
2419
  this.message = parsedResponse.message || "";
2253
2420
  }
2254
2421
  throw() {
2255
- throw new BadRequest(this.message, this.response);
2422
+ const error = new BadRequest(this.message, this.response);
2423
+ error.metadata = this.metadata;
2424
+ throw error;
2256
2425
  }
2257
2426
  };
2258
2427
 
@@ -2274,19 +2443,31 @@ var Unauthorized = class extends ThrowableError {
2274
2443
  this.message = parsedResponse.message || "";
2275
2444
  }
2276
2445
  throw() {
2277
- throw new Unauthorized(this.message, this.response);
2446
+ const error = new Unauthorized(this.message, this.response);
2447
+ error.metadata = this.metadata;
2448
+ throw error;
2278
2449
  }
2279
2450
  };
2280
2451
 
2281
2452
  // src/services/destinations/destinations-service.ts
2282
2453
  var DestinationsService = class extends BaseService {
2454
+ /**
2455
+ * Sets method-level configuration for listDestinations.
2456
+ * @param config - Partial configuration to override service-level defaults
2457
+ * @returns This service instance for method chaining
2458
+ */
2459
+ setListDestinationsConfig(config) {
2460
+ this.listDestinationsConfig = config;
2461
+ return this;
2462
+ }
2283
2463
  /**
2284
2464
  * List Destinations
2285
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
2465
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
2286
2466
  * @returns {Promise<HttpResponse<ListDestinationsOkResponse>>} - Successful Response
2287
2467
  */
2288
2468
  async listDestinations(requestConfig) {
2289
- 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(z8.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
2469
+ const resolvedConfig = this.getResolvedConfig(this.listDestinationsConfig, requestConfig);
2470
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/destinations").setRequestSchema(z8.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
2290
2471
  schema: listDestinationsOkResponseResponse,
2291
2472
  contentType: "json" /* Json */,
2292
2473
  status: 200
@@ -2298,8 +2479,8 @@ var DestinationsService = class extends BaseService {
2298
2479
  error: Unauthorized,
2299
2480
  contentType: "json" /* Json */,
2300
2481
  status: 401
2301
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).build();
2302
- return this.client.call(request);
2482
+ }).build();
2483
+ return this.client.callDirect(request);
2303
2484
  }
2304
2485
  };
2305
2486
 
@@ -2394,6 +2575,15 @@ var listPackagesOkResponseRequest = z10.lazy(() => {
2394
2575
 
2395
2576
  // src/services/packages/packages-service.ts
2396
2577
  var PackagesService = class extends BaseService {
2578
+ /**
2579
+ * Sets method-level configuration for listPackages.
2580
+ * @param config - Partial configuration to override service-level defaults
2581
+ * @returns This service instance for method chaining
2582
+ */
2583
+ setListPackagesConfig(config) {
2584
+ this.listPackagesConfig = config;
2585
+ return this;
2586
+ }
2397
2587
  /**
2398
2588
  * List Packages
2399
2589
  * @param {string} [params.destination] - ISO representation of the package's destination. Supports both ISO2 (e.g., 'FR') and ISO3 (e.g., 'FRA') country codes.
@@ -2403,11 +2593,21 @@ var PackagesService = class extends BaseService {
2403
2593
  * @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
2404
2594
  * @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
2405
2595
  * @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
2406
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
2596
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
2407
2597
  * @returns {Promise<HttpResponse<ListPackagesOkResponse>>} - Successful Response
2408
2598
  */
2409
2599
  async listPackages(params, requestConfig) {
2410
- 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(z11.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
2600
+ const resolvedConfig = this.getResolvedConfig(this.listPackagesConfig, requestConfig);
2601
+ z11.object({
2602
+ destination: z11.string().optional(),
2603
+ startDate: z11.string().optional(),
2604
+ endDate: z11.string().optional(),
2605
+ afterCursor: z11.string().optional(),
2606
+ limit: z11.number().optional(),
2607
+ startTime: z11.number().optional(),
2608
+ endTime: z11.number().optional()
2609
+ }).parse(params != null ? params : {});
2610
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/packages").setRequestSchema(z11.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
2411
2611
  schema: listPackagesOkResponseResponse,
2412
2612
  contentType: "json" /* Json */,
2413
2613
  status: 200
@@ -2419,7 +2619,7 @@ var PackagesService = class extends BaseService {
2419
2619
  error: Unauthorized,
2420
2620
  contentType: "json" /* Json */,
2421
2621
  status: 401
2422
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
2622
+ }).addQueryParam({
2423
2623
  key: "destination",
2424
2624
  value: params == null ? void 0 : params.destination
2425
2625
  }).addQueryParam({
@@ -2441,7 +2641,7 @@ var PackagesService = class extends BaseService {
2441
2641
  key: "endTime",
2442
2642
  value: params == null ? void 0 : params.endTime
2443
2643
  }).build();
2444
- return this.client.call(request);
2644
+ return this.client.callDirect(request);
2445
2645
  }
2446
2646
  };
2447
2647
 
@@ -3283,13 +3483,68 @@ var getPurchaseConsumptionOkResponseRequest = z30.lazy(() => {
3283
3483
 
3284
3484
  // src/services/purchases/purchases-service.ts
3285
3485
  var PurchasesService = class extends BaseService {
3486
+ /**
3487
+ * Sets method-level configuration for createPurchaseV2.
3488
+ * @param config - Partial configuration to override service-level defaults
3489
+ * @returns This service instance for method chaining
3490
+ */
3491
+ setCreatePurchaseV2Config(config) {
3492
+ this.createPurchaseV2Config = config;
3493
+ return this;
3494
+ }
3495
+ /**
3496
+ * Sets method-level configuration for listPurchases.
3497
+ * @param config - Partial configuration to override service-level defaults
3498
+ * @returns This service instance for method chaining
3499
+ */
3500
+ setListPurchasesConfig(config) {
3501
+ this.listPurchasesConfig = config;
3502
+ return this;
3503
+ }
3504
+ /**
3505
+ * Sets method-level configuration for createPurchase.
3506
+ * @param config - Partial configuration to override service-level defaults
3507
+ * @returns This service instance for method chaining
3508
+ */
3509
+ setCreatePurchaseConfig(config) {
3510
+ this.createPurchaseConfig = config;
3511
+ return this;
3512
+ }
3513
+ /**
3514
+ * Sets method-level configuration for topUpEsim.
3515
+ * @param config - Partial configuration to override service-level defaults
3516
+ * @returns This service instance for method chaining
3517
+ */
3518
+ setTopUpEsimConfig(config) {
3519
+ this.topUpEsimConfig = config;
3520
+ return this;
3521
+ }
3522
+ /**
3523
+ * Sets method-level configuration for editPurchase.
3524
+ * @param config - Partial configuration to override service-level defaults
3525
+ * @returns This service instance for method chaining
3526
+ */
3527
+ setEditPurchaseConfig(config) {
3528
+ this.editPurchaseConfig = config;
3529
+ return this;
3530
+ }
3531
+ /**
3532
+ * Sets method-level configuration for getPurchaseConsumption.
3533
+ * @param config - Partial configuration to override service-level defaults
3534
+ * @returns This service instance for method chaining
3535
+ */
3536
+ setGetPurchaseConsumptionConfig(config) {
3537
+ this.getPurchaseConsumptionConfig = config;
3538
+ return this;
3539
+ }
3286
3540
  /**
3287
3541
  * This endpoint is used to purchase a new eSIM by providing the package details.
3288
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3542
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3289
3543
  * @returns {Promise<HttpResponse<CreatePurchaseV2OkResponse[]>>} - Successful Response
3290
3544
  */
3291
3545
  async createPurchaseV2(body, requestConfig) {
3292
- 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({
3546
+ const resolvedConfig = this.getResolvedConfig(this.createPurchaseV2Config, requestConfig);
3547
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/v2").setRequestSchema(createPurchaseV2RequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3293
3548
  schema: z31.array(createPurchaseV2OkResponseResponse),
3294
3549
  contentType: "json" /* Json */,
3295
3550
  status: 200
@@ -3301,8 +3556,8 @@ var PurchasesService = class extends BaseService {
3301
3556
  error: Unauthorized,
3302
3557
  contentType: "json" /* Json */,
3303
3558
  status: 401
3304
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3305
- return this.client.call(request);
3559
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3560
+ return this.client.callDirect(request);
3306
3561
  }
3307
3562
  /**
3308
3563
  * This endpoint can be used to list all the successful purchases made between a given interval.
@@ -3316,11 +3571,24 @@ var PurchasesService = class extends BaseService {
3316
3571
  * @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
3317
3572
  * @param {number} [params.after] - Epoch value representing the start of the time interval for filtering purchases
3318
3573
  * @param {number} [params.before] - Epoch value representing the end of the time interval for filtering purchases
3319
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3574
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3320
3575
  * @returns {Promise<HttpResponse<ListPurchasesOkResponse>>} - Successful Response
3321
3576
  */
3322
3577
  async listPurchases(params, requestConfig) {
3323
- 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(z31.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3578
+ const resolvedConfig = this.getResolvedConfig(this.listPurchasesConfig, requestConfig);
3579
+ z31.object({
3580
+ purchaseId: z31.string().optional(),
3581
+ iccid: z31.string().optional(),
3582
+ afterDate: z31.string().optional(),
3583
+ beforeDate: z31.string().optional(),
3584
+ email: z31.string().optional(),
3585
+ referenceId: z31.string().optional(),
3586
+ afterCursor: z31.string().optional(),
3587
+ limit: z31.number().optional(),
3588
+ after: z31.number().optional(),
3589
+ before: z31.number().optional()
3590
+ }).parse(params != null ? params : {});
3591
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/purchases").setRequestSchema(z31.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3324
3592
  schema: listPurchasesOkResponseResponse,
3325
3593
  contentType: "json" /* Json */,
3326
3594
  status: 200
@@ -3332,7 +3600,7 @@ var PurchasesService = class extends BaseService {
3332
3600
  error: Unauthorized,
3333
3601
  contentType: "json" /* Json */,
3334
3602
  status: 401
3335
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
3603
+ }).addQueryParam({
3336
3604
  key: "purchaseId",
3337
3605
  value: params == null ? void 0 : params.purchaseId
3338
3606
  }).addQueryParam({
@@ -3363,15 +3631,16 @@ var PurchasesService = class extends BaseService {
3363
3631
  key: "before",
3364
3632
  value: params == null ? void 0 : params.before
3365
3633
  }).build();
3366
- return this.client.call(request);
3634
+ return this.client.callDirect(request);
3367
3635
  }
3368
3636
  /**
3369
3637
  * This endpoint is used to purchase a new eSIM by providing the package details.
3370
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3638
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3371
3639
  * @returns {Promise<HttpResponse<CreatePurchaseOkResponse>>} - Successful Response
3372
3640
  */
3373
3641
  async createPurchase(body, requestConfig) {
3374
- 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({
3642
+ const resolvedConfig = this.getResolvedConfig(this.createPurchaseConfig, requestConfig);
3643
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases").setRequestSchema(createPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3375
3644
  schema: createPurchaseOkResponseResponse,
3376
3645
  contentType: "json" /* Json */,
3377
3646
  status: 200
@@ -3383,16 +3652,17 @@ var PurchasesService = class extends BaseService {
3383
3652
  error: Unauthorized,
3384
3653
  contentType: "json" /* Json */,
3385
3654
  status: 401
3386
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3387
- return this.client.call(request);
3655
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3656
+ return this.client.callDirect(request);
3388
3657
  }
3389
3658
  /**
3390
3659
  * 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.
3391
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3660
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3392
3661
  * @returns {Promise<HttpResponse<TopUpEsimOkResponse>>} - Successful Response
3393
3662
  */
3394
3663
  async topUpEsim(body, requestConfig) {
3395
- 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({
3664
+ const resolvedConfig = this.getResolvedConfig(this.topUpEsimConfig, requestConfig);
3665
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/topup").setRequestSchema(topUpEsimRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3396
3666
  schema: topUpEsimOkResponseResponse,
3397
3667
  contentType: "json" /* Json */,
3398
3668
  status: 200
@@ -3404,8 +3674,8 @@ var PurchasesService = class extends BaseService {
3404
3674
  error: Unauthorized,
3405
3675
  contentType: "json" /* Json */,
3406
3676
  status: 401
3407
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3408
- return this.client.call(request);
3677
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3678
+ return this.client.callDirect(request);
3409
3679
  }
3410
3680
  /**
3411
3681
  * This endpoint allows you to modify the validity dates of an existing purchase.
@@ -3416,11 +3686,12 @@ var PurchasesService = class extends BaseService {
3416
3686
 
3417
3687
  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.
3418
3688
 
3419
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3689
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3420
3690
  * @returns {Promise<HttpResponse<EditPurchaseOkResponse>>} - Successful Response
3421
3691
  */
3422
3692
  async editPurchase(body, requestConfig) {
3423
- 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({
3693
+ const resolvedConfig = this.getResolvedConfig(this.editPurchaseConfig, requestConfig);
3694
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/purchases/edit").setRequestSchema(editPurchaseRequestRequest).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3424
3695
  schema: editPurchaseOkResponseResponse,
3425
3696
  contentType: "json" /* Json */,
3426
3697
  status: 200
@@ -3432,17 +3703,18 @@ var PurchasesService = class extends BaseService {
3432
3703
  error: Unauthorized,
3433
3704
  contentType: "json" /* Json */,
3434
3705
  status: 401
3435
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3436
- return this.client.call(request);
3706
+ }).addHeaderParam({ key: "Content-Type", value: "application/json" }).addBody(body).build();
3707
+ return this.client.callDirect(request);
3437
3708
  }
3438
3709
  /**
3439
3710
  * 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.
3440
3711
  * @param {string} purchaseId - ID of the purchase
3441
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
3712
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3442
3713
  * @returns {Promise<HttpResponse<GetPurchaseConsumptionOkResponse>>} - Successful Response
3443
3714
  */
3444
3715
  async getPurchaseConsumption(purchaseId, requestConfig) {
3445
- 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(z31.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3716
+ const resolvedConfig = this.getResolvedConfig(this.getPurchaseConsumptionConfig, requestConfig);
3717
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/purchases/{purchaseId}/consumption").setRequestSchema(z31.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3446
3718
  schema: getPurchaseConsumptionOkResponseResponse,
3447
3719
  contentType: "json" /* Json */,
3448
3720
  status: 200
@@ -3454,11 +3726,11 @@ var PurchasesService = class extends BaseService {
3454
3726
  error: Unauthorized,
3455
3727
  contentType: "json" /* Json */,
3456
3728
  status: 401
3457
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addPathParam({
3729
+ }).addPathParam({
3458
3730
  key: "purchaseId",
3459
3731
  value: purchaseId
3460
3732
  }).build();
3461
- return this.client.call(request);
3733
+ return this.client.callDirect(request);
3462
3734
  }
3463
3735
  };
3464
3736
 
@@ -3709,14 +3981,43 @@ var getEsimHistoryOkResponseRequest = z38.lazy(() => {
3709
3981
 
3710
3982
  // src/services/e-sim/e-sim-service.ts
3711
3983
  var ESimService = class extends BaseService {
3984
+ /**
3985
+ * Sets method-level configuration for getEsim.
3986
+ * @param config - Partial configuration to override service-level defaults
3987
+ * @returns This service instance for method chaining
3988
+ */
3989
+ setGetEsimConfig(config) {
3990
+ this.getEsimConfig = config;
3991
+ return this;
3992
+ }
3993
+ /**
3994
+ * Sets method-level configuration for getEsimDevice.
3995
+ * @param config - Partial configuration to override service-level defaults
3996
+ * @returns This service instance for method chaining
3997
+ */
3998
+ setGetEsimDeviceConfig(config) {
3999
+ this.getEsimDeviceConfig = config;
4000
+ return this;
4001
+ }
4002
+ /**
4003
+ * Sets method-level configuration for getEsimHistory.
4004
+ * @param config - Partial configuration to override service-level defaults
4005
+ * @returns This service instance for method chaining
4006
+ */
4007
+ setGetEsimHistoryConfig(config) {
4008
+ this.getEsimHistoryConfig = config;
4009
+ return this;
4010
+ }
3712
4011
  /**
3713
4012
  * Get eSIM
3714
4013
  * @param {string} params.iccid - ID of the eSIM
3715
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4014
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3716
4015
  * @returns {Promise<HttpResponse<GetEsimOkResponse>>} - Successful Response
3717
4016
  */
3718
4017
  async getEsim(params, requestConfig) {
3719
- 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(z39.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4018
+ const resolvedConfig = this.getResolvedConfig(this.getEsimConfig, requestConfig);
4019
+ z39.object({ iccid: z39.string() }).parse(params != null ? params : {});
4020
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/esim").setRequestSchema(z39.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3720
4021
  schema: getEsimOkResponseResponse,
3721
4022
  contentType: "json" /* Json */,
3722
4023
  status: 200
@@ -3728,20 +4029,21 @@ var ESimService = class extends BaseService {
3728
4029
  error: Unauthorized,
3729
4030
  contentType: "json" /* Json */,
3730
4031
  status: 401
3731
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addQueryParam({
4032
+ }).addQueryParam({
3732
4033
  key: "iccid",
3733
4034
  value: params == null ? void 0 : params.iccid
3734
4035
  }).build();
3735
- return this.client.call(request);
4036
+ return this.client.callDirect(request);
3736
4037
  }
3737
4038
  /**
3738
4039
  * Get eSIM Device
3739
4040
  * @param {string} iccid - ID of the eSIM
3740
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4041
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3741
4042
  * @returns {Promise<HttpResponse<GetEsimDeviceOkResponse>>} - Successful Response
3742
4043
  */
3743
4044
  async getEsimDevice(iccid, requestConfig) {
3744
- 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(z39.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4045
+ const resolvedConfig = this.getResolvedConfig(this.getEsimDeviceConfig, requestConfig);
4046
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/esim/{iccid}/device").setRequestSchema(z39.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3745
4047
  schema: getEsimDeviceOkResponseResponse,
3746
4048
  contentType: "json" /* Json */,
3747
4049
  status: 200
@@ -3753,20 +4055,21 @@ var ESimService = class extends BaseService {
3753
4055
  error: Unauthorized,
3754
4056
  contentType: "json" /* Json */,
3755
4057
  status: 401
3756
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addPathParam({
4058
+ }).addPathParam({
3757
4059
  key: "iccid",
3758
4060
  value: iccid
3759
4061
  }).build();
3760
- return this.client.call(request);
4062
+ return this.client.callDirect(request);
3761
4063
  }
3762
4064
  /**
3763
4065
  * Get eSIM History
3764
4066
  * @param {string} iccid - ID of the eSIM
3765
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4067
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3766
4068
  * @returns {Promise<HttpResponse<GetEsimHistoryOkResponse>>} - Successful Response
3767
4069
  */
3768
4070
  async getEsimHistory(iccid, requestConfig) {
3769
- 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(z39.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4071
+ const resolvedConfig = this.getResolvedConfig(this.getEsimHistoryConfig, requestConfig);
4072
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("GET").setPath("/esim/{iccid}/history").setRequestSchema(z39.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3770
4073
  schema: getEsimHistoryOkResponseResponse,
3771
4074
  contentType: "json" /* Json */,
3772
4075
  status: 200
@@ -3778,11 +4081,11 @@ var ESimService = class extends BaseService {
3778
4081
  error: Unauthorized,
3779
4082
  contentType: "json" /* Json */,
3780
4083
  status: 401
3781
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).addPathParam({
4084
+ }).addPathParam({
3782
4085
  key: "iccid",
3783
4086
  value: iccid
3784
4087
  }).build();
3785
- return this.client.call(request);
4088
+ return this.client.callDirect(request);
3786
4089
  }
3787
4090
  };
3788
4091
 
@@ -3813,13 +4116,23 @@ var tokenOkResponseRequest = z40.lazy(() => {
3813
4116
 
3814
4117
  // src/services/i-frame/i-frame-service.ts
3815
4118
  var IFrameService = class extends BaseService {
4119
+ /**
4120
+ * Sets method-level configuration for token.
4121
+ * @param config - Partial configuration to override service-level defaults
4122
+ * @returns This service instance for method chaining
4123
+ */
4124
+ setTokenConfig(config) {
4125
+ this.tokenConfig = config;
4126
+ return this;
4127
+ }
3816
4128
  /**
3817
4129
  * Generate a new token to be used in the iFrame
3818
- * @param {RequestConfig} [requestConfig] - The request configuration for retry and validation.
4130
+ * @param {Partial<SdkConfig>} [requestConfig] - The request configuration for retry and validation.
3819
4131
  * @returns {Promise<HttpResponse<TokenOkResponse>>} - Successful Response
3820
4132
  */
3821
4133
  async token(requestConfig) {
3822
- 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(z41.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
4134
+ const resolvedConfig = this.getResolvedConfig(this.tokenConfig, requestConfig);
4135
+ const request = new RequestBuilder().setConfig(resolvedConfig).setBaseUrl(resolvedConfig).setMethod("POST").setPath("/iframe/token").setRequestSchema(z41.any()).setScopes([]).setTokenManager(this.tokenManager).setRequestContentType("json" /* Json */).addResponse({
3823
4136
  schema: tokenOkResponseResponse,
3824
4137
  contentType: "json" /* Json */,
3825
4138
  status: 200
@@ -3831,8 +4144,8 @@ var IFrameService = class extends BaseService {
3831
4144
  error: Unauthorized,
3832
4145
  contentType: "json" /* Json */,
3833
4146
  status: 401
3834
- }).setRetryAttempts(this.config, requestConfig).setRetryDelayMs(this.config, requestConfig).setResponseValidation(this.config, requestConfig).build();
3835
- return this.client.call(request);
4147
+ }).build();
4148
+ return this.client.callDirect(request);
3836
4149
  }
3837
4150
  };
3838
4151