@notionhq/workers 0.4.0 → 0.6.0
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.
- package/dist/alpha/builder.d.ts +149 -0
- package/dist/alpha/builder.d.ts.map +1 -0
- package/dist/alpha/builder.js +260 -0
- package/dist/alpha/builder.test.d.ts +2 -0
- package/dist/alpha/builder.test.d.ts.map +1 -0
- package/dist/alpha/cli/build.d.ts +13 -0
- package/dist/alpha/cli/build.d.ts.map +1 -0
- package/dist/alpha/cli/build.js +36 -0
- package/dist/alpha/cli/build.test.d.ts +2 -0
- package/dist/alpha/cli/build.test.d.ts.map +1 -0
- package/dist/alpha/cli/codegen.d.ts +10 -0
- package/dist/alpha/cli/codegen.d.ts.map +1 -0
- package/dist/alpha/cli/codegen.js +41 -0
- package/dist/alpha/cli/codegen.test.d.ts +2 -0
- package/dist/alpha/cli/codegen.test.d.ts.map +1 -0
- package/dist/alpha/cli/discover.d.ts +35 -0
- package/dist/alpha/cli/discover.d.ts.map +1 -0
- package/dist/alpha/cli/discover.js +39 -0
- package/dist/alpha/cli/discover.test.d.ts +2 -0
- package/dist/alpha/cli/discover.test.d.ts.map +1 -0
- package/dist/alpha/cli/emit-manifest.d.ts +33 -0
- package/dist/alpha/cli/emit-manifest.d.ts.map +1 -0
- package/dist/alpha/cli/emit-manifest.js +266 -0
- package/dist/alpha/cli/emit-manifest.test.d.ts +2 -0
- package/dist/alpha/cli/emit-manifest.test.d.ts.map +1 -0
- package/dist/alpha/cli/index.d.ts +3 -0
- package/dist/alpha/cli/index.d.ts.map +1 -0
- package/dist/alpha/cli/index.js +36 -0
- package/dist/alpha/context.d.ts +8 -0
- package/dist/alpha/context.d.ts.map +1 -0
- package/dist/alpha/context.js +33 -0
- package/dist/alpha/database.d.ts +90 -0
- package/dist/alpha/database.d.ts.map +1 -0
- package/dist/alpha/database.js +9 -0
- package/dist/alpha/error.d.ts +41 -0
- package/dist/alpha/error.d.ts.map +1 -0
- package/dist/alpha/error.js +25 -0
- package/dist/alpha/icon-names.d.ts +6 -0
- package/dist/alpha/icon-names.d.ts.map +1 -0
- package/dist/alpha/icon-names.js +0 -0
- package/dist/alpha/json-schema.d.ts +117 -0
- package/dist/alpha/json-schema.d.ts.map +1 -0
- package/dist/alpha/json-schema.js +0 -0
- package/dist/alpha/manifest.d.ts +44 -0
- package/dist/alpha/manifest.d.ts.map +1 -0
- package/dist/alpha/manifest.js +0 -0
- package/dist/alpha/output.d.ts +7 -0
- package/dist/alpha/output.d.ts.map +1 -0
- package/dist/alpha/output.js +8 -0
- package/dist/alpha/pacer.d.ts +74 -0
- package/dist/alpha/pacer.d.ts.map +1 -0
- package/dist/alpha/pacer.js +66 -0
- package/dist/alpha/pacer.test.d.ts +2 -0
- package/dist/alpha/pacer.test.d.ts.map +1 -0
- package/dist/alpha/schedule.d.ts +6 -0
- package/dist/alpha/schedule.d.ts.map +1 -0
- package/dist/alpha/schedule.js +43 -0
- package/dist/alpha/schedule.test.d.ts +2 -0
- package/dist/alpha/schedule.test.d.ts.map +1 -0
- package/dist/alpha/schema-builder.d.ts +79 -0
- package/dist/alpha/schema-builder.d.ts.map +1 -0
- package/dist/alpha/schema-builder.js +135 -0
- package/dist/alpha/schema.d.ts +185 -0
- package/dist/alpha/schema.d.ts.map +1 -0
- package/dist/alpha/schema.js +115 -0
- package/dist/alpha/sync.d.ts +233 -0
- package/dist/alpha/sync.d.ts.map +1 -0
- package/dist/alpha/sync.js +70 -0
- package/dist/alpha/sync.test.d.ts +2 -0
- package/dist/alpha/sync.test.d.ts.map +1 -0
- package/dist/alpha/tool.d.ts +132 -0
- package/dist/alpha/tool.d.ts.map +1 -0
- package/dist/alpha/tool.js +156 -0
- package/dist/alpha/tool.test.d.ts +2 -0
- package/dist/alpha/tool.test.d.ts.map +1 -0
- package/dist/alpha/triggers.d.ts +365 -0
- package/dist/alpha/triggers.d.ts.map +1 -0
- package/dist/alpha/triggers.generated.d.ts +246 -0
- package/dist/alpha/triggers.generated.d.ts.map +1 -0
- package/dist/alpha/triggers.generated.js +239 -0
- package/dist/alpha/triggers.js +0 -0
- package/dist/alpha/types.d.ts +228 -0
- package/dist/alpha/types.d.ts.map +1 -0
- package/dist/alpha/types.js +0 -0
- package/dist/alpha/workflow.d.ts +70 -0
- package/dist/alpha/workflow.d.ts.map +1 -0
- package/dist/alpha/workflow.js +39 -0
- package/dist/alpha/workflow.test.d.ts +2 -0
- package/dist/alpha/workflow.test.d.ts.map +1 -0
- package/dist/builder.d.ts +7 -1
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +12 -3
- package/dist/capabilities/ai_connector.d.ts.map +1 -1
- package/dist/capabilities/automation.d.ts.map +1 -1
- package/dist/capabilities/context.d.ts.map +1 -1
- package/dist/capabilities/context.js +1 -1
- package/dist/capabilities/custom-block.d.ts +124 -0
- package/dist/capabilities/custom-block.d.ts.map +1 -0
- package/dist/capabilities/custom-block.js +22 -0
- package/dist/capabilities/oauth.d.ts.map +1 -1
- package/dist/capabilities/output.d.ts.map +1 -1
- package/dist/capabilities/output.js +2 -4
- package/dist/capabilities/stateful-capability.d.ts.map +1 -1
- package/dist/capabilities/stateful-capability.js +3 -7
- package/dist/capabilities/sync.d.ts +11 -1
- package/dist/capabilities/sync.d.ts.map +1 -1
- package/dist/capabilities/sync.js +2 -8
- package/dist/capabilities/tool.d.ts.map +1 -1
- package/dist/capabilities/tool.js +6 -20
- package/dist/capabilities/webhook.d.ts.map +1 -1
- package/dist/capabilities/workflow.d.ts +50 -0
- package/dist/capabilities/workflow.d.ts.map +1 -0
- package/dist/capabilities/workflow.js +40 -0
- package/dist/capabilities/workflow.test.d.ts +2 -0
- package/dist/capabilities/workflow.test.d.ts.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/schema-builder.d.ts.map +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/triggers.d.ts +365 -0
- package/dist/triggers.d.ts.map +1 -0
- package/dist/triggers.generated.d.ts +246 -0
- package/dist/triggers.generated.d.ts.map +1 -0
- package/dist/triggers.generated.js +239 -0
- package/dist/triggers.js +0 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +72 -2
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +85 -4
- package/package.json +81 -14
- package/src/alpha/ajv-formats.d.ts +7 -0
- package/src/alpha/builder.test.ts +197 -0
- package/src/alpha/builder.ts +338 -0
- package/src/alpha/cli/build.test.ts +240 -0
- package/src/alpha/cli/build.ts +57 -0
- package/src/alpha/cli/codegen.test.ts +31 -0
- package/src/alpha/cli/codegen.ts +51 -0
- package/src/alpha/cli/discover.test.ts +43 -0
- package/src/alpha/cli/discover.ts +81 -0
- package/src/alpha/cli/emit-manifest.test.ts +45 -0
- package/src/alpha/cli/emit-manifest.ts +409 -0
- package/src/alpha/cli/index.ts +41 -0
- package/src/alpha/context.ts +61 -0
- package/src/alpha/database.ts +102 -0
- package/src/alpha/error.ts +49 -0
- package/src/alpha/icon-names.ts +890 -0
- package/src/alpha/json-schema.ts +180 -0
- package/src/alpha/manifest.ts +47 -0
- package/src/alpha/output.ts +8 -0
- package/src/alpha/pacer.test.ts +81 -0
- package/src/alpha/pacer.ts +181 -0
- package/src/alpha/schedule.test.ts +31 -0
- package/src/alpha/schedule.ts +53 -0
- package/src/alpha/schema-builder.ts +193 -0
- package/src/alpha/schema.ts +222 -0
- package/src/alpha/sync.test.ts +191 -0
- package/src/alpha/sync.ts +340 -0
- package/src/alpha/tool.test.ts +116 -0
- package/src/alpha/tool.ts +319 -0
- package/src/alpha/triggers.generated.ts +489 -0
- package/src/alpha/triggers.ts +500 -0
- package/src/alpha/types.ts +284 -0
- package/src/alpha/workflow.test.ts +84 -0
- package/src/alpha/workflow.ts +131 -0
- package/src/builder.test.ts +28 -60
- package/src/builder.ts +20 -7
- package/src/capabilities/ai_connector.test.ts +9 -32
- package/src/capabilities/ai_connector.ts +5 -17
- package/src/capabilities/automation.test.ts +3 -12
- package/src/capabilities/automation.ts +3 -11
- package/src/capabilities/context.ts +5 -8
- package/src/capabilities/custom-block.ts +181 -0
- package/src/capabilities/oauth.test.ts +1 -0
- package/src/capabilities/oauth.ts +1 -3
- package/src/capabilities/output.ts +1 -3
- package/src/capabilities/stateful-capability.test.ts +1 -0
- package/src/capabilities/stateful-capability.ts +3 -7
- package/src/capabilities/sync.test.ts +76 -42
- package/src/capabilities/sync.ts +16 -40
- package/src/capabilities/tool.test.ts +106 -146
- package/src/capabilities/tool.ts +17 -39
- package/src/capabilities/webhook.ts +3 -10
- package/src/capabilities/workflow.test.ts +163 -0
- package/src/capabilities/workflow.ts +112 -0
- package/src/index.ts +18 -6
- package/src/json-schema.test.ts +2 -4
- package/src/json-schema.ts +7 -6
- package/src/pacer.test.ts +1 -3
- package/src/pacer_internal.ts +1 -5
- package/src/schema-builder.test.ts +10 -35
- package/src/schema-builder.ts +6 -16
- package/src/schema.ts +2 -10
- package/src/triggers.generated.ts +489 -0
- package/src/triggers.ts +504 -0
- package/src/types.ts +21 -7
- package/src/worker.test.ts +147 -0
- package/src/worker.ts +155 -32
- package/dist/block.d.ts +0 -321
- package/dist/block.d.ts.map +0 -1
- package/src/block.ts +0 -529
- /package/dist/{block.js → alpha/ajv-formats.d.js} +0 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Trigger Types — Public API
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for agent triggers between @notionhq/workers and the Notion repository.
|
|
5
|
+
* This file MUST be kept identical in both repositories.
|
|
6
|
+
*
|
|
7
|
+
* Conventions:
|
|
8
|
+
* - Protocols define the standard fields every consumer can rely on.
|
|
9
|
+
* - Vendor-specific fields use `x-<vendor>-` prefix (e.g., "x-slack-threadId").
|
|
10
|
+
* - Only public URLs — no internal URIs.
|
|
11
|
+
* - No `data` sub-object — vendor fields live at the top level with `x-<vendor>-`.
|
|
12
|
+
* - Types only — no runtime values.
|
|
13
|
+
* - All fields are required. Nullable fields use `T | null` (no `?:`) so they
|
|
14
|
+
* map directly to required + nullable in JSON Schema for LLM structured output.
|
|
15
|
+
* - Conversions must always provide explicit values (use `null` when absent).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// ============================================================
|
|
19
|
+
// Vendor extension pattern
|
|
20
|
+
// ============================================================
|
|
21
|
+
|
|
22
|
+
/** Allows arbitrary vendor-specific fields prefixed with `x-<vendor>-`. */
|
|
23
|
+
export type VendorExtensions = {
|
|
24
|
+
[key: `x-${string}`]: unknown;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// ============================================================
|
|
28
|
+
// Protocols (composable capabilities)
|
|
29
|
+
// ============================================================
|
|
30
|
+
|
|
31
|
+
/** Has a human-readable message / summary. */
|
|
32
|
+
export type MessageLike = {
|
|
33
|
+
message: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** Has an actor who performed the action. */
|
|
37
|
+
export type ActorLike = {
|
|
38
|
+
actor: Actor | null;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Has a navigable URL. */
|
|
42
|
+
export type LinkLike = {
|
|
43
|
+
url: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** Has a timestamp. */
|
|
47
|
+
export type TimestampLike = {
|
|
48
|
+
/** ISO 8601 */
|
|
49
|
+
timestamp: string | null;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Has a conversation thread. */
|
|
53
|
+
export type ThreadLike<M = ThreadMessage> = {
|
|
54
|
+
thread: Array<M>;
|
|
55
|
+
/** Whether this event is a follow-up in a previously subscribed thread. */
|
|
56
|
+
isFollowUpMessage: boolean | null;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A chat message. Any chat platform (Slack, Discord, MS Teams, etc.) implements this.
|
|
61
|
+
* Composes MessageLike, ActorLike, LinkLike, TimestampLike.
|
|
62
|
+
*/
|
|
63
|
+
export type ChatMessageLike = MessageLike &
|
|
64
|
+
ActorLike &
|
|
65
|
+
LinkLike &
|
|
66
|
+
TimestampLike & {
|
|
67
|
+
id: string;
|
|
68
|
+
channelId: string;
|
|
69
|
+
channelName: string | null;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** An email message. Any mail provider (Gmail, Outlook, etc.) implements this. */
|
|
73
|
+
export type EmailMessageLike = MessageLike &
|
|
74
|
+
LinkLike &
|
|
75
|
+
TimestampLike & {
|
|
76
|
+
id: string;
|
|
77
|
+
subject: string;
|
|
78
|
+
from: string;
|
|
79
|
+
fromName: string | null;
|
|
80
|
+
to: Array<string>;
|
|
81
|
+
cc: Array<string> | null;
|
|
82
|
+
bcc: Array<string> | null;
|
|
83
|
+
/** Plain-text or HTML body content. */
|
|
84
|
+
body: string;
|
|
85
|
+
isRead: boolean | null;
|
|
86
|
+
hasAttachments: boolean | null;
|
|
87
|
+
labels: Array<string> | null;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/** An email thread. Any mail provider implements this. */
|
|
91
|
+
export type EmailThreadLike = {
|
|
92
|
+
id: string;
|
|
93
|
+
subject: string;
|
|
94
|
+
participants: Array<string>;
|
|
95
|
+
messageCount: number;
|
|
96
|
+
/** ISO 8601 */
|
|
97
|
+
lastMessageAt: string;
|
|
98
|
+
hasUnread: boolean;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** A calendar event. Any calendar provider (Google, Outlook, iCal, etc.) implements this. */
|
|
102
|
+
export type CalendarEventLike = LinkLike &
|
|
103
|
+
TimestampLike & {
|
|
104
|
+
eventId: string;
|
|
105
|
+
summary: string;
|
|
106
|
+
description: string | null;
|
|
107
|
+
location: string | null;
|
|
108
|
+
/** ISO 8601 */
|
|
109
|
+
startTime: string;
|
|
110
|
+
/** ISO 8601 */
|
|
111
|
+
endTime: string | null;
|
|
112
|
+
isAllDay: boolean | null;
|
|
113
|
+
isRecurring: boolean | null;
|
|
114
|
+
attendees: Array<Actor> | null;
|
|
115
|
+
calendarId: string;
|
|
116
|
+
accountId: string;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// ============================================================
|
|
120
|
+
// Core types
|
|
121
|
+
// ============================================================
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* An actor who performed an action.
|
|
125
|
+
*
|
|
126
|
+
* `id` / `displayName` / `email` are the Notion-resolved identity.
|
|
127
|
+
* `vendorActor` carries the identity in the originating system.
|
|
128
|
+
*/
|
|
129
|
+
export type Actor = {
|
|
130
|
+
/** Notion user ID (when resolved). */
|
|
131
|
+
id: string | null;
|
|
132
|
+
displayName: string | null;
|
|
133
|
+
email: string | null;
|
|
134
|
+
/** The actor's identity in the vendor system. */
|
|
135
|
+
vendorActor: VendorActor | null;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** Vendor-specific actor identity. */
|
|
139
|
+
export type VendorActor = {
|
|
140
|
+
/** Vendor name: "slack", "gmail", "discord", "notion", etc. */
|
|
141
|
+
vendor: string;
|
|
142
|
+
/** Vendor-specific ID. */
|
|
143
|
+
id: string;
|
|
144
|
+
displayName: string | null;
|
|
145
|
+
/** Handle / username (e.g., Slack @handle). */
|
|
146
|
+
handle: string | null;
|
|
147
|
+
/** "user", "bot", or a vendor-specific string. */
|
|
148
|
+
type: "user" | "bot" | string | null;
|
|
149
|
+
/** URL to the actor's profile in the vendor system. */
|
|
150
|
+
url: string | null;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// ============================================================
|
|
154
|
+
// Thread message
|
|
155
|
+
// ============================================================
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A single message inside a thread.
|
|
159
|
+
* Implements MessageLike, ActorLike, LinkLike, TimestampLike.
|
|
160
|
+
* Vendor-specific fields use `x-<vendor>-` prefix.
|
|
161
|
+
*/
|
|
162
|
+
export type ThreadMessage = MessageLike &
|
|
163
|
+
ActorLike &
|
|
164
|
+
LinkLike &
|
|
165
|
+
TimestampLike &
|
|
166
|
+
VendorExtensions & {
|
|
167
|
+
id: string;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/** A chat thread message. Extends ChatMessageLike with VendorExtensions. */
|
|
171
|
+
export type ChatThreadMessage = ChatMessageLike & VendorExtensions;
|
|
172
|
+
|
|
173
|
+
/** An email message in a trigger. Extends EmailMessageLike with VendorExtensions. */
|
|
174
|
+
export type EmailTriggerMessage = EmailMessageLike & VendorExtensions;
|
|
175
|
+
|
|
176
|
+
// ============================================================
|
|
177
|
+
// Trigger event base
|
|
178
|
+
// ============================================================
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Every trigger event has at least these fields.
|
|
182
|
+
* `message` is a human-readable summary of what happened.
|
|
183
|
+
*/
|
|
184
|
+
export type TriggerEventBase = MessageLike &
|
|
185
|
+
ActorLike &
|
|
186
|
+
VendorExtensions & {
|
|
187
|
+
type: string;
|
|
188
|
+
vendor: string;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Base shape for chat trigger events (Slack, Discord, MS Teams, etc.).
|
|
193
|
+
* Parameterized on the message type so each platform can narrow
|
|
194
|
+
* `triggerMessage` and `thread` to its vendor-specific message shape.
|
|
195
|
+
*/
|
|
196
|
+
type ChatEventBase<M extends ChatThreadMessage = ChatThreadMessage> = TriggerEventBase &
|
|
197
|
+
LinkLike &
|
|
198
|
+
TimestampLike &
|
|
199
|
+
ThreadLike<M> & {
|
|
200
|
+
/** The message that fired the trigger. */
|
|
201
|
+
triggerMessage: M;
|
|
202
|
+
channelId: string;
|
|
203
|
+
channelName: string | null;
|
|
204
|
+
threadId: string | null;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// ============================================================
|
|
208
|
+
// Slack
|
|
209
|
+
// ============================================================
|
|
210
|
+
|
|
211
|
+
export type SlackChatThreadMessage = ChatThreadMessage & {
|
|
212
|
+
"x-slack-fileUrls": Array<string> | null;
|
|
213
|
+
/** URLs extracted from the message text. */
|
|
214
|
+
"x-slack-urls": Array<string> | null;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export type SlackMessageEvent = ChatEventBase<SlackChatThreadMessage> & {
|
|
218
|
+
type: "slack.message";
|
|
219
|
+
vendor: "slack";
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export type SlackReactionAddedEvent = ChatEventBase<SlackChatThreadMessage> & {
|
|
223
|
+
type: "slack.reaction.added";
|
|
224
|
+
vendor: "slack";
|
|
225
|
+
/** The emoji name (without colons), e.g. "thumbsup". */
|
|
226
|
+
"x-slack-reaction": string | null;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type SlackAppMentionEvent = ChatEventBase<SlackChatThreadMessage> & {
|
|
230
|
+
type: "slack.app.mention";
|
|
231
|
+
vendor: "slack";
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// ============================================================
|
|
235
|
+
// Mail
|
|
236
|
+
// ============================================================
|
|
237
|
+
|
|
238
|
+
/** Base shape for all mail trigger events. */
|
|
239
|
+
type MailEventBase = TriggerEventBase &
|
|
240
|
+
LinkLike &
|
|
241
|
+
TimestampLike & {
|
|
242
|
+
vendor: "notionmail" | "gmail" | string;
|
|
243
|
+
/** The triggering email. */
|
|
244
|
+
email: EmailTriggerMessage;
|
|
245
|
+
/** The email thread this message belongs to. */
|
|
246
|
+
emailThread: EmailThreadLike;
|
|
247
|
+
/** The email address of the mailbox owner. */
|
|
248
|
+
userEmail: string;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export type MailEmailReceivedEvent = MailEventBase & {
|
|
252
|
+
type: "mail.email.received";
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
export type MailEmailSentEvent = MailEventBase & {
|
|
256
|
+
type: "mail.email.sent";
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export type MailLabelAppliedEvent = MailEventBase & {
|
|
260
|
+
type: "mail.label.applied";
|
|
261
|
+
/** The label that was applied. */
|
|
262
|
+
appliedLabel: string;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// ============================================================
|
|
266
|
+
// Calendar
|
|
267
|
+
// ============================================================
|
|
268
|
+
|
|
269
|
+
/** Base shape for all calendar trigger events. */
|
|
270
|
+
type CalendarEventBase = TriggerEventBase &
|
|
271
|
+
CalendarEventLike & {
|
|
272
|
+
vendor: "notion-calendar" | "google" | string;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export type CalendarEventCreatedEvent = CalendarEventBase & {
|
|
276
|
+
type: "calendar.event.created";
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export type CalendarEventUpdatedEvent = CalendarEventBase & {
|
|
280
|
+
type: "calendar.event.updated";
|
|
281
|
+
/** Which fields changed. */
|
|
282
|
+
updatedFields: Array<string> | null;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
export type CalendarEventCanceledEvent = CalendarEventBase & {
|
|
286
|
+
type: "calendar.event.canceled";
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// ============================================================
|
|
290
|
+
// Discord
|
|
291
|
+
// ============================================================
|
|
292
|
+
|
|
293
|
+
export type DiscordChatThreadMessage = ChatThreadMessage & {
|
|
294
|
+
"x-discord-guildId": string | null;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export type DiscordInteractionEvent = ChatEventBase<DiscordChatThreadMessage> & {
|
|
298
|
+
type: "discord.interaction";
|
|
299
|
+
vendor: "discord";
|
|
300
|
+
"x-discord-guildId": string | null;
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// ============================================================
|
|
304
|
+
// Notion — Page / Database triggers
|
|
305
|
+
// ============================================================
|
|
306
|
+
|
|
307
|
+
/** A property edit with before/after snapshots. */
|
|
308
|
+
export type NotionPageEdit = {
|
|
309
|
+
before: Record<string, unknown> | null;
|
|
310
|
+
after: Record<string, unknown> | null;
|
|
311
|
+
afterContent: string | null;
|
|
312
|
+
contentChanged: boolean | null;
|
|
313
|
+
timestamp: number;
|
|
314
|
+
editedBy: Actor | null;
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export type NotionPageCreatedEvent = TriggerEventBase &
|
|
318
|
+
LinkLike &
|
|
319
|
+
TimestampLike & {
|
|
320
|
+
type: "notion.page.created";
|
|
321
|
+
vendor: "notion";
|
|
322
|
+
/** Page properties as key-value pairs. */
|
|
323
|
+
page: Record<string, unknown>;
|
|
324
|
+
/** Rendered markdown content of the page. */
|
|
325
|
+
content: string;
|
|
326
|
+
edits: Array<NotionPageEdit> | null;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export type NotionPageUpdatedEvent = TriggerEventBase &
|
|
330
|
+
LinkLike &
|
|
331
|
+
TimestampLike & {
|
|
332
|
+
type: "notion.page.updated";
|
|
333
|
+
vendor: "notion";
|
|
334
|
+
/** Chronological array of edits (accumulated during debounce). */
|
|
335
|
+
edits: Array<NotionPageEdit>;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
export type NotionPageDeletedEvent = TriggerEventBase &
|
|
339
|
+
LinkLike &
|
|
340
|
+
TimestampLike & {
|
|
341
|
+
type: "notion.page.deleted";
|
|
342
|
+
vendor: "notion";
|
|
343
|
+
page: Record<string, unknown>;
|
|
344
|
+
content: string;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export type NotionMeetingNoteSummaryCompletedEvent = TriggerEventBase &
|
|
348
|
+
LinkLike &
|
|
349
|
+
TimestampLike & {
|
|
350
|
+
type: "notion.meetingNote.summary.completed";
|
|
351
|
+
vendor: "notion";
|
|
352
|
+
page: Record<string, unknown>;
|
|
353
|
+
content: string;
|
|
354
|
+
meetingNoteBlockId: string;
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
// ============================================================
|
|
358
|
+
// Notion — Discussion / Comment triggers
|
|
359
|
+
// ============================================================
|
|
360
|
+
|
|
361
|
+
export type NotionCommentAddedEvent = TriggerEventBase &
|
|
362
|
+
LinkLike &
|
|
363
|
+
TimestampLike & {
|
|
364
|
+
type: "notion.page.discussion.comment.added";
|
|
365
|
+
vendor: "notion";
|
|
366
|
+
/** The full discussion context. */
|
|
367
|
+
discussion: {
|
|
368
|
+
id: string;
|
|
369
|
+
pageId: string;
|
|
370
|
+
resolved: boolean;
|
|
371
|
+
context: "inline" | "block" | "page" | "databaseProperty" | null;
|
|
372
|
+
parentBlockId: string | null;
|
|
373
|
+
propertyId: string | null;
|
|
374
|
+
propertyName: string | null;
|
|
375
|
+
};
|
|
376
|
+
/** The new comment. */
|
|
377
|
+
comment: {
|
|
378
|
+
id: string;
|
|
379
|
+
text: string;
|
|
380
|
+
url: string;
|
|
381
|
+
timestamp: string;
|
|
382
|
+
actor: Actor | null;
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
// ============================================================
|
|
387
|
+
// Notion — Agent / Button triggers
|
|
388
|
+
// ============================================================
|
|
389
|
+
|
|
390
|
+
export type NotionAgentMentionedEvent = TriggerEventBase &
|
|
391
|
+
LinkLike &
|
|
392
|
+
TimestampLike & {
|
|
393
|
+
type: "notion.agent.mentioned";
|
|
394
|
+
vendor: "notion";
|
|
395
|
+
page: Record<string, unknown>;
|
|
396
|
+
content: string;
|
|
397
|
+
mentionLocation: "page_content" | "person_property";
|
|
398
|
+
mentionBlockContent: string | null;
|
|
399
|
+
propertyId: string | null;
|
|
400
|
+
propertyName: string | null;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
export type NotionButtonPressedEvent = TriggerEventBase &
|
|
404
|
+
LinkLike &
|
|
405
|
+
TimestampLike & {
|
|
406
|
+
type: "notion.button.pressed";
|
|
407
|
+
vendor: "notion";
|
|
408
|
+
blockUrl: string;
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
export type NotionDatabaseAgentUpdatedEvent = TriggerEventBase &
|
|
412
|
+
TimestampLike & {
|
|
413
|
+
type: "notion.database.agent.updated";
|
|
414
|
+
vendor: "notion";
|
|
415
|
+
agentId: string;
|
|
416
|
+
runtimeInstructions: string;
|
|
417
|
+
shouldRunOverDatabase: boolean;
|
|
418
|
+
viewId: string | null;
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
export type WebhookEvent = TriggerEventBase &
|
|
422
|
+
TimestampLike & {
|
|
423
|
+
type: "webhooks.webhook";
|
|
424
|
+
vendor: "webhooks";
|
|
425
|
+
triggerId: string;
|
|
426
|
+
verificationSchema: string;
|
|
427
|
+
eventType: string | null;
|
|
428
|
+
deliveryId: string | null;
|
|
429
|
+
payload: unknown;
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
// ============================================================
|
|
433
|
+
// Google Drive OAuth — File changed (polling) trigger
|
|
434
|
+
// ============================================================
|
|
435
|
+
|
|
436
|
+
export type GoogleDriveOauthFilesChangedEvent = TriggerEventBase &
|
|
437
|
+
TimestampLike & {
|
|
438
|
+
type: "googleDriveOauth.filesChanged";
|
|
439
|
+
vendor: "google-drive";
|
|
440
|
+
/** The page token from before this poll. */
|
|
441
|
+
changeToken: string;
|
|
442
|
+
/** The page token after this poll. */
|
|
443
|
+
newChangeToken: string;
|
|
444
|
+
/** Number of changes detected. */
|
|
445
|
+
changeCount: number;
|
|
446
|
+
/** The folder or drive being watched. */
|
|
447
|
+
scope: { type: "folder"; folderId: string } | { type: "drive"; driveId: string };
|
|
448
|
+
/** Upper time bound for this poll window (ISO 8601). */
|
|
449
|
+
lastEventTimestamp: string;
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// ============================================================
|
|
453
|
+
// Recurrence (scheduled) trigger
|
|
454
|
+
// ============================================================
|
|
455
|
+
|
|
456
|
+
export type RecurrenceFrequency = "hour" | "day" | "week" | "month" | "year";
|
|
457
|
+
|
|
458
|
+
export type RecurrenceEvent = TriggerEventBase &
|
|
459
|
+
TimestampLike & {
|
|
460
|
+
type: "recurrence";
|
|
461
|
+
vendor: "notion";
|
|
462
|
+
frequency: RecurrenceFrequency;
|
|
463
|
+
interval: number;
|
|
464
|
+
timezone: string;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// ============================================================
|
|
468
|
+
// Derived union types
|
|
469
|
+
// ============================================================
|
|
470
|
+
|
|
471
|
+
/** Map from trigger type string to its event shape. Single source of truth. */
|
|
472
|
+
export type TriggerEventMap = {
|
|
473
|
+
"slack.message": SlackMessageEvent;
|
|
474
|
+
"slack.reaction.added": SlackReactionAddedEvent;
|
|
475
|
+
"slack.app.mention": SlackAppMentionEvent;
|
|
476
|
+
"discord.interaction": DiscordInteractionEvent;
|
|
477
|
+
"mail.email.received": MailEmailReceivedEvent;
|
|
478
|
+
"mail.email.sent": MailEmailSentEvent;
|
|
479
|
+
"mail.label.applied": MailLabelAppliedEvent;
|
|
480
|
+
"calendar.event.created": CalendarEventCreatedEvent;
|
|
481
|
+
"calendar.event.updated": CalendarEventUpdatedEvent;
|
|
482
|
+
"calendar.event.canceled": CalendarEventCanceledEvent;
|
|
483
|
+
"notion.page.created": NotionPageCreatedEvent;
|
|
484
|
+
"notion.page.updated": NotionPageUpdatedEvent;
|
|
485
|
+
"notion.page.deleted": NotionPageDeletedEvent;
|
|
486
|
+
"notion.meetingNote.summary.completed": NotionMeetingNoteSummaryCompletedEvent;
|
|
487
|
+
"notion.page.discussion.comment.added": NotionCommentAddedEvent;
|
|
488
|
+
"notion.agent.mentioned": NotionAgentMentionedEvent;
|
|
489
|
+
"notion.button.pressed": NotionButtonPressedEvent;
|
|
490
|
+
"notion.database.agent.updated": NotionDatabaseAgentUpdatedEvent;
|
|
491
|
+
"webhooks.webhook": WebhookEvent;
|
|
492
|
+
"googleDriveOauth.filesChanged": GoogleDriveOauthFilesChangedEvent;
|
|
493
|
+
recurrence: RecurrenceEvent;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
/** All trigger type strings. Derived from TriggerEventMap. */
|
|
497
|
+
export type TriggerType = keyof TriggerEventMap;
|
|
498
|
+
|
|
499
|
+
/** Discriminated union of all trigger events. Derived from TriggerEventMap. */
|
|
500
|
+
export type TriggerEvent = TriggerEventMap[TriggerType];
|