npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reshuffle-asana-connector

v0.0.2

Published

Reshuffle Asana connector

Downloads

7

Readme

reshuffle-asana-connector

Code | npm | Code sample

npm install reshuffle-asana-connector

This connector uses Node Asana Client package.

Reshuffle Asana Connector

This package contains a Reshuffle connector for Asana.

The following example listen to Asana updates:

const { Reshuffle } = require('reshuffle')
const { AsanaConnector } = require('reshuffle-asana-connector')

const app = new Reshuffle()

const connector = new AsanaConnector(app, {
  accessToken: process.env.ASANA_ACCESS_TOKEN,
  baseURL: process.env.RUNTIME_BASE_URL,
  workspaceId: process.env.ASANA_WORKSPACE_ID,
})

// Listening to any changes for a given project
connector.on({ gid: projectId, asanaEvent: 'changed' }, (event, app) => {
  console.log(event.change) // { field: 'likes', action: 'added', added_value: { gid: '1199236509904757', resource_type: 'like', user: {...} } }
})

app.start()

Table of Contents

Create Asana API token

Configuration Options

Connector Events

Listening to Asana events

Connector Actions

SDK - Node Asana Client SDK

Examples using the SDK

Create Asana access token

Create Asana access token:

  • Go to https://app.asana.com/0/developer-console
  • Under 'Personal Access Token'' > '+ New Access Token'
  • Name it, copy your token, and pass it to the connector as below

Configuration Options

const connector = new AsanaConnector(app, {
  accessToken: process.env.ASANA_ACCESS_TOKEN,
})

To use Reshuffle Asana connector events, you need to provide at least your runtime baseURL and workspaceId. The workspaceId can be find in Asana Console page url (e.g. https://app.asana.com/admin/<YOUR_WORKSPACE_ID>) You can also override the default webhookPath.

const connector = new AsanaConnector(app, {
  accessToken: process.env.ASANA_ACCESS_TOKEN,
  baseURL: process.env.RUNTIME_BASE_URL,
  workspaceId: process.env.ASANA_WORKSPACE_ID,
  webhookPath: process.env.ASANA_WEBHOOK_PATH // Optional, default is '/reshuffle-asana-connector/webhook'
})

Required webhooks will be automatically set up for you on app.start(). It uses existing webhooks when ti finds one already registered with the same base URL / workspace ID.

Connector events

Listening to Asana events

Note: Reshuffle Asana events uses Asana webhooks which can be triggered up to a minute after the actual event took place in asana.com

To listen to events happening in Asana, simply pass the gid of the entity you want to track (project or task id) This can be found in the URL (e.g for your project home page: https://app.asana.com/0/<YOUR_PROJECT_ID>/board) You can also pass an asanaEvent (default is trigger for any changes)

interface AsanaConnectorEventOptions {
  gid: string // Asana project or task unique identifier
  asanaEvent?: AsanaEvent // Optional, the default is to listen to any Asana events 
}

// List extracted from section 'Resources and Actions' at https://developers.asana.com/docs/webhooks
type AsanaEvent = '*' | 'deleted' | 'undeleted' | 'added' | 'removed' | 'changed'
  • Listening to all events in your project
connector.on({ gid: projectId }, (event, app) => {
  console.log(event.change) // type is AsanaEvent, e.g. 'changed'
})
  • Listening to added entities in your project
connector.on({ gid: projectId, asanaEvent: 'added' }, async (event, app) => {
  console.log(event.change) // e.g. 'added'
  console.log(event.resource) // { gid: '1198840429184158', resource_type: 'story', resource_subtype: 'added_to_project' }

  // Get the new task details
  const newTask = await connector.sdk().tasks.findById(event.resource.gid)
  console.log('new task details', newTask) // { gid: '1199238260452125', created_at: '2020-11-20T01:13:37.669Z', name: 'task name', ... }
})

Connector actions

All actions are provided via the sdk. See full list of actions with documentation in Node Asana Client code (select a resource and see the list of actions available via the sdk action.)

SDK

Full access to the Node Asana Client SDK

const sdk = await connector.sdk()
Examples using the SDK
  • Get project details
const project = await connector.sdk().projects.findById(projectId)
console.log('project details', project) // { name: 'my project name', ... }
  • Create a new task:
const task = await connector.sdk().tasks.createInWorkspace(project.workspace.gid, { name: 'task 1' })
console.log(`task created`, task) // { gid: '1234567898765', name: 'task 1' }
  • Get all tasks for a project
const tasks = await connector.sdk().tasks.findByProject(projectId)
console.log(`tasks for project ${projectId}`, tasks.data) // [{ gid: '1199204075353966', name: 'File uploader broken on Chrome' }, ...]
  • Amend a task
const taskUpdated = await connector.sdk().tasks.update(tasks.data[0].gid, { name: 'New name' }) // tasks coming from 'Get all tasks for a project' example above
console.log(taskUpdated) // {gid: '0123456789', name: 'New name', ... }
  • Get the team details
const team = await connector.sdk().teams.findById(project.team.gid) // project object coming from 'Get project details' example above 
console.log('team details', team) // { name: 'Engineering', gid: '112233', organization: { name: 'my organisation name', gid: '12345'} ... }