feat(google-sheets): add new spreadsheets trigger
This commit is contained in:
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
@@ -11,7 +11,7 @@ export default {
|
|||||||
type: 'string' as const,
|
type: 'string' as const,
|
||||||
required: true,
|
required: true,
|
||||||
readOnly: true,
|
readOnly: true,
|
||||||
value: '{WEB_APP_URL}/app/google-sheet/connections/add',
|
value: '{WEB_APP_URL}/app/google-sheets/connections/add',
|
||||||
placeholder: null,
|
placeholder: null,
|
||||||
description:
|
description:
|
||||||
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
'When asked to input a redirect URL in Google Cloud, enter the URL above.',
|
@@ -0,0 +1,3 @@
|
|||||||
|
import listDrives from './list-drives';
|
||||||
|
|
||||||
|
export default [listDrives];
|
@@ -0,0 +1,38 @@
|
|||||||
|
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(
|
||||||
|
`https://www.googleapis.com/drive/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;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,16 +1,20 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
import defineApp from '../../helpers/define-app';
|
||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
|
import triggers from './triggers';
|
||||||
|
import dynamicData from './dynamic-data';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Google Sheet',
|
name: 'Google Sheets',
|
||||||
key: 'google-sheet',
|
key: 'google-sheets',
|
||||||
baseUrl: 'https://docs.google.com/spreadsheets',
|
baseUrl: 'https://docs.google.com/spreadsheets',
|
||||||
apiBaseUrl: 'https://sheets.googleapis.com',
|
apiBaseUrl: 'https://sheets.googleapis.com',
|
||||||
iconUrl: '{BASE_URL}/apps/google-sheet/assets/favicon.svg',
|
iconUrl: '{BASE_URL}/apps/google-sheets/assets/favicon.svg',
|
||||||
authDocUrl: 'https://automatisch.io/docs/apps/google-sheet/connection',
|
authDocUrl: 'https://automatisch.io/docs/apps/google-sheets/connection',
|
||||||
primaryColor: '0F9D58',
|
primaryColor: '0F9D58',
|
||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
triggers,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
@@ -0,0 +1,3 @@
|
|||||||
|
import newSpreadsheets from './new-spreadsheets';
|
||||||
|
|
||||||
|
export default [newSpreadsheets];
|
@@ -0,0 +1,33 @@
|
|||||||
|
import defineTrigger from '../../../../helpers/define-trigger';
|
||||||
|
import newSpreadsheets from './new-spreadsheets'
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New Spreadsheets',
|
||||||
|
key: 'newSpreadsheets',
|
||||||
|
pollInterval: 15,
|
||||||
|
description: 'Triggers when you create a new spreadsheet.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Drive',
|
||||||
|
key: 'driveId',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description: 'The Google Drive where your spreadsheet resides. 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 newSpreadsheets($);
|
||||||
|
},
|
||||||
|
});
|
@@ -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;
|
@@ -69,7 +69,7 @@ function ControlledAutocomplete(
|
|||||||
},
|
},
|
||||||
fieldState,
|
fieldState,
|
||||||
}) => (
|
}) => (
|
||||||
<div style={{ width:'100%' }}>
|
<div style={{ width: '100%' }}>
|
||||||
{/* encapsulated with an element such as div to vertical spacing delegated from parent */}
|
{/* encapsulated with an element such as div to vertical spacing delegated from parent */}
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
{...autocompleteProps}
|
{...autocompleteProps}
|
||||||
@@ -102,7 +102,7 @@ function ControlledAutocomplete(
|
|||||||
renderOption={(optionProps, option) => (
|
renderOption={(optionProps, option) => (
|
||||||
<li
|
<li
|
||||||
{...optionProps}
|
{...optionProps}
|
||||||
key={option.value.toString()}
|
key={option.value?.toString()}
|
||||||
style={{ flexDirection: 'column', alignItems: 'start' }}
|
style={{ flexDirection: 'column', alignItems: 'start' }}
|
||||||
>
|
>
|
||||||
<Typography>{option.label}</Typography>
|
<Typography>{option.label}</Typography>
|
||||||
|
Reference in New Issue
Block a user