astro 4.10.1 → 4.10.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/dist/@types/astro.d.ts +43 -39
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +4 -4
- package/dist/container/index.d.ts +32 -1
- package/dist/container/index.js +45 -0
- package/dist/container/pipeline.d.ts +1 -1
- package/dist/container/pipeline.js +17 -18
- package/dist/container/vite-plugin-container.d.ts +2 -0
- package/dist/container/vite-plugin-container.js +15 -0
- package/dist/content/runtime.js +2 -2
- package/dist/content/types-generator.js +30 -32
- package/dist/content/utils.d.ts +11 -0
- package/dist/content/utils.js +49 -0
- package/dist/content/vite-plugin-content-imports.d.ts +3 -1
- package/dist/content/vite-plugin-content-imports.js +15 -4
- package/dist/core/app/index.js +0 -4
- package/dist/core/app/pipeline.d.ts +1 -1
- package/dist/core/app/pipeline.js +4 -4
- package/dist/core/base-pipeline.d.ts +1 -1
- package/dist/core/base-pipeline.js +1 -1
- package/dist/core/build/generate.js +2 -1
- package/dist/core/build/internal.d.ts +4 -0
- package/dist/core/build/internal.js +2 -1
- package/dist/core/build/page-data.js +2 -4
- package/dist/core/build/pipeline.d.ts +1 -1
- package/dist/core/build/pipeline.js +4 -4
- package/dist/core/build/plugins/plugin-chunks.js +6 -0
- package/dist/core/build/plugins/plugin-prerender.js +55 -48
- package/dist/core/build/plugins/plugin-ssr.js +15 -12
- package/dist/core/build/static-build.js +36 -44
- package/dist/core/build/types.d.ts +0 -1
- package/dist/core/config/schema.d.ts +422 -78
- package/dist/core/constants.d.ts +4 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/create-vite.js +4 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +31 -0
- package/dist/core/errors/errors-data.js +12 -0
- package/dist/core/messages.js +2 -2
- package/dist/core/render-context.d.ts +1 -1
- package/dist/core/render-context.js +28 -22
- package/dist/core/routing/astro-designed-error-pages.d.ts +1 -0
- package/dist/core/routing/astro-designed-error-pages.js +15 -1
- package/dist/core/routing/params.js +1 -1
- package/dist/core/util.js +5 -2
- package/dist/env/config.d.ts +2 -1
- package/dist/env/config.js +4 -0
- package/dist/env/constants.d.ts +0 -1
- package/dist/env/constants.js +0 -2
- package/dist/env/runtime.d.ts +3 -1
- package/dist/env/runtime.js +8 -1
- package/dist/env/schema.d.ts +198 -220
- package/dist/env/schema.js +47 -79
- package/dist/env/validators.js +73 -10
- package/dist/env/vite-plugin-env.js +15 -15
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +4 -11
- package/dist/jsx/server.d.ts +3 -5
- package/dist/jsx/server.js +3 -1
- package/dist/runtime/server/render/astro/render.js +8 -2
- package/dist/vite-plugin-astro/index.js +1 -1
- package/dist/vite-plugin-astro-server/pipeline.d.ts +1 -1
- package/dist/vite-plugin-astro-server/pipeline.js +4 -4
- package/dist/vite-plugin-astro-server/request.js +2 -2
- package/dist/vite-plugin-astro-server/route.js +18 -1
- package/package.json +16 -16
- package/templates/env/module.mjs +14 -5
- package/templates/env/types.d.ts +1 -12
package/dist/env/schema.d.ts
CHANGED
|
@@ -1,29 +1,69 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
declare const
|
|
2
|
+
declare const StringSchema: z.ZodObject<{
|
|
3
3
|
type: z.ZodLiteral<"string">;
|
|
4
4
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
5
5
|
default: z.ZodOptional<z.ZodString>;
|
|
6
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
length: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
url: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
includes: z.ZodOptional<z.ZodString>;
|
|
11
|
+
startsWith: z.ZodOptional<z.ZodString>;
|
|
12
|
+
endsWith: z.ZodOptional<z.ZodString>;
|
|
6
13
|
}, "strip", z.ZodTypeAny, {
|
|
7
14
|
type: "string";
|
|
15
|
+
length?: number | undefined;
|
|
16
|
+
includes?: string | undefined;
|
|
17
|
+
endsWith?: string | undefined;
|
|
18
|
+
startsWith?: string | undefined;
|
|
8
19
|
default?: string | undefined;
|
|
20
|
+
url?: boolean | undefined;
|
|
9
21
|
optional?: boolean | undefined;
|
|
22
|
+
min?: number | undefined;
|
|
23
|
+
max?: number | undefined;
|
|
10
24
|
}, {
|
|
11
25
|
type: "string";
|
|
26
|
+
length?: number | undefined;
|
|
27
|
+
includes?: string | undefined;
|
|
28
|
+
endsWith?: string | undefined;
|
|
29
|
+
startsWith?: string | undefined;
|
|
12
30
|
default?: string | undefined;
|
|
31
|
+
url?: boolean | undefined;
|
|
13
32
|
optional?: boolean | undefined;
|
|
14
|
-
|
|
33
|
+
min?: number | undefined;
|
|
34
|
+
max?: number | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export type StringSchema = z.infer<typeof StringSchema>;
|
|
37
|
+
declare const NumberSchema: z.ZodObject<{
|
|
15
38
|
type: z.ZodLiteral<"number">;
|
|
16
39
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
17
40
|
default: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
int: z.ZodOptional<z.ZodBoolean>;
|
|
18
46
|
}, "strip", z.ZodTypeAny, {
|
|
19
47
|
type: "number";
|
|
20
48
|
default?: number | undefined;
|
|
21
49
|
optional?: boolean | undefined;
|
|
50
|
+
min?: number | undefined;
|
|
51
|
+
max?: number | undefined;
|
|
52
|
+
gt?: number | undefined;
|
|
53
|
+
lt?: number | undefined;
|
|
54
|
+
int?: boolean | undefined;
|
|
22
55
|
}, {
|
|
23
56
|
type: "number";
|
|
24
57
|
default?: number | undefined;
|
|
25
58
|
optional?: boolean | undefined;
|
|
26
|
-
|
|
59
|
+
min?: number | undefined;
|
|
60
|
+
max?: number | undefined;
|
|
61
|
+
gt?: number | undefined;
|
|
62
|
+
lt?: number | undefined;
|
|
63
|
+
int?: boolean | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
export type NumberSchema = z.infer<typeof NumberSchema>;
|
|
66
|
+
declare const BooleanSchema: z.ZodObject<{
|
|
27
67
|
type: z.ZodLiteral<"boolean">;
|
|
28
68
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
29
69
|
default: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -35,59 +75,84 @@ declare const EnvFieldType: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
35
75
|
type: "boolean";
|
|
36
76
|
default?: boolean | undefined;
|
|
37
77
|
optional?: boolean | undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
context: "client";
|
|
45
|
-
access: "public";
|
|
46
|
-
}, {
|
|
47
|
-
context: "client";
|
|
48
|
-
access: "public";
|
|
49
|
-
}>, z.ZodObject<{
|
|
50
|
-
context: z.ZodLiteral<"server">;
|
|
51
|
-
access: z.ZodLiteral<"public">;
|
|
52
|
-
}, "strip", z.ZodTypeAny, {
|
|
53
|
-
context: "server";
|
|
54
|
-
access: "public";
|
|
55
|
-
}, {
|
|
56
|
-
context: "server";
|
|
57
|
-
access: "public";
|
|
58
|
-
}>, z.ZodObject<{
|
|
59
|
-
context: z.ZodLiteral<"server">;
|
|
60
|
-
access: z.ZodLiteral<"secret">;
|
|
78
|
+
}>;
|
|
79
|
+
declare const EnumSchema: z.ZodObject<{
|
|
80
|
+
type: z.ZodLiteral<"enum">;
|
|
81
|
+
values: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
82
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
default: z.ZodOptional<z.ZodString>;
|
|
61
84
|
}, "strip", z.ZodTypeAny, {
|
|
62
|
-
|
|
63
|
-
|
|
85
|
+
type: "enum";
|
|
86
|
+
values: string[];
|
|
87
|
+
default?: string | undefined;
|
|
88
|
+
optional?: boolean | undefined;
|
|
64
89
|
}, {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
type: "enum";
|
|
91
|
+
values: string[];
|
|
92
|
+
default?: string | undefined;
|
|
93
|
+
optional?: boolean | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export type EnumSchema = z.infer<typeof EnumSchema>;
|
|
96
|
+
declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
|
|
68
97
|
type: z.ZodLiteral<"string">;
|
|
69
98
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
70
99
|
default: z.ZodOptional<z.ZodString>;
|
|
100
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
length: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
url: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
+
includes: z.ZodOptional<z.ZodString>;
|
|
105
|
+
startsWith: z.ZodOptional<z.ZodString>;
|
|
106
|
+
endsWith: z.ZodOptional<z.ZodString>;
|
|
71
107
|
}, "strip", z.ZodTypeAny, {
|
|
72
108
|
type: "string";
|
|
109
|
+
length?: number | undefined;
|
|
110
|
+
includes?: string | undefined;
|
|
111
|
+
endsWith?: string | undefined;
|
|
112
|
+
startsWith?: string | undefined;
|
|
73
113
|
default?: string | undefined;
|
|
114
|
+
url?: boolean | undefined;
|
|
74
115
|
optional?: boolean | undefined;
|
|
116
|
+
min?: number | undefined;
|
|
117
|
+
max?: number | undefined;
|
|
75
118
|
}, {
|
|
76
119
|
type: "string";
|
|
120
|
+
length?: number | undefined;
|
|
121
|
+
includes?: string | undefined;
|
|
122
|
+
endsWith?: string | undefined;
|
|
123
|
+
startsWith?: string | undefined;
|
|
77
124
|
default?: string | undefined;
|
|
125
|
+
url?: boolean | undefined;
|
|
78
126
|
optional?: boolean | undefined;
|
|
127
|
+
min?: number | undefined;
|
|
128
|
+
max?: number | undefined;
|
|
79
129
|
}>, z.ZodObject<{
|
|
80
130
|
type: z.ZodLiteral<"number">;
|
|
81
131
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
82
132
|
default: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
int: z.ZodOptional<z.ZodBoolean>;
|
|
83
138
|
}, "strip", z.ZodTypeAny, {
|
|
84
139
|
type: "number";
|
|
85
140
|
default?: number | undefined;
|
|
86
141
|
optional?: boolean | undefined;
|
|
142
|
+
min?: number | undefined;
|
|
143
|
+
max?: number | undefined;
|
|
144
|
+
gt?: number | undefined;
|
|
145
|
+
lt?: number | undefined;
|
|
146
|
+
int?: boolean | undefined;
|
|
87
147
|
}, {
|
|
88
148
|
type: "number";
|
|
89
149
|
default?: number | undefined;
|
|
90
150
|
optional?: boolean | undefined;
|
|
151
|
+
min?: number | undefined;
|
|
152
|
+
max?: number | undefined;
|
|
153
|
+
gt?: number | undefined;
|
|
154
|
+
lt?: number | undefined;
|
|
155
|
+
int?: boolean | undefined;
|
|
91
156
|
}>, z.ZodObject<{
|
|
92
157
|
type: z.ZodLiteral<"boolean">;
|
|
93
158
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -100,51 +165,34 @@ export declare const EnvSchema: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodInter
|
|
|
100
165
|
type: "boolean";
|
|
101
166
|
default?: boolean | undefined;
|
|
102
167
|
optional?: boolean | undefined;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
access: "secret";
|
|
112
|
-
}) & ({
|
|
113
|
-
type: "string";
|
|
168
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
169
|
+
type: z.ZodLiteral<"enum">;
|
|
170
|
+
values: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
171
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
+
default: z.ZodOptional<z.ZodString>;
|
|
173
|
+
}, "strip", z.ZodTypeAny, {
|
|
174
|
+
type: "enum";
|
|
175
|
+
values: string[];
|
|
114
176
|
default?: string | undefined;
|
|
115
177
|
optional?: boolean | undefined;
|
|
116
|
-
}
|
|
117
|
-
type: "
|
|
118
|
-
|
|
119
|
-
optional?: boolean | undefined;
|
|
120
|
-
} | {
|
|
121
|
-
type: "boolean";
|
|
122
|
-
default?: boolean | undefined;
|
|
123
|
-
optional?: boolean | undefined;
|
|
124
|
-
})>, Record<string, ({
|
|
125
|
-
context: "client";
|
|
126
|
-
access: "public";
|
|
127
|
-
} | {
|
|
128
|
-
context: "server";
|
|
129
|
-
access: "public";
|
|
130
|
-
} | {
|
|
131
|
-
context: "server";
|
|
132
|
-
access: "secret";
|
|
133
|
-
}) & ({
|
|
134
|
-
type: "string";
|
|
178
|
+
}, {
|
|
179
|
+
type: "enum";
|
|
180
|
+
values: string[];
|
|
135
181
|
default?: string | undefined;
|
|
136
182
|
optional?: boolean | undefined;
|
|
137
|
-
}
|
|
138
|
-
type: "
|
|
139
|
-
|
|
183
|
+
}>, {
|
|
184
|
+
type: "enum";
|
|
185
|
+
values: string[];
|
|
186
|
+
default?: string | undefined;
|
|
140
187
|
optional?: boolean | undefined;
|
|
141
|
-
}
|
|
142
|
-
type: "
|
|
143
|
-
|
|
188
|
+
}, {
|
|
189
|
+
type: "enum";
|
|
190
|
+
values: string[];
|
|
191
|
+
default?: string | undefined;
|
|
144
192
|
optional?: boolean | undefined;
|
|
145
|
-
}
|
|
146
|
-
export type
|
|
147
|
-
declare const
|
|
193
|
+
}>]>;
|
|
194
|
+
export type EnvFieldType = z.infer<typeof EnvFieldType>;
|
|
195
|
+
declare const EnvFieldMetadata: z.ZodUnion<[z.ZodObject<{
|
|
148
196
|
context: z.ZodLiteral<"client">;
|
|
149
197
|
access: z.ZodLiteral<"public">;
|
|
150
198
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -171,21 +219,8 @@ declare const StringField: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
|
171
219
|
}, {
|
|
172
220
|
context: "server";
|
|
173
221
|
access: "secret";
|
|
174
|
-
}>]
|
|
175
|
-
|
|
176
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
177
|
-
default: z.ZodOptional<z.ZodString>;
|
|
178
|
-
}, "strip", z.ZodTypeAny, {
|
|
179
|
-
type: "string";
|
|
180
|
-
default?: string | undefined;
|
|
181
|
-
optional?: boolean | undefined;
|
|
182
|
-
}, {
|
|
183
|
-
type: "string";
|
|
184
|
-
default?: string | undefined;
|
|
185
|
-
optional?: boolean | undefined;
|
|
186
|
-
}>>;
|
|
187
|
-
export type StringField = z.infer<typeof StringField>;
|
|
188
|
-
export declare const StringFieldInput: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
222
|
+
}>]>;
|
|
223
|
+
export declare const EnvSchema: z.ZodRecord<z.ZodString, z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
189
224
|
context: z.ZodLiteral<"client">;
|
|
190
225
|
access: z.ZodLiteral<"public">;
|
|
191
226
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -212,126 +247,67 @@ export declare const StringFieldInput: z.ZodIntersection<z.ZodUnion<[z.ZodObject
|
|
|
212
247
|
}, {
|
|
213
248
|
context: "server";
|
|
214
249
|
access: "secret";
|
|
215
|
-
}>]>, z.ZodObject<
|
|
250
|
+
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
216
251
|
type: z.ZodLiteral<"string">;
|
|
217
252
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
218
253
|
default: z.ZodOptional<z.ZodString>;
|
|
219
|
-
|
|
254
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
255
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
length: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
url: z.ZodOptional<z.ZodBoolean>;
|
|
258
|
+
includes: z.ZodOptional<z.ZodString>;
|
|
259
|
+
startsWith: z.ZodOptional<z.ZodString>;
|
|
260
|
+
endsWith: z.ZodOptional<z.ZodString>;
|
|
261
|
+
}, "strip", z.ZodTypeAny, {
|
|
262
|
+
type: "string";
|
|
263
|
+
length?: number | undefined;
|
|
264
|
+
includes?: string | undefined;
|
|
265
|
+
endsWith?: string | undefined;
|
|
266
|
+
startsWith?: string | undefined;
|
|
220
267
|
default?: string | undefined;
|
|
268
|
+
url?: boolean | undefined;
|
|
221
269
|
optional?: boolean | undefined;
|
|
270
|
+
min?: number | undefined;
|
|
271
|
+
max?: number | undefined;
|
|
222
272
|
}, {
|
|
273
|
+
type: "string";
|
|
274
|
+
length?: number | undefined;
|
|
275
|
+
includes?: string | undefined;
|
|
276
|
+
endsWith?: string | undefined;
|
|
277
|
+
startsWith?: string | undefined;
|
|
223
278
|
default?: string | undefined;
|
|
279
|
+
url?: boolean | undefined;
|
|
224
280
|
optional?: boolean | undefined;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
declare const NumberField: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
228
|
-
context: z.ZodLiteral<"client">;
|
|
229
|
-
access: z.ZodLiteral<"public">;
|
|
230
|
-
}, "strip", z.ZodTypeAny, {
|
|
231
|
-
context: "client";
|
|
232
|
-
access: "public";
|
|
233
|
-
}, {
|
|
234
|
-
context: "client";
|
|
235
|
-
access: "public";
|
|
281
|
+
min?: number | undefined;
|
|
282
|
+
max?: number | undefined;
|
|
236
283
|
}>, z.ZodObject<{
|
|
237
|
-
context: z.ZodLiteral<"server">;
|
|
238
|
-
access: z.ZodLiteral<"public">;
|
|
239
|
-
}, "strip", z.ZodTypeAny, {
|
|
240
|
-
context: "server";
|
|
241
|
-
access: "public";
|
|
242
|
-
}, {
|
|
243
|
-
context: "server";
|
|
244
|
-
access: "public";
|
|
245
|
-
}>, z.ZodObject<{
|
|
246
|
-
context: z.ZodLiteral<"server">;
|
|
247
|
-
access: z.ZodLiteral<"secret">;
|
|
248
|
-
}, "strip", z.ZodTypeAny, {
|
|
249
|
-
context: "server";
|
|
250
|
-
access: "secret";
|
|
251
|
-
}, {
|
|
252
|
-
context: "server";
|
|
253
|
-
access: "secret";
|
|
254
|
-
}>]>, z.ZodObject<{
|
|
255
284
|
type: z.ZodLiteral<"number">;
|
|
256
285
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
257
286
|
default: z.ZodOptional<z.ZodNumber>;
|
|
287
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
288
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
289
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
290
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
291
|
+
int: z.ZodOptional<z.ZodBoolean>;
|
|
258
292
|
}, "strip", z.ZodTypeAny, {
|
|
259
293
|
type: "number";
|
|
260
294
|
default?: number | undefined;
|
|
261
295
|
optional?: boolean | undefined;
|
|
296
|
+
min?: number | undefined;
|
|
297
|
+
max?: number | undefined;
|
|
298
|
+
gt?: number | undefined;
|
|
299
|
+
lt?: number | undefined;
|
|
300
|
+
int?: boolean | undefined;
|
|
262
301
|
}, {
|
|
263
302
|
type: "number";
|
|
264
303
|
default?: number | undefined;
|
|
265
304
|
optional?: boolean | undefined;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}, "strip", z.ZodTypeAny, {
|
|
272
|
-
context: "client";
|
|
273
|
-
access: "public";
|
|
274
|
-
}, {
|
|
275
|
-
context: "client";
|
|
276
|
-
access: "public";
|
|
277
|
-
}>, z.ZodObject<{
|
|
278
|
-
context: z.ZodLiteral<"server">;
|
|
279
|
-
access: z.ZodLiteral<"public">;
|
|
280
|
-
}, "strip", z.ZodTypeAny, {
|
|
281
|
-
context: "server";
|
|
282
|
-
access: "public";
|
|
283
|
-
}, {
|
|
284
|
-
context: "server";
|
|
285
|
-
access: "public";
|
|
286
|
-
}>, z.ZodObject<{
|
|
287
|
-
context: z.ZodLiteral<"server">;
|
|
288
|
-
access: z.ZodLiteral<"secret">;
|
|
289
|
-
}, "strip", z.ZodTypeAny, {
|
|
290
|
-
context: "server";
|
|
291
|
-
access: "secret";
|
|
292
|
-
}, {
|
|
293
|
-
context: "server";
|
|
294
|
-
access: "secret";
|
|
295
|
-
}>]>, z.ZodObject<Omit<{
|
|
296
|
-
type: z.ZodLiteral<"number">;
|
|
297
|
-
optional: z.ZodOptional<z.ZodBoolean>;
|
|
298
|
-
default: z.ZodOptional<z.ZodNumber>;
|
|
299
|
-
}, "type">, "strip", z.ZodTypeAny, {
|
|
300
|
-
default?: number | undefined;
|
|
301
|
-
optional?: boolean | undefined;
|
|
302
|
-
}, {
|
|
303
|
-
default?: number | undefined;
|
|
304
|
-
optional?: boolean | undefined;
|
|
305
|
-
}>>;
|
|
306
|
-
export type NumberFieldInput = z.infer<typeof NumberFieldInput>;
|
|
307
|
-
declare const BooleanField: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
308
|
-
context: z.ZodLiteral<"client">;
|
|
309
|
-
access: z.ZodLiteral<"public">;
|
|
310
|
-
}, "strip", z.ZodTypeAny, {
|
|
311
|
-
context: "client";
|
|
312
|
-
access: "public";
|
|
313
|
-
}, {
|
|
314
|
-
context: "client";
|
|
315
|
-
access: "public";
|
|
316
|
-
}>, z.ZodObject<{
|
|
317
|
-
context: z.ZodLiteral<"server">;
|
|
318
|
-
access: z.ZodLiteral<"public">;
|
|
319
|
-
}, "strip", z.ZodTypeAny, {
|
|
320
|
-
context: "server";
|
|
321
|
-
access: "public";
|
|
322
|
-
}, {
|
|
323
|
-
context: "server";
|
|
324
|
-
access: "public";
|
|
305
|
+
min?: number | undefined;
|
|
306
|
+
max?: number | undefined;
|
|
307
|
+
gt?: number | undefined;
|
|
308
|
+
lt?: number | undefined;
|
|
309
|
+
int?: boolean | undefined;
|
|
325
310
|
}>, z.ZodObject<{
|
|
326
|
-
context: z.ZodLiteral<"server">;
|
|
327
|
-
access: z.ZodLiteral<"secret">;
|
|
328
|
-
}, "strip", z.ZodTypeAny, {
|
|
329
|
-
context: "server";
|
|
330
|
-
access: "secret";
|
|
331
|
-
}, {
|
|
332
|
-
context: "server";
|
|
333
|
-
access: "secret";
|
|
334
|
-
}>]>, z.ZodObject<{
|
|
335
311
|
type: z.ZodLiteral<"boolean">;
|
|
336
312
|
optional: z.ZodOptional<z.ZodBoolean>;
|
|
337
313
|
default: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -343,45 +319,47 @@ declare const BooleanField: z.ZodIntersection<z.ZodUnion<[z.ZodObject<{
|
|
|
343
319
|
type: "boolean";
|
|
344
320
|
default?: boolean | undefined;
|
|
345
321
|
optional?: boolean | undefined;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}, "strip", z.ZodTypeAny, {
|
|
352
|
-
context: "client";
|
|
353
|
-
access: "public";
|
|
354
|
-
}, {
|
|
355
|
-
context: "client";
|
|
356
|
-
access: "public";
|
|
357
|
-
}>, z.ZodObject<{
|
|
358
|
-
context: z.ZodLiteral<"server">;
|
|
359
|
-
access: z.ZodLiteral<"public">;
|
|
360
|
-
}, "strip", z.ZodTypeAny, {
|
|
361
|
-
context: "server";
|
|
362
|
-
access: "public";
|
|
363
|
-
}, {
|
|
364
|
-
context: "server";
|
|
365
|
-
access: "public";
|
|
366
|
-
}>, z.ZodObject<{
|
|
367
|
-
context: z.ZodLiteral<"server">;
|
|
368
|
-
access: z.ZodLiteral<"secret">;
|
|
322
|
+
}>, z.ZodEffects<z.ZodObject<{
|
|
323
|
+
type: z.ZodLiteral<"enum">;
|
|
324
|
+
values: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
325
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
326
|
+
default: z.ZodOptional<z.ZodString>;
|
|
369
327
|
}, "strip", z.ZodTypeAny, {
|
|
370
|
-
|
|
371
|
-
|
|
328
|
+
type: "enum";
|
|
329
|
+
values: string[];
|
|
330
|
+
default?: string | undefined;
|
|
331
|
+
optional?: boolean | undefined;
|
|
372
332
|
}, {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
default?:
|
|
333
|
+
type: "enum";
|
|
334
|
+
values: string[];
|
|
335
|
+
default?: string | undefined;
|
|
336
|
+
optional?: boolean | undefined;
|
|
337
|
+
}>, {
|
|
338
|
+
type: "enum";
|
|
339
|
+
values: string[];
|
|
340
|
+
default?: string | undefined;
|
|
381
341
|
optional?: boolean | undefined;
|
|
382
342
|
}, {
|
|
383
|
-
|
|
343
|
+
type: "enum";
|
|
344
|
+
values: string[];
|
|
345
|
+
default?: string | undefined;
|
|
384
346
|
optional?: boolean | undefined;
|
|
385
|
-
}
|
|
386
|
-
|
|
347
|
+
}>]>>>;
|
|
348
|
+
type Prettify<T> = {
|
|
349
|
+
[K in keyof T]: T[K];
|
|
350
|
+
} & {};
|
|
351
|
+
export type EnvSchema = z.infer<typeof EnvSchema>;
|
|
352
|
+
type _Field<T extends z.ZodType> = Prettify<z.infer<typeof EnvFieldMetadata & T>>;
|
|
353
|
+
type _FieldInput<T extends z.ZodType, TKey extends string = 'type'> = Prettify<z.infer<typeof EnvFieldMetadata> & Omit<z.infer<T>, TKey>>;
|
|
354
|
+
export type StringField = _Field<typeof StringSchema>;
|
|
355
|
+
export type StringFieldInput = _FieldInput<typeof StringSchema>;
|
|
356
|
+
export type NumberField = _Field<typeof NumberSchema>;
|
|
357
|
+
export type NumberFieldInput = _FieldInput<typeof NumberSchema>;
|
|
358
|
+
export type BooleanField = _Field<typeof BooleanSchema>;
|
|
359
|
+
export type BooleanFieldInput = _FieldInput<typeof BooleanSchema>;
|
|
360
|
+
export type EnumField = _Field<typeof EnumSchema>;
|
|
361
|
+
export type EnumFieldInput<T extends string> = Prettify<_FieldInput<typeof EnumSchema, 'type' | 'values' | 'default'> & {
|
|
362
|
+
values: Array<T>;
|
|
363
|
+
default?: NoInfer<T> | undefined;
|
|
364
|
+
}>;
|
|
387
365
|
export {};
|
package/dist/env/schema.js
CHANGED
|
@@ -1,21 +1,57 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { PUBLIC_PREFIX } from "./constants.js";
|
|
3
2
|
const StringSchema = z.object({
|
|
4
3
|
type: z.literal("string"),
|
|
5
4
|
optional: z.boolean().optional(),
|
|
6
|
-
default: z.string().optional()
|
|
5
|
+
default: z.string().optional(),
|
|
6
|
+
max: z.number().optional(),
|
|
7
|
+
min: z.number().min(0).optional(),
|
|
8
|
+
length: z.number().optional(),
|
|
9
|
+
url: z.boolean().optional(),
|
|
10
|
+
includes: z.string().optional(),
|
|
11
|
+
startsWith: z.string().optional(),
|
|
12
|
+
endsWith: z.string().optional()
|
|
7
13
|
});
|
|
8
14
|
const NumberSchema = z.object({
|
|
9
15
|
type: z.literal("number"),
|
|
10
16
|
optional: z.boolean().optional(),
|
|
11
|
-
default: z.number().optional()
|
|
17
|
+
default: z.number().optional(),
|
|
18
|
+
gt: z.number().optional(),
|
|
19
|
+
min: z.number().optional(),
|
|
20
|
+
lt: z.number().optional(),
|
|
21
|
+
max: z.number().optional(),
|
|
22
|
+
int: z.boolean().optional()
|
|
12
23
|
});
|
|
13
24
|
const BooleanSchema = z.object({
|
|
14
25
|
type: z.literal("boolean"),
|
|
15
26
|
optional: z.boolean().optional(),
|
|
16
27
|
default: z.boolean().optional()
|
|
17
28
|
});
|
|
18
|
-
const
|
|
29
|
+
const EnumSchema = z.object({
|
|
30
|
+
type: z.literal("enum"),
|
|
31
|
+
values: z.array(
|
|
32
|
+
// We use "'" for codegen so it can't be passed here
|
|
33
|
+
z.string().refine((v) => !v.includes("'"), {
|
|
34
|
+
message: `The "'" character can't be used as an enum value`
|
|
35
|
+
})
|
|
36
|
+
),
|
|
37
|
+
optional: z.boolean().optional(),
|
|
38
|
+
default: z.string().optional()
|
|
39
|
+
});
|
|
40
|
+
const EnvFieldType = z.union([
|
|
41
|
+
StringSchema,
|
|
42
|
+
NumberSchema,
|
|
43
|
+
BooleanSchema,
|
|
44
|
+
EnumSchema.superRefine((schema, ctx) => {
|
|
45
|
+
if (schema.default) {
|
|
46
|
+
if (!schema.values.includes(schema.default)) {
|
|
47
|
+
ctx.addIssue({
|
|
48
|
+
code: z.ZodIssueCode.custom,
|
|
49
|
+
message: `The default value "${schema.default}" must be one of the specified values: ${schema.values.join(", ")}.`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
]);
|
|
19
55
|
const PublicClientEnvFieldMetadata = z.object({
|
|
20
56
|
context: z.literal("client"),
|
|
21
57
|
access: z.literal("public")
|
|
@@ -28,86 +64,18 @@ const SecretServerEnvFieldMetadata = z.object({
|
|
|
28
64
|
context: z.literal("server"),
|
|
29
65
|
access: z.literal("secret")
|
|
30
66
|
});
|
|
67
|
+
const EnvFieldMetadata = z.union([
|
|
68
|
+
PublicClientEnvFieldMetadata,
|
|
69
|
+
PublicServerEnvFieldMetadata,
|
|
70
|
+
SecretServerEnvFieldMetadata
|
|
71
|
+
]);
|
|
31
72
|
const KEY_REGEX = /^[A-Z_]+$/;
|
|
32
73
|
const EnvSchema = z.record(
|
|
33
74
|
z.string().regex(KEY_REGEX, {
|
|
34
75
|
message: "A valid variable name can only contain uppercase letters and underscores."
|
|
35
76
|
}),
|
|
36
|
-
z.intersection(
|
|
37
|
-
z.union([
|
|
38
|
-
PublicClientEnvFieldMetadata,
|
|
39
|
-
PublicServerEnvFieldMetadata,
|
|
40
|
-
SecretServerEnvFieldMetadata
|
|
41
|
-
]),
|
|
42
|
-
EnvFieldType
|
|
43
|
-
)
|
|
44
|
-
).superRefine((schema, ctx) => {
|
|
45
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
46
|
-
if (key.startsWith(PUBLIC_PREFIX) && value.access !== "public") {
|
|
47
|
-
ctx.addIssue({
|
|
48
|
-
code: z.ZodIssueCode.custom,
|
|
49
|
-
message: `An environment variable whose name is prefixed by "${PUBLIC_PREFIX}" must be public.`
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (value.access === "public" && !key.startsWith(PUBLIC_PREFIX)) {
|
|
53
|
-
ctx.addIssue({
|
|
54
|
-
code: z.ZodIssueCode.custom,
|
|
55
|
-
message: `An environment variable that is public must have a name prefixed by "${PUBLIC_PREFIX}".`
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
const StringField = z.intersection(
|
|
61
|
-
z.union([
|
|
62
|
-
PublicClientEnvFieldMetadata,
|
|
63
|
-
PublicServerEnvFieldMetadata,
|
|
64
|
-
SecretServerEnvFieldMetadata
|
|
65
|
-
]),
|
|
66
|
-
StringSchema
|
|
67
|
-
);
|
|
68
|
-
const StringFieldInput = z.intersection(
|
|
69
|
-
z.union([
|
|
70
|
-
PublicClientEnvFieldMetadata,
|
|
71
|
-
PublicServerEnvFieldMetadata,
|
|
72
|
-
SecretServerEnvFieldMetadata
|
|
73
|
-
]),
|
|
74
|
-
StringSchema.omit({ type: true })
|
|
75
|
-
);
|
|
76
|
-
const NumberField = z.intersection(
|
|
77
|
-
z.union([
|
|
78
|
-
PublicClientEnvFieldMetadata,
|
|
79
|
-
PublicServerEnvFieldMetadata,
|
|
80
|
-
SecretServerEnvFieldMetadata
|
|
81
|
-
]),
|
|
82
|
-
NumberSchema
|
|
83
|
-
);
|
|
84
|
-
const NumberFieldInput = z.intersection(
|
|
85
|
-
z.union([
|
|
86
|
-
PublicClientEnvFieldMetadata,
|
|
87
|
-
PublicServerEnvFieldMetadata,
|
|
88
|
-
SecretServerEnvFieldMetadata
|
|
89
|
-
]),
|
|
90
|
-
NumberSchema.omit({ type: true })
|
|
91
|
-
);
|
|
92
|
-
const BooleanField = z.intersection(
|
|
93
|
-
z.union([
|
|
94
|
-
PublicClientEnvFieldMetadata,
|
|
95
|
-
PublicServerEnvFieldMetadata,
|
|
96
|
-
SecretServerEnvFieldMetadata
|
|
97
|
-
]),
|
|
98
|
-
BooleanSchema
|
|
99
|
-
);
|
|
100
|
-
const BooleanFieldInput = z.intersection(
|
|
101
|
-
z.union([
|
|
102
|
-
PublicClientEnvFieldMetadata,
|
|
103
|
-
PublicServerEnvFieldMetadata,
|
|
104
|
-
SecretServerEnvFieldMetadata
|
|
105
|
-
]),
|
|
106
|
-
BooleanSchema.omit({ type: true })
|
|
77
|
+
z.intersection(EnvFieldMetadata, EnvFieldType)
|
|
107
78
|
);
|
|
108
79
|
export {
|
|
109
|
-
|
|
110
|
-
EnvSchema,
|
|
111
|
-
NumberFieldInput,
|
|
112
|
-
StringFieldInput
|
|
80
|
+
EnvSchema
|
|
113
81
|
};
|