@mvriu5/payload-ai 0.5.9 → 0.5.10
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/README.md +62 -6
- package/dist/ai/{proposals.d.ts → proposalSigning.d.ts} +1 -1
- package/dist/ai/{proposals.js → proposalSigning.js} +6 -11
- package/dist/ai/providerOptions.d.ts +17 -1
- package/dist/ai/providerOptions.js +35 -7
- package/dist/ai/providerRuntime.d.ts +2 -2
- package/dist/ai/providerRuntime.js +50 -16
- package/dist/ai/sensitiveData.js +2 -6
- package/dist/components/AIInput.d.ts +2 -1
- package/dist/components/AIInput.js +210 -39
- package/dist/components/AIInput.module.css +15 -1
- package/dist/components/APIKeyField.d.ts +3 -0
- package/dist/components/{AIApiKeyField.js → APIKeyField.js} +3 -4
- package/dist/components/ActionToast.d.ts +30 -0
- package/dist/components/{AIActionProposalList.js → ActionToast.js} +10 -8
- package/dist/components/AuditLogList.d.ts +32 -0
- package/dist/components/{RecentChangesList.js → AuditLogList.js} +13 -12
- package/dist/components/{RecentChangesList.module.css → AuditLogList.module.css} +18 -1
- package/dist/components/DiffDialog.d.ts +10 -3
- package/dist/components/DiffDialog.js +164 -78
- package/dist/components/DiffDialog.module.css +86 -2
- package/dist/components/Icons.d.ts +5 -0
- package/dist/components/Icons.js +109 -3
- package/dist/components/MentionPopover.d.ts +19 -0
- package/dist/components/{CollectionMentionPopover.js → MentionPopover.js} +11 -4
- package/dist/components/{CollectionMentionPopover.module.css → MentionPopover.module.css} +0 -2
- package/dist/components/hooks/useAISettings.d.ts +6 -4
- package/dist/components/hooks/useAISettings.js +18 -3
- package/dist/components/hooks/useDocumentMentionSuggestions.d.ts +3 -3
- package/dist/components/hooks/useDocumentMentionSuggestions.js +2 -2
- package/dist/exports/client.d.ts +4 -2
- package/dist/exports/client.js +4 -2
- package/dist/handlers/applyActionHandler.d.ts +8 -0
- package/dist/handlers/applyActionHandler.js +563 -0
- package/dist/handlers/auditLogHandler.d.ts +6 -0
- package/dist/{endpoints/aiRecentChangesEndpointHandler.js → handlers/auditLogHandler.js} +12 -8
- package/dist/handlers/chatHandler.d.ts +42 -0
- package/dist/handlers/chatHandler.js +634 -0
- package/dist/handlers/mentionSuggestionHandler.d.ts +7 -0
- package/dist/handlers/mentionSuggestionHandler.js +97 -0
- package/dist/handlers/proposalDiffHandler.d.ts +7 -0
- package/dist/handlers/proposalDiffHandler.js +208 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.js +50 -18
- package/dist/payload/collectionPermissions.d.ts +14 -13
- package/dist/payload/collectionPermissions.js +3 -2
- package/dist/payload/normalizeData.d.ts +8 -0
- package/dist/payload/normalizeData.js +25 -3
- package/dist/payload/schemaContext.d.ts +43 -16
- package/dist/payload/schemaContext.js +139 -18
- package/dist/payload/shared.d.ts +33 -0
- package/dist/payload/shared.js +114 -0
- package/package.json +7 -2
- package/dist/components/AIActionProposalList.d.ts +0 -26
- package/dist/components/AIApiKeyField.d.ts +0 -2
- package/dist/components/CollectionMentionPopover.d.ts +0 -16
- package/dist/components/RecentChangesList.d.ts +0 -18
- package/dist/components/hooks/utils.d.ts +0 -1
- package/dist/components/hooks/utils.js +0 -3
- package/dist/endpoints/aiApplyActionEndpointHandler.d.ts +0 -8
- package/dist/endpoints/aiApplyActionEndpointHandler.js +0 -365
- package/dist/endpoints/aiChatEndpointHandler.d.ts +0 -35
- package/dist/endpoints/aiChatEndpointHandler.js +0 -382
- package/dist/endpoints/aiMentionSuggestionsEndpointHandler.d.ts +0 -7
- package/dist/endpoints/aiMentionSuggestionsEndpointHandler.js +0 -63
- package/dist/endpoints/aiProposalDiffEndpointHandler.d.ts +0 -7
- package/dist/endpoints/aiProposalDiffEndpointHandler.js +0 -138
- package/dist/endpoints/aiRecentChangesEndpointHandler.d.ts +0 -6
- /package/dist/components/{AIActionProposalList.module.css → ActionToast.module.css} +0 -0
package/dist/components/Icons.js
CHANGED
|
@@ -51,6 +51,8 @@ export function OpenaiIcon(props) {
|
|
|
51
51
|
return /*#__PURE__*/ React.createElement("svg", {
|
|
52
52
|
xmlns: "http://www.w3.org/2000/svg",
|
|
53
53
|
viewBox: "0 0 256 260",
|
|
54
|
+
fill: "currentColor",
|
|
55
|
+
stroke: "currentColor",
|
|
54
56
|
...props
|
|
55
57
|
}, /*#__PURE__*/ React.createElement("path", {
|
|
56
58
|
d: "M239.184 106.203a64.72 64.72 0 0 0-5.576-53.103C219.452 28.459 191 15.784 163.213 21.74A65.586 65.586 0 0 0 52.096 45.22a64.72 64.72 0 0 0-43.23 31.36c-14.31 24.602-11.061 55.634 8.033 76.74a64.67 64.67 0 0 0 5.525 53.102c14.174 24.65 42.644 37.324 70.446 31.36a64.72 64.72 0 0 0 48.754 21.744c28.481.025 53.714-18.361 62.414-45.481a64.77 64.77 0 0 0 43.229-31.36c14.137-24.558 10.875-55.423-8.083-76.483m-97.56 136.338a48.4 48.4 0 0 1-31.105-11.255l1.535-.87l51.67-29.825a8.6 8.6 0 0 0 4.247-7.367v-72.85l21.845 12.636c.218.111.37.32.409.563v60.367c-.056 26.818-21.783 48.545-48.601 48.601M37.158 197.93a48.35 48.35 0 0 1-5.781-32.589l1.534.921l51.722 29.826a8.34 8.34 0 0 0 8.441 0l63.181-36.425v25.221a.87.87 0 0 1-.358.665l-52.335 30.184c-23.257 13.398-52.97 5.431-66.404-17.803M23.549 85.38a48.5 48.5 0 0 1 25.58-21.333v61.39a8.29 8.29 0 0 0 4.195 7.316l62.874 36.272l-21.845 12.636a.82.82 0 0 1-.767 0L41.353 151.53c-23.211-13.454-31.171-43.144-17.804-66.405zm179.466 41.695l-63.08-36.63L161.73 77.86a.82.82 0 0 1 .768 0l52.233 30.184a48.6 48.6 0 0 1-7.316 87.635v-61.391a8.54 8.54 0 0 0-4.4-7.213m21.742-32.69l-1.535-.922l-51.619-30.081a8.39 8.39 0 0 0-8.492 0L99.98 99.808V74.587a.72.72 0 0 1 .307-.665l52.233-30.133a48.652 48.652 0 0 1 72.236 50.391zM88.061 139.097l-21.845-12.585a.87.87 0 0 1-.41-.614V65.685a48.652 48.652 0 0 1 79.757-37.346l-1.535.87l-51.67 29.825a8.6 8.6 0 0 0-4.246 7.367zm11.868-25.58L128.067 97.3l28.188 16.218v32.434l-28.086 16.218l-28.188-16.218z"
|
|
@@ -177,6 +179,29 @@ export function GoogleGeminiIcon(props) {
|
|
|
177
179
|
d: "M348.374 72.76c-2.846-18.788-17.592-33.533-36.38-36.38c18.788-2.847 33.534-17.593 36.38-36.38c2.847 18.787 17.593 33.533 36.38 36.38c-18.787 2.847-33.533 17.592-36.38 36.38"
|
|
178
180
|
}));
|
|
179
181
|
}
|
|
182
|
+
export function OpenrouterIcon(props) {
|
|
183
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
184
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
185
|
+
width: "512",
|
|
186
|
+
height: "512",
|
|
187
|
+
viewBox: "0 0 512 512",
|
|
188
|
+
fill: "currentColor",
|
|
189
|
+
stroke: "currentColor",
|
|
190
|
+
...props
|
|
191
|
+
}, /*#__PURE__*/ React.createElement("g", {
|
|
192
|
+
clipPath: "url(#clip0_205_3)"
|
|
193
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
194
|
+
d: "M3 248.945C18 248.945 76 236 106 219C136 202 136 202 198 158C276.497 102.293 332 120.945 423 120.945",
|
|
195
|
+
strokeWidth: "90"
|
|
196
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
197
|
+
d: "M511 121.5L357.25 210.268L357.25 32.7324L511 121.5Z"
|
|
198
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
199
|
+
d: "M0 249C15 249 73 261.945 103 278.945C133 295.945 133 295.945 195 339.945C273.497 395.652 329 377 420 377",
|
|
200
|
+
strokeWidth: "90"
|
|
201
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
202
|
+
d: "M508 376.445L354.25 287.678L354.25 465.213L508 376.445Z"
|
|
203
|
+
})));
|
|
204
|
+
}
|
|
180
205
|
export function FileDiff(props) {
|
|
181
206
|
return /*#__PURE__*/ React.createElement("svg", {
|
|
182
207
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -212,7 +237,6 @@ export function Send(props) {
|
|
|
212
237
|
strokeWidth: 2,
|
|
213
238
|
strokeLinecap: "round",
|
|
214
239
|
strokeLinejoin: "round",
|
|
215
|
-
className: "icon icon-tabler icons-tabler-outline icon-tabler-send",
|
|
216
240
|
...props
|
|
217
241
|
}, /*#__PURE__*/ React.createElement("path", {
|
|
218
242
|
stroke: "none",
|
|
@@ -233,7 +257,6 @@ export function Apply(props) {
|
|
|
233
257
|
strokeWidth: 2,
|
|
234
258
|
strokeLinecap: "round",
|
|
235
259
|
strokeLinejoin: "round",
|
|
236
|
-
className: "icon icon-tabler icons-tabler-outline icon-tabler-check",
|
|
237
260
|
...props
|
|
238
261
|
}, /*#__PURE__*/ React.createElement("path", {
|
|
239
262
|
stroke: "none",
|
|
@@ -252,7 +275,6 @@ export function Reject(props) {
|
|
|
252
275
|
strokeWidth: 2,
|
|
253
276
|
strokeLinecap: "round",
|
|
254
277
|
strokeLinejoin: "round",
|
|
255
|
-
className: "icon icon-tabler icons-tabler-outline icon-tabler-x",
|
|
256
278
|
...props
|
|
257
279
|
}, /*#__PURE__*/ React.createElement("path", {
|
|
258
280
|
stroke: "none",
|
|
@@ -264,3 +286,87 @@ export function Reject(props) {
|
|
|
264
286
|
d: "M6 6l12 12"
|
|
265
287
|
}));
|
|
266
288
|
}
|
|
289
|
+
export function Collection(props) {
|
|
290
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
291
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
292
|
+
viewBox: "0 0 24 24",
|
|
293
|
+
fill: "none",
|
|
294
|
+
stroke: "currentColor",
|
|
295
|
+
strokeWidth: 2,
|
|
296
|
+
strokeLinecap: "round",
|
|
297
|
+
strokeLinejoin: "round",
|
|
298
|
+
...props
|
|
299
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
300
|
+
stroke: "none",
|
|
301
|
+
d: "M0 0h24v24H0z",
|
|
302
|
+
fill: "none"
|
|
303
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
304
|
+
d: "M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2"
|
|
305
|
+
}));
|
|
306
|
+
}
|
|
307
|
+
export function Document(props) {
|
|
308
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
309
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
310
|
+
viewBox: "0 0 24 24",
|
|
311
|
+
fill: "none",
|
|
312
|
+
stroke: "currentColor",
|
|
313
|
+
strokeWidth: 2,
|
|
314
|
+
strokeLinecap: "round",
|
|
315
|
+
strokeLinejoin: "round",
|
|
316
|
+
...props
|
|
317
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
318
|
+
stroke: "none",
|
|
319
|
+
d: "M0 0h24v24H0z",
|
|
320
|
+
fill: "none"
|
|
321
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
322
|
+
d: "M14 3v4a1 1 0 0 0 1 1h4"
|
|
323
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
324
|
+
d: "M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2"
|
|
325
|
+
}));
|
|
326
|
+
}
|
|
327
|
+
export function Global(props) {
|
|
328
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
329
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
330
|
+
viewBox: "0 0 24 24",
|
|
331
|
+
fill: "none",
|
|
332
|
+
stroke: "currentColor",
|
|
333
|
+
strokeWidth: 2,
|
|
334
|
+
strokeLinecap: "round",
|
|
335
|
+
strokeLinejoin: "round",
|
|
336
|
+
...props
|
|
337
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
338
|
+
stroke: "none",
|
|
339
|
+
d: "M0 0h24v24H0z",
|
|
340
|
+
fill: "none"
|
|
341
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
342
|
+
d: "M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0"
|
|
343
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
344
|
+
d: "M3.6 9h16.8"
|
|
345
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
346
|
+
d: "M3.6 15h16.8"
|
|
347
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
348
|
+
d: "M11.5 3a17 17 0 0 0 0 18"
|
|
349
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
350
|
+
d: "M12.5 3a17 17 0 0 1 0 18"
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
export function Block(props) {
|
|
354
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
355
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
356
|
+
viewBox: "0 0 24 24",
|
|
357
|
+
fill: "none",
|
|
358
|
+
stroke: "currentColor",
|
|
359
|
+
strokeWidth: 2,
|
|
360
|
+
strokeLinecap: "round",
|
|
361
|
+
strokeLinejoin: "round",
|
|
362
|
+
...props
|
|
363
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
364
|
+
stroke: "none",
|
|
365
|
+
d: "M0 0h24v24H0z",
|
|
366
|
+
fill: "none"
|
|
367
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
368
|
+
d: "M14 4a1 1 0 0 1 1 -1h5a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1l0 -5"
|
|
369
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
370
|
+
d: "M3 14h12a2 2 0 0 1 2 2v3a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2h3a2 2 0 0 1 2 2v12"
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { RefObject } from "react";
|
|
3
|
+
export type MentionOption = {
|
|
4
|
+
collection?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
isDefault?: boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
parent?: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
type: "block" | "collection" | "doc" | "global" | "locale";
|
|
11
|
+
};
|
|
12
|
+
type MentionPopoverProps = {
|
|
13
|
+
containerRef?: RefObject<HTMLDivElement | null>;
|
|
14
|
+
suggestions: MentionOption[];
|
|
15
|
+
onSelect: (suggestion: MentionOption) => void;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
};
|
|
18
|
+
export declare const MentionPopover: ({ containerRef, onSelect, style, suggestions }: MentionPopoverProps) => import("react").JSX.Element | null;
|
|
19
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import styles from "./
|
|
1
|
+
import styles from "./MentionPopover.module.css";
|
|
2
2
|
const suggestionGroups = [
|
|
3
3
|
{
|
|
4
4
|
label: "Collections",
|
|
5
5
|
type: "collection"
|
|
6
6
|
},
|
|
7
7
|
{
|
|
8
|
-
label: "
|
|
8
|
+
label: "Documents",
|
|
9
9
|
type: "doc"
|
|
10
10
|
},
|
|
11
11
|
{
|
|
@@ -15,21 +15,27 @@ const suggestionGroups = [
|
|
|
15
15
|
{
|
|
16
16
|
label: "Blocks",
|
|
17
17
|
type: "block"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
label: "Locales",
|
|
21
|
+
type: "locale"
|
|
18
22
|
}
|
|
19
23
|
];
|
|
20
24
|
const getSuggestionTitle = (suggestion)=>{
|
|
21
25
|
if (suggestion.type === "collection") return `@${suggestion.slug}`;
|
|
22
26
|
if (suggestion.type === "global") return `@${suggestion.slug}`;
|
|
23
27
|
if (suggestion.type === "block") return `@${suggestion.slug}`;
|
|
28
|
+
if (suggestion.type === "locale") return `@${suggestion.slug}`;
|
|
24
29
|
return suggestion.label;
|
|
25
30
|
};
|
|
26
31
|
const getSuggestionLabel = (suggestion)=>{
|
|
27
32
|
if (suggestion.type === "collection") return suggestion.label;
|
|
28
33
|
if (suggestion.type === "global") return "global";
|
|
29
34
|
if (suggestion.type === "block") return `${suggestion.parent} block`;
|
|
35
|
+
if (suggestion.type === "locale") return suggestion.isDefault ? "default locale" : "locale";
|
|
30
36
|
return `${suggestion.collection} item`;
|
|
31
37
|
};
|
|
32
|
-
export const
|
|
38
|
+
export const MentionPopover = ({ containerRef, onSelect, style, suggestions })=>{
|
|
33
39
|
if (suggestions.length === 0) return null;
|
|
34
40
|
const onKeyDown = (event, suggestion)=>{
|
|
35
41
|
if (event.key === "Enter" || event.key === " ") {
|
|
@@ -53,7 +59,8 @@ export const CollectionMentionPopover = ({ containerRef, onSelect, suggestions }
|
|
|
53
59
|
};
|
|
54
60
|
return /*#__PURE__*/ React.createElement("div", {
|
|
55
61
|
className: styles.popover,
|
|
56
|
-
ref: containerRef
|
|
62
|
+
ref: containerRef,
|
|
63
|
+
style: style
|
|
57
64
|
}, suggestionGroups.map((group)=>{
|
|
58
65
|
const groupSuggestions = suggestions.filter((s)=>s.type === group.type);
|
|
59
66
|
if (groupSuggestions.length === 0) return null;
|
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
border: 1px solid var(--theme-elevation-150);
|
|
4
4
|
border-radius: 6px;
|
|
5
5
|
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
|
|
6
|
-
left: 0;
|
|
7
6
|
max-height: 220px;
|
|
8
7
|
max-width: calc(100% - 96px);
|
|
9
8
|
min-width: 260px;
|
|
10
9
|
overflow: auto;
|
|
11
10
|
padding: 6px;
|
|
12
11
|
position: absolute;
|
|
13
|
-
top: calc(100% + 6px);
|
|
14
12
|
z-index: 10;
|
|
15
13
|
}
|
|
16
14
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { type AIProvider } from "../../ai/providerOptions.js";
|
|
2
|
-
|
|
2
|
+
interface UseAISettingsOptions {
|
|
3
3
|
adminUserSlug?: string;
|
|
4
4
|
apiRoute: string;
|
|
5
5
|
defaultModels: Record<AIProvider, string>;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare const useAISettings: ({ adminUserSlug, apiRoute, defaultModels }: UseAISettingsOptions) => {
|
|
7
8
|
selectedModel: string;
|
|
8
|
-
setSelectedModel:
|
|
9
|
-
settingsProvider: "claude" | "google" | "mistral" | "openai" | null;
|
|
9
|
+
setSelectedModel: (model: string) => void;
|
|
10
|
+
settingsProvider: "claude" | "google" | "mistral" | "openai" | "openrouter" | null;
|
|
10
11
|
};
|
|
12
|
+
export {};
|
|
@@ -2,10 +2,25 @@
|
|
|
2
2
|
import { formatAdminURL } from "payload/shared";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
4
|
import { isAIProvider } from "../../ai/providerOptions.js";
|
|
5
|
-
import { isAbortError } from "
|
|
5
|
+
import { isAbortError } from "../../payload/shared.js";
|
|
6
|
+
const getStoredModelKey = (provider)=>`payload-ai:selected-model:${provider}`;
|
|
7
|
+
const getStoredModel = (provider)=>{
|
|
8
|
+
if (typeof window === "undefined") return null;
|
|
9
|
+
return window.localStorage.getItem(getStoredModelKey(provider));
|
|
10
|
+
};
|
|
11
|
+
const storeModel = (provider, model)=>{
|
|
12
|
+
if (typeof window === "undefined") return;
|
|
13
|
+
window.localStorage.setItem(getStoredModelKey(provider), model);
|
|
14
|
+
};
|
|
6
15
|
export const useAISettings = ({ adminUserSlug, apiRoute, defaultModels })=>{
|
|
7
16
|
const [settingsProvider, setSettingsProvider] = useState(null);
|
|
8
17
|
const [selectedModel, setSelectedModel] = useState("");
|
|
18
|
+
const setStoredSelectedModel = (model)=>{
|
|
19
|
+
setSelectedModel(model);
|
|
20
|
+
if (settingsProvider && model) {
|
|
21
|
+
storeModel(settingsProvider, model);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
9
24
|
useEffect(()=>{
|
|
10
25
|
if (!adminUserSlug) {
|
|
11
26
|
setSettingsProvider(null);
|
|
@@ -34,7 +49,7 @@ export const useAISettings = ({ adminUserSlug, apiRoute, defaultModels })=>{
|
|
|
34
49
|
return;
|
|
35
50
|
}
|
|
36
51
|
setSettingsProvider(provider);
|
|
37
|
-
setSelectedModel(defaultModels[provider]);
|
|
52
|
+
setSelectedModel(getStoredModel(provider) || defaultModels[provider]);
|
|
38
53
|
} catch (err) {
|
|
39
54
|
if (isAbortError(err)) return;
|
|
40
55
|
setSettingsProvider(null);
|
|
@@ -50,7 +65,7 @@ export const useAISettings = ({ adminUserSlug, apiRoute, defaultModels })=>{
|
|
|
50
65
|
]);
|
|
51
66
|
return {
|
|
52
67
|
selectedModel,
|
|
53
|
-
setSelectedModel,
|
|
68
|
+
setSelectedModel: setStoredSelectedModel,
|
|
54
69
|
settingsProvider
|
|
55
70
|
};
|
|
56
71
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MentionOption } from "../MentionPopover.js";
|
|
2
2
|
type MentionRange = {
|
|
3
3
|
end: number;
|
|
4
4
|
start: number;
|
|
@@ -9,8 +9,8 @@ interface DocumentMentionSuggestions {
|
|
|
9
9
|
mentionQuery: string;
|
|
10
10
|
mentionRange: MentionRange | null;
|
|
11
11
|
}
|
|
12
|
-
export declare const useDocumentMentionSuggestions: ({ apiRoute, documentSuggestionCollection, mentionQuery, mentionRange
|
|
13
|
-
documentSuggestions:
|
|
12
|
+
export declare const useDocumentMentionSuggestions: ({ apiRoute, documentSuggestionCollection, mentionQuery, mentionRange }: DocumentMentionSuggestions) => {
|
|
13
|
+
documentSuggestions: MentionOption[];
|
|
14
14
|
resetDocumentSuggestions: () => void;
|
|
15
15
|
};
|
|
16
16
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { formatAdminURL } from "payload/shared";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import { isAbortError } from "
|
|
4
|
+
import { isAbortError } from "../../payload/shared.js";
|
|
5
5
|
export const useDocumentMentionSuggestions = ({ apiRoute, documentSuggestionCollection, mentionQuery, mentionRange })=>{
|
|
6
6
|
const [documentSuggestions, setDocumentSuggestions] = useState([]);
|
|
7
7
|
useEffect(()=>{
|
|
@@ -15,7 +15,7 @@ export const useDocumentMentionSuggestions = ({ apiRoute, documentSuggestionColl
|
|
|
15
15
|
try {
|
|
16
16
|
const res = await fetch(formatAdminURL({
|
|
17
17
|
apiRoute,
|
|
18
|
-
path: "/ai-mention-
|
|
18
|
+
path: "/ai-mention-suggestion"
|
|
19
19
|
}), {
|
|
20
20
|
body: JSON.stringify({
|
|
21
21
|
collectionSlug: documentSuggestionCollection,
|
package/dist/exports/client.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import AIInput from "../components/AIInput.js";
|
|
2
|
+
import APIKeyField from "../components/APIKeyField.js";
|
|
3
|
+
export { AIInput };
|
|
4
|
+
export { APIKeyField as AIApiKeyField };
|
package/dist/exports/client.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import AIInput from "../components/AIInput.js";
|
|
2
|
+
import APIKeyField from "../components/APIKeyField.js";
|
|
3
|
+
export { AIInput };
|
|
4
|
+
export { APIKeyField as AIApiKeyField };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PayloadHandler } from "payload";
|
|
2
|
+
import { type ResolvedCollectionPermissionMap } from "../payload/collectionPermissions.js";
|
|
3
|
+
type ApplyActionOptions = {
|
|
4
|
+
changeLogCollection?: string;
|
|
5
|
+
collections?: ResolvedCollectionPermissionMap;
|
|
6
|
+
};
|
|
7
|
+
export declare const createApplyActionHandler: (options?: ApplyActionOptions) => PayloadHandler;
|
|
8
|
+
export {};
|