@activepieces/pieces-framework 0.6.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,12 +1,12 @@
1
1
  {
2
2
  "name": "@activepieces/pieces-framework",
3
- "version": "0.6.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
8
  "semver": "7.5.3",
9
- "@activepieces/shared": "0.5.5",
9
+ "@activepieces/shared": "0.5.6",
10
10
  "tslib": "1.14.1"
11
11
  },
12
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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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"}
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 {