@prismatic-io/spectral 10.2.0 → 10.2.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.d.ts CHANGED
@@ -100,7 +100,7 @@ export declare const trigger: <TInputs extends Inputs, TConfigVars extends Confi
100
100
  * @param definition A PollingTriggerDefinition is similar to a TriggerDefinition, except it requires a pollAction instead of a perform. The pollAction, which can be any action defined in the component, will be polled on the defined schedule.
101
101
  * @returns This function validates the shape of the `definition` object provided, and returns the same polling trigger object.
102
102
  */
103
- export declare const pollingTrigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload, TResult extends TriggerResult<boolean, TPayload>, TActionInputs extends Inputs>(definition: PollingTriggerDefinition<TInputs, TConfigVars, TPayload, TResult, TActionInputs>) => PollingTriggerDefinition<TInputs, TConfigVars, TPayload, TResult, TActionInputs>;
103
+ export declare const pollingTrigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs>(definition: PollingTriggerDefinition<TInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TActionInputs>) => PollingTriggerDefinition<TInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TActionInputs>;
104
104
  /**
105
105
  * This function creates a data source object that can be referenced
106
106
  * by a custom component. It helps ensure that the shape of the
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
11
22
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
24
  };
@@ -87,8 +98,8 @@ const createPollingPerform = (trigger, { inputCleaners, errorHandler }) => {
87
98
  errorHandler,
88
99
  });
89
100
  const combinedContext = Object.assign({}, context, pollingContext);
90
- const triggerResponse = yield triggerPerform(combinedContext, payload, params);
91
- return triggerResponse;
101
+ const _a = yield triggerPerform(combinedContext, payload, params), { polledNoChanges } = _a, rest = __rest(_a, ["polledNoChanges"]);
102
+ return Object.assign(Object.assign({}, rest), { resultType: polledNoChanges ? "polled_no_changes" : "completed" });
92
103
  }
93
104
  catch (error) {
94
105
  throw errorHandler ? errorHandler(error) : error;
@@ -1,31 +1,35 @@
1
1
  import type { AxiosRequestConfig, AxiosResponse } from "axios";
2
- import type { ActionDisplayDefinition, TriggerEventFunction, Inputs, TriggerResult, ConfigVarResultCollection, TriggerPayload, ActionDefinition, ActionContext, ActionInputParameters } from ".";
2
+ import type { ActionDisplayDefinition, TriggerEventFunction, Inputs, ConfigVarResultCollection, TriggerPayload, ActionDefinition, ActionContext, ActionInputParameters, ActionPerformReturn, TriggerResult } from ".";
3
3
  export interface PollingContext<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection> extends ActionContext<TConfigVars> {
4
4
  polling: {
5
5
  reinvokeFlow: (data?: Record<string, unknown>, config?: AxiosRequestConfig<any>) => Promise<AxiosResponse<any, any>>;
6
- invokeAction: (params: ActionInputParameters<TInputs>) => Promise<any>;
6
+ invokeAction: (params: ActionInputParameters<TInputs>) => Promise<ActionPerformReturn<boolean, any>>;
7
7
  getState: () => Record<string, unknown>;
8
8
  setState: (newState: Record<string, unknown>) => void;
9
9
  };
10
10
  }
11
- export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TResult extends TriggerResult<boolean, TPayload> = TriggerResult<boolean, TPayload>> = (context: ActionContext<TConfigVars> & PollingContext<TActionInputs>, payload: TPayload, params: ActionInputParameters<TInputs>) => Promise<TResult>;
11
+ export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> = (context: ActionContext<TConfigVars> & PollingContext<TActionInputs>, payload: TPayload, params: ActionInputParameters<TInputs>) => Promise<TResult>;
12
12
  /**
13
13
  * PollingTriggerDefinition is the type of the object that is passed in to `pollingTrigger` function to
14
14
  * define a component trigger.
15
15
  */
16
- export type PollingTriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TResult extends TriggerResult<boolean, TPayload> = TriggerResult<boolean, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> = {
16
+ export interface PollingTriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
17
17
  triggerType?: "polling";
18
18
  /** Defines how the Action is displayed in the Prismatic interface. */
19
19
  display: ActionDisplayDefinition;
20
20
  /** Defines your trigger's polling behavior. */
21
21
  pollAction?: TAction;
22
22
  /** Function to perform when this Trigger is invoked. A default perform will be provided for most polling triggers but defining this allows for custom behavior. */
23
- perform: PollingTriggerPerformFunction<TCombinedInputs, TActionInputs, TConfigVars, TPayload, TResult>;
23
+ perform: PollingTriggerPerformFunction<TCombinedInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
24
24
  /** Function to execute when an Instance of an Integration with a Flow that uses this Trigger is deployed. */
25
25
  onInstanceDeploy?: TriggerEventFunction<TInputs, TConfigVars>;
26
26
  /** Function to execute when an Instance of an Integration with a Flow that uses this Trigger is deleted. */
27
27
  onInstanceDelete?: TriggerEventFunction<TInputs, TConfigVars>;
28
28
  /** InputFields to present in the Prismatic interface for configuration of this Trigger. */
29
29
  inputs?: TInputs;
30
- };
30
+ /** Determines whether this Trigger allows Conditional Branching. */
31
+ allowsBranching?: TAllowsBranching;
32
+ /** An example of the payload outputted by this Trigger. */
33
+ examplePayload?: Awaited<ReturnType<this["perform"]>>;
34
+ }
31
35
  export declare const isPollingTriggerDefinition: (ref: unknown) => ref is PollingTriggerDefinition;
@@ -18,6 +18,8 @@ export interface TriggerBaseResult<TPayload extends TriggerPayload> {
18
18
  failed?: boolean;
19
19
  /** A field populated by the Prismatic platform which may refer to an object that contains data about any error that resulted in failure. */
20
20
  error?: Record<string, unknown>;
21
+ /** An optional field that component authors can use to denote their CNI trigger result as having a polling response. */
22
+ polledNoChanges?: boolean;
21
23
  }
22
24
  /** Represents the result of a Trigger action that uses branching. */
23
25
  export interface TriggerBranchingResult<TPayload extends TriggerPayload> extends TriggerBaseResult<TPayload> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.2.0",
3
+ "version": "10.2.1",
4
4
  "description": "Utility library for building Prismatic components and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",