@notionhq/client 2.2.6 → 2.2.7
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/build/package.json +1 -1
- package/build/src/api-endpoints.d.ts +21 -2
- package/build/src/api-endpoints.d.ts.map +1 -1
- package/build/src/api-endpoints.js +1 -1
- package/build/src/api-endpoints.js.map +1 -1
- package/build/src/helpers.d.ts +5 -0
- package/build/src/helpers.d.ts.map +1 -1
- package/build/src/helpers.js +14 -1
- package/build/src/helpers.js.map +1 -1
- package/package.json +1 -1
package/build/src/helpers.d.ts
CHANGED
|
@@ -59,6 +59,11 @@ export declare function isFullPage(response: PageObjectResponse | PartialPageObj
|
|
|
59
59
|
* @returns `true` if `response` is a full `DatabaseObjectResponse`.
|
|
60
60
|
*/
|
|
61
61
|
export declare function isFullDatabase(response: DatabaseObjectResponse | PartialDatabaseObjectResponse): response is DatabaseObjectResponse;
|
|
62
|
+
/**
|
|
63
|
+
* @returns `true` if `response` is a full `DatabaseObjectResponse` or a full
|
|
64
|
+
* `PageObjectResponse`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isFullPageOrDatabase(response: DatabaseObjectResponse | PartialDatabaseObjectResponse | PageObjectResponse | PartialPageObjectResponse): response is DatabaseObjectResponse | PageObjectResponse;
|
|
62
67
|
/**
|
|
63
68
|
* @returns `true` if `response` is a full `UserObjectResponse`.
|
|
64
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;AAExB,UAAU,aAAa;IACrB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,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E,sBAAsB,GAAG,6BAA6B,GAC/D,QAAQ,IAAI,sBAAsB,CAEpC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EACJ,sBAAsB,GACtB,6BAA6B,GAC7B,kBAAkB,GAClB,yBAAyB,GAC5B,QAAQ,IAAI,sBAAsB,GAAG,kBAAkB,CAMzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,kBAAkB,GAAG,yBAAyB,GACvD,QAAQ,IAAI,kBAAkB,CAEhC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,qBAAqB,GAAG,4BAA4B,GAC7D,QAAQ,IAAI,qBAAqB,CAEnC"}
|
package/build/src/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFullComment = exports.isFullUser = exports.isFullDatabase = exports.isFullPage = exports.isFullBlock = exports.collectPaginatedAPI = exports.iteratePaginatedAPI = void 0;
|
|
3
|
+
exports.isFullComment = exports.isFullUser = exports.isFullPageOrDatabase = exports.isFullDatabase = exports.isFullPage = exports.isFullBlock = exports.collectPaginatedAPI = exports.iteratePaginatedAPI = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Returns an async iterator over the results of any paginated Notion API.
|
|
6
6
|
*
|
|
@@ -79,6 +79,19 @@ function isFullDatabase(response) {
|
|
|
79
79
|
return "title" in response;
|
|
80
80
|
}
|
|
81
81
|
exports.isFullDatabase = isFullDatabase;
|
|
82
|
+
/**
|
|
83
|
+
* @returns `true` if `response` is a full `DatabaseObjectResponse` or a full
|
|
84
|
+
* `PageObjectResponse`.
|
|
85
|
+
*/
|
|
86
|
+
function isFullPageOrDatabase(response) {
|
|
87
|
+
if (response.object === "database") {
|
|
88
|
+
return isFullDatabase(response);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
return isFullPage(response);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.isFullPageOrDatabase = isFullPageOrDatabase;
|
|
82
95
|
/**
|
|
83
96
|
* @returns `true` if `response` is a full `UserObjectResponse`.
|
|
84
97
|
*/
|
package/build/src/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAwBA;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,SAAS,CAAC,CAAC,mBAAmB,CACxC,MAAoD,EACpD,aAAmB;IAEnB,IAAI,UAAU,GAA8B,aAAa,CAAC,YAAY,CAAA;IACtE,GAAG;QACD,MAAM,QAAQ,GAAwB,MAAM,MAAM,CAAC;YACjD,GAAG,aAAa;YAChB,YAAY,EAAE,UAAU;SACzB,CAAC,CAAA;QACF,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAA;QACvB,UAAU,GAAG,QAAQ,CAAC,WAAW,CAAA;KAClC,QAAQ,UAAU,EAAC;AACtB,CAAC;AAbD,kDAaC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACI,KAAK,UAAU,mBAAmB,CACvC,MAAoD,EACpD,aAAmB;IAEnB,MAAM,OAAO,GAAW,EAAE,CAAA;IAC1B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,mBAAmB,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;QACnE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACnB;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AATD,kDASC;AAED;;GAEG;AACH,SAAgB,WAAW,CACzB,QAA0D;IAE1D,OAAO,MAAM,IAAI,QAAQ,CAAA;AAC3B,CAAC;AAJD,kCAIC;AAED;;GAEG;AACH,SAAgB,UAAU,CACxB,QAAwD;IAExD,OAAO,KAAK,IAAI,QAAQ,CAAA;AAC1B,CAAC;AAJD,gCAIC;AAED;;GAEG;AACH,SAAgB,cAAc,CAC5B,QAAgE;IAEhE,OAAO,OAAO,IAAI,QAAQ,CAAA;AAC5B,CAAC;AAJD,wCAIC;AAED;;GAEG;AACH,SAAgB,UAAU,CACxB,QAAwD;IAExD,OAAO,MAAM,IAAI,QAAQ,CAAA;AAC3B,CAAC;AAJD,gCAIC;AAED;;GAEG;AACH,SAAgB,aAAa,CAC3B,QAA8D;IAE9D,OAAO,YAAY,IAAI,QAAQ,CAAA;AACjC,CAAC;AAJD,sCAIC","sourcesContent":["import {\n BlockObjectResponse,\n CommentObjectResponse,\n DatabaseObjectResponse,\n PageObjectResponse,\n PartialBlockObjectResponse,\n PartialCommentObjectResponse,\n PartialDatabaseObjectResponse,\n PartialPageObjectResponse,\n PartialUserObjectResponse,\n UserObjectResponse,\n} from \"./api-endpoints\"\n\ninterface PaginatedArgs {\n start_cursor?: string\n}\n\ninterface PaginatedList<T> {\n object: \"list\"\n results: T[]\n next_cursor: string | null\n has_more: boolean\n}\n\n/**\n * Returns an async iterator over the results of any paginated Notion API.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const block of iteratePaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })) {\n * // Do something with block.\n * }\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function* iteratePaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): AsyncIterableIterator<Item> {\n let nextCursor: string | null | undefined = firstPageArgs.start_cursor\n do {\n const response: PaginatedList<Item> = await listFn({\n ...firstPageArgs,\n start_cursor: nextCursor,\n })\n yield* response.results\n nextCursor = response.next_cursor\n } while (nextCursor)\n}\n\n/**\n * Collect all of the results of paginating an API into an in-memory array.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const blocks = await collectPaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })\n * // Do something with blocks.\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function collectPaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): Promise<Item[]> {\n const results: Item[] = []\n for await (const item of iteratePaginatedAPI(listFn, firstPageArgs)) {\n results.push(item)\n }\n return results\n}\n\n/**\n * @returns `true` if `response` is a full `BlockObjectResponse`.\n */\nexport function isFullBlock(\n response: BlockObjectResponse | PartialBlockObjectResponse\n): response is BlockObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `PageObjectResponse`.\n */\nexport function isFullPage(\n response: PageObjectResponse | PartialPageObjectResponse\n): response is PageObjectResponse {\n return \"url\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DatabaseObjectResponse`.\n */\nexport function isFullDatabase(\n response: DatabaseObjectResponse | PartialDatabaseObjectResponse\n): response is DatabaseObjectResponse {\n return \"title\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `UserObjectResponse`.\n */\nexport function isFullUser(\n response: UserObjectResponse | PartialUserObjectResponse\n): response is UserObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `CommentObjectResponse`.\n */\nexport function isFullComment(\n response: CommentObjectResponse | PartialCommentObjectResponse\n): response is CommentObjectResponse {\n return \"created_by\" in response\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;AAwBA;;;;;;;;;;;;;;;;;;GAkBG;AACI,KAAK,SAAS,CAAC,CAAC,mBAAmB,CACxC,MAAoD,EACp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MAAM,IAAI,QAAQ,CAAA;AAC3B,CAAC;AAJD,gCAIC;AAED;;GAEG;AACH,SAAgB,aAAa,CAC3B,QAA8D;IAE9D,OAAO,YAAY,IAAI,QAAQ,CAAA;AACjC,CAAC;AAJD,sCAIC","sourcesContent":["import {\n BlockObjectResponse,\n CommentObjectResponse,\n DatabaseObjectResponse,\n PageObjectResponse,\n PartialBlockObjectResponse,\n PartialCommentObjectResponse,\n PartialDatabaseObjectResponse,\n PartialPageObjectResponse,\n PartialUserObjectResponse,\n UserObjectResponse,\n} from \"./api-endpoints\"\n\ninterface PaginatedArgs {\n start_cursor?: string\n}\n\ninterface PaginatedList<T> {\n object: \"list\"\n results: T[]\n next_cursor: string | null\n has_more: boolean\n}\n\n/**\n * Returns an async iterator over the results of any paginated Notion API.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * for await (const block of iteratePaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })) {\n * // Do something with block.\n * }\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function* iteratePaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): AsyncIterableIterator<Item> {\n let nextCursor: string | null | undefined = firstPageArgs.start_cursor\n do {\n const response: PaginatedList<Item> = await listFn({\n ...firstPageArgs,\n start_cursor: nextCursor,\n })\n yield* response.results\n nextCursor = response.next_cursor\n } while (nextCursor)\n}\n\n/**\n * Collect all of the results of paginating an API into an in-memory array.\n *\n * Example (given a notion Client called `notion`):\n *\n * ```\n * const blocks = await collectPaginatedAPI(notion.blocks.children.list, {\n * block_id: parentBlockId,\n * })\n * // Do something with blocks.\n * ```\n *\n * @param listFn A bound function on the Notion client that represents a conforming paginated\n * API. Example: `notion.blocks.children.list`.\n * @param firstPageArgs Arguments that should be passed to the API on the first and subsequent\n * calls to the API. Any necessary `next_cursor` will be automatically populated by\n * this function. Example: `{ block_id: \"<my block id>\" }`\n */\nexport async function collectPaginatedAPI<Args extends PaginatedArgs, Item>(\n listFn: (args: Args) => Promise<PaginatedList<Item>>,\n firstPageArgs: Args\n): Promise<Item[]> {\n const results: Item[] = []\n for await (const item of iteratePaginatedAPI(listFn, firstPageArgs)) {\n results.push(item)\n }\n return results\n}\n\n/**\n * @returns `true` if `response` is a full `BlockObjectResponse`.\n */\nexport function isFullBlock(\n response: BlockObjectResponse | PartialBlockObjectResponse\n): response is BlockObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `PageObjectResponse`.\n */\nexport function isFullPage(\n response: PageObjectResponse | PartialPageObjectResponse\n): response is PageObjectResponse {\n return \"url\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DatabaseObjectResponse`.\n */\nexport function isFullDatabase(\n response: DatabaseObjectResponse | PartialDatabaseObjectResponse\n): response is DatabaseObjectResponse {\n return \"title\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `DatabaseObjectResponse` or a full\n * `PageObjectResponse`.\n */\nexport function isFullPageOrDatabase(\n response:\n | DatabaseObjectResponse\n | PartialDatabaseObjectResponse\n | PageObjectResponse\n | PartialPageObjectResponse\n): response is DatabaseObjectResponse | PageObjectResponse {\n if (response.object === \"database\") {\n return isFullDatabase(response)\n } else {\n return isFullPage(response)\n }\n}\n\n/**\n * @returns `true` if `response` is a full `UserObjectResponse`.\n */\nexport function isFullUser(\n response: UserObjectResponse | PartialUserObjectResponse\n): response is UserObjectResponse {\n return \"type\" in response\n}\n\n/**\n * @returns `true` if `response` is a full `CommentObjectResponse`.\n */\nexport function isFullComment(\n response: CommentObjectResponse | PartialCommentObjectResponse\n): response is CommentObjectResponse {\n return \"created_by\" in response\n}\n"]}
|