@ontrails/config 1.0.0-beta.13 → 1.0.0-beta.14
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/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +11 -0
- package/README.md +212 -0
- package/dist/compose.d.ts +15 -11
- package/dist/compose.d.ts.map +1 -1
- package/dist/compose.js +9 -7
- package/dist/compose.js.map +1 -1
- package/dist/config-gate.d.ts +11 -0
- package/dist/config-gate.d.ts.map +1 -0
- package/dist/config-gate.js +6 -0
- package/dist/config-gate.js.map +1 -0
- package/dist/config-provision.d.ts +3 -0
- package/dist/config-provision.d.ts.map +1 -0
- package/dist/config-provision.js +26 -0
- package/dist/config-provision.js.map +1 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +1 -37
- package/dist/doctor.js.map +1 -1
- package/dist/explain.d.ts.map +1 -1
- package/dist/explain.js +5 -18
- package/dist/explain.js.map +1 -1
- package/dist/extensions.d.ts +1 -1
- package/dist/extensions.js +1 -1
- package/dist/generate/example.d.ts.map +1 -1
- package/dist/generate/example.js +20 -18
- package/dist/generate/example.js.map +1 -1
- package/dist/generate/helpers.js +1 -1
- package/dist/generate/helpers.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/ref.d.ts +8 -3
- package/dist/ref.d.ts.map +1 -1
- package/dist/ref.js +8 -3
- package/dist/ref.js.map +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +4 -1
- package/dist/resolve.js.map +1 -1
- package/dist/trails/config-check.js +12 -12
- package/dist/trails/config-check.js.map +1 -1
- package/dist/trails/config-describe.js +8 -8
- package/dist/trails/config-describe.js.map +1 -1
- package/dist/trails/config-explain.js +12 -12
- package/dist/trails/config-explain.js.map +1 -1
- package/dist/trails/config-init.js +13 -13
- package/dist/trails/config-init.js.map +1 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +5 -0
- package/dist/workspace.js.map +1 -1
- package/package.json +2 -2
- package/src/workspace.ts +5 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-lint.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ontrails/config
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 69057e9: Add hierarchical CLI command trees and structured input, enforce established-only topo exports across trailheads, move developer topo and tracker state onto shared `trails.db` with pins and maintenance flows, and ship schema-derived stores through `@ontrails/store` and its Drizzle runtime.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [69057e9]
|
|
12
|
+
- @ontrails/core@1.0.0-beta.14
|
|
13
|
+
|
|
3
14
|
## 1.0.0-beta.13
|
|
4
15
|
|
|
5
16
|
### Minor Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# @ontrails/config
|
|
2
|
+
|
|
3
|
+
Schema-derived configuration for Trails.
|
|
4
|
+
|
|
5
|
+
The root package owns the connector-agnostic config declaration and resolution engine. Schemas define the contract; the provision and gate bind resolved values to the execution context.
|
|
6
|
+
|
|
7
|
+
## The core pattern
|
|
8
|
+
|
|
9
|
+
### 1. Define the config schema
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { defineConfig, env, secret } from '@ontrails/config';
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
|
|
15
|
+
export const config = defineConfig({
|
|
16
|
+
schema: z.object({
|
|
17
|
+
port: z.number().default(3000),
|
|
18
|
+
host: z.string().default('localhost'),
|
|
19
|
+
database: z.object({
|
|
20
|
+
url: env(secret(z.string()), 'DATABASE_URL'),
|
|
21
|
+
}),
|
|
22
|
+
debug: z.boolean().default(false),
|
|
23
|
+
}),
|
|
24
|
+
base: {
|
|
25
|
+
host: 'example.com',
|
|
26
|
+
},
|
|
27
|
+
loadouts: {
|
|
28
|
+
production: {
|
|
29
|
+
debug: false,
|
|
30
|
+
host: 'prod.example.com',
|
|
31
|
+
port: 443,
|
|
32
|
+
},
|
|
33
|
+
test: {
|
|
34
|
+
debug: true,
|
|
35
|
+
port: 0,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 2. Resolve the config at bootstrap
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { registerConfigState } from '@ontrails/config';
|
|
45
|
+
|
|
46
|
+
const result = await config.resolve({
|
|
47
|
+
cwd: process.cwd(),
|
|
48
|
+
loadout: process.env.TRAILS_ENV,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (!result.isOk()) {
|
|
52
|
+
throw result.error;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
registerConfigState({
|
|
56
|
+
resolved: result.unwrap(),
|
|
57
|
+
schema: config.schema,
|
|
58
|
+
base: config.base,
|
|
59
|
+
loadout: process.env.TRAILS_ENV,
|
|
60
|
+
env: process.env,
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 3. Access resolved config in trails
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { configProvision } from '@ontrails/config';
|
|
68
|
+
|
|
69
|
+
export const getStatus = trail('status.get', {
|
|
70
|
+
provisions: [configProvision],
|
|
71
|
+
blaze: (_input, ctx) => {
|
|
72
|
+
const state = configProvision.from(ctx);
|
|
73
|
+
return Result.ok({
|
|
74
|
+
port: state.resolved.port,
|
|
75
|
+
debug: state.resolved.debug,
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Resolution stack
|
|
82
|
+
|
|
83
|
+
Config resolves through a deterministic priority order:
|
|
84
|
+
|
|
85
|
+
```text
|
|
86
|
+
defaults (schema) → base → loadout → local → env
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Each layer overrides the previous. Environment variables always win.
|
|
90
|
+
|
|
91
|
+
## Extensions
|
|
92
|
+
|
|
93
|
+
### `env()`
|
|
94
|
+
|
|
95
|
+
Bind a schema field to an environment variable:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { env } from '@ontrails/config';
|
|
99
|
+
|
|
100
|
+
const schema = z.object({
|
|
101
|
+
database: env(z.string(), 'DATABASE_URL'),
|
|
102
|
+
port: env(z.number(), 'PORT').default(3000),
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Environment variables are coerced to the schema type. Apply `env()` before `.default()` so metadata lives on the inner type.
|
|
107
|
+
|
|
108
|
+
### `secret()`
|
|
109
|
+
|
|
110
|
+
Mark a schema field as sensitive:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
import { secret } from '@ontrails/config';
|
|
114
|
+
|
|
115
|
+
const schema = z.object({
|
|
116
|
+
apiKey: secret(z.string()),
|
|
117
|
+
password: secret(env(z.string(), 'DB_PASSWORD')),
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Secret fields are redacted in explain output, diagnostics, and logs.
|
|
122
|
+
|
|
123
|
+
### `deprecated()`
|
|
124
|
+
|
|
125
|
+
Mark a field as deprecated with migration guidance:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
import { deprecated } from '@ontrails/config';
|
|
129
|
+
|
|
130
|
+
const schema = z.object({
|
|
131
|
+
oldField: deprecated(z.string(), 'Use newField instead'),
|
|
132
|
+
newField: z.string(),
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## The provision
|
|
137
|
+
|
|
138
|
+
The config provision manages resolved config lifecycle:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { configProvision } from '@ontrails/config';
|
|
142
|
+
|
|
143
|
+
export const myTrail = trail('my.trail', {
|
|
144
|
+
provisions: [configProvision],
|
|
145
|
+
blaze: (_input, ctx) => {
|
|
146
|
+
const state = configProvision.from(ctx);
|
|
147
|
+
return Result.ok(state.resolved);
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## The gate
|
|
153
|
+
|
|
154
|
+
The config gate reserves a slot in the execution context for per-trail config validation:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { configGate } from '@ontrails/config';
|
|
158
|
+
|
|
159
|
+
export const app = topo('my-app', configModule);
|
|
160
|
+
// Register configGate with your trailhead
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Trail definitions
|
|
164
|
+
|
|
165
|
+
### `config.check`
|
|
166
|
+
|
|
167
|
+
Validate config values against the schema. Returns diagnostics with field-level status (valid, missing, invalid, deprecated, default).
|
|
168
|
+
|
|
169
|
+
### `config.describe`
|
|
170
|
+
|
|
171
|
+
Describe all fields in the schema — paths, types, defaults, env bindings, secret markers, deprecation messages.
|
|
172
|
+
|
|
173
|
+
### `config.explain`
|
|
174
|
+
|
|
175
|
+
Show which source won for each config field — defaults, base, loadout, local, or env.
|
|
176
|
+
|
|
177
|
+
### `config.init`
|
|
178
|
+
|
|
179
|
+
Generate example config files in TOML, JSON, JSONC, or YAML. Optionally writes `.env.example` and `.schema.json`.
|
|
180
|
+
|
|
181
|
+
## Testing
|
|
182
|
+
|
|
183
|
+
Trails that depend on `configProvision` auto-resolve with a mock when registered in the topo:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { testAll } from '@ontrails/testing';
|
|
187
|
+
|
|
188
|
+
const results = testAll(app);
|
|
189
|
+
// configProvision.mock() is called automatically
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
For explicit test setup:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
import { registerConfigState, clearConfigState } from '@ontrails/config';
|
|
196
|
+
|
|
197
|
+
afterEach(() => clearConfigState());
|
|
198
|
+
|
|
199
|
+
test('config trail', async () => {
|
|
200
|
+
registerConfigState({
|
|
201
|
+
resolved: { port: 3000 },
|
|
202
|
+
schema: z.object({ port: z.number() }),
|
|
203
|
+
});
|
|
204
|
+
// ...
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Installation
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
bun add @ontrails/config @ontrails/core zod
|
|
212
|
+
```
|
package/dist/compose.d.ts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Config composition utilities for
|
|
2
|
+
* Config composition utilities for provisions.
|
|
3
3
|
*
|
|
4
|
-
* Collects config schemas from
|
|
4
|
+
* Collects config schemas from provision declarations so they can be
|
|
5
5
|
* composed into a unified config structure via `defineConfig`.
|
|
6
6
|
*/
|
|
7
7
|
import type { z } from 'zod';
|
|
8
|
-
/** A
|
|
9
|
-
export interface
|
|
10
|
-
readonly
|
|
8
|
+
/** A provision config schema entry extracted from a provision declaration. */
|
|
9
|
+
export interface ProvisionConfigEntry {
|
|
10
|
+
readonly provisionId: string;
|
|
11
11
|
readonly schema: z.ZodType;
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/** Backward-compatible alias while the migration is in flight. */
|
|
14
|
+
export type ServiceConfigEntry = ProvisionConfigEntry;
|
|
15
|
+
/** Minimal shape needed to extract config from a provision-like object. */
|
|
16
|
+
interface ProvisionWithOptionalConfig {
|
|
15
17
|
readonly id: string;
|
|
16
18
|
readonly config?: z.ZodType | undefined;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
|
-
* Collect config schemas from
|
|
21
|
+
* Collect config schemas from provisions that declare them.
|
|
20
22
|
*
|
|
21
|
-
* Returns entries keyed by
|
|
22
|
-
*
|
|
23
|
+
* Returns entries keyed by provision ID for composition into `defineConfig`.
|
|
24
|
+
* Provisions without a `config` schema are excluded.
|
|
23
25
|
*/
|
|
24
|
-
export declare const
|
|
26
|
+
export declare const collectProvisionConfigs: (provisions: readonly ProvisionWithOptionalConfig[]) => ProvisionConfigEntry[];
|
|
27
|
+
/** Backward-compatible alias while the migration is in flight. */
|
|
28
|
+
export declare const collectServiceConfigs: (provisions: readonly ProvisionWithOptionalConfig[]) => ProvisionConfigEntry[];
|
|
25
29
|
export {};
|
|
26
30
|
//# sourceMappingURL=compose.d.ts.map
|
package/dist/compose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAM7B,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC;CAC5B;AAED,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEtD,2EAA2E;AAC3E,UAAU,2BAA2B;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC;CACzC;AAMD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,YAAY,SAAS,2BAA2B,EAAE,KACjD,oBAAoB,EAQyC,CAAC;AAEjE,kEAAkE;AAClE,eAAO,MAAM,qBAAqB,eAZpB,SAAS,2BAA2B,EAAE,KACjD,oBAAoB,EAWqC,CAAC"}
|
package/dist/compose.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Config composition utilities for
|
|
2
|
+
* Config composition utilities for provisions.
|
|
3
3
|
*
|
|
4
|
-
* Collects config schemas from
|
|
4
|
+
* Collects config schemas from provision declarations so they can be
|
|
5
5
|
* composed into a unified config structure via `defineConfig`.
|
|
6
6
|
*/
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// Public API
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
10
|
/**
|
|
11
|
-
* Collect config schemas from
|
|
11
|
+
* Collect config schemas from provisions that declare them.
|
|
12
12
|
*
|
|
13
|
-
* Returns entries keyed by
|
|
14
|
-
*
|
|
13
|
+
* Returns entries keyed by provision ID for composition into `defineConfig`.
|
|
14
|
+
* Provisions without a `config` schema are excluded.
|
|
15
15
|
*/
|
|
16
|
-
export const
|
|
16
|
+
export const collectProvisionConfigs = (provisions) => provisions
|
|
17
17
|
.filter((svc) => svc.config !== undefined)
|
|
18
|
-
.map((svc) => ({
|
|
18
|
+
.map((svc) => ({ provisionId: svc.id, schema: svc.config }));
|
|
19
|
+
/** Backward-compatible alias while the migration is in flight. */
|
|
20
|
+
export const collectServiceConfigs = collectProvisionConfigs;
|
|
19
21
|
//# sourceMappingURL=compose.js.map
|
package/dist/compose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"compose.js","sourceRoot":"","sources":["../src/compose.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,UAAkD,EAC1B,EAAE,CAC1B,UAAU;KACP,MAAM,CACL,CACE,GAAG,EACkE,EAAE,CACvE,GAAG,CAAC,MAAM,KAAK,SAAS,CAC3B;KACA,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;AAEjE,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config gate — attaches resolved config to the execution context.
|
|
3
|
+
*
|
|
4
|
+
* For v1, the gate is a pass-through: config resolution happens at
|
|
5
|
+
* bootstrap time and the provision pipeline (TRL-91) injects the resolved
|
|
6
|
+
* config before any trail runs. The gate reserves a named slot so future
|
|
7
|
+
* versions can add per-trail config overrides or validation.
|
|
8
|
+
*/
|
|
9
|
+
import type { Gate } from '@ontrails/core';
|
|
10
|
+
export declare const configGate: Gate;
|
|
11
|
+
//# sourceMappingURL=config-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-gate.d.ts","sourceRoot":"","sources":["../src/config-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE3C,eAAO,MAAM,UAAU,EAAE,IAIxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-gate.js","sourceRoot":"","sources":["../src/config-gate.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,UAAU,GAAS;IAC9B,WAAW,EAAE,+DAA+D;IAC5E,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC;CACzD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-provision.d.ts","sourceRoot":"","sources":["../src/config-provision.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,eAAO,MAAM,eAAe,iDAkB1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config provision — manages resolved config lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* The config is resolved during bootstrap (two-phase init per ADR-010)
|
|
5
|
+
* and registered via `registerConfigState`. This provision reads from the
|
|
6
|
+
* global registry so trails can access it through `configProvision.from(ctx)`.
|
|
7
|
+
*/
|
|
8
|
+
import { InternalError, Result, provision } from '@ontrails/core';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { getConfigState } from './registry.js';
|
|
11
|
+
export const configProvision = provision('config', {
|
|
12
|
+
create: () => {
|
|
13
|
+
const state = getConfigState();
|
|
14
|
+
if (state === undefined) {
|
|
15
|
+
return Result.err(new InternalError('Config state not registered — call registerConfigState at bootstrap'));
|
|
16
|
+
}
|
|
17
|
+
return Result.ok(state);
|
|
18
|
+
},
|
|
19
|
+
description: 'Resolved application configuration',
|
|
20
|
+
meta: { category: 'infrastructure' },
|
|
21
|
+
mock: () => ({
|
|
22
|
+
resolved: {},
|
|
23
|
+
schema: z.object({}),
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=config-provision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-provision.js","sourceRoot":"","sources":["../src/config-provision.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,SAAS,CAAc,QAAQ,EAAE;IAC9D,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;QAC/B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC,GAAG,CACf,IAAI,aAAa,CACf,qEAAqE,CACtE,CACF,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,WAAW,EAAE,oCAAoC;IACjD,IAAI,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IACpC,IAAI,EAAE,GAAgB,EAAE,CAAC,CAAC;QACxB,QAAQ,EAAE,EAAE;QACZ,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;KACrB,CAAC;CACH,CAAC,CAAC"}
|
package/dist/doctor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAS7B,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAS7B,mDAAmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAoKD;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAC7C,QAAQ,CAAC,EACT,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU;IAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CAAE,KAC9D,WAkBF,CAAC"}
|
package/dist/doctor.js
CHANGED
|
@@ -14,8 +14,6 @@ const isDefaultWrapper = (schema) => zodDef(schema)['type'] === 'default';
|
|
|
14
14
|
const isOptionalWrapper = (schema) => zodDef(schema)['type'] === 'optional';
|
|
15
15
|
/** Get the default value from a ZodDefault wrapper. */
|
|
16
16
|
const getDefaultValue = (schema) => zodDef(schema)['defaultValue'];
|
|
17
|
-
const BOOL_TRUE = new Set(['true', '1']);
|
|
18
|
-
const BOOL_FALSE = new Set(['false', '0']);
|
|
19
17
|
/** Set a value at a dot-separated path, creating intermediate objects. */
|
|
20
18
|
const setAtPath = (obj, path, value) => {
|
|
21
19
|
const parts = path.split('.');
|
|
@@ -32,47 +30,13 @@ const setAtPath = (obj, path, value) => {
|
|
|
32
30
|
const lastPart = parts.at(-1);
|
|
33
31
|
current[lastPart] = value;
|
|
34
32
|
};
|
|
35
|
-
const resolveBaseTypeName = (schema) => zodDef(unwrapToBase(schema))['type'];
|
|
36
|
-
const coerceEnvValue = (raw, schema) => {
|
|
37
|
-
switch (resolveBaseTypeName(schema)) {
|
|
38
|
-
case 'number':
|
|
39
|
-
return Number(raw);
|
|
40
|
-
case 'boolean':
|
|
41
|
-
if (BOOL_TRUE.has(raw)) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
if (BOOL_FALSE.has(raw)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
return raw;
|
|
48
|
-
default:
|
|
49
|
-
return raw;
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const getFieldSchema = (schema, path) => {
|
|
53
|
-
let current = schema;
|
|
54
|
-
for (const part of path.split('.')) {
|
|
55
|
-
if (!isZodObject(current)) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
const shape = zodDef(unwrapToBase(current))['shape'];
|
|
59
|
-
const next = shape?.[part];
|
|
60
|
-
if (!next) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
current = next;
|
|
64
|
-
}
|
|
65
|
-
return current;
|
|
66
|
-
};
|
|
67
33
|
/** Build values object with env overrides applied. */
|
|
68
34
|
const applyEnvToValues = (values, schema, envVars) => {
|
|
69
35
|
const meta = collectConfigMeta(schema);
|
|
70
36
|
const result = structuredClone(values);
|
|
71
37
|
for (const [path, fieldMeta] of meta) {
|
|
72
38
|
if (fieldMeta.env && envVars[fieldMeta.env] !== undefined) {
|
|
73
|
-
|
|
74
|
-
const fieldSchema = getFieldSchema(schema, path);
|
|
75
|
-
setAtPath(result, path, fieldSchema ? coerceEnvValue(envValue, fieldSchema) : envValue);
|
|
39
|
+
setAtPath(result, path, envVars[fieldMeta.env]);
|
|
76
40
|
}
|
|
77
41
|
}
|
|
78
42
|
return result;
|
package/dist/doctor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAoB9E,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,4CAA4C;AAC5C,MAAM,gBAAgB,GAAG,CAAC,MAAiB,EAAW,EAAE,CACtD,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;AAEvC,6CAA6C;AAC7C,MAAM,iBAAiB,GAAG,CAAC,MAAiB,EAAW,EAAE,CACvD,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC;AAExC,uDAAuD;AACvD,MAAM,eAAe,GAAG,CAAC,MAAiB,EAAW,EAAE,CACrD,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAC;AAEjC,
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAoB9E,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,4CAA4C;AAC5C,MAAM,gBAAgB,GAAG,CAAC,MAAiB,EAAW,EAAE,CACtD,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;AAEvC,6CAA6C;AAC7C,MAAM,iBAAiB,GAAG,CAAC,MAAiB,EAAW,EAAE,CACvD,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC;AAExC,uDAAuD;AACvD,MAAM,eAAe,GA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,SAAS,eAAe,EAoC1B,CAAC"}
|
package/dist/explain.js
CHANGED
|
@@ -31,21 +31,8 @@ const buildSecretSet = (schema) => {
|
|
|
31
31
|
}
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
|
-
const hasPath = (obj, path) => {
|
|
35
|
-
let current = obj;
|
|
36
|
-
for (const part of path.split('.')) {
|
|
37
|
-
if (typeof current !== 'object' || current === null) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
if (!Object.hasOwn(current, part)) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
current = current[part];
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
};
|
|
47
34
|
/** Determine which source provided the winning value for a given path. */
|
|
48
|
-
const determineSource = (path, resolved,
|
|
35
|
+
const determineSource = (path, resolved, sources, envMap, envVars) => {
|
|
49
36
|
if (envVars && envMap.has(path)) {
|
|
50
37
|
const envVar = envMap.get(path);
|
|
51
38
|
if (envVar && envVars[envVar] !== undefined) {
|
|
@@ -53,8 +40,8 @@ const determineSource = (path, resolved, layers, envMap, envVars) => {
|
|
|
53
40
|
}
|
|
54
41
|
}
|
|
55
42
|
const resolvedValue = getAtPath(resolved, path);
|
|
56
|
-
for (const [name, values] of
|
|
57
|
-
if (values &&
|
|
43
|
+
for (const [name, values] of sources) {
|
|
44
|
+
if (values && getAtPath(values, path) === resolvedValue) {
|
|
58
45
|
return name;
|
|
59
46
|
}
|
|
60
47
|
}
|
|
@@ -91,14 +78,14 @@ export const explainConfig = (options) => {
|
|
|
91
78
|
const objSchema = options.schema;
|
|
92
79
|
const envMap = buildEnvMap(objSchema);
|
|
93
80
|
const secretSet = buildSecretSet(objSchema);
|
|
94
|
-
const
|
|
81
|
+
const sources = [
|
|
95
82
|
['local', options.local],
|
|
96
83
|
['loadout', options.loadout],
|
|
97
84
|
['base', options.base],
|
|
98
85
|
];
|
|
99
86
|
const paths = collectLeafPaths(objSchema, '');
|
|
100
87
|
return paths.map((path) => {
|
|
101
|
-
const source = determineSource(path, options.resolved,
|
|
88
|
+
const source = determineSource(path, options.resolved, sources, envMap, options.env);
|
|
102
89
|
const envVarName = envMap.get(path);
|
|
103
90
|
const isSecret = secretSet.has(path) ||
|
|
104
91
|
(envVarName !== undefined && isLikelySecret(envVarName));
|
package/dist/explain.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../src/explain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAwB9E,8EAA8E;AAC9E,qCAAqC;AACrC,8EAA8E;AAE9E,+DAA+D;AAC/D,MAAM,WAAW,GAAG,CAClB,MAA8C,EACzB,EAAE;IACvB,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;QACrC,IAAI,SAAS,CAAC,GAAG,EAAE,CAAC;YAClB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,kEAAkE;AAClE,MAAM,cAAc,GAAG,CACrB,MAA8C,EACjC,EAAE;IACf,MAAM,IAAI,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IACjC,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;QACrC,IAAI,SAAS,CA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pC,MAAM,QAAQ,GACZ,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;YACnB,CAAC,UAAU,KAAK,SAAS,IAAI,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEnD,OAAO;YACL,IAAI;YACJ,QAAQ,EAAE,QAAQ;YAClB,MAAM;YACN,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ;SAC1C,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/dist/extensions.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare const secret: <T extends z.ZodType>(schema: T) => T;
|
|
|
28
28
|
* standard key. We set `deprecated: true` so Zod-native tooling (schema
|
|
29
29
|
* serializers, OpenAPI generators) recognises the field as deprecated, and store
|
|
30
30
|
* the human-readable message under `deprecationMessage` for our own
|
|
31
|
-
* `collectConfigMeta` / survey / explain
|
|
31
|
+
* `collectConfigMeta` / survey / explain trailheads.
|
|
32
32
|
*
|
|
33
33
|
* Must be called BEFORE `.default()`, `.optional()`, or other transforms
|
|
34
34
|
* so that the metadata lives on the inner type where `collectConfigMeta`
|
package/dist/extensions.js
CHANGED
|
@@ -21,7 +21,7 @@ export const secret = (schema) => schema.meta({ ...schema.meta(), secret: true }
|
|
|
21
21
|
* standard key. We set `deprecated: true` so Zod-native tooling (schema
|
|
22
22
|
* serializers, OpenAPI generators) recognises the field as deprecated, and store
|
|
23
23
|
* the human-readable message under `deprecationMessage` for our own
|
|
24
|
-
* `collectConfigMeta` / survey / explain
|
|
24
|
+
* `collectConfigMeta` / survey / explain trailheads.
|
|
25
25
|
*
|
|
26
26
|
* Must be called BEFORE `.default()`, `.optional()`, or other transforms
|
|
27
27
|
* so that the metadata lives on the inner type where `collectConfigMeta`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/generate/example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../../src/generate/example.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmM7B,KAAK,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAYxD;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAC9C,QAAQ,aAAa,KACpB,MAAoC,CAAC"}
|
package/dist/generate/example.js
CHANGED
|
@@ -63,31 +63,33 @@ const buildJsonObject = (schema) => {
|
|
|
63
63
|
return obj;
|
|
64
64
|
};
|
|
65
65
|
const formatJson = (schema) => `${JSON.stringify(buildJsonObject(schema), null, 2)}\n`;
|
|
66
|
-
/**
|
|
67
|
-
const
|
|
68
|
-
pushComments(lines, fieldComments(fieldSchema, '//'), indent);
|
|
69
|
-
const comma = isLast ? '' : ',';
|
|
66
|
+
/** Serialize a nested object field for JSONC output. */
|
|
67
|
+
const serializeJsoncObject = (fieldSchema) => {
|
|
70
68
|
const nested = getObjectShape(fieldSchema);
|
|
71
|
-
if (nested) {
|
|
72
|
-
|
|
73
|
-
renderJsoncFields(nested, lines, `${indent} `);
|
|
74
|
-
lines.push(`${indent}}${comma}`);
|
|
75
|
-
return;
|
|
69
|
+
if (!nested) {
|
|
70
|
+
return undefined;
|
|
76
71
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
72
|
+
const inner = unwrap(fieldSchema);
|
|
73
|
+
return JSON.stringify(buildJsonObject(inner), null, 2).replaceAll('\n', '\n ');
|
|
79
74
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
75
|
+
/** Render a single JSONC entry (comments + key: value). */
|
|
76
|
+
const renderJsoncEntry = (key, fieldSchema, isLast, lines) => {
|
|
77
|
+
pushComments(lines, fieldComments(fieldSchema, '//'), ' ');
|
|
78
|
+
const comma = isLast ? '' : ',';
|
|
79
|
+
const serialized = isObjectType(fieldSchema)
|
|
80
|
+
? serializeJsoncObject(fieldSchema)
|
|
81
|
+
: undefined;
|
|
82
|
+
const val = serialized ?? formatValue(fieldValue(fieldSchema));
|
|
83
|
+
lines.push(` "${key}": ${val}${comma}`);
|
|
86
84
|
};
|
|
87
85
|
const formatJsonc = (schema) => {
|
|
86
|
+
const keys = Object.keys(schema.shape);
|
|
88
87
|
const shape = schema.shape;
|
|
89
88
|
const lines = ['{'];
|
|
90
|
-
|
|
89
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
90
|
+
const key = keys[i];
|
|
91
|
+
renderJsoncEntry(key, shape[key], i === keys.length - 1, lines);
|
|
92
|
+
}
|
|
91
93
|
lines.push('}');
|
|
92
94
|
return `${lines.join('\n')}\n`;
|
|
93
95
|
};
|