AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(clickup): keep items resolved, time billable and multiple assignees on when an agent edits them (#16737)
Kishan Parmarb529ea9525b4
diff --git a/bun.lock b/bun.lockindex 2220ab92f12..dfd03ea0edf 100644--- a/bun.lock+++ b/bun.lock@@ -2012,7 +2012,7 @@},"packages/pieces/community/clickup": {"name": "@activepieces/piece-clickup",- "version": "0.9.1",+ "version": "0.10.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",@@ -2025,6 +2025,7 @@"devDependencies": {"@types/qs": "6.14.0","tslib": "2.6.2",+ "vitest": "3.2.6",},},"packages/pieces/community/clockify": {diff --git a/packages/pieces/community/clickup/package.json b/packages/pieces/community/clickup/package.jsonindex e65ffd7fe8d..f3f6a9ed3d1 100644--- a/packages/pieces/community/clickup/package.json+++ b/packages/pieces/community/clickup/package.json@@ -1,12 +1,13 @@{"name": "@activepieces/piece-clickup",- "version": "0.9.1",+ "version": "0.10.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {"build": "tsc -p tsconfig.lib.json && cp package.json dist/","bundle": "node ../../../../dist/packages/cli/src/index.js pieces bundle",- "lint": "eslint 'src/**/*.ts'"+ "lint": "eslint 'src/**/*.ts'",+ "test": "vitest run"},"dependencies": {"@activepieces/pieces-common": "workspace:*",@@ -19,6 +20,7 @@},"devDependencies": {"@types/qs": "6.14.0",- "tslib": "2.6.2"+ "tslib": "2.6.2",+ "vitest": "3.2.6"}}diff --git a/packages/pieces/community/clickup/src/i18n/translation.json b/packages/pieces/community/clickup/src/i18n/translation.jsonindex e7ed63214b3..d81aa339e2d 100644--- a/packages/pieces/community/clickup/src/i18n/translation.json+++ b/packages/pieces/community/clickup/src/i18n/translation.json@@ -354,7 +354,7 @@"The ID of the checklist to delete (from Create Checklist)": "The ID of the checklist to delete (from Create Checklist)","The ID of the checklist item to update": "The ID of the checklist item to update","The new text of the checklist item": "The new text of the checklist item",- "Whether the checklist item is resolved (checked)": "Whether the checklist item is resolved (checked)",+ "Whether the checklist item is resolved (checked). Leave empty or pick Leave unchanged to keep the current setting.": "Whether the checklist item is resolved (checked). Leave empty or pick Leave unchanged to keep the current setting.","The ID of another checklist item to nest this one under as a child": "The ID of another checklist item to nest this one under as a child","The ID of the checklist to update (from Create Checklist)": "The ID of the checklist to update (from Create Checklist)","The new name of the checklist": "The new name of the checklist",@@ -366,7 +366,7 @@"The ID of the comment to update (from Get Task Comments or Get Threaded Comments)": "The ID of the comment to update (from Get Task Comments or Get Threaded Comments)","The new text of the comment": "The new text of the comment","The user ID to assign the comment to": "The user ID to assign the comment to",- "Whether the comment is resolved": "Whether the comment is resolved",+ "Whether the comment is resolved. Leave empty or pick Leave unchanged to keep the current setting.": "Whether the comment is resolved. Leave empty or pick Leave unchanged to keep the current setting.","The name of the folder to create": "The name of the folder to create","The ID of the folder to delete": "The ID of the folder to delete","The ID of the folder to get": "The ID of the folder to get",@@ -383,6 +383,7 @@"The name of the space to create": "The name of the space to create","Allow tasks in this space to have multiple assignees": "Allow tasks in this space to have multiple assignees","The new name for the space": "The new name for the space",+ "Allow tasks in this space to have multiple assignees. Leave empty or pick Leave unchanged to keep the current setting.": "Allow tasks in this space to have multiple assignees. Leave empty or pick Leave unchanged to keep the current setting.","The name of the new tag": "The name of the new tag","Foreground (text) color as a hex value, e.g. #FFFFFF": "Foreground (text) color as a hex value, e.g. #FFFFFF","Background color as a hex value, e.g. #000000": "Background color as a hex value, e.g. #000000",@@ -440,7 +441,7 @@"New note for the time entry.": "New note for the time entry.","New start time for the entry.": "New start time for the entry.","New length of the entry in milliseconds.": "New length of the entry in milliseconds.",- "Whether the time entry is billable.": "Whether the time entry is billable.",+ "Whether the time entry is billable. Leave empty or pick Leave unchanged to keep the current setting.": "Whether the time entry is billable. Leave empty or pick Leave unchanged to keep the current setting.","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.",@@ -457,6 +458,9 @@"Plain Text": "Plain Text","Date Created": "Date Created","Last Updated": "Last Updated",+ "Yes": "Yes",+ "No": "No",+ "Leave unchanged": "Leave unchanged","Id": "Id","Created at": "Created at","Last updated": "Last updated",@@ -467,6 +471,20 @@"PUT": "PUT","DELETE": "DELETE","HEAD": "HEAD",+ "Location": "Location",+ "Task Details": "Task Details",+ "Dates": "Dates",+ "List Fields": "List Fields",+ "Search In": "Search In",+ "Filters": "Filters",+ "Sort and Page": "Sort and Page",+ "Time Window": "Time Window",+ "People": "People",+ "Task to Update": "Task to Update",+ "Changes": "Changes",+ "Field Value": "Field Value",+ "Request": "Request",+ "Data to send": "Data to send","Task Created": "Task Created","Task Updated": "Task Updated","Task Deleted": "Task Deleted",@@ -527,5 +545,6 @@"Triggered when a key result is updated.": "Triggered when a key result is updated.","Triggered when a key result is deleted.": "Triggered when a key result is deleted.","Triggered when a tag is added or removed or renamed on a task.": "Triggered when a tag is added or removed or renamed on a task.",- "Leave space, folder, list and task empty to listen to the whole workspace.": "Leave space, folder, list and task empty to listen to the whole workspace."+ "Leave space, folder, list and task empty to listen to the whole workspace.": "Leave space, folder, list and task empty to listen to the whole workspace.",+ "Listen In": "Listen In"}\ No newline at end of filediff --git a/packages/pieces/community/clickup/src/lib/actions/checklists/update-checklist-item.ts b/packages/pieces/community/clickup/src/lib/actions/checklists/update-checklist-item.tsindex e3ef9f923f5..75376e29266 100644--- a/packages/pieces/community/clickup/src/lib/actions/checklists/update-checklist-item.ts+++ b/packages/pieces/community/clickup/src/lib/actions/checklists/update-checklist-item.ts@@ -1,6 +1,6 @@import { Property, createAction } from '@activepieces/pieces-framework';import { HttpMethod, getAccessTokenOrThrow } from '@activepieces/pieces-common';-import { callClickUpApi } from '../../common';+import { callClickUpApi, clickupCommon } from '../../common';import { clickupAuth } from '../../auth';import { checklistOutputSchema } from '../../output-schemas';@@ -33,10 +33,10 @@ export const clickupUpdateChecklistItem = createAction({displayName: 'Item Name',required: false,}),- resolved: Property.Checkbox({- description: 'Whether the checklist item is resolved (checked)',+ resolved: clickupCommon.optionalBoolean({displayName: 'Resolved',- required: false,+ description:+ 'Whether the checklist item is resolved (checked). Leave empty or pick Leave unchanged to keep the current setting.',}),assignee: Property.Number({description: 'The user ID to assign this checklist item to',@@ -51,14 +51,17 @@ export const clickupUpdateChecklistItem = createAction({}),},async run(configValue) {- const { checklist_id, checklist_item_id, name, resolved, assignee, parent } =+ const { checklist_id, checklist_item_id, name, assignee, parent } =configValue.propsValue;+ const resolved = clickupCommon.optionalBooleanValue(+ configValue.propsValue.resolved+ );const body: Record<string, unknown> = {};if (name !== undefined && name !== null && name !== '') {body['name'] = name;}- if (resolved !== undefined && resolved !== null) {+ if (resolved !== undefined) {body['resolved'] = resolved;}if (assignee !== undefined && assignee !== null) {diff --git a/packages/pieces/community/clickup/src/lib/actions/comments/clickup-update-comment.ts b/packages/pieces/community/clickup/src/lib/actions/comments/clickup-update-comment.tsindex 053fdc36a6e..e06f4d7fd8a 100644--- a/packages/pieces/community/clickup/src/lib/actions/comments/clickup-update-comment.ts+++ b/packages/pieces/community/clickup/src/lib/actions/comments/clickup-update-comment.ts@@ -1,6 +1,6 @@import { Property, createAction } from '@activepieces/pieces-framework';import { HttpMethod, getAccessTokenOrThrow } from '@activepieces/pieces-common';-import { callClickUpApi } from '../../common';+import { callClickUpApi, clickupCommon } from '../../common';import { clickupAuth } from '../../auth';export const clickupUpdateComment = createAction({@@ -32,15 +32,17 @@ export const clickupUpdateComment = createAction({displayName: 'Assignee',required: false,}),- resolved: Property.Checkbox({- description: 'Whether the comment is resolved',+ resolved: clickupCommon.optionalBoolean({displayName: 'Resolved',- required: false,+ description:+ 'Whether the comment is resolved. Leave empty or pick Leave unchanged to keep the current setting.',}),},async run(configValue) {- const { comment_id, comment_text, assignee, resolved } =- configValue.propsValue;+ const { comment_id, comment_text, assignee } = configValue.propsValue;+ const resolved = clickupCommon.optionalBooleanValue(+ configValue.propsValue.resolved+ );const body: Record<string, unknown> = {comment_text,@@ -48,7 +50,7 @@ export const clickupUpdateComment = createAction({if (assignee !== undefined && assignee !== null) {body['assignee'] = assignee;}- if (resolved !== undefined && resolved !== null) {+ if (resolved !== undefined) {body['resolved'] = resolved;}diff --git a/packages/pieces/community/clickup/src/lib/actions/spaces/ai-update-space.ts b/packages/pieces/community/clickup/src/lib/actions/spaces/ai-update-space.tsindex 08f14a84eeb..6a7a201f373 100644--- a/packages/pieces/community/clickup/src/lib/actions/spaces/ai-update-space.ts+++ b/packages/pieces/community/clickup/src/lib/actions/spaces/ai-update-space.ts@@ -25,25 +25,48 @@ export const clickupUpdateSpace = createAction({displayName: 'Space Name',required: false,}),- multiple_assignees: Property.Checkbox({- description: 'Allow tasks in this space to have multiple assignees',+ multiple_assignees: clickupCommon.optionalBoolean({displayName: 'Multiple Assignees',- required: false,+ description:+ 'Allow tasks in this space to have multiple assignees. Leave empty or pick Leave unchanged to keep the current setting.',}),},async run(configValue) {- const { space_id, name, multiple_assignees } = configValue.propsValue;- const body: Record<string, unknown> = {};+ const { space_id, name } = configValue.propsValue;+ const accessToken = getAccessTokenOrThrow(configValue.auth);+ const multiple_assignees =+ clickupCommon.optionalBooleanValue(+ configValue.propsValue.multiple_assignees+ ) ??+ (await currentMultipleAssignees({+ accessToken,+ spaceId: String(space_id),+ }));+ const body: Record<string, unknown> = { multiple_assignees };if (name !== undefined) body['name'] = name;- if (multiple_assignees !== undefined)- body['multiple_assignees'] = multiple_assignees;const response = await callClickUpApi(HttpMethod.PUT,`space/${space_id}`,- getAccessTokenOrThrow(configValue.auth),+ accessToken,body);return response.body;},});++async function currentMultipleAssignees({+ accessToken,+ spaceId,+}: {+ accessToken: string;+ spaceId: string;+}): Promise<boolean> {+ const response = await callClickUpApi<{ multiple_assignees: boolean }>(+ HttpMethod.GET,+ `space/${spaceId}`,+ accessToken,+ undefined+ );+ return response.body.multiple_assignees;+}diff --git a/packages/pieces/community/clickup/src/lib/actions/time-tracking/update-time-entry.ts b/packages/pieces/community/clickup/src/lib/actions/time-tracking/update-time-entry.tsindex 6d845c3d8fd..fe2d6fb7abf 100644--- a/packages/pieces/community/clickup/src/lib/actions/time-tracking/update-time-entry.ts+++ b/packages/pieces/community/clickup/src/lib/actions/time-tracking/update-time-entry.ts@@ -41,15 +41,18 @@ export const clickupUpdateTimeEntry = createAction({description: 'New length of the entry in milliseconds.',required: false,}),- billable: Property.Checkbox({+ billable: clickupCommon.optionalBoolean({displayName: 'Billable',- description: 'Whether the time entry is billable.',- required: false,+ description:+ 'Whether the time entry is billable. Leave empty or pick Leave unchanged to keep the current setting.',}),},async run(context) {- const { workspace_id, timer_id, description, start, duration, billable } =+ const { workspace_id, timer_id, description, start, duration } =context.propsValue;+ const billable = clickupCommon.optionalBooleanValue(+ context.propsValue.billable+ );const auth = getAccessTokenOrThrow(context.auth);const body: Record<string, unknown> = {};diff --git a/packages/pieces/community/clickup/src/lib/common/index.ts b/packages/pieces/community/clickup/src/lib/common/index.tsindex 6335114733a..41cdb7ff202 100644--- a/packages/pieces/community/clickup/src/lib/common/index.ts+++ b/packages/pieces/community/clickup/src/lib/common/index.ts@@ -483,8 +483,41 @@ export const clickupCommon = {};},}),+ optionalBoolean: ({+ displayName,+ description,+ }: {+ displayName: string;+ description: string;+ }) =>+ Property.StaticDropdown<string, false>({+ displayName,+ description,+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Yes', value: 'yes' },+ { label: 'No', value: 'no' },+ { label: 'Leave unchanged', value: 'unchanged' },+ ],+ },+ }),+ optionalBooleanValue,};+function optionalBooleanValue(value: unknown): boolean | undefined {+ const normalized =+ typeof value === 'string' ? value.trim().toLowerCase() : value;+ if (normalized === true || normalized === 'yes' || normalized === 'true') {+ return true;+ }+ if (normalized === false || normalized === 'no' || normalized === 'false') {+ return false;+ }+ return undefined;+}+async function listWorkspaces(accessToken: string) {return (await callClickUpApi<{ teams: ClickupWorkspace[] }>(diff --git a/packages/pieces/community/clickup/test/agent-optional-booleans.test.ts b/packages/pieces/community/clickup/test/agent-optional-booleans.test.tsnew file mode 100644index 00000000000..0e6f29be8aa--- /dev/null+++ b/packages/pieces/community/clickup/test/agent-optional-booleans.test.ts@@ -0,0 +1,256 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import {+ HttpMethod,+ HttpRequest,+ httpClient,+} from '@activepieces/pieces-common';+import {+ Action,+ AppConnectionType,+ AppConnectionValueForAuthProperty,+ createMockActionContext,+ InputPropertyMap,+ PropertyType,+ StaticPropsValue,+} from '@activepieces/pieces-framework';+import { clickupAuth } from '../src/lib/auth';+import { clickupCommon } from '../src/lib/common';+import { clickupUpdateChecklistItem } from '../src/lib/actions/checklists/update-checklist-item';+import { clickupUpdateComment } from '../src/lib/actions/comments/clickup-update-comment';+import { clickupUpdateSpace } from '../src/lib/actions/spaces/ai-update-space';+import { clickupUpdateTimeEntry } from '../src/lib/actions/time-tracking/update-time-entry';++const AUTH: AppConnectionValueForAuthProperty<typeof clickupAuth> = {+ type: AppConnectionType.OAUTH2,+ access_token: 'test-token',+ client_id: 'client',+ client_secret: 'secret',+ redirect_url: 'https://example.com',+ token_type: 'Bearer',+ claimed_at: 0,+ refresh_token: 'refresh',+ scope: '',+ token_url: 'https://app.clickup.com/api/v2/oauth/token',+ data: {},+};++let requests: HttpRequest[] = [];+let currentMultipleAssignees = true;++beforeEach(() => {+ requests = [];+ currentMultipleAssignees = true;+ vi.spyOn(httpClient, 'sendRequest').mockImplementation(async (request) => {+ requests.push(request);+ return {+ status: 200,+ headers: {},+ body: { multiple_assignees: currentMultipleAssignees },+ };+ });+});++afterEach(() => {+ vi.restoreAllMocks();+});++describe('optionalBooleanValue', () => {+ it.each([true, 'yes', ' Yes ', 'TRUE', 'true'])(+ 'reads %j as true',+ (value) => {+ expect(clickupCommon.optionalBooleanValue(value)).toBe(true);+ }+ );++ it.each([false, 'no', 'NO', ' False '])('reads %j as false', (value) => {+ expect(clickupCommon.optionalBooleanValue(value)).toBe(false);+ });++ it.each([undefined, null, '', 'unchanged', 'maybe', 1])(+ 'reads %j as leave unchanged',+ (value) => {+ expect(clickupCommon.optionalBooleanValue(value)).toBeUndefined();+ }+ );+});++describe('agent-facing boolean props', () => {+ it.each([+ [clickupUpdateChecklistItem.props.resolved],+ [clickupUpdateComment.props.resolved],+ [clickupUpdateSpace.props.multiple_assignees],+ [clickupUpdateTimeEntry.props.billable],+ ])('%# is an optional Yes / No / Leave unchanged dropdown', (prop) => {+ expect(prop.type).toBe(PropertyType.STATIC_DROPDOWN);+ expect(prop.required).toBe(false);+ expect(prop.options.options.map((option) => option.value)).toEqual([+ 'yes',+ 'no',+ 'unchanged',+ ]);+ });+});++describe('Update Checklist Item', () => {+ const base = {+ checklist_id: 'cl1',+ checklist_item_id: 'it1',+ name: 'Renamed',+ assignee: undefined,+ parent: undefined,+ };++ it.each([undefined, 'unchanged', 'maybe'])(+ 'leaves resolved out of the request for %j',+ async (resolved) => {+ await run({+ action: clickupUpdateChecklistItem,+ propsValue: { ...base, resolved },+ });+ expect(requests).toHaveLength(1);+ expect(requests[0].body).toEqual({ name: 'Renamed' });+ }+ );++ it.each([+ ['yes', true],+ ['no', false],+ ])('sends resolved for %j', async (resolved, expected) => {+ await run({+ action: clickupUpdateChecklistItem,+ propsValue: { ...base, resolved },+ });+ expect(requests[0].body).toEqual({ name: 'Renamed', resolved: expected });+ });+});++describe('Update Comment', () => {+ const base = {+ comment_id: 'c1',+ comment_text: 'Edited',+ assignee: undefined,+ };++ it.each([undefined, 'unchanged'])(+ 'leaves resolved out of the request for %j',+ async (resolved) => {+ await run({+ action: clickupUpdateComment,+ propsValue: { ...base, resolved },+ });+ expect(requests[0].body).toEqual({ comment_text: 'Edited' });+ }+ );++ it.each([+ ['yes', true],+ ['no', false],+ ])('sends resolved for %j', async (resolved, expected) => {+ await run({+ action: clickupUpdateComment,+ propsValue: { ...base, resolved },+ });+ expect(requests[0].body).toEqual({+ comment_text: 'Edited',+ resolved: expected,+ });+ });+});++describe('Update Time Entry', () => {+ const base = {+ workspace_id: 'w1',+ timer_id: 't1',+ description: 'Edited',+ start: undefined,+ duration: undefined,+ };++ it.each([undefined, 'unchanged'])(+ 'leaves billable out of the request for %j',+ async (billable) => {+ await run({+ action: clickupUpdateTimeEntry,+ propsValue: { ...base, billable },+ });+ expect(requests[0].body).toEqual({ description: 'Edited' });+ }+ );++ it.each([+ ['yes', true],+ ['no', false],+ [' True ', true],+ ])('sends billable for %j', async (billable, expected) => {+ await run({+ action: clickupUpdateTimeEntry,+ propsValue: { ...base, billable },+ });+ expect(requests[0].body).toEqual({+ description: 'Edited',+ billable: expected,+ });+ });+});++describe('Update Space', () => {+ const base = { workspace_id: 'w1', space_id: 's1', name: 'Renamed' };++ it.each([+ [undefined, true],+ ['unchanged', true],+ [undefined, false],+ ['unchanged', false],+ ])(+ 'reads the current setting and sends it back for %j (current %j)',+ async (multiple_assignees, current) => {+ currentMultipleAssignees = current;+ await run({+ action: clickupUpdateSpace,+ propsValue: { ...base, multiple_assignees },+ });+ expect(requests.map((request) => request.method)).toEqual([+ HttpMethod.GET,+ HttpMethod.PUT,+ ]);+ expect(requests[0].url).toBe('https://api.clickup.com/api/v2/space/s1');+ expect(requests[1].body).toEqual({+ name: 'Renamed',+ multiple_assignees: current,+ });+ }+ );++ it.each([+ ['yes', true],+ ['no', false],+ ])(+ 'sends %j without reading the space first',+ async (multiple_assignees, expected) => {+ await run({+ action: clickupUpdateSpace,+ propsValue: { ...base, multiple_assignees },+ });+ expect(requests.map((request) => request.method)).toEqual([+ HttpMethod.PUT,+ ]);+ expect(requests[0].body).toEqual({+ name: 'Renamed',+ multiple_assignees: expected,+ });+ }+ );+});++function run<Props extends InputPropertyMap>({+ action,+ propsValue,+}: {+ action: Action<typeof clickupAuth, Props>;+ propsValue: StaticPropsValue<Props>;+}): Promise<unknown> {+ return action.run({+ ...createMockActionContext<Props>({ propsValue }),+ auth: AUTH,+ });+}diff --git a/packages/pieces/community/clickup/vitest.config.ts b/packages/pieces/community/clickup/vitest.config.tsnew file mode 100644index 00000000000..fccdb644d65--- /dev/null+++ b/packages/pieces/community/clickup/vitest.config.ts@@ -0,0 +1,25 @@+import path from 'path';+import { defineConfig } from 'vitest/config';++const repoRoot = path.resolve(__dirname, '../../../..');++export default defineConfig({+ root: __dirname,+ test: {+ globals: true,+ environment: 'node',+ include: ['test/**/*.test.ts'],+ },+ resolve: {+ alias: {+ '@activepieces/pieces-framework': path.resolve(+ repoRoot,+ 'packages/pieces/framework/src/index.ts'+ ),+ '@activepieces/pieces-common': path.resolve(+ repoRoot,+ 'packages/pieces/common/src/index.ts'+ ),+ },+ },+});