Skip to content

Commit 4215b55

Browse files
committed
fix: update adminforth dependency to version 3.8.2 and remove redundant parseBody calls in endpoint handlers
1 parent 988e707 commit 4215b55

3 files changed

Lines changed: 16 additions & 20 deletions

File tree

index.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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";
22
import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthResource, BeforeLoginConfirmationFunction, AdminForthConfigMenuItem, AdminUser } from "adminforth";
33
import type { PluginOptions, SupportedLanguage } from './types.js';
44
import { 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 || []) {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
"zod": "^4.3.6"
4040
},
4141
"peerDependencies": {
42-
"adminforth": "^3.7.1"
42+
"adminforth": "^3.8.2"
4343
},
4444
"devDependencies": {
4545
"@types/node": "^22.10.7",
46-
"adminforth": "^3.7.1",
46+
"adminforth": "^3.8.2",
4747
"i18n-iso-countries": "^7.13.0",
4848
"semantic-release": "^24.2.1",
4949
"semantic-release-slack-bot": "^4.0.2",

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)