@openfn/language-asana 3.3.0 → 4.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/ast.json CHANGED
@@ -304,6 +304,143 @@
304
304
  ]
305
305
  },
306
306
  "valid": true
307
+ },
308
+ {
309
+ "name": "createTaskStory",
310
+ "params": [
311
+ "taskGid",
312
+ "params",
313
+ "callback"
314
+ ],
315
+ "docs": {
316
+ "description": "Options provided to the createTaskStory request",
317
+ "tags": [
318
+ {
319
+ "title": "typedef",
320
+ "description": null,
321
+ "type": {
322
+ "type": "NameExpression",
323
+ "name": "Object"
324
+ },
325
+ "name": "StoryOptions"
326
+ },
327
+ {
328
+ "title": "public",
329
+ "description": null,
330
+ "type": null
331
+ },
332
+ {
333
+ "title": "property",
334
+ "description": "The plain text of the comment to add. Cannot be used with html_text.",
335
+ "type": {
336
+ "type": "NameExpression",
337
+ "name": "string"
338
+ },
339
+ "name": "text"
340
+ },
341
+ {
342
+ "title": "property",
343
+ "description": "Opt In. HTML formatted text for a comment. This will not include the name of the creator.",
344
+ "type": {
345
+ "type": "NameExpression",
346
+ "name": "string"
347
+ },
348
+ "name": "html_text"
349
+ },
350
+ {
351
+ "title": "property",
352
+ "description": "Default to `false`. Whether the story should be pinned on the resource.",
353
+ "type": {
354
+ "type": "NameExpression",
355
+ "name": "boolean"
356
+ },
357
+ "name": "is_pinned"
358
+ },
359
+ {
360
+ "title": "property",
361
+ "description": "The name of the sticker in this story. `null` if there is no sticker.",
362
+ "type": {
363
+ "type": "NameExpression",
364
+ "name": "string"
365
+ },
366
+ "name": "sticker_name"
367
+ },
368
+ {
369
+ "title": "property",
370
+ "description": "Opt In. This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.",
371
+ "type": {
372
+ "type": "NameExpression",
373
+ "name": "array"
374
+ },
375
+ "name": "opt_fields"
376
+ },
377
+ {
378
+ "title": "property",
379
+ "description": "Defaults to `false`. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.",
380
+ "type": {
381
+ "type": "NameExpression",
382
+ "name": "boolean"
383
+ },
384
+ "name": "opt_pretty"
385
+ }
386
+ ]
387
+ },
388
+ "valid": false
389
+ },
390
+ {
391
+ "name": "request",
392
+ "params": [
393
+ "path",
394
+ "params",
395
+ "callback"
396
+ ],
397
+ "docs": {
398
+ "description": "Options provided to the Asana API request",
399
+ "tags": [
400
+ {
401
+ "title": "typedef",
402
+ "description": null,
403
+ "type": {
404
+ "type": "NameExpression",
405
+ "name": "Object"
406
+ },
407
+ "name": "RequestOptions"
408
+ },
409
+ {
410
+ "title": "public",
411
+ "description": null,
412
+ "type": null
413
+ },
414
+ {
415
+ "title": "property",
416
+ "description": "Body data to append to the request.",
417
+ "type": {
418
+ "type": "NameExpression",
419
+ "name": "object"
420
+ },
421
+ "name": "body"
422
+ },
423
+ {
424
+ "title": "property",
425
+ "description": "An object of query parameters to be encoded into the URL.",
426
+ "type": {
427
+ "type": "NameExpression",
428
+ "name": "object"
429
+ },
430
+ "name": "query"
431
+ },
432
+ {
433
+ "title": "property",
434
+ "description": "The HTTP method to use. Defaults to `GET`",
435
+ "type": {
436
+ "type": "NameExpression",
437
+ "name": "string"
438
+ },
439
+ "name": "method"
440
+ }
441
+ ]
442
+ },
443
+ "valid": false
307
444
  }
308
445
  ],
309
446
  "exports": [],
@@ -321,15 +458,15 @@
321
458
  "description": null,
322
459
  "type": null
323
460
  },
324
- {
325
- "title": "example",
326
- "description": "fn(state => {\n // do some things to state\n return state;\n});"
327
- },
328
461
  {
329
462
  "title": "function",
330
463
  "description": null,
331
464
  "name": null
332
465
  },
466
+ {
467
+ "title": "example",
468
+ "description": "fn(state => {\n // do some things to state\n return state;\n});"
469
+ },
333
470
  {
334
471
  "title": "param",
335
472
  "description": "is the function",
@@ -365,15 +502,15 @@
365
502
  "description": null,
366
503
  "type": null
367
504
  },
368
- {
369
- "title": "example",
370
- "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
371
- },
372
505
  {
373
506
  "title": "function",
374
507
  "description": null,
375
508
  "name": null
376
509
  },
510
+ {
511
+ "title": "example",
512
+ "description": "fnIf((state) => state?.data?.name, get(\"https://example.com\"));"
513
+ },
377
514
  {
378
515
  "title": "param",
379
516
  "description": "The condition that returns true",
@@ -417,15 +554,15 @@
417
554
  "description": null,
418
555
  "type": null
419
556
  },
420
- {
421
- "title": "example",
422
- "description": "sourceValue('$.key')"
423
- },
424
557
  {
425
558
  "title": "function",
426
559
  "description": null,
427
560
  "name": null
428
561
  },
562
+ {
563
+ "title": "example",
564
+ "description": "sourceValue('$.key')"
565
+ },
429
566
  {
430
567
  "title": "param",
431
568
  "description": "JSONPath referencing a point in `state`.",
@@ -460,15 +597,15 @@
460
597
  "description": null,
461
598
  "type": null
462
599
  },
463
- {
464
- "title": "example",
465
- "description": "dataPath('key')"
466
- },
467
600
  {
468
601
  "title": "function",
469
602
  "description": null,
470
603
  "name": null
471
604
  },
605
+ {
606
+ "title": "example",
607
+ "description": "dataPath('key')"
608
+ },
472
609
  {
473
610
  "title": "param",
474
611
  "description": "JSONPath referencing a point in `data`.",
@@ -503,15 +640,15 @@
503
640
  "description": null,
504
641
  "type": null
505
642
  },
506
- {
507
- "title": "example",
508
- "description": "dataValue('key')"
509
- },
510
643
  {
511
644
  "title": "function",
512
645
  "description": null,
513
646
  "name": null
514
647
  },
648
+ {
649
+ "title": "example",
650
+ "description": "dataValue('key')"
651
+ },
515
652
  {
516
653
  "title": "param",
517
654
  "description": "JSONPath referencing a point in `data`.",
@@ -546,15 +683,15 @@
546
683
  "description": null,
547
684
  "type": null
548
685
  },
549
- {
550
- "title": "example",
551
- "description": "lastReferenceValue('key')"
552
- },
553
686
  {
554
687
  "title": "function",
555
688
  "description": null,
556
689
  "name": null
557
690
  },
691
+ {
692
+ "title": "example",
693
+ "description": "lastReferenceValue('key')"
694
+ },
558
695
  {
559
696
  "title": "param",
560
697
  "description": "JSONPath referencing a point in `references`.",
@@ -590,15 +727,15 @@
590
727
  "description": null,
591
728
  "type": null
592
729
  },
593
- {
594
- "title": "example",
595
- "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
596
- },
597
730
  {
598
731
  "title": "function",
599
732
  "description": null,
600
733
  "name": null
601
734
  },
735
+ {
736
+ "title": "example",
737
+ "description": "each(\"$.[*]\",\n create(\"SObject\",\n field(\"FirstName\", sourceValue(\"$.firstName\"))\n )\n)"
738
+ },
602
739
  {
603
740
  "title": "param",
604
741
  "description": "JSONPath referencing a point in `state`.",
@@ -643,15 +780,15 @@
643
780
  "description": null,
644
781
  "type": null
645
782
  },
646
- {
647
- "title": "example",
648
- "description": "field('destination_field_name__c', 'value')"
649
- },
650
783
  {
651
784
  "title": "function",
652
785
  "description": null,
653
786
  "name": null
654
787
  },
788
+ {
789
+ "title": "example",
790
+ "description": "field('destination_field_name__c', 'value')"
791
+ },
655
792
  {
656
793
  "title": "param",
657
794
  "description": "Name of the field",
@@ -695,15 +832,15 @@
695
832
  "description": null,
696
833
  "type": null
697
834
  },
698
- {
699
- "title": "example",
700
- "description": "fields(list_of_fields)"
701
- },
702
835
  {
703
836
  "title": "function",
704
837
  "description": null,
705
838
  "name": null
706
839
  },
840
+ {
841
+ "title": "example",
842
+ "description": "fields(list_of_fields)"
843
+ },
707
844
  {
708
845
  "title": "param",
709
846
  "description": "a list of fields",
@@ -748,6 +885,11 @@
748
885
  "description": null,
749
886
  "name": null
750
887
  },
888
+ {
889
+ "title": "public",
890
+ "description": null,
891
+ "type": null
892
+ },
751
893
  {
752
894
  "title": "param",
753
895
  "description": null,
@@ -792,6 +934,11 @@
792
934
  "description": null,
793
935
  "type": null
794
936
  },
937
+ {
938
+ "title": "function",
939
+ "description": null,
940
+ "name": null
941
+ },
795
942
  {
796
943
  "title": "example",
797
944
  "description": "cursor($.cursor, { defaultValue: 'today' })",
@@ -802,11 +949,6 @@
802
949
  "description": "cursor(22)",
803
950
  "caption": "Use a pagination cursor"
804
951
  },
805
- {
806
- "title": "function",
807
- "description": null,
808
- "name": null
809
- },
810
952
  {
811
953
  "title": "param",
812
954
  "description": "the cursor value. Usually an ISO date, natural language date, or page number",
package/dist/index.cjs CHANGED
@@ -102,8 +102,10 @@ function request(state, path, params, callback = (s) => s) {
102
102
  response: responseWithoutBody
103
103
  };
104
104
  }).then(callback).catch((err) => {
105
- console.log("Asana says:");
106
- (0, import_util.logResponse)(err);
105
+ if (err.code !== "BASE_URL_MISMATCH") {
106
+ console.log("Asana says:");
107
+ (0, import_util.logResponse)(err);
108
+ }
107
109
  throw err;
108
110
  });
109
111
  }
@@ -232,9 +234,14 @@ function createTaskStory(taskGid, params, callback) {
232
234
  );
233
235
  };
234
236
  }
235
- function request2(path, params, callback) {
237
+ function request2(path, params = {}, callback) {
236
238
  return (state) => {
237
- const [resolvedPath, { body = {}, query = {}, method = "GET" }] = (0, import_util2.expandReferences)(state, path, params);
239
+ const [resolvedPath, resolvedParams] = (0, import_util2.expandReferences)(
240
+ state,
241
+ path,
242
+ params
243
+ );
244
+ const { body = {}, query = {}, method = "GET" } = resolvedParams;
238
245
  return request(
239
246
  state,
240
247
  resolvedPath,
package/dist/index.js CHANGED
@@ -64,8 +64,10 @@ function request(state, path, params, callback = (s) => s) {
64
64
  response: responseWithoutBody
65
65
  };
66
66
  }).then(callback).catch((err) => {
67
- console.log("Asana says:");
68
- logResponse(err);
67
+ if (err.code !== "BASE_URL_MISMATCH") {
68
+ console.log("Asana says:");
69
+ logResponse(err);
70
+ }
69
71
  throw err;
70
72
  });
71
73
  }
@@ -209,9 +211,14 @@ function createTaskStory(taskGid, params, callback) {
209
211
  );
210
212
  };
211
213
  }
212
- function request2(path, params, callback) {
214
+ function request2(path, params = {}, callback) {
213
215
  return (state) => {
214
- const [resolvedPath, { body = {}, query = {}, method = "GET" }] = expandReferences(state, path, params);
216
+ const [resolvedPath, resolvedParams] = expandReferences(
217
+ state,
218
+ path,
219
+ params
220
+ );
221
+ const { body = {}, query = {}, method = "GET" } = resolvedParams;
215
222
  return request(
216
223
  state,
217
224
  resolvedPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-asana",
3
- "version": "3.3.0",
3
+ "version": "4.0.1",
4
4
  "description": "An adaptor to access objects in Asana",
5
5
  "homepage": "https://docs.openfn.org",
6
6
  "repository": {
@@ -10,6 +10,7 @@
10
10
  "exports": {
11
11
  ".": {
12
12
  "import": "./dist/index.js",
13
+ "types": "./types/index.d.ts",
13
14
  "require": "./dist/index.cjs"
14
15
  },
15
16
  "./package.json": "./package.json"
@@ -23,7 +24,7 @@
23
24
  "configuration-schema.json"
24
25
  ],
25
26
  "dependencies": {
26
- "@openfn/language-common": "^1.14.0"
27
+ "@openfn/language-common": "2.0.1"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@openfn/simple-ast": "0.4.1",
@@ -94,6 +94,7 @@ export function upsertTask(projectGid: string, params: object, callback: Functio
94
94
  /**
95
95
  * Options provided to the createTaskStory request
96
96
  * @typedef {Object} StoryOptions
97
+ * @public
97
98
  * @property {string} text - The plain text of the comment to add. Cannot be used with html_text.
98
99
  * @property {string} html_text - Opt In. HTML formatted text for a comment. This will not include the name of the creator.
99
100
  * @property {boolean} is_pinned - Default to `false`. Whether the story should be pinned on the resource.
@@ -122,21 +123,28 @@ export function createTaskStory(taskGid: string, params: StoryOptions, callback:
122
123
  /**
123
124
  * Options provided to the Asana API request
124
125
  * @typedef {Object} RequestOptions
126
+ * @public
125
127
  * @property {object} body - Body data to append to the request.
126
128
  * @property {object} query - An object of query parameters to be encoded into the URL.
127
129
  * @property {string} method - The HTTP method to use. Defaults to `GET`
128
130
  */
129
131
  /**
130
- * Make a request in Asana API
132
+ * Make a HTTP request against the Asana API.
131
133
  * @public
132
- * @example
133
- * request("/asanaEndpoint", {
134
+ * @example Get a task by id
135
+ * request("/tasks/1234");
136
+ * @example Query for tasks in a given project
137
+ * request("/tasks", {
138
+ * query: { project: "abc" },
139
+ * });
140
+ * @example Create a new task
141
+ * request("/tasks", {
134
142
  * method: "POST",
135
- * query: { foo: "bar", a: 1 },
143
+ * body: { data: { name: "do the thing", completed: false } },
136
144
  * });
137
145
  * @function
138
- * @param {string} path - Path to resource
139
- * @param {RequestOptions} params - Query, body and method parameters
146
+ * @param {string} path - Path to resource (excluding api/version)
147
+ * @param {RequestOptions} params - (Optional) Query, body and method parameters
140
148
  * @param {function} callback - (Optional) Callback function
141
149
  * @returns {Operation}
142
150
  */
@@ -144,47 +152,9 @@ export function request(path: string, params: RequestOptions, callback: Function
144
152
  /**
145
153
  * Options provided to the createTaskStory request
146
154
  */
147
- export type StoryOptions = {
148
- /**
149
- * - The plain text of the comment to add. Cannot be used with html_text.
150
- */
151
- text: string;
152
- /**
153
- * - Opt In. HTML formatted text for a comment. This will not include the name of the creator.
154
- */
155
- html_text: string;
156
- /**
157
- * - Default to `false`. Whether the story should be pinned on the resource.
158
- */
159
- is_pinned: boolean;
160
- /**
161
- * - The name of the sticker in this story. `null` if there is no sticker.
162
- */
163
- sticker_name: string;
164
- /**
165
- * - Opt In. This endpoint returns a compact resource, which excludes some properties by default. To include those optional properties, set this query parameter to a comma-separated list of the properties you wish to include.
166
- */
167
- opt_fields: any[];
168
- /**
169
- * - Defaults to `false`. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.
170
- */
171
- opt_pretty: boolean;
172
- };
155
+ export type StoryOptions = any;
173
156
  /**
174
157
  * Options provided to the Asana API request
175
158
  */
176
- export type RequestOptions = {
177
- /**
178
- * - Body data to append to the request.
179
- */
180
- body: object;
181
- /**
182
- * - An object of query parameters to be encoded into the URL.
183
- */
184
- query: object;
185
- /**
186
- * - The HTTP method to use. Defaults to `GET`
187
- */
188
- method: string;
189
- };
159
+ export type RequestOptions = any;
190
160
  export { alterState, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, http, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";