1+ import { axios } from "@pipedream/platform" ;
2+
13export 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+ } ;
0 commit comments