@prismatic-io/spectral 5.4.1 → 6.1.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.
- package/dist/clients/http/index.d.ts +13 -0
- package/dist/clients/http/index.js +46 -0
- package/dist/clients/http/inputs.d.ts +116 -0
- package/dist/clients/http/inputs.js +134 -0
- package/dist/clients/soap/index.js +5 -1
- package/dist/clients/soap/types.js +1 -2
- package/dist/clients/soap/utils.js +12 -12
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +6 -10
- package/dist/index.js +8 -60
- package/dist/serverTypes/convert.d.ts +3 -0
- package/dist/serverTypes/convert.js +60 -0
- package/dist/serverTypes/index.d.ts +169 -0
- package/dist/serverTypes/index.js +7 -0
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +13 -15
- package/dist/types/ActionDefinition.d.ts +6 -6
- package/dist/types/ActionInputParameters.d.ts +3 -3
- package/dist/types/ActionLogger.d.ts +1 -1
- package/dist/types/ActionLogger.js +1 -1
- package/dist/types/ActionPerformFunction.d.ts +4 -2
- package/dist/types/ActionPerformReturn.d.ts +4 -2
- package/dist/types/ComponentDefinition.d.ts +28 -6
- package/dist/types/DataPayload.d.ts +10 -0
- package/dist/types/DataPayload.js +2 -0
- package/dist/types/Inputs.d.ts +5 -2
- package/dist/types/TriggerDefinition.d.ts +6 -6
- package/dist/types/TriggerPerformFunction.d.ts +1 -1
- package/dist/types/TriggerResult.d.ts +5 -3
- package/dist/types/conditional-logic.d.ts +1 -1
- package/dist/types/conditional-logic.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +6 -15
- package/dist/util.d.ts +9 -3
- package/dist/util.js +20 -7
- package/package.json +27 -45
- package/dist/types/server-types.d.ts +0 -174
- package/dist/types/server-types.js +0 -8
- package/dist/util.test.d.ts +0 -1
- package/dist/util.test.js +0 -305
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
import { IAxiosRetryConfig } from "axios-retry";
|
|
3
|
+
export declare type HttpClient = AxiosInstance;
|
|
4
|
+
export interface ClientProps {
|
|
5
|
+
baseUrl?: string;
|
|
6
|
+
responseType?: AxiosRequestConfig["responseType"];
|
|
7
|
+
headers?: AxiosRequestConfig["headers"];
|
|
8
|
+
timeout?: number;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
retryConfig?: IAxiosRetryConfig;
|
|
11
|
+
}
|
|
12
|
+
export declare const createClient: ({ baseUrl, responseType, headers, timeout, debug, retryConfig, }: ClientProps) => HttpClient;
|
|
13
|
+
export declare const handleErrors: (error: unknown) => unknown;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleErrors = exports.createClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
const createClient = ({ baseUrl, responseType, headers, timeout, debug = false, retryConfig, }) => {
|
|
11
|
+
const client = axios_1.default.create({
|
|
12
|
+
baseURL: baseUrl,
|
|
13
|
+
responseType,
|
|
14
|
+
headers,
|
|
15
|
+
timeout,
|
|
16
|
+
maxContentLength: Infinity,
|
|
17
|
+
maxBodyLength: Infinity,
|
|
18
|
+
});
|
|
19
|
+
if (debug) {
|
|
20
|
+
client.interceptors.request.use((request) => {
|
|
21
|
+
console.log((0, util_1.toJSON)(request));
|
|
22
|
+
return request;
|
|
23
|
+
});
|
|
24
|
+
client.interceptors.response.use((response) => {
|
|
25
|
+
console.log((0, util_1.toJSON)(response));
|
|
26
|
+
return response;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (retryConfig) {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
(0, axios_retry_1.default)(client, retryConfig);
|
|
32
|
+
}
|
|
33
|
+
return client;
|
|
34
|
+
};
|
|
35
|
+
exports.createClient = createClient;
|
|
36
|
+
const handleErrors = (error) => {
|
|
37
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
38
|
+
const { message, response } = error;
|
|
39
|
+
return {
|
|
40
|
+
message,
|
|
41
|
+
data: response === null || response === void 0 ? void 0 : response.data,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return error;
|
|
45
|
+
};
|
|
46
|
+
exports.handleErrors = handleErrors;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Method, ResponseType } from "axios";
|
|
2
|
+
export declare const url: {
|
|
3
|
+
label: string;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
type: "string";
|
|
6
|
+
required: true;
|
|
7
|
+
comments: string;
|
|
8
|
+
example: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const data: {
|
|
11
|
+
label: string;
|
|
12
|
+
placeholder: string;
|
|
13
|
+
type: "string";
|
|
14
|
+
required: false;
|
|
15
|
+
comments: string;
|
|
16
|
+
example: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const timeout: {
|
|
19
|
+
label: string;
|
|
20
|
+
type: "string";
|
|
21
|
+
required: false;
|
|
22
|
+
comments: string;
|
|
23
|
+
example: string;
|
|
24
|
+
};
|
|
25
|
+
export declare const method: {
|
|
26
|
+
label: string;
|
|
27
|
+
type: "string";
|
|
28
|
+
model: {
|
|
29
|
+
label: Method;
|
|
30
|
+
value: Method;
|
|
31
|
+
}[];
|
|
32
|
+
comments: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const responseType: {
|
|
35
|
+
label: string;
|
|
36
|
+
placeholder: string;
|
|
37
|
+
type: "string";
|
|
38
|
+
default: string;
|
|
39
|
+
required: false;
|
|
40
|
+
comments: string;
|
|
41
|
+
model: {
|
|
42
|
+
label: ResponseType;
|
|
43
|
+
value: ResponseType;
|
|
44
|
+
}[];
|
|
45
|
+
};
|
|
46
|
+
export declare const headers: {
|
|
47
|
+
label: string;
|
|
48
|
+
placeholder: string;
|
|
49
|
+
type: "string";
|
|
50
|
+
collection: "keyvaluelist";
|
|
51
|
+
required: false;
|
|
52
|
+
comments: string;
|
|
53
|
+
example: string;
|
|
54
|
+
};
|
|
55
|
+
export declare const queryParams: {
|
|
56
|
+
label: string;
|
|
57
|
+
placeholder: string;
|
|
58
|
+
type: "string";
|
|
59
|
+
collection: "keyvaluelist";
|
|
60
|
+
required: false;
|
|
61
|
+
comments: string;
|
|
62
|
+
};
|
|
63
|
+
export declare const maxRetries: {
|
|
64
|
+
label: string;
|
|
65
|
+
placeholder: string;
|
|
66
|
+
type: "string";
|
|
67
|
+
required: false;
|
|
68
|
+
comments: string;
|
|
69
|
+
default: string;
|
|
70
|
+
};
|
|
71
|
+
export declare const retryDelayMS: {
|
|
72
|
+
label: string;
|
|
73
|
+
placeholder: string;
|
|
74
|
+
type: "string";
|
|
75
|
+
required: false;
|
|
76
|
+
comments: string;
|
|
77
|
+
default: string;
|
|
78
|
+
};
|
|
79
|
+
export declare const useExponentialBackoff: {
|
|
80
|
+
label: string;
|
|
81
|
+
type: "boolean";
|
|
82
|
+
default: string;
|
|
83
|
+
required: false;
|
|
84
|
+
comments: string;
|
|
85
|
+
};
|
|
86
|
+
export declare const retryOnAllErrors: {
|
|
87
|
+
label: string;
|
|
88
|
+
type: "boolean";
|
|
89
|
+
default: string;
|
|
90
|
+
required: false;
|
|
91
|
+
comments: string;
|
|
92
|
+
};
|
|
93
|
+
export declare const formData: {
|
|
94
|
+
label: string;
|
|
95
|
+
placeholder: string;
|
|
96
|
+
type: "string";
|
|
97
|
+
collection: "keyvaluelist";
|
|
98
|
+
required: false;
|
|
99
|
+
comments: string;
|
|
100
|
+
example: string;
|
|
101
|
+
};
|
|
102
|
+
export declare const fileData: {
|
|
103
|
+
label: string;
|
|
104
|
+
placeholder: string;
|
|
105
|
+
type: "string";
|
|
106
|
+
collection: "keyvaluelist";
|
|
107
|
+
required: false;
|
|
108
|
+
comments: string;
|
|
109
|
+
example: string;
|
|
110
|
+
};
|
|
111
|
+
export declare const debugRequest: {
|
|
112
|
+
label: string;
|
|
113
|
+
type: "boolean";
|
|
114
|
+
required: false;
|
|
115
|
+
comments: string;
|
|
116
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.debugRequest = exports.fileData = exports.formData = exports.retryOnAllErrors = exports.useExponentialBackoff = exports.retryDelayMS = exports.maxRetries = exports.queryParams = exports.headers = exports.responseType = exports.method = exports.timeout = exports.data = exports.url = void 0;
|
|
4
|
+
const __1 = require("../..");
|
|
5
|
+
const supportedMethods = [
|
|
6
|
+
"DELETE",
|
|
7
|
+
"GET",
|
|
8
|
+
"HEAD",
|
|
9
|
+
"LINK",
|
|
10
|
+
"OPTIONS",
|
|
11
|
+
"PATCH",
|
|
12
|
+
"POST",
|
|
13
|
+
"PURGE",
|
|
14
|
+
"PUT",
|
|
15
|
+
"UNLINK",
|
|
16
|
+
];
|
|
17
|
+
const supportedResponseTypes = [
|
|
18
|
+
"arraybuffer",
|
|
19
|
+
"document",
|
|
20
|
+
"json",
|
|
21
|
+
"text",
|
|
22
|
+
];
|
|
23
|
+
exports.url = (0, __1.input)({
|
|
24
|
+
label: "URL",
|
|
25
|
+
placeholder: "URL to call",
|
|
26
|
+
type: "string",
|
|
27
|
+
required: true,
|
|
28
|
+
comments: "This is the URL to call.",
|
|
29
|
+
example: "/sobjects/Account",
|
|
30
|
+
});
|
|
31
|
+
exports.data = (0, __1.input)({
|
|
32
|
+
label: "Data",
|
|
33
|
+
placeholder: "Data to send",
|
|
34
|
+
type: "string",
|
|
35
|
+
required: false,
|
|
36
|
+
comments: "The HTTP body payload to send to the URL. Must be a string or a reference to output from a previous step.",
|
|
37
|
+
example: '{"exampleKey": "Example Data"}',
|
|
38
|
+
});
|
|
39
|
+
exports.timeout = (0, __1.input)({
|
|
40
|
+
label: "Timeout",
|
|
41
|
+
type: "string",
|
|
42
|
+
required: false,
|
|
43
|
+
comments: "The maximum time that a client will await a response to its request",
|
|
44
|
+
example: "2000",
|
|
45
|
+
});
|
|
46
|
+
exports.method = (0, __1.input)({
|
|
47
|
+
label: "Method",
|
|
48
|
+
type: "string",
|
|
49
|
+
model: supportedMethods.map((method) => ({ label: method, value: method })),
|
|
50
|
+
comments: "The HTTP method to use.",
|
|
51
|
+
});
|
|
52
|
+
exports.responseType = (0, __1.input)({
|
|
53
|
+
label: "Response Type",
|
|
54
|
+
placeholder: "Response Type",
|
|
55
|
+
type: "string",
|
|
56
|
+
default: "json",
|
|
57
|
+
required: false,
|
|
58
|
+
comments: "The type of data you expect in the response. You can request json, text, or binary data.",
|
|
59
|
+
model: supportedResponseTypes.map((responseType) => ({
|
|
60
|
+
label: responseType,
|
|
61
|
+
value: responseType,
|
|
62
|
+
})),
|
|
63
|
+
});
|
|
64
|
+
exports.headers = (0, __1.input)({
|
|
65
|
+
label: "Header",
|
|
66
|
+
placeholder: "Header",
|
|
67
|
+
type: "string",
|
|
68
|
+
collection: "keyvaluelist",
|
|
69
|
+
required: false,
|
|
70
|
+
comments: "A list of headers to send with the request.",
|
|
71
|
+
example: "User-Agent: curl/7.64.1",
|
|
72
|
+
});
|
|
73
|
+
exports.queryParams = (0, __1.input)({
|
|
74
|
+
label: "Query Parameter",
|
|
75
|
+
placeholder: "Query Parameter",
|
|
76
|
+
type: "string",
|
|
77
|
+
collection: "keyvaluelist",
|
|
78
|
+
required: false,
|
|
79
|
+
comments: "A list of query parameters to send with the request. This is the portion at the end of the URL similar to ?key1=value1&key2=value2.",
|
|
80
|
+
});
|
|
81
|
+
exports.maxRetries = (0, __1.input)({
|
|
82
|
+
label: "Max Retry Count",
|
|
83
|
+
placeholder: "Max Retries",
|
|
84
|
+
type: "string",
|
|
85
|
+
required: false,
|
|
86
|
+
comments: "The maximum number of retries to attempt.",
|
|
87
|
+
default: "0",
|
|
88
|
+
});
|
|
89
|
+
exports.retryDelayMS = (0, __1.input)({
|
|
90
|
+
label: "Retry Delay (ms)",
|
|
91
|
+
placeholder: "Retry Delay",
|
|
92
|
+
type: "string",
|
|
93
|
+
required: false,
|
|
94
|
+
comments: "The delay in milliseconds between retries.",
|
|
95
|
+
default: "0",
|
|
96
|
+
});
|
|
97
|
+
exports.useExponentialBackoff = (0, __1.input)({
|
|
98
|
+
label: "Use Exponential Backoff",
|
|
99
|
+
type: "boolean",
|
|
100
|
+
default: "false",
|
|
101
|
+
required: false,
|
|
102
|
+
comments: "Specifies whether to use a pre-defined exponential backoff strategy for retries.",
|
|
103
|
+
});
|
|
104
|
+
exports.retryOnAllErrors = (0, __1.input)({
|
|
105
|
+
label: "Retry On All Errors",
|
|
106
|
+
type: "boolean",
|
|
107
|
+
default: "false",
|
|
108
|
+
required: false,
|
|
109
|
+
comments: "If true, retries on all erroneous responses regardless of type.",
|
|
110
|
+
});
|
|
111
|
+
exports.formData = (0, __1.input)({
|
|
112
|
+
label: "Form Data",
|
|
113
|
+
placeholder: "Data to send",
|
|
114
|
+
type: "string",
|
|
115
|
+
collection: "keyvaluelist",
|
|
116
|
+
required: false,
|
|
117
|
+
comments: "The Form Data to be sent as a multipart form upload.",
|
|
118
|
+
example: '[{"key": "Example Key", "value": new Buffer("Hello World")}]',
|
|
119
|
+
});
|
|
120
|
+
exports.fileData = (0, __1.input)({
|
|
121
|
+
label: "File Data",
|
|
122
|
+
placeholder: "Data to send",
|
|
123
|
+
type: "string",
|
|
124
|
+
collection: "keyvaluelist",
|
|
125
|
+
required: false,
|
|
126
|
+
comments: "File Data to be sent as a multipart form upload.",
|
|
127
|
+
example: `[{key: "example.txt", value: "My File Contents"}]`,
|
|
128
|
+
});
|
|
129
|
+
exports.debugRequest = (0, __1.input)({
|
|
130
|
+
label: "Debug Request",
|
|
131
|
+
type: "boolean",
|
|
132
|
+
required: false,
|
|
133
|
+
comments: "Enabling this flag will log out the current request.",
|
|
134
|
+
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -7,9 +7,8 @@ exports.isBasicAuthConnection = exports.isSOAPConnection = void 0;
|
|
|
7
7
|
* @returns This function returns true if the connection is a SOAPConnection, and false otherwise.
|
|
8
8
|
*/
|
|
9
9
|
const isSOAPConnection = (connection) => {
|
|
10
|
-
var _a;
|
|
11
10
|
if (typeof connection === "object" && connection !== null)
|
|
12
|
-
return "wsdlDefinitionURL" in (
|
|
11
|
+
return "wsdlDefinitionURL" in (connection === null || connection === void 0 ? void 0 : connection.fields);
|
|
13
12
|
return false;
|
|
14
13
|
};
|
|
15
14
|
exports.isSOAPConnection = isSOAPConnection;
|
|
@@ -38,7 +38,7 @@ const debugRequest = (client) => {
|
|
|
38
38
|
* @returns An object containing the methods and attributes defined in a WSDL
|
|
39
39
|
*/
|
|
40
40
|
const describeWSDL = (wsdlParam) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
-
const client = yield getSOAPClient(types_1.isSOAPConnection(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
|
|
41
|
+
const client = yield getSOAPClient((0, types_1.isSOAPConnection)(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
|
|
42
42
|
try {
|
|
43
43
|
const result = client.describe();
|
|
44
44
|
return result;
|
|
@@ -68,19 +68,19 @@ const getWSDL = (wsdlDefinitionURL) => __awaiter(void 0, void 0, void 0, functio
|
|
|
68
68
|
const getSOAPClient = (wsdlParam) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
69
|
if (typeof wsdlParam === "string") {
|
|
70
70
|
const wsdl = index_1.util.types.toString(wsdlParam);
|
|
71
|
-
const filePath = path_1.default.join(os_1.default.tmpdir(), `${uuid_1.v4()}.wsdl`);
|
|
72
|
-
yield promises_1.writeFile(filePath, wsdl);
|
|
73
|
-
const client = yield soap_1.createClientAsync(filePath);
|
|
74
|
-
yield promises_1.rm(filePath);
|
|
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
75
|
return client;
|
|
76
76
|
}
|
|
77
|
-
else if (types_1.isSOAPConnection(wsdlParam)) {
|
|
77
|
+
else if ((0, types_1.isSOAPConnection)(wsdlParam)) {
|
|
78
78
|
const { fields: { wsdlDefinitionURL }, } = wsdlParam;
|
|
79
79
|
if (!wsdlDefinitionURL ||
|
|
80
80
|
!index_1.util.types.isUrl(index_1.util.types.toString(wsdlDefinitionURL))) {
|
|
81
81
|
throw new Error("WSDL Definition or the Connection field 'wsdlDefinitionURL' must be supplied.");
|
|
82
82
|
}
|
|
83
|
-
const client = yield soap_1.createClientAsync(index_1.util.types.toString(wsdlDefinitionURL));
|
|
83
|
+
const client = yield (0, soap_1.createClientAsync)(index_1.util.types.toString(wsdlDefinitionURL));
|
|
84
84
|
return client;
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
@@ -110,7 +110,7 @@ const overrideClientDefaults = (client, overrides) => {
|
|
|
110
110
|
* @returns The results from the SOAP request, including the full XML of the request and response
|
|
111
111
|
*/
|
|
112
112
|
const soapRequest = ({ wsdlParam, method, overrides, debug }, methodParams) => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
-
const client = yield getSOAPClient(types_1.isSOAPConnection(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
|
|
113
|
+
const client = yield getSOAPClient((0, types_1.isSOAPConnection)(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
|
|
114
114
|
if (overrides) {
|
|
115
115
|
overrideClientDefaults(client, overrides);
|
|
116
116
|
}
|
|
@@ -144,7 +144,7 @@ const soapRequest = ({ wsdlParam, method, overrides, debug }, methodParams) => _
|
|
|
144
144
|
* @returns
|
|
145
145
|
*/
|
|
146
146
|
const generateHeader = (wsdlParam, headerPayload, headerOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
-
const client = yield getSOAPClient(types_1.isSOAPConnection(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
|
|
147
|
+
const client = yield getSOAPClient((0, types_1.isSOAPConnection)(wsdlParam) ? wsdlParam : index_1.util.types.toString(wsdlParam));
|
|
148
148
|
let options = [];
|
|
149
149
|
if (headerOptions) {
|
|
150
150
|
options = Object.values(headerOptions);
|
|
@@ -159,7 +159,7 @@ const generateHeader = (wsdlParam, headerPayload, headerOptions) => __awaiter(vo
|
|
|
159
159
|
* @returns
|
|
160
160
|
*/
|
|
161
161
|
const getSOAPAuth = (connection, wsdlDefinition) => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
|
-
if (types_1.isBasicAuthConnection(connection) && wsdlDefinition) {
|
|
162
|
+
if ((0, types_1.isBasicAuthConnection)(connection) && wsdlDefinition) {
|
|
163
163
|
const { fields: { username, password, loginMethod }, } = connection;
|
|
164
164
|
const result = yield soapRequest({
|
|
165
165
|
wsdlParam: index_1.util.types.toString(wsdlDefinition),
|
|
@@ -167,8 +167,8 @@ const getSOAPAuth = (connection, wsdlDefinition) => __awaiter(void 0, void 0, vo
|
|
|
167
167
|
}, { username, password });
|
|
168
168
|
return result;
|
|
169
169
|
}
|
|
170
|
-
else if (types_1.isSOAPConnection(connection) &&
|
|
171
|
-
types_1.isBasicAuthConnection(connection)) {
|
|
170
|
+
else if ((0, types_1.isSOAPConnection)(connection) &&
|
|
171
|
+
(0, types_1.isBasicAuthConnection)(connection)) {
|
|
172
172
|
const { fields: { username, password, loginMethod }, } = connection;
|
|
173
173
|
const result = yield soapRequest({
|
|
174
174
|
wsdlParam: connection,
|
package/dist/errors.js
CHANGED
|
@@ -22,5 +22,5 @@ const isSpectralError = (payload) => Boolean(payload &&
|
|
|
22
22
|
"isSpectralError" in payload &&
|
|
23
23
|
payload.isSpectralError === true);
|
|
24
24
|
exports.isSpectralError = isSpectralError;
|
|
25
|
-
const isConnectionError = (payload) => exports.isSpectralError(payload) && "connection" in payload;
|
|
25
|
+
const isConnectionError = (payload) => (0, exports.isSpectralError)(payload) && "connection" in payload;
|
|
26
26
|
exports.isConnectionError = isConnectionError;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,21 +3,17 @@
|
|
|
3
3
|
* authors create inputs, actions, and components that can
|
|
4
4
|
* be processed by the Prismatic API.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* the Prismatic API expects are imported here.
|
|
9
|
-
*/
|
|
10
|
-
import { ActionDefinition, InputFieldDefinition, ActionPerformReturn, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, TriggerResult } from "./types";
|
|
11
|
-
import { Component } from "./types/server-types";
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition } from "./types";
|
|
7
|
+
import { convertComponent } from "./serverTypes/convert";
|
|
12
8
|
/**
|
|
13
9
|
* This function creates a component object that can be
|
|
14
10
|
* imported into the Prismatic API. For information on using
|
|
15
11
|
* this function to write custom components, see
|
|
16
12
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#exporting-a-component.
|
|
17
|
-
* @param definition A ComponentDefinition type object, including display
|
|
13
|
+
* @param definition A ComponentDefinition type object, including display information, unique key, and a set of actions the component implements.
|
|
18
14
|
* @returns This function returns a component object that has the shape the Prismatic API expects.
|
|
19
15
|
*/
|
|
20
|
-
export declare const component: <T extends boolean>(definition: ComponentDefinition<T>) =>
|
|
16
|
+
export declare const component: <T extends boolean>(definition: ComponentDefinition<T>) => ReturnType<typeof convertComponent>;
|
|
21
17
|
/**
|
|
22
18
|
* This function creates an action object that can be referenced
|
|
23
19
|
* by a custom component. It helps ensure that the shape of the
|
|
@@ -27,7 +23,7 @@ export declare const component: <T extends boolean>(definition: ComponentDefinit
|
|
|
27
23
|
* @param definition An ActionDefinition type object that includes UI display information, a function to perform when the action is invoked, and a an object containing inputs for the perform function.
|
|
28
24
|
* @returns This function validates the shape of the `definition` object provided, and returns the same action object.
|
|
29
25
|
*/
|
|
30
|
-
export declare const action: <T extends Inputs
|
|
26
|
+
export declare const action: <T extends Inputs>(definition: ActionDefinition<T>) => ActionDefinition<T>;
|
|
31
27
|
/**
|
|
32
28
|
* This function creates a trigger object that can be referenced
|
|
33
29
|
* by a custom component. It helps ensure that the shape of the
|
|
@@ -37,7 +33,7 @@ export declare const action: <T extends Inputs, AllowsBranching extends boolean,
|
|
|
37
33
|
* @param definition A TriggerDefinition type object that includes UI display information, a function to perform when the trigger is invoked, and a an object containing inputs for the perform function.
|
|
38
34
|
* @returns This function validates the shape of the `definition` object provided, and returns the same trigger object.
|
|
39
35
|
*/
|
|
40
|
-
export declare const trigger: <T extends Inputs
|
|
36
|
+
export declare const trigger: <T extends Inputs>(definition: TriggerDefinition<T>) => TriggerDefinition<T>;
|
|
41
37
|
/**
|
|
42
38
|
* For information and examples on how to write inputs
|
|
43
39
|
* for custom component actions and triggers, see
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
9
|
-
Object.
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
10
14
|
}) : (function(o, m, k, k2) {
|
|
11
15
|
if (k2 === undefined) k2 = k;
|
|
12
16
|
o[k2] = m[k];
|
|
@@ -14,77 +18,21 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
14
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
20
|
};
|
|
17
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
18
|
-
var t = {};
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
22
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
23
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
24
|
-
t[p[i]] = s[p[i]];
|
|
25
|
-
}
|
|
26
|
-
return t;
|
|
27
|
-
};
|
|
28
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
23
|
};
|
|
31
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
25
|
exports.testing = exports.util = exports.oauth2Connection = exports.connection = exports.input = exports.trigger = exports.action = exports.component = void 0;
|
|
33
|
-
|
|
34
|
-
* Both component author-facing types and server types that
|
|
35
|
-
* the Prismatic API expects are imported here.
|
|
36
|
-
*/
|
|
37
|
-
const types_1 = require("./types");
|
|
38
|
-
const convertInput = (key, _a) => {
|
|
39
|
-
var { default: defaultValue, type, label, collection } = _a, rest = __rest(_a, ["default", "type", "label", "collection"]);
|
|
40
|
-
return (Object.assign(Object.assign({}, rest), { key,
|
|
41
|
-
type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], collection, label: typeof label === "string" ? label : label.value, keyLabel: collection === "keyvaluelist" && typeof label === "object"
|
|
42
|
-
? label.key
|
|
43
|
-
: undefined }));
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* This is a helper function for component() to convert an
|
|
47
|
-
* action defined in TypeScript into an action object that
|
|
48
|
-
* Prismatic's API can process.
|
|
49
|
-
* @param actionKey The unique identifier of an action.
|
|
50
|
-
* @param action The action definition, including its inputs, perform function, and app display information.
|
|
51
|
-
* @returns This function returns an action object that has the shape the Prismatic API expects.
|
|
52
|
-
*/
|
|
53
|
-
const convertAction = (actionKey, action) => {
|
|
54
|
-
var _a;
|
|
55
|
-
return (Object.assign(Object.assign({}, action), { key: actionKey, inputs: Object.entries((_a = action.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)), perform: action.perform, examplePayload: action.examplePayload }));
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* This is a helper function for component() to convert a
|
|
59
|
-
* trigger defined in TypeScript into an trigger object that
|
|
60
|
-
* Prismatic's API can process.
|
|
61
|
-
* @param triggerKey The unique identifier of a trigger.
|
|
62
|
-
* @param trigger The trigger definition, including its inputs, perform function, and app display information.
|
|
63
|
-
* @returns This function returns a trigger object that has the shape the Prismatic API expects.
|
|
64
|
-
*/
|
|
65
|
-
const convertTrigger = (triggerKey, trigger) => {
|
|
66
|
-
var _a;
|
|
67
|
-
return (Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: Object.entries((_a = trigger.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)), perform: trigger.perform, examplePayload: trigger.examplePayload || undefined }));
|
|
68
|
-
};
|
|
69
|
-
const convertConnection = (connection) => {
|
|
70
|
-
var _a;
|
|
71
|
-
return (Object.assign(Object.assign({}, connection), { inputs: Object.entries((_a = connection.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)) }));
|
|
72
|
-
};
|
|
26
|
+
const convert_1 = require("./serverTypes/convert");
|
|
73
27
|
/**
|
|
74
28
|
* This function creates a component object that can be
|
|
75
29
|
* imported into the Prismatic API. For information on using
|
|
76
30
|
* this function to write custom components, see
|
|
77
31
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#exporting-a-component.
|
|
78
|
-
* @param definition A ComponentDefinition type object, including display
|
|
32
|
+
* @param definition A ComponentDefinition type object, including display information, unique key, and a set of actions the component implements.
|
|
79
33
|
* @returns This function returns a component object that has the shape the Prismatic API expects.
|
|
80
34
|
*/
|
|
81
|
-
const component = (definition) => (
|
|
82
|
-
actionKey,
|
|
83
|
-
convertAction(actionKey, action),
|
|
84
|
-
])), triggers: Object.fromEntries(Object.entries(definition.triggers || {}).map(([triggerKey, trigger]) => [
|
|
85
|
-
triggerKey,
|
|
86
|
-
convertTrigger(triggerKey, trigger),
|
|
87
|
-
])), connections: (definition.connections || []).map(convertConnection) }));
|
|
35
|
+
const component = (definition) => (0, convert_1.convertComponent)(definition);
|
|
88
36
|
exports.component = component;
|
|
89
37
|
/**
|
|
90
38
|
* This function creates an action object that can be referenced
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ComponentDefinition } from "../types";
|
|
2
|
+
import { Component as ServerComponent } from ".";
|
|
3
|
+
export declare const convertComponent: <TPublic extends boolean = false>({ connections, actions, triggers, hooks, ...definition }: ComponentDefinition<TPublic>) => ServerComponent;
|
|
@@ -0,0 +1,60 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.convertComponent = void 0;
|
|
24
|
+
const serialize_error_1 = require("serialize-error");
|
|
25
|
+
const util_1 = require("../util");
|
|
26
|
+
const types_1 = require("../types");
|
|
27
|
+
const wrapPerform = (fn, errorHandler) => {
|
|
28
|
+
return (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
try {
|
|
30
|
+
return yield fn(...args);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error((0, util_1.toJSON)((0, serialize_error_1.serializeError)(errorHandler(error))));
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const convertInput = (key, _a) => {
|
|
38
|
+
var { default: defaultValue, type, label, collection } = _a, rest = __rest(_a, ["default", "type", "label", "collection"]);
|
|
39
|
+
return (Object.assign(Object.assign({}, rest), { key,
|
|
40
|
+
type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], collection, label: typeof label === "string" ? label : label.value, keyLabel: collection === "keyvaluelist" && typeof label === "object"
|
|
41
|
+
? label.key
|
|
42
|
+
: undefined }));
|
|
43
|
+
};
|
|
44
|
+
const convertAction = (actionKey, _a, hooks) => {
|
|
45
|
+
var { inputs = {}, perform } = _a, action = __rest(_a, ["inputs", "perform"]);
|
|
46
|
+
return (Object.assign(Object.assign({}, action), { key: actionKey, perform: (hooks === null || hooks === void 0 ? void 0 : hooks.error) ? wrapPerform(perform, hooks.error) : perform, inputs: Object.entries(inputs).map(([key, value]) => convertInput(key, value)) }));
|
|
47
|
+
};
|
|
48
|
+
const convertTrigger = (triggerKey, _a, hooks) => {
|
|
49
|
+
var { inputs = {}, perform } = _a, trigger = __rest(_a, ["inputs", "perform"]);
|
|
50
|
+
return (Object.assign(Object.assign({}, trigger), { key: triggerKey, perform: (hooks === null || hooks === void 0 ? void 0 : hooks.error) ? wrapPerform(perform, hooks.error) : perform, inputs: Object.entries(inputs).map(([key, value]) => convertInput(key, value)) }));
|
|
51
|
+
};
|
|
52
|
+
const convertConnection = (connection) => {
|
|
53
|
+
var _a;
|
|
54
|
+
return (Object.assign(Object.assign({}, connection), { inputs: Object.entries((_a = connection.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)) }));
|
|
55
|
+
};
|
|
56
|
+
const convertComponent = (_a) => {
|
|
57
|
+
var { connections = [], actions = {}, triggers = {}, hooks } = _a, definition = __rest(_a, ["connections", "actions", "triggers", "hooks"]);
|
|
58
|
+
return (Object.assign(Object.assign({}, definition), { connections: connections.map(convertConnection), actions: Object.entries(actions).reduce((result, [actionKey, action]) => (Object.assign(Object.assign({}, result), { [actionKey]: convertAction(actionKey, action, hooks) })), {}), triggers: Object.entries(triggers).reduce((result, [triggerKey, trigger]) => (Object.assign(Object.assign({}, result), { [triggerKey]: convertTrigger(triggerKey, trigger, hooks) })), {}) }));
|
|
59
|
+
};
|
|
60
|
+
exports.convertComponent = convertComponent;
|