@activepieces/pieces-framework 0.3.29 → 0.4.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/package.json +5 -6
- package/src/lib/action/action.d.ts +22 -14
- package/src/lib/action/action.js +8 -5
- package/src/lib/action/action.js.map +1 -1
- package/src/lib/context.d.ts +22 -23
- package/src/lib/context.js +1 -1
- package/src/lib/context.js.map +1 -1
- package/src/lib/piece-metadata.d.ts +8 -6
- package/src/lib/piece.d.ts +31 -43
- package/src/lib/piece.js +16 -18
- package/src/lib/piece.js.map +1 -1
- package/src/lib/property/base-prop.d.ts +13 -13
- package/src/lib/property/basic-auth-prop.d.ts +3 -3
- package/src/lib/property/custom-auth-prop.d.ts +3 -3
- package/src/lib/property/dropdown-prop.d.ts +9 -10
- package/src/lib/property/dynamic-prop.d.ts +4 -4
- package/src/lib/property/oauth2-prop.d.ts +5 -5
- package/src/lib/property/oauth2-prop.js +1 -1
- package/src/lib/property/oauth2-prop.js.map +1 -1
- package/src/lib/property/property.d.ts +26 -17
- package/src/lib/property/property.js +19 -14
- package/src/lib/property/property.js.map +1 -1
- package/src/lib/trigger/trigger.d.ts +30 -23
- package/src/lib/trigger/trigger.js +8 -6
- package/src/lib/trigger/trigger.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/pieces-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@sinclair/typebox": "0.26.
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"tslib": "2.5.3"
|
|
6
|
+
"@sinclair/typebox": "^0.26.3",
|
|
7
|
+
"nanoid": "^3.3.4",
|
|
8
|
+
"@activepieces/shared": "0.4.0",
|
|
9
|
+
"tslib": "1.14.1"
|
|
11
10
|
},
|
|
12
11
|
"main": "./src/index.js",
|
|
13
12
|
"types": "./src/index.d.ts"
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import { ActionContext } from '../context';
|
|
2
2
|
import { ActionBase } from '../piece-metadata';
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { NonAuthPiecePropertyMap, PieceAuthProperty } from '../property/property';
|
|
4
|
+
export type ActionRunner<PieceAuth extends PieceAuthProperty, ActionProps extends NonAuthPiecePropertyMap> = (ctx: ActionContext<PieceAuth, ActionProps>) => Promise<unknown | void>;
|
|
5
|
+
type CreateActionParams<PieceAuth extends PieceAuthProperty, ActionProps extends NonAuthPiecePropertyMap> = {
|
|
6
|
+
/**
|
|
7
|
+
* A dummy parameter used to infer {@code PieceAuth} type
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
auth?: PieceAuth;
|
|
11
|
+
displayName: string;
|
|
12
|
+
description: string;
|
|
13
|
+
props: ActionProps;
|
|
14
|
+
run: ActionRunner<PieceAuth, ActionProps>;
|
|
15
|
+
requireAuth?: boolean;
|
|
16
|
+
sampleData?: unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare class IAction<PieceAuth extends PieceAuthProperty, ActionProps extends NonAuthPiecePropertyMap> implements ActionBase {
|
|
5
19
|
readonly name: string;
|
|
6
20
|
readonly displayName: string;
|
|
7
21
|
readonly description: string;
|
|
8
|
-
readonly props:
|
|
9
|
-
readonly run:
|
|
22
|
+
readonly props: ActionProps;
|
|
23
|
+
readonly run: ActionRunner<PieceAuth, ActionProps>;
|
|
24
|
+
readonly requireAuth: boolean;
|
|
10
25
|
readonly sampleData: unknown;
|
|
11
|
-
constructor(name: string, displayName: string, description: string, props:
|
|
26
|
+
constructor(name: string, displayName: string, description: string, props: ActionProps, run: ActionRunner<PieceAuth, ActionProps>, requireAuth: boolean, sampleData?: unknown);
|
|
12
27
|
}
|
|
13
|
-
export
|
|
14
|
-
export declare
|
|
15
|
-
name: string;
|
|
16
|
-
displayName: string;
|
|
17
|
-
description: string;
|
|
18
|
-
props: T;
|
|
19
|
-
run: (context: ActionContext<StaticPropsValue<T>>) => Promise<unknown | void>;
|
|
20
|
-
sampleData?: unknown;
|
|
21
|
-
}): Action;
|
|
28
|
+
export type Action<PieceAuth extends PieceAuthProperty = any, ActionProps extends NonAuthPiecePropertyMap = any> = IAction<PieceAuth, ActionProps>;
|
|
29
|
+
export declare const createAction: <PieceAuth extends PieceAuthProperty = PieceAuthProperty, ActionProps extends NonAuthPiecePropertyMap = any>(params: CreateActionParams<PieceAuth, ActionProps>) => IAction<PieceAuth, ActionProps>;
|
|
22
30
|
export {};
|
package/src/lib/action/action.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAction = void 0;
|
|
3
|
+
exports.createAction = exports.IAction = void 0;
|
|
4
4
|
class IAction {
|
|
5
|
-
constructor(name, displayName, description, props, run, sampleData = {}) {
|
|
5
|
+
constructor(name, displayName, description, props, run, requireAuth, sampleData = {}) {
|
|
6
6
|
this.name = name;
|
|
7
7
|
this.displayName = displayName;
|
|
8
8
|
this.description = description;
|
|
9
9
|
this.props = props;
|
|
10
10
|
this.run = run;
|
|
11
|
+
this.requireAuth = requireAuth;
|
|
11
12
|
this.sampleData = sampleData;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
exports.IAction = IAction;
|
|
16
|
+
const createAction = (params) => {
|
|
17
|
+
var _a;
|
|
18
|
+
return new IAction(params.name, params.displayName, params.description, params.props, params.run, (_a = params.requireAuth) !== null && _a !== void 0 ? _a : true, params.sampleData);
|
|
19
|
+
};
|
|
17
20
|
exports.createAction = createAction;
|
|
18
21
|
//# sourceMappingURL=action.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/action/action.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/action/action.ts"],"names":[],"mappings":";;;AAqBA,MAAa,OAAO;IAClB,YACkB,IAAY,EACZ,WAAmB,EACnB,WAAmB,EACnB,KAAkB,EAClB,GAAyC,EACzC,WAAoB,EACpB,aAAsB,EAAE;QANxB,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,UAAK,GAAL,KAAK,CAAa;QAClB,QAAG,GAAH,GAAG,CAAsC;QACzC,gBAAW,GAAX,WAAW,CAAS;QACpB,eAAU,GAAV,UAAU,CAAc;IACtC,CAAC;CACN;AAVD,0BAUC;AAOM,MAAM,YAAY,GAAG,CAI1B,MAAkD,EAClD,EAAE;;IACF,OAAO,IAAI,OAAO,CAChB,MAAM,CAAC,IAAI,EACX,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,GAAG,EACV,MAAA,MAAM,CAAC,WAAW,mCAAI,IAAI,EAC1B,MAAM,CAAC,UAAU,CAClB,CAAA;AACH,CAAC,CAAA;AAfY,QAAA,YAAY,gBAexB"}
|
package/src/lib/context.d.ts
CHANGED
|
@@ -1,51 +1,49 @@
|
|
|
1
1
|
import { AppConnectionValue, ExecutionType, PauseMetadata, StopResponse, TriggerPayload } from "@activepieces/shared";
|
|
2
2
|
import { TriggerStrategy } from "./trigger/trigger";
|
|
3
|
-
|
|
3
|
+
import { NonAuthPiecePropertyMap, PieceAuthProperty, PiecePropValueSchema, PiecePropertyMap, StaticPropsValue } from "./property";
|
|
4
|
+
type BaseContext<PieceAuth extends PieceAuthProperty, Props extends PiecePropertyMap> = {
|
|
5
|
+
auth: PiecePropValueSchema<PieceAuth>;
|
|
6
|
+
propsValue: StaticPropsValue<Props>;
|
|
7
|
+
store: Store;
|
|
8
|
+
};
|
|
9
|
+
type AppWebhookTriggerHookContext<PieceAuth extends PieceAuthProperty, TriggerProps extends PiecePropertyMap> = BaseContext<PieceAuth, TriggerProps> & {
|
|
4
10
|
webhookUrl: string;
|
|
11
|
+
payload: TriggerPayload;
|
|
5
12
|
app: {
|
|
6
13
|
createListeners({ events, identifierValue }: {
|
|
7
14
|
events: string[];
|
|
8
15
|
identifierValue: string;
|
|
9
16
|
}): Promise<void>;
|
|
10
17
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} : S extends TriggerStrategy.POLLING ? {
|
|
14
|
-
propsValue: T;
|
|
18
|
+
};
|
|
19
|
+
type PollingTriggerHookContext<PieceAuth extends PieceAuthProperty, TriggerProps extends PiecePropertyMap> = BaseContext<PieceAuth, TriggerProps> & {
|
|
15
20
|
setSchedule(schedule: {
|
|
16
21
|
cronExpression: string;
|
|
17
22
|
timezone?: string;
|
|
18
23
|
}): void;
|
|
19
|
-
store: Store;
|
|
20
|
-
} : {
|
|
21
|
-
webhookUrl: string;
|
|
22
|
-
propsValue: T;
|
|
23
|
-
store: Store;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type WebhookTriggerHookContext<PieceAuth extends PieceAuthProperty, TriggerProps extends PiecePropertyMap> = BaseContext<PieceAuth, TriggerProps> & {
|
|
26
|
+
webhookUrl: string;
|
|
26
27
|
payload: TriggerPayload;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export declare type StopHookParams = {
|
|
28
|
+
};
|
|
29
|
+
export type TriggerHookContext<PieceAuth extends PieceAuthProperty, TriggerProps extends PiecePropertyMap, S extends TriggerStrategy> = S extends TriggerStrategy.APP_WEBHOOK ? AppWebhookTriggerHookContext<PieceAuth, TriggerProps> : S extends TriggerStrategy.POLLING ? PollingTriggerHookContext<PieceAuth, TriggerProps> : S extends TriggerStrategy.WEBHOOK ? WebhookTriggerHookContext<PieceAuth, TriggerProps> : never;
|
|
30
|
+
export type StopHookParams = {
|
|
31
31
|
response: StopResponse;
|
|
32
32
|
};
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
33
|
+
export type StopHook = (params: StopHookParams) => void;
|
|
34
|
+
export type PauseHookPauseMetadata = Omit<PauseMetadata, 'resumeStepMetadata'>;
|
|
35
|
+
export type PauseHookParams = {
|
|
36
36
|
pauseMetadata: PauseHookPauseMetadata;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
39
|
-
export
|
|
38
|
+
export type PauseHook = (params: PauseHookParams) => void;
|
|
39
|
+
export type ActionContext<PieceAuth extends PieceAuthProperty = PieceAuthProperty, ActionProps extends NonAuthPiecePropertyMap = NonAuthPiecePropertyMap> = BaseContext<PieceAuth, ActionProps> & {
|
|
40
40
|
executionType: ExecutionType;
|
|
41
|
-
propsValue: T;
|
|
42
|
-
store: Store;
|
|
43
41
|
connections: ConnectionsManager;
|
|
44
42
|
run: {
|
|
45
43
|
stop: StopHook;
|
|
46
44
|
pause: PauseHook;
|
|
47
45
|
};
|
|
48
|
-
}
|
|
46
|
+
};
|
|
49
47
|
export interface ConnectionsManager {
|
|
50
48
|
get(key: string): Promise<AppConnectionValue | Record<string, unknown> | string | null>;
|
|
51
49
|
}
|
|
@@ -58,3 +56,4 @@ export declare enum StoreScope {
|
|
|
58
56
|
PROJECT = "COLLECTION",
|
|
59
57
|
FLOW = "FLOW"
|
|
60
58
|
}
|
|
59
|
+
export {};
|
package/src/lib/context.js
CHANGED
|
@@ -6,5 +6,5 @@ var StoreScope;
|
|
|
6
6
|
// Collection were deprecated in favor of project
|
|
7
7
|
StoreScope["PROJECT"] = "COLLECTION";
|
|
8
8
|
StoreScope["FLOW"] = "FLOW";
|
|
9
|
-
})(StoreScope
|
|
9
|
+
})(StoreScope || (exports.StoreScope = StoreScope = {}));
|
|
10
10
|
//# sourceMappingURL=context.js.map
|
package/src/lib/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../packages/pieces/framework/src/lib/context.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../../../packages/pieces/framework/src/lib/context.ts"],"names":[],"mappings":";;;AAiFA,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,iDAAiD;IACjD,oCAAsB,CAAA;IACtB,2BAAa,CAAA;AACjB,CAAC,EAJW,UAAU,0BAAV,UAAU,QAIrB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProjectId } from "@activepieces/shared";
|
|
2
|
-
import { PiecePropertyMap } from "./property";
|
|
2
|
+
import { PieceAuthProperty, PiecePropertyMap } from "./property";
|
|
3
3
|
import { TriggerStrategy } from "./trigger/trigger";
|
|
4
|
-
export
|
|
4
|
+
export type PieceBase = {
|
|
5
5
|
id?: string;
|
|
6
6
|
name: string;
|
|
7
7
|
displayName: string;
|
|
@@ -9,25 +9,27 @@ export declare type PieceBase = {
|
|
|
9
9
|
description: string;
|
|
10
10
|
projectId?: ProjectId;
|
|
11
11
|
directoryName?: string;
|
|
12
|
+
auth?: PieceAuthProperty;
|
|
12
13
|
version: string;
|
|
13
14
|
minimumSupportedRelease?: string;
|
|
14
15
|
maximumSupportedRelease?: string;
|
|
15
16
|
};
|
|
16
|
-
export
|
|
17
|
+
export type ActionBase = {
|
|
17
18
|
name: string;
|
|
18
19
|
displayName: string;
|
|
19
20
|
description: string;
|
|
20
21
|
sampleData: unknown;
|
|
21
22
|
props: PiecePropertyMap;
|
|
23
|
+
requireAuth: boolean;
|
|
22
24
|
};
|
|
23
|
-
export
|
|
25
|
+
export type TriggerBase = ActionBase & {
|
|
24
26
|
type: TriggerStrategy;
|
|
25
27
|
};
|
|
26
|
-
export
|
|
28
|
+
export type PieceMetadata = PieceBase & {
|
|
27
29
|
actions: Record<string, ActionBase>;
|
|
28
30
|
triggers: Record<string, TriggerBase>;
|
|
29
31
|
};
|
|
30
|
-
export
|
|
32
|
+
export type PieceMetadataSummary = Omit<PieceMetadata, "actions" | "triggers"> & {
|
|
31
33
|
actions: number;
|
|
32
34
|
triggers: number;
|
|
33
35
|
};
|
package/src/lib/piece.d.ts
CHANGED
|
@@ -1,59 +1,47 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Trigger } from './trigger/trigger';
|
|
2
2
|
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
|
+
type CreatePieceParams<PieceAuth extends PieceAuthProperty = PieceAuthProperty> = {
|
|
7
|
+
displayName: string;
|
|
8
|
+
logoUrl: string;
|
|
9
|
+
authors?: string[];
|
|
10
|
+
description?: string;
|
|
11
|
+
auth: PieceAuth | undefined;
|
|
12
|
+
events?: PieceEventProcessors;
|
|
13
|
+
minimumSupportedRelease?: string;
|
|
14
|
+
maximumSupportedRelease?: string;
|
|
15
|
+
actions: Action<PieceAuth>[];
|
|
16
|
+
triggers: Trigger<PieceAuth>[];
|
|
17
|
+
};
|
|
18
|
+
type PieceEventProcessors = {
|
|
19
|
+
parseAndReply: (ctx: {
|
|
20
|
+
payload: EventPayload;
|
|
21
|
+
}) => ParseEventResponse;
|
|
22
|
+
verify: (ctx: {
|
|
23
|
+
webhookSecret: string;
|
|
24
|
+
payload: EventPayload;
|
|
25
|
+
appWebhookUrl: string;
|
|
26
|
+
}) => boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare class Piece<PieceAuth extends PieceAuthProperty = PieceAuthProperty> implements Omit<PieceBase, "version" | "name"> {
|
|
6
29
|
readonly displayName: string;
|
|
7
30
|
readonly logoUrl: string;
|
|
8
31
|
readonly authors: string[];
|
|
9
|
-
readonly events:
|
|
10
|
-
|
|
11
|
-
payload: EventPayload;
|
|
12
|
-
}) => ParseEventResponse;
|
|
13
|
-
verify: (ctx: {
|
|
14
|
-
webhookSecret: string;
|
|
15
|
-
payload: EventPayload;
|
|
16
|
-
appWebhookUrl: string;
|
|
17
|
-
}) => boolean;
|
|
18
|
-
} | undefined;
|
|
32
|
+
readonly events: PieceEventProcessors | undefined;
|
|
33
|
+
readonly auth?: PieceAuth | undefined;
|
|
19
34
|
readonly minimumSupportedRelease?: string | undefined;
|
|
20
35
|
readonly maximumSupportedRelease?: string | undefined;
|
|
21
36
|
readonly description: string;
|
|
22
37
|
private readonly _actions;
|
|
23
38
|
private readonly _triggers;
|
|
24
|
-
constructor(displayName: string, logoUrl: string, authors: string[], events:
|
|
25
|
-
|
|
26
|
-
payload: EventPayload;
|
|
27
|
-
}) => ParseEventResponse;
|
|
28
|
-
verify: (ctx: {
|
|
29
|
-
webhookSecret: string;
|
|
30
|
-
payload: EventPayload;
|
|
31
|
-
appWebhookUrl: string;
|
|
32
|
-
}) => boolean;
|
|
33
|
-
} | undefined, actions: Action[], triggers: Trigger[], minimumSupportedRelease?: string | undefined, maximumSupportedRelease?: string | undefined, description?: string);
|
|
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">;
|
|
34
41
|
getAction(actionName: string): Action | undefined;
|
|
35
42
|
getTrigger(triggerName: string): Trigger | undefined;
|
|
36
|
-
metadata(): Omit<PieceMetadata, "name" | "version">;
|
|
37
43
|
actions(): Record<string, Action>;
|
|
38
44
|
triggers(): Record<string, Trigger>;
|
|
39
45
|
}
|
|
40
|
-
export declare const createPiece: (
|
|
41
|
-
|
|
42
|
-
logoUrl: string;
|
|
43
|
-
authors?: string[] | undefined;
|
|
44
|
-
actions: Action[];
|
|
45
|
-
triggers: Trigger[];
|
|
46
|
-
description?: string | undefined;
|
|
47
|
-
events?: {
|
|
48
|
-
parseAndReply: (ctx: {
|
|
49
|
-
payload: EventPayload;
|
|
50
|
-
}) => ParseEventResponse;
|
|
51
|
-
verify: (ctx: {
|
|
52
|
-
webhookSecret: string;
|
|
53
|
-
payload: EventPayload;
|
|
54
|
-
appWebhookUrl: string;
|
|
55
|
-
}) => boolean;
|
|
56
|
-
} | undefined;
|
|
57
|
-
minimumSupportedRelease?: string | undefined;
|
|
58
|
-
maximumSupportedRelease?: string | undefined;
|
|
59
|
-
}) => Piece;
|
|
46
|
+
export declare const createPiece: <PieceAuth extends PieceAuthProperty>(params: CreatePieceParams<PieceAuth>) => Piece<PieceAuth>;
|
|
47
|
+
export {};
|
package/src/lib/piece.js
CHANGED
|
@@ -2,28 +2,19 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createPiece = exports.Piece = void 0;
|
|
4
4
|
class Piece {
|
|
5
|
-
constructor(displayName, logoUrl, authors, events, actions, triggers, minimumSupportedRelease, maximumSupportedRelease, description = '') {
|
|
5
|
+
constructor(displayName, logoUrl, authors, events, actions, triggers, auth, minimumSupportedRelease, maximumSupportedRelease, description = '') {
|
|
6
6
|
this.displayName = displayName;
|
|
7
7
|
this.logoUrl = logoUrl;
|
|
8
8
|
this.authors = authors;
|
|
9
9
|
this.events = events;
|
|
10
|
+
this.auth = auth;
|
|
10
11
|
this.minimumSupportedRelease = minimumSupportedRelease;
|
|
11
12
|
this.maximumSupportedRelease = maximumSupportedRelease;
|
|
12
13
|
this.description = description;
|
|
13
|
-
this._actions =
|
|
14
|
-
this._triggers =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!(actionName in this._actions)) {
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
return this._actions[actionName];
|
|
21
|
-
}
|
|
22
|
-
getTrigger(triggerName) {
|
|
23
|
-
if (!(triggerName in this._triggers)) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
return this._triggers[triggerName];
|
|
14
|
+
this._actions = {};
|
|
15
|
+
this._triggers = {};
|
|
16
|
+
actions.forEach(action => this._actions[action.name] = action);
|
|
17
|
+
triggers.forEach(trigger => this._triggers[trigger.name] = trigger);
|
|
27
18
|
}
|
|
28
19
|
metadata() {
|
|
29
20
|
return {
|
|
@@ -32,10 +23,17 @@ class Piece {
|
|
|
32
23
|
actions: this._actions,
|
|
33
24
|
triggers: this._triggers,
|
|
34
25
|
description: this.description,
|
|
26
|
+
auth: this.auth,
|
|
35
27
|
minimumSupportedRelease: this.minimumSupportedRelease,
|
|
36
28
|
maximumSupportedRelease: this.maximumSupportedRelease,
|
|
37
29
|
};
|
|
38
30
|
}
|
|
31
|
+
getAction(actionName) {
|
|
32
|
+
return this._actions[actionName];
|
|
33
|
+
}
|
|
34
|
+
getTrigger(triggerName) {
|
|
35
|
+
return this._triggers[triggerName];
|
|
36
|
+
}
|
|
39
37
|
actions() {
|
|
40
38
|
return this._actions;
|
|
41
39
|
}
|
|
@@ -44,9 +42,9 @@ class Piece {
|
|
|
44
42
|
}
|
|
45
43
|
}
|
|
46
44
|
exports.Piece = Piece;
|
|
47
|
-
const createPiece = (
|
|
48
|
-
var _a;
|
|
49
|
-
return new Piece(
|
|
45
|
+
const createPiece = (params) => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return new Piece(params.displayName, params.logoUrl, (_a = params.authors) !== null && _a !== void 0 ? _a : [], params.events, params.actions, params.triggers, (_b = params.auth) !== null && _b !== void 0 ? _b : undefined, params.minimumSupportedRelease, params.maximumSupportedRelease, params.description);
|
|
50
48
|
};
|
|
51
49
|
exports.createPiece = createPiece;
|
|
52
50
|
//# sourceMappingURL=piece.js.map
|
package/src/lib/piece.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piece.js","sourceRoot":"","sources":["../../../../../../packages/pieces/framework/src/lib/piece.ts"],"names":[],"mappings":";;;
|
|
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,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"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { PropertyType } from "./property";
|
|
2
|
-
export
|
|
2
|
+
export type BasePropertySchema = {
|
|
3
3
|
displayName: string;
|
|
4
4
|
description?: string;
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export type TPropertyValue<T, U extends PropertyType, REQUIRED extends boolean> = {
|
|
7
7
|
valueSchema: T;
|
|
8
8
|
type: U;
|
|
9
9
|
required: REQUIRED;
|
|
10
10
|
defaultValue?: U extends PropertyType.ARRAY ? unknown[] : U extends PropertyType.JSON ? object : U extends PropertyType.CHECKBOX ? boolean : U extends PropertyType.LONG_TEXT ? string : U extends PropertyType.SHORT_TEXT ? string : U extends PropertyType.NUMBER ? number : U extends PropertyType.DROPDOWN ? unknown : U extends PropertyType.MULTI_SELECT_DROPDOWN ? unknown[] : U extends PropertyType.STATIC_MULTI_SELECT_DROPDOWN ? unknown[] : U extends PropertyType.STATIC_DROPDOWN ? unknown : U extends PropertyType.DATE_TIME ? string : U extends PropertyType.FILE ? ApFile : unknown;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
12
|
+
export type ShortTextProperty<R extends boolean> = BasePropertySchema & TPropertyValue<string, PropertyType.SHORT_TEXT, R>;
|
|
13
|
+
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>;
|
|
15
|
+
export type CheckboxProperty<R extends boolean> = BasePropertySchema & TPropertyValue<boolean, PropertyType.CHECKBOX, R>;
|
|
16
|
+
export type NumberProperty<R extends boolean> = BasePropertySchema & TPropertyValue<number, PropertyType.NUMBER, R>;
|
|
17
|
+
export type ArrayProperty<R extends boolean> = BasePropertySchema & TPropertyValue<unknown[], PropertyType.ARRAY, R>;
|
|
18
|
+
export type ObjectProperty<R extends boolean> = BasePropertySchema & TPropertyValue<Record<string, unknown>, PropertyType.OBJECT, R>;
|
|
19
|
+
export type JsonProperty<R extends boolean> = BasePropertySchema & TPropertyValue<Record<string, unknown>, PropertyType.JSON, R>;
|
|
20
|
+
export type DateTimeProperty<R extends boolean> = BasePropertySchema & TPropertyValue<string, PropertyType.DATE_TIME, R>;
|
|
21
|
+
export type ApFile = {
|
|
22
22
|
filename?: string;
|
|
23
23
|
extension?: string;
|
|
24
24
|
base64: string;
|
|
25
25
|
};
|
|
26
|
-
export
|
|
26
|
+
export type FileProperty<R extends boolean> = BasePropertySchema & TPropertyValue<ApFile, PropertyType.FILE, R>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PropertyType } from "./property";
|
|
2
2
|
import { BasePropertySchema, TPropertyValue } from "./base-prop";
|
|
3
|
-
export
|
|
3
|
+
export type BasicAuthPropertySchema = BasePropertySchema & {
|
|
4
4
|
username: {
|
|
5
5
|
displayName: string;
|
|
6
6
|
description?: string;
|
|
@@ -10,8 +10,8 @@ export declare type BasicAuthPropertySchema = BasePropertySchema & {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type BasicAuthPropertyValue = {
|
|
14
14
|
username: string;
|
|
15
15
|
password: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type BasicAuthProperty<R extends boolean> = BasicAuthPropertySchema & TPropertyValue<BasicAuthPropertyValue, PropertyType.BASIC_AUTH, R>;
|
|
@@ -5,8 +5,8 @@ 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
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type CustomAuthPropertyValue<T extends CustomAuthProps> = StaticPropsValue<T>;
|
|
9
|
+
export type CustomAuthPropertySchema<T> = BasePropertySchema & {
|
|
10
10
|
props: T;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type CustomAuthProperty<R extends boolean, T extends CustomAuthProps> = CustomAuthPropertySchema<T> & TPropertyValue<CustomAuthPropertyValue<T>, PropertyType.CUSTOM_AUTH, R>;
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { PropertyType } from "./property";
|
|
2
2
|
import { BasePropertySchema, TPropertyValue } from "./base-prop";
|
|
3
|
-
|
|
4
|
-
import { OAuth2PropertyValue } from "./oauth2-prop";
|
|
5
|
-
export declare type DropdownState<T> = {
|
|
3
|
+
export type DropdownState<T> = {
|
|
6
4
|
disabled?: boolean;
|
|
7
5
|
placeholder?: string;
|
|
8
6
|
options: DropdownOption<T>[];
|
|
9
7
|
};
|
|
10
|
-
export
|
|
8
|
+
export type DropdownOption<T> = {
|
|
11
9
|
label: string;
|
|
12
10
|
value: T;
|
|
13
11
|
};
|
|
14
|
-
export
|
|
12
|
+
export type DynamicDropdownOptions<T> = (propsValue: Record<string, unknown>) => Promise<DropdownState<T>>;
|
|
13
|
+
export type DropdownProperty<T, R extends boolean> = BasePropertySchema & {
|
|
15
14
|
refreshers: string[];
|
|
16
|
-
options:
|
|
15
|
+
options: DynamicDropdownOptions<T>;
|
|
17
16
|
} & TPropertyValue<T, PropertyType.DROPDOWN, R>;
|
|
18
|
-
export
|
|
17
|
+
export type StaticDropdownProperty<T, R extends boolean> = BasePropertySchema & {
|
|
19
18
|
options: DropdownState<T>;
|
|
20
19
|
} & TPropertyValue<T, PropertyType.STATIC_DROPDOWN, R>;
|
|
21
|
-
export
|
|
20
|
+
export type MultiSelectDropdownProperty<T, R extends boolean> = BasePropertySchema & {
|
|
22
21
|
refreshers: string[];
|
|
23
|
-
options:
|
|
22
|
+
options: DynamicDropdownOptions<T>;
|
|
24
23
|
} & TPropertyValue<T[], PropertyType.MULTI_SELECT_DROPDOWN, R>;
|
|
25
|
-
export
|
|
24
|
+
export type StaticMultiSelectDropdownProperty<T, R extends boolean> = BasePropertySchema & {
|
|
26
25
|
options: DropdownState<T>;
|
|
27
26
|
} & TPropertyValue<T[], PropertyType.STATIC_MULTI_SELECT_DROPDOWN, R>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PropertyType } from "./property";
|
|
2
2
|
import { BasePropertySchema, ShortTextProperty, TPropertyValue } from "./base-prop";
|
|
3
3
|
import { StaticDropdownProperty, StaticMultiSelectDropdownProperty } from "./dropdown-prop";
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
4
|
+
type DynamicProp = ShortTextProperty<boolean> | StaticDropdownProperty<any, boolean> | StaticMultiSelectDropdownProperty<any, boolean>;
|
|
5
|
+
export type DynamicPropsValue = Record<string, DynamicProp['valueSchema']>;
|
|
6
|
+
export type DynamicPropsSchema = BasePropertySchema & {
|
|
7
7
|
props: (propsValue: Record<string, DynamicPropsValue>) => Promise<Record<string, DynamicProp>>;
|
|
8
8
|
refreshers: string[];
|
|
9
9
|
};
|
|
10
|
-
export
|
|
10
|
+
export type DynamicProperties<R extends boolean> = DynamicPropsSchema & TPropertyValue<DynamicPropsValue, PropertyType.DYNAMIC, R>;
|
|
11
11
|
export {};
|
|
@@ -2,12 +2,12 @@ import { PropertyType } from "./property";
|
|
|
2
2
|
import { BasePropertySchema, 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>;
|
|
6
6
|
export interface OAuth2Props {
|
|
7
7
|
[name: string]: ShortTextProperty<boolean> | SecretTextProperty<boolean> | StaticDropdownProperty<unknown, boolean>;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
export
|
|
9
|
+
export type OAuthPropsValue<T extends OAuth2Props> = StaticPropsValue<T>;
|
|
10
|
+
export type OAuth2PropertySchema = BasePropertySchema & {
|
|
11
11
|
props?: Record<string, OAuthProp>;
|
|
12
12
|
authUrl: string;
|
|
13
13
|
tokenUrl: string;
|
|
@@ -16,12 +16,12 @@ export declare type OAuth2PropertySchema = BasePropertySchema & {
|
|
|
16
16
|
authorizationMethod?: OAuth2AuthorizationMethod;
|
|
17
17
|
extra?: Record<string, unknown>;
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type OAuth2PropertyValue<T extends OAuth2Props = any> = {
|
|
20
20
|
access_token: string;
|
|
21
21
|
props?: OAuthPropsValue<T>;
|
|
22
22
|
data: Record<string, any>;
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type OAuth2Property<R extends boolean, T extends OAuth2Props> = OAuth2PropertySchema & TPropertyValue<OAuth2PropertyValue<T>, PropertyType.OAUTH2, R>;
|
|
25
25
|
export declare enum OAuth2AuthorizationMethod {
|
|
26
26
|
HEADER = "HEADER",
|
|
27
27
|
BODY = "BODY"
|
|
@@ -5,5 +5,5 @@ var OAuth2AuthorizationMethod;
|
|
|
5
5
|
(function (OAuth2AuthorizationMethod) {
|
|
6
6
|
OAuth2AuthorizationMethod["HEADER"] = "HEADER";
|
|
7
7
|
OAuth2AuthorizationMethod["BODY"] = "BODY";
|
|
8
|
-
})(OAuth2AuthorizationMethod
|
|
8
|
+
})(OAuth2AuthorizationMethod || (exports.OAuth2AuthorizationMethod = OAuth2AuthorizationMethod = {}));
|
|
9
9
|
//# sourceMappingURL=oauth2-prop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2-prop.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/property/oauth2-prop.ts"],"names":[],"mappings":";;;AAoCA,IAAY,yBAGX;AAHD,WAAY,yBAAyB;IACpC,8CAAiB,CAAA;IACjB,0CAAa,CAAA;AACd,CAAC,EAHW,yBAAyB,
|
|
1
|
+
{"version":3,"file":"oauth2-prop.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/property/oauth2-prop.ts"],"names":[],"mappings":";;;AAoCA,IAAY,yBAGX;AAHD,WAAY,yBAAyB;IACpC,8CAAiB,CAAA;IACjB,0CAAa,CAAA;AACd,CAAC,EAHW,yBAAyB,yCAAzB,yBAAyB,QAGpC"}
|
|
@@ -24,14 +24,20 @@ export declare enum PropertyType {
|
|
|
24
24
|
DATE_TIME = "DATE_TIME",
|
|
25
25
|
FILE = "FILE"
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type PieceAuthProperty = BasicAuthProperty<boolean> | CustomAuthProperty<boolean, CustomAuthProps> | OAuth2Property<boolean, OAuth2Props> | SecretTextProperty<boolean>;
|
|
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
|
+
export type PieceProperty = NonAuthPieceProperty | PieceAuthProperty;
|
|
28
30
|
export interface PiecePropertyMap {
|
|
29
31
|
[name: string]: PieceProperty;
|
|
30
32
|
}
|
|
31
|
-
export
|
|
32
|
-
[
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
export interface NonAuthPiecePropertyMap {
|
|
34
|
+
[name: string]: NonAuthPieceProperty;
|
|
35
|
+
}
|
|
36
|
+
export type PiecePropValueSchema<T extends PieceProperty | PieceAuthProperty> = T extends undefined ? undefined : T extends {
|
|
37
|
+
required: true;
|
|
38
|
+
} ? T['valueSchema'] : T['valueSchema'] | undefined;
|
|
39
|
+
export type StaticPropsValue<T extends PiecePropertyMap> = {
|
|
40
|
+
[P in keyof T]: PiecePropValueSchema<T[P]>;
|
|
35
41
|
};
|
|
36
42
|
export declare const Property: {
|
|
37
43
|
ShortText<R extends boolean>(request: Properties<ShortTextProperty<R>>): R extends true ? ShortTextProperty<true> : ShortTextProperty<false>;
|
|
@@ -41,17 +47,20 @@ export declare const Property: {
|
|
|
41
47
|
Json<R_4 extends boolean>(request: Properties<JsonProperty<R_4>>): R_4 extends true ? JsonProperty<true> : JsonProperty<false>;
|
|
42
48
|
Array<R_5 extends boolean>(request: Properties<ArrayProperty<R_5>>): R_5 extends true ? ArrayProperty<true> : ArrayProperty<false>;
|
|
43
49
|
Object<R_6 extends boolean>(request: Properties<ObjectProperty<R_6>>): R_6 extends true ? ObjectProperty<true> : ObjectProperty<false>;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
Dropdown<T, R_7 extends boolean = boolean>(request: Properties<DropdownProperty<T, R_7>>): R_7 extends true ? DropdownProperty<T, true> : DropdownProperty<T, false>;
|
|
51
|
+
StaticDropdown<T_1, R_8 extends boolean = boolean>(request: Properties<StaticDropdownProperty<T_1, R_8>>): R_8 extends true ? StaticDropdownProperty<T_1, true> : StaticDropdownProperty<T_1, false>;
|
|
52
|
+
MultiSelectDropdown<T_2, R_9 extends boolean = boolean>(request: Properties<MultiSelectDropdownProperty<T_2, R_9>>): R_9 extends true ? MultiSelectDropdownProperty<T_2, true> : MultiSelectDropdownProperty<T_2, false>;
|
|
53
|
+
DynamicProperties<R_10 extends boolean = boolean>(request: Properties<DynamicProperties<R_10>>): R_10 extends true ? DynamicProperties<true> : DynamicProperties<false>;
|
|
54
|
+
StaticMultiSelectDropdown<T_3, R_11 extends boolean = boolean>(request: Properties<StaticMultiSelectDropdownProperty<T_3, R_11>>): R_11 extends true ? StaticMultiSelectDropdownProperty<T_3, true> : StaticMultiSelectDropdownProperty<T_3, false>;
|
|
55
|
+
DateTime<R_12 extends boolean>(request: Properties<DateTimeProperty<R_12>>): R_12 extends true ? DateTimeProperty<true> : DateTimeProperty<false>;
|
|
56
|
+
File<R_13 extends boolean>(request: Properties<FileProperty<R_13>>): R_13 extends true ? FileProperty<true> : FileProperty<false>;
|
|
57
|
+
};
|
|
58
|
+
export declare const PieceAuth: {
|
|
59
|
+
SecretText<R extends boolean>(request: Properties<SecretTextProperty<R>>): R extends true ? SecretTextProperty<true> : SecretTextProperty<false>;
|
|
60
|
+
BasicAuth<R_1 extends boolean>(request: Properties<BasicAuthProperty<R_1>>): R_1 extends true ? BasicAuthProperty<true> : BasicAuthProperty<false>;
|
|
61
|
+
CustomAuth<R_2 extends boolean, T extends CustomAuthProps>(request: Properties<CustomAuthProperty<R_2, T>>): R_2 extends true ? CustomAuthProperty<true, T> : CustomAuthProperty<false, T>;
|
|
62
|
+
OAuth2<R_3 extends boolean, T_1 extends OAuth2Props>(request: Properties<OAuth2Property<R_3, T_1>>): R_3 extends true ? OAuth2Property<true, T_1> : OAuth2Property<false, T_1>;
|
|
63
|
+
None(): undefined;
|
|
55
64
|
};
|
|
56
|
-
|
|
65
|
+
type Properties<T> = Omit<T, "valueSchema" | "type">;
|
|
57
66
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Property = exports.PropertyType = void 0;
|
|
3
|
+
exports.PieceAuth = exports.Property = exports.PropertyType = void 0;
|
|
4
4
|
var PropertyType;
|
|
5
5
|
(function (PropertyType) {
|
|
6
6
|
PropertyType["SHORT_TEXT"] = "SHORT_TEXT";
|
|
@@ -21,7 +21,7 @@ var PropertyType;
|
|
|
21
21
|
PropertyType["CUSTOM_AUTH"] = "CUSTOM_AUTH";
|
|
22
22
|
PropertyType["DATE_TIME"] = "DATE_TIME";
|
|
23
23
|
PropertyType["FILE"] = "FILE";
|
|
24
|
-
})(PropertyType
|
|
24
|
+
})(PropertyType || (exports.PropertyType = PropertyType = {}));
|
|
25
25
|
exports.Property = {
|
|
26
26
|
ShortText(request) {
|
|
27
27
|
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.SHORT_TEXT });
|
|
@@ -44,18 +44,6 @@ exports.Property = {
|
|
|
44
44
|
Object(request) {
|
|
45
45
|
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.OBJECT });
|
|
46
46
|
},
|
|
47
|
-
SecretText(request) {
|
|
48
|
-
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.SECRET_TEXT });
|
|
49
|
-
},
|
|
50
|
-
BasicAuth(request) {
|
|
51
|
-
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.BASIC_AUTH });
|
|
52
|
-
},
|
|
53
|
-
CustomAuth(request) {
|
|
54
|
-
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.CUSTOM_AUTH });
|
|
55
|
-
},
|
|
56
|
-
OAuth2(request) {
|
|
57
|
-
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.OAUTH2 });
|
|
58
|
-
},
|
|
59
47
|
Dropdown(request) {
|
|
60
48
|
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.DROPDOWN });
|
|
61
49
|
},
|
|
@@ -78,4 +66,21 @@ exports.Property = {
|
|
|
78
66
|
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.FILE });
|
|
79
67
|
},
|
|
80
68
|
};
|
|
69
|
+
exports.PieceAuth = {
|
|
70
|
+
SecretText(request) {
|
|
71
|
+
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.SECRET_TEXT });
|
|
72
|
+
},
|
|
73
|
+
BasicAuth(request) {
|
|
74
|
+
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.BASIC_AUTH });
|
|
75
|
+
},
|
|
76
|
+
CustomAuth(request) {
|
|
77
|
+
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.CUSTOM_AUTH });
|
|
78
|
+
},
|
|
79
|
+
OAuth2(request) {
|
|
80
|
+
return Object.assign(Object.assign({}, request), { valueSchema: undefined, type: PropertyType.OAUTH2 });
|
|
81
|
+
},
|
|
82
|
+
None() {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
81
86
|
//# sourceMappingURL=property.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/property/property.ts"],"names":[],"mappings":";;;AAkBA,IAAY,YAmBX;AAnBD,WAAY,YAAY;IACvB,yCAAyB,CAAA;IACzB,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,mDAAmC,CAAA;IACnC,iCAAiB,CAAA;IACjB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,2CAA2B,CAAA;IAC3B,+BAAe,CAAA;IACf,iCAAiB,CAAA;IACjB,yCAAyB,CAAA;IACzB,6BAAa,CAAA;IACb,+DAA+C,CAAA;IAC/C,6EAA6D,CAAA;IAC7D,mCAAmB,CAAA;IACnB,2CAA2B,CAAA;IAC3B,uCAAuB,CAAA;IACvB,6BAAa,CAAA;AACd,CAAC,EAnBW,YAAY,
|
|
1
|
+
{"version":3,"file":"property.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/framework/src/lib/property/property.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,35 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TriggerHookContext } from '../context';
|
|
2
2
|
import { TriggerBase } from '../piece-metadata';
|
|
3
|
-
import {
|
|
3
|
+
import { NonAuthPiecePropertyMap, PieceAuthProperty } from '../property/property';
|
|
4
4
|
export declare enum TriggerStrategy {
|
|
5
5
|
POLLING = "POLLING",
|
|
6
6
|
WEBHOOK = "WEBHOOK",
|
|
7
7
|
APP_WEBHOOK = "APP_WEBHOOK"
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
type CreateTriggerParams<PieceAuth extends PieceAuthProperty, TriggerProps extends NonAuthPiecePropertyMap, TS extends TriggerStrategy> = {
|
|
10
|
+
/**
|
|
11
|
+
* A dummy parameter used to infer {@code PieceAuth} type
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
displayName: string;
|
|
15
|
+
description: string;
|
|
16
|
+
auth?: PieceAuth;
|
|
17
|
+
props: TriggerProps;
|
|
18
|
+
type: TS;
|
|
19
|
+
onEnable: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
|
|
20
|
+
onDisable: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
|
|
21
|
+
run: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
|
|
22
|
+
test?: (context: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
|
|
23
|
+
requireAuth?: boolean;
|
|
24
|
+
sampleData: unknown;
|
|
25
|
+
};
|
|
26
|
+
export declare class ITrigger<TS extends TriggerStrategy, PieceAuth extends PieceAuthProperty, TriggerProps extends NonAuthPiecePropertyMap> implements TriggerBase {
|
|
10
27
|
readonly name: string;
|
|
11
28
|
readonly displayName: string;
|
|
12
29
|
readonly description: string;
|
|
13
|
-
readonly props:
|
|
14
|
-
readonly type:
|
|
15
|
-
readonly onEnable: (ctx: TriggerHookContext<
|
|
16
|
-
readonly onDisable: (ctx: TriggerHookContext<
|
|
17
|
-
readonly run: (ctx:
|
|
18
|
-
readonly test: (ctx:
|
|
30
|
+
readonly props: TriggerProps;
|
|
31
|
+
readonly type: TS;
|
|
32
|
+
readonly onEnable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
|
|
33
|
+
readonly onDisable: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<void>;
|
|
34
|
+
readonly run: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
|
|
35
|
+
readonly test: (ctx: TriggerHookContext<PieceAuth, TriggerProps, TS>) => Promise<unknown[]>;
|
|
19
36
|
sampleData: unknown;
|
|
20
|
-
|
|
37
|
+
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);
|
|
21
39
|
}
|
|
22
|
-
export
|
|
23
|
-
export declare
|
|
24
|
-
name: string;
|
|
25
|
-
displayName: string;
|
|
26
|
-
description: string;
|
|
27
|
-
props: T;
|
|
28
|
-
type: S;
|
|
29
|
-
onEnable: (context: TriggerHookContext<StaticPropsValue<T>, S>) => Promise<void>;
|
|
30
|
-
onDisable: (context: TriggerHookContext<StaticPropsValue<T>, S>) => Promise<void>;
|
|
31
|
-
run: (context: TriggerContext<StaticPropsValue<T>>) => Promise<unknown[]>;
|
|
32
|
-
test?: (context: TriggerContext<StaticPropsValue<T>>) => Promise<unknown[]>;
|
|
33
|
-
sampleData: unknown | ((context: TriggerContext<StaticPropsValue<T>>) => Promise<unknown>);
|
|
34
|
-
}): Trigger;
|
|
40
|
+
export type Trigger<PieceAuth extends PieceAuthProperty = any, TriggerProps extends NonAuthPiecePropertyMap = any, S extends TriggerStrategy = TriggerStrategy> = ITrigger<S, PieceAuth, TriggerProps>;
|
|
41
|
+
export declare const createTrigger: <TS extends TriggerStrategy, PieceAuth extends PieceAuthProperty, TriggerProps extends NonAuthPiecePropertyMap>(params: CreateTriggerParams<PieceAuth, TriggerProps, TS>) => ITrigger<TS, PieceAuth, TriggerProps>;
|
|
35
42
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTrigger = exports.TriggerStrategy = void 0;
|
|
3
|
+
exports.createTrigger = exports.ITrigger = exports.TriggerStrategy = void 0;
|
|
4
4
|
var TriggerStrategy;
|
|
5
5
|
(function (TriggerStrategy) {
|
|
6
6
|
TriggerStrategy["POLLING"] = "POLLING";
|
|
7
7
|
TriggerStrategy["WEBHOOK"] = "WEBHOOK";
|
|
8
8
|
TriggerStrategy["APP_WEBHOOK"] = "APP_WEBHOOK";
|
|
9
|
-
})(TriggerStrategy
|
|
9
|
+
})(TriggerStrategy || (exports.TriggerStrategy = TriggerStrategy = {}));
|
|
10
10
|
class ITrigger {
|
|
11
|
-
constructor(name, displayName, description, props, type, onEnable, onDisable, run, test, sampleData) {
|
|
11
|
+
constructor(name, displayName, description, props, type, onEnable, onDisable, run, test, sampleData, requireAuth = true) {
|
|
12
12
|
this.name = name;
|
|
13
13
|
this.displayName = displayName;
|
|
14
14
|
this.description = description;
|
|
@@ -19,11 +19,13 @@ class ITrigger {
|
|
|
19
19
|
this.run = run;
|
|
20
20
|
this.test = test;
|
|
21
21
|
this.sampleData = sampleData;
|
|
22
|
+
this.requireAuth = requireAuth;
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
exports.ITrigger = ITrigger;
|
|
26
|
+
const createTrigger = (params) => {
|
|
25
27
|
var _a;
|
|
26
|
-
return new ITrigger(
|
|
27
|
-
}
|
|
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);
|
|
29
|
+
};
|
|
28
30
|
exports.createTrigger = createTrigger;
|
|
29
31
|
//# 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,
|
|
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"}
|