@cedgetec-utils/astro-components 1.6.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 +16 -13
- package/src/components/index.ts +4 -4
- package/src/libs/directus.ts +12 -12
package/package.json
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedgetec-utils/astro-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"astro-component"
|
|
6
|
+
],
|
|
7
|
+
"files": [
|
|
8
|
+
"src",
|
|
9
|
+
"index.ts"
|
|
10
|
+
],
|
|
4
11
|
"type": "module",
|
|
5
12
|
"exports": {
|
|
6
13
|
".": "./src/components/index.ts",
|
|
7
14
|
"./libs": "./src/libs/index.ts"
|
|
8
15
|
},
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"keywords": [
|
|
14
|
-
"astro-component"
|
|
15
|
-
],
|
|
16
|
-
"scripts": {},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"lint": "oxlint",
|
|
18
|
+
"format": "oxfmt"
|
|
19
|
+
},
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"astro": "^
|
|
21
|
+
"astro": "^6.0.2"
|
|
19
22
|
},
|
|
20
23
|
"devDependencies": {
|
|
21
|
-
"oxfmt": "^0.
|
|
22
|
-
"oxlint": "^1.
|
|
24
|
+
"oxfmt": "^0.38.0",
|
|
25
|
+
"oxlint": "^1.53.0",
|
|
23
26
|
"typescript": "^5.9.3"
|
|
24
27
|
},
|
|
25
28
|
"peerDependencies": {
|
|
26
|
-
"astro": "^
|
|
29
|
+
"astro": "^6.0.2"
|
|
27
30
|
}
|
|
28
31
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Do not write code directly here, instead use the `src` folder!
|
|
2
2
|
// Then, use this file to export everything you want your user to access.
|
|
3
3
|
|
|
4
|
-
export { default as DirectusImage } from "./DirectusImage.astro"
|
|
5
|
-
export type { DirectusImageData } from "./DirectusImage.astro"
|
|
6
|
-
export { default as Head } from "./Head.astro"
|
|
7
|
-
export { default as Matomo } from "./Matomo.astro"
|
|
4
|
+
export { default as DirectusImage } from "./DirectusImage.astro"
|
|
5
|
+
export type { DirectusImageData } from "./DirectusImage.astro"
|
|
6
|
+
export { default as Head } from "./Head.astro"
|
|
7
|
+
export { default as Matomo } from "./Matomo.astro"
|
package/src/libs/directus.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ZodObject, ZodRawShape,
|
|
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:
|
|
35
|
+
function getZodSchemaPaths(schema: ZodType, prefix = ""): string[] {
|
|
36
36
|
const paths: string[] = []
|
|
37
37
|
|
|
38
|
-
// Unwrap optional, nullable, and
|
|
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.
|
|
43
|
+
unwrapped instanceof z.ZodPipe
|
|
44
44
|
) {
|
|
45
|
-
if (unwrapped instanceof z.
|
|
46
|
-
unwrapped = unwrapped.
|
|
45
|
+
if (unwrapped instanceof z.ZodPipe) {
|
|
46
|
+
unwrapped = unwrapped.def.in as ZodType
|
|
47
47
|
} else {
|
|
48
|
-
unwrapped = unwrapped.
|
|
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.
|
|
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.
|
|
77
|
-
const options = unwrapped.
|
|
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.
|
|
88
|
+
discriminatorValue = discriminatorSchema.def.values[0] as string
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// Process other fields in this variant
|