@thexjs/env 0.1.2 → 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.
- package/dist/index.d.ts +9 -1
- package/dist/index.js +3 -1
- package/package.json +3 -15
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { EnvValidator } from './validators.js';
|
|
2
2
|
export { bool, num, oneOf, str, url } from './validators.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Default prefix required of any variable exposed to client/browser code.
|
|
6
|
+
* Matches the compiler boundary enforced by `@thexjs/core`'s build step
|
|
7
|
+
* (`security/env-isolation.ts`) — anything not prefixed with this is treated
|
|
8
|
+
* as server-only and will fail the build if referenced from client code.
|
|
9
|
+
*/
|
|
10
|
+
declare const DEFAULT_CLIENT_PREFIX = "THEXJS_PUBLIC_";
|
|
4
11
|
interface EnvSchemaInput {
|
|
5
12
|
server?: Record<string, EnvValidator>;
|
|
13
|
+
/** Required prefix for client-exposed variables. Default: "THEXJS_PUBLIC_". */
|
|
6
14
|
clientPrefix?: string;
|
|
7
15
|
client?: Record<string, EnvValidator>;
|
|
8
16
|
runtimeEnv: Record<string, string | undefined>;
|
|
@@ -15,4 +23,4 @@ type InferClient<T, P extends string> = {
|
|
|
15
23
|
};
|
|
16
24
|
declare function createEnv<T extends EnvSchemaInput>(schema: T): InferServer<T["server"]> & InferClient<T["client"], T["clientPrefix"] extends string ? T["clientPrefix"] : "">;
|
|
17
25
|
|
|
18
|
-
export { EnvValidator, createEnv };
|
|
26
|
+
export { DEFAULT_CLIENT_PREFIX, EnvValidator, createEnv };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-FUU2FFDH.js";
|
|
8
8
|
|
|
9
9
|
// src/index.ts
|
|
10
|
+
var DEFAULT_CLIENT_PREFIX = "THEXJS_PUBLIC_";
|
|
10
11
|
function createEnv(schema) {
|
|
11
12
|
const errors = [];
|
|
12
13
|
const result = {};
|
|
@@ -20,7 +21,7 @@ function createEnv(schema) {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
if (schema.client) {
|
|
23
|
-
const prefix = schema.clientPrefix ??
|
|
24
|
+
const prefix = schema.clientPrefix ?? DEFAULT_CLIENT_PREFIX;
|
|
24
25
|
for (const [key, validator] of Object.entries(schema.client)) {
|
|
25
26
|
if (!key.startsWith(prefix)) {
|
|
26
27
|
errors.push(`client.${key}: must start with prefix "${prefix}"`);
|
|
@@ -40,6 +41,7 @@ function createEnv(schema) {
|
|
|
40
41
|
return result;
|
|
41
42
|
}
|
|
42
43
|
export {
|
|
44
|
+
DEFAULT_CLIENT_PREFIX,
|
|
43
45
|
bool,
|
|
44
46
|
createEnv,
|
|
45
47
|
num,
|
package/package.json
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thexjs/env",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Type-safe environment variable loading and validation for the x framework.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"environment-variables",
|
|
7
|
-
"env",
|
|
8
|
-
"validation",
|
|
9
|
-
"typescript",
|
|
10
|
-
"config",
|
|
11
|
-
"bun",
|
|
12
|
-
"x"
|
|
13
|
-
],
|
|
5
|
+
"keywords": ["environment-variables", "env", "validation", "typescript", "config", "bun", "x"],
|
|
14
6
|
"license": "MIT",
|
|
15
7
|
"type": "module",
|
|
16
8
|
"sideEffects": false,
|
|
@@ -27,11 +19,7 @@
|
|
|
27
19
|
"import": "./dist/validators.js"
|
|
28
20
|
}
|
|
29
21
|
},
|
|
30
|
-
"files": [
|
|
31
|
-
"dist",
|
|
32
|
-
"README.md",
|
|
33
|
-
"LICENSE"
|
|
34
|
-
],
|
|
22
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
35
23
|
"publishConfig": {
|
|
36
24
|
"access": "public"
|
|
37
25
|
},
|