convex-cms 0.0.16 → 0.0.17
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/admin/dist/types/admin/src/components/ui/field.d.ts +1 -1
- package/admin/dist/types/admin/src/lib/cmsExports.d.ts +6 -6
- package/admin/dist/types/admin/src/lib/cmsExports.d.ts.map +1 -1
- package/admin/src/lib/cmsExports.ts +8 -8
- package/admin-dist/assets/index-DagpgVMo.js +104 -0
- package/admin-dist/embed/favicon.ico +0 -0
- package/admin-dist/embed/index.js +30961 -0
- package/admin-dist/embed/index.js.map +1 -0
- package/admin-dist/index.html +1 -1
- package/package.json +12 -5
- package/admin/dist/types/src/client/admin/bulk.d.ts +0 -79
- package/admin/dist/types/src/client/admin/bulk.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/contentLock.d.ts +0 -118
- package/admin/dist/types/src/client/admin/contentLock.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/contentTypes.d.ts +0 -1627
- package/admin/dist/types/src/client/admin/contentTypes.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/dashboard.d.ts +0 -16
- package/admin/dist/types/src/client/admin/dashboard.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/entries.d.ts +0 -357
- package/admin/dist/types/src/client/admin/entries.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/index.d.ts +0 -7502
- package/admin/dist/types/src/client/admin/index.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/media.d.ts +0 -1038
- package/admin/dist/types/src/client/admin/media.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/settings.d.ts +0 -50
- package/admin/dist/types/src/client/admin/settings.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/taxonomies.d.ts +0 -339
- package/admin/dist/types/src/client/admin/taxonomies.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/trash.d.ts +0 -90
- package/admin/dist/types/src/client/admin/trash.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/types.d.ts +0 -594
- package/admin/dist/types/src/client/admin/types.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/users.d.ts +0 -58
- package/admin/dist/types/src/client/admin/users.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/validators.d.ts +0 -7732
- package/admin/dist/types/src/client/admin/validators.d.ts.map +0 -1
- package/admin/dist/types/src/client/admin/versions.d.ts +0 -106
- package/admin/dist/types/src/client/admin/versions.d.ts.map +0 -1
- package/admin/dist/types/src/client/adminConfig.d.ts +0 -125
- package/admin/dist/types/src/client/adminConfig.d.ts.map +0 -1
- package/admin/dist/types/src/client/config.d.ts +0 -155
- package/admin/dist/types/src/client/config.d.ts.map +0 -1
- package/admin/dist/types/src/client/field-types.d.ts +0 -55
- package/admin/dist/types/src/client/field-types.d.ts.map +0 -1
- package/admin/dist/types/src/client/fields.d.ts +0 -70
- package/admin/dist/types/src/client/fields.d.ts.map +0 -1
- package/admin/dist/types/src/client/registry.d.ts +0 -77
- package/admin/dist/types/src/client/registry.d.ts.map +0 -1
- package/admin/dist/types/src/client/schema/defineContentType.d.ts +0 -233
- package/admin/dist/types/src/client/schema/defineContentType.d.ts.map +0 -1
- package/admin/dist/types/src/client/schema/types.d.ts +0 -540
- package/admin/dist/types/src/client/schema/types.d.ts.map +0 -1
- package/admin/dist/types/src/client/types.d.ts +0 -449
- package/admin/dist/types/src/client/types.d.ts.map +0 -1
- package/admin/dist/types/src/client/utils/toSlug.d.ts +0 -60
- package/admin/dist/types/src/client/utils/toSlug.d.ts.map +0 -1
- package/admin/dist/types/src/client/workflows.d.ts +0 -51
- package/admin/dist/types/src/client/workflows.d.ts.map +0 -1
- package/admin/dist/types/src/component/_generated/component.d.ts +0 -4813
- package/admin/dist/types/src/component/_generated/component.d.ts.map +0 -1
- package/admin/dist/types/src/component/_generated/dataModel.d.ts +0 -46
- package/admin/dist/types/src/component/_generated/dataModel.d.ts.map +0 -1
- package/admin/dist/types/src/component/_generated/server.d.ts +0 -121
- package/admin/dist/types/src/component/_generated/server.d.ts.map +0 -1
- package/admin/dist/types/src/component/contentEntryMutations.d.ts +0 -551
- package/admin/dist/types/src/component/contentEntryMutations.d.ts.map +0 -1
- package/admin/dist/types/src/component/contentLock.d.ts +0 -328
- package/admin/dist/types/src/component/contentLock.d.ts.map +0 -1
- package/admin/dist/types/src/component/contentTypeMutations.d.ts +0 -1253
- package/admin/dist/types/src/component/contentTypeMutations.d.ts.map +0 -1
- package/admin/dist/types/src/component/documentTypes.d.ts +0 -186
- package/admin/dist/types/src/component/documentTypes.d.ts.map +0 -1
- package/admin/dist/types/src/component/eventEmitter.d.ts +0 -309
- package/admin/dist/types/src/component/eventEmitter.d.ts.map +0 -1
- package/admin/dist/types/src/component/lib/errors.d.ts +0 -306
- package/admin/dist/types/src/component/lib/errors.d.ts.map +0 -1
- package/admin/dist/types/src/component/lib/metadataExtractor.d.ts +0 -245
- package/admin/dist/types/src/component/lib/metadataExtractor.d.ts.map +0 -1
- package/admin/dist/types/src/component/lib/mutationAuth.d.ts +0 -95
- package/admin/dist/types/src/component/lib/mutationAuth.d.ts.map +0 -1
- package/admin/dist/types/src/component/lib/slugGenerator.d.ts +0 -71
- package/admin/dist/types/src/component/lib/slugGenerator.d.ts.map +0 -1
- package/admin/dist/types/src/component/lib/slugUniqueness.d.ts +0 -131
- package/admin/dist/types/src/component/lib/slugUniqueness.d.ts.map +0 -1
- package/admin/dist/types/src/component/lib/softDelete.d.ts +0 -18
- package/admin/dist/types/src/component/lib/softDelete.d.ts.map +0 -1
- package/admin/dist/types/src/component/localeFields.d.ts +0 -508
- package/admin/dist/types/src/component/localeFields.d.ts.map +0 -1
- package/admin/dist/types/src/component/mediaAssetMutations.d.ts +0 -282
- package/admin/dist/types/src/component/mediaAssetMutations.d.ts.map +0 -1
- package/admin/dist/types/src/component/schema.d.ts +0 -5248
- package/admin/dist/types/src/component/schema.d.ts.map +0 -1
- package/admin/dist/types/src/component/validation.d.ts +0 -407
- package/admin/dist/types/src/component/validation.d.ts.map +0 -1
- package/admin/dist/types/src/component/validators.d.ts +0 -5722
- package/admin/dist/types/src/component/validators.d.ts.map +0 -1
- package/admin/dist/types/src/react/index.d.ts +0 -493
- package/admin/dist/types/src/react/index.d.ts.map +0 -1
- package/admin-dist/assets/index-DTgANhXL.js +0 -104
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content Type Schema Definition
|
|
3
|
-
*
|
|
4
|
-
* The `defineContentType` function creates type-safe content type definitions
|
|
5
|
-
* using Convex validators. Types are automatically inferred via Convex's
|
|
6
|
-
* native `Infer<typeof validator>` pattern.
|
|
7
|
-
*
|
|
8
|
-
* You can use either display names ("Blog Post") or slug format ("blog_post"):
|
|
9
|
-
* - Display names are automatically converted to slugs
|
|
10
|
-
* - Slugs are used for queries and code references
|
|
11
|
-
*
|
|
12
|
-
* @example Using a display name (recommended)
|
|
13
|
-
* ```typescript
|
|
14
|
-
* import { v } from "convex/values";
|
|
15
|
-
* import { defineContentType } from "convex-cms";
|
|
16
|
-
*
|
|
17
|
-
* export const blogPost = defineContentType({
|
|
18
|
-
* name: "Blog Post", // → slug: "blog_post"
|
|
19
|
-
* validator: v.object({
|
|
20
|
-
* title: v.string(),
|
|
21
|
-
* content: v.string(),
|
|
22
|
-
* }),
|
|
23
|
-
* meta: {
|
|
24
|
-
* displayName: "Blog Post",
|
|
25
|
-
* titleField: "title",
|
|
26
|
-
* },
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // blogPost.slug === "blog_post"
|
|
30
|
-
* // blogPost.name === "Blog Post"
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @example Using slug format directly
|
|
34
|
-
* ```typescript
|
|
35
|
-
* export const blogPost = defineContentType({
|
|
36
|
-
* name: "blog_post", // Already a valid slug
|
|
37
|
-
* validator: v.object({
|
|
38
|
-
* title: v.string(),
|
|
39
|
-
* content: v.string(),
|
|
40
|
-
* }),
|
|
41
|
-
* meta: {
|
|
42
|
-
* displayName: "Blog Post",
|
|
43
|
-
* titleField: "title",
|
|
44
|
-
* },
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
import type { CmsObjectValidator, ContentTypeConfig, ContentTypeDefinition } from "./types.js";
|
|
49
|
-
import { type ToSlugType } from "../utils/toSlug.js";
|
|
50
|
-
/**
|
|
51
|
-
* Creates a type-safe content type definition.
|
|
52
|
-
*
|
|
53
|
-
* This function accepts a Convex validator and CMS metadata, returning a
|
|
54
|
-
* definition object that can be used for:
|
|
55
|
-
* 1. **Type inference**: `Infer<typeof definition.validator>` gives the data type
|
|
56
|
-
* 2. **Runtime validation**: The validator is used to validate content at runtime
|
|
57
|
-
* 3. **Admin UI configuration**: Metadata provides display hints and field labels
|
|
58
|
-
*
|
|
59
|
-
* ## Why Convex Validators?
|
|
60
|
-
*
|
|
61
|
-
* Using Convex validators directly (instead of custom schema builders) provides:
|
|
62
|
-
* - **Native type inference** via `Infer<typeof>` - no custom type machinery
|
|
63
|
-
* - **Familiarity** - same validators used in Convex functions
|
|
64
|
-
* - **Full power** - supports unions, literals, nested objects, arrays, IDs
|
|
65
|
-
* - **Maintenance-free** - types are maintained by Convex
|
|
66
|
-
*
|
|
67
|
-
* ## Example: Basic Blog Post
|
|
68
|
-
*
|
|
69
|
-
* ```typescript
|
|
70
|
-
* import { v, Infer } from "convex/values";
|
|
71
|
-
* import { defineContentType } from "convex-cms";
|
|
72
|
-
*
|
|
73
|
-
* export const blogPost = defineContentType({
|
|
74
|
-
* name: "Blog Post", // Display name → auto-converted to slug "blog_post"
|
|
75
|
-
* validator: v.object({
|
|
76
|
-
* title: v.string(),
|
|
77
|
-
* content: v.string(),
|
|
78
|
-
* publishedAt: v.optional(v.number()),
|
|
79
|
-
* }),
|
|
80
|
-
* meta: {
|
|
81
|
-
* displayName: "Blog Post",
|
|
82
|
-
* titleField: "title",
|
|
83
|
-
* },
|
|
84
|
-
* });
|
|
85
|
-
*
|
|
86
|
-
* // Type is automatically inferred
|
|
87
|
-
* type BlogPostData = Infer<typeof blogPost.validator>;
|
|
88
|
-
* // { title: string; content: string; publishedAt?: number }
|
|
89
|
-
* ```
|
|
90
|
-
*
|
|
91
|
-
* ## Example: Product with Variants
|
|
92
|
-
*
|
|
93
|
-
* ```typescript
|
|
94
|
-
* export const product = defineContentType({
|
|
95
|
-
* name: "Product",
|
|
96
|
-
* validator: v.object({
|
|
97
|
-
* name: v.string(),
|
|
98
|
-
* price: v.number(),
|
|
99
|
-
* description: v.optional(v.string()),
|
|
100
|
-
* variants: v.array(v.object({
|
|
101
|
-
* sku: v.string(),
|
|
102
|
-
* name: v.string(),
|
|
103
|
-
* price: v.number(),
|
|
104
|
-
* attributes: v.record(v.string(), v.string()),
|
|
105
|
-
* })),
|
|
106
|
-
* seo: v.optional(v.object({
|
|
107
|
-
* title: v.string(),
|
|
108
|
-
* description: v.string(),
|
|
109
|
-
* keywords: v.array(v.string()),
|
|
110
|
-
* })),
|
|
111
|
-
* }),
|
|
112
|
-
* meta: {
|
|
113
|
-
* displayName: "Product",
|
|
114
|
-
* titleField: "name",
|
|
115
|
-
* fields: {
|
|
116
|
-
* name: { label: "Product Name", searchable: true },
|
|
117
|
-
* price: { label: "Base Price" },
|
|
118
|
-
* variants: { label: "Variants", renderAs: "json" },
|
|
119
|
-
* seo: { label: "SEO Settings", renderAs: "json" },
|
|
120
|
-
* },
|
|
121
|
-
* },
|
|
122
|
-
* });
|
|
123
|
-
* ```
|
|
124
|
-
*
|
|
125
|
-
* @param config - The content type configuration
|
|
126
|
-
* @returns A frozen content type definition object
|
|
127
|
-
*
|
|
128
|
-
* @typeParam TName - The literal string type of the content type name (display or slug)
|
|
129
|
-
* @typeParam TValidator - The Convex validator type
|
|
130
|
-
*/
|
|
131
|
-
export declare function defineContentType<const TName extends string, TValidator extends CmsObjectValidator>(config: ContentTypeConfig<TValidator> & {
|
|
132
|
-
name: TName;
|
|
133
|
-
}): ContentTypeDefinition<ToSlugType<TName>, TValidator>;
|
|
134
|
-
/**
|
|
135
|
-
* Creates a content schema from multiple content type definitions.
|
|
136
|
-
*
|
|
137
|
-
* This is a convenience function that validates the schema and provides
|
|
138
|
-
* runtime utilities for working with multiple content types.
|
|
139
|
-
*
|
|
140
|
-
* @example
|
|
141
|
-
* ```typescript
|
|
142
|
-
* import { createContentSchema } from "convex-cms";
|
|
143
|
-
*
|
|
144
|
-
* export const contentSchema = createContentSchema({
|
|
145
|
-
* blogPost,
|
|
146
|
-
* author,
|
|
147
|
-
* product,
|
|
148
|
-
* });
|
|
149
|
-
*
|
|
150
|
-
* // Get a specific definition
|
|
151
|
-
* const blogDef = contentSchema.getDefinition("blog_post");
|
|
152
|
-
*
|
|
153
|
-
* // List all content type names
|
|
154
|
-
* const names = contentSchema.getContentTypeNames();
|
|
155
|
-
* // ["blog_post", "author", "product"]
|
|
156
|
-
* ```
|
|
157
|
-
*
|
|
158
|
-
* @param definitions - An object containing content type definitions
|
|
159
|
-
* @returns A schema object with utility methods
|
|
160
|
-
*/
|
|
161
|
-
export declare function createContentSchema<T extends Record<string, ContentTypeDefinition>>(definitions: T): ContentSchemaInstance<T>;
|
|
162
|
-
/**
|
|
163
|
-
* A content schema instance with utility methods.
|
|
164
|
-
*/
|
|
165
|
-
export interface ContentSchemaInstance<T extends Record<string, ContentTypeDefinition>> {
|
|
166
|
-
/**
|
|
167
|
-
* The raw definitions object.
|
|
168
|
-
*/
|
|
169
|
-
readonly definitions: T;
|
|
170
|
-
/**
|
|
171
|
-
* Get a content type definition by its slug.
|
|
172
|
-
*
|
|
173
|
-
* @param slug - The content type slug (e.g., "blog_post")
|
|
174
|
-
* @returns The definition or undefined if not found
|
|
175
|
-
*/
|
|
176
|
-
getDefinition(slug: string): ContentTypeDefinition | undefined;
|
|
177
|
-
/**
|
|
178
|
-
* Get all content type slugs in the schema.
|
|
179
|
-
*
|
|
180
|
-
* @returns Array of content type slugs
|
|
181
|
-
*/
|
|
182
|
-
getContentTypeNames(): string[];
|
|
183
|
-
/**
|
|
184
|
-
* Check if a content type exists in the schema.
|
|
185
|
-
*
|
|
186
|
-
* @param slug - The content type slug to check
|
|
187
|
-
* @returns true if the content type exists
|
|
188
|
-
*/
|
|
189
|
-
hasContentType(slug: string): boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Get a content type definition by its key in the definitions object.
|
|
192
|
-
*
|
|
193
|
-
* @param key - The key used in the definitions object
|
|
194
|
-
* @returns The definition
|
|
195
|
-
*/
|
|
196
|
-
getDefinitionByKey<K extends keyof T>(key: K): T[K];
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Field definition format expected by the CMS database.
|
|
200
|
-
* This is the format stored in contentTypes.fields.
|
|
201
|
-
*/
|
|
202
|
-
export interface DatabaseFieldDefinition {
|
|
203
|
-
name: string;
|
|
204
|
-
label: string;
|
|
205
|
-
type: string;
|
|
206
|
-
required: boolean;
|
|
207
|
-
searchable?: boolean;
|
|
208
|
-
localized?: boolean;
|
|
209
|
-
description?: string;
|
|
210
|
-
defaultValue?: unknown;
|
|
211
|
-
options?: Record<string, unknown>;
|
|
212
|
-
group?: string;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Converts a content type definition to the database field format.
|
|
216
|
-
*
|
|
217
|
-
* This bridges the gap between the code-defined schema and the
|
|
218
|
-
* database format used by the CMS component.
|
|
219
|
-
*
|
|
220
|
-
* @param definition - The content type definition
|
|
221
|
-
* @returns An array of field definitions for the database
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* ```typescript
|
|
225
|
-
* const fields = toFieldDefinitions(blogPost);
|
|
226
|
-
* // [
|
|
227
|
-
* // { name: "title", label: "Title", type: "text", required: true, ... },
|
|
228
|
-
* // { name: "content", label: "Content", type: "richText", required: true, ... },
|
|
229
|
-
* // ]
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
export declare function toFieldDefinitions(definition: ContentTypeDefinition): DatabaseFieldDefinition[];
|
|
233
|
-
//# sourceMappingURL=defineContentType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineContentType.d.ts","sourceRoot":"","sources":["../../../../../../src/client/schema/defineContentType.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EAGtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAuC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,CAAC,KAAK,SAAS,MAAM,EAC1B,UAAU,SAAS,kBAAkB,EAErC,MAAM,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACtD,qBAAqB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,CAiCtD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAC/C,WAAW,EAAE,CAAC,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAmC1C;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB,CACpC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAE/C;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAExB;;;;;OAKG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAC;IAE/D;;;;OAIG;IACH,mBAAmB,IAAI,MAAM,EAAE,CAAC;IAEhC;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAEtC;;;;;OAKG;IACH,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;CACrD;AAMD;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,qBAAqB,GAChC,uBAAuB,EAAE,CA2C3B"}
|