@prismatic-io/spectral 5.2.1 → 5.3.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.js CHANGED
@@ -14,12 +14,31 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
14
14
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
16
  };
17
+ var __rest = (this && this.__rest) || function (s, e) {
18
+ var t = {};
19
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
+ t[p] = s[p];
21
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
+ t[p[i]] = s[p[i]];
25
+ }
26
+ return t;
27
+ };
17
28
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
30
  };
20
31
  Object.defineProperty(exports, "__esModule", { value: true });
21
32
  exports.testing = exports.util = exports.oauth2Connection = exports.connection = exports.input = exports.trigger = exports.action = exports.component = void 0;
22
- const convertInput = (key, input) => (Object.assign(Object.assign({}, input), { key }));
33
+ /**
34
+ * Both component author-facing types and server types that
35
+ * the Prismatic API expects are imported here.
36
+ */
37
+ const types_1 = require("./types");
38
+ const convertInput = (key, _a) => {
39
+ var { default: defaultValue, type } = _a, rest = __rest(_a, ["default", "type"]);
40
+ return (Object.assign(Object.assign({}, rest), { type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], key }));
41
+ };
23
42
  /**
24
43
  * This is a helper function for component() to convert an
25
44
  * action defined in TypeScript into an action object that
@@ -12,3 +12,4 @@ export declare type InputFieldTypeMap = {
12
12
  conditional: ConditionalExpression;
13
13
  connection: Connection;
14
14
  };
15
+ export declare const InputFieldDefaultMap: Record<InputFieldType, string | undefined>;
@@ -1,2 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputFieldDefaultMap = void 0;
4
+ exports.InputFieldDefaultMap = {
5
+ string: "",
6
+ data: "",
7
+ text: "",
8
+ password: "",
9
+ boolean: "false",
10
+ code: "",
11
+ conditional: undefined,
12
+ connection: undefined,
13
+ };
@@ -1,10 +1,12 @@
1
- import { InputFieldType } from ".";
1
+ import { InputFieldDefaultMap, InputFieldType } from ".";
2
2
  export declare type Inputs = Record<string, InputFieldDefinition>;
3
3
  export declare type ConnectionInput = DefaultInputFieldDefinition & {
4
4
  shown?: boolean;
5
5
  };
6
6
  export declare type InputFieldDefinition = DefaultInputFieldDefinition | CodeInputFieldDefinition | ConditionalInputField | ConnectionInputField;
7
7
  interface BaseInputFieldDefinition {
8
+ /** Data type the InputField will collect. */
9
+ type: InputFieldType;
8
10
  /** Interface label of the InputField. */
9
11
  label: string;
10
12
  /** Collection type of the InputField */
@@ -12,7 +14,7 @@ interface BaseInputFieldDefinition {
12
14
  /** Text to show as the InputField placeholder. */
13
15
  placeholder?: string;
14
16
  /** Default value for this field. */
15
- default?: string;
17
+ default?: typeof InputFieldDefaultMap[this["type"]];
16
18
  /** Additional text to give guidance to the user configuring the InputField. */
17
19
  comments?: string;
18
20
  /** Example valid input for this InputField. */
@@ -6,7 +6,7 @@
6
6
  */
7
7
  /// <reference types="node" />
8
8
  /** Import shared types from types/ */
9
- import { OAuth2Type } from ".";
9
+ import { OAuth2Type, InputFieldType, InputFieldDefaultMap } from ".";
10
10
  import { ActionContext } from "./ActionPerformFunction";
11
11
  import { ActionDisplayDefinition, ComponentDisplayDefinition } from "./DisplayDefinition";
12
12
  import { InputFieldChoice, InputFieldCollection } from "./Inputs";
@@ -146,7 +146,7 @@ interface DefaultInputField {
146
146
  /** Text to show as the InputField placeholder. */
147
147
  placeholder?: string;
148
148
  /** Default value for this field. */
149
- default?: string;
149
+ default?: typeof InputFieldDefaultMap[this["type"]];
150
150
  /** Additional text to give guidance to the user configuring the InputField. */
151
151
  comments?: string;
152
152
  /** Example valid input for this InputField. */
@@ -160,8 +160,6 @@ interface CodeInputField extends DefaultInputField {
160
160
  type: "code";
161
161
  language?: string;
162
162
  }
163
- /** InputField type enumeration. */
164
- export declare type InputFieldType = "string" | "text" | "password" | "boolean" | "code" | "data" | "conditional" | "connection";
165
163
  /** Binary data payload */
166
164
  export interface DataPayload {
167
165
  /** Raw binary data as a Buffer */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "5.2.1",
3
+ "version": "5.3.0",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"