convex-env 2.1.0 → 2.2.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/dist/index.d.mts +7 -1
- package/dist/index.mjs +8 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,7 @@ type CreateEnvOptions = {
|
|
|
28
28
|
* FOO: v.string(),
|
|
29
29
|
* BAR: v.number(),
|
|
30
30
|
* BAZ: v.boolean(),
|
|
31
|
+
* FIZZ: v.union(v.literal("development"), v.literal("production")),
|
|
31
32
|
* });
|
|
32
33
|
*
|
|
33
34
|
* @example
|
|
@@ -36,11 +37,13 @@ type CreateEnvOptions = {
|
|
|
36
37
|
* FOO: v.string(),
|
|
37
38
|
* BAR: v.number(),
|
|
38
39
|
* BAZ: v.optional(v.boolean()),
|
|
40
|
+
* FIZZ: v.union(v.literal("development"), v.literal("production")),
|
|
39
41
|
* },
|
|
40
42
|
* values: {
|
|
41
43
|
* FOO: process.env.FOO,
|
|
42
44
|
* BAR: "42",
|
|
43
45
|
* BAZ: "true",
|
|
46
|
+
* FIZZ: "development",
|
|
44
47
|
* },
|
|
45
48
|
* options: {
|
|
46
49
|
* skipValidation: true,
|
|
@@ -52,7 +55,10 @@ declare const createEnv: <Schema extends Record<string, AllowedValidators>>(args
|
|
|
52
55
|
schema: Schema;
|
|
53
56
|
values?: Values<Schema>;
|
|
54
57
|
options?: CreateEnvOptions;
|
|
55
|
-
}) => { [K in keyof Schema]: InferredOuput<Schema[K]> }
|
|
58
|
+
}) => { [K in keyof Schema]: InferredOuput<Schema[K]> } & {
|
|
59
|
+
CONVEX_SITE_URL: string;
|
|
60
|
+
CONVEX_CLOUD_URL: string;
|
|
61
|
+
};
|
|
56
62
|
/**
|
|
57
63
|
*
|
|
58
64
|
* @description You may want to verify the existence and type of the environment variables separately from the creation of the env object. If so, use this function in convex.config.ts, and use the skipValidation option when calling createEnv.
|
package/dist/index.mjs
CHANGED
|
@@ -38,6 +38,7 @@ const validateAndTransformBoolean = (value) => {
|
|
|
38
38
|
* FOO: v.string(),
|
|
39
39
|
* BAR: v.number(),
|
|
40
40
|
* BAZ: v.boolean(),
|
|
41
|
+
* FIZZ: v.union(v.literal("development"), v.literal("production")),
|
|
41
42
|
* });
|
|
42
43
|
*
|
|
43
44
|
* @example
|
|
@@ -46,11 +47,13 @@ const validateAndTransformBoolean = (value) => {
|
|
|
46
47
|
* FOO: v.string(),
|
|
47
48
|
* BAR: v.number(),
|
|
48
49
|
* BAZ: v.optional(v.boolean()),
|
|
50
|
+
* FIZZ: v.union(v.literal("development"), v.literal("production")),
|
|
49
51
|
* },
|
|
50
52
|
* values: {
|
|
51
53
|
* FOO: process.env.FOO,
|
|
52
54
|
* BAR: "42",
|
|
53
55
|
* BAZ: "true",
|
|
56
|
+
* FIZZ: "development",
|
|
54
57
|
* },
|
|
55
58
|
* options: {
|
|
56
59
|
* skipValidation: true,
|
|
@@ -73,6 +76,7 @@ const createEnv = (args) => {
|
|
|
73
76
|
const values = inputValues ?? process.env;
|
|
74
77
|
return Object.keys(schema).map((key) => {
|
|
75
78
|
try {
|
|
79
|
+
if (key === "CONVEX_SITE_URL" || key === "CONVEX_CLOUD_URL") throw new Error("Cannot override CONVEX_SITE_URL or CONVEX_CLOUD_URL");
|
|
76
80
|
const validator = schema[key];
|
|
77
81
|
const envValue = values[key];
|
|
78
82
|
if (validator.isOptional === "required" && envValue === void 0 && options?.skipValidation !== true) throw new Error("Variable is required but not found in env");
|
|
@@ -86,7 +90,10 @@ const createEnv = (args) => {
|
|
|
86
90
|
}).reduce((acc, [key, value]) => {
|
|
87
91
|
acc[key] = value;
|
|
88
92
|
return acc;
|
|
89
|
-
}, {
|
|
93
|
+
}, {
|
|
94
|
+
CONVEX_SITE_URL: process.env.CONVEX_SITE_URL,
|
|
95
|
+
CONVEX_CLOUD_URL: process.env.CONVEX_CLOUD_URL
|
|
96
|
+
});
|
|
90
97
|
};
|
|
91
98
|
/**
|
|
92
99
|
*
|