1- import AdminForth , { AdminForthPlugin , parseBody , Filters , suggestIfTypo , AdminForthDataTypes , RAMLock , filtersTools , AdminForthFilterOperators } from "adminforth" ;
1+ import AdminForth , { AdminForthPlugin , Filters , suggestIfTypo , AdminForthDataTypes , RAMLock , filtersTools , AdminForthFilterOperators } from "adminforth" ;
22import type { IAdminForth , IHttpServer , AdminForthComponentDeclaration , AdminForthResourceColumn , AdminForthResource , BeforeLoginConfirmationFunction , AdminForthConfigMenuItem , AdminUser } from "adminforth" ;
33import type { PluginOptions , SupportedLanguage } from './types.js' ;
44import { z } from "zod" ;
@@ -1270,10 +1270,9 @@ export default class I18nPlugin extends AdminForthPlugin {
12701270 server . endpoint ( {
12711271 method : 'POST' ,
12721272 path : `/plugin/${ this . pluginInstanceId } /update-field` ,
1273+ request_schema : updateFieldBodySchema ,
12731274 handler : async ( { body, adminUser, headers, response } ) => {
1274- const parsed = parseBody ( updateFieldBodySchema , body , response ) ;
1275- if ( 'error' in parsed ) return parsed . error ;
1276- const data = parsed . data ;
1275+ const data = body as z . infer < typeof updateFieldBodySchema > ;
12771276 const { resourceId, recordId, field, value, reviewed } = data ;
12781277 if ( resourceId !== this . resourceConfig . resourceId ) {
12791278 return { error : 'Invalid resourceId' } ;
@@ -1336,10 +1335,9 @@ export default class I18nPlugin extends AdminForthPlugin {
13361335 method : 'POST' ,
13371336 path : `/plugin/${ this . pluginInstanceId } /translate-selected-to-languages` ,
13381337 noAuth : false ,
1338+ request_schema : translateSelectedBodySchema ,
13391339 handler : async ( { body, tr, adminUser, response } ) => {
1340- const parsed = parseBody ( translateSelectedBodySchema , body , response ) ;
1341- if ( 'error' in parsed ) return parsed . error ;
1342- const data = parsed . data ;
1340+ const data = body as z . infer < typeof translateSelectedBodySchema > ;
13431341 const selectedLanguages = data . selectedLanguages ;
13441342 const selectedIds = data . selectedIds ;
13451343
@@ -1363,10 +1361,8 @@ export default class I18nPlugin extends AdminForthPlugin {
13631361 server . endpoint ( {
13641362 method : 'POST' ,
13651363 path : `/plugin/${ this . pluginInstanceId } /get_filtered_ids` ,
1364+ request_schema : getFilteredIdsBodySchema ,
13661365 handler : async ( { body, adminUser, headers, query, cookies, requestUrl, response } ) => {
1367- const parsed = parseBody ( getFilteredIdsBodySchema , body , response ) ;
1368- if ( 'error' in parsed ) return parsed . error ;
1369- const data = parsed . data ;
13701366 const resource = this . resourceConfig ;
13711367
13721368 for ( const hook of resource . hooks ?. list ?. beforeDatasourceRequest || [ ] ) {
0 commit comments