@openfn/language-asana 1.0.1 → 1.1.0

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 CHANGED
@@ -15,7 +15,15 @@ Language Pack for connecting with Asana.
15
15
 
16
16
  ### Sample expression
17
17
 
18
- ## Find the list of tasks of a given project.
18
+ ## Find a single task of a given project using the task id.
19
+
20
+ ```js
21
+ getTask('1234', {
22
+ opt_fields: 'name,assignee',
23
+ });
24
+ ```
25
+
26
+ ## Find the list of tasks of a given project using the project id.
19
27
 
20
28
  ```js
21
29
  getTasks('22889593722', {
@@ -44,8 +52,9 @@ createTask({
44
52
  ```
45
53
 
46
54
  ## Update a task or create a new one
47
- You can use a field name as `externalId` to match a specific task. If the task does not exist,
48
- a new one will be created.
55
+
56
+ You can use a field name as `externalId` to match a specific task. If the task
57
+ does not exist, a new one will be created.
49
58
 
50
59
  ```js
51
60
  upsertTask('12344', {
package/ast.json CHANGED
@@ -1,5 +1,68 @@
1
1
  {
2
2
  "operations": [
3
+ {
4
+ "name": "getTask",
5
+ "params": [
6
+ "task_gid",
7
+ "params",
8
+ "callback"
9
+ ],
10
+ "docs": {
11
+ "description": "Get a single task of a given project.",
12
+ "tags": [
13
+ {
14
+ "title": "public",
15
+ "description": null,
16
+ "type": null
17
+ },
18
+ {
19
+ "title": "example",
20
+ "description": "getTask(\"task_gid\",\n {\n opt_fields: \"name,notes,assignee\"\n })"
21
+ },
22
+ {
23
+ "title": "function",
24
+ "description": null,
25
+ "name": null
26
+ },
27
+ {
28
+ "title": "param",
29
+ "description": "Globally unique identifier for the task",
30
+ "type": {
31
+ "type": "NameExpression",
32
+ "name": "string"
33
+ },
34
+ "name": "task_gid"
35
+ },
36
+ {
37
+ "title": "param",
38
+ "description": "Query params to include.",
39
+ "type": {
40
+ "type": "NameExpression",
41
+ "name": "object"
42
+ },
43
+ "name": "params"
44
+ },
45
+ {
46
+ "title": "param",
47
+ "description": "(Optional) callback function",
48
+ "type": {
49
+ "type": "NameExpression",
50
+ "name": "function"
51
+ },
52
+ "name": "callback"
53
+ },
54
+ {
55
+ "title": "returns",
56
+ "description": null,
57
+ "type": {
58
+ "type": "NameExpression",
59
+ "name": "Operation"
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ "valid": true
65
+ },
3
66
  {
4
67
  "name": "getTasks",
5
68
  "params": [
package/lib/Adaptor.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.execute = execute;
7
+ exports.getTask = getTask;
7
8
  exports.getTasks = getTasks;
8
9
  exports.updateTask = updateTask;
9
10
  exports.createTask = createTask;
@@ -108,6 +109,51 @@ function execute(...operations) {
108
109
  });
109
110
  };
110
111
  }
112
+ /**
113
+ * Get a single task of a given project.
114
+ * @public
115
+ * @example
116
+ * getTask("task_gid",
117
+ * {
118
+ * opt_fields: "name,notes,assignee"
119
+ * })
120
+ * @function
121
+ * @param {string} task_gid - Globally unique identifier for the task
122
+ * @param {object} params - Query params to include.
123
+ * @param {function} callback - (Optional) callback function
124
+ * @returns {Operation}
125
+ */
126
+
127
+
128
+ function getTask(task_gid, params, callback) {
129
+ return state => {
130
+ task_gid = (0, _languageCommon.expandReferences)(task_gid)(state);
131
+ const {
132
+ opt_fields
133
+ } = (0, _languageCommon.expandReferences)(params)(state);
134
+ const {
135
+ baseUrl,
136
+ token
137
+ } = state.configuration;
138
+ const url = `${baseUrl}/tasks/${task_gid}`;
139
+ const config = {
140
+ url,
141
+ headers: {
142
+ Authorization: `Bearer ${token}`
143
+ },
144
+ params: {
145
+ opt_fields
146
+ }
147
+ };
148
+ return _languageCommon.http.get(config)(state).then(response => {
149
+ const nextState = { ...(0, _languageCommon.composeNextState)(state, response.data),
150
+ response
151
+ };
152
+ if (callback) return callback(nextState);
153
+ return nextState;
154
+ });
155
+ };
156
+ }
111
157
  /**
112
158
  * Get the list of tasks for a given project.
113
159
  * @public
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-asana",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "An adaptor to access objects in Asana",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {