@ontrails/config 1.0.0-beta.12 → 1.0.0-beta.13
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 +33 -5
- package/package.json +1 -1
- package/src/__tests__/compose.test.ts +15 -15
- package/src/__tests__/config-check.test.ts +15 -15
- package/src/__tests__/config-describe.test.ts +15 -15
- package/src/__tests__/config-explain.test.ts +15 -15
- package/src/__tests__/{config-layer.test.ts → config-gate.test.ts} +9 -9
- package/src/__tests__/config-init.test.ts +19 -19
- package/src/__tests__/{config-service.test.ts → config-provision.test.ts} +13 -13
- package/src/compose.ts +22 -16
- package/src/config-gate.ts +15 -0
- package/src/{config-service.ts → config-provision.ts} +6 -6
- package/src/explain.ts +6 -6
- package/src/extensions.ts +1 -1
- package/src/index.ts +8 -3
- package/src/registry.ts +1 -1
- package/src/trails/config-check.ts +12 -12
- package/src/trails/config-describe.ts +8 -8
- package/src/trails/config-explain.ts +12 -12
- package/src/trails/config-init.ts +15 -15
- package/src/config-layer.ts +0 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
# @ontrails/config
|
|
2
2
|
|
|
3
|
-
## 1.0.0-beta.
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
- Complete trifecta for config, permits, and
|
|
7
|
+
- 6944147: Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
8
8
|
|
|
9
|
-
- **config**: Add `
|
|
9
|
+
- **config**: Add `configProvision`, `configGate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
10
10
|
- **permits**: Add `authService` and `auth.verify` trail for runtime authorization checks
|
|
11
|
-
- **
|
|
11
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured signal tracking
|
|
12
|
+
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
13
|
+
- **testing**: Expand test context helpers and example-based testing utilities
|
|
14
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
15
|
+
|
|
16
|
+
- Trail-native vocabulary cutover. Breaking API field renames across all packages:
|
|
17
|
+
|
|
18
|
+
- Trail spec: `run:` → `blaze:`, `follow:` → `crosses:`, `services:` → `provisions:`, `metadata:` → `meta:`, `emits:` → `signals:`
|
|
19
|
+
- Runtime: `ctx.follow()` → `ctx.cross()`, `ctx.emit()` → `ctx.signal()`, `ctx.signal` (abort) → `ctx.abortSignal`
|
|
20
|
+
- Entry points: `blaze(app)` → `trailhead(app)`
|
|
21
|
+
- Package rename: `@ontrails/crumbs` → `@ontrails/tracker`
|
|
22
|
+
- Wrapper types: `Layer` → `Gate`, `layers`/`middleware` → `gates`
|
|
23
|
+
- Transport: `surface` → `trailhead`, `adapter` → `connector`
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [6944147]
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @ontrails/core@1.0.0-beta.13
|
|
30
|
+
|
|
31
|
+
## 1.0.0-beta.12
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- Complete trifecta for config, permits, and tracker (formerly tracks)
|
|
36
|
+
|
|
37
|
+
- **config**: Add `configProvision`, `config.gate`, `config.trail`, and `config.workspace` trails with full `defineConfig`, `resolve`, `describe`, `explain`, `doctor`, and code generation support
|
|
38
|
+
- **permits**: Add `authProvision` and `auth.verify` trail for runtime authorization checks
|
|
39
|
+
- **tracker**: Rename tracks to tracker; add `trackerProvision` and `tracker.status` trail for structured event tracking
|
|
12
40
|
- **cli**: Fix build flag handling and improve bootstrap scaffolding
|
|
13
41
|
- **testing**: Expand test context helpers and example-based testing utilities
|
|
14
|
-
- **core/mcp/http**: Internal alignment for
|
|
42
|
+
- **core/mcp/http**: Internal alignment for provision and composition updates
|
|
15
43
|
|
|
16
44
|
### Patch Changes
|
|
17
45
|
|
package/package.json
CHANGED
|
@@ -2,57 +2,57 @@ import { describe, expect, test } from 'bun:test';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { collectProvisionConfigs } from '../compose.js';
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// Tests
|
|
9
9
|
// ---------------------------------------------------------------------------
|
|
10
10
|
|
|
11
|
-
describe('
|
|
12
|
-
test('extracts config schemas from
|
|
11
|
+
describe('collectProvisionConfigs', () => {
|
|
12
|
+
test('extracts config schemas from provisions that declare them', () => {
|
|
13
13
|
const dbSchema = z.object({ url: z.string().url() });
|
|
14
14
|
const cacheSchema = z.object({ ttl: z.number() });
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const provisions = [
|
|
17
17
|
{ config: dbSchema, id: 'db.main' },
|
|
18
18
|
{ config: cacheSchema, id: 'cache.main' },
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
const entries =
|
|
21
|
+
const entries = collectProvisionConfigs(provisions);
|
|
22
22
|
|
|
23
23
|
expect(entries).toHaveLength(2);
|
|
24
|
-
expect(entries[0]).toEqual({
|
|
24
|
+
expect(entries[0]).toEqual({ provisionId: 'db.main', schema: dbSchema });
|
|
25
25
|
expect(entries[1]).toEqual({
|
|
26
|
+
provisionId: 'cache.main',
|
|
26
27
|
schema: cacheSchema,
|
|
27
|
-
serviceId: 'cache.main',
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
test('excludes
|
|
31
|
+
test('excludes provisions without config', () => {
|
|
32
32
|
const schema = z.object({ url: z.string() });
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const provisions = [
|
|
35
35
|
{ config: schema, id: 'db.main' },
|
|
36
36
|
{ id: 'counter.main' },
|
|
37
37
|
{ config: undefined, id: 'logger.main' },
|
|
38
38
|
];
|
|
39
39
|
|
|
40
|
-
const entries =
|
|
40
|
+
const entries = collectProvisionConfigs(provisions);
|
|
41
41
|
|
|
42
42
|
expect(entries).toHaveLength(1);
|
|
43
|
-
expect(entries[0]?.
|
|
43
|
+
expect(entries[0]?.provisionId).toBe('db.main');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
test('returns empty array when no
|
|
47
|
-
const
|
|
46
|
+
test('returns empty array when no provisions have config', () => {
|
|
47
|
+
const provisions = [{ id: 'counter.main' }, { id: 'logger.main' }];
|
|
48
48
|
|
|
49
|
-
const entries =
|
|
49
|
+
const entries = collectProvisionConfigs(provisions);
|
|
50
50
|
|
|
51
51
|
expect(entries).toEqual([]);
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
test('returns empty array for empty input', () => {
|
|
55
|
-
const entries =
|
|
55
|
+
const entries = collectProvisionConfigs([]);
|
|
56
56
|
|
|
57
57
|
expect(entries).toEqual([]);
|
|
58
58
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { createProvisionLookup } from '@ontrails/core';
|
|
3
3
|
import type { TrailContext } from '@ontrails/core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -7,22 +7,22 @@ import { configCheck } from '../trails/config-check.js';
|
|
|
7
7
|
import type { ConfigState } from '../registry.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Build a TrailContext with
|
|
10
|
+
* Build a TrailContext with configProvision resolved in extensions.
|
|
11
11
|
*/
|
|
12
12
|
const buildCtx = (state: ConfigState): TrailContext => {
|
|
13
13
|
const extensions = { config: state };
|
|
14
14
|
const ctx: TrailContext = {
|
|
15
|
+
abortSignal: AbortSignal.timeout(5000),
|
|
15
16
|
cwd: '/tmp',
|
|
16
17
|
env: {},
|
|
17
18
|
extensions,
|
|
19
|
+
provision: undefined as unknown as TrailContext['provision'],
|
|
18
20
|
requestId: 'test',
|
|
19
|
-
service: undefined as unknown as TrailContext['service'],
|
|
20
|
-
signal: AbortSignal.timeout(5000),
|
|
21
21
|
workspaceRoot: '/tmp',
|
|
22
22
|
};
|
|
23
23
|
const withLookup = {
|
|
24
24
|
...ctx,
|
|
25
|
-
|
|
25
|
+
provision: createProvisionLookup(() => withLookup),
|
|
26
26
|
};
|
|
27
27
|
return withLookup;
|
|
28
28
|
};
|
|
@@ -41,17 +41,17 @@ describe('config.check trail', () => {
|
|
|
41
41
|
expect(configCheck.intent).toBe('read');
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
test('has infrastructure
|
|
45
|
-
expect(configCheck.
|
|
44
|
+
test('has infrastructure meta', () => {
|
|
45
|
+
expect(configCheck.meta).toEqual({ category: 'infrastructure' });
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
test('has output schema', () => {
|
|
49
49
|
expect(configCheck.output).toBeDefined();
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
test('declares
|
|
53
|
-
expect(configCheck.
|
|
54
|
-
expect(configCheck.
|
|
52
|
+
test('declares configProvision dependency', () => {
|
|
53
|
+
expect(configCheck.provisions).toBeDefined();
|
|
54
|
+
expect(configCheck.provisions?.length).toBe(1);
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -72,7 +72,7 @@ describe('config.check trail', () => {
|
|
|
72
72
|
schema,
|
|
73
73
|
};
|
|
74
74
|
const ctx = buildCtx(state);
|
|
75
|
-
const result = await configCheck.
|
|
75
|
+
const result = await configCheck.blaze({ values: {} }, ctx);
|
|
76
76
|
|
|
77
77
|
expect(result.isOk()).toBe(true);
|
|
78
78
|
const value = result.unwrap();
|
|
@@ -90,7 +90,7 @@ describe('config.check trail', () => {
|
|
|
90
90
|
schema,
|
|
91
91
|
};
|
|
92
92
|
const ctx = buildCtx(state);
|
|
93
|
-
const result = await configCheck.
|
|
93
|
+
const result = await configCheck.blaze({ values: {} }, ctx);
|
|
94
94
|
|
|
95
95
|
expect(result.isOk()).toBe(true);
|
|
96
96
|
const value = result.unwrap();
|
|
@@ -108,7 +108,7 @@ describe('config.check trail', () => {
|
|
|
108
108
|
schema,
|
|
109
109
|
};
|
|
110
110
|
const ctx = buildCtx(state);
|
|
111
|
-
const result = await configCheck.
|
|
111
|
+
const result = await configCheck.blaze({ values: { port: 8080 } }, ctx);
|
|
112
112
|
|
|
113
113
|
expect(result.isOk()).toBe(true);
|
|
114
114
|
const value = result.unwrap();
|
|
@@ -129,7 +129,7 @@ describe('config.check trail', () => {
|
|
|
129
129
|
schema,
|
|
130
130
|
};
|
|
131
131
|
const ctx = buildCtx(state);
|
|
132
|
-
const result = await configCheck.
|
|
132
|
+
const result = await configCheck.blaze(
|
|
133
133
|
{ values: { db: { port: 6543 } } },
|
|
134
134
|
ctx
|
|
135
135
|
);
|
|
@@ -159,7 +159,7 @@ describe('config.check trail', () => {
|
|
|
159
159
|
schema,
|
|
160
160
|
};
|
|
161
161
|
const ctx = buildCtx(state);
|
|
162
|
-
const result = await configCheck.
|
|
162
|
+
const result = await configCheck.blaze({ values: {} }, ctx);
|
|
163
163
|
|
|
164
164
|
expect(result.isOk()).toBe(true);
|
|
165
165
|
const defaults = result
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { createProvisionLookup } from '@ontrails/core';
|
|
3
3
|
import type { TrailContext } from '@ontrails/core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -8,22 +8,22 @@ import { env, secret } from '../extensions.js';
|
|
|
8
8
|
import type { ConfigState } from '../registry.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Build a TrailContext with
|
|
11
|
+
* Build a TrailContext with configProvision resolved in extensions.
|
|
12
12
|
*/
|
|
13
13
|
const buildCtx = (state: ConfigState): TrailContext => {
|
|
14
14
|
const extensions = { config: state };
|
|
15
15
|
const ctx: TrailContext = {
|
|
16
|
+
abortSignal: AbortSignal.timeout(5000),
|
|
16
17
|
cwd: '/tmp',
|
|
17
18
|
env: {},
|
|
18
19
|
extensions,
|
|
20
|
+
provision: undefined as unknown as TrailContext['provision'],
|
|
19
21
|
requestId: 'test',
|
|
20
|
-
service: undefined as unknown as TrailContext['service'],
|
|
21
|
-
signal: AbortSignal.timeout(5000),
|
|
22
22
|
workspaceRoot: '/tmp',
|
|
23
23
|
};
|
|
24
24
|
const withLookup = {
|
|
25
25
|
...ctx,
|
|
26
|
-
|
|
26
|
+
provision: createProvisionLookup(() => withLookup),
|
|
27
27
|
};
|
|
28
28
|
return withLookup;
|
|
29
29
|
};
|
|
@@ -42,17 +42,17 @@ describe('config.describe trail', () => {
|
|
|
42
42
|
expect(configDescribe.intent).toBe('read');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
test('has infrastructure
|
|
46
|
-
expect(configDescribe.
|
|
45
|
+
test('has infrastructure meta', () => {
|
|
46
|
+
expect(configDescribe.meta).toEqual({ category: 'infrastructure' });
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
test('has output schema', () => {
|
|
50
50
|
expect(configDescribe.output).toBeDefined();
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
test('declares
|
|
54
|
-
expect(configDescribe.
|
|
55
|
-
expect(configDescribe.
|
|
53
|
+
test('declares configProvision dependency', () => {
|
|
54
|
+
expect(configDescribe.provisions).toBeDefined();
|
|
55
|
+
expect(configDescribe.provisions?.length).toBe(1);
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -73,7 +73,7 @@ describe('config.describe trail', () => {
|
|
|
73
73
|
schema,
|
|
74
74
|
};
|
|
75
75
|
const ctx = buildCtx(state);
|
|
76
|
-
const result = await configDescribe.
|
|
76
|
+
const result = await configDescribe.blaze({}, ctx);
|
|
77
77
|
|
|
78
78
|
expect(result.isOk()).toBe(true);
|
|
79
79
|
expect(result.unwrap().fields.length).toBe(2);
|
|
@@ -89,7 +89,7 @@ describe('config.describe trail', () => {
|
|
|
89
89
|
schema,
|
|
90
90
|
};
|
|
91
91
|
const ctx = buildCtx(state);
|
|
92
|
-
const result = await configDescribe.
|
|
92
|
+
const result = await configDescribe.blaze({}, ctx);
|
|
93
93
|
const { fields } = result.unwrap();
|
|
94
94
|
|
|
95
95
|
expect(fields[0]?.path).toBe('host');
|
|
@@ -107,7 +107,7 @@ describe('config.describe trail', () => {
|
|
|
107
107
|
schema,
|
|
108
108
|
};
|
|
109
109
|
const ctx = buildCtx(state);
|
|
110
|
-
const result = await configDescribe.
|
|
110
|
+
const result = await configDescribe.blaze({}, ctx);
|
|
111
111
|
|
|
112
112
|
expect(result.isOk()).toBe(true);
|
|
113
113
|
const [field] = result.unwrap().fields;
|
|
@@ -123,7 +123,7 @@ describe('config.describe trail', () => {
|
|
|
123
123
|
schema,
|
|
124
124
|
};
|
|
125
125
|
const ctx = buildCtx(state);
|
|
126
|
-
const result = await configDescribe.
|
|
126
|
+
const result = await configDescribe.blaze({}, ctx);
|
|
127
127
|
|
|
128
128
|
expect(result.isOk()).toBe(true);
|
|
129
129
|
const [field] = result.unwrap().fields;
|
|
@@ -141,7 +141,7 @@ describe('config.describe trail', () => {
|
|
|
141
141
|
schema,
|
|
142
142
|
};
|
|
143
143
|
const ctx = buildCtx(state);
|
|
144
|
-
const result = await configDescribe.
|
|
144
|
+
const result = await configDescribe.blaze({}, ctx);
|
|
145
145
|
|
|
146
146
|
expect(result.isOk()).toBe(true);
|
|
147
147
|
const { fields } = result.unwrap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from 'bun:test';
|
|
2
|
-
import {
|
|
2
|
+
import { createProvisionLookup } from '@ontrails/core';
|
|
3
3
|
import type { TrailContext } from '@ontrails/core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -8,22 +8,22 @@ import { env } from '../extensions.js';
|
|
|
8
8
|
import type { ConfigState } from '../registry.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Build a TrailContext with
|
|
11
|
+
* Build a TrailContext with configProvision resolved in extensions.
|
|
12
12
|
*/
|
|
13
13
|
const buildCtx = (state: ConfigState): TrailContext => {
|
|
14
14
|
const extensions = { config: state };
|
|
15
15
|
const ctx: TrailContext = {
|
|
16
|
+
abortSignal: AbortSignal.timeout(5000),
|
|
16
17
|
cwd: '/tmp',
|
|
17
18
|
env: {},
|
|
18
19
|
extensions,
|
|
20
|
+
provision: undefined as unknown as TrailContext['provision'],
|
|
19
21
|
requestId: 'test',
|
|
20
|
-
service: undefined as unknown as TrailContext['service'],
|
|
21
|
-
signal: AbortSignal.timeout(5000),
|
|
22
22
|
workspaceRoot: '/tmp',
|
|
23
23
|
};
|
|
24
24
|
const withLookup = {
|
|
25
25
|
...ctx,
|
|
26
|
-
|
|
26
|
+
provision: createProvisionLookup(() => withLookup),
|
|
27
27
|
};
|
|
28
28
|
return withLookup;
|
|
29
29
|
};
|
|
@@ -42,17 +42,17 @@ describe('config.explain trail', () => {
|
|
|
42
42
|
expect(configExplain.intent).toBe('read');
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
test('has infrastructure
|
|
46
|
-
expect(configExplain.
|
|
45
|
+
test('has infrastructure meta', () => {
|
|
46
|
+
expect(configExplain.meta).toEqual({ category: 'infrastructure' });
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
test('has output schema', () => {
|
|
50
50
|
expect(configExplain.output).toBeDefined();
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
test('declares
|
|
54
|
-
expect(configExplain.
|
|
55
|
-
expect(configExplain.
|
|
53
|
+
test('declares configProvision dependency', () => {
|
|
54
|
+
expect(configExplain.provisions).toBeDefined();
|
|
55
|
+
expect(configExplain.provisions?.length).toBe(1);
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
@@ -73,7 +73,7 @@ describe('config.explain trail', () => {
|
|
|
73
73
|
schema,
|
|
74
74
|
};
|
|
75
75
|
const ctx = buildCtx(state);
|
|
76
|
-
const result = await configExplain.
|
|
76
|
+
const result = await configExplain.blaze({ path: '' }, ctx);
|
|
77
77
|
|
|
78
78
|
expect(result.isOk()).toBe(true);
|
|
79
79
|
const value = result.unwrap();
|
|
@@ -96,7 +96,7 @@ describe('config.explain trail', () => {
|
|
|
96
96
|
schema,
|
|
97
97
|
};
|
|
98
98
|
const ctx = buildCtx(state);
|
|
99
|
-
const result = await configExplain.
|
|
99
|
+
const result = await configExplain.blaze({ path: 'db' }, ctx);
|
|
100
100
|
|
|
101
101
|
expect(result.isOk()).toBe(true);
|
|
102
102
|
const value = result.unwrap();
|
|
@@ -121,7 +121,7 @@ describe('config.explain trail', () => {
|
|
|
121
121
|
schema,
|
|
122
122
|
};
|
|
123
123
|
const ctx = buildCtx(state);
|
|
124
|
-
const result = await configExplain.
|
|
124
|
+
const result = await configExplain.blaze({ path: 'db' }, ctx);
|
|
125
125
|
|
|
126
126
|
expect(result.isOk()).toBe(true);
|
|
127
127
|
expect(result.unwrap().entries).toEqual([
|
|
@@ -139,7 +139,7 @@ describe('config.explain trail', () => {
|
|
|
139
139
|
schema,
|
|
140
140
|
};
|
|
141
141
|
const ctx = buildCtx(state);
|
|
142
|
-
const result = await configExplain.
|
|
142
|
+
const result = await configExplain.blaze({ path: '' }, ctx);
|
|
143
143
|
|
|
144
144
|
expect(result.isOk()).toBe(true);
|
|
145
145
|
const [entry] = result.unwrap().entries;
|
|
@@ -157,7 +157,7 @@ describe('config.explain trail', () => {
|
|
|
157
157
|
schema,
|
|
158
158
|
};
|
|
159
159
|
const ctx = buildCtx(state);
|
|
160
|
-
const result = await configExplain.
|
|
160
|
+
const result = await configExplain.blaze({ path: '' }, ctx);
|
|
161
161
|
|
|
162
162
|
expect(result.isOk()).toBe(true);
|
|
163
163
|
const [entry] = result.unwrap().entries;
|
|
@@ -3,33 +3,33 @@ import { Result } from '@ontrails/core';
|
|
|
3
3
|
import type { TrailContext } from '@ontrails/core';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { configGate } from '../config-gate.js';
|
|
7
7
|
|
|
8
8
|
const stubTrail = {
|
|
9
|
+
blaze: (_input: unknown, _ctx: TrailContext) => Result.ok({}),
|
|
10
|
+
crosses: [],
|
|
9
11
|
description: undefined,
|
|
10
12
|
detours: undefined,
|
|
11
13
|
examples: undefined,
|
|
12
14
|
fields: undefined,
|
|
13
|
-
follow: [],
|
|
14
15
|
id: 'test.stub',
|
|
15
16
|
idempotent: undefined,
|
|
16
17
|
input: z.object({}),
|
|
17
18
|
intent: 'read' as const,
|
|
18
19
|
kind: 'trail' as const,
|
|
19
|
-
|
|
20
|
+
meta: undefined,
|
|
20
21
|
output: undefined,
|
|
21
|
-
|
|
22
|
-
services: [],
|
|
22
|
+
provisions: [],
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
describe('
|
|
25
|
+
describe('configGate', () => {
|
|
26
26
|
describe('identity', () => {
|
|
27
27
|
test('has name "config"', () => {
|
|
28
|
-
expect(
|
|
28
|
+
expect(configGate.name).toBe('config');
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
test('has a description', () => {
|
|
32
|
-
expect(
|
|
32
|
+
expect(configGate.description).toBeDefined();
|
|
33
33
|
});
|
|
34
34
|
});
|
|
35
35
|
|
|
@@ -38,7 +38,7 @@ describe('configLayer', () => {
|
|
|
38
38
|
const impl = (_input: unknown, _ctx: TrailContext) =>
|
|
39
39
|
Result.ok({ called: true });
|
|
40
40
|
|
|
41
|
-
const wrapped =
|
|
41
|
+
const wrapped = configGate.wrap(stubTrail, impl);
|
|
42
42
|
const ctx = {
|
|
43
43
|
cwd: '/tmp',
|
|
44
44
|
env: {},
|
|
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
|
2
2
|
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import {
|
|
5
|
+
import { createProvisionLookup } from '@ontrails/core';
|
|
6
6
|
import type { TrailContext } from '@ontrails/core';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
|
|
@@ -11,22 +11,22 @@ import type { ConfigState } from '../registry.js';
|
|
|
11
11
|
import { configInit } from '../trails/config-init.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* Build a TrailContext with
|
|
14
|
+
* Build a TrailContext with configProvision resolved in extensions.
|
|
15
15
|
*/
|
|
16
16
|
const buildCtx = (state: ConfigState): TrailContext => {
|
|
17
17
|
const extensions = { config: state };
|
|
18
18
|
const ctx: TrailContext = {
|
|
19
|
+
abortSignal: AbortSignal.timeout(5000),
|
|
19
20
|
cwd: '/tmp',
|
|
20
21
|
env: {},
|
|
21
22
|
extensions,
|
|
23
|
+
provision: undefined as unknown as TrailContext['provision'],
|
|
22
24
|
requestId: 'test',
|
|
23
|
-
service: undefined as unknown as TrailContext['service'],
|
|
24
|
-
signal: AbortSignal.timeout(5000),
|
|
25
25
|
workspaceRoot: '/tmp',
|
|
26
26
|
};
|
|
27
27
|
const withLookup = {
|
|
28
28
|
...ctx,
|
|
29
|
-
|
|
29
|
+
provision: createProvisionLookup(() => withLookup),
|
|
30
30
|
};
|
|
31
31
|
return withLookup;
|
|
32
32
|
};
|
|
@@ -55,17 +55,17 @@ describe('config.init trail', () => {
|
|
|
55
55
|
expect(configInit.intent).toBe('write');
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
test('has infrastructure
|
|
59
|
-
expect(configInit.
|
|
58
|
+
test('has infrastructure meta', () => {
|
|
59
|
+
expect(configInit.meta).toEqual({ category: 'infrastructure' });
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
test('has output schema', () => {
|
|
63
63
|
expect(configInit.output).toBeDefined();
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
test('declares
|
|
67
|
-
expect(configInit.
|
|
68
|
-
expect(configInit.
|
|
66
|
+
test('declares configProvision dependency', () => {
|
|
67
|
+
expect(configInit.provisions).toBeDefined();
|
|
68
|
+
expect(configInit.provisions?.length).toBe(1);
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
|
|
@@ -78,7 +78,7 @@ describe('config.init trail', () => {
|
|
|
78
78
|
describe('wired behavior', () => {
|
|
79
79
|
test('generates TOML output by default', async () => {
|
|
80
80
|
const ctx = buildCtx(testState);
|
|
81
|
-
const result = await configInit.
|
|
81
|
+
const result = await configInit.blaze({ format: 'toml' }, ctx);
|
|
82
82
|
|
|
83
83
|
expect(result.isOk()).toBe(true);
|
|
84
84
|
const value = result.unwrap();
|
|
@@ -90,7 +90,7 @@ describe('config.init trail', () => {
|
|
|
90
90
|
|
|
91
91
|
test('generates JSON output when requested', async () => {
|
|
92
92
|
const ctx = buildCtx(testState);
|
|
93
|
-
const result = await configInit.
|
|
93
|
+
const result = await configInit.blaze({ format: 'json' }, ctx);
|
|
94
94
|
|
|
95
95
|
expect(result.isOk()).toBe(true);
|
|
96
96
|
const value = result.unwrap();
|
|
@@ -101,7 +101,7 @@ describe('config.init trail', () => {
|
|
|
101
101
|
|
|
102
102
|
test('generates YAML output when requested', async () => {
|
|
103
103
|
const ctx = buildCtx(testState);
|
|
104
|
-
const result = await configInit.
|
|
104
|
+
const result = await configInit.blaze({ format: 'yaml' }, ctx);
|
|
105
105
|
|
|
106
106
|
expect(result.isOk()).toBe(true);
|
|
107
107
|
const value = result.unwrap();
|
|
@@ -111,7 +111,7 @@ describe('config.init trail', () => {
|
|
|
111
111
|
|
|
112
112
|
test('generates JSONC output when requested', async () => {
|
|
113
113
|
const ctx = buildCtx(testState);
|
|
114
|
-
const result = await configInit.
|
|
114
|
+
const result = await configInit.blaze({ format: 'jsonc' }, ctx);
|
|
115
115
|
|
|
116
116
|
expect(result.isOk()).toBe(true);
|
|
117
117
|
const value = result.unwrap();
|
|
@@ -121,7 +121,7 @@ describe('config.init trail', () => {
|
|
|
121
121
|
|
|
122
122
|
test('output content is non-empty for schema with fields', async () => {
|
|
123
123
|
const ctx = buildCtx(testState);
|
|
124
|
-
const result = await configInit.
|
|
124
|
+
const result = await configInit.blaze({ format: 'toml' }, ctx);
|
|
125
125
|
|
|
126
126
|
expect(result.isOk()).toBe(true);
|
|
127
127
|
expect(result.unwrap().content.trim().length).toBeGreaterThan(0);
|
|
@@ -129,7 +129,7 @@ describe('config.init trail', () => {
|
|
|
129
129
|
|
|
130
130
|
test('returns content without writtenFiles when dir is not provided', async () => {
|
|
131
131
|
const ctx = buildCtx(testState);
|
|
132
|
-
const result = await configInit.
|
|
132
|
+
const result = await configInit.blaze({ format: 'toml' }, ctx);
|
|
133
133
|
|
|
134
134
|
expect(result.isOk()).toBe(true);
|
|
135
135
|
expect(result.unwrap().writtenFiles).toBeUndefined();
|
|
@@ -159,7 +159,7 @@ describe('config.init trail', () => {
|
|
|
159
159
|
|
|
160
160
|
test('writes .schema.json when dir is provided', async () => {
|
|
161
161
|
const ctx = buildCtx(envState);
|
|
162
|
-
const result = await configInit.
|
|
162
|
+
const result = await configInit.blaze(
|
|
163
163
|
{ dir: tempDir, format: 'toml' },
|
|
164
164
|
ctx
|
|
165
165
|
);
|
|
@@ -181,7 +181,7 @@ describe('config.init trail', () => {
|
|
|
181
181
|
|
|
182
182
|
test('writes .env.example when schema has env bindings', async () => {
|
|
183
183
|
const ctx = buildCtx(envState);
|
|
184
|
-
const result = await configInit.
|
|
184
|
+
const result = await configInit.blaze(
|
|
185
185
|
{ dir: tempDir, format: 'toml' },
|
|
186
186
|
ctx
|
|
187
187
|
);
|
|
@@ -196,7 +196,7 @@ describe('config.init trail', () => {
|
|
|
196
196
|
|
|
197
197
|
test('still returns content alongside written files', async () => {
|
|
198
198
|
const ctx = buildCtx(envState);
|
|
199
|
-
const result = await configInit.
|
|
199
|
+
const result = await configInit.blaze(
|
|
200
200
|
{ dir: tempDir, format: 'json' },
|
|
201
201
|
ctx
|
|
202
202
|
);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { afterEach, describe, expect, test } from 'bun:test';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { configProvision } from '../config-provision.js';
|
|
5
5
|
import type { ConfigState } from '../registry.js';
|
|
6
6
|
import { clearConfigState, registerConfigState } from '../registry.js';
|
|
7
7
|
|
|
8
|
-
/** Stub
|
|
8
|
+
/** Stub ProvisionContext for create calls. */
|
|
9
9
|
const stubSvcCtx = {
|
|
10
10
|
config: undefined,
|
|
11
11
|
cwd: '/tmp',
|
|
@@ -13,32 +13,32 @@ const stubSvcCtx = {
|
|
|
13
13
|
workspaceRoot: '/tmp',
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
describe('
|
|
16
|
+
describe('configProvision', () => {
|
|
17
17
|
afterEach(() => {
|
|
18
18
|
clearConfigState();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
describe('identity', () => {
|
|
22
22
|
test('has id "config"', () => {
|
|
23
|
-
expect(
|
|
23
|
+
expect(configProvision.id).toBe('config');
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
test('has kind "
|
|
27
|
-
expect(
|
|
26
|
+
test('has kind "provision"', () => {
|
|
27
|
+
expect(configProvision.kind).toBe('provision');
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
test('has infrastructure
|
|
31
|
-
expect(
|
|
30
|
+
test('has infrastructure meta', () => {
|
|
31
|
+
expect(configProvision.meta).toEqual({ category: 'infrastructure' });
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
test('has description', () => {
|
|
35
|
-
expect(
|
|
35
|
+
expect(configProvision.description).toBeDefined();
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
describe('mock', () => {
|
|
40
40
|
test('returns a ConfigState with empty schema and resolved', () => {
|
|
41
|
-
const value =
|
|
41
|
+
const value = configProvision.mock?.() as ConfigState;
|
|
42
42
|
expect(value).toBeDefined();
|
|
43
43
|
expect(value.resolved).toEqual({});
|
|
44
44
|
expect(value.schema).toBeDefined();
|
|
@@ -51,7 +51,7 @@ describe('configService', () => {
|
|
|
51
51
|
const state: ConfigState = { resolved: { port: 3000 }, schema };
|
|
52
52
|
registerConfigState(state);
|
|
53
53
|
|
|
54
|
-
const result = await
|
|
54
|
+
const result = await configProvision.create(stubSvcCtx);
|
|
55
55
|
|
|
56
56
|
expect(result.isOk()).toBe(true);
|
|
57
57
|
const value = result.unwrap() as ConfigState;
|
|
@@ -69,7 +69,7 @@ describe('configService', () => {
|
|
|
69
69
|
};
|
|
70
70
|
registerConfigState(state);
|
|
71
71
|
|
|
72
|
-
const result = await
|
|
72
|
+
const result = await configProvision.create(stubSvcCtx);
|
|
73
73
|
|
|
74
74
|
expect(result.isOk()).toBe(true);
|
|
75
75
|
const value = result.unwrap() as ConfigState;
|
|
@@ -78,7 +78,7 @@ describe('configService', () => {
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
test('returns Result.err when no state is registered', async () => {
|
|
81
|
-
const result = await
|
|
81
|
+
const result = await configProvision.create(stubSvcCtx);
|
|
82
82
|
|
|
83
83
|
expect(result.isErr()).toBe(true);
|
|
84
84
|
expect(result.error.message).toContain('Config state not registered');
|
package/src/compose.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
|
@@ -11,14 +11,17 @@ import type { z } from 'zod';
|
|
|
11
11
|
// Types
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
|
|
14
|
-
/** A
|
|
15
|
-
export interface
|
|
16
|
-
readonly
|
|
14
|
+
/** A provision config schema entry extracted from a provision declaration. */
|
|
15
|
+
export interface ProvisionConfigEntry {
|
|
16
|
+
readonly provisionId: string;
|
|
17
17
|
readonly schema: z.ZodType;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
|
|
20
|
+
/** Backward-compatible alias while the migration is in flight. */
|
|
21
|
+
export type ServiceConfigEntry = ProvisionConfigEntry;
|
|
22
|
+
|
|
23
|
+
/** Minimal shape needed to extract config from a provision-like object. */
|
|
24
|
+
interface ProvisionWithOptionalConfig {
|
|
22
25
|
readonly id: string;
|
|
23
26
|
readonly config?: z.ZodType | undefined;
|
|
24
27
|
}
|
|
@@ -28,19 +31,22 @@ interface ServiceWithOptionalConfig {
|
|
|
28
31
|
// ---------------------------------------------------------------------------
|
|
29
32
|
|
|
30
33
|
/**
|
|
31
|
-
* Collect config schemas from
|
|
34
|
+
* Collect config schemas from provisions that declare them.
|
|
32
35
|
*
|
|
33
|
-
* Returns entries keyed by
|
|
34
|
-
*
|
|
36
|
+
* Returns entries keyed by provision ID for composition into `defineConfig`.
|
|
37
|
+
* Provisions without a `config` schema are excluded.
|
|
35
38
|
*/
|
|
36
|
-
export const
|
|
37
|
-
|
|
38
|
-
):
|
|
39
|
-
|
|
39
|
+
export const collectProvisionConfigs = (
|
|
40
|
+
provisions: readonly ProvisionWithOptionalConfig[]
|
|
41
|
+
): ProvisionConfigEntry[] =>
|
|
42
|
+
provisions
|
|
40
43
|
.filter(
|
|
41
44
|
(
|
|
42
45
|
svc
|
|
43
|
-
): svc is
|
|
46
|
+
): svc is ProvisionWithOptionalConfig & { readonly config: z.ZodType } =>
|
|
44
47
|
svc.config !== undefined
|
|
45
48
|
)
|
|
46
|
-
.map((svc) => ({
|
|
49
|
+
.map((svc) => ({ provisionId: svc.id, schema: svc.config }));
|
|
50
|
+
|
|
51
|
+
/** Backward-compatible alias while the migration is in flight. */
|
|
52
|
+
export const collectServiceConfigs = collectProvisionConfigs;
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
|
|
11
|
+
export const configGate: Gate = {
|
|
12
|
+
description: 'Ensures resolved config is available in the execution context',
|
|
13
|
+
name: 'config',
|
|
14
|
+
wrap: (_trail, impl) => (input, ctx) => impl(input, ctx),
|
|
15
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Config
|
|
2
|
+
* Config provision — manages resolved config lifecycle.
|
|
3
3
|
*
|
|
4
4
|
* The config is resolved during bootstrap (two-phase init per ADR-010)
|
|
5
|
-
* and registered via `registerConfigState`. This
|
|
6
|
-
* global registry so trails can access it through `
|
|
5
|
+
* and registered via `registerConfigState`. This provision reads from the
|
|
6
|
+
* global registry so trails can access it through `configProvision.from(ctx)`.
|
|
7
7
|
*/
|
|
8
|
-
import { InternalError, Result,
|
|
8
|
+
import { InternalError, Result, provision } from '@ontrails/core';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
|
|
11
11
|
import type { ConfigState } from './registry.js';
|
|
12
12
|
import { getConfigState } from './registry.js';
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const configProvision = provision<ConfigState>('config', {
|
|
15
15
|
create: () => {
|
|
16
16
|
const state = getConfigState();
|
|
17
17
|
if (state === undefined) {
|
|
@@ -24,7 +24,7 @@ export const configService = service<ConfigState>('config', {
|
|
|
24
24
|
return Result.ok(state);
|
|
25
25
|
},
|
|
26
26
|
description: 'Resolved application configuration',
|
|
27
|
-
|
|
27
|
+
meta: { category: 'infrastructure' },
|
|
28
28
|
mock: (): ConfigState => ({
|
|
29
29
|
resolved: {},
|
|
30
30
|
schema: z.object({}),
|
package/src/explain.ts
CHANGED
|
@@ -64,8 +64,8 @@ const buildSecretSet = (
|
|
|
64
64
|
return result;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
/** Source
|
|
68
|
-
type
|
|
67
|
+
/** Source entries in reverse precedence order for winner detection. */
|
|
68
|
+
type SourceEntry = readonly [
|
|
69
69
|
name: ProvenanceEntry['source'],
|
|
70
70
|
values: Record<string, unknown> | undefined,
|
|
71
71
|
];
|
|
@@ -74,7 +74,7 @@ type SourceLayer = readonly [
|
|
|
74
74
|
const determineSource = (
|
|
75
75
|
path: string,
|
|
76
76
|
resolved: Record<string, unknown>,
|
|
77
|
-
|
|
77
|
+
sources: readonly SourceEntry[],
|
|
78
78
|
envMap: Map<string, string>,
|
|
79
79
|
envVars: Record<string, string | undefined> | undefined
|
|
80
80
|
): ProvenanceEntry['source'] => {
|
|
@@ -86,7 +86,7 @@ const determineSource = (
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
const resolvedValue = getAtPath(resolved, path);
|
|
89
|
-
for (const [name, values] of
|
|
89
|
+
for (const [name, values] of sources) {
|
|
90
90
|
if (values && getAtPath(values, path) === resolvedValue) {
|
|
91
91
|
return name;
|
|
92
92
|
}
|
|
@@ -144,7 +144,7 @@ export const explainConfig = <T extends z.ZodType>(
|
|
|
144
144
|
const envMap = buildEnvMap(objSchema);
|
|
145
145
|
const secretSet = buildSecretSet(objSchema);
|
|
146
146
|
|
|
147
|
-
const
|
|
147
|
+
const sources: readonly SourceEntry[] = [
|
|
148
148
|
['local', options.local],
|
|
149
149
|
['loadout', options.loadout],
|
|
150
150
|
['base', options.base],
|
|
@@ -156,7 +156,7 @@ export const explainConfig = <T extends z.ZodType>(
|
|
|
156
156
|
const source = determineSource(
|
|
157
157
|
path,
|
|
158
158
|
options.resolved,
|
|
159
|
-
|
|
159
|
+
sources,
|
|
160
160
|
envMap,
|
|
161
161
|
options.env
|
|
162
162
|
);
|
package/src/extensions.ts
CHANGED
|
@@ -34,7 +34,7 @@ export const secret = <T extends z.ZodType>(schema: T): T =>
|
|
|
34
34
|
* standard key. We set `deprecated: true` so Zod-native tooling (schema
|
|
35
35
|
* serializers, OpenAPI generators) recognises the field as deprecated, and store
|
|
36
36
|
* the human-readable message under `deprecationMessage` for our own
|
|
37
|
-
* `collectConfigMeta` / survey / explain
|
|
37
|
+
* `collectConfigMeta` / survey / explain trailheads.
|
|
38
38
|
*
|
|
39
39
|
* Must be called BEFORE `.default()`, `.optional()`, or other transforms
|
|
40
40
|
* so that the metadata lives on the inner type where `collectConfigMeta`
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,12 @@ export {
|
|
|
7
7
|
type ResolveOptions,
|
|
8
8
|
} from './app-config.js';
|
|
9
9
|
export { collectConfigMeta } from './collect.js';
|
|
10
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
collectProvisionConfigs,
|
|
12
|
+
collectServiceConfigs,
|
|
13
|
+
type ProvisionConfigEntry,
|
|
14
|
+
type ServiceConfigEntry,
|
|
15
|
+
} from './compose.js';
|
|
11
16
|
export { defineConfig, type DefineConfigOptions } from './define-config.js';
|
|
12
17
|
export { describeConfig, type FieldDescription } from './describe.js';
|
|
13
18
|
export {
|
|
@@ -26,8 +31,8 @@ export {
|
|
|
26
31
|
generateExample,
|
|
27
32
|
generateJsonSchema,
|
|
28
33
|
} from './generate/index.js';
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
34
|
+
export { configGate } from './config-gate.js';
|
|
35
|
+
export { configProvision } from './config-provision.js';
|
|
31
36
|
export {
|
|
32
37
|
clearConfigState,
|
|
33
38
|
type ConfigState,
|
package/src/registry.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Module-level config state registry.
|
|
3
3
|
*
|
|
4
4
|
* Config is resolved once at bootstrap (two-phase init per ADR-010) and
|
|
5
|
-
* registered here so `
|
|
5
|
+
* registered here so `configProvision` can expose it to trailheads. This is
|
|
6
6
|
* a process-level singleton — config resolution is inherently global.
|
|
7
7
|
*/
|
|
8
8
|
import type { z } from 'zod';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Result, trail } from '@ontrails/core';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { configProvision } from '../config-provision.js';
|
|
11
11
|
import { checkConfig } from '../doctor.js';
|
|
12
12
|
import { deepMerge } from '../merge.js';
|
|
13
13
|
|
|
@@ -32,6 +32,15 @@ const mergeValues = (
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const configCheck = trail('config.check', {
|
|
35
|
+
blaze: (input, ctx) => {
|
|
36
|
+
const state = configProvision.from(ctx);
|
|
37
|
+
const effective = mergeValues(state.resolved, input.values);
|
|
38
|
+
const checked = checkConfig(state.schema, effective);
|
|
39
|
+
return Result.ok({
|
|
40
|
+
diagnostics: [...checked.diagnostics],
|
|
41
|
+
valid: checked.valid,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
35
44
|
examples: [
|
|
36
45
|
{
|
|
37
46
|
input: {},
|
|
@@ -45,16 +54,7 @@ export const configCheck = trail('config.check', {
|
|
|
45
54
|
.default({}),
|
|
46
55
|
}),
|
|
47
56
|
intent: 'read',
|
|
48
|
-
|
|
57
|
+
meta: { category: 'infrastructure' },
|
|
49
58
|
output: outputSchema,
|
|
50
|
-
|
|
51
|
-
const state = configService.from(ctx);
|
|
52
|
-
const effective = mergeValues(state.resolved, input.values);
|
|
53
|
-
const checked = checkConfig(state.schema, effective);
|
|
54
|
-
return Result.ok({
|
|
55
|
-
diagnostics: [...checked.diagnostics],
|
|
56
|
-
valid: checked.valid,
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
services: [configService],
|
|
59
|
+
provisions: [configProvision],
|
|
60
60
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Result, trail } from '@ontrails/core';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { configProvision } from '../config-provision.js';
|
|
11
11
|
import { describeConfig } from '../describe.js';
|
|
12
12
|
|
|
13
13
|
const fieldSchema = z.object({
|
|
@@ -25,6 +25,11 @@ const outputSchema = z.object({
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
export const configDescribe = trail('config.describe', {
|
|
28
|
+
blaze: (_input, ctx) => {
|
|
29
|
+
const state = configProvision.from(ctx);
|
|
30
|
+
const fields = describeConfig(state.schema);
|
|
31
|
+
return Result.ok({ fields: [...fields] });
|
|
32
|
+
},
|
|
28
33
|
examples: [
|
|
29
34
|
{
|
|
30
35
|
input: {},
|
|
@@ -33,12 +38,7 @@ export const configDescribe = trail('config.describe', {
|
|
|
33
38
|
],
|
|
34
39
|
input: z.object({}),
|
|
35
40
|
intent: 'read',
|
|
36
|
-
|
|
41
|
+
meta: { category: 'infrastructure' },
|
|
37
42
|
output: outputSchema,
|
|
38
|
-
|
|
39
|
-
const state = configService.from(ctx);
|
|
40
|
-
const fields = describeConfig(state.schema);
|
|
41
|
-
return Result.ok({ fields: [...fields] });
|
|
42
|
-
},
|
|
43
|
-
services: [configService],
|
|
43
|
+
provisions: [configProvision],
|
|
44
44
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Result, trail } from '@ontrails/core';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { configProvision } from '../config-provision.js';
|
|
11
11
|
import type { ExplainConfigOptions } from '../explain.js';
|
|
12
12
|
import { explainConfig } from '../explain.js';
|
|
13
13
|
import type { ConfigState } from '../registry.js';
|
|
@@ -34,7 +34,7 @@ const filterByPath = (
|
|
|
34
34
|
)
|
|
35
35
|
: entries;
|
|
36
36
|
|
|
37
|
-
/** Build ExplainConfigOptions from ConfigState, omitting undefined
|
|
37
|
+
/** Build ExplainConfigOptions from ConfigState, omitting undefined source overrides. */
|
|
38
38
|
const toExplainOptions = (
|
|
39
39
|
state: ConfigState
|
|
40
40
|
): ExplainConfigOptions<typeof state.schema> => {
|
|
@@ -48,7 +48,7 @@ const toExplainOptions = (
|
|
|
48
48
|
return base;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/** Enrich explain options with env and
|
|
51
|
+
/** Enrich explain options with env and source overrides from state. */
|
|
52
52
|
const enrichOptions = (
|
|
53
53
|
state: ConfigState,
|
|
54
54
|
options: ExplainConfigOptions<typeof state.schema>
|
|
@@ -67,6 +67,13 @@ const enrichOptions = (
|
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
export const configExplain = trail('config.explain', {
|
|
70
|
+
blaze: (input, ctx) => {
|
|
71
|
+
const state = configProvision.from(ctx);
|
|
72
|
+
const options = enrichOptions(state, toExplainOptions(state));
|
|
73
|
+
const entries = explainConfig(options);
|
|
74
|
+
const filtered = filterByPath(entries, input.path);
|
|
75
|
+
return Result.ok({ entries: [...filtered] });
|
|
76
|
+
},
|
|
70
77
|
examples: [
|
|
71
78
|
{
|
|
72
79
|
input: {},
|
|
@@ -80,14 +87,7 @@ export const configExplain = trail('config.explain', {
|
|
|
80
87
|
.default(''),
|
|
81
88
|
}),
|
|
82
89
|
intent: 'read',
|
|
83
|
-
|
|
90
|
+
meta: { category: 'infrastructure' },
|
|
84
91
|
output: outputSchema,
|
|
85
|
-
|
|
86
|
-
const state = configService.from(ctx);
|
|
87
|
-
const options = enrichOptions(state, toExplainOptions(state));
|
|
88
|
-
const entries = explainConfig(options);
|
|
89
|
-
const filtered = filterByPath(entries, input.path);
|
|
90
|
-
return Result.ok({ entries: [...filtered] });
|
|
91
|
-
},
|
|
92
|
-
services: [configService],
|
|
92
|
+
provisions: [configProvision],
|
|
93
93
|
});
|
|
@@ -14,7 +14,7 @@ import { Result, trail } from '@ontrails/core';
|
|
|
14
14
|
import type { z } from 'zod';
|
|
15
15
|
import { z as zod } from 'zod';
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { configProvision } from '../config-provision.js';
|
|
18
18
|
import {
|
|
19
19
|
generateEnvExample,
|
|
20
20
|
generateExample,
|
|
@@ -62,6 +62,18 @@ const writeArtifacts = async (
|
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
export const configInit = trail('config.init', {
|
|
65
|
+
blaze: async (input, ctx) => {
|
|
66
|
+
const state = configProvision.from(ctx);
|
|
67
|
+
const schema = state.schema as z.ZodObject<Record<string, z.ZodType>>;
|
|
68
|
+
const content = generateExample(schema, input.format);
|
|
69
|
+
|
|
70
|
+
if (input.dir) {
|
|
71
|
+
const writtenFiles = await writeArtifacts(input.dir, schema);
|
|
72
|
+
return Result.ok({ content, format: input.format, writtenFiles });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return Result.ok({ content, format: input.format });
|
|
76
|
+
},
|
|
65
77
|
examples: [
|
|
66
78
|
{
|
|
67
79
|
input: {},
|
|
@@ -78,19 +90,7 @@ export const configInit = trail('config.init', {
|
|
|
78
90
|
.default('toml'),
|
|
79
91
|
}),
|
|
80
92
|
intent: 'write',
|
|
81
|
-
|
|
93
|
+
meta: { category: 'infrastructure' },
|
|
82
94
|
output: outputSchema,
|
|
83
|
-
|
|
84
|
-
const state = configService.from(ctx);
|
|
85
|
-
const schema = state.schema as z.ZodObject<Record<string, z.ZodType>>;
|
|
86
|
-
const content = generateExample(schema, input.format);
|
|
87
|
-
|
|
88
|
-
if (input.dir) {
|
|
89
|
-
const writtenFiles = await writeArtifacts(input.dir, schema);
|
|
90
|
-
return Result.ok({ content, format: input.format, writtenFiles });
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return Result.ok({ content, format: input.format });
|
|
94
|
-
},
|
|
95
|
-
services: [configService],
|
|
95
|
+
provisions: [configProvision],
|
|
96
96
|
});
|
package/src/config-layer.ts
DELETED
|
@@ -1,15 +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
|
-
|
|
11
|
-
export const configLayer: Layer = {
|
|
12
|
-
description: 'Ensures resolved config is available in the execution context',
|
|
13
|
-
name: 'config',
|
|
14
|
-
wrap: (_trail, impl) => (input, ctx) => impl(input, ctx),
|
|
15
|
-
};
|