@opensip-tools/fitness 1.0.4
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-build.log +4 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/LICENSE +21 -0
- package/dist/__tests__/gate.test.d.ts +13 -0
- package/dist/__tests__/gate.test.d.ts.map +1 -0
- package/dist/__tests__/gate.test.js +422 -0
- package/dist/__tests__/gate.test.js.map +1 -0
- package/dist/__tests__/sarif.test.d.ts +2 -0
- package/dist/__tests__/sarif.test.d.ts.map +1 -0
- package/dist/__tests__/sarif.test.js +169 -0
- package/dist/__tests__/sarif.test.js.map +1 -0
- package/dist/cli/dashboard.d.ts +6 -0
- package/dist/cli/dashboard.d.ts.map +1 -0
- package/dist/cli/dashboard.js +77 -0
- package/dist/cli/dashboard.js.map +1 -0
- package/dist/cli/fit.d.ts +37 -0
- package/dist/cli/fit.d.ts.map +1 -0
- package/dist/cli/fit.js +539 -0
- package/dist/cli/fit.js.map +1 -0
- package/dist/cli/list-checks.d.ts +6 -0
- package/dist/cli/list-checks.d.ts.map +1 -0
- package/dist/cli/list-checks.js +23 -0
- package/dist/cli/list-checks.js.map +1 -0
- package/dist/cli/list-recipes.d.ts +6 -0
- package/dist/cli/list-recipes.d.ts.map +1 -0
- package/dist/cli/list-recipes.js +31 -0
- package/dist/cli/list-recipes.js.map +1 -0
- package/dist/framework/__tests__/ast-utilities.test.d.ts +2 -0
- package/dist/framework/__tests__/ast-utilities.test.d.ts.map +1 -0
- package/dist/framework/__tests__/ast-utilities.test.js +153 -0
- package/dist/framework/__tests__/ast-utilities.test.js.map +1 -0
- package/dist/framework/__tests__/check-config.test.d.ts +2 -0
- package/dist/framework/__tests__/check-config.test.d.ts.map +1 -0
- package/dist/framework/__tests__/check-config.test.js +56 -0
- package/dist/framework/__tests__/check-config.test.js.map +1 -0
- package/dist/framework/__tests__/command-executor.test.d.ts +2 -0
- package/dist/framework/__tests__/command-executor.test.d.ts.map +1 -0
- package/dist/framework/__tests__/command-executor.test.js +71 -0
- package/dist/framework/__tests__/command-executor.test.js.map +1 -0
- package/dist/framework/__tests__/content-filter-dispatch.test.d.ts +2 -0
- package/dist/framework/__tests__/content-filter-dispatch.test.d.ts.map +1 -0
- package/dist/framework/__tests__/content-filter-dispatch.test.js +104 -0
- package/dist/framework/__tests__/content-filter-dispatch.test.js.map +1 -0
- package/dist/framework/__tests__/content-filter.test.d.ts +2 -0
- package/dist/framework/__tests__/content-filter.test.d.ts.map +1 -0
- package/dist/framework/__tests__/content-filter.test.js +126 -0
- package/dist/framework/__tests__/content-filter.test.js.map +1 -0
- package/dist/framework/__tests__/define-check.test.d.ts +2 -0
- package/dist/framework/__tests__/define-check.test.d.ts.map +1 -0
- package/dist/framework/__tests__/define-check.test.js +155 -0
- package/dist/framework/__tests__/define-check.test.js.map +1 -0
- package/dist/framework/__tests__/directive-inventory.test.d.ts +2 -0
- package/dist/framework/__tests__/directive-inventory.test.d.ts.map +1 -0
- package/dist/framework/__tests__/directive-inventory.test.js +44 -0
- package/dist/framework/__tests__/directive-inventory.test.js.map +1 -0
- package/dist/framework/__tests__/execution-context.test.d.ts +2 -0
- package/dist/framework/__tests__/execution-context.test.d.ts.map +1 -0
- package/dist/framework/__tests__/execution-context.test.js +62 -0
- package/dist/framework/__tests__/execution-context.test.js.map +1 -0
- package/dist/framework/__tests__/file-accessor.test.d.ts +2 -0
- package/dist/framework/__tests__/file-accessor.test.d.ts.map +1 -0
- package/dist/framework/__tests__/file-accessor.test.js +106 -0
- package/dist/framework/__tests__/file-accessor.test.js.map +1 -0
- package/dist/framework/__tests__/file-cache.test.d.ts +2 -0
- package/dist/framework/__tests__/file-cache.test.d.ts.map +1 -0
- package/dist/framework/__tests__/file-cache.test.js +122 -0
- package/dist/framework/__tests__/file-cache.test.js.map +1 -0
- package/dist/framework/__tests__/import-graph.test.d.ts +15 -0
- package/dist/framework/__tests__/import-graph.test.d.ts.map +1 -0
- package/dist/framework/__tests__/import-graph.test.js +164 -0
- package/dist/framework/__tests__/import-graph.test.js.map +1 -0
- package/dist/framework/__tests__/path-matcher.test.d.ts +2 -0
- package/dist/framework/__tests__/path-matcher.test.d.ts.map +1 -0
- package/dist/framework/__tests__/path-matcher.test.js +113 -0
- package/dist/framework/__tests__/path-matcher.test.js.map +1 -0
- package/dist/framework/__tests__/register-helpers.test.d.ts +2 -0
- package/dist/framework/__tests__/register-helpers.test.d.ts.map +1 -0
- package/dist/framework/__tests__/register-helpers.test.js +42 -0
- package/dist/framework/__tests__/register-helpers.test.js.map +1 -0
- package/dist/framework/__tests__/registry.test.d.ts +2 -0
- package/dist/framework/__tests__/registry.test.d.ts.map +1 -0
- package/dist/framework/__tests__/registry.test.js +208 -0
- package/dist/framework/__tests__/registry.test.js.map +1 -0
- package/dist/framework/__tests__/result-builder.test.d.ts +2 -0
- package/dist/framework/__tests__/result-builder.test.d.ts.map +1 -0
- package/dist/framework/__tests__/result-builder.test.js +153 -0
- package/dist/framework/__tests__/result-builder.test.js.map +1 -0
- package/dist/framework/__tests__/scope-resolver.test.d.ts +2 -0
- package/dist/framework/__tests__/scope-resolver.test.d.ts.map +1 -0
- package/dist/framework/__tests__/scope-resolver.test.js +140 -0
- package/dist/framework/__tests__/scope-resolver.test.js.map +1 -0
- package/dist/framework/__tests__/severity-mapping.test.d.ts +2 -0
- package/dist/framework/__tests__/severity-mapping.test.d.ts.map +1 -0
- package/dist/framework/__tests__/severity-mapping.test.js +42 -0
- package/dist/framework/__tests__/severity-mapping.test.js.map +1 -0
- package/dist/framework/__tests__/strip-literals.test.d.ts +2 -0
- package/dist/framework/__tests__/strip-literals.test.d.ts.map +1 -0
- package/dist/framework/__tests__/strip-literals.test.js +87 -0
- package/dist/framework/__tests__/strip-literals.test.js.map +1 -0
- package/dist/framework/abortable-exec.d.ts +34 -0
- package/dist/framework/abortable-exec.d.ts.map +1 -0
- package/dist/framework/abortable-exec.js +136 -0
- package/dist/framework/abortable-exec.js.map +1 -0
- package/dist/framework/ast-utilities.d.ts +41 -0
- package/dist/framework/ast-utilities.d.ts.map +1 -0
- package/dist/framework/ast-utilities.js +106 -0
- package/dist/framework/ast-utilities.js.map +1 -0
- package/dist/framework/check-config.d.ts +171 -0
- package/dist/framework/check-config.d.ts.map +1 -0
- package/dist/framework/check-config.js +114 -0
- package/dist/framework/check-config.js.map +1 -0
- package/dist/framework/check-types.d.ts +57 -0
- package/dist/framework/check-types.d.ts.map +1 -0
- package/dist/framework/check-types.js +35 -0
- package/dist/framework/check-types.js.map +1 -0
- package/dist/framework/command-executor.d.ts +25 -0
- package/dist/framework/command-executor.d.ts.map +1 -0
- package/dist/framework/command-executor.js +63 -0
- package/dist/framework/command-executor.js.map +1 -0
- package/dist/framework/constants.d.ts +9 -0
- package/dist/framework/constants.d.ts.map +1 -0
- package/dist/framework/constants.js +16 -0
- package/dist/framework/constants.js.map +1 -0
- package/dist/framework/content-filter.d.ts +33 -0
- package/dist/framework/content-filter.d.ts.map +1 -0
- package/dist/framework/content-filter.js +236 -0
- package/dist/framework/content-filter.js.map +1 -0
- package/dist/framework/define-check.d.ts +38 -0
- package/dist/framework/define-check.d.ts.map +1 -0
- package/dist/framework/define-check.js +252 -0
- package/dist/framework/define-check.js.map +1 -0
- package/dist/framework/directive-inventory.d.ts +34 -0
- package/dist/framework/directive-inventory.d.ts.map +1 -0
- package/dist/framework/directive-inventory.js +77 -0
- package/dist/framework/directive-inventory.js.map +1 -0
- package/dist/framework/directive-parsing.d.ts +20 -0
- package/dist/framework/directive-parsing.d.ts.map +1 -0
- package/dist/framework/directive-parsing.js +121 -0
- package/dist/framework/directive-parsing.js.map +1 -0
- package/dist/framework/execution-context.d.ts +95 -0
- package/dist/framework/execution-context.d.ts.map +1 -0
- package/dist/framework/execution-context.js +122 -0
- package/dist/framework/execution-context.js.map +1 -0
- package/dist/framework/file-accessor.d.ts +20 -0
- package/dist/framework/file-accessor.d.ts.map +1 -0
- package/dist/framework/file-accessor.js +122 -0
- package/dist/framework/file-accessor.js.map +1 -0
- package/dist/framework/file-cache.d.ts +70 -0
- package/dist/framework/file-cache.d.ts.map +1 -0
- package/dist/framework/file-cache.js +178 -0
- package/dist/framework/file-cache.js.map +1 -0
- package/dist/framework/file-type-filter.d.ts +11 -0
- package/dist/framework/file-type-filter.d.ts.map +1 -0
- package/dist/framework/file-type-filter.js +21 -0
- package/dist/framework/file-type-filter.js.map +1 -0
- package/dist/framework/ignore-processing.d.ts +22 -0
- package/dist/framework/ignore-processing.d.ts.map +1 -0
- package/dist/framework/ignore-processing.js +241 -0
- package/dist/framework/ignore-processing.js.map +1 -0
- package/dist/framework/import-graph.d.ts +51 -0
- package/dist/framework/import-graph.d.ts.map +1 -0
- package/dist/framework/import-graph.js +216 -0
- package/dist/framework/import-graph.js.map +1 -0
- package/dist/framework/memory-profiler.d.ts +53 -0
- package/dist/framework/memory-profiler.d.ts.map +1 -0
- package/dist/framework/memory-profiler.js +92 -0
- package/dist/framework/memory-profiler.js.map +1 -0
- package/dist/framework/parse-cache.d.ts +23 -0
- package/dist/framework/parse-cache.d.ts.map +1 -0
- package/dist/framework/parse-cache.js +37 -0
- package/dist/framework/parse-cache.js.map +1 -0
- package/dist/framework/path-matcher.d.ts +86 -0
- package/dist/framework/path-matcher.d.ts.map +1 -0
- package/dist/framework/path-matcher.js +138 -0
- package/dist/framework/path-matcher.js.map +1 -0
- package/dist/framework/register-helpers.d.ts +10 -0
- package/dist/framework/register-helpers.d.ts.map +1 -0
- package/dist/framework/register-helpers.js +17 -0
- package/dist/framework/register-helpers.js.map +1 -0
- package/dist/framework/registry.d.ts +41 -0
- package/dist/framework/registry.d.ts.map +1 -0
- package/dist/framework/registry.js +103 -0
- package/dist/framework/registry.js.map +1 -0
- package/dist/framework/result-builder.d.ts +74 -0
- package/dist/framework/result-builder.d.ts.map +1 -0
- package/dist/framework/result-builder.js +154 -0
- package/dist/framework/result-builder.js.map +1 -0
- package/dist/framework/scope-resolver.d.ts +23 -0
- package/dist/framework/scope-resolver.d.ts.map +1 -0
- package/dist/framework/scope-resolver.js +201 -0
- package/dist/framework/scope-resolver.js.map +1 -0
- package/dist/framework/severity-mapping.d.ts +13 -0
- package/dist/framework/severity-mapping.d.ts.map +1 -0
- package/dist/framework/severity-mapping.js +51 -0
- package/dist/framework/severity-mapping.js.map +1 -0
- package/dist/framework/strip-literals.d.ts +48 -0
- package/dist/framework/strip-literals.d.ts.map +1 -0
- package/dist/framework/strip-literals.js +188 -0
- package/dist/framework/strip-literals.js.map +1 -0
- package/dist/gate.d.ts +74 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +257 -0
- package/dist/gate.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/__tests__/check-package-discovery.test.d.ts +2 -0
- package/dist/plugins/__tests__/check-package-discovery.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/check-package-discovery.test.js +170 -0
- package/dist/plugins/__tests__/check-package-discovery.test.js.map +1 -0
- package/dist/plugins/__tests__/lang-domain.test.d.ts +2 -0
- package/dist/plugins/__tests__/lang-domain.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/lang-domain.test.js +171 -0
- package/dist/plugins/__tests__/lang-domain.test.js.map +1 -0
- package/dist/plugins/__tests__/loader.test.d.ts +2 -0
- package/dist/plugins/__tests__/loader.test.d.ts.map +1 -0
- package/dist/plugins/__tests__/loader.test.js +194 -0
- package/dist/plugins/__tests__/loader.test.js.map +1 -0
- package/dist/plugins/check-package-discovery.d.ts +73 -0
- package/dist/plugins/check-package-discovery.d.ts.map +1 -0
- package/dist/plugins/check-package-discovery.js +212 -0
- package/dist/plugins/check-package-discovery.js.map +1 -0
- package/dist/plugins/loader.d.ts +31 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +290 -0
- package/dist/plugins/loader.js.map +1 -0
- package/dist/plugins/types.d.ts +23 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +9 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/recipes/__tests__/built-in-recipes.test.d.ts +2 -0
- package/dist/recipes/__tests__/built-in-recipes.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/built-in-recipes.test.js +93 -0
- package/dist/recipes/__tests__/built-in-recipes.test.js.map +1 -0
- package/dist/recipes/__tests__/check-config.test.d.ts +5 -0
- package/dist/recipes/__tests__/check-config.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/check-config.test.js +37 -0
- package/dist/recipes/__tests__/check-config.test.js.map +1 -0
- package/dist/recipes/__tests__/check-resolution.test.d.ts +2 -0
- package/dist/recipes/__tests__/check-resolution.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/check-resolution.test.js +135 -0
- package/dist/recipes/__tests__/check-resolution.test.js.map +1 -0
- package/dist/recipes/__tests__/registry.test.d.ts +2 -0
- package/dist/recipes/__tests__/registry.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/registry.test.js +97 -0
- package/dist/recipes/__tests__/registry.test.js.map +1 -0
- package/dist/recipes/__tests__/retry.test.d.ts +2 -0
- package/dist/recipes/__tests__/retry.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/retry.test.js +75 -0
- package/dist/recipes/__tests__/retry.test.js.map +1 -0
- package/dist/recipes/__tests__/service.test.d.ts +11 -0
- package/dist/recipes/__tests__/service.test.d.ts.map +1 -0
- package/dist/recipes/__tests__/service.test.js +482 -0
- package/dist/recipes/__tests__/service.test.js.map +1 -0
- package/dist/recipes/built-in-recipes.d.ts +14 -0
- package/dist/recipes/built-in-recipes.d.ts.map +1 -0
- package/dist/recipes/built-in-recipes.js +247 -0
- package/dist/recipes/built-in-recipes.js.map +1 -0
- package/dist/recipes/check-config.d.ts +40 -0
- package/dist/recipes/check-config.d.ts.map +1 -0
- package/dist/recipes/check-config.js +61 -0
- package/dist/recipes/check-config.js.map +1 -0
- package/dist/recipes/check-resolution.d.ts +21 -0
- package/dist/recipes/check-resolution.d.ts.map +1 -0
- package/dist/recipes/check-resolution.js +121 -0
- package/dist/recipes/check-resolution.js.map +1 -0
- package/dist/recipes/check-result-processor.d.ts +51 -0
- package/dist/recipes/check-result-processor.d.ts.map +1 -0
- package/dist/recipes/check-result-processor.js +158 -0
- package/dist/recipes/check-result-processor.js.map +1 -0
- package/dist/recipes/parallel-execution.d.ts +33 -0
- package/dist/recipes/parallel-execution.d.ts.map +1 -0
- package/dist/recipes/parallel-execution.js +142 -0
- package/dist/recipes/parallel-execution.js.map +1 -0
- package/dist/recipes/registry.d.ts +81 -0
- package/dist/recipes/registry.d.ts.map +1 -0
- package/dist/recipes/registry.js +131 -0
- package/dist/recipes/registry.js.map +1 -0
- package/dist/recipes/retry.d.ts +25 -0
- package/dist/recipes/retry.d.ts.map +1 -0
- package/dist/recipes/retry.js +44 -0
- package/dist/recipes/retry.js.map +1 -0
- package/dist/recipes/sequential-execution.d.ts +10 -0
- package/dist/recipes/sequential-execution.d.ts.map +1 -0
- package/dist/recipes/sequential-execution.js +122 -0
- package/dist/recipes/sequential-execution.js.map +1 -0
- package/dist/recipes/service-types.d.ts +84 -0
- package/dist/recipes/service-types.d.ts.map +1 -0
- package/dist/recipes/service-types.js +8 -0
- package/dist/recipes/service-types.js.map +1 -0
- package/dist/recipes/service.d.ts +71 -0
- package/dist/recipes/service.d.ts.map +1 -0
- package/dist/recipes/service.js +331 -0
- package/dist/recipes/service.js.map +1 -0
- package/dist/recipes/types.d.ts +154 -0
- package/dist/recipes/types.d.ts.map +1 -0
- package/dist/recipes/types.js +54 -0
- package/dist/recipes/types.js.map +1 -0
- package/dist/sarif.d.ts +34 -0
- package/dist/sarif.d.ts.map +1 -0
- package/dist/sarif.js +192 -0
- package/dist/sarif.js.map +1 -0
- package/dist/signalers/__tests__/loader.test.d.ts +2 -0
- package/dist/signalers/__tests__/loader.test.d.ts.map +1 -0
- package/dist/signalers/__tests__/loader.test.js +74 -0
- package/dist/signalers/__tests__/loader.test.js.map +1 -0
- package/dist/signalers/index.d.ts +8 -0
- package/dist/signalers/index.d.ts.map +1 -0
- package/dist/signalers/index.js +9 -0
- package/dist/signalers/index.js.map +1 -0
- package/dist/signalers/loader.d.ts +24 -0
- package/dist/signalers/loader.d.ts.map +1 -0
- package/dist/signalers/loader.js +108 -0
- package/dist/signalers/loader.js.map +1 -0
- package/dist/signalers/schema.d.ts +288 -0
- package/dist/signalers/schema.d.ts.map +1 -0
- package/dist/signalers/schema.js +99 -0
- package/dist/signalers/schema.js.map +1 -0
- package/dist/signalers/types.d.ts +13 -0
- package/dist/signalers/types.d.ts.map +1 -0
- package/dist/signalers/types.js +5 -0
- package/dist/signalers/types.js.map +1 -0
- package/dist/targets/__tests__/loader.test.d.ts +2 -0
- package/dist/targets/__tests__/loader.test.d.ts.map +1 -0
- package/dist/targets/__tests__/loader.test.js +127 -0
- package/dist/targets/__tests__/loader.test.js.map +1 -0
- package/dist/targets/__tests__/resolver.test.d.ts +2 -0
- package/dist/targets/__tests__/resolver.test.d.ts.map +1 -0
- package/dist/targets/__tests__/resolver.test.js +54 -0
- package/dist/targets/__tests__/resolver.test.js.map +1 -0
- package/dist/targets/__tests__/target-registry.test.d.ts +2 -0
- package/dist/targets/__tests__/target-registry.test.d.ts.map +1 -0
- package/dist/targets/__tests__/target-registry.test.js +89 -0
- package/dist/targets/__tests__/target-registry.test.js.map +1 -0
- package/dist/targets/index.d.ts +10 -0
- package/dist/targets/index.d.ts.map +1 -0
- package/dist/targets/index.js +12 -0
- package/dist/targets/index.js.map +1 -0
- package/dist/targets/loader.d.ts +19 -0
- package/dist/targets/loader.d.ts.map +1 -0
- package/dist/targets/loader.js +159 -0
- package/dist/targets/loader.js.map +1 -0
- package/dist/targets/resolver.d.ts +19 -0
- package/dist/targets/resolver.d.ts.map +1 -0
- package/dist/targets/resolver.js +37 -0
- package/dist/targets/resolver.js.map +1 -0
- package/dist/targets/target-registry.d.ts +61 -0
- package/dist/targets/target-registry.d.ts.map +1 -0
- package/dist/targets/target-registry.js +93 -0
- package/dist/targets/target-registry.js.map +1 -0
- package/dist/targets/types.d.ts +85 -0
- package/dist/targets/types.d.ts.map +1 -0
- package/dist/targets/types.js +5 -0
- package/dist/targets/types.js.map +1 -0
- package/dist/tool.d.ts +17 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +282 -0
- package/dist/tool.js.map +1 -0
- package/dist/types/findings.d.ts +117 -0
- package/dist/types/findings.d.ts.map +1 -0
- package/dist/types/findings.js +93 -0
- package/dist/types/findings.js.map +1 -0
- package/dist/types/severity.d.ts +15 -0
- package/dist/types/severity.d.ts.map +1 -0
- package/dist/types/severity.js +36 -0
- package/dist/types/severity.js.map +1 -0
- package/package.json +45 -0
- package/src/__tests__/gate.test.ts +537 -0
- package/src/__tests__/sarif.test.ts +201 -0
- package/src/cli/dashboard.ts +93 -0
- package/src/cli/fit.ts +612 -0
- package/src/cli/list-checks.ts +32 -0
- package/src/cli/list-recipes.ts +38 -0
- package/src/framework/__tests__/ast-utilities.test.ts +157 -0
- package/src/framework/__tests__/check-config.test.ts +65 -0
- package/src/framework/__tests__/command-executor.test.ts +79 -0
- package/src/framework/__tests__/content-filter-dispatch.test.ts +132 -0
- package/src/framework/__tests__/content-filter.test.ts +136 -0
- package/src/framework/__tests__/define-check.test.ts +180 -0
- package/src/framework/__tests__/directive-inventory.test.ts +53 -0
- package/src/framework/__tests__/execution-context.test.ts +80 -0
- package/src/framework/__tests__/file-accessor.test.ts +121 -0
- package/src/framework/__tests__/file-cache.test.ts +142 -0
- package/src/framework/__tests__/import-graph.test.ts +282 -0
- package/src/framework/__tests__/path-matcher.test.ts +130 -0
- package/src/framework/__tests__/register-helpers.test.ts +51 -0
- package/src/framework/__tests__/registry.test.ts +243 -0
- package/src/framework/__tests__/result-builder.test.ts +178 -0
- package/src/framework/__tests__/scope-resolver.test.ts +208 -0
- package/src/framework/__tests__/severity-mapping.test.ts +50 -0
- package/src/framework/__tests__/strip-literals.test.ts +109 -0
- package/src/framework/abortable-exec.ts +177 -0
- package/src/framework/ast-utilities.ts +112 -0
- package/src/framework/check-config.ts +339 -0
- package/src/framework/check-types.ts +77 -0
- package/src/framework/command-executor.ts +100 -0
- package/src/framework/constants.ts +16 -0
- package/src/framework/content-filter.ts +288 -0
- package/src/framework/define-check.ts +336 -0
- package/src/framework/directive-inventory.ts +110 -0
- package/src/framework/directive-parsing.ts +152 -0
- package/src/framework/execution-context.ts +247 -0
- package/src/framework/file-accessor.ts +171 -0
- package/src/framework/file-cache.ts +220 -0
- package/src/framework/file-type-filter.ts +25 -0
- package/src/framework/ignore-processing.ts +350 -0
- package/src/framework/import-graph.ts +280 -0
- package/src/framework/memory-profiler.ts +145 -0
- package/src/framework/parse-cache.ts +38 -0
- package/src/framework/path-matcher.ts +191 -0
- package/src/framework/register-helpers.ts +20 -0
- package/src/framework/registry.ts +125 -0
- package/src/framework/result-builder.ts +225 -0
- package/src/framework/scope-resolver.ts +262 -0
- package/src/framework/severity-mapping.ts +56 -0
- package/src/framework/strip-literals.ts +200 -0
- package/src/gate.ts +337 -0
- package/src/index.ts +110 -0
- package/src/plugins/__tests__/check-package-discovery.test.ts +204 -0
- package/src/plugins/__tests__/lang-domain.test.ts +198 -0
- package/src/plugins/__tests__/loader.test.ts +226 -0
- package/src/plugins/check-package-discovery.ts +242 -0
- package/src/plugins/loader.ts +327 -0
- package/src/plugins/types.ts +25 -0
- package/src/recipes/__tests__/built-in-recipes.test.ts +107 -0
- package/src/recipes/__tests__/check-config.test.ts +51 -0
- package/src/recipes/__tests__/check-resolution.test.ts +185 -0
- package/src/recipes/__tests__/registry.test.ts +115 -0
- package/src/recipes/__tests__/retry.test.ts +83 -0
- package/src/recipes/__tests__/service.test.ts +572 -0
- package/src/recipes/built-in-recipes.ts +273 -0
- package/src/recipes/check-config.ts +64 -0
- package/src/recipes/check-resolution.ts +169 -0
- package/src/recipes/check-result-processor.ts +258 -0
- package/src/recipes/parallel-execution.ts +220 -0
- package/src/recipes/registry.ts +192 -0
- package/src/recipes/retry.ts +69 -0
- package/src/recipes/sequential-execution.ts +139 -0
- package/src/recipes/service-types.ts +105 -0
- package/src/recipes/service.ts +400 -0
- package/src/recipes/types.ts +247 -0
- package/src/sarif.ts +232 -0
- package/src/signalers/__tests__/loader.test.ts +99 -0
- package/src/signalers/index.ts +9 -0
- package/src/signalers/loader.ts +141 -0
- package/src/signalers/schema.ts +117 -0
- package/src/signalers/types.ts +15 -0
- package/src/targets/__tests__/loader.test.ts +170 -0
- package/src/targets/__tests__/resolver.test.ts +74 -0
- package/src/targets/__tests__/target-registry.test.ts +103 -0
- package/src/targets/index.ts +13 -0
- package/src/targets/loader.ts +214 -0
- package/src/targets/resolver.ts +44 -0
- package/src/targets/target-registry.ts +111 -0
- package/src/targets/types.ts +89 -0
- package/src/tool.ts +302 -0
- package/src/types/findings.ts +239 -0
- package/src/types/severity.ts +39 -0
- package/tsconfig.json +8 -0
- package/vitest.config.ts +33 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tests for the per-check recipe-config helper.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
getCheckConfig,
|
|
9
|
+
setCurrentRecipeCheckConfig,
|
|
10
|
+
clearCurrentRecipeCheckConfig,
|
|
11
|
+
} from '../check-config.js'
|
|
12
|
+
|
|
13
|
+
interface SampleConfig extends Record<string, unknown> {
|
|
14
|
+
additionalEntries?: string[]
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('getCheckConfig', () => {
|
|
18
|
+
afterEach(() => {
|
|
19
|
+
clearCurrentRecipeCheckConfig()
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it('returns an empty object when no recipe config is set', () => {
|
|
23
|
+
const cfg = getCheckConfig<SampleConfig>('any-slug')
|
|
24
|
+
expect(cfg).toEqual({})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('returns an empty object for a slug not present in the recipe config', () => {
|
|
28
|
+
setCurrentRecipeCheckConfig({
|
|
29
|
+
'other-check': { additionalEntries: ['x'] },
|
|
30
|
+
})
|
|
31
|
+
const cfg = getCheckConfig<SampleConfig>('missing')
|
|
32
|
+
expect(cfg).toEqual({})
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('returns the recipe-config slice for the matching slug', () => {
|
|
36
|
+
setCurrentRecipeCheckConfig({
|
|
37
|
+
'sample-check': { additionalEntries: ['a', 'b'] },
|
|
38
|
+
})
|
|
39
|
+
const cfg = getCheckConfig<SampleConfig>('sample-check')
|
|
40
|
+
expect(cfg.additionalEntries).toEqual(['a', 'b'])
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('returns an empty object after clearCurrentRecipeCheckConfig is called', () => {
|
|
44
|
+
setCurrentRecipeCheckConfig({
|
|
45
|
+
'sample-check': { additionalEntries: ['a', 'b'] },
|
|
46
|
+
})
|
|
47
|
+
clearCurrentRecipeCheckConfig()
|
|
48
|
+
const cfg = getCheckConfig<SampleConfig>('sample-check')
|
|
49
|
+
expect(cfg).toEqual({})
|
|
50
|
+
})
|
|
51
|
+
})
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest'
|
|
2
|
+
|
|
3
|
+
import { CheckRegistry } from '../../framework/registry.js'
|
|
4
|
+
import { resolveChecks } from '../check-resolution.js'
|
|
5
|
+
|
|
6
|
+
import type { Check } from '../../framework/check-types.js'
|
|
7
|
+
import type { CheckSelector } from '../types.js'
|
|
8
|
+
|
|
9
|
+
function makeCheck(slug: string, tags: string[] = ['quality'], opts?: { disabled?: boolean }): Check {
|
|
10
|
+
return {
|
|
11
|
+
config: {
|
|
12
|
+
id: `id-${slug}`,
|
|
13
|
+
slug,
|
|
14
|
+
tags,
|
|
15
|
+
description: `Check: ${slug}`,
|
|
16
|
+
analysisMode: 'analyze',
|
|
17
|
+
scope: { include: [], exclude: [], description: '' },
|
|
18
|
+
itemType: 'files',
|
|
19
|
+
disabled: opts?.disabled,
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- mock matches expected `() => Promise<CheckResult>` shape
|
|
21
|
+
execute: async () => ({ findings: [], passed: true }),
|
|
22
|
+
},
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- mock matches expected `() => Promise<CheckResult>` shape
|
|
24
|
+
run: async () => ({ findings: [], passed: true }),
|
|
25
|
+
getScope: () => ({ include: [], exclude: [], description: '' }),
|
|
26
|
+
getMatcher: () => ({ matches: () => true }),
|
|
27
|
+
} as unknown as Check
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function createRegistry(...checks: Check[]): CheckRegistry {
|
|
31
|
+
const reg = new CheckRegistry()
|
|
32
|
+
for (const check of checks) {
|
|
33
|
+
reg.register(check)
|
|
34
|
+
}
|
|
35
|
+
return reg
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createNamespacedRegistry(namespace: string, ...checks: Check[]): CheckRegistry {
|
|
39
|
+
const reg = new CheckRegistry()
|
|
40
|
+
for (const check of checks) {
|
|
41
|
+
reg.register(check, namespace)
|
|
42
|
+
}
|
|
43
|
+
return reg
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
describe('resolveChecks', () => {
|
|
47
|
+
describe('tags selector', () => {
|
|
48
|
+
it('resolves checks matching a single tag', () => {
|
|
49
|
+
const reg = createRegistry(
|
|
50
|
+
makeCheck('a', ['security']),
|
|
51
|
+
makeCheck('b', ['quality']),
|
|
52
|
+
makeCheck('c', ['security', 'quality']),
|
|
53
|
+
)
|
|
54
|
+
const selector: CheckSelector = { type: 'tags', include: ['security'] }
|
|
55
|
+
const result = resolveChecks(selector, reg)
|
|
56
|
+
expect(result).toHaveLength(2)
|
|
57
|
+
expect(result).toContain('a')
|
|
58
|
+
expect(result).toContain('c')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('resolves checks matching any include tag', () => {
|
|
62
|
+
const reg = createRegistry(
|
|
63
|
+
makeCheck('a', ['security']),
|
|
64
|
+
makeCheck('b', ['performance']),
|
|
65
|
+
makeCheck('c', ['quality']),
|
|
66
|
+
)
|
|
67
|
+
const selector: CheckSelector = { type: 'tags', include: ['security', 'performance'] }
|
|
68
|
+
const result = resolveChecks(selector, reg)
|
|
69
|
+
expect(result).toHaveLength(2)
|
|
70
|
+
expect(result).toContain('a')
|
|
71
|
+
expect(result).toContain('b')
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
it('excludes checks matching exclude tags', () => {
|
|
75
|
+
const reg = createRegistry(
|
|
76
|
+
makeCheck('a', ['security', 'backend']),
|
|
77
|
+
makeCheck('b', ['security', 'frontend']),
|
|
78
|
+
)
|
|
79
|
+
const selector: CheckSelector = { type: 'tags', include: ['security'], exclude: ['frontend'] }
|
|
80
|
+
const result = resolveChecks(selector, reg)
|
|
81
|
+
expect(result).toEqual(['a'])
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it('returns empty array when no tags match', () => {
|
|
85
|
+
const reg = createRegistry(makeCheck('a', ['quality']))
|
|
86
|
+
const selector: CheckSelector = { type: 'tags', include: ['nonexistent'] }
|
|
87
|
+
expect(resolveChecks(selector, reg)).toEqual([])
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('explicit selector', () => {
|
|
92
|
+
it('resolves by bare slug', () => {
|
|
93
|
+
const reg = createRegistry(makeCheck('no-eval'), makeCheck('no-console'))
|
|
94
|
+
const selector: CheckSelector = { type: 'explicit', checkIds: ['no-eval'] }
|
|
95
|
+
expect(resolveChecks(selector, reg)).toEqual(['no-eval'])
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('resolves bare slug to namespaced check', () => {
|
|
99
|
+
const reg = createNamespacedRegistry('builtin',
|
|
100
|
+
makeCheck('no-eval'),
|
|
101
|
+
makeCheck('no-console'),
|
|
102
|
+
)
|
|
103
|
+
const selector: CheckSelector = { type: 'explicit', checkIds: ['no-eval'] }
|
|
104
|
+
const result = resolveChecks(selector, reg)
|
|
105
|
+
expect(result).toHaveLength(1)
|
|
106
|
+
expect(result[0]).toBe('builtin:no-eval')
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('resolves by exact namespaced slug', () => {
|
|
110
|
+
const reg = createNamespacedRegistry('builtin', makeCheck('no-eval'))
|
|
111
|
+
const selector: CheckSelector = { type: 'explicit', checkIds: ['builtin:no-eval'] }
|
|
112
|
+
expect(resolveChecks(selector, reg)).toEqual(['builtin:no-eval'])
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('filters out unknown slugs', () => {
|
|
116
|
+
const reg = createRegistry(makeCheck('exists'))
|
|
117
|
+
const selector: CheckSelector = { type: 'explicit', checkIds: ['exists', 'nope'] }
|
|
118
|
+
expect(resolveChecks(selector, reg)).toEqual(['exists'])
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
describe('pattern selector', () => {
|
|
123
|
+
it('matches tag/slug patterns like security/*', () => {
|
|
124
|
+
const reg = createRegistry(
|
|
125
|
+
makeCheck('no-eval', ['security']),
|
|
126
|
+
makeCheck('null-safety', ['quality']),
|
|
127
|
+
makeCheck('sql-injection', ['security']),
|
|
128
|
+
)
|
|
129
|
+
const selector: CheckSelector = { type: 'pattern', include: ['security/*'] }
|
|
130
|
+
const result = resolveChecks(selector, reg)
|
|
131
|
+
expect(result).toHaveLength(2)
|
|
132
|
+
expect(result).toContain('no-eval')
|
|
133
|
+
expect(result).toContain('sql-injection')
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('matches bare slug patterns', () => {
|
|
137
|
+
const reg = createRegistry(
|
|
138
|
+
makeCheck('no-eval'), makeCheck('no-console'), makeCheck('null-safety'),
|
|
139
|
+
)
|
|
140
|
+
const selector: CheckSelector = { type: 'pattern', include: ['no-*'] }
|
|
141
|
+
const result = resolveChecks(selector, reg)
|
|
142
|
+
expect(result).toHaveLength(2)
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
it('excludes patterns correctly', () => {
|
|
146
|
+
const reg = createRegistry(
|
|
147
|
+
makeCheck('no-eval', ['security']),
|
|
148
|
+
makeCheck('no-console', ['quality']),
|
|
149
|
+
makeCheck('no-any', ['quality']),
|
|
150
|
+
)
|
|
151
|
+
const selector: CheckSelector = { type: 'pattern', include: ['no-*'], exclude: ['quality/*'] }
|
|
152
|
+
const result = resolveChecks(selector, reg)
|
|
153
|
+
expect(result).toEqual(['no-eval'])
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
it('matches namespaced slugs via tag patterns', () => {
|
|
157
|
+
const reg = createNamespacedRegistry('builtin',
|
|
158
|
+
makeCheck('no-eval', ['security']),
|
|
159
|
+
makeCheck('null-safety', ['quality']),
|
|
160
|
+
)
|
|
161
|
+
const selector: CheckSelector = { type: 'pattern', include: ['security/*'] }
|
|
162
|
+
const result = resolveChecks(selector, reg)
|
|
163
|
+
expect(result).toHaveLength(1)
|
|
164
|
+
expect(result[0]).toBe('builtin:no-eval')
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
describe('all selector', () => {
|
|
169
|
+
it('returns all checks', () => {
|
|
170
|
+
const reg = createRegistry(makeCheck('a'), makeCheck('b'), makeCheck('c'))
|
|
171
|
+
const selector: CheckSelector = { type: 'all' }
|
|
172
|
+
expect(resolveChecks(selector, reg)).toHaveLength(3)
|
|
173
|
+
})
|
|
174
|
+
|
|
175
|
+
it('excludes by pattern', () => {
|
|
176
|
+
const reg = createRegistry(
|
|
177
|
+
makeCheck('no-eval', ['security']),
|
|
178
|
+
makeCheck('null-safety', ['quality']),
|
|
179
|
+
)
|
|
180
|
+
const selector: CheckSelector = { type: 'all', exclude: ['security/*'] }
|
|
181
|
+
const result = resolveChecks(selector, reg)
|
|
182
|
+
expect(result).toEqual(['null-safety'])
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
})
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { FitnessRecipeRegistry } from '../registry.js';
|
|
4
|
+
|
|
5
|
+
import type { FitnessRecipe } from '../types.js';
|
|
6
|
+
|
|
7
|
+
const stub = (id: string, name: string, tags: string[] = []): FitnessRecipe => ({
|
|
8
|
+
id,
|
|
9
|
+
name,
|
|
10
|
+
displayName: name,
|
|
11
|
+
description: name,
|
|
12
|
+
tags,
|
|
13
|
+
checks: { type: 'all', exclude: [] },
|
|
14
|
+
execution: { mode: 'parallel', stopOnFirstFailure: false, timeout: 30_000 },
|
|
15
|
+
reporting: { format: 'table', verbose: false },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('FitnessRecipeRegistry', () => {
|
|
19
|
+
it('pre-loads built-in recipes by default', () => {
|
|
20
|
+
const reg = new FitnessRecipeRegistry({ logWarnings: false });
|
|
21
|
+
expect(reg.size).toBeGreaterThan(0);
|
|
22
|
+
expect(reg.has('default')).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('loadRecipe finds by name or id', () => {
|
|
26
|
+
const reg = new FitnessRecipeRegistry({ logWarnings: false });
|
|
27
|
+
expect(reg.loadRecipe('default')).toBeDefined();
|
|
28
|
+
expect(reg.loadRecipe('nope')).toBeUndefined();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('getByName / getById work independently', () => {
|
|
32
|
+
const reg = new FitnessRecipeRegistry({ logWarnings: false });
|
|
33
|
+
const def = reg.getByName('default');
|
|
34
|
+
expect(def).toBeDefined();
|
|
35
|
+
expect(reg.getById(def?.id ?? '')).toBe(def);
|
|
36
|
+
expect(reg.getById('NOT_EXIST')).toBeUndefined();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('register refuses to overwrite by default', () => {
|
|
40
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
41
|
+
reg.register(stub('URCP_a', 'a'));
|
|
42
|
+
expect(() => reg.register(stub('URCP_a', 'a'))).toThrow(/already registered/);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('register allows overwrite when explicitly requested', () => {
|
|
46
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
47
|
+
reg.register(stub('URCP_a', 'a'));
|
|
48
|
+
reg.register({ ...stub('URCP_a', 'a'), description: 'updated' }, { allowOverwrite: true });
|
|
49
|
+
expect(reg.getByName('a')?.description).toBe('updated');
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('registerAll mounts every recipe in a list', () => {
|
|
53
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
54
|
+
reg.clear();
|
|
55
|
+
reg.registerAll([stub('URCP_a', 'a'), stub('URCP_b', 'b')]);
|
|
56
|
+
expect(reg.size).toBe(2);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('remove returns true on hit, false on miss', () => {
|
|
60
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
61
|
+
reg.register(stub('URCP_a', 'a'));
|
|
62
|
+
expect(reg.remove('URCP_a')).toBe(true);
|
|
63
|
+
expect(reg.remove('URCP_a')).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('reset clears user-registered and restores built-ins', () => {
|
|
67
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
68
|
+
reg.register(stub('URCP_user', 'user'));
|
|
69
|
+
reg.reset();
|
|
70
|
+
expect(reg.has('user')).toBe(false);
|
|
71
|
+
expect(reg.has('default')).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('getByTag returns matching recipes', () => {
|
|
75
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
76
|
+
reg.register(stub('URCP_t1', 't1', ['custom-tag-xyz']));
|
|
77
|
+
reg.register(stub('URCP_t2', 't2', ['other-tag']));
|
|
78
|
+
expect(reg.getByTag('custom-tag-xyz').map((r) => r.name)).toEqual(['t1']);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('getNames returns all registered names', () => {
|
|
82
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
83
|
+
expect(reg.getNames()).toContain('default');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('listForDisplay distinguishes built-in vs user-defined', () => {
|
|
87
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
88
|
+
reg.register(stub('URCP_user', 'user'));
|
|
89
|
+
const display = reg.listForDisplay();
|
|
90
|
+
expect(display.find((d) => d.name === 'default')?.isBuiltIn).toBe(true);
|
|
91
|
+
expect(display.find((d) => d.name === 'user')?.isUserDefined).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('isOverridden / getOverriddenBuiltIns reflect override state', () => {
|
|
95
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
96
|
+
expect(reg.isOverridden('default')).toBe(false);
|
|
97
|
+
expect(reg.getOverriddenBuiltIns()).toEqual([]);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('getUserRecipesLoadResult is defined when loadUserRecipes runs', () => {
|
|
101
|
+
const reg = new FitnessRecipeRegistry({ logWarnings: false });
|
|
102
|
+
expect(reg.getUserRecipesLoadResult()).toBeDefined();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('getUserRecipesLoadResult is undefined when loadUserRecipes is disabled', () => {
|
|
106
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
107
|
+
expect(reg.getUserRecipesLoadResult()).toBeUndefined();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('clear removes everything', () => {
|
|
111
|
+
const reg = new FitnessRecipeRegistry({ loadUserRecipes: false, logWarnings: false });
|
|
112
|
+
reg.clear();
|
|
113
|
+
expect(reg.size).toBe(0);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { CheckAbortedError } from '../../framework/execution-context.js';
|
|
4
|
+
import { executeWithRetry } from '../retry.js';
|
|
5
|
+
|
|
6
|
+
const opts = (overrides: Partial<Parameters<typeof executeWithRetry>[1]> = {}) => ({
|
|
7
|
+
enabled: true,
|
|
8
|
+
maxRetries: 2,
|
|
9
|
+
checkId: 'check-id',
|
|
10
|
+
checkSlug: 'check-slug',
|
|
11
|
+
...overrides,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('executeWithRetry', () => {
|
|
15
|
+
it('returns result on first success without retrying', async () => {
|
|
16
|
+
const fn = vi.fn().mockResolvedValue(42);
|
|
17
|
+
const out = await executeWithRetry(fn, opts());
|
|
18
|
+
expect(out).toEqual({ result: 42, lastError: undefined, retryCount: 0, wasRetried: false });
|
|
19
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('does not retry CheckAbortedError', async () => {
|
|
23
|
+
const aborted = new CheckAbortedError('check-slug');
|
|
24
|
+
const fn = vi.fn().mockRejectedValue(aborted);
|
|
25
|
+
const out = await executeWithRetry(fn, opts());
|
|
26
|
+
expect(out.wasRetried).toBe(false);
|
|
27
|
+
expect(out.retryCount).toBe(0);
|
|
28
|
+
expect(out.lastError).toBe(aborted);
|
|
29
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('does not retry when retries are disabled', async () => {
|
|
33
|
+
const err = new Error('boom');
|
|
34
|
+
const fn = vi.fn().mockRejectedValue(err);
|
|
35
|
+
const out = await executeWithRetry(fn, opts({ enabled: false }));
|
|
36
|
+
expect(out.wasRetried).toBe(false);
|
|
37
|
+
expect(out.retryCount).toBe(0);
|
|
38
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('does not retry when maxRetries is 0', async () => {
|
|
42
|
+
const err = new Error('boom');
|
|
43
|
+
const fn = vi.fn().mockRejectedValue(err);
|
|
44
|
+
const out = await executeWithRetry(fn, opts({ maxRetries: 0 }));
|
|
45
|
+
expect(out.wasRetried).toBe(false);
|
|
46
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('retries up to maxRetries on transient failure and succeeds', async () => {
|
|
50
|
+
vi.useFakeTimers();
|
|
51
|
+
let calls = 0;
|
|
52
|
+
const fn = vi.fn().mockImplementation(() => {
|
|
53
|
+
calls++;
|
|
54
|
+
if (calls < 3) return Promise.reject(new Error(`fail-${calls}`));
|
|
55
|
+
return Promise.resolve('ok');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const promise = executeWithRetry(fn, opts({ maxRetries: 3 }));
|
|
59
|
+
await vi.runAllTimersAsync();
|
|
60
|
+
const out = await promise;
|
|
61
|
+
|
|
62
|
+
expect(out.result).toBe('ok');
|
|
63
|
+
expect(out.wasRetried).toBe(true);
|
|
64
|
+
expect(out.retryCount).toBe(2);
|
|
65
|
+
expect(fn).toHaveBeenCalledTimes(3);
|
|
66
|
+
vi.useRealTimers();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('returns lastError after exhausting retries', async () => {
|
|
70
|
+
vi.useFakeTimers();
|
|
71
|
+
const err = new Error('persistent');
|
|
72
|
+
const fn = vi.fn().mockRejectedValue(err);
|
|
73
|
+
const promise = executeWithRetry(fn, opts({ maxRetries: 2 }));
|
|
74
|
+
await vi.runAllTimersAsync();
|
|
75
|
+
const out = await promise;
|
|
76
|
+
expect(out.result).toBeUndefined();
|
|
77
|
+
expect(out.lastError).toBe(err);
|
|
78
|
+
expect(out.retryCount).toBe(2);
|
|
79
|
+
expect(out.wasRetried).toBe(true);
|
|
80
|
+
expect(fn).toHaveBeenCalledTimes(3); // initial + 2 retries
|
|
81
|
+
vi.useRealTimers();
|
|
82
|
+
});
|
|
83
|
+
});
|