Giter Club home page Giter Club logo

asana-api-meta's Introduction

Asana API Metadata Build Status

Metadata for Asana API for generating client libraries and documentation

This repository contains descriptions of the various resources in the API and their endpoints. The metadata is rich in structural information and comments, such that we can use it to build both documentation and functioning client library objects.

It is currently used to build the following client libraries:

It is also used to build the Asana API Reference in the developer documentation.

Contributing

  1. Clone the repo: git clone [email protected]:Asana/asana-api-meta.git
  2. Make a topic branch: git checkout -b my-topic-branch
  3. Make changes on the topic branch.
  4. Run gulp build to build the output for all languages. You can inspect the final output in dist/.
  5. When satisfied, make a pull request.

How It Works

Language Configuration

Each language has its own configuration that determines how the output files are built. These configurations are specified in gulpfile.js as var languages = .... Each record has the following schema:

  • repo: Name of the target repository where built files will be pushed to.
  • branch: Name of the branch in the repository to push to.
  • outputPath: Path, relative to the root of repo, where template output will go.
  • preserveRepoFiles: Set to true if when the files are built and pushed to the target, any existing files are preserved. If false, it will clear out outputPath each time it pushes.
  • skip: An array of resource names to avoid generating output files for.

Resource Definitions

Resources are defined in individual YAML files under src/resources. The one-resource-per-file convention keeps the files manageable.

A schema is provided for resources, and the resources are validated against it during testing. It can be found in test/resource_schema.json, and uses the JSON Schema syntax, with the jsonschema Node package for validation.

The schemas make heavy use of the "anchor" and "alias" features of YAML, so the files can be more normalized and avoid excessive repetition. These are mostly used to define commonly-used components like types, properties, and parameters that appear in multiple (sometimes many, many) places.

Definitions for value types (like Email, ProjectColor, TeamId etc.) that may appear as a parameter or resource property in more than one place should go in the src/includes.yaml file.

Templates

This module uses templates for generating library source files from the resources.

The build system will, for each language LANG it is building (e.g. LANG='js'):

  1. For each resource: 2. Read in the resource definition file, src/resources/NAME.yaml. 3. Read in the template definition file, src/templates/LANG/index.js. 4. Find the resource key. 5. Read in the template to find the input template, and the filename function to generate the output filename. 4. Execute the template against the resource definition. 5. Output the result into the file dist/LANG/OUTPUTFILE.

All templates use the lodash library for generation. gulpfile.js has the build rules that execute the templates. It provides various helpers to the template that are configurable on a per-library basis, by scoping the file helpers.js into the template namespace. These include utilities for common code-generation patterns.

Authors modifying the templates should ensure that they generate pretty code, at the expense of the prettiness of the template. Trivial issues like bad indents in the output should be fixed.

Helpers

Rather than pour a bunch of logic into the template, it's better style to put them into helpers. Currently there is only a single helpers file, but we should break this into a set of language-specific files (that might each call some useful common helpers where appropriate).

Examples of places where extracting helpers is useful are paramsForAction or wrapComment.

Owner Workflow

Testing Proposed Changes

  1. Get a personal access token for GitHub and assign it to the environment variable ASANA_GITHUB_TOKEN: export ASANA_GITHUB_TOKEN=...
  2. Run a test deployment for a single language, e.g. gulp deploy-js. This will create a new branch in the target repo and deploy the generated files to that branch. The branch will be named for your GitHub username and a date-timestamp, for example asanabot-20150531-012345.
  3. Inspect the diffs on GitHub. If you need to make changes you can re-run the deploy and it will create a new branch.
  4. You can do a test deploy to all languages at once by running just gulp deploy.

Committing

  1. Push changes to origin git push origin my-topic-branch.
  2. Make a pull request in GitHub. This will automatically create a task in Asana.
  3. Once your request is reviewed, it can be merged.

Deploying

  1. Clone the repo, work on master.
  2. Bump the package version to indicate the semantic version change, using one of: gulp bump-patch, gulp bump-feature, or gulp bump-release
  3. Push changes to origin, including tags: git push origin master --tags

Propagating Changes to Client Libraries

  1. Travis will automatically build and deploy new code to the api-meta-incoming branch of all the repos, creating pull requests for each.
  2. Review and merge the pull requests as appropriate.
  3. Update package versions according to semantic versioning, and push.

asana-api-meta's People

Contributors

agnoster avatar alexdavies74 avatar ciwang avatar dependabot[bot] avatar epelz avatar ferhatelmas avatar jjschnei avatar joetrollo avatar keenanpayne avatar keiththomps avatar leei avatar lucas-gluchowski avatar marcogallotta avatar markchua avatar mr0grog avatar praecipula avatar rossgrambo-zz avatar seanwentzel avatar slobak avatar theaeolianmachine avatar tlrobinson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asana-api-meta's Issues

Filter tasks by external:data custom fields

It is great that asana api provides a way to save custom data.

Currently the external:data field allows storage of string characters.
It would be great if json objects can be stored so that when I update a task with the following external data

          external: {
            "id": 1234567899,
            "data": "{ 'time_estimate': 3600, 'time_spent': 1482 }"
          }

I can then filter tasks that match for example the custom field time_estimate

client.tasks.findByExternalField({'time_estimate': 3600})
//or
client.tasks.findBy({'external:time_estimate': 3600})

returning a list of tasks

Getting an error when I run gulp build

I had forked this repo a while back to create an Asana R client. At that point, everything was working well. Recently, I updated my fork to make sure I have the latest version of the API. However, if I run npm install followed by gulp build now, I run into the following error.

On googling the error, it seems to be the case that Gulp 3 is not longer supported, and I believe this repo uses Gulp 3. Any pointers on how I can get my build working.

I would like to contribute the Asana R client once I clean this up.

fs.js:34
} = primordials;
    ^

ReferenceError: primordials is not defined
    at fs.js:34:5
    at req_ (/Users/ramnath/Documents/Repositories/ramnathv/asana-api-meta/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/Users/ramnath/Documents/Repositories/ramnathv/asana-api-meta/node_modules/natives/index.js:55:10)
    at Object.<anonymous> (/Users/ramnath/Documents/Repositories/ramnathv/asana-api-meta/node_modules/fs-extra/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1028:19)
    at require (internal/modules/cjs/helpers.js:72:18)

Asana::Resources::Section::find_by_project does not return a collection

I am using the Ruby version of the client.

I am assuming that the "sections" resources should be similar to tasks. With that said, ::find_by_project should return a collection. Instead, I get this error:

client.sections.find_by_project(project: PROJECT_ID)
# TypeError: {"id"=>000, "gid"=>"000", "name"=>"THE NAME"} is not a symbol nor a string
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/resource_includes/resource.rb:20:in `respond_to?'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/resource_includes/resource.rb:20:in `block in initialize'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/resource_includes/resource.rb:19:in `each'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/resource_includes/resource.rb:19:in `initialize'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/resources/section.rb:45:in `new'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/resources/section.rb:45:in `find_by_project'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/client.rb:63:in `public_send'
# 	/home/vagrant/.rbenv/versions/2.3.6/lib/ruby/gems/2.3.0/gems/asana-0.8.0/lib/asana/client.rb:63:in `method_missing'
# 	smorg-console:64:in `<main>'

I guess adding collection: true in line 89 of /src/resources/section.yaml should do the trick. However, I am new at using the api myself, so my guess might be wrong.

Thank you πŸ™

Test

Making sure this sync works

client.tasks.find_by_project: null membership

When fetching tasks of a given project, the memberships somehow looks erroneous :

If, the section a task belongs to has been completed (yes : a competed section), then task['memberships'][x]['section']['name'] is null instead of being the name of the section.

Filter task by team

Hi,

We can through the API list tasks by assignee but can we retrieve task by team ?

Regards,

PS : It could be a list of assignee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.