@wild-framework/config 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wild Framework contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # @wild-framework/config
2
+
3
+ Typed configuration management using Zod for [Wild Framework](https://github.com/your-org/wild-framework).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @wild-framework/config
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { Config } from "@wild-framework/config";
15
+ import { z } from "zod";
16
+
17
+ config.register("database", z.object({
18
+ host: z.string().default("localhost"),
19
+ port: z.coerce.number().default(5432),
20
+ }));
21
+
22
+ config.validate();
23
+
24
+ const db = config.get<{ host: string; port: number }>("database");
25
+ ```
26
+
27
+ Env vars map automatically: `DATABASE_HOST` → `database.host`.
28
+
29
+ ## License
30
+
31
+ MIT
@@ -0,0 +1,54 @@
1
+ import type { ZodSchema } from "zod";
2
+ /**
3
+ * Typed configuration manager.
4
+ *
5
+ * Providers register Zod schemas under namespaces. On validation, env vars
6
+ * are mapped to schema keys and parsed. Access is fully typed via `get<T>()`.
7
+ */
8
+ export declare class Config {
9
+ private schemas;
10
+ private validated;
11
+ /**
12
+ * Register a Zod schema under a namespace.
13
+ *
14
+ * Must be called during provider `register()` — before `validate()`.
15
+ */
16
+ register<T>(namespace: string, schema: ZodSchema<T>): void;
17
+ /**
18
+ * Validate all registered schemas against environment variables.
19
+ *
20
+ * Env var names are derived as `{NAMESPACE}_{KEY}` (uppercased).
21
+ * Nested keys use `__` separator.
22
+ *
23
+ * Throws `ConfigValidationError` with all failures if any schema fails.
24
+ */
25
+ validate(): void;
26
+ /**
27
+ * Get validated config for a namespace.
28
+ *
29
+ * The caller must provide the expected type for type safety:
30
+ * `config.get<DBConfig>("database")`.
31
+ *
32
+ * Throws if not validated yet or namespace not registered.
33
+ */
34
+ get<T>(namespace: string): T;
35
+ /**
36
+ * Whether validation has completed.
37
+ */
38
+ isValidated(): boolean;
39
+ /**
40
+ * Read env vars for a namespace and expand dotted keys into nested objects.
41
+ *
42
+ * Example: namespace "auth", env vars { AUTH_JWT__SECRET: "x" }
43
+ * → result { jwt: { secret: "x" } }
44
+ */
45
+ private readEnv;
46
+ /**
47
+ * Convert a flat dotted-key record into a nested object.
48
+ *
49
+ * { "jwt.secret": "x", "host": "localhost" }
50
+ * → { jwt: { secret: "x" }, host: "localhost" }
51
+ */
52
+ private unflatten;
53
+ }
54
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,KAAK,CAAC;AAa/C;;;;;GAKG;AACH,qBAAa,MAAM;IACf,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,SAAS,CAAS;IAM1B;;;;OAIG;IACH,QAAQ,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI;IAW1D;;;;;;;OAOG;IACH,QAAQ,IAAI,IAAI;IAyBhB;;;;;;;OAOG;IACH,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC;IAa5B;;OAEG;IACH,WAAW,IAAI,OAAO;IAQtB;;;;;OAKG;IACH,OAAO,CAAC,OAAO;IAiBf;;;;;OAKG;IACH,OAAO,CAAC,SAAS;CAqBpB"}
package/dist/config.js ADDED
@@ -0,0 +1,127 @@
1
+ import { ConfigAlreadyRegisteredError, ConfigNotRegisteredError, ConfigNotValidatedError, ConfigValidationError, } from "./errors.js";
2
+ /**
3
+ * Typed configuration manager.
4
+ *
5
+ * Providers register Zod schemas under namespaces. On validation, env vars
6
+ * are mapped to schema keys and parsed. Access is fully typed via `get<T>()`.
7
+ */
8
+ export class Config {
9
+ schemas = new Map();
10
+ validated = false;
11
+ // -----------------------------------------------------------------------
12
+ // Registration
13
+ // -----------------------------------------------------------------------
14
+ /**
15
+ * Register a Zod schema under a namespace.
16
+ *
17
+ * Must be called during provider `register()` — before `validate()`.
18
+ */
19
+ register(namespace, schema) {
20
+ if (this.schemas.has(namespace)) {
21
+ throw new ConfigAlreadyRegisteredError(namespace);
22
+ }
23
+ this.schemas.set(namespace, { schema: schema });
24
+ }
25
+ // -----------------------------------------------------------------------
26
+ // Validation
27
+ // -----------------------------------------------------------------------
28
+ /**
29
+ * Validate all registered schemas against environment variables.
30
+ *
31
+ * Env var names are derived as `{NAMESPACE}_{KEY}` (uppercased).
32
+ * Nested keys use `__` separator.
33
+ *
34
+ * Throws `ConfigValidationError` with all failures if any schema fails.
35
+ */
36
+ validate() {
37
+ const failures = [];
38
+ for (const [namespace, entry] of this.schemas) {
39
+ const envValues = this.readEnv(namespace);
40
+ const result = entry.schema.safeParse(envValues);
41
+ if (result.success) {
42
+ entry.value = result.data;
43
+ }
44
+ else {
45
+ failures.push({ namespace, issues: result.error.issues });
46
+ }
47
+ }
48
+ if (failures.length > 0) {
49
+ throw new ConfigValidationError(failures);
50
+ }
51
+ this.validated = true;
52
+ }
53
+ // -----------------------------------------------------------------------
54
+ // Access
55
+ // -----------------------------------------------------------------------
56
+ /**
57
+ * Get validated config for a namespace.
58
+ *
59
+ * The caller must provide the expected type for type safety:
60
+ * `config.get<DBConfig>("database")`.
61
+ *
62
+ * Throws if not validated yet or namespace not registered.
63
+ */
64
+ get(namespace) {
65
+ if (!this.validated) {
66
+ throw new ConfigNotValidatedError();
67
+ }
68
+ const entry = this.schemas.get(namespace);
69
+ if (!entry) {
70
+ throw new ConfigNotRegisteredError(namespace);
71
+ }
72
+ return entry.value;
73
+ }
74
+ /**
75
+ * Whether validation has completed.
76
+ */
77
+ isValidated() {
78
+ return this.validated;
79
+ }
80
+ // -----------------------------------------------------------------------
81
+ // Internal
82
+ // -----------------------------------------------------------------------
83
+ /**
84
+ * Read env vars for a namespace and expand dotted keys into nested objects.
85
+ *
86
+ * Example: namespace "auth", env vars { AUTH_JWT__SECRET: "x" }
87
+ * → result { jwt: { secret: "x" } }
88
+ */
89
+ readEnv(namespace) {
90
+ const prefix = namespace.toUpperCase() + "_";
91
+ const flat = {};
92
+ for (const [key, value] of Object.entries(process.env)) {
93
+ if (key.startsWith(prefix) && value !== undefined) {
94
+ const configKey = key
95
+ .slice(prefix.length)
96
+ .toLowerCase()
97
+ .replace(/__/g, ".");
98
+ flat[configKey] = value;
99
+ }
100
+ }
101
+ return this.unflatten(flat);
102
+ }
103
+ /**
104
+ * Convert a flat dotted-key record into a nested object.
105
+ *
106
+ * { "jwt.secret": "x", "host": "localhost" }
107
+ * → { jwt: { secret: "x" }, host: "localhost" }
108
+ */
109
+ unflatten(flat) {
110
+ const result = {};
111
+ for (const [key, value] of Object.entries(flat)) {
112
+ const parts = key.split(".");
113
+ let current = result;
114
+ for (let i = 0; i < parts.length - 1; i++) {
115
+ const part = parts[i];
116
+ if (!current[part] || typeof current[part] !== "object") {
117
+ current[part] = {};
118
+ }
119
+ current = current[part];
120
+ }
121
+ const lastPart = parts[parts.length - 1];
122
+ current[lastPart] = value;
123
+ }
124
+ return result;
125
+ }
126
+ }
127
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EACH,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,aAAa,CAAC;AAOrB;;;;;GAKG;AACH,MAAM,OAAO,MAAM;IACP,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IACzC,SAAS,GAAG,KAAK,CAAC;IAE1B,0EAA0E;IAC1E,eAAe;IACf,0EAA0E;IAE1E;;;;OAIG;IACH,QAAQ,CAAI,SAAiB,EAAE,MAAoB;QAC/C,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,4BAA4B,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAmB,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,0EAA0E;IAC1E,aAAa;IACb,0EAA0E;IAE1E;;;;;;;OAOG;IACH,QAAQ;QACJ,MAAM,QAAQ,GAAqD,EAAE,CAAC;QAEtE,KAAK,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAA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 +1,34 @@
1
+ import type { ZodIssue } from "zod";
2
+ /**
3
+ * Thrown when config validation fails.
4
+ * Contains all validation errors grouped by namespace.
5
+ */
6
+ export declare class ConfigValidationError extends Error {
7
+ readonly errors: Array<{
8
+ namespace: string;
9
+ issues: ZodIssue[];
10
+ }>;
11
+ constructor(errors: Array<{
12
+ namespace: string;
13
+ issues: ZodIssue[];
14
+ }>);
15
+ }
16
+ /**
17
+ * Thrown when accessing config for a namespace that hasn't been registered.
18
+ */
19
+ export declare class ConfigNotRegisteredError extends Error {
20
+ constructor(namespace: string);
21
+ }
22
+ /**
23
+ * Thrown when accessing config before validation has run.
24
+ */
25
+ export declare class ConfigNotValidatedError extends Error {
26
+ constructor();
27
+ }
28
+ /**
29
+ * Thrown when registering a config namespace that already exists.
30
+ */
31
+ export declare class ConfigAlreadyRegisteredError extends Error {
32
+ constructor(namespace: string);
33
+ }
34
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,KAAK,CAAC;AAE/C;;;GAGG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC5C,SAAgB,MAAM,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC,CAAC;gBAE7D,MAAM,EAAE,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,QAAQ,EAAE,CAAA;KAAE,CAAC;CASvE;AAED;;GAEG;AACH,qBAAa,wBAAyB,SAAQ,KAAK;gBACnC,SAAS,EAAE,MAAM;CAIhC;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;;CAKjD;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;gBACvC,SAAS,EAAE,MAAM;CAIhC"}
package/dist/errors.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Thrown when config validation fails.
3
+ * Contains all validation errors grouped by namespace.
4
+ */
5
+ export class ConfigValidationError extends Error {
6
+ errors;
7
+ constructor(errors) {
8
+ const count = errors.reduce((sum, e) => sum + e.issues.length, 0);
9
+ const namespaces = errors.map(e => `"${e.namespace}"`).join(", ");
10
+ super(`Config validation failed with ${count} error(s) across [${namespaces}].`);
11
+ this.name = "ConfigValidationError";
12
+ this.errors = errors;
13
+ }
14
+ }
15
+ /**
16
+ * Thrown when accessing config for a namespace that hasn't been registered.
17
+ */
18
+ export class ConfigNotRegisteredError extends Error {
19
+ constructor(namespace) {
20
+ super(`Config namespace "${namespace}" has not been registered.`);
21
+ this.name = "ConfigNotRegisteredError";
22
+ }
23
+ }
24
+ /**
25
+ * Thrown when accessing config before validation has run.
26
+ */
27
+ export class ConfigNotValidatedError extends Error {
28
+ constructor() {
29
+ super("Config has not been validated yet. Call config.validate() first.");
30
+ this.name = "ConfigNotValidatedError";
31
+ }
32
+ }
33
+ /**
34
+ * Thrown when registering a config namespace that already exists.
35
+ */
36
+ export class ConfigAlreadyRegisteredError extends Error {
37
+ constructor(namespace) {
38
+ super(`Config namespace "${namespace}" is already registered.`);
39
+ this.name = "ConfigAlreadyRegisteredError";
40
+ }
41
+ }
42
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC5B,MAAM,CAAmD;IAEzE,YAAY,MAAwD;QAChE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAClE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClE,KAAK,CACD,iCAAiC,KAAK,qBAAqB,UAAU,IAAI,CAC5E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC/C,YAAY,SAAiB;QACzB,KAAK,CAAC,qBAAqB,SAAS,4BAA4B,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IAC3C,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAC9C;QACI,KAAK,CAAC,kEAAkE,CAAC,CAAC;QAC1E,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IAC1C,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IACnD,YAAY,SAAiB;QACzB,KAAK,CAAC,qBAAqB,SAAS,0BAA0B,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC/C,CAAC;CACJ"}
@@ -0,0 +1,4 @@
1
+ export { Config } from "./config.js";
2
+ export { ConfigProvider } from "./provider.js";
3
+ export { ConfigAlreadyRegisteredError, ConfigNotRegisteredError, ConfigNotValidatedError, ConfigValidationError, } from "./errors.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACH,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { Config } from "./config.js";
2
+ export { ConfigProvider } from "./provider.js";
3
+ export { ConfigAlreadyRegisteredError, ConfigNotRegisteredError, ConfigNotValidatedError, ConfigValidationError, } from "./errors.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACH,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,GACxB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Provider, Application } from "@wild-framework/core";
2
+ /**
3
+ * Registers the configuration system with the application.
4
+ *
5
+ * Must be registered after `ContainerProvider` and before any provider
6
+ * that registers config schemas.
7
+ *
8
+ * - `register()`: creates Config, binds it into the container
9
+ * - `boot()`: validates all registered schemas (fail-early)
10
+ */
11
+ export declare class ConfigProvider implements Provider {
12
+ register(app: Application): void;
13
+ boot(app: Application): void;
14
+ }
15
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIlE;;;;;;;;GAQG;AACH,qBAAa,cAAe,YAAW,QAAQ;IAC3C,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;IAMhC,IAAI,CAAC,GAAG,EAAE,WAAW,GAAG,IAAI;CAI/B"}
@@ -0,0 +1,23 @@
1
+ import { Container } from "@wild-framework/container";
2
+ import { Config } from "./config.js";
3
+ /**
4
+ * Registers the configuration system with the application.
5
+ *
6
+ * Must be registered after `ContainerProvider` and before any provider
7
+ * that registers config schemas.
8
+ *
9
+ * - `register()`: creates Config, binds it into the container
10
+ * - `boot()`: validates all registered schemas (fail-early)
11
+ */
12
+ export class ConfigProvider {
13
+ register(app) {
14
+ const container = app.resolve(Container);
15
+ const config = new Config();
16
+ container.singleton(Config, () => config);
17
+ }
18
+ boot(app) {
19
+ const config = app.resolve(Config);
20
+ config.validate();
21
+ }
22
+ }
23
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;GAQG;AACH,MAAM,OAAO,cAAc;IACvB,QAAQ,CAAC,GAAgB;QACrB,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC5B,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC,GAAgB;QACjB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;CACJ"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@wild-framework/config",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "license": "MIT",
20
+ "author": "Sphah",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/KhandaSoftware/wild-framework.git"
24
+ },
25
+ "description": "Typed configuration management using Zod for Wild Framework.",
26
+ "keywords": [
27
+ "wild",
28
+ "framework",
29
+ "config",
30
+ "zod",
31
+ "typed"
32
+ ],
33
+ "dependencies": {
34
+ "zod": "^3.24.0",
35
+ "@wild-framework/core": "0.1.0",
36
+ "@wild-framework/container": "0.1.0"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "clean": "rm -rf dist",
41
+ "test": "vitest run"
42
+ }
43
+ }