-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New Components - peerdom #16405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - peerdom #16405
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d47284
peerdom init
luancazarine 7aa5e10
[Components] peerdom #16400
luancazarine 0f6bcc7
pnpm update
luancazarine dd5d498
pnpm update
luancazarine be483b3
Update components/peerdom/peerdom.app.mjs
luancazarine d2ec3eb
Update components/peerdom/peerdom.app.mjs
luancazarine 1b49aed
Update components/peerdom/peerdom.app.mjs
luancazarine 43e4295
Update components/peerdom/peerdom.app.mjs
luancazarine 9021d2b
some adjusts
luancazarine d9a7619
Merge branch 'master' into issue-16400
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
components/peerdom/actions/assign-member-to-role/assign-member-to-role.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import peerdom from "../../peerdom.app.mjs"; | ||
|
||
export default { | ||
key: "peerdom-assign-member-to-role", | ||
name: "Assign Member to Role", | ||
description: "Assigns a member to a role within a circle using the Peerdom API. [See the documentation](https://api.peerdom.org/v1/docs)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
peerdom, | ||
roleId: { | ||
propDefinition: [ | ||
peerdom, | ||
"roleId", | ||
], | ||
}, | ||
memberId: { | ||
propDefinition: [ | ||
peerdom, | ||
"memberId", | ||
], | ||
}, | ||
percentage: { | ||
type: "integer", | ||
label: "Percentage", | ||
description: "The percentage of the role assigned to the member", | ||
optional: true, | ||
min: 0, | ||
max: 100, | ||
}, | ||
focus: { | ||
type: "string", | ||
label: "Focus", | ||
description: "The focus of the role assigned to the member", | ||
optional: true, | ||
}, | ||
electedUntil: { | ||
type: "string", | ||
label: "Elected Until", | ||
description: "The date until which the member is elected to the role (YYYY-MM-DD)", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.peerdom.assignMemberToRole({ | ||
$, | ||
roleId: this.roleId, | ||
data: { | ||
peerId: this.memberId, | ||
percentage: this.percentage, | ||
focus: this.focus, | ||
electedUntil: this.electedUntil, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully assigned member with ID ${this.memberId} to role with ID ${this.roleId}`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import peerdom from "../../peerdom.app.mjs"; | ||
|
||
export default { | ||
key: "peerdom-create-role", | ||
name: "Create Role", | ||
description: "Create a new role within a specified circle. [See the documentation](https://api.peerdom.org/v1/docs)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
peerdom, | ||
name: { | ||
propDefinition: [ | ||
peerdom, | ||
"name", | ||
], | ||
}, | ||
mapId: { | ||
propDefinition: [ | ||
peerdom, | ||
"mapId", | ||
], | ||
}, | ||
parentId: { | ||
propDefinition: [ | ||
peerdom, | ||
"groupId", | ||
], | ||
}, | ||
electable: { | ||
propDefinition: [ | ||
peerdom, | ||
"electable", | ||
], | ||
optional: true, | ||
}, | ||
external: { | ||
propDefinition: [ | ||
peerdom, | ||
"external", | ||
], | ||
optional: true, | ||
}, | ||
color: { | ||
propDefinition: [ | ||
peerdom, | ||
"color", | ||
], | ||
optional: true, | ||
}, | ||
shape: { | ||
propDefinition: [ | ||
peerdom, | ||
"shape", | ||
], | ||
optional: true, | ||
}, | ||
customFields: { | ||
propDefinition: [ | ||
peerdom, | ||
"customFields", | ||
], | ||
optional: true, | ||
}, | ||
groupEmail: { | ||
propDefinition: [ | ||
peerdom, | ||
"groupEmail", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const { | ||
peerdom, | ||
customFields, | ||
...data | ||
} = this; | ||
|
||
const response = await peerdom.createRole({ | ||
$, | ||
data: { | ||
...data, | ||
customFields: parseObject(customFields), | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created role: ${response.name}`); | ||
return response; | ||
} catch ({ response }) { | ||
throw new ConfigurationError(response.data.message); | ||
} | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import peerdom from "../../peerdom.app.mjs"; | ||
|
||
export default { | ||
key: "peerdom-update-role", | ||
name: "Update Role", | ||
description: "Update an existing role's attributes such as name, description, or linked domains. [See the documentation](https://api.peerdom.org/v1/docs)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
peerdom, | ||
roleId: { | ||
propDefinition: [ | ||
peerdom, | ||
"roleId", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
peerdom, | ||
"name", | ||
], | ||
optional: true, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
parentId: { | ||
propDefinition: [ | ||
peerdom, | ||
"groupId", | ||
], | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
electable: { | ||
propDefinition: [ | ||
peerdom, | ||
"electable", | ||
], | ||
optional: true, | ||
}, | ||
external: { | ||
propDefinition: [ | ||
peerdom, | ||
"external", | ||
], | ||
optional: true, | ||
}, | ||
color: { | ||
propDefinition: [ | ||
peerdom, | ||
"color", | ||
], | ||
optional: true, | ||
}, | ||
shape: { | ||
propDefinition: [ | ||
peerdom, | ||
"shape", | ||
], | ||
optional: true, | ||
}, | ||
customFields: { | ||
propDefinition: [ | ||
peerdom, | ||
"customFields", | ||
], | ||
optional: true, | ||
}, | ||
groupEmail: { | ||
propDefinition: [ | ||
peerdom, | ||
"groupEmail", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const { | ||
peerdom, | ||
roleId, | ||
customFields, | ||
...data | ||
} = this; | ||
|
||
const response = await peerdom.updateRole({ | ||
$, | ||
roleId, | ||
data: { | ||
...data, | ||
customFields: parseObject(customFields), | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully updated role with ID ${this.roleId}`); | ||
return response; | ||
} catch ({ response }) { | ||
throw new ConfigurationError(response.data.message); | ||
} | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const LIMIT = 100; | ||
|
||
export const SHAPE_OPTIONS = [ | ||
"circle", | ||
"hexagon", | ||
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const parseObject = (obj) => { | ||
if (!obj) return undefined; | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((item) => { | ||
if (typeof item === "string") { | ||
try { | ||
return JSON.parse(item); | ||
} catch (e) { | ||
return item; | ||
} | ||
} | ||
return item; | ||
}); | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
return obj; | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.