feat(asana): add new projects trigger

This commit is contained in:
Rıdvan Akca
2024-06-05 11:18:52 +02:00
parent 9d5dac1701
commit ab307cdee0
7 changed files with 116 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
import listWorkspaces from './list-workspaces/index.js';
export default [listWorkspaces];

View File

@@ -0,0 +1,34 @@
export default {
name: 'List workspaces',
key: 'listWorkspaces',
async run($) {
const workspaces = {
data: [],
};
const params = {
limit: 100,
offset: undefined,
};
do {
const {
data: { data, next_page },
} = await $.http.get('/1.0/workspaces', { params });
params.offset = next_page?.offset;
if (data) {
for (const workspace of data) {
workspaces.data.push({
value: workspace.gid,
name: workspace.name,
});
}
}
} while (params.offset);
return workspaces;
},
};

View File

@@ -1,6 +1,8 @@
import defineApp from '../../helpers/define-app.js';
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';
export default defineApp({
name: 'Asana',
@@ -13,4 +15,6 @@ export default defineApp({
supportsConnections: true,
beforeRequest: [addAuthHeader],
auth,
dynamicData,
triggers,
});

View File

@@ -0,0 +1,3 @@
import newProjects from './new-projects/index.js';
export default [newProjects];

View File

@@ -0,0 +1,59 @@
import defineTrigger from '../../../../helpers/define-trigger.js';
export default defineTrigger({
name: 'New projects',
key: 'newProjects',
pollInterval: 15,
description: 'Triggers when a new project is created.',
arguments: [
{
label: 'Workspace',
key: 'workspaceId',
type: 'dropdown',
required: true,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listWorkspaces',
},
],
},
},
],
async run($) {
const workspaceId = $.step.parameters.workspaceId;
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) {
$.pushTriggerItem({
raw: project,
meta: {
internalId: project.gid,
},
});
}
}
} while (params.offset);
},
});

View File

@@ -0,0 +1,12 @@
---
favicon: /favicons/asana.svg
items:
- name: New projects
desc: Triggers when a new project is created.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />

View File

@@ -4,6 +4,7 @@ The following integrations are currently supported by Automatisch.
- [Airtable](/apps/airtable/actions)
- [Appwrite](/apps/appwrite/triggers)
- [Asana](/apps/asana/triggers)
- [Carbone](/apps/carbone/actions)
- [Datastore](/apps/datastore/actions)
- [DeepL](/apps/deepl/actions)