@prismatic-io/spectral 10.18.7-preview.3 → 10.18.7-preview.5
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 +6 -0
- package/dist/serverTypes/convertComponent.js +43 -3
- package/dist/serverTypes/convertIntegration.js +29 -20
- package/dist/serverTypes/index.d.ts +16 -4
- package/dist/types/Inputs.d.ts +13 -11
- package/dist/types/IntegrationDefinition.d.ts +20 -2
- package/dist/types/PollingTriggerDefinition.d.ts +7 -1
- package/dist/types/TriggerDefinition.d.ts +35 -2
- package/dist/types/TriggerPayload.d.ts +11 -2
- package/package.json +1 -1
|
@@ -7,6 +7,12 @@ 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;
|
|
10
16
|
export declare const convertInput: (key: string, definition: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
|
|
11
17
|
export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
12
18
|
[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.cleanerFor = void 0;
|
|
17
|
+
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.validateBatchSize = 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,6 +60,34 @@ 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
|
+
};
|
|
63
91
|
const convertInput = (key, definition) => {
|
|
64
92
|
// Cast: the field union is wider than any single member; runtime guards below handle it.
|
|
65
93
|
const _a = definition, { default: defaultValue, type, label, collection, inputs: childInputs, configurations } = _a, rest = __rest(_a, ["default", "type", "label", "collection", "inputs", "configurations"]);
|
|
@@ -143,6 +171,18 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
143
171
|
});
|
|
144
172
|
const triggerInputCleaners = Object.entries(inputs).reduce((result, [key, value]) => (Object.assign(Object.assign({}, result), { [key]: (0, exports.cleanerFor)(value) })), {});
|
|
145
173
|
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
|
+
}
|
|
146
186
|
let convertedActionInputs = [];
|
|
147
187
|
let performToUse;
|
|
148
188
|
if ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger)) {
|
|
@@ -171,11 +211,11 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
171
211
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
172
212
|
});
|
|
173
213
|
}
|
|
174
|
-
const result = Object.assign(Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
|
|
214
|
+
const result = Object.assign(Object.assign(Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
|
|
175
215
|
? trigger.synchronousResponseSupport
|
|
176
216
|
: scheduleSupport === "invalid"
|
|
177
217
|
? "valid"
|
|
178
|
-
: "invalid" }), ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger) ? { isPollingTrigger: true } : {}));
|
|
218
|
+
: "invalid", triggerResolverSupport }), buildTriggerResolverFields(trigger.display.label, triggerResolverSupport, triggerResolver)), ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger) ? { isPollingTrigger: true } : {}));
|
|
179
219
|
if (onInstanceDeploy) {
|
|
180
220
|
result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
|
|
181
221
|
inputCleaners: triggerInputCleaners,
|
|
@@ -29,6 +29,12 @@ 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
|
+
};
|
|
32
38
|
const convertIntegration = (definition) => {
|
|
33
39
|
var _a, _b, _c;
|
|
34
40
|
// Generate a unique reference key that will be used to reference the
|
|
@@ -403,6 +409,10 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
403
409
|
}
|
|
404
410
|
: {}));
|
|
405
411
|
}
|
|
412
|
+
const triggerResolver = "triggerResolver" in flow ? flow.triggerResolver : undefined;
|
|
413
|
+
if (triggerResolver) {
|
|
414
|
+
result.triggerResolver = validateFlowResolverBatchSize(flow.name, "triggerResolver", triggerResolver);
|
|
415
|
+
}
|
|
406
416
|
const actionStep = {
|
|
407
417
|
action: {
|
|
408
418
|
key: flowFunctionKey(flow.name, "onExecution"),
|
|
@@ -670,7 +680,11 @@ function generateTriggerPerformFn(params) {
|
|
|
670
680
|
case "standard":
|
|
671
681
|
return (0, perform_1.createCNIPerform)({ componentRegistry, onTrigger });
|
|
672
682
|
case "component-ref":
|
|
673
|
-
return (0, perform_1.createCNIComponentRefPerform)({
|
|
683
|
+
return (0, perform_1.createCNIComponentRefPerform)({
|
|
684
|
+
componentRegistry,
|
|
685
|
+
componentRef,
|
|
686
|
+
onTrigger,
|
|
687
|
+
});
|
|
674
688
|
default:
|
|
675
689
|
throw new Error(`Invalid trigger configuration detected: ${JSON.stringify(params, null, 2)}`);
|
|
676
690
|
}
|
|
@@ -739,7 +753,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
739
753
|
inputs: [],
|
|
740
754
|
} });
|
|
741
755
|
}, {});
|
|
742
|
-
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, }) => {
|
|
756
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, triggerResolver, }) => {
|
|
743
757
|
if (!flowUsesWrapperTrigger({
|
|
744
758
|
onTrigger,
|
|
745
759
|
onInstanceDelete,
|
|
@@ -774,26 +788,21 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
774
788
|
const deployFn = generateTriggerEventWrapperFn(ref, onTrigger, "onInstanceDeploy", componentRegistry, onInstanceDeploy);
|
|
775
789
|
const webhookCreateFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookCreate", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.create);
|
|
776
790
|
const webhookDeleteFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookDelete", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.delete);
|
|
777
|
-
return Object.assign(Object.assign({}, result), { [key]: {
|
|
778
|
-
key,
|
|
779
|
-
display: {
|
|
791
|
+
return Object.assign(Object.assign({}, result), { [key]: Object.assign({ key, display: {
|
|
780
792
|
label: `${name} - onTrigger`,
|
|
781
793
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
782
|
-
},
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
synchronousResponseSupport: "valid",
|
|
795
|
-
isPollingTrigger: triggerType === "polling",
|
|
796
|
-
} });
|
|
794
|
+
}, perform: performFn, onInstanceDeploy: deployFn, hasOnInstanceDeploy: !!deployFn, onInstanceDelete: deleteFn, hasOnInstanceDelete: !!deleteFn, webhookCreate: webhookCreateFn, hasWebhookCreateFunction: !!webhookCreateFn, webhookDelete: webhookDeleteFn, hasWebhookDeleteFunction: !!webhookDeleteFn, inputs: [], scheduleSupport: triggerType === "polling" ? "required" : "valid", synchronousResponseSupport: "valid", isPollingTrigger: triggerType === "polling", triggerResolverSupport: triggerResolver ? "valid" : "invalid" }, (triggerResolver
|
|
795
|
+
? Object.assign(Object.assign({ triggerResolverDefaultBatchSize: triggerResolver.batchSize }, (triggerResolver.resolveItems
|
|
796
|
+
? {
|
|
797
|
+
resolveTriggerItems: triggerResolver.resolveItems,
|
|
798
|
+
hasResolveTriggerItems: true,
|
|
799
|
+
}
|
|
800
|
+
: {})), (triggerResolver.getNextDiscoveryState
|
|
801
|
+
? {
|
|
802
|
+
getNextDiscoveryState: triggerResolver.getNextDiscoveryState,
|
|
803
|
+
hasGetNextDiscoveryState: true,
|
|
804
|
+
}
|
|
805
|
+
: {})) : {})) });
|
|
797
806
|
}, {});
|
|
798
807
|
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
799
808
|
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<TPayload extends TriggerPayload = TriggerPayload> {
|
|
116
|
+
payload: TPayload;
|
|
117
117
|
response?: HttpResponse;
|
|
118
118
|
instanceState?: Record<string, unknown>;
|
|
119
119
|
crossFlowState?: Record<string, unknown>;
|
|
@@ -122,12 +122,18 @@ interface TriggerBaseResult {
|
|
|
122
122
|
failed?: boolean;
|
|
123
123
|
error?: Record<string, unknown>;
|
|
124
124
|
}
|
|
125
|
-
interface TriggerBranchingResult extends TriggerBaseResult {
|
|
125
|
+
interface TriggerBranchingResult<TPayload extends TriggerPayload = TriggerPayload> extends TriggerBaseResult<TPayload> {
|
|
126
126
|
branch: string;
|
|
127
127
|
}
|
|
128
|
-
export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
128
|
+
export type TriggerResult<TPayload extends TriggerPayload = TriggerPayload> = TriggerBranchingResult<TPayload> | TriggerBaseResult<TPayload> | 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
|
+
*/
|
|
131
137
|
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>> {
|
|
132
138
|
key: string;
|
|
133
139
|
display: DisplayDefinition & {
|
|
@@ -155,6 +161,12 @@ export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, T
|
|
|
155
161
|
hasWebhookDeleteFunction?: boolean;
|
|
156
162
|
scheduleSupport: TriggerOptionChoice;
|
|
157
163
|
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;
|
|
158
170
|
examplePayload?: unknown;
|
|
159
171
|
isCommonTrigger?: boolean;
|
|
160
172
|
isPollingTrigger?: boolean;
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -291,15 +291,19 @@ export type DateTimeInputField = BaseInputField & {
|
|
|
291
291
|
/** Clean function. */
|
|
292
292
|
clean?: InputCleanFunction<unknown>;
|
|
293
293
|
} & CollectionOptions<string>;
|
|
294
|
-
/** `InputFieldDefinition` minus container input types
|
|
295
|
-
*
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
294
|
+
/** `InputFieldDefinition` minus container input types and connection
|
|
295
|
+
* pickers. Connections resolve to config-var references outside the
|
|
296
|
+
* parent's value tree, so they're only valid at the top level — never as
|
|
297
|
+
* a child of a structuredObject or a dynamicObject configuration. */
|
|
298
|
+
export type LeafInputFieldDefinition = Exclude<InputFieldDefinition, StructuredObjectInputField | DynamicObjectInputField | ConnectionInputField | ConnectionTemplateInputField>;
|
|
299
|
+
/** `LeafInputFieldDefinition` plus `StructuredObjectInputField`; used
|
|
300
|
+
* inside a dynamicObject's `configurations.<key>.inputs` to allow leaves
|
|
301
|
+
* and structuredObject children while still rejecting nested
|
|
302
|
+
* dynamicObjects and connection pickers. */
|
|
303
|
+
export type StructuredOrLeafInputFieldDefinition = LeafInputFieldDefinition | StructuredObjectInputField;
|
|
301
304
|
/** Groups related primitive inputs under a single named container.
|
|
302
|
-
* Nesting is capped at one level.
|
|
305
|
+
* Nesting is capped at one level. Connection pickers are rejected as
|
|
306
|
+
* children — they may only appear at the top level. */
|
|
303
307
|
export type StructuredObjectInputField = Omit<BaseInputField, "dataSource"> & {
|
|
304
308
|
/** Data type the input will collect. */
|
|
305
309
|
type: "structuredObject";
|
|
@@ -317,9 +321,7 @@ export interface DynamicObjectConfiguration {
|
|
|
317
321
|
} | string;
|
|
318
322
|
/** Additional text to give guidance to the user when this configuration is selected. */
|
|
319
323
|
comments?: string;
|
|
320
|
-
/** Inputs that become available when this configuration is selected.
|
|
321
|
-
* include leaf inputs and structuredObject inputs; nested dynamicObjects
|
|
322
|
-
* are rejected at the type level. */
|
|
324
|
+
/** Inputs that become available when this configuration is selected. */
|
|
323
325
|
inputs: Record<string, StructuredOrLeafInputFieldDefinition>;
|
|
324
326
|
}
|
|
325
327
|
/** Presents a discriminated set of input groups; the user picks a configuration
|
|
@@ -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 { Inputs } from "./Inputs";
|
|
7
|
+
import type { ConfigVarResultCollection, 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 { TriggerResult } from "./TriggerResult";
|
|
13
|
+
import type { TriggerBaseResult, 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,6 +117,13 @@ 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>;
|
|
120
127
|
/** Error handling configuration. */
|
|
121
128
|
errorConfig?: StepErrorConfig;
|
|
122
129
|
/** Optional schemas definitions for the flow. Currently only for use with AI agents. */
|
|
@@ -246,4 +253,15 @@ export type EndpointType = "flow_specific" | "instance_specific" | "shared_insta
|
|
|
246
253
|
export type EndpointSecurityType = "unsecured" | "customer_optional" | "customer_required" | "organization";
|
|
247
254
|
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
248
255
|
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
|
+
};
|
|
249
267
|
export {};
|
|
@@ -4,6 +4,7 @@ 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";
|
|
7
8
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
8
9
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
9
10
|
import type { TriggerResult } from "./TriggerResult";
|
|
@@ -18,8 +19,12 @@ export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs
|
|
|
18
19
|
/**
|
|
19
20
|
* PollingTriggerDefinition is the type of the object that is passed in to `pollingTrigger` function to
|
|
20
21
|
* define a component trigger.
|
|
22
|
+
*
|
|
23
|
+
* Composed from `PollingTriggerDefinitionBase` plus `TriggerResolverDecl`, which
|
|
24
|
+
* enforces the resolver support relationship at the type level.
|
|
21
25
|
*/
|
|
22
|
-
export
|
|
26
|
+
export type 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> = PollingTriggerDefinitionBase<TInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TActionInputs, TAction, TCombinedInputs> & TriggerResolverDecl<TConfigVars, TPayload>;
|
|
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> {
|
|
23
28
|
triggerType?: "polling";
|
|
24
29
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
25
30
|
display: ActionDisplayDefinition;
|
|
@@ -39,3 +44,4 @@ export interface PollingTriggerDefinition<TInputs extends Inputs = Inputs, TConf
|
|
|
39
44
|
examplePayload?: Awaited<ReturnType<this["perform"]>>;
|
|
40
45
|
}
|
|
41
46
|
export declare const isPollingTriggerDefinition: (ref: unknown) => ref is PollingTriggerDefinition;
|
|
47
|
+
export {};
|
|
@@ -1,18 +1,51 @@
|
|
|
1
|
+
import type { ActionContext } from "./ActionPerformFunction";
|
|
1
2
|
import type { ActionDisplayDefinition } from "./DisplayDefinition";
|
|
2
3
|
import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
3
4
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
4
5
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
5
6
|
import type { TriggerPerformFunction } from "./TriggerPerformFunction";
|
|
6
|
-
import type { TriggerResult } from "./TriggerResult";
|
|
7
|
+
import type { TriggerBaseResult, TriggerResult } from "./TriggerResult";
|
|
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
|
+
};
|
|
7
24
|
declare const optionChoices: readonly ["invalid", "valid", "required"];
|
|
8
25
|
export type TriggerOptionChoice = (typeof optionChoices)[number];
|
|
9
26
|
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
|
+
}
|
|
10
38
|
/**
|
|
11
39
|
* TriggerDefinition is the type of the object that is passed in to `trigger` function to
|
|
12
40
|
* define a component trigger. See
|
|
13
41
|
* 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.
|
|
14
46
|
*/
|
|
15
|
-
export
|
|
47
|
+
export type TriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> = TriggerDefinitionBase<TInputs, TConfigVars, TAllowsBranching, TResult> & TriggerResolverDecl<TConfigVars, TriggerPayload>;
|
|
48
|
+
interface TriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
16
49
|
/** Defines how the trigger is displayed in the Prismatic UI. */
|
|
17
50
|
display: ActionDisplayDefinition;
|
|
18
51
|
/** Function to perform when this trigger is invoked. */
|
|
@@ -3,8 +3,13 @@ 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
|
-
|
|
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>> {
|
|
8
13
|
/** The headers sent in the webhook request. */
|
|
9
14
|
headers: {
|
|
10
15
|
[key: string]: string;
|
|
@@ -50,4 +55,8 @@ export interface TriggerPayload {
|
|
|
50
55
|
startedAt: string;
|
|
51
56
|
/** Determines whether the execution will run in debug mode. */
|
|
52
57
|
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;
|
|
53
62
|
}
|