-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[Components] workflow_max #14568 #17450
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,55 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import app from "../../workflow_max.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
key: "workflow_max-create-client-group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: "Create Client Group", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
description: "Creates a new Client Group in Workflow Max. [See the documentation](https://app.swaggerhub.com/apis-docs/WorkflowMax-BlueRock/WorkflowMax-BlueRock-OpenAPI3/0.1#/Client/createClient)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
clientUuid: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"clientUuid", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
name: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"name", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
taxable: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"taxable", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const xmlBody = ` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Group> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<ClientUUID>${this.clientUuid}</ClientUUID> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Name>${this.name}</Name> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<Taxable>${this.taxable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
? "Yes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
: "No"}</Taxable> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
</Group> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
`.trim(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+32
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add XML escaping for user input. The name field could contain special XML characters that would break the XML structure. Consider escaping the input to prevent XML injection or parsing errors. Add an XML escape function: + function escapeXml(unsafe) {
+ return unsafe.replace(/[<>&'"]/g, (c) => {
+ switch (c) {
+ case '<': return '<';
+ case '>': return '>';
+ case '&': return '&';
+ case '\'': return ''';
+ case '"': return '"';
+ }
+ });
+ }
+
async run({ $ }) {
const xmlBody = `
<Group>
<ClientUUID>${this.clientUuid}</ClientUUID>
- <Name>${this.name}</Name>
+ <Name>${escapeXml(this.name)}</Name>
<Taxable>${this.taxable
? "Yes"
: "No"}</Taxable>
</Group>
`.trim(); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const response = await this.app.createClientGroup({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
data: xmlBody, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const status = response.match(/<Status>(.*?)<\/Status>/)?.[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const error = response.match(/<Error>(.*?)<\/Error>/)?.[1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (status !== "OK") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
throw new Error(`Workflow Max couldn't create the client group: ${error}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$.export("$summary", "Successfully created the client group: " + this.name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||
import app from "../../workflow_max.app.mjs"; | ||||||
|
||||||
export default { | ||||||
key: "workflow_max-delete-client-group", | ||||||
name: "Delete Client Group", | ||||||
description: "Deletes the specified client group. [See the documentation](https://app.swaggerhub.com/apis-docs/WorkflowMax-BlueRock/WorkflowMax-BlueRock-OpenAPI3/0.1#/Client%20Group/deleteClientGroup)", | ||||||
version: "0.0.1", | ||||||
type: "action", | ||||||
props: { | ||||||
app, | ||||||
clientGroupUuid: { | ||||||
propDefinition: [ | ||||||
app, | ||||||
"clientGroupUuid", | ||||||
], | ||||||
}, | ||||||
}, | ||||||
async run({ $ }) { | ||||||
const xmlBody = ` | ||||||
<Group> | ||||||
<UUID>${this.clientGroupUuid}</UUID> | ||||||
</Group> | ||||||
`.trim(); | ||||||
const response = await this.app.deleteClientGroup({ | ||||||
$, | ||||||
data: xmlBody, | ||||||
}); | ||||||
|
||||||
const status = response.match(/<Status>(.*?)<\/Status>/)?.[1]; | ||||||
const error = response.match(/<Error>(.*?)<\/Error>/)?.[1]; | ||||||
|
||||||
if (status !== "OK") { | ||||||
throw new Error(`Workflow Max couldn't delete the client group: ${error}`); | ||||||
} | ||||||
|
||||||
$.export("$summary", "Successfully deleted the client group: " + this.name); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix undefined reference in summary message. The export summary references Apply this diff to fix the issue: - $.export("$summary", "Successfully deleted the client group: " + this.name);
+ $.export("$summary", `Successfully deleted the client group with UUID: ${this.clientGroupUuid}`); 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||
return response; | ||||||
}, | ||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/workflow_max", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Workflow Max Components", | ||
"main": "workflow_max.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.1.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,11 +1,112 @@ | ||||||
import { axios } from "@pipedream/platform"; | ||||||
import { parseStringPromise } from "xml2js"; | ||||||
|
||||||
export default { | ||||||
type: "app", | ||||||
app: "workflow_max", | ||||||
propDefinitions: {}, | ||||||
propDefinitions: { | ||||||
clientUuid: { | ||||||
type: "string", | ||||||
label: "Client UUID", | ||||||
description: "UUID of the client", | ||||||
async options() { | ||||||
const responseXml = await this.getClients(); | ||||||
const result = await parseStringPromise(responseXml, { | ||||||
explicitArray: false, | ||||||
}); | ||||||
const clients = result.Response.Clients.Client; | ||||||
const clientsArray = Array.isArray(clients) | ||||||
? clients | ||||||
: [ | ||||||
clients, | ||||||
]; | ||||||
return clientsArray | ||||||
.filter((client) => client && client.Name && client.UUID) | ||||||
.map((client) => ({ | ||||||
label: client.Name, | ||||||
value: client.UUID, | ||||||
})); | ||||||
}, | ||||||
}, | ||||||
name: { | ||||||
type: "string", | ||||||
label: "Name", | ||||||
description: "Name of the client group", | ||||||
}, | ||||||
taxable: { | ||||||
type: "boolean", | ||||||
label: "Taxable", | ||||||
description: "Wheter the client group is taxable", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in description. - description: "Wheter the client group is taxable",
+ description: "Whether the client group is taxable", 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||
}, | ||||||
clientGroupUuid: { | ||||||
type: "string", | ||||||
label: "Client Group", | ||||||
description: "UUID of the client group", | ||||||
async options() { | ||||||
const responseXml = await this.getClientGroups(); | ||||||
const result = await parseStringPromise(responseXml, { | ||||||
explicitArray: false, | ||||||
}); | ||||||
const groups = result.Response.Groups.Group; | ||||||
const groupsArray = Array.isArray(groups) | ||||||
? groups | ||||||
: [ | ||||||
groups, | ||||||
]; | ||||||
return groupsArray.filter((group) => group && group.Name && group.UUID).map((group) => ({ | ||||||
label: group.Name, | ||||||
value: group.UUID, | ||||||
})); | ||||||
}, | ||||||
}, | ||||||
}, | ||||||
methods: { | ||||||
// this.$auth contains connected account data | ||||||
authKeys() { | ||||||
console.log(Object.keys(this.$auth)); | ||||||
_baseUrl() { | ||||||
return "https://api.workflowmax2.com"; | ||||||
}, | ||||||
async _makeRequest(opts = {}) { | ||||||
const { | ||||||
$ = this, | ||||||
path, | ||||||
headers, | ||||||
...otherOpts | ||||||
} = opts; | ||||||
return axios($, { | ||||||
...otherOpts, | ||||||
url: this._baseUrl() + path, | ||||||
headers: { | ||||||
"Authorization": `Bearer ${this.$auth.oauth_access_token}`, | ||||||
"Content-Type": "application/xml", | ||||||
"account_id": `${this.$auth.account_id}`, | ||||||
...headers, | ||||||
}, | ||||||
}); | ||||||
}, | ||||||
async createClientGroup(args = {}) { | ||||||
return this._makeRequest({ | ||||||
path: "/clientgroup.api/add", | ||||||
method: "post", | ||||||
...args, | ||||||
}); | ||||||
}, | ||||||
async getClients(args = {}) { | ||||||
return this._makeRequest({ | ||||||
path: "/client.api/list", | ||||||
...args, | ||||||
}); | ||||||
}, | ||||||
async getClientGroups(args = {}) { | ||||||
return this._makeRequest({ | ||||||
path: "/clientgroup.api/list", | ||||||
...args, | ||||||
}); | ||||||
}, | ||||||
async deleteClientGroup(args = {}) { | ||||||
return this._makeRequest({ | ||||||
path: "/clientgroup.api/delete", | ||||||
method: "post", | ||||||
...args, | ||||||
}); | ||||||
}, | ||||||
}, | ||||||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix incorrect documentation link.
The documentation link points to
/Client/createClient
but this action creates a client group, not a client. Update to the correct endpoint documentation.🤖 Prompt for AI Agents