@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.
Files changed (113) hide show
  1. package/dist/api/index.d.cts +2 -2
  2. package/dist/api/index.d.mts +2 -2
  3. package/dist/api/index.d.ts +2 -2
  4. package/dist/client/index.d.cts +2 -2
  5. package/dist/client/index.d.mts +2 -2
  6. package/dist/client/index.d.ts +2 -2
  7. package/dist/context/index.d.cts +1 -1
  8. package/dist/context/index.d.mts +1 -1
  9. package/dist/context/index.d.ts +1 -1
  10. package/dist/index.d.cts +1 -1
  11. package/dist/index.d.mts +1 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/packages/stack/src/plugins/cms/api/getters.cjs +142 -6
  14. package/dist/packages/stack/src/plugins/cms/api/getters.mjs +139 -8
  15. package/dist/packages/stack/src/plugins/cms/api/operations.cjs +67 -61
  16. package/dist/packages/stack/src/plugins/cms/api/operations.mjs +69 -63
  17. package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +26 -8
  18. package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +27 -9
  19. package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +15 -1
  20. package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +14 -2
  21. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.cjs +45 -24
  22. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.mjs +45 -24
  23. package/dist/packages/stack/src/plugins/cms/schemas.cjs +22 -0
  24. package/dist/packages/stack/src/plugins/cms/schemas.mjs +20 -1
  25. package/dist/plugins/api/index.d.cts +2 -2
  26. package/dist/plugins/api/index.d.mts +2 -2
  27. package/dist/plugins/api/index.d.ts +2 -2
  28. package/dist/plugins/blog/api/index.d.cts +2 -2
  29. package/dist/plugins/blog/api/index.d.mts +2 -2
  30. package/dist/plugins/blog/api/index.d.ts +2 -2
  31. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  32. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  33. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  34. package/dist/plugins/blog/client/index.d.cts +2 -2
  35. package/dist/plugins/blog/client/index.d.mts +2 -2
  36. package/dist/plugins/blog/client/index.d.ts +2 -2
  37. package/dist/plugins/blog/query-keys.d.cts +2 -2
  38. package/dist/plugins/blog/query-keys.d.mts +2 -2
  39. package/dist/plugins/blog/query-keys.d.ts +2 -2
  40. package/dist/plugins/client/index.d.cts +2 -2
  41. package/dist/plugins/client/index.d.mts +2 -2
  42. package/dist/plugins/client/index.d.ts +2 -2
  43. package/dist/plugins/cms/api/index.cjs +1 -0
  44. package/dist/plugins/cms/api/index.d.cts +43 -11
  45. package/dist/plugins/cms/api/index.d.mts +43 -11
  46. package/dist/plugins/cms/api/index.d.ts +43 -11
  47. package/dist/plugins/cms/api/index.mjs +1 -1
  48. package/dist/plugins/cms/client/hooks/index.d.cts +90 -45
  49. package/dist/plugins/cms/client/hooks/index.d.mts +90 -45
  50. package/dist/plugins/cms/client/hooks/index.d.ts +90 -45
  51. package/dist/plugins/cms/client/index.d.cts +2 -1
  52. package/dist/plugins/cms/client/index.d.mts +2 -1
  53. package/dist/plugins/cms/client/index.d.ts +2 -1
  54. package/dist/plugins/cms/query-keys.cjs +69 -13
  55. package/dist/plugins/cms/query-keys.d.cts +89 -212
  56. package/dist/plugins/cms/query-keys.d.mts +89 -212
  57. package/dist/plugins/cms/query-keys.d.ts +89 -212
  58. package/dist/plugins/cms/query-keys.mjs +70 -14
  59. package/dist/plugins/kanban/client/index.d.cts +1 -1
  60. package/dist/plugins/kanban/client/index.d.mts +1 -1
  61. package/dist/plugins/kanban/client/index.d.ts +1 -1
  62. package/dist/plugins/route-docs/client/index.d.cts +1 -1
  63. package/dist/plugins/route-docs/client/index.d.mts +1 -1
  64. package/dist/plugins/route-docs/client/index.d.ts +1 -1
  65. package/dist/plugins/ui-builder/client/hooks/index.d.cts +3 -3
  66. package/dist/plugins/ui-builder/client/hooks/index.d.mts +3 -3
  67. package/dist/plugins/ui-builder/client/hooks/index.d.ts +3 -3
  68. package/dist/plugins/ui-builder/client/index.d.cts +3 -3
  69. package/dist/plugins/ui-builder/client/index.d.mts +3 -3
  70. package/dist/plugins/ui-builder/client/index.d.ts +3 -3
  71. package/dist/plugins/ui-builder/query-keys.d.cts +4 -3
  72. package/dist/plugins/ui-builder/query-keys.d.mts +4 -3
  73. package/dist/plugins/ui-builder/query-keys.d.ts +4 -3
  74. package/dist/shared/{stack.DMj68qY0.d.mts → stack.B2jlVVhD.d.mts} +5 -5
  75. package/dist/shared/{stack.Cvnj99cs.d.ts → stack.BB9tubJJ.d.ts} +9 -3
  76. package/dist/shared/{stack.Bt3WG2yb.d.cts → stack.BWduIMKG.d.cts} +35 -35
  77. package/dist/shared/stack.Bw09Lg2z.d.ts +1420 -0
  78. package/dist/shared/{stack.CkEz7vSt.d.mts → stack.C2Pvl-RS.d.mts} +9 -3
  79. package/dist/shared/{stack.C2l2wd_X.d.ts → stack.Ch9-ppmQ.d.ts} +35 -35
  80. package/dist/shared/{stack.Ht8mhDj5.d.cts → stack.D17yFglU.d.cts} +5 -5
  81. package/dist/shared/{stack.CiD115Ov.d.mts → stack.D6fPBfYe.d.mts} +35 -35
  82. package/dist/shared/stack.DFGj0gb7.d.mts +1420 -0
  83. package/dist/shared/{stack.pi0FxoEa.d.ts → stack.Dcfg4GNN.d.ts} +5 -5
  84. package/dist/shared/{stack.3rxARhgS.d.cts → stack.DrB3L7Ih.d.cts} +52 -3
  85. package/dist/shared/{stack.3rxARhgS.d.mts → stack.DrB3L7Ih.d.mts} +52 -3
  86. package/dist/shared/{stack.3rxARhgS.d.ts → stack.DrB3L7Ih.d.ts} +52 -3
  87. package/dist/shared/stack.NNrBKBkM.d.cts +1420 -0
  88. package/dist/shared/{stack.mRRyZBUg.d.cts → stack.Rb87lHqK.d.cts} +9 -3
  89. package/package.json +1 -1
  90. package/src/__tests__/cms-query-keys.test.ts +57 -0
  91. package/src/plugins/api/index.ts +1 -0
  92. package/src/plugins/api/operation.ts +16 -3
  93. package/src/plugins/cms/__tests__/authorization.test.ts +652 -187
  94. package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +655 -0
  95. package/src/plugins/cms/__tests__/content-read.typecheck.ts +351 -0
  96. package/src/plugins/cms/__tests__/getters.test.ts +286 -0
  97. package/src/plugins/cms/api/getters.ts +270 -12
  98. package/src/plugins/cms/api/index.ts +10 -0
  99. package/src/plugins/cms/api/operations.ts +163 -75
  100. package/src/plugins/cms/api/plugin.ts +50 -12
  101. package/src/plugins/cms/api/query-key-defs.ts +29 -2
  102. package/src/plugins/cms/client/hooks/cms-hooks.tsx +400 -91
  103. package/src/plugins/cms/client/index.ts +9 -0
  104. package/src/plugins/cms/query-keys.ts +171 -16
  105. package/src/plugins/cms/schemas.ts +30 -0
  106. package/src/plugins/cms/types.ts +49 -2
  107. package/src/plugins/media/__tests__/identity-partition.test.tsx +26 -16
  108. package/dist/shared/stack.CAmVUwjV.d.cts +0 -764
  109. package/dist/shared/stack.CQK02ujt.d.ts +0 -764
  110. package/dist/shared/stack.D9x1fR5a.d.mts +0 -764
  111. package/dist/shared/{stack.CKc_Bais.d.cts → stack.Csi-4Mgz.d.cts} +7 -7
  112. package/dist/shared/{stack.CKc_Bais.d.mts → stack.Csi-4Mgz.d.mts} +7 -7
  113. package/dist/shared/{stack.CKc_Bais.d.ts → stack.Csi-4Mgz.d.ts} +7 -7
@@ -1,5 +1,5 @@
1
- import { p as ClientPluginDefinition } from '../../shared/stack.mRRyZBUg.cjs';
2
- export { C as ClientPlugin, q as ClientPluginRegistration, P as PluginOverrides, r as ResolvedClientPluginRuntime } from '../../shared/stack.mRRyZBUg.cjs';
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 { p as ClientPluginDefinition } from '../../shared/stack.CkEz7vSt.mjs';
2
- export { C as ClientPlugin, q as ClientPluginRegistration, P as PluginOverrides, r as ResolvedClientPluginRuntime } from '../../shared/stack.CkEz7vSt.mjs';
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 { p as ClientPluginDefinition } from '../../shared/stack.Cvnj99cs.js';
2
- export { C as ClientPlugin, q as ClientPluginRegistration, P as PluginOverrides, r as ResolvedClientPluginRuntime } from '../../shared/stack.Cvnj99cs.js';
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.CAmVUwjV.cjs';
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 SerializedContentItemWithType, S as SerializedContentType, b as ContentItem, c as SerializedContentItem, d as ContentItemWithType, e as ContentType } from '../../../shared/stack.3rxARhgS.cjs';
4
- export { C as CMSBackendConfig, f as CMSBackendHooks, g as CMSCreateOperationContext, h as CMSCreateResultContext, i as CMSDeleteOperationContext, j as CMSDeleteResultContext, k as CMSOperationErrorContext, l as CMSOperationLifecycleContext, m as CMSUpdateOperationContext, n as CMSUpdateResultContext, o as ContentTypeConfig } from '../../../shared/stack.3rxARhgS.cjs';
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: SerializedContentItemWithType[];
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<SerializedContentItemWithType | null>;
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<SerializedContentItemWithType | null>;
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.D9x1fR5a.mjs';
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 SerializedContentItemWithType, S as SerializedContentType, b as ContentItem, c as SerializedContentItem, d as ContentItemWithType, e as ContentType } from '../../../shared/stack.3rxARhgS.mjs';
4
- export { C as CMSBackendConfig, f as CMSBackendHooks, g as CMSCreateOperationContext, h as CMSCreateResultContext, i as CMSDeleteOperationContext, j as CMSDeleteResultContext, k as CMSOperationErrorContext, l as CMSOperationLifecycleContext, m as CMSUpdateOperationContext, n as CMSUpdateResultContext, o as ContentTypeConfig } from '../../../shared/stack.3rxARhgS.mjs';
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: SerializedContentItemWithType[];
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<SerializedContentItemWithType | null>;
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<SerializedContentItemWithType | null>;
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.CQK02ujt.js';
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 SerializedContentItemWithType, S as SerializedContentType, b as ContentItem, c as SerializedContentItem, d as ContentItemWithType, e as ContentType } from '../../../shared/stack.3rxARhgS.js';
4
- export { C as CMSBackendConfig, f as CMSBackendHooks, g as CMSCreateOperationContext, h as CMSCreateResultContext, i as CMSDeleteOperationContext, j as CMSDeleteResultContext, k as CMSOperationErrorContext, l as CMSOperationLifecycleContext, m as CMSUpdateOperationContext, n as CMSUpdateResultContext, o as ContentTypeConfig } from '../../../shared/stack.3rxARhgS.js';
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: SerializedContentItemWithType[];
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<SerializedContentItemWithType | null>;
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<SerializedContentItemWithType | null>;
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 { a as SerializedContentItemWithType, S as SerializedContentType, I as InverseRelation } from '../../../../shared/stack.3rxARhgS.cjs';
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: SerializedContentItemWithType<TData>[];
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 Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, options?: UseContentOptions): UseContentResult<TMap[TSlug]>;
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
- declare function useSuspenseContent<TMap extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, options?: UseContentOptions): {
95
- items: SerializedContentItemWithType<TMap[TSlug]>[];
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
- declare function useContentItem<TMap extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, id: string): {
116
- item: SerializedContentItemWithType<TMap[TSlug]> | null;
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
- declare function useSuspenseContentItem<TMap extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, id: string): {
128
- item: SerializedContentItemWithType<TMap[TSlug]> | null;
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 Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, slug: string): {
145
- item: SerializedContentItemWithType<TMap[TSlug]> | null;
146
- isLoading: boolean;
147
- error: Error | null;
148
- refetch: () => void;
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 item ids — preloaded when missing from options */
575
+ /** Currently selected IDs, preloaded when absent from search results. */
536
576
  value: string[];
537
- getOptionLabel: (item: SerializedContentItemWithType) => string;
538
- }): ResourceSelectResult<SerializedContentItemWithType>;
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 Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, fieldName: string, targetId: string, options?: UseContentByRelationOptions): {
598
- items: SerializedContentItemWithType<TMap[TSlug]>[];
599
- total: number;
600
- isLoading: boolean;
601
- error: Error | null;
602
- loadMore: () => void;
603
- hasMore: boolean;
604
- isLoadingMore: boolean;
605
- refetch: () => void;
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 Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>, TSlug extends keyof TMap = keyof TMap>(typeSlug: TSlug & string, fieldName: string, targetId: string, options?: UseContentByRelationOptions): {
611
- items: SerializedContentItemWithType<TMap[TSlug]>[];
612
- total: number;
613
- loadMore: () => Promise<unknown>;
614
- hasMore: boolean;
615
- isLoadingMore: boolean;
616
- refetch: () => Promise<unknown>;
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: SerializedContentItemWithType[];
685
+ items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
641
686
  total: number;
642
687
  isLoading: boolean;
643
688
  error: Error | null;