Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

notion-utils

Package Overview
Dependencies
Maintainers
2
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notion-utils - npm Package Compare versions

Comparing version 6.8.0 to 6.8.1

2

build/index.js

@@ -1,2 +0,2 @@

var A=Object.defineProperty;var R=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var C=(e,t,o)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))z.call(t,o)&&C(e,o,t[o]);if(R)for(var o of R(t))q.call(t,o)&&C(e,o,t[o]);return e};var w=(e,t,o)=>new Promise((r,i)=>{var n=l=>{try{p(o.next(l))}catch(s){i(s)}},c=l=>{try{p(o.throw(l))}catch(s){i(s)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(n,c);p((o=o.apply(e,t)).next())});var _=e=>{var t;return e?Array.isArray(e)?(t=e==null?void 0:e.reduce((o,r)=>o+(r[0]!=="\u204D"&&r[0]!=="\u2023"?r[0]:""),""))!=null?t:"":e:""};function T(e){var t,o;return e.collection_id||((o=(t=e.format)==null?void 0:t.collection_pointer)==null?void 0:o.id)||null}function v(e,t){var o,r;if((o=e.properties)!=null&&o.title)return _(e.properties.title);if(e.type==="collection_view_page"||e.type==="collection_view"){let i=(r=t.collection[T(e)])==null?void 0:r.value;if(i)return _(i.name)}return""}function P(e,t){var o,r,i;if((o=e.format)!=null&&o.page_icon)return(r=e.format)==null?void 0:r.page_icon;if(e.type==="collection_view_page"||e.type==="collection_view"){let n=T(e);if(n){let c=(i=t.collection[n])==null?void 0:i.value;if(c)return c.icon}}return null}function re(e){var o;let t=(o=e.block[Object.keys(e.block)[0]])==null?void 0:o.value;return t?v(t,e):null}function E(e,t,o){var r;try{if(!t.properties||!Object.keys(o.collection))return null;let i=(r=o.collection[t.parent_id])==null?void 0:r.value;if(i){let n=Object.keys(i.schema).find(l=>{var s;return((s=i.schema[l])==null?void 0:s.name)===e});if(!n)return null;let{type:c}=i.schema[n],p=_(t.properties[n]);switch(c){case"created_time":return t.created_time;case"multi_select":return p.split(",");case"date":{let s=t.properties[n][0][1][0][1];if(s.type=="datetime")return new Date(`${s.start_date} ${s.start_time}`).getTime();if(s.type=="date")return new Date(s.start_date).getTime();if(s.type=="datetimerange"){let{start_date:u,start_time:y,end_date:m,end_time:a}=s,k=new Date(`${u} ${y}`).getTime(),d=new Date(`${m} ${a}`).getTime();return[k,d]}else{let u=new Date(s.start_date).getTime(),y=new Date(s.end_date).getTime();return[u,y]}}case"checkbox":return p=="Yes";case"last_edited_time":return t.last_edited_time;default:return p}}}catch(i){}return null}var F=e=>{if(e&&Array.isArray(e)){if(e[0]==="d")return e[1];for(let t of e){let o=F(t);if(o)return o}}return null};var I=(e,t,{inclusive:o=!1}={})=>{var i,n;let r=e;for(;r!=null;){if(o&&(r==null?void 0:r.type)==="page")return r;let c=r.parent_id,p=r.parent_table;if(!c)break;if(p==="collection")r=(i=t.collection[c])==null?void 0:i.value;else if(r=(n=t.block[c])==null?void 0:n.value,(r==null?void 0:r.type)==="page")return r}return null};var W={header:0,sub_header:1,sub_sub_header:2},pe=(e,t)=>{var i;let o=((i=e.content)!=null?i:[]).map(n=>{var p,l;let c=(p=t.block[n])==null?void 0:p.value;if(c){let{type:s}=c;if(s==="header"||s==="sub_header"||s==="sub_sub_header")return{id:n,type:s,text:_((l=c.properties)==null?void 0:l.title),indentLevel:W[s]}}return null}).filter(Boolean),r=[{actual:-1,effective:-1}];for(let n of o){let{indentLevel:c}=n,p=c;do{let l=r[r.length-1],{actual:s,effective:u}=l;if(p>s)n.indentLevel=u+1,r.push({actual:p,effective:n.indentLevel});else if(p===s){n.indentLevel=u;break}else r.pop()}while(!0)}return o};var fe=(e,t)=>{var n,c,p;let o=t||Object.keys(e.block)[0],r=new Set;function i(l){var m;if(r.has(l))return;r.add(l);let s=(m=e.block[l])==null?void 0:m.value;if(!s)return;let{content:u,type:y}=s;if(!!u&&!(y==="page"&&l!==o))for(let a of u)i(a)}i(o);for(let l of Object.keys(e.block)){let s=(n=e.block[l])==null?void 0:n.value;if(!s)continue;let{properties:u}=s;if(u)for(let y of Object.keys(u)){let m=u[y];m.map(k=>{var f,b;let d=(b=(f=k==null?void 0:k[0])==null?void 0:f[1])==null?void 0:b[0];(d==null?void 0:d[0])==="p"&&d[1]&&r.add(d[1])});let a=(p=(c=m==null?void 0:m[0])==null?void 0:c[1])==null?void 0:p[0];(a==null?void 0:a[0])==="p"&&a[1]&&r.add(a[1])}}return Array.from(r)};var U=(e="")=>`${e.substr(0,8)}-${e.substr(8,4)}-${e.substr(12,4)}-${e.substr(16,4)}-${e.substr(20)}`;var M=/\b([a-f0-9]{32})\b/,S=/\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\b/,$=(e="",{uuid:t=!0}={})=>{if(!e)return null;e=e.split("?")[0];let o=e.match(M);if(o)return t?U(o[1]):o[1];let r=e.match(S);return r?t?r[1]:r[1].replace(/-/g,""):null};var D=e=>e.replace(/-/g,"");import Q from"p-queue";function _e(c,p,l){return w(this,arguments,function*(e,t,o,{concurrency:r=4,traverseCollections:i=!0,targetPageId:n=null}={}){let s={},u=new Set,y=new Q({concurrency:r});function m(a){return w(this,null,function*(){n&&u.has(n)||(a=$(a),a&&!s[a]&&!u.has(a)&&(u.add(a),y.add(()=>w(this,null,function*(){var k,d;try{if(n&&u.has(n)&&a!==n)return;let f=yield o(a);if(!f)return;let b=(d=(k=f.block[a])==null?void 0:k.value)==null?void 0:d.space_id;if(b){if(!t)t=b;else if(t!==b)return}if(Object.keys(f.block).filter(h=>{var B;let x=(B=f.block[h])==null?void 0:B.value;return!(!x||x.type!=="page"&&x.type!=="collection_view_page"||t&&x.space_id&&x.space_id!==t)}).forEach(h=>m(h)),i)for(let h of Object.values(f.collection_query))for(let x of Object.values(h)){let{blockIds:B}=x;if(B)for(let L of B)m(L)}s[a]=f}catch(f){console.warn("page load error",{pageId:a,spaceId:t},f.statusCode,f.message),s[a]=null}u.delete(a)}))))})}return yield m(e),yield y.onIdle(),s})}var O=e=>(e||"").replace(/ /g,"-").replace(/[^a-zA-Z0-9-\u4e00-\u9fa5]/g,"").replace(/--/g,"-").replace(/-$/,"").replace(/^-/,"").trim().toLowerCase();var Ee=(e,t,{uuid:o=!0}={})=>{var n;if(!e||!t)return null;let r=D(e),i=(n=t.block[e])==null?void 0:n.value;if(i){let c=E("slug",i,t)||E("Slug",i,t)||O(v(i,t));if(c)return o?`${c}-${r}`:c}return r};var $e=(e,t)=>{var n;let o=e.block,r=[],i=t;do{let c=(n=o[i])==null?void 0:n.value;if(!c)break;let p=v(c,e),l=P(c,e);if(!(p||l))break;r.push({block:c,active:i===t,pageId:i,title:p,icon:l});let s=I(c,e),u=s==null?void 0:s.id;if(!u)break;i=u}while(!0);return r.reverse(),r};import j from"is-url-superb";var ze=(e,{mapImageUrl:t})=>{let r=Object.keys(e.block).flatMap(i=>{var p,l,s,u,y,m,a,k;let n=(p=e.block[i])==null?void 0:p.value,c=[];if(n){if(n.type==="image"){let b=((l=e.signed_urls)==null?void 0:l[n.id])||((y=(u=(s=n.properties)==null?void 0:s.source)==null?void 0:u[0])==null?void 0:y[0]);b&&c.push({block:n,url:b})}if((m=n.format)!=null&&m.page_cover){let f=n.format.page_cover;c.push({block:n,url:f})}if((a=n.format)!=null&&a.bookmark_cover){let f=n.format.bookmark_cover;c.push({block:n,url:f})}if((k=n.format)!=null&&k.bookmark_icon){let f=n.format.bookmark_icon;c.push({block:n,url:f})}let d=P(n,e);d&&j(d)&&c.push({block:n,url:d})}return c}).filter(Boolean).map(({block:i,url:n})=>t(n,i)).filter(Boolean);return Array.from(new Set(r))};import V from"normalize-url";import H from"mem";var N=H(e=>{if(!e)return"";try{if(e.startsWith("https://www.notion.so/image/")){let t=new URL(e),o=decodeURIComponent(t.pathname.substr(7)),r=N(o);t.pathname=`/image/${encodeURIComponent(r)}`,e=t.toString()}return V(e,{stripProtocol:!0,stripWWW:!0,stripHash:!0,stripTextFragment:!0,removeQueryParameters:!0})}catch(t){return""}});function Se(e,t){return{block:g(g({},e.block),t.block),collection:g(g({},e.collection),t.collection),collection_view:g(g({},e.collection_view),t.collection_view),notion_user:g(g({},e.notion_user),t.notion_user),collection_query:g(g({},e.collection_query),t.collection_query),signed_urls:g(g({},e.signed_urls),t.signed_urls),preview_images:g(g({},e.preview_images),t.preview_images)}}export{_e as getAllPagesInSpace,T as getBlockCollectionId,P as getBlockIcon,I as getBlockParentPage,v as getBlockTitle,Ee as getCanonicalPageId,F as getDateValue,$e as getPageBreadcrumbs,fe as getPageContentBlockIds,ze as getPageImageUrls,E as getPageProperty,pe as getPageTableOfContents,re as getPageTitle,_ as getTextContent,U as idToUuid,j as isUrl,Se as mergeRecordMaps,O as normalizeTitle,N as normalizeUrl,$ as parsePageId,D as uuidToId};
var A=Object.defineProperty;var C=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var I=(e,t,o)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))z.call(t,o)&&I(e,o,t[o]);if(C)for(var o of C(t))q.call(t,o)&&I(e,o,t[o]);return e};var T=(e,t,o)=>new Promise((n,s)=>{var r=a=>{try{l(o.next(a))}catch(i){s(i)}},c=a=>{try{l(o.throw(a))}catch(i){s(i)}},l=a=>a.done?n(a.value):Promise.resolve(a.value).then(r,c);l((o=o.apply(e,t)).next())});var h=e=>{var t;return e?Array.isArray(e)?(t=e==null?void 0:e.reduce((o,n)=>o+(n[0]!=="\u204D"&&n[0]!=="\u2023"?n[0]:""),""))!=null?t:"":e:""};function P(e){var t,o;return e.collection_id||((o=(t=e.format)==null?void 0:t.collection_pointer)==null?void 0:o.id)||null}function B(e,t){var o,n;if((o=e.properties)!=null&&o.title)return h(e.properties.title);if(e.type==="collection_view_page"||e.type==="collection_view"){let s=(n=t.collection[P(e)])==null?void 0:n.value;if(s)return h(s.name)}return""}function E(e,t){var o,n,s;if((o=e.format)!=null&&o.page_icon)return(n=e.format)==null?void 0:n.page_icon;if(e.type==="collection_view_page"||e.type==="collection_view"){let r=P(e);if(r){let c=(s=t.collection[r])==null?void 0:s.value;if(c)return c.icon}}return null}function re(e){var o;let t=(o=e.block[Object.keys(e.block)[0]])==null?void 0:o.value;return t?B(t,e):null}function R(e,t,o){var n;try{if(!t.properties||!Object.keys(o.collection))return null;let s=(n=o.collection[t.parent_id])==null?void 0:n.value;if(s){let r=Object.keys(s.schema).find(a=>{var i;return((i=s.schema[a])==null?void 0:i.name)===e});if(!r)return null;let{type:c}=s.schema[r],l=h(t.properties[r]);switch(c){case"created_time":return t.created_time;case"multi_select":return l.split(",");case"date":{let i=t.properties[r][0][1][0][1];if(i.type=="datetime")return new Date(`${i.start_date} ${i.start_time}`).getTime();if(i.type=="date")return new Date(i.start_date).getTime();if(i.type=="datetimerange"){let{start_date:p,start_time:y,end_date:x,end_time:f}=i,b=new Date(`${p} ${y}`).getTime(),m=new Date(`${x} ${f}`).getTime();return[b,m]}else{let p=new Date(i.start_date).getTime(),y=new Date(i.end_date).getTime();return[p,y]}}case"checkbox":return l=="Yes";case"last_edited_time":return t.last_edited_time;default:return l}}}catch(s){}return null}var M=e=>{if(e&&Array.isArray(e)){if(e[0]==="d")return e[1];for(let t of e){let o=M(t);if(o)return o}}return null};var U=(e,t,{inclusive:o=!1}={})=>{var s,r;let n=e;for(;n!=null;){if(o&&(n==null?void 0:n.type)==="page")return n;let c=n.parent_id,l=n.parent_table;if(!c)break;if(l==="collection")n=(s=t.collection[c])==null?void 0:s.value;else if(n=(r=t.block[c])==null?void 0:r.value,(n==null?void 0:n.type)==="page")return n}return null};var F={header:0,sub_header:1,sub_sub_header:2},pe=(e,t)=>{var s;let o=((s=e.content)!=null?s:[]).map(r=>{var l,a;let c=(l=t.block[r])==null?void 0:l.value;if(c){let{type:i}=c;if(i==="header"||i==="sub_header"||i==="sub_sub_header")return{id:r,type:i,text:h((a=c.properties)==null?void 0:a.title),indentLevel:F[i]}}return null}).filter(Boolean),n=[{actual:-1,effective:-1}];for(let r of o){let{indentLevel:c}=r,l=c;do{let a=n[n.length-1],{actual:i,effective:p}=a;if(l>i)r.indentLevel=p+1,n.push({actual:l,effective:r.indentLevel});else if(l===i){r.indentLevel=p;break}else n.pop()}while(!0)}return o};var ue=(e,t)=>{let o=t||Object.keys(e.block)[0],n=new Set;function s(r){var y,x,f,b;if(n.has(r))return;n.add(r);let c=(y=e.block[r])==null?void 0:y.value;if(!c)return;let{content:l,type:a,properties:i,format:p}=c;if(i)for(let m of Object.keys(i)){let u=i[m];u.map(_=>{var v,w;let d=(w=(v=_==null?void 0:_[0])==null?void 0:v[1])==null?void 0:w[0];(d==null?void 0:d[0])==="p"&&d[1]&&s(d[1])});let k=(f=(x=u==null?void 0:u[0])==null?void 0:x[1])==null?void 0:f[0];(k==null?void 0:k[0])==="p"&&k[1]&&s(k[1])}if(r==="41f43794-d110-4006-a17d-7caaa4583d83"&&console.log("BLOCK",c),p){let m=(b=p.transclusion_reference_pointer)==null?void 0:b.id;m&&s(m)}if(!(!l||!Array.isArray(l))&&!(a==="page"&&r!==o))for(let m of l)s(m)}return s(o),Array.from(n)};var $=(e="")=>`${e.substr(0,8)}-${e.substr(8,4)}-${e.substr(12,4)}-${e.substr(16,4)}-${e.substr(20)}`;var W=/\b([a-f0-9]{32})\b/,S=/\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\b/,D=(e="",{uuid:t=!0}={})=>{if(!e)return null;e=e.split("?")[0];let o=e.match(W);if(o)return t?$(o[1]):o[1];let n=e.match(S);return n?t?n[1]:n[1].replace(/-/g,""):null};var O=e=>e.replace(/-/g,"");import Q from"p-queue";function _e(c,l,a){return T(this,arguments,function*(e,t,o,{concurrency:n=4,traverseCollections:s=!0,targetPageId:r=null}={}){let i={},p=new Set,y=new Q({concurrency:n});function x(f){return T(this,null,function*(){r&&p.has(r)||(f=D(f),f&&!i[f]&&!p.has(f)&&(p.add(f),y.add(()=>T(this,null,function*(){var b,m;try{if(r&&p.has(r)&&f!==r)return;let u=yield o(f);if(!u)return;let k=(m=(b=u.block[f])==null?void 0:b.value)==null?void 0:m.space_id;if(k){if(!t)t=k;else if(t!==k)return}if(Object.keys(u.block).filter(_=>{var v;let d=(v=u.block[_])==null?void 0:v.value;return!(!d||d.type!=="page"&&d.type!=="collection_view_page"||t&&d.space_id&&d.space_id!==t)}).forEach(_=>x(_)),s)for(let _ of Object.values(u.collection_query))for(let d of Object.values(_)){let{blockIds:v}=d;if(v)for(let w of v)x(w)}i[f]=u}catch(u){console.warn("page load error",{pageId:f,spaceId:t},u.statusCode,u.message),i[f]=null}p.delete(f)}))))})}return yield x(e),yield y.onIdle(),i})}var L=e=>(e||"").replace(/ /g,"-").replace(/[^a-zA-Z0-9-\u4e00-\u9fa5]/g,"").replace(/--/g,"-").replace(/-$/,"").replace(/^-/,"").trim().toLowerCase();var Ee=(e,t,{uuid:o=!0}={})=>{var r;if(!e||!t)return null;let n=O(e),s=(r=t.block[e])==null?void 0:r.value;if(s){let c=R("slug",s,t)||R("Slug",s,t)||L(B(s,t));if(c)return o?`${c}-${n}`:c}return n};var $e=(e,t)=>{var r;let o=e.block,n=[],s=t;do{let c=(r=o[s])==null?void 0:r.value;if(!c)break;let l=B(c,e),a=E(c,e);if(!(l||a))break;n.push({block:c,active:s===t,pageId:s,title:l,icon:a});let i=U(c,e),p=i==null?void 0:i.id;if(!p)break;s=p}while(!0);return n.reverse(),n};import j from"is-url-superb";var ze=(e,{mapImageUrl:t})=>{let n=Object.keys(e.block).flatMap(s=>{var l,a,i,p,y,x,f,b;let r=(l=e.block[s])==null?void 0:l.value,c=[];if(r){if(r.type==="image"){let k=((a=e.signed_urls)==null?void 0:a[r.id])||((y=(p=(i=r.properties)==null?void 0:i.source)==null?void 0:p[0])==null?void 0:y[0]);k&&c.push({block:r,url:k})}if((x=r.format)!=null&&x.page_cover){let u=r.format.page_cover;c.push({block:r,url:u})}if((f=r.format)!=null&&f.bookmark_cover){let u=r.format.bookmark_cover;c.push({block:r,url:u})}if((b=r.format)!=null&&b.bookmark_icon){let u=r.format.bookmark_icon;c.push({block:r,url:u})}let m=E(r,e);m&&j(m)&&c.push({block:r,url:m})}return c}).filter(Boolean).map(({block:s,url:r})=>t(r,s)).filter(Boolean);return Array.from(new Set(n))};import V from"normalize-url";import H from"mem";var K=H(e=>{if(!e)return"";try{if(e.startsWith("https://www.notion.so/image/")){let t=new URL(e),o=decodeURIComponent(t.pathname.substr(7)),n=K(o);t.pathname=`/image/${encodeURIComponent(n)}`,e=t.toString()}return V(e,{stripProtocol:!0,stripWWW:!0,stripHash:!0,stripTextFragment:!0,removeQueryParameters:!0})}catch(t){return""}});function Se(e,t){return{block:g(g({},e.block),t.block),collection:g(g({},e.collection),t.collection),collection_view:g(g({},e.collection_view),t.collection_view),notion_user:g(g({},e.notion_user),t.notion_user),collection_query:g(g({},e.collection_query),t.collection_query),signed_urls:g(g({},e.signed_urls),t.signed_urls),preview_images:g(g({},e.preview_images),t.preview_images)}}export{_e as getAllPagesInSpace,P as getBlockCollectionId,E as getBlockIcon,U as getBlockParentPage,B as getBlockTitle,Ee as getCanonicalPageId,M as getDateValue,$e as getPageBreadcrumbs,ue as getPageContentBlockIds,ze as getPageImageUrls,R as getPageProperty,pe as getPageTableOfContents,re as getPageTitle,h as getTextContent,$ as idToUuid,j as isUrl,Se as mergeRecordMaps,L as normalizeTitle,K as normalizeUrl,D as parsePageId,O as uuidToId};
//# sourceMappingURL=index.js.map
{
"name": "notion-utils",
"version": "6.8.0",
"version": "6.8.1",
"type": "module",

@@ -48,3 +48,3 @@ "description": "Useful utilities for working with Notion data. Isomorphic.",

},
"gitHead": "8d977e79be6b5e76cf0e43a5c64aa8ce8ea81a2a"
"gitHead": "b4a0954b04549740b1ed75cd655980f53b3a50e4"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc