@activepieces/pieces-framework 0.5.0 → 0.6.1

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/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@activepieces/pieces-framework",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "type": "commonjs",
5
5
  "dependencies": {
6
6
  "@sinclair/typebox": "^0.26.3",
7
7
  "nanoid": "^3.3.4",
8
- "@activepieces/shared": "0.5.0",
8
+ "semver": "7.5.3",
9
+ "@activepieces/shared": "0.5.6",
9
10
  "tslib": "1.14.1"
10
11
  },
11
12
  "main": "./src/index.js",
@@ -3,6 +3,25 @@ import { Action } from './action/action';
3
3
  import { EventPayload, ParseEventResponse } from '@activepieces/shared';
4
4
  import { PieceBase, PieceMetadata } from './piece-metadata';
5
5
  import { PieceAuthProperty } from './property';
6
+ export declare class Piece<PieceAuth extends PieceAuthProperty = PieceAuthProperty> implements Omit<PieceBase, "version" | "name"> {
7
+ readonly displayName: string;
8
+ readonly logoUrl: string;
9
+ readonly authors: string[];
10
+ readonly events: PieceEventProcessors | undefined;
11
+ readonly auth?: PieceAuth | undefined;
12
+ readonly minimumSupportedRelease?: string | undefined;
13
+ readonly maximumSupportedRelease?: string | undefined;
14
+ readonly description: string;
15
+ private readonly _actions;
16
+ private readonly _triggers;
17
+ constructor(displayName: string, logoUrl: string, authors: string[], events: PieceEventProcessors | undefined, actions: Action<PieceAuth>[], triggers: Trigger<PieceAuth>[], auth?: PieceAuth | undefined, minimumSupportedRelease?: string | undefined, maximumSupportedRelease?: string | undefined, description?: string);
18
+ metadata(): Omit<PieceMetadata, "name" | "version">;
19
+ getAction(actionName: string): Action | undefined;
20
+ getTrigger(triggerName: string): Trigger | undefined;
21
+ actions(): Record<string, Action>;
22
+ triggers(): Record<string, Trigger>;
23
+ }
24
+ export declare const createPiece: <PieceAuth extends PieceAuthProperty>(params: CreatePieceParams<PieceAuth>) => Piece<PieceAuth>;
6
25
  type CreatePieceParams<PieceAuth extends PieceAuthProperty = PieceAuthProperty> = {
7
26
  displayName: string;
8
27
  logoUrl: string;
@@ -25,23 +44,4 @@ type PieceEventProcessors = {
25
44
  appWebhookUrl: string;
26
45
  }) => boolean;
27
46
  };
28
- export declare class Piece<PieceAuth extends PieceAuthProperty = PieceAuthProperty> implements Omit<PieceBase, "version" | "name"> {
29
- readonly displayName: string;
30
- readonly logoUrl: string;
31
- readonly authors: string[];
32
- readonly events: PieceEventProcessors | undefined;
33
- readonly auth?: PieceAuth | undefined;
34
- readonly minimumSupportedRelease?: string | undefined;
35
- readonly maximumSupportedRelease?: string | undefined;
36
- readonly description: string;
37
- private readonly _actions;
38
- private readonly _triggers;
39
- constructor(displayName: string, logoUrl: string, authors: string[], events: PieceEventProcessors | undefined, actions: Action<PieceAuth>[], triggers: Trigger<PieceAuth>[], auth?: PieceAuth | undefined, minimumSupportedRelease?: string | undefined, maximumSupportedRelease?: string | undefined, description?: string);
40
- metadata(): Omit<PieceMetadata, "name" | "version">;
41
- getAction(actionName: string): Action | undefined;
42
- getTrigger(triggerName: string): Trigger | undefined;
43
- actions(): Record<string, Action>;
44
- triggers(): Record<string, Trigger>;
45
- }
46
- export declare const createPiece: <PieceAuth extends PieceAuthProperty>(params: CreatePieceParams<PieceAuth>) => Piece<PieceAuth>;
47
47
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"piece.js","sourceRoot":"","sources":["../../../../../../packages/pieces/framework/src/lib/piece.ts"],"names":[],"mappings":";;;AAwBA,MAAa,KAAK;IAIhB,YACkB,WAAmB,EACnB,OAAe,EACf,OAAiB,EACjB,MAAwC,EACxD,OAA4B,EAC5B,QAA8B,EACd,IAAgB,EAChB,uBAAgC,EAChC,uBAAgC,EAChC,cAAsB,EAAE;QATxB,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAU;QACjB,WAAM,GAAN,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AAM,CAAC,WAAW,EAClB,MAAM,CAAC,OAAO,EACd,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,EACpB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS,EACxB,MAAM,CAAC,uBAAuB,EAC9B,MAAM,CAAC,uBAAuB,EAC9B,MAAM,CAAC,WAAW,CACnB,CAAA;AACH,CAAC,CAAA;AAbY,QAAA,WAAW,eAavB"}
1
+ {"version":3,"file":"piece.js","sourceRoot":"","sources":["../../../../../../packages/pieces/framework/src/lib/piece.ts"],"names":[],"mappings":";;;AAMA,MAAa,KAAK;IAIhB,YACkB,WAAmB,EACnB,OAAe,EACf,OAAiB,EACjB,MAAwC,EACxD,OAA4B,EAC5B,QAA8B,EACd,IAAgB,EAChB,uBAAgC,EAChC,uBAAgC,EAChC,cAAsB,EAAE;QATxB,gBAAW,GAAX,WAAW,CAAQ;QACnB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAU;QACjB,WAAM,GAAN,MAAM,CAAkC;QAGxC,SAAI,GAAJ,IAAI,CAAY;QAChB,4BAAuB,GAAvB,uBAAuB,CAAS;QAChC,4BAAuB,GAAvB,uBAAuB,CAAS;QAChC,gBAAW,GAAX,WAAW,CAAa;QAbzB,aAAQ,GAA2B,EAAE,CAAA;QACrC,cAAS,GAA4B,EAAE,CAAA;QActD,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAA;QAC9D,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAA;IACrE,CAAC;IAED,QAAQ;QACN,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,QAAQ;YACtB,QAAQ,EAAE,IAAI,CAAC,SAAS;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;YACrD,uBAAuB,EAAE,IAAI,CAAC,uBAAuB;SACtD,CAAA;IACH,CAAC;IAED,SAAS,CAAC,UAAkB;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;IAClC,CAAC;IAED,UAAU,CAAC,WAAmB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;IACpC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF;AAhDD,sBAgDC;AAEM,MAAM,WAAW,GAAG,CAAsC,MAAoC,EAAE,EAAE;;IACvG,OAAO,IAAI,KAAK,CACd,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,OAAO,EACd,MAAA,MAAM,CAAC,OAAO,mCAAI,EAAE,EACpB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS,EACxB,MAAM,CAAC,uBAAuB,EAC9B,MAAM,CAAC,uBAAuB,EAC9B,MAAM,CAAC,WAAW,CACnB,CAAA;AACH,CAAC,CAAA;AAbY,QAAA,WAAW,eAavB"}
@@ -3,6 +3,18 @@ export type BasePropertySchema = {
3
3
  displayName: string;
4
4
  description?: string;
5
5
  };
6
+ type PieceAuthValidatorParams<AuthValueSchema> = {
7
+ auth: AuthValueSchema;
8
+ };
9
+ export type PieceAuthValidatorResponse = {
10
+ valid: true;
11
+ } | {
12
+ valid: false;
13
+ error: string;
14
+ };
15
+ export type BasePieceAuthSchema<AuthValueSchema> = BasePropertySchema & {
16
+ validate?: (params: PieceAuthValidatorParams<AuthValueSchema>) => Promise<PieceAuthValidatorResponse>;
17
+ };
6
18
  export type TPropertyValue<T, U extends PropertyType, REQUIRED extends boolean> = {
7
19
  valueSchema: T;
8
20
  type: U;
@@ -11,7 +23,7 @@ export type TPropertyValue<T, U extends PropertyType, REQUIRED extends boolean>
11
23
  };
