@adminforth/rich-editor 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/dist/index.js +10 -6
- package/index.ts +10 -6
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -221,10 +221,13 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
221
221
|
parseBody(schema, body, response) {
|
|
222
222
|
const parsed = schema.safeParse(body !== null && body !== void 0 ? body : {});
|
|
223
223
|
if (!parsed.success) {
|
|
224
|
-
response.setStatus(
|
|
225
|
-
return
|
|
224
|
+
response.setStatus(400, '');
|
|
225
|
+
return {
|
|
226
|
+
ok: false,
|
|
227
|
+
error: { error: 'Request body validation failed', details: parsed.error.issues },
|
|
228
|
+
};
|
|
226
229
|
}
|
|
227
|
-
return parsed.data;
|
|
230
|
+
return { ok: true, data: parsed.data };
|
|
228
231
|
}
|
|
229
232
|
setupEndpoints(server) {
|
|
230
233
|
server.endpoint({
|
|
@@ -232,9 +235,10 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
232
235
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
233
236
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers, response }) {
|
|
234
237
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
return;
|
|
238
|
+
const parsed = this.parseBody(doCompleteBodySchema, body, response);
|
|
239
|
+
if ('error' in parsed)
|
|
240
|
+
return parsed.error;
|
|
241
|
+
const data = parsed.data;
|
|
238
242
|
const { record } = data;
|
|
239
243
|
if (!record) {
|
|
240
244
|
return { completion: [] };
|
package/index.ts
CHANGED
|
@@ -279,13 +279,16 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
279
279
|
schema: z.ZodType<T>,
|
|
280
280
|
body: unknown,
|
|
281
281
|
response: { setStatus: (code: number, message: string) => void },
|
|
282
|
-
): T |
|
|
282
|
+
): { ok: true; data: T } | { ok: false; error: { error: string; details: unknown } } {
|
|
283
283
|
const parsed = schema.safeParse(body ?? {});
|
|
284
284
|
if (!parsed.success) {
|
|
285
|
-
response.setStatus(
|
|
286
|
-
return
|
|
285
|
+
response.setStatus(400, '');
|
|
286
|
+
return {
|
|
287
|
+
ok: false,
|
|
288
|
+
error: { error: 'Request body validation failed', details: parsed.error.issues },
|
|
289
|
+
};
|
|
287
290
|
}
|
|
288
|
-
return parsed.data;
|
|
291
|
+
return { ok: true, data: parsed.data };
|
|
289
292
|
}
|
|
290
293
|
|
|
291
294
|
setupEndpoints(server: IHttpServer) {
|
|
@@ -293,8 +296,9 @@ export default class RichEditorPlugin extends AdminForthPlugin {
|
|
|
293
296
|
method: 'POST',
|
|
294
297
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
295
298
|
handler: async ({ body, headers, response }) => {
|
|
296
|
-
const
|
|
297
|
-
if (
|
|
299
|
+
const parsed = this.parseBody(doCompleteBodySchema, body, response);
|
|
300
|
+
if ('error' in parsed) return parsed.error;
|
|
301
|
+
const data = parsed.data;
|
|
298
302
|
const { record } = data;
|
|
299
303
|
|
|
300
304
|
if (!record) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/rich-editor",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
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
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"cheerio": "^1.0.0",
|
|
27
|
+
"zod": "^4.3.6"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"adminforth": "^3.
|
|
30
|
+
"adminforth": "^3.7.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.10.7",
|
|
34
|
-
"adminforth": "^3.
|
|
34
|
+
"adminforth": "^3.7.1",
|
|
35
35
|
"semantic-release": "^24.2.1",
|
|
36
36
|
"semantic-release-slack-bot": "^4.0.2",
|
|
37
37
|
"typescript": "^5.7.3"
|