@vexcms/core 0.0.20 → 0.1.0-alpha.3
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 -3475
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/fields/url/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,WAAW,aAAa,CAC5B,UAAU,SAAS,EAAE,GAAG,EAAE,CAC1B,SAAQ,cAAc,CAAC,UAAU,CAAC;IAClC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ,CAAC,UAAU,SAAS,EAAE,GAAG,EAAE,CAAE,SAAQ,SAAS,CAAC,UAAU,CAAC;IACjF,QAAQ,CAAC,IAAI,EAAE,OAAO,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;IAC5C;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { UrlField } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a URL field definition to a Convex schema validator string.
|
|
4
|
+
*
|
|
5
|
+
* URL fields are stored as plain strings in Convex — the URL format is
|
|
6
|
+
* enforced at the admin form layer, not in the database schema. This
|
|
7
|
+
* function generates only the type constraint.
|
|
8
|
+
*
|
|
9
|
+
* Length constraints (`min`, `max`) are runtime validation — they do not
|
|
10
|
+
* affect the generated Convex validator string. Index configuration is
|
|
11
|
+
* handled separately by the collection schema builder.
|
|
12
|
+
*
|
|
13
|
+
* @param props - Input props.
|
|
14
|
+
* @param props.field - The resolved URL field definition.
|
|
15
|
+
* @returns Convex validator string: `"v.string()"` for required fields,
|
|
16
|
+
* `"v.optional(v.string())"` for optional fields.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const field1 = url({ required: true })
|
|
21
|
+
* urlFieldToValidator({ field: field1 }) // "v.string()"
|
|
22
|
+
*
|
|
23
|
+
* const field2 = url({ required: false })
|
|
24
|
+
* urlFieldToValidator({ field: field2 }) // "v.optional(v.string())"
|
|
25
|
+
*
|
|
26
|
+
* const field3 = url({ min: { value: 10 }, max: { value: 2048 } })
|
|
27
|
+
* urlFieldToValidator({ field: field3 }) // "v.optional(v.string())"
|
|
28
|
+
* // Length constraints don't affect schema — handled at validation layer
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @see {@link urlFieldToInputSchema} for the admin-form Zod schema with URL format and length validation
|
|
32
|
+
* @internal Used by schema generation, not typically called directly.
|
|
33
|
+
*/
|
|
34
|
+
export declare function urlFieldToValidator(props: {
|
|
35
|
+
field: UrlField;
|
|
36
|
+
}): string;
|
|
37
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/fields/url/validator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,QAAQ,CAAA;CAAE,GAAG,MAAM,CAKtE"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AdminField } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a string into lines that do not exceed `maxLen` characters, splitting
|
|
4
|
+
* on word boundaries.
|
|
5
|
+
*
|
|
6
|
+
* Used by `adminFieldToJSDocComment` to keep JSDoc comment lines within the
|
|
7
|
+
* conventional 80-character limit before emitting them into generated source files.
|
|
8
|
+
*
|
|
9
|
+
* @param props - Input props.
|
|
10
|
+
* @param props.text - The string to wrap.
|
|
11
|
+
* @param props.maxLen - Maximum character length per line.
|
|
12
|
+
* @returns An array of strings, each no longer than `maxLen` characters.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* wrapLines({ text: "This is a long description that should wrap.", maxLen: 20 })
|
|
17
|
+
* // → ["This is a long", "description that", "should wrap."]
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function wrapLines(props: {
|
|
21
|
+
text: string;
|
|
22
|
+
maxLen: number;
|
|
23
|
+
}): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Builds a tab-indented JSDoc comment block for a field's description.
|
|
26
|
+
*
|
|
27
|
+
* Reads `field.interfaceDescription` first, falling back to `field.description`.
|
|
28
|
+
* Returns an empty string when neither is set. The output is ready to insert
|
|
29
|
+
* directly above a property line in a generated TypeScript interface — lines are
|
|
30
|
+
* wrapped at 80 characters via `wrapLines`.
|
|
31
|
+
*
|
|
32
|
+
* @param props - Input props.
|
|
33
|
+
* @param props.field - The resolved field definition to extract the description from.
|
|
34
|
+
* @returns A tab-indented JSDoc block string ready to splice into generated
|
|
35
|
+
* TypeScript source, or an empty string if the field has no description.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const field = text({ description: "Page title shown in browser tabs." })
|
|
40
|
+
* adminFieldToJSDocComment({ field })
|
|
41
|
+
* // Returns a multi-line JSDoc block wrapping the description text
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function adminFieldToJSDocComment(props: {
|
|
45
|
+
field: AdminField;
|
|
46
|
+
}): string;
|
|
47
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/fields/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,EAAE,CAc3E;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG,MAAM,CAW7E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AdminField } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Converts any field definition to its Convex schema validator string.
|
|
4
|
+
*
|
|
5
|
+
* Dispatches to the field-type-specific validator function based on `field.type`.
|
|
6
|
+
* Used by the CLI during schema generation to build the Convex schema file.
|
|
7
|
+
*
|
|
8
|
+
* @param props Input props
|
|
9
|
+
* @param props.field - The resolved field definition to convert
|
|
10
|
+
* @returns A Convex validator string (e.g. `"v.string()"`, `"v.optional(v.boolean())"`)
|
|
11
|
+
* @throws An Error if an unrecognized field type is given. Reaching this is a
|
|
12
|
+
* compile error: the default arm binds the exhausted union to `never`, so a new
|
|
13
|
+
* member of `AdminField` fails typecheck here until a case is added
|
|
14
|
+
*
|
|
15
|
+
* @see {@link textFieldToValidator} for the text field implementation
|
|
16
|
+
* @see {@link numberFieldToValidator} for the number field implementation
|
|
17
|
+
* @see {@link checkboxFieldToValidator} for the checkbox field implementation
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function adminFieldToValidator<TFieldMeta extends {} = {}>(props: {
|
|
21
|
+
field: AdminField<TFieldMeta>;
|
|
22
|
+
}): string;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/fields/validators/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AActC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,SAAS,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE;IACvE,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAC/B,UAqCA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AdminField } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a Convex validator string in `v.optional()` when the field is not required.
|
|
4
|
+
*
|
|
5
|
+
* Used during schema generation to apply the correct Convex validator based on
|
|
6
|
+
* whether the field is marked as required in its config.
|
|
7
|
+
*
|
|
8
|
+
* @param props - handleOptionalValidators() input props
|
|
9
|
+
* @param props.field - The resolved field definition, used to check `required`
|
|
10
|
+
* @param props.validator - A Convex validator expression string (e.g. `"v.string()"`)
|
|
11
|
+
* @returns The validator string, wrapped in `v.optional(...)` if the field is optional
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* handleOptionalValidators({ field: textField, validator: "v.string()" })
|
|
16
|
+
* // required field → "v.string()"
|
|
17
|
+
* // optional field → "v.optional(v.string())"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function applyBaseValidators(props: {
|
|
21
|
+
field: AdminField;
|
|
22
|
+
validator: string;
|
|
23
|
+
}): string;
|
|
24
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/fields/validators/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,KAAK,EAAE,UAAU,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,MAAM,CAKT"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { CollectionConfig } from "./collections";
|
|
2
|
+
import { ClientVexConfig } from "./config";
|
|
3
|
+
import type { AdminField, ApplyComponent, BaseFieldMeta, CellComponentProps, ComponentHKT, InputComponentProps } from "./fields";
|
|
4
|
+
import type { VexDocument } from "./api/convex";
|
|
5
|
+
import { CollectionSlug, GlobalSlug, VexDocumentGlobal } from "./types/generated";
|
|
6
|
+
import { PaginationResult } from "./api/types";
|
|
7
|
+
import { GlobalConfig } from "./globals";
|
|
8
|
+
/**
|
|
9
|
+
* Maps every field type in the `AdminField` union to the framework's input component type
|
|
10
|
+
* for that field.
|
|
11
|
+
*
|
|
12
|
+
* Keyed by `AdminField['type']` — as new field types are added to the union, TypeScript
|
|
13
|
+
* automatically requires a matching component slot in this map.
|
|
14
|
+
*
|
|
15
|
+
* Each slot resolves to `ApplyComponent<F, InputComponentProps<MatchingFieldDef>>`, which
|
|
16
|
+
* means the component must accept the input props for that specific field type. This gives
|
|
17
|
+
* the component full autocomplete for field-specific properties (e.g. `fieldDef.max`
|
|
18
|
+
* on the text slot).
|
|
19
|
+
*
|
|
20
|
+
* @see {@link CellComponentProps} for the data table cell props
|
|
21
|
+
* @see {@link ComponentHKT} for how framework packages define their HKT
|
|
22
|
+
* @see {@link ApplyComponent} for how the HKT resolves to a concrete component type
|
|
23
|
+
*/
|
|
24
|
+
export type FieldComponentMap<F extends ComponentHKT, TFieldMeta extends BaseFieldMeta = BaseFieldMeta> = {
|
|
25
|
+
[K in AdminField["type"]]: {
|
|
26
|
+
input: ApplyComponent<F, InputComponentProps<TFieldMeta, Extract<AdminField<TFieldMeta>, {
|
|
27
|
+
type: K;
|
|
28
|
+
}>>>;
|
|
29
|
+
cell: ApplyComponent<F, CellComponentProps<Extract<AdminField<TFieldMeta>, {
|
|
30
|
+
type: K;
|
|
31
|
+
}>>>;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Props passed to the admin `Dashboard` view component.
|
|
36
|
+
*
|
|
37
|
+
* The Dashboard receives the full resolved VexCMS config and is responsible
|
|
38
|
+
* for rendering the admin shell — navigation sidebar, header, and a slot for
|
|
39
|
+
* the active view (collection list or edit form).
|
|
40
|
+
*
|
|
41
|
+
* @see {@link ViewComponentMap}
|
|
42
|
+
*/
|
|
43
|
+
export interface DashboardProps {
|
|
44
|
+
/** The full resolved VexCMS configuration. */
|
|
45
|
+
config: ClientVexConfig;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Props passed to the `CollectionListView` component.
|
|
49
|
+
*
|
|
50
|
+
* `TCollectionSlug` is inferred from the `collection` prop and narrows the collection type
|
|
51
|
+
* to a specific slug after `vex generate` runs. `TDoc` defaults to `VexDocument`
|
|
52
|
+
* and can be narrowed to a generated document interface when the caller has a
|
|
53
|
+
* typed initial data array.
|
|
54
|
+
*
|
|
55
|
+
* @see {@link ViewComponentMap}
|
|
56
|
+
*/
|
|
57
|
+
export interface CollectionListViewProps<TFieldMeta extends {} = {}, TCollectionMeta extends {} = {}, TCollectionSlug extends CollectionSlug = CollectionSlug, TDoc extends VexDocument = VexDocument> {
|
|
58
|
+
/** The resolved collection configuration for the collection being listed. */
|
|
59
|
+
collection: CollectionConfig<TFieldMeta, TCollectionMeta, TCollectionSlug>;
|
|
60
|
+
/**
|
|
61
|
+
* Pre-fetched documents from the server. Passed as `initialData` to
|
|
62
|
+
* the TanStack Query so the list renders immediately on first load.
|
|
63
|
+
* Omit when rendering client-side only.
|
|
64
|
+
*/
|
|
65
|
+
initialData?: PaginationResult<TDoc>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Props passed to the `CollectionEditView` component.
|
|
69
|
+
*
|
|
70
|
+
* `TCollectionSlug` is inferred from the `collection` prop. After `vex generate` runs,
|
|
71
|
+
* passing a collection of the wrong slug is a compile-time error.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link ViewComponentMap}
|
|
74
|
+
*/
|
|
75
|
+
export interface CollectionEditViewProps<TFieldMeta extends {} = {}, TCollectionMeta extends {} = {}, TCollectionSlug extends CollectionSlug = CollectionSlug, TDocument extends VexDocument = VexDocument> {
|
|
76
|
+
/** The resolved collection configuration whose fields will be rendered. */
|
|
77
|
+
collection: CollectionConfig<TFieldMeta, TCollectionMeta, TCollectionSlug>;
|
|
78
|
+
/**
|
|
79
|
+
* The Convex document ID of the document being edited.
|
|
80
|
+
* Omit for new document creation — the form will be empty.
|
|
81
|
+
*/
|
|
82
|
+
documentId: VexDocument["_id"];
|
|
83
|
+
/**
|
|
84
|
+
* Pre-fetched document from the server for SSR hydration.
|
|
85
|
+
* `null` explicitly means "no document found". `undefined` means "not loaded yet".
|
|
86
|
+
*/
|
|
87
|
+
initialData?: TDocument | null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Props passed to the `GlobalEditView` component.
|
|
91
|
+
*
|
|
92
|
+
* `TGlobalSlug` is inferred from the `global` prop. After `vex generate` runs,
|
|
93
|
+
* passing a global config with an unregistered slug is a compile-time error.
|
|
94
|
+
*
|
|
95
|
+
* @see {@link ViewComponentMap}
|
|
96
|
+
*/
|
|
97
|
+
export interface GlobalEditViewProps<TFieldMeta extends {} = {}, TGlobalMeta extends {} = {}, TGlobalSlug extends GlobalSlug = GlobalSlug, TDocument extends VexDocumentGlobal = VexDocumentGlobal> {
|
|
98
|
+
/** The resolved global configuration whose fields will be rendered. */
|
|
99
|
+
global: GlobalConfig<TFieldMeta, TGlobalMeta, TGlobalSlug>;
|
|
100
|
+
/**
|
|
101
|
+
* Pre-fetched document from the server for SSR hydration.
|
|
102
|
+
* `null` explicitly means "no document found". `undefined` means "not loaded yet".
|
|
103
|
+
*/
|
|
104
|
+
initialData?: TDocument | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Maps the three required admin views to their framework component types.
|
|
108
|
+
*
|
|
109
|
+
* All three are required — omitting any one causes a TypeScript error at the
|
|
110
|
+
* `defineFrameworkAdapter` call site.
|
|
111
|
+
*
|
|
112
|
+
* @see {@link FrameworkAdapterInput}
|
|
113
|
+
*/
|
|
114
|
+
export type ViewComponentMap<F extends ComponentHKT> = {
|
|
115
|
+
/** Admin shell component receiving the full VexCMS config. */
|
|
116
|
+
dashboard: ApplyComponent<F, DashboardProps>;
|
|
117
|
+
/** Collection list view — renders a list of documents for a collection. */
|
|
118
|
+
collectionListView: ApplyComponent<F, CollectionListViewProps>;
|
|
119
|
+
/** Collection edit form — renders all field inputs for a collection. */
|
|
120
|
+
collectionEditView: ApplyComponent<F, CollectionEditViewProps>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Input type for `defineFrameworkAdapter()`.
|
|
124
|
+
*
|
|
125
|
+
* Framework packages pass this to register their component implementations.
|
|
126
|
+
* TypeScript enforces that every field type in the `AdminField` union has both
|
|
127
|
+
* an input component (`fields`) and a cell component (`cells`), and that each
|
|
128
|
+
* component accepts the correct props for its field type.
|
|
129
|
+
*
|
|
130
|
+
* **What the HKT does:**
|
|
131
|
+
* The `F` parameter is the framework's HKT — a type-level function that maps
|
|
132
|
+
* a props type to the framework's component type. For React:
|
|
133
|
+
* ```ts
|
|
134
|
+
* interface ReactHKT extends ComponentHKT {
|
|
135
|
+
* component: ComponentType<this['_props']>;
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
* Passing `ReactHKT` as `F` means every slot in `fields` and `cells` resolves to
|
|
139
|
+
* `ComponentType<CorrectProps>`, giving the component full prop autocomplete.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```ts
|
|
143
|
+
* // In @vexcms/react
|
|
144
|
+
* import { defineFrameworkAdapter, ComponentHKT } from '@vexcms/core';
|
|
145
|
+
* import { ComponentType } from 'react';
|
|
146
|
+
*
|
|
147
|
+
* interface ReactHKT extends ComponentHKT {
|
|
148
|
+
* component: ComponentType<this['_props']>;
|
|
149
|
+
* }
|
|
150
|
+
*
|
|
151
|
+
* export const reactAdapter = defineFrameworkAdapter<ReactHKT>({
|
|
152
|
+
* name: 'react',
|
|
153
|
+
* version: '0.1.0',
|
|
154
|
+
* fields: {
|
|
155
|
+
* text: TextInputComponent, // must accept InputComponentProps<TextField>
|
|
156
|
+
* },
|
|
157
|
+
* cells: {
|
|
158
|
+
* text: TextCellComponent, // must accept CellComponentProps<TextField>
|
|
159
|
+
* },
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @see {@link FrameworkAdapter} for the resolved type returned by `defineFrameworkAdapter`
|
|
164
|
+
* @see {@link FieldComponentMap} for the field component slot types
|
|
165
|
+
* @see {@link CellComponentProps} for the cell component props
|
|
166
|
+
*/
|
|
167
|
+
export interface FrameworkAdapterInput<F extends ComponentHKT, TFieldMeta extends BaseFieldMeta = BaseFieldMeta> {
|
|
168
|
+
/** Framework name used for identification (e.g. `"react"`, `"solid"`). */
|
|
169
|
+
name: string;
|
|
170
|
+
/** Adapter version — should match the framework package version. */
|
|
171
|
+
version: string;
|
|
172
|
+
/**
|
|
173
|
+
* Input components for each field type, rendered in the document edit form.
|
|
174
|
+
* Every type in the `AdminField` union must have a corresponding component.
|
|
175
|
+
*/
|
|
176
|
+
fields: FieldComponentMap<F, TFieldMeta>;
|
|
177
|
+
/**
|
|
178
|
+
* Admin view components — required for rendering the admin panel.
|
|
179
|
+
* All three must be provided; TypeScript enforces completeness.
|
|
180
|
+
*/
|
|
181
|
+
views: ViewComponentMap<F>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Resolved framework adapter returned by `defineFrameworkAdapter()`.
|
|
185
|
+
*
|
|
186
|
+
* @see {@link FrameworkAdapterInput} for the user-facing input type
|
|
187
|
+
* @see {@link defineFrameworkAdapter} for the function that produces this type
|
|
188
|
+
*/
|
|
189
|
+
export type FrameworkAdapter<F extends ComponentHKT, TFieldMeta extends BaseFieldMeta = BaseFieldMeta> = FrameworkAdapterInput<F, TFieldMeta>;
|
|
190
|
+
/**
|
|
191
|
+
* Registers a framework adapter, enforcing that all field and cell components are
|
|
192
|
+
* implemented and typed correctly.
|
|
193
|
+
*
|
|
194
|
+
* This is a zero-runtime identity function — it returns the adapter unchanged.
|
|
195
|
+
* All enforcement happens at the TypeScript level via the `F` HKT parameter:
|
|
196
|
+
* missing components cause a type error, and each component gets autocomplete
|
|
197
|
+
* for its field-specific props.
|
|
198
|
+
*
|
|
199
|
+
* @param adapter - The framework adapter implementation.
|
|
200
|
+
* @returns The same adapter, verified by TypeScript.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts
|
|
204
|
+
* import { defineFrameworkAdapter, ComponentHKT } from '@vexcms/core';
|
|
205
|
+
* import { ComponentType } from 'react';
|
|
206
|
+
*
|
|
207
|
+
* interface ReactHKT extends ComponentHKT {
|
|
208
|
+
* component: ComponentType<this['_props']>;
|
|
209
|
+
* }
|
|
210
|
+
*
|
|
211
|
+
* export const reactAdapter = defineFrameworkAdapter<ReactHKT>({
|
|
212
|
+
* name: 'react',
|
|
213
|
+
* version: '0.1.0',
|
|
214
|
+
* fields: {
|
|
215
|
+
* text: MyTextInput, // TS error if missing or wrong props
|
|
216
|
+
* },
|
|
217
|
+
* cells: {
|
|
218
|
+
* text: MyTextCell,
|
|
219
|
+
* },
|
|
220
|
+
* });
|
|
221
|
+
* ```
|
|
222
|
+
*
|
|
223
|
+
* @see {@link FrameworkAdapterInput} for the full input type
|
|
224
|
+
* @see {@link FrameworkAdapter} for the resolved return type
|
|
225
|
+
*/
|
|
226
|
+
export declare function defineFrameworkAdapter<F extends ComponentHKT, TFieldMeta extends BaseFieldMeta = BaseFieldMeta>(adapter: FrameworkAdapterInput<F, TFieldMeta>): FrameworkAdapter<F, TFieldMeta>;
|
|
227
|
+
//# sourceMappingURL=framework.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.d.ts","sourceRoot":"","sources":["../src/framework.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/globals/config/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/config/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ComponentHKT } from "../fields";
|
|
2
|
+
import type { GlobalConfig, GlobalConfigInput, ReservedGlobalFieldKey } from "./types";
|
|
3
|
+
import type { GlobalSlug } from "../types/generated";
|
|
4
|
+
/**
|
|
5
|
+
* Defines a singleton global document for the VexCMS project.
|
|
6
|
+
*
|
|
7
|
+
* **Flat API:** `globals.get({ slug: "siteSettings" })` returns a flat document
|
|
8
|
+
* where user fields (`siteName`, `activeTheme`, …) are at root level alongside
|
|
9
|
+
* `_id`, `_creationTime`, and `_slug`. The DB stores data nested in a `data`
|
|
10
|
+
* field; the VexCMS API layer handles flattening on read and re-nesting on write.
|
|
11
|
+
*
|
|
12
|
+
* **Reserved field keys:** `_id`, `_creationTime`, and `_slug` may not be used
|
|
13
|
+
* as field names. A compile-time error is emitted on the offending field when
|
|
14
|
+
* they are used. A runtime error is also thrown for JS consumers.
|
|
15
|
+
*
|
|
16
|
+
* @typeParam TFieldMeta - Metadata on each field definition.
|
|
17
|
+
* @typeParam TGlobalMeta - Metadata on the global config itself.
|
|
18
|
+
* @typeParam TGlobalSlug - The slug string literal (inferred by TypeScript).
|
|
19
|
+
* @typeParam TFieldSlug - Union of field key string literals.
|
|
20
|
+
* @typeParam TComponent - Framework HKT binding.
|
|
21
|
+
* @param config - The raw global configuration.
|
|
22
|
+
* @returns The resolved `GlobalConfig` with all defaults applied.
|
|
23
|
+
* @throws {Error} When `config.fields` contains one of the reserved keys
|
|
24
|
+
* `_id`, `_creationTime`, or `_slug`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* export const siteSettings = defineGlobal({
|
|
29
|
+
* slug: "siteSettings",
|
|
30
|
+
* label: "Site Settings",
|
|
31
|
+
* fields: {
|
|
32
|
+
* siteName: text({ label: "Site Name", required: true }),
|
|
33
|
+
* activeTheme: relationship({ label: "Active Theme", collection: "themes" }),
|
|
34
|
+
* },
|
|
35
|
+
* admin: { group: "Site Builder" },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @see {@link GlobalConfigInput} for the user-facing input type
|
|
40
|
+
* @see {@link GlobalConfig} for the resolved return type
|
|
41
|
+
*/
|
|
42
|
+
export declare function defineGlobal<TFieldMeta extends {} = {}, TGlobalMeta extends {} = {}, TGlobalSlug extends GlobalSlug = GlobalSlug, TFieldSlug extends string = string, TComponent extends ComponentHKT = ComponentHKT>(config: string extends TFieldSlug ? GlobalConfigInput<TFieldMeta, TGlobalMeta, TGlobalSlug, TFieldSlug, TComponent> : [TFieldSlug & ReservedGlobalFieldKey] extends [never] ? GlobalConfigInput<TFieldMeta, TGlobalMeta, TGlobalSlug, TFieldSlug, TComponent> : {
|
|
43
|
+
fields: {
|
|
44
|
+
[K in TFieldSlug & ReservedGlobalFieldKey]: "Field name is reserved — cannot use _id, _creationTime, or _slug";
|
|
45
|
+
};
|
|
46
|
+
}): GlobalConfig<TFieldMeta, TGlobalMeta, TGlobalSlug, TFieldSlug, TComponent>;
|
|
47
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/globals/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,YAAY,CAC1B,UAAU,SAAS,EAAE,GAAG,EAAE,EAC1B,WAAW,SAAS,EAAE,GAAG,EAAE,EAC3B,WAAW,SAAS,UAAU,GAAG,UAAU,EAC3C,UAAU,SAAS,MAAM,GAAG,MAAM,EAClC,UAAU,SAAS,YAAY,GAAG,YAAY,EAE9C,MAAM,EAAE,MAAM,SAAS,UAAU,GAC7B,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,GAC/E,CAAC,UAAU,GAAG,sBAAsB,CAAC,SAAS,CAAC,KAAK,CAAC,GACnD,iBAAiB,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,GAC/E;IACE,MAAM,EAAE;SACL,CAAC,IAAI,UAAU,GACd,sBAAsB,GAAG,kEAAkE;KAC9F,CAAC;CACH,GACN,YAAY,CAAC,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAmC5E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { defineGlobal } from "./config";
|
|
2
|
+
export type { GlobalConfig, GlobalConfigInput, GlobalAdminConfig, GlobalAdminConfigInput, ReservedGlobalFieldKey, } from "./types";
|
|
3
|
+
export { getGlobalDefaultValues, getGlobalInputSchema } from "./utils";
|
|
4
|
+
export { globalConfigToInterface, globalConfigToFieldTypeMap } from "./interfaceGen";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/globals/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { GlobalConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Converts a resolved `GlobalConfig` to a TypeScript `export interface` source string.
|
|
4
|
+
*
|
|
5
|
+
* The generated interface extends `VexDocumentGlobal<"slug">` (which itself
|
|
6
|
+
* extends `VexDocument`), adding user fields at root level. This produces the
|
|
7
|
+
* flat shape returned by `globals.get` — no `data` wrapper.
|
|
8
|
+
*
|
|
9
|
+
* @param props.global - The resolved global definition to convert.
|
|
10
|
+
* @returns TypeScript source string for one flat global interface block.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* globalConfigToInterface({ global: siteSettings });
|
|
15
|
+
* // → 'export interface SiteSettingsGlobal extends VexDocumentGlobal<"siteSettings"> {\n\tsiteName: string\n\t...\n}'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function globalConfigToInterface(props: {
|
|
19
|
+
global: GlobalConfig;
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* Converts a resolved `GlobalConfig` to the TypeScript source string for its
|
|
23
|
+
* `GlobalsFieldTypeMap` entry in the `declare module '@vexcms/core'` block.
|
|
24
|
+
*
|
|
25
|
+
* Powers `GlobalRelationshipKeysOf<TGlobalSlug>` for populate type narrowing.
|
|
26
|
+
*
|
|
27
|
+
* @param props.global - The resolved global definition.
|
|
28
|
+
* @returns TypeScript source string for one `GlobalsFieldTypeMap` entry.
|
|
29
|
+
*/
|
|
30
|
+
export declare function globalConfigToFieldTypeMap(props: {
|
|
31
|
+
global: GlobalConfig;
|
|
32
|
+
}): string;
|
|
33
|
+
//# sourceMappingURL=interfaceGen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaceGen.d.ts","sourceRoot":"","sources":["../../src/globals/interfaceGen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG,MAAM,CAyB/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GAAG,MAAM,CAelF"}
|