Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
102 changes: 102 additions & 0 deletions components/ironclad/actions/create-record/create-record.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import ironclad from "../../ironclad.app.mjs";

export default {
key: "ironclad-create-record",
name: "Create Record",
description: "Creates a new record in Ironclad. [See the documentation](https://developer.ironcladapp.com/reference/create-a-record)",
version: "0.0.1",
type: "action",
props: {
ironclad,
name: {
type: "string",
label: "Name",
description: "Name of the record",
},
type: {
propDefinition: [
ironclad,
"recordType",
],
},
links: {
propDefinition: [
ironclad,
"recordId",
],
type: "string[]",
label: "Links",
description: "Record ID's to link to the new record",
},
parent: {
propDefinition: [
ironclad,
"recordId",
],
label: "Parent",
description: "Record ID to be set as the parent of the current record",
},
children: {
propDefinition: [
ironclad,
"recordId",
],
type: "string[]",
label: "Children",
description: "Record ID's to be set as child records of the current record",
},
properties: {
propDefinition: [
ironclad,
"properties",
],
reloadProps: true,
},
},
async additionalProps() {
const props = {};
if (!this.properties?.length) {
return props;
}
const { properties } = await this.ironclad.getRecordsSchema();
for (const property of this.properties) {
props[property] = {
type: properties[property].type === "boolean"
? "boolean"
: "string",
label: properties[property].displayName,
};
}
return props;
},
async run({ $ }) {
const { properties } = await this.ironclad.getRecordsSchema();
const propertiesData = {};
for (const property of this.properties) {
propertiesData[property] = {
type: properties[property].type,
value: this[property],
};
}

const response = await this.ironclad.createRecord({
$,
data: {
name: this.name,
type: this.type,
links: this.links?.length && this.links.map((link) => ({
recordId: link,
})),
parent: this.parent && {
recordId: this.parent,
},
children: this.children?.length && this.children.map((child) => ({
recordId: child,
})),
properties: propertiesData,
},
});
$.export("$summary", `Created record with ID: ${response.id}`);
return response;
},
};
70 changes: 70 additions & 0 deletions components/ironclad/actions/launch-workflow/launch-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import ironclad from "../../ironclad.app.mjs";

export default {
key: "ironclad-launch-workflow",
name: "Launch Workflow",
description: "Launches a new workflow in Ironclad. [See the documentation](https://developer.ironcladapp.com/reference/launch-a-new-workflow)",
version: "0.0.1",
type: "action",
props: {
ironclad,
templateId: {
propDefinition: [
ironclad,
"templateId",
],
reloadProps: true,
},
},
async additionalProps() {
const props = {};
if (!this.templateId) {
return props;
}
const { schema } = await this.ironclad.getWorkflowSchema({
templateId: this.templateId,
});
for (const [
key,
value,
] of Object.entries(schema)) {
if (!value.readOnly && value?.type !== "document" && value?.elementType?.type !== "document") {
props[key] = {
type: value.type === "boolean"
? "boolean"
: value.type === "array"
? "string[]"
: "string",
label: value.displayName,
optional: !(key === "counterpartyName"),
};
if (key === "paperSource") {
props[key].options = [
"Counterparty paper",
"Our paper",
];
}
}
}
return props;
},
async run({ $ }) {
const {
ironclad,
templateId,
...attributes
} = this;

const response = await ironclad.launchWorkflow({
$,
data: {
template: templateId,
attributes: {
...attributes,
},
},
});
$.export("$summary", `Workflow launched successfully with ID ${response.id}`);
return response;
},
};
76 changes: 76 additions & 0 deletions components/ironclad/actions/update-workflow/update-workflow.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import ironclad from "../../ironclad.app.mjs";

export default {
key: "ironclad-update-workflow",
name: "Update Workflow Metadata",
description: "Updates the metadata of an existing workflow. [See the documentation]()",
version: "0.0.1",
type: "action",
props: {
ironclad,
workflowId: {
propDefinition: [
ironclad,
"workflowId",
],
reloadProps: true,
},
comment: {
type: "string",
label: "Comment",
description: "A comment that explains the updates you are making to the workflow",
optional: true,
},
},
async additionalProps() {
const props = {};
if (!this.workflowId) {
return props;
}
const { schema } = await this.ironclad.getWorkflow({
workflowId: this.workflowId,
});
for (const [
key,
value,
] of Object.entries(schema)) {
if (!value?.readOnly && value?.type !== "document" && value?.elementType?.type !== "document") {
props[key] = {
type: value.type === "boolean"
? "boolean"
: value.type === "array"
? "string[]"
: "string",
label: value.displayName,
optional: true,
};
}
}
return props;
},
async run({ $ }) {
const {
ironclad,
workflowId,
comment,
...attributes
} = this;
const response = await ironclad.updateWorkflowMetadata({
$,
workflowId: workflowId,
data: {
updates: attributes && Object.entries(attributes).map(([
key,
value,
]) => ({
action: "set",
path: key,
value,
})),
comment: comment,
},
});
$.export("$summary", `Workflow ${workflowId} updated successfully`);
return response;
},
};
Loading
Loading