@notionhq/apps 0.0.12 → 0.0.14
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/README.md +32 -0
- package/dist/box.generated.d.ts +164 -0
- package/dist/box.generated.d.ts.map +1 -0
- package/dist/box.generated.js +24 -0
- package/dist/calendar.generated.d.ts +1036 -0
- package/dist/calendar.generated.d.ts.map +1 -0
- package/dist/calendar.generated.js +42 -0
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +41 -10
- package/dist/cli/codegen.d.ts +2 -0
- package/dist/cli/codegen.d.ts.map +1 -1
- package/dist/cli/codegen.js +13 -2
- package/dist/cli/discover.d.ts +2 -0
- package/dist/cli/discover.d.ts.map +1 -1
- package/dist/cli/discover.js +4 -2
- package/dist/cli/emit-manifest.d.ts +3 -1
- package/dist/cli/emit-manifest.d.ts.map +1 -1
- package/dist/cli/emit-manifest.js +10 -4
- package/dist/cli/index.js +33 -1
- package/dist/confluence.generated.d.ts +98 -0
- package/dist/confluence.generated.d.ts.map +1 -0
- package/dist/confluence.generated.js +18 -0
- package/dist/connection-actions.d.ts +2 -0
- package/dist/connection-actions.d.ts.map +1 -0
- package/dist/connection-actions.js +0 -0
- package/dist/connection-trigger-definitions.generated.d.ts +34 -0
- package/dist/connection-trigger-definitions.generated.d.ts.map +1 -0
- package/dist/connection-trigger-definitions.generated.js +45 -0
- package/dist/connections.d.ts +15 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +79 -0
- package/dist/connections.test.d.ts +2 -0
- package/dist/connections.test.d.ts.map +1 -0
- package/dist/cursor.generated.d.ts +154 -0
- package/dist/cursor.generated.d.ts.map +1 -0
- package/dist/cursor.generated.js +18 -0
- package/dist/custom-block.d.ts +54 -0
- package/dist/custom-block.d.ts.map +1 -0
- package/dist/custom-block.js +30 -0
- package/dist/custom-block.test.d.ts +2 -0
- package/dist/custom-block.test.d.ts.map +1 -0
- package/dist/custom-blocks.d.ts +2 -0
- package/dist/custom-blocks.d.ts.map +1 -0
- package/dist/custom-blocks.js +1 -0
- package/dist/discord.generated.d.ts +279 -0
- package/dist/discord.generated.d.ts.map +1 -0
- package/dist/discord.generated.js +33 -0
- package/dist/gmail.generated.d.ts +184 -0
- package/dist/gmail.generated.d.ts.map +1 -0
- package/dist/gmail.generated.js +21 -0
- package/dist/googleCalendar.generated.d.ts +83 -0
- package/dist/googleCalendar.generated.d.ts.map +1 -0
- package/dist/googleCalendar.generated.js +15 -0
- package/dist/googleDrive.generated.d.ts +210 -0
- package/dist/googleDrive.generated.d.ts.map +1 -0
- package/dist/googleDrive.generated.js +27 -0
- package/dist/googleDriveOauth.generated.d.ts +851 -0
- package/dist/googleDriveOauth.generated.d.ts.map +1 -0
- package/dist/googleDriveOauth.generated.js +84 -0
- package/dist/manifest.d.ts +1 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/nds.css +1 -0
- package/dist/notion-as-code/database.d.ts +4 -3
- package/dist/notion-as-code/database.d.ts.map +1 -1
- package/dist/notion-as-code/database.js +11 -2
- package/dist/notion-as-code/intents.d.ts +4 -1
- package/dist/notion-as-code/intents.d.ts.map +1 -1
- package/dist/notion-as-code/page.d.ts +4 -4
- package/dist/notion-as-code/page.d.ts.map +1 -1
- package/dist/notion-as-code/page.js +11 -2
- package/dist/outlook.generated.d.ts +224 -0
- package/dist/outlook.generated.d.ts.map +1 -0
- package/dist/outlook.generated.js +24 -0
- package/dist/providers.generated.d.ts +117 -0
- package/dist/providers.generated.d.ts.map +1 -0
- package/dist/providers.generated.js +108 -0
- package/dist/react.d.ts +2 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +1 -0
- package/dist/salesforce.generated.d.ts +151 -0
- package/dist/salesforce.generated.d.ts.map +1 -0
- package/dist/salesforce.generated.js +24 -0
- package/dist/slack.generated.d.ts +290 -0
- package/dist/slack.generated.d.ts.map +1 -0
- package/dist/slack.generated.js +30 -0
- package/dist/triggers.generated.d.ts +107 -32
- package/dist/triggers.generated.d.ts.map +1 -1
- package/dist/triggers.generated.js +36 -24
- package/dist/workflow-connections-types.test.d.ts +2 -0
- package/dist/workflow-connections-types.test.d.ts.map +1 -0
- package/dist/workflow-types.test.d.ts +2 -0
- package/dist/workflow-types.test.d.ts.map +1 -0
- package/dist/workflow.d.ts +20 -16
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +14 -17
- package/docs/BUILD.md +83 -14
- package/docs/CONNECTIONS.md +129 -0
- package/package.json +16 -2
- package/src/box.generated.ts +187 -0
- package/src/calendar.generated.ts +1117 -0
- package/src/cli/build.test.ts +87 -0
- package/src/cli/build.ts +47 -9
- package/src/cli/codegen.test.ts +2 -0
- package/src/cli/codegen.ts +25 -7
- package/src/cli/discover.test.ts +12 -0
- package/src/cli/discover.ts +6 -2
- package/src/cli/emit-manifest.ts +13 -3
- package/src/cli/index.ts +33 -1
- package/src/confluence.generated.ts +109 -0
- package/src/connection-actions.ts +2 -0
- package/src/connection-trigger-definitions.generated.ts +48 -0
- package/src/connections.test.ts +157 -0
- package/src/connections.ts +126 -0
- package/src/cursor.generated.ts +167 -0
- package/src/custom-block.test.ts +19 -0
- package/src/custom-block.ts +41 -0
- package/src/custom-blocks.ts +1 -0
- package/src/discord.generated.ts +318 -0
- package/src/gmail.generated.ts +205 -0
- package/src/googleCalendar.generated.ts +95 -0
- package/src/googleDrive.generated.ts +235 -0
- package/src/googleDriveOauth.generated.ts +980 -0
- package/src/manifest.ts +1 -1
- package/src/nds.css +1 -0
- package/src/notion-as-code/database.ts +19 -11
- package/src/notion-as-code/intents.ts +2 -1
- package/src/notion-as-code/page.ts +17 -11
- package/src/outlook.generated.ts +249 -0
- package/src/providers.generated.ts +207 -0
- package/src/react.ts +1 -0
- package/src/salesforce.generated.ts +170 -0
- package/src/slack.generated.ts +330 -0
- package/src/triggers.generated.ts +112 -32
- package/src/workflow-connections-types.test.ts +59 -0
- package/src/workflow-types.test.ts +144 -0
- package/src/workflow.test.ts +112 -2
- package/src/workflow.ts +58 -29
package/src/workflow.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createWorkflowConnections,
|
|
3
|
+
validateConnectionRequirements,
|
|
4
|
+
validateTriggerConnections,
|
|
5
|
+
type WorkflowConnection,
|
|
6
|
+
type WorkflowConnections,
|
|
7
|
+
} from "./connections.js";
|
|
1
8
|
import { createHash } from "node:crypto";
|
|
2
9
|
import { readFile } from "node:fs/promises";
|
|
3
10
|
import { join } from "node:path";
|
|
@@ -8,7 +15,13 @@ import { ExecutionError } from "./error.js";
|
|
|
8
15
|
import { writeOutput } from "./output.js";
|
|
9
16
|
import { resolveRuntimeInput } from "./runtime-input.js";
|
|
10
17
|
import { readRunMetadata, type RunMetadata } from "./runtime-metadata.js";
|
|
11
|
-
import
|
|
18
|
+
import { createWorkflowTriggers } from "./triggers.generated.js";
|
|
19
|
+
import type {
|
|
20
|
+
WorkflowEventMap,
|
|
21
|
+
WorkflowTrigger,
|
|
22
|
+
WorkflowTriggerCreators,
|
|
23
|
+
WorkflowTriggerForConnections,
|
|
24
|
+
} from "./triggers.generated.js";
|
|
12
25
|
|
|
13
26
|
type HandlerOptions = {
|
|
14
27
|
/** Return the concrete result instead of writing the output envelope. */
|
|
@@ -22,24 +35,14 @@ export type WorkflowEventForTrigger<T extends WorkflowTrigger> = WorkflowEventMa
|
|
|
22
35
|
export type WorkflowEventForTriggers<T extends readonly WorkflowTrigger[]> =
|
|
23
36
|
WorkflowEventForTrigger<T[number]>;
|
|
24
37
|
|
|
25
|
-
|
|
26
|
-
export type WorkflowConnection = {
|
|
27
|
-
type: "calendar";
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/** Connection requirements supported by workflow capabilities. */
|
|
31
|
-
export const connections = {
|
|
32
|
-
/** Require an authorized Calendar connection. */
|
|
33
|
-
calendar(): WorkflowConnection {
|
|
34
|
-
return { type: "calendar" };
|
|
35
|
-
},
|
|
36
|
-
};
|
|
38
|
+
export { connections, type WorkflowConnection, type WorkflowConnections } from "./connections.js";
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* Configuration passed to {@link createWorkflow}.
|
|
40
42
|
*/
|
|
41
43
|
export type WorkflowConfiguration<
|
|
42
44
|
TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
45
|
+
TConnections extends readonly WorkflowConnection[] = readonly WorkflowConnection[],
|
|
43
46
|
> = {
|
|
44
47
|
/**
|
|
45
48
|
* A human-readable name for the workflow, shown in the UI when viewing workflows
|
|
@@ -61,14 +64,22 @@ export type WorkflowConfiguration<
|
|
|
61
64
|
/**
|
|
62
65
|
* Connections that must be set up before this workflow can run.
|
|
63
66
|
*/
|
|
64
|
-
connections?:
|
|
67
|
+
connections?: TConnections;
|
|
65
68
|
|
|
66
69
|
handler: (
|
|
67
70
|
event: WorkflowEventForTriggers<TTriggers>,
|
|
68
|
-
context: WorkflowContext
|
|
71
|
+
context: WorkflowContext<TConnections>,
|
|
69
72
|
) => Promise<void> | void;
|
|
70
73
|
};
|
|
71
74
|
|
|
75
|
+
/** Configuration that checks trigger keys against declared connections. */
|
|
76
|
+
export type WorkflowTriggerConfiguration<
|
|
77
|
+
TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
78
|
+
TConnections extends readonly WorkflowConnection[],
|
|
79
|
+
> = Omit<WorkflowConfiguration<TTriggers, TConnections>, "triggers"> & {
|
|
80
|
+
triggers: (context: { triggers: WorkflowTriggerCreators<NoInfer<TConnections>> }) => TTriggers;
|
|
81
|
+
};
|
|
82
|
+
|
|
72
83
|
/**
|
|
73
84
|
* A workflow capability as returned by {@link createWorkflow}.
|
|
74
85
|
*
|
|
@@ -120,25 +131,38 @@ export type Workflow<
|
|
|
120
131
|
* });
|
|
121
132
|
* ```
|
|
122
133
|
*/
|
|
134
|
+
export function createWorkflow<
|
|
135
|
+
const TTriggers extends readonly [
|
|
136
|
+
WorkflowTriggerForConnections<NoInfer<TConnections>>,
|
|
137
|
+
...WorkflowTriggerForConnections<NoInfer<TConnections>>[],
|
|
138
|
+
],
|
|
139
|
+
const TConnections extends readonly WorkflowConnection[] = readonly [],
|
|
140
|
+
>(configuration: WorkflowTriggerConfiguration<TTriggers, TConnections>): Workflow<TTriggers>;
|
|
123
141
|
export function createWorkflow<
|
|
124
142
|
const TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
const TConnections extends readonly WorkflowConnection[] = readonly [],
|
|
144
|
+
>(configuration: WorkflowConfiguration<TTriggers, TConnections>): Workflow<TTriggers>;
|
|
145
|
+
export function createWorkflow<
|
|
146
|
+
const TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
147
|
+
const TConnections extends readonly WorkflowConnection[] = readonly [],
|
|
148
|
+
>(
|
|
149
|
+
configuration:
|
|
150
|
+
| WorkflowConfiguration<TTriggers, TConnections>
|
|
151
|
+
| WorkflowTriggerConfiguration<TTriggers, TConnections>,
|
|
152
|
+
): Workflow<TTriggers> {
|
|
153
|
+
const triggers =
|
|
154
|
+
typeof configuration.triggers === "function"
|
|
155
|
+
? configuration.triggers({ triggers: createWorkflowTriggers<TConnections>() })
|
|
156
|
+
: configuration.triggers;
|
|
157
|
+
validateConnectionRequirements(configuration.connections ?? []);
|
|
158
|
+
validateTriggerConnections(triggers, configuration.connections ?? []);
|
|
135
159
|
|
|
136
160
|
return {
|
|
137
161
|
_tag: "workflow",
|
|
138
162
|
config: {
|
|
139
163
|
name: configuration.name,
|
|
140
164
|
description: configuration.description,
|
|
141
|
-
triggers
|
|
165
|
+
triggers,
|
|
142
166
|
...(configuration.connections === undefined
|
|
143
167
|
? {}
|
|
144
168
|
: { connections: configuration.connections }),
|
|
@@ -150,8 +174,10 @@ export function createWorkflow<
|
|
|
150
174
|
try {
|
|
151
175
|
event = await resolveRuntimeInput(event);
|
|
152
176
|
const runMetadata = readRunMetadata();
|
|
177
|
+
const baseContext = createCapabilityContext();
|
|
153
178
|
const capabilityContext: WorkflowContext = {
|
|
154
|
-
...
|
|
179
|
+
...baseContext,
|
|
180
|
+
connections: createWorkflowConnections(baseContext.notion),
|
|
155
181
|
...runMetadata,
|
|
156
182
|
step: createStep(runMetadata),
|
|
157
183
|
};
|
|
@@ -213,8 +239,11 @@ type WorkflowStep = {
|
|
|
213
239
|
};
|
|
214
240
|
|
|
215
241
|
/** Context passed to a workflow handler. */
|
|
216
|
-
export type WorkflowContext
|
|
217
|
-
|
|
242
|
+
export type WorkflowContext<
|
|
243
|
+
TConnections extends readonly WorkflowConnection[] = readonly WorkflowConnection[],
|
|
244
|
+
> = CapabilityContext & {
|
|
245
|
+
connections: WorkflowConnections<TConnections>;
|
|
246
|
+
} & RunMetadata & {
|
|
218
247
|
/**
|
|
219
248
|
* Run an observable unit of work within the workflow.
|
|
220
249
|
*
|