@accelbyte/codegen 0.0.0-dev-20260407233405 → 0.0.0-dev-20260422072053

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.
@@ -84,13 +84,16 @@ var CodegenConfig = class _CodegenConfig {
84
84
  _CodegenConfig.config = loaded.default ?? loaded ?? {};
85
85
  }
86
86
  static shouldProduceIndexFiles() {
87
- return _CodegenConfig.config.unstable_shouldProduceIndexFiles ?? true;
87
+ return _CodegenConfig.config.shouldProduceIndexFiles ?? true;
88
88
  }
89
89
  static getBasePath() {
90
90
  return _CodegenConfig.config.basePath;
91
91
  }
92
92
  static getOverrideAsAny() {
93
- return _CodegenConfig.config.unstable_overrideAsAny;
93
+ return _CodegenConfig.config.overrideAsAny;
94
+ }
95
+ static splitOutputByServiceName() {
96
+ return _CodegenConfig.config.unstable_splitOutputByServiceName ?? false;
94
97
  }
95
98
  /** Reset to defaults — used for testing */
96
99
  static reset() {
@@ -858,6 +861,16 @@ var resolveConflicts = ({ path: path9, generatedMethod, testedGeneratedMethod, e
858
861
  _testedGenMethod += "_admin";
859
862
  }
860
863
  }
864
+ try {
865
+ testConflict(path9, _testedGenMethod, existingMethods);
866
+ } catch (e) {
867
+ const parentSegmentMatch = path9.match(/\/([^/{}]+)\/{[^}]+}\/[^/]*$/);
868
+ if (parentSegmentMatch) {
869
+ const suffix = "_By" + _.upperFirst(_.camelCase(parentSegmentMatch[1]));
870
+ generatedMethod += suffix;
871
+ _testedGenMethod += suffix;
872
+ }
873
+ }
861
874
  testConflict(path9, _testedGenMethod, existingMethods);
862
875
  return generatedMethod;
863
876
  };
@@ -1882,8 +1895,11 @@ var CodeGenerator = class _CodeGenerator {
1882
1895
  const queryImportsSet = /* @__PURE__ */ new Set();
1883
1896
  const apiInfo = { ...api.info, "x-version": api["x-version"]?.version };
1884
1897
  console.log("----------\nGenerating API:", { title: apiInfo.title, version: apiInfo.version });
1898
+ const isSplitByService = CodegenConfig.splitOutputByServiceName();
1899
+ const srcFolder = isSplitByService ? path5.join(CliParser.getOutputPath(), serviceName) : CliParser.getOutputPath();
1900
+ const targetSrcFolder = `${CliParser.getOutputPath()}/`;
1885
1901
  if (!CliParser.isGenerateSnippetOnly()) {
1886
- ParserUtils.writeXVersion(_CodeGenerator.srcFolder(), api["x-version"], api.info);
1902
+ ParserUtils.writeXVersion(srcFolder, api["x-version"], api.info);
1887
1903
  }
1888
1904
  const parsedInformation = await SwaggerReaderHelpers.parseAllEndpoints({ api, sdkName, serviceName });
1889
1905
  if (CliParser.getSnippetOutputPath()) {
@@ -1909,11 +1925,10 @@ var CodeGenerator = class _CodeGenerator {
1909
1925
  console.log("\nSuccessfully generate SDK snippets only\n----------\n\n");
1910
1926
  return;
1911
1927
  }
1912
- const DIST_DIR = (isAdmin) => `${_CodeGenerator.getGeneratedFolder(isAdmin)}`;
1928
+ const DIST_DIR = (isAdmin) => path5.join(srcFolder, isAdmin ? "generated-admin" : "generated-public");
1913
1929
  const DIST_DIR_ENDPOINTS = (isAdmin) => path5.join(DIST_DIR(isAdmin), "endpoints");
1914
1930
  const DIST_DIR_QUERIES = (isAdmin) => path5.join(DIST_DIR(isAdmin), "queries");
1915
- const DIST_DEFINITION_DIR = path5.join(_CodeGenerator.srcFolder(), "generated-definitions");
1916
- const targetSrcFolder = `${_CodeGenerator.srcFolder()}/`;
1931
+ const DIST_DEFINITION_DIR = path5.join(srcFolder, "generated-definitions");
1917
1932
  _CodeGenerator.prepareDirs(DIST_DEFINITION_DIR, DIST_DIR, DIST_DIR_ENDPOINTS, DIST_DIR_QUERIES);
1918
1933
  const mainApiList = [];
1919
1934
  const generatedDefinitions = [];
@@ -1968,9 +1983,7 @@ var CodeGenerator = class _CodeGenerator {
1968
1983
  }
1969
1984
  mainApiList.push(...apiList);
1970
1985
  if (CodegenConfig.shouldProduceIndexFiles()) {
1971
- indexImportsSet.add(
1972
- ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
1973
- );
1986
+ indexImportsSet.add(ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(srcFolder, serviceNameTitle), targetSrcFolder));
1974
1987
  }
1975
1988
  };
1976
1989
  const writeDefinitions = (api2) => {
@@ -2005,7 +2018,7 @@ var CodeGenerator = class _CodeGenerator {
2005
2018
  if (CodegenConfig.shouldProduceIndexFiles()) {
2006
2019
  const isGenerateWebSocket = CliParser.isGenerateWebSocket();
2007
2020
  const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
2008
- ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
2021
+ ParserUtils.writeApiMainFile(srcFolder, serviceNameTitle, apiIndexBuff);
2009
2022
  }
2010
2023
  console.log("\nCOMPLETED\n----------\n\n");
2011
2024
  return { indexImports: indexImportsSet, queryImports: queryImportsSet };