@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,239 @@
|
|
|
1
|
+
const triggers = {
|
|
2
|
+
/**
|
|
3
|
+
* Declare that a workflow can run on `slack.message` events.
|
|
4
|
+
*
|
|
5
|
+
* A message was posted in a subscribed Slack channel.
|
|
6
|
+
*/
|
|
7
|
+
slackMessage() {
|
|
8
|
+
return {
|
|
9
|
+
type: "slack.message"
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* Declare that a workflow can run on `slack.reaction.added` events.
|
|
14
|
+
*
|
|
15
|
+
* A reaction was added to a Slack message.
|
|
16
|
+
*/
|
|
17
|
+
slackReactionAdded() {
|
|
18
|
+
return {
|
|
19
|
+
type: "slack.reaction.added"
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Declare that a workflow can run on `slack.app.mention` events.
|
|
24
|
+
*
|
|
25
|
+
* The Notion app was mentioned in a Slack message.
|
|
26
|
+
*/
|
|
27
|
+
slackAppMention() {
|
|
28
|
+
return {
|
|
29
|
+
type: "slack.app.mention"
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Declare that a workflow can run on `discord.interaction` events.
|
|
34
|
+
*
|
|
35
|
+
* A Discord interaction was received.
|
|
36
|
+
*/
|
|
37
|
+
discordInteraction() {
|
|
38
|
+
return {
|
|
39
|
+
type: "discord.interaction"
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Declare that a workflow can run on `mail.email.received` events.
|
|
44
|
+
*
|
|
45
|
+
* An email was received.
|
|
46
|
+
*/
|
|
47
|
+
mailEmailReceived() {
|
|
48
|
+
return {
|
|
49
|
+
type: "mail.email.received"
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
/**
|
|
53
|
+
* Declare that a workflow can run on `mail.email.sent` events.
|
|
54
|
+
*
|
|
55
|
+
* An email was sent.
|
|
56
|
+
*/
|
|
57
|
+
mailEmailSent() {
|
|
58
|
+
return {
|
|
59
|
+
type: "mail.email.sent"
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
/**
|
|
63
|
+
* Declare that a workflow can run on `mail.label.applied` events.
|
|
64
|
+
*
|
|
65
|
+
* A label was applied to an email.
|
|
66
|
+
*/
|
|
67
|
+
mailLabelApplied() {
|
|
68
|
+
return {
|
|
69
|
+
type: "mail.label.applied"
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Declare that a workflow can run on `calendar.event.created` events.
|
|
74
|
+
*
|
|
75
|
+
* A calendar event was created.
|
|
76
|
+
*/
|
|
77
|
+
calendarEventCreated() {
|
|
78
|
+
return {
|
|
79
|
+
type: "calendar.event.created"
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Declare that a workflow can run on `calendar.event.updated` events.
|
|
84
|
+
*
|
|
85
|
+
* A calendar event was updated.
|
|
86
|
+
*/
|
|
87
|
+
calendarEventUpdated() {
|
|
88
|
+
return {
|
|
89
|
+
type: "calendar.event.updated"
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
/**
|
|
93
|
+
* Declare that a workflow can run on `calendar.event.canceled` events.
|
|
94
|
+
*
|
|
95
|
+
* A calendar event was canceled.
|
|
96
|
+
*/
|
|
97
|
+
calendarEventCanceled() {
|
|
98
|
+
return {
|
|
99
|
+
type: "calendar.event.canceled"
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Declare that a workflow can run on `notion.page.created` events.
|
|
104
|
+
*
|
|
105
|
+
* A page has been added to a database.
|
|
106
|
+
*/
|
|
107
|
+
notionPageCreated() {
|
|
108
|
+
return {
|
|
109
|
+
type: "notion.page.created"
|
|
110
|
+
};
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Declare that a workflow can run on `notion.page.updated` events.
|
|
114
|
+
*
|
|
115
|
+
* A page was updated.
|
|
116
|
+
*/
|
|
117
|
+
notionPageUpdated() {
|
|
118
|
+
return {
|
|
119
|
+
type: "notion.page.updated"
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
/**
|
|
123
|
+
* Declare that a workflow can run on `notion.page.deleted` events.
|
|
124
|
+
*
|
|
125
|
+
* A page was deleted.
|
|
126
|
+
*/
|
|
127
|
+
notionPageDeleted() {
|
|
128
|
+
return {
|
|
129
|
+
type: "notion.page.deleted"
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
/**
|
|
133
|
+
* Declare that a workflow can run on `notion.meetingNote.summary.completed` events.
|
|
134
|
+
*
|
|
135
|
+
* A meeting note's AI summary finished generating.
|
|
136
|
+
*/
|
|
137
|
+
notionMeetingNoteSummaryCompleted() {
|
|
138
|
+
return {
|
|
139
|
+
type: "notion.meetingNote.summary.completed"
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
/**
|
|
143
|
+
* Declare that a workflow can run on `notion.page.discussion.comment.added` events.
|
|
144
|
+
*
|
|
145
|
+
* A comment was added to a page discussion.
|
|
146
|
+
*/
|
|
147
|
+
notionCommentAdded() {
|
|
148
|
+
return {
|
|
149
|
+
type: "notion.page.discussion.comment.added"
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
/**
|
|
153
|
+
* Declare that a workflow can run on `notion.agent.mentioned` events.
|
|
154
|
+
*
|
|
155
|
+
* An agent was mentioned in page content or a person property.
|
|
156
|
+
*/
|
|
157
|
+
notionAgentMentioned() {
|
|
158
|
+
return {
|
|
159
|
+
type: "notion.agent.mentioned"
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* Declare that a workflow can run on `notion.button.pressed` events.
|
|
164
|
+
*
|
|
165
|
+
* A button block was pressed.
|
|
166
|
+
*/
|
|
167
|
+
notionButtonPressed() {
|
|
168
|
+
return {
|
|
169
|
+
type: "notion.button.pressed"
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
* Declare that a workflow can run on `notion.database.agent.updated` events.
|
|
174
|
+
*
|
|
175
|
+
* A database agent's configuration was updated.
|
|
176
|
+
*/
|
|
177
|
+
notionDatabaseAgentUpdated() {
|
|
178
|
+
return {
|
|
179
|
+
type: "notion.database.agent.updated"
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
/**
|
|
183
|
+
* Declare that a workflow can run on `webhooks.webhook` events.
|
|
184
|
+
*
|
|
185
|
+
* An incoming webhook request was received.
|
|
186
|
+
*/
|
|
187
|
+
webhook() {
|
|
188
|
+
return {
|
|
189
|
+
type: "webhooks.webhook"
|
|
190
|
+
};
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Declare that a workflow can run on `googleDriveOauth.filesChanged` events.
|
|
194
|
+
*
|
|
195
|
+
* Files changed in a watched Google Drive folder or drive.
|
|
196
|
+
*/
|
|
197
|
+
googleDriveOauthFilesChanged() {
|
|
198
|
+
return {
|
|
199
|
+
type: "googleDriveOauth.filesChanged"
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
/**
|
|
203
|
+
* Declare that a workflow can run on `recurrence` events.
|
|
204
|
+
*
|
|
205
|
+
* A recurring schedule fired.
|
|
206
|
+
*/
|
|
207
|
+
recurrence() {
|
|
208
|
+
return {
|
|
209
|
+
type: "recurrence"
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const WORKFLOW_TRIGGER_TYPES = [
|
|
214
|
+
"slack.message",
|
|
215
|
+
"slack.reaction.added",
|
|
216
|
+
"slack.app.mention",
|
|
217
|
+
"discord.interaction",
|
|
218
|
+
"mail.email.received",
|
|
219
|
+
"mail.email.sent",
|
|
220
|
+
"mail.label.applied",
|
|
221
|
+
"calendar.event.created",
|
|
222
|
+
"calendar.event.updated",
|
|
223
|
+
"calendar.event.canceled",
|
|
224
|
+
"notion.page.created",
|
|
225
|
+
"notion.page.updated",
|
|
226
|
+
"notion.page.deleted",
|
|
227
|
+
"notion.meetingNote.summary.completed",
|
|
228
|
+
"notion.page.discussion.comment.added",
|
|
229
|
+
"notion.agent.mentioned",
|
|
230
|
+
"notion.button.pressed",
|
|
231
|
+
"notion.database.agent.updated",
|
|
232
|
+
"webhooks.webhook",
|
|
233
|
+
"googleDriveOauth.filesChanged",
|
|
234
|
+
"recurrence"
|
|
235
|
+
];
|
|
236
|
+
export {
|
|
237
|
+
WORKFLOW_TRIGGER_TYPES,
|
|
238
|
+
triggers
|
|
239
|
+
};
|
package/dist/triggers.js
ADDED
|
File without changes
|
package/dist/types.d.ts
CHANGED
|
@@ -122,6 +122,24 @@ export interface ImageIcon {
|
|
|
122
122
|
* All possible icon types
|
|
123
123
|
*/
|
|
124
124
|
export type Icon = EmojiIcon | NoticonIcon | ImageIcon;
|
|
125
|
+
/**
|
|
126
|
+
* Cover image for a Notion page.
|
|
127
|
+
*/
|
|
128
|
+
export interface ImageCover {
|
|
129
|
+
type: "image";
|
|
130
|
+
/**
|
|
131
|
+
* The URL of the image (must be a valid http/https URL)
|
|
132
|
+
*/
|
|
133
|
+
url: string;
|
|
134
|
+
/**
|
|
135
|
+
* Vertical image position, from 0 (top) to 1 (bottom).
|
|
136
|
+
*/
|
|
137
|
+
position?: number;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* All possible cover types
|
|
141
|
+
*/
|
|
142
|
+
export type Cover = ImageCover;
|
|
125
143
|
/**
|
|
126
144
|
* Person reference - represents a user in a people property
|
|
127
145
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,GAClB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEhC;;;GAGG;AACH,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AAExC;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,WAAW,GACpB,SAAS,GACT,MAAM,GACN,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,KAAK,CAAC;AAET;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACpB;A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AAM,MAAM,cAAc,GAAG;IAC5B,cAAc,CAAC,EAAE,IAAI,CAAC;CACtB,CAAC"}
|
package/dist/worker.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import type { AiConnectorArchetype, AiConnectorCapability, AiConnectorConfiguration } from "./capabilities/ai_connector.js";
|
|
2
2
|
import type { AutomationCapability, AutomationConfiguration, AutomationEvent } from "./capabilities/automation.js";
|
|
3
3
|
import type { CapabilityContext } from "./capabilities/context.js";
|
|
4
|
+
import type { CustomBlockCapability, CustomBlockConfiguration } from "./capabilities/custom-block.js";
|
|
4
5
|
import type { NotionManagedOAuthConfiguration, OAuthCapability, OAuthConfiguration, UserManagedOAuthConfiguration } from "./capabilities/oauth.js";
|
|
5
6
|
import type { SyncCapability, SyncConfiguration } from "./capabilities/sync.js";
|
|
6
7
|
import type { ToolCapability, ToolConfiguration } from "./capabilities/tool.js";
|
|
7
8
|
import type { WebhookCapability, WebhookConfiguration, WebhookEvent } from "./capabilities/webhook.js";
|
|
8
9
|
import { WebhookVerificationError } from "./capabilities/webhook.js";
|
|
10
|
+
import type { WorkflowCapability, WorkflowConfiguration, WorkflowEvent } from "./capabilities/workflow.js";
|
|
9
11
|
import type { PacerDeclaration } from "./pacer_internal.js";
|
|
10
12
|
import type { Schema } from "./schema.js";
|
|
13
|
+
import type { WorkflowTrigger } from "./triggers.generated.js";
|
|
11
14
|
import type { HandlerOptions, JSONValue } from "./types.js";
|
|
12
|
-
export type { AutomationConfiguration, AutomationEvent,
|
|
15
|
+
export type { AiConnectorConfiguration, AutomationConfiguration, AutomationEvent, CapabilityContext, NotionManagedOAuthConfiguration, OAuthConfiguration, SyncConfiguration, ToolConfiguration, UserManagedOAuthConfiguration, WebhookConfiguration, WebhookEvent, WorkflowConfiguration, WorkflowEvent, };
|
|
13
16
|
export { WebhookVerificationError };
|
|
14
|
-
type Capability = SyncCapability | AiConnectorCapability | ToolCapability<any, any> | AutomationCapability | OAuthCapability | WebhookCapability;
|
|
17
|
+
type Capability = SyncCapability | AiConnectorCapability | ToolCapability<any, any> | AutomationCapability | WorkflowCapability | OAuthCapability | WebhookCapability | CustomBlockCapability;
|
|
15
18
|
export type CapabilityType = Capability["_tag"];
|
|
16
19
|
/**
|
|
17
20
|
* Configuration for a database that Notion creates and manages on behalf
|
|
@@ -299,6 +302,34 @@ export declare class Worker {
|
|
|
299
302
|
* @returns The capability object.
|
|
300
303
|
*/
|
|
301
304
|
automation(key: string, config: AutomationConfiguration): AutomationCapability;
|
|
305
|
+
/**
|
|
306
|
+
* Register a workflow capability.
|
|
307
|
+
*
|
|
308
|
+
* Example:
|
|
309
|
+
*
|
|
310
|
+
* ```ts
|
|
311
|
+
* import { Worker } from "@notionhq/workers";
|
|
312
|
+
* import { triggers } from "@notionhq/workers/triggers";
|
|
313
|
+
*
|
|
314
|
+
* const worker = new Worker();
|
|
315
|
+
* export default worker;
|
|
316
|
+
*
|
|
317
|
+
* worker.workflow("sendWelcomeEmail", {
|
|
318
|
+
* title: "Send Welcome Email",
|
|
319
|
+
* description: "Sends a welcome email when a new user is added",
|
|
320
|
+
* triggers: [triggers.notionPageCreated()],
|
|
321
|
+
* execute: async (event) => {
|
|
322
|
+
* console.log(event.page);
|
|
323
|
+
* console.log(event.content);
|
|
324
|
+
* },
|
|
325
|
+
* })
|
|
326
|
+
* ```
|
|
327
|
+
*
|
|
328
|
+
* @param key - The unique key for this capability.
|
|
329
|
+
* @param config - The workflow configuration.
|
|
330
|
+
* @returns The capability object.
|
|
331
|
+
*/
|
|
332
|
+
workflow<const TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]]>(key: string, config: WorkflowConfiguration<TTriggers>): WorkflowCapability<TTriggers>;
|
|
302
333
|
/**
|
|
303
334
|
* Register a webhook capability.
|
|
304
335
|
*
|
|
@@ -370,6 +401,45 @@ export declare class Worker {
|
|
|
370
401
|
* @returns The registered OAuth capability.
|
|
371
402
|
*/
|
|
372
403
|
oauth(key: string, config: OAuthConfiguration): OAuthCapability;
|
|
404
|
+
/**
|
|
405
|
+
* Register a custom block capability.
|
|
406
|
+
*
|
|
407
|
+
* A custom block is a front-end view that the deploy pipeline builds from
|
|
408
|
+
* the source entry into a deployable bundle. It can optionally declare a
|
|
409
|
+
* data-source *schema* (`name`, and optional `description`, `icon`, and
|
|
410
|
+
* `properties`) that the block reads.
|
|
411
|
+
*
|
|
412
|
+
* Example:
|
|
413
|
+
*
|
|
414
|
+
* ```ts
|
|
415
|
+
* const worker = new Worker();
|
|
416
|
+
* export default worker;
|
|
417
|
+
*
|
|
418
|
+
* worker.customBlock("issueBoard", {
|
|
419
|
+
* version: 1,
|
|
420
|
+
* path: "./views/issueBoard",
|
|
421
|
+
* dataSources: {
|
|
422
|
+
* issues: {
|
|
423
|
+
* name: "Issues",
|
|
424
|
+
* properties: {
|
|
425
|
+
* title: { name: "Title", type: "title" },
|
|
426
|
+
* status: { name: "Status", type: "status" },
|
|
427
|
+
* },
|
|
428
|
+
* },
|
|
429
|
+
* },
|
|
430
|
+
* });
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* The manifest keys (`version`, `dataSources`) are top-level on the config;
|
|
434
|
+
* the SDK assembles the deploy-wire `CustomBlockManifest` from them. Binding
|
|
435
|
+
* each declared data source to a concrete managed database is instance-level
|
|
436
|
+
* and handled at deploy time — the worker does not emit bindings.
|
|
437
|
+
*
|
|
438
|
+
* @param key - The unique key for this block (the block declaration key).
|
|
439
|
+
* @param config - The custom block configuration (a `project`/`static` source folder + optional `version`/`dataSources` schema).
|
|
440
|
+
* @returns The custom block capability.
|
|
441
|
+
*/
|
|
442
|
+
customBlock(key: string, config: CustomBlockConfiguration): CustomBlockCapability;
|
|
373
443
|
/**
|
|
374
444
|
* Get all registered capabilities (for discovery) without their handlers.
|
|
375
445
|
*/
|
package/dist/worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],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9E;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,QAAQ,CAAC,KAAK,CAAC,SAAS,SAAS,SAAS,CAAC,eAAe,EAAE,GAAG,eAAe,EAAE,CAAC,EAChF,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,CAAC,SAAS,CAAC,GACtC,kBAAkB,CAAC,SAAS,CAAC;IAOhC;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,iBAAiB;IAOrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,eAAe;IAO/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,wBAAwB,GAAG,qBAAqB;IAOjF;;OAEG;IACH,IAAI,YAAY,IAAI,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC,EAAE,CAMhE;IAED,IAAI,QAAQ,IAAI,cAAc,CAO7B;IAED;;;;;;;OAOG;IACG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;CAsCxF"}
|
package/dist/worker.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { createAiConnectorCapability } from "./capabilities/ai_connector.js";
|
|
2
2
|
import { createAutomationCapability } from "./capabilities/automation.js";
|
|
3
|
+
import { createCustomBlockCapability } from "./capabilities/custom-block.js";
|
|
3
4
|
import { createOAuthCapability } from "./capabilities/oauth.js";
|
|
4
5
|
import { createSyncCapability } from "./capabilities/sync.js";
|
|
5
6
|
import { createToolCapability } from "./capabilities/tool.js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
WebhookVerificationError
|
|
9
|
-
} from "./capabilities/webhook.js";
|
|
7
|
+
import { createWebhookCapability, WebhookVerificationError } from "./capabilities/webhook.js";
|
|
8
|
+
import { createWorkflowCapability } from "./capabilities/workflow.js";
|
|
10
9
|
import { pacerWait } from "./pacer_internal.js";
|
|
11
10
|
import { createRequire } from "node:module";
|
|
12
11
|
const SDK_VERSION = (() => {
|
|
@@ -253,6 +252,39 @@ class Worker {
|
|
|
253
252
|
this.#capabilities.set(key, capability);
|
|
254
253
|
return capability;
|
|
255
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Register a workflow capability.
|
|
257
|
+
*
|
|
258
|
+
* Example:
|
|
259
|
+
*
|
|
260
|
+
* ```ts
|
|
261
|
+
* import { Worker } from "@notionhq/workers";
|
|
262
|
+
* import { triggers } from "@notionhq/workers/triggers";
|
|
263
|
+
*
|
|
264
|
+
* const worker = new Worker();
|
|
265
|
+
* export default worker;
|
|
266
|
+
*
|
|
267
|
+
* worker.workflow("sendWelcomeEmail", {
|
|
268
|
+
* title: "Send Welcome Email",
|
|
269
|
+
* description: "Sends a welcome email when a new user is added",
|
|
270
|
+
* triggers: [triggers.notionPageCreated()],
|
|
271
|
+
* execute: async (event) => {
|
|
272
|
+
* console.log(event.page);
|
|
273
|
+
* console.log(event.content);
|
|
274
|
+
* },
|
|
275
|
+
* })
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @param key - The unique key for this capability.
|
|
279
|
+
* @param config - The workflow configuration.
|
|
280
|
+
* @returns The capability object.
|
|
281
|
+
*/
|
|
282
|
+
workflow(key, config) {
|
|
283
|
+
this.#validateUniqueKey(key);
|
|
284
|
+
const capability = createWorkflowCapability(key, config);
|
|
285
|
+
this.#capabilities.set(key, capability);
|
|
286
|
+
return capability;
|
|
287
|
+
}
|
|
256
288
|
/**
|
|
257
289
|
* Register a webhook capability.
|
|
258
290
|
*
|
|
@@ -334,6 +366,50 @@ class Worker {
|
|
|
334
366
|
this.#capabilities.set(key, capability);
|
|
335
367
|
return capability;
|
|
336
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Register a custom block capability.
|
|
371
|
+
*
|
|
372
|
+
* A custom block is a front-end view that the deploy pipeline builds from
|
|
373
|
+
* the source entry into a deployable bundle. It can optionally declare a
|
|
374
|
+
* data-source *schema* (`name`, and optional `description`, `icon`, and
|
|
375
|
+
* `properties`) that the block reads.
|
|
376
|
+
*
|
|
377
|
+
* Example:
|
|
378
|
+
*
|
|
379
|
+
* ```ts
|
|
380
|
+
* const worker = new Worker();
|
|
381
|
+
* export default worker;
|
|
382
|
+
*
|
|
383
|
+
* worker.customBlock("issueBoard", {
|
|
384
|
+
* version: 1,
|
|
385
|
+
* path: "./views/issueBoard",
|
|
386
|
+
* dataSources: {
|
|
387
|
+
* issues: {
|
|
388
|
+
* name: "Issues",
|
|
389
|
+
* properties: {
|
|
390
|
+
* title: { name: "Title", type: "title" },
|
|
391
|
+
* status: { name: "Status", type: "status" },
|
|
392
|
+
* },
|
|
393
|
+
* },
|
|
394
|
+
* },
|
|
395
|
+
* });
|
|
396
|
+
* ```
|
|
397
|
+
*
|
|
398
|
+
* The manifest keys (`version`, `dataSources`) are top-level on the config;
|
|
399
|
+
* the SDK assembles the deploy-wire `CustomBlockManifest` from them. Binding
|
|
400
|
+
* each declared data source to a concrete managed database is instance-level
|
|
401
|
+
* and handled at deploy time — the worker does not emit bindings.
|
|
402
|
+
*
|
|
403
|
+
* @param key - The unique key for this block (the block declaration key).
|
|
404
|
+
* @param config - The custom block configuration (a `project`/`static` source folder + optional `version`/`dataSources` schema).
|
|
405
|
+
* @returns The custom block capability.
|
|
406
|
+
*/
|
|
407
|
+
customBlock(key, config) {
|
|
408
|
+
this.#validateUniqueKey(key);
|
|
409
|
+
const capability = createCustomBlockCapability(key, config);
|
|
410
|
+
this.#capabilities.set(key, capability);
|
|
411
|
+
return capability;
|
|
412
|
+
}
|
|
337
413
|
/**
|
|
338
414
|
* Get all registered capabilities (for discovery) without their handlers.
|
|
339
415
|
*/
|
|
@@ -370,6 +446,11 @@ class Worker {
|
|
|
370
446
|
`Cannot run OAuth capability "${key}" - OAuth capabilities only provide configuration`
|
|
371
447
|
);
|
|
372
448
|
}
|
|
449
|
+
if (capability._tag === "custom_block") {
|
|
450
|
+
throw new Error(
|
|
451
|
+
`Cannot run custom block capability "${key}" - custom blocks only provide configuration`
|
|
452
|
+
);
|
|
453
|
+
}
|
|
373
454
|
if (!capability.handler) {
|
|
374
455
|
throw new Error(`Capability "${key}" cannot be executed`);
|
|
375
456
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@notionhq/workers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "An SDK for building workers for the Notion Workers platform",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"notion-workers": "./dist/alpha/cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"src/",
|
|
12
|
+
"LICENSE.md",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
6
15
|
"type": "module",
|
|
7
16
|
"exports": {
|
|
8
17
|
".": {
|
|
@@ -29,6 +38,10 @@
|
|
|
29
38
|
"types": "./dist/schema-builder.d.ts",
|
|
30
39
|
"default": "./dist/schema-builder.js"
|
|
31
40
|
},
|
|
41
|
+
"./triggers": {
|
|
42
|
+
"types": "./dist/triggers.generated.d.ts",
|
|
43
|
+
"default": "./dist/triggers.generated.js"
|
|
44
|
+
},
|
|
32
45
|
"./types": {
|
|
33
46
|
"types": "./dist/types.d.ts",
|
|
34
47
|
"default": "./dist/types.js"
|
|
@@ -36,21 +49,67 @@
|
|
|
36
49
|
"./pacer": {
|
|
37
50
|
"types": "./dist/pacer.d.ts",
|
|
38
51
|
"default": "./dist/pacer.js"
|
|
52
|
+
},
|
|
53
|
+
"./alpha/builder": {
|
|
54
|
+
"types": "./dist/alpha/builder.d.ts",
|
|
55
|
+
"default": "./dist/alpha/builder.js"
|
|
56
|
+
},
|
|
57
|
+
"./alpha/context": {
|
|
58
|
+
"types": "./dist/alpha/context.d.ts",
|
|
59
|
+
"default": "./dist/alpha/context.js"
|
|
60
|
+
},
|
|
61
|
+
"./alpha/database": {
|
|
62
|
+
"types": "./dist/alpha/database.d.ts",
|
|
63
|
+
"default": "./dist/alpha/database.js"
|
|
64
|
+
},
|
|
65
|
+
"./alpha/error": {
|
|
66
|
+
"types": "./dist/alpha/error.d.ts",
|
|
67
|
+
"default": "./dist/alpha/error.js"
|
|
68
|
+
},
|
|
69
|
+
"./alpha/manifest": {
|
|
70
|
+
"types": "./dist/alpha/manifest.d.ts",
|
|
71
|
+
"default": "./dist/alpha/manifest.js"
|
|
72
|
+
},
|
|
73
|
+
"./alpha/pacer": {
|
|
74
|
+
"types": "./dist/alpha/pacer.d.ts",
|
|
75
|
+
"default": "./dist/alpha/pacer.js"
|
|
76
|
+
},
|
|
77
|
+
"./alpha/schedule": {
|
|
78
|
+
"types": "./dist/alpha/schedule.d.ts",
|
|
79
|
+
"default": "./dist/alpha/schedule.js"
|
|
80
|
+
},
|
|
81
|
+
"./alpha/schema": {
|
|
82
|
+
"types": "./dist/alpha/schema.d.ts",
|
|
83
|
+
"default": "./dist/alpha/schema.js"
|
|
84
|
+
},
|
|
85
|
+
"./alpha/schema-builder": {
|
|
86
|
+
"types": "./dist/alpha/schema-builder.d.ts",
|
|
87
|
+
"default": "./dist/alpha/schema-builder.js"
|
|
88
|
+
},
|
|
89
|
+
"./alpha/sync": {
|
|
90
|
+
"types": "./dist/alpha/sync.d.ts",
|
|
91
|
+
"default": "./dist/alpha/sync.js"
|
|
92
|
+
},
|
|
93
|
+
"./alpha/tool": {
|
|
94
|
+
"types": "./dist/alpha/tool.d.ts",
|
|
95
|
+
"default": "./dist/alpha/tool.js"
|
|
96
|
+
},
|
|
97
|
+
"./alpha/triggers": {
|
|
98
|
+
"types": "./dist/alpha/triggers.generated.d.ts",
|
|
99
|
+
"default": "./dist/alpha/triggers.generated.js"
|
|
100
|
+
},
|
|
101
|
+
"./alpha/types": {
|
|
102
|
+
"types": "./dist/alpha/types.d.ts",
|
|
103
|
+
"default": "./dist/alpha/types.js"
|
|
104
|
+
},
|
|
105
|
+
"./alpha/workflow": {
|
|
106
|
+
"types": "./dist/alpha/workflow.d.ts",
|
|
107
|
+
"default": "./dist/alpha/workflow.js"
|
|
39
108
|
}
|
|
40
109
|
},
|
|
41
|
-
"engines": {
|
|
42
|
-
"node": ">=22.0.0",
|
|
43
|
-
"npm": ">=10.9.2"
|
|
44
|
-
},
|
|
45
110
|
"publishConfig": {
|
|
46
111
|
"access": "public"
|
|
47
112
|
},
|
|
48
|
-
"files": [
|
|
49
|
-
"dist/",
|
|
50
|
-
"src/",
|
|
51
|
-
"LICENSE.md",
|
|
52
|
-
"README.md"
|
|
53
|
-
],
|
|
54
113
|
"scripts": {
|
|
55
114
|
"bootstrap": "mise install && mise exec -- lefthook install",
|
|
56
115
|
"build": "rm -rf dist && npm run build:types && npm run build:js",
|
|
@@ -59,8 +118,16 @@
|
|
|
59
118
|
"build:watch": "concurrently --group \"npm run build:watch:types\" \"npm run build:watch:js\"",
|
|
60
119
|
"build:watch:types": "tsc --watch",
|
|
61
120
|
"build:watch:js": "esbuild --watch --format=esm --outdir=dist --target=esnext --packages=external ./src/**.ts ./src/**/*.ts",
|
|
121
|
+
"generate": "tsx scripts/generate-triggers.ts",
|
|
122
|
+
"generate:check": "tsx scripts/generate-triggers.ts --check",
|
|
123
|
+
"sync:triggers": "tsx scripts/sync-triggers.ts",
|
|
62
124
|
"test": "vitest run"
|
|
63
125
|
},
|
|
126
|
+
"dependencies": {
|
|
127
|
+
"ajv": "^8.17.1",
|
|
128
|
+
"ajv-formats": "^3.0.1",
|
|
129
|
+
"rolldown": "^1.1.5"
|
|
130
|
+
},
|
|
64
131
|
"devDependencies": {
|
|
65
132
|
"@types/node": "^24.10.0",
|
|
66
133
|
"concurrently": "^9.2.1",
|
|
@@ -72,8 +139,8 @@
|
|
|
72
139
|
"peerDependencies": {
|
|
73
140
|
"@notionhq/client": ">=2.2.15"
|
|
74
141
|
},
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
142
|
+
"engines": {
|
|
143
|
+
"node": ">=22.0.0",
|
|
144
|
+
"npm": ">=10.9.2"
|
|
78
145
|
}
|
|
79
146
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ajv-formats is CJS-only and doesn't ship types compatible with
|
|
2
|
+
// moduleResolution: "nodenext". This declaration provides the correct
|
|
3
|
+
// callable default export signature so we can import it without suppression.
|
|
4
|
+
declare module "ajv-formats" {
|
|
5
|
+
import type { Ajv } from "ajv";
|
|
6
|
+
export default function addFormats(ajv: Ajv): Ajv;
|
|
7
|
+
}
|