notion-utils
Advanced tools
Comparing version 6.13.4 to 6.15.6
@@ -1,2 +0,2 @@ | ||
var F=Object.defineProperty,N=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var D=(e,t,o)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,d=(e,t)=>{for(var o in t||(t={}))H.call(t,o)&&D(e,o,t[o]);if($)for(var o of $(t))Q.call(t,o)&&D(e,o,t[o]);return e},U=(e,t)=>N(e,V(t));var R=(e,t,o)=>new Promise((n,s)=>{var r=c=>{try{m(o.next(c))}catch(l){s(l)}},a=c=>{try{m(o.throw(c))}catch(l){s(l)}},m=c=>c.done?n(c.value):Promise.resolve(c.value).then(r,a);m((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 w(e,t){var s,r,a,m,c,l,i;let o=e.collection_id||((r=(s=e.format)==null?void 0:s.collection_pointer)==null?void 0:r.id);if(o)return o;let n=(a=e==null?void 0:e.view_ids)==null?void 0:a[0];if(n){let u=(c=(m=t.collection_view)==null?void 0:m[n])==null?void 0:c.value;if(u)return(i=(l=u.format)==null?void 0:l.collection_pointer)==null?void 0:i.id}return null}function T(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=w(e,t);if(s){let r=(n=t.collection[s])==null?void 0:n.value;if(r)return h(r.name)}}return""}function B(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=w(e,t);if(r){let a=(s=t.collection[r])==null?void 0:s.value;if(a)return a.icon}}return null}function pe(e){var o;let t=(o=e.block[Object.keys(e.block)[0]])==null?void 0:o.value;return t?T(t,e):null}function P(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=e.toLowerCase(),a=Object.keys(s.schema).find(l=>{var i,u;return((u=(i=s.schema[l])==null?void 0:i.name)==null?void 0:u.toLowerCase())===r});if(!a)return null;let{type:m}=s.schema[a],c=h(t.properties[a]);switch(m){case"created_time":return t.created_time;case"multi_select":return c.split(",");case"date":{let i=t.properties[a][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:u,start_time:g,end_date:p,end_time:_}=i,y=new Date(`${u} ${g}`).getTime(),f=new Date(`${p} ${_}`).getTime();return[y,f]}else{let u=new Date(i.start_date).getTime(),g=new Date(i.end_date).getTime();return[u,g]}}case"checkbox":return c=="Yes";case"last_edited_time":return t.last_edited_time;default:return c}}}catch(s){}return null}var Y=e=>{if(e&&Array.isArray(e)){if(e[0]==="d")return e[1];for(let t of e){let o=Y(t);if(o)return o}}return null};var O=(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 a=n.parent_id,m=n.parent_table;if(!a)break;if(m==="collection")n=(s=t.collection[a])==null?void 0:s.value;else if(n=(r=t.block[a])==null?void 0:r.value,(n==null?void 0:n.type)==="page")return n}return null};var Z={header:0,sub_header:1,sub_sub_header:2},S=(e,t)=>{var s;let o=((s=e.content)!=null?s:[]).map(r=>{var m,c;let a=(m=t.block[r])==null?void 0:m.value;if(a){let{type:l}=a;if(l==="header"||l==="sub_header"||l==="sub_sub_header")return{id:r,type:l,text:h((c=a.properties)==null?void 0:c.title),indentLevel:Z[l]}}return null}).filter(Boolean),n=[{actual:-1,effective:-1}];for(let r of o){let{indentLevel:a}=r,m=a;do{let c=n[n.length-1],{actual:l,effective:i}=c;if(m>l)r.indentLevel=i+1,n.push({actual:m,effective:r.indentLevel});else if(m===l){r.indentLevel=i;break}else n.pop()}while(!0)}return o};var Te=(e,t)=>{let o=t||Object.keys(e.block)[0],n=new Set;function s(r){var u,g,p,_;if(n.has(r))return;n.add(r);let a=(u=e.block[r])==null?void 0:u.value;if(!a)return;let{content:m,type:c,properties:l,format:i}=a;if(l)for(let y of Object.keys(l)){let f=l[y];f.map(x=>{var v,I;let b=(I=(v=x==null?void 0:x[0])==null?void 0:v[1])==null?void 0:I[0];(b==null?void 0:b[0])==="p"&&b[1]&&s(b[1])});let k=(p=(g=f==null?void 0:f[0])==null?void 0:g[1])==null?void 0:p[0];(k==null?void 0:k[0])==="p"&&k[1]&&s(k[1])}if(i){let y=(_=i.transclusion_reference_pointer)==null?void 0:_.id;y&&s(y)}if(!(!m||!Array.isArray(m))&&!(r!==o&&(c==="page"||c==="collection_view_page")))for(let y of m)s(y)}return s(o),Array.from(n)};var L=(e="")=>`${e.substr(0,8)}-${e.substr(8,4)}-${e.substr(12,4)}-${e.substr(16,4)}-${e.substr(20)}`;var G=/\b([a-f0-9]{32})\b/,J=/\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\b/,W=(e="",{uuid:t=!0}={})=>{if(!e)return null;e=e.split("?")[0];let o=e.match(G);if(o)return t?L(o[1]):o[1];let n=e.match(J);return n?t?n[1]:n[1].replace(/-/g,""):null};var M=e=>e.replace(/-/g,"");import K from"p-queue";function Ee(a,m,c){return R(this,arguments,function*(e,t,o,{concurrency:n=4,traverseCollections:s=!0,targetPageId:r=null}={}){let l={},i=new Set,u=new K({concurrency:n});function g(p){return R(this,null,function*(){r&&i.has(r)||(p=W(p),p&&!l[p]&&!i.has(p)&&(i.add(p),u.add(()=>R(this,null,function*(){var _,y;try{if(r&&i.has(r)&&p!==r)return;let f=yield o(p);if(!f)return;let k=(y=(_=f.block[p])==null?void 0:_.value)==null?void 0:y.space_id;if(k){if(!t)t=k;else if(t!==k)return}if(Object.keys(f.block).filter(x=>{var v;let b=(v=f.block[x])==null?void 0:v.value;return!(!b||b.type!=="page"&&b.type!=="collection_view_page"||t&&b.space_id&&b.space_id!==t)}).forEach(x=>g(x)),s)for(let x of Object.values(f.collection_query))for(let b of Object.values(x)){let{blockIds:v}=b;if(v)for(let I of v)g(I)}l[p]=f}catch(f){console.warn("page load error",{pageId:p,spaceId:t},f.statusCode,f.message),l[p]=null}i.delete(p)}))))})}return yield g(e),yield u.onIdle(),l})}var z=e=>(e||"").replace(/ /g,"-").replace(/[^a-zA-Z0-9-\u4e00-\u9fa5]/g,"").replace(/--/g,"-").replace(/-$/,"").replace(/^-/,"").trim().toLowerCase();var Le=(e,t,{uuid:o=!0}={})=>{var r;if(!e||!t)return null;let n=M(e),s=(r=t.block[e])==null?void 0:r.value;if(s){let a=P("slug",s,t)||P("Slug",s,t)||z(T(s,t));if(a)return o?`${a}-${n}`:a}return n};var Ae=(e,t)=>{var r;let o=e.block,n=[],s=t;do{let a=(r=o[s])==null?void 0:r.value;if(!a)break;let m=T(a,e),c=B(a,e);if(!(m||c))break;n.push({block:a,active:s===t,pageId:s,title:m,icon:c});let l=O(a,e),i=l==null?void 0:l.id;if(!i)break;s=i}while(!0);return n.reverse(),n};import j from"is-url-superb";var Qe=(e,{mapImageUrl:t})=>{let n=Object.keys(e.block).flatMap(s=>{var m,c,l,i,u,g,p,_;let r=(m=e.block[s])==null?void 0:m.value,a=[];if(r){if(r.type==="image"){let k=((c=e.signed_urls)==null?void 0:c[r.id])||((u=(i=(l=r.properties)==null?void 0:l.source)==null?void 0:i[0])==null?void 0:u[0]);k&&a.push({block:r,url:k})}if((g=r.format)!=null&&g.page_cover){let f=r.format.page_cover;a.push({block:r,url:f})}if((p=r.format)!=null&&p.bookmark_cover){let f=r.format.bookmark_cover;a.push({block:r,url:f})}if((_=r.format)!=null&&_.bookmark_icon){let f=r.format.bookmark_icon;a.push({block:r,url:f})}let y=B(r,e);y&&j(y)&&a.push({block:r,url:y})}return a}).filter(Boolean).map(({block:s,url:r})=>t(r,s)).filter(Boolean);return Array.from(new Set(n))};import X from"normalize-url";import ee from"mem";var te=ee(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=te(o);t.pathname=`/image/${encodeURIComponent(n)}`,e=t.toString()}return X(e,{stripProtocol:!0,stripWWW:!0,stripHash:!0,stripTextFragment:!0,removeQueryParameters:!0})}catch(t){return""}});function Ke(e,t){return{block:d(d({},e.block),t.block),collection:d(d({},e.collection),t.collection),collection_view:d(d({},e.collection_view),t.collection_view),notion_user:d(d({},e.notion_user),t.notion_user),collection_query:d(d({},e.collection_query),t.collection_query),signed_urls:d(d({},e.signed_urls),t.signed_urls),preview_images:d(d({},e.preview_images),t.preview_images)}}var A=(e,{month:t="short"}={})=>{let o=new Date(e);return`${o.toLocaleString("en-US",{month:t})} ${o.getUTCDate()}, ${o.getUTCFullYear()}`};var ot=e=>{let t=`${e.start_time||""} ${e.start_date} ${e.time_zone||""}`;return A(t)};function oe(e,t,{wordsPerMinute:o=275,imageReadTimeInSeconds:n=12}={}){let s=C(e,t),r=s.numWords/o,m=(s.numImages>10?s.numImages/2*(n+3)+(s.numImages-10)*3:s.numImages/2*(2*n+(1-s.numImages)))/60,c=r+m;return U(d({},s),{totalWordsReadTimeInMinutes:r,totalImageReadTimeInMinutes:m,totalReadTimeInMinutes:c})}function at(e,t,o){let n=oe(e,t,o);return ne(n.totalReadTimeInMinutes)}function C(e,t){var n,s,r,a;let o={numWords:0,numImages:0};if(!e)return o;for(let m of e.content||[]){let c=(n=t.block[m])==null?void 0:n.value,l=!1;if(!!c){switch(c.type){case"quote":case"alias":case"header":case"sub_header":case"sub_sub_header":{let i=T(c,t);o.numWords+=E(i);break}case"callout":case"toggle":case"to_do":case"bulleted_list":case"numbered_list":case"text":{let i=T(c,t);o.numWords+=E(i),l=!0;break}case"embed":case"tweet":case"maps":case"pdf":case"figma":case"typeform":case"codepen":case"excalidraw":case"gist":case"video":case"drive":case"audio":case"file":case"image":o.numImages+=1;break;case"bookmark":o.numImages+=.25;break;case"code":o.numImages+=2;break;case"table":case"collection_view":o.numImages+=2;break;case"column":case"column_list":case"transclusion_container":l=!0;break;case"table_of_contents":{let i=e;if(!i)continue;let u=S(i,t);for(let g of u)o.numWords+=E(g.text);break}case"transclusion_reference":{let i=(r=(s=c==null?void 0:c.format)==null?void 0:s.transclusion_reference_pointer)==null?void 0:r.id;if(!i)continue;let u=(a=t.block[i])==null?void 0:a.value;u&&q(o,C(u,t));break}default:break}l&&q(o,C(c,t))}}return o}function q(e,t){e.numWords+=t.numWords,e.numImages+=t.numImages}function E(e){return e?(e.match(/\w+/g)||[]).length:0}function ne(e){return e<.5?"less than a minute":e<1.5?"1 minute":`${Math.ceil(e)} minutes`}export{oe as estimatePageReadTime,at as estimatePageReadTimeAsHumanizedString,A as formatDate,ot as formatNotionDateTime,Ee as getAllPagesInSpace,w as getBlockCollectionId,B as getBlockIcon,O as getBlockParentPage,T as getBlockTitle,Le as getCanonicalPageId,Y as getDateValue,Ae as getPageBreadcrumbs,Te as getPageContentBlockIds,Qe as getPageImageUrls,P as getPageProperty,S as getPageTableOfContents,pe as getPageTitle,h as getTextContent,L as idToUuid,j as isUrl,Ke as mergeRecordMaps,z as normalizeTitle,te as normalizeUrl,W as parsePageId,M as uuidToId}; | ||
var F=Object.defineProperty,N=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var $=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var D=(e,t,o)=>t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,d=(e,t)=>{for(var o in t||(t={}))H.call(t,o)&&D(e,o,t[o]);if($)for(var o of $(t))Q.call(t,o)&&D(e,o,t[o]);return e},U=(e,t)=>N(e,V(t));var R=(e,t,o)=>new Promise((n,s)=>{var r=c=>{try{m(o.next(c))}catch(l){s(l)}},a=c=>{try{m(o.throw(c))}catch(l){s(l)}},m=c=>c.done?n(c.value):Promise.resolve(c.value).then(r,a);m((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 w(e,t){var s,r,a,m,c,l,i;let o=e.collection_id||((r=(s=e.format)==null?void 0:s.collection_pointer)==null?void 0:r.id);if(o)return o;let n=(a=e==null?void 0:e.view_ids)==null?void 0:a[0];if(n){let u=(c=(m=t.collection_view)==null?void 0:m[n])==null?void 0:c.value;if(u)return(i=(l=u.format)==null?void 0:l.collection_pointer)==null?void 0:i.id}return null}function T(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=w(e,t);if(s){let r=(n=t.collection[s])==null?void 0:n.value;if(r)return h(r.name)}}return""}function B(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=w(e,t);if(r){let a=(s=t.collection[r])==null?void 0:s.value;if(a)return a.icon}}return null}function pe(e){var o;let t=(o=e.block[Object.keys(e.block)[0]])==null?void 0:o.value;return t?T(t,e):null}function P(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=e.toLowerCase(),a=Object.keys(s.schema).find(l=>{var i,u;return((u=(i=s.schema[l])==null?void 0:i.name)==null?void 0:u.toLowerCase())===r});if(!a)return null;let{type:m}=s.schema[a],c=h(t.properties[a]);switch(m){case"created_time":return t.created_time;case"multi_select":return c.split(",");case"date":{let i=t.properties[a][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:u,start_time:g,end_date:p,end_time:_}=i,y=new Date(`${u} ${g}`).getTime(),f=new Date(`${p} ${_}`).getTime();return[y,f]}else{let u=new Date(i.start_date).getTime(),g=new Date(i.end_date).getTime();return[u,g]}}case"checkbox":return c=="Yes";case"last_edited_time":return t.last_edited_time;default:return c}}}catch(s){}return null}var Y=e=>{if(e&&Array.isArray(e)){if(e[0]==="d")return e[1];for(let t of e){let o=Y(t);if(o)return o}}return null};var O=(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 a=n.parent_id,m=n.parent_table;if(!a)break;if(m==="collection")n=(s=t.collection[a])==null?void 0:s.value;else if(n=(r=t.block[a])==null?void 0:r.value,(n==null?void 0:n.type)==="page")return n}return null};var Z={header:0,sub_header:1,sub_sub_header:2},S=(e,t)=>{var s;let o=((s=e.content)!=null?s:[]).map(r=>{var m,c;let a=(m=t.block[r])==null?void 0:m.value;if(a){let{type:l}=a;if(l==="header"||l==="sub_header"||l==="sub_sub_header")return{id:r,type:l,text:h((c=a.properties)==null?void 0:c.title),indentLevel:Z[l]}}return null}).filter(Boolean),n=[{actual:-1,effective:-1}];for(let r of o){let{indentLevel:a}=r,m=a;do{let c=n[n.length-1],{actual:l,effective:i}=c;if(m>l)r.indentLevel=i+1,n.push({actual:m,effective:r.indentLevel});else if(m===l){r.indentLevel=i;break}else n.pop()}while(!0)}return o};var Te=(e,t)=>{let o=t||Object.keys(e.block)[0],n=new Set;function s(r){var u,g,p,_;if(n.has(r))return;n.add(r);let a=(u=e.block[r])==null?void 0:u.value;if(!a)return;let{content:m,type:c,properties:l,format:i}=a;if(l)for(let y of Object.keys(l)){let f=l[y];f.map(x=>{var v,I;let b=(I=(v=x==null?void 0:x[0])==null?void 0:v[1])==null?void 0:I[0];(b==null?void 0:b[0])==="p"&&b[1]&&s(b[1])});let k=(p=(g=f==null?void 0:f[0])==null?void 0:g[1])==null?void 0:p[0];(k==null?void 0:k[0])==="p"&&k[1]&&s(k[1])}if(i){let y=(_=i.transclusion_reference_pointer)==null?void 0:_.id;y&&s(y)}if(!(!m||!Array.isArray(m))&&!(r!==o&&(c==="page"||c==="collection_view_page")))for(let y of m)s(y)}return s(o),Array.from(n)};var L=(e="")=>`${e.substr(0,8)}-${e.substr(8,4)}-${e.substr(12,4)}-${e.substr(16,4)}-${e.substr(20)}`;var G=/\b([a-f0-9]{32})\b/,J=/\b([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})\b/,W=(e="",{uuid:t=!0}={})=>{if(!e)return null;e=e.split("?")[0];let o=e.match(G);if(o)return t?L(o[1]):o[1];let n=e.match(J);return n?t?n[1]:n[1].replace(/-/g,""):null};var M=e=>e.replace(/-/g,"");import K from"p-queue";function Ee(a,m,c){return R(this,arguments,function*(e,t,o,{concurrency:n=4,traverseCollections:s=!0,targetPageId:r=null}={}){let l={},i=new Set,u=new K({concurrency:n});function g(p){return R(this,null,function*(){r&&i.has(r)||(p=W(p),p&&!l[p]&&!i.has(p)&&(i.add(p),u.add(()=>R(this,null,function*(){var _,y;try{if(r&&i.has(r)&&p!==r)return;let f=yield o(p);if(!f)return;let k=(y=(_=f.block[p])==null?void 0:_.value)==null?void 0:y.space_id;if(k){if(!t)t=k;else if(t!==k)return}if(Object.keys(f.block).filter(x=>{var v;let b=(v=f.block[x])==null?void 0:v.value;return!(!b||b.type!=="page"&&b.type!=="collection_view_page"||t&&b.space_id&&b.space_id!==t)}).forEach(x=>g(x)),s)for(let x of Object.values(f.collection_query))for(let b of Object.values(x)){let{blockIds:v}=b;if(v)for(let I of v)g(I)}l[p]=f}catch(f){console.warn("page load error",{pageId:p,spaceId:t},f.statusCode,f.message),l[p]=null}i.delete(p)}))))})}return yield g(e),yield u.onIdle(),l})}var z=e=>(e||"").replace(/ /g,"-").replace(/[^a-zA-Z0-9-\u4e00-\u9fa5]/g,"").replace(/--/g,"-").replace(/-$/,"").replace(/^-/,"").trim().toLowerCase();var We=(e,t,{uuid:o=!0}={})=>{var r;if(!e||!t)return null;let n=M(e),s=(r=t.block[e])==null?void 0:r.value;if(s){let a=P("slug",s,t)||P("Slug",s,t)||z(T(s,t));if(a)return o?`${a}-${n}`:a}return n};var qe=(e,t)=>{var r;let o=e.block,n=[],s=t;do{let a=(r=o[s])==null?void 0:r.value;if(!a)break;let m=T(a,e),c=B(a,e);if(!(m||c))break;n.push({block:a,active:s===t,pageId:s,title:m,icon:c});let l=O(a,e),i=l==null?void 0:l.id;if(!i)break;s=i}while(!0);return n.reverse(),n};import j from"is-url-superb";var Ye=(e,{mapImageUrl:t})=>{let n=Object.keys(e.block).flatMap(s=>{var m,c,l,i,u,g,p,_;let r=(m=e.block[s])==null?void 0:m.value,a=[];if(r){if(r.type==="image"){let k=((c=e.signed_urls)==null?void 0:c[r.id])||((u=(i=(l=r.properties)==null?void 0:l.source)==null?void 0:i[0])==null?void 0:u[0]);k&&a.push({block:r,url:k})}if((g=r.format)!=null&&g.page_cover){let f=r.format.page_cover;a.push({block:r,url:f})}if((p=r.format)!=null&&p.bookmark_cover){let f=r.format.bookmark_cover;a.push({block:r,url:f})}if((_=r.format)!=null&&_.bookmark_icon){let f=r.format.bookmark_icon;a.push({block:r,url:f})}let y=B(r,e);y&&j(y)&&a.push({block:r,url:y})}return a}).filter(Boolean).map(({block:s,url:r})=>t(r,s)).filter(Boolean);return Array.from(new Set(n))};import X from"mem";import ee from"normalize-url";var te=X(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=te(o);t.pathname=`/image/${encodeURIComponent(n)}`,e=t.toString()}return ee(e,{stripProtocol:!0,stripWWW:!0,stripHash:!0,stripTextFragment:!0,removeQueryParameters:!0})}catch(t){return""}});function Xe(e,t){return{block:d(d({},e.block),t.block),collection:d(d({},e.collection),t.collection),collection_view:d(d({},e.collection_view),t.collection_view),notion_user:d(d({},e.notion_user),t.notion_user),collection_query:d(d({},e.collection_query),t.collection_query),signed_urls:d(d({},e.signed_urls),t.signed_urls),preview_images:d(d({},e.preview_images),t.preview_images)}}var A=(e,{month:t="short"}={})=>{let o=new Date(e);return`${o.toLocaleString("en-US",{month:t})} ${o.getUTCDate()}, ${o.getUTCFullYear()}`};var rt=e=>{let t=`${e.start_time||""} ${e.start_date} ${e.time_zone||""}`;return A(t)};function oe(e,t,{wordsPerMinute:o=275,imageReadTimeInSeconds:n=12}={}){let s=C(e,t),r=s.numWords/o,m=(s.numImages>10?s.numImages/2*(n+3)+(s.numImages-10)*3:s.numImages/2*(2*n+(1-s.numImages)))/60,c=r+m;return U(d({},s),{totalWordsReadTimeInMinutes:r,totalImageReadTimeInMinutes:m,totalReadTimeInMinutes:c})}function ct(e,t,o){let n=oe(e,t,o);return ne(n.totalReadTimeInMinutes)}function C(e,t){var n,s,r,a;let o={numWords:0,numImages:0};if(!e)return o;for(let m of e.content||[]){let c=(n=t.block[m])==null?void 0:n.value,l=!1;if(!!c){switch(c.type){case"quote":case"alias":case"header":case"sub_header":case"sub_sub_header":{let i=T(c,t);o.numWords+=E(i);break}case"callout":case"toggle":case"to_do":case"bulleted_list":case"numbered_list":case"text":{let i=T(c,t);o.numWords+=E(i),l=!0;break}case"embed":case"tweet":case"maps":case"pdf":case"figma":case"typeform":case"codepen":case"excalidraw":case"gist":case"video":case"drive":case"audio":case"file":case"image":o.numImages+=1;break;case"bookmark":o.numImages+=.25;break;case"code":o.numImages+=2;break;case"table":case"collection_view":o.numImages+=2;break;case"column":case"column_list":case"transclusion_container":l=!0;break;case"table_of_contents":{let i=e;if(!i)continue;let u=S(i,t);for(let g of u)o.numWords+=E(g.text);break}case"transclusion_reference":{let i=(r=(s=c==null?void 0:c.format)==null?void 0:s.transclusion_reference_pointer)==null?void 0:r.id;if(!i)continue;let u=(a=t.block[i])==null?void 0:a.value;u&&q(o,C(u,t));break}default:break}l&&q(o,C(c,t))}}return o}function q(e,t){e.numWords+=t.numWords,e.numImages+=t.numImages}function E(e){return e?(e.match(/\w+/g)||[]).length:0}function ne(e){return e<.5?"less than a minute":e<1.5?"1 minute":`${Math.ceil(e)} minutes`}export{oe as estimatePageReadTime,ct as estimatePageReadTimeAsHumanizedString,A as formatDate,rt as formatNotionDateTime,Ee as getAllPagesInSpace,w as getBlockCollectionId,B as getBlockIcon,O as getBlockParentPage,T as getBlockTitle,We as getCanonicalPageId,Y as getDateValue,qe as getPageBreadcrumbs,Te as getPageContentBlockIds,Ye as getPageImageUrls,P as getPageProperty,S as getPageTableOfContents,pe as getPageTitle,h as getTextContent,L as idToUuid,j as isUrl,Xe as mergeRecordMaps,z as normalizeTitle,te as normalizeUrl,W as parsePageId,M as uuidToId}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "notion-utils", | ||
"version": "6.13.4", | ||
"version": "6.15.6", | ||
"type": "module", | ||
@@ -34,3 +34,3 @@ "description": "Useful utilities for working with Notion data. Isomorphic.", | ||
"normalize-url": "^7.0.3", | ||
"notion-types": "^6.13.4", | ||
"notion-types": "^6.15.6", | ||
"p-queue": "^7.2.0" | ||
@@ -49,3 +49,3 @@ }, | ||
}, | ||
"gitHead": "bf81f2aa75c60b785e850b363901f47b9a2cd464" | ||
"gitHead": "621e966049fd755079e6f1a62cae825e9fbeeddd" | ||
} |
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
117423
Updatednotion-types@^6.15.6