@prismatic-io/spectral 10.18.7-preview.5 → 10.18.7-preview.6
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/index.d.ts +43 -2
- package/dist/index.js +47 -2
- package/dist/serverTypes/convertComponent.d.ts +9 -3
- package/dist/serverTypes/convertComponent.js +85 -10
- package/dist/serverTypes/convertIntegration.js +52 -12
- package/dist/serverTypes/index.d.ts +16 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +5 -1
- package/dist/types/IntegrationDefinition.d.ts +58 -27
- package/dist/types/PollingTriggerDefinition.d.ts +10 -4
- package/dist/types/TriggerDefinition.d.ts +81 -17
- package/dist/types/TriggerPerformFunction.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { convertComponent } from "./serverTypes/convertComponent";
|
|
7
7
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
8
|
-
import type { ActionDefinition, ActionPerformReturn, ComponentDefinition, ComponentManifest, ConfigPage, ConfigVarResultCollection, ConnectionConfigVar, CustomerActivatedConnectionConfigVar, DataSourceConfigVar, DataSourceDefinition, DataSourceType, DefaultConnectionDefinition, DynamicObjectInputField, Flow, InputFieldDefinition, Inputs, IntegrationDefinition, OAuth2ConnectionDefinition, OnPremConnectionDefinition, OrganizationActivatedConnectionConfigVar, StandardConfigVar, StructuredObjectInputField, TriggerDefinition, TriggerPayload, TriggerResult } from "./types";
|
|
8
|
+
import type { ActionDefinition, ActionPerformReturn, ComponentDefinition, ComponentManifest, ConfigPage, ConfigVarResultCollection, ConfigVars, ConnectionConfigVar, CustomerActivatedConnectionConfigVar, DataSourceConfigVar, DataSourceDefinition, DataSourceType, DefaultConnectionDefinition, DynamicObjectInputField, Flow, InputFieldDefinition, Inputs, IntegrationDefinition, OAuth2ConnectionDefinition, OnPremConnectionDefinition, OrganizationActivatedConnectionConfigVar, StandardConfigVar, StructuredObjectInputField, TriggerDefinition, TriggerPayload, TriggerResolverBehavior, TriggerResult } from "./types";
|
|
9
9
|
import type { PollingTriggerDefinition } from "./types/PollingTriggerDefinition";
|
|
10
10
|
/**
|
|
11
11
|
* This function creates a code-native integration object that can be
|
|
@@ -73,7 +73,48 @@ export declare const integration: <TInputs extends Inputs, TActionInputs extends
|
|
|
73
73
|
* },
|
|
74
74
|
* });
|
|
75
75
|
*/
|
|
76
|
-
export declare const flow: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload> = Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload>>(definition: T
|
|
76
|
+
export declare const flow: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>, T extends Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload, TItem, TDiscoveryState> = Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload, TItem, TDiscoveryState>>(definition: T & {
|
|
77
|
+
triggerResolver?: TriggerResolverBehavior<ConfigVars, TriggerPayload, TItem, TDiscoveryState>;
|
|
78
|
+
onDeployResolver?: TriggerResolverBehavior<ConfigVars, TriggerPayload, TItem, TDiscoveryState>;
|
|
79
|
+
}) => T;
|
|
80
|
+
/**
|
|
81
|
+
* Builds a flow's `triggerResolver` — the behavior that extracts the records a trigger
|
|
82
|
+
* returns into batched dispatches and (optionally) paginates. Batch *sizing* comes from
|
|
83
|
+
* the flow's `batch` config, not from here. Supply the item and pagination-cursor types
|
|
84
|
+
* explicitly — `triggerResolver<Order, { cursor: number }>({ ... })` — and they flow
|
|
85
|
+
* through the whole chain: `resolveItems` returns `Order[]`, `result.payload.discoveryState`
|
|
86
|
+
* reads back as `{ cursor: number }`, and the flow's `onExecution` sees
|
|
87
|
+
* `params.onTrigger.results.body.data` typed as `Order | Order[]`.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam TItem - the item type each batched execution receives.
|
|
90
|
+
* @typeParam TDiscoveryState - the pagination cursor shape round-tripped via `payload.discoveryState`.
|
|
91
|
+
* @see {@link https://prismatic.io/docs/integrations/code-native/flows/ | Code-Native Flows}
|
|
92
|
+
* @example
|
|
93
|
+
* import { flow, triggerResolver } from "@prismatic-io/spectral";
|
|
94
|
+
*
|
|
95
|
+
* flow({
|
|
96
|
+
* // ...
|
|
97
|
+
* batch: { batchSize: 50 },
|
|
98
|
+
* triggerResolver: triggerResolver<Order, { cursor: number }>({
|
|
99
|
+
* resolveItems: (context, result) => result.payload.body.data as Order[],
|
|
100
|
+
* getNextDiscoveryState: (context, result) => {
|
|
101
|
+
* const next = result.payload.discoveryState?.cursor; // number | undefined
|
|
102
|
+
* return next === undefined ? null : { cursor: next };
|
|
103
|
+
* },
|
|
104
|
+
* }),
|
|
105
|
+
* });
|
|
106
|
+
*/
|
|
107
|
+
export declare const triggerResolver: <TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>, TConfigVars extends ConfigVarResultCollection = ConfigVars, TPayload extends TriggerPayload = TriggerPayload>(resolver: TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>) => TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>;
|
|
108
|
+
/**
|
|
109
|
+
* Builds a flow's `onDeployResolver` — the resolver behavior for the `onDeployTrigger`
|
|
110
|
+
* fire that runs once when an instance is first deployed. Identical in shape to
|
|
111
|
+
* {@link triggerResolver} and shares the flow's `batch` config; named separately so the
|
|
112
|
+
* call site reads as the sibling of `onDeployTrigger`.
|
|
113
|
+
*
|
|
114
|
+
* @typeParam TItem - the item type each batched on-deploy execution receives.
|
|
115
|
+
* @typeParam TDiscoveryState - the pagination cursor shape round-tripped via `payload.discoveryState`.
|
|
116
|
+
*/
|
|
117
|
+
export declare const onDeployResolver: <TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>, TConfigVars extends ConfigVarResultCollection = ConfigVars, TPayload extends TriggerPayload = TriggerPayload>(resolver: TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>) => TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>;
|
|
77
118
|
/**
|
|
78
119
|
* This function creates a config wizard page object for use in code-native
|
|
79
120
|
* integrations.
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.util = exports.testing = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.dynamicObjectInput = exports.structuredObjectInput = exports.input = exports.dataSource = exports.pollingTrigger = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.customerActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
25
|
+
exports.util = exports.testing = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.dynamicObjectInput = exports.structuredObjectInput = exports.input = exports.dataSource = exports.pollingTrigger = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.customerActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.onDeployResolver = exports.triggerResolver = exports.flow = exports.integration = void 0;
|
|
26
26
|
const serverTypes_1 = require("./serverTypes");
|
|
27
27
|
const convertComponent_1 = require("./serverTypes/convertComponent");
|
|
28
28
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
@@ -102,8 +102,53 @@ exports.integration = integration;
|
|
|
102
102
|
* },
|
|
103
103
|
* });
|
|
104
104
|
*/
|
|
105
|
-
const flow = (
|
|
105
|
+
const flow = (
|
|
106
|
+
// The intersection adds an explicit inference site for `TItem`/`TDiscoveryState`
|
|
107
|
+
// (from the resolver's `resolveItems` / `getNextDiscoveryState` return types) that
|
|
108
|
+
// the `T extends Flow<...>` capture alone does not provide, while `T` still preserves
|
|
109
|
+
// the precise literal type for the return value.
|
|
110
|
+
definition) => definition;
|
|
106
111
|
exports.flow = flow;
|
|
112
|
+
/**
|
|
113
|
+
* Builds a flow's `triggerResolver` — the behavior that extracts the records a trigger
|
|
114
|
+
* returns into batched dispatches and (optionally) paginates. Batch *sizing* comes from
|
|
115
|
+
* the flow's `batch` config, not from here. Supply the item and pagination-cursor types
|
|
116
|
+
* explicitly — `triggerResolver<Order, { cursor: number }>({ ... })` — and they flow
|
|
117
|
+
* through the whole chain: `resolveItems` returns `Order[]`, `result.payload.discoveryState`
|
|
118
|
+
* reads back as `{ cursor: number }`, and the flow's `onExecution` sees
|
|
119
|
+
* `params.onTrigger.results.body.data` typed as `Order | Order[]`.
|
|
120
|
+
*
|
|
121
|
+
* @typeParam TItem - the item type each batched execution receives.
|
|
122
|
+
* @typeParam TDiscoveryState - the pagination cursor shape round-tripped via `payload.discoveryState`.
|
|
123
|
+
* @see {@link https://prismatic.io/docs/integrations/code-native/flows/ | Code-Native Flows}
|
|
124
|
+
* @example
|
|
125
|
+
* import { flow, triggerResolver } from "@prismatic-io/spectral";
|
|
126
|
+
*
|
|
127
|
+
* flow({
|
|
128
|
+
* // ...
|
|
129
|
+
* batch: { batchSize: 50 },
|
|
130
|
+
* triggerResolver: triggerResolver<Order, { cursor: number }>({
|
|
131
|
+
* resolveItems: (context, result) => result.payload.body.data as Order[],
|
|
132
|
+
* getNextDiscoveryState: (context, result) => {
|
|
133
|
+
* const next = result.payload.discoveryState?.cursor; // number | undefined
|
|
134
|
+
* return next === undefined ? null : { cursor: next };
|
|
135
|
+
* },
|
|
136
|
+
* }),
|
|
137
|
+
* });
|
|
138
|
+
*/
|
|
139
|
+
const triggerResolver = (resolver) => resolver;
|
|
140
|
+
exports.triggerResolver = triggerResolver;
|
|
141
|
+
/**
|
|
142
|
+
* Builds a flow's `onDeployResolver` — the resolver behavior for the `onDeployTrigger`
|
|
143
|
+
* fire that runs once when an instance is first deployed. Identical in shape to
|
|
144
|
+
* {@link triggerResolver} and shares the flow's `batch` config; named separately so the
|
|
145
|
+
* call site reads as the sibling of `onDeployTrigger`.
|
|
146
|
+
*
|
|
147
|
+
* @typeParam TItem - the item type each batched on-deploy execution receives.
|
|
148
|
+
* @typeParam TDiscoveryState - the pagination cursor shape round-tripped via `payload.discoveryState`.
|
|
149
|
+
*/
|
|
150
|
+
const onDeployResolver = (resolver) => resolver;
|
|
151
|
+
exports.onDeployResolver = onDeployResolver;
|
|
107
152
|
/**
|
|
108
153
|
* This function creates a config wizard page object for use in code-native
|
|
109
154
|
* integrations.
|
|
@@ -8,11 +8,17 @@ import { type CleanFn } from "./perform";
|
|
|
8
8
|
* supplies one so nested clean functions are applied at runtime. */
|
|
9
9
|
export declare const cleanerFor: (input: InputFieldDefinition) => CleanFn | undefined;
|
|
10
10
|
/**
|
|
11
|
-
* Throws if `batchSize` isn't a positive integer; otherwise returns it.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Throws if `batchSize` isn't a positive integer; otherwise returns it. Shared by the
|
|
12
|
+
* component-trigger (`TriggerDefinition.batch.batchSize`) and CNI flow (`flow.batch.batchSize`)
|
|
13
|
+
* validation paths.
|
|
14
14
|
*/
|
|
15
15
|
export declare const validateBatchSize: (ownerLabel: string, fieldName: string, batchSize: unknown) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Throws if `concurrentBatchLimit` is set but isn't a positive integer; returns it
|
|
18
|
+
* unchanged (including `undefined`, which the platform treats as unlimited). Shared by the
|
|
19
|
+
* component-trigger and CNI flow paths, both sourcing it from the single `batchConfig`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const validateConcurrentBatchLimit: (ownerLabel: string, fieldName: string, concurrentBatchLimit: unknown) => number | undefined;
|
|
16
22
|
export declare const convertInput: (key: string, definition: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
|
|
17
23
|
export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
18
24
|
[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.validateBatchSize = exports.cleanerFor = void 0;
|
|
17
|
+
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.validateConcurrentBatchLimit = 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");
|
|
@@ -61,9 +61,9 @@ const cleanerFor = (input) => {
|
|
|
61
61
|
};
|
|
62
62
|
exports.cleanerFor = cleanerFor;
|
|
63
63
|
/**
|
|
64
|
-
* Throws if `batchSize` isn't a positive integer; otherwise returns it.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
64
|
+
* Throws if `batchSize` isn't a positive integer; otherwise returns it. Shared by the
|
|
65
|
+
* component-trigger (`TriggerDefinition.batch.batchSize`) and CNI flow (`flow.batch.batchSize`)
|
|
66
|
+
* validation paths.
|
|
67
67
|
*/
|
|
68
68
|
const validateBatchSize = (ownerLabel, fieldName, batchSize) => {
|
|
69
69
|
if (typeof batchSize !== "number" || !Number.isInteger(batchSize) || batchSize < 1) {
|
|
@@ -72,11 +72,48 @@ const validateBatchSize = (ownerLabel, fieldName, batchSize) => {
|
|
|
72
72
|
return batchSize;
|
|
73
73
|
};
|
|
74
74
|
exports.validateBatchSize = validateBatchSize;
|
|
75
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Throws if `concurrentBatchLimit` is set but isn't a positive integer; returns it
|
|
77
|
+
* unchanged (including `undefined`, which the platform treats as unlimited). Shared by the
|
|
78
|
+
* component-trigger and CNI flow paths, both sourcing it from the single `batchConfig`.
|
|
79
|
+
*/
|
|
80
|
+
const validateConcurrentBatchLimit = (ownerLabel, fieldName, concurrentBatchLimit) => {
|
|
81
|
+
if (concurrentBatchLimit === undefined) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
if (typeof concurrentBatchLimit !== "number" ||
|
|
85
|
+
!Number.isInteger(concurrentBatchLimit) ||
|
|
86
|
+
concurrentBatchLimit < 1) {
|
|
87
|
+
throw new Error(`${ownerLabel} has an invalid ${fieldName} concurrentBatchLimit of ${String(concurrentBatchLimit)}. concurrentBatchLimit must be an integer >= 1.`);
|
|
88
|
+
}
|
|
89
|
+
return concurrentBatchLimit;
|
|
90
|
+
};
|
|
91
|
+
exports.validateConcurrentBatchLimit = validateConcurrentBatchLimit;
|
|
92
|
+
/**
|
|
93
|
+
* Emits the trigger's single default batch size to the one wire field the platform reads
|
|
94
|
+
* (`triggerResolverDefaultBatchSize`), shared by both the trigger and on-deploy resolution.
|
|
95
|
+
* Emitted when the trigger declares a resolver — `triggerResolverSupport` `"valid"`/`"required"`
|
|
96
|
+
* for the normal path, or an `onDeployResolver` for the on-deploy path. Defaults to 1 when no
|
|
97
|
+
* `batchConfig` was declared.
|
|
98
|
+
*/
|
|
99
|
+
const buildBatchDefaultField = (triggerLabel, triggerResolverSupport, hasOnDeployResolver, batchConfig) => {
|
|
100
|
+
if (triggerResolverSupport === "invalid" && !hasOnDeployResolver) {
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
103
|
+
const concurrentBatchLimit = batchConfig
|
|
104
|
+
? (0, exports.validateConcurrentBatchLimit)(`Trigger "${triggerLabel}"`, "batchConfig", batchConfig.concurrentBatchLimit)
|
|
105
|
+
: undefined;
|
|
106
|
+
return Object.assign({ triggerResolverDefaultBatchSize: batchConfig
|
|
107
|
+
? (0, exports.validateBatchSize)(`Trigger "${triggerLabel}"`, "batchConfig", batchConfig.batchSize)
|
|
108
|
+
: 1 }, (concurrentBatchLimit !== undefined
|
|
109
|
+
? { triggerResolverDefaultConcurrentBatchLimit: concurrentBatchLimit }
|
|
110
|
+
: {}));
|
|
111
|
+
};
|
|
112
|
+
const buildTriggerResolverFields = (resolver) => {
|
|
76
113
|
if (!resolver) {
|
|
77
|
-
return
|
|
114
|
+
return {};
|
|
78
115
|
}
|
|
79
|
-
return Object.assign(Object.assign({
|
|
116
|
+
return Object.assign(Object.assign({}, (resolver.resolveItems
|
|
80
117
|
? {
|
|
81
118
|
resolveTriggerItems: resolver.resolveItems,
|
|
82
119
|
hasResolveTriggerItems: true,
|
|
@@ -88,6 +125,22 @@ const buildTriggerResolverFields = (triggerLabel, support, resolver) => {
|
|
|
88
125
|
}
|
|
89
126
|
: {}));
|
|
90
127
|
};
|
|
128
|
+
const buildOnDeployResolverFields = (resolver) => {
|
|
129
|
+
if (!resolver) {
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
132
|
+
return Object.assign(Object.assign({}, (resolver.resolveItems
|
|
133
|
+
? {
|
|
134
|
+
resolveOnDeployItems: resolver.resolveItems,
|
|
135
|
+
hasResolveOnDeployItems: true,
|
|
136
|
+
}
|
|
137
|
+
: {})), (resolver.getNextDiscoveryState
|
|
138
|
+
? {
|
|
139
|
+
getOnDeployNextDiscoveryState: resolver.getNextDiscoveryState,
|
|
140
|
+
hasGetOnDeployNextDiscoveryState: true,
|
|
141
|
+
}
|
|
142
|
+
: {}));
|
|
143
|
+
};
|
|
91
144
|
const convertInput = (key, definition) => {
|
|
92
145
|
// Cast: the field union is wider than any single member; runtime guards below handle it.
|
|
93
146
|
const _a = definition, { default: defaultValue, type, label, collection, inputs: childInputs, configurations } = _a, rest = __rest(_a, ["default", "type", "label", "collection", "inputs", "configurations"]);
|
|
@@ -160,7 +213,14 @@ const convertAction = (actionKey, _a, hooks) => {
|
|
|
160
213
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
161
214
|
}) });
|
|
162
215
|
};
|
|
163
|
-
const convertTrigger = (triggerKey,
|
|
216
|
+
const convertTrigger = (triggerKey,
|
|
217
|
+
// `any` is load-bearing: the user-facing TriggerDefinition / PollingTriggerDefinition
|
|
218
|
+
// type their event-function fields (onInstanceDeploy, webhookLifecycleHandlers, etc.) over
|
|
219
|
+
// TInputs/TConfigVars/TPayload, while the wire-format ServerTrigger drops those generics.
|
|
220
|
+
// The `...trigger` spread in the result construction below would surface variance errors
|
|
221
|
+
// without these `any`s. The user-typed handlers are immediately replaced with
|
|
222
|
+
// createPerform-wrapped versions, so the loose input typing is safe in practice.
|
|
223
|
+
trigger, hooks) => {
|
|
164
224
|
var _a;
|
|
165
225
|
const { onInstanceDeploy, onInstanceDelete } = trigger;
|
|
166
226
|
const webhookLifecycleHandlers = "webhookLifecycleHandlers" in trigger ? trigger.webhookLifecycleHandlers : undefined;
|
|
@@ -171,6 +231,7 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
171
231
|
});
|
|
172
232
|
const triggerInputCleaners = Object.entries(inputs).reduce((result, [key, value]) => (Object.assign(Object.assign({}, result), { [key]: (0, exports.cleanerFor)(value) })), {});
|
|
173
233
|
let scheduleSupport = "scheduleSupport" in trigger ? trigger.scheduleSupport : "invalid";
|
|
234
|
+
const batchConfig = "batchConfig" in trigger ? trigger.batchConfig : undefined;
|
|
174
235
|
const triggerResolver = "triggerResolver" in trigger ? trigger.triggerResolver : undefined;
|
|
175
236
|
const triggerResolverSupport = "triggerResolverSupport" in trigger && trigger.triggerResolverSupport !== undefined
|
|
176
237
|
? trigger.triggerResolverSupport
|
|
@@ -183,6 +244,13 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
183
244
|
if (triggerResolverSupport === "invalid" && triggerResolver) {
|
|
184
245
|
throw new Error(`Trigger "${trigger.display.label}" declares triggerResolver but triggerResolverSupport is "invalid".`);
|
|
185
246
|
}
|
|
247
|
+
const onDeployPerform = "onDeployPerform" in trigger ? trigger.onDeployPerform : undefined;
|
|
248
|
+
const onDeployResolver = "onDeployResolver" in trigger ? trigger.onDeployResolver : undefined;
|
|
249
|
+
// On-deploy is presence-driven (no support flag): a trigger that defines an
|
|
250
|
+
// `onDeployResolver` must also define the `onDeployPerform` fire it batches.
|
|
251
|
+
if ((onDeployResolver === null || onDeployResolver === void 0 ? void 0 : onDeployResolver.resolveItems) && !onDeployPerform) {
|
|
252
|
+
throw new Error(`Trigger "${trigger.display.label}" declares onDeployResolver.resolveItems but is missing onDeployPerform.`);
|
|
253
|
+
}
|
|
186
254
|
let convertedActionInputs = [];
|
|
187
255
|
let performToUse;
|
|
188
256
|
if ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger)) {
|
|
@@ -211,11 +279,11 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
211
279
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
212
280
|
});
|
|
213
281
|
}
|
|
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
|
|
282
|
+
const result = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (0, omit_1.default)(trigger, ["batchConfig", "triggerResolver", "onDeployResolver"])), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
|
|
215
283
|
? trigger.synchronousResponseSupport
|
|
216
284
|
: scheduleSupport === "invalid"
|
|
217
285
|
? "valid"
|
|
218
|
-
: "invalid", triggerResolverSupport }),
|
|
286
|
+
: "invalid", triggerResolverSupport }), buildBatchDefaultField(trigger.display.label, triggerResolverSupport, !!(onDeployResolver === null || onDeployResolver === void 0 ? void 0 : onDeployResolver.resolveItems), batchConfig)), buildTriggerResolverFields(triggerResolver)), buildOnDeployResolverFields(onDeployResolver)), ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger) ? { isPollingTrigger: true } : {}));
|
|
219
287
|
if (onInstanceDeploy) {
|
|
220
288
|
result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
|
|
221
289
|
inputCleaners: triggerInputCleaners,
|
|
@@ -223,6 +291,13 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
223
291
|
});
|
|
224
292
|
result.hasOnInstanceDeploy = true;
|
|
225
293
|
}
|
|
294
|
+
if (onDeployPerform) {
|
|
295
|
+
result.onDeployPerform = (0, perform_1.createPerform)(onDeployPerform, {
|
|
296
|
+
inputCleaners: triggerInputCleaners,
|
|
297
|
+
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
298
|
+
});
|
|
299
|
+
result.hasOnDeployPerform = true;
|
|
300
|
+
}
|
|
226
301
|
if (onInstanceDelete) {
|
|
227
302
|
result.onInstanceDelete = (0, perform_1.createPerform)(onInstanceDelete, {
|
|
228
303
|
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
|
|
@@ -325,6 +319,7 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
325
319
|
result.onInstanceDelete = undefined;
|
|
326
320
|
result.webhookLifecycleHandlers = undefined;
|
|
327
321
|
result.onExecution = undefined;
|
|
322
|
+
result.onDeployTrigger = undefined;
|
|
328
323
|
result.preprocessFlowConfig = undefined;
|
|
329
324
|
result.errorConfig = undefined;
|
|
330
325
|
result.testApiKeys = undefined;
|
|
@@ -410,8 +405,28 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
410
405
|
: {}));
|
|
411
406
|
}
|
|
412
407
|
const triggerResolver = "triggerResolver" in flow ? flow.triggerResolver : undefined;
|
|
413
|
-
|
|
414
|
-
|
|
408
|
+
const onDeployResolver = "onDeployResolver" in flow ? flow.onDeployResolver : undefined;
|
|
409
|
+
const batchConfig = "batchConfig" in flow ? flow.batchConfig : undefined;
|
|
410
|
+
// Resolver behaviors (resolveItems/getNextDiscoveryState) are serialized onto the
|
|
411
|
+
// synthesized trigger below. On the flow wire we emit only `triggerResolver`, the single
|
|
412
|
+
// config the platform reads (`trigger_resolver_batch_size` / `trigger_resolver_enabled`)
|
|
413
|
+
// and shares between the normal and on-deploy fires. `batchConfig`/`onDeployResolver` are
|
|
414
|
+
// author-side only — clear them out of the `{ ...flow }` spread.
|
|
415
|
+
result.triggerResolver = undefined;
|
|
416
|
+
result.onDeployResolver = undefined;
|
|
417
|
+
result.batchConfig = undefined;
|
|
418
|
+
if (triggerResolver || onDeployResolver) {
|
|
419
|
+
if (!batchConfig) {
|
|
420
|
+
throw new Error(`${flow.name} defines a triggerResolver/onDeployResolver but no batchConfig. Add \`batchConfig: { batchSize }\` to the flow.`);
|
|
421
|
+
}
|
|
422
|
+
if (onDeployResolver &&
|
|
423
|
+
(!("onDeployTrigger" in flow) || typeof flow.onDeployTrigger !== "function")) {
|
|
424
|
+
throw new Error(`${flow.name} declares onDeployResolver without onDeployTrigger. Set onDeployTrigger to handle the initial-deploy fire that the resolver fans out.`);
|
|
425
|
+
}
|
|
426
|
+
// `enabled: true` is required: for a "valid"-support trigger (which CNI synthesized
|
|
427
|
+
// triggers are) the platform only batches when the flow's resolver is enabled.
|
|
428
|
+
const concurrentBatchLimit = (0, convertComponent_1.validateConcurrentBatchLimit)(flow.name, "batchConfig", batchConfig.concurrentBatchLimit);
|
|
429
|
+
result.triggerResolver = Object.assign({ batchSize: (0, convertComponent_1.validateBatchSize)(flow.name, "batchConfig", batchConfig.batchSize), enabled: true }, (concurrentBatchLimit !== undefined ? { concurrentBatchLimit } : {}));
|
|
415
430
|
}
|
|
416
431
|
const actionStep = {
|
|
417
432
|
action: {
|
|
@@ -753,7 +768,8 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
753
768
|
inputs: [],
|
|
754
769
|
} });
|
|
755
770
|
}, {});
|
|
756
|
-
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, triggerResolver, }) => {
|
|
771
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, batchConfig, triggerResolver, onDeployTrigger, onDeployResolver, }) => {
|
|
772
|
+
var _a;
|
|
757
773
|
if (!flowUsesWrapperTrigger({
|
|
758
774
|
onTrigger,
|
|
759
775
|
onInstanceDelete,
|
|
@@ -788,11 +804,16 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
788
804
|
const deployFn = generateTriggerEventWrapperFn(ref, onTrigger, "onInstanceDeploy", componentRegistry, onInstanceDeploy);
|
|
789
805
|
const webhookCreateFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookCreate", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.create);
|
|
790
806
|
const webhookDeleteFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookDelete", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.delete);
|
|
791
|
-
return Object.assign(Object.assign({}, result), { [key]: Object.assign({ key, display: {
|
|
807
|
+
return Object.assign(Object.assign({}, result), { [key]: Object.assign(Object.assign(Object.assign(Object.assign({ key, display: {
|
|
792
808
|
label: `${name} - onTrigger`,
|
|
793
809
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
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(
|
|
810
|
+
}, 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 || onDeployResolver
|
|
811
|
+
? Object.assign({ triggerResolverDefaultBatchSize: (_a = batchConfig === null || batchConfig === void 0 ? void 0 : batchConfig.batchSize) !== null && _a !== void 0 ? _a : 1 }, ((batchConfig === null || batchConfig === void 0 ? void 0 : batchConfig.concurrentBatchLimit) !== undefined
|
|
812
|
+
? {
|
|
813
|
+
triggerResolverDefaultConcurrentBatchLimit: batchConfig.concurrentBatchLimit,
|
|
814
|
+
}
|
|
815
|
+
: {})) : {})), (triggerResolver
|
|
816
|
+
? Object.assign(Object.assign({}, (triggerResolver.resolveItems
|
|
796
817
|
? {
|
|
797
818
|
resolveTriggerItems: triggerResolver.resolveItems,
|
|
798
819
|
hasResolveTriggerItems: true,
|
|
@@ -802,6 +823,25 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
802
823
|
getNextDiscoveryState: triggerResolver.getNextDiscoveryState,
|
|
803
824
|
hasGetNextDiscoveryState: true,
|
|
804
825
|
}
|
|
826
|
+
: {})) : {})), (onDeployTrigger
|
|
827
|
+
? {
|
|
828
|
+
onDeployPerform: (0, perform_1.createCNIPerform)({
|
|
829
|
+
componentRegistry,
|
|
830
|
+
onTrigger: onDeployTrigger,
|
|
831
|
+
}),
|
|
832
|
+
hasOnDeployPerform: true,
|
|
833
|
+
}
|
|
834
|
+
: {})), (onDeployResolver
|
|
835
|
+
? Object.assign(Object.assign({}, (onDeployResolver.resolveItems
|
|
836
|
+
? {
|
|
837
|
+
resolveOnDeployItems: onDeployResolver.resolveItems,
|
|
838
|
+
hasResolveOnDeployItems: true,
|
|
839
|
+
}
|
|
840
|
+
: {})), (onDeployResolver.getNextDiscoveryState
|
|
841
|
+
? {
|
|
842
|
+
getOnDeployNextDiscoveryState: onDeployResolver.getNextDiscoveryState,
|
|
843
|
+
hasGetOnDeployNextDiscoveryState: true,
|
|
844
|
+
}
|
|
805
845
|
: {})) : {})) });
|
|
806
846
|
}, {});
|
|
807
847
|
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
@@ -133,6 +133,11 @@ export type TriggerEventFunction = (context: ActionContext, params: Record<strin
|
|
|
133
133
|
* (perform, resolveTriggerItems, getNextDiscoveryState, ...) don't survive JSON
|
|
134
134
|
* serialization, so each callback has a paired `hasXxx: boolean` flag the
|
|
135
135
|
* server reads to detect presence. Keep the flag and its callback in sync.
|
|
136
|
+
*
|
|
137
|
+
* The on-deploy fire is named asymmetrically by intent: CNI flow authors set
|
|
138
|
+
* `onDeployTrigger` (sibling to `onTrigger`), component-trigger authors set
|
|
139
|
+
* `onDeployPerform` (sibling to `perform`), and both flatten to
|
|
140
|
+
* `onDeployPerform` here on the wire.
|
|
136
141
|
*/
|
|
137
142
|
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
143
|
key: string;
|
|
@@ -162,11 +167,22 @@ export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, T
|
|
|
162
167
|
scheduleSupport: TriggerOptionChoice;
|
|
163
168
|
synchronousResponseSupport: TriggerOptionChoice;
|
|
164
169
|
triggerResolverSupport?: TriggerOptionChoice;
|
|
170
|
+
/**
|
|
171
|
+
* The single default batch size shared by the trigger and on-deploy resolvers. The
|
|
172
|
+
* platform reads only this field for both paths; there is no separate on-deploy default.
|
|
173
|
+
*/
|
|
165
174
|
triggerResolverDefaultBatchSize?: number;
|
|
175
|
+
triggerResolverDefaultConcurrentBatchLimit?: number;
|
|
166
176
|
resolveTriggerItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => unknown[];
|
|
167
177
|
hasResolveTriggerItems?: boolean;
|
|
168
178
|
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
169
179
|
hasGetNextDiscoveryState?: boolean;
|
|
180
|
+
onDeployPerform?: TriggerPerformFunction<TInputs, TConfigVars, TAllowsBranching, TResult> | PollingTriggerPerformFunction<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult> | CNIPollingPerformFunction<TInputs, TConfigVars, TPayload, TAllowsBranching> | ComponentRefTriggerPerformFunction<TInputs, TConfigVars>;
|
|
181
|
+
hasOnDeployPerform?: boolean;
|
|
182
|
+
resolveOnDeployItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => unknown[];
|
|
183
|
+
hasResolveOnDeployItems?: boolean;
|
|
184
|
+
getOnDeployNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
185
|
+
hasGetOnDeployNextDiscoveryState?: boolean;
|
|
170
186
|
examplePayload?: unknown;
|
|
171
187
|
isCommonTrigger?: boolean;
|
|
172
188
|
isPollingTrigger?: boolean;
|
package/dist/testing.d.ts
CHANGED
|
@@ -217,7 +217,7 @@ type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
|
217
217
|
* expect(result.data).toBeDefined();
|
|
218
218
|
* });
|
|
219
219
|
*/
|
|
220
|
-
export declare const invokeFlow: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TPayload> = InvokeTriggerResult<TAllowsBranching, TPayload>>(flow: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>, { configVars, context, payload, }?: {
|
|
220
|
+
export declare const invokeFlow: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TPayload> = InvokeTriggerResult<TAllowsBranching, TPayload>>(flow: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, any, any, any>, { configVars, context, payload, }?: {
|
|
221
221
|
configVars?: TConfigVarValues;
|
|
222
222
|
context?: Partial<ActionContext<TConfigVars>>;
|
|
223
223
|
payload?: Partial<TriggerPayload>;
|
package/dist/testing.js
CHANGED
|
@@ -408,7 +408,11 @@ const createConfigVars = (values) => {
|
|
|
408
408
|
* expect(result.data).toBeDefined();
|
|
409
409
|
* });
|
|
410
410
|
*/
|
|
411
|
-
const invokeFlow = (flow_1, ...args_1) => __awaiter(void 0, [flow_1, ...args_1], void 0, function* (
|
|
411
|
+
const invokeFlow = (flow_1, ...args_1) => __awaiter(void 0, [flow_1, ...args_1], void 0, function* (
|
|
412
|
+
// `any` for TItem/TDiscoveryState/TTriggerPayload: the tester accepts a flow with any
|
|
413
|
+
// resolver item and cursor typing; it drives the flow dynamically and does not rely on
|
|
414
|
+
// the precise `onExecution` param type.
|
|
415
|
+
flow, { configVars, context, payload, } = {}) {
|
|
412
416
|
const realizedConfigVars = createConfigVars(configVars);
|
|
413
417
|
const realizedContext = createActionContext(Object.assign(Object.assign({}, context), { configVars: realizedConfigVars }));
|
|
414
418
|
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
|
|
@@ -4,13 +4,14 @@ 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
|
+
import type { BatchConfig, TriggerResolverBehavior } from "./TriggerDefinition";
|
|
10
11
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
11
12
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
12
13
|
import type { TriggerPerformFunction } from "./TriggerPerformFunction";
|
|
13
|
-
import type {
|
|
14
|
+
import type { TriggerResult } from "./TriggerResult";
|
|
14
15
|
/**
|
|
15
16
|
* Defines attributes of a code-native integration. See
|
|
16
17
|
* https://prismatic.io/docs/integrations/code-native/
|
|
@@ -46,8 +47,13 @@ export type IntegrationDefinition<TInputs extends Inputs = Inputs, TActionInputs
|
|
|
46
47
|
/**
|
|
47
48
|
* Flows for this integration. See
|
|
48
49
|
* https://prismatic.io/docs/integrations/code-native/flows/
|
|
50
|
+
*
|
|
51
|
+
* The trailing `any`s for `TItem`/`TDiscoveryState`/`TTriggerPayload` let flows with
|
|
52
|
+
* different resolver item and cursor types live in one array. `integration` only holds
|
|
53
|
+
* and serializes these flows (it never invokes `onExecution`), so the precise — and
|
|
54
|
+
* per-flow distinct — `onExecution` param type does not need to be preserved here.
|
|
49
55
|
*/
|
|
50
|
-
flows: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>[];
|
|
56
|
+
flows: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, any, any, any>[];
|
|
51
57
|
/**
|
|
52
58
|
* Config wizard pages for this integration. See
|
|
53
59
|
* https://prismatic.io/docs/integrations/code-native/config-wizard/
|
|
@@ -70,12 +76,24 @@ export type IntegrationDefinition<TInputs extends Inputs = Inputs, TActionInputs
|
|
|
70
76
|
*/
|
|
71
77
|
componentRegistry?: ComponentRegistry;
|
|
72
78
|
};
|
|
73
|
-
|
|
79
|
+
/**
|
|
80
|
+
* The trigger payload as `onExecution` sees it. When a `triggerResolver` is in
|
|
81
|
+
* play, the platform replaces `body.data` with this execution's batch slice —
|
|
82
|
+
* a single `TItem` when `batchSize` is 1, otherwise a `TItem[]`. When no item
|
|
83
|
+
* type is known (`TItem` defaults to `unknown`), the payload is left untouched.
|
|
84
|
+
*/
|
|
85
|
+
export type BatchedTriggerPayload<TPayload extends TriggerPayload, TItem> = unknown extends TItem ? TPayload : Omit<TPayload, "body"> & {
|
|
86
|
+
body: {
|
|
87
|
+
data: TItem | TItem[];
|
|
88
|
+
contentType?: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export type FlowOnExecution<TTriggerPayload extends TriggerPayload, TItem = unknown> = ActionPerformFunction<{
|
|
74
92
|
onTrigger: {
|
|
75
93
|
type: "data";
|
|
76
94
|
label: string;
|
|
77
95
|
clean: (value: unknown) => {
|
|
78
|
-
results: TTriggerPayload
|
|
96
|
+
results: BatchedTriggerPayload<TTriggerPayload, TItem>;
|
|
79
97
|
};
|
|
80
98
|
};
|
|
81
99
|
}, ConfigVars, {
|
|
@@ -86,7 +104,7 @@ export type FlowExecutionContext = ActionContext<ConfigVars, {
|
|
|
86
104
|
}>;
|
|
87
105
|
export type FlowExecutionContextActions = FlowExecutionContext["components"];
|
|
88
106
|
/** Base properties shared by all flow types. */
|
|
89
|
-
interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
107
|
+
interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> {
|
|
90
108
|
/** The unique name for this flow. */
|
|
91
109
|
name: string;
|
|
92
110
|
/** A unique, unchanging value that is used to maintain identity for the flow even if the name changes. */
|
|
@@ -118,12 +136,24 @@ interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
118
136
|
organizationApiKeys?: string[];
|
|
119
137
|
testApiKeys?: string[];
|
|
120
138
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
139
|
+
* Batch-dispatch config for this flow's resolvers. A single config shared by both
|
|
140
|
+
* `triggerResolver` and `onDeployResolver` — they always batch the same way. For a
|
|
141
|
+
* CNI flow this value is authoritative (what's written here is what's used). Required
|
|
142
|
+
* whenever the flow defines a `triggerResolver` or `onDeployResolver`.
|
|
143
|
+
*/
|
|
144
|
+
batchConfig?: BatchConfig;
|
|
145
|
+
/**
|
|
146
|
+
* Trigger resolver behavior: extracts the items returned by the trigger into batched
|
|
147
|
+
* dispatches and (optionally) paginates. Sizing comes from the flow's `batchConfig`.
|
|
148
|
+
* When using an existing component trigger, that trigger must declare
|
|
149
|
+
* `triggerResolverSupport`; CNI flows infer support from the resolver's presence.
|
|
125
150
|
*/
|
|
126
|
-
triggerResolver?:
|
|
151
|
+
triggerResolver?: TriggerResolverBehavior<ConfigVars, TriggerPayload, TItem, TDiscoveryState>;
|
|
152
|
+
/**
|
|
153
|
+
* On-deploy resolver behavior: same as `triggerResolver` but for the `onDeployTrigger`
|
|
154
|
+
* initial-deploy fire. Shares the flow's `batchConfig`.
|
|
155
|
+
*/
|
|
156
|
+
onDeployResolver?: TriggerResolverBehavior<ConfigVars, TriggerPayload, TItem, TDiscoveryState>;
|
|
127
157
|
/** Error handling configuration. */
|
|
128
158
|
errorConfig?: StepErrorConfig;
|
|
129
159
|
/** Optional schemas definitions for the flow. Currently only for use with AI agents. */
|
|
@@ -151,22 +181,28 @@ interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
151
181
|
delete: TriggerEventFunction<Inputs, ConfigVars>;
|
|
152
182
|
};
|
|
153
183
|
/** Specifies the main function for this flow which is run when this flow is invoked. */
|
|
154
|
-
onExecution: FlowOnExecution<TTriggerPayload>;
|
|
184
|
+
onExecution: FlowOnExecution<TTriggerPayload, TItem>;
|
|
155
185
|
}
|
|
156
186
|
export type StandardTriggerType = "standard";
|
|
157
187
|
/** A standard flow with a webhook or scheduled trigger (non-polling). */
|
|
158
|
-
interface StandardFlow<TInputs extends Inputs = Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = false, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload> extends FlowBase<TTriggerPayload> {
|
|
188
|
+
interface StandardFlow<TInputs extends Inputs = Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = false, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> extends FlowBase<TTriggerPayload, TItem, TDiscoveryState> {
|
|
159
189
|
triggerType?: StandardTriggerType;
|
|
160
190
|
/** Schedule configuration that defines the frequency with which this flow will be automatically executed. */
|
|
161
191
|
schedule?: (ValueExpression<string> | ConfigVarExpression) & {
|
|
162
192
|
timezone?: string;
|
|
163
193
|
};
|
|
164
194
|
/** Specifies the trigger function for this flow, which returns a payload and optional HTTP response. */
|
|
165
|
-
onTrigger?: TriggerReference | TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult>;
|
|
195
|
+
onTrigger?: TriggerReference | TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult, TDiscoveryState>;
|
|
196
|
+
/**
|
|
197
|
+
* Function to execute on initial instance deploy, in addition to (and independent of) `onTrigger`.
|
|
198
|
+
* Typically used to backfill baseline records for systems whose webhooks only emit future events.
|
|
199
|
+
* Pair with `onDeployResolver` to batch the records it returns.
|
|
200
|
+
*/
|
|
201
|
+
onDeployTrigger?: TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult, TDiscoveryState>;
|
|
166
202
|
}
|
|
167
203
|
export type PollingTriggerType = "polling";
|
|
168
204
|
/** A polling flow that runs on a schedule and has access to polling context (getState/setState). */
|
|
169
|
-
interface PollingFlow<TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload> extends FlowBase<TTriggerPayload> {
|
|
205
|
+
interface PollingFlow<TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> extends FlowBase<TTriggerPayload, TItem, TDiscoveryState> {
|
|
170
206
|
/**
|
|
171
207
|
* Type of trigger for this flow. A "polling" trigger runs on a schedule
|
|
172
208
|
* and can use context.polling.* functions. Requires schedule to be set.
|
|
@@ -180,9 +216,15 @@ interface PollingFlow<TInputs extends Inputs, TActionInputs extends Inputs, TPay
|
|
|
180
216
|
* Specifies the trigger function for this flow.
|
|
181
217
|
*/
|
|
182
218
|
onTrigger: PollingTriggerPerformFunction<TInputs, TActionInputs, ConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
219
|
+
/**
|
|
220
|
+
* Function to execute on initial instance deploy, in addition to (and independent of) `onTrigger`.
|
|
221
|
+
* Typically used to backfill baseline records for systems whose webhooks only emit future events.
|
|
222
|
+
* Pair with `onDeployResolver` to batch the records it returns.
|
|
223
|
+
*/
|
|
224
|
+
onDeployTrigger?: TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult, TDiscoveryState>;
|
|
183
225
|
}
|
|
184
226
|
/** Defines attributes of a flow of a code-native integration. */
|
|
185
|
-
export type Flow<TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload> = StandardFlow<TInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload> | PollingFlow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload>;
|
|
227
|
+
export type Flow<TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> = StandardFlow<TInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload, TItem, TDiscoveryState> | PollingFlow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload, TItem, TDiscoveryState>;
|
|
186
228
|
export type FlowTriggerType = PollingTriggerType | StandardTriggerType;
|
|
187
229
|
/** Defines attributes of a Preprocess flow Configuration used by a flow of an integration. */
|
|
188
230
|
export type PreprocessFlowConfig = {
|
|
@@ -253,15 +295,4 @@ export type EndpointType = "flow_specific" | "instance_specific" | "shared_insta
|
|
|
253
295
|
export type EndpointSecurityType = "unsecured" | "customer_optional" | "customer_required" | "organization";
|
|
254
296
|
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
255
297
|
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
298
|
export {};
|
|
@@ -4,7 +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
|
+
import type { BatchConfig, OnDeployDecl, TriggerResolverDecl } from "./TriggerDefinition";
|
|
8
8
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
9
9
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
10
10
|
import type { TriggerResult } from "./TriggerResult";
|
|
@@ -20,14 +20,20 @@ export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs
|
|
|
20
20
|
* PollingTriggerDefinition is the type of the object that is passed in to `pollingTrigger` function to
|
|
21
21
|
* define a component trigger.
|
|
22
22
|
*
|
|
23
|
-
* Composed from `PollingTriggerDefinitionBase` plus `TriggerResolverDecl
|
|
24
|
-
*
|
|
23
|
+
* Composed from `PollingTriggerDefinitionBase` plus `TriggerResolverDecl` (resolver support)
|
|
24
|
+
* and `OnDeployDecl` (the on-deploy perform/resolver relationship), enforced at the type level.
|
|
25
25
|
*/
|
|
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>;
|
|
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> & OnDeployDecl<TInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
27
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> {
|
|
28
28
|
triggerType?: "polling";
|
|
29
29
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
30
30
|
display: ActionDisplayDefinition;
|
|
31
|
+
/**
|
|
32
|
+
* Default batch-dispatch config shared by `triggerResolver` and `onDeployResolver`.
|
|
33
|
+
* Required when this trigger declares either (a `triggerResolver` with
|
|
34
|
+
* `triggerResolverSupport` `"valid"`/`"required"`, or an `onDeployResolver`).
|
|
35
|
+
*/
|
|
36
|
+
batchConfig?: BatchConfig;
|
|
31
37
|
/** Defines your trigger's polling behavior. */
|
|
32
38
|
pollAction?: TAction;
|
|
33
39
|
/** Function to perform when this Trigger is invoked. A default perform will be provided for most polling triggers but defining this allows for custom behavior. */
|
|
@@ -10,46 +10,110 @@ import type { TriggerBaseResult, TriggerResult } from "./TriggerResult";
|
|
|
10
10
|
* - absent or `"invalid"`: no resolver allowed
|
|
11
11
|
* - `"valid"`: resolver optional
|
|
12
12
|
* - `"required"`: resolver required
|
|
13
|
+
*
|
|
14
|
+
* `triggerResolver` is the resolver *behavior* only; batch sizing comes from the
|
|
15
|
+
* trigger's shared `batchConfig` (see `TriggerDefinition`).
|
|
13
16
|
*/
|
|
14
|
-
export type TriggerResolverDecl<TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload> = {
|
|
17
|
+
export type TriggerResolverDecl<TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> = {
|
|
15
18
|
triggerResolverSupport?: "invalid" | undefined;
|
|
16
19
|
triggerResolver?: undefined;
|
|
17
20
|
} | {
|
|
18
21
|
triggerResolverSupport: "valid";
|
|
19
|
-
triggerResolver?:
|
|
22
|
+
triggerResolver?: TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>;
|
|
20
23
|
} | {
|
|
21
24
|
triggerResolverSupport: "required";
|
|
22
|
-
triggerResolver:
|
|
25
|
+
triggerResolver: TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Encodes the relationship between `onDeployPerform` and `onDeployResolver`. On-deploy is
|
|
29
|
+
* presence-driven — there is no separate support flag: a trigger fires on deploy if it
|
|
30
|
+
* defines `onDeployPerform`, and batches that fire if it also defines an `onDeployResolver`.
|
|
31
|
+
* An `onDeployResolver` therefore requires an `onDeployPerform`.
|
|
32
|
+
*
|
|
33
|
+
* `onDeployPerform` is the component-trigger sibling to `perform`. A CNI flow names the
|
|
34
|
+
* same on-deploy fire `onDeployTrigger` (sibling to its `onTrigger`); both flatten to
|
|
35
|
+
* `onDeployPerform` on the wire.
|
|
36
|
+
*/
|
|
37
|
+
export type OnDeployDecl<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TPayload>, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> = {
|
|
38
|
+
onDeployPerform?: undefined;
|
|
39
|
+
onDeployResolver?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
onDeployPerform: TriggerPerformFunction<TInputs, TConfigVars, TAllowsBranching, TResult>;
|
|
42
|
+
onDeployResolver?: TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>;
|
|
23
43
|
};
|
|
24
44
|
declare const optionChoices: readonly ["invalid", "valid", "required"];
|
|
25
45
|
export type TriggerOptionChoice = (typeof optionChoices)[number];
|
|
26
46
|
export declare const TriggerOptionChoices: TriggerOptionChoice[];
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The batching/pagination behavior shared by every resolver surface — component
|
|
49
|
+
* triggers (`TriggerResolver`), CNI flows (`TriggerResolverConfig`), and the
|
|
50
|
+
* on-deploy variants. Defining it once keeps the contract from drifting across
|
|
51
|
+
* those surfaces.
|
|
52
|
+
*
|
|
53
|
+
* The two type variables ARE the data that flows through the batch chain:
|
|
54
|
+
*
|
|
55
|
+
* perform ──▶ resolveItems ──▶ [batch of TItem] ──▶ onExecution
|
|
56
|
+
* │
|
|
57
|
+
* └─ getNextDiscoveryState ──▶ payload.discoveryState ──▶ next perform
|
|
58
|
+
*
|
|
59
|
+
* @typeParam TItem - element produced by `resolveItems`. With `batchSize: 1`
|
|
60
|
+
* each execution receives one `TItem` as its trigger data; with `batchSize > 1`
|
|
61
|
+
* it receives a `TItem[]` slice.
|
|
62
|
+
* @typeParam TDiscoveryState - the pagination cursor. Whatever
|
|
63
|
+
* `getNextDiscoveryState` returns is what the next round reads back on
|
|
64
|
+
* `payload.discoveryState` (see {@link TriggerPayload}). The `result.payload`
|
|
65
|
+
* passed to both callbacks has its `discoveryState` narrowed to this type, so
|
|
66
|
+
* the cursor round-trip is checked end to end.
|
|
67
|
+
*/
|
|
68
|
+
export interface TriggerResolverBehavior<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> {
|
|
69
|
+
/** Extracts the items to dispatch from one trigger result. Receives the same context as the trigger's perform function. With `batchSize: 1` each item is delivered to its own execution; with `batchSize > 1` items are grouped into `TItem[]` slices. */
|
|
70
|
+
resolveItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<WithDiscoveryState<TPayload, TDiscoveryState>>) => TItem[];
|
|
71
|
+
/** Returns the cursor for the next page, or `null` to stop. A non-null return re-invokes the trigger with this object stamped onto `payload.discoveryState`. */
|
|
72
|
+
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<WithDiscoveryState<TPayload, TDiscoveryState>>) => TDiscoveryState | null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A trigger payload with its `discoveryState` field narrowed to `TDiscoveryState`,
|
|
76
|
+
* leaving every other field of `TPayload` intact. Lets a resolver type the cursor
|
|
77
|
+
* it reads back independently of how the base payload was parameterized.
|
|
78
|
+
*/
|
|
79
|
+
export type WithDiscoveryState<TPayload extends TriggerPayload, TDiscoveryState extends Record<string, unknown>> = Omit<TPayload, "discoveryState"> & {
|
|
80
|
+
discoveryState?: TDiscoveryState;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* The single batch-dispatch config shared by a trigger's `triggerResolver` and
|
|
84
|
+
* `onDeployResolver` — they always batch the same way. One place for batch settings.
|
|
85
|
+
*
|
|
86
|
+
* On a CNI flow (`flow.batchConfig`) this value is authoritative. On a component trigger
|
|
87
|
+
* (`TriggerDefinition.batchConfig`) it's the default the platform seeds, which a low-code
|
|
88
|
+
* user may override per instance.
|
|
89
|
+
*/
|
|
90
|
+
export interface BatchConfig {
|
|
91
|
+
/** Number of items per batch. Must be an integer >= 1. `1` dispatches each item individually; `>1` groups items into batches. */
|
|
92
|
+
batchSize: number;
|
|
93
|
+
/** Max batches of a single execution dispatched concurrently. Must be an integer >= 1 when set. Omit for unlimited. */
|
|
94
|
+
concurrentBatchLimit?: number;
|
|
37
95
|
}
|
|
38
96
|
/**
|
|
39
97
|
* TriggerDefinition is the type of the object that is passed in to `trigger` function to
|
|
40
98
|
* define a component trigger. See
|
|
41
99
|
* https://prismatic.io/docs/custom-connectors/triggers/
|
|
42
100
|
*
|
|
43
|
-
* Composed from `TriggerDefinitionBase` (static fields) plus the
|
|
44
|
-
*
|
|
45
|
-
* level.
|
|
101
|
+
* Composed from `TriggerDefinitionBase` (static fields) plus `TriggerResolverDecl` (the
|
|
102
|
+
* resolver support relationship) and `OnDeployDecl` (the on-deploy perform/resolver
|
|
103
|
+
* relationship), which enforce those constraints at the type level.
|
|
46
104
|
*/
|
|
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>;
|
|
105
|
+
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> & OnDeployDecl<TInputs, TConfigVars, TriggerPayload, TAllowsBranching, TResult>;
|
|
48
106
|
interface TriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
49
107
|
/** Defines how the trigger is displayed in the Prismatic UI. */
|
|
50
108
|
display: ActionDisplayDefinition;
|
|
51
109
|
/** Function to perform when this trigger is invoked. */
|
|
52
110
|
perform: TriggerPerformFunction<TInputs, TConfigVars, TAllowsBranching, TResult>;
|
|
111
|
+
/**
|
|
112
|
+
* Default batch-dispatch config shared by `triggerResolver` and `onDeployResolver`.
|
|
113
|
+
* Required when this trigger declares either (a `triggerResolver` with
|
|
114
|
+
* `triggerResolverSupport` `"valid"`/`"required"`, or an `onDeployResolver`).
|
|
115
|
+
*/
|
|
116
|
+
batchConfig?: BatchConfig;
|
|
53
117
|
/**
|
|
54
118
|
* Function to execute when an instance of an integration with a flow that uses this trigger is deployed. See
|
|
55
119
|
* https://prismatic.io/docs/custom-connectors/triggers/#instance-deploy-and-delete-events-for-triggers
|
|
@@ -4,4 +4,4 @@ import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
|
4
4
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
5
5
|
import type { TriggerResult } from "./TriggerResult";
|
|
6
6
|
/** Definition of the function to perform when a Trigger is invoked. */
|
|
7
|
-
export type TriggerPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>> = (context: ActionContext<TConfigVars>, payload: TriggerPayload
|
|
7
|
+
export type TriggerPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> = (context: ActionContext<TConfigVars>, payload: TriggerPayload<TDiscoveryState>, params: ActionInputParameters<TInputs>) => Promise<TResult>;
|