import {
getState,
setState,
} from "https://deno.land/x/windmill@v1.85.0/mod.ts";
import { drive } from "npm:@googleapis/drive@4";
const PAGE_SIZE = 500 as const;
/**
* @returns A list of newly uploaded files in ascending order
* of creation date.
* Maximum number of returned items is set to `500` for each run.
*/
type Gdrive = {
token: string;
};
export async function main(auth: Gdrive) {
const client = drive({
version: "v3",
headers: {
Authorization: `Bearer ${auth.token}`,
},
});
const lastCheck = await getState();
await setState(new Date().toISOString());
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: "createdTime asc",
pageSize: PAGE_SIZE,
});
if (response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: "createdTime",
});
const date = lastItem?.data?.createdTime;
if (date) {
await setState(date);
}
}
return response.data.files;
}
Submitted by admin 497 days ago
import { getState, setState } from "https://deno.land/x/windmill@v1.85.0/mod.ts"
import { drive } from "npm:@googleapis/drive@4"
const PAGE_SIZE = 500 as const
/**
* @returns A list of newly uploaded files in ascending order
* of creation date.
* Maximum number of returned items is set to `500` for each run.
*/
type Gdrive = {
token: string;
};
export async function main(
auth: Gdrive
) {
const client = drive({
version: 'v3',
headers: {
Authorization: `Bearer ${auth.token}`
}
})
const lastCheck = await getState()
await setState(new Date().toISOString())
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: 'createdTime asc',
pageSize: PAGE_SIZE,
})
if(response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: 'createdTime'
})
const date = lastItem?.data?.createdTime
if(date) {
await setState(date)
}
}
return response.data.files
}
Submitted by admin 500 days ago
import { getState, Resource, setState } from "https://deno.land/x/windmill@v1.85.0/mod.ts"
import { drive } from "npm:@googleapis/drive@4"
const PAGE_SIZE = 500 as const
/**
* @returns A list of newly uploaded files in ascending order
* of creation date.
* Maximum number of returned items is set to `500` for each run.
*/
export async function main(
auth: Resource<'gdrive'>
) {
const client = drive({
version: 'v3',
headers: {
Authorization: `Bearer ${auth.token}`
}
})
const lastCheck = await getState()
await setState(new Date().toISOString())
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: 'createdTime asc',
pageSize: PAGE_SIZE,
})
if(response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: 'createdTime'
})
const date = lastItem?.data?.createdTime
if(date) {
await setState(date)
}
}
return response.data.files
}
Submitted by adam186 628 days ago
import { getState, Resource, setState } from "https://deno.land/x/windmill@v1.70.1/mod.ts"
import { drive } from "npm:@googleapis/drive@4"
const PAGE_SIZE = 500 as const
/**
* @returns A list of newly uploaded files in ascending order
* of creation date.
* Maximum number of returned items is set to `500` for each run.
*/
export async function main(
auth: Resource<'gdrive'>
) {
const client = drive({
version: 'v3',
headers: {
Authorization: `Bearer ${auth.token}`
}
})
const lastCheck = await getState()
await setState(new Date().toISOString())
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: 'createdTime asc',
pageSize: PAGE_SIZE,
})
if(response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: 'createdTime'
})
const date = lastItem?.data?.createdTime
if(date) {
await setState(date)
}
}
return response.data.files
}
Submitted by adam186 663 days ago
import { getState, Resource, setState } from "https://deno.land/x/windmill@v1.55.0/mod.ts"
import { drive } from "npm:@googleapis/drive@4"
const PAGE_SIZE = 500 as const
/**
* @returns A list of newly uploaded files in ascending order
* of creation date.
* Maximum number of returned items is set to `500` for each run.
*/
export async function main(
auth: Resource<'gdrive'>
) {
const client = drive({
version: 'v3',
headers: {
Authorization: `Bearer ${auth.token}`
}
})
const lastCheck = await getState()
await setState(new Date().toISOString())
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: 'createdTime asc',
pageSize: PAGE_SIZE,
})
if(response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: 'createdTime'
})
const date = lastItem?.data?.createdTime
if(date) {
await setState(date)
}
}
return response.data.files
}
Submitted by adam186 733 days ago
import { getState, Resource, setState } from "https://deno.land/x/windmill@v1.55.0/mod.ts"
import { drive } from "npm:@googleapis/drive@4"
const PAGE_SIZE = 500 as const
/**
* @returns A list of newly uploaded files.
* Maximum number of returned items is set to `500`
* for each run.
*/
export async function main(
auth: Resource<'gdrive'>
) {
const client = drive({
version: 'v3',
headers: {
Authorization: `Bearer ${auth.token}`
}
})
const lastCheck = await getState()
await setState(new Date().toISOString())
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: 'createdTime asc',
pageSize: PAGE_SIZE,
})
if(response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: 'createdTime'
})
const date = lastItem?.data?.createdTime
if(date) {
await setState(date)
}
}
return response.data.files
}
Submitted by adam186 733 days ago
import { getState, Resource, setState } from "https://deno.land/x/windmill@v1.55.0/mod.ts"
import { drive } from "npm:@googleapis/drive@4"
const PAGE_SIZE = 500 as const
/**
* @returns A list of newly uploaded files.
* Maximum number of returned items is set to `500`
* for each run.
*/
export async function main(
auth: Resource<'gdrive'>
) {
const client = drive({
version: 'v3',
headers: {
Authorization: `Bearer ${auth.token}`
}
})
const lastCheck = await getState()
await setState(new Date().toISOString())
const response = await client.files.list({
q: lastCheck ? `createdTime > '${lastCheck}'` : undefined,
orderBy: 'createdTime asc',
pageSize: PAGE_SIZE,
})
if(response.data.nextPageToken && response?.data?.files?.at(-1)) {
const lastItem = await client.files.get({
fileId: response.data.files.at(-1)?.id || undefined,
fields: 'createdTime'
})
await setState(lastItem.data.createdTime || '')
}
return response.data.files
}
Submitted by adam186 733 days ago