@openfn/language-asana 4.2.2 → 4.3.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/ast.json CHANGED
@@ -359,6 +359,88 @@
359
359
  },
360
360
  "valid": false
361
361
  },
362
+ {
363
+ "name": "searchTask",
364
+ "params": [
365
+ "task",
366
+ "query",
367
+ "options"
368
+ ],
369
+ "docs": {
370
+ "description": "Search for tasks in a workspace by task name.",
371
+ "tags": [
372
+ {
373
+ "title": "public",
374
+ "description": null,
375
+ "type": null
376
+ },
377
+ {
378
+ "title": "example",
379
+ "description": "searchTask(\"Test Search Task\", {\n resource_subtype: \"default_task\",\n sort_by: \"modified_at\"\n});",
380
+ "caption": "Search for a task by name"
381
+ },
382
+ {
383
+ "title": "function",
384
+ "description": null,
385
+ "name": null
386
+ },
387
+ {
388
+ "title": "param",
389
+ "description": "The text or name of the task to search for.",
390
+ "type": {
391
+ "type": "NameExpression",
392
+ "name": "string"
393
+ },
394
+ "name": "task"
395
+ },
396
+ {
397
+ "title": "param",
398
+ "description": "Query params. See {@link https://developers.asana.com/reference/searchtasksforworkspace Docs} for a list of valid parameters.",
399
+ "type": {
400
+ "type": "OptionalType",
401
+ "expression": {
402
+ "type": "NameExpression",
403
+ "name": "object"
404
+ }
405
+ },
406
+ "name": "query"
407
+ },
408
+ {
409
+ "title": "param",
410
+ "description": "(Optional) options argument.",
411
+ "type": {
412
+ "type": "OptionalType",
413
+ "expression": {
414
+ "type": "NameExpression",
415
+ "name": "object"
416
+ }
417
+ },
418
+ "name": "options"
419
+ },
420
+ {
421
+ "title": "param",
422
+ "description": "The workspace to search in. Defaults to the workspace specified in the configuration.",
423
+ "type": {
424
+ "type": "OptionalType",
425
+ "expression": {
426
+ "type": "NameExpression",
427
+ "name": "string"
428
+ }
429
+ },
430
+ "name": "options.workspaceGid"
431
+ },
432
+ {
433
+ "title": "returns",
434
+ "description": "An operation that, when executed, returns the search results in state.data.",
435
+ "type": {
436
+ "type": "NameExpression",
437
+ "name": "Operation"
438
+ }
439
+ }
440
+ ]
441
+ },
442
+ "valid": false
443
+ },
362
444
  {
363
445
  "name": "createTaskStory",
364
446
  "params": [
@@ -17,11 +17,20 @@
17
17
  "examples": [
18
18
  "sample-tokenyWSJdXBACMLLWMNGgADFA"
19
19
  ]
20
+ },
21
+ "workspaceGid": {
22
+ "title": "Workspace GID",
23
+ "type": "string",
24
+ "description": "Globally unique identifier for the workspace or organization.",
25
+ "examples": [
26
+ "12345"
27
+ ]
20
28
  }
21
29
  },
22
30
  "type": "object",
23
31
  "additionalProperties": true,
24
32
  "required": [
25
- "token"
33
+ "token",
34
+ "workspaceGid"
26
35
  ]
27
36
  }
package/dist/index.cjs CHANGED
@@ -40,6 +40,7 @@ __export(src_exports, {
40
40
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
41
41
  merge: () => import_language_common3.merge,
42
42
  request: () => request2,
43
+ searchTask: () => searchTask,
43
44
  sourceValue: () => import_language_common3.sourceValue,
44
45
  updateTask: () => updateTask,
45
46
  upsertTask: () => upsertTask
@@ -69,6 +70,7 @@ __export(Adaptor_exports, {
69
70
  lastReferenceValue: () => import_language_common3.lastReferenceValue,
70
71
  merge: () => import_language_common3.merge,
71
72
  request: () => request2,
73
+ searchTask: () => searchTask,
72
74
  sourceValue: () => import_language_common3.sourceValue,
73
75
  updateTask: () => updateTask,
74
76
  upsertTask: () => upsertTask
@@ -246,6 +248,30 @@ function upsertTask(projectGid, params, callback) {
246
248
  });
247
249
  };
248
250
  }
251
+ function searchTask(task, query = {}, options = {}) {
252
+ return async (state) => {
253
+ const [resolvedTask, resolvedQuery, resolvedOptions] = (0, import_util2.expandReferences)(
254
+ state,
255
+ task,
256
+ query,
257
+ options
258
+ );
259
+ const { workspaceGid = state.configuration.workspaceGid } = resolvedOptions;
260
+ if (!workspaceGid)
261
+ throw new Error("You need to specify Workspace GID");
262
+ const response = await request(
263
+ state,
264
+ `workspaces/${workspaceGid}/tasks/search`,
265
+ {
266
+ query: {
267
+ text: resolvedTask,
268
+ ...resolvedQuery
269
+ }
270
+ }
271
+ );
272
+ return prepareNextState(state, response);
273
+ };
274
+ }
249
275
  function createTaskStory(taskGid, params, callback) {
250
276
  return async (state) => {
251
277
  const [
@@ -315,6 +341,7 @@ var src_default = Adaptor_exports;
315
341
  lastReferenceValue,
316
342
  merge,
317
343
  request,
344
+ searchTask,
318
345
  sourceValue,
319
346
  updateTask,
320
347
  upsertTask
package/dist/index.js CHANGED
@@ -27,6 +27,7 @@ __export(Adaptor_exports, {
27
27
  lastReferenceValue: () => lastReferenceValue,
28
28
  merge: () => merge,
29
29
  request: () => request2,
30
+ searchTask: () => searchTask,
30
31
  sourceValue: () => sourceValue,
31
32
  updateTask: () => updateTask,
32
33
  upsertTask: () => upsertTask
@@ -227,6 +228,30 @@ function upsertTask(projectGid, params, callback) {
227
228
  });
228
229
  };
229
230
  }
231
+ function searchTask(task, query = {}, options = {}) {
232
+ return async (state) => {
233
+ const [resolvedTask, resolvedQuery, resolvedOptions] = expandReferences(
234
+ state,
235
+ task,
236
+ query,
237
+ options
238
+ );
239
+ const { workspaceGid = state.configuration.workspaceGid } = resolvedOptions;
240
+ if (!workspaceGid)
241
+ throw new Error("You need to specify Workspace GID");
242
+ const response = await request(
243
+ state,
244
+ `workspaces/${workspaceGid}/tasks/search`,
245
+ {
246
+ query: {
247
+ text: resolvedTask,
248
+ ...resolvedQuery
249
+ }
250
+ }
251
+ );
252
+ return prepareNextState(state, response);
253
+ };
254
+ }
230
255
  function createTaskStory(taskGid, params, callback) {
231
256
  return async (state) => {
232
257
  const [
@@ -296,6 +321,7 @@ export {
296
321
  lastReferenceValue,
297
322
  merge,
298
323
  request2 as request,
324
+ searchTask,
299
325
  sourceValue,
300
326
  updateTask,
301
327
  upsertTask
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfn/language-asana",
3
- "version": "4.2.2",
3
+ "version": "4.3.0",
4
4
  "label": "Asana",
5
5
  "description": "OpenFn adaptor for accessing objects in Asana",
6
6
  "homepage": "https://docs.openfn.org",
@@ -109,6 +109,24 @@ export function upsertTask(projectGid: string, params: {
109
109
  externalId: string;
110
110
  data: object;
111
111
  }, callback: Function): Operation;
112
+ /**
113
+ * Search for tasks in a workspace by task name.
114
+ * @public
115
+ * @example <caption>Search for a task by name</caption>
116
+ * searchTask("Test Search Task", {
117
+ * resource_subtype: "default_task",
118
+ * sort_by: "modified_at"
119
+ * });
120
+ * @function
121
+ * @param {string} task - The text or name of the task to search for.
122
+ * @param {object} [query] - Query params. See {@link https://developers.asana.com/reference/searchtasksforworkspace Docs} for a list of valid parameters.
123
+ * @param {object} [options] - (Optional) options argument.
124
+ * @param {string} [options.workspaceGid] - The workspace to search in. Defaults to the workspace specified in the configuration.
125
+ * @returns {Operation} An operation that, when executed, returns the search results in state.data.
126
+ */
127
+ export function searchTask(task: string, query?: object, options?: {
128
+ workspaceGid?: string;
129
+ }): Operation;
112
130
  /**
113
131
  * Options provided to the createTaskStory request
114
132
  * @typedef {Object} StoryOptions