@prismatic-io/spectral 10.12.2 → 10.14.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.
- package/dist/generators/cniComponentManifest/index.d.ts +3 -2
- package/dist/generators/cniComponentManifest/types.d.ts +6 -4
- package/dist/generators/componentManifest/createActions.d.ts +4 -3
- package/dist/generators/componentManifest/createConnections.d.ts +4 -3
- package/dist/generators/componentManifest/createDataSources.d.ts +4 -3
- package/dist/generators/componentManifest/createStaticFiles.d.ts +4 -3
- package/dist/generators/componentManifest/createTriggers.d.ts +4 -3
- package/dist/generators/componentManifest/index.d.ts +4 -3
- package/dist/index.d.ts +2 -2
- package/dist/serverTypes/asyncContext.d.ts +3 -3
- package/dist/serverTypes/context.d.ts +2 -2
- package/dist/serverTypes/convertComponent.d.ts +3 -3
- package/dist/serverTypes/convertIntegration.d.ts +23 -5
- package/dist/serverTypes/convertIntegration.js +88 -24
- package/dist/serverTypes/index.d.ts +6 -6
- package/dist/serverTypes/perform.d.ts +26 -3
- package/dist/serverTypes/perform.js +64 -20
- package/dist/serverTypes/triggerTypes.d.ts +34 -0
- package/dist/serverTypes/triggerTypes.js +6 -0
- package/dist/testing.d.ts +5 -5
- package/dist/testing.js +3 -1
- package/dist/types/ConfigVars.d.ts +2 -1
- package/dist/types/IntegrationDefinition.d.ts +41 -12
- package/dist/types/PollingTriggerDefinition.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
1
2
|
import { FormattedAction, FormattedDataSource, FormattedTrigger } from "./types";
|
|
2
|
-
export declare const fetchComponentDataForManifest: ({ componentKey, isPrivate, }: {
|
|
3
|
+
export declare const fetchComponentDataForManifest: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ componentKey, isPrivate, }: {
|
|
3
4
|
componentKey: string;
|
|
4
5
|
isPrivate: boolean;
|
|
5
6
|
}) => Promise<{
|
|
@@ -11,7 +12,7 @@ export declare const fetchComponentDataForManifest: ({ componentKey, isPrivate,
|
|
|
11
12
|
description: string;
|
|
12
13
|
};
|
|
13
14
|
actions: Record<string, FormattedAction>;
|
|
14
|
-
triggers: Record<string, FormattedTrigger
|
|
15
|
+
triggers: Record<string, FormattedTrigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>>;
|
|
15
16
|
dataSources: Record<string, FormattedDataSource>;
|
|
16
17
|
connections: {
|
|
17
18
|
key: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Action, Component, DataSource, Trigger } from "../../serverTypes";
|
|
1
|
+
import { Action, Component, DataSource, Trigger, TriggerPayload } from "../../serverTypes";
|
|
2
|
+
import { ConfigVarResultCollection, Inputs } from "../../types";
|
|
3
|
+
import { TriggerResult } from "../../types/TriggerResult";
|
|
2
4
|
export interface ComponentNode {
|
|
3
5
|
id: string;
|
|
4
6
|
label: string;
|
|
@@ -46,11 +48,11 @@ export interface InputNode {
|
|
|
46
48
|
onPremiseControlled: boolean;
|
|
47
49
|
}
|
|
48
50
|
export type FormattedAction = Pick<Action, "key" | "display" | "inputs" | "examplePayload">;
|
|
49
|
-
export type FormattedTrigger = Pick<Trigger, "key" | "display" | "inputs">;
|
|
51
|
+
export type FormattedTrigger<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> = Pick<Trigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>, "key" | "display" | "inputs">;
|
|
50
52
|
export type FormattedDataSource = Pick<DataSource, "key" | "display" | "inputs" | "dataSourceType" | "examplePayload">;
|
|
51
|
-
export type ComponentForManifest = Pick<Component, "key" | "public" | "display" | "connections"> & {
|
|
53
|
+
export type ComponentForManifest<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> = Pick<Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>, "key" | "public" | "display" | "connections"> & {
|
|
52
54
|
actions: Record<string, Action | FormattedAction>;
|
|
53
|
-
triggers: Record<string, Trigger | FormattedTrigger
|
|
55
|
+
triggers: Record<string, Trigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult> | FormattedTrigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>>;
|
|
54
56
|
dataSources: Record<string, DataSource | FormattedDataSource>;
|
|
55
57
|
};
|
|
56
58
|
export type ComponentActionsQueryResponse = {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ComponentForManifest } from "../cniComponentManifest/types";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
3
|
+
interface CreateActionsProps<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> {
|
|
4
|
+
component: ComponentForManifest<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
4
5
|
dryRun: boolean;
|
|
5
6
|
verbose: boolean;
|
|
6
7
|
sourceDir: string;
|
|
7
8
|
destinationDir: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const createActions: ({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateActionsProps) => Promise<{
|
|
10
|
+
export declare const createActions: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateActionsProps<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => Promise<{
|
|
10
11
|
actionIndex: string | void;
|
|
11
12
|
actions: (string | void)[];
|
|
12
13
|
}>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ComponentForManifest } from "../cniComponentManifest/types";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
3
|
+
interface CreateConnectionsProps<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> {
|
|
4
|
+
component: ComponentForManifest<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
4
5
|
dryRun: boolean;
|
|
5
6
|
verbose: boolean;
|
|
6
7
|
sourceDir: string;
|
|
7
8
|
destinationDir: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const createConnections: ({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateConnectionsProps) => Promise<{
|
|
10
|
+
export declare const createConnections: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateConnectionsProps<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => Promise<{
|
|
10
11
|
connectionIndex: string | void;
|
|
11
12
|
connections: (string | void)[];
|
|
12
13
|
}>;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ComponentForManifest } from "../cniComponentManifest/types";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
3
|
+
interface CreateDataSourcesProps<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> {
|
|
4
|
+
component: ComponentForManifest<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
4
5
|
dryRun: boolean;
|
|
5
6
|
verbose: boolean;
|
|
6
7
|
sourceDir: string;
|
|
7
8
|
destinationDir: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const createDataSources: ({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateDataSourcesProps) => Promise<{
|
|
10
|
+
export declare const createDataSources: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateDataSourcesProps<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => Promise<{
|
|
10
11
|
dataSourceIndex: string | void;
|
|
11
12
|
dataSources: (string | void)[];
|
|
12
13
|
}>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Component } from "../../serverTypes";
|
|
2
|
+
import { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
2
3
|
export interface PackageDependencies {
|
|
3
4
|
spectral: string;
|
|
4
5
|
dependencies: Record<string, string>;
|
|
5
6
|
devDependencies: Record<string, string>;
|
|
6
7
|
}
|
|
7
|
-
interface CreateStaticFilesProps {
|
|
8
|
-
component: Component
|
|
8
|
+
interface CreateStaticFilesProps<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> {
|
|
9
|
+
component: Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
9
10
|
dryRun: boolean;
|
|
10
11
|
signature: string | null;
|
|
11
12
|
packageName: string;
|
|
@@ -15,7 +16,7 @@ interface CreateStaticFilesProps {
|
|
|
15
16
|
destinationDir: string;
|
|
16
17
|
registry: string | null;
|
|
17
18
|
}
|
|
18
|
-
export declare const createStaticFiles: ({ component, dryRun, signature, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateStaticFilesProps) => Promise<{
|
|
19
|
+
export declare const createStaticFiles: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ component, dryRun, signature, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateStaticFilesProps<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => Promise<{
|
|
19
20
|
index: string | void;
|
|
20
21
|
packageJson: string | void;
|
|
21
22
|
tsConfig: string | void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { ComponentForManifest } from "../cniComponentManifest/types";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
3
|
+
interface CreateTriggersProps<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> {
|
|
4
|
+
component: ComponentForManifest<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
4
5
|
dryRun: boolean;
|
|
5
6
|
verbose: boolean;
|
|
6
7
|
sourceDir: string;
|
|
7
8
|
destinationDir: string;
|
|
8
9
|
}
|
|
9
|
-
export declare const createTriggers: ({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateTriggersProps) => Promise<{
|
|
10
|
+
export declare const createTriggers: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ component, dryRun, verbose, sourceDir, destinationDir, }: CreateTriggersProps<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => Promise<{
|
|
10
11
|
triggersIndex: string | void;
|
|
11
12
|
triggers: (string | void)[];
|
|
12
13
|
}>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type PackageDependencies } from "./createStaticFiles";
|
|
2
2
|
import type { Component } from "../../serverTypes";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { Inputs, ConfigVarResultCollection, TriggerPayload, TriggerResult } from "../../types";
|
|
4
|
+
interface CreateComponentManifestProps<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> {
|
|
5
|
+
component: Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
5
6
|
dryRun: boolean;
|
|
6
7
|
skipSignatureVerify: boolean;
|
|
7
8
|
packageName: string;
|
|
@@ -11,5 +12,5 @@ interface CreateComponentManifestProps {
|
|
|
11
12
|
destinationDir: string;
|
|
12
13
|
registry: string | null;
|
|
13
14
|
}
|
|
14
|
-
export declare const createComponentManifest: ({ component, dryRun, skipSignatureVerify, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateComponentManifestProps) => Promise<void>;
|
|
15
|
+
export declare const createComponentManifest: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ component, dryRun, skipSignatureVerify, packageName, dependencies, verbose, sourceDir, destinationDir, registry, }: CreateComponentManifestProps<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => Promise<void>;
|
|
15
16
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { PollingTriggerDefinition } from "./types/PollingTriggerDefinition"
|
|
|
16
16
|
* @param definition An IntegrationDefinition type object.
|
|
17
17
|
* @returns This function returns an integration object that has the shape the Prismatic API expects.
|
|
18
18
|
*/
|
|
19
|
-
export declare const integration: <T extends IntegrationDefinition = IntegrationDefinition
|
|
19
|
+
export declare const integration: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, T extends IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult> = IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>>(definition: T) => ReturnType<typeof convertIntegration<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>>;
|
|
20
20
|
/**
|
|
21
21
|
* This function creates a flow object for use in code-native integrations.
|
|
22
22
|
* For information on writing code-native flows, see
|
|
@@ -25,7 +25,7 @@ export declare const integration: <T extends IntegrationDefinition = Integration
|
|
|
25
25
|
* @param definition A Flow type object.
|
|
26
26
|
* @returns This function returns a flow object that has the shape the Prismatic API expects.
|
|
27
27
|
*/
|
|
28
|
-
export declare const flow: <TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TTriggerPayload> = Flow<TTriggerPayload>>(definition: T) => T;
|
|
28
|
+
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;
|
|
29
29
|
/**
|
|
30
30
|
* This function creates a config wizard page object for use in code-native
|
|
31
31
|
* integrations. For information on code-native config wizards, see
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ComponentRegistry, IntegrationDefinition } from "../types";
|
|
1
|
+
import { ComponentRegistry, IntegrationDefinition, Inputs, TriggerPayload, TriggerResult } from "../types";
|
|
2
2
|
import type { ActionContext } from "../types/ActionPerformFunction";
|
|
3
3
|
export declare function runWithContext<T>(context: ActionContext, fn: () => T | Promise<T>): T | Promise<T>;
|
|
4
4
|
export declare function requireContext(): ActionContext;
|
|
5
|
-
export declare function runWithIntegrationContext<T extends IntegrationDefinition, U>(context: T, fn: () => U): U;
|
|
6
|
-
export declare function requireIntegrationContext<T extends IntegrationDefinition>(): T;
|
|
5
|
+
export declare function runWithIntegrationContext<TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, T extends IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult> = IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>, U = unknown>(context: T, fn: () => U): U;
|
|
6
|
+
export declare function requireIntegrationContext<TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, T extends IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult> = IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>>(): T;
|
|
7
7
|
type GetUserDefinedKeyByComponentKey<K extends string, T extends ComponentRegistry, TPublic extends boolean> = keyof T extends infer UserKey ? UserKey extends keyof T ? T[UserKey] extends {
|
|
8
8
|
key: string;
|
|
9
9
|
public: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionContext as ServerActionContext } from ".";
|
|
2
|
-
import { ActionContext, ComponentRegistry, DebugContext, FlowInvoker } from "../types";
|
|
3
|
-
export declare function createCNIContext(context: ActionContext, componentRegistry: ComponentRegistry): ActionContext
|
|
2
|
+
import { ActionContext, ComponentRegistry, DebugContext, FlowInvoker, ConfigVarResultCollection, ComponentManifest } from "../types";
|
|
3
|
+
export declare function createCNIContext<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TComponentActions extends Record<string, ComponentManifest["actions"]> = Record<string, ComponentManifest["actions"]>, TFlows extends string[] = string[]>(context: ActionContext<TConfigVars, TComponentActions, TFlows>, componentRegistry: ComponentRegistry): ActionContext<TConfigVars, TComponentActions, TFlows>;
|
|
4
4
|
export declare function createDebugContext(context: ServerActionContext): DebugContext;
|
|
5
5
|
export declare function logDebugResults(context: ActionContext): void;
|
|
6
6
|
export declare const createInvokeFlow: <const TFlows extends Readonly<string[]>>(context: ActionContext, options?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InputFieldDefinition, ComponentDefinition, ConnectionDefinition, TriggerDefinition, ComponentHooks, ConfigVarResultCollection, OnPremConnectionInput, TriggerPayload, ConnectionTemplateInputField, ConnectionInput } from "../types";
|
|
1
|
+
import { InputFieldDefinition, ComponentDefinition, ConnectionDefinition, Inputs, TriggerDefinition, ComponentHooks, ConfigVarResultCollection, OnPremConnectionInput, TriggerPayload, ConnectionTemplateInputField, ConnectionInput, TriggerResult } from "../types";
|
|
2
2
|
import { Component as ServerComponent, Connection as ServerConnection, Trigger as ServerTrigger, Input as ServerInput } from ".";
|
|
3
3
|
import { PollingTriggerDefinition } from "../types/PollingTriggerDefinition";
|
|
4
4
|
export declare const convertInput: (key: string, { default: defaultValue, type, label, collection, ...rest }: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
|
|
@@ -11,6 +11,6 @@ export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
|
11
11
|
export declare const convertTemplateInput: (key: string, { templateValue, label, ...rest }: ConnectionTemplateInputField, inputs: {
|
|
12
12
|
[key: string]: ConnectionInput | ConnectionTemplateInputField;
|
|
13
13
|
}) => ServerInput;
|
|
14
|
-
export declare const convertTrigger: (triggerKey: string, trigger: TriggerDefinition<any> | PollingTriggerDefinition<any, ConfigVarResultCollection, TriggerPayload, boolean, any, any>, hooks?: ComponentHooks) => ServerTrigger
|
|
14
|
+
export declare const convertTrigger: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>(triggerKey: string, trigger: TriggerDefinition<any> | PollingTriggerDefinition<any, ConfigVarResultCollection, TriggerPayload, boolean, any, any>, hooks?: ComponentHooks) => ServerTrigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
15
15
|
export declare const convertConnection: ({ inputs, ...connection }: ConnectionDefinition) => ServerConnection;
|
|
16
|
-
export declare const convertComponent: <TPublic extends boolean, TKey extends string>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent
|
|
16
|
+
export declare const convertComponent: <TPublic extends boolean, TKey extends string, TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import { IntegrationDefinition, ConfigVar, Flow, ConfigPages, ComponentRegistry, CollectionType } from "../types";
|
|
2
|
-
import { Component as ServerComponent } from ".";
|
|
3
|
-
import { RequiredConfigVariable as ServerRequiredConfigVariable, ConfigPage as ServerConfigPage } from "./integration";
|
|
4
|
-
export declare const convertIntegration: (definition: IntegrationDefinition) => ServerComponent
|
|
1
|
+
import { IntegrationDefinition, ConfigVar, Flow, ConfigPages, ComponentRegistry, TriggerReference, CollectionType, Inputs, TriggerResult as TriggerPerformResult, ConfigVarResultCollection } from "../types";
|
|
2
|
+
import { Component as ServerComponent, ActionContext, TriggerPayload, TriggerResult } from ".";
|
|
3
|
+
import { RequiredConfigVariable as ServerRequiredConfigVariable, ConfigPage as ServerConfigPage, ComponentReference as ServerComponentReference } from "./integration";
|
|
4
|
+
export declare const convertIntegration: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>>(definition: IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>) => ServerComponent<TInputs, TActionInputs, ConfigVarResultCollection, TPayload, TAllowsBranching, TResult>;
|
|
5
5
|
export declare const convertConfigPages: (pages: ConfigPages | undefined, userLevelConfigured: boolean) => ServerConfigPage[];
|
|
6
6
|
/** Converts a Flow into the structure necessary for YAML generation. */
|
|
7
|
-
export declare const convertFlow: (flow: Flow, componentRegistry: ComponentRegistry, referenceKey: string) => Record<string, unknown>;
|
|
7
|
+
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>;
|
|
8
8
|
/** Converts an input value to the expected server type by its collection type. */
|
|
9
9
|
export declare const convertInputValue: (value: unknown, collectionType: CollectionType | undefined) => unknown;
|
|
10
10
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
11
11
|
export declare const convertConfigVar: (key: string, configVar: ConfigVar, referenceKey: string, componentRegistry: ComponentRegistry) => ServerRequiredConfigVariable;
|
|
12
|
+
export declare const invokeTriggerComponentInput: (componentRef: ServerComponentReference, onTrigger: TriggerReference | undefined, eventName: "perform" | "onInstanceDeploy" | "onInstanceDelete") => {
|
|
13
|
+
component: {
|
|
14
|
+
key: string;
|
|
15
|
+
version: number | "LATEST";
|
|
16
|
+
isPublic: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
key: string;
|
|
19
|
+
signature: string;
|
|
20
|
+
isPublic: boolean;
|
|
21
|
+
};
|
|
22
|
+
key: string;
|
|
23
|
+
triggerEventFunctionName: "perform" | "onInstanceDeploy" | "onInstanceDelete";
|
|
24
|
+
};
|
|
25
|
+
export type TriggerActionInvokeFunction = (ref: {
|
|
26
|
+
component: ServerComponentReference["component"];
|
|
27
|
+
key: string;
|
|
28
|
+
triggerEventFunctionName: "perform" | "onInstanceDeploy" | "onInstanceDelete";
|
|
29
|
+
}, context: ActionContext, payload: TriggerPayload | null, params: Record<string, unknown>) => Promise<TriggerResult>;
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.convertConfigVar = exports.convertInputValue = exports.convertFlow = exports.convertConfigPages = exports.convertIntegration = void 0;
|
|
15
|
+
exports.invokeTriggerComponentInput = exports.convertConfigVar = exports.convertInputValue = exports.convertFlow = exports.convertConfigPages = exports.convertIntegration = void 0;
|
|
16
16
|
const yaml_1 = __importDefault(require("yaml"));
|
|
17
17
|
const uuid_1 = require("uuid");
|
|
18
18
|
const assign_1 = __importDefault(require("lodash/assign"));
|
|
@@ -20,6 +20,7 @@ const camelCase_1 = __importDefault(require("lodash/camelCase"));
|
|
|
20
20
|
const pick_1 = __importDefault(require("lodash/pick"));
|
|
21
21
|
const types_1 = require("../types");
|
|
22
22
|
const convertComponent_1 = require("./convertComponent");
|
|
23
|
+
const perform_1 = require("./perform");
|
|
23
24
|
const integration_1 = require("./integration");
|
|
24
25
|
const merge_1 = __importDefault(require("lodash/merge"));
|
|
25
26
|
const context_1 = require("./context");
|
|
@@ -306,6 +307,7 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
306
307
|
result.preprocessFlowConfig = undefined;
|
|
307
308
|
result.errorConfig = undefined;
|
|
308
309
|
result.testApiKeys = undefined;
|
|
310
|
+
result.triggerType = undefined;
|
|
309
311
|
let publicSupplementalComponent;
|
|
310
312
|
const triggerStep = {
|
|
311
313
|
name: "On Trigger",
|
|
@@ -358,6 +360,9 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
358
360
|
result.schedule = undefined;
|
|
359
361
|
hasSchedule = true;
|
|
360
362
|
}
|
|
363
|
+
if (flow.triggerType === "polling" && !hasSchedule) {
|
|
364
|
+
throw new Error(`${flow.name} is marked as a polling trigger but has no schedule. Polling triggers require a schedule.`);
|
|
365
|
+
}
|
|
361
366
|
if ("queueConfig" in flow && typeof flow.queueConfig === "object") {
|
|
362
367
|
const { queueConfig } = flow;
|
|
363
368
|
if (hasSchedule && queueConfig.usesFifoQueue) {
|
|
@@ -369,6 +374,10 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
369
374
|
else if (queueConfig.usesFifoQueue && queueConfig.singletonExecutions) {
|
|
370
375
|
throw new Error(`${flow.name} is configured for both FIFO queues and singleton executions, but these options are mutually exclusive. Please choose one.`);
|
|
371
376
|
}
|
|
377
|
+
if (queueConfig.concurrencyLimit !== undefined &&
|
|
378
|
+
(queueConfig.concurrencyLimit < 2 || queueConfig.concurrencyLimit > 10)) {
|
|
379
|
+
throw new Error(`${flow.name} has an invalid concurrencyLimit of ${queueConfig.concurrencyLimit}. concurrencyLimit must be between 2 and 10.`);
|
|
380
|
+
}
|
|
372
381
|
result.queueConfig = Object.assign(Object.assign({ usesFifoQueue: false }, queueConfig), (queueConfig.dedupeIdField
|
|
373
382
|
? {
|
|
374
383
|
dedupeIdField: {
|
|
@@ -408,6 +417,22 @@ const convertInputValue = (value, collectionType) => {
|
|
|
408
417
|
}));
|
|
409
418
|
};
|
|
410
419
|
exports.convertInputValue = convertInputValue;
|
|
420
|
+
const validateOnPremConnectionConfig = (connection) => {
|
|
421
|
+
if ((0, types_1.isConnectionDefinitionConfigVar)(connection)) {
|
|
422
|
+
const hasOnPremControlledInputs = Object.values(connection.inputs).some((value) => {
|
|
423
|
+
return "onPremControlled" in value && value.onPremControlled;
|
|
424
|
+
});
|
|
425
|
+
const { onPremConnectionConfig: config } = connection;
|
|
426
|
+
if (hasOnPremControlledInputs && !config) {
|
|
427
|
+
throw new Error(`Connection ${connection.stableKey} has onPremControlled inputs but no onPremConnectionConfig value set. Please set an onPremConnectionConfig value for the connection.`);
|
|
428
|
+
}
|
|
429
|
+
if (!hasOnPremControlledInputs && config && config !== "disallowed") {
|
|
430
|
+
throw new Error(`Connection ${connection.stableKey} has onPremConnectionConfig set but no onPremControlled inputs. The connection will not be valid without onPremControlled inputs (host, port).`);
|
|
431
|
+
}
|
|
432
|
+
return hasOnPremControlledInputs && config ? config : "disallowed";
|
|
433
|
+
}
|
|
434
|
+
return "disallowed";
|
|
435
|
+
};
|
|
411
436
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
412
437
|
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
413
438
|
var _a, _b, _c;
|
|
@@ -428,6 +453,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
428
453
|
description,
|
|
429
454
|
key,
|
|
430
455
|
dataType: "connection",
|
|
456
|
+
onPremiseConnectionConfig: validateOnPremConnectionConfig(configVar),
|
|
431
457
|
connection: {
|
|
432
458
|
key: (0, camelCase_1.default)(key),
|
|
433
459
|
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
@@ -570,25 +596,57 @@ const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
|
|
|
570
596
|
triggerEventFunctionName: eventName,
|
|
571
597
|
};
|
|
572
598
|
};
|
|
599
|
+
exports.invokeTriggerComponentInput = invokeTriggerComponentInput;
|
|
600
|
+
/** Type guard to narrow trigger perform functions based on triggerType.
|
|
601
|
+
* Since TriggerPerformFunction and CodeNativePollingTriggerPerformFunction are
|
|
602
|
+
* structurally identical, TypeScript cannot distinguish them. This guard uses
|
|
603
|
+
* triggerType to narrow the function type. */
|
|
604
|
+
const isStandardTriggerPerform = (fn, triggerType) => triggerType !== "polling";
|
|
605
|
+
// Force incoming config into a discriminated union type to simplify downstream handling
|
|
606
|
+
function validateTriggerPerformConfig(params) {
|
|
607
|
+
const { componentRef, onTrigger, componentRegistry, triggerType } = params;
|
|
608
|
+
if (componentRef && onTrigger && typeof onTrigger !== "function") {
|
|
609
|
+
return {
|
|
610
|
+
componentRef,
|
|
611
|
+
onTrigger,
|
|
612
|
+
triggerType: "component-ref",
|
|
613
|
+
componentRegistry,
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
else if (triggerType === "polling" && typeof onTrigger === "function") {
|
|
617
|
+
return {
|
|
618
|
+
componentRef: undefined,
|
|
619
|
+
onTrigger,
|
|
620
|
+
triggerType,
|
|
621
|
+
componentRegistry,
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
else if (typeof onTrigger === "function" && isStandardTriggerPerform(onTrigger, triggerType)) {
|
|
625
|
+
return {
|
|
626
|
+
componentRef: undefined,
|
|
627
|
+
onTrigger,
|
|
628
|
+
triggerType: "standard",
|
|
629
|
+
componentRegistry,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
throw new Error(`Invalid trigger configuration detected: ${JSON.stringify(params, null, 2)}`);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
573
636
|
/* Generates a wrapper function that calls an existing component trigger's perform. */
|
|
574
|
-
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
const cniContext = (0, context_1.createCNIContext)(context, componentRegistry);
|
|
588
|
-
return yield onTrigger(cniContext, payload, params);
|
|
589
|
-
});
|
|
590
|
-
return performFn;
|
|
591
|
-
};
|
|
637
|
+
function generateTriggerPerformFn(params) {
|
|
638
|
+
const { componentRef, onTrigger, componentRegistry, triggerType } = validateTriggerPerformConfig(params);
|
|
639
|
+
switch (triggerType) {
|
|
640
|
+
case "polling":
|
|
641
|
+
return (0, perform_1.createCNIPollingPerform)({ onTrigger, componentRegistry });
|
|
642
|
+
case "standard":
|
|
643
|
+
return (0, perform_1.createCNIPerform)({ componentRegistry, onTrigger });
|
|
644
|
+
case "component-ref":
|
|
645
|
+
return (0, perform_1.createCNIComponentRefPerform)({ componentRegistry, componentRef, onTrigger });
|
|
646
|
+
default:
|
|
647
|
+
throw new Error(`Invalid trigger configuration detected: ${JSON.stringify(params, null, 2)}`);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
592
650
|
/** Generates a wrapper function that calls an existing component's onInstanceDeploy
|
|
593
651
|
* or onInstanceDelete, then calls the flow-defined version if it exists.
|
|
594
652
|
* Returns the deep-merged results of the two, prioritizing the custom response
|
|
@@ -606,7 +664,7 @@ const generateOnInstanceWrapperFn = (componentRef, onTrigger, eventName, compone
|
|
|
606
664
|
const cniContext = (0, context_1.createCNIContext)(context, componentRegistry);
|
|
607
665
|
// Using runWithContext allows for component action invocation via manifest.
|
|
608
666
|
return yield (0, asyncContext_1.runWithContext)(cniContext, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
609
|
-
const invokeResponse = (yield invokeTrigger(invokeTriggerComponentInput(componentRef, onTrigger, eventName), cniContext, null, params)) || {};
|
|
667
|
+
const invokeResponse = (yield invokeTrigger((0, exports.invokeTriggerComponentInput)(componentRef, onTrigger, eventName), cniContext, null, params)) || {};
|
|
610
668
|
let customResponse = {};
|
|
611
669
|
if (customFn) {
|
|
612
670
|
customResponse = (yield customFn(cniContext, params)) || {};
|
|
@@ -639,7 +697,7 @@ const convertOnExecution = (onExecution, componentRegistry) => (context, params)
|
|
|
639
697
|
});
|
|
640
698
|
/** Creates the structure necessary to import a Component as part of a
|
|
641
699
|
* Code Native integration. */
|
|
642
|
-
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], componentRegistry = {} }, referenceKey, configVars) => {
|
|
700
|
+
const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [], componentRegistry = {}, }, referenceKey, configVars) => {
|
|
643
701
|
const convertedActions = flows.reduce((result, { name, onExecution }) => {
|
|
644
702
|
const key = flowFunctionKey(name, "onExecution");
|
|
645
703
|
return Object.assign(Object.assign({}, result), { [key]: {
|
|
@@ -652,7 +710,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
652
710
|
inputs: [],
|
|
653
711
|
} });
|
|
654
712
|
}, {});
|
|
655
|
-
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, schedule }) => {
|
|
713
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, schedule, triggerType }) => {
|
|
656
714
|
if (!flowUsesWrapperTrigger({
|
|
657
715
|
onTrigger,
|
|
658
716
|
onInstanceDelete,
|
|
@@ -676,7 +734,12 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
676
734
|
const { ref } = (0, types_1.isComponentReference)(onTrigger)
|
|
677
735
|
? convertComponentReference(onTrigger, componentRegistry, "triggers")
|
|
678
736
|
: { ref: onTrigger ? undefined : defaultComponentRef };
|
|
679
|
-
const performFn = generateTriggerPerformFn(
|
|
737
|
+
const performFn = generateTriggerPerformFn({
|
|
738
|
+
componentRef: ref,
|
|
739
|
+
onTrigger,
|
|
740
|
+
componentRegistry,
|
|
741
|
+
triggerType,
|
|
742
|
+
});
|
|
680
743
|
const deleteFn = generateOnInstanceWrapperFn(ref, onTrigger, "onInstanceDelete", componentRegistry, onInstanceDelete);
|
|
681
744
|
const deployFn = generateOnInstanceWrapperFn(ref, onTrigger, "onInstanceDeploy", componentRegistry, onInstanceDeploy);
|
|
682
745
|
return Object.assign(Object.assign({}, result), { [key]: {
|
|
@@ -691,8 +754,9 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
691
754
|
onInstanceDelete: deleteFn,
|
|
692
755
|
hasOnInstanceDelete: !!deleteFn,
|
|
693
756
|
inputs: [],
|
|
694
|
-
scheduleSupport: "valid",
|
|
757
|
+
scheduleSupport: triggerType === "polling" ? "required" : "valid",
|
|
695
758
|
synchronousResponseSupport: "valid",
|
|
759
|
+
isPollingTrigger: triggerType === "polling",
|
|
696
760
|
} });
|
|
697
761
|
}, {});
|
|
698
762
|
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InstanceAttributes, CustomerAttributes, DataSourceType, DataSourceResultType, UserAttributes, TriggerEventFunctionReturn, IntegrationAttributes, FlowAttributes, ConfigVarResultCollection, ComponentManifest, FlowInvoker, ExecutionFrame, DebugContext, FlowSchemas } from "../types";
|
|
1
|
+
import { InstanceAttributes, CustomerAttributes, DataSourceType, DataSourceResultType, UserAttributes, TriggerEventFunctionReturn, IntegrationAttributes, FlowAttributes, ConfigVarResultCollection, ComponentManifest, FlowInvoker, ExecutionFrame, DebugContext, FlowSchemas, PollingTriggerPerformFunction, Inputs, TriggerResult as TriggerPerformResult, TriggerPerformFunction } from "../types";
|
|
2
|
+
import type { CNIPollingPerformFunction, ComponentRefTriggerPerformFunction } from "./triggerTypes";
|
|
2
3
|
interface DisplayDefinition {
|
|
3
4
|
label: string;
|
|
4
5
|
description: string;
|
|
@@ -15,7 +16,7 @@ export interface PublishingMetadata {
|
|
|
15
16
|
testApiKeys?: string[];
|
|
16
17
|
}[];
|
|
17
18
|
}
|
|
18
|
-
export interface Component {
|
|
19
|
+
export interface Component<TInputs extends Inputs = Inputs, TActionInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>> {
|
|
19
20
|
key: string;
|
|
20
21
|
public?: boolean;
|
|
21
22
|
documentationUrl?: string;
|
|
@@ -24,7 +25,7 @@ export interface Component {
|
|
|
24
25
|
iconPath?: string;
|
|
25
26
|
};
|
|
26
27
|
actions: Record<string, Action>;
|
|
27
|
-
triggers: Record<string, Trigger
|
|
28
|
+
triggers: Record<string, Trigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>>;
|
|
28
29
|
dataSources: Record<string, DataSource>;
|
|
29
30
|
connections: Connection[];
|
|
30
31
|
codeNativeIntegrationYAML?: string;
|
|
@@ -130,10 +131,9 @@ interface TriggerBranchingResult extends TriggerBaseResult {
|
|
|
130
131
|
branch: string;
|
|
131
132
|
}
|
|
132
133
|
export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
133
|
-
export type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: Record<string, unknown>) => Promise<TriggerResult>;
|
|
134
134
|
export type TriggerEventFunctionResult = TriggerEventFunctionReturn | void;
|
|
135
135
|
export type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>;
|
|
136
|
-
export interface Trigger {
|
|
136
|
+
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>> {
|
|
137
137
|
key: string;
|
|
138
138
|
display: DisplayDefinition & {
|
|
139
139
|
directions?: string;
|
|
@@ -145,7 +145,7 @@ export interface Trigger {
|
|
|
145
145
|
allowsBranching?: boolean;
|
|
146
146
|
staticBranchNames?: string[];
|
|
147
147
|
dynamicBranchInput?: string;
|
|
148
|
-
perform: TriggerPerformFunction
|
|
148
|
+
perform: TriggerPerformFunction<TInputs, TConfigVars, TAllowsBranching, TResult> | PollingTriggerPerformFunction<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult> | CNIPollingPerformFunction<TInputs, TConfigVars, TPayload, TAllowsBranching> | ComponentRefTriggerPerformFunction<TInputs, TConfigVars>;
|
|
149
149
|
onInstanceDeploy?: TriggerEventFunction;
|
|
150
150
|
hasOnInstanceDeploy?: boolean;
|
|
151
151
|
onInstanceDelete?: TriggerEventFunction;
|
|
@@ -1,12 +1,35 @@
|
|
|
1
|
-
import type { ConfigVarResultCollection, ErrorHandler, Inputs, PollingTriggerDefinition, PollingTriggerPerformFunction, TriggerPayload } from "../types";
|
|
1
|
+
import type { ActionContext, ComponentRegistry, ConfigVarResultCollection, ErrorHandler, Inputs, PollingContext, PollingTriggerDefinition, PollingTriggerPerformFunction, TriggerPayload, TriggerReference, TriggerResult, TriggerPerformFunction } from "../types";
|
|
2
|
+
import { ComponentReference as ServerComponentReference } from "./integration";
|
|
3
|
+
import type { CNIPollingPerformFunction, ComponentRefTriggerPerformFunction } from "./triggerTypes";
|
|
2
4
|
export type PerformFn = (...args: any[]) => Promise<any>;
|
|
5
|
+
interface CreatePollingContext {
|
|
6
|
+
context: ActionContext;
|
|
7
|
+
invokeAction: PollingContext["polling"]["invokeAction"];
|
|
8
|
+
}
|
|
9
|
+
export declare const createPollingContext: ({ context, invokeAction, }: CreatePollingContext) => Pick<PollingContext, "polling">;
|
|
3
10
|
export type CleanFn = (...args: any[]) => any;
|
|
4
11
|
export type InputCleaners = Record<string, CleanFn | undefined>;
|
|
5
12
|
interface CreatePerformProps {
|
|
6
13
|
inputCleaners: InputCleaners;
|
|
7
14
|
errorHandler?: ErrorHandler;
|
|
8
15
|
}
|
|
9
|
-
export declare const cleanParams: (params: Record<string, unknown>, cleaners: InputCleaners) => Record<string,
|
|
16
|
+
export declare const cleanParams: (params: Record<string, unknown>, cleaners: InputCleaners) => Record<string, unknown>;
|
|
10
17
|
export declare const createPerform: (performFn: PerformFn, { inputCleaners, errorHandler }: CreatePerformProps) => PerformFn;
|
|
11
|
-
export declare const createPollingPerform: (trigger: PollingTriggerDefinition<any, ConfigVarResultCollection, TriggerPayload, boolean, any, any>, { inputCleaners, errorHandler }: CreatePerformProps) => PollingTriggerPerformFunction<
|
|
18
|
+
export declare const createPollingPerform: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>(trigger: PollingTriggerDefinition<any, ConfigVarResultCollection, TriggerPayload, boolean, any, any>, { inputCleaners, errorHandler }: CreatePerformProps) => PollingTriggerPerformFunction<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
19
|
+
type CreateCNIPollingPerform<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> = {
|
|
20
|
+
componentRegistry: ComponentRegistry;
|
|
21
|
+
onTrigger: PollingTriggerPerformFunction<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
22
|
+
};
|
|
23
|
+
export declare const createCNIPollingPerform: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ onTrigger, componentRegistry, }: CreateCNIPollingPerform<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>) => CNIPollingPerformFunction<TInputs, TConfigVars, TPayload, TAllowsBranching>;
|
|
24
|
+
interface CreateCNIComponentRefPerform {
|
|
25
|
+
componentRef: ServerComponentReference;
|
|
26
|
+
componentRegistry: ComponentRegistry;
|
|
27
|
+
onTrigger: TriggerReference;
|
|
28
|
+
}
|
|
29
|
+
export declare const createCNIComponentRefPerform: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection>({ componentRegistry, componentRef, onTrigger, }: CreateCNIComponentRefPerform) => ComponentRefTriggerPerformFunction<TInputs, TConfigVars>;
|
|
30
|
+
interface CreateCNIPerform<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
31
|
+
componentRegistry: ComponentRegistry;
|
|
32
|
+
onTrigger: TriggerPerformFunction<TInputs, TConfigVars, TAllowsBranching, TResult>;
|
|
33
|
+
}
|
|
34
|
+
export declare const createCNIPerform: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean | undefined, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>>({ componentRegistry, onTrigger, }: CreateCNIPerform<TInputs, TConfigVars, TAllowsBranching, TResult>) => TriggerPerformFunction<TInputs, TConfigVars, TAllowsBranching, TResult>;
|
|
12
35
|
export {};
|
|
@@ -23,9 +23,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createPollingPerform = exports.createPerform = exports.cleanParams = void 0;
|
|
26
|
+
exports.createCNIPerform = exports.createCNIComponentRefPerform = exports.createCNIPollingPerform = exports.createPollingPerform = exports.createPerform = exports.cleanParams = exports.createPollingContext = void 0;
|
|
27
|
+
const convertIntegration_1 = require("./convertIntegration");
|
|
27
28
|
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
28
29
|
const context_1 = require("./context");
|
|
30
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31
|
+
const createPollingContext = ({ context, invokeAction, }) => {
|
|
32
|
+
return {
|
|
33
|
+
polling: {
|
|
34
|
+
invokeAction,
|
|
35
|
+
getState: () => {
|
|
36
|
+
const internal = context.instanceState.__prismaticInternal;
|
|
37
|
+
const internalState = isRecord(internal) ? internal : {};
|
|
38
|
+
return isRecord(internalState.polling) ? internalState.polling : {};
|
|
39
|
+
},
|
|
40
|
+
setState: (newState) => {
|
|
41
|
+
const internal = context.instanceState.__prismaticInternal;
|
|
42
|
+
const internalState = isRecord(internal) ? internal : {};
|
|
43
|
+
context.instanceState.__prismaticInternal = Object.assign(Object.assign({}, internalState), { polling: newState });
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
exports.createPollingContext = createPollingContext;
|
|
29
49
|
const cleanParams = (params, cleaners) => {
|
|
30
50
|
const keys = (0, uniq_1.default)([...Object.keys(params), ...Object.keys(cleaners)]);
|
|
31
51
|
return keys.reduce((result, key) => {
|
|
@@ -85,25 +105,10 @@ const createPollingPerform = (trigger, { inputCleaners, errorHandler }) => {
|
|
|
85
105
|
return (context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
106
|
try {
|
|
87
107
|
const { pollAction } = trigger;
|
|
88
|
-
const pollingContext = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
errorHandler,
|
|
93
|
-
}),
|
|
94
|
-
getState: () => {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
const castState = (_a = context.instanceState.__prismaticInternal) !== null && _a !== void 0 ? _a : {};
|
|
97
|
-
return (_b = castState.polling) !== null && _b !== void 0 ? _b : {};
|
|
98
|
-
},
|
|
99
|
-
setState: (newState) => {
|
|
100
|
-
var _a;
|
|
101
|
-
const castState = (_a = context.instanceState.__prismaticInternal) !== null && _a !== void 0 ? _a : {};
|
|
102
|
-
context.instanceState.__prismaticInternal = Object.assign(Object.assign({}, castState), { polling: newState });
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
debug: (0, context_1.createDebugContext)(context),
|
|
106
|
-
};
|
|
108
|
+
const pollingContext = Object.assign(Object.assign({ invokeFlow: (0, context_1.createInvokeFlow)(context) }, (0, exports.createPollingContext)({
|
|
109
|
+
context,
|
|
110
|
+
invokeAction: createInvokePollAction(context, pollAction, { errorHandler }),
|
|
111
|
+
})), { debug: (0, context_1.createDebugContext)(context) });
|
|
107
112
|
const triggerPerform = (0, exports.createPerform)(trigger.perform, {
|
|
108
113
|
inputCleaners,
|
|
109
114
|
errorHandler,
|
|
@@ -118,3 +123,42 @@ const createPollingPerform = (trigger, { inputCleaners, errorHandler }) => {
|
|
|
118
123
|
});
|
|
119
124
|
};
|
|
120
125
|
exports.createPollingPerform = createPollingPerform;
|
|
126
|
+
const createCNIPollingPerform = ({ onTrigger, componentRegistry, }) => {
|
|
127
|
+
return (context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
128
|
+
const cniContext = (0, context_1.createCNIContext)(context, componentRegistry);
|
|
129
|
+
const finalContext = Object.assign(Object.assign({}, cniContext), (0, exports.createPollingContext)({
|
|
130
|
+
context: cniContext,
|
|
131
|
+
invokeAction: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
+
throw new Error("invokeAction is not available for code-native polling triggers. " +
|
|
133
|
+
"Use getState/setState to manage polling state directly in your onTrigger function.");
|
|
134
|
+
}),
|
|
135
|
+
}));
|
|
136
|
+
const result = yield onTrigger(finalContext, payload, params);
|
|
137
|
+
if (result === undefined) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
const { polledNoChanges } = result, rest = __rest(result, ["polledNoChanges"]);
|
|
141
|
+
return Object.assign(Object.assign({}, rest), { resultType: polledNoChanges ? "polled_no_changes" : "completed" });
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
exports.createCNIPollingPerform = createCNIPollingPerform;
|
|
145
|
+
const createCNIComponentRefPerform = ({ componentRegistry, componentRef, onTrigger, }) => {
|
|
146
|
+
return (context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
var _a;
|
|
148
|
+
// @ts-expect-error: _components isn't part of the public API
|
|
149
|
+
const _components = (_a = context._components) !== null && _a !== void 0 ? _a : {
|
|
150
|
+
invokeTrigger: () => { },
|
|
151
|
+
};
|
|
152
|
+
const invokeTrigger = _components.invokeTrigger;
|
|
153
|
+
const cniContext = (0, context_1.createCNIContext)(context, componentRegistry);
|
|
154
|
+
return yield invokeTrigger((0, convertIntegration_1.invokeTriggerComponentInput)(componentRef, onTrigger, "perform"), cniContext, payload, params);
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
exports.createCNIComponentRefPerform = createCNIComponentRefPerform;
|
|
158
|
+
const createCNIPerform = ({ componentRegistry, onTrigger, }) => {
|
|
159
|
+
return (context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
+
const cniContext = (0, context_1.createCNIContext)(context, componentRegistry);
|
|
161
|
+
return yield onTrigger(cniContext, payload, params);
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
exports.createCNIPerform = createCNIPerform;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trigger perform function types for server-side usage.
|
|
3
|
+
* These are separate from the user-facing types in ../types to avoid circular dependencies.
|
|
4
|
+
*/
|
|
5
|
+
import type { ActionContext, ActionInputParameters, ConfigVarResultCollection, Inputs, TriggerPayload, TriggerResult } from "../types";
|
|
6
|
+
/** The result type after transforming a polling trigger result for the server. */
|
|
7
|
+
export type PollingTriggerServerResult<TAllowsBranching extends boolean, TPayload extends TriggerPayload> = Omit<NonNullable<TriggerResult<TAllowsBranching, TPayload>>, "polledNoChanges"> & {
|
|
8
|
+
resultType: string;
|
|
9
|
+
};
|
|
10
|
+
/** The perform function type for CNI polling triggers that returns the server-expected format. */
|
|
11
|
+
export type CNIPollingPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean> = (context: ActionContext<TConfigVars>, payload: TPayload, params: ActionInputParameters<TInputs>) => Promise<PollingTriggerServerResult<TAllowsBranching, TPayload> | undefined>;
|
|
12
|
+
/** Server trigger result type - matches the non-generic TriggerResult from serverTypes/index.ts */
|
|
13
|
+
interface ServerTriggerBaseResult {
|
|
14
|
+
payload: TriggerPayload;
|
|
15
|
+
response?: {
|
|
16
|
+
statusCode: number;
|
|
17
|
+
contentType: string;
|
|
18
|
+
headers?: Record<string, string>;
|
|
19
|
+
body?: string;
|
|
20
|
+
};
|
|
21
|
+
instanceState?: Record<string, unknown>;
|
|
22
|
+
crossFlowState?: Record<string, unknown>;
|
|
23
|
+
executionState?: Record<string, unknown>;
|
|
24
|
+
integrationState?: Record<string, unknown>;
|
|
25
|
+
failed?: boolean;
|
|
26
|
+
error?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
interface ServerTriggerBranchingResult extends ServerTriggerBaseResult {
|
|
29
|
+
branch: string;
|
|
30
|
+
}
|
|
31
|
+
type ServerTriggerResult = ServerTriggerBranchingResult | ServerTriggerBaseResult | undefined;
|
|
32
|
+
/** Return type for component ref triggers - uses the server's TriggerResult since we delegate to invokeTrigger. */
|
|
33
|
+
export type ComponentRefTriggerPerformFunction<TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection> = (context: ActionContext<TConfigVars>, payload: TriggerPayload, params: ActionInputParameters<TInputs>) => Promise<ServerTriggerResult>;
|
|
34
|
+
export {};
|
package/dist/testing.d.ts
CHANGED
|
@@ -78,12 +78,12 @@ type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
|
78
78
|
* Runs the Trigger and then the Action function and returns the result of the Action. See
|
|
79
79
|
* https://prismatic.io/docs/integrations/triggers/cross-flow/#using-cross-flow-triggers-in-code-native
|
|
80
80
|
*/
|
|
81
|
-
export declare const invokeFlow: <TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow, { configVars, context, payload, }?: {
|
|
81
|
+
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, }?: {
|
|
82
82
|
configVars?: TConfigVarValues;
|
|
83
83
|
context?: Partial<ActionContext<TConfigVars>>;
|
|
84
84
|
payload?: Partial<TriggerPayload>;
|
|
85
85
|
}) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
86
|
-
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
86
|
+
export declare class ComponentTestHarness<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TPayload> = InvokeTriggerResult<TAllowsBranching, TPayload>, TComponent extends Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult> = Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>> {
|
|
87
87
|
component: TComponent;
|
|
88
88
|
constructor(component: TComponent);
|
|
89
89
|
private buildParams;
|
|
@@ -96,7 +96,7 @@ export declare class ComponentTestHarness<TComponent extends Component> {
|
|
|
96
96
|
* Invoke a trigger by its key within a unit test. See
|
|
97
97
|
* https://prismatic.io/docs/custom-connectors/unit-testing/
|
|
98
98
|
*/
|
|
99
|
-
trigger
|
|
99
|
+
trigger(key: string, payload?: Partial<TPayload>, params?: Record<string, unknown>, context?: Partial<ActionContext<TConfigVars>>): Promise<TriggerResult>;
|
|
100
100
|
/**
|
|
101
101
|
* Invoke a trigger's onInstanceDeploy function by its key within a unit test. See
|
|
102
102
|
* https://prismatic.io/docs/custom-connectors/unit-testing/
|
|
@@ -122,12 +122,12 @@ export declare class ComponentTestHarness<TComponent extends Component> {
|
|
|
122
122
|
* Create a testing harness to test a custom component's actions, triggers and data sources. See
|
|
123
123
|
* https://prismatic.io/docs/custom-connectors/unit-testing/
|
|
124
124
|
*/
|
|
125
|
-
export declare const createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
125
|
+
export declare const createHarness: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TPayload> = InvokeTriggerResult<TAllowsBranching, TPayload>, TComponent extends Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult> = Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>>(component: TComponent) => ComponentTestHarness<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TComponent>;
|
|
126
126
|
declare const _default: {
|
|
127
127
|
loggerMock: () => ActionLogger;
|
|
128
128
|
invoke: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends InvokeActionPerformReturn<TAllowsBranching, unknown>>({ perform }: ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>, params: ActionInputParameters<TInputs>, context?: Partial<ActionContext<TConfigVars>>) => Promise<InvokeReturn<TReturn>>;
|
|
129
129
|
invokeTrigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TriggerPayload>>({ perform }: TriggerDefinition<TInputs, TConfigVars, TAllowsBranching, TResult>, context?: Partial<ActionContext<TConfigVars>>, payload?: TriggerPayload, params?: ActionInputParameters<TInputs>) => Promise<InvokeReturn<TResult>>;
|
|
130
|
-
createHarness: <TComponent extends Component>(component: TComponent) => ComponentTestHarness<TComponent>;
|
|
130
|
+
createHarness: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends InvokeTriggerResult<TAllowsBranching, TPayload> = InvokeTriggerResult<TAllowsBranching, TPayload>, TComponent extends Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult> = Component<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>>(component: TComponent) => ComponentTestHarness<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TComponent>;
|
|
131
131
|
invokeDataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends DataSourceType>({ perform }: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>, params: ActionInputParameters<TInputs>, context?: Partial<DataSourceContext<TConfigVars>>) => Promise<InvokeDataSourceResult<TDataSourceType>>;
|
|
132
132
|
};
|
|
133
133
|
export default _default;
|
package/dist/testing.js
CHANGED
|
@@ -312,7 +312,9 @@ class ComponentTestHarness {
|
|
|
312
312
|
trigger(key, payload, params, context) {
|
|
313
313
|
return __awaiter(this, void 0, void 0, function* () {
|
|
314
314
|
const trigger = this.component.triggers[key];
|
|
315
|
-
return trigger.perform(
|
|
315
|
+
return trigger.perform(
|
|
316
|
+
// @ts-expect-error -- Revisit if this should support polling
|
|
317
|
+
createActionContext(context), Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload), this.buildParams(trigger.inputs, params));
|
|
316
318
|
});
|
|
317
319
|
}
|
|
318
320
|
/**
|
|
@@ -169,13 +169,14 @@ export type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceRefe
|
|
|
169
169
|
type BaseConnectionConfigVar = BaseConfigVar & {
|
|
170
170
|
dataType: "connection";
|
|
171
171
|
};
|
|
172
|
+
export type OnPremiseConnectionConfigTypeEnum = "allowed" | "disallowed" | "required";
|
|
172
173
|
type ConnectionDefinitionConfigVar = ConnectionDefinition extends infer TConnectionDefinitionType extends ConnectionDefinition ? TConnectionDefinitionType extends infer TConnectionDefinition extends ConnectionDefinition ? BaseConnectionConfigVar & Omit<TConnectionDefinition, "inputs" | "display" | "key"> & {
|
|
173
174
|
icons?: TConnectionDefinition["display"]["icons"];
|
|
175
|
+
onPremConnectionConfig?: OnPremiseConnectionConfigTypeEnum;
|
|
174
176
|
inputs: {
|
|
175
177
|
[Key in keyof TConnectionDefinition["inputs"]]: TConnectionDefinition["inputs"][Key] & ConfigVarInputVisibility;
|
|
176
178
|
};
|
|
177
179
|
} : never : never;
|
|
178
|
-
type OnPremiseConnectionConfigTypeEnum = "allowed" | "disallowed" | "required";
|
|
179
180
|
type ConnectionReferenceConfigVar = ComponentRegistryConnection extends infer TConnectionReference ? TConnectionReference extends ComponentRegistryConnection ? BaseConnectionConfigVar & {
|
|
180
181
|
connection: TConnectionReference["reference"] & ("onPremAvailable" extends keyof TConnectionReference ? TConnectionReference["onPremAvailable"] extends true ? {
|
|
181
182
|
template?: string;
|
|
@@ -5,6 +5,7 @@ import type { ConfigPages, UserLevelConfigPages } from "./ConfigPages";
|
|
|
5
5
|
import type { ConfigVars } from "./ConfigVars";
|
|
6
6
|
import type { FlowDefinitionFlowSchema } from "./FlowSchemas";
|
|
7
7
|
import type { Inputs } from "./Inputs";
|
|
8
|
+
import type { PollingTriggerPerformFunction } from "./PollingTriggerDefinition";
|
|
8
9
|
import type { ScopedConfigVarMap } from "./ScopedConfigVars";
|
|
9
10
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
10
11
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
@@ -14,7 +15,7 @@ import type { TriggerResult } from "./TriggerResult";
|
|
|
14
15
|
* Defines attributes of a code-native integration. See
|
|
15
16
|
* https://prismatic.io/docs/integrations/code-native/
|
|
16
17
|
*/
|
|
17
|
-
export type IntegrationDefinition = {
|
|
18
|
+
export type IntegrationDefinition<TInputs extends Inputs = Inputs, TActionInputs extends Inputs = Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>> = {
|
|
18
19
|
/** The unique name for this integration. */
|
|
19
20
|
name: string;
|
|
20
21
|
/** Description for this integration. */
|
|
@@ -46,7 +47,7 @@ export type IntegrationDefinition = {
|
|
|
46
47
|
* Flows for this integration. See
|
|
47
48
|
* https://prismatic.io/docs/integrations/code-native/flows/
|
|
48
49
|
*/
|
|
49
|
-
flows: Flow[];
|
|
50
|
+
flows: Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>[];
|
|
50
51
|
/**
|
|
51
52
|
* Config wizard pages for this integration. See
|
|
52
53
|
* https://prismatic.io/docs/integrations/code-native/config-wizard/
|
|
@@ -84,8 +85,8 @@ export type FlowExecutionContext = ActionContext<ConfigVars, {
|
|
|
84
85
|
[Key in keyof ComponentRegistry]: ComponentRegistry[Key]["actions"];
|
|
85
86
|
}>;
|
|
86
87
|
export type FlowExecutionContextActions = FlowExecutionContext["components"];
|
|
87
|
-
/**
|
|
88
|
-
|
|
88
|
+
/** Base properties shared by all flow types. */
|
|
89
|
+
interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
89
90
|
/** The unique name for this flow. */
|
|
90
91
|
name: string;
|
|
91
92
|
/** A unique, unchanging value that is used to maintain identity for the flow even if the name changes. */
|
|
@@ -116,18 +117,12 @@ export interface Flow<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
116
117
|
*/
|
|
117
118
|
organizationApiKeys?: string[];
|
|
118
119
|
testApiKeys?: string[];
|
|
119
|
-
/** Schedule configuration that defines the frequency with which this flow will be automatically executed. */
|
|
120
|
-
schedule?: (ValueExpression<string> | ConfigVarExpression) & {
|
|
121
|
-
timezone?: string;
|
|
122
|
-
};
|
|
123
120
|
/** Error handling configuration. */
|
|
124
121
|
errorConfig?: StepErrorConfig;
|
|
125
122
|
/** Optional schemas definitions for the flow. Currently only for use with AI agents. */
|
|
126
123
|
schemas?: Record<string, FlowDefinitionFlowSchema> & {
|
|
127
124
|
invoke: FlowDefinitionFlowSchema;
|
|
128
125
|
};
|
|
129
|
-
/** Specifies the trigger function for this flow, which returns a payload and optional HTTP response. */
|
|
130
|
-
onTrigger?: TriggerReference | TriggerPerformFunction<Inputs, ConfigVars, false, TriggerResult<false, TTriggerPayload>>;
|
|
131
126
|
/**
|
|
132
127
|
* Specifies the function to execute when an instance of this integration is deployed. See
|
|
133
128
|
* https://prismatic.io/docs/custom-connectors/triggers/#instance-deploy-and-delete-events-for-triggers
|
|
@@ -141,6 +136,37 @@ export interface Flow<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
141
136
|
/** Specifies the main function for this flow which is run when this flow is invoked. */
|
|
142
137
|
onExecution: FlowOnExecution<TTriggerPayload>;
|
|
143
138
|
}
|
|
139
|
+
export type StandardTriggerType = "standard";
|
|
140
|
+
/** A standard flow with a webhook or scheduled trigger (non-polling). */
|
|
141
|
+
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> {
|
|
142
|
+
triggerType?: StandardTriggerType;
|
|
143
|
+
/** Schedule configuration that defines the frequency with which this flow will be automatically executed. */
|
|
144
|
+
schedule?: (ValueExpression<string> | ConfigVarExpression) & {
|
|
145
|
+
timezone?: string;
|
|
146
|
+
};
|
|
147
|
+
/** Specifies the trigger function for this flow, which returns a payload and optional HTTP response. */
|
|
148
|
+
onTrigger?: TriggerReference | TriggerPerformFunction<TInputs, ConfigVars, TAllowsBranching, TResult>;
|
|
149
|
+
}
|
|
150
|
+
export type PollingTriggerType = "polling";
|
|
151
|
+
/** A polling flow that runs on a schedule and has access to polling context (getState/setState). */
|
|
152
|
+
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> {
|
|
153
|
+
/**
|
|
154
|
+
* Type of trigger for this flow. A "polling" trigger runs on a schedule
|
|
155
|
+
* and can use context.polling.* functions. Requires schedule to be set.
|
|
156
|
+
*/
|
|
157
|
+
triggerType: PollingTriggerType;
|
|
158
|
+
/** Schedule configuration that defines the frequency with which this flow will be automatically executed. Required for polling triggers. */
|
|
159
|
+
schedule: (ValueExpression<string> | ConfigVarExpression) & {
|
|
160
|
+
timezone?: string;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Specifies the trigger function for this flow.
|
|
164
|
+
*/
|
|
165
|
+
onTrigger: PollingTriggerPerformFunction<TInputs, TActionInputs, ConfigVars, TPayload, TAllowsBranching, TResult>;
|
|
166
|
+
}
|
|
167
|
+
/** Defines attributes of a flow of a code-native integration. */
|
|
168
|
+
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>;
|
|
169
|
+
export type FlowTriggerType = PollingTriggerType | StandardTriggerType;
|
|
144
170
|
/** Defines attributes of a Preprocess flow Configuration used by a flow of an integration. */
|
|
145
171
|
export type PreprocessFlowConfig = {
|
|
146
172
|
/** Name of the field in the data payload returned by the Preprocess flow to use for a flow Name. */
|
|
@@ -161,14 +187,16 @@ export type RetryConfig = {
|
|
|
161
187
|
/** Name of the field in the data payload returned by the flow's trigger to use as a Unique Request ID for retry request cancellation. */
|
|
162
188
|
uniqueRequestIdField?: string;
|
|
163
189
|
};
|
|
164
|
-
/** Defines attributes of a
|
|
190
|
+
/** Defines attributes of a queue configuration used by a flow of an integration. */
|
|
165
191
|
export type QueueConfig = {
|
|
166
|
-
/** Determines whether the flow should be executed using FIFO ordering. Not valid for
|
|
192
|
+
/** Determines whether the flow should be executed using FIFO ordering. Not valid for synchronous or scheduled flows. */
|
|
167
193
|
usesFifoQueue?: boolean;
|
|
168
194
|
/** Reference to the field in the flow's trigger return payload; used to determine whether to queue the execution. */
|
|
169
195
|
dedupeIdField?: string;
|
|
170
196
|
/** Determines whether the flow should be setup for singleton executions. Only valid for scheduled/polling trigger-based flows. */
|
|
171
197
|
singletonExecutions?: boolean;
|
|
198
|
+
/** The maximum number of concurrent executions for this flow. Must be between 2 and 10. */
|
|
199
|
+
concurrencyLimit?: number;
|
|
172
200
|
};
|
|
173
201
|
/** Defines attributes of a step error configuration used to determine how to handle errors during flow step execution. */
|
|
174
202
|
export type StepErrorConfig = {
|
|
@@ -189,3 +217,4 @@ export type EndpointType = "flow_specific" | "instance_specific" | "shared_insta
|
|
|
189
217
|
export type EndpointSecurityType = "unsecured" | "customer_optional" | "customer_required" | "organization";
|
|
190
218
|
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
191
219
|
export type StepErrorHandlerType = "fail" | "ignore" | "retry";
|
|
220
|
+
export {};
|
|
@@ -7,9 +7,9 @@ import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
|
7
7
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
8
8
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
9
9
|
import type { TriggerResult } from "./TriggerResult";
|
|
10
|
-
export interface PollingContext<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection> extends ActionContext<TConfigVars> {
|
|
10
|
+
export interface PollingContext<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, ReturnData = unknown> extends ActionContext<TConfigVars> {
|
|
11
11
|
polling: {
|
|
12
|
-
invokeAction: (params: ActionInputParameters<TInputs>) => Promise<ActionPerformReturn<boolean,
|
|
12
|
+
invokeAction: (params: ActionInputParameters<TInputs>) => Promise<ActionPerformReturn<boolean, ReturnData>>;
|
|
13
13
|
getState: () => Record<string, unknown>;
|
|
14
14
|
setState: (newState: Record<string, unknown>) => void;
|
|
15
15
|
};
|
package/package.json
CHANGED