@vexcms/core 0.0.19 → 0.1.0-alpha.2
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 +202 -0
- package/dist/.build +1 -0
- package/dist/access/buildChecks.d.ts +58 -0
- package/dist/access/buildChecks.d.ts.map +1 -0
- package/dist/access/canAccessAdminPanel.d.ts +53 -0
- package/dist/access/canAccessAdminPanel.d.ts.map +1 -0
- package/dist/access/compileConstraints.d.ts +155 -0
- package/dist/access/compileConstraints.d.ts.map +1 -0
- package/dist/access/config.d.ts +62 -0
- package/dist/access/config.d.ts.map +1 -0
- package/dist/access/constants.d.ts +95 -0
- package/dist/access/constants.d.ts.map +1 -0
- package/dist/access/constraintTypes.d.ts +337 -0
- package/dist/access/constraintTypes.d.ts.map +1 -0
- package/dist/access/createAccessQueryBuilder.d.ts +59 -0
- package/dist/access/createAccessQueryBuilder.d.ts.map +1 -0
- package/dist/access/createFilterConstraintBuilder.d.ts +26 -0
- package/dist/access/createFilterConstraintBuilder.d.ts.map +1 -0
- package/dist/access/createIndexConstraintBuilder.d.ts +40 -0
- package/dist/access/createIndexConstraintBuilder.d.ts.map +1 -0
- package/dist/access/hasPermission.d.ts +85 -0
- package/dist/access/hasPermission.d.ts.map +1 -0
- package/dist/access/index.d.ts +13 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/pickQueryIndex.d.ts +42 -0
- package/dist/access/pickQueryIndex.d.ts.map +1 -0
- package/dist/access/resolveAccessRule.d.ts +85 -0
- package/dist/access/resolveAccessRule.d.ts.map +1 -0
- package/dist/access/types.d.ts +738 -0
- package/dist/access/types.d.ts.map +1 -0
- package/dist/access/validateAccessConstraints.d.ts +57 -0
- package/dist/access/validateAccessConstraints.d.ts.map +1 -0
- package/dist/api/client.d.ts +20 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +117 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/convex.d.ts +296 -0
- package/dist/api/convex.d.ts.map +1 -0
- package/dist/api/create/client.d.ts +50 -0
- package/dist/api/create/client.d.ts.map +1 -0
- package/dist/api/create/server.d.ts +43 -0
- package/dist/api/create/server.d.ts.map +1 -0
- package/dist/api/depth.d.ts +39 -0
- package/dist/api/depth.d.ts.map +1 -0
- package/dist/api/find/client.d.ts +90 -0
- package/dist/api/find/client.d.ts.map +1 -0
- package/dist/api/find/server.d.ts +73 -0
- package/dist/api/find/server.d.ts.map +1 -0
- package/dist/api/get/client.d.ts +56 -0
- package/dist/api/get/client.d.ts.map +1 -0
- package/dist/api/get/server.d.ts +49 -0
- package/dist/api/get/server.d.ts.map +1 -0
- package/dist/api/globals/find.client.d.ts +20 -0
- package/dist/api/globals/find.client.d.ts.map +1 -0
- package/dist/api/globals/find.server.d.ts +29 -0
- package/dist/api/globals/find.server.d.ts.map +1 -0
- package/dist/api/globals/get.client.d.ts +46 -0
- package/dist/api/globals/get.client.d.ts.map +1 -0
- package/dist/api/globals/get.server.d.ts +55 -0
- package/dist/api/globals/get.server.d.ts.map +1 -0
- package/dist/api/globals/types.d.ts +65 -0
- package/dist/api/globals/types.d.ts.map +1 -0
- package/dist/api/globals/upsert.client.d.ts +24 -0
- package/dist/api/globals/upsert.client.d.ts.map +1 -0
- package/dist/api/globals/upsert.server.d.ts +47 -0
- package/dist/api/globals/upsert.server.d.ts.map +1 -0
- package/dist/api/populate.d.ts +23 -0
- package/dist/api/populate.d.ts.map +1 -0
- package/dist/api/remove/client.d.ts +58 -0
- package/dist/api/remove/client.d.ts.map +1 -0
- package/dist/api/remove/server.d.ts +65 -0
- package/dist/api/remove/server.d.ts.map +1 -0
- package/dist/api/search/client.d.ts +58 -0
- package/dist/api/search/client.d.ts.map +1 -0
- package/dist/api/search/server.d.ts +54 -0
- package/dist/api/search/server.d.ts.map +1 -0
- package/dist/api/server.d.ts +370 -0
- package/dist/api/server.d.ts.map +1 -0
- package/dist/api/server.js +33 -0
- package/dist/api/server.js.map +1 -0
- package/dist/api/types.d.ts +525 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/update/client.d.ts +53 -0
- package/dist/api/update/client.d.ts.map +1 -0
- package/dist/api/update/server.d.ts +47 -0
- package/dist/api/update/server.d.ts.map +1 -0
- package/dist/api/utils.d.ts +57 -0
- package/dist/api/utils.d.ts.map +1 -0
- package/dist/auth/mergeCollections.d.ts +28 -0
- package/dist/auth/mergeCollections.d.ts.map +1 -0
- package/dist/auth/types.d.ts +84 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/chunk-2DU7JDEX.js +1877 -0
- package/dist/chunk-2DU7JDEX.js.map +1 -0
- package/dist/chunk-2IB2DCN7.js +75 -0
- package/dist/chunk-2IB2DCN7.js.map +1 -0
- package/dist/collections/config.d.ts +28 -0
- package/dist/collections/config.d.ts.map +1 -0
- package/dist/collections/constants.d.ts +27 -0
- package/dist/collections/constants.d.ts.map +1 -0
- package/dist/collections/index.d.ts +7 -0
- package/dist/collections/index.d.ts.map +1 -0
- package/dist/collections/indexFields.d.ts +20 -0
- package/dist/collections/indexFields.d.ts.map +1 -0
- package/dist/collections/interfaceGen.d.ts +59 -0
- package/dist/collections/interfaceGen.d.ts.map +1 -0
- package/dist/collections/internal/index.d.ts +2 -0
- package/dist/collections/internal/index.d.ts.map +1 -0
- package/dist/collections/types.d.ts +282 -0
- package/dist/collections/types.d.ts.map +1 -0
- package/dist/collections/utils.d.ts +71 -0
- package/dist/collections/utils.d.ts.map +1 -0
- package/dist/collections/validator.d.ts +73 -0
- package/dist/collections/validator.d.ts.map +1 -0
- package/dist/config/config.d.ts +43 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/sanitizeConfig.d.ts +82 -0
- package/dist/config/sanitizeConfig.d.ts.map +1 -0
- package/dist/config/types.d.ts +316 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/fields/array/config.d.ts +57 -0
- package/dist/fields/array/config.d.ts.map +1 -0
- package/dist/fields/array/index.d.ts +5 -0
- package/dist/fields/array/index.d.ts.map +1 -0
- package/dist/fields/array/inputSchema.d.ts +32 -0
- package/dist/fields/array/inputSchema.d.ts.map +1 -0
- package/dist/fields/array/types.d.ts +127 -0
- package/dist/fields/array/types.d.ts.map +1 -0
- package/dist/fields/array/validator.d.ts +30 -0
- package/dist/fields/array/validator.d.ts.map +1 -0
- package/dist/fields/baseTypes.d.ts +251 -0
- package/dist/fields/baseTypes.d.ts.map +1 -0
- package/dist/fields/blocks/config.d.ts +63 -0
- package/dist/fields/blocks/config.d.ts.map +1 -0
- package/dist/fields/blocks/index.d.ts +5 -0
- package/dist/fields/blocks/index.d.ts.map +1 -0
- package/dist/fields/blocks/inputSchema.d.ts +22 -0
- package/dist/fields/blocks/inputSchema.d.ts.map +1 -0
- package/dist/fields/blocks/types.d.ts +253 -0
- package/dist/fields/blocks/types.d.ts.map +1 -0
- package/dist/fields/blocks/validator.d.ts +32 -0
- package/dist/fields/blocks/validator.d.ts.map +1 -0
- package/dist/fields/checkbox/config.d.ts +46 -0
- package/dist/fields/checkbox/config.d.ts.map +1 -0
- package/dist/fields/checkbox/index.d.ts +5 -0
- package/dist/fields/checkbox/index.d.ts.map +1 -0
- package/dist/fields/checkbox/inputSchema.d.ts +27 -0
- package/dist/fields/checkbox/inputSchema.d.ts.map +1 -0
- package/dist/fields/checkbox/types.d.ts +67 -0
- package/dist/fields/checkbox/types.d.ts.map +1 -0
- package/dist/fields/checkbox/validator.d.ts +34 -0
- package/dist/fields/checkbox/validator.d.ts.map +1 -0
- package/dist/fields/color/config.d.ts +49 -0
- package/dist/fields/color/config.d.ts.map +1 -0
- package/dist/fields/color/convert.d.ts +72 -0
- package/dist/fields/color/convert.d.ts.map +1 -0
- package/dist/fields/color/formats.d.ts +38 -0
- package/dist/fields/color/formats.d.ts.map +1 -0
- package/dist/fields/color/index.d.ts +8 -0
- package/dist/fields/color/index.d.ts.map +1 -0
- package/dist/fields/color/inputSchema.d.ts +29 -0
- package/dist/fields/color/inputSchema.d.ts.map +1 -0
- package/dist/fields/color/types.d.ts +100 -0
- package/dist/fields/color/types.d.ts.map +1 -0
- package/dist/fields/color/utils.d.ts +100 -0
- package/dist/fields/color/utils.d.ts.map +1 -0
- package/dist/fields/color/validator.d.ts +27 -0
- package/dist/fields/color/validator.d.ts.map +1 -0
- package/dist/fields/constants.d.ts +108 -0
- package/dist/fields/constants.d.ts.map +1 -0
- package/dist/fields/date/config.d.ts +57 -0
- package/dist/fields/date/config.d.ts.map +1 -0
- package/dist/fields/date/index.d.ts +5 -0
- package/dist/fields/date/index.d.ts.map +1 -0
- package/dist/fields/date/inputSchema.d.ts +29 -0
- package/dist/fields/date/inputSchema.d.ts.map +1 -0
- package/dist/fields/date/types.d.ts +147 -0
- package/dist/fields/date/types.d.ts.map +1 -0
- package/dist/fields/date/validator.d.ts +34 -0
- package/dist/fields/date/validator.d.ts.map +1 -0
- package/dist/fields/group/config.d.ts +47 -0
- package/dist/fields/group/config.d.ts.map +1 -0
- package/dist/fields/group/index.d.ts +5 -0
- package/dist/fields/group/index.d.ts.map +1 -0
- package/dist/fields/group/inputSchema.d.ts +27 -0
- package/dist/fields/group/inputSchema.d.ts.map +1 -0
- package/dist/fields/group/types.d.ts +105 -0
- package/dist/fields/group/types.d.ts.map +1 -0
- package/dist/fields/group/validator.d.ts +41 -0
- package/dist/fields/group/validator.d.ts.map +1 -0
- package/dist/fields/index.d.ts +20 -0
- package/dist/fields/index.d.ts.map +1 -0
- package/dist/fields/inputSchemas/index.d.ts +23 -0
- package/dist/fields/inputSchemas/index.d.ts.map +1 -0
- package/dist/fields/inputSchemas/utils.d.ts +25 -0
- package/dist/fields/inputSchemas/utils.d.ts.map +1 -0
- package/dist/fields/interfaceGen.d.ts +15 -0
- package/dist/fields/interfaceGen.d.ts.map +1 -0
- package/dist/fields/number/config.d.ts +48 -0
- package/dist/fields/number/config.d.ts.map +1 -0
- package/dist/fields/number/index.d.ts +5 -0
- package/dist/fields/number/index.d.ts.map +1 -0
- package/dist/fields/number/inputSchema.d.ts +23 -0
- package/dist/fields/number/inputSchema.d.ts.map +1 -0
- package/dist/fields/number/types.d.ts +100 -0
- package/dist/fields/number/types.d.ts.map +1 -0
- package/dist/fields/number/validator.d.ts +39 -0
- package/dist/fields/number/validator.d.ts.map +1 -0
- package/dist/fields/relationship/config.d.ts +45 -0
- package/dist/fields/relationship/config.d.ts.map +1 -0
- package/dist/fields/relationship/index.d.ts +5 -0
- package/dist/fields/relationship/index.d.ts.map +1 -0
- package/dist/fields/relationship/inputSchema.d.ts +31 -0
- package/dist/fields/relationship/inputSchema.d.ts.map +1 -0
- package/dist/fields/relationship/types.d.ts +126 -0
- package/dist/fields/relationship/types.d.ts.map +1 -0
- package/dist/fields/relationship/validator.d.ts +27 -0
- package/dist/fields/relationship/validator.d.ts.map +1 -0
- package/dist/fields/select/config.d.ts +59 -0
- package/dist/fields/select/config.d.ts.map +1 -0
- package/dist/fields/select/index.d.ts +5 -0
- package/dist/fields/select/index.d.ts.map +1 -0
- package/dist/fields/select/inputSchema.d.ts +28 -0
- package/dist/fields/select/inputSchema.d.ts.map +1 -0
- package/dist/fields/select/types.d.ts +89 -0
- package/dist/fields/select/types.d.ts.map +1 -0
- package/dist/fields/select/validator.d.ts +31 -0
- package/dist/fields/select/validator.d.ts.map +1 -0
- package/dist/fields/text/config.d.ts +48 -0
- package/dist/fields/text/config.d.ts.map +1 -0
- package/dist/fields/text/index.d.ts +5 -0
- package/dist/fields/text/index.d.ts.map +1 -0
- package/dist/fields/text/inputSchema.d.ts +24 -0
- package/dist/fields/text/inputSchema.d.ts.map +1 -0
- package/dist/fields/text/types.d.ts +132 -0
- package/dist/fields/text/types.d.ts.map +1 -0
- package/dist/fields/text/validator.d.ts +39 -0
- package/dist/fields/text/validator.d.ts.map +1 -0
- package/dist/fields/types.d.ts +135 -0
- package/dist/fields/types.d.ts.map +1 -0
- package/dist/fields/upload/config.d.ts +24 -0
- package/dist/fields/upload/config.d.ts.map +1 -0
- package/dist/fields/upload/index.d.ts +5 -0
- package/dist/fields/upload/index.d.ts.map +1 -0
- package/dist/fields/upload/inputSchema.d.ts +17 -0
- package/dist/fields/upload/inputSchema.d.ts.map +1 -0
- package/dist/fields/upload/types.d.ts +78 -0
- package/dist/fields/upload/types.d.ts.map +1 -0
- package/dist/fields/upload/validator.d.ts +16 -0
- package/dist/fields/upload/validator.d.ts.map +1 -0
- package/dist/fields/url/config.d.ts +49 -0
- package/dist/fields/url/config.d.ts.map +1 -0
- package/dist/fields/url/index.d.ts +5 -0
- package/dist/fields/url/index.d.ts.map +1 -0
- package/dist/fields/url/inputSchema.d.ts +31 -0
- package/dist/fields/url/inputSchema.d.ts.map +1 -0
- package/dist/fields/url/types.d.ts +70 -0
- package/dist/fields/url/types.d.ts.map +1 -0
- package/dist/fields/url/validator.d.ts +37 -0
- package/dist/fields/url/validator.d.ts.map +1 -0
- package/dist/fields/utils.d.ts +47 -0
- package/dist/fields/utils.d.ts.map +1 -0
- package/dist/fields/validators/index.d.ts +23 -0
- package/dist/fields/validators/index.d.ts.map +1 -0
- package/dist/fields/validators/utils.d.ts +24 -0
- package/dist/fields/validators/utils.d.ts.map +1 -0
- package/dist/framework.d.ts +227 -0
- package/dist/framework.d.ts.map +1 -0
- package/dist/globals/config/config.d.ts +1 -0
- package/dist/globals/config/config.d.ts.map +1 -0
- package/dist/globals/config/types.d.ts +1 -0
- package/dist/globals/config/types.d.ts.map +1 -0
- package/dist/globals/config.d.ts +47 -0
- package/dist/globals/config.d.ts.map +1 -0
- package/dist/globals/index.d.ts +5 -0
- package/dist/globals/index.d.ts.map +1 -0
- package/dist/globals/interfaceGen.d.ts +33 -0
- package/dist/globals/interfaceGen.d.ts.map +1 -0
- package/dist/globals/types.d.ts +175 -0
- package/dist/globals/types.d.ts.map +1 -0
- package/dist/globals/utils.d.ts +37 -0
- package/dist/globals/utils.d.ts.map +1 -0
- package/dist/index.d.ts +15 -3165
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2101 -3470
- package/dist/index.js.map +1 -1
- package/dist/media/api/index.d.ts +5 -0
- package/dist/media/api/index.d.ts.map +1 -0
- package/dist/media/api/mutations.d.ts +76 -0
- package/dist/media/api/mutations.d.ts.map +1 -0
- package/dist/media/api/queries.d.ts +28 -0
- package/dist/media/api/queries.d.ts.map +1 -0
- package/dist/media/api/server.d.ts +68 -0
- package/dist/media/api/server.d.ts.map +1 -0
- package/dist/media/api/types.d.ts +171 -0
- package/dist/media/api/types.d.ts.map +1 -0
- package/dist/media/config.d.ts +25 -0
- package/dist/media/config.d.ts.map +1 -0
- package/dist/media/index.d.ts +6 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/types.d.ts +332 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/utils.d.ts +35 -0
- package/dist/media/utils.d.ts.map +1 -0
- package/dist/media/validators.d.ts +61 -0
- package/dist/media/validators.d.ts.map +1 -0
- package/dist/schema/generateVexSchema.d.ts +36 -0
- package/dist/schema/generateVexSchema.d.ts.map +1 -0
- package/dist/schema/index.d.ts +3 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/migrate.d.ts +73 -0
- package/dist/schema/migrate.d.ts.map +1 -0
- package/dist/types/generateVexTypes.d.ts +41 -0
- package/dist/types/generateVexTypes.d.ts.map +1 -0
- package/dist/types/generated.d.ts +382 -0
- package/dist/types/generated.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils.d.ts +57 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +67 -24
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CollectionConfig } from "./types";
|
|
2
|
+
import type { VexConfig } from "../config";
|
|
3
|
+
/**
|
|
4
|
+
* Describes a relationship field in another collection that points to a given collection.
|
|
5
|
+
*
|
|
6
|
+
* Used by `collectionConfigToVexSchema` to detect whether a search index should be
|
|
7
|
+
* auto-generated on the current collection's `useAsTitle` field.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link getIncomingRelationships}
|
|
10
|
+
*/
|
|
11
|
+
export interface IncomingRelationship {
|
|
12
|
+
/** The slug of the collection that holds the relationship field. */
|
|
13
|
+
fromSlug: string;
|
|
14
|
+
/** The field key of the relationship field in that collection. */
|
|
15
|
+
fieldKey: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns all relationship fields in other collections that point to `collection`.
|
|
19
|
+
*
|
|
20
|
+
* Iterates every collection in `config` (excluding `collection` itself) and collects
|
|
21
|
+
* any field with `type === "relationship"` whose `collection` matches
|
|
22
|
+
* `props.collection.slug`.
|
|
23
|
+
*
|
|
24
|
+
* @param props - Input props.
|
|
25
|
+
* @param props.collection - The collection being checked for incoming relationships.
|
|
26
|
+
* @param props.config - The full resolved VexCMS configuration.
|
|
27
|
+
* @returns An array of `IncomingRelationship` descriptors, empty if none found.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* // posts has: author: relationship({ collection: "authors" })
|
|
32
|
+
* getIncomingRelationships({ collection: authorsCollection, config })
|
|
33
|
+
* // → [{ fromSlug: "posts", fieldKey: "author" }]
|
|
34
|
+
*/
|
|
35
|
+
export declare function getIncomingRelationships(props: {
|
|
36
|
+
collection: CollectionConfig;
|
|
37
|
+
config: VexConfig;
|
|
38
|
+
}): IncomingRelationship[];
|
|
39
|
+
/**
|
|
40
|
+
* Converts a resolved `CollectionConfig` to a Convex `defineTable(...)` source string.
|
|
41
|
+
*
|
|
42
|
+
* Iterates the collection's fields, builds each field's Convex validator via
|
|
43
|
+
* `adminFieldToValidator`, and appends index chains:
|
|
44
|
+
* - `.index()` for fields with an explicit `field.index` property
|
|
45
|
+
* - `.index("by_<fieldKey>", ["<fieldKey>"])` auto-generated for every relationship field
|
|
46
|
+
* - `.searchIndex()` for text fields with `field.searchIndex` configured
|
|
47
|
+
* - `.searchIndex("search_<useAsTitle>", { searchField: "<useAsTitle>", filterFields: [] })`
|
|
48
|
+
* auto-generated when another collection has a relationship pointing HERE and
|
|
49
|
+
* `useAsTitle` is not a Convex system field (`_id`, `_creationTime`), provided
|
|
50
|
+
* no manually configured search index already has that name.
|
|
51
|
+
*
|
|
52
|
+
* @param props - Input props.
|
|
53
|
+
* @param props.collection - The resolved collection definition to convert.
|
|
54
|
+
* @param props.config - The full resolved VexCMS config, needed for cross-collection relationship detection.
|
|
55
|
+
* @returns A TypeScript source string declaring the Convex table.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const posts = defineCollection({
|
|
60
|
+
* slug: "posts",
|
|
61
|
+
* fields: { author: relationship({ collection: "authors", required: true }) },
|
|
62
|
+
* });
|
|
63
|
+
* collectionConfigToVexSchema({ collection: posts, config });
|
|
64
|
+
* // → 'export const posts = defineTable({...})\n\t.index("by_author", ["author"])'
|
|
65
|
+
*
|
|
66
|
+
* @see {@link generateVexSchema} for the full-file generator that wraps this function
|
|
67
|
+
* @see {@link getIncomingRelationships} for the cross-collection helper
|
|
68
|
+
*/
|
|
69
|
+
export declare function collectionConfigToVexSchema(props: {
|
|
70
|
+
collection: CollectionConfig;
|
|
71
|
+
config: VexConfig;
|
|
72
|
+
}): string;
|
|
73
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/collections/validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,SAAS,CAAC;CACnB,GAAG,oBAAoB,EAAE,CA6BzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,UAAU,EAAE,gBAAgB,CAAC;IAC7B,MAAM,EAAE,SAAS,CAAC;CACnB,GAAG,MAAM,CAmDT"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { VexConfig, VexConfigInput } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolves a raw Vex config input into a fully-populated `VexConfig`.
|
|
4
|
+
*
|
|
5
|
+
* Applies defaults for any omitted properties — an absent `collections`
|
|
6
|
+
* array is replaced with an empty array so downstream consumers can always
|
|
7
|
+
* iterate without null-checking.
|
|
8
|
+
*
|
|
9
|
+
* When an `auth` adapter is provided, its collections are merged with
|
|
10
|
+
* user-defined collections via {@link mergeAuthCollections}. Protected
|
|
11
|
+
* auth collections cannot be overridden, and locked fields are preserved.
|
|
12
|
+
*
|
|
13
|
+
* @param config - The raw Vex configuration supplied by the caller.
|
|
14
|
+
* @returns The resolved `VexConfig` with all defaults applied.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* // Basic config with user-defined collections only
|
|
19
|
+
* defineConfig({
|
|
20
|
+
* collections: [
|
|
21
|
+
* defineCollection({ slug: "posts", fields: { title: text() } }),
|
|
22
|
+
* ],
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // Config with Better Auth integration
|
|
29
|
+
* import { betterAuthAdapter } from "@vexcms/better-auth";
|
|
30
|
+
*
|
|
31
|
+
* defineConfig({
|
|
32
|
+
* auth: betterAuthAdapter(authOptions),
|
|
33
|
+
* collections: [posts, authors],
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @see {@link VexConfigInput} for the user-facing input type
|
|
38
|
+
* @see {@link VexConfig} for the resolved return type
|
|
39
|
+
* @see {@link mergeAuthCollections} for auth collection merge logic
|
|
40
|
+
* @see {@link better-auth/src!betterAuthAdapter} for the Better Auth adapter
|
|
41
|
+
*/
|
|
42
|
+
export declare function defineConfig(config?: VexConfigInput): VexConfig;
|
|
43
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,SAAS,CAmD/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACjF,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { VexConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* A version of `VexConfig` safe to pass across RSC / JSON serialization
|
|
4
|
+
* boundaries. All non-serializable values (functions, React components, class
|
|
5
|
+
* instances, symbols) are replaced with `null`. The shape is otherwise
|
|
6
|
+
* identical to `VexConfig` — serializable fields retain their types.
|
|
7
|
+
*
|
|
8
|
+
* Produced by {@link sanitizeConfigForClient}.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link VexConfig} for the full server-side config
|
|
11
|
+
* @see {@link sanitizeConfigForClient} for the sanitization function
|
|
12
|
+
*/
|
|
13
|
+
export type ClientVexConfig = Sanitized<Omit<VexConfig, "access">>;
|
|
14
|
+
/**
|
|
15
|
+
* Recursively replaces all non-serializable values in a type with `null`.
|
|
16
|
+
*
|
|
17
|
+
* - Functions → `null`
|
|
18
|
+
* - Symbols → `null`
|
|
19
|
+
* - Class instances → `null`
|
|
20
|
+
* - Arrays → element type recursively sanitized
|
|
21
|
+
* - Plain objects → property types recursively sanitized
|
|
22
|
+
* - Primitives (string, number, boolean, null, undefined) → unchanged
|
|
23
|
+
*/
|
|
24
|
+
type Sanitized<T> = T extends (...args: any[]) => any ? null : T extends symbol ? null : T extends Array<infer U> ? Sanitized<U>[] : T extends object ? {
|
|
25
|
+
[K in keyof T]: Sanitized<T[K]>;
|
|
26
|
+
} : T;
|
|
27
|
+
/**
|
|
28
|
+
* Recursively strips all non-serializable values from an arbitrary value tree.
|
|
29
|
+
*
|
|
30
|
+
* Rules:
|
|
31
|
+
* - `null` / `undefined` → `null`
|
|
32
|
+
* - `function` → `null` (covers React components and callbacks)
|
|
33
|
+
* - `symbol` → `null`
|
|
34
|
+
* - Primitive (string, number, boolean) → returned as-is
|
|
35
|
+
* - Array → each element recursively processed
|
|
36
|
+
* - Plain object (`{}`) → each property recursively processed
|
|
37
|
+
* - Class instance (non-plain object) → `null`
|
|
38
|
+
*
|
|
39
|
+
* This function is intentionally exhaustive so that new non-serializable
|
|
40
|
+
* properties added anywhere in `VexConfig` are stripped automatically without
|
|
41
|
+
* requiring manual additions to `sanitizeConfigForClient`.
|
|
42
|
+
*
|
|
43
|
+
* @param value - Any value to sanitize.
|
|
44
|
+
* @returns A JSON-serializable version of `value`, with non-serializable
|
|
45
|
+
* leaves replaced by `null`.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare function stripNonSerializable(value: unknown): unknown;
|
|
50
|
+
/**
|
|
51
|
+
* Strips all non-serializable values from a `VexConfig` for safe passage
|
|
52
|
+
* across RSC / JSON serialization boundaries (e.g. server layout →
|
|
53
|
+
* client component).
|
|
54
|
+
*
|
|
55
|
+
* Uses {@link stripNonSerializable} to recursively walk the entire config
|
|
56
|
+
* tree, replacing functions, React components, class instances, and symbols
|
|
57
|
+
* with `null`. Adding a new non-serializable property anywhere in the config
|
|
58
|
+
* is handled automatically — no manual additions needed here.
|
|
59
|
+
*
|
|
60
|
+
* The `access` config is always omitted from the client version — it is
|
|
61
|
+
* never needed client-side and contains permission functions that cannot
|
|
62
|
+
* be serialized.
|
|
63
|
+
*
|
|
64
|
+
* @param config - The fully resolved server-side VexCMS config.
|
|
65
|
+
* @returns A deeply sanitized copy safe to pass to client components.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* // In a Next.js server component (e.g. AdminLayout):
|
|
70
|
+
* import vexConfig from "~/convex/vex.config";
|
|
71
|
+
* import { sanitizeConfigForClient } from "@vexcms/core";
|
|
72
|
+
*
|
|
73
|
+
* const clientConfig = sanitizeConfigForClient(vexConfig);
|
|
74
|
+
* return <AdminShell config={clientConfig} />;
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* @see {@link ClientVexConfig} for the sanitized type
|
|
78
|
+
* @see {@link stripNonSerializable} for the recursive sanitizer
|
|
79
|
+
*/
|
|
80
|
+
export declare function sanitizeConfigForClient(config: VexConfig): ClientVexConfig;
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=sanitizeConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitizeConfig.d.ts","sourceRoot":"","sources":["../../src/config/sanitizeConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEnE;;;;;;;;;GASG;AAEH,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GACjD,IAAI,GACJ,CAAC,SAAS,MAAM,GACd,IAAI,GACJ,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GACtB,SAAS,CAAC,CAAC,CAAC,EAAE,GACd,CAAC,SAAS,MAAM,GACd;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACnC,CAAC,CAAC;AAmBZ;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAwB5D;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,eAAe,CAO1E"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { CollectionConfig } from "../collections";
|
|
2
|
+
import { VexAuthAdapter } from "../auth/types";
|
|
3
|
+
import { MediaCollectionConfig, VexStorageAdapter } from "../media";
|
|
4
|
+
import { StorageAdapterSlug } from "../types";
|
|
5
|
+
import { GlobalConfig } from "../globals";
|
|
6
|
+
import { VexAccessConfig } from "../access";
|
|
7
|
+
/**
|
|
8
|
+
* User-facing configuration input for the VexCMS admin panel.
|
|
9
|
+
*
|
|
10
|
+
* All properties are optional — omitted properties fall back to the defaults below.
|
|
11
|
+
*
|
|
12
|
+
* **Defaults applied by `defineConfig()`:**
|
|
13
|
+
* ```ts
|
|
14
|
+
* {
|
|
15
|
+
* sidebar: {
|
|
16
|
+
* side: "left", // sidebar rendered on the left side of the viewport
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Move the sidebar to the right side
|
|
24
|
+
* defineConfig({
|
|
25
|
+
* admin: { sidebar: { side: "right" } },
|
|
26
|
+
* collections: [posts],
|
|
27
|
+
* })
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @see {@link AdminConfig} for the resolved type after defaults are applied
|
|
31
|
+
* @see {@link defineConfig} for the config function
|
|
32
|
+
*/
|
|
33
|
+
export interface AdminConfigInput {
|
|
34
|
+
/**
|
|
35
|
+
* Navigation sidebar configuration for the admin panel.
|
|
36
|
+
*
|
|
37
|
+
* Controls the sidebar that houses collection links and navigation items.
|
|
38
|
+
* All properties are optional; omitted values fall back to the defaults below.
|
|
39
|
+
*
|
|
40
|
+
* **Defaults applied by `defineConfig()`:**
|
|
41
|
+
* ```ts
|
|
42
|
+
* { side: "left" } // sidebar rendered on the left side of the viewport
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
sidebar?: {
|
|
46
|
+
/**
|
|
47
|
+
* Which side of the viewport the admin sidebar is anchored to.
|
|
48
|
+
*
|
|
49
|
+
* - `"left"` — sidebar sits on the left (default)
|
|
50
|
+
* - `"right"` — sidebar sits on the right
|
|
51
|
+
*/
|
|
52
|
+
side?: "left" | "right";
|
|
53
|
+
/**
|
|
54
|
+
* How the sidebar in the admin panel collapses
|
|
55
|
+
*
|
|
56
|
+
* - `"offcanvas"` — A collapsible sidebar that slides in from the left or right.
|
|
57
|
+
* - `"icon"` — A sidebar that collapses to icons.
|
|
58
|
+
* - `"none"` — A non-collapsible sidebar.
|
|
59
|
+
*/
|
|
60
|
+
collapsible?: "offcanvas" | "none" | "icon";
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolved admin panel configuration after defaults are applied by `defineConfig()`.
|
|
65
|
+
*
|
|
66
|
+
* @see {@link AdminConfigInput} for the user-facing input type
|
|
67
|
+
* @see {@link defineConfig} for the config function
|
|
68
|
+
*/
|
|
69
|
+
export interface AdminConfig {
|
|
70
|
+
/** Navigation sidebar configuration — always present after defaults are applied. */
|
|
71
|
+
sidebar: {
|
|
72
|
+
/** Which side of the viewport the admin sidebar is anchored to. */
|
|
73
|
+
side: "left" | "right";
|
|
74
|
+
/**
|
|
75
|
+
* How the sidebar in the admin panel collapses
|
|
76
|
+
*/
|
|
77
|
+
collapsible: "offcanvas" | "none" | "icon";
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* User-facing schema generation configuration for `defineConfig()`.
|
|
82
|
+
*
|
|
83
|
+
* Controls where generated files are written and whether automatic database
|
|
84
|
+
* migrations run when the schema changes. All properties are optional; omitted
|
|
85
|
+
* properties fall back to the defaults listed below.
|
|
86
|
+
*
|
|
87
|
+
* **Defaults applied by `defineConfig()`:**
|
|
88
|
+
* ```ts
|
|
89
|
+
* {
|
|
90
|
+
* outputPath: "/convex/vex.schema.ts", // vex.schema.ts output location
|
|
91
|
+
* typesOutputPath: "/convex/vex.types.ts", // vex.types.ts output location
|
|
92
|
+
* autoMigrate: false, // no auto-migration on schema change
|
|
93
|
+
* autoRemove: false, // removed tables stay in schema.ts
|
|
94
|
+
* }
|
|
95
|
+
*
|
|
96
|
+
* @see {@link SchemaConfig} for the resolved type after defaults are applied
|
|
97
|
+
*/
|
|
98
|
+
export interface SchemaConfigInput {
|
|
99
|
+
/**
|
|
100
|
+
* Path (relative to project root) where `vex.schema.ts` is written.
|
|
101
|
+
*
|
|
102
|
+
* Default: `"/convex/vex.schema.ts"`
|
|
103
|
+
*/
|
|
104
|
+
outputPath?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolved schema generation configuration after defaults are applied.
|
|
108
|
+
*
|
|
109
|
+
* @see {@link SchemaConfigInput} for the user-facing input type
|
|
110
|
+
*/
|
|
111
|
+
export interface SchemaConfig {
|
|
112
|
+
/** Path where `vex.schema.ts` is written. Always set after defaults are applied. */
|
|
113
|
+
outputPath: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* User-facing schema generation configuration for `defineConfig()`.
|
|
117
|
+
*
|
|
118
|
+
* Controls where generated files are written and whether automatic database
|
|
119
|
+
* migrations run when the schema changes. All properties are optional; omitted
|
|
120
|
+
* properties fall back to the defaults listed below.
|
|
121
|
+
*
|
|
122
|
+
* **Defaults applied by `defineConfig()`:**
|
|
123
|
+
* ```ts
|
|
124
|
+
* {
|
|
125
|
+
* outputPath: "/convex/vex.schema.ts", // vex.schema.ts output location
|
|
126
|
+
* typesOutputPath: "/convex/vex.types.ts", // vex.types.ts output location
|
|
127
|
+
* autoMigrate: false, // no auto-migration on schema change
|
|
128
|
+
* autoRemove: false, // removed tables stay in schema.ts
|
|
129
|
+
* }
|
|
130
|
+
*
|
|
131
|
+
* @see {@link SchemaConfig} for the resolved type after defaults are applied
|
|
132
|
+
*/
|
|
133
|
+
export interface TypesConfigInput {
|
|
134
|
+
/**
|
|
135
|
+
* Path (relative to project root) where `vex.types.ts` is written.
|
|
136
|
+
*
|
|
137
|
+
* Default: `"/convex/vex.schema.ts"`
|
|
138
|
+
*/
|
|
139
|
+
outputPath?: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Resolved schema generation configuration after defaults are applied.
|
|
143
|
+
*
|
|
144
|
+
* @see {@link SchemaConfigInput} for the user-facing input type
|
|
145
|
+
*/
|
|
146
|
+
export interface TypesConfig {
|
|
147
|
+
/** Path where `vex.types.ts` is written. Always set after defaults are applied. */
|
|
148
|
+
outputPath: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Client-side upload functions for each registered presigned-url adapter.
|
|
152
|
+
*
|
|
153
|
+
* Keys are `StorageAdapterSlug` — only adapters whose `type` is
|
|
154
|
+
* `"presigned-url"` and whose `name` appears in the config are valid.
|
|
155
|
+
* After `vex generate`, this is narrowed to the exact set of adapter
|
|
156
|
+
* names in the project.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* // apps/test/src/app/(vexcms)/admin/clientProviders.tsx
|
|
161
|
+
* import { StorageAdapterContextProvider } from "@vexcms/react";
|
|
162
|
+
* import { uploadFile } from "@vexcms/file-storage-convex/adapter";
|
|
163
|
+
*
|
|
164
|
+
* // Pass the map to StorageAdapterContextProvider — one entry per registered adapter.
|
|
165
|
+
* <StorageAdapterContextProvider adapterClients={{ convex: uploadFile }}>
|
|
166
|
+
* {children}
|
|
167
|
+
* </StorageAdapterContextProvider>
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export type ClientUploadMap = Record<StorageAdapterSlug, (file: any, uploadUrl: string) => Promise<{
|
|
171
|
+
storageId: string;
|
|
172
|
+
url?: string;
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
}>>;
|
|
175
|
+
/**
|
|
176
|
+
* User-facing configuration input passed to `defineConfig()`.
|
|
177
|
+
*
|
|
178
|
+
* All properties are optional — omitting `collections` produces an empty CMS
|
|
179
|
+
* with no custom content types registered.
|
|
180
|
+
*
|
|
181
|
+
* **Defaults applied by `defineConfig()`:**
|
|
182
|
+
* ```ts
|
|
183
|
+
* {
|
|
184
|
+
* collections: [], // no collections registered — the CMS starts empty
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* // Register a collection
|
|
191
|
+
* defineConfig({
|
|
192
|
+
* collections: [
|
|
193
|
+
* defineCollection({ slug: "posts", fields: { title: text() } }),
|
|
194
|
+
* ],
|
|
195
|
+
* });
|
|
196
|
+
*
|
|
197
|
+
* // Register collections and customise the admin panel
|
|
198
|
+
* defineConfig({
|
|
199
|
+
* admin: { sidebar: { side: "right" } },
|
|
200
|
+
* collections: [posts, authors],
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @see {@link VexConfig} for the resolved type after defaults are applied
|
|
205
|
+
* @see {@link defineConfig} for the config function
|
|
206
|
+
*/
|
|
207
|
+
export interface VexConfigInput {
|
|
208
|
+
/**
|
|
209
|
+
* Admin panel configuration. All properties are optional — omitted values fall back to defaults.
|
|
210
|
+
*
|
|
211
|
+
* **Defaults applied by `defineConfig()`:**
|
|
212
|
+
* ```ts
|
|
213
|
+
* { sidebar: { side: "left" } }
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* @see {@link AdminConfigInput} for all available options
|
|
217
|
+
*/
|
|
218
|
+
admin?: AdminConfigInput;
|
|
219
|
+
access?: VexAccessConfig;
|
|
220
|
+
/** Content collections to register with the CMS. Defaults to `[]` if omitted. */
|
|
221
|
+
collections?: CollectionConfig[];
|
|
222
|
+
/** Singleton global documents. Each produced by `defineGlobal()`. Slugs must be unique. */
|
|
223
|
+
globals?: GlobalConfig[];
|
|
224
|
+
/**
|
|
225
|
+
* URL prefix for all admin panel routes.
|
|
226
|
+
*
|
|
227
|
+
* Default: `"/admin"`. Override when mounting the admin UI at a custom path
|
|
228
|
+
* (e.g. `"/cms"` or `"/dashboard/admin"`).
|
|
229
|
+
*/
|
|
230
|
+
basePath?: string;
|
|
231
|
+
/**
|
|
232
|
+
* Schema generation configuration — controls output paths and auto-migration.
|
|
233
|
+
* All properties are optional; omitted values fall back to defaults.
|
|
234
|
+
*
|
|
235
|
+
* @see {@link SchemaConfigInput} for all available options
|
|
236
|
+
*/
|
|
237
|
+
schema?: SchemaConfigInput;
|
|
238
|
+
types?: TypesConfigInput;
|
|
239
|
+
/**
|
|
240
|
+
* Auth adapter to register authentication collections (user, session,
|
|
241
|
+
* account, verification, etc.) alongside user-defined collections.
|
|
242
|
+
*
|
|
243
|
+
* Pass the return value of an auth adapter (e.g.
|
|
244
|
+
* {@link better-auth/src!betterAuthAdapter} from `@vexcms/better-auth`). Auth collections
|
|
245
|
+
* are merged with user collections by `defineConfig()` — protected auth
|
|
246
|
+
* collections cannot be overridden, and locked fields are preserved.
|
|
247
|
+
*
|
|
248
|
+
* @see {@link VexAuthAdapter} for the adapter interface
|
|
249
|
+
* @see {@link better-auth/src!betterAuthAdapter} for the Better Auth implementation
|
|
250
|
+
*/
|
|
251
|
+
authAdapter?: VexAuthAdapter;
|
|
252
|
+
/**
|
|
253
|
+
* Storage configuration — adapters and client-side upload functions.
|
|
254
|
+
*
|
|
255
|
+
* When present, media collections are available in the admin panel and
|
|
256
|
+
* `upload()` fields can be used in regular collections. The `adapters`
|
|
257
|
+
* array holds the server-side adapter instances (stripped by
|
|
258
|
+
* `sanitizeConfigForClient`). The `clientUploads` map holds serializable
|
|
259
|
+
* `uploadFile` functions that the admin panel uses to upload files
|
|
260
|
+
* directly from the browser. Keys are `StorageAdapterSlug` — only
|
|
261
|
+
* presigned-url adapters registered in the config are valid.
|
|
262
|
+
*
|
|
263
|
+
* @see {@link VexStorageAdapter} for the adapter interface
|
|
264
|
+
* @see {@link StorageAdapterSlug} for the key type
|
|
265
|
+
* @see {@link file-storage-convex/src!convexFileStorage} from `@vexcms/file-storage-convex` for the first adapter
|
|
266
|
+
*/
|
|
267
|
+
storage?: {
|
|
268
|
+
/** Storage adapters configured for the project. */
|
|
269
|
+
adapters: VexStorageAdapter[];
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Resolved Vex CMS configuration after defaults are applied by `defineConfig()`.
|
|
274
|
+
*
|
|
275
|
+
* @see {@link VexConfigInput} for the user-facing input type
|
|
276
|
+
* @see {@link defineConfig} for the config function
|
|
277
|
+
*/
|
|
278
|
+
export interface VexConfig {
|
|
279
|
+
/** Resolved admin panel configuration — always fully populated after defaults are applied. */
|
|
280
|
+
admin: AdminConfig;
|
|
281
|
+
access?: VexAccessConfig;
|
|
282
|
+
/** All registered content collections — always an array after defaults are applied. */
|
|
283
|
+
collections: CollectionConfig[];
|
|
284
|
+
/** Resolved global configs. Always present; defaults to `[]`. */
|
|
285
|
+
globals: GlobalConfig[];
|
|
286
|
+
/** URL prefix for all admin panel routes — always set after defaults are applied. */
|
|
287
|
+
basePath: string;
|
|
288
|
+
/** Resolved schema generation configuration — always fully populated after defaults are applied. */
|
|
289
|
+
schema: SchemaConfig;
|
|
290
|
+
types: TypesConfig;
|
|
291
|
+
/**
|
|
292
|
+
* Auth adapter registered with this config. Auth collections are merged
|
|
293
|
+
* with user-defined collections — protected collections and locked fields
|
|
294
|
+
* are preserved during merge.
|
|
295
|
+
*
|
|
296
|
+
* @see {@link VexAuthAdapter} for the adapter interface
|
|
297
|
+
* @see {@link better-auth/src!betterAuthAdapter} for the Better Auth implementation
|
|
298
|
+
*/
|
|
299
|
+
auth?: VexAuthAdapter;
|
|
300
|
+
/**
|
|
301
|
+
* Storage adapters registered with this config. Processed media collections
|
|
302
|
+
* from all adapters are available via `mediaCollections`.
|
|
303
|
+
*/
|
|
304
|
+
storage?: {
|
|
305
|
+
/** Storage adapters configured for the project. */
|
|
306
|
+
adapters: VexStorageAdapter[];
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* Media collections — processed by storage adapters and stored separately
|
|
310
|
+
* from user-defined `collections`. These appear in the admin panel under a
|
|
311
|
+
* dedicated "Media" section. Each collection is tagged with
|
|
312
|
+
* `meta.storageAdapterName` indicating which adapter owns it.
|
|
313
|
+
*/
|
|
314
|
+
mediaCollections: MediaCollectionConfig[];
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseFieldMeta } from "../types";
|
|
2
|
+
import type { ArrayFieldInput, ArrayField, ArrayType } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an array field with all defaults applied.
|
|
5
|
+
*
|
|
6
|
+
* Array fields store ordered lists of values — strings, numbers, booleans,
|
|
7
|
+
* or nested objects. Items are validated by a nested field definition
|
|
8
|
+
* (`items`) which supports any VexCMS field type including nested arrays.
|
|
9
|
+
*
|
|
10
|
+
* Accepts {@link ArrayFieldInput} (all optional) and returns {@link ArrayField}
|
|
11
|
+
* with all defaults applied.
|
|
12
|
+
*
|
|
13
|
+
* **Defaults applied:**
|
|
14
|
+
* - `label` — `""` (inferred from the field key by `defineCollection`)
|
|
15
|
+
* - `labels.singular` — `"Item"`
|
|
16
|
+
* - `labels.plural` — `"Items"`
|
|
17
|
+
* - `required` — `false`
|
|
18
|
+
* - `defaultValue` — `[]`
|
|
19
|
+
* - `admin.hidden` — `false`
|
|
20
|
+
* - `admin.readOnly` — `false`
|
|
21
|
+
* - `admin.position` — `"main"`
|
|
22
|
+
* - `admin.width` — `"full"`
|
|
23
|
+
* - `admin.cellAlignment` — `"left"`
|
|
24
|
+
*
|
|
25
|
+
* @param options - Array field configuration. All properties are optional.
|
|
26
|
+
* @returns Resolved array field definition with all defaults applied.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { array, text, defineCollection } from '@vexcms/core'
|
|
31
|
+
*
|
|
32
|
+
* posts: defineCollection({
|
|
33
|
+
* fields: {
|
|
34
|
+
* // Simple string tags array
|
|
35
|
+
* tags: array({
|
|
36
|
+
* items: text(),
|
|
37
|
+
* }),
|
|
38
|
+
*
|
|
39
|
+
* // Number array with a min length
|
|
40
|
+
* scores: array({
|
|
41
|
+
* items: number(),
|
|
42
|
+
* min: { value: 1 },
|
|
43
|
+
* }),
|
|
44
|
+
*
|
|
45
|
+
* // Nested array — array of arrays of numbers
|
|
46
|
+
* matrix: array({
|
|
47
|
+
* items: array({ items: number() }),
|
|
48
|
+
* }),
|
|
49
|
+
* }
|
|
50
|
+
* })
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @see {@link ArrayFieldInput} for the full input type
|
|
54
|
+
* @see {@link ArrayField} for the resolved output type
|
|
55
|
+
*/
|
|
56
|
+
export declare function array<TArrayType extends ArrayType = string, TFieldMeta extends BaseFieldMeta = BaseFieldMeta>(options: ArrayFieldInput<TArrayType, TFieldMeta>): ArrayField<TArrayType, TFieldMeta>;
|
|
57
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/fields/array/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,KAAK,CACnB,UAAU,SAAS,SAAS,GAAG,MAAM,EACrC,UAAU,SAAS,aAAa,GAAG,aAAa,EAChD,OAAO,EAAE,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CA2CtF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/array/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ZodType } from "zod";
|
|
2
|
+
import { ArrayField, ArrayType } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a Zod schema for validating an array field value in the admin form.
|
|
5
|
+
*
|
|
6
|
+
* Wraps the nested item schema in `z.array(…)`, applies `min`/`max` item count
|
|
7
|
+
* constraints when configured, then wraps in `.optional()` for non-required
|
|
8
|
+
* fields via `applyBaseInputSchemaMeta`. The item schema is built
|
|
9
|
+
* recursively by delegating to `adminFieldToInputSchema` for the nested field.
|
|
10
|
+
*
|
|
11
|
+
* @param props - Input props.
|
|
12
|
+
* @param props.field - The resolved array field definition
|
|
13
|
+
* @returns A Zod array schema with item count constraints, a baked-in `.default(field.defaultValue)`, and optionality applied
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const field = array({ items: text(), required: true })
|
|
18
|
+
* arrayFieldToInputSchema({ field })
|
|
19
|
+
* // → z.array(z.string()).superRefine(...).default([])
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const field = array({ items: number(), min: { value: 1 }, max: { value: 5 } })
|
|
25
|
+
* arrayFieldToInputSchema({ field })
|
|
26
|
+
* // → z.array(z.number()).min(1).max(5).default([])
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function arrayFieldToInputSchema<TArrayType extends ArrayType = string, TFieldMeta extends {} = {}>(props: {
|
|
30
|
+
field: ArrayField<TArrayType, TFieldMeta>;
|
|
31
|
+
}): ZodType;
|
|
32
|
+
//# sourceMappingURL=inputSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputSchema.d.ts","sourceRoot":"","sources":["../../../src/fields/array/inputSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,SAAS,SAAS,GAAG,MAAM,EACrC,UAAU,SAAS,EAAE,GAAG,EAAE,EAC1B,KAAK,EAAE;IAAE,KAAK,EAAE,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;CAAE,GAAG,OAAO,CAyD/D"}
|