@prismatic-io/spectral 5.4.1 → 6.2.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.
- package/dist/clients/http/index.d.ts +13 -0
- package/dist/clients/http/index.js +46 -0
- package/dist/clients/http/inputs.d.ts +116 -0
- package/dist/clients/http/inputs.js +134 -0
- package/dist/clients/soap/index.js +5 -1
- package/dist/clients/soap/types.js +1 -2
- package/dist/clients/soap/utils.js +12 -12
- package/dist/errors.js +1 -1
- package/dist/index.d.ts +6 -10
- package/dist/index.js +8 -60
- package/dist/serverTypes/convert.d.ts +3 -0
- package/dist/serverTypes/convert.js +60 -0
- package/dist/serverTypes/index.d.ts +178 -0
- package/dist/serverTypes/index.js +8 -0
- package/dist/testing.d.ts +16 -7
- package/dist/testing.js +48 -17
- package/dist/types/ActionDefinition.d.ts +6 -6
- package/dist/types/ActionInputParameters.d.ts +3 -3
- package/dist/types/ActionLogger.d.ts +1 -1
- package/dist/types/ActionLogger.js +1 -1
- package/dist/types/ActionPerformFunction.d.ts +4 -2
- package/dist/types/ActionPerformReturn.d.ts +4 -2
- package/dist/types/ComponentDefinition.d.ts +25 -6
- package/dist/types/DataPayload.d.ts +10 -0
- package/dist/types/DataPayload.js +2 -0
- package/dist/types/Inputs.d.ts +5 -2
- package/dist/types/TriggerDefinition.d.ts +6 -6
- package/dist/types/TriggerPerformFunction.d.ts +1 -1
- package/dist/types/TriggerResult.d.ts +5 -3
- package/dist/types/conditional-logic.d.ts +1 -1
- package/dist/types/conditional-logic.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +6 -15
- package/dist/util.d.ts +9 -3
- package/dist/util.js +20 -7
- package/package.json +27 -45
- package/dist/types/server-types.d.ts +0 -174
- package/dist/types/server-types.js +0 -8
- package/dist/util.test.d.ts +0 -1
- package/dist/util.test.js +0 -305
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
interface DisplayDefinition {
|
|
3
|
+
label: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}
|
|
6
|
+
export 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
|
+
export 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
|
+
export declare type ActionLoggerFunction = (...args: unknown[]) => void;
|
|
34
|
+
export 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
|
+
export 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
|
+
export 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
|
+
export declare type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
94
|
+
export declare type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>;
|
|
95
|
+
export 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
|
+
export declare enum OAuth2Type {
|
|
114
|
+
ClientCredentials = "client_credentials",
|
|
115
|
+
AuthorizationCode = "authorization_code"
|
|
116
|
+
}
|
|
117
|
+
export 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
|
+
export interface ConnectionValue {
|
|
128
|
+
key: string;
|
|
129
|
+
configVarKey: string;
|
|
130
|
+
fields: {
|
|
131
|
+
[key: string]: unknown;
|
|
132
|
+
};
|
|
133
|
+
token?: Record<string, unknown>;
|
|
134
|
+
context?: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
interface ServerPerformDataStructureReturn {
|
|
137
|
+
data: boolean | number | string | Record<string, unknown> | unknown[] | unknown;
|
|
138
|
+
contentType?: string;
|
|
139
|
+
statusCode?: number;
|
|
140
|
+
instanceState?: Record<string, unknown>;
|
|
141
|
+
crossFlowState?: Record<string, unknown>;
|
|
142
|
+
executionState?: Record<string, unknown>;
|
|
143
|
+
}
|
|
144
|
+
interface ServerPerformDataReturn {
|
|
145
|
+
data: Buffer | string | unknown;
|
|
146
|
+
contentType: string;
|
|
147
|
+
statusCode?: number;
|
|
148
|
+
instanceState?: Record<string, unknown>;
|
|
149
|
+
crossFlowState?: Record<string, unknown>;
|
|
150
|
+
executionState?: Record<string, unknown>;
|
|
151
|
+
}
|
|
152
|
+
interface ServerPerformBranchingDataStructureReturn extends ServerPerformDataStructureReturn {
|
|
153
|
+
branch: string;
|
|
154
|
+
}
|
|
155
|
+
interface ServerPerformBranchingDataReturn extends ServerPerformDataReturn {
|
|
156
|
+
branch: string;
|
|
157
|
+
}
|
|
158
|
+
export declare type ActionPerformReturn = ServerPerformDataStructureReturn | ServerPerformBranchingDataStructureReturn | ServerPerformDataReturn | ServerPerformBranchingDataReturn | undefined;
|
|
159
|
+
export declare type ActionPerformFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<ActionPerformReturn>;
|
|
160
|
+
interface InputFieldChoice {
|
|
161
|
+
label: string;
|
|
162
|
+
value: string;
|
|
163
|
+
}
|
|
164
|
+
export interface Input {
|
|
165
|
+
key: string;
|
|
166
|
+
label: string;
|
|
167
|
+
keyLabel?: string;
|
|
168
|
+
type: string;
|
|
169
|
+
collection?: string;
|
|
170
|
+
placeholder?: string;
|
|
171
|
+
default?: unknown;
|
|
172
|
+
comments?: string;
|
|
173
|
+
example?: string;
|
|
174
|
+
required?: boolean;
|
|
175
|
+
model?: InputFieldChoice[];
|
|
176
|
+
language?: string;
|
|
177
|
+
}
|
|
178
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuth2Type = void 0;
|
|
4
|
+
var OAuth2Type;
|
|
5
|
+
(function (OAuth2Type) {
|
|
6
|
+
OAuth2Type["ClientCredentials"] = "client_credentials";
|
|
7
|
+
OAuth2Type["AuthorizationCode"] = "authorization_code";
|
|
8
|
+
})(OAuth2Type = exports.OAuth2Type || (exports.OAuth2Type = {}));
|
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
|
-
|
|
8
|
-
import {
|
|
9
|
-
export declare const createConnection: <T extends
|
|
7
|
+
import { TriggerPayload, TriggerResult, Connection, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn } from "./serverTypes";
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters } from "./types";
|
|
9
|
+
export declare const createConnection: <T extends Connection>({ 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: <T extends Inputs
|
|
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,19 @@ 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
|
|
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
|
+
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
38
|
+
component: TComponent;
|
|
39
|
+
constructor(component: TComponent);
|
|
40
|
+
connectionValue({ key }: ConnectionDefinition): ConnectionValue;
|
|
41
|
+
trigger(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<TriggerResult>;
|
|
42
|
+
action(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<ActionPerformReturn>;
|
|
43
|
+
}
|
|
44
|
+
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
37
45
|
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>>;
|
|
40
46
|
loggerMock: () => ActionLogger;
|
|
47
|
+
invoke: <T extends Inputs>({ perform }: ActionDefinition<T>, params: ActionInputParameters<T>, context?: Partial<ActionContext> | undefined) => Promise<InvokeReturn<import("./types").ActionPerformReturn<boolean | undefined, unknown>>>;
|
|
48
|
+
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>>>;
|
|
49
|
+
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
41
50
|
};
|
|
42
51
|
export default _default;
|
package/dist/testing.js
CHANGED
|
@@ -15,7 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.invokeTrigger = exports.defaultTriggerPayload = exports.invoke = exports.loggerMock = exports.createConnection = void 0;
|
|
18
|
+
exports.createHarness = exports.ComponentTestHarness = exports.invokeTrigger = exports.defaultTriggerPayload = exports.invoke = exports.loggerMock = exports.createConnection = void 0;
|
|
19
19
|
const jest_mock_1 = require("jest-mock");
|
|
20
20
|
const createConnection = ({ key }, values) => ({
|
|
21
21
|
configVarKey: "",
|
|
@@ -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 = (
|
|
47
|
-
const
|
|
48
|
-
const
|
|
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,20 +94,52 @@ 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 = (
|
|
99
|
-
const
|
|
100
|
-
const
|
|
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
|
|
101
|
+
const result = yield perform(realizedContext, realizedPayload, realizedParams);
|
|
104
102
|
return {
|
|
105
103
|
result,
|
|
106
104
|
loggerMock: realizedContext.logger,
|
|
107
105
|
};
|
|
108
106
|
});
|
|
109
107
|
exports.invokeTrigger = invokeTrigger;
|
|
108
|
+
class ComponentTestHarness {
|
|
109
|
+
constructor(component) {
|
|
110
|
+
this.component = component;
|
|
111
|
+
}
|
|
112
|
+
connectionValue({ key }) {
|
|
113
|
+
const { PRISMATIC_CONNECTION_VALUE: value } = process.env;
|
|
114
|
+
if (!value) {
|
|
115
|
+
throw new Error("Unable to find connection value.");
|
|
116
|
+
}
|
|
117
|
+
const result = Object.assign(Object.assign({}, JSON.parse(value)), { key });
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
trigger(key, payload, params, context) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
|
|
123
|
+
const trigger = this.component.triggers[key];
|
|
124
|
+
return trigger.perform(realizedContext, Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), Object.assign({}, params));
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
action(key, params, context) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const realizedContext = Object.assign({ logger: (0, exports.loggerMock)(), instanceState: {}, crossFlowState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
|
|
130
|
+
const action = this.component.actions[key];
|
|
131
|
+
return action.perform(realizedContext, Object.assign({}, params));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.ComponentTestHarness = ComponentTestHarness;
|
|
136
|
+
const createHarness = (component) => {
|
|
137
|
+
return new ComponentTestHarness(component);
|
|
138
|
+
};
|
|
139
|
+
exports.createHarness = createHarness;
|
|
110
140
|
exports.default = {
|
|
141
|
+
loggerMock: exports.loggerMock,
|
|
111
142
|
invoke: exports.invoke,
|
|
112
143
|
invokeTrigger: exports.invokeTrigger,
|
|
113
|
-
|
|
144
|
+
createHarness: exports.createHarness,
|
|
114
145
|
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
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<
|
|
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<
|
|
10
|
+
perform: ActionPerformFunction<this["inputs"], this["allowsBranching"]>;
|
|
11
11
|
/** InputFields to present in the Prismatic interface for configuration of this Action. */
|
|
12
|
-
inputs:
|
|
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?:
|
|
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?:
|
|
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> =
|
|
7
|
+
export declare type ActionInputParameters<TInputs extends Inputs> = {
|
|
8
8
|
[Property in keyof TInputs]: ExtractValue<TInputs[Property]>;
|
|
9
|
-
}
|
|
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"]
|
|
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
|
|
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
|
|
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<
|
|
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,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
/** Defines attributes of a Component. */
|
|
8
|
+
export declare type ComponentDefinition<TPublic extends boolean> = {
|
|
9
|
+
/** Specifies unique key for this Component. */
|
|
10
|
+
key: string;
|
|
11
|
+
/** Specifies if this Component is available for all Organizations or only your own @default false */
|
|
12
|
+
public?: TPublic;
|
|
13
|
+
/** Defines how the Component is displayed in the Prismatic interface. */
|
|
14
|
+
display: ComponentDisplayDefinition<TPublic>;
|
|
15
|
+
/** Specifies the supported Actions of this Component. */
|
|
16
|
+
actions?: Record<string, ActionDefinition<any>>;
|
|
17
|
+
/** Specifies the supported Triggers of this Component. */
|
|
18
|
+
triggers?: Record<string, TriggerDefinition<any>>;
|
|
19
|
+
/** Specifies the supported Connections of this Component. */
|
|
6
20
|
connections?: ConnectionDefinition[];
|
|
7
|
-
|
|
21
|
+
/** Hooks */
|
|
22
|
+
hooks?: ComponentHooks;
|
|
23
|
+
} & (TPublic extends true ? {
|
|
24
|
+
/** Specified the URL for the Component Documentation. */
|
|
25
|
+
documentationUrl: string;
|
|
26
|
+
} : unknown);
|
|
@@ -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
|
+
}
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -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 {
|
|
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<
|
|
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<
|
|
13
|
+
perform: TriggerPerformFunction<this["inputs"], this["allowsBranching"]>;
|
|
14
14
|
/** InputFields to present in the Prismatic interface for configuration of this Trigger. */
|
|
15
|
-
inputs:
|
|
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?:
|
|
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?:
|
|
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
|
|
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
|
|
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;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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";
|