@prismatic-io/spectral 6.5.1 → 6.6.1
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.
|
@@ -13,11 +13,12 @@ export interface ClientProps {
|
|
|
13
13
|
baseUrl?: string;
|
|
14
14
|
responseType?: AxiosRequestConfig["responseType"];
|
|
15
15
|
headers?: AxiosRequestConfig["headers"];
|
|
16
|
+
params?: Record<string, any>;
|
|
16
17
|
timeout?: number;
|
|
17
18
|
debug?: boolean;
|
|
18
19
|
retryConfig?: RetryConfig;
|
|
19
20
|
}
|
|
20
|
-
export declare const createClient: ({ baseUrl, responseType, headers, timeout, debug, retryConfig, }: ClientProps) => HttpClient;
|
|
21
|
+
export declare const createClient: ({ baseUrl, responseType, headers, timeout, params, debug, retryConfig, }: ClientProps) => HttpClient;
|
|
21
22
|
export declare const handleErrors: (error: unknown) => unknown;
|
|
22
23
|
declare type SendRawRequestValues = ActionInputParameters<typeof inputs>;
|
|
23
24
|
export declare const sendRawRequest: (baseUrl: string, values: SendRawRequestValues, authorizationHeaders?: Record<string, string>) => Promise<AxiosResponse>;
|
|
@@ -89,12 +89,13 @@ const toAxiosRetryConfig = (_a) => {
|
|
|
89
89
|
var { retryDelay, retryAllErrors, retryCondition, useExponentialBackoff } = _a, rest = __rest(_a, ["retryDelay", "retryAllErrors", "retryCondition", "useExponentialBackoff"]);
|
|
90
90
|
return (Object.assign(Object.assign({}, rest), { retryDelay: computeRetryDelay(retryDelay, useExponentialBackoff), retryCondition: retryAllErrors ? () => true : retryCondition }));
|
|
91
91
|
};
|
|
92
|
-
const createClient = ({ baseUrl, responseType, headers, timeout, debug = false, retryConfig, }) => {
|
|
92
|
+
const createClient = ({ baseUrl, responseType, headers, timeout, params, debug = false, retryConfig, }) => {
|
|
93
93
|
const client = axios_1.default.create({
|
|
94
94
|
baseURL: baseUrl,
|
|
95
95
|
responseType,
|
|
96
96
|
headers,
|
|
97
97
|
timeout,
|
|
98
|
+
params,
|
|
98
99
|
maxContentLength: Infinity,
|
|
99
100
|
maxBodyLength: Infinity,
|
|
100
101
|
});
|
|
@@ -130,7 +131,9 @@ const sendRawRequest = (baseUrl, values, authorizationHeaders = {}) => __awaiter
|
|
|
130
131
|
if (values.data && (!(0, lodash_1.isEmpty)(values.formData) || !(0, lodash_1.isEmpty)(values.fileData))) {
|
|
131
132
|
throw new Error("Cannot specify both Data and File/Form Data.");
|
|
132
133
|
}
|
|
133
|
-
const payload = values.
|
|
134
|
+
const payload = !(0, lodash_1.isEmpty)(values.formData) || !(0, lodash_1.isEmpty)(values.fileData)
|
|
135
|
+
? toFormData(values.formData, values.fileData)
|
|
136
|
+
: values.data;
|
|
134
137
|
const client = (0, exports.createClient)({
|
|
135
138
|
baseUrl,
|
|
136
139
|
debug: values.debugRequest,
|
|
@@ -47,6 +47,18 @@ export interface ActionContext {
|
|
|
47
47
|
executionState: Record<string, unknown>;
|
|
48
48
|
stepId: string;
|
|
49
49
|
executionId: string;
|
|
50
|
+
webhookUrls: Record<string, string>;
|
|
51
|
+
webhookApiKeys: Record<string, string[]>;
|
|
52
|
+
invokeUrl: string;
|
|
53
|
+
customer: {
|
|
54
|
+
id: string | null;
|
|
55
|
+
externalId: string | null;
|
|
56
|
+
name: string | null;
|
|
57
|
+
};
|
|
58
|
+
instance: {
|
|
59
|
+
id: string | null;
|
|
60
|
+
name: string | null;
|
|
61
|
+
};
|
|
50
62
|
}
|
|
51
63
|
declare type TriggerOptionChoice = "invalid" | "valid" | "required";
|
|
52
64
|
export interface TriggerPayload {
|
package/dist/testing.js
CHANGED
|
@@ -44,7 +44,18 @@ exports.loggerMock = loggerMock;
|
|
|
44
44
|
* action result and a mock logger for asserting logging.
|
|
45
45
|
*/
|
|
46
46
|
const invoke = ({ perform }, params, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId"
|
|
47
|
+
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
48
|
+
"Flow 1": "https://example.com",
|
|
49
|
+
}, webhookApiKeys: {
|
|
50
|
+
"Flow 1": ["example-123", "example-456"],
|
|
51
|
+
}, invokeUrl: "https://example.com", customer: {
|
|
52
|
+
id: "customerId",
|
|
53
|
+
name: "Customer 1",
|
|
54
|
+
externalId: "1234",
|
|
55
|
+
}, instance: {
|
|
56
|
+
id: "instanceId",
|
|
57
|
+
name: "Instance 1",
|
|
58
|
+
} }, context);
|
|
48
59
|
const result = yield perform(realizedContext, params);
|
|
49
60
|
return {
|
|
50
61
|
result,
|
|
@@ -96,7 +107,18 @@ exports.defaultTriggerPayload = defaultTriggerPayload;
|
|
|
96
107
|
* trigger result and a mock logger for asserting logging.
|
|
97
108
|
*/
|
|
98
109
|
const invokeTrigger = ({ perform }, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
-
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId"
|
|
110
|
+
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
111
|
+
"Flow 1": "https://example.com",
|
|
112
|
+
}, webhookApiKeys: {
|
|
113
|
+
"Flow 1": ["example-123", "example-456"],
|
|
114
|
+
}, invokeUrl: "https://example.com", customer: {
|
|
115
|
+
id: "customerId",
|
|
116
|
+
name: "Customer 1",
|
|
117
|
+
externalId: "1234",
|
|
118
|
+
}, instance: {
|
|
119
|
+
id: "instanceId",
|
|
120
|
+
name: "Instance 1",
|
|
121
|
+
} }, context);
|
|
100
122
|
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
|
|
101
123
|
const realizedParams = params || {};
|
|
102
124
|
const result = yield perform(realizedContext, realizedPayload, realizedParams);
|
|
@@ -120,14 +142,36 @@ class ComponentTestHarness {
|
|
|
120
142
|
}
|
|
121
143
|
trigger(key, payload, params, context) {
|
|
122
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId"
|
|
145
|
+
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
146
|
+
"Flow 1": "https://example.com",
|
|
147
|
+
}, webhookApiKeys: {
|
|
148
|
+
"Flow 1": ["example-123", "example-456"],
|
|
149
|
+
}, invokeUrl: "https://example.com", customer: {
|
|
150
|
+
id: "customerId",
|
|
151
|
+
name: "Customer 1",
|
|
152
|
+
externalId: "1234",
|
|
153
|
+
}, instance: {
|
|
154
|
+
id: "instanceId",
|
|
155
|
+
name: "Instance 1",
|
|
156
|
+
} }, context);
|
|
124
157
|
const trigger = this.component.triggers[key];
|
|
125
158
|
return trigger.perform(realizedContext, Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), Object.assign({}, params));
|
|
126
159
|
});
|
|
127
160
|
}
|
|
128
161
|
action(key, params, context) {
|
|
129
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId"
|
|
163
|
+
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
|
|
164
|
+
"Flow 1": "https://example.com",
|
|
165
|
+
}, webhookApiKeys: {
|
|
166
|
+
"Flow 1": ["example-123", "example-456"],
|
|
167
|
+
}, invokeUrl: "https://example.com", customer: {
|
|
168
|
+
id: "customerId",
|
|
169
|
+
name: "Customer 1",
|
|
170
|
+
externalId: "1234",
|
|
171
|
+
}, instance: {
|
|
172
|
+
id: "instanceId",
|
|
173
|
+
name: "Instance 1",
|
|
174
|
+
} }, context);
|
|
131
175
|
const action = this.component.actions[key];
|
|
132
176
|
return action.perform(realizedContext, Object.assign({}, params));
|
|
133
177
|
});
|
|
@@ -15,4 +15,21 @@ export interface ActionContext {
|
|
|
15
15
|
stepId: string;
|
|
16
16
|
/** A unique id that corresponds to the specific execution of the Integration */
|
|
17
17
|
executionId: string;
|
|
18
|
+
/** An object containing webhook URLs for all flows of the currently running instance */
|
|
19
|
+
webhookUrls: Record<string, string>;
|
|
20
|
+
/** An object containing webhook API keys for all flows of the currently running instance */
|
|
21
|
+
webhookApiKeys: Record<string, string[]>;
|
|
22
|
+
/** The URL used to invoke the current execution */
|
|
23
|
+
invokeUrl: string;
|
|
24
|
+
/** An object containing the ID, External ID and name of the customer the instance is deployed to */
|
|
25
|
+
customer: {
|
|
26
|
+
id: string | null;
|
|
27
|
+
externalId: string | null;
|
|
28
|
+
name: string | null;
|
|
29
|
+
};
|
|
30
|
+
/** An object containing the ID ad name of the currently running instance */
|
|
31
|
+
instance: {
|
|
32
|
+
id: string | null;
|
|
33
|
+
name: string | null;
|
|
34
|
+
};
|
|
18
35
|
}
|
package/dist/util.js
CHANGED
|
@@ -26,16 +26,16 @@ const valid_url_1 = require("valid-url");
|
|
|
26
26
|
*/
|
|
27
27
|
const isBool = (value) => value === true || value === false;
|
|
28
28
|
/**
|
|
29
|
-
* Convert
|
|
30
|
-
* and
|
|
31
|
-
* Truthy/
|
|
29
|
+
* Convert truthy (true, "t", "true", "y", "yes") values to boolean `true`,
|
|
30
|
+
* and falsy (false, "f", "false", "n", "no") values to boolean `false`.
|
|
31
|
+
* Truthy/falsy checks are case-insensitive.
|
|
32
32
|
*
|
|
33
33
|
* In the event that `value` is undefined or an empty string, a default value can be provided.
|
|
34
34
|
* For example, `util.types.toBool('', true)` will return `true`.
|
|
35
35
|
*
|
|
36
36
|
* @param value The value to convert to a boolean.
|
|
37
37
|
* @param defaultValue The value to return if `value` is undefined or an empty string.
|
|
38
|
-
* @returns The boolean equivalent of the
|
|
38
|
+
* @returns The boolean equivalent of the truthy or falsy `value`.
|
|
39
39
|
*/
|
|
40
40
|
const toBool = (value, defaultValue) => {
|
|
41
41
|
if (isBool(value)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.1",
|
|
4
4
|
"description": "Utility library for building Prismatic components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismatic"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"check": "yarn run check-format && yarn run lint",
|
|
30
30
|
"lint": "eslint --ext .ts .",
|
|
31
31
|
"lint-fix": "eslint --fix --ext .ts .",
|
|
32
|
-
"test": "jest
|
|
32
|
+
"test": "jest",
|
|
33
33
|
"tsd": "tsd",
|
|
34
34
|
"docs": "rm -f sidebars.{js,jse} && typedoc"
|
|
35
35
|
},
|