@vite-hub/env 0.0.4 → 0.3.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.
Files changed (57) hide show
  1. package/README.md +288 -23
  2. package/dist/access-B8lSDip4.js +54 -0
  3. package/dist/bridge-Cs9YfQWk.d.ts +447 -0
  4. package/dist/bridge-error-BhJ77age.js +66 -0
  5. package/dist/bridge.d.ts +2 -0
  6. package/dist/bridge.js +354 -0
  7. package/dist/cli-BPp7rdcA.d.ts +159 -0
  8. package/dist/cli-DLpY0QAo.js +669 -0
  9. package/dist/cli.d.ts +41 -0
  10. package/dist/cli.js +2 -0
  11. package/dist/database.d.ts +47 -0
  12. package/dist/database.js +274 -0
  13. package/dist/declarations-C5XR3aKw.d.ts +58 -0
  14. package/dist/error-diagnostics-B8RFjQ1V.js +56 -0
  15. package/dist/index.d.ts +146 -11
  16. package/dist/index.js +240 -7
  17. package/dist/internal/agent.d.ts +5 -0
  18. package/dist/internal/agent.js +22 -0
  19. package/dist/internal/connections.d.ts +18 -0
  20. package/dist/internal/connections.js +31 -0
  21. package/dist/internal/server.d.ts +3 -0
  22. package/dist/internal/server.js +2 -0
  23. package/dist/object-_dlsZ4lP.js +276 -0
  24. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  25. package/dist/operations-X1w--wds.js +30 -0
  26. package/dist/operations.d.ts +37 -0
  27. package/dist/operations.js +833 -0
  28. package/dist/runtime/public-env.d.ts +5 -0
  29. package/dist/runtime/public-env.js +8 -0
  30. package/dist/runtime/server-env.d.ts +22 -0
  31. package/dist/runtime/server-env.js +35 -0
  32. package/dist/schema-DMZ1_yhY.js +360 -0
  33. package/dist/seal.d.ts +17 -0
  34. package/dist/seal.js +52 -0
  35. package/dist/{secret.js → secret-DJd-fy5T.js} +1 -1
  36. package/dist/server-ChNL_Xc3.js +1279 -0
  37. package/dist/server-Dd8bjIKd.d.ts +145 -0
  38. package/dist/server.d.ts +3 -8
  39. package/dist/server.js +2 -3
  40. package/dist/virtual-module.d.ts +9 -5
  41. package/dist/virtual.d.ts +1 -1
  42. package/dist/vite.d.ts +79 -21
  43. package/dist/vite.js +1095 -339
  44. package/package.json +81 -28
  45. package/dist/declarations-CoMmvRqH.js +0 -159
  46. package/dist/declarations-U6P3rvxC.d.ts +0 -24
  47. package/dist/errors-C4Xcs6Fi.js +0 -121
  48. package/dist/presets.d.ts +0 -11
  49. package/dist/presets.js +0 -25
  50. package/dist/provider.d.ts +0 -6
  51. package/dist/provider.js +0 -7
  52. package/dist/schema.d.ts +0 -16
  53. package/dist/schema.js +0 -37
  54. package/dist/secret-C2191nAa.d.ts +0 -11
  55. package/dist/secret.d.ts +0 -2
  56. package/dist/server-C16sFc1E.js +0 -303
  57. package/dist/types-CsB6DTGE.d.ts +0 -190
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@vite-hub/env",
3
- "version": "0.0.4",
3
+ "version": "0.3.0",
4
4
  "description": "Safe build and runtime environment variables for ViteHub.",
5
5
  "keywords": [
6
6
  "env",
7
7
  "environment-variables",
8
8
  "runtime-config",
9
+ "secrets",
10
+ "typescript",
9
11
  "vite",
10
12
  "vitehub"
11
13
  ],
12
- "homepage": "https://github.com/vite-hub/vitehub#readme",
14
+ "homepage": "https://vitehub.dev",
13
15
  "bugs": "https://github.com/vite-hub/vitehub/issues",
14
16
  "license": "Apache-2.0",
15
17
  "author": "onmax <maximogarciamtnez@gmail.com>",
@@ -25,67 +27,118 @@
25
27
  "type": "module",
26
28
  "sideEffects": false,
27
29
  "types": "./dist/index.d.ts",
30
+ "imports": {
31
+ "#vitehub/env/public": {
32
+ "types": "./dist/runtime/public-env.d.ts",
33
+ "default": "./dist/runtime/public-env.js"
34
+ },
35
+ "#vitehub/env/server": {
36
+ "types": "./dist/runtime/server-env.d.ts",
37
+ "default": "./dist/runtime/server-env.js"
38
+ }
39
+ },
28
40
  "exports": {
29
41
  ".": {
30
42
  "types": "./dist/index.d.ts",
31
- "import": "./dist/index.js"
43
+ "import": "./dist/index.js",
44
+ "default": "./dist/index.js"
45
+ },
46
+ "./bridge": {
47
+ "types": "./dist/bridge.d.ts",
48
+ "import": "./dist/bridge.js",
49
+ "default": "./dist/bridge.js"
50
+ },
51
+ "./cli": {
52
+ "types": "./dist/cli.d.ts",
53
+ "import": "./dist/cli.js",
54
+ "default": "./dist/cli.js"
32
55
  },
33
- "./presets": {
34
- "types": "./dist/presets.d.ts",
35
- "import": "./dist/presets.js"
56
+ "./database": {
57
+ "types": "./dist/database.d.ts",
58
+ "import": "./dist/database.js",
59
+ "default": "./dist/database.js"
36
60
  },
37
- "./provider": {
38
- "types": "./dist/provider.d.ts",
39
- "import": "./dist/provider.js"
61
+ "./internal/agent": {
62
+ "types": "./dist/internal/agent.d.ts",
63
+ "import": "./dist/internal/agent.js",
64
+ "default": "./dist/internal/agent.js"
40
65
  },
41
- "./schema": {
42
- "types": "./dist/schema.d.ts",
43
- "import": "./dist/schema.js"
66
+ "./internal/connections": {
67
+ "types": "./dist/internal/connections.d.ts",
68
+ "import": "./dist/internal/connections.js",
69
+ "default": "./dist/internal/connections.js"
44
70
  },
45
- "./secret": {
46
- "types": "./dist/secret.d.ts",
47
- "import": "./dist/secret.js"
71
+ "./internal/server": {
72
+ "types": "./dist/internal/server.d.ts",
73
+ "import": "./dist/internal/server.js",
74
+ "default": "./dist/internal/server.js"
75
+ },
76
+ "./seal": {
77
+ "types": "./dist/seal.d.ts",
78
+ "import": "./dist/seal.js",
79
+ "default": "./dist/seal.js"
48
80
  },
49
81
  "./server": {
50
82
  "types": "./dist/server.d.ts",
51
- "import": "./dist/server.js"
83
+ "import": "./dist/server.js",
84
+ "default": "./dist/server.js"
52
85
  },
53
86
  "./virtual": {
54
87
  "types": "./dist/virtual.d.ts",
55
- "import": "./dist/virtual.js"
88
+ "import": "./dist/virtual.js",
89
+ "default": "./dist/virtual.js"
56
90
  },
57
91
  "./vite": {
58
92
  "types": "./dist/vite.d.ts",
59
- "import": "./dist/vite.js"
93
+ "import": "./dist/vite.js",
94
+ "default": "./dist/vite.js"
60
95
  },
61
96
  "./package.json": "./package.json"
62
97
  },
63
98
  "dependencies": {
64
- "@vite-hub/runtime": "0.0.4"
99
+ "@env-spec/parser": "0.6.2",
100
+ "@vite-hub/runtime": "0.3.0",
101
+ "nostics": "1.4.0",
102
+ "valibot": "^1.5.0"
65
103
  },
66
104
  "devDependencies": {
67
- "publint": "^0.3.21",
105
+ "@types/node": "^24.19.1",
106
+ "zod": "^4.6.7",
107
+ "@vite-hub/internal": "0.0.1",
108
+ "publint": "^0.3.25",
68
109
  "typescript": "^6.0.3",
69
- "vite": "^8.0.8",
70
- "vite-plus": "^0.1.24",
71
- "vitest": "^4.1.4",
72
- "@vite-hub/internal": "0.0.1"
110
+ "vite": "^8.2.2",
111
+ "vite-plus": "^0.3.3",
112
+ "vitest": "^4.1.11",
113
+ "drizzle-orm": "1.0.0-rc.5",
114
+ "@libsql/client": "^0.18.0",
115
+ "miniflare": "4.20260730.0",
116
+ "nitro": "^3.0.261103-rc"
73
117
  },
74
118
  "peerDependencies": {
75
- "vite": ">=8.0.0"
119
+ "vite": ">=8.0.0",
120
+ "drizzle-orm": "1.0.0-rc.5 || ^1.0.0",
121
+ "@vite-hub/agent": "0.3.0",
122
+ "nitro": "3.0.261102-rc || ^3.0.261103-rc"
76
123
  },
77
124
  "peerDependenciesMeta": {
78
125
  "vite": {
79
126
  "optional": true
127
+ },
128
+ "drizzle-orm": {
129
+ "optional": true
130
+ },
131
+ "@vite-hub/agent": {
132
+ "optional": true
80
133
  }
81
134
  },
82
135
  "engines": {
83
- "node": ">=24.0.0"
136
+ "node": ">=22.18.0"
84
137
  },
85
138
  "scripts": {
86
139
  "build": "vp pack",
87
140
  "dev": "vp pack --watch",
88
- "typecheck": "tsc --noEmit -p ./tsconfig.json",
89
- "test": "vp run -t @vite-hub/env#build && vp test"
141
+ "typecheck": "vp run --cache -t @vite-hub/env#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
142
+ "test": "vp run --cache -t @vite-hub/env#build && vp test"
90
143
  }
91
144
  }
@@ -1,159 +0,0 @@
1
- //#region src/core/declarations.ts
2
- const defaultStringSchema = {
3
- __vitehubDefaultRuntimeSchema: getDefaultStringSchemaToken(),
4
- safeParse(input) {
5
- return typeof input === "string" ? {
6
- data: input,
7
- success: true
8
- } : {
9
- error: /* @__PURE__ */ new Error("Expected string"),
10
- success: false
11
- };
12
- }
13
- };
14
- const defaultStringSchemaProperty = "__vitehubDefaultRuntimeSchema";
15
- const defaultStringSchemaToken = defaultStringSchema.__vitehubDefaultRuntimeSchema;
16
- const defaultStringSchemas = /* @__PURE__ */ new WeakMap();
17
- const defaultStringSchemaParsers = /* @__PURE__ */ new WeakSet();
18
- defaultStringSchemaParsers.add(defaultStringSchema.safeParse);
19
- function source(name) {
20
- const names = Array.isArray(name) ? name : [name];
21
- if (!names.length || names.some((value) => typeof value !== "string" || !value.trim())) throw new TypeError("env.source() requires one or more non-empty env variable names.");
22
- const normalized = names.map((value) => value.trim());
23
- return {
24
- kind: "env",
25
- label: `env:${normalized.join("|")}`,
26
- name: normalized[0],
27
- ...normalized.length > 1 ? { names: normalized } : {},
28
- serializable: true
29
- };
30
- }
31
- function custom(label, resolver) {
32
- return {
33
- kind: "custom",
34
- label,
35
- resolver,
36
- serializable: false
37
- };
38
- }
39
- function gitBranch() {
40
- return {
41
- kind: "git-branch",
42
- label: "git:branch",
43
- serializable: true
44
- };
45
- }
46
- function gitCommit(options = {}) {
47
- return {
48
- kind: "git-commit",
49
- label: "git:commit",
50
- serializable: true,
51
- short: options.short
52
- };
53
- }
54
- function gitRef() {
55
- return {
56
- kind: "git-ref",
57
- label: "git:ref",
58
- serializable: true
59
- };
60
- }
61
- function gitSha(options = {}) {
62
- return {
63
- kind: "git-sha",
64
- label: "git:sha",
65
- serializable: true,
66
- short: options.short
67
- };
68
- }
69
- function gitTag() {
70
- return {
71
- kind: "git-tag",
72
- label: "git:tag",
73
- serializable: true
74
- };
75
- }
76
- function buildTimestamp() {
77
- return {
78
- kind: "build-timestamp",
79
- label: "build:timestamp",
80
- serializable: true
81
- };
82
- }
83
- function packageJson(path) {
84
- return {
85
- kind: "package-json",
86
- label: `package.json:${path}`,
87
- path,
88
- serializable: true
89
- };
90
- }
91
- function provider(provider, key) {
92
- if (typeof provider !== "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(provider.trim())) throw new TypeError("env.provider() requires a provider name that starts with a letter and contains only letters, numbers, underscores, or hyphens.");
93
- if (typeof key !== "string" || !key.trim() || key.length > 512) throw new TypeError("env.provider() requires a non-empty provider key.");
94
- return {
95
- key: key.trim(),
96
- kind: "provider",
97
- label: "provider",
98
- provider: provider.trim(),
99
- serializable: true
100
- };
101
- }
102
- function variable(options = {}) {
103
- if (typeof options !== "object" || options === null || Array.isArray(options)) throw new TypeError("env() only accepts a single options object.");
104
- if (options.optional && typeof options.required !== "undefined") throw new TypeError("env() cannot use both optional and required.");
105
- const required = options.optional ? false : options.required ?? true;
106
- const source = typeof options.source === "function" ? custom("custom", options.source) : options.source;
107
- const schema = options.schema ?? defaultStringSchema;
108
- const declaration = {
109
- default: options.default,
110
- kind: "env-variable",
111
- mode: options.mode ?? "runtime",
112
- required,
113
- schema,
114
- secret: options.secret ?? false,
115
- source,
116
- type: options.type
117
- };
118
- if (typeof options.schema === "undefined") {
119
- defaultStringSchemas.set(declaration, defaultStringSchema);
120
- Object.defineProperty(declaration, defaultStringSchemaProperty, {
121
- enumerable: true,
122
- value: defaultStringSchemaToken
123
- });
124
- }
125
- return declaration;
126
- }
127
- const env = Object.assign(variable, {
128
- buildTimestamp,
129
- custom,
130
- gitBranch,
131
- gitCommit,
132
- gitRef,
133
- gitSha,
134
- gitTag,
135
- packageJson,
136
- provider,
137
- source,
138
- variable
139
- });
140
- function isDefaultStringEnvVariable(declaration) {
141
- const declarationToken = Object.getOwnPropertyDescriptor(declaration, defaultStringSchemaProperty)?.value;
142
- const schemaObject = typeof declaration.schema === "object" && declaration.schema !== null ? declaration.schema : void 0;
143
- const schemaToken = schemaObject ? Object.getOwnPropertyDescriptor(schemaObject, defaultStringSchemaProperty)?.value : void 0;
144
- return defaultStringSchemas.get(declaration) === declaration.schema || declarationToken === defaultStringSchemaToken && schemaToken === defaultStringSchemaToken && schemaObject !== void 0 && hasOnlyDefaultStringSchemaKeys(schemaObject);
145
- }
146
- function getDefaultStringSchemaToken() {
147
- const tokenKey = Symbol.for("vitehub.env.defaultRuntimeSchemaToken");
148
- const globalScope = globalThis;
149
- globalScope[tokenKey] ??= `string:${Math.random().toString(36).slice(2)}`;
150
- return globalScope[tokenKey];
151
- }
152
- function hasOnlyDefaultStringSchemaKeys(schema) {
153
- if ("~standard" in schema || "parse" in schema) return false;
154
- const keys = Reflect.ownKeys(schema);
155
- const safeParse = Object.getOwnPropertyDescriptor(schema, "safeParse");
156
- return keys.length === 2 && keys.includes(defaultStringSchemaProperty) && keys.includes("safeParse") && typeof safeParse?.value === "function" && defaultStringSchemaParsers.has(safeParse.value);
157
- }
158
- //#endregion
159
- export { env as n, isDefaultStringEnvVariable as r, defaultStringSchema as t };
@@ -1,24 +0,0 @@
1
- import { _ as EnvVariableOptions, g as EnvVariableDeclaration, h as EnvSourceResolver, p as EnvSource } from "./types-CsB6DTGE.js";
2
-
3
- //#region src/core/declarations.d.ts
4
- interface EnvNamespace {
5
- (options?: EnvVariableOptions): EnvVariableDeclaration;
6
- buildTimestamp: () => EnvSource;
7
- custom: (label: string, resolver: EnvSourceResolver) => EnvSource;
8
- gitBranch: () => EnvSource;
9
- gitCommit: (options?: {
10
- short?: boolean;
11
- }) => EnvSource;
12
- gitRef: () => EnvSource;
13
- gitSha: (options?: {
14
- short?: boolean;
15
- }) => EnvSource;
16
- gitTag: () => EnvSource;
17
- packageJson: (path: string) => EnvSource;
18
- provider: (provider: string, key: string) => EnvSource;
19
- source: (name: string | string[]) => EnvSource;
20
- variable: (options?: EnvVariableOptions) => EnvVariableDeclaration;
21
- }
22
- declare const env: EnvNamespace;
23
- //#endregion
24
- export { env as t };
@@ -1,121 +0,0 @@
1
- import { ViteHubError } from "@vite-hub/runtime";
2
- //#region src/core/errors.ts
3
- const envErrorMessages = {
4
- ENV_DECLARATION_INVALID: "[vitehub] Env declaration is invalid.",
5
- ENV_ASYNC_REQUIRED: "[vitehub] Server Env requires asynchronous loading.",
6
- ENV_REQUIRED_MISSING: "[vitehub] Required Env value is missing.",
7
- ENV_RUNTIME_VALUE_INVALID: "[vitehub] Runtime Env value is invalid.",
8
- ENV_SOURCE_FAILED: "[vitehub] Env source resolution failed."
9
- };
10
- const envSourceIdentifierSet = new Set([
11
- "custom",
12
- "env",
13
- "git:branch",
14
- "git:commit",
15
- "git:ref",
16
- "git:sha",
17
- "git:tag",
18
- "package.json",
19
- "provider"
20
- ]);
21
- function invalidOptions() {
22
- throw new TypeError("[vitehub] Invalid Env error options.");
23
- }
24
- function own(value, key) {
25
- if (typeof value !== "object" || value === null || Array.isArray(value)) invalidOptions();
26
- try {
27
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
28
- if (descriptor === void 0) return void 0;
29
- if (!("value" in descriptor)) invalidOptions();
30
- return descriptor.value;
31
- } catch {
32
- invalidOptions();
33
- }
34
- }
35
- function createEnvError(options) {
36
- const code = own(options, "code");
37
- if (typeof code !== "string" || !Object.hasOwn(envErrorMessages, code)) invalidOptions();
38
- const cause = own(options, "cause");
39
- const details = normalizeDetails(code, own(options, "details"));
40
- return new ViteHubError(code, envErrorMessages[code], {
41
- ...cause === void 0 ? {} : { cause },
42
- ...details === void 0 ? {} : { details }
43
- });
44
- }
45
- function invalidEnvDeclaration(path, diagnostic) {
46
- return createEnvError({
47
- cause: new TypeError(diagnostic),
48
- code: "ENV_DECLARATION_INVALID",
49
- details: optionalPath(path)
50
- });
51
- }
52
- function asyncServerEnvRequired(path) {
53
- return createEnvError({
54
- cause: /* @__PURE__ */ new TypeError(`Server Env at ${path} uses env.provider(). Use loadServerEnv() or runWithServerEnv().`),
55
- code: "ENV_ASYNC_REQUIRED",
56
- details: optionalPath(path)
57
- });
58
- }
59
- function missingRequiredEnv(source, diagnostic, path) {
60
- const pathDetails = optionalPath(path);
61
- return createEnvError({
62
- cause: new Error(diagnostic),
63
- code: "ENV_REQUIRED_MISSING",
64
- details: {
65
- ...pathDetails,
66
- source: publicSourceIdentifier(source)
67
- }
68
- });
69
- }
70
- function invalidRuntimeEnvValue(source, diagnostic) {
71
- return createEnvError({
72
- cause: new TypeError(diagnostic),
73
- code: "ENV_RUNTIME_VALUE_INVALID",
74
- details: { source: publicSourceIdentifier(source) }
75
- });
76
- }
77
- function envSourceFailed(source, cause) {
78
- return createEnvError({
79
- cause,
80
- code: "ENV_SOURCE_FAILED",
81
- details: { source: publicSourceIdentifier(source) }
82
- });
83
- }
84
- function isAbortError(value) {
85
- if ((typeof value !== "object" || value === null) && typeof value !== "function") return false;
86
- try {
87
- return value.name === "AbortError";
88
- } catch {
89
- return false;
90
- }
91
- }
92
- function publicSourceIdentifier(source) {
93
- if (envSourceIdentifierSet.has(source)) return source;
94
- if (source.startsWith("env:")) return "env";
95
- if (source.startsWith("package.json:")) return "package.json";
96
- return "custom";
97
- }
98
- function normalizeDetails(code, details) {
99
- if (details === void 0) return void 0;
100
- if (typeof details !== "object" || details === null || Array.isArray(details)) invalidOptions();
101
- const normalized = {};
102
- if (code === "ENV_ASYNC_REQUIRED" || code === "ENV_DECLARATION_INVALID" || code === "ENV_REQUIRED_MISSING") {
103
- const path = safePath(own(details, "path"));
104
- if (path) normalized.path = path;
105
- }
106
- if (code !== "ENV_ASYNC_REQUIRED" && code !== "ENV_DECLARATION_INVALID") {
107
- const source = own(details, "source");
108
- if (envSourceIdentifierSet.has(source)) normalized.source = source;
109
- }
110
- return Object.keys(normalized).length ? normalized : void 0;
111
- }
112
- function optionalPath(path) {
113
- const normalized = safePath(path);
114
- return normalized ? { path: normalized } : {};
115
- }
116
- function safePath(path) {
117
- if (typeof path !== "string" || path.length > 256) return void 0;
118
- return /^(?:env|runtime)(?:\.[A-Za-z_$][A-Za-z0-9_$-]{0,63}){0,8}$/.test(path) ? path : void 0;
119
- }
120
- //#endregion
121
- export { isAbortError as a, invalidRuntimeEnvValue as i, envSourceFailed as n, missingRequiredEnv as o, invalidEnvDeclaration as r, asyncServerEnvRequired as t };
package/dist/presets.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { d as EnvRuntimeConfigOptions } from "./types-CsB6DTGE.js";
2
-
3
- //#region src/presets.d.ts
4
- interface OpenWorkflowEnvOptions {
5
- namespaceId?: string;
6
- schema?: string;
7
- workerConcurrency?: string;
8
- }
9
- declare function openWorkflowEnv(options?: OpenWorkflowEnvOptions): EnvRuntimeConfigOptions;
10
- //#endregion
11
- export { OpenWorkflowEnvOptions, openWorkflowEnv };
package/dist/presets.js DELETED
@@ -1,25 +0,0 @@
1
- import { n as env } from "./declarations-CoMmvRqH.js";
2
- //#region src/presets.ts
3
- function openWorkflowEnv(options = {}) {
4
- return {
5
- namespaceId: env({
6
- default: options.namespaceId || "production",
7
- source: env.source("OPENWORKFLOW_NAMESPACE_ID")
8
- }),
9
- postgresUrl: env({
10
- optional: true,
11
- secret: true,
12
- source: env.source(["OPENWORKFLOW_POSTGRES_URL", "DATABASE_URL"])
13
- }),
14
- schema: env({
15
- default: options.schema || "openworkflow",
16
- source: env.source("OPENWORKFLOW_SCHEMA")
17
- }),
18
- workerConcurrency: env({
19
- default: options.workerConcurrency || "10",
20
- source: env.source("OPENWORKFLOW_WORKER_CONCURRENCY")
21
- })
22
- };
23
- }
24
- //#endregion
25
- export { openWorkflowEnv };
@@ -1,6 +0,0 @@
1
- import { c as EnvProviderContext, l as EnvProviderValues, s as EnvProvider } from "./types-CsB6DTGE.js";
2
-
3
- //#region src/provider.d.ts
4
- declare function defineEnvProvider<TEnv extends Record<string, unknown> = Record<string, unknown>, const TProvider extends EnvProvider<TEnv> = EnvProvider<TEnv>>(provider: TProvider): TProvider;
5
- //#endregion
6
- export { type EnvProvider, type EnvProviderContext, type EnvProviderValues, defineEnvProvider };
package/dist/provider.js DELETED
@@ -1,7 +0,0 @@
1
- //#region src/provider.ts
2
- function defineEnvProvider(provider) {
3
- if (typeof provider !== "object" || provider === null || Array.isArray(provider) || typeof provider.read !== "function") throw new TypeError("[vitehub] defineEnvProvider() requires a provider with a read({ env, keys, signal }) method.");
4
- return provider;
5
- }
6
- //#endregion
7
- export { defineEnvProvider };
package/dist/schema.d.ts DELETED
@@ -1,16 +0,0 @@
1
- //#region src/schema.d.ts
2
- interface StandardSchemaResultSuccess<T = unknown> {
3
- issues?: undefined;
4
- value: T;
5
- }
6
- interface StandardSchemaResultFailure {
7
- issues: readonly unknown[];
8
- }
9
- interface StandardSchemaV1<T = unknown> {
10
- "~standard": {
11
- validate: (input: unknown) => StandardSchemaResultSuccess<T> | StandardSchemaResultFailure | Promise<StandardSchemaResultSuccess<T> | StandardSchemaResultFailure>;
12
- };
13
- }
14
- declare function parseSchema(schema: unknown, value: unknown, label: string): unknown;
15
- //#endregion
16
- export { StandardSchemaResultFailure, StandardSchemaResultSuccess, StandardSchemaV1, parseSchema };
package/dist/schema.js DELETED
@@ -1,37 +0,0 @@
1
- //#region src/schema.ts
2
- function parseSchema(schema, value, label) {
3
- if (isStandardSchema(schema)) {
4
- const result = schema["~standard"].validate(value);
5
- if (isPromiseLike(result)) throw new Error(`[vitehub] ${label} uses an async schema. Env validation currently requires sync schemas.`);
6
- if ("issues" in result && result.issues && result.issues.length > 0) throw new Error(`[vitehub] Invalid ${label}: ${formatIssues(result.issues)}`);
7
- if (!("value" in result)) throw new Error(`[vitehub] Invalid ${label}: ${formatIssues(result.issues)}`);
8
- return result.value;
9
- }
10
- if (isZodLike(schema) && typeof schema.safeParse === "function") {
11
- const result = schema.safeParse(value);
12
- if (!result.success) throw new Error(`[vitehub] Invalid ${label}: ${formatIssues(result.error)}`);
13
- return result.data;
14
- }
15
- if (isZodLike(schema) && typeof schema.parse === "function") try {
16
- return schema.parse(value);
17
- } catch (error) {
18
- throw new Error(`[vitehub] Invalid ${label}: ${formatIssues(error)}`);
19
- }
20
- return value;
21
- }
22
- function isPromiseLike(value) {
23
- return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
24
- }
25
- function isStandardSchema(schema) {
26
- return typeof schema === "object" && schema !== null && "~standard" in schema && typeof schema["~standard"]?.validate === "function";
27
- }
28
- function isZodLike(schema) {
29
- return typeof schema === "object" && schema !== null;
30
- }
31
- function formatIssues(issues) {
32
- if (Array.isArray(issues)) return issues.map((issue) => typeof issue === "string" ? issue : JSON.stringify(issue)).join("; ");
33
- if (issues instanceof Error) return issues.message;
34
- return typeof issues === "string" ? issues : JSON.stringify(issues);
35
- }
36
- //#endregion
37
- export { parseSchema };
@@ -1,11 +0,0 @@
1
- //#region src/secret.d.ts
2
- declare class SecretEnv<T = string> {
3
- #private;
4
- constructor(value: T);
5
- unseal(): T;
6
- toString(): string;
7
- toJSON(): string;
8
- [Symbol.toPrimitive](): string;
9
- }
10
- //#endregion
11
- export { SecretEnv as t };
package/dist/secret.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { t as SecretEnv } from "./secret-C2191nAa.js";
2
- export { SecretEnv };