@accelbyte/codegen 3.0.4 → 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.
@@ -114,7 +114,7 @@ ${generateImports(body, importStatements, makeNewImportVarMap$1(), getImportable
114
114
 
115
115
  export class ${className} {
116
116
  // @ts-ignore
117
- constructor(private axiosInstance: AxiosInstance, private namespace: string, private isValidationEnabled = true) {}
117
+ constructor(private axiosInstance: AxiosInstance, private namespace: string, private isZodEnabled = true) {}
118
118
  ${body}
119
119
  }
120
120
  `;
@@ -131,6 +131,7 @@ const templateApiClass = (className, body, importStatements, returnMethods) => {
131
131
  * AUTO GENERATED
132
132
  */
133
133
  /* eslint-disable camelcase */
134
+ // @ts-ignore -> ts-expect-error TS6133
134
135
  ${generateImports(body, importStatements, makeNewImportVarMap(), getImportableVarMap())}
135
136
 
136
137
  export function ${className}(sdk: AccelbyteSDK, args?: ApiArgs) {
@@ -138,7 +139,7 @@ export function ${className}(sdk: AccelbyteSDK, args?: ApiArgs) {
138
139
 
139
140
  const namespace = args?.namespace ? args?.namespace : sdkAssembly.namespace
140
141
  const requestConfig = ApiUtils.mergedConfigs(sdkAssembly.config, args)
141
- const isValidationEnabled = args?.isValidationEnabled !== false
142
+ const isZodEnabled = typeof window !== "undefined" && localStorage.getItem('ZodEnabled') !== 'false'
142
143
  ${body}
143
144
 
144
145
  return {
@@ -1130,7 +1131,7 @@ const templateMethod = ({
1130
1131
  const url = ${newPath} ${formPayloadString} ${isFileUpload ? "\n// TODO file upload not implemented" : ""}
1131
1132
  const resultPromise = this.axiosInstance.${httpMethod}(url, ${dataPayload})
1132
1133
 
1133
- ${` return this.isValidationEnabled ? Validate.responseType(() => resultPromise, ${resolvedResponseClassValidated}, '${resolvedResponseClassValidated}') : Validate.unsafeResponse(() => resultPromise)`}
1134
+ ${` return Validate.validateOrReturnResponse(this.isZodEnabled, () => resultPromise, ${resolvedResponseClassValidated}, '${resolvedResponseClassValidated}')`}
1134
1135
  }
1135
1136
  `;
1136
1137
  if (!isGuardInvoked) {
@@ -1203,7 +1204,7 @@ const templateApiMethod = ({
1203
1204
  const methodImpl = `
1204
1205
  ${descriptionText}
1205
1206
  async function ${classMethod}(${methodParams}): Promise<${responseType}> {
1206
- const $ = new ${classGenName}(Network.create(requestConfig), namespace, isValidationEnabled)
1207
+ const $ = new ${classGenName}(Network.create(requestConfig), namespace, isZodEnabled)
1207
1208
  const resp = await $.${classMethod}(${methodParamsNoTypes})
1208
1209
  if (resp.error) throw resp.error
1209
1210
  return resp.response.data