@btst/stack 5.0.0 → 5.1.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.d.cts +2 -2
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- 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/context/index.d.cts +1 -1
- package/dist/context/index.d.mts +1 -1
- package/dist/context/index.d.ts +1 -1
- 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/cms/api/getters.cjs +142 -6
- package/dist/packages/stack/src/plugins/cms/api/getters.mjs +139 -8
- package/dist/packages/stack/src/plugins/cms/api/operations.cjs +67 -61
- package/dist/packages/stack/src/plugins/cms/api/operations.mjs +69 -63
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +26 -8
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +27 -9
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +15 -1
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +14 -2
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.cjs +45 -24
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.mjs +45 -24
- package/dist/packages/stack/src/plugins/cms/schemas.cjs +22 -0
- package/dist/packages/stack/src/plugins/cms/schemas.mjs +20 -1
- package/dist/plugins/api/index.d.cts +2 -2
- package/dist/plugins/api/index.d.mts +2 -2
- package/dist/plugins/api/index.d.ts +2 -2
- package/dist/plugins/blog/api/index.d.cts +2 -2
- package/dist/plugins/blog/api/index.d.mts +2 -2
- package/dist/plugins/blog/api/index.d.ts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +2 -2
- package/dist/plugins/blog/client/index.d.mts +2 -2
- package/dist/plugins/blog/client/index.d.ts +2 -2
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/plugins/client/index.d.cts +2 -2
- package/dist/plugins/client/index.d.mts +2 -2
- package/dist/plugins/client/index.d.ts +2 -2
- package/dist/plugins/cms/api/index.cjs +1 -0
- package/dist/plugins/cms/api/index.d.cts +43 -11
- package/dist/plugins/cms/api/index.d.mts +43 -11
- package/dist/plugins/cms/api/index.d.ts +43 -11
- package/dist/plugins/cms/api/index.mjs +1 -1
- package/dist/plugins/cms/client/hooks/index.d.cts +90 -45
- package/dist/plugins/cms/client/hooks/index.d.mts +90 -45
- package/dist/plugins/cms/client/hooks/index.d.ts +90 -45
- package/dist/plugins/cms/client/index.d.cts +2 -1
- package/dist/plugins/cms/client/index.d.mts +2 -1
- package/dist/plugins/cms/client/index.d.ts +2 -1
- package/dist/plugins/cms/query-keys.cjs +69 -13
- package/dist/plugins/cms/query-keys.d.cts +89 -212
- package/dist/plugins/cms/query-keys.d.mts +89 -212
- package/dist/plugins/cms/query-keys.d.ts +89 -212
- package/dist/plugins/cms/query-keys.mjs +70 -14
- 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/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/client/hooks/index.d.cts +3 -3
- package/dist/plugins/ui-builder/client/hooks/index.d.mts +3 -3
- package/dist/plugins/ui-builder/client/hooks/index.d.ts +3 -3
- package/dist/plugins/ui-builder/client/index.d.cts +3 -3
- package/dist/plugins/ui-builder/client/index.d.mts +3 -3
- package/dist/plugins/ui-builder/client/index.d.ts +3 -3
- package/dist/plugins/ui-builder/query-keys.d.cts +4 -3
- package/dist/plugins/ui-builder/query-keys.d.mts +4 -3
- package/dist/plugins/ui-builder/query-keys.d.ts +4 -3
- package/dist/shared/{stack.DMj68qY0.d.mts → stack.B2jlVVhD.d.mts} +5 -5
- package/dist/shared/{stack.Cvnj99cs.d.ts → stack.BB9tubJJ.d.ts} +9 -3
- package/dist/shared/{stack.Bt3WG2yb.d.cts → stack.BWduIMKG.d.cts} +35 -35
- package/dist/shared/stack.Bw09Lg2z.d.ts +1420 -0
- package/dist/shared/{stack.CkEz7vSt.d.mts → stack.C2Pvl-RS.d.mts} +9 -3
- package/dist/shared/{stack.C2l2wd_X.d.ts → stack.Ch9-ppmQ.d.ts} +35 -35
- package/dist/shared/{stack.Ht8mhDj5.d.cts → stack.D17yFglU.d.cts} +5 -5
- package/dist/shared/{stack.CiD115Ov.d.mts → stack.D6fPBfYe.d.mts} +35 -35
- package/dist/shared/stack.DFGj0gb7.d.mts +1420 -0
- package/dist/shared/{stack.pi0FxoEa.d.ts → stack.Dcfg4GNN.d.ts} +5 -5
- package/dist/shared/{stack.3rxARhgS.d.cts → stack.DrB3L7Ih.d.cts} +52 -3
- package/dist/shared/{stack.3rxARhgS.d.mts → stack.DrB3L7Ih.d.mts} +52 -3
- package/dist/shared/{stack.3rxARhgS.d.ts → stack.DrB3L7Ih.d.ts} +52 -3
- package/dist/shared/stack.NNrBKBkM.d.cts +1420 -0
- package/dist/shared/{stack.mRRyZBUg.d.cts → stack.Rb87lHqK.d.cts} +9 -3
- package/package.json +1 -1
- package/src/__tests__/cms-query-keys.test.ts +57 -0
- package/src/plugins/api/index.ts +1 -0
- package/src/plugins/api/operation.ts +16 -3
- package/src/plugins/cms/__tests__/authorization.test.ts +652 -187
- package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +655 -0
- package/src/plugins/cms/__tests__/content-read.typecheck.ts +351 -0
- package/src/plugins/cms/__tests__/getters.test.ts +286 -0
- package/src/plugins/cms/api/getters.ts +270 -12
- package/src/plugins/cms/api/index.ts +10 -0
- package/src/plugins/cms/api/operations.ts +163 -75
- package/src/plugins/cms/api/plugin.ts +50 -12
- package/src/plugins/cms/api/query-key-defs.ts +29 -2
- package/src/plugins/cms/client/hooks/cms-hooks.tsx +400 -91
- package/src/plugins/cms/client/index.ts +9 -0
- package/src/plugins/cms/query-keys.ts +171 -16
- package/src/plugins/cms/schemas.ts +30 -0
- package/src/plugins/cms/types.ts +49 -2
- package/src/plugins/media/__tests__/identity-partition.test.tsx +26 -16
- package/dist/shared/stack.CAmVUwjV.d.cts +0 -764
- package/dist/shared/stack.CQK02ujt.d.ts +0 -764
- package/dist/shared/stack.D9x1fR5a.d.mts +0 -764
- package/dist/shared/{stack.CKc_Bais.d.cts → stack.Csi-4Mgz.d.cts} +7 -7
- package/dist/shared/{stack.CKc_Bais.d.mts → stack.Csi-4Mgz.d.mts} +7 -7
- package/dist/shared/{stack.CKc_Bais.d.ts → stack.Csi-4Mgz.d.ts} +7 -7
|
@@ -2,7 +2,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ResourceFormConfig, ResourceFormResult } from '@btst/stack/plugins/client/hooks';
|
|
4
4
|
import { S as SerializedPost, a as SerializedTag } from './stack.Dsatjh0B.js';
|
|
5
|
-
import { c as createPostSchema, u as updatePostSchema } from './stack.
|
|
5
|
+
import { c as createPostSchema, u as updatePostSchema } from './stack.Csi-4Mgz.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Options for the usePosts hook
|
|
@@ -136,10 +136,6 @@ declare function useSuspenseTags(): {
|
|
|
136
136
|
declare function usePostForm<TValues>(config: ResourceFormConfig<TValues, SerializedPost | null, SerializedPost | null>): ResourceFormResult<TValues, SerializedPost | null, SerializedPost | null>;
|
|
137
137
|
/** Create a new post */
|
|
138
138
|
declare function useCreatePost(): _tanstack_react_query.UseMutationResult<SerializedPost | null, Error, {
|
|
139
|
-
title: string;
|
|
140
|
-
content: string;
|
|
141
|
-
excerpt: string;
|
|
142
|
-
published: boolean;
|
|
143
139
|
tags: ({
|
|
144
140
|
name: string;
|
|
145
141
|
} | {
|
|
@@ -147,6 +143,10 @@ declare function useCreatePost(): _tanstack_react_query.UseMutationResult<Serial
|
|
|
147
143
|
name: string;
|
|
148
144
|
slug: string;
|
|
149
145
|
})[];
|
|
146
|
+
title: string;
|
|
147
|
+
content: string;
|
|
148
|
+
excerpt: string;
|
|
149
|
+
published: boolean;
|
|
150
150
|
slug?: string | undefined;
|
|
151
151
|
publishedAt?: Date | undefined;
|
|
152
152
|
createdAt?: Date | undefined;
|
|
@@ -106,16 +106,65 @@ interface SerializedContentItemWithType<TData = Record<string, unknown>> extends
|
|
|
106
106
|
*/
|
|
107
107
|
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
108
108
|
}
|
|
109
|
+
/** Output shape for CMS reads; omission retains the full editor envelope. */
|
|
110
|
+
type CMSReadView = "content" | undefined;
|
|
111
|
+
/** Literal top-level property names selected from parsed content. */
|
|
112
|
+
type CMSContentFields = readonly string[] | undefined;
|
|
113
|
+
/** Select known literal properties, or an honest partial shape for dynamic arrays. */
|
|
114
|
+
type CMSSelectedData<TData, TFields extends CMSContentFields = undefined> = TFields extends readonly string[] ? string extends TFields[number] ? Partial<TData> : Pick<TData, Extract<TFields[number], keyof TData>> : TData;
|
|
115
|
+
/** Optional output controls for CMS reads. These do not change access checks. */
|
|
116
|
+
interface CMSReadOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> {
|
|
117
|
+
/** Return identity, parsed content and timestamps without editor metadata. */
|
|
118
|
+
view?: TView;
|
|
119
|
+
/** Literal declared top-level content properties. Requires content view. */
|
|
120
|
+
fields?: TFields;
|
|
121
|
+
}
|
|
122
|
+
/** Serialized content envelope without raw JSON or editor metadata. */
|
|
123
|
+
type SerializedContentItemContent<TData = Record<string, unknown>> = Pick<SerializedContentItemWithType<TData>, "id" | "slug" | "parsedData" | "createdAt" | "updatedAt">;
|
|
124
|
+
/** Result envelope selected by a statically known read view. */
|
|
125
|
+
type CMSContentItemResult<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> = TView extends "content" ? SerializedContentItemContent<CMSSelectedData<TData, TFields>> : SerializedContentItemWithType<TData>;
|
|
109
126
|
/**
|
|
110
127
|
* Paginated list response for content items
|
|
111
128
|
* @template TData - The type of the parsed data (defaults to Record<string, unknown>)
|
|
112
129
|
*/
|
|
113
|
-
interface PaginatedContentItems<TData = Record<string, unknown
|
|
114
|
-
items:
|
|
130
|
+
interface PaginatedContentItems<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
131
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
115
132
|
total: number;
|
|
116
133
|
limit: number;
|
|
117
134
|
offset: number;
|
|
118
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Type helper to define a map of content type slugs to their data types.
|
|
138
|
+
* Use with z.infer to get the type from your Zod schemas.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* import { z } from "zod"
|
|
143
|
+
*
|
|
144
|
+
* // Define your schemas
|
|
145
|
+
* export const ProductSchema = z.object({
|
|
146
|
+
* name: z.string(),
|
|
147
|
+
* price: z.number(),
|
|
148
|
+
* })
|
|
149
|
+
*
|
|
150
|
+
* export const TestimonialSchema = z.object({
|
|
151
|
+
* author: z.string(),
|
|
152
|
+
* quote: z.string(),
|
|
153
|
+
* })
|
|
154
|
+
*
|
|
155
|
+
* // Create the type map
|
|
156
|
+
* export type MyCMSTypes = {
|
|
157
|
+
* product: z.infer<typeof ProductSchema>
|
|
158
|
+
* testimonial: z.infer<typeof TestimonialSchema>
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* // Use in hooks for type-safe parsedData
|
|
162
|
+
* const { items } = useContent<MyCMSTypes, "product">("product")
|
|
163
|
+
* // items[0].parsedData.name is typed as string
|
|
164
|
+
* // items[0].parsedData.price is typed as number
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
type CMSContentTypeMap = Record<string, Record<string, unknown>>;
|
|
119
168
|
/** JSON-safe values accepted at the CMS operation boundary. */
|
|
120
169
|
type CMSOperationData = string | number | boolean | null | readonly CMSOperationData[] | {
|
|
121
170
|
readonly [key: string]: CMSOperationData;
|
|
@@ -278,4 +327,4 @@ interface CMSBackendConfig {
|
|
|
278
327
|
maxPageSize?: number;
|
|
279
328
|
}
|
|
280
329
|
|
|
281
|
-
export type {
|
|
330
|
+
export type { CMSReadOptions as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, CMSReadView as a, SerializedContentItemWithType as b, CMSContentFields as c, CMSContentItemResult as d, CMSContentTypeMap as e, CMSBackendConfig as f, CMSSelectedData as g, ContentItem as h, SerializedContentItem as i, ContentItemWithType as j, ContentType as k, CMSBackendHooks as l, CMSCreateOperationContext as m, CMSCreateResultContext as n, CMSDeleteOperationContext as o, CMSDeleteResultContext as p, CMSOperationErrorContext as q, CMSOperationLifecycleContext as r, CMSUpdateOperationContext as s, CMSUpdateResultContext as t, ContentTypeConfig as u, SerializedContentItemContent as v };
|
|
@@ -106,16 +106,65 @@ interface SerializedContentItemWithType<TData = Record<string, unknown>> extends
|
|
|
106
106
|
*/
|
|
107
107
|
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
108
108
|
}
|
|
109
|
+
/** Output shape for CMS reads; omission retains the full editor envelope. */
|
|
110
|
+
type CMSReadView = "content" | undefined;
|
|
111
|
+
/** Literal top-level property names selected from parsed content. */
|
|
112
|
+
type CMSContentFields = readonly string[] | undefined;
|
|
113
|
+
/** Select known literal properties, or an honest partial shape for dynamic arrays. */
|
|
114
|
+
type CMSSelectedData<TData, TFields extends CMSContentFields = undefined> = TFields extends readonly string[] ? string extends TFields[number] ? Partial<TData> : Pick<TData, Extract<TFields[number], keyof TData>> : TData;
|
|
115
|
+
/** Optional output controls for CMS reads. These do not change access checks. */
|
|
116
|
+
interface CMSReadOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> {
|
|
117
|
+
/** Return identity, parsed content and timestamps without editor metadata. */
|
|
118
|
+
view?: TView;
|
|
119
|
+
/** Literal declared top-level content properties. Requires content view. */
|
|
120
|
+
fields?: TFields;
|
|
121
|
+
}
|
|
122
|
+
/** Serialized content envelope without raw JSON or editor metadata. */
|
|
123
|
+
type SerializedContentItemContent<TData = Record<string, unknown>> = Pick<SerializedContentItemWithType<TData>, "id" | "slug" | "parsedData" | "createdAt" | "updatedAt">;
|
|
124
|
+
/** Result envelope selected by a statically known read view. */
|
|
125
|
+
type CMSContentItemResult<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> = TView extends "content" ? SerializedContentItemContent<CMSSelectedData<TData, TFields>> : SerializedContentItemWithType<TData>;
|
|
109
126
|
/**
|
|
110
127
|
* Paginated list response for content items
|
|
111
128
|
* @template TData - The type of the parsed data (defaults to Record<string, unknown>)
|
|
112
129
|
*/
|
|
113
|
-
interface PaginatedContentItems<TData = Record<string, unknown
|
|
114
|
-
items:
|
|
130
|
+
interface PaginatedContentItems<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
131
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
115
132
|
total: number;
|
|
116
133
|
limit: number;
|
|
117
134
|
offset: number;
|
|
118
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Type helper to define a map of content type slugs to their data types.
|
|
138
|
+
* Use with z.infer to get the type from your Zod schemas.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* import { z } from "zod"
|
|
143
|
+
*
|
|
144
|
+
* // Define your schemas
|
|
145
|
+
* export const ProductSchema = z.object({
|
|
146
|
+
* name: z.string(),
|
|
147
|
+
* price: z.number(),
|
|
148
|
+
* })
|
|
149
|
+
*
|
|
150
|
+
* export const TestimonialSchema = z.object({
|
|
151
|
+
* author: z.string(),
|
|
152
|
+
* quote: z.string(),
|
|
153
|
+
* })
|
|
154
|
+
*
|
|
155
|
+
* // Create the type map
|
|
156
|
+
* export type MyCMSTypes = {
|
|
157
|
+
* product: z.infer<typeof ProductSchema>
|
|
158
|
+
* testimonial: z.infer<typeof TestimonialSchema>
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* // Use in hooks for type-safe parsedData
|
|
162
|
+
* const { items } = useContent<MyCMSTypes, "product">("product")
|
|
163
|
+
* // items[0].parsedData.name is typed as string
|
|
164
|
+
* // items[0].parsedData.price is typed as number
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
type CMSContentTypeMap = Record<string, Record<string, unknown>>;
|
|
119
168
|
/** JSON-safe values accepted at the CMS operation boundary. */
|
|
120
169
|
type CMSOperationData = string | number | boolean | null | readonly CMSOperationData[] | {
|
|
121
170
|
readonly [key: string]: CMSOperationData;
|
|
@@ -278,4 +327,4 @@ interface CMSBackendConfig {
|
|
|
278
327
|
maxPageSize?: number;
|
|
279
328
|
}
|
|
280
329
|
|
|
281
|
-
export type {
|
|
330
|
+
export type { CMSReadOptions as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, CMSReadView as a, SerializedContentItemWithType as b, CMSContentFields as c, CMSContentItemResult as d, CMSContentTypeMap as e, CMSBackendConfig as f, CMSSelectedData as g, ContentItem as h, SerializedContentItem as i, ContentItemWithType as j, ContentType as k, CMSBackendHooks as l, CMSCreateOperationContext as m, CMSCreateResultContext as n, CMSDeleteOperationContext as o, CMSDeleteResultContext as p, CMSOperationErrorContext as q, CMSOperationLifecycleContext as r, CMSUpdateOperationContext as s, CMSUpdateResultContext as t, ContentTypeConfig as u, SerializedContentItemContent as v };
|
|
@@ -106,16 +106,65 @@ interface SerializedContentItemWithType<TData = Record<string, unknown>> extends
|
|
|
106
106
|
*/
|
|
107
107
|
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
108
108
|
}
|
|
109
|
+
/** Output shape for CMS reads; omission retains the full editor envelope. */
|
|
110
|
+
type CMSReadView = "content" | undefined;
|
|
111
|
+
/** Literal top-level property names selected from parsed content. */
|
|
112
|
+
type CMSContentFields = readonly string[] | undefined;
|
|
113
|
+
/** Select known literal properties, or an honest partial shape for dynamic arrays. */
|
|
114
|
+
type CMSSelectedData<TData, TFields extends CMSContentFields = undefined> = TFields extends readonly string[] ? string extends TFields[number] ? Partial<TData> : Pick<TData, Extract<TFields[number], keyof TData>> : TData;
|
|
115
|
+
/** Optional output controls for CMS reads. These do not change access checks. */
|
|
116
|
+
interface CMSReadOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> {
|
|
117
|
+
/** Return identity, parsed content and timestamps without editor metadata. */
|
|
118
|
+
view?: TView;
|
|
119
|
+
/** Literal declared top-level content properties. Requires content view. */
|
|
120
|
+
fields?: TFields;
|
|
121
|
+
}
|
|
122
|
+
/** Serialized content envelope without raw JSON or editor metadata. */
|
|
123
|
+
type SerializedContentItemContent<TData = Record<string, unknown>> = Pick<SerializedContentItemWithType<TData>, "id" | "slug" | "parsedData" | "createdAt" | "updatedAt">;
|
|
124
|
+
/** Result envelope selected by a statically known read view. */
|
|
125
|
+
type CMSContentItemResult<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> = TView extends "content" ? SerializedContentItemContent<CMSSelectedData<TData, TFields>> : SerializedContentItemWithType<TData>;
|
|
109
126
|
/**
|
|
110
127
|
* Paginated list response for content items
|
|
111
128
|
* @template TData - The type of the parsed data (defaults to Record<string, unknown>)
|
|
112
129
|
*/
|
|
113
|
-
interface PaginatedContentItems<TData = Record<string, unknown
|
|
114
|
-
items:
|
|
130
|
+
interface PaginatedContentItems<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
131
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
115
132
|
total: number;
|
|
116
133
|
limit: number;
|
|
117
134
|
offset: number;
|
|
118
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Type helper to define a map of content type slugs to their data types.
|
|
138
|
+
* Use with z.infer to get the type from your Zod schemas.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* import { z } from "zod"
|
|
143
|
+
*
|
|
144
|
+
* // Define your schemas
|
|
145
|
+
* export const ProductSchema = z.object({
|
|
146
|
+
* name: z.string(),
|
|
147
|
+
* price: z.number(),
|
|
148
|
+
* })
|
|
149
|
+
*
|
|
150
|
+
* export const TestimonialSchema = z.object({
|
|
151
|
+
* author: z.string(),
|
|
152
|
+
* quote: z.string(),
|
|
153
|
+
* })
|
|
154
|
+
*
|
|
155
|
+
* // Create the type map
|
|
156
|
+
* export type MyCMSTypes = {
|
|
157
|
+
* product: z.infer<typeof ProductSchema>
|
|
158
|
+
* testimonial: z.infer<typeof TestimonialSchema>
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* // Use in hooks for type-safe parsedData
|
|
162
|
+
* const { items } = useContent<MyCMSTypes, "product">("product")
|
|
163
|
+
* // items[0].parsedData.name is typed as string
|
|
164
|
+
* // items[0].parsedData.price is typed as number
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
type CMSContentTypeMap = Record<string, Record<string, unknown>>;
|
|
119
168
|
/** JSON-safe values accepted at the CMS operation boundary. */
|
|
120
169
|
type CMSOperationData = string | number | boolean | null | readonly CMSOperationData[] | {
|
|
121
170
|
readonly [key: string]: CMSOperationData;
|
|
@@ -278,4 +327,4 @@ interface CMSBackendConfig {
|
|
|
278
327
|
maxPageSize?: number;
|
|
279
328
|
}
|
|
280
329
|
|
|
281
|
-
export type {
|
|
330
|
+
export type { CMSReadOptions as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, CMSReadView as a, SerializedContentItemWithType as b, CMSContentFields as c, CMSContentItemResult as d, CMSContentTypeMap as e, CMSBackendConfig as f, CMSSelectedData as g, ContentItem as h, SerializedContentItem as i, ContentItemWithType as j, ContentType as k, CMSBackendHooks as l, CMSCreateOperationContext as m, CMSCreateResultContext as n, CMSDeleteOperationContext as o, CMSDeleteResultContext as p, CMSOperationErrorContext as q, CMSOperationLifecycleContext as r, CMSUpdateOperationContext as s, CMSUpdateResultContext as t, ContentTypeConfig as u, SerializedContentItemContent as v };
|