12
24
  export type ShortTextProperty<R extends boolean> = BasePropertySchema & TPropertyValue<string, PropertyType.SHORT_TEXT, R>;
13
25
  export type LongTextProperty<R extends boolean> = BasePropertySchema & TPropertyValue<string, PropertyType.LONG_TEXT, R>;
14
- export type SecretTextProperty<R extends boolean> = BasePropertySchema & TPropertyValue<string, PropertyType.SECRET_TEXT, R>;
26
+ export type SecretTextProperty<R extends boolean> = BasePieceAuthSchema<string> & TPropertyValue<string, PropertyType.SECRET_TEXT, R>;
15
27
  export type CheckboxProperty<R extends boolean> = BasePropertySchema & TPropertyValue<boolean, PropertyType.CHECKBOX, R>;
16
28
  export type NumberProperty<R extends boolean> = BasePropertySchema & TPropertyValue<number, PropertyType.NUMBER, R>;
17
29
  export type ArrayProperty<R extends boolean> = BasePropertySchema & TPropertyValue<unknown[], PropertyType.ARRAY, R>;
@@ -24,3 +36,4 @@ export type ApFile = {
24
36
  base64: string;
25
37
  };
26
38
  export type FileProperty<R extends boolean> = BasePropertySchema & TPropertyValue<ApFile, PropertyType.FILE, R>;
39
+ export {};
@@ -1,6 +1,10 @@
1
1
  import { PropertyType } from "./property";
