@notionhq/apps 0.0.16 → 0.0.18

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.
Files changed (77) hide show
  1. package/AGENTS.md +27 -0
  2. package/README.md +86 -36
  3. package/dist/connections.d.ts +39 -11
  4. package/dist/connections.d.ts.map +1 -1
  5. package/dist/connections.js +85 -21
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +2 -0
  9. package/dist/notion-as-code/database.d.ts +89 -48
  10. package/dist/notion-as-code/database.d.ts.map +1 -1
  11. package/dist/notion-as-code/database.js +132 -45
  12. package/dist/notion-as-code/database.test.d.ts +2 -0
  13. package/dist/notion-as-code/database.test.d.ts.map +1 -0
  14. package/dist/notion-as-code/handles.d.ts +2 -0
  15. package/dist/notion-as-code/handles.d.ts.map +1 -1
  16. package/dist/notion-as-code/handles.js +2 -0
  17. package/dist/notion-as-code/index.d.ts +5 -2
  18. package/dist/notion-as-code/index.d.ts.map +1 -1
  19. package/dist/notion-as-code/intents.d.ts +36 -3
  20. package/dist/notion-as-code/intents.d.ts.map +1 -1
  21. package/dist/notion-as-code/schema.d.ts +8 -4
  22. package/dist/notion-as-code/schema.d.ts.map +1 -1
  23. package/dist/notion-as-code/view.d.ts +12 -0
  24. package/dist/notion-as-code/view.d.ts.map +1 -0
  25. package/dist/notion-as-code/view.js +13 -0
  26. package/dist/notion-as-code/views-types.test.d.ts +2 -0
  27. package/dist/notion-as-code/views-types.test.d.ts.map +1 -0
  28. package/dist/notion-as-code/views.d.ts +488 -0
  29. package/dist/notion-as-code/views.d.ts.map +1 -0
  30. package/dist/notion-as-code/views.js +0 -0
  31. package/dist/oauth.d.ts +11 -0
  32. package/dist/oauth.d.ts.map +1 -0
  33. package/dist/oauth.js +26 -0
  34. package/dist/providers.generated.d.ts +26 -86
  35. package/dist/providers.generated.d.ts.map +1 -1
  36. package/dist/providers.generated.js +54 -66
  37. package/dist/sync.d.ts +33 -15
  38. package/dist/sync.d.ts.map +1 -1
  39. package/dist/sync.js +12 -0
  40. package/dist/triggers.generated.d.ts +3 -3
  41. package/dist/triggers.generated.d.ts.map +1 -1
  42. package/dist/workflow-state.d.ts +13 -0
  43. package/dist/workflow-state.d.ts.map +1 -0
  44. package/dist/workflow-state.js +107 -0
  45. package/dist/workflow.d.ts +56 -11
  46. package/dist/workflow.d.ts.map +1 -1
  47. package/dist/workflow.js +123 -10
  48. package/docs/BUILD.md +96 -0
  49. package/docs/CONNECTIONS.md +70 -22
  50. package/package.json +1 -1
  51. package/skills/connections/SKILL.md +7 -8
  52. package/skills/notion-as-code/SKILL.md +88 -50
  53. package/skills/sync/SKILL.md +21 -18
  54. package/skills/workflow/SKILL.md +52 -3
  55. package/src/cli/build.test.ts +124 -64
  56. package/src/connections.test.ts +205 -41
  57. package/src/connections.ts +144 -38
  58. package/src/index.ts +2 -0
  59. package/src/notion-as-code/database.test.ts +661 -0
  60. package/src/notion-as-code/database.ts +346 -129
  61. package/src/notion-as-code/handles.ts +2 -0
  62. package/src/notion-as-code/index.ts +71 -1
  63. package/src/notion-as-code/intents.ts +41 -4
  64. package/src/notion-as-code/schema.ts +11 -3
  65. package/src/notion-as-code/view.ts +23 -0
  66. package/src/notion-as-code/views-types.test.ts +59 -0
  67. package/src/notion-as-code/views.ts +573 -0
  68. package/src/oauth.ts +40 -0
  69. package/src/providers.generated.ts +68 -163
  70. package/src/sync.test.ts +295 -0
  71. package/src/sync.ts +85 -21
  72. package/src/triggers.generated.ts +4 -4
  73. package/src/workflow-connections-types.test.ts +16 -10
  74. package/src/workflow-state.ts +152 -0
  75. package/src/workflow-types.test.ts +88 -16
  76. package/src/workflow.test.ts +374 -18
  77. package/src/workflow.ts +211 -23
package/AGENTS.md CHANGED
@@ -11,3 +11,30 @@ matching skill:
11
11
 
12
12
  Resolve these links relative to this package directory. Check the installed SDK
13
13
  declarations for current API details.
14
+
15
+ ## Pull requests for SDK changes
16
+
17
+ For a change to the public SDK, show the user-facing code change in the pull
18
+ request body. Put a short, complete example near the top:
19
+
20
+ ````md
21
+ ## User code
22
+
23
+ ### Before
24
+
25
+ ```ts
26
+ // Existing app code
27
+ ```
28
+
29
+ ### After
30
+
31
+ ```ts
32
+ // Updated app code
33
+ ```
34
+ ````
35
+
36
+ Use the same small example in both sections so reviewers can compare them
37
+ quickly. Include imports and the call that changed when they matter. Show
38
+ normal app code, not internal types, tests, generated files, or provisioning
39
+ output. Explain any required migration steps in plain language below the
40
+ example.
package/README.md CHANGED
@@ -95,12 +95,12 @@ export default workflow({
95
95
  name: "Schedule follow-up",
96
96
  description: "Schedules a follow-up after a page is created",
97
97
  triggers: [triggers.notionPageCreated()],
98
- connections: [connections.calendar()],
98
+ connections: { calendar: connections.calendar() },
99
99
  handler: async () => {},
100
100
  });
101
101
  ```
102
102
 
103
- Declaring the same connection more than once causes the app build to fail.
103
+ The property name is the connection key. Access its typed client with `context.connections.calendar`; use separate keys for separate connections to the same provider.
104
104
 
105
105
  ## Notion API access
106
106
 
@@ -116,22 +116,17 @@ Declare a database with Notion as Code, then pass one of its data-source handles
116
116
  import { database, sync } from "@notionhq/apps";
117
117
  import { Builder } from "@notionhq/apps/builder";
118
118
 
119
- const issues = database({
120
- resourceId: "issues-db",
121
- dataSources: [
122
- {
123
- resourceId: "issues-source",
124
- name: "GitHub Issues",
125
- properties: [
126
- { resourceId: "name", name: "Name", type: "title" },
127
- { resourceId: "github-id", name: "GitHub ID", type: "text" },
128
- ],
129
- },
130
- ],
119
+ const issues = database("issues-db", {
120
+ dataSourceResourceId: "issues-source",
121
+ name: "GitHub Issues",
122
+ schema: {
123
+ Name: { resourceId: "name", type: "title" },
124
+ "GitHub ID": { resourceId: "github-id", type: "text" },
125
+ },
131
126
  });
132
127
 
133
128
  export default sync({
134
- dataSource: issues.dataSources["issues-source"],
129
+ dataSource: issues.dataSource,
135
130
  primaryKey: "GitHub ID",
136
131
  handler: async () => ({
137
132
  changes: [
@@ -146,40 +141,95 @@ export default sync({
146
141
  ```
147
142
 
148
143
  Put each default-exported sync directly in `src/syncs/`. A primary key must be a title
149
- or text property. Do not include that property in an upsert: the SDK fills it from
150
- the change's `key`.
144
+ or text property. Each upsert must include at least one known non-primary-key schema
145
+ property, while any other non-primary-key properties may be omitted; unknown property keys
146
+ are rejected by TypeScript. Do not include the primary-key property in an upsert: the SDK
147
+ fills it from the change's `key`.
151
148
 
152
149
  ## Notion-as-Code databases
153
150
 
154
- Use `properties` to declare a database with one data source:
151
+ Use `schema` and an explicit `dataSourceResourceId` to declare a database with one data source:
155
152
 
156
153
  ```ts
157
154
  import { notion } from "@notionhq/apps/notion-as-code";
158
155
 
159
- const issues = notion.database({
160
- resourceId: "branch-check-issues",
156
+ const singleSourceIssues = notion.database("branch-check-issues", {
157
+ dataSourceResourceId: "branch-check-issues-source",
161
158
  name: "Issues",
162
- properties: [
163
- { resourceId: "issue-title", name: "Name", type: "title" },
164
- { resourceId: "issue-id", name: "ID", type: "text" },
165
- ],
159
+ schema: {
160
+ Name: { resourceId: "issue-title", type: "title" },
161
+ ID: { resourceId: "issue-id", type: "text" },
162
+ },
166
163
  });
167
164
  ```
168
165
 
169
- Pass `issues.dataSource` as the `dataSource` argument to `sync` from `@notionhq/apps`, or use
170
- `issues.dataSource.addPage(...)` to declare a page in the source. The database still exposes
171
- `dataSources` and `addView`.
166
+ Pass `singleSourceIssues.dataSource` as the `dataSource` argument to `sync` from `@notionhq/apps`, or use
167
+ `singleSourceIssues.dataSource.addPage(...)` to declare a page in the source. Both database forms expose `addView`.
172
168
 
173
- For explicit sources, keep using `notion.database({ resourceId, dataSources: [...] })`
174
- and access each source through `handle.dataSources[sourceResourceId]`.
175
- `properties` and `dataSources` are mutually exclusive. Both forms also work with
176
- page and teamspace `addDatabase` helpers.
169
+ For multiple sources, use `datasources` instead of the top-level `schema`:
170
+
171
+ ```ts
172
+ const issues = notion.database("issues-db", {
173
+ datasources: {
174
+ Issues: {
175
+ resourceId: "issues-source",
176
+ schema: {
177
+ Name: { resourceId: "issue-title", type: "title" },
178
+ "GitHub ID": { resourceId: "github-id", type: "text" },
179
+ },
180
+ },
181
+ },
182
+ });
183
+
184
+ issues.datasources.Issues.schema.Name;
185
+ ```
186
+
187
+ `schema` and `datasources` are mutually exclusive. A database declaration must
188
+ include at least one data source or at least one view. A linked-only database
189
+ may omit `datasources`, or use `datasources: {}`, only when `views` is nonempty;
190
+ `{}`, `{ datasources: {} }`, and `{ datasources: {}, views: [] }` are invalid.
191
+ Page and teamspace child helpers accept the same forms through
192
+ `page.addDatabase("database-id", args)` and `teamspace.addDatabase("database-id", args)`.
193
+
194
+ Each `datasources` key is the source's name, and each `schema` key is the
195
+ property's name used for typed access, sync keys, and serialized properties.
196
+ Nested data-source configs and property configs do not accept `name`. The
197
+ top-level database `name` remains supported; in the single-source shorthand it
198
+ supplies both the database and data-source display names. In a multi-source
199
+ declaration, it names the database while each data-source name comes from its key.
200
+
201
+ All database, source, and property IDs remain explicit and must be globally unique.
202
+ No IDs are generated from keys or names. The build emits the existing `dataSources`
203
+ and `properties` arrays with exact IDs and names from those keys; authoring
204
+ `schema`, `datasources`, and database-level `dataSourceResourceId` fields do not
205
+ leak into the serialized database intent. The provisioning JSON envelope and
206
+ server API are unchanged. See [the build guide](docs/BUILD.md#declaring-notion-as-code-databases)
207
+ for complete single-, multi-source, and linked-only examples.
208
+
209
+ Declare database views with `views` or `addView`, or use the top-level `view`
210
+ function from `@notionhq/apps` (`notion.view` is also available). The standalone
211
+ function accepts `ViewArgs`: a `ViewSchema` plus the owning `databaseResourceId`,
212
+ and returns a handle with `resourceId`. Both types are exported from
213
+ `@notionhq/apps/notion-as-code`, with table, board, calendar, list, gallery, feed,
214
+ and timeline variants. View types include sorting, nested filters, grouping,
215
+ property visibility, and layout-specific options.
216
+
217
+ ```ts
218
+ import { view } from "@notionhq/apps";
219
+
220
+ view({
221
+ databaseResourceId: issues.resourceId,
222
+ resourceId: "issues-table",
223
+ type: "table",
224
+ dataSourceResourceId: issues.datasources.Issues.resourceId,
225
+ properties: [{ property: "issue-title", visible: true }],
226
+ sorts: [{ propertyId: "issue-title", direction: "ascending" }],
227
+ });
228
+ ```
177
229
 
178
- The shorthand emits the existing database intent with one source named after the
179
- database and identified by `${resourceId}-source`. That ID must be globally unique.
180
- When converting an existing explicit declaration, use the shorthand only if its
181
- source already has that ID; changing the source ID creates a different resource.
182
- No top-level `properties` field is added to the database intent.
230
+ Each view requires a `dataSourceResourceId`. Property references use property
231
+ resource IDs, not display names. Calendar views require `calendarBy`; timeline
232
+ views require `timelineBy`.
183
233
 
184
234
  ## Custom blocks
185
235
 
@@ -1,15 +1,43 @@
1
- import { type ConnectionProviders } from "./providers.generated.js";
2
- /** A setup requirement. The server decides which providers are available. */
3
- export type WorkflowConnection<TProvider extends string = string, TKey extends string = string> = {
1
+ import { type OAuthConfiguration } from "./oauth.js";
2
+ import { type ConnectionClients } from "./providers.generated.js";
3
+ /** A setup requirement. The property name in a workflow supplies its key. */
4
+ export type WorkflowConnection<TProvider extends string = string> = {
4
5
  type: TProvider;
5
- key?: TKey;
6
+ oauth?: OAuthConfiguration;
6
7
  };
7
- /** Keys declared for one provider in a workflow. */
8
- export type WorkflowConnectionKeys<TConnections extends readonly WorkflowConnection[], TProvider extends string> = WorkflowConnectionKey<Extract<TConnections[number], {
9
- type: TProvider;
10
- }>>;
11
- type WorkflowConnectionKey<TConnection extends WorkflowConnection> = TConnection extends WorkflowConnection ? "key" extends keyof TConnection ? Exclude<TConnection["key"], undefined> : TConnection["type"] : never;
8
+ export type WorkflowConnectionDeclarations = Readonly<Record<string, WorkflowConnection>>;
9
+ /** Serialized connection requirement sent in the workflow manifest. */
10
+ export type WorkflowConnectionRequirement = WorkflowConnection & {
11
+ key: string;
12
+ };
13
+ /** Declared property names belonging to one provider. */
14
+ export type WorkflowConnectionKeys<TConnections extends WorkflowConnectionDeclarations, TProvider extends string> = Extract<{
15
+ [TKey in keyof TConnections]: TConnections[TKey]["type"] extends TProvider ? TKey : never;
16
+ }[keyof TConnections], string>;
12
17
  /** Requirements are declarations, not credentials or permission grants. */
13
- export { connections } from "./providers.generated.js";
14
- export type WorkflowConnections<TConnections extends readonly WorkflowConnection[] = readonly WorkflowConnection[]> = Pick<ConnectionProviders, Extract<keyof ConnectionProviders, TConnections[number]["type"]>>;
18
+ export declare const connections: {
19
+ oauth(options: OAuthConfiguration): WorkflowConnection<"oauth">;
20
+ calendar: () => WorkflowConnection<"calendar">;
21
+ slack: () => WorkflowConnection<"slack">;
22
+ googleDriveOauth: () => WorkflowConnection<"googleDriveOauth">;
23
+ discord: () => WorkflowConnection<"discord">;
24
+ cursor: () => WorkflowConnection<"cursor">;
25
+ box: () => WorkflowConnection<"box">;
26
+ confluence: () => WorkflowConnection<"confluence">;
27
+ gmail: () => WorkflowConnection<"gmail">;
28
+ googleCalendar: () => WorkflowConnection<"googleCalendar">;
29
+ googleDrive: () => WorkflowConnection<"googleDrive">;
30
+ outlook: () => WorkflowConnection<"outlook">;
31
+ salesforce: () => WorkflowConnection<"salesforce">;
32
+ };
33
+ export type { OAuthConfiguration } from "./oauth.js";
34
+ export type OAuthConnection = {
35
+ accessToken(): Promise<string>;
36
+ };
37
+ type WorkflowConnectionClients = ConnectionClients & {
38
+ oauth: OAuthConnection;
39
+ };
40
+ export type WorkflowConnections<TConnections extends WorkflowConnectionDeclarations = WorkflowConnectionDeclarations> = {
41
+ readonly [TKey in keyof TConnections]: WorkflowConnectionClients[Extract<keyof WorkflowConnectionClients, TConnections[TKey]["type"]>];
42
+ };
15
43
  //# sourceMappingURL=connections.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6B,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/F,6EAA6E;AAC7E,MAAM,MAAM,kBAAkB,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,SAAS,MAAM,GAAG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AE,kBAAkB,CAAC,CAAC,CAAC;AAE1F,uEAAuE;AACvE,MAAM,MAAM,6BAA6B,GAAG,kBAAkB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF,yDAAyD;AACzD,MAAM,MAAM,sBAAsB,CACjC,YAAY,SAAS,8BAA8B,EACnD,SAAS,SAAS,MAAM,IACrB,OAAO,CACV;KACE,IAAI,IAAI,MAAM,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,SAAS,GAAG,IAAI,GAAG,KAAK;CACzF,CAAC,MAAM,YAAY,CAAC,EACrB,MAAM,CACN,CAAC;AAIF,2EAA2E;AAC3E,eAAO,MAAM,WAAW;mBAER,kBAAkB,GAAG,kBAAkB,CAAC,OAAO,CAAC;;;;;;;;;;;;;CAI/D,CAAC;AACF,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG;IAAE,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC;AAEjE,KAAK,yBAAyB,GAAG,iBAAiB,GAAG;IAAE,KAAK,EAAE,eAAe,CAAA;CAAE,CAAC;AAIhF,MAAM,MAAM,mBAAmB,CAC9B,YAAY,SAAS,8BAA8B,GAAG,8BAA8B,IACjF;IACH,QAAQ,EAAE,IAAI,IAAI,MAAM,YAAY,GAAG,yBAAyB,CAAC,OAAO,CACvE,MAAM,yBAAyB,EAC/B,YAAY,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAC1B,CAAC;CACF,CAAC"}
@@ -1,25 +1,60 @@
1
+ import { validateOAuthConfiguration } from "./oauth.js";
1
2
  import { connectionTriggerDefinitions } from "./connection-trigger-definitions.generated.js";
2
- import { createConnectionProviders } from "./providers.generated.js";
3
- import { connections } from "./providers.generated.js";
4
- function validateConnectionRequirements(requirements) {
5
- if (requirements.length > 100) throw new Error("Workflows support at most 100 connections.");
6
- const keys = /* @__PURE__ */ new Set();
7
- for (const requirement of requirements) {
8
- if (!requirement.type) throw new Error("A workflow connection needs a provider type.");
9
- const key = requirement.key ?? requirement.type;
10
- if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(key)) {
3
+ import {
4
+ connections as providerConnections,
5
+ createConnectionClient
6
+ } from "./providers.generated.js";
7
+ const connections = {
8
+ ...providerConnections,
9
+ oauth(options) {
10
+ validateOAuthConfiguration(options);
11
+ return { type: "oauth", oauth: structuredClone(options) };
12
+ }
13
+ };
14
+ function normalizeConnectionRequirements(declarations) {
15
+ if (typeof declarations !== "object" || declarations === null || Array.isArray(declarations)) {
16
+ throw new Error("Workflow connections must be an object keyed by connection name.");
17
+ }
18
+ const prototype = Object.getPrototypeOf(declarations);
19
+ if (prototype !== Object.prototype && prototype !== null) {
20
+ throw new Error("Workflow connections must contain only own connection declarations.");
21
+ }
22
+ const keys = Object.keys(declarations);
23
+ if (Reflect.ownKeys(declarations).length !== keys.length) {
24
+ throw new Error("Workflow connection keys must be enumerable strings.");
25
+ }
26
+ if (keys.length > 100) throw new Error("Workflows support at most 100 connections.");
27
+ return Object.entries(declarations).map(([key, requirement]) => {
28
+ if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/.test(key) || ["__proto__", "prototype", "constructor"].includes(key)) {
11
29
  throw new Error("Invalid workflow connection key: " + key);
12
30
  }
13
- if (keys.has(key)) throw new Error("Duplicate workflow connection: " + key);
14
- keys.add(key);
15
- }
31
+ if (typeof requirement !== "object" || requirement === null || typeof requirement.type !== "string" || !requirement.type || !Object.hasOwn(requirement, "type")) {
32
+ throw new Error("A workflow connection needs a provider type.");
33
+ }
34
+ if ("key" in requirement)
35
+ throw new Error(
36
+ "Declare a connection key as its workflow object property, not in the provider options."
37
+ );
38
+ if (requirement.type === "oauth") {
39
+ if (!requirement.oauth)
40
+ throw new Error("OAuth connections require provider configuration.");
41
+ validateOAuthConfiguration(requirement.oauth);
42
+ } else if (requirement.oauth !== void 0) {
43
+ throw new Error("OAuth configuration is only valid on OAuth connections.");
44
+ }
45
+ return {
46
+ type: requirement.type,
47
+ key,
48
+ ...requirement.oauth === void 0 ? {} : { oauth: structuredClone(requirement.oauth) }
49
+ };
50
+ });
16
51
  }
17
52
  function validateTriggerConnections(triggers, requirements) {
18
53
  const seen = /* @__PURE__ */ new Set();
19
54
  for (const trigger of triggers) {
20
55
  if (!("connectionKey" in trigger) || trigger.connectionKey === void 0) continue;
21
56
  const requirement = requirements.find(
22
- (connection) => (connection.key ?? connection.type) === trigger.connectionKey
57
+ (connection) => connection.key === trigger.connectionKey
23
58
  );
24
59
  const definition = connectionTriggerDefinitions.find(
25
60
  (definition2) => definition2.type === trigger.type
@@ -37,8 +72,29 @@ function validateTriggerConnections(triggers, requirements) {
37
72
  seen.add(identity);
38
73
  }
39
74
  }
40
- function createWorkflowConnections(notion) {
75
+ function createWorkflowConnections(notion, declarations) {
76
+ const requirements = normalizeConnectionRequirements(declarations ?? {});
41
77
  const rawBindings = process.env.NOTION_CONNECTION_BINDINGS;
78
+ const clients = {};
79
+ Object.setPrototypeOf(clients, null);
80
+ for (const requirement of requirements) {
81
+ let client;
82
+ Object.defineProperty(clients, requirement.key, {
83
+ enumerable: true,
84
+ get() {
85
+ if (client) return client;
86
+ const binding = resolveBinding(requirement.key);
87
+ if (binding.type !== requirement.type) {
88
+ throw new Error(
89
+ `Workflow connection "${requirement.key}" is ${binding.type}, not ${requirement.type}.`
90
+ );
91
+ }
92
+ client = requirement.type === "oauth" ? createOAuthConnection(binding) : createConnectionClient(requirement.type, invoker(binding));
93
+ return client;
94
+ }
95
+ });
96
+ }
97
+ return Object.freeze(clients);
42
98
  function resolveBinding(key) {
43
99
  const bindings = JSON.parse(rawBindings ?? "[]");
44
100
  if (!Array.isArray(bindings) || !bindings.every(isConnectionBinding)) {
@@ -52,11 +108,7 @@ function createWorkflowConnections(notion) {
52
108
  }
53
109
  return { ...matches[0] };
54
110
  }
55
- function invoker(provider, key) {
56
- const binding = resolveBinding(key);
57
- if (binding.type !== provider) {
58
- throw new Error(`Workflow connection "${key}" is ${binding.type}, not ${provider}.`);
59
- }
111
+ function invoker(binding) {
60
112
  return async (action, args) => {
61
113
  const response = await notion.request({
62
114
  path: "tools/run/internal",
@@ -66,7 +118,19 @@ function createWorkflowConnections(notion) {
66
118
  return response.result;
67
119
  };
68
120
  }
69
- return createConnectionProviders(invoker);
121
+ }
122
+ function createOAuthConnection(binding) {
123
+ const envKey = `NOTION_OAUTH_CONNECTION_${binding.id.replaceAll("-", "").toUpperCase()}`;
124
+ const token = process.env[envKey];
125
+ return {
126
+ async accessToken() {
127
+ if (!token)
128
+ throw new Error(
129
+ `Workflow OAuth connection "${binding.key}" requires authorization.`
130
+ );
131
+ return token;
132
+ }
133
+ };
70
134
  }
71
135
  function isConnectionBinding(value) {
72
136
  return typeof value === "object" && value !== null && "key" in value && typeof value.key === "string" && value.key.length > 0 && "type" in value && typeof value.type === "string" && value.type.length > 0 && "id" in value && typeof value.id === "string" && value.id.length > 0;
@@ -74,6 +138,6 @@ function isConnectionBinding(value) {
74
138
  export {
75
139
  connections,
76
140
  createWorkflowConnections,
77
- validateConnectionRequirements,
141
+ normalizeConnectionRequirements,
78
142
  validateTriggerConnections
79
143
  };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,8 @@ export { customAgent } from "./notion-as-code/custom-agent.js";
3
3
  export { database } from "./notion-as-code/database.js";
4
4
  export { page } from "./notion-as-code/page.js";
5
5
  export { teamspace } from "./notion-as-code/teamspace.js";
6
+ export { view } from "./notion-as-code/view.js";
6
7
  export { sync } from "./sync.js";
7
8
  export { workflow } from "./workflow.js";
9
+ export type { WorkflowState, WorkflowStateValue } from "./workflow-state.js";
8
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { customAgent } from "./notion-as-code/custom-agent.js";
3
3
  import { database } from "./notion-as-code/database.js";
4
4
  import { page } from "./notion-as-code/page.js";
5
5
  import { teamspace } from "./notion-as-code/teamspace.js";
6
+ import { view } from "./notion-as-code/view.js";
6
7
  import { sync } from "./sync.js";
7
8
  import { workflow } from "./workflow.js";
8
9
  export {
@@ -12,5 +13,6 @@ export {
12
13
  page,
13
14
  sync,
14
15
  teamspace,
16
+ view,
15
17
  workflow
16
18
  };
@@ -1,67 +1,108 @@
1
1
  import type { Database } from "../database.js";
2
- import { type DataSourceDefinition, type NotionAsCodeIcon, type NotionAsCodeProperty, type Parent, type ResourceId } from "./intents.js";
2
+ import { type DatabaseIntent, type NotionAsCodeIcon, type NotionAsCodeSchema, type Parent, type ResourceId } from "./intents.js";
3
3
  import { type ChildPageArgs, type PageHandle } from "./page.js";
4
- import { type AppsSchemaForProperties } from "./schema.js";
5
- /** Input for declaring a database and its optional data sources. */
6
- export type DatabaseArgs<DataSources extends readonly DataSourceDefinition[] = readonly DataSourceDefinition[]> = {
4
+ import { type AppsSchemaForSchema } from "./schema.js";
5
+ import type { ViewSchema } from "./views.js";
6
+ /** Reuse serialized database intent metadata, excluding identity, parent, and sources. */
7
+ type DatabaseMetadata = Omit<DatabaseIntent, "resourceId" | "parent" | "dataSources">;
8
+ type NonEmptyViewSchemas = readonly [ViewSchema, ...ViewSchema[]];
9
+ /** A keyed data-source declaration; the containing map key supplies the serialized source name. */
10
+ export type DataSourceArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
7
11
  resourceId: ResourceId;
8
- /** Omit to create a private top-level database in the Apps workspace. */
9
- parent?: Parent;
10
- dataSources?: DataSources;
11
- views?: readonly unknown[];
12
+ name?: never;
13
+ schema: Schema;
12
14
  icon?: NotionAsCodeIcon;
13
- cover?: unknown;
14
- hideDataSourceTitle?: boolean;
15
- hideDatabaseTitleIfEmpty?: boolean;
16
- name?: string;
17
- description?: string;
18
15
  };
19
- /** Input for adding a database beneath an existing resource. */
20
- export type ChildDatabaseArgs<DataSources extends readonly DataSourceDefinition[] = readonly DataSourceDefinition[]> = Omit<DatabaseArgs<DataSources>, "parent">;
21
- /** Single-source shorthand; the source ID is `${resourceId}-source`. */
22
- export type SingleSourceDatabaseArgs<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = Omit<DatabaseArgs, "dataSources" | "name"> & {
16
+ /** Data sources keyed by the names used to access their handles. */
17
+ export type DataSourceMap = Record<string, DataSourceArgs>;
18
+ /**
19
+ * Single-source inputs require a name for both database and source. `datasources?: never`
20
+ * keeps this form exclusive even when callers pass a predeclared object.
21
+ */
22
+ type SingleSourceDatabaseOptions<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = Omit<DatabaseMetadata, "name"> & {
23
+ dataSourceResourceId: ResourceId;
23
24
  name: string;
24
- properties: Properties;
25
- dataSources?: never;
25
+ schema: Schema;
26
+ datasources?: never;
26
27
  };
27
- export type ChildSingleSourceDatabaseArgs<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = Omit<SingleSourceDatabaseArgs<Properties>, "parent">;
28
- /** Resolves one data source ID to the properties declared for it. */
29
- type DataSourcePropertiesForResourceId<DataSources extends readonly DataSourceDefinition[], ResourceId extends DataSources[number]["resourceId"]> = Extract<DataSources[number], {
30
- resourceId: ResourceId;
31
- }> extends DataSourceDefinition<infer Properties> ? Properties : never;
32
- /** Handle for a data source and the Apps database it backs. */
33
- export type DataSourceHandle<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = {
28
+ /** Top-level single-source inputs may choose a parent; page.addDatabase/teamspace.addDatabase bind it instead. */
29
+ export type SingleSourceDatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = SingleSourceDatabaseOptions<Schema> & {
30
+ parent?: Parent;
31
+ };
32
+ /**
33
+ * Multi-source inputs preserve source-map keys. The NoInfer guard makes the
34
+ * emptiness check inspect the inferred map instead of widening it to the broad
35
+ * DataSourceMap constraint.
36
+ */
37
+ type MultiSourceDatabaseOptions<DataSources extends DataSourceMap = DataSourceMap> = DatabaseMetadata & {
38
+ datasources: DataSources;
39
+ dataSourceResourceId?: never;
40
+ schema?: never;
41
+ } & (keyof NoInfer<DataSources> extends never ? {
42
+ views: NonEmptyViewSchemas;
43
+ } : {
44
+ views?: readonly ViewSchema[];
45
+ });
46
+ /** Top-level multi-source inputs may choose a parent; page.addDatabase/teamspace.addDatabase bind it instead. */
47
+ export type MultiSourceDatabaseArgs<DataSources extends DataSourceMap = DataSourceMap> = MultiSourceDatabaseOptions<DataSources> & {
48
+ parent?: Parent;
49
+ };
50
+ /** Linked-only databases use a nonempty typed view tuple and no authored source map. */
51
+ type ViewOnlyDatabaseOptions = DatabaseMetadata & {
52
+ datasources?: never;
53
+ dataSourceResourceId?: never;
54
+ schema?: never;
55
+ views: NonEmptyViewSchemas;
56
+ };
57
+ type ViewOnlyDatabaseArgs = ViewOnlyDatabaseOptions & {
58
+ parent?: Parent;
59
+ };
60
+ /** Remove parent because page.addDatabase/teamspace.addDatabase supplies it. */
61
+ export type ChildSingleSourceDatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = Omit<SingleSourceDatabaseArgs<Schema>, "parent">;
62
+ /** Remove parent because page.addDatabase/teamspace.addDatabase supplies it. */
63
+ export type ChildMultiSourceDatabaseArgs<DataSources extends DataSourceMap = DataSourceMap> = Omit<MultiSourceDatabaseArgs<DataSources>, "parent">;
64
+ /** Input for declaring a database and its data sources. */
65
+ export type DatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema, DataSources extends DataSourceMap = DataSourceMap> = SingleSourceDatabaseArgs<Schema> | MultiSourceDatabaseArgs<DataSources> | ViewOnlyDatabaseArgs;
66
+ /**
67
+ * Child inputs omit parent from each union member separately. `page.addDatabase`
68
+ * and `teamspace.addDatabase` use this shape for their shared child factory.
69
+ */
70
+ export type ChildDatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema, DataSources extends DataSourceMap = DataSourceMap> = ChildSingleSourceDatabaseArgs<Schema> | ChildMultiSourceDatabaseArgs<DataSources> | Omit<ViewOnlyDatabaseArgs, "parent">;
71
+ /** A source handle retains its keyed authoring schema for sync inference. */
72
+ export type DataSourceHandle<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
34
73
  readonly resourceId: string;
35
- readonly schema: Properties;
36
- readonly database: Database<AppsSchemaForProperties<Properties>>;
74
+ readonly schema: Schema;
75
+ readonly database: Database<AppsSchemaForSchema<Schema>>;
37
76
  addPage: (args: ChildPageArgs) => PageHandle;
38
77
  };
39
- /** Handle for a database with data sources indexed by resource ID. */
40
- export type DatabaseHandle<DataSources extends readonly DataSourceDefinition[] = readonly DataSourceDefinition[]> = {
78
+ type DatabaseHandleBase = {
41
79
  readonly resourceId: string;
42
- readonly dataSources: {
43
- readonly [ResourceId in DataSources[number]["resourceId"]]: DataSourceHandle<DataSourcePropertiesForResourceId<DataSources, ResourceId>>;
80
+ addView: (view: ViewSchema) => void;
81
+ };
82
+ /** Map each authoring source key to a handle backed by that source's own schema. */
83
+ export type DatabaseHandle<DataSources extends DataSourceMap = DataSourceMap> = DatabaseHandleBase & {
84
+ readonly datasources: {
85
+ readonly [DataSourceName in keyof DataSources]: DataSourceHandle<DataSources[DataSourceName]["schema"]>;
44
86
  };
45
- addView: (view: unknown) => void;
46
87
  };
47
- /** A database whose sole data source is available without an ID lookup. */
48
- export type SingleSourceDatabaseHandle<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = DatabaseHandle<readonly DataSourceDefinition<Properties>[]> & {
49
- readonly dataSource: DataSourceHandle<Properties>;
88
+ /** A database whose sole data source is available without a key lookup. */
89
+ export type SingleSourceDatabaseHandle<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = DatabaseHandleBase & {
90
+ readonly dataSource: DataSourceHandle<Schema>;
50
91
  };
92
+ /**
93
+ * Overloaded callable used by page.addDatabase/teamspace.addDatabase. Each form
94
+ * returns its matching handle while preserving literal source and schema inference.
95
+ */
51
96
  export type ChildDatabaseFactory = {
52
- <const Properties extends readonly NotionAsCodeProperty[]>(args: ChildSingleSourceDatabaseArgs<Properties>): SingleSourceDatabaseHandle<Properties>;
53
- <const DataSources extends readonly DataSourceDefinition[]>(args: ChildDatabaseArgs<DataSources> & {
54
- properties?: never;
55
- }): DatabaseHandle<DataSources>;
97
+ <const Schema extends NotionAsCodeSchema>(databaseResourceId: ResourceId, args: ChildSingleSourceDatabaseArgs<Schema>): SingleSourceDatabaseHandle<Schema>;
98
+ <const DataSources extends DataSourceMap>(databaseResourceId: ResourceId, args: ChildMultiSourceDatabaseArgs<DataSources>): DatabaseHandle<DataSources>;
99
+ (databaseResourceId: ResourceId, args: Omit<ViewOnlyDatabaseArgs, "parent">): DatabaseHandle<{}>;
56
100
  };
57
- /** Declare a database, defaulting to a private top-level database in the Apps workspace. */
58
- export declare function database<const Properties extends readonly NotionAsCodeProperty[]>(args: SingleSourceDatabaseArgs<Properties>): SingleSourceDatabaseHandle<Properties>;
59
- export declare function database<const DataSources extends readonly DataSourceDefinition[]>(args: DatabaseArgs<DataSources> & {
60
- properties?: never;
61
- }): DatabaseHandle<DataSources>;
62
- /** Bind both database declaration forms to an existing parent. */
101
+ /** Declare a database, defaulting to the Apps workspace. */
102
+ export declare function database<const Schema extends NotionAsCodeSchema>(databaseResourceId: ResourceId, args: SingleSourceDatabaseArgs<Schema>): SingleSourceDatabaseHandle<Schema>;
103
+ export declare function database<const DataSources extends DataSourceMap>(databaseResourceId: ResourceId, args: MultiSourceDatabaseArgs<DataSources>): DatabaseHandle<DataSources>;
104
+ export declare function database(databaseResourceId: ResourceId, args: ViewOnlyDatabaseArgs): DatabaseHandle<{}>;
105
+ /** Bind a parent for page.addDatabase/teamspace.addDatabase. */
63
106
  export declare function createChildDatabase(parent: Parent): ChildDatabaseFactory;
64
- /** Record a database declaration and create handles for each of its data sources. */
65
- export declare function createDatabase(args: DatabaseArgs, parent: Parent): DatabaseHandle;
66
107
  export {};
67
108
  //# sourceMappingURL=database.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/database.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAEN,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,aAAa,EA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