@accelbyte/codegen 0.0.0-dev-20240912075533 → 0.0.0-dev-20240923031656

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.
@@ -74,6 +74,9 @@ var CliParser = class _CliParser {
74
74
  static skipReactQuery = () => {
75
75
  return _CliParser.instance().argv.skipReactQuery;
76
76
  };
77
+ static isGenerateSnippetOnly = () => {
78
+ return _CliParser.instance().argv.snippetOnly;
79
+ };
77
80
  };
78
81
 
79
82
  // src/CodeGenerator.ts
@@ -939,7 +942,7 @@ var templateApiMethod = ({
939
942
  const snippetApiArgs = [];
940
943
  if (xSecurity !== void 0 || path7.includes("/admin")) {
941
944
  snippetShellArgs.push("--header 'Authorization: Bearer {access_token}'");
942
- snippetApiArgs.push("{ config: { headers: { Authorization: 'Bearer {access_token}' } }}".trim());
945
+ snippetApiArgs.push("{ axiosConfig: { request: { headers: { Authorization: 'Bearer {access_token}' } } } }".trim());
943
946
  }
944
947
  if (httpMethod !== "get") {
945
948
  const curlParams = bodyParams?.map((ob) => {
@@ -1217,11 +1220,11 @@ var templateSdkSnippet = ({
1217
1220
  normMethod = normalizeMethodSnippet(normMethod, "queryParams:");
1218
1221
  normMethod = normalizeMethodSnippet(normMethod, "queryParams?:");
1219
1222
  normMethod += "\n\n//" + methodArr[1];
1220
- const sdkSnippet = `import { Accelbyte } from '@accelbyte/sdk'
1223
+ const sdkSnippet = `import { AccelByte } from '@accelbyte/sdk'
1221
1224
  import { ${serviceNameTitle} } from '@accelbyte/sdk-${serviceNameTitle.toLowerCase()}'
1222
1225
 
1223
- const sdk = Accelbyte.SDK({
1224
- options: {
1226
+ const sdk = AccelByte.SDK({
1227
+ coreConfig: {
1225
1228
  baseURL: 'https://demo.accelbyte.io',
1226
1229
  clientId: '77f88506b6174c3ea4d925f5b4096ce8',
1227
1230
  namespace: 'accelbyte',
@@ -1756,6 +1759,7 @@ var CodeGenerator = class _CodeGenerator {
1756
1759
  const parsedInformation = await SwaggerReaderHelpers.parseAllEndpoints({ api, sdkName, serviceName });
1757
1760
  if (CliParser.getSnippetOutputPath()) {
1758
1761
  try {
1762
+ ParserUtils.mkdirIfNotExist(_CodeGenerator.getGeneratedSnippetsFolder());
1759
1763
  ParserUtils.writeSnippetFile(
1760
1764
  _CodeGenerator.getGeneratedSnippetsFolder(),
1761
1765
  api.info.title,
@@ -1769,9 +1773,13 @@ var CodeGenerator = class _CodeGenerator {
1769
1773
  )
1770
1774
  );
1771
1775
  } catch (err) {
1772
- console.log("Generating snippets", err);
1776
+ console.error("Error generating snippets", err);
1773
1777
  }
1774
1778
  }
1779
+ if (CliParser.isGenerateSnippetOnly()) {
1780
+ console.log("\nSuccessfully generate SDK snippets only\n----------\n\n");
1781
+ return;
1782
+ }
1775
1783
  const DIST_DIR = (isAdmin) => `${_CodeGenerator.getGeneratedFolder(isAdmin)}`;
1776
1784
  const DIST_DIR_ENDPOINTS = (isAdmin) => import_path3.default.join(DIST_DIR(isAdmin), "endpoints");
1777
1785
  const DIST_DIR_QUERIES = (isAdmin) => import_path3.default.join(DIST_DIR(isAdmin), "queries");
@@ -1936,6 +1944,9 @@ var SwaggerDownloader = class _SwaggerDownloader {
1936
1944
  // src/cli.ts
1937
1945
  var generateSdk = async () => {
1938
1946
  const arrayOfSets = await Promise.all(CliParser.getConfigFile().map((config) => CodeGenerator.main(config)));
1947
+ if (CliParser.isGenerateSnippetOnly()) {
1948
+ return;
1949
+ }
1939
1950
  const indexImportsSet = /* @__PURE__ */ new Set();
1940
1951
  const queryImportsSet = /* @__PURE__ */ new Set();
1941
1952
  const filenamesSet = /* @__PURE__ */ new Set();
@@ -1991,5 +2002,8 @@ import_yargs.default.command("download-swaggers", "Download swaggers JSON files"
1991
2002
  }).option("skipReactQuery", {
1992
2003
  description: "Skip generating react query",
1993
2004
  type: "boolean"
2005
+ }).option("snippetOnly", {
2006
+ description: "Only generate snippet",
2007
+ type: "boolean"
1994
2008
  }).demandCommand(1).help().argv;
1995
2009
  //# sourceMappingURL=accelbyte-codegen.js.map