File tree Expand file tree Collapse file tree 12 files changed +502
-239
lines changed Expand file tree Collapse file tree 12 files changed +502
-239
lines changed Original file line number Diff line number Diff line change 11import peerdom from "../../peerdom.app.mjs" ;
2- import { axios } from "@pipedream/platform" ;
32
43export default {
54 key : "peerdom-assign-member-to-role" ,
@@ -21,11 +20,37 @@ export default {
2120 "memberId" ,
2221 ] ,
2322 } ,
23+ percentage : {
24+ type : "integer" ,
25+ label : "Percentage" ,
26+ description : "The percentage of the role assigned to the member" ,
27+ optional : true ,
28+ min : 0 ,
29+ max : 100 ,
30+ } ,
31+ focus : {
32+ type : "string" ,
33+ label : "Focus" ,
34+ description : "The focus of the role assigned to the member" ,
35+ optional : true ,
36+ } ,
37+ electedUntil : {
38+ type : "string" ,
39+ label : "Elected Until" ,
40+ description : "The date until which the member is elected to the role (YYYY-MM-DD)" ,
41+ optional : true ,
42+ } ,
2443 } ,
2544 async run ( { $ } ) {
2645 const response = await this . peerdom . assignMemberToRole ( {
46+ $,
2747 roleId : this . roleId ,
28- memberId : this . memberId ,
48+ data : {
49+ peerId : this . memberId ,
50+ percentage : this . percentage ,
51+ focus : this . focus ,
52+ electedUntil : this . electedUntil ,
53+ } ,
2954 } ) ;
3055
3156 $ . export ( "$summary" , `Successfully assigned member with ID ${ this . memberId } to role with ID ${ this . roleId } ` ) ;
Original file line number Diff line number Diff line change 1+ import { ConfigurationError } from "@pipedream/platform" ;
2+ import { parseObject } from "../../common/utils.mjs" ;
13import peerdom from "../../peerdom.app.mjs" ;
2- import { axios } from "@pipedream/platform" ;
34
45export default {
56 key : "peerdom-create-role" ,
67 name : "Create Role" ,
78 description : "Create a new role within a specified circle. [See the documentation](https://api.peerdom.org/v1/docs)" ,
8- version : "0.0.{{ts}} " ,
9+ version : "0.0.1 " ,
910 type : "action" ,
1011 props : {
1112 peerdom,
12- circleId : {
13+ name : {
1314 propDefinition : [
1415 peerdom ,
15- "circleId " ,
16+ "name " ,
1617 ] ,
1718 } ,
18- roleName : {
19+ mapId : {
1920 propDefinition : [
2021 peerdom ,
21- "roleName " ,
22+ "mapId " ,
2223 ] ,
2324 } ,
24- description : {
25+ parentId : {
2526 propDefinition : [
2627 peerdom ,
27- "description" ,
28+ "groupId" ,
29+ ] ,
30+ } ,
31+ electable : {
32+ propDefinition : [
33+ peerdom ,
34+ "electable" ,
35+ ] ,
36+ optional : true ,
37+ } ,
38+ external : {
39+ propDefinition : [
40+ peerdom ,
41+ "external" ,
42+ ] ,
43+ optional : true ,
44+ } ,
45+ color : {
46+ propDefinition : [
47+ peerdom ,
48+ "color" ,
2849 ] ,
2950 optional : true ,
3051 } ,
31- linkedDomains : {
52+ shape : {
3253 propDefinition : [
3354 peerdom ,
34- "linkedDomains" ,
55+ "shape" ,
56+ ] ,
57+ optional : true ,
58+ } ,
59+ customFields : {
60+ propDefinition : [
61+ peerdom ,
62+ "customFields" ,
63+ ] ,
64+ optional : true ,
65+ } ,
66+ groupEmail : {
67+ propDefinition : [
68+ peerdom ,
69+ "groupEmail" ,
3570 ] ,
3671 optional : true ,
3772 } ,
3873 } ,
3974 async run ( { $ } ) {
40- const response = await this . peerdom . createRole ( {
41- circleId : this . circleId ,
42- roleName : this . roleName ,
43- description : this . description ,
44- linkedDomains : this . linkedDomains ,
45- } ) ;
75+ try {
76+ const {
77+ peerdom,
78+ customFields,
79+ ...data
80+ } = this ;
81+
82+ const response = await peerdom . createRole ( {
83+ $,
84+ data : {
85+ ...data ,
86+ customFields : parseObject ( customFields ) ,
87+ } ,
88+ } ) ;
4689
47- $ . export ( "$summary" , `Successfully created role: ${ response . name } ` ) ;
48- return response ;
90+ $ . export ( "$summary" , `Successfully created role: ${ response . name } ` ) ;
91+ return response ;
92+ } catch ( { response } ) {
93+ throw new ConfigurationError ( response . data . message ) ;
94+ }
4995 } ,
5096} ;
Original file line number Diff line number Diff line change 1+ import { ConfigurationError } from "@pipedream/platform" ;
2+ import { parseObject } from "../../common/utils.mjs" ;
13import peerdom from "../../peerdom.app.mjs" ;
2- import { axios } from "@pipedream/platform" ;
34
45export default {
56 key : "peerdom-update-role" ,
@@ -15,51 +16,84 @@ export default {
1516 "roleId" ,
1617 ] ,
1718 } ,
18- roleName : {
19+ name : {
1920 propDefinition : [
2021 peerdom ,
21- "roleName " ,
22+ "name " ,
2223 ] ,
2324 optional : true ,
2425 } ,
25- description : {
26+ parentId : {
2627 propDefinition : [
2728 peerdom ,
28- "description" ,
29+ "groupId" ,
30+ ] ,
31+ } ,
32+ electable : {
33+ propDefinition : [
34+ peerdom ,
35+ "electable" ,
36+ ] ,
37+ optional : true ,
38+ } ,
39+ external : {
40+ propDefinition : [
41+ peerdom ,
42+ "external" ,
43+ ] ,
44+ optional : true ,
45+ } ,
46+ color : {
47+ propDefinition : [
48+ peerdom ,
49+ "color" ,
2950 ] ,
3051 optional : true ,
3152 } ,
32- linkedDomains : {
53+ shape : {
3354 propDefinition : [
3455 peerdom ,
35- "linkedDomains" ,
56+ "shape" ,
57+ ] ,
58+ optional : true ,
59+ } ,
60+ customFields : {
61+ propDefinition : [
62+ peerdom ,
63+ "customFields" ,
64+ ] ,
65+ optional : true ,
66+ } ,
67+ groupEmail : {
68+ propDefinition : [
69+ peerdom ,
70+ "groupEmail" ,
3671 ] ,
3772 optional : true ,
3873 } ,
3974 } ,
4075 async run ( { $ } ) {
41- const data = {
42- ...( this . roleName && {
43- name : this . roleName ,
44- } ) ,
45- ...( this . description && {
46- customFields : {
47- Description : this . description ,
48- } ,
49- } ) ,
50- ...( this . linkedDomains && {
51- customFields : {
52- LinkedDomains : this . linkedDomains ,
53- } ,
54- } ) ,
55- } ;
76+ try {
77+ const {
78+ peerdom,
79+ roleId,
80+ customFields,
81+ ...data
82+ } = this ;
5683
57- const response = await this . peerdom . updateRole ( {
58- roleId : this . roleId ,
59- ...data ,
60- } ) ;
84+ const response = await peerdom . updateRole ( {
85+ $,
86+ roleId,
87+ data : {
88+ ...data ,
89+ customFields : parseObject ( customFields ) ,
90+ } ,
91+ } ) ;
6192
62- $ . export ( "$summary" , `Successfully updated role with ID ${ this . roleId } ` ) ;
63- return response ;
93+ $ . export ( "$summary" , `Successfully updated role with ID ${ this . roleId } ` ) ;
94+ return response ;
95+ } catch ( { response } ) {
96+ throw new ConfigurationError ( response . data . message ) ;
97+ }
6498 } ,
6599} ;
Original file line number Diff line number Diff line change 1+ export const LIMIT = 100 ;
2+
3+ export const SHAPE_OPTIONS = [
4+ "circle" ,
5+ "hexagon" ,
6+ ] ;
Original file line number Diff line number Diff line change 1+ export const parseObject = ( obj ) => {
2+ if ( ! obj ) return undefined ;
3+
4+ if ( Array . isArray ( obj ) ) {
5+ return obj . map ( ( item ) => {
6+ if ( typeof item === "string" ) {
7+ try {
8+ return JSON . parse ( item ) ;
9+ } catch ( e ) {
10+ return item ;
11+ }
12+ }
13+ return item ;
14+ } ) ;
15+ }
16+ if ( typeof obj === "string" ) {
17+ try {
18+ return JSON . parse ( obj ) ;
19+ } catch ( e ) {
20+ return obj ;
21+ }
22+ }
23+ return obj ;
24+ } ;
Original file line number Diff line number Diff line change 11{
22 "name" : " @pipedream/peerdom" ,
3- "version" : " 0.0.1 " ,
3+ "version" : " 0.1.0 " ,
44 "description" : " Pipedream Peerdom Components" ,
55 "main" : " peerdom.app.mjs" ,
66 "keywords" : [
1111 "author" :
" Pipedream <[email protected] > (https://pipedream.com/)" ,
1212 "publishConfig" : {
1313 "access" : " public"
14+ },
15+ "dependencies" : {
16+ "@pipedream/platform" : " ^3.0.3"
1417 }
1518}
You can’t perform that action at this time.
0 commit comments