@ontrails/warden 1.0.0-beta.1 → 1.0.0-beta.10
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 +148 -0
- package/README.md +27 -6
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +1 -4
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/rules/ast.d.ts +15 -8
- package/dist/rules/ast.d.ts.map +1 -1
- package/dist/rules/ast.js +99 -44
- package/dist/rules/ast.js.map +1 -1
- package/dist/rules/context-no-surface-types.js +1 -1
- package/dist/rules/context-no-surface-types.js.map +1 -1
- package/dist/rules/follow-declarations.d.ts +13 -0
- package/dist/rules/follow-declarations.d.ts.map +1 -0
- package/dist/rules/follow-declarations.js +264 -0
- package/dist/rules/follow-declarations.js.map +1 -0
- package/dist/rules/implementation-returns-result.d.ts +1 -1
- package/dist/rules/implementation-returns-result.d.ts.map +1 -1
- package/dist/rules/implementation-returns-result.js +52 -6
- package/dist/rules/implementation-returns-result.js.map +1 -1
- package/dist/rules/index.d.ts +2 -8
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +4 -8
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/no-direct-impl-in-route.d.ts +4 -4
- package/dist/rules/no-direct-impl-in-route.d.ts.map +1 -1
- package/dist/rules/no-direct-impl-in-route.js +15 -14
- package/dist/rules/no-direct-impl-in-route.js.map +1 -1
- package/dist/rules/no-direct-implementation-call.d.ts +3 -3
- package/dist/rules/no-direct-implementation-call.js +7 -7
- package/dist/rules/no-direct-implementation-call.js.map +1 -1
- package/dist/rules/no-sync-result-assumption.d.ts +1 -1
- package/dist/rules/no-sync-result-assumption.js +5 -5
- package/dist/rules/no-sync-result-assumption.js.map +1 -1
- package/dist/rules/no-throw-in-detour-target.js +2 -2
- package/dist/rules/no-throw-in-detour-target.js.map +1 -1
- package/dist/rules/no-throw-in-implementation.d.ts +1 -1
- package/dist/rules/no-throw-in-implementation.js +3 -3
- package/dist/rules/no-throw-in-implementation.js.map +1 -1
- package/dist/rules/specs.d.ts +1 -1
- package/dist/rules/specs.d.ts.map +1 -1
- package/dist/rules/specs.js +2 -2
- package/dist/rules/specs.js.map +1 -1
- package/dist/trails/context-no-surface-types.trail.d.ts +13 -0
- package/dist/trails/context-no-surface-types.trail.d.ts.map +1 -0
- package/dist/trails/context-no-surface-types.trail.js +21 -0
- package/dist/trails/context-no-surface-types.trail.js.map +1 -0
- package/dist/trails/follow-declarations.trail.d.ts +13 -0
- package/dist/trails/follow-declarations.trail.d.ts.map +1 -0
- package/dist/trails/follow-declarations.trail.js +22 -0
- package/dist/trails/follow-declarations.trail.js.map +1 -0
- package/dist/trails/implementation-returns-result.trail.d.ts +13 -0
- package/dist/trails/implementation-returns-result.trail.d.ts.map +1 -0
- package/dist/trails/implementation-returns-result.trail.js +20 -0
- package/dist/trails/implementation-returns-result.trail.js.map +1 -0
- package/dist/trails/index.d.ts +14 -0
- package/dist/trails/index.d.ts.map +1 -0
- package/dist/trails/index.js +13 -0
- package/dist/trails/index.js.map +1 -0
- package/dist/trails/no-direct-impl-in-route.trail.d.ts +13 -0
- package/dist/trails/no-direct-impl-in-route.trail.d.ts.map +1 -0
- package/dist/trails/no-direct-impl-in-route.trail.js +22 -0
- package/dist/trails/no-direct-impl-in-route.trail.js.map +1 -0
- package/dist/trails/no-direct-implementation-call.trail.d.ts +13 -0
- package/dist/trails/no-direct-implementation-call.trail.d.ts.map +1 -0
- package/dist/trails/no-direct-implementation-call.trail.js +16 -0
- package/dist/trails/no-direct-implementation-call.trail.js.map +1 -0
- package/dist/trails/no-sync-result-assumption.trail.d.ts +13 -0
- package/dist/trails/no-sync-result-assumption.trail.d.ts.map +1 -0
- package/dist/trails/no-sync-result-assumption.trail.js +19 -0
- package/dist/trails/no-sync-result-assumption.trail.js.map +1 -0
- package/dist/trails/no-throw-in-detour-target.trail.d.ts +14 -0
- package/dist/trails/no-throw-in-detour-target.trail.d.ts.map +1 -0
- package/dist/trails/no-throw-in-detour-target.trail.js +20 -0
- package/dist/trails/no-throw-in-detour-target.trail.js.map +1 -0
- package/dist/trails/no-throw-in-implementation.trail.d.ts +13 -0
- package/dist/trails/no-throw-in-implementation.trail.d.ts.map +1 -0
- package/dist/trails/no-throw-in-implementation.trail.js +20 -0
- package/dist/trails/no-throw-in-implementation.trail.js.map +1 -0
- package/dist/trails/prefer-schema-inference.trail.d.ts +13 -0
- package/dist/trails/prefer-schema-inference.trail.d.ts.map +1 -0
- package/dist/trails/prefer-schema-inference.trail.js +21 -0
- package/dist/trails/prefer-schema-inference.trail.js.map +1 -0
- package/dist/trails/run.d.ts +16 -0
- package/dist/trails/run.d.ts.map +1 -0
- package/dist/trails/run.js +30 -0
- package/dist/trails/run.js.map +1 -0
- package/dist/trails/schema.d.ts +52 -0
- package/dist/trails/schema.d.ts.map +1 -0
- package/dist/trails/schema.js +38 -0
- package/dist/trails/schema.js.map +1 -0
- package/dist/trails/topo.d.ts +3 -0
- package/dist/trails/topo.d.ts.map +1 -0
- package/dist/trails/topo.js +5 -0
- package/dist/trails/topo.js.map +1 -0
- package/dist/trails/valid-describe-refs.trail.d.ts +14 -0
- package/dist/trails/valid-describe-refs.trail.d.ts.map +1 -0
- package/dist/trails/valid-describe-refs.trail.js +18 -0
- package/dist/trails/valid-describe-refs.trail.js.map +1 -0
- package/dist/trails/valid-detour-refs.trail.d.ts +14 -0
- package/dist/trails/valid-detour-refs.trail.d.ts.map +1 -0
- package/dist/trails/valid-detour-refs.trail.js +24 -0
- package/dist/trails/valid-detour-refs.trail.js.map +1 -0
- package/dist/trails/wrap-rule.d.ts +29 -0
- package/dist/trails/wrap-rule.d.ts.map +1 -0
- package/dist/trails/wrap-rule.js +43 -0
- package/dist/trails/wrap-rule.js.map +1 -0
- package/package.json +5 -4
- package/src/__tests__/cli.test.ts +7 -7
- package/src/__tests__/drift.test.ts +1 -1
- package/src/__tests__/follow-declarations.test.ts +303 -0
- package/src/__tests__/implementation-returns-result.test.ts +60 -6
- package/src/__tests__/no-direct-implementation-call.test.ts +8 -8
- package/src/__tests__/no-sync-result-assumption.test.ts +6 -6
- package/src/__tests__/no-throw-in-detour-target.test.ts +6 -6
- package/src/__tests__/prefer-schema-inference.test.ts +4 -4
- package/src/__tests__/rules.test.ts +59 -20
- package/src/__tests__/trails.test.ts +19 -0
- package/src/__tests__/valid-describe-refs.test.ts +4 -4
- package/src/cli.ts +1 -4
- package/src/index.ts +21 -0
- package/src/rules/ast.ts +126 -57
- package/src/rules/context-no-surface-types.ts +1 -1
- package/src/rules/follow-declarations.ts +380 -0
- package/src/rules/implementation-returns-result.ts +63 -6
- package/src/rules/index.ts +4 -8
- package/src/rules/no-direct-impl-in-route.ts +20 -16
- package/src/rules/no-direct-implementation-call.ts +7 -7
- package/src/rules/no-sync-result-assumption.ts +5 -5
- package/src/rules/no-throw-in-detour-target.ts +2 -2
- package/src/rules/no-throw-in-implementation.ts +3 -3
- package/src/rules/specs.ts +5 -5
- package/src/trails/context-no-surface-types.trail.ts +21 -0
- package/src/trails/follow-declarations.trail.ts +22 -0
- package/src/trails/implementation-returns-result.trail.ts +20 -0
- package/src/trails/index.ts +14 -0
- package/src/trails/no-direct-impl-in-route.trail.ts +22 -0
- package/src/trails/no-direct-implementation-call.trail.ts +16 -0
- package/src/trails/no-sync-result-assumption.trail.ts +19 -0
- package/src/trails/no-throw-in-detour-target.trail.ts +20 -0
- package/src/trails/no-throw-in-implementation.trail.ts +20 -0
- package/src/trails/prefer-schema-inference.trail.ts +21 -0
- package/src/trails/run.ts +40 -0
- package/src/trails/schema.ts +46 -0
- package/src/trails/topo.ts +6 -0
- package/src/trails/valid-describe-refs.trail.ts +18 -0
- package/src/trails/valid-detour-refs.trail.ts +24 -0
- package/src/trails/wrap-rule.ts +84 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { noThrowInDetourTarget } from '../rules/no-throw-in-detour-target.js';
|
|
2
|
+
import { wrapRule } from './wrap-rule.js';
|
|
3
|
+
export const noThrowInDetourTargetTrail = wrapRule({
|
|
4
|
+
examples: [
|
|
5
|
+
{
|
|
6
|
+
expected: { diagnostics: [] },
|
|
7
|
+
input: {
|
|
8
|
+
filePath: 'clean.ts',
|
|
9
|
+
sourceCode: `trail("entity.fallback", {
|
|
10
|
+
run: async (input, ctx) => {
|
|
11
|
+
return Result.ok({ recovered: true });
|
|
12
|
+
}
|
|
13
|
+
})`,
|
|
14
|
+
},
|
|
15
|
+
name: 'Detour target without throw',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
rule: noThrowInDetourTarget,
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=no-throw-in-detour-target.trail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-throw-in-detour-target.trail.js","sourceRoot":"","sources":["../../src/trails/no-throw-in-detour-target.trail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IACjD,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;YAC7B,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,UAAU,EAAE;;;;GAIjB;aACI;YACD,IAAI,EAAE,6BAA6B;SACpC;KACF;IACD,IAAI,EAAE,qBAAqB;CAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const noThrowInImplementationTrail: import("@ontrails/core").Trail<{
|
|
2
|
+
filePath: string;
|
|
3
|
+
sourceCode: string;
|
|
4
|
+
}, {
|
|
5
|
+
diagnostics: {
|
|
6
|
+
filePath: string;
|
|
7
|
+
line: number;
|
|
8
|
+
message: string;
|
|
9
|
+
rule: string;
|
|
10
|
+
severity: "error" | "warn";
|
|
11
|
+
}[];
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=no-throw-in-implementation.trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-throw-in-implementation.trail.d.ts","sourceRoot":"","sources":["../../src/trails/no-throw-in-implementation.trail.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,4BAA4B;;;;;;;;;;;EAgBvC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { noThrowInImplementation } from '../rules/no-throw-in-implementation.js';
|
|
2
|
+
import { wrapRule } from './wrap-rule.js';
|
|
3
|
+
export const noThrowInImplementationTrail = wrapRule({
|
|
4
|
+
examples: [
|
|
5
|
+
{
|
|
6
|
+
expected: { diagnostics: [] },
|
|
7
|
+
input: {
|
|
8
|
+
filePath: 'clean.ts',
|
|
9
|
+
sourceCode: `trail("entity.show", {
|
|
10
|
+
run: async (input, ctx) => {
|
|
11
|
+
return Result.ok({ name: "test" });
|
|
12
|
+
}
|
|
13
|
+
})`,
|
|
14
|
+
},
|
|
15
|
+
name: 'Clean implementation without throw',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
rule: noThrowInImplementation,
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=no-throw-in-implementation.trail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-throw-in-implementation.trail.js","sourceRoot":"","sources":["../../src/trails/no-throw-in-implementation.trail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IACnD,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;YAC7B,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,UAAU,EAAE;;;;GAIjB;aACI;YACD,IAAI,EAAE,oCAAoC;SAC3C;KACF;IACD,IAAI,EAAE,uBAAuB;CAC9B,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const preferSchemaInferenceTrail: import("@ontrails/core").Trail<{
|
|
2
|
+
filePath: string;
|
|
3
|
+
sourceCode: string;
|
|
4
|
+
}, {
|
|
5
|
+
diagnostics: {
|
|
6
|
+
filePath: string;
|
|
7
|
+
line: number;
|
|
8
|
+
message: string;
|
|
9
|
+
rule: string;
|
|
10
|
+
severity: "error" | "warn";
|
|
11
|
+
}[];
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=prefer-schema-inference.trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-schema-inference.trail.d.ts","sourceRoot":"","sources":["../../src/trails/prefer-schema-inference.trail.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B;;;;;;;;;;;EAiBrC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { preferSchemaInference } from '../rules/prefer-schema-inference.js';
|
|
2
|
+
import { wrapRule } from './wrap-rule.js';
|
|
3
|
+
export const preferSchemaInferenceTrail = wrapRule({
|
|
4
|
+
examples: [
|
|
5
|
+
{
|
|
6
|
+
expected: { diagnostics: [] },
|
|
7
|
+
input: {
|
|
8
|
+
filePath: 'clean.ts',
|
|
9
|
+
sourceCode: `trail("entity.show", {
|
|
10
|
+
input: z.object({ name: z.string() }),
|
|
11
|
+
run: async (input, ctx) => {
|
|
12
|
+
return Result.ok({ name: input.name });
|
|
13
|
+
}
|
|
14
|
+
})`,
|
|
15
|
+
},
|
|
16
|
+
name: 'Trail without redundant field overrides',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
rule: preferSchemaInference,
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=prefer-schema-inference.trail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-schema-inference.trail.js","sourceRoot":"","sources":["../../src/trails/prefer-schema-inference.trail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IACjD,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;YAC7B,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,UAAU,EAAE;;;;;GAKjB;aACI;YACD,IAAI,EAAE,yCAAyC;SAChD;KACF;IACD,IAAI,EAAE,qBAAqB;CAC5B,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run all warden rule trails against a single source file.
|
|
3
|
+
*
|
|
4
|
+
* Returns a flat array of diagnostics from every rule.
|
|
5
|
+
*/
|
|
6
|
+
import type { WardenDiagnostic } from '../rules/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Dispatch all warden rule trails for a given file and collect diagnostics.
|
|
9
|
+
*
|
|
10
|
+
* Each rule trail runs independently. Errors from individual trails are
|
|
11
|
+
* silently skipped so that one broken rule does not block the rest.
|
|
12
|
+
*/
|
|
13
|
+
export declare const runWardenTrails: (filePath: string, sourceCode: string, options?: {
|
|
14
|
+
readonly knownTrailIds?: readonly string[];
|
|
15
|
+
}) => Promise<readonly WardenDiagnostic[]>;
|
|
16
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/trails/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,YAAY,MAAM,EAClB,UAAU;IAAE,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,KACvD,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAiBrC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run all warden rule trails against a single source file.
|
|
3
|
+
*
|
|
4
|
+
* Returns a flat array of diagnostics from every rule.
|
|
5
|
+
*/
|
|
6
|
+
import { dispatch } from '@ontrails/core';
|
|
7
|
+
import { wardenTopo } from './topo.js';
|
|
8
|
+
/**
|
|
9
|
+
* Dispatch all warden rule trails for a given file and collect diagnostics.
|
|
10
|
+
*
|
|
11
|
+
* Each rule trail runs independently. Errors from individual trails are
|
|
12
|
+
* silently skipped so that one broken rule does not block the rest.
|
|
13
|
+
*/
|
|
14
|
+
export const runWardenTrails = async (filePath, sourceCode, options) => {
|
|
15
|
+
const allDiagnostics = [];
|
|
16
|
+
for (const id of wardenTopo.ids()) {
|
|
17
|
+
const input = options?.knownTrailIds
|
|
18
|
+
? { filePath, knownTrailIds: options.knownTrailIds, sourceCode }
|
|
19
|
+
: { filePath, sourceCode };
|
|
20
|
+
const result = await dispatch(wardenTopo, id, input);
|
|
21
|
+
if (result.isOk()) {
|
|
22
|
+
const { diagnostics } = result.value;
|
|
23
|
+
for (const d of diagnostics) {
|
|
24
|
+
allDiagnostics.push(d);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return allDiagnostics;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/trails/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,QAAgB,EAChB,UAAkB,EAClB,OAAwD,EAClB,EAAE;IACxC,MAAM,cAAc,GAAuB,EAAE,CAAC;IAE9C,KAAK,MAAM,EAAE,IAAI,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,OAAO,EAAE,aAAa;YAClC,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,UAAU,EAAE;YAChE,CAAC,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;QACrD,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;YAClB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,KAAmB,CAAC;YACnD,KAAK,MAAM,CAAC,IAAI,WAAW,EAAE,CAAC;gBAC5B,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Zod schemas for warden rule trails.
|
|
3
|
+
*
|
|
4
|
+
* Every rule trail shares the same input (source file) and output
|
|
5
|
+
* (array of diagnostics) shape.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/** A single diagnostic emitted by a warden rule trail. */
|
|
9
|
+
export declare const diagnosticSchema: z.ZodObject<{
|
|
10
|
+
filePath: z.ZodString;
|
|
11
|
+
line: z.ZodNumber;
|
|
12
|
+
message: z.ZodString;
|
|
13
|
+
rule: z.ZodString;
|
|
14
|
+
severity: z.ZodEnum<{
|
|
15
|
+
error: "error";
|
|
16
|
+
warn: "warn";
|
|
17
|
+
}>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
/** Input accepted by every warden rule trail. */
|
|
20
|
+
export declare const ruleInput: z.ZodObject<{
|
|
21
|
+
filePath: z.ZodString;
|
|
22
|
+
sourceCode: z.ZodString;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
/**
|
|
25
|
+
* Extended input for project-aware warden rule trails.
|
|
26
|
+
*
|
|
27
|
+
* Adds `knownTrailIds` so the caller can supply cross-file context and avoid
|
|
28
|
+
* false positives for detour targets or `@see` references defined in other
|
|
29
|
+
* files.
|
|
30
|
+
*/
|
|
31
|
+
export declare const projectAwareRuleInput: z.ZodObject<{
|
|
32
|
+
filePath: z.ZodString;
|
|
33
|
+
sourceCode: z.ZodString;
|
|
34
|
+
knownTrailIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/** Output returned by every warden rule trail. */
|
|
37
|
+
export declare const ruleOutput: z.ZodObject<{
|
|
38
|
+
diagnostics: z.ZodArray<z.ZodObject<{
|
|
39
|
+
filePath: z.ZodString;
|
|
40
|
+
line: z.ZodNumber;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
rule: z.ZodString;
|
|
43
|
+
severity: z.ZodEnum<{
|
|
44
|
+
error: "error";
|
|
45
|
+
warn: "warn";
|
|
46
|
+
}>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type RuleInput = z.infer<typeof ruleInput>;
|
|
50
|
+
export type ProjectAwareRuleInput = z.infer<typeof projectAwareRuleInput>;
|
|
51
|
+
export type RuleOutput = z.infer<typeof ruleOutput>;
|
|
52
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/trails/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB;;;;;;;;;iBAM3B,CAAC;AAEH,iDAAiD;AACjD,eAAO,MAAM,SAAS;;;iBAGpB,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;iBAKhC,CAAC;AAEH,kDAAkD;AAClD,eAAO,MAAM,UAAU;;;;;;;;;;;iBAErB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAClD,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC1E,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Zod schemas for warden rule trails.
|
|
3
|
+
*
|
|
4
|
+
* Every rule trail shares the same input (source file) and output
|
|
5
|
+
* (array of diagnostics) shape.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
/** A single diagnostic emitted by a warden rule trail. */
|
|
9
|
+
export const diagnosticSchema = z.object({
|
|
10
|
+
filePath: z.string().describe('File path that was analyzed'),
|
|
11
|
+
line: z.number().describe('1-based line number'),
|
|
12
|
+
message: z.string().describe('Human-readable diagnostic message'),
|
|
13
|
+
rule: z.string().describe('Rule name'),
|
|
14
|
+
severity: z.enum(['error', 'warn']).describe('Diagnostic severity'),
|
|
15
|
+
});
|
|
16
|
+
/** Input accepted by every warden rule trail. */
|
|
17
|
+
export const ruleInput = z.object({
|
|
18
|
+
filePath: z.string().describe('Path to the source file'),
|
|
19
|
+
sourceCode: z.string().describe('Source code content'),
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Extended input for project-aware warden rule trails.
|
|
23
|
+
*
|
|
24
|
+
* Adds `knownTrailIds` so the caller can supply cross-file context and avoid
|
|
25
|
+
* false positives for detour targets or `@see` references defined in other
|
|
26
|
+
* files.
|
|
27
|
+
*/
|
|
28
|
+
export const projectAwareRuleInput = ruleInput.extend({
|
|
29
|
+
knownTrailIds: z
|
|
30
|
+
.array(z.string())
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Trail IDs known across the project'),
|
|
33
|
+
});
|
|
34
|
+
/** Output returned by every warden rule trail. */
|
|
35
|
+
export const ruleOutput = z.object({
|
|
36
|
+
diagnostics: z.array(diagnosticSchema).describe('Diagnostics found'),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/trails/schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC5D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;IACjE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;IACtC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,qBAAqB,CAAC;CACpE,CAAC,CAAC;AAEH,iDAAiD;AACjD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IACxD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;CACvD,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC,MAAM,CAAC;IACpD,aAAa,EAAE,CAAC;SACb,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CAAC,oCAAoC,CAAC;CAClD,CAAC,CAAC;AAEH,kDAAkD;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CACrE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo.d.ts","sourceRoot":"","sources":["../../src/trails/topo.ts"],"names":[],"mappings":"AAIA,8CAA8C;AAC9C,eAAO,MAAM,UAAU,+BAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"topo.js","sourceRoot":"","sources":["../../src/trails/topo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,8CAA8C;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const validDescribeRefsTrail: import("@ontrails/core").Trail<{
|
|
2
|
+
filePath: string;
|
|
3
|
+
sourceCode: string;
|
|
4
|
+
knownTrailIds?: string[] | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
diagnostics: {
|
|
7
|
+
filePath: string;
|
|
8
|
+
line: number;
|
|
9
|
+
message: string;
|
|
10
|
+
rule: string;
|
|
11
|
+
severity: "error" | "warn";
|
|
12
|
+
}[];
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=valid-describe-refs.trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valid-describe-refs.trail.d.ts","sourceRoot":"","sources":["../../src/trails/valid-describe-refs.trail.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAcjC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { validDescribeRefs } from '../rules/valid-describe-refs.js';
|
|
2
|
+
import { wrapRule } from './wrap-rule.js';
|
|
3
|
+
export const validDescribeRefsTrail = wrapRule({
|
|
4
|
+
examples: [
|
|
5
|
+
{
|
|
6
|
+
expected: { diagnostics: [] },
|
|
7
|
+
input: {
|
|
8
|
+
filePath: 'clean.ts',
|
|
9
|
+
sourceCode: `const schema = z.object({
|
|
10
|
+
name: z.string().describe("User display name"),
|
|
11
|
+
});`,
|
|
12
|
+
},
|
|
13
|
+
name: 'Describe without @see refs',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
rule: validDescribeRefs,
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=valid-describe-refs.trail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valid-describe-refs.trail.js","sourceRoot":"","sources":["../../src/trails/valid-describe-refs.trail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC7C,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;YAC7B,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,UAAU,EAAE;;IAEhB;aACG;YACD,IAAI,EAAE,4BAA4B;SACnC;KACF;IACD,IAAI,EAAE,iBAAiB;CACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const validDetourRefsTrail: import("@ontrails/core").Trail<{
|
|
2
|
+
filePath: string;
|
|
3
|
+
sourceCode: string;
|
|
4
|
+
knownTrailIds?: string[] | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
diagnostics: {
|
|
7
|
+
filePath: string;
|
|
8
|
+
line: number;
|
|
9
|
+
message: string;
|
|
10
|
+
rule: string;
|
|
11
|
+
severity: "error" | "warn";
|
|
12
|
+
}[];
|
|
13
|
+
}>;
|
|
14
|
+
//# sourceMappingURL=valid-detour-refs.trail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valid-detour-refs.trail.d.ts","sourceRoot":"","sources":["../../src/trails/valid-detour-refs.trail.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAoB/B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { validDetourRefs } from '../rules/valid-detour-refs.js';
|
|
2
|
+
import { wrapRule } from './wrap-rule.js';
|
|
3
|
+
export const validDetourRefsTrail = wrapRule({
|
|
4
|
+
examples: [
|
|
5
|
+
{
|
|
6
|
+
expected: { diagnostics: [] },
|
|
7
|
+
input: {
|
|
8
|
+
filePath: 'clean.ts',
|
|
9
|
+
knownTrailIds: ['entity.fallback', 'entity.show'],
|
|
10
|
+
sourceCode: `trail("entity.fallback", {
|
|
11
|
+
run: async (input, ctx) => Result.ok(data)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
trail("entity.show", {
|
|
15
|
+
detours: [{ target: "entity.fallback" }],
|
|
16
|
+
run: async (input, ctx) => Result.ok(data)
|
|
17
|
+
})`,
|
|
18
|
+
},
|
|
19
|
+
name: 'Valid detour target reference',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
rule: validDetourRefs,
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=valid-detour-refs.trail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valid-detour-refs.trail.js","sourceRoot":"","sources":["../../src/trails/valid-detour-refs.trail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC3C,QAAQ,EAAE;QACR;YACE,QAAQ,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;YAC7B,KAAK,EAAE;gBACL,QAAQ,EAAE,UAAU;gBACpB,aAAa,EAAE,CAAC,iBAAiB,EAAE,aAAa,CAAC;gBACjD,UAAU,EAAE;;;;;;;GAOjB;aACI;YACD,IAAI,EAAE,+BAA+B;SACtC;KACF;IACD,IAAI,EAAE,eAAe;CACtB,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory that wraps a WardenRule as a trail.
|
|
3
|
+
*
|
|
4
|
+
* Keeps each rule trail file minimal — just the import + examples.
|
|
5
|
+
*/
|
|
6
|
+
import type { Trail } from '@ontrails/core';
|
|
7
|
+
import type { ProjectAwareWardenRule, WardenRule } from '../rules/types.js';
|
|
8
|
+
import type { ProjectAwareRuleInput, RuleInput, RuleOutput } from './schema.js';
|
|
9
|
+
interface WrapRuleOptions {
|
|
10
|
+
/** The existing warden rule to wrap. */
|
|
11
|
+
readonly rule: WardenRule;
|
|
12
|
+
/** Trail examples for testing and documentation. */
|
|
13
|
+
readonly examples: Trail<RuleInput, RuleOutput>['examples'];
|
|
14
|
+
}
|
|
15
|
+
interface WrapProjectAwareRuleOptions {
|
|
16
|
+
/** The existing project-aware warden rule to wrap. */
|
|
17
|
+
readonly rule: ProjectAwareWardenRule;
|
|
18
|
+
/** Trail examples for testing and documentation. */
|
|
19
|
+
readonly examples: Trail<ProjectAwareRuleInput, RuleOutput>['examples'];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wrap an existing `WardenRule` as a trail with typed input/output.
|
|
23
|
+
*
|
|
24
|
+
* The trail ID follows the pattern `warden.rule.<rule-name>`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function wrapRule(options: WrapProjectAwareRuleOptions): Trail<ProjectAwareRuleInput, RuleOutput>;
|
|
27
|
+
export declare function wrapRule(options: WrapRuleOptions): Trail<RuleInput, RuleOutput>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=wrap-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap-rule.d.ts","sourceRoot":"","sources":["../../src/trails/wrap-rule.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhF,UAAU,eAAe;IACvB,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC;CAC7D;AAED,UAAU,2BAA2B;IACnC,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IACtC,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,UAAU,CAAC,CAAC;CACzE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,2BAA2B,GACnC,KAAK,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;AAC5C,wBAAgB,QAAQ,CACtB,OAAO,EAAE,eAAe,GACvB,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory that wraps a WardenRule as a trail.
|
|
3
|
+
*
|
|
4
|
+
* Keeps each rule trail file minimal — just the import + examples.
|
|
5
|
+
*/
|
|
6
|
+
import { trail, Result } from '@ontrails/core';
|
|
7
|
+
import { projectAwareRuleInput, ruleInput, ruleOutput } from './schema.js';
|
|
8
|
+
export function wrapRule(options) {
|
|
9
|
+
const { rule, examples } = options;
|
|
10
|
+
const isProjectAware = 'checkWithContext' in rule;
|
|
11
|
+
if (isProjectAware) {
|
|
12
|
+
const projectAwareRule = rule;
|
|
13
|
+
return trail(`warden.rule.${rule.name}`, {
|
|
14
|
+
description: rule.description,
|
|
15
|
+
examples: examples,
|
|
16
|
+
input: projectAwareRuleInput,
|
|
17
|
+
intent: 'read',
|
|
18
|
+
metadata: { category: 'governance', severity: rule.severity },
|
|
19
|
+
output: ruleOutput,
|
|
20
|
+
run: (input) => {
|
|
21
|
+
const diagnostics = projectAwareRule.checkWithContext(input.sourceCode, input.filePath, {
|
|
22
|
+
knownTrailIds: input.knownTrailIds
|
|
23
|
+
? new Set(input.knownTrailIds)
|
|
24
|
+
: new Set(),
|
|
25
|
+
});
|
|
26
|
+
return Result.ok({ diagnostics: [...diagnostics] });
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return trail(`warden.rule.${rule.name}`, {
|
|
31
|
+
description: rule.description,
|
|
32
|
+
examples: examples,
|
|
33
|
+
input: ruleInput,
|
|
34
|
+
intent: 'read',
|
|
35
|
+
metadata: { category: 'governance', severity: rule.severity },
|
|
36
|
+
output: ruleOutput,
|
|
37
|
+
run: (input) => {
|
|
38
|
+
const diagnostics = rule.check(input.sourceCode, input.filePath);
|
|
39
|
+
return Result.ok({ diagnostics: [...diagnostics] });
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=wrap-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrap-rule.js","sourceRoot":"","sources":["../../src/trails/wrap-rule.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI/C,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA4B3E,MAAM,UAAU,QAAQ,CACtB,OAAsD;IAEtD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,cAAc,GAAG,kBAAkB,IAAI,IAAI,CAAC;IAElD,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,gBAAgB,GAAG,IAA8B,CAAC;QACxD,OAAO,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,EAAE,EAAE;YACvC,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,QAGG;YACb,KAAK,EAAE,qBAAqB;YAC5B,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;YAC7D,MAAM,EAAE,UAAU;YAClB,GAAG,EAAE,CAAC,KAA4B,EAAE,EAAE;gBACpC,MAAM,WAAW,GAAG,gBAAgB,CAAC,gBAAgB,CACnD,KAAK,CAAC,UAAU,EAChB,KAAK,CAAC,QAAQ,EACd;oBACE,aAAa,EAAE,KAAK,CAAC,aAAa;wBAChC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC;wBAC9B,CAAC,CAAC,IAAI,GAAG,EAAU;iBACtB,CACF,CAAC;gBACF,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC,eAAe,IAAI,CAAC,IAAI,EAAE,EAAE;QACvC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,QAAQ,EAAE,QAAoD;QAC9D,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,MAAM;QACd,QAAQ,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE;QAC7D,MAAM,EAAE,UAAU;QAClB,GAAG,EAAE,CAAC,KAAgB,EAAE,EAAE;YACxB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;YACjE,OAAO,MAAM,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ontrails/warden",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts",
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
"clean": "rm -rf dist *.tsbuildinfo"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@ontrails/testing": "^1.0.0-beta.8",
|
|
17
18
|
"@oxc-project/types": "^0.122.0",
|
|
18
19
|
"oxc-parser": "^0.121.0",
|
|
19
|
-
"zod": "
|
|
20
|
+
"zod": "^4.3.5"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
|
-
"@ontrails/core": "
|
|
23
|
-
"@ontrails/schema": "
|
|
23
|
+
"@ontrails/core": "^1.0.0-beta.8",
|
|
24
|
+
"@ontrails/schema": "^1.0.0-beta.8"
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -21,7 +21,7 @@ describe('runWarden', () => {
|
|
|
21
21
|
writeFileSync(
|
|
22
22
|
join(dir, 'bad.ts'),
|
|
23
23
|
`trail("entity.show", {
|
|
24
|
-
|
|
24
|
+
run: async (input, ctx) => {
|
|
25
25
|
throw new Error("boom");
|
|
26
26
|
}
|
|
27
27
|
})`
|
|
@@ -41,7 +41,7 @@ describe('runWarden', () => {
|
|
|
41
41
|
writeFileSync(
|
|
42
42
|
join(dir, 'good.ts'),
|
|
43
43
|
`trail("entity.show", {
|
|
44
|
-
|
|
44
|
+
run: async (input, ctx) => {
|
|
45
45
|
return Result.ok(data);
|
|
46
46
|
}
|
|
47
47
|
})`
|
|
@@ -72,7 +72,7 @@ describe('runWarden', () => {
|
|
|
72
72
|
// Even with bad code, driftOnly should produce 0 diagnostics
|
|
73
73
|
writeFileSync(
|
|
74
74
|
join(dir, 'bad.ts'),
|
|
75
|
-
`trail("x", {
|
|
75
|
+
`trail("x", { run: async () => { throw new Error("x"); } })`
|
|
76
76
|
);
|
|
77
77
|
const report = await runWarden({ driftOnly: true, rootDir: dir });
|
|
78
78
|
expect(report.diagnostics.length).toBe(0);
|
|
@@ -89,7 +89,7 @@ describe('runWarden', () => {
|
|
|
89
89
|
join(dir, 'show.ts'),
|
|
90
90
|
`trail("entity.show", {
|
|
91
91
|
detours: { NotFoundError: ["entity.search"] },
|
|
92
|
-
|
|
92
|
+
run: async (input, ctx) => {
|
|
93
93
|
return Result.ok(data);
|
|
94
94
|
}
|
|
95
95
|
})`
|
|
@@ -97,7 +97,7 @@ describe('runWarden', () => {
|
|
|
97
97
|
writeFileSync(
|
|
98
98
|
join(dir, 'search.ts'),
|
|
99
99
|
`trail("entity.search", {
|
|
100
|
-
|
|
100
|
+
run: async (input, ctx) => {
|
|
101
101
|
return Result.ok(data);
|
|
102
102
|
}
|
|
103
103
|
})`
|
|
@@ -121,7 +121,7 @@ describe('runWarden', () => {
|
|
|
121
121
|
join(dir, 'show.ts'),
|
|
122
122
|
`trail("entity.show", {
|
|
123
123
|
detours: { NotFoundError: ["entity.search"] },
|
|
124
|
-
|
|
124
|
+
run: async (input, ctx) => {
|
|
125
125
|
return Result.ok(data);
|
|
126
126
|
}
|
|
127
127
|
})`
|
|
@@ -129,7 +129,7 @@ describe('runWarden', () => {
|
|
|
129
129
|
writeFileSync(
|
|
130
130
|
join(dir, 'search.ts'),
|
|
131
131
|
`trail("entity.search", {
|
|
132
|
-
|
|
132
|
+
run: async (input, ctx) => {
|
|
133
133
|
throw new Error("boom");
|
|
134
134
|
}
|
|
135
135
|
})`
|
|
@@ -11,9 +11,9 @@ import { checkDrift } from '../drift.js';
|
|
|
11
11
|
|
|
12
12
|
const makeTopo = () => {
|
|
13
13
|
const t = trail('test.hello', {
|
|
14
|
-
implementation: () => Result.ok({ greeting: 'hi' }),
|
|
15
14
|
input: z.object({ name: z.string() }),
|
|
16
15
|
output: z.object({ greeting: z.string() }),
|
|
16
|
+
run: () => Result.ok({ greeting: 'hi' }),
|
|
17
17
|
});
|
|
18
18
|
return topo('test-app', { t });
|
|
19
19
|
};
|