Skip to content

Commit a45459d

Browse files
committed
ironclad init
1 parent d110209 commit a45459d

File tree

8 files changed

+706
-4
lines changed

8 files changed

+706
-4
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import ironclad from "../../ironclad.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "ironclad-create-record",
6+
name: "Create Record",
7+
description: "Creates a new record in Ironclad. [See the documentation](/reference/create-a-record)",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
ironclad,
12+
recordData: {
13+
propDefinition: [
14+
ironclad,
15+
"recordData",
16+
],
17+
},
18+
user: {
19+
propDefinition: [
20+
ironclad,
21+
"user",
22+
],
23+
optional: true,
24+
},
25+
tags: {
26+
propDefinition: [
27+
ironclad,
28+
"tags",
29+
],
30+
optional: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
const response = await this.ironclad.createRecord(this.recordData, this.user, this.tags);
35+
$.export("$summary", `Created record with ID: ${response.id}`);
36+
return response;
37+
},
38+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import ironclad from "../../ironclad.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "ironclad-launch-workflow",
6+
name: "Launch Workflow",
7+
description: "Launches a new workflow in Ironclad. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
ironclad,
12+
workflowDetails: {
13+
propDefinition: [
14+
ironclad,
15+
"workflowDetails",
16+
],
17+
},
18+
attachments: {
19+
propDefinition: [
20+
ironclad,
21+
"attachments",
22+
],
23+
optional: true,
24+
},
25+
user: {
26+
propDefinition: [
27+
ironclad,
28+
"user",
29+
],
30+
optional: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
const response = await this.ironclad.launchWorkflow(
35+
this.workflowDetails,
36+
this.attachments,
37+
this.user,
38+
);
39+
const workflowId = response.id || response.workflowId || "unknown";
40+
$.export("$summary", `Workflow launched successfully with ID ${workflowId}`);
41+
return response;
42+
},
43+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import ironclad from "../../ironclad.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "ironclad-update-workflow",
6+
name: "Update Workflow Metadata",
7+
description: "Updates the metadata of an existing workflow. [See the documentation]()/",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
ironclad,
12+
workflowId: {
13+
propDefinition: [
14+
"ironclad",
15+
"workflowId",
16+
],
17+
},
18+
updatedMetadata: {
19+
propDefinition: [
20+
"ironclad",
21+
"updatedMetadata",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.ironclad.updateWorkflowMetadata(
27+
this.workflowId,
28+
this.updatedMetadata,
29+
);
30+
$.export("$summary", `Workflow ${this.workflowId} updated successfully`);
31+
return response;
32+
},
33+
};
Lines changed: 195 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,203 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "ironclad",
4-
propDefinitions: {},
6+
version: "0.0.{{ts}}",
7+
propDefinitions: {
8+
selectedEvent: {
9+
type: "string[]",
10+
label: "Selected Events",
11+
description: "Select the Ironclad events to emit",
12+
async options() {
13+
const events = [
14+
"workflow_launched",
15+
"workflow_updated",
16+
"workflow_completed",
17+
"workflow_cancelled",
18+
"workflow_approval_status_changed",
19+
"workflow_attribute_updated",
20+
"workflow_comment_added",
21+
"workflow_comment_removed",
22+
"workflow_comment_updated",
23+
"workflow_comment_reaction_added",
24+
"workflow_comment_reaction_removed",
25+
"workflow_counterparty_invite_sent",
26+
"workflow_counterparty_invite_revoked",
27+
"workflow_documents_added",
28+
"workflow_documents_removed",
29+
"workflow_documents_updated",
30+
"workflow_documents_renamed",
31+
"workflow_document_edited",
32+
"workflow_changed_turn",
33+
"workflow_paused",
34+
"workflow_resumed",
35+
"workflow_roles_assigned",
36+
"workflow_signature_packet_sent",
37+
"workflow_signature_packet_signer_first_viewed",
38+
"workflow_signature_packet_signer_viewed",
39+
"workflow_signature_packet_uploaded",
40+
"workflow_signature_packet_signatures_collected",
41+
"workflow_signature_packet_fully_signed",
42+
"workflow_signature_packet_cancelled",
43+
"workflow_signer_added",
44+
"workflow_signer_removed",
45+
"workflow_signer_reassigned",
46+
"workflow_step_updated",
47+
"*",
48+
];
49+
return events.map((event) => ({
50+
label: event.replace(/_/g, " ").toUpperCase(),
51+
value: event,
52+
}));
53+
},
54+
},
55+
workflowDetails: {
56+
type: "object",
57+
label: "Workflow Details",
58+
description: "Details required to launch a new workflow",
59+
properties: {
60+
templateId: {
61+
type: "string",
62+
label: "Template ID",
63+
description: "ID of the workflow template to use",
64+
},
65+
attributes: {
66+
type: "object",
67+
label: "Attributes",
68+
description: "Workflow attributes as key-value pairs",
69+
},
70+
},
71+
},
72+
attachments: {
73+
type: "string[]",
74+
label: "Attachments",
75+
description: "Optional attachments to include when launching workflow",
76+
optional: true,
77+
},
78+
user: {
79+
type: "object",
80+
label: "User",
81+
description: "Optional user information for actions that support it",
82+
optional: true,
83+
properties: {
84+
userId: {
85+
type: "string",
86+
label: "User ID",
87+
description: "ID of the user performing the action",
88+
},
89+
},
90+
},
91+
recordData: {
92+
type: "object",
93+
label: "Record Data",
94+
description: "Data required to create a new record in Ironclad",
95+
properties: {
96+
type: {
97+
type: "string",
98+
label: "Record Type",
99+
description: "Type/category of the record",
100+
},
101+
name: {
102+
type: "string",
103+
label: "Name",
104+
description: "Name/title of the record",
105+
},
106+
properties: {
107+
type: "object",
108+
label: "Properties",
109+
description: "Metadata properties of the record",
110+
},
111+
},
112+
},
113+
tags: {
114+
type: "string[]",
115+
label: "Tags",
116+
description: "Optional tags for the record",
117+
optional: true,
118+
},
119+
workflowId: {
120+
type: "string",
121+
label: "Workflow ID",
122+
description: "ID of the workflow to update",
123+
},
124+
updatedMetadata: {
125+
type: "object",
126+
label: "Updated Metadata",
127+
description: "New metadata to update the workflow",
128+
properties: {
129+
status: {
130+
type: "string",
131+
label: "Status",
132+
description: "New status for the workflow",
133+
},
134+
comments: {
135+
type: "string",
136+
label: "Comments",
137+
description: "Additional comments for the workflow",
138+
},
139+
},
140+
},
141+
},
5142
methods: {
6-
// this.$auth contains connected account data
7143
authKeys() {
8144
console.log(Object.keys(this.$auth));
9145
},
146+
_baseUrl() {
147+
return "https://api.ironcladapp.com";
148+
},
149+
async _makeRequest(opts = {}) {
150+
const {
151+
$, method = "GET", path = "/", headers, ...otherOpts
152+
} = opts;
153+
return axios($, {
154+
method,
155+
url: `${this._baseUrl()}${path}`,
156+
headers: {
157+
...headers,
158+
Authorization: `Bearer ${this.$auth.api_token}`,
159+
},
160+
...otherOpts,
161+
});
162+
},
163+
async launchWorkflow(workflowDetails, attachments, user) {
164+
const data = {
165+
...workflowDetails,
166+
};
167+
if (attachments && attachments.length > 0) {
168+
data.attachments = attachments;
169+
}
170+
if (user) {
171+
data.user = user;
172+
}
173+
return await this._makeRequest({
174+
method: "POST",
175+
path: "/workflows",
176+
data,
177+
});
178+
},
179+
async createRecord(recordData, user, tags) {
180+
const data = {
181+
...recordData,
182+
};
183+
if (user) {
184+
data.user = user;
185+
}
186+
if (tags && tags.length > 0) {
187+
data.tags = tags;
188+
}
189+
return await this._makeRequest({
190+
method: "POST",
191+
path: "/records",
192+
data,
193+
});
194+
},
195+
async updateWorkflowMetadata(workflowId, updatedMetadata) {
196+
return await this._makeRequest({
197+
method: "PATCH",
198+
path: `/workflows/${workflowId}`,
199+
data: updatedMetadata,
200+
});
201+
},
10202
},
11-
};
203+
};

components/ironclad/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)