@accelbyte/codegen 0.0.0-dev-20250519035357 → 0.0.0-dev-20260320085237

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.
@@ -23,7 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  ));
24
24
 
25
25
  // src/cli.ts
26
- var import_path5 = __toESM(require("path"));
26
+ var import_path6 = __toESM(require("path"));
27
27
  var import_yargs = __toESM(require("yargs"));
28
28
 
29
29
  // src/CliParser.ts
@@ -87,18 +87,52 @@ var CliParser = class _CliParser {
87
87
 
88
88
  // src/CodeGenerator.ts
89
89
  var import_swagger_parser = __toESM(require("@apidevtools/swagger-parser"));
90
- var import_fs4 = __toESM(require("fs"));
91
- var import_path3 = __toESM(require("path"));
90
+ var import_fs5 = __toESM(require("fs"));
91
+ var import_path4 = __toESM(require("path"));
92
+
93
+ // src/CodegenConfig.ts
94
+ var import_fs2 = __toESM(require("fs"));
95
+ var import_path = __toESM(require("path"));
96
+ var import_url = require("url");
97
+ var CodegenConfig = class _CodegenConfig {
98
+ static config = {};
99
+ static async loadConfig(configDir) {
100
+ const configPath = import_path.default.join(configDir, "abcodegen.config.ts");
101
+ if (!import_fs2.default.existsSync(configPath)) {
102
+ _CodegenConfig.config = {};
103
+ return;
104
+ }
105
+ const loaded = await import((0, import_url.pathToFileURL)(configPath).href);
106
+ _CodegenConfig.config = loaded.default ?? loaded ?? {};
107
+ }
108
+ static shouldProduceIndexFile() {
109
+ return _CodegenConfig.config.unstable_shouldProduceIndexFile ?? true;
110
+ }
111
+ static getBasePath() {
112
+ return _CodegenConfig.config.basePath;
113
+ }
114
+ static getOverrideAsAny() {
115
+ return _CodegenConfig.config.unstable_overrideAsAny;
116
+ }
117
+ /** Reset to defaults — used for testing */
118
+ static reset() {
119
+ _CodegenConfig.config = {};
120
+ }
121
+ /** Set config directly — used for testing */
122
+ static setConfig(config) {
123
+ _CodegenConfig.config = config;
124
+ }
125
+ };
92
126
 
93
127
  // src/ParserUtils.ts
94
128
  var import_fast_json_patch = require("fast-json-patch");
95
- var import_fs3 = __toESM(require("fs"));
129
+ var import_fs4 = __toESM(require("fs"));
96
130
  var import_lodash = __toESM(require("lodash"));
97
- var import_path2 = __toESM(require("path"));
131
+ var import_path3 = __toESM(require("path"));
98
132
 
99
133
  // src/helpers/utils.ts
100
- var import_fs2 = __toESM(require("fs"));
101
- var import_path = __toESM(require("path"));
134
+ var import_fs3 = __toESM(require("fs"));
135
+ var import_path2 = __toESM(require("path"));
102
136
  var capitalize = (string) => {
103
137
  return string.charAt(0).toUpperCase() + string.slice(1);
104
138
  };
@@ -175,10 +209,10 @@ var getImportableVarMap = () => ({
175
209
  zod: ["z"]
176
210
  });
177
211
  var makeNewImportVarMap = () => ({
178
- axios: ["AxiosInstance", "AxiosRequestConfig"],
179
- "@accelbyte/sdk": ["SDKRequestConfig"]
212
+ axios: ["AxiosInstance", "AxiosRequestConfig"]
180
213
  });
181
- var generateImports = (body, importStatements, makeNewImportVarMap3, getImportableVarMap3) => {
214
+ var CLASS_TYPE_ONLY_VARS = /* @__PURE__ */ new Set(["AxiosInstance", "AxiosRequestConfig", "AxiosResponse", "SdkSetConfigParam", "Response"]);
215
+ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportableVarMap3, typeOnlyVars = /* @__PURE__ */ new Set()) => {
182
216
  const usedImportVarMap = makeNewImportVarMap3;
183
217
  const importableVarMap = getImportableVarMap3;
184
218
  for (const [moduleSource, importableVars] of Object.entries(importableVarMap)) {
@@ -189,9 +223,19 @@ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportab
189
223
  }
190
224
  }
191
225
  }
192
- const generatedImports = Object.keys(usedImportVarMap).sort().map((moduleSource) => {
193
- return `import { ${usedImportVarMap[moduleSource].sort().join(", ")} } from '${moduleSource}'`;
194
- }).join("\n");
226
+ const importLines = [];
227
+ for (const moduleSource of Object.keys(usedImportVarMap).sort()) {
228
+ const allVars = usedImportVarMap[moduleSource];
229
+ const valueVars = allVars.filter((v) => !typeOnlyVars.has(v)).sort();
230
+ const typeVars = allVars.filter((v) => typeOnlyVars.has(v)).sort();
231
+ if (valueVars.length > 0) {
232
+ importLines.push(`import { ${valueVars.join(", ")} } from '${moduleSource}'`);
233
+ }
234
+ if (typeVars.length > 0) {
235
+ importLines.push(`import type { ${typeVars.join(", ")} } from '${moduleSource}'`);
236
+ }
237
+ }
238
+ const generatedImports = importLines.join("\n");
195
239
  return `${generatedImports}
196
240
  ${importStatements.sort().join("\n")}`;
197
241
  };
