@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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
- import path7 from "path";
4
+ import path8 from "path";
5
5
  import yargs from "yargs";
6
6
 
7
7
  // src/CliParser.ts
@@ -65,18 +65,52 @@ var CliParser = class _CliParser {
65
65
 
66
66
  // src/CodeGenerator.ts
67
67
  import SwaggerParser from "@apidevtools/swagger-parser";
68
- import fs4 from "fs";
69
- import path4 from "path";
68
+ import fs5 from "fs";
69
+ import path5 from "path";
70
+
71
+ // src/CodegenConfig.ts
72
+ import fs2 from "fs";
73
+ import path2 from "path";
74
+ import { pathToFileURL } from "url";
75
+ var CodegenConfig = class _CodegenConfig {
76
+ static config = {};
77
+ static async loadConfig(configDir) {
78
+ const configPath = path2.join(configDir, "abcodegen.config.ts");
79
+ if (!fs2.existsSync(configPath)) {
80
+ _CodegenConfig.config = {};
81
+ return;
82
+ }
83
+ const loaded = await import(pathToFileURL(configPath).href);
84
+ _CodegenConfig.config = loaded.default ?? loaded ?? {};
85
+ }
86
+ static shouldProduceIndexFile() {
87
+ return _CodegenConfig.config.unstable_shouldProduceIndexFile ?? true;
88
+ }
89
+ static getBasePath() {
90
+ return _CodegenConfig.config.basePath;
91
+ }
92
+ static getOverrideAsAny() {
93
+ return _CodegenConfig.config.unstable_overrideAsAny;
94
+ }
95
+ /** Reset to defaults — used for testing */
96
+ static reset() {
97
+ _CodegenConfig.config = {};
98
+ }
99
+ /** Set config directly — used for testing */
100
+ static setConfig(config) {
101
+ _CodegenConfig.config = config;
102
+ }
103
+ };
70
104
 
71
105
  // src/ParserUtils.ts
72
106
  import { applyPatch } from "fast-json-patch";
73
- import fs3 from "fs";
107
+ import fs4 from "fs";
74
108
  import _ from "lodash";
75
- import path3 from "path";
109
+ import path4 from "path";
76
110
 
77
111
  // src/helpers/utils.ts
78
- import fs2 from "fs";
79
- import path2 from "path";
112
+ import fs3 from "fs";
113
+ import path3 from "path";
80
114
  var capitalize = (string) => {
81
115
  return string.charAt(0).toUpperCase() + string.slice(1);
82
116
  };
@@ -153,10 +187,10 @@ var getImportableVarMap = () => ({
153
187
  zod: ["z"]
154
188
  });
155
189
  var makeNewImportVarMap = () => ({
156
- axios: ["AxiosInstance", "AxiosRequestConfig"],
157
- "@accelbyte/sdk": ["SDKRequestConfig"]
190
+ axios: ["AxiosInstance", "AxiosRequestConfig"]
158
191
  });
159
- var generateImports = (body, importStatements, makeNewImportVarMap3, getImportableVarMap3) => {
192
+ var CLASS_TYPE_ONLY_VARS = /* @__PURE__ */ new Set(["AxiosInstance", "AxiosRequestConfig", "AxiosResponse", "SdkSetConfigParam", "Response"]);
193
+ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportableVarMap3, typeOnlyVars = /* @__PURE__ */ new Set()) => {
160
194
  const usedImportVarMap = makeNewImportVarMap3;
161
195
  const importableVarMap = getImportableVarMap3;
162
196
  for (const [moduleSource, importableVars] of Object.entries(importableVarMap)) {
@@ -167,9 +201,19 @@ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportab
167
201
  }
168
202
  }
169
203
  }
170
- const generatedImports = Object.keys(usedImportVarMap).sort().map((moduleSource) => {
171
- return `import { ${usedImportVarMap[moduleSource].sort().join(", ")} } from '${moduleSource}'`;
172
- }).join("\n");
204
+ const importLines = [];
205
+ for (const moduleSource of Object.keys(usedImportVarMap).sort()) {
206
+ const allVars = usedImportVarMap[moduleSource];
207
+ const valueVars = allVars.filter((v) => !typeOnlyVars.has(v)).sort();
208
+ const typeVars = allVars.filter((v) => typeOnlyVars.has(v)).sort();
209
+ if (valueVars.length > 0) {
210
+ importLines.push(`import { ${valueVars.join(", ")} } from '${moduleSource}'`);
211
+ }
212
+ if (typeVars.length > 0) {
213
+ importLines.push(`import type { ${typeVars.join(", ")} } from '${moduleSource}'`);
214
+ }
215
+ }
216
+ const generatedImports = importLines.join("\n");
173
217
  return `${generatedImports}
174
218
  ${importStatements.sort().join("\n")}`;
175
219
  };
@@ -177,11 +221,9 @@ var templateClass = (className, body, importStatements) => {
177
221
  return `/**
178
222
  * AUTO GENERATED
179
223
  */
180
- ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap())}
224
+ ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap(), CLASS_TYPE_ONLY_VARS)}
181
225
 
182
226
  export class ${className} {
183
- // @ts-ignore
184
- // prettier-ignore
185
227
  constructor(private axiosInstance: AxiosInstance, private namespace: string, private useSchemaValidation = true) {}
186
228
  ${body}
187
229
  }
@@ -197,6 +239,15 @@ var makeNewImportVarMap2 = () => ({
197
239
  "@accelbyte/sdk": ["AccelByteSDK", "SdkSetConfigParam", "ApiUtils", "Network"],
198
240
  axios: ["AxiosRequestConfig", "AxiosResponse"]
199
241
  });
242
+ var API_TYPE_ONLY_VARS = /* @__PURE__ */ new Set([
243
+ "AxiosRequestConfig",
244
+ "AxiosResponse",
245
+ "AxiosDefaults",
246
+ "HeadersDefaults",
247
+ "AccelByteSDK",
248
+ "SdkSetConfigParam",
249
+ "Response"
250
+ ]);
200
251
  var templateApiClass = (className, body, importStatements, returnMethods) => {
201
252
  const returnsMethodsWithDescription = Object.keys(returnMethods).reduce((acc, key) => {
202
253
  acc += `
@@ -208,43 +259,45 @@ ${key},`;
208
259
  return `/**
209
260
  * AUTO GENERATED
210
261
  */
211
- /* eslint-disable camelcase */
212
- // @ts-ignore -> ts-expect-error TS6133
213
- ${generateImports(body, importStatements, makeNewImportVarMap2(), getImportableVarMap2())}
262
+ ${generateImports(body, importStatements, makeNewImportVarMap2(), getImportableVarMap2(), API_TYPE_ONLY_VARS)}
214
263
  ${`import { ${$className} } from './endpoints/${$className}.js'
215
264
  `}
216
265
 
217
266
  export function ${className}(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
218
267
  const sdkAssembly = sdk.assembly()
219
-
268
+
220
269
  const namespace = args?.coreConfig?.namespace ?? sdkAssembly.coreConfig.namespace
221
270
  const useSchemaValidation = args?.coreConfig?.useSchemaValidation ?? sdkAssembly.coreConfig.useSchemaValidation
222
-
271
+
223
272
  let axiosInstance = sdkAssembly.axiosInstance
224
273
  const requestConfigOverrides = args?.axiosConfig?.request
225
274
  const baseURLOverride = args?.coreConfig?.baseURL
226
- const interceptorsOverride = args?.axiosConfig?.interceptors ?? []
275
+ const interceptorsOverride = args?.axiosConfig?.interceptors
227
276
 
228
- if (requestConfigOverrides || baseURLOverride || interceptorsOverride.length > 0) {
277
+ if (requestConfigOverrides || baseURLOverride || interceptorsOverride) {
229
278
  const requestConfig = ApiUtils.mergeAxiosConfigs(sdkAssembly.axiosInstance.defaults as AxiosRequestConfig, {
230
279
  ...(baseURLOverride ? { baseURL: baseURLOverride } : {}),
231
280
  ...requestConfigOverrides
232
281
  })
233
282
  axiosInstance = Network.create(requestConfig)
234
283
 
235
- for (const interceptor of interceptorsOverride) {
236
- if (interceptor.type === 'request') {
237
- axiosInstance.interceptors.request.use(interceptor.onRequest, interceptor.onError)
238
- }
284
+ if (interceptorsOverride) {
285
+ for (const interceptor of interceptorsOverride) {
286
+ if (interceptor.type === 'request') {
287
+ axiosInstance.interceptors.request.use(interceptor.onRequest, interceptor.onError)
288
+ }
239
289
 
240
- if (interceptor.type === 'response') {
241
- axiosInstance.interceptors.response.use(interceptor.onSuccess, interceptor.onError)
290
+ if (interceptor.type === 'response') {
291
+ axiosInstance.interceptors.response.use(interceptor.onSuccess, interceptor.onError)
292
+ }
242
293
  }
294
+ } else {
295
+ axiosInstance.interceptors = sdkAssembly.axiosInstance.interceptors
243
296
  }
244
297
  }
245
298
 
246
299
  ${body}
247
-
300
+
248
301
  return {
249
302
  ${returnsMethodsWithDescription}
250
303
  }
@@ -255,7 +308,7 @@ export function ${className}(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
255
308
  // src/ParserQueryUtils.ts
256
309
  var ParserQueryUtils = class {
257
310
  /**
258
- * convert csv 'aa,bb' into "aa='aa', bb='bb'"
311
+ * convert csv 'aa,bb' into "aa = 'Sdk.Class.aa', bb = 'Sdk.Class.bb'"
259
312
  */
260
313
  static createQueryKeys(classNameWithoutApi, csvMethodNames, sdkName) {
261
314
  const keys = csvMethodNames.split(",");
@@ -266,7 +319,7 @@ var ParserQueryUtils = class {
266
319
  const cleanedKey = trimmedKey.replace(/^(get|update|create|patch|delete|post|fetch)[_]?/, "");
267
320
  if (!processedKeys.has(cleanedKey)) {
268
321
  processedKeys.add(cleanedKey);
269
- acc += `${cleanedKey} = '${capitalize(sdkName)}.${classNameWithoutApi}.${cleanedKey}'`;
322
+ acc += `${cleanedKey}: '${capitalize(sdkName)}.${classNameWithoutApi}.${cleanedKey}'`;
270
323
  if (index < keys.length - 1) {
271
324
  acc += ",\n";
272
325
  }
@@ -280,42 +333,51 @@ var ParserQueryUtils = class {
280
333
 
281
334
  // src/templates/template-query.ts
282
335
  var generateImports2 = (body, className) => {
283
- const generatedImports = `import { AccelByteSDK, SdkSetConfigParam, ApiError } from '@accelbyte/sdk'
284
- import { AxiosError, AxiosResponse } from 'axios'
285
- // @ts-ignore
286
- import { useQuery, UseQueryOptions, UseQueryResult, useMutation, UseMutationOptions, UseMutationResult } from '@tanstack/react-query'
287
- import { ${className} } from "../${className}.js"
288
- `;
289
- return generatedImports;
336
+ const lines = [];
337
+ lines.push("import type { AccelByteSDK, ApiError, SdkSetConfigParam } from '@accelbyte/sdk'");
338
+ const axiosTypes = ["AxiosError", "AxiosResponse"].filter((t) => body.includes(t));
339
+ if (axiosTypes.length) {
340
+ lines.push(`import type { ${axiosTypes.join(", ")} } from 'axios'`);
341
+ }
342
+ const rqValues = ["useMutation", "useQuery"].filter((t) => body.includes(t));
343
+ if (rqValues.length) {
344
+ lines.push(`import { ${rqValues.join(", ")} } from '@tanstack/react-query'`);
345
+ }
346
+ const rqTypes = ["UseMutationOptions", "UseMutationResult", "UseQueryOptions", "UseQueryResult"].filter((t) => body.includes(t));
347
+ if (rqTypes.length) {
348
+ lines.push(`import type { ${rqTypes.join(", ")} } from '@tanstack/react-query'`);
349
+ }
350
+ lines.push(`import { ${className} } from "../${className}.js"`);
351
+ return lines.join("\n") + "\n";
290
352
  };
291
353
  var templateQuery = (className, body, importStatements, serviceNameTitle, returnMethods, paramImports, sdkName) => {
292
354
  const classNameWithoutApi = className.replace("Api", "");
293
355
  const queryKeys = ParserQueryUtils.createQueryKeys(classNameWithoutApi, returnMethods, sdkName);
294
356
  const generatedImports = generateImports2(body, className);
357
+ const queryKeyBlock = `export const Key_${classNameWithoutApi} = {
358
+ ${queryKeys}
359
+ } as const`;
295
360
  return `/**
296
361
  * AUTO GENERATED
297
362
  */
298
- /* eslint-disable camelcase */
299
363
  ${generatedImports}
300
364
  ${filterUsedImports(paramImports, body)}
301
365
 
302
- export enum Key_${classNameWithoutApi} {
303
- ${queryKeys}
304
- }
366
+ ${queryKeyBlock}
305
367
 
306
368
  ${body}
307
369
  `;
308
370
  };
309
371
  function filterUsedImports(importArr, body) {
310
- return importArr.filter((path8) => {
311
- const start = path8.indexOf("{") + 1;
312
- const end = path8.indexOf("}");
372
+ return importArr.filter((path9) => {
373
+ const start = path9.indexOf("{") + 1;
374
+ const end = path9.indexOf("}");
313
375
  if (start > 0 && end > start) {
314
- const importName = path8.slice(start, end).trim();
376
+ const importName = path9.slice(start, end).trim();
315
377
  return body.includes(importName);
316
378
  }
317
379
  return false;
318
- }).map((path8) => path8).join("\n") + "\n";
380
+ }).map((path9) => path9).join("\n") + "\n";
319
381
  }
320
382
 
321
383
  // src/ParserUtils.ts
@@ -332,8 +394,8 @@ var REMOVED_KEYWORDS = [
332
394
  "/{namespace}/"
333
395
  ];
334
396
  var ParserUtils = class _ParserUtils {
335
- static getVersionSuffixFromPath(path8) {
336
- const version2_3_4_etc = path8.match(/\/v([2-9]|[1-9]\d+)\/+/);
397
+ static getVersionSuffixFromPath(path9) {
398
+ const version2_3_4_etc = path9.match(/\/v([2-9]|[1-9]\d+)\/+/);
337
399
  const methodSuffix = version2_3_4_etc ? `_v${version2_3_4_etc[1]}` : "";
338
400
  return methodSuffix;
339
401
  }
@@ -528,14 +590,14 @@ var ParserUtils = class _ParserUtils {
528
590
  * to this
529
591
  * `createGenerateByRequestIdByUserId`
530
592
  */
531
- static generateNaturalLangMethod = ({ servicePrefix, path: path8, httpMethod, isForm, existingMethods, permissionType }) => {
532
- let path_ = path8;
593
+ static generateNaturalLangMethod = ({ servicePrefix, path: path9, httpMethod, isForm, existingMethods, permissionType }) => {
594
+ let path_ = path9;
533
595
  path_ = path_.replace(`/${servicePrefix}/`, "/");
534
596
  REMOVED_KEYWORDS.forEach((prefix) => {
535
597
  path_ = path_.replace(prefix, "/");
536
598
  });
537
599
  path_ = path_.substring(1);
538
- const isPlural = httpMethod === "get" && !(path8.slice(-1) === "}");
600
+ const isPlural = httpMethod === "get" && !(path9.slice(-1) === "}");
539
601
  if (!isPlural) {
540
602
  path_ = _ParserUtils.replaceAll(path_, "ies/", "y/");
541
603
  path_ = _ParserUtils.replaceAll(path_, "s/", "/");
@@ -578,9 +640,9 @@ var ParserUtils = class _ParserUtils {
578
640
  const genPath = _.upperFirst(lastWords) + "/" + listBeforeLastWords.join("/") + listByParams.reverse().join("/");
579
641
  let generatedMethod = _.camelCase(mappedMethod(httpMethod, isForm, permissionType) + genPath);
580
642
  generatedMethod = _ParserUtils.replaceAll(generatedMethod, "Byword", "_By");
581
- const testedGeneratedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path8);
582
- generatedMethod = resolveConflicts({ path: path8, generatedMethod, testedGeneratedMethod, existingMethods });
583
- generatedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path8);
643
+ const testedGeneratedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path9);
644
+ generatedMethod = resolveConflicts({ path: path9, generatedMethod, testedGeneratedMethod, existingMethods });
645
+ generatedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path9);
584
646
  return generatedMethod;
585
647
  };
586
648
  static filterBodyParams(parameters) {
@@ -596,17 +658,17 @@ var ParserUtils = class _ParserUtils {
596
658
  return parameters.filter((parameter) => parameter.in === "query");
597
659
  }
598
660
  static mkdirIfNotExist(dirToCreate) {
599
- if (!fs3.existsSync(dirToCreate)) {
600
- fs3.mkdirSync(dirToCreate, { recursive: true });
661
+ if (!fs4.existsSync(dirToCreate)) {
662
+ fs4.mkdirSync(dirToCreate, { recursive: true });
601
663
  }
602
664
  }
603
665
  static writeClassFile(distDir, apiName, apiBuffer, imports) {
604
666
  const fileContent = templateClass(apiName, apiBuffer, imports);
605
- fs3.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
667
+ fs4.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
606
668
  }
607
669
  static writeAtomFile(distDir, apiName, fileContent) {
608
670
  _ParserUtils.mkdirIfNotExist(distDir);
609
- fs3.writeFileSync(`${distDir}/${apiName}.atom.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
671
+ fs4.writeFileSync(`${distDir}/${apiName}.atom.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
610
672
  }
611
673
  static writeQueryFile(distDir, apiName, apiBuffer, imports, serviceNameTitle, returnMethods, paramImports, sdkName) {
612
674
  if (apiBuffer.length < 1) {
@@ -615,20 +677,20 @@ var ParserUtils = class _ParserUtils {
615
677
  const queryFileName = `${apiName.replace("Api", "")}.query`;
616
678
  _ParserUtils.mkdirIfNotExist(distDir);
617
679
  const fileContent = templateQuery(apiName, apiBuffer, imports, serviceNameTitle, returnMethods, paramImports, sdkName);
618
- fs3.writeFileSync(`${distDir}/${queryFileName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
680
+ fs4.writeFileSync(`${distDir}/${queryFileName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
619
681
  return queryFileName;
620
682
  }
621
683
  static writeXVersion(distDir, xversionJson, apiInfo) {
622
684
  if (xversionJson) {
623
685
  console.log("x-version:", xversionJson);
624
- fs3.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
686
+ fs4.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
625
687
  } else {
626
688
  const customVersion = {
627
689
  ...apiInfo,
628
690
  gitHash: apiInfo.version
629
691
  };
630
692
  console.error(`!!!! Missing x-version for ${distDir} ${customVersion}`);
631
- fs3.writeFileSync(`${distDir}/version.json`, JSON.stringify(customVersion, null, 2));
693
+ fs4.writeFileSync(`${distDir}/version.json`, JSON.stringify(customVersion, null, 2));
632
694
  }
633
695
  }
634
696
  static writeApiFile(distDir, apiName, apiBuffer, imports, returnMethodsDescription) {
@@ -637,28 +699,28 @@ var ParserUtils = class _ParserUtils {
637
699
  newImports.push(el.replace("../../generated-definitions", "../generated-definitions"));
638
700
  });
639
701
  const fileContent = templateApiClass(apiName, apiBuffer, newImports, returnMethodsDescription);
640
- fs3.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
702
+ fs4.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
641
703
  }
642
704
  static writeApiMainFile(distDir, serviceName, fileContent) {
643
- fs3.writeFileSync(`${distDir}/${serviceName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
705
+ fs4.writeFileSync(`${distDir}/${serviceName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
644
706
  }
645
707
  static writeSnippetFile(distDir, name, docBuffer) {
646
708
  let snippetFileName = _ParserUtils.replaceAll(name, " ", "-").toLowerCase();
647
709
  snippetFileName = snippetFileName.replace("justice-", "");
648
710
  snippetFileName = "snippet-" + snippetFileName + ".json";
649
- fs3.writeFileSync(`${distDir}/${snippetFileName}`, docBuffer);
711
+ fs4.writeFileSync(`${distDir}/${snippetFileName}`, docBuffer);
650
712
  }
651
713
  static writeDefinitionFile(distDir, name, buffer) {
652
714
  _ParserUtils.mkdirIfNotExist(distDir);
653
- fs3.writeFileSync(path3.join(distDir, `${name}.ts`), _ParserUtils.prependCopyrightHeader(buffer));
715
+ fs4.writeFileSync(path4.join(distDir, `${name}.ts`), _ParserUtils.prependCopyrightHeader(buffer));
654
716
  }
655
717
  static writeAllImportsFile(distDir, buffer) {
656
718
  _ParserUtils.mkdirIfNotExist(distDir);
657
- fs3.writeFileSync(path3.join(distDir, "all-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
719
+ fs4.writeFileSync(path4.join(distDir, "all-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
658
720
  }
659
721
  static writeAllQueryImportsFile(distDir, buffer) {
660
722
  _ParserUtils.mkdirIfNotExist(distDir);
661
- fs3.writeFileSync(path3.join(distDir, "all-query-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
723
+ fs4.writeFileSync(path4.join(distDir, "all-query-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
662
724
  }
663
725
  static toCamelCase(str) {
664
726
  return str.split("/").map(function(word, index) {
@@ -684,15 +746,15 @@ var ParserUtils = class _ParserUtils {
684
746
  });
685
747
  }
686
748
  static applyPatchIfExists(swaggerFilePath, possibleSwaggerPatchFilePath, swaggerPatchedFilePath, swaggerPatchedDir) {
687
- if (!fs3.existsSync(swaggerPatchedDir)) {
688
- fs3.mkdirSync(swaggerPatchedDir, { recursive: true });
749
+ if (!fs4.existsSync(swaggerPatchedDir)) {
750
+ fs4.mkdirSync(swaggerPatchedDir, { recursive: true });
689
751
  }
690
- if (!fs3.existsSync(possibleSwaggerPatchFilePath)) {
691
- fs3.copyFileSync(swaggerFilePath, swaggerPatchedFilePath);
752
+ if (!fs4.existsSync(possibleSwaggerPatchFilePath)) {
753
+ fs4.copyFileSync(swaggerFilePath, swaggerPatchedFilePath);
692
754
  return;
693
755
  }
694
- const swaggerContent = JSON.parse(fs3.readFileSync(swaggerFilePath, "utf8"));
695
- const swaggerPatchFileContent = JSON.parse(fs3.readFileSync(possibleSwaggerPatchFilePath, "utf8"));
756
+ const swaggerContent = JSON.parse(fs4.readFileSync(swaggerFilePath, "utf8"));
757
+ const swaggerPatchFileContent = JSON.parse(fs4.readFileSync(possibleSwaggerPatchFilePath, "utf8"));
696
758
  for (const patchEntry of swaggerPatchFileContent) {
697
759
  const segments = patchEntry.path.split("/").filter(Boolean);
698
760
  let currentNode = swaggerContent;
@@ -720,7 +782,7 @@ var ParserUtils = class _ParserUtils {
720
782
  }
721
783
  }
722
784
  const { newDocument } = applyPatch(swaggerContent, swaggerPatchFileContent);
723
- fs3.writeFileSync(swaggerPatchedFilePath, JSON.stringify(newDocument, null, 2));
785
+ fs4.writeFileSync(swaggerPatchedFilePath, JSON.stringify(newDocument, null, 2));
724
786
  }
725
787
  static getRelativePathToWebSdkSrcFolder(srcFolder, targetSrcFolder) {
726
788
  const replaced = srcFolder.replace(/\\/g, "/");
@@ -735,8 +797,8 @@ var ParserUtils = class _ParserUtils {
735
797
  */
736
798
  ${content}`;
737
799
  };
738
- static sortPathParamsByPath = (pathParams, path8) => {
739
- const params = path8.match(/{\w*}/g) || [];
800
+ static sortPathParamsByPath = (pathParams, path9) => {
801
+ const params = path9.match(/{\w*}/g) || [];
740
802
  const cleanParams = params.map((param) => param.replace("{", "").replace("}", ""));
741
803
  return pathParams.sort((a, b) => cleanParams.indexOf(a.name) - cleanParams.indexOf(b.name));
742
804
  };
@@ -760,30 +822,30 @@ var mappedMethod = (httpMethod, isForm, permissionType) => {
760
822
  return "delete";
761
823
  }
762
824
  };
763
- var resolveConflicts = ({ path: path8, generatedMethod, testedGeneratedMethod, existingMethods }) => {
825
+ var resolveConflicts = ({ path: path9, generatedMethod, testedGeneratedMethod, existingMethods }) => {
764
826
  let _testedGenMethod = testedGeneratedMethod;
765
827
  try {
766
- testConflict(path8, _testedGenMethod, existingMethods);
828
+ testConflict(path9, _testedGenMethod, existingMethods);
767
829
  } catch (e) {
768
- if (path8.indexOf("/namespaces/") >= 0) {
830
+ if (path9.indexOf("/namespaces/") >= 0) {
769
831
  generatedMethod += "_ByNS";
770
832
  _testedGenMethod += "_ByNS";
771
833
  }
772
834
  }
773
835
  try {
774
- testConflict(path8, _testedGenMethod, existingMethods);
836
+ testConflict(path9, _testedGenMethod, existingMethods);
775
837
  } catch (e) {
776
- if (path8.indexOf("/admin/") >= 0) {
838
+ if (path9.indexOf("/admin/") >= 0) {
777
839
  generatedMethod += "_admin";
778
840
  _testedGenMethod += "_admin";
779
841
  }
780
842
  }
781
- testConflict(path8, _testedGenMethod, existingMethods);
843
+ testConflict(path9, _testedGenMethod, existingMethods);
782
844
  return generatedMethod;
783
845
  };
784
- var testConflict = (path8, generatedMethod, existingMethods) => {
846
+ var testConflict = (path9, generatedMethod, existingMethods) => {
785
847
  if (existingMethods[generatedMethod]) {
786
- const conflictingMethod = { path: path8, generatedMethod };
848
+ const conflictingMethod = { path: path9, generatedMethod };
787
849
  throw Error(
788
850
  `Duplicate method conflict in ${JSON.stringify(conflictingMethod)},
789
851
  existingMethods: ${JSON.stringify(existingMethods, null, 2)}`
@@ -900,7 +962,7 @@ var OpenApiSpec = z2.object({
900
962
  var templateApiMethod = ({
901
963
  classMethod,
902
964
  httpMethod,
903
- path: path8,
965
+ path: path9,
904
966
  pathParams,
905
967
  bodyParams,
906
968
  responseClasses,
@@ -909,12 +971,12 @@ var templateApiMethod = ({
909
971
  methodParamsNoTypes,
910
972
  xSecurity
911
973
  }) => {
912
- let newPath = `'${path8}'`;
974
+ let newPath = `'${path9}'`;
913
975
  let snippetMethod = "";
914
976
  for (const pathParam of pathParams) {
915
977
  const type = ParserUtils.parseType(pathParam);
916
978
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
917
- if (path8.match(`{${pathParam.name}}`)) {
979
+ if (path9.match(`{${pathParam.name}}`)) {
918
980
  if (type === "string") {
919
981
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
920
982
  } else {
@@ -922,9 +984,9 @@ var templateApiMethod = ({
922
984
  }
923
985
  }
924
986
  }
925
- const snippetShellArgs = ["--location --request", `${httpMethod} '__DOMAIN__${path8}'`, "--header 'accept: application/json'"];
987
+ const snippetShellArgs = ["--location --request", `${httpMethod} '__DOMAIN__${path9}'`, "--header 'accept: application/json'"];
926
988
  const snippetApiArgs = [];
927
- if (xSecurity !== void 0 || path8.includes("/admin")) {
989
+ if (xSecurity !== void 0 || path9.includes("/admin")) {
928
990
  snippetShellArgs.push("--header 'Authorization: Bearer {access_token}'");
929
991
  snippetApiArgs.push("{ axiosConfig: { request: { headers: { Authorization: 'Bearer {access_token}' } } } }".trim());
930
992
  }
@@ -962,7 +1024,7 @@ var templateMethod = ({
962
1024
  classMethod,
963
1025
  description,
964
1026
  httpMethod,
965
- path: path8,
1027
+ path: path9,
966
1028
  pathParams,
967
1029
  bodyParams,
968
1030
  queryParams,
@@ -972,9 +1034,9 @@ var templateMethod = ({
972
1034
  }) => {
973
1035
  let methodParams = "";
974
1036
  let methodParamsNoTypes = "";
975
- let newPath = `'${path8}'`;
1037
+ let newPath = `'${path9}'`;
976
1038
  let importStatements = [];
977
- const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path8);
1039
+ const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path9);
978
1040
  for (const pathParam of sortedPathParams) {
979
1041
  const type = ParserUtils.parseType(pathParam);
980
1042
  if (pathParam.name !== "namespace") {
@@ -982,7 +1044,7 @@ var templateMethod = ({
982
1044
  methodParamsNoTypes += pathParam.name + ", ";
983
1045
  }
984
1046
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
985
- if (path8.match(`{${pathParam.name}}`)) {
1047
+ if (path9.match(`{${pathParam.name}}`)) {
986
1048
  if (type === "string") {
987
1049
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
988
1050
  } else {
@@ -1047,7 +1109,7 @@ var POST_FETCH_INCLUDES_PATH = ["/table-query/"];
1047
1109
  var templateQueryMethod = ({
1048
1110
  classMethod,
1049
1111
  httpMethod,
1050
- path: path8,
1112
+ path: path9,
1051
1113
  pathParams,
1052
1114
  responseClasses,
1053
1115
  methodParams,
@@ -1055,14 +1117,14 @@ var templateQueryMethod = ({
1055
1117
  description,
1056
1118
  deprecated
1057
1119
  }) => {
1058
- const isPostFetch = httpMethod === "post" && (POST_FETCH_INCLUDES_PATH.some((p) => path8.includes(p)) || path8.endsWith("/list"));
1120
+ const isPostFetch = httpMethod === "post" && (POST_FETCH_INCLUDES_PATH.some((p) => path9.includes(p)) || path9.endsWith("/list"));
1059
1121
  const isFetch = classMethod.startsWith("fetch");
1060
1122
  const isGet = httpMethod === "get" || isPostFetch || isFetch;
1061
1123
  const queryMethod = isGet ? "useQuery" : "useMutation";
1062
1124
  let mParams = "";
1063
1125
  let mParamsNoTypes = "";
1064
- let newPath = `'${path8}'`;
1065
- const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path8);
1126
+ let newPath = `'${path9}'`;
1127
+ const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path9);
1066
1128
  for (const pathParam of sortedPathParams) {
1067
1129
  const type = ParserUtils.parseType(pathParam);
1068
1130
  if (pathParam.name !== "namespace") {
@@ -1070,7 +1132,7 @@ var templateQueryMethod = ({
1070
1132
  mParamsNoTypes += pathParam.name + ", ";
1071
1133
  }
1072
1134
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
1073
- if (path8.match(`{${pathParam.name}}`)) {
1135
+ if (path9.match(`{${pathParam.name}}`)) {
1074
1136
  if (type === "string") {
1075
1137
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
1076
1138
  } else {
@@ -1105,7 +1167,7 @@ export const ${_methodName} = (
1105
1167
  const response =
1106
1168
  (await ${apiGenName}(sdk, { coreConfig: input.coreConfig, axiosConfig: input.axiosConfig }).
1107
1169
  ${classMethod}(${_methodParamsImpl}))
1108
- callback && callback(response)
1170
+ callback?.(response)
1109
1171
  return response.data
1110
1172
  }
1111
1173
 
@@ -1130,7 +1192,7 @@ export const ${_methodName} = (
1130
1192
  const response =
1131
1193
  (await ${apiGenName}(sdk, { coreConfig: input.coreConfig, axiosConfig: input.axiosConfig }).
1132
1194
  ${classMethod}(${_methodParamsImpl}))
1133
- callback && callback(response.data)
1195
+ callback?.(response.data)
1134
1196
  return response.data
1135
1197
  }
1136
1198
 
@@ -1309,11 +1371,11 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
1309
1371
  admin: {},
1310
1372
  public: {}
1311
1373
  };
1312
- for (const [path8, operation] of sortedPathsByLength) {
1313
- if (path8.indexOf("/healthz") >= 0) {
1374
+ for (const [path9, operation] of sortedPathsByLength) {
1375
+ if (path9.indexOf("/healthz") >= 0) {
1314
1376
  continue;
1315
1377
  }
1316
- const isAdminEndpoint = path8.indexOf("/admin/") > -1;
1378
+ const isAdminEndpoint = path9.indexOf("/admin/") > -1;
1317
1379
  const picked = isAdminEndpoint ? result.admin : result.public;
1318
1380
  const {
1319
1381
  arrayDefinitions,
@@ -1331,25 +1393,27 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
1331
1393
  const httpMethods = Object.keys(operation);
1332
1394
  for (const httpMethod of httpMethods) {
1333
1395
  const endpoint = await Endpoint.parseAsync(operation[httpMethod]).catch((error) => {
1334
- console.error(JSON.stringify({ path: path8, httpMethod }, null, 2));
1396
+ console.error(JSON.stringify({ path: path9, httpMethod }, null, 2));
1335
1397
  throw error;
1336
1398
  });
1337
1399
  if (!endpoint.tags) continue;
1338
1400
  const [tag] = endpoint.tags;
1339
- const pathWithBase = `${api.basePath ?? ""}${path8}`;
1401
+ const configBasePath = CodegenConfig.getBasePath();
1402
+ const effectiveBasePath = configBasePath !== void 0 ? configBasePath : api.basePath ?? "";
1403
+ const pathWithBase = `${effectiveBasePath}${path9}`;
1340
1404
  const permissionType = getPermissionType(getPermission(endpoint));
1341
1405
  tagToClassMethodsMapByType[tag] = tagToClassMethodsMapByType[tag] ? tagToClassMethodsMapByType[tag] : {};
1342
1406
  const isForm = endpoint.consumes && endpoint.consumes[0] === "application/x-www-form-urlencoded";
1343
1407
  const classMethod = ParserUtils.generateNaturalLangMethod({
1344
1408
  servicePrefix,
1345
- path: path8,
1409
+ path: path9,
1346
1410
  httpMethod,
1347
1411
  isForm,
1348
1412
  existingMethods: tagToClassMethodsMapByType[tag],
1349
1413
  permissionType
1350
1414
  });
1351
- tagToClassMethodsMapByType[tag][classMethod] = `${path8} ${httpMethod}`;
1352
- generatedMethods[`${path8} ${httpMethod}`] = `${classMethod}`;
1415
+ tagToClassMethodsMapByType[tag][classMethod] = `${path9} ${httpMethod}`;
1416
+ generatedMethods[`${path9} ${httpMethod}`] = `${classMethod}`;
1353
1417
  if (!snippetMap[pathWithBase]) {
1354
1418
  snippetMap[pathWithBase] = {};
1355
1419
  }
@@ -1504,6 +1568,20 @@ var TemplateZod = class {
1504
1568
  // --
1505
1569
  render = (fileName, definition, duplicates) => {
1506
1570
  this.duplicates = duplicates;
1571
+ const overrideAsAny = CodegenConfig.getOverrideAsAny();
1572
+ const override = overrideAsAny?.[fileName];
1573
+ if (override !== void 0) {
1574
+ const shouldOverride = typeof override === "function" ? override(definition) : override;
1575
+ if (shouldOverride) {
1576
+ const template2 = `import { z } from 'zod'
1577
+
1578
+ export const ${fileName} = z.any()
1579
+
1580
+ export interface ${fileName} extends z.TypeOf<typeof ${fileName}> {}
1581
+ `;
1582
+ return { buffer: template2, duplicateFound: false };
1583
+ }
1584
+ }
1507
1585
  const content = this.parseToZodSchema(definition, definition.required || []);
1508
1586
  const containsRecursiveType = this.importClasses.has(fileName);
1509
1587
  if (containsRecursiveType) {
@@ -1806,9 +1884,9 @@ var CodeGenerator = class _CodeGenerator {
1806
1884
  return;
1807
1885
  }
1808
1886
  const DIST_DIR = (isAdmin) => `${_CodeGenerator.getGeneratedFolder(isAdmin)}`;
1809
- const DIST_DIR_ENDPOINTS = (isAdmin) => path4.join(DIST_DIR(isAdmin), "endpoints");
1810
- const DIST_DIR_QUERIES = (isAdmin) => path4.join(DIST_DIR(isAdmin), "queries");
1811
- const DIST_DEFINITION_DIR = path4.join(_CodeGenerator.srcFolder(), "generated-definitions");
1887
+ const DIST_DIR_ENDPOINTS = (isAdmin) => path5.join(DIST_DIR(isAdmin), "endpoints");
1888
+ const DIST_DIR_QUERIES = (isAdmin) => path5.join(DIST_DIR(isAdmin), "queries");
1889
+ const DIST_DEFINITION_DIR = path5.join(_CodeGenerator.srcFolder(), "generated-definitions");
1812
1890
  const targetSrcFolder = `${_CodeGenerator.srcFolder()}/`;
1813
1891
  _CodeGenerator.prepareDirs(DIST_DEFINITION_DIR, DIST_DIR, DIST_DIR_ENDPOINTS, DIST_DIR_QUERIES);
1814
1892
  const mainApiList = [];
@@ -1850,22 +1928,24 @@ var CodeGenerator = class _CodeGenerator {
1850
1928
  ParserUtils.writeApiFile(DIST_DIR(isAdminEndpoint), apiGenName, apiBuffer, imports, tagToSdkFunctionDescription[tag]);
1851
1929
  apiList.push(apiGenName);
1852
1930
  indexImportsSet.add(
1853
- ParserUtils.getRelativePathToWebSdkSrcFolder(path4.join(DIST_DIR_ENDPOINTS(isAdminEndpoint), `${classGenName}`), targetSrcFolder)
1931
+ ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(DIST_DIR_ENDPOINTS(isAdminEndpoint), `${classGenName}`), targetSrcFolder)
1854
1932
  );
1855
1933
  indexImportsSet.add(
1856
- ParserUtils.getRelativePathToWebSdkSrcFolder(path4.join(DIST_DIR(isAdminEndpoint), `${apiGenName}`), targetSrcFolder)
1934
+ ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(DIST_DIR(isAdminEndpoint), `${apiGenName}`), targetSrcFolder)
1857
1935
  );
1858
1936
  queryFileName && queryImportsSet.add(
1859
1937
  ParserUtils.getRelativePathToWebSdkSrcFolder(
1860
- path4.join(DIST_DIR(isAdminEndpoint), "queries", `${queryFileName}`),
1938
+ path5.join(DIST_DIR(isAdminEndpoint), "queries", `${queryFileName}`),
1861
1939
  targetSrcFolder
1862
1940
  )
1863
1941
  );
1864
1942
  }
1865
1943
  mainApiList.push(...apiList);
1866
- indexImportsSet.add(
1867
- ParserUtils.getRelativePathToWebSdkSrcFolder(path4.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1868
- );
1944
+ if (CodegenConfig.shouldProduceIndexFile()) {
1945
+ indexImportsSet.add(
1946
+ ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1947
+ );
1948
+ }
1869
1949
  };
1870
1950
  const writeDefinitions = (api2) => {
1871
1951
  const duplicates = /* @__PURE__ */ new Map();
@@ -1873,7 +1953,7 @@ var CodeGenerator = class _CodeGenerator {
1873
1953
  for (const ref in definitions) {
1874
1954
  const definition = definitions[ref];
1875
1955
  const fileName = ParserUtils.parseRefType(ref);
1876
- const fileExist = fs4.existsSync(path4.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
1956
+ const fileExist = fs5.existsSync(path5.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
1877
1957
  if (fileExist) {
1878
1958
  const duplicateName = ParserUtils.toCamelCaseWord(ref).replace(".", "").replace(".", "");
1879
1959
  duplicates.set(ref, duplicateName);
@@ -1881,13 +1961,13 @@ var CodeGenerator = class _CodeGenerator {
1881
1961
  const { buffer } = new TemplateZod().render(fileName, definition, /* @__PURE__ */ new Map());
1882
1962
  generatedDefinitions.push(fileName);
1883
1963
  ParserUtils.writeDefinitionFile(DIST_DEFINITION_DIR, fileName, buffer);
1884
- indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(path4.join(DIST_DEFINITION_DIR, fileName), targetSrcFolder));
1964
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(DIST_DEFINITION_DIR, fileName), targetSrcFolder));
1885
1965
  }
1886
1966
  for (const arrayClass of arrayDefinitions) {
1887
1967
  const buffer = new TemplateZodArray().render(arrayClass);
1888
1968
  generatedDefinitions.push(arrayClass);
1889
1969
  ParserUtils.writeDefinitionFile(DIST_DEFINITION_DIR, arrayClass, buffer);
1890
- indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(path4.join(DIST_DEFINITION_DIR, arrayClass), targetSrcFolder));
1970
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(DIST_DEFINITION_DIR, arrayClass), targetSrcFolder));
1891
1971
  }
1892
1972
  };
1893
1973
  writeApiEndpointFiles(isAdmin);
@@ -1895,9 +1975,11 @@ var CodeGenerator = class _CodeGenerator {
1895
1975
  };
1896
1976
  generatePublicOrAdmin(true);
1897
1977
  generatePublicOrAdmin(false);
1898
- const isGenerateWebSocket = CliParser.isGenerateWebSocket();
1899
- const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
1900
- ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
1978
+ if (CodegenConfig.shouldProduceIndexFile()) {
1979
+ const isGenerateWebSocket = CliParser.isGenerateWebSocket();
1980
+ const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
1981
+ ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
1982
+ }
1901
1983
  console.log("\nCOMPLETED\n----------\n\n");
1902
1984
  return { indexImports: indexImportsSet, queryImports: queryImportsSet };
1903
1985
  };
@@ -1905,29 +1987,29 @@ var CodeGenerator = class _CodeGenerator {
1905
1987
  };
1906
1988
 
1907
1989
  // src/SwaggerDownloader.ts
1990
+ import * as fs6 from "fs";
1908
1991
  import * as https from "https";
1909
- import * as fs5 from "fs";
1910
- import * as path5 from "path";
1992
+ import * as path6 from "path";
1911
1993
  var SwaggerDownloader = class _SwaggerDownloader {
1912
1994
  static getDestFile = (targetFileName) => {
1913
1995
  const destPath = CliParser.getResolvedSwaggersOutputPath();
1914
- const destFile = path5.join(destPath, targetFileName);
1915
- if (fs5.existsSync(destFile)) return destFile;
1916
- if (!fs5.existsSync(destPath)) fs5.mkdirSync(destPath);
1917
- fs5.writeFileSync(destFile, "");
1996
+ const destFile = path6.join(destPath, targetFileName);
1997
+ if (fs6.existsSync(destFile)) return destFile;
1998
+ if (!fs6.existsSync(destPath)) fs6.mkdirSync(destPath);
1999
+ fs6.writeFileSync(destFile, "");
1918
2000
  return destFile;
1919
2001
  };
1920
2002
  // session-api.json contains illegal URL encoded character that breaks the codegen
1921
2003
  // e.g. "$ref": "#/definitions/map%5Bstring%5Dinterface%20%7B%7D"
1922
2004
  static postSanitizeDownloadedFile = (filePath) => {
1923
2005
  const searchStr = ["%5B", "%5D", "%20", "%7B", "%7D"];
1924
- fs5.readFile(filePath, "utf8", (err, data) => {
2006
+ fs6.readFile(filePath, "utf8", (err, data) => {
1925
2007
  if (err) throw err;
1926
2008
  let result = data;
1927
2009
  searchStr.forEach((s) => {
1928
2010
  result = result.replace(new RegExp(s, "g"), " ");
1929
2011
  });
1930
- fs5.writeFile(filePath, result, "utf8", (err2) => {
2012
+ fs6.writeFile(filePath, result, "utf8", (err2) => {
1931
2013
  if (err2) throw err2;
1932
2014
  console.log("File updated successfully.");
1933
2015
  });
@@ -1945,7 +2027,7 @@ var SwaggerDownloader = class _SwaggerDownloader {
1945
2027
  if (response.statusCode !== 200) {
1946
2028
  console.log(`SwaggerDownload error with status code: ${response.statusCode}`);
1947
2029
  } else {
1948
- fs5.writeFileSync(destFile, JSON.stringify(JSON.parse(data), null, 2), "utf-8");
2030
+ fs6.writeFileSync(destFile, JSON.stringify(JSON.parse(data), null, 2), "utf-8");
1949
2031
  _SwaggerDownloader.postSanitizeDownloadedFile(destFile);
1950
2032
  console.log(`SwaggerDownload ${url} completed with status code: ${response.statusCode}`);
1951
2033
  }
@@ -1968,8 +2050,8 @@ var SwaggerDownloader = class _SwaggerDownloader {
1968
2050
  };
1969
2051
 
1970
2052
  // src/WebsocketGenerator.ts
1971
- import fs6 from "fs";
1972
- import path6 from "path";
2053
+ import fs7 from "fs";
2054
+ import path7 from "path";
1973
2055
 
1974
2056
  // src/templates/template-ws-class.ts
1975
2057
  var definitionToFunctionName = (type) => {
@@ -1984,7 +2066,7 @@ var renderSendFunction = (name, definition) => {
1984
2066
  send({ type: '${name}', ...data })
1985
2067
  }`;
1986
2068
  };
1987
- var templateWebsocketClass = (name, path8, definitions) => {
2069
+ var templateWebsocketClass = (name, path9, definitions) => {
1988
2070
  const requestDefinitions = Object.keys(definitions).filter((key) => {
1989
2071
  const val = definitions[key];
1990
2072
  return val["x-type"] == "request";
@@ -2043,7 +2125,7 @@ const messageSerializer = (data: Record<string, any>) => {
2043
2125
  export function WebSocketClass(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
2044
2126
  const sdkAssembly = sdk.assembly()
2045
2127
  const baseURL = (args?.coreConfig?.baseURL ?? sdkAssembly.coreConfig.baseURL).replace('http', 'ws')
2046
- const path = '${path8}'
2128
+ const path = '${path9}'
2047
2129
  const url = baseURL + path
2048
2130
  let ws: WebSocket | null = null
2049
2131
  let isDisconnectManually = false
@@ -2292,9 +2374,9 @@ ${renderUnion(["response", "notification"], definitions)}
2292
2374
  // src/WebsocketGenerator.ts
2293
2375
  var WebsocketGenerator = class {
2294
2376
  static srcFolder = () => CliParser.getOutputPath();
2295
- static outputFolder = () => path6.join(this.srcFolder(), "generated-websocket");
2377
+ static outputFolder = () => path7.join(this.srcFolder(), "generated-websocket");
2296
2378
  static schemaContent = () => {
2297
- const fileContent = JSON.parse(fs6.readFileSync(CliParser.getWebSocketSchemaPath(), "utf8"));
2379
+ const fileContent = JSON.parse(fs7.readFileSync(CliParser.getWebSocketSchemaPath(), "utf8"));
2298
2380
  return fileContent;
2299
2381
  };
2300
2382
  static prepareDirs = () => {
@@ -2304,11 +2386,11 @@ var WebsocketGenerator = class {
2304
2386
  const { name, path: wsPath, definitions } = this.schemaContent();
2305
2387
  const templateDefinitions = templateWebsocketDefinitions(definitions);
2306
2388
  this.prepareDirs();
2307
- const filePath = path6.join(this.outputFolder(), "WebSocketDefinitions.ts");
2308
- fs6.writeFileSync(filePath, templateDefinitions, "utf8");
2389
+ const filePath = path7.join(this.outputFolder(), "WebSocketDefinitions.ts");
2390
+ fs7.writeFileSync(filePath, templateDefinitions, "utf8");
2309
2391
  const templateClass2 = templateWebsocketClass(name, wsPath, definitions);
2310
- const filePathClass = path6.join(this.outputFolder(), "WebSocketClass.ts");
2311
- fs6.writeFileSync(filePathClass, templateClass2, "utf8");
2392
+ const filePathClass = path7.join(this.outputFolder(), "WebSocketClass.ts");
2393
+ fs7.writeFileSync(filePathClass, templateClass2, "utf8");
2312
2394
  };
2313
2395
  };
2314
2396
 
@@ -2326,19 +2408,20 @@ var generateSdk = async () => {
2326
2408
  const filenamesSet = /* @__PURE__ */ new Set();
2327
2409
  for (const set of arrayOfSets) {
2328
2410
  set.indexImports.forEach((value) => {
2329
- const fileName = path7.basename(value);
2411
+ const fileName = path8.basename(value);
2330
2412
  if (!filenamesSet.has(fileName)) {
2331
2413
  indexImportsSet.add(value);
2332
2414
  filenamesSet.add(fileName);
2333
2415
  }
2334
2416
  });
2335
2417
  set.queryImports.forEach((value) => {
2336
- const fileName = path7.basename(value);
2418
+ const fileName = path8.basename(value);
2337
2419
  if (!filenamesSet.has(fileName)) {
2338
2420
  queryImportsSet.add(value);
2339
2421
  }
2340
2422
  });
2341
2423
  }
2424
+ const outputPath = CliParser.getOutputPath();
2342
2425
  const indexImportsArray = Array.from(indexImportsSet).sort();
2343
2426
  const queryImportsArray = Array.from(queryImportsSet).sort();
2344
2427
  const filesToImport = indexImportsArray.map((fileToImport) => {
@@ -2347,8 +2430,8 @@ var generateSdk = async () => {
2347
2430
  const queryFilesToImport = queryImportsArray.map((fileToImport) => {
2348
2431
  return `export * from '${fileToImport.replace("\\", "/")}.js'`;
2349
2432
  });
2350
- ParserUtils.writeAllImportsFile(CliParser.getOutputPath(), filesToImport.join("\n"));
2351
- ParserUtils.writeAllQueryImportsFile(CliParser.getOutputPath(), queryFilesToImport.join("\n"));
2433
+ ParserUtils.writeAllImportsFile(outputPath, filesToImport.join("\n"));
2434
+ ParserUtils.writeAllQueryImportsFile(outputPath, queryFilesToImport.join("\n"));
2352
2435
  };
2353
2436
  yargs.command("download-swaggers", "Download swaggers JSON files", (yargs2) => {
2354
2437
  CliParser.createInstance(yargs2);
@@ -2364,6 +2447,7 @@ yargs.command("download-swaggers", "Download swaggers JSON files", (yargs2) => {
2364
2447
  return true;
2365
2448
  });
2366
2449
  CliParser.createInstance(yargs2);
2450
+ await CodegenConfig.loadConfig(path8.dirname(path8.resolve(CliParser.getConfigPath())));
2367
2451
  await generateSdk();
2368
2452
  }).option("config", {
2369
2453
  description: "Path to the config file with backend service URLs.",