@prismatic-io/spectral 10.4.4 → 10.5.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.
Files changed (38) hide show
  1. package/dist/clients/http/index.d.ts +37 -0
  2. package/dist/clients/http/index.js +24 -0
  3. package/dist/generators/componentManifest/getInputs.js +1 -0
  4. package/dist/index.d.ts +71 -36
  5. package/dist/index.js +68 -33
  6. package/dist/serverTypes/convertComponent.d.ts +2 -1
  7. package/dist/serverTypes/convertComponent.js +12 -2
  8. package/dist/serverTypes/convertIntegration.js +17 -6
  9. package/dist/serverTypes/index.d.ts +2 -0
  10. package/dist/serverTypes/integration.d.ts +0 -1
  11. package/dist/testing.d.ts +42 -4
  12. package/dist/testing.js +42 -4
  13. package/dist/types/ActionDefinition.d.ts +21 -10
  14. package/dist/types/ActionLogger.d.ts +3 -2
  15. package/dist/types/ActionLogger.js +1 -1
  16. package/dist/types/ActionPerformFunction.d.ts +12 -12
  17. package/dist/types/ActionPerformReturn.d.ts +11 -11
  18. package/dist/types/ComponentDefinition.d.ts +34 -11
  19. package/dist/types/ConfigVars.d.ts +36 -24
  20. package/dist/types/ConnectionDefinition.d.ts +92 -13
  21. package/dist/types/ConnectionDefinition.js +16 -0
  22. package/dist/types/CustomerAttributes.d.ts +6 -0
  23. package/dist/types/DataPayload.d.ts +4 -4
  24. package/dist/types/DataSourceDefinition.d.ts +11 -7
  25. package/dist/types/DataSourcePerformFunction.d.ts +1 -1
  26. package/dist/types/FlowAttributes.d.ts +2 -0
  27. package/dist/types/HttpResponse.d.ts +7 -0
  28. package/dist/types/Inputs.d.ts +82 -57
  29. package/dist/types/Inputs.js +1 -0
  30. package/dist/types/InstanceAttributes.d.ts +3 -1
  31. package/dist/types/IntegrationAttributes.d.ts +4 -1
  32. package/dist/types/IntegrationDefinition.d.ts +78 -41
  33. package/dist/types/TriggerDefinition.d.ts +29 -14
  34. package/dist/types/TriggerEventFunction.d.ts +4 -4
  35. package/dist/types/TriggerPayload.d.ts +6 -2
  36. package/dist/types/TriggerResult.d.ts +6 -6
  37. package/dist/types/UserAttributes.d.ts +11 -1
  38. package/package.json +1 -1
@@ -24,6 +24,8 @@ const integration_1 = require("./integration");
24
24
  const merge_1 = __importDefault(require("lodash/merge"));
25
25
  const perform_1 = require("./perform");
26
26
  const context_1 = require("./context");
27
+ const path_1 = __importDefault(require("path"));
28
+ const fs_1 = require("fs");
27
29
  const convertIntegration = (definition) => {
28
30
  var _a, _b, _c;
29
31
  // Generate a unique reference key that will be used to reference the
@@ -44,8 +46,17 @@ const convertIntegration = (definition) => {
44
46
  }
45
47
  return Object.assign(Object.assign({}, acc), { [key]: element });
46
48
  }, acc), {}))), {});
49
+ let metadata = {};
50
+ try {
51
+ const metaDataPath = path_1.default.join("..", ".spectral", "metadata.json");
52
+ const file = (0, fs_1.readFileSync)(metaDataPath, { encoding: "utf-8" });
53
+ metadata = JSON.parse(file);
54
+ }
55
+ catch (e) {
56
+ // No-op. If there's no metadata file then we move on.
57
+ }
47
58
  const cniComponent = codeNativeIntegrationComponent(definition, referenceKey, configVars);
48
- const cniYaml = codeNativeIntegrationYaml(definition, referenceKey, configVars);
59
+ const cniYaml = codeNativeIntegrationYaml(definition, referenceKey, configVars, metadata);
49
60
  return Object.assign(Object.assign({}, cniComponent), { codeNativeIntegrationYAML: cniYaml });
50
61
  };
51
62
  exports.convertIntegration = convertIntegration;
@@ -76,7 +87,7 @@ const convertConfigPages = (pages, userLevelConfigured) => {
76
87
  };
77
88
  }) })));
78
89
  };
79
- const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, userLevelConfigPages, scopedConfigVars, componentRegistry = {}, }, referenceKey, configVars) => {
90
+ const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, userLevelConfigPages, scopedConfigVars, componentRegistry = {}, }, referenceKey, configVars, metadata) => {
80
91
  // Find the preprocess flow config on the flow, if one exists.
81
92
  const preprocessFlows = flows.filter((flow) => flow.preprocessFlowConfig);
82
93
  // Do some validation of preprocess flow configs.
@@ -129,6 +140,7 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
129
140
  ...convertConfigPages(configPages, false),
130
141
  ...convertConfigPages(userLevelConfigPages, true),
131
142
  ],
143
+ importMetadata: metadata,
132
144
  };
133
145
  return yaml_1.default.stringify(result);
134
146
  };
@@ -342,7 +354,7 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
342
354
  return result;
343
355
  };
344
356
  exports.convertFlow = convertFlow;
345
- /** Converts an input value to the expected server type by its collection type */
357
+ /** Converts an input value to the expected server type by its collection type. */
346
358
  const convertInputValue = (value, collectionType) => {
347
359
  if (collectionType !== "keyvaluelist") {
348
360
  return value;
@@ -364,7 +376,6 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
364
376
  key,
365
377
  stableKey,
366
378
  dataType: "connection",
367
- orgOnly: false,
368
379
  useScopedConfigVar: stableKey,
369
380
  };
370
381
  }
@@ -484,7 +495,7 @@ const flowFunctionKey = (flowName, functionName) => {
484
495
  .join("");
485
496
  return `${flowKey}_${functionName}`;
486
497
  };
487
- /* Generates component argument for invokeTrigger calls */
498
+ /* Generates component argument for invokeTrigger calls. */
488
499
  const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
489
500
  const { component } = componentRef;
490
501
  const inputComponent = "signature" in componentRef.component
@@ -504,7 +515,7 @@ const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
504
515
  triggerEventFunctionName: eventName,
505
516
  };
506
517
  };
507
- /* Generates a wrapper function that calls an existing component trigger's perform */
518
+ /* Generates a wrapper function that calls an existing component trigger's perform. */
508
519
  const generateTriggerPerformFn = (componentRef, onTrigger) => {
509
520
  const performFn = componentRef && typeof onTrigger !== "function"
510
521
  ? (context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
@@ -247,4 +247,6 @@ export interface Input {
247
247
  model?: InputFieldChoice[];
248
248
  language?: string;
249
249
  onPremiseControlled?: boolean;
250
+ dataSource?: string;
251
+ shown?: boolean;
250
252
  }
@@ -57,7 +57,6 @@ export interface DefaultRequiredConfigVariable {
57
57
  export interface OrganizationActivatedConnectionRequiredConfigVariable {
58
58
  key: string;
59
59
  dataType: "connection";
60
- orgOnly: false;
61
60
  inputs?: never;
62
61
  useScopedConfigVar: string;
63
62
  }
package/dist/testing.d.ts CHANGED
@@ -2,16 +2,25 @@
2
2
  * This module provides functions to help developers unit
3
3
  * test custom components prior to publishing them. For
4
4
  * information on unit testing, check out our docs:
5
- * https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
5
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
6
6
  */
7
7
  import { ActionPerformReturn as ServerActionPerformReturn, TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, DataSourceResult, DataSourceContext } from "./serverTypes";
8
8
  import { ActionContext, ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceType, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection, ComponentManifest } from "./types";
9
+ /**
10
+ * Create a test connection to use when testing your custom component locally. See
11
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#providing-test-connection-inputs-to-an-action-test
12
+ */
9
13
  export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown>) => ConnectionValue;
10
14
  export declare const defaultConnectionValueEnvironmentVariable = "PRISMATIC_CONNECTION_VALUE";
15
+ /**
16
+ * Source a test connection from an environment variable for local testing. See
17
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#access-connections-for-local-testing
18
+ */
11
19
  export declare const connectionValue: (envVarKey?: string) => ConnectionValue;
12
20
  /**
13
- * Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
14
- * See https://prismatic.io/docs/custom-components/writing-custom-components/#verifying-correct-logging-in-action-tests for information on testing correct logging behavior in your custom component.
21
+ * Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected. See
22
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#verifying-correct-logging-in-action-tests
23
+ * for information on testing correct logging behavior in your custom component.
15
24
  */
16
25
  export declare const loggerMock: () => ActionLogger;
17
26
  /**
@@ -66,7 +75,8 @@ type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
66
75
  };
67
76
  /**
68
77
  * Invokes specified Flow of a Code Native Integration using supplied params.
69
- * Runs the Trigger and then the Action function and returns the result of the Action.
78
+ * Runs the Trigger and then the Action function and returns the result of the Action. See
79
+ * https://prismatic.io/docs/integrations/triggers/cross-flow/#using-cross-flow-triggers-in-code-native
70
80
  */
71
81
  export declare const invokeFlow: <TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow, { configVars, context, payload, }?: {
72
82
  configVars?: TConfigVarValues;
@@ -77,13 +87,41 @@ export declare class ComponentTestHarness<TComponent extends Component> {
77
87
  component: TComponent;
78
88
  constructor(component: TComponent);
79
89
  private buildParams;
90
+ /**
91
+ * Source a test connection from an environment variable for local testing. See
92
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#access-connections-for-local-testing
93
+ */
80
94
  connectionValue({ key }: ConnectionDefinition): ConnectionValue;
95
+ /**
96
+ * Invoke a trigger by its key within a unit test. See
97
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
98
+ */
81
99
  trigger<TConfigVars extends ConfigVarResultCollection>(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerResult>;
100
+ /**
101
+ * Invoke a trigger's onInstanceDeploy function by its key within a unit test. See
102
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
103
+ */
82
104
  triggerOnInstanceDeploy<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerEventFunctionReturn | void>;
105
+ /**
106
+ * Invoke a trigger's onInstanceDelete function by its key within a unit test. See
107
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
108
+ */
83
109
  triggerOnInstanceDelete<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerEventFunctionReturn | void>;
110
+ /**
111
+ * Invoke an action by its key within a unit test. See
112
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
113
+ */
84
114
  action<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<ServerActionPerformReturn>;
115
+ /**
116
+ * Invoke a data source by its key within a unit test. See
117
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
118
+ */
85
119
  dataSource<TConfigVars extends ConfigVarResultCollection>(key: string, params?: Record<string, unknown>, context?: Partial<DataSourceContext<TConfigVars>>): Promise<DataSourceResult>;
86
120
  }
121
+ /**
122
+ * Create a testing harness to test a custom component's actions, triggers and data sources. See
123
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
124
+ */
87
125
  export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
88
126
  declare const _default: {
89
127
  loggerMock: () => ActionLogger;
package/dist/testing.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * This module provides functions to help developers unit
4
4
  * test custom components prior to publishing them. For
5
5
  * information on unit testing, check out our docs:
6
- * https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
6
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
7
7
  */
8
8
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
9
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -17,6 +17,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.createHarness = exports.ComponentTestHarness = exports.invokeFlow = exports.invokeDataSource = exports.invokeTrigger = exports.defaultTriggerPayload = exports.invoke = exports.createMockContextComponents = exports.loggerMock = exports.connectionValue = exports.defaultConnectionValueEnvironmentVariable = exports.createConnection = void 0;
19
19
  const jest_mock_1 = require("jest-mock");
20
+ /**
21
+ * Create a test connection to use when testing your custom component locally. See
22
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#providing-test-connection-inputs-to-an-action-test
23
+ */
20
24
  const createConnection = ({ key }, values, tokenValues) => ({
21
25
  configVarKey: "",
22
26
  key,
@@ -25,6 +29,10 @@ const createConnection = ({ key }, values, tokenValues) => ({
25
29
  });
26
30
  exports.createConnection = createConnection;
27
31
  exports.defaultConnectionValueEnvironmentVariable = "PRISMATIC_CONNECTION_VALUE";
32
+ /**
33
+ * Source a test connection from an environment variable for local testing. See
34
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#access-connections-for-local-testing
35
+ */
28
36
  const connectionValue = (envVarKey = exports.defaultConnectionValueEnvironmentVariable) => {
29
37
  const value = process.env[envVarKey];
30
38
  if (!value) {
@@ -35,8 +43,9 @@ const connectionValue = (envVarKey = exports.defaultConnectionValueEnvironmentVa
35
43
  };
36
44
  exports.connectionValue = connectionValue;
37
45
  /**
38
- * Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
39
- * See https://prismatic.io/docs/custom-components/writing-custom-components/#verifying-correct-logging-in-action-tests for information on testing correct logging behavior in your custom component.
46
+ * Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected. See
47
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#verifying-correct-logging-in-action-tests
48
+ * for information on testing correct logging behavior in your custom component.
40
49
  */
41
50
  const loggerMock = () => ({
42
51
  metric: console.log,
@@ -251,7 +260,8 @@ const createConfigVars = (values) => {
251
260
  };
252
261
  /**
253
262
  * Invokes specified Flow of a Code Native Integration using supplied params.
254
- * Runs the Trigger and then the Action function and returns the result of the Action.
263
+ * Runs the Trigger and then the Action function and returns the result of the Action. See
264
+ * https://prismatic.io/docs/integrations/triggers/cross-flow/#using-cross-flow-triggers-in-code-native
255
265
  */
256
266
  const invokeFlow = (flow_1, ...args_1) => __awaiter(void 0, [flow_1, ...args_1], void 0, function* (flow, { configVars, context, payload, } = {}) {
257
267
  const realizedConfigVars = createConfigVars(configVars);
@@ -279,6 +289,10 @@ class ComponentTestHarness {
279
289
  const defaults = inputs.reduce((result, { key, default: defaultValue }) => (Object.assign(Object.assign({}, result), { [key]: `${defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""}` })), {});
280
290
  return Object.assign(Object.assign({}, defaults), params);
281
291
  }
292
+ /**
293
+ * Source a test connection from an environment variable for local testing. See
294
+ * https://prismatic.io/docs/custom-connectors/unit-testing/#access-connections-for-local-testing
295
+ */
282
296
  connectionValue({ key }) {
283
297
  const { PRISMATIC_CONNECTION_VALUE: value } = process.env;
284
298
  if (!value) {
@@ -287,12 +301,20 @@ class ComponentTestHarness {
287
301
  const result = Object.assign(Object.assign({}, JSON.parse(value)), { key });
288
302
  return result;
289
303
  }
304
+ /**
305
+ * Invoke a trigger by its key within a unit test. See
306
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
307
+ */
290
308
  trigger(key, payload, params, context) {
291
309
  return __awaiter(this, void 0, void 0, function* () {
292
310
  const trigger = this.component.triggers[key];
293
311
  return trigger.perform(createActionContext(context), Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), this.buildParams(trigger.inputs, params));
294
312
  });
295
313
  }
314
+ /**
315
+ * Invoke a trigger's onInstanceDeploy function by its key within a unit test. See
316
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
317
+ */
296
318
  triggerOnInstanceDeploy(key, params, context) {
297
319
  return __awaiter(this, void 0, void 0, function* () {
298
320
  const trigger = this.component.triggers[key];
@@ -302,6 +324,10 @@ class ComponentTestHarness {
302
324
  return trigger.onInstanceDeploy(createActionContext(context), this.buildParams(trigger.inputs, params));
303
325
  });
304
326
  }
327
+ /**
328
+ * Invoke a trigger's onInstanceDelete function by its key within a unit test. See
329
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
330
+ */
305
331
  triggerOnInstanceDelete(key, params, context) {
306
332
  return __awaiter(this, void 0, void 0, function* () {
307
333
  const trigger = this.component.triggers[key];
@@ -311,12 +337,20 @@ class ComponentTestHarness {
311
337
  return trigger.onInstanceDelete(createActionContext(context), this.buildParams(trigger.inputs, params));
312
338
  });
313
339
  }
340
+ /**
341
+ * Invoke an action by its key within a unit test. See
342
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
343
+ */
314
344
  action(key, params, context) {
315
345
  return __awaiter(this, void 0, void 0, function* () {
316
346
  const action = this.component.actions[key];
317
347
  return action.perform(createActionContext(context), this.buildParams(action.inputs, params));
318
348
  });
319
349
  }
350
+ /**
351
+ * Invoke a data source by its key within a unit test. See
352
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
353
+ */
320
354
  dataSource(key, params, context) {
321
355
  return __awaiter(this, void 0, void 0, function* () {
322
356
  const dataSource = this.component.dataSources[key];
@@ -325,6 +359,10 @@ class ComponentTestHarness {
325
359
  }
326
360
  }
327
361
  exports.ComponentTestHarness = ComponentTestHarness;
362
+ /**
363
+ * Create a testing harness to test a custom component's actions, triggers and data sources. See
364
+ * https://prismatic.io/docs/custom-connectors/unit-testing/
365
+ */
328
366
  const createHarness = (component) => {
329
367
  return new ComponentTestHarness(component);
330
368
  };
@@ -2,25 +2,36 @@ import { ActionDisplayDefinition, ActionPerformFunction, ActionPerformReturn, Co
2
2
  import { ComponentManifestAction } from "./ComponentManifest";
3
3
  /**
4
4
  * ActionDefinition is the type of the object that is passed in to `action` function to
5
- * define a component action.
5
+ * define a component action. See
6
+ * https://prismatic.io/docs/custom-connectors/actions/
6
7
  */
7
8
  export interface ActionDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown> = ActionPerformReturn<TAllowsBranching, unknown>> {
8
- /** Defines how the Action is displayed in the Prismatic interface. */
9
+ /** Defines how the action is displayed in the Prismatic UI. */
9
10
  display: ActionDisplayDefinition;
10
- /** Function to perform when this Action is invoked. */
11
+ /** The function to perform when this action is invoked. */
11
12
  perform: ActionPerformFunction<TInputs, TConfigVars, Record<string, Record<string, ComponentManifestAction>>, TAllowsBranching, TReturn>;
12
- /** InputFields to present in the Prismatic interface for configuration of this Action. */
13
+ /**
14
+ * The inputs to present a low-code integration builder. Values of these inputs
15
+ * are passed to the `perform` function when the action is invoked.
16
+ */
13
17
  inputs: TInputs;
14
- /** Optional attribute that specifies whether an Action will terminate execution.*/
18
+ /** Attribute that specifies whether an action will terminate execution.*/
15
19
  terminateExecution?: boolean;
16
- /** Specifies whether an Action will break out of a loop. */
20
+ /** Specifies whether an action will break out of a loop. */
17
21
  breakLoop?: boolean;
18
- /** Determines whether an Action will allow Conditional Branching.*/
22
+ /**
23
+ * Determines whether an action will allow branching. See
24
+ * https://prismatic.io/docs/custom-connectors/branching/
25
+ */
19
26
  allowsBranching?: TAllowsBranching;
20
- /** Static Branch names associated with an Action. */
27
+ /**
28
+ * Static branches associated with an action.
29
+ * Use if your action supports branching. See
30
+ * https://prismatic.io/docs/custom-connectors/branching/
31
+ */
21
32
  staticBranchNames?: string[];
22
- /** The Input associated with Dynamic Branching.*/
33
+ /** The input field associated with dynamic branching. */
23
34
  dynamicBranchInput?: string;
24
- /** An example of the payload outputted by an Action*/
35
+ /** An example of the payload output by this action. */
25
36
  examplePayload?: Awaited<ReturnType<this["perform"]>>;
26
37
  }
@@ -2,14 +2,15 @@
2
2
  * Actions' perform functions receive a logger object as part of their first parameter.
3
3
  * Types in this file define the shape of the logger that is passed to an action.
4
4
  * For information on the logger object, see:
5
- * https://prismatic.io/docs/custom-components/writing-custom-components/#contextlogger
5
+ * https://prismatic.io/docs/custom-connectors/actions/#logger-object
6
6
  */
7
7
  /**
8
8
  * A logger function, similar to `console.log()` or `console.error()`.
9
9
  */
10
10
  export type ActionLoggerFunction = (...args: unknown[]) => void;
11
11
  /**
12
- * An object containing logger functions.
12
+ * An object containing logger functions. See
13
+ * https://prismatic.io/docs/custom-connectors/actions/#logger-object
13
14
  */
14
15
  export interface ActionLogger {
15
16
  metric: ActionLoggerFunction;
@@ -3,6 +3,6 @@
3
3
  * Actions' perform functions receive a logger object as part of their first parameter.
4
4
  * Types in this file define the shape of the logger that is passed to an action.
5
5
  * For information on the logger object, see:
6
- * https://prismatic.io/docs/custom-components/writing-custom-components/#contextlogger
6
+ * https://prismatic.io/docs/custom-connectors/actions/#logger-object
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -43,7 +43,7 @@ interface DebugResult {
43
43
  duration: number;
44
44
  }>;
45
45
  };
46
- /** Memory limit in MB */
46
+ /** Memory limit in MB. */
47
47
  allowedMemory: number;
48
48
  /** Resulting data bout memory usage. */
49
49
  memoryUsage: Array<{
@@ -69,17 +69,17 @@ export type ExecutionFrame = ({
69
69
  export type FlowInvoker<TFlows extends Readonly<string[]> | undefined> = (flowName: TFlows extends Readonly<string[]> ? TFlows[number] : string, data?: Record<string, unknown>, config?: AxiosRequestConfig<any>, source?: string) => Promise<AxiosResponse<any, any>>;
70
70
  /** Definition of the function to perform when an Action is invoked. */
71
71
  export type ActionPerformFunction<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]> = Record<string, ComponentManifest["actions"]>, TAllowsBranching extends boolean | undefined = undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown> = ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext<TConfigVars, TComponentActions>, params: ActionInputParameters<TInputs>) => Promise<TReturn>;
72
- /** Context provided to perform method containing helpers and contextual data */
72
+ /** Context provided to perform method containing helpers and contextual data. */
73
73
  export type ActionContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]> = Record<string, ComponentManifest["actions"]>, TFlows extends string[] = string[]> = {
74
- /** Logger for permanent logging; console calls are also captured */
74
+ /** Logger for permanent logging; console calls are also captured. */
75
75
  logger: ActionLogger;
76
- /** A a flow-specific key/value store that may be used to store small amounts of data that is persisted between Instance executions */
76
+ /** A a flow-specific key/value store that may be used to store small amounts of data that is persisted between Instance executions. */
77
77
  instanceState: Record<string, unknown>;
78
- /** A key/value store that is shared between flows on an Instance that may be used to store small amounts of data that is persisted between Instance executions */
78
+ /** A key/value store that is shared between flows on an Instance that may be used to store small amounts of data that is persisted between Instance executions. */
79
79
  crossFlowState: Record<string, unknown>;
80
- /** A key/value store that may be used to store small amounts of data for use later during the execution */
80
+ /** A key/value store that may be used to store small amounts of data for use later during the execution. */
81
81
  executionState: Record<string, unknown>;
82
- /** A key/value store that is shared between all flows of an Instance for any version of an Integration that may be used to store small amounts of data that is persisted between Instance executions */
82
+ /** A key/value store that is shared between all flows of an Instance for any version of an Integration that may be used to store small amounts of data that is persisted between Instance executions. */
83
83
  integrationState: Record<string, unknown>;
84
84
  /** Key/value collection of config variables of the integration. */
85
85
  configVars: TConfigVars;
@@ -89,15 +89,15 @@ export type ActionContext<TConfigVars extends ConfigVarResultCollection = Config
89
89
  [A in keyof TComponentActions[K]]: TComponentActions[K][A]["perform"];
90
90
  };
91
91
  };
92
- /** A unique id that corresponds to the step on the Integration */
92
+ /** A unique id that corresponds to the step on the Integration. */
93
93
  stepId: string;
94
- /** A unique id that corresponds to the specific execution of the Integration */
94
+ /** A unique id that corresponds to the specific execution of the Integration. */
95
95
  executionId: string;
96
- /** An object containing webhook URLs for all flows of the currently running instance */
96
+ /** An object containing webhook URLs for all flows of the currently running instance. */
97
97
  webhookUrls: Record<string, string>;
98
- /** An object containing webhook API keys for all flows of the currently running instance */
98
+ /** An object containing webhook API keys for all flows of the currently running instance. */
99
99
  webhookApiKeys: Record<string, string[]>;
100
- /** The URL used to invoke the current execution */
100
+ /** The URL used to invoke the current execution. */
101
101
  invokeUrl: string;
102
102
  /** Contains attributes of the Customer for whom an Instance is being executed. */
103
103
  customer: CustomerAttributes;
@@ -1,31 +1,31 @@
1
- /** Used to represent a binary or serialized data return as content type must be specified */
1
+ /** Used to represent a binary or serialized data return as content type must be specified. */
2
2
  export interface ActionPerformDataReturn<ReturnData> {
3
- /** Data payload containing data of the specified contentType */
3
+ /** Data payload containing data of the specified contentType. */
4
4
  data: ReturnData;
5
- /** The Content Type of the payload data */
5
+ /** The Content Type of the payload data. */
6
6
  contentType?: string;
7
7
  /** The HTTP Status code that will be used if this terminates a synchronous invocation */
8
8
  statusCode?: number;
9
- /** The HTTP headers that will be sent back if this terminates a synchronous invocation */
9
+ /** The HTTP headers that will be sent back if this terminates a synchronous invocation. */
10
10
  headers?: Record<string, string>;
11
- /** An optional object, the keys and values of which will be persisted in the flow-specific instanceState and available for subsequent actions and executions */
11
+ /** An optional object, the keys and values of which will be persisted in the flow-specific instanceState and available for subsequent actions and executions. */
12
12
  instanceState?: Record<string, unknown>;
13
- /** An optional object, the keys and values of which will be persisted in the crossFlowState and available in any flow for subsequent actions and executions */
13
+ /** An optional object, the keys and values of which will be persisted in the crossFlowState and available in any flow for subsequent actions and executions. */
14
14
  crossFlowState?: Record<string, unknown>;
15
- /** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
15
+ /** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution. */
16
16
  executionState?: Record<string, unknown>;
17
- /** An optional object, the keys and values of which will be persisted in the integrationState and available in any flow of an Instance for any version of an Integration for subsequent actions and executions */
17
+ /** An optional object, the keys and values of which will be persisted in the integrationState and available in any flow of an Instance for any version of an Integration for subsequent actions and executions. */
18
18
  integrationState?: Record<string, unknown>;
19
19
  /** A field populated by the Prismatic platform which indicates whether the action failed with an error during execution. */
20
20
  failed?: boolean;
21
21
  /** A field populated by the Prismatic platform which may refer to an object that contains data about any error that resulted in failure. */
22
22
  error?: Record<string, unknown>;
23
23
  }
24
- /** Used to represent a branching return of conventional data and does not require content type to be specified */
25
- /** Used to represent a binary or serialized data branching return as content type must be specified */
24
+ /** Used to represent a branching return of conventional data and does not require content type to be specified. */
25
+ /** Used to represent a binary or serialized data branching return as content type must be specified. */
26
26
  export interface ActionPerformBranchingDataReturn<ReturnData> extends ActionPerformDataReturn<ReturnData> {
27
27
  /** Name of the Branch to take. */
28
28
  branch: string;
29
29
  }
30
- /** Required return type of all action perform functions */
30
+ /** Required return type of all action perform functions. */
31
31
  export type ActionPerformReturn<AllowsBranching extends boolean | undefined, ReturnData> = (AllowsBranching extends true ? ActionPerformBranchingDataReturn<ReturnData> : ActionPerformDataReturn<ReturnData>) | undefined;
@@ -2,29 +2,52 @@ import { ActionDefinition, ConnectionDefinition, ComponentDisplayDefinition, Tri
2
2
  import { PollingTriggerDefinition } from "./PollingTriggerDefinition";
3
3
  export type ErrorHandler = (error: unknown) => unknown;
4
4
  export interface ComponentHooks {
5
- /** Defines a global error handler that automatically wraps the component's action/trigger perform functions. */
5
+ /**
6
+ * Defines a global error handler that automatically wraps the component's action/trigger
7
+ * perform functions. See
8
+ * https://prismatic.io/docs/custom-connectors/error-handling/#global-error-handlers
9
+ */
6
10
  error?: ErrorHandler;
7
11
  }
8
- /** Defines attributes of a Component. */
12
+ /** Defines attributes of a component. */
9
13
  export type ComponentDefinition<TPublic extends boolean, TKey extends string> = {
10
- /** Specifies unique key for this Component. */
14
+ /** Specifies a unique programmatic key for this component. */
11
15
  key: TKey;
12
- /** Specifies if this Component is available for all Organizations or only your own @default false */
16
+ /**
17
+ * Specifies if this component is available for all organizations or only your own.
18
+ * Only Prismatic public components can specify 'true'
19
+ * @default false
20
+ */
13
21
  public?: TPublic;
14
- /** Defines how the Component is displayed in the Prismatic interface. */
22
+ /** Defines how the component is displayed in the Prismatic UI. */
15
23
  display: ComponentDisplayDefinition<TPublic>;
16
- /** Specifies the supported Actions of this Component. */
24
+ /**
25
+ * Specifies the supported Actions of this component. See
26
+ * https://prismatic.io/docs/custom-connectors/actions/
27
+ */
17
28
  actions?: Record<string, ActionDefinition<any, any, boolean, any>>;
18
- /** Specifies the supported Triggers of this Component. */
29
+ /**
30
+ * Specifies the supported triggers of this component. See
31
+ * https://prismatic.io/docs/custom-connectors/triggers/
32
+ */
19
33
  triggers?: Record<string, TriggerDefinition<any, any, boolean, any> | PollingTriggerDefinition<any, any, any, any, any, any>>;
20
- /** Specifies the supported Data Sources of this Component. */
34
+ /**
35
+ * Specifies the supported data sources of this component. See
36
+ * https://prismatic.io/docs/custom-connectors/data-sources/
37
+ */
21
38
  dataSources?: Record<string, DataSourceDefinition<any, any, any>>;
22
- /** Specifies the supported Connections of this Component. */
39
+ /**
40
+ * Specifies the supported connections of this component. See
41
+ * https://prismatic.io/docs/custom-connectors/connections/
42
+ */
23
43
  connections?: ConnectionDefinition[];
24
- /** Hooks */
44
+ /**
45
+ * Hooks (error handler) for this component. See
46
+ * https://prismatic.io/docs/custom-connectors/error-handling/
47
+ */
25
48
  hooks?: ComponentHooks;
26
49
  } & (TPublic extends true ? {
27
- /** Specified the URL for the Component Documentation. */
50
+ /** The URL for this component's documentation. */
28
51
  documentationUrl: `https://prismatic.io/docs/components/${TKey}/`;
29
52
  } : {
30
53
  documentationUrl?: string;