@adminforth/i18n 2.1.0 → 2.1.1

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.
package/build.log CHANGED
@@ -20,5 +20,5 @@ custom/package.json
20
20
  custom/pnpm-lock.yaml
21
21
  custom/tsconfig.json
22
22
 
23
- sent 45,262 bytes received 305 bytes 91,134.00 bytes/sec
23
+ sent 45,278 bytes received 305 bytes 91,166.00 bytes/sec
24
24
  total size is 44,110 speedup is 0.97
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { AdminForthPlugin, parseBody, Filters, suggestIfTypo, AdminForthDataTypes, RAMLock, filtersTools, AdminForthFilterOperators } from "adminforth";
10
+ import { AdminForthPlugin, Filters, suggestIfTypo, AdminForthDataTypes, RAMLock, filtersTools, AdminForthFilterOperators } from "adminforth";
11
11
  import { z } from "zod";
12
12
  import iso6391 from 'iso-639-1';
13
13
  const updateFieldBodySchema = z.object({
@@ -1036,11 +1036,9 @@ export default class I18nPlugin extends AdminForthPlugin {
1036
1036
  server.endpoint({
1037
1037
  method: 'POST',
1038
1038
  path: `/plugin/${this.pluginInstanceId}/update-field`,
1039
+ request_schema: updateFieldBodySchema,
1039
1040
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, response }) {
1040
- const parsed = parseBody(updateFieldBodySchema, body, response);
1041
- if ('error' in parsed)
1042
- return parsed.error;
1043
- const data = parsed.data;
1041
+ const data = body;
1044
1042
  const { resourceId, recordId, field, value, reviewed } = data;
1045
1043
  if (resourceId !== this.resourceConfig.resourceId) {
1046
1044
  return { error: 'Invalid resourceId' };
@@ -1095,11 +1093,9 @@ export default class I18nPlugin extends AdminForthPlugin {
1095
1093
  method: 'POST',
1096
1094
  path: `/plugin/${this.pluginInstanceId}/translate-selected-to-languages`,
1097
1095
  noAuth: false,
1096
+ request_schema: translateSelectedBodySchema,
1098
1097
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, tr, adminUser, response }) {
1099
- const parsed = parseBody(translateSelectedBodySchema, body, response);
1100
- if ('error' in parsed)
1101
- return parsed.error;
1102
- const data = parsed.data;
1098
+ const data = body;
1103
1099
  const selectedLanguages = data.selectedLanguages;
1104
1100
  const selectedIds = data.selectedIds;
1105
1101
  if (!Array.isArray(selectedIds) || selectedIds.length === 0) {
@@ -1119,12 +1115,9 @@ export default class I18nPlugin extends AdminForthPlugin {
1119
1115
  server.endpoint({
1120
1116
  method: 'POST',
1121
1117
  path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
1118
+ request_schema: getFilteredIdsBodySchema,
1122
1119
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, headers, query, cookies, requestUrl, response }) {
1123
1120
  var _b, _c;
1124
- const parsed = parseBody(getFilteredIdsBodySchema, body, response);
1125
- if ('error' in parsed)
1126
- return parsed.error;
1127
- const data = parsed.data;
1128
1121
  const resource = this.resourceConfig;
1129
1122
  for (const hook of ((_c = (_b = resource.hooks) === null || _b === void 0 ? void 0 : _b.list) === null || _c === void 0 ? void 0 : _c.beforeDatasourceRequest) || []) {
1130
1123
  const filterTools = filtersTools.get(body);
package/index.ts CHANGED
@@ -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";
2
2
  import type { IAdminForth, IHttpServer, AdminForthComponentDeclaration, AdminForthResourceColumn, AdminForthResource, BeforeLoginConfirmationFunction, AdminForthConfigMenuItem, AdminUser } from "adminforth";
3
3
  import type { PluginOptions, SupportedLanguage } from './types.js';
4
4
  import { z } from "zod";
@@ -1270,10 +1270,9 @@ export default class I18nPlugin extends AdminForthPlugin {
1270
1270
  server.endpoint({
1271
1271
  method: 'POST',
1272
1272
  path: `/plugin/${this.pluginInstanceId}/update-field`,
1273
+ request_schema: updateFieldBodySchema,
1273
1274
  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>;
1277
1276
  const { resourceId, recordId, field, value, reviewed } = data;
1278
1277
  if (resourceId !== this.resourceConfig.resourceId) {
1279
1278
  return { error: 'Invalid resourceId' };
@@ -1336,10 +1335,9 @@ export default class I18nPlugin extends AdminForthPlugin {
1336
1335
  method: 'POST',
1337
1336
  path: `/plugin/${this.pluginInstanceId}/translate-selected-to-languages`,
1338
1337
  noAuth: false,
1338
+ request_schema: translateSelectedBodySchema,
1339
1339
  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>;
1343
1341
  const selectedLanguages = data.selectedLanguages;
1344
1342
  const selectedIds = data.selectedIds;
1345
1343
 
@@ -1363,10 +1361,8 @@ export default class I18nPlugin extends AdminForthPlugin {
1363
1361
  server.endpoint({
1364
1362
  method: 'POST',
1365
1363
  path: `/plugin/${this.pluginInstanceId}/get_filtered_ids`,
1364
+ request_schema: getFilteredIdsBodySchema,
1366
1365
  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;
1370
1366
  const resource = this.resourceConfig;
1371
1367
 
1372
1368
  for (const hook of resource.hooks?.list?.beforeDatasourceRequest || []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/i18n",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -39,11 +39,11 @@
39
39
  "zod": "^4.3.6"
40
40
  },
41
41
  "peerDependencies": {
42
- "adminforth": "^3.7.1"
42
+ "adminforth": "^3.8.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^22.10.7",
46
- "adminforth": "^3.7.1",
46
+ "adminforth": "^3.8.2",
47
47
  "i18n-iso-countries": "^7.13.0",
48
48
  "semantic-release": "^24.2.1",
49
49
  "semantic-release-slack-bot": "^4.0.2",