@prismatic-io/spectral 7.0.16-pre → 7.2.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.
@@ -50,7 +50,6 @@ export declare const buildRawRequestAction: (baseUrl: string, label?: string, de
50
50
  required: false;
51
51
  comments: string;
52
52
  example: string;
53
- clean: (value: unknown) => string;
54
53
  };
55
54
  formData: {
56
55
  label: string;
@@ -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. Must be a string or a reference to output from a previous step.",
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/index.d.ts CHANGED
@@ -47,7 +47,7 @@ export declare const dataSource: <TInputs extends Inputs, TDataSourceType extend
47
47
  string: string;
48
48
  date: string;
49
49
  timestamp: string;
50
- picklist: string[];
50
+ picklist: string[] | import("./types").Element[];
51
51
  schedule: {
52
52
  value: string;
53
53
  };
package/dist/testing.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare const invokeDataSource: <TInputs extends Inputs, TDataSourceType
43
43
  string: string;
44
44
  date: string;
45
45
  timestamp: string;
46
- picklist: string[];
46
+ picklist: string[] | import("./types").Element[];
47
47
  schedule: {
48
48
  value: string;
49
49
  };
@@ -76,7 +76,7 @@ declare const _default: {
76
76
  string: string;
77
77
  date: string;
78
78
  timestamp: string;
79
- picklist: string[];
79
+ picklist: string[] | import("./types").Element[];
80
80
  schedule: {
81
81
  value: string;
82
82
  };
@@ -1,11 +1,11 @@
1
1
  import { ConnectionDefinition } from "./ConnectionDefinition";
2
- import { ObjectSelection, ObjectFieldMap, JSONForm } from "./Inputs";
2
+ import { ObjectSelection, ObjectFieldMap, JSONForm, Element } from "./Inputs";
3
3
  /** The type of field that is appropriate for rendering the data that is the result of the data source perform function. */
4
4
  declare type DataSourceTypeMap = {
5
5
  string: string;
6
6
  date: string;
7
7
  timestamp: string;
8
- picklist: string[];
8
+ picklist: string[] | Element[];
9
9
  schedule: {
10
10
  value: string;
11
11
  };
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, ConnectionDefinition } from "./types";
6
+ import { KeyValuePair, DataPayload, ObjectSelection, ObjectFieldMap, JSONForm, ConnectionDefinition, Element } from "./types";
7
7
  /**
8
8
  * This function returns a lower cased version of the headers passed to it.
9
9
  *
@@ -46,9 +46,7 @@ declare const _default: {
46
46
  isPicklist: (value: unknown) => boolean;
47
47
  isSchedule: (value: unknown) => boolean;
48
48
  isConnection: (value: unknown) => value is ConnectionDefinition;
49
- };
50
- docs: {
51
- formatJsonExample: (input: unknown) => string;
49
+ isElement: (value: unknown) => value is Element;
52
50
  };
53
51
  };
54
52
  export default _default;
package/dist/util.js CHANGED
@@ -20,6 +20,13 @@ const isObjectWithTruthyKeys = (value, keys) => {
20
20
  typeof value === "object" &&
21
21
  keys.every((key) => key in value && Boolean(value === null || value === void 0 ? void 0 : value[key])));
22
22
  };
23
+ /**
24
+ * This function checks if value is an Element.
25
+ * `util.types.isElement({key: "foo"})` and `util.types.isElement({key: "foo", label: "Foo"})` return true.
26
+ * @param value The variable to test.
27
+ * @returns This function returns true or false, depending on if `value` is an Element.
28
+ */
29
+ const isElement = (value) => isObjectWithTruthyKeys(value, ["key"]);
23
30
  /**
24
31
  * @param value The value to test
25
32
  * @returns This function returns true if the type of `value` is an ObjectSelection, or false otherwise.
@@ -57,9 +64,7 @@ const isObjectFieldMap = (value) => {
57
64
  const { fields } = value;
58
65
  return (Array.isArray(fields) &&
59
66
  fields.every((item) => isObjectWithTruthyKeys(item, ["field"]) &&
60
- isObjectWithTruthyKeys(item === null || item === void 0 ? void 0 : item.field, [
61
- "key",
62
- ])));
67
+ isElement(item === null || item === void 0 ? void 0 : item.field)));
63
68
  }
64
69
  return false;
65
70
  };
@@ -281,7 +286,7 @@ const isUrl = (value) => (0, valid_url_1.isWebUri)(value) !== undefined;
281
286
  * @param value The variable to test.
282
287
  * @returns This function returns true if `value` is a valid picklist.
283
288
  */
284
- const isPicklist = (value) => Array.isArray(value) && value.every(isString);
289
+ const isPicklist = (value) => Array.isArray(value) && (value.every(isString) || value.every(isElement));
285
290
  /**
286
291
  * This function checks if value is a valid schedule.
287
292
  *
@@ -379,12 +384,6 @@ const isData = (value) => isBufferDataPayload(value);
379
384
  * @returns This function returns an object with two keys: `data`, which is a `Buffer`, and `contentType`, which is a string.
380
385
  */
381
386
  const toData = (value) => toBufferDataPayload(value);
382
- /**
383
- * This function helps to format JSON examples for documentation.
384
- * @param input An object to be JSONified.
385
- * @returns This function returns a code block that can be used for documentation.
386
- */
387
- const formatJsonExample = (input) => ["```json", JSON.stringify(input, undefined, 2), "```"].join("\n");
388
387
  /**
389
388
  * This function checks if value is a string.
390
389
  * `util.types.isString("value")` and `util.types.isString(new String("value"))` return true.
@@ -420,16 +419,10 @@ const isConnection = (value) => {
420
419
  return (isObjectWithTruthyKeys(inputs, [
421
420
  "authorizeUrl",
422
421
  "tokenUrl",
423
- "scopes",
424
422
  "clientId",
425
423
  "clientSecret",
426
424
  ]) ||
427
- isObjectWithTruthyKeys(inputs, [
428
- "tokenUrl",
429
- "scopes",
430
- "clientId",
431
- "clientSecret",
432
- ]));
425
+ isObjectWithTruthyKeys(inputs, ["tokenUrl", "clientId", "clientSecret"]));
433
426
  }
434
427
  return (isObjectWithTruthyKeys(value, ["key", "label"]) &&
435
428
  typeof inputs === "object");
@@ -510,8 +503,6 @@ exports.default = {
510
503
  isPicklist,
511
504
  isSchedule,
512
505
  isConnection,
513
- },
514
- docs: {
515
- formatJsonExample,
506
+ isElement,
516
507
  },
517
508
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "7.0.16-pre",
3
+ "version": "7.2.0",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"