@prismatic-io/spectral 6.5.2 → 6.6.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.
@@ -47,6 +47,18 @@ export interface ActionContext {
47
47
  executionState: Record<string, unknown>;
48
48
  stepId: string;
49
49
  executionId: string;
50
+ webhookUrls: Record<string, string>;
51
+ webhookApiKeys: Record<string, string[]>;
52
+ invokeUrl: string;
53
+ customer: {
54
+ id: string | null;
55
+ externalId: string | null;
56
+ name: string | null;
57
+ };
58
+ instance: {
59
+ id: string | null;
60
+ name: string | null;
61
+ };
50
62
  }
51
63
  declare type TriggerOptionChoice = "invalid" | "valid" | "required";
52
64
  export interface TriggerPayload {
package/dist/testing.js CHANGED
@@ -44,7 +44,18 @@ exports.loggerMock = loggerMock;
44
44
  * action result and a mock logger for asserting logging.
45
45
  */
46
46
  const invoke = ({ perform }, params, context) => __awaiter(void 0, void 0, void 0, function* () {
47
- const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
47
+ const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
48
+ "Flow 1": "https://example.com",
49
+ }, webhookApiKeys: {
50
+ "Flow 1": ["example-123", "example-456"],
51
+ }, invokeUrl: "https://example.com", customer: {
52
+ id: "customerId",
53
+ name: "Customer 1",
54
+ externalId: "1234",
55
+ }, instance: {
56
+ id: "instanceId",
57
+ name: "Instance 1",
58
+ } }, context);
48
59
  const result = yield perform(realizedContext, params);
49
60
  return {
50
61
  result,
@@ -96,7 +107,18 @@ exports.defaultTriggerPayload = defaultTriggerPayload;
96
107
  * trigger result and a mock logger for asserting logging.
97
108
  */
98
109
  const invokeTrigger = ({ perform }, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
99
- const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
110
+ const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
111
+ "Flow 1": "https://example.com",
112
+ }, webhookApiKeys: {
113
+ "Flow 1": ["example-123", "example-456"],
114
+ }, invokeUrl: "https://example.com", customer: {
115
+ id: "customerId",
116
+ name: "Customer 1",
117
+ externalId: "1234",
118
+ }, instance: {
119
+ id: "instanceId",
120
+ name: "Instance 1",
121
+ } }, context);
100
122
  const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
101
123
  const realizedParams = params || {};
102
124
  const result = yield perform(realizedContext, realizedPayload, realizedParams);
@@ -120,14 +142,36 @@ class ComponentTestHarness {
120
142
  }
121
143
  trigger(key, payload, params, context) {
122
144
  return __awaiter(this, void 0, void 0, function* () {
123
- const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
145
+ const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
146
+ "Flow 1": "https://example.com",
147
+ }, webhookApiKeys: {
148
+ "Flow 1": ["example-123", "example-456"],
149
+ }, invokeUrl: "https://example.com", customer: {
150
+ id: "customerId",
151
+ name: "Customer 1",
152
+ externalId: "1234",
153
+ }, instance: {
154
+ id: "instanceId",
155
+ name: "Instance 1",
156
+ } }, context);
124
157
  const trigger = this.component.triggers[key];
125
158
  return trigger.perform(realizedContext, Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), Object.assign({}, params));
126
159
  });
127
160
  }
128
161
  action(key, params, context) {
129
162
  return __awaiter(this, void 0, void 0, function* () {
130
- const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
163
+ const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId", webhookUrls: {
164
+ "Flow 1": "https://example.com",
165
+ }, webhookApiKeys: {
166
+ "Flow 1": ["example-123", "example-456"],
167
+ }, invokeUrl: "https://example.com", customer: {
168
+ id: "customerId",
169
+ name: "Customer 1",
170
+ externalId: "1234",
171
+ }, instance: {
172
+ id: "instanceId",
173
+ name: "Instance 1",
174
+ } }, context);
131
175
  const action = this.component.actions[key];
132
176
  return action.perform(realizedContext, Object.assign({}, params));
133
177
  });
@@ -15,4 +15,21 @@ export interface ActionContext {
15
15
  stepId: string;
16
16
  /** A unique id that corresponds to the specific execution of the Integration */
17
17
  executionId: string;
18
+ /** An object containing webhook URLs for all flows of the currently running instance */
19
+ webhookUrls: Record<string, string>;
20
+ /** An object containing webhook API keys for all flows of the currently running instance */
21
+ webhookApiKeys: Record<string, string[]>;
22
+ /** The URL used to invoke the current execution */
23
+ invokeUrl: string;
24
+ /** An object containing the ID, External ID and name of the customer the instance is deployed to */
25
+ customer: {
26
+ id: string | null;
27
+ externalId: string | null;
28
+ name: string | null;
29
+ };
30
+ /** An object containing the ID ad name of the currently running instance */
31
+ instance: {
32
+ id: string | null;
33
+ name: string | null;
34
+ };
18
35
  }
package/dist/util.js CHANGED
@@ -26,16 +26,16 @@ const valid_url_1 = require("valid-url");
26
26
  */
27
27
  const isBool = (value) => value === true || value === false;
28
28
  /**
29
- * Convert truthey (true, "t", "true", "y", "yes") values to boolean `true`,
30
- * and falsey (false, "f", "false", "n", "no") values to boolean `false`.
31
- * Truthy/falsey checks are case-insensitive.
29
+ * Convert truthy (true, "t", "true", "y", "yes") values to boolean `true`,
30
+ * and falsy (false, "f", "false", "n", "no") values to boolean `false`.
31
+ * Truthy/falsy checks are case-insensitive.
32
32
  *
33
33
  * In the event that `value` is undefined or an empty string, a default value can be provided.
34
34
  * For example, `util.types.toBool('', true)` will return `true`.
35
35
  *
36
36
  * @param value The value to convert to a boolean.
37
37
  * @param defaultValue The value to return if `value` is undefined or an empty string.
38
- * @returns The boolean equivalent of the truthey or falsey `value`.
38
+ * @returns The boolean equivalent of the truthy or falsy `value`.
39
39
  */
40
40
  const toBool = (value, defaultValue) => {
41
41
  if (isBool(value)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "6.5.2",
3
+ "version": "6.6.0",
4
4
  "description": "Utility library for building Prismatic components",
5
5
  "keywords": [
6
6
  "prismatic"
@@ -29,7 +29,7 @@
29
29
  "check": "yarn run check-format && yarn run lint",
30
30
  "lint": "eslint --ext .ts .",
31
31
  "lint-fix": "eslint --fix --ext .ts .",
32
- "test": "jest --maxWorkers=4",
32
+ "test": "jest",
33
33
  "tsd": "tsd",
34
34
  "docs": "rm -f sidebars.{js,jse} && typedoc"
35
35
  },