Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stoplight/prism-core

Package Overview
Dependencies
Maintainers
20
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stoplight/prism-core - npm Package Compare versions

Comparing version 3.2.2 to 3.2.3

22

dist/factory.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Either = require("fp-ts/lib/Either");
const TaskEither = require("fp-ts/lib/TaskEither");
const E = require("fp-ts/lib/Either");
const TE = require("fp-ts/lib/TaskEither");
const pipeable_1 = require("fp-ts/lib/pipeable");

@@ -10,3 +10,3 @@ const lodash_1 = require("lodash");

const types_1 = require("@stoplight/types");
const sequenceValidation = Apply_1.sequenceT(Either.getValidation(NonEmptyArray_1.getSemigroup()));
const sequenceValidation = Apply_1.sequenceT(E.getValidation(NonEmptyArray_1.getSemigroup()));
function isProxyConfig(p) {

@@ -30,7 +30,7 @@ return !p.mock;

function factory(defaultConfig, components) {
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 }));
const inputValidation = (resource, input, config) => pipeable_1.pipe(sequenceValidation(config.validateRequest ? components.validateInput({ resource, element: input }) : E.right(input), config.checkSecurity ? components.validateSecurity({ resource, element: input }) : E.right(input)), E.fold(validations => validations, () => []), validations => TE.right({ resource, validations }));
const mockOrForward = (resource, input, config, validations) => {
const produceOutput = isProxyConfig(config)
? components.forward(input, config.upstream.href)(components.logger.child({ name: 'PROXY' }))
: TaskEither.fromEither(components.mock({
: TE.fromEither(components.mock({
resource,

@@ -43,3 +43,3 @@ input: {

})(components.logger.child({ name: 'NEGOTIATOR' })));
return pipeable_1.pipe(produceOutput, TaskEither.map(output => ({ output, resource, validations })));
return pipeable_1.pipe(produceOutput, TE.map(output => ({ output, resource, validations })));
};

@@ -49,11 +49,11 @@ return {

const config = lodash_1.defaults(c, defaultConfig);
return pipeable_1.pipe(TaskEither.fromEither(components.route({ resources, input })), TaskEither.fold(error => {
return pipeable_1.pipe(TE.fromEither(components.route({ resources, input })), TE.fold(error => {
if (!config.errors && isProxyConfig(config)) {
return pipeable_1.pipe(components.forward(input, config.upstream.href)(components.logger.child({ name: 'PROXY' })), TaskEither.map(createWarningOutput));
return pipeable_1.pipe(components.forward(input, config.upstream.href)(components.logger.child({ name: 'PROXY' })), TE.map(createWarningOutput));
}
else
return TaskEither.left(error);
}, resource => pipeable_1.pipe(inputValidation(resource, input, config), TaskEither.chain(({ resource, validations }) => mockOrForward(resource, input, config, validations)), TaskEither.map(({ output, resource, validations: inputValidations }) => {
return TE.left(error);
}, resource => pipeable_1.pipe(inputValidation(resource, input, config), TE.chain(({ resource, validations }) => mockOrForward(resource, input, config, validations)), TE.map(({ output, resource, validations: inputValidations }) => {
const outputValidations = config.validateResponse
? pipeable_1.pipe(Either.swap(components.validateOutput({ resource, element: output })), Either.getOrElse(() => []))
? pipeable_1.pipe(E.swap(components.validateOutput({ resource, element: output })), E.getOrElse(() => []))
: [];

@@ -60,0 +60,0 @@ return {

{
"name": "@stoplight/prism-core",
"version": "3.2.2",
"version": "3.2.3",
"main": "dist/index.js",

@@ -26,3 +26,3 @@ "types": "dist/index.d.ts",

},
"gitHead": "b4026b6e45662b7b97135b6142239e3ea9068814"
"gitHead": "ccd17d7cb305f34655df3b38b5bf94b127f73d03"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc