@accelbyte/codegen 0.0.0-dev-20260326093546 → 0.0.0-dev-20260406042959
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.
|
@@ -172,7 +172,8 @@ var getResponseType = ({
|
|
|
172
172
|
defaultType = "unknown"
|
|
173
173
|
}) => {
|
|
174
174
|
const responseClass = responseClasses.length === 1 ? responseClasses?.[0] : "unknown";
|
|
175
|
-
const
|
|
175
|
+
const rawResponseType = responseClass !== "unknown" ? responseClasses?.[0] : defaultType;
|
|
176
|
+
const responseType = rawResponseType === "__dictionary__" ? "Record<string, any>" : rawResponseType;
|
|
176
177
|
return {
|
|
177
178
|
responseType,
|
|
178
179
|
responseTypeInAxiosResponse: `Promise<AxiosResponse<${responseType}>>`,
|
|
@@ -492,13 +493,14 @@ var ParserUtils = class _ParserUtils {
|
|
|
492
493
|
};
|
|
493
494
|
static parseRefImport = (bodyParam) => {
|
|
494
495
|
const $ref = bodyParam?.schema?.$ref || bodyParam?.schema?.items?.$ref;
|
|
495
|
-
if (!$ref) {
|
|
496
|
+
if (!$ref || $ref.endsWith("__dictionary__")) {
|
|
496
497
|
return null;
|
|
497
498
|
}
|
|
498
499
|
const type = _ParserUtils.parseRefType($ref);
|
|
499
500
|
return `import { ${type} } from '../../generated-definitions/${type}.js'`;
|
|
500
501
|
};
|
|
501
502
|
static parseRefType = ($ref) => {
|
|
503
|
+
if ($ref.endsWith("__dictionary__")) return "__dictionary__";
|
|
502
504
|
let ref = $ref.replace(".", "/");
|
|
503
505
|
if (ref[ref.length - 1] === "." || ref[ref.length - 1] === "/") {
|
|
504
506
|
ref = ref.slice(0, -1);
|
|
@@ -1071,6 +1073,7 @@ var templateMethod = ({
|
|
|
1071
1073
|
let dataType = null;
|
|
1072
1074
|
if (httpMethod !== "get") {
|
|
1073
1075
|
dataType = ParserUtils.parseBodyParamsType(bodyParams);
|
|
1076
|
+
if (dataType === "__dictionary__") dataType = "Record<string, any>";
|
|
1074
1077
|
importStatements = ParserUtils.parseBodyParamsImports(bodyParams);
|
|
1075
1078
|
methodParams += dataType ? `data: ${dataType},` : "";
|
|
1076
1079
|
methodParamsNoTypes += dataType ? `data,` : "";
|
|
@@ -1094,7 +1097,7 @@ var templateMethod = ({
|
|
|
1094
1097
|
}
|
|
1095
1098
|
const isFileUpload = methodParams.indexOf("data: {file") > -1;
|
|
1096
1099
|
const { responseType, responseTypeInResponse } = getResponseType({ responseClasses });
|
|
1097
|
-
const resolvedResponseClassValidated = responseType !== "unknown" ? `${responseType}` : "z.unknown()";
|
|
1100
|
+
const resolvedResponseClassValidated = responseClasses.length === 1 && responseClasses[0] === "__dictionary__" ? "z.record(z.string(), z.any())" : responseType !== "unknown" ? `${responseType}` : "z.unknown()";
|
|
1098
1101
|
methodParams = (queryParamsType ? `${methodParams} ${queryParamsType}` : methodParams).replace(/,\s*$/, "");
|
|
1099
1102
|
methodParamsNoTypes = queryParamsType ? `${methodParamsNoTypes} queryParams` : methodParamsNoTypes;
|
|
1100
1103
|
const isGuardInvoked = ["get", "post", "put", "patch", "delete"].includes(httpMethod);
|
|
@@ -1438,7 +1441,7 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
|
|
|
1438
1441
|
const responseClass = responseClasses.length > 1 ? null : responseClasses?.[0];
|
|
1439
1442
|
const { className, classGenName } = ParserUtils.generateClassName(tag, isAdminEndpoint);
|
|
1440
1443
|
tagToClassImportsRecord[className] = tagToClassImportsRecord[className] ? tagToClassImportsRecord[className] : {};
|
|
1441
|
-
if (responseClass) {
|
|
1444
|
+
if (responseClass && responseClass !== "__dictionary__") {
|
|
1442
1445
|
tagToClassImportsRecord[className][responseClass] = `import { ${responseClass} } from '../../generated-definitions/${responseClass}.js'`;
|
|
1443
1446
|
}
|
|
1444
1447
|
if (responseClass && responseClass.endsWith("Array")) {
|
|
@@ -1686,7 +1689,14 @@ ${exportedTypeString}
|
|
|
1686
1689
|
};
|
|
1687
1690
|
} else if (type) {
|
|
1688
1691
|
if (type === "object" && definition.additionalProperties) {
|
|
1689
|
-
const
|
|
1692
|
+
const additionalProps = definition.additionalProperties;
|
|
1693
|
+
if (Object.keys(additionalProps).length === 0) {
|
|
1694
|
+
return {
|
|
1695
|
+
schemaString: `${schemaAttribute} z.record(z.any())${schemaRequired}`,
|
|
1696
|
+
typeString: `${typeAttribute} Record<string, any>${typeNullishability}`
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
const zodAttribute = this.parseToZodAttribute("", additionalProps, [""]);
|
|
1690
1700
|
return {
|
|
1691
1701
|
schemaString: `${schemaAttribute} z.record(${zodAttribute.schemaString})${schemaRequired}`,
|
|
1692
1702
|
typeString: `${typeAttribute} Record<string, ${zodAttribute.typeString}>${typeNullishability}`
|
|
@@ -1967,6 +1977,7 @@ var CodeGenerator = class _CodeGenerator {
|
|
|
1967
1977
|
const duplicates = /* @__PURE__ */ new Map();
|
|
1968
1978
|
const definitions = api2?.components?.schemas || api2.definitions;
|
|
1969
1979
|
for (const ref in definitions) {
|
|
1980
|
+
if (ref === "__dictionary__") continue;
|
|
1970
1981
|
const definition = definitions[ref];
|
|
1971
1982
|
const fileName = ParserUtils.parseRefType(ref);
|
|
1972
1983
|
const fileExist = fs5.existsSync(path5.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
|
|
@@ -2022,6 +2033,7 @@ var SwaggerDownloader = class _SwaggerDownloader {
|
|
|
2022
2033
|
fs6.readFile(filePath, "utf8", (err, data) => {
|
|
2023
2034
|
if (err) throw err;
|
|
2024
2035
|
let result = data;
|
|
2036
|
+
result = result.replace(new RegExp("map%5Bstring%5Dinterface%20%7B%7D", "g"), "__dictionary__").replace(new RegExp("map\\[string\\]interface \\{\\}", "g"), "__dictionary__").replace(new RegExp("map\\[string\\]any", "g"), "__dictionary__");
|
|
2025
2037
|
searchStr.forEach((s) => {
|
|
2026
2038
|
result = result.replace(new RegExp(s, "g"), " ");
|
|
2027
2039
|
});
|