Merge pull request #1039 from automatisch/list-shared-drives-for-new-files
feat(google-drive): list shared drives for new files trigger
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import listFolders from './list-folders';
|
||||
import listDrives from './list-drives';
|
||||
|
||||
export default [listFolders];
|
||||
export default [listFolders, listDrives];
|
||||
|
@@ -0,0 +1,35 @@
|
||||
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default {
|
||||
name: 'List drives',
|
||||
key: 'listDrives',
|
||||
|
||||
async run($: IGlobalVariable) {
|
||||
const drives: {
|
||||
data: IJSONObject[];
|
||||
} = {
|
||||
data: [{ value: null, name: 'My Google Drive' }],
|
||||
};
|
||||
|
||||
const params = {
|
||||
pageSize: 100,
|
||||
pageToken: undefined as unknown as string,
|
||||
};
|
||||
|
||||
do {
|
||||
const { data } = await $.http.get(`/v3/drives`, { params });
|
||||
params.pageToken = data.nextPageToken;
|
||||
|
||||
if (data.drives) {
|
||||
for (const drive of data.drives) {
|
||||
drives.data.push({
|
||||
value: drive.id,
|
||||
name: drive.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.pageToken);
|
||||
|
||||
return drives;
|
||||
},
|
||||
};
|
@@ -6,6 +6,27 @@ export default defineTrigger({
|
||||
key: 'newFiles',
|
||||
pollInterval: 15,
|
||||
description: 'Triggers when any new file is added (inside of any folder).',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Drive',
|
||||
key: 'driveId',
|
||||
type: 'dropdown' as const,
|
||||
required: false,
|
||||
description:
|
||||
'The drive to use. If nothing is selected, then your personal Google Drive will be used.',
|
||||
variables: false,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listDrives',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
await newFiles($);
|
||||
|
@@ -7,6 +7,7 @@ const newFiles = async ($: IGlobalVariable) => {
|
||||
q: `mimeType!='application/vnd.google-apps.folder'`,
|
||||
fields: '*',
|
||||
pageSize: 1000,
|
||||
driveId: $.step.parameters.driveId,
|
||||
};
|
||||
|
||||
do {
|
||||
|
Reference in New Issue
Block a user