UNPKG

notion-page-tree

Version:

Recursively fetch nested Notion pages from the root page/database/block node.

24 lines (23 loc) 980 B
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.flattenEntity = void 0; /** * @param entity entity whose children and parnt are the reference to block. * @returns entity whose children and parent are the id of block. */ var flattenEntity = function (entity) { var _a, _b; return (__assign(__assign({}, entity), { parent: (_a = entity.parent) === null || _a === void 0 ? void 0 : _a.id, children: (_b = entity.children) === null || _b === void 0 ? void 0 : _b.map(function (child) { return child.id; }) })); }; exports.flattenEntity = flattenEntity;