asana 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.github/workflows/publish.yaml +78 -38
  2. package/.swagger-codegen/VERSION +1 -1
  3. package/README.md +135 -40
  4. package/build-tests/README.md +19 -0
  5. package/build-tests/api/ProjectsApi.js +178 -0
  6. package/build-tests/api/TasksApi.js +260 -0
  7. package/codegen/templates/README.mustache +129 -37
  8. package/codegen/templates/api.mustache +17 -15
  9. package/codegen/templates/package.mustache +3 -1
  10. package/dist/ApiClient.js +6 -7
  11. package/dist/api/AttachmentsApi.js +22 -95
  12. package/dist/api/AuditLogAPIApi.js +10 -14
  13. package/dist/api/BatchAPIApi.js +10 -14
  14. package/dist/api/CustomFieldSettingsApi.js +16 -23
  15. package/dist/api/CustomFieldsApi.js +38 -203
  16. package/dist/api/EventsApi.js +12 -16
  17. package/dist/api/GoalRelationshipsApi.js +26 -122
  18. package/dist/api/GoalsApi.js +48 -239
  19. package/dist/api/JobsApi.js +8 -32
  20. package/dist/api/MembershipsApi.js +73 -99
  21. package/dist/api/OrganizationExportsApi.js +12 -59
  22. package/dist/api/PortfolioMembershipsApi.js +20 -50
  23. package/dist/api/PortfoliosApi.js +56 -293
  24. package/dist/api/ProjectBriefsApi.js +20 -113
  25. package/dist/api/ProjectMembershipsApi.js +14 -41
  26. package/dist/api/ProjectStatusesApi.js +22 -95
  27. package/dist/api/ProjectTemplatesApi.js +28 -104
  28. package/dist/api/ProjectsApi.js +88 -446
  29. package/dist/api/RulesApi.js +8 -32
  30. package/dist/api/SectionsApi.js +34 -176
  31. package/dist/api/StatusUpdatesApi.js +22 -95
  32. package/dist/api/StoriesApi.js +26 -122
  33. package/dist/api/TagsApi.js +42 -167
  34. package/dist/api/TaskTemplatesApi.js +63 -72
  35. package/dist/api/TasksApi.js +173 -544
  36. package/dist/api/TeamMembershipsApi.js +26 -59
  37. package/dist/api/TeamsApi.js +36 -158
  38. package/dist/api/TimePeriodsApi.js +14 -41
  39. package/dist/api/TimeTrackingEntriesApi.js +26 -122
  40. package/dist/api/TypeaheadApi.js +12 -16
  41. package/dist/api/UserTaskListsApi.js +12 -59
  42. package/dist/api/UsersApi.js +32 -68
  43. package/dist/api/WebhooksApi.js +26 -122
  44. package/dist/api/WorkspaceMembershipsApi.js +20 -50
  45. package/dist/api/WorkspacesApi.js +26 -122
  46. package/package.json +3 -1
  47. package/src/ApiClient.js +4 -4
  48. package/src/api/AttachmentsApi.js +42 -134
  49. package/src/api/AuditLogAPIApi.js +15 -17
  50. package/src/api/BatchAPIApi.js +15 -17
  51. package/src/api/CustomFieldSettingsApi.js +28 -32
  52. package/src/api/CustomFieldsApi.js +78 -290
  53. package/src/api/EventsApi.js +17 -19
  54. package/src/api/GoalRelationshipsApi.js +51 -173
  55. package/src/api/GoalsApi.js +100 -344
  56. package/src/api/JobsApi.js +11 -41
  57. package/src/api/MembershipsApi.js +105 -138
  58. package/src/api/OrganizationExportsApi.js +20 -80
  59. package/src/api/PortfolioMembershipsApi.js +37 -71
  60. package/src/api/PortfoliosApi.js +118 -422
  61. package/src/api/ProjectBriefsApi.js +38 -158
  62. package/src/api/ProjectMembershipsApi.js +24 -56
  63. package/src/api/ProjectStatusesApi.js +42 -134
  64. package/src/api/ProjectTemplatesApi.js +55 -149
  65. package/src/api/ProjectsApi.js +189 -647
  66. package/src/api/RulesApi.js +11 -41
  67. package/src/api/SectionsApi.js +69 -251
  68. package/src/api/StatusUpdatesApi.js +42 -134
  69. package/src/api/StoriesApi.js +51 -173
  70. package/src/api/TagsApi.js +86 -242
  71. package/src/api/TaskTemplatesApi.js +86 -95
  72. package/src/api/TasksApi.js +330 -799
  73. package/src/api/TeamMembershipsApi.js +50 -86
  74. package/src/api/TeamsApi.js +73 -227
  75. package/src/api/TimePeriodsApi.js +24 -56
  76. package/src/api/TimeTrackingEntriesApi.js +51 -173
  77. package/src/api/TypeaheadApi.js +17 -19
  78. package/src/api/UserTaskListsApi.js +20 -80
  79. package/src/api/UsersApi.js +63 -101
  80. package/src/api/WebhooksApi.js +51 -173
  81. package/src/api/WorkspaceMembershipsApi.js +37 -71
  82. package/src/api/WorkspacesApi.js +51 -173
  83. package/src/index.js +2 -2
@@ -6,26 +6,47 @@ on:
6
6
  version:
7
7
  required: true
8
8
 
9
+ defaults:
10
+ run:
11
+ shell: bash
12
+
13
+ permissions:
14
+ contents: read
15
+ id-token: write
16
+
17
+ env:
18
+ GENERATOR_VERSION: 3.0.54
19
+ GENERATOR_NAME: swagger-codegen-cli.jar
20
+ JAR_ASANA: codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar
21
+ ACTUAL_LANG: com.asana.codegen.JavascriptClientCodegenGenerator
22
+ NAME: asana
23
+
9
24
  jobs:
10
25
  generate-javascript-library:
11
26
  name: Generate JavaScript client library
12
27
  runs-on: ubuntu-latest
13
28
  steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-java@v3
29
+ - name: Authenticate to AWS
30
+ uses: aws-actions/configure-aws-credentials@v4
31
+ with:
32
+ aws-region: us-east-1
33
+ role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
34
+ - name: Get GitHub app token
35
+ uses: asana/get-github-app-token@v1
36
+ id: get-token
37
+ with:
38
+ github-app-name: asana-publish-client-libraries
39
+ - name: Checkout repo files and set the git token
40
+ uses: actions/checkout@v4
41
+ with:
42
+ token: ${{ steps.get-token.outputs.app-token }}
43
+ - uses: actions/setup-java@v4
16
44
  with:
17
45
  distribution: "temurin"
18
46
  java-version: "17"
19
- - name: Setup environment variables
20
- run: |
21
- echo "generator_version=3.0.52" >> "$GITHUB_ENV"
22
- echo "generator_name=swagger-codegen-cli.jar" >> "$GITHUB_ENV"
23
- echo "jar_asana=codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar" >> "$GITHUB_ENV"
24
- echo "actual_lang=com.asana.codegen.JavascriptClientCodegenGenerator" >> "$GITHUB_ENV"
25
- echo "name=asana" >> "$GITHUB_ENV"
26
47
  - name: Download generator
27
48
  run: |
28
- wget -q -O $generator_name https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${{ env.generator_version }}/swagger-codegen-cli-${{ env.generator_version }}.jar
49
+ wget -q -O $GENERATOR_NAME https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${{ env.GENERATOR_VERSION }}/swagger-codegen-cli-${{ env.GENERATOR_VERSION }}.jar
29
50
  - name: Build custom code
30
51
  run: |
31
52
  pushd codegen/swagger >/dev/null
@@ -33,34 +54,48 @@ jobs:
33
54
  popd >/dev/null
34
55
  - name: Generate library
35
56
  run: >-
36
- java -cp "${{ env.jar_asana }}:${{ env.generator_name }}"
57
+ java -cp "${{ env.JAR_ASANA }}:${{ env.GENERATOR_NAME }}"
37
58
  io.swagger.codegen.v3.cli.SwaggerCodegen
38
59
  generate
39
60
  --input-spec https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_sdk_oas.yaml
40
61
  --template-dir "codegen/templates"
41
- --lang "${{ env.actual_lang }}"
42
- -DpackageName=${{ env.name }}
43
- --additional-properties "projectVersion=${{ inputs.version }},projectName=${{ env.name }},packageName=${{ env.name }},usePromises=true,useES6=true"
62
+ --lang "${{ env.ACTUAL_LANG }}"
63
+ -DpackageName=${{ env.NAME }}
64
+ --additional-properties "projectVersion=${{ inputs.version }},projectName=${{ env.NAME }},packageName=${{ env.NAME }},usePromises=true,useES6=true"
44
65
  - name: Clean up generator
45
- run: rm -rf codegen/swagger/target ${{ env.generator_name }}
66
+ run: rm -rf codegen/swagger/target ${{ env.GENERATOR_NAME }}
46
67
  - name: Push changes to master branch
47
- uses: EndBug/add-and-commit@v9
48
- with:
49
- message: 'Updated JavaScript SDK: v${{ inputs.version }}'
50
- committer_name: GitHub Actions
51
- committer_email: actions@github.com
52
- tag: 'v${{ inputs.version }} --force'
53
- tag_push: '--force'
54
- build-n-publish-to-npmjs:
68
+ run: |
69
+ git config user.name asana-publish-client-libraries[bot]
70
+ git config user.email 159857493+asana-publish-client-libraries[bot]@users.noreply.github.com
71
+ git add .
72
+ git commit -m 'Updated JavaScript SDK: v${{ inputs.version }}'
73
+ git push origin master
74
+ git pull
75
+ git tag 'v${{ inputs.version }}' --force
76
+ git push origin --tags --force
77
+ publish-to-npmjs:
55
78
  needs: generate-javascript-library
56
79
  name: Build and publish 📦 to npmjs
57
80
  runs-on: ubuntu-latest
58
81
  steps:
59
- - uses: actions/checkout@v3
82
+ - name: Authenticate to AWS
83
+ uses: aws-actions/configure-aws-credentials@v4
84
+ with:
85
+ aws-region: us-east-1
86
+ role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
87
+ - name: Load secrets
88
+ uses: aws-actions/aws-secretsmanager-get-secrets@v1
89
+ with:
90
+ secret-ids: NPM_API,prod/github_actions_release_asana_client_libraries/npm_api_key
91
+ # npm_api_key secret is stored as {key:"***..."}.
92
+ # GitHub Actions environment variable name is NPM_API so to access "key" from the json we can use NPM_API_KEY
93
+ parse-json-secrets: true
94
+ - uses: actions/checkout@v4
60
95
  with:
61
96
  fetch-depth: 0
62
97
  ref: master
63
- - uses: actions/setup-node@v3
98
+ - uses: actions/setup-node@v4
64
99
  with:
65
100
  node-version: "18.x"
66
101
  registry-url: "https://registry.npmjs.com"
@@ -72,17 +107,27 @@ jobs:
72
107
  npm install
73
108
  npm publish
74
109
  env:
75
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
76
- publish-to-github:
77
- needs: build-n-publish-to-npmjs
78
- name: Publish to GitHub Releases
110
+ NODE_AUTH_TOKEN: ${{ env.NPM_API_KEY }}
111
+ publish-to-github-releases:
112
+ needs: publish-to-npmjs
113
+ name: Build and publish to GitHub Releases
79
114
  runs-on: ubuntu-latest
80
115
  steps:
81
- - uses: actions/checkout@v3
116
+ - name: Authenticate to AWS
117
+ uses: aws-actions/configure-aws-credentials@v4
118
+ with:
119
+ aws-region: us-east-1
120
+ role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
121
+ - name: Get GitHub app token
122
+ uses: asana/get-github-app-token@v1
123
+ id: get-token
124
+ with:
125
+ github-app-name: asana-publish-client-libraries
126
+ - uses: actions/checkout@v4
82
127
  with:
83
128
  fetch-depth: 0
84
129
  ref: master
85
- - uses: actions/setup-node@v3
130
+ - uses: actions/setup-node@v4
86
131
  with:
87
132
  node-version: "18.x"
88
133
  registry-url: "https://registry.npmjs.com"
@@ -99,11 +144,6 @@ jobs:
99
144
  browserify dist/index.js -s Asana | uglifyjs > dist/asana-min.js
100
145
  browserify dist/index.js -s Asana > dist/asana.js
101
146
  - name: Publish to GitHub Releases
102
- uses: softprops/action-gh-release@v1
147
+ run: gh release create v${{ inputs.version }} dist/asana.js dist/asana-min.js
103
148
  env:
104
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105
- with:
106
- tag_name: v${{ inputs.version }}
107
- files: |
108
- dist/asana.js
109
- dist/asana-min.js
149
+ GH_TOKEN: ${{ steps.get-token.outputs.app-token }}
@@ -1 +1 @@
1
- 3.0.52
1
+ 3.0.54
package/README.md CHANGED
@@ -1,18 +1,7 @@
1
1
  # asana [![GitHub release][release-image]][release-url] [![NPM Version][npm-image]][npm-url]
2
2
 
3
- > **Important**
4
- > Version 3.X.X is the newest release of our Node client library and currently in public beta. This means that while it has the latest Asana features, we're still putting on the final touches to ensure it's as stable and reliable as possible.
5
- >
6
- >🛠️ **Looking Ahead**
7
- >
8
- > This version will receive updates going forward, and it’s on track to reach full stability soon. Your input is invaluable in this process! If you spot any issues, have suggestions, or need help, don’t hesitate to reach out. You can open a GitHub issue or submit your feedback directly to us.
9
- >
10
- >📖 **Get Started with Examples and Resources**
11
- >
12
- > For now, if you’re in search of a version that has stood the test of time and is proven to be stable, we recommend using version 1.0.2. You can easily install it using: `npm install asana@1.0.2` and following v1 samples and documentation.
13
-
14
3
  - API version: 1.0
15
- - Package version: 3.0.1
4
+ - Package version: 3.0.3
16
5
 
17
6
  ## Installation
18
7
 
@@ -29,7 +18,7 @@ npm install asana --save
29
18
  Include the latest release directly from GitHub:
30
19
 
31
20
  ```html
32
- <script src="https://github.com/Asana/node-asana/releases/download/v3.0.1/asana-min.js"></script>
21
+ <script src="https://github.com/Asana/node-asana/releases/download/v3.0.3/asana-min.js"></script>
33
22
  ```
34
23
 
35
24
  Example usage (**NOTE**: be careful not to expose your access token):
@@ -243,6 +232,7 @@ Class | Method | HTTP request | Description
243
232
  *Asana.MembershipsApi* | [**deleteMembership**](docs/MembershipsApi.md#deleteMembership) | **DELETE** /memberships/{membership_gid} | Delete a membership
244
233
  *Asana.MembershipsApi* | [**getMembership**](docs/MembershipsApi.md#getMembership) | **GET** /memberships/{membership_gid} | Get a membership
245
234
  *Asana.MembershipsApi* | [**getMemberships**](docs/MembershipsApi.md#getMemberships) | **GET** /memberships | Get multiple memberships
235
+ *Asana.MembershipsApi* | [**updateMembership**](docs/MembershipsApi.md#updateMembership) | **PUT** /memberships/{membership_gid} | Update a membership
246
236
  *Asana.OrganizationExportsApi* | [**createOrganizationExport**](docs/OrganizationExportsApi.md#createOrganizationExport) | **POST** /organization_exports | Create an organization export request
247
237
  *Asana.OrganizationExportsApi* | [**getOrganizationExport**](docs/OrganizationExportsApi.md#getOrganizationExport) | **GET** /organization_exports/{organization_export_gid} | Get details on an org export request
248
238
  *Asana.PortfolioMembershipsApi* | [**getPortfolioMembership**](docs/PortfolioMembershipsApi.md#getPortfolioMembership) | **GET** /portfolio_memberships/{portfolio_membership_gid} | Get a portfolio membership
@@ -319,6 +309,7 @@ Class | Method | HTTP request | Description
319
309
  *Asana.TagsApi* | [**getTagsForTask**](docs/TagsApi.md#getTagsForTask) | **GET** /tasks/{task_gid}/tags | Get a task&#x27;s tags
320
310
  *Asana.TagsApi* | [**getTagsForWorkspace**](docs/TagsApi.md#getTagsForWorkspace) | **GET** /workspaces/{workspace_gid}/tags | Get tags in a workspace
321
311
  *Asana.TagsApi* | [**updateTag**](docs/TagsApi.md#updateTag) | **PUT** /tags/{tag_gid} | Update a tag
312
+ *Asana.TaskTemplatesApi* | [**deleteTaskTemplate**](docs/TaskTemplatesApi.md#deleteTaskTemplate) | **DELETE** /task_templates/{task_template_gid} | Delete a task template
322
313
  *Asana.TaskTemplatesApi* | [**getTaskTemplate**](docs/TaskTemplatesApi.md#getTaskTemplate) | **GET** /task_templates/{task_template_gid} | Get a task template
323
314
  *Asana.TaskTemplatesApi* | [**getTaskTemplates**](docs/TaskTemplatesApi.md#getTaskTemplates) | **GET** /task_templates | Get multiple task templates
324
315
  *Asana.TaskTemplatesApi* | [**instantiateTask**](docs/TaskTemplatesApi.md#instantiateTask) | **POST** /task_templates/{task_template_gid}/instantiateTask | Instantiate a task from a task template
@@ -335,6 +326,7 @@ Class | Method | HTTP request | Description
335
326
  *Asana.TasksApi* | [**getDependentsForTask**](docs/TasksApi.md#getDependentsForTask) | **GET** /tasks/{task_gid}/dependents | Get dependents from a task
336
327
  *Asana.TasksApi* | [**getSubtasksForTask**](docs/TasksApi.md#getSubtasksForTask) | **GET** /tasks/{task_gid}/subtasks | Get subtasks from a task
337
328
  *Asana.TasksApi* | [**getTask**](docs/TasksApi.md#getTask) | **GET** /tasks/{task_gid} | Get a task
329
+ *Asana.TasksApi* | [**getTaskForCustomID**](docs/TasksApi.md#getTaskForCustomID) | **GET** /workspaces/{workspace_gid}/tasks/custom_id/{custom_id} | Get a task for a given custom ID
338
330
  *Asana.TasksApi* | [**getTasks**](docs/TasksApi.md#getTasks) | **GET** /tasks | Get multiple tasks
339
331
  *Asana.TasksApi* | [**getTasksForProject**](docs/TasksApi.md#getTasksForProject) | **GET** /projects/{project_gid}/tasks | Get tasks from a project
340
332
  *Asana.TasksApi* | [**getTasksForSection**](docs/TasksApi.md#getTasksForSection) | **GET** /sections/{section_gid}/tasks | Get tasks from a section
@@ -597,22 +589,25 @@ token.accessToken = '<YOUR_ACCESS_TOKEN>';
597
589
 
598
590
  let tasksApiInstance = new Asana.TasksApi();
599
591
  let opts = {
600
- "project": "<YOUR_PROJECT_GID>"
601
- "limit": 100
592
+ "project": "<YOUR_PROJECT_GID>",
593
+ "limit": 100,
602
594
  };
603
595
 
604
596
  async function getAllTasks(opts) {
605
- let tasks = await tasksApiInstance.getTasks(opts).then(async (firstPage) => {
606
- let res = []
607
- res = res.concat(firstPage.data);
608
- // Get the next page
609
- let nextPage = await firstPage.nextPage();
610
- // Keep fetching for the next page until there are no more results
611
- while(nextPage.data) {
612
- res = res.concat(nextPage.data);
613
- nextPage = await nextPage.nextPage();
597
+ let tasks = await tasksApiInstance.getTasks(opts).then(async (response) => {
598
+ let result = [];
599
+ let page = response;
600
+ while(true) {
601
+ // Add items on page to list of results
602
+ result = result.concat(page.data);
603
+ // Fetch the next page
604
+ page = await page.nextPage();
605
+ // If the there is no data in the next page break from the loop
606
+ if (!page.data) {
607
+ break;
608
+ }
614
609
  }
615
- return res;
610
+ return result;
616
611
  }, (error) => {
617
612
  console.error(error.response.body);
618
613
  });
@@ -621,6 +616,79 @@ async function getAllTasks(opts) {
621
616
  }
622
617
 
623
618
  getAllTasks(opts);
619
+
620
+ ```
621
+
622
+ Sample output:
623
+ ```bash
624
+ Tasks: [
625
+ {
626
+ "gid": "123",
627
+ "name": "task 1",
628
+ "resource_type": "task",
629
+ "resource_subtype": "default_task"
630
+ },
631
+ {
632
+ "gid": "456",
633
+ "name": "task 2",
634
+ "resource_type": "task",
635
+ "resource_subtype": "default_task"
636
+ },
637
+ {
638
+ "gid": "789",
639
+ "name": "task 3",
640
+ "resource_type": "task",
641
+ "resource_subtype": "default_task"
642
+ },
643
+ {
644
+ "gid": "101112",
645
+ "name": "task 4",
646
+ "resource_type": "task",
647
+ "resource_subtype": "default_task"
648
+ },
649
+ {
650
+ "gid": "131415",
651
+ "name": "task 5",
652
+ "resource_type": "task",
653
+ "resource_subtype": "default_task"
654
+ },
655
+ {
656
+ "gid": "161718",
657
+ "name": "task 6",
658
+ "resource_type": "task",
659
+ "resource_subtype": "default_task"
660
+ },
661
+ {
662
+ "gid": "192021",
663
+ "name": "task 7",
664
+ "resource_type": "task",
665
+ "resource_subtype": "default_task"
666
+ },
667
+ {
668
+ "gid": "222324",
669
+ "name": "task 8",
670
+ "resource_type": "task",
671
+ "resource_subtype": "default_task"
672
+ },
673
+ {
674
+ "gid": "252627",
675
+ "name": "task 9",
676
+ "resource_type": "task",
677
+ "resource_subtype": "default_task"
678
+ },
679
+ {
680
+ "gid": "282930",
681
+ "name": "task 10",
682
+ "resource_type": "task",
683
+ "resource_subtype": "default_task"
684
+ },
685
+ {
686
+ "gid": "313233",
687
+ "name": "task 11",
688
+ "resource_type": "task",
689
+ "resource_subtype": "default_task"
690
+ },
691
+ ]
624
692
  ```
625
693
 
626
694
  EX: Pagination do something per page
@@ -634,28 +702,55 @@ token.accessToken = '<YOUR_ACCESS_TOKEN>';
634
702
  let tasksApiInstance = new Asana.TasksApi();
635
703
  let opts = {
636
704
  'project': "<YOUR_PROJECT_GID>",
637
- 'limit': 10
705
+ "limit": 5,
638
706
  };
639
707
 
640
- pageIndex = 1;
641
-
642
- tasksApiInstance.getTasks(opts).then(async (firstPage) => {
643
- // Do something with the first <LIMIT> results. EX: print out results
644
- console.log(`Page ${pageIndex}: ` + JSON.stringify(firstPage.data, null, 2));
708
+ let pageIndex = 1;
645
709
 
646
- // Get the next page
647
- let nextPage = await firstPage.nextPage();
648
- // Keep fetching for the next page until there are no more results
649
- while(nextPage.data) {
650
- // Do something with the next <LIMIT> results. EX: print out results
710
+ tasksApiInstance.getTasks(opts).then(async (response) => {
711
+ let page = response;
712
+ while(true) {
713
+ // Do something with the page results
714
+ // EX: print the name of the tasks on that page
715
+ console.log(`Page ${pageIndex}: `);
716
+ page.data.forEach(task => {
717
+ console.log(` ${task.name}`);
718
+ });
651
719
  pageIndex += 1;
652
- console.log(`Page ${pageIndex}: ` + JSON.stringify(nextPage.data, null, 2));
653
- // Get the next page
654
- nextPage = await nextPage.nextPage();
720
+
721
+ page = await page.nextPage();
722
+ // If the there is no data in the next page break from the loop
723
+ if (!page.data) {
724
+ break;
725
+ }
655
726
  }
656
727
  }, (error) => {
657
728
  console.error(error.response.body);
658
729
  });
730
+
731
+ ```
732
+
733
+ Sample output:
734
+
735
+ ```bash
736
+ Page 1:
737
+ task 1
738
+ task 2
739
+ task 3
740
+ task 4
741
+ task 5
742
+ Page 2:
743
+ task 6
744
+ task 7
745
+ task 8
746
+ task 9
747
+ task 10
748
+ Page 3:
749
+ task 11
750
+ task 12
751
+ task 13
752
+ task 14
753
+ task 15
659
754
  ```
660
755
 
661
756
  ### Turning off Pagination
@@ -1011,6 +1106,6 @@ client.callApi(
1011
1106
  ```
1012
1107
 
1013
1108
  [release-image]: https://img.shields.io/github/release/asana/node-asana.svg
1014
- [release-url]: https://github.com/Asana/node-asana/releases/tag/v3.0.1
1109
+ [release-url]: https://github.com/Asana/node-asana/releases/tag/v3.0.3
1015
1110
  [npm-image]: http://img.shields.io/npm/v/asana.svg?style=flat-square
1016
1111
  [npm-url]: https://www.npmjs.org/package/asana
@@ -0,0 +1,19 @@
1
+ # Test Build
2
+
3
+ This directory contains tests that are meant to be ran locally
4
+
5
+ 1. Install dependencies: `npm i`
6
+
7
+ 2. Setup Environment Variables. Create a `.env` file within the root of the project directory with the following information
8
+
9
+ ```
10
+ PERSONAL_ACCESS_TOKEN=<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>
11
+ TEAM_GID=<YOUR_TEAM_GID>
12
+ TEXT_CUSTOM_FIELD_GID=<YOUR_TEXT_CUSTOM_FIELD_GID> -> NOTE: make sure that there is at least one task that has this custom field and the value of the custom field on that task is `custom_value`
13
+ USER_GID=<YOUR_USER_GID>
14
+ WORKSPACE_GID=<YOUR_WORKSPACE_GID>
15
+ ```
16
+
17
+ 3. Run tests: `npm run testbuild`
18
+
19
+ TIP: to debug, add `debugger;` to the location of the test code you want to debug and re-run `npm run testbuild`
@@ -0,0 +1,178 @@
1
+ (function (root, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ // AMD.
4
+ define(["expect.js", "../../src/index"], factory);
5
+ } else if (typeof module === "object" && module.exports) {
6
+ // CommonJS-like environments that support module.exports, like Node.
7
+ factory(require("expect.js"), require("../../src/index"));
8
+ } else {
9
+ // Browser globals (root is window)
10
+ factory(root.expect, root.Asana);
11
+ }
12
+ })(this, function (expect, Asana) {
13
+ "use strict";
14
+
15
+ var TEAM_GID;
16
+ var WORKSPACE_GID;
17
+
18
+ var projectsApiInstance;
19
+ var project;
20
+ var projects;
21
+
22
+ before(async function () {
23
+ require('dotenv').config()
24
+ TEAM_GID = process.env.TEAM_GID;
25
+ WORKSPACE_GID = process.env.WORKSPACE_GID;
26
+
27
+ let client = Asana.ApiClient.instance;
28
+ let token = client.authentications["token"];
29
+ token.accessToken = process.env.PERSONAL_ACCESS_TOKEN;
30
+
31
+ projectsApiInstance = new Asana.ProjectsApi();
32
+ });
33
+
34
+ describe("ProjectsApi", function () {
35
+ describe("createProject", function () {
36
+ it("should have created project", async function () {
37
+ let body = {
38
+ data: {
39
+ name: "Project 1",
40
+ notes: "Some description",
41
+ team: TEAM_GID,
42
+ },
43
+ };
44
+
45
+ try {
46
+ project = await projectsApiInstance.createProject(body, {});
47
+ } catch (error) {
48
+ throw error.response.body;
49
+ }
50
+ expect(project).to.be.ok();
51
+ });
52
+ it("should have a `name`", function () {
53
+ expect(project.data.name).to.be("Project 1");
54
+ });
55
+ it("should have a description/`notes`", function () {
56
+ expect(project.data.notes).to.be("Some description");
57
+ });
58
+ });
59
+ describe("updateProject", function () {
60
+ it("should have updated project", async function () {
61
+ let body = {
62
+ data: {
63
+ name: "Project 1 - Updated",
64
+ notes: "Updated description",
65
+ },
66
+ };
67
+
68
+ try {
69
+ project = await projectsApiInstance.updateProject(
70
+ body,
71
+ project.data.gid,
72
+ {}
73
+ );
74
+ } catch (error) {
75
+ throw error.response.body;
76
+ }
77
+ expect(project).to.be.ok();
78
+ });
79
+ it("should have updated project `name`", function () {
80
+ expect(project.data.name).to.be("Project 1 - Updated");
81
+ });
82
+ it("should have updated project description/`notes`", function () {
83
+ expect(project.data.notes).to.be("Updated description");
84
+ });
85
+ });
86
+ describe("getProject", function () {
87
+ it("should return project", async function () {
88
+ let response;
89
+ try {
90
+ response = await projectsApiInstance.getProject(
91
+ project.data.gid,
92
+ {}
93
+ );
94
+ } catch (error) {
95
+ throw error.response.body;
96
+ }
97
+ expect(response).to.ok();
98
+ });
99
+ });
100
+ describe("getProject with `opt_fields`", function () {
101
+ describe("ask for `html_notes` and `due_on` properties in `opt_fields`", function () {
102
+ it("should return project", async function () {
103
+ let opts = {
104
+ opt_fields: "html_notes,due_on",
105
+ };
106
+
107
+ try {
108
+ project = await projectsApiInstance.getProject(
109
+ project.data.gid,
110
+ opts
111
+ );
112
+ } catch (error) {
113
+ throw error.response.body;
114
+ }
115
+ expect(project).to.ok();
116
+ });
117
+ it("should have `html_notes`", async function () {
118
+ expect(project.data.html_notes).not.to.equal(null);
119
+ });
120
+ it("should have `due_on` with `null` value", async function () {
121
+ expect(project.data.due_on).to.be(null);
122
+ });
123
+ });
124
+ });
125
+ describe("getProjects", function () {
126
+ it("should return an array of projects", async function () {
127
+ let opts = {
128
+ limit: 100,
129
+ workspace: WORKSPACE_GID,
130
+ };
131
+ try {
132
+ projects = await projectsApiInstance.getProjects(opts);
133
+ } catch (error) {
134
+ throw error.response.body;
135
+ }
136
+ expect(projects).to.be.ok();
137
+ expect(projects.data).to.be.an("array");
138
+ });
139
+ });
140
+ describe("getProjects with `opt_fields`", function () {
141
+ describe("ask for `color` and `completed` properties in `opt_fields`", function () {
142
+ it("should return an array of projects", async function () {
143
+ let opts = {
144
+ workspace: WORKSPACE_GID,
145
+ opt_fields: "color,completed",
146
+ };
147
+
148
+ try {
149
+ projects = await projectsApiInstance.getProjects(opts);
150
+ } catch (error) {
151
+ throw error.response.body;
152
+ }
153
+ expect(projects).to.be.ok();
154
+ expect(projects.data).to.be.an("array");
155
+ });
156
+ it("should have `workspace`", function () {
157
+ expect("color" in projects.data[0]).to.be(true);
158
+ });
159
+ it("should have `completed`", function () {
160
+ expect("completed" in projects.data[0]).to.be(true);
161
+ });
162
+ });
163
+ });
164
+ describe("deleteProject", function () {
165
+ it("should be deleted", async function () {
166
+ let response;
167
+ try {
168
+ response = await projectsApiInstance.deleteProject(
169
+ project.data.gid
170
+ );
171
+ } catch (error) {
172
+ throw error.response.body;
173
+ }
174
+ expect(response.data).to.be.empty();
175
+ });
176
+ });
177
+ });
178
+ });