@adminforth/many2many 1.2.11 → 1.3.0

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
@@ -8,5 +8,5 @@ custom/ManyToManyInput.vue
8
8
  custom/ManyToManyShow.vue
9
9
  custom/tsconfig.json
10
10
 
11
- sent 4,979 bytes received 77 bytes 10,112.00 bytes/sec
11
+ sent 4,983 bytes received 77 bytes 10,120.00 bytes/sec
12
12
  total size is 4,701 speedup is 0.93
package/dist/index.js CHANGED
@@ -7,7 +7,12 @@ 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, Filters } from "adminforth";
10
+ import { AdminForthPlugin, parseBody, Filters } from "adminforth";
11
+ import { z } from "zod";
12
+ const getJunctionRecordsBodySchema = z.object({
13
+ recordId: z.union([z.string(), z.number()]).nullish(),
14
+ returnLabels: z.boolean().nullish(),
15
+ }).strict();
11
16
  export default class ManyToManyPlugin extends AdminForthPlugin {
12
17
  constructor(options) {
13
18
  super(options, import.meta.url);
@@ -193,8 +198,12 @@ export default class ManyToManyPlugin extends AdminForthPlugin {
193
198
  server.endpoint({
194
199
  method: 'POST',
195
200
  path: `/plugin/${this.pluginInstanceId}/get-junctionResource-records`,
196
- handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body }) {
197
- const { recordId, returnLabels } = body;
201
+ handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, response }) {
202
+ const parsed = parseBody(getJunctionRecordsBodySchema, body, response);
203
+ if ('error' in parsed)
204
+ return parsed.error;
205
+ const data = parsed.data;
206
+ const { recordId, returnLabels } = data;
198
207
  if (recordId === undefined || recordId === null || recordId === '') {
199
208
  return { ok: true, data: [] };
200
209
  }
package/index.ts CHANGED
@@ -1,6 +1,12 @@
1
- import { AdminForthPlugin, Filters } from "adminforth";
1
+ import { AdminForthPlugin, parseBody, Filters } from "adminforth";
2
2
  import type { IAdminForth, IHttpServer, AdminForthResourcePages, AdminForthResourceColumn, AdminForthDataTypes, AdminForthResource } from "adminforth";
3
3
  import type { PluginOptions } from './types.js';
4
+ import { z } from "zod";
5
+
6
+ const getJunctionRecordsBodySchema = z.object({
7
+ recordId: z.union([z.string(), z.number()]).nullish(),
8
+ returnLabels: z.boolean().nullish(),
9
+ }).strict();
4
10
 
5
11
  export default class ManyToManyPlugin extends AdminForthPlugin {
6
12
  options: PluginOptions;
@@ -194,8 +200,11 @@ export default class ManyToManyPlugin extends AdminForthPlugin {
194
200
  server.endpoint({
195
201
  method: 'POST',
196
202
  path: `/plugin/${this.pluginInstanceId}/get-junctionResource-records`,
197
- handler: async ({ body }) => {
198
- const { recordId, returnLabels } = body;
203
+ handler: async ({ body, response }) => {
204
+ const parsed = parseBody(getJunctionRecordsBodySchema, body, response);
205
+ if ('error' in parsed) return parsed.error;
206
+ const data = parsed.data;
207
+ const { recordId, returnLabels } = data;
199
208
  if (recordId === undefined || recordId === null || recordId === '') {
200
209
  return { ok: true, data: [] };
201
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/many2many",
3
- "version": "1.2.11",
3
+ "version": "1.3.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -40,14 +40,17 @@
40
40
  }
41
41
  ]
42
42
  },
43
+ "dependencies": {
44
+ "zod": "^4.3.6"
45
+ },
43
46
  "devDependencies": {
44
47
  "@types/node": "latest",
45
- "adminforth": "^3.6.21",
48
+ "adminforth": "^3.7.1",
46
49
  "semantic-release": "^24.2.1",
47
50
  "semantic-release-slack-bot": "^4.0.2",
48
51
  "typescript": "^5.7.3"
49
52
  },
50
53
  "peerDependencies": {
51
- "adminforth": "^3.6.21"
54
+ "adminforth": "^3.7.1"
52
55
  }
53
56
  }