@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.
@@ -52,6 +52,9 @@ var CliParser = class _CliParser {
52
52
  static skipReactQuery = () => {
53
53
  return _CliParser.instance().argv.skipReactQuery;
54
54
  };
55
+ static isGenerateSnippetOnly = () => {
56
+ return _CliParser.instance().argv.snippetOnly;
57
+ };
55
58
  };
56
59
 
57
60
  // src/CodeGenerator.ts
@@ -917,7 +920,7 @@ var templateApiMethod = ({
917
920
  const snippetApiArgs = [];
918
921
  if (xSecurity !== void 0 || path7.includes("/admin")) {
919
922
  snippetShellArgs.push("--header 'Authorization: Bearer {access_token}'");
920
- snippetApiArgs.push("{ config: { headers: { Authorization: 'Bearer {access_token}' } }}".trim());
923
+ snippetApiArgs.push("{ axiosConfig: { request: { headers: { Authorization: 'Bearer {access_token}' } } } }".trim());
921
924
  }
922
925
  if (httpMethod !== "get") {
923
926
  const curlParams = bodyParams?.map((ob) => {
@@ -1195,11 +1198,11 @@ var templateSdkSnippet = ({
1195
1198
  normMethod = normalizeMethodSnippet(normMethod, "queryParams:");
1196
1199
  normMethod = normalizeMethodSnippet(normMethod, "queryParams?:");
1197
1200
  normMethod += "\n\n//" + methodArr[1];
1198
- const sdkSnippet = `import { Accelbyte } from '@accelbyte/sdk'
1201
+ const sdkSnippet = `import { AccelByte } from '@accelbyte/sdk'
1199
1202
  import { ${serviceNameTitle} } from '@accelbyte/sdk-${serviceNameTitle.toLowerCase()}'
1200
1203
 
1201
- const sdk = Accelbyte.SDK({
1202
- options: {
1204
+ const sdk = AccelByte.SDK({
1205
+ coreConfig: {
1203
1206
  baseURL: 'https://demo.accelbyte.io',
1204
1207
  clientId: '77f88506b6174c3ea4d925f5b4096ce8',
1205
1208
  namespace: 'accelbyte',
@@ -1734,6 +1737,7 @@ var CodeGenerator = class _CodeGenerator {
1734
1737
  const parsedInformation = await SwaggerReaderHelpers.parseAllEndpoints({ api, sdkName, serviceName });
1735
1738
  if (CliParser.getSnippetOutputPath()) {
1736
1739
  try {
1740
+ ParserUtils.mkdirIfNotExist(_CodeGenerator.getGeneratedSnippetsFolder());
1737
1741
  ParserUtils.writeSnippetFile(
1738
1742
  _CodeGenerator.getGeneratedSnippetsFolder(),
1739
1743
  api.info.title,
@@ -1747,9 +1751,13 @@ var CodeGenerator = class _CodeGenerator {
1747
1751
  )
1748
1752
  );
1749
1753
  } catch (err) {
1750
- console.log("Generating snippets", err);
1754
+ console.error("Error generating snippets", err);
1751
1755
  }
1752
1756
  }
1757
+ if (CliParser.isGenerateSnippetOnly()) {
1758
+ console.log("\nSuccessfully generate SDK snippets only\n----------\n\n");
1759
+ return;
1760
+ }
1753
1761
  const DIST_DIR = (isAdmin) => `${_CodeGenerator.getGeneratedFolder(isAdmin)}`;
1754
1762
  const DIST_DIR_ENDPOINTS = (isAdmin) => path4.join(DIST_DIR(isAdmin), "endpoints");
1755
1763
  const DIST_DIR_QUERIES = (isAdmin) => path4.join(DIST_DIR(isAdmin), "queries");
@@ -1914,6 +1922,9 @@ var SwaggerDownloader = class _SwaggerDownloader {
1914
1922
  // src/cli.ts
1915
1923
  var generateSdk = async () => {
1916
1924
  const arrayOfSets = await Promise.all(CliParser.getConfigFile().map((config) => CodeGenerator.main(config)));
1925
+ if (CliParser.isGenerateSnippetOnly()) {
1926
+ return;
1927
+ }
1917
1928
  const indexImportsSet = /* @__PURE__ */ new Set();
1918
1929
  const queryImportsSet = /* @__PURE__ */ new Set();
1919
1930
  const filenamesSet = /* @__PURE__ */ new Set();
@@ -1969,5 +1980,8 @@ yargs.command("download-swaggers", "Download swaggers JSON files", (yargs2) => {
1969
1980
  }).option("skipReactQuery", {
1970
1981
  description: "Skip generating react query",
1971
1982
  type: "boolean"
1983
+ }).option("snippetOnly", {
1984
+ description: "Only generate snippet",
1985
+ type: "boolean"
1972
1986
  }).demandCommand(1).help().argv;
1973
1987
  //# sourceMappingURL=accelbyte-codegen.mjs.map