@notionhq/custom-blocks-host 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/browser.js +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.d.ts.map +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.js +5 -1
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts +88 -1
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -1
- package/dist/compatibility/pages/toIconForProtocol3To8.d.ts +4 -0
- package/dist/compatibility/pages/toIconForProtocol3To8.d.ts.map +1 -0
- package/dist/compatibility/pages/toIconForProtocol3To8.js +13 -0
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.d.ts.map +1 -1
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.js +2 -1
- package/dist/compatibility/protocol3To5/toQueryPageForProtocol3To5.d.ts +8 -8
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.d.ts.map +1 -1
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.js +9 -2
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts +4 -0
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts.map +1 -0
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.js +16 -0
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +50 -34
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/messages/createSandboxMessageRouter.d.ts +3 -2
- package/dist/messages/createSandboxMessageRouter.d.ts.map +1 -1
- package/dist/messages/createSandboxMessageRouter.js +7 -1
- package/dist/messages/getInvalidSandboxMessageResponse.d.ts.map +1 -1
- package/dist/messages/getInvalidSandboxMessageResponse.js +3 -0
- package/dist/messages/invalidNativeIconColor.d.ts +5 -0
- package/dist/messages/invalidNativeIconColor.d.ts.map +1 -0
- package/dist/messages/invalidNativeIconColor.js +34 -0
- package/dist/pages/types.d.ts +2 -0
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +7 -1
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +14 -2
- package/dist/protocol/icons.d.ts +17 -0
- package/dist/protocol/icons.js +27 -0
- package/dist/protocol/index.d.ts +5 -3
- package/dist/protocol/index.js +4 -2
- package/dist/protocol/messages/hostToSandbox.d.ts +79 -11
- package/dist/protocol/messages/invalidHostMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidHostMessage.js +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +2 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +88 -1
- package/dist/protocol/navigation/openExternalUrl.d.ts +2 -2
- package/dist/protocol/pages/bridgePage.d.ts +7 -1
- package/dist/protocol/pages/messages/createPage.d.ts +103 -5
- package/dist/protocol/pages/messages/createPage.js +3 -1
- package/dist/protocol/pages/messages/getPage.d.ts +23 -5
- package/dist/protocol/pages/messages/openPage.d.ts +2 -2
- package/dist/protocol/pages/messages/updatePage.d.ts +30 -6
- package/dist/protocol/pages/pageAppearance.d.ts +36 -1
- package/dist/protocol/pages/pageAppearance.js +9 -0
- package/dist/protocol/users/messages/getUser.d.ts +2 -2
- package/dist/protocol/users/messages/listUsers.d.ts +2 -2
- package/dist/protocol/utils/errors.d.ts +2 -0
- package/dist/protocol/utils/protocolVersion.d.ts +2 -1
- package/dist/protocol/utils/protocolVersion.js +3 -1
- package/dist/protocol/utils/readRequestId.d.ts +2 -0
- package/dist/protocol/utils/readRequestId.js +7 -0
- package/docs/bridge/changelog.md +19 -0
- package/docs/bridge/protocol.md +30 -1
- package/docs/bridge/versioning.md +1 -0
- package/docs/compatibility.md +15 -7
- package/docs/handlers.md +6 -3
- package/package.json +1 -1
- package/src/compatibility/normalizeHostToSandboxMessage.ts +5 -0
- package/src/compatibility/pages/toIconForProtocol3To8.ts +17 -0
- package/src/compatibility/protocol3To5/toPageForProtocol3To5.ts +2 -1
- package/src/compatibility/protocol6/normalizePageResultsForProtocol6.ts +11 -2
- package/src/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.ts +22 -0
- package/src/createCustomBlockHost.ts +57 -37
- package/src/index.ts +1 -0
- package/src/messages/createSandboxMessageRouter.ts +18 -2
- package/src/messages/getInvalidSandboxMessageResponse.ts +3 -0
- package/src/messages/invalidNativeIconColor.ts +43 -0
- package/src/pages/types.ts +3 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { toIconForProtocol3To8 } from "../pages/toIconForProtocol3To8.js";
|
|
2
|
+
/** Encodes icons for protocols 7–8. Delete when the runtime minimum reaches 9. */
|
|
3
|
+
export function normalizePageResultsForProtocol7To8(message) {
|
|
4
|
+
if (message.type === "queryDataSourceResult") {
|
|
5
|
+
if (!message.items.some(page => page.icon?.type === "icon")) {
|
|
6
|
+
return message;
|
|
7
|
+
}
|
|
8
|
+
return { ...message, items: message.items.map(toPageWithoutNativeIcon) };
|
|
9
|
+
}
|
|
10
|
+
const page = toPageWithoutNativeIcon(message.page);
|
|
11
|
+
return page === message.page ? message : { ...message, page };
|
|
12
|
+
}
|
|
13
|
+
function toPageWithoutNativeIcon(page) {
|
|
14
|
+
const icon = toIconForProtocol3To8(page.icon);
|
|
15
|
+
return icon === page.icon ? page : { ...page, icon };
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomBlockHost.d.ts","sourceRoot":"","sources":["../src/createCustomBlockHost.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4DAA4D,CAAA;AACvG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAA;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAA;AACtF,OAAO,KAAK,EAAE,WAAW,E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EAAE,CAAC,SAAS,EAAE,2BAA2B,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAA;IAC1E,2DAA2D;IAC3D,mBAAmB,EAAE,kCAAkC,CAAA;IACvD,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAC9B,CAAA;AAED,gFAAgF;AAChF,MAAM,MAAM,mCAAmC,GAC5C;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IACA,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,oBAAoB,CACxB,6BAA6B,GAC7B,0BAA0B,GAC1B,0BAA0B,CAC5B,CAAA;CACA,CAAA;AAEJ,MAAM,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACtC,eAAe,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC3D,SAAS,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAA;IACzC,OAAO,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,KAAK,IAAI,CAAA;IACjE;;;OAGG;IACH,cAAc,EAAE,CACf,WAAW,EAAE,iCAAiC,KAC1C,mCAAmC,CAAA;IACxC,cAAc,EAAE,CAAC,WAAW,EAAE,UAAU,KAAK,IAAI,CAAA;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACtD,CAAA;AAUD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,sBAAsB,GAC7B,qBAAqB,CAokBvB"}
|
|
@@ -96,16 +96,33 @@ export function createCustomBlockHost(options) {
|
|
|
96
96
|
* Invokes a one-shot handler and posts its result with the request's ID.
|
|
97
97
|
* Each result type is named `<request type>Result` by the bridge protocol.
|
|
98
98
|
*/
|
|
99
|
-
async function
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
async function handleRequest(message, handler) {
|
|
100
|
+
try {
|
|
101
|
+
const response = handler === undefined
|
|
102
|
+
? unsupportedOperation(message.type)
|
|
103
|
+
: await handler(message);
|
|
104
|
+
sendInitializedMessage({
|
|
105
|
+
...response,
|
|
106
|
+
type: `${message.type}Result`,
|
|
107
|
+
requestId: message.requestId,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (initializationController.status !== "initialized") {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
emit("warn", error);
|
|
115
|
+
sendInitializedMessage({
|
|
116
|
+
type: `${message.type}Result`,
|
|
117
|
+
requestId: message.requestId,
|
|
118
|
+
status: "error",
|
|
119
|
+
error: {
|
|
120
|
+
code: "unknown_error",
|
|
121
|
+
message: `The host could not complete ${message.type}.`,
|
|
122
|
+
isRetryable: false,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
102
125
|
}
|
|
103
|
-
const response = await handler(message);
|
|
104
|
-
sendInitializedMessage({
|
|
105
|
-
type: `${message.type}Result`,
|
|
106
|
-
requestId: message.requestId,
|
|
107
|
-
...response,
|
|
108
|
-
});
|
|
109
126
|
}
|
|
110
127
|
function postQueryDataSourceResult(args) {
|
|
111
128
|
const message = args.response.status === "error"
|
|
@@ -166,8 +183,12 @@ export function createCustomBlockHost(options) {
|
|
|
166
183
|
flushPendingHostStateChanges();
|
|
167
184
|
}
|
|
168
185
|
async function handleOpenExternalUrl(message) {
|
|
169
|
-
if (
|
|
170
|
-
|
|
186
|
+
if (navigationAbortController.signal.aborted) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const handler = handlers.openExternalUrl;
|
|
190
|
+
if (handler === undefined) {
|
|
191
|
+
await handleRequest(message, undefined);
|
|
171
192
|
return;
|
|
172
193
|
}
|
|
173
194
|
if (pendingOpenExternalUrlRequestId === message.requestId) {
|
|
@@ -204,23 +225,7 @@ export function createCustomBlockHost(options) {
|
|
|
204
225
|
}
|
|
205
226
|
pendingOpenExternalUrlRequestId = message.requestId;
|
|
206
227
|
try {
|
|
207
|
-
|
|
208
|
-
signal: navigationAbortController.signal,
|
|
209
|
-
});
|
|
210
|
-
if (navigationAbortController.signal.aborted) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
const result = {
|
|
214
|
-
type: "openExternalUrlResult",
|
|
215
|
-
requestId: message.requestId,
|
|
216
|
-
...response,
|
|
217
|
-
};
|
|
218
|
-
sendInitializedMessage(result);
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
if (!navigationAbortController.signal.aborted) {
|
|
222
|
-
throw error;
|
|
223
|
-
}
|
|
228
|
+
await handleRequest(message, () => handler({ ...message, url }, { signal: navigationAbortController.signal }));
|
|
224
229
|
}
|
|
225
230
|
finally {
|
|
226
231
|
if (pendingOpenExternalUrlRequestId === message.requestId) {
|
|
@@ -392,6 +397,7 @@ export function createCustomBlockHost(options) {
|
|
|
392
397
|
getInitStatus: () => initializationController.status,
|
|
393
398
|
emit,
|
|
394
399
|
sendNack,
|
|
400
|
+
sendPageMutationError: postToSandbox,
|
|
395
401
|
onInvalidConnect: initializationController.handleInvalidConnect,
|
|
396
402
|
onInvalidInitResult: initializationController.handleInvalidInitResult,
|
|
397
403
|
onConnect: initializationController.handleConnect,
|
|
@@ -399,12 +405,12 @@ export function createCustomBlockHost(options) {
|
|
|
399
405
|
onQueryDataSource: handleQuery,
|
|
400
406
|
onUnsubscribeDataSourceQuery: message => querySubscriptions.unsubscribe(message.subscriptionId),
|
|
401
407
|
onOpenExternalUrl: handleOpenExternalUrl,
|
|
402
|
-
onCreatePage: message =>
|
|
403
|
-
onGetPage: message =>
|
|
404
|
-
onOpenPage: message =>
|
|
405
|
-
onGetUser: message =>
|
|
406
|
-
onListUsers: message =>
|
|
407
|
-
onUpdatePage: message =>
|
|
408
|
+
onCreatePage: message => handleRequest(message, handlers.createPage),
|
|
409
|
+
onGetPage: message => handleRequest(message, handlers.getPage),
|
|
410
|
+
onOpenPage: message => handleRequest(message, handlers.openPage),
|
|
411
|
+
onGetUser: message => handleRequest(message, handlers.getUser),
|
|
412
|
+
onListUsers: message => handleRequest(message, handlers.listUsers),
|
|
413
|
+
onUpdatePage: message => handleRequest(message, handlers.updatePage),
|
|
408
414
|
onResize: message => handlers.resize?.(message),
|
|
409
415
|
});
|
|
410
416
|
window.addEventListener("message", onMessage);
|
|
@@ -554,6 +560,16 @@ function getBindingError(manifest, dataSources) {
|
|
|
554
560
|
}
|
|
555
561
|
return undefined;
|
|
556
562
|
}
|
|
563
|
+
function unsupportedOperation(type) {
|
|
564
|
+
return {
|
|
565
|
+
status: "error",
|
|
566
|
+
error: {
|
|
567
|
+
code: "unsupported_operation",
|
|
568
|
+
message: `The host does not support ${type}.`,
|
|
569
|
+
isRetryable: false,
|
|
570
|
+
},
|
|
571
|
+
};
|
|
572
|
+
}
|
|
557
573
|
function getQueryValidationError(message, collectionSchema) {
|
|
558
574
|
// The host can omit the database schema. Queries without filters or sorts need no schema validation.
|
|
559
575
|
if (collectionSchema === undefined) {
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type { CustomBlockHostHandlers } from "./messages/handlers.js";
|
|
|
11
11
|
export type { CustomBlockHostLogDirection } from "./messages/logging.js";
|
|
12
12
|
export type { CustomBlockHostResult } from "./messages/result.js";
|
|
13
13
|
export type { CustomBlockHostNavigationContext, OpenExternalUrlMessageInput, } from "./navigation/types.js";
|
|
14
|
-
export type { CreatePageMessageInput, CustomBlockHostOpenPageResult, CustomBlockHostPageResult, GetPageMessageInput, OpenPageMessageInput, UpdatePageMessageInput, } from "./pages/types.js";
|
|
14
|
+
export type { CreatePageMessageInput, CustomBlockHostOpenPageResult, CustomBlockHostPageIcon, CustomBlockHostPageResult, GetPageMessageInput, OpenPageMessageInput, UpdatePageMessageInput, } from "./pages/types.js";
|
|
15
15
|
export type { CustomBlockHostUserListResult, CustomBlockHostUserResult, GetUserMessageInput, ListUsersMessageInput, } from "./users/types.js";
|
|
16
16
|
export { toNotionPageId } from "./utils/toNotionPageId.js";
|
|
17
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,2BAA2B,EAC3B,iCAAiC,EACjC,kCAAkC,EAClC,kCAAkC,GAClC,MAAM,2BAA2B,CAAA;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mCAAmC,EACxC,qBAAqB,GACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EACN,KAAK,oBAAoB,EACzB,4BAA4B,GAC5B,MAAM,wDAAwD,CAAA;AAC/D,OAAO,EACN,KAAK,oBAAoB,EACzB,sBAAsB,EACtB,iBAAiB,GACjB,MAAM,+CAA+C,CAAA;AACtD,YAAY,EACX,iCAAiC,EACjC,oCAAoC,EACpC,2BAA2B,GAC3B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAClF,YAAY,EACX,sBAAsB,EACtB,qBAAqB,GACrB,MAAM,sBAAsB,CAAA;AAC7B,YAAY,EACX,6BAA6B,EAC7B,yBAAyB,GACzB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AACrE,YAAY,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AACxE,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,YAAY,EACX,gCAAgC,EAChC,2BAA2B,GAC3B,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EACX,sBAAsB,EACtB,6BAA6B,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EAC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,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,GACtB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EACX,6BAA6B,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,GACrB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA"}
|
|
@@ -5,10 +5,10 @@ import type { ConnectMessage } from "../protocol/handshake/connect.js";
|
|
|
5
5
|
import type { InitResultMessage } from "../protocol/handshake/initResult.js";
|
|
6
6
|
import type { InvalidSandboxMessage } from "../protocol/messages/invalidSandboxMessage.js";
|
|
7
7
|
import type { OpenExternalUrlMessage } from "../protocol/navigation/openExternalUrl.js";
|
|
8
|
-
import type { CreatePageMessage } from "../protocol/pages/messages/createPage.js";
|
|
8
|
+
import type { CreatePageMessage, CreatePageResultMessage } from "../protocol/pages/messages/createPage.js";
|
|
9
9
|
import type { GetPageMessage } from "../protocol/pages/messages/getPage.js";
|
|
10
10
|
import type { OpenPageMessage } from "../protocol/pages/messages/openPage.js";
|
|
11
|
-
import type { UpdatePageMessage } from "../protocol/pages/messages/updatePage.js";
|
|
11
|
+
import type { UpdatePageMessage, UpdatePageResultMessage } from "../protocol/pages/messages/updatePage.js";
|
|
12
12
|
import type { GetUserMessage } from "../protocol/users/messages/getUser.js";
|
|
13
13
|
import type { ListUsersMessage } from "../protocol/users/messages/listUsers.js";
|
|
14
14
|
import type { InitializationController } from "../lifecycle/createInitializationController.js";
|
|
@@ -20,6 +20,7 @@ export type SandboxMessageRouterOptions = {
|
|
|
20
20
|
getInitStatus: () => InitStatus;
|
|
21
21
|
emit: (direction: CustomBlockHostLogDirection, payload: unknown) => void;
|
|
22
22
|
sendNack: (message: InvalidSandboxMessage) => void;
|
|
23
|
+
sendPageMutationError: (message: UpdatePageResultMessage | CreatePageResultMessage) => void;
|
|
23
24
|
onInvalidConnect: InitializationController["handleInvalidConnect"];
|
|
24
25
|
onInvalidInitResult: InitializationController["handleInvalidInitResult"];
|
|
25
26
|
onConnect: (message: ConnectMessage) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSandboxMessageRouter.d.ts","sourceRoot":"","sources":["../../src/messages/createSandboxMessageRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6DAA6D,CAAA;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0EAA0E,CAAA;AACtH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qFAAqF,CAAA;AAC5I,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAA;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAEjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oEAAoE,CAAA;AAC/G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gEAAgE,CAAA;AAC5G,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"createSandboxMessageRouter.d.ts","sourceRoot":"","sources":["../../src/messages/createSandboxMessageRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6DAA6D,CAAA;AAChG,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0EAA0E,CAAA;AACtH,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,qFAAqF,CAAA;AAC5I,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uDAAuD,CAAA;AAC3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0DAA0D,CAAA;AAEjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oEAAoE,CAAA;AAC/G,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gEAAgE,CAAA;AAC5G,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,MAAM,+DAA+D,CAAA;AACtE,OAAO,KAAK,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E,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,UAAU,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9D,iBAAiB,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5E,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D,SAAS,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D,WAAW,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAChE,YAAY,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClE,QAAQ,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAA;CAC1C,CAAA;AAED,wBAAgB,0BAA0B,CACzC,OAAO,EAAE,2BAA2B,GAClC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAgJ/B"}
|
|
@@ -5,6 +5,7 @@ import { invalidConnectPayloadError } from "../lifecycle/errors/invalidConnectPa
|
|
|
5
5
|
import { invalidInitResultPayloadError } from "../lifecycle/errors/invalidInitResultPayloadError.js";
|
|
6
6
|
import { unreachable } from "../utils/unreachable.js";
|
|
7
7
|
import { getInvalidSandboxMessageResponse } from "./getInvalidSandboxMessageResponse.js";
|
|
8
|
+
import { getInvalidNativeIconColorResponse } from "./invalidNativeIconColor.js";
|
|
8
9
|
const initializationIdentitySchema = v.object({
|
|
9
10
|
initializationId: v.string(),
|
|
10
11
|
});
|
|
@@ -14,8 +15,13 @@ const bridgeProtocolVersionSchema = v.object({
|
|
|
14
15
|
bridgeProtocolVersion: v.union([v.number(), v.nan()]),
|
|
15
16
|
});
|
|
16
17
|
export function createSandboxMessageRouter(options) {
|
|
17
|
-
const { iframe, sandboxOrigin, getInitStatus, emit, sendNack, onInvalidConnect, onInvalidInitResult, onConnect, onInitResult, onQueryDataSource, onUnsubscribeDataSourceQuery, onCreatePage, onGetPage, onOpenPage, onOpenExternalUrl, onGetUser, onListUsers, onUpdatePage, onResize, } = options;
|
|
18
|
+
const { iframe, sandboxOrigin, getInitStatus, emit, sendNack, sendPageMutationError, onInvalidConnect, onInvalidInitResult, onConnect, onInitResult, onQueryDataSource, onUnsubscribeDataSourceQuery, onCreatePage, onGetPage, onOpenPage, onOpenExternalUrl, onGetUser, onListUsers, onUpdatePage, onResize, } = options;
|
|
18
19
|
function onInvalidSandboxMessage(data, issues) {
|
|
20
|
+
const iconError = getInvalidNativeIconColorResponse(data);
|
|
21
|
+
if (iconError !== undefined && getInitStatus() === "initialized") {
|
|
22
|
+
sendPageMutationError(iconError);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
19
25
|
emit("warn", {
|
|
20
26
|
message: "Ignored unsupported sandbox message",
|
|
21
27
|
payload: redactExternalUrl(data),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInvalidSandboxMessageResponse.d.ts","sourceRoot":"","sources":["../../src/messages/getInvalidSandboxMessageResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oEAAoE,CAAA;
|
|
1
|
+
{"version":3,"file":"getInvalidSandboxMessageResponse.d.ts","sourceRoot":"","sources":["../../src/messages/getInvalidSandboxMessageResponse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oEAAoE,CAAA;AAG/G,MAAM,MAAM,6BAA6B,GAAG;IAC3C,YAAY,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,IAAI,CAAC,EAAE,qBAAqB,CAAA;CAC5B,CAAA;AAED,wBAAgB,gCAAgC,CAC/C,IAAI,EAAE,OAAO,GACX,6BAA6B,CAiB/B"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { readIncomingType } from "../protocol/messages/incomingType.js";
|
|
2
|
+
import { readRequestId } from "../protocol/utils/readRequestId.js";
|
|
2
3
|
export function getInvalidSandboxMessageResponse(data) {
|
|
3
4
|
const incomingType = readIncomingType(data);
|
|
4
5
|
if (incomingType === "invalidHostMessage" ||
|
|
5
6
|
incomingType === "invalidSandboxMessage") {
|
|
6
7
|
return { incomingType };
|
|
7
8
|
}
|
|
9
|
+
const requestId = readRequestId(data);
|
|
8
10
|
return {
|
|
9
11
|
incomingType,
|
|
10
12
|
nack: {
|
|
11
13
|
type: "invalidSandboxMessage",
|
|
14
|
+
...(requestId !== undefined ? { requestId } : {}),
|
|
12
15
|
reason: nackReasonForInvalidSandboxMessage(incomingType),
|
|
13
16
|
},
|
|
14
17
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CreatePageResultMessage } from "../protocol/pages/messages/createPage.js";
|
|
2
|
+
import type { UpdatePageResultMessage } from "../protocol/pages/messages/updatePage.js";
|
|
3
|
+
/** Reject malformed colors with a correlated result before invoking a page mutation handler. */
|
|
4
|
+
export declare function getInvalidNativeIconColorResponse(data: unknown): UpdatePageResultMessage | CreatePageResultMessage | undefined;
|
|
5
|
+
//# sourceMappingURL=invalidNativeIconColor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invalidNativeIconColor.d.ts","sourceRoot":"","sources":["../../src/messages/invalidNativeIconColor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAA;AAC5G,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAA;AAY5G,gGAAgG;AAChG,wBAAgB,iCAAiC,CAChD,IAAI,EAAE,OAAO,GACX,uBAAuB,GAAG,uBAAuB,GAAG,SAAS,CAyB/D"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { notionIconColorSchema } from "../protocol/icons.js";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
const nativeIconMutationSchema = v.object({
|
|
4
|
+
type: v.picklist(["updatePage", "createPage"]),
|
|
5
|
+
requestId: v.string(),
|
|
6
|
+
icon: v.object({
|
|
7
|
+
type: v.literal("icon"),
|
|
8
|
+
icon: v.object({ color: v.unknown() }),
|
|
9
|
+
}),
|
|
10
|
+
});
|
|
11
|
+
/** Reject malformed colors with a correlated result before invoking a page mutation handler. */
|
|
12
|
+
export function getInvalidNativeIconColorResponse(data) {
|
|
13
|
+
const parsed = v.safeParse(nativeIconMutationSchema, data);
|
|
14
|
+
if (!parsed.success) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const color = parsed.output.icon.icon.color;
|
|
18
|
+
if (color === undefined ||
|
|
19
|
+
v.safeParse(notionIconColorSchema, color).success) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
type: parsed.output.type === "createPage"
|
|
24
|
+
? "createPageResult"
|
|
25
|
+
: "updatePageResult",
|
|
26
|
+
requestId: parsed.output.requestId,
|
|
27
|
+
status: "error",
|
|
28
|
+
error: {
|
|
29
|
+
code: "invalid_icon_color",
|
|
30
|
+
message: "Use a supported Notion icon color.",
|
|
31
|
+
isRetryable: false,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
package/dist/pages/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { createPageMessageSchema } from "../protocol/pages/messages/createP
|
|
|
3
3
|
import type { getPageMessageSchema } from "../protocol/pages/messages/getPage.js";
|
|
4
4
|
import type { openPageMessageSchema } from "../protocol/pages/messages/openPage.js";
|
|
5
5
|
import type { updatePageMessageSchema } from "../protocol/pages/messages/updatePage.js";
|
|
6
|
+
import type { notionPageIconSchema } from "../protocol/pages/pageAppearance.js";
|
|
6
7
|
import type { InferInput } from "valibot";
|
|
7
8
|
import type { CustomBlockHostResult } from "../messages/result.js";
|
|
8
9
|
export type CreatePageMessageInput = InferInput<typeof createPageMessageSchema>;
|
|
@@ -15,4 +16,5 @@ export type CustomBlockHostPageResult = CustomBlockHostResult<{
|
|
|
15
16
|
export type CustomBlockHostOpenPageResult = CustomBlockHostResult<{
|
|
16
17
|
pageId: string;
|
|
17
18
|
}>;
|
|
19
|
+
export type CustomBlockHostPageIcon = InferInput<typeof notionPageIconSchema>;
|
|
18
20
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pages/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAA;AACtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AACtG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAA;AACxG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAA;AAC5G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAElE,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE/E,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAE3E,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE/E,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;IAC7D,IAAI,EAAE,UAAU,CAAA;CAChB,CAAC,CAAA;AACF,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;IACjE,MAAM,EAAE,MAAM,CAAA;CACd,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/pages/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAA;AACtF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AACtG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAA;AACxG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+DAA+D,CAAA;AAC5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAA;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAElE,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE/E,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEzE,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAE3E,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE/E,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;IAC7D,IAAI,EAAE,UAAU,CAAA;CAChB,CAAC,CAAA;AACF,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,CAAC;IACjE,MAAM,EAAE,MAAM,CAAA;CACd,CAAC,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
|
|
@@ -237,7 +237,13 @@ export declare const bridgePageForProtocol3To5Schema: v.ObjectSchema<{
|
|
|
237
237
|
}, undefined>], undefined>, undefined>;
|
|
238
238
|
readonly created_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
239
239
|
readonly last_edited_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
240
|
-
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.
|
|
240
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
241
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
242
|
+
readonly icon: v.LooseObjectSchema<{
|
|
243
|
+
readonly name: v.StringSchema<undefined>;
|
|
244
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
245
|
+
}, undefined>;
|
|
246
|
+
}, undefined>, v.ObjectSchema<{
|
|
241
247
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
242
248
|
readonly emoji: v.StringSchema<undefined>;
|
|
243
249
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -787,7 +787,13 @@ export declare const queryDataSourceResultMessageSchema: v.VariantSchema<"status
|
|
|
787
787
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
788
788
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
789
789
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
790
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
790
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
791
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
792
|
+
readonly icon: v.LooseObjectSchema<{
|
|
793
|
+
readonly name: v.StringSchema<undefined>;
|
|
794
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
795
|
+
}, undefined>;
|
|
796
|
+
}, undefined>, v.ObjectSchema<{
|
|
791
797
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
792
798
|
readonly emoji: v.StringSchema<undefined>;
|
|
793
799
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1090,7 +1096,13 @@ export declare const queryDataSourceResultMessageWithProtocol3To5CompatibilitySc
|
|
|
1090
1096
|
readonly last_visited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
1091
1097
|
readonly created_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
1092
1098
|
readonly last_edited_time: v.OptionalSchema<v.NullableSchema<v.StringSchema<undefined>, undefined>, null>;
|
|
1093
|
-
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.
|
|
1099
|
+
readonly icon: v.OptionalSchema<v.NullableSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
1100
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
1101
|
+
readonly icon: v.LooseObjectSchema<{
|
|
1102
|
+
readonly name: v.StringSchema<undefined>;
|
|
1103
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../../icons.js").NotionIconColor>, undefined>;
|
|
1104
|
+
}, undefined>;
|
|
1105
|
+
}, undefined>, v.ObjectSchema<{
|
|
1094
1106
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
1095
1107
|
readonly emoji: v.StringSchema<undefined>;
|
|
1096
1108
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/** Icon names stay open as hosts add to their catalogs. */
|
|
3
|
+
export declare const notionIconNameSchema: v.StringSchema<undefined>;
|
|
4
|
+
export type NotionIconName = v.InferOutput<typeof notionIconNameSchema>;
|
|
5
|
+
declare const knownNotionIconColorSchema: v.PicklistSchema<["gray", "lightgray", "brown", "yellow", "orange", "green", "blue", "purple", "pink", "red"], undefined>;
|
|
6
|
+
/** Known colors remain discoverable while reads and writes accept future colors. */
|
|
7
|
+
export type NotionIconColor = v.InferOutput<typeof knownNotionIconColorSchema> | (string & {});
|
|
8
|
+
export declare const notionIconColorSchema: v.GenericSchema<NotionIconColor>;
|
|
9
|
+
/** Reads and writes share an open shape; hosts resolve names and default omitted colors. */
|
|
10
|
+
export declare const notionNativeIconSchema: v.LooseObjectSchema<{
|
|
11
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
12
|
+
readonly icon: v.LooseObjectSchema<{
|
|
13
|
+
readonly name: v.StringSchema<undefined>;
|
|
14
|
+
readonly color: v.OptionalSchema<v.GenericSchema<NotionIconColor>, undefined>;
|
|
15
|
+
}, undefined>;
|
|
16
|
+
}, undefined>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/** Icon names stay open as hosts add to their catalogs. */
|
|
3
|
+
export const notionIconNameSchema = v.string();
|
|
4
|
+
const knownNotionIconColorSchema = v.picklist([
|
|
5
|
+
"gray",
|
|
6
|
+
"lightgray",
|
|
7
|
+
"brown",
|
|
8
|
+
"yellow",
|
|
9
|
+
"orange",
|
|
10
|
+
"green",
|
|
11
|
+
"blue",
|
|
12
|
+
"purple",
|
|
13
|
+
"pink",
|
|
14
|
+
"red",
|
|
15
|
+
]);
|
|
16
|
+
export const notionIconColorSchema = v.union([
|
|
17
|
+
knownNotionIconColorSchema,
|
|
18
|
+
v.string(),
|
|
19
|
+
]);
|
|
20
|
+
/** Reads and writes share an open shape; hosts resolve names and default omitted colors. */
|
|
21
|
+
export const notionNativeIconSchema = v.looseObject({
|
|
22
|
+
type: v.literal("icon"),
|
|
23
|
+
icon: v.looseObject({
|
|
24
|
+
name: notionIconNameSchema,
|
|
25
|
+
color: v.optional(notionIconColorSchema),
|
|
26
|
+
}),
|
|
27
|
+
});
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -85,6 +85,7 @@ export { CustomBlockInitializationError, customBlockInitErrorCodeSchema, customB
|
|
|
85
85
|
export type { CustomBlockInitResultErrorCode, CustomBlockInitResultErrorInfo, InitResultMessage, } from "./handshake/initResult.js";
|
|
86
86
|
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./handshake/initResult.js";
|
|
87
87
|
export { isInitHandshakeMessage } from "./handshake/isInitHandshakeMessage.js";
|
|
88
|
+
export * from "./icons.js";
|
|
88
89
|
export type { CustomBlockCapabilityDeclaration, CustomBlockCapabilityName, CustomBlockCapabilityResourceName, CustomBlockOriginResourceName, } from "./manifest/capabilities.js";
|
|
89
90
|
export { customBlockCapabilityDeclarationSchema } from "./manifest/capabilities.js";
|
|
90
91
|
export type { BridgeCustomBlockManifest, ManifestDataSource, ManifestIcon, ManifestProperty, } from "./manifest/manifest.js";
|
|
@@ -114,7 +115,7 @@ export { customBlockOpenPageErrorCodeSchema, customBlockOpenPageErrorInfoSchema,
|
|
|
114
115
|
export type { CustomBlockUpdatePageErrorCode, CustomBlockUpdatePageErrorInfo, UpdatePageMessage, UpdatePageResultMessage, UpdatePageResultMessageWithProtocol3To5Compatibility, } from "./pages/messages/updatePage.js";
|
|
115
116
|
export { customBlockUpdatePageErrorCodeSchema, customBlockUpdatePageErrorInfoSchema, updatePageMessageSchema, updatePageResultMessageSchema, updatePageResultMessageWithProtocol3To5CompatibilitySchema, } from "./pages/messages/updatePage.js";
|
|
116
117
|
export type { NotionPageCover, NotionPageIcon } from "./pages/pageAppearance.js";
|
|
117
|
-
export { notionCustomEmojiIconSchema, notionEmojiIconSchema, notionExternalFileSchema, notionHostedFileSchema, notionPageCoverSchema, notionPageIconSchema, } from "./pages/pageAppearance.js";
|
|
118
|
+
export { type NotionCreatePageIcon, notionCreatePageIconSchema, notionCustomEmojiIconSchema, notionEmojiIconSchema, notionExternalFileSchema, notionHostedFileSchema, notionPageCoverSchema, notionPageIconSchema, } from "./pages/pageAppearance.js";
|
|
118
119
|
export type { BridgePagePropertyReadMap, BridgePagePropertyWriteMap, } from "./pages/properties/bridgePagePropertyMaps.js";
|
|
119
120
|
export { bridgePagePropertyReadMapSchema, bridgePagePropertyWriteMapSchema, } from "./pages/properties/bridgePagePropertyMaps.js";
|
|
120
121
|
export type { BridgePagePropertyValue } from "./pages/properties/bridgePagePropertyValue.js";
|
|
@@ -140,11 +141,12 @@ export type { CustomBlockListUsersErrorCode, CustomBlockListUsersErrorInfo, List
|
|
|
140
141
|
export { customBlockListUsersErrorCodeSchema, customBlockListUsersErrorInfoSchema, listUsersMessageSchema, listUsersResultMessageSchema, } from "./users/messages/listUsers.js";
|
|
141
142
|
export type { NotionUserId } from "./users/userId.js";
|
|
142
143
|
export { notionUserIdSchema } from "./users/userId.js";
|
|
143
|
-
export type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo, } from "./utils/errors.js";
|
|
144
|
+
export type { CustomBlockCapabilityErrorCode, CustomBlockErrorCode, CustomBlockErrorInfo, CustomBlockRequestErrorCode, } from "./utils/errors.js";
|
|
144
145
|
export { CAPABILITY_NOT_GRANTED_ERROR_CODE, customBlockErrorInfoSchema, } from "./utils/errors.js";
|
|
145
146
|
export type { NotionAgentId, NotionBlockId, NotionDataSourceId, NotionPageId, NotionSpaceId, } from "./utils/ids.js";
|
|
146
147
|
export { notionAgentIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, notionSpaceIdSchema, } from "./utils/ids.js";
|
|
147
148
|
export { isLocalBlockServerUrl } from "./utils/isLocalBlockServerUrl.js";
|
|
148
|
-
export { LATEST_BRIDGE_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
149
|
+
export { LATEST_BRIDGE_PROTOCOL_VERSION, NATIVE_ICON_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
150
|
+
export { readRequestId } from "./utils/readRequestId.js";
|
|
149
151
|
export type { NotionRecordPointer } from "./utils/recordPointer.js";
|
|
150
152
|
export { notionRecordPointerSchema } from "./utils/recordPointer.js";
|
package/dist/protocol/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export { connectMessageSchema } from "./handshake/connect.js";
|
|
|
42
42
|
export { CustomBlockInitializationError, customBlockInitErrorCodeSchema, customBlockInitErrorInfoSchema, initMessageSchema, } from "./handshake/init.js";
|
|
43
43
|
export { customBlockInitResultErrorCodeSchema, customBlockInitResultErrorInfoSchema, initResultMessageSchema, } from "./handshake/initResult.js";
|
|
44
44
|
export { isInitHandshakeMessage } from "./handshake/isInitHandshakeMessage.js";
|
|
45
|
+
export * from "./icons.js";
|
|
45
46
|
export { customBlockCapabilityDeclarationSchema } from "./manifest/capabilities.js";
|
|
46
47
|
export { manifestDataSourceSchema, manifestIconSchema, manifestPropertySchema, manifestSchema, } from "./manifest/manifest.js";
|
|
47
48
|
export { hostToSandboxMessageSchema, hostToSandboxMessageWithProtocol3To5CompatibilitySchema, } from "./messages/hostToSandbox.js";
|
|
@@ -56,7 +57,7 @@ export { createPageMessageSchema, createPageParentSchema, createPageResultMessag
|
|
|
56
57
|
export { customBlockGetPageErrorCodeSchema, customBlockGetPageErrorInfoSchema, getPageMessageSchema, getPageResultMessageSchema, getPageResultMessageWithProtocol3To5CompatibilitySchema, } from "./pages/messages/getPage.js";
|
|
57
58
|
export { customBlockOpenPageErrorCodeSchema, customBlockOpenPageErrorInfoSchema, openPageMessageSchema, openPageModeSchema, openPageResultMessageSchema, } from "./pages/messages/openPage.js";
|
|
58
59
|
export { customBlockUpdatePageErrorCodeSchema, customBlockUpdatePageErrorInfoSchema, updatePageMessageSchema, updatePageResultMessageSchema, updatePageResultMessageWithProtocol3To5CompatibilitySchema, } from "./pages/messages/updatePage.js";
|
|
59
|
-
export { notionCustomEmojiIconSchema, notionEmojiIconSchema, notionExternalFileSchema, notionHostedFileSchema, notionPageCoverSchema, notionPageIconSchema, } from "./pages/pageAppearance.js";
|
|
60
|
+
export { notionCreatePageIconSchema, notionCustomEmojiIconSchema, notionEmojiIconSchema, notionExternalFileSchema, notionHostedFileSchema, notionPageCoverSchema, notionPageIconSchema, } from "./pages/pageAppearance.js";
|
|
60
61
|
export { bridgePagePropertyReadMapSchema, bridgePagePropertyWriteMapSchema, } from "./pages/properties/bridgePagePropertyMaps.js";
|
|
61
62
|
export { bridgePagePropertyValueSchema } from "./pages/properties/bridgePagePropertyValue.js";
|
|
62
63
|
export { bridgeUserSchema } from "./users/bridgeUser.js";
|
|
@@ -69,5 +70,6 @@ export { notionUserIdSchema } from "./users/userId.js";
|
|
|
69
70
|
export { CAPABILITY_NOT_GRANTED_ERROR_CODE, customBlockErrorInfoSchema, } from "./utils/errors.js";
|
|
70
71
|
export { notionAgentIdSchema, notionBlockIdSchema, notionDataSourceIdSchema, notionPageIdSchema, notionSpaceIdSchema, } from "./utils/ids.js";
|
|
71
72
|
export { isLocalBlockServerUrl } from "./utils/isLocalBlockServerUrl.js";
|
|
72
|
-
export { LATEST_BRIDGE_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
73
|
+
export { LATEST_BRIDGE_PROTOCOL_VERSION, NATIVE_ICON_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "./utils/protocolVersion.js";
|
|
74
|
+
export { readRequestId } from "./utils/readRequestId.js";
|
|
73
75
|
export { notionRecordPointerSchema } from "./utils/recordPointer.js";
|