feat(clickup): add new folders trigger
This commit is contained in:
4
packages/backend/src/apps/clickup/dynamic-data/index.js
Normal file
4
packages/backend/src/apps/clickup/dynamic-data/index.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import listSpaces from './list-spaces/index.js';
|
||||||
|
import listWorkspaces from './list-workspaces/index.js';
|
||||||
|
|
||||||
|
export default [listSpaces, listWorkspaces];
|
@@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List spaces',
|
||||||
|
key: 'listSpaces',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const spaces = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
const workspaceId = $.step.parameters.workspaceId;
|
||||||
|
|
||||||
|
if (!workspaceId) {
|
||||||
|
return spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/v2/team/${workspaceId}/space`);
|
||||||
|
|
||||||
|
if (data.spaces) {
|
||||||
|
for (const space of data.spaces) {
|
||||||
|
spaces.data.push({
|
||||||
|
value: space.id,
|
||||||
|
name: space.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spaces;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,23 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List workspaces',
|
||||||
|
key: 'listWorkspaces',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const workspaces = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get('/v2/team');
|
||||||
|
|
||||||
|
if (data.teams) {
|
||||||
|
for (const workspace of data.teams) {
|
||||||
|
workspaces.data.push({
|
||||||
|
value: workspace.id,
|
||||||
|
name: workspace.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return workspaces;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,6 +1,8 @@
|
|||||||
import defineApp from '../../helpers/define-app.js';
|
import defineApp from '../../helpers/define-app.js';
|
||||||
import addAuthHeader from './common/add-auth-header.js';
|
import addAuthHeader from './common/add-auth-header.js';
|
||||||
import auth from './auth/index.js';
|
import auth from './auth/index.js';
|
||||||
|
import triggers from './triggers/index.js';
|
||||||
|
import dynamicData from './dynamic-data/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'ClickUp',
|
name: 'ClickUp',
|
||||||
@@ -13,4 +15,6 @@ export default defineApp({
|
|||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
triggers,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
3
packages/backend/src/apps/clickup/triggers/index.js
Normal file
3
packages/backend/src/apps/clickup/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import newFolders from './new-folders/index.js';
|
||||||
|
|
||||||
|
export default [newFolders];
|
105
packages/backend/src/apps/clickup/triggers/new-folders/index.js
Normal file
105
packages/backend/src/apps/clickup/triggers/new-folders/index.js
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
import Crypto from 'crypto';
|
||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New folders',
|
||||||
|
key: 'newFolder',
|
||||||
|
type: 'webhook',
|
||||||
|
description: 'Triggers when a new folder is created.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Workspace',
|
||||||
|
key: 'workspaceId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listWorkspaces',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Space',
|
||||||
|
key: 'spaceId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
dependsOn: ['parameters.workspaceId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listSpaces',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.workspaceId',
|
||||||
|
value: '{parameters.workspaceId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const dataItem = {
|
||||||
|
raw: $.request.body,
|
||||||
|
meta: {
|
||||||
|
internalId: Crypto.randomUUID(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
async testRun($) {
|
||||||
|
const sampleEventData = {
|
||||||
|
event: 'folderCreated',
|
||||||
|
folder_id: '90180382912',
|
||||||
|
webhook_id: $.webhookUrl.split('/')[5],
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataItem = {
|
||||||
|
raw: sampleEventData,
|
||||||
|
meta: {
|
||||||
|
internalId: sampleEventData.webhook_id,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
$.pushTriggerItem(dataItem);
|
||||||
|
},
|
||||||
|
|
||||||
|
async registerHook($) {
|
||||||
|
const { workspaceId, spaceId } = $.step.parameters;
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
name: $.flow.id,
|
||||||
|
endpoint: $.webhookUrl,
|
||||||
|
events: ['folderCreated'],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (spaceId) {
|
||||||
|
payload.space_id = spaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.post(
|
||||||
|
`/v2/team/${workspaceId}/webhook`,
|
||||||
|
payload
|
||||||
|
);
|
||||||
|
|
||||||
|
await $.flow.setRemoteWebhookId(data.id);
|
||||||
|
},
|
||||||
|
|
||||||
|
async unregisterHook($) {
|
||||||
|
await $.http.delete(`/v2/webhook/${$.flow.remoteWebhookId}`);
|
||||||
|
},
|
||||||
|
});
|
@@ -81,7 +81,10 @@ export default defineConfig({
|
|||||||
text: 'ClickUp',
|
text: 'ClickUp',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [{ text: 'Connection', link: '/apps/clickup/connection' }],
|
items: [
|
||||||
|
{ text: 'Triggers', link: '/apps/clickup/triggers' },
|
||||||
|
{ text: 'Connection', link: '/apps/clickup/connection' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'DeepL',
|
text: 'DeepL',
|
||||||
|
12
packages/docs/pages/apps/clickup/triggers.md
Normal file
12
packages/docs/pages/apps/clickup/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/clickup.svg
|
||||||
|
items:
|
||||||
|
- name: New folders
|
||||||
|
desc: Triggers when a new folder is created.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -5,6 +5,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Airtable](/apps/airtable/actions)
|
- [Airtable](/apps/airtable/actions)
|
||||||
- [Appwrite](/apps/appwrite/triggers)
|
- [Appwrite](/apps/appwrite/triggers)
|
||||||
- [Carbone](/apps/carbone/actions)
|
- [Carbone](/apps/carbone/actions)
|
||||||
|
- [ClickUp](/apps/clickup/triggers)
|
||||||
- [Datastore](/apps/datastore/actions)
|
- [Datastore](/apps/datastore/actions)
|
||||||
- [DeepL](/apps/deepl/actions)
|
- [DeepL](/apps/deepl/actions)
|
||||||
- [Delay](/apps/delay/actions)
|
- [Delay](/apps/delay/actions)
|
||||||
|
Reference in New Issue
Block a user