@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,498 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { incompleteCrud } from '../rules/incomplete-crud.js';
|
|
4
|
+
import type { ProjectContext } from '../rules/types.js';
|
|
5
|
+
|
|
6
|
+
const TEST_FILE = 'entity.ts';
|
|
7
|
+
|
|
8
|
+
const buildContext = (
|
|
9
|
+
coverage: Record<string, readonly string[]>
|
|
10
|
+
): ProjectContext => ({
|
|
11
|
+
crudCoverageByEntity: new Map(
|
|
12
|
+
Object.entries(coverage).map(([entityId, operations]) => [
|
|
13
|
+
entityId,
|
|
14
|
+
new Set(operations) as ReadonlySet<string>,
|
|
15
|
+
])
|
|
16
|
+
),
|
|
17
|
+
knownTrailIds: new Set<string>(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const splitFileSource = (operation: string): string => `
|
|
21
|
+
import { Result, contour, resource } from '@ontrails/core';
|
|
22
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
|
|
25
|
+
const note = contour('note', {
|
|
26
|
+
body: z.string(),
|
|
27
|
+
id: z.string(),
|
|
28
|
+
title: z.string(),
|
|
29
|
+
}, { identity: 'id' });
|
|
30
|
+
|
|
31
|
+
const notesResource = resource('db.notes', {
|
|
32
|
+
create: () => Result.ok({}),
|
|
33
|
+
mock: () => ({}),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const ${operation}Note = deriveTrail(note, '${operation}', {
|
|
37
|
+
blaze: async () => Result.ok({}),
|
|
38
|
+
resource: notesResource,
|
|
39
|
+
});
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const importedSplitFileSource = (
|
|
43
|
+
operation: string,
|
|
44
|
+
source = './shared/contours.js'
|
|
45
|
+
): string => `
|
|
46
|
+
import { Result, resource } from '@ontrails/core';
|
|
47
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
48
|
+
import { note } from '${source}';
|
|
49
|
+
|
|
50
|
+
const notesResource = resource('db.notes', {
|
|
51
|
+
create: () => Result.ok({}),
|
|
52
|
+
mock: () => ({}),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const ${operation}Note = deriveTrail(note, '${operation}', {
|
|
56
|
+
blaze: async () => Result.ok({}),
|
|
57
|
+
resource: notesResource,
|
|
58
|
+
});
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const suffixedBindingSplitFileSource = (operation: string): string => `
|
|
62
|
+
import { Result, contour, resource } from '@ontrails/core';
|
|
63
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
64
|
+
import { z } from 'zod';
|
|
65
|
+
|
|
66
|
+
const noteContour = contour('note', {
|
|
67
|
+
body: z.string(),
|
|
68
|
+
id: z.string(),
|
|
69
|
+
title: z.string(),
|
|
70
|
+
}, { identity: 'id' });
|
|
71
|
+
|
|
72
|
+
const notesResource = resource('db.notes', {
|
|
73
|
+
create: () => Result.ok({}),
|
|
74
|
+
mock: () => ({}),
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
export const ${operation}Note = deriveTrail(noteContour, '${operation}', {
|
|
78
|
+
blaze: async () => Result.ok({}),
|
|
79
|
+
resource: notesResource,
|
|
80
|
+
});
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
const importedSuffixedBindingSplitFileSource = (operation: string): string => `
|
|
84
|
+
import { Result, resource } from '@ontrails/core';
|
|
85
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
86
|
+
import { noteContour } from './shared/contours.js';
|
|
87
|
+
|
|
88
|
+
const notesResource = resource('db.notes', {
|
|
89
|
+
create: () => Result.ok({}),
|
|
90
|
+
mock: () => ({}),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const ${operation}Note = deriveTrail(noteContour, '${operation}', {
|
|
94
|
+
blaze: async () => Result.ok({}),
|
|
95
|
+
resource: notesResource,
|
|
96
|
+
});
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
describe('incomplete-crud', () => {
|
|
100
|
+
test('warns when deriveTrail only covers part of the CRUD set', () => {
|
|
101
|
+
const code = `
|
|
102
|
+
import { Result, contour, resource } from '@ontrails/core';
|
|
103
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
104
|
+
import { z } from 'zod';
|
|
105
|
+
|
|
106
|
+
const note = contour('note', {
|
|
107
|
+
body: z.string(),
|
|
108
|
+
id: z.string(),
|
|
109
|
+
title: z.string(),
|
|
110
|
+
}, { identity: 'id' });
|
|
111
|
+
|
|
112
|
+
const notesResource = resource('db.notes', {
|
|
113
|
+
create: () => Result.ok({}),
|
|
114
|
+
mock: () => ({}),
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export const createNote = deriveTrail(note, 'create', {
|
|
118
|
+
blaze: async () => Result.ok({}),
|
|
119
|
+
resource: notesResource,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
export const readNote = deriveTrail(note, 'read', {
|
|
123
|
+
blaze: async () => Result.ok({}),
|
|
124
|
+
resource: notesResource,
|
|
125
|
+
});
|
|
126
|
+
`;
|
|
127
|
+
|
|
128
|
+
const diagnostics = incompleteCrud.check(code, TEST_FILE);
|
|
129
|
+
|
|
130
|
+
expect(diagnostics).toHaveLength(1);
|
|
131
|
+
expect(diagnostics[0]?.rule).toBe('incomplete-crud');
|
|
132
|
+
expect(diagnostics[0]?.severity).toBe('warn');
|
|
133
|
+
expect(diagnostics[0]?.message).toContain('note');
|
|
134
|
+
expect(diagnostics[0]?.message).toContain('create');
|
|
135
|
+
expect(diagnostics[0]?.message).toContain('read');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('warns when crud() tuple destructuring captures only part of the standard trails', () => {
|
|
139
|
+
const code = `
|
|
140
|
+
import { Result, resource } from '@ontrails/core';
|
|
141
|
+
import { store } from '@ontrails/store';
|
|
142
|
+
import { crud } from '@ontrails/store/trails';
|
|
143
|
+
import { z } from 'zod';
|
|
144
|
+
|
|
145
|
+
const db = store({
|
|
146
|
+
notes: {
|
|
147
|
+
identity: 'id',
|
|
148
|
+
schema: z.object({
|
|
149
|
+
id: z.string(),
|
|
150
|
+
title: z.string(),
|
|
151
|
+
}),
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
const notesResource = resource('db.notes', {
|
|
156
|
+
create: () => Result.ok({}),
|
|
157
|
+
mock: () => ({}),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const [createNote, readNote] = crud(db.tables.notes, notesResource);
|
|
161
|
+
`;
|
|
162
|
+
|
|
163
|
+
const diagnostics = incompleteCrud.check(code, TEST_FILE);
|
|
164
|
+
|
|
165
|
+
expect(diagnostics).toHaveLength(1);
|
|
166
|
+
expect(diagnostics[0]?.rule).toBe('incomplete-crud');
|
|
167
|
+
expect(diagnostics[0]?.message).toContain('notes');
|
|
168
|
+
expect(diagnostics[0]?.message).toContain('create');
|
|
169
|
+
expect(diagnostics[0]?.message).toContain('read');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('stays quiet when the full CRUD tuple is captured', () => {
|
|
173
|
+
const code = `
|
|
174
|
+
import { Result, resource } from '@ontrails/core';
|
|
175
|
+
import { store } from '@ontrails/store';
|
|
176
|
+
import { crud } from '@ontrails/store/trails';
|
|
177
|
+
import { z } from 'zod';
|
|
178
|
+
|
|
179
|
+
const db = store({
|
|
180
|
+
notes: {
|
|
181
|
+
identity: 'id',
|
|
182
|
+
schema: z.object({
|
|
183
|
+
id: z.string(),
|
|
184
|
+
title: z.string(),
|
|
185
|
+
}),
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const notesResource = resource('db.notes', {
|
|
190
|
+
create: () => Result.ok({}),
|
|
191
|
+
mock: () => ({}),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const [createNote, readNote, updateNote, deleteNote, listNote] = crud(
|
|
195
|
+
db.tables.notes,
|
|
196
|
+
notesResource
|
|
197
|
+
);
|
|
198
|
+
`;
|
|
199
|
+
|
|
200
|
+
expect(incompleteCrud.check(code, TEST_FILE)).toEqual([]);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test('tracks deriveTrail coverage for imported contours as pending-resolution', () => {
|
|
204
|
+
const code = `
|
|
205
|
+
import { Result, resource } from '@ontrails/core';
|
|
206
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
207
|
+
import { note } from './shared/contours.js';
|
|
208
|
+
|
|
209
|
+
const notesResource = resource('db.notes', {
|
|
210
|
+
create: () => Result.ok({}),
|
|
211
|
+
mock: () => ({}),
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
export const createNote = deriveTrail(note, 'create', {
|
|
215
|
+
blaze: async () => Result.ok({}),
|
|
216
|
+
resource: notesResource,
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
export const readNote = deriveTrail(note, 'read', {
|
|
220
|
+
blaze: async () => Result.ok({}),
|
|
221
|
+
resource: notesResource,
|
|
222
|
+
});
|
|
223
|
+
`;
|
|
224
|
+
|
|
225
|
+
const diagnostics = incompleteCrud.check(code, TEST_FILE);
|
|
226
|
+
|
|
227
|
+
expect(diagnostics).toHaveLength(1);
|
|
228
|
+
expect(diagnostics[0]?.rule).toBe('incomplete-crud');
|
|
229
|
+
// Imported contours surface as pending-resolution so coverage is still tracked.
|
|
230
|
+
expect(diagnostics[0]?.message).toContain('note');
|
|
231
|
+
expect(diagnostics[0]?.message).toContain('pending-resolution');
|
|
232
|
+
expect(diagnostics[0]?.message).toContain('create');
|
|
233
|
+
expect(diagnostics[0]?.message).toContain('read');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test('does not warn when imported contour covers the full CRUD set', () => {
|
|
237
|
+
const code = `
|
|
238
|
+
import { Result, resource } from '@ontrails/core';
|
|
239
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
240
|
+
import { note } from './shared/contours.js';
|
|
241
|
+
|
|
242
|
+
const notesResource = resource('db.notes', {
|
|
243
|
+
create: () => Result.ok({}),
|
|
244
|
+
mock: () => ({}),
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
export const createNote = deriveTrail(note, 'create', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
248
|
+
export const readNote = deriveTrail(note, 'read', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
249
|
+
export const updateNote = deriveTrail(note, 'update', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
250
|
+
export const deleteNote = deriveTrail(note, 'delete', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
251
|
+
export const listNote = deriveTrail(note, 'list', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
252
|
+
`;
|
|
253
|
+
|
|
254
|
+
expect(incompleteCrud.check(code, TEST_FILE)).toEqual([]);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
test('tracks two stores with colliding table names independently', () => {
|
|
258
|
+
const code = `
|
|
259
|
+
import { Result, resource } from '@ontrails/core';
|
|
260
|
+
import { store } from '@ontrails/store';
|
|
261
|
+
import { crud } from '@ontrails/store/trails';
|
|
262
|
+
import { z } from 'zod';
|
|
263
|
+
|
|
264
|
+
const primary = store({
|
|
265
|
+
notes: {
|
|
266
|
+
identity: 'id',
|
|
267
|
+
schema: z.object({ id: z.string(), title: z.string() }),
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const archive = store({
|
|
272
|
+
notes: {
|
|
273
|
+
identity: 'id',
|
|
274
|
+
schema: z.object({ id: z.string(), title: z.string() }),
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
const primaryResource = resource('db.primary', {
|
|
279
|
+
create: () => Result.ok({}),
|
|
280
|
+
mock: () => ({}),
|
|
281
|
+
});
|
|
282
|
+
const archiveResource = resource('db.archive', {
|
|
283
|
+
create: () => Result.ok({}),
|
|
284
|
+
mock: () => ({}),
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
// primary is fully covered
|
|
288
|
+
const [createPrimary, readPrimary, updatePrimary, deletePrimary, listPrimary] =
|
|
289
|
+
crud(primary.tables.notes, primaryResource);
|
|
290
|
+
|
|
291
|
+
// archive is partially covered — the warning should target only archive
|
|
292
|
+
const [createArchive, readArchive] = crud(archive.tables.notes, archiveResource);
|
|
293
|
+
`;
|
|
294
|
+
|
|
295
|
+
const diagnostics = incompleteCrud.check(code, TEST_FILE);
|
|
296
|
+
|
|
297
|
+
expect(diagnostics).toHaveLength(1);
|
|
298
|
+
expect(diagnostics[0]?.rule).toBe('incomplete-crud');
|
|
299
|
+
// Stores are keyed by their local binding, so the colliding bare name
|
|
300
|
+
// `notes` does not cause archive coverage to leak into primary.
|
|
301
|
+
expect(diagnostics[0]?.message).toContain('archive:notes');
|
|
302
|
+
expect(diagnostics[0]?.message).toContain('create');
|
|
303
|
+
expect(diagnostics[0]?.message).toContain('read');
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
describe('project-aware (cross-file) coverage', () => {
|
|
307
|
+
const CREATE_FILE = 'notes/create.ts';
|
|
308
|
+
const READ_FILE = 'notes/read.ts';
|
|
309
|
+
|
|
310
|
+
test('stays quiet when sibling files cover the remaining CRUD operations', () => {
|
|
311
|
+
const context = buildContext({
|
|
312
|
+
note: ['create', 'read', 'update', 'delete', 'list'],
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
expect(
|
|
316
|
+
incompleteCrud.checkWithContext(
|
|
317
|
+
splitFileSource('create'),
|
|
318
|
+
CREATE_FILE,
|
|
319
|
+
context
|
|
320
|
+
)
|
|
321
|
+
).toEqual([]);
|
|
322
|
+
expect(
|
|
323
|
+
incompleteCrud.checkWithContext(
|
|
324
|
+
splitFileSource('read'),
|
|
325
|
+
READ_FILE,
|
|
326
|
+
context
|
|
327
|
+
)
|
|
328
|
+
).toEqual([]);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test('merges local and imported contour coverage for the same entity', () => {
|
|
332
|
+
const context = buildContext({
|
|
333
|
+
'imported:note': ['read', 'update', 'delete', 'list'],
|
|
334
|
+
note: ['create'],
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
expect(
|
|
338
|
+
incompleteCrud.checkWithContext(
|
|
339
|
+
splitFileSource('create'),
|
|
340
|
+
CREATE_FILE,
|
|
341
|
+
context
|
|
342
|
+
)
|
|
343
|
+
).toEqual([]);
|
|
344
|
+
expect(
|
|
345
|
+
incompleteCrud.checkWithContext(
|
|
346
|
+
importedSplitFileSource('read'),
|
|
347
|
+
READ_FILE,
|
|
348
|
+
context
|
|
349
|
+
)
|
|
350
|
+
).toEqual([]);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
test('merges imported coverage when the contour binding ends with Contour', () => {
|
|
354
|
+
const context = buildContext({
|
|
355
|
+
'imported:noteContour': ['read', 'update', 'delete', 'list'],
|
|
356
|
+
note: ['create'],
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
expect(
|
|
360
|
+
incompleteCrud.checkWithContext(
|
|
361
|
+
suffixedBindingSplitFileSource('create'),
|
|
362
|
+
CREATE_FILE,
|
|
363
|
+
context
|
|
364
|
+
)
|
|
365
|
+
).toEqual([]);
|
|
366
|
+
expect(
|
|
367
|
+
incompleteCrud.checkWithContext(
|
|
368
|
+
importedSuffixedBindingSplitFileSource('read'),
|
|
369
|
+
READ_FILE,
|
|
370
|
+
context
|
|
371
|
+
)
|
|
372
|
+
).toEqual([]);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
test('does not collapse authored contour IDs that end with Contour', () => {
|
|
376
|
+
const source = `
|
|
377
|
+
import { Result, contour, resource } from '@ontrails/core';
|
|
378
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
379
|
+
import { z } from 'zod';
|
|
380
|
+
|
|
381
|
+
const noteContour = contour('noteContour', {
|
|
382
|
+
body: z.string(),
|
|
383
|
+
id: z.string(),
|
|
384
|
+
title: z.string(),
|
|
385
|
+
}, { identity: 'id' });
|
|
386
|
+
|
|
387
|
+
const notesResource = resource('db.notes', {
|
|
388
|
+
create: () => Result.ok({}),
|
|
389
|
+
mock: () => ({}),
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
export const readNote = deriveTrail(noteContour, 'read', {
|
|
393
|
+
blaze: async () => Result.ok({}),
|
|
394
|
+
resource: notesResource,
|
|
395
|
+
});
|
|
396
|
+
`;
|
|
397
|
+
const context = buildContext({
|
|
398
|
+
note: ['create', 'update', 'delete', 'list'],
|
|
399
|
+
noteContour: ['read'],
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
const diagnostics = incompleteCrud.checkWithContext(
|
|
403
|
+
source,
|
|
404
|
+
READ_FILE,
|
|
405
|
+
context
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
expect(diagnostics).toHaveLength(1);
|
|
409
|
+
expect(diagnostics[0]?.message).toContain('noteContour');
|
|
410
|
+
expect(diagnostics[0]?.message).not.toContain('"note"');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
test('does not merge imported coverage from a different module origin', () => {
|
|
414
|
+
const context = buildContext({
|
|
415
|
+
'imported:./shared/a.js#note': ['read', 'update', 'delete', 'list'],
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
const diagnostics = incompleteCrud.checkWithContext(
|
|
419
|
+
importedSplitFileSource('create', './shared/b.js'),
|
|
420
|
+
CREATE_FILE,
|
|
421
|
+
context
|
|
422
|
+
);
|
|
423
|
+
|
|
424
|
+
expect(diagnostics).toHaveLength(1);
|
|
425
|
+
expect(diagnostics[0]?.message).toContain('note');
|
|
426
|
+
expect(diagnostics[0]?.message).toContain('create');
|
|
427
|
+
expect(diagnostics[0]?.message).toContain('read');
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
test('still warns when aggregated coverage is incomplete', () => {
|
|
431
|
+
const context = buildContext({
|
|
432
|
+
note: ['create', 'read'],
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
const diagnostics = incompleteCrud.checkWithContext(
|
|
436
|
+
splitFileSource('create'),
|
|
437
|
+
CREATE_FILE,
|
|
438
|
+
context
|
|
439
|
+
);
|
|
440
|
+
|
|
441
|
+
expect(diagnostics).toHaveLength(1);
|
|
442
|
+
expect(diagnostics[0]?.filePath).toBe(CREATE_FILE);
|
|
443
|
+
expect(diagnostics[0]?.message).toContain('note');
|
|
444
|
+
expect(diagnostics[0]?.message).toContain('create');
|
|
445
|
+
expect(diagnostics[0]?.message).toContain('read');
|
|
446
|
+
expect(diagnostics[0]?.message).toContain('update');
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
test('colocated full-coverage still passes via checkWithContext', () => {
|
|
450
|
+
const code = `
|
|
451
|
+
import { Result, contour, resource } from '@ontrails/core';
|
|
452
|
+
import { deriveTrail } from '@ontrails/core/trails';
|
|
453
|
+
import { z } from 'zod';
|
|
454
|
+
|
|
455
|
+
const note = contour('note', {
|
|
456
|
+
body: z.string(),
|
|
457
|
+
id: z.string(),
|
|
458
|
+
title: z.string(),
|
|
459
|
+
}, { identity: 'id' });
|
|
460
|
+
|
|
461
|
+
const notesResource = resource('db.notes', {
|
|
462
|
+
create: () => Result.ok({}),
|
|
463
|
+
mock: () => ({}),
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
export const createNote = deriveTrail(note, 'create', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
467
|
+
export const readNote = deriveTrail(note, 'read', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
468
|
+
export const updateNote = deriveTrail(note, 'update', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
469
|
+
export const deleteNote = deriveTrail(note, 'delete', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
470
|
+
export const listNote = deriveTrail(note, 'list', { blaze: async () => Result.ok({}), resource: notesResource });
|
|
471
|
+
`;
|
|
472
|
+
|
|
473
|
+
expect(
|
|
474
|
+
incompleteCrud.checkWithContext(
|
|
475
|
+
code,
|
|
476
|
+
TEST_FILE,
|
|
477
|
+
buildContext({
|
|
478
|
+
note: ['create', 'read', 'update', 'delete', 'list'],
|
|
479
|
+
})
|
|
480
|
+
)
|
|
481
|
+
).toEqual([]);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
test('project context with no matching entity falls back to file-scoped behavior', () => {
|
|
485
|
+
const diagnostics = incompleteCrud.checkWithContext(
|
|
486
|
+
splitFileSource('create'),
|
|
487
|
+
CREATE_FILE,
|
|
488
|
+
buildContext({})
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
// The local file has only `create`, so without cross-file context
|
|
492
|
+
// the rule behaves exactly like the file-scoped check.
|
|
493
|
+
expect(diagnostics).toHaveLength(1);
|
|
494
|
+
expect(diagnostics[0]?.filePath).toBe(CREATE_FILE);
|
|
495
|
+
expect(diagnostics[0]?.message).toContain('note');
|
|
496
|
+
});
|
|
497
|
+
});
|
|
498
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
|
|
3
|
+
import { intentPropagation } from '../rules/intent-propagation.js';
|
|
4
|
+
|
|
5
|
+
const TEST_FILE = 'entity.ts';
|
|
6
|
+
|
|
7
|
+
describe('intent-propagation', () => {
|
|
8
|
+
test('warns when a read trail crosses a write trail', () => {
|
|
9
|
+
const code = `
|
|
10
|
+
trail('entity.read', {
|
|
11
|
+
intent: 'read',
|
|
12
|
+
crosses: ['entity.refresh'],
|
|
13
|
+
blaze: async (_input, ctx) => ctx.cross('entity.refresh', {}),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
trail('entity.refresh', {
|
|
17
|
+
intent: 'write',
|
|
18
|
+
blaze: async () => Result.ok({}),
|
|
19
|
+
});
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const diagnostics = intentPropagation.check(code, TEST_FILE);
|
|
23
|
+
|
|
24
|
+
expect(diagnostics).toHaveLength(1);
|
|
25
|
+
expect(diagnostics[0]?.rule).toBe('intent-propagation');
|
|
26
|
+
expect(diagnostics[0]?.severity).toBe('warn');
|
|
27
|
+
expect(diagnostics[0]?.message).toContain('entity.refresh');
|
|
28
|
+
expect(diagnostics[0]?.message).toContain("intent: 'write'");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('warns when project context resolves a crossed trail to destroy intent', () => {
|
|
32
|
+
const code = `
|
|
33
|
+
trail('entity.read', {
|
|
34
|
+
intent: 'read',
|
|
35
|
+
crosses: ['entity.delete'],
|
|
36
|
+
blaze: async (_input, ctx) => ctx.cross('entity.delete', {}),
|
|
37
|
+
});
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const diagnostics = intentPropagation.checkWithContext(code, TEST_FILE, {
|
|
41
|
+
knownTrailIds: new Set(['entity.delete', 'entity.read']),
|
|
42
|
+
trailIntentsById: new Map([
|
|
43
|
+
['entity.delete', 'destroy'],
|
|
44
|
+
['entity.read', 'read'],
|
|
45
|
+
]),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
expect(diagnostics).toHaveLength(1);
|
|
49
|
+
expect(diagnostics[0]?.message).toContain("intent: 'destroy'");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('stays quiet when a read trail crosses another read trail', () => {
|
|
53
|
+
const code = `
|
|
54
|
+
trail('entity.read', {
|
|
55
|
+
intent: 'read',
|
|
56
|
+
crosses: ['entity.lookup'],
|
|
57
|
+
blaze: async (_input, ctx) => ctx.cross('entity.lookup', {}),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
trail('entity.lookup', {
|
|
61
|
+
intent: 'read',
|
|
62
|
+
blaze: async () => Result.ok({}),
|
|
63
|
+
});
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
expect(intentPropagation.check(code, TEST_FILE)).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('warns when namespaced core.trail(...) read crosses a write trail', () => {
|
|
70
|
+
// Regression guard for TRL-343: the shared findTrailDefinitions helper
|
|
71
|
+
// must recognize `core.trail("id", { ... })` as a trail definition, not
|
|
72
|
+
// just bare `trail("id", { ... })`. Before the fix these definitions were
|
|
73
|
+
// silently skipped and this rule stayed quiet on namespaced-import files.
|
|
74
|
+
//
|
|
75
|
+
// Per TRL-347 the namespace receiver must resolve to an `@ontrails/*`
|
|
76
|
+
// import — the `import * as core from '@ontrails/core'` below is what
|
|
77
|
+
// licenses the `core.trail(...)` recognition.
|
|
78
|
+
const code = `
|
|
79
|
+
import * as core from '@ontrails/core';
|
|
80
|
+
|
|
81
|
+
core.trail('entity.read', {
|
|
82
|
+
intent: 'read',
|
|
83
|
+
crosses: ['entity.refresh'],
|
|
84
|
+
blaze: async (_input, ctx) => ctx.cross('entity.refresh', {}),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
core.trail('entity.refresh', {
|
|
88
|
+
intent: 'write',
|
|
89
|
+
blaze: async () => Result.ok({}),
|
|
90
|
+
});
|
|
91
|
+
`;
|
|
92
|
+
|
|
93
|
+
const diagnostics = intentPropagation.check(code, TEST_FILE);
|
|
94
|
+
|
|
95
|
+
expect(diagnostics).toHaveLength(1);
|
|
96
|
+
expect(diagnostics[0]?.message).toContain('entity.refresh');
|
|
97
|
+
expect(diagnostics[0]?.message).toContain("intent: 'write'");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('stays quiet when the entry trail is not read-only', () => {
|
|
101
|
+
const code = `
|
|
102
|
+
trail('entity.update', {
|
|
103
|
+
intent: 'write',
|
|
104
|
+
crosses: ['entity.delete'],
|
|
105
|
+
blaze: async (_input, ctx) => ctx.cross('entity.delete', {}),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
trail('entity.delete', {
|
|
109
|
+
intent: 'destroy',
|
|
110
|
+
blaze: async () => Result.ok({}),
|
|
111
|
+
});
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
expect(intentPropagation.check(code, TEST_FILE)).toEqual([]);
|
|
115
|
+
});
|
|
116
|
+
});
|