@stoplight/prism-core
Advanced tools
Comparing version 3.2.1 to 3.2.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Either = require("fp-ts/lib/Either"); | ||
const Option = require("fp-ts/lib/Option"); | ||
const TaskEither = require("fp-ts/lib/TaskEither"); | ||
const pipeable_1 = require("fp-ts/lib/pipeable"); | ||
const TaskEither = require("fp-ts/lib/TaskEither"); | ||
const lodash_1 = require("lodash"); | ||
@@ -15,2 +14,16 @@ const Apply_1 = require("fp-ts/lib/Apply"); | ||
} | ||
function createWarningOutput(output) { | ||
return { | ||
output, | ||
validations: { | ||
input: [ | ||
{ | ||
message: 'Selected route not found', | ||
severity: types_1.DiagnosticSeverity.Warning, | ||
}, | ||
], | ||
output: [], | ||
}, | ||
}; | ||
} | ||
function factory(defaultConfig, components) { | ||
@@ -36,15 +49,3 @@ const inputValidation = (resource, input, config) => pipeable_1.pipe(sequenceValidation(config.validateRequest ? components.validateInput({ resource, element: input }) : Either.right(input), config.checkSecurity ? components.validateSecurity({ resource, element: input }) : Either.right(input)), Either.fold(validations => validations, () => []), validations => TaskEither.right({ resource, validations })); | ||
if (!config.errors && isProxyConfig(config)) { | ||
return pipeable_1.pipe(components.forward(input, config.upstream.href)(components.logger.child({ name: 'PROXY' })), TaskEither.map(output => ({ | ||
input, | ||
output, | ||
validations: { | ||
input: [ | ||
{ | ||
message: "The selected route hasn't been found and the errors is set false. Prism has proxied the request to the upstream server but no validation will happen", | ||
severity: types_1.DiagnosticSeverity.Warning, | ||
}, | ||
], | ||
output: [], | ||
}, | ||
}))); | ||
return pipeable_1.pipe(components.forward(input, config.upstream.href)(components.logger.child({ name: 'PROXY' })), TaskEither.map(createWarningOutput)); | ||
} | ||
@@ -55,6 +56,5 @@ else | ||
const outputValidations = config.validateResponse | ||
? pipeable_1.pipe(Option.fromEither(Either.swap(components.validateOutput({ resource, element: output }))), Option.getOrElse(() => [])) | ||
? pipeable_1.pipe(Either.swap(components.validateOutput({ resource, element: output })), Either.getOrElse(() => [])) | ||
: []; | ||
return { | ||
input, | ||
output, | ||
@@ -61,0 +61,0 @@ validations: { |
@@ -21,6 +21,6 @@ import { IDiagnostic } from '@stoplight/types'; | ||
} | ||
export declare type ValidatorFn<Resource, T> = (opts: { | ||
resource: Resource; | ||
element: T; | ||
}) => Either<NonEmptyArray<IPrismDiagnostic>, T>; | ||
export declare type ValidatorFn<R, E> = (opts: { | ||
resource: R; | ||
element: E; | ||
}) => Either<NonEmptyArray<IPrismDiagnostic>, E>; | ||
export declare type IPrismProxyConfig = IPrismConfig & { | ||
@@ -27,0 +27,0 @@ mock: false; |
{ | ||
"name": "@stoplight/prism-core", | ||
"version": "3.2.1", | ||
"version": "3.2.2", | ||
"main": "dist/index.js", | ||
@@ -26,3 +26,3 @@ "types": "dist/index.d.ts", | ||
}, | ||
"gitHead": "64d17079cfcd3bdc791c9ffc7380f2e4c82f409a" | ||
"gitHead": "b4026b6e45662b7b97135b6142239e3ea9068814" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19713