@adminforth/inline-create 1.1.14 → 1.2.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/dist/index.js +12 -3
- package/index.ts +12 -3
- package/package.json +6 -3
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 { ActionCheckSource, AdminForthPlugin, interpretResource } from "adminforth";
|
|
10
|
+
import { ActionCheckSource, AdminForthPlugin, parseBody, interpretResource } from "adminforth";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
const createBodySchema = z.object({
|
|
13
|
+
resourceId: z.string(),
|
|
14
|
+
record: z.record(z.string(), z.unknown()).nullish(),
|
|
15
|
+
}).strict();
|
|
11
16
|
export default class InlineCreatePlugin extends AdminForthPlugin {
|
|
12
17
|
constructor(options) {
|
|
13
18
|
super(options, import.meta.url);
|
|
@@ -66,8 +71,12 @@ export default class InlineCreatePlugin extends AdminForthPlugin {
|
|
|
66
71
|
server.endpoint({
|
|
67
72
|
method: 'POST',
|
|
68
73
|
path: `/plugin/${this.pluginInstanceId}/create`,
|
|
69
|
-
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser }) {
|
|
70
|
-
const
|
|
74
|
+
handler: (_a) => __awaiter(this, [_a], void 0, function* ({ body, adminUser, response }) {
|
|
75
|
+
const parsed = parseBody(createBodySchema, body, response);
|
|
76
|
+
if ('error' in parsed)
|
|
77
|
+
return parsed.error;
|
|
78
|
+
const data = parsed.data;
|
|
79
|
+
const { record, resourceId } = data;
|
|
71
80
|
if (!record) {
|
|
72
81
|
return { error: 'No record provided' };
|
|
73
82
|
}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { ActionCheckSource, AdminForthPlugin, interpretResource } from "adminforth";
|
|
1
|
+
import { ActionCheckSource, AdminForthPlugin, parseBody, interpretResource } 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 createBodySchema = z.object({
|
|
7
|
+
resourceId: z.string(),
|
|
8
|
+
record: z.record(z.string(), z.unknown()).nullish(),
|
|
9
|
+
}).strict();
|
|
4
10
|
|
|
5
11
|
export default class InlineCreatePlugin extends AdminForthPlugin {
|
|
6
12
|
options: PluginOptions;
|
|
@@ -70,8 +76,11 @@ export default class InlineCreatePlugin extends AdminForthPlugin {
|
|
|
70
76
|
server.endpoint({
|
|
71
77
|
method: 'POST',
|
|
72
78
|
path: `/plugin/${this.pluginInstanceId}/create`,
|
|
73
|
-
handler: async ({ body, adminUser }) => {
|
|
74
|
-
const
|
|
79
|
+
handler: async ({ body, adminUser, response }) => {
|
|
80
|
+
const parsed = parseBody(createBodySchema, body, response);
|
|
81
|
+
if ('error' in parsed) return parsed.error;
|
|
82
|
+
const data = parsed.data;
|
|
83
|
+
const { record, resourceId } = data;
|
|
75
84
|
|
|
76
85
|
if (!record) {
|
|
77
86
|
return { error: 'No record provided' };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/inline-create",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"description": "Inline create plugin for adminforth",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"adminforth": "^3.
|
|
26
|
+
"adminforth": "^3.7.1"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"zod": "^4.3.6"
|
|
27
30
|
},
|
|
28
31
|
"devDependencies": {
|
|
29
32
|
"@types/node": "^22.10.7",
|
|
30
|
-
"adminforth": "^3.
|
|
33
|
+
"adminforth": "^3.7.1",
|
|
31
34
|
"semantic-release": "^24.2.1",
|
|
32
35
|
"semantic-release-slack-bot": "^4.0.2",
|
|
33
36
|
"typescript": "^5.7.3"
|