@openfn/language-asana 2.1.6 → 2.1.7

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
@@ -16,6 +16,7 @@ definition.
16
16
  Using Asana's API requires having an API token. To generate that token, head to
17
17
  the [Asana developer console](https://app.asana.com/0/developer-console) and
18
18
  enter the **Personal access tokens** section.
19
+ [For API Reference docs](https://developers.asana.com/docs/api-explorer)
19
20
 
20
21
  There you can click on **+New access token**. A prompt will be opened allowing
21
22
  you to give the token a name and then create it.
package/ast.json CHANGED
@@ -321,15 +321,15 @@
321
321
  "description": null,
322
322
  "type": null
323
323
  },
324
- {
325
- "title": "example",
326
- "description": "fn(state => {\n // do some things to state\n return state;\n});"
327
- },
328
324
  {
329
325
  "title": "function",
330
326
  "description": null,
331
327
  "name": null
332
328
  },
329
+ {
330
+ "title": "example",
331
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
332
+ },
333
333
  {
334
334
  "title": "param",
335
335
  "description": "is the function",
@@ -364,15 +364,15 @@
364
364
  "description": null,
365
365
  "type": null
366
366
  },
367
- {
368
- "title": "example",
369
- "description": "sourceValue('$.key')"
370
- },
371
367
  {
372
368
  "title": "function",
373
369
  "description": null,
374
370
  "name": null
375
371
  },
372
+ {
373
+ "title": "example",
374
+ "description": "sourceValue('$.key')"
375
+ },
376
376
  {
377
377
  "title": "param",
378
378
  "description": "JSONPath referencing a point in `state`.",
@@ -407,15 +407,15 @@
407
407
  "description": null,
408
408
  "type": null
409
409
  },
410
- {
411
- "title": "example",
412
- "description": "dataPath('key')"
413
- },
414
410
  {
415
411
  "title": "function",
416
412
  "description": null,
417
413
  "name": null
418
414
  },
415
+ {
416
+ "title": "example",
417
+ "description": "dataPath('key')"
418
+ },
419
419
  {
420
420
  "title": "param",
421
421
  "description": "JSONPath referencing a point in `data`.",
@@ -450,15 +450,15 @@
450
450
  "description": null,
451
451
  "type": null
452
452
  },
453
- {
454
- "title": "example",
455
- "description": "dataValue('key')"
456
- },
457
453
  {
458
454
  "title": "function",
459
455
  "description": null,
460
456
  "name": null
461
457
  },
458
+ {
459
+ "title": "example",
460
+ "description": "dataValue('key')"
461
+ },
462
462
  {
463
463
  "title": "param",
464
464
  "description": "JSONPath referencing a point in `data`.",
@@ -493,15 +493,15 @@
493
493
  "description": null,
494
494
  "type": null
495
495
  },
496
- {
497
- "title": "example",
498
- "description": "lastReferenceValue('key')"
499
- },
500
496
  {
501
497
  "title": "function",
502
498
  "description": null,
503
499
  "name": null
504
500
  },
501
+ {
502
+ "title": "example",
503
+ "description": "lastReferenceValue('key')"
504
+ },
505
505
  {
506
506
  "title": "param",
507
507
  "description": "JSONPath referencing a point in `references`.",
@@ -537,15 +537,15 @@
537
537
  "description": null,
538
538
  "type": null
539
539
  },
540
- {
541
- "title": "example",
542
- "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
543
- },
544
540
  {
545
541
  "title": "function",
546
542
  "description": null,
547
543
  "name": null
548
544
  },
545
+ {
546
+ "title": "example",
547
+ "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
548
+ },
549
549
  {
550
550
  "title": "param",
551
551
  "description": "JSONPath referencing a point in `state`.",
@@ -590,15 +590,15 @@
590
590
  "description": null,
591
591
  "type": null
592
592
  },
593
- {
594
- "title": "example",
595
- "description": "field('destination_field_name__c', 'value')"
596
- },
597
593
  {
598
594
  "title": "function",
599
595
  "description": null,
600
596
  "name": null
601
597
  },
598
+ {
599
+ "title": "example",
600
+ "description": "field('destination_field_name__c', 'value')"
601
+ },
602
602
  {
603
603
  "title": "param",
604
604
  "description": "Name of the field",
@@ -642,15 +642,15 @@
642
642
  "description": null,
643
643
  "type": null
644
644
  },
645
- {
646
- "title": "example",
647
- "description": "fields(list_of_fields)"
648
- },
649
645
  {
650
646
  "title": "function",
651
647
  "description": null,
652
648
  "name": null
653
649
  },
650
+ {
651
+ "title": "example",
652
+ "description": "fields(list_of_fields)"
653
+ },
654
654
  {
655
655
  "title": "param",
656
656
  "description": "a list of fields",
@@ -695,6 +695,11 @@
695
695
  "description": null,
696
696
  "name": null
697
697
  },
698
+ {
699
+ "title": "public",
700
+ "description": null,
701
+ "type": null
702
+ },
698
703
  {
699
704
  "title": "param",
700
705
  "description": null,
package/dist/index.cjs CHANGED
@@ -77,7 +77,14 @@ function execute(...operations) {
77
77
  });
78
78
  };
79
79
  }
80
- function getTask(task_gid, params, callback) {
80
+ var handleError = (e) => {
81
+ if (e.code && e.message && e.response) {
82
+ console.log(JSON.stringify(e.response.data, null, 2));
83
+ throw new Error(`AxiosError: ${e.code} - ${e.message}`);
84
+ }
85
+ throw e;
86
+ };
87
+ function getTask(task_gid, params = {}, callback) {
81
88
  return (state) => {
82
89
  task_gid = (0, import_language_common.expandReferences)(task_gid)(state);
83
90
  const { opt_fields } = (0, import_language_common.expandReferences)(params)(state);
@@ -98,7 +105,7 @@ function getTask(task_gid, params, callback) {
98
105
  if (callback)
99
106
  return callback(nextState);
100
107
  return nextState;
101
- });
108
+ }).catch(handleError);
102
109
  };
103
110
  }
104
111
  function getTasks(project_gid, params, callback) {
@@ -122,7 +129,7 @@ function getTasks(project_gid, params, callback) {
122
129
  if (callback)
123
130
  return callback(nextState);
124
131
  return nextState;
125
- });
132
+ }).catch(handleError);
126
133
  };
127
134
  }
128
135
  function updateTask(task_gid, params, callback) {
@@ -144,10 +151,7 @@ function updateTask(task_gid, params, callback) {
144
151
  if (callback)
145
152
  return callback(nextState);
146
153
  return nextState;
147
- }).catch((e) => {
148
- console.log("Asana says:", e.response.data);
149
- throw e;
150
- });
154
+ }).catch(handleError);
151
155
  };
152
156
  }
153
157
  function createTask(params, callback) {
@@ -168,10 +172,7 @@ function createTask(params, callback) {
168
172
  if (callback)
169
173
  return callback(nextState);
170
174
  return nextState;
171
- }).catch((e) => {
172
- console.log("Asana says:", e.response.data);
173
- throw e;
174
- });
175
+ }).catch(handleError);
175
176
  };
176
177
  }
177
178
  function upsertTask(project_gid, params, callback) {
@@ -201,7 +202,7 @@ function upsertTask(project_gid, params, callback) {
201
202
  console.log("No matching task found. Performing create.");
202
203
  return createTask(data, callback)(state);
203
204
  }
204
- });
205
+ }).catch(handleError);
205
206
  };
206
207
  }
207
208
 
package/dist/index.js CHANGED
@@ -58,7 +58,14 @@ function execute(...operations) {
58
58
  });
59
59
  };
60
60
  }
61
- function getTask(task_gid, params, callback) {
61
+ var handleError = (e) => {
62
+ if (e.code && e.message && e.response) {
63
+ console.log(JSON.stringify(e.response.data, null, 2));
64
+ throw new Error(`AxiosError: ${e.code} - ${e.message}`);
65
+ }
66
+ throw e;
67
+ };
68
+ function getTask(task_gid, params = {}, callback) {
62
69
  return (state) => {
63
70
  task_gid = expandReferences(task_gid)(state);
64
71
  const { opt_fields } = expandReferences(params)(state);
@@ -79,7 +86,7 @@ function getTask(task_gid, params, callback) {
79
86
  if (callback)
80
87
  return callback(nextState);
81
88
  return nextState;
82
- });
89
+ }).catch(handleError);
83
90
  };
84
91
  }
85
92
  function getTasks(project_gid, params, callback) {
@@ -103,7 +110,7 @@ function getTasks(project_gid, params, callback) {
103
110
  if (callback)
104
111
  return callback(nextState);
105
112
  return nextState;
106
- });
113
+ }).catch(handleError);
107
114
  };
108
115
  }
109
116
  function updateTask(task_gid, params, callback) {
@@ -125,10 +132,7 @@ function updateTask(task_gid, params, callback) {
125
132
  if (callback)
126
133
  return callback(nextState);
127
134
  return nextState;
128
- }).catch((e) => {
129
- console.log("Asana says:", e.response.data);
130
- throw e;
131
- });
135
+ }).catch(handleError);
132
136
  };
133
137
  }
134
138
  function createTask(params, callback) {
@@ -149,10 +153,7 @@ function createTask(params, callback) {
149
153
  if (callback)
150
154
  return callback(nextState);
151
155
  return nextState;
152
- }).catch((e) => {
153
- console.log("Asana says:", e.response.data);
154
- throw e;
155
- });
156
+ }).catch(handleError);
156
157
  };
157
158
  }
158
159
  function upsertTask(project_gid, params, callback) {
@@ -182,7 +183,7 @@ function upsertTask(project_gid, params, callback) {
182
183
  console.log("No matching task found. Performing create.");
183
184
  return createTask(data, callback)(state);
184
185
  }
185
- });
186
+ }).catch(handleError);
186
187
  };
187
188
  }
188
189
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-asana",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "An adaptor to access objects in Asana",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {