@notionhq/apps 0.0.26 → 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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- 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/dist/workflow.d.ts +61 -1
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +109 -1
- package/docs/CONNECTIONS.md +38 -3
- package/docs/workflow-inputs.md +28 -0
- 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/index.ts +1 -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/src/workflow.test.ts +210 -0
- package/src/workflow.ts +226 -3
package/dist/workflow.d.ts
CHANGED
|
@@ -20,6 +20,50 @@ export type WorkflowWaitDuration = {
|
|
|
20
20
|
[Unit in keyof WorkflowWaitDurationValues]-?: Required<Pick<WorkflowWaitDurationValues, Unit>> & WorkflowWaitDurationValues;
|
|
21
21
|
}[keyof WorkflowWaitDurationValues];
|
|
22
22
|
type WorkflowWaitKey = string | string[];
|
|
23
|
+
type WorkflowInputFieldOptions = {
|
|
24
|
+
optional?: boolean;
|
|
25
|
+
};
|
|
26
|
+
declare const workflowInputValueType: unique symbol;
|
|
27
|
+
export type WorkflowInputField<T> = {
|
|
28
|
+
type: "text" | "number" | "checkbox" | "select" | "multi_select" | "date" | "person" | "files";
|
|
29
|
+
optional?: boolean;
|
|
30
|
+
options?: readonly string[];
|
|
31
|
+
readonly [workflowInputValueType]?: T;
|
|
32
|
+
};
|
|
33
|
+
type WorkflowInputValue<T, TOptions extends WorkflowInputFieldOptions | undefined> = TOptions extends {
|
|
34
|
+
optional: true;
|
|
35
|
+
} ? T | undefined : T;
|
|
36
|
+
/** Date-only or local date-time endpoints, with the selected IANA time zone. */
|
|
37
|
+
export type WorkflowInputDate = {
|
|
38
|
+
start: string;
|
|
39
|
+
end?: string;
|
|
40
|
+
timeZone?: string;
|
|
41
|
+
};
|
|
42
|
+
export declare const input: {
|
|
43
|
+
text<const TOptions extends WorkflowInputFieldOptions | undefined>(options?: TOptions): WorkflowInputField<WorkflowInputValue<string, TOptions>>;
|
|
44
|
+
number<const TOptions extends WorkflowInputFieldOptions | undefined>(options?: TOptions): WorkflowInputField<WorkflowInputValue<number, TOptions>>;
|
|
45
|
+
checkbox<const TOptions extends WorkflowInputFieldOptions | undefined>(options?: TOptions): WorkflowInputField<WorkflowInputValue<boolean, TOptions>>;
|
|
46
|
+
select<const TOptions extends readonly [string, ...string[]], const TFieldOptions extends WorkflowInputFieldOptions | undefined>(values: TOptions, options?: TFieldOptions): WorkflowInputField<WorkflowInputValue<TOptions[number], TFieldOptions>>;
|
|
47
|
+
date<const TOptions extends WorkflowInputFieldOptions | undefined>(options?: TOptions): WorkflowInputField<WorkflowInputValue<WorkflowInputDate, TOptions>>;
|
|
48
|
+
multiSelect<const TOptions extends readonly [string, ...string[]], const TFieldOptions extends WorkflowInputFieldOptions | undefined>(values: TOptions, options?: TFieldOptions): WorkflowInputField<WorkflowInputValue<TOptions[number][], TFieldOptions>>;
|
|
49
|
+
/** Returns the user ID of every selected person. */
|
|
50
|
+
person<const TOptions extends WorkflowInputFieldOptions | undefined>(options?: TOptions): WorkflowInputField<WorkflowInputValue<string[], TOptions>>;
|
|
51
|
+
/** Returns each attachment's URL or Notion attachment block ID. */
|
|
52
|
+
files<const TOptions extends WorkflowInputFieldOptions | undefined>(options?: TOptions): WorkflowInputField<WorkflowInputValue<string[], TOptions>>;
|
|
53
|
+
};
|
|
54
|
+
export type WorkflowInputSchema = Record<string, WorkflowInputField<unknown>>;
|
|
55
|
+
export type WorkflowInputValues<TSchema extends WorkflowInputSchema> = {
|
|
56
|
+
[Key in keyof TSchema]: TSchema[Key] extends WorkflowInputField<infer Value> ? Value : never;
|
|
57
|
+
};
|
|
58
|
+
export type WorkflowInputResponse<TSchema extends WorkflowInputSchema> = {
|
|
59
|
+
value: WorkflowInputValues<TSchema>;
|
|
60
|
+
respondedBy: string;
|
|
61
|
+
respondedAt: string;
|
|
62
|
+
};
|
|
63
|
+
export type WorkflowWaitForInputOptions<TSchema extends WorkflowInputSchema> = {
|
|
64
|
+
input: TSchema;
|
|
65
|
+
key?: WorkflowWaitKey;
|
|
66
|
+
};
|
|
23
67
|
export type WorkflowWaitUntilOptions = {
|
|
24
68
|
at: Date;
|
|
25
69
|
key?: WorkflowWaitKey;
|
|
@@ -35,9 +79,19 @@ export type WorkflowWaitUntilResult = {
|
|
|
35
79
|
resumeAtMs: number;
|
|
36
80
|
};
|
|
37
81
|
};
|
|
82
|
+
export type WorkflowWaitForInputResult = {
|
|
83
|
+
status: "waiting";
|
|
84
|
+
wait: {
|
|
85
|
+
type: "input";
|
|
86
|
+
name: string;
|
|
87
|
+
stepKey: string;
|
|
88
|
+
input: WorkflowInputSchema;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
type WorkflowWaitResult = WorkflowWaitUntilResult | WorkflowWaitForInputResult;
|
|
38
92
|
type WorkflowHandlerResult = {
|
|
39
93
|
status: "success";
|
|
40
|
-
} |
|
|
94
|
+
} | WorkflowWaitResult;
|
|
41
95
|
export type { WorkflowAccess, WorkflowAccessAgentLevel, WorkflowAccessBindings, WorkflowAccessDeclaration, WorkflowAccessDeclarations, WorkflowAccessLevel, WorkflowAccessLevelFor, WorkflowAccessResource, WorkflowAccessResourceLevel, WorkflowAccessResourceType, WorkflowAccessRequirement, WorkflowAccessRequirements, WorkflowAccessValue, } from "./workflow-access.js";
|
|
42
96
|
export { access } from "./workflow-access.js";
|
|
43
97
|
export type WorkflowEvent = WorkflowEventMap[keyof WorkflowEventMap];
|
|
@@ -166,6 +220,12 @@ type WorkflowWait = {
|
|
|
166
220
|
* date has been reached.
|
|
167
221
|
*/
|
|
168
222
|
until(name: string, options: WorkflowWaitUntilOptions): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Suspend the workflow until a person submits values matching the input
|
|
225
|
+
* schema. The returned value is restored from the durable workflow
|
|
226
|
+
* checkpoint when the request is fulfilled.
|
|
227
|
+
*/
|
|
228
|
+
forInput<const TSchema extends WorkflowInputSchema>(name: string, options: WorkflowWaitForInputOptions<TSchema>): Promise<WorkflowInputResponse<TSchema>>;
|
|
169
229
|
};
|
|
170
230
|
/** Context passed to a workflow handler. */
|
|
171
231
|
export type WorkflowContext<TConnections extends WorkflowConnectionDeclarations = WorkflowConnectionDeclarations, TAccess extends WorkflowAccessDeclarations = WorkflowAccessDeclarations> = CapabilityContext & {
|
package/dist/workflow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,mBAAmB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,EAC/B,MAAM,sBAAsB,CAAC;AAK9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,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EACjD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAC3C,OAAO,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;CAC3C,CAAC;AAEF,4CAA4C;AAC5C,MAAM,MAAM,eAAe,CAC1B,YAAY,SAAS,8BAA8B,GAAG,8BAA8B,EACpF,OAAO,SAAS,0BAA0B,GAAG,0BAA0B,IACpE,iBAAiB,GAAG;IACvB,0FAA0F;IAC1F,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;IACzC,WAAW,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;CAC/C,GAAG,WAAW,GAAG;IAChB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,IAAI,EAAE,YAAY,CAAC;IACnB,iEAAiE;IACjE,IAAI,EAAE,YAAY,CAAC;CACnB,CAAC"}
|
package/dist/workflow.js
CHANGED
|
@@ -17,6 +17,34 @@ import { resolveRuntimeInput } from "./runtime-input.js";
|
|
|
17
17
|
import { readRunMetadata } from "./runtime-metadata.js";
|
|
18
18
|
import { createWorkflowTriggers } from "./triggers.generated.js";
|
|
19
19
|
import { createWorkflowStepState } from "./workflow-state.js";
|
|
20
|
+
const input = {
|
|
21
|
+
text(options) {
|
|
22
|
+
return { type: "text", ...options };
|
|
23
|
+
},
|
|
24
|
+
number(options) {
|
|
25
|
+
return { type: "number", ...options };
|
|
26
|
+
},
|
|
27
|
+
checkbox(options) {
|
|
28
|
+
return { type: "checkbox", ...options };
|
|
29
|
+
},
|
|
30
|
+
select(values, options) {
|
|
31
|
+
return { type: "select", options: values, ...options };
|
|
32
|
+
},
|
|
33
|
+
date(options) {
|
|
34
|
+
return { type: "date", ...options };
|
|
35
|
+
},
|
|
36
|
+
multiSelect(values, options) {
|
|
37
|
+
return { type: "multi_select", options: values, ...options };
|
|
38
|
+
},
|
|
39
|
+
/** Returns the user ID of every selected person. */
|
|
40
|
+
person(options) {
|
|
41
|
+
return { type: "person", ...options };
|
|
42
|
+
},
|
|
43
|
+
/** Returns each attachment's URL or Notion attachment block ID. */
|
|
44
|
+
files(options) {
|
|
45
|
+
return { type: "files", ...options };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
20
48
|
const MAX_WORKFLOW_WAIT_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
21
49
|
import { access } from "./workflow-access.js";
|
|
22
50
|
import {
|
|
@@ -189,13 +217,20 @@ function createStep(metadata) {
|
|
|
189
217
|
}
|
|
190
218
|
class WorkflowWaitInterrupt extends Error {
|
|
191
219
|
constructor(result) {
|
|
192
|
-
super(
|
|
220
|
+
super(workflowWaitMessage(result));
|
|
193
221
|
this.result = result;
|
|
194
222
|
this.name = "WorkflowWaitInterrupt";
|
|
195
223
|
}
|
|
196
224
|
result;
|
|
197
225
|
}
|
|
226
|
+
function workflowWaitMessage(result) {
|
|
227
|
+
if (result.wait.type === "until") {
|
|
228
|
+
return `Workflow is waiting until ${new Date(result.wait.resumeAtMs).toISOString()}`;
|
|
229
|
+
}
|
|
230
|
+
return `Workflow is waiting for input: ${result.wait.name}`;
|
|
231
|
+
}
|
|
198
232
|
function createWait(step) {
|
|
233
|
+
const inputWaitNameByKey = /* @__PURE__ */ new Map();
|
|
199
234
|
return {
|
|
200
235
|
async until(name, options) {
|
|
201
236
|
const keyInput = options.key ?? name;
|
|
@@ -220,9 +255,81 @@ function createWait(step) {
|
|
|
220
255
|
resumeAtMs
|
|
221
256
|
}
|
|
222
257
|
});
|
|
258
|
+
},
|
|
259
|
+
async forInput(name, options) {
|
|
260
|
+
const keyInput = options.key ?? name;
|
|
261
|
+
const stepKey = createWorkflowStepKey([
|
|
262
|
+
"wait",
|
|
263
|
+
"input",
|
|
264
|
+
...typeof keyInput === "string" ? [keyInput] : keyInput
|
|
265
|
+
]);
|
|
266
|
+
const existingName = inputWaitNameByKey.get(stepKey);
|
|
267
|
+
if (existingName !== void 0) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
`Workflow input wait "${name}" has the same key as "${existingName}". Provide a unique name or an explicit key.`
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
inputWaitNameByKey.set(stepKey, name);
|
|
273
|
+
const checkpoint = await readWorkflowStepCheckpoint(stepKey);
|
|
274
|
+
if (checkpoint) {
|
|
275
|
+
if (!isWorkflowInputResponse(checkpoint.value, options.input)) {
|
|
276
|
+
throw new Error(
|
|
277
|
+
`Workflow input checkpoint ${hashWorkflowStepKey(stepKey)} does not match its schema.`
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
return checkpoint.value;
|
|
281
|
+
}
|
|
282
|
+
throw new WorkflowWaitInterrupt({
|
|
283
|
+
status: "waiting",
|
|
284
|
+
wait: {
|
|
285
|
+
type: "input",
|
|
286
|
+
name,
|
|
287
|
+
stepKey,
|
|
288
|
+
input: options.input
|
|
289
|
+
}
|
|
290
|
+
});
|
|
223
291
|
}
|
|
224
292
|
};
|
|
225
293
|
}
|
|
294
|
+
function isWorkflowInputResponse(value, schema) {
|
|
295
|
+
if (!isRecord(value) || !isRecord(value.value) || typeof value.respondedBy !== "string" || typeof value.respondedAt !== "string") {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
if (Object.keys(value.value).some((key) => !Object.hasOwn(schema, key))) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
302
|
+
const fieldValue = value.value[key];
|
|
303
|
+
if (fieldValue === void 0 && field.optional === true) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (!isWorkflowInputFieldValue(fieldValue, field)) {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
function isWorkflowInputFieldValue(value, field) {
|
|
313
|
+
switch (field.type) {
|
|
314
|
+
case "text":
|
|
315
|
+
return typeof value === "string";
|
|
316
|
+
case "date":
|
|
317
|
+
return isRecord(value) && typeof value.start === "string" && (value.end === void 0 || typeof value.end === "string") && (value.timeZone === void 0 || typeof value.timeZone === "string");
|
|
318
|
+
case "number":
|
|
319
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
320
|
+
case "checkbox":
|
|
321
|
+
return typeof value === "boolean";
|
|
322
|
+
case "select":
|
|
323
|
+
return typeof value === "string" && field.options !== void 0 && field.options.includes(value);
|
|
324
|
+
case "person":
|
|
325
|
+
case "files":
|
|
326
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
327
|
+
case "multi_select": {
|
|
328
|
+
const options = field.options;
|
|
329
|
+
return Array.isArray(value) && options !== void 0 && value.every((item) => typeof item === "string" && options.includes(item));
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
226
333
|
function resolveWaitUntilMs(options) {
|
|
227
334
|
const now = Date.now();
|
|
228
335
|
if ("at" in options) {
|
|
@@ -344,5 +451,6 @@ function isNodeError(error) {
|
|
|
344
451
|
export {
|
|
345
452
|
access,
|
|
346
453
|
connections,
|
|
454
|
+
input,
|
|
347
455
|
workflow
|
|
348
456
|
};
|
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.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Workflow input values
|
|
2
|
+
|
|
3
|
+
Use `input` from `@notionhq/apps` to describe a `context.wait.forInput` form:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
const response = await context.wait.forInput("Launch details", {
|
|
7
|
+
input: {
|
|
8
|
+
teams: input.multiSelect(["Design", "Engineering"]),
|
|
9
|
+
owners: input.person(),
|
|
10
|
+
window: input.date(),
|
|
11
|
+
attachments: input.files({ optional: true }),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- `teams` is an array of the declared options, typed as `("Design" | "Engineering")[]`.
|
|
17
|
+
- `owners` is a `string[]` of all selected user IDs, including when only one person
|
|
18
|
+
is selected. This replaces the previous scalar `string` response.
|
|
19
|
+
- `window` is `{ start: string; end?: string; timeZone?: string }`, not a string.
|
|
20
|
+
Date-only endpoints use `YYYY-MM-DD`; timed endpoints use local `YYYY-MM-DDTHH:mm`
|
|
21
|
+
together with the selected IANA `timeZone`. Ranges retain both endpoints.
|
|
22
|
+
The type is available as `WorkflowInputDate` from `@notionhq/apps/workflow`.
|
|
23
|
+
- `attachments` is a `string[]` with one URL or Notion attachment block ID per item,
|
|
24
|
+
in property order. Attachment display names are not returned as URLs.
|
|
25
|
+
|
|
26
|
+
Empty required multi-select, person, and file inputs keep the request waiting. Empty optional
|
|
27
|
+
inputs are omitted. Selections outside the declared options keep the request waiting
|
|
28
|
+
so the respondent can correct them.
|