From 7723dcac23668e6eb3512c9b6ba40fab52a9564d Mon Sep 17 00:00:00 2001 From: Ron Yehoshua Date: Wed, 30 Aug 2023 10:57:43 -0700 Subject: [PATCH 1/3] update readme with isfullpageordatabase --- README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8b7a0f0a..6d8fbd52 100644 --- a/README.md +++ b/README.md @@ -183,13 +183,14 @@ try { There are several [type guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) provided to distinguish between full and partial API responses. -| Type guard function | Purpose | -| ------------------- | -------------------------------------------------------------- | -| `isFullPage` | Determine whether an object is a full `PageObjectResponse` | -| `isFullBlock` | Determine whether an object is a full `BlockObjectResponse` | -| `isFullDatabase` | Determine whether an object is a full `DatabaseObjectResponse` | -| `isFullUser` | Determine whether an object is a full `UserObjectResponse` | -| `isFullComment` | Determine whether an object is a full `CommentObjectResponse` | +| Type guard function | Purpose | +| ----------------------- | ------------------------------------------------------------------------------------------- | +| `isFullPage` | Determine whether an object is a full `PageObjectResponse` | +| `isFullBlock` | Determine whether an object is a full `BlockObjectResponse` | +| `isFullDatabase` | Determine whether an object is a full `DatabaseObjectResponse` | +| `isFullPageOrDatabase` | Determine whether an object is a full `PageObjectResponse` or `DatabaseObjectResponse` | +| `isFullUser` | Determine whether an object is a full `UserObjectResponse` | +| `isFullComment` | Determine whether an object is a full `CommentObjectResponse` | Here is an example of using a type guard: @@ -198,10 +199,13 @@ const fullOrPartialPages = await notion.databases.query({ database_id: "897e5a76-ae52-4b48-9fdf-e71f5945d1af", }) for (const page of fullOrPartialPages.results) { - if (!isFullPage(page)) { + if (!isFullPageOrDatabase(page)) { continue } - // The page variable has been narrowed from PageObjectResponse | PartialPageObjectResponse to PageObjectResponse. + // The page variable has been narrowed from + // PageObjectResponse | PartialPageObjectResponse | DatabaseObjectResponse | PartialDatabaseObjectResponse + // to + // PageObjectResponse | DatabaseObjectResponse. console.log("Created at:", page.created_time) } ``` From 30b6c767177eb6b58fd71ce076e42ba52513a37e Mon Sep 17 00:00:00 2001 From: Ron Yehoshua Date: Wed, 30 Aug 2023 11:00:49 -0700 Subject: [PATCH 2/3] fix spacing --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d8fbd52..4e67da9d 100644 --- a/README.md +++ b/README.md @@ -203,9 +203,9 @@ for (const page of fullOrPartialPages.results) { continue } // The page variable has been narrowed from - // PageObjectResponse | PartialPageObjectResponse | DatabaseObjectResponse | PartialDatabaseObjectResponse - // to - // PageObjectResponse | DatabaseObjectResponse. + // PageObjectResponse | PartialPageObjectResponse | DatabaseObjectResponse | PartialDatabaseObjectResponse + // to + // PageObjectResponse | DatabaseObjectResponse. console.log("Created at:", page.created_time) } ``` From be6b0101a4b5b67e665391760dc1cc8474e96142 Mon Sep 17 00:00:00 2001 From: Ryan Hart Date: Wed, 30 Aug 2023 11:39:09 -0700 Subject: [PATCH 3/3] Fix formatting. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4e67da9d..a1727b81 100644 --- a/README.md +++ b/README.md @@ -183,14 +183,14 @@ try { There are several [type guards](https://www.typescriptlang.org/docs/handbook/advanced-types.html#type-guards-and-differentiating-types) provided to distinguish between full and partial API responses. -| Type guard function | Purpose | -| ----------------------- | ------------------------------------------------------------------------------------------- | -| `isFullPage` | Determine whether an object is a full `PageObjectResponse` | -| `isFullBlock` | Determine whether an object is a full `BlockObjectResponse` | -| `isFullDatabase` | Determine whether an object is a full `DatabaseObjectResponse` | -| `isFullPageOrDatabase` | Determine whether an object is a full `PageObjectResponse` or `DatabaseObjectResponse` | -| `isFullUser` | Determine whether an object is a full `UserObjectResponse` | -| `isFullComment` | Determine whether an object is a full `CommentObjectResponse` | +| Type guard function | Purpose | +| ---------------------- | -------------------------------------------------------------------------------------- | +| `isFullPage` | Determine whether an object is a full `PageObjectResponse` | +| `isFullBlock` | Determine whether an object is a full `BlockObjectResponse` | +| `isFullDatabase` | Determine whether an object is a full `DatabaseObjectResponse` | +| `isFullPageOrDatabase` | Determine whether an object is a full `PageObjectResponse` or `DatabaseObjectResponse` | +| `isFullUser` | Determine whether an object is a full `UserObjectResponse` | +| `isFullComment` | Determine whether an object is a full `CommentObjectResponse` | Here is an example of using a type guard: