@btst/plugin-cms 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +17 -0
- package/dist/api/getters.cjs +328 -0
- package/dist/api/getters.mjs +314 -0
- package/dist/api/index.cjs +29 -0
- package/dist/api/index.d.cts +209 -0
- package/dist/api/index.d.mts +209 -0
- package/dist/api/index.d.ts +209 -0
- package/dist/api/index.mjs +7 -0
- package/dist/api/lifecycle-migrations.cjs +13 -0
- package/dist/api/lifecycle-migrations.mjs +11 -0
- package/dist/api/mutations.cjs +59 -0
- package/dist/api/mutations.mjs +57 -0
- package/dist/api/operations.cjs +1769 -0
- package/dist/api/operations.mjs +1762 -0
- package/dist/api/plugin.cjs +337 -0
- package/dist/api/plugin.mjs +331 -0
- package/dist/api/query-key-defs.cjs +44 -0
- package/dist/api/query-key-defs.mjs +39 -0
- package/dist/api/relations.cjs +76 -0
- package/dist/api/relations.mjs +70 -0
- package/dist/client/components/forms/content-form.cjs +286 -0
- package/dist/client/components/forms/content-form.mjs +284 -0
- package/dist/client/components/forms/file-upload.cjs +160 -0
- package/dist/client/components/forms/file-upload.mjs +158 -0
- package/dist/client/components/forms/relation-field.cjs +237 -0
- package/dist/client/components/forms/relation-field.mjs +235 -0
- package/dist/client/components/index.cjs +14 -0
- package/dist/client/components/index.d.cts +20 -0
- package/dist/client/components/index.d.mts +20 -0
- package/dist/client/components/index.d.ts +20 -0
- package/dist/client/components/index.mjs +10 -0
- package/dist/client/components/inverse-relations-panel.cjs +272 -0
- package/dist/client/components/inverse-relations-panel.mjs +270 -0
- package/dist/client/components/loading/dashboard-skeleton.cjs +18 -0
- package/dist/client/components/loading/dashboard-skeleton.mjs +16 -0
- package/dist/client/components/loading/editor-skeleton.cjs +32 -0
- package/dist/client/components/loading/editor-skeleton.mjs +30 -0
- package/dist/client/components/loading/list-skeleton.cjs +32 -0
- package/dist/client/components/loading/list-skeleton.mjs +30 -0
- package/dist/client/components/pages/404-page.cjs +26 -0
- package/dist/client/components/pages/404-page.mjs +24 -0
- package/dist/client/components/pages/content-editor-page.cjs +84 -0
- package/dist/client/components/pages/content-editor-page.internal.cjs +170 -0
- package/dist/client/components/pages/content-editor-page.internal.mjs +168 -0
- package/dist/client/components/pages/content-editor-page.mjs +82 -0
- package/dist/client/components/pages/content-list-page.cjs +49 -0
- package/dist/client/components/pages/content-list-page.internal.cjs +334 -0
- package/dist/client/components/pages/content-list-page.internal.mjs +332 -0
- package/dist/client/components/pages/content-list-page.mjs +47 -0
- package/dist/client/components/pages/dashboard-page.cjs +42 -0
- package/dist/client/components/pages/dashboard-page.internal.cjs +102 -0
- package/dist/client/components/pages/dashboard-page.internal.mjs +100 -0
- package/dist/client/components/pages/dashboard-page.mjs +40 -0
- package/dist/client/components/shared/default-error.cjs +17 -0
- package/dist/client/components/shared/default-error.mjs +15 -0
- package/dist/client/components/shared/empty-state.cjs +16 -0
- package/dist/client/components/shared/empty-state.mjs +14 -0
- package/dist/client/components/shared/page-wrapper.cjs +29 -0
- package/dist/client/components/shared/page-wrapper.mjs +27 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/cms-hooks.cjs +300 -0
- package/dist/client/hooks/cms-hooks.mjs +280 -0
- package/dist/client/hooks/cms-resource.cjs +13 -0
- package/dist/client/hooks/cms-resource.mjs +11 -0
- package/dist/client/hooks/index.cjs +25 -0
- package/dist/client/hooks/index.d.cts +693 -0
- package/dist/client/hooks/index.d.mts +693 -0
- package/dist/client/hooks/index.d.ts +693 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.cjs +15 -0
- package/dist/client/index.d.cts +654 -0
- package/dist/client/index.d.mts +654 -0
- package/dist/client/index.d.ts +654 -0
- package/dist/client/index.mjs +3 -0
- package/dist/client/overrides.cjs +26 -0
- package/dist/client/overrides.mjs +24 -0
- package/dist/client/plugin.cjs +316 -0
- package/dist/client/plugin.mjs +314 -0
- package/dist/client.css +3 -0
- package/dist/db.cjs +118 -0
- package/dist/db.mjs +116 -0
- package/dist/permissions.cjs +46 -0
- package/dist/permissions.d.cts +42 -0
- package/dist/permissions.d.mts +42 -0
- package/dist/permissions.d.ts +42 -0
- package/dist/permissions.mjs +44 -0
- package/dist/query-keys.cjs +229 -0
- package/dist/query-keys.d.cts +8 -0
- package/dist/query-keys.d.mts +8 -0
- package/dist/query-keys.d.ts +8 -0
- package/dist/query-keys.mjs +225 -0
- package/dist/schemas.cjs +81 -0
- package/dist/schemas.mjs +72 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.cts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.mts +6 -0
- package/dist/shared/plugin-cms.BBshPRkb.d.ts +6 -0
- package/dist/shared/plugin-cms.DQLAoogy.d.ts +1749 -0
- package/dist/shared/plugin-cms.W4Le8D91.d.mts +1749 -0
- package/dist/shared/plugin-cms.c-GeWvTf.d.cts +1749 -0
- package/dist/style.css +6 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +406 -0
- package/dist/types.d.mts +406 -0
- package/dist/types.d.ts +406 -0
- package/dist/types.mjs +1 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/alert-dialog.cjs +157 -0
- package/dist/ui/src/components/alert-dialog.mjs +132 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +92 -0
- package/dist/ui/src/components/auto-form/index.mjs +86 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/badge.cjs +42 -0
- package/dist/ui/src/components/badge.mjs +39 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/card.cjs +56 -0
- package/dist/ui/src/components/card.mjs +51 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/command.cjs +78 -0
- package/dist/ui/src/components/command.mjs +73 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +119 -0
- package/dist/ui/src/components/dialog.mjs +97 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/multi-select.cjs +555 -0
- package/dist/ui/src/components/multi-select.mjs +540 -0
- package/dist/ui/src/components/page-layout.cjs +25 -0
- package/dist/ui/src/components/page-layout.mjs +23 -0
- package/dist/ui/src/components/page-wrapper.cjs +20 -0
- package/dist/ui/src/components/page-wrapper.mjs +18 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/skeleton.cjs +17 -0
- package/dist/ui/src/components/skeleton.mjs +15 -0
- package/dist/ui/src/components/stack-attribution.cjs +24 -0
- package/dist/ui/src/components/stack-attribution.mjs +22 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/table.cjs +89 -0
- package/dist/ui/src/components/table.mjs +82 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/hooks/use-debounce.cjs +16 -0
- package/dist/ui/src/hooks/use-debounce.mjs +14 -0
- package/dist/ui/src/hooks/use-route-lifecycle.cjs +31 -0
- package/dist/ui/src/hooks/use-route-lifecycle.mjs +29 -0
- package/dist/ui/src/lib/schema-converter.cjs +133 -0
- package/dist/ui/src/lib/schema-converter.mjs +127 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/utils.cjs +19 -0
- package/dist/utils.mjs +12 -0
- package/package.json +170 -3
- package/README.md +0 -3
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export { C as CMSApiRouter, a as CMSRouteKey, b as CMS_QUERY_KEYS, c as cmsBackendPlugin, d as createCMSQueryKeys } from '../shared/plugin-cms.c-GeWvTf.cjs';
|
|
2
|
+
import { DBAdapter } from '@btst/db';
|
|
3
|
+
import { CMSReadView, CMSContentFields, CMSReadOptions, CMSContentItemResult, SerializedContentType, ContentItem, SerializedContentItem, ContentItemWithType, SerializedContentItemWithType, ContentType } from '../types.cjs';
|
|
4
|
+
export { CMSBackendConfig, CMSBackendHooks, CMSCreateOperationContext, CMSCreateResultContext, CMSDeleteOperationContext, CMSDeleteResultContext, CMSOperationErrorContext, CMSOperationLifecycleContext, CMSSelectedData, CMSUpdateOperationContext, CMSUpdateResultContext, ContentTypeConfig, PaginatedContentItems, SerializedContentItemContent } from '../types.cjs';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import '@btst/stack/plugins/client';
|
|
7
|
+
import '@btst/stack/authorization';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
|
+
import 'better-call';
|
|
10
|
+
import '@tanstack/react-query';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Removed CMS lifecycle names and their canonical v3 replacements.
|
|
14
|
+
*
|
|
15
|
+
* The aggregate error callback remains one phase. Its operation argument
|
|
16
|
+
* distinguishes create, update, delete, list, and get failures.
|
|
17
|
+
*/
|
|
18
|
+
declare const CMS_LIFECYCLE_HOOK_MIGRATIONS: Readonly<{
|
|
19
|
+
readonly onBeforeCreate: "onBeforeCreateContent";
|
|
20
|
+
readonly onAfterCreate: "onAfterCreateContent";
|
|
21
|
+
readonly onBeforeUpdate: "onBeforeUpdateContent";
|
|
22
|
+
readonly onAfterUpdate: "onAfterUpdateContent";
|
|
23
|
+
readonly onBeforeDelete: "onBeforeDeleteContent";
|
|
24
|
+
readonly onAfterDelete: "onAfterDeleteContent";
|
|
25
|
+
readonly onError: "onErrorExecuteContentOperation";
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a ContentType for SSR/SSG use (convert dates to strings).
|
|
30
|
+
* Applies lazy migration for legacy schemas (version 1 → 2).
|
|
31
|
+
*/
|
|
32
|
+
declare function serializeContentType(ct: ContentType): SerializedContentType;
|
|
33
|
+
/**
|
|
34
|
+
* Serialize a ContentItem for SSR/SSG use (convert dates to strings).
|
|
35
|
+
*/
|
|
36
|
+
declare function serializeContentItem(item: ContentItem): SerializedContentItem;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize a ContentItem with parsed data and joined ContentType.
|
|
39
|
+
* Throws a SyntaxError if `item.data` is not valid JSON, so corrupted rows
|
|
40
|
+
* produce a visible, debuggable error rather than silently returning null.
|
|
41
|
+
*/
|
|
42
|
+
declare function serializeContentItemWithType(item: ContentItemWithType): SerializedContentItemWithType;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve all content types.
|
|
45
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
46
|
+
*
|
|
47
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
48
|
+
* responsible for any access-control checks before invoking this function.
|
|
49
|
+
*
|
|
50
|
+
* @param adapter - The database adapter
|
|
51
|
+
*/
|
|
52
|
+
declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedContentType[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve all content items for a given content type, with optional pagination
|
|
55
|
+
* and free-text search.
|
|
56
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
57
|
+
*
|
|
58
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT
|
|
59
|
+
* called. The caller is responsible for any access-control checks before
|
|
60
|
+
* invoking this function.
|
|
61
|
+
*
|
|
62
|
+
* @param adapter - The database adapter
|
|
63
|
+
* @param contentTypeSlug - The slug of the content type to query
|
|
64
|
+
* @param params - Optional filter/pagination parameters. `search` matches
|
|
65
|
+
* case-insensitively against item slugs and string values in the item data.
|
|
66
|
+
*/
|
|
67
|
+
declare function getAllContentItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
68
|
+
slug?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
search?: string;
|
|
72
|
+
} & CMSReadOptions<TView, TFields>): Promise<{
|
|
73
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
74
|
+
total: number;
|
|
75
|
+
limit?: number;
|
|
76
|
+
offset?: number;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieve a single content item by its ID.
|
|
80
|
+
* Returns null if the item is not found.
|
|
81
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
82
|
+
*
|
|
83
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
84
|
+
* responsible for any access-control checks before invoking this function.
|
|
85
|
+
*
|
|
86
|
+
* @param adapter - The database adapter
|
|
87
|
+
* @param id - The content item ID (UUID)
|
|
88
|
+
*/
|
|
89
|
+
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>;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve a single content item by its slug within a content type.
|
|
92
|
+
* Returns null if the content type or item is not found.
|
|
93
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
94
|
+
*
|
|
95
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
96
|
+
* responsible for any access-control checks before invoking this function.
|
|
97
|
+
*
|
|
98
|
+
* @param adapter - The database adapter
|
|
99
|
+
* @param contentTypeSlug - The slug of the content type
|
|
100
|
+
* @param slug - The slug of the content item
|
|
101
|
+
*/
|
|
102
|
+
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>;
|
|
103
|
+
/** Parameters for a page of items referencing one relation target. */
|
|
104
|
+
interface ContentItemsByRelationParams<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
105
|
+
/** Declared top-level relation field on the source content type. */
|
|
106
|
+
field: string;
|
|
107
|
+
/** ID of the item referenced by the relation. */
|
|
108
|
+
targetId: string;
|
|
109
|
+
/** Number of items to return (default: 20). */
|
|
110
|
+
limit?: number;
|
|
111
|
+
/** Number of matching items to skip (default: 0). */
|
|
112
|
+
offset?: number;
|
|
113
|
+
}
|
|
114
|
+
/** A page of unique related items, ordered by creation time then ID descending. */
|
|
115
|
+
interface ContentItemsByRelationResult<TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
116
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
117
|
+
total: number;
|
|
118
|
+
limit: number;
|
|
119
|
+
offset: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve source items whose relation field references a target item.
|
|
123
|
+
* Relation rows are scanned completely, metadata is read in batches, and full
|
|
124
|
+
* content is fetched only for the requested page. Internal scans grow with the
|
|
125
|
+
* relation count; this does not promise constant query counts or native joins.
|
|
126
|
+
* Set `view: "content"` for identity, parsed content and serialized timestamps
|
|
127
|
+
* without the editor envelope. Omitting it preserves the full item response.
|
|
128
|
+
*
|
|
129
|
+
* @remarks This lower-level read does not authorize requests, validate relation
|
|
130
|
+
* configuration or target access, or compose lifecycle hooks. Callers own those
|
|
131
|
+
* checks and pagination validation. Use `forRequest(request).operations.cms` for
|
|
132
|
+
* request work or trusted operations for validated, lifecycle-aware server work.
|
|
133
|
+
*/
|
|
134
|
+
declare function getContentItemsByRelation<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params: ContentItemsByRelationParams<TView, TFields>): Promise<ContentItemsByRelationResult<TView, TFields>>;
|
|
135
|
+
|
|
136
|
+
declare const CMSContentTypeParamsSchema: z.ZodObject<{
|
|
137
|
+
slug: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
declare const CMSContentItemParamsSchema: z.ZodObject<{
|
|
140
|
+
typeSlug: z.ZodString;
|
|
141
|
+
id: z.ZodString;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
declare const CMSCreateContentItemBodySchema: z.ZodObject<{
|
|
144
|
+
slug: z.ZodString;
|
|
145
|
+
data: z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
declare const CMSUpdateContentItemBodySchema: z.ZodObject<{
|
|
148
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
149
|
+
data: z.ZodOptional<z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Input for creating a new CMS content item.
|
|
154
|
+
*/
|
|
155
|
+
interface CreateCMSContentItemInput {
|
|
156
|
+
/** URL-safe slug for the item */
|
|
157
|
+
slug: string;
|
|
158
|
+
/** Arbitrary data payload — should match the content type schema */
|
|
159
|
+
data: Record<string, unknown>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for {@link createCMSContentItem}.
|
|
163
|
+
*/
|
|
164
|
+
interface CreateCMSContentItemOptions {
|
|
165
|
+
/**
|
|
166
|
+
* When `true`, persist relation fields (`belongsTo`, `hasMany`,
|
|
167
|
+
* `manyToMany`) into the `contentRelation` junction table in addition to
|
|
168
|
+
* the item's JSON payload.
|
|
169
|
+
*
|
|
170
|
+
* This is what the HTTP `POST /content/:typeSlug` route does, and is
|
|
171
|
+
* required for the admin "Related Items" panel / inverse-relation queries
|
|
172
|
+
* to find the item.
|
|
173
|
+
*
|
|
174
|
+
* Seeds and other programmatic callers that want the admin UI to work
|
|
175
|
+
* should enable this flag. Callers are still expected to pass
|
|
176
|
+
* pre-created target IDs (`{ id }` or `[{ id }, ...]`) — inline `_new`
|
|
177
|
+
* creation is only supported via the HTTP route.
|
|
178
|
+
*
|
|
179
|
+
* Defaults to `false` for backwards compatibility (a no-op for content
|
|
180
|
+
* types without relations).
|
|
181
|
+
*/
|
|
182
|
+
syncRelations?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a new content item for a content type (looked up by slug).
|
|
186
|
+
*
|
|
187
|
+
* Bypasses Zod schema validation and inline `_new` relation creation — the
|
|
188
|
+
* caller is responsible for providing valid data and pre-created relation
|
|
189
|
+
* IDs. For schema validation or inline creation of related items, use the
|
|
190
|
+
* HTTP endpoint instead.
|
|
191
|
+
*
|
|
192
|
+
* Throws if the content type is not found or the slug is already taken within
|
|
193
|
+
* that content type.
|
|
194
|
+
*
|
|
195
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are not
|
|
196
|
+
* called. The caller is responsible for any access-control checks before
|
|
197
|
+
* invoking this function.
|
|
198
|
+
*
|
|
199
|
+
* @param adapter - The database adapter
|
|
200
|
+
* @param contentTypeSlug - Slug of the target content type
|
|
201
|
+
* @param input - Item slug and data payload
|
|
202
|
+
* @param options - See {@link CreateCMSContentItemOptions}. Pass
|
|
203
|
+
* `{ syncRelations: true }` to also populate the `contentRelation`
|
|
204
|
+
* junction table for relation fields in the payload.
|
|
205
|
+
*/
|
|
206
|
+
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
207
|
+
|
|
208
|
+
export { CMSContentFields, CMSContentItemParamsSchema, CMSContentItemResult, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSReadOptions, CMSReadView, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
209
|
+
export type { ContentItemsByRelationParams, ContentItemsByRelationResult, CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export { C as CMSApiRouter, a as CMSRouteKey, b as CMS_QUERY_KEYS, c as cmsBackendPlugin, d as createCMSQueryKeys } from '../shared/plugin-cms.W4Le8D91.mjs';
|
|
2
|
+
import { DBAdapter } from '@btst/db';
|
|
3
|
+
import { CMSReadView, CMSContentFields, CMSReadOptions, CMSContentItemResult, SerializedContentType, ContentItem, SerializedContentItem, ContentItemWithType, SerializedContentItemWithType, ContentType } from '../types.mjs';
|
|
4
|
+
export { CMSBackendConfig, CMSBackendHooks, CMSCreateOperationContext, CMSCreateResultContext, CMSDeleteOperationContext, CMSDeleteResultContext, CMSOperationErrorContext, CMSOperationLifecycleContext, CMSSelectedData, CMSUpdateOperationContext, CMSUpdateResultContext, ContentTypeConfig, PaginatedContentItems, SerializedContentItemContent } from '../types.mjs';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import '@btst/stack/plugins/client';
|
|
7
|
+
import '@btst/stack/authorization';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
|
+
import 'better-call';
|
|
10
|
+
import '@tanstack/react-query';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Removed CMS lifecycle names and their canonical v3 replacements.
|
|
14
|
+
*
|
|
15
|
+
* The aggregate error callback remains one phase. Its operation argument
|
|
16
|
+
* distinguishes create, update, delete, list, and get failures.
|
|
17
|
+
*/
|
|
18
|
+
declare const CMS_LIFECYCLE_HOOK_MIGRATIONS: Readonly<{
|
|
19
|
+
readonly onBeforeCreate: "onBeforeCreateContent";
|
|
20
|
+
readonly onAfterCreate: "onAfterCreateContent";
|
|
21
|
+
readonly onBeforeUpdate: "onBeforeUpdateContent";
|
|
22
|
+
readonly onAfterUpdate: "onAfterUpdateContent";
|
|
23
|
+
readonly onBeforeDelete: "onBeforeDeleteContent";
|
|
24
|
+
readonly onAfterDelete: "onAfterDeleteContent";
|
|
25
|
+
readonly onError: "onErrorExecuteContentOperation";
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a ContentType for SSR/SSG use (convert dates to strings).
|
|
30
|
+
* Applies lazy migration for legacy schemas (version 1 → 2).
|
|
31
|
+
*/
|
|
32
|
+
declare function serializeContentType(ct: ContentType): SerializedContentType;
|
|
33
|
+
/**
|
|
34
|
+
* Serialize a ContentItem for SSR/SSG use (convert dates to strings).
|
|
35
|
+
*/
|
|
36
|
+
declare function serializeContentItem(item: ContentItem): SerializedContentItem;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize a ContentItem with parsed data and joined ContentType.
|
|
39
|
+
* Throws a SyntaxError if `item.data` is not valid JSON, so corrupted rows
|
|
40
|
+
* produce a visible, debuggable error rather than silently returning null.
|
|
41
|
+
*/
|
|
42
|
+
declare function serializeContentItemWithType(item: ContentItemWithType): SerializedContentItemWithType;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve all content types.
|
|
45
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
46
|
+
*
|
|
47
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
48
|
+
* responsible for any access-control checks before invoking this function.
|
|
49
|
+
*
|
|
50
|
+
* @param adapter - The database adapter
|
|
51
|
+
*/
|
|
52
|
+
declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedContentType[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve all content items for a given content type, with optional pagination
|
|
55
|
+
* and free-text search.
|
|
56
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
57
|
+
*
|
|
58
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT
|
|
59
|
+
* called. The caller is responsible for any access-control checks before
|
|
60
|
+
* invoking this function.
|
|
61
|
+
*
|
|
62
|
+
* @param adapter - The database adapter
|
|
63
|
+
* @param contentTypeSlug - The slug of the content type to query
|
|
64
|
+
* @param params - Optional filter/pagination parameters. `search` matches
|
|
65
|
+
* case-insensitively against item slugs and string values in the item data.
|
|
66
|
+
*/
|
|
67
|
+
declare function getAllContentItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
68
|
+
slug?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
search?: string;
|
|
72
|
+
} & CMSReadOptions<TView, TFields>): Promise<{
|
|
73
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
74
|
+
total: number;
|
|
75
|
+
limit?: number;
|
|
76
|
+
offset?: number;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieve a single content item by its ID.
|
|
80
|
+
* Returns null if the item is not found.
|
|
81
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
82
|
+
*
|
|
83
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
84
|
+
* responsible for any access-control checks before invoking this function.
|
|
85
|
+
*
|
|
86
|
+
* @param adapter - The database adapter
|
|
87
|
+
* @param id - The content item ID (UUID)
|
|
88
|
+
*/
|
|
89
|
+
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>;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve a single content item by its slug within a content type.
|
|
92
|
+
* Returns null if the content type or item is not found.
|
|
93
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
94
|
+
*
|
|
95
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
96
|
+
* responsible for any access-control checks before invoking this function.
|
|
97
|
+
*
|
|
98
|
+
* @param adapter - The database adapter
|
|
99
|
+
* @param contentTypeSlug - The slug of the content type
|
|
100
|
+
* @param slug - The slug of the content item
|
|
101
|
+
*/
|
|
102
|
+
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>;
|
|
103
|
+
/** Parameters for a page of items referencing one relation target. */
|
|
104
|
+
interface ContentItemsByRelationParams<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
105
|
+
/** Declared top-level relation field on the source content type. */
|
|
106
|
+
field: string;
|
|
107
|
+
/** ID of the item referenced by the relation. */
|
|
108
|
+
targetId: string;
|
|
109
|
+
/** Number of items to return (default: 20). */
|
|
110
|
+
limit?: number;
|
|
111
|
+
/** Number of matching items to skip (default: 0). */
|
|
112
|
+
offset?: number;
|
|
113
|
+
}
|
|
114
|
+
/** A page of unique related items, ordered by creation time then ID descending. */
|
|
115
|
+
interface ContentItemsByRelationResult<TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
116
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
117
|
+
total: number;
|
|
118
|
+
limit: number;
|
|
119
|
+
offset: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve source items whose relation field references a target item.
|
|
123
|
+
* Relation rows are scanned completely, metadata is read in batches, and full
|
|
124
|
+
* content is fetched only for the requested page. Internal scans grow with the
|
|
125
|
+
* relation count; this does not promise constant query counts or native joins.
|
|
126
|
+
* Set `view: "content"` for identity, parsed content and serialized timestamps
|
|
127
|
+
* without the editor envelope. Omitting it preserves the full item response.
|
|
128
|
+
*
|
|
129
|
+
* @remarks This lower-level read does not authorize requests, validate relation
|
|
130
|
+
* configuration or target access, or compose lifecycle hooks. Callers own those
|
|
131
|
+
* checks and pagination validation. Use `forRequest(request).operations.cms` for
|
|
132
|
+
* request work or trusted operations for validated, lifecycle-aware server work.
|
|
133
|
+
*/
|
|
134
|
+
declare function getContentItemsByRelation<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params: ContentItemsByRelationParams<TView, TFields>): Promise<ContentItemsByRelationResult<TView, TFields>>;
|
|
135
|
+
|
|
136
|
+
declare const CMSContentTypeParamsSchema: z.ZodObject<{
|
|
137
|
+
slug: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
declare const CMSContentItemParamsSchema: z.ZodObject<{
|
|
140
|
+
typeSlug: z.ZodString;
|
|
141
|
+
id: z.ZodString;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
declare const CMSCreateContentItemBodySchema: z.ZodObject<{
|
|
144
|
+
slug: z.ZodString;
|
|
145
|
+
data: z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
declare const CMSUpdateContentItemBodySchema: z.ZodObject<{
|
|
148
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
149
|
+
data: z.ZodOptional<z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Input for creating a new CMS content item.
|
|
154
|
+
*/
|
|
155
|
+
interface CreateCMSContentItemInput {
|
|
156
|
+
/** URL-safe slug for the item */
|
|
157
|
+
slug: string;
|
|
158
|
+
/** Arbitrary data payload — should match the content type schema */
|
|
159
|
+
data: Record<string, unknown>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for {@link createCMSContentItem}.
|
|
163
|
+
*/
|
|
164
|
+
interface CreateCMSContentItemOptions {
|
|
165
|
+
/**
|
|
166
|
+
* When `true`, persist relation fields (`belongsTo`, `hasMany`,
|
|
167
|
+
* `manyToMany`) into the `contentRelation` junction table in addition to
|
|
168
|
+
* the item's JSON payload.
|
|
169
|
+
*
|
|
170
|
+
* This is what the HTTP `POST /content/:typeSlug` route does, and is
|
|
171
|
+
* required for the admin "Related Items" panel / inverse-relation queries
|
|
172
|
+
* to find the item.
|
|
173
|
+
*
|
|
174
|
+
* Seeds and other programmatic callers that want the admin UI to work
|
|
175
|
+
* should enable this flag. Callers are still expected to pass
|
|
176
|
+
* pre-created target IDs (`{ id }` or `[{ id }, ...]`) — inline `_new`
|
|
177
|
+
* creation is only supported via the HTTP route.
|
|
178
|
+
*
|
|
179
|
+
* Defaults to `false` for backwards compatibility (a no-op for content
|
|
180
|
+
* types without relations).
|
|
181
|
+
*/
|
|
182
|
+
syncRelations?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a new content item for a content type (looked up by slug).
|
|
186
|
+
*
|
|
187
|
+
* Bypasses Zod schema validation and inline `_new` relation creation — the
|
|
188
|
+
* caller is responsible for providing valid data and pre-created relation
|
|
189
|
+
* IDs. For schema validation or inline creation of related items, use the
|
|
190
|
+
* HTTP endpoint instead.
|
|
191
|
+
*
|
|
192
|
+
* Throws if the content type is not found or the slug is already taken within
|
|
193
|
+
* that content type.
|
|
194
|
+
*
|
|
195
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are not
|
|
196
|
+
* called. The caller is responsible for any access-control checks before
|
|
197
|
+
* invoking this function.
|
|
198
|
+
*
|
|
199
|
+
* @param adapter - The database adapter
|
|
200
|
+
* @param contentTypeSlug - Slug of the target content type
|
|
201
|
+
* @param input - Item slug and data payload
|
|
202
|
+
* @param options - See {@link CreateCMSContentItemOptions}. Pass
|
|
203
|
+
* `{ syncRelations: true }` to also populate the `contentRelation`
|
|
204
|
+
* junction table for relation fields in the payload.
|
|
205
|
+
*/
|
|
206
|
+
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
207
|
+
|
|
208
|
+
export { CMSContentFields, CMSContentItemParamsSchema, CMSContentItemResult, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSReadOptions, CMSReadView, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
209
|
+
export type { ContentItemsByRelationParams, ContentItemsByRelationResult, CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
export { C as CMSApiRouter, a as CMSRouteKey, b as CMS_QUERY_KEYS, c as cmsBackendPlugin, d as createCMSQueryKeys } from '../shared/plugin-cms.DQLAoogy.js';
|
|
2
|
+
import { DBAdapter } from '@btst/db';
|
|
3
|
+
import { CMSReadView, CMSContentFields, CMSReadOptions, CMSContentItemResult, SerializedContentType, ContentItem, SerializedContentItem, ContentItemWithType, SerializedContentItemWithType, ContentType } from '../types.js';
|
|
4
|
+
export { CMSBackendConfig, CMSBackendHooks, CMSCreateOperationContext, CMSCreateResultContext, CMSDeleteOperationContext, CMSDeleteResultContext, CMSOperationErrorContext, CMSOperationLifecycleContext, CMSSelectedData, CMSUpdateOperationContext, CMSUpdateResultContext, ContentTypeConfig, PaginatedContentItems, SerializedContentItemContent } from '../types.js';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import '@btst/stack/plugins/client';
|
|
7
|
+
import '@btst/stack/authorization';
|
|
8
|
+
import '@btst/stack/plugins/api';
|
|
9
|
+
import 'better-call';
|
|
10
|
+
import '@tanstack/react-query';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Removed CMS lifecycle names and their canonical v3 replacements.
|
|
14
|
+
*
|
|
15
|
+
* The aggregate error callback remains one phase. Its operation argument
|
|
16
|
+
* distinguishes create, update, delete, list, and get failures.
|
|
17
|
+
*/
|
|
18
|
+
declare const CMS_LIFECYCLE_HOOK_MIGRATIONS: Readonly<{
|
|
19
|
+
readonly onBeforeCreate: "onBeforeCreateContent";
|
|
20
|
+
readonly onAfterCreate: "onAfterCreateContent";
|
|
21
|
+
readonly onBeforeUpdate: "onBeforeUpdateContent";
|
|
22
|
+
readonly onAfterUpdate: "onAfterUpdateContent";
|
|
23
|
+
readonly onBeforeDelete: "onBeforeDeleteContent";
|
|
24
|
+
readonly onAfterDelete: "onAfterDeleteContent";
|
|
25
|
+
readonly onError: "onErrorExecuteContentOperation";
|
|
26
|
+
}>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Serialize a ContentType for SSR/SSG use (convert dates to strings).
|
|
30
|
+
* Applies lazy migration for legacy schemas (version 1 → 2).
|
|
31
|
+
*/
|
|
32
|
+
declare function serializeContentType(ct: ContentType): SerializedContentType;
|
|
33
|
+
/**
|
|
34
|
+
* Serialize a ContentItem for SSR/SSG use (convert dates to strings).
|
|
35
|
+
*/
|
|
36
|
+
declare function serializeContentItem(item: ContentItem): SerializedContentItem;
|
|
37
|
+
/**
|
|
38
|
+
* Serialize a ContentItem with parsed data and joined ContentType.
|
|
39
|
+
* Throws a SyntaxError if `item.data` is not valid JSON, so corrupted rows
|
|
40
|
+
* produce a visible, debuggable error rather than silently returning null.
|
|
41
|
+
*/
|
|
42
|
+
declare function serializeContentItemWithType(item: ContentItemWithType): SerializedContentItemWithType;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieve all content types.
|
|
45
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
46
|
+
*
|
|
47
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
48
|
+
* responsible for any access-control checks before invoking this function.
|
|
49
|
+
*
|
|
50
|
+
* @param adapter - The database adapter
|
|
51
|
+
*/
|
|
52
|
+
declare function getAllContentTypes(adapter: DBAdapter): Promise<SerializedContentType[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieve all content items for a given content type, with optional pagination
|
|
55
|
+
* and free-text search.
|
|
56
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
57
|
+
*
|
|
58
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT
|
|
59
|
+
* called. The caller is responsible for any access-control checks before
|
|
60
|
+
* invoking this function.
|
|
61
|
+
*
|
|
62
|
+
* @param adapter - The database adapter
|
|
63
|
+
* @param contentTypeSlug - The slug of the content type to query
|
|
64
|
+
* @param params - Optional filter/pagination parameters. `search` matches
|
|
65
|
+
* case-insensitively against item slugs and string values in the item data.
|
|
66
|
+
*/
|
|
67
|
+
declare function getAllContentItems<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params?: {
|
|
68
|
+
slug?: string;
|
|
69
|
+
limit?: number;
|
|
70
|
+
offset?: number;
|
|
71
|
+
search?: string;
|
|
72
|
+
} & CMSReadOptions<TView, TFields>): Promise<{
|
|
73
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
74
|
+
total: number;
|
|
75
|
+
limit?: number;
|
|
76
|
+
offset?: number;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Retrieve a single content item by its ID.
|
|
80
|
+
* Returns null if the item is not found.
|
|
81
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
82
|
+
*
|
|
83
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
84
|
+
* responsible for any access-control checks before invoking this function.
|
|
85
|
+
*
|
|
86
|
+
* @param adapter - The database adapter
|
|
87
|
+
* @param id - The content item ID (UUID)
|
|
88
|
+
*/
|
|
89
|
+
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>;
|
|
90
|
+
/**
|
|
91
|
+
* Retrieve a single content item by its slug within a content type.
|
|
92
|
+
* Returns null if the content type or item is not found.
|
|
93
|
+
* Pure DB function — no hooks, no HTTP context. Safe for SSG and server-side use.
|
|
94
|
+
*
|
|
95
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are NOT called. The caller is
|
|
96
|
+
* responsible for any access-control checks before invoking this function.
|
|
97
|
+
*
|
|
98
|
+
* @param adapter - The database adapter
|
|
99
|
+
* @param contentTypeSlug - The slug of the content type
|
|
100
|
+
* @param slug - The slug of the content item
|
|
101
|
+
*/
|
|
102
|
+
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>;
|
|
103
|
+
/** Parameters for a page of items referencing one relation target. */
|
|
104
|
+
interface ContentItemsByRelationParams<TView extends CMSReadView = CMSReadView, TFields extends CMSContentFields = CMSContentFields> extends CMSReadOptions<TView, TFields> {
|
|
105
|
+
/** Declared top-level relation field on the source content type. */
|
|
106
|
+
field: string;
|
|
107
|
+
/** ID of the item referenced by the relation. */
|
|
108
|
+
targetId: string;
|
|
109
|
+
/** Number of items to return (default: 20). */
|
|
110
|
+
limit?: number;
|
|
111
|
+
/** Number of matching items to skip (default: 0). */
|
|
112
|
+
offset?: number;
|
|
113
|
+
}
|
|
114
|
+
/** A page of unique related items, ordered by creation time then ID descending. */
|
|
115
|
+
interface ContentItemsByRelationResult<TView extends CMSReadView = undefined, TFields extends CMSContentFields = undefined> {
|
|
116
|
+
items: CMSContentItemResult<Record<string, unknown>, TView, TFields>[];
|
|
117
|
+
total: number;
|
|
118
|
+
limit: number;
|
|
119
|
+
offset: number;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Retrieve source items whose relation field references a target item.
|
|
123
|
+
* Relation rows are scanned completely, metadata is read in batches, and full
|
|
124
|
+
* content is fetched only for the requested page. Internal scans grow with the
|
|
125
|
+
* relation count; this does not promise constant query counts or native joins.
|
|
126
|
+
* Set `view: "content"` for identity, parsed content and serialized timestamps
|
|
127
|
+
* without the editor envelope. Omitting it preserves the full item response.
|
|
128
|
+
*
|
|
129
|
+
* @remarks This lower-level read does not authorize requests, validate relation
|
|
130
|
+
* configuration or target access, or compose lifecycle hooks. Callers own those
|
|
131
|
+
* checks and pagination validation. Use `forRequest(request).operations.cms` for
|
|
132
|
+
* request work or trusted operations for validated, lifecycle-aware server work.
|
|
133
|
+
*/
|
|
134
|
+
declare function getContentItemsByRelation<TView extends CMSReadView = undefined, const TFields extends CMSContentFields = undefined>(adapter: DBAdapter, contentTypeSlug: string, params: ContentItemsByRelationParams<TView, TFields>): Promise<ContentItemsByRelationResult<TView, TFields>>;
|
|
135
|
+
|
|
136
|
+
declare const CMSContentTypeParamsSchema: z.ZodObject<{
|
|
137
|
+
slug: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
declare const CMSContentItemParamsSchema: z.ZodObject<{
|
|
140
|
+
typeSlug: z.ZodString;
|
|
141
|
+
id: z.ZodString;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
declare const CMSCreateContentItemBodySchema: z.ZodObject<{
|
|
144
|
+
slug: z.ZodString;
|
|
145
|
+
data: z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>;
|
|
146
|
+
}, z.core.$strip>;
|
|
147
|
+
declare const CMSUpdateContentItemBodySchema: z.ZodObject<{
|
|
148
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
149
|
+
data: z.ZodOptional<z.ZodType<Record<string, any>, unknown, z.core.$ZodTypeInternals<Record<string, any>, unknown>>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Input for creating a new CMS content item.
|
|
154
|
+
*/
|
|
155
|
+
interface CreateCMSContentItemInput {
|
|
156
|
+
/** URL-safe slug for the item */
|
|
157
|
+
slug: string;
|
|
158
|
+
/** Arbitrary data payload — should match the content type schema */
|
|
159
|
+
data: Record<string, unknown>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Options for {@link createCMSContentItem}.
|
|
163
|
+
*/
|
|
164
|
+
interface CreateCMSContentItemOptions {
|
|
165
|
+
/**
|
|
166
|
+
* When `true`, persist relation fields (`belongsTo`, `hasMany`,
|
|
167
|
+
* `manyToMany`) into the `contentRelation` junction table in addition to
|
|
168
|
+
* the item's JSON payload.
|
|
169
|
+
*
|
|
170
|
+
* This is what the HTTP `POST /content/:typeSlug` route does, and is
|
|
171
|
+
* required for the admin "Related Items" panel / inverse-relation queries
|
|
172
|
+
* to find the item.
|
|
173
|
+
*
|
|
174
|
+
* Seeds and other programmatic callers that want the admin UI to work
|
|
175
|
+
* should enable this flag. Callers are still expected to pass
|
|
176
|
+
* pre-created target IDs (`{ id }` or `[{ id }, ...]`) — inline `_new`
|
|
177
|
+
* creation is only supported via the HTTP route.
|
|
178
|
+
*
|
|
179
|
+
* Defaults to `false` for backwards compatibility (a no-op for content
|
|
180
|
+
* types without relations).
|
|
181
|
+
*/
|
|
182
|
+
syncRelations?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a new content item for a content type (looked up by slug).
|
|
186
|
+
*
|
|
187
|
+
* Bypasses Zod schema validation and inline `_new` relation creation — the
|
|
188
|
+
* caller is responsible for providing valid data and pre-created relation
|
|
189
|
+
* IDs. For schema validation or inline creation of related items, use the
|
|
190
|
+
* HTTP endpoint instead.
|
|
191
|
+
*
|
|
192
|
+
* Throws if the content type is not found or the slug is already taken within
|
|
193
|
+
* that content type.
|
|
194
|
+
*
|
|
195
|
+
* @remarks **Security:** Operation authorization and lifecycle hooks are not
|
|
196
|
+
* called. The caller is responsible for any access-control checks before
|
|
197
|
+
* invoking this function.
|
|
198
|
+
*
|
|
199
|
+
* @param adapter - The database adapter
|
|
200
|
+
* @param contentTypeSlug - Slug of the target content type
|
|
201
|
+
* @param input - Item slug and data payload
|
|
202
|
+
* @param options - See {@link CreateCMSContentItemOptions}. Pass
|
|
203
|
+
* `{ syncRelations: true }` to also populate the `contentRelation`
|
|
204
|
+
* junction table for relation fields in the payload.
|
|
205
|
+
*/
|
|
206
|
+
declare function createCMSContentItem(adapter: DBAdapter, contentTypeSlug: string, input: CreateCMSContentItemInput, options?: CreateCMSContentItemOptions): Promise<SerializedContentItem>;
|
|
207
|
+
|
|
208
|
+
export { CMSContentFields, CMSContentItemParamsSchema, CMSContentItemResult, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSReadOptions, CMSReadView, CMSUpdateContentItemBodySchema, CMS_LIFECYCLE_HOOK_MIGRATIONS, createCMSContentItem, getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType };
|
|
209
|
+
export type { ContentItemsByRelationParams, ContentItemsByRelationResult, CreateCMSContentItemInput, CreateCMSContentItemOptions };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { cmsBackendPlugin } from './plugin.mjs';
|
|
2
|
+
export { getAllContentItems, getAllContentTypes, getContentItemById, getContentItemBySlug, getContentItemsByRelation, serializeContentItem, serializeContentItemWithType, serializeContentType } from './getters.mjs';
|
|
3
|
+
export { createCMSContentItem } from './mutations.mjs';
|
|
4
|
+
export { CMS_QUERY_KEYS } from './query-key-defs.mjs';
|
|
5
|
+
export { createCMSQueryKeys } from '../query-keys.mjs';
|
|
6
|
+
export { CMSContentItemParamsSchema, CMSContentTypeParamsSchema, CMSCreateContentItemBodySchema, CMSUpdateContentItemBodySchema } from './operations.mjs';
|
|
7
|
+
export { CMS_LIFECYCLE_HOOK_MIGRATIONS } from './lifecycle-migrations.mjs';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const CMS_LIFECYCLE_HOOK_MIGRATIONS = Object.freeze({
|
|
4
|
+
onBeforeCreate: "onBeforeCreateContent",
|
|
5
|
+
onAfterCreate: "onAfterCreateContent",
|
|
6
|
+
onBeforeUpdate: "onBeforeUpdateContent",
|
|
7
|
+
onAfterUpdate: "onAfterUpdateContent",
|
|
8
|
+
onBeforeDelete: "onBeforeDeleteContent",
|
|
9
|
+
onAfterDelete: "onAfterDeleteContent",
|
|
10
|
+
onError: "onErrorExecuteContentOperation"
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
exports.CMS_LIFECYCLE_HOOK_MIGRATIONS = CMS_LIFECYCLE_HOOK_MIGRATIONS;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const CMS_LIFECYCLE_HOOK_MIGRATIONS = Object.freeze({
|
|
2
|
+
onBeforeCreate: "onBeforeCreateContent",
|
|
3
|
+
onAfterCreate: "onAfterCreateContent",
|
|
4
|
+
onBeforeUpdate: "onBeforeUpdateContent",
|
|
5
|
+
onAfterUpdate: "onAfterUpdateContent",
|
|
6
|
+
onBeforeDelete: "onBeforeDeleteContent",
|
|
7
|
+
onAfterDelete: "onAfterDeleteContent",
|
|
8
|
+
onError: "onErrorExecuteContentOperation"
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export { CMS_LIFECYCLE_HOOK_MIGRATIONS };
|