@oapiex/sdk-kit 0.1.6 → 0.1.9

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
@@ -2,6 +2,8 @@ import { i as __toESM, r as __require, t as __commonJS } from "./chunk-BLWcukCW.
2
2
  import "dotenv/config";
3
3
  import axios from "axios";
4
4
  import path from "path";
5
+ import { createJiti } from "jiti";
6
+ import path$1 from "node:path";
5
7
  import crypto from "crypto";
6
8
  import process$1 from "node:process";
7
9
  import os from "node:os";
@@ -72,39 +74,96 @@ const buildUrl = (baseUrl, ...endpoint) => {
72
74
 
73
75
  //#endregion
74
76
  //#region src/utilities/Manager.ts
77
+ const CONFIG_BASENAMES = [
78
+ "oapiex.config.ts",
79
+ "oapiex.config.js",
80
+ "oapiex.config.cjs"
81
+ ];
75
82
  const defaultConfig = {
76
83
  environment: "sandbox",
77
84
  urls: {
78
85
  live: "",
79
86
  sandbox: ""
80
87
  },
81
- headers: {}
88
+ headers: {},
89
+ debugLevel: 0
90
+ };
91
+ const createBaseConfig = () => ({
92
+ ...defaultConfig,
93
+ urls: { ...defaultConfig.urls ?? {} },
94
+ headers: { ...defaultConfig.headers ?? {} }
95
+ });
96
+ let globalConfig = createBaseConfig();
97
+ let loadedConfigRoot = null;
98
+ const mergeConfig = (baseConfig, config) => ({
99
+ ...baseConfig,
100
+ ...config,
101
+ urls: config.urls ? {
102
+ ...baseConfig.urls ?? defaultConfig.urls,
103
+ ...config.urls
104
+ } : baseConfig.urls,
105
+ headers: config.headers ? {
106
+ ...baseConfig.headers ?? defaultConfig.headers,
107
+ ...config.headers
108
+ } : baseConfig.headers
109
+ });
110
+ const pickInitOptions = (value) => {
111
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return null;
112
+ const config = value;
113
+ const scoped = config.sdkKit ?? config.sdk;
114
+ if (scoped && typeof scoped === "object" && !Array.isArray(scoped)) return pickInitOptions(scoped);
115
+ const nextConfig = [
116
+ "clientId",
117
+ "clientSecret",
118
+ "encryptionKey",
119
+ "environment",
120
+ "urls",
121
+ "headers",
122
+ "timeout",
123
+ "auth",
124
+ "debugLevel"
125
+ ].reduce((result, key) => {
126
+ if (config[key] !== void 0) result[key] = config[key];
127
+ return result;
128
+ }, {});
129
+ return Object.keys(nextConfig).length > 0 ? nextConfig : null;
130
+ };
131
+ const loadUserConfig = (rootDir = process.cwd()) => {
132
+ const syncLoad = createJiti(import.meta.url, {
133
+ interopDefault: true,
134
+ moduleCache: false,
135
+ fsCache: false
136
+ });
137
+ for (const basename of CONFIG_BASENAMES) {
138
+ const configPath = path$1.join(rootDir, basename);
139
+ try {
140
+ const loaded = syncLoad(configPath);
141
+ const loadedModule = typeof loaded === "object" && loaded !== null ? loaded : null;
142
+ const sdkConfig = pickInitOptions(loadedModule?.default ?? loadedModule?.config ?? loaded);
143
+ if (sdkConfig) return sdkConfig;
144
+ } catch {
145
+ continue;
146
+ }
147
+ }
148
+ return null;
149
+ };
150
+ const ensureConfigLoaded = (rootDir = process.cwd()) => {
151
+ if (loadedConfigRoot === rootDir) return globalConfig;
152
+ globalConfig = createBaseConfig();
153
+ loadedConfigRoot = rootDir;
154
+ const userConfig = loadUserConfig(rootDir);
155
+ if (userConfig) globalConfig = mergeConfig(globalConfig, userConfig);
156
+ return globalConfig;
82
157
  };
83
- let globalConfig = defaultConfig;
84
158
  const defineConfig = (config) => {
85
- const baseConfig = globalConfig ?? defaultConfig;
86
- const userConfig = {
87
- ...baseConfig,
88
- ...config,
89
- urls: config.urls ? {
90
- ...baseConfig.urls ?? defaultConfig.urls,
91
- ...config.urls
92
- } : baseConfig.urls,
93
- headers: config.headers ? {
94
- ...baseConfig.headers ?? defaultConfig.headers,
95
- ...config.headers
96
- } : baseConfig.headers
97
- };
159
+ const userConfig = mergeConfig(ensureConfigLoaded(), config);
98
160
  globalConfig = userConfig;
99
161
  return userConfig;
100
162
  };
101
- const getConfig = () => globalConfig;
163
+ const getConfig = () => ensureConfigLoaded();
102
164
  const resetConfig = () => {
103
- globalConfig = {
104
- ...defaultConfig,
105
- urls: { ...defaultConfig.urls ?? {} },
106
- headers: { ...defaultConfig.headers ?? {} }
107
- };
165
+ loadedConfigRoot = null;
166
+ globalConfig = createBaseConfig();
108
167
  return globalConfig;
109
168
  };
110
169
 
@@ -197,8 +256,8 @@ var Builder = class {
197
256
  * @param queryParams
198
257
  * @returns
199
258
  */
200
- static buildTargetUrl(path$9, params = {}, queryParams = {}) {
201
- const url = this.buildUrl(path$9);
259
+ static buildTargetUrl(path$10, params = {}, queryParams = {}) {
260
+ const url = this.buildUrl(path$10);
202
261
  let builtUrl = this.assignParamsToUrl(url, params, "path");
203
262
  builtUrl = this.assignParamsToUrl(builtUrl, queryParams, "query");
204
263
  return builtUrl;
@@ -2347,15 +2406,15 @@ var require_route = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/color
2347
2406
  };
2348
2407
  }
2349
2408
  function wrapConversion(toModel, graph) {
2350
- const path$9 = [graph[toModel].parent, toModel];
2409
+ const path$10 = [graph[toModel].parent, toModel];
2351
2410
  let fn$1 = conversions$1[graph[toModel].parent][toModel];
2352
2411
  let cur = graph[toModel].parent;
2353
2412
  while (graph[cur].parent) {
2354
- path$9.unshift(graph[cur].parent);
2413
+ path$10.unshift(graph[cur].parent);
2355
2414
  fn$1 = link(conversions$1[graph[cur].parent][cur], fn$1);
2356
2415
  cur = graph[cur].parent;
2357
2416
  }
2358
- fn$1.conversion = path$9;
2417
+ fn$1.conversion = path$10;
2359
2418
  return fn$1;
2360
2419
  }
2361
2420
  module.exports = function(fromModel) {
@@ -5987,7 +6046,7 @@ var require_p_locate = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/p-
5987
6046
  //#endregion
5988
6047
  //#region ../../node_modules/.pnpm/locate-path@5.0.0/node_modules/locate-path/index.js
5989
6048
  var require_locate_path = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/locate-path@5.0.0/node_modules/locate-path/index.js": ((exports, module) => {
5990
- const path$8 = __require("path");
6049
+ const path$9 = __require("path");
5991
6050
  const fs$5 = __require("fs");
5992
6051
  const { promisify: promisify$1 } = __require("util");
5993
6052
  const pLocate = require_p_locate();
@@ -6013,7 +6072,7 @@ var require_locate_path = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
6013
6072
  const statFn = options.allowSymlinks ? fsStat : fsLStat;
6014
6073
  return pLocate(paths, async (path_) => {
6015
6074
  try {
6016
- const stat = await statFn(path$8.resolve(options.cwd, path_));
6075
+ const stat = await statFn(path$9.resolve(options.cwd, path_));
6017
6076
  return matchType(options.type, stat);
6018
6077
  } catch (_) {
6019
6078
  return false;
@@ -6030,7 +6089,7 @@ var require_locate_path = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
6030
6089
  checkType(options);
6031
6090
  const statFn = options.allowSymlinks ? fs$5.statSync : fs$5.lstatSync;
6032
6091
  for (const path_ of paths) try {
6033
- const stat = statFn(path$8.resolve(options.cwd, path_));
6092
+ const stat = statFn(path$9.resolve(options.cwd, path_));
6034
6093
  if (matchType(options.type, stat)) return path_;
6035
6094
  } catch (_) {}
6036
6095
  };
@@ -6042,17 +6101,17 @@ var require_path_exists = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
6042
6101
  const fs$4 = __require("fs");
6043
6102
  const { promisify } = __require("util");
6044
6103
  const pAccess = promisify(fs$4.access);
6045
- module.exports = async (path$9) => {
6104
+ module.exports = async (path$10) => {
6046
6105
  try {
6047
- await pAccess(path$9);
6106
+ await pAccess(path$10);
6048
6107
  return true;
6049
6108
  } catch (_) {
6050
6109
  return false;
6051
6110
  }
6052
6111
  };
6053
- module.exports.sync = (path$9) => {
6112
+ module.exports.sync = (path$10) => {
6054
6113
  try {
6055
- fs$4.accessSync(path$9);
6114
+ fs$4.accessSync(path$10);
6056
6115
  return true;
6057
6116
  } catch (_) {
6058
6117
  return false;
@@ -6063,13 +6122,13 @@ var require_path_exists = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
6063
6122
  //#endregion
6064
6123
  //#region ../../node_modules/.pnpm/find-up@4.1.0/node_modules/find-up/index.js
6065
6124
  var require_find_up = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/find-up@4.1.0/node_modules/find-up/index.js": ((exports, module) => {
6066
- const path$7 = __require("path");
6125
+ const path$8 = __require("path");
6067
6126
  const locatePath = require_locate_path();
6068
6127
  const pathExists = require_path_exists();
6069
6128
  const stop = Symbol("findUp.stop");
6070
6129
  module.exports = async (name, options = {}) => {
6071
- let directory = path$7.resolve(options.cwd || "");
6072
- const { root } = path$7.parse(directory);
6130
+ let directory = path$8.resolve(options.cwd || "");
6131
+ const { root } = path$8.parse(directory);
6073
6132
  const paths = [].concat(name);
6074
6133
  const runMatcher = async (locateOptions) => {
6075
6134
  if (typeof name !== "function") return locatePath(paths, locateOptions);
@@ -6083,14 +6142,14 @@ var require_find_up = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fin
6083
6142
  cwd: directory
6084
6143
  });
6085
6144
  if (foundPath === stop) return;
6086
- if (foundPath) return path$7.resolve(directory, foundPath);
6145
+ if (foundPath) return path$8.resolve(directory, foundPath);
6087
6146
  if (directory === root) return;
6088
- directory = path$7.dirname(directory);
6147
+ directory = path$8.dirname(directory);
6089
6148
  }
6090
6149
  };
6091
6150
  module.exports.sync = (name, options = {}) => {
6092
- let directory = path$7.resolve(options.cwd || "");
6093
- const { root } = path$7.parse(directory);
6151
+ let directory = path$8.resolve(options.cwd || "");
6152
+ const { root } = path$8.parse(directory);
6094
6153
  const paths = [].concat(name);
6095
6154
  const runMatcher = (locateOptions) => {
6096
6155
  if (typeof name !== "function") return locatePath.sync(paths, locateOptions);
@@ -6104,9 +6163,9 @@ var require_find_up = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fin
6104
6163
  cwd: directory
6105
6164
  });
6106
6165
  if (foundPath === stop) return;
6107
- if (foundPath) return path$7.resolve(directory, foundPath);
6166
+ if (foundPath) return path$8.resolve(directory, foundPath);
6108
6167
  if (directory === root) return;
6109
- directory = path$7.dirname(directory);
6168
+ directory = path$8.dirname(directory);
6110
6169
  }
6111
6170
  };
6112
6171
  module.exports.exists = pathExists;
@@ -6117,17 +6176,17 @@ var require_find_up = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/fin
6117
6176
  //#endregion
6118
6177
  //#region ../../node_modules/.pnpm/pkg-dir@4.2.0/node_modules/pkg-dir/index.js
6119
6178
  var require_pkg_dir = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/pkg-dir@4.2.0/node_modules/pkg-dir/index.js": ((exports, module) => {
6120
- const path$6 = __require("path");
6179
+ const path$7 = __require("path");
6121
6180
  const findUp = require_find_up();
6122
6181
  const pkgDir = async (cwd$1) => {
6123
6182
  const filePath = await findUp("package.json", { cwd: cwd$1 });
6124
- return filePath && path$6.dirname(filePath);
6183
+ return filePath && path$7.dirname(filePath);
6125
6184
  };
6126
6185
  module.exports = pkgDir;
6127
6186
  module.exports.default = pkgDir;
6128
6187
  module.exports.sync = (cwd$1) => {
6129
6188
  const filePath = findUp.sync("package.json", { cwd: cwd$1 });
6130
- return filePath && path$6.dirname(filePath);
6189
+ return filePath && path$7.dirname(filePath);
6131
6190
  };
6132
6191
  }) });
6133
6192
 
@@ -7201,7 +7260,7 @@ var require_braces = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/brac
7201
7260
  //#endregion
7202
7261
  //#region ../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js
7203
7262
  var require_constants = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js": ((exports, module) => {
7204
- const path$5 = __require("path");
7263
+ const path$6 = __require("path");
7205
7264
  const WIN_SLASH = "\\\\/";
7206
7265
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
7207
7266
  const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
@@ -7330,7 +7389,7 @@ var require_constants = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/p
7330
7389
  CHAR_UNDERSCORE: 95,
7331
7390
  CHAR_VERTICAL_LINE: 124,
7332
7391
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
7333
- SEP: path$5.sep,
7392
+ SEP: path$6.sep,
7334
7393
  extglobChars(chars) {
7335
7394
  return {
7336
7395
  "!": {
@@ -7369,7 +7428,7 @@ var require_constants = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/p
7369
7428
  //#endregion
7370
7429
  //#region ../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js
7371
7430
  var require_utils = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js": ((exports) => {
7372
- const path$4 = __require("path");
7431
+ const path$5 = __require("path");
7373
7432
  const win32 = process.platform === "win32";
7374
7433
  const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
7375
7434
  exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
@@ -7389,7 +7448,7 @@ var require_utils = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/picom
7389
7448
  };
7390
7449
  exports.isWindows = (options) => {
7391
7450
  if (options && typeof options.windows === "boolean") return options.windows;
7392
- return win32 === true || path$4.sep === "\\";
7451
+ return win32 === true || path$5.sep === "\\";
7393
7452
  };
7394
7453
  exports.escapeLast = (input, char, lastIdx) => {
7395
7454
  const idx = input.lastIndexOf(char, lastIdx);
@@ -8762,7 +8821,7 @@ var require_parse = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/picom
8762
8821
  //#endregion
8763
8822
  //#region ../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js
8764
8823
  var require_picomatch$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js": ((exports, module) => {
8765
- const path$3 = __require("path");
8824
+ const path$4 = __require("path");
8766
8825
  const scan = require_scan();
8767
8826
  const parse$1 = require_parse();
8768
8827
  const utils$1 = require_utils();
@@ -8901,7 +8960,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
8901
8960
  * @api public
8902
8961
  */
8903
8962
  picomatch$1.matchBase = (input, glob, options, posix = utils$1.isWindows(options)) => {
8904
- return (glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options)).test(path$3.basename(input));
8963
+ return (glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options)).test(path$4.basename(input));
8905
8964
  };
8906
8965
  /**
8907
8966
  * Returns true if **any** of the given glob `patterns` match the specified `string`.
@@ -9582,13 +9641,13 @@ var require_polyfills = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/g
9582
9641
  fs$6.fstatSync = statFixSync(fs$6.fstatSync);
9583
9642
  fs$6.lstatSync = statFixSync(fs$6.lstatSync);
9584
9643
  if (fs$6.chmod && !fs$6.lchmod) {
9585
- fs$6.lchmod = function(path$9, mode, cb) {
9644
+ fs$6.lchmod = function(path$10, mode, cb) {
9586
9645
  if (cb) process.nextTick(cb);
9587
9646
  };
9588
9647
  fs$6.lchmodSync = function() {};
9589
9648
  }
9590
9649
  if (fs$6.chown && !fs$6.lchown) {
9591
- fs$6.lchown = function(path$9, uid, gid, cb) {
9650
+ fs$6.lchown = function(path$10, uid, gid, cb) {
9592
9651
  if (cb) process.nextTick(cb);
9593
9652
  };
9594
9653
  fs$6.lchownSync = function() {};
@@ -9647,8 +9706,8 @@ var require_polyfills = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/g
9647
9706
  };
9648
9707
  })(fs$6.readSync);
9649
9708
  function patchLchmod(fs$7) {
9650
- fs$7.lchmod = function(path$9, mode, callback) {
9651
- fs$7.open(path$9, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
9709
+ fs$7.lchmod = function(path$10, mode, callback) {
9710
+ fs$7.open(path$10, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
9652
9711
  if (err) {
9653
9712
  if (callback) callback(err);
9654
9713
  return;
@@ -9660,8 +9719,8 @@ var require_polyfills = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/g
9660
9719
  });
9661
9720
  });
9662
9721
  };
9663
- fs$7.lchmodSync = function(path$9, mode) {
9664
- var fd = fs$7.openSync(path$9, constants.O_WRONLY | constants.O_SYMLINK, mode);
9722
+ fs$7.lchmodSync = function(path$10, mode) {
9723
+ var fd = fs$7.openSync(path$10, constants.O_WRONLY | constants.O_SYMLINK, mode);
9665
9724
  var threw = true;
9666
9725
  var ret;
9667
9726
  try {
@@ -9678,8 +9737,8 @@ var require_polyfills = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/g
9678
9737
  }
9679
9738
  function patchLutimes(fs$7) {
9680
9739
  if (constants.hasOwnProperty("O_SYMLINK") && fs$7.futimes) {
9681
- fs$7.lutimes = function(path$9, at, mt, cb) {
9682
- fs$7.open(path$9, constants.O_SYMLINK, function(er, fd) {
9740
+ fs$7.lutimes = function(path$10, at, mt, cb) {
9741
+ fs$7.open(path$10, constants.O_SYMLINK, function(er, fd) {
9683
9742
  if (er) {
9684
9743
  if (cb) cb(er);
9685
9744
  return;
@@ -9691,8 +9750,8 @@ var require_polyfills = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/g
9691
9750
  });
9692
9751
  });
9693
9752
  };
9694
- fs$7.lutimesSync = function(path$9, at, mt) {
9695
- var fd = fs$7.openSync(path$9, constants.O_SYMLINK);
9753
+ fs$7.lutimesSync = function(path$10, at, mt) {
9754
+ var fd = fs$7.openSync(path$10, constants.O_SYMLINK);
9696
9755
  var ret;
9697
9756
  var threw = true;
9698
9757
  try {
@@ -9800,11 +9859,11 @@ var require_legacy_streams = /* @__PURE__ */ __commonJS({ "../../node_modules/.p
9800
9859
  ReadStream,
9801
9860
  WriteStream
9802
9861
  };
9803
- function ReadStream(path$9, options) {
9804
- if (!(this instanceof ReadStream)) return new ReadStream(path$9, options);
9862
+ function ReadStream(path$10, options) {
9863
+ if (!(this instanceof ReadStream)) return new ReadStream(path$10, options);
9805
9864
  Stream.call(this);
9806
9865
  var self = this;
9807
- this.path = path$9;
9866
+ this.path = path$10;
9808
9867
  this.fd = null;
9809
9868
  this.readable = true;
9810
9869
  this.paused = false;
@@ -9842,10 +9901,10 @@ var require_legacy_streams = /* @__PURE__ */ __commonJS({ "../../node_modules/.p
9842
9901
  self._read();
9843
9902
  });
9844
9903
  }
9845
- function WriteStream(path$9, options) {
9846
- if (!(this instanceof WriteStream)) return new WriteStream(path$9, options);
9904
+ function WriteStream(path$10, options) {
9905
+ if (!(this instanceof WriteStream)) return new WriteStream(path$10, options);
9847
9906
  Stream.call(this);
9848
- this.path = path$9;
9907
+ this.path = path$10;
9849
9908
  this.fd = null;
9850
9909
  this.writable = true;
9851
9910
  this.flags = "w";
@@ -9968,15 +10027,15 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
9968
10027
  fs$6.createWriteStream = createWriteStream;
9969
10028
  var fs$readFile = fs$6.readFile;
9970
10029
  fs$6.readFile = readFile;
9971
- function readFile(path$9, options, cb) {
10030
+ function readFile(path$10, options, cb) {
9972
10031
  if (typeof options === "function") cb = options, options = null;
9973
- return go$readFile(path$9, options, cb);
9974
- function go$readFile(path$10, options$1, cb$1, startTime) {
9975
- return fs$readFile(path$10, options$1, function(err) {
10032
+ return go$readFile(path$10, options, cb);
10033
+ function go$readFile(path$11, options$1, cb$1, startTime) {
10034
+ return fs$readFile(path$11, options$1, function(err) {
9976
10035
  if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
9977
10036
  go$readFile,
9978
10037
  [
9979
- path$10,
10038
+ path$11,
9980
10039
  options$1,
9981
10040
  cb$1
9982
10041
  ],
@@ -9990,15 +10049,15 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
9990
10049
  }
9991
10050
  var fs$writeFile = fs$6.writeFile;
9992
10051
  fs$6.writeFile = writeFile;
9993
- function writeFile(path$9, data, options, cb) {
10052
+ function writeFile(path$10, data, options, cb) {
9994
10053
  if (typeof options === "function") cb = options, options = null;
9995
- return go$writeFile(path$9, data, options, cb);
9996
- function go$writeFile(path$10, data$1, options$1, cb$1, startTime) {
9997
- return fs$writeFile(path$10, data$1, options$1, function(err) {
10054
+ return go$writeFile(path$10, data, options, cb);
10055
+ function go$writeFile(path$11, data$1, options$1, cb$1, startTime) {
10056
+ return fs$writeFile(path$11, data$1, options$1, function(err) {
9998
10057
  if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
9999
10058
  go$writeFile,
10000
10059
  [
10001
- path$10,
10060
+ path$11,
10002
10061
  data$1,
10003
10062
  options$1,
10004
10063
  cb$1
@@ -10013,15 +10072,15 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
10013
10072
  }
10014
10073
  var fs$appendFile = fs$6.appendFile;
10015
10074
  if (fs$appendFile) fs$6.appendFile = appendFile;
10016
- function appendFile(path$9, data, options, cb) {
10075
+ function appendFile(path$10, data, options, cb) {
10017
10076
  if (typeof options === "function") cb = options, options = null;
10018
- return go$appendFile(path$9, data, options, cb);
10019
- function go$appendFile(path$10, data$1, options$1, cb$1, startTime) {
10020
- return fs$appendFile(path$10, data$1, options$1, function(err) {
10077
+ return go$appendFile(path$10, data, options, cb);
10078
+ function go$appendFile(path$11, data$1, options$1, cb$1, startTime) {
10079
+ return fs$appendFile(path$11, data$1, options$1, function(err) {
10021
10080
  if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
10022
10081
  go$appendFile,
10023
10082
  [
10024
- path$10,
10083
+ path$11,
10025
10084
  data$1,
10026
10085
  options$1,
10027
10086
  cb$1
@@ -10063,20 +10122,20 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
10063
10122
  var fs$readdir = fs$6.readdir;
10064
10123
  fs$6.readdir = readdir;
10065
10124
  var noReaddirOptionVersions = /^v[0-5]\./;
10066
- function readdir(path$9, options, cb) {
10125
+ function readdir(path$10, options, cb) {
10067
10126
  if (typeof options === "function") cb = options, options = null;
10068
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir$1(path$10, options$1, cb$1, startTime) {
10069
- return fs$readdir(path$10, fs$readdirCallback(path$10, options$1, cb$1, startTime));
10070
- } : function go$readdir$1(path$10, options$1, cb$1, startTime) {
10071
- return fs$readdir(path$10, options$1, fs$readdirCallback(path$10, options$1, cb$1, startTime));
10127
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir$1(path$11, options$1, cb$1, startTime) {
10128
+ return fs$readdir(path$11, fs$readdirCallback(path$11, options$1, cb$1, startTime));
10129
+ } : function go$readdir$1(path$11, options$1, cb$1, startTime) {
10130
+ return fs$readdir(path$11, options$1, fs$readdirCallback(path$11, options$1, cb$1, startTime));
10072
10131
  };
10073
- return go$readdir(path$9, options, cb);
10074
- function fs$readdirCallback(path$10, options$1, cb$1, startTime) {
10132
+ return go$readdir(path$10, options, cb);
10133
+ function fs$readdirCallback(path$11, options$1, cb$1, startTime) {
10075
10134
  return function(err, files) {
10076
10135
  if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
10077
10136
  go$readdir,
10078
10137
  [
10079
- path$10,
10138
+ path$11,
10080
10139
  options$1,
10081
10140
  cb$1
10082
10141
  ],
@@ -10148,7 +10207,7 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
10148
10207
  enumerable: true,
10149
10208
  configurable: true
10150
10209
  });
10151
- function ReadStream(path$9, options) {
10210
+ function ReadStream(path$10, options) {
10152
10211
  if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
10153
10212
  else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
10154
10213
  }
@@ -10165,7 +10224,7 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
10165
10224
  }
10166
10225
  });
10167
10226
  }
10168
- function WriteStream(path$9, options) {
10227
+ function WriteStream(path$10, options) {
10169
10228
  if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
10170
10229
  else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
10171
10230
  }
@@ -10181,23 +10240,23 @@ var require_graceful_fs = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
10181
10240
  }
10182
10241
  });
10183
10242
  }
10184
- function createReadStream(path$9, options) {
10185
- return new fs$6.ReadStream(path$9, options);
10243
+ function createReadStream(path$10, options) {
10244
+ return new fs$6.ReadStream(path$10, options);
10186
10245
  }
10187
- function createWriteStream(path$9, options) {
10188
- return new fs$6.WriteStream(path$9, options);
10246
+ function createWriteStream(path$10, options) {
10247
+ return new fs$6.WriteStream(path$10, options);
10189
10248
  }
10190
10249
  var fs$open = fs$6.open;
10191
10250
  fs$6.open = open;
10192
- function open(path$9, flags, mode, cb) {
10251
+ function open(path$10, flags, mode, cb) {
10193
10252
  if (typeof mode === "function") cb = mode, mode = null;
10194
- return go$open(path$9, flags, mode, cb);
10195
- function go$open(path$10, flags$1, mode$1, cb$1, startTime) {
10196
- return fs$open(path$10, flags$1, mode$1, function(err, fd) {
10253
+ return go$open(path$10, flags, mode, cb);
10254
+ function go$open(path$11, flags$1, mode$1, cb$1, startTime) {
10255
+ return fs$open(path$11, flags$1, mode$1, function(err, fd) {
10197
10256
  if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
10198
10257
  go$open,
10199
10258
  [
10200
- path$10,
10259
+ path$11,
10201
10260
  flags$1,
10202
10261
  mode$1,
10203
10262
  cb$1
@@ -17879,18 +17938,18 @@ var require_load_yaml_file = /* @__PURE__ */ __commonJS({ "../../node_modules/.p
17879
17938
  //#endregion
17880
17939
  //#region ../../node_modules/.pnpm/which-pm@3.0.1/node_modules/which-pm/index.js
17881
17940
  var require_which_pm = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/which-pm@3.0.1/node_modules/which-pm/index.js": ((exports, module) => {
17882
- const path$2 = __require("path");
17941
+ const path$3 = __require("path");
17883
17942
  const fs$1 = __require("fs");
17884
17943
  const loadYamlFile = require_load_yaml_file();
17885
17944
  module.exports = async function(pkgPath) {
17886
- const modulesPath = path$2.join(pkgPath, "node_modules");
17887
- if (fs$1.existsSync(path$2.join(modulesPath, ".yarn-integrity"))) return { name: "yarn" };
17945
+ const modulesPath = path$3.join(pkgPath, "node_modules");
17946
+ if (fs$1.existsSync(path$3.join(modulesPath, ".yarn-integrity"))) return { name: "yarn" };
17888
17947
  try {
17889
- return toNameAndVersion((await loadYamlFile(path$2.join(modulesPath, ".modules.yaml"))).packageManager);
17948
+ return toNameAndVersion((await loadYamlFile(path$3.join(modulesPath, ".modules.yaml"))).packageManager);
17890
17949
  } catch (err) {
17891
17950
  if (err.code !== "ENOENT") throw err;
17892
17951
  }
17893
- if (fs$1.existsSync(path$2.join(pkgPath, "bun.lockb"))) return { name: "bun" };
17952
+ if (fs$1.existsSync(path$3.join(pkgPath, "bun.lockb"))) return { name: "bun" };
17894
17953
  return fs$1.existsSync(modulesPath) ? { name: "npm" } : null;
17895
17954
  };
17896
17955
  function toNameAndVersion(pkgSpec) {
@@ -17914,31 +17973,31 @@ var require_which_pm = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/wh
17914
17973
  var require_preferred_pm = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/preferred-pm@4.1.1/node_modules/preferred-pm/index.js": ((exports, module) => {
17915
17974
  const findYarnWorkspaceRoot = require_find_yarn_workspace_root2();
17916
17975
  const fs = __require("fs");
17917
- const path$1 = __require("path");
17976
+ const path$2 = __require("path");
17918
17977
  const whichPM = require_which_pm();
17919
17978
  module.exports = async function preferredPM$1(pkgPath) {
17920
17979
  if (typeof pkgPath !== "string") throw new TypeError(`pkgPath should be a string, got ${typeof pkgPath}`);
17921
- if (fs.existsSync(path$1.join(pkgPath, "package-lock.json"))) return {
17980
+ if (fs.existsSync(path$2.join(pkgPath, "package-lock.json"))) return {
17922
17981
  name: "npm",
17923
17982
  version: ">=5"
17924
17983
  };
17925
- if (fs.existsSync(path$1.join(pkgPath, "yarn.lock"))) return {
17984
+ if (fs.existsSync(path$2.join(pkgPath, "yarn.lock"))) return {
17926
17985
  name: "yarn",
17927
17986
  version: "*"
17928
17987
  };
17929
- if (fs.existsSync(path$1.join(pkgPath, "pnpm-lock.yaml"))) return {
17988
+ if (fs.existsSync(path$2.join(pkgPath, "pnpm-lock.yaml"))) return {
17930
17989
  name: "pnpm",
17931
17990
  version: ">=3"
17932
17991
  };
17933
- if (fs.existsSync(path$1.join(pkgPath, "shrinkwrap.yaml"))) return {
17992
+ if (fs.existsSync(path$2.join(pkgPath, "shrinkwrap.yaml"))) return {
17934
17993
  name: "pnpm",
17935
17994
  version: "1 || 2"
17936
17995
  };
17937
- if (fs.existsSync(path$1.join(pkgPath, "bun.lockb")) || fs.existsSync(path$1.join(pkgPath, "bun.lock"))) return {
17996
+ if (fs.existsSync(path$2.join(pkgPath, "bun.lockb")) || fs.existsSync(path$2.join(pkgPath, "bun.lock"))) return {
17938
17997
  name: "bun",
17939
17998
  version: "*"
17940
17999
  };
17941
- const { findUp: findUp$1 } = await import("./find-up-simple-y_v4Cpd8.js");
18000
+ const { findUp: findUp$1 } = await import("./find-up-simple-eHmrWCoZ.js");
17942
18001
  if (await findUp$1("pnpm-lock.yaml", { cwd: pkgPath })) return {
17943
18002
  name: "pnpm",
17944
18003
  version: ">=3"
@@ -17946,7 +18005,7 @@ var require_preferred_pm = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnp
17946
18005
  try {
17947
18006
  const workspaceRoot = findYarnWorkspaceRoot(pkgPath);
17948
18007
  if (typeof workspaceRoot === "string") {
17949
- if (fs.existsSync(path$1.join(workspaceRoot, "package-lock.json"))) return {
18008
+ if (fs.existsSync(path$2.join(workspaceRoot, "package-lock.json"))) return {
17950
18009
  name: "npm",
17951
18010
  version: ">=7"
17952
18011
  };
@@ -18734,30 +18793,15 @@ var Core = class Core {
18734
18793
  builder = Builder;
18735
18794
  constructor(clientId, clientSecret, encryptionKey, env$3, config) {
18736
18795
  const currentConfig = getConfig();
18737
- if (clientId && typeof clientId === "object") {
18738
- this.clientId = Core.normalizeCredential(clientId.clientId);
18739
- this.clientSecret = Core.normalizeCredential(clientId.clientSecret);
18740
- this.environment = clientId.environment ?? currentConfig.environment ?? Core.normalizeEnvironment(process.env.ENVIRONMENT) ?? "live";
18741
- this.configure({
18742
- environment: this.environment,
18743
- urls: clientId.urls,
18744
- headers: clientId.headers,
18745
- timeout: clientId.timeout,
18746
- encryptionKey: clientId.encryptionKey,
18747
- auth: clientId.auth
18748
- });
18749
- this.debug(clientId.debugLevel ?? 0);
18750
- } else {
18751
- this.clientId = Core.normalizeCredential(clientId) ?? Core.normalizeCredential(process.env.CLIENT_ID);
18752
- this.clientSecret = Core.normalizeCredential(clientSecret) ?? Core.normalizeCredential(process.env.CLIENT_SECRET);
18753
- this.environment = env$3 ?? currentConfig.environment ?? Core.normalizeEnvironment(process.env.ENVIRONMENT) ?? "live";
18754
- this.configure({
18755
- ...config ?? {},
18756
- environment: this.environment,
18757
- encryptionKey: encryptionKey ?? config?.encryptionKey
18758
- });
18759
- this.debug(0);
18760
- }
18796
+ const resolvedConfig = clientId && typeof clientId === "object" ? this.resolveInitOptionsFromObject(clientId, currentConfig) : this.resolveInitOptionsFromArgs(clientId, clientSecret, encryptionKey, env$3, config, currentConfig);
18797
+ this.clientId = Core.normalizeCredential(resolvedConfig.clientId);
18798
+ this.clientSecret = Core.normalizeCredential(resolvedConfig.clientSecret);
18799
+ this.environment = resolvedConfig.environment ?? Core.normalizeEnvironment(process.env.ENVIRONMENT) ?? "live";
18800
+ this.configure({
18801
+ ...resolvedConfig,
18802
+ environment: this.environment
18803
+ });
18804
+ this.debug(resolvedConfig.debugLevel ?? 0);
18761
18805
  if (!this.clientSecret && !this.hasConfiguredAuth()) throw new Error("Client Secret is required to initialize API instance when auth is not provided");
18762
18806
  this.api = this.createApi();
18763
18807
  }
@@ -18773,6 +18817,9 @@ var Core = class Core {
18773
18817
  this.environment = nextConfig.environment;
18774
18818
  this.builder.setEnvironment(nextConfig.environment);
18775
18819
  }
18820
+ if ("clientId" in config) this.clientId = Core.normalizeCredential(nextConfig.clientId);
18821
+ if ("clientSecret" in config) this.clientSecret = Core.normalizeCredential(nextConfig.clientSecret);
18822
+ if (nextConfig.debugLevel !== void 0) this.debug(nextConfig.debugLevel);
18776
18823
  return this;
18777
18824
  }
18778
18825
  /**
@@ -18879,6 +18926,36 @@ var Core = class Core {
18879
18926
  const normalized = value.trim();
18880
18927
  return normalized ? normalized : void 0;
18881
18928
  }
18929
+ resolveInitOptionsFromObject(config, currentConfig) {
18930
+ return {
18931
+ ...currentConfig,
18932
+ ...config,
18933
+ clientId: Core.normalizeCredential(config.clientId) ?? Core.normalizeCredential(currentConfig.clientId) ?? Core.normalizeCredential(process.env.CLIENT_ID),
18934
+ clientSecret: Core.normalizeCredential(config.clientSecret) ?? Core.normalizeCredential(currentConfig.clientSecret) ?? Core.normalizeCredential(process.env.CLIENT_SECRET),
18935
+ environment: config.environment ?? currentConfig.environment ?? Core.normalizeEnvironment(process.env.ENVIRONMENT) ?? "live",
18936
+ encryptionKey: config.encryptionKey ?? currentConfig.encryptionKey,
18937
+ urls: config.urls ?? currentConfig.urls,
18938
+ headers: config.headers ?? currentConfig.headers,
18939
+ timeout: config.timeout ?? currentConfig.timeout,
18940
+ auth: config.auth ?? currentConfig.auth,
18941
+ debugLevel: config.debugLevel ?? currentConfig.debugLevel ?? 0
18942
+ };
18943
+ }
18944
+ resolveInitOptionsFromArgs(clientId, clientSecret, encryptionKey, env$3, config, currentConfig) {
18945
+ return {
18946
+ ...currentConfig,
18947
+ ...config ?? {},
18948
+ clientId: Core.normalizeCredential(clientId) ?? Core.normalizeCredential(currentConfig.clientId) ?? Core.normalizeCredential(process.env.CLIENT_ID),
18949
+ clientSecret: Core.normalizeCredential(clientSecret) ?? Core.normalizeCredential(currentConfig.clientSecret) ?? Core.normalizeCredential(process.env.CLIENT_SECRET),
18950
+ environment: env$3 ?? config?.environment ?? currentConfig.environment ?? Core.normalizeEnvironment(process.env.ENVIRONMENT) ?? "live",
18951
+ encryptionKey: encryptionKey ?? config?.encryptionKey ?? currentConfig.encryptionKey,
18952
+ urls: config?.urls ?? currentConfig.urls,
18953
+ headers: config?.headers ?? currentConfig.headers,
18954
+ timeout: config?.timeout ?? currentConfig.timeout,
18955
+ auth: config?.auth ?? currentConfig.auth,
18956
+ debugLevel: config?.debugLevel ?? currentConfig.debugLevel ?? 0
18957
+ };
18958
+ }
18882
18959
  hasConfiguredAuth() {
18883
18960
  const auth = getConfig().auth;
18884
18961
  if (Array.isArray(auth)) return auth.length > 0;
@@ -18895,6 +18972,9 @@ var Core = class Core {
18895
18972
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
18896
18973
  return [
18897
18974
  "auth",
18975
+ "clientId",
18976
+ "clientSecret",
18977
+ "debugLevel",
18898
18978
  "environment",
18899
18979
  "headers",
18900
18980
  "timeout",
@@ -18998,4 +19078,4 @@ var WebhookValidator = class {
18998
19078
  };
18999
19079
 
19000
19080
  //#endregion
19001
- export { BadRequestException, BaseApi, Builder, Core, ForbiddenRequestException, Http, HttpException, UnauthorizedRequestException, WebhookValidator, buildUrl, createAccessTokenCache, createAuthCache, createRuntimeApi, createSdk, defaultConfig, defineConfig, getConfig, globalConfig, normalizeValue, resetConfig };
19081
+ export { BadRequestException, BaseApi, Builder, Core, ForbiddenRequestException, Http, HttpException, UnauthorizedRequestException, WebhookValidator, buildUrl, createAccessTokenCache, createAuthCache, createRuntimeApi, createSdk, defaultConfig, defineConfig, getConfig, globalConfig, loadUserConfig, normalizeValue, resetConfig };