@notionhq/client 2.2.12 → 2.2.13
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
CHANGED
|
@@ -183,13 +183,14 @@ try {
|
|
|
183
183
|
There are several [type guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types)
|
|
184
184
|
provided to distinguish between full and partial API responses.
|
|
185
185
|
|
|
186
|
-
| Type guard function
|
|
187
|
-
|
|
|
188
|
-
| `isFullPage`
|
|
189
|
-
| `isFullBlock`
|
|
190
|
-
| `isFullDatabase`
|
|
191
|
-
| `
|
|
192
|
-
| `
|
|
186
|
+
| Type guard function | Purpose |
|
|
187
|
+
| ---------------------- | -------------------------------------------------------------------------------------- |
|
|
188
|
+
| `isFullPage` | Determine whether an object is a full `PageObjectResponse` |
|
|
189
|
+
| `isFullBlock` | Determine whether an object is a full `BlockObjectResponse` |
|
|
190
|
+
| `isFullDatabase` | Determine whether an object is a full `DatabaseObjectResponse` |
|
|
191
|
+
| `isFullPageOrDatabase` | Determine whether an object is a full `PageObjectResponse` or `DatabaseObjectResponse` |
|
|
192
|
+
| `isFullUser` | Determine whether an object is a full `UserObjectResponse` |
|
|
193
|
+
| `isFullComment` | Determine whether an object is a full `CommentObjectResponse` |
|
|
193
194
|
|
|
194
195
|
Here is an example of using a type guard:
|
|
195
196
|
|
|
@@ -198,10 +199,13 @@ const fullOrPartialPages = await notion.databases.query({
|
|
|
198
199
|
database_id: "897e5a76-ae52-4b48-9fdf-e71f5945d1af",
|
|
199
200
|
})
|
|
200
201
|
for (const page of fullOrPartialPages.results) {
|
|
201
|
-
if (!
|
|
202
|
+
if (!isFullPageOrDatabase(page)) {
|
|
202
203
|
continue
|
|
203
204
|
}
|
|
204
|
-
// The page variable has been narrowed from
|
|
205
|
+
// The page variable has been narrowed from
|
|
206
|
+
// PageObjectResponse | PartialPageObjectResponse | DatabaseObjectResponse | PartialDatabaseObjectResponse
|
|
207
|
+
// to
|
|
208
|
+
// PageObjectResponse | DatabaseObjectResponse.
|
|
205
209
|
console.log("Created at:", page.created_time)
|
|
206
210
|
}
|
|
207
211
|
```
|
package/build/package.json
CHANGED
|
@@ -5769,6 +5769,10 @@ type PropertyFilter = {
|
|
|
5769
5769
|
formula: FormulaPropertyFilter;
|
|
5770
5770
|
property: string;
|
|
5771
5771
|
type?: "formula";
|
|
5772
|
+
} | {
|
|
5773
|
+
unique_id: NumberPropertyFilter;
|
|
5774
|
+
property: string;
|
|
5775
|
+
type?: "unique_id";
|
|
5772
5776
|
} | {
|
|
5773
5777
|
rollup: RollupPropertyFilter;
|
|
5774
5778
|
property: string;
|