Skip to content

[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

Merged
merged 5 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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
In components/workflow_max/actions/create-client-group/create-client-group.mjs
at line 6, the documentation link incorrectly points to the client creation
endpoint instead of the client group creation endpoint. Update the URL in the
description to reference the correct API documentation endpoint for creating a
client group.

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 '&lt;';
+        case '>': return '&gt;';
+        case '&': return '&amp;';
+        case '\'': return '&apos;';
+        case '"': return '&quot;';
+      }
+    });
+  }
+
   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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const xmlBody = `
<Group>
<ClientUUID>${this.clientUuid}</ClientUUID>
<Name>${this.name}</Name>
<Taxable>${this.taxable
? "Yes"
: "No"}</Taxable>
</Group>
`.trim();
// Escape special XML characters to prevent breaking the document or injection
function escapeXml(unsafe) {
return unsafe.replace(/[<>&'"]/g, (c) => {
switch (c) {
case '<': return '&lt;';
case '>': return '&gt;';
case '&': return '&amp;';
case '\'': return '&apos;';
case '"': return '&quot;';
}
});
}
async run({ $ }) {
const xmlBody = `
<Group>
<ClientUUID>${this.clientUuid}</ClientUUID>
<Name>${escapeXml(this.name)}</Name>
<Taxable>${this.taxable
? "Yes"
: "No"}</Taxable>
</Group>
`.trim();
🤖 Prompt for AI Agents
In components/workflow_max/actions/create-client-group/create-client-group.mjs
around lines 31 to 39, the XML body construction directly inserts user input
into the XML without escaping, which can break the XML structure if special
characters are present. Implement an XML escape function to replace characters
like &, <, >, ", and ' with their corresponding XML entities, and apply this
function to the this.name value before embedding it in the XML string.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix undefined reference in summary message.

The export summary references this.name which is not defined in the action's props. This will result in "undefined" in the summary message.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$.export("$summary", "Successfully deleted the client group: " + this.name);
$.export("$summary", `Successfully deleted the client group with UUID: ${this.clientGroupUuid}`);
🤖 Prompt for AI Agents
In components/workflow_max/actions/delete-client-group/delete-client-group.mjs
at line 36, the summary message uses this.name which is undefined in the current
context. Replace this.name with the correct property or variable that holds the
client group name, likely from the action's props or input parameters, to ensure
the summary message displays the actual deleted client group name instead of
"undefined".

return response;
},
};
5 changes: 4 additions & 1 deletion components/workflow_max/package.json
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": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
109 changes: 105 additions & 4 deletions components/workflow_max/workflow_max.app.mjs
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix typo in description.

-      description: "Wheter the client group is taxable",
+      description: "Whether the client group is taxable",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
description: "Wheter the client group is taxable",
description: "Whether the client group is taxable",
🤖 Prompt for AI Agents
In components/workflow_max/workflow_max.app.mjs at line 37, fix the typo in the
description string by changing "Wheter" to "Whether" to correct the spelling.

},
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,
});
},
},
};
6 changes: 5 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading