notion-client
Advanced tools
Comparing version 2.4.1 to 2.5.0
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
exports.__esModule = true; | ||
__export(require("./notion-api")); | ||
__exportStar(require("./notion-api"), exports); | ||
__exportStar(require("./types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -53,2 +53,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.NotionAPI = void 0; | ||
var node_fetch_1 = __importDefault(require("node-fetch")); | ||
@@ -69,20 +70,20 @@ var p_map_1 = __importDefault(require("p-map")); | ||
NotionAPI.prototype.getPage = function (pageId, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.concurrency, concurrency = _c === void 0 ? 3 : _c, _d = _b.fetchCollections, fetchCollections = _d === void 0 ? true : _d, _e = _b.signFileUrls, signFileUrls = _e === void 0 ? true : _e; | ||
var _f, _g, _h, _j, _k; | ||
var _b, _c, _d; | ||
var _e = _a === void 0 ? {} : _a, _f = _e.concurrency, concurrency = _f === void 0 ? 3 : _f, _g = _e.fetchCollections, fetchCollections = _g === void 0 ? true : _g, _h = _e.signFileUrls, signFileUrls = _h === void 0 ? true : _h; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var page, recordMap, pendingBlockIds, newBlocks, contentBlockIds, allCollectionInstances, allFileInstances, signedUrls, i, file, signedUrl, err_1; | ||
var _this = this; | ||
return __generator(this, function (_l) { | ||
switch (_l.label) { | ||
return __generator(this, function (_j) { | ||
switch (_j.label) { | ||
case 0: return [4 /*yield*/, this.getPageRaw(pageId)]; | ||
case 1: | ||
page = _l.sent(); | ||
recordMap = (_f = page) === null || _f === void 0 ? void 0 : _f.recordMap; | ||
if (!((_g = recordMap) === null || _g === void 0 ? void 0 : _g.block)) { | ||
page = _j.sent(); | ||
recordMap = page === null || page === void 0 ? void 0 : page.recordMap; | ||
if (!(recordMap === null || recordMap === void 0 ? void 0 : recordMap.block)) { | ||
throw new Error("Notion page not found \"" + notion_utils_1.uuidToId(pageId) + "\""); | ||
} | ||
// ensure that all top-level maps exist | ||
recordMap.collection = (_h = recordMap.collection, (_h !== null && _h !== void 0 ? _h : {})); | ||
recordMap.collection_view = (_j = recordMap.collection_view, (_j !== null && _j !== void 0 ? _j : {})); | ||
recordMap.notion_user = (_k = recordMap.notion_user, (_k !== null && _k !== void 0 ? _k : {})); | ||
recordMap.collection = (_b = recordMap.collection) !== null && _b !== void 0 ? _b : {}; | ||
recordMap.collection_view = (_c = recordMap.collection_view) !== null && _c !== void 0 ? _c : {}; | ||
recordMap.notion_user = (_d = recordMap.notion_user) !== null && _d !== void 0 ? _d : {}; | ||
// additional mappings added for convenience | ||
@@ -92,3 +93,3 @@ // note: these are not native notion objects | ||
recordMap.signed_urls = {}; | ||
_l.label = 2; | ||
_j.label = 2; | ||
case 2: | ||
@@ -102,3 +103,3 @@ if (!true) return [3 /*break*/, 4]; | ||
case 3: | ||
newBlocks = _l.sent(); | ||
newBlocks = _j.sent(); | ||
recordMap.block = __assign(__assign({}, recordMap.block), newBlocks); | ||
@@ -127,15 +128,15 @@ return [3 /*break*/, 2]; | ||
var _a; | ||
var _b, _c, _d, _e, _f, _g, _h, _j; | ||
return __generator(this, function (_k) { | ||
switch (_k.label) { | ||
var _b, _c, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
collectionId = collectionInstance.collectionId, collectionViewId = collectionInstance.collectionViewId; | ||
collectionView = (_b = recordMap.collection_view[collectionViewId]) === null || _b === void 0 ? void 0 : _b.value; | ||
_k.label = 1; | ||
_e.label = 1; | ||
case 1: | ||
_k.trys.push([1, 3, , 4]); | ||
_e.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.getCollectionData(collectionId, collectionViewId, { | ||
type: (_c = collectionView) === null || _c === void 0 ? void 0 : _c.type, | ||
query: ((_d = collectionView) === null || _d === void 0 ? void 0 : _d.query2) || ((_e = collectionView) === null || _e === void 0 ? void 0 : _e.query), | ||
groups: ((_g = (_f = collectionView) === null || _f === void 0 ? void 0 : _f.format) === null || _g === void 0 ? void 0 : _g.board_groups2) || ((_j = (_h = collectionView) === null || _h === void 0 ? void 0 : _h.format) === null || _j === void 0 ? void 0 : _j.board_groups) | ||
type: collectionView === null || collectionView === void 0 ? void 0 : collectionView.type, | ||
query: (collectionView === null || collectionView === void 0 ? void 0 : collectionView.query2) || (collectionView === null || collectionView === void 0 ? void 0 : collectionView.query), | ||
groups: ((_c = collectionView === null || collectionView === void 0 ? void 0 : collectionView.format) === null || _c === void 0 ? void 0 : _c.board_groups2) || ((_d = collectionView === null || collectionView === void 0 ? void 0 : collectionView.format) === null || _d === void 0 ? void 0 : _d.board_groups) | ||
}) | ||
@@ -148,3 +149,3 @@ // await fs.writeFile( | ||
case 2: | ||
collectionData = _k.sent(); | ||
collectionData = _e.sent(); | ||
// await fs.writeFile( | ||
@@ -161,3 +162,3 @@ // `${collectionId}-${collectionViewId}.json`, | ||
case 3: | ||
err_2 = _k.sent(); | ||
err_2 = _e.sent(); | ||
// It's possible for public pages to link to private collections, in which case | ||
@@ -175,4 +176,4 @@ // Notion returns a 400 error | ||
// fetch data for all collection view instances | ||
_l.sent(); | ||
_l.label = 6; | ||
_j.sent(); | ||
_j.label = 6; | ||
case 6: | ||
@@ -201,8 +202,8 @@ if (!signFileUrls) return [3 /*break*/, 10]; | ||
if (!(allFileInstances.length > 0)) return [3 /*break*/, 10]; | ||
_l.label = 7; | ||
_j.label = 7; | ||
case 7: | ||
_l.trys.push([7, 9, , 10]); | ||
_j.trys.push([7, 9, , 10]); | ||
return [4 /*yield*/, this.getSignedFileUrls(allFileInstances)]; | ||
case 8: | ||
signedUrls = (_l.sent()).signedUrls; | ||
signedUrls = (_j.sent()).signedUrls; | ||
if (signedUrls.length === allFileInstances.length) { | ||
@@ -217,3 +218,3 @@ for (i = 0; i < allFileInstances.length; ++i) { | ||
case 9: | ||
err_1 = _l.sent(); | ||
err_1 = _j.sent(); | ||
console.warn('NotionAPI getSignedfileUrls error', err_1); | ||
@@ -220,0 +221,0 @@ return [3 /*break*/, 10]; |
export * from './notion-api'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.js.map |
@@ -63,20 +63,20 @@ var __assign = (this && this.__assign) || function () { | ||
NotionAPI.prototype.getPage = function (pageId, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.concurrency, concurrency = _c === void 0 ? 3 : _c, _d = _b.fetchCollections, fetchCollections = _d === void 0 ? true : _d, _e = _b.signFileUrls, signFileUrls = _e === void 0 ? true : _e; | ||
var _f, _g, _h, _j, _k; | ||
var _b, _c, _d; | ||
var _e = _a === void 0 ? {} : _a, _f = _e.concurrency, concurrency = _f === void 0 ? 3 : _f, _g = _e.fetchCollections, fetchCollections = _g === void 0 ? true : _g, _h = _e.signFileUrls, signFileUrls = _h === void 0 ? true : _h; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var page, recordMap, pendingBlockIds, newBlocks, contentBlockIds, allCollectionInstances, allFileInstances, signedUrls, i, file, signedUrl, err_1; | ||
var _this = this; | ||
return __generator(this, function (_l) { | ||
switch (_l.label) { | ||
return __generator(this, function (_j) { | ||
switch (_j.label) { | ||
case 0: return [4 /*yield*/, this.getPageRaw(pageId)]; | ||
case 1: | ||
page = _l.sent(); | ||
recordMap = (_f = page) === null || _f === void 0 ? void 0 : _f.recordMap; | ||
if (!((_g = recordMap) === null || _g === void 0 ? void 0 : _g.block)) { | ||
page = _j.sent(); | ||
recordMap = page === null || page === void 0 ? void 0 : page.recordMap; | ||
if (!(recordMap === null || recordMap === void 0 ? void 0 : recordMap.block)) { | ||
throw new Error("Notion page not found \"" + uuidToId(pageId) + "\""); | ||
} | ||
// ensure that all top-level maps exist | ||
recordMap.collection = (_h = recordMap.collection, (_h !== null && _h !== void 0 ? _h : {})); | ||
recordMap.collection_view = (_j = recordMap.collection_view, (_j !== null && _j !== void 0 ? _j : {})); | ||
recordMap.notion_user = (_k = recordMap.notion_user, (_k !== null && _k !== void 0 ? _k : {})); | ||
recordMap.collection = (_b = recordMap.collection) !== null && _b !== void 0 ? _b : {}; | ||
recordMap.collection_view = (_c = recordMap.collection_view) !== null && _c !== void 0 ? _c : {}; | ||
recordMap.notion_user = (_d = recordMap.notion_user) !== null && _d !== void 0 ? _d : {}; | ||
// additional mappings added for convenience | ||
@@ -86,3 +86,3 @@ // note: these are not native notion objects | ||
recordMap.signed_urls = {}; | ||
_l.label = 2; | ||
_j.label = 2; | ||
case 2: | ||
@@ -96,3 +96,3 @@ if (!true) return [3 /*break*/, 4]; | ||
case 3: | ||
newBlocks = _l.sent(); | ||
newBlocks = _j.sent(); | ||
recordMap.block = __assign(__assign({}, recordMap.block), newBlocks); | ||
@@ -121,15 +121,15 @@ return [3 /*break*/, 2]; | ||
var _a; | ||
var _b, _c, _d, _e, _f, _g, _h, _j; | ||
return __generator(this, function (_k) { | ||
switch (_k.label) { | ||
var _b, _c, _d; | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
collectionId = collectionInstance.collectionId, collectionViewId = collectionInstance.collectionViewId; | ||
collectionView = (_b = recordMap.collection_view[collectionViewId]) === null || _b === void 0 ? void 0 : _b.value; | ||
_k.label = 1; | ||
_e.label = 1; | ||
case 1: | ||
_k.trys.push([1, 3, , 4]); | ||
_e.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, this.getCollectionData(collectionId, collectionViewId, { | ||
type: (_c = collectionView) === null || _c === void 0 ? void 0 : _c.type, | ||
query: ((_d = collectionView) === null || _d === void 0 ? void 0 : _d.query2) || ((_e = collectionView) === null || _e === void 0 ? void 0 : _e.query), | ||
groups: ((_g = (_f = collectionView) === null || _f === void 0 ? void 0 : _f.format) === null || _g === void 0 ? void 0 : _g.board_groups2) || ((_j = (_h = collectionView) === null || _h === void 0 ? void 0 : _h.format) === null || _j === void 0 ? void 0 : _j.board_groups) | ||
type: collectionView === null || collectionView === void 0 ? void 0 : collectionView.type, | ||
query: (collectionView === null || collectionView === void 0 ? void 0 : collectionView.query2) || (collectionView === null || collectionView === void 0 ? void 0 : collectionView.query), | ||
groups: ((_c = collectionView === null || collectionView === void 0 ? void 0 : collectionView.format) === null || _c === void 0 ? void 0 : _c.board_groups2) || ((_d = collectionView === null || collectionView === void 0 ? void 0 : collectionView.format) === null || _d === void 0 ? void 0 : _d.board_groups) | ||
}) | ||
@@ -142,3 +142,3 @@ // await fs.writeFile( | ||
case 2: | ||
collectionData = _k.sent(); | ||
collectionData = _e.sent(); | ||
// await fs.writeFile( | ||
@@ -155,3 +155,3 @@ // `${collectionId}-${collectionViewId}.json`, | ||
case 3: | ||
err_2 = _k.sent(); | ||
err_2 = _e.sent(); | ||
// It's possible for public pages to link to private collections, in which case | ||
@@ -169,4 +169,4 @@ // Notion returns a 400 error | ||
// fetch data for all collection view instances | ||
_l.sent(); | ||
_l.label = 6; | ||
_j.sent(); | ||
_j.label = 6; | ||
case 6: | ||
@@ -195,8 +195,8 @@ if (!signFileUrls) return [3 /*break*/, 10]; | ||
if (!(allFileInstances.length > 0)) return [3 /*break*/, 10]; | ||
_l.label = 7; | ||
_j.label = 7; | ||
case 7: | ||
_l.trys.push([7, 9, , 10]); | ||
_j.trys.push([7, 9, , 10]); | ||
return [4 /*yield*/, this.getSignedFileUrls(allFileInstances)]; | ||
case 8: | ||
signedUrls = (_l.sent()).signedUrls; | ||
signedUrls = (_j.sent()).signedUrls; | ||
if (signedUrls.length === allFileInstances.length) { | ||
@@ -211,3 +211,3 @@ for (i = 0; i < allFileInstances.length; ++i) { | ||
case 9: | ||
err_1 = _l.sent(); | ||
err_1 = _j.sent(); | ||
console.warn('NotionAPI getSignedfileUrls error', err_1); | ||
@@ -214,0 +214,0 @@ return [3 /*break*/, 10]; |
@@ -0,1 +1,2 @@ | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "notion-client", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"description": "Robust TypeScript client for the unofficial Notion API.", | ||
"repository": "NotionX/notion-kit", | ||
"repository": "NotionX/react-notion-x", | ||
"author": "Saasify <dev@saasify.sh>", | ||
@@ -19,4 +19,4 @@ "license": "MIT", | ||
"node-fetch": "^2.6.1", | ||
"notion-types": "^2.2.1", | ||
"notion-utils": "^2.4.1", | ||
"notion-types": "^2.5.0", | ||
"notion-utils": "^2.5.0", | ||
"p-map": "^4.0.0" | ||
@@ -26,5 +26,5 @@ }, | ||
"@types/node-fetch": "^2.5.7", | ||
"ava": "^3.11.1" | ||
"ava": "^3.13.0" | ||
}, | ||
"gitHead": "e6371a8426a29a214c17444d33de9b23b8d6706d" | ||
"gitHead": "113403d0c366278a94039e573fbe5158abb8a005" | ||
} |
<p align="center"> | ||
<img alt="Notion + TypeScript" src="https://raw.githubusercontent.com/NotionX/notion-kit/master/notion-ts.png" width="689"> | ||
<img alt="Notion + TypeScript" src="https://raw.githubusercontent.com/NotionX/react-notion-x/master/notion-ts.png" width="689"> | ||
</p> | ||
@@ -9,3 +9,3 @@ | ||
[](https://www.npmjs.com/package/notion-client) [](https://travis-ci.com/NotionX/notion-kit) [](https://prettier.io) | ||
[](https://www.npmjs.com/package/notion-client) [](https://travis-ci.com/NotionX/react-notion-x) [](https://prettier.io) | ||
@@ -42,3 +42,3 @@ ## Install | ||
See the [auto-generated docs](https://github.com/NotionX/notion-kit/blob/master/docs/notion-client.md). | ||
See the [auto-generated docs](https://github.com/NotionX/react-notion-x/blob/master/docs/notion-client.md). | ||
@@ -45,0 +45,0 @@ ## License |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
818136
11595
Updatednotion-types@^2.5.0
Updatednotion-utils@^2.5.0