Skip to content

Commit 49a1c46

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pr/Sanket6652/8614
2 parents e7fa823 + eb1a0a1 commit 49a1c46

30 files changed

Lines changed: 3718 additions & 12 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name": "@activepieces/piece-google-drive",
3-
"version": "0.5.42"
3+
"version": "0.5.43"
44
}

packages/pieces/community/google-drive/src/lib/action/add-permission.action.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Property, createAction } from "@activepieces/pieces-framework";
22
import { googleDriveAuth } from "../../";
33
import { google } from 'googleapis';
44
import { OAuth2Client } from 'googleapis-common';
5+
import { common } from "../common";
56

67
export const addPermission = createAction({
78
auth: googleDriveAuth,
@@ -49,16 +50,16 @@ export const addPermission = createAction({
4950
]
5051
}
5152
}),
53+
include_team_drives: common.properties.include_team_drives,
5254
send_invitation_email: Property.Checkbox({
5355
displayName: 'Send invitation email',
5456
description: 'Send an email to the user to notify them of the new permissions',
5557
required: true,
5658
}),
57-
5859
},
5960

6061
async run(context) {
61-
const [fileId, user_email, permission_name, send_invitation_email] = [context.propsValue.fileId, context.propsValue.user_email, context.propsValue.permission_name, context.propsValue.send_invitation_email];
62+
const {fileId, user_email, permission_name, send_invitation_email,include_team_drives} = context.propsValue;
6263

6364
const authClient = new OAuth2Client();
6465
authClient.setCredentials(context.auth)
@@ -70,7 +71,8 @@ export const addPermission = createAction({
7071
const result = await drive.permissions.create({
7172
requestBody: permission,
7273
fileId: fileId,
73-
sendNotificationEmail: send_invitation_email
74+
sendNotificationEmail: send_invitation_email,
75+
supportsAllDrives: include_team_drives,
7476
});
7577

7678
return result.data;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# pieces-podio
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Building
6+
7+
Run `nx build pieces-podio` to build the library.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@activepieces/piece-podio",
3+
"version": "0.0.1",
4+
"type": "commonjs",
5+
"main": "./src/index.js",
6+
"types": "./src/index.d.ts",
7+
"dependencies": {
8+
"tslib": "^2.3.0"
9+
}
10+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "pieces-podio",
3+
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "packages/pieces/community/podio/src",
5+
"projectType": "library",
6+
"release": {
7+
"version": {
8+
"manifestRootsToUpdate": [
9+
"dist/{projectRoot}"
10+
],
11+
"currentVersionResolver": "git-tag",
12+
"fallbackCurrentVersionResolver": "disk"
13+
}
14+
},
15+
"tags": [],
16+
"targets": {
17+
"build": {
18+
"executor": "@nx/js:tsc",
19+
"outputs": [
20+
"{options.outputPath}"
21+
],
22+
"options": {
23+
"outputPath": "dist/packages/pieces/community/podio",
24+
"tsConfig": "packages/pieces/community/podio/tsconfig.lib.json",
25+
"packageJson": "packages/pieces/community/podio/package.json",
26+
"main": "packages/pieces/community/podio/src/index.ts",
27+
"assets": [
28+
"packages/pieces/community/podio/*.md",
29+
{
30+
"input": "packages/pieces/community/podio/src/i18n",
31+
"output": "./src/i18n",
32+
"glob": "**/!(i18n.json)"
33+
}
34+
],
35+
"buildableProjectDepsInPackageJsonType": "dependencies",
36+
"updateBuildableProjectDepsInPackageJson": true
37+
}
38+
},
39+
"nx-release-publish": {
40+
"options": {
41+
"packageRoot": "dist/{projectRoot}"
42+
}
43+
},
44+
"lint": {
45+
"executor": "@nx/eslint:lint",
46+
"outputs": [
47+
"{options.outputFile}"
48+
]
49+
}
50+
}
51+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { createPiece, PieceAuth } from "@activepieces/pieces-framework";
2+
import { createCustomApiCallAction, HttpMethod } from '@activepieces/pieces-common';
3+
import { createItemAction } from './lib/actions/create-item';
4+
import { updateItemAction } from './lib/actions/update-item';
5+
import { createTaskAction } from './lib/actions/create-task';
6+
import { updateTaskAction } from './lib/actions/update-task';
7+
import { attachFileAction } from './lib/actions/attach-file';
8+
import { createCommentAction } from './lib/actions/create-comment';
9+
import { createStatusAction } from './lib/actions/create-status';
10+
import { findItemAction } from './lib/actions/find-item';
11+
import { findTaskAction } from './lib/actions/find-task';
12+
import { newItemTrigger } from './lib/triggers/new-item';
13+
import { newTaskTrigger } from './lib/triggers/new-task';
14+
import { newActivityTrigger } from './lib/triggers/new-activity';
15+
import { itemUpdatedTrigger } from './lib/triggers/item-updated';
16+
import { newOrganizationTrigger } from './lib/triggers/new-organization';
17+
import { newWorkspaceTrigger } from './lib/triggers/new-workspace';
18+
import { podioApiCall, validateAuthData } from './lib/common';
19+
20+
export const podioAuth = PieceAuth.OAuth2({
21+
description: "Connect your Podio account to automate workspace management and item operations.",
22+
authUrl: 'https://podio.com/oauth/authorize',
23+
tokenUrl: 'https://podio.com/oauth/token',
24+
required: true,
25+
scope: ['global:read', 'global:write'],
26+
validate: async ({ auth }) => {
27+
try {
28+
const validation = validateAuthData(auth);
29+
if (!validation.valid) {
30+
return { valid: false, error: validation.error || 'Authentication validation failed' };
31+
}
32+
33+
const response = await podioApiCall({
34+
method: HttpMethod.GET,
35+
accessToken: auth.access_token,
36+
resourceUri: '/user/status',
37+
});
38+
39+
if (response && typeof response === 'object') {
40+
return { valid: true };
41+
}
42+
43+
return { valid: false, error: 'Failed to validate connection with Podio API' };
44+
} catch (error: any) {
45+
if (error.response?.status === 401) {
46+
return { valid: false, error: 'Invalid or expired access token. Please reconnect your Podio account.' };
47+
}
48+
49+
if (error.response?.status === 403) {
50+
return { valid: false, error: 'Access denied. Please check your Podio permissions.' };
51+
}
52+
53+
return {
54+
valid: false,
55+
error: `Connection validation failed: ${error.message || 'Unknown error occurred'}`
56+
};
57+
}
58+
},
59+
});
60+
61+
export const podio = createPiece({
62+
displayName: "Podio",
63+
auth: podioAuth,
64+
minimumSupportedRelease: '0.36.1',
65+
logoUrl: "https://cdn.activepieces.com/pieces/podio.png",
66+
authors: ["sparkybug", "onyedikachi-david"],
67+
actions: [
68+
createItemAction,
69+
updateItemAction,
70+
createTaskAction,
71+
updateTaskAction,
72+
attachFileAction,
73+
createCommentAction,
74+
createStatusAction,
75+
findItemAction,
76+
findTaskAction,
77+
createCustomApiCallAction({
78+
baseUrl: () => 'https://api.podio.com',
79+
auth: podioAuth,
80+
authMapping: async (auth: any) => ({
81+
Authorization: `Bearer ${auth.access_token}`,
82+
}),
83+
}),
84+
],
85+
triggers: [
86+
newItemTrigger,
87+
newTaskTrigger,
88+
newActivityTrigger,
89+
itemUpdatedTrigger,
90+
newOrganizationTrigger,
91+
newWorkspaceTrigger,
92+
],
93+
});
94+
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { createAction, Property } from '@activepieces/pieces-framework';
2+
import { HttpMethod } from '@activepieces/pieces-common';
3+
import { podioAuth } from '../../index';
4+
import { podioApiCall, getAccessToken, silentProperty, dynamicRefTypeProperty, dynamicRefIdProperty, dynamicAppProperty, dynamicSpaceProperty, dynamicOrgProperty, dynamicFileProperty } from '../common';
5+
6+
export const attachFileAction = createAction({
7+
auth: podioAuth,
8+
name: 'attach_file',
9+
displayName: 'Attach File',
10+
description: 'Upload and attach a file to an item/task/comment.',
11+
props: {
12+
orgId: dynamicOrgProperty,
13+
spaceId: dynamicSpaceProperty,
14+
appId: dynamicAppProperty,
15+
16+
fileId: dynamicFileProperty,
17+
18+
refType: Property.Dropdown({
19+
displayName: 'Attach To',
20+
description: 'What type of object to attach the file to',
21+
required: true,
22+
refreshers: [],
23+
options: async () => {
24+
return {
25+
options: [
26+
{ label: 'Item', value: 'item' },
27+
{ label: 'Task', value: 'task' },
28+
{ label: 'Status Update', value: 'status' },
29+
{ label: 'Comment', value: 'comment' },
30+
{ label: 'Space', value: 'space' },
31+
],
32+
};
33+
},
34+
}),
35+
refId: dynamicRefIdProperty,
36+
37+
silent: silentProperty,
38+
},
39+
async run(context) {
40+
const accessToken = getAccessToken(context.auth);
41+
const { fileId, orgId, spaceId, appId, refType, refId, silent } = context.propsValue;
42+
43+
if (!spaceId) {
44+
throw new Error('Space selection is required to load and attach files. Please select a space first.');
45+
}
46+
47+
if (!fileId) {
48+
throw new Error('File selection is required. Please select a file from the dropdown.');
49+
}
50+
51+
if (!refType) {
52+
throw new Error('Attach To selection is required. Please choose what type of object to attach the file to.');
53+
}
54+
55+
if (!refId) {
56+
throw new Error('Reference Object is required. Please select the specific object to attach the file to.');
57+
}
58+
59+
if (refType === 'item' && !appId) {
60+
throw new Error('App selection is required when attaching files to items. Please select an app first.');
61+
}
62+
63+
if ((refType === 'status' || refType === 'task') && !spaceId) {
64+
throw new Error('Space selection is required when attaching files to status updates or tasks. Please select a space first.');
65+
}
66+
67+
const body = {
68+
ref_type: refType,
69+
ref_id: refId,
70+
};
71+
72+
const queryParams: any = {};
73+
if (typeof silent === 'boolean') {
74+
queryParams.silent = silent.toString();
75+
}
76+
77+
const response = await podioApiCall<{
78+
file_id: number;
79+
}>({
80+
method: HttpMethod.POST,
81+
accessToken,
82+
resourceUri: `/file/${fileId}/attach`,
83+
body,
84+
queryParams,
85+
});
86+
87+
return response;
88+
},
89+
});

0 commit comments

Comments
 (0)