@prismatic-io/spectral 10.18.7-preview.5 → 10.18.8
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/convertComponent.d.ts +0 -6
- package/dist/serverTypes/convertComponent.js +3 -43
- package/dist/serverTypes/convertIntegration.js +45 -29
- package/dist/serverTypes/index.d.ts +4 -16
- package/dist/types/Inputs.d.ts +2 -2
- package/dist/types/IntegrationDefinition.d.ts +2 -20
- package/dist/types/PollingTriggerDefinition.d.ts +1 -7
- package/dist/types/TriggerDefinition.d.ts +2 -35
- package/dist/types/TriggerPayload.d.ts +2 -11
- package/package.json +1 -1
|
@@ -7,12 +7,6 @@ import { type CleanFn } from "./perform";
|
|
|
7
7
|
* declare a top-level clean on these containers — the conversion always
|
|
8
8
|
* supplies one so nested clean functions are applied at runtime. */
|
|
9
9
|
export declare const cleanerFor: (input: InputFieldDefinition) => CleanFn | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Throws if `batchSize` isn't a positive integer; otherwise returns it.
|
|
12
|
-
* Shared by both component-trigger (`TriggerResolver.default.batchSize`) and
|
|
13
|
-
* CNI flow (`TriggerResolverConfig.batchSize`) validation paths.
|
|
14
|
-
*/
|
|
15
|
-
export declare const validateBatchSize: (ownerLabel: string, fieldName: string, batchSize: unknown) => number;
|
|
16
10
|
export declare const convertInput: (key: string, definition: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
|
|
17
11
|
export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
18
12
|
[key: string]: ConnectionInput | ConnectionTemplateInputField;
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.
|
|
17
|
+
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.cleanerFor = void 0;
|
|
18
18
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
19
19
|
const types_1 = require("../types");
|
|
20
20
|
const PollingTriggerDefinition_1 = require("../types/PollingTriggerDefinition");
|
|
@@ -60,34 +60,6 @@ const cleanerFor = (input) => {
|
|
|
60
60
|
return "clean" in input ? input.clean : undefined;
|
|
61
61
|
};
|
|
62
62
|
exports.cleanerFor = cleanerFor;
|
|
63
|
-
/**
|
|
64
|
-
* Throws if `batchSize` isn't a positive integer; otherwise returns it.
|
|
65
|
-
* Shared by both component-trigger (`TriggerResolver.default.batchSize`) and
|
|
66
|
-
* CNI flow (`TriggerResolverConfig.batchSize`) validation paths.
|
|
67
|
-
*/
|
|
68
|
-
const validateBatchSize = (ownerLabel, fieldName, batchSize) => {
|
|
69
|
-
if (typeof batchSize !== "number" || !Number.isInteger(batchSize) || batchSize < 1) {
|
|
70
|
-
throw new Error(`${ownerLabel} has an invalid ${fieldName} batchSize of ${String(batchSize)}. batchSize must be an integer >= 1.`);
|
|
71
|
-
}
|
|
72
|
-
return batchSize;
|
|
73
|
-
};
|
|
74
|
-
exports.validateBatchSize = validateBatchSize;
|
|
75
|
-
const buildTriggerResolverFields = (triggerLabel, support, resolver) => {
|
|
76
|
-
if (!resolver) {
|
|
77
|
-
return support === "invalid" ? {} : { triggerResolverDefaultBatchSize: 1 };
|
|
78
|
-
}
|
|
79
|
-
return Object.assign(Object.assign({ triggerResolverDefaultBatchSize: (0, exports.validateBatchSize)(`Trigger "${triggerLabel}"`, "triggerResolver.default", resolver.default.batchSize) }, (resolver.resolveItems
|
|
80
|
-
? {
|
|
81
|
-
resolveTriggerItems: resolver.resolveItems,
|
|
82
|
-
hasResolveTriggerItems: true,
|
|
83
|
-
}
|
|
84
|
-
: {})), (resolver.getNextDiscoveryState
|
|
85
|
-
? {
|
|
86
|
-
getNextDiscoveryState: resolver.getNextDiscoveryState,
|
|
87
|
-
hasGetNextDiscoveryState: true,
|
|
88
|
-
}
|
|
89
|
-
: {}));
|
|
90
|
-
};
|
|
91
63
|
const convertInput = (key, definition) => {
|
|
92
64
|
// Cast: the field union is wider than any single member; runtime guards below handle it.
|
|
93
65
|
const _a = definition, { default: defaultValue, type, label, collection, inputs: childInputs, configurations } = _a, rest = __rest(_a, ["default", "type", "label", "collection", "inputs", "configurations"]);
|
|
@@ -171,18 +143,6 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
171
143
|
});
|
|
172
144
|
const triggerInputCleaners = Object.entries(inputs).reduce((result, [key, value]) => (Object.assign(Object.assign({}, result), { [key]: (0, exports.cleanerFor)(value) })), {});
|
|
173
145
|
let scheduleSupport = "scheduleSupport" in trigger ? trigger.scheduleSupport : "invalid";
|
|
174
|
-
const triggerResolver = "triggerResolver" in trigger ? trigger.triggerResolver : undefined;
|
|
175
|
-
const triggerResolverSupport = "triggerResolverSupport" in trigger && trigger.triggerResolverSupport !== undefined
|
|
176
|
-
? trigger.triggerResolverSupport
|
|
177
|
-
: triggerResolver
|
|
178
|
-
? "valid"
|
|
179
|
-
: "invalid";
|
|
180
|
-
if (triggerResolverSupport === "required" && !triggerResolver) {
|
|
181
|
-
throw new Error(`Trigger "${trigger.display.label}" declares triggerResolverSupport "required" but is missing triggerResolver.`);
|
|
182
|
-
}
|
|
183
|
-
if (triggerResolverSupport === "invalid" && triggerResolver) {
|
|
184
|
-
throw new Error(`Trigger "${trigger.display.label}" declares triggerResolver but triggerResolverSupport is "invalid".`);
|
|
185
|
-
}
|
|
186
146
|
let convertedActionInputs = [];
|
|
187
147
|
let performToUse;
|
|
188
148
|
if ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger)) {
|
|
@@ -211,11 +171,11 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
211
171
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
212
172
|
});
|
|
213
173
|
}
|
|
214
|
-
const result = Object.assign(Object.assign(Object.assign(
|
|
174
|
+
const result = Object.assign(Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
|
|
215
175
|
? trigger.synchronousResponseSupport
|
|
216
176
|
: scheduleSupport === "invalid"
|
|
217
177
|
? "valid"
|
|
218
|
-
: "invalid"
|
|
178
|
+
: "invalid" }), ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger) ? { isPollingTrigger: true } : {}));
|
|
219
179
|
if (onInstanceDeploy) {
|
|
220
180
|
result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
|
|
221
181
|
inputCleaners: triggerInputCleaners,
|
|
@@ -29,12 +29,6 @@ const integration_1 = require("./integration");
|
|
|
29
29
|
const perform_1 = require("./perform");
|
|
30
30
|
exports.CONCURRENCY_LIMIT_MAX = 15;
|
|
31
31
|
exports.CONCURRENCY_LIMIT_MIN = 2;
|
|
32
|
-
const validateFlowResolverBatchSize = (flowName, configName, resolver) => {
|
|
33
|
-
if (!resolver) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return { batchSize: (0, convertComponent_1.validateBatchSize)(flowName, configName, resolver.batchSize) };
|
|
37
|
-
};
|
|
38
32
|
const convertIntegration = (definition) => {
|
|
39
33
|
var _a, _b, _c;
|
|
40
34
|
// Generate a unique reference key that will be used to reference the
|
|
@@ -347,6 +341,15 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
347
341
|
if (!flow.onTrigger) {
|
|
348
342
|
publicSupplementalComponent = flow.schedule ? "schedule" : "webhook";
|
|
349
343
|
}
|
|
344
|
+
// The step action points at the CNI-generated wrapper trigger rather than
|
|
345
|
+
// the referenced component's trigger. When the flow references a component
|
|
346
|
+
// trigger, still carry that reference's configured input values onto the
|
|
347
|
+
// step so the wrapper trigger receives them as params (and can forward them
|
|
348
|
+
// to the referenced trigger via invokeTrigger).
|
|
349
|
+
if ((0, types_1.isComponentReference)(flow.onTrigger)) {
|
|
350
|
+
const { inputs } = convertComponentReference(flow.onTrigger, componentRegistry, "triggers");
|
|
351
|
+
triggerStep.inputs = inputs;
|
|
352
|
+
}
|
|
350
353
|
triggerStep.action = {
|
|
351
354
|
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
352
355
|
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
@@ -409,10 +412,6 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
409
412
|
}
|
|
410
413
|
: {}));
|
|
411
414
|
}
|
|
412
|
-
const triggerResolver = "triggerResolver" in flow ? flow.triggerResolver : undefined;
|
|
413
|
-
if (triggerResolver) {
|
|
414
|
-
result.triggerResolver = validateFlowResolverBatchSize(flow.name, "triggerResolver", triggerResolver);
|
|
415
|
-
}
|
|
416
415
|
const actionStep = {
|
|
417
416
|
action: {
|
|
418
417
|
key: flowFunctionKey(flow.name, "onExecution"),
|
|
@@ -635,6 +634,22 @@ const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
|
|
|
635
634
|
};
|
|
636
635
|
};
|
|
637
636
|
exports.invokeTriggerComponentInput = invokeTriggerComponentInput;
|
|
637
|
+
/* When a flow references a component trigger but also defines on* lifecycle
|
|
638
|
+
* behavior, the trigger is wrapped in a generated CNI component trigger. That
|
|
639
|
+
* wrapper must declare the referenced trigger's inputs so the platform passes
|
|
640
|
+
* the step's configured values through as params (which the wrapper then
|
|
641
|
+
* forwards to the referenced trigger via invokeTrigger). */
|
|
642
|
+
const wrapperTriggerInputsFromReference = (onTrigger, componentRegistry) => {
|
|
643
|
+
var _a, _b, _c;
|
|
644
|
+
if (!(0, types_1.isComponentReference)(onTrigger)) {
|
|
645
|
+
return [];
|
|
646
|
+
}
|
|
647
|
+
const manifestInputs = (_c = (_b = (_a = componentRegistry[onTrigger.component]) === null || _a === void 0 ? void 0 : _a.triggers) === null || _b === void 0 ? void 0 : _b[onTrigger.key]) === null || _c === void 0 ? void 0 : _c.inputs;
|
|
648
|
+
if (!manifestInputs) {
|
|
649
|
+
return [];
|
|
650
|
+
}
|
|
651
|
+
return Object.entries(manifestInputs).map(([key, input]) => (Object.assign(Object.assign(Object.assign({ key, label: key, type: input.inputType }, (input.collection ? { collection: input.collection } : {})), (input.default !== undefined ? { default: input.default } : {})), (input.required !== undefined ? { required: input.required } : {}))));
|
|
652
|
+
};
|
|
638
653
|
/** Type guard to narrow trigger perform functions based on triggerType.
|
|
639
654
|
* Since TriggerPerformFunction and CodeNativePollingTriggerPerformFunction are
|
|
640
655
|
* structurally identical, TypeScript cannot distinguish them. This guard uses
|
|
@@ -680,11 +695,7 @@ function generateTriggerPerformFn(params) {
|
|
|
680
695
|
case "standard":
|
|
681
696
|
return (0, perform_1.createCNIPerform)({ componentRegistry, onTrigger });
|
|
682
697
|
case "component-ref":
|
|
683
|
-
return (0, perform_1.createCNIComponentRefPerform)({
|
|
684
|
-
componentRegistry,
|
|
685
|
-
componentRef,
|
|
686
|
-
onTrigger,
|
|
687
|
-
});
|
|
698
|
+
return (0, perform_1.createCNIComponentRefPerform)({ componentRegistry, componentRef, onTrigger });
|
|
688
699
|
default:
|
|
689
700
|
throw new Error(`Invalid trigger configuration detected: ${JSON.stringify(params, null, 2)}`);
|
|
690
701
|
}
|
|
@@ -753,7 +764,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
753
764
|
inputs: [],
|
|
754
765
|
} });
|
|
755
766
|
}, {});
|
|
756
|
-
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType,
|
|
767
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, }) => {
|
|
757
768
|
if (!flowUsesWrapperTrigger({
|
|
758
769
|
onTrigger,
|
|
759
770
|
onInstanceDelete,
|
|
@@ -788,21 +799,26 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
788
799
|
const deployFn = generateTriggerEventWrapperFn(ref, onTrigger, "onInstanceDeploy", componentRegistry, onInstanceDeploy);
|
|
789
800
|
const webhookCreateFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookCreate", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.create);
|
|
790
801
|
const webhookDeleteFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookDelete", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.delete);
|
|
791
|
-
return Object.assign(Object.assign({}, result), { [key]:
|
|
802
|
+
return Object.assign(Object.assign({}, result), { [key]: {
|
|
803
|
+
key,
|
|
804
|
+
display: {
|
|
792
805
|
label: `${name} - onTrigger`,
|
|
793
806
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
794
|
-
},
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
807
|
+
},
|
|
808
|
+
perform: performFn,
|
|
809
|
+
onInstanceDeploy: deployFn,
|
|
810
|
+
hasOnInstanceDeploy: !!deployFn,
|
|
811
|
+
onInstanceDelete: deleteFn,
|
|
812
|
+
hasOnInstanceDelete: !!deleteFn,
|
|
813
|
+
webhookCreate: webhookCreateFn,
|
|
814
|
+
hasWebhookCreateFunction: !!webhookCreateFn,
|
|
815
|
+
webhookDelete: webhookDeleteFn,
|
|
816
|
+
hasWebhookDeleteFunction: !!webhookDeleteFn,
|
|
817
|
+
inputs: wrapperTriggerInputsFromReference(onTrigger, componentRegistry),
|
|
818
|
+
scheduleSupport: triggerType === "polling" ? "required" : "valid",
|
|
819
|
+
synchronousResponseSupport: "valid",
|
|
820
|
+
isPollingTrigger: triggerType === "polling",
|
|
821
|
+
} });
|
|
806
822
|
}, {});
|
|
807
823
|
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
808
824
|
if (!(0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
|
|
@@ -112,8 +112,8 @@ interface HttpResponse {
|
|
|
112
112
|
headers?: Record<string, string>;
|
|
113
113
|
body?: string;
|
|
114
114
|
}
|
|
115
|
-
interface TriggerBaseResult
|
|
116
|
-
payload:
|
|
115
|
+
interface TriggerBaseResult {
|
|
116
|
+
payload: TriggerPayload;
|
|
117
117
|
response?: HttpResponse;
|
|
118
118
|
instanceState?: Record<string, unknown>;
|
|
119
119
|
crossFlowState?: Record<string, unknown>;
|
|
@@ -122,18 +122,12 @@ interface TriggerBaseResult<TPayload extends TriggerPayload = TriggerPayload> {
|
|
|
122
122
|
failed?: boolean;
|
|
123
123
|
error?: Record<string, unknown>;
|
|
124
124
|
}
|
|
125
|
-
interface TriggerBranchingResult
|
|
125
|
+
interface TriggerBranchingResult extends TriggerBaseResult {
|
|
126
126
|
branch: string;
|
|
127
127
|
}
|
|
128
|
-
export type TriggerResult
|
|
128
|
+
export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
129
129
|
export type TriggerEventFunctionResult = TriggerEventFunctionReturn | void;
|
|
130
130
|
export type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>;
|
|
131
|
-
/**
|
|
132
|
-
* Wire format the platform expects for a trigger. Note: function references
|
|
133
|
-
* (perform, resolveTriggerItems, getNextDiscoveryState, ...) don't survive JSON
|
|
134
|
-
* serialization, so each callback has a paired `hasXxx: boolean` flag the
|
|
135
|
-
* server reads to detect presence. Keep the flag and its callback in sync.
|
|
136
|
-
*/
|
|
137
131
|
export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>> {
|
|
138
132
|
key: string;
|
|
139
133
|
display: DisplayDefinition & {
|
|
@@ -161,12 +155,6 @@ export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, T
|
|
|
161
155
|
hasWebhookDeleteFunction?: boolean;
|
|
162
156
|
scheduleSupport: TriggerOptionChoice;
|
|
163
157
|
synchronousResponseSupport: TriggerOptionChoice;
|
|
164
|
-
triggerResolverSupport?: TriggerOptionChoice;
|
|
165
|
-
triggerResolverDefaultBatchSize?: number;
|
|
166
|
-
resolveTriggerItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => unknown[];
|
|
167
|
-
hasResolveTriggerItems?: boolean;
|
|
168
|
-
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
169
|
-
hasGetNextDiscoveryState?: boolean;
|
|
170
158
|
examplePayload?: unknown;
|
|
171
159
|
isCommonTrigger?: boolean;
|
|
172
160
|
isPollingTrigger?: boolean;
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -304,7 +304,7 @@ export type StructuredOrLeafInputFieldDefinition = LeafInputFieldDefinition | St
|
|
|
304
304
|
/** Groups related primitive inputs under a single named container.
|
|
305
305
|
* Nesting is capped at one level. Connection pickers are rejected as
|
|
306
306
|
* children — they may only appear at the top level. */
|
|
307
|
-
export type StructuredObjectInputField = Omit<BaseInputField, "dataSource"> & {
|
|
307
|
+
export type StructuredObjectInputField = Omit<BaseInputField, "dataSource" | "example" | "placeholder" | "required"> & {
|
|
308
308
|
/** Data type the input will collect. */
|
|
309
309
|
type: "structuredObject";
|
|
310
310
|
/** Nested input fields keyed by their local key. */
|
|
@@ -328,7 +328,7 @@ export interface DynamicObjectConfiguration {
|
|
|
328
328
|
* at integration-build time and that configuration's inputs become available.
|
|
329
329
|
* Nesting is capped: configurations may contain structuredObject children
|
|
330
330
|
* (depth-1) but never another dynamicObject. */
|
|
331
|
-
export type DynamicObjectInputField = Omit<BaseInputField, "dataSource"> & {
|
|
331
|
+
export type DynamicObjectInputField = Omit<BaseInputField, "dataSource" | "example" | "placeholder"> & {
|
|
332
332
|
/** Data type the input will collect. */
|
|
333
333
|
type: "dynamicObject";
|
|
334
334
|
/** Available configurations keyed by their local key (used as the
|
|
@@ -4,13 +4,13 @@ import type { ComponentRegistry, ConfigVarExpression, TriggerReference, ValueExp
|
|
|
4
4
|
import type { ConfigPages, UserLevelConfigPages } from "./ConfigPages";
|
|
5
5
|
import type { ConfigVars } from "./ConfigVars";
|
|
6
6
|
import type { FlowDefinitionFlowSchema } from "./FlowSchemas";
|
|
7
|
-
import type {
|
|
7
|
+
import type { Inputs } from "./Inputs";
|
|
8
8
|
import type { PollingTriggerPerformFunction } from "./PollingTriggerDefinition";
|
|
9
9
|
import type { ScopedConfigVarMap } from "./ScopedConfigVars";
|
|
10
10
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
11
11
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
12
12
|
import type { TriggerPerformFunction } from "./TriggerPerformFunction";
|
|
13
|
-
import type {
|
|
13
|
+
import type { TriggerResult } from "./TriggerResult";
|
|
14
14
|
/**
|
|
15
15
|
* Defines attributes of a code-native integration. See
|
|
16
16
|
* https://prismatic.io/docs/integrations/code-native/
|
|
@@ -117,13 +117,6 @@ interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
117
117
|
*/
|
|
118
118
|
organizationApiKeys?: string[];
|
|
119
119
|
testApiKeys?: string[];
|
|
120
|
-
/**
|
|
121
|
-
* Trigger resolver configuration: batches the records returned by the
|
|
122
|
-
* trigger into parallel dispatches. When using an existing component
|
|
123
|
-
* trigger, that trigger must declare `triggerResolverSupport`. CNI flows
|
|
124
|
-
* infer support from the resolver's presence.
|
|
125
|
-
*/
|
|
126
|
-
triggerResolver?: TriggerResolverConfig<ConfigVars, TTriggerPayload>;
|
|
127
120
|
/** Error handling configuration. */
|
|
128
121
|
errorConfig?: StepErrorConfig;
|
|
129
122
|
/** Optional schemas definitions for the flow. Currently only for use with AI agents. */
|
|
@@ -253,15 +246,4 @@ export type EndpointType = "flow_specific" | "instance_specific" | "shared_insta
|
|
|
253
246
|
export type EndpointSecurityType = "unsecured" | "customer_optional" | "customer_required" | "organization";
|
|
254
247
|
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
255
248
|
export type StepErrorHandlerType = "fail" | "ignore" | "retry";
|
|
256
|
-
/** Configures how trigger items are batched when the trigger supports a resolver. */
|
|
257
|
-
export type TriggerResolverConfig<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TItem = unknown> = {
|
|
258
|
-
/** Number of items per batch. Must be an integer >= 1. `1` dispatches each item individually; `>1` groups items into batches. */
|
|
259
|
-
batchSize: number;
|
|
260
|
-
/** Extracts an array of items from the trigger result for batched dispatch. Receives the same context as the trigger's perform function. */
|
|
261
|
-
resolveItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => TItem[];
|
|
262
|
-
/** Called after each trigger run. When defined and returns a non-null object, the platform
|
|
263
|
-
* queues another pagination round (re-invokes the trigger) and stamps the returned object
|
|
264
|
-
* onto `payload.discoveryState` for that next invocation. Return `null` to stop. */
|
|
265
|
-
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
266
|
-
};
|
|
267
249
|
export {};
|
|
@@ -4,7 +4,6 @@ import type { ActionContext } from "./ActionPerformFunction";
|
|
|
4
4
|
import type { ActionPerformReturn } from "./ActionPerformReturn";
|
|
5
5
|
import type { ActionDisplayDefinition } from "./DisplayDefinition";
|
|
6
6
|
import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
7
|
-
import type { TriggerResolverDecl } from "./TriggerDefinition";
|
|
8
7
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
9
8
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
10
9
|
import type { TriggerResult } from "./TriggerResult";
|
|
@@ -19,12 +18,8 @@ export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs
|
|
|
19
18
|
/**
|
|
20
19
|
* PollingTriggerDefinition is the type of the object that is passed in to `pollingTrigger` function to
|
|
21
20
|
* define a component trigger.
|
|
22
|
-
*
|
|
23
|
-
* Composed from `PollingTriggerDefinitionBase` plus `TriggerResolverDecl`, which
|
|
24
|
-
* enforces the resolver support relationship at the type level.
|
|
25
21
|
*/
|
|
26
|
-
export
|
|
27
|
-
interface PollingTriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
|
|
22
|
+
export interface PollingTriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
|
|
28
23
|
triggerType?: "polling";
|
|
29
24
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
30
25
|
display: ActionDisplayDefinition;
|
|
@@ -44,4 +39,3 @@ interface PollingTriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigV
|
|
|
44
39
|
examplePayload?: Awaited<ReturnType<this["perform"]>>;
|
|
45
40
|
}
|
|
46
41
|
export declare const isPollingTriggerDefinition: (ref: unknown) => ref is PollingTriggerDefinition;
|
|
47
|
-
export {};
|
|
@@ -1,51 +1,18 @@
|
|
|
1
|
-
import type { ActionContext } from "./ActionPerformFunction";
|
|
2
1
|
import type { ActionDisplayDefinition } from "./DisplayDefinition";
|
|
3
2
|
import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
4
3
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
5
4
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
6
5
|
import type { TriggerPerformFunction } from "./TriggerPerformFunction";
|
|
7
|
-
import type {
|
|
8
|
-
/**
|
|
9
|
-
* Encodes the relationship between `triggerResolverSupport` and `triggerResolver`:
|
|
10
|
-
* - absent or `"invalid"`: no resolver allowed
|
|
11
|
-
* - `"valid"`: resolver optional
|
|
12
|
-
* - `"required"`: resolver required
|
|
13
|
-
*/
|
|
14
|
-
export type TriggerResolverDecl<TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload> = {
|
|
15
|
-
triggerResolverSupport?: "invalid" | undefined;
|
|
16
|
-
triggerResolver?: undefined;
|
|
17
|
-
} | {
|
|
18
|
-
triggerResolverSupport: "valid";
|
|
19
|
-
triggerResolver?: TriggerResolver<TConfigVars, TPayload>;
|
|
20
|
-
} | {
|
|
21
|
-
triggerResolverSupport: "required";
|
|
22
|
-
triggerResolver: TriggerResolver<TConfigVars, TPayload>;
|
|
23
|
-
};
|
|
6
|
+
import type { TriggerResult } from "./TriggerResult";
|
|
24
7
|
declare const optionChoices: readonly ["invalid", "valid", "required"];
|
|
25
8
|
export type TriggerOptionChoice = (typeof optionChoices)[number];
|
|
26
9
|
export declare const TriggerOptionChoices: TriggerOptionChoice[];
|
|
27
|
-
export interface TriggerResolver<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TItem = unknown> {
|
|
28
|
-
/** Author-declared defaults for how this trigger's items are batched. */
|
|
29
|
-
default: {
|
|
30
|
-
/** Number of items per batch. Must be an integer >= 1. `1` dispatches each item individually; `>1` groups items into batches. */
|
|
31
|
-
batchSize: number;
|
|
32
|
-
};
|
|
33
|
-
/** Extracts an array of items from the trigger result for batched dispatch. Receives the same context as the trigger's perform function. */
|
|
34
|
-
resolveItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => TItem[];
|
|
35
|
-
/** Extracts data from the trigger result to be passed to the next trigger invocation to fetch another page of data. */
|
|
36
|
-
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
37
|
-
}
|
|
38
10
|
/**
|
|
39
11
|
* TriggerDefinition is the type of the object that is passed in to `trigger` function to
|
|
40
12
|
* define a component trigger. See
|
|
41
13
|
* https://prismatic.io/docs/custom-connectors/triggers/
|
|
42
|
-
*
|
|
43
|
-
* Composed from `TriggerDefinitionBase` (static fields) plus the discriminated union
|
|
44
|
-
* `TriggerResolverDecl`, which enforces the resolver support relationship at the type
|
|
45
|
-
* level.
|
|
46
14
|
*/
|
|
47
|
-
export
|
|
48
|
-
interface TriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
15
|
+
export interface TriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
49
16
|
/** Defines how the trigger is displayed in the Prismatic UI. */
|
|
50
17
|
display: ActionDisplayDefinition;
|
|
51
18
|
/** Function to perform when this trigger is invoked. */
|
|
@@ -3,13 +3,8 @@ import type { FlowAttributes } from "./FlowAttributes";
|
|
|
3
3
|
import type { InstanceAttributes } from "./InstanceAttributes";
|
|
4
4
|
import type { IntegrationAttributes } from "./IntegrationAttributes";
|
|
5
5
|
import type { UserAttributes } from "./UserAttributes";
|
|
6
|
-
/** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution.
|
|
7
|
-
|
|
8
|
-
* The optional `TDiscoveryState` parameter types the `discoveryState` field, so authors who
|
|
9
|
-
* declare a pagination-state shape on their `getNextDiscoveryState` resolver can read back
|
|
10
|
-
* the same shape on the next round's payload. Defaults to `Record<string, unknown>`.
|
|
11
|
-
*/
|
|
12
|
-
export interface TriggerPayload<TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> {
|
|
6
|
+
/** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution. */
|
|
7
|
+
export interface TriggerPayload {
|
|
13
8
|
/** The headers sent in the webhook request. */
|
|
14
9
|
headers: {
|
|
15
10
|
[key: string]: string;
|
|
@@ -55,8 +50,4 @@ export interface TriggerPayload<TDiscoveryState extends Record<string, unknown>
|
|
|
55
50
|
startedAt: string;
|
|
56
51
|
/** Determines whether the execution will run in debug mode. */
|
|
57
52
|
globalDebug: boolean;
|
|
58
|
-
/** Managed by the execution when this trigger invocation is a paginated re-run.
|
|
59
|
-
* Contains the object returned by `getNextDiscoveryState` from the previous round.
|
|
60
|
-
* Absent on the initial invocation. */
|
|
61
|
-
discoveryState?: TDiscoveryState;
|
|
62
53
|
}
|