@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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientPlugin,
|
|
1
|
+
import { q as ClientPluginDefinition } from '../../shared/stack.Rb87lHqK.cjs';
|
|
2
|
+
export { C as ClientPlugin, r as ClientPluginRegistration, P as PluginOverrides, s as ResolvedClientPluginRuntime } from '../../shared/stack.Rb87lHqK.cjs';
|
|
3
3
|
import { Route } from '@btst/yar';
|
|
4
4
|
export { Route, RouteContext, RouteDef, createRoute, createRouter, defineRoute, defineRoutes } from '@btst/yar';
|
|
5
5
|
import { createClient } from 'better-call/client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientPlugin,
|
|
1
|
+
import { q as ClientPluginDefinition } from '../../shared/stack.C2Pvl-RS.mjs';
|
|
2
|
+
export { C as ClientPlugin, r as ClientPluginRegistration, P as PluginOverrides, s as ResolvedClientPluginRuntime } from '../../shared/stack.C2Pvl-RS.mjs';
|
|
3
3
|
import { Route } from '@btst/yar';
|
|
4
4
|
export { Route, RouteContext, RouteDef, createRoute, createRouter, defineRoute, defineRoutes } from '@btst/yar';
|
|
5
5
|
import { createClient } from 'better-call/client';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { C as ClientPlugin,
|
|
1
|
+
import { q as ClientPluginDefinition } from '../../shared/stack.BB9tubJJ.js';
|
|
2
|
+
export { C as ClientPlugin, r as ClientPluginRegistration, P as PluginOverrides, s as ResolvedClientPluginRuntime } from '../../shared/stack.BB9tubJJ.js';
|
|
3
3
|
import { Route } from '@btst/yar';
|
|
4
4
|
export { Route, RouteContext, RouteDef, createRoute, createRouter, defineRoute, defineRoutes } from '@btst/yar';
|
|
5
5
|
import { createClient } from 'better-call/client';
|
|
@@ -15,6 +15,7 @@ exports.getAllContentItems = getters.getAllContentItems;
|
|
|
15
15
|
exports.getAllContentTypes = getters.getAllContentTypes;
|
|
16
16
|
exports.getContentItemById = getters.getContentItemById;
|
|
17
17
|
exports.getContentItemBySlug = getters.getContentItemBySlug;
|
|
18
|
+
exports.getContentItemsByRelation = getters.getContentItemsByRelation;
|
|
18
19
|
exports.serializeContentItem = getters.serializeContentItem;
|
|
19
20
|
exports.serializeContentItemWithType = getters.serializeContentItemWithType;
|
|
20
21
|
exports.serializeContentType = getters.serializeContentType;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { C as CMSApiRouter, b as CMSRouteKey, c as CMS_QUERY_KEYS, d as cmsBackendPlugin } from '../../../shared/stack.
|
|
1
|
+
export { C as CMSApiRouter, b as CMSRouteKey, c as CMS_QUERY_KEYS, d as cmsBackendPlugin } from '../../../shared/stack.NNrBKBkM.cjs';
|
|
2
2
|
import { DBAdapter } from '@btst/db';
|
|
3
|
-
import { a as
|
|
4
|
-
export {
|
|
3
|
+
import { a as CMSReadView, c as CMSContentFields, C as CMSReadOptions, d as CMSContentItemResult, S as SerializedContentType, h as ContentItem, i as SerializedContentItem, j as ContentItemWithType, b as SerializedContentItemWithType, k as ContentType } from '../../../shared/stack.DrB3L7Ih.cjs';
|
|
4
|
+
export { f as CMSBackendConfig, l as CMSBackendHooks, m as CMSCreateOperationContext, n as CMSCreateResultContext, o as CMSDeleteOperationContext, p as CMSDeleteResultContext, q as CMSOperationErrorContext, r as CMSOperationLifecycleContext, g as CMSSelectedData, s as CMSUpdateOperationContext, t as CMSUpdateResultContext, u as ContentTypeConfig, P as PaginatedContentItems, v as SerializedContentItemContent } from '../../../shared/stack.DrB3L7Ih.cjs';
|
|
5
5
|
export { createCMSQueryKeys } from '../query-keys.cjs';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import '@btst/stack/plugins/api';
|
|
8
7
|
import '../../../authorization/index.cjs';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
9
|
import 'better-call';
|
|
10
10
|
import '@tanstack/react-query';
|
|
11
11
|
import '@btst/stack/plugins/client';
|
|
@@ -65,13 +65,13 @@ declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedConte
|
|
|
65
65
|
* @param params - Optional filter/pagination parameters. `search` matches
|
|
66
66
|
* case-insensitively against item slugs and string values in the item data.
|
|
67
67
|
*/
|
|
68
|
-
declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
68
|
+
declare function getAllContentItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
69
69
|
slug?: string;
|
|
70
70
|
limit?: number;
|
|
71
71
|
offset?: number;
|
|
72
72
|
search?: string;
|
|
73
|
-
}): Promise<{
|
|
74
|
-
items:
|
|
73
|
+
} & CMSReadOptions<TView, TFields>): Promise<{
|
|
74
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
75
75
|
total: number;
|
|
76
76
|
limit?: number;
|
|
77
77
|
offset?: number;
|
|
@@ -87,7 +87,7 @@ declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string,
|
|
|
87
87
|
* @param adapter - The database adapter
|
|
88
88
|
* @param id - The content item ID (UUID)
|
|
89
89
|
*/
|
|
90
|
-
declare function getContentItemById(adapter: DBAdapter, id: string): Promise<
|
|
90
|
+
declare function getContentItemById<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, id: string, options?: CMSReadOptions<TView, TFields>): Promise<CMSContentItemResult<Record<string, unknown>, TView, TFields> | null>;
|
|
91
91
|
/**
|
|
92
92
|
* Retrieve a single content item by its slug within a content type.
|
|
93
93
|
* Returns null if the content type or item is not found.
|
|
@@ -100,7 +100,39 @@ declare function getContentItemById(adapter: DBAdapter, id: string): Promise<Ser
|
|
|
100
100
|
* @param contentTypeSlug - The slug of the content type
|
|
101
101
|
* @param slug - The slug of the content item
|
|
102
102
|
*/
|
|
103
|
-
declare function getContentItemBySlug(adapter: DBAdapter, contentTypeSlug: string, slug: string): Promise<
|
|
103
|
+
declare function getContentItemBySlug<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, slug: string, options?: CMSReadOptions<TView, TFields>): Promise<CMSContentItemResult<Record<string, unknown>, TView, TFields> | null>;
|
|
104
|
+
/** Parameters for a page of items referencing one relation target. */
|
|
105
|
+
interface ContentItemsByRelationParams<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
106
|
+
/** Declared top-level relation field on the source content type. */
|
|
107
|
+
field: string;
|
|
108
|
+
/** ID of the item referenced by the relation. */
|
|
109
|
+
targetId: string;
|
|
110
|
+
/** Number of items to return (default: 20). */
|
|
111
|
+
limit?: number;
|
|
112
|
+
/** Number of matching items to skip (default: 0). */
|
|
113
|
+
offset?: number;
|
|
114
|
+
}
|
|
115
|
+
/** A page of unique related items, ordered by creation time then ID descending. */
|
|
116
|
+
interface ContentItemsByRelationResult<TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
117
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
118
|
+
total: number;
|
|
119
|
+
limit: number;
|
|
120
|
+
offset: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Retrieve source items whose relation field references a target item.
|
|
124
|
+
* Relation rows are scanned completely, metadata is read in batches, and full
|
|
125
|
+
* content is fetched only for the requested page. Internal scans grow with the
|
|
126
|
+
* relation count; this does not promise constant query counts or native joins.
|
|
127
|
+
* Set `view: "content"` for identity, parsed content and serialized timestamps
|
|
128
|
+
* without the editor envelope. Omitting it preserves the full item response.
|
|
129
|
+
*
|
|
130
|
+
* @remarks This lower-level read does not authorize requests, validate relation
|
|
131
|
+
* configuration or target access, or compose lifecycle hooks. Callers own those
|
|
132
|
+
* checks and pagination validation. Use `forRequest(request).operations.cms` for
|
|
133
|
+
* request work or trusted operations for validated, lifecycle-aware server work.
|
|
134
|
+
*/
|
|
135
|
+
declare function getContentItemsByRelation<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params: ContentItemsByRelationParams<TView, TFields>): Promise<ContentItemsByRelationResult<TView, TFields>>;
|
|
104
136
|
|
|
105
137
|
declare const CMSContentTypeParamsSchema: z.ZodObject<{
|
|
106
138
|
slug: z.ZodString;
|
|
@@ -174,5 +206,5 @@ interface CreateCMSContentItemOptions {
|
|
|
174
206
|
*/
|
|
175
207
|
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
176
208
|
|
|
177
|
-
export { CMSContentItemParamsSchema, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
178
|
-
export type { CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
209
|
+
export { CMSContentFields, CMSContentItemParamsSchema, CMSContentItemResult, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSReadOptions, CMSReadView, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
210
|
+
export type { ContentItemsByRelationParams, ContentItemsByRelationResult, CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { C as CMSApiRouter, b as CMSRouteKey, c as CMS_QUERY_KEYS, d as cmsBackendPlugin } from '../../../shared/stack.
|
|
1
|
+
export { C as CMSApiRouter, b as CMSRouteKey, c as CMS_QUERY_KEYS, d as cmsBackendPlugin } from '../../../shared/stack.DFGj0gb7.mjs';
|
|
2
2
|
import { DBAdapter } from '@btst/db';
|
|
3
|
-
import { a as
|
|
4
|
-
export {
|
|
3
|
+
import { a as CMSReadView, c as CMSContentFields, C as CMSReadOptions, d as CMSContentItemResult, S as SerializedContentType, h as ContentItem, i as SerializedContentItem, j as ContentItemWithType, b as SerializedContentItemWithType, k as ContentType } from '../../../shared/stack.DrB3L7Ih.mjs';
|
|
4
|
+
export { f as CMSBackendConfig, l as CMSBackendHooks, m as CMSCreateOperationContext, n as CMSCreateResultContext, o as CMSDeleteOperationContext, p as CMSDeleteResultContext, q as CMSOperationErrorContext, r as CMSOperationLifecycleContext, g as CMSSelectedData, s as CMSUpdateOperationContext, t as CMSUpdateResultContext, u as ContentTypeConfig, P as PaginatedContentItems, v as SerializedContentItemContent } from '../../../shared/stack.DrB3L7Ih.mjs';
|
|
5
5
|
export { createCMSQueryKeys } from '../query-keys.mjs';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import '@btst/stack/plugins/api';
|
|
8
7
|
import '../../../authorization/index.mjs';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
9
|
import 'better-call';
|
|
10
10
|
import '@tanstack/react-query';
|
|
11
11
|
import '@btst/stack/plugins/client';
|
|
@@ -65,13 +65,13 @@ declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedConte
|
|
|
65
65
|
* @param params - Optional filter/pagination parameters. `search` matches
|
|
66
66
|
* case-insensitively against item slugs and string values in the item data.
|
|
67
67
|
*/
|
|
68
|
-
declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
68
|
+
declare function getAllContentItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
69
69
|
slug?: string;
|
|
70
70
|
limit?: number;
|
|
71
71
|
offset?: number;
|
|
72
72
|
search?: string;
|
|
73
|
-
}): Promise<{
|
|
74
|
-
items:
|
|
73
|
+
} & CMSReadOptions<TView, TFields>): Promise<{
|
|
74
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
75
75
|
total: number;
|
|
76
76
|
limit?: number;
|
|
77
77
|
offset?: number;
|
|
@@ -87,7 +87,7 @@ declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string,
|
|
|
87
87
|
* @param adapter - The database adapter
|
|
88
88
|
* @param id - The content item ID (UUID)
|
|
89
89
|
*/
|
|
90
|
-
declare function getContentItemById(adapter: DBAdapter, id: string): Promise<
|
|
90
|
+
declare function getContentItemById<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, id: string, options?: CMSReadOptions<TView, TFields>): Promise<CMSContentItemResult<Record<string, unknown>, TView, TFields> | null>;
|
|
91
91
|
/**
|
|
92
92
|
* Retrieve a single content item by its slug within a content type.
|
|
93
93
|
* Returns null if the content type or item is not found.
|
|
@@ -100,7 +100,39 @@ declare function getContentItemById(adapter: DBAdapter, id: string): Promise<Ser
|
|
|
100
100
|
* @param contentTypeSlug - The slug of the content type
|
|
101
101
|
* @param slug - The slug of the content item
|
|
102
102
|
*/
|
|
103
|
-
declare function getContentItemBySlug(adapter: DBAdapter, contentTypeSlug: string, slug: string): Promise<
|
|
103
|
+
declare function getContentItemBySlug<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, slug: string, options?: CMSReadOptions<TView, TFields>): Promise<CMSContentItemResult<Record<string, unknown>, TView, TFields> | null>;
|
|
104
|
+
/** Parameters for a page of items referencing one relation target. */
|
|
105
|
+
interface ContentItemsByRelationParams<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
106
|
+
/** Declared top-level relation field on the source content type. */
|
|
107
|
+
field: string;
|
|
108
|
+
/** ID of the item referenced by the relation. */
|
|
109
|
+
targetId: string;
|
|
110
|
+
/** Number of items to return (default: 20). */
|
|
111
|
+
limit?: number;
|
|
112
|
+
/** Number of matching items to skip (default: 0). */
|
|
113
|
+
offset?: number;
|
|
114
|
+
}
|
|
115
|
+
/** A page of unique related items, ordered by creation time then ID descending. */
|
|
116
|
+
interface ContentItemsByRelationResult<TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
117
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
118
|
+
total: number;
|
|
119
|
+
limit: number;
|
|
120
|
+
offset: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Retrieve source items whose relation field references a target item.
|
|
124
|
+
* Relation rows are scanned completely, metadata is read in batches, and full
|
|
125
|
+
* content is fetched only for the requested page. Internal scans grow with the
|
|
126
|
+
* relation count; this does not promise constant query counts or native joins.
|
|
127
|
+
* Set `view: "content"` for identity, parsed content and serialized timestamps
|
|
128
|
+
* without the editor envelope. Omitting it preserves the full item response.
|
|
129
|
+
*
|
|
130
|
+
* @remarks This lower-level read does not authorize requests, validate relation
|
|
131
|
+
* configuration or target access, or compose lifecycle hooks. Callers own those
|
|
132
|
+
* checks and pagination validation. Use `forRequest(request).operations.cms` for
|
|
133
|
+
* request work or trusted operations for validated, lifecycle-aware server work.
|
|
134
|
+
*/
|
|
135
|
+
declare function getContentItemsByRelation<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params: ContentItemsByRelationParams<TView, TFields>): Promise<ContentItemsByRelationResult<TView, TFields>>;
|
|
104
136
|
|
|
105
137
|
declare const CMSContentTypeParamsSchema: z.ZodObject<{
|
|
106
138
|
slug: z.ZodString;
|
|
@@ -174,5 +206,5 @@ interface CreateCMSContentItemOptions {
|
|
|
174
206
|
*/
|
|
175
207
|
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
176
208
|
|
|
177
|
-
export { CMSContentItemParamsSchema, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
178
|
-
export type { CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
209
|
+
export { CMSContentFields, CMSContentItemParamsSchema, CMSContentItemResult, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSReadOptions, CMSReadView, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
210
|
+
export type { ContentItemsByRelationParams, ContentItemsByRelationResult, CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export { C as CMSApiRouter, b as CMSRouteKey, c as CMS_QUERY_KEYS, d as cmsBackendPlugin } from '../../../shared/stack.
|
|
1
|
+
export { C as CMSApiRouter, b as CMSRouteKey, c as CMS_QUERY_KEYS, d as cmsBackendPlugin } from '../../../shared/stack.Bw09Lg2z.js';
|
|
2
2
|
import { DBAdapter } from '@btst/db';
|
|
3
|
-
import { a as
|
|
4
|
-
export {
|
|
3
|
+
import { a as CMSReadView, c as CMSContentFields, C as CMSReadOptions, d as CMSContentItemResult, S as SerializedContentType, h as ContentItem, i as SerializedContentItem, j as ContentItemWithType, b as SerializedContentItemWithType, k as ContentType } from '../../../shared/stack.DrB3L7Ih.js';
|
|
4
|
+
export { f as CMSBackendConfig, l as CMSBackendHooks, m as CMSCreateOperationContext, n as CMSCreateResultContext, o as CMSDeleteOperationContext, p as CMSDeleteResultContext, q as CMSOperationErrorContext, r as CMSOperationLifecycleContext, g as CMSSelectedData, s as CMSUpdateOperationContext, t as CMSUpdateResultContext, u as ContentTypeConfig, P as PaginatedContentItems, v as SerializedContentItemContent } from '../../../shared/stack.DrB3L7Ih.js';
|
|
5
5
|
export { createCMSQueryKeys } from '../query-keys.js';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import '@btst/stack/plugins/api';
|
|
8
7
|
import '../../../authorization/index.js';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
9
|
import 'better-call';
|
|
10
10
|
import '@tanstack/react-query';
|
|
11
11
|
import '@btst/stack/plugins/client';
|
|
@@ -65,13 +65,13 @@ declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedConte
|
|
|
65
65
|
* @param params - Optional filter/pagination parameters. `search` matches
|
|
66
66
|
* case-insensitively against item slugs and string values in the item data.
|
|
67
67
|
*/
|
|
68
|
-
declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
68
|
+
declare function getAllContentItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
69
69
|
slug?: string;
|
|
70
70
|
limit?: number;
|
|
71
71
|
offset?: number;
|
|
72
72
|
search?: string;
|
|
73
|
-
}): Promise<{
|
|
74
|
-
items:
|
|
73
|
+
} & CMSReadOptions<TView, TFields>): Promise<{
|
|
74
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
75
75
|
total: number;
|
|
76
76
|
limit?: number;
|
|
77
77
|
offset?: number;
|
|
@@ -87,7 +87,7 @@ declare function getAllContentItems(adapter: DBAdapter, contentTypeSlug: string,
|
|
|
87
87
|
* @param adapter - The database adapter
|
|
88
88
|
* @param id - The content item ID (UUID)
|
|
89
89
|
*/
|
|
90
|
-
declare function getContentItemById(adapter: DBAdapter, id: string): Promise<
|
|
90
|
+
declare function getContentItemById<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, id: string, options?: CMSReadOptions<TView, TFields>): Promise<CMSContentItemResult<Record<string, unknown>, TView, TFields> | null>;
|
|
91
91
|
/**
|
|
92
92
|
* Retrieve a single content item by its slug within a content type.
|
|
93
93
|
* Returns null if the content type or item is not found.
|
|
@@ -100,7 +100,39 @@ declare function getContentItemById(adapter: DBAdapter, id: string): Promise<Ser
|
|
|
100
100
|
* @param contentTypeSlug - The slug of the content type
|
|
101
101
|
* @param slug - The slug of the content item
|
|
102
102
|
*/
|
|
103
|
-
declare function getContentItemBySlug(adapter: DBAdapter, contentTypeSlug: string, slug: string): Promise<
|
|
103
|
+
declare function getContentItemBySlug<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, slug: string, options?: CMSReadOptions<TView, TFields>): Promise<CMSContentItemResult<Record<string, unknown>, TView, TFields> | null>;
|
|
104
|
+
/** Parameters for a page of items referencing one relation target. */
|
|
105
|
+
interface ContentItemsByRelationParams<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
106
|
+
/** Declared top-level relation field on the source content type. */
|
|
107
|
+
field: string;
|
|
108
|
+
/** ID of the item referenced by the relation. */
|
|
109
|
+
targetId: string;
|
|
110
|
+
/** Number of items to return (default: 20). */
|
|
111
|
+
limit?: number;
|
|
112
|
+
/** Number of matching items to skip (default: 0). */
|
|
113
|
+
offset?: number;
|
|
114
|
+
}
|
|
115
|
+
/** A page of unique related items, ordered by creation time then ID descending. */
|
|
116
|
+
interface ContentItemsByRelationResult<TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
117
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
118
|
+
total: number;
|
|
119
|
+
limit: number;
|
|
120
|
+
offset: number;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Retrieve source items whose relation field references a target item.
|
|
124
|
+
* Relation rows are scanned completely, metadata is read in batches, and full
|
|
125
|
+
* content is fetched only for the requested page. Internal scans grow with the
|
|
126
|
+
* relation count; this does not promise constant query counts or native joins.
|
|
127
|
+
* Set `view: "content"` for identity, parsed content and serialized timestamps
|
|
128
|
+
* without the editor envelope. Omitting it preserves the full item response.
|
|
129
|
+
*
|
|
130
|
+
* @remarks This lower-level read does not authorize requests, validate relation
|
|
131
|
+
* configuration or target access, or compose lifecycle hooks. Callers own those
|
|
132
|
+
* checks and pagination validation. Use `forRequest(request).operations.cms` for
|
|
133
|
+
* request work or trusted operations for validated, lifecycle-aware server work.
|
|
134
|
+
*/
|
|
135
|
+
declare function getContentItemsByRelation<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params: ContentItemsByRelationParams<TView, TFields>): Promise<ContentItemsByRelationResult<TView, TFields>>;
|
|
104
136
|
|
|
105
137
|
declare const CMSContentTypeParamsSchema: z.ZodObject<{
|
|
106
138
|
slug: z.ZodString;
|
|
@@ -174,5 +206,5 @@ interface CreateCMSContentItemOptions {
|
|
|
174
206
|
*/
|
|
175
207
|
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
176
208
|
|
|
177
|
-
export { CMSContentItemParamsSchema, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
178
|
-
export type { CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
209
|
+
export { CMSContentFields, CMSContentItemParamsSchema, CMSContentItemResult, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSReadOptions, CMSReadView, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
210
|
+
export type { ContentItemsByRelationParams, ContentItemsByRelationResult, CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { cmsBackendPlugin } from '../../../packages/stack/src/plugins/cms/api/plugin.mjs';
|
|
2
|
-
export { getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, serializeContentItem, serializeContentItemWithType, serializeContentType } from '../../../packages/stack/src/plugins/cms/api/getters.mjs';
|
|
2
|
+
export { getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType } from '../../../packages/stack/src/plugins/cms/api/getters.mjs';
|
|
3
3
|
export { createCMSContentItem } from '../../../packages/stack/src/plugins/cms/api/mutations.mjs';
|
|
4
4
|
export { CMS_QUERY_KEYS } from '../../../packages/stack/src/plugins/cms/api/query-key-defs.mjs';
|
|
5
5
|
export { createCMSQueryKeys } from '../query-keys.mjs';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ResourceFormConfig, ResourceFormResult, ResourceSelectResult } from '@btst/stack/plugins/client/hooks';
|
|
2
|
-
import {
|
|
2
|
+
import { b as SerializedContentItemWithType, S as SerializedContentType, e as CMSContentTypeMap, I as InverseRelation } from '../../../../shared/stack.DrB3L7Ih.cjs';
|
|
3
|
+
import { CMSReadView, CMSContentFields, CMSReadOptions, CMSContentItemResult } from '../../api/index.cjs';
|
|
3
4
|
import 'zod';
|
|
4
5
|
|
|
5
6
|
interface UseContentTypesResult {
|
|
@@ -32,7 +33,7 @@ declare function useContentType(slug: string): {
|
|
|
32
33
|
error: Error | null;
|
|
33
34
|
refetch: () => void;
|
|
34
35
|
};
|
|
35
|
-
interface UseContentOptions {
|
|
36
|
+
interface UseContentOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
36
37
|
/** Number of items per page (default: 10) */
|
|
37
38
|
limit?: number;
|
|
38
39
|
/** Whether to enable the query (default: true) */
|
|
@@ -44,9 +45,9 @@ interface UseContentOptions {
|
|
|
44
45
|
* Result type for useContent hook with load more functionality
|
|
45
46
|
* @template TData - The type of parsedData (defaults to Record<string, unknown>)
|
|
46
47
|
*/
|
|
47
|
-
interface UseContentResult<TData = Record<string, unknown
|
|
48
|
+
interface UseContentResult<TData = Record<string, unknown>, TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
48
49
|
/** Array of all loaded content items */
|
|
49
|
-
items:
|
|
50
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
50
51
|
/** Total number of items available */
|
|
51
52
|
total: number;
|
|
52
53
|
/** Whether the initial load is in progress */
|
|
@@ -84,21 +85,38 @@ interface UseContentResult<TData = Record<string, unknown>> {
|
|
|
84
85
|
* // items[0].parsedData.price is number
|
|
85
86
|
* ```
|
|
86
87
|
*/
|
|
87
|
-
declare function useContent<TMap extends
|
|
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>;
|
|
88
97
|
/**
|
|
89
98
|
* Suspense variant of useContent with load more functionality.
|
|
90
99
|
*
|
|
91
100
|
* @template TMap - A type map of content type slugs to their data types
|
|
92
101
|
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
93
102
|
*/
|
|
94
|
-
|
|
95
|
-
items:
|
|
103
|
+
type SuspenseContentResult<TData, TView extends CMSReadView, TFields extends CMSContentFields = undefined> = {
|
|
104
|
+
items: CMSContentItemResult<TData, TView, TFields>[];
|
|
96
105
|
total: number;
|
|
97
106
|
loadMore: () => Promise<unknown>;
|
|
98
107
|
hasMore: boolean;
|
|
99
108
|
isLoadingMore: boolean;
|
|
100
109
|
refetch: () => Promise<unknown>;
|
|
101
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>;
|
|
102
120
|
/**
|
|
103
121
|
* Hook for fetching a single content item by ID with optional type safety.
|
|
104
122
|
*
|
|
@@ -112,22 +130,40 @@ declare function useSuspenseContent<TMap extends Record<string, Record<string, u
|
|
|
112
130
|
* // item?.parsedData.name is string
|
|
113
131
|
* ```
|
|
114
132
|
*/
|
|
115
|
-
|
|
116
|
-
item:
|
|
133
|
+
type ContentItemQueryResult<TData, TView extends CMSReadView, TFields extends CMSContentFields = undefined> = {
|
|
134
|
+
item: CMSContentItemResult<TData, TView, TFields> | null;
|
|
117
135
|
isLoading: boolean;
|
|
118
136
|
error: Error | null;
|
|
119
137
|
refetch: () => void;
|
|
120
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>;
|
|
121
148
|
/**
|
|
122
149
|
* Suspense variant of useContentItem with optional type safety.
|
|
123
150
|
*
|
|
124
151
|
* @template TMap - A type map of content type slugs to their data types
|
|
125
152
|
* @template TSlug - The content type slug (inferred from typeSlug parameter)
|
|
126
153
|
*/
|
|
127
|
-
|
|
128
|
-
item:
|
|
154
|
+
type SuspenseContentItemResult<TData, TView extends CMSReadView, TFields extends CMSContentFields = undefined> = {
|
|
155
|
+
item: CMSContentItemResult<TData, TView, TFields> | null;
|
|
129
156
|
refetch: () => Promise<unknown>;
|
|
130
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>;
|
|
131
167
|
/**
|
|
132
168
|
* Hook for fetching a content item by slug with optional type safety.
|
|
133
169
|
*
|
|
@@ -141,12 +177,15 @@ declare function useSuspenseContentItem<TMap extends Record<string, Record<strin
|
|
|
141
177
|
* // item?.parsedData.price is number
|
|
142
178
|
* ```
|
|
143
179
|
*/
|
|
144
|
-
declare function useContentItemBySlug<TMap extends
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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>;
|
|
150
189
|
/**
|
|
151
190
|
* Hook for creating a content item with optional type safety.
|
|
152
191
|
*
|
|
@@ -527,15 +566,16 @@ declare function useContentItemForm<TValues>(config: ResourceFormConfig<TValues,
|
|
|
527
566
|
* query, with selected ids missing from the current results preloaded via
|
|
528
567
|
* the `detail` query (typeSlug, id) so their labels resolve.
|
|
529
568
|
*
|
|
530
|
-
* Used by the relation picker (`RelationField`).
|
|
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.
|
|
531
571
|
*/
|
|
532
|
-
declare function useContentOptions(config: {
|
|
533
|
-
/** Content type slug to search within */
|
|
572
|
+
declare function useContentOptions<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(config: {
|
|
573
|
+
/** Content type slug to search within. */
|
|
534
574
|
targetType: string;
|
|
535
|
-
/** Currently selected
|
|
575
|
+
/** Currently selected IDs, preloaded when absent from search results. */
|
|
536
576
|
value: string[];
|
|
537
|
-
getOptionLabel: (item:
|
|
538
|
-
}): ResourceSelectResult<
|
|
577
|
+
getOptionLabel: (item: CMSContentItemResult<Record<string, unknown>, TView, TFields>) => string;
|
|
578
|
+
} & CMSReadOptions<TView, TFields>): ResourceSelectResult<CMSContentItemResult<Record<string, unknown>, TView, TFields>>;
|
|
539
579
|
/**
|
|
540
580
|
* Content item with populated relations
|
|
541
581
|
*/
|
|
@@ -575,7 +615,7 @@ declare function useSuspenseContentItemPopulated<TMap extends Record<string, Rec
|
|
|
575
615
|
/**
|
|
576
616
|
* Options for useContentByRelation hook
|
|
577
617
|
*/
|
|
578
|
-
interface UseContentByRelationOptions {
|
|
618
|
+
interface UseContentByRelationOptions<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
579
619
|
/** Number of items per page (default: 20) */
|
|
580
620
|
limit?: number;
|
|
581
621
|
/** Whether to enable the query (default: true) */
|
|
@@ -594,27 +634,27 @@ interface UseContentByRelationOptions {
|
|
|
594
634
|
* const { items } = useContentByRelation("resource", "categoryIds", categoryId)
|
|
595
635
|
* ```
|
|
596
636
|
*/
|
|
597
|
-
declare function useContentByRelation<TMap extends
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
};
|
|
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>;
|
|
607
646
|
/**
|
|
608
647
|
* Suspense variant of useContentByRelation
|
|
609
648
|
*/
|
|
610
|
-
declare function useSuspenseContentByRelation<TMap extends
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
}
|
|
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>;
|
|
618
658
|
/**
|
|
619
659
|
* Hook for fetching the inverse relations of a content item — the content
|
|
620
660
|
* types with belongsTo fields pointing at it, with per-field counts.
|
|
@@ -629,15 +669,20 @@ declare function useInverseRelations(contentTypeSlug: string, itemId: string): {
|
|
|
629
669
|
* Hook for listing the items behind one inverse relation (e.g. all comments
|
|
630
670
|
* whose `resourceId` points at this resource).
|
|
631
671
|
*/
|
|
632
|
-
declare function useInverseRelationItems(params: {
|
|
672
|
+
declare function useInverseRelationItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(params: {
|
|
633
673
|
contentTypeSlug: string;
|
|
634
674
|
sourceType: string;
|
|
635
675
|
itemId: string;
|
|
636
676
|
fieldName: string;
|
|
637
|
-
}, options?: {
|
|
677
|
+
}, options?: CMSReadOptions<TView, TFields> & {
|
|
678
|
+
/** Whether to enable the query (default: true). */
|
|
638
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;
|
|
639
684
|
}): {
|
|
640
|
-
items:
|
|
685
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
641
686
|
total: number;
|
|
642
687
|
isLoading: boolean;
|
|
643
688
|
error: Error | null;
|