@btst/stack 2.1.0 → 2.3.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/api/index.cjs +9 -1
- package/dist/api/index.d.cts +4 -4
- package/dist/api/index.d.mts +4 -4
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.mjs +9 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/api/getters.cjs +42 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/getters.mjs +39 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +5 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +5 -0
- package/dist/packages/stack/src/plugins/blog/api/getters.cjs +131 -0
- package/dist/packages/stack/src/plugins/blog/api/getters.mjs +127 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +60 -107
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +60 -107
- package/dist/packages/stack/src/plugins/blog/api/query-key-defs.cjs +18 -0
- package/dist/packages/stack/src/plugins/blog/api/query-key-defs.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/api/serializers.cjs +21 -0
- package/dist/packages/stack/src/plugins/blog/api/serializers.mjs +18 -0
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +16 -1
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +17 -2
- package/dist/packages/stack/src/plugins/cms/api/getters.cjs +156 -0
- package/dist/packages/stack/src/plugins/cms/api/getters.mjs +147 -0
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +624 -617
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +623 -616
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +29 -0
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +26 -0
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.cjs +6 -3
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.mjs +6 -3
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +15 -0
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +16 -1
- package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +120 -0
- package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +112 -0
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +75 -86
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +71 -82
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +37 -0
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +33 -0
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +15 -0
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +16 -1
- package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +84 -0
- package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +81 -0
- package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +37 -123
- package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +37 -123
- package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.cjs +26 -0
- package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.mjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +30 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +26 -0
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +11 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +12 -2
- package/dist/packages/stack/src/plugins/utils.cjs +6 -0
- package/dist/packages/stack/src/plugins/utils.mjs +6 -1
- package/dist/plugins/ai-chat/api/index.cjs +3 -0
- package/dist/plugins/ai-chat/api/index.d.cts +27 -4
- package/dist/plugins/ai-chat/api/index.d.mts +27 -4
- package/dist/plugins/ai-chat/api/index.d.ts +27 -4
- package/dist/plugins/ai-chat/api/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +2 -2
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +2 -2
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +2 -2
- package/dist/plugins/ai-chat/query-keys.d.cts +9 -284
- package/dist/plugins/ai-chat/query-keys.d.mts +9 -284
- package/dist/plugins/ai-chat/query-keys.d.ts +9 -284
- package/dist/plugins/api/index.d.cts +4 -3
- package/dist/plugins/api/index.d.mts +4 -3
- package/dist/plugins/api/index.d.ts +4 -3
- package/dist/plugins/blog/api/index.cjs +9 -0
- package/dist/plugins/blog/api/index.d.cts +20 -4
- package/dist/plugins/blog/api/index.d.mts +20 -4
- package/dist/plugins/blog/api/index.d.ts +20 -4
- package/dist/plugins/blog/api/index.mjs +3 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +5 -5
- package/dist/plugins/blog/client/hooks/index.d.mts +5 -5
- package/dist/plugins/blog/client/hooks/index.d.ts +5 -5
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.cjs +13 -9
- package/dist/plugins/blog/query-keys.d.cts +8 -333
- package/dist/plugins/blog/query-keys.d.mts +8 -333
- package/dist/plugins/blog/query-keys.d.ts +8 -333
- package/dist/plugins/blog/query-keys.mjs +13 -9
- package/dist/plugins/client/index.cjs +1 -0
- package/dist/plugins/client/index.d.cts +10 -3
- package/dist/plugins/client/index.d.mts +10 -3
- package/dist/plugins/client/index.d.ts +10 -3
- package/dist/plugins/client/index.mjs +1 -1
- package/dist/plugins/cms/api/index.cjs +10 -0
- package/dist/plugins/cms/api/index.d.cts +7 -163
- package/dist/plugins/cms/api/index.d.mts +7 -163
- package/dist/plugins/cms/api/index.d.ts +7 -163
- package/dist/plugins/cms/api/index.mjs +2 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
- package/dist/plugins/cms/query-keys.cjs +2 -1
- package/dist/plugins/cms/query-keys.d.cts +6 -9
- package/dist/plugins/cms/query-keys.d.mts +6 -9
- package/dist/plugins/cms/query-keys.d.ts +6 -9
- package/dist/plugins/cms/query-keys.mjs +2 -1
- package/dist/plugins/form-builder/api/index.cjs +10 -0
- package/dist/plugins/form-builder/api/index.d.cts +7 -141
- package/dist/plugins/form-builder/api/index.d.mts +7 -141
- package/dist/plugins/form-builder/api/index.d.ts +7 -141
- package/dist/plugins/form-builder/api/index.mjs +2 -0
- package/dist/plugins/form-builder/client/components/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.ts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
- package/dist/plugins/form-builder/query-keys.cjs +3 -2
- package/dist/plugins/form-builder/query-keys.d.cts +7 -6
- package/dist/plugins/form-builder/query-keys.d.mts +7 -6
- package/dist/plugins/form-builder/query-keys.d.ts +7 -6
- package/dist/plugins/form-builder/query-keys.mjs +3 -2
- package/dist/plugins/kanban/api/index.cjs +9 -0
- package/dist/plugins/kanban/api/index.d.cts +17 -395
- package/dist/plugins/kanban/api/index.d.mts +17 -395
- package/dist/plugins/kanban/api/index.d.ts +17 -395
- package/dist/plugins/kanban/api/index.mjs +3 -0
- package/dist/plugins/kanban/client/components/index.d.cts +1 -1
- package/dist/plugins/kanban/client/components/index.d.mts +1 -1
- package/dist/plugins/kanban/client/components/index.d.ts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
- package/dist/plugins/kanban/client/index.d.cts +1 -1
- package/dist/plugins/kanban/client/index.d.mts +1 -1
- package/dist/plugins/kanban/client/index.d.ts +1 -1
- package/dist/plugins/kanban/query-keys.cjs +6 -12
- package/dist/plugins/kanban/query-keys.d.cts +5 -16
- package/dist/plugins/kanban/query-keys.d.mts +5 -16
- package/dist/plugins/kanban/query-keys.d.ts +5 -16
- package/dist/plugins/kanban/query-keys.mjs +6 -12
- package/dist/plugins/open-api/api/index.d.cts +2 -2
- package/dist/plugins/open-api/api/index.d.mts +2 -2
- package/dist/plugins/open-api/api/index.d.ts +2 -2
- package/dist/plugins/route-docs/client/index.d.cts +1 -1
- package/dist/plugins/route-docs/client/index.d.mts +1 -1
- package/dist/plugins/route-docs/client/index.d.ts +1 -1
- package/dist/plugins/ui-builder/index.d.cts +1 -1
- package/dist/plugins/ui-builder/index.d.mts +1 -1
- package/dist/plugins/ui-builder/index.d.ts +1 -1
- package/dist/shared/{stack.BoA0xkJv.d.cts → stack.7n9Y_u7N.d.cts} +33 -7
- package/dist/shared/{stack.BoA0xkJv.d.mts → stack.7n9Y_u7N.d.mts} +33 -7
- package/dist/shared/{stack.BoA0xkJv.d.ts → stack.7n9Y_u7N.d.ts} +33 -7
- package/dist/shared/stack.B1EeBt1b.d.ts +297 -0
- package/dist/shared/stack.BIXEI6v_.d.mts +419 -0
- package/dist/shared/stack.BKfolAyK.d.ts +419 -0
- package/dist/shared/stack.BeSm90va.d.ts +289 -0
- package/dist/shared/stack.BpolpQpf.d.cts +445 -0
- package/dist/shared/stack.C5dtIncc.d.mts +293 -0
- package/dist/shared/stack.CIP6QS9l.d.ts +293 -0
- package/dist/shared/stack.CMh_EdxW.d.cts +289 -0
- package/dist/shared/stack.CP68pFEH.d.mts +297 -0
- package/dist/shared/{stack.BsXokfNh.d.mts → stack.CVDTkMoO.d.cts} +8 -2
- package/dist/shared/{stack.BsXokfNh.d.ts → stack.CVDTkMoO.d.mts} +8 -2
- package/dist/shared/{stack.BsXokfNh.d.cts → stack.CVDTkMoO.d.ts} +8 -2
- package/dist/shared/{stack.DKDMI-QO.d.mts → stack.DJaKVY7v.d.cts} +7 -1
- package/dist/shared/{stack.DKDMI-QO.d.ts → stack.DJaKVY7v.d.mts} +7 -1
- package/dist/shared/{stack.DKDMI-QO.d.cts → stack.DJaKVY7v.d.ts} +7 -1
- package/dist/shared/{stack.DzH_wcvr.d.mts → stack.DdI5W6MB.d.cts} +9 -3
- package/dist/shared/{stack.DzH_wcvr.d.ts → stack.DdI5W6MB.d.mts} +9 -3
- package/dist/shared/{stack.DzH_wcvr.d.cts → stack.DdI5W6MB.d.ts} +9 -3
- package/dist/shared/stack.Dg09R0oB.d.mts +289 -0
- package/dist/shared/stack.Dw0Ly2TM.d.cts +293 -0
- package/dist/shared/stack.IdtKDRka.d.cts +297 -0
- package/dist/shared/stack.TIBF2AOx.d.ts +445 -0
- package/dist/shared/stack.rTy7-wQU.d.mts +445 -0
- package/dist/shared/stack.snB1EDP7.d.cts +419 -0
- package/package.json +3 -3
- package/src/__tests__/stack-api.test.ts +118 -0
- package/src/api/index.ts +15 -1
- package/src/plugins/ai-chat/__tests__/getters.test.ts +109 -0
- package/src/plugins/ai-chat/api/getters.ts +71 -0
- package/src/plugins/ai-chat/api/index.ts +1 -0
- package/src/plugins/ai-chat/api/plugin.ts +8 -0
- package/src/plugins/api/index.ts +3 -1
- package/src/plugins/blog/__tests__/getters.test.ts +540 -0
- package/src/plugins/blog/api/getters.ts +243 -0
- package/src/plugins/blog/api/index.ts +9 -0
- package/src/plugins/blog/api/plugin.ts +98 -141
- package/src/plugins/blog/api/query-key-defs.ts +46 -0
- package/src/plugins/blog/api/serializers.ts +27 -0
- package/src/plugins/blog/client/plugin.tsx +21 -1
- package/src/plugins/blog/query-keys.ts +21 -20
- package/src/plugins/client/index.ts +1 -1
- package/src/plugins/cms/__tests__/getters.test.ts +206 -0
- package/src/plugins/cms/api/getters.ts +268 -0
- package/src/plugins/cms/api/index.ts +15 -1
- package/src/plugins/cms/api/plugin.ts +151 -150
- package/src/plugins/cms/api/query-key-defs.ts +53 -0
- package/src/plugins/cms/api/serializers.ts +12 -0
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +1 -1
- package/src/plugins/cms/client/hooks/cms-hooks.tsx +3 -0
- package/src/plugins/cms/client/plugin.tsx +19 -0
- package/src/plugins/cms/query-keys.ts +2 -1
- package/src/plugins/cms/types.ts +1 -1
- package/src/plugins/form-builder/__tests__/getters.test.ts +159 -0
- package/src/plugins/form-builder/api/getters.ts +226 -0
- package/src/plugins/form-builder/api/index.ts +15 -1
- package/src/plugins/form-builder/api/plugin.ts +107 -109
- package/src/plugins/form-builder/api/query-key-defs.ts +79 -0
- package/src/plugins/form-builder/api/serializers.ts +12 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +1 -1
- package/src/plugins/form-builder/client/plugin.tsx +19 -0
- package/src/plugins/form-builder/query-keys.ts +6 -2
- package/src/plugins/form-builder/types.ts +2 -2
- package/src/plugins/kanban/__tests__/getters.test.ts +172 -0
- package/src/plugins/kanban/api/getters.ts +149 -0
- package/src/plugins/kanban/api/index.ts +4 -0
- package/src/plugins/kanban/api/plugin.ts +65 -146
- package/src/plugins/kanban/api/query-key-defs.ts +54 -0
- package/src/plugins/kanban/api/serializers.ts +49 -0
- package/src/plugins/kanban/client/plugin.tsx +15 -1
- package/src/plugins/kanban/query-keys.ts +10 -14
- package/src/plugins/utils.ts +19 -0
- package/src/types.ts +44 -5
- package/dist/shared/{stack.CbuN2zVV.d.cts → stack.CBON0dWL.d.cts} +7 -7
- package/dist/shared/{stack.CbuN2zVV.d.mts → stack.CBON0dWL.d.mts} +7 -7
- package/dist/shared/{stack.CbuN2zVV.d.ts → stack.CBON0dWL.d.ts} +7 -7
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { createApiClient } from '@btst/stack/plugins/client';
|
|
3
|
+
import { M as Message, C as Conversation, S as SerializedConversation, a as SerializedMessage } from './stack.Be1QIHEn.cjs';
|
|
4
|
+
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
5
|
+
import * as better_call from 'better-call';
|
|
6
|
+
import * as zod_v4_core from 'zod/v4/core';
|
|
7
|
+
import * as zod from 'zod';
|
|
8
|
+
import { LanguageModel, Tool } from 'ai';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Context passed to AI Chat API hooks
|
|
12
|
+
*/
|
|
13
|
+
interface ChatApiContext<TBody = any, TParams = any, TQuery = any> {
|
|
14
|
+
body?: TBody;
|
|
15
|
+
params?: TParams;
|
|
16
|
+
query?: TQuery;
|
|
17
|
+
request?: Request;
|
|
18
|
+
headers?: Headers;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Configuration hooks for AI Chat backend plugin
|
|
23
|
+
* All hooks are optional and allow consumers to customize behavior
|
|
24
|
+
*/
|
|
25
|
+
interface AiChatBackendHooks {
|
|
26
|
+
/**
|
|
27
|
+
* Called before processing a chat message. Return false to deny access.
|
|
28
|
+
* @param messages - Array of messages being sent
|
|
29
|
+
* @param context - Request context with headers, etc.
|
|
30
|
+
*/
|
|
31
|
+
onBeforeChat?: (messages: Array<{
|
|
32
|
+
role: string;
|
|
33
|
+
content: string;
|
|
34
|
+
}>, context: ChatApiContext) => Promise<boolean> | boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Called before listing conversations. Return false to deny access.
|
|
37
|
+
* @param context - Request context with headers, etc.
|
|
38
|
+
*/
|
|
39
|
+
onBeforeListConversations?: (context: ChatApiContext) => Promise<boolean> | boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Called before getting a single conversation. Return false to deny access.
|
|
42
|
+
* @param conversationId - ID of the conversation being accessed
|
|
43
|
+
* @param context - Request context with headers, etc.
|
|
44
|
+
*/
|
|
45
|
+
onBeforeGetConversation?: (conversationId: string, context: ChatApiContext) => Promise<boolean> | boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Called before creating a conversation. Return false to deny access.
|
|
48
|
+
* @param data - Conversation data being created
|
|
49
|
+
* @param context - Request context with headers, etc.
|
|
50
|
+
*/
|
|
51
|
+
onBeforeCreateConversation?: (data: {
|
|
52
|
+
id?: string;
|
|
53
|
+
title?: string;
|
|
54
|
+
}, context: ChatApiContext) => Promise<boolean> | boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Called before updating a conversation. Return false to deny access.
|
|
57
|
+
* @param conversationId - ID of the conversation being updated
|
|
58
|
+
* @param data - Updated conversation data
|
|
59
|
+
* @param context - Request context with headers, etc.
|
|
60
|
+
*/
|
|
61
|
+
onBeforeUpdateConversation?: (conversationId: string, data: {
|
|
62
|
+
title?: string;
|
|
63
|
+
}, context: ChatApiContext) => Promise<boolean> | boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Called before deleting a conversation. Return false to deny access.
|
|
66
|
+
* @param conversationId - ID of the conversation being deleted
|
|
67
|
+
* @param context - Request context with headers, etc.
|
|
68
|
+
*/
|
|
69
|
+
onBeforeDeleteConversation?: (conversationId: string, context: ChatApiContext) => Promise<boolean> | boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Called after a chat message is processed successfully
|
|
72
|
+
* @param conversationId - ID of the conversation
|
|
73
|
+
* @param messages - Array of messages in the conversation
|
|
74
|
+
* @param context - Request context
|
|
75
|
+
*/
|
|
76
|
+
onAfterChat?: (conversationId: string, messages: Message[], context: ChatApiContext) => Promise<void> | void;
|
|
77
|
+
/**
|
|
78
|
+
* Called after conversations are read successfully
|
|
79
|
+
* @param conversations - Array of conversations that were read
|
|
80
|
+
* @param context - Request context
|
|
81
|
+
*/
|
|
82
|
+
onConversationsRead?: (conversations: Conversation[], context: ChatApiContext) => Promise<void> | void;
|
|
83
|
+
/**
|
|
84
|
+
* Called after a single conversation is read successfully
|
|
85
|
+
* @param conversation - The conversation with messages
|
|
86
|
+
* @param context - Request context
|
|
87
|
+
*/
|
|
88
|
+
onConversationRead?: (conversation: Conversation & {
|
|
89
|
+
messages: Message[];
|
|
90
|
+
}, context: ChatApiContext) => Promise<void> | void;
|
|
91
|
+
/**
|
|
92
|
+
* Called after a conversation is created successfully
|
|
93
|
+
* @param conversation - The created conversation
|
|
94
|
+
* @param context - Request context
|
|
95
|
+
*/
|
|
96
|
+
onConversationCreated?: (conversation: Conversation, context: ChatApiContext) => Promise<void> | void;
|
|
97
|
+
/**
|
|
98
|
+
* Called after a conversation is updated successfully
|
|
99
|
+
* @param conversation - The updated conversation
|
|
100
|
+
* @param context - Request context
|
|
101
|
+
*/
|
|
102
|
+
onConversationUpdated?: (conversation: Conversation, context: ChatApiContext) => Promise<void> | void;
|
|
103
|
+
/**
|
|
104
|
+
* Called after a conversation is deleted successfully
|
|
105
|
+
* @param conversationId - ID of the deleted conversation
|
|
106
|
+
* @param context - Request context
|
|
107
|
+
*/
|
|
108
|
+
onConversationDeleted?: (conversationId: string, context: ChatApiContext) => Promise<void> | void;
|
|
109
|
+
/**
|
|
110
|
+
* Called when a chat operation fails
|
|
111
|
+
* @param error - The error that occurred
|
|
112
|
+
* @param context - Request context
|
|
113
|
+
*/
|
|
114
|
+
onChatError?: (error: Error, context: ChatApiContext) => Promise<void> | void;
|
|
115
|
+
/**
|
|
116
|
+
* Called when listing conversations fails
|
|
117
|
+
* @param error - The error that occurred
|
|
118
|
+
* @param context - Request context
|
|
119
|
+
*/
|
|
120
|
+
onListConversationsError?: (error: Error, context: ChatApiContext) => Promise<void> | void;
|
|
121
|
+
/**
|
|
122
|
+
* Called when getting a conversation fails
|
|
123
|
+
* @param error - The error that occurred
|
|
124
|
+
* @param context - Request context
|
|
125
|
+
*/
|
|
126
|
+
onGetConversationError?: (error: Error, context: ChatApiContext) => Promise<void> | void;
|
|
127
|
+
/**
|
|
128
|
+
* Called when creating a conversation fails
|
|
129
|
+
* @param error - The error that occurred
|
|
130
|
+
* @param context - Request context
|
|
131
|
+
*/
|
|
132
|
+
onCreateConversationError?: (error: Error, context: ChatApiContext) => Promise<void> | void;
|
|
133
|
+
/**
|
|
134
|
+
* Called when updating a conversation fails
|
|
135
|
+
* @param error - The error that occurred
|
|
136
|
+
* @param context - Request context
|
|
137
|
+
*/
|
|
138
|
+
onUpdateConversationError?: (error: Error, context: ChatApiContext) => Promise<void> | void;
|
|
139
|
+
/**
|
|
140
|
+
* Called when deleting a conversation fails
|
|
141
|
+
* @param error - The error that occurred
|
|
142
|
+
* @param context - Request context
|
|
143
|
+
*/
|
|
144
|
+
onDeleteConversationError?: (error: Error, context: ChatApiContext) => Promise<void> | void;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Plugin mode for AI Chat
|
|
148
|
+
* - 'authenticated': Conversations persisted with userId (default)
|
|
149
|
+
* - 'public': Stateless chat, no persistence (ideal for public chatbots)
|
|
150
|
+
*/
|
|
151
|
+
type AiChatMode = "authenticated" | "public";
|
|
152
|
+
/**
|
|
153
|
+
* Configuration for AI Chat backend plugin
|
|
154
|
+
*/
|
|
155
|
+
interface AiChatBackendConfig {
|
|
156
|
+
/**
|
|
157
|
+
* The language model to use for chat completions.
|
|
158
|
+
* Supports any model from AI SDK providers (OpenAI, Anthropic, Google, etc.)
|
|
159
|
+
*/
|
|
160
|
+
model: LanguageModel;
|
|
161
|
+
/**
|
|
162
|
+
* Plugin mode:
|
|
163
|
+
* - 'authenticated': Conversations persisted with userId (requires getUserId)
|
|
164
|
+
* - 'public': Stateless chat, no persistence (ideal for public chatbots)
|
|
165
|
+
* @default 'authenticated'
|
|
166
|
+
*/
|
|
167
|
+
mode?: AiChatMode;
|
|
168
|
+
/**
|
|
169
|
+
* Extract userId from request context (authenticated mode only).
|
|
170
|
+
* Return null/undefined to deny access in authenticated mode.
|
|
171
|
+
* This function is called for all conversation operations.
|
|
172
|
+
* @example (ctx) => ctx.headers?.get('x-user-id')
|
|
173
|
+
*/
|
|
174
|
+
getUserId?: (context: ChatApiContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
175
|
+
/**
|
|
176
|
+
* Optional system prompt to prepend to all conversations
|
|
177
|
+
*/
|
|
178
|
+
systemPrompt?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Optional tools to make available to the model.
|
|
181
|
+
* Uses AI SDK v5 tool format.
|
|
182
|
+
* @see https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling
|
|
183
|
+
*/
|
|
184
|
+
tools?: Record<string, Tool>;
|
|
185
|
+
/**
|
|
186
|
+
* Optional hooks for customizing plugin behavior
|
|
187
|
+
*/
|
|
188
|
+
hooks?: AiChatBackendHooks;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* AI Chat backend plugin
|
|
192
|
+
* Provides API endpoints for AI-powered chat with conversation history
|
|
193
|
+
* Uses AI SDK v5 for model interactions
|
|
194
|
+
*
|
|
195
|
+
* @param config - Configuration including model, tools, and optional hooks
|
|
196
|
+
*/
|
|
197
|
+
declare const aiChatBackendPlugin: (config: AiChatBackendConfig) => _btst_stack_plugins_api.BackendPlugin<{
|
|
198
|
+
chat: better_call.StrictEndpoint<"/chat", {
|
|
199
|
+
method: "POST";
|
|
200
|
+
body: zod.ZodObject<{
|
|
201
|
+
messages: zod.ZodArray<zod.ZodUnion<readonly [zod.ZodObject<{
|
|
202
|
+
role: zod.ZodEnum<{
|
|
203
|
+
system: "system";
|
|
204
|
+
user: "user";
|
|
205
|
+
assistant: "assistant";
|
|
206
|
+
data: "data";
|
|
207
|
+
}>;
|
|
208
|
+
content: zod.ZodString;
|
|
209
|
+
id: zod.ZodOptional<zod.ZodString>;
|
|
210
|
+
}, zod_v4_core.$strip>, zod.ZodObject<{
|
|
211
|
+
role: zod.ZodEnum<{
|
|
212
|
+
system: "system";
|
|
213
|
+
user: "user";
|
|
214
|
+
assistant: "assistant";
|
|
215
|
+
data: "data";
|
|
216
|
+
}>;
|
|
217
|
+
parts: zod.ZodArray<zod.ZodObject<{
|
|
218
|
+
type: zod.ZodString;
|
|
219
|
+
text: zod.ZodOptional<zod.ZodString>;
|
|
220
|
+
}, zod_v4_core.$loose>>;
|
|
221
|
+
id: zod.ZodOptional<zod.ZodString>;
|
|
222
|
+
metadata: zod.ZodOptional<zod.ZodAny>;
|
|
223
|
+
}, zod_v4_core.$strip>]>>;
|
|
224
|
+
conversationId: zod.ZodOptional<zod.ZodString>;
|
|
225
|
+
model: zod.ZodOptional<zod.ZodString>;
|
|
226
|
+
}, zod_v4_core.$strip>;
|
|
227
|
+
}, Response>;
|
|
228
|
+
createConversation: better_call.StrictEndpoint<"/chat/conversations", {
|
|
229
|
+
method: "POST";
|
|
230
|
+
body: zod.ZodObject<{
|
|
231
|
+
id: zod.ZodOptional<zod.ZodString>;
|
|
232
|
+
title: zod.ZodOptional<zod.ZodString>;
|
|
233
|
+
}, zod_v4_core.$strip>;
|
|
234
|
+
}, Conversation>;
|
|
235
|
+
listConversations: better_call.StrictEndpoint<"/chat/conversations", {
|
|
236
|
+
method: "GET";
|
|
237
|
+
}, Conversation[]>;
|
|
238
|
+
getConversation: better_call.StrictEndpoint<"/chat/conversations/:id", {
|
|
239
|
+
method: "GET";
|
|
240
|
+
}, Conversation & {
|
|
241
|
+
messages: Message[];
|
|
242
|
+
}>;
|
|
243
|
+
updateConversation: better_call.StrictEndpoint<"/chat/conversations/:id", {
|
|
244
|
+
method: "PUT";
|
|
245
|
+
body: zod.ZodObject<{
|
|
246
|
+
title: zod.ZodOptional<zod.ZodString>;
|
|
247
|
+
}, zod_v4_core.$strip>;
|
|
248
|
+
}, Conversation>;
|
|
249
|
+
deleteConversation: better_call.StrictEndpoint<"/chat/conversations/:id", {
|
|
250
|
+
method: "DELETE";
|
|
251
|
+
}, {
|
|
252
|
+
success: boolean;
|
|
253
|
+
}>;
|
|
254
|
+
}, {
|
|
255
|
+
getAllConversations: (userId?: string) => Promise<Conversation[]>;
|
|
256
|
+
getConversationById: (id: string) => Promise<(Conversation & {
|
|
257
|
+
messages: Message[];
|
|
258
|
+
}) | null>;
|
|
259
|
+
}>;
|
|
260
|
+
type AiChatApiRouter = ReturnType<ReturnType<typeof aiChatBackendPlugin>["routes"]>;
|
|
261
|
+
|
|
262
|
+
type ConversationWithMessages = SerializedConversation & {
|
|
263
|
+
messages: SerializedMessage[];
|
|
264
|
+
};
|
|
265
|
+
declare function createAiChatQueryKeys(client: ReturnType<typeof createApiClient<AiChatApiRouter>>, headers?: HeadersInit): {
|
|
266
|
+
conversations: {
|
|
267
|
+
_def: readonly ["conversations"];
|
|
268
|
+
} & {
|
|
269
|
+
list: (() => Omit<{
|
|
270
|
+
queryKey: readonly ["conversations", "list", string];
|
|
271
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedConversation[], readonly ["conversations", "list", string]>;
|
|
272
|
+
} & {
|
|
273
|
+
_def: readonly ["conversations", "list"];
|
|
274
|
+
}, "_def">) & {
|
|
275
|
+
_def: readonly ["conversations", "list"];
|
|
276
|
+
};
|
|
277
|
+
detail: ((id: string) => Omit<{
|
|
278
|
+
queryKey: readonly ["conversations", "detail", string];
|
|
279
|
+
queryFn: _tanstack_react_query.QueryFunction<ConversationWithMessages | null, readonly ["conversations", "detail", string]>;
|
|
280
|
+
} & {
|
|
281
|
+
_def: readonly ["conversations", "detail"];
|
|
282
|
+
}, "_def">) & {
|
|
283
|
+
_def: readonly ["conversations", "detail"];
|
|
284
|
+
};
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export { createAiChatQueryKeys as c, aiChatBackendPlugin as d };
|
|
289
|
+
export type { AiChatBackendHooks as A, ChatApiContext as C, AiChatMode as a, AiChatBackendConfig as b, AiChatApiRouter as e, ConversationWithMessages as f };
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
|
+
import { a as SerializedContentItemWithType, S as SerializedContentType, b as ContentType, c as ContentItem, d as SerializedContentItem, e as ContentItemWithType, f as CMSBackendConfig, I as InverseRelation } from './stack.CVDTkMoO.mjs';
|
|
3
|
+
import * as better_call from 'better-call';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { Adapter } from '@btst/db';
|
|
6
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Serialize a ContentType for SSR/SSG use (convert dates to strings).
|
|
10
|
+
* Applies lazy migration for legacy schemas (version 1 → 2).
|
|
11
|
+
*/
|
|
12
|
+
declare function serializeContentType(ct: ContentType): SerializedContentType;
|
|
13
|
+
/**
|
|
14
|
+
* Serialize a ContentItem for SSR/SSG use (convert dates to strings).
|
|
15
|
+
*/
|
|
16
|
+
declare function serializeContentItem(item: ContentItem): SerializedContentItem;
|
|
17
|
+
/**
|
|
18
|
+
* Serialize a ContentItem with parsed data and joined ContentType.
|
|
19
|
+
* Throws a SyntaxError if `item.data` is not valid JSON, so corrupted rows
|
|
20
|
+
* produce a visible, debuggable error rather than silently returning null.
|
|
21
|
+
*/
|
|
22
|
+
declare function serializeContentItemWithType(item: ContentItemWithType): SerializedContentItemWithType;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve all content types.
|
|
25
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
26
|
+
*
|
|
27
|
+
* @remarks **Security:** Authorization hooks are NOT called. The caller is
|
|
28
|
+
* responsible for any access-control checks before invoking this function.
|
|
29
|
+
*
|
|
30
|
+
* @param adapter - The database adapter
|
|
31
|
+
*/
|
|
32
|
+
declare function getAllContentTypes(adapter: Adapter): Promise<SerializedContentType[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve all content items for a given content type, with optional pagination.
|
|
35
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
36
|
+
*
|
|
37
|
+
* @remarks **Security:** Authorization hooks (e.g. `onBeforeListItems`) are NOT
|
|
38
|
+
* called. The caller is responsible for any access-control checks before
|
|
39
|
+
* invoking this function.
|
|
40
|
+
*
|
|
41
|
+
* @param adapter - The database adapter
|
|
42
|
+
* @param contentTypeSlug - The slug of the content type to query
|
|
43
|
+
* @param params - Optional filter/pagination parameters
|
|
44
|
+
*/
|
|
45
|
+
declare function getAllContentItems(adapter: Adapter, contentTypeSlug: string, params?: {
|
|
46
|
+
slug?: string;
|
|
47
|
+
limit?: number;
|
|
48
|
+
offset?: number;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
items: SerializedContentItemWithType[];
|
|
51
|
+
total: number;
|
|
52
|
+
limit?: number;
|
|
53
|
+
offset?: number;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieve a single content item by its ID.
|
|
57
|
+
* Returns null if the item is not found.
|
|
58
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
59
|
+
*
|
|
60
|
+
* @remarks **Security:** Authorization hooks are NOT called. The caller is
|
|
61
|
+
* responsible for any access-control checks before invoking this function.
|
|
62
|
+
*
|
|
63
|
+
* @param adapter - The database adapter
|
|
64
|
+
* @param id - The content item ID (UUID)
|
|
65
|
+
*/
|
|
66
|
+
declare function getContentItemById(adapter: Adapter, id: string): Promise<SerializedContentItemWithType | null>;
|
|
67
|
+
/**
|
|
68
|
+
* Retrieve a single content item by its slug within a content type.
|
|
69
|
+
* Returns null if the content type or item is not found.
|
|
70
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
71
|
+
*
|
|
72
|
+
* @remarks **Security:** Authorization hooks are NOT called. The caller is
|
|
73
|
+
* responsible for any access-control checks before invoking this function.
|
|
74
|
+
*
|
|
75
|
+
* @param adapter - The database adapter
|
|
76
|
+
* @param contentTypeSlug - The slug of the content type
|
|
77
|
+
* @param slug - The slug of the content item
|
|
78
|
+
*/
|
|
79
|
+
declare function getContentItemBySlug(adapter: Adapter, contentTypeSlug: string, slug: string): Promise<SerializedContentItemWithType | null>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Route keys for the CMS plugin — matches the keys returned by
|
|
83
|
+
* `stackClient.router.getRoute(path).routeKey`.
|
|
84
|
+
*/
|
|
85
|
+
type CMSRouteKey = "dashboard" | "contentList" | "newContent" | "editContent";
|
|
86
|
+
interface CMSPrefetchForRoute {
|
|
87
|
+
(key: "dashboard" | "newContent", qc: QueryClient): Promise<void>;
|
|
88
|
+
(key: "contentList", qc: QueryClient, params: {
|
|
89
|
+
typeSlug: string;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
(key: "editContent", qc: QueryClient, params: {
|
|
92
|
+
typeSlug: string;
|
|
93
|
+
id: string;
|
|
94
|
+
}): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* CMS backend plugin
|
|
98
|
+
* Provides API endpoints for managing content types and content items
|
|
99
|
+
*
|
|
100
|
+
* @param config - Configuration with content types and optional hooks
|
|
101
|
+
*/
|
|
102
|
+
declare const cmsBackendPlugin: (config: CMSBackendConfig) => _btst_stack_plugins_api.BackendPlugin<{
|
|
103
|
+
listContentTypes: better_call.StrictEndpoint<"/content-types", {
|
|
104
|
+
method: "GET";
|
|
105
|
+
}, {
|
|
106
|
+
itemCount: number;
|
|
107
|
+
createdAt: string;
|
|
108
|
+
updatedAt: string;
|
|
109
|
+
name: string;
|
|
110
|
+
id: string;
|
|
111
|
+
slug: string;
|
|
112
|
+
description?: string | undefined;
|
|
113
|
+
jsonSchema: string;
|
|
114
|
+
fieldConfig?: string | undefined;
|
|
115
|
+
autoFormVersion?: number | undefined;
|
|
116
|
+
}[]>;
|
|
117
|
+
getContentTypeBySlug: better_call.StrictEndpoint<"/content-types/:slug", {
|
|
118
|
+
method: "GET";
|
|
119
|
+
params: z.ZodObject<{
|
|
120
|
+
slug: z.ZodString;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
}, SerializedContentType>;
|
|
123
|
+
listContentItems: better_call.StrictEndpoint<"/content/:typeSlug", {
|
|
124
|
+
method: "GET";
|
|
125
|
+
params: z.ZodObject<{
|
|
126
|
+
typeSlug: z.ZodString;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
query: z.ZodObject<{
|
|
129
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
130
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
131
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
132
|
+
}, z.core.$strip>;
|
|
133
|
+
}, {
|
|
134
|
+
items: SerializedContentItemWithType[];
|
|
135
|
+
total: number;
|
|
136
|
+
limit?: number;
|
|
137
|
+
offset?: number;
|
|
138
|
+
}>;
|
|
139
|
+
getContentItem: better_call.StrictEndpoint<"/content/:typeSlug/:id", {
|
|
140
|
+
method: "GET";
|
|
141
|
+
params: z.ZodObject<{
|
|
142
|
+
typeSlug: z.ZodString;
|
|
143
|
+
id: z.ZodString;
|
|
144
|
+
}, z.core.$strip>;
|
|
145
|
+
}, SerializedContentItemWithType<Record<string, unknown>>>;
|
|
146
|
+
createContentItem: better_call.StrictEndpoint<"/content/:typeSlug", {
|
|
147
|
+
method: "POST";
|
|
148
|
+
params: z.ZodObject<{
|
|
149
|
+
typeSlug: z.ZodString;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
body: z.ZodObject<{
|
|
152
|
+
slug: z.ZodString;
|
|
153
|
+
data: z.ZodObject<{}, z.core.$loose>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
}, {
|
|
156
|
+
parsedData: Record<string, unknown>;
|
|
157
|
+
createdAt: string;
|
|
158
|
+
updatedAt: string;
|
|
159
|
+
id: string;
|
|
160
|
+
slug: string;
|
|
161
|
+
contentTypeId: string;
|
|
162
|
+
data: string;
|
|
163
|
+
authorId?: string | undefined;
|
|
164
|
+
}>;
|
|
165
|
+
updateContentItem: better_call.StrictEndpoint<"/content/:typeSlug/:id", {
|
|
166
|
+
method: "PUT";
|
|
167
|
+
params: z.ZodObject<{
|
|
168
|
+
typeSlug: z.ZodString;
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
}, z.core.$strip>;
|
|
171
|
+
body: z.ZodObject<{
|
|
172
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
173
|
+
data: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
}, SerializedContentItemWithType<Record<string, unknown>>>;
|
|
176
|
+
deleteContentItem: better_call.StrictEndpoint<"/content/:typeSlug/:id", {
|
|
177
|
+
method: "DELETE";
|
|
178
|
+
params: z.ZodObject<{
|
|
179
|
+
typeSlug: z.ZodString;
|
|
180
|
+
id: z.ZodString;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
}, {
|
|
183
|
+
success: boolean;
|
|
184
|
+
}>;
|
|
185
|
+
getContentItemPopulated: better_call.StrictEndpoint<"/content/:typeSlug/:id/populated", {
|
|
186
|
+
method: "GET";
|
|
187
|
+
params: z.ZodObject<{
|
|
188
|
+
typeSlug: z.ZodString;
|
|
189
|
+
id: z.ZodString;
|
|
190
|
+
}, z.core.$strip>;
|
|
191
|
+
}, {
|
|
192
|
+
_relations: Record<string, SerializedContentItemWithType<Record<string, unknown>>[]>;
|
|
193
|
+
parsedData: Record<string, unknown>;
|
|
194
|
+
contentType?: SerializedContentType;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
updatedAt: string;
|
|
197
|
+
id: string;
|
|
198
|
+
slug: string;
|
|
199
|
+
contentTypeId: string;
|
|
200
|
+
data: string;
|
|
201
|
+
authorId?: string | undefined;
|
|
202
|
+
}>;
|
|
203
|
+
listContentByRelation: better_call.StrictEndpoint<"/content/:typeSlug/by-relation", {
|
|
204
|
+
method: "GET";
|
|
205
|
+
params: z.ZodObject<{
|
|
206
|
+
typeSlug: z.ZodString;
|
|
207
|
+
}, z.core.$strip>;
|
|
208
|
+
query: z.ZodObject<{
|
|
209
|
+
field: z.ZodString;
|
|
210
|
+
targetId: z.ZodString;
|
|
211
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
212
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
213
|
+
}, z.core.$strip>;
|
|
214
|
+
}, {
|
|
215
|
+
items: SerializedContentItemWithType<Record<string, unknown>>[];
|
|
216
|
+
total: number;
|
|
217
|
+
limit: number;
|
|
218
|
+
offset: number;
|
|
219
|
+
}>;
|
|
220
|
+
getInverseRelations: better_call.StrictEndpoint<"/content-types/:slug/inverse-relations", {
|
|
221
|
+
method: "GET";
|
|
222
|
+
params: z.ZodObject<{
|
|
223
|
+
slug: z.ZodString;
|
|
224
|
+
}, z.core.$strip>;
|
|
225
|
+
query: z.ZodObject<{
|
|
226
|
+
itemId: z.ZodOptional<z.ZodString>;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
}, {
|
|
229
|
+
inverseRelations: InverseRelation[];
|
|
230
|
+
}>;
|
|
231
|
+
listInverseRelationItems: better_call.StrictEndpoint<"/content-types/:slug/inverse-relations/:sourceType", {
|
|
232
|
+
method: "GET";
|
|
233
|
+
params: z.ZodObject<{
|
|
234
|
+
slug: z.ZodString;
|
|
235
|
+
sourceType: z.ZodString;
|
|
236
|
+
}, z.core.$strip>;
|
|
237
|
+
query: z.ZodObject<{
|
|
238
|
+
itemId: z.ZodString;
|
|
239
|
+
fieldName: z.ZodString;
|
|
240
|
+
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
241
|
+
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
242
|
+
}, z.core.$strip>;
|
|
243
|
+
}, {
|
|
244
|
+
items: SerializedContentItemWithType<Record<string, unknown>>[];
|
|
245
|
+
total: number;
|
|
246
|
+
limit: number;
|
|
247
|
+
offset: number;
|
|
248
|
+
}>;
|
|
249
|
+
}, {
|
|
250
|
+
getAllContentTypes: () => Promise<SerializedContentType[]>;
|
|
251
|
+
getAllContentItems: (contentTypeSlug: string, params?: Parameters<typeof getAllContentItems>[2]) => Promise<{
|
|
252
|
+
items: SerializedContentItemWithType[];
|
|
253
|
+
total: number;
|
|
254
|
+
limit?: number;
|
|
255
|
+
offset?: number;
|
|
256
|
+
}>;
|
|
257
|
+
getContentItemBySlug: (contentTypeSlug: string, slug: string) => Promise<SerializedContentItemWithType<Record<string, unknown>> | null>;
|
|
258
|
+
getContentItemById: (id: string) => Promise<SerializedContentItemWithType<Record<string, unknown>> | null>;
|
|
259
|
+
prefetchForRoute: CMSPrefetchForRoute;
|
|
260
|
+
}>;
|
|
261
|
+
type CMSApiRouter = ReturnType<ReturnType<typeof cmsBackendPlugin>["routes"]>;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Internal query key constants for the CMS plugin.
|
|
265
|
+
* Shared between query-keys.ts (HTTP path) and prefetchForRoute (DB path)
|
|
266
|
+
* to prevent key drift between SSR loaders and SSG prefetching.
|
|
267
|
+
*/
|
|
268
|
+
interface ContentListDiscriminator {
|
|
269
|
+
typeSlug: string;
|
|
270
|
+
limit: number;
|
|
271
|
+
offset: number;
|
|
272
|
+
}
|
|
273
|
+
/** Full query key builders — use these with queryClient.setQueryData() */
|
|
274
|
+
declare const CMS_QUERY_KEYS: {
|
|
275
|
+
/**
|
|
276
|
+
* Key for the cmsTypes.list() query.
|
|
277
|
+
* Full key: ["cmsTypes", "list", "list"]
|
|
278
|
+
*/
|
|
279
|
+
typesList: () => readonly ["cmsTypes", "list", "list"];
|
|
280
|
+
/**
|
|
281
|
+
* Key for the cmsContent.list({ typeSlug, limit, offset }) query.
|
|
282
|
+
* Full key: ["cmsContent", "list", { typeSlug, limit, offset }]
|
|
283
|
+
*/
|
|
284
|
+
contentList: (params: {
|
|
285
|
+
typeSlug: string;
|
|
286
|
+
limit?: number;
|
|
287
|
+
offset?: number;
|
|
288
|
+
}) => readonly ["cmsContent", "list", ContentListDiscriminator];
|
|
289
|
+
/**
|
|
290
|
+
* Key for the cmsContent.detail(typeSlug, id) query.
|
|
291
|
+
* Full key: ["cmsContent", "detail", typeSlug, id]
|
|
292
|
+
*/
|
|
293
|
+
contentDetail: (typeSlug: string, id: string) => readonly ["cmsContent", "detail", string, string];
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export { cmsBackendPlugin as c, getAllContentItems as d, getContentItemBySlug as e, getContentItemById as f, getAllContentTypes as g, serializeContentItem as h, serializeContentItemWithType as i, CMS_QUERY_KEYS as j, serializeContentType as s };
|
|
297
|
+
export type { CMSApiRouter as C, ContentListDiscriminator as a, CMSRouteKey as b };
|
|
@@ -58,6 +58,12 @@ type ContentItem = {
|
|
|
58
58
|
createdAt: Date;
|
|
59
59
|
updatedAt: Date;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Content item with its content type joined
|
|
63
|
+
*/
|
|
64
|
+
type ContentItemWithType = ContentItem & {
|
|
65
|
+
contentType?: ContentType;
|
|
66
|
+
};
|
|
61
67
|
/**
|
|
62
68
|
* Represents an inverse relation (content types that reference this type via belongsTo)
|
|
63
69
|
*/
|
|
@@ -90,7 +96,7 @@ interface SerializedContentItem extends Omit<ContentItem, "createdAt" | "updated
|
|
|
90
96
|
* @template TData - The type of the parsed data (defaults to Record<string, unknown>)
|
|
91
97
|
*/
|
|
92
98
|
interface SerializedContentItemWithType<TData = Record<string, unknown>> extends SerializedContentItem {
|
|
93
|
-
/** Parsed data object (JSON.parse of data field) */
|
|
99
|
+
/** Parsed data object (JSON.parse of data field). */
|
|
94
100
|
parsedData: TData;
|
|
95
101
|
/** Joined content type */
|
|
96
102
|
contentType?: SerializedContentType;
|
|
@@ -154,4 +160,4 @@ interface CMSBackendConfig {
|
|
|
154
160
|
hooks?: CMSBackendHooks;
|
|
155
161
|
}
|
|
156
162
|
|
|
157
|
-
export type { ContentTypeConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a,
|
|
163
|
+
export type { ContentTypeConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a, ContentType as b, ContentItem as c, SerializedContentItem as d, ContentItemWithType as e, CMSBackendConfig as f };
|
|
@@ -58,6 +58,12 @@ type ContentItem = {
|
|
|
58
58
|
createdAt: Date;
|
|
59
59
|
updatedAt: Date;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Content item with its content type joined
|
|
63
|
+
*/
|
|
64
|
+
type ContentItemWithType = ContentItem & {
|
|
65
|
+
contentType?: ContentType;
|
|
66
|
+
};
|
|
61
67
|
/**
|
|
62
68
|
* Represents an inverse relation (content types that reference this type via belongsTo)
|
|
63
69
|
*/
|
|
@@ -90,7 +96,7 @@ interface SerializedContentItem extends Omit<ContentItem, "createdAt" | "updated
|
|
|
90
96
|
* @template TData - The type of the parsed data (defaults to Record<string, unknown>)
|
|
91
97
|
*/
|
|
92
98
|
interface SerializedContentItemWithType<TData = Record<string, unknown>> extends SerializedContentItem {
|
|
93
|
-
/** Parsed data object (JSON.parse of data field) */
|
|
99
|
+
/** Parsed data object (JSON.parse of data field). */
|
|
94
100
|
parsedData: TData;
|
|
95
101
|
/** Joined content type */
|
|
96
102
|
contentType?: SerializedContentType;
|
|
@@ -154,4 +160,4 @@ interface CMSBackendConfig {
|
|
|
154
160
|
hooks?: CMSBackendHooks;
|
|
155
161
|
}
|
|
156
162
|
|
|
157
|
-
export type { ContentTypeConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a,
|
|
163
|
+
export type { ContentTypeConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a, ContentType as b, ContentItem as c, SerializedContentItem as d, ContentItemWithType as e, CMSBackendConfig as f };
|
|
@@ -58,6 +58,12 @@ type ContentItem = {
|
|
|
58
58
|
createdAt: Date;
|
|
59
59
|
updatedAt: Date;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Content item with its content type joined
|
|
63
|
+
*/
|
|
64
|
+
type ContentItemWithType = ContentItem & {
|
|
65
|
+
contentType?: ContentType;
|
|
66
|
+
};
|
|
61
67
|
/**
|
|
62
68
|
* Represents an inverse relation (content types that reference this type via belongsTo)
|
|
63
69
|
*/
|
|
@@ -90,7 +96,7 @@ interface SerializedContentItem extends Omit<ContentItem, "createdAt" | "updated
|
|
|
90
96
|
* @template TData - The type of the parsed data (defaults to Record<string, unknown>)
|
|
91
97
|
*/
|
|
92
98
|
interface SerializedContentItemWithType<TData = Record<string, unknown>> extends SerializedContentItem {
|
|
93
|
-
/** Parsed data object (JSON.parse of data field) */
|
|
99
|
+
/** Parsed data object (JSON.parse of data field). */
|
|
94
100
|
parsedData: TData;
|
|
95
101
|
/** Joined content type */
|
|
96
102
|
contentType?: SerializedContentType;
|
|
@@ -154,4 +160,4 @@ interface CMSBackendConfig {
|
|
|
154
160
|
hooks?: CMSBackendHooks;
|
|
155
161
|
}
|
|
156
162
|
|
|
157
|
-
export type { ContentTypeConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a,
|
|
163
|
+
export type { ContentTypeConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a, ContentType as b, ContentItem as c, SerializedContentItem as d, ContentItemWithType as e, CMSBackendConfig as f };
|
|
@@ -48,6 +48,12 @@ type Task = {
|
|
|
48
48
|
type ColumnWithTasks = Column & {
|
|
49
49
|
tasks: Task[];
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Board with columns and tasks
|
|
53
|
+
*/
|
|
54
|
+
type BoardWithColumns = Board & {
|
|
55
|
+
columns: ColumnWithTasks[];
|
|
56
|
+
};
|
|
51
57
|
interface SerializedTask extends Omit<Task, "createdAt" | "updatedAt" | "completedAt"> {
|
|
52
58
|
completedAt?: string;
|
|
53
59
|
createdAt: string;
|
|
@@ -67,4 +73,4 @@ interface SerializedBoardWithColumns extends SerializedBoard {
|
|
|
67
73
|
columns: SerializedColumn[];
|
|
68
74
|
}
|
|
69
75
|
|
|
70
|
-
export type {
|
|
76
|
+
export type { BoardWithColumns as B, ColumnWithTasks as C, Priority as P, SerializedBoardWithColumns as S, Task as T, SerializedColumn as a, SerializedTask as b, SerializedBoard as c, Board as d, Column as e };
|