feat(asana): add new projects trigger
This commit is contained in:
3
packages/backend/src/apps/asana/dynamic-data/index.js
Normal file
3
packages/backend/src/apps/asana/dynamic-data/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import listWorkspaces from './list-workspaces/index.js';
|
||||||
|
|
||||||
|
export default [listWorkspaces];
|
@@ -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;
|
||||||
|
},
|
||||||
|
};
|
@@ -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 dynamicData from './dynamic-data/index.js';
|
||||||
|
import triggers from './triggers/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Asana',
|
name: 'Asana',
|
||||||
@@ -13,4 +15,6 @@ export default defineApp({
|
|||||||
supportsConnections: true,
|
supportsConnections: true,
|
||||||
beforeRequest: [addAuthHeader],
|
beforeRequest: [addAuthHeader],
|
||||||
auth,
|
auth,
|
||||||
|
dynamicData,
|
||||||
|
triggers,
|
||||||
});
|
});
|
||||||
|
3
packages/backend/src/apps/asana/triggers/index.js
Normal file
3
packages/backend/src/apps/asana/triggers/index.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import newProjects from './new-projects/index.js';
|
||||||
|
|
||||||
|
export default [newProjects];
|
@@ -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);
|
||||||
|
},
|
||||||
|
});
|
12
packages/docs/pages/apps/asana/triggers.md
Normal file
12
packages/docs/pages/apps/asana/triggers.md
Normal 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 />
|
@@ -4,6 +4,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)
|
||||||
|
- [Asana](/apps/asana/triggers)
|
||||||
- [Carbone](/apps/carbone/actions)
|
- [Carbone](/apps/carbone/actions)
|
||||||
- [Datastore](/apps/datastore/actions)
|
- [Datastore](/apps/datastore/actions)
|
||||||
- [DeepL](/apps/deepl/actions)
|
- [DeepL](/apps/deepl/actions)
|
||||||
|
Reference in New Issue
Block a user