@notionhq/apps 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +1 -4
- package/dist/custom-block.d.ts +14 -2
- package/dist/custom-block.d.ts.map +1 -1
- package/dist/custom-block.js +27 -2
- package/dist/notion-as-code/custom-agent.d.ts +43 -2
- package/dist/notion-as-code/custom-agent.d.ts.map +1 -1
- package/dist/notion-as-code/custom-agent.js +2 -2
- package/dist/notion-as-code/database.d.ts +3 -0
- package/dist/notion-as-code/database.d.ts.map +1 -1
- package/dist/notion-as-code/database.js +6 -2
- package/dist/notion-as-code/index.d.ts +2 -1
- package/dist/notion-as-code/index.d.ts.map +1 -1
- package/dist/notion-as-code/index.js +4 -1
- package/dist/notion-as-code/intents.d.ts +1 -0
- package/dist/notion-as-code/intents.d.ts.map +1 -1
- package/dist/translate.d.ts +10 -0
- package/dist/translate.d.ts.map +1 -0
- package/dist/translate.js +65 -0
- package/docs/BUILD.md +4 -2
- package/package.json +1 -1
- package/skills/custom-blocks/SKILL.md +4 -4
- package/skills/notion-as-code/SKILL.md +9 -7
- package/src/cli/build.test.ts +50 -0
- package/src/cli/build.ts +1 -4
- package/src/cli/codegen.test.ts +17 -1
- package/src/custom-block.test.ts +138 -2
- package/src/custom-block.ts +49 -2
- package/src/notion-as-code/custom-agent.test.ts +17 -1
- package/src/notion-as-code/custom-agent.ts +48 -4
- package/src/notion-as-code/database.test.ts +5 -1
- package/src/notion-as-code/database.ts +9 -1
- package/src/notion-as-code/index.ts +4 -0
- package/src/notion-as-code/intents.ts +1 -0
- package/src/notion-as-code/notion-as-code-types.test.ts +25 -0
- package/src/translate.ts +77 -0
package/dist/cli/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/cli/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA2CxE"}
|
package/dist/cli/build.js
CHANGED
|
@@ -30,10 +30,7 @@ async function buildApp(projectRoot) {
|
|
|
30
30
|
await bundle.close();
|
|
31
31
|
}
|
|
32
32
|
const blockConfigs = await buildBlockDeclarations(projectRoot, capabilities);
|
|
33
|
-
const entityProvisioning = await buildMetadata(
|
|
34
|
-
projectRoot,
|
|
35
|
-
capabilities.filter((capability) => capability.runtime === "worker")
|
|
36
|
-
);
|
|
33
|
+
const entityProvisioning = await buildMetadata(projectRoot, capabilities);
|
|
37
34
|
const manifest = await extractManifest(
|
|
38
35
|
bundlePath,
|
|
39
36
|
capabilities,
|
package/dist/custom-block.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { ManifestDataSource } from "@notionhq/custom-blocks";
|
|
2
|
+
import type { DataSourceHandle, SingleSourceDatabaseHandle } from "./notion-as-code/database.js";
|
|
3
|
+
export type CustomBlockDefaultBinding = {
|
|
4
|
+
dataSourceResourceId: string;
|
|
5
|
+
propertyResourceIdsByKey: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
type CustomBlockDataSource = ManifestDataSource | DataSourceHandle | SingleSourceDatabaseHandle;
|
|
2
8
|
export type CustomBlockOptions = {
|
|
3
9
|
path: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
description?: string;
|
|
4
12
|
slashCommand?: string;
|
|
5
|
-
dataSources?: Record<string,
|
|
13
|
+
dataSources?: Record<string, CustomBlockDataSource>;
|
|
6
14
|
} & ({
|
|
7
15
|
static: true;
|
|
8
16
|
command?: never;
|
|
@@ -16,6 +24,7 @@ export type CustomBlockOptions = {
|
|
|
16
24
|
export declare function customBlock(options: CustomBlockOptions): {
|
|
17
25
|
_tag: "custom_block";
|
|
18
26
|
config: {
|
|
27
|
+
defaultBindings?: Record<string, CustomBlockDefaultBinding>;
|
|
19
28
|
source: {
|
|
20
29
|
type: "static";
|
|
21
30
|
path: string;
|
|
@@ -42,13 +51,16 @@ export declare function customBlock(options: CustomBlockOptions): {
|
|
|
42
51
|
[x: string]: {
|
|
43
52
|
name: string;
|
|
44
53
|
description?: string | undefined;
|
|
45
|
-
type: "number" | "date" | "url" | "title" | "
|
|
54
|
+
type: "number" | "date" | "url" | "title" | "email" | "phone_number" | "checkbox" | "select" | "multi_select" | "status" | "people" | "place" | "relation" | "verification" | "created_by" | "last_edited_by" | "created_time" | "last_edited_time" | "last_visited_time" | "location" | "formula" | "rollup" | "rich_text" | "files" | "unique_id" | "button";
|
|
46
55
|
};
|
|
47
56
|
};
|
|
48
57
|
}>;
|
|
49
58
|
slashCommand?: string;
|
|
59
|
+
description?: string;
|
|
60
|
+
name?: string;
|
|
50
61
|
version: 1;
|
|
51
62
|
};
|
|
52
63
|
};
|
|
53
64
|
};
|
|
65
|
+
export {};
|
|
54
66
|
//# sourceMappingURL=custom-block.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-block.d.ts","sourceRoot":"","sources":["../src/custom-block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;;;;;;;;;;;;;;;;;EAgCtD"}
|
package/dist/custom-block.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toCustomBlockDefaultBinding, toCustomBlockDataSource } from "./translate.js";
|
|
1
2
|
function customBlock(options) {
|
|
2
3
|
if (typeof options.path !== "string" || options.path.trim() === "") {
|
|
3
4
|
throw new Error("customBlock requires a non-empty path relative to the app root");
|
|
@@ -8,6 +9,7 @@ function customBlock(options) {
|
|
|
8
9
|
"Custom block slashCommand must be 1\u201364 lowercase letters, numbers, hyphens or underscores, starting with a letter or number"
|
|
9
10
|
);
|
|
10
11
|
}
|
|
12
|
+
const { dataSources, defaultBindings } = lowerDataSources(options.dataSources ?? {});
|
|
11
13
|
return {
|
|
12
14
|
_tag: "custom_block",
|
|
13
15
|
config: {
|
|
@@ -19,12 +21,35 @@ function customBlock(options) {
|
|
|
19
21
|
},
|
|
20
22
|
manifest: {
|
|
21
23
|
version: 1,
|
|
24
|
+
...options.name === void 0 ? {} : { name: options.name },
|
|
25
|
+
...options.description === void 0 ? {} : { description: options.description },
|
|
22
26
|
...slashCommand === void 0 ? {} : { slashCommand },
|
|
23
|
-
dataSources
|
|
24
|
-
}
|
|
27
|
+
dataSources
|
|
28
|
+
},
|
|
29
|
+
...Object.keys(defaultBindings).length === 0 ? {} : { defaultBindings }
|
|
25
30
|
}
|
|
26
31
|
};
|
|
27
32
|
}
|
|
33
|
+
function lowerDataSources(dataSources) {
|
|
34
|
+
const manifestDataSources = {};
|
|
35
|
+
const defaultBindings = {};
|
|
36
|
+
for (const [key, dataSource] of Object.entries(dataSources)) {
|
|
37
|
+
const handle = isSingleSourceDatabaseHandle(dataSource) ? dataSource.dataSource : dataSource;
|
|
38
|
+
if (isDataSourceHandle(handle)) {
|
|
39
|
+
manifestDataSources[key] = toCustomBlockDataSource(handle);
|
|
40
|
+
defaultBindings[key] = toCustomBlockDefaultBinding(handle);
|
|
41
|
+
} else {
|
|
42
|
+
manifestDataSources[key] = handle;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { dataSources: manifestDataSources, defaultBindings };
|
|
46
|
+
}
|
|
47
|
+
function isSingleSourceDatabaseHandle(value) {
|
|
48
|
+
return "dataSource" in value;
|
|
49
|
+
}
|
|
50
|
+
function isDataSourceHandle(value) {
|
|
51
|
+
return "resourceId" in value && "schema" in value && "database" in value;
|
|
52
|
+
}
|
|
28
53
|
export {
|
|
29
54
|
customBlock
|
|
30
55
|
};
|
|
@@ -72,6 +72,27 @@ export type CustomAgentPropertyUpdatedTrigger = CustomAgentTriggerBase & Propert
|
|
|
72
72
|
dataSourceResourceId: ResourceId;
|
|
73
73
|
};
|
|
74
74
|
export type CustomAgentTrigger = CustomAgentRecurrenceTrigger | CustomAgentPageAddedTrigger | CustomAgentPropertyUpdatedTrigger;
|
|
75
|
+
/**
|
|
76
|
+
* Defines access levels for resources that a custom agent can use.
|
|
77
|
+
*
|
|
78
|
+
* These values map to Notion module permissions: full access, content editing,
|
|
79
|
+
* commenting, and read-only.
|
|
80
|
+
*/
|
|
81
|
+
export type CustomAgentAccessRole = "full_access" | "can_edit_content" | "can_comment" | "can_view";
|
|
82
|
+
/** Grants a custom agent access to a page or database resource. */
|
|
83
|
+
export type CustomAgentAccess = {
|
|
84
|
+
resourceId: ResourceId;
|
|
85
|
+
role: CustomAgentAccessRole;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* URL trust settings for a custom agent.
|
|
89
|
+
*
|
|
90
|
+
* URL trust is independent from web access: an agent can trust URLs without
|
|
91
|
+
* being granted web search access.
|
|
92
|
+
*/
|
|
93
|
+
export type CustomAgentTrustedUrls = {
|
|
94
|
+
type: "all";
|
|
95
|
+
};
|
|
75
96
|
export type CustomAgentArgs = {
|
|
76
97
|
resourceId: ResourceId;
|
|
77
98
|
name: string;
|
|
@@ -80,14 +101,34 @@ export type CustomAgentArgs = {
|
|
|
80
101
|
}>;
|
|
81
102
|
instructions?: string;
|
|
82
103
|
model?: "ambrosia-tart-high" | "opal-quince-medium" | "almond-croissant-low";
|
|
83
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Whether the agent can use web search. Defaults to `false` when omitted for
|
|
106
|
+
* a new agent. When updating an existing agent, omitting this field preserves
|
|
107
|
+
* its current web access and domain restrictions.
|
|
108
|
+
*/
|
|
109
|
+
webAccess?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* URL trust policy for this agent. `{ type: "all" }` allows every HTTP and
|
|
112
|
+
* HTTPS URL. For a new agent, omitting this field leaves URL trust disabled;
|
|
113
|
+
* for an existing agent, omission preserves the current URL trust policy.
|
|
114
|
+
*/
|
|
115
|
+
trustedUrls?: CustomAgentTrustedUrls;
|
|
116
|
+
/**
|
|
117
|
+
* Grants the agent access to pages and databases.
|
|
118
|
+
*
|
|
119
|
+
* For an existing custom agent, omit this field or provide an empty list to
|
|
120
|
+
* preserve current page and database grants. Each listed resource adds a
|
|
121
|
+
* grant or replaces its existing grant with the listed role. Grants for
|
|
122
|
+
* unlisted resources remain unchanged.
|
|
123
|
+
*/
|
|
124
|
+
access?: readonly CustomAgentAccess[];
|
|
84
125
|
triggers?: readonly CustomAgentTrigger[];
|
|
85
126
|
};
|
|
86
127
|
export type CustomAgentHandle = {
|
|
87
128
|
readonly resourceType: "customAgent";
|
|
88
129
|
readonly resourceId: string;
|
|
89
130
|
};
|
|
90
|
-
/** Declare a custom agent and validate every
|
|
131
|
+
/** Declare a custom agent and validate every resource reference. */
|
|
91
132
|
export declare function customAgent(args: CustomAgentArgs): CustomAgentHandle;
|
|
92
133
|
export {};
|
|
93
134
|
//# sourceMappingURL=custom-agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-agent.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/custom-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAIpF,KAAK,iBAAiB,GAAG,IAAI,GAAG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AAO,CAAC;IACpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,QAAQ,CAAC,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,iBAAiB,CAoBpE"}
|
|
@@ -2,8 +2,8 @@ import { recordIntent } from "./recorder.js";
|
|
|
2
2
|
import { assertUserResourceId } from "./resource.js";
|
|
3
3
|
function customAgent(args) {
|
|
4
4
|
assertUserResourceId(args.resourceId);
|
|
5
|
-
for (const
|
|
6
|
-
assertUserResourceId(resourceId);
|
|
5
|
+
for (const grant of args.access ?? []) {
|
|
6
|
+
assertUserResourceId(grant.resourceId);
|
|
7
7
|
}
|
|
8
8
|
for (const trigger of args.triggers ?? []) {
|
|
9
9
|
assertUserResourceId(trigger.resourceId);
|
|
@@ -10,6 +10,7 @@ type NonEmptyViewSchemas = readonly [ViewSchema, ...ViewSchema[]];
|
|
|
10
10
|
export type DataSourceArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
|
|
11
11
|
resourceId: ResourceId;
|
|
12
12
|
name?: never;
|
|
13
|
+
description?: string;
|
|
13
14
|
schema: Schema;
|
|
14
15
|
icon?: NotionAsCodeIcon;
|
|
15
16
|
pageLayout?: DatabasePageLayout<Schema>;
|
|
@@ -76,6 +77,8 @@ export type ChildDatabaseArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSc
|
|
|
76
77
|
export type DataSourceHandle<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
|
|
77
78
|
readonly resourceType: "dataSource";
|
|
78
79
|
readonly resourceId: string;
|
|
80
|
+
readonly name: string;
|
|
81
|
+
readonly description?: string;
|
|
79
82
|
readonly schema: Schema;
|
|
80
83
|
readonly database: Database<AppsSchemaForSchema<Schema>>;
|
|
81
84
|
addPage: (args: ChildPageArgs) => PageHandle;
|
|
@@ -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,cAAc,EACnB,KAAK,kBAAkB,EAEvB,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAc,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAG5E,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,0FAA0F;AAC1F,KAAK,gBAAgB,GAAG,IAAI,CAAC,cAAc,EAAE,YAAY,GAAG,QAAQ,GAAG,aAAa,CAAC,CAAC;AAEtF,KAAK,mBAAmB,GAAG,SAAS,CAAC,UAAU,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;AAElE,mGAAmG;AACnG,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,kBAAkB,GAAG,kBAAkB,IAAI;IACpF,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,CAAC,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,UAAU,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAE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E,UAAU,EAC9B,IAAI,EAAE,6BAA6B,CAAC,MAAM,CAAC,GACzC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC,KAAK,CAAC,WAAW,SAAS,aAAa,EACvC,kBAAkB,EAAE,UAAU,EAC9B,IAAI,EAAE,4BAA4B,CAAC,WAAW,CAAC,GAC7C,cAAc,CAAC,WAAW,CAAC,CAAC;IAC/B,CACC,kBAAkB,EAAE,UAAU,EAC9B,IAAI,EAAE,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,GACxC,cAAc,CAAC,EAAE,CAAC,CAAC;CACtB,CAAC;AAEF,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS,kBAAkB,EAC/D,kBAAkB,EAAE,UAAU,EAC9B,IAAI,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACpC,0BAA0B,CAAC,MAAM,CAAC,CAAC;AACtC,wBAAgB,QAAQ,CAAC,KAAK,CAAC,WAAW,SAAS,aAAa,EAC/D,kBAAkB,EAAE,UAAU,EAC9B,IAAI,EAAE,uBAAuB,CAAC,WAAW,CAAC,GACxC,cAAc,CAAC,WAAW,CAAC,CAAC;AAC/B,wBAAgB,QAAQ,CACvB,kBAAkB,EAAE,UAAU,EAC9B,IAAI,EAAE,oBAAoB,GACxB,cAAc,CAAC,EAAE,CAAC,CAAC;AAmBtB,gEAAgE;AAChE,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAuBxE"}
|
|
@@ -43,6 +43,7 @@ function buildDatabaseHandle(databaseResourceId, args, parent) {
|
|
|
43
43
|
const source = {
|
|
44
44
|
resourceId: args.dataSourceResourceId,
|
|
45
45
|
name: args.name,
|
|
46
|
+
...args.description === void 0 ? {} : { description: args.description },
|
|
46
47
|
properties: normalizeProperties(args.schema),
|
|
47
48
|
...args.pageLayout === void 0 ? {} : { pageLayout: args.pageLayout }
|
|
48
49
|
};
|
|
@@ -150,7 +151,7 @@ function createDatabase(intent, sourceEntries) {
|
|
|
150
151
|
);
|
|
151
152
|
}
|
|
152
153
|
dataSourceIds.add(definition.resourceId);
|
|
153
|
-
handles[key] = createDataSourceHandle(definition, schema);
|
|
154
|
+
handles[key] = createDataSourceHandle(definition, schema, intent.description);
|
|
154
155
|
}
|
|
155
156
|
recordIntent({ ...intent, type: "database" });
|
|
156
157
|
return {
|
|
@@ -162,7 +163,7 @@ function createDatabase(intent, sourceEntries) {
|
|
|
162
163
|
}
|
|
163
164
|
};
|
|
164
165
|
}
|
|
165
|
-
function createDataSourceHandle(dataSource, schema) {
|
|
166
|
+
function createDataSourceHandle(dataSource, schema, databaseDescription) {
|
|
166
167
|
const propertyResourceIds = /* @__PURE__ */ new Set();
|
|
167
168
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
168
169
|
for (const property of dataSource.properties) {
|
|
@@ -180,9 +181,12 @@ function createDataSourceHandle(dataSource, schema) {
|
|
|
180
181
|
propertyResourceIds.add(property.resourceId);
|
|
181
182
|
propertyNames.add(property.name);
|
|
182
183
|
}
|
|
184
|
+
const description = dataSource.description ?? databaseDescription;
|
|
183
185
|
return {
|
|
184
186
|
resourceType: "dataSource",
|
|
185
187
|
resourceId: dataSource.resourceId,
|
|
188
|
+
name: dataSource.name,
|
|
189
|
+
...description === void 0 ? {} : { description },
|
|
186
190
|
schema,
|
|
187
191
|
database: createAppsDatabase(dataSource.resourceId, dataSource),
|
|
188
192
|
addPage(pageArgs) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { APPS_RESERVED_RESOURCE_ID_PREFIX, APPS_WORKSPACE_RESOURCE_ID } from "./intents.js";
|
|
2
2
|
export type { ContentPageLayoutTab, DatabasePageLayout, DatabasePageLayoutTab, DatabaseIntent, DataSourceDefinition, NotionAsCodeIcon, NotionAsCodeProperty, NotionAsCodePropertyConfig, NotionAsCodeSchema, NotionAsCodeSelectOption, NotionAsCodeStatusOption, PageCoverReference, PageLayoutMainModule, PageLayoutNumberAndFormulaStyle, PageLayoutPersonStyle, PageLayoutPropertiesModule, PageLayoutPropertyConfig, PageLayoutPropertyModule, PageLayoutPropertySection, PageLayoutRelationConfig, PageLayoutRelationsGroupModule, PageLayoutSidebarModule, Parent, ResourceId, RollupBaseAggregationType, RollupDateAggregationType, RollupNumberAggregationType, RollupTargetPropertyType, ViewPageLayoutTab, } from "./intents.js";
|
|
3
|
-
export type { CustomAgentArgs, CustomAgentHandle, CustomAgentPageAddedTrigger, CustomAgentPropertyUpdatedTrigger, CustomAgentRecurrenceSchedule, CustomAgentRecurrenceTrigger, CustomAgentTrigger, CustomAgentTriggerBase, DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceRestriction, MonthlyRecurrenceSchedule, MonthlyWeekdayOccurrence, PropertyTriggerCondition, RecurrenceScheduleEnd, RecurrenceWeekdays, WeeklyRecurrenceSchedule, YearlyRecurrenceSchedule, } from "./custom-agent.js";
|
|
3
|
+
export type { CustomAgentAccess, CustomAgentAccessRole, CustomAgentArgs, CustomAgentHandle, CustomAgentPageAddedTrigger, CustomAgentPropertyUpdatedTrigger, CustomAgentRecurrenceSchedule, CustomAgentRecurrenceTrigger, CustomAgentTrustedUrls, CustomAgentTrigger, CustomAgentTriggerBase, DailyRecurrenceSchedule, HourlyRecurrenceSchedule, MonthlyRecurrenceRestriction, MonthlyRecurrenceSchedule, MonthlyWeekdayOccurrence, PropertyTriggerCondition, RecurrenceScheduleEnd, RecurrenceWeekdays, WeeklyRecurrenceSchedule, YearlyRecurrenceSchedule, } from "./custom-agent.js";
|
|
4
4
|
export type { ChildDatabaseArgs, ChildDatabaseFactory, ChildMultiSourceDatabaseArgs, ChildSingleSourceDatabaseArgs, DataSourceArgs, DataSourceHandle, DataSourceMap, DatabaseArgs, DatabaseHandle, MultiSourceDatabaseArgs, SingleSourceDatabaseArgs, SingleSourceDatabaseHandle, } from "./database.js";
|
|
5
|
+
export { toCustomBlockDefaultBinding, toCustomBlockDataSource } from "../translate.js";
|
|
5
6
|
export type { ChildPageArgs, PageArgs, PageHandle, PropertyValue, SimpleTextToken, TextValue, VerificationInput, VerificationPropertyValue, } from "./page.js";
|
|
6
7
|
export type { TeamspaceArgs, TeamspaceHandle } from "./teamspace.js";
|
|
7
8
|
export type { ViewArgs, ViewHandle } from "./view.js";
|
|
@@ -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,EACX,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,+BAA+B,EAC/B,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,EAC9B,uBAAuB,EACvB,MAAM,EACN,UAAU,EACV,yBAAyB,EACzB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,iBAAiB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACX,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC3B,iCAAiC,EACjC,6BAA6B,EAC7B,4BAA4B,EAC5B,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,EAC5B,yBAAyB,EACzB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,iBAAiB,EACjB,oBAAoB,EACpB,4BAA4B,EAC5B,6BAA6B,EAC7B,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,GAC1B,MAAM,eAAe,CAAC;AACvB,YAAY,EACX,aAAa,EACb,QAAQ,EACR,UAAU,EACV,aAAa,EACb,eAAe,EACf,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,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"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/notion-as-code/index.ts"],"names":[],"mappings":"AA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,MAAM,WAAW,CAAC;AACnB,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"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { createNotion } from "./handles.js";
|
|
2
2
|
import { APPS_RESERVED_RESOURCE_ID_PREFIX, APPS_WORKSPACE_RESOURCE_ID } from "./intents.js";
|
|
3
|
+
import { toCustomBlockDefaultBinding, toCustomBlockDataSource } from "../translate.js";
|
|
3
4
|
const notion = createNotion();
|
|
4
5
|
export {
|
|
5
6
|
APPS_RESERVED_RESOURCE_ID_PREFIX,
|
|
6
7
|
APPS_WORKSPACE_RESOURCE_ID,
|
|
7
|
-
notion
|
|
8
|
+
notion,
|
|
9
|
+
toCustomBlockDataSource,
|
|
10
|
+
toCustomBlockDefaultBinding
|
|
8
11
|
};
|
|
@@ -225,6 +225,7 @@ export type DatabasePageLayout<Schema extends NotionAsCodeSchema = NotionAsCodeS
|
|
|
225
225
|
export type DataSourceDefinition<Properties extends readonly NotionAsCodeProperty[] = readonly NotionAsCodeProperty[]> = {
|
|
226
226
|
resourceId: ResourceId;
|
|
227
227
|
name: string;
|
|
228
|
+
description?: string;
|
|
228
229
|
properties: Properties;
|
|
229
230
|
icon?: NotionAsCodeIcon;
|
|
230
231
|
pageLayout?: DatabasePageLayout;
|
|
@@ -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,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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
|
+
import type { CustomBlockDefaultBinding } from "./custom-block.js";
|
|
3
|
+
import type { DataSourceHandle } from "./notion-as-code/database.js";
|
|
4
|
+
import type { NotionAsCodeProperty } from "./notion-as-code/intents.js";
|
|
5
|
+
/** Lower a Notion-as-Code handle into the declaration consumed by custom block hosts. */
|
|
6
|
+
export declare function toCustomBlockDataSource(handle: DataSourceHandle): ManifestDataSource;
|
|
7
|
+
/** Keep resource IDs in the build artifact so deploy can resolve workspace-local IDs later. */
|
|
8
|
+
export declare function toCustomBlockDefaultBinding(handle: DataSourceHandle): CustomBlockDefaultBinding;
|
|
9
|
+
export declare function toCustomBlockPropertyType(type: NotionAsCodeProperty["type"]): NotionPropertyType;
|
|
10
|
+
//# sourceMappingURL=translate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../src/translate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,kBAAkB,EAElB,kBAAkB,EAClB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,yFAAyF;AACzF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,GAAG,kBAAkB,CAiBpF;AAED,+FAA+F;AAC/F,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,gBAAgB,GAAG,yBAAyB,CAO/F;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,kBAAkB,CAgChG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
function toCustomBlockDataSource(handle) {
|
|
2
|
+
return {
|
|
3
|
+
name: handle.name,
|
|
4
|
+
...handle.description === void 0 ? {} : { description: handle.description },
|
|
5
|
+
properties: Object.fromEntries(
|
|
6
|
+
Object.entries(handle.schema).map(([key, property]) => [
|
|
7
|
+
key,
|
|
8
|
+
{
|
|
9
|
+
name: key,
|
|
10
|
+
...typeof property.description !== "string" ? {} : { description: property.description },
|
|
11
|
+
type: toCustomBlockPropertyType(property.type)
|
|
12
|
+
}
|
|
13
|
+
])
|
|
14
|
+
)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function toCustomBlockDefaultBinding(handle) {
|
|
18
|
+
return {
|
|
19
|
+
dataSourceResourceId: handle.resourceId,
|
|
20
|
+
propertyResourceIdsByKey: Object.fromEntries(
|
|
21
|
+
Object.entries(handle.schema).map(([key, property]) => [key, property.resourceId])
|
|
22
|
+
)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function toCustomBlockPropertyType(type) {
|
|
26
|
+
switch (type) {
|
|
27
|
+
case "text":
|
|
28
|
+
return "rich_text";
|
|
29
|
+
case "file":
|
|
30
|
+
return "files";
|
|
31
|
+
case "person":
|
|
32
|
+
return "people";
|
|
33
|
+
case "auto_increment_id":
|
|
34
|
+
return "unique_id";
|
|
35
|
+
case "title":
|
|
36
|
+
case "number":
|
|
37
|
+
case "select":
|
|
38
|
+
case "multi_select":
|
|
39
|
+
case "status":
|
|
40
|
+
case "date":
|
|
41
|
+
case "checkbox":
|
|
42
|
+
case "url":
|
|
43
|
+
case "email":
|
|
44
|
+
case "phone_number":
|
|
45
|
+
case "relation":
|
|
46
|
+
case "formula":
|
|
47
|
+
case "rollup":
|
|
48
|
+
case "created_time":
|
|
49
|
+
case "last_edited_time":
|
|
50
|
+
case "created_by":
|
|
51
|
+
case "last_edited_by":
|
|
52
|
+
case "verification":
|
|
53
|
+
return type;
|
|
54
|
+
default:
|
|
55
|
+
return assertNever(type);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function assertNever(value) {
|
|
59
|
+
throw new Error(`Unsupported Notion-as-Code property type: ${String(value)}`);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
toCustomBlockDataSource,
|
|
63
|
+
toCustomBlockDefaultBinding,
|
|
64
|
+
toCustomBlockPropertyType
|
|
65
|
+
};
|
package/docs/BUILD.md
CHANGED
|
@@ -44,7 +44,7 @@ natural capability owner.
|
|
|
44
44
|
2. Generate `.notion/entry.ts` with workflow and sync imports and a dispatcher.
|
|
45
45
|
3. Bundle the app's code into `dist/worker.js`, leaving npm packages external.
|
|
46
46
|
4. Evaluate custom-block declarations separately. Blocks do not enter `worker.js`.
|
|
47
|
-
5. Evaluate worker capabilities in a separate build-only metadata bundle to record
|
|
47
|
+
5. Evaluate worker and custom-block capabilities in a separate build-only metadata bundle to record
|
|
48
48
|
Notion-as-Code declarations. Validate workflow access references against those
|
|
49
49
|
declarations before writing the manifest and optional provisioning artifact.
|
|
50
50
|
6. Emit `dist/manifest.json` and, when declarations exist, `dist/provisioning.json`.
|
|
@@ -198,7 +198,9 @@ the cloud build endpoint.
|
|
|
198
198
|
Workflows with nonempty `access` require cloud deployment. The local-build path
|
|
199
199
|
rejects them after the SDK build and before uploading or deploying the bundle.
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
Custom-block default bindings are stored in `manifest.json` as resource IDs and
|
|
202
|
+
resolved to live data source and property IDs during deployment. Live resource
|
|
203
|
+
bindings are not stored in SDK build output. Local deployments retain a
|
|
202
204
|
local state file and report `state_file`; cloud deployments keep installation-owned
|
|
203
205
|
resource mappings and state on the server. Cloud builds do not import local state
|
|
204
206
|
or return provisioning state to the CLI. Local and cloud state are independent:
|
package/package.json
CHANGED
|
@@ -33,10 +33,10 @@ Browser runtime APIs stay on `@notionhq/apps/custom-blocks`; the root
|
|
|
33
33
|
`customBlock` creates a capability, not a browser runtime client.
|
|
34
34
|
Never put server credentials in browser source.
|
|
35
35
|
|
|
36
|
-
`dataSources`
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
`dataSources` accepts either Notion-as-Code data source handles or inline declarations.
|
|
37
|
+
Both create mappings, but only a data source handle creates default bindings.
|
|
38
|
+
Single-source database handles can be referenced directly; multi-source databases
|
|
39
|
+
must use `multiSourceDatabase.datasources.Key`.
|
|
40
40
|
|
|
41
41
|
Blocks are build-time declarations, not executable workflow handlers. Do not
|
|
42
42
|
port `worker.customBlock()`, Worker source options, or Worker execution commands.
|
|
@@ -35,8 +35,8 @@ rejects it before upload.
|
|
|
35
35
|
|
|
36
36
|
## Where declarations are picked up
|
|
37
37
|
|
|
38
|
-
The Apps build discovers direct `.ts` children of `src/workflows
|
|
39
|
-
`src/syncs/`, then evaluates their imports with the Notion as Code recorder active.
|
|
38
|
+
The Apps build discovers direct `.ts` children of `src/workflows/`,
|
|
39
|
+
`src/syncs/`, and `src/customBlocks/`, then evaluates their imports with the Notion as Code recorder active.
|
|
40
40
|
Pages, databases, data sources, teamspaces, and custom agents all follow this
|
|
41
41
|
same rule. Their resource type does not determine their file location.
|
|
42
42
|
|
|
@@ -51,6 +51,8 @@ src/
|
|
|
51
51
|
myWorkflow/
|
|
52
52
|
lib/
|
|
53
53
|
notion.ts Resources owned by myWorkflow
|
|
54
|
+
customBlocks/
|
|
55
|
+
board.ts May import shared resource declarations
|
|
54
56
|
```
|
|
55
57
|
|
|
56
58
|
Choose the location based on ownership, not resource type. Export an app-wide
|
|
@@ -65,8 +67,8 @@ either. Helpers under capability-specific `lib/` directories are not discovered
|
|
|
65
67
|
on their own.
|
|
66
68
|
Every direct file in a capability directory must still default-export that
|
|
67
69
|
capability, so do not put a resource-only file there. Imports reached only
|
|
68
|
-
through
|
|
69
|
-
|
|
70
|
+
through browser code do not enter the Notion as Code recording phase. An App containing
|
|
71
|
+
only unimported resource declarations is not a
|
|
70
72
|
standalone Notion as Code project and has no discovered capabilities.
|
|
71
73
|
|
|
72
74
|
## Declare resources
|
|
@@ -84,9 +86,9 @@ root exports support:
|
|
|
84
86
|
`database(resourceId, { datasources: { Key: { resourceId, schema } }, views?, parent? })`,
|
|
85
87
|
returning sources as `handle.datasources.Key`. A source's `addPage` declares a row;
|
|
86
88
|
the database handle also exposes `addView`.
|
|
87
|
-
- `customAgent({ resourceId, name, instructions?,
|
|
88
|
-
|
|
89
|
-
before specifying models or
|
|
89
|
+
- `customAgent({ resourceId, name, instructions?, access?, webAccess?, trustedUrls? })`.
|
|
90
|
+
Access grants pair declared page or database resource IDs with a role. Inspect
|
|
91
|
+
the installed types before specifying models, triggers, or URL trust.
|
|
90
92
|
- `view({ databaseResourceId, resourceId, type, dataSourceResourceId, ... })`,
|
|
91
93
|
returning a handle with `resourceId`. This is also available as `notion.view`.
|
|
92
94
|
Use property resource IDs in view filters, sorts, and layout options; calendar
|
package/src/cli/build.test.ts
CHANGED
|
@@ -194,6 +194,56 @@ describe("buildApp", () => {
|
|
|
194
194
|
expect(worker).not.toMatch(/custom_block|customBlock|react|createRoot|NotionCustomBlock/);
|
|
195
195
|
expect(fs.existsSync(path.join(root, ".notion/blocks.js"))).toBe(false);
|
|
196
196
|
});
|
|
197
|
+
|
|
198
|
+
it("records resources imported only by a custom block and emits default bindings", async () => {
|
|
199
|
+
const root = fixture("custom-block-notion-as-code");
|
|
200
|
+
const { manifest } = await buildApp(root);
|
|
201
|
+
|
|
202
|
+
expect(manifest.capabilities).toEqual([
|
|
203
|
+
{
|
|
204
|
+
type: "custom_block",
|
|
205
|
+
key: "board",
|
|
206
|
+
config: expect.objectContaining({
|
|
207
|
+
defaultBindings: {
|
|
208
|
+
tasks: {
|
|
209
|
+
dataSourceResourceId: "tasks-source",
|
|
210
|
+
propertyResourceIdsByKey: {
|
|
211
|
+
Name: "task-name",
|
|
212
|
+
Status: "task-status",
|
|
213
|
+
Due: "task-due",
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
manifest: expect.objectContaining({
|
|
218
|
+
dataSources: {
|
|
219
|
+
tasks: expect.objectContaining({
|
|
220
|
+
name: "Tasks",
|
|
221
|
+
description: "Work items shown on the board",
|
|
222
|
+
}),
|
|
223
|
+
},
|
|
224
|
+
}),
|
|
225
|
+
}),
|
|
226
|
+
},
|
|
227
|
+
]);
|
|
228
|
+
const provisioning = JSON.parse(
|
|
229
|
+
await fs.promises.readFile(path.join(root, "dist", "provisioning.json"), "utf8"),
|
|
230
|
+
);
|
|
231
|
+
expect(provisioning.intents).toEqual([
|
|
232
|
+
expect.objectContaining({
|
|
233
|
+
type: "database",
|
|
234
|
+
resourceId: "tasks-db",
|
|
235
|
+
dataSources: [
|
|
236
|
+
expect.objectContaining({
|
|
237
|
+
resourceId: "tasks-source",
|
|
238
|
+
properties: expect.arrayContaining([
|
|
239
|
+
expect.objectContaining({ resourceId: "task-status" }),
|
|
240
|
+
]),
|
|
241
|
+
}),
|
|
242
|
+
],
|
|
243
|
+
}),
|
|
244
|
+
]);
|
|
245
|
+
});
|
|
246
|
+
|
|
197
247
|
it("names the block file when path is missing", async () => {
|
|
198
248
|
await expect(buildApp(fixture("custom-block-missing-path"))).rejects.toThrow(
|
|
199
249
|
/hello.ts.*non-empty path/,
|
package/src/cli/build.ts
CHANGED
|
@@ -54,10 +54,7 @@ export async function buildApp(projectRoot: string): Promise<BuildResult> {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const blockConfigs = await buildBlockDeclarations(projectRoot, capabilities);
|
|
57
|
-
const entityProvisioning = await buildMetadata(
|
|
58
|
-
projectRoot,
|
|
59
|
-
capabilities.filter((capability) => capability.runtime === "worker"),
|
|
60
|
-
);
|
|
57
|
+
const entityProvisioning = await buildMetadata(projectRoot, capabilities);
|
|
61
58
|
const manifest = await extractManifest(
|
|
62
59
|
bundlePath,
|
|
63
60
|
capabilities,
|
package/src/cli/codegen.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
|
-
import { generateEntry } from "./codegen.js";
|
|
3
|
+
import { generateEntry, generateMetadataEntry } from "./codegen.js";
|
|
4
4
|
|
|
5
5
|
describe("generateEntry", () => {
|
|
6
6
|
it("statically imports and registers workflows by key", () => {
|
|
@@ -36,3 +36,19 @@ describe("generateEntry", () => {
|
|
|
36
36
|
expect(entry).toContain(`"issues": capability_0,`);
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
describe("generateMetadataEntry", () => {
|
|
41
|
+
it("records resources imported by custom blocks", () => {
|
|
42
|
+
const entry = generateMetadataEntry([
|
|
43
|
+
{
|
|
44
|
+
type: "custom_block",
|
|
45
|
+
tag: "custom_block",
|
|
46
|
+
runtime: "build",
|
|
47
|
+
key: "board",
|
|
48
|
+
sourcePath: "src/customBlocks/board.ts",
|
|
49
|
+
},
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
expect(entry).toContain(`await import("../src/customBlocks/board.ts");`);
|
|
53
|
+
});
|
|
54
|
+
});
|
package/src/custom-block.test.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
1
|
+
import { describe, expect, expectTypeOf, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { customBlock, type CustomBlockOptions } from "./custom-block.js";
|
|
4
|
+
import { notion, type DatabaseHandle } from "./notion-as-code/index.js";
|
|
5
|
+
import { toCustomBlockPropertyType } from "./translate.js";
|
|
3
6
|
|
|
4
7
|
describe("customBlock", () => {
|
|
5
8
|
it("supports static assets without a build command", () => {
|
|
@@ -16,4 +19,137 @@ describe("customBlock", () => {
|
|
|
16
19
|
);
|
|
17
20
|
},
|
|
18
21
|
);
|
|
22
|
+
|
|
23
|
+
it("generates mappings and default bindings from a single-source database", () => {
|
|
24
|
+
const tasks = notion.database("tasks-db", {
|
|
25
|
+
dataSourceResourceId: "tasks-source",
|
|
26
|
+
name: "Tasks",
|
|
27
|
+
description: "Work items shown on the board",
|
|
28
|
+
schema: {
|
|
29
|
+
Name: { resourceId: "task-name", type: "title" },
|
|
30
|
+
Notes: {
|
|
31
|
+
resourceId: "task-notes",
|
|
32
|
+
type: "text",
|
|
33
|
+
description: "Extra context",
|
|
34
|
+
},
|
|
35
|
+
Files: { resourceId: "task-files", type: "file" },
|
|
36
|
+
Due: { resourceId: "task-due", type: "date" },
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
expect(
|
|
41
|
+
customBlock({
|
|
42
|
+
path: "./blocks/board",
|
|
43
|
+
name: "Task board",
|
|
44
|
+
description: "Shows tasks by status",
|
|
45
|
+
dataSources: { tasks },
|
|
46
|
+
}).config,
|
|
47
|
+
).toEqual({
|
|
48
|
+
source: {
|
|
49
|
+
type: "project",
|
|
50
|
+
path: "./blocks/board",
|
|
51
|
+
command: "npx vite build",
|
|
52
|
+
output: "dist",
|
|
53
|
+
},
|
|
54
|
+
manifest: {
|
|
55
|
+
version: 1,
|
|
56
|
+
name: "Task board",
|
|
57
|
+
description: "Shows tasks by status",
|
|
58
|
+
dataSources: {
|
|
59
|
+
tasks: {
|
|
60
|
+
name: "Tasks",
|
|
61
|
+
description: "Work items shown on the board",
|
|
62
|
+
properties: {
|
|
63
|
+
Name: { name: "Name", type: "title" },
|
|
64
|
+
Notes: {
|
|
65
|
+
name: "Notes",
|
|
66
|
+
description: "Extra context",
|
|
67
|
+
type: "rich_text",
|
|
68
|
+
},
|
|
69
|
+
Files: { name: "Files", type: "files" },
|
|
70
|
+
Due: { name: "Due", type: "date" },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
defaultBindings: {
|
|
76
|
+
tasks: {
|
|
77
|
+
dataSourceResourceId: "tasks-source",
|
|
78
|
+
propertyResourceIdsByKey: {
|
|
79
|
+
Name: "task-name",
|
|
80
|
+
Notes: "task-notes",
|
|
81
|
+
Files: "task-files",
|
|
82
|
+
Due: "task-due",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("accepts a data-source handle alongside an inline mapping", () => {
|
|
90
|
+
const tasks = notion.database("tasks-db", {
|
|
91
|
+
name: "Project",
|
|
92
|
+
datasources: {
|
|
93
|
+
Tasks: {
|
|
94
|
+
resourceId: "tasks-source",
|
|
95
|
+
description: "Current tasks",
|
|
96
|
+
schema: { Name: { resourceId: "task-name", type: "title" } },
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const block = customBlock({
|
|
101
|
+
path: "./blocks/board",
|
|
102
|
+
dataSources: {
|
|
103
|
+
tasks: tasks.datasources.Tasks,
|
|
104
|
+
people: { name: "People", properties: {} },
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(block.config.manifest.dataSources).toEqual({
|
|
109
|
+
tasks: {
|
|
110
|
+
name: "Tasks",
|
|
111
|
+
description: "Current tasks",
|
|
112
|
+
properties: { Name: { name: "Name", type: "title" } },
|
|
113
|
+
},
|
|
114
|
+
people: { name: "People", properties: {} },
|
|
115
|
+
});
|
|
116
|
+
expect(block.config.defaultBindings).toEqual({
|
|
117
|
+
tasks: {
|
|
118
|
+
dataSourceResourceId: "tasks-source",
|
|
119
|
+
propertyResourceIdsByKey: { Name: "task-name" },
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("rejects multi-source database handles in the dataSources type", () => {
|
|
125
|
+
type DataSourceOption = NonNullable<CustomBlockOptions["dataSources"]>[string];
|
|
126
|
+
expectTypeOf<DatabaseHandle>().not.toExtend<DataSourceOption>();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it.each([
|
|
130
|
+
["title", "title"],
|
|
131
|
+
["text", "rich_text"],
|
|
132
|
+
["number", "number"],
|
|
133
|
+
["select", "select"],
|
|
134
|
+
["multi_select", "multi_select"],
|
|
135
|
+
["status", "status"],
|
|
136
|
+
["date", "date"],
|
|
137
|
+
["checkbox", "checkbox"],
|
|
138
|
+
["url", "url"],
|
|
139
|
+
["email", "email"],
|
|
140
|
+
["phone_number", "phone_number"],
|
|
141
|
+
["file", "files"],
|
|
142
|
+
["person", "people"],
|
|
143
|
+
["auto_increment_id", "unique_id"],
|
|
144
|
+
["relation", "relation"],
|
|
145
|
+
["formula", "formula"],
|
|
146
|
+
["rollup", "rollup"],
|
|
147
|
+
["created_time", "created_time"],
|
|
148
|
+
["last_edited_time", "last_edited_time"],
|
|
149
|
+
["created_by", "created_by"],
|
|
150
|
+
["last_edited_by", "last_edited_by"],
|
|
151
|
+
["verification", "verification"],
|
|
152
|
+
] as const)("maps Notion-as-Code %s properties to manifest %s properties", (input, output) => {
|
|
153
|
+
expect(toCustomBlockPropertyType(input)).toBe(output);
|
|
154
|
+
});
|
|
19
155
|
});
|
package/src/custom-block.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import type { ManifestDataSource } from "@notionhq/custom-blocks";
|
|
2
2
|
|
|
3
|
+
import type { DataSourceHandle, SingleSourceDatabaseHandle } from "./notion-as-code/database.js";
|
|
4
|
+
import { toCustomBlockDefaultBinding, toCustomBlockDataSource } from "./translate.js";
|
|
5
|
+
|
|
6
|
+
export type CustomBlockDefaultBinding = {
|
|
7
|
+
dataSourceResourceId: string;
|
|
8
|
+
propertyResourceIdsByKey: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type CustomBlockDataSource = ManifestDataSource | DataSourceHandle | SingleSourceDatabaseHandle;
|
|
12
|
+
|
|
3
13
|
export type CustomBlockOptions = {
|
|
4
14
|
path: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
description?: string;
|
|
5
17
|
slashCommand?: string;
|
|
6
|
-
dataSources?: Record<string,
|
|
18
|
+
dataSources?: Record<string, CustomBlockDataSource>;
|
|
7
19
|
} & (
|
|
8
20
|
| { static: true; command?: never; output?: never }
|
|
9
21
|
| { static?: false; command?: string; output?: string }
|
|
@@ -20,6 +32,7 @@ export function customBlock(options: CustomBlockOptions) {
|
|
|
20
32
|
"Custom block slashCommand must be 1–64 lowercase letters, numbers, hyphens or underscores, starting with a letter or number",
|
|
21
33
|
);
|
|
22
34
|
}
|
|
35
|
+
const { dataSources, defaultBindings } = lowerDataSources(options.dataSources ?? {});
|
|
23
36
|
return {
|
|
24
37
|
_tag: "custom_block" as const,
|
|
25
38
|
config: {
|
|
@@ -33,9 +46,43 @@ export function customBlock(options: CustomBlockOptions) {
|
|
|
33
46
|
},
|
|
34
47
|
manifest: {
|
|
35
48
|
version: 1 as const,
|
|
49
|
+
...(options.name === undefined ? {} : { name: options.name }),
|
|
50
|
+
...(options.description === undefined ? {} : { description: options.description }),
|
|
36
51
|
...(slashCommand === undefined ? {} : { slashCommand }),
|
|
37
|
-
dataSources
|
|
52
|
+
dataSources,
|
|
38
53
|
},
|
|
54
|
+
...(Object.keys(defaultBindings).length === 0 ? {} : { defaultBindings }),
|
|
39
55
|
},
|
|
40
56
|
};
|
|
41
57
|
}
|
|
58
|
+
|
|
59
|
+
function lowerDataSources(dataSources: Record<string, CustomBlockDataSource>) {
|
|
60
|
+
const manifestDataSources: Record<string, ManifestDataSource> = {};
|
|
61
|
+
const defaultBindings: Record<string, CustomBlockDefaultBinding> = {};
|
|
62
|
+
|
|
63
|
+
for (const [key, dataSource] of Object.entries(dataSources)) {
|
|
64
|
+
const handle = isSingleSourceDatabaseHandle(dataSource)
|
|
65
|
+
? dataSource.dataSource
|
|
66
|
+
: dataSource;
|
|
67
|
+
if (isDataSourceHandle(handle)) {
|
|
68
|
+
manifestDataSources[key] = toCustomBlockDataSource(handle);
|
|
69
|
+
defaultBindings[key] = toCustomBlockDefaultBinding(handle);
|
|
70
|
+
} else {
|
|
71
|
+
manifestDataSources[key] = handle;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return { dataSources: manifestDataSources, defaultBindings };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function isSingleSourceDatabaseHandle(
|
|
79
|
+
value: CustomBlockDataSource,
|
|
80
|
+
): value is SingleSourceDatabaseHandle {
|
|
81
|
+
return "dataSource" in value;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function isDataSourceHandle(
|
|
85
|
+
value: ManifestDataSource | DataSourceHandle,
|
|
86
|
+
): value is DataSourceHandle {
|
|
87
|
+
return "resourceId" in value && "schema" in value && "database" in value;
|
|
88
|
+
}
|
|
@@ -4,12 +4,15 @@ import { notion } from "./index.js";
|
|
|
4
4
|
import { finishMetadataRecording, startMetadataRecording } from "./recorder.js";
|
|
5
5
|
|
|
6
6
|
describe("Notion-as-Code custom agent declarations", () => {
|
|
7
|
-
it("records
|
|
7
|
+
it("records access, web, URL trust, and triggers", () => {
|
|
8
8
|
const recorder = startMetadataRecording();
|
|
9
9
|
|
|
10
10
|
notion.customAgent({
|
|
11
11
|
resourceId: "triage-agent",
|
|
12
12
|
name: "Triage agent",
|
|
13
|
+
webAccess: true,
|
|
14
|
+
trustedUrls: { type: "all" },
|
|
15
|
+
access: [{ resourceId: "tasks", role: "can_edit_content" }],
|
|
13
16
|
triggers: [
|
|
14
17
|
{
|
|
15
18
|
type: "recurrence",
|
|
@@ -37,6 +40,9 @@ describe("Notion-as-Code custom agent declarations", () => {
|
|
|
37
40
|
type: "custom_agent",
|
|
38
41
|
resourceId: "triage-agent",
|
|
39
42
|
name: "Triage agent",
|
|
43
|
+
webAccess: true,
|
|
44
|
+
trustedUrls: { type: "all" },
|
|
45
|
+
access: [{ resourceId: "tasks", role: "can_edit_content" }],
|
|
40
46
|
triggers: [
|
|
41
47
|
{
|
|
42
48
|
type: "recurrence",
|
|
@@ -76,4 +82,14 @@ describe("Notion-as-Code custom agent declarations", () => {
|
|
|
76
82
|
}),
|
|
77
83
|
).toThrow("reserved");
|
|
78
84
|
});
|
|
85
|
+
|
|
86
|
+
it("rejects reserved resource IDs inside access grants", () => {
|
|
87
|
+
expect(() =>
|
|
88
|
+
notion.customAgent({
|
|
89
|
+
resourceId: "triage-agent",
|
|
90
|
+
name: "Triage agent",
|
|
91
|
+
access: [{ resourceId: "__notion_apps_tasks", role: "can_view" }],
|
|
92
|
+
}),
|
|
93
|
+
).toThrow("reserved");
|
|
94
|
+
});
|
|
79
95
|
});
|
|
@@ -101,13 +101,57 @@ export type CustomAgentTrigger =
|
|
|
101
101
|
| CustomAgentPageAddedTrigger
|
|
102
102
|
| CustomAgentPropertyUpdatedTrigger;
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Defines access levels for resources that a custom agent can use.
|
|
106
|
+
*
|
|
107
|
+
* These values map to Notion module permissions: full access, content editing,
|
|
108
|
+
* commenting, and read-only.
|
|
109
|
+
*/
|
|
110
|
+
export type CustomAgentAccessRole = "full_access" | "can_edit_content" | "can_comment" | "can_view";
|
|
111
|
+
|
|
112
|
+
/** Grants a custom agent access to a page or database resource. */
|
|
113
|
+
export type CustomAgentAccess = {
|
|
114
|
+
resourceId: ResourceId;
|
|
115
|
+
role: CustomAgentAccessRole;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* URL trust settings for a custom agent.
|
|
120
|
+
*
|
|
121
|
+
* URL trust is independent from web access: an agent can trust URLs without
|
|
122
|
+
* being granted web search access.
|
|
123
|
+
*/
|
|
124
|
+
export type CustomAgentTrustedUrls = {
|
|
125
|
+
type: "all";
|
|
126
|
+
};
|
|
127
|
+
|
|
104
128
|
export type CustomAgentArgs = {
|
|
105
129
|
resourceId: ResourceId;
|
|
106
130
|
name: string;
|
|
107
131
|
icon?: Exclude<NotionAsCodeIcon, { type: "file" }>;
|
|
108
132
|
instructions?: string;
|
|
109
133
|
model?: "ambrosia-tart-high" | "opal-quince-medium" | "almond-croissant-low";
|
|
110
|
-
|
|
134
|
+
/**
|
|
135
|
+
* Whether the agent can use web search. Defaults to `false` when omitted for
|
|
136
|
+
* a new agent. When updating an existing agent, omitting this field preserves
|
|
137
|
+
* its current web access and domain restrictions.
|
|
138
|
+
*/
|
|
139
|
+
webAccess?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* URL trust policy for this agent. `{ type: "all" }` allows every HTTP and
|
|
142
|
+
* HTTPS URL. For a new agent, omitting this field leaves URL trust disabled;
|
|
143
|
+
* for an existing agent, omission preserves the current URL trust policy.
|
|
144
|
+
*/
|
|
145
|
+
trustedUrls?: CustomAgentTrustedUrls;
|
|
146
|
+
/**
|
|
147
|
+
* Grants the agent access to pages and databases.
|
|
148
|
+
*
|
|
149
|
+
* For an existing custom agent, omit this field or provide an empty list to
|
|
150
|
+
* preserve current page and database grants. Each listed resource adds a
|
|
151
|
+
* grant or replaces its existing grant with the listed role. Grants for
|
|
152
|
+
* unlisted resources remain unchanged.
|
|
153
|
+
*/
|
|
154
|
+
access?: readonly CustomAgentAccess[];
|
|
111
155
|
triggers?: readonly CustomAgentTrigger[];
|
|
112
156
|
};
|
|
113
157
|
|
|
@@ -116,11 +160,11 @@ export type CustomAgentHandle = {
|
|
|
116
160
|
readonly resourceId: string;
|
|
117
161
|
};
|
|
118
162
|
|
|
119
|
-
/** Declare a custom agent and validate every
|
|
163
|
+
/** Declare a custom agent and validate every resource reference. */
|
|
120
164
|
export function customAgent(args: CustomAgentArgs): CustomAgentHandle {
|
|
121
165
|
assertUserResourceId(args.resourceId);
|
|
122
|
-
for (const
|
|
123
|
-
assertUserResourceId(resourceId);
|
|
166
|
+
for (const grant of args.access ?? []) {
|
|
167
|
+
assertUserResourceId(grant.resourceId);
|
|
124
168
|
}
|
|
125
169
|
for (const trigger of args.triggers ?? []) {
|
|
126
170
|
assertUserResourceId(trigger.resourceId);
|
|
@@ -75,6 +75,7 @@ describe("Notion-as-Code database declarations", () => {
|
|
|
75
75
|
database.dataSource.schema.Title.resourceId,
|
|
76
76
|
).toEqualTypeOf<"single-title-id">();
|
|
77
77
|
expect(database.dataSource.schema).toEqual(schema);
|
|
78
|
+
expect(database.dataSource.name).toBe("Tasks");
|
|
78
79
|
|
|
79
80
|
const declaration = sync({
|
|
80
81
|
dataSource: database.dataSource,
|
|
@@ -636,6 +637,7 @@ describe("Notion-as-Code database declarations", () => {
|
|
|
636
637
|
notion.database("metadata-database", {
|
|
637
638
|
dataSourceResourceId: "metadata-source",
|
|
638
639
|
name: "Metadata",
|
|
640
|
+
description: "Metadata source",
|
|
639
641
|
schema: {
|
|
640
642
|
Name: { type: "title", resourceId: "metadata-name" },
|
|
641
643
|
},
|
|
@@ -658,11 +660,13 @@ describe("Notion-as-Code database declarations", () => {
|
|
|
658
660
|
type: "database",
|
|
659
661
|
resourceId: "metadata-database",
|
|
660
662
|
name: "Metadata",
|
|
663
|
+
description: "Metadata source",
|
|
661
664
|
parent: { type: "resourceId", resourceId: APPS_WORKSPACE_RESOURCE_ID },
|
|
662
665
|
dataSources: [
|
|
663
666
|
{
|
|
664
667
|
resourceId: "metadata-source",
|
|
665
668
|
name: "Metadata",
|
|
669
|
+
description: "Metadata source",
|
|
666
670
|
properties: [{ type: "title", resourceId: "metadata-name", name: "Name" }],
|
|
667
671
|
},
|
|
668
672
|
],
|
|
@@ -680,7 +684,7 @@ describe("Notion-as-Code database declarations", () => {
|
|
|
680
684
|
expect(serialized).not.toHaveProperty("schema");
|
|
681
685
|
expect(serialized).not.toHaveProperty("dataSourceResourceId");
|
|
682
686
|
expect(serialized).not.toHaveProperty("datasources");
|
|
683
|
-
expect(serialized).
|
|
687
|
+
expect(serialized.description).toBe("Metadata source");
|
|
684
688
|
});
|
|
685
689
|
|
|
686
690
|
it("requires the status property configuration in authoring types", () => {
|
|
@@ -25,6 +25,7 @@ type NonEmptyViewSchemas = readonly [ViewSchema, ...ViewSchema[]];
|
|
|
25
25
|
export type DataSourceArgs<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
|
|
26
26
|
resourceId: ResourceId;
|
|
27
27
|
name?: never;
|
|
28
|
+
description?: string;
|
|
28
29
|
schema: Schema;
|
|
29
30
|
icon?: NotionAsCodeIcon;
|
|
30
31
|
pageLayout?: DatabasePageLayout<Schema>;
|
|
@@ -120,6 +121,8 @@ export type ChildDatabaseArgs<
|
|
|
120
121
|
export type DataSourceHandle<Schema extends NotionAsCodeSchema = NotionAsCodeSchema> = {
|
|
121
122
|
readonly resourceType: "dataSource";
|
|
122
123
|
readonly resourceId: string;
|
|
124
|
+
readonly name: string;
|
|
125
|
+
readonly description?: string;
|
|
123
126
|
readonly schema: Schema;
|
|
124
127
|
readonly database: Database<AppsSchemaForSchema<Schema>>;
|
|
125
128
|
addPage: (args: ChildPageArgs) => PageHandle;
|
|
@@ -259,6 +262,7 @@ function buildDatabaseHandle(
|
|
|
259
262
|
const source: DataSourceDefinition = {
|
|
260
263
|
resourceId: args.dataSourceResourceId,
|
|
261
264
|
name: args.name,
|
|
265
|
+
...(args.description === undefined ? {} : { description: args.description }),
|
|
262
266
|
properties: normalizeProperties(args.schema),
|
|
263
267
|
...(args.pageLayout === undefined ? {} : { pageLayout: args.pageLayout }),
|
|
264
268
|
};
|
|
@@ -400,7 +404,7 @@ function createDatabase(
|
|
|
400
404
|
);
|
|
401
405
|
}
|
|
402
406
|
dataSourceIds.add(definition.resourceId);
|
|
403
|
-
handles[key] = createDataSourceHandle(definition, schema);
|
|
407
|
+
handles[key] = createDataSourceHandle(definition, schema, intent.description);
|
|
404
408
|
}
|
|
405
409
|
|
|
406
410
|
recordIntent({ ...intent, type: "database" });
|
|
@@ -419,6 +423,7 @@ function createDatabase(
|
|
|
419
423
|
function createDataSourceHandle(
|
|
420
424
|
dataSource: DataSourceDefinition,
|
|
421
425
|
schema: NotionAsCodeSchema,
|
|
426
|
+
databaseDescription: string | undefined,
|
|
422
427
|
): DataSourceHandle {
|
|
423
428
|
const propertyResourceIds = new Set<string>();
|
|
424
429
|
const propertyNames = new Set<string>();
|
|
@@ -437,10 +442,13 @@ function createDataSourceHandle(
|
|
|
437
442
|
propertyResourceIds.add(property.resourceId);
|
|
438
443
|
propertyNames.add(property.name);
|
|
439
444
|
}
|
|
445
|
+
const description = dataSource.description ?? databaseDescription;
|
|
440
446
|
|
|
441
447
|
return {
|
|
442
448
|
resourceType: "dataSource",
|
|
443
449
|
resourceId: dataSource.resourceId,
|
|
450
|
+
name: dataSource.name,
|
|
451
|
+
...(description === undefined ? {} : { description }),
|
|
444
452
|
schema,
|
|
445
453
|
database: createAppsDatabase(dataSource.resourceId, dataSource),
|
|
446
454
|
addPage(pageArgs) {
|
|
@@ -33,12 +33,15 @@ export type {
|
|
|
33
33
|
ViewPageLayoutTab,
|
|
34
34
|
} from "./intents.js";
|
|
35
35
|
export type {
|
|
36
|
+
CustomAgentAccess,
|
|
37
|
+
CustomAgentAccessRole,
|
|
36
38
|
CustomAgentArgs,
|
|
37
39
|
CustomAgentHandle,
|
|
38
40
|
CustomAgentPageAddedTrigger,
|
|
39
41
|
CustomAgentPropertyUpdatedTrigger,
|
|
40
42
|
CustomAgentRecurrenceSchedule,
|
|
41
43
|
CustomAgentRecurrenceTrigger,
|
|
44
|
+
CustomAgentTrustedUrls,
|
|
42
45
|
CustomAgentTrigger,
|
|
43
46
|
CustomAgentTriggerBase,
|
|
44
47
|
DailyRecurrenceSchedule,
|
|
@@ -66,6 +69,7 @@ export type {
|
|
|
66
69
|
SingleSourceDatabaseArgs,
|
|
67
70
|
SingleSourceDatabaseHandle,
|
|
68
71
|
} from "./database.js";
|
|
72
|
+
export { toCustomBlockDefaultBinding, toCustomBlockDataSource } from "../translate.js";
|
|
69
73
|
export type {
|
|
70
74
|
ChildPageArgs,
|
|
71
75
|
PageArgs,
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { expectTypeOf, it } from "vitest";
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
|
+
CustomAgentAccess,
|
|
5
|
+
CustomAgentAccessRole,
|
|
4
6
|
CustomAgentArgs,
|
|
5
7
|
CustomAgentPropertyUpdatedTrigger,
|
|
8
|
+
CustomAgentTrustedUrls,
|
|
6
9
|
CustomAgentTrigger,
|
|
7
10
|
DatabasePageLayout,
|
|
8
11
|
NotionAsCodePropertyConfig,
|
|
@@ -12,6 +15,28 @@ import type {
|
|
|
12
15
|
SingleSourceDatabaseArgs,
|
|
13
16
|
} from "./index.js";
|
|
14
17
|
|
|
18
|
+
it("types custom agent resource access and URL trust", () => {
|
|
19
|
+
expectTypeOf<
|
|
20
|
+
"full_access" | "can_edit_content" | "can_comment" | "can_view"
|
|
21
|
+
>().toEqualTypeOf<CustomAgentAccessRole>();
|
|
22
|
+
expectTypeOf<{
|
|
23
|
+
resourceId: "tasks";
|
|
24
|
+
role: "can_view";
|
|
25
|
+
}>().toExtend<CustomAgentAccess>();
|
|
26
|
+
expectTypeOf<{
|
|
27
|
+
resourceId: "tasks";
|
|
28
|
+
role: "read_and_write";
|
|
29
|
+
}>().not.toExtend<CustomAgentAccess>();
|
|
30
|
+
expectTypeOf<{ type: "all" }>().toEqualTypeOf<CustomAgentTrustedUrls>();
|
|
31
|
+
expectTypeOf<CustomAgentArgs["webAccess"]>().toEqualTypeOf<boolean | undefined>();
|
|
32
|
+
expectTypeOf<CustomAgentArgs["trustedUrls"]>().toEqualTypeOf<
|
|
33
|
+
CustomAgentTrustedUrls | undefined
|
|
34
|
+
>();
|
|
35
|
+
expectTypeOf<CustomAgentArgs["access"]>().toEqualTypeOf<
|
|
36
|
+
readonly CustomAgentAccess[] | undefined
|
|
37
|
+
>();
|
|
38
|
+
});
|
|
39
|
+
|
|
15
40
|
it("types page and database covers as URL references", () => {
|
|
16
41
|
expectTypeOf<{
|
|
17
42
|
type: "url";
|
package/src/translate.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ManifestDataSource,
|
|
3
|
+
ManifestProperty,
|
|
4
|
+
NotionPropertyType,
|
|
5
|
+
} from "@notionhq/custom-blocks";
|
|
6
|
+
|
|
7
|
+
import type { CustomBlockDefaultBinding } from "./custom-block.js";
|
|
8
|
+
import type { DataSourceHandle } from "./notion-as-code/database.js";
|
|
9
|
+
import type { NotionAsCodeProperty } from "./notion-as-code/intents.js";
|
|
10
|
+
|
|
11
|
+
/** Lower a Notion-as-Code handle into the declaration consumed by custom block hosts. */
|
|
12
|
+
export function toCustomBlockDataSource(handle: DataSourceHandle): ManifestDataSource {
|
|
13
|
+
return {
|
|
14
|
+
name: handle.name,
|
|
15
|
+
...(handle.description === undefined ? {} : { description: handle.description }),
|
|
16
|
+
properties: Object.fromEntries(
|
|
17
|
+
Object.entries(handle.schema).map(([key, property]) => [
|
|
18
|
+
key,
|
|
19
|
+
{
|
|
20
|
+
name: key,
|
|
21
|
+
...(typeof property.description !== "string"
|
|
22
|
+
? {}
|
|
23
|
+
: { description: property.description }),
|
|
24
|
+
type: toCustomBlockPropertyType(property.type),
|
|
25
|
+
} satisfies ManifestProperty,
|
|
26
|
+
]),
|
|
27
|
+
),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Keep resource IDs in the build artifact so deploy can resolve workspace-local IDs later. */
|
|
32
|
+
export function toCustomBlockDefaultBinding(handle: DataSourceHandle): CustomBlockDefaultBinding {
|
|
33
|
+
return {
|
|
34
|
+
dataSourceResourceId: handle.resourceId,
|
|
35
|
+
propertyResourceIdsByKey: Object.fromEntries(
|
|
36
|
+
Object.entries(handle.schema).map(([key, property]) => [key, property.resourceId]),
|
|
37
|
+
),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function toCustomBlockPropertyType(type: NotionAsCodeProperty["type"]): NotionPropertyType {
|
|
42
|
+
switch (type) {
|
|
43
|
+
case "text":
|
|
44
|
+
return "rich_text";
|
|
45
|
+
case "file":
|
|
46
|
+
return "files";
|
|
47
|
+
case "person":
|
|
48
|
+
return "people";
|
|
49
|
+
case "auto_increment_id":
|
|
50
|
+
return "unique_id";
|
|
51
|
+
case "title":
|
|
52
|
+
case "number":
|
|
53
|
+
case "select":
|
|
54
|
+
case "multi_select":
|
|
55
|
+
case "status":
|
|
56
|
+
case "date":
|
|
57
|
+
case "checkbox":
|
|
58
|
+
case "url":
|
|
59
|
+
case "email":
|
|
60
|
+
case "phone_number":
|
|
61
|
+
case "relation":
|
|
62
|
+
case "formula":
|
|
63
|
+
case "rollup":
|
|
64
|
+
case "created_time":
|
|
65
|
+
case "last_edited_time":
|
|
66
|
+
case "created_by":
|
|
67
|
+
case "last_edited_by":
|
|
68
|
+
case "verification":
|
|
69
|
+
return type;
|
|
70
|
+
default:
|
|
71
|
+
return assertNever(type);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function assertNever(value: never): never {
|
|
76
|
+
throw new Error(`Unsupported Notion-as-Code property type: ${String(value)}`);
|
|
77
|
+
}
|