@prismatic-io/spectral 7.8.4 → 7.10.0

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.
@@ -1,6 +1,6 @@
1
1
  import { Inputs } from ".";
2
2
  import { ConditionalExpression } from "./conditional-logic";
3
- import { InputFieldCollection, InputCleanFunction, Connection } from "./Inputs";
3
+ import { InputFieldCollection, InputCleanFunction, Connection, KeyValuePair } from "./Inputs";
4
4
  /**
5
5
  * Collection of input parameters.
6
6
  * Inputs can be static values, references to config variables, or
@@ -10,16 +10,3 @@ export declare type ActionInputParameters<TInputs extends Inputs> = {
10
10
  [Property in keyof TInputs]: TInputs[Property]["clean"] extends InputCleanFunction<any> ? ReturnType<TInputs[Property]["clean"]> : TInputs[Property]["type"] extends "connection" ? ExtractValue<Connection, TInputs[Property]["collection"]> : TInputs[Property]["type"] extends "conditional" ? ExtractValue<ConditionalExpression, TInputs[Property]["collection"]> : ExtractValue<TInputs[Property]["default"], TInputs[Property]["collection"]>;
11
11
  };
12
12
  export declare type ExtractValue<TType, TCollection extends InputFieldCollection | undefined> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] : TCollection extends "valuelist" ? TType[] : TType;
13
- /**
14
- * KeyValuePair input parameter type.
15
- * This allows users to input multiple keys / values as an input.
16
- * To see an example of how this can be used, see the `tagging` input
17
- * of the `putObject` action of the AWS S3 component:
18
- * https://github.com/prismatic-io/examples/blob/main/components/aws-s3/src/actions.ts
19
- */
20
- export interface KeyValuePair<V = unknown> {
21
- /** Key of the KeyValuePair */
22
- key: string;
23
- /** Value of the KeyValuePair */
24
- value: V;
25
- }
@@ -1,5 +1,18 @@
1
1
  import { ConditionalExpression } from "./conditional-logic";
2
2
  import { JsonSchema, UISchemaElement } from "@jsonforms/core";
