Socket
Socket
Sign inDemoInstall

@prismatic-io/spectral

Package Overview
Dependencies
Maintainers
3
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismatic-io/spectral - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

44

dist/clients/soap/types.d.ts
import { Connection } from "../../index";
import { Client, IMTOMAttachments } from "soap";
import { IMTOMAttachments } from "soap";
/**
* SOAPConnection takes standard connection fields, and adds an optional `wsdlDefinitionUrl` field.
*/
export interface SOAPConnection extends Connection {

@@ -9,23 +12,19 @@ fields: {

}
/**
* This function determines if the object presented is a SOAP connection with a `wsdlDefinitionUrl` field.
* @param connection The connection to test
* @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
*/
export declare const isSOAPConnection: (connection: unknown) => connection is SOAPConnection;
export interface GetClient {
(connection: SOAPConnection): Promise<Client>;
(wsdlDefinition: string): Promise<Client>;
}
/**
* SOAP requests return a 4-tuple or 5-tuple with the response first, the XML response second, headers third, and the XML request fourth, and optional message attachments fifth.
*/
export declare type SOAPResponse = [any, any, any, any, IMTOMAttachments?];
/**
* Overload the `soapRequest` function to take a variety of types of arguments.
*/
export interface SOAPRequest {
(params: RequestParams): Promise<[any, any, any, any, IMTOMAttachments?]>;
(params: RequestParams, methodParams: Record<string, unknown>): Promise<[
any,
any,
any,
any,
IMTOMAttachments?
]>;
(params: RequestParams, methodParams: undefined): Promise<[
any,
any,
any,
any,
IMTOMAttachments?
]>;
(params: RequestParams): Promise<SOAPResponse>;
(params: RequestParams, methodParams: Record<string, unknown>): Promise<SOAPResponse>;
(params: RequestParams, methodParams: undefined): Promise<SOAPResponse>;
}

@@ -60,2 +59,7 @@ export interface RequestParams {

}
/**
* This function determines if the object presented is a Basic Auth connection with `username`, `password`, and `loginMethod` fields.
* @param connection The connection to test
* @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
*/
export declare const isBasicAuthConnection: (connection: Connection) => connection is BasicAuthConnection;

@@ -62,0 +66,0 @@ export interface SOAPAuth {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBasicAuthConnection = exports.isSOAPConnection = void 0;
/**
* This function determines if the object presented is a SOAP connection with a `wsdlDefinitionUrl` field.
* @param connection The connection to test
* @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
*/
const isSOAPConnection = (connection) => {

@@ -11,2 +16,7 @@ var _a;

exports.isSOAPConnection = isSOAPConnection;
/**
* This function determines if the object presented is a Basic Auth connection with `username`, `password`, and `loginMethod` fields.
* @param connection The connection to test
* @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
*/
const isBasicAuthConnection = (connection) => {

@@ -13,0 +23,0 @@ const { fields } = connection;

@@ -1,13 +0,12 @@

import { ClientOverrides, GenerateHeader, GetClient, SOAPAuth, SOAPRequest, DescribeWSDL } from "./types";
import { ClientOverrides, GenerateHeader, SOAPAuth, SOAPConnection, SOAPRequest, DescribeWSDL } from "./types";
import { Client } from "soap";
export declare const describeWSDL: DescribeWSDL;
declare const _default: {
describeWSDL: DescribeWSDL;
generateHeader: GenerateHeader;
getSOAPClient: GetClient;
getSOAPAuth: SOAPAuth;
getSOAPClient: <T extends string | SOAPConnection = string | SOAPConnection>(wsdlParam: T) => Promise<Client>;
getWSDL: (wsdlDefinitionURL: string) => Promise<string>;
overrideClientDefaults: (client: Client, overrides: ClientOverrides) => void;
soapRequest: SOAPRequest;
describeWSDL: DescribeWSDL;
};
export default _default;

@@ -15,6 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.describeWSDL = void 0;
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */

@@ -27,2 +24,9 @@ const types_1 = require("./types");

const uuid_1 = require("uuid");
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
/**
* Optionally log out SOAP requests and responses for debugging purposes
*
* @param client A SOAP client that generates requests and responses
*/
const debugRequest = (client) => {

@@ -32,10 +36,10 @@ console.debug(client.lastRequest);

};
/**
* This function takes either the URL of a WSDL or the XML defining a WSDL, and returns an object describing the methods and attributes defined in the WSDL.
*
* @param wsdlParam Either the URL where a WSDL is stored, or the XML defining a WSDL.
* @returns An object containing the methods and attributes defined in a WSDL
*/
const describeWSDL = (wsdlParam) => __awaiter(void 0, void 0, void 0, function* () {
let client;
if (types_1.isSOAPConnection(wsdlParam)) {
client = yield getSOAPClient(wsdlParam);
}
else {
client = yield getSOAPClient(index_1.util.types.toString(wsdlParam));
}
const client = yield getSOAPClient(types_1.isSOAPConnection(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
try {

@@ -49,3 +53,7 @@ const result = client.describe();

});
exports.describeWSDL = describeWSDL;
/**
* Fetch a WSDL from a URL
* @param wsdlDefinitionURL The URL where the WSDL is stored
* @returns The WSDL's raw XML
*/
const getWSDL = (wsdlDefinitionURL) => __awaiter(void 0, void 0, void 0, function* () {

@@ -59,6 +67,11 @@ const httpClient = axios_1.default.create({

});
/**
* Create a SOAP client given a WSDL or SOAPConnection
* @param wsdlParam a SOAPConnection or XML defining a WSDL
* @returns An HTTP client configured to query a SOAP-based API
*/
const getSOAPClient = (wsdlParam) => __awaiter(void 0, void 0, void 0, function* () {
if (typeof wsdlParam === "string") {
const wsdl = index_1.util.types.toString(wsdlParam);
const filePath = `/tmp/${uuid_1.v4()}.wsdl`;
const filePath = path_1.default.join(os_1.default.tmpdir(), `${uuid_1.v4()}.wsdl`);
yield promises_1.writeFile(filePath, wsdl);

@@ -82,2 +95,7 @@ const client = yield soap_1.createClientAsync(filePath);

});
/**
* Override some HTTP client defaults
* @param client The client to override
* @param overrides An endpoint URL or SOAP headers to override
*/
const overrideClientDefaults = (client, overrides) => {

@@ -94,10 +112,10 @@ const { endpointURL, soapHeaders } = overrides;

};
/**
* Make a request to a SOAP-based API
* @param param0
* @param methodParams Parameters to pass to the specified SOAP method
* @returns The results from the SOAP request, including the full XML of the request and response
*/
const soapRequest = ({ wsdlParam, method, overrides, debug }, methodParams) => __awaiter(void 0, void 0, void 0, function* () {
let client;
if (types_1.isSOAPConnection(wsdlParam)) {
client = yield getSOAPClient(wsdlParam);
}
else {
client = yield getSOAPClient(wsdlParam);
}
const client = yield getSOAPClient(types_1.isSOAPConnection(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
if (overrides) {

@@ -124,13 +142,15 @@ overrideClientDefaults(client, overrides);

}
console.warn("Please verify that the method you specified exists in the WSDL specification.");
throw error;
}
});
/**
* Create a SOAP header
* @param wsdlParam A SOAPConnection or XML definition of a WSDL
* @param headerPayload The contents of a header XML node
* @param headerOptions Attributes for a header XML node, like namespace or xmlns
* @returns
*/
const generateHeader = (wsdlParam, headerPayload, headerOptions) => __awaiter(void 0, void 0, void 0, function* () {
let client;
if (types_1.isSOAPConnection(wsdlParam)) {
client = yield getSOAPClient(wsdlParam);
}
else {
client = yield getSOAPClient(wsdlParam);
}
const client = yield getSOAPClient(types_1.isSOAPConnection(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
let options = [];

@@ -143,2 +163,8 @@ if (headerOptions) {

});
/**
* Fetch authentication information for a SOAPConnection
* @param connection The SOAPConnection
* @param wsdlDefinition The XML WSDL definition
* @returns
*/
const getSOAPAuth = (connection, wsdlDefinition) => __awaiter(void 0, void 0, void 0, function* () {

@@ -167,9 +193,9 @@ if (types_1.isBasicAuthConnection(connection) && wsdlDefinition) {

exports.default = {
describeWSDL,
generateHeader,
getSOAPAuth,
getSOAPClient,
getSOAPAuth,
getWSDL,
overrideClientDefaults,
soapRequest,
describeWSDL: exports.describeWSDL,
};
{
"name": "@prismatic-io/spectral",
"version": "5.2.0",
"version": "5.2.1",
"description": "Utility library for building Prismatic components",

@@ -5,0 +5,0 @@ "keywords": [

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