@prismatic-io/spectral 6.5.0 → 6.5.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.
@@ -1,13 +1,159 @@
1
+ import { AxiosResponse } from "axios";
1
2
  import { AxiosInstance, AxiosRequestConfig } from "axios";
2
3
  import { IAxiosRetryConfig } from "axios-retry";
4
+ import { ActionInputParameters } from "../../types";
5
+ import { inputs } from "./inputs";
3
6
  export declare type HttpClient = AxiosInstance;
7
+ interface RetryConfig extends Omit<IAxiosRetryConfig, "retryDelay"> {
8
+ retryDelay?: IAxiosRetryConfig["retryDelay"] | number;
9
+ retryAllErrors?: boolean;
10
+ useExponentialBackoff?: boolean;
11
+ }
4
12
  export interface ClientProps {
5
13
  baseUrl?: string;
6
14
  responseType?: AxiosRequestConfig["responseType"];
7
15
  headers?: AxiosRequestConfig["headers"];
8
16
  timeout?: number;
9
17
  debug?: boolean;
10
- retryConfig?: IAxiosRetryConfig;
18
+ retryConfig?: RetryConfig;
11
19
  }
12
20
  export declare const createClient: ({ baseUrl, responseType, headers, timeout, debug, retryConfig, }: ClientProps) => HttpClient;
13
21
  export declare const handleErrors: (error: unknown) => unknown;
22
+ declare type SendRawRequestValues = ActionInputParameters<typeof inputs>;
23
+ export declare const sendRawRequest: (baseUrl: string, values: SendRawRequestValues, authorizationHeaders?: Record<string, string>) => Promise<AxiosResponse>;
24
+ export declare const buildRawRequestAction: (baseUrl: string, label?: string, description?: string) => import("../..").ActionDefinition<{
25
+ url: {
26
+ label: string;
27
+ placeholder: string;
28
+ type: "string";
29
+ required: true;
30
+ comments: string;
31
+ example: string;
32
+ clean: (value: unknown) => string;
33
+ };
34
+ method: {
35
+ label: string;
36
+ type: "string";
37
+ required: true;
38
+ model: {
39
+ label: import("axios").Method;
40
+ value: import("axios").Method;
41
+ }[];
42
+ comments: string;
43
+ clean: (value: unknown) => string;
44
+ };
45
+ data: {
46
+ label: string;
47
+ placeholder: string;
48
+ type: "string";
49
+ required: false;
50
+ comments: string;
51
+ example: string;
52
+ clean: (value: unknown) => string;
53
+ };
54
+ formData: {
55
+ label: string;
56
+ placeholder: string;
57
+ type: "string";
58
+ collection: "keyvaluelist";
59
+ required: false;
60
+ comments: string;
61
+ example: string;
62
+ };
63
+ fileData: {
64
+ label: string;
65
+ placeholder: string;
66
+ type: "string";
67
+ collection: "keyvaluelist";
68
+ required: false;
69
+ comments: string;
70
+ example: string;
71
+ };
72
+ queryParams: {
73
+ label: string;
74
+ placeholder: string;
75
+ type: "string";
76
+ collection: "keyvaluelist";
77
+ required: false;
78
+ comments: string;
79
+ };
80
+ headers: {
81
+ label: string;
82
+ placeholder: string;
83
+ type: "string";
84
+ collection: "keyvaluelist";
85
+ required: false;
86
+ comments: string;
87
+ example: string;
88
+ };
89
+ responseType: {
90
+ label: string;
91
+ placeholder: string;
92
+ type: "string";
93
+ default: string;
94
+ required: true;
95
+ comments: string;
96
+ model: {
97
+ label: import("axios").ResponseType;
98
+ value: import("axios").ResponseType;
99
+ }[];
100
+ clean: (value: unknown) => import("axios").ResponseType;
101
+ };
102
+ timeout: {
103
+ label: string;
104
+ type: "string";
105
+ required: false;
106
+ comments: string;
107
+ example: string;
108
+ clean: (value: unknown) => number;
109
+ };
110
+ debugRequest: {
111
+ label: string;
112
+ type: "boolean";
113
+ required: false;
114
+ comments: string;
115
+ clean: (value: unknown) => boolean;
116
+ };
117
+ retryDelayMS: {
118
+ label: string;
119
+ placeholder: string;
120
+ type: "string";
121
+ required: false;
122
+ comments: string;
123
+ default: string;
124
+ clean: (value: unknown) => number;
125
+ };
126
+ retryAllErrors: {
127
+ label: string;
128
+ type: "boolean";
129
+ default: string;
130
+ required: false;
131
+ comments: string;
132
+ clean: (value: unknown) => boolean;
133
+ };
134
+ maxRetries: {
135
+ label: string;
136
+ placeholder: string;
137
+ type: "string";
138
+ required: false;
139
+ comments: string;
140
+ default: string;
141
+ clean: (value: unknown) => number;
142
+ };
143
+ useExponentialBackoff: {
144
+ label: string;
145
+ type: "boolean";
146
+ default: string;
147
+ required: false;
148
+ comments: string;
149
+ clean: (value: unknown) => boolean;
150
+ };
151
+ connection: {
152
+ label: string;
153
+ type: "connection";
154
+ required: true;
155
+ };
156
+ }, boolean, {
157
+ data: any;
158
+ }>;
159
+ export { inputs };
@@ -1,12 +1,94 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __rest = (this && this.__rest) || function (s, e) {
35
+ var t = {};
36
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
+ t[p] = s[p];
38
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
+ t[p[i]] = s[p[i]];
42
+ }
43
+ return t;
44
+ };
2
45
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
46
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
47
  };
5
48
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.handleErrors = exports.createClient = void 0;
49
+ exports.inputs = exports.buildRawRequestAction = exports.sendRawRequest = exports.handleErrors = exports.createClient = void 0;
50
+ const lodash_1 = require("lodash");
7
51
  const axios_1 = __importDefault(require("axios"));
8
- const axios_retry_1 = __importDefault(require("axios-retry"));
9
- const util_1 = require("../../util");
52
+ const axios_retry_1 = __importStar(require("axios-retry"));
53
+ const form_data_1 = __importDefault(require("form-data"));
54
+ const __1 = require("../..");
55
+ const util_1 = __importDefault(require("../../util"));
56
+ const inputs_1 = require("./inputs");
57
+ Object.defineProperty(exports, "inputs", { enumerable: true, get: function () { return inputs_1.inputs; } });
58
+ const toAuthorizationHeaders = (connection) => {
59
+ var _a, _b, _c, _d;
60
+ const accessToken = util_1.default.types.toString((_a = connection.token) === null || _a === void 0 ? void 0 : _a.access_token);
61
+ if (accessToken) {
62
+ return { Authorization: `Bearer ${accessToken}` };
63
+ }
64
+ const apiKey = util_1.default.types.toString((_b = connection.fields) === null || _b === void 0 ? void 0 : _b.apiKey);
65
+ if (apiKey) {
66
+ return { Authorization: `Bearer ${apiKey}` };
67
+ }
68
+ const username = util_1.default.types.toString((_c = connection.fields) === null || _c === void 0 ? void 0 : _c.username);
69
+ const password = util_1.default.types.toString((_d = connection.fields) === null || _d === void 0 ? void 0 : _d.password);
70
+ if (username && password) {
71
+ const encoded = Buffer.from(`${username}:${password}`).toString("base64");
72
+ return { Authorization: `Basic ${encoded}` };
73
+ }
74
+ throw new Error(`Failed to guess at authorization parameters for Connection: ${connection.key}`);
75
+ };
76
+ const toFormData = (formData, fileData) => {
77
+ const form = new form_data_1.default();
78
+ (formData || []).map(({ key, value }) => form.append(key, value));
79
+ (fileData || []).map(({ key, value }) => form.append(key, value, { filename: key }));
80
+ return form;
81
+ };
82
+ const computeRetryDelay = (retryDelay, useExponentialBackoff) => {
83
+ if (useExponentialBackoff) {
84
+ return axios_retry_1.exponentialDelay;
85
+ }
86
+ return typeof retryDelay === "number" ? () => retryDelay : retryDelay;
87
+ };
88
+ const toAxiosRetryConfig = (_a) => {
89
+ var { retryDelay, retryAllErrors, retryCondition, useExponentialBackoff } = _a, rest = __rest(_a, ["retryDelay", "retryAllErrors", "retryCondition", "useExponentialBackoff"]);
90
+ return (Object.assign(Object.assign({}, rest), { retryDelay: computeRetryDelay(retryDelay, useExponentialBackoff), retryCondition: retryAllErrors ? () => true : retryCondition }));
91
+ };
10
92
  const createClient = ({ baseUrl, responseType, headers, timeout, debug = false, retryConfig, }) => {
11
93
  const client = axios_1.default.create({
12
94
  baseURL: baseUrl,
@@ -18,17 +100,17 @@ const createClient = ({ baseUrl, responseType, headers, timeout, debug = false,
18
100
  });
19
101
  if (debug) {
20
102
  client.interceptors.request.use((request) => {
21
- console.log((0, util_1.toJSON)(request));
103
+ console.log(util_1.default.types.toJSON(request));
22
104
  return request;
23
105
  });
24
106
  client.interceptors.response.use((response) => {
25
- console.log((0, util_1.toJSON)(response));
107
+ console.log(util_1.default.types.toJSON(response));
26
108
  return response;
27
109
  });
28
110
  }
29
111
  if (retryConfig) {
30
112
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- (0, axios_retry_1.default)(client, retryConfig);
113
+ (0, axios_retry_1.default)(client, toAxiosRetryConfig(retryConfig));
32
114
  }
33
115
  return client;
34
116
  };
@@ -44,3 +126,39 @@ const handleErrors = (error) => {
44
126
  return error;
45
127
  };
46
128
  exports.handleErrors = handleErrors;
129
+ const sendRawRequest = (baseUrl, values, authorizationHeaders = {}) => __awaiter(void 0, void 0, void 0, function* () {
130
+ if (values.data && (!(0, lodash_1.isEmpty)(values.formData) || !(0, lodash_1.isEmpty)(values.fileData))) {
131
+ throw new Error("Cannot specify both Data and File/Form Data.");
132
+ }
133
+ const payload = values.data || toFormData(values.formData, values.fileData);
134
+ const client = (0, exports.createClient)({
135
+ baseUrl,
136
+ debug: values.debugRequest,
137
+ responseType: values.responseType,
138
+ timeout: values.timeout,
139
+ retryConfig: {
140
+ retries: values.maxRetries,
141
+ retryDelay: values.retryDelayMS,
142
+ retryAllErrors: values.retryAllErrors,
143
+ useExponentialBackoff: values.useExponentialBackoff,
144
+ },
145
+ });
146
+ return yield client.request({
147
+ method: values.method,
148
+ url: values.url,
149
+ headers: Object.assign(Object.assign(Object.assign({}, util_1.default.types.keyValPairListToObject(values.headers)), (payload instanceof form_data_1.default ? payload.getHeaders() : {})), authorizationHeaders),
150
+ params: util_1.default.types.keyValPairListToObject(values.queryParams),
151
+ data: payload,
152
+ });
153
+ });
154
+ exports.sendRawRequest = sendRawRequest;
155
+ const buildRawRequestAction = (baseUrl, label = "Raw Request", description = "Issue a raw HTTP request") => (0, __1.action)({
156
+ display: { label, description },
157
+ inputs: Object.assign({ connection: { label: "Connection", type: "connection", required: true } }, inputs_1.inputs),
158
+ perform: (context, _a) => __awaiter(void 0, void 0, void 0, function* () {
159
+ var { connection } = _a, httpInputValues = __rest(_a, ["connection"]);
160
+ const { data } = yield (0, exports.sendRawRequest)(baseUrl, httpInputValues, toAuthorizationHeaders(connection));
161
+ return { data };
162
+ }),
163
+ });
164
+ exports.buildRawRequestAction = buildRawRequestAction;
@@ -28,6 +28,7 @@ export declare const timeout: {
28
28
  export declare const method: {
29
29
  label: string;
30
30
  type: "string";
31
+ required: true;
31
32
  model: {
32
33
  label: Method;
33
34
  value: Method;
@@ -40,13 +41,13 @@ export declare const responseType: {
40
41
  placeholder: string;
41
42
  type: "string";
42
43
  default: string;
43
- required: false;
44
+ required: true;
44
45
  comments: string;
45
46
  model: {
46
47
  label: ResponseType;
47
48
  value: ResponseType;
48
49
  }[];
49
- clean: (value: unknown) => string;
50
+ clean: (value: unknown) => ResponseType;
50
51
  };
51
52
  export declare const headers: {
52
53
  label: string;
@@ -81,6 +82,7 @@ export declare const retryDelayMS: {
81
82
  required: false;
82
83
  comments: string;
83
84
  default: string;
85
+ clean: (value: unknown) => number;
84
86
  };
85
87
  export declare const useExponentialBackoff: {
86
88
  label: string;
@@ -90,7 +92,7 @@ export declare const useExponentialBackoff: {
90
92
  comments: string;
91
93
  clean: (value: unknown) => boolean;
92
94
  };
93
- export declare const retryOnAllErrors: {
95
+ export declare const retryAllErrors: {
94
96
  label: string;
95
97
  type: "boolean";
96
98
  default: string;
@@ -123,3 +125,131 @@ export declare const debugRequest: {
123
125
  comments: string;
124
126
  clean: (value: unknown) => boolean;
125
127
  };
128
+ export declare const inputs: {
129
+ url: {
130
+ label: string;
131
+ placeholder: string;
132
+ type: "string";
133
+ required: true;
134
+ comments: string;
135
+ example: string;
136
+ clean: (value: unknown) => string;
137
+ };
138
+ method: {
139
+ label: string;
140
+ type: "string";
141
+ required: true;
142
+ model: {
143
+ label: Method;
144
+ value: Method;
145
+ }[];
146
+ comments: string;
147
+ clean: (value: unknown) => string;
148
+ };
149
+ data: {
150
+ label: string;
151
+ placeholder: string;
152
+ type: "string";
153
+ required: false;
154
+ comments: string;
155
+ example: string;
156
+ clean: (value: unknown) => string;
157
+ };
158
+ formData: {
159
+ label: string;
160
+ placeholder: string;
161
+ type: "string";
162
+ collection: "keyvaluelist";
163
+ required: false;
164
+ comments: string;
165
+ example: string;
166
+ };
167
+ fileData: {
168
+ label: string;
169
+ placeholder: string;
170
+ type: "string";
171
+ collection: "keyvaluelist";
172
+ required: false;
173
+ comments: string;
174
+ example: string;
175
+ };
176
+ queryParams: {
177
+ label: string;
178
+ placeholder: string;
179
+ type: "string";
180
+ collection: "keyvaluelist";
181
+ required: false;
182
+ comments: string;
183
+ };
184
+ headers: {
185
+ label: string;
186
+ placeholder: string;
187
+ type: "string";
188
+ collection: "keyvaluelist";
189
+ required: false;
190
+ comments: string;
191
+ example: string;
192
+ };
193
+ responseType: {
194
+ label: string;
195
+ placeholder: string;
196
+ type: "string";
197
+ default: string;
198
+ required: true;
199
+ comments: string;
200
+ model: {
201
+ label: ResponseType;
202
+ value: ResponseType;
203
+ }[];
204
+ clean: (value: unknown) => ResponseType;
205
+ };
206
+ timeout: {
207
+ label: string;
208
+ type: "string";
209
+ required: false;
210
+ comments: string;
211
+ example: string;
212
+ clean: (value: unknown) => number;
213
+ };
214
+ debugRequest: {
215
+ label: string;
216
+ type: "boolean";
217
+ required: false;
218
+ comments: string;
219
+ clean: (value: unknown) => boolean;
220
+ };
221
+ retryDelayMS: {
222
+ label: string;
223
+ placeholder: string;
224
+ type: "string";
225
+ required: false;
226
+ comments: string;
227
+ default: string;
228
+ clean: (value: unknown) => number;
229
+ };
230
+ retryAllErrors: {
231
+ label: string;
232
+ type: "boolean";
233
+ default: string;
234
+ required: false;
235
+ comments: string;
236
+ clean: (value: unknown) => boolean;
237
+ };
238
+ maxRetries: {
239
+ label: string;
240
+ placeholder: string;
241
+ type: "string";
242
+ required: false;
243
+ comments: string;
244
+ default: string;
245
+ clean: (value: unknown) => number;
246
+ };
247
+ useExponentialBackoff: {
248
+ label: string;
249
+ type: "boolean";
250
+ default: string;
251
+ required: false;
252
+ comments: string;
253
+ clean: (value: unknown) => boolean;
254
+ };
255
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
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;
3
+ exports.inputs = exports.debugRequest = exports.fileData = exports.formData = exports.retryAllErrors = exports.useExponentialBackoff = exports.retryDelayMS = exports.maxRetries = exports.queryParams = exports.headers = exports.responseType = exports.method = exports.timeout = exports.data = exports.url = void 0;
4
4
  const __1 = require("../..");
5
5
  const supportedMethods = [
6
6
  "DELETE",
@@ -49,6 +49,7 @@ exports.timeout = (0, __1.input)({
49
49
  exports.method = (0, __1.input)({
50
50
  label: "Method",
51
51
  type: "string",
52
+ required: true,
52
53
  model: supportedMethods.map((method) => ({ label: method, value: method })),
53
54
  comments: "The HTTP method to use.",
54
55
  clean: (value) => __1.util.types.toString(value),
@@ -58,7 +59,7 @@ exports.responseType = (0, __1.input)({
58
59
  placeholder: "Response Type",
59
60
  type: "string",
60
61
  default: "json",
61
- required: false,
62
+ required: true,
62
63
  comments: "The type of data you expect in the response. You can request json, text, or binary data.",
63
64
  model: supportedResponseTypes.map((responseType) => ({
64
65
  label: responseType,
@@ -99,6 +100,7 @@ exports.retryDelayMS = (0, __1.input)({
99
100
  required: false,
100
101
  comments: "The delay in milliseconds between retries.",
101
102
  default: "0",
103
+ clean: (value) => __1.util.types.toNumber(value, 0),
102
104
  });
103
105
  exports.useExponentialBackoff = (0, __1.input)({
104
106
  label: "Use Exponential Backoff",
@@ -108,7 +110,7 @@ exports.useExponentialBackoff = (0, __1.input)({
108
110
  comments: "Specifies whether to use a pre-defined exponential backoff strategy for retries.",
109
111
  clean: (value) => __1.util.types.toBool(value),
110
112
  });
111
- exports.retryOnAllErrors = (0, __1.input)({
113
+ exports.retryAllErrors = (0, __1.input)({
112
114
  label: "Retry On All Errors",
113
115
  type: "boolean",
114
116
  default: "false",
@@ -141,3 +143,19 @@ exports.debugRequest = (0, __1.input)({
141
143
  comments: "Enabling this flag will log out the current request.",
142
144
  clean: (value) => __1.util.types.toBool(value),
143
145
  });
146
+ exports.inputs = {
147
+ url: exports.url,
148
+ method: exports.method,
149
+ data: exports.data,
150
+ formData: exports.formData,
151
+ fileData: exports.fileData,
152
+ queryParams: exports.queryParams,
153
+ headers: exports.headers,
154
+ responseType: exports.responseType,
155
+ timeout: exports.timeout,
156
+ debugRequest: exports.debugRequest,
157
+ retryDelayMS: exports.retryDelayMS,
158
+ retryAllErrors: exports.retryAllErrors,
159
+ maxRetries: exports.maxRetries,
160
+ useExponentialBackoff: exports.useExponentialBackoff,
161
+ };
@@ -8,10 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.createPerform = void 0;
13
16
  const serialize_error_1 = require("serialize-error");
14
- const util_1 = require("../util");
17
+ const util_1 = __importDefault(require("../util"));
15
18
  const cleanParams = (params, cleaners) => Object.entries(params).reduce((result, [key, value]) => {
16
19
  const cleanFn = cleaners[key];
17
20
  return Object.assign(Object.assign({}, result), { [key]: cleanFn ? cleanFn(value) : value });
@@ -31,7 +34,7 @@ const createPerform = (performFn, { inputCleaners, errorHandler }) => {
31
34
  throw error;
32
35
  }
33
36
  const handled = errorHandler(error);
34
- const serialized = (0, util_1.toJSON)((0, serialize_error_1.serializeError)(handled));
37
+ const serialized = util_1.default.types.toJSON((0, serialize_error_1.serializeError)(handled));
35
38
  throw new Error(serialized);
36
39
  }
37
40
  });
package/dist/util.d.ts CHANGED
@@ -4,12 +4,6 @@
4
4
  * For example, `util.types.toInt("5.5")` will return an integer, `5`.
5
5
  */
6
6
  import { KeyValuePair, DataPayload } from "./types";
7
- /** This function accepts an arbitrary object/value and safely serializes it (handles cyclic references).
8
- *
9
- * @param value Arbitrary object/value to serialize.
10
- * @returns JSON serialized text that can be safely logged.
11
- */
12
- export declare const toJSON: (value: unknown) => string;
13
7
  /**
14
8
  * This function returns a lower cased version of the headers passed to it.
15
9
  *
@@ -38,7 +32,7 @@ declare const _default: {
38
32
  isData: (value: unknown) => boolean;
39
33
  toData: (value: unknown) => DataPayload;
40
34
  toString: (value: unknown, defaultValue?: string) => string;
41
- keyValPairListToObject: <TValue = unknown>(kvpList?: KeyValuePair<unknown>[], valueConverter?: ((value: unknown) => TValue) | undefined) => Record<string, TValue>;
35
+ keyValPairListToObject: <TValue = unknown>(kvpList: KeyValuePair<unknown>[], valueConverter?: ((value: unknown) => TValue) | undefined) => Record<string, TValue>;
42
36
  isJSON: (value: string) => boolean;
43
37
  toJSON: (value: unknown) => string;
44
38
  lowerCaseHeaders: (headers: Record<string, string>) => Record<string, string>;
package/dist/util.js CHANGED
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.lowerCaseHeaders = exports.toJSON = void 0;
11
+ exports.lowerCaseHeaders = void 0;
12
12
  /** */
13
13
  const parseISO_1 = __importDefault(require("date-fns/parseISO"));
14
14
  const isValid_1 = __importDefault(require("date-fns/isValid"));
@@ -197,8 +197,8 @@ const isUrl = (value) => (0, valid_url_1.isWebUri)(value) !== undefined;
197
197
  * @param kvpList An array of objects with `key` and `value` properties.
198
198
  * @param valueConverter Optional function to call for each `value`.
199
199
  */
200
- const keyValPairListToObject = (kvpList = [], valueConverter) => {
201
- return kvpList.reduce((result, { key, value }) => (Object.assign(Object.assign({}, result), { [key]: valueConverter ? valueConverter(value) : value })), {});
200
+ const keyValPairListToObject = (kvpList, valueConverter) => {
201
+ return (kvpList || []).reduce((result, { key, value }) => (Object.assign(Object.assign({}, result), { [key]: valueConverter ? valueConverter(value) : value })), {});
202
202
  };
203
203
  /**
204
204
  * This function tests if the object provided is a Prismatic `DataPayload` object.
@@ -322,7 +322,6 @@ const toJSON = (value) => {
322
322
  const stringify = (0, safe_stable_stringify_1.configure)({ circularValue: undefined });
323
323
  return stringify(value, null, 2);
324
324
  };
325
- exports.toJSON = toJSON;
326
325
  /**
327
326
  * This function returns a lower cased version of the headers passed to it.
328
327
  *
@@ -356,7 +355,7 @@ exports.default = {
356
355
  toString,
357
356
  keyValPairListToObject,
358
357
  isJSON,
359
- toJSON: exports.toJSON,
358
+ toJSON,
360
359
  lowerCaseHeaders: exports.lowerCaseHeaders,
361
360
  },
362
361
  docs: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "6.5.0",
3
+ "version": "6.5.1",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"
@@ -37,9 +37,10 @@
37
37
  "dist/"
38
38
  ],
39
39
  "dependencies": {
40
- "axios": "0.26.1",
41
- "axios-retry": "3.2.4",
40
+ "axios": "0.27.2",
41
+ "axios-retry": "3.2.5",
42
42
  "date-fns": "2.28.0",
43
+ "form-data": "4.0.0",
43
44
  "jest-mock": "27.0.3",
44
45
  "soap": "0.43.0",
45
46
  "uuid": "8.3.2",