@notionhq/apps 0.0.15 → 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/AGENTS.md +13 -0
- package/README.md +69 -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 +26 -3
- package/dist/notion-as-code/database.d.ts.map +1 -1
- package/dist/notion-as-code/database.js +27 -0
- 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 +4 -1
- 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/page.d.ts +3 -3
- package/dist/notion-as-code/page.d.ts.map +1 -1
- package/dist/notion-as-code/page.js +2 -7
- package/dist/notion-as-code/teamspace.d.ts +3 -3
- package/dist/notion-as-code/teamspace.d.ts.map +1 -1
- package/dist/notion-as-code/teamspace.js +2 -7
- 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 +3 -1
- package/skills/connections/SKILL.md +85 -0
- package/skills/custom-blocks/SKILL.md +45 -0
- package/skills/notion-as-code/SKILL.md +195 -0
- package/skills/sync/SKILL.md +98 -0
- package/skills/workflow/SKILL.md +123 -0
- package/src/cli/build.test.ts +95 -3
- 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 +75 -5
- package/src/notion-as-code/handles.ts +2 -0
- package/src/notion-as-code/index.ts +59 -0
- package/src/notion-as-code/intents.ts +2 -2
- package/src/notion-as-code/page.ts +3 -11
- package/src/notion-as-code/teamspace.ts +3 -11
- 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/AGENTS.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Agent instructions
|
|
2
|
+
|
|
3
|
+
Before creating, modifying, or troubleshooting an App capability, read the
|
|
4
|
+
matching skill:
|
|
5
|
+
|
|
6
|
+
- [Workflows](./skills/workflow/SKILL.md)
|
|
7
|
+
- [Connections](./skills/connections/SKILL.md)
|
|
8
|
+
- [Database syncs](./skills/sync/SKILL.md)
|
|
9
|
+
- [Custom blocks](./skills/custom-blocks/SKILL.md)
|
|
10
|
+
- [Notion as Code](./skills/notion-as-code/SKILL.md)
|
|
11
|
+
|
|
12
|
+
Resolve these links relative to this package directory. Check the installed SDK
|
|
13
|
+
declarations for current API details.
|
package/README.md
CHANGED
|
@@ -63,6 +63,16 @@ uses explicit exports and does not re-export utility types or the custom-block b
|
|
|
63
63
|
keep using `@notionhq/apps/custom-blocks` and `@notionhq/apps/react`; the root includes
|
|
64
64
|
Node-only workflow code. Styles stay in `@notionhq/apps/nds.css`.
|
|
65
65
|
|
|
66
|
+
## Agent skills
|
|
67
|
+
|
|
68
|
+
The package includes skills for [workflows](./skills/workflow/SKILL.md),
|
|
69
|
+
[connections](./skills/connections/SKILL.md),
|
|
70
|
+
[database syncs](./skills/sync/SKILL.md),
|
|
71
|
+
[custom blocks](./skills/custom-blocks/SKILL.md), and
|
|
72
|
+
[Notion as Code](./skills/notion-as-code/SKILL.md). Read the matching skill
|
|
73
|
+
before creating, modifying, or troubleshooting an App capability. Shipping the
|
|
74
|
+
skills with the SDK keeps their instructions up to date with the installed API.
|
|
75
|
+
|
|
66
76
|
## Development
|
|
67
77
|
|
|
68
78
|
1. Install [mise](https://mise.jdx.dev/getting-started.html)
|
|
@@ -85,12 +95,12 @@ export default workflow({
|
|
|
85
95
|
name: "Schedule follow-up",
|
|
86
96
|
description: "Schedules a follow-up after a page is created",
|
|
87
97
|
triggers: [triggers.notionPageCreated()],
|
|
88
|
-
connections:
|
|
98
|
+
connections: { calendar: connections.calendar() },
|
|
89
99
|
handler: async () => {},
|
|
90
100
|
});
|
|
91
101
|
```
|
|
92
102
|
|
|
93
|
-
|
|
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.
|
|
94
104
|
|
|
95
105
|
## Notion API access
|
|
96
106
|
|
|
@@ -139,6 +149,63 @@ Put each default-exported sync directly in `src/syncs/`. A primary key must be a
|
|
|
139
149
|
or text property. Do not include that property in an upsert: the SDK fills it from
|
|
140
150
|
the change's `key`.
|
|
141
151
|
|
|
152
|
+
## Notion-as-Code databases
|
|
153
|
+
|
|
154
|
+
Use `properties` to declare a database with one data source:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { notion } from "@notionhq/apps/notion-as-code";
|
|
158
|
+
|
|
159
|
+
const issues = notion.database({
|
|
160
|
+
resourceId: "branch-check-issues",
|
|
161
|
+
name: "Issues",
|
|
162
|
+
properties: [
|
|
163
|
+
{ resourceId: "issue-title", name: "Name", type: "title" },
|
|
164
|
+
{ resourceId: "issue-id", name: "ID", type: "text" },
|
|
165
|
+
],
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
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`.
|
|
172
|
+
|
|
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.
|
|
177
|
+
|
|
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.
|
|
183
|
+
|
|
184
|
+
Declare database views with `views` or `addView`, or use the top-level `view`
|
|
185
|
+
function from `@notionhq/apps` (`notion.view` is also available). The standalone
|
|
186
|
+
function accepts `ViewArgs`: a `ViewSchema` plus the owning `databaseResourceId`,
|
|
187
|
+
and returns a handle with `resourceId`. Both types are exported from
|
|
188
|
+
`@notionhq/apps/notion-as-code`, with table, board, calendar, list, gallery, feed,
|
|
189
|
+
and timeline variants. View types include sorting, nested filters, grouping,
|
|
190
|
+
property visibility, and layout-specific options.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { view } from "@notionhq/apps";
|
|
194
|
+
|
|
195
|
+
view({
|
|
196
|
+
databaseResourceId: issues.resourceId,
|
|
197
|
+
resourceId: "issues-table",
|
|
198
|
+
type: "table",
|
|
199
|
+
dataSourceResourceId: issues.dataSource.resourceId,
|
|
200
|
+
properties: [{ property: "issue-title", visible: true }],
|
|
201
|
+
sorts: [{ propertyId: "issue-title", direction: "ascending" }],
|
|
202
|
+
});
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Each view requires a `dataSourceResourceId`. Property references use property
|
|
206
|
+
resource IDs, not display names. Calendar views require `calendarBy`; timeline
|
|
207
|
+
views require `timelineBy`.
|
|
208
|
+
|
|
142
209
|
## Custom blocks
|
|
143
210
|
|
|
144
211
|
Declare browser blocks in `src/customBlocks/<key>.ts`:
|
package/dist/connections.d.ts
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
6
|
+
oauth?: OAuthConfiguration;
|
|
6
7
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
14
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIjF,OAAO,EAGN,KAAK,iBAAiB,EACtB,MAAM,0BAA0B,CAAC;AA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js
CHANGED
|
@@ -1,25 +1,60 @@
|
|
|
1
|
+
import { validateOAuthConfiguration } from "./oauth.js";
|
|
1
2
|
import { connectionTriggerDefinitions } from "./connection-trigger-definitions.generated.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 (
|
|
14
|
-
|
|
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) =>
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
141
|
+
normalizeConnectionRequirements,
|
|
78
142
|
validateTriggerConnections
|
|
79
143
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ 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";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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"}
|
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
|
};
|
|
@@ -2,13 +2,14 @@ import type { Database } from "../database.js";
|
|
|
2
2
|
import { type DataSourceDefinition, type NotionAsCodeIcon, type NotionAsCodeProperty, type Parent, type ResourceId } from "./intents.js";
|
|
3
3
|
import { type ChildPageArgs, type PageHandle } from "./page.js";
|
|
4
4
|
import { type AppsSchemaForProperties } from "./schema.js";
|
|
5
|
+
import type { ViewSchema } from "./views.js";
|
|
5
6
|
/** Input for declaring a database and its optional data sources. */
|
|
6
7
|
export type DatabaseArgs<DataSources extends readonly DataSourceDefinition[] = readonly DataSourceDefinition[]> = {
|
|
7
8
|
resourceId: ResourceId;
|
|
8
9
|
/** Omit to create a private top-level database in the Apps workspace. */
|
|
9
10
|
parent?: Parent;
|
|
10
11
|
dataSources?: DataSources;
|
|
11
|
-
views?: readonly
|
|
12
|
+
views?: readonly ViewSchema[];
|
|
12
13
|
icon?: NotionAsCodeIcon;
|
|
13
14
|
cover?: unknown;
|
|
14
15
|
hideDataSourceTitle?: boolean;
|
|
@@ -18,6 +19,13 @@ export type DatabaseArgs<DataSources extends readonly DataSourceDefinition[] = r
|
|
|
18
19
|
};
|
|
19
20
|
/** Input for adding a database beneath an existing resource. */
|
|
20
21
|
export type ChildDatabaseArgs<DataSources extends readonly DataSourceDefinition[] = readonly DataSourceDefinition[]> = Omit<DatabaseArgs<DataSources>, "parent">;
|
|
22
|
+
/** Single-source shorthand; the source ID is `${resourceId}-source`. */
|
|
23
|
+
export type SingleSourceDatabaseArgs<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = Omit<DatabaseArgs, "dataSources" | "name"> & {
|
|
24
|
+
name: string;
|
|
25
|
+
properties: Properties;
|
|
26
|
+
dataSources?: never;
|
|
27
|
+
};
|
|
28
|
+
export type ChildSingleSourceDatabaseArgs<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = Omit<SingleSourceDatabaseArgs<Properties>, "parent">;
|
|
21
29
|
/** Resolves one data source ID to the properties declared for it. */
|
|
22
30
|
type DataSourcePropertiesForResourceId<DataSources extends readonly DataSourceDefinition[], ResourceId extends DataSources[number]["resourceId"]> = Extract<DataSources[number], {
|
|
23
31
|
resourceId: ResourceId;
|
|
@@ -35,10 +43,25 @@ export type DatabaseHandle<DataSources extends readonly DataSourceDefinition[] =
|
|
|
35
43
|
readonly dataSources: {
|
|
36
44
|
readonly [ResourceId in DataSources[number]["resourceId"]]: DataSourceHandle<DataSourcePropertiesForResourceId<DataSources, ResourceId>>;
|
|
37
45
|
};
|
|
38
|
-
addView: (view:
|
|
46
|
+
addView: (view: ViewSchema) => void;
|
|
47
|
+
};
|
|
48
|
+
/** A database whose sole data source is available without an ID lookup. */
|
|
49
|
+
export type SingleSourceDatabaseHandle<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = DatabaseHandle<readonly DataSourceDefinition<Properties>[]> & {
|
|
50
|
+
readonly dataSource: DataSourceHandle<Properties>;
|
|
51
|
+
};
|
|
52
|
+
export type ChildDatabaseFactory = {
|
|
53
|
+
<const Properties extends readonly NotionAsCodeProperty[]>(args: ChildSingleSourceDatabaseArgs<Properties>): SingleSourceDatabaseHandle<Properties>;
|
|
54
|
+
<const DataSources extends readonly DataSourceDefinition[]>(args: ChildDatabaseArgs<DataSources> & {
|
|
55
|
+
properties?: never;
|
|
56
|
+
}): DatabaseHandle<DataSources>;
|
|
39
57
|
};
|
|
40
58
|
/** Declare a database, defaulting to a private top-level database in the Apps workspace. */
|
|
41
|
-
export declare function database<const
|
|
59
|
+
export declare function database<const Properties extends readonly NotionAsCodeProperty[]>(args: SingleSourceDatabaseArgs<Properties>): SingleSourceDatabaseHandle<Properties>;
|
|
60
|
+
export declare function database<const DataSources extends readonly DataSourceDefinition[]>(args: DatabaseArgs<DataSources> & {
|
|
61
|
+
properties?: never;
|
|
62
|
+
}): DatabaseHandle<DataSources>;
|
|
63
|
+
/** Bind both database declaration forms to an existing parent. */
|
|
64
|
+
export declare function createChildDatabase(parent: Parent): ChildDatabaseFactory;
|
|
42
65
|
/** Record a database declaration and create handles for each of its data sources. */
|
|
43
66
|
export declare function createDatabase(args: DatabaseArgs, parent: Parent): DatabaseHandle;
|
|
44
67
|
export {};
|
|
@@ -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,E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wBAAgB,QAAQ,CAAC,KAAK,CAAC,WAAW,SAAS,SAAS,oBAAoB,EAAE,EACjF,IAAI,EAAE,YAAY,CAAC,WAAW,CAAC,GAAG;IAAE,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACtD,cAAc,CAAC,WAAW,CAAC,CAAC;AA+B/B,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAgBxE;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CA+BjF"}
|
|
@@ -13,8 +13,34 @@ function database(args) {
|
|
|
13
13
|
type: "resourceId",
|
|
14
14
|
resourceId: APPS_WORKSPACE_RESOURCE_ID
|
|
15
15
|
};
|
|
16
|
+
if ("properties" in args) {
|
|
17
|
+
if (args.dataSources !== void 0) {
|
|
18
|
+
throw new Error("Specify either properties or dataSources, not both");
|
|
19
|
+
}
|
|
20
|
+
const { properties, ...databaseArgs } = args;
|
|
21
|
+
const source = {
|
|
22
|
+
resourceId: `${args.resourceId}-source`,
|
|
23
|
+
name: args.name,
|
|
24
|
+
properties
|
|
25
|
+
};
|
|
26
|
+
const handle = createDatabase({ ...databaseArgs, dataSources: [source] }, parent);
|
|
27
|
+
const dataSource = handle.dataSources[source.resourceId];
|
|
28
|
+
if (!dataSource) {
|
|
29
|
+
throw new Error(`Missing data source "${source.resourceId}"`);
|
|
30
|
+
}
|
|
31
|
+
return { ...handle, dataSource };
|
|
32
|
+
}
|
|
16
33
|
return createDatabase(args, parent);
|
|
17
34
|
}
|
|
35
|
+
function createChildDatabase(parent) {
|
|
36
|
+
function addDatabase(args) {
|
|
37
|
+
if ("properties" in args) {
|
|
38
|
+
return database({ ...args, parent });
|
|
39
|
+
}
|
|
40
|
+
return database({ ...args, parent });
|
|
41
|
+
}
|
|
42
|
+
return addDatabase;
|
|
43
|
+
}
|
|
18
44
|
function createDatabase(args, parent) {
|
|
19
45
|
assertUserResourceId(args.resourceId);
|
|
20
46
|
const dataSources = args.dataSources ?? [];
|
|
@@ -72,6 +98,7 @@ function createDataSourceHandle(dataSource) {
|
|
|
72
98
|
};
|
|
73
99
|
}
|
|
74
100
|
export {
|
|
101
|
+
createChildDatabase,
|
|
75
102
|
createDatabase,
|
|
76
103
|
database
|
|
77
104
|
};
|
|
@@ -3,11 +3,13 @@ import { database } from "./database.js";
|
|
|
3
3
|
import { date, datetime } from "./date.js";
|
|
4
4
|
import { page } from "./page.js";
|
|
5
5
|
import { teamspace } from "./teamspace.js";
|
|
6
|
+
import { view } from "./view.js";
|
|
6
7
|
declare const notionAsCodeFacade: {
|
|
7
8
|
teamspace: typeof teamspace;
|
|
8
9
|
database: typeof database;
|
|
9
10
|
page: typeof page;
|
|
10
11
|
customAgent: typeof customAgent;
|
|
12
|
+
view: typeof view;
|
|
11
13
|
text: (value: string) => string[][];
|
|
12
14
|
number: (value: number) => string[][];
|
|
13
15
|
date: typeof date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/handles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/handles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,QAAA,MAAM,kBAAkB;;;;;;kBAMT,MAAM;oBACJ,MAAM;;;oBAGN,MAAM;oBACN,MAAM;0BACA,SAAS,MAAM,EAAE;sBACrB,OAAO;iBACZ,MAAM;mBACJ,MAAM;mBACN,MAAM;sBACH,MAAM,GAAG,SAAS,MAAM,EAAE;uBACzB,MAAM;;;;CAIzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AAE3D,iFAAiF;AACjF,wBAAgB,YAAY,IAAI,kBAAkB,CAEjD"}
|
|
@@ -4,11 +4,13 @@ import { date, datetime } from "./date.js";
|
|
|
4
4
|
import { page } from "./page.js";
|
|
5
5
|
import { assertUserResourceId } from "./resource.js";
|
|
6
6
|
import { teamspace } from "./teamspace.js";
|
|
7
|
+
import { view } from "./view.js";
|
|
7
8
|
const notionAsCodeFacade = {
|
|
8
9
|
teamspace,
|
|
9
10
|
database,
|
|
10
11
|
page,
|
|
11
12
|
customAgent,
|
|
13
|
+
view,
|
|
12
14
|
text: (value) => [[value]],
|
|
13
15
|
number: (value) => [[String(value)]],
|
|
14
16
|
date,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
export { APPS_RESERVED_RESOURCE_ID_PREFIX, APPS_WORKSPACE_RESOURCE_ID } from "./intents.js";
|
|
2
2
|
export type { DataSourceDefinition, NotionAsCodeProperty, Parent } from "./intents.js";
|
|
3
3
|
export type { CustomAgentArgs, CustomAgentHandle } from "./custom-agent.js";
|
|
4
|
-
export type { ChildDatabaseArgs, DataSourceHandle, DatabaseArgs, DatabaseHandle, } from "./database.js";
|
|
4
|
+
export type { ChildDatabaseArgs, ChildDatabaseFactory, ChildSingleSourceDatabaseArgs, DataSourceHandle, DatabaseArgs, DatabaseHandle, SingleSourceDatabaseArgs, SingleSourceDatabaseHandle, } from "./database.js";
|
|
5
5
|
export type { ChildPageArgs, PageArgs, PageHandle } from "./page.js";
|
|
6
6
|
export type { TeamspaceArgs, TeamspaceHandle } from "./teamspace.js";
|
|
7
|
+
export type { ViewArgs, ViewHandle } from "./view.js";
|
|
8
|
+
export type { AdvancedFilterSchema, BasePropertyFilter, BaseViewSchema, BoardViewSchema, CalendarViewSchema, CheckboxGroupByFormat, CheckboxPropertyFilter, CoverAspectFormat, CoverFormat, CoverSizeFormat, DatabaseViewSortDirection, DateFilterMode, DateGroupByFormat, DatePropertyFilter, DatePropertyFilterValue, DatePropertyTypes, ExactDatePropertyFilterValue, ExactRangeDatePropertyFilterValue, FeedViewSchema, FilterSchema, FormulaGroupByFormat, GalleryViewSchema, GroupByFormat, GroupByFormatBase, GroupFormat, ListViewSchema, LocationGroupByFormat, MultiSelectPropertyFilter, NumberGroupByFormat, NumberPropertyFilter, PersonGroupByFormat, PersonPropertyFilter, PropertyFilterSchema, PropertyFormat, PropertyViewSortSchema, PropertyVisibility, RelationGroupByFormat, RelationPropertyFilter, RelativeDatePreset, RelativeDatePropertyFilterValue, RelativeDateRangeUnit, RelativeToTodayDatePropertyFilterValue, SelectGroupByFormat, SelectPropertyFilter, StatusGroupByFormat, StatusPropertyFilter, TableViewSchema, TextGroupByFormat, TextPropertyFilter, TimelineViewSchema, ViewSchema, ViewType, } from "./views.js";
|
|
7
9
|
/** Experimental Notion-as-Code facade for Apps SDK project metadata. */
|
|
8
10
|
export declare const notion: {
|
|
9
11
|
teamspace: typeof import("./teamspace.js").teamspace;
|
|
10
12
|
database: typeof import("./database.js").database;
|
|
11
13
|
page: typeof import("./page.js").page;
|
|
12
14
|
customAgent: typeof import("./custom-agent.js").customAgent;
|
|
15
|
+
view: typeof import("./view.js").view;
|
|
13
16
|
text: (value: string) => string[][];
|
|
14
17
|
number: (value: number) => string[][];
|
|
15
18
|
date: typeof import("./date.js").date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC5F,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACvF,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,YAAY,EACX,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC5F,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACvF,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,YAAY,EACX,iBAAiB,EACjB,oBAAoB,EACpB,6BAA6B,EAC7B,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,wBAAwB,EACxB,0BAA0B,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACrE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,YAAY,EACX,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,yBAAyB,EACzB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,EACjB,4BAA4B,EAC5B,iCAAiC,EACjC,cAAc,EACd,YAAY,EACZ,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,+BAA+B,EAC/B,qBAAqB,EACrB,sCAAsC,EACtC,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,QAAQ,GACR,MAAM,YAAY,CAAC;AAEpB,wEAAwE;AACxE,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;CAAiB,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { CustomAgentArgs } from "./custom-agent.js";
|
|
|
2
2
|
import type { DatabaseArgs } from "./database.js";
|
|
3
3
|
import type { PageArgs } from "./page.js";
|
|
4
4
|
import type { TeamspaceArgs } from "./teamspace.js";
|
|
5
|
+
import type { ViewSchema } from "./views.js";
|
|
5
6
|
/** Apps-specific resource IDs used while declaring Notion-as-Code metadata. */
|
|
6
7
|
/** Synthetic workspace parent for teamspaces declared by an Apps project. */
|
|
7
8
|
export declare const APPS_WORKSPACE_RESOURCE_ID = "__notion_apps_workspace__";
|
|
@@ -101,7 +102,7 @@ export type PageIntent = PageArgs & {
|
|
|
101
102
|
export type CustomAgentIntent = CustomAgentArgs;
|
|
102
103
|
export type ViewIntent = {
|
|
103
104
|
databaseResourceId: ResourceId;
|
|
104
|
-
view:
|
|
105
|
+
view: ViewSchema;
|
|
105
106
|
};
|
|
106
107
|
export type InfraAsCodeIntent = ({
|
|
107
108
|
type: "teamspace";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/intents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/intents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,+EAA+E;AAC/E,6EAA6E;AAC7E,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,kEAAkE;AAClE,eAAO,MAAM,gCAAgC,mBAAmB,CAAC;AAEjE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACzB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAE5C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M,MAAM,cAAc,GAAG,YAAY,GAAG;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACvD,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD,MAAM,MAAM,UAAU,GAAG;IACxB,kBAAkB,EAAE,UAAU,CAAC;IAC/B,IAAI,EAAE,UAAU,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAC1B,CAAC;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GAAG,eAAe,CAAC,GACzC,CAAC;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,cAAc,CAAC,GACvC,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,GAC/B,CAAC;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GAAG,iBAAiB,CAAC,GAC9C,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type Parent, type ResourceId } from "./intents.js";
|
|
2
|
+
import { type ChildDatabaseFactory } from "./database.js";
|
|
3
3
|
export type PageArgs = {
|
|
4
4
|
resourceId: ResourceId;
|
|
5
5
|
/** Omit to create a private top-level page in the Apps workspace. */
|
|
@@ -12,7 +12,7 @@ export type PageArgs = {
|
|
|
12
12
|
export type ChildPageArgs = Omit<PageArgs, "parent">;
|
|
13
13
|
export type PageHandle = {
|
|
14
14
|
readonly resourceId: string;
|
|
15
|
-
addDatabase:
|
|
15
|
+
addDatabase: ChildDatabaseFactory;
|
|
16
16
|
addPage: (args: ChildPageArgs) => PageHandle;
|
|
17
17
|
};
|
|
18
18
|
/** Declare a page, defaulting to a private top-level page in the Apps workspace. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/page.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/page.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,MAAM,EACX,KAAK,UAAU,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAuB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAI/E,MAAM,MAAM,QAAQ,GAAG;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAErD,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,oBAAoB,CAAC;IAClC,OAAO,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,UAAU,CAAC;CAC7C,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAS/C;AAED,6DAA6D;AAC7D,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAerF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
APPS_WORKSPACE_RESOURCE_ID
|
|
3
3
|
} from "./intents.js";
|
|
4
|
-
import {
|
|
4
|
+
import { createChildDatabase } from "./database.js";
|
|
5
5
|
import { recordIntent } from "./recorder.js";
|
|
6
6
|
import { assertParent, assertUserResourceId } from "./resource.js";
|
|
7
7
|
function page(args) {
|
|
@@ -23,12 +23,7 @@ function createPage(args, parent) {
|
|
|
23
23
|
});
|
|
24
24
|
return {
|
|
25
25
|
resourceId: args.resourceId,
|
|
26
|
-
addDatabase(
|
|
27
|
-
return database({
|
|
28
|
-
...databaseArgs,
|
|
29
|
-
parent: { type: "resourceId", resourceId: args.resourceId }
|
|
30
|
-
});
|
|
31
|
-
},
|
|
26
|
+
addDatabase: createChildDatabase({ type: "resourceId", resourceId: args.resourceId }),
|
|
32
27
|
addPage(pageArgs) {
|
|
33
28
|
return createPage(pageArgs, { type: "resourceId", resourceId: args.resourceId });
|
|
34
29
|
}
|