Skip to content

Commit 594fd1a

Browse files
committed
wip
1 parent 491fb31 commit 594fd1a

File tree

9 files changed

+269
-6
lines changed

9 files changed

+269
-6
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import attio from "../../attio.app.mjs";
2+
3+
export default {
4+
key: "attio-create-note",
5+
name: "Create Note",
6+
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.{{ts}}",
8+
type: "action",
9+
props: {
10+
attio,
11+
parentObject: {
12+
propDefinition: [
13+
attio,
14+
"objectId",
15+
],
16+
label: "Parent Object ID",
17+
description: "The ID of the parent object the note belongs to",
18+
},
19+
parentRecordId: {
20+
propDefinition: [
21+
attio,
22+
"recordId",
23+
(c) => ({
24+
objectId: c.parentObject,
25+
}),
26+
],
27+
label: "Parent Record ID",
28+
description: "The ID of the parent record the note belongs to",
29+
},
30+
title: {
31+
type: "string",
32+
label: "Title",
33+
description: "The note title",
34+
},
35+
content: {
36+
type: "string",
37+
label: "Content",
38+
description: "The content of the note",
39+
},
40+
},
41+
async run({ $ }) {
42+
const response = await this.attio.createNote({
43+
$,
44+
data: {
45+
data: {
46+
parent_object: this.parentObject,
47+
parent_record_id: this.parentRecordId,
48+
title: this.title,
49+
format: "plaintext",
50+
content: this.content,
51+
},
52+
},
53+
});
54+
$.export("$summary", `Successfully created note with ID: ${response.data.id.note_id}`);
55+
return response;
56+
},
57+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import attio from "../../attio.app.mjs";
2+
3+
export default {
4+
key: "attio-create-update-record",
5+
name: "Create or Update Record",
6+
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)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
attio,
11+
objectId: {
12+
propDefinition: [
13+
attio,
14+
"objectId",
15+
],
16+
},
17+
parentRecordId: {
18+
propDefinition: [
19+
attio,
20+
"recordId",
21+
(c) => ({
22+
objectId: c.objectId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.upsertRecord({
29+
$,
30+
data: {},
31+
});
32+
return response;
33+
},
34+
};
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import attio from "../../attio.app.mjs";
2+
3+
export default {
4+
key: "attio-delete-list-entry",
5+
name: "Delete List Entry",
6+
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.{{ts}}",
8+
type: "action",
9+
props: {
10+
attio,
11+
listId: {
12+
propDefinition: [
13+
attio,
14+
"listId",
15+
],
16+
},
17+
entryId: {
18+
propDefinition: [
19+
attio,
20+
"entryId",
21+
(c) => ({
22+
listId: c.listId,
23+
}),
24+
],
25+
},
26+
},
27+
async run({ $ }) {
28+
const response = await this.attio.deleteListEntry({
29+
$,
30+
listId: this.listId,
31+
entryId: this.entryId,
32+
});
33+
$.export("$summary", `Successfully deleted list entry with ID: ${this.entryId}`);
34+
return response;
35+
},
36+
};

components/attio/attio.app.mjs

Lines changed: 137 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,144 @@
1+
import { axios } from "@pipedream/platform";
2+
const DEFAULT_LIMIT = 20;
3+
14
export default {
25
type: "app",
36
app: "attio",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
listId: {
9+
type: "string",
10+
label: "List ID",
11+
description: "The identifier of a list",
12+
async options() {
13+
const { data } = await this.listLists();
14+
return data?.map(({
15+
id, name: label,
16+
}) => ({
17+
value: id.list_id,
18+
label,
19+
})) || [];
20+
},
21+
},
22+
entryId: {
23+
type: "string",
24+
label: "Entry ID",
25+
description: "The identifier of a list entry",
26+
async options({
27+
listId, page,
28+
}) {
29+
const { data } = await this.listEntries({
30+
listId,
31+
params: {
32+
limit: DEFAULT_LIMIT,
33+
offset: page * DEFAULT_LIMIT,
34+
},
35+
});
36+
return data?.map(({ id }) => id.entry_id) || [];
37+
},
38+
},
39+
objectId: {
40+
type: "string",
41+
label: "Object ID",
42+
description: "The identifier of an object",
43+
async options() {
44+
const { data } = await this.listObjects();
45+
return data?.map(({
46+
id, singular_noun: label,
47+
}) => ({
48+
value: id.object_id,
49+
label,
50+
})) || [];
51+
},
52+
},
53+
recordId: {
54+
type: "string",
55+
label: "Record ID",
56+
description: "Identifier of a record",
57+
async options({
58+
objectId, page,
59+
}) {
60+
const { data } = await this.listRecords({
61+
objectId,
62+
params: {
63+
limit: DEFAULT_LIMIT,
64+
offset: page * DEFAULT_LIMIT,
65+
},
66+
});
67+
return data?.map(({ id }) => id.record_id) || [];
68+
},
69+
},
70+
},
571
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
72+
_baseUrl() {
73+
return "https://api.attio.com/v2";
74+
},
75+
_makeRequest({
76+
$ = this,
77+
path,
78+
...opts
79+
}) {
80+
return axios($, {
81+
url: `${this._baseUrl()}${path}`,
82+
headers: {
83+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
84+
},
85+
...opts,
86+
});
87+
},
88+
listLists(opts = {}) {
89+
return this._makeRequest({
90+
path: "/lists",
91+
...opts,
92+
});
93+
},
94+
listEntries({
95+
listId, ...opts
96+
}) {
97+
return this._makeRequest({
98+
method: "POST",
99+
path: `/lists/${listId}/entries/query`,
100+
...opts,
101+
});
102+
},
103+
listObjects(opts = {}) {
104+
return this._makeRequest({
105+
path: "/objects",
106+
...opts,
107+
});
108+
},
109+
listRecords({
110+
objectId, ...opts
111+
}) {
112+
return this._makeRequest({
113+
method: "POST",
114+
path: `/objects/${objectId}/records/query`,
115+
...opts,
116+
});
117+
},
118+
createNote(opts = {}) {
119+
return this._makeRequest({
120+
method: "POST",
121+
path: "/notes",
122+
...opts,
123+
});
124+
},
125+
upsertRecord({
126+
objectType, ...opts
127+
}) {
128+
return this._makeRequest({
129+
method: "PUT",
130+
path: `/objects/${objectType}/records`,
131+
...opts,
132+
});
133+
},
134+
deleteListEntry({
135+
listId, entryId, ...opts
136+
}) {
137+
return this._makeRequest({
138+
method: "DELETE",
139+
path: `/lists/${listId}/entries/${entryId}`,
140+
...opts,
141+
});
9142
},
10143
},
11144
};

components/attio/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/attio",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Attio Components",
55
"main": "attio.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
}
15-
}
18+
}

components/attio/sources/common/base.mjs

Whitespace-only changes.

components/attio/sources/new-list-entry-instant/new-list-entry-instant.mjs

Whitespace-only changes.

components/attio/sources/new-record-created-instant/new-record-created-instant.mjs

Whitespace-only changes.

components/attio/sources/record-updated-instant/record-updated-instant.mjs

Whitespace-only changes.

0 commit comments

Comments
 (0)