feat(google-drive): add new files in folder trigger

This commit is contained in:
Rıdvan Akca
2023-03-28 21:28:58 +03:00
parent fce20263ea
commit e2c75a2daf
6 changed files with 109 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
import { IGlobalVariable } from '@automatisch/types';
const newFilesInFolder = async ($: IGlobalVariable) => {
const params = {
pageToken: undefined as unknown as string,
orderBy: 'createdTime desc',
q: `'${$.step.parameters.folderId}' in parents`,
fields: '*',
pageSize: 1000,
};
do {
const { data } = await $.http.get(`/v3/files`, { params });
params.pageToken = data.nextPageToken;
if (data.files?.length) {
for (const file of data.files) {
$.pushTriggerItem({
raw: file,
meta: {
internalId: file.id,
},
});
}
}
} while (params.pageToken);
};
export default newFilesInFolder;