Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0526ec5b06 | ||
![]() |
061a9c6947 |
216
packages/backend/src/apps/asana/actions/create-project/index.js
Normal file
216
packages/backend/src/apps/asana/actions/create-project/index.js
Normal file
@@ -0,0 +1,216 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import omitBy from 'lodash/omitBy.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create project',
|
||||
key: 'createProject',
|
||||
description: 'Creates a new project.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Workspace',
|
||||
key: 'workspaceId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listWorkspaces',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Team',
|
||||
key: 'teamId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listTeams',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Due date',
|
||||
key: 'dueDate',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Example due on: 2019-09-15',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Notes',
|
||||
key: 'notes',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'You can format the notes using html.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Is the notes rich text?',
|
||||
key: 'richText',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'No',
|
||||
value: 'false',
|
||||
},
|
||||
{
|
||||
label: 'Yes',
|
||||
value: 'true',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Default View',
|
||||
key: 'defaultView',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'List',
|
||||
value: 'list',
|
||||
},
|
||||
{
|
||||
label: 'Board',
|
||||
value: 'board',
|
||||
},
|
||||
{
|
||||
label: 'Calendar',
|
||||
value: 'calendar',
|
||||
},
|
||||
{
|
||||
label: 'Timeline',
|
||||
value: 'timeline',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Owner',
|
||||
key: 'ownerId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.workspaceId'],
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Followers',
|
||||
key: 'followerIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Follower',
|
||||
key: 'followerId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.workspaceId'],
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
workspaceId,
|
||||
teamId,
|
||||
dueDate,
|
||||
name,
|
||||
notes,
|
||||
richText,
|
||||
defaultView,
|
||||
ownerId,
|
||||
followerIds,
|
||||
} = $.step.parameters;
|
||||
|
||||
const allFollowers = followerIds
|
||||
.map((followerId) => followerId.followerId)
|
||||
.filter(Boolean);
|
||||
|
||||
const data = {
|
||||
workspace: workspaceId,
|
||||
team: teamId,
|
||||
due_on: dueDate,
|
||||
name,
|
||||
default_view: defaultView,
|
||||
owner: ownerId,
|
||||
followers: allFollowers,
|
||||
};
|
||||
|
||||
if (richText === 'true') {
|
||||
data.html_notes = notes;
|
||||
} else {
|
||||
data.notes = notes;
|
||||
}
|
||||
|
||||
const filteredData = omitBy(data, isEmpty);
|
||||
|
||||
const response = await $.http.post('/1.0/projects', { data: filteredData });
|
||||
|
||||
$.setActionItem({
|
||||
raw: response.data,
|
||||
});
|
||||
},
|
||||
});
|
312
packages/backend/src/apps/asana/actions/create-task/index.js
Normal file
312
packages/backend/src/apps/asana/actions/create-task/index.js
Normal file
@@ -0,0 +1,312 @@
|
||||
import defineAction from '../../../../helpers/define-action.js';
|
||||
import omitBy from 'lodash/omitBy.js';
|
||||
import isEmpty from 'lodash/isEmpty.js';
|
||||
|
||||
export default defineAction({
|
||||
name: 'Create task',
|
||||
key: 'createTask',
|
||||
description: 'Creates a new task.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Workspace',
|
||||
key: 'workspaceId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listWorkspaces',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Project',
|
||||
key: 'projectId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listProjects',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Section',
|
||||
key: 'sectionId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listSections',
|
||||
},
|
||||
{
|
||||
name: 'parameters.projectId',
|
||||
value: '{parameters.projectId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Due date type',
|
||||
key: 'dueDateType',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: "If not filled in, 'Date & time' will be assumed.",
|
||||
options: [
|
||||
{
|
||||
label: 'Date & time',
|
||||
value: 'at',
|
||||
},
|
||||
{
|
||||
label: 'Date only',
|
||||
value: 'on',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Due date (date & time)',
|
||||
key: 'dueDate',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description:
|
||||
'Example due at: 2019-09-15T02:06:58.147Z, example due on: 2019-09-15',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Name',
|
||||
key: 'name',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Description',
|
||||
key: 'description',
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'You can format the description using html.',
|
||||
variables: true,
|
||||
},
|
||||
{
|
||||
label: 'Is the description rich text?',
|
||||
key: 'richText',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'No',
|
||||
value: 'false',
|
||||
},
|
||||
{
|
||||
label: 'Yes',
|
||||
value: 'true',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Mark Task as complete?',
|
||||
key: 'taskCompleted',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'No',
|
||||
value: 'false',
|
||||
},
|
||||
{
|
||||
label: 'Yes',
|
||||
value: 'true',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Mark Task as liked?',
|
||||
key: 'taskLiked',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
description: '',
|
||||
variables: true,
|
||||
options: [
|
||||
{
|
||||
label: 'No',
|
||||
value: 'false',
|
||||
},
|
||||
{
|
||||
label: 'Yes',
|
||||
value: 'true',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Assignee',
|
||||
key: 'assigneeId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.workspaceId'],
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Followers',
|
||||
key: 'followerIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Follower',
|
||||
key: 'followerId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.workspaceId'],
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listUsers',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Tags',
|
||||
key: 'tagIds',
|
||||
type: 'dynamic',
|
||||
required: false,
|
||||
description: '',
|
||||
fields: [
|
||||
{
|
||||
label: 'Tag',
|
||||
key: 'tagId',
|
||||
type: 'dropdown',
|
||||
required: false,
|
||||
dependsOn: ['parameters.workspaceId'],
|
||||
description: '',
|
||||
variables: true,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listTags',
|
||||
},
|
||||
{
|
||||
name: 'parameters.workspaceId',
|
||||
value: '{parameters.workspaceId}',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const {
|
||||
workspaceId,
|
||||
projectId,
|
||||
sectionId,
|
||||
dueDateType,
|
||||
dueDate,
|
||||
name,
|
||||
description,
|
||||
richText,
|
||||
taskCompleted,
|
||||
taskLiked,
|
||||
assigneeId,
|
||||
followerIds,
|
||||
tagIds,
|
||||
} = $.step.parameters;
|
||||
|
||||
const allFollowers = followerIds
|
||||
.map((followerId) => followerId.followerId)
|
||||
.filter(Boolean);
|
||||
|
||||
const allTags = tagIds.map((tagId) => tagId.tagId).filter(Boolean);
|
||||
|
||||
const data = {
|
||||
name,
|
||||
completed: taskCompleted,
|
||||
liked: taskLiked,
|
||||
assignee: assigneeId,
|
||||
assignee_section: sectionId,
|
||||
followers: allFollowers,
|
||||
projects: projectId,
|
||||
tags: allTags,
|
||||
workspace: workspaceId,
|
||||
};
|
||||
|
||||
if (richText === 'true') {
|
||||
data.html_notes = description;
|
||||
} else {
|
||||
data.notes = description;
|
||||
}
|
||||
|
||||
if (dueDateType === 'on') {
|
||||
data.due_on = dueDate;
|
||||
} else {
|
||||
data.due_at = dueDate;
|
||||
}
|
||||
|
||||
const filteredData = omitBy(data, isEmpty);
|
||||
|
||||
const response = await $.http.post('/1.0/tasks', { data: filteredData });
|
||||
|
||||
$.setActionItem({
|
||||
raw: response.data,
|
||||
});
|
||||
},
|
||||
});
|
4
packages/backend/src/apps/asana/actions/index.js
Normal file
4
packages/backend/src/apps/asana/actions/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import createProject from './create-project/index.js';
|
||||
import createTask from './create-task/index.js';
|
||||
|
||||
export default [createProject, createTask];
|
@@ -1,3 +1,15 @@
|
||||
import listProjects from './list-projects/index.js';
|
||||
import listSections from './list-sections/index.js';
|
||||
import listTags from './list-tags/index.js';
|
||||
import listTeams from './list-teams/index.js';
|
||||
import listUsers from './list-users/index.js';
|
||||
import listWorkspaces from './list-workspaces/index.js';
|
||||
|
||||
export default [listWorkspaces];
|
||||
export default [
|
||||
listProjects,
|
||||
listSections,
|
||||
listTags,
|
||||
listTeams,
|
||||
listUsers,
|
||||
listWorkspaces,
|
||||
];
|
||||
|
@@ -0,0 +1,42 @@
|
||||
export default {
|
||||
name: 'List projects',
|
||||
key: 'listProjects',
|
||||
|
||||
async run($) {
|
||||
const projects = {
|
||||
data: [],
|
||||
};
|
||||
const workspaceId = $.step.parameters.workspaceId;
|
||||
|
||||
if (!workspaceId) {
|
||||
return projects;
|
||||
}
|
||||
|
||||
const params = {
|
||||
limit: 100,
|
||||
offset: undefined,
|
||||
workspace: workspaceId,
|
||||
};
|
||||
|
||||
do {
|
||||
const {
|
||||
data: { data, next_page },
|
||||
} = await $.http.get('/1.0/projects', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.offset = next_page?.offset;
|
||||
|
||||
if (data) {
|
||||
for (const project of data) {
|
||||
projects.data.push({
|
||||
value: project.gid,
|
||||
name: project.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.offset);
|
||||
|
||||
return projects;
|
||||
},
|
||||
};
|
@@ -0,0 +1,41 @@
|
||||
export default {
|
||||
name: 'List sections',
|
||||
key: 'listSections',
|
||||
|
||||
async run($) {
|
||||
const sections = {
|
||||
data: [],
|
||||
};
|
||||
const projectId = $.step.parameters.projectId;
|
||||
|
||||
if (!projectId) {
|
||||
return sections;
|
||||
}
|
||||
|
||||
const params = {
|
||||
limit: 100,
|
||||
offset: undefined,
|
||||
};
|
||||
|
||||
do {
|
||||
const {
|
||||
data: { data, next_page },
|
||||
} = await $.http.get(`/1.0/projects/${projectId}/sections`, {
|
||||
params,
|
||||
});
|
||||
|
||||
params.offset = next_page?.offset;
|
||||
|
||||
if (data) {
|
||||
for (const section of data) {
|
||||
sections.data.push({
|
||||
value: section.gid,
|
||||
name: section.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.offset);
|
||||
|
||||
return sections;
|
||||
},
|
||||
};
|
@@ -0,0 +1,42 @@
|
||||
export default {
|
||||
name: 'List tags',
|
||||
key: 'listTags',
|
||||
|
||||
async run($) {
|
||||
const tags = {
|
||||
data: [],
|
||||
};
|
||||
const workspaceId = $.step.parameters.workspaceId;
|
||||
|
||||
if (!workspaceId) {
|
||||
return workspaceId;
|
||||
}
|
||||
|
||||
const params = {
|
||||
limit: 100,
|
||||
offset: undefined,
|
||||
workspace: workspaceId,
|
||||
};
|
||||
|
||||
do {
|
||||
const {
|
||||
data: { data, next_page },
|
||||
} = await $.http.get('/1.0/tags', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.offset = next_page?.offset;
|
||||
|
||||
if (data) {
|
||||
for (const tag of data) {
|
||||
tags.data.push({
|
||||
value: tag.gid,
|
||||
name: tag.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.offset);
|
||||
|
||||
return tags;
|
||||
},
|
||||
};
|
@@ -0,0 +1,42 @@
|
||||
export default {
|
||||
name: 'List teams',
|
||||
key: 'listTeams',
|
||||
|
||||
async run($) {
|
||||
const teams = {
|
||||
data: [],
|
||||
};
|
||||
const workspaceId = $.step.parameters.workspaceId;
|
||||
|
||||
if (!workspaceId) {
|
||||
return workspaceId;
|
||||
}
|
||||
|
||||
const params = {
|
||||
limit: 100,
|
||||
offset: undefined,
|
||||
workspace: workspaceId,
|
||||
};
|
||||
|
||||
do {
|
||||
const {
|
||||
data: { data, next_page },
|
||||
} = await $.http.get('/1.0/teams', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.offset = next_page?.offset;
|
||||
|
||||
if (data) {
|
||||
for (const team of data) {
|
||||
teams.data.push({
|
||||
value: team.gid,
|
||||
name: team.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.offset);
|
||||
|
||||
return teams;
|
||||
},
|
||||
};
|
@@ -0,0 +1,42 @@
|
||||
export default {
|
||||
name: 'List users',
|
||||
key: 'listUsers',
|
||||
|
||||
async run($) {
|
||||
const users = {
|
||||
data: [],
|
||||
};
|
||||
const workspaceId = $.step.parameters.workspaceId;
|
||||
|
||||
if (!workspaceId) {
|
||||
return workspaceId;
|
||||
}
|
||||
|
||||
const params = {
|
||||
limit: 100,
|
||||
offset: undefined,
|
||||
workspace: workspaceId,
|
||||
};
|
||||
|
||||
do {
|
||||
const {
|
||||
data: { data, next_page },
|
||||
} = await $.http.get('/1.0/users', {
|
||||
params,
|
||||
});
|
||||
|
||||
params.offset = next_page?.offset;
|
||||
|
||||
if (data) {
|
||||
for (const user of data) {
|
||||
users.data.push({
|
||||
value: user.gid,
|
||||
name: user.name,
|
||||
});
|
||||
}
|
||||
}
|
||||
} while (params.offset);
|
||||
|
||||
return users;
|
||||
},
|
||||
};
|
@@ -3,6 +3,7 @@ import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import actions from './actions/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Asana',
|
||||
@@ -17,4 +18,5 @@ export default defineApp({
|
||||
auth,
|
||||
dynamicData,
|
||||
triggers,
|
||||
actions,
|
||||
});
|
||||
|
@@ -54,7 +54,11 @@ export default defineConfig({
|
||||
text: 'Asana',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/asana/connection' }],
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/asana/triggers' },
|
||||
{ text: 'Actions', link: '/apps/asana/actions' },
|
||||
{ text: 'Connection', link: '/apps/asana/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Carbone',
|
||||
|
14
packages/docs/pages/apps/asana/actions.md
Normal file
14
packages/docs/pages/apps/asana/actions.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
favicon: /favicons/asana.svg
|
||||
items:
|
||||
- name: Create project
|
||||
desc: Creates a new project.
|
||||
- name: Create task
|
||||
desc: Creates a new task.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
Reference in New Issue
Block a user