@@ -199,11 +243,9 @@ var templateClass = (className, body, importStatements) => {
199
243
  return `/**
200
244
  * AUTO GENERATED
201
245
  */
202
- ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap())}
246
+ ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap(), CLASS_TYPE_ONLY_VARS)}
203
247
 
204
248
  export class ${className} {
205
- // @ts-ignore
206
- // prettier-ignore
207
249
  constructor(private axiosInstance: AxiosInstance, private namespace: string, private useSchemaValidation = true) {}
208
250
  ${body}
209
251
  }
@@ -219,6 +261,15 @@ var makeNewImportVarMap2 = () => ({
219
261
  "@accelbyte/sdk": ["AccelByteSDK", "SdkSetConfigParam", "ApiUtils", "Network"],
220
262
  axios: ["AxiosRequestConfig", "AxiosResponse"]
221
263
  });
264
+ var API_TYPE_ONLY_VARS = /* @__PURE__ */ new Set([
265
+ "AxiosRequestConfig",
266
+ "AxiosResponse",
267
+ "AxiosDefaults",
268
+ "HeadersDefaults",
269
+ "AccelByteSDK",
270
+ "SdkSetConfigParam",
271
+ "Response"
272
+ ]);
222
273
  var templateApiClass = (className, body, importStatements, returnMethods) => {
223
274
  const returnsMethodsWithDescription = Object.keys(returnMethods).reduce((acc, key) => {
224
275
  acc += `
@@ -230,43 +281,45 @@ ${key},`;
230
281
  return `/**
231
282
  * AUTO GENERATED
232
283
  */
233
- /* eslint-disable camelcase */
234
- // @ts-ignore -> ts-expect-error TS6133
235
- ${generateImports(body, importStatements, makeNewImportVarMap2(), getImportableVarMap2())}
284
+ ${generateImports(body, importStatements, makeNewImportVarMap2(), getImportableVarMap2(), API_TYPE_ONLY_VARS)}
236
285
  ${`import { ${$className} } from './endpoints/${$className}.js'
237
286
  `}
238
287
 
239
288
  export function ${className}(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
240
289
  const sdkAssembly = sdk.assembly()
241
-
290
+
242
291
  const namespace = args?.coreConfig?.namespace ?? sdkAssembly.coreConfig.namespace
243
292
  const useSchemaValidation = args?.coreConfig?.useSchemaValidation ?? sdkAssembly.coreConfig.useSchemaValidation
244
-
293
+
245
294
  let axiosInstance = sdkAssembly.axiosInstance
246
295
  const requestConfigOverrides = args?.axiosConfig?.request
247
296
  const baseURLOverride = args?.coreConfig?.baseURL
248
- const interceptorsOverride = args?.axiosConfig?.interceptors ?? []
297
+ const interceptorsOverride = args?.axiosConfig?.interceptors
249
298
 
250
- if (requestConfigOverrides || baseURLOverride || interceptorsOverride.length > 0) {
299
+ if (requestConfigOverrides || baseURLOverride || interceptorsOverride) {
251
300
  const requestConfig = ApiUtils.mergeAxiosConfigs(sdkAssembly.axiosInstance.defaults as AxiosRequestConfig, {
252
301
  ...(baseURLOverride ? { baseURL: baseURLOverride } : {}),
253
302
  ...requestConfigOverrides
254
303
  })
255
304
  axiosInstance = Network.create(requestConfig)
256
305
 
257
- for (const interceptor of interceptorsOverride) {
258
- if (interceptor.type === 'request') {
259
- axiosInstance.interceptors.request.use(interceptor.onRequest, interceptor.onError)
260
- }
306
+ if (interceptorsOverride) {
307
+ for (const interceptor of interceptorsOverride) {
308
+ if (interceptor.type === 'request') {
309
+ axiosInstance.interceptors.request.use(interceptor.onRequest, interceptor.onError)
310
+ }
261
311
 
262
- if (interceptor.type === 'response') {
263
- axiosInstance.interceptors.response.use(interceptor.onSuccess, interceptor.onError)
312
+ if (interceptor.type === 'response') {
313
+ axiosInstance.interceptors.response.use(interceptor.onSuccess, interceptor.onError)
314
+ }
264
315
  }
316
+ } else {
317
+ axiosInstance.interceptors = sdkAssembly.axiosInstance.interceptors
265
318
  }
266
319
  }
267
320
 
268
321
  ${body}
269
-
322
+
270
323
  return {
271
324
  ${returnsMethodsWithDescription}
272
325
  }
@@ -277,7 +330,7 @@ export function ${className}(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
277
330
  // src/ParserQueryUtils.ts
278
331
  var ParserQueryUtils = class {
279
332
  /**
280
- * convert csv 'aa,bb' into "aa='aa', bb='bb'"
333
+ * convert csv 'aa,bb' into "aa = 'Sdk.Class.aa', bb = 'Sdk.Class.bb'"
281
334
  */
282
335
  static createQueryKeys(classNameWithoutApi, csvMethodNames, sdkName) {
283
336
  const keys = csvMethodNames.split(",");
@@ -288,7 +341,7 @@ var ParserQueryUtils = class {
288
341
  const cleanedKey = trimmedKey.replace(/^(get|update|create|patch|delete|post|fetch)[_]?/, "");
289
342
  if (!processedKeys.has(cleanedKey)) {
290
343
  processedKeys.add(cleanedKey);
291
- acc += `${cleanedKey} = '${capitalize(sdkName)}.${classNameWithoutApi}.${cleanedKey}'`;
344
+ acc += `${cleanedKey}: '${capitalize(sdkName)}.${classNameWithoutApi}.${cleanedKey}'`;
292
345
  if (index < keys.length - 1) {
293
346
  acc += ",\n";
294
347
  }
@@ -302,42 +355,51 @@ var ParserQueryUtils = class {
302
355
 
303
356
  // src/templates/template-query.ts
304
357
  var generateImports2 = (body, className) => {
305
- const generatedImports = `import { AccelByteSDK, SdkSetConfigParam, ApiError } from '@accelbyte/sdk'
306
- import { AxiosError, AxiosResponse } from 'axios'
307
- // @ts-ignore
308
- import { useQuery, UseQueryOptions, UseQueryResult, useMutation, UseMutationOptions, UseMutationResult } from '@tanstack/react-query'
309
- import { ${className} } from "../${className}.js"
310
- `;
311
- return generatedImports;
358
+ const lines = [];
359
+ lines.push("import type { AccelByteSDK, ApiError, SdkSetConfigParam } from '@accelbyte/sdk'");
360
+ const axiosTypes = ["AxiosError", "AxiosResponse"].filter((t) => body.includes(t));
361
+ if (axiosTypes.length) {
362
+ lines.push(`import type { ${axiosTypes.join(", ")} } from 'axios'`);
363
+ }
364
+ const rqValues = ["useMutation", "useQuery"].filter((t) => body.includes(t));
365
+ if (rqValues.length) {
366
+ lines.push(`import { ${rqValues.join(", ")} } from '@tanstack/react-query'`);
367
+ }
368
+ const rqTypes = ["UseMutationOptions", "UseMutationResult", "UseQueryOptions", "UseQueryResult"].filter((t) => body.includes(t));
369
+ if (rqTypes.length) {
370
+ lines.push(`import type { ${rqTypes.join(", ")} } from '@tanstack/react-query'`);
371
+ }
372
+ lines.push(`import { ${className} } from "../${className}.js"`);
373
+ return lines.join("\n") + "\n";
312
374
  };
313
375
  var templateQuery = (className, body, importStatements, serviceNameTitle, returnMethods, paramImports, sdkName) => {
314
376
  const classNameWithoutApi = className.replace("Api", "");
315
377
  const queryKeys = ParserQueryUtils.createQueryKeys(classNameWithoutApi, returnMethods, sdkName);
316
378
  const generatedImports = generateImports2(body, className);
379
+ const queryKeyBlock = `export const Key_${classNameWithoutApi} = {
380
+ ${queryKeys}
381
+ } as const`;
317
382
  return `/**
318
383
  * AUTO GENERATED
319
384
  */
320
- /* eslint-disable camelcase */
321
385
  ${generatedImports}
322
386
  ${filterUsedImports(paramImports, body)}
323
387
 
324
- export enum Key_${classNameWithoutApi} {
325
- ${queryKeys}
326
- }
388
+ ${queryKeyBlock}
327
389
 
328
390
  ${body}
329
391
  `;
330
392
  };
331
393
  function filterUsedImports(importArr, body) {
332
- return importArr.filter((path8) => {
333
- const start = path8.indexOf("{") + 1;
334
- const end = path8.indexOf("}");
394
+ return importArr.filter((path9) => {
395
+ const start = path9.indexOf("{") + 1;
396
+ const end = path9.indexOf("}");
335
397
  if (start > 0 && end > start) {
336
- const importName = path8.slice(start, end).trim();
398
+ const importName = path9.slice(start, end).trim();
337
399
  return body.includes(importName);
338
400
  }
339
401
  return false;
340
- }).map((path8) => path8).join("\n") + "\n";
402
+ }).map((path9) => path9).join("\n") + "\n";
341
403
  }
342
404
 
343
405
  // src/ParserUtils.ts
@@ -354,8 +416,8 @@ var REMOVED_KEYWORDS = [
354
416
  "/{namespace}/"
355
417
  ];
356
418
  var ParserUtils = class _ParserUtils {
357
- static getVersionSuffixFromPath(path8) {
358
- const version2_3_4_etc = path8.match(/\/v([2-9]|[1-9]\d+)\/+/);
419
+ static getVersionSuffixFromPath(path9) {
420
+ const version2_3_4_etc = path9.match(/\/v([2-9]|[1-9]\d+)\/+/);
359
421
  const methodSuffix = version2_3_4_etc ? `_v${version2_3_4_etc[1]}` : "";
360
422
  return methodSuffix;
361
423
  }
@@ -550,14 +612,14 @@ var ParserUtils = class _ParserUtils {
550
612
  * to this
551
613
  * `createGenerateByRequestIdByUserId`
552
614
  */
553
- static generateNaturalLangMethod = ({ servicePrefix, path: path8, httpMethod, isForm, existingMethods, permissionType }) => {
554
- let path_ = path8;
615
+ static generateNaturalLangMethod = ({ servicePrefix, path: path9, httpMethod, isForm, existingMethods, permissionType }) => {
616
+ let path_ = path9;
555
617
  path_ = path_.replace(`/${servicePrefix}/`, "/");
556
618
  REMOVED_KEYWORDS.forEach((prefix) => {
557
619
  path_ = path_.replace(prefix, "/");
558
620
  });
559
621
  path_ = path_.substring(1);
560
- const isPlural = httpMethod === "get" && !(path8.slice(-1) === "}");
622
+ const isPlural = httpMethod === "get" && !(path9.slice(-1) === "}");
561
623
  if (!isPlural) {
562
624
  path_ = _ParserUtils.replaceAll(path_, "ies/", "y/");
563
625
  path_ = _ParserUtils.replaceAll(path_, "s/", "/");
@@ -600,9 +662,9 @@ var ParserUtils = class _ParserUtils {
600
662
  const genPath = import_lodash.default.upperFirst(lastWords) + "/" + listBeforeLastWords.join("/") + listByParams.reverse().join("/");
601
663
  let generatedMethod = import_lodash.default.camelCase(mappedMethod(httpMethod, isForm, permissionType) + genPath);
602
664
  generatedMethod = _ParserUtils.replaceAll(generatedMethod, "Byword", "_By");
603
- const testedGeneratedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path8);
604
- generatedMethod = resolveConflicts({ path: path8, generatedMethod, testedGeneratedMethod, existingMethods });
605
- generatedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path8);
665
+ const testedGeneratedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path9);
666
+ generatedMethod = resolveConflicts({ path: path9, generatedMethod, testedGeneratedMethod, existingMethods });
667
+ generatedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path9);
606
668
  return generatedMethod;
607
669
  };
608
670
  static filterBodyParams(parameters) {
@@ -618,17 +680,17 @@ var ParserUtils = class _ParserUtils {
618
680
  return parameters.filter((parameter) => parameter.in === "query");
619
681
  }
620
682
  static mkdirIfNotExist(dirToCreate) {
621
- if (!import_fs3.default.existsSync(dirToCreate)) {
622
- import_fs3.default.mkdirSync(dirToCreate, { recursive: true });
683
+ if (!import_fs4.default.existsSync(dirToCreate)) {
684
+ import_fs4.default.mkdirSync(dirToCreate, { recursive: true });
623
685
  }
624
686
  }
625
687
  static writeClassFile(distDir, apiName, apiBuffer, imports) {
626
688
  const fileContent = templateClass(apiName, apiBuffer, imports);
627
- import_fs3.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
689
+ import_fs4.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
628
690
  }
629
691
  static writeAtomFile(distDir, apiName, fileContent) {
630
692
  _ParserUtils.mkdirIfNotExist(distDir);
631
- import_fs3.default.writeFileSync(`${distDir}/${apiName}.atom.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
693
+ import_fs4.default.writeFileSync(`${distDir}/${apiName}.atom.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
632
694
  }
633
695
  static writeQueryFile(distDir, apiName, apiBuffer, imports, serviceNameTitle, returnMethods, paramImports, sdkName) {
634
696
  if (apiBuffer.length < 1) {
@@ -637,20 +699,20 @@ var ParserUtils = class _ParserUtils {
637
699
  const queryFileName = `${apiName.replace("Api", "")}.query`;
638
700
  _ParserUtils.mkdirIfNotExist(distDir);
639
701
  const fileContent = templateQuery(apiName, apiBuffer, imports, serviceNameTitle, returnMethods, paramImports, sdkName);
640
- import_fs3.default.writeFileSync(`${distDir}/${queryFileName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
702
+ import_fs4.default.writeFileSync(`${distDir}/${queryFileName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
641
703
  return queryFileName;
642
704
  }
643
705
  static writeXVersion(distDir, xversionJson, apiInfo) {
644
706
  if (xversionJson) {
645
707
  console.log("x-version:", xversionJson);
646
- import_fs3.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
708
+ import_fs4.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
647
709
  } else {
648
710
  const customVersion = {
649
711
  ...apiInfo,
650
712
  gitHash: apiInfo.version
651
713
  };
652
714
  console.error(`!!!! Missing x-version for ${distDir} ${customVersion}`);
653
- import_fs3.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(customVersion, null, 2));
715
+ import_fs4.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(customVersion, null, 2));
654
716
  }
655
717
  }
656
718
  static writeApiFile(distDir, apiName, apiBuffer, imports, returnMethodsDescription) {
@@ -659,28 +721,28 @@ var ParserUtils = class _ParserUtils {
659
721
  newImports.push(el.replace("../../generated-definitions", "../generated-definitions"));
660
722
  });
661
723
  const fileContent = templateApiClass(apiName, apiBuffer, newImports, returnMethodsDescription);
662
- import_fs3.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
724
+ import_fs4.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
663
725
  }
664
726
  static writeApiMainFile(distDir, serviceName, fileContent) {
665
- import_fs3.default.writeFileSync(`${distDir}/${serviceName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
727
+ import_fs4.default.writeFileSync(`${distDir}/${serviceName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
666
728
  }
667
729
  static writeSnippetFile(distDir, name, docBuffer) {
668
730
  let snippetFileName = _ParserUtils.replaceAll(name, " ", "-").toLowerCase();
669
731
  snippetFileName = snippetFileName.replace("justice-", "");
670
732
  snippetFileName = "snippet-" + snippetFileName + ".json";
671
- import_fs3.default.writeFileSync(`${distDir}/${snippetFileName}`, docBuffer);
733
+ import_fs4.default.writeFileSync(`${distDir}/${snippetFileName}`, docBuffer);
672
734
  }
673
735
  static writeDefinitionFile(distDir, name, buffer) {
674
736
  _ParserUtils.mkdirIfNotExist(distDir);
675
- import_fs3.default.writeFileSync(import_path2.default.join(distDir, `${name}.ts`), _ParserUtils.prependCopyrightHeader(buffer));
737
+ import_fs4.default.writeFileSync(import_path3.default.join(distDir, `${name}.ts`), _ParserUtils.prependCopyrightHeader(buffer));
676
738
  }
677
739
  static writeAllImportsFile(distDir, buffer) {
678
740
  _ParserUtils.mkdirIfNotExist(distDir);
679
- import_fs3.default.writeFileSync(import_path2.default.join(distDir, "all-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
741
+ import_fs4.default.writeFileSync(import_path3.default.join(distDir, "all-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
680
742
  }
681
743
  static writeAllQueryImportsFile(distDir, buffer) {
682
744
  _ParserUtils.mkdirIfNotExist(distDir);
683
- import_fs3.default.writeFileSync(import_path2.default.join(distDir, "all-query-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
745
+ import_fs4.default.writeFileSync(import_path3.default.join(distDir, "all-query-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
684
746
  }
685
747
  static toCamelCase(str) {
686
748
  return str.split("/").map(function(word, index) {
@@ -706,15 +768,15 @@ var ParserUtils = class _ParserUtils {
706
768
  });
707
769
  }
708
770
  static applyPatchIfExists(swaggerFilePath, possibleSwaggerPatchFilePath, swaggerPatchedFilePath, swaggerPatchedDir) {
709
- if (!import_fs3.default.existsSync(swaggerPatchedDir)) {
710
- import_fs3.default.mkdirSync(swaggerPatchedDir, { recursive: true });
771
+ if (!import_fs4.default.existsSync(swaggerPatchedDir)) {
772
+ import_fs4.default.mkdirSync(swaggerPatchedDir, { recursive: true });
711
773
  }
712
- if (!import_fs3.default.existsSync(possibleSwaggerPatchFilePath)) {
713
- import_fs3.default.copyFileSync(swaggerFilePath, swaggerPatchedFilePath);
774
+ if (!import_fs4.default.existsSync(possibleSwaggerPatchFilePath)) {
775
+ import_fs4.default.copyFileSync(swaggerFilePath, swaggerPatchedFilePath);
714
776
  return;
715
777
  }
716
- const swaggerContent = JSON.parse(import_fs3.default.readFileSync(swaggerFilePath, "utf8"));
717
- const swaggerPatchFileContent = JSON.parse(import_fs3.default.readFileSync(possibleSwaggerPatchFilePath, "utf8"));
778
+ const swaggerContent = JSON.parse(import_fs4.default.readFileSync(swaggerFilePath, "utf8"));
779
+ const swaggerPatchFileContent = JSON.parse(import_fs4.default.readFileSync(possibleSwaggerPatchFilePath, "utf8"));
718
780
  for (const patchEntry of swaggerPatchFileContent) {
719
781
  const segments = patchEntry.path.split("/").filter(Boolean);
720
782
  let currentNode = swaggerContent;
@@ -742,7 +804,7 @@ var ParserUtils = class _ParserUtils {
742
804
  }
743
805
  }
744
806
  const { newDocument } = (0, import_fast_json_patch.applyPatch)(swaggerContent, swaggerPatchFileContent);
745
- import_fs3.default.writeFileSync(swaggerPatchedFilePath, JSON.stringify(newDocument, null, 2));
807
+ import_fs4.default.writeFileSync(swaggerPatchedFilePath, JSON.stringify(newDocument, null, 2));
746
808
  }
747
809
  static getRelativePathToWebSdkSrcFolder(srcFolder, targetSrcFolder) {
748
810
  const replaced = srcFolder.replace(/\\/g, "/");
@@ -757,8 +819,8 @@ var ParserUtils = class _ParserUtils {
757
819
  */
758
820
  ${content}`;
759
821
  };
760
- static sortPathParamsByPath = (pathParams, path8) => {
761
- const params = path8.match(/{\w*}/g) || [];
822
+ static sortPathParamsByPath = (pathParams, path9) => {
823
+ const params = path9.match(/{\w*}/g) || [];
762
824
  const cleanParams = params.map((param) => param.replace("{", "").replace("}", ""));
763
825
  return pathParams.sort((a, b) => cleanParams.indexOf(a.name) - cleanParams.indexOf(b.name));
764
826
  };
@@ -782,30 +844,30 @@ var mappedMethod = (httpMethod, isForm, permissionType) => {
782
844
  return "delete";
783
845
  }
784
846
  };
785
- var resolveConflicts = ({ path: path8, generatedMethod, testedGeneratedMethod, existingMethods }) => {
847
+ var resolveConflicts = ({ path: path9, generatedMethod, testedGeneratedMethod, existingMethods }) => {
786
848
  let _testedGenMethod = testedGeneratedMethod;
787
849
  try {
788
- testConflict(path8, _testedGenMethod, existingMethods);
850
+ testConflict(path9, _testedGenMethod, existingMethods);
789
851
  } catch (e) {
790
- if (path8.indexOf("/namespaces/") >= 0) {
852
+ if (path9.indexOf("/namespaces/") >= 0) {
791
853
  generatedMethod += "_ByNS";
792
854
  _testedGenMethod += "_ByNS";
793
855
  }
794
856
  }
795
857
  try {
796
- testConflict(path8, _testedGenMethod, existingMethods);
858
+ testConflict(path9, _testedGenMethod, existingMethods);
797
859
  } catch (e) {
798
- if (path8.indexOf("/admin/") >= 0) {
860
+ if (path9.indexOf("/admin/") >= 0) {
799
861
  generatedMethod += "_admin";
800
862
  _testedGenMethod += "_admin";
801
863
  }
802
864
  }
803
- testConflict(path8, _testedGenMethod, existingMethods);
865
+ testConflict(path9, _testedGenMethod, existingMethods);
804
866
  return generatedMethod;
805
867
  };
806
- var testConflict = (path8, generatedMethod, existingMethods) => {
868
+ var testConflict = (path9, generatedMethod, existingMethods) => {
807
869
  if (existingMethods[generatedMethod]) {
808
- const conflictingMethod = { path: path8, generatedMethod };
870
+ const conflictingMethod = { path: path9, generatedMethod };
809
871
  throw Error(
810
872
  `Duplicate method conflict in ${JSON.stringify(conflictingMethod)},
811
873
  existingMethods: ${JSON.stringify(existingMethods, null, 2)}`
@@ -922,7 +984,7 @@ var OpenApiSpec = import_zod2.z.object({
922
984
  var templateApiMethod = ({
923
985
  classMethod,
924
986
  httpMethod,
925
- path: path8,
987
+ path: path9,
926
988
  pathParams,
927
989
  bodyParams,
928
990
  responseClasses,
@@ -931,12 +993,12 @@ var templateApiMethod = ({
931
993
  methodParamsNoTypes,
932
994
  xSecurity
933
995
  }) => {
934
- let newPath = `'${path8}'`;
996
+ let newPath = `'${path9}'`;
935
997
  let snippetMethod = "";
936
998
  for (const pathParam of pathParams) {
937
999
  const type = ParserUtils.parseType(pathParam);
938
1000
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
939
- if (path8.match(`{${pathParam.name}}`)) {
1001
+ if (path9.match(`{${pathParam.name}}`)) {
940
1002
  if (type === "string") {
941
1003
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
942
1004
  } else {
@@ -944,9 +1006,9 @@ var templateApiMethod = ({
944
1006
  }
945
1007
  }
946
1008
  }
947
- const snippetShellArgs = ["--location --request", `${httpMethod} '__DOMAIN__${path8}'`, "--header 'accept: application/json'"];
1009
+ const snippetShellArgs = ["--location --request", `${httpMethod} '__DOMAIN__${path9}'`, "--header 'accept: application/json'"];
948
1010
  const snippetApiArgs = [];
949
- if (xSecurity !== void 0 || path8.includes("/admin")) {
1011
+ if (xSecurity !== void 0 || path9.includes("/admin")) {
950
1012
  snippetShellArgs.push("--header 'Authorization: Bearer {access_token}'");
951
1013
  snippetApiArgs.push("{ axiosConfig: { request: { headers: { Authorization: 'Bearer {access_token}' } } } }".trim());
952
1014
  }
@@ -984,7 +1046,7 @@ var templateMethod = ({
984
1046
  classMethod,
985
1047
  description,
986
1048
  httpMethod,
987
- path: path8,
1049
+ path: path9,
988
1050
  pathParams,
989
1051
  bodyParams,
990
1052
  queryParams,
@@ -994,9 +1056,9 @@ var templateMethod = ({
994
1056
  }) => {
995
1057
  let methodParams = "";
996
1058
  let methodParamsNoTypes = "";
997
- let newPath = `'${path8}'`;
1059
+ let newPath = `'${path9}'`;
998
1060
  let importStatements = [];
999
- const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path8);
1061
+ const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path9);
1000
1062
  for (const pathParam of sortedPathParams) {
1001
1063
  const type = ParserUtils.parseType(pathParam);
1002
1064
  if (pathParam.name !== "namespace") {
@@ -1004,7 +1066,7 @@ var templateMethod = ({
1004
1066
  methodParamsNoTypes += pathParam.name + ", ";
1005
1067
  }
1006
1068
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
1007
- if (path8.match(`{${pathParam.name}}`)) {
1069
+ if (path9.match(`{${pathParam.name}}`)) {
1008
1070
  if (type === "string") {
1009
1071
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
1010
1072
  } else {
@@ -1069,7 +1131,7 @@ var POST_FETCH_INCLUDES_PATH = ["/table-query/"];
1069
1131
  var templateQueryMethod = ({
1070
1132
  classMethod,
1071
1133
  httpMethod,
1072
- path: path8,
1134
+ path: path9,
1073
1135
  pathParams,
1074
1136
  responseClasses,
1075
1137
  methodParams,
@@ -1077,14 +1139,14 @@ var templateQueryMethod = ({
1077
1139
  description,
1078
1140
  deprecated
1079
1141
  }) => {
1080
- const isPostFetch = httpMethod === "post" && (POST_FETCH_INCLUDES_PATH.some((p) => path8.includes(p)) || path8.endsWith("/list"));
1142
+ const isPostFetch = httpMethod === "post" && (POST_FETCH_INCLUDES_PATH.some((p) => path9.includes(p)) || path9.endsWith("/list"));
1081
1143
  const isFetch = classMethod.startsWith("fetch");
1082
1144
  const isGet = httpMethod === "get" || isPostFetch || isFetch;
1083
1145
  const queryMethod = isGet ? "useQuery" : "useMutation";
1084
1146
  let mParams = "";
1085
1147
  let mParamsNoTypes = "";
1086
- let newPath = `'${path8}'`;
1087
- const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path8);
1148
+ let newPath = `'${path9}'`;
1149
+ const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path9);
1088
1150
  for (const pathParam of sortedPathParams) {
1089
1151
  const type = ParserUtils.parseType(pathParam);
1090
1152
  if (pathParam.name !== "namespace") {
@@ -1092,7 +1154,7 @@ var templateQueryMethod = ({
1092
1154
  mParamsNoTypes += pathParam.name + ", ";
1093
1155
  }
1094
1156
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
1095
- if (path8.match(`{${pathParam.name}}`)) {
1157
+ if (path9.match(`{${pathParam.name}}`)) {
1096
1158
  if (type === "string") {
1097
1159
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
1098
1160
  } else {
@@ -1127,7 +1189,7 @@ export const ${_methodName} = (
1127
1189
  const response =
1128
1190
  (await ${apiGenName}(sdk, { coreConfig: input.coreConfig, axiosConfig: input.axiosConfig }).
1129
1191
  ${classMethod}(${_methodParamsImpl}))
1130
- callback && callback(response)
1192
+ callback?.(response)
1131
1193
  return response.data
1132
1194
  }
1133
1195
 
@@ -1152,7 +1214,7 @@ export const ${_methodName} = (
1152
1214
  const response =
1153
1215
  (await ${apiGenName}(sdk, { coreConfig: input.coreConfig, axiosConfig: input.axiosConfig }).
1154
1216
  ${classMethod}(${_methodParamsImpl}))
1155
- callback && callback(response.data)
1217
+ callback?.(response.data)
1156
1218
  return response.data
1157
1219
  }
1158
1220
 
@@ -1331,11 +1393,11 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
1331
1393
  admin: {},
1332
1394
  public: {}
1333
1395
  };
1334
- for (const [path8, operation] of sortedPathsByLength) {
1335
- if (path8.indexOf("/healthz") >= 0) {
1396
+ for (const [path9, operation] of sortedPathsByLength) {
1397
+ if (path9.indexOf("/healthz") >= 0) {
1336
1398
  continue;
1337
1399
  }
1338
- const isAdminEndpoint = path8.indexOf("/admin/") > -1;
1400
+ const isAdminEndpoint = path9.indexOf("/admin/") > -1;
1339
1401
  const picked = isAdminEndpoint ? result.admin : result.public;
1340
1402
  const {
1341
1403
  arrayDefinitions,
@@ -1353,25 +1415,27 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
1353
1415
  const httpMethods = Object.keys(operation);
1354
1416
  for (const httpMethod of httpMethods) {
1355
1417
  const endpoint = await Endpoint.parseAsync(operation[httpMethod]).catch((error) => {
1356
- console.error(JSON.stringify({ path: path8, httpMethod }, null, 2));
1418
+ console.error(JSON.stringify({ path: path9, httpMethod }, null, 2));
1357
1419
  throw error;
1358
1420
  });
1359
1421
  if (!endpoint.tags) continue;
1360
1422
  const [tag] = endpoint.tags;
1361
- const pathWithBase = `${api.basePath ?? ""}${path8}`;
1423
+ const configBasePath = CodegenConfig.getBasePath();
1424
+ const effectiveBasePath = configBasePath !== void 0 ? configBasePath : api.basePath ?? "";
1425
+ const pathWithBase = `${effectiveBasePath}${path9}`;
1362
1426
  const permissionType = getPermissionType(getPermission(endpoint));
1363
1427
  tagToClassMethodsMapByType[tag] = tagToClassMethodsMapByType[tag] ? tagToClassMethodsMapByType[tag] : {};
1364
1428
  const isForm = endpoint.consumes && endpoint.consumes[0] === "application/x-www-form-urlencoded";
1365
1429
  const classMethod = ParserUtils.generateNaturalLangMethod({
1366
1430
  servicePrefix,
1367
- path: path8,
1431
+ path: path9,
1368
1432
  httpMethod,
1369
1433
  isForm,
1370
1434
  existingMethods: tagToClassMethodsMapByType[tag],
1371
1435
  permissionType
1372
1436
  });
1373
- tagToClassMethodsMapByType[tag][classMethod] = `${path8} ${httpMethod}`;
1374
- generatedMethods[`${path8} ${httpMethod}`] = `${classMethod}`;
1437
+ tagToClassMethodsMapByType[tag][classMethod] = `${path9} ${httpMethod}`;
1438
+ generatedMethods[`${path9} ${httpMethod}`] = `${classMethod}`;
1375
1439
  if (!snippetMap[pathWithBase]) {
1376
1440
  snippetMap[pathWithBase] = {};
1377
1441
  }
@@ -1526,6 +1590,20 @@ var TemplateZod = class {
1526
1590
  // --
1527
1591
  render = (fileName, definition, duplicates) => {
1528
1592
  this.duplicates = duplicates;
1593
+ const overrideAsAny = CodegenConfig.getOverrideAsAny();
1594
+ const override = overrideAsAny?.[fileName];
1595
+ if (override !== void 0) {
1596
+ const shouldOverride = typeof override === "function" ? override(definition) : override;
1597
+ if (shouldOverride) {
1598
+ const template2 = `import { z } from 'zod'
1599
+
1600
+ export const ${fileName} = z.any()
1601
+
1602
+ export interface ${fileName} extends z.TypeOf<typeof ${fileName}> {}
1603
+ `;
1604
+ return { buffer: template2, duplicateFound: false };
1605
+ }
1606
+ }
1529
1607
  const content = this.parseToZodSchema(definition, definition.required || []);
1530
1608
  const containsRecursiveType = this.importClasses.has(fileName);
1531
1609
  if (containsRecursiveType) {
@@ -1828,9 +1906,9 @@ var CodeGenerator = class _CodeGenerator {
1828
1906
  return;
1829
1907
  }
1830
1908
  const DIST_DIR = (isAdmin) => `${_CodeGenerator.getGeneratedFolder(isAdmin)}`;
1831
- const DIST_DIR_ENDPOINTS = (isAdmin) => import_path3.default.join(DIST_DIR(isAdmin), "endpoints");
1832
- const DIST_DIR_QUERIES = (isAdmin) => import_path3.default.join(DIST_DIR(isAdmin), "queries");
1833
- const DIST_DEFINITION_DIR = import_path3.default.join(_CodeGenerator.srcFolder(), "generated-definitions");
1909
+ const DIST_DIR_ENDPOINTS = (isAdmin) => import_path4.default.join(DIST_DIR(isAdmin), "endpoints");
1910
+ const DIST_DIR_QUERIES = (isAdmin) => import_path4.default.join(DIST_DIR(isAdmin), "queries");
1911
+ const DIST_DEFINITION_DIR = import_path4.default.join(_CodeGenerator.srcFolder(), "generated-definitions");
1834
1912
  const targetSrcFolder = `${_CodeGenerator.srcFolder()}/`;
1835
1913
  _CodeGenerator.prepareDirs(DIST_DEFINITION_DIR, DIST_DIR, DIST_DIR_ENDPOINTS, DIST_DIR_QUERIES);
1836
1914
  const mainApiList = [];
@@ -1872,22 +1950,24 @@ var CodeGenerator = class _CodeGenerator {
1872
1950
  ParserUtils.writeApiFile(DIST_DIR(isAdminEndpoint), apiGenName, apiBuffer, imports, tagToSdkFunctionDescription[tag]);
1873
1951
  apiList.push(apiGenName);
1874
1952
  indexImportsSet.add(
1875
- ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DIR_ENDPOINTS(isAdminEndpoint), `${classGenName}`), targetSrcFolder)
1953
+ ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DIR_ENDPOINTS(isAdminEndpoint), `${classGenName}`), targetSrcFolder)
1876
1954
  );
1877
1955
  indexImportsSet.add(
1878
- ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DIR(isAdminEndpoint), `${apiGenName}`), targetSrcFolder)
1956
+ ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DIR(isAdminEndpoint), `${apiGenName}`), targetSrcFolder)
1879
1957
  );
1880
1958
  queryFileName && queryImportsSet.add(
1881
1959
  ParserUtils.getRelativePathToWebSdkSrcFolder(
1882
- import_path3.default.join(DIST_DIR(isAdminEndpoint), "queries", `${queryFileName}`),
1960
+ import_path4.default.join(DIST_DIR(isAdminEndpoint), "queries", `${queryFileName}`),
1883
1961
  targetSrcFolder
1884
1962
  )
1885
1963
  );
1886
1964
  }
1887
1965
  mainApiList.push(...apiList);
1888
- indexImportsSet.add(
1889
- ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1890
- );
1966
+ if (CodegenConfig.shouldProduceIndexFile()) {
1967
+ indexImportsSet.add(
1968
+ ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1969
+ );
1970
+ }
1891
1971
  };
1892
1972
  const writeDefinitions = (api2) => {
1893
1973
  const duplicates = /* @__PURE__ */ new Map();
@@ -1895,7 +1975,7 @@ var CodeGenerator = class _CodeGenerator {
1895
1975
  for (const ref in definitions) {
1896
1976
  const definition = definitions[ref];
1897
1977
  const fileName = ParserUtils.parseRefType(ref);
1898
- const fileExist = import_fs4.default.existsSync(import_path3.default.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
1978
+ const fileExist = import_fs5.default.existsSync(import_path4.default.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
1899
1979
  if (fileExist) {
1900
1980
  const duplicateName = ParserUtils.toCamelCaseWord(ref).replace(".", "").replace(".", "");
1901
1981
  duplicates.set(ref, duplicateName);
@@ -1903,13 +1983,13 @@ var CodeGenerator = class _CodeGenerator {
1903
1983
  const { buffer } = new TemplateZod().render(fileName, definition, /* @__PURE__ */ new Map());
1904
1984
  generatedDefinitions.push(fileName);
1905
1985
  ParserUtils.writeDefinitionFile(DIST_DEFINITION_DIR, fileName, buffer);
1906
- indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DEFINITION_DIR, fileName), targetSrcFolder));
1986
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DEFINITION_DIR, fileName), targetSrcFolder));
1907
1987
  }
1908
1988
  for (const arrayClass of arrayDefinitions) {
1909
1989
  const buffer = new TemplateZodArray().render(arrayClass);
1910
1990
  generatedDefinitions.push(arrayClass);
1911
1991
  ParserUtils.writeDefinitionFile(DIST_DEFINITION_DIR, arrayClass, buffer);
1912
- indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DEFINITION_DIR, arrayClass), targetSrcFolder));
1992
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DEFINITION_DIR, arrayClass), targetSrcFolder));
1913
1993
  }
1914
1994
  };
1915
1995
  writeApiEndpointFiles(isAdmin);
@@ -1917,9 +1997,11 @@ var CodeGenerator = class _CodeGenerator {
1917
1997
  };
1918
1998
  generatePublicOrAdmin(true);
1919
1999
  generatePublicOrAdmin(false);
1920
- const isGenerateWebSocket = CliParser.isGenerateWebSocket();
1921
- const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
1922
- ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
2000
+ if (CodegenConfig.shouldProduceIndexFile()) {
2001
+ const isGenerateWebSocket = CliParser.isGenerateWebSocket();
2002
+ const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
2003
+ ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
2004
+ }
1923
2005
  console.log("\nCOMPLETED\n----------\n\n");
1924
2006
  return { indexImports: indexImportsSet, queryImports: queryImportsSet };
1925
2007
  };
@@ -1927,29 +2009,29 @@ var CodeGenerator = class _CodeGenerator {
1927
2009
  };
1928
2010
 
1929
2011
  // src/SwaggerDownloader.ts
2012
+ var fs6 = __toESM(require("fs"));
1930
2013
  var https = __toESM(require("https"));
1931
- var fs5 = __toESM(require("fs"));
1932
- var path5 = __toESM(require("path"));
2014
+ var path6 = __toESM(require("path"));
1933
2015
  var SwaggerDownloader = class _SwaggerDownloader {
1934
2016
  static getDestFile = (targetFileName) => {
1935
2017
  const destPath = CliParser.getResolvedSwaggersOutputPath();
1936
- const destFile = path5.join(destPath, targetFileName);
1937
- if (fs5.existsSync(destFile)) return destFile;
1938
- if (!fs5.existsSync(destPath)) fs5.mkdirSync(destPath);
1939
- fs5.writeFileSync(destFile, "");
2018
+ const destFile = path6.join(destPath, targetFileName);
2019
+ if (fs6.existsSync(destFile)) return destFile;
2020
+ if (!fs6.existsSync(destPath)) fs6.mkdirSync(destPath);
2021
+ fs6.writeFileSync(destFile, "");
1940
2022
  return destFile;
1941
2023
  };
1942
2024
  // session-api.json contains illegal URL encoded character that breaks the codegen
1943
2025
  // e.g. "$ref": "#/definitions/map%5Bstring%5Dinterface%20%7B%7D"
1944
2026
  static postSanitizeDownloadedFile = (filePath) => {
1945
2027
  const searchStr = ["%5B", "%5D", "%20", "%7B", "%7D"];
1946
- fs5.readFile(filePath, "utf8", (err, data) => {
2028
+ fs6.readFile(filePath, "utf8", (err, data) => {
1947
2029
  if (err) throw err;
1948
2030
  let result = data;
1949
2031
  searchStr.forEach((s) => {
1950
2032
  result = result.replace(new RegExp(s, "g"), " ");
1951
2033
  });
1952
- fs5.writeFile(filePath, result, "utf8", (err2) => {
2034
+ fs6.writeFile(filePath, result, "utf8", (err2) => {
1953
2035
  if (err2) throw err2;
1954
2036
  console.log("File updated successfully.");
1955
2037
  });
@@ -1967,7 +2049,7 @@ var SwaggerDownloader = class _SwaggerDownloader {
1967
2049
  if (response.statusCode !== 200) {
1968
2050
  console.log(`SwaggerDownload error with status code: ${response.statusCode}`);
1969
2051
  } else {
1970
- fs5.writeFileSync(destFile, JSON.stringify(JSON.parse(data), null, 2), "utf-8");
2052
+ fs6.writeFileSync(destFile, JSON.stringify(JSON.parse(data), null, 2), "utf-8");
1971
2053
  _SwaggerDownloader.postSanitizeDownloadedFile(destFile);
1972
2054
  console.log(`SwaggerDownload ${url} completed with status code: ${response.statusCode}`);
1973
2055
  }
@@ -1990,8 +2072,8 @@ var SwaggerDownloader = class _SwaggerDownloader {
1990
2072
  };
1991
2073
 
1992
2074
  // src/WebsocketGenerator.ts
1993
- var import_fs5 = __toESM(require("fs"));
1994
- var import_path4 = __toESM(require("path"));
2075
+ var import_fs6 = __toESM(require("fs"));
2076
+ var import_path5 = __toESM(require("path"));
1995
2077
 
1996
2078
  // src/templates/template-ws-class.ts
1997
2079
  var definitionToFunctionName = (type) => {
@@ -2006,7 +2088,7 @@ var renderSendFunction = (name, definition) => {
2006
2088
  send({ type: '${name}', ...data })
2007
2089
  }`;
2008
2090
  };
2009
- var templateWebsocketClass = (name, path8, definitions) => {
2091
+ var templateWebsocketClass = (name, path9, definitions) => {
2010
2092
  const requestDefinitions = Object.keys(definitions).filter((key) => {
2011
2093
  const val = definitions[key];
2012
2094
  return val["x-type"] == "request";
@@ -2065,7 +2147,7 @@ const messageSerializer = (data: Record<string, any>) => {
2065
2147
  export function WebSocketClass(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
2066
2148
  const sdkAssembly = sdk.assembly()
2067
2149
  const baseURL = (args?.coreConfig?.baseURL ?? sdkAssembly.coreConfig.baseURL).replace('http', 'ws')
2068
- const path = '${path8}'
2150
+ const path = '${path9}'
2069
2151
  const url = baseURL + path
2070
2152
  let ws: WebSocket | null = null
2071
2153
  let isDisconnectManually = false
@@ -2314,9 +2396,9 @@ ${renderUnion(["response", "notification"], definitions)}
2314
2396
  // src/WebsocketGenerator.ts
2315
2397
  var WebsocketGenerator = class {
2316
2398
  static srcFolder = () => CliParser.getOutputPath();
2317
- static outputFolder = () => import_path4.default.join(this.srcFolder(), "generated-websocket");
2399
+ static outputFolder = () => import_path5.default.join(this.srcFolder(), "generated-websocket");
2318
2400
  static schemaContent = () => {
2319
- const fileContent = JSON.parse(import_fs5.default.readFileSync(CliParser.getWebSocketSchemaPath(), "utf8"));
2401
+ const fileContent = JSON.parse(import_fs6.default.readFileSync(CliParser.getWebSocketSchemaPath(), "utf8"));
2320
2402
  return fileContent;
2321
2403
  };
2322
2404
  static prepareDirs = () => {
@@ -2326,11 +2408,11 @@ var WebsocketGenerator = class {
2326
2408
  const { name, path: wsPath, definitions } = this.schemaContent();
2327
2409
  const templateDefinitions = templateWebsocketDefinitions(definitions);
2328
2410
  this.prepareDirs();
2329
- const filePath = import_path4.default.join(this.outputFolder(), "WebSocketDefinitions.ts");
2330
- import_fs5.default.writeFileSync(filePath, templateDefinitions, "utf8");
2411
+ const filePath = import_path5.default.join(this.outputFolder(), "WebSocketDefinitions.ts");
2412
+ import_fs6.default.writeFileSync(filePath, templateDefinitions, "utf8");
2331
2413
  const templateClass2 = templateWebsocketClass(name, wsPath, definitions);
2332
- const filePathClass = import_path4.default.join(this.outputFolder(), "WebSocketClass.ts");
2333
- import_fs5.default.writeFileSync(filePathClass, templateClass2, "utf8");
2414
+ const filePathClass = import_path5.default.join(this.outputFolder(), "WebSocketClass.ts");
2415
+ import_fs6.default.writeFileSync(filePathClass, templateClass2, "utf8");
2334
2416
  };
2335
2417
  };
2336
2418
 
@@ -2348,19 +2430,20 @@ var generateSdk = async () => {
2348
2430
  const filenamesSet = /* @__PURE__ */ new Set();
2349
2431
  for (const set of arrayOfSets) {
2350
2432
  set.indexImports.forEach((value) => {
2351
- const fileName = import_path5.default.basename(value);
2433
+ const fileName = import_path6.default.basename(value);
2352
2434
  if (!filenamesSet.has(fileName)) {
2353
2435
  indexImportsSet.add(value);
2354
2436
  filenamesSet.add(fileName);
2355
2437
  }
2356
2438
  });
2357
2439
  set.queryImports.forEach((value) => {
2358
- const fileName = import_path5.default.basename(value);
2440
+ const fileName = import_path6.default.basename(value);
2359
2441
  if (!filenamesSet.has(fileName)) {
2360
2442
  queryImportsSet.add(value);
2361
2443
  }
2362
2444
  });
2363
2445
  }
2446
+ const outputPath = CliParser.getOutputPath();
2364
2447
  const indexImportsArray = Array.from(indexImportsSet).sort();
2365
2448
  const queryImportsArray = Array.from(queryImportsSet).sort();
2366
2449
  const filesToImport = indexImportsArray.map((fileToImport) => {
@@ -2369,8 +2452,8 @@ var generateSdk = async () => {
2369
2452
  const queryFilesToImport = queryImportsArray.map((fileToImport) => {
2370
2453
  return `export * from '${fileToImport.replace("\\", "/")}.js'`;
2371
2454
  });
2372
- ParserUtils.writeAllImportsFile(CliParser.getOutputPath(), filesToImport.join("\n"));
2373
- ParserUtils.writeAllQueryImportsFile(CliParser.getOutputPath(), queryFilesToImport.join("\n"));
2455
+ ParserUtils.writeAllImportsFile(outputPath, filesToImport.join("\n"));
2456
+ ParserUtils.writeAllQueryImportsFile(outputPath, queryFilesToImport.join("\n"));
2374
2457
  };
2375
2458
  import_yargs.default.command("download-swaggers", "Download swaggers JSON files", (yargs2) => {
2376
2459
  CliParser.createInstance(yargs2);
@@ -2386,6 +2469,7 @@ import_yargs.default.command("download-swaggers", "Download swaggers JSON files"
2386
2469
  return true;
2387
2470
  });
2388
2471
  CliParser.createInstance(yargs2);
2472
+ await CodegenConfig.loadConfig(import_path6.default.dirname(import_path6.default.resolve(CliParser.getConfigPath())));
2389
2473
  await generateSdk();
2390
2474
  }).option("config", {
2391
2475
  description: "Path to the config file with backend service URLs.",