@ontrails/config 1.0.0-beta.14 → 1.0.0-beta.16
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/CHANGELOG.md +41 -0
- package/README.md +20 -28
- package/package.json +10 -2
- package/src/app-config.ts +23 -12
- package/src/compose.ts +16 -22
- package/src/{config-provision.ts → config-resource.ts} +5 -5
- package/src/define-config.ts +18 -18
- package/src/{generate → derive}/env.ts +3 -3
- package/src/{generate → derive}/example.ts +1 -1
- package/src/{generate → derive}/helpers.ts +1 -1
- package/src/derive/index.ts +3 -0
- package/src/{generate → derive}/json-schema.ts +1 -1
- package/src/{describe.ts → derive-fields.ts} +1 -1
- package/src/{explain.ts → derive-provenance.ts} +6 -6
- package/src/extensions.ts +1 -1
- package/src/index.ts +12 -19
- package/src/registry.ts +2 -2
- package/src/resolve.ts +17 -15
- package/src/trails/config-check.ts +3 -3
- package/src/trails/config-describe.ts +5 -5
- package/src/trails/config-explain.ts +13 -13
- package/src/trails/config-init.ts +10 -10
- package/.turbo/turbo-build.log +0 -1
- package/.turbo/turbo-lint.log +0 -3
- package/.turbo/turbo-typecheck.log +0 -1
- package/dist/app-config.d.ts +0 -65
- package/dist/app-config.d.ts.map +0 -1
- package/dist/app-config.js +0 -172
- package/dist/app-config.js.map +0 -1
- package/dist/collect.d.ts +0 -11
- package/dist/collect.d.ts.map +0 -1
- package/dist/collect.js +0 -81
- package/dist/collect.js.map +0 -1
- package/dist/compose.d.ts +0 -30
- package/dist/compose.d.ts.map +0 -1
- package/dist/compose.js +0 -21
- package/dist/compose.js.map +0 -1
- package/dist/config-gate.d.ts +0 -11
- package/dist/config-gate.d.ts.map +0 -1
- package/dist/config-gate.js +0 -6
- package/dist/config-gate.js.map +0 -1
- package/dist/config-layer.d.ts +0 -11
- package/dist/config-layer.d.ts.map +0 -1
- package/dist/config-layer.js +0 -6
- package/dist/config-layer.js.map +0 -1
- package/dist/config-provision.d.ts +0 -3
- package/dist/config-provision.d.ts.map +0 -1
- package/dist/config-provision.js +0 -26
- package/dist/config-provision.js.map +0 -1
- package/dist/config-service.d.ts +0 -3
- package/dist/config-service.d.ts.map +0 -1
- package/dist/config-service.js +0 -26
- package/dist/config-service.js.map +0 -1
- package/dist/define-config.d.ts +0 -61
- package/dist/define-config.d.ts.map +0 -1
- package/dist/define-config.js +0 -90
- package/dist/define-config.js.map +0 -1
- package/dist/describe.d.ts +0 -25
- package/dist/describe.d.ts.map +0 -1
- package/dist/describe.js +0 -147
- package/dist/describe.js.map +0 -1
- package/dist/doctor.d.ts +0 -27
- package/dist/doctor.d.ts.map +0 -1
- package/dist/doctor.js +0 -131
- package/dist/doctor.js.map +0 -1
- package/dist/explain.d.ts +0 -30
- package/dist/explain.d.ts.map +0 -1
- package/dist/explain.js +0 -101
- package/dist/explain.js.map +0 -1
- package/dist/extensions.d.ts +0 -38
- package/dist/extensions.d.ts.map +0 -1
- package/dist/extensions.js +0 -35
- package/dist/extensions.js.map +0 -1
- package/dist/generate/env.d.ts +0 -15
- package/dist/generate/env.d.ts.map +0 -1
- package/dist/generate/env.js +0 -65
- package/dist/generate/env.js.map +0 -1
- package/dist/generate/example.d.ts +0 -16
- package/dist/generate/example.d.ts.map +0 -1
- package/dist/generate/example.js +0 -138
- package/dist/generate/example.js.map +0 -1
- package/dist/generate/helpers.d.ts +0 -35
- package/dist/generate/helpers.d.ts.map +0 -1
- package/dist/generate/helpers.js +0 -116
- package/dist/generate/helpers.js.map +0 -1
- package/dist/generate/index.d.ts +0 -4
- package/dist/generate/index.d.ts.map +0 -1
- package/dist/generate/index.js +0 -4
- package/dist/generate/index.js.map +0 -1
- package/dist/generate/json-schema.d.ts +0 -18
- package/dist/generate/json-schema.d.ts.map +0 -1
- package/dist/generate/json-schema.js +0 -97
- package/dist/generate/json-schema.js.map +0 -1
- package/dist/index.d.ts +0 -21
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/merge.d.ts +0 -16
- package/dist/merge.d.ts.map +0 -1
- package/dist/merge.js +0 -34
- package/dist/merge.js.map +0 -1
- package/dist/ref.d.ts +0 -29
- package/dist/ref.d.ts.map +0 -1
- package/dist/ref.js +0 -30
- package/dist/ref.js.map +0 -1
- package/dist/registry.d.ts +0 -24
- package/dist/registry.d.ts.map +0 -1
- package/dist/registry.js +0 -12
- package/dist/registry.js.map +0 -1
- package/dist/resolve.d.ts +0 -21
- package/dist/resolve.d.ts.map +0 -1
- package/dist/resolve.js +0 -177
- package/dist/resolve.js.map +0 -1
- package/dist/secret-heuristics.d.ts +0 -10
- package/dist/secret-heuristics.d.ts.map +0 -1
- package/dist/secret-heuristics.js +0 -11
- package/dist/secret-heuristics.js.map +0 -1
- package/dist/trails/config-check.d.ts +0 -11
- package/dist/trails/config-check.d.ts.map +0 -1
- package/dist/trails/config-check.js +0 -53
- package/dist/trails/config-check.js.map +0 -1
- package/dist/trails/config-describe.d.ts +0 -12
- package/dist/trails/config-describe.d.ts.map +0 -1
- package/dist/trails/config-describe.js +0 -41
- package/dist/trails/config-describe.js.map +0 -1
- package/dist/trails/config-explain.d.ts +0 -8
- package/dist/trails/config-explain.d.ts.map +0 -1
- package/dist/trails/config-explain.js +0 -74
- package/dist/trails/config-explain.js.map +0 -1
- package/dist/trails/config-init.d.ts +0 -9
- package/dist/trails/config-init.d.ts.map +0 -1
- package/dist/trails/config-init.js +0 -78
- package/dist/trails/config-init.js.map +0 -1
- package/dist/workspace.d.ts +0 -9
- package/dist/workspace.d.ts.map +0 -1
- package/dist/workspace.js +0 -49
- package/dist/workspace.js.map +0 -1
- package/dist/zod-utils.d.ts +0 -14
- package/dist/zod-utils.d.ts.map +0 -1
- package/dist/zod-utils.js +0 -41
- package/dist/zod-utils.js.map +0 -1
- package/src/__tests__/app-config.test.ts +0 -329
- package/src/__tests__/compose.test.ts +0 -59
- package/src/__tests__/config-check.test.ts +0 -171
- package/src/__tests__/config-describe.test.ts +0 -154
- package/src/__tests__/config-explain.test.ts +0 -167
- package/src/__tests__/config-gate.test.ts +0 -53
- package/src/__tests__/config-init.test.ts +0 -210
- package/src/__tests__/config-provision.test.ts +0 -87
- package/src/__tests__/define-config.test.ts +0 -263
- package/src/__tests__/describe.test.ts +0 -158
- package/src/__tests__/doctor.test.ts +0 -172
- package/src/__tests__/explain.test.ts +0 -139
- package/src/__tests__/extensions.test.ts +0 -134
- package/src/__tests__/generate.test.ts +0 -269
- package/src/__tests__/ref.test.ts +0 -35
- package/src/__tests__/resolve.test.ts +0 -246
- package/src/__tests__/workspace.test.ts +0 -64
- package/src/config-gate.ts +0 -15
- package/src/generate/index.ts +0 -3
- package/src/workspace.ts +0 -56
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/dist/compose.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config composition utilities for provisions.
|
|
3
|
-
*
|
|
4
|
-
* Collects config schemas from provision declarations so they can be
|
|
5
|
-
* composed into a unified config structure via `defineConfig`.
|
|
6
|
-
*/
|
|
7
|
-
import type { z } from 'zod';
|
|
8
|
-
/** A provision config schema entry extracted from a provision declaration. */
|
|
9
|
-
export interface ProvisionConfigEntry {
|
|
10
|
-
readonly provisionId: string;
|
|
11
|
-
readonly schema: z.ZodType;
|
|
12
|
-
}
|
|
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 {
|
|
17
|
-
readonly id: string;
|
|
18
|
-
readonly config?: z.ZodType | undefined;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Collect config schemas from provisions that declare them.
|
|
22
|
-
*
|
|
23
|
-
* Returns entries keyed by provision ID for composition into `defineConfig`.
|
|
24
|
-
* Provisions without a `config` schema are excluded.
|
|
25
|
-
*/
|
|
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[];
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=compose.d.ts.map
|
package/dist/compose.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config composition utilities for provisions.
|
|
3
|
-
*
|
|
4
|
-
* Collects config schemas from provision declarations so they can be
|
|
5
|
-
* composed into a unified config structure via `defineConfig`.
|
|
6
|
-
*/
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Public API
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* Collect config schemas from provisions that declare them.
|
|
12
|
-
*
|
|
13
|
-
* Returns entries keyed by provision ID for composition into `defineConfig`.
|
|
14
|
-
* Provisions without a `config` schema are excluded.
|
|
15
|
-
*/
|
|
16
|
-
export const collectProvisionConfigs = (provisions) => provisions
|
|
17
|
-
.filter((svc) => svc.config !== undefined)
|
|
18
|
-
.map((svc) => ({ provisionId: svc.id, schema: svc.config }));
|
|
19
|
-
/** Backward-compatible alias while the migration is in flight. */
|
|
20
|
-
export const collectServiceConfigs = collectProvisionConfigs;
|
|
21
|
-
//# sourceMappingURL=compose.js.map
|
package/dist/compose.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/config-gate.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/config-gate.js
DELETED
package/dist/config-gate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/config-layer.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config layer — attaches resolved config to the execution context.
|
|
3
|
-
*
|
|
4
|
-
* For v1, the layer is a pass-through: config resolution happens at
|
|
5
|
-
* bootstrap time and the service pipeline (TRL-91) injects the resolved
|
|
6
|
-
* config before any trail runs. The layer reserves a named slot so
|
|
7
|
-
* future versions can add per-trail config overrides or validation.
|
|
8
|
-
*/
|
|
9
|
-
import type { Layer } from '@ontrails/core';
|
|
10
|
-
export declare const configLayer: Layer;
|
|
11
|
-
//# sourceMappingURL=config-layer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-layer.d.ts","sourceRoot":"","sources":["../src/config-layer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,eAAO,MAAM,WAAW,EAAE,KAIzB,CAAC"}
|
package/dist/config-layer.js
DELETED
package/dist/config-layer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-layer.js","sourceRoot":"","sources":["../src/config-layer.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,WAAW,GAAU;IAChC,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"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/config-provision.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/config-service.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-service.d.ts","sourceRoot":"","sources":["../src/config-service.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,eAAO,MAAM,aAAa,+CAkBxB,CAAC"}
|
package/dist/config-service.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config service — manages resolved config lifecycle.
|
|
3
|
-
*
|
|
4
|
-
* The config is resolved during bootstrap (two-phase init per ADR-010)
|
|
5
|
-
* and registered via `registerConfigState`. This service reads from the
|
|
6
|
-
* global registry so trails can access it through `configService.from(ctx)`.
|
|
7
|
-
*/
|
|
8
|
-
import { InternalError, Result, service } from '@ontrails/core';
|
|
9
|
-
import { z } from 'zod';
|
|
10
|
-
import { getConfigState } from './registry.js';
|
|
11
|
-
export const configService = service('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
|
-
metadata: { category: 'infrastructure' },
|
|
21
|
-
mock: () => ({
|
|
22
|
-
resolved: {},
|
|
23
|
-
schema: z.object({}),
|
|
24
|
-
}),
|
|
25
|
-
});
|
|
26
|
-
//# sourceMappingURL=config-service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-service.js","sourceRoot":"","sources":["../src/config-service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,CAAC,MAAM,aAAa,GAAG,OAAO,CAAc,QAAQ,EAAE;IAC1D,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,QAAQ,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IACxC,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/define-config.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trails-specific config wrapper — `appConfig('trails', ...)` with
|
|
3
|
-
* framework conventions for loadout selection and local overrides.
|
|
4
|
-
*/
|
|
5
|
-
import type { z } from 'zod';
|
|
6
|
-
/** Options for defining a Trails app config. */
|
|
7
|
-
export interface DefineConfigOptions<T extends z.ZodType> {
|
|
8
|
-
readonly schema: T;
|
|
9
|
-
readonly base?: Partial<z.infer<T>>;
|
|
10
|
-
readonly loadouts?: Record<string, Partial<z.infer<T>>>;
|
|
11
|
-
/** When true, fall back to `NODE_ENV` when `TRAILS_ENV` is unset. */
|
|
12
|
-
readonly envFromNodeEnv?: boolean;
|
|
13
|
-
}
|
|
14
|
-
/** Options passed to `resolve()` on a defined config. */
|
|
15
|
-
interface DefineConfigResolveOptions {
|
|
16
|
-
readonly loadout?: string;
|
|
17
|
-
readonly env?: Record<string, string | undefined>;
|
|
18
|
-
/** Working directory for local overrides discovery. Defaults to `process.cwd()`. */
|
|
19
|
-
readonly cwd?: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Define Trails app config.
|
|
23
|
-
*
|
|
24
|
-
* This is `appConfig('trails', ...)` with the framework's own conventions:
|
|
25
|
-
* `TRAILS_ENV` selects the loadout. When `envFromNodeEnv` is true,
|
|
26
|
-
* `NODE_ENV` is used as a fallback when `TRAILS_ENV` is unset.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const config = defineConfig({
|
|
31
|
-
* schema: z.object({
|
|
32
|
-
* port: z.number().default(3000),
|
|
33
|
-
* debug: z.boolean().default(false),
|
|
34
|
-
* }),
|
|
35
|
-
* base: { port: 8080 },
|
|
36
|
-
* loadouts: {
|
|
37
|
-
* production: { debug: false },
|
|
38
|
-
* test: { debug: true, port: 0 },
|
|
39
|
-
* },
|
|
40
|
-
* });
|
|
41
|
-
*
|
|
42
|
-
* const result = config.resolve();
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export declare const defineConfig: <T extends z.ZodType>(options: DefineConfigOptions<T>) => {
|
|
46
|
-
base: Partial<z.core.output<T>> | undefined;
|
|
47
|
-
loadouts: Record<string, Partial<z.core.output<T>>> | undefined;
|
|
48
|
-
resolve: (resolveOpts?: DefineConfigResolveOptions) => Promise<import("@ontrails/core").Result<z.core.output<T>, Error>>;
|
|
49
|
-
schema: T;
|
|
50
|
-
name: string;
|
|
51
|
-
formats: readonly import("./app-config.js").ConfigFormat[];
|
|
52
|
-
dotfile: boolean;
|
|
53
|
-
describe(): readonly import("./describe.js").FieldDescription[];
|
|
54
|
-
check(values: Record<string, unknown>, options?: {
|
|
55
|
-
readonly env?: Record<string, string | undefined>;
|
|
56
|
-
}): import("./doctor.js").CheckResult;
|
|
57
|
-
explain(options: import("./app-config.js").AppConfigExplainOptions): readonly import("./explain.js").ProvenanceEntry[];
|
|
58
|
-
ref(fieldPath: string): import("./ref.js").ConfigRef;
|
|
59
|
-
};
|
|
60
|
-
export {};
|
|
61
|
-
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAS7B,gDAAgD;AAChD,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO;IACtD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IACnB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,qEAAqE;IACrE,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,yDAAyD;AACzD,UAAU,0BAA0B;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,oFAAoF;IACpF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAoCD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAC9C,SAAS,mBAAmB,CAAC,CAAC,CAAC;;;4BAWC,0BAA0B;;;;;;;oBAxCtB,CAAC;;;;CAqEtC,CAAC"}
|
package/dist/define-config.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Trails-specific config wrapper — `appConfig('trails', ...)` with
|
|
3
|
-
* framework conventions for loadout selection and local overrides.
|
|
4
|
-
*/
|
|
5
|
-
import { existsSync } from 'node:fs';
|
|
6
|
-
import { join } from 'node:path';
|
|
7
|
-
import { appConfig } from './app-config.js';
|
|
8
|
-
import { resolveConfig } from './resolve.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Local overrides discovery
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
const LOCAL_OVERRIDE_CANDIDATES = ['local.ts', 'local.js'];
|
|
13
|
-
/**
|
|
14
|
-
* Discover and synchronously import a `.trails/config/local.{ts,js}` file.
|
|
15
|
-
*
|
|
16
|
-
* Skipped when `TRAILS_ENV=test` for hermetic test environments.
|
|
17
|
-
*/
|
|
18
|
-
const discoverLocalOverrides = async (cwd, envRecord) => {
|
|
19
|
-
if (envRecord['TRAILS_ENV'] === 'test') {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
for (const filename of LOCAL_OVERRIDE_CANDIDATES) {
|
|
23
|
-
const candidate = join(cwd, '.trails', 'config', filename);
|
|
24
|
-
if (existsSync(candidate)) {
|
|
25
|
-
const mod = await import(candidate);
|
|
26
|
-
return (mod['default'] ?? mod);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
};
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
// Public API
|
|
33
|
-
// ---------------------------------------------------------------------------
|
|
34
|
-
/**
|
|
35
|
-
* Define Trails app config.
|
|
36
|
-
*
|
|
37
|
-
* This is `appConfig('trails', ...)` with the framework's own conventions:
|
|
38
|
-
* `TRAILS_ENV` selects the loadout. When `envFromNodeEnv` is true,
|
|
39
|
-
* `NODE_ENV` is used as a fallback when `TRAILS_ENV` is unset.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* const config = defineConfig({
|
|
44
|
-
* schema: z.object({
|
|
45
|
-
* port: z.number().default(3000),
|
|
46
|
-
* debug: z.boolean().default(false),
|
|
47
|
-
* }),
|
|
48
|
-
* base: { port: 8080 },
|
|
49
|
-
* loadouts: {
|
|
50
|
-
* production: { debug: false },
|
|
51
|
-
* test: { debug: true, port: 0 },
|
|
52
|
-
* },
|
|
53
|
-
* });
|
|
54
|
-
*
|
|
55
|
-
* const result = config.resolve();
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export const defineConfig = (options) => {
|
|
59
|
-
const config = appConfig('trails', {
|
|
60
|
-
formats: ['toml', 'json'],
|
|
61
|
-
schema: options.schema,
|
|
62
|
-
});
|
|
63
|
-
return {
|
|
64
|
-
...config,
|
|
65
|
-
base: options.base,
|
|
66
|
-
loadouts: options.loadouts,
|
|
67
|
-
resolve: async (resolveOpts) => {
|
|
68
|
-
const envRecord = {
|
|
69
|
-
...(resolveOpts?.env ?? process.env),
|
|
70
|
-
};
|
|
71
|
-
if (options.envFromNodeEnv &&
|
|
72
|
-
envRecord['TRAILS_ENV'] === undefined &&
|
|
73
|
-
envRecord['NODE_ENV'] !== undefined) {
|
|
74
|
-
envRecord['TRAILS_ENV'] = envRecord['NODE_ENV'];
|
|
75
|
-
}
|
|
76
|
-
const cwd = resolveOpts?.cwd ?? process.cwd();
|
|
77
|
-
const localOverrides = await discoverLocalOverrides(cwd, envRecord);
|
|
78
|
-
return resolveConfig({
|
|
79
|
-
base: options.base,
|
|
80
|
-
env: envRecord,
|
|
81
|
-
loadout: resolveOpts?.loadout ?? envRecord['TRAILS_ENV'],
|
|
82
|
-
loadouts: options.loadouts,
|
|
83
|
-
localOverrides,
|
|
84
|
-
schema: options.schema,
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
schema: options.schema,
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
//# sourceMappingURL=define-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define-config.js","sourceRoot":"","sources":["../src/define-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EA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AO,CAAC,GAAG,CAAC;aACC,CAAC;YAExC,IACE,OAAO,CAAC,cAAc;gBACtB,SAAS,CAAC,YAAY,CAAC,KAAK,SAAS;gBACrC,SAAS,CAAC,UAAU,CAAC,KAAK,SAAS,EACnC,CAAC;gBACD,SAAS,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YAClD,CAAC;YAED,MAAM,GAAG,GAAG,WAAW,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAC9C,MAAM,cAAc,GAAG,MAAM,sBAAsB,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;YAEpE,OAAO,aAAa,CAAC;gBACnB,IAAI,EAAE,OAAO,CAAC,IAA2C;gBACzD,GAAG,EAAE,SAAS;gBACd,OAAO,EAAE,WAAW,EAAE,OAAO,IAAI,SAAS,CAAC,YAAY,CAAC;gBACxD,QAAQ,EAAE,OAAO,CAAC,QAEL;gBACb,cAAc;gBACd,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAC;QACL,CAAC;QACD,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/describe.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config introspection — describe all fields in a schema without values.
|
|
3
|
-
*
|
|
4
|
-
* Returns a structured catalog suitable for CLI rendering or agent inspection.
|
|
5
|
-
*/
|
|
6
|
-
import type { z } from 'zod';
|
|
7
|
-
/** Description of a single config field. */
|
|
8
|
-
export interface FieldDescription {
|
|
9
|
-
readonly path: string;
|
|
10
|
-
readonly type: string;
|
|
11
|
-
readonly description?: string;
|
|
12
|
-
readonly default?: unknown;
|
|
13
|
-
readonly required: boolean;
|
|
14
|
-
readonly env?: string;
|
|
15
|
-
readonly secret?: boolean;
|
|
16
|
-
readonly deprecated?: string;
|
|
17
|
-
readonly constraints?: Record<string, unknown>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Describe all fields in a schema without needing a config file.
|
|
21
|
-
*
|
|
22
|
-
* Returns a structured catalog suitable for CLI rendering or agent inspection.
|
|
23
|
-
*/
|
|
24
|
-
export declare const describeConfig: (schema: z.ZodObject<Record<string, z.ZodType>>) => readonly FieldDescription[];
|
|
25
|
-
//# sourceMappingURL=describe.d.ts.map
|
package/dist/describe.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAS7B,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChD;AAsMD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACzB,QAAQ,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,KAC7C,SAAS,gBAAgB,EAmB3B,CAAC"}
|
package/dist/describe.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config introspection — describe all fields in a schema without values.
|
|
3
|
-
*
|
|
4
|
-
* Returns a structured catalog suitable for CLI rendering or agent inspection.
|
|
5
|
-
*/
|
|
6
|
-
import { globalRegistry } from 'zod';
|
|
7
|
-
import { collectConfigMeta } from './collect.js';
|
|
8
|
-
import { isZodObject, unwrapToBase, zodDef } from './zod-utils.js';
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Helpers (defined before consumers — satisfies no-use-before-define)
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
/** Read the description from the Zod global registry. */
|
|
13
|
-
const getDescription = (schema) => {
|
|
14
|
-
const meta = globalRegistry.get(schema);
|
|
15
|
-
return meta?.description;
|
|
16
|
-
};
|
|
17
|
-
/** Handle a single unwrap step; returns updated inner type and state, or null to stop. */
|
|
18
|
-
const unwrapStep = (def, state) => {
|
|
19
|
-
const typeName = def['type'];
|
|
20
|
-
if (typeName === 'default') {
|
|
21
|
-
return {
|
|
22
|
-
inner: def['innerType'],
|
|
23
|
-
state: { ...state, defaultValue: def['defaultValue'], hasDefault: true },
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
if (typeName === 'optional') {
|
|
27
|
-
return {
|
|
28
|
-
inner: def['innerType'],
|
|
29
|
-
state: { ...state, isOptional: true },
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
if (typeName === 'nullable') {
|
|
33
|
-
return { inner: def['innerType'], state };
|
|
34
|
-
}
|
|
35
|
-
return null;
|
|
36
|
-
};
|
|
37
|
-
/** Unwrap through default/optional/nullable wrappers to find the base type. */
|
|
38
|
-
const unwrapSchema = (schema) => {
|
|
39
|
-
let current = schema;
|
|
40
|
-
let state = {
|
|
41
|
-
defaultValue: undefined,
|
|
42
|
-
hasDefault: false,
|
|
43
|
-
isOptional: false,
|
|
44
|
-
};
|
|
45
|
-
for (let depth = 0; depth < 10; depth += 1) {
|
|
46
|
-
const result = unwrapStep(zodDef(current), state);
|
|
47
|
-
if (!result) {
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
current = result.inner;
|
|
51
|
-
({ state } = result);
|
|
52
|
-
}
|
|
53
|
-
return { base: current, ...state };
|
|
54
|
-
};
|
|
55
|
-
/** Resolve the user-facing type name from a base Zod schema. */
|
|
56
|
-
const resolveTypeName = (schema) => {
|
|
57
|
-
const typeName = zodDef(schema)['type'];
|
|
58
|
-
const typeMap = {
|
|
59
|
-
boolean: 'boolean',
|
|
60
|
-
enum: 'enum',
|
|
61
|
-
number: 'number',
|
|
62
|
-
string: 'string',
|
|
63
|
-
};
|
|
64
|
-
return typeMap[typeName] ?? typeName;
|
|
65
|
-
};
|
|
66
|
-
/** Extract enum values from an enum def. */
|
|
67
|
-
const extractEnumConstraints = (def) => {
|
|
68
|
-
const entries = def['entries'];
|
|
69
|
-
if (!entries) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
return { values: Object.values(entries) };
|
|
73
|
-
};
|
|
74
|
-
/** Extract min/max from a number schema's properties. */
|
|
75
|
-
const extractNumberConstraints = (schema) => {
|
|
76
|
-
const result = {};
|
|
77
|
-
const numSchema = schema;
|
|
78
|
-
if (numSchema.minValue !== undefined && numSchema.minValue !== null) {
|
|
79
|
-
result['min'] = numSchema.minValue;
|
|
80
|
-
}
|
|
81
|
-
if (numSchema.maxValue !== undefined && numSchema.maxValue !== null) {
|
|
82
|
-
result['max'] = numSchema.maxValue;
|
|
83
|
-
}
|
|
84
|
-
return Object.keys(result).length > 0 ? result : undefined;
|
|
85
|
-
};
|
|
86
|
-
/** Extract constraints from a base schema (min, max, enum values). */
|
|
87
|
-
const extractConstraints = (schema) => {
|
|
88
|
-
const def = zodDef(schema);
|
|
89
|
-
const typeName = def['type'];
|
|
90
|
-
if (typeName === 'enum') {
|
|
91
|
-
return extractEnumConstraints(def);
|
|
92
|
-
}
|
|
93
|
-
if (typeName === 'number') {
|
|
94
|
-
return extractNumberConstraints(schema);
|
|
95
|
-
}
|
|
96
|
-
return undefined;
|
|
97
|
-
};
|
|
98
|
-
/** Build a single FieldDescription from a leaf schema and its metadata. */
|
|
99
|
-
const buildFieldDescription = (path, fieldSchema, configMeta) => {
|
|
100
|
-
const { base, defaultValue, hasDefault, isOptional } = unwrapSchema(fieldSchema);
|
|
101
|
-
const meta = configMeta.get(path);
|
|
102
|
-
const description = getDescription(base) ?? getDescription(fieldSchema);
|
|
103
|
-
const constraints = extractConstraints(base);
|
|
104
|
-
return {
|
|
105
|
-
...(constraints ? { constraints } : {}),
|
|
106
|
-
...(hasDefault ? { default: defaultValue } : {}),
|
|
107
|
-
...(meta?.deprecated ? { deprecated: meta.deprecated } : {}),
|
|
108
|
-
...(description ? { description } : {}),
|
|
109
|
-
...(meta?.env ? { env: meta.env } : {}),
|
|
110
|
-
path,
|
|
111
|
-
required: !hasDefault && !isOptional,
|
|
112
|
-
...(meta?.secret ? { secret: meta.secret } : {}),
|
|
113
|
-
type: resolveTypeName(base),
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
/** Walk one level of an object shape, collecting leaves and queuing nested objects. */
|
|
117
|
-
const walkShapeLevel = (shape, prefix, configMeta, results, queue) => {
|
|
118
|
-
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
119
|
-
const path = prefix ? `${prefix}.${key}` : key;
|
|
120
|
-
if (isZodObject(fieldSchema)) {
|
|
121
|
-
queue.push({ prefix: path, schema: unwrapToBase(fieldSchema) });
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
results.push(buildFieldDescription(path, fieldSchema, configMeta));
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
// ---------------------------------------------------------------------------
|
|
129
|
-
// Public API
|
|
130
|
-
// ---------------------------------------------------------------------------
|
|
131
|
-
/**
|
|
132
|
-
* Describe all fields in a schema without needing a config file.
|
|
133
|
-
*
|
|
134
|
-
* Returns a structured catalog suitable for CLI rendering or agent inspection.
|
|
135
|
-
*/
|
|
136
|
-
export const describeConfig = (schema) => {
|
|
137
|
-
const configMeta = collectConfigMeta(schema);
|
|
138
|
-
const queue = [];
|
|
139
|
-
const results = [];
|
|
140
|
-
walkShapeLevel(schema.shape, '', configMeta, results, queue);
|
|
141
|
-
for (let entry = queue.pop(); entry; entry = queue.pop()) {
|
|
142
|
-
const nested = zodDef(entry.schema)['shape'];
|
|
143
|
-
walkShapeLevel(nested, entry.prefix, configMeta, results, queue);
|
|
144
|
-
}
|
|
145
|
-
return results;
|
|
146
|
-
};
|
|
147
|
-
//# sourceMappingURL=describe.js.map
|
package/dist/describe.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../src/describe.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAkCnE,8EAA8E;AAC9E,sEAAsE;AACtE,8EAA8E;AAE9E,yDAAyD;AACzD,MAAM,cAAc,GAAG,CAAC,MAAiB,EAAsB,EAAE;IAC/D,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,IAAI,EAAE,WAAiC,CAAC;AACjD,CAAC,CAAC;AAEF,0FAA0F;AAC1F,MAAM,UAAU,GAAG,CACjB,GAA4B,EAC5B,KAAkB,EAC+B,EAAE;IACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAW,CAAC;IAEvC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO;YACL,KAAK,EAAE,GAAG,CAAC,WAAW,CAAc;YACpC,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,YAAY,EAAE,GAAG,CAAC,cAAc,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE;SACzE,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC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AC,GAAG,EAAE,EAAE,CAAC;QACzD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAA8B,CAAC;QAC1E,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/dist/doctor.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Config doctor — structured diagnostics for a config object against a schema.
|
|
3
|
-
*
|
|
4
|
-
* Reports which fields are valid, missing, using defaults, deprecated, or invalid.
|
|
5
|
-
*/
|
|
6
|
-
import type { z } from 'zod';
|
|
7
|
-
/** Diagnostic status for a single config field. */
|
|
8
|
-
export interface ConfigDiagnostic {
|
|
9
|
-
readonly path: string;
|
|
10
|
-
readonly status: 'valid' | 'missing' | 'invalid' | 'deprecated' | 'default';
|
|
11
|
-
readonly message: string;
|
|
12
|
-
readonly value?: unknown;
|
|
13
|
-
}
|
|
14
|
-
/** Aggregated result from checking config against a schema. */
|
|
15
|
-
export interface CheckResult {
|
|
16
|
-
readonly diagnostics: readonly ConfigDiagnostic[];
|
|
17
|
-
readonly valid: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Check a config object against a schema and return structured diagnostics.
|
|
21
|
-
*
|
|
22
|
-
* Reports which fields are valid, missing, using defaults, deprecated, or invalid.
|
|
23
|
-
*/
|
|
24
|
-
export declare const checkConfig: <T extends z.ZodType>(schema: T, values: Record<string, unknown>, options?: {
|
|
25
|
-
readonly env?: Record<string, string | undefined>;
|
|
26
|
-
}) => CheckResult;
|
|
27
|
-
//# sourceMappingURL=doctor.d.ts.map
|
package/dist/doctor.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|