@prismatic-io/spectral 7.0.15-pre → 7.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.
|
@@ -15,7 +15,6 @@ export declare const data: {
|
|
|
15
15
|
required: false;
|
|
16
16
|
comments: string;
|
|
17
17
|
example: string;
|
|
18
|
-
clean: (value: unknown) => string;
|
|
19
18
|
};
|
|
20
19
|
export declare const timeout: {
|
|
21
20
|
label: string;
|
|
@@ -153,7 +152,6 @@ export declare const inputs: {
|
|
|
153
152
|
required: false;
|
|
154
153
|
comments: string;
|
|
155
154
|
example: string;
|
|
156
|
-
clean: (value: unknown) => string;
|
|
157
155
|
};
|
|
158
156
|
formData: {
|
|
159
157
|
label: string;
|
|
@@ -34,9 +34,8 @@ exports.data = (0, __1.input)({
|
|
|
34
34
|
placeholder: "Data to send",
|
|
35
35
|
type: "string",
|
|
36
36
|
required: false,
|
|
37
|
-
comments: "The HTTP body payload to send to the URL.
|
|
37
|
+
comments: "The HTTP body payload to send to the URL.",
|
|
38
38
|
example: '{"exampleKey": "Example Data"}',
|
|
39
|
-
clean: (value) => __1.util.types.toString(value),
|
|
40
39
|
});
|
|
41
40
|
exports.timeout = (0, __1.input)({
|
|
42
41
|
label: "Timeout",
|
package/dist/util.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Many functions in the `util` module are used to coerce data into a particular type, and can be accessed through `util.types`.
|
|
4
4
|
* For example, `util.types.toInt("5.5")` will return an integer, `5`.
|
|
5
5
|
*/
|
|
6
|
-
import { KeyValuePair, DataPayload, ObjectSelection, ObjectFieldMap, JSONForm } from "./types";
|
|
6
|
+
import { KeyValuePair, DataPayload, ObjectSelection, ObjectFieldMap, JSONForm, ConnectionDefinition } from "./types";
|
|
7
7
|
/**
|
|
8
8
|
* This function returns a lower cased version of the headers passed to it.
|
|
9
9
|
*
|
|
@@ -45,6 +45,7 @@ declare const _default: {
|
|
|
45
45
|
toJSONForm: (value: unknown) => JSONForm;
|
|
46
46
|
isPicklist: (value: unknown) => boolean;
|
|
47
47
|
isSchedule: (value: unknown) => boolean;
|
|
48
|
+
isConnection: (value: unknown) => value is ConnectionDefinition;
|
|
48
49
|
};
|
|
49
50
|
docs: {
|
|
50
51
|
formatJsonExample: (input: unknown) => string;
|
package/dist/util.js
CHANGED
|
@@ -405,6 +405,31 @@ const isString = (value) => typeof value === "string" || value instanceof String
|
|
|
405
405
|
* @returns This function returns the stringified version fo `value`, or `defaultValue` in the case that `value` is undefined or an empty string.
|
|
406
406
|
*/
|
|
407
407
|
const toString = (value, defaultValue = "") => `${value !== null && value !== void 0 ? value : defaultValue}`;
|
|
408
|
+
/**
|
|
409
|
+
* This function checks if value is a valid connection.
|
|
410
|
+
* @param value The variable to test.
|
|
411
|
+
* @returns This function returns true or false, depending on if `value` is a valid connection.
|
|
412
|
+
*/
|
|
413
|
+
const isConnection = (value) => {
|
|
414
|
+
if (typeof value === "string" && isJSON(value)) {
|
|
415
|
+
return isConnection(JSON.parse(value));
|
|
416
|
+
}
|
|
417
|
+
if (Boolean(value) && typeof value === "object") {
|
|
418
|
+
const { inputs } = value;
|
|
419
|
+
if (isObjectWithTruthyKeys(value, ["key", "label", "oauth2Type"])) {
|
|
420
|
+
return (isObjectWithTruthyKeys(inputs, [
|
|
421
|
+
"authorizeUrl",
|
|
422
|
+
"tokenUrl",
|
|
423
|
+
"clientId",
|
|
424
|
+
"clientSecret",
|
|
425
|
+
]) ||
|
|
426
|
+
isObjectWithTruthyKeys(inputs, ["tokenUrl", "clientId", "clientSecret"]));
|
|
427
|
+
}
|
|
428
|
+
return (isObjectWithTruthyKeys(value, ["key", "label"]) &&
|
|
429
|
+
typeof inputs === "object");
|
|
430
|
+
}
|
|
431
|
+
return false;
|
|
432
|
+
};
|
|
408
433
|
/**
|
|
409
434
|
* This function returns true if `value` resembles the shape of JSON, and false otherwise.
|
|
410
435
|
*
|
|
@@ -478,6 +503,7 @@ exports.default = {
|
|
|
478
503
|
toJSONForm,
|
|
479
504
|
isPicklist,
|
|
480
505
|
isSchedule,
|
|
506
|
+
isConnection,
|
|
481
507
|
},
|
|
482
508
|
docs: {
|
|
483
509
|
formatJsonExample,
|