2
- import { BasePropertySchema, TPropertyValue } from "./base-prop";
3
- export type BasicAuthPropertySchema = BasePropertySchema & {
2
+ import { BasePieceAuthSchema, TPropertyValue } from "./base-prop";
3
+ export type BasicAuthPropertyValue = {
4
+ username: string;
5
+ password: string;
6
+ };
7
+ export type BasicAuthPropertySchema = BasePieceAuthSchema<BasicAuthPropertyValue> & {
4
8
  username: {
5
9
  displayName: string;
6
10
  description?: string;
@@ -10,8 +14,4 @@ export type BasicAuthPropertySchema = BasePropertySchema & {
10
14
  description?: string;
11
15
  };
12
16
  };
13
- export type BasicAuthPropertyValue = {
14
- username: string;
15
- password: string;
16
- };
17
17
  export type BasicAuthProperty<R extends boolean> = BasicAuthPropertySchema & TPropertyValue<BasicAuthPropertyValue, PropertyType.BASIC_AUTH, R>;
@@ -1,12 +1,12 @@
1
1
  import { PropertyType } from "./property";
2
- import { BasePropertySchema, CheckboxProperty, LongTextProperty, NumberProperty, SecretTextProperty, ShortTextProperty, TPropertyValue } from "./base-prop";
2
+ import { BasePieceAuthSchema, CheckboxProperty, LongTextProperty, NumberProperty, SecretTextProperty, ShortTextProperty, TPropertyValue } from "./base-prop";
3
3
  import { StaticDropdownProperty } from "./dropdown-prop";
4
4
  import { StaticPropsValue } from "./property";
5
5
  export interface CustomAuthProps {
6
6
  [name: string]: ShortTextProperty<boolean> | LongTextProperty<boolean> | SecretTextProperty<boolean> | NumberProperty<boolean> | StaticDropdownProperty<unknown, boolean> | CheckboxProperty<boolean>;
7
7
  }
8
8
  export type CustomAuthPropertyValue<T extends CustomAuthProps> = StaticPropsValue<T>;
9
- export type CustomAuthPropertySchema<T> = BasePropertySchema & {
9
+ export type CustomAuthPropertySchema<T extends CustomAuthProps> = BasePieceAuthSchema<CustomAuthPropertyValue<T>> & {
10
10
  props: T;
11
11
  };
12
12
  export type CustomAuthProperty<R extends boolean, T extends CustomAuthProps> = CustomAuthPropertySchema<T> & TPropertyValue<CustomAuthPropertyValue<T>, PropertyType.CUSTOM_AUTH, R>;
@@ -1,5 +1,5 @@
1
1
  import { PropertyType } from "./property";
2
- import { BasePropertySchema, SecretTextProperty, ShortTextProperty, TPropertyValue } from "./base-prop";
2
+ import { BasePieceAuthSchema, SecretTextProperty, ShortTextProperty, TPropertyValue } from "./base-prop";
3
3
  import { StaticDropdownProperty } from "./dropdown-prop";
4
4
  import { StaticPropsValue } from "./property";
5
5
  type OAuthProp = ShortTextProperty<true> | SecretTextProperty<true> | StaticDropdownProperty<any, true>;
@@ -7,7 +7,7 @@ export interface OAuth2Props {
7
7
  [name: string]: ShortTextProperty<boolean> | SecretTextProperty<boolean> | StaticDropdownProperty<unknown, boolean>;
8
8
  }
9
9
  export type OAuthPropsValue<T extends OAuth2Props> = StaticPropsValue<T>;
10
- export type OAuth2PropertySchema = BasePropertySchema & {
10
+ export type OAuth2PropertySchema = BasePieceAuthSchema<OAuth2PropertyValue> & {
11
11
  props?: Record<string, OAuthProp>;
12
12
  authUrl: string;
13
13
  tokenUrl: string;
@@ -24,7 +24,7 @@ export declare enum PropertyType {
24
24
  DATE_TIME = "DATE_TIME",
25
25
  FILE = "FILE"
26
26
  }
27
- export type PieceAuthProperty = BasicAuthProperty<boolean> | CustomAuthProperty<boolean, CustomAuthProps> | OAuth2Property<boolean, OAuth2Props> | SecretTextProperty<boolean>;
27
+ export type PieceAuthProperty = BasicAuthProperty<boolean> | CustomAuthProperty<boolean, any> | OAuth2Property<boolean, OAuth2Props> | SecretTextProperty<boolean>;
28
28
  export type NonAuthPieceProperty = ShortTextProperty<boolean> | LongTextProperty<boolean> | CheckboxProperty<boolean> | DropdownProperty<any, boolean> | StaticDropdownProperty<any, boolean> | NumberProperty<boolean> | ArrayProperty<boolean> | ObjectProperty<boolean> | JsonProperty<boolean> | MultiSelectDropdownProperty<unknown, boolean> | StaticMultiSelectDropdownProperty<unknown, boolean> | DynamicProperties<boolean> | DateTimeProperty<boolean> | FileProperty<boolean>;
29
29
  export type PieceProperty = NonAuthPieceProperty | PieceAuthProperty;
30
30
  export interface PiecePropertyMap {
@@ -6,6 +6,21 @@ export declare enum TriggerStrategy {
6
6
  WEBHOOK = "WEBHOOK",
7
7
  APP_WEBHOOK = "APP_WEBHOOK"
8
8
  }
9
+ export declare enum WebhookHandshakeStrategy {
10
+ NONE = "NONE",
11
+ HEADER_PRESENT = "HEADER_PRESENT",
12
+ QUERY_PRESENT = "QUERY_PRESENT",
13
+ BODY_PARAM_PRESENT = "BODY_PARAM_PRESENT"
14
+ }
15
+ export interface WebhookHandshakeConfiguration {
16
+ strategy: WebhookHandshakeStrategy;
17
+ paramName?: string;
18
+ }
19
+ export interface WebhookResponse {
20
+ status: number;
21
+ body?: any;
22
+ headers?: Record<string, string>;
23
+ }
9
24
  type CreateTriggerParams<PieceAuth extends PieceAuthProperty, TriggerProps extends NonAuthPiecePropertyMap, TS extends TriggerStrategy> = {
10
25
  /**
11
26
  * A dummy parameter used to infer {@code PieceAuth} type
@@ -16,7 +31,9 @@ type CreateTriggerParams<PieceAuth extends PieceAuthProperty, TriggerProps exten
16
31
  auth?: PieceAuth;
17
32
  props: TriggerProps;
18
33
  type: TS;
34
+ handshakeConfiguration?: WebhookHandshakeConfiguration;
19
35
  onEnable: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
36
+ onHandshake?: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<WebhookResponse>;
20
37
  onDisable: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
21
38
  run: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
22
39
  test?: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
@@ -29,13 +46,15 @@ export declare class ITrigger<TS extends TriggerStrategy, PieceAuth extends Piec
29
46
  readonly description: string;
30
47
  readonly props: TriggerProps;
31
48
  readonly type: TS;
49
+ readonly handshakeConfiguration: WebhookHandshakeConfiguration;
32
50
  readonly onEnable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
51
+ readonly onHandshake: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<WebhookResponse>;
33
52
  readonly onDisable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
34
53
  readonly run: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
35
54
  readonly test: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
36
55
  sampleData: unknown;
37
56
  readonly requireAuth: boolean;
38
- constructor(name: string, displayName: string, description: string, props: TriggerProps, type: TS, onEnable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>, onDisable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>, run: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>, test: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>, sampleData: unknown, requireAuth?: boolean);
57
+ constructor(name: string, displayName: string, description: string, props: TriggerProps, type: TS, handshakeConfiguration: WebhookHandshakeConfiguration, onEnable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>, onHandshake: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<WebhookResponse>, onDisable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>, run: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>, test: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>, sampleData: unknown, requireAuth?: boolean);
39
58
  }
40
59
  export type Trigger<PieceAuth extends PieceAuthProperty = any, TriggerProps extends NonAuthPiecePropertyMap = any, S extends TriggerStrategy = TriggerStrategy> = ITrigger<S, PieceAuth, TriggerProps>;
41
60
  export declare const createTrigger: <TS extends TriggerStrategy, PieceAuth extends PieceAuthProperty, TriggerProps extends NonAuthPiecePropertyMap>(params: CreateTriggerParams<PieceAuth, TriggerProps, TS>) => ITrigger<TS, PieceAuth, TriggerProps>;
@@ -1,20 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTrigger = exports.ITrigger = exports.TriggerStrategy = void 0;
3
+ exports.createTrigger = exports.ITrigger = exports.WebhookHandshakeStrategy = exports.TriggerStrategy = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  var TriggerStrategy;
5
6
  (function (TriggerStrategy) {
6
7
  TriggerStrategy["POLLING"] = "POLLING";
7
8
  TriggerStrategy["WEBHOOK"] = "WEBHOOK";
8
9
  TriggerStrategy["APP_WEBHOOK"] = "APP_WEBHOOK";
9
10
  })(TriggerStrategy || (exports.TriggerStrategy = TriggerStrategy = {}));
11
+ var WebhookHandshakeStrategy;
12
+ (function (WebhookHandshakeStrategy) {
13
+ WebhookHandshakeStrategy["NONE"] = "NONE";
14
+ WebhookHandshakeStrategy["HEADER_PRESENT"] = "HEADER_PRESENT";
15
+ WebhookHandshakeStrategy["QUERY_PRESENT"] = "QUERY_PRESENT";
16
+ WebhookHandshakeStrategy["BODY_PARAM_PRESENT"] = "BODY_PARAM_PRESENT";
17
+ })(WebhookHandshakeStrategy || (exports.WebhookHandshakeStrategy = WebhookHandshakeStrategy = {}));
10
18
  class ITrigger {
11
- constructor(name, displayName, description, props, type, onEnable, onDisable, run, test, sampleData, requireAuth = true) {
19
+ constructor(name, displayName, description, props, type, handshakeConfiguration, onEnable, onHandshake, onDisable, run, test, sampleData, requireAuth = true) {
12
20
  this.name = name;
13
21
  this.displayName = displayName;
14
22
  this.description = description;
15
23
  this.props = props;
16
24
  this.type = type;
25
+ this.handshakeConfiguration = handshakeConfiguration;
17
26
  this.onEnable = onEnable;
27
+ this.onHandshake = onHandshake;
18
28
  this.onDisable = onDisable;
19
29
  this.run = run;
20
30
  this.test = test;
@@ -24,8 +34,8 @@ class ITrigger {
24
34
  }
25
35
  exports.ITrigger = ITrigger;
26
36
  const createTrigger = (params) => {
27
- var _a;
28
- return new ITrigger(params.name, params.displayName, params.description, params.props, params.type, params.onEnable, params.onDisable, params.run, (_a = params.test) !== null && _a !== void 0 ? _a : (() => Promise.resolve([params.sampleData])), params.sampleData, params.requireAuth);
37
+ var _a, _b, _c;
38
+ return new ITrigger(params.name, params.displayName, params.description, params.props, params.type, (_a = params.handshakeConfiguration) !== null && _a !== void 0 ? _a : { strategy: WebhookHandshakeStrategy.NONE }, params.onEnable, (_b = params.onHandshake) !== null && _b !== void 0 ? _b : (() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { return ({ status: 200 }); })), params.onDisable, params.run, (_c = params.test) !== null && _c !== void 0 ? _c : (() => Promise.resolve([params.sampleData])), params.sampleData, params.requireAuth);
29
39
  };
30
40
  exports.createTrigger = createTrigger;
31
41
  //# sourceMappingURL=trigger.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/trigger/trigger.ts"],"names":[],"mappings":";;;AAIA,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,8CAA2B,CAAA;AAC7B,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAwBD,MAAa,QAAQ;IAKnB,YACkB,IAAY,EACZ,WAAmB,EACnB,WAAmB,EACnB,KAAmB,EACnB,IAAQ,EACR,QAAiF,EACjF,SAAkF,EAClF,GAAiF,EACjF,IAAkF,EAC3F,UAAmB,EACV,cAAuB,IAAI;QAV3B,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,UAAK,GAAL,KAAK,CAAc;QACnB,SAAI,GAAJ,IAAI,CAAI;QACR,aAAQ,GAAR,QAAQ,CAAyE;QACjF,cAAS,GAAT,SAAS,CAAyE;QAClF,QAAG,GAAH,GAAG,CAA8E;QACjF,SAAI,GAAJ,IAAI,CAA8E;QAC3F,eAAU,GAAV,UAAU,CAAS;QACV,gBAAW,GAAX,WAAW,CAAgB;IACzC,CAAC;CACN;AAlBD,4BAkBC;AAQM,MAAM,aAAa,GAAG,CAI3B,MAAwD,EAAE,EAAE;;IAC5D,OAAO,IAAI,QAAQ,CACjB,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,SAAS,EAChB,MAAM,CAAC,GAAG,EACV,MAAA,MAAM,CAAC,IAAI,mCAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAC3D,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,WAAW,CACnB,CAAA;AACH,CAAC,CAAA;AAlBY,QAAA,aAAa,iBAkBzB"}
1
+ {"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/trigger/trigger.ts"],"names":[],"mappings":";;;;AAIA,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,8CAA2B,CAAA;AAC7B,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAED,IAAY,wBAKX;AALD,WAAY,wBAAwB;IAClC,yCAAa,CAAA;IACb,6DAAiC,CAAA;IACjC,2DAA+B,CAAA;IAC/B,qEAAyC,CAAA;AAC3C,CAAC,EALW,wBAAwB,wCAAxB,wBAAwB,QAKnC;AAqCD,MAAa,QAAQ;IAKnB,YACkB,IAAY,EACZ,WAAmB,EACnB,WAAmB,EACnB,KAAmB,EACnB,IAAQ,EACR,sBAAqD,EACrD,QAAiF,EACjF,WAA+F,EAC/F,SAAkF,EAClF,GAAiF,EACjF,IAAkF,EAC3F,UAAmB,EACV,cAAuB,IAAI;QAZ3B,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,UAAK,GAAL,KAAK,CAAc;QACnB,SAAI,GAAJ,IAAI,CAAI;QACR,2BAAsB,GAAtB,sBAAsB,CAA+B;QACrD,aAAQ,GAAR,QAAQ,CAAyE;QACjF,gBAAW,GAAX,WAAW,CAAoF;QAC/F,cAAS,GAAT,SAAS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