asana 3.0.0 → 3.0.2
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.
- package/.github/workflows/publish.yaml +1 -1
- package/.swagger-codegen/VERSION +1 -1
- package/README.md +15 -21
- package/build-tests/README.md +19 -0
- package/build-tests/api/ProjectsApi.js +178 -0
- package/build-tests/api/TasksApi.js +260 -0
- package/codegen/swagger/src/main/java/com/asana/codegen/JavascriptClientCodegenGenerator.java +1 -1
- package/codegen/templates/ApiClient.mustache +18 -10
- package/codegen/templates/README.mustache +12 -18
- package/codegen/templates/package.mustache +3 -1
- package/dist/ApiClient.js +30 -24
- package/dist/api/AttachmentsApi.js +16 -16
- package/dist/api/AuditLogAPIApi.js +16 -16
- package/dist/api/BatchAPIApi.js +16 -16
- package/dist/api/CustomFieldSettingsApi.js +16 -16
- package/dist/api/CustomFieldsApi.js +16 -16
- package/dist/api/EventsApi.js +16 -16
- package/dist/api/GoalRelationshipsApi.js +16 -16
- package/dist/api/GoalsApi.js +18 -16
- package/dist/api/JobsApi.js +16 -16
- package/dist/api/MembershipsApi.js +16 -16
- package/dist/api/OrganizationExportsApi.js +16 -16
- package/dist/api/PortfolioMembershipsApi.js +16 -16
- package/dist/api/PortfoliosApi.js +16 -16
- package/dist/api/ProjectBriefsApi.js +16 -16
- package/dist/api/ProjectMembershipsApi.js +16 -16
- package/dist/api/ProjectStatusesApi.js +16 -16
- package/dist/api/ProjectTemplatesApi.js +16 -16
- package/dist/api/ProjectsApi.js +27 -20
- package/dist/api/RulesApi.js +16 -16
- package/dist/api/SectionsApi.js +16 -16
- package/dist/api/StatusUpdatesApi.js +16 -16
- package/dist/api/StoriesApi.js +16 -16
- package/dist/api/TagsApi.js +16 -16
- package/dist/api/TaskTemplatesApi.js +16 -16
- package/dist/api/TasksApi.js +16 -16
- package/dist/api/TeamMembershipsApi.js +16 -16
- package/dist/api/TeamsApi.js +16 -16
- package/dist/api/TimePeriodsApi.js +16 -16
- package/dist/api/TimeTrackingEntriesApi.js +16 -16
- package/dist/api/TypeaheadApi.js +16 -16
- package/dist/api/UserTaskListsApi.js +16 -16
- package/dist/api/UsersApi.js +16 -16
- package/dist/api/WebhooksApi.js +16 -16
- package/dist/api/WorkspaceMembershipsApi.js +16 -16
- package/dist/api/WorkspacesApi.js +16 -16
- package/package.json +3 -1
- package/src/ApiClient.js +20 -12
- package/src/api/AttachmentsApi.js +2 -2
- package/src/api/AuditLogAPIApi.js +2 -2
- package/src/api/BatchAPIApi.js +2 -2
- package/src/api/CustomFieldSettingsApi.js +2 -2
- package/src/api/CustomFieldsApi.js +2 -2
- package/src/api/EventsApi.js +2 -2
- package/src/api/GoalRelationshipsApi.js +2 -2
- package/src/api/GoalsApi.js +4 -2
- package/src/api/JobsApi.js +2 -2
- package/src/api/MembershipsApi.js +2 -2
- package/src/api/OrganizationExportsApi.js +2 -2
- package/src/api/PortfolioMembershipsApi.js +2 -2
- package/src/api/PortfoliosApi.js +2 -2
- package/src/api/ProjectBriefsApi.js +2 -2
- package/src/api/ProjectMembershipsApi.js +2 -2
- package/src/api/ProjectStatusesApi.js +2 -2
- package/src/api/ProjectTemplatesApi.js +2 -2
- package/src/api/ProjectsApi.js +13 -7
- package/src/api/RulesApi.js +2 -2
- package/src/api/SectionsApi.js +2 -2
- package/src/api/StatusUpdatesApi.js +2 -2
- package/src/api/StoriesApi.js +2 -2
- package/src/api/TagsApi.js +2 -2
- package/src/api/TaskTemplatesApi.js +2 -2
- package/src/api/TasksApi.js +2 -2
- package/src/api/TeamMembershipsApi.js +2 -2
- package/src/api/TeamsApi.js +2 -2
- package/src/api/TimePeriodsApi.js +2 -2
- package/src/api/TimeTrackingEntriesApi.js +2 -2
- package/src/api/TypeaheadApi.js +2 -2
- package/src/api/UserTaskListsApi.js +2 -2
- package/src/api/UsersApi.js +2 -2
- package/src/api/WebhooksApi.js +2 -2
- package/src/api/WorkspaceMembershipsApi.js +2 -2
- package/src/api/WorkspacesApi.js +2 -2
- package/src/index.js +2 -2
|
@@ -18,7 +18,7 @@ jobs:
|
|
|
18
18
|
java-version: "17"
|
|
19
19
|
- name: Setup environment variables
|
|
20
20
|
run: |
|
|
21
|
-
echo "generator_version=3.0.
|
|
21
|
+
echo "generator_version=3.0.52" >> "$GITHUB_ENV"
|
|
22
22
|
echo "generator_name=swagger-codegen-cli.jar" >> "$GITHUB_ENV"
|
|
23
23
|
echo "jar_asana=codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar" >> "$GITHUB_ENV"
|
|
24
24
|
echo "actual_lang=com.asana.codegen.JavascriptClientCodegenGenerator" >> "$GITHUB_ENV"
|
package/.swagger-codegen/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.0.
|
|
1
|
+
3.0.52
|
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.
|
|
4
|
+
- Package version: 3.0.2
|
|
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.
|
|
21
|
+
<script src="https://github.com/Asana/node-asana/releases/download/v3.0.2/asana-min.js"></script>
|
|
33
22
|
```
|
|
34
23
|
|
|
35
24
|
Example usage (**NOTE**: be careful not to expose your access token):
|
|
@@ -721,29 +710,34 @@ let opts = {
|
|
|
721
710
|
};
|
|
722
711
|
const timeouts = 5000
|
|
723
712
|
|
|
713
|
+
// Used to fetch for initial sync token
|
|
724
714
|
const setSyncToken = async () => {
|
|
725
715
|
await eventsApiInstance.getEvents(resource, opts).then((result) => {
|
|
726
|
-
console.log(
|
|
716
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
727
717
|
}, (error) => {
|
|
728
718
|
let syncToken = error.response.body.sync;
|
|
729
719
|
opts['sync'] = syncToken;
|
|
730
|
-
console.log(syncToken);
|
|
731
720
|
});
|
|
732
721
|
}
|
|
733
722
|
|
|
734
723
|
const getEvents = async () => {
|
|
735
|
-
console.log("Setting
|
|
724
|
+
console.log("Setting sync token");
|
|
736
725
|
await setSyncToken();
|
|
737
|
-
// Fetch for new events every 5 seconds
|
|
738
|
-
console.log(`Fetching events every ${timeouts/1000} second(s)
|
|
726
|
+
// Fetch for new events every 5 seconds
|
|
727
|
+
console.log(`Fetching events every ${timeouts/1000} second(s)`);
|
|
739
728
|
while(true) {
|
|
740
729
|
await eventsApiInstance.getEvents(resource, opts).then((result) => {
|
|
741
|
-
|
|
730
|
+
// Print response
|
|
731
|
+
console.log(`Fetching events since sync: ${opts['sync']}`);
|
|
732
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
733
|
+
|
|
734
|
+
// Update the sync token with the new sync token provided in the response
|
|
735
|
+
opts['sync'] = result._response.sync;
|
|
742
736
|
}, (error) => {
|
|
743
737
|
if (error.status === 412) {
|
|
744
738
|
let syncToken = error.response.body.sync;
|
|
745
739
|
opts['sync'] = syncToken;
|
|
746
|
-
console.log(syncToken);
|
|
740
|
+
console.log(`412 error new sync token: ${syncToken}`);
|
|
747
741
|
} else{
|
|
748
742
|
console.error(error.response.text);
|
|
749
743
|
}
|
|
@@ -1006,6 +1000,6 @@ client.callApi(
|
|
|
1006
1000
|
```
|
|
1007
1001
|
|
|
1008
1002
|
[release-image]: https://img.shields.io/github/release/asana/node-asana.svg
|
|
1009
|
-
[release-url]: https://github.com/Asana/node-asana/releases/tag/v3.0.
|
|
1003
|
+
[release-url]: https://github.com/Asana/node-asana/releases/tag/v3.0.2
|
|
1010
1004
|
[npm-image]: http://img.shields.io/npm/v/asana.svg?style=flat-square
|
|
1011
1005
|
[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
|
+
});
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
// NOTE: Because these tests are making live API calls, we decided to write these tests in a particular order to optimize speed and reduce API calls.
|
|
2
|
+
// The down side to this approach is that these tests are tightly coupled.
|
|
3
|
+
(function (root, factory) {
|
|
4
|
+
if (typeof define === "function" && define.amd) {
|
|
5
|
+
// AMD.
|
|
6
|
+
define(["expect.js", "../../src/index"], factory);
|
|
7
|
+
} else if (typeof module === "object" && module.exports) {
|
|
8
|
+
// CommonJS-like environments that support module.exports, like Node.
|
|
9
|
+
factory(require("expect.js"), require("../../src/index"));
|
|
10
|
+
} else {
|
|
11
|
+
// Browser globals (root is window)
|
|
12
|
+
factory(root.expect, root.Asana);
|
|
13
|
+
}
|
|
14
|
+
})(this, function (expect, Asana) {
|
|
15
|
+
"use strict";
|
|
16
|
+
|
|
17
|
+
var TEXT_CUSTOM_FIELD_GID;
|
|
18
|
+
var USER_GID;
|
|
19
|
+
var WORKSPACE_GID;
|
|
20
|
+
|
|
21
|
+
var tasksApiInstance;
|
|
22
|
+
var task;
|
|
23
|
+
var tasks;
|
|
24
|
+
|
|
25
|
+
before(async function () {
|
|
26
|
+
require('dotenv').config()
|
|
27
|
+
TEXT_CUSTOM_FIELD_GID = process.env.TEXT_CUSTOM_FIELD_GID;
|
|
28
|
+
USER_GID = process.env.USER_GID;
|
|
29
|
+
WORKSPACE_GID = process.env.WORKSPACE_GID;
|
|
30
|
+
|
|
31
|
+
let client = Asana.ApiClient.instance;
|
|
32
|
+
let token = client.authentications["token"];
|
|
33
|
+
token.accessToken = process.env.PERSONAL_ACCESS_TOKEN;
|
|
34
|
+
tasksApiInstance = new Asana.TasksApi();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("TasksApi", function () {
|
|
38
|
+
describe("createTask", function () {
|
|
39
|
+
it("should have created task", async function () {
|
|
40
|
+
let body = {
|
|
41
|
+
data: {
|
|
42
|
+
assignee: USER_GID,
|
|
43
|
+
name: "Task 1",
|
|
44
|
+
notes: "Some description",
|
|
45
|
+
workspace: WORKSPACE_GID,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
task = await tasksApiInstance.createTask(body, {});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
throw error.response.body;
|
|
52
|
+
}
|
|
53
|
+
expect(task).to.be.ok();
|
|
54
|
+
});
|
|
55
|
+
it("should have a `name`", function () {
|
|
56
|
+
expect(task.data.name).to.be("Task 1");
|
|
57
|
+
});
|
|
58
|
+
it("should have a description/`notes`", function () {
|
|
59
|
+
expect(task.data.notes).to.be("Some description");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe("updateTask", function () {
|
|
63
|
+
it("should have updated task", async function () {
|
|
64
|
+
let body = {
|
|
65
|
+
data: {
|
|
66
|
+
name: "Task 1 - Updated",
|
|
67
|
+
notes: "Updated description",
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
task = await tasksApiInstance.updateTask(
|
|
72
|
+
body,
|
|
73
|
+
task.data.gid,
|
|
74
|
+
{}
|
|
75
|
+
);
|
|
76
|
+
} catch (error) {
|
|
77
|
+
throw error.response.body;
|
|
78
|
+
}
|
|
79
|
+
expect(task).to.be.ok();
|
|
80
|
+
});
|
|
81
|
+
it("should have updated task `name`", function () {
|
|
82
|
+
expect(task.data.name).to.be("Task 1 - Updated");
|
|
83
|
+
});
|
|
84
|
+
it("should have updated task description/`notes`", function () {
|
|
85
|
+
expect(task.data.notes).to.be("Updated description");
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
describe("getTask", function () {
|
|
89
|
+
it("should return task", async function () {
|
|
90
|
+
let response;
|
|
91
|
+
try {
|
|
92
|
+
response = await tasksApiInstance.getTask(
|
|
93
|
+
task.data.gid,
|
|
94
|
+
{}
|
|
95
|
+
);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
throw error.response.body;
|
|
98
|
+
}
|
|
99
|
+
expect(response).to.ok();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe("getTask with `opt_fields`", function () {
|
|
103
|
+
describe("task for `html_notes` and `due_on` properties in `opt_fields`", function () {
|
|
104
|
+
it("should return task", async function () {
|
|
105
|
+
let opts = {
|
|
106
|
+
opt_fields: "html_notes,due_on",
|
|
107
|
+
};
|
|
108
|
+
try {
|
|
109
|
+
task = await tasksApiInstance.getTask(
|
|
110
|
+
task.data.gid,
|
|
111
|
+
opts
|
|
112
|
+
);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
throw error.response.body;
|
|
115
|
+
}
|
|
116
|
+
expect(task).to.be.ok();
|
|
117
|
+
});
|
|
118
|
+
it("should have `html_notes`", function () {
|
|
119
|
+
expect(task.data.html_notes).not.to.equal(null);
|
|
120
|
+
});
|
|
121
|
+
it("should have `due_on` with `null` value", function () {
|
|
122
|
+
expect(task.data.due_on).to.be(null);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe("getTasks", function () {
|
|
127
|
+
it("should return an array of tasks", async function () {
|
|
128
|
+
let tasksApiInstance = new Asana.TasksApi();
|
|
129
|
+
let opts = {
|
|
130
|
+
limit: 100,
|
|
131
|
+
assignee: USER_GID,
|
|
132
|
+
workspace: WORKSPACE_GID,
|
|
133
|
+
};
|
|
134
|
+
try {
|
|
135
|
+
tasks = await tasksApiInstance.getTasks(opts);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
throw error.response.body;
|
|
138
|
+
}
|
|
139
|
+
expect(tasks).to.be.ok();
|
|
140
|
+
expect(tasks.data).to.be.an("array");
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
describe("getTasks with `opt_fields`", function () {
|
|
144
|
+
describe("ask for `workspace` and `due_on` properties in `opt_fields`", function () {
|
|
145
|
+
it("should return an array of tasks", async function () {
|
|
146
|
+
let tasksApiInstance = new Asana.TasksApi();
|
|
147
|
+
let opts = {
|
|
148
|
+
assignee: USER_GID,
|
|
149
|
+
workspace: WORKSPACE_GID,
|
|
150
|
+
opt_fields: "workspace,due_on",
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
tasks = await tasksApiInstance.getTasks(opts);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
throw error.response.body;
|
|
157
|
+
}
|
|
158
|
+
expect(tasks).to.be.ok();
|
|
159
|
+
expect(tasks.data).to.be.an("array");
|
|
160
|
+
});
|
|
161
|
+
it("should have `workspace`", function () {
|
|
162
|
+
expect(tasks.data[0].workspace).not.to.equal(null);
|
|
163
|
+
});
|
|
164
|
+
it("should have `due_on`", function () {
|
|
165
|
+
expect("due_on" in tasks.data[0]).to.be(true);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
describe("getTasks limit 1", function () {
|
|
170
|
+
it("should return an array with 1 task", async function () {
|
|
171
|
+
let tasksApiInstance = new Asana.TasksApi();
|
|
172
|
+
let opts = {
|
|
173
|
+
limit: 1,
|
|
174
|
+
assignee: USER_GID,
|
|
175
|
+
workspace: WORKSPACE_GID,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
try {
|
|
179
|
+
tasks = await tasksApiInstance.getTasks(opts);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
throw error.response.body;
|
|
182
|
+
}
|
|
183
|
+
expect(tasks.data.length).to.be(1);
|
|
184
|
+
expect(tasks.data).to.be.an("array");
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
describe("searchTasksForWorkspace", function () {
|
|
188
|
+
it("should return an array of tasks", async function () {
|
|
189
|
+
let opts = {
|
|
190
|
+
text: "Task",
|
|
191
|
+
completed: false,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
try {
|
|
195
|
+
tasks = await tasksApiInstance.searchTasksForWorkspace(
|
|
196
|
+
WORKSPACE_GID,
|
|
197
|
+
opts
|
|
198
|
+
);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
throw error.response.body;
|
|
201
|
+
}
|
|
202
|
+
expect(tasks).to.be.ok();
|
|
203
|
+
expect(tasks.data).to.be.an("array");
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
describe("searchTasksForWorkspace with custom field parameter - MATCH", function () {
|
|
207
|
+
it("should return an array with one task that has matching custom field value from search query", async function () {
|
|
208
|
+
let opts = {
|
|
209
|
+
limit: 1,
|
|
210
|
+
[`custom_fields.${TEXT_CUSTOM_FIELD_GID}.value`]:
|
|
211
|
+
"custom_value",
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
tasks = await tasksApiInstance.searchTasksForWorkspace(
|
|
216
|
+
WORKSPACE_GID,
|
|
217
|
+
opts
|
|
218
|
+
);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
throw error.response.body;
|
|
221
|
+
}
|
|
222
|
+
expect(tasks).to.be.ok();
|
|
223
|
+
expect(tasks.data.length).to.be(1);
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
describe("searchTasksForWorkspace with custom field parameter - NO MATCH", function () {
|
|
227
|
+
it("should return an empty array", async function () {
|
|
228
|
+
let opts = {
|
|
229
|
+
[`custom_fields.${TEXT_CUSTOM_FIELD_GID}.value`]:
|
|
230
|
+
"inimw8I23M4FRTPfApu1",
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
try {
|
|
234
|
+
tasks = await tasksApiInstance.searchTasksForWorkspace(
|
|
235
|
+
WORKSPACE_GID,
|
|
236
|
+
opts
|
|
237
|
+
);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
throw error.response.body;
|
|
240
|
+
}
|
|
241
|
+
expect(tasks.data).to.be.empty();
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
describe("deleteTask", function () {
|
|
245
|
+
it("should be deleted", async function () {
|
|
246
|
+
let response;
|
|
247
|
+
try {
|
|
248
|
+
// NOTE: In the above tasks we are setting the global task variable in different tests. Make sure
|
|
249
|
+
// that future tests don't overwrite the original task created with another task otherwise
|
|
250
|
+
// that original task won't be deleted
|
|
251
|
+
response = await tasksApiInstance.deleteTask(task.data.gid);
|
|
252
|
+
} catch (error) {
|
|
253
|
+
throw error.response.body;
|
|
254
|
+
}
|
|
255
|
+
expect(response).to.be.ok();
|
|
256
|
+
expect(response.data).to.be.empty();
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
});
|
package/codegen/swagger/src/main/java/com/asana/codegen/JavascriptClientCodegenGenerator.java
CHANGED
|
@@ -96,7 +96,7 @@ public class JavascriptClientCodegenGenerator extends JavaScriptClientCodegen {
|
|
|
96
96
|
// Update example for requests that require body
|
|
97
97
|
if (!languageSpecificPrimitives.contains(type)) {
|
|
98
98
|
// type is a model class, e.g. User
|
|
99
|
-
p.example = "{\"data\": {\"
|
|
99
|
+
p.example = "{\"data\": {\"<PARAM_1>\": \"<VALUE_1>\", \"<PARAM_2>\": \"<VALUE_2>\",}}";
|
|
100
100
|
p.dataType = "Object";
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
{{>licenseInfo}}
|
|
2
2
|
import superagent from "superagent";
|
|
3
|
-
import querystring from "querystring";
|
|
4
3
|
|
|
5
4
|
{{#emitJSDoc}}/**
|
|
6
5
|
* @module {{#invokerPackage}}{{invokerPackage}}/{{/invokerPackage}}ApiClient
|
|
@@ -420,14 +419,23 @@ export class ApiClient {
|
|
|
420
419
|
request.query(this.normalizeParams(queryParams));
|
|
421
420
|
|
|
422
421
|
// set header parameters
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
422
|
+
if (typeof(navigator) === 'undefined' || typeof(window) === 'undefined') {
|
|
423
|
+
headerParams['X-Asana-Client-Lib'] = new URLSearchParams(
|
|
424
|
+
{
|
|
425
|
+
'version': "{{projectVersion}}",
|
|
426
|
+
'language': 'NodeJS',
|
|
427
|
+
'language_version': process.version,
|
|
428
|
+
'os': process.platform
|
|
429
|
+
}
|
|
430
|
+
).toString();
|
|
431
|
+
} else {
|
|
432
|
+
headerParams['X-Asana-Client-Lib'] = new URLSearchParams(
|
|
433
|
+
{
|
|
434
|
+
'version': "{{projectVersion}}",
|
|
435
|
+
'language': 'BrowserJS'
|
|
436
|
+
}
|
|
437
|
+
).toString();
|
|
438
|
+
}
|
|
431
439
|
request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
|
|
432
440
|
|
|
433
441
|
// set requestAgent if it is set by user
|
|
@@ -449,7 +457,7 @@ export class ApiClient {
|
|
|
449
457
|
}
|
|
450
458
|
|
|
451
459
|
if (contentType === 'application/x-www-form-urlencoded') {
|
|
452
|
-
request.send(
|
|
460
|
+
request.send(new URLSearchParams(this.normalizeParams(formParams)).toString());
|
|
453
461
|
} else if (contentType == 'multipart/form-data') {
|
|
454
462
|
var _formParams = this.normalizeParams(formParams);
|
|
455
463
|
for (var key in _formParams) {
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
# {{projectName}} [![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: {{appVersion}}
|
|
15
4
|
- Package version: {{projectVersion}}
|
|
16
5
|
{{^hideGenerationTimestamp}}
|
|
@@ -516,29 +505,34 @@ let opts = {
|
|
|
516
505
|
};
|
|
517
506
|
const timeouts = 5000
|
|
518
507
|
|
|
508
|
+
// Used to fetch for initial sync token
|
|
519
509
|
const setSyncToken = async () => {
|
|
520
510
|
await eventsApiInstance.getEvents(resource, opts).then((result) => {
|
|
521
|
-
console.log(
|
|
511
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
522
512
|
}, (error) => {
|
|
523
513
|
let syncToken = error.response.body.sync;
|
|
524
514
|
opts['sync'] = syncToken;
|
|
525
|
-
console.log(syncToken);
|
|
526
515
|
});
|
|
527
516
|
}
|
|
528
517
|
|
|
529
518
|
const getEvents = async () => {
|
|
530
|
-
console.log("Setting
|
|
519
|
+
console.log("Setting sync token");
|
|
531
520
|
await setSyncToken();
|
|
532
|
-
// Fetch for new events every 5 seconds
|
|
533
|
-
console.log(`Fetching events every ${timeouts/1000} second(s)
|
|
521
|
+
// Fetch for new events every 5 seconds
|
|
522
|
+
console.log(`Fetching events every ${timeouts/1000} second(s)`);
|
|
534
523
|
while(true) {
|
|
535
524
|
await eventsApiInstance.getEvents(resource, opts).then((result) => {
|
|
536
|
-
|
|
525
|
+
// Print response
|
|
526
|
+
console.log(`Fetching events since sync: ${opts['sync']}`);
|
|
527
|
+
console.log(JSON.stringify(result.data, null, 2));
|
|
528
|
+
|
|
529
|
+
// Update the sync token with the new sync token provided in the response
|
|
530
|
+
opts['sync'] = result._response.sync;
|
|
537
531
|
}, (error) => {
|
|
538
532
|
if (error.status === 412) {
|
|
539
533
|
let syncToken = error.response.body.sync;
|
|
540
534
|
opts['sync'] = syncToken;
|
|
541
|
-
console.log(syncToken);
|
|
535
|
+
console.log(`412 error new sync token: ${syncToken}`);
|
|
542
536
|
} else{
|
|
543
537
|
console.error(error.response.text);
|
|
544
538
|
}
|