Skip to content

Commit 2cd9e3e

Browse files
committed
new components
1 parent 23ba51a commit 2cd9e3e

File tree

12 files changed

+382
-478
lines changed

12 files changed

+382
-478
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "ironclad-create-record",
55
name: "Create Record",
66
description: "Creates a new record in Ironclad. [See the documentation](https://developer.ironcladapp.com/reference/create-a-record)",
7-
version: "0.0.{{ts}}",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
ironclad,
@@ -58,17 +58,19 @@ export default {
5858
if (!this.properties?.length) {
5959
return props;
6060
}
61-
const { properties } = await this.ironclad.getRecordSchema();
61+
const { properties } = await this.ironclad.getRecordsSchema();
6262
for (const property of this.properties) {
6363
props[property] = {
64-
type: "string",
64+
type: properties[property].type === "boolean"
65+
? "boolean"
66+
: "string",
6567
label: properties[property].displayName,
6668
};
6769
}
6870
return props;
6971
},
7072
async run({ $ }) {
71-
const { properties } = await this.ironclad.getRecordSchema();
73+
const { properties } = await this.ironclad.getRecordsSchema();
7274
const propertiesData = {};
7375
for (const property of this.properties) {
7476
propertiesData[property] = {

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

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,68 @@ import ironclad from "../../ironclad.app.mjs";
33
export default {
44
key: "ironclad-launch-workflow",
55
name: "Launch Workflow",
6-
description: "Launches a new workflow in Ironclad. [See the documentation]()",
7-
version: "0.0.{{ts}}",
6+
description: "Launches a new workflow in Ironclad. [See the documentation](https://developer.ironcladapp.com/reference/launch-a-new-workflow)",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
ironclad,
11-
workflowDetails: {
11+
templateId: {
1212
propDefinition: [
1313
ironclad,
14-
"workflowDetails",
14+
"templateId",
1515
],
16-
},
17-
attachments: {
18-
propDefinition: [
19-
ironclad,
20-
"attachments",
21-
],
22-
optional: true,
23-
},
24-
user: {
25-
propDefinition: [
26-
ironclad,
27-
"user",
28-
],
29-
optional: true,
16+
reloadProps: true,
3017
},
3118
},
19+
async additionalProps() {
20+
const props = {};
21+
if (!this.templateId) {
22+
return props;
23+
}
24+
const { schema } = await this.ironclad.getWorkflowSchema({
25+
templateId: this.templateId,
26+
});
27+
for (const [
28+
key,
29+
value,
30+
] of Object.entries(schema)) {
31+
if (!value.readOnly && value?.type !== "document" && value?.elementType?.type !== "document") {
32+
props[key] = {
33+
type: value.type === "boolean"
34+
? "boolean"
35+
: value.type === "array"
36+
? "string[]"
37+
: "string",
38+
label: value.displayName,
39+
optional: !(key === "counterpartyName"),
40+
};
41+
if (key === "paperSource") {
42+
props[key].options = [
43+
"Counterparty paper",
44+
"Our paper",
45+
];
46+
}
47+
}
48+
}
49+
return props;
50+
},
3251
async run({ $ }) {
33-
const response = await this.ironclad.launchWorkflow(
34-
this.workflowDetails,
35-
this.attachments,
36-
this.user,
37-
);
38-
const workflowId = response.id || response.workflowId || "unknown";
39-
$.export("$summary", `Workflow launched successfully with ID ${workflowId}`);
52+
const {
53+
ironclad,
54+
templateId,
55+
...attributes
56+
} = this;
57+
58+
const response = await ironclad.launchWorkflow({
59+
$,
60+
data: {
61+
template: templateId,
62+
attributes: {
63+
...attributes,
64+
},
65+
},
66+
});
67+
$.export("$summary", `Workflow launched successfully with ID ${response.id}`);
4068
return response;
4169
},
4270
};

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

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,74 @@ import ironclad from "../../ironclad.app.mjs";
33
export default {
44
key: "ironclad-update-workflow",
55
name: "Update Workflow Metadata",
6-
description: "Updates the metadata of an existing workflow. [See the documentation]()/",
7-
version: "0.0.{{ts}}",
6+
description: "Updates the metadata of an existing workflow. [See the documentation]()",
7+
version: "0.0.1",
88
type: "action",
99
props: {
1010
ironclad,
1111
workflowId: {
1212
propDefinition: [
13-
"ironclad",
13+
ironclad,
1414
"workflowId",
1515
],
16+
reloadProps: true,
1617
},
17-
updatedMetadata: {
18-
propDefinition: [
19-
"ironclad",
20-
"updatedMetadata",
21-
],
18+
comment: {
19+
type: "string",
20+
label: "Comment",
21+
description: "A comment that explains the updates you are making to the workflow",
22+
optional: true,
2223
},
2324
},
25+
async additionalProps() {
26+
const props = {};
27+
if (!this.workflowId) {
28+
return props;
29+
}
30+
const { schema } = await this.ironclad.getWorkflow({
31+
workflowId: this.workflowId,
32+
});
33+
for (const [
34+
key,
35+
value,
36+
] of Object.entries(schema)) {
37+
if (!value?.readOnly && value?.type !== "document" && value?.elementType?.type !== "document") {
38+
props[key] = {
39+
type: value.type === "boolean"
40+
? "boolean"
41+
: value.type === "array"
42+
? "string[]"
43+
: "string",
44+
label: value.displayName,
45+
optional: true,
46+
};
47+
}
48+
}
49+
return props;
50+
},
2451
async run({ $ }) {
25-
const response = await this.ironclad.updateWorkflowMetadata(
26-
this.workflowId,
27-
this.updatedMetadata,
28-
);
29-
$.export("$summary", `Workflow ${this.workflowId} updated successfully`);
52+
const {
53+
ironclad,
54+
workflowId,
55+
comment,
56+
...attributes
57+
} = this;
58+
const response = await ironclad.updateWorkflowMetadata({
59+
$,
60+
workflowId: workflowId,
61+
data: {
62+
updates: attributes && Object.entries(attributes).map(([
63+
key,
64+
value,
65+
]) => ({
66+
action: "set",
67+
path: key,
68+
value,
69+
})),
70+
comment: comment,
71+
},
72+
});
73+
$.export("$summary", `Workflow ${workflowId} updated successfully`);
3074
return response;
3175
},
3276
};

0 commit comments

Comments
 (0)