@accelbyte/codegen 3.0.5 → 3.0.6
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.
|
@@ -91,7 +91,7 @@ ${generateImports(body, importStatements, makeNewImportVarMap$1(), getImportable
|
|
|
91
91
|
|
|
92
92
|
export class ${className} {
|
|
93
93
|
// @ts-ignore
|
|
94
|
-
constructor(private axiosInstance: AxiosInstance, private namespace: string, private
|
|
94
|
+
constructor(private axiosInstance: AxiosInstance, private namespace: string, private isZodEnabled = true) {}
|
|
95
95
|
${body}
|
|
96
96
|
}
|
|
97
97
|
`;
|
|
@@ -108,6 +108,7 @@ const templateApiClass = (className, body, importStatements, returnMethods) => {
|
|
|
108
108
|
* AUTO GENERATED
|
|
109
109
|
*/
|
|
110
110
|
/* eslint-disable camelcase */
|
|
111
|
+
// @ts-ignore -> ts-expect-error TS6133
|
|
111
112
|
${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap())}
|
|
112
113
|
|
|
113
114
|
export function ${className}(sdk: AccelbyteSDK, args?: ApiArgs) {
|
|
@@ -115,7 +116,7 @@ export function ${className}(sdk: AccelbyteSDK, args?: ApiArgs) {
|
|
|
115
116
|
|
|
116
117
|
const namespace = args?.namespace ? args?.namespace : sdkAssembly.namespace
|
|
117
118
|
const requestConfig = ApiUtils.mergedConfigs(sdkAssembly.config, args)
|
|
118
|
-
const
|
|
119
|
+
const isZodEnabled = typeof window !== "undefined" && localStorage.getItem('ZodEnabled') !== 'false'
|
|
119
120
|
${body}
|
|
120
121
|
|
|
121
122
|
return {
|
|
@@ -1107,7 +1108,7 @@ const templateMethod = ({
|
|
|
1107
1108
|
const url = ${newPath} ${formPayloadString} ${isFileUpload ? "\n// TODO file upload not implemented" : ""}
|
|
1108
1109
|
const resultPromise = this.axiosInstance.${httpMethod}(url, ${dataPayload})
|
|
1109
1110
|
|
|
1110
|
-
${` return Validate.validateOrReturnResponse(this.
|
|
1111
|
+
${` return Validate.validateOrReturnResponse(this.isZodEnabled, () => resultPromise, ${resolvedResponseClassValidated}, '${resolvedResponseClassValidated}')`}
|
|
1111
1112
|
}
|
|
1112
1113
|
`;
|
|
1113
1114
|
if (!isGuardInvoked) {
|
|
@@ -1180,7 +1181,7 @@ const templateApiMethod = ({
|
|
|
1180
1181
|
const methodImpl = `
|
|
1181
1182
|
${descriptionText}
|
|
1182
1183
|
async function ${classMethod}(${methodParams}): Promise<${responseType}> {
|
|
1183
|
-
const $ = new ${classGenName}(Network.create(requestConfig), namespace,
|
|
1184
|
+
const $ = new ${classGenName}(Network.create(requestConfig), namespace, isZodEnabled)
|
|
1184
1185
|
const resp = await $.${classMethod}(${methodParamsNoTypes})
|
|
1185
1186
|
if (resp.error) throw resp.error
|
|
1186
1187
|
return resp.response.data
|