@thymian/core 0.0.0-PLACEHOLDER
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/README.md +59 -0
- package/dist/actions/action.d.ts +5 -0
- package/dist/actions/action.d.ts.map +1 -0
- package/dist/actions/action.js +2 -0
- package/dist/actions/action.js.map +1 -0
- package/dist/actions/close.action.d.ts +3 -0
- package/dist/actions/close.action.d.ts.map +1 -0
- package/dist/actions/close.action.js +2 -0
- package/dist/actions/close.action.js.map +1 -0
- package/dist/actions/core-analyze.action.d.ts +11 -0
- package/dist/actions/core-analyze.action.d.ts.map +1 -0
- package/dist/actions/core-analyze.action.js +2 -0
- package/dist/actions/core-analyze.action.js.map +1 -0
- package/dist/actions/core-lint.action.d.ts +9 -0
- package/dist/actions/core-lint.action.d.ts.map +1 -0
- package/dist/actions/core-lint.action.js +2 -0
- package/dist/actions/core-lint.action.js.map +1 -0
- package/dist/actions/core-request-sample.action.d.ts +9 -0
- package/dist/actions/core-request-sample.action.d.ts.map +1 -0
- package/dist/actions/core-request-sample.action.js +2 -0
- package/dist/actions/core-request-sample.action.js.map +1 -0
- package/dist/actions/core-test.action.d.ts +10 -0
- package/dist/actions/core-test.action.d.ts.map +1 -0
- package/dist/actions/core-test.action.js +2 -0
- package/dist/actions/core-test.action.js.map +1 -0
- package/dist/actions/core-validation-input.d.ts +6 -0
- package/dist/actions/core-validation-input.d.ts.map +1 -0
- package/dist/actions/core-validation-input.js +2 -0
- package/dist/actions/core-validation-input.js.map +1 -0
- package/dist/actions/format-load.action.d.ts +16 -0
- package/dist/actions/format-load.action.d.ts.map +1 -0
- package/dist/actions/format-load.action.js +36 -0
- package/dist/actions/format-load.action.js.map +1 -0
- package/dist/actions/format.action.d.ts +4 -0
- package/dist/actions/format.action.d.ts.map +1 -0
- package/dist/actions/format.action.js +2 -0
- package/dist/actions/format.action.js.map +1 -0
- package/dist/actions/index.d.ts +39 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +14 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/ready.action.d.ts +3 -0
- package/dist/actions/ready.action.d.ts.map +1 -0
- package/dist/actions/ready.action.js +2 -0
- package/dist/actions/ready.action.js.map +1 -0
- package/dist/actions/report-flush.action.d.ts +6 -0
- package/dist/actions/report-flush.action.d.ts.map +1 -0
- package/dist/actions/report-flush.action.js +2 -0
- package/dist/actions/report-flush.action.js.map +1 -0
- package/dist/actions/request-dispatch.action.d.ts +13 -0
- package/dist/actions/request-dispatch.action.d.ts.map +1 -0
- package/dist/actions/request-dispatch.action.js +45 -0
- package/dist/actions/request-dispatch.action.js.map +1 -0
- package/dist/actions/traffic-load.action.d.ts +16 -0
- package/dist/actions/traffic-load.action.d.ts.map +1 -0
- package/dist/actions/traffic-load.action.js +36 -0
- package/dist/actions/traffic-load.action.js.map +1 -0
- package/dist/actions/validation-result.d.ts +18 -0
- package/dist/actions/validation-result.d.ts.map +1 -0
- package/dist/actions/validation-result.js +81 -0
- package/dist/actions/validation-result.js.map +1 -0
- package/dist/ajv.d.ts +5 -0
- package/dist/ajv.d.ts.map +1 -0
- package/dist/ajv.js +9 -0
- package/dist/ajv.js.map +1 -0
- package/dist/chalk.d.ts +2 -0
- package/dist/chalk.d.ts.map +1 -0
- package/dist/chalk.js +2 -0
- package/dist/chalk.js.map +1 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/core-plugin.d.ts +5 -0
- package/dist/core-plugin.d.ts.map +1 -0
- package/dist/core-plugin.js +62 -0
- package/dist/core-plugin.js.map +1 -0
- package/dist/emitter/action-event.d.ts +19 -0
- package/dist/emitter/action-event.d.ts.map +1 -0
- package/dist/emitter/action-event.js +2 -0
- package/dist/emitter/action-event.js.map +1 -0
- package/dist/emitter/error-event.d.ts +13 -0
- package/dist/emitter/error-event.d.ts.map +1 -0
- package/dist/emitter/error-event.js +2 -0
- package/dist/emitter/error-event.js.map +1 -0
- package/dist/emitter/events.d.ts +10 -0
- package/dist/emitter/events.d.ts.map +1 -0
- package/dist/emitter/events.js +2 -0
- package/dist/emitter/events.js.map +1 -0
- package/dist/emitter/index.d.ts +6 -0
- package/dist/emitter/index.d.ts.map +1 -0
- package/dist/emitter/index.js +6 -0
- package/dist/emitter/index.js.map +1 -0
- package/dist/emitter/thymian-emitter.d.ts +61 -0
- package/dist/emitter/thymian-emitter.d.ts.map +1 -0
- package/dist/emitter/thymian-emitter.js +371 -0
- package/dist/emitter/thymian-emitter.js.map +1 -0
- package/dist/emitter/utils.d.ts +8 -0
- package/dist/emitter/utils.d.ts.map +1 -0
- package/dist/emitter/utils.js +16 -0
- package/dist/emitter/utils.js.map +1 -0
- package/dist/events/error.event.d.ts +5 -0
- package/dist/events/error.event.d.ts.map +1 -0
- package/dist/events/error.event.js +49 -0
- package/dist/events/error.event.js.map +1 -0
- package/dist/events/exit.event.d.ts +14 -0
- package/dist/events/exit.event.d.ts.map +1 -0
- package/dist/events/exit.event.js +9 -0
- package/dist/events/exit.event.js.map +1 -0
- package/dist/events/index.d.ts +15 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +4 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/register-plugin.event.d.ts +51 -0
- package/dist/events/register-plugin.event.d.ts.map +1 -0
- package/dist/events/register-plugin.event.js +29 -0
- package/dist/events/register-plugin.event.js.map +1 -0
- package/dist/events/report.event.d.ts +104 -0
- package/dist/events/report.event.d.ts.map +1 -0
- package/dist/events/report.event.js +109 -0
- package/dist/events/report.event.js.map +1 -0
- package/dist/format/circular-references.d.ts +3 -0
- package/dist/format/circular-references.d.ts.map +1 -0
- package/dist/format/circular-references.js +71 -0
- package/dist/format/circular-references.js.map +1 -0
- package/dist/format/edges/edge.d.ts +9 -0
- package/dist/format/edges/edge.d.ts.map +1 -0
- package/dist/format/edges/edge.js +2 -0
- package/dist/format/edges/edge.js.map +1 -0
- package/dist/format/edges/has-sample.edge.d.ts +5 -0
- package/dist/format/edges/has-sample.edge.d.ts.map +1 -0
- package/dist/format/edges/has-sample.edge.js +2 -0
- package/dist/format/edges/has-sample.edge.js.map +1 -0
- package/dist/format/edges/http-link.edge.d.ts +10 -0
- package/dist/format/edges/http-link.edge.d.ts.map +1 -0
- package/dist/format/edges/http-link.edge.js +2 -0
- package/dist/format/edges/http-link.edge.js.map +1 -0
- package/dist/format/edges/http-transaction.edge.d.ts +5 -0
- package/dist/format/edges/http-transaction.edge.d.ts.map +1 -0
- package/dist/format/edges/http-transaction.edge.js +2 -0
- package/dist/format/edges/http-transaction.edge.js.map +1 -0
- package/dist/format/edges/is-secured-with.edge.d.ts +5 -0
- package/dist/format/edges/is-secured-with.edge.d.ts.map +1 -0
- package/dist/format/edges/is-secured-with.edge.js +2 -0
- package/dist/format/edges/is-secured-with.edge.js.map +1 -0
- package/dist/format/edges/sample-http-transaction.edge.d.ts +5 -0
- package/dist/format/edges/sample-http-transaction.edge.d.ts.map +1 -0
- package/dist/format/edges/sample-http-transaction.edge.js +2 -0
- package/dist/format/edges/sample-http-transaction.edge.js.map +1 -0
- package/dist/format/format-location.d.ts +13 -0
- package/dist/format/format-location.d.ts.map +1 -0
- package/dist/format/format-location.js +2 -0
- package/dist/format/format-location.js.map +1 -0
- package/dist/format/http-filter-expression-to-transaction-filter.d.ts +5 -0
- package/dist/format/http-filter-expression-to-transaction-filter.d.ts.map +1 -0
- package/dist/format/http-filter-expression-to-transaction-filter.js +88 -0
- package/dist/format/http-filter-expression-to-transaction-filter.js.map +1 -0
- package/dist/format/index.d.ts +14 -0
- package/dist/format/index.d.ts.map +1 -0
- package/dist/format/index.js +14 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/nodes/http-request.node.d.ts +29 -0
- package/dist/format/nodes/http-request.node.d.ts.map +1 -0
- package/dist/format/nodes/http-request.node.js +2 -0
- package/dist/format/nodes/http-request.node.js.map +1 -0
- package/dist/format/nodes/http-response.node.d.ts +12 -0
- package/dist/format/nodes/http-response.node.d.ts.map +1 -0
- package/dist/format/nodes/http-response.node.js +2 -0
- package/dist/format/nodes/http-response.node.js.map +1 -0
- package/dist/format/nodes/node.d.ts +9 -0
- package/dist/format/nodes/node.d.ts.map +1 -0
- package/dist/format/nodes/node.js +2 -0
- package/dist/format/nodes/node.js.map +1 -0
- package/dist/format/nodes/sample-http-request.node.d.ts +7 -0
- package/dist/format/nodes/sample-http-request.node.d.ts.map +1 -0
- package/dist/format/nodes/sample-http-request.node.js +2 -0
- package/dist/format/nodes/sample-http-request.node.js.map +1 -0
- package/dist/format/nodes/sample-http-response.node.d.ts +7 -0
- package/dist/format/nodes/sample-http-response.node.d.ts.map +1 -0
- package/dist/format/nodes/sample-http-response.node.js +2 -0
- package/dist/format/nodes/sample-http-response.node.js.map +1 -0
- package/dist/format/nodes/security-scheme.node.d.ts +17 -0
- package/dist/format/nodes/security-scheme.node.d.ts.map +1 -0
- package/dist/format/nodes/security-scheme.node.js +2 -0
- package/dist/format/nodes/security-scheme.node.js.map +1 -0
- package/dist/format/parameter.d.ts +10 -0
- package/dist/format/parameter.d.ts.map +1 -0
- package/dist/format/parameter.js +2 -0
- package/dist/format/parameter.js.map +1 -0
- package/dist/format/serialization-style/cookie.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/cookie.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/cookie.serialization-style.js +7 -0
- package/dist/format/serialization-style/cookie.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/header.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/header.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/header.serialization-style.js +7 -0
- package/dist/format/serialization-style/header.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/index.d.ts +6 -0
- package/dist/format/serialization-style/index.d.ts.map +1 -0
- package/dist/format/serialization-style/index.js +6 -0
- package/dist/format/serialization-style/index.js.map +1 -0
- package/dist/format/serialization-style/path.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/path.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/path.serialization-style.js +7 -0
- package/dist/format/serialization-style/path.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/query.serialization-style.d.ts +5 -0
- package/dist/format/serialization-style/query.serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/query.serialization-style.js +7 -0
- package/dist/format/serialization-style/query.serialization-style.js.map +1 -0
- package/dist/format/serialization-style/serialization-style.d.ts +13 -0
- package/dist/format/serialization-style/serialization-style.d.ts.map +1 -0
- package/dist/format/serialization-style/serialization-style.js +25 -0
- package/dist/format/serialization-style/serialization-style.js.map +1 -0
- package/dist/format/thymian-format.d.ts +109 -0
- package/dist/format/thymian-format.d.ts.map +1 -0
- package/dist/format/thymian-format.js +437 -0
- package/dist/format/thymian-format.js.map +1 -0
- package/dist/format/thymian-schema.d.ts +56 -0
- package/dist/format/thymian-schema.d.ts.map +1 -0
- package/dist/format/thymian-schema.js +2 -0
- package/dist/format/thymian-schema.js.map +1 -0
- package/dist/format/utils.d.ts +12 -0
- package/dist/format/utils.d.ts.map +1 -0
- package/dist/format/utils.js +85 -0
- package/dist/format/utils.js.map +1 -0
- package/dist/http-filter-visitor.d.ts +76 -0
- package/dist/http-filter-visitor.d.ts.map +1 -0
- package/dist/http-filter-visitor.js +168 -0
- package/dist/http-filter-visitor.js.map +1 -0
- package/dist/http-filter.d.ts +140 -0
- package/dist/http-filter.d.ts.map +1 -0
- package/dist/http-filter.js +137 -0
- package/dist/http-filter.js.map +1 -0
- package/dist/http-status-codes/1xx/index.d.ts +15 -0
- package/dist/http-status-codes/1xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/1xx/index.js +15 -0
- package/dist/http-status-codes/1xx/index.js.map +1 -0
- package/dist/http-status-codes/1xx/informational.phrases.d.ts +4 -0
- package/dist/http-status-codes/1xx/informational.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/1xx/informational.phrases.js +10 -0
- package/dist/http-status-codes/1xx/informational.phrases.js.map +1 -0
- package/dist/http-status-codes/1xx/informational.status-codes.d.ts +4 -0
- package/dist/http-status-codes/1xx/informational.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/1xx/informational.status-codes.js +5 -0
- package/dist/http-status-codes/1xx/informational.status-codes.js.map +1 -0
- package/dist/http-status-codes/2xx/index.d.ts +25 -0
- package/dist/http-status-codes/2xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/2xx/index.js +25 -0
- package/dist/http-status-codes/2xx/index.js.map +1 -0
- package/dist/http-status-codes/2xx/successful.phrases.d.ts +4 -0
- package/dist/http-status-codes/2xx/successful.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/2xx/successful.phrases.js +15 -0
- package/dist/http-status-codes/2xx/successful.phrases.js.map +1 -0
- package/dist/http-status-codes/2xx/successful.status-codes.d.ts +4 -0
- package/dist/http-status-codes/2xx/successful.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/2xx/successful.status-codes.js +7 -0
- package/dist/http-status-codes/2xx/successful.status-codes.js.map +1 -0
- package/dist/http-status-codes/3xx/index.d.ts +21 -0
- package/dist/http-status-codes/3xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/3xx/index.js +21 -0
- package/dist/http-status-codes/3xx/index.js.map +1 -0
- package/dist/http-status-codes/3xx/redirection.phrases.d.ts +4 -0
- package/dist/http-status-codes/3xx/redirection.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/3xx/redirection.phrases.js +13 -0
- package/dist/http-status-codes/3xx/redirection.phrases.js.map +1 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.d.ts +4 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.js +7 -0
- package/dist/http-status-codes/3xx/redirection.status-codes.js.map +1 -0
- package/dist/http-status-codes/4xx/client-error.phrases.d.ts +4 -0
- package/dist/http-status-codes/4xx/client-error.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/4xx/client-error.phrases.js +34 -0
- package/dist/http-status-codes/4xx/client-error.phrases.js.map +1 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.d.ts +4 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.js +8 -0
- package/dist/http-status-codes/4xx/client-error.status-codes.js.map +1 -0
- package/dist/http-status-codes/4xx/index.d.ts +63 -0
- package/dist/http-status-codes/4xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/4xx/index.js +63 -0
- package/dist/http-status-codes/4xx/index.js.map +1 -0
- package/dist/http-status-codes/5xx/index.d.ts +29 -0
- package/dist/http-status-codes/5xx/index.d.ts.map +1 -0
- package/dist/http-status-codes/5xx/index.js +29 -0
- package/dist/http-status-codes/5xx/index.js.map +1 -0
- package/dist/http-status-codes/5xx/server-error.phrases.d.ts +4 -0
- package/dist/http-status-codes/5xx/server-error.phrases.d.ts.map +1 -0
- package/dist/http-status-codes/5xx/server-error.phrases.js +17 -0
- package/dist/http-status-codes/5xx/server-error.phrases.js.map +1 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.d.ts +4 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.d.ts.map +1 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.js +7 -0
- package/dist/http-status-codes/5xx/server-error.status-codes.js.map +1 -0
- package/dist/http-status-codes/http-status-code-ranges.d.ts +11 -0
- package/dist/http-status-codes/http-status-code-ranges.d.ts.map +1 -0
- package/dist/http-status-codes/http-status-code-ranges.js +19 -0
- package/dist/http-status-codes/http-status-code-ranges.js.map +1 -0
- package/dist/http-status-codes/http-status-code.d.ts +8 -0
- package/dist/http-status-codes/http-status-code.d.ts.map +1 -0
- package/dist/http-status-codes/http-status-code.js +13 -0
- package/dist/http-status-codes/http-status-code.js.map +1 -0
- package/dist/http-status-codes/http-status-phrase.d.ts +8 -0
- package/dist/http-status-codes/http-status-phrase.d.ts.map +1 -0
- package/dist/http-status-codes/http-status-phrase.js +13 -0
- package/dist/http-status-codes/http-status-phrase.js.map +1 -0
- package/dist/http-status-codes/index.d.ts +10 -0
- package/dist/http-status-codes/index.d.ts.map +1 -0
- package/dist/http-status-codes/index.js +10 -0
- package/dist/http-status-codes/index.js.map +1 -0
- package/dist/http-status-codes/phrase-to-status-code.d.ts +62 -0
- package/dist/http-status-codes/phrase-to-status-code.d.ts.map +1 -0
- package/dist/http-status-codes/phrase-to-status-code.js +13 -0
- package/dist/http-status-codes/phrase-to-status-code.js.map +1 -0
- package/dist/http-status-codes/status-code-to-phrase.d.ts +62 -0
- package/dist/http-status-codes/status-code-to-phrase.d.ts.map +1 -0
- package/dist/http-status-codes/status-code-to-phrase.js +13 -0
- package/dist/http-status-codes/status-code-to-phrase.js.map +1 -0
- package/dist/http-status-codes/validate.d.ts +5 -0
- package/dist/http-status-codes/validate.d.ts.map +1 -0
- package/dist/http-status-codes/validate.js +28 -0
- package/dist/http-status-codes/validate.js.map +1 -0
- package/dist/http-testing/http-test/create-hook-runner.d.ts +21 -0
- package/dist/http-testing/http-test/create-hook-runner.d.ts.map +1 -0
- package/dist/http-testing/http-test/create-hook-runner.js +17 -0
- package/dist/http-testing/http-test/create-hook-runner.js.map +1 -0
- package/dist/http-testing/http-test/create-http-test-context.d.ts +3 -0
- package/dist/http-testing/http-test/create-http-test-context.d.ts.map +1 -0
- package/dist/http-testing/http-test/create-http-test-context.js +24 -0
- package/dist/http-testing/http-test/create-http-test-context.js.map +1 -0
- package/dist/http-testing/http-test/http-test-case-result.d.ts +46 -0
- package/dist/http-testing/http-test/http-test-case-result.d.ts.map +1 -0
- package/dist/http-testing/http-test/http-test-case-result.js +2 -0
- package/dist/http-testing/http-test/http-test-case-result.js.map +1 -0
- package/dist/http-testing/http-test/http-test-case.d.ts +36 -0
- package/dist/http-testing/http-test/http-test-case.d.ts.map +1 -0
- package/dist/http-testing/http-test/http-test-case.js +2 -0
- package/dist/http-testing/http-test/http-test-case.js.map +1 -0
- package/dist/http-testing/http-test/http-test-context.d.ts +20 -0
- package/dist/http-testing/http-test/http-test-context.d.ts.map +1 -0
- package/dist/http-testing/http-test/http-test-context.js +2 -0
- package/dist/http-testing/http-test/http-test-context.js.map +1 -0
- package/dist/http-testing/http-test/http-test-hooks.d.ts +26 -0
- package/dist/http-testing/http-test/http-test-hooks.d.ts.map +1 -0
- package/dist/http-testing/http-test/http-test-hooks.js +2 -0
- package/dist/http-testing/http-test/http-test-hooks.js.map +1 -0
- package/dist/http-testing/http-test/http-test-pipeline.d.ts +10 -0
- package/dist/http-testing/http-test/http-test-pipeline.d.ts.map +1 -0
- package/dist/http-testing/http-test/http-test-pipeline.js +2 -0
- package/dist/http-testing/http-test/http-test-pipeline.js.map +1 -0
- package/dist/http-testing/http-test/http-test.d.ts +11 -0
- package/dist/http-testing/http-test/http-test.d.ts.map +1 -0
- package/dist/http-testing/http-test/http-test.js +35 -0
- package/dist/http-testing/http-test/http-test.js.map +1 -0
- package/dist/http-testing/http-test/index.d.ts +10 -0
- package/dist/http-testing/http-test/index.d.ts.map +1 -0
- package/dist/http-testing/http-test/index.js +10 -0
- package/dist/http-testing/http-test/index.js.map +1 -0
- package/dist/http-testing/http-test/utils.d.ts +11 -0
- package/dist/http-testing/http-test/utils.d.ts.map +1 -0
- package/dist/http-testing/http-test/utils.js +16 -0
- package/dist/http-testing/http-test/utils.js.map +1 -0
- package/dist/http-testing/index.d.ts +7 -0
- package/dist/http-testing/index.d.ts.map +1 -0
- package/dist/http-testing/index.js +7 -0
- package/dist/http-testing/index.js.map +1 -0
- package/dist/http-testing/operators/expect-for-transaction.operator.d.ts +5 -0
- package/dist/http-testing/operators/expect-for-transaction.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/expect-for-transaction.operator.js +39 -0
- package/dist/http-testing/operators/expect-for-transaction.operator.js.map +1 -0
- package/dist/http-testing/operators/expect-headers.operator.d.ts +4 -0
- package/dist/http-testing/operators/expect-headers.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/expect-headers.operator.js +37 -0
- package/dist/http-testing/operators/expect-headers.operator.js.map +1 -0
- package/dist/http-testing/operators/expect-status-code.operator.d.ts +5 -0
- package/dist/http-testing/operators/expect-status-code.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/expect-status-code.operator.js +55 -0
- package/dist/http-testing/operators/expect-status-code.operator.js.map +1 -0
- package/dist/http-testing/operators/expect.operator.d.ts +4 -0
- package/dist/http-testing/operators/expect.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/expect.operator.js +31 -0
- package/dist/http-testing/operators/expect.operator.js.map +1 -0
- package/dist/http-testing/operators/fail.operator.d.ts +4 -0
- package/dist/http-testing/operators/fail.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/fail.operator.js +8 -0
- package/dist/http-testing/operators/fail.operator.js.map +1 -0
- package/dist/http-testing/operators/filter-http-transactions.operator.d.ts +10 -0
- package/dist/http-testing/operators/filter-http-transactions.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/filter-http-transactions.operator.js +18 -0
- package/dist/http-testing/operators/filter-http-transactions.operator.js.map +1 -0
- package/dist/http-testing/operators/generate-requests.operator.d.ts +10 -0
- package/dist/http-testing/operators/generate-requests.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/generate-requests.operator.js +44 -0
- package/dist/http-testing/operators/generate-requests.operator.js.map +1 -0
- package/dist/http-testing/operators/index.d.ts +21 -0
- package/dist/http-testing/operators/index.d.ts.map +1 -0
- package/dist/http-testing/operators/index.js +21 -0
- package/dist/http-testing/operators/index.js.map +1 -0
- package/dist/http-testing/operators/map-to-grouped-test-case.operator.d.ts +7 -0
- package/dist/http-testing/operators/map-to-grouped-test-case.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/map-to-grouped-test-case.operator.js +32 -0
- package/dist/http-testing/operators/map-to-grouped-test-case.operator.js.map +1 -0
- package/dist/http-testing/operators/map-to-test-case.operator.d.ts +7 -0
- package/dist/http-testing/operators/map-to-test-case.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/map-to-test-case.operator.js +21 -0
- package/dist/http-testing/operators/map-to-test-case.operator.js.map +1 -0
- package/dist/http-testing/operators/override-headers.operator.d.ts +5 -0
- package/dist/http-testing/operators/override-headers.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/override-headers.operator.js +18 -0
- package/dist/http-testing/operators/override-headers.operator.js.map +1 -0
- package/dist/http-testing/operators/override-with-previous.operator.d.ts +5 -0
- package/dist/http-testing/operators/override-with-previous.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/override-with-previous.operator.js +23 -0
- package/dist/http-testing/operators/override-with-previous.operator.js.map +1 -0
- package/dist/http-testing/operators/replay-previous-step.operator.d.ts +5 -0
- package/dist/http-testing/operators/replay-previous-step.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/replay-previous-step.operator.js +27 -0
- package/dist/http-testing/operators/replay-previous-step.operator.js.map +1 -0
- package/dist/http-testing/operators/reply-previous-but-expect-response.operator.d.ts +7 -0
- package/dist/http-testing/operators/reply-previous-but-expect-response.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/reply-previous-but-expect-response.operator.js +61 -0
- package/dist/http-testing/operators/reply-previous-but-expect-response.operator.js.map +1 -0
- package/dist/http-testing/operators/requires-authorization.operator.d.ts +5 -0
- package/dist/http-testing/operators/requires-authorization.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/requires-authorization.operator.js +9 -0
- package/dist/http-testing/operators/requires-authorization.operator.js.map +1 -0
- package/dist/http-testing/operators/run-requests.operator.d.ts +14 -0
- package/dist/http-testing/operators/run-requests.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/run-requests.operator.js +139 -0
- package/dist/http-testing/operators/run-requests.operator.js.map +1 -0
- package/dist/http-testing/operators/single-step-for-transaction.operator.d.ts +5 -0
- package/dist/http-testing/operators/single-step-for-transaction.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/single-step-for-transaction.operator.js +43 -0
- package/dist/http-testing/operators/single-step-for-transaction.operator.js.map +1 -0
- package/dist/http-testing/operators/skip.operator.d.ts +5 -0
- package/dist/http-testing/operators/skip.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/skip.operator.js +11 -0
- package/dist/http-testing/operators/skip.operator.js.map +1 -0
- package/dist/http-testing/operators/step.operator.d.ts +5 -0
- package/dist/http-testing/operators/step.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/step.operator.js +20 -0
- package/dist/http-testing/operators/step.operator.js.map +1 -0
- package/dist/http-testing/operators/utils.d.ts +10 -0
- package/dist/http-testing/operators/utils.d.ts.map +1 -0
- package/dist/http-testing/operators/utils.js +17 -0
- package/dist/http-testing/operators/utils.js.map +1 -0
- package/dist/http-testing/operators/validate-responses.operator.d.ts +4 -0
- package/dist/http-testing/operators/validate-responses.operator.d.ts.map +1 -0
- package/dist/http-testing/operators/validate-responses.operator.js +33 -0
- package/dist/http-testing/operators/validate-responses.operator.js.map +1 -0
- package/dist/http-testing/serialize-parameter.d.ts +6 -0
- package/dist/http-testing/serialize-parameter.d.ts.map +1 -0
- package/dist/http-testing/serialize-parameter.js +51 -0
- package/dist/http-testing/serialize-parameter.js.map +1 -0
- package/dist/http-testing/serialize-request.d.ts +7 -0
- package/dist/http-testing/serialize-request.d.ts.map +1 -0
- package/dist/http-testing/serialize-request.js +112 -0
- package/dist/http-testing/serialize-request.js.map +1 -0
- package/dist/http-testing/test-builder/builder-pipeline.d.ts +4 -0
- package/dist/http-testing/test-builder/builder-pipeline.d.ts.map +1 -0
- package/dist/http-testing/test-builder/builder-pipeline.js +2 -0
- package/dist/http-testing/test-builder/builder-pipeline.js.map +1 -0
- package/dist/http-testing/test-builder/compilers/http-filter-to-transaction-filter.d.ts +9 -0
- package/dist/http-testing/test-builder/compilers/http-filter-to-transaction-filter.d.ts.map +1 -0
- package/dist/http-testing/test-builder/compilers/http-filter-to-transaction-filter.js +114 -0
- package/dist/http-testing/test-builder/compilers/http-filter-to-transaction-filter.js.map +1 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-response-checker.d.ts +4 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-response-checker.d.ts.map +1 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-response-checker.js +36 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-response-checker.js.map +1 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-transaction-validator.d.ts +4 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-transaction-validator.d.ts.map +1 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-transaction-validator.js +65 -0
- package/dist/http-testing/test-builder/compilers/response-scoped-to-transaction-validator.js.map +1 -0
- package/dist/http-testing/test-builder/extract-value-from-response.d.ts +4 -0
- package/dist/http-testing/test-builder/extract-value-from-response.d.ts.map +1 -0
- package/dist/http-testing/test-builder/extract-value-from-response.js +16 -0
- package/dist/http-testing/test-builder/extract-value-from-response.js.map +1 -0
- package/dist/http-testing/test-builder/override-request-template.d.ts +4 -0
- package/dist/http-testing/test-builder/override-request-template.d.ts.map +1 -0
- package/dist/http-testing/test-builder/override-request-template.js +33 -0
- package/dist/http-testing/test-builder/override-request-template.js.map +1 -0
- package/dist/http-testing/test-builder/reply-step-builder.d.ts +10 -0
- package/dist/http-testing/test-builder/reply-step-builder.d.ts.map +1 -0
- package/dist/http-testing/test-builder/reply-step-builder.js +39 -0
- package/dist/http-testing/test-builder/reply-step-builder.js.map +1 -0
- package/dist/http-testing/test-builder/single-step-test-builder.d.ts +42 -0
- package/dist/http-testing/test-builder/single-step-test-builder.d.ts.map +1 -0
- package/dist/http-testing/test-builder/single-step-test-builder.js +112 -0
- package/dist/http-testing/test-builder/single-step-test-builder.js.map +1 -0
- package/dist/http-testing/validate/ajv.d.ts +3 -0
- package/dist/http-testing/validate/ajv.d.ts.map +1 -0
- package/dist/http-testing/validate/ajv.js +7 -0
- package/dist/http-testing/validate/ajv.js.map +1 -0
- package/dist/http-testing/validate/index.d.ts +9 -0
- package/dist/http-testing/validate/index.d.ts.map +1 -0
- package/dist/http-testing/validate/index.js +9 -0
- package/dist/http-testing/validate/index.js.map +1 -0
- package/dist/http-testing/validate/validate-body.d.ts +5 -0
- package/dist/http-testing/validate/validate-body.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-body.js +62 -0
- package/dist/http-testing/validate/validate-body.js.map +1 -0
- package/dist/http-testing/validate/validate-headers.d.ts +8 -0
- package/dist/http-testing/validate/validate-headers.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-headers.js +101 -0
- package/dist/http-testing/validate/validate-headers.js.map +1 -0
- package/dist/http-testing/validate/validate-request-body.d.ts +5 -0
- package/dist/http-testing/validate/validate-request-body.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-request-body.js +71 -0
- package/dist/http-testing/validate/validate-request-body.js.map +1 -0
- package/dist/http-testing/validate/validate-request-headers.d.ts +8 -0
- package/dist/http-testing/validate/validate-request-headers.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-request-headers.js +93 -0
- package/dist/http-testing/validate/validate-request-headers.js.map +1 -0
- package/dist/http-testing/validate/validate-request-path-parameters.d.ts +6 -0
- package/dist/http-testing/validate/validate-request-path-parameters.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-request-path-parameters.js +69 -0
- package/dist/http-testing/validate/validate-request-path-parameters.js.map +1 -0
- package/dist/http-testing/validate/validate-request-query-parameters.d.ts +7 -0
- package/dist/http-testing/validate/validate-request-query-parameters.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-request-query-parameters.js +91 -0
- package/dist/http-testing/validate/validate-request-query-parameters.js.map +1 -0
- package/dist/http-testing/validate/validate-response.d.ts +7 -0
- package/dist/http-testing/validate/validate-response.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-response.js +15 -0
- package/dist/http-testing/validate/validate-response.js.map +1 -0
- package/dist/http-testing/validate/validate-status-code.d.ts +3 -0
- package/dist/http-testing/validate/validate-status-code.d.ts.map +1 -0
- package/dist/http-testing/validate/validate-status-code.js +25 -0
- package/dist/http-testing/validate/validate-status-code.js.map +1 -0
- package/dist/http.d.ts +29 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +2 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/log-level.d.ts +5 -0
- package/dist/logger/log-level.d.ts.map +1 -0
- package/dist/logger/log-level.js +24 -0
- package/dist/logger/log-level.js.map +1 -0
- package/dist/logger/logger.d.ts +13 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +2 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/logger/noop.logger.d.ts +15 -0
- package/dist/logger/noop.logger.d.ts.map +1 -0
- package/dist/logger/noop.logger.js +18 -0
- package/dist/logger/noop.logger.js.map +1 -0
- package/dist/logger/text.logger.d.ts +16 -0
- package/dist/logger/text.logger.d.ts.map +1 -0
- package/dist/logger/text.logger.js +51 -0
- package/dist/logger/text.logger.js.map +1 -0
- package/dist/report-sorter.d.ts +16 -0
- package/dist/report-sorter.d.ts.map +1 -0
- package/dist/report-sorter.js +193 -0
- package/dist/report-sorter.js.map +1 -0
- package/dist/rules/ajv-validate.d.ts +2 -0
- package/dist/rules/ajv-validate.d.ts.map +1 -0
- package/dist/rules/ajv-validate.js +4 -0
- package/dist/rules/ajv-validate.js.map +1 -0
- package/dist/rules/captured-trace-to-string.d.ts +3 -0
- package/dist/rules/captured-trace-to-string.d.ts.map +1 -0
- package/dist/rules/captured-trace-to-string.js +27 -0
- package/dist/rules/captured-trace-to-string.js.map +1 -0
- package/dist/rules/common-http-converters.d.ts +8 -0
- package/dist/rules/common-http-converters.d.ts.map +1 -0
- package/dist/rules/common-http-converters.js +58 -0
- package/dist/rules/common-http-converters.js.map +1 -0
- package/dist/rules/contexts.d.ts +63 -0
- package/dist/rules/contexts.d.ts.map +1 -0
- package/dist/rules/contexts.js +2 -0
- package/dist/rules/contexts.js.map +1 -0
- package/dist/rules/index.d.ts +16 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +16 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/rule-builder.d.ts +34 -0
- package/dist/rules/rule-builder.d.ts.map +1 -0
- package/dist/rules/rule-builder.js +112 -0
- package/dist/rules/rule-builder.js.map +1 -0
- package/dist/rules/rule-configuration.d.ts +10 -0
- package/dist/rules/rule-configuration.d.ts.map +1 -0
- package/dist/rules/rule-configuration.js +2 -0
- package/dist/rules/rule-configuration.js.map +1 -0
- package/dist/rules/rule-filter.d.ts +9 -0
- package/dist/rules/rule-filter.d.ts.map +1 -0
- package/dist/rules/rule-filter.js +12 -0
- package/dist/rules/rule-filter.js.map +1 -0
- package/dist/rules/rule-fn.d.ts +7 -0
- package/dist/rules/rule-fn.d.ts.map +1 -0
- package/dist/rules/rule-fn.js +2 -0
- package/dist/rules/rule-fn.js.map +1 -0
- package/dist/rules/rule-loader.d.ts +8 -0
- package/dist/rules/rule-loader.d.ts.map +1 -0
- package/dist/rules/rule-loader.js +124 -0
- package/dist/rules/rule-loader.js.map +1 -0
- package/dist/rules/rule-meta.d.ts +20 -0
- package/dist/rules/rule-meta.d.ts.map +1 -0
- package/dist/rules/rule-meta.js +18 -0
- package/dist/rules/rule-meta.js.map +1 -0
- package/dist/rules/rule-runner.d.ts +30 -0
- package/dist/rules/rule-runner.d.ts.map +1 -0
- package/dist/rules/rule-runner.js +129 -0
- package/dist/rules/rule-runner.js.map +1 -0
- package/dist/rules/rule-set.d.ts +9 -0
- package/dist/rules/rule-set.d.ts.map +1 -0
- package/dist/rules/rule-set.js +2 -0
- package/dist/rules/rule-set.js.map +1 -0
- package/dist/rules/rule-severity.d.ts +10 -0
- package/dist/rules/rule-severity.d.ts.map +1 -0
- package/dist/rules/rule-severity.js +12 -0
- package/dist/rules/rule-severity.js.map +1 -0
- package/dist/rules/rule-violation.d.ts +22 -0
- package/dist/rules/rule-violation.d.ts.map +1 -0
- package/dist/rules/rule-violation.js +2 -0
- package/dist/rules/rule-violation.js.map +1 -0
- package/dist/rules/rule.d.ts +10 -0
- package/dist/rules/rule.d.ts.map +1 -0
- package/dist/rules/rule.js +2 -0
- package/dist/rules/rule.js.map +1 -0
- package/dist/rules/traffic.d.ts +25 -0
- package/dist/rules/traffic.d.ts.map +1 -0
- package/dist/rules/traffic.js +2 -0
- package/dist/rules/traffic.js.map +1 -0
- package/dist/thymian-plugin.d.ts +38 -0
- package/dist/thymian-plugin.d.ts.map +1 -0
- package/dist/thymian-plugin.js +24 -0
- package/dist/thymian-plugin.js.map +1 -0
- package/dist/thymian.d.ts +85 -0
- package/dist/thymian.d.ts.map +1 -0
- package/dist/thymian.error.d.ts +26 -0
- package/dist/thymian.error.d.ts.map +1 -0
- package/dist/thymian.error.js +34 -0
- package/dist/thymian.error.js.map +1 -0
- package/dist/thymian.js +322 -0
- package/dist/thymian.js.map +1 -0
- package/dist/utils.d.ts +40 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +139 -0
- package/dist/utils.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { isRuleSeverityLevel } from './rule-severity.js';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
+
function isInformationalRule(rule) {
|
|
4
|
+
return rule.meta.type.includes('informational');
|
|
5
|
+
}
|
|
6
|
+
class RuleBuilder {
|
|
7
|
+
#rule;
|
|
8
|
+
constructor(name) {
|
|
9
|
+
this.#rule = {
|
|
10
|
+
meta: {
|
|
11
|
+
severity: 'off',
|
|
12
|
+
tags: [],
|
|
13
|
+
name: name.trim(),
|
|
14
|
+
type: ['static', 'analytics', 'test'],
|
|
15
|
+
options: {},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type(...types) {
|
|
20
|
+
this.#rule.meta.type = types;
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
appliesTo(...participants) {
|
|
24
|
+
this.#rule.meta.appliesTo = participants;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
description(description) {
|
|
28
|
+
this.#rule.meta.description = description.trim();
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
summary(summary) {
|
|
32
|
+
this.#rule.meta.summary = summary.trim();
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
url(url) {
|
|
36
|
+
this.#rule.meta.description = url.trim();
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
tags(...tags) {
|
|
40
|
+
this.#rule.meta.tags = tags;
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
explanation(explanation) {
|
|
44
|
+
this.#rule.meta.explanation = explanation.trim();
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
options(schema) {
|
|
48
|
+
this.#rule.meta.options = schema;
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
severity(severity) {
|
|
52
|
+
if (!isRuleSeverityLevel(severity)) {
|
|
53
|
+
throw new Error('Invalid rule severity.');
|
|
54
|
+
}
|
|
55
|
+
this.#rule.meta.severity = severity;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
rule(fn) {
|
|
59
|
+
if (isInformationalRule(this.#rule)) {
|
|
60
|
+
throw new Error('Cannot define rule function for this type of rule.');
|
|
61
|
+
}
|
|
62
|
+
for (const t of this.#rule.meta.type) {
|
|
63
|
+
if (t === 'static') {
|
|
64
|
+
this.#rule.lintRule = fn;
|
|
65
|
+
}
|
|
66
|
+
else if (t === 'test') {
|
|
67
|
+
this.#rule.testRule = fn;
|
|
68
|
+
}
|
|
69
|
+
else if (t === 'analytics') {
|
|
70
|
+
this.#rule.analyzeRule = fn;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
overrideAnalyticsRule(fn) {
|
|
76
|
+
if (isInformationalRule(this.#rule)) {
|
|
77
|
+
throw new Error('Cannot define rule function for this type of rule.');
|
|
78
|
+
}
|
|
79
|
+
this.#rule.analyzeRule = fn;
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
overrideStaticRule(fn) {
|
|
83
|
+
if (isInformationalRule(this.#rule)) {
|
|
84
|
+
throw new Error('Cannot define rule function for this type of rule.');
|
|
85
|
+
}
|
|
86
|
+
this.#rule.lintRule = fn;
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
overrideTest(fn) {
|
|
90
|
+
if (isInformationalRule(this.#rule)) {
|
|
91
|
+
throw new Error('Cannot define rule function for this type of rule.');
|
|
92
|
+
}
|
|
93
|
+
this.#rule.testRule = fn;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
done() {
|
|
97
|
+
if (this.#rule.meta.description && !this.#rule.meta.summary) {
|
|
98
|
+
this.#rule.meta.summary = this.#rule.meta.description;
|
|
99
|
+
}
|
|
100
|
+
if (!this.#rule.meta.description && this.#rule.meta.summary) {
|
|
101
|
+
this.#rule.meta.description = this.#rule.meta.summary;
|
|
102
|
+
}
|
|
103
|
+
return this.#rule;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export function httpRule(name) {
|
|
107
|
+
if (name.includes(' ')) {
|
|
108
|
+
throw new Error('Rule name cannot contain spaces: ' + name);
|
|
109
|
+
}
|
|
110
|
+
return new RuleBuilder(name);
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=rule-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-builder.js","sourceRoot":"","sources":["../../src/rules/rule-builder.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,mBAAmB,EAAqB,MAAM,oBAAoB,CAAC;AAa5E,8DAA8D;AAC9D,SAAS,mBAAmB,CAC1B,IAAO;IAEP,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAClD,CAAC;AA0ED,MAAM,WAAW;IASN,KAAK,CAAg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W,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RuleType } from './rule-meta.js';
|
|
2
|
+
import type { RuleSeverity } from './rule-severity.js';
|
|
3
|
+
export type SingleRuleConfiguration<Options extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> = {
|
|
4
|
+
severity?: RuleSeverity;
|
|
5
|
+
type?: RuleType[];
|
|
6
|
+
skipOrigins?: string[];
|
|
7
|
+
options?: Options;
|
|
8
|
+
};
|
|
9
|
+
export type RulesConfiguration = Record<string, RuleSeverity | SingleRuleConfiguration>;
|
|
10
|
+
//# sourceMappingURL=rule-configuration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-configuration.d.ts","sourceRoot":"","sources":["../../src/rules/rule-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,IACzE;IACF,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CACrC,MAAM,EACN,YAAY,GAAG,uBAAuB,CACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-configuration.js","sourceRoot":"","sources":["../../src/rules/rule-configuration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from './rule.js';
|
|
2
|
+
import type { RuleType } from './rule-meta.js';
|
|
3
|
+
import { type RuleSeverity } from './rule-severity.js';
|
|
4
|
+
export type RuleFilter = (rule: Rule) => boolean;
|
|
5
|
+
export declare function createRuleFilter({ severity, type, }: {
|
|
6
|
+
severity: RuleSeverity;
|
|
7
|
+
type: RuleType[];
|
|
8
|
+
}): RuleFilter;
|
|
9
|
+
//# sourceMappingURL=rule-filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-filter.d.ts","sourceRoot":"","sources":["../../src/rules/rule-filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,oBAAoB,CAAC;AAE5E,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC;AAEjD,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,GACL,EAAE;IACD,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,QAAQ,EAAE,CAAC;CAClB,GAAG,UAAU,CAgBb"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { severityLevelValues } from './rule-severity.js';
|
|
2
|
+
export function createRuleFilter({ severity, type, }) {
|
|
3
|
+
// we need this so we don't load any rules if the linter severity is set to 'off'
|
|
4
|
+
if (severity === 'off') {
|
|
5
|
+
return () => false;
|
|
6
|
+
}
|
|
7
|
+
const ruleFilters = [];
|
|
8
|
+
ruleFilters.push((rule) => severityLevelValues[rule.meta.severity] <= severityLevelValues[severity]);
|
|
9
|
+
ruleFilters.push((rule) => type.some((t) => rule.meta.type.includes(t)));
|
|
10
|
+
return (rule) => ruleFilters.every((filter) => filter(rule));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=rule-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-filter.js","sourceRoot":"","sources":["../../src/rules/rule-filter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI5E,MAAM,UAAU,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,GAIL;IACC,iFAAiF;IACjF,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC;IACrB,CAAC;IAED,MAAM,WAAW,GAAiB,EAAE,CAAC;IAErC,WAAW,CAAC,IAAI,CACd,CAAC,IAAI,EAAE,EAAE,CACP,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAC3E,CAAC;IAEF,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Logger } from '../logger/logger.js';
|
|
2
|
+
import type { ApiContext } from './contexts.js';
|
|
3
|
+
import type { RuleFnResult } from './rule-violation.js';
|
|
4
|
+
export type RuleFn<Context extends ApiContext, Options extends Record<PropertyKey, unknown>> = (context: Context, options: Options & {
|
|
5
|
+
mode: 'static' | 'analytics' | 'test';
|
|
6
|
+
}, logger: Logger) => RuleFnResult | Promise<RuleFnResult>;
|
|
7
|
+
//# sourceMappingURL=rule-fn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-fn.d.ts","sourceRoot":"","sources":["../../src/rules/rule-fn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,MAAM,CAChB,OAAO,SAAS,UAAU,EAC1B,OAAO,SAAS,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,IAC1C,CACF,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAA;CAAE,EAC5D,MAAM,EAAE,MAAM,KACX,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-fn.js","sourceRoot":"","sources":["../../src/rules/rule-fn.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rule } from './rule.js';
|
|
2
|
+
import type { RulesConfiguration } from './rule-configuration.js';
|
|
3
|
+
import type { RuleFilter } from './rule-filter.js';
|
|
4
|
+
import type { RuleSet } from './rule-set.js';
|
|
5
|
+
export declare function isRule(rule: unknown): rule is Rule;
|
|
6
|
+
export declare function isRuleSet(ruleSet: unknown): ruleSet is RuleSet;
|
|
7
|
+
export declare function loadRules(input: string | string[], ruleFilter?: RuleFilter, options?: RulesConfiguration, cwd?: string): Promise<Rule[]>;
|
|
8
|
+
//# sourceMappingURL=rule-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-loader.d.ts","sourceRoot":"","sources":["../../src/rules/rule-loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA6B7C,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,IAAI,CAMlD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,OAAO,CAU9D;AAuCD,wBAAsB,SAAS,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,EACxB,UAAU,GAAE,UAAuB,EACnC,OAAO,GAAE,kBAAuB,EAChC,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,IAAI,EAAE,CAAC,CA8FjB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { glob } from 'tinyglobby';
|
|
6
|
+
import { ThymianBaseError } from '../thymian.error.js';
|
|
7
|
+
import { isRecord } from '../utils.js';
|
|
8
|
+
import { validate } from './ajv-validate.js';
|
|
9
|
+
import { isRuleSeverityLevel } from './rule-severity.js';
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const ruleFunctionProperties = ['lintRule', 'testRule', 'analyzeRule'];
|
|
12
|
+
function areFunctionPropertiesIfDefined(obj) {
|
|
13
|
+
return ruleFunctionProperties.every((property) => {
|
|
14
|
+
if (!Object.hasOwn(obj, property)) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
const value = obj[property];
|
|
18
|
+
return value === undefined || typeof value === 'function';
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function isRule(rule) {
|
|
22
|
+
if (!(isRecord(rule) && 'meta' in rule)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return areFunctionPropertiesIfDefined(rule);
|
|
26
|
+
}
|
|
27
|
+
export function isRuleSet(ruleSet) {
|
|
28
|
+
if (!(isRecord(ruleSet) && typeof ruleSet.name === 'string')) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return !('rules' in ruleSet &&
|
|
32
|
+
Array.isArray(ruleSet.rules) &&
|
|
33
|
+
!ruleSet.rules.every(isRule));
|
|
34
|
+
}
|
|
35
|
+
async function loadRuleSet(ruleSet, basePath, ruleFilter, options, cwd) {
|
|
36
|
+
if (ruleSet.rules) {
|
|
37
|
+
return ruleSet.rules.filter(ruleFilter);
|
|
38
|
+
}
|
|
39
|
+
const rules = [];
|
|
40
|
+
if (ruleSet.pattern) {
|
|
41
|
+
const dirname = path.dirname(basePath);
|
|
42
|
+
for (const pattern of Array.isArray(ruleSet.pattern)
|
|
43
|
+
? ruleSet.pattern
|
|
44
|
+
: [ruleSet.pattern]) {
|
|
45
|
+
const files = await glob(pattern, { cwd: dirname });
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
rules.push(...(await loadRules(path.join(dirname, file), ruleFilter, options, cwd)));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return rules;
|
|
52
|
+
}
|
|
53
|
+
export async function loadRules(input, ruleFilter = () => true, options = {}, cwd = process.cwd()) {
|
|
54
|
+
if (!input || (Array.isArray(input) && input.length === 0)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(input)) {
|
|
58
|
+
return (await Promise.all(input.map((entry) => loadRules(entry, ruleFilter, options, cwd)))).flat();
|
|
59
|
+
}
|
|
60
|
+
let location = input;
|
|
61
|
+
const fileLocation = path.resolve(cwd, input);
|
|
62
|
+
if (existsSync(fileLocation)) {
|
|
63
|
+
location = fileLocation;
|
|
64
|
+
}
|
|
65
|
+
let resolved;
|
|
66
|
+
try {
|
|
67
|
+
resolved = require.resolve(location);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new ThymianBaseError(`Cannot resolve rule source ${input}.`, {
|
|
71
|
+
name: 'RuleLoadError',
|
|
72
|
+
ref: 'https://thymian.dev/references/errors/rule-load-error/',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const module = await import(pathToFileURL(resolved).href);
|
|
76
|
+
if (!('default' in module)) {
|
|
77
|
+
throw new ThymianBaseError(`Rule or rule set at ${location} does not use default export.`, {
|
|
78
|
+
suggestions: [
|
|
79
|
+
'Use "export default" or "module.exports =" to export your rule (set).',
|
|
80
|
+
],
|
|
81
|
+
name: 'RuleLoadError',
|
|
82
|
+
ref: 'https://thymian.dev/references/errors/rule-load-error/',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const ruleOrRuleSet = module.default;
|
|
86
|
+
if (isRule(ruleOrRuleSet)) {
|
|
87
|
+
// Create a shallow copy of the rule to avoid mutating the cached module
|
|
88
|
+
const rule = {
|
|
89
|
+
...ruleOrRuleSet,
|
|
90
|
+
meta: {
|
|
91
|
+
...ruleOrRuleSet.meta,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
const { name } = rule.meta;
|
|
95
|
+
const ruleOptions = options[name];
|
|
96
|
+
if (isRecord(ruleOptions)) {
|
|
97
|
+
rule.meta.severity = ruleOptions.severity ?? rule.meta.severity;
|
|
98
|
+
rule.meta.type = ruleOptions.type ?? rule.meta.type;
|
|
99
|
+
if (ruleOptions.options && rule.meta.options) {
|
|
100
|
+
if (!validate(rule.meta.options, ruleOptions.options)) {
|
|
101
|
+
throw new ThymianBaseError(`Options for rule "${rule.meta.name}" does not match the schema of the rule.`, {
|
|
102
|
+
suggestions: [
|
|
103
|
+
'Check the options for the rule in your Thymian config file.',
|
|
104
|
+
],
|
|
105
|
+
name: 'InvalidRuleOptionError',
|
|
106
|
+
ref: 'https://thymian.dev/references/errors/invalid-rule-option/',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else if (isRuleSeverityLevel(ruleOptions)) {
|
|
112
|
+
rule.meta.severity = ruleOptions;
|
|
113
|
+
}
|
|
114
|
+
if (ruleFilter(rule)) {
|
|
115
|
+
return [rule];
|
|
116
|
+
}
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
if (isRuleSet(ruleOrRuleSet)) {
|
|
120
|
+
return loadRuleSet(ruleOrRuleSet, resolved, ruleFilter, options, cwd);
|
|
121
|
+
}
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=rule-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-loader.js","sourceRoot":"","sources":["../../src/rules/rule-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAK7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAQ/C,MAAM,sBAAsB,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,CAAU,CAAC;AAIhF,SAAS,8BAA8B,CACrC,GAAiC;IAEjC,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC/C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,CAAC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AO,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC7C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;oBACtD,MAAM,IAAI,gBAAgB,CACxB,qBAAqB,IAAI,CAAC,IAAI,CAAC,IAAI,0CAA0C,EAC7E;wBACE,WAAW,EAAE;4BACX,6DAA6D;yBAC9D;wBACD,IAAI,EAAE,wBAAwB;wBAC9B,GAAG,EAAE,4DAA4D;qBAClE,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,mBAAmB,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;QACnC,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,SAAS,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JSONSchemaType } from '../ajv.js';
|
|
2
|
+
import type { RuleSeverity } from './rule-severity.js';
|
|
3
|
+
export declare const httpParticipantRoles: readonly ["intermediary", "proxy", "gateway", "tunnel", "origin server", "server", "client", "user-agent", "cache"];
|
|
4
|
+
export type HttpParticipantRole = (typeof httpParticipantRoles)[number];
|
|
5
|
+
export declare const ruleTypes: readonly ["static", "analytics", "test", "informational"];
|
|
6
|
+
export type RuleType = (typeof ruleTypes)[number];
|
|
7
|
+
export type RuleMeta<Options = unknown> = {
|
|
8
|
+
name: string;
|
|
9
|
+
type: RuleType[];
|
|
10
|
+
options: JSONSchemaType<Options>;
|
|
11
|
+
severity: RuleSeverity;
|
|
12
|
+
appliesTo?: HttpParticipantRole[];
|
|
13
|
+
tags?: string[];
|
|
14
|
+
explanation?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
recommendation?: string;
|
|
17
|
+
summary?: string;
|
|
18
|
+
url?: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=rule-meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-meta.d.ts","sourceRoot":"","sources":["../../src/rules/rule-meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,eAAO,MAAM,oBAAoB,qHAUvB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,eAAO,MAAM,SAAS,2DAKZ,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,MAAM,QAAQ,CAAC,OAAO,GAAG,OAAO,IAAI;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACjC,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const httpParticipantRoles = [
|
|
2
|
+
'intermediary',
|
|
3
|
+
'proxy',
|
|
4
|
+
'gateway',
|
|
5
|
+
'tunnel',
|
|
6
|
+
'origin server',
|
|
7
|
+
'server',
|
|
8
|
+
'client',
|
|
9
|
+
'user-agent',
|
|
10
|
+
'cache',
|
|
11
|
+
];
|
|
12
|
+
export const ruleTypes = [
|
|
13
|
+
'static',
|
|
14
|
+
'analytics',
|
|
15
|
+
'test',
|
|
16
|
+
'informational',
|
|
17
|
+
];
|
|
18
|
+
//# sourceMappingURL=rule-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-meta.js","sourceRoot":"","sources":["../../src/rules/rule-meta.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,cAAc;IACd,OAAO;IACP,SAAS;IACT,QAAQ;IACR,eAAe;IACf,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,OAAO;CACC,CAAC;AAIX,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ;IACR,WAAW;IACX,MAAM;IACN,eAAe;CACP,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ThymianReportLocation } from '../events/report.event.js';
|
|
2
|
+
import { ThymianFormat } from '../format/index.js';
|
|
3
|
+
import type { Logger } from '../logger/logger.js';
|
|
4
|
+
import type { Rule } from './rule.js';
|
|
5
|
+
import type { RulesConfiguration, SingleRuleConfiguration } from './rule-configuration.js';
|
|
6
|
+
import type { EvaluatedRuleViolation, RuleFnResult } from './rule-violation.js';
|
|
7
|
+
import type { RuleViolation } from './rule-violation.js';
|
|
8
|
+
export declare function findDuplicates<T>(elements: T[]): T[];
|
|
9
|
+
export declare function resolveViolationLocation(violation: RuleViolation, format: ThymianFormat, ruleName: string): {
|
|
10
|
+
heading: string;
|
|
11
|
+
location?: ThymianReportLocation;
|
|
12
|
+
};
|
|
13
|
+
export interface RuleRunnerStatistics {
|
|
14
|
+
rulesRun: number;
|
|
15
|
+
rulesWithViolations: number;
|
|
16
|
+
}
|
|
17
|
+
export interface RunRulesResult {
|
|
18
|
+
violations: EvaluatedRuleViolation[];
|
|
19
|
+
statistics: RuleRunnerStatistics;
|
|
20
|
+
}
|
|
21
|
+
export type RuleRunnerAdapter<Context> = {
|
|
22
|
+
errorName: string;
|
|
23
|
+
mode: 'static' | 'analytics' | 'test';
|
|
24
|
+
getRuleFn(rule: Rule): ((context: Context, options: Record<PropertyKey, unknown> & {
|
|
25
|
+
mode: 'static' | 'analytics' | 'test';
|
|
26
|
+
}, logger: Logger) => RuleFnResult | Promise<RuleFnResult>) | undefined;
|
|
27
|
+
createContext(rule: Rule, options: SingleRuleConfiguration | undefined): Context;
|
|
28
|
+
};
|
|
29
|
+
export declare function runRules<Context>(logger: Logger, rules: Rule[], format: ThymianFormat, rulesConfig: RulesConfiguration, adapter: RuleRunnerAdapter<Context>): Promise<RunRulesResult>;
|
|
30
|
+
//# sourceMappingURL=rule-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-runner.d.ts","sourceRoot":"","sources":["../../src/rules/rule-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAMvE,OAAO,EAAc,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAOlD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,cAAc,CAAC,CAAC,EAA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/index.js';
|
|
2
|
+
import { ThymianBaseError } from '../thymian.error.js';
|
|
3
|
+
import { thymianHttpTransactionToString, thymianRequestToString, thymianResponseToString, } from '../utils.js';
|
|
4
|
+
import { isRuleSeverityLevel } from './rule-severity.js';
|
|
5
|
+
export function findDuplicates(elements) {
|
|
6
|
+
return elements.filter((element, index) => elements.indexOf(element) !== index);
|
|
7
|
+
}
|
|
8
|
+
export function resolveViolationLocation(violation, format, ruleName) {
|
|
9
|
+
const { location } = violation;
|
|
10
|
+
if (typeof location === 'string') {
|
|
11
|
+
return { heading: location };
|
|
12
|
+
}
|
|
13
|
+
if (location.elementType === 'node') {
|
|
14
|
+
const node = format.getNode(location.elementId);
|
|
15
|
+
if (!node) {
|
|
16
|
+
throw new ThymianBaseError(`Invalid rule violation location for rule ${ruleName}.`, {
|
|
17
|
+
name: 'InvalidRuleViolationLocationError',
|
|
18
|
+
ref: 'https://thymian.dev/references/errors/invalid-rule-violation-location-error/',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
let heading = '';
|
|
22
|
+
if (isNodeType(node, 'http-request')) {
|
|
23
|
+
heading = thymianRequestToString(node);
|
|
24
|
+
}
|
|
25
|
+
else if (isNodeType(node, 'http-response')) {
|
|
26
|
+
heading = thymianResponseToString(node);
|
|
27
|
+
}
|
|
28
|
+
const reportLocation = {};
|
|
29
|
+
if (node.sourceLocation) {
|
|
30
|
+
reportLocation.file = { ...node.sourceLocation };
|
|
31
|
+
}
|
|
32
|
+
reportLocation.format = {
|
|
33
|
+
elementType: 'node',
|
|
34
|
+
elementId: location.elementId,
|
|
35
|
+
};
|
|
36
|
+
return { heading, location: reportLocation };
|
|
37
|
+
}
|
|
38
|
+
const [source, target] = format.graph.extremities(location.elementId);
|
|
39
|
+
const transaction = format.getEdge(location.elementId);
|
|
40
|
+
const req = format.getNode(source);
|
|
41
|
+
const res = format.getNode(target);
|
|
42
|
+
if (!req || !res || !transaction) {
|
|
43
|
+
throw new ThymianBaseError(`Invalid rule violation location for rule ${ruleName}.`, {
|
|
44
|
+
name: 'InvalidRuleViolationLocationError',
|
|
45
|
+
ref: 'https://thymian.dev/references/errors/invalid-rule-violation-location-error/',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const heading = thymianHttpTransactionToString(req, res);
|
|
49
|
+
const reportLocation = {};
|
|
50
|
+
if (transaction.sourceLocation) {
|
|
51
|
+
reportLocation.file = { ...transaction.sourceLocation };
|
|
52
|
+
}
|
|
53
|
+
reportLocation.format = {
|
|
54
|
+
elementType: 'edge',
|
|
55
|
+
elementId: location.elementId,
|
|
56
|
+
};
|
|
57
|
+
return { heading, location: reportLocation };
|
|
58
|
+
}
|
|
59
|
+
export async function runRules(logger, rules, format, rulesConfig, adapter) {
|
|
60
|
+
const duplicateRuleNames = findDuplicates(rules.map((r) => r.meta.name));
|
|
61
|
+
if (duplicateRuleNames.length > 0) {
|
|
62
|
+
throw new ThymianBaseError(`Duplicate rule names found: ${duplicateRuleNames.join(', ')}`, {
|
|
63
|
+
name: 'DuplicateRuleNamesError',
|
|
64
|
+
ref: 'https://thymian.dev/references/errors/duplicate-rule-names-error/',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const filteredRules = rules.filter((r) => r.meta.severity !== 'off' &&
|
|
68
|
+
!(r.meta.type.length === 1 && r.meta.type[0] === 'informational'));
|
|
69
|
+
const violations = [];
|
|
70
|
+
let rulesRun = 0;
|
|
71
|
+
let rulesWithViolations = 0;
|
|
72
|
+
for (const rule of filteredRules) {
|
|
73
|
+
const options = isRuleSeverityLevel(rulesConfig[rule.meta.name])
|
|
74
|
+
? {}
|
|
75
|
+
: rulesConfig[rule.meta.name];
|
|
76
|
+
try {
|
|
77
|
+
const ruleFn = adapter.getRuleFn(rule);
|
|
78
|
+
if (!ruleFn) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
rulesRun++;
|
|
82
|
+
const context = adapter.createContext(rule, options);
|
|
83
|
+
const result = await ruleFn(context, {
|
|
84
|
+
...((options ?? {}).options ?? {}),
|
|
85
|
+
mode: adapter.mode,
|
|
86
|
+
}, logger.child(rule.meta.name));
|
|
87
|
+
if (!result || (Array.isArray(result) && result.length === 0)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const violationArray = Array.isArray(result) ? result : [result];
|
|
91
|
+
if (rule.meta.severity === 'off') {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
rulesWithViolations++;
|
|
95
|
+
for (const violation of violationArray) {
|
|
96
|
+
violations.push({
|
|
97
|
+
ruleName: rule.meta.name,
|
|
98
|
+
severity: rule.meta.severity,
|
|
99
|
+
violation: {
|
|
100
|
+
message: rule.meta.summary ?? rule.meta.description ?? rule.meta.name,
|
|
101
|
+
...violation,
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
if (e instanceof ThymianBaseError) {
|
|
108
|
+
throw new ThymianBaseError(`Error running rule ${rule.meta.name}: ${e.message}`, {
|
|
109
|
+
name: adapter.errorName,
|
|
110
|
+
cause: e,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
throw new ThymianBaseError(`Error running rule ${rule.meta.name}: ${e}`, {
|
|
115
|
+
name: adapter.errorName,
|
|
116
|
+
cause: e,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
violations,
|
|
123
|
+
statistics: {
|
|
124
|
+
rulesRun,
|
|
125
|
+
rulesWithViolations,
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=rule-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-runner.js","sourceRoot":"","sources":["../../src/rules/rule-runner.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oB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,CAAC;YACX,IAAI,CAAC,YAAY,gBAAgB,EAAE,CAAC;gBAClC,MAAM,IAAI,gBAAgB,CACxB,sBAAsB,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,EACpD;oBACE,IAAI,EAAE,OAAO,CAAC,SAAS;oBACvB,KAAK,EAAE,CAAC;iBACT,CACF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,gBAAgB,CACxB,sBAAsB,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,EAAE,EAC5C;oBACE,IAAI,EAAE,OAAO,CAAC,SAAS;oBACvB,KAAK,EAAE,CAAC;iBACT,CACF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU;QACV,UAAU,EAAE;YACV,QAAQ;YACR,mBAAmB;SACpB;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-set.d.ts","sourceRoot":"","sources":["../../src/rules/rule-set.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-set.js","sourceRoot":"","sources":["../../src/rules/rule-set.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type RuleSeverity = (typeof severityLevels)[number];
|
|
2
|
+
export declare const severityLevelValues: {
|
|
3
|
+
readonly error: 1;
|
|
4
|
+
readonly warn: 2;
|
|
5
|
+
readonly hint: 3;
|
|
6
|
+
readonly off: 4;
|
|
7
|
+
};
|
|
8
|
+
export declare const severityLevels: readonly ["off", "error", "warn", "hint"];
|
|
9
|
+
export declare function isRuleSeverityLevel(level: unknown): level is RuleSeverity;
|
|
10
|
+
//# sourceMappingURL=rule-severity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-severity.d.ts","sourceRoot":"","sources":["../../src/rules/rule-severity.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AAEX,eAAO,MAAM,cAAc,2CAA4C,CAAC;AAExE,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAKzE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const severityLevelValues = {
|
|
2
|
+
error: 1,
|
|
3
|
+
warn: 2,
|
|
4
|
+
hint: 3,
|
|
5
|
+
off: 4,
|
|
6
|
+
};
|
|
7
|
+
export const severityLevels = ['off', 'error', 'warn', 'hint'];
|
|
8
|
+
export function isRuleSeverityLevel(level) {
|
|
9
|
+
return (typeof level === 'string' &&
|
|
10
|
+
severityLevels.includes(level));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=rule-severity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-severity.js","sourceRoot":"","sources":["../../src/rules/rule-severity.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,GAAG,EAAE,CAAC;CACE,CAAC;AAEX,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAU,CAAC;AAExE,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACxB,cAAoC,CAAC,QAAQ,CAAC,KAAK,CAAC,CACtD,CAAC;AACJ,CAAC"}
|