@btst/stack 2.11.8 → 2.12.1
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/packages/stack/src/plugins/cms/api/plugin.cjs +14 -11
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +14 -11
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.cjs +87 -15
- package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.mjs +87 -15
- package/dist/packages/stack/src/plugins/cms/schemas.cjs +11 -6
- package/dist/packages/stack/src/plugins/cms/schemas.mjs +10 -6
- package/dist/packages/stack/src/plugins/comments/api/query-key-defs.cjs +2 -1
- package/dist/packages/stack/src/plugins/comments/api/query-key-defs.mjs +2 -1
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +6 -2
- package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +6 -2
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +5 -3
- package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +5 -3
- package/dist/packages/ui/src/components/auto-form/fields/array.cjs +181 -4
- package/dist/packages/ui/src/components/auto-form/fields/array.mjs +184 -7
- package/dist/packages/ui/src/components/auto-form/index.cjs +16 -1
- package/dist/packages/ui/src/components/auto-form/index.mjs +17 -2
- package/dist/plugins/cms/api/index.cjs +2 -0
- package/dist/plugins/cms/api/index.d.cts +3 -2
- package/dist/plugins/cms/api/index.d.mts +3 -2
- package/dist/plugins/cms/api/index.d.ts +3 -2
- package/dist/plugins/cms/api/index.mjs +1 -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.d.cts +398 -7
- package/dist/plugins/cms/query-keys.d.mts +398 -7
- package/dist/plugins/cms/query-keys.d.ts +398 -7
- package/dist/plugins/comments/api/index.d.cts +4 -4
- package/dist/plugins/comments/api/index.d.mts +4 -4
- package/dist/plugins/comments/api/index.d.ts +4 -4
- package/dist/plugins/comments/client/components/index.d.cts +11 -0
- package/dist/plugins/comments/client/components/index.d.mts +11 -0
- package/dist/plugins/comments/client/components/index.d.ts +11 -0
- package/dist/plugins/comments/client/hooks/index.d.cts +17 -1
- package/dist/plugins/comments/client/hooks/index.d.mts +17 -1
- package/dist/plugins/comments/client/hooks/index.d.ts +17 -1
- package/dist/plugins/comments/client/index.d.cts +9 -0
- package/dist/plugins/comments/client/index.d.mts +9 -0
- package/dist/plugins/comments/client/index.d.ts +9 -0
- package/dist/plugins/comments/query-keys.cjs +1 -0
- package/dist/plugins/comments/query-keys.d.cts +3 -2
- package/dist/plugins/comments/query-keys.d.mts +3 -2
- package/dist/plugins/comments/query-keys.d.ts +3 -2
- package/dist/plugins/comments/query-keys.mjs +1 -0
- package/dist/plugins/kanban/api/index.d.cts +1 -1
- package/dist/plugins/kanban/api/index.d.mts +1 -1
- package/dist/plugins/kanban/api/index.d.ts +1 -1
- package/dist/plugins/kanban/query-keys.d.cts +1 -1
- package/dist/plugins/kanban/query-keys.d.mts +1 -1
- package/dist/plugins/kanban/query-keys.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.CJE9sAjV.d.ts → stack.Bq3kiUaM.d.ts} +1 -1
- package/dist/shared/{stack.C-b3Sn8j.d.cts → stack.C7KNNiJm.d.cts} +3 -1
- package/dist/shared/{stack.C-b3Sn8j.d.mts → stack.C7KNNiJm.d.mts} +3 -1
- package/dist/shared/{stack.C-b3Sn8j.d.ts → stack.C7KNNiJm.d.ts} +3 -1
- package/dist/shared/{stack.Dcz6636A.d.mts → stack.CCncwK6g.d.cts} +1 -1
- package/dist/shared/{stack.CmHRdhl8.d.cts → stack.CO1g47IS.d.mts} +1 -1
- package/dist/shared/{stack.B8QD11QU.d.cts → stack.DFtpFS00.d.cts} +10 -0
- package/dist/shared/{stack.B8QD11QU.d.mts → stack.DFtpFS00.d.mts} +10 -0
- package/dist/shared/{stack.B8QD11QU.d.ts → stack.DFtpFS00.d.ts} +10 -0
- package/package.json +1 -1
- package/src/plugins/cms/__tests__/schema-roundtrip.test.ts +203 -0
- package/src/plugins/cms/api/index.ts +1 -0
- package/src/plugins/cms/api/plugin.ts +33 -16
- package/src/plugins/cms/client/components/forms/relation-field.tsx +121 -36
- package/src/plugins/cms/schemas.ts +26 -6
- package/src/plugins/cms/types.ts +10 -0
- package/src/plugins/comments/api/query-key-defs.ts +5 -1
- package/src/plugins/comments/client/components/comment-thread.tsx +15 -0
- package/src/plugins/comments/client/hooks/use-comments.tsx +26 -3
- package/src/plugins/comments/client/overrides.ts +10 -0
- package/src/plugins/comments/query-keys.ts +2 -0
- package/dist/shared/stack.DbnCLdNF.d.mts +0 -399
- package/dist/shared/stack.fXlShnhv.d.ts +0 -399
- package/dist/shared/stack.r6HohbyX.d.cts +0 -399
- package/dist/shared/{stack.B6S3cgwN.d.cts → stack.CuI_-z-_.d.cts} +16 -16
- package/dist/shared/{stack.Bzfx-_lq.d.mts → stack.D2RVkQD8.d.mts} +16 -16
- package/dist/shared/{stack.j5SFLC1d.d.ts → stack.DXrOtuek.d.ts} +16 -16
|
@@ -1,11 +1,401 @@
|
|
|
1
|
-
import
|
|
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, P as PaginatedContentItems } from '../../shared/stack.DFtpFS00.js';
|
|
3
|
+
import * as better_call from 'better-call';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { DBAdapter } from '@btst/db';
|
|
2
6
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
8
|
import { createApiClient } from '@btst/stack/plugins/client';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Serialize a ContentType for SSR/SSG use (convert dates to strings).
|
|
12
|
+
* Applies lazy migration for legacy schemas (version 1 → 2).
|
|
13
|
+
*/
|
|
14
|
+
declare function serializeContentType(ct: ContentType): SerializedContentType;
|
|
15
|
+
/**
|
|
16
|
+
* Serialize a ContentItem for SSR/SSG use (convert dates to strings).
|
|
17
|
+
*/
|
|
18
|
+
declare function serializeContentItem(item: ContentItem): SerializedContentItem;
|
|
19
|
+
/**
|
|
20
|
+
* Serialize a ContentItem with parsed data and joined ContentType.
|
|
21
|
+
* Throws a SyntaxError if `item.data` is not valid JSON, so corrupted rows
|
|
22
|
+
* produce a visible, debuggable error rather than silently returning null.
|
|
23
|
+
*/
|
|
24
|
+
declare function serializeContentItemWithType(item: ContentItemWithType): SerializedContentItemWithType;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieve all content types.
|
|
27
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
28
|
+
*
|
|
29
|
+
* @remarks **Security:** Authorization hooks are NOT called. The caller is
|
|
30
|
+
* responsible for any access-control checks before invoking this function.
|
|
31
|
+
*
|
|
32
|
+
* @param adapter - The database adapter
|
|
33
|
+
*/
|
|
34
|
+
declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedContentType[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Retrieve all content items for a given content type, with optional pagination.
|
|
37
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
38
|
+
*
|
|
39
|
+
* @remarks **Security:** Authorization hooks (e.g. `onBeforeListItems`) are NOT
|
|
40
|
+
* called. The caller is responsible for any access-control checks before
|
|
41
|
+
* invoking this function.
|
|
42
|
+
*
|
|
43
|
+
* @param adapter - The database adapter
|
|
44
|
+
* @param contentTypeSlug - The slug of the content type to query
|
|
45
|
+
* @param params - Optional filter/pagination parameters
|
|
46
|
+
*/
|
|
47
|
+
declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
48
|
+
slug?: string;
|
|
49
|
+
limit?: number;
|
|
50
|
+
offset?: number;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
items: SerializedContentItemWithType[];
|
|
53
|
+
total: number;
|
|
54
|
+
limit?: number;
|
|
55
|
+
offset?: number;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve a single content item by its ID.
|
|
59
|
+
* Returns null if the item is not found.
|
|
60
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
61
|
+
*
|
|
62
|
+
* @remarks **Security:** Authorization hooks are NOT called. The caller is
|
|
63
|
+
* responsible for any access-control checks before invoking this function.
|
|
64
|
+
*
|
|
65
|
+
* @param adapter - The database adapter
|
|
66
|
+
* @param id - The content item ID (UUID)
|
|
67
|
+
*/
|
|
68
|
+
declare function getContentItemById(adapter: DBAdapter, id: string): Promise<SerializedContentItemWithType | null>;
|
|
69
|
+
/**
|
|
70
|
+
* Retrieve a single content item by its slug within a content type.
|
|
71
|
+
* Returns null if the content type or item is not found.
|
|
72
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
73
|
+
*
|
|
74
|
+
* @remarks **Security:** Authorization hooks are NOT called. The caller is
|
|
75
|
+
* responsible for any access-control checks before invoking this function.
|
|
76
|
+
*
|
|
77
|
+
* @param adapter - The database adapter
|
|
78
|
+
* @param contentTypeSlug - The slug of the content type
|
|
79
|
+
* @param slug - The slug of the content item
|
|
80
|
+
*/
|
|
81
|
+
declare function getContentItemBySlug(adapter: DBAdapter, contentTypeSlug: string, slug: string): Promise<SerializedContentItemWithType | null>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Input for creating a new CMS content item.
|
|
85
|
+
*/
|
|
86
|
+
interface CreateCMSContentItemInput {
|
|
87
|
+
/** URL-safe slug for the item */
|
|
88
|
+
slug: string;
|
|
89
|
+
/** Arbitrary data payload — should match the content type schema */
|
|
90
|
+
data: Record<string, unknown>;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Options for {@link createCMSContentItem}.
|
|
94
|
+
*/
|
|
95
|
+
interface CreateCMSContentItemOptions {
|
|
96
|
+
/**
|
|
97
|
+
* When `true`, persist relation fields (`belongsTo`, `hasMany`,
|
|
98
|
+
* `manyToMany`) into the `contentRelation` junction table in addition to
|
|
99
|
+
* the item's JSON payload.
|
|
100
|
+
*
|
|
101
|
+
* This is what the HTTP `POST /content/:typeSlug` route does, and is
|
|
102
|
+
* required for the admin "Related Items" panel / inverse-relation queries
|
|
103
|
+
* to find the item.
|
|
104
|
+
*
|
|
105
|
+
* Seeds and other programmatic callers that want the admin UI to work
|
|
106
|
+
* should enable this flag. Callers are still expected to pass
|
|
107
|
+
* pre-created target IDs (`{ id }` or `[{ id }, ...]`) — inline `_new`
|
|
108
|
+
* creation is only supported via the HTTP route.
|
|
109
|
+
*
|
|
110
|
+
* Defaults to `false` for backwards compatibility (a no-op for content
|
|
111
|
+
* types without relations).
|
|
112
|
+
*/
|
|
113
|
+
syncRelations?: boolean;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Create a new content item for a content type (looked up by slug).
|
|
117
|
+
*
|
|
118
|
+
* Bypasses Zod schema validation and inline `_new` relation creation — the
|
|
119
|
+
* caller is responsible for providing valid data and pre-created relation
|
|
120
|
+
* IDs. For schema validation or inline creation of related items, use the
|
|
121
|
+
* HTTP endpoint instead.
|
|
122
|
+
*
|
|
123
|
+
* Throws if the content type is not found or the slug is already taken within
|
|
124
|
+
* that content type.
|
|
125
|
+
*
|
|
126
|
+
* @remarks **Security:** No authorization hooks (`onBeforeCreate`, `onAfterCreate`)
|
|
127
|
+
* are called. The caller is responsible for any access-control checks before
|
|
128
|
+
* invoking this function.
|
|
129
|
+
*
|
|
130
|
+
* @param adapter - The database adapter
|
|
131
|
+
* @param contentTypeSlug - Slug of the target content type
|
|
132
|
+
* @param input - Item slug and data payload
|
|
133
|
+
* @param options - See {@link CreateCMSContentItemOptions}. Pass
|
|
134
|
+
* `{ syncRelations: true }` to also populate the `contentRelation`
|
|
135
|
+
* junction table for relation fields in the payload.
|
|
136
|
+
*/
|
|
137
|
+
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Route keys for the CMS plugin — matches the keys returned by
|
|
141
|
+
* `stackClient.router.getRoute(path).routeKey`.
|
|
142
|
+
*/
|
|
143
|
+
type CMSRouteKey = "dashboard" | "contentList" | "newContent" | "editContent";
|
|
144
|
+
interface CMSPrefetchForRoute {
|
|
145
|
+
(key: "dashboard" | "newContent", qc: QueryClient): Promise<void>;
|
|
146
|
+
(key: "contentList", qc: QueryClient, params: {
|
|
147
|
+
typeSlug: string;
|
|
148
|
+
}): Promise<void>;
|
|
149
|
+
(key: "editContent", qc: QueryClient, params: {
|
|
150
|
+
typeSlug: string;
|
|
151
|
+
id: string;
|
|
152
|
+
}): Promise<void>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* CMS backend plugin
|
|
156
|
+
* Provides API endpoints for managing content types and content items
|
|
157
|
+
*
|
|
158
|
+
* @param config - Configuration with content types and optional hooks
|
|
159
|
+
*/
|
|
160
|
+
declare const cmsBackendPlugin: (config: CMSBackendConfig) => _btst_stack_plugins_api.BackendPlugin<{
|
|
161
|
+
listContentTypes: better_call.StrictEndpoint<"/content-types", {} & {
|
|
162
|
+
method: "GET";
|
|
163
|
+
}, {
|
|
164
|
+
itemCount: number;
|
|
165
|
+
createdAt: string;
|
|
166
|
+
updatedAt: string;
|
|
167
|
+
name: string;
|
|
168
|
+
id: string;
|
|
169
|
+
slug: string;
|
|
170
|
+
description?: string | undefined;
|
|
171
|
+
jsonSchema: string;
|
|
172
|
+
fieldConfig?: string | undefined;
|
|
173
|
+
autoFormVersion?: number | undefined;
|
|
174
|
+
}[]>;
|
|
175
|
+
getContentTypeBySlug: better_call.StrictEndpoint<"/content-types/:slug", {
|
|
176
|
+
params: z.ZodObject<{
|
|
177
|
+
slug: z.ZodString;
|
|
178
|
+
}, z.core.$strip>;
|
|
179
|
+
} & {
|
|
180
|
+
method: "GET";
|
|
181
|
+
}, SerializedContentType>;
|
|
182
|
+
listContentItems: better_call.StrictEndpoint<"/content/:typeSlug", {
|
|
183
|
+
params: z.ZodObject<{
|
|
184
|
+
typeSlug: z.ZodString;
|
|
185
|
+
}, z.core.$strip>;
|
|
186
|
+
} & {
|
|
187
|
+
method: "GET";
|
|
188
|
+
} & {
|
|
189
|
+
query: better_call.StandardSchemaV1<{
|
|
190
|
+
slug?: string | undefined;
|
|
191
|
+
limit?: unknown;
|
|
192
|
+
offset?: unknown;
|
|
193
|
+
}, {
|
|
194
|
+
slug?: string | undefined;
|
|
195
|
+
limit?: unknown;
|
|
196
|
+
offset?: unknown;
|
|
197
|
+
}>;
|
|
198
|
+
}, {
|
|
199
|
+
items: SerializedContentItemWithType[];
|
|
200
|
+
total: number;
|
|
201
|
+
limit?: number;
|
|
202
|
+
offset?: number;
|
|
203
|
+
}>;
|
|
204
|
+
getContentItem: better_call.StrictEndpoint<"/content/:typeSlug/:id", {
|
|
205
|
+
params: z.ZodObject<{
|
|
206
|
+
typeSlug: z.ZodString;
|
|
207
|
+
id: z.ZodString;
|
|
208
|
+
}, z.core.$strip>;
|
|
209
|
+
} & {
|
|
210
|
+
method: "GET";
|
|
211
|
+
}, SerializedContentItemWithType<Record<string, unknown>>>;
|
|
212
|
+
createContentItem: better_call.StrictEndpoint<"/content/:typeSlug", {
|
|
213
|
+
params: z.ZodObject<{
|
|
214
|
+
typeSlug: z.ZodString;
|
|
215
|
+
}, z.core.$strip>;
|
|
216
|
+
} & {
|
|
217
|
+
method: "POST";
|
|
218
|
+
body: better_call.StandardSchemaV1<{
|
|
219
|
+
slug: string;
|
|
220
|
+
data: {
|
|
221
|
+
[x: string]: unknown;
|
|
222
|
+
};
|
|
223
|
+
}, {
|
|
224
|
+
slug: string;
|
|
225
|
+
data: {
|
|
226
|
+
[x: string]: unknown;
|
|
227
|
+
};
|
|
228
|
+
}>;
|
|
229
|
+
}, {
|
|
230
|
+
parsedData: Record<string, unknown>;
|
|
231
|
+
createdAt: string;
|
|
232
|
+
updatedAt: string;
|
|
233
|
+
id: string;
|
|
234
|
+
slug: string;
|
|
235
|
+
contentTypeId: string;
|
|
236
|
+
data: string;
|
|
237
|
+
authorId?: string | undefined;
|
|
238
|
+
}>;
|
|
239
|
+
updateContentItem: better_call.StrictEndpoint<"/content/:typeSlug/:id", {
|
|
240
|
+
params: z.ZodObject<{
|
|
241
|
+
typeSlug: z.ZodString;
|
|
242
|
+
id: z.ZodString;
|
|
243
|
+
}, z.core.$strip>;
|
|
244
|
+
} & {
|
|
245
|
+
method: "PUT";
|
|
246
|
+
body: better_call.StandardSchemaV1<{
|
|
247
|
+
slug?: string | undefined;
|
|
248
|
+
data?: {
|
|
249
|
+
[x: string]: unknown;
|
|
250
|
+
} | undefined;
|
|
251
|
+
}, {
|
|
252
|
+
slug?: string | undefined;
|
|
253
|
+
data?: {
|
|
254
|
+
[x: string]: unknown;
|
|
255
|
+
} | undefined;
|
|
256
|
+
}>;
|
|
257
|
+
}, SerializedContentItemWithType<Record<string, unknown>>>;
|
|
258
|
+
deleteContentItem: better_call.StrictEndpoint<"/content/:typeSlug/:id", {
|
|
259
|
+
params: z.ZodObject<{
|
|
260
|
+
typeSlug: z.ZodString;
|
|
261
|
+
id: z.ZodString;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
} & {
|
|
264
|
+
method: "DELETE";
|
|
265
|
+
body: better_call.StandardSchemaV1<unknown, unknown>;
|
|
266
|
+
}, {
|
|
267
|
+
success: boolean;
|
|
268
|
+
}>;
|
|
269
|
+
getContentItemPopulated: better_call.StrictEndpoint<"/content/:typeSlug/:id/populated", {
|
|
270
|
+
params: z.ZodObject<{
|
|
271
|
+
typeSlug: z.ZodString;
|
|
272
|
+
id: z.ZodString;
|
|
273
|
+
}, z.core.$strip>;
|
|
274
|
+
} & {
|
|
275
|
+
method: "GET";
|
|
276
|
+
}, {
|
|
277
|
+
_relations: Record<string, SerializedContentItemWithType<Record<string, unknown>>[]>;
|
|
278
|
+
parsedData: Record<string, unknown>;
|
|
279
|
+
contentType?: SerializedContentType;
|
|
280
|
+
createdAt: string;
|
|
281
|
+
updatedAt: string;
|
|
282
|
+
id: string;
|
|
283
|
+
slug: string;
|
|
284
|
+
contentTypeId: string;
|
|
285
|
+
data: string;
|
|
286
|
+
authorId?: string | undefined;
|
|
287
|
+
}>;
|
|
288
|
+
listContentByRelation: better_call.StrictEndpoint<"/content/:typeSlug/by-relation", {
|
|
289
|
+
params: z.ZodObject<{
|
|
290
|
+
typeSlug: z.ZodString;
|
|
291
|
+
}, z.core.$strip>;
|
|
292
|
+
} & {
|
|
293
|
+
method: "GET";
|
|
294
|
+
} & {
|
|
295
|
+
query: better_call.StandardSchemaV1<{
|
|
296
|
+
field: string;
|
|
297
|
+
targetId: string;
|
|
298
|
+
limit?: unknown;
|
|
299
|
+
offset?: unknown;
|
|
300
|
+
}, {
|
|
301
|
+
field: string;
|
|
302
|
+
targetId: string;
|
|
303
|
+
limit?: unknown;
|
|
304
|
+
offset?: unknown;
|
|
305
|
+
}>;
|
|
306
|
+
}, {
|
|
307
|
+
items: SerializedContentItemWithType<Record<string, unknown>>[];
|
|
308
|
+
total: number;
|
|
309
|
+
limit: number;
|
|
310
|
+
offset: number;
|
|
311
|
+
}>;
|
|
312
|
+
getInverseRelations: better_call.StrictEndpoint<"/content-types/:slug/inverse-relations", {
|
|
313
|
+
params: z.ZodObject<{
|
|
314
|
+
slug: z.ZodString;
|
|
315
|
+
}, z.core.$strip>;
|
|
316
|
+
} & {
|
|
317
|
+
method: "GET";
|
|
318
|
+
} & {
|
|
319
|
+
query: better_call.StandardSchemaV1<{
|
|
320
|
+
itemId?: string | undefined;
|
|
321
|
+
}, {
|
|
322
|
+
itemId?: string | undefined;
|
|
323
|
+
}>;
|
|
324
|
+
}, {
|
|
325
|
+
inverseRelations: InverseRelation[];
|
|
326
|
+
}>;
|
|
327
|
+
listInverseRelationItems: better_call.StrictEndpoint<"/content-types/:slug/inverse-relations/:sourceType", {
|
|
328
|
+
params: z.ZodObject<{
|
|
329
|
+
slug: z.ZodString;
|
|
330
|
+
sourceType: z.ZodString;
|
|
331
|
+
}, z.core.$strip>;
|
|
332
|
+
} & {
|
|
333
|
+
method: "GET";
|
|
334
|
+
} & {
|
|
335
|
+
query: better_call.StandardSchemaV1<{
|
|
336
|
+
itemId: string;
|
|
337
|
+
fieldName: string;
|
|
338
|
+
limit?: unknown;
|
|
339
|
+
offset?: unknown;
|
|
340
|
+
}, {
|
|
341
|
+
itemId: string;
|
|
342
|
+
fieldName: string;
|
|
343
|
+
limit?: unknown;
|
|
344
|
+
offset?: unknown;
|
|
345
|
+
}>;
|
|
346
|
+
}, {
|
|
347
|
+
items: SerializedContentItemWithType<Record<string, unknown>>[];
|
|
348
|
+
total: number;
|
|
349
|
+
limit: number;
|
|
350
|
+
offset: number;
|
|
351
|
+
}>;
|
|
352
|
+
}, {
|
|
353
|
+
getAllContentTypes: () => Promise<SerializedContentType[]>;
|
|
354
|
+
getAllContentItems: (contentTypeSlug: string, params?: Parameters<typeof getAllContentItems>[2]) => Promise<{
|
|
355
|
+
items: SerializedContentItemWithType[];
|
|
356
|
+
total: number;
|
|
357
|
+
limit?: number;
|
|
358
|
+
offset?: number;
|
|
359
|
+
}>;
|
|
360
|
+
getContentItemBySlug: (contentTypeSlug: string, slug: string) => Promise<SerializedContentItemWithType<Record<string, unknown>> | null>;
|
|
361
|
+
getContentItemById: (id: string) => Promise<SerializedContentItemWithType<Record<string, unknown>> | null>;
|
|
362
|
+
prefetchForRoute: CMSPrefetchForRoute;
|
|
363
|
+
createContentItem: (typeSlug: string, input: Parameters<typeof createCMSContentItem>[2], options?: Parameters<typeof createCMSContentItem>[3]) => Promise<SerializedContentItem>;
|
|
364
|
+
}>;
|
|
365
|
+
type CMSApiRouter = ReturnType<ReturnType<typeof cmsBackendPlugin>["routes"]>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Internal query key constants for the CMS plugin.
|
|
369
|
+
* Shared between query-keys.ts (HTTP path) and prefetchForRoute (DB path)
|
|
370
|
+
* to prevent key drift between SSR loaders and SSG prefetching.
|
|
371
|
+
*/
|
|
372
|
+
interface ContentListDiscriminator {
|
|
373
|
+
typeSlug: string;
|
|
374
|
+
limit: number;
|
|
375
|
+
offset: number;
|
|
376
|
+
}
|
|
377
|
+
/** Full query key builders — use these with queryClient.setQueryData() */
|
|
378
|
+
declare const CMS_QUERY_KEYS: {
|
|
379
|
+
/**
|
|
380
|
+
* Key for the cmsTypes.list() query.
|
|
381
|
+
* Full key: ["cmsTypes", "list", "list"]
|
|
382
|
+
*/
|
|
383
|
+
typesList: () => readonly ["cmsTypes", "list", "list"];
|
|
384
|
+
/**
|
|
385
|
+
* Key for the cmsContent.list({ typeSlug, limit, offset }) query.
|
|
386
|
+
* Full key: ["cmsContent", "list", { typeSlug, limit, offset }]
|
|
387
|
+
*/
|
|
388
|
+
contentList: (params: {
|
|
389
|
+
typeSlug: string;
|
|
390
|
+
limit?: number;
|
|
391
|
+
offset?: number;
|
|
392
|
+
}) => readonly ["cmsContent", "list", ContentListDiscriminator];
|
|
393
|
+
/**
|
|
394
|
+
* Key for the cmsContent.detail(typeSlug, id) query.
|
|
395
|
+
* Full key: ["cmsContent", "detail", typeSlug, id]
|
|
396
|
+
*/
|
|
397
|
+
contentDetail: (typeSlug: string, id: string) => readonly ["cmsContent", "detail", string, string];
|
|
398
|
+
};
|
|
9
399
|
|
|
10
400
|
interface ContentListParams {
|
|
11
401
|
limit?: number;
|
|
@@ -70,4 +460,5 @@ declare function createCMSQueryKeys(client: ReturnType<typeof createApiClient<CM
|
|
|
70
460
|
};
|
|
71
461
|
};
|
|
72
462
|
|
|
73
|
-
export { createCMSQueryKeys };
|
|
463
|
+
export { getAllContentItems as b, cmsBackendPlugin as c, createCMSQueryKeys, getContentItemBySlug as d, getContentItemById as e, serializeContentItem as f, getAllContentTypes as g, serializeContentItemWithType as h, createCMSContentItem as i, CMS_QUERY_KEYS as l, serializeContentType as s };
|
|
464
|
+
export type { CMSApiRouter as C, CMSRouteKey as a, CreateCMSContentItemInput as j, CreateCMSContentItemOptions as k };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as CommentListParamsSchema, b as CommentCountQuerySchema } from '../../../shared/stack.
|
|
2
|
-
export { d as CommentsApiContext, C as CommentsApiRouter, e as CommentsBackendOptions, c as commentsBackendPlugin } from '../../../shared/stack.
|
|
1
|
+
import { a as CommentListParamsSchema, b as CommentCountQuerySchema } from '../../../shared/stack.CCncwK6g.cjs';
|
|
2
|
+
export { d as CommentsApiContext, C as CommentsApiRouter, e as CommentsBackendOptions, c as commentsBackendPlugin } from '../../../shared/stack.CCncwK6g.cjs';
|
|
3
3
|
import { DBAdapter } from '@btst/db';
|
|
4
|
-
import { C as CommentListResult, S as SerializedComment, d as Comment } from '../../../shared/stack.
|
|
5
|
-
export { e as COMMENTS_QUERY_KEYS } from '../../../shared/stack.
|
|
4
|
+
import { C as CommentListResult, S as SerializedComment, d as Comment } from '../../../shared/stack.C7KNNiJm.cjs';
|
|
5
|
+
export { e as COMMENTS_QUERY_KEYS } from '../../../shared/stack.C7KNNiJm.cjs';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import '@btst/stack/plugins/api';
|
|
8
8
|
import 'better-call';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as CommentListParamsSchema, b as CommentCountQuerySchema } from '../../../shared/stack.
|
|
2
|
-
export { d as CommentsApiContext, C as CommentsApiRouter, e as CommentsBackendOptions, c as commentsBackendPlugin } from '../../../shared/stack.
|
|
1
|
+
import { a as CommentListParamsSchema, b as CommentCountQuerySchema } from '../../../shared/stack.CO1g47IS.mjs';
|
|
2
|
+
export { d as CommentsApiContext, C as CommentsApiRouter, e as CommentsBackendOptions, c as commentsBackendPlugin } from '../../../shared/stack.CO1g47IS.mjs';
|
|
3
3
|
import { DBAdapter } from '@btst/db';
|
|
4
|
-
import { C as CommentListResult, S as SerializedComment, d as Comment } from '../../../shared/stack.
|
|
5
|
-
export { e as COMMENTS_QUERY_KEYS } from '../../../shared/stack.
|
|
4
|
+
import { C as CommentListResult, S as SerializedComment, d as Comment } from '../../../shared/stack.C7KNNiJm.mjs';
|
|
5
|
+
export { e as COMMENTS_QUERY_KEYS } from '../../../shared/stack.C7KNNiJm.mjs';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import '@btst/stack/plugins/api';
|
|
8
8
|
import 'better-call';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as CommentListParamsSchema, b as CommentCountQuerySchema } from '../../../shared/stack.
|
|
2
|
-
export { d as CommentsApiContext, C as CommentsApiRouter, e as CommentsBackendOptions, c as commentsBackendPlugin } from '../../../shared/stack.
|
|
1
|
+
import { a as CommentListParamsSchema, b as CommentCountQuerySchema } from '../../../shared/stack.Bq3kiUaM.js';
|
|
2
|
+
export { d as CommentsApiContext, C as CommentsApiRouter, e as CommentsBackendOptions, c as commentsBackendPlugin } from '../../../shared/stack.Bq3kiUaM.js';
|
|
3
3
|
import { DBAdapter } from '@btst/db';
|
|
4
|
-
import { C as CommentListResult, S as SerializedComment, d as Comment } from '../../../shared/stack.
|
|
5
|
-
export { e as COMMENTS_QUERY_KEYS } from '../../../shared/stack.
|
|
4
|
+
import { C as CommentListResult, S as SerializedComment, d as Comment } from '../../../shared/stack.C7KNNiJm.js';
|
|
5
|
+
export { e as COMMENTS_QUERY_KEYS } from '../../../shared/stack.C7KNNiJm.js';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import '@btst/stack/plugins/api';
|
|
8
8
|
import 'better-call';
|
|
@@ -59,6 +59,17 @@ interface CommentThreadProps {
|
|
|
59
59
|
* Defaults to true.
|
|
60
60
|
*/
|
|
61
61
|
allowEditing?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Sort direction for top-level comments by `createdAt`.
|
|
64
|
+
* - `"desc"` (default): newest first.
|
|
65
|
+
* - `"asc"`: oldest first.
|
|
66
|
+
*
|
|
67
|
+
* Replies inside each thread always render chronologically (oldest → newest)
|
|
68
|
+
* and are unaffected by this prop.
|
|
69
|
+
*
|
|
70
|
+
* Overrides the global `defaultCommentSort` from `CommentsPluginOverrides`.
|
|
71
|
+
*/
|
|
72
|
+
sort?: "asc" | "desc";
|
|
62
73
|
}
|
|
63
74
|
declare function CommentThread(props: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
64
75
|
|
|
@@ -59,6 +59,17 @@ interface CommentThreadProps {
|
|
|
59
59
|
* Defaults to true.
|
|
60
60
|
*/
|
|
61
61
|
allowEditing?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Sort direction for top-level comments by `createdAt`.
|
|
64
|
+
* - `"desc"` (default): newest first.
|
|
65
|
+
* - `"asc"`: oldest first.
|
|
66
|
+
*
|
|
67
|
+
* Replies inside each thread always render chronologically (oldest → newest)
|
|
68
|
+
* and are unaffected by this prop.
|
|
69
|
+
*
|
|
70
|
+
* Overrides the global `defaultCommentSort` from `CommentsPluginOverrides`.
|
|
71
|
+
*/
|
|
72
|
+
sort?: "asc" | "desc";
|
|
62
73
|
}
|
|
63
74
|
declare function CommentThread(props: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
64
75
|
|
|
@@ -59,6 +59,17 @@ interface CommentThreadProps {
|
|
|
59
59
|
* Defaults to true.
|
|
60
60
|
*/
|
|
61
61
|
allowEditing?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Sort direction for top-level comments by `createdAt`.
|
|
64
|
+
* - `"desc"` (default): newest first.
|
|
65
|
+
* - `"asc"`: oldest first.
|
|
66
|
+
*
|
|
67
|
+
* Replies inside each thread always render chronologically (oldest → newest)
|
|
68
|
+
* and are unaffected by this prop.
|
|
69
|
+
*
|
|
70
|
+
* Overrides the global `defaultCommentSort` from `CommentsPluginOverrides`.
|
|
71
|
+
*/
|
|
72
|
+
sort?: "asc" | "desc";
|
|
62
73
|
}
|
|
63
74
|
declare function CommentThread(props: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
64
75
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.
|
|
1
|
+
import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.C7KNNiJm.cjs';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { InfiniteData } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -81,6 +81,11 @@ declare function useInfiniteComments(config: CommentsClientConfig, params: {
|
|
|
81
81
|
parentId?: string | null;
|
|
82
82
|
status?: "pending" | "approved" | "spam";
|
|
83
83
|
currentUserId?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Sort direction by `createdAt`. Default: `"asc"` (oldest first) — matches
|
|
86
|
+
* the server-side default. Pass `"desc"` for newest-first threads.
|
|
87
|
+
*/
|
|
88
|
+
sort?: "asc" | "desc";
|
|
84
89
|
pageSize?: number;
|
|
85
90
|
}, options?: {
|
|
86
91
|
enabled?: boolean;
|
|
@@ -129,6 +134,17 @@ declare function usePostComment(config: CommentsClientConfig, params: {
|
|
|
129
134
|
* `nextOffset` from `lastPage.limit` instead of a hardcoded fallback.
|
|
130
135
|
*/
|
|
131
136
|
pageSize?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Sort direction of the surrounding infinite thread.
|
|
139
|
+
* - `"asc"` (default): newest comments belong on the LAST page → optimistic
|
|
140
|
+
* item is appended to `pages[last].items`.
|
|
141
|
+
* - `"desc"`: newest comments belong on the FIRST page → optimistic item
|
|
142
|
+
* is prepended to `pages[0].items`.
|
|
143
|
+
*
|
|
144
|
+
* Must match the `sort` passed to `useInfiniteComments` so the optimistic
|
|
145
|
+
* item appears in the same position the server will place it.
|
|
146
|
+
*/
|
|
147
|
+
sort?: "asc" | "desc";
|
|
132
148
|
}): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
|
|
133
149
|
body: string;
|
|
134
150
|
parentId?: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.
|
|
1
|
+
import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.C7KNNiJm.mjs';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { InfiniteData } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -81,6 +81,11 @@ declare function useInfiniteComments(config: CommentsClientConfig, params: {
|
|
|
81
81
|
parentId?: string | null;
|
|
82
82
|
status?: "pending" | "approved" | "spam";
|
|
83
83
|
currentUserId?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Sort direction by `createdAt`. Default: `"asc"` (oldest first) — matches
|
|
86
|
+
* the server-side default. Pass `"desc"` for newest-first threads.
|
|
87
|
+
*/
|
|
88
|
+
sort?: "asc" | "desc";
|
|
84
89
|
pageSize?: number;
|
|
85
90
|
}, options?: {
|
|
86
91
|
enabled?: boolean;
|
|
@@ -129,6 +134,17 @@ declare function usePostComment(config: CommentsClientConfig, params: {
|
|
|
129
134
|
* `nextOffset` from `lastPage.limit` instead of a hardcoded fallback.
|
|
130
135
|
*/
|
|
131
136
|
pageSize?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Sort direction of the surrounding infinite thread.
|
|
139
|
+
* - `"asc"` (default): newest comments belong on the LAST page → optimistic
|
|
140
|
+
* item is appended to `pages[last].items`.
|
|
141
|
+
* - `"desc"`: newest comments belong on the FIRST page → optimistic item
|
|
142
|
+
* is prepended to `pages[0].items`.
|
|
143
|
+
*
|
|
144
|
+
* Must match the `sort` passed to `useInfiniteComments` so the optimistic
|
|
145
|
+
* item appears in the same position the server will place it.
|
|
146
|
+
*/
|
|
147
|
+
sort?: "asc" | "desc";
|
|
132
148
|
}): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
|
|
133
149
|
body: string;
|
|
134
150
|
parentId?: string | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.
|
|
1
|
+
import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.C7KNNiJm.js';
|
|
2
2
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
3
3
|
import { InfiniteData } from '@tanstack/react-query';
|
|
4
4
|
|
|
@@ -81,6 +81,11 @@ declare function useInfiniteComments(config: CommentsClientConfig, params: {
|
|
|
81
81
|
parentId?: string | null;
|
|
82
82
|
status?: "pending" | "approved" | "spam";
|
|
83
83
|
currentUserId?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Sort direction by `createdAt`. Default: `"asc"` (oldest first) — matches
|
|
86
|
+
* the server-side default. Pass `"desc"` for newest-first threads.
|
|
87
|
+
*/
|
|
88
|
+
sort?: "asc" | "desc";
|
|
84
89
|
pageSize?: number;
|
|
85
90
|
}, options?: {
|
|
86
91
|
enabled?: boolean;
|
|
@@ -129,6 +134,17 @@ declare function usePostComment(config: CommentsClientConfig, params: {
|
|
|
129
134
|
* `nextOffset` from `lastPage.limit` instead of a hardcoded fallback.
|
|
130
135
|
*/
|
|
131
136
|
pageSize?: number;
|
|
137
|
+
/**
|
|
138
|
+
* Sort direction of the surrounding infinite thread.
|
|
139
|
+
* - `"asc"` (default): newest comments belong on the LAST page → optimistic
|
|
140
|
+
* item is appended to `pages[last].items`.
|
|
141
|
+
* - `"desc"`: newest comments belong on the FIRST page → optimistic item
|
|
142
|
+
* is prepended to `pages[0].items`.
|
|
143
|
+
*
|
|
144
|
+
* Must match the `sort` passed to `useInfiniteComments` so the optimistic
|
|
145
|
+
* item appears in the same position the server will place it.
|
|
146
|
+
*/
|
|
147
|
+
sort?: "asc" | "desc";
|
|
132
148
|
}): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
|
|
133
149
|
body: string;
|
|
134
150
|
parentId?: string | null;
|
|
@@ -197,6 +197,15 @@ interface CommentsPluginOverrides {
|
|
|
197
197
|
* Defaults to 100 when not set.
|
|
198
198
|
*/
|
|
199
199
|
defaultCommentPageSize?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Default sort direction (by `createdAt`) for top-level comments in
|
|
202
|
+
* `CommentThread`.
|
|
203
|
+
* - `"desc"` (default): newest comments first.
|
|
204
|
+
* - `"asc"`: oldest comments first.
|
|
205
|
+
*
|
|
206
|
+
* Can be overridden per-instance via the `sort` prop on `CommentThread`.
|
|
207
|
+
*/
|
|
208
|
+
defaultCommentSort?: "asc" | "desc";
|
|
200
209
|
/**
|
|
201
210
|
* When false, the comment form and reply buttons are hidden in all
|
|
202
211
|
* `CommentThread` instances. Users can still read existing comments.
|
|
@@ -197,6 +197,15 @@ interface CommentsPluginOverrides {
|
|
|
197
197
|
* Defaults to 100 when not set.
|
|
198
198
|
*/
|
|
199
199
|
defaultCommentPageSize?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Default sort direction (by `createdAt`) for top-level comments in
|
|
202
|
+
* `CommentThread`.
|
|
203
|
+
* - `"desc"` (default): newest comments first.
|
|
204
|
+
* - `"asc"`: oldest comments first.
|
|
205
|
+
*
|
|
206
|
+
* Can be overridden per-instance via the `sort` prop on `CommentThread`.
|
|
207
|
+
*/
|
|
208
|
+
defaultCommentSort?: "asc" | "desc";
|
|
200
209
|
/**
|
|
201
210
|
* When false, the comment form and reply buttons are hidden in all
|
|
202
211
|
* `CommentThread` instances. Users can still read existing comments.
|
|
@@ -197,6 +197,15 @@ interface CommentsPluginOverrides {
|
|
|
197
197
|
* Defaults to 100 when not set.
|
|
198
198
|
*/
|
|
199
199
|
defaultCommentPageSize?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Default sort direction (by `createdAt`) for top-level comments in
|
|
202
|
+
* `CommentThread`.
|
|
203
|
+
* - `"desc"` (default): newest comments first.
|
|
204
|
+
* - `"asc"`: oldest comments first.
|
|
205
|
+
*
|
|
206
|
+
* Can be overridden per-instance via the `sort` prop on `CommentThread`.
|
|
207
|
+
*/
|
|
208
|
+
defaultCommentSort?: "asc" | "desc";
|
|
200
209
|
/**
|
|
201
210
|
* When false, the comment form and reply buttons are hidden in all
|
|
202
211
|
* `CommentThread` instances. Users can still read existing comments.
|