@mvriu5/payload-ai 0.5.10 → 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/components/AIInput.js +318 -112
- package/dist/components/AIInput.module.css +11 -2
- package/dist/components/APIKeyField.js +41 -24
- package/dist/components/ActionToast.d.ts +2 -1
- package/dist/components/ActionToast.js +203 -103
- package/dist/components/AuditLogList.js +90 -53
- package/dist/components/DiffDialog.js +222 -121
- package/dist/components/Icons.js +390 -274
- package/dist/components/MentionPopover.js +33 -22
- package/dist/handlers/applyActionHandler.js +316 -107
- package/dist/handlers/chatHandler.js +749 -50
- package/dist/handlers/proposalDiffHandler.js +81 -26
- package/dist/index.js +2 -2
- package/dist/payload/logging.d.ts +9 -0
- package/dist/payload/logging.js +14 -0
- package/dist/payload/normalizeData.d.ts +17 -7
- package/dist/payload/normalizeData.js +22 -1
- package/dist/payload/proposalData.d.ts +31 -0
- package/dist/payload/proposalData.js +575 -0
- package/dist/payload/schemaContext.d.ts +3 -7
- package/dist/payload/schemaContext.js +49 -23
- package/package.json +40 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCollectionPermissions, getCollectionSlugsForAction } from "./collectionPermissions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getSchemaFields as getNormalizeSchemaFields, hasDrafts, isAuthCollection } from "./normalizeData.js";
|
|
3
3
|
import { getSerializableLabel, isInternalCollection, isRecord } from "./shared.js";
|
|
4
4
|
const getSerializableRelationTo = (relationTo)=>{
|
|
5
5
|
if (typeof relationTo === "string") return relationTo;
|
|
@@ -66,12 +66,6 @@ const getSerializableOptions = (options)=>{
|
|
|
66
66
|
}).filter(Boolean);
|
|
67
67
|
return serializedOptions.length > 0 ? serializedOptions : undefined;
|
|
68
68
|
};
|
|
69
|
-
const hasDrafts = (config)=>{
|
|
70
|
-
const versions = config?.versions;
|
|
71
|
-
if (!versions || versions === true) return false;
|
|
72
|
-
if (!isRecord(versions)) return false;
|
|
73
|
-
return Boolean(versions.drafts);
|
|
74
|
-
};
|
|
75
69
|
const toNormalizeCollectionConfig = (config)=>{
|
|
76
70
|
if (!config) return undefined;
|
|
77
71
|
return {
|
|
@@ -82,22 +76,7 @@ const toNormalizeCollectionConfig = (config)=>{
|
|
|
82
76
|
};
|
|
83
77
|
const getSchemaFields = (config)=>{
|
|
84
78
|
const normalizedConfig = toNormalizeCollectionConfig(config);
|
|
85
|
-
|
|
86
|
-
...config?.fields || []
|
|
87
|
-
];
|
|
88
|
-
if (hasDrafts(config)) {
|
|
89
|
-
fields.push({
|
|
90
|
-
label: "Status",
|
|
91
|
-
name: "_status",
|
|
92
|
-
options: [
|
|
93
|
-
"draft",
|
|
94
|
-
"published"
|
|
95
|
-
],
|
|
96
|
-
required: true,
|
|
97
|
-
type: "select"
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
return fields;
|
|
79
|
+
return getNormalizeSchemaFields(normalizedConfig);
|
|
101
80
|
};
|
|
102
81
|
const getLocalizedFieldNames = (fields, path = "")=>{
|
|
103
82
|
return fields.flatMap((field)=>{
|
|
@@ -191,6 +170,14 @@ const describeField = (field)=>{
|
|
|
191
170
|
...options ? {
|
|
192
171
|
options
|
|
193
172
|
} : {},
|
|
173
|
+
...field.type === "blocks" && field.blocks ? {
|
|
174
|
+
acceptedBlockTypes: field.blocks.map((block)=>block.slug),
|
|
175
|
+
blockExample: [
|
|
176
|
+
{
|
|
177
|
+
...getBlockExample(field.blocks[0])
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
} : {},
|
|
194
181
|
...field.admin?.condition ? {
|
|
195
182
|
hasCondition: true
|
|
196
183
|
} : {},
|
|
@@ -208,6 +195,8 @@ const describeBlock = (block)=>{
|
|
|
208
195
|
const cached = blockDescriptionCache.get(block);
|
|
209
196
|
if (cached) return cached;
|
|
210
197
|
const description = {
|
|
198
|
+
blockType: block.slug,
|
|
199
|
+
example: getBlockExample(block),
|
|
211
200
|
fields: (block.fields || []).map(describeField),
|
|
212
201
|
label: getSerializableLabel(block.labels?.singular) || block.slug,
|
|
213
202
|
slug: block.slug
|
|
@@ -215,6 +204,43 @@ const describeBlock = (block)=>{
|
|
|
215
204
|
blockDescriptionCache.set(block, description);
|
|
216
205
|
return description;
|
|
217
206
|
};
|
|
207
|
+
const getBlockExample = (block)=>{
|
|
208
|
+
if (!block) return {};
|
|
209
|
+
const example = {
|
|
210
|
+
blockType: block.slug
|
|
211
|
+
};
|
|
212
|
+
for (const field of block.fields || []){
|
|
213
|
+
if (!field.name) continue;
|
|
214
|
+
if (field.type === "array") {
|
|
215
|
+
example[field.name] = field.fields?.length ? [
|
|
216
|
+
Object.fromEntries(field.fields.filter((childField)=>Boolean(childField.name)).slice(0, 2).map((childField)=>[
|
|
217
|
+
childField.name,
|
|
218
|
+
childField.type === "checkbox" ? false : `<${childField.name}>`
|
|
219
|
+
]))
|
|
220
|
+
] : [];
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (field.type === "blocks") {
|
|
224
|
+
example[field.name] = field.blocks?.length ? [
|
|
225
|
+
getBlockExample(field.blocks[0])
|
|
226
|
+
] : [];
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (field.type === "group") {
|
|
230
|
+
example[field.name] = Object.fromEntries((field.fields || []).filter((childField)=>Boolean(childField.name)).slice(0, 2).map((childField)=>[
|
|
231
|
+
childField.name,
|
|
232
|
+
childField.type === "checkbox" ? false : `<${childField.name}>`
|
|
233
|
+
]));
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (field.type === "checkbox") {
|
|
237
|
+
example[field.name] = false;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
example[field.name] = `<${field.name}>`;
|
|
241
|
+
}
|
|
242
|
+
return example;
|
|
243
|
+
};
|
|
218
244
|
export const describeCollectionLikeConfig = ({ config, permissions, type })=>{
|
|
219
245
|
return {
|
|
220
246
|
...describeCollectionLikeSummary({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mvriu5/payload-ai",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "AI assistant plugin for Payload CMS with provider selection, CMS mentions, and signed action proposals.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
|
|
46
46
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
47
47
|
"build:types": "tsc --outDir dist --rootDir ./src",
|
|
48
|
-
"clean": "rimraf
|
|
48
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
49
49
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
50
50
|
"dev": "next dev dev --turbo",
|
|
51
51
|
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
@@ -55,9 +55,23 @@
|
|
|
55
55
|
"generate:types": "pnpm dev:generate-types",
|
|
56
56
|
"lint": "eslint",
|
|
57
57
|
"lint:fix": "eslint ./src --fix",
|
|
58
|
-
"prepublishOnly": "pnpm clean && pnpm build"
|
|
58
|
+
"prepublishOnly": "pnpm clean && pnpm build",
|
|
59
|
+
"test": "vitest run tests/components tests/handlers tests/unit",
|
|
60
|
+
"test:all": "pnpm test && pnpm test:e2e",
|
|
61
|
+
"test:components": "vitest run tests/components",
|
|
62
|
+
"test:e2e": "playwright test",
|
|
63
|
+
"test:e2e:headed": "playwright test --headed",
|
|
64
|
+
"test:handlers": "vitest run tests/handlers",
|
|
65
|
+
"test:unit": "vitest run tests/unit",
|
|
66
|
+
"setup:hooks": "git config core.hooksPath .githooks"
|
|
59
67
|
},
|
|
60
68
|
"devDependencies": {
|
|
69
|
+
"@ai-sdk/anthropic": "^3.0.81",
|
|
70
|
+
"@ai-sdk/google": "^3.0.80",
|
|
71
|
+
"@ai-sdk/mistral": "^3.0.37",
|
|
72
|
+
"@ai-sdk/openai": "^3.0.67",
|
|
73
|
+
"@openrouter/ai-sdk-provider": "^2.9.1",
|
|
74
|
+
"@playwright/test": "^1.56.1",
|
|
61
75
|
"@payloadcms/db-postgres": "3.84.1",
|
|
62
76
|
"@payloadcms/next": "3.84.1",
|
|
63
77
|
"@payloadcms/richtext-lexical": "3.84.1",
|
|
@@ -70,6 +84,7 @@
|
|
|
70
84
|
"cross-env": "^7.0.3",
|
|
71
85
|
"eslint": "^10.5.0",
|
|
72
86
|
"graphql": "^16.8.1",
|
|
87
|
+
"jsdom": "^29.1.1",
|
|
73
88
|
"knip": "^6.16.1",
|
|
74
89
|
"next": "16.2.9",
|
|
75
90
|
"payload": "3.84.1",
|
|
@@ -79,12 +94,33 @@
|
|
|
79
94
|
"rimraf": "6.1.3",
|
|
80
95
|
"sharp": "0.35.1",
|
|
81
96
|
"typescript": "5.9.3",
|
|
82
|
-
"vite-tsconfig-paths": "6.1.1",
|
|
83
97
|
"vitest": "4.1.9"
|
|
84
98
|
},
|
|
85
99
|
"peerDependencies": {
|
|
100
|
+
"@ai-sdk/anthropic": "^3.0.81",
|
|
101
|
+
"@ai-sdk/google": "^3.0.80",
|
|
102
|
+
"@ai-sdk/mistral": "^3.0.37",
|
|
103
|
+
"@ai-sdk/openai": "^3.0.67",
|
|
104
|
+
"@openrouter/ai-sdk-provider": "^2.9.1",
|
|
86
105
|
"payload": "^3.84.1"
|
|
87
106
|
},
|
|
107
|
+
"peerDependenciesMeta": {
|
|
108
|
+
"@ai-sdk/anthropic": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"@ai-sdk/google": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"@ai-sdk/mistral": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
117
|
+
"@ai-sdk/openai": {
|
|
118
|
+
"optional": true
|
|
119
|
+
},
|
|
120
|
+
"@openrouter/ai-sdk-provider": {
|
|
121
|
+
"optional": true
|
|
122
|
+
}
|
|
123
|
+
},
|
|
88
124
|
"engines": {
|
|
89
125
|
"node": "^18.20.2 || >=20.9.0",
|
|
90
126
|
"pnpm": "^9 || ^10 || ^11"
|
|
@@ -111,11 +147,6 @@
|
|
|
111
147
|
]
|
|
112
148
|
},
|
|
113
149
|
"dependencies": {
|
|
114
|
-
"@ai-sdk/anthropic": "^3.0.81",
|
|
115
|
-
"@ai-sdk/google": "^3.0.80",
|
|
116
|
-
"@ai-sdk/mistral": "^3.0.37",
|
|
117
|
-
"@ai-sdk/openai": "^3.0.67",
|
|
118
|
-
"@openrouter/ai-sdk-provider": "^2.9.1",
|
|
119
150
|
"ai": "^6.0.193",
|
|
120
151
|
"zod": "^4.4.3"
|
|
121
152
|
}
|