AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, OAuth2PropertyValue, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { oneDriveAuth } from '../auth';
import { GraphDriveItem, oneDriveApi } from '../common/graph-api';
import { onedriveListBundlesOutputSchema } from '../output-schemas';
export const onedriveListBundles = createAction({
auth: oneDriveAuth,
name: 'onedrive_list_bundles',
displayName: 'List Albums and Bundles',
description: 'List the photo albums and file bundles in a personal OneDrive.',
audience: 'ai',
outputSchema: onedriveListBundlesOutputSchema,
classification: 'SEARCH',
aiMetadata: {
description:
'List the bundles in the user\'s drive, meaning photo albums and multi-file share sets, with each bundle\'s ID and item count, one page per call. Use it to find a bundle ID for Add Item to Bundle or Remove Item from Bundle. Works only on personal OneDrive (Microsoft account); OneDrive for Business has no bundles. Read-only and safe to retry.',
idempotent: true,
},
props: {
pageToken: Property.ShortText({
displayName: 'Page Token',
description: 'nextPageToken from the previous call. Empty for the first page.',
required: false,
}),
},
async run(context) {
const { pageToken } = context.propsValue;
await assertPersonalDrive({ auth: context.auth });
const token = pageToken?.trim();
const response = await oneDriveApi.request<GraphBundlePage>({
auth: context.auth,
method: HttpMethod.GET,
path: token ? token : '/me/drive/bundles',
});
const items = response.value.map((bundle) => ({
...oneDriveApi.toItem(bundle),
bundleChildCount: bundle.bundle?.childCount ?? null,
isAlbum: bundle.bundle?.album !== undefined && bundle.bundle?.album !== null,
}));
return {
items,
count: items.length,
nextPageToken: response['@odata.nextLink'] ?? null,
};
},
});
async function assertPersonalDrive({ auth }: { auth: OAuth2PropertyValue }): Promise<void> {
const drive = await oneDriveApi.request<{ driveType?: string }>({
auth,
method: HttpMethod.GET,
path: '/me/drive',
queryParams: { $select: 'driveType' },
});
if (drive.driveType !== 'personal') {
throw new Error('Albums and bundles are available only on personal OneDrive (Microsoft account) drives. This connection uses OneDrive for Business.');
}
}
type GraphBundle = GraphDriveItem & {
bundle?: { childCount?: number; album?: Record<string, unknown> | null };
};
type GraphBundlePage = {
value: GraphBundle[];
'@odata.nextLink'?: string;
};