@cedgetec-utils/astro-components 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedgetec-utils/astro-components",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "keywords": [
5
5
  "astro-component"
6
6
  ],
@@ -1,4 +1,4 @@
1
- import type { ZodObject, ZodRawShape, ZodSchema } from "astro/zod"
1
+ import type { ZodObject, ZodRawShape, ZodType } from "astro/zod"
2
2
  import { defineCollection } from "astro:content"
3
3
  import { z } from "astro/zod"
4
4
 
@@ -32,20 +32,20 @@ async function fetchWithRetry(
32
32
  }
33
33
  }
34
34
 
35
- function getZodSchemaPaths(schema: ZodSchema, prefix = ""): string[] {
35
+ function getZodSchemaPaths(schema: ZodType, prefix = ""): string[] {
36
36
  const paths: string[] = []
37
37
 
38
- // Unwrap optional, nullable, and effects (transforms, refinements, etc.)
39
- let unwrapped = schema
38
+ // Unwrap optional, nullable, and pipe/transform
39
+ let unwrapped: ZodType = schema
40
40
  while (
41
41
  unwrapped instanceof z.ZodOptional ||
42
42
  unwrapped instanceof z.ZodNullable ||
43
- unwrapped instanceof z.ZodEffects
43
+ unwrapped instanceof z.ZodPipe
44
44
  ) {
45
- if (unwrapped instanceof z.ZodEffects) {
46
- unwrapped = unwrapped._def.schema
45
+ if (unwrapped instanceof z.ZodPipe) {
46
+ unwrapped = unwrapped.def.in as ZodType
47
47
  } else {
48
- unwrapped = unwrapped._def.innerType
48
+ unwrapped = unwrapped.def.innerType as ZodType
49
49
  }
50
50
  }
51
51
 
@@ -67,14 +67,14 @@ function getZodSchemaPaths(schema: ZodSchema, prefix = ""): string[] {
67
67
  }
68
68
  } // Handle ZodArray
69
69
  else if (unwrapped instanceof z.ZodArray) {
70
- const elementSchema = unwrapped._def.type
70
+ const elementSchema = unwrapped.def.element as ZodType
71
71
  // Get paths from the array element schema without adding array indices
72
72
  const nestedPaths = getZodSchemaPaths(elementSchema, prefix)
73
73
  paths.push(...nestedPaths)
74
74
  } // Handle ZodDiscriminatedUnion (for Directus M2A relationships)
75
75
  else if (unwrapped instanceof z.ZodDiscriminatedUnion) {
76
- const discriminator = unwrapped._def.discriminator as string
77
- const options = unwrapped._def.options as z.ZodObject<any>[]
76
+ const discriminator = unwrapped.def.discriminator as string
77
+ const options = unwrapped.def.options as z.ZodObject<any>[]
78
78
 
79
79
  // Always include the discriminator field
80
80
  paths.push(prefix ? `${prefix}.${discriminator}` : discriminator)
@@ -85,7 +85,7 @@ function getZodSchemaPaths(schema: ZodSchema, prefix = ""): string[] {
85
85
  let discriminatorValue: string | undefined
86
86
  const discriminatorSchema = shape[discriminator]
87
87
  if (discriminatorSchema instanceof z.ZodLiteral) {
88
- discriminatorValue = discriminatorSchema._def.value as string
88
+ discriminatorValue = discriminatorSchema.def.values[0] as string
89
89
  }
90
90
 
91
91
  // Process other fields in this variant