@accelbyte/codegen 0.0.0-dev-20250530101210 → 0.0.0-dev-20260326093546

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.
@@ -21,9 +21,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
22
  mod
23
23
  ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
25
 
25
26
  // src/cli.ts
26
- var import_path5 = __toESM(require("path"));
27
+ var cli_exports = {};
28
+ module.exports = __toCommonJS(cli_exports);
29
+ var import_path6 = __toESM(require("path"));
27
30
  var import_yargs = __toESM(require("yargs"));
28
31
 
29
32
  // src/CliParser.ts
@@ -87,18 +90,52 @@ var CliParser = class _CliParser {
87
90
 
88
91
  // src/CodeGenerator.ts
89
92
  var import_swagger_parser = __toESM(require("@apidevtools/swagger-parser"));
90
- var import_fs4 = __toESM(require("fs"));
91
- var import_path3 = __toESM(require("path"));
93
+ var import_fs5 = __toESM(require("fs"));
94
+ var import_path4 = __toESM(require("path"));
95
+
96
+ // src/CodegenConfig.ts
97
+ var import_fs2 = __toESM(require("fs"));
98
+ var import_path = __toESM(require("path"));
99
+ var import_url = require("url");
100
+ var CodegenConfig = class _CodegenConfig {
101
+ static config = {};
102
+ static async loadConfig(configDir) {
103
+ const configPath = import_path.default.join(configDir, "abcodegen.config.ts");
104
+ if (!import_fs2.default.existsSync(configPath)) {
105
+ _CodegenConfig.config = {};
106
+ return;
107
+ }
108
+ const loaded = await import((0, import_url.pathToFileURL)(configPath).href);
109
+ _CodegenConfig.config = loaded.default ?? loaded ?? {};
110
+ }
111
+ static shouldProduceIndexFiles() {
112
+ return _CodegenConfig.config.unstable_shouldProduceIndexFiles ?? true;
113
+ }
114
+ static getBasePath() {
115
+ return _CodegenConfig.config.basePath;
116
+ }
117
+ static getOverrideAsAny() {
118
+ return _CodegenConfig.config.unstable_overrideAsAny;
119
+ }
120
+ /** Reset to defaults — used for testing */
121
+ static reset() {
122
+ _CodegenConfig.config = {};
123
+ }
124
+ /** Set config directly — used for testing */
125
+ static setConfig(config) {
126
+ _CodegenConfig.config = config;
127
+ }
128
+ };
92
129
 
93
130
  // src/ParserUtils.ts
94
131
  var import_fast_json_patch = require("fast-json-patch");
95
- var import_fs3 = __toESM(require("fs"));
132
+ var import_fs4 = __toESM(require("fs"));
96
133
  var import_lodash = __toESM(require("lodash"));
97
- var import_path2 = __toESM(require("path"));
134
+ var import_path3 = __toESM(require("path"));
98
135
 
99
136
  // src/helpers/utils.ts
100
- var import_fs2 = __toESM(require("fs"));
101
- var import_path = __toESM(require("path"));
137
+ var import_fs3 = __toESM(require("fs"));
138
+ var import_path2 = __toESM(require("path"));
102
139
  var capitalize = (string) => {
103
140
  return string.charAt(0).toUpperCase() + string.slice(1);
104
141
  };
@@ -175,10 +212,10 @@ var getImportableVarMap = () => ({
175
212
  zod: ["z"]
176
213
  });
177
214
  var makeNewImportVarMap = () => ({
178
- axios: ["AxiosInstance", "AxiosRequestConfig"],
179
- "@accelbyte/sdk": ["SDKRequestConfig"]
215
+ axios: ["AxiosInstance", "AxiosRequestConfig"]
180
216
  });
181
- var generateImports = (body, importStatements, makeNewImportVarMap3, getImportableVarMap3) => {
217
+ var CLASS_TYPE_ONLY_VARS = /* @__PURE__ */ new Set(["AxiosInstance", "AxiosRequestConfig", "AxiosResponse", "SdkSetConfigParam", "Response"]);
218
+ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportableVarMap3, typeOnlyVars = /* @__PURE__ */ new Set()) => {
182
219
  const usedImportVarMap = makeNewImportVarMap3;
183
220
  const importableVarMap = getImportableVarMap3;
184
221
  for (const [moduleSource, importableVars] of Object.entries(importableVarMap)) {
@@ -189,22 +226,45 @@ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportab
189
226
  }
190
227
  }
191
228
  }
192
- const generatedImports = Object.keys(usedImportVarMap).sort().map((moduleSource) => {
193
- return `import { ${usedImportVarMap[moduleSource].sort().join(", ")} } from '${moduleSource}'`;
194
- }).join("\n");
229
+ const importLines = [];
230
+ for (const moduleSource of Object.keys(usedImportVarMap).sort()) {
231
+ const allVars = usedImportVarMap[moduleSource];
232
+ const valueVars = allVars.filter((v) => !typeOnlyVars.has(v)).sort();
233
+ const typeVars = allVars.filter((v) => typeOnlyVars.has(v)).sort();
234
+ if (valueVars.length > 0) {
235
+ importLines.push(`import { ${valueVars.join(", ")} } from '${moduleSource}'`);
236
+ }
237
+ if (typeVars.length > 0) {
238
+ importLines.push(`import type { ${typeVars.join(", ")} } from '${moduleSource}'`);
239
+ }
240
+ }
241
+ const generatedImports = importLines.join("\n");
195
242
  return `${generatedImports}
196
243
  ${importStatements.sort().join("\n")}`;
197
244
  };
198
245
  var templateClass = (className, body, importStatements) => {
246
+ const attributes = {
247
+ definitions: ["private axiosInstance: AxiosInstance", "private namespace: string", "private useSchemaValidation: boolean"],
248
+ assignments: ["this.axiosInstance = axiosInstance", "this.namespace = namespace", "this.useSchemaValidation = useSchemaValidation"]
249
+ };
250
+ let namespaceConstructor = "namespace";
251
+ if (!body.includes(".replace('{namespace}', this.namespace)")) {
252
+ namespaceConstructor = "_namespace";
253
+ attributes.definitions.splice(1, 1);
254
+ attributes.assignments.splice(1, 1);
255
+ }
199
256
  return `/**
200
257
  * AUTO GENERATED
201
258
  */
202
- ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap())}
259
+ ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap(), CLASS_TYPE_ONLY_VARS)}
203
260
 
204
261
  export class ${className} {
205
- // @ts-ignore
206
- // prettier-ignore
207
- constructor(private axiosInstance: AxiosInstance, private namespace: string, private useSchemaValidation = true) {}
262
+ ${attributes.definitions.join("\n")}
263
+
264
+ constructor(axiosInstance: AxiosInstance, ${namespaceConstructor}: string, useSchemaValidation = true) {
265
+ ${attributes.assignments.join("\n")}
266
+ }
267
+
208
268
  ${body}
209
269
  }
210
270
  `;
@@ -219,6 +279,15 @@ var makeNewImportVarMap2 = () => ({
219
279
  "@accelbyte/sdk": ["AccelByteSDK", "SdkSetConfigParam", "ApiUtils", "Network"],
220
280
  axios: ["AxiosRequestConfig", "AxiosResponse"]
221
281
  });
282
+ var API_TYPE_ONLY_VARS = /* @__PURE__ */ new Set([
283
+ "AxiosRequestConfig",
284
+ "AxiosResponse",
285
+ "AxiosDefaults",
286
+ "HeadersDefaults",
287
+ "AccelByteSDK",
288
+ "SdkSetConfigParam",
289
+ "Response"
290
+ ]);
222
291
  var templateApiClass = (className, body, importStatements, returnMethods) => {
223
292
  const returnsMethodsWithDescription = Object.keys(returnMethods).reduce((acc, key) => {
224
293
  acc += `
@@ -230,43 +299,45 @@ ${key},`;
230
299
  return `/**
231
300
  * AUTO GENERATED
232
301
  */
233
- /* eslint-disable camelcase */
234
- // @ts-ignore -> ts-expect-error TS6133
235
- ${generateImports(body, importStatements, makeNewImportVarMap2(), getImportableVarMap2())}
302
+ ${generateImports(body, importStatements, makeNewImportVarMap2(), getImportableVarMap2(), API_TYPE_ONLY_VARS)}
236
303
  ${`import { ${$className} } from './endpoints/${$className}.js'
237
304
  `}
238
305
 
239
306
  export function ${className}(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
240
307
  const sdkAssembly = sdk.assembly()
241
-
308
+
242
309
  const namespace = args?.coreConfig?.namespace ?? sdkAssembly.coreConfig.namespace
243
310
  const useSchemaValidation = args?.coreConfig?.useSchemaValidation ?? sdkAssembly.coreConfig.useSchemaValidation
244
-
311
+
245
312
  let axiosInstance = sdkAssembly.axiosInstance
246
313
  const requestConfigOverrides = args?.axiosConfig?.request
247
314
  const baseURLOverride = args?.coreConfig?.baseURL
248
- const interceptorsOverride = args?.axiosConfig?.interceptors ?? []
315
+ const interceptorsOverride = args?.axiosConfig?.interceptors
249
316
 
250
- if (requestConfigOverrides || baseURLOverride || interceptorsOverride.length > 0) {
317
+ if (requestConfigOverrides || baseURLOverride || interceptorsOverride) {
251
318
  const requestConfig = ApiUtils.mergeAxiosConfigs(sdkAssembly.axiosInstance.defaults as AxiosRequestConfig, {
252
319
  ...(baseURLOverride ? { baseURL: baseURLOverride } : {}),
253
320
  ...requestConfigOverrides
254
321
  })
255
322
  axiosInstance = Network.create(requestConfig)
256
323
 
257
- for (const interceptor of interceptorsOverride) {
258
- if (interceptor.type === 'request') {
259
- axiosInstance.interceptors.request.use(interceptor.onRequest, interceptor.onError)
260
- }
324
+ if (interceptorsOverride) {
325
+ for (const interceptor of interceptorsOverride) {
326
+ if (interceptor.type === 'request') {
327
+ axiosInstance.interceptors.request.use(interceptor.onRequest, interceptor.onError)
328
+ }
261
329
 
262
- if (interceptor.type === 'response') {
263
- axiosInstance.interceptors.response.use(interceptor.onSuccess, interceptor.onError)
330
+ if (interceptor.type === 'response') {
331
+ axiosInstance.interceptors.response.use(interceptor.onSuccess, interceptor.onError)
332
+ }
264
333
  }
334
+ } else {
335
+ axiosInstance.interceptors = sdkAssembly.axiosInstance.interceptors
265
336
  }
266
337
  }
267
338
 
268
339
  ${body}
269
-
340
+
270
341
  return {
271
342
  ${returnsMethodsWithDescription}
272
343
  }
@@ -277,7 +348,7 @@ export function ${className}(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
277
348
  // src/ParserQueryUtils.ts
278
349
  var ParserQueryUtils = class {
279
350
  /**
280
- * convert csv 'aa,bb' into "aa='aa', bb='bb'"
351
+ * convert csv 'aa,bb' into "aa = 'Sdk.Class.aa', bb = 'Sdk.Class.bb'"
281
352
  */
282
353
  static createQueryKeys(classNameWithoutApi, csvMethodNames, sdkName) {
283
354
  const keys = csvMethodNames.split(",");
@@ -288,7 +359,7 @@ var ParserQueryUtils = class {
288
359
  const cleanedKey = trimmedKey.replace(/^(get|update|create|patch|delete|post|fetch)[_]?/, "");
289
360
  if (!processedKeys.has(cleanedKey)) {
290
361
  processedKeys.add(cleanedKey);
291
- acc += `${cleanedKey} = '${capitalize(sdkName)}.${classNameWithoutApi}.${cleanedKey}'`;
362
+ acc += `${cleanedKey}: '${capitalize(sdkName)}.${classNameWithoutApi}.${cleanedKey}'`;
292
363
  if (index < keys.length - 1) {
293
364
  acc += ",\n";
294
365
  }
@@ -302,42 +373,51 @@ var ParserQueryUtils = class {
302
373
 
303
374
  // src/templates/template-query.ts
304
375
  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;
376
+ const lines = [];
377
+ lines.push("import type { AccelByteSDK, ApiError, SdkSetConfigParam } from '@accelbyte/sdk'");
378
+ const axiosTypes = ["AxiosError", "AxiosResponse"].filter((t) => body.includes(t));
379
+ if (axiosTypes.length) {
380
+ lines.push(`import type { ${axiosTypes.join(", ")} } from 'axios'`);
381
+ }
382
+ const rqValues = ["useMutation", "useQuery"].filter((t) => body.includes(t));
383
+ if (rqValues.length) {
384
+ lines.push(`import { ${rqValues.join(", ")} } from '@tanstack/react-query'`);
385
+ }
386
+ const rqTypes = ["UseMutationOptions", "UseMutationResult", "UseQueryOptions", "UseQueryResult"].filter((t) => body.includes(t));
387
+ if (rqTypes.length) {
388
+ lines.push(`import type { ${rqTypes.join(", ")} } from '@tanstack/react-query'`);
389
+ }
390
+ lines.push(`import { ${className} } from "../${className}.js"`);
391
+ return lines.join("\n") + "\n";
312
392
  };
313
393
  var templateQuery = (className, body, importStatements, serviceNameTitle, returnMethods, paramImports, sdkName) => {
314
394
  const classNameWithoutApi = className.replace("Api", "");
315
395
  const queryKeys = ParserQueryUtils.createQueryKeys(classNameWithoutApi, returnMethods, sdkName);
316
396
  const generatedImports = generateImports2(body, className);
397
+ const queryKeyBlock = `export const Key_${classNameWithoutApi} = {
398
+ ${queryKeys}
399
+ } as const`;
317
400
  return `/**
318
401
  * AUTO GENERATED
319
402
  */
320
- /* eslint-disable camelcase */
321
403
  ${generatedImports}
322
404
  ${filterUsedImports(paramImports, body)}
323
405
 
324
- export enum Key_${classNameWithoutApi} {
325
- ${queryKeys}
326
- }
406
+ ${queryKeyBlock}
327
407
 
328
408
  ${body}
329
409
  `;
330
410
  };
331
411
  function filterUsedImports(importArr, body) {
332
- return importArr.filter((path8) => {
333
- const start = path8.indexOf("{") + 1;
334
- const end = path8.indexOf("}");
412
+ return importArr.filter((path9) => {
413
+ const start = path9.indexOf("{") + 1;
414
+ const end = path9.indexOf("}");
335
415
  if (start > 0 && end > start) {
336
- const importName = path8.slice(start, end).trim();
416
+ const importName = path9.slice(start, end).trim();
337
417
  return body.includes(importName);
338
418
  }
339
419
  return false;
340
- }).map((path8) => path8).join("\n") + "\n";
420
+ }).map((path9) => path9).join("\n") + "\n";
341
421
  }
342
422
 
343
423
  // src/ParserUtils.ts
@@ -354,8 +434,8 @@ var REMOVED_KEYWORDS = [
354
434
  "/{namespace}/"
355
435
  ];
356
436
  var ParserUtils = class _ParserUtils {
357
- static getVersionSuffixFromPath(path8) {
358
- const version2_3_4_etc = path8.match(/\/v([2-9]|[1-9]\d+)\/+/);
437
+ static getVersionSuffixFromPath(path9) {
438
+ const version2_3_4_etc = path9.match(/\/v([2-9]|[1-9]\d+)\/+/);
359
439
  const methodSuffix = version2_3_4_etc ? `_v${version2_3_4_etc[1]}` : "";
360
440
  return methodSuffix;
361
441
  }
@@ -550,14 +630,14 @@ var ParserUtils = class _ParserUtils {
550
630
  * to this
551
631
  * `createGenerateByRequestIdByUserId`
552
632
  */
553
- static generateNaturalLangMethod = ({ servicePrefix, path: path8, httpMethod, isForm, existingMethods, permissionType }) => {
554
- let path_ = path8;
633
+ static generateNaturalLangMethod = ({ servicePrefix, path: path9, httpMethod, isForm, existingMethods, permissionType }) => {
634
+ let path_ = path9;
555
635
  path_ = path_.replace(`/${servicePrefix}/`, "/");
556
636
  REMOVED_KEYWORDS.forEach((prefix) => {
557
637
  path_ = path_.replace(prefix, "/");
558
638
  });
559
639
  path_ = path_.substring(1);
560
- const isPlural = httpMethod === "get" && !(path8.slice(-1) === "}");
640
+ const isPlural = httpMethod === "get" && !(path9.slice(-1) === "}");
561
641
  if (!isPlural) {
562
642
  path_ = _ParserUtils.replaceAll(path_, "ies/", "y/");
563
643
  path_ = _ParserUtils.replaceAll(path_, "s/", "/");
@@ -600,9 +680,9 @@ var ParserUtils = class _ParserUtils {
600
680
  const genPath = import_lodash.default.upperFirst(lastWords) + "/" + listBeforeLastWords.join("/") + listByParams.reverse().join("/");
601
681
  let generatedMethod = import_lodash.default.camelCase(mappedMethod(httpMethod, isForm, permissionType) + genPath);
602
682
  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);
683
+ const testedGeneratedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path9);
684
+ generatedMethod = resolveConflicts({ path: path9, generatedMethod, testedGeneratedMethod, existingMethods });
685
+ generatedMethod = generatedMethod + _ParserUtils.getVersionSuffixFromPath(path9);
606
686
  return generatedMethod;
607
687
  };
608
688
  static filterBodyParams(parameters) {
@@ -618,17 +698,17 @@ var ParserUtils = class _ParserUtils {
618
698
  return parameters.filter((parameter) => parameter.in === "query");
619
699
  }
620
700
  static mkdirIfNotExist(dirToCreate) {
621
- if (!import_fs3.default.existsSync(dirToCreate)) {
622
- import_fs3.default.mkdirSync(dirToCreate, { recursive: true });
701
+ if (!import_fs4.default.existsSync(dirToCreate)) {
702
+ import_fs4.default.mkdirSync(dirToCreate, { recursive: true });
623
703
  }
624
704
  }
625
705
  static writeClassFile(distDir, apiName, apiBuffer, imports) {
626
706
  const fileContent = templateClass(apiName, apiBuffer, imports);
627
- import_fs3.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
707
+ import_fs4.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
628
708
  }
629
709
  static writeAtomFile(distDir, apiName, fileContent) {
630
710
  _ParserUtils.mkdirIfNotExist(distDir);
631
- import_fs3.default.writeFileSync(`${distDir}/${apiName}.atom.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
711
+ import_fs4.default.writeFileSync(`${distDir}/${apiName}.atom.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
632
712
  }
633
713
  static writeQueryFile(distDir, apiName, apiBuffer, imports, serviceNameTitle, returnMethods, paramImports, sdkName) {
634
714
  if (apiBuffer.length < 1) {
@@ -637,20 +717,21 @@ var ParserUtils = class _ParserUtils {
637
717
  const queryFileName = `${apiName.replace("Api", "")}.query`;
638
718
  _ParserUtils.mkdirIfNotExist(distDir);
639
719
  const fileContent = templateQuery(apiName, apiBuffer, imports, serviceNameTitle, returnMethods, paramImports, sdkName);
640
- import_fs3.default.writeFileSync(`${distDir}/${queryFileName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
720
+ import_fs4.default.writeFileSync(`${distDir}/${queryFileName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
641
721
  return queryFileName;
642
722
  }
643
723
  static writeXVersion(distDir, xversionJson, apiInfo) {
724
+ import_fs4.default.mkdirSync(distDir, { recursive: true });
644
725
  if (xversionJson) {
645
726
  console.log("x-version:", xversionJson);
646
- import_fs3.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
727
+ import_fs4.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
647
728
  } else {
648
729
  const customVersion = {
649
730
  ...apiInfo,
650
731
  gitHash: apiInfo.version
651
732
  };
652
733
  console.error(`!!!! Missing x-version for ${distDir} ${customVersion}`);
653
- import_fs3.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(customVersion, null, 2));
734
+ import_fs4.default.writeFileSync(`${distDir}/version.json`, JSON.stringify(customVersion, null, 2));
654
735
  }
655
736
  }
656
737
  static writeApiFile(distDir, apiName, apiBuffer, imports, returnMethodsDescription) {
@@ -659,28 +740,28 @@ var ParserUtils = class _ParserUtils {
659
740
  newImports.push(el.replace("../../generated-definitions", "../generated-definitions"));
660
741
  });
661
742
  const fileContent = templateApiClass(apiName, apiBuffer, newImports, returnMethodsDescription);
662
- import_fs3.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
743
+ import_fs4.default.writeFileSync(`${distDir}/${apiName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
663
744
  }
664
745
  static writeApiMainFile(distDir, serviceName, fileContent) {
665
- import_fs3.default.writeFileSync(`${distDir}/${serviceName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
746
+ import_fs4.default.writeFileSync(`${distDir}/${serviceName}.ts`, _ParserUtils.prependCopyrightHeader(fileContent));
666
747
  }
667
748
  static writeSnippetFile(distDir, name, docBuffer) {
668
749
  let snippetFileName = _ParserUtils.replaceAll(name, " ", "-").toLowerCase();
669
750
  snippetFileName = snippetFileName.replace("justice-", "");
670
751
  snippetFileName = "snippet-" + snippetFileName + ".json";
671
- import_fs3.default.writeFileSync(`${distDir}/${snippetFileName}`, docBuffer);
752
+ import_fs4.default.writeFileSync(`${distDir}/${snippetFileName}`, docBuffer);
672
753
  }
673
754
  static writeDefinitionFile(distDir, name, buffer) {
674
755
  _ParserUtils.mkdirIfNotExist(distDir);
675
- import_fs3.default.writeFileSync(import_path2.default.join(distDir, `${name}.ts`), _ParserUtils.prependCopyrightHeader(buffer));
756
+ import_fs4.default.writeFileSync(import_path3.default.join(distDir, `${name}.ts`), _ParserUtils.prependCopyrightHeader(buffer));
676
757
  }
677
758
  static writeAllImportsFile(distDir, buffer) {
678
759
  _ParserUtils.mkdirIfNotExist(distDir);
679
- import_fs3.default.writeFileSync(import_path2.default.join(distDir, "all-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
760
+ import_fs4.default.writeFileSync(import_path3.default.join(distDir, "all-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
680
761
  }
681
762
  static writeAllQueryImportsFile(distDir, buffer) {
682
763
  _ParserUtils.mkdirIfNotExist(distDir);
683
- import_fs3.default.writeFileSync(import_path2.default.join(distDir, "all-query-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
764
+ import_fs4.default.writeFileSync(import_path3.default.join(distDir, "all-query-imports.ts"), _ParserUtils.prependCopyrightHeader(buffer));
684
765
  }
685
766
  static toCamelCase(str) {
686
767
  return str.split("/").map(function(word, index) {
@@ -706,15 +787,15 @@ var ParserUtils = class _ParserUtils {
706
787
  });
707
788
  }
708
789
  static applyPatchIfExists(swaggerFilePath, possibleSwaggerPatchFilePath, swaggerPatchedFilePath, swaggerPatchedDir) {
709
- if (!import_fs3.default.existsSync(swaggerPatchedDir)) {
710
- import_fs3.default.mkdirSync(swaggerPatchedDir, { recursive: true });
790
+ if (!import_fs4.default.existsSync(swaggerPatchedDir)) {
791
+ import_fs4.default.mkdirSync(swaggerPatchedDir, { recursive: true });
711
792
  }
712
- if (!import_fs3.default.existsSync(possibleSwaggerPatchFilePath)) {
713
- import_fs3.default.copyFileSync(swaggerFilePath, swaggerPatchedFilePath);
793
+ if (!import_fs4.default.existsSync(possibleSwaggerPatchFilePath)) {
794
+ import_fs4.default.copyFileSync(swaggerFilePath, swaggerPatchedFilePath);
714
795
  return;
715
796
  }
716
- const swaggerContent = JSON.parse(import_fs3.default.readFileSync(swaggerFilePath, "utf8"));
717
- const swaggerPatchFileContent = JSON.parse(import_fs3.default.readFileSync(possibleSwaggerPatchFilePath, "utf8"));
797
+ const swaggerContent = JSON.parse(import_fs4.default.readFileSync(swaggerFilePath, "utf8"));
798
+ const swaggerPatchFileContent = JSON.parse(import_fs4.default.readFileSync(possibleSwaggerPatchFilePath, "utf8"));
718
799
  for (const patchEntry of swaggerPatchFileContent) {
719
800
  const segments = patchEntry.path.split("/").filter(Boolean);
720
801
  let currentNode = swaggerContent;
@@ -742,7 +823,7 @@ var ParserUtils = class _ParserUtils {
742
823
  }
743
824
  }
744
825
  const { newDocument } = (0, import_fast_json_patch.applyPatch)(swaggerContent, swaggerPatchFileContent);
745
- import_fs3.default.writeFileSync(swaggerPatchedFilePath, JSON.stringify(newDocument, null, 2));
826
+ import_fs4.default.writeFileSync(swaggerPatchedFilePath, JSON.stringify(newDocument, null, 2));
746
827
  }
747
828
  static getRelativePathToWebSdkSrcFolder(srcFolder, targetSrcFolder) {
748
829
  const replaced = srcFolder.replace(/\\/g, "/");
@@ -757,8 +838,8 @@ var ParserUtils = class _ParserUtils {
757
838
  */
758
839
  ${content}`;
759
840
  };
760
- static sortPathParamsByPath = (pathParams, path8) => {
761
- const params = path8.match(/{\w*}/g) || [];
841
+ static sortPathParamsByPath = (pathParams, path9) => {
842
+ const params = path9.match(/{\w*}/g) || [];
762
843
  const cleanParams = params.map((param) => param.replace("{", "").replace("}", ""));
763
844
  return pathParams.sort((a, b) => cleanParams.indexOf(a.name) - cleanParams.indexOf(b.name));
764
845
  };
@@ -782,30 +863,30 @@ var mappedMethod = (httpMethod, isForm, permissionType) => {
782
863
  return "delete";
783
864
  }
784
865
  };
785
- var resolveConflicts = ({ path: path8, generatedMethod, testedGeneratedMethod, existingMethods }) => {
866
+ var resolveConflicts = ({ path: path9, generatedMethod, testedGeneratedMethod, existingMethods }) => {
786
867
  let _testedGenMethod = testedGeneratedMethod;
787
868
  try {
788
- testConflict(path8, _testedGenMethod, existingMethods);
869
+ testConflict(path9, _testedGenMethod, existingMethods);
789
870
  } catch (e) {
790
- if (path8.indexOf("/namespaces/") >= 0) {
871
+ if (path9.indexOf("/namespaces/") >= 0) {
791
872
  generatedMethod += "_ByNS";
792
873
  _testedGenMethod += "_ByNS";
793
874
  }
794
875
  }
795
876
  try {
796
- testConflict(path8, _testedGenMethod, existingMethods);
877
+ testConflict(path9, _testedGenMethod, existingMethods);
797
878
  } catch (e) {
798
- if (path8.indexOf("/admin/") >= 0) {
879
+ if (path9.indexOf("/admin/") >= 0) {
799
880
  generatedMethod += "_admin";
800
881
  _testedGenMethod += "_admin";
801
882
  }
802
883
  }
803
- testConflict(path8, _testedGenMethod, existingMethods);
884
+ testConflict(path9, _testedGenMethod, existingMethods);
804
885
  return generatedMethod;
805
886
  };
806
- var testConflict = (path8, generatedMethod, existingMethods) => {
887
+ var testConflict = (path9, generatedMethod, existingMethods) => {
807
888
  if (existingMethods[generatedMethod]) {
808
- const conflictingMethod = { path: path8, generatedMethod };
889
+ const conflictingMethod = { path: path9, generatedMethod };
809
890
  throw Error(
810
891
  `Duplicate method conflict in ${JSON.stringify(conflictingMethod)},
811
892
  existingMethods: ${JSON.stringify(existingMethods, null, 2)}`
@@ -922,7 +1003,7 @@ var OpenApiSpec = import_zod2.z.object({
922
1003
  var templateApiMethod = ({
923
1004
  classMethod,
924
1005
  httpMethod,
925
- path: path8,
1006
+ path: path9,
926
1007
  pathParams,
927
1008
  bodyParams,
928
1009
  responseClasses,
@@ -931,12 +1012,12 @@ var templateApiMethod = ({
931
1012
  methodParamsNoTypes,
932
1013
  xSecurity
933
1014
  }) => {
934
- let newPath = `'${path8}'`;
1015
+ let newPath = `'${path9}'`;
935
1016
  let snippetMethod = "";
936
1017
  for (const pathParam of pathParams) {
937
1018
  const type = ParserUtils.parseType(pathParam);
938
1019
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
939
- if (path8.match(`{${pathParam.name}}`)) {
1020
+ if (path9.match(`{${pathParam.name}}`)) {
940
1021
  if (type === "string") {
941
1022
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
942
1023
  } else {
@@ -944,9 +1025,9 @@ var templateApiMethod = ({
944
1025
  }
945
1026
  }
946
1027
  }
947
- const snippetShellArgs = ["--location --request", `${httpMethod} '__DOMAIN__${path8}'`, "--header 'accept: application/json'"];
1028
+ const snippetShellArgs = ["--location --request", `${httpMethod} '__DOMAIN__${path9}'`, "--header 'accept: application/json'"];
948
1029
  const snippetApiArgs = [];
949
- if (xSecurity !== void 0 || path8.includes("/admin")) {
1030
+ if (xSecurity !== void 0 || path9.includes("/admin")) {
950
1031
  snippetShellArgs.push("--header 'Authorization: Bearer {access_token}'");
951
1032
  snippetApiArgs.push("{ axiosConfig: { request: { headers: { Authorization: 'Bearer {access_token}' } } } }".trim());
952
1033
  }
@@ -984,7 +1065,7 @@ var templateMethod = ({
984
1065
  classMethod,
985
1066
  description,
986
1067
  httpMethod,
987
- path: path8,
1068
+ path: path9,
988
1069
  pathParams,
989
1070
  bodyParams,
990
1071
  queryParams,
@@ -994,9 +1075,9 @@ var templateMethod = ({
994
1075
  }) => {
995
1076
  let methodParams = "";
996
1077
  let methodParamsNoTypes = "";
997
- let newPath = `'${path8}'`;
1078
+ let newPath = `'${path9}'`;
998
1079
  let importStatements = [];
999
- const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path8);
1080
+ const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path9);
1000
1081
  for (const pathParam of sortedPathParams) {
1001
1082
  const type = ParserUtils.parseType(pathParam);
1002
1083
  if (pathParam.name !== "namespace") {
@@ -1004,7 +1085,7 @@ var templateMethod = ({
1004
1085
  methodParamsNoTypes += pathParam.name + ", ";
1005
1086
  }
1006
1087
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
1007
- if (path8.match(`{${pathParam.name}}`)) {
1088
+ if (path9.match(`{${pathParam.name}}`)) {
1008
1089
  if (type === "string") {
1009
1090
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
1010
1091
  } else {
@@ -1069,7 +1150,7 @@ var POST_FETCH_INCLUDES_PATH = ["/table-query/"];
1069
1150
  var templateQueryMethod = ({
1070
1151
  classMethod,
1071
1152
  httpMethod,
1072
- path: path8,
1153
+ path: path9,
1073
1154
  pathParams,
1074
1155
  responseClasses,
1075
1156
  methodParams,
@@ -1077,14 +1158,14 @@ var templateQueryMethod = ({
1077
1158
  description,
1078
1159
  deprecated
1079
1160
  }) => {
1080
- const isPostFetch = httpMethod === "post" && (POST_FETCH_INCLUDES_PATH.some((p) => path8.includes(p)) || path8.endsWith("/list"));
1161
+ const isPostFetch = httpMethod === "post" && (POST_FETCH_INCLUDES_PATH.some((p) => path9.includes(p)) || path9.endsWith("/list"));
1081
1162
  const isFetch = classMethod.startsWith("fetch");
1082
1163
  const isGet = httpMethod === "get" || isPostFetch || isFetch;
1083
1164
  const queryMethod = isGet ? "useQuery" : "useMutation";
1084
1165
  let mParams = "";
1085
1166
  let mParamsNoTypes = "";
1086
- let newPath = `'${path8}'`;
1087
- const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path8);
1167
+ let newPath = `'${path9}'`;
1168
+ const sortedPathParams = ParserUtils.sortPathParamsByPath(pathParams, path9);
1088
1169
  for (const pathParam of sortedPathParams) {
1089
1170
  const type = ParserUtils.parseType(pathParam);
1090
1171
  if (pathParam.name !== "namespace") {
@@ -1092,7 +1173,7 @@ var templateQueryMethod = ({
1092
1173
  mParamsNoTypes += pathParam.name + ", ";
1093
1174
  }
1094
1175
  const pName = pathParam.name === "namespace" ? "this.namespace" : pathParam.name;
1095
- if (path8.match(`{${pathParam.name}}`)) {
1176
+ if (path9.match(`{${pathParam.name}}`)) {
1096
1177
  if (type === "string") {
1097
1178
  newPath = `${newPath}.replace('{${pathParam.name}}', ${pName})`;
1098
1179
  } else {
@@ -1127,7 +1208,7 @@ export const ${_methodName} = (
1127
1208
  const response =
1128
1209
  (await ${apiGenName}(sdk, { coreConfig: input.coreConfig, axiosConfig: input.axiosConfig }).
1129
1210
  ${classMethod}(${_methodParamsImpl}))
1130
- callback && callback(response)
1211
+ callback?.(response)
1131
1212
  return response.data
1132
1213
  }
1133
1214
 
@@ -1152,7 +1233,7 @@ export const ${_methodName} = (
1152
1233
  const response =
1153
1234
  (await ${apiGenName}(sdk, { coreConfig: input.coreConfig, axiosConfig: input.axiosConfig }).
1154
1235
  ${classMethod}(${_methodParamsImpl}))
1155
- callback && callback(response.data)
1236
+ callback?.(response.data)
1156
1237
  return response.data
1157
1238
  }
1158
1239
 
@@ -1331,11 +1412,11 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
1331
1412
  admin: {},
1332
1413
  public: {}
1333
1414
  };
1334
- for (const [path8, operation] of sortedPathsByLength) {
1335
- if (path8.indexOf("/healthz") >= 0) {
1415
+ for (const [path9, operation] of sortedPathsByLength) {
1416
+ if (path9.indexOf("/healthz") >= 0) {
1336
1417
  continue;
1337
1418
  }
1338
- const isAdminEndpoint = path8.indexOf("/admin/") > -1;
1419
+ const isAdminEndpoint = path9.indexOf("/admin/") > -1;
1339
1420
  const picked = isAdminEndpoint ? result.admin : result.public;
1340
1421
  const {
1341
1422
  arrayDefinitions,
@@ -1353,25 +1434,27 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
1353
1434
  const httpMethods = Object.keys(operation);
1354
1435
  for (const httpMethod of httpMethods) {
1355
1436
  const endpoint = await Endpoint.parseAsync(operation[httpMethod]).catch((error) => {
1356
- console.error(JSON.stringify({ path: path8, httpMethod }, null, 2));
1437
+ console.error(JSON.stringify({ path: path9, httpMethod }, null, 2));
1357
1438
  throw error;
1358
1439
  });
1359
1440
  if (!endpoint.tags) continue;
1360
1441
  const [tag] = endpoint.tags;
1361
- const pathWithBase = `${api.basePath ?? ""}${path8}`;
1442
+ const configBasePath = CodegenConfig.getBasePath();
1443
+ const effectiveBasePath = configBasePath !== void 0 ? configBasePath : api.basePath ?? "";
1444
+ const pathWithBase = `${effectiveBasePath}${path9}`;
1362
1445
  const permissionType = getPermissionType(getPermission(endpoint));
1363
1446
  tagToClassMethodsMapByType[tag] = tagToClassMethodsMapByType[tag] ? tagToClassMethodsMapByType[tag] : {};
1364
1447
  const isForm = endpoint.consumes && endpoint.consumes[0] === "application/x-www-form-urlencoded";
1365
1448
  const classMethod = ParserUtils.generateNaturalLangMethod({
1366
1449
  servicePrefix,
1367
- path: path8,
1450
+ path: path9,
1368
1451
  httpMethod,
1369
1452
  isForm,
1370
1453
  existingMethods: tagToClassMethodsMapByType[tag],
1371
1454
  permissionType
1372
1455
  });
1373
- tagToClassMethodsMapByType[tag][classMethod] = `${path8} ${httpMethod}`;
1374
- generatedMethods[`${path8} ${httpMethod}`] = `${classMethod}`;
1456
+ tagToClassMethodsMapByType[tag][classMethod] = `${path9} ${httpMethod}`;
1457
+ generatedMethods[`${path9} ${httpMethod}`] = `${classMethod}`;
1375
1458
  if (!snippetMap[pathWithBase]) {
1376
1459
  snippetMap[pathWithBase] = {};
1377
1460
  }
@@ -1526,6 +1609,20 @@ var TemplateZod = class {
1526
1609
  // --
1527
1610
  render = (fileName, definition, duplicates) => {
1528
1611
  this.duplicates = duplicates;
1612
+ const overrideAsAny = CodegenConfig.getOverrideAsAny();
1613
+ const override = overrideAsAny?.[fileName];
1614
+ if (override !== void 0) {
1615
+ const shouldOverride = typeof override === "function" ? override(definition) : override;
1616
+ if (shouldOverride) {
1617
+ const template2 = `import { z } from 'zod'
1618
+
1619
+ export const ${fileName} = z.any()
1620
+
1621
+ export interface ${fileName} extends z.TypeOf<typeof ${fileName}> {}
1622
+ `;
1623
+ return { buffer: template2, duplicateFound: false };
1624
+ }
1625
+ }
1529
1626
  const content = this.parseToZodSchema(definition, definition.required || []);
1530
1627
  const containsRecursiveType = this.importClasses.has(fileName);
1531
1628
  if (containsRecursiveType) {
@@ -1828,9 +1925,9 @@ var CodeGenerator = class _CodeGenerator {
1828
1925
  return;
1829
1926
  }
1830
1927
  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");
1928
+ const DIST_DIR_ENDPOINTS = (isAdmin) => import_path4.default.join(DIST_DIR(isAdmin), "endpoints");
1929
+ const DIST_DIR_QUERIES = (isAdmin) => import_path4.default.join(DIST_DIR(isAdmin), "queries");
1930
+ const DIST_DEFINITION_DIR = import_path4.default.join(_CodeGenerator.srcFolder(), "generated-definitions");
1834
1931
  const targetSrcFolder = `${_CodeGenerator.srcFolder()}/`;
1835
1932
  _CodeGenerator.prepareDirs(DIST_DEFINITION_DIR, DIST_DIR, DIST_DIR_ENDPOINTS, DIST_DIR_QUERIES);
1836
1933
  const mainApiList = [];
@@ -1872,22 +1969,24 @@ var CodeGenerator = class _CodeGenerator {
1872
1969
  ParserUtils.writeApiFile(DIST_DIR(isAdminEndpoint), apiGenName, apiBuffer, imports, tagToSdkFunctionDescription[tag]);
1873
1970
  apiList.push(apiGenName);
1874
1971
  indexImportsSet.add(
1875
- ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DIR_ENDPOINTS(isAdminEndpoint), `${classGenName}`), targetSrcFolder)
1972
+ ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DIR_ENDPOINTS(isAdminEndpoint), `${classGenName}`), targetSrcFolder)
1876
1973
  );
1877
1974
  indexImportsSet.add(
1878
- ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DIR(isAdminEndpoint), `${apiGenName}`), targetSrcFolder)
1975
+ ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DIR(isAdminEndpoint), `${apiGenName}`), targetSrcFolder)
1879
1976
  );
1880
1977
  queryFileName && queryImportsSet.add(
1881
1978
  ParserUtils.getRelativePathToWebSdkSrcFolder(
1882
- import_path3.default.join(DIST_DIR(isAdminEndpoint), "queries", `${queryFileName}`),
1979
+ import_path4.default.join(DIST_DIR(isAdminEndpoint), "queries", `${queryFileName}`),
1883
1980
  targetSrcFolder
1884
1981
  )
1885
1982
  );
1886
1983
  }
1887
1984
  mainApiList.push(...apiList);
1888
- indexImportsSet.add(
1889
- ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1890
- );
1985
+ if (CodegenConfig.shouldProduceIndexFiles()) {
1986
+ indexImportsSet.add(
1987
+ ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1988
+ );
1989
+ }
1891
1990
  };
1892
1991
  const writeDefinitions = (api2) => {
1893
1992
  const duplicates = /* @__PURE__ */ new Map();
@@ -1895,7 +1994,7 @@ var CodeGenerator = class _CodeGenerator {
1895
1994
  for (const ref in definitions) {
1896
1995
  const definition = definitions[ref];
1897
1996
  const fileName = ParserUtils.parseRefType(ref);
1898
- const fileExist = import_fs4.default.existsSync(import_path3.default.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
1997
+ const fileExist = import_fs5.default.existsSync(import_path4.default.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
1899
1998
  if (fileExist) {
1900
1999
  const duplicateName = ParserUtils.toCamelCaseWord(ref).replace(".", "").replace(".", "");
1901
2000
  duplicates.set(ref, duplicateName);
@@ -1903,13 +2002,13 @@ var CodeGenerator = class _CodeGenerator {
1903
2002
  const { buffer } = new TemplateZod().render(fileName, definition, /* @__PURE__ */ new Map());
1904
2003
  generatedDefinitions.push(fileName);
1905
2004
  ParserUtils.writeDefinitionFile(DIST_DEFINITION_DIR, fileName, buffer);
1906
- indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DEFINITION_DIR, fileName), targetSrcFolder));
2005
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DEFINITION_DIR, fileName), targetSrcFolder));
1907
2006
  }
1908
2007
  for (const arrayClass of arrayDefinitions) {
1909
2008
  const buffer = new TemplateZodArray().render(arrayClass);
1910
2009
  generatedDefinitions.push(arrayClass);
1911
2010
  ParserUtils.writeDefinitionFile(DIST_DEFINITION_DIR, arrayClass, buffer);
1912
- indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path3.default.join(DIST_DEFINITION_DIR, arrayClass), targetSrcFolder));
2011
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(import_path4.default.join(DIST_DEFINITION_DIR, arrayClass), targetSrcFolder));
1913
2012
  }
1914
2013
  };
1915
2014
  writeApiEndpointFiles(isAdmin);
@@ -1917,9 +2016,11 @@ var CodeGenerator = class _CodeGenerator {
1917
2016
  };
1918
2017
  generatePublicOrAdmin(true);
1919
2018
  generatePublicOrAdmin(false);
1920
- const isGenerateWebSocket = CliParser.isGenerateWebSocket();
1921
- const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
1922
- ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
2019
+ if (CodegenConfig.shouldProduceIndexFiles()) {
2020
+ const isGenerateWebSocket = CliParser.isGenerateWebSocket();
2021
+ const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
2022
+ ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
2023
+ }
1923
2024
  console.log("\nCOMPLETED\n----------\n\n");
1924
2025
  return { indexImports: indexImportsSet, queryImports: queryImportsSet };
1925
2026
  };
@@ -1927,29 +2028,29 @@ var CodeGenerator = class _CodeGenerator {
1927
2028
  };
1928
2029
 
1929
2030
  // src/SwaggerDownloader.ts
2031
+ var fs6 = __toESM(require("fs"));
1930
2032
  var https = __toESM(require("https"));
1931
- var fs5 = __toESM(require("fs"));
1932
- var path5 = __toESM(require("path"));
2033
+ var path6 = __toESM(require("path"));
1933
2034
  var SwaggerDownloader = class _SwaggerDownloader {
1934
2035
  static getDestFile = (targetFileName) => {
1935
2036
  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, "");
2037
+ const destFile = path6.join(destPath, targetFileName);
2038
+ if (fs6.existsSync(destFile)) return destFile;
2039
+ if (!fs6.existsSync(destPath)) fs6.mkdirSync(destPath);
2040
+ fs6.writeFileSync(destFile, "");
1940
2041
  return destFile;
1941
2042
  };
1942
2043
  // session-api.json contains illegal URL encoded character that breaks the codegen
1943
2044
  // e.g. "$ref": "#/definitions/map%5Bstring%5Dinterface%20%7B%7D"
1944
2045
  static postSanitizeDownloadedFile = (filePath) => {
1945
2046
  const searchStr = ["%5B", "%5D", "%20", "%7B", "%7D"];
1946
- fs5.readFile(filePath, "utf8", (err, data) => {
2047
+ fs6.readFile(filePath, "utf8", (err, data) => {
1947
2048
  if (err) throw err;
1948
2049
  let result = data;
1949
2050
  searchStr.forEach((s) => {
1950
2051
  result = result.replace(new RegExp(s, "g"), " ");
1951
2052
  });
1952
- fs5.writeFile(filePath, result, "utf8", (err2) => {
2053
+ fs6.writeFile(filePath, result, "utf8", (err2) => {
1953
2054
  if (err2) throw err2;
1954
2055
  console.log("File updated successfully.");
1955
2056
  });
@@ -1967,7 +2068,7 @@ var SwaggerDownloader = class _SwaggerDownloader {
1967
2068
  if (response.statusCode !== 200) {
1968
2069
  console.log(`SwaggerDownload error with status code: ${response.statusCode}`);
1969
2070
  } else {
1970
- fs5.writeFileSync(destFile, JSON.stringify(JSON.parse(data), null, 2), "utf-8");
2071
+ fs6.writeFileSync(destFile, JSON.stringify(JSON.parse(data), null, 2), "utf-8");
1971
2072
  _SwaggerDownloader.postSanitizeDownloadedFile(destFile);
1972
2073
  console.log(`SwaggerDownload ${url} completed with status code: ${response.statusCode}`);
1973
2074
  }
@@ -1990,8 +2091,8 @@ var SwaggerDownloader = class _SwaggerDownloader {
1990
2091
  };
1991
2092
 
1992
2093
  // src/WebsocketGenerator.ts
1993
- var import_fs5 = __toESM(require("fs"));
1994
- var import_path4 = __toESM(require("path"));
2094
+ var import_fs6 = __toESM(require("fs"));
2095
+ var import_path5 = __toESM(require("path"));
1995
2096
 
1996
2097
  // src/templates/template-ws-class.ts
1997
2098
  var definitionToFunctionName = (type) => {
@@ -2006,7 +2107,7 @@ var renderSendFunction = (name, definition) => {
2006
2107
  send({ type: '${name}', ...data })
2007
2108
  }`;
2008
2109
  };
2009
- var templateWebsocketClass = (name, path8, definitions) => {
2110
+ var templateWebsocketClass = (name, path9, definitions) => {
2010
2111
  const requestDefinitions = Object.keys(definitions).filter((key) => {
2011
2112
  const val = definitions[key];
2012
2113
  return val["x-type"] == "request";
@@ -2065,7 +2166,7 @@ const messageSerializer = (data: Record<string, any>) => {
2065
2166
  export function WebSocketClass(sdk: AccelByteSDK, args?: SdkSetConfigParam) {
2066
2167
  const sdkAssembly = sdk.assembly()
2067
2168
  const baseURL = (args?.coreConfig?.baseURL ?? sdkAssembly.coreConfig.baseURL).replace('http', 'ws')
2068
- const path = '${path8}'
2169
+ const path = '${path9}'
2069
2170
  const url = baseURL + path
2070
2171
  let ws: WebSocket | null = null
2071
2172
  let isDisconnectManually = false
@@ -2314,9 +2415,9 @@ ${renderUnion(["response", "notification"], definitions)}
2314
2415
  // src/WebsocketGenerator.ts
2315
2416
  var WebsocketGenerator = class {
2316
2417
  static srcFolder = () => CliParser.getOutputPath();
2317
- static outputFolder = () => import_path4.default.join(this.srcFolder(), "generated-websocket");
2418
+ static outputFolder = () => import_path5.default.join(this.srcFolder(), "generated-websocket");
2318
2419
  static schemaContent = () => {
2319
- const fileContent = JSON.parse(import_fs5.default.readFileSync(CliParser.getWebSocketSchemaPath(), "utf8"));
2420
+ const fileContent = JSON.parse(import_fs6.default.readFileSync(CliParser.getWebSocketSchemaPath(), "utf8"));
2320
2421
  return fileContent;
2321
2422
  };
2322
2423
  static prepareDirs = () => {
@@ -2326,11 +2427,11 @@ var WebsocketGenerator = class {
2326
2427
  const { name, path: wsPath, definitions } = this.schemaContent();
2327
2428
  const templateDefinitions = templateWebsocketDefinitions(definitions);
2328
2429
  this.prepareDirs();
2329
- const filePath = import_path4.default.join(this.outputFolder(), "WebSocketDefinitions.ts");
2330
- import_fs5.default.writeFileSync(filePath, templateDefinitions, "utf8");
2430
+ const filePath = import_path5.default.join(this.outputFolder(), "WebSocketDefinitions.ts");
2431
+ import_fs6.default.writeFileSync(filePath, templateDefinitions, "utf8");
2331
2432
  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");
2433
+ const filePathClass = import_path5.default.join(this.outputFolder(), "WebSocketClass.ts");
2434
+ import_fs6.default.writeFileSync(filePathClass, templateClass2, "utf8");
2334
2435
  };
2335
2436
  };
2336
2437
 
@@ -2343,24 +2444,28 @@ var generateSdk = async () => {
2343
2444
  if (CliParser.isGenerateWebSocket()) {
2344
2445
  WebsocketGenerator.main();
2345
2446
  }
2447
+ if (!CodegenConfig.shouldProduceIndexFiles()) {
2448
+ return;
2449
+ }
2346
2450
  const indexImportsSet = /* @__PURE__ */ new Set();
2347
2451
  const queryImportsSet = /* @__PURE__ */ new Set();
2348
2452
  const filenamesSet = /* @__PURE__ */ new Set();
2349
2453
  for (const set of arrayOfSets) {
2350
2454
  set.indexImports.forEach((value) => {
2351
- const fileName = import_path5.default.basename(value);
2455
+ const fileName = import_path6.default.basename(value);
2352
2456
  if (!filenamesSet.has(fileName)) {
2353
2457
  indexImportsSet.add(value);
2354
2458
  filenamesSet.add(fileName);
2355
2459
  }
2356
2460
  });
2357
2461
  set.queryImports.forEach((value) => {
2358
- const fileName = import_path5.default.basename(value);
2462
+ const fileName = import_path6.default.basename(value);
2359
2463
  if (!filenamesSet.has(fileName)) {
2360
2464
  queryImportsSet.add(value);
2361
2465
  }
2362
2466
  });
2363
2467
  }
2468
+ const outputPath = CliParser.getOutputPath();
2364
2469
  const indexImportsArray = Array.from(indexImportsSet).sort();
2365
2470
  const queryImportsArray = Array.from(queryImportsSet).sort();
2366
2471
  const filesToImport = indexImportsArray.map((fileToImport) => {
@@ -2369,8 +2474,8 @@ var generateSdk = async () => {
2369
2474
  const queryFilesToImport = queryImportsArray.map((fileToImport) => {
2370
2475
  return `export * from '${fileToImport.replace("\\", "/")}.js'`;
2371
2476
  });
2372
- ParserUtils.writeAllImportsFile(CliParser.getOutputPath(), filesToImport.join("\n"));
2373
- ParserUtils.writeAllQueryImportsFile(CliParser.getOutputPath(), queryFilesToImport.join("\n"));
2477
+ ParserUtils.writeAllImportsFile(outputPath, filesToImport.join("\n"));
2478
+ ParserUtils.writeAllQueryImportsFile(outputPath, queryFilesToImport.join("\n"));
2374
2479
  };
2375
2480
  import_yargs.default.command("download-swaggers", "Download swaggers JSON files", (yargs2) => {
2376
2481
  CliParser.createInstance(yargs2);
@@ -2386,6 +2491,7 @@ import_yargs.default.command("download-swaggers", "Download swaggers JSON files"
2386
2491
  return true;
2387
2492
  });
2388
2493
  CliParser.createInstance(yargs2);
2494
+ await CodegenConfig.loadConfig(import_path6.default.dirname(import_path6.default.resolve(CliParser.getConfigPath())));
2389
2495
  await generateSdk();
2390
2496
  }).option("config", {
2391
2497
  description: "Path to the config file with backend service URLs.",