@prismatic-io/spectral 5.2.1 → 5.4.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.
package/dist/index.js CHANGED
@@ -14,12 +14,34 @@ 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, label, collection } = _a, rest = __rest(_a, ["default", "type", "label", "collection"]);
40
+ return (Object.assign(Object.assign({}, rest), { key,
41
+ type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], collection, label: typeof label === "string" ? label : label.value, keyLabel: collection === "keyvaluelist" && typeof label === "object"
42
+ ? label.key
43
+ : undefined }));
44
+ };
23
45
  /**
24
46
  * This is a helper function for component() to convert an
25
47
  * action defined in TypeScript into an action object that
package/dist/testing.js CHANGED
@@ -75,10 +75,17 @@ const defaultTriggerPayload = () => {
75
75
  webhookApiKeys: {
76
76
  "Flow 1": ["example-123", "example-456"],
77
77
  },
78
+ invokeUrl: "https://example.com",
79
+ executionId: "executionId",
78
80
  customer: {
81
+ id: "customerId",
79
82
  name: "Customer 1",
80
83
  externalId: "1234",
81
84
  },
85
+ instance: {
86
+ id: "instanceId",
87
+ name: "Instance 1",
88
+ },
82
89
  };
83
90
  };
84
91
  exports.defaultTriggerPayload = defaultTriggerPayload;
@@ -18,4 +18,4 @@ export interface ActionPerformBranchingDataReturn<ReturnData> extends ActionPerf
18
18
  branch: string;
19
19
  }
20
20
  /** Required return type of all action perform functions */
21
- export declare type ActionPerformReturn<AllowsBranching extends boolean, ReturnData extends unknown> = (AllowsBranching extends true ? ActionPerformBranchingDataReturn<ReturnData> : ActionPerformDataReturn<ReturnData>) | undefined;
21
+ export declare type ActionPerformReturn<AllowsBranching extends boolean, ReturnData> = (AllowsBranching extends true ? ActionPerformBranchingDataReturn<ReturnData> : ActionPerformDataReturn<ReturnData>) | undefined;
@@ -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,18 +1,23 @@
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
- label: string;
11
+ label: {
12
+ key: string;
13
+ value: string;
14
+ } | string;
10
15
  /** Collection type of the InputField */
11
16
  collection?: InputFieldCollection;
12
17
  /** Text to show as the InputField placeholder. */
13
18
  placeholder?: string;
14
19
  /** Default value for this field. */
15
- default?: string;
20
+ default?: typeof InputFieldDefaultMap[this["type"]];
16
21
  /** Additional text to give guidance to the user configuring the InputField. */
17
22
  comments?: string;
18
23
  /** Example valid input for this InputField. */
@@ -22,8 +22,16 @@ export interface TriggerPayload {
22
22
  webhookApiKeys: {
23
23
  [key: string]: string[];
24
24
  };
25
+ /** The URL that was used to invoke the execution. */
26
+ invokeUrl: string;
27
+ executionId: string;
25
28
  customer: {
29
+ id: string | null;
26
30
  externalId: string | null;
27
31
  name: string | null;
28
32
  };
33
+ instance: {
34
+ id: string | null;
35
+ name: string | null;
36
+ };
29
37
  }
@@ -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";
@@ -139,6 +139,8 @@ interface DefaultInputField {
139
139
  key: string;
140
140
  /** Interface label of the InputField. */
141
141
  label: string;
142
+ /** Interface label of the Key if the InputField is a 'keyvaluelist'. */
143
+ keyLabel?: string;
142
144
  /** Data type the InputField will collect. */
143
145
  type: InputFieldType;
144
146
  /** Collection type of the InputField */
@@ -146,7 +148,7 @@ interface DefaultInputField {
146
148
  /** Text to show as the InputField placeholder. */
147
149
  placeholder?: string;
148
150
  /** Default value for this field. */
149
- default?: string;
151
+ default?: typeof InputFieldDefaultMap[this["type"]];
150
152
  /** Additional text to give guidance to the user configuring the InputField. */
151
153
  comments?: string;
152
154
  /** Example valid input for this InputField. */
@@ -160,8 +162,6 @@ interface CodeInputField extends DefaultInputField {
160
162
  type: "code";
161
163
  language?: string;
162
164
  }
163
- /** InputField type enumeration. */
164
- export declare type InputFieldType = "string" | "text" | "password" | "boolean" | "code" | "data" | "conditional" | "connection";
165
165
  /** Binary data payload */
166
166
  export interface DataPayload {
167
167
  /** 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.4.1",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"
@@ -15,6 +15,10 @@
15
15
  "type": "git",
16
16
  "url": "https://github.com/prismatic-io/spectral.git"
17
17
  },
18
+ "publishConfig": {
19
+ "access": "public",
20
+ "registry": "https://registry.npmjs.org/"
21
+ },
18
22
  "license": "MIT",
19
23
  "scripts": {
20
24
  "clean": "rm -rf dist",
@@ -73,14 +77,15 @@
73
77
  ]
74
78
  },
75
79
  "plugins": [
76
- "@typescript-eslint"
80
+ "@typescript-eslint",
81
+ "prettier"
77
82
  ],
78
83
  "extends": [
79
84
  "eslint:recommended",
80
85
  "plugin:@typescript-eslint/eslint-recommended",
81
86
  "plugin:@typescript-eslint/recommended",
82
87
  "plugin:@typescript-eslint/recommended-requiring-type-checking",
83
- "prettier"
88
+ "plugin:prettier/recommended"
84
89
  ],
85
90
  "rules": {
86
91
  "@typescript-eslint/explicit-function-return-type": "off",