@prismatic-io/spectral 5.4.1 → 6.1.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.
Files changed (40) hide show
  1. package/dist/clients/http/index.d.ts +13 -0
  2. package/dist/clients/http/index.js +46 -0
  3. package/dist/clients/http/inputs.d.ts +116 -0
  4. package/dist/clients/http/inputs.js +134 -0
  5. package/dist/clients/soap/index.js +5 -1
  6. package/dist/clients/soap/types.js +1 -2
  7. package/dist/clients/soap/utils.js +12 -12
  8. package/dist/errors.js +1 -1
  9. package/dist/index.d.ts +6 -10
  10. package/dist/index.js +8 -60
  11. package/dist/serverTypes/convert.d.ts +3 -0
  12. package/dist/serverTypes/convert.js +60 -0
  13. package/dist/serverTypes/index.d.ts +169 -0
  14. package/dist/serverTypes/index.js +7 -0
  15. package/dist/testing.d.ts +5 -5
  16. package/dist/testing.js +13 -15
  17. package/dist/types/ActionDefinition.d.ts +6 -6
  18. package/dist/types/ActionInputParameters.d.ts +3 -3
  19. package/dist/types/ActionLogger.d.ts +1 -1
  20. package/dist/types/ActionLogger.js +1 -1
  21. package/dist/types/ActionPerformFunction.d.ts +4 -2
  22. package/dist/types/ActionPerformReturn.d.ts +4 -2
  23. package/dist/types/ComponentDefinition.d.ts +28 -6
  24. package/dist/types/DataPayload.d.ts +10 -0
  25. package/dist/types/DataPayload.js +2 -0
  26. package/dist/types/Inputs.d.ts +5 -2
  27. package/dist/types/TriggerDefinition.d.ts +6 -6
  28. package/dist/types/TriggerPerformFunction.d.ts +1 -1
  29. package/dist/types/TriggerResult.d.ts +5 -3
  30. package/dist/types/conditional-logic.d.ts +1 -1
  31. package/dist/types/conditional-logic.js +1 -1
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/index.js +6 -15
  34. package/dist/util.d.ts +9 -3
  35. package/dist/util.js +20 -7
  36. package/package.json +27 -45
  37. package/dist/types/server-types.d.ts +0 -174
  38. package/dist/types/server-types.js +0 -8
  39. package/dist/util.test.d.ts +0 -1
  40. package/dist/util.test.js +0 -305
@@ -0,0 +1,169 @@
1
+ /// <reference types="node" />
2
+ interface DisplayDefinition {
3
+ label: string;
4
+ description: string;
5
+ }
6
+ interface Component {
7
+ key: string;
8
+ public?: boolean;
9
+ documentationUrl?: string;
10
+ display: DisplayDefinition & {
11
+ category?: string;
12
+ iconPath?: string;
13
+ };
14
+ actions: Record<string, Action>;
15
+ triggers: Record<string, Trigger>;
16
+ connections: Connection[];
17
+ }
18
+ interface Action {
19
+ key: string;
20
+ display: DisplayDefinition & {
21
+ directions?: string;
22
+ important?: boolean;
23
+ };
24
+ inputs: Input[];
25
+ terminateExecution?: boolean;
26
+ breakLoop?: boolean;
27
+ allowsBranching?: boolean;
28
+ staticBranchNames?: string[];
29
+ dynamicBranchInput?: string;
30
+ perform: ActionPerformFunction;
31
+ examplePayload?: unknown;
32
+ }
33
+ declare type ActionLoggerFunction = (...args: unknown[]) => void;
34
+ interface ActionLogger {
35
+ metric: ActionLoggerFunction;
36
+ trace: ActionLoggerFunction;
37
+ debug: ActionLoggerFunction;
38
+ info: ActionLoggerFunction;
39
+ log: ActionLoggerFunction;
40
+ warn: ActionLoggerFunction;
41
+ error: ActionLoggerFunction;
42
+ }
43
+ interface ActionContext {
44
+ logger: ActionLogger;
45
+ instanceState: Record<string, unknown>;
46
+ crossFlowState: Record<string, unknown>;
47
+ executionState: Record<string, unknown>;
48
+ stepId: string;
49
+ executionId: string;
50
+ }
51
+ declare type TriggerOptionChoice = "invalid" | "valid" | "required";
52
+ interface TriggerPayload {
53
+ headers: Record<string, string>;
54
+ queryParameters: Record<string, string>;
55
+ rawBody: {
56
+ data: unknown;
57
+ contentType?: string;
58
+ };
59
+ body: {
60
+ data: unknown;
61
+ contentType?: string;
62
+ };
63
+ webhookUrls: Record<string, string>;
64
+ webhookApiKeys: Record<string, string[]>;
65
+ invokeUrl: string;
66
+ executionId: string;
67
+ customer: {
68
+ id: string | null;
69
+ externalId: string | null;
70
+ name: string | null;
71
+ };
72
+ instance: {
73
+ id: string | null;
74
+ name: string | null;
75
+ };
76
+ }
77
+ interface HttpResponse {
78
+ statusCode: number;
79
+ contentType: string;
80
+ headers?: Record<string, string>;
81
+ body?: string;
82
+ }
83
+ interface TriggerBaseResult {
84
+ payload: TriggerPayload;
85
+ response?: HttpResponse;
86
+ instanceState?: Record<string, unknown>;
87
+ crossFlowState?: Record<string, unknown>;
88
+ executionState?: Record<string, unknown>;
89
+ }
90
+ interface TriggerBranchingResult extends TriggerBaseResult {
91
+ branch: string;
92
+ }
93
+ declare type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
94
+ declare type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>;
95
+ interface Trigger {
96
+ key: string;
97
+ display: DisplayDefinition & {
98
+ directions?: string;
99
+ important?: boolean;
100
+ };
101
+ inputs: Input[];
102
+ terminateExecution?: boolean;
103
+ breakLoop?: boolean;
104
+ allowsBranching?: boolean;
105
+ staticBranchNames?: string[];
106
+ dynamicBranchInput?: string;
107
+ perform: TriggerPerformFunction;
108
+ scheduleSupport: TriggerOptionChoice;
109
+ synchronousResponseSupport: TriggerOptionChoice;
110
+ examplePayload?: unknown;
111
+ isCommonTrigger?: boolean;
112
+ }
113
+ declare enum OAuth2Type {
114
+ ClientCredentials = "client_credentials",
115
+ AuthorizationCode = "authorization_code"
116
+ }
117
+ interface Connection {
118
+ key: string;
119
+ label: string;
120
+ comments?: string;
121
+ oauth2Type?: OAuth2Type;
122
+ iconPath?: string;
123
+ inputs: (Input & {
124
+ shown?: boolean;
125
+ })[];
126
+ }
127
+ interface ServerPerformDataStructureReturn {
128
+ data: boolean | number | string | Record<string, unknown> | unknown[] | unknown;
129
+ contentType?: string;
130
+ statusCode?: number;
131
+ instanceState?: Record<string, unknown>;
132
+ crossFlowState?: Record<string, unknown>;
133
+ executionState?: Record<string, unknown>;
134
+ }
135
+ interface ServerPerformDataReturn {
136
+ data: Buffer | string | unknown;
137
+ contentType: string;
138
+ statusCode?: number;
139
+ instanceState?: Record<string, unknown>;
140
+ crossFlowState?: Record<string, unknown>;
141
+ executionState?: Record<string, unknown>;
142
+ }
143
+ interface ServerPerformBranchingDataStructureReturn extends ServerPerformDataStructureReturn {
144
+ branch: string;
145
+ }
146
+ interface ServerPerformBranchingDataReturn extends ServerPerformDataReturn {
147
+ branch: string;
148
+ }
149
+ declare type ActionPerformReturn = ServerPerformDataStructureReturn | ServerPerformBranchingDataStructureReturn | ServerPerformDataReturn | ServerPerformBranchingDataReturn | undefined;
150
+ declare type ActionPerformFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<ActionPerformReturn>;
151
+ interface InputFieldChoice {
152
+ label: string;
153
+ value: string;
154
+ }
155
+ interface Input {
156
+ key: string;
157
+ label: string;
158
+ keyLabel?: string;
159
+ type: string;
160
+ collection?: string;
161
+ placeholder?: string;
162
+ default?: unknown;
163
+ comments?: string;
164
+ example?: string;
165
+ required?: boolean;
166
+ model?: InputFieldChoice[];
167
+ language?: string;
168
+ }
169
+ export type { Component, Trigger, Action, Connection, Input };
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var OAuth2Type;
4
+ (function (OAuth2Type) {
5
+ OAuth2Type["ClientCredentials"] = "client_credentials";
6
+ OAuth2Type["AuthorizationCode"] = "authorization_code";
7
+ })(OAuth2Type || (OAuth2Type = {}));
package/dist/testing.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
6
6
  */
7
7
  /** */
8
- import { ActionContext, ActionLogger, ActionDefinition, ActionInputParameters, ConnectionDefinition, Connection, ActionPerformReturn, Inputs, TriggerDefinition, TriggerResult, TriggerPayload } from "./types";
8
+ import { ActionContext, ActionLogger, ActionDefinition, ActionInputParameters, ConnectionDefinition, Connection, Inputs, TriggerDefinition, TriggerPayload } from "./types";
9
9
  export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>) => Connection;
10
10
  /**
11
11
  * Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
@@ -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: <T extends Inputs, AllowsBranching extends boolean, ReturnData extends ActionPerformReturn<AllowsBranching, unknown>>(actionBase: ActionDefinition<T, AllowsBranching, ReturnData> | Record<string, ActionDefinition<T, AllowsBranching, ReturnData>>, params: ActionInputParameters<T>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<ReturnData>>;
28
+ export declare const invoke: <T extends Inputs>({ perform }: ActionDefinition<T>, params: ActionInputParameters<T>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<import("./types").ActionPerformReturn<boolean | undefined, unknown>>>;
29
29
  export declare const defaultTriggerPayload: () => TriggerPayload;
30
30
  /**
31
31
  * Invokes specified TriggerDefinition perform function using supplied params
@@ -33,10 +33,10 @@ 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: <T extends Inputs, AllowsBranching extends boolean, Result extends TriggerResult<AllowsBranching>>(triggerBase: TriggerDefinition<T, AllowsBranching, Result> | Record<string, TriggerDefinition<T, AllowsBranching, Result>>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<T> | undefined) => Promise<InvokeReturn<Result>>;
36
+ export declare const invokeTrigger: <T extends Inputs>({ perform }: TriggerDefinition<T>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<T> | undefined) => Promise<InvokeReturn<import("./types").TriggerResult<boolean | undefined>>>;
37
37
  declare const _default: {
38
- invoke: <T extends Inputs, AllowsBranching extends boolean, ReturnData extends ActionPerformReturn<AllowsBranching, unknown>>(actionBase: ActionDefinition<T, AllowsBranching, ReturnData> | Record<string, ActionDefinition<T, AllowsBranching, ReturnData>>, params: ActionInputParameters<T>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<ReturnData>>;
39
- invokeTrigger: <T_1 extends Inputs, AllowsBranching_1 extends boolean, Result extends TriggerResult<AllowsBranching_1>>(triggerBase: TriggerDefinition<T_1, AllowsBranching_1, Result> | Record<string, TriggerDefinition<T_1, AllowsBranching_1, Result>>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<T_1> | undefined) => Promise<InvokeReturn<Result>>;
38
+ invoke: <T extends Inputs>({ perform }: ActionDefinition<T>, params: ActionInputParameters<T>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<import("./types").ActionPerformReturn<boolean | undefined, unknown>>>;
39
+ invokeTrigger: <T_1 extends Inputs>({ perform }: TriggerDefinition<T_1>, context?: Partial<ActionContext> | undefined, payload?: TriggerPayload | undefined, params?: ActionInputParameters<T_1> | undefined) => Promise<InvokeReturn<import("./types").TriggerResult<boolean | undefined>>>;
40
40
  loggerMock: () => ActionLogger;
41
41
  };
42
42
  export default _default;
package/dist/testing.js CHANGED
@@ -29,12 +29,12 @@ exports.createConnection = createConnection;
29
29
  */
30
30
  const loggerMock = () => ({
31
31
  metric: console.log,
32
- trace: jest_mock_1.spyOn(console, "trace"),
33
- debug: jest_mock_1.spyOn(console, "debug"),
34
- info: jest_mock_1.spyOn(console, "info"),
35
- log: jest_mock_1.spyOn(console, "log"),
36
- warn: jest_mock_1.spyOn(console, "warn"),
37
- error: jest_mock_1.spyOn(console, "error"),
32
+ trace: (0, jest_mock_1.spyOn)(console, "trace"),
33
+ debug: (0, jest_mock_1.spyOn)(console, "debug"),
34
+ info: (0, jest_mock_1.spyOn)(console, "info"),
35
+ log: (0, jest_mock_1.spyOn)(console, "log"),
36
+ warn: (0, jest_mock_1.spyOn)(console, "warn"),
37
+ error: (0, jest_mock_1.spyOn)(console, "error"),
38
38
  });
39
39
  exports.loggerMock = loggerMock;
40
40
  /**
@@ -43,10 +43,9 @@ exports.loggerMock = loggerMock;
43
43
  * to avoid extra casting within test methods. Returns an InvokeResult containing both the
44
44
  * action result and a mock logger for asserting logging.
45
45
  */
46
- const invoke = (actionBase, params, context) => __awaiter(void 0, void 0, void 0, function* () {
47
- const action = (actionBase.perform ? actionBase : Object.values(actionBase)[0]);
48
- const realizedContext = Object.assign({ logger: exports.loggerMock(), instanceState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
49
- const result = yield action.perform(realizedContext, params);
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);
48
+ const result = yield perform(realizedContext, params);
50
49
  return {
51
50
  result,
52
51
  loggerMock: realizedContext.logger,
@@ -95,12 +94,11 @@ exports.defaultTriggerPayload = defaultTriggerPayload;
95
94
  * to avoid extra casting within test methods. Returns an InvokeResult containing both the
96
95
  * trigger result and a mock logger for asserting logging.
97
96
  */
98
- const invokeTrigger = (triggerBase, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
99
- const trigger = (triggerBase.perform ? triggerBase : Object.values(triggerBase)[0]);
100
- const realizedContext = Object.assign({ logger: exports.loggerMock(), instanceState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
101
- const realizedPayload = Object.assign(Object.assign({}, exports.defaultTriggerPayload()), payload);
97
+ const invokeTrigger = ({ perform }, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
98
+ const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
99
+ const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
102
100
  const realizedParams = params || {};
103
- const result = yield trigger.perform(realizedContext, realizedPayload, realizedParams);
101
+ const result = yield perform(realizedContext, realizedPayload, realizedParams);
104
102
  return {
105
103
  result,
106
104
  loggerMock: realizedContext.logger,
@@ -1,25 +1,25 @@
1
- import { ActionPerformReturn, ActionDisplayDefinition, ActionPerformFunction, Inputs } from ".";
1
+ import { ActionDisplayDefinition, ActionPerformFunction, 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<T extends Inputs, AllowsBranching extends boolean, ReturnData extends ActionPerformReturn<AllowsBranching, unknown>> {
6
+ export interface ActionDefinition<TInputs extends Inputs> {
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<T, AllowsBranching, ReturnData>;
10
+ perform: ActionPerformFunction<this["inputs"], this["allowsBranching"]>;
11
11
  /** InputFields to present in the Prismatic interface for configuration of this Action. */
12
- inputs: T;
12
+ inputs: TInputs;
13
13
  /** Optional attribute that specifies whether an Action will terminate execution.*/
14
14
  terminateExecution?: boolean;
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?: AllowsBranching;
18
+ allowsBranching?: boolean;
19
19
  /** Static Branch names associated with an Action. */
20
20
  staticBranchNames?: string[];
21
21
  /** The Input associated with Dynamic Branching.*/
22
22
  dynamicBranchInput?: string;
23
23
  /** An example of the payload outputted by an Action*/
24
- examplePayload?: ReturnData;
24
+ examplePayload?: Awaited<ReturnType<this["perform"]>>;
25
25
  }
@@ -4,11 +4,11 @@ import { InputFieldDefinition, Inputs, InputFieldTypeMap } from ".";
4
4
  * Inputs can be static values, references to config variables, or
5
5
  * references to previous steps' outputs.
6
6
  */
7
- export declare type ActionInputParameters<TInputs extends Inputs> = TInputs extends Record<string, InputFieldDefinition> ? {
7
+ export declare type ActionInputParameters<TInputs extends Inputs> = {
8
8
  [Property in keyof TInputs]: ExtractValue<TInputs[Property]>;
9
- } : never;
9
+ };
10
10
  export declare type ExtractValue<TValue extends InputFieldDefinition> = MapCollectionValues<InputFieldTypeMap[TValue["type"]], TValue["collection"]>;
11
- export declare type MapCollectionValues<TType, TCollection extends InputFieldDefinition["collection"] | undefined> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] | undefined : TCollection extends "valuelist" ? TType[] | undefined : TType;
11
+ export declare type MapCollectionValues<TType, TCollection extends InputFieldDefinition["collection"]> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] : TCollection extends "valuelist" ? TType[] : TType;
12
12
  /**
13
13
  * KeyValuePair input parameter type.
14
14
  * This allows users to input multiple keys / values as an input.
@@ -2,7 +2,7 @@
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-components/writing-custom-components/#contextlogger
6
6
  */
7
7
  /**
8
8
  * A logger function, similar to `console.log()` or `console.error()`.
@@ -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-components/writing-custom-components/#contextlogger
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +1,14 @@
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<T extends Inputs, AllowsBranching extends boolean, ReturnData extends ActionPerformReturn<AllowsBranching, unknown>> = (context: ActionContext, params: ActionInputParameters<T>) => Promise<ReturnData>;
3
+ export declare type ActionPerformFunction<TInputs extends Inputs, AllowsBranching extends boolean | undefined> = (context: ActionContext, params: ActionInputParameters<TInputs>) => Promise<ActionPerformReturn<AllowsBranching, unknown>>;
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 */
7
7
  logger: ActionLogger;
8
- /** A key/value store that may be used to store small amounts of data that is persisted between Instance executions */
8
+ /** A a flow-specific key/value store that may be used to store small amounts of data that is persisted between Instance executions */
9
9
  instanceState: Record<string, unknown>;
10
+ /** An key/value store what is shared between flows on an Instance that may be used to store small amounts of data that is persisted between Instance executions */
11
+ crossFlowState: Record<string, unknown>;
10
12
  /** A key/value store that may be used to store small amounts of data for use later during the execution */
11
13
  executionState: Record<string, unknown>;
12
14
  /** A unique id that corresponds to the step on the Integration */
@@ -6,8 +6,10 @@ export interface ActionPerformDataReturn<ReturnData> {
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
- /** An optional object, the keys and values of which will be persisted in the instanceState and available for subsequent actions and executions */
9
+ /** An optional object, the keys and values of which will be persisted in the flow-specific instanceState and available for subsequent actions and executions */
10
10
  instanceState?: Record<string, unknown>;
11
+ /** 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 */
12
+ crossFlowState: Record<string, unknown>;
11
13
  /** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
12
14
  executionState?: Record<string, unknown>;
13
15
  }
@@ -18,4 +20,4 @@ export interface ActionPerformBranchingDataReturn<ReturnData> extends ActionPerf
18
20
  branch: string;
19
21
  }
20
22
  /** Required return type of all action perform functions */
21
- export declare type ActionPerformReturn<AllowsBranching extends boolean, ReturnData> = (AllowsBranching extends true ? ActionPerformBranchingDataReturn<ReturnData> : ActionPerformDataReturn<ReturnData>) | undefined;
23
+ export declare type ActionPerformReturn<AllowsBranching extends boolean | undefined, ReturnData> = (AllowsBranching extends true ? ActionPerformBranchingDataReturn<ReturnData> : ActionPerformDataReturn<ReturnData>) | undefined;
@@ -1,7 +1,29 @@
1
- import { Component } from "./server-types";
2
- import { ActionPerformReturn, ActionDefinition, ConnectionDefinition, TriggerDefinition, TriggerResult } from ".";
3
- export declare type ComponentDefinition<T extends boolean> = Omit<Component<T>, "actions" | "triggers" | "connections"> & {
4
- actions?: Record<string, ActionDefinition<any, boolean, ActionPerformReturn<boolean, any>>>;
5
- triggers?: Record<string, TriggerDefinition<any, boolean, TriggerResult<boolean>>>;
1
+ import { ActionDefinition, ConnectionDefinition, ComponentDisplayDefinition, TriggerDefinition } from ".";
2
+ export declare type ErrorHandler = (error: unknown) => unknown;
3
+ export interface ComponentHooks {
4
+ /** Defines a global error handler that automatically wraps the component's action/trigger perform functions. */
5
+ error?: ErrorHandler;
6
+ }
7
+ interface BaseComponentDefinition<TPublic extends boolean = false> {
8
+ /** Specifies unique key for this Component. */
9
+ key: string;
10
+ /** Specifies if this Component is available for all Organizations or only your own @default false */
11
+ public?: TPublic;
12
+ /** Specified the URL for the Component Documentation. */
13
+ documentationUrl?: string;
14
+ /** Defines how the Component is displayed in the Prismatic interface. */
15
+ display: ComponentDisplayDefinition<TPublic>;
16
+ /** Specifies the supported Actions of this Component. */
17
+ actions?: Record<string, ActionDefinition<any>>;
18
+ /** Specifies the supported Triggers of this Component. */
19
+ triggers?: Record<string, TriggerDefinition<any>>;
20
+ /** Specifies the supported Connections of this Component. */
6
21
  connections?: ConnectionDefinition[];
7
- };
22
+ /** Hooks */
23
+ hooks?: ComponentHooks;
24
+ }
25
+ /** Defines attributes of a Component. */
26
+ export declare type ComponentDefinition<TPublic extends boolean = false> = BaseComponentDefinition<TPublic> & (TPublic extends true ? {
27
+ documentationUrl: string;
28
+ } : unknown);
29
+ export {};
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
2
+ /** Binary data payload */
3
+ export interface DataPayload {
4
+ /** Raw binary data as a Buffer */
5
+ data: Buffer;
6
+ /** Content type of data contained within this payload */
7
+ contentType: string;
8
+ /** Suggested extension to use when writing the data */
9
+ suggestedExtension?: string;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -24,17 +24,20 @@ interface BaseInputFieldDefinition {
24
24
  example?: string;
25
25
  /** Indicate if this InputField is required. */
26
26
  required?: boolean;
27
- /** Dictates possible choices for the input. */
28
- model?: InputFieldChoice[];
29
27
  }
30
28
  /** Defines attributes of a InputField. */
31
29
  export interface DefaultInputFieldDefinition extends BaseInputFieldDefinition {
32
30
  type: Exclude<InputFieldType, "code" | "conditional" | "connection">;
31
+ /** Dictates possible choices for the input. */
32
+ model?: InputFieldChoice[];
33
33
  }
34
34
  /** Defines attributes of a CodeInputField. */
35
35
  export interface CodeInputFieldDefinition extends BaseInputFieldDefinition {
36
36
  type: Extract<InputFieldType, "code">;
37
+ /** Code language of this field. */
37
38
  language?: string;
39
+ /** Dictates possible choices for the input. */
40
+ model?: InputFieldChoice[];
38
41
  }
39
42
  /** Defines attributes of a ConditionalInputField. */
40
43
  export interface ConditionalInputField extends BaseInputFieldDefinition {
@@ -1,4 +1,4 @@
1
- import { TriggerResult, ActionDisplayDefinition, TriggerPerformFunction, Inputs } from ".";
1
+ import { ActionDisplayDefinition, TriggerPerformFunction, Inputs } 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,13 +6,13 @@ 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<T extends Inputs, AllowsBranching extends boolean, Result extends TriggerResult<AllowsBranching>> {
9
+ export interface TriggerDefinition<TInputs extends Inputs> {
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<T, AllowsBranching, Result>;
13
+ perform: TriggerPerformFunction<this["inputs"], this["allowsBranching"]>;
14
14
  /** InputFields to present in the Prismatic interface for configuration of this Trigger. */
15
- inputs: T;
15
+ inputs: TInputs;
16
16
  /** Specifies whether this Trigger supports executing the Integration on a recurring schedule. */
17
17
  scheduleSupport: TriggerOptionChoice;
18
18
  /** Specifies whether this Trigger supports synchronous responses to an Integration webhook request. */
@@ -22,13 +22,13 @@ export interface TriggerDefinition<T extends Inputs, AllowsBranching extends boo
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?: AllowsBranching;
25
+ allowsBranching?: boolean;
26
26
  /** Static Branch names associated with this Trigger. */
27
27
  staticBranchNames?: string[];
28
28
  /** The Input associated with Dynamic Branching. */
29
29
  dynamicBranchInput?: string;
30
30
  /** An example of the payload outputted by this Trigger. */
31
- examplePayload?: Result;
31
+ examplePayload?: Awaited<ReturnType<this["perform"]>>;
32
32
  /** Specifies if this Trigger appears in the list of 'common' Triggers. Only configurable by Prismatic. @default false */
33
33
  isCommonTrigger?: boolean;
34
34
  }
@@ -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, AllowsBranching extends boolean, Result extends TriggerResult<AllowsBranching>> = (context: ActionContext, payload: TriggerPayload, params: ActionInputParameters<T>) => Promise<Result>;
3
+ export declare type TriggerPerformFunction<T extends Inputs, AllowsBranching extends boolean | undefined> = (context: ActionContext, payload: TriggerPayload, params: ActionInputParameters<T>) => Promise<TriggerResult<AllowsBranching>>;
@@ -2,12 +2,14 @@ import { TriggerPayload } from "./TriggerPayload";
2
2
  import { HttpResponse } from "./HttpResponse";
3
3
  /** Represents the result of a Trigger action. */
4
4
  export interface TriggerBaseResult {
5
- /** The payload in the requst that invoked the Integration, which is returned as a result for later use. */
5
+ /** The payload in the request that invoked the Integration, which is returned as a result for later use. */
6
6
  payload: TriggerPayload;
7
7
  /** Optional HTTP response to the request that invoked the integration. */
8
8
  response?: HttpResponse;
9
- /** An optional object, the keys and values of which will be persisted in the instanceState and available for subsequent actions and executions */
9
+ /** An optional object, the keys and values of which will be persisted in the flow-specific instanceState and available for subsequent actions and executions */
10
10
  instanceState?: Record<string, unknown>;
11
+ /** 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 */
12
+ crossFlowState: Record<string, unknown>;
11
13
  /** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
12
14
  executionState?: Record<string, unknown>;
13
15
  }
@@ -17,4 +19,4 @@ export interface TriggerBranchingResult extends TriggerBaseResult {
17
19
  branch: string;
18
20
  }
19
21
  /** Required return type of all trigger perform functions */
20
- export declare type TriggerResult<AllowsBranching extends boolean> = (AllowsBranching extends true ? TriggerBranchingResult : TriggerBaseResult) | undefined;
22
+ export declare type TriggerResult<AllowsBranching extends boolean | undefined> = (AllowsBranching extends true ? TriggerBranchingResult : TriggerBaseResult) | undefined;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * This file contains types to help define conditional logic for the Prismatic
3
- * branch component, https://prismatic.io/docs/components/branch
3
+ * branch component, https://prismatic.io/docs/components/branch/
4
4
  */
5
5
  /** @ignore */
6
6
  export declare enum BooleanOperator {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  /**
3
3
  * This file contains types to help define conditional logic for the Prismatic
4
- * branch component, https://prismatic.io/docs/components/branch
4
+ * branch component, https://prismatic.io/docs/components/branch/
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TermOperatorPhrase = exports.BinaryOperatorPhrase = exports.BinaryOperator = exports.UnaryOperatorPhrase = exports.UnaryOperator = exports.BooleanOperatorPhrase = exports.BooleanOperator = void 0;
@@ -7,6 +7,7 @@ export * from "./ComponentDefinition";
7
7
  export * from "./ConnectionDefinition";
8
8
  export * from "./Inputs";
9
9
  export * from "./ActionPerformReturn";
10
+ export * from "./DataPayload";
10
11
  export * from "./DisplayDefinition";
11
12
  export * from "./ActionInputParameters";
12
13
  export * from "./ActionLogger";
@@ -18,4 +19,3 @@ export * from "./TriggerPerformFunction";
18
19
  export * from "./TriggerDefinition";
19
20
  export * from "./HttpResponse";
20
21
  export * from "./TriggerPayload";
21
- export * as serverTypes from "./server-types";
@@ -5,33 +5,25 @@
5
5
  */
6
6
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
7
  if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
9
13
  }) : (function(o, m, k, k2) {
10
14
  if (k2 === undefined) k2 = k;
11
15
  o[k2] = m[k];
12
16
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
17
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
19
  };
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
20
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.serverTypes = void 0;
30
21
  __exportStar(require("./ActionDefinition"), exports);
31
22
  __exportStar(require("./ComponentDefinition"), exports);
32
23
  __exportStar(require("./ConnectionDefinition"), exports);
33
24
  __exportStar(require("./Inputs"), exports);
34
25
  __exportStar(require("./ActionPerformReturn"), exports);
26
+ __exportStar(require("./DataPayload"), exports);
35
27
  __exportStar(require("./DisplayDefinition"), exports);
36
28
  __exportStar(require("./ActionInputParameters"), exports);
37
29
  __exportStar(require("./ActionLogger"), exports);
@@ -43,4 +35,3 @@ __exportStar(require("./TriggerPerformFunction"), exports);
43
35
  __exportStar(require("./TriggerDefinition"), exports);
44
36
  __exportStar(require("./HttpResponse"), exports);
45
37
  __exportStar(require("./TriggerPayload"), exports);
46
- exports.serverTypes = __importStar(require("./server-types"));
package/dist/util.d.ts CHANGED
@@ -3,8 +3,13 @@
3
3
  * Many functions in the `util` module are used to coerce data into a particular type, and can be accessed through `util.types`.
4
4
  * For example, `util.types.toInt("5.5")` will return an integer, `5`.
5
5
  */
6
- import { DataPayload } from "./types/server-types";
7
- import { KeyValuePair } from "./types";
6
+ import { KeyValuePair, DataPayload } from "./types";
7
+ /** This function accepts an arbitrary object/value and safely serializes it (handles cyclic references).
8
+ *
9
+ * @param value Arbitrary object/value to serialize.
10
+ * @returns JSON serialized text that can be safely logged.
11
+ */
12
+ export declare const toJSON: (value: unknown) => string;
8
13
  /**
9
14
  * This function returns a lower cased version of the headers passed to it.
10
15
  *
@@ -33,8 +38,9 @@ declare const _default: {
33
38
  isData: (value: unknown) => boolean;
34
39
  toData: (value: unknown) => DataPayload;
35
40
  toString: (value: unknown, defaultValue?: string) => string;
36
- keyValPairListToObject: (kvpList?: KeyValuePair<unknown>[]) => Record<string, unknown>;
41
+ keyValPairListToObject: <TValue = unknown>(kvpList?: KeyValuePair<unknown>[], valueConverter?: ((value: unknown) => TValue) | undefined) => Record<string, TValue>;
37
42
  isJSON: (value: string) => boolean;
43
+ toJSON: (value: unknown) => string;
38
44
  lowerCaseHeaders: (headers: Record<string, string>) => Record<string, string>;
39
45
  };
40
46
  docs: {