@ontrails/warden 1.0.0-beta.13 → 1.0.0-beta.15
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 +30 -0
- package/README.md +31 -20
- package/dist/cli.d.ts +19 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +261 -64
- package/dist/cli.js.map +1 -1
- package/dist/draft.d.ts +5 -0
- package/dist/draft.d.ts.map +1 -0
- package/dist/draft.js +16 -0
- package/dist/draft.js.map +1 -0
- package/dist/drift.d.ts +10 -7
- package/dist/drift.d.ts.map +1 -1
- package/dist/drift.js +50 -16
- package/dist/drift.js.map +1 -1
- package/dist/formatters.d.ts +2 -1
- package/dist/formatters.d.ts.map +1 -1
- package/dist/formatters.js +15 -4
- package/dist/formatters.js.map +1 -1
- package/dist/index.d.ts +9 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -17
- package/dist/index.js.map +1 -1
- package/dist/rules/ast.d.ts +412 -7
- package/dist/rules/ast.d.ts.map +1 -1
- package/dist/rules/ast.js +1847 -102
- package/dist/rules/ast.js.map +1 -1
- package/dist/rules/circular-refs.d.ts +6 -0
- package/dist/rules/circular-refs.d.ts.map +1 -0
- package/dist/rules/circular-refs.js +83 -0
- package/dist/rules/circular-refs.js.map +1 -0
- package/dist/rules/context-no-surface-types.d.ts.map +1 -1
- package/dist/rules/context-no-surface-types.js +59 -3
- package/dist/rules/context-no-surface-types.js.map +1 -1
- package/dist/rules/contour-exists.d.ts +7 -0
- package/dist/rules/contour-exists.d.ts.map +1 -0
- package/dist/rules/contour-exists.js +113 -0
- package/dist/rules/contour-exists.js.map +1 -0
- package/dist/rules/contour-ids.d.ts +10 -0
- package/dist/rules/contour-ids.d.ts.map +1 -0
- package/dist/rules/contour-ids.js +12 -0
- package/dist/rules/contour-ids.js.map +1 -0
- package/dist/rules/cross-declarations.d.ts.map +1 -1
- package/dist/rules/cross-declarations.js +171 -57
- package/dist/rules/cross-declarations.js.map +1 -1
- package/dist/rules/dead-internal-trail.d.ts +3 -0
- package/dist/rules/dead-internal-trail.d.ts.map +1 -0
- package/dist/rules/dead-internal-trail.js +80 -0
- package/dist/rules/dead-internal-trail.js.map +1 -0
- package/dist/rules/draft-file-marking.d.ts +6 -0
- package/dist/rules/draft-file-marking.d.ts.map +1 -0
- package/dist/rules/draft-file-marking.js +87 -0
- package/dist/rules/draft-file-marking.js.map +1 -0
- package/dist/rules/draft-visible-debt.d.ts +12 -0
- package/dist/rules/draft-visible-debt.d.ts.map +1 -0
- package/dist/rules/draft-visible-debt.js +50 -0
- package/dist/rules/draft-visible-debt.js.map +1 -0
- package/dist/rules/error-mapping-completeness.d.ts +13 -0
- package/dist/rules/error-mapping-completeness.d.ts.map +1 -0
- package/dist/rules/error-mapping-completeness.js +160 -0
- package/dist/rules/error-mapping-completeness.js.map +1 -0
- package/dist/rules/example-valid.d.ts +6 -0
- package/dist/rules/example-valid.d.ts.map +1 -0
- package/dist/rules/example-valid.js +203 -0
- package/dist/rules/example-valid.js.map +1 -0
- package/dist/rules/fires-declarations.d.ts +16 -0
- package/dist/rules/fires-declarations.d.ts.map +1 -0
- package/dist/rules/fires-declarations.js +444 -0
- package/dist/rules/fires-declarations.js.map +1 -0
- package/dist/rules/implementation-returns-result.d.ts +9 -0
- package/dist/rules/implementation-returns-result.d.ts.map +1 -1
- package/dist/rules/implementation-returns-result.js +638 -76
- package/dist/rules/implementation-returns-result.js.map +1 -1
- package/dist/rules/incomplete-accessor-for-standard-op.d.ts +30 -0
- package/dist/rules/incomplete-accessor-for-standard-op.d.ts.map +1 -0
- package/dist/rules/incomplete-accessor-for-standard-op.js +226 -0
- package/dist/rules/incomplete-accessor-for-standard-op.js.map +1 -0
- package/dist/rules/incomplete-crud.d.ts +21 -0
- package/dist/rules/incomplete-crud.d.ts.map +1 -0
- package/dist/rules/incomplete-crud.js +368 -0
- package/dist/rules/incomplete-crud.js.map +1 -0
- package/dist/rules/index.d.ts +40 -7
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +91 -15
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/intent-propagation.d.ts +3 -0
- package/dist/rules/intent-propagation.d.ts.map +1 -0
- package/dist/rules/intent-propagation.js +57 -0
- package/dist/rules/intent-propagation.js.map +1 -0
- package/dist/rules/missing-reconcile.d.ts +3 -0
- package/dist/rules/missing-reconcile.d.ts.map +1 -0
- package/dist/rules/missing-reconcile.js +44 -0
- package/dist/rules/missing-reconcile.js.map +1 -0
- package/dist/rules/missing-visibility.d.ts +3 -0
- package/dist/rules/missing-visibility.d.ts.map +1 -0
- package/dist/rules/missing-visibility.js +63 -0
- package/dist/rules/missing-visibility.js.map +1 -0
- package/dist/rules/no-direct-impl-in-route.d.ts.map +1 -1
- package/dist/rules/no-direct-impl-in-route.js +0 -3
- package/dist/rules/no-direct-impl-in-route.js.map +1 -1
- package/dist/rules/no-direct-implementation-call.js +1 -1
- package/dist/rules/no-direct-implementation-call.js.map +1 -1
- package/dist/rules/no-sync-result-assumption.d.ts.map +1 -1
- package/dist/rules/no-sync-result-assumption.js +870 -61
- package/dist/rules/no-sync-result-assumption.js.map +1 -1
- package/dist/rules/no-throw-in-detour-recover.d.ts +3 -0
- package/dist/rules/no-throw-in-detour-recover.d.ts.map +1 -0
- package/dist/rules/no-throw-in-detour-recover.js +147 -0
- package/dist/rules/no-throw-in-detour-recover.js.map +1 -0
- package/dist/rules/no-throw-in-detour-target.d.ts +4 -1
- package/dist/rules/no-throw-in-detour-target.d.ts.map +1 -1
- package/dist/rules/no-throw-in-detour-target.js +6 -3
- package/dist/rules/no-throw-in-detour-target.js.map +1 -1
- package/dist/rules/no-throw-in-implementation.d.ts +4 -2
- package/dist/rules/no-throw-in-implementation.d.ts.map +1 -1
- package/dist/rules/no-throw-in-implementation.js +6 -4
- package/dist/rules/no-throw-in-implementation.js.map +1 -1
- package/dist/rules/on-references-exist.d.ts +14 -0
- package/dist/rules/on-references-exist.d.ts.map +1 -0
- package/dist/rules/on-references-exist.js +109 -0
- package/dist/rules/on-references-exist.js.map +1 -0
- package/dist/rules/orphaned-signal.d.ts +3 -0
- package/dist/rules/orphaned-signal.d.ts.map +1 -0
- package/dist/rules/orphaned-signal.js +67 -0
- package/dist/rules/orphaned-signal.js.map +1 -0
- package/dist/rules/permit-governance.d.ts +3 -0
- package/dist/rules/permit-governance.d.ts.map +1 -0
- package/dist/rules/permit-governance.js +15 -0
- package/dist/rules/permit-governance.js.map +1 -0
- package/dist/rules/reference-exists.d.ts +6 -0
- package/dist/rules/reference-exists.d.ts.map +1 -0
- package/dist/rules/reference-exists.js +47 -0
- package/dist/rules/reference-exists.js.map +1 -0
- package/dist/rules/registry-names.d.ts +8 -0
- package/dist/rules/registry-names.d.ts.map +1 -0
- package/dist/rules/registry-names.js +83 -0
- package/dist/rules/registry-names.js.map +1 -0
- package/dist/rules/resource-declarations.d.ts +14 -0
- package/dist/rules/resource-declarations.d.ts.map +1 -0
- package/dist/rules/resource-declarations.js +413 -0
- package/dist/rules/resource-declarations.js.map +1 -0
- package/dist/rules/resource-exists.d.ts +6 -0
- package/dist/rules/resource-exists.d.ts.map +1 -0
- package/dist/rules/resource-exists.js +90 -0
- package/dist/rules/resource-exists.js.map +1 -0
- package/dist/rules/resource-id-grammar.d.ts +3 -0
- package/dist/rules/resource-id-grammar.d.ts.map +1 -0
- package/dist/rules/resource-id-grammar.js +39 -0
- package/dist/rules/resource-id-grammar.js.map +1 -0
- package/dist/rules/specs.d.ts.map +1 -1
- package/dist/rules/specs.js +5 -1
- package/dist/rules/specs.js.map +1 -1
- package/dist/rules/types.d.ts +53 -4
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/unreachable-detour-shadowing.d.ts +3 -0
- package/dist/rules/unreachable-detour-shadowing.d.ts.map +1 -0
- package/dist/rules/unreachable-detour-shadowing.js +202 -0
- package/dist/rules/unreachable-detour-shadowing.js.map +1 -0
- package/dist/rules/valid-describe-refs.d.ts.map +1 -1
- package/dist/rules/valid-describe-refs.js +132 -16
- package/dist/rules/valid-describe-refs.js.map +1 -1
- package/dist/rules/valid-detour-contract.d.ts +3 -0
- package/dist/rules/valid-detour-contract.d.ts.map +1 -0
- package/dist/rules/valid-detour-contract.js +47 -0
- package/dist/rules/valid-detour-contract.js.map +1 -0
- package/dist/rules/valid-detour-refs.d.ts.map +1 -1
- package/dist/rules/valid-detour-refs.js +73 -82
- package/dist/rules/valid-detour-refs.js.map +1 -1
- package/dist/rules/warden-export-symmetry.d.ts +7 -0
- package/dist/rules/warden-export-symmetry.d.ts.map +1 -0
- package/dist/rules/warden-export-symmetry.js +352 -0
- package/dist/rules/warden-export-symmetry.js.map +1 -0
- package/dist/rules/warden-rules-use-ast.d.ts +17 -0
- package/dist/rules/warden-rules-use-ast.d.ts.map +1 -0
- package/dist/rules/warden-rules-use-ast.js +778 -0
- package/dist/rules/warden-rules-use-ast.js.map +1 -0
- package/dist/trails/circular-refs.trail.d.ts +24 -0
- package/dist/trails/circular-refs.trail.d.ts.map +1 -0
- package/dist/trails/circular-refs.trail.js +29 -0
- package/dist/trails/circular-refs.trail.js.map +1 -0
- package/dist/trails/context-no-surface-types.trail.d.ts +2 -2
- package/dist/trails/context-no-surface-types.trail.d.ts.map +1 -1
- package/dist/trails/context-no-trailhead-types.trail.d.ts +2 -2
- package/dist/trails/context-no-trailhead-types.trail.d.ts.map +1 -1
- package/dist/trails/contour-exists.trail.d.ts +24 -0
- package/dist/trails/contour-exists.trail.d.ts.map +1 -0
- package/dist/trails/contour-exists.trail.js +21 -0
- package/dist/trails/contour-exists.trail.js.map +1 -0
- package/dist/trails/cross-declarations.trail.d.ts +2 -2
- package/dist/trails/cross-declarations.trail.d.ts.map +1 -1
- package/dist/trails/dead-internal-trail.trail.d.ts +24 -0
- package/dist/trails/dead-internal-trail.trail.d.ts.map +1 -0
- package/dist/trails/dead-internal-trail.trail.js +26 -0
- package/dist/trails/dead-internal-trail.trail.js.map +1 -0
- package/dist/trails/{provision-declarations.trail.d.ts → draft-file-marking.trail.d.ts} +3 -3
- package/dist/trails/draft-file-marking.trail.d.ts.map +1 -0
- package/dist/trails/draft-file-marking.trail.js +16 -0
- package/dist/trails/draft-file-marking.trail.js.map +1 -0
- package/dist/trails/draft-visible-debt.trail.d.ts +13 -0
- package/dist/trails/draft-visible-debt.trail.d.ts.map +1 -0
- package/dist/trails/draft-visible-debt.trail.js +16 -0
- package/dist/trails/draft-visible-debt.trail.js.map +1 -0
- package/dist/trails/error-mapping-completeness.trail.d.ts +13 -0
- package/dist/trails/error-mapping-completeness.trail.d.ts.map +1 -0
- package/dist/trails/error-mapping-completeness.trail.js +29 -0
- package/dist/trails/error-mapping-completeness.trail.js.map +1 -0
- package/dist/trails/{follow-declarations.trail.d.ts → example-valid.trail.d.ts} +3 -3
- package/dist/trails/example-valid.trail.d.ts.map +1 -0
- package/dist/trails/example-valid.trail.js +25 -0
- package/dist/trails/example-valid.trail.js.map +1 -0
- package/dist/trails/fires-declarations.trail.d.ts +13 -0
- package/dist/trails/fires-declarations.trail.d.ts.map +1 -0
- package/dist/trails/fires-declarations.trail.js +22 -0
- package/dist/trails/fires-declarations.trail.js.map +1 -0
- package/dist/trails/implementation-returns-result.trail.d.ts +2 -2
- package/dist/trails/implementation-returns-result.trail.d.ts.map +1 -1
- package/dist/trails/incomplete-accessor-for-standard-op.trail.d.ts +12 -0
- package/dist/trails/incomplete-accessor-for-standard-op.trail.d.ts.map +1 -0
- package/dist/trails/incomplete-accessor-for-standard-op.trail.js +60 -0
- package/dist/trails/incomplete-accessor-for-standard-op.trail.js.map +1 -0
- package/dist/trails/incomplete-crud.trail.d.ts +24 -0
- package/dist/trails/incomplete-crud.trail.d.ts.map +1 -0
- package/dist/trails/incomplete-crud.trail.js +39 -0
- package/dist/trails/incomplete-crud.trail.js.map +1 -0
- package/dist/trails/index.d.ts +29 -7
- package/dist/trails/index.d.ts.map +1 -1
- package/dist/trails/index.js +28 -6
- package/dist/trails/index.js.map +1 -1
- package/dist/trails/intent-propagation.trail.d.ts +24 -0
- package/dist/trails/intent-propagation.trail.d.ts.map +1 -0
- package/dist/trails/intent-propagation.trail.js +30 -0
- package/dist/trails/intent-propagation.trail.js.map +1 -0
- package/dist/trails/missing-reconcile.trail.d.ts +24 -0
- package/dist/trails/missing-reconcile.trail.d.ts.map +1 -0
- package/dist/trails/missing-reconcile.trail.js +33 -0
- package/dist/trails/missing-reconcile.trail.js.map +1 -0
- package/dist/trails/missing-visibility.trail.d.ts +24 -0
- package/dist/trails/missing-visibility.trail.d.ts.map +1 -0
- package/dist/trails/missing-visibility.trail.js +22 -0
- package/dist/trails/missing-visibility.trail.js.map +1 -0
- package/dist/trails/no-direct-impl-in-route.trail.d.ts +2 -2
- package/dist/trails/no-direct-impl-in-route.trail.d.ts.map +1 -1
- package/dist/trails/no-direct-implementation-call.trail.d.ts +2 -2
- package/dist/trails/no-direct-implementation-call.trail.d.ts.map +1 -1
- package/dist/trails/no-sync-result-assumption.trail.d.ts +2 -2
- package/dist/trails/no-sync-result-assumption.trail.d.ts.map +1 -1
- package/dist/trails/no-throw-in-detour-recover.trail.d.ts +13 -0
- package/dist/trails/no-throw-in-detour-recover.trail.d.ts.map +1 -0
- package/dist/trails/no-throw-in-detour-recover.trail.js +24 -0
- package/dist/trails/no-throw-in-detour-recover.trail.js.map +1 -0
- package/dist/trails/no-throw-in-detour-target.trail.d.ts +13 -3
- package/dist/trails/no-throw-in-detour-target.trail.d.ts.map +1 -1
- package/dist/trails/no-throw-in-implementation.trail.d.ts +2 -2
- package/dist/trails/no-throw-in-implementation.trail.d.ts.map +1 -1
- package/dist/trails/on-references-exist.trail.d.ts +24 -0
- package/dist/trails/on-references-exist.trail.d.ts.map +1 -0
- package/dist/trails/on-references-exist.trail.js +21 -0
- package/dist/trails/on-references-exist.trail.js.map +1 -0
- package/dist/trails/orphaned-signal.trail.d.ts +24 -0
- package/dist/trails/orphaned-signal.trail.d.ts.map +1 -0
- package/dist/trails/orphaned-signal.trail.js +36 -0
- package/dist/trails/orphaned-signal.trail.js.map +1 -0
- package/dist/trails/permit-governance.trail.d.ts +12 -0
- package/dist/trails/permit-governance.trail.d.ts.map +1 -0
- package/dist/trails/permit-governance.trail.js +47 -0
- package/dist/trails/permit-governance.trail.js.map +1 -0
- package/dist/trails/prefer-schema-inference.trail.d.ts +2 -2
- package/dist/trails/prefer-schema-inference.trail.d.ts.map +1 -1
- package/dist/trails/reference-exists.trail.d.ts +24 -0
- package/dist/trails/reference-exists.trail.d.ts.map +1 -0
- package/dist/trails/reference-exists.trail.js +25 -0
- package/dist/trails/reference-exists.trail.js.map +1 -0
- package/dist/trails/resource-declarations.trail.d.ts +13 -0
- package/dist/trails/resource-declarations.trail.d.ts.map +1 -0
- package/dist/trails/{provision-declarations.trail.js → resource-declarations.trail.js} +7 -7
- package/dist/trails/resource-declarations.trail.js.map +1 -0
- package/dist/trails/resource-exists.trail.d.ts +24 -0
- package/dist/trails/resource-exists.trail.d.ts.map +1 -0
- package/dist/trails/{provision-exists.trail.js → resource-exists.trail.js} +8 -8
- package/dist/trails/resource-exists.trail.js.map +1 -0
- package/dist/trails/resource-id-grammar.trail.d.ts +13 -0
- package/dist/trails/resource-id-grammar.trail.d.ts.map +1 -0
- package/dist/trails/resource-id-grammar.trail.js +38 -0
- package/dist/trails/resource-id-grammar.trail.js.map +1 -0
- package/dist/trails/run.d.ts +25 -9
- package/dist/trails/run.d.ts.map +1 -1
- package/dist/trails/run.js +63 -19
- package/dist/trails/run.js.map +1 -1
- package/dist/trails/schema.d.ts +28 -3
- package/dist/trails/schema.d.ts.map +1 -1
- package/dist/trails/schema.js +57 -4
- package/dist/trails/schema.js.map +1 -1
- package/dist/trails/unreachable-detour-shadowing.trail.d.ts +13 -0
- package/dist/trails/unreachable-detour-shadowing.trail.d.ts.map +1 -0
- package/dist/trails/unreachable-detour-shadowing.trail.js +44 -0
- package/dist/trails/unreachable-detour-shadowing.trail.js.map +1 -0
- package/dist/trails/valid-describe-refs.trail.d.ts +12 -3
- package/dist/trails/valid-describe-refs.trail.d.ts.map +1 -1
- package/dist/trails/valid-detour-contract.trail.d.ts +12 -0
- package/dist/trails/valid-detour-contract.trail.d.ts.map +1 -0
- package/dist/trails/valid-detour-contract.trail.js +66 -0
- package/dist/trails/valid-detour-contract.trail.js.map +1 -0
- package/dist/trails/valid-detour-refs.trail.d.ts +13 -3
- package/dist/trails/valid-detour-refs.trail.d.ts.map +1 -1
- package/dist/trails/warden-export-symmetry.trail.d.ts +13 -0
- package/dist/trails/warden-export-symmetry.trail.d.ts.map +1 -0
- package/dist/trails/warden-export-symmetry.trail.js +16 -0
- package/dist/trails/warden-export-symmetry.trail.js.map +1 -0
- package/dist/trails/warden-rules-use-ast.trail.d.ts +13 -0
- package/dist/trails/warden-rules-use-ast.trail.d.ts.map +1 -0
- package/dist/trails/warden-rules-use-ast.trail.js +41 -0
- package/dist/trails/warden-rules-use-ast.trail.js.map +1 -0
- package/dist/trails/wrap-rule.d.ts +16 -2
- package/dist/trails/wrap-rule.d.ts.map +1 -1
- package/dist/trails/wrap-rule.js +71 -11
- package/dist/trails/wrap-rule.js.map +1 -1
- package/package.json +7 -4
- package/src/__tests__/ast.test.ts +613 -0
- package/src/__tests__/circular-refs.test.ts +121 -0
- package/src/__tests__/cli.test.ts +360 -32
- package/src/__tests__/contour-exists.test.ts +203 -0
- package/src/__tests__/cross-declarations.test.ts +245 -0
- package/src/__tests__/dead-internal-trail.test.ts +81 -0
- package/src/__tests__/draft-rules-context.test.ts +150 -0
- package/src/__tests__/drift.test.ts +75 -5
- package/src/__tests__/error-mapping-completeness.test.ts +56 -0
- package/src/__tests__/example-valid.test.ts +101 -0
- package/src/__tests__/fires-declarations-param-destructure.test.ts +54 -0
- package/src/__tests__/fires-declarations.test.ts +652 -0
- package/src/__tests__/formatters.test.ts +2 -2
- package/src/__tests__/implementation-returns-result.test.ts +1016 -2
- package/src/__tests__/incomplete-accessor-for-standard-op.test.ts +337 -0
- package/src/__tests__/incomplete-crud.test.ts +498 -0
- package/src/__tests__/intent-propagation.test.ts +116 -0
- package/src/__tests__/missing-reconcile.test.ts +154 -0
- package/src/__tests__/missing-visibility.test.ts +108 -0
- package/src/__tests__/no-sync-result-assumption.test.ts +870 -39
- package/src/__tests__/no-throw-in-detour-recover.test.ts +93 -0
- package/src/__tests__/no-throw-in-implementation.test.ts +88 -0
- package/src/__tests__/on-references-exist.test.ts +151 -0
- package/src/__tests__/orphaned-signal.test.ts +137 -0
- package/src/__tests__/permit-governance.test.ts +66 -0
- package/src/__tests__/reference-exists.test.ts +281 -0
- package/src/__tests__/resource-declarations.test.ts +448 -0
- package/src/__tests__/resource-exists.test.ts +122 -0
- package/src/__tests__/resource-id-grammar.test.ts +50 -0
- package/src/__tests__/rules.test.ts +17 -77
- package/src/__tests__/topo-aware-rule.test.ts +257 -0
- package/src/__tests__/trails.test.ts +2 -2
- package/src/__tests__/unreachable-detour-shadowing.test.ts +128 -0
- package/src/__tests__/valid-describe-refs.test.ts +183 -0
- package/src/__tests__/valid-detour-contract.test.ts +86 -0
- package/src/__tests__/warden-export-symmetry.test.ts +251 -0
- package/src/__tests__/warden-rules-use-ast.test.ts +468 -0
- package/src/__tests__/wrap-rule.test.ts +3 -3
- package/src/cli.ts +458 -91
- package/src/draft.ts +22 -0
- package/src/drift.ts +63 -21
- package/src/formatters.ts +15 -4
- package/src/index.ts +62 -23
- package/src/rules/ast.ts +2715 -119
- package/src/rules/circular-refs.ts +154 -0
- package/src/rules/{context-no-trailhead-types.ts → context-no-surface-types.ts} +72 -12
- package/src/rules/contour-exists.ts +251 -0
- package/src/rules/contour-ids.ts +15 -0
- package/src/rules/cross-declarations.ts +277 -69
- package/src/rules/dead-internal-trail.ts +141 -0
- package/src/rules/draft-file-marking.ts +160 -0
- package/src/rules/draft-visible-debt.ts +87 -0
- package/src/rules/error-mapping-completeness.ts +273 -0
- package/src/rules/example-valid.ts +401 -0
- package/src/rules/fires-declarations.ts +609 -0
- package/src/rules/implementation-returns-result.ts +1042 -122
- package/src/rules/incomplete-accessor-for-standard-op.ts +315 -0
- package/src/rules/incomplete-crud.ts +579 -0
- package/src/rules/index.ts +95 -16
- package/src/rules/intent-propagation.ts +142 -0
- package/src/rules/missing-reconcile.ts +98 -0
- package/src/rules/missing-visibility.ts +110 -0
- package/src/rules/no-direct-impl-in-route.ts +0 -4
- package/src/rules/no-direct-implementation-call.ts +1 -1
- package/src/rules/no-sync-result-assumption.ts +1134 -96
- package/src/rules/no-throw-in-detour-recover.ts +225 -0
- package/src/rules/no-throw-in-implementation.ts +6 -4
- package/src/rules/on-references-exist.ts +194 -0
- package/src/rules/orphaned-signal.ts +150 -0
- package/src/rules/permit-governance.ts +25 -0
- package/src/rules/reference-exists.ts +98 -0
- package/src/rules/registry-names.ts +83 -0
- package/src/rules/{provision-declarations.ts → resource-declarations.ts} +208 -138
- package/src/rules/{provision-exists.ts → resource-exists.ts} +48 -51
- package/src/rules/resource-id-grammar.ts +65 -0
- package/src/rules/specs.ts +5 -1
- package/src/rules/types.ts +57 -4
- package/src/rules/unreachable-detour-shadowing.ts +375 -0
- package/src/rules/valid-describe-refs.ts +160 -32
- package/src/rules/valid-detour-contract.ts +78 -0
- package/src/rules/warden-export-symmetry.ts +533 -0
- package/src/rules/warden-rules-use-ast.ts +996 -0
- package/src/trails/circular-refs.trail.ts +29 -0
- package/src/trails/{context-no-trailhead-types.trail.ts → context-no-surface-types.trail.ts} +4 -4
- package/src/trails/contour-exists.trail.ts +21 -0
- package/src/trails/dead-internal-trail.trail.ts +26 -0
- package/src/trails/draft-file-marking.trail.ts +16 -0
- package/src/trails/draft-visible-debt.trail.ts +16 -0
- package/src/trails/error-mapping-completeness.trail.ts +29 -0
- package/src/trails/example-valid.trail.ts +25 -0
- package/src/trails/fires-declarations.trail.ts +22 -0
- package/src/trails/incomplete-accessor-for-standard-op.trail.ts +76 -0
- package/src/trails/incomplete-crud.trail.ts +39 -0
- package/src/trails/index.ts +40 -7
- package/src/trails/intent-propagation.trail.ts +30 -0
- package/src/trails/missing-reconcile.trail.ts +33 -0
- package/src/trails/missing-visibility.trail.ts +22 -0
- package/src/trails/no-throw-in-detour-recover.trail.ts +24 -0
- package/src/trails/on-references-exist.trail.ts +21 -0
- package/src/trails/orphaned-signal.trail.ts +36 -0
- package/src/trails/permit-governance.trail.ts +51 -0
- package/src/trails/reference-exists.trail.ts +25 -0
- package/src/trails/{provision-declarations.trail.ts → resource-declarations.trail.ts} +6 -6
- package/src/trails/{provision-exists.trail.ts → resource-exists.trail.ts} +7 -7
- package/src/trails/resource-id-grammar.trail.ts +39 -0
- package/src/trails/run.ts +121 -24
- package/src/trails/schema.ts +66 -4
- package/src/trails/unreachable-detour-shadowing.trail.ts +45 -0
- package/src/trails/valid-detour-contract.trail.ts +71 -0
- package/src/trails/warden-export-symmetry.trail.ts +16 -0
- package/src/trails/warden-rules-use-ast.trail.ts +45 -0
- package/src/trails/wrap-rule.ts +104 -12
- package/tsconfig.tests.json +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/rules/follow-declarations.d.ts +0 -13
- package/dist/rules/follow-declarations.d.ts.map +0 -1
- package/dist/rules/follow-declarations.js +0 -264
- package/dist/rules/follow-declarations.js.map +0 -1
- package/dist/rules/provision-declarations.d.ts +0 -14
- package/dist/rules/provision-declarations.d.ts.map +0 -1
- package/dist/rules/provision-declarations.js +0 -344
- package/dist/rules/provision-declarations.js.map +0 -1
- package/dist/rules/provision-exists.d.ts +0 -6
- package/dist/rules/provision-exists.d.ts.map +0 -1
- package/dist/rules/provision-exists.js +0 -89
- package/dist/rules/provision-exists.js.map +0 -1
- package/dist/rules/service-declarations.d.ts +0 -16
- package/dist/rules/service-declarations.d.ts.map +0 -1
- package/dist/rules/service-declarations.js +0 -346
- package/dist/rules/service-declarations.js.map +0 -1
- package/dist/rules/service-exists.d.ts +0 -8
- package/dist/rules/service-exists.d.ts.map +0 -1
- package/dist/rules/service-exists.js +0 -91
- package/dist/rules/service-exists.js.map +0 -1
- package/dist/trails/follow-declarations.trail.d.ts.map +0 -1
- package/dist/trails/follow-declarations.trail.js +0 -22
- package/dist/trails/follow-declarations.trail.js.map +0 -1
- package/dist/trails/provision-declarations.trail.d.ts.map +0 -1
- package/dist/trails/provision-declarations.trail.js.map +0 -1
- package/dist/trails/provision-exists.trail.d.ts +0 -15
- package/dist/trails/provision-exists.trail.d.ts.map +0 -1
- package/dist/trails/provision-exists.trail.js.map +0 -1
- package/dist/trails/service-declarations.trail.d.ts +0 -26
- package/dist/trails/service-declarations.trail.d.ts.map +0 -1
- package/dist/trails/service-declarations.trail.js +0 -27
- package/dist/trails/service-declarations.trail.js.map +0 -1
- package/dist/trails/service-exists.trail.d.ts +0 -32
- package/dist/trails/service-exists.trail.d.ts.map +0 -1
- package/dist/trails/service-exists.trail.js +0 -29
- package/dist/trails/service-exists.trail.js.map +0 -1
- package/src/__tests__/no-throw-in-detour-target.test.ts +0 -78
- package/src/__tests__/provision-declarations.test.ts +0 -318
- package/src/__tests__/provision-exists.test.ts +0 -122
- package/src/rules/no-throw-in-detour-target.ts +0 -150
- package/src/rules/valid-detour-refs.ts +0 -187
- package/src/trails/no-throw-in-detour-target.trail.ts +0 -20
- package/src/trails/valid-detour-refs.trail.ts +0 -24
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { noThrowInDetourRecover } from '../rules/no-throw-in-detour-recover.js';
|
|
4
|
+
|
|
5
|
+
const TEST_FILE = 'detour.ts';
|
|
6
|
+
|
|
7
|
+
describe('no-throw-in-detour-recover', () => {
|
|
8
|
+
test('flags throw inside an inline detour recover function', () => {
|
|
9
|
+
const code = `
|
|
10
|
+
trail("entity.save", {
|
|
11
|
+
detours: [
|
|
12
|
+
{
|
|
13
|
+
on: ConflictError,
|
|
14
|
+
recover: async () => {
|
|
15
|
+
throw new Error("boom");
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
blaze: () => Result.err(new ConflictError("conflict")),
|
|
20
|
+
})`;
|
|
21
|
+
|
|
22
|
+
const diagnostics = noThrowInDetourRecover.check(code, TEST_FILE);
|
|
23
|
+
|
|
24
|
+
expect(diagnostics).toHaveLength(1);
|
|
25
|
+
expect(diagnostics[0]?.rule).toBe('no-throw-in-detour-recover');
|
|
26
|
+
expect(diagnostics[0]?.severity).toBe('error');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('flags throw inside a detour recover function declaration binding', () => {
|
|
30
|
+
const code = `
|
|
31
|
+
async function recoverConflict() {
|
|
32
|
+
throw new Error("boom");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
trail("entity.save", {
|
|
36
|
+
detours: [
|
|
37
|
+
{
|
|
38
|
+
on: ConflictError,
|
|
39
|
+
recover: recoverConflict,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
blaze: () => Result.err(new ConflictError("conflict")),
|
|
43
|
+
})`;
|
|
44
|
+
|
|
45
|
+
const diagnostics = noThrowInDetourRecover.check(code, TEST_FILE);
|
|
46
|
+
|
|
47
|
+
expect(diagnostics).toHaveLength(1);
|
|
48
|
+
expect(diagnostics[0]?.message).toContain('detour[0]');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('does not flag throw inside a nested callback within recover', () => {
|
|
52
|
+
const code = `
|
|
53
|
+
trail("entity.save", {
|
|
54
|
+
detours: [
|
|
55
|
+
{
|
|
56
|
+
on: ConflictError,
|
|
57
|
+
recover: async () => {
|
|
58
|
+
[1].map(() => {
|
|
59
|
+
throw new Error("inner");
|
|
60
|
+
});
|
|
61
|
+
return Result.err(new ConflictError("still conflicting"));
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
blaze: () => Result.err(new ConflictError("conflict")),
|
|
66
|
+
})`;
|
|
67
|
+
|
|
68
|
+
const diagnostics = noThrowInDetourRecover.check(code, TEST_FILE);
|
|
69
|
+
|
|
70
|
+
expect(diagnostics).toEqual([]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('ignores throws outside detour recover functions', () => {
|
|
74
|
+
const code = `
|
|
75
|
+
function helper() {
|
|
76
|
+
throw new Error("boom");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
trail("entity.save", {
|
|
80
|
+
detours: [
|
|
81
|
+
{
|
|
82
|
+
on: ConflictError,
|
|
83
|
+
recover: async () => Result.err(new ConflictError("still conflicting")),
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
blaze: () => Result.err(new ConflictError("conflict")),
|
|
87
|
+
})`;
|
|
88
|
+
|
|
89
|
+
const diagnostics = noThrowInDetourRecover.check(code, TEST_FILE);
|
|
90
|
+
|
|
91
|
+
expect(diagnostics).toEqual([]);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { noThrowInImplementation } from '../rules/no-throw-in-implementation.js';
|
|
4
|
+
|
|
5
|
+
const TEST_FILE = 'test.ts';
|
|
6
|
+
|
|
7
|
+
describe('no-throw-in-implementation', () => {
|
|
8
|
+
test('flags direct throw inside blaze body', () => {
|
|
9
|
+
const code = `
|
|
10
|
+
trail("entity.show", {
|
|
11
|
+
blaze: async (input, ctx) => {
|
|
12
|
+
throw new Error("boom");
|
|
13
|
+
}
|
|
14
|
+
})`;
|
|
15
|
+
const diagnostics = noThrowInImplementation.check(code, TEST_FILE);
|
|
16
|
+
expect(diagnostics.length).toBe(1);
|
|
17
|
+
expect(diagnostics[0]?.rule).toBe('no-throw-in-implementation');
|
|
18
|
+
expect(diagnostics[0]?.severity).toBe('error');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('allows Result.err() in blaze body', () => {
|
|
22
|
+
const code = `
|
|
23
|
+
trail("entity.show", {
|
|
24
|
+
blaze: async (input, ctx) => {
|
|
25
|
+
return Result.err(new NotFoundError("not found"));
|
|
26
|
+
}
|
|
27
|
+
})`;
|
|
28
|
+
const diagnostics = noThrowInImplementation.check(code, TEST_FILE);
|
|
29
|
+
expect(diagnostics.length).toBe(0);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('does not flag throw inside a nested .map() callback', () => {
|
|
33
|
+
const code = `
|
|
34
|
+
trail("demo", {
|
|
35
|
+
blaze: async () => {
|
|
36
|
+
[1].map(() => {
|
|
37
|
+
throw new Error("boom");
|
|
38
|
+
});
|
|
39
|
+
return Result.ok({ ok: true });
|
|
40
|
+
}
|
|
41
|
+
})`;
|
|
42
|
+
const diagnostics = noThrowInImplementation.check(code, TEST_FILE);
|
|
43
|
+
expect(diagnostics).toHaveLength(0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('does not flag throw inside a nested .filter() callback', () => {
|
|
47
|
+
const code = `
|
|
48
|
+
trail("demo", {
|
|
49
|
+
blaze: async () => {
|
|
50
|
+
[1].filter(() => {
|
|
51
|
+
throw new Error("boom");
|
|
52
|
+
});
|
|
53
|
+
return Result.ok({ ok: true });
|
|
54
|
+
}
|
|
55
|
+
})`;
|
|
56
|
+
const diagnostics = noThrowInImplementation.check(code, TEST_FILE);
|
|
57
|
+
expect(diagnostics).toHaveLength(0);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('does not flag throw inside a nested function declaration', () => {
|
|
61
|
+
const code = `
|
|
62
|
+
trail("demo", {
|
|
63
|
+
blaze: async () => {
|
|
64
|
+
function helper() {
|
|
65
|
+
throw new Error("boom");
|
|
66
|
+
}
|
|
67
|
+
return Result.ok({ ok: true });
|
|
68
|
+
}
|
|
69
|
+
})`;
|
|
70
|
+
const diagnostics = noThrowInImplementation.check(code, TEST_FILE);
|
|
71
|
+
expect(diagnostics).toHaveLength(0);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('still flags direct throw alongside a safe nested callback', () => {
|
|
75
|
+
const code = `
|
|
76
|
+
trail("demo", {
|
|
77
|
+
blaze: async () => {
|
|
78
|
+
[1].map(() => {
|
|
79
|
+
throw new Error("inner — allowed");
|
|
80
|
+
});
|
|
81
|
+
throw new Error("outer — flagged");
|
|
82
|
+
}
|
|
83
|
+
})`;
|
|
84
|
+
const diagnostics = noThrowInImplementation.check(code, TEST_FILE);
|
|
85
|
+
expect(diagnostics).toHaveLength(1);
|
|
86
|
+
expect(diagnostics[0]?.rule).toBe('no-throw-in-implementation');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { onReferencesExist } from '../rules/on-references-exist.js';
|
|
4
|
+
|
|
5
|
+
const TEST_FILE = 'consumer.ts';
|
|
6
|
+
|
|
7
|
+
describe('on-references-exist', () => {
|
|
8
|
+
test('passes when a locally defined signal is referenced', () => {
|
|
9
|
+
const code = `
|
|
10
|
+
import { signal, trail, Result } from '@ontrails/core';
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
|
|
13
|
+
const created = signal('entity.created', { payload: z.object({ id: z.string() }) });
|
|
14
|
+
|
|
15
|
+
trail('notify', {
|
|
16
|
+
on: ['entity.created'],
|
|
17
|
+
input: z.object({ id: z.string() }),
|
|
18
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
19
|
+
});
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
expect(onReferencesExist.check(code, TEST_FILE)).toEqual([]);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('flags an on: reference missing from project context', () => {
|
|
26
|
+
const code = `
|
|
27
|
+
import { trail, Result } from '@ontrails/core';
|
|
28
|
+
|
|
29
|
+
trail('notify', {
|
|
30
|
+
on: ['entity.created'],
|
|
31
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
32
|
+
});
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
const diagnostics = onReferencesExist.checkWithContext(code, TEST_FILE, {
|
|
36
|
+
knownSignalIds: new Set(['some.other.signal']),
|
|
37
|
+
knownTrailIds: new Set(['notify']),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(diagnostics).toHaveLength(1);
|
|
41
|
+
expect(diagnostics[0]?.rule).toBe('on-references-exist');
|
|
42
|
+
expect(diagnostics[0]?.severity).toBe('error');
|
|
43
|
+
expect(diagnostics[0]?.message).toContain('entity.created');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('passes when project context includes the referenced signal', () => {
|
|
47
|
+
const code = `
|
|
48
|
+
import { trail, Result } from '@ontrails/core';
|
|
49
|
+
|
|
50
|
+
trail('notify', {
|
|
51
|
+
on: ['entity.created'],
|
|
52
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
53
|
+
});
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const diagnostics = onReferencesExist.checkWithContext(code, TEST_FILE, {
|
|
57
|
+
knownSignalIds: new Set(['entity.created']),
|
|
58
|
+
knownTrailIds: new Set(['notify']),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
expect(diagnostics).toEqual([]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('flags only the unresolved id when multiple references are present', () => {
|
|
65
|
+
const code = `
|
|
66
|
+
import { trail, Result } from '@ontrails/core';
|
|
67
|
+
|
|
68
|
+
trail('notify', {
|
|
69
|
+
on: ['entity.created', 'audit.logged'],
|
|
70
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
71
|
+
});
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const diagnostics = onReferencesExist.checkWithContext(code, TEST_FILE, {
|
|
75
|
+
knownSignalIds: new Set(['entity.created']),
|
|
76
|
+
knownTrailIds: new Set(['notify']),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
expect(diagnostics).toHaveLength(1);
|
|
80
|
+
expect(diagnostics[0]?.message).toContain('audit.logged');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('skips trails with no on: declaration', () => {
|
|
84
|
+
const code = `
|
|
85
|
+
import { trail, Result } from '@ontrails/core';
|
|
86
|
+
|
|
87
|
+
trail('plain', {
|
|
88
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
89
|
+
});
|
|
90
|
+
`;
|
|
91
|
+
|
|
92
|
+
expect(
|
|
93
|
+
onReferencesExist.checkWithContext(code, TEST_FILE, {
|
|
94
|
+
knownSignalIds: new Set(),
|
|
95
|
+
knownTrailIds: new Set(['plain']),
|
|
96
|
+
})
|
|
97
|
+
).toEqual([]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('resolves const identifiers in on: array', () => {
|
|
101
|
+
const code = `
|
|
102
|
+
import { trail, Result } from '@ontrails/core';
|
|
103
|
+
|
|
104
|
+
const ENTITY_CREATED = 'entity.created';
|
|
105
|
+
|
|
106
|
+
trail('notify', {
|
|
107
|
+
on: [ENTITY_CREATED],
|
|
108
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
109
|
+
});
|
|
110
|
+
`;
|
|
111
|
+
|
|
112
|
+
const diagnostics = onReferencesExist.checkWithContext(code, TEST_FILE, {
|
|
113
|
+
knownSignalIds: new Set(['entity.created']),
|
|
114
|
+
knownTrailIds: new Set(['notify']),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
expect(diagnostics).toEqual([]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('skips test files', () => {
|
|
121
|
+
const code = `
|
|
122
|
+
trail('notify', {
|
|
123
|
+
on: ['unknown.signal'],
|
|
124
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
125
|
+
});
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
expect(
|
|
129
|
+
onReferencesExist.check(code, 'src/__tests__/notify.test.ts')
|
|
130
|
+
).toEqual([]);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('skips object-form Signal value references without error', () => {
|
|
134
|
+
const code = `
|
|
135
|
+
import { trail, signal, Result } from '@ontrails/core';
|
|
136
|
+
const orderPlaced = signal('order.placed', { payload: z.object({}) });
|
|
137
|
+
trail('notify', {
|
|
138
|
+
on: [orderPlaced],
|
|
139
|
+
blaze: async (input, ctx) => Result.ok({}),
|
|
140
|
+
});
|
|
141
|
+
`;
|
|
142
|
+
|
|
143
|
+
// Even without registering 'order.placed' as known, the object-form entry
|
|
144
|
+
// is skipped — runtime normalization is the source of truth.
|
|
145
|
+
const diagnostics = onReferencesExist.checkWithContext(code, TEST_FILE, {
|
|
146
|
+
knownSignalIds: new Set(),
|
|
147
|
+
knownTrailIds: new Set(['notify']),
|
|
148
|
+
});
|
|
149
|
+
expect(diagnostics).toEqual([]);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { orphanedSignal } from '../rules/orphaned-signal.js';
|
|
4
|
+
|
|
5
|
+
const TEST_FILE = 'store.ts';
|
|
6
|
+
|
|
7
|
+
describe('orphaned-signal', () => {
|
|
8
|
+
test('warns when a crud-backed store table has no reactive consumers for its change signals', () => {
|
|
9
|
+
const code = `
|
|
10
|
+
import { Result, resource } from '@ontrails/core';
|
|
11
|
+
import { store } from '@ontrails/store';
|
|
12
|
+
import { crud } from '@ontrails/store/trails';
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
|
|
15
|
+
const definition = store({
|
|
16
|
+
notes: {
|
|
17
|
+
identity: 'id',
|
|
18
|
+
schema: z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
title: z.string(),
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const notesResource = resource('db.notes', {
|
|
26
|
+
create: () => Result.ok({}),
|
|
27
|
+
mock: () => ({}),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const noteTrails = crud(definition.tables.notes, notesResource);
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const diagnostics = orphanedSignal.check(code, TEST_FILE);
|
|
34
|
+
|
|
35
|
+
expect(diagnostics).toHaveLength(1);
|
|
36
|
+
expect(diagnostics[0]?.rule).toBe('orphaned-signal');
|
|
37
|
+
expect(diagnostics[0]?.severity).toBe('warn');
|
|
38
|
+
expect(diagnostics[0]?.message).toContain('notes');
|
|
39
|
+
expect(diagnostics[0]?.message).toContain('notes.created');
|
|
40
|
+
expect(diagnostics[0]?.message).toContain('notes.updated');
|
|
41
|
+
expect(diagnostics[0]?.message).toContain('notes.removed');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('stays quiet when all derived change signals are consumed elsewhere in the project', () => {
|
|
45
|
+
const code = `
|
|
46
|
+
import { store } from '@ontrails/store';
|
|
47
|
+
import { z } from 'zod';
|
|
48
|
+
|
|
49
|
+
const definition = store({
|
|
50
|
+
notes: {
|
|
51
|
+
identity: 'id',
|
|
52
|
+
schema: z.object({
|
|
53
|
+
id: z.string(),
|
|
54
|
+
title: z.string(),
|
|
55
|
+
}),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
const diagnostics = orphanedSignal.checkWithContext(code, TEST_FILE, {
|
|
61
|
+
// Keys are composite (`${storeBinding}:${tableName}`) so two stores
|
|
62
|
+
// that share a table name don't collide across files.
|
|
63
|
+
crudTableIds: new Set(['definition:notes']),
|
|
64
|
+
knownTrailIds: new Set(['notes.notify']),
|
|
65
|
+
onTargetSignalIds: new Set([
|
|
66
|
+
'definition:notes.created',
|
|
67
|
+
'definition:notes.updated',
|
|
68
|
+
'definition:notes.removed',
|
|
69
|
+
]),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(diagnostics).toEqual([]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('tracks two stores with colliding table names independently', () => {
|
|
76
|
+
const code = `
|
|
77
|
+
import { Result, resource } from '@ontrails/core';
|
|
78
|
+
import { store } from '@ontrails/store';
|
|
79
|
+
import { crud } from '@ontrails/store/trails';
|
|
80
|
+
import { z } from 'zod';
|
|
81
|
+
|
|
82
|
+
const primary = store({
|
|
83
|
+
notes: {
|
|
84
|
+
identity: 'id',
|
|
85
|
+
schema: z.object({ id: z.string(), title: z.string() }),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const archive = store({
|
|
90
|
+
notes: {
|
|
91
|
+
identity: 'id',
|
|
92
|
+
schema: z.object({ id: z.string(), title: z.string() }),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const primaryResource = resource('db.primary', {
|
|
97
|
+
create: () => Result.ok({}),
|
|
98
|
+
mock: () => ({}),
|
|
99
|
+
});
|
|
100
|
+
const archiveResource = resource('db.archive', {
|
|
101
|
+
create: () => Result.ok({}),
|
|
102
|
+
mock: () => ({}),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const primaryTrails = crud(primary.tables.notes, primaryResource);
|
|
106
|
+
const archiveTrails = crud(archive.tables.notes, archiveResource);
|
|
107
|
+
`;
|
|
108
|
+
|
|
109
|
+
const diagnostics = orphanedSignal.check(code, TEST_FILE);
|
|
110
|
+
|
|
111
|
+
// Both stores warn, but independently — not one combined message.
|
|
112
|
+
expect(diagnostics).toHaveLength(2);
|
|
113
|
+
for (const diagnostic of diagnostics) {
|
|
114
|
+
expect(diagnostic.rule).toBe('orphaned-signal');
|
|
115
|
+
expect(diagnostic.message).toContain('notes');
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('stays quiet when the table is not used with crud()', () => {
|
|
120
|
+
const code = `
|
|
121
|
+
import { store } from '@ontrails/store';
|
|
122
|
+
import { z } from 'zod';
|
|
123
|
+
|
|
124
|
+
const definition = store({
|
|
125
|
+
notes: {
|
|
126
|
+
identity: 'id',
|
|
127
|
+
schema: z.object({
|
|
128
|
+
id: z.string(),
|
|
129
|
+
title: z.string(),
|
|
130
|
+
}),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
expect(orphanedSignal.check(code, TEST_FILE)).toEqual([]);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
|
|
6
|
+
import { Result, topo, trail } from '@ontrails/core';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
import { runWarden } from '../cli.js';
|
|
10
|
+
import { permitGovernance } from '../rules/permit-governance.js';
|
|
11
|
+
|
|
12
|
+
describe('permitGovernance', () => {
|
|
13
|
+
test('emits permit diagnostics from the compiled topo', async () => {
|
|
14
|
+
const destroyTrail = trail('entity.delete', {
|
|
15
|
+
blaze: () => Result.ok({ ok: true }),
|
|
16
|
+
input: z.object({}),
|
|
17
|
+
intent: 'destroy',
|
|
18
|
+
output: z.object({ ok: z.boolean() }),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const diagnostics = await permitGovernance.checkTopo(
|
|
22
|
+
topo('permit-topo', { destroyTrail })
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(diagnostics).toEqual([
|
|
26
|
+
{
|
|
27
|
+
filePath: '<topo>',
|
|
28
|
+
line: 1,
|
|
29
|
+
message:
|
|
30
|
+
'Trail "entity.delete" has intent \'destroy\' but no permit declaration',
|
|
31
|
+
rule: 'permit.destroyWithoutPermit',
|
|
32
|
+
severity: 'error',
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('runWarden includes permit governance when topo is supplied', async () => {
|
|
38
|
+
const rootDir = mkdtempSync(join(tmpdir(), 'warden-permit-'));
|
|
39
|
+
const destroyTrail = trail('entity.delete', {
|
|
40
|
+
blaze: () => Result.ok({ ok: true }),
|
|
41
|
+
input: z.object({}),
|
|
42
|
+
intent: 'destroy',
|
|
43
|
+
output: z.object({ ok: z.boolean() }),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
const report = await runWarden({
|
|
48
|
+
rootDir,
|
|
49
|
+
topo: topo('permit-topo', { destroyTrail }),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
expect(report.diagnostics).toEqual(
|
|
53
|
+
expect.arrayContaining([
|
|
54
|
+
expect.objectContaining({
|
|
55
|
+
message: expect.stringContaining('no permit declaration'),
|
|
56
|
+
rule: 'permit.destroyWithoutPermit',
|
|
57
|
+
severity: 'error',
|
|
58
|
+
}),
|
|
59
|
+
])
|
|
60
|
+
);
|
|
61
|
+
expect(report.errorCount).toBeGreaterThan(0);
|
|
62
|
+
} finally {
|
|
63
|
+
rmSync(rootDir, { force: true, recursive: true });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|