@adminforth/rich-editor 2.1.0 → 2.1.2

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/dist/index.d.ts CHANGED
@@ -14,6 +14,5 @@ export default class RichEditorPlugin extends AdminForthPlugin {
14
14
  validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
15
15
  instanceUniqueRepresentation(pluginOptions: any): string;
16
16
  generateRecordContext(record: any, maxFields: number, inputFieldLimit: number, partsCount: number): string;
17
- private parseBody;
18
17
  setupEndpoints(server: IHttpServer): void;
19
18
  }
package/dist/index.js CHANGED
@@ -218,23 +218,14 @@ export default class RichEditorPlugin extends AdminForthPlugin {
218
218
  });
219
219
  return JSON.stringify(Object.fromEntries(fields));
220
220
  }
221
- parseBody(schema, body, response) {
222
- const parsed = schema.safeParse(body !== null && body !== void 0 ? body : {});
223
- if (!parsed.success) {
224
- response.setStatus(422, parsed.error.message);
225
- return null;
226
- }
227
- return parsed.data;
228
- }
229
221
  setupEndpoints(server) {
230
222
  server.endpoint({
231
223
  method: 'POST',
232
224
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
225
+ request_schema: doCompleteBodySchema,
233
226
  handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers, response }) {
234
227
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
235
- const data = this.parseBody(doCompleteBodySchema, body, response);
236
- if (!data)
237
- return;
228
+ const data = body;
238
229
  const { record } = data;
239
230
  if (!record) {
240
231
  return { completion: [] };
package/index.ts CHANGED
@@ -275,26 +275,13 @@ export default class RichEditorPlugin extends AdminForthPlugin {
275
275
  return JSON.stringify(Object.fromEntries(fields));
276
276
  }
277
277
 
278
- private parseBody<T>(
279
- schema: z.ZodType<T>,
280
- body: unknown,
281
- response: { setStatus: (code: number, message: string) => void },
282
- ): T | null {
283
- const parsed = schema.safeParse(body ?? {});
284
- if (!parsed.success) {
285
- response.setStatus(422, parsed.error.message);
286
- return null;
287
- }
288
- return parsed.data;
289
- }
290
-
291
278
  setupEndpoints(server: IHttpServer) {
292
279
  server.endpoint({
293
280
  method: 'POST',
294
281
  path: `/plugin/${this.pluginInstanceId}/doComplete`,
282
+ request_schema: doCompleteBodySchema,
295
283
  handler: async ({ body, headers, response }) => {
296
- const data = this.parseBody(doCompleteBodySchema, body, response);
297
- if (!data) return;
284
+ const data = body as z.infer<typeof doCompleteBodySchema>;
298
285
  const { record } = data;
299
286
 
300
287
  if (!record) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/rich-editor",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Rich editor plugin for adminforth",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,15 +23,15 @@
23
23
  "author": "DevForth (https://devforth.io)",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "zod": "^4.3.6",
27
- "cheerio": "^1.0.0"
26
+ "cheerio": "^1.0.0",
27
+ "zod": "^4.3.6"
28
28
  },
29
29
  "peerDependencies": {
30
- "adminforth": "^3.6.21"
30
+ "adminforth": "^3.8.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.10.7",
34
- "adminforth": "^3.6.21",
34
+ "adminforth": "^3.8.2",
35
35
  "semantic-release": "^24.2.1",
36
36
  "semantic-release-slack-bot": "^4.0.2",
37
37
  "typescript": "^5.7.3"