@notionhq/custom-blocks 0.2.14 → 0.2.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 -8
- package/dist/bridge/SandboxBridge.d.ts.map +1 -1
- package/dist/bridge/SandboxBridge.js +49 -44
- package/dist/bridge/dataSources/query.d.ts +2 -1
- package/dist/bridge/dataSources/query.d.ts.map +1 -1
- package/dist/bridge/dataSources/query.js +39 -8
- package/dist/bridge/dataSources/resolve.d.ts +10 -10
- package/dist/bridge/dataSources/resolve.d.ts.map +1 -1
- package/dist/bridge/dataSources/resolve.js +17 -5
- package/dist/protocol/dataSources/dataSource.d.ts +61 -6
- package/dist/protocol/dataSources/dataSource.js +35 -6
- package/dist/protocol/dataSources/propertySchema.d.ts +2 -0
- package/dist/protocol/dataSources/propertySchema.js +7 -0
- package/dist/protocol/messages/queryDataSource.d.ts +485 -485
- package/dist/protocol/messages/queryDataSource.js +43 -43
- package/dist/protocol/messages/queryDataSourceResult.d.ts +1 -1
- package/dist/protocol/messages/sandboxToHost.d.ts +178 -178
- package/dist/protocol/protocolVersion.d.ts +1 -1
- package/dist/protocol/protocolVersion.js +1 -1
- package/dist/typeUtils.d.ts +10 -0
- package/dist/typeUtils.d.ts.map +1 -0
- package/dist/types.d.ts +18 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/docs/block-location.md +4 -4
- package/docs/data-sources.md +60 -35
- package/docs/errors.md +17 -1
- package/package.json +1 -1
- package/src/bridge/SandboxBridge.ts +62 -50
- package/src/bridge/dataSources/query.ts +47 -9
- package/src/bridge/dataSources/resolve.ts +30 -13
- package/src/typeUtils.ts +10 -0
- package/src/types.ts +22 -16
- package/bin/notion-custom-blocks/upload.test.js +0 -35
- /package/{bin/notion-custom-blocks/upload.test.d.ts → dist/typeUtils.js} +0 -0
|
@@ -8,30 +8,59 @@ const collectionPointerValidator = v.object({
|
|
|
8
8
|
});
|
|
9
9
|
export const notionCollectionSchemaValidator = v.object({
|
|
10
10
|
id: v.optional(notionDataSourceIdSchema),
|
|
11
|
+
/**
|
|
12
|
+
* Describes actual database properties in protocol 5. Protocol 3/4 payloads can also include
|
|
13
|
+
* synthetic metadata for compatibility. Use this map to resolve property bindings. Use this map
|
|
14
|
+
* to validate filter and sort references.
|
|
15
|
+
*/
|
|
11
16
|
propertiesById: v.record(v.string(), notionPropertySchemaSchema),
|
|
12
17
|
});
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
19
|
+
* Describes a data source, its optional database binding, and its property schemas. The
|
|
20
|
+
* database schema validates query references. The read schemas describe snapshot values.
|
|
16
21
|
*/
|
|
17
22
|
export const notionDataSourceSchema = v.object({
|
|
18
23
|
key: v.string(),
|
|
19
24
|
collectionPointer: v.optional(collectionPointerValidator),
|
|
25
|
+
/**
|
|
26
|
+
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
27
|
+
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
28
|
+
* database schema.
|
|
29
|
+
*/
|
|
20
30
|
collectionSchema: v.optional(notionCollectionSchemaValidator),
|
|
21
31
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
32
|
+
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
33
|
+
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
34
|
+
* property without a valid binding. Synthetic metadata does not add entries to this map.
|
|
24
35
|
*/
|
|
25
36
|
propertyIdsByKey: v.record(v.string(), v.optional(v.string())),
|
|
26
37
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
38
|
+
* Describes property values in query snapshots. Keys use the same property IDs as a snapshot's
|
|
39
|
+
* `propertiesById` map.
|
|
40
|
+
*
|
|
41
|
+
* Includes four synthetic metadata fields, even when the database schema is unavailable:
|
|
42
|
+
* `created_time`, `last_edited_time`, `created_by`, and `last_edited_by`. Also includes
|
|
43
|
+
* database properties when the host provides their schema.
|
|
44
|
+
*
|
|
45
|
+
* Use `propertiesById` to read a value. Use this map to read the value's schema. Use
|
|
46
|
+
* `collectionSchema` to validate filter and sort references.
|
|
29
47
|
*/
|
|
30
48
|
propertySchemasById: v.record(v.string(), notionPropertySchemaSchema),
|
|
31
49
|
});
|
|
32
50
|
export const notionDataSourceBindingSchema = v.object({
|
|
33
51
|
collectionPointer: v.optional(collectionPointerValidator),
|
|
52
|
+
/**
|
|
53
|
+
* Describes database properties. Use this schema to resolve property bindings. Use this
|
|
54
|
+
* schema to validate filter and sort references. Undefined when the host does not provide a
|
|
55
|
+
* database schema.
|
|
56
|
+
*/
|
|
34
57
|
collectionSchema: v.optional(notionCollectionSchemaValidator),
|
|
58
|
+
/**
|
|
59
|
+
* Maps user-defined property keys to database property IDs. Use this map to resolve a key
|
|
60
|
+
* such as `name` to its database property ID. A value of `undefined` marks a declared
|
|
61
|
+
* property without a binding. Omitted when the host does not provide property mappings.
|
|
62
|
+
* Synthetic metadata does not add entries to this map.
|
|
63
|
+
*/
|
|
35
64
|
propertyIdsByKey: v.optional(v.record(v.string(), v.optional(v.string()))),
|
|
36
65
|
});
|
|
37
66
|
export const notionDataSourceBindingsSchema = v.record(v.string(), notionDataSourceBindingSchema);
|
|
@@ -195,3 +195,5 @@ export type NotionPropertySchema = v.InferOutput<typeof notionPropertySchemaSche
|
|
|
195
195
|
*/
|
|
196
196
|
export declare const NOTION_BUILTIN_PROPERTY_IDS: readonly ["created_time", "last_edited_time", "created_by", "last_edited_by"];
|
|
197
197
|
export type NotionBuiltinPropertyId = (typeof NOTION_BUILTIN_PROPERTY_IDS)[number];
|
|
198
|
+
/** Schemas for synthetic metadata values in query snapshots. */
|
|
199
|
+
export declare const NOTION_BUILTIN_PROPERTY_SCHEMAS: Record<NotionBuiltinPropertyId, NotionPropertySchema>;
|
|
@@ -163,3 +163,10 @@ export const NOTION_BUILTIN_PROPERTY_IDS = [
|
|
|
163
163
|
"created_by",
|
|
164
164
|
"last_edited_by",
|
|
165
165
|
];
|
|
166
|
+
/** Schemas for synthetic metadata values in query snapshots. */
|
|
167
|
+
export const NOTION_BUILTIN_PROPERTY_SCHEMAS = {
|
|
168
|
+
created_time: { type: "created_time", name: "Created time" },
|
|
169
|
+
last_edited_time: { type: "last_edited_time", name: "Last edited time" },
|
|
170
|
+
created_by: { type: "created_by", name: "Created by" },
|
|
171
|
+
last_edited_by: { type: "last_edited_by", name: "Last edited by" },
|
|
172
|
+
};
|