feat(google-sheets): add new spreadsheets trigger

This commit is contained in:
Rıdvan Akca
2023-04-04 16:25:38 +03:00
parent f88f05cd46
commit 287f299b94
17 changed files with 121 additions and 7 deletions

View File

@@ -0,0 +1,33 @@
import { IGlobalVariable } from '@automatisch/types';
const newSpreadsheets = async ($: IGlobalVariable) => {
const params = {
pageToken: undefined as unknown as string,
orderBy: 'createdTime desc',
q: `mimeType='application/vnd.google-apps.spreadsheet'`,
fields: '*',
pageSize: 1000,
driveId: $.step.parameters.driveId,
};
do {
const { data } = await $.http.get(
'https://www.googleapis.com/drive/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 newSpreadsheets;