Skip to content

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

feat(microsoft-365-planner): let AI agents manage plans, buckets, tasks and assignees (#16720)

Kishan Parmar930c8cc54cef
diff --git a/bun.lock b/bun.lock
index 9afdc49a008..400b8946dde 100644
--- a/bun.lock
+++ b/bun.lock
@@ -5871,7 +5871,7 @@
},
"packages/pieces/community/microsoft-365-planner": {
"name": "@activepieces/piece-microsoft-365-planner",
- "version": "0.3.2",
+ "version": "0.4.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/microsoft-365-planner/package.json b/packages/pieces/community/microsoft-365-planner/package.json
index f135790f5dd..4ea5de4c25c 100644
--- a/packages/pieces/community/microsoft-365-planner/package.json
+++ b/packages/pieces/community/microsoft-365-planner/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-microsoft-365-planner",
- "version": "0.3.2",
+ "version": "0.4.0",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/microsoft-365-planner/src/i18n/translation.json b/packages/pieces/community/microsoft-365-planner/src/i18n/translation.json
index 73fa3ea9486..9f9b93ebd05 100644
--- a/packages/pieces/community/microsoft-365-planner/src/i18n/translation.json
+++ b/packages/pieces/community/microsoft-365-planner/src/i18n/translation.json
@@ -4,7 +4,7 @@
"Select your Microsoft cloud environment.": "Select your Microsoft cloud environment.",
"Commercial (Global)": "Commercial (Global)",
"US Government (GCC High)": "US Government (GCC High)",
- "\nIf you'd like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),\n set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:\n - Group.Read.All\n - Tasks.ReadWrite\n - User.Read": "\nIf you'd like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),\n set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:\n - Group.Read.All\n - Tasks.ReadWrite\n - User.Read",
+ "\nIf you'd like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),\n set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:\n - Group.Read.All\n - Tasks.ReadWrite\n - User.Read\n - User.ReadBasic.All": "\nIf you'd like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),\n set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:\n - Group.Read.All\n - Tasks.ReadWrite\n - User.Read\n - User.ReadBasic.All",
"Create Plan": "Create Plan",
"Create Bucket": "Create Bucket",
"Create Task": "Create Task",
@@ -16,6 +16,26 @@
"Find a Plan": "Find a Plan",
"Get a Bucket": "Get a Bucket",
"Find Task": "Find Task",
+ "List Plans": "List Plans",
+ "Get Plan": "Get Plan",
+ "Delete Plan": "Delete Plan",
+ "Get Plan Details": "Get Plan Details",
+ "Update Plan Details": "Update Plan Details",
+ "List Buckets": "List Buckets",
+ "Get Bucket": "Get Bucket",
+ "List Plan Tasks": "List Plan Tasks",
+ "List Bucket Tasks": "List Bucket Tasks",
+ "List My Tasks": "List My Tasks",
+ "Get Task": "Get Task",
+ "Complete Task": "Complete Task",
+ "Assign Task": "Assign Task",
+ "Move Task": "Move Task",
+ "Get Task Details": "Get Task Details",
+ "Update Task Details": "Update Task Details",
+ "Get Current User": "Get Current User",
+ "List Groups": "List Groups",
+ "List Group Members": "List Group Members",
+ "List Users": "List Users",
"Custom API Call": "Custom API Call",
"Create a new planner plan": "Create a new planner plan",
"Create a bucket (category) under a plan.": "Create a bucket (category) under a plan.",
@@ -28,6 +48,34 @@
"Finds a plan by field.": "Finds a plan by field.",
"Retrieve details about a specific bucket.": "Retrieve details about a specific bucket.",
"Find task by fields.": "Find task by fields.",
+ "Lists your Planner plans, or the plans of a group.": "Lists your Planner plans, or the plans of a group.",
+ "Gets a Planner plan by ID.": "Gets a Planner plan by ID.",
+ "Creates a Planner plan owned by a Microsoft 365 group.": "Creates a Planner plan owned by a Microsoft 365 group.",
+ "Renames a Planner plan.": "Renames a Planner plan.",
+ "Permanently deletes a Planner plan.": "Permanently deletes a Planner plan.",
+ "Gets a plan’s category labels and sharing.": "Gets a plan’s category labels and sharing.",
+ "Renames a plan’s label categories.": "Renames a plan’s label categories.",
+ "Lists the buckets of a Planner plan.": "Lists the buckets of a Planner plan.",
+ "Gets a Planner bucket by ID.": "Gets a Planner bucket by ID.",
+ "Creates a bucket in a Planner plan.": "Creates a bucket in a Planner plan.",
+ "Renames or reorders a Planner bucket.": "Renames or reorders a Planner bucket.",
+ "Permanently deletes a Planner bucket.": "Permanently deletes a Planner bucket.",
+ "Lists the tasks of a Planner plan.": "Lists the tasks of a Planner plan.",
+ "Lists the tasks in a Planner bucket.": "Lists the tasks in a Planner bucket.",
+ "Lists the Planner tasks assigned to you.": "Lists the Planner tasks assigned to you.",
+ "Gets a Planner task by ID.": "Gets a Planner task by ID.",
+ "Creates a task in a Planner plan.": "Creates a task in a Planner plan.",
+ "Updates fields of a Planner task.": "Updates fields of a Planner task.",
+ "Marks a Planner task as completed.": "Marks a Planner task as completed.",
+ "Assigns users to a Planner task.": "Assigns users to a Planner task.",
+ "Moves a Planner task to another bucket.": "Moves a Planner task to another bucket.",
+ "Permanently deletes a Planner task.": "Permanently deletes a Planner task.",
+ "Gets a task’s description, checklist and links.": "Gets a task’s description, checklist and links.",
+ "Edits a task’s description, checklist and links.": "Edits a task’s description, checklist and links.",
+ "Gets the signed-in Microsoft 365 user.": "Gets the signed-in Microsoft 365 user.",
+ "Lists the Microsoft 365 groups that can own plans.": "Lists the Microsoft 365 groups that can own plans.",
+ "Lists the users in a Microsoft 365 group.": "Lists the users in a Microsoft 365 group.",
+ "Lists or finds users in your organization.": "Lists or finds users in your organization.",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Group": "Group",
"Title": "Title",
@@ -42,6 +90,31 @@
"Start Date": "Start Date",
"Task": "Task",
"Name": "Name",
+ "Group ID": "Group ID",
+ "Title Contains": "Title Contains",
+ "Plan ID": "Plan ID",
+ "Category Labels": "Category Labels",
+ "Bucket ID": "Bucket ID",
+ "Task ID": "Task ID",
+ "Assignee IDs": "Assignee IDs",
+ "Label Categories": "Label Categories",
+ "Assign User IDs": "Assign User IDs",
+ "Unassign User IDs": "Unassign User IDs",
+ "Clear Due Date": "Clear Due Date",
+ "Clear Start Date": "Clear Start Date",
+ "Add Label Categories": "Add Label Categories",
+ "Remove Label Categories": "Remove Label Categories",
+ "User IDs": "User IDs",
+ "Description": "Description",
+ "Add Checklist Items": "Add Checklist Items",
+ "Check Checklist Item IDs": "Check Checklist Item IDs",
+ "Uncheck Checklist Item IDs": "Uncheck Checklist Item IDs",
+ "Remove Checklist Item IDs": "Remove Checklist Item IDs",
+ "Add Links": "Add Links",
+ "Remove Link URLs": "Remove Link URLs",
+ "Limit": "Limit",
+ "Cursor": "Cursor",
+ "Starts With": "Starts With",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
@@ -69,6 +142,53 @@
"The new title of the task": "The new title of the task",
"The title of the plan to search for": "The title of the plan to search for",
"The title of the task to search for": "The title of the task to search for",
+ "Only list the plans of this Microsoft 365 group (from List Groups). Leave empty for every plan shared with you.": "Only list the plans of this Microsoft 365 group (from List Groups). Leave empty for every plan shared with you.",
+ "Only return plans whose title contains this text (case-insensitive).": "Only return plans whose title contains this text (case-insensitive).",
+ "Planner plan ID. Use List Plans to find it.": "Planner plan ID. Use List Plans to find it.",
+ "ID (GUID) of a Microsoft 365 group. Use List Groups to find it.": "ID (GUID) of a Microsoft 365 group. Use List Groups to find it.",
+ "Title of the new plan.": "Title of the new plan.",
+ "New title of the plan.": "New title of the plan.",
+ "Object mapping category keys (category1 to category25) to label names, e.g. {\"category1\": \"Urgent\", \"category2\": null}. null removes a label name.": "Object mapping category keys (category1 to category25) to label names, e.g. {\"category1\": \"Urgent\", \"category2\": null}. null removes a label name.",
+ "Planner bucket ID. Use List Buckets to find it.": "Planner bucket ID. Use List Buckets to find it.",
+ "Name of the new bucket.": "Name of the new bucket.",
+ "Optional Planner order hint that positions the bucket, e.g. \" !\" to put it first. Leave empty to add it at the end.": "Optional Planner order hint that positions the bucket, e.g. \" !\" to put it first. Leave empty to add it at the end.",
+ "New name of the bucket.": "New name of the bucket.",
+ "New Planner order hint, e.g. \" !\" to move it first.": "New Planner order hint, e.g. \" !\" to move it first.",
+ "Only return tasks whose title contains this text (case-insensitive).": "Only return tasks whose title contains this text (case-insensitive).",
+ "Planner task ID. Use List Plan Tasks, List Bucket Tasks or List My Tasks to find it.": "Planner task ID. Use List Plan Tasks, List Bucket Tasks or List My Tasks to find it.",
+ "Title of the new task.": "Title of the new task.",
+ "Bucket to put the task in (from List Buckets). Leave empty for the plan’s default placement.": "Bucket to put the task in (from List Buckets). Leave empty for the plan’s default placement.",
+ "User IDs to assign the task to (from List Group Members or Get Current User).": "User IDs to assign the task to (from List Group Members or Get Current User).",
+ "Due date and time, ISO 8601 (e.g. 2026-11-01T17:00:00Z).": "Due date and time, ISO 8601 (e.g. 2026-11-01T17:00:00Z).",
+ "Start date and time, ISO 8601.": "Start date and time, ISO 8601.",
+ "Progress from 0 to 100. Planner shows 0 as not started, 1–99 as in progress and 100 as completed.": "Progress from 0 to 100. Planner shows 0 as not started, 1–99 as in progress and 100 as completed.",
+ "Priority from 0 (highest) to 10 (lowest). Planner shows 1 as urgent, 3 as important, 5 as medium and 9 as low.": "Priority from 0 (highest) to 10 (lowest). Planner shows 1 as urgent, 3 as important, 5 as medium and 9 as low.",
+ "Label categories to apply, e.g. [\"category1\", \"category4\"]. Get Plan Details shows each category’s name.": "Label categories to apply, e.g. [\"category1\", \"category4\"]. Get Plan Details shows each category’s name.",
+ "New title.": "New title.",
+ "Move the task to this bucket of the same plan.": "Move the task to this bucket of the same plan.",
+ "User IDs to add as assignees (existing assignees stay). From List Group Members or Get Current User.": "User IDs to add as assignees (existing assignees stay). From List Group Members or Get Current User.",
+ "User IDs to remove from the assignees.": "User IDs to remove from the assignees.",
+ "New due date and time, ISO 8601.": "New due date and time, ISO 8601.",
+ "Remove the due date. Cannot be combined with Due Date.": "Remove the due date. Cannot be combined with Due Date.",
+ "New start date and time, ISO 8601.": "New start date and time, ISO 8601.",
+ "Remove the start date. Cannot be combined with Start Date.": "Remove the start date. Cannot be combined with Start Date.",
+ "Progress from 0 to 100; 100 marks the task completed.": "Progress from 0 to 100; 100 marks the task completed.",
+ "Label categories to apply, e.g. [\"category1\"].": "Label categories to apply, e.g. [\"category1\"].",
+ "Label categories to remove, e.g. [\"category2\"].": "Label categories to remove, e.g. [\"category2\"].",
+ "User IDs (GUIDs). Use List Group Members or Get Current User to find them.": "User IDs (GUIDs). Use List Group Members or Get Current User to find them.",
+ "Bucket of the same plan to move the task to (from List Buckets).": "Bucket of the same plan to move the task to (from List Buckets).",
+ "New description (replaces the current one).": "New description (replaces the current one).",
+ "Titles of checklist items to add, unchecked.": "Titles of checklist items to add, unchecked.",
+ "Checklist item IDs (from Get Task Details) to mark done.": "Checklist item IDs (from Get Task Details) to mark done.",
+ "Checklist item IDs to mark not done.": "Checklist item IDs to mark not done.",
+ "Checklist item IDs to delete.": "Checklist item IDs to delete.",
+ "Links to attach to the task.": "Links to attach to the task.",
+ "URLs of attached links to remove, exactly as attached.": "URLs of attached links to remove, exactly as attached.",
+ "Groups per page, 1 to 999. Defaults to 100.": "Groups per page, 1 to 999. Defaults to 100.",
+ "Next Cursor from the previous page. Leave empty for the first page.": "Next Cursor from the previous page. Leave empty for the first page.",
+ "Members per page, 1 to 999. Defaults to 100.": "Members per page, 1 to 999. Defaults to 100.",
+ "Only return users whose display name, email or user principal name starts with this text (case-insensitive), e.g. \"ada\" or \"[email protected]\".": "Only return users whose display name, email or user principal name starts with this text (case-insensitive), e.g. \"ada\" or \"[email protected]\".",
+ "Users per page, 1 to 999. Defaults to 100.": "Users per page, 1 to 999. Defaults to 100.",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",
"Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",
@@ -81,6 +201,8 @@
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD",
+ "Request": "Request",
+ "Data to send": "Data to send",
"New Plan Created": "New Plan Created",
"New Task Created": "New Task Created",
"New Task Assigned to User": "New Task Assigned to User",
diff --git a/packages/pieces/community/microsoft-365-planner/src/index.ts b/packages/pieces/community/microsoft-365-planner/src/index.ts
index 6a2608d4ae7..4e8079bba05 100644
--- a/packages/pieces/community/microsoft-365-planner/src/index.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/index.ts
@@ -1,58 +1,56 @@
-import { createPiece, OAuth2PropertyValue } from '@activepieces/pieces-framework';
-import { createBucket } from './lib/actions/create-bucket';
-import { createPlan } from './lib/actions/create-plan';
-import { createTask } from './lib/actions/create-task';
-import { deleteBucket } from './lib/actions/delete-bucket';
-import { deleteTask } from './lib/actions/delete-task';
-import { findAPlan } from './lib/actions/find-a-plan';
-import { findTask } from './lib/actions/find-task';
-import { getABucket } from './lib/actions/get-a-bucket';
-import { updateBucket } from './lib/actions/update-bucket';
-import { updatePlan } from './lib/actions/update-plan';
-import { updateTask } from './lib/actions/update-task';
-import { microsoft365PlannerAuth } from './lib/common';
-import { newPlanCreated } from './lib/triggers/new-plan-created';
-import { newTaskAssignedToUser } from './lib/triggers/new-task-assigned-to-user';
-import { newTaskCreated } from './lib/triggers/new-task-created';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
-import { getGraphBaseUrl, getMicrosoftCloudFromAuth } from './lib/common/microsoft-cloud';
+import { createPiece } from '@activepieces/pieces-framework';
+import { microsoft365PlannerAiActions } from './lib/actions/ai';
+import { createBucketAction } from './lib/actions/create-bucket';
+import { createPlanAction } from './lib/actions/create-plan';
+import { createTaskAction } from './lib/actions/create-task';
+import { deleteBucketAction } from './lib/actions/delete-bucket';
+import { deleteTaskAction } from './lib/actions/delete-task';
+import { findAPlanAction } from './lib/actions/find-a-plan';
+import { findTaskAction } from './lib/actions/find-task';
+import { getABucketAction } from './lib/actions/get-a-bucket';
+import { updateBucketAction } from './lib/actions/update-bucket';
+import { updatePlanAction } from './lib/actions/update-plan';
+import { updateTaskAction } from './lib/actions/update-task';
+import { microsoft365PlannerAuth } from './lib/auth';
+import { microsoft365PlannerClient } from './lib/common/client';
+import { newPlanCreatedTrigger } from './lib/triggers/new-plan-created';
+import { newTaskAssignedToUserTrigger } from './lib/triggers/new-task-assigned-to-user';
+import { newTaskCreatedTrigger } from './lib/triggers/new-task-created';
export const microsoft365Planner = createPiece({
displayName: 'Microsoft 365 Planner',
description:
'Microsoft 365 Planner is part of the Microsoft 365 suite, offering lightweight task and bucket-based planning for teams. This integration supports creating plans, buckets, tasks, fetching them, deleting them, and custom API calls.',
auth: microsoft365PlannerAuth,
- minimumSupportedRelease: '0.36.1',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/microsoft-365-planner.png',
- authors: ['LuizDMM','sanket-a11y'],
+ authors: ['LuizDMM', 'sanket-a11y'],
actions: [
- // Write Actions
- createPlan,
- createBucket,
- createTask,
- deleteBucket,
- deleteTask,
- updatePlan,
- updateBucket,
- updateTask,
- // Search Actions
- findAPlan,
- getABucket,
- findTask,
+ createPlanAction,
+ createBucketAction,
+ createTaskAction,
+ deleteBucketAction,
+ deleteTaskAction,
+ updatePlanAction,
+ updateBucketAction,
+ updateTaskAction,
+ findAPlanAction,
+ getABucketAction,
+ findTaskAction,
+ ...microsoft365PlannerAiActions,
createCustomApiCallAction({
- auth: microsoft365PlannerAuth,
- baseUrl: (auth) => {
- const cloud = getMicrosoftCloudFromAuth(auth as OAuth2PropertyValue);
- return getGraphBaseUrl(cloud) + '/v1.0/';
- },
- authMapping: async (auth) => ({
- Authorization: `Bearer ${(auth as OAuth2PropertyValue).access_token}`,
- }),
- }),
+ auth: microsoft365PlannerAuth,
+ baseUrl: (auth) =>
+ auth ? `${microsoft365PlannerClient.baseUrl({ auth })}/v1.0/` : '',
+ authMapping: async (auth) => ({
+ Authorization: `Bearer ${auth.access_token}`,
+ }),
+ }),
],
triggers: [
- newPlanCreated,
- newTaskCreated,
- newTaskAssignedToUser,
+ newPlanCreatedTrigger,
+ newTaskCreatedTrigger,
+ newTaskAssignedToUserTrigger,
],
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/assign-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/assign-task.ts
new file mode 100644
index 00000000000..4ef84bd9933
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/assign-task.ts
@@ -0,0 +1,42 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerUtils } from '../../common/utils';
+import { microsoft365PlannerTaskOutputSchema } from '../../output-schemas';
+
+export const assignTaskAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_assign_task',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
+ displayName: 'Assign Task',
+ description: 'Assigns users to a Planner task.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds users (IDs from List Group Members or Get Current User) as assignees of a Planner task and returns the updated task. Existing assignees stay; to remove someone use Update Task.',
+ idempotent: true,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ userIds: microsoft365PlannerAiProps.userIds({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const userIds = microsoft365PlannerUtils.stringIds({
+ value: propsValue.userIds,
+ propName: 'User IDs',
+ });
+ if (userIds.length === 0) {
+ throw new Error('User IDs must contain at least one user ID.');
+ }
+ return await microsoft365PlannerApi.patchTask({
+ auth,
+ taskId: propsValue.taskId,
+ fields: {
+ assignments: microsoft365PlannerUtils.assignmentsFor({ userIds }),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/complete-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/complete-task.ts
new file mode 100644
index 00000000000..88cd4768b53
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/complete-task.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskOutputSchema } from '../../output-schemas';
+
+export const completeTaskAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_complete_task',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
+ displayName: 'Complete Task',
+ description: 'Marks a Planner task as completed.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Marks a Planner task completed (sets percent complete to 100) and returns the updated task. To reopen a task, use Update Task with a lower percent complete.',
+ idempotent: true,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.patchTask({
+ auth,
+ taskId: propsValue.taskId,
+ fields: { percentComplete: 100 },
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-bucket.ts
new file mode 100644
index 00000000000..af6c8a5cc09
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-bucket.ts
@@ -0,0 +1,43 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerBucketOutputSchema } from '../../output-schemas';
+
+export const createBucketAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_create_bucket',
+ outputSchema: microsoft365PlannerBucketOutputSchema,
+ displayName: 'Create Bucket',
+ description: 'Creates a bucket in a Planner plan.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a new bucket (column) in a Planner plan (Plan ID from List Plans). Each call creates another bucket, even with the same name.',
+ idempotent: false,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'Name of the new bucket.',
+ required: true,
+ }),
+ orderHint: Property.ShortText({
+ displayName: 'Order Hint',
+ description:
+ 'Optional Planner order hint that positions the bucket, e.g. " !" to put it first. Leave empty to add it at the end.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.createBucket({
+ auth,
+ planId: propsValue.planId,
+ name: propsValue.name,
+ orderHint: propsValue.orderHint,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-plan.ts
new file mode 100644
index 00000000000..d55fd61114b
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-plan.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerPlanOutputSchema } from '../../output-schemas';
+
+export const createPlanAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_create_plan',
+ outputSchema: microsoft365PlannerPlanOutputSchema,
+ displayName: 'Create Plan',
+ description: 'Creates a Planner plan owned by a Microsoft 365 group.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a new Planner plan owned by a Microsoft 365 group (Group ID from List Groups). The signed-in user must be a member of the group. Each call creates another plan.',
+ idempotent: false,
+ },
+ props: {
+ groupId: microsoft365PlannerAiProps.groupId({ required: true }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Title of the new plan.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.createPlan({
+ auth,
+ groupId: propsValue.groupId,
+ title: propsValue.title,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-task.ts
new file mode 100644
index 00000000000..3b783fc965e
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/create-task.ts
@@ -0,0 +1,113 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerUtils } from '../../common/utils';
+import { microsoft365PlannerTaskOutputSchema } from '../../output-schemas';
+
+export const createTaskAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_create_task',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
+ displayName: 'Create Task',
+ description: 'Creates a task in a Planner plan.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a new task in a Planner plan (Plan ID from List Plans), optionally in a bucket (from List Buckets), assigned to users (from List Group Members), with dates, priority, percent complete and label categories. Each call creates another task. Set the description and checklist afterwards with Update Task Details.',
+ idempotent: false,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Title of the new task.',
+ required: true,
+ }),
+ bucketId: microsoft365PlannerAiProps.bucketId({
+ required: false,
+ description:
+ 'Bucket to put the task in (from List Buckets). Leave empty for the plan’s default placement.',
+ }),
+ assigneeIds: microsoft365PlannerAiProps.userIds({
+ required: false,
+ displayName: 'Assignee IDs',
+ description:
+ 'User IDs to assign the task to (from List Group Members or Get Current User).',
+ }),
+ dueDateTime: Property.DateTime({
+ displayName: 'Due Date',
+ description: 'Due date and time, ISO 8601 (e.g. 2026-11-01T17:00:00Z).',
+ required: false,
+ }),
+ startDateTime: Property.DateTime({
+ displayName: 'Start Date',
+ description: 'Start date and time, ISO 8601.',
+ required: false,
+ }),
+ percentComplete: Property.Number({
+ displayName: 'Percent Complete',
+ description:
+ 'Progress from 0 to 100. Planner shows 0 as not started, 1–99 as in progress and 100 as completed.',
+ required: false,
+ }),
+ priority: Property.Number({
+ displayName: 'Priority',
+ description:
+ 'Priority from 0 (highest) to 10 (lowest). Planner shows 1 as urgent, 3 as important, 5 as medium and 9 as low.',
+ required: false,
+ }),
+ categories: Property.Array({
+ displayName: 'Label Categories',
+ description:
+ 'Label categories to apply, e.g. ["category1", "category4"]. Get Plan Details shows each category’s name.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const assigneeIds = microsoft365PlannerUtils.stringIds({
+ value: propsValue.assigneeIds,
+ propName: 'Assignee IDs',
+ });
+ const categories = microsoft365PlannerUtils.stringIds({
+ value: propsValue.categories,
+ propName: 'Label Categories',
+ });
+ return await microsoft365PlannerApi.createTask({
+ auth,
+ planId: propsValue.planId,
+ title: propsValue.title,
+ ...(propsValue.bucketId !== undefined
+ ? { bucketId: propsValue.bucketId }
+ : {}),
+ ...(assigneeIds.length > 0
+ ? {
+ assignments: microsoft365PlannerUtils.assignmentsFor({
+ userIds: assigneeIds,
+ }),
+ }
+ : {}),
+ ...(propsValue.dueDateTime !== undefined
+ ? { dueDateTime: propsValue.dueDateTime }
+ : {}),
+ ...(propsValue.startDateTime !== undefined
+ ? { startDateTime: propsValue.startDateTime }
+ : {}),
+ ...(propsValue.percentComplete !== undefined
+ ? { percentComplete: propsValue.percentComplete }
+ : {}),
+ ...(propsValue.priority !== undefined
+ ? { priority: propsValue.priority }
+ : {}),
+ ...(categories.length > 0
+ ? {
+ appliedCategories: Object.fromEntries(
+ categories.map((category) => [category, true])
+ ),
+ }
+ : {}),
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-bucket.ts
new file mode 100644
index 00000000000..265be7721a9
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-bucket.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerDeletedOutputSchema } from '../../output-schemas';
+
+export const deleteBucketAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_delete_bucket',
+ outputSchema: microsoft365PlannerDeletedOutputSchema,
+ displayName: 'Delete Bucket',
+ description: 'Permanently deletes a Planner bucket.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a Planner bucket (Bucket ID from List Buckets) and the tasks in it. Cannot be undone; repeating the call fails because the bucket no longer exists.',
+ idempotent: false,
+ },
+ props: {
+ bucketId: microsoft365PlannerAiProps.bucketId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ await microsoft365PlannerApi.deleteBucket({
+ auth,
+ id: propsValue.bucketId,
+ });
+ return { success: true, id: propsValue.bucketId };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-plan.ts
new file mode 100644
index 00000000000..2c9fdf3700c
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-plan.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerDeletedOutputSchema } from '../../output-schemas';
+
+export const deletePlanAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_delete_plan',
+ outputSchema: microsoft365PlannerDeletedOutputSchema,
+ displayName: 'Delete Plan',
+ description: 'Permanently deletes a Planner plan.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a Planner plan (Plan ID from List Plans) together with all its buckets and tasks. Cannot be undone; repeating the call fails because the plan no longer exists.',
+ idempotent: false,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ await microsoft365PlannerApi.deletePlan({
+ auth,
+ planId: propsValue.planId,
+ });
+ return { success: true, id: propsValue.planId };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-task.ts
new file mode 100644
index 00000000000..c7e39cceb3e
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/delete-task.ts
@@ -0,0 +1,28 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerDeletedOutputSchema } from '../../output-schemas';
+
+export const deleteTaskAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_delete_task',
+ outputSchema: microsoft365PlannerDeletedOutputSchema,
+ displayName: 'Delete Task',
+ description: 'Permanently deletes a Planner task.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a Planner task. Cannot be undone; repeating the call fails because the task no longer exists. To close a task instead, use Complete Task.',
+ idempotent: false,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ await microsoft365PlannerApi.deleteTask({ auth, id: propsValue.taskId });
+ return { success: true, id: propsValue.taskId };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-bucket.ts
new file mode 100644
index 00000000000..a73ae940aa3
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-bucket.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerBucketOutputSchema } from '../../output-schemas';
+
+export const getBucketAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_get_bucket',
+ outputSchema: microsoft365PlannerBucketOutputSchema,
+ displayName: 'Get Bucket',
+ description: 'Gets a Planner bucket by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one Planner bucket by its Bucket ID (from List Buckets): name, plan ID and order hint.',
+ idempotent: true,
+ },
+ props: {
+ bucketId: microsoft365PlannerAiProps.bucketId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.getBucket({
+ auth,
+ bucketId: propsValue.bucketId,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-current-user.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-current-user.ts
new file mode 100644
index 00000000000..78db8753fd9
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-current-user.ts
@@ -0,0 +1,24 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerCurrentUserOutputSchema } from '../../output-schemas';
+
+export const getCurrentUserAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_get_current_user',
+ outputSchema: microsoft365PlannerCurrentUserOutputSchema,
+ displayName: 'Get Current User',
+ description: 'Gets the signed-in Microsoft 365 user.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the signed-in Microsoft 365 user: ID, name, email and user principal name. Use the ID to assign tasks to yourself.',
+ idempotent: true,
+ },
+ props: {},
+ async run({ auth }) {
+ return await microsoft365PlannerApi.getUser({ auth });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-plan-details.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-plan-details.ts
new file mode 100644
index 00000000000..c278759ce64
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-plan-details.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerPlanDetailsOutputSchema } from '../../output-schemas';
+
+export const getPlanDetailsAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_get_plan_details',
+ outputSchema: microsoft365PlannerPlanDetailsOutputSchema,
+ displayName: 'Get Plan Details',
+ description: 'Gets a plan’s category labels and sharing.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the details of a Planner plan (Plan ID from List Plans): the names of its label categories (category1 to category25, used by a task’s applied categories) and who it is shared with.',
+ idempotent: true,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.getPlanDetails({
+ auth,
+ planId: propsValue.planId,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-plan.ts
new file mode 100644
index 00000000000..a53c61a7310
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-plan.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerPlanOutputSchema } from '../../output-schemas';
+
+export const getPlanAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_get_plan',
+ outputSchema: microsoft365PlannerPlanOutputSchema,
+ displayName: 'Get Plan',
+ description: 'Gets a Planner plan by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one Planner plan by its Plan ID (from List Plans): title, owning group, creator and created time. For category labels use Get Plan Details.',
+ idempotent: true,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.getPlan({
+ auth,
+ planId: propsValue.planId,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-task-details.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-task-details.ts
new file mode 100644
index 00000000000..0dbe364467c
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-task-details.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskDetailsOutputSchema } from '../../output-schemas';
+
+export const getTaskDetailsAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_get_task_details',
+ outputSchema: microsoft365PlannerTaskDetailsOutputSchema,
+ displayName: 'Get Task Details',
+ description: 'Gets a task’s description, checklist and links.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the details of a Planner task: its description, checklist items (keyed by item ID, with title and checked state) and attached links. The checklist item IDs are what Update Task Details needs to check, uncheck or remove items.',
+ idempotent: true,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.getTaskDetails({
+ auth,
+ taskId: propsValue.taskId,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-task.ts
new file mode 100644
index 00000000000..a2e07e5ea1d
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/get-task.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskOutputSchema } from '../../output-schemas';
+
+export const getTaskAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_get_task',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
+ displayName: 'Get Task',
+ description: 'Gets a Planner task by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one Planner task by its Task ID: title, plan and bucket IDs, assignees, applied categories, dates, priority and percent complete. For the description, checklist and links use Get Task Details.',
+ idempotent: true,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.getTask({
+ auth,
+ taskId: propsValue.taskId,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/index.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..6343cc87089
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/index.ts
@@ -0,0 +1,59 @@
+import { assignTaskAction } from './assign-task';
+import { completeTaskAction } from './complete-task';
+import { createBucketAiAction } from './create-bucket';
+import { createPlanAiAction } from './create-plan';
+import { createTaskAiAction } from './create-task';
+import { deleteBucketAiAction } from './delete-bucket';
+import { deletePlanAction } from './delete-plan';
+import { deleteTaskAiAction } from './delete-task';
+import { getBucketAction } from './get-bucket';
+import { getCurrentUserAction } from './get-current-user';
+import { getPlanAction } from './get-plan';
+import { getPlanDetailsAction } from './get-plan-details';
+import { getTaskAction } from './get-task';
+import { getTaskDetailsAction } from './get-task-details';
+import { listBucketTasksAction } from './list-bucket-tasks';
+import { listBucketsAction } from './list-buckets';
+import { listGroupMembersAction } from './list-group-members';
+import { listGroupsAction } from './list-groups';
+import { listMyTasksAction } from './list-my-tasks';
+import { listPlanTasksAction } from './list-plan-tasks';
+import { listPlansAction } from './list-plans';
+import { listUsersAction } from './list-users';
+import { moveTaskAction } from './move-task';
+import { updateBucketAiAction } from './update-bucket';
+import { updatePlanAiAction } from './update-plan';
+import { updatePlanDetailsAction } from './update-plan-details';
+import { updateTaskAiAction } from './update-task';
+import { updateTaskDetailsAction } from './update-task-details';
+
+export const microsoft365PlannerAiActions = [
+ listPlansAction,
+ getPlanAction,
+ createPlanAiAction,
+ updatePlanAiAction,
+ deletePlanAction,
+ getPlanDetailsAction,
+ updatePlanDetailsAction,
+ listBucketsAction,
+ getBucketAction,
+ createBucketAiAction,
+ updateBucketAiAction,
+ deleteBucketAiAction,
+ listPlanTasksAction,
+ listBucketTasksAction,
+ listMyTasksAction,
+ getTaskAction,
+ createTaskAiAction,
+ updateTaskAiAction,
+ completeTaskAction,
+ assignTaskAction,
+ moveTaskAction,
+ deleteTaskAiAction,
+ getTaskDetailsAction,
+ updateTaskDetailsAction,
+ getCurrentUserAction,
+ listGroupsAction,
+ listGroupMembersAction,
+ listUsersAction,
+];
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-bucket-tasks.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-bucket-tasks.ts
new file mode 100644
index 00000000000..eb800612e47
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-bucket-tasks.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskListOutputSchema } from '../../output-schemas';
+
+export const listBucketTasksAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_bucket_tasks',
+ outputSchema: microsoft365PlannerTaskListOutputSchema,
+ displayName: 'List Bucket Tasks',
+ description: 'Lists the tasks in a Planner bucket.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every task in one Planner bucket (Bucket ID from List Buckets), with IDs, assignees, dates, priority and percent complete.',
+ idempotent: true,
+ },
+ props: {
+ bucketId: microsoft365PlannerAiProps.bucketId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const tasks = await microsoft365PlannerApi.listBucketTasks({
+ auth,
+ bucketId: propsValue.bucketId,
+ });
+ return { tasks, count: tasks.length };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-buckets.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-buckets.ts
new file mode 100644
index 00000000000..7464bb5e3a2
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-buckets.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerBucketListOutputSchema } from '../../output-schemas';
+
+export const listBucketsAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_buckets',
+ outputSchema: microsoft365PlannerBucketListOutputSchema,
+ displayName: 'List Buckets',
+ description: 'Lists the buckets of a Planner plan.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the buckets (columns) of a Planner plan (Plan ID from List Plans), with each bucket’s ID and name. Use it to find the Bucket ID for creating or moving tasks.',
+ idempotent: true,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const buckets = await microsoft365PlannerApi.listAllBuckets({
+ auth,
+ planId: propsValue.planId,
+ });
+ return { buckets, count: buckets.length };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-group-members.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-group-members.ts
new file mode 100644
index 00000000000..f0573948371
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-group-members.ts
@@ -0,0 +1,51 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerMemberListOutputSchema } from '../../output-schemas';
+
+export const listGroupMembersAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_group_members',
+ outputSchema: microsoft365PlannerMemberListOutputSchema,
+ displayName: 'List Group Members',
+ description: 'Lists the users in a Microsoft 365 group.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the users in a Microsoft 365 group (Group ID from List Groups or from a plan’s owner), one page at a time: the people tasks in that group’s plans can be assigned to. Non-user members such as devices and nested groups are left out, so a page can hold fewer than Limit users. Pass Next Cursor to continue.',
+ idempotent: true,
+ },
+ props: {
+ groupId: microsoft365PlannerAiProps.groupId({ required: true }),
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Members per page, 1 to 999. Defaults to 100.',
+ required: false,
+ }),
+ cursor: Property.ShortText({
+ displayName: 'Cursor',
+ description:
+ 'Next Cursor from the previous page. Leave empty for the first page.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const limit = propsValue.limit ?? 100;
+ if (!Number.isInteger(limit) || limit < 1 || limit > 999) {
+ throw new Error('Limit must be a whole number from 1 to 999.');
+ }
+ const page = await microsoft365PlannerApi.listGroupMembers({
+ auth,
+ groupId: propsValue.groupId,
+ limit,
+ cursor: propsValue.cursor,
+ });
+ const users = page.items.filter(
+ (member) => member['@odata.type'] === '#microsoft.graph.user'
+ );
+ return { users, count: users.length, nextCursor: page.nextCursor };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-groups.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-groups.ts
new file mode 100644
index 00000000000..e77dc03dd36
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-groups.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerGroupListOutputSchema } from '../../output-schemas';
+
+export const listGroupsAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_groups',
+ outputSchema: microsoft365PlannerGroupListOutputSchema,
+ displayName: 'List Groups',
+ description: 'Lists the Microsoft 365 groups that can own plans.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists Microsoft 365 groups in the organization (only these can own Planner plans), with ID, name, email and visibility, one page at a time. Pass Next Cursor from the previous page to continue. Use a group ID with Create Plan, List Plans or List Group Members.',
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Groups per page, 1 to 999. Defaults to 100.',
+ required: false,
+ }),
+ cursor: Property.ShortText({
+ displayName: 'Cursor',
+ description:
+ 'Next Cursor from the previous page. Leave empty for the first page.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const limit = propsValue.limit ?? 100;
+ if (!Number.isInteger(limit) || limit < 1 || limit > 999) {
+ throw new Error('Limit must be a whole number from 1 to 999.');
+ }
+ const page = await microsoft365PlannerApi.listUnifiedGroups({
+ auth,
+ limit,
+ cursor: propsValue.cursor,
+ });
+ return {
+ groups: page.items,
+ count: page.items.length,
+ nextCursor: page.nextCursor,
+ };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-my-tasks.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-my-tasks.ts
new file mode 100644
index 00000000000..d0d7c723659
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-my-tasks.ts
@@ -0,0 +1,25 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskListOutputSchema } from '../../output-schemas';
+
+export const listMyTasksAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_my_tasks',
+ outputSchema: microsoft365PlannerTaskListOutputSchema,
+ displayName: 'List My Tasks',
+ description: 'Lists the Planner tasks assigned to you.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every Planner task assigned to the signed-in user, across all plans, with each task’s plan ID, bucket ID, dates, priority and percent complete.',
+ idempotent: true,
+ },
+ props: {},
+ async run({ auth }) {
+ const tasks = await microsoft365PlannerApi.listMyTasks({ auth });
+ return { tasks, count: tasks.length };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-plan-tasks.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-plan-tasks.ts
new file mode 100644
index 00000000000..464b2bf83ba
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-plan-tasks.ts
@@ -0,0 +1,43 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskListOutputSchema } from '../../output-schemas';
+
+export const listPlanTasksAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_plan_tasks',
+ outputSchema: microsoft365PlannerTaskListOutputSchema,
+ displayName: 'List Plan Tasks',
+ description: 'Lists the tasks of a Planner plan.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every task in a Planner plan (Plan ID from List Plans), with IDs, bucket, assignees, dates, priority and percent complete. Title Contains narrows the result to tasks whose title contains the text, case-insensitive. For one bucket use List Bucket Tasks; for your own tasks across plans use List My Tasks.',
+ idempotent: true,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ titleContains: Property.ShortText({
+ displayName: 'Title Contains',
+ description:
+ 'Only return tasks whose title contains this text (case-insensitive).',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const tasks = await microsoft365PlannerApi.listAllTasks({
+ auth,
+ planId: propsValue.planId,
+ });
+ const titleContains = propsValue.titleContains?.toLowerCase();
+ const matching = titleContains
+ ? tasks.filter((task) =>
+ task.title?.toLowerCase().includes(titleContains)
+ )
+ : tasks;
+ return { tasks: matching, count: matching.length };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-plans.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-plans.ts
new file mode 100644
index 00000000000..d744d60d879
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-plans.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerPlanListOutputSchema } from '../../output-schemas';
+
+export const listPlansAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_plans',
+ outputSchema: microsoft365PlannerPlanListOutputSchema,
+ displayName: 'List Plans',
+ description: 'Lists your Planner plans, or the plans of a group.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the Planner plans shared with the signed-in user, or, when Group ID is set, the plans owned by that Microsoft 365 group (from List Groups). Title Contains narrows the result to plans whose title contains the text, case-insensitive. Use it to turn a plan name into the Plan ID other actions need. Without Group ID, Microsoft can leave out plans created recently; set Group ID to be sure a new plan is listed.',
+ idempotent: true,
+ },
+ props: {
+ groupId: microsoft365PlannerAiProps.groupId({
+ required: false,
+ description:
+ 'Only list the plans of this Microsoft 365 group (from List Groups). Leave empty for every plan shared with you.',
+ }),
+ titleContains: Property.ShortText({
+ displayName: 'Title Contains',
+ description:
+ 'Only return plans whose title contains this text (case-insensitive).',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const plans = propsValue.groupId
+ ? await microsoft365PlannerApi.listGroupPlans({
+ auth,
+ groupId: propsValue.groupId,
+ })
+ : await microsoft365PlannerApi.listAllPlans({ auth });
+ const titleContains = propsValue.titleContains?.toLowerCase();
+ const matching = titleContains
+ ? plans.filter((plan) =>
+ plan.title?.toLowerCase().includes(titleContains)
+ )
+ : plans;
+ return { plans: matching, count: matching.length };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-users.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-users.ts
new file mode 100644
index 00000000000..42687d46219
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/list-users.ts
@@ -0,0 +1,56 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerMemberListOutputSchema } from '../../output-schemas';
+
+export const listUsersAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_list_users',
+ outputSchema: microsoft365PlannerMemberListOutputSchema,
+ displayName: 'List Users',
+ description: 'Lists or finds users in your organization.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the users in the signed-in user’s Microsoft 365 organization, one page at a time, or finds them by the start of their name or email with Starts With. Use it to turn a person’s name or email into the User ID that Create Task, Assign Task and Update Task need. A task can only be assigned to a member of the plan’s group; List Group Members lists those. Pass Next Cursor to continue.',
+ idempotent: true,
+ },
+ props: {
+ startsWith: Property.ShortText({
+ displayName: 'Starts With',
+ description:
+ 'Only return users whose display name, email or user principal name starts with this text (case-insensitive), e.g. "ada" or "[email protected]".',
+ required: false,
+ }),
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'Users per page, 1 to 999. Defaults to 100.',
+ required: false,
+ }),
+ cursor: Property.ShortText({
+ displayName: 'Cursor',
+ description:
+ 'Next Cursor from the previous page. Leave empty for the first page.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const limit = propsValue.limit ?? 100;
+ if (!Number.isInteger(limit) || limit < 1 || limit > 999) {
+ throw new Error('Limit must be a whole number from 1 to 999.');
+ }
+ const page = await microsoft365PlannerApi.listUserPage({
+ auth,
+ limit,
+ cursor: propsValue.cursor,
+ startsWith: propsValue.startsWith,
+ });
+ return {
+ users: page.items,
+ count: page.items.length,
+ nextCursor: page.nextCursor,
+ };
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/move-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/move-task.ts
new file mode 100644
index 00000000000..2ad3decf5df
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/move-task.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerTaskOutputSchema } from '../../output-schemas';
+
+export const moveTaskAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_move_task',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
+ displayName: 'Move Task',
+ description: 'Moves a Planner task to another bucket.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Moves a Planner task to another bucket of the same plan (Bucket ID from List Buckets) and returns the updated task. Tasks cannot move between plans.',
+ idempotent: true,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ bucketId: microsoft365PlannerAiProps.bucketId({
+ required: true,
+ description:
+ 'Bucket of the same plan to move the task to (from List Buckets).',
+ }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.patchTask({
+ auth,
+ taskId: propsValue.taskId,
+ fields: { bucketId: propsValue.bucketId },
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-bucket.ts
new file mode 100644
index 00000000000..b5635b21eaa
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-bucket.ts
@@ -0,0 +1,48 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerBucketOutputSchema } from '../../output-schemas';
+
+export const updateBucketAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_update_bucket',
+ outputSchema: microsoft365PlannerBucketOutputSchema,
+ displayName: 'Update Bucket',
+ description: 'Renames or reorders a Planner bucket.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes a Planner bucket’s name and/or order hint (Bucket ID from List Buckets) and returns the updated bucket. Only the fields you set change.',
+ idempotent: true,
+ },
+ props: {
+ bucketId: microsoft365PlannerAiProps.bucketId({ required: true }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ description: 'New name of the bucket.',
+ required: false,
+ }),
+ orderHint: Property.ShortText({
+ displayName: 'Order Hint',
+ description: 'New Planner order hint, e.g. " !" to move it first.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const { name, orderHint } = propsValue;
+ if (name === undefined && orderHint === undefined) {
+ throw new Error('Set Name or Order Hint.');
+ }
+ return await microsoft365PlannerApi.patchBucket({
+ auth,
+ bucketId: propsValue.bucketId,
+ fields: {
+ ...(name !== undefined ? { name } : {}),
+ ...(orderHint !== undefined ? { orderHint } : {}),
+ },
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-plan-details.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-plan-details.ts
new file mode 100644
index 00000000000..66a11d8b63a
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-plan-details.ts
@@ -0,0 +1,47 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerPlanDetailsOutputSchema } from '../../output-schemas';
+
+export const updatePlanDetailsAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_update_plan_details',
+ outputSchema: microsoft365PlannerPlanDetailsOutputSchema,
+ displayName: 'Update Plan Details',
+ description: 'Renames a plan’s label categories.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets the names of a Planner plan’s label categories (Plan ID from List Plans) and returns the updated details. Only the categories you pass change; pass null for a category to remove its name.',
+ idempotent: true,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ categoryLabels: Property.Json({
+ displayName: 'Category Labels',
+ description:
+ 'Object mapping category keys (category1 to category25) to label names, e.g. {"category1": "Urgent", "category2": null}. null removes a label name.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const categoryLabels = propsValue.categoryLabels;
+ if (
+ typeof categoryLabels !== 'object' ||
+ categoryLabels === null ||
+ Array.isArray(categoryLabels)
+ ) {
+ throw new Error(
+ 'Category Labels must be an object such as {"category1": "Urgent"}.'
+ );
+ }
+ return await microsoft365PlannerApi.patchPlanDetails({
+ auth,
+ planId: propsValue.planId,
+ categoryDescriptions: categoryLabels,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-plan.ts
new file mode 100644
index 00000000000..6679ab1eddf
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-plan.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerPlanOutputSchema } from '../../output-schemas';
+
+export const updatePlanAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_update_plan',
+ outputSchema: microsoft365PlannerPlanOutputSchema,
+ displayName: 'Update Plan',
+ description: 'Renames a Planner plan.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Renames a Planner plan (Plan ID from List Plans) and returns the updated plan. Category labels are changed with Update Plan Details.',
+ idempotent: true,
+ },
+ props: {
+ planId: microsoft365PlannerAiProps.planId({ required: true }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New title of the plan.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ return await microsoft365PlannerApi.patchPlan({
+ auth,
+ planId: propsValue.planId,
+ title: propsValue.title,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-task-details.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-task-details.ts
new file mode 100644
index 00000000000..da559dd203a
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-task-details.ts
@@ -0,0 +1,185 @@
+import { randomUUID } from 'crypto';
+
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerUtils } from '../../common/utils';
+import { microsoft365PlannerTaskDetailsOutputSchema } from '../../output-schemas';
+
+export const updateTaskDetailsAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_update_task_details',
+ outputSchema: microsoft365PlannerTaskDetailsOutputSchema,
+ displayName: 'Update Task Details',
+ description: 'Edits a task’s description, checklist and links.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets a Planner task’s description, adds checklist items, checks, unchecks or removes existing ones (item IDs from Get Task Details), and adds or removes links. Returns the updated details. Only what you set changes. Each call with Add Checklist Items adds new items, even with the same titles.',
+ idempotent: false,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ description: Property.LongText({
+ displayName: 'Description',
+ description: 'New description (replaces the current one).',
+ required: false,
+ }),
+ addChecklistItems: Property.Array({
+ displayName: 'Add Checklist Items',
+ description: 'Titles of checklist items to add, unchecked.',
+ required: false,
+ }),
+ checkChecklistItemIds: Property.Array({
+ displayName: 'Check Checklist Item IDs',
+ description: 'Checklist item IDs (from Get Task Details) to mark done.',
+ required: false,
+ }),
+ uncheckChecklistItemIds: Property.Array({
+ displayName: 'Uncheck Checklist Item IDs',
+ description: 'Checklist item IDs to mark not done.',
+ required: false,
+ }),
+ removeChecklistItemIds: Property.Array({
+ displayName: 'Remove Checklist Item IDs',
+ description: 'Checklist item IDs to delete.',
+ required: false,
+ }),
+ addLinks: Property.Array({
+ displayName: 'Add Links',
+ description: 'Links to attach to the task.',
+ required: false,
+ properties: {
+ url: Property.ShortText({
+ displayName: 'URL',
+ description: 'Full URL, e.g. https://contoso.com/spec.docx.',
+ required: true,
+ }),
+ alias: Property.ShortText({
+ displayName: 'Name',
+ description: 'Name shown for the link. Defaults to the URL.',
+ required: false,
+ }),
+ },
+ }),
+ removeLinkUrls: Property.Array({
+ displayName: 'Remove Link URLs',
+ description: 'URLs of attached links to remove, exactly as attached.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const addItems = microsoft365PlannerUtils.stringIds({
+ value: propsValue.addChecklistItems,
+ propName: 'Add Checklist Items',
+ });
+ const checkIds = microsoft365PlannerUtils.stringIds({
+ value: propsValue.checkChecklistItemIds,
+ propName: 'Check Checklist Item IDs',
+ });
+ const uncheckIds = microsoft365PlannerUtils.stringIds({
+ value: propsValue.uncheckChecklistItemIds,
+ propName: 'Uncheck Checklist Item IDs',
+ });
+ const removeIds = microsoft365PlannerUtils.stringIds({
+ value: propsValue.removeChecklistItemIds,
+ propName: 'Remove Checklist Item IDs',
+ });
+ const removeUrls = microsoft365PlannerUtils.stringIds({
+ value: propsValue.removeLinkUrls,
+ propName: 'Remove Link URLs',
+ });
+ const addLinks = (propsValue.addLinks ?? []).map((link) => {
+ if (
+ typeof link !== 'object' ||
+ link === null ||
+ !('url' in link) ||
+ typeof link.url !== 'string' ||
+ link.url === ''
+ ) {
+ throw new Error('Each item in Add Links needs a URL.');
+ }
+ const alias =
+ 'alias' in link && typeof link.alias === 'string' && link.alias !== ''
+ ? link.alias
+ : link.url;
+ return { url: link.url, alias };
+ });
+ const touchedIds = [...checkIds, ...uncheckIds, ...removeIds];
+ if (new Set(touchedIds).size !== touchedIds.length) {
+ throw new Error(
+ 'A checklist item ID can appear in only one of Check, Uncheck and Remove.'
+ );
+ }
+ const checklist = {
+ ...Object.fromEntries(
+ addItems.map((title) => [
+ randomUUID(),
+ {
+ '@odata.type': 'microsoft.graph.plannerChecklistItem',
+ title,
+ isChecked: false,
+ },
+ ])
+ ),
+ ...Object.fromEntries(
+ checkIds.map((id) => [
+ id,
+ {
+ '@odata.type': 'microsoft.graph.plannerChecklistItem',
+ isChecked: true,
+ },
+ ])
+ ),
+ ...Object.fromEntries(
+ uncheckIds.map((id) => [
+ id,
+ {
+ '@odata.type': 'microsoft.graph.plannerChecklistItem',
+ isChecked: false,
+ },
+ ])
+ ),
+ ...Object.fromEntries(removeIds.map((id) => [id, null])),
+ };
+ const references = {
+ ...Object.fromEntries(
+ addLinks.map((link) => [
+ referenceKey({ url: link.url }),
+ {
+ '@odata.type': 'microsoft.graph.plannerExternalReference',
+ alias: link.alias,
+ },
+ ])
+ ),
+ ...Object.fromEntries(
+ removeUrls.map((url) => [referenceKey({ url }), null])
+ ),
+ };
+ const fields = {
+ ...(propsValue.description !== undefined
+ ? { description: propsValue.description }
+ : {}),
+ ...(Object.keys(checklist).length > 0 ? { checklist } : {}),
+ ...(Object.keys(references).length > 0 ? { references } : {}),
+ };
+ if (Object.keys(fields).length === 0) {
+ throw new Error('Set at least one field to change.');
+ }
+ return await microsoft365PlannerApi.patchTaskDetails({
+ auth,
+ taskId: propsValue.taskId,
+ fields,
+ });
+ },
+});
+
+function referenceKey({ url }: { url: string }): string {
+ return url.replace(
+ /[%.:@#]/g,
+ (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`
+ );
+}
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-task.ts
new file mode 100644
index 00000000000..0d58b24adb0
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/ai/update-task.ts
@@ -0,0 +1,164 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../../auth';
+import { microsoft365PlannerAiProps } from '../../common/ai-props';
+import { microsoft365PlannerApi } from '../../common/api';
+import { microsoft365PlannerUtils } from '../../common/utils';
+import { microsoft365PlannerTaskOutputSchema } from '../../output-schemas';
+
+export const updateTaskAiAction = createAction({
+ auth: microsoft365PlannerAuth,
+ name: 'microsoft_365_planner_update_task',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
+ displayName: 'Update Task',
+ description: 'Updates fields of a Planner task.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Changes any of a Planner task’s title, bucket (same plan), assignees (add or remove), dates (set or clear), priority, percent complete and label categories (add or remove), and returns the updated task. Only the fields you set change. For a single change prefer Complete Task, Assign Task or Move Task; for description and checklist use Update Task Details.',
+ idempotent: true,
+ },
+ props: {
+ taskId: microsoft365PlannerAiProps.taskId({ required: true }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New title.',
+ required: false,
+ }),
+ bucketId: microsoft365PlannerAiProps.bucketId({
+ required: false,
+ description: 'Move the task to this bucket of the same plan.',
+ }),
+ assignUserIds: microsoft365PlannerAiProps.userIds({
+ required: false,
+ displayName: 'Assign User IDs',
+ description:
+ 'User IDs to add as assignees (existing assignees stay). From List Group Members or Get Current User.',
+ }),
+ unassignUserIds: microsoft365PlannerAiProps.userIds({
+ required: false,
+ displayName: 'Unassign User IDs',
+ description: 'User IDs to remove from the assignees.',
+ }),
+ dueDateTime: Property.DateTime({
+ displayName: 'Due Date',
+ description: 'New due date and time, ISO 8601.',
+ required: false,
+ }),
+ clearDueDate: Property.Checkbox({
+ displayName: 'Clear Due Date',
+ description: 'Remove the due date. Cannot be combined with Due Date.',
+ required: false,
+ }),
+ startDateTime: Property.DateTime({
+ displayName: 'Start Date',
+ description: 'New start date and time, ISO 8601.',
+ required: false,
+ }),
+ clearStartDate: Property.Checkbox({
+ displayName: 'Clear Start Date',
+ description: 'Remove the start date. Cannot be combined with Start Date.',
+ required: false,
+ }),
+ percentComplete: Property.Number({
+ displayName: 'Percent Complete',
+ description: 'Progress from 0 to 100; 100 marks the task completed.',
+ required: false,
+ }),
+ priority: Property.Number({
+ displayName: 'Priority',
+ description:
+ 'Priority from 0 (highest) to 10 (lowest). Planner shows 1 as urgent, 3 as important, 5 as medium and 9 as low.',
+ required: false,
+ }),
+ addCategories: Property.Array({
+ displayName: 'Add Label Categories',
+ description: 'Label categories to apply, e.g. ["category1"].',
+ required: false,
+ }),
+ removeCategories: Property.Array({
+ displayName: 'Remove Label Categories',
+ description: 'Label categories to remove, e.g. ["category2"].',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const assign = microsoft365PlannerUtils.stringIds({
+ value: propsValue.assignUserIds,
+ propName: 'Assign User IDs',
+ });
+ const unassign = microsoft365PlannerUtils.stringIds({
+ value: propsValue.unassignUserIds,
+ propName: 'Unassign User IDs',
+ });
+ const addCategories = microsoft365PlannerUtils.stringIds({
+ value: propsValue.addCategories,
+ propName: 'Add Label Categories',
+ });
+ const removeCategories = microsoft365PlannerUtils.stringIds({
+ value: propsValue.removeCategories,
+ propName: 'Remove Label Categories',
+ });
+ if (assign.some((id) => unassign.includes(id))) {
+ throw new Error(
+ 'A user cannot be in both Assign User IDs and Unassign User IDs.'
+ );
+ }
+ if (addCategories.some((category) => removeCategories.includes(category))) {
+ throw new Error(
+ 'A category cannot be in both Add Label Categories and Remove Label Categories.'
+ );
+ }
+ if (propsValue.dueDateTime !== undefined && propsValue.clearDueDate) {
+ throw new Error('Set Due Date or Clear Due Date, not both.');
+ }
+ if (propsValue.startDateTime !== undefined && propsValue.clearStartDate) {
+ throw new Error('Set Start Date or Clear Start Date, not both.');
+ }
+ const fields = {
+ ...(propsValue.title !== undefined ? { title: propsValue.title } : {}),
+ ...(propsValue.bucketId !== undefined
+ ? { bucketId: propsValue.bucketId }
+ : {}),
+ ...(assign.length > 0 || unassign.length > 0
+ ? {
+ assignments: {
+ ...microsoft365PlannerUtils.assignmentsFor({ userIds: assign }),
+ ...Object.fromEntries(unassign.map((id) => [id, null])),
+ },
+ }
+ : {}),
+ ...(propsValue.dueDateTime !== undefined
+ ? { dueDateTime: propsValue.dueDateTime }
+ : {}),
+ ...(propsValue.clearDueDate ? { dueDateTime: null } : {}),
+ ...(propsValue.startDateTime !== undefined
+ ? { startDateTime: propsValue.startDateTime }
+ : {}),
+ ...(propsValue.clearStartDate ? { startDateTime: null } : {}),
+ ...(propsValue.percentComplete !== undefined
+ ? { percentComplete: propsValue.percentComplete }
+ : {}),
+ ...(propsValue.priority !== undefined
+ ? { priority: propsValue.priority }
+ : {}),
+ ...(addCategories.length > 0 || removeCategories.length > 0
+ ? {
+ appliedCategories: {
+ ...Object.fromEntries(addCategories.map((c) => [c, true])),
+ ...Object.fromEntries(removeCategories.map((c) => [c, false])),
+ },
+ }
+ : {}),
+ };
+ if (Object.keys(fields).length === 0) {
+ throw new Error('Set at least one field to change.');
+ }
+ return await microsoft365PlannerApi.patchTask({
+ auth,
+ taskId: propsValue.taskId,
+ fields,
+ });
+ },
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-bucket.ts
index 3327424010d..43c7d7f4e34 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-bucket.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-bucket.ts
@@ -1,29 +1,32 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { OrderHintProperty, PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerBucketOutputSchema } from '../output-schemas';
-export const createBucket = createAction({
+export const createBucketAction = createAction({
auth: microsoft365PlannerAuth,
name: 'createBucket',
+ outputSchema: microsoft365PlannerBucketOutputSchema,
classification: 'WRITE',
displayName: 'Create Bucket',
description: 'Create a bucket (category) under a plan.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Creates a new bucket (a column/category for grouping tasks) under an existing Planner plan, identified by plan ID. Use to organize tasks within a plan. Each call adds another bucket, so it is not idempotent.',
idempotent: false,
},
props: {
- planId: PlanDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
name: Property.ShortText({
displayName: 'Bucket Name',
description: 'The name of the bucket to be created',
required: true,
}),
- orderHint: OrderHintProperty({ required: false }),
+ orderHint: microsoft365PlannerProps.orderHint({ required: false }),
},
async run({ auth, propsValue }) {
- return await microsoft365PlannerCommon.createBucket({
+ return await microsoft365PlannerApi.createBucket({
auth,
...propsValue,
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-plan.ts
index 1ad9091ed84..cabefca5092 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-plan.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-plan.ts
@@ -1,21 +1,23 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { getGraphBaseUrl, getMicrosoftCloudFromAuth } from '../common/microsoft-cloud';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { groupDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerPlanOutputSchema } from '../output-schemas';
-export const createPlan = createAction({
+export const createPlanAction = createAction({
auth: microsoft365PlannerAuth,
name: 'createPlan',
+ outputSchema: microsoft365PlannerPlanOutputSchema,
classification: 'WRITE',
displayName: 'Create Plan',
description: 'Create a new planner plan',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Creates a new Microsoft 365 Planner plan with the given title, owned by a specified Microsoft 365 group. Use to set up a fresh planning board before adding buckets or tasks. The group must already exist; each call creates a separate plan, so it is not idempotent.',
idempotent: false,
},
props: {
- groupId: groupDropdown({ required: true }),
+ groupId: microsoft365PlannerProps.groupId({ required: true }),
title: Property.ShortText({
displayName: 'Title',
description: 'The title of the plan',
@@ -23,14 +25,10 @@ export const createPlan = createAction({
}),
},
async run({ auth, propsValue }) {
- const cloud = getMicrosoftCloudFromAuth(auth);
- const graphBaseUrl = getGraphBaseUrl(cloud);
- const planParams = {
- container: {
- url: `${graphBaseUrl}/v1.0/groups/${propsValue.groupId}`,
- },
+ return await microsoft365PlannerApi.createPlan({
+ auth,
+ groupId: propsValue.groupId,
title: propsValue.title,
- };
- return await microsoft365PlannerCommon.createPlan({ auth, ...planParams });
+ });
},
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-task.ts
index 05cd5b98771..1802acce767 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-task.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/create-task.ts
@@ -1,57 +1,32 @@
-import {
- createAction,
- OAuth2PropertyValue,
- Property,
-} from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { BucketDropdown, PlanDropdown } from '../common/properties';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerUtils } from '../common/utils';
+import { microsoft365PlannerCreatedTaskOutputSchema } from '../output-schemas';
-export const createTask = createAction({
+export const createTaskAction = createAction({
auth: microsoft365PlannerAuth,
name: 'createTask',
+ outputSchema: microsoft365PlannerCreatedTaskOutputSchema,
classification: 'WRITE',
displayName: 'Create Task',
description:
'Create a new planner task with title, assignments, due date, etc.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Creates a new task in a Planner plan, optionally placing it in a bucket and setting assignees, due/start dates, priority, and percent complete. Use to add work items to a plan. Each call creates a separate task, so it is not idempotent.',
idempotent: false,
},
props: {
- planId: PlanDropdown({ required: true }),
- bucketId: BucketDropdown({ required: false }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
+ bucketId: microsoft365PlannerProps.bucketId({ required: false }),
title: Property.ShortText({
displayName: 'Title',
description: 'The title of the task to be created',
required: true,
}),
- assignments: Property.MultiSelectDropdown({
- displayName: 'Assignments',
- description:
- 'Select users to assign the task to. If left empty, the task will be unassigned.',
- required: false,
- auth: microsoft365PlannerAuth,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select an authentication first',
- };
- }
- const users = await microsoft365PlannerCommon.listUsers({ auth: auth });
- return {
- options: users.map((user) => ({
- label: user.displayName || user.userPrincipalName || 'No Name',
- value: user.id || '',
- })),
- disabled: false,
- placeholder: 'Select users to assign the task to',
- };
- },
- }),
+ assignments: microsoft365PlannerProps.assignments({ required: false }),
dueDateTime: Property.DateTime({
displayName: 'Due Date',
description: 'The due date and time for the task',
@@ -78,21 +53,18 @@ export const createTask = createAction({
const taskParams = {
...propsValue,
assignments: propsValue.assignments
- ? Object.fromEntries(
- propsValue.assignments.map((userId) => [
- userId,
- { '@odata.type': 'microsoft.graph.plannerAssignment' },
- ])
- )
+ ? microsoft365PlannerUtils.assignmentsFor({
+ userIds: propsValue.assignments,
+ })
: undefined,
- dueDateTime: propsValue.dueDateTime
+ dueDateTime: propsValue.dueDateTime
? new Date(propsValue.dueDateTime).toISOString()
: undefined,
- startDateTime: propsValue.startDateTime
+ startDateTime: propsValue.startDateTime
? new Date(propsValue.startDateTime).toISOString()
: undefined,
};
- return await microsoft365PlannerCommon.createTask({
+ return await microsoft365PlannerApi.createTask({
auth,
...taskParams,
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-bucket.ts
index c51b47837b6..1c1366293c3 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-bucket.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-bucket.ts
@@ -1,27 +1,30 @@
import { createAction } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { BucketDropdown, PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerSuccessOutputSchema } from '../output-schemas';
-export const deleteBucket = createAction({
+export const deleteBucketAction = createAction({
auth: microsoft365PlannerAuth,
name: 'deleteBucket',
+ outputSchema: microsoft365PlannerSuccessOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Delete Bucket',
description: 'Delete an existing bucket.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Permanently deletes a bucket from a Planner plan by bucket ID. Use to remove a category and stop grouping tasks under it. Destructive and not idempotent; once removed, repeating the call fails because the bucket no longer exists.',
idempotent: false,
},
props: {
- planId: PlanDropdown({ required: true }),
- id: BucketDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
+ id: microsoft365PlannerProps.bucketId({ required: true }),
},
async run({ auth, propsValue: { id } }) {
if (!id) {
throw new Error('Bucket id is required');
}
- return await microsoft365PlannerCommon.deleteBucket({
+ return await microsoft365PlannerApi.deleteBucket({
auth,
id,
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-task.ts
index 089c9949a14..135539b845d 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-task.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/delete-task.ts
@@ -1,27 +1,30 @@
import { createAction } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { PlanDropdown, TaskDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerSuccessOutputSchema } from '../output-schemas';
-export const deleteTask = createAction({
+export const deleteTaskAction = createAction({
auth: microsoft365PlannerAuth,
name: 'deleteTask',
+ outputSchema: microsoft365PlannerSuccessOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Delete Task',
description: 'Remove a specific task by ID.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Permanently deletes a task from a Planner plan by task ID. Use to remove a work item. Destructive and not idempotent; once removed, repeating the call fails because the task no longer exists.',
idempotent: false,
},
props: {
- planId: PlanDropdown({ required: true }),
- id: TaskDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
+ id: microsoft365PlannerProps.taskId({ required: true }),
},
async run({ auth, propsValue: { id } }) {
if (!id) {
throw new Error('Task id is required');
}
- return await microsoft365PlannerCommon.deleteTask({
+ return await microsoft365PlannerApi.deleteTask({
auth,
id,
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-a-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-a-plan.ts
index 9e6a31145eb..7956e813963 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-a-plan.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-a-plan.ts
@@ -1,13 +1,16 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerFindPlanOutputSchema } from '../output-schemas';
-export const findAPlan = createAction({
+export const findAPlanAction = createAction({
auth: microsoft365PlannerAuth,
name: 'findAPlan',
+ outputSchema: microsoft365PlannerFindPlanOutputSchema,
classification: 'SEARCH',
displayName: 'Find a Plan',
description: 'Finds a plan by field.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Searches across the authenticated user\'s Planner plans and returns those whose title contains the given text (case-insensitive substring match). Use to resolve a plan name into its plan ID before acting on it. Read-only and idempotent; the title input is required.',
idempotent: true,
@@ -20,7 +23,7 @@ export const findAPlan = createAction({
}),
},
async run({ auth, propsValue: { title } }) {
- const plans = await microsoft365PlannerCommon.listPlans({ auth });
+ const plans = await microsoft365PlannerApi.listPlans({ auth });
return plans.filter(
(plan) =>
plan.title && plan.title.toLowerCase().includes(title.toLowerCase())
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-task.ts
index de3cab7230c..8dba1ba7264 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-task.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/find-task.ts
@@ -1,20 +1,23 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerFindTaskOutputSchema } from '../output-schemas';
-export const findTask = createAction({
+export const findTaskAction = createAction({
auth: microsoft365PlannerAuth,
name: 'findTask',
+ outputSchema: microsoft365PlannerFindTaskOutputSchema,
classification: 'SEARCH',
displayName: 'Find Task',
description: 'Find task by fields.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Searches the tasks of a given Planner plan and returns those whose title contains the given text (case-insensitive substring match). Use to locate a task ID within a known plan. Read-only and idempotent; both plan ID and title are required.',
idempotent: true,
},
props: {
- planId: PlanDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
title: Property.ShortText({
displayName: 'Title',
description: 'The title of the task to search for',
@@ -25,7 +28,7 @@ export const findTask = createAction({
if (!planId) {
throw new Error('Plan ID is required to fetch tasks.');
}
- const tasks = await microsoft365PlannerCommon.listTasks({ auth, planId });
+ const tasks = await microsoft365PlannerApi.listTasks({ auth, planId });
return tasks.filter(
(task) =>
task.title && task.title.toLowerCase().includes(title.toLowerCase())
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/get-a-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/get-a-bucket.ts
index 7450238bcfa..8952eee5639 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/get-a-bucket.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/get-a-bucket.ts
@@ -1,27 +1,30 @@
import { createAction } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { BucketDropdown, PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerBucketOutputSchema } from '../output-schemas';
-export const getABucket = createAction({
+export const getABucketAction = createAction({
auth: microsoft365PlannerAuth,
name: 'getABucket',
+ outputSchema: microsoft365PlannerBucketOutputSchema,
classification: 'READ',
displayName: 'Get a Bucket',
description: 'Retrieve details about a specific bucket.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Retrieves the details of a single Planner bucket by its bucket ID (within a known plan). Use to inspect a bucket\'s current name and order hint. Read-only and idempotent.',
idempotent: true,
},
props: {
- planId: PlanDropdown({ required: true }),
- bucketId: BucketDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
+ bucketId: microsoft365PlannerProps.bucketId({ required: true }),
},
async run({ auth, propsValue: { bucketId } }) {
if (!bucketId) {
throw new Error('Bucket ID is required to fetch bucket details.');
}
- return await microsoft365PlannerCommon.getBucketDetails({
+ return await microsoft365PlannerApi.getBucket({
auth,
bucketId,
});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-bucket.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-bucket.ts
index a9996240c0b..14612adc89a 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-bucket.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-bucket.ts
@@ -1,38 +1,37 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import {
- BucketDropdown,
- OrderHintProperty,
- PlanDropdown,
-} from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerSuccessOutputSchema } from '../output-schemas';
-export const updateBucket = createAction({
+export const updateBucketAction = createAction({
auth: microsoft365PlannerAuth,
name: 'updateBucket',
+ outputSchema: microsoft365PlannerSuccessOutputSchema,
classification: 'WRITE',
displayName: 'Update Bucket',
description: 'Modify bucket’s name or properties.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Updates an existing bucket\'s name and/or order hint, identified by bucket ID within a plan. Use to rename or reorder a bucket. Idempotent: applying the same field values repeatedly leaves the bucket in the same end state.',
idempotent: true,
},
props: {
- planId: PlanDropdown({ required: true }),
- id: BucketDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
+ id: microsoft365PlannerProps.bucketId({ required: true }),
name: Property.ShortText({
displayName: 'Name',
description: 'The new name of the bucket',
required: false,
}),
- orderHint: OrderHintProperty({ required: false }),
+ orderHint: microsoft365PlannerProps.orderHint({ required: false }),
},
async run({ auth, propsValue }) {
- const { planId, id, ...updateParams } = propsValue;
+ const { planId: _planId, id, ...updateParams } = propsValue;
if (!id) {
throw new Error('Bucket ID is required to update a bucket.');
}
- return await microsoft365PlannerCommon.updateBucket({
+ return await microsoft365PlannerApi.updateBucket({
auth,
id,
...updateParams,
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-plan.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-plan.ts
index 84d752fbe33..f2c74de32e8 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-plan.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-plan.ts
@@ -1,20 +1,23 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerSuccessOutputSchema } from '../output-schemas';
-export const updatePlan = createAction({
+export const updatePlanAction = createAction({
auth: microsoft365PlannerAuth,
name: 'updatePlan',
+ outputSchema: microsoft365PlannerSuccessOutputSchema,
classification: 'WRITE',
displayName: 'Update Plan',
description: 'modify metadata of a plan (e.g. title changes).',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Updates an existing Planner plan\'s title, identified by plan ID. Use to rename a plan. Idempotent: setting the same title repeatedly leaves the plan in the same end state.',
idempotent: true,
},
props: {
- id: PlanDropdown({ required: true }),
+ id: microsoft365PlannerProps.planId({ required: true }),
title: Property.ShortText({
displayName: 'Title',
description: 'The new title of the plan',
@@ -25,7 +28,7 @@ export const updatePlan = createAction({
if (!id) {
throw new Error('Plan id is required');
}
- return await microsoft365PlannerCommon.updatePlan({
+ return await microsoft365PlannerApi.updatePlan({
auth,
id,
title,
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-task.ts b/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-task.ts
index 839b189fdf7..2da3627fc77 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-task.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/actions/update-task.ts
@@ -1,57 +1,32 @@
-import {
- createAction,
- OAuth2PropertyValue,
- Property,
-} from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { PlanDropdown, TaskDropdown } from '../common/properties';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerUtils } from '../common/utils';
+import { microsoft365PlannerSuccessOutputSchema } from '../output-schemas';
-export const updateTask = createAction({
+export const updateTaskAction = createAction({
auth: microsoft365PlannerAuth,
name: 'updateTask',
+ outputSchema: microsoft365PlannerSuccessOutputSchema,
classification: 'WRITE',
displayName: 'Update Task',
description:
'Modify existing task fields: title, due date, assignments, descriptions.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description: 'Updates fields on an existing Planner task identified by task ID, such as title, assignees, due/start dates, priority, and percent complete. Use to edit a task; only provided fields are changed. Idempotent: applying the same field values repeatedly leaves the task in the same end state.',
idempotent: true,
},
props: {
- planId: PlanDropdown({ required: true }),
- id: TaskDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
+ id: microsoft365PlannerProps.taskId({ required: true }),
title: Property.ShortText({
displayName: 'Title',
description: 'The new title of the task',
required: false,
}),
- assignments: Property.MultiSelectDropdown({
- displayName: 'Assignments',
- description:
- 'Select users to assign the task to. If left empty, the task will be unassigned.',
- required: false,
- refreshers: ['auth'],
- auth: microsoft365PlannerAuth,
- options: async ({ auth }) => {
- if (!auth) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select an authentication first',
- };
- }
- const users = await microsoft365PlannerCommon.listUsers({ auth: auth });
- return {
- options: users.map((user) => ({
- label: user.displayName || user.userPrincipalName || 'No Name',
- value: user.id || '',
- })),
- disabled: false,
- placeholder: 'Select users to assign the task to',
- };
- },
- }),
+ assignments: microsoft365PlannerProps.assignments({ required: false }),
dueDateTime: Property.DateTime({
displayName: 'Due Date',
description: 'The due date and time for the task',
@@ -75,22 +50,19 @@ export const updateTask = createAction({
}),
},
async run({ auth, propsValue }) {
- const { planId, id, ...updateParams } = propsValue;
+ const { planId: _planId, id, ...updateParams } = propsValue;
if (!id) {
throw new Error('Task ID is required to update a task.');
}
const formattedParams = {
...updateParams,
assignments: updateParams.assignments
- ? Object.fromEntries(
- updateParams.assignments.map((userId) => [
- userId,
- { '@odata.type': 'microsoft.graph.plannerAssignment' },
- ])
- )
+ ? microsoft365PlannerUtils.assignmentsFor({
+ userIds: updateParams.assignments,
+ })
: undefined,
};
- return await microsoft365PlannerCommon.updateTask({
+ return await microsoft365PlannerApi.updateTask({
auth,
id,
...formattedParams,
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/auth.ts b/packages/pieces/community/microsoft-365-planner/src/lib/auth.ts
new file mode 100644
index 00000000000..29a5e9a205a
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/auth.ts
@@ -0,0 +1,44 @@
+import { PieceAuth, Property } from '@activepieces/pieces-framework';
+
+const authDesc = `
+If you'd like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),
+ set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:
+ - Group.Read.All
+ - Tasks.ReadWrite
+ - User.Read
+ - User.ReadBasic.All`;
+
+const microsoftCloudProperty = Property.StaticDropdown({
+ displayName: 'Cloud Environment',
+ description: 'Select your Microsoft cloud environment.',
+ required: true,
+ defaultValue: 'login.microsoftonline.com',
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Commercial (Global)', value: 'login.microsoftonline.com' },
+ { label: 'US Government (GCC High)', value: 'login.microsoftonline.us' },
+ ],
+ },
+});
+
+export const microsoft365PlannerAuth = PieceAuth.OAuth2({
+ description: authDesc,
+ props: {
+ cloud: microsoftCloudProperty,
+ },
+ authUrl: 'https://{cloud}/common/oauth2/v2.0/authorize',
+ tokenUrl: 'https://{cloud}/common/oauth2/v2.0/token',
+ required: true,
+ scope: [
+ 'Tasks.ReadWrite',
+ 'User.Read',
+ 'User.ReadBasic.All',
+ 'Group.Read.All',
+ 'openid',
+ 'email',
+ 'profile',
+ 'offline_access',
+ ],
+ prompt: 'omit',
+});
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/ai-props.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/ai-props.ts
new file mode 100644
index 00000000000..3c53acc780b
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/common/ai-props.ts
@@ -0,0 +1,51 @@
+import { Property } from '@activepieces/pieces-framework';
+
+import type { PropParams } from './props';
+
+function groupId<R extends boolean>({
+ required,
+ displayName = 'Group ID',
+ description = 'ID (GUID) of a Microsoft 365 group. Use List Groups to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function planId<R extends boolean>({
+ required,
+ displayName = 'Plan ID',
+ description = 'Planner plan ID. Use List Plans to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function bucketId<R extends boolean>({
+ required,
+ displayName = 'Bucket ID',
+ description = 'Planner bucket ID. Use List Buckets to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function taskId<R extends boolean>({
+ required,
+ displayName = 'Task ID',
+ description = 'Planner task ID. Use List Plan Tasks, List Bucket Tasks or List My Tasks to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function userIds<R extends boolean>({
+ required,
+ displayName = 'User IDs',
+ description = 'User IDs (GUIDs). Use List Group Members or Get Current User to find them.',
+}: PropParams<R>) {
+ return Property.Array({ displayName, description, required });
+}
+
+export const microsoft365PlannerAiProps = {
+ groupId,
+ planId,
+ bucketId,
+ taskId,
+ userIds,
+};
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/api.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/api.ts
new file mode 100644
index 00000000000..c5e6e9de917
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/common/api.ts
@@ -0,0 +1,643 @@
+import { microsoft365PlannerClient } from './client';
+
+import type {
+ Group,
+ Microsoft365PlannerAuthValue,
+ Microsoft365PlannerCreateBucketParams,
+ Microsoft365PlannerCreateTaskParams,
+ Microsoft365PlannerEtagged,
+ Microsoft365PlannerDirectoryObject,
+ Microsoft365PlannerList,
+ Microsoft365PlannerPage,
+ Microsoft365PlannerUpdateTaskParams,
+ PlannerBucket,
+ PlannerPlan,
+ PlannerPlanDetails,
+ PlannerTask,
+ PlannerTaskDetails,
+ User,
+} from './types';
+import type { Client } from '@microsoft/microsoft-graph-client';
+
+async function getEtag({
+ auth,
+ path,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ path: string;
+}): Promise<string> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerEtagged = await client.api(path).get();
+ return response['@odata.etag'];
+}
+
+async function updateWithEtag<T>({
+ auth,
+ path,
+ body,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ path: string;
+ body: Record<string, unknown>;
+}): Promise<T> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path });
+ const response: T = await client
+ .api(path)
+ .header('If-Match', etag)
+ .header('Prefer', 'return=representation')
+ .update(body);
+ return response;
+}
+
+async function deleteWithEtag({
+ auth,
+ path,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ path: string;
+}): Promise<void> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path });
+ await client.api(path).header('If-Match', etag).delete();
+}
+
+async function getUser({
+ auth,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<User> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const user: User = await client.api('/me').get();
+ return user;
+}
+
+async function listUnifiedGroups({
+ auth,
+ limit,
+ cursor,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ limit: number;
+ cursor?: string;
+}): Promise<Microsoft365PlannerPage<Group>> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<Group> = await client
+ .api('/groups')
+ .filter("groupTypes/any(c:c eq 'Unified')")
+ .select('id,displayName,description,mail,visibility,createdDateTime')
+ .top(limit)
+ .query(cursor ? { $skiptoken: cursor } : {})
+ .get();
+ return {
+ items: response.value,
+ nextCursor: skipToken({ nextLink: response['@odata.nextLink'] }),
+ };
+}
+
+async function listGroupMembers({
+ auth,
+ groupId,
+ limit,
+ cursor,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ groupId: string;
+ limit: number;
+ cursor?: string;
+}): Promise<Microsoft365PlannerPage<Microsoft365PlannerDirectoryObject>> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<Microsoft365PlannerDirectoryObject> =
+ await client
+ .api(`/groups/${groupId}/members`)
+ .select('id,displayName,mail,userPrincipalName')
+ .top(limit)
+ .query(cursor ? { $skiptoken: cursor } : {})
+ .get();
+ return {
+ items: response.value,
+ nextCursor: skipToken({ nextLink: response['@odata.nextLink'] }),
+ };
+}
+
+function skipToken({
+ nextLink,
+}: {
+ nextLink: string | undefined;
+}): string | null {
+ if (!nextLink) {
+ return null;
+ }
+ return new URL(nextLink).searchParams.get('$skiptoken');
+}
+
+async function listUsers({
+ auth,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<User[]> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<User> = await client
+ .api('/users')
+ .get();
+ return response.value;
+}
+
+async function listUserPage({
+ auth,
+ limit,
+ cursor,
+ startsWith,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ limit: number;
+ cursor?: string;
+ startsWith?: string;
+}): Promise<Microsoft365PlannerPage<User>> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const prefix = startsWith?.replace(/'/g, "''");
+ const request = client
+ .api('/users')
+ .select('id,displayName,mail,userPrincipalName')
+ .top(limit)
+ .query(cursor ? { $skiptoken: cursor } : {});
+ const response: Microsoft365PlannerList<User> = await (prefix
+ ? request.filter(
+ `startswith(displayName,'${prefix}') or startswith(mail,'${prefix}') or startswith(userPrincipalName,'${prefix}')`
+ )
+ : request
+ ).get();
+ return {
+ items: response.value,
+ nextCursor: skipToken({ nextLink: response['@odata.nextLink'] }),
+ };
+}
+
+async function listGroups({
+ auth,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<Group[]> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<Group> = await client
+ .api('/groups')
+ .get();
+ return response.value;
+}
+
+async function listPlans({
+ auth,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<PlannerPlan[]> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<PlannerPlan> = await client
+ .api('/me/planner/plans')
+ .get();
+ return response.value;
+}
+
+async function listAllPlans({
+ auth,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<PlannerPlan[]> {
+ return await listAllPages<PlannerPlan>({ auth, path: '/me/planner/plans' });
+}
+
+async function listAllBuckets({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<PlannerBucket[]> {
+ return await listAllPages<PlannerBucket>({
+ auth,
+ path: `/planner/plans/${planId}/buckets`,
+ });
+}
+
+async function listAllTasks({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<PlannerTask[]> {
+ return await listAllPages<PlannerTask>({
+ auth,
+ path: `/planner/plans/${planId}/tasks`,
+ });
+}
+
+async function listGroupPlans({
+ auth,
+ groupId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ groupId: string;
+}): Promise<PlannerPlan[]> {
+ return await listAllPages<PlannerPlan>({
+ auth,
+ path: `/groups/${groupId}/planner/plans`,
+ });
+}
+
+async function getPlan({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<PlannerPlan> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerPlan = await client
+ .api(`/planner/plans/${planId}`)
+ .get();
+ return response;
+}
+
+async function patchPlan({
+ auth,
+ planId,
+ title,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+ title: string;
+}): Promise<PlannerPlan> {
+ return await updateWithEtag<PlannerPlan>({
+ auth,
+ path: `/planner/plans/${planId}`,
+ body: { title },
+ });
+}
+
+async function deletePlan({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<void> {
+ await deleteWithEtag({ auth, path: `/planner/plans/${planId}` });
+}
+
+async function getPlanDetails({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<PlannerPlanDetails> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerPlanDetails = await client
+ .api(`/planner/plans/${planId}/details`)
+ .get();
+ return response;
+}
+
+async function patchPlanDetails({
+ auth,
+ planId,
+ categoryDescriptions,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+ categoryDescriptions: Record<string, unknown>;
+}): Promise<PlannerPlanDetails> {
+ return await updateWithEtag<PlannerPlanDetails>({
+ auth,
+ path: `/planner/plans/${planId}/details`,
+ body: { categoryDescriptions },
+ });
+}
+
+async function createPlan({
+ auth,
+ groupId,
+ title,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ groupId: string;
+ title: string;
+}): Promise<PlannerPlan> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const graphBaseUrl = microsoft365PlannerClient.baseUrl({ auth });
+ const response: PlannerPlan = await client.api('/planner/plans').create({
+ container: {
+ url: `${graphBaseUrl}/v1.0/groups/${groupId}`,
+ },
+ title,
+ });
+ return response;
+}
+
+async function updatePlan({
+ auth,
+ id,
+ title,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ id: string;
+ title: string;
+}): Promise<{ success: boolean }> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path: `/planner/plans/${id}` });
+ await client
+ .api(`/planner/plans/${id}`)
+ .header('If-Match', etag)
+ .update({ title });
+ return { success: true };
+}
+
+async function listBuckets({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<PlannerBucket[]> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<PlannerBucket> = await client
+ .api(`/planner/plans/${planId}/buckets`)
+ .get();
+ return response.value;
+}
+
+async function getBucket({
+ auth,
+ bucketId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ bucketId: string;
+}): Promise<PlannerBucket> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerBucket = await client
+ .api(`/planner/buckets/${bucketId}`)
+ .get();
+ return response;
+}
+
+async function patchBucket({
+ auth,
+ bucketId,
+ fields,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ bucketId: string;
+ fields: Record<string, unknown>;
+}): Promise<PlannerBucket> {
+ return await updateWithEtag<PlannerBucket>({
+ auth,
+ path: `/planner/buckets/${bucketId}`,
+ body: fields,
+ });
+}
+
+async function createBucket({
+ auth,
+ ...bucketParams
+}: Microsoft365PlannerCreateBucketParams & {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<PlannerBucket> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerBucket = await client
+ .api('/planner/buckets')
+ .create(bucketParams);
+ return response;
+}
+
+async function updateBucket({
+ auth,
+ id,
+ name,
+ orderHint,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ id: string;
+ name?: string;
+ orderHint?: string;
+}): Promise<{ success: boolean }> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path: `/planner/buckets/${id}` });
+ await client
+ .api(`/planner/buckets/${id}`)
+ .header('If-Match', etag)
+ .update({ name, orderHint });
+ return { success: true };
+}
+
+async function deleteBucket({
+ auth,
+ id,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ id: string;
+}): Promise<{ success: boolean }> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path: `/planner/buckets/${id}` });
+ await client.api(`/planner/buckets/${id}`).header('If-Match', etag).delete();
+ return { success: true };
+}
+
+async function listTasks({
+ auth,
+ planId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ planId: string;
+}): Promise<PlannerTask[]> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: Microsoft365PlannerList<PlannerTask> = await client
+ .api(`/planner/plans/${planId}/tasks`)
+ .get();
+ return response.value;
+}
+
+async function listBucketTasks({
+ auth,
+ bucketId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ bucketId: string;
+}): Promise<PlannerTask[]> {
+ return await listAllPages<PlannerTask>({
+ auth,
+ path: `/planner/buckets/${bucketId}/tasks`,
+ });
+}
+
+async function listMyTasks({
+ auth,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<PlannerTask[]> {
+ return await listAllPages<PlannerTask>({ auth, path: '/me/planner/tasks' });
+}
+
+async function getTask({
+ auth,
+ taskId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ taskId: string;
+}): Promise<PlannerTask> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerTask = await client
+ .api(`/planner/tasks/${taskId}`)
+ .get();
+ return response;
+}
+
+async function patchTask({
+ auth,
+ taskId,
+ fields,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ taskId: string;
+ fields: Record<string, unknown>;
+}): Promise<PlannerTask> {
+ return await updateWithEtag<PlannerTask>({
+ auth,
+ path: `/planner/tasks/${taskId}`,
+ body: fields,
+ });
+}
+
+async function getTaskDetails({
+ auth,
+ taskId,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ taskId: string;
+}): Promise<PlannerTaskDetails> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerTaskDetails = await client
+ .api(`/planner/tasks/${taskId}/details`)
+ .get();
+ return response;
+}
+
+async function patchTaskDetails({
+ auth,
+ taskId,
+ fields,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ taskId: string;
+ fields: Record<string, unknown>;
+}): Promise<PlannerTaskDetails> {
+ return await updateWithEtag<PlannerTaskDetails>({
+ auth,
+ path: `/planner/tasks/${taskId}/details`,
+ body: fields,
+ });
+}
+
+async function createTask({
+ auth,
+ ...taskParams
+}: Microsoft365PlannerCreateTaskParams & {
+ auth: Microsoft365PlannerAuthValue;
+}): Promise<PlannerTask> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const response: PlannerTask = await client
+ .api('/planner/tasks')
+ .create(taskParams);
+ return response;
+}
+
+async function updateTask({
+ auth,
+ id,
+ ...taskParams
+}: Microsoft365PlannerUpdateTaskParams & {
+ auth: Microsoft365PlannerAuthValue;
+ id: string;
+}): Promise<{ success: boolean }> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path: `/planner/tasks/${id}` });
+ await client
+ .api(`/planner/tasks/${id}`)
+ .header('If-Match', etag)
+ .update(taskParams);
+ return { success: true };
+}
+
+async function deleteTask({
+ auth,
+ id,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ id: string;
+}): Promise<{ success: boolean }> {
+ const client = microsoft365PlannerClient.create({ auth });
+ const etag = await getEtag({ auth, path: `/planner/tasks/${id}` });
+ await client.api(`/planner/tasks/${id}`).header('If-Match', etag).delete();
+ return { success: true };
+}
+
+export const microsoft365PlannerApi = {
+ getUser,
+ listUsers,
+ listUserPage,
+ listGroups,
+ listUnifiedGroups,
+ listGroupMembers,
+ listPlans,
+ listAllPlans,
+ listGroupPlans,
+ getPlan,
+ createPlan,
+ updatePlan,
+ patchPlan,
+ deletePlan,
+ getPlanDetails,
+ patchPlanDetails,
+ listBuckets,
+ listAllBuckets,
+ getBucket,
+ createBucket,
+ updateBucket,
+ patchBucket,
+ deleteBucket,
+ listTasks,
+ listAllTasks,
+ listBucketTasks,
+ listMyTasks,
+ getTask,
+ createTask,
+ updateTask,
+ patchTask,
+ getTaskDetails,
+ patchTaskDetails,
+ deleteTask,
+};
+
+async function listAllPages<T>({
+ auth,
+ path,
+}: {
+ auth: Microsoft365PlannerAuthValue;
+ path: string;
+}): Promise<T[]> {
+ const client = microsoft365PlannerClient.create({ auth });
+ return await collectPages<T>({ client, url: path });
+}
+
+async function collectPages<T>({
+ client,
+ url,
+}: {
+ client: Client;
+ url: string;
+}): Promise<T[]> {
+ const response: Microsoft365PlannerList<T> = await client.api(url).get();
+ const nextLink = response['@odata.nextLink'];
+ return nextLink
+ ? [...response.value, ...(await collectPages<T>({ client, url: nextLink }))]
+ : response.value;
+}
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/client.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/client.ts
new file mode 100644
index 00000000000..f4489868528
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/common/client.ts
@@ -0,0 +1,28 @@
+import { Client } from '@microsoft/microsoft-graph-client';
+
+import type { Microsoft365PlannerAuthValue } from './types';
+
+function baseUrl({ auth }: { auth: Microsoft365PlannerAuthValue }): string {
+ const host = auth.props?.cloud ?? COMMERCIAL_LOGIN_HOST;
+ return GRAPH_BASE_URLS[host] ?? GRAPH_BASE_URLS[COMMERCIAL_LOGIN_HOST];
+}
+
+function create({ auth }: { auth: Microsoft365PlannerAuthValue }): Client {
+ return Client.initWithMiddleware({
+ authProvider: {
+ getAccessToken: async () => {
+ return auth.access_token;
+ },
+ },
+ baseUrl: baseUrl({ auth }),
+ });
+}
+
+export const microsoft365PlannerClient = { baseUrl, create };
+
+const COMMERCIAL_LOGIN_HOST = 'login.microsoftonline.com';
+
+const GRAPH_BASE_URLS: Record<string, string> = {
+ [COMMERCIAL_LOGIN_HOST]: 'https://graph.microsoft.com',
+ 'login.microsoftonline.us': 'https://graph.microsoft.us',
+};
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/index.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/index.ts
deleted file mode 100644
index 5c82e87ab1f..00000000000
--- a/packages/pieces/community/microsoft-365-planner/src/lib/common/index.ts
+++ /dev/null
@@ -1,227 +0,0 @@
-import { PieceAuth } from '@activepieces/pieces-framework';
-import { microsoftCloudProperty, getGraphBaseUrl, getMicrosoftCloudFromAuth } from './microsoft-cloud';
-import { Client } from '@microsoft/microsoft-graph-client';
-import { PlannerBucket } from '@microsoft/microsoft-graph-types';
-import {
- AuthenticationParams,
- CreateBucketParams,
- CreateBucketResponse,
- CreatePlanParams,
- CreatePlanResponse,
- CreateTaskParams,
- CreateTaskResponse,
- DeleteBucketParams,
- DeleteTaskParams,
- GetBucketDetailsParams,
- GetUserResponse,
- ListBucketsParams,
- ListBucketsResponse,
- ListGroupsResponse,
- ListPlansResponse,
- ListTasksParams,
- ListTasksResponse,
- ListUserResponse,
- UpdateBucketParams,
- UpdatePlanParams,
- UpdateTaskParams,
-} from './types';
-
-const authDesc = `
-If you'd like to use your own custom Azure app instead of the default app, follow the [Azure app creation guide](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app#register-an-application),
- set the **Redirect URI** to {{redirectUrl}} and add the following **Microsoft Graph (Delegated) permissions** under **API permissions**:
- - Group.Read.All
- - Tasks.ReadWrite
- - User.Read`;
-
-export const microsoft365PlannerAuth = PieceAuth.OAuth2({
- description: authDesc,
- props: {
- cloud: microsoftCloudProperty,
- },
- authUrl: 'https://{cloud}/common/oauth2/v2.0/authorize',
- tokenUrl: 'https://{cloud}/common/oauth2/v2.0/token',
- required: true,
- scope: ['Tasks.ReadWrite', 'User.Read', 'Group.Read.All', 'openid', 'email', 'profile'],
- prompt: 'omit',
-});
-
-export const microsoft365PlannerCommon = {
- endpoints: {
- createPlan: '/planner/plans',
- listPlans: '/me/planner/plans',
- listGroups: '/groups',
- planDetail: (id: string) => `/planner/plans/${id}`,
- listBuckets: (planId: string) => `/planner/plans/${planId}/buckets`,
- listPlanTasks: (planId: string) => `/planner/plans/${planId}/tasks`,
- createBucket: '/planner/buckets',
- bucketDetail: (id: string) => `/planner/buckets/${id}`,
- createTask: '/planner/tasks',
- deleteTask: (id: string) => `/planner/tasks/${id}`,
- },
- getClient: ({ auth }: AuthenticationParams) => {
- const cloud = getMicrosoftCloudFromAuth(auth);
- return Client.initWithMiddleware({
- authProvider: {
- getAccessToken: async () => {
- return auth.access_token;
- },
- },
- baseUrl: getGraphBaseUrl(cloud),
- });
- },
- getUser: async ({ auth }: AuthenticationParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const user: GetUserResponse = await client.api('/me').get();
- return user;
- },
- getEtag: async ({
- auth,
- id,
- endpointType,
- }: AuthenticationParams & {
- id: string;
- endpointType:
- | 'planDetail'
- | 'listBuckets'
- | 'listPlanTasks'
- | 'bucketDetail'
- | 'deleteTask'
- | 'deleteTask';
- }) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const endpointFn = microsoft365PlannerCommon.endpoints[endpointType] as (
- arg: string
- ) => string;
- const endpoint = endpointFn(id);
- const response = await client.api(endpoint).get();
- return (response as any)['@odata.etag'] as string;
- },
- listUsers: async ({ auth }: AuthenticationParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: ListUserResponse = await client.api('/users').get();
- return response.value;
- },
- listGroups: async ({ auth }: AuthenticationParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: ListGroupsResponse = await client
- .api(microsoft365PlannerCommon.endpoints.listGroups)
- .get();
- return response.value;
- },
- listPlans: async ({ auth }: AuthenticationParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: ListPlansResponse = await client
- .api(microsoft365PlannerCommon.endpoints.listPlans)
- .get();
- return response.value;
- },
- listBuckets: async ({ auth, planId }: ListBucketsParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: ListBucketsResponse = await client
- .api(microsoft365PlannerCommon.endpoints.listBuckets(planId))
- .get();
- return response.value;
- },
- listTasks: async ({ auth, planId }: ListTasksParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
-
- const response: ListTasksResponse = await client
- .api(microsoft365PlannerCommon.endpoints.listPlanTasks(planId))
- .get();
- return response.value;
- },
- createPlan: async ({ auth, ...planParams }: CreatePlanParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: CreatePlanResponse = await client
- .api(microsoft365PlannerCommon.endpoints.createPlan)
- .create(planParams);
- return response;
- },
- createBucket: async ({ auth, ...bucketParams }: CreateBucketParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: CreateBucketResponse = await client
- .api(microsoft365PlannerCommon.endpoints.createBucket)
- .create(bucketParams);
- return response;
- },
- updateBucket: async ({ auth, id, name, orderHint }: UpdateBucketParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const etag = await microsoft365PlannerCommon.getEtag({
- auth,
- id,
- endpointType: 'bucketDetail',
- });
- await client
- .api(microsoft365PlannerCommon.endpoints.bucketDetail(id))
- .header('If-Match', etag)
- .update({ name, orderHint });
- return { success: true };
- },
- deleteTask: async ({ auth, id }: DeleteTaskParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const etag = await microsoft365PlannerCommon.getEtag({
- auth,
- id,
- endpointType: 'deleteTask',
- });
- await client
- .api(microsoft365PlannerCommon.endpoints.deleteTask(id))
- .header('If-Match', etag)
- .delete();
- return { success: true };
- },
- createTask: async ({ auth, ...taskParams }: CreateTaskParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: CreateTaskResponse = await client
- .api(microsoft365PlannerCommon.endpoints.createTask)
- .create(taskParams);
- return response;
- },
- updateTask: async ({ auth, id, ...taskParams }: UpdateTaskParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const etag = await microsoft365PlannerCommon.getEtag({
- auth,
- id,
- endpointType: 'deleteTask',
- });
- await client
- .api(microsoft365PlannerCommon.endpoints.deleteTask(id))
- .header('If-Match', etag)
- .update(taskParams);
- return { success: true };
- },
- deleteBucket: async ({ auth, id }: DeleteBucketParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const etag = await microsoft365PlannerCommon.getEtag({
- auth,
- id,
- endpointType: 'bucketDetail',
- });
- await client
- .api(microsoft365PlannerCommon.endpoints.bucketDetail(id))
- .header('If-Match', etag)
- .delete();
- return { success: true };
- },
-
- updatePlan: async ({ auth, id, title }: UpdatePlanParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const etag = await microsoft365PlannerCommon.getEtag({
- auth,
- id,
- endpointType: 'planDetail',
- });
- await client
- .api(microsoft365PlannerCommon.endpoints.planDetail(id))
- .header('If-Match', etag)
- .update({ title });
- return { success: true };
- },
- getBucketDetails: async ({ auth, bucketId }: GetBucketDetailsParams) => {
- const client = microsoft365PlannerCommon.getClient({ auth });
- const response: PlannerBucket = await client
- .api(microsoft365PlannerCommon.endpoints.bucketDetail(bucketId))
- .get();
- return response;
- },
-};
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/microsoft-cloud.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/microsoft-cloud.ts
deleted file mode 100644
index 065a7056060..00000000000
--- a/packages/pieces/community/microsoft-365-planner/src/lib/common/microsoft-cloud.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { OAuth2PropertyValue, Property } from '@activepieces/pieces-framework';
-
-const COMMERCIAL_LOGIN_HOST = 'login.microsoftonline.com';
-const GOV_LOGIN_HOST = 'login.microsoftonline.us';
-
-const GRAPH_BASE_URLS: Record<string, string> = {
- [COMMERCIAL_LOGIN_HOST]: 'https://graph.microsoft.com',
- [GOV_LOGIN_HOST]: 'https://graph.microsoft.us',
-};
-
-export const microsoftCloudProperty = Property.StaticDropdown({
- displayName: 'Cloud Environment',
- description: 'Select your Microsoft cloud environment.',
- required: true,
- defaultValue: COMMERCIAL_LOGIN_HOST,
- options: {
- disabled: false,
- options: [
- { label: 'Commercial (Global)', value: COMMERCIAL_LOGIN_HOST },
- { label: 'US Government (GCC High)', value: GOV_LOGIN_HOST },
- ],
- },
-});
-
-function resolveCloudHost(cloudLoginHost: string | undefined | null): string {
- return cloudLoginHost ?? COMMERCIAL_LOGIN_HOST;
-}
-
-export function getMicrosoftCloudFromAuth(auth: OAuth2PropertyValue): string {
- return resolveCloudHost(auth.props?.['cloud'] as string | undefined);
-}
-
-export function getGraphBaseUrl(cloudLoginHost: string | undefined | null): string {
- const host = resolveCloudHost(cloudLoginHost);
- return GRAPH_BASE_URLS[host] ?? GRAPH_BASE_URLS[COMMERCIAL_LOGIN_HOST];
-}
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/properties.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/properties.ts
deleted file mode 100644
index c70365feabd..00000000000
--- a/packages/pieces/community/microsoft-365-planner/src/lib/common/properties.ts
+++ /dev/null
@@ -1,151 +0,0 @@
-import { OAuth2PropertyValue, Property } from '@activepieces/pieces-framework';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '.';
-
-export const groupDropdown = ({ required = true }) =>
- Property.Dropdown({
- auth: microsoft365PlannerAuth,
- displayName: 'Group',
- description: 'Select the Grroup',
- required: required,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select an authentication first',
- };
- }
- const groups = await microsoft365PlannerCommon.listGroups({ auth });
- return {
- options: groups.map((group) => ({
- label: group.displayName ?? '',
- value: group.id ?? '',
- })),
- disabled: false,
- placeholder: 'Select a group',
- };
- },
- });
-
-export const PlanDropdown = ({ required = true }) =>
- Property.Dropdown({
- auth: microsoft365PlannerAuth,
- displayName: 'Plan',
- description: 'Select the plan',
- required: required,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select an authentication first',
- };
- }
- const plans = await microsoft365PlannerCommon.listPlans({ auth });
- return {
- options: plans.map((plan) => ({
- label: plan.title ?? '',
- value: plan.id ?? '',
- })),
- disabled: false,
- placeholder: 'Select a plan',
- };
- },
- });
-
-export const BucketDropdown = ({ required = true }) =>
- Property.Dropdown({
- auth: microsoft365PlannerAuth,
- displayName: 'Bucket',
- description: 'Select the bucket',
- required: required,
- refreshers: ['auth', 'planId'],
- options: async ({
- auth,
- planId,
- }: {
- auth?: OAuth2PropertyValue | null;
- planId?: string;
- }) => {
- if (!auth) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select an authentication first',
- };
- }
- if (!planId) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select a plan first',
- };
- }
- const buckets = await microsoft365PlannerCommon.listBuckets({
- auth,
- planId,
- });
- console.log("Buckets:", JSON.stringify(buckets));
- return {
- options: buckets.map((bucket) => ({
- label: bucket.name ?? '',
- value: bucket.id ?? '',
- })),
- disabled: false,
- placeholder: 'Select a bucket',
- };
- },
- });
-
-export const TaskDropdown = ({ required = true }) =>
- Property.Dropdown({
- auth: microsoft365PlannerAuth,
- displayName: 'Task',
- description: 'Select the task',
- required: required,
- refreshers: ['auth', 'planId'],
- options: async ({
- auth,
- planId,
- }: {
- auth?: OAuth2PropertyValue | null;
- planId?: string;
- }) => {
- if (!auth) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select an authentication first',
- };
- }
- if (!planId) {
- return {
- options: [],
- disabled: true,
- placeholder: 'Please select a plan first',
- };
- }
- const tasks = await microsoft365PlannerCommon.listTasks({
- auth,
- planId,
- });
- return {
- options: tasks.map((task) => ({
- label: task.title ?? '',
- value: task.id ?? '',
- })),
- disabled: false,
- placeholder: 'Select a task',
- };
- },
- });
-
-export const OrderHintProperty = ({ required = false }) =>
- Property.ShortText({
- displayName: 'Order Hint',
- description:
- 'Hint used to order items of this type in a list. The format is defined as outlined here: https://learn.microsoft.com/en-us/graph/api/resources/planner-order-hint-format?view=graph-rest-1.0',
- required: required,
- });
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/props.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/props.ts
new file mode 100644
index 00000000000..be1e7f71dc7
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/common/props.ts
@@ -0,0 +1,197 @@
+import { DropdownState, Property } from '@activepieces/pieces-framework';
+
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from './api';
+
+function groupId<R extends boolean>({
+ required,
+ displayName = 'Group',
+ description = 'Select the Grroup',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: microsoft365PlannerAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please select an authentication first',
+ });
+ }
+ const groups = await microsoft365PlannerApi.listGroups({ auth });
+ return {
+ options: groups.map((group) => ({
+ label: group.displayName ?? '',
+ value: group.id ?? '',
+ })),
+ disabled: false,
+ placeholder: 'Select a group',
+ };
+ },
+ });
+}
+
+function planId<R extends boolean>({
+ required,
+ displayName = 'Plan',
+ description = 'Select the plan',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: microsoft365PlannerAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please select an authentication first',
+ });
+ }
+ const plans = await microsoft365PlannerApi.listPlans({ auth });
+ return {
+ options: plans.map((plan) => ({
+ label: plan.title ?? '',
+ value: plan.id ?? '',
+ })),
+ disabled: false,
+ placeholder: 'Select a plan',
+ };
+ },
+ });
+}
+
+function bucketId<R extends boolean>({
+ required,
+ displayName = 'Bucket',
+ description = 'Select the bucket',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: microsoft365PlannerAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth', 'planId'],
+ options: async ({ auth, planId }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please select an authentication first',
+ });
+ }
+ if (!planId) {
+ return disabledOptions({ placeholder: 'Please select a plan first' });
+ }
+ const buckets = await microsoft365PlannerApi.listBuckets({
+ auth,
+ planId: String(planId),
+ });
+ return {
+ options: buckets.map((bucket) => ({
+ label: bucket.name ?? '',
+ value: bucket.id ?? '',
+ })),
+ disabled: false,
+ placeholder: 'Select a bucket',
+ };
+ },
+ });
+}
+
+function taskId<R extends boolean>({
+ required,
+ displayName = 'Task',
+ description = 'Select the task',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: microsoft365PlannerAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth', 'planId'],
+ options: async ({ auth, planId }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please select an authentication first',
+ });
+ }
+ if (!planId) {
+ return disabledOptions({ placeholder: 'Please select a plan first' });
+ }
+ const tasks = await microsoft365PlannerApi.listTasks({
+ auth,
+ planId: String(planId),
+ });
+ return {
+ options: tasks.map((task) => ({
+ label: task.title ?? '',
+ value: task.id ?? '',
+ })),
+ disabled: false,
+ placeholder: 'Select a task',
+ };
+ },
+ });
+}
+
+function assignments<R extends boolean>({
+ required,
+ displayName = 'Assignments',
+ description = 'Select users to assign the task to. If left empty, the task will be unassigned.',
+}: PropParams<R>) {
+ return Property.MultiSelectDropdown({
+ auth: microsoft365PlannerAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({
+ placeholder: 'Please select an authentication first',
+ });
+ }
+ const users = await microsoft365PlannerApi.listUsers({ auth });
+ return {
+ options: users.map((user) => ({
+ label: user.displayName || user.userPrincipalName || 'No Name',
+ value: user.id || '',
+ })),
+ disabled: false,
+ placeholder: 'Select users to assign the task to',
+ };
+ },
+ });
+}
+
+function orderHint<R extends boolean>({
+ required,
+ displayName = 'Order Hint',
+ description = 'Hint used to order items of this type in a list. The format is defined as outlined here: https://learn.microsoft.com/en-us/graph/api/resources/planner-order-hint-format?view=graph-rest-1.0',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function disabledOptions({
+ placeholder,
+}: {
+ placeholder: string;
+}): DropdownState<never> {
+ return { disabled: true, options: [], placeholder };
+}
+
+export const microsoft365PlannerProps = {
+ groupId,
+ planId,
+ bucketId,
+ taskId,
+ assignments,
+ orderHint,
+};
+
+export type PropParams<R extends boolean> = {
+ required: R;
+ displayName?: string;
+ description?: string;
+};
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/types.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/types.ts
index a5fab93d6ea..c1746fe17dc 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/common/types.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/common/types.ts
@@ -1,108 +1,59 @@
-import { OAuth2PropertyValue } from '@activepieces/pieces-framework';
-import {
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+import type {
+ PlannerBucket,
+ PlannerTask,
+ User,
+} from '@microsoft/microsoft-graph-types';
+
+export type {
Group,
PlannerBucket,
PlannerPlan,
- PlannerPlanContainer,
+ PlannerPlanDetails,
PlannerTask,
- User
+ PlannerTaskDetails,
+ User,
} from '@microsoft/microsoft-graph-types';
-export interface AuthenticationParams {
- auth: OAuth2PropertyValue;
-}
-
-export interface GenericDetailParams extends AuthenticationParams {
- id: string;
-}
-
-// API Types
-export interface ListPlansResponse {
- value: PlannerPlan[];
-}
-
-export interface ListGroupsResponse {
- value: Group[];
-}
-
-export interface ListBucketsParams extends AuthenticationParams {
- planId: string;
-}
-
-export interface ListBucketsResponse {
- value: PlannerBucket[];
-}
-
-export interface ListTasksParams extends AuthenticationParams {
- planId: string;
-}
+export type Microsoft365PlannerAuthValue = {
+ type:
+ | AppConnectionType.OAUTH2
+ | AppConnectionType.CLOUD_OAUTH2
+ | AppConnectionType.PLATFORM_OAUTH2;
+ access_token: string;
+ props?: { cloud?: string | null };
+};
-export interface ListTasksResponse {
- value: PlannerTask[];
-}
+export type Microsoft365PlannerList<T> = {
+ value: T[];
+ '@odata.nextLink'?: string;
+};
-export interface CreatePlanParams extends AuthenticationParams {
- title: string;
- container: PlannerPlanContainer;
-}
+export type Microsoft365PlannerPage<T> = { items: T[]; nextCursor: string | null };
-export type CreatePlanResponse = PlannerPlan;
+export type Microsoft365PlannerDirectoryObject = User & { '@odata.type'?: string };
-export interface CreateBucketParams
- extends AuthenticationParams,
- Omit<PlannerBucket, 'id'> {}
+export type Microsoft365PlannerEtagged = { '@odata.etag': string };
-export type CreateBucketResponse = PlannerBucket;
+export type Microsoft365PlannerCreateBucketParams = Omit<PlannerBucket, 'id'>;
-export interface CreateTaskParams
- extends AuthenticationParams,
- Omit<PlannerTask, 'id'> {}
+export type Microsoft365PlannerCreateTaskParams = Omit<PlannerTask, 'id'>;
-export type CreateTaskResponse = PlannerTask;
-
-export type DeleteBucketParams = GenericDetailParams;
-
-export type DeleteTaskParams = GenericDetailParams;
-
-export interface UpdatePlanParams extends AuthenticationParams {
- id: string;
- title: string;
-}
-
-export interface UpdateBucketParams extends AuthenticationParams {
- id: string;
- name?: string;
- orderHint?: string;
-}
-
-export interface UpdateTaskParams
- extends AuthenticationParams,
- Omit<
- PlannerTask,
- | 'activeChecklistItemCount'
- | 'checklistItemCount'
- | 'completedBy'
- | 'completedDateTime'
- | 'createdBy'
- | 'createdDateTime'
- | 'hasDescription'
- | 'planId'
- | 'previewType'
- | 'referenceCount'
- | 'assignedToTaskBoardFormat'
- | 'bucketTaskBoardFormat'
- | 'details'
- | 'progressTaskBoardFormat'
- > {
- id: string;
-}
-
-export interface GetBucketDetailsParams extends AuthenticationParams {
- bucketId: string;
-}
-
-export type GetUserResponse = User;
-
-export interface ListUserResponse {
- value: User[];
-}
+export type Microsoft365PlannerUpdateTaskParams = Omit<
+ PlannerTask,
+ | 'id'
+ | 'activeChecklistItemCount'
+ | 'checklistItemCount'
+ | 'completedBy'
+ | 'completedDateTime'
+ | 'createdBy'
+ | 'createdDateTime'
+ | 'hasDescription'
+ | 'planId'
+ | 'previewType'
+ | 'referenceCount'
+ | 'assignedToTaskBoardFormat'
+ | 'bucketTaskBoardFormat'
+ | 'details'
+ | 'progressTaskBoardFormat'
+>;
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/common/utils.ts b/packages/pieces/community/microsoft-365-planner/src/lib/common/utils.ts
new file mode 100644
index 00000000000..a2f12d36c73
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/common/utils.ts
@@ -0,0 +1,27 @@
+function stringIds({
+ value,
+ propName,
+}: {
+ value: unknown[] | undefined;
+ propName: string;
+}): string[] {
+ const ids = value ?? [];
+ if (!ids.every((id): id is string => typeof id === 'string' && id !== '')) {
+ throw new Error(`${propName} must be a list of non-empty ID strings.`);
+ }
+ return ids;
+}
+
+function assignmentsFor({ userIds }: { userIds: string[] }) {
+ return Object.fromEntries(
+ userIds.map((userId) => [
+ userId,
+ {
+ '@odata.type': '#microsoft.graph.plannerAssignment',
+ orderHint: ' !',
+ },
+ ])
+ );
+}
+
+export const microsoft365PlannerUtils = { stringIds, assignmentsFor };
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/output-schemas.ts b/packages/pieces/community/microsoft-365-planner/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..1b92e57403e
--- /dev/null
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/output-schemas.ts
@@ -0,0 +1,292 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const etagField: OutputSchema['fields'][number] = {
+ key: 'etag',
+ label: 'ETag',
+ value: "['@odata.etag']",
+};
+
+const identityFields: OutputSchema['fields'] = [
+ {
+ key: 'user',
+ label: 'User',
+ children: [
+ { key: 'id', label: 'User ID' },
+ { key: 'displayName', label: 'Display Name' },
+ ],
+ },
+ {
+ key: 'application',
+ label: 'Application',
+ children: [
+ { key: 'id', label: 'Application ID' },
+ { key: 'displayName', label: 'Display Name' },
+ ],
+ },
+];
+
+const userIdentityFields = identityFields.slice(0, 1);
+
+const planFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Plan ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'owner', label: 'Owner Group ID' },
+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },
+ { key: 'createdBy', label: 'Created By', children: identityFields },
+ {
+ key: 'container',
+ label: 'Container',
+ children: [
+ { key: 'containerId', label: 'Container ID' },
+ { key: 'type', label: 'Container Type' },
+ { key: 'url', label: 'Container URL', format: 'url' },
+ ],
+ },
+ etagField,
+];
+
+const bucketFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Bucket ID' },
+ { key: 'name', label: 'Name' },
+ { key: 'planId', label: 'Plan ID' },
+ { key: 'orderHint', label: 'Order Hint' },
+ etagField,
+];
+
+const taskFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Task ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'planId', label: 'Plan ID' },
+ { key: 'bucketId', label: 'Bucket ID' },
+ { key: 'percentComplete', label: 'Percent Complete', format: 'number' },
+ { key: 'priority', label: 'Priority', format: 'number' },
+ { key: 'startDateTime', label: 'Start Date', format: 'datetime' },
+ { key: 'dueDateTime', label: 'Due Date', format: 'datetime' },
+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },
+ { key: 'completedDateTime', label: 'Completed At', format: 'datetime' },
+ { key: 'hasDescription', label: 'Has Description', format: 'boolean' },
+ { key: 'previewType', label: 'Preview Type' },
+ { key: 'referenceCount', label: 'Link Count', format: 'number' },
+ {
+ key: 'checklistItemCount',
+ label: 'Checklist Item Count',
+ format: 'number',
+ },
+ {
+ key: 'activeChecklistItemCount',
+ label: 'Open Checklist Item Count',
+ format: 'number',
+ },
+ { key: 'conversationThreadId', label: 'Conversation Thread ID' },
+ { key: 'orderHint', label: 'Order Hint' },
+ { key: 'assigneePriority', label: 'Assignee Priority' },
+ { key: 'createdBy', label: 'Created By', children: identityFields },
+ { key: 'completedBy', label: 'Completed By', children: identityFields },
+ {
+ key: 'assignments',
+ label: 'Assignments (by User ID)',
+ dynamicKey: true,
+ children: [
+ { key: 'assignedDateTime', label: 'Assigned At', format: 'datetime' },
+ { key: 'orderHint', label: 'Order Hint' },
+ { key: 'assignedBy', label: 'Assigned By', children: identityFields },
+ ],
+ },
+ {
+ key: 'appliedCategories',
+ label: 'Applied Label Categories',
+ dynamicKey: true,
+ format: 'boolean',
+ },
+ etagField,
+];
+
+const taskDetailsFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Task ID' },
+ { key: 'description', label: 'Description' },
+ { key: 'previewType', label: 'Preview Type' },
+ {
+ key: 'checklist',
+ label: 'Checklist (by Item ID)',
+ dynamicKey: true,
+ labelKey: 'title',
+ children: [
+ { key: 'title', label: 'Title' },
+ { key: 'isChecked', label: 'Is Checked', format: 'boolean' },
+ { key: 'orderHint', label: 'Order Hint' },
+ {
+ key: 'lastModifiedDateTime',
+ label: 'Last Modified At',
+ format: 'datetime',
+ },
+ {
+ key: 'lastModifiedBy',
+ label: 'Last Modified By',
+ children: userIdentityFields,
+ },
+ ],
+ },
+ {
+ key: 'references',
+ label: 'Links (by Encoded URL)',
+ dynamicKey: true,
+ labelKey: 'alias',
+ children: [
+ { key: 'alias', label: 'Name' },
+ { key: 'type', label: 'Type' },
+ { key: 'previewPriority', label: 'Preview Priority' },
+ {
+ key: 'lastModifiedDateTime',
+ label: 'Last Modified At',
+ format: 'datetime',
+ },
+ {
+ key: 'lastModifiedBy',
+ label: 'Last Modified By',
+ children: userIdentityFields,
+ },
+ ],
+ },
+ etagField,
+];
+
+const userFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'User ID' },
+ { key: 'displayName', label: 'Display Name' },
+ { key: 'mail', label: 'Email', format: 'email' },
+ { key: 'userPrincipalName', label: 'User Principal Name', format: 'email' },
+];
+
+export const microsoft365PlannerPlanOutputSchema: OutputSchema = {
+ fields: planFields,
+};
+
+export const microsoft365PlannerPlanListOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'plans', label: 'Plans', labelKey: 'title', listItems: planFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const microsoft365PlannerFindPlanOutputSchema: OutputSchema = {
+ itemLabel: '{title}',
+ fields: [{ key: 'plans', label: 'Plans', value: '', listItems: planFields }],
+};
+
+export const microsoft365PlannerPlanDetailsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Plan ID' },
+ {
+ key: 'sharedWith',
+ label: 'Shared With (by User or Group ID)',
+ dynamicKey: true,
+ format: 'boolean',
+ },
+ {
+ key: 'categoryDescriptions',
+ label: 'Label Category Names',
+ children: Array.from({ length: 25 }, (_, index) => ({
+ key: `category${index + 1}`,
+ label: `Category ${index + 1}`,
+ })),
+ },
+ etagField,
+ ],
+};
+
+export const microsoft365PlannerBucketOutputSchema: OutputSchema = {
+ fields: bucketFields,
+};
+
+export const microsoft365PlannerBucketListOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'buckets',
+ label: 'Buckets',
+ labelKey: 'name',
+ listItems: bucketFields,
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const microsoft365PlannerTaskOutputSchema: OutputSchema = {
+ fields: taskFields,
+};
+
+export const microsoft365PlannerCreatedTaskOutputSchema: OutputSchema = {
+ fields: taskFields.filter((field) => field.key !== 'appliedCategories'),
+};
+
+export const microsoft365PlannerTaskListOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'tasks', label: 'Tasks', labelKey: 'title', listItems: taskFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const microsoft365PlannerFindTaskOutputSchema: OutputSchema = {
+ itemLabel: '{title}',
+ fields: [{ key: 'tasks', label: 'Tasks', value: '', listItems: taskFields }],
+};
+
+export const microsoft365PlannerTaskDetailsOutputSchema: OutputSchema = {
+ fields: taskDetailsFields,
+};
+
+export const microsoft365PlannerDeletedOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'id', label: 'Deleted ID' },
+ ],
+};
+
+export const microsoft365PlannerSuccessOutputSchema: OutputSchema = {
+ fields: [{ key: 'success', label: 'Success', format: 'boolean' }],
+};
+
+export const microsoft365PlannerCurrentUserOutputSchema: OutputSchema = {
+ fields: [
+ ...userFields,
+ { key: 'jobTitle', label: 'Job Title' },
+ { key: 'givenName', label: 'First Name' },
+ { key: 'surname', label: 'Last Name' },
+ { key: 'businessPhones', label: 'Business Phones' },
+ { key: 'mobilePhone', label: 'Mobile Phone' },
+ { key: 'officeLocation', label: 'Office Location' },
+ { key: 'preferredLanguage', label: 'Preferred Language' },
+ ],
+};
+
+export const microsoft365PlannerGroupListOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'groups',
+ label: 'Groups',
+ labelKey: 'displayName',
+ listItems: [
+ { key: 'id', label: 'Group ID' },
+ { key: 'displayName', label: 'Display Name' },
+ { key: 'description', label: 'Description' },
+ { key: 'mail', label: 'Email', format: 'email' },
+ { key: 'visibility', label: 'Visibility' },
+ { key: 'createdDateTime', label: 'Created At', format: 'datetime' },
+ ],
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'nextCursor', label: 'Next Cursor' },
+ ],
+};
+
+export const microsoft365PlannerMemberListOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'users',
+ label: 'Members',
+ labelKey: 'displayName',
+ listItems: userFields,
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'nextCursor', label: 'Next Cursor' },
+ ],
+};
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-plan-created.ts b/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-plan-created.ts
index fe7d49fbfa4..9f852a2cdd5 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-plan-created.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-plan-created.ts
@@ -6,11 +6,12 @@ import {
import {
AppConnectionValueForAuthProperty,
createTrigger,
- PiecePropValueSchema,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerPlanOutputSchema } from '../output-schemas';
const polling: Polling<
AppConnectionValueForAuthProperty<typeof microsoft365PlannerAuth>,
@@ -18,7 +19,7 @@ const polling: Polling<
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth }) => {
- const items = await microsoft365PlannerCommon.listPlans({
+ const items = await microsoft365PlannerApi.listPlans({
auth,
});
return items.map((item) => ({
@@ -28,9 +29,10 @@ const polling: Polling<
},
};
-export const newPlanCreated = createTrigger({
+export const newPlanCreatedTrigger = createTrigger({
auth: microsoft365PlannerAuth,
name: 'newPlanCreated',
+ outputSchema: microsoft365PlannerPlanOutputSchema,
classification: 'READ',
displayName: 'New Plan Created',
description: 'Triggers when a new Plan is created in Microsoft 365 Planner.',
@@ -44,13 +46,11 @@ export const newPlanCreated = createTrigger({
return await pollingHelper.test(polling, context);
},
async onEnable(context) {
- const { store, auth, propsValue } = context;
- await pollingHelper.onEnable(polling, { store, auth, propsValue });
+ await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
- const { store, auth, propsValue } = context;
- await pollingHelper.onDisable(polling, { store, auth, propsValue });
+ await pollingHelper.onDisable(polling, context);
},
async run(context) {
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-assigned-to-user.ts b/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-assigned-to-user.ts
index f046db0f515..0a2265d13c2 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-assigned-to-user.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-assigned-to-user.ts
@@ -6,16 +6,17 @@ import {
import {
AppConnectionValueForAuthProperty,
createTrigger,
- PiecePropValueSchema,
StaticPropsValue,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerTaskOutputSchema } from '../output-schemas';
const props = {
- planId: PlanDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
};
const polling: Polling<
@@ -27,11 +28,11 @@ const polling: Polling<
if (!planId) {
return [];
}
- const user = await microsoft365PlannerCommon.getUser({ auth });
+ const user = await microsoft365PlannerApi.getUser({ auth });
if (!user || !user.id) {
throw new Error('Unable to fetch authenticated user details.');
}
- const items = await microsoft365PlannerCommon.listTasks({ auth, planId });
+ const items = await microsoft365PlannerApi.listTasks({ auth, planId });
return items
.filter((item) => {
const userId = String(user.id);
@@ -47,9 +48,10 @@ const polling: Polling<
},
};
-export const newTaskAssignedToUser = createTrigger({
+export const newTaskAssignedToUserTrigger = createTrigger({
auth: microsoft365PlannerAuth,
name: 'newTaskAssignedToUser',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
classification: 'READ',
displayName: 'New Task Assigned to User',
description:
@@ -64,13 +66,11 @@ export const newTaskAssignedToUser = createTrigger({
return await pollingHelper.test(polling, context);
},
async onEnable(context) {
- const { store, auth, propsValue } = context;
- await pollingHelper.onEnable(polling, { store, auth, propsValue });
+ await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
- const { store, auth, propsValue } = context;
- await pollingHelper.onDisable(polling, { store, auth, propsValue });
+ await pollingHelper.onDisable(polling, context);
},
async run(context) {
diff --git a/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-created.ts b/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-created.ts
index cf930705f80..5454b53d8c8 100644
--- a/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-created.ts
+++ b/packages/pieces/community/microsoft-365-planner/src/lib/triggers/new-task-created.ts
@@ -6,16 +6,17 @@ import {
import {
AppConnectionValueForAuthProperty,
createTrigger,
- PiecePropValueSchema,
StaticPropsValue,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
-import { microsoft365PlannerAuth, microsoft365PlannerCommon } from '../common';
-import { PlanDropdown } from '../common/properties';
+import { microsoft365PlannerAuth } from '../auth';
+import { microsoft365PlannerApi } from '../common/api';
+import { microsoft365PlannerProps } from '../common/props';
+import { microsoft365PlannerTaskOutputSchema } from '../output-schemas';
const props = {
- planId: PlanDropdown({ required: true }),
+ planId: microsoft365PlannerProps.planId({ required: true }),
};
const polling: Polling<
@@ -27,7 +28,7 @@ const polling: Polling<
if (!planId) {
return [];
}
- const items = await microsoft365PlannerCommon.listTasks({
+ const items = await microsoft365PlannerApi.listTasks({
auth,
planId,
});
@@ -38,9 +39,10 @@ const polling: Polling<
},
};
-export const newTaskCreated = createTrigger({
+export const newTaskCreatedTrigger = createTrigger({
auth: microsoft365PlannerAuth,
name: 'newTaskCreated',
+ outputSchema: microsoft365PlannerTaskOutputSchema,
classification: 'READ',
displayName: 'New Task Created',
description: 'Triggers when a new Task is created in Microsoft 365 Planner.',
@@ -87,13 +89,11 @@ export const newTaskCreated = createTrigger({
return await pollingHelper.test(polling, context);
},
async onEnable(context) {
- const { store, auth, propsValue } = context;
- await pollingHelper.onEnable(polling, { store, auth, propsValue });
+ await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
- const { store, auth, propsValue } = context;
- await pollingHelper.onDisable(polling, { store, auth, propsValue });
+ await pollingHelper.onDisable(polling, context);
},
async run(context) {