Skip to content

Commit 3a89f05

Browse files
committed
wip
1 parent a45459d commit 3a89f05

File tree

8 files changed

+141
-108
lines changed

8 files changed

+141
-108
lines changed

components/ironclad/actions/create-record/create-record.mjs

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,99 @@
11
import ironclad from "../../ironclad.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "ironclad-create-record",
65
name: "Create Record",
7-
description: "Creates a new record in Ironclad. [See the documentation](/reference/create-a-record)",
6+
description: "Creates a new record in Ironclad. [See the documentation](https://developer.ironcladapp.com/reference/create-a-record)",
87
version: "0.0.{{ts}}",
98
type: "action",
109
props: {
1110
ironclad,
12-
recordData: {
11+
name: {
12+
type: "string",
13+
label: "Name",
14+
description: "Name of the record",
15+
},
16+
type: {
17+
propDefinition: [
18+
ironclad,
19+
"recordType",
20+
],
21+
},
22+
links: {
1323
propDefinition: [
1424
ironclad,
15-
"recordData",
25+
"recordId",
1626
],
27+
type: "string[]",
28+
label: "Links",
29+
description: "Record ID's to link to the new record",
1730
},
18-
user: {
31+
parent: {
1932
propDefinition: [
2033
ironclad,
21-
"user",
34+
"recordId",
2235
],
23-
optional: true,
36+
label: "Parent",
37+
description: "Record ID to be set as the parent of the current record",
2438
},
25-
tags: {
39+
children: {
2640
propDefinition: [
2741
ironclad,
28-
"tags",
42+
"recordId",
2943
],
30-
optional: true,
44+
type: "string[]",
45+
label: "Children",
46+
description: "Record ID's to be set as child records of the current record",
47+
},
48+
properties: {
49+
propDefinition: [
50+
ironclad,
51+
"properties",
52+
],
53+
reloadProps: true,
3154
},
3255
},
56+
async additionalProps() {
57+
const props = {};
58+
if (!this.properties?.length) {
59+
return props;
60+
}
61+
const { properties } = await this.ironclad.getRecordSchema();
62+
for (const property of this.properties) {
63+
props[property] = {
64+
type: "string",
65+
label: properties[property].displayName,
66+
};
67+
}
68+
return props;
69+
},
3370
async run({ $ }) {
34-
const response = await this.ironclad.createRecord(this.recordData, this.user, this.tags);
71+
const { properties } = await this.ironclad.getRecordSchema();
72+
const propertiesData = {};
73+
for (const property of this.properties) {
74+
propertiesData[property] = {
75+
type: properties[property].type,
76+
value: this[property],
77+
};
78+
}
79+
80+
const response = await this.ironclad.createRecord({
81+
$,
82+
data: {
83+
name: this.name,
84+
type: this.type,
85+
links: this.links?.length && this.links.map((link) => ({
86+
recordId: link,
87+
})),
88+
parent: this.parent && {
89+
recordId: this.parent,
90+
},
91+
children: this.children?.length && this.children.map((child) => ({
92+
recordId: child,
93+
})),
94+
properties: propertiesData,
95+
},
96+
});
3597
$.export("$summary", `Created record with ID: ${response.id}`);
3698
return response;
3799
},

components/ironclad/actions/launch-workflow/launch-workflow.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ironclad from "../../ironclad.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "ironclad-launch-workflow",

components/ironclad/actions/update-workflow/update-workflow.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ironclad from "../../ironclad.app.mjs";
2-
import { axios } from "@pipedream/platform";
32

43
export default {
54
key: "ironclad-update-workflow",

components/ironclad/ironclad.app.mjs

Lines changed: 62 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,43 @@ export default {
55
app: "ironclad",
66
version: "0.0.{{ts}}",
77
propDefinitions: {
8+
recordType: {
9+
type: "string",
10+
label: "Type",
11+
description: "The type of the record",
12+
async options() {
13+
const { recordTypes } = await this.getRecordsSchema();
14+
return (Object.keys(recordTypes)).map((type) => type);
15+
},
16+
},
17+
recordId: {
18+
type: "string",
19+
label: "Record ID",
20+
description: "The identifier of a record",
21+
optional: true,
22+
async options({ page }) {
23+
const { list } = await this.listRecords({
24+
params: {
25+
page,
26+
},
27+
});
28+
return list?.map(({
29+
id: value, name: label,
30+
}) => ({
31+
value,
32+
label,
33+
})) || [];
34+
},
35+
},
36+
properties: {
37+
type: "string[]",
38+
label: "Properties",
39+
description: "Properties to add to the record",
40+
async options() {
41+
const { properties } = await this.getRecordSchema();
42+
return (Object.keys(properties)).map((property) => property);
43+
},
44+
},
845
selectedEvent: {
946
type: "string[]",
1047
label: "Selected Events",
@@ -75,91 +112,40 @@ export default {
75112
description: "Optional attachments to include when launching workflow",
76113
optional: true,
77114
},
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-
},
119115
workflowId: {
120116
type: "string",
121117
label: "Workflow ID",
122118
description: "ID of the workflow to update",
123119
},
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-
},
141120
},
142121
methods: {
143-
authKeys() {
144-
console.log(Object.keys(this.$auth));
145-
},
146122
_baseUrl() {
147-
return "https://api.ironcladapp.com";
123+
return "https://ironcladapp.com/public/api/v1";
148124
},
149-
async _makeRequest(opts = {}) {
125+
_makeRequest(opts = {}) {
150126
const {
151-
$, method = "GET", path = "/", headers, ...otherOpts
127+
$, path, ...otherOpts
152128
} = opts;
153129
return axios($, {
154-
method,
155130
url: `${this._baseUrl()}${path}`,
156131
headers: {
157-
...headers,
158-
Authorization: `Bearer ${this.$auth.api_token}`,
132+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
159133
},
160134
...otherOpts,
161135
});
162136
},
137+
getRecordsSchema(opts = {}) {
138+
return this._makeRequest({
139+
path: "/records/metadata",
140+
...opts,
141+
});
142+
},
143+
listRecords(opts = {}) {
144+
return this._makeRequest({
145+
path: "/records",
146+
...opts,
147+
});
148+
},
163149
async launchWorkflow(workflowDetails, attachments, user) {
164150
const data = {
165151
...workflowDetails,
@@ -176,27 +162,20 @@ export default {
176162
data,
177163
});
178164
},
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({
165+
createRecord(opts = {}) {
166+
return this._makeRequest({
190167
method: "POST",
191168
path: "/records",
192-
data,
169+
...opts,
193170
});
194171
},
195-
async updateWorkflowMetadata(workflowId, updatedMetadata) {
196-
return await this._makeRequest({
172+
updateWorkflowMetadata({
173+
workflowId, ...opts
174+
}) {
175+
return this._makeRequest({
197176
method: "PATCH",
198-
path: `/workflows/${workflowId}`,
199-
data: updatedMetadata,
177+
path: `workflows/${workflowId}/attributes`,
178+
...opts,
200179
});
201180
},
202181
},

components/ironclad/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/ironclad",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Ironclad Components",
55
"main": "ironclad.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
1518
}

components/ironclad/sources/new-approval-event-instant/new-approval-event-instant.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import ironclad from "../../ironclad.app.mjs";
2-
import { axios } from "@pipedream/platform";
32
import crypto from "crypto";
43

54
export default {
@@ -10,10 +9,7 @@ export default {
109
type: "source",
1110
dedupe: "unique",
1211
props: {
13-
ironclad: {
14-
type: "app",
15-
app: "ironclad",
16-
},
12+
ironclad,
1713
selectedEvent: {
1814
propDefinition: [
1915
ironclad,

components/ironclad/sources/new-workflow-document-event-instant/new-workflow-document-event-instant.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import ironclad from "../../ironclad.app.mjs";
22
import crypto from "crypto";
3-
import { axios } from "@pipedream/platform";
43

54
export default {
65
key: "ironclad-new-workflow-document-event-instant",
@@ -10,10 +9,7 @@ export default {
109
type: "source",
1110
dedupe: "unique",
1211
props: {
13-
ironclad: {
14-
type: "app",
15-
app: "ironclad",
16-
},
12+
ironclad,
1713
selectedEvent: {
1814
propDefinition: [
1915
"ironclad",

components/ironclad/sources/new-workflow-event-instant/new-workflow-event-instant.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { axios } from "@pipedream/platform";
21
import ironclad from "../../ironclad.app.mjs";
32
import crypto from "crypto";
43

0 commit comments

Comments
 (0)