@prismatic-io/spectral 7.0.3-pre → 7.0.6-pre
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/serverTypes/index.d.ts +9 -22
- package/dist/serverTypes/perform.js +4 -0
- package/dist/testing.d.ts +8 -9
- package/dist/testing.js +8 -14
- package/dist/types/ActionPerformFunction.d.ts +5 -12
- package/dist/types/Customer.d.ts +6 -0
- package/dist/types/Customer.js +2 -0
- package/dist/types/DataSourceDefinition.d.ts +2 -0
- package/dist/types/DataSourcePerformFunction.d.ts +2 -2
- package/dist/types/DataSourceResult.d.ts +5 -3
- package/dist/types/Inputs.d.ts +5 -0
- package/dist/types/Instance.d.ts +5 -0
- package/dist/types/Instance.js +2 -0
- package/dist/types/TriggerPayload.d.ts +5 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { DataSourceResultType, DataSourceResultFieldType } from "../types";
|
|
2
|
+
import { DataSourceResultType, DataSourceResultFieldType, Instance, Customer } from "../types";
|
|
3
3
|
interface DisplayDefinition {
|
|
4
4
|
label: string;
|
|
5
5
|
description: string;
|
|
6
6
|
}
|
|
7
|
+
export { Instance } from "../types";
|
|
8
|
+
export { Customer } from "../types";
|
|
7
9
|
export interface Component {
|
|
8
10
|
key: string;
|
|
9
11
|
public?: boolean;
|
|
@@ -52,15 +54,8 @@ export interface ActionContext {
|
|
|
52
54
|
webhookUrls: Record<string, string>;
|
|
53
55
|
webhookApiKeys: Record<string, string[]>;
|
|
54
56
|
invokeUrl: string;
|
|
55
|
-
customer:
|
|
56
|
-
|
|
57
|
-
externalId: string | null;
|
|
58
|
-
name: string | null;
|
|
59
|
-
};
|
|
60
|
-
instance: {
|
|
61
|
-
id: string | null;
|
|
62
|
-
name: string | null;
|
|
63
|
-
};
|
|
57
|
+
customer: Customer;
|
|
58
|
+
instance: Instance;
|
|
64
59
|
}
|
|
65
60
|
declare type TriggerOptionChoice = "invalid" | "valid" | "required";
|
|
66
61
|
export interface TriggerPayload {
|
|
@@ -79,15 +74,8 @@ export interface TriggerPayload {
|
|
|
79
74
|
webhookApiKeys: Record<string, string[]>;
|
|
80
75
|
invokeUrl: string;
|
|
81
76
|
executionId: string;
|
|
82
|
-
customer:
|
|
83
|
-
|
|
84
|
-
externalId: string | null;
|
|
85
|
-
name: string | null;
|
|
86
|
-
};
|
|
87
|
-
instance: {
|
|
88
|
-
id: string | null;
|
|
89
|
-
name: string | null;
|
|
90
|
-
};
|
|
77
|
+
customer: Customer;
|
|
78
|
+
instance: Instance;
|
|
91
79
|
}
|
|
92
80
|
interface HttpResponse {
|
|
93
81
|
statusCode: number;
|
|
@@ -129,12 +117,12 @@ export interface Trigger {
|
|
|
129
117
|
}
|
|
130
118
|
export declare type DataSourceResult = {
|
|
131
119
|
result: DataSourceResultType;
|
|
132
|
-
supplementalData
|
|
120
|
+
supplementalData?: {
|
|
133
121
|
data: unknown;
|
|
134
122
|
contentType: string;
|
|
135
123
|
};
|
|
136
124
|
};
|
|
137
|
-
export declare type DataSourcePerformFunction = (
|
|
125
|
+
export declare type DataSourcePerformFunction = (params: Record<string, unknown>) => Promise<DataSourceResult>;
|
|
138
126
|
export interface DataSource {
|
|
139
127
|
key: string;
|
|
140
128
|
display: DisplayDefinition & {
|
|
@@ -215,4 +203,3 @@ export interface Input {
|
|
|
215
203
|
model?: InputFieldChoice[];
|
|
216
204
|
language?: string;
|
|
217
205
|
}
|
|
218
|
-
export {};
|
|
@@ -22,6 +22,10 @@ const cleanParams = (params, cleaners) => Object.entries(params).reduce((result,
|
|
|
22
22
|
const createPerform = (performFn, { inputCleaners, errorHandler }) => {
|
|
23
23
|
return (...args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
|
+
if (args.length === 1) {
|
|
26
|
+
const [params] = args;
|
|
27
|
+
return yield performFn(cleanParams(params, inputCleaners));
|
|
28
|
+
}
|
|
25
29
|
if (args.length === 2) {
|
|
26
30
|
const [context, params] = args;
|
|
27
31
|
return yield performFn(context, cleanParams(params, inputCleaners));
|
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
|
import { TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn, DataSourceResult } from "./serverTypes";
|
|
8
|
-
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult } from "./types";
|
|
9
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.
|
|
@@ -13,7 +13,7 @@ export declare const createConnection: <T extends ConnectionDefinition>({ key }:
|
|
|
13
13
|
*/
|
|
14
14
|
export declare const loggerMock: () => ActionLogger;
|
|
15
15
|
/**
|
|
16
|
-
* The type of data returned by an `invoke()` function used for unit testing component actions.
|
|
16
|
+
* The type of data returned by an `invoke()` function used for unit testing component actions and triggers.
|
|
17
17
|
*/
|
|
18
18
|
interface InvokeReturn<ReturnData> {
|
|
19
19
|
result: ReturnData;
|
|
@@ -35,19 +35,18 @@ export declare const defaultTriggerPayload: () => TriggerPayload;
|
|
|
35
35
|
*/
|
|
36
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
|
/**
|
|
38
|
-
* Invokes specified DataSourceDefinition perform function using supplied params
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* action result and a mock logger for asserting logging.
|
|
38
|
+
* Invokes specified DataSourceDefinition perform function using supplied params.
|
|
39
|
+
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
40
|
+
* casting within test methods. Returns a DataSourceResult.
|
|
42
41
|
*/
|
|
43
|
-
export declare const invokeDataSource: <TInputs extends Inputs, TReturn extends
|
|
42
|
+
export declare const invokeDataSource: <TInputs extends Inputs, TReturn extends DataSourceResult>({ perform }: DataSourceDefinition<TInputs, TReturn>, params: ActionInputParameters<TInputs>) => Promise<TReturn>;
|
|
44
43
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
45
44
|
component: TComponent;
|
|
46
45
|
constructor(component: TComponent);
|
|
47
46
|
connectionValue({ key }: ConnectionDefinition): ConnectionValue;
|
|
48
47
|
trigger(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<TriggerResult>;
|
|
49
48
|
action(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<ActionPerformReturn>;
|
|
50
|
-
dataSource(key: string, params?: Record<string, unknown
|
|
49
|
+
dataSource(key: string, params?: Record<string, unknown>): Promise<DataSourceResult>;
|
|
51
50
|
}
|
|
52
51
|
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
53
52
|
declare const _default: {
|
|
@@ -55,6 +54,6 @@ declare const _default: {
|
|
|
55
54
|
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>>;
|
|
56
55
|
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>>;
|
|
57
56
|
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
58
|
-
invokeDataSource: <TInputs_2 extends Inputs, TReturn_1 extends
|
|
57
|
+
invokeDataSource: <TInputs_2 extends Inputs, TReturn_1 extends DataSourceResult>({ perform }: DataSourceDefinition<TInputs_2, TReturn_1>, params: ActionInputParameters<TInputs_2>) => Promise<TReturn_1>;
|
|
59
58
|
};
|
|
60
59
|
export default _default;
|
package/dist/testing.js
CHANGED
|
@@ -131,18 +131,13 @@ const invokeTrigger = ({ perform }, context, payload, params) => __awaiter(void
|
|
|
131
131
|
});
|
|
132
132
|
exports.invokeTrigger = invokeTrigger;
|
|
133
133
|
/**
|
|
134
|
-
* Invokes specified DataSourceDefinition perform function using supplied params
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* action result and a mock logger for asserting logging.
|
|
134
|
+
* Invokes specified DataSourceDefinition perform function using supplied params.
|
|
135
|
+
* Accepts a generic type matching DataSourceResult as a convenience to avoid extra
|
|
136
|
+
* casting within test methods. Returns a DataSourceResult.
|
|
138
137
|
*/
|
|
139
|
-
const invokeDataSource = ({ perform }, params
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
result,
|
|
144
|
-
loggerMock: realizedContext.logger,
|
|
145
|
-
};
|
|
138
|
+
const invokeDataSource = ({ perform }, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
139
|
+
const result = yield perform(params);
|
|
140
|
+
return result;
|
|
146
141
|
});
|
|
147
142
|
exports.invokeDataSource = invokeDataSource;
|
|
148
143
|
class ComponentTestHarness {
|
|
@@ -171,11 +166,10 @@ class ComponentTestHarness {
|
|
|
171
166
|
return action.perform(realizedContext, Object.assign({}, params));
|
|
172
167
|
});
|
|
173
168
|
}
|
|
174
|
-
dataSource(key, params
|
|
169
|
+
dataSource(key, params) {
|
|
175
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
const realizedContext = Object.assign(Object.assign({}, baseContext), context);
|
|
177
171
|
const dataSource = this.component.dataSources[key];
|
|
178
|
-
return dataSource.perform(
|
|
172
|
+
return dataSource.perform(Object.assign({}, params));
|
|
179
173
|
});
|
|
180
174
|
}
|
|
181
175
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Inputs, ActionPerformReturn, ActionInputParameters, ActionLogger } from ".";
|
|
1
|
+
import { Inputs, ActionPerformReturn, ActionInputParameters, ActionLogger, Instance, Customer } from ".";
|
|
2
2
|
/** Definition of the function to perform when an Action is invoked. */
|
|
3
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 */
|
|
@@ -21,15 +21,8 @@ export interface ActionContext {
|
|
|
21
21
|
webhookApiKeys: Record<string, string[]>;
|
|
22
22
|
/** The URL used to invoke the current execution */
|
|
23
23
|
invokeUrl: string;
|
|
24
|
-
/**
|
|
25
|
-
customer:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name: string | null;
|
|
29
|
-
};
|
|
30
|
-
/** An object containing the ID ad name of the currently running instance */
|
|
31
|
-
instance: {
|
|
32
|
-
id: string | null;
|
|
33
|
-
name: string | null;
|
|
34
|
-
};
|
|
24
|
+
/** Contains attributes of the Customer for whom an Instance is being executed. */
|
|
25
|
+
customer: Customer;
|
|
26
|
+
/** Contains attributes of the Instance that is being executed. */
|
|
27
|
+
instance: Instance;
|
|
35
28
|
}
|
|
@@ -14,4 +14,6 @@ export interface DataSourceDefinition<TInputs extends Inputs, TDataSourceResult
|
|
|
14
14
|
inputs: TInputs;
|
|
15
15
|
/** An example of the payload outputted by this Data Source. */
|
|
16
16
|
examplePayload?: Awaited<ReturnType<this["perform"]>>;
|
|
17
|
+
/** Specifies the name of a Data Source in this Component which can provide additional details about the content for this Data Source, such as example values when selecting particular API object fields. */
|
|
18
|
+
detailDataSource?: string;
|
|
17
19
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Inputs, DataSourceResult, DataSourceResultType, ActionInputParameters
|
|
1
|
+
import { Inputs, DataSourceResult, DataSourceResultType, ActionInputParameters } from ".";
|
|
2
2
|
/** Definition of the function to perform when a Data Source is invoked. */
|
|
3
|
-
export declare type DataSourcePerformFunction<T extends Inputs, TResult extends DataSourceResult<DataSourceResultType>> = (
|
|
3
|
+
export declare type DataSourcePerformFunction<T extends Inputs, TResult extends DataSourceResult<DataSourceResultType>> = (params: ActionInputParameters<T>) => Promise<TResult>;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { ObjectSelection, ObjectFieldMap,
|
|
2
|
+
import { ObjectSelection, ObjectFieldMap, JSONForm } from "./Inputs";
|
|
3
3
|
/** The type of field that is appropriate for rendering the data that is the result of the data source perform function. */
|
|
4
|
-
export declare type DataSourceResultFieldType =
|
|
4
|
+
export declare type DataSourceResultFieldType = "string" | "date" | "timestamp" | "picklist" | "schedule" | "code" | "credential" | "boolean" | "number" | "connection" | "objectSelection" | "objectFieldMap" | "jsonForm";
|
|
5
5
|
/** The actual data type of the data that is the result of the data source perform function. */
|
|
6
6
|
export declare type DataSourceResultType = ObjectSelection | ObjectFieldMap | JSONForm | Buffer | boolean | number | string | Record<string, unknown> | unknown[] | unknown;
|
|
7
7
|
/** Represents the result of a Data Source action. */
|
|
8
8
|
export declare type DataSourceResult<TDataSourceResultType> = {
|
|
9
9
|
/** The resulting data that is returned from the data source. */
|
|
10
10
|
result: TDataSourceResultType;
|
|
11
|
-
/** Additional data that may be useful for out-of-band processing at a later time.
|
|
11
|
+
/** Additional data that may be useful for out-of-band processing at a later time.
|
|
12
|
+
* NOTE: This is only available when the Data Source is called as part of fetching
|
|
13
|
+
* contents for a Configuration Wizard Page. */
|
|
12
14
|
supplementalData?: {
|
|
13
15
|
data: unknown;
|
|
14
16
|
contentType: string;
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ConditionalExpression } from "./conditional-logic";
|
|
|
2
2
|
export declare type ObjectSelection = {
|
|
3
3
|
key: string;
|
|
4
4
|
label?: string;
|
|
5
|
+
selected?: boolean;
|
|
5
6
|
fields: {
|
|
6
7
|
key: string;
|
|
7
8
|
label?: string;
|
|
@@ -16,6 +17,10 @@ export declare type ObjectFieldMap = {
|
|
|
16
17
|
fieldKey: string;
|
|
17
18
|
fieldLabel?: string;
|
|
18
19
|
};
|
|
20
|
+
defaultValue?: {
|
|
21
|
+
objectKey: string;
|
|
22
|
+
fieldKey: string;
|
|
23
|
+
};
|
|
19
24
|
}[];
|
|
20
25
|
export declare type JSONForm = {
|
|
21
26
|
schema: Record<string, unknown>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Instance, Customer } from ".";
|
|
1
2
|
/** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution. */
|
|
2
3
|
export interface TriggerPayload {
|
|
3
4
|
headers: {
|
|
@@ -27,13 +28,8 @@ export interface TriggerPayload {
|
|
|
27
28
|
/** The URL that was used to invoke the execution. */
|
|
28
29
|
invokeUrl: string;
|
|
29
30
|
executionId: string;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
instance: {
|
|
36
|
-
id: string | null;
|
|
37
|
-
name: string | null;
|
|
38
|
-
};
|
|
31
|
+
/** Contains attributes of the Customer for whom an Instance is being executed. */
|
|
32
|
+
customer: Customer;
|
|
33
|
+
/** Contains attributes of the Instance that is being executed. */
|
|
34
|
+
instance: Instance;
|
|
39
35
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,4 +21,6 @@ export * from "./TriggerPayload";
|
|
|
21
21
|
export * from "./DataSourceDefinition";
|
|
22
22
|
export * from "./DataSourcePerformFunction";
|
|
23
23
|
export * from "./DataSourceResult";
|
|
24
|
+
export * from "./Instance";
|
|
25
|
+
export * from "./Customer";
|
|
24
26
|
export * as serverTypes from "../serverTypes";
|
package/dist/types/index.js
CHANGED
|
@@ -50,4 +50,6 @@ __exportStar(require("./TriggerPayload"), exports);
|
|
|
50
50
|
__exportStar(require("./DataSourceDefinition"), exports);
|
|
51
51
|
__exportStar(require("./DataSourcePerformFunction"), exports);
|
|
52
52
|
__exportStar(require("./DataSourceResult"), exports);
|
|
53
|
+
__exportStar(require("./Instance"), exports);
|
|
54
|
+
__exportStar(require("./Customer"), exports);
|
|
53
55
|
exports.serverTypes = __importStar(require("../serverTypes"));
|