@notionhq/apps 0.0.27 → 0.0.28
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/calendar.generated.d.ts +1908 -680
- package/dist/calendar.generated.d.ts.map +1 -1
- package/dist/calendar.generated.js +27 -0
- package/dist/connection-trigger-definitions.generated.d.ts +12 -0
- package/dist/connection-trigger-definitions.generated.d.ts.map +1 -1
- package/dist/connection-trigger-definitions.generated.js +15 -0
- package/dist/connections.d.ts +1 -0
- package/dist/connections.d.ts.map +1 -1
- package/dist/mail.generated.d.ts +4590 -0
- package/dist/mail.generated.d.ts.map +1 -0
- package/dist/mail.generated.js +252 -0
- package/dist/providers.generated.d.ts +4 -0
- package/dist/providers.generated.d.ts.map +1 -1
- package/dist/providers.generated.js +7 -0
- package/dist/triggers.generated.d.ts +34 -16
- package/dist/triggers.generated.d.ts.map +1 -1
- package/dist/triggers.generated.js +12 -9
- package/docs/CONNECTIONS.md +38 -3
- package/package.json +1 -1
- package/src/calendar.generated.ts +2033 -737
- package/src/connection-trigger-definitions.generated.ts +18 -0
- package/src/connections.test.ts +35 -0
- package/src/mail.generated.ts +5095 -0
- package/src/providers.generated.ts +8 -0
- package/src/triggers.generated.ts +27 -18
- package/src/workflow-connections-types.test.ts +16 -0
package/docs/CONNECTIONS.md
CHANGED
|
@@ -47,7 +47,7 @@ The callback runs once when `workflow` is called. Its result is serialized as th
|
|
|
47
47
|
|
|
48
48
|
Deployment creates a disabled trigger attached to that connection. Configure the account, channel or calendar, and enable the trigger through workflow setup before publishing. Redeploying preserves its configuration. The server checks the binding at publication and execution, so a trigger on another connection cannot invoke this declaration.
|
|
49
49
|
|
|
50
|
-
Calendar, Slack, Google Drive OAuth, and Discord currently have generated connection trigger helpers. Providers without registered public trigger events do not gain helpers merely by supporting actions. Existing helper calls without `connectionKey` keep their existing behavior. For `connections: { calendar: connections.calendar() }`, use `triggers.calendarEventCreated({ connectionKey: "calendar" })`.
|
|
50
|
+
Calendar, Mail, Slack, Google Drive OAuth, and Discord currently have generated connection trigger helpers. Providers without registered public trigger events do not gain helpers merely by supporting actions. Existing helper calls without `connectionKey` keep their existing behavior. For `connections: { calendar: connections.calendar() }`, use `triggers.calendarEventCreated({ connectionKey: "calendar" })`.
|
|
51
51
|
|
|
52
52
|
Removing a declaration retains the configured trigger, but it can no longer invoke the capability unless another declaration allows it. Renaming a key creates a new connection and disabled trigger. Two keys can declare the same event type independently; repeating the same type and key is rejected.
|
|
53
53
|
|
|
@@ -88,12 +88,47 @@ The SDK serializes the object to the existing manifest array of `{ key, type }`
|
|
|
88
88
|
|
|
89
89
|
## Supported providers and setup
|
|
90
90
|
|
|
91
|
-
The registry
|
|
91
|
+
The registry generates clients for Calendar, Mail, Slack, Google Drive OAuth, Discord, Cursor, Box, Confluence, Gmail, Google Calendar, Google Drive, Outlook, and Salesforce. Only eligible Tool Core methods are generated; this does not expose every operation in those services.
|
|
92
92
|
|
|
93
93
|
Each connection must be authenticated and granted access through the workflow’s setup flow before use. The server handles provider-specific authentication and checks that setup is complete. App code declares a provider under a binding key; declaring a connection never grants permissions.
|
|
94
94
|
|
|
95
95
|
Providers outside the supported list are not currently available as workflow connections. Unsupported declarations receive an unavailable-provider error.
|
|
96
96
|
|
|
97
|
+
### Mail
|
|
98
|
+
|
|
99
|
+
`connections.mail()` uses the personal Mail connection and selected accounts configured in workflow setup. It is separate from the admin-enabled `connections.gmail()` and `connections.outlook()` search connectors.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import { workflow } from "@notionhq/apps";
|
|
103
|
+
import { connections } from "@notionhq/apps/workflow";
|
|
104
|
+
|
|
105
|
+
export default workflow({
|
|
106
|
+
name: "Read unread mail",
|
|
107
|
+
description: "Search the configured mailbox when an email arrives",
|
|
108
|
+
connections: { inbox: connections.mail() },
|
|
109
|
+
triggers: ({ triggers }) => [triggers.mailEmailReceived({ connectionKey: "inbox" })],
|
|
110
|
+
handler: async (_event, context) => {
|
|
111
|
+
await context.step("Search unread mail", async () => {
|
|
112
|
+
const result = await context.connections.inbox.searchEmails({
|
|
113
|
+
userEmailAddress: "me@example.com",
|
|
114
|
+
query: "is:unread",
|
|
115
|
+
count: 20,
|
|
116
|
+
});
|
|
117
|
+
if (result.isError) throw new Error("Mailbox search failed");
|
|
118
|
+
return result;
|
|
119
|
+
});
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Mail exposes reads such as `searchEmails`, `viewThreadContent`, `readAttachment`, and `listLabels`, plus writes such as `sendNewEmail`, draft creation, and label updates. Search accepts `pageToken` for pagination. Results preserve the Mail tool response, including `content`, optional `structuredContent`, and `isError`; inspect the provider's response before using its contents. The server enforces selected accounts and action permissions on every call.
|
|
125
|
+
|
|
126
|
+
### Mail and Calendar write approval
|
|
127
|
+
|
|
128
|
+
Mail and Calendar write methods are available in configured workflows, including sending email and creating, updating, or canceling calendar events. Configuring and publishing the workflow authorizes unattended execution within the connection's permissions. The server automatically approves ordinary action confirmations for the workflow's granted Mail and Calendar connections; app code does not need to approve individual calls.
|
|
129
|
+
|
|
130
|
+
Account and calendar permissions still apply. Auto-approval does not grant access to an unselected mailbox, enable disallowed sending, or make a read-only calendar writable. Other confirmation requirements are not automatically approved. Direct agent calls retain their existing confirmation behavior.
|
|
131
|
+
|
|
97
132
|
## Regenerate provider clients
|
|
98
133
|
|
|
99
134
|
From `apps-sdk`, with a compatible sibling `notion-next` checkout and its mise toolchain installed:
|
|
@@ -113,7 +148,7 @@ notion tool-core codegen-script-types --connections --path ../apps-sdk/src --che
|
|
|
113
148
|
### How generation works
|
|
114
149
|
|
|
115
150
|
1. The generator reads `src/shared/workflows/connectionProviders.ts` in `notion-next`. Each entry selects a provider; the server owns its authentication and readiness checks.
|
|
116
|
-
2. For each provider, it reads the corresponding workflow module's effects. It keeps effects backed by a Tool Core definition, exposed to script agents, not excluded from the connection API
|
|
151
|
+
2. For each provider, it reads the corresponding workflow module's effects. It keeps effects backed by a Tool Core definition, exposed to script agents, and not excluded from the connection API. Mail and Calendar include writes because the workflow runtime can approve their action confirmations. Other providers include only read-only methods or methods without a confirmation policy. Server permission checks still apply; workflows do not yet support human confirmation steps.
|
|
117
152
|
3. It reads the exact Tool Core definition stored on each workflow effect projection, so providers with multiple tool versions use the contract selected by their module.
|
|
118
153
|
4. The existing script-type emitter renders the method's wire input and result types. It honors input field mappings and declared output projections, so the types describe the workflow endpoint contract.
|
|
119
154
|
5. It also reads each provider module’s trigger definitions and emits `connection-trigger-definitions.generated.ts`. The SDK trigger generator intersects these with the public `TriggerEventMap` to generate supported `connectionKey` options, descriptions, event types, and provider-scoped trigger creators. Internal events are not exposed.
|