@accelbyte/codegen 0.0.0-dev-20260320085237 → 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.
- package/README.md +12 -4
- package/dist/accelbyte-codegen.d.mts +22 -0
- package/dist/accelbyte-codegen.d.ts +22 -0
- package/dist/accelbyte-codegen.js +27 -5
- package/dist/accelbyte-codegen.js.map +1 -1
- package/dist/accelbyte-codegen.mjs +24 -5
- package/dist/accelbyte-codegen.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -83,8 +83,8 @@ var CodegenConfig = class _CodegenConfig {
|
|
|
83
83
|
const loaded = await import(pathToFileURL(configPath).href);
|
|
84
84
|
_CodegenConfig.config = loaded.default ?? loaded ?? {};
|
|
85
85
|
}
|
|
86
|
-
static
|
|
87
|
-
return _CodegenConfig.config.
|
|
86
|
+
static shouldProduceIndexFiles() {
|
|
87
|
+
return _CodegenConfig.config.unstable_shouldProduceIndexFiles ?? true;
|
|
88
88
|
}
|
|
89
89
|
static getBasePath() {
|
|
90
90
|
return _CodegenConfig.config.basePath;
|
|
@@ -218,13 +218,28 @@ var generateImports = (body, importStatements, makeNewImportVarMap3, getImportab
|
|
|
218
218
|
${importStatements.sort().join("\n")}`;
|
|
219
219
|
};
|
|
220
220
|
var templateClass = (className, body, importStatements) => {
|
|
221
|
+
const attributes = {
|
|
222
|
+
definitions: ["private axiosInstance: AxiosInstance", "private namespace: string", "private useSchemaValidation: boolean"],
|
|
223
|
+
assignments: ["this.axiosInstance = axiosInstance", "this.namespace = namespace", "this.useSchemaValidation = useSchemaValidation"]
|
|
224
|
+
};
|
|
225
|
+
let namespaceConstructor = "namespace";
|
|
226
|
+
if (!body.includes(".replace('{namespace}', this.namespace)")) {
|
|
227
|
+
namespaceConstructor = "_namespace";
|
|
228
|
+
attributes.definitions.splice(1, 1);
|
|
229
|
+
attributes.assignments.splice(1, 1);
|
|
230
|
+
}
|
|
221
231
|
return `/**
|
|
222
232
|
* AUTO GENERATED
|
|
223
233
|
*/
|
|
224
234
|
${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap(), CLASS_TYPE_ONLY_VARS)}
|
|
225
235
|
|
|
226
236
|
export class ${className} {
|
|
227
|
-
|
|
237
|
+
${attributes.definitions.join("\n")}
|
|
238
|
+
|
|
239
|
+
constructor(axiosInstance: AxiosInstance, ${namespaceConstructor}: string, useSchemaValidation = true) {
|
|
240
|
+
${attributes.assignments.join("\n")}
|
|
241
|
+
}
|
|
242
|
+
|
|
228
243
|
${body}
|
|
229
244
|
}
|
|
230
245
|
`;
|
|
@@ -681,6 +696,7 @@ var ParserUtils = class _ParserUtils {
|
|
|
681
696
|
return queryFileName;
|
|
682
697
|
}
|
|
683
698
|
static writeXVersion(distDir, xversionJson, apiInfo) {
|
|
699
|
+
fs4.mkdirSync(distDir, { recursive: true });
|
|
684
700
|
if (xversionJson) {
|
|
685
701
|
console.log("x-version:", xversionJson);
|
|
686
702
|
fs4.writeFileSync(`${distDir}/version.json`, JSON.stringify(xversionJson, null, 2));
|
|
@@ -1941,7 +1957,7 @@ var CodeGenerator = class _CodeGenerator {
|
|
|
1941
1957
|
);
|
|
1942
1958
|
}
|
|
1943
1959
|
mainApiList.push(...apiList);
|
|
1944
|
-
if (CodegenConfig.
|
|
1960
|
+
if (CodegenConfig.shouldProduceIndexFiles()) {
|
|
1945
1961
|
indexImportsSet.add(
|
|
1946
1962
|
ParserUtils.getRelativePathToWebSdkSrcFolder(path5.join(_CodeGenerator.srcFolder(), serviceNameTitle), targetSrcFolder)
|
|
1947
1963
|
);
|
|
@@ -1975,7 +1991,7 @@ var CodeGenerator = class _CodeGenerator {
|
|
|
1975
1991
|
};
|
|
1976
1992
|
generatePublicOrAdmin(true);
|
|
1977
1993
|
generatePublicOrAdmin(false);
|
|
1978
|
-
if (CodegenConfig.
|
|
1994
|
+
if (CodegenConfig.shouldProduceIndexFiles()) {
|
|
1979
1995
|
const isGenerateWebSocket = CliParser.isGenerateWebSocket();
|
|
1980
1996
|
const apiIndexBuff = templateApiIndex(serviceNameTitle, mainApiList, isGenerateWebSocket);
|
|
1981
1997
|
ParserUtils.writeApiMainFile(_CodeGenerator.srcFolder(), serviceNameTitle, apiIndexBuff);
|
|
@@ -2403,6 +2419,9 @@ var generateSdk = async () => {
|
|
|
2403
2419
|
if (CliParser.isGenerateWebSocket()) {
|
|
2404
2420
|
WebsocketGenerator.main();
|
|
2405
2421
|
}
|
|
2422
|
+
if (!CodegenConfig.shouldProduceIndexFiles()) {
|
|
2423
|
+
return;
|
|
2424
|
+
}
|
|
2406
2425
|
const indexImportsSet = /* @__PURE__ */ new Set();
|
|
2407
2426
|
const queryImportsSet = /* @__PURE__ */ new Set();
|
|
2408
2427
|
const filenamesSet = /* @__PURE__ */ new Set();
|