@openfn/language-asana 1.1.0 → 2.0.1
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/README.md +19 -6
- package/ast.json +1 -1
- package/lib/Adaptor.js +19 -11
- package/node_modules/@openfn/language-common/node_modules/axios/package.json +2 -2
- package/node_modules/@openfn/language-common/node_modules/follow-redirects/package.json +2 -2
- package/node_modules/@openfn/language-common/node_modules/jsonpath-plus/package.json +2 -2
- package/node_modules/@openfn/language-common/node_modules/lodash/package.json +2 -2
- package/node_modules/@openfn/language-common/package.json +13 -9
- package/node_modules/date-fns/package.json +13 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,11 +8,23 @@ Language Pack for connecting with Asana.
|
|
|
8
8
|
|
|
9
9
|
```json
|
|
10
10
|
{
|
|
11
|
-
"
|
|
12
|
-
"token": "
|
|
11
|
+
"apiVersion": "1.0",
|
|
12
|
+
"token": "shhhhhhhh"
|
|
13
13
|
}
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
### How to create an API token
|
|
17
|
+
|
|
18
|
+
Using Asana's API requires having an API token. To generate that token, head to
|
|
19
|
+
the [Asana developer console](https://app.asana.com/0/developer-console) and
|
|
20
|
+
enter the **Personal access tokens** section.
|
|
21
|
+
|
|
22
|
+
There you can click on **+New access token**. A prompt will be opened allowing
|
|
23
|
+
you to give the token a name and then create it.
|
|
24
|
+
|
|
25
|
+
_Note: Treat your PAT like you would with a password. Do not share it or display
|
|
26
|
+
it online._
|
|
27
|
+
|
|
16
28
|
### Sample expression
|
|
17
29
|
|
|
18
30
|
## Find a single task of a given project using the task id.
|
|
@@ -53,16 +65,17 @@ createTask({
|
|
|
53
65
|
|
|
54
66
|
## Update a task or create a new one
|
|
55
67
|
|
|
56
|
-
You can use a field name as `externalId` to match a specific task. If
|
|
57
|
-
does not exist, a new one will be created.
|
|
68
|
+
You can use a field name literal as `externalId` to match a specific task. If
|
|
69
|
+
the task does not exist, a new one will be created. The first parameter in this
|
|
70
|
+
function should be the `project_id`.
|
|
58
71
|
|
|
59
72
|
```js
|
|
60
73
|
upsertTask('12344', {
|
|
61
|
-
externalId: '
|
|
74
|
+
externalId: 'name',
|
|
62
75
|
data: {
|
|
63
|
-
gid: '123456',
|
|
64
76
|
name: 'A new task',
|
|
65
77
|
projects: ['12344'],
|
|
78
|
+
notes: 'This is a new task',
|
|
66
79
|
},
|
|
67
80
|
});
|
|
68
81
|
```
|
package/ast.json
CHANGED
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
},
|
|
260
260
|
{
|
|
261
261
|
"title": "example",
|
|
262
|
-
"description": "upsertTask(\n {\n \"externalId\": \"name\",\n \"data\": {\n name: 'test', \"approval_status\": \"pending\", \"assignee\": \"12345\"\n }\n\n }\n)"
|
|
262
|
+
"description": "upsertTask(\n \"1201382240880\",\n {\n \"externalId\": \"name\",\n \"data\": {\n name: 'test', \"approval_status\": \"pending\", \"assignee\": \"12345\"\n }\n\n }\n)"
|
|
263
263
|
},
|
|
264
264
|
{
|
|
265
265
|
"title": "function",
|
package/lib/Adaptor.js
CHANGED
|
@@ -132,10 +132,10 @@ function getTask(task_gid, params, callback) {
|
|
|
132
132
|
opt_fields
|
|
133
133
|
} = (0, _languageCommon.expandReferences)(params)(state);
|
|
134
134
|
const {
|
|
135
|
-
|
|
135
|
+
apiVersion,
|
|
136
136
|
token
|
|
137
137
|
} = state.configuration;
|
|
138
|
-
const url =
|
|
138
|
+
const url = `https://app.asana.com/api/${apiVersion}/tasks/${task_gid}`;
|
|
139
139
|
const config = {
|
|
140
140
|
url,
|
|
141
141
|
headers: {
|
|
@@ -177,10 +177,10 @@ function getTasks(project_gid, params, callback) {
|
|
|
177
177
|
opt_fields
|
|
178
178
|
} = (0, _languageCommon.expandReferences)(params)(state);
|
|
179
179
|
const {
|
|
180
|
-
|
|
180
|
+
apiVersion,
|
|
181
181
|
token
|
|
182
182
|
} = state.configuration;
|
|
183
|
-
const url =
|
|
183
|
+
const url = `https://app.asana.com/api/${apiVersion}/projects/${project_gid}/tasks`;
|
|
184
184
|
const config = {
|
|
185
185
|
url,
|
|
186
186
|
headers: {
|
|
@@ -221,10 +221,10 @@ function updateTask(task_gid, params, callback) {
|
|
|
221
221
|
task_gid = (0, _languageCommon.expandReferences)(task_gid)(state);
|
|
222
222
|
params = (0, _languageCommon.expandReferences)(params)(state);
|
|
223
223
|
const {
|
|
224
|
-
|
|
224
|
+
apiVersion,
|
|
225
225
|
token
|
|
226
226
|
} = state.configuration;
|
|
227
|
-
const url =
|
|
227
|
+
const url = `https://app.asana.com/api/${apiVersion}/tasks/${task_gid}/`;
|
|
228
228
|
const config = {
|
|
229
229
|
url,
|
|
230
230
|
data: {
|
|
@@ -240,6 +240,9 @@ function updateTask(task_gid, params, callback) {
|
|
|
240
240
|
};
|
|
241
241
|
if (callback) return callback(nextState);
|
|
242
242
|
return nextState;
|
|
243
|
+
}).catch(e => {
|
|
244
|
+
console.log('Asana says:', e.response.data);
|
|
245
|
+
throw e;
|
|
243
246
|
});
|
|
244
247
|
};
|
|
245
248
|
}
|
|
@@ -263,10 +266,10 @@ function createTask(params, callback) {
|
|
|
263
266
|
return state => {
|
|
264
267
|
params = (0, _languageCommon.expandReferences)(params)(state);
|
|
265
268
|
const {
|
|
266
|
-
|
|
269
|
+
apiVersion,
|
|
267
270
|
token
|
|
268
271
|
} = state.configuration;
|
|
269
|
-
const url =
|
|
272
|
+
const url = `https://app.asana.com/api/${apiVersion}/tasks/`;
|
|
270
273
|
const config = {
|
|
271
274
|
url,
|
|
272
275
|
data: {
|
|
@@ -282,6 +285,9 @@ function createTask(params, callback) {
|
|
|
282
285
|
};
|
|
283
286
|
if (callback) return callback(nextState);
|
|
284
287
|
return nextState;
|
|
288
|
+
}).catch(e => {
|
|
289
|
+
console.log('Asana says:', e.response.data);
|
|
290
|
+
throw e;
|
|
285
291
|
});
|
|
286
292
|
};
|
|
287
293
|
}
|
|
@@ -290,6 +296,7 @@ function createTask(params, callback) {
|
|
|
290
296
|
* @public
|
|
291
297
|
* @example
|
|
292
298
|
* upsertTask(
|
|
299
|
+
* "1201382240880",
|
|
293
300
|
* {
|
|
294
301
|
* "externalId": "name",
|
|
295
302
|
* "data": {
|
|
@@ -314,10 +321,10 @@ function upsertTask(project_gid, params, callback) {
|
|
|
314
321
|
data
|
|
315
322
|
} = (0, _languageCommon.expandReferences)(params)(state);
|
|
316
323
|
const {
|
|
317
|
-
|
|
324
|
+
apiVersion,
|
|
318
325
|
token
|
|
319
326
|
} = state.configuration;
|
|
320
|
-
const url =
|
|
327
|
+
const url = `https://app.asana.com/api/${apiVersion}/projects/${project_gid}/tasks`;
|
|
321
328
|
const config = {
|
|
322
329
|
url,
|
|
323
330
|
headers: {
|
|
@@ -331,7 +338,8 @@ function upsertTask(project_gid, params, callback) {
|
|
|
331
338
|
const matchingTask = response.data.data.find(task => task[externalId] === data[externalId]);
|
|
332
339
|
|
|
333
340
|
if (matchingTask) {
|
|
334
|
-
console.log('Matching task found. Performing update.');
|
|
341
|
+
console.log('Matching task found. Performing update.');
|
|
342
|
+
console.log('Data to update', data); // projects and workspace ids should ne be included to update
|
|
335
343
|
|
|
336
344
|
delete data.projects;
|
|
337
345
|
delete data.workspace;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
4
|
"axios@0.21.4",
|
|
5
|
-
"/Users/
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-asana"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
8
|
"_from": "axios@0.21.4",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"_resolved": false,
|
|
28
28
|
"_shasum": "c67b90dc0568e5c1cf2b0b858c43ba28e2eda575",
|
|
29
29
|
"_spec": "0.21.4",
|
|
30
|
-
"_where": "/Users/
|
|
30
|
+
"_where": "/Users/taylor/devtools/adaptors/language-asana",
|
|
31
31
|
"author": {
|
|
32
32
|
"name": "Matt Zabriskie"
|
|
33
33
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
4
|
"follow-redirects@1.14.3",
|
|
5
|
-
"/Users/
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-asana"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
8
|
"_from": "follow-redirects@1.14.3",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"_resolved": false,
|
|
28
28
|
"_shasum": "6ada78118d8d24caee595595accdc0ac6abd022e",
|
|
29
29
|
"_spec": "1.14.3",
|
|
30
|
-
"_where": "/Users/
|
|
30
|
+
"_where": "/Users/taylor/devtools/adaptors/language-asana",
|
|
31
31
|
"author": {
|
|
32
32
|
"name": "Ruben Verborgh",
|
|
33
33
|
"email": "ruben@verborgh.org",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
4
|
"jsonpath-plus@4.0.0",
|
|
5
|
-
"/Users/
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-asana"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
8
|
"_from": "jsonpath-plus@4.0.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"_resolved": false,
|
|
28
28
|
"_spec": "4.0.0",
|
|
29
|
-
"_where": "/Users/
|
|
29
|
+
"_where": "/Users/taylor/devtools/adaptors/language-asana",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "Stefan Goessner"
|
|
32
32
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"_args": [
|
|
3
3
|
[
|
|
4
4
|
"lodash@4.17.21",
|
|
5
|
-
"/Users/
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-asana"
|
|
6
6
|
]
|
|
7
7
|
],
|
|
8
8
|
"_from": "lodash@4.17.21",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"_resolved": false,
|
|
28
28
|
"_spec": "4.17.21",
|
|
29
|
-
"_where": "/Users/
|
|
29
|
+
"_where": "/Users/taylor/devtools/adaptors/language-asana",
|
|
30
30
|
"author": {
|
|
31
31
|
"name": "John-David Dalton",
|
|
32
32
|
"email": "john.david.dalton@gmail.com"
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"_args": [
|
|
3
|
+
[
|
|
4
|
+
"@openfn/language-common@1.6.2",
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-asana"
|
|
6
|
+
]
|
|
7
|
+
],
|
|
8
|
+
"_from": "@openfn/language-common@1.6.2",
|
|
3
9
|
"_id": "@openfn/language-common@1.6.2",
|
|
4
10
|
"_inBundle": false,
|
|
5
11
|
"_integrity": "sha512-ZyjpC7S9Tf0zGvvHYQ+0n2PM5hpYLP3/yJImJQXoYa2hpL0yZo5ef0prGzLmPJJECraiRyY6vkBJp/uKg2SRdw==",
|
|
6
12
|
"_location": "/@openfn/language-common",
|
|
7
13
|
"_phantomChildren": {},
|
|
8
14
|
"_requested": {
|
|
9
|
-
"type": "
|
|
15
|
+
"type": "version",
|
|
10
16
|
"registry": true,
|
|
11
|
-
"raw": "@openfn/language-common
|
|
17
|
+
"raw": "@openfn/language-common@1.6.2",
|
|
12
18
|
"name": "@openfn/language-common",
|
|
13
19
|
"escapedName": "@openfn%2flanguage-common",
|
|
14
20
|
"scope": "@openfn",
|
|
15
|
-
"rawSpec": "
|
|
21
|
+
"rawSpec": "1.6.2",
|
|
16
22
|
"saveSpec": null,
|
|
17
|
-
"fetchSpec": "
|
|
23
|
+
"fetchSpec": "1.6.2"
|
|
18
24
|
},
|
|
19
25
|
"_requiredBy": [
|
|
20
26
|
"/"
|
|
21
27
|
],
|
|
22
28
|
"_resolved": "https://registry.npmjs.org/@openfn/language-common/-/language-common-1.6.2.tgz",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"_where": "/Users/mlcisse/Documents/OpenFn/devtools/adaptors/language-asana",
|
|
29
|
+
"_spec": "1.6.2",
|
|
30
|
+
"_where": "/Users/taylor/devtools/adaptors/language-asana",
|
|
26
31
|
"author": {
|
|
27
32
|
"name": "Open Function Group"
|
|
28
33
|
},
|
|
@@ -40,7 +45,6 @@
|
|
|
40
45
|
"jsonpath-plus": "^4.0.0",
|
|
41
46
|
"lodash": "^4.17.19"
|
|
42
47
|
},
|
|
43
|
-
"deprecated": false,
|
|
44
48
|
"description": "Common Expressions for OpenFn",
|
|
45
49
|
"devDependencies": {
|
|
46
50
|
"@babel/cli": "^7.8.4",
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
2
|
+
"_args": [
|
|
3
|
+
[
|
|
4
|
+
"date-fns@2.28.0",
|
|
5
|
+
"/Users/taylor/devtools/adaptors/language-asana"
|
|
6
|
+
]
|
|
7
|
+
],
|
|
8
|
+
"_from": "date-fns@2.28.0",
|
|
3
9
|
"_id": "date-fns@2.28.0",
|
|
4
10
|
"_inBundle": false,
|
|
5
11
|
"_integrity": "sha512-8d35hViGYx/QH0icHYCeLmsLmMUheMmTyV9Fcm6gvNwdw31yXXH+O85sOBJ+OLnLQMKZowvpKb6FgMIQjcpvQw==",
|
|
6
12
|
"_location": "/date-fns",
|
|
7
13
|
"_phantomChildren": {},
|
|
8
14
|
"_requested": {
|
|
9
|
-
"type": "
|
|
15
|
+
"type": "version",
|
|
10
16
|
"registry": true,
|
|
11
|
-
"raw": "date-fns
|
|
17
|
+
"raw": "date-fns@2.28.0",
|
|
12
18
|
"name": "date-fns",
|
|
13
19
|
"escapedName": "date-fns",
|
|
14
|
-
"rawSpec": "
|
|
20
|
+
"rawSpec": "2.28.0",
|
|
15
21
|
"saveSpec": null,
|
|
16
|
-
"fetchSpec": "
|
|
22
|
+
"fetchSpec": "2.28.0"
|
|
17
23
|
},
|
|
18
24
|
"_requiredBy": [
|
|
19
25
|
"/@openfn/language-common"
|
|
20
26
|
],
|
|
21
27
|
"_resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.28.0.tgz",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"_where": "/Users/mlcisse/Documents/OpenFn/devtools/adaptors/language-asana/node_modules/@openfn/language-common",
|
|
28
|
+
"_spec": "2.28.0",
|
|
29
|
+
"_where": "/Users/taylor/devtools/adaptors/language-asana",
|
|
25
30
|
"bugs": {
|
|
26
31
|
"url": "https://github.com/date-fns/date-fns/issues"
|
|
27
32
|
},
|
|
28
|
-
"bundleDependencies": false,
|
|
29
33
|
"contributors": [
|
|
30
34
|
{
|
|
31
35
|
"name": "Sasha Koss",
|
|
@@ -37,7 +41,6 @@
|
|
|
37
41
|
}
|
|
38
42
|
],
|
|
39
43
|
"dependencies": {},
|
|
40
|
-
"deprecated": false,
|
|
41
44
|
"description": "Modern JavaScript date utility library",
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"@babel/cli": "^7.13.10",
|