@adminforth/rich-editor 2.1.1 → 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 +0 -1
- package/dist/index.js +2 -15
- package/index.ts +2 -19
- package/package.json +3 -3
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,27 +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(400, '');
|
|
225
|
-
return {
|
|
226
|
-
ok: false,
|
|
227
|
-
error: { error: 'Request body validation failed', details: parsed.error.issues },
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
return { ok: true, data: parsed.data };
|
|
231
|
-
}
|
|
232
221
|
setupEndpoints(server) {
|
|
233
222
|
server.endpoint({
|
|
234
223
|
method: 'POST',
|
|
235
224
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
225
|
+
request_schema: doCompleteBodySchema,
|
|
236
226
|
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, headers, response }) {
|
|
237
227
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
238
|
-
const
|
|
239
|
-
if ('error' in parsed)
|
|
240
|
-
return parsed.error;
|
|
241
|
-
const data = parsed.data;
|
|
228
|
+
const data = body;
|
|
242
229
|
const { record } = data;
|
|
243
230
|
if (!record) {
|
|
244
231
|
return { completion: [] };
|
package/index.ts
CHANGED
|
@@ -275,30 +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
|
-
): { ok: true; data: T } | { ok: false; error: { error: string; details: unknown } } {
|
|
283
|
-
const parsed = schema.safeParse(body ?? {});
|
|
284
|
-
if (!parsed.success) {
|
|
285
|
-
response.setStatus(400, '');
|
|
286
|
-
return {
|
|
287
|
-
ok: false,
|
|
288
|
-
error: { error: 'Request body validation failed', details: parsed.error.issues },
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
return { ok: true, data: parsed.data };
|
|
292
|
-
}
|
|
293
|
-
|
|
294
278
|
setupEndpoints(server: IHttpServer) {
|
|
295
279
|
server.endpoint({
|
|
296
280
|
method: 'POST',
|
|
297
281
|
path: `/plugin/${this.pluginInstanceId}/doComplete`,
|
|
282
|
+
request_schema: doCompleteBodySchema,
|
|
298
283
|
handler: async ({ body, headers, response }) => {
|
|
299
|
-
const
|
|
300
|
-
if ('error' in parsed) return parsed.error;
|
|
301
|
-
const data = parsed.data;
|
|
284
|
+
const data = body as z.infer<typeof doCompleteBodySchema>;
|
|
302
285
|
const { record } = data;
|
|
303
286
|
|
|
304
287
|
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.2",
|
|
4
4
|
"description": "Rich editor plugin for adminforth",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"zod": "^4.3.6"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"adminforth": "^3.
|
|
30
|
+
"adminforth": "^3.8.2"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^22.10.7",
|
|
34
|
-
"adminforth": "^3.
|
|
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"
|