nuxtseo-shared 0.1.4 → 0.1.5

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.
@@ -1,14 +1,10 @@
1
- import { z } from "zod";
2
-
3
1
  //#region src/content.d.ts
4
- type ZodInstance = typeof z;
5
- type ZodTypeAny = z.ZodTypeAny;
6
2
  interface ContentSchemaOptions {
7
3
  /**
8
4
  * Pass the `z` instance from `@nuxt/content` to ensure `.editor()` works
9
5
  * across Zod versions. When omitted, the module's bundled `z` is used.
10
6
  */
11
- z?: ZodInstance;
7
+ z?: any;
12
8
  }
13
9
  interface ContentEditorConfig {
14
10
  hidden?: boolean;
@@ -19,13 +15,12 @@ interface ContentEditorConfig {
19
15
  * Apply Nuxt Content `.editor()` metadata to a zod schema field.
20
16
  * No-ops gracefully when `.editor()` is not patched onto ZodType (outside Nuxt Content).
21
17
  */
22
- declare function withEditor<T extends ZodTypeAny>(schema: T, config: ContentEditorConfig): T;
18
+ declare function withEditor<T>(schema: T, config: ContentEditorConfig): T;
23
19
  /**
24
20
  * Hide a zod schema field from the Nuxt Content / Studio editor.
25
- * Only use for fields that genuinely don't work in a form (freeform JSON, deeply nested arrays).
26
21
  */
27
- declare function withEditorHidden<T extends ZodTypeAny>(schema: T): T;
28
- interface DefineContentSchemaConfig<TSchema extends ZodTypeAny, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions> {
22
+ declare function withEditorHidden<T>(schema: T): T;
23
+ interface DefineContentSchemaConfig<TSchema = any, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions> {
29
24
  /**
30
25
  * The field name used in frontmatter (e.g. 'robots', 'sitemap', 'ogImage').
31
26
  */
@@ -34,7 +29,7 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny, TDefineOptions e
34
29
  * Build the zod schema for this field. Receives the zod instance
35
30
  * (either the user's `@nuxt/content` patched version or the module's bundled one).
36
31
  */
37
- buildSchema: (z: ZodInstance) => TSchema;
32
+ buildSchema: (z: any) => TSchema;
38
33
  /**
39
34
  * Module label for deprecation warnings (e.g. 'robots', 'sitemap').
40
35
  */
@@ -58,7 +53,6 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny, TDefineOptions e
58
53
  * - Deprecated `asXxxCollection()` wrapper with migration warning
59
54
  *
60
55
  * @example
61
- * // In @nuxtjs/robots/content.ts
62
56
  * import { z } from 'zod'
63
57
  * import { createContentSchemaFactory } from 'nuxtseo-shared/content'
64
58
  *
@@ -66,21 +60,15 @@ interface DefineContentSchemaConfig<TSchema extends ZodTypeAny, TDefineOptions e
66
60
  * fieldName: 'robots',
67
61
  * label: 'robots',
68
62
  * docsUrl: 'https://nuxtseo.com/robots/guides/content',
69
- * buildSchema: (z) => z.enum(['index, follow', 'noindex', 'nofollow', 'noindex, nofollow', 'none']).optional(),
63
+ * buildSchema: (z) => z.union([z.string(), z.boolean()]).optional(),
70
64
  * }, z)
71
65
  *
72
66
  * export { defineSchema as defineRobotsSchema, asCollection as asRobotsCollection, schema }
73
67
  */
74
- declare function createContentSchemaFactory<TSchema extends ZodTypeAny, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions>(config: DefineContentSchemaConfig<TSchema, TDefineOptions>, defaultZ: ZodInstance): {
68
+ declare function createContentSchemaFactory<TSchema, TDefineOptions extends ContentSchemaOptions = ContentSchemaOptions>(config: DefineContentSchemaConfig<TSchema, TDefineOptions>, defaultZ: any): {
75
69
  defineSchema: (options?: TDefineOptions) => TSchema;
76
70
  asCollection: <T>(collection: any) => T;
77
- schema: z.ZodObject<{
78
- [x: string]: TSchema;
79
- }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
80
- [x: string]: TSchema;
81
- }>, any> extends infer T ? { [k in keyof T]: T[k] } : never, z.baseObjectInputType<{
82
- [x: string]: TSchema;
83
- }> extends infer T_1 ? { [k_1 in keyof T_1]: T_1[k_1] } : never>;
71
+ schema: any;
84
72
  fieldSchema: TSchema;
85
73
  };
86
74
  //#endregion
package/dist/content.mjs CHANGED
@@ -9,7 +9,6 @@ function withEditor(schema, config) {
9
9
  }
10
10
  /**
11
11
  * Hide a zod schema field from the Nuxt Content / Studio editor.
12
- * Only use for fields that genuinely don't work in a form (freeform JSON, deeply nested arrays).
13
12
  */
14
13
  function withEditorHidden(schema) {
15
14
  return withEditor(schema, { hidden: true });
@@ -23,7 +22,6 @@ function withEditorHidden(schema) {
23
22
  * - Deprecated `asXxxCollection()` wrapper with migration warning
24
23
  *
25
24
  * @example
26
- * // In @nuxtjs/robots/content.ts
27
25
  * import { z } from 'zod'
28
26
  * import { createContentSchemaFactory } from 'nuxtseo-shared/content'
29
27
  *
@@ -31,7 +29,7 @@ function withEditorHidden(schema) {
31
29
  * fieldName: 'robots',
32
30
  * label: 'robots',
33
31
  * docsUrl: 'https://nuxtseo.com/robots/guides/content',
34
- * buildSchema: (z) => z.enum(['index, follow', 'noindex', 'nofollow', 'noindex, nofollow', 'none']).optional(),
32
+ * buildSchema: (z) => z.union([z.string(), z.boolean()]).optional(),
35
33
  * }, z)
36
34
  *
37
35
  * export { defineSchema as defineRobotsSchema, asCollection as asRobotsCollection, schema }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxtseo-shared",
3
3
  "type": "module",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "description": "Shared utilities for Nuxt SEO modules.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -50,7 +50,7 @@
50
50
  "nuxt": "^3.16.0 || ^4.0.0",
51
51
  "nuxt-site-config": "^3.2.0",
52
52
  "vue": "^3.5.0",
53
- "zod": "^3.23.0"
53
+ "zod": "^3.23.0 || ^4.0.0"
54
54
  },
55
55
  "peerDependenciesMeta": {
56
56
  "nuxt-site-config": {