@btst/plugin-cms 0.0.0-stage → 1.0.0-beta.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/LICENSE.md +17 -0
- package/dist/api/getters.cjs +328 -0
- package/dist/api/getters.mjs +314 -0
- package/dist/api/index.cjs +29 -0
- package/dist/api/index.d.cts +209 -0
- package/dist/api/index.d.mts +209 -0
- package/dist/api/index.d.ts +209 -0
- package/dist/api/index.mjs +7 -0
- package/dist/api/lifecycle-migrations.cjs +13 -0
- package/dist/api/lifecycle-migrations.mjs +11 -0
- package/dist/api/mutations.cjs +59 -0
- package/dist/api/mutations.mjs +57 -0
- package/dist/api/operations.cjs +1769 -0
- package/dist/api/operations.mjs +1762 -0
- package/dist/api/plugin.cjs +337 -0
- package/dist/api/plugin.mjs +331 -0
- package/dist/api/query-key-defs.cjs +44 -0
- package/dist/api/query-key-defs.mjs +39 -0
- package/dist/api/relations.cjs +76 -0
- package/dist/api/relations.mjs +70 -0
- package/dist/client/components/forms/content-form.cjs +286 -0
- package/dist/client/components/forms/content-form.mjs +284 -0
- package/dist/client/components/forms/file-upload.cjs +160 -0
- package/dist/client/components/forms/file-upload.mjs +158 -0
- package/dist/client/components/forms/relation-field.cjs +237 -0
- package/dist/client/components/forms/relation-field.mjs +235 -0
- package/dist/client/components/index.cjs +14 -0
- package/dist/client/components/index.d.cts +20 -0
- package/dist/client/components/index.d.mts +20 -0
- package/dist/client/components/index.d.ts +20 -0
- package/dist/client/components/index.mjs +10 -0
- package/dist/client/components/inverse-relations-panel.cjs +272 -0
- package/dist/client/components/inverse-relations-panel.mjs +270 -0
- package/dist/client/components/loading/dashboard-skeleton.cjs +18 -0
- package/dist/client/components/loading/dashboard-skeleton.mjs +16 -0
- package/dist/client/components/loading/editor-skeleton.cjs +32 -0
- package/dist/client/components/loading/editor-skeleton.mjs +30 -0
- package/dist/client/components/loading/list-skeleton.cjs +32 -0
- package/dist/client/components/loading/list-skeleton.mjs +30 -0
- package/dist/client/components/pages/404-page.cjs +26 -0
- package/dist/client/components/pages/404-page.mjs +24 -0
- package/dist/client/components/pages/content-editor-page.cjs +84 -0
- package/dist/client/components/pages/content-editor-page.internal.cjs +170 -0
- package/dist/client/components/pages/content-editor-page.internal.mjs +168 -0
- package/dist/client/components/pages/content-editor-page.mjs +82 -0
- package/dist/client/components/pages/content-list-page.cjs +49 -0
- package/dist/client/components/pages/content-list-page.internal.cjs +334 -0
- package/dist/client/components/pages/content-list-page.internal.mjs +332 -0
- package/dist/client/components/pages/content-list-page.mjs +47 -0
- package/dist/client/components/pages/dashboard-page.cjs +42 -0
- package/dist/client/components/pages/dashboard-page.internal.cjs +102 -0
- package/dist/client/components/pages/dashboard-page.internal.mjs +100 -0
- package/dist/client/components/pages/dashboard-page.mjs +40 -0
- package/dist/client/components/shared/default-error.cjs +17 -0
- package/dist/client/components/shared/default-error.mjs +15 -0
- package/dist/client/components/shared/empty-state.cjs +16 -0
- package/dist/client/components/shared/empty-state.mjs +14 -0
- package/dist/client/components/shared/page-wrapper.cjs +29 -0
- package/dist/client/components/shared/page-wrapper.mjs +27 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/cms-hooks.cjs +300 -0
- package/dist/client/hooks/cms-hooks.mjs +280 -0
- package/dist/client/hooks/cms-resource.cjs +13 -0
- package/dist/client/hooks/cms-resource.mjs +11 -0
- package/dist/client/hooks/index.cjs +25 -0
- package/dist/client/hooks/index.d.cts +693 -0
- package/dist/client/hooks/index.d.mts +693 -0
- package/dist/client/hooks/index.d.ts +693 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.cjs +15 -0
- package/dist/client/index.d.cts +654 -0
- package/dist/client/index.d.mts +654 -0
- package/dist/client/index.d.ts +654 -0
- package/dist/client/index.mjs +3 -0
- package/dist/client/overrides.cjs +26 -0
- package/dist/client/overrides.mjs +24 -0
- package/dist/client/plugin.cjs +316 -0
- package/dist/client/plugin.mjs +314 -0
- package/dist/client.css +3 -0
- package/dist/db.cjs +118 -0
- package/dist/db.mjs +116 -0
- package/dist/permissions.cjs +46 -0
- package/dist/permissions.d.cts +42 -0
- package/dist/permissions.d.mts +42 -0
- package/dist/permissions.d.ts +42 -0
- package/dist/permissions.mjs +44 -0
- package/dist/query-keys.cjs +229 -0
- package/dist/query-keys.d.cts +8 -0
- package/dist/query-keys.d.mts +8 -0
- package/dist/query-keys.d.ts +8 -0
- package/dist/query-keys.mjs +225 -0
- package/dist/schemas.cjs +81 -0
- package/dist/schemas.mjs +72 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.cts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.mts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.ts +6 -0
- package/dist/shared/plugin-cms.Bptwe33B.d.cts +1749 -0
- package/dist/shared/plugin-cms.Csx7tNDO.d.mts +1749 -0
- package/dist/shared/plugin-cms.eNW9_FO5.d.ts +1749 -0
- package/dist/style.css +6 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +406 -0
- package/dist/types.d.mts +406 -0
- package/dist/types.d.ts +406 -0
- package/dist/types.mjs +1 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/alert-dialog.cjs +157 -0
- package/dist/ui/src/components/alert-dialog.mjs +132 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +92 -0
- package/dist/ui/src/components/auto-form/index.mjs +86 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/badge.cjs +42 -0
- package/dist/ui/src/components/badge.mjs +39 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/card.cjs +56 -0
- package/dist/ui/src/components/card.mjs +51 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/command.cjs +78 -0
- package/dist/ui/src/components/command.mjs +73 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +119 -0
- package/dist/ui/src/components/dialog.mjs +97 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/multi-select.cjs +555 -0
- package/dist/ui/src/components/multi-select.mjs +540 -0
- package/dist/ui/src/components/page-layout.cjs +25 -0
- package/dist/ui/src/components/page-layout.mjs +23 -0
- package/dist/ui/src/components/page-wrapper.cjs +20 -0
- package/dist/ui/src/components/page-wrapper.mjs +18 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/skeleton.cjs +17 -0
- package/dist/ui/src/components/skeleton.mjs +15 -0
- package/dist/ui/src/components/stack-attribution.cjs +24 -0
- package/dist/ui/src/components/stack-attribution.mjs +22 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/table.cjs +89 -0
- package/dist/ui/src/components/table.mjs +82 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/hooks/use-debounce.cjs +16 -0
- package/dist/ui/src/hooks/use-debounce.mjs +14 -0
- package/dist/ui/src/hooks/use-route-lifecycle.cjs +31 -0
- package/dist/ui/src/hooks/use-route-lifecycle.mjs +29 -0
- package/dist/ui/src/lib/schema-converter.cjs +133 -0
- package/dist/ui/src/lib/schema-converter.mjs +127 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/utils.cjs +19 -0
- package/dist/utils.mjs +12 -0
- package/package.json +170 -3
- package/README.md +0 -3
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ResourceFormConfig, ResourceFormResult, ResourceSelectResult } from '@btst/stack/plugins/client/hooks';
|
|
3
|
+
import { SerializedContentItemWithType, CMSReadView, CMSContentFields, CMSReadOptions, CMSContentItemResult, SerializedContentType, CMSContentTypeMap, InverseRelation } from '../../types.mjs';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
interface UseContentTypesResult {
|
|
7
|
+
contentTypes: (SerializedContentType & {
|
|
8
|
+
itemCount: number;
|
|
9
|
+
})[];
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
refetch: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Hook for fetching all content types
|
|
16
|
+
*/
|
|
17
|
+
declare function useContentTypes(): UseContentTypesResult;
|
|
18
|
+
/**
|
|
19
|
+
* Suspense variant of useContentTypes
|
|
20
|
+
*/
|
|
21
|
+
declare function useSuspenseContentTypes(): {
|
|
22
|
+
contentTypes: (SerializedContentType & {
|
|
23
|
+
itemCount: number;
|
|
24
|
+
})[];
|
|
25
|
+
refetch: () => Promise<unknown>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Hook for fetching a single content type by slug
|
|
29
|
+
*/
|
|
30
|
+
declare function useContentType(slug: string): {
|
|
31
|
+
contentType: SerializedContentType | null;
|
|
32
|
+
isLoading: boolean;
|
|
33
|
+
error: Error | null;
|
|
34
|
+
refetch: () => void;
|
|
35
|
+
};
|
|
36
|
+
interface UseContentOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
37
|
+
/** Number of items per page (default: 10) */
|
|
38
|
+
limit?: number;
|
|
39
|
+
/** Whether to enable the query (default: true) */
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
/** Free-text search across item slugs and data values */
|
|
42
|
+
search?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Result type for useContent hook with load more functionality
|
|
46
|
+
* @template TData - The type of parsedData (defaults to Record<string, unknown>)
|
|
47
|
+
*/
|
|
48
|
+
interface UseContentResult<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
49
|
+
/** Array of all loaded content items */
|
|
50
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
51
|
+
/** Total number of items available */
|
|
52
|
+
total: number;
|
|
53
|
+
/** Whether the initial load is in progress */
|
|
54
|
+
isLoading: boolean;
|
|
55
|
+
/** Error if the query failed */
|
|
56
|
+
error: Error | null;
|
|
57
|
+
/** Function to load the next page of items */
|
|
58
|
+
loadMore: () => void;
|
|
59
|
+
/** Whether there are more items to load */
|
|
60
|
+
hasMore: boolean;
|
|
61
|
+
/** Whether the next page is being loaded */
|
|
62
|
+
isLoadingMore: boolean;
|
|
63
|
+
/** Function to refetch all items */
|
|
64
|
+
refetch: () => void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Hook for fetching paginated content items with load more functionality.
|
|
68
|
+
* Uses React Query's infinite query for efficient pagination.
|
|
69
|
+
*
|
|
70
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
71
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Without type safety (backward compatible)
|
|
76
|
+
* const { items, loadMore, hasMore, isLoadingMore } = useContent("product")
|
|
77
|
+
*
|
|
78
|
+
* // With type safety using a type map
|
|
79
|
+
* type MyCMSTypes = {
|
|
80
|
+
* product: { name: string; price: number }
|
|
81
|
+
* testimonial: { author: string; quote: string }
|
|
82
|
+
* }
|
|
83
|
+
* const { items, loadMore, hasMore } = useContent<MyCMSTypes, "product">("product")
|
|
84
|
+
* // items[0].parsedData.name is string
|
|
85
|
+
* // items[0].parsedData.price is number
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function useContent<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, options: UseContentOptions<"content", TFields> & {
|
|
89
|
+
view: "content";
|
|
90
|
+
fields: TFields;
|
|
91
|
+
}): UseContentResult<TMap[TSlug], "content", TFields>;
|
|
92
|
+
declare function useContent<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, options: UseContentOptions<"content"> & {
|
|
93
|
+
view: "content";
|
|
94
|
+
fields?: undefined;
|
|
95
|
+
}): UseContentResult<TMap[TSlug], "content">;
|
|
96
|
+
declare function useContent<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, options?: UseContentOptions<TView, TFields>): UseContentResult<TMap[TSlug], TView, TFields>;
|
|
97
|
+
/**
|
|
98
|
+
* Suspense variant of useContent with load more functionality.
|
|
99
|
+
*
|
|
100
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
101
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
102
|
+
*/
|
|
103
|
+
type SuspenseContentResult<TData, TView extends CMSReadView, TFields extends CMSContentFields = undefined> = {
|
|
104
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
105
|
+
total: number;
|
|
106
|
+
loadMore: () => Promise<unknown>;
|
|
107
|
+
hasMore: boolean;
|
|
108
|
+
isLoadingMore: boolean;
|
|
109
|
+
refetch: () => Promise<unknown>;
|
|
110
|
+
};
|
|
111
|
+
declare function useSuspenseContent<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, options: UseContentOptions<"content", TFields> & {
|
|
112
|
+
view: "content";
|
|
113
|
+
fields: TFields;
|
|
114
|
+
}): SuspenseContentResult<TMap[TSlug], "content", TFields>;
|
|
115
|
+
declare function useSuspenseContent<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, options: UseContentOptions<"content"> & {
|
|
116
|
+
view: "content";
|
|
117
|
+
fields?: undefined;
|
|
118
|
+
}): SuspenseContentResult<TMap[TSlug], "content">;
|
|
119
|
+
declare function useSuspenseContent<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, options?: UseContentOptions<TView, TFields>): SuspenseContentResult<TMap[TSlug], TView, TFields>;
|
|
120
|
+
/**
|
|
121
|
+
* Hook for fetching a single content item by ID with optional type safety.
|
|
122
|
+
*
|
|
123
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
124
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* type MyCMSTypes = { product: { name: string; price: number } }
|
|
129
|
+
* const { item } = useContentItem<MyCMSTypes, "product">("product", "some-id")
|
|
130
|
+
* // item?.parsedData.name is string
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
type ContentItemQueryResult<TData, TView extends CMSReadView, TFields extends CMSContentFields = undefined> = {
|
|
134
|
+
item: CMSContentItemResult<TData, TView, TFields> | null;
|
|
135
|
+
isLoading: boolean;
|
|
136
|
+
error: Error | null;
|
|
137
|
+
refetch: () => void;
|
|
138
|
+
};
|
|
139
|
+
declare function useContentItem<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, id: string, options: CMSReadOptions<"content", TFields> & {
|
|
140
|
+
view: "content";
|
|
141
|
+
fields: TFields;
|
|
142
|
+
}): ContentItemQueryResult<TMap[TSlug], "content", TFields>;
|
|
143
|
+
declare function useContentItem<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, id: string, options: CMSReadOptions<"content"> & {
|
|
144
|
+
view: "content";
|
|
145
|
+
fields?: undefined;
|
|
146
|
+
}): ContentItemQueryResult<TMap[TSlug], "content">;
|
|
147
|
+
declare function useContentItem<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, id: string, options?: CMSReadOptions<TView, TFields>): ContentItemQueryResult<TMap[TSlug], TView, TFields>;
|
|
148
|
+
/**
|
|
149
|
+
* Suspense variant of useContentItem with optional type safety.
|
|
150
|
+
*
|
|
151
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
152
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
153
|
+
*/
|
|
154
|
+
type SuspenseContentItemResult<TData, TView extends CMSReadView, TFields extends CMSContentFields = undefined> = {
|
|
155
|
+
item: CMSContentItemResult<TData, TView, TFields> | null;
|
|
156
|
+
refetch: () => Promise<unknown>;
|
|
157
|
+
};
|
|
158
|
+
declare function useSuspenseContentItem<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, id: string, options: CMSReadOptions<"content", TFields> & {
|
|
159
|
+
view: "content";
|
|
160
|
+
fields: TFields;
|
|
161
|
+
}): SuspenseContentItemResult<TMap[TSlug], "content", TFields>;
|
|
162
|
+
declare function useSuspenseContentItem<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, id: string, options: CMSReadOptions<"content"> & {
|
|
163
|
+
view: "content";
|
|
164
|
+
fields?: undefined;
|
|
165
|
+
}): SuspenseContentItemResult<TMap[TSlug], "content">;
|
|
166
|
+
declare function useSuspenseContentItem<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, id: string, options?: CMSReadOptions<TView, TFields>): SuspenseContentItemResult<TMap[TSlug], TView, TFields>;
|
|
167
|
+
/**
|
|
168
|
+
* Hook for fetching a content item by slug with optional type safety.
|
|
169
|
+
*
|
|
170
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
171
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* type MyCMSTypes = { product: { name: string; price: number } }
|
|
176
|
+
* const { item } = useContentItemBySlug<MyCMSTypes, "product">("product", "my-product")
|
|
177
|
+
* // item?.parsedData.price is number
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
180
|
+
declare function useContentItemBySlug<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, slug: string, options: CMSReadOptions<"content", TFields> & {
|
|
181
|
+
view: "content";
|
|
182
|
+
fields: TFields;
|
|
183
|
+
}): ContentItemQueryResult<TMap[TSlug], "content", TFields>;
|
|
184
|
+
declare function useContentItemBySlug<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, slug: string, options: CMSReadOptions<"content"> & {
|
|
185
|
+
view: "content";
|
|
186
|
+
fields?: undefined;
|
|
187
|
+
}): ContentItemQueryResult<TMap[TSlug], "content">;
|
|
188
|
+
declare function useContentItemBySlug<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, slug: string, options?: CMSReadOptions<TView, TFields>): ContentItemQueryResult<TMap[TSlug], TView, TFields>;
|
|
189
|
+
/**
|
|
190
|
+
* Hook for creating a content item with optional type safety.
|
|
191
|
+
*
|
|
192
|
+
* @template TData - The type of the content data (defaults to Record<string, unknown>)
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* type ProductData = { name: string; price: number }
|
|
197
|
+
* const createProduct = useCreateContent<ProductData>("product")
|
|
198
|
+
*
|
|
199
|
+
* // TypeScript will enforce the correct shape
|
|
200
|
+
* createProduct.mutate({
|
|
201
|
+
* slug: "my-product",
|
|
202
|
+
* data: { name: "Widget", price: 29.99 }
|
|
203
|
+
* })
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
declare function useCreateContent<TData = Record<string, unknown>>(typeSlug: string): {
|
|
207
|
+
mutate: (vars: {
|
|
208
|
+
slug: string;
|
|
209
|
+
data: TData;
|
|
210
|
+
}) => void;
|
|
211
|
+
mutateAsync: (vars: {
|
|
212
|
+
slug: string;
|
|
213
|
+
data: TData;
|
|
214
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
215
|
+
data: undefined;
|
|
216
|
+
variables: undefined;
|
|
217
|
+
error: null;
|
|
218
|
+
isError: false;
|
|
219
|
+
isIdle: true;
|
|
220
|
+
isPending: false;
|
|
221
|
+
isSuccess: false;
|
|
222
|
+
status: "idle";
|
|
223
|
+
reset: () => void;
|
|
224
|
+
context: unknown;
|
|
225
|
+
failureCount: number;
|
|
226
|
+
failureReason: Error | null;
|
|
227
|
+
isPaused: boolean;
|
|
228
|
+
submittedAt: number;
|
|
229
|
+
} | {
|
|
230
|
+
mutate: (vars: {
|
|
231
|
+
slug: string;
|
|
232
|
+
data: TData;
|
|
233
|
+
}) => void;
|
|
234
|
+
mutateAsync: (vars: {
|
|
235
|
+
slug: string;
|
|
236
|
+
data: TData;
|
|
237
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
238
|
+
data: undefined;
|
|
239
|
+
variables: {
|
|
240
|
+
typeSlug: string;
|
|
241
|
+
slug: string;
|
|
242
|
+
data: Record<string, unknown>;
|
|
243
|
+
};
|
|
244
|
+
error: null;
|
|
245
|
+
isError: false;
|
|
246
|
+
isIdle: false;
|
|
247
|
+
isPending: true;
|
|
248
|
+
isSuccess: false;
|
|
249
|
+
status: "pending";
|
|
250
|
+
reset: () => void;
|
|
251
|
+
context: unknown;
|
|
252
|
+
failureCount: number;
|
|
253
|
+
failureReason: Error | null;
|
|
254
|
+
isPaused: boolean;
|
|
255
|
+
submittedAt: number;
|
|
256
|
+
} | {
|
|
257
|
+
mutate: (vars: {
|
|
258
|
+
slug: string;
|
|
259
|
+
data: TData;
|
|
260
|
+
}) => void;
|
|
261
|
+
mutateAsync: (vars: {
|
|
262
|
+
slug: string;
|
|
263
|
+
data: TData;
|
|
264
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
265
|
+
data: undefined;
|
|
266
|
+
error: Error;
|
|
267
|
+
variables: {
|
|
268
|
+
typeSlug: string;
|
|
269
|
+
slug: string;
|
|
270
|
+
data: Record<string, unknown>;
|
|
271
|
+
};
|
|
272
|
+
isError: true;
|
|
273
|
+
isIdle: false;
|
|
274
|
+
isPending: false;
|
|
275
|
+
isSuccess: false;
|
|
276
|
+
status: "error";
|
|
277
|
+
reset: () => void;
|
|
278
|
+
context: unknown;
|
|
279
|
+
failureCount: number;
|
|
280
|
+
failureReason: Error | null;
|
|
281
|
+
isPaused: boolean;
|
|
282
|
+
submittedAt: number;
|
|
283
|
+
} | {
|
|
284
|
+
mutate: (vars: {
|
|
285
|
+
slug: string;
|
|
286
|
+
data: TData;
|
|
287
|
+
}) => void;
|
|
288
|
+
mutateAsync: (vars: {
|
|
289
|
+
slug: string;
|
|
290
|
+
data: TData;
|
|
291
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
292
|
+
data: SerializedContentItemWithType<Record<string, unknown>> | null;
|
|
293
|
+
error: null;
|
|
294
|
+
variables: {
|
|
295
|
+
typeSlug: string;
|
|
296
|
+
slug: string;
|
|
297
|
+
data: Record<string, unknown>;
|
|
298
|
+
};
|
|
299
|
+
isError: false;
|
|
300
|
+
isIdle: false;
|
|
301
|
+
isPending: false;
|
|
302
|
+
isSuccess: true;
|
|
303
|
+
status: "success";
|
|
304
|
+
reset: () => void;
|
|
305
|
+
context: unknown;
|
|
306
|
+
failureCount: number;
|
|
307
|
+
failureReason: Error | null;
|
|
308
|
+
isPaused: boolean;
|
|
309
|
+
submittedAt: number;
|
|
310
|
+
};
|
|
311
|
+
/**
|
|
312
|
+
* Hook for updating a content item with optional type safety.
|
|
313
|
+
*
|
|
314
|
+
* @template TData - The type of the content data (defaults to Record<string, unknown>)
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* type ProductData = { name: string; price: number }
|
|
319
|
+
* const updateProduct = useUpdateContent<ProductData>("product")
|
|
320
|
+
*
|
|
321
|
+
* updateProduct.mutate({
|
|
322
|
+
* id: "item-id",
|
|
323
|
+
* data: { data: { name: "Updated Widget", price: 39.99 } }
|
|
324
|
+
* })
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
declare function useUpdateContent<TData = Record<string, unknown>>(typeSlug: string): {
|
|
328
|
+
mutate: (vars: {
|
|
329
|
+
id: string;
|
|
330
|
+
data: {
|
|
331
|
+
slug?: string;
|
|
332
|
+
data?: TData;
|
|
333
|
+
};
|
|
334
|
+
}) => void;
|
|
335
|
+
mutateAsync: (vars: {
|
|
336
|
+
id: string;
|
|
337
|
+
data: {
|
|
338
|
+
slug?: string;
|
|
339
|
+
data?: TData;
|
|
340
|
+
};
|
|
341
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
342
|
+
data: undefined;
|
|
343
|
+
variables: undefined;
|
|
344
|
+
error: null;
|
|
345
|
+
isError: false;
|
|
346
|
+
isIdle: true;
|
|
347
|
+
isPending: false;
|
|
348
|
+
isSuccess: false;
|
|
349
|
+
status: "idle";
|
|
350
|
+
reset: () => void;
|
|
351
|
+
context: unknown;
|
|
352
|
+
failureCount: number;
|
|
353
|
+
failureReason: Error | null;
|
|
354
|
+
isPaused: boolean;
|
|
355
|
+
submittedAt: number;
|
|
356
|
+
} | {
|
|
357
|
+
mutate: (vars: {
|
|
358
|
+
id: string;
|
|
359
|
+
data: {
|
|
360
|
+
slug?: string;
|
|
361
|
+
data?: TData;
|
|
362
|
+
};
|
|
363
|
+
}) => void;
|
|
364
|
+
mutateAsync: (vars: {
|
|
365
|
+
id: string;
|
|
366
|
+
data: {
|
|
367
|
+
slug?: string;
|
|
368
|
+
data?: TData;
|
|
369
|
+
};
|
|
370
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
371
|
+
data: undefined;
|
|
372
|
+
variables: {
|
|
373
|
+
typeSlug: string;
|
|
374
|
+
id: string;
|
|
375
|
+
data: {
|
|
376
|
+
slug?: string;
|
|
377
|
+
data?: Record<string, unknown>;
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
error: null;
|
|
381
|
+
isError: false;
|
|
382
|
+
isIdle: false;
|
|
383
|
+
isPending: true;
|
|
384
|
+
isSuccess: false;
|
|
385
|
+
status: "pending";
|
|
386
|
+
reset: () => void;
|
|
387
|
+
context: unknown;
|
|
388
|
+
failureCount: number;
|
|
389
|
+
failureReason: Error | null;
|
|
390
|
+
isPaused: boolean;
|
|
391
|
+
submittedAt: number;
|
|
392
|
+
} | {
|
|
393
|
+
mutate: (vars: {
|
|
394
|
+
id: string;
|
|
395
|
+
data: {
|
|
396
|
+
slug?: string;
|
|
397
|
+
data?: TData;
|
|
398
|
+
};
|
|
399
|
+
}) => void;
|
|
400
|
+
mutateAsync: (vars: {
|
|
401
|
+
id: string;
|
|
402
|
+
data: {
|
|
403
|
+
slug?: string;
|
|
404
|
+
data?: TData;
|
|
405
|
+
};
|
|
406
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
407
|
+
data: undefined;
|
|
408
|
+
error: Error;
|
|
409
|
+
variables: {
|
|
410
|
+
typeSlug: string;
|
|
411
|
+
id: string;
|
|
412
|
+
data: {
|
|
413
|
+
slug?: string;
|
|
414
|
+
data?: Record<string, unknown>;
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
isError: true;
|
|
418
|
+
isIdle: false;
|
|
419
|
+
isPending: false;
|
|
420
|
+
isSuccess: false;
|
|
421
|
+
status: "error";
|
|
422
|
+
reset: () => void;
|
|
423
|
+
context: unknown;
|
|
424
|
+
failureCount: number;
|
|
425
|
+
failureReason: Error | null;
|
|
426
|
+
isPaused: boolean;
|
|
427
|
+
submittedAt: number;
|
|
428
|
+
} | {
|
|
429
|
+
mutate: (vars: {
|
|
430
|
+
id: string;
|
|
431
|
+
data: {
|
|
432
|
+
slug?: string;
|
|
433
|
+
data?: TData;
|
|
434
|
+
};
|
|
435
|
+
}) => void;
|
|
436
|
+
mutateAsync: (vars: {
|
|
437
|
+
id: string;
|
|
438
|
+
data: {
|
|
439
|
+
slug?: string;
|
|
440
|
+
data?: TData;
|
|
441
|
+
};
|
|
442
|
+
}) => Promise<SerializedContentItemWithType<TData>>;
|
|
443
|
+
data: SerializedContentItemWithType<Record<string, unknown>> | null;
|
|
444
|
+
error: null;
|
|
445
|
+
variables: {
|
|
446
|
+
typeSlug: string;
|
|
447
|
+
id: string;
|
|
448
|
+
data: {
|
|
449
|
+
slug?: string;
|
|
450
|
+
data?: Record<string, unknown>;
|
|
451
|
+
};
|
|
452
|
+
};
|
|
453
|
+
isError: false;
|
|
454
|
+
isIdle: false;
|
|
455
|
+
isPending: false;
|
|
456
|
+
isSuccess: true;
|
|
457
|
+
status: "success";
|
|
458
|
+
reset: () => void;
|
|
459
|
+
context: unknown;
|
|
460
|
+
failureCount: number;
|
|
461
|
+
failureReason: Error | null;
|
|
462
|
+
isPaused: boolean;
|
|
463
|
+
submittedAt: number;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* Hook for deleting a content item
|
|
467
|
+
*/
|
|
468
|
+
declare function useDeleteContent(typeSlug: string): {
|
|
469
|
+
mutate: (id: string) => void;
|
|
470
|
+
mutateAsync: (id: string) => Promise<{
|
|
471
|
+
success: boolean;
|
|
472
|
+
}>;
|
|
473
|
+
data: undefined;
|
|
474
|
+
variables: undefined;
|
|
475
|
+
error: null;
|
|
476
|
+
isError: false;
|
|
477
|
+
isIdle: true;
|
|
478
|
+
isPending: false;
|
|
479
|
+
isSuccess: false;
|
|
480
|
+
status: "idle";
|
|
481
|
+
reset: () => void;
|
|
482
|
+
context: unknown;
|
|
483
|
+
failureCount: number;
|
|
484
|
+
failureReason: Error | null;
|
|
485
|
+
isPaused: boolean;
|
|
486
|
+
submittedAt: number;
|
|
487
|
+
} | {
|
|
488
|
+
mutate: (id: string) => void;
|
|
489
|
+
mutateAsync: (id: string) => Promise<{
|
|
490
|
+
success: boolean;
|
|
491
|
+
}>;
|
|
492
|
+
data: undefined;
|
|
493
|
+
variables: {
|
|
494
|
+
typeSlug: string;
|
|
495
|
+
id: string;
|
|
496
|
+
};
|
|
497
|
+
error: null;
|
|
498
|
+
isError: false;
|
|
499
|
+
isIdle: false;
|
|
500
|
+
isPending: true;
|
|
501
|
+
isSuccess: false;
|
|
502
|
+
status: "pending";
|
|
503
|
+
reset: () => void;
|
|
504
|
+
context: unknown;
|
|
505
|
+
failureCount: number;
|
|
506
|
+
failureReason: Error | null;
|
|
507
|
+
isPaused: boolean;
|
|
508
|
+
submittedAt: number;
|
|
509
|
+
} | {
|
|
510
|
+
mutate: (id: string) => void;
|
|
511
|
+
mutateAsync: (id: string) => Promise<{
|
|
512
|
+
success: boolean;
|
|
513
|
+
}>;
|
|
514
|
+
data: undefined;
|
|
515
|
+
error: Error;
|
|
516
|
+
variables: {
|
|
517
|
+
typeSlug: string;
|
|
518
|
+
id: string;
|
|
519
|
+
};
|
|
520
|
+
isError: true;
|
|
521
|
+
isIdle: false;
|
|
522
|
+
isPending: false;
|
|
523
|
+
isSuccess: false;
|
|
524
|
+
status: "error";
|
|
525
|
+
reset: () => void;
|
|
526
|
+
context: unknown;
|
|
527
|
+
failureCount: number;
|
|
528
|
+
failureReason: Error | null;
|
|
529
|
+
isPaused: boolean;
|
|
530
|
+
submittedAt: number;
|
|
531
|
+
} | {
|
|
532
|
+
mutate: (id: string) => void;
|
|
533
|
+
mutateAsync: (id: string) => Promise<{
|
|
534
|
+
success: boolean;
|
|
535
|
+
}>;
|
|
536
|
+
data: {
|
|
537
|
+
success: boolean;
|
|
538
|
+
};
|
|
539
|
+
error: null;
|
|
540
|
+
variables: {
|
|
541
|
+
typeSlug: string;
|
|
542
|
+
id: string;
|
|
543
|
+
};
|
|
544
|
+
isError: false;
|
|
545
|
+
isIdle: false;
|
|
546
|
+
isPending: false;
|
|
547
|
+
isSuccess: true;
|
|
548
|
+
status: "success";
|
|
549
|
+
reset: () => void;
|
|
550
|
+
context: unknown;
|
|
551
|
+
failureCount: number;
|
|
552
|
+
failureReason: Error | null;
|
|
553
|
+
isPaused: boolean;
|
|
554
|
+
submittedAt: number;
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* Form lifecycle hook for creating/editing content items, built on the core
|
|
558
|
+
* resource `useForm`: submits the right mutation, awaits invalidation,
|
|
559
|
+
* notifies via `useNotify()`, redirects, and maps server validation issues
|
|
560
|
+
* to `fieldErrors`.
|
|
561
|
+
*/
|
|
562
|
+
declare function useContentItemForm<TValues>(config: ResourceFormConfig<TValues, SerializedContentItemWithType | null, SerializedContentItemWithType | null>): ResourceFormResult<TValues, SerializedContentItemWithType | null, SerializedContentItemWithType | null>;
|
|
563
|
+
/**
|
|
564
|
+
* Select-input options for content items of a target type, built on the core
|
|
565
|
+
* resource `useSelect`: debounced server-side search over the `options`
|
|
566
|
+
* query, with selected ids missing from the current results preloaded via
|
|
567
|
+
* the `detail` query (typeSlug, id) so their labels resolve.
|
|
568
|
+
*
|
|
569
|
+
* Used by the relation picker (`RelationField`). Optional content view/fields
|
|
570
|
+
* apply to both search results and selected-ID preloads; full records remain the default.
|
|
571
|
+
*/
|
|
572
|
+
declare function useContentOptions<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(config: {
|
|
573
|
+
/** Content type slug to search within. */
|
|
574
|
+
targetType: string;
|
|
575
|
+
/** Currently selected IDs, preloaded when absent from search results. */
|
|
576
|
+
value: string[];
|
|
577
|
+
getOptionLabel: (item: CMSContentItemResult<Record<string, unknown>, TView, TFields>) => string;
|
|
578
|
+
} & CMSReadOptions<TView, TFields>): ResourceSelectResult<CMSContentItemResult<Record<string, unknown>, TView, TFields>>;
|
|
579
|
+
/**
|
|
580
|
+
* Content item with populated relations
|
|
581
|
+
*/
|
|
582
|
+
interface ContentItemWithRelations<TData = Record<string, unknown>> extends SerializedContentItemWithType<TData> {
|
|
583
|
+
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Hook for fetching a content item with its relations populated.
|
|
587
|
+
* Use this when you need to display related items alongside the main item.
|
|
588
|
+
*
|
|
589
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
590
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
591
|
+
*
|
|
592
|
+
* @example
|
|
593
|
+
* ```typescript
|
|
594
|
+
* type MyCMSTypes = {
|
|
595
|
+
* resource: { name: string; categoryIds: Array<{ id: string }> }
|
|
596
|
+
* category: { name: string }
|
|
597
|
+
* }
|
|
598
|
+
* const { item } = useContentItemPopulated<MyCMSTypes, "resource">("resource", "some-id")
|
|
599
|
+
* // item?._relations?.categoryIds contains populated category items
|
|
600
|
+
* ```
|
|
601
|
+
*/
|
|
602
|
+
declare function useContentItemPopulated<TMap extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, id: string): {
|
|
603
|
+
item: ContentItemWithRelations<TMap[TSlug]> | null;
|
|
604
|
+
isLoading: boolean;
|
|
605
|
+
error: Error | null;
|
|
606
|
+
refetch: () => void;
|
|
607
|
+
};
|
|
608
|
+
/**
|
|
609
|
+
* Suspense variant of useContentItemPopulated
|
|
610
|
+
*/
|
|
611
|
+
declare function useSuspenseContentItemPopulated<TMap extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, id: string): {
|
|
612
|
+
item: ContentItemWithRelations<TMap[TSlug]> | null;
|
|
613
|
+
refetch: () => Promise<unknown>;
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Options for useContentByRelation hook
|
|
617
|
+
*/
|
|
618
|
+
interface UseContentByRelationOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
619
|
+
/** Number of items per page (default: 20) */
|
|
620
|
+
limit?: number;
|
|
621
|
+
/** Whether to enable the query (default: true) */
|
|
622
|
+
enabled?: boolean;
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Hook for fetching content items that have a specific relation.
|
|
626
|
+
* Useful for "filter by category" functionality.
|
|
627
|
+
*
|
|
628
|
+
* @template TMap - A type map of content type slugs to their data types
|
|
629
|
+
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* ```typescript
|
|
633
|
+
* // Get all resources in a specific category
|
|
634
|
+
* const { items } = useContentByRelation("resource", "categoryIds", categoryId)
|
|
635
|
+
* ```
|
|
636
|
+
*/
|
|
637
|
+
declare function useContentByRelation<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, fieldName: string, targetId: string, options: UseContentByRelationOptions<"content", TFields> & {
|
|
638
|
+
view: "content";
|
|
639
|
+
fields: TFields;
|
|
640
|
+
}): UseContentResult<TMap[TSlug], "content", TFields>;
|
|
641
|
+
declare function useContentByRelation<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, fieldName: string, targetId: string, options: UseContentByRelationOptions<"content"> & {
|
|
642
|
+
view: "content";
|
|
643
|
+
fields?: undefined;
|
|
644
|
+
}): UseContentResult<TMap[TSlug], "content">;
|
|
645
|
+
declare function useContentByRelation<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, fieldName: string, targetId: string, options?: UseContentByRelationOptions<TView, TFields>): UseContentResult<TMap[TSlug], TView, TFields>;
|
|
646
|
+
/**
|
|
647
|
+
* Suspense variant of useContentByRelation
|
|
648
|
+
*/
|
|
649
|
+
declare function useSuspenseContentByRelation<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, const TFields extends readonly string[] = readonly string[]>(typeSlug: TSlug & string, fieldName: string, targetId: string, options: UseContentByRelationOptions<"content", TFields> & {
|
|
650
|
+
view: "content";
|
|
651
|
+
fields: TFields;
|
|
652
|
+
}): SuspenseContentResult<TMap[TSlug], "content", TFields>;
|
|
653
|
+
declare function useSuspenseContentByRelation<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, fieldName: string, targetId: string, options: UseContentByRelationOptions<"content"> & {
|
|
654
|
+
view: "content";
|
|
655
|
+
fields?: undefined;
|
|
656
|
+
}): SuspenseContentResult<TMap[TSlug], "content">;
|
|
657
|
+
declare function useSuspenseContentByRelation<TMap extends CMSContentTypeMap = CMSContentTypeMap, TSlug extends keyof TMap = keyof TMap, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined>(typeSlug: TSlug & string, fieldName: string, targetId: string, options?: UseContentByRelationOptions<TView, TFields>): SuspenseContentResult<TMap[TSlug], TView, TFields>;
|
|
658
|
+
/**
|
|
659
|
+
* Hook for fetching the inverse relations of a content item — the content
|
|
660
|
+
* types with belongsTo fields pointing at it, with per-field counts.
|
|
661
|
+
*/
|
|
662
|
+
declare function useInverseRelations(contentTypeSlug: string, itemId: string): {
|
|
663
|
+
inverseRelations: InverseRelation[];
|
|
664
|
+
isLoading: boolean;
|
|
665
|
+
error: Error | null;
|
|
666
|
+
refetch: () => void;
|
|
667
|
+
};
|
|
668
|
+
/**
|
|
669
|
+
* Hook for listing the items behind one inverse relation (e.g. all comments
|
|
670
|
+
* whose `resourceId` points at this resource).
|
|
671
|
+
*/
|
|
672
|
+
declare function useInverseRelationItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(params: {
|
|
673
|
+
contentTypeSlug: string;
|
|
674
|
+
sourceType: string;
|
|
675
|
+
itemId: string;
|
|
676
|
+
fieldName: string;
|
|
677
|
+
}, options?: CMSReadOptions<TView, TFields> & {
|
|
678
|
+
/** Whether to enable the query (default: true). */
|
|
679
|
+
enabled?: boolean;
|
|
680
|
+
/** Number of items per page (default: 20). */
|
|
681
|
+
limit?: number;
|
|
682
|
+
/** Number of matching items to skip (default: 0). */
|
|
683
|
+
offset?: number;
|
|
684
|
+
}): {
|
|
685
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
686
|
+
total: number;
|
|
687
|
+
isLoading: boolean;
|
|
688
|
+
error: Error | null;
|
|
689
|
+
refetch: () => void;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
export { useContent, useContentByRelation, useContentItem, useContentItemBySlug, useContentItemForm, useContentItemPopulated, useContentOptions, useContentType, useContentTypes, useCreateContent, useDeleteContent, useInverseRelationItems, useInverseRelations, useSuspenseContent, useSuspenseContentByRelation, useSuspenseContentItem, useSuspenseContentItemPopulated, useSuspenseContentTypes, useUpdateContent };
|
|
693
|
+
export type { ContentItemWithRelations, UseContentByRelationOptions, UseContentOptions, UseContentResult, UseContentTypesResult };
|