@notionhq/client 2.2.11 → 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
|
@@ -530,6 +530,14 @@ type RollupDatabasePropertyConfigResponse = {
|
|
|
530
530
|
id: string;
|
|
531
531
|
name: string;
|
|
532
532
|
};
|
|
533
|
+
type UniqueIdDatabasePropertyConfigResponse = {
|
|
534
|
+
type: "unique_id";
|
|
535
|
+
unique_id: {
|
|
536
|
+
prefix: string | null;
|
|
537
|
+
};
|
|
538
|
+
id: string;
|
|
539
|
+
name: string;
|
|
540
|
+
};
|
|
533
541
|
type TitleDatabasePropertyConfigResponse = {
|
|
534
542
|
type: "title";
|
|
535
543
|
title: EmptyObject;
|
|
@@ -608,7 +616,7 @@ type LastEditedTimeDatabasePropertyConfigResponse = {
|
|
|
608
616
|
id: string;
|
|
609
617
|
name: string;
|
|
610
618
|
};
|
|
611
|
-
type DatabasePropertyConfigResponse = NumberDatabasePropertyConfigResponse | FormulaDatabasePropertyConfigResponse | SelectDatabasePropertyConfigResponse | MultiSelectDatabasePropertyConfigResponse | StatusDatabasePropertyConfigResponse | RelationDatabasePropertyConfigResponse | RollupDatabasePropertyConfigResponse | TitleDatabasePropertyConfigResponse | RichTextDatabasePropertyConfigResponse | UrlDatabasePropertyConfigResponse | PeopleDatabasePropertyConfigResponse | FilesDatabasePropertyConfigResponse | EmailDatabasePropertyConfigResponse | PhoneNumberDatabasePropertyConfigResponse | DateDatabasePropertyConfigResponse | CheckboxDatabasePropertyConfigResponse | CreatedByDatabasePropertyConfigResponse | CreatedTimeDatabasePropertyConfigResponse | LastEditedByDatabasePropertyConfigResponse | LastEditedTimeDatabasePropertyConfigResponse;
|
|
619
|
+
type DatabasePropertyConfigResponse = NumberDatabasePropertyConfigResponse | FormulaDatabasePropertyConfigResponse | SelectDatabasePropertyConfigResponse | MultiSelectDatabasePropertyConfigResponse | StatusDatabasePropertyConfigResponse | RelationDatabasePropertyConfigResponse | RollupDatabasePropertyConfigResponse | UniqueIdDatabasePropertyConfigResponse | TitleDatabasePropertyConfigResponse | RichTextDatabasePropertyConfigResponse | UrlDatabasePropertyConfigResponse | PeopleDatabasePropertyConfigResponse | FilesDatabasePropertyConfigResponse | EmailDatabasePropertyConfigResponse | PhoneNumberDatabasePropertyConfigResponse | DateDatabasePropertyConfigResponse | CheckboxDatabasePropertyConfigResponse | CreatedByDatabasePropertyConfigResponse | CreatedTimeDatabasePropertyConfigResponse | LastEditedByDatabasePropertyConfigResponse | LastEditedTimeDatabasePropertyConfigResponse;
|
|
612
620
|
export type PartialDatabaseObjectResponse = {
|
|
613
621
|
object: "database";
|
|
614
622
|
id: string;
|
|
@@ -1068,7 +1076,7 @@ export type EquationBlockObjectResponse = {
|
|
|
1068
1076
|
has_children: boolean;
|
|
1069
1077
|
archived: boolean;
|
|
1070
1078
|
};
|
|
1071
|
-
type LanguageRequest = "abap" | "agda" | "arduino" | "assembly" | "bash" | "basic" | "bnf" | "c" | "c#" | "c++" | "clojure" | "coffeescript" | "coq" | "css" | "dart" | "dhall" | "diff" | "docker" | "ebnf" | "elixir" | "elm" | "erlang" | "f#" | "flow" | "fortran" | "gherkin" | "glsl" | "go" | "graphql" | "groovy" | "haskell" | "html" | "idris" | "java" | "javascript" | "json" | "julia" | "kotlin" | "latex" | "less" | "lisp" | "livescript" | "llvm ir" | "lua" | "makefile" | "markdown" | "markup" | "matlab" | "mathematica" | "mermaid" | "nix" | "objective-c" | "ocaml" | "pascal" | "perl" | "php" | "plain text" | "powershell" | "prolog" | "protobuf" | "purescript" | "python" | "r" | "racket" | "reason" | "ruby" | "rust" | "sass" | "scala" | "scheme" | "scss" | "shell" | "solidity" | "sql" | "swift" | "toml" | "typescript" | "vb.net" | "verilog" | "vhdl" | "visual basic" | "webassembly" | "xml" | "yaml" | "java/c/c++/c#";
|
|
1079
|
+
type LanguageRequest = "abap" | "agda" | "arduino" | "assembly" | "bash" | "basic" | "bnf" | "c" | "c#" | "c++" | "clojure" | "coffeescript" | "coq" | "css" | "dart" | "dhall" | "diff" | "docker" | "ebnf" | "elixir" | "elm" | "erlang" | "f#" | "flow" | "fortran" | "gherkin" | "glsl" | "go" | "graphql" | "groovy" | "haskell" | "html" | "idris" | "java" | "javascript" | "json" | "julia" | "kotlin" | "latex" | "less" | "lisp" | "livescript" | "llvm ir" | "lua" | "makefile" | "markdown" | "markup" | "matlab" | "mathematica" | "mermaid" | "nix" | "notion formula" | "objective-c" | "ocaml" | "pascal" | "perl" | "php" | "plain text" | "powershell" | "prolog" | "protobuf" | "purescript" | "python" | "r" | "racket" | "reason" | "ruby" | "rust" | "sass" | "scala" | "scheme" | "scss" | "shell" | "solidity" | "sql" | "swift" | "toml" | "typescript" | "vb.net" | "verilog" | "vhdl" | "visual basic" | "webassembly" | "xml" | "yaml" | "java/c/c++/c#";
|
|
1072
1080
|
export type CodeBlockObjectResponse = {
|
|
1073
1081
|
type: "code";
|
|
1074
1082
|
code: {
|
|
@@ -5761,6 +5769,10 @@ type PropertyFilter = {
|
|
|
5761
5769
|
formula: FormulaPropertyFilter;
|
|
5762
5770
|
property: string;
|
|
5763
5771
|
type?: "formula";
|
|
5772
|
+
} | {
|
|
5773
|
+
unique_id: NumberPropertyFilter;
|
|
5774
|
+
property: string;
|
|
5775
|
+
type?: "unique_id";
|
|
5764
5776
|
} | {
|
|
5765
5777
|
rollup: RollupPropertyFilter;
|
|
5766
5778
|
property: string;
|
|
@@ -6709,6 +6721,12 @@ type UpdateDatabaseBodyParameters = {
|
|
|
6709
6721
|
};
|
|
6710
6722
|
type?: "rollup";
|
|
6711
6723
|
name?: string;
|
|
6724
|
+
} | null | {
|
|
6725
|
+
unique_id: {
|
|
6726
|
+
prefix?: string | null;
|
|
6727
|
+
};
|
|
6728
|
+
type?: "unique_id";
|
|
6729
|
+
name?: string;
|
|
6712
6730
|
} | null | {
|
|
6713
6731
|
title: EmptyObject;
|
|
6714
6732
|
type?: "title";
|
|
@@ -6915,6 +6933,11 @@ type CreateDatabaseBodyParameters = {
|
|
|
6915
6933
|
relation_property_name?: string;
|
|
6916
6934
|
};
|
|
6917
6935
|
type?: "rollup";
|
|
6936
|
+
} | {
|
|
6937
|
+
unique_id: {
|
|
6938
|
+
prefix?: string | null;
|
|
6939
|
+
};
|
|
6940
|
+
type?: "unique_id";
|
|
6918
6941
|
} | {
|
|
6919
6942
|
title: EmptyObject;
|
|
6920
6943
|
type?: "title";
|