@slates-integrations/attio 0.2.0-rc.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,106 @@
1
+ import { SlateTrigger } from 'slates';
2
+ import { AttioClient } from '../lib/client';
3
+ import { spec } from '../spec';
4
+ import { z } from 'zod';
5
+
6
+ let LIST_ENTRY_EVENT_TYPES = [
7
+ 'list-entry.created',
8
+ 'list-entry.updated',
9
+ 'list-entry.deleted'
10
+ ] as const;
11
+
12
+ export let listEntryEventsTrigger = SlateTrigger.create(spec, {
13
+ name: 'List Entry Events',
14
+ key: 'list_entry_events',
15
+ description:
16
+ 'Triggers when records are added to, updated within, or removed from lists (e.g. sales pipelines, recruitment pipelines).'
17
+ })
18
+ .input(
19
+ z.object({
20
+ eventType: z.string().describe('Type of list entry event'),
21
+ eventId: z.string().describe('Unique event identifier'),
22
+ listId: z.string().describe('The list ID'),
23
+ entryId: z.string().describe('The entry ID'),
24
+ parentObjectId: z.string().optional().describe('Parent object ID'),
25
+ parentRecordId: z.string().optional().describe('Parent record ID'),
26
+ attributeId: z
27
+ .string()
28
+ .optional()
29
+ .describe('Attribute ID that changed (for update events)'),
30
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
31
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
32
+ })
33
+ )
34
+ .output(
35
+ z.object({
36
+ listId: z.string().describe('The list ID'),
37
+ entryId: z.string().describe('The entry ID'),
38
+ parentObjectId: z.string().optional().describe('Parent object ID'),
39
+ parentRecordId: z.string().optional().describe('Parent record ID'),
40
+ attributeId: z
41
+ .string()
42
+ .optional()
43
+ .describe('Attribute ID that changed (for update events)'),
44
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
45
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
46
+ })
47
+ )
48
+ .webhook({
49
+ autoRegisterWebhook: async ctx => {
50
+ let client = new AttioClient({ token: ctx.auth.token });
51
+
52
+ let webhook = await client.createWebhook(
53
+ ctx.input.webhookBaseUrl,
54
+ LIST_ENTRY_EVENT_TYPES.map(eventType => ({ eventType }))
55
+ );
56
+
57
+ return {
58
+ registrationDetails: {
59
+ webhookId: webhook.id?.webhook_id ?? webhook.webhook_id
60
+ }
61
+ };
62
+ },
63
+
64
+ autoUnregisterWebhook: async ctx => {
65
+ let client = new AttioClient({ token: ctx.auth.token });
66
+ await client.deleteWebhook(ctx.input.registrationDetails.webhookId);
67
+ },
68
+
69
+ handleRequest: async ctx => {
70
+ let body = (await ctx.request.json()) as any;
71
+ let events = body.events ?? [];
72
+
73
+ let inputs = events
74
+ .filter((e: any) => LIST_ENTRY_EVENT_TYPES.includes(e.event_type))
75
+ .map((e: any) => ({
76
+ eventType: e.event_type,
77
+ eventId: e.id?.event_id ?? `${e.event_type}-${e.id?.entry_id}-${Date.now()}`,
78
+ listId: e.id?.list_id ?? '',
79
+ entryId: e.id?.entry_id ?? '',
80
+ parentObjectId: e.id?.parent_object_id,
81
+ parentRecordId: e.id?.parent_record_id,
82
+ attributeId: e.id?.attribute_id,
83
+ actorType: e.actor?.type,
84
+ actorId: e.actor?.id
85
+ }));
86
+
87
+ return { inputs };
88
+ },
89
+
90
+ handleEvent: async ctx => {
91
+ return {
92
+ type: ctx.input.eventType,
93
+ id: ctx.input.eventId,
94
+ output: {
95
+ listId: ctx.input.listId,
96
+ entryId: ctx.input.entryId,
97
+ parentObjectId: ctx.input.parentObjectId,
98
+ parentRecordId: ctx.input.parentRecordId,
99
+ attributeId: ctx.input.attributeId,
100
+ actorType: ctx.input.actorType,
101
+ actorId: ctx.input.actorId
102
+ }
103
+ };
104
+ }
105
+ })
106
+ .build();
@@ -0,0 +1,93 @@
1
+ import { SlateTrigger } from 'slates';
2
+ import { AttioClient } from '../lib/client';
3
+ import { spec } from '../spec';
4
+ import { z } from 'zod';
5
+
6
+ let NOTE_EVENT_TYPES = [
7
+ 'note.created',
8
+ 'note.updated',
9
+ 'note.deleted',
10
+ 'note-content.updated'
11
+ ] as const;
12
+
13
+ export let noteEventsTrigger = SlateTrigger.create(spec, {
14
+ name: 'Note Events',
15
+ key: 'note_events',
16
+ description:
17
+ 'Triggers when notes are created, updated (title changes), deleted, or when note content changes.'
18
+ })
19
+ .input(
20
+ z.object({
21
+ eventType: z.string().describe('Type of note event'),
22
+ eventId: z.string().describe('Unique event identifier'),
23
+ noteId: z.string().describe('The note ID'),
24
+ parentObjectId: z.string().optional().describe('Parent object ID'),
25
+ parentRecordId: z.string().optional().describe('Parent record ID'),
26
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
27
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
28
+ })
29
+ )
30
+ .output(
31
+ z.object({
32
+ noteId: z.string().describe('The note ID'),
33
+ parentObjectId: z.string().optional().describe('Parent object ID'),
34
+ parentRecordId: z.string().optional().describe('Parent record ID'),
35
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
36
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
37
+ })
38
+ )
39
+ .webhook({
40
+ autoRegisterWebhook: async ctx => {
41
+ let client = new AttioClient({ token: ctx.auth.token });
42
+
43
+ let webhook = await client.createWebhook(
44
+ ctx.input.webhookBaseUrl,
45
+ NOTE_EVENT_TYPES.map(eventType => ({ eventType }))
46
+ );
47
+
48
+ return {
49
+ registrationDetails: {
50
+ webhookId: webhook.id?.webhook_id ?? webhook.webhook_id
51
+ }
52
+ };
53
+ },
54
+
55
+ autoUnregisterWebhook: async ctx => {
56
+ let client = new AttioClient({ token: ctx.auth.token });
57
+ await client.deleteWebhook(ctx.input.registrationDetails.webhookId);
58
+ },
59
+
60
+ handleRequest: async ctx => {
61
+ let body = (await ctx.request.json()) as any;
62
+ let events = body.events ?? [];
63
+
64
+ let inputs = events
65
+ .filter((e: any) => NOTE_EVENT_TYPES.includes(e.event_type))
66
+ .map((e: any) => ({
67
+ eventType: e.event_type,
68
+ eventId: e.id?.event_id ?? `${e.event_type}-${e.id?.note_id}-${Date.now()}`,
69
+ noteId: e.id?.note_id ?? '',
70
+ parentObjectId: e.id?.parent_object_id,
71
+ parentRecordId: e.id?.parent_record_id,
72
+ actorType: e.actor?.type,
73
+ actorId: e.actor?.id
74
+ }));
75
+
76
+ return { inputs };
77
+ },
78
+
79
+ handleEvent: async ctx => {
80
+ return {
81
+ type: ctx.input.eventType,
82
+ id: ctx.input.eventId,
83
+ output: {
84
+ noteId: ctx.input.noteId,
85
+ parentObjectId: ctx.input.parentObjectId,
86
+ parentRecordId: ctx.input.parentRecordId,
87
+ actorType: ctx.input.actorType,
88
+ actorId: ctx.input.actorId
89
+ }
90
+ };
91
+ }
92
+ })
93
+ .build();
@@ -0,0 +1,109 @@
1
+ import { SlateTrigger } from 'slates';
2
+ import { AttioClient } from '../lib/client';
3
+ import { spec } from '../spec';
4
+ import { z } from 'zod';
5
+
6
+ let RECORD_EVENT_TYPES = [
7
+ 'record.created',
8
+ 'record.updated',
9
+ 'record.deleted',
10
+ 'record.merged'
11
+ ] as const;
12
+
13
+ export let recordEventsTrigger = SlateTrigger.create(spec, {
14
+ name: 'Record Events',
15
+ key: 'record_events',
16
+ description:
17
+ 'Triggers when records are created, updated, deleted, or merged in Attio. Covers all object types (People, Companies, Deals, custom objects).'
18
+ })
19
+ .input(
20
+ z.object({
21
+ eventType: z.string().describe('Type of record event'),
22
+ eventId: z.string().describe('Unique event identifier'),
23
+ objectId: z.string().describe('Object ID the record belongs to'),
24
+ recordId: z.string().describe('The affected record ID'),
25
+ attributeId: z
26
+ .string()
27
+ .optional()
28
+ .describe('Attribute ID that changed (for update events)'),
29
+ duplicateRecordId: z
30
+ .string()
31
+ .optional()
32
+ .describe('Duplicate record ID (for merge events)'),
33
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
34
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
35
+ })
36
+ )
37
+ .output(
38
+ z.object({
39
+ objectId: z.string().describe('Object ID the record belongs to'),
40
+ recordId: z.string().describe('The affected record ID'),
41
+ attributeId: z
42
+ .string()
43
+ .optional()
44
+ .describe('Attribute ID that changed (for update events)'),
45
+ duplicateRecordId: z
46
+ .string()
47
+ .optional()
48
+ .describe('Duplicate record ID (for merge events)'),
49
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
50
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
51
+ })
52
+ )
53
+ .webhook({
54
+ autoRegisterWebhook: async ctx => {
55
+ let client = new AttioClient({ token: ctx.auth.token });
56
+
57
+ let webhook = await client.createWebhook(
58
+ ctx.input.webhookBaseUrl,
59
+ RECORD_EVENT_TYPES.map(eventType => ({ eventType }))
60
+ );
61
+
62
+ return {
63
+ registrationDetails: {
64
+ webhookId: webhook.id?.webhook_id ?? webhook.webhook_id
65
+ }
66
+ };
67
+ },
68
+
69
+ autoUnregisterWebhook: async ctx => {
70
+ let client = new AttioClient({ token: ctx.auth.token });
71
+ await client.deleteWebhook(ctx.input.registrationDetails.webhookId);
72
+ },
73
+
74
+ handleRequest: async ctx => {
75
+ let body = (await ctx.request.json()) as any;
76
+ let events = body.events ?? [];
77
+
78
+ let inputs = events
79
+ .filter((e: any) => RECORD_EVENT_TYPES.includes(e.event_type))
80
+ .map((e: any) => ({
81
+ eventType: e.event_type,
82
+ eventId: e.id?.event_id ?? `${e.event_type}-${e.id?.record_id}-${Date.now()}`,
83
+ objectId: e.id?.object_id ?? '',
84
+ recordId: e.id?.record_id ?? '',
85
+ attributeId: e.id?.attribute_id,
86
+ duplicateRecordId: e.id?.duplicate_record_id,
87
+ actorType: e.actor?.type,
88
+ actorId: e.actor?.id
89
+ }));
90
+
91
+ return { inputs };
92
+ },
93
+
94
+ handleEvent: async ctx => {
95
+ return {
96
+ type: ctx.input.eventType,
97
+ id: ctx.input.eventId,
98
+ output: {
99
+ objectId: ctx.input.objectId,
100
+ recordId: ctx.input.recordId,
101
+ attributeId: ctx.input.attributeId,
102
+ duplicateRecordId: ctx.input.duplicateRecordId,
103
+ actorType: ctx.input.actorType,
104
+ actorId: ctx.input.actorId
105
+ }
106
+ };
107
+ }
108
+ })
109
+ .build();
@@ -0,0 +1,79 @@
1
+ import { SlateTrigger } from 'slates';
2
+ import { AttioClient } from '../lib/client';
3
+ import { spec } from '../spec';
4
+ import { z } from 'zod';
5
+
6
+ let TASK_EVENT_TYPES = ['task.created', 'task.updated', 'task.deleted'] as const;
7
+
8
+ export let taskEventsTrigger = SlateTrigger.create(spec, {
9
+ name: 'Task Events',
10
+ key: 'task_events',
11
+ description: 'Triggers when tasks are created, updated, or deleted in the workspace.'
12
+ })
13
+ .input(
14
+ z.object({
15
+ eventType: z.string().describe('Type of task event'),
16
+ eventId: z.string().describe('Unique event identifier'),
17
+ taskId: z.string().describe('The task ID'),
18
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
19
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
20
+ })
21
+ )
22
+ .output(
23
+ z.object({
24
+ taskId: z.string().describe('The task ID'),
25
+ actorType: z.string().optional().describe('Type of actor that triggered the event'),
26
+ actorId: z.string().optional().describe('ID of the actor that triggered the event')
27
+ })
28
+ )
29
+ .webhook({
30
+ autoRegisterWebhook: async ctx => {
31
+ let client = new AttioClient({ token: ctx.auth.token });
32
+
33
+ let webhook = await client.createWebhook(
34
+ ctx.input.webhookBaseUrl,
35
+ TASK_EVENT_TYPES.map(eventType => ({ eventType }))
36
+ );
37
+
38
+ return {
39
+ registrationDetails: {
40
+ webhookId: webhook.id?.webhook_id ?? webhook.webhook_id
41
+ }
42
+ };
43
+ },
44
+
45
+ autoUnregisterWebhook: async ctx => {
46
+ let client = new AttioClient({ token: ctx.auth.token });
47
+ await client.deleteWebhook(ctx.input.registrationDetails.webhookId);
48
+ },
49
+
50
+ handleRequest: async ctx => {
51
+ let body = (await ctx.request.json()) as any;
52
+ let events = body.events ?? [];
53
+
54
+ let inputs = events
55
+ .filter((e: any) => TASK_EVENT_TYPES.includes(e.event_type))
56
+ .map((e: any) => ({
57
+ eventType: e.event_type,
58
+ eventId: e.id?.event_id ?? `${e.event_type}-${e.id?.task_id}-${Date.now()}`,
59
+ taskId: e.id?.task_id ?? '',
60
+ actorType: e.actor?.type,
61
+ actorId: e.actor?.id
62
+ }));
63
+
64
+ return { inputs };
65
+ },
66
+
67
+ handleEvent: async ctx => {
68
+ return {
69
+ type: ctx.input.eventType,
70
+ id: ctx.input.eventId,
71
+ output: {
72
+ taskId: ctx.input.taskId,
73
+ actorType: ctx.input.actorType,
74
+ actorId: ctx.input.actorId
75
+ }
76
+ };
77
+ }
78
+ })
79
+ .build();
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "types": ["node"],
4
+ "lib": ["ESNext"],
5
+ "target": "ESNext",
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+ "moduleResolution": "bundler",
11
+ "noEmit": true,
12
+ "strict": true,
13
+ "skipLibCheck": true,
14
+ "noFallthroughCasesInSwitch": true,
15
+ "noUncheckedIndexedAccess": true,
16
+ "noImplicitOverride": true,
17
+ "noUnusedLocals": false,
18
+ "noUnusedParameters": false,
19
+ "noPropertyAccessFromIndexSignature": false
20
+ },
21
+ "include": ["src"]
22
+ }