File tree 12 files changed +502
-239
lines changed
12 files changed +502
-239
lines changed Original file line number Diff line number Diff line change 1
1
import peerdom from "../../peerdom.app.mjs" ;
2
- import { axios } from "@pipedream/platform" ;
3
2
4
3
export default {
5
4
key : "peerdom-assign-member-to-role" ,
@@ -21,11 +20,37 @@ export default {
21
20
"memberId" ,
22
21
] ,
23
22
} ,
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
+ } ,
24
43
} ,
25
44
async run ( { $ } ) {
26
45
const response = await this . peerdom . assignMemberToRole ( {
46
+ $,
27
47
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
+ } ,
29
54
} ) ;
30
55
31
56
$ . 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" ;
1
3
import peerdom from "../../peerdom.app.mjs" ;
2
- import { axios } from "@pipedream/platform" ;
3
4
4
5
export default {
5
6
key : "peerdom-create-role" ,
6
7
name : "Create Role" ,
7
8
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 " ,
9
10
type : "action" ,
10
11
props : {
11
12
peerdom,
12
- circleId : {
13
+ name : {
13
14
propDefinition : [
14
15
peerdom ,
15
- "circleId " ,
16
+ "name " ,
16
17
] ,
17
18
} ,
18
- roleName : {
19
+ mapId : {
19
20
propDefinition : [
20
21
peerdom ,
21
- "roleName " ,
22
+ "mapId " ,
22
23
] ,
23
24
} ,
24
- description : {
25
+ parentId : {
25
26
propDefinition : [
26
27
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" ,
28
49
] ,
29
50
optional : true ,
30
51
} ,
31
- linkedDomains : {
52
+ shape : {
32
53
propDefinition : [
33
54
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" ,
35
70
] ,
36
71
optional : true ,
37
72
} ,
38
73
} ,
39
74
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
+ } ) ;
46
89
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
+ }
49
95
} ,
50
96
} ;
Original file line number Diff line number Diff line change
1
+ import { ConfigurationError } from "@pipedream/platform" ;
2
+ import { parseObject } from "../../common/utils.mjs" ;
1
3
import peerdom from "../../peerdom.app.mjs" ;
2
- import { axios } from "@pipedream/platform" ;
3
4
4
5
export default {
5
6
key : "peerdom-update-role" ,
@@ -15,51 +16,84 @@ export default {
15
16
"roleId" ,
16
17
] ,
17
18
} ,
18
- roleName : {
19
+ name : {
19
20
propDefinition : [
20
21
peerdom ,
21
- "roleName " ,
22
+ "name " ,
22
23
] ,
23
24
optional : true ,
24
25
} ,
25
- description : {
26
+ parentId : {
26
27
propDefinition : [
27
28
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" ,
29
50
] ,
30
51
optional : true ,
31
52
} ,
32
- linkedDomains : {
53
+ shape : {
33
54
propDefinition : [
34
55
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" ,
36
71
] ,
37
72
optional : true ,
38
73
} ,
39
74
} ,
40
75
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 ;
56
83
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
+ } ) ;
61
92
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
+ }
64
98
} ,
65
99
} ;
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 1
1
{
2
2
"name" : " @pipedream/peerdom" ,
3
- "version" : " 0.0.1 " ,
3
+ "version" : " 0.1.0 " ,
4
4
"description" : " Pipedream Peerdom Components" ,
5
5
"main" : " peerdom.app.mjs" ,
6
6
"keywords" : [
11
11
"author" :
" Pipedream <[email protected] > (https://pipedream.com/)" ,
12
12
"publishConfig" : {
13
13
"access" : " public"
14
+ },
15
+ "dependencies" : {
16
+ "@pipedream/platform" : " ^3.0.3"
14
17
}
15
18
}
You can’t perform that action at this time.
0 commit comments