3
+ /**
4
+ * KeyValuePair input parameter type.
5
+ * This allows users to input multiple keys / values as an input.
6
+ * To see an example of how this can be used, see the `tagging` input
7
+ * of the `putObject` action of the AWS S3 component:
8
+ * https://github.com/prismatic-io/examples/blob/main/components/aws-s3/src/actions.ts
9
+ */
10
+ export interface KeyValuePair<V = unknown> {
11
+ /** Key of the KeyValuePair */
12
+ key: string;
13
+ /** Value of the KeyValuePair */
14
+ value: V;
15
+ }
3
16
  export declare type Element = {
4
17
  key: string;
5
18
  label?: string;
@@ -66,81 +79,76 @@ interface BaseInputField {
66
79
  /** Indicate if this InputField is required. */
67
80
  required?: boolean;
68
81
  }
69
- export interface StringInputField extends BaseInputField {
70
- /** Data type the InputField will collect. */
71
- type: "string";
82
+ declare type CollectionOptions<T> = SingleValue<T> | ValueListCollection<T> | KeyValueListCollection<T>;
83
+ interface SingleValue<T> {
72
84
  /** Collection type of the InputField */
73
- collection?: InputFieldCollection;
85
+ collection?: undefined;
74
86
  /** Default value for this field. */
75
- default?: unknown;
87
+ default?: T;
88
+ }
89
+ interface ValueListCollection<T> {
90
+ /** Collection type of the InputField */
91
+ collection: "valuelist";
92
+ /** Default value for this field. */
93
+ default?: T[];
94
+ }
95
+ interface KeyValueListCollection<T> {
96
+ /** Collection type of the InputField */
97
+ collection: "keyvaluelist";
98
+ /** Default value for this field. */
99
+ default?: KeyValuePair<T>[];
100
+ }
101
+ export declare type StringInputField = BaseInputField & CollectionOptions<string> & {
102
+ /** Data type the InputField will collect. */
103
+ type: "string";
76
104
  /** Dictates possible choices for the input. */
77
105
  model?: InputFieldChoice[];
78
106
  /** Clean function */
79
- clean?: InputCleanFunction<this["default"]>;
80
- }
81
- export interface DataInputField extends BaseInputField {
107
+ clean?: InputCleanFunction<unknown>;
108
+ };
109
+ export declare type DataInputField = BaseInputField & CollectionOptions<string> & {
82
110
  /** Data type the InputField will collect. */
83
111
  type: "data";
84
- /** Collection type of the InputField */
85
- collection?: InputFieldCollection;
86
- /** Default value for this field. */
87
- default?: unknown;
88
112
  /** Dictates possible choices for the input. */
89
113
  model?: InputFieldChoice[];
90
114
  /** Clean function */
91
- clean?: InputCleanFunction<this["default"]>;
92
- }
93
- export interface TextInputField extends BaseInputField {
115
+ clean?: InputCleanFunction<unknown>;
116
+ };
117
+ export declare type TextInputField = BaseInputField & CollectionOptions<string> & {
94
118
  /** Data type the InputField will collect. */
95
119
  type: "text";
96
- /** Collection type of the InputField */
97
- collection?: InputFieldCollection;
98
- /** Default value for this field. */
99
- default?: unknown;
100
120
  /** Dictates possible choices for the input. */
101
121
  model?: InputFieldChoice[];
102
122
  /** Clean function */
103
- clean?: InputCleanFunction<this["default"]>;
104
- }
105
- export interface PasswordInputField extends BaseInputField {
123
+ clean?: InputCleanFunction<unknown>;
124
+ };
125
+ export declare type PasswordInputField = BaseInputField & CollectionOptions<string> & {
106
126
  /** Data type the InputField will collect. */
107
127
  type: "password";
108
- /** Collection type of the InputField */
109
- collection?: InputFieldCollection;
110
- /** Default value for this field. */
111
- default?: unknown;
112
128
  /** Dictates possible choices for the input. */
113
129
  model?: InputFieldChoice[];
114
130
  /** Clean function */
115
- clean?: InputCleanFunction<this["default"]>;
116
- }
117
- export interface BooleanInputField extends BaseInputField {
131
+ clean?: InputCleanFunction<unknown>;
132
+ };
133
+ export declare type BooleanInputField = BaseInputField & CollectionOptions<string> & {
118
134
  /** Data type the InputField will collect. */
119
135
  type: "boolean";
120
- /** Collection type of the InputField */
121
- collection?: InputFieldCollection;
122
- /** Default value for this field. */
123
- default?: unknown;
124
136
  /** Dictates possible choices for the input. */
125
137
  model?: InputFieldChoice[];
126
138
  /** Clean function */
127
- clean?: InputCleanFunction<this["default"]>;
128
- }
139
+ clean?: InputCleanFunction<unknown>;
140
+ };
129
141
  /** Defines attributes of a CodeInputField. */
130
- export interface CodeInputField extends BaseInputField {
142
+ export declare type CodeInputField = BaseInputField & CollectionOptions<string> & {
131
143
  /** Data type the InputField will collect. */
132
144
  type: "code";
133
- /** Collection type of the InputField */
134
- collection?: InputFieldCollection;
135
- /** Default value for this field. */
136
- default?: unknown;
137
145
  /** Code language for syntax highlighting. For no syntax highlighting, choose "plaintext" */
138
146
  language: "css" | "graphql" | "handlebars" | "hcl" | "html" | "javascript" | "json" | "liquid" | "markdown" | "mysql" | "pgsql" | "plaintext" | "sql" | "typescript" | "xml" | "yaml";
139
147
  /** Dictates possible choices for the input. */
140
148
  model?: InputFieldChoice[];
141
149
  /** Clean function */
142
- clean?: InputCleanFunction<this["default"]>;
143
- }
150
+ clean?: InputCleanFunction<unknown>;
151
+ };
144
152
  /** Defines attributes of a ConditionalInputField. */
145
153
  export interface ConditionalInputField extends BaseInputField {
146
154
  /** Data type the InputField will collect. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "7.8.4",
3
+ "version": "7.10.0",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"
@@ -38,14 +38,13 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@jsonforms/core": "3.0.0",
41
- "axios": "0.27.2",
42
- "axios-retry": "3.2.5",
41
+ "axios": "1.6.2",
42
+ "axios-retry": "3.9.1",
43
43
  "date-fns": "2.30.0",
44
44
  "form-data": "4.0.0",
45
45
  "jest-mock": "27.0.3",
46
46
  "safe-stable-stringify": "2.3.1",
47
47
  "serialize-error": "8.1.0",
48
- "soap": "1.0.0",
49
48
  "url-join": "5.0.0",
50
49
  "uuid": "8.3.2",
51
50
  "valid-url": "1.0.9"
@@ -1,2 +0,0 @@
1
- export * from "./types";
2
- export * from "./utils";
@@ -1,18 +0,0 @@
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("./types"), exports);
18
- __exportStar(require("./utils"), exports);
@@ -1,71 +0,0 @@
1
- import { Connection } from "../../index";
2
- import { IMTOMAttachments } from "soap";
3
- /**
4
- * SOAPConnection takes standard connection fields, and adds an optional `wsdlDefinitionUrl` field.
5
- */
6
- export interface SOAPConnection extends Connection {
7
- fields: {
8
- [key: string]: unknown;
9
- wsdlDefinitionUrl?: string;
10
- };
11
- }
12
- /**
13
- * This function determines if the object presented is a SOAP connection with a `wsdlDefinitionUrl` field.
14
- * @param connection The connection to test
15
- * @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
16
- */
17
- export declare const isSOAPConnection: (connection: unknown) => connection is SOAPConnection;
18
- /**
19
- * 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.
20
- */
21
- export declare type SOAPResponse = [any, any, any, any, IMTOMAttachments?];
22
- /**
23
- * Overload the `soapRequest` function to take a variety of types of arguments.
24
- */
25
- export interface SOAPRequest {
26
- (params: RequestParams): Promise<SOAPResponse>;
27
- (params: RequestParams, methodParams: Record<string, unknown>): Promise<SOAPResponse>;
28
- (params: RequestParams, methodParams: undefined): Promise<SOAPResponse>;
29
- }
30
- export interface RequestParams {
31
- wsdlParam: SOAPConnection | string;
32
- method: string;
33
- overrides?: ClientOverrides;
34
- debug?: boolean;
35
- }
36
- export interface ClientOverrides {
37
- endpointURL?: string;
38
- soapHeaders?: unknown[];
39
- }
40
- export interface HeaderPayload {
41
- [x: string]: any;
42
- }
43
- export interface GenerateHeader {
44
- (wsdlParam: SOAPConnection | string, headerPayload: HeaderPayload, headerOptions: undefined): Promise<string>;
45
- (wsdlParam: SOAPConnection | string, headerPayload: HeaderPayload, headerOptions: {
46
- namespace: string;
47
- xmlns: string;
48
- }): Promise<string>;
49
- }
50
- export interface BasicAuthConnection extends Connection {
51
- fields: {
52
- [key: string]: unknown;
53
- username: unknown;
54
- password: unknown;
55
- loginMethod: unknown;
56
- };
57
- }
58
- /**
59
- * This function determines if the object presented is a Basic Auth connection with `username`, `password`, and `loginMethod` fields.
60
- * @param connection The connection to test
61
- * @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
62
- */
63
- export declare const isBasicAuthConnection: (connection: Connection) => connection is BasicAuthConnection;
64
- export interface SOAPAuth {
65
- (connection: BasicAuthConnection, wsdlDefinition: string): Promise<any>;
66
- (connection: BasicAuthConnection & SOAPConnection): Promise<any>;
67
- }
68
- export interface DescribeWSDL {
69
- (connection: SOAPConnection): Promise<any>;
70
- (wsdlDefinition: string): Promise<any>;
71
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBasicAuthConnection = exports.isSOAPConnection = void 0;
4
- /**
5
- * This function determines if the object presented is a SOAP connection with a `wsdlDefinitionUrl` field.
6
- * @param connection The connection to test
7
- * @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
8
- */
9
- const isSOAPConnection = (connection) => {
10
- if (typeof connection === "object" && connection !== null)
11
- return "wsdlDefinitionURL" in (connection === null || connection === void 0 ? void 0 : connection.fields);
12
- return false;
13
- };
14
- exports.isSOAPConnection = isSOAPConnection;
15
- /**
16
- * This function determines if the object presented is a Basic Auth connection with `username`, `password`, and `loginMethod` fields.
17
- * @param connection The connection to test
18
- * @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
19
- */
20
- const isBasicAuthConnection = (connection) => {
21
- const { fields } = connection;
22
- return ("username" in fields && "password" in fields && "loginMethod" in fields);
23
- };
24
- exports.isBasicAuthConnection = isBasicAuthConnection;
@@ -1,12 +0,0 @@
1
- import { ClientOverrides, GenerateHeader, SOAPAuth, SOAPConnection, SOAPRequest, DescribeWSDL } from "./types";
2
- import { Client } from "soap";
3
- declare const _default: {
4
- describeWSDL: DescribeWSDL;
5
- generateHeader: GenerateHeader;
6
- getSOAPAuth: SOAPAuth;
7
- getSOAPClient: <T extends string | SOAPConnection = string | SOAPConnection>(wsdlParam: T) => Promise<Client>;
8
- getWSDL: (wsdlDefinitionURL: string) => Promise<string>;
9
- overrideClientDefaults: (client: Client, overrides: ClientOverrides) => void;
10
- soapRequest: SOAPRequest;
11
- };
12
- export default _default;
@@ -1,191 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- /* eslint-disable @typescript-eslint/no-unsafe-return */
16
- /* eslint-disable @typescript-eslint/no-unsafe-assignment */
17
- const types_1 = require("./types");
18
- const index_1 = require("../../index");
19
- const soap_1 = require("soap");
20
- const axios_1 = __importDefault(require("axios"));
21
- const promises_1 = require("fs/promises");
22
- const uuid_1 = require("uuid");
23
- const os_1 = __importDefault(require("os"));
24
- const path_1 = __importDefault(require("path"));
25
- /**
26
- * Optionally log out SOAP requests and responses for debugging purposes
27
- *
28
- * @param client A SOAP client that generates requests and responses
29
- */
30
- const debugRequest = (client) => {
31
- console.debug(client.lastRequest);
32
- console.debug(client.lastResponse);
33
- };
34
- /**
35
- * 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.
36
- *
37
- * @param wsdlParam Either the URL where a WSDL is stored, or the XML defining a WSDL.
38
- * @returns An object containing the methods and attributes defined in a WSDL
39
- */
40
- const describeWSDL = (wsdlParam) => __awaiter(void 0, void 0, void 0, function* () {
41
- const client = yield getSOAPClient((0, types_1.isSOAPConnection)(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
42
- try {
43
- const result = client.describe();
44
- return result;
45
- }
46
- catch (error) {
47
- throw new Error("Unable to parse WSDL Services due to circular references");
48
- }
49
- });
50
- /**
51
- * Fetch a WSDL from a URL
52
- * @param wsdlDefinitionURL The URL where the WSDL is stored
53
- * @returns The WSDL's raw XML
54
- */
55
- const getWSDL = (wsdlDefinitionURL) => __awaiter(void 0, void 0, void 0, function* () {
56
- const httpClient = axios_1.default.create({
57
- baseURL: wsdlDefinitionURL,
58
- headers: { "Content-Type": "text/xml" },
59
- });
60
- const { data } = yield httpClient.get("");
61
- return index_1.util.types.toString(data);
62
- });
63
- /**
64
- * Create a SOAP client given a WSDL or SOAPConnection
65
- * @param wsdlParam a SOAPConnection or XML defining a WSDL
66
- * @returns An HTTP client configured to query a SOAP-based API
67
- */
68
- const getSOAPClient = (wsdlParam) => __awaiter(void 0, void 0, void 0, function* () {
69
- if (typeof wsdlParam === "string") {
70
- const wsdl = index_1.util.types.toString(wsdlParam);
71
- const filePath = path_1.default.join(os_1.default.tmpdir(), `${(0, uuid_1.v4)()}.wsdl`);
72
- yield (0, promises_1.writeFile)(filePath, wsdl);
73
- const client = yield (0, soap_1.createClientAsync)(filePath);
74
- yield (0, promises_1.rm)(filePath);
75
- return client;
76
- }
77
- else if ((0, types_1.isSOAPConnection)(wsdlParam)) {
78
- const { fields: { wsdlDefinitionURL }, } = wsdlParam;
79
- if (!wsdlDefinitionURL ||
80
- !index_1.util.types.isUrl(index_1.util.types.toString(wsdlDefinitionURL))) {
81
- throw new Error("WSDL Definition or the Connection field 'wsdlDefinitionURL' must be supplied.");
82
- }
83
- const client = yield (0, soap_1.createClientAsync)(index_1.util.types.toString(wsdlDefinitionURL));
84
- return client;
85
- }
86
- else {
87
- throw new Error("WSDL Definition or the Connection field 'wsdlDefinitionURL' must be supplied.");
88
- }
89
- });
90
- /**
91
- * Override some HTTP client defaults
92
- * @param client The client to override
93
- * @param overrides An endpoint URL or SOAP headers to override
94
- */
95
- const overrideClientDefaults = (client, overrides) => {
96
- const { endpointURL, soapHeaders } = overrides;
97
- if (endpointURL) {
98
- client.setEndpoint(endpointURL);
99
- }
100
- if (soapHeaders) {
101
- soapHeaders.map((header) => {
102
- client.addSoapHeader(header);
103
- });
104
- }
105
- };
106
- /**
107
- * Make a request to a SOAP-based API
108
- * @param param0
109
- * @param methodParams Parameters to pass to the specified SOAP method
110
- * @returns The results from the SOAP request, including the full XML of the request and response
111
- */
112
- const soapRequest = ({ wsdlParam, method, overrides, debug }, methodParams) => __awaiter(void 0, void 0, void 0, function* () {
113
- const client = yield getSOAPClient((0, types_1.isSOAPConnection)(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
114
- if (overrides) {
115
- overrideClientDefaults(client, overrides);
116
- }
117
- const requestFunction = client[`${method}Async`];
118
- let results = undefined;
119
- try {
120
- if (typeof methodParams === "object" && methodParams !== null) {
121
- results = yield requestFunction(methodParams);
122
- }
123
- else {
124
- results = yield requestFunction({});
125
- }
126
- if (index_1.util.types.isBool(debug) && debug) {
127
- debugRequest(client);
128
- }
129
- return results;
130
- }
131
- catch (error) {
132
- if (index_1.util.types.isBool(debug) && debug) {
133
- debugRequest(client);
134
- }
135
- console.warn("Please verify that the method you specified exists in the WSDL specification.");
136
- throw error;
137
- }
138
- });
139
- /**
140
- * Create a SOAP header
141
- * @param wsdlParam A SOAPConnection or XML definition of a WSDL
142
- * @param headerPayload The contents of a header XML node
143
- * @param headerOptions Attributes for a header XML node, like namespace or xmlns
144
- * @returns
145
- */
146
- const generateHeader = (wsdlParam, headerPayload, headerOptions) => __awaiter(void 0, void 0, void 0, function* () {
147
- const client = yield getSOAPClient((0, types_1.isSOAPConnection)(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
148
- let options = [];
149
- if (headerOptions) {
150
- options = Object.values(headerOptions);
151
- }
152
- const index = client.addSoapHeader(headerPayload, "", ...options);
153
- return client.getSoapHeaders()[index];
154
- });
155
- /**
156
- * Fetch authentication information for a SOAPConnection
157
- * @param connection The SOAPConnection
158
- * @param wsdlDefinition The XML WSDL definition
159
- * @returns
160
- */
161
- const getSOAPAuth = (connection, wsdlDefinition) => __awaiter(void 0, void 0, void 0, function* () {
162
- if ((0, types_1.isBasicAuthConnection)(connection) && wsdlDefinition) {
163
- const { fields: { username, password, loginMethod }, } = connection;
164
- const result = yield soapRequest({
165
- wsdlParam: index_1.util.types.toString(wsdlDefinition),
166
- method: index_1.util.types.toString(loginMethod),
167
- }, { username, password });
168
- return result;
169
- }
170
- else if ((0, types_1.isSOAPConnection)(connection) &&
171
- (0, types_1.isBasicAuthConnection)(connection)) {
172
- const { fields: { username, password, loginMethod }, } = connection;
173
- const result = yield soapRequest({
174
- wsdlParam: connection,
175
- method: index_1.util.types.toString(loginMethod),
176
- }, { username, password });
177
- return result;
178
- }
179
- else {
180
- throw new Error("Must supply a SOAP Connection or a WSDL Definition");
181
- }
182
- });
183
- exports.default = {
184
- describeWSDL,
185
- generateHeader,
186
- getSOAPAuth,
187
- getSOAPClient,
188
- getWSDL,
189
- overrideClientDefaults,
190
- soapRequest,
191
- };