@redocly/respect-core 0.0.0-snapshot.1739898268
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/LICENSE +18 -0
- package/README.md +25 -0
- package/lib/arazzo-schema.d.ts +2385 -0
- package/lib/arazzo-schema.d.ts.map +1 -0
- package/lib/arazzo-schema.js +372 -0
- package/lib/arazzo-schema.js.map +1 -0
- package/lib/handlers/generate.d.ts +3 -0
- package/lib/handlers/generate.d.ts.map +1 -0
- package/lib/handlers/generate.js +18 -0
- package/lib/handlers/generate.js.map +1 -0
- package/lib/handlers/index.d.ts +3 -0
- package/lib/handlers/index.d.ts.map +1 -0
- package/lib/handlers/index.js +19 -0
- package/lib/handlers/index.js.map +1 -0
- package/lib/handlers/run.d.ts +2 -0
- package/lib/handlers/run.d.ts.map +1 -0
- package/lib/handlers/run.js +67 -0
- package/lib/handlers/run.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +7 -0
- package/lib/index.js.map +1 -0
- package/lib/modules/checks/checks.d.ts +9 -0
- package/lib/modules/checks/checks.d.ts.map +1 -0
- package/lib/modules/checks/checks.js +12 -0
- package/lib/modules/checks/checks.js.map +1 -0
- package/lib/modules/checks/index.d.ts +3 -0
- package/lib/modules/checks/index.d.ts.map +1 -0
- package/lib/modules/checks/index.js +19 -0
- package/lib/modules/checks/index.js.map +1 -0
- package/lib/modules/checks/severity.d.ts +9 -0
- package/lib/modules/checks/severity.d.ts.map +1 -0
- package/lib/modules/checks/severity.js +29 -0
- package/lib/modules/checks/severity.js.map +1 -0
- package/lib/modules/cli-output/calculate-tests-passed.d.ts +3 -0
- package/lib/modules/cli-output/calculate-tests-passed.d.ts.map +1 -0
- package/lib/modules/cli-output/calculate-tests-passed.js +67 -0
- package/lib/modules/cli-output/calculate-tests-passed.js.map +1 -0
- package/lib/modules/cli-output/display-checks.d.ts +3 -0
- package/lib/modules/cli-output/display-checks.d.ts.map +1 -0
- package/lib/modules/cli-output/display-checks.js +86 -0
- package/lib/modules/cli-output/display-checks.js.map +1 -0
- package/lib/modules/cli-output/display-errors.d.ts +3 -0
- package/lib/modules/cli-output/display-errors.d.ts.map +1 -0
- package/lib/modules/cli-output/display-errors.js +45 -0
- package/lib/modules/cli-output/display-errors.js.map +1 -0
- package/lib/modules/cli-output/display-files-summary-table.d.ts +11 -0
- package/lib/modules/cli-output/display-files-summary-table.d.ts.map +1 -0
- package/lib/modules/cli-output/display-files-summary-table.js +100 -0
- package/lib/modules/cli-output/display-files-summary-table.js.map +1 -0
- package/lib/modules/cli-output/display-summary.d.ts +7 -0
- package/lib/modules/cli-output/display-summary.d.ts.map +1 -0
- package/lib/modules/cli-output/display-summary.js +75 -0
- package/lib/modules/cli-output/display-summary.js.map +1 -0
- package/lib/modules/cli-output/index.d.ts +9 -0
- package/lib/modules/cli-output/index.d.ts.map +1 -0
- package/lib/modules/cli-output/index.js +25 -0
- package/lib/modules/cli-output/index.js.map +1 -0
- package/lib/modules/cli-output/json-logs.d.ts +3 -0
- package/lib/modules/cli-output/json-logs.d.ts.map +1 -0
- package/lib/modules/cli-output/json-logs.js +27 -0
- package/lib/modules/cli-output/json-logs.js.map +1 -0
- package/lib/modules/cli-output/mask-secrets.d.ts +5 -0
- package/lib/modules/cli-output/mask-secrets.d.ts.map +1 -0
- package/lib/modules/cli-output/mask-secrets.js +34 -0
- package/lib/modules/cli-output/mask-secrets.js.map +1 -0
- package/lib/modules/cli-output/verbose-logs.d.ts +3 -0
- package/lib/modules/cli-output/verbose-logs.d.ts.map +1 -0
- package/lib/modules/cli-output/verbose-logs.js +24 -0
- package/lib/modules/cli-output/verbose-logs.js.map +1 -0
- package/lib/modules/config-parser/get-value-from-context.d.ts +12 -0
- package/lib/modules/config-parser/get-value-from-context.d.ts.map +1 -0
- package/lib/modules/config-parser/get-value-from-context.js +183 -0
- package/lib/modules/config-parser/get-value-from-context.js.map +1 -0
- package/lib/modules/config-parser/handle-request-body-replacements.d.ts +3 -0
- package/lib/modules/config-parser/handle-request-body-replacements.d.ts.map +1 -0
- package/lib/modules/config-parser/handle-request-body-replacements.js +24 -0
- package/lib/modules/config-parser/handle-request-body-replacements.js.map +1 -0
- package/lib/modules/config-parser/index.d.ts +8 -0
- package/lib/modules/config-parser/index.d.ts.map +1 -0
- package/lib/modules/config-parser/index.js +24 -0
- package/lib/modules/config-parser/index.js.map +1 -0
- package/lib/modules/config-parser/map-header-params-and-cookie-to-object.d.ts +6 -0
- package/lib/modules/config-parser/map-header-params-and-cookie-to-object.d.ts.map +1 -0
- package/lib/modules/config-parser/map-header-params-and-cookie-to-object.js +22 -0
- package/lib/modules/config-parser/map-header-params-and-cookie-to-object.js.map +1 -0
- package/lib/modules/config-parser/parse-parameters.d.ts +10 -0
- package/lib/modules/config-parser/parse-parameters.d.ts.map +1 -0
- package/lib/modules/config-parser/parse-parameters.js +48 -0
- package/lib/modules/config-parser/parse-parameters.js.map +1 -0
- package/lib/modules/config-parser/parse-request-body.d.ts +8 -0
- package/lib/modules/config-parser/parse-request-body.d.ts.map +1 -0
- package/lib/modules/config-parser/parse-request-body.js +149 -0
- package/lib/modules/config-parser/parse-request-body.js.map +1 -0
- package/lib/modules/config-parser/resolve-reusable-component.d.ts +3 -0
- package/lib/modules/config-parser/resolve-reusable-component.d.ts.map +1 -0
- package/lib/modules/config-parser/resolve-reusable-component.js +8 -0
- package/lib/modules/config-parser/resolve-reusable-component.js.map +1 -0
- package/lib/modules/config-parser/resolve-reusable-object-reference.d.ts +5 -0
- package/lib/modules/config-parser/resolve-reusable-object-reference.d.ts.map +1 -0
- package/lib/modules/config-parser/resolve-reusable-object-reference.js +20 -0
- package/lib/modules/config-parser/resolve-reusable-object-reference.js.map +1 -0
- package/lib/modules/description-parser/bundle-openapi.d.ts +2 -0
- package/lib/modules/description-parser/bundle-openapi.d.ts.map +1 -0
- package/lib/modules/description-parser/bundle-openapi.js +41 -0
- package/lib/modules/description-parser/bundle-openapi.js.map +1 -0
- package/lib/modules/description-parser/extract-first-example.d.ts +2 -0
- package/lib/modules/description-parser/extract-first-example.d.ts.map +1 -0
- package/lib/modules/description-parser/extract-first-example.js +10 -0
- package/lib/modules/description-parser/extract-first-example.js.map +1 -0
- package/lib/modules/description-parser/get-operation-by-id.d.ts +3 -0
- package/lib/modules/description-parser/get-operation-by-id.d.ts.map +1 -0
- package/lib/modules/description-parser/get-operation-by-id.js +56 -0
- package/lib/modules/description-parser/get-operation-by-id.js.map +1 -0
- package/lib/modules/description-parser/get-operation-by-path.d.ts +7 -0
- package/lib/modules/description-parser/get-operation-by-path.d.ts.map +1 -0
- package/lib/modules/description-parser/get-operation-by-path.js +44 -0
- package/lib/modules/description-parser/get-operation-by-path.js.map +1 -0
- package/lib/modules/description-parser/get-operation-from-description.d.ts +18 -0
- package/lib/modules/description-parser/get-operation-from-description.d.ts.map +1 -0
- package/lib/modules/description-parser/get-operation-from-description.js +26 -0
- package/lib/modules/description-parser/get-operation-from-description.js.map +1 -0
- package/lib/modules/description-parser/get-request-body-schema.d.ts +3 -0
- package/lib/modules/description-parser/get-request-body-schema.d.ts.map +1 -0
- package/lib/modules/description-parser/get-request-body-schema.js +12 -0
- package/lib/modules/description-parser/get-request-body-schema.js.map +1 -0
- package/lib/modules/description-parser/get-request-data-from-openapi.d.ts +9 -0
- package/lib/modules/description-parser/get-request-data-from-openapi.d.ts.map +1 -0
- package/lib/modules/description-parser/get-request-data-from-openapi.js +63 -0
- package/lib/modules/description-parser/get-request-data-from-openapi.js.map +1 -0
- package/lib/modules/description-parser/get-response-schema.d.ts +6 -0
- package/lib/modules/description-parser/get-response-schema.d.ts.map +1 -0
- package/lib/modules/description-parser/get-response-schema.js +10 -0
- package/lib/modules/description-parser/get-response-schema.js.map +1 -0
- package/lib/modules/description-parser/index.d.ts +10 -0
- package/lib/modules/description-parser/index.d.ts.map +1 -0
- package/lib/modules/description-parser/index.js +26 -0
- package/lib/modules/description-parser/index.js.map +1 -0
- package/lib/modules/description-parser/remove-write-only-properties.d.ts +3 -0
- package/lib/modules/description-parser/remove-write-only-properties.d.ts.map +1 -0
- package/lib/modules/description-parser/remove-write-only-properties.js +41 -0
- package/lib/modules/description-parser/remove-write-only-properties.js.map +1 -0
- package/lib/modules/faker.d.ts +42 -0
- package/lib/modules/faker.d.ts.map +1 -0
- package/lib/modules/faker.js +36 -0
- package/lib/modules/faker.js.map +1 -0
- package/lib/modules/flow-runner/call-api-and-analyze-results.d.ts +30 -0
- package/lib/modules/flow-runner/call-api-and-analyze-results.d.ts.map +1 -0
- package/lib/modules/flow-runner/call-api-and-analyze-results.js +100 -0
- package/lib/modules/flow-runner/call-api-and-analyze-results.js.map +1 -0
- package/lib/modules/flow-runner/context/create-runtime-expression-ctx.d.ts +7 -0
- package/lib/modules/flow-runner/context/create-runtime-expression-ctx.d.ts.map +1 -0
- package/lib/modules/flow-runner/context/create-runtime-expression-ctx.js +56 -0
- package/lib/modules/flow-runner/context/create-runtime-expression-ctx.js.map +1 -0
- package/lib/modules/flow-runner/context/create-test-context.d.ts +5 -0
- package/lib/modules/flow-runner/context/create-test-context.d.ts.map +1 -0
- package/lib/modules/flow-runner/context/create-test-context.js +88 -0
- package/lib/modules/flow-runner/context/create-test-context.js.map +1 -0
- package/lib/modules/flow-runner/context/index.d.ts +5 -0
- package/lib/modules/flow-runner/context/index.d.ts.map +1 -0
- package/lib/modules/flow-runner/context/index.js +21 -0
- package/lib/modules/flow-runner/context/index.js.map +1 -0
- package/lib/modules/flow-runner/context/set-public-steps.d.ts +3 -0
- package/lib/modules/flow-runner/context/set-public-steps.d.ts.map +1 -0
- package/lib/modules/flow-runner/context/set-public-steps.js +11 -0
- package/lib/modules/flow-runner/context/set-public-steps.js.map +1 -0
- package/lib/modules/flow-runner/context/set-public-workflows.d.ts +7 -0
- package/lib/modules/flow-runner/context/set-public-workflows.d.ts.map +1 -0
- package/lib/modules/flow-runner/context/set-public-workflows.js +29 -0
- package/lib/modules/flow-runner/context/set-public-workflows.js.map +1 -0
- package/lib/modules/flow-runner/error-message-matcher.d.ts +4 -0
- package/lib/modules/flow-runner/error-message-matcher.d.ts.map +1 -0
- package/lib/modules/flow-runner/error-message-matcher.js +11 -0
- package/lib/modules/flow-runner/error-message-matcher.js.map +1 -0
- package/lib/modules/flow-runner/get-server-url.d.ts +12 -0
- package/lib/modules/flow-runner/get-server-url.d.ts.map +1 -0
- package/lib/modules/flow-runner/get-server-url.js +67 -0
- package/lib/modules/flow-runner/get-server-url.js.map +1 -0
- package/lib/modules/flow-runner/get-test-description-from-file.d.ts +20 -0
- package/lib/modules/flow-runner/get-test-description-from-file.d.ts.map +1 -0
- package/lib/modules/flow-runner/get-test-description-from-file.js +75 -0
- package/lib/modules/flow-runner/get-test-description-from-file.js.map +1 -0
- package/lib/modules/flow-runner/get-workflows-to-run.d.ts +3 -0
- package/lib/modules/flow-runner/get-workflows-to-run.d.ts.map +1 -0
- package/lib/modules/flow-runner/get-workflows-to-run.js +50 -0
- package/lib/modules/flow-runner/get-workflows-to-run.js.map +1 -0
- package/lib/modules/flow-runner/index.d.ts +16 -0
- package/lib/modules/flow-runner/index.d.ts.map +1 -0
- package/lib/modules/flow-runner/index.js +32 -0
- package/lib/modules/flow-runner/index.js.map +1 -0
- package/lib/modules/flow-runner/inputs/format-cli-inputs.d.ts +2 -0
- package/lib/modules/flow-runner/inputs/format-cli-inputs.d.ts.map +1 -0
- package/lib/modules/flow-runner/inputs/format-cli-inputs.js +45 -0
- package/lib/modules/flow-runner/inputs/format-cli-inputs.js.map +1 -0
- package/lib/modules/flow-runner/inputs/index.d.ts +3 -0
- package/lib/modules/flow-runner/inputs/index.d.ts.map +1 -0
- package/lib/modules/flow-runner/inputs/index.js +19 -0
- package/lib/modules/flow-runner/inputs/index.js.map +1 -0
- package/lib/modules/flow-runner/inputs/map-input-values-to-schema.d.ts +7 -0
- package/lib/modules/flow-runner/inputs/map-input-values-to-schema.d.ts.map +1 -0
- package/lib/modules/flow-runner/inputs/map-input-values-to-schema.js +29 -0
- package/lib/modules/flow-runner/inputs/map-input-values-to-schema.js.map +1 -0
- package/lib/modules/flow-runner/outputs/index.d.ts +2 -0
- package/lib/modules/flow-runner/outputs/index.d.ts.map +1 -0
- package/lib/modules/flow-runner/outputs/index.js +18 -0
- package/lib/modules/flow-runner/outputs/index.js.map +1 -0
- package/lib/modules/flow-runner/outputs/print-message.d.ts +7 -0
- package/lib/modules/flow-runner/outputs/print-message.d.ts.map +1 -0
- package/lib/modules/flow-runner/outputs/print-message.js +17 -0
- package/lib/modules/flow-runner/outputs/print-message.js.map +1 -0
- package/lib/modules/flow-runner/prepare-request.d.ts +15 -0
- package/lib/modules/flow-runner/prepare-request.d.ts.map +1 -0
- package/lib/modules/flow-runner/prepare-request.js +166 -0
- package/lib/modules/flow-runner/prepare-request.js.map +1 -0
- package/lib/modules/flow-runner/read-env-variables.d.ts +2 -0
- package/lib/modules/flow-runner/read-env-variables.d.ts.map +1 -0
- package/lib/modules/flow-runner/read-env-variables.js +44 -0
- package/lib/modules/flow-runner/read-env-variables.js.map +1 -0
- package/lib/modules/flow-runner/resolve-running-workflows.d.ts +2 -0
- package/lib/modules/flow-runner/resolve-running-workflows.d.ts.map +1 -0
- package/lib/modules/flow-runner/resolve-running-workflows.js +25 -0
- package/lib/modules/flow-runner/resolve-running-workflows.js.map +1 -0
- package/lib/modules/flow-runner/run-step.d.ts +12 -0
- package/lib/modules/flow-runner/run-step.d.ts.map +1 -0
- package/lib/modules/flow-runner/run-step.js +250 -0
- package/lib/modules/flow-runner/run-step.js.map +1 -0
- package/lib/modules/flow-runner/runner.d.ts +11 -0
- package/lib/modules/flow-runner/runner.d.ts.map +1 -0
- package/lib/modules/flow-runner/runner.js +225 -0
- package/lib/modules/flow-runner/runner.js.map +1 -0
- package/lib/modules/flow-runner/schema/index.d.ts +2 -0
- package/lib/modules/flow-runner/schema/index.d.ts.map +1 -0
- package/lib/modules/flow-runner/schema/index.js +18 -0
- package/lib/modules/flow-runner/schema/index.js.map +1 -0
- package/lib/modules/flow-runner/schema/schema-checker.d.ts +7 -0
- package/lib/modules/flow-runner/schema/schema-checker.d.ts.map +1 -0
- package/lib/modules/flow-runner/schema/schema-checker.js +124 -0
- package/lib/modules/flow-runner/schema/schema-checker.js.map +1 -0
- package/lib/modules/flow-runner/success-criteria/check-success-criteria.d.ts +8 -0
- package/lib/modules/flow-runner/success-criteria/check-success-criteria.d.ts.map +1 -0
- package/lib/modules/flow-runner/success-criteria/check-success-criteria.js +97 -0
- package/lib/modules/flow-runner/success-criteria/check-success-criteria.js.map +1 -0
- package/lib/modules/flow-runner/success-criteria/index.d.ts +3 -0
- package/lib/modules/flow-runner/success-criteria/index.d.ts.map +1 -0
- package/lib/modules/flow-runner/success-criteria/index.js +19 -0
- package/lib/modules/flow-runner/success-criteria/index.js.map +1 -0
- package/lib/modules/flow-runner/success-criteria/validate-success-criteria.d.ts +6 -0
- package/lib/modules/flow-runner/success-criteria/validate-success-criteria.d.ts.map +1 -0
- package/lib/modules/flow-runner/success-criteria/validate-success-criteria.js +63 -0
- package/lib/modules/flow-runner/success-criteria/validate-success-criteria.js.map +1 -0
- package/lib/modules/runtime-expressions/abnf-parser.d.ts +15 -0
- package/lib/modules/runtime-expressions/abnf-parser.d.ts.map +1 -0
- package/lib/modules/runtime-expressions/abnf-parser.js +2012 -0
- package/lib/modules/runtime-expressions/abnf-parser.js.map +1 -0
- package/lib/modules/runtime-expressions/evaluate.d.ts +9 -0
- package/lib/modules/runtime-expressions/evaluate.d.ts.map +1 -0
- package/lib/modules/runtime-expressions/evaluate.js +169 -0
- package/lib/modules/runtime-expressions/evaluate.js.map +1 -0
- package/lib/modules/runtime-expressions/index.d.ts +2 -0
- package/lib/modules/runtime-expressions/index.d.ts.map +1 -0
- package/lib/modules/runtime-expressions/index.js +18 -0
- package/lib/modules/runtime-expressions/index.js.map +1 -0
- package/lib/modules/runtime-expressions/lint.d.ts +2 -0
- package/lib/modules/runtime-expressions/lint.d.ts.map +1 -0
- package/lib/modules/runtime-expressions/lint.js +13 -0
- package/lib/modules/runtime-expressions/lint.js.map +1 -0
- package/lib/modules/runtime-expressions/replace-json-pointers.d.ts +2 -0
- package/lib/modules/runtime-expressions/replace-json-pointers.d.ts.map +1 -0
- package/lib/modules/runtime-expressions/replace-json-pointers.js +62 -0
- package/lib/modules/runtime-expressions/replace-json-pointers.js.map +1 -0
- package/lib/modules/test-config-generator/cleanup-test-description.d.ts +16 -0
- package/lib/modules/test-config-generator/cleanup-test-description.d.ts.map +1 -0
- package/lib/modules/test-config-generator/cleanup-test-description.js +28 -0
- package/lib/modules/test-config-generator/cleanup-test-description.js.map +1 -0
- package/lib/modules/test-config-generator/generate-example-value.d.ts +3 -0
- package/lib/modules/test-config-generator/generate-example-value.d.ts.map +1 -0
- package/lib/modules/test-config-generator/generate-example-value.js +17 -0
- package/lib/modules/test-config-generator/generate-example-value.js.map +1 -0
- package/lib/modules/test-config-generator/generate-test-config.d.ts +7 -0
- package/lib/modules/test-config-generator/generate-test-config.d.ts.map +1 -0
- package/lib/modules/test-config-generator/generate-test-config.js +117 -0
- package/lib/modules/test-config-generator/generate-test-config.js.map +1 -0
- package/lib/modules/test-config-generator/generate-test-data-from-json-schema.d.ts +2 -0
- package/lib/modules/test-config-generator/generate-test-data-from-json-schema.d.ts.map +1 -0
- package/lib/modules/test-config-generator/generate-test-data-from-json-schema.js +42 -0
- package/lib/modules/test-config-generator/generate-test-data-from-json-schema.js.map +1 -0
- package/lib/modules/test-config-generator/index.d.ts +5 -0
- package/lib/modules/test-config-generator/index.d.ts.map +1 -0
- package/lib/modules/test-config-generator/index.js +21 -0
- package/lib/modules/test-config-generator/index.js.map +1 -0
- package/lib/types.d.ts +241 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/ajv-errors.d.ts +3 -0
- package/lib/utils/ajv-errors.d.ts.map +1 -0
- package/lib/utils/ajv-errors.js +28 -0
- package/lib/utils/ajv-errors.js.map +1 -0
- package/lib/utils/api-fetcher.d.ts +27 -0
- package/lib/utils/api-fetcher.d.ts.map +1 -0
- package/lib/utils/api-fetcher.js +243 -0
- package/lib/utils/api-fetcher.js.map +1 -0
- package/lib/utils/check-circular-refs-in-schema.d.ts +2 -0
- package/lib/utils/check-circular-refs-in-schema.d.ts.map +1 -0
- package/lib/utils/check-circular-refs-in-schema.js +13 -0
- package/lib/utils/check-circular-refs-in-schema.js.map +1 -0
- package/lib/utils/clean-colors.d.ts +2 -0
- package/lib/utils/clean-colors.d.ts.map +1 -0
- package/lib/utils/clean-colors.js +8 -0
- package/lib/utils/clean-colors.js.map +1 -0
- package/lib/utils/cli-outputs.d.ts +18 -0
- package/lib/utils/cli-outputs.d.ts.map +1 -0
- package/lib/utils/cli-outputs.js +70 -0
- package/lib/utils/cli-outputs.js.map +1 -0
- package/lib/utils/delay.d.ts +2 -0
- package/lib/utils/delay.d.ts.map +1 -0
- package/lib/utils/delay.js +8 -0
- package/lib/utils/delay.js.map +1 -0
- package/lib/utils/env.d.ts +3 -0
- package/lib/utils/env.d.ts.map +1 -0
- package/lib/utils/env.js +13 -0
- package/lib/utils/env.js.map +1 -0
- package/lib/utils/file.d.ts +2 -0
- package/lib/utils/file.d.ts.map +1 -0
- package/lib/utils/file.js +7 -0
- package/lib/utils/file.js.map +1 -0
- package/lib/utils/get-nested-value.d.ts +2 -0
- package/lib/utils/get-nested-value.d.ts.map +1 -0
- package/lib/utils/get-nested-value.js +16 -0
- package/lib/utils/get-nested-value.js.map +1 -0
- package/lib/utils/get-reunite-url.d.ts +2 -0
- package/lib/utils/get-reunite-url.d.ts.map +1 -0
- package/lib/utils/get-reunite-url.js +18 -0
- package/lib/utils/get-reunite-url.js.map +1 -0
- package/lib/utils/har-logs/create-har-log.d.ts +2 -0
- package/lib/utils/har-logs/create-har-log.d.ts.map +1 -0
- package/lib/utils/har-logs/create-har-log.js +28 -0
- package/lib/utils/har-logs/create-har-log.js.map +1 -0
- package/lib/utils/har-logs/helpers/add-headers.d.ts +2 -0
- package/lib/utils/har-logs/helpers/add-headers.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/add-headers.js +20 -0
- package/lib/utils/har-logs/helpers/add-headers.js.map +1 -0
- package/lib/utils/har-logs/helpers/build-headers.d.ts +10 -0
- package/lib/utils/har-logs/helpers/build-headers.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/build-headers.js +35 -0
- package/lib/utils/har-logs/helpers/build-headers.js.map +1 -0
- package/lib/utils/har-logs/helpers/build-params.d.ts +2 -0
- package/lib/utils/har-logs/helpers/build-params.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/build-params.js +44 -0
- package/lib/utils/har-logs/helpers/build-params.js.map +1 -0
- package/lib/utils/har-logs/helpers/build-request-cookies.d.ts +2 -0
- package/lib/utils/har-logs/helpers/build-request-cookies.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/build-request-cookies.js +44 -0
- package/lib/utils/har-logs/helpers/build-request-cookies.js.map +1 -0
- package/lib/utils/har-logs/helpers/build-response-cookies.d.ts +2 -0
- package/lib/utils/har-logs/helpers/build-response-cookies.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/build-response-cookies.js +66 -0
- package/lib/utils/har-logs/helpers/build-response-cookies.js.map +1 -0
- package/lib/utils/har-logs/helpers/get-agent.d.ts +2 -0
- package/lib/utils/har-logs/helpers/get-agent.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/get-agent.js +115 -0
- package/lib/utils/har-logs/helpers/get-agent.js.map +1 -0
- package/lib/utils/har-logs/helpers/get-duration.d.ts +2 -0
- package/lib/utils/har-logs/helpers/get-duration.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/get-duration.js +9 -0
- package/lib/utils/har-logs/helpers/get-duration.js.map +1 -0
- package/lib/utils/har-logs/helpers/get-input-url.d.ts +2 -0
- package/lib/utils/har-logs/helpers/get-input-url.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/get-input-url.js +8 -0
- package/lib/utils/har-logs/helpers/get-input-url.js.map +1 -0
- package/lib/utils/har-logs/helpers/handle-request.d.ts +9 -0
- package/lib/utils/har-logs/helpers/handle-request.d.ts.map +1 -0
- package/lib/utils/har-logs/helpers/handle-request.js +202 -0
- package/lib/utils/har-logs/helpers/handle-request.js.map +1 -0
- package/lib/utils/har-logs/index.d.ts +3 -0
- package/lib/utils/har-logs/index.d.ts.map +1 -0
- package/lib/utils/har-logs/index.js +19 -0
- package/lib/utils/har-logs/index.js.map +1 -0
- package/lib/utils/har-logs/with-har.d.ts +6 -0
- package/lib/utils/har-logs/with-har.d.ts.map +1 -0
- package/lib/utils/har-logs/with-har.js +216 -0
- package/lib/utils/har-logs/with-har.js.map +1 -0
- package/lib/utils/is-empty.d.ts +2 -0
- package/lib/utils/is-empty.d.ts.map +1 -0
- package/lib/utils/is-empty.js +16 -0
- package/lib/utils/is-empty.js.map +1 -0
- package/lib/utils/is-json.d.ts +2 -0
- package/lib/utils/is-json.d.ts.map +1 -0
- package/lib/utils/is-json.js +13 -0
- package/lib/utils/is-json.js.map +1 -0
- package/lib/utils/is-url.d.ts +2 -0
- package/lib/utils/is-url.d.ts.map +1 -0
- package/lib/utils/is-url.js +16 -0
- package/lib/utils/is-url.js.map +1 -0
- package/lib/utils/logger/logger.d.ts +16 -0
- package/lib/utils/logger/logger.d.ts.map +1 -0
- package/lib/utils/logger/logger.js +33 -0
- package/lib/utils/logger/logger.js.map +1 -0
- package/lib/utils/mtls/create-mtls-client.d.ts +4 -0
- package/lib/utils/mtls/create-mtls-client.d.ts.map +1 -0
- package/lib/utils/mtls/create-mtls-client.js +22 -0
- package/lib/utils/mtls/create-mtls-client.js.map +1 -0
- package/lib/utils/mtls/resolve-mtls-certificates.d.ts +7 -0
- package/lib/utils/mtls/resolve-mtls-certificates.d.ts.map +1 -0
- package/lib/utils/mtls/resolve-mtls-certificates.js +69 -0
- package/lib/utils/mtls/resolve-mtls-certificates.js.map +1 -0
- package/lib/utils/sort.d.ts +2 -0
- package/lib/utils/sort.d.ts.map +1 -0
- package/lib/utils/sort.js +29 -0
- package/lib/utils/sort.js.map +1 -0
- package/lib/utils/time.d.ts +2 -0
- package/lib/utils/time.d.ts.map +1 -0
- package/lib/utils/time.js +10 -0
- package/lib/utils/time.js.map +1 -0
- package/lib/utils/url.d.ts +2 -0
- package/lib/utils/url.d.ts.map +1 -0
- package/lib/utils/url.js +9 -0
- package/lib/utils/url.js.map +1 -0
- package/lib/utils/yaml.d.ts +5 -0
- package/lib/utils/yaml.d.ts.map +1 -0
- package/lib/utils/yaml.js +23 -0
- package/lib/utils/yaml.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runTestFile = runTestFile;
|
|
4
|
+
exports.runWorkflow = runWorkflow;
|
|
5
|
+
exports.resolveWorkflowContext = resolveWorkflowContext;
|
|
6
|
+
const colorette_1 = require("colorette");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const har_logs_1 = require("../../utils/har-logs");
|
|
10
|
+
const api_fetcher_1 = require("../../utils/api-fetcher");
|
|
11
|
+
const create_test_context_1 = require("./context/create-test-context");
|
|
12
|
+
const config_parser_1 = require("../config-parser");
|
|
13
|
+
const get_workflows_to_run_1 = require("./get-workflows-to-run");
|
|
14
|
+
const run_step_1 = require("./run-step");
|
|
15
|
+
const cli_outputs_1 = require("../../utils/cli-outputs");
|
|
16
|
+
const get_test_description_from_file_1 = require("./get-test-description-from-file");
|
|
17
|
+
const checks_1 = require("../checks");
|
|
18
|
+
const context_1 = require("./context");
|
|
19
|
+
const runtime_expressions_1 = require("../runtime-expressions");
|
|
20
|
+
const cli_output_1 = require("../cli-output");
|
|
21
|
+
const resolve_running_workflows_1 = require("./resolve-running-workflows");
|
|
22
|
+
const logger_1 = require("../../utils/logger/logger");
|
|
23
|
+
const logger = logger_1.DefaultLogger.getInstance();
|
|
24
|
+
async function runTestFile(argv, output) {
|
|
25
|
+
const { file: filePath, workflow, verbose, input, skip, server, harOutput, jsonOutput, severity, } = argv;
|
|
26
|
+
const options = {
|
|
27
|
+
workflowPath: filePath, // filePath or documentPath
|
|
28
|
+
workflow,
|
|
29
|
+
skip,
|
|
30
|
+
verbose,
|
|
31
|
+
harOutput,
|
|
32
|
+
jsonOutput,
|
|
33
|
+
metadata: { ...argv },
|
|
34
|
+
input,
|
|
35
|
+
server,
|
|
36
|
+
severity,
|
|
37
|
+
mutualTls: {
|
|
38
|
+
clientCert: argv?.clientCert,
|
|
39
|
+
clientKey: argv?.clientKey,
|
|
40
|
+
caCert: argv?.caCert,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
const bundledTestDescription = await (0, get_test_description_from_file_1.bundleArazzo)(filePath);
|
|
44
|
+
const descriptionCopy = JSON.parse(JSON.stringify(bundledTestDescription));
|
|
45
|
+
const { harLogs, jsonLogs, workflows, secretFields } = await runWorkflows(bundledTestDescription, options);
|
|
46
|
+
if (output?.harFile && Object.keys(harLogs).length) {
|
|
47
|
+
const parsedHarLogs = (0, cli_output_1.maskSecrets)(harLogs, secretFields || new Set());
|
|
48
|
+
(0, node_fs_1.writeFileSync)(output.harFile, JSON.stringify(parsedHarLogs, null, 2), 'utf-8');
|
|
49
|
+
logger.log((0, colorette_1.blue)(`Har logs saved in ${(0, colorette_1.green)(output.harFile)}`));
|
|
50
|
+
logger.printNewLine();
|
|
51
|
+
logger.printNewLine();
|
|
52
|
+
}
|
|
53
|
+
if (output?.jsonFile && jsonLogs) {
|
|
54
|
+
(0, node_fs_1.writeFileSync)(output.jsonFile, JSON.stringify(jsonLogs, null, 2), 'utf-8');
|
|
55
|
+
logger.log((0, colorette_1.blue)((0, cli_outputs_1.indent)(`JSON logs saved in ${(0, colorette_1.green)(output.jsonFile)}`, 2)));
|
|
56
|
+
logger.printNewLine();
|
|
57
|
+
logger.printNewLine();
|
|
58
|
+
}
|
|
59
|
+
return { workflows, parsedYaml: descriptionCopy };
|
|
60
|
+
}
|
|
61
|
+
async function runWorkflows(testDescription, options) {
|
|
62
|
+
const harLogs = options.metadata?.harOutput && (0, har_logs_1.createHarLog)();
|
|
63
|
+
const apiClient = new api_fetcher_1.ApiFetcher({
|
|
64
|
+
harLogs,
|
|
65
|
+
});
|
|
66
|
+
const ctx = await (0, create_test_context_1.createTestContext)(testDescription, options, apiClient);
|
|
67
|
+
const workflowsToRun = (0, resolve_running_workflows_1.resolveRunningWorkflows)(options.workflow);
|
|
68
|
+
const workflowsToSkip = (0, resolve_running_workflows_1.resolveRunningWorkflows)(options.skip);
|
|
69
|
+
const workflows = (0, get_workflows_to_run_1.getWorkflowsToRun)(ctx.workflows, workflowsToRun, workflowsToSkip);
|
|
70
|
+
for (const workflow of workflows) {
|
|
71
|
+
// run dependencies workflows first
|
|
72
|
+
if (workflow.dependsOn?.length) {
|
|
73
|
+
await handleDependsOn({ workflow, ctx });
|
|
74
|
+
}
|
|
75
|
+
await runWorkflow({
|
|
76
|
+
workflowInput: workflow.workflowId,
|
|
77
|
+
ctx,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// json logs should be composed after all workflows are run
|
|
81
|
+
const jsonLogs = options.jsonLogsFile ? (0, cli_output_1.composeJsonLogs)(ctx) : undefined;
|
|
82
|
+
return { ...ctx, harLogs, jsonLogs };
|
|
83
|
+
}
|
|
84
|
+
async function runWorkflow({ workflowInput, ctx, parentStepId, parentWorkflowId, fromStepId, }) {
|
|
85
|
+
const workflowStartTime = performance.now();
|
|
86
|
+
const fileBaseName = (0, node_path_1.basename)(ctx.options.workflowPath);
|
|
87
|
+
const workflow = typeof workflowInput === 'string'
|
|
88
|
+
? ctx.workflows.find((w) => w.workflowId === workflowInput)
|
|
89
|
+
: workflowInput;
|
|
90
|
+
if (!workflow) {
|
|
91
|
+
throw new Error(`\n ${(0, colorette_1.blue)('Workflow')} ${workflowInput} ${(0, colorette_1.blue)('not found')} \n`);
|
|
92
|
+
}
|
|
93
|
+
const workflowName = workflow?.workflowId || parentWorkflowId;
|
|
94
|
+
if (parentWorkflowId && parentStepId) {
|
|
95
|
+
(0, cli_outputs_1.printStepWorkflowSeparator)(parentStepId, parentWorkflowId);
|
|
96
|
+
}
|
|
97
|
+
else if (parentWorkflowId) {
|
|
98
|
+
(0, cli_outputs_1.printDependentWorkflowSeparator)(parentWorkflowId);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
(0, cli_outputs_1.printWorkflowSeparator)(fileBaseName, workflowName);
|
|
102
|
+
}
|
|
103
|
+
const fromStepIndex = fromStepId
|
|
104
|
+
? workflow.steps.findIndex((step) => step.stepId === fromStepId)
|
|
105
|
+
: 0;
|
|
106
|
+
const workflowSteps = workflow.steps.slice(fromStepIndex);
|
|
107
|
+
// clean $steps ctx before running workflow steps
|
|
108
|
+
ctx.$steps = {};
|
|
109
|
+
for (const step of workflowSteps) {
|
|
110
|
+
try {
|
|
111
|
+
const stepResults = await (0, run_step_1.runStep)({
|
|
112
|
+
step,
|
|
113
|
+
ctx,
|
|
114
|
+
workflowName,
|
|
115
|
+
parentWorkflowId,
|
|
116
|
+
parentStepId,
|
|
117
|
+
});
|
|
118
|
+
// When `end` action is used, we should not continue with the next steps
|
|
119
|
+
if (stepResults?.shouldEnd) {
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
const failedCall = {
|
|
125
|
+
name: checks_1.CHECKS.UNEXPECTED_ERROR,
|
|
126
|
+
message: err.message,
|
|
127
|
+
pass: false,
|
|
128
|
+
severity: ctx.severity['UNEXPECTED_ERROR'],
|
|
129
|
+
};
|
|
130
|
+
step.checks.push(failedCall);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// workflow level outputs
|
|
135
|
+
if (workflow.outputs && workflowName) {
|
|
136
|
+
if (!ctx.$outputs) {
|
|
137
|
+
ctx.$outputs = {};
|
|
138
|
+
}
|
|
139
|
+
if (!ctx.$outputs[workflowName]) {
|
|
140
|
+
ctx.$outputs[workflowName] = {};
|
|
141
|
+
}
|
|
142
|
+
const runtimeExpressionContext = (0, context_1.createRuntimeExpressionCtx)({
|
|
143
|
+
ctx: {
|
|
144
|
+
...ctx,
|
|
145
|
+
$inputs: {
|
|
146
|
+
...(ctx.$inputs || {}),
|
|
147
|
+
...(ctx.$workflows[workflowName]?.inputs || {}),
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
workflowId: workflowName,
|
|
151
|
+
});
|
|
152
|
+
for (const outputKey of Object.keys(workflow.outputs)) {
|
|
153
|
+
try {
|
|
154
|
+
if (workflow.outputs) {
|
|
155
|
+
workflow.outputs[outputKey] = (0, runtime_expressions_1.evaluateRuntimeExpressionPayload)({
|
|
156
|
+
payload: workflow.outputs[outputKey],
|
|
157
|
+
context: runtimeExpressionContext,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
ctx.$outputs[workflowName].outputs = workflow.outputs;
|
|
161
|
+
ctx.$workflows[workflowName].outputs = workflow.outputs;
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
throw new Error(`Failed to resolve outputs in workflow "${workflowName}": ${error.message}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
workflow.time = Math.ceil(performance.now() - workflowStartTime);
|
|
169
|
+
logger.printNewLine();
|
|
170
|
+
return workflow;
|
|
171
|
+
}
|
|
172
|
+
async function handleDependsOn({ workflow, ctx }) {
|
|
173
|
+
if (!workflow.dependsOn?.length)
|
|
174
|
+
return;
|
|
175
|
+
const dependenciesWorkflows = await Promise.all(workflow.dependsOn.map(async (workflowId) => {
|
|
176
|
+
const resolvedWorkflow = (0, config_parser_1.getValueFromContext)(workflowId, ctx);
|
|
177
|
+
const workflowCtx = await resolveWorkflowContext(workflowId, resolvedWorkflow, ctx);
|
|
178
|
+
return runWorkflow({
|
|
179
|
+
workflowInput: resolvedWorkflow,
|
|
180
|
+
parentWorkflowId: workflow.workflowId,
|
|
181
|
+
ctx: workflowCtx,
|
|
182
|
+
});
|
|
183
|
+
}));
|
|
184
|
+
if (dependenciesWorkflows.some((w) => !w)) {
|
|
185
|
+
throw new Error('Dependent workflows failed');
|
|
186
|
+
}
|
|
187
|
+
const totals = (0, cli_output_1.calculateTotals)(dependenciesWorkflows);
|
|
188
|
+
const hasProblems = totals.steps.failed > 0;
|
|
189
|
+
if (hasProblems) {
|
|
190
|
+
throw new Error('Dependent workflows has failed steps');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async function resolveWorkflowContext(workflowId, resolvedWorkflow, ctx) {
|
|
194
|
+
const sourceDescriptionId = workflowId && workflowId.startsWith('$sourceDescriptions.') && workflowId.split('.')[1];
|
|
195
|
+
const testDescription = sourceDescriptionId && ctx.$sourceDescriptions[sourceDescriptionId];
|
|
196
|
+
// executing external workflow should not mutate the original context
|
|
197
|
+
// only outputs are transferred to the parent workflow
|
|
198
|
+
// creating the new ctx for the external workflow or recreate current ctx for local workflow
|
|
199
|
+
return testDescription
|
|
200
|
+
? await (0, create_test_context_1.createTestContext)(testDescription, {
|
|
201
|
+
workflowPath: findSourceDescriptionUrl(sourceDescriptionId, ctx.sourceDescriptions, ctx.options),
|
|
202
|
+
workflow: [resolvedWorkflow.workflowId],
|
|
203
|
+
skip: undefined,
|
|
204
|
+
input: ctx.options.input || undefined,
|
|
205
|
+
server: ctx.options.server || undefined,
|
|
206
|
+
severity: ctx.options.severity || undefined,
|
|
207
|
+
}, ctx.apiClient)
|
|
208
|
+
: await (0, create_test_context_1.createTestContext)(JSON.parse(JSON.stringify(ctx.testDescription)), JSON.parse(JSON.stringify(ctx.options)), ctx.apiClient);
|
|
209
|
+
}
|
|
210
|
+
function findSourceDescriptionUrl(sourceDescriptionId, sourceDescriptions, options) {
|
|
211
|
+
const sourceDescription = sourceDescriptions && sourceDescriptions.find(({ name }) => name === sourceDescriptionId);
|
|
212
|
+
if (!sourceDescription) {
|
|
213
|
+
return '';
|
|
214
|
+
}
|
|
215
|
+
else if (sourceDescription.type === 'openapi') {
|
|
216
|
+
return sourceDescription.url;
|
|
217
|
+
}
|
|
218
|
+
else if (sourceDescription.type === 'arazzo') {
|
|
219
|
+
return (0, node_path_1.resolve)((0, node_path_1.dirname)(options.workflowPath), sourceDescription.url);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
throw new Error(`Unknown source description type ${sourceDescription.type}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/modules/flow-runner/runner.ts"],"names":[],"mappings":";;AAoCA,kCAuDC;AAiCD,kCAuGC;AA8BD,wDAkCC;AAnSD,yCAAwC;AACxC,yCAAuD;AACvD,qCAAwC;AACxC,mDAAoD;AACpD,yDAAqD;AACrD,uEAAkE;AAClE,oDAAuD;AACvD,iEAA2D;AAC3D,yCAAqC;AACrC,yDAKiC;AACjC,qFAAgE;AAChE,sCAAmC;AACnC,uCAAuD;AACvD,gEAA0E;AAC1E,8CAA8E;AAC9E,2EAAsE;AACtE,sDAA0D;AAa1D,MAAM,MAAM,GAAG,sBAAa,CAAC,WAAW,EAAE,CAAC;AAEpC,KAAK,UAAU,WAAW,CAAC,IAAa,EAAE,MAA+C;IAC9F,MAAM,EACJ,IAAI,EAAE,QAAQ,EACd,QAAQ,EACR,OAAO,EACP,KAAK,EACL,IAAI,EACJ,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,GACT,GAAG,IAAI,CAAC;IAET,MAAM,OAAO,GAAG;QACd,YAAY,EAAE,QAAQ,EAAE,2BAA2B;QACnD,QAAQ;QACR,IAAI;QACJ,OAAO;QACP,SAAS;QACT,UAAU;QACV,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE;QACrB,KAAK;QACL,MAAM;Q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AuC,CAAC,IAAI,EAAE,CACnF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./schema-checker"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Check, type StepCallContext, type TestContext } from '../../../types';
|
|
2
|
+
export declare function checkSchema({ stepCallCtx, descriptionOperation, ctx, }: {
|
|
3
|
+
stepCallCtx: StepCallContext;
|
|
4
|
+
descriptionOperation?: any;
|
|
5
|
+
ctx: TestContext;
|
|
6
|
+
}): Check[];
|
|
7
|
+
//# sourceMappingURL=schema-checker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-checker.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/schema-checker.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,KAAK,EAEV,KAAK,eAAe,EACpB,KAAK,WAAW,EACjB,MAAM,gBAAgB,CAAC;AAwBxB,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,oBAAoB,EACpB,GAAG,GACJ,EAAE;IACD,WAAW,EAAE,eAAe,CAAC;IAC7B,oBAAoB,CAAC,EAAE,GAAG,CAAC;IAC3B,GAAG,EAAE,WAAW,CAAC;CAClB,GAAG,KAAK,EAAE,CAkBV"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.checkSchema = checkSchema;
|
|
7
|
+
const _2020_1 = __importDefault(require("@redocly/ajv/dist/2020"));
|
|
8
|
+
const jest_diff_1 = require("jest-diff");
|
|
9
|
+
const colorette_1 = require("colorette");
|
|
10
|
+
const checks_1 = require("../../checks");
|
|
11
|
+
const ajv_errors_1 = require("../../../utils/ajv-errors");
|
|
12
|
+
const check_circular_refs_in_schema_1 = require("../../../utils/check-circular-refs-in-schema");
|
|
13
|
+
const description_parser_1 = require("../../description-parser");
|
|
14
|
+
const logger_1 = require("../../../utils/logger/logger");
|
|
15
|
+
const logger = logger_1.DefaultLogger.getInstance();
|
|
16
|
+
const ajvStrict = new _2020_1.default({
|
|
17
|
+
schemaId: '$id',
|
|
18
|
+
meta: true,
|
|
19
|
+
allErrors: true,
|
|
20
|
+
strictSchema: false,
|
|
21
|
+
inlineRefs: false,
|
|
22
|
+
validateSchema: false,
|
|
23
|
+
discriminator: true,
|
|
24
|
+
allowUnionTypes: true,
|
|
25
|
+
validateFormats: false,
|
|
26
|
+
logger: false,
|
|
27
|
+
verbose: true,
|
|
28
|
+
defaultUnevaluatedProperties: false,
|
|
29
|
+
});
|
|
30
|
+
function checkSchema({ stepCallCtx, descriptionOperation, ctx, }) {
|
|
31
|
+
const { $response } = stepCallCtx;
|
|
32
|
+
const checks = [];
|
|
33
|
+
// if no $response, that is a common case for executing dependsOn workflow steps of workflow inside
|
|
34
|
+
// the step - return checks
|
|
35
|
+
if (!$response || !descriptionOperation) {
|
|
36
|
+
return checks;
|
|
37
|
+
}
|
|
38
|
+
checkStatusCodeFromDescription({ checks, descriptionOperation, $response, ctx });
|
|
39
|
+
checkContentTypeFromDescription({ checks, descriptionOperation, $response, ctx });
|
|
40
|
+
checkSchemaFromDescription({ checks, descriptionOperation, $response, ctx });
|
|
41
|
+
return checks;
|
|
42
|
+
}
|
|
43
|
+
function checkSchemaFromDescription({ checks, descriptionOperation, $response, ctx, }) {
|
|
44
|
+
const { body: resultBody } = $response;
|
|
45
|
+
const descriptionResponseByCode = descriptionOperation?.responses[String($response?.statusCode)] ||
|
|
46
|
+
descriptionOperation?.responses['default'];
|
|
47
|
+
const schemaFromDescription = $response?.contentType
|
|
48
|
+
? descriptionResponseByCode?.content?.[$response.contentType]?.schema
|
|
49
|
+
: undefined;
|
|
50
|
+
const isSchemaWithCircularRef = (0, check_circular_refs_in_schema_1.checkCircularRefsInSchema)(schemaFromDescription);
|
|
51
|
+
if (isSchemaWithCircularRef) {
|
|
52
|
+
logger.log(`${(0, colorette_1.yellow)('WARNING: schema have circular references')}`);
|
|
53
|
+
logger.printNewLine();
|
|
54
|
+
}
|
|
55
|
+
if (schemaFromDescription && !isSchemaWithCircularRef) {
|
|
56
|
+
try {
|
|
57
|
+
checks.push({
|
|
58
|
+
name: checks_1.CHECKS.SCHEMA_CHECK,
|
|
59
|
+
pass: ajvStrict.validate((0, description_parser_1.removeWriteOnlyProperties)(schemaFromDescription), resultBody),
|
|
60
|
+
message: ajvStrict.errors
|
|
61
|
+
? (0, ajv_errors_1.printErrors)((0, description_parser_1.removeWriteOnlyProperties)(schemaFromDescription), resultBody, ajvStrict.errors)
|
|
62
|
+
: '',
|
|
63
|
+
severity: ctx.severity['SCHEMA_CHECK'],
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
checks.push({
|
|
68
|
+
name: checks_1.CHECKS.SCHEMA_CHECK,
|
|
69
|
+
pass: false,
|
|
70
|
+
message: `Ajv error: ${error.message}`,
|
|
71
|
+
severity: ctx.severity['SCHEMA_CHECK'],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function checkStatusCodeFromDescription({ checks, descriptionOperation, $response, ctx, }) {
|
|
77
|
+
const responseStatusCode = $response?.statusCode;
|
|
78
|
+
const responseCodesFromDescription = Object.keys(descriptionOperation?.responses || {});
|
|
79
|
+
const matchesCodeFromDescription = responseStatusCode &&
|
|
80
|
+
responseCodesFromDescription
|
|
81
|
+
.map((item) => item.toString())
|
|
82
|
+
.includes(responseStatusCode.toString());
|
|
83
|
+
const matchesDefaultResponse = responseCodesFromDescription.includes('default');
|
|
84
|
+
const message = matchesCodeFromDescription
|
|
85
|
+
? (0, colorette_1.dim)(`List of valid response codes are inferred from description \n\n`) +
|
|
86
|
+
(0, jest_diff_1.diffLinesUnified)(responseCodesFromDescription.map(String), [`${responseStatusCode}`])
|
|
87
|
+
: ''; // NOTE: we don't show any diff if response code hits default response
|
|
88
|
+
const pass = matchesCodeFromDescription || matchesDefaultResponse;
|
|
89
|
+
checks.push({
|
|
90
|
+
name: checks_1.CHECKS.STATUS_CODE_CHECK,
|
|
91
|
+
pass,
|
|
92
|
+
message,
|
|
93
|
+
...(pass && {
|
|
94
|
+
additionalMessage: `Response code ${responseStatusCode} matches one of description codes: [${responseCodesFromDescription.join(', ')}]`,
|
|
95
|
+
}),
|
|
96
|
+
severity: ctx.severity['STATUS_CODE_CHECK'],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function checkContentTypeFromDescription({ checks, descriptionOperation, $response, ctx, }) {
|
|
100
|
+
const statusCode = $response?.statusCode;
|
|
101
|
+
const responseContentType = $response?.contentType;
|
|
102
|
+
const possibleContentTypesFromDescription = Object.keys(descriptionOperation?.responses[statusCode]?.content || {});
|
|
103
|
+
if (!possibleContentTypesFromDescription.length) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (responseContentType && !possibleContentTypesFromDescription.includes(responseContentType)) {
|
|
107
|
+
checks.push({
|
|
108
|
+
name: checks_1.CHECKS.CONTENT_TYPE_CHECK,
|
|
109
|
+
pass: false,
|
|
110
|
+
message: `Content type ${(0, colorette_1.red)(responseContentType)} for ${(0, colorette_1.blue)(statusCode)} response is not described in the schema.
|
|
111
|
+
Expected content types: ${(0, colorette_1.blue)(possibleContentTypesFromDescription.join(', '))}.`,
|
|
112
|
+
severity: ctx.severity['CONTENT_TYPE_CHECK'],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
checks.push({
|
|
117
|
+
name: checks_1.CHECKS.CONTENT_TYPE_CHECK,
|
|
118
|
+
pass: true,
|
|
119
|
+
message: `Content type "${responseContentType}" is described in the schema.`,
|
|
120
|
+
severity: ctx.severity['CONTENT_TYPE_CHECK'],
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=schema-checker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-checker.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/schema/schema-checker.ts"],"names":[],"mappings":";;;;;AAgCA,kCA0BC;AA1DD,mEAAkE;AAClE,yCAA6C;AAC7C,yCAAmD;AAOnD,yCAAsC;AACtC,0DAA0E;AAC1E,gGAAyF;AACzF,iEAAqE;AACrE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AG,SAAS,EAAE,WAAW,CAAC;IACnD,MAAM,mCAAmC,GAAG,MAAM,CAAC,IAAI,CACrD,oBAAoB,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,OAAO,IAAI,EAAE,CAC3D,CAAC;IAEF,IAAI,CAAC,mCAAmC,CAAC,MAAM,EAAE,CAAC;QAChD,OAAO;IACT,CAAC;IAED,IAAI,mBAAmB,IAAI,CAAC,mCAAmC,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC9F,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,eAAM,CAAC,kBAAkB;YAC/B,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,gBAAgB,IAAA,eAAG,EAAC,mBAAmB,CAAC,QAAQ,IAAA,gBAAI,EAC3D,UAAU,CACX;iCAC0B,IAAA,gBAAI,EAAC,mCAAmC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG;YAClF,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,eAAM,CAAC,kBAAkB;YAC/B,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,iBAAiB,mBAAmB,+BAA+B;YAC5E,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,oBAAoB,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TestContext, Check, Step, CriteriaObject } from '../../../types';
|
|
2
|
+
export declare function checkCriteria({ workflowId, step, criteria, ctx, }: {
|
|
3
|
+
workflowId?: string;
|
|
4
|
+
step: Step;
|
|
5
|
+
criteria?: CriteriaObject[];
|
|
6
|
+
ctx: TestContext;
|
|
7
|
+
}): Check[];
|
|
8
|
+
//# sourceMappingURL=check-success-criteria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-success-criteria.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/check-success-criteria.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,WAAW,EACX,KAAK,EAEL,IAAI,EACJ,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,IAAI,EACJ,QAAa,EACb,GAAG,GACJ,EAAE;IACD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAC5B,GAAG,EAAE,WAAW,CAAC;CAClB,GAAG,KAAK,EAAE,CA8EV"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkCriteria = checkCriteria;
|
|
4
|
+
const jsonpath_plus_1 = require("jsonpath-plus");
|
|
5
|
+
const validate_success_criteria_1 = require("./validate-success-criteria");
|
|
6
|
+
const checks_1 = require("../../checks");
|
|
7
|
+
const runtime_expressions_1 = require("../../runtime-expressions");
|
|
8
|
+
const context_1 = require("../context");
|
|
9
|
+
function checkCriteria({ workflowId, step, criteria = [], ctx, }) {
|
|
10
|
+
(0, validate_success_criteria_1.validateSuccessCriteria)(criteria);
|
|
11
|
+
const checks = [];
|
|
12
|
+
if (!workflowId) {
|
|
13
|
+
checks.push({
|
|
14
|
+
name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
|
|
15
|
+
pass: false,
|
|
16
|
+
message: `Undefined workflowId for step ${step.stepId}`,
|
|
17
|
+
severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
|
|
18
|
+
});
|
|
19
|
+
return checks;
|
|
20
|
+
}
|
|
21
|
+
const criteriaContext = (0, context_1.createRuntimeExpressionCtx)({
|
|
22
|
+
ctx,
|
|
23
|
+
workflowId,
|
|
24
|
+
step,
|
|
25
|
+
});
|
|
26
|
+
criteria.forEach((criteria) => {
|
|
27
|
+
const { condition } = criteria;
|
|
28
|
+
try {
|
|
29
|
+
if ((0, validate_success_criteria_1.isRegexpSuccessCriteria)(criteria)) {
|
|
30
|
+
const regexParts = condition.match(/^\/(.*)\/([gimsuy]*)$/);
|
|
31
|
+
let regexPattern;
|
|
32
|
+
let flags;
|
|
33
|
+
if (regexParts) {
|
|
34
|
+
regexPattern = regexParts[1]; // Extract pattern between the first and last slash
|
|
35
|
+
flags = regexParts[2]; // Extract flags after the last slash
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
regexPattern = condition; // If no slashes are present, treat the whole string as the pattern
|
|
39
|
+
flags = ''; // No flags in this case
|
|
40
|
+
}
|
|
41
|
+
const { context } = criteria;
|
|
42
|
+
const regex = new RegExp(regexPattern, flags);
|
|
43
|
+
checks.push({
|
|
44
|
+
name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
|
|
45
|
+
pass: regex.test((0, runtime_expressions_1.evaluateRuntimeExpression)(context, criteriaContext)),
|
|
46
|
+
message: `Checking regex criteria: ${JSON.stringify(criteria)}`,
|
|
47
|
+
severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if ((0, validate_success_criteria_1.isJSONPathSuccessCriteria)(criteria)) {
|
|
51
|
+
const { context, condition } = criteria;
|
|
52
|
+
const data = (0, runtime_expressions_1.evaluateRuntimeExpression)(context, criteriaContext);
|
|
53
|
+
checks.push({
|
|
54
|
+
name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
|
|
55
|
+
pass: evaluateJSONPAthCondition(condition, data),
|
|
56
|
+
message: `Checking jsonpath criteria: ${condition}`,
|
|
57
|
+
severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
checks.push({
|
|
62
|
+
name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
|
|
63
|
+
pass: (0, runtime_expressions_1.evaluateRuntimeExpression)(condition, criteriaContext),
|
|
64
|
+
message: `Checking simple criteria: ${JSON.stringify(criteria)}`,
|
|
65
|
+
severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
checks.push({
|
|
71
|
+
name: checks_1.CHECKS.SUCCESS_CRITERIA_CHECK,
|
|
72
|
+
pass: false,
|
|
73
|
+
message: `Failed to pass ${JSON.stringify(criteria)}: ${e.message}`,
|
|
74
|
+
severity: ctx.severity['SUCCESS_CRITERIA_CHECK'],
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return checks;
|
|
79
|
+
}
|
|
80
|
+
function evaluateJSONPAthCondition(condition, context) {
|
|
81
|
+
// Extract JSONPath expressions from the string
|
|
82
|
+
const jsonpathMatches = condition.match(/\$\.[a-zA-Z0-9_]+/g) || [];
|
|
83
|
+
// Replace JSONPath expressions with their values
|
|
84
|
+
const replacedCondition = jsonpathMatches.reduce((acc, match) => {
|
|
85
|
+
const jsonpathResult = (0, jsonpath_plus_1.JSONPath)({ path: match, json: context });
|
|
86
|
+
const jsonpathResultValue = jsonpathResult[0] || null;
|
|
87
|
+
return acc.replace(match, JSON.stringify(jsonpathResultValue));
|
|
88
|
+
}, condition);
|
|
89
|
+
try {
|
|
90
|
+
const evaluateFn = new Function(`return ${replacedCondition};`);
|
|
91
|
+
return !!evaluateFn();
|
|
92
|
+
}
|
|
93
|
+
catch (_error) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=check-success-criteria.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-success-criteria.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/check-success-criteria.ts"],"names":[],"mappings":";;AAkBA,sCAwF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/success-criteria/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./validate-success-criteria"), exports);
|
|
18
|
+
__exportStar(require("./check-success-criteria"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,2DAAyC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CriteriaObject, RegexpSuccessCriteria, JsonPathSuccessCriteria } from '../../../types';
|
|
2
|
+
export declare function isRegexpSuccessCriteria(criteria: CriteriaObject): criteria is RegexpSuccessCriteria;
|
|
3
|
+
export declare function isJSONPathSuccessCriteria(criteria: CriteriaObject): criteria is JsonPathSuccessCriteria;
|
|
4
|
+
export declare const ALLOWED_EXPRESSION_KEYS: string[];
|
|
5
|
+
export declare function validateSuccessCriteria(successCriteria: CriteriaObject[]): void;
|
|
6
|
+
//# sourceMappingURL=validate-success-criteria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-success-criteria.d.ts","sourceRoot":"","sources":["../../../../src/modules/flow-runner/success-criteria/validate-success-criteria.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,QAAQ,IAAI,qBAAqB,CAEnC;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,cAAc,GACvB,QAAQ,IAAI,uBAAuB,CAMrC;AAED,eAAO,MAAM,uBAAuB,UAYnC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,cAAc,EAAE,QAyCxE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ALLOWED_EXPRESSION_KEYS = void 0;
|
|
4
|
+
exports.isRegexpSuccessCriteria = isRegexpSuccessCriteria;
|
|
5
|
+
exports.isJSONPathSuccessCriteria = isJSONPathSuccessCriteria;
|
|
6
|
+
exports.validateSuccessCriteria = validateSuccessCriteria;
|
|
7
|
+
function isRegexpSuccessCriteria(criteria) {
|
|
8
|
+
return criteria.type === 'regex';
|
|
9
|
+
}
|
|
10
|
+
function isJSONPathSuccessCriteria(criteria) {
|
|
11
|
+
const typeValue = criteria?.type;
|
|
12
|
+
return (typeValue === 'jsonpath' || (typeof typeValue === 'object' && typeValue?.type === 'jsonpath'));
|
|
13
|
+
}
|
|
14
|
+
exports.ALLOWED_EXPRESSION_KEYS = [
|
|
15
|
+
'$url',
|
|
16
|
+
'$method',
|
|
17
|
+
'$statusCode',
|
|
18
|
+
'$request',
|
|
19
|
+
'$response',
|
|
20
|
+
'$inputs',
|
|
21
|
+
'$outputs',
|
|
22
|
+
'$steps',
|
|
23
|
+
'$workflows',
|
|
24
|
+
'$sourceDescriptions',
|
|
25
|
+
'$components',
|
|
26
|
+
];
|
|
27
|
+
function validateSuccessCriteria(successCriteria) {
|
|
28
|
+
successCriteria.forEach((criteria) => {
|
|
29
|
+
const { condition } = criteria;
|
|
30
|
+
if (isRegexpSuccessCriteria(criteria)) {
|
|
31
|
+
const { context } = criteria;
|
|
32
|
+
const regex = /\$[a-zA-Z_]\w*/g;
|
|
33
|
+
const matches = context.match(regex);
|
|
34
|
+
if (!matches) {
|
|
35
|
+
throw new Error(`"${context}" does not contain any valid context.`);
|
|
36
|
+
}
|
|
37
|
+
const invalidKeys = matches.filter((key) => !exports.ALLOWED_EXPRESSION_KEYS.includes(key));
|
|
38
|
+
if (invalidKeys.length) {
|
|
39
|
+
throw new Error(`Success criteria context "${context}" is not allowed.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else if (isJSONPathSuccessCriteria(criteria)) {
|
|
43
|
+
if (!criteria.context) {
|
|
44
|
+
throw new Error(`jsonpath success criteria context is required.`);
|
|
45
|
+
}
|
|
46
|
+
if (!criteria.condition) {
|
|
47
|
+
throw new Error(`jsonpath success criteria condition is required.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const regex = /\$[a-zA-Z_]\w*/g;
|
|
52
|
+
const matches = condition.match(regex);
|
|
53
|
+
if (!matches) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const invalidKeys = matches.filter((key) => !exports.ALLOWED_EXPRESSION_KEYS.includes(key));
|
|
57
|
+
if (invalidKeys.length) {
|
|
58
|
+
throw new Error(`Success criteria condition ${condition} is not allowed.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=validate-success-criteria.js.map
|