@notionhq/apps 0.0.16 → 0.0.17
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 +27 -2
- package/dist/connections.d.ts +39 -11
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +85 -21
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/notion-as-code/database.d.ts +3 -2
- package/dist/notion-as-code/database.d.ts.map +1 -1
- package/dist/notion-as-code/handles.d.ts +2 -0
- package/dist/notion-as-code/handles.d.ts.map +1 -1
- package/dist/notion-as-code/handles.js +2 -0
- package/dist/notion-as-code/index.d.ts +3 -0
- package/dist/notion-as-code/index.d.ts.map +1 -1
- package/dist/notion-as-code/intents.d.ts +2 -1
- package/dist/notion-as-code/intents.d.ts.map +1 -1
- package/dist/notion-as-code/view.d.ts +12 -0
- package/dist/notion-as-code/view.d.ts.map +1 -0
- package/dist/notion-as-code/view.js +13 -0
- package/dist/notion-as-code/views-types.test.d.ts +2 -0
- package/dist/notion-as-code/views-types.test.d.ts.map +1 -0
- package/dist/notion-as-code/views.d.ts +469 -0
- package/dist/notion-as-code/views.d.ts.map +1 -0
- package/dist/notion-as-code/views.js +0 -0
- package/dist/oauth.d.ts +11 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +26 -0
- package/dist/providers.generated.d.ts +26 -86
- package/dist/providers.generated.d.ts.map +1 -1
- package/dist/providers.generated.js +54 -66
- package/dist/triggers.generated.d.ts +3 -3
- package/dist/triggers.generated.d.ts.map +1 -1
- package/dist/workflow.d.ts +8 -8
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +12 -6
- package/docs/CONNECTIONS.md +70 -22
- package/package.json +1 -1
- package/skills/connections/SKILL.md +7 -8
- package/skills/notion-as-code/SKILL.md +8 -2
- package/src/connections.test.ts +205 -41
- package/src/connections.ts +144 -38
- package/src/index.ts +1 -0
- package/src/notion-as-code/database.ts +3 -3
- package/src/notion-as-code/handles.ts +2 -0
- package/src/notion-as-code/index.ts +55 -0
- package/src/notion-as-code/intents.ts +2 -2
- package/src/notion-as-code/view.ts +23 -0
- package/src/notion-as-code/views-types.test.ts +59 -0
- package/src/notion-as-code/views.ts +554 -0
- package/src/oauth.ts +40 -0
- package/src/providers.generated.ts +68 -163
- package/src/triggers.generated.ts +4 -4
- package/src/workflow-connections-types.test.ts +16 -10
- package/src/workflow-types.test.ts +88 -16
- package/src/workflow.test.ts +45 -17
- package/src/workflow.ts +31 -17
package/src/workflow.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createWorkflowConnections,
|
|
3
|
-
|
|
3
|
+
normalizeConnectionRequirements,
|
|
4
4
|
validateTriggerConnections,
|
|
5
|
-
type
|
|
5
|
+
type WorkflowConnectionDeclarations,
|
|
6
|
+
type WorkflowConnectionRequirement,
|
|
6
7
|
type WorkflowConnections,
|
|
7
8
|
} from "./connections.js";
|
|
8
9
|
import { createHash } from "node:crypto";
|
|
@@ -35,14 +36,22 @@ export type WorkflowEventForTrigger<T extends WorkflowTrigger> = WorkflowEventMa
|
|
|
35
36
|
export type WorkflowEventForTriggers<T extends readonly WorkflowTrigger[]> =
|
|
36
37
|
WorkflowEventForTrigger<T[number]>;
|
|
37
38
|
|
|
38
|
-
export {
|
|
39
|
+
export {
|
|
40
|
+
connections,
|
|
41
|
+
type WorkflowConnection,
|
|
42
|
+
type WorkflowConnectionDeclarations,
|
|
43
|
+
type WorkflowConnectionRequirement,
|
|
44
|
+
type WorkflowConnections,
|
|
45
|
+
type OAuthConfiguration,
|
|
46
|
+
type OAuthConnection,
|
|
47
|
+
} from "./connections.js";
|
|
39
48
|
|
|
40
49
|
/**
|
|
41
50
|
* Configuration passed to {@link workflow}.
|
|
42
51
|
*/
|
|
43
52
|
export type WorkflowConfiguration<
|
|
44
53
|
TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
45
|
-
TConnections extends
|
|
54
|
+
TConnections extends WorkflowConnectionDeclarations = WorkflowConnectionDeclarations,
|
|
46
55
|
> = {
|
|
47
56
|
/**
|
|
48
57
|
* A human-readable name for the workflow, shown in the UI when viewing workflows
|
|
@@ -75,7 +84,7 @@ export type WorkflowConfiguration<
|
|
|
75
84
|
/** Configuration that checks trigger keys against declared connections. */
|
|
76
85
|
export type WorkflowTriggerConfiguration<
|
|
77
86
|
TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
78
|
-
TConnections extends
|
|
87
|
+
TConnections extends WorkflowConnectionDeclarations,
|
|
79
88
|
> = Omit<WorkflowConfiguration<TTriggers, TConnections>, "triggers"> & {
|
|
80
89
|
triggers: (context: { triggers: WorkflowTriggerCreators<NoInfer<TConnections>> }) => TTriggers;
|
|
81
90
|
};
|
|
@@ -97,7 +106,7 @@ export type Workflow<
|
|
|
97
106
|
name: string;
|
|
98
107
|
description: string;
|
|
99
108
|
triggers: TTriggers;
|
|
100
|
-
connections?: readonly
|
|
109
|
+
connections?: readonly WorkflowConnectionRequirement[];
|
|
101
110
|
};
|
|
102
111
|
handler: (
|
|
103
112
|
event: WorkflowEventForTriggers<TTriggers>,
|
|
@@ -136,26 +145,30 @@ export function workflow<
|
|
|
136
145
|
WorkflowTriggerForConnections<NoInfer<TConnections>>,
|
|
137
146
|
...WorkflowTriggerForConnections<NoInfer<TConnections>>[],
|
|
138
147
|
],
|
|
139
|
-
const TConnections extends
|
|
148
|
+
const TConnections extends WorkflowConnectionDeclarations = Record<never, never>,
|
|
140
149
|
>(configuration: WorkflowTriggerConfiguration<TTriggers, TConnections>): Workflow<TTriggers>;
|
|
141
150
|
export function workflow<
|
|
142
151
|
const TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
143
|
-
const TConnections extends
|
|
152
|
+
const TConnections extends WorkflowConnectionDeclarations = Record<never, never>,
|
|
144
153
|
>(configuration: WorkflowConfiguration<TTriggers, TConnections>): Workflow<TTriggers>;
|
|
145
154
|
export function workflow<
|
|
146
155
|
const TTriggers extends readonly [WorkflowTrigger, ...WorkflowTrigger[]],
|
|
147
|
-
const TConnections extends
|
|
156
|
+
const TConnections extends WorkflowConnectionDeclarations = Record<never, never>,
|
|
148
157
|
>(
|
|
149
158
|
configuration:
|
|
150
159
|
| WorkflowConfiguration<TTriggers, TConnections>
|
|
151
160
|
| WorkflowTriggerConfiguration<TTriggers, TConnections>,
|
|
152
161
|
): Workflow<TTriggers> {
|
|
162
|
+
const requirements = normalizeConnectionRequirements(configuration.connections ?? {});
|
|
163
|
+
const connectionDeclarations =
|
|
164
|
+
configuration.connections === undefined
|
|
165
|
+
? undefined
|
|
166
|
+
: structuredClone(configuration.connections);
|
|
153
167
|
const triggers =
|
|
154
168
|
typeof configuration.triggers === "function"
|
|
155
169
|
? configuration.triggers({ triggers: createWorkflowTriggers<TConnections>() })
|
|
156
170
|
: configuration.triggers;
|
|
157
|
-
|
|
158
|
-
validateTriggerConnections(triggers, configuration.connections ?? []);
|
|
171
|
+
validateTriggerConnections(triggers, requirements);
|
|
159
172
|
|
|
160
173
|
return {
|
|
161
174
|
_tag: "workflow",
|
|
@@ -163,9 +176,7 @@ export function workflow<
|
|
|
163
176
|
name: configuration.name,
|
|
164
177
|
description: configuration.description,
|
|
165
178
|
triggers,
|
|
166
|
-
...(configuration.connections === undefined
|
|
167
|
-
? {}
|
|
168
|
-
: { connections: configuration.connections }),
|
|
179
|
+
...(configuration.connections === undefined ? {} : { connections: requirements }),
|
|
169
180
|
},
|
|
170
181
|
async handler(
|
|
171
182
|
event: WorkflowEventForTriggers<TTriggers>,
|
|
@@ -175,9 +186,12 @@ export function workflow<
|
|
|
175
186
|
event = await resolveRuntimeInput(event);
|
|
176
187
|
const runMetadata = readRunMetadata();
|
|
177
188
|
const baseContext = createCapabilityContext();
|
|
178
|
-
const capabilityContext: WorkflowContext = {
|
|
189
|
+
const capabilityContext: WorkflowContext<TConnections> = {
|
|
179
190
|
...baseContext,
|
|
180
|
-
connections: createWorkflowConnections(
|
|
191
|
+
connections: createWorkflowConnections(
|
|
192
|
+
baseContext.notion,
|
|
193
|
+
connectionDeclarations,
|
|
194
|
+
),
|
|
181
195
|
...runMetadata,
|
|
182
196
|
step: createStep(runMetadata),
|
|
183
197
|
};
|
|
@@ -240,7 +254,7 @@ type WorkflowStep = {
|
|
|
240
254
|
|
|
241
255
|
/** Context passed to a workflow handler. */
|
|
242
256
|
export type WorkflowContext<
|
|
243
|
-
TConnections extends
|
|
257
|
+
TConnections extends WorkflowConnectionDeclarations = WorkflowConnectionDeclarations,
|
|
244
258
|
> = CapabilityContext & {
|
|
245
259
|
connections: WorkflowConnections<TConnections>;
|
|
246
260
|
} & RunMetadata & {
|