@prismatic-io/spectral 7.1.0 → 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.
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.
@@ -504,8 +503,6 @@ exports.default = {
504
503
  isPicklist,
505
504
  isSchedule,
506
505
  isConnection,
507
- },
508
- docs: {
509
- formatJsonExample,
506
+ isElement,
510
507
  },
511
508
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"