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

@stoplight/prism-core

Package Overview
Dependencies
Maintainers
27
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.3.3 to 3.3.4

31

dist/factory.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const E = require("fp-ts/lib/Either");
const A = require("fp-ts/lib/Array");
const lodash_1 = require("lodash");
const TE = require("fp-ts/lib/TaskEither");
const pipeable_1 = require("fp-ts/lib/pipeable");
const lodash_1 = require("lodash");
const Apply_1 = require("fp-ts/lib/Apply");
const lodash_2 = require("lodash");
const NonEmptyArray_1 = require("fp-ts/lib/NonEmptyArray");
const types_1 = require("@stoplight/types");
const sequenceValidation = Apply_1.sequenceT(E.getValidation(NonEmptyArray_1.getSemigroup()));
const function_1 = require("fp-ts/lib/function");
const eitherSequence = A.array.sequence(E.getValidation(NonEmptyArray_1.getSemigroup()));
function isProxyConfig(p) {

@@ -29,12 +31,15 @@ return !p.mock;

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

@@ -46,10 +51,10 @@ })(components.logger.child({ name: 'NEGOTIATOR' })));

request: (input, resources, c) => {
const config = lodash_1.defaults(c, defaultConfig);
const config = lodash_2.defaults(c, defaultConfig);
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' })), TE.map(createWarningOutput));
return pipeable_1.pipe(components.forward({ data: input, validations: [] }, config.upstream.href)(components.logger.child({ name: 'PROXY' })), TE.map(createWarningOutput));
}
else
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 }) => {
}, resource => pipeable_1.pipe(TE.fromEither(inputValidation(resource, input, config)), TE.chain(({ resource, validations }) => mockOrForward(resource, input, config, validations)), TE.map(({ output, resource, validations: inputValidations }) => {
const outputValidations = config.validateResponse

@@ -56,0 +61,0 @@ ? pipeable_1.pipe(E.swap(components.validateOutput({ resource, element: output })), E.getOrElse(() => []))

@@ -37,3 +37,3 @@ import { IDiagnostic } from '@stoplight/types';

validateOutput: ValidatorFn<Resource, Output>;
forward: (input: Input, baseUrl: string) => ReaderTaskEither<Logger, Error, Output>;
forward: (input: IPrismInput<Input>, baseUrl: string) => ReaderTaskEither<Logger, Error, Output>;
mock: (opts: {

@@ -40,0 +40,0 @@ resource: Resource;

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

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

"lodash": "^4.17.15",
"pino": "^5.13.2",
"pino": "^6.2.1",
"tslib": "^1.10.0"

@@ -28,3 +28,3 @@ },

},
"gitHead": "678acbdeaa92925cf80304910aa20740a144dc5d"
"gitHead": "435278e18f248c6d15495af5dec0c214ce39a6d5"
}
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