feat(trello): add create card action
This commit is contained in:
189
packages/backend/src/apps/trello/actions/create-card/index.ts
Normal file
189
packages/backend/src/apps/trello/actions/create-card/index.ts
Normal file
@@ -0,0 +1,189 @@
|
|||||||
|
import { IJSONArray, IJSONObject } from '@automatisch/types';
|
||||||
|
import defineAction from '../../../../helpers/define-action';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Create card',
|
||||||
|
key: 'createCard',
|
||||||
|
description: 'Creates a new card within a specified board and list.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Board',
|
||||||
|
key: 'boardId',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listBoards',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'List',
|
||||||
|
key: 'listId',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: true,
|
||||||
|
dependsOn: ['parameters.boardId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listBoardLists',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.boardId',
|
||||||
|
value: '{parameters.boardId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Name',
|
||||||
|
key: 'name',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: true,
|
||||||
|
variables: true,
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Description',
|
||||||
|
key: 'description',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: false,
|
||||||
|
variables: true,
|
||||||
|
description: '',
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: 'Label',
|
||||||
|
key: 'label',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
dependsOn: ['parameters.boardId'],
|
||||||
|
description: 'Select a color tag to attach to the card.',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listBoardLabels',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.boardId',
|
||||||
|
value: '{parameters.boardId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Card Position',
|
||||||
|
key: 'cardPosition',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'top',
|
||||||
|
value: 'top',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'bottom',
|
||||||
|
value: 'bottom',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Members',
|
||||||
|
key: 'memberIds',
|
||||||
|
type: 'dynamic' as const,
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: 'Member',
|
||||||
|
key: 'memberId',
|
||||||
|
type: 'dropdown' as const,
|
||||||
|
required: false,
|
||||||
|
dependsOn: ['parameters.boardId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listMembers',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.boardId',
|
||||||
|
value: '{parameters.boardId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Due Date',
|
||||||
|
key: 'dueDate',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: false,
|
||||||
|
variables: true,
|
||||||
|
description: 'Format: mm-dd-yyyy HH:mm:ss or yyyy-MM-dd HH:mm:ss.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'URL Attachment',
|
||||||
|
key: 'urlSource',
|
||||||
|
type: 'string' as const,
|
||||||
|
required: false,
|
||||||
|
variables: true,
|
||||||
|
description: 'A URL to attach to the card.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const {
|
||||||
|
listId,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
cardPosition,
|
||||||
|
dueDate,
|
||||||
|
label,
|
||||||
|
urlSource,
|
||||||
|
} = $.step.parameters;
|
||||||
|
|
||||||
|
const memberIds = $.step.parameters.memberIds as IJSONArray;
|
||||||
|
const idMembers = memberIds.map(
|
||||||
|
(memberId: IJSONObject) => memberId.memberId
|
||||||
|
);
|
||||||
|
|
||||||
|
const fields = {
|
||||||
|
name,
|
||||||
|
desc: description,
|
||||||
|
idList: listId,
|
||||||
|
pos: cardPosition,
|
||||||
|
due: dueDate,
|
||||||
|
idMembers: idMembers.join(','),
|
||||||
|
idLabels: label,
|
||||||
|
urlSource,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await $.http.post('/1/cards', fields);
|
||||||
|
|
||||||
|
$.setActionItem({ raw: response.data });
|
||||||
|
},
|
||||||
|
});
|
3
packages/backend/src/apps/trello/actions/index.ts
Normal file
3
packages/backend/src/apps/trello/actions/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import createCard from './create-card';
|
||||||
|
|
||||||
|
export default [createCard];
|
@@ -5,6 +5,8 @@ const addAuthHeader: TBeforeRequest = ($, requestConfig) => {
|
|||||||
requestConfig.headers.Authorization = `OAuth oauth_consumer_key="${$.auth.data.apiKey}", oauth_token="${$.auth.data.token}"`;
|
requestConfig.headers.Authorization = `OAuth oauth_consumer_key="${$.auth.data.apiKey}", oauth_token="${$.auth.data.token}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestConfig.headers.Accept = 'application/json';
|
||||||
|
|
||||||
return requestConfig;
|
return requestConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
6
packages/backend/src/apps/trello/dynamic-data/index.ts
Normal file
6
packages/backend/src/apps/trello/dynamic-data/index.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import listBoardLabels from './list-board-labels';
|
||||||
|
import listBoardLists from './list-board-lists';
|
||||||
|
import listBoards from './list-boards';
|
||||||
|
import listMembers from './listMembers';
|
||||||
|
|
||||||
|
export default [listBoardLabels, listBoardLists, listBoards, listMembers];
|
@@ -0,0 +1,39 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List board labels',
|
||||||
|
key: 'listBoardLabels',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const boardLabels: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const boardId = $.step.parameters.boardId;
|
||||||
|
|
||||||
|
if (!boardId) {
|
||||||
|
return boardLabels;
|
||||||
|
}
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
fields: 'color',
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/boards/${boardId}/labels`, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (data?.length) {
|
||||||
|
for (const boardLabel of data) {
|
||||||
|
boardLabels.data.push({
|
||||||
|
value: boardLabel.id,
|
||||||
|
name: boardLabel.color,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boardLabels;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,33 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List board lists',
|
||||||
|
key: 'listBoardLists',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const boards: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const boardId = $.step.parameters.boardId;
|
||||||
|
|
||||||
|
if (!boardId) {
|
||||||
|
return boards;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/boards/${boardId}/lists`);
|
||||||
|
|
||||||
|
if (data?.length) {
|
||||||
|
for (const list of data) {
|
||||||
|
boards.data.push({
|
||||||
|
value: list.id,
|
||||||
|
name: list.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boards;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,27 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List boards',
|
||||||
|
key: 'listBoards',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const boards: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/members/me/boards`);
|
||||||
|
|
||||||
|
if (data?.length) {
|
||||||
|
for (const board of data) {
|
||||||
|
boards.data.push({
|
||||||
|
value: board.id,
|
||||||
|
name: board.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return boards;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,33 @@
|
|||||||
|
import { IGlobalVariable, IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List members',
|
||||||
|
key: 'listMembers',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const members: {
|
||||||
|
data: IJSONObject[];
|
||||||
|
} = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const boardId = $.step.parameters.boardId;
|
||||||
|
|
||||||
|
if (!boardId) {
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/1/boards/${boardId}/members`);
|
||||||
|
|
||||||
|
if (data?.length) {
|
||||||
|
for (const member of data) {
|
||||||
|
members.data.push({
|
||||||
|
value: member.id,
|
||||||
|
name: member.fullName,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return members;
|
||||||
|
},
|
||||||
|
};
|
@@ -1,6 +1,8 @@
|
|||||||
import defineApp from '../../helpers/define-app';
|
import defineApp from '../../helpers/define-app';
|
||||||
import addAuthHeader from './common/add-auth-header';
|
import addAuthHeader from './common/add-auth-header';
|
||||||
import auth from './auth';
|
import auth from './auth';
|
||||||
|
import actions from './actions';
|
||||||
|
import dynamicData from './dynamic-data';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Trello',
|
name: 'Trello',
|
||||||
@@ -13,4 +15,6 @@ export default defineApp({
|
|||||||
primaryColor: '0079bf',
|
primaryColor: '0079bf',
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
actions,
|
||||||
|
dynamicData,
|
||||||
});
|
});
|
||||||
|
@@ -377,7 +377,10 @@ export default defineConfig({
|
|||||||
text: 'Trello',
|
text: 'Trello',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [{ text: 'Connection', link: '/apps/trello/connection' }],
|
items: [
|
||||||
|
{ text: 'Actions', link: '/apps/trello/actions' },
|
||||||
|
{ text: 'Connection', link: '/apps/trello/connection' },
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Twilio',
|
text: 'Twilio',
|
||||||
@@ -439,9 +442,7 @@ export default defineConfig({
|
|||||||
text: 'Zendesk',
|
text: 'Zendesk',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [{ text: 'Connection', link: '/apps/zendesk/connection' }],
|
||||||
{ text: 'Connection', link: '/apps/zendesk/connection' },
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'/': [
|
'/': [
|
||||||
|
12
packages/docs/pages/apps/trello/actions.md
Normal file
12
packages/docs/pages/apps/trello/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/trello.svg
|
||||||
|
items:
|
||||||
|
- name: Create card
|
||||||
|
desc: Creates a new card within a specified board and list.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -39,6 +39,7 @@ The following integrations are currently supported by Automatisch.
|
|||||||
- [Stripe](/apps/stripe/triggers)
|
- [Stripe](/apps/stripe/triggers)
|
||||||
- [Telegram](/apps/telegram-bot/actions)
|
- [Telegram](/apps/telegram-bot/actions)
|
||||||
- [Todoist](/apps/todoist/triggers)
|
- [Todoist](/apps/todoist/triggers)
|
||||||
|
- [Trello](/apps/trello/actions)
|
||||||
- [Twilio](/apps/twilio/triggers)
|
- [Twilio](/apps/twilio/triggers)
|
||||||
- [Twitter](/apps/twitter/triggers)
|
- [Twitter](/apps/twitter/triggers)
|
||||||
- [Typeform](/apps/typeform/triggers)
|
- [Typeform](/apps/typeform/triggers)
|
||||||
|
Reference in New Issue
Block a user