11import asana from "../../asana.app.mjs" ;
22import common from "../common/common.mjs" ;
3+ import { ConfigurationError } from "@pipedream/platform" ;
34
45export default {
56 key : "asana-search-tasks" ,
67 name : "Search Tasks" ,
78 description : "Searches for a Task by name within a Project. [See the documentation](https://developers.asana.com/docs/get-multiple-tasks)" ,
8- version : "0.3.1 " ,
9+ version : "0.3.2 " ,
910 type : "action" ,
1011 props : {
1112 ...common . props ,
13+ project : {
14+ ...common . props . project ,
15+ optional : true ,
16+ } ,
1217 name : {
1318 label : "Name" ,
1419 description : "The task name to search for." ,
@@ -30,7 +35,7 @@ export default {
3035 section : {
3136 label : "Section" ,
3237 type : "string" ,
33- description : "The section to filter tasks on." ,
38+ description : "The section to filter tasks on. Must specify Project to list options. " ,
3439 optional : true ,
3540 propDefinition : [
3641 asana ,
@@ -40,33 +45,44 @@ export default {
4045 } ) ,
4146 ] ,
4247 } ,
43- completed_since : {
48+ completedSince : {
4449 label : "Completed Since" ,
4550 type : "string" ,
4651 description : "Only return tasks that are either incomplete or that have been completed since this time. ISO 8601 date string" ,
4752 optional : true ,
4853 } ,
49- modified_since : {
54+ modifiedSince : {
5055 label : "Modified Since" ,
5156 type : "string" ,
5257 description : "Only return tasks that have been modified since the given time. ISO 8601 date string" ,
5358 optional : true ,
5459 } ,
5560 } ,
5661 async run ( { $ } ) {
57- if ( ( ! this . workspace || ! this . assignee ) && ! this . project && ! this . section ) {
58- throw new Error ( "You must specify a Project or Section if you do not specify Assignee and Workspace" ) ;
62+ if ( ! this . project && ! this . section && ! this . assignee ) {
63+ throw new ConfigurationError ( "Must specify one of Project, Section, or Assignee" ) ;
64+ }
65+
66+ if ( ( this . project || this . section ) && this . assignee ) {
67+ throw new ConfigurationError ( "Must specify only one of Assignee, Project, or Project + Section" ) ;
68+ }
69+
70+ const params = {
71+ completed_since : this . completedSince ,
72+ modified_since : this . modifiedSince ,
73+ } ;
74+
75+ if ( this . assignee ) {
76+ params . assignee = this . assignee ;
77+ params . workspace = this . workspace ;
78+ } else if ( this . section ) {
79+ params . section = this . section ;
80+ } else {
81+ params . project = this . project ;
5982 }
6083
6184 const { data : tasks } = await this . asana . getTasks ( {
62- params : {
63- assignee : this . assignee ,
64- project : this . project ,
65- section : this . section ,
66- workspace : this . workspace ,
67- completed_since : this . completed_since ,
68- modified_since : this . modified_since ,
69- } ,
85+ params,
7086 $,
7187 } ) ;
7288
0 commit comments