@notionhq/custom-blocks 0.1.15 → 0.1.16
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/bridge/SandboxBridge.d.ts +7 -7
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +30 -30
- package/dist/bridge/hostState.d.ts +2 -2
- package/dist/bridge/hostState.d.ts.map +1 -1
- package/dist/bridge/hostState.js +2 -2
- package/dist/bridge/sandboxClient.d.ts +4 -4
- package/dist/bridge/sandboxClient.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/protocol/dataSources/dataSourcePage.d.ts +8 -2
- package/dist/protocol/dataSources/dataSourcePage.d.ts.map +1 -1
- package/dist/types.d.ts +23 -20
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/data-sources.md +3 -2
- package/docs/pages.md +4 -2
- package/docs/users.md +3 -2
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +36 -36
- package/src/bridge/hostState.ts +4 -4
- package/src/bridge/sandboxClient.ts +6 -6
- package/src/index.ts +1 -0
- package/src/types.ts +28 -21
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NotionDataSourcePageUpdateArgs, NotionDataSourcePageUpdateResult } from "../protocol/dataSources/dataSourcePage.js";
|
|
3
3
|
import { type InitMessage } from "../protocol/messages/init.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { CreatePageArgs, CreatePageResult, GetPageResult, GetUserResult, ListUsersArgs, ListUsersResult, NotionPageId, NotionUserId, UpdatePageArgs, UpdatePageResult, UseDataSourceOptions } from "../types.js";
|
|
5
5
|
import { type CustomBlockHostState } from "./hostState.js";
|
|
6
6
|
import type { ManifestLoadResult } from "./loadManifest.js";
|
|
7
7
|
/**
|
|
@@ -55,11 +55,11 @@ export declare class SandboxBridge {
|
|
|
55
55
|
queryDataSource(key: string, options?: UseDataSourceOptions): void;
|
|
56
56
|
private setDataSourceQueryError;
|
|
57
57
|
postResize(height: number): void;
|
|
58
|
-
createPage(
|
|
58
|
+
createPage(args: CreatePageArgs): Promise<CreatePageResult>;
|
|
59
59
|
getPage(pageId: NotionPageId): Promise<GetPageResult>;
|
|
60
60
|
getUser(userId: NotionUserId): Promise<GetUserResult>;
|
|
61
|
-
listUsers(
|
|
62
|
-
updatePage(
|
|
61
|
+
listUsers(args?: ListUsersArgs): Promise<ListUsersResult>;
|
|
62
|
+
updatePage(args: UpdatePageArgs): Promise<UpdatePageResult>;
|
|
63
63
|
/**
|
|
64
64
|
* Updates a page on a known data source, resolving any property keys against the data source's
|
|
65
65
|
* `propertyIdsByKey` before sending the bridge message. Used by the per-row `update` callback
|
|
@@ -68,10 +68,10 @@ export declare class SandboxBridge {
|
|
|
68
68
|
updateDataSourcePage(args: {
|
|
69
69
|
dataSource: NotionDataSource;
|
|
70
70
|
pageId: NotionPageId;
|
|
71
|
-
|
|
71
|
+
pageUpdateArgs: NotionDataSourcePageUpdateArgs;
|
|
72
72
|
}): Promise<NotionDataSourcePageUpdateResult>;
|
|
73
73
|
/**
|
|
74
|
-
* Translates the public `
|
|
74
|
+
* Translates the public `CreatePageArgs["parent"]` into the bridge-native
|
|
75
75
|
* `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against
|
|
76
76
|
* the data source mapping the host delivered in `init` / `dataSourcesChanged`.
|
|
77
77
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SandboxBridge.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/SandboxBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,gBAAgB,EAEhB,MAAM,4DAA4D,CAAA;AACnE,OAAO,KAAK,EACX
|
|
1
|
+
{"version":3,"file":"SandboxBridge.d.ts","s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QAC5B,MAAM,EAAE,YAAY,CAAA;QACpB,cAAc,EAAE,8BAA8B,CAAA;KAC9C,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAuB7C;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;CAkE/B"}
|
|
@@ -509,16 +509,16 @@ export class SandboxBridge {
|
|
|
509
509
|
};
|
|
510
510
|
this.postToHost(outbound);
|
|
511
511
|
}
|
|
512
|
-
createPage(
|
|
512
|
+
createPage(args) {
|
|
513
513
|
return new Promise(resolve => {
|
|
514
|
-
const resolvedParent = this.resolveCreatePageParent(
|
|
514
|
+
const resolvedParent = this.resolveCreatePageParent(args.parent);
|
|
515
515
|
if (resolvedParent.status === "error") {
|
|
516
516
|
resolve(resolvedParent);
|
|
517
517
|
return;
|
|
518
518
|
}
|
|
519
519
|
const resolvedProperties = resolvePropertyWriteMapForDataSource({
|
|
520
520
|
dataSource: resolvedParent.dataSource,
|
|
521
|
-
properties:
|
|
521
|
+
properties: args.properties,
|
|
522
522
|
operationName: "createPage",
|
|
523
523
|
});
|
|
524
524
|
if (resolvedProperties.status === "error") {
|
|
@@ -532,8 +532,8 @@ export class SandboxBridge {
|
|
|
532
532
|
parent: resolvedParent.parent,
|
|
533
533
|
properties: resolvedProperties.properties,
|
|
534
534
|
};
|
|
535
|
-
if (
|
|
536
|
-
outbound.position =
|
|
535
|
+
if (args.position !== undefined) {
|
|
536
|
+
outbound.position = args.position;
|
|
537
537
|
}
|
|
538
538
|
this.postToHost(outbound);
|
|
539
539
|
});
|
|
@@ -560,25 +560,25 @@ export class SandboxBridge {
|
|
|
560
560
|
this.postToHost(outbound);
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
|
-
listUsers(
|
|
563
|
+
listUsers(args = {}) {
|
|
564
564
|
return new Promise(resolve => {
|
|
565
565
|
const requestId = this.pendingListUsers.allocate(resolve);
|
|
566
566
|
const outbound = {
|
|
567
567
|
type: "listUsers",
|
|
568
568
|
requestId,
|
|
569
|
-
startCursor:
|
|
570
|
-
pageSize:
|
|
569
|
+
startCursor: args.startCursor,
|
|
570
|
+
pageSize: args.pageSize,
|
|
571
571
|
};
|
|
572
572
|
this.postToHost(outbound);
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
|
-
updatePage(
|
|
575
|
+
updatePage(args) {
|
|
576
576
|
return new Promise(resolve => {
|
|
577
|
-
if ((
|
|
578
|
-
Object.keys(
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
577
|
+
if ((args.properties === undefined ||
|
|
578
|
+
Object.keys(args.properties).length === 0) &&
|
|
579
|
+
args.icon === undefined &&
|
|
580
|
+
args.cover === undefined &&
|
|
581
|
+
args.archived === undefined) {
|
|
582
582
|
resolve({
|
|
583
583
|
status: "error",
|
|
584
584
|
error: {
|
|
@@ -593,19 +593,19 @@ export class SandboxBridge {
|
|
|
593
593
|
const outbound = {
|
|
594
594
|
type: "updatePage",
|
|
595
595
|
requestId,
|
|
596
|
-
pageId:
|
|
596
|
+
pageId: args.pageId,
|
|
597
597
|
};
|
|
598
|
-
if (
|
|
599
|
-
outbound.properties =
|
|
598
|
+
if (args.properties !== undefined) {
|
|
599
|
+
outbound.properties = args.properties;
|
|
600
600
|
}
|
|
601
|
-
if (
|
|
602
|
-
outbound.icon =
|
|
601
|
+
if (args.icon !== undefined) {
|
|
602
|
+
outbound.icon = args.icon;
|
|
603
603
|
}
|
|
604
|
-
if (
|
|
605
|
-
outbound.cover =
|
|
604
|
+
if (args.cover !== undefined) {
|
|
605
|
+
outbound.cover = args.cover;
|
|
606
606
|
}
|
|
607
|
-
if (
|
|
608
|
-
outbound.archived =
|
|
607
|
+
if (args.archived !== undefined) {
|
|
608
|
+
outbound.archived = args.archived;
|
|
609
609
|
}
|
|
610
610
|
this.postToHost(outbound);
|
|
611
611
|
});
|
|
@@ -616,12 +616,12 @@ export class SandboxBridge {
|
|
|
616
616
|
* returned from {@link getDataSourceQueryView}.
|
|
617
617
|
*/
|
|
618
618
|
updateDataSourcePage(args) {
|
|
619
|
-
const { dataSource, pageId,
|
|
620
|
-
const resolvedProperties =
|
|
619
|
+
const { dataSource, pageId, pageUpdateArgs } = args;
|
|
620
|
+
const resolvedProperties = pageUpdateArgs.properties === undefined
|
|
621
621
|
? undefined
|
|
622
622
|
: resolvePropertyWriteMapForDataSource({
|
|
623
623
|
dataSource,
|
|
624
|
-
properties:
|
|
624
|
+
properties: pageUpdateArgs.properties,
|
|
625
625
|
operationName: "dataSourcePage.update",
|
|
626
626
|
});
|
|
627
627
|
if (resolvedProperties?.status === "error") {
|
|
@@ -630,13 +630,13 @@ export class SandboxBridge {
|
|
|
630
630
|
return this.updatePage({
|
|
631
631
|
pageId,
|
|
632
632
|
properties: resolvedProperties?.properties,
|
|
633
|
-
icon:
|
|
634
|
-
cover:
|
|
635
|
-
archived:
|
|
633
|
+
icon: pageUpdateArgs.icon,
|
|
634
|
+
cover: pageUpdateArgs.cover,
|
|
635
|
+
archived: pageUpdateArgs.archived,
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
/**
|
|
639
|
-
* Translates the public `
|
|
639
|
+
* Translates the public `CreatePageArgs["parent"]` into the bridge-native
|
|
640
640
|
* `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against
|
|
641
641
|
* the data source mapping the host delivered in `init` / `dataSourcesChanged`.
|
|
642
642
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NotionContrastMode } from "../protocol/contrast.js";
|
|
2
2
|
import type { NotionDataSource } from "../protocol/dataSources/dataSource.js";
|
|
3
|
-
import type { NotionDataSourcePage, NotionDataSourcePageBridge,
|
|
3
|
+
import type { NotionDataSourcePage, NotionDataSourcePageBridge, NotionDataSourcePageUpdateArgs, NotionDataSourcePageUpdateResult } from "../protocol/dataSources/dataSourcePage.js";
|
|
4
4
|
import type { NotionPropertySchema } from "../protocol/dataSources/propertySchema.js";
|
|
5
5
|
import type { NotionBlockId } from "../protocol/ids.js";
|
|
6
6
|
import type { CustomBlockManifest } from "../protocol/manifest.js";
|
|
@@ -66,7 +66,7 @@ export type DataSourceQueryView = {
|
|
|
66
66
|
export type UpdateDataSourcePageFn = (args: {
|
|
67
67
|
dataSource: NotionDataSource;
|
|
68
68
|
pageId: NotionPageId;
|
|
69
|
-
|
|
69
|
+
pageUpdateArgs: NotionDataSourcePageUpdateArgs;
|
|
70
70
|
}) => Promise<NotionDataSourcePageUpdateResult>;
|
|
71
71
|
export declare function getDataSourceQueryView(hostState: CustomBlockHostState, key: string, updateDataSourcePage: UpdateDataSourcePageFn): DataSourceQueryView;
|
|
72
72
|
//# sourceMappingURL=hostState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,EACX,oBAAoB,EACpB,0BAA0B,EAC1B
|
|
1
|
+
{"version":3,"file":"hostState.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/hostState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4DAA4D,CAAA;AAClG,OAAO,KAAK,EACX,oBAAoB,EACpB,0BAA0B,EAC1B,8BAA8B,EAC9B,gCAAgC,EAChC,MAAM,gEAAgE,CAAA;AAEvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAA;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAA;AACvF,OAAO,KAAK,EAAE,m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AAK,EAAE,oBAAoB,EAAE,CAAA;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,CAAA;IACvD,mBAAmB,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,oBAAoB,CAAA;KAAE,CAAA;IACnE,gBAAgB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACvD,oBAAoB,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAAA;KAAE,CAAA;IACzE,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,mCAAmC,CAAA;CAC3C,CAAA;AAWD;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,IAAI,EAAE;IAC3C,UAAU,EAAE,gBAAgB,CAAA;IAC5B,MAAM,EAAE,YAAY,CAAA;IACpB,cAAc,EAAE,8BAA8B,CAAA;CAC9C,KAAK,OAAO,CAAC,gCAAgC,CAAC,CAAA;AAE/C,wBAAgB,sBAAsB,CACrC,SAAS,EAAE,oBAAoB,EAC/B,GAAG,EAAE,MAAM,EACX,oBAAoB,EAAE,sBAAsB,GAC1C,mBAAmB,CAgErB"}
|
package/dist/bridge/hostState.js
CHANGED
|
@@ -43,10 +43,10 @@ export function getDataSourceQueryView(hostState, key, updateDataSourcePage) {
|
|
|
43
43
|
id: entry.id,
|
|
44
44
|
propertiesById: entry.propertiesById,
|
|
45
45
|
propertiesByKey,
|
|
46
|
-
update:
|
|
46
|
+
update: args => updateDataSourcePage({
|
|
47
47
|
dataSource,
|
|
48
48
|
pageId: entry.id,
|
|
49
|
-
|
|
49
|
+
pageUpdateArgs: args,
|
|
50
50
|
}),
|
|
51
51
|
};
|
|
52
52
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InitMessage } from "../protocol/messages/init.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreatePageArgs, CreatePageResult, GetPageResult, GetUserResult, ListUsersArgs, ListUsersResult, NotionPageId, NotionUserId, UpdatePageArgs, UpdatePageResult, UseDataSourceOptions } from "../types.js";
|
|
3
3
|
import { type CustomBlockHostState, type DataSourceQueryView } from "./hostState.js";
|
|
4
4
|
import type { ManifestLoadResult } from "./loadManifest.js";
|
|
5
5
|
import { type MessageLogEntry } from "./SandboxBridge.js";
|
|
@@ -31,7 +31,7 @@ export declare const pages: {
|
|
|
31
31
|
/**
|
|
32
32
|
* Creates a new Notion page.
|
|
33
33
|
*/
|
|
34
|
-
create: (input:
|
|
34
|
+
create: (input: CreatePageArgs) => Promise<CreatePageResult>;
|
|
35
35
|
/**
|
|
36
36
|
* Fetches a page by id.
|
|
37
37
|
*/
|
|
@@ -39,7 +39,7 @@ export declare const pages: {
|
|
|
39
39
|
/**
|
|
40
40
|
* Updates an existing page.
|
|
41
41
|
*/
|
|
42
|
-
update: (input:
|
|
42
|
+
update: (input: UpdatePageArgs) => Promise<UpdatePageResult>;
|
|
43
43
|
/**
|
|
44
44
|
* Soft-delete a page by archiving it.
|
|
45
45
|
*/
|
|
@@ -52,7 +52,7 @@ export declare const users: {
|
|
|
52
52
|
/**
|
|
53
53
|
* Lists users visible in the current custom block workspace.
|
|
54
54
|
*/
|
|
55
|
-
list: (input?:
|
|
55
|
+
list: (input?: ListUsersArgs) => Promise<ListUsersResult>;
|
|
56
56
|
/**
|
|
57
57
|
* Fetches a user by id.
|
|
58
58
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/bridge/sandboxClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAA;AACpF,OAAO,KAAK,EACX,
|
|
1
|
+
{"version":3,"file":"sandboxClient.d.ts","sourceRoot":"","sources":["../../../../home/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G,OAAO,CAAC,eAAe,CAAC;IAIvD;;OAEG;kBACW,YAAY,KAAG,OAAO,CAAC,aAAa,CAAC;CAGnD,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export type { NotionContrastMode } from "./protocol/contrast.js";
|
|
10
10
|
export type { NotionCollectionSchema, NotionDataSource, } from "./protocol/dataSources/dataSource.js";
|
|
11
|
-
export type { NotionDataSourcePage, NotionDataSourcePageUpdateInput, NotionDataSourcePageUpdateResult, } from "./protocol/dataSources/dataSourcePage.js";
|
|
11
|
+
export type { NotionDataSourcePage, NotionDataSourcePageUpdateArgs, NotionDataSourcePageUpdateInput, NotionDataSourcePageUpdateResult, } from "./protocol/dataSources/dataSourcePage.js";
|
|
12
12
|
export type { NotionDataSourceValue } from "./protocol/dataSources/dataSourceValue.js";
|
|
13
13
|
export type { NotionDate, NotionDateRange, NotionDateReminder, NotionDateTime, NotionDateTimeRange, NotionDateTimeReminder, NotionDateValue, NotionNoReminder, NotionTimeReminder, } from "./protocol/dataSources/dateValue.js";
|
|
14
14
|
export type { CustomBlockDataSourceResolutionErrorCode, CustomBlockDataSourceResolutionErrorInfo, CustomBlockPropertyErrorCode, CustomBlockPropertyErrorInfo, } from "./protocol/dataSources/errors.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,YAAY,EACX,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,4DAA4D,CAAA;AACnE,YAAY,EACX,oBAAoB,EACpB,+BAA+B,EAC/B,gCAAgC,GAChC,MAAM,gEAAgE,CAAA;AACvE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iEAAiE,C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AmC,GACnC,MAAM,oEAAoE,CAAA;AAC3E,YAAY,EACX,8BAA8B,EAC9B,8BAA8B,GAC9B,MAAM,+DAA+D,CAAA;AACtE,YAAY,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACZ,0BAA0B,EAC1B,4BAA4B,EAC5B,uBAAuB,EACvB,0BAA0B,GAC1B,MAAM,gDAAgD,CAAA;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,YAAY,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,eAAe,EACf,gBAAgB,GAChB,MAAM,WAAW,CAAA;AAClB,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,YAAY,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAA;AACtF,YAAY,EACX,sBAAsB,EACtB,gBAAgB,GAChB,MAAM,4DAA4D,CAAA;AACnE,YAAY,EACX,oBAAoB,EACpB,8BAA8B,EAC9B,+BAA+B,EAC/B,gCAAgC,GAChC,MAAM,gEAAgE,CAAA;AACvE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iEAAiE,CAAA;AAC5G,YAAY,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GAClB,MAAM,2DAA2D,CAAA;AAClE,YAAY,EACX,wCAAwC,EACxC,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,GAC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AAgD,CAAA;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAA;AAC9E,YAAY,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAA;AAC5E,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,EAAE,KAAK,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EACN,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,eAAe,EACf,gBAAgB,GAChB,MAAM,WAAW,CAAA;AAClB,cAAc,YAAY,CAAA"}
|
|
@@ -75,12 +75,18 @@ export declare const notionDataSourcePageBridgeSchema: v.ObjectSchema<{
|
|
|
75
75
|
}, undefined>;
|
|
76
76
|
/** Internal SDK type for a parsed bridge page. */
|
|
77
77
|
export type NotionDataSourcePageBridge = v.InferOutput<typeof notionDataSourcePageBridgeSchema>;
|
|
78
|
-
export type
|
|
78
|
+
export type NotionDataSourcePageUpdateArgs = {
|
|
79
79
|
properties?: NotionPagePropertyInputMap;
|
|
80
80
|
icon?: NotionPageIcon;
|
|
81
81
|
cover?: NotionPageCover;
|
|
82
82
|
archived?: boolean;
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* @deprecated Use `NotionDataSourcePageUpdateArgs` instead.
|
|
86
|
+
*
|
|
87
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
88
|
+
*/
|
|
89
|
+
export type NotionDataSourcePageUpdateInput = NotionDataSourcePageUpdateArgs;
|
|
84
90
|
export type NotionDataSourcePageUpdateResult = {
|
|
85
91
|
status: "success";
|
|
86
92
|
page: NotionPage;
|
|
@@ -113,6 +119,6 @@ export type NotionDataSourcePage = {
|
|
|
113
119
|
* Updates this page using the data source's property-key bindings. The SDK resolves property
|
|
114
120
|
* keys to raw property IDs before sending the bridge message to the host.
|
|
115
121
|
*/
|
|
116
|
-
update: (
|
|
122
|
+
update: (args: NotionDataSourcePageUpdateArgs) => Promise<NotionDataSourcePageUpdateResult>;
|
|
117
123
|
};
|
|
118
124
|
//# sourceMappingURL=dataSourcePage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataSourcePage.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/dataSources/dataSourcePage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAA;AACrF,OAAO,KAAK,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACZ,0BAA0B,EAC1B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,KAAK,qBAAqB,EAE1B,MAAM,sBAAsB,CAAA;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAG3C,CAAA;AAEF,kDAAkD;AAClD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,WAAW,CACrD,OAAO,gCAAgC,CACvC,CAAA;AAED,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"dataSourcePage.d.ts","sourceRoot":"","sources":["../../../../../home/runner/work/custom-blocks/custom-blocks/protocol/src/dataSources/dataSourcePage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAA;AACrF,OAAO,KAAK,EACX,UAAU,EACV,eAAe,EACf,cAAc,EACd,YAAY,EACZ,0BAA0B,EAC1B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,KAAK,qBAAqB,EAE1B,MAAM,sBAAsB,CAAA;AAE7B;;;;;;GAMG;AACH,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAG3C,CAAA;AAEF,kDAAkD;AAClD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,WAAW,CACrD,OAAO,gCAAgC,CACvC,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC5C,UAAU,CAAC,EAAE,0BAA0B,CAAA;IACvC,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,+BAA+B,GAAG,8BAA8B,CAAA;AAE5E,MAAM,MAAM,gCAAgC,GACzC;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;CACf,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,8BAA8B,CAAA;CAAE,CAAA;AAE7D;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,EAAE,EAAE,YAAY,CAAA;IAChB;;;;OAIG;IACH,cAAc,EAAE;QAAE,CAAC,UAAU,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAA;KAAE,CAAA;IAC3E;;;OAGG;IACH,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAAA;KAAE,CAAA;IACrE;;;OAGG;IACH,MAAM,EAAE,CACP,IAAI,EAAE,8BAA8B,KAChC,OAAO,CAAC,gCAAgC,CAAC,CAAA;CAC9C,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,12 +6,13 @@ import type { NotionCreatePagePosition } from "./protocol/messages/createPage.js
|
|
|
6
6
|
import type { CustomBlockCreatePageErrorInfo } from "./protocol/messages/createPageResult.js";
|
|
7
7
|
import type { CustomBlockGetPageErrorInfo } from "./protocol/messages/getPage.js";
|
|
8
8
|
import type { CustomBlockGetUserErrorInfo } from "./protocol/messages/getUser.js";
|
|
9
|
-
import type { CustomBlockListUsersErrorInfo } from "./protocol/messages/listUsers.js";
|
|
9
|
+
import type { CustomBlockListUsersErrorInfo, ListUsersMessage } from "./protocol/messages/listUsers.js";
|
|
10
10
|
import type { CustomBlockQueryDataSourceErrorInfo } from "./protocol/messages/queryDataSourceResult.js";
|
|
11
|
+
import type { UpdatePageMessage } from "./protocol/messages/updatePage.js";
|
|
11
12
|
import type { CustomBlockUpdatePageErrorInfo } from "./protocol/messages/updatePageResult.js";
|
|
12
|
-
import type { NotionPage,
|
|
13
|
+
import type { NotionPage, NotionPageId, NotionPagePropertyInputMap } from "./protocol/pages/page.js";
|
|
13
14
|
import type { NotionUser, NotionUserList } from "./protocol/users/user.js";
|
|
14
|
-
export type { NotionDataSourcePageUpdateInput, NotionDataSourcePageUpdateResult, } from "./protocol/dataSources/dataSourcePage.js";
|
|
15
|
+
export type { NotionDataSourcePageUpdateArgs, NotionDataSourcePageUpdateInput, NotionDataSourcePageUpdateResult, } from "./protocol/dataSources/dataSourcePage.js";
|
|
15
16
|
export type { CustomBlockErrorInfo } from "./protocol/errors.js";
|
|
16
17
|
export type { NotionDataSourceId, NotionSpaceId, } from "./protocol/ids.js";
|
|
17
18
|
export type { NotionPageId } from "./protocol/pages/page.js";
|
|
@@ -87,13 +88,19 @@ export type CreatePageParent = {
|
|
|
87
88
|
key: string;
|
|
88
89
|
};
|
|
89
90
|
/**
|
|
90
|
-
*
|
|
91
|
+
* Arguments accepted by `sdk.pages.create`. Mirrors the Notion public API `POST /v1/pages` API.
|
|
91
92
|
*/
|
|
92
|
-
export type
|
|
93
|
+
export type CreatePageArgs = {
|
|
93
94
|
parent: CreatePageParent;
|
|
94
95
|
properties: NotionPagePropertyInputMap;
|
|
95
96
|
position?: NotionCreatePagePosition;
|
|
96
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated Use `CreatePageArgs` instead.
|
|
100
|
+
*
|
|
101
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
102
|
+
*/
|
|
103
|
+
export type CreatePageInput = CreatePageArgs;
|
|
97
104
|
/**
|
|
98
105
|
* The result of a `sdk.pages.create` API call.
|
|
99
106
|
*/
|
|
@@ -105,20 +112,13 @@ export type CreatePageResult = {
|
|
|
105
112
|
status: "error";
|
|
106
113
|
error: CustomBlockCreatePageErrorInfo;
|
|
107
114
|
};
|
|
115
|
+
export type UpdatePageArgs = Omit<UpdatePageMessage, "type" | "requestId">;
|
|
108
116
|
/**
|
|
109
|
-
*
|
|
117
|
+
* @deprecated Use `UpdatePageArgs` instead.
|
|
110
118
|
*
|
|
111
|
-
*
|
|
112
|
-
* custom-block property keys, use the `update` helper on pages returned from
|
|
113
|
-
* `useDataSource`.
|
|
119
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
114
120
|
*/
|
|
115
|
-
export type UpdatePageInput =
|
|
116
|
-
pageId: NotionPageId;
|
|
117
|
-
properties?: NotionPagePropertyWriteMap;
|
|
118
|
-
icon?: NotionPageIcon;
|
|
119
|
-
cover?: NotionPageCover;
|
|
120
|
-
archived?: boolean;
|
|
121
|
-
};
|
|
121
|
+
export type UpdatePageInput = UpdatePageArgs;
|
|
122
122
|
/**
|
|
123
123
|
* Result of `sdk.pages.get`.
|
|
124
124
|
*/
|
|
@@ -139,10 +139,13 @@ export type UpdatePageResult = {
|
|
|
139
139
|
status: "error";
|
|
140
140
|
error: CustomBlockUpdatePageErrorInfo;
|
|
141
141
|
};
|
|
142
|
-
export type
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">;
|
|
143
|
+
/**
|
|
144
|
+
* @deprecated Use `ListUsersArgs` instead.
|
|
145
|
+
*
|
|
146
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
147
|
+
*/
|
|
148
|
+
export type ListUsersInput = ListUsersArgs;
|
|
146
149
|
export type ListUsersResult = {
|
|
147
150
|
status: "success";
|
|
148
151
|
list: NotionUserList;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../home/runner/work/custom-blocks/custom-blocks/sdk/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAA;AACxG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gEAAgE,CAAA;AAC1G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAA;AACjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yDAAyD,CAAA;AACvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+DAA+D,CAAA;AACnH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAA;AACvG,OAAO,KAAK,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I,EAAE,UAAU,CAAA;CACf,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,2BAA2B,CAAA;CAAE,CAAA;AAE1D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACzB;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;CACf,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,8BAA8B,CAAA;CAAE,CAAA;AAE7D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,WAAW,CAAC,CAAA;AAExE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,CAAA;AAE1C,MAAM,MAAM,eAAe,GACxB;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,cAAc,CAAA;CACnB,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,6BAA6B,CAAA;CAAE,CAAA;AAE5D,MAAM,MAAM,aAAa,GACtB;IACA,MAAM,EAAE,SAAS,CAAA;IACjB,IAAI,EAAE,UAAU,CAAA;CACf,GACD;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,2BAA2B,CAAA;CAAE,CAAA"}
|
package/dist/version.js
CHANGED
package/docs/data-sources.md
CHANGED
|
@@ -30,7 +30,7 @@ await row.update({
|
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Property values can be keyed by **either** semantic keys or raw IDs. The SDK resolves semantic keys to IDs before sending the request.
|
|
34
34
|
|
|
35
35
|
Use `row.update(...)` whenever you already have a row in hand. For pages you don't have a row for (e.g. you only have a `pageId`), drop down to the top-level [`pages` API](./pages.md) — it covers create / get / update / delete and accepts raw property IDs only.
|
|
36
36
|
|
|
@@ -158,7 +158,8 @@ export function ScoreList() {
|
|
|
158
158
|
- `NotionDataSource` — a resolved data source: semantic key, `collectionSchema`, `propertyIdsByKey`, `propertySchemasById`.
|
|
159
159
|
- `NotionDataSourcePage` — a single row exposed to app code: `{ id, propertiesById, propertiesByKey, update }`.
|
|
160
160
|
- `NotionDataSourceValue` — the discriminated union of values that can appear inside `propertiesById[propertyId]`. Date values branch into the `NotionDateValue` union below.
|
|
161
|
-
- `
|
|
161
|
+
- `NotionDataSourcePageUpdateArgs` / `NotionDataSourcePageUpdateResult` — arguments and result for the per-page `update` helper.
|
|
162
|
+
- `NotionDataSourcePageUpdateInput` — deprecated alias for `NotionDataSourcePageUpdateArgs`.
|
|
162
163
|
- `UseDataSourceOptions` — options accepted by `useDataSource`, currently `{ limit?: number }`.
|
|
163
164
|
|
|
164
165
|
### Property schemas
|
package/docs/pages.md
CHANGED
|
@@ -138,6 +138,8 @@ Do **not** send `{ type: "file_upload", file_upload: { id } }`; the host will re
|
|
|
138
138
|
- `NotionPagePropertyInputMap` — input map for `pages.create` (keys can be raw property IDs, or semantic keys when creating into a mapped data source).
|
|
139
139
|
- `NotionPagePropertyWriteMap` — input map for `pages.update` (raw property IDs only).
|
|
140
140
|
- `NotionCreatePagePosition` — `start` / `end` / `before` / `after` insertion variants.
|
|
141
|
-
- `
|
|
141
|
+
- `CreatePageArgs` / `CreatePageParent` / `CreatePageResult`.
|
|
142
|
+
- `CreatePageInput` — deprecated alias for `CreatePageArgs`.
|
|
142
143
|
- `GetPageResult`.
|
|
143
|
-
- `
|
|
144
|
+
- `UpdatePageArgs` / `UpdatePageResult`.
|
|
145
|
+
- `UpdatePageInput` — deprecated alias for `UpdatePageArgs`.
|
package/docs/users.md
CHANGED
|
@@ -55,7 +55,7 @@ if (result.list.has_more && result.list.next_cursor) {
|
|
|
55
55
|
}
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
`
|
|
58
|
+
`ListUsersArgs` accepts `pageSize` and `startCursor`; both are optional. `ListUsersResult` resolves to either `{ status: "success", list }` or `{ status: "error", error }`, where `list` is a `NotionUserList` (with `results`, `next_cursor`, `has_more`).
|
|
59
59
|
|
|
60
60
|
## Reading a single user
|
|
61
61
|
|
|
@@ -77,5 +77,6 @@ if (result.status === "success") {
|
|
|
77
77
|
- `NotionUserList` — paginated list shape returned by `users.list`.
|
|
78
78
|
- `useCurrentUser()` — hook that returns the viewer's `NotionUser`.
|
|
79
79
|
- `customBlock.getCurrentUser()` — framework-neutral getter for the viewer's `NotionUser`.
|
|
80
|
-
- `
|
|
80
|
+
- `ListUsersArgs` / `ListUsersResult`.
|
|
81
|
+
- `ListUsersInput` — deprecated alias for `ListUsersArgs`.
|
|
81
82
|
- `GetUserResult`.
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
NotionDataSourceBindings,
|
|
5
5
|
} from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
6
6
|
import type {
|
|
7
|
-
|
|
7
|
+
NotionDataSourcePageUpdateArgs,
|
|
8
8
|
NotionDataSourcePageUpdateResult,
|
|
9
9
|
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
10
10
|
import { readIncomingType } from "@notionhq/custom-blocks-protocol/incomingType.js"
|
|
@@ -36,15 +36,15 @@ import { CUSTOM_BLOCK_BRIDGE_PROTOCOL_VERSION } from "@notionhq/custom-blocks-pr
|
|
|
36
36
|
import type { NotionUser } from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
37
37
|
import * as v from "valibot"
|
|
38
38
|
import type {
|
|
39
|
-
|
|
39
|
+
CreatePageArgs,
|
|
40
40
|
CreatePageResult,
|
|
41
41
|
GetPageResult,
|
|
42
42
|
GetUserResult,
|
|
43
|
-
|
|
43
|
+
ListUsersArgs,
|
|
44
44
|
ListUsersResult,
|
|
45
45
|
NotionPageId,
|
|
46
46
|
NotionUserId,
|
|
47
|
-
|
|
47
|
+
UpdatePageArgs,
|
|
48
48
|
UpdatePageResult,
|
|
49
49
|
UseDataSourceOptions,
|
|
50
50
|
} from "../types.js"
|
|
@@ -672,16 +672,16 @@ export class SandboxBridge {
|
|
|
672
672
|
this.postToHost(outbound)
|
|
673
673
|
}
|
|
674
674
|
|
|
675
|
-
createPage(
|
|
675
|
+
createPage(args: CreatePageArgs): Promise<CreatePageResult> {
|
|
676
676
|
return new Promise(resolve => {
|
|
677
|
-
const resolvedParent = this.resolveCreatePageParent(
|
|
677
|
+
const resolvedParent = this.resolveCreatePageParent(args.parent)
|
|
678
678
|
if (resolvedParent.status === "error") {
|
|
679
679
|
resolve(resolvedParent)
|
|
680
680
|
return
|
|
681
681
|
}
|
|
682
682
|
const resolvedProperties = resolvePropertyWriteMapForDataSource({
|
|
683
683
|
dataSource: resolvedParent.dataSource,
|
|
684
|
-
properties:
|
|
684
|
+
properties: args.properties,
|
|
685
685
|
operationName: "createPage",
|
|
686
686
|
})
|
|
687
687
|
if (resolvedProperties.status === "error") {
|
|
@@ -695,8 +695,8 @@ export class SandboxBridge {
|
|
|
695
695
|
parent: resolvedParent.parent,
|
|
696
696
|
properties: resolvedProperties.properties,
|
|
697
697
|
}
|
|
698
|
-
if (
|
|
699
|
-
outbound.position =
|
|
698
|
+
if (args.position !== undefined) {
|
|
699
|
+
outbound.position = args.position
|
|
700
700
|
}
|
|
701
701
|
this.postToHost(outbound)
|
|
702
702
|
})
|
|
@@ -726,27 +726,27 @@ export class SandboxBridge {
|
|
|
726
726
|
})
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
-
listUsers(
|
|
729
|
+
listUsers(args: ListUsersArgs = {}): Promise<ListUsersResult> {
|
|
730
730
|
return new Promise(resolve => {
|
|
731
731
|
const requestId = this.pendingListUsers.allocate(resolve)
|
|
732
732
|
const outbound: ListUsersMessage = {
|
|
733
733
|
type: "listUsers",
|
|
734
734
|
requestId,
|
|
735
|
-
startCursor:
|
|
736
|
-
pageSize:
|
|
735
|
+
startCursor: args.startCursor,
|
|
736
|
+
pageSize: args.pageSize,
|
|
737
737
|
}
|
|
738
738
|
this.postToHost(outbound)
|
|
739
739
|
})
|
|
740
740
|
}
|
|
741
741
|
|
|
742
|
-
updatePage(
|
|
742
|
+
updatePage(args: UpdatePageArgs): Promise<UpdatePageResult> {
|
|
743
743
|
return new Promise(resolve => {
|
|
744
744
|
if (
|
|
745
|
-
(
|
|
746
|
-
Object.keys(
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
745
|
+
(args.properties === undefined ||
|
|
746
|
+
Object.keys(args.properties).length === 0) &&
|
|
747
|
+
args.icon === undefined &&
|
|
748
|
+
args.cover === undefined &&
|
|
749
|
+
args.archived === undefined
|
|
750
750
|
) {
|
|
751
751
|
resolve({
|
|
752
752
|
status: "error",
|
|
@@ -764,19 +764,19 @@ export class SandboxBridge {
|
|
|
764
764
|
const outbound: UpdatePageMessage = {
|
|
765
765
|
type: "updatePage",
|
|
766
766
|
requestId,
|
|
767
|
-
pageId:
|
|
767
|
+
pageId: args.pageId,
|
|
768
768
|
}
|
|
769
|
-
if (
|
|
770
|
-
outbound.properties =
|
|
769
|
+
if (args.properties !== undefined) {
|
|
770
|
+
outbound.properties = args.properties
|
|
771
771
|
}
|
|
772
|
-
if (
|
|
773
|
-
outbound.icon =
|
|
772
|
+
if (args.icon !== undefined) {
|
|
773
|
+
outbound.icon = args.icon
|
|
774
774
|
}
|
|
775
|
-
if (
|
|
776
|
-
outbound.cover =
|
|
775
|
+
if (args.cover !== undefined) {
|
|
776
|
+
outbound.cover = args.cover
|
|
777
777
|
}
|
|
778
|
-
if (
|
|
779
|
-
outbound.archived =
|
|
778
|
+
if (args.archived !== undefined) {
|
|
779
|
+
outbound.archived = args.archived
|
|
780
780
|
}
|
|
781
781
|
this.postToHost(outbound)
|
|
782
782
|
})
|
|
@@ -790,15 +790,15 @@ export class SandboxBridge {
|
|
|
790
790
|
updateDataSourcePage(args: {
|
|
791
791
|
dataSource: NotionDataSource
|
|
792
792
|
pageId: NotionPageId
|
|
793
|
-
|
|
793
|
+
pageUpdateArgs: NotionDataSourcePageUpdateArgs
|
|
794
794
|
}): Promise<NotionDataSourcePageUpdateResult> {
|
|
795
|
-
const { dataSource, pageId,
|
|
795
|
+
const { dataSource, pageId, pageUpdateArgs } = args
|
|
796
796
|
const resolvedProperties =
|
|
797
|
-
|
|
797
|
+
pageUpdateArgs.properties === undefined
|
|
798
798
|
? undefined
|
|
799
799
|
: resolvePropertyWriteMapForDataSource({
|
|
800
800
|
dataSource,
|
|
801
|
-
properties:
|
|
801
|
+
properties: pageUpdateArgs.properties,
|
|
802
802
|
operationName: "dataSourcePage.update",
|
|
803
803
|
})
|
|
804
804
|
if (resolvedProperties?.status === "error") {
|
|
@@ -808,18 +808,18 @@ export class SandboxBridge {
|
|
|
808
808
|
return this.updatePage({
|
|
809
809
|
pageId,
|
|
810
810
|
properties: resolvedProperties?.properties,
|
|
811
|
-
icon:
|
|
812
|
-
cover:
|
|
813
|
-
archived:
|
|
811
|
+
icon: pageUpdateArgs.icon,
|
|
812
|
+
cover: pageUpdateArgs.cover,
|
|
813
|
+
archived: pageUpdateArgs.archived,
|
|
814
814
|
})
|
|
815
815
|
}
|
|
816
816
|
|
|
817
817
|
/**
|
|
818
|
-
* Translates the public `
|
|
818
|
+
* Translates the public `CreatePageArgs["parent"]` into the bridge-native
|
|
819
819
|
* `CreatePageMessageParent`. The `data_source_key` variant is resolved sandbox-side against
|
|
820
820
|
* the data source mapping the host delivered in `init` / `dataSourcesChanged`.
|
|
821
821
|
*/
|
|
822
|
-
private resolveCreatePageParent(parent:
|
|
822
|
+
private resolveCreatePageParent(parent: CreatePageArgs["parent"]):
|
|
823
823
|
| {
|
|
824
824
|
status: "ok"
|
|
825
825
|
parent: CreatePageMessageParent
|
package/src/bridge/hostState.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { NotionDataSource } from "@notionhq/custom-blocks-protocol/dataSour
|
|
|
3
3
|
import type {
|
|
4
4
|
NotionDataSourcePage,
|
|
5
5
|
NotionDataSourcePageBridge,
|
|
6
|
-
|
|
6
|
+
NotionDataSourcePageUpdateArgs,
|
|
7
7
|
NotionDataSourcePageUpdateResult,
|
|
8
8
|
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
9
9
|
import type { NotionDataSourceValue } from "@notionhq/custom-blocks-protocol/dataSources/dataSourceValue.js"
|
|
@@ -91,7 +91,7 @@ const EMPTY_QUERY_VIEW: DataSourceQueryView = {
|
|
|
91
91
|
export type UpdateDataSourcePageFn = (args: {
|
|
92
92
|
dataSource: NotionDataSource
|
|
93
93
|
pageId: NotionPageId
|
|
94
|
-
|
|
94
|
+
pageUpdateArgs: NotionDataSourcePageUpdateArgs
|
|
95
95
|
}) => Promise<NotionDataSourcePageUpdateResult>
|
|
96
96
|
|
|
97
97
|
export function getDataSourceQueryView(
|
|
@@ -135,11 +135,11 @@ export function getDataSourceQueryView(
|
|
|
135
135
|
id: entry.id,
|
|
136
136
|
propertiesById: entry.propertiesById,
|
|
137
137
|
propertiesByKey,
|
|
138
|
-
update:
|
|
138
|
+
update: args =>
|
|
139
139
|
updateDataSourcePage({
|
|
140
140
|
dataSource,
|
|
141
141
|
pageId: entry.id,
|
|
142
|
-
|
|
142
|
+
pageUpdateArgs: args,
|
|
143
143
|
}),
|
|
144
144
|
}
|
|
145
145
|
})
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { InitMessage } from "@notionhq/custom-blocks-protocol/messages/init.js"
|
|
2
2
|
import type {
|
|
3
|
-
|
|
3
|
+
CreatePageArgs,
|
|
4
4
|
CreatePageResult,
|
|
5
5
|
GetPageResult,
|
|
6
6
|
GetUserResult,
|
|
7
|
-
|
|
7
|
+
ListUsersArgs,
|
|
8
8
|
ListUsersResult,
|
|
9
9
|
NotionPageId,
|
|
10
10
|
NotionUserId,
|
|
11
|
-
|
|
11
|
+
UpdatePageArgs,
|
|
12
12
|
UpdatePageResult,
|
|
13
13
|
UseDataSourceOptions,
|
|
14
14
|
} from "../types.js"
|
|
@@ -86,7 +86,7 @@ export const pages = {
|
|
|
86
86
|
/**
|
|
87
87
|
* Creates a new Notion page.
|
|
88
88
|
*/
|
|
89
|
-
create: (input:
|
|
89
|
+
create: (input: CreatePageArgs): Promise<CreatePageResult> => {
|
|
90
90
|
return bridge.createPage(input)
|
|
91
91
|
},
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ export const pages = {
|
|
|
100
100
|
/**
|
|
101
101
|
* Updates an existing page.
|
|
102
102
|
*/
|
|
103
|
-
update: (input:
|
|
103
|
+
update: (input: UpdatePageArgs): Promise<UpdatePageResult> => {
|
|
104
104
|
return bridge.updatePage(input)
|
|
105
105
|
},
|
|
106
106
|
|
|
@@ -119,7 +119,7 @@ export const users = {
|
|
|
119
119
|
/**
|
|
120
120
|
* Lists users visible in the current custom block workspace.
|
|
121
121
|
*/
|
|
122
|
-
list: (input?:
|
|
122
|
+
list: (input?: ListUsersArgs): Promise<ListUsersResult> => {
|
|
123
123
|
return bridge.listUsers(input)
|
|
124
124
|
},
|
|
125
125
|
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type {
|
|
|
14
14
|
} from "@notionhq/custom-blocks-protocol/dataSources/dataSource.js"
|
|
15
15
|
export type {
|
|
16
16
|
NotionDataSourcePage,
|
|
17
|
+
NotionDataSourcePageUpdateArgs,
|
|
17
18
|
NotionDataSourcePageUpdateInput,
|
|
18
19
|
NotionDataSourcePageUpdateResult,
|
|
19
20
|
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
package/src/types.ts
CHANGED
|
@@ -6,16 +6,17 @@ import type { NotionCreatePagePosition } from "@notionhq/custom-blocks-protocol/
|
|
|
6
6
|
import type { CustomBlockCreatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/createPageResult.js"
|
|
7
7
|
import type { CustomBlockGetPageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/getPage.js"
|
|
8
8
|
import type { CustomBlockGetUserErrorInfo } from "@notionhq/custom-blocks-protocol/messages/getUser.js"
|
|
9
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
CustomBlockListUsersErrorInfo,
|
|
11
|
+
ListUsersMessage,
|
|
12
|
+
} from "@notionhq/custom-blocks-protocol/messages/listUsers.js"
|
|
10
13
|
import type { CustomBlockQueryDataSourceErrorInfo } from "@notionhq/custom-blocks-protocol/messages/queryDataSourceResult.js"
|
|
14
|
+
import type { UpdatePageMessage } from "@notionhq/custom-blocks-protocol/messages/updatePage.js"
|
|
11
15
|
import type { CustomBlockUpdatePageErrorInfo } from "@notionhq/custom-blocks-protocol/messages/updatePageResult.js"
|
|
12
16
|
import type {
|
|
13
17
|
NotionPage,
|
|
14
|
-
NotionPageCover,
|
|
15
|
-
NotionPageIcon,
|
|
16
18
|
NotionPageId,
|
|
17
19
|
NotionPagePropertyInputMap,
|
|
18
|
-
NotionPagePropertyWriteMap,
|
|
19
20
|
} from "@notionhq/custom-blocks-protocol/pages/page.js"
|
|
20
21
|
import type {
|
|
21
22
|
NotionUser,
|
|
@@ -23,6 +24,7 @@ import type {
|
|
|
23
24
|
} from "@notionhq/custom-blocks-protocol/users/user.js"
|
|
24
25
|
|
|
25
26
|
export type {
|
|
27
|
+
NotionDataSourcePageUpdateArgs,
|
|
26
28
|
NotionDataSourcePageUpdateInput,
|
|
27
29
|
NotionDataSourcePageUpdateResult,
|
|
28
30
|
} from "@notionhq/custom-blocks-protocol/dataSources/dataSourcePage.js"
|
|
@@ -107,15 +109,22 @@ export type CreatePageParent =
|
|
|
107
109
|
| { type: "data_source_key"; key: string }
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
|
-
*
|
|
112
|
+
* Arguments accepted by `sdk.pages.create`. Mirrors the Notion public API `POST /v1/pages` API.
|
|
111
113
|
*/
|
|
112
|
-
export type
|
|
114
|
+
export type CreatePageArgs = {
|
|
113
115
|
parent: CreatePageParent
|
|
114
116
|
properties: NotionPagePropertyInputMap
|
|
115
117
|
// TODO(custom-blocks): Add icon and cover once the Notion host supports them for page creation.
|
|
116
118
|
position?: NotionCreatePagePosition
|
|
117
119
|
}
|
|
118
120
|
|
|
121
|
+
/**
|
|
122
|
+
* @deprecated Use `CreatePageArgs` instead.
|
|
123
|
+
*
|
|
124
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
125
|
+
*/
|
|
126
|
+
export type CreatePageInput = CreatePageArgs
|
|
127
|
+
|
|
119
128
|
/**
|
|
120
129
|
* The result of a `sdk.pages.create` API call.
|
|
121
130
|
*/
|
|
@@ -127,20 +136,14 @@ export type CreatePageResult =
|
|
|
127
136
|
}
|
|
128
137
|
| { status: "error"; error: CustomBlockCreatePageErrorInfo }
|
|
129
138
|
|
|
139
|
+
export type UpdatePageArgs = Omit<UpdatePageMessage, "type" | "requestId">
|
|
140
|
+
|
|
130
141
|
/**
|
|
131
|
-
*
|
|
142
|
+
* @deprecated Use `UpdatePageArgs` instead.
|
|
132
143
|
*
|
|
133
|
-
*
|
|
134
|
-
* custom-block property keys, use the `update` helper on pages returned from
|
|
135
|
-
* `useDataSource`.
|
|
144
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
136
145
|
*/
|
|
137
|
-
export type UpdatePageInput =
|
|
138
|
-
pageId: NotionPageId
|
|
139
|
-
properties?: NotionPagePropertyWriteMap
|
|
140
|
-
icon?: NotionPageIcon
|
|
141
|
-
cover?: NotionPageCover
|
|
142
|
-
archived?: boolean
|
|
143
|
-
}
|
|
146
|
+
export type UpdatePageInput = UpdatePageArgs
|
|
144
147
|
|
|
145
148
|
/**
|
|
146
149
|
* Result of `sdk.pages.get`.
|
|
@@ -162,10 +165,14 @@ export type UpdatePageResult =
|
|
|
162
165
|
}
|
|
163
166
|
| { status: "error"; error: CustomBlockUpdatePageErrorInfo }
|
|
164
167
|
|
|
165
|
-
export type
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
export type ListUsersArgs = Omit<ListUsersMessage, "type" | "requestId">
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Use `ListUsersArgs` instead.
|
|
172
|
+
*
|
|
173
|
+
* TODO(custom-blocks): Remove this alias when bumping the SDK version to 0.2.0.
|
|
174
|
+
*/
|
|
175
|
+
export type ListUsersInput = ListUsersArgs
|
|
169
176
|
|
|
170
177
|
export type ListUsersResult =
|
|
171
178
|
| {
|