@prismatic-io/spectral 10.18.9-preview.1 → 10.19.0

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.
@@ -73,7 +73,7 @@ exports.INPUT_TYPE_MAP = {
73
73
  const getInputValueType = (input) => {
74
74
  var _a, _b;
75
75
  if (input.type === "structuredObject") {
76
- return structuredObjectTypeString((_a = input.inputs) !== null && _a !== void 0 ? _a : []);
76
+ return wrapCollection(structuredObjectTypeString((_a = input.inputs) !== null && _a !== void 0 ? _a : []), input.collection);
77
77
  }
78
78
  if (input.type === "dynamicObject") {
79
79
  return dynamicObjectTypeString((_b = input.inputs) !== null && _b !== void 0 ? _b : []);
@@ -138,7 +138,7 @@ const getLeafBaseType = (child) => {
138
138
  const getLeafTypeString = (child) => {
139
139
  var _a;
140
140
  if (child.type === "structuredObject") {
141
- return structuredObjectTypeString((_a = child.inputs) !== null && _a !== void 0 ? _a : []);
141
+ return wrapCollection(structuredObjectTypeString((_a = child.inputs) !== null && _a !== void 0 ? _a : []), child.collection);
142
142
  }
143
143
  return wrapCollection(getLeafBaseType(child), child.collection);
144
144
  };
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, BatchTrigger, 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, ConnectionConfigVar, CustomerActivatedConnectionConfigVar, DataSourceConfigVar, DataSourceDefinition, DataSourceType, DefaultConnectionDefinition, DynamicObjectInputField, Flow, InputFieldDefinition, Inputs, IntegrationDefinition, OAuth2ConnectionDefinition, OnPremConnectionDefinition, OrganizationActivatedConnectionConfigVar, StandardConfigVar, StructuredObjectInputField, TriggerDefinition, TriggerPayload, 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,48 +73,7 @@ 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, 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
- trigger?: BatchTrigger<TItem, TDiscoveryState>;
78
- }) => T;
79
- /**
80
- * Builds a flow's batched `trigger` — the ergonomic way to define a batching flow. Instead of
81
- * writing `onTrigger`/`onDeployTrigger` (returning a full payload) plus `triggerResolver`/
82
- * `onDeployResolver` (to extract and paginate), the trigger fires return just their `items` and
83
- * the pagination callbacks live alongside them. spectral wraps the items into the wire payload
84
- * and synthesizes the `resolveItems` that reads them back.
85
- *
86
- * Supply the item and pagination-state types explicitly —
87
- * `batchFlowTrigger<Order, { cursor: number }>({ ... })`. They flow through the whole flow:
88
- * the trigger fires return `Order[]`, `payload.discoveryState` reads back as `{ cursor: number }`,
89
- * and the flow's `onExecution` sees `params.onTrigger.results.body.data` typed as `Order | Order[]`.
90
- *
91
- * @typeParam TItem - the item type each batched execution receives.
92
- * @typeParam TPaginationState - the pagination state round-tripped via `payload.discoveryState`.
93
- * @see {@link https://prismatic.io/docs/integrations/code-native/flows/ | Code-Native Flows}
94
- * @example
95
- * import { flow, batchFlowTrigger } from "@prismatic-io/spectral";
96
- *
97
- * flow({
98
- * name: "Sync Orders",
99
- * stableKey: "sync-orders",
100
- * batchConfig: { batchSize: 50 },
101
- * trigger: batchFlowTrigger<Order, { cursor: number }>({
102
- * onTrigger: async (context, payload) => {
103
- * const page = await fetchOrders(payload.discoveryState?.cursor);
104
- * return { items: page.orders };
105
- * },
106
- * getNextOnTriggerPaginationState: (context, result) => {
107
- * const next = result.payload.discoveryState?.cursor;
108
- * return next === undefined ? null : { cursor: next };
109
- * },
110
- * }),
111
- * onExecution: async (context, params) => {
112
- * const orders = params.onTrigger.results.body.data; // Order | Order[]
113
- * return { data: orders };
114
- * },
115
- * });
116
- */
117
- export declare const batchFlowTrigger: <TItem, TPaginationState extends Record<string, unknown> = Record<string, unknown>>(trigger: BatchTrigger<TItem, TPaginationState>) => BatchTrigger<TItem, TPaginationState>;
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) => T;
118
77
  /**
119
78
  * This function creates a config wizard page object for use in code-native
120
79
  * 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.batchFlowTrigger = 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.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,53 +102,8 @@ exports.integration = integration;
102
102
  * },
103
103
  * });
104
104
  */
105
- const flow = (
106
- // The intersection adds an explicit inference site for `TItem`/`TDiscoveryState` that the
107
- // `T extends Flow<...>` capture alone does not provide, while `T` still preserves the precise
108
- // literal type for the return value. They are inferred from a batched `trigger`'s
109
- // `items`/pagination-state types (see `batchFlowTrigger`).
110
- definition) => definition;
105
+ const flow = (definition) => definition;
111
106
  exports.flow = flow;
112
- /**
113
- * Builds a flow's batched `trigger` — the ergonomic way to define a batching flow. Instead of
114
- * writing `onTrigger`/`onDeployTrigger` (returning a full payload) plus `triggerResolver`/
115
- * `onDeployResolver` (to extract and paginate), the trigger fires return just their `items` and
116
- * the pagination callbacks live alongside them. spectral wraps the items into the wire payload
117
- * and synthesizes the `resolveItems` that reads them back.
118
- *
119
- * Supply the item and pagination-state types explicitly —
120
- * `batchFlowTrigger<Order, { cursor: number }>({ ... })`. They flow through the whole flow:
121
- * the trigger fires return `Order[]`, `payload.discoveryState` reads back as `{ cursor: number }`,
122
- * and the flow's `onExecution` sees `params.onTrigger.results.body.data` typed as `Order | Order[]`.
123
- *
124
- * @typeParam TItem - the item type each batched execution receives.
125
- * @typeParam TPaginationState - the pagination state round-tripped via `payload.discoveryState`.
126
- * @see {@link https://prismatic.io/docs/integrations/code-native/flows/ | Code-Native Flows}
127
- * @example
128
- * import { flow, batchFlowTrigger } from "@prismatic-io/spectral";
129
- *
130
- * flow({
131
- * name: "Sync Orders",
132
- * stableKey: "sync-orders",
133
- * batchConfig: { batchSize: 50 },
134
- * trigger: batchFlowTrigger<Order, { cursor: number }>({
135
- * onTrigger: async (context, payload) => {
136
- * const page = await fetchOrders(payload.discoveryState?.cursor);
137
- * return { items: page.orders };
138
- * },
139
- * getNextOnTriggerPaginationState: (context, result) => {
140
- * const next = result.payload.discoveryState?.cursor;
141
- * return next === undefined ? null : { cursor: next };
142
- * },
143
- * }),
144
- * onExecution: async (context, params) => {
145
- * const orders = params.onTrigger.results.body.data; // Order | Order[]
146
- * return { data: orders };
147
- * },
148
- * });
149
- */
150
- const batchFlowTrigger = (trigger) => trigger;
151
- exports.batchFlowTrigger = batchFlowTrigger;
152
107
  /**
153
108
  * This function creates a config wizard page object for use in code-native
154
109
  * integrations.
@@ -7,18 +7,6 @@ import { type CleanFn } from "./perform";
7
7
  * declare a top-level clean on these containers — the conversion always
8
8
  * supplies one so nested clean functions are applied at runtime. */
9
9
  export declare const cleanerFor: (input: InputFieldDefinition) => CleanFn | undefined;
10
- /**
11
- * Throws if `batchSize` isn't a positive integer; otherwise returns it. Shared by the
12
- * component-trigger (`TriggerDefinition.batch.batchSize`) and CNI flow (`flow.batch.batchSize`)
13
- * validation paths.
14
- */
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;
22
10
  export declare const convertInput: (key: string, definition: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
23
11
  export declare const _isValidTemplateValue: (template: string, inputs: {
24
12
  [key: string]: ConnectionInput | ConnectionTemplateInputField;
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.validateConcurrentBatchLimit = exports.validateBatchSize = exports.cleanerFor = void 0;
17
+ exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = exports.cleanerFor = void 0;
18
18
  const omit_1 = __importDefault(require("lodash/omit"));
19
19
  const types_1 = require("../types");
20
20
  const PollingTriggerDefinition_1 = require("../types/PollingTriggerDefinition");
@@ -27,12 +27,19 @@ const isPlainObject = (value) => value !== null && typeof value === "object" &&
27
27
  const cleanerFor = (input) => {
28
28
  if (input.type === "structuredObject") {
29
29
  const childCleaners = Object.entries(input.inputs).reduce((acc, [childKey, childDef]) => (Object.assign(Object.assign({}, acc), { [childKey]: (0, exports.cleanerFor)(childDef) })), {});
30
- return (value) => {
31
- if (!isPlainObject(value)) {
32
- return value;
33
- }
34
- return (0, perform_1.cleanParams)(value, childCleaners);
35
- };
30
+ const cleanRecord = (value) => isPlainObject(value) ? (0, perform_1.cleanParams)(value, childCleaners) : value;
31
+ if (input.collection === "valuelist") {
32
+ return (value) => (Array.isArray(value) ? value.map(cleanRecord) : value);
33
+ }
34
+ if (input.collection === "keyvaluelist") {
35
+ // Entries arrive as KeyValuePair envelopes; the object to clean
36
+ // lives under `value`.
37
+ return (value) => Array.isArray(value)
38
+ ? value.map((entry) => isPlainObject(entry) && "value" in entry
39
+ ? Object.assign(Object.assign({}, entry), { value: cleanRecord(entry.value) }) : entry)
40
+ : value;
41
+ }
42
+ return cleanRecord;
36
43
  }
37
44
  if (input.type === "dynamicObject") {
38
45
  const configCleaners = {};
@@ -60,87 +67,6 @@ const cleanerFor = (input) => {
60
67
  return "clean" in input ? input.clean : undefined;
61
68
  };
62
69
  exports.cleanerFor = cleanerFor;
63
- /**
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
- */
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
- /**
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) => {
113
- if (!resolver) {
114
- return {};
115
- }
116
- return Object.assign(Object.assign({}, (resolver.resolveItems
117
- ? {
118
- resolveTriggerItems: resolver.resolveItems,
119
- hasResolveTriggerItems: true,
120
- }
121
- : {})), (resolver.getNextDiscoveryState
122
- ? {
123
- getNextDiscoveryState: resolver.getNextDiscoveryState,
124
- hasGetNextDiscoveryState: true,
125
- }
126
- : {}));
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
- };
144
70
  const convertInput = (key, definition) => {
145
71
  // Cast: the field union is wider than any single member; runtime guards below handle it.
146
72
  const _a = definition, { default: defaultValue, type, label, collection, inputs: childInputs, configurations } = _a, rest = __rest(_a, ["default", "type", "label", "collection", "inputs", "configurations"]);
@@ -213,14 +139,7 @@ const convertAction = (actionKey, _a, hooks) => {
213
139
  errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
214
140
  }) });
215
141
  };
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) => {
142
+ const convertTrigger = (triggerKey, trigger, hooks) => {
224
143
  var _a;
225
144
  const { onInstanceDeploy, onInstanceDelete } = trigger;
226
145
  const webhookLifecycleHandlers = "webhookLifecycleHandlers" in trigger ? trigger.webhookLifecycleHandlers : undefined;
@@ -231,26 +150,6 @@ trigger, hooks) => {
231
150
  });
232
151
  const triggerInputCleaners = Object.entries(inputs).reduce((result, [key, value]) => (Object.assign(Object.assign({}, result), { [key]: (0, exports.cleanerFor)(value) })), {});
233
152
  let scheduleSupport = "scheduleSupport" in trigger ? trigger.scheduleSupport : "invalid";
234
- const batchConfig = "batchConfig" in trigger ? trigger.batchConfig : undefined;
235
- const triggerResolver = "triggerResolver" in trigger ? trigger.triggerResolver : undefined;
236
- const triggerResolverSupport = "triggerResolverSupport" in trigger && trigger.triggerResolverSupport !== undefined
237
- ? trigger.triggerResolverSupport
238
- : triggerResolver
239
- ? "valid"
240
- : "invalid";
241
- if (triggerResolverSupport === "required" && !triggerResolver) {
242
- throw new Error(`Trigger "${trigger.display.label}" declares triggerResolverSupport "required" but is missing triggerResolver.`);
243
- }
244
- if (triggerResolverSupport === "invalid" && triggerResolver) {
245
- throw new Error(`Trigger "${trigger.display.label}" declares triggerResolver but triggerResolverSupport is "invalid".`);
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
- }
254
153
  let convertedActionInputs = [];
255
154
  let performToUse;
256
155
  if ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger)) {
@@ -279,11 +178,11 @@ trigger, hooks) => {
279
178
  errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
280
179
  });
281
180
  }
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
181
+ const result = Object.assign(Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
283
182
  ? trigger.synchronousResponseSupport
284
183
  : scheduleSupport === "invalid"
285
184
  ? "valid"
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 } : {}));
185
+ : "invalid" }), ((0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger) ? { isPollingTrigger: true } : {}));
287
186
  if (onInstanceDeploy) {
288
187
  result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
289
188
  inputCleaners: triggerInputCleaners,
@@ -291,13 +190,6 @@ trigger, hooks) => {
291
190
  });
292
191
  result.hasOnInstanceDeploy = true;
293
192
  }
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
- }
301
193
  if (onInstanceDelete) {
302
194
  result.onInstanceDelete = (0, perform_1.createPerform)(onInstanceDelete, {
303
195
  inputCleaners: triggerInputCleaners,
@@ -8,7 +8,7 @@ export declare const convertConfigPages: (pages: ConfigPages | undefined, userLe
8
8
  /** Converts typed QueueConfig to legacy format with usesFifoQueue and concurrencyLimit. */
9
9
  export declare const convertQueueConfig: (queueConfig: QueueConfig) => StandardQueueConfig;
10
10
  /** Converts a Flow into the structure necessary for YAML generation. */
11
- export declare const convertFlow: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>>(rawFlow: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>, componentRegistry: ComponentRegistry, referenceKey: string) => Record<string, unknown>;
11
+ export declare const convertFlow: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>>(flow: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>, componentRegistry: ComponentRegistry, referenceKey: string) => Record<string, unknown>;
12
12
  /** Converts an input value to the expected server type by its collection type. */
13
13
  export declare const convertInputValue: (value: unknown, collectionType: CollectionType | undefined) => unknown;
14
14
  /** Converts a Config Var into the structure necessary for YAML generation. */
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
23
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
13
  };
@@ -40,46 +29,6 @@ const integration_1 = require("./integration");
40
29
  const perform_1 = require("./perform");
41
30
  exports.CONCURRENCY_LIMIT_MAX = 15;
42
31
  exports.CONCURRENCY_LIMIT_MIN = 2;
43
- /**
44
- * Default `resolveItems`: a batched `trigger`'s fires return their records under
45
- * `payload.body.data` (the wrapper {@link normalizeBatchedFlow} builds writes them there),
46
- * so extraction is just reading that array back. Authors never write this themselves.
47
- */
48
- const defaultResolveItems = (_context, result) => result.payload.body.data;
49
- /**
50
- * Expands a flow's batched `trigger` (built with `batchFlowTrigger`) into the flat
51
- * `onTrigger`/`onDeployTrigger`/`triggerResolver`/`onDeployResolver` shape the rest of the
52
- * conversion pipeline already understands. The trigger fires return just `{ items }`; here we
53
- * wrap each into a `TriggerPerformFunction` that emits `{ payload: { …payload, body: { data:
54
- * items } } }`, synthesize the default `resolveItems`, and map the pagination callbacks onto
55
- * the resolver `getNextDiscoveryState`. Flows without a `trigger` pass through unchanged.
56
- *
57
- * Returns the same `Flow` type it received; the synthesized `triggerResolver`/`onDeployResolver`
58
- * are wire-only fields (not on the author-facing `Flow`), read downstream via `"x" in flow` checks.
59
- */
60
- const normalizeBatchedFlow = (flow) => {
61
- const trigger = "trigger" in flow ? flow.trigger : undefined;
62
- if (!trigger) {
63
- return flow;
64
- }
65
- const { onTrigger, onDeploy, getNextOnTriggerPaginationState, getNextOnDeployPaginationState } = trigger;
66
- // Wrap a batched fire (returns `{ items, response? }`) into a TriggerPerformFunction that
67
- // emits the wire payload shape (`body.data = items`), preserving the incoming payload fields.
68
- const wrapFire = (fire) => (context, payload) => __awaiter(void 0, void 0, void 0, function* () {
69
- const { items, response } = yield fire(context, payload);
70
- return Object.assign({ payload: Object.assign(Object.assign({}, payload), { body: { data: items, contentType: "application/json" } }) }, (response ? { response } : {}));
71
- });
72
- const _a = flow, { trigger: _omitTrigger } = _a, rest = __rest(_a, ["trigger"]);
73
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { onTrigger: wrapFire(onTrigger) }), (onDeploy ? { onDeployTrigger: wrapFire(onDeploy) } : {})), { triggerResolver: Object.assign({ resolveItems: defaultResolveItems }, (getNextOnTriggerPaginationState
74
- ? { getNextDiscoveryState: getNextOnTriggerPaginationState }
75
- : {})) }), (onDeploy
76
- ? {
77
- onDeployResolver: Object.assign({ resolveItems: defaultResolveItems }, (getNextOnDeployPaginationState
78
- ? { getNextDiscoveryState: getNextOnDeployPaginationState }
79
- : {})),
80
- }
81
- : {}));
82
- };
83
32
  const convertIntegration = (definition) => {
84
33
  var _a, _b, _c;
85
34
  // Generate a unique reference key that will be used to reference the
@@ -145,11 +94,7 @@ const convertConfigPages = (pages, userLevelConfigured) => {
145
94
  }) })));
146
95
  };
147
96
  exports.convertConfigPages = convertConfigPages;
148
- const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows: rawFlows, configPages, userLevelConfigPages, scopedConfigVars, instanceProfile, componentRegistry = {}, }, referenceKey, configVars, metadata) => {
149
- // Expand any batched `trigger` (built with `batchFlowTrigger`) into the flat
150
- // onTrigger/onDeployTrigger/triggerResolver/onDeployResolver shape the rest of this
151
- // pipeline (convertFlow + the trigger reducer) already handles.
152
- const flows = rawFlows.map((flow) => normalizeBatchedFlow(flow));
97
+ const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, userLevelConfigPages, scopedConfigVars, instanceProfile, componentRegistry = {}, }, referenceKey, configVars, metadata) => {
153
98
  // Find the preprocess flow config on the flow, if one exists.
154
99
  const preprocessFlows = flows.filter((flow) => flow.preprocessFlowConfig);
155
100
  // Do some validation of preprocess flow configs.
@@ -365,11 +310,8 @@ const convertFlowSchemas = (flowKey, schemas) => {
365
310
  }, {});
366
311
  };
367
312
  /** Converts a Flow into the structure necessary for YAML generation. */
368
- const convertFlow = (rawFlow, componentRegistry, referenceKey) => {
313
+ const convertFlow = (flow, componentRegistry, referenceKey) => {
369
314
  var _a;
370
- // Expand a batched `trigger` into the flat shape this function serializes. Idempotent: a flow
371
- // that already lacks `trigger` (including one pre-normalized by `convertIntegration`) is returned as-is.
372
- const flow = normalizeBatchedFlow(rawFlow);
373
315
  const result = Object.assign({}, flow);
374
316
  result.onTrigger = undefined;
375
317
  result.trigger = undefined;
@@ -377,7 +319,6 @@ const convertFlow = (rawFlow, componentRegistry, referenceKey) => {
377
319
  result.onInstanceDelete = undefined;
378
320
  result.webhookLifecycleHandlers = undefined;
379
321
  result.onExecution = undefined;
380
- result.onDeployTrigger = undefined;
381
322
  result.preprocessFlowConfig = undefined;
382
323
  result.errorConfig = undefined;
383
324
  result.testApiKeys = undefined;
@@ -471,30 +412,6 @@ const convertFlow = (rawFlow, componentRegistry, referenceKey) => {
471
412
  }
472
413
  : {}));
473
414
  }
474
- const triggerResolver = "triggerResolver" in flow ? flow.triggerResolver : undefined;
475
- const onDeployResolver = "onDeployResolver" in flow ? flow.onDeployResolver : undefined;
476
- const batchConfig = "batchConfig" in flow ? flow.batchConfig : undefined;
477
- // Resolver behaviors (resolveItems/getNextDiscoveryState) are serialized onto the
478
- // synthesized trigger below. On the flow wire we emit only `triggerResolver`, the single
479
- // config the platform reads (`trigger_resolver_batch_size` / `trigger_resolver_enabled`)
480
- // and shares between the normal and on-deploy fires. `batchConfig`/`onDeployResolver` are
481
- // author-side only — clear them out of the `{ ...flow }` spread.
482
- result.triggerResolver = undefined;
483
- result.onDeployResolver = undefined;
484
- result.batchConfig = undefined;
485
- if (triggerResolver || onDeployResolver) {
486
- if (!batchConfig) {
487
- throw new Error(`${flow.name} defines a triggerResolver/onDeployResolver but no batchConfig. Add \`batchConfig: { batchSize }\` to the flow.`);
488
- }
489
- if (onDeployResolver &&
490
- (!("onDeployTrigger" in flow) || typeof flow.onDeployTrigger !== "function")) {
491
- throw new Error(`${flow.name} declares onDeployResolver without onDeployTrigger. Set onDeployTrigger to handle the initial-deploy fire that the resolver fans out.`);
492
- }
493
- // `enabled: true` is required: for a "valid"-support trigger (which CNI synthesized
494
- // triggers are) the platform only batches when the flow's resolver is enabled.
495
- const concurrentBatchLimit = (0, convertComponent_1.validateConcurrentBatchLimit)(flow.name, "batchConfig", batchConfig.concurrentBatchLimit);
496
- result.triggerResolver = Object.assign({ batchSize: (0, convertComponent_1.validateBatchSize)(flow.name, "batchConfig", batchConfig.batchSize), enabled: true }, (concurrentBatchLimit !== undefined ? { concurrentBatchLimit } : {}));
497
- }
498
415
  const actionStep = {
499
416
  action: {
500
417
  key: flowFunctionKey(flow.name, "onExecution"),
@@ -778,11 +695,7 @@ function generateTriggerPerformFn(params) {
778
695
  case "standard":
779
696
  return (0, perform_1.createCNIPerform)({ componentRegistry, onTrigger });
780
697
  case "component-ref":
781
- return (0, perform_1.createCNIComponentRefPerform)({
782
- componentRegistry,
783
- componentRef,
784
- onTrigger,
785
- });
698
+ return (0, perform_1.createCNIComponentRefPerform)({ componentRegistry, componentRef, onTrigger });
786
699
  default:
787
700
  throw new Error(`Invalid trigger configuration detected: ${JSON.stringify(params, null, 2)}`);
788
701
  }
@@ -838,9 +751,7 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
838
751
  });
839
752
  /** Creates the structure necessary to import a Component as part of a
840
753
  * Code Native integration. */
841
- const codeNativeIntegrationComponent = ({ name, iconPath, description, flows: rawFlows = [], componentRegistry = {}, }, referenceKey, configVars) => {
842
- // Expand any batched `trigger` so the action/trigger reducers below see the flat shape.
843
- const flows = rawFlows.map((flow) => normalizeBatchedFlow(flow));
754
+ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], componentRegistry = {}, }, referenceKey, configVars) => {
844
755
  const convertedActions = flows.reduce((result, { name, onExecution }) => {
845
756
  const key = flowFunctionKey(name, "onExecution");
846
757
  return Object.assign(Object.assign({}, result), { [key]: {
@@ -853,12 +764,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows: ra
853
764
  inputs: [],
854
765
  } });
855
766
  }, {});
856
- const convertedTriggers = flows.reduce((result, flow) => {
857
- var _a;
858
- const { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, onDeployTrigger, } = flow;
859
- // `batchConfig`/`triggerResolver`/`onDeployResolver` are wire-only fields synthesized by
860
- // `normalizeBatchedFlow`; they aren't on the author-facing `Flow` type, so read via cast.
861
- const { batchConfig, triggerResolver, onDeployResolver } = flow;
767
+ const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, }) => {
862
768
  if (!flowUsesWrapperTrigger({
863
769
  onTrigger,
864
770
  onInstanceDelete,
@@ -893,45 +799,26 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows: ra
893
799
  const deployFn = generateTriggerEventWrapperFn(ref, onTrigger, "onInstanceDeploy", componentRegistry, onInstanceDeploy);
894
800
  const webhookCreateFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookCreate", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.create);
895
801
  const webhookDeleteFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookDelete", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.delete);
896
- return Object.assign(Object.assign({}, result), { [key]: Object.assign(Object.assign(Object.assign(Object.assign({ key, display: {
802
+ return Object.assign(Object.assign({}, result), { [key]: {
803
+ key,
804
+ display: {
897
805
  label: `${name} - onTrigger`,
898
806
  description: "The function that will be executed by the flow to return an HTTP response.",
899
- }, perform: performFn, onInstanceDeploy: deployFn, hasOnInstanceDeploy: !!deployFn, onInstanceDelete: deleteFn, hasOnInstanceDelete: !!deleteFn, webhookCreate: webhookCreateFn, hasWebhookCreateFunction: !!webhookCreateFn, webhookDelete: webhookDeleteFn, hasWebhookDeleteFunction: !!webhookDeleteFn, inputs: wrapperTriggerInputsFromReference(onTrigger, componentRegistry), scheduleSupport: triggerType === "polling" ? "required" : "valid", synchronousResponseSupport: "valid", isPollingTrigger: triggerType === "polling", triggerResolverSupport: triggerResolver ? "valid" : "invalid" }, (triggerResolver || onDeployResolver
900
- ? 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
901
- ? {
902
- triggerResolverDefaultConcurrentBatchLimit: batchConfig.concurrentBatchLimit,
903
- }
904
- : {})) : {})), (triggerResolver
905
- ? Object.assign(Object.assign({}, (triggerResolver.resolveItems
906
- ? {
907
- resolveTriggerItems: triggerResolver.resolveItems,
908
- hasResolveTriggerItems: true,
909
- }
910
- : {})), (triggerResolver.getNextDiscoveryState
911
- ? {
912
- getNextDiscoveryState: triggerResolver.getNextDiscoveryState,
913
- hasGetNextDiscoveryState: true,
914
- }
915
- : {})) : {})), (onDeployTrigger
916
- ? {
917
- onDeployPerform: (0, perform_1.createCNIPerform)({
918
- componentRegistry,
919
- onTrigger: onDeployTrigger,
920
- }),
921
- hasOnDeployPerform: true,
922
- }
923
- : {})), (onDeployResolver
924
- ? Object.assign(Object.assign({}, (onDeployResolver.resolveItems
925
- ? {
926
- resolveOnDeployItems: onDeployResolver.resolveItems,
927
- hasResolveOnDeployItems: true,
928
- }
929
- : {})), (onDeployResolver.getNextDiscoveryState
930
- ? {
931
- getOnDeployNextDiscoveryState: onDeployResolver.getNextDiscoveryState,
932
- hasGetOnDeployNextDiscoveryState: true,
933
- }
934
- : {})) : {})) });
807
+ },
808
+ perform: performFn,
809
+ onInstanceDeploy: deployFn,
810
+ hasOnInstanceDeploy: !!deployFn,
811
+ onInstanceDelete: deleteFn,
812
+ hasOnInstanceDelete: !!deleteFn,
813
+ webhookCreate: webhookCreateFn,
814
+ hasWebhookCreateFunction: !!webhookCreateFn,
815
+ webhookDelete: webhookDeleteFn,
816
+ hasWebhookDeleteFunction: !!webhookDeleteFn,
817
+ inputs: wrapperTriggerInputsFromReference(onTrigger, componentRegistry),
818
+ scheduleSupport: triggerType === "polling" ? "required" : "valid",
819
+ synchronousResponseSupport: "valid",
820
+ isPollingTrigger: triggerType === "polling",
821
+ } });
935
822
  }, {});
936
823
  const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
937
824
  if (!(0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
@@ -112,8 +112,8 @@ interface HttpResponse {
112
112
  headers?: Record<string, string>;
113
113
  body?: string;
114
114
  }
115
- interface TriggerBaseResult<TPayload extends TriggerPayload = TriggerPayload> {
116
- payload: TPayload;
115
+ interface TriggerBaseResult {
116
+ payload: TriggerPayload;
117
117
  response?: HttpResponse;
118
118
  instanceState?: Record<string, unknown>;
119
119
  crossFlowState?: Record<string, unknown>;
@@ -122,23 +122,12 @@ interface TriggerBaseResult<TPayload extends TriggerPayload = TriggerPayload> {
122
122
  failed?: boolean;
123
123
  error?: Record<string, unknown>;
124
124
  }
125
- interface TriggerBranchingResult<TPayload extends TriggerPayload = TriggerPayload> extends TriggerBaseResult<TPayload> {
125
+ interface TriggerBranchingResult extends TriggerBaseResult {
126
126
  branch: string;
127
127
  }
128
- export type TriggerResult<TPayload extends TriggerPayload = TriggerPayload> = TriggerBranchingResult<TPayload> | TriggerBaseResult<TPayload> | undefined;
128
+ export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
129
129
  export type TriggerEventFunctionResult = TriggerEventFunctionReturn | void;
130
130
  export type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>;
131
- /**
132
- * Wire format the platform expects for a trigger. Note: function references
133
- * (perform, resolveTriggerItems, getNextDiscoveryState, ...) don't survive JSON
134
- * serialization, so each callback has a paired `hasXxx: boolean` flag the
135
- * server reads to detect presence. Keep the flag and its callback in sync.
136
- *
137
- * 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.
141
- */
142
131
  export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>> {
143
132
  key: string;
144
133
  display: DisplayDefinition & {
@@ -166,23 +155,6 @@ export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, T
166
155
  hasWebhookDeleteFunction?: boolean;
167
156
  scheduleSupport: TriggerOptionChoice;
168
157
  synchronousResponseSupport: TriggerOptionChoice;
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
- */
174
- triggerResolverDefaultBatchSize?: number;
175
- triggerResolverDefaultConcurrentBatchLimit?: number;
176
- resolveTriggerItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => unknown[];
177
- hasResolveTriggerItems?: boolean;
178
- getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
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;
186
158
  examplePayload?: unknown;
187
159
  isCommonTrigger?: boolean;
188
160
  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, any, any, any>, { 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>, { configVars, context, payload, }?: {
221
221
  configVars?: TConfigVarValues;
222
222
  context?: Partial<ActionContext<TConfigVars>>;
223
223
  payload?: Partial<TriggerPayload>;
package/dist/testing.js CHANGED
@@ -408,11 +408,7 @@ 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* (
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, } = {}) {
411
+ const invokeFlow = (flow_1, ...args_1) => __awaiter(void 0, [flow_1, ...args_1], void 0, function* (flow, { configVars, context, payload, } = {}) {
416
412
  const realizedConfigVars = createConfigVars(configVars);
417
413
  const realizedContext = createActionContext(Object.assign(Object.assign({}, context), { configVars: realizedConfigVars }));
418
414
  const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
@@ -1,15 +1,17 @@
1
1
  import type { ConditionalExpression } from "./conditional-logic";
2
2
  import type { Connection, DynamicObjectInputField, InputCleanFunction, InputFieldCollection, Inputs, KeyValuePair, StructuredObjectInputField } from "./Inputs";
3
3
  /** Resolves a single InputFieldDefinition's runtime value type.
4
- * - structuredObject: record of declared children's resolved value types.
4
+ * - structuredObject: record of declared children's resolved value types;
5
+ * with `collection` set, a list (`valuelist`) or `KeyValuePair` list
6
+ * (`keyvaluelist`) of that record.
5
7
  * - dynamicObject: discriminated union keyed by the selected configuration,
6
8
  * with the configuration's resolved inputs nested under `values` to avoid
7
9
  * collisions with the `configuration` discriminant key.
8
10
  * The depth caps (`LeafInputFieldDefinition`, `StructuredOrLeafInputFieldDefinition`)
9
11
  * prevent unbounded recursion. */
10
- type InputValue<T> = T extends StructuredObjectInputField ? {
12
+ type InputValue<T> = T extends StructuredObjectInputField ? ExtractValue<{
11
13
  [K in keyof T["inputs"]]: InputValue<T["inputs"][K]>;
12
- } : T extends DynamicObjectInputField ? {
14
+ }, T["collection"]> : T extends DynamicObjectInputField ? {
13
15
  [C in keyof T["configurations"]]: {
14
16
  configuration: C;
15
17
  values: {
@@ -307,6 +307,10 @@ export type StructuredOrLeafInputFieldDefinition = LeafInputFieldDefinition | St
307
307
  export type StructuredObjectInputField = Omit<BaseInputField, "dataSource" | "example" | "placeholder" | "required"> & {
308
308
  /** Data type the input will collect. */
309
309
  type: "structuredObject";
310
+ /** Collection type of the input; when set, the input collects a list
311
+ * (`valuelist`) or keyed list (`keyvaluelist`) of objects instead of a
312
+ * single object. */
313
+ collection?: InputFieldCollection;
310
314
  /** Nested input fields keyed by their local key. */
311
315
  inputs: Record<string, LeafInputFieldDefinition>;
312
316
  };
@@ -4,15 +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 { HttpResponse } from "./HttpResponse";
8
7
  import type { Inputs } from "./Inputs";
9
8
  import type { PollingTriggerPerformFunction } from "./PollingTriggerDefinition";
10
9
  import type { ScopedConfigVarMap } from "./ScopedConfigVars";
11
- import type { BatchConfig, WithDiscoveryState } from "./TriggerDefinition";
12
10
  import type { TriggerEventFunction } from "./TriggerEventFunction";
13
11
  import type { TriggerPayload } from "./TriggerPayload";
14
12
  import type { TriggerPerformFunction } from "./TriggerPerformFunction";
15
- import type { TriggerBaseResult, TriggerResult } from "./TriggerResult";
13
+ import type { TriggerResult } from "./TriggerResult";
16
14
  /**
17
15
  * Defines attributes of a code-native integration. See
18
16
  * https://prismatic.io/docs/integrations/code-native/
@@ -48,13 +46,8 @@ export type IntegrationDefinition<TInputs extends Inputs = Inputs, TActionInputs
48
46
  /**
49
47
  * Flows for this integration. See
50
48
  * https://prismatic.io/docs/integrations/code-native/flows/
51
- *
52
- * The trailing `any`s for `TItem`/`TDiscoveryState`/`TTriggerPayload` let flows with
53
- * different resolver item and cursor types live in one array. `integration` only holds
54
- * and serializes these flows (it never invokes `onExecution`), so the precise — and
55
- * per-flow distinct — `onExecution` param type does not need to be preserved here.
56
49
  */
57
- flows: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, any, any, any>[];
50
+ flows: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>[];
58
51
  /**
59
52
  * Config wizard pages for this integration. See
60
53
  * https://prismatic.io/docs/integrations/code-native/config-wizard/
@@ -77,66 +70,12 @@ export type IntegrationDefinition<TInputs extends Inputs = Inputs, TActionInputs
77
70
  */
78
71
  componentRegistry?: ComponentRegistry;
79
72
  };
80
- /**
81
- * The trigger payload as `onExecution` sees it. When a `triggerResolver` is in
82
- * play, the platform replaces `body.data` with this execution's batch slice —
83
- * a single `TItem` when `batchSize` is 1, otherwise a `TItem[]`. When no item
84
- * type is known (`TItem` defaults to `unknown`), the payload is left untouched.
85
- */
86
- export type BatchedTriggerPayload<TPayload extends TriggerPayload, TItem> = unknown extends TItem ? TPayload : Omit<TPayload, "body"> & {
87
- body: {
88
- data: TItem | TItem[];
89
- contentType?: string;
90
- };
91
- };
92
- /**
93
- * The page of records a batched trigger fire (`onTrigger`/`onDeploy`) returns. The author
94
- * returns just the items; spectral wraps them into the wire trigger payload (`body.data`)
95
- * and synthesizes the resolver that extracts them. Returning `items` is the whole contract —
96
- * there is no `payload` to thread by hand.
97
- */
98
- export interface BatchedTriggerReturn<TItem> {
99
- /** The records produced by this trigger fire. Chunked into batches of the flow's `batchConfig.batchSize`. */
100
- items: TItem[];
101
- /** Optional HTTP response to the request that invoked the integration. */
102
- response?: HttpResponse;
103
- }
104
- /**
105
- * The pagination callback for a batched trigger fire. Returns the state for the next page,
106
- * or `null` to stop. A non-null return re-invokes the corresponding trigger with this object
107
- * stamped onto `payload.discoveryState`; the loop ends when it returns `null`.
108
- */
109
- export type BatchPaginationStateFunction<TPaginationState extends Record<string, unknown>> = (context: ActionContext<ConfigVars>, result: TriggerBaseResult<WithDiscoveryState<TriggerPayload, TPaginationState>>) => TPaginationState | null;
110
- /**
111
- * A batched trigger built by {@link batchFlowTrigger}. Bundles the normal and on-deploy trigger
112
- * fires (each returning just `items`) with their pagination callbacks. The two type parameters
113
- * — supplied explicitly to `batchTrigger<TItem, TPaginationState>(...)` — flow through to the
114
- * rest of the flow: `TItem` types `onExecution`'s `params.onTrigger.results.body.data`, and
115
- * `TPaginationState` types `payload.discoveryState` and the pagination callbacks' return.
116
- */
117
- export interface BatchTrigger<TItem, TPaginationState extends Record<string, unknown> = Record<string, unknown>> {
118
- /**
119
- * The trigger function for this flow. Fetches a page of records and returns them as `items`.
120
- * Re-invoked once per pagination round (see `getNextOnTriggerPaginationState`); read the
121
- * cursor for the current page from `payload.discoveryState`.
122
- */
123
- onTrigger: (context: ActionContext<ConfigVars>, payload: TriggerPayload<TPaginationState>) => Promise<BatchedTriggerReturn<TItem>>;
124
- /**
125
- * The on-deploy trigger fire, run once on initial instance deploy. Same shape as `onTrigger`;
126
- * pair with `getNextOnDeployPaginationState` to paginate.
127
- */
128
- onDeploy?: (context: ActionContext<ConfigVars>, payload: TriggerPayload<TPaginationState>) => Promise<BatchedTriggerReturn<TItem>>;
129
- /** Pagination for `onTrigger`: return the next page's state, or `null` to stop. */
130
- getNextOnTriggerPaginationState?: BatchPaginationStateFunction<TPaginationState>;
131
- /** Pagination for `onDeploy`: return the next page's state, or `null` to stop. */
132
- getNextOnDeployPaginationState?: BatchPaginationStateFunction<TPaginationState>;
133
- }
134
- export type FlowOnExecution<TTriggerPayload extends TriggerPayload, TItem = unknown> = ActionPerformFunction<{
73
+ export type FlowOnExecution<TTriggerPayload extends TriggerPayload> = ActionPerformFunction<{
135
74
  onTrigger: {
136
75
  type: "data";
137
76
  label: string;
138
77
  clean: (value: unknown) => {
139
- results: BatchedTriggerPayload<TTriggerPayload, TItem>;
78
+ results: TTriggerPayload;
140
79
  };
141
80
  };
142
81
  }, ConfigVars, {
@@ -146,56 +85,8 @@ export type FlowExecutionContext = ActionContext<ConfigVars, {
146
85
  [Key in keyof ComponentRegistry]: ComponentRegistry[Key]["actions"];
147
86
  }>;
148
87
  export type FlowExecutionContextActions = FlowExecutionContext["components"];
149
- /**
150
- * The batch-discriminated fields of a flow. A flow either batches or it does not, and
151
- * the presence of `batchConfig` is the discriminant TypeScript uses to choose a member:
152
- *
153
- * - {@link BatchFields}: `batchConfig` is present, which requires a batched `trigger`
154
- * (built with {@link batchFlowTrigger}). The flat `onTrigger`/`onDeployTrigger` are
155
- * forbidden — the trigger fires live inside the `trigger` object.
156
- * - {@link NonBatchFields}: `batchConfig`/`trigger` are absent; the flow uses the plain
157
- * `onTrigger`/`onDeployTrigger` on its variant.
158
- *
159
- * Discrimination is structural — it depends only on whether the object literal you write
160
- * has a `batchConfig` key — so it works without TypeScript having to infer any type
161
- * parameter from the value. The batched-vs-not shape of `onExecution`'s payload is handled
162
- * separately, on `FlowBase`, via `TItem`: when a `trigger` is present `TItem` is inferred
163
- * (so `onExecution` sees `TItem | TItem[]`); otherwise it stays `unknown` and the payload
164
- * is left untouched (see {@link BatchedTriggerPayload}). Keeping `onExecution` out of this
165
- * union is deliberate — a function property living in a union member loses contextual
166
- * parameter typing, which would make `onExecution`'s `context`/`params` implicitly `any`.
167
- */
168
- interface BatchFields<TItem, TDiscoveryState extends Record<string, unknown>> {
169
- /**
170
- * Batch-dispatch config for this flow. Items returned by the `trigger`'s fires are chunked
171
- * into batches of `batchSize`. For a CNI flow this value is authoritative (what's written
172
- * here is what's used). Its presence requires a batched `trigger`.
173
- */
174
- batchConfig: BatchConfig;
175
- /**
176
- * The batched trigger for this flow, built with {@link batchFlowTrigger}. Its fires
177
- * (`onTrigger`/`onDeploy`) return just `items`; spectral synthesizes the resolver that
178
- * extracts them and maps the pagination callbacks. Required when `batchConfig` is set.
179
- */
180
- trigger: BatchTrigger<TItem, TDiscoveryState>;
181
- /** A batched flow's trigger fires live inside `trigger`; the flat `onTrigger` is forbidden. */
182
- onTrigger?: never;
183
- /** A batched flow's on-deploy fire lives inside `trigger`; the flat `onDeployTrigger` is forbidden. */
184
- onDeployTrigger?: never;
185
- }
186
- interface NonBatchFields {
187
- /** A non-batching flow may not declare batch config. */
188
- batchConfig?: never;
189
- /** A non-batching flow may not declare a batched trigger. */
190
- trigger?: never;
191
- }
192
- /**
193
- * The discriminated union coupling `batchConfig` and the batched `trigger`. Intersected
194
- * into each flow variant at {@link Flow}.
195
- */
196
- type BatchDiscriminant<TItem, TDiscoveryState extends Record<string, unknown>> = BatchFields<TItem, TDiscoveryState> | NonBatchFields;
197
88
  /** Base properties shared by all flow types. */
198
- interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload, TItem = unknown> {
89
+ interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
199
90
  /** The unique name for this flow. */
200
91
  name: string;
201
92
  /** A unique, unchanging value that is used to maintain identity for the flow even if the name changes. */
@@ -252,33 +143,23 @@ interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload, TIte
252
143
  /** Function to execute for webhook teardown. */
253
144
  delete: TriggerEventFunction<Inputs, ConfigVars>;
254
145
  };
255
- /**
256
- * Specifies the main function for this flow which is run when this flow is invoked.
257
- * When the flow batches (has a `triggerResolver`/`onDeployResolver`, so `TItem` is
258
- * inferred), `params.onTrigger.results.body.data` is typed as the resolved item type
259
- * (`TItem | TItem[]`); otherwise the trigger payload is left untouched.
260
- */
261
- onExecution: FlowOnExecution<TTriggerPayload, TItem>;
146
+ /** Specifies the main function for this flow which is run when this flow is invoked. */
147
+ onExecution: FlowOnExecution<TTriggerPayload>;
262
148
  }
263
149
  export type StandardTriggerType = "standard";
264
150
  /** A standard flow with a webhook or scheduled trigger (non-polling). */
265
- 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> {
151
+ 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> {
266
152
  triggerType?: StandardTriggerType;
267
153
  /** Schedule configuration that defines the frequency with which this flow will be automatically executed. */
268
154
  schedule?: (ValueExpression<string> | ConfigVarExpression) & {
269
155
  timezone?: string;
270
156
  };
271
157
  /** Specifies the trigger function for this flow, which returns a payload and optional HTTP response. */
272
- onTrigger?: TriggerReference | TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult, TDiscoveryState>;
273
- /**
274
- * Function to execute on initial instance deploy, in addition to (and independent of) `onTrigger`.
275
- * Typically used to backfill baseline records for systems whose webhooks only emit future events.
276
- */
277
- onDeployTrigger?: TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult, TDiscoveryState>;
158
+ onTrigger?: TriggerReference | TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult>;
278
159
  }
279
160
  export type PollingTriggerType = "polling";
280
161
  /** A polling flow that runs on a schedule and has access to polling context (getState/setState). */
281
- 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> {
162
+ 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> {
282
163
  /**
283
164
  * Type of trigger for this flow. A "polling" trigger runs on a schedule
284
165
  * and can use context.polling.* functions. Requires schedule to be set.
@@ -292,14 +173,9 @@ interface PollingFlow<TInputs extends Inputs, TActionInputs extends Inputs, TPay
292
173
  * Specifies the trigger function for this flow.
293
174
  */
294
175
  onTrigger: PollingTriggerPerformFunction<TInputs, TActionInputs, ConfigVars, TPayload, TAllowsBranching, TResult>;
295
- /**
296
- * Function to execute on initial instance deploy, in addition to (and independent of) `onTrigger`.
297
- * Typically used to backfill baseline records for systems whose webhooks only emit future events.
298
- */
299
- onDeployTrigger?: TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult, TDiscoveryState>;
300
176
  }
301
177
  /** Defines attributes of a flow of a code-native integration. */
302
- 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> & BatchDiscriminant<TItem, TDiscoveryState>) | (PollingFlow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload, TItem, TDiscoveryState> & BatchDiscriminant<TItem, TDiscoveryState>);
178
+ 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>;
303
179
  export type FlowTriggerType = PollingTriggerType | StandardTriggerType;
304
180
  /** Defines attributes of a Preprocess flow Configuration used by a flow of an integration. */
305
181
  export type PreprocessFlowConfig = {
@@ -4,7 +4,6 @@ import type { ActionContext } from "./ActionPerformFunction";
4
4
  import type { ActionPerformReturn } from "./ActionPerformReturn";
5
5
  import type { ActionDisplayDefinition } from "./DisplayDefinition";
6
6
  import type { ConfigVarResultCollection, Inputs } from "./Inputs";
7
- import type { BatchConfig, OnDeployDecl, TriggerResolverDecl } from "./TriggerDefinition";
8
7
  import type { TriggerEventFunction } from "./TriggerEventFunction";
9
8
  import type { TriggerPayload } from "./TriggerPayload";
10
9
  import type { TriggerResult } from "./TriggerResult";
@@ -19,21 +18,11 @@ export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs
19
18
  /**
20
19
  * PollingTriggerDefinition is the type of the object that is passed in to `pollingTrigger` function to
21
20
  * define a component trigger.
22
- *
23
- * Composed from `PollingTriggerDefinitionBase` plus `TriggerResolverDecl` (resolver support)
24
- * and `OnDeployDecl` (the on-deploy perform/resolver relationship), enforced at the type level.
25
21
  */
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
- interface PollingTriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
22
+ export interface PollingTriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
28
23
  triggerType?: "polling";
29
24
  /** Defines how the Action is displayed in the Prismatic interface. */
30
25
  display: ActionDisplayDefinition;
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;
37
26
  /** Defines your trigger's polling behavior. */
38
27
  pollAction?: TAction;
39
28
  /** 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. */
@@ -50,4 +39,3 @@ interface PollingTriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigV
50
39
  examplePayload?: Awaited<ReturnType<this["perform"]>>;
51
40
  }
52
41
  export declare const isPollingTriggerDefinition: (ref: unknown) => ref is PollingTriggerDefinition;
53
- export {};
@@ -1,119 +1,22 @@
1
- import type { ActionContext } from "./ActionPerformFunction";
2
1
  import type { ActionDisplayDefinition } from "./DisplayDefinition";
3
2
  import type { ConfigVarResultCollection, Inputs } from "./Inputs";
4
3
  import type { TriggerEventFunction } from "./TriggerEventFunction";
5
4
  import type { TriggerPayload } from "./TriggerPayload";
6
5
  import type { TriggerPerformFunction } from "./TriggerPerformFunction";
7
- import type { 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
- * `triggerResolver` is the resolver *behavior* only; batch sizing comes from the
15
- * trigger's shared `batchConfig` (see `TriggerDefinition`).
16
- */
17
- export type TriggerResolverDecl<TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload, TItem = unknown, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> = {
18
- triggerResolverSupport?: "invalid" | undefined;
19
- triggerResolver?: undefined;
20
- } | {
21
- triggerResolverSupport: "valid";
22
- triggerResolver?: TriggerResolverBehavior<TConfigVars, TPayload, TItem, TDiscoveryState>;
23
- } | {
24
- triggerResolverSupport: "required";
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>;
43
- };
6
+ import type { TriggerResult } from "./TriggerResult";
44
7
  declare const optionChoices: readonly ["invalid", "valid", "required"];
45
8
  export type TriggerOptionChoice = (typeof optionChoices)[number];
46
9
  export declare const TriggerOptionChoices: TriggerOptionChoice[];
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;
95
- }
96
10
  /**
97
11
  * TriggerDefinition is the type of the object that is passed in to `trigger` function to
98
12
  * define a component trigger. See
99
13
  * https://prismatic.io/docs/custom-connectors/triggers/
100
- *
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.
104
14
  */
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>;
106
- interface TriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
15
+ export interface TriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
107
16
  /** Defines how the trigger is displayed in the Prismatic UI. */
108
17
  display: ActionDisplayDefinition;
109
18
  /** Function to perform when this trigger is invoked. */
110
19
  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;
117
20
  /**
118
21
  * Function to execute when an instance of an integration with a flow that uses this trigger is deployed. See
119
22
  * https://prismatic.io/docs/custom-connectors/triggers/#instance-deploy-and-delete-events-for-triggers
@@ -3,13 +3,8 @@ import type { FlowAttributes } from "./FlowAttributes";
3
3
  import type { InstanceAttributes } from "./InstanceAttributes";
4
4
  import type { IntegrationAttributes } from "./IntegrationAttributes";
5
5
  import type { UserAttributes } from "./UserAttributes";
6
- /** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution.
7
- *
8
- * The optional `TDiscoveryState` parameter types the `discoveryState` field, so authors who
9
- * declare a pagination-state shape on their `getNextDiscoveryState` resolver can read back
10
- * the same shape on the next round's payload. Defaults to `Record<string, unknown>`.
11
- */
12
- export interface TriggerPayload<TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> {
6
+ /** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution. */
7
+ export interface TriggerPayload {
13
8
  /** The headers sent in the webhook request. */
14
9
  headers: {
15
10
  [key: string]: string;
@@ -55,8 +50,4 @@ export interface TriggerPayload<TDiscoveryState extends Record<string, unknown>
55
50
  startedAt: string;
56
51
  /** Determines whether the execution will run in debug mode. */
57
52
  globalDebug: boolean;
58
- /** Managed by the execution when this trigger invocation is a paginated re-run.
59
- * Contains the object returned by `getNextDiscoveryState` from the previous round.
60
- * Absent on the initial invocation. */
61
- discoveryState?: TDiscoveryState;
62
53
  }
@@ -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>, TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> = (context: ActionContext<TConfigVars>, payload: TriggerPayload<TDiscoveryState>, params: ActionInputParameters<TInputs>) => Promise<TResult>;
7
+ export type TriggerPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>> = (context: ActionContext<TConfigVars>, payload: TriggerPayload, params: ActionInputParameters<TInputs>) => Promise<TResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.18.9-preview.1",
3
+ "version": "10.19.0",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": [
6
6
  "prismatic"