@prismatic-io/spectral 6.4.0 → 6.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.d.ts +3 -3
- package/dist/testing.d.ts +7 -7
- package/dist/types/ActionDefinition.d.ts +4 -4
- package/dist/types/ActionPerformFunction.d.ts +1 -1
- package/dist/types/ComponentDefinition.d.ts +2 -2
- package/dist/types/TriggerDefinition.d.ts +4 -4
- package/dist/types/TriggerPerformFunction.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* authors create inputs, actions, and components that can
|
|
4
4
|
* be processed by the Prismatic API.
|
|
5
5
|
*/
|
|
6
|
-
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition } from "./types";
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult } from "./types";
|
|
7
7
|
import { convertComponent } from "./serverTypes/convert";
|
|
8
8
|
/**
|
|
9
9
|
* This function creates a component object that can be
|
|
@@ -23,7 +23,7 @@ export declare const component: <T extends boolean>(definition: ComponentDefinit
|
|
|
23
23
|
* @param definition An ActionDefinition type object that includes UI display information, a function to perform when the action is invoked, and a an object containing inputs for the perform function.
|
|
24
24
|
* @returns This function validates the shape of the `definition` object provided, and returns the same action object.
|
|
25
25
|
*/
|
|
26
|
-
export declare const action: <
|
|
26
|
+
export declare const action: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>>(definition: ActionDefinition<TInputs, TAllowsBranching, TReturn>) => ActionDefinition<TInputs, TAllowsBranching, TReturn>;
|
|
27
27
|
/**
|
|
28
28
|
* This function creates a trigger object that can be referenced
|
|
29
29
|
* by a custom component. It helps ensure that the shape of the
|
|
@@ -33,7 +33,7 @@ export declare const action: <T extends Inputs>(definition: ActionDefinition<T>)
|
|
|
33
33
|
* @param definition A TriggerDefinition type object that includes UI display information, a function to perform when the trigger is invoked, and a an object containing inputs for the perform function.
|
|
34
34
|
* @returns This function validates the shape of the `definition` object provided, and returns the same trigger object.
|
|
35
35
|
*/
|
|
36
|
-
export declare const trigger: <
|
|
36
|
+
export declare const trigger: <TInputs extends Inputs, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching>>(definition: TriggerDefinition<TInputs, TAllowsBranching, TResult>) => TriggerDefinition<TInputs, TAllowsBranching, TResult>;
|
|
37
37
|
/**
|
|
38
38
|
* For information and examples on how to write inputs
|
|
39
39
|
* for custom component actions and triggers, see
|
package/dist/testing.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* information on unit testing, check out our docs:
|
|
5
5
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
|
|
6
6
|
*/
|
|
7
|
-
import { TriggerPayload, TriggerResult,
|
|
8
|
-
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters } from "./types";
|
|
9
|
-
export declare const createConnection: <T extends
|
|
7
|
+
import { TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn } from "./serverTypes";
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult } from "./types";
|
|
9
|
+
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>) => ConnectionValue;
|
|
10
10
|
/**
|
|
11
11
|
* Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
|
|
12
12
|
* 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.
|
|
@@ -25,7 +25,7 @@ interface InvokeReturn<ReturnData> {
|
|
|
25
25
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
26
26
|
* action result and a mock logger for asserting logging.
|
|
27
27
|
*/
|
|
28
|
-
export declare const invoke: <
|
|
28
|
+
export declare const invoke: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform }: ActionDefinition<TInputs, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
29
29
|
export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
30
30
|
/**
|
|
31
31
|
* Invokes specified TriggerDefinition perform function using supplied params
|
|
@@ -33,7 +33,7 @@ export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
|
33
33
|
* to avoid extra casting within test methods. Returns an InvokeResult containing both the
|
|
34
34
|
* trigger result and a mock logger for asserting logging.
|
|
35
35
|
*/
|
|
36
|
-
export declare const invokeTrigger: <
|
|
36
|
+
export declare const invokeTrigger: <TInputs extends Inputs, TAllowsBranching extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching>>({ perform }: TriggerDefinition<TInputs, TAllowsBranching, TResult>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
37
37
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
38
38
|
component: TComponent;
|
|
39
39
|
constructor(component: TComponent);
|
|
@@ -44,8 +44,8 @@ export declare class ComponentTestHarness<TComponent extends Component> {
|
|
|
44
44
|
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
45
45
|
declare const _default: {
|
|
46
46
|
loggerMock: () => ActionLogger;
|
|
47
|
-
invoke: <
|
|
48
|
-
invokeTrigger: <
|
|
47
|
+
invoke: <TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform }: ActionDefinition<TInputs, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<TReturn>>;
|
|
48
|
+
invokeTrigger: <TInputs_1 extends Inputs, TAllowsBranching_1 extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching_1>>({ perform }: TriggerDefinition<TInputs_1, TAllowsBranching_1, TResult>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<TInputs_1> | undefined) => Promise<InvokeReturn<TResult>>;
|
|
49
49
|
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
50
50
|
};
|
|
51
51
|
export default _default;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ActionDisplayDefinition, ActionPerformFunction, Inputs } from ".";
|
|
1
|
+
import { ActionDisplayDefinition, ActionPerformFunction, ActionPerformReturn, Inputs } from ".";
|
|
2
2
|
/**
|
|
3
3
|
* ActionDefinition is the type of the object that is passed in to `action` function to
|
|
4
4
|
* define a component action.
|
|
5
5
|
*/
|
|
6
|
-
export interface ActionDefinition<TInputs extends Inputs
|
|
6
|
+
export interface ActionDefinition<TInputs extends Inputs, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> {
|
|
7
7
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
8
8
|
display: ActionDisplayDefinition;
|
|
9
9
|
/** Function to perform when this Action is invoked. */
|
|
10
|
-
perform: ActionPerformFunction<
|
|
10
|
+
perform: ActionPerformFunction<TInputs, TAllowsBranching, TReturn>;
|
|
11
11
|
/** InputFields to present in the Prismatic interface for configuration of this Action. */
|
|
12
12
|
inputs: TInputs;
|
|
13
13
|
/** Optional attribute that specifies whether an Action will terminate execution.*/
|
|
@@ -15,7 +15,7 @@ export interface ActionDefinition<TInputs extends Inputs> {
|
|
|
15
15
|
/** Specifies whether an Action will break out of a loop. */
|
|
16
16
|
breakLoop?: boolean;
|
|
17
17
|
/** Determines whether an Action will allow Conditional Branching.*/
|
|
18
|
-
allowsBranching?:
|
|
18
|
+
allowsBranching?: TAllowsBranching;
|
|
19
19
|
/** Static Branch names associated with an Action. */
|
|
20
20
|
staticBranchNames?: string[];
|
|
21
21
|
/** The Input associated with Dynamic Branching.*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Inputs, ActionPerformReturn, ActionInputParameters, ActionLogger } from ".";
|
|
2
2
|
/** Definition of the function to perform when an Action is invoked. */
|
|
3
|
-
export declare type ActionPerformFunction<TInputs extends Inputs,
|
|
3
|
+
export declare type ActionPerformFunction<TInputs extends Inputs, TAllowsBranching extends boolean | undefined, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>> = (context: ActionContext, params: ActionInputParameters<TInputs>) => Promise<TReturn>;
|
|
4
4
|
/** Context provided to perform method containing helpers and contextual data */
|
|
5
5
|
export interface ActionContext {
|
|
6
6
|
/** Logger for permanent logging; console calls are also captured */
|
|
@@ -13,9 +13,9 @@ export declare type ComponentDefinition<TPublic extends boolean> = {
|
|
|
13
13
|
/** Defines how the Component is displayed in the Prismatic interface. */
|
|
14
14
|
display: ComponentDisplayDefinition<TPublic>;
|
|
15
15
|
/** Specifies the supported Actions of this Component. */
|
|
16
|
-
actions?: Record<string, ActionDefinition<any>>;
|
|
16
|
+
actions?: Record<string, ActionDefinition<any, boolean, any>>;
|
|
17
17
|
/** Specifies the supported Triggers of this Component. */
|
|
18
|
-
triggers?: Record<string, TriggerDefinition<any>>;
|
|
18
|
+
triggers?: Record<string, TriggerDefinition<any, boolean, any>>;
|
|
19
19
|
/** Specifies the supported Connections of this Component. */
|
|
20
20
|
connections?: ConnectionDefinition[];
|
|
21
21
|
/** Hooks */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionDisplayDefinition, TriggerPerformFunction, Inputs } from ".";
|
|
1
|
+
import { ActionDisplayDefinition, TriggerPerformFunction, Inputs, TriggerResult } from ".";
|
|
2
2
|
declare const optionChoices: readonly ["invalid", "valid", "required"];
|
|
3
3
|
export declare type TriggerOptionChoice = typeof optionChoices[number];
|
|
4
4
|
export declare const TriggerOptionChoices: TriggerOptionChoice[];
|
|
@@ -6,11 +6,11 @@ export declare const TriggerOptionChoices: TriggerOptionChoice[];
|
|
|
6
6
|
* TriggerDefinition is the type of the object that is passed in to `trigger` function to
|
|
7
7
|
* define a component trigger.
|
|
8
8
|
*/
|
|
9
|
-
export interface TriggerDefinition<TInputs extends Inputs
|
|
9
|
+
export interface TriggerDefinition<TInputs extends Inputs, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching>> {
|
|
10
10
|
/** Defines how the Trigger is displayed in the Prismatic interface. */
|
|
11
11
|
display: ActionDisplayDefinition;
|
|
12
12
|
/** Function to perform when this Trigger is invoked. */
|
|
13
|
-
perform: TriggerPerformFunction<
|
|
13
|
+
perform: TriggerPerformFunction<TInputs, TAllowsBranching, TResult>;
|
|
14
14
|
/** InputFields to present in the Prismatic interface for configuration of this Trigger. */
|
|
15
15
|
inputs: TInputs;
|
|
16
16
|
/** Specifies whether this Trigger supports executing the Integration on a recurring schedule. */
|
|
@@ -22,7 +22,7 @@ export interface TriggerDefinition<TInputs extends Inputs> {
|
|
|
22
22
|
/** Specifies whether an Action will break out of a loop. */
|
|
23
23
|
breakLoop?: boolean;
|
|
24
24
|
/** Determines whether this Trigger allows Conditional Branching. */
|
|
25
|
-
allowsBranching?:
|
|
25
|
+
allowsBranching?: TAllowsBranching;
|
|
26
26
|
/** Static Branch names associated with this Trigger. */
|
|
27
27
|
staticBranchNames?: string[];
|
|
28
28
|
/** The Input associated with Dynamic Branching. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Inputs, TriggerResult, ActionInputParameters, ActionContext, TriggerPayload } from ".";
|
|
2
2
|
/** Definition of the function to perform when a Trigger is invoked. */
|
|
3
|
-
export declare type TriggerPerformFunction<T extends Inputs,
|
|
3
|
+
export declare type TriggerPerformFunction<T extends Inputs, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching>> = (context: ActionContext, payload: TriggerPayload, params: ActionInputParameters<T>) => Promise<TResult>;
|