Skip to content

Commit ae31376

Browse files
committed
[Components] attio - added new components
1 parent 106b401 commit ae31376

File tree

22 files changed

+927
-199
lines changed

22 files changed

+927
-199
lines changed

components/attio/actions/create-note/create-note.mjs

+24-7
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,33 @@ export default {
44
key: "attio-create-note",
55
name: "Create Note",
66
description: "Creates a new note for a given record. The note will be linked to the specified record. [See the documentation](https://developers.attio.com/reference/post_v2-notes)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
attio,
1111
parentObject: {
1212
propDefinition: [
1313
attio,
1414
"objectId",
15+
() => ({
16+
mapper: ({
17+
api_slug: value,
18+
singular_noun: label,
19+
}) => ({
20+
value,
21+
label,
22+
}),
23+
}),
1524
],
16-
label: "Parent Object ID",
17-
description: "The ID of the parent object the note belongs to",
25+
label: "Parent Object",
26+
description: "The parent object the note belongs to",
1827
},
1928
parentRecordId: {
2029
propDefinition: [
2130
attio,
2231
"recordId",
23-
(c) => ({
24-
objectId: c.parentObject,
32+
({ parentObject }) => ({
33+
targetObject: parentObject,
2534
}),
2635
],
2736
label: "Parent Record ID",
@@ -38,8 +47,16 @@ export default {
3847
description: "The content of the note",
3948
},
4049
},
50+
methods: {
51+
createNote(args = {}) {
52+
return this.attio.post({
53+
path: "/notes",
54+
...args,
55+
});
56+
},
57+
},
4158
async run({ $ }) {
42-
const response = await this.attio.createNote({
59+
const response = await this.createNote({
4360
$,
4461
data: {
4562
data: {
@@ -51,7 +68,7 @@ export default {
5168
},
5269
},
5370
});
54-
$.export("$summary", `Successfully created note with ID: ${response.data.id.note_id}`);
71+
$.export("$summary", `Successfully created note with ID \`${response.data.id.note_id}\`.`);
5572
return response;
5673
},
5774
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
import attio from "../../attio.app.mjs";
2+
import constants from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "attio-create-person",
6+
name: "Create Person",
7+
description: "Creates a new person. [See the documentation](https://developers.attio.com/reference/post_v2-objects-people-records).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
attio,
12+
firstName: {
13+
propDefinition: [
14+
attio,
15+
"firstName",
16+
],
17+
},
18+
lastName: {
19+
propDefinition: [
20+
attio,
21+
"lastName",
22+
],
23+
},
24+
emailAddress: {
25+
propDefinition: [
26+
attio,
27+
"emailAddress",
28+
],
29+
},
30+
description: {
31+
propDefinition: [
32+
attio,
33+
"description",
34+
],
35+
},
36+
jobTitle: {
37+
propDefinition: [
38+
attio,
39+
"jobTitle",
40+
],
41+
},
42+
phoneNumber: {
43+
propDefinition: [
44+
attio,
45+
"phoneNumber",
46+
],
47+
},
48+
phoneNumberCountryCode: {
49+
propDefinition: [
50+
attio,
51+
"phoneNumberCountryCode",
52+
],
53+
},
54+
linkedin: {
55+
propDefinition: [
56+
attio,
57+
"linkedin",
58+
],
59+
},
60+
twitter: {
61+
propDefinition: [
62+
attio,
63+
"twitter",
64+
],
65+
},
66+
facebook: {
67+
propDefinition: [
68+
attio,
69+
"facebook",
70+
],
71+
},
72+
instagram: {
73+
propDefinition: [
74+
attio,
75+
"instagram",
76+
],
77+
},
78+
companyId: {
79+
label: "Company ID",
80+
description: "The ID of the company to associate with the person.",
81+
optional: true,
82+
propDefinition: [
83+
attio,
84+
"recordId",
85+
() => ({
86+
targetObject: constants.TARGET_OBJECT.COMPANIES,
87+
}),
88+
],
89+
},
90+
},
91+
async run({ $ }) {
92+
const {
93+
attio,
94+
firstName,
95+
lastName,
96+
emailAddress,
97+
description,
98+
jobTitle,
99+
phoneNumber,
100+
phoneNumberCountryCode,
101+
linkedin,
102+
twitter,
103+
facebook,
104+
instagram,
105+
companyId,
106+
} = this;
107+
108+
const response = await attio.createRecord({
109+
$,
110+
targetObject: constants.TARGET_OBJECT.PEOPLE,
111+
data: {
112+
data: {
113+
values: {
114+
...(emailAddress && {
115+
email_addresses: [
116+
{
117+
email_address: emailAddress,
118+
},
119+
],
120+
}),
121+
...(firstName || lastName) && {
122+
name: [
123+
{
124+
first_name: firstName || "",
125+
last_name: lastName || "",
126+
full_name: `${firstName || ""} ${lastName || ""}`.trim(),
127+
},
128+
],
129+
},
130+
...(description && {
131+
description: [
132+
{
133+
value: description,
134+
},
135+
],
136+
}),
137+
...(jobTitle && {
138+
job_title: [
139+
{
140+
value: jobTitle,
141+
},
142+
],
143+
}),
144+
...(phoneNumber && {
145+
phone_numbers: [
146+
{
147+
original_phone_number: phoneNumber,
148+
...(phoneNumberCountryCode && {
149+
country_code: phoneNumberCountryCode,
150+
}),
151+
},
152+
],
153+
}),
154+
...(linkedin && {
155+
linkedin: [
156+
{
157+
value: linkedin,
158+
},
159+
],
160+
}),
161+
...(twitter && {
162+
twitter: [
163+
{
164+
value: twitter,
165+
},
166+
],
167+
}),
168+
...(facebook && {
169+
facebook: [
170+
{
171+
value: facebook,
172+
},
173+
],
174+
}),
175+
...(instagram && {
176+
instagram: [
177+
{
178+
value: instagram,
179+
},
180+
],
181+
}),
182+
...(companyId && {
183+
company: [
184+
{
185+
target_object: constants.TARGET_OBJECT.COMPANIES,
186+
target_record_id: companyId,
187+
},
188+
],
189+
}),
190+
},
191+
},
192+
},
193+
});
194+
195+
$.export("$summary", `Successfully created person with ID \`${response.data.id.record_id}\`.`);
196+
197+
return response;
198+
},
199+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import attio from "../../attio.app.mjs";
2+
3+
export default {
4+
key: "attio-create-task",
5+
name: "Create Task",
6+
description: "Creates a new task. [See the documentation](https://developers.attio.com/reference/post_v2-tasks)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
attio,
11+
content: {
12+
type: "string",
13+
label: "Content",
14+
description: "The text content of the task",
15+
},
16+
deadlineAt: {
17+
type: "string",
18+
label: "Deadline",
19+
description: "The deadline of the task in ISO 8601 format (e.g. `2025-04-22T10:00:00Z`)",
20+
},
21+
isCompleted: {
22+
type: "boolean",
23+
label: "Is Completed",
24+
description: "Whether the task has been completed",
25+
},
26+
assigneeIds: {
27+
type: "string[]",
28+
label: "Assignees",
29+
description: "The id of the members to assign the task to",
30+
propDefinition: [
31+
attio,
32+
"workspaceMemberId",
33+
],
34+
},
35+
},
36+
methods: {
37+
createTask(args = {}) {
38+
return this.attio.post({
39+
path: "/tasks",
40+
...args,
41+
});
42+
},
43+
},
44+
async run({ $ }) {
45+
const {
46+
content,
47+
deadlineAt,
48+
isCompleted,
49+
assigneeIds,
50+
} = this;
51+
52+
const response = await this.createTask({
53+
$,
54+
data: {
55+
data: {
56+
format: "plaintext",
57+
content,
58+
deadline_at: deadlineAt,
59+
is_completed: isCompleted,
60+
assignees: assigneeIds?.map((id) => ({
61+
referenced_actor_type: "workspace-member",
62+
referenced_actor_id: id,
63+
})) || [],
64+
},
65+
},
66+
});
67+
68+
$.export("$summary", `Successfully created task with ID \`${response.data.id.task_id}\`.`);
69+
return response;
70+
},
71+
};

components/attio/actions/create-update-record/create-update-record.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "attio-create-update-record",
66
name: "Create or Update Record",
77
description: "Creates or updates a specific record such as a person or a deal. If the record already exists, it's updated. Otherwise, a new record is created. [See the documentation](https://developers.attio.com/reference/put_v2-objects-object-records)",
8-
version: "0.0.2",
8+
version: "0.0.3",
99
type: "action",
1010
props: {
1111
attio,

components/attio/actions/delete-list-entry/delete-list-entry.mjs

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "attio-delete-list-entry",
55
name: "Delete List Entry",
66
description: "Deletes an existing entry from a specific list. [See the documentation](https://developers.attio.com/reference/delete_v2-lists-list-entries-entry-id)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
type: "action",
99
props: {
1010
attio,
@@ -18,14 +18,24 @@ export default {
1818
propDefinition: [
1919
attio,
2020
"entryId",
21-
(c) => ({
22-
listId: c.listId,
21+
({ listId }) => ({
22+
listId,
2323
}),
2424
],
2525
},
2626
},
27+
methods: {
28+
deleteListEntry({
29+
listId, entryId, ...opts
30+
}) {
31+
return this.attio.delete({
32+
path: `/lists/${listId}/entries/${entryId}`,
33+
...opts,
34+
});
35+
},
36+
},
2737
async run({ $ }) {
28-
const response = await this.attio.deleteListEntry({
38+
const response = await this.deleteListEntry({
2939
$,
3040
listId: this.listId,
3141
entryId: this.entryId,

0 commit comments

Comments
 (0)