@prismatic-io/spectral 7.8.0 → 7.8.2
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/convert.js +2 -0
- package/dist/serverTypes/index.d.ts +2 -0
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +18 -0
- package/package.json +1 -1
|
@@ -44,12 +44,14 @@ const convertTrigger = (triggerKey, _a, hooks) => {
|
|
|
44
44
|
inputCleaners,
|
|
45
45
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
46
46
|
});
|
|
47
|
+
result.hasOnInstanceDeploy = true;
|
|
47
48
|
}
|
|
48
49
|
if (onInstanceDelete) {
|
|
49
50
|
result.onInstanceDelete = (0, perform_1.createPerform)(onInstanceDelete, {
|
|
50
51
|
inputCleaners,
|
|
51
52
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
52
53
|
});
|
|
54
|
+
result.hasOnInstanceDelete = true;
|
|
53
55
|
}
|
|
54
56
|
return result;
|
|
55
57
|
};
|
|
@@ -124,7 +124,9 @@ export interface Trigger {
|
|
|
124
124
|
dynamicBranchInput?: string;
|
|
125
125
|
perform: TriggerPerformFunction;
|
|
126
126
|
onInstanceDeploy?: TriggerEventFunction;
|
|
127
|
+
hasOnInstanceDeploy?: boolean;
|
|
127
128
|
onInstanceDelete?: TriggerEventFunction;
|
|
129
|
+
hasOnInstanceDelete?: boolean;
|
|
128
130
|
scheduleSupport: TriggerOptionChoice;
|
|
129
131
|
synchronousResponseSupport: TriggerOptionChoice;
|
|
130
132
|
examplePayload?: unknown;
|
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, DataSourceContext } from "./serverTypes";
|
|
8
|
-
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult } from "./types";
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn } from "./types";
|
|
9
9
|
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown> | undefined) => ConnectionValue;
|
|
10
10
|
/**
|
|
11
11
|
* Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
|
|
@@ -63,6 +63,8 @@ export declare class ComponentTestHarness<TComponent extends Component> {
|
|
|
63
63
|
private buildParams;
|
|
64
64
|
connectionValue({ key }: ConnectionDefinition): ConnectionValue;
|
|
65
65
|
trigger(key: string, payload?: TriggerPayload, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<TriggerResult>;
|
|
66
|
+
triggerOnInstanceDeploy(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<void | TriggerEventFunctionReturn>;
|
|
67
|
+
triggerOnInstanceDelete(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<void | TriggerEventFunctionReturn>;
|
|
66
68
|
action(key: string, params?: Record<string, unknown>, context?: Partial<ActionContext>): Promise<ActionPerformReturn>;
|
|
67
69
|
dataSource(key: string, params?: Record<string, unknown>, context?: Partial<DataSourceContext>): Promise<DataSourceResult>;
|
|
68
70
|
}
|
package/dist/testing.js
CHANGED
|
@@ -216,6 +216,24 @@ class ComponentTestHarness {
|
|
|
216
216
|
return trigger.perform(this.buildContext(baseActionContext, context), Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), this.buildParams(trigger.inputs, params));
|
|
217
217
|
});
|
|
218
218
|
}
|
|
219
|
+
triggerOnInstanceDeploy(key, params, context) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const trigger = this.component.triggers[key];
|
|
222
|
+
if (!trigger.onInstanceDeploy) {
|
|
223
|
+
throw new Error("Trigger does not support onInstanceDeploy");
|
|
224
|
+
}
|
|
225
|
+
return trigger.onInstanceDeploy(this.buildContext(baseActionContext, context), this.buildParams(trigger.inputs, params));
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
triggerOnInstanceDelete(key, params, context) {
|
|
229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
+
const trigger = this.component.triggers[key];
|
|
231
|
+
if (!trigger.onInstanceDelete) {
|
|
232
|
+
throw new Error("Trigger does not support onInstanceDelete");
|
|
233
|
+
}
|
|
234
|
+
return trigger.onInstanceDelete(this.buildContext(baseActionContext, context), this.buildParams(trigger.inputs, params));
|
|
235
|
+
});
|
|
236
|
+
}
|
|
219
237
|
action(key, params, context) {
|
|
220
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
239
|
const action = this.component.actions[key];
|