notion-utils
Advanced tools
Comparing version 7.0.1 to 7.1.0
@@ -152,2 +152,6 @@ import * as types from 'notion-types'; | ||
declare const defaultMapImageUrl: (url: string | undefined, block: Block) => string | undefined; | ||
declare const defaultMapPageUrl: (rootPageId?: string) => (pageId: string) => string; | ||
declare function mergeRecordMaps(recordMapA: ExtendedRecordMap, recordMapB: ExtendedRecordMap): ExtendedRecordMap; | ||
@@ -170,2 +174,2 @@ | ||
export { type NotionDateTime, type TableOfContentsEntry, estimatePageReadTime, estimatePageReadTimeAsHumanizedString, formatDate, formatNotionDateTime, getAllPagesInSpace, getBlockCollectionId, getBlockIcon, getBlockParentPage, getBlockTitle, getCanonicalPageId, getDateValue, getPageBreadcrumbs, getPageContentBlockIds, getPageImageUrls, getPageProperty, getPageTableOfContents, getPageTitle, getTextContent, idToUuid, mergeRecordMaps, normalizeTitle, normalizeUrl, parsePageId, uuidToId }; | ||
export { type NotionDateTime, type TableOfContentsEntry, defaultMapImageUrl, defaultMapPageUrl, estimatePageReadTime, estimatePageReadTimeAsHumanizedString, formatDate, formatNotionDateTime, getAllPagesInSpace, getBlockCollectionId, getBlockIcon, getBlockParentPage, getBlockTitle, getCanonicalPageId, getDateValue, getPageBreadcrumbs, getPageContentBlockIds, getPageImageUrls, getPageProperty, getPageTableOfContents, getPageTitle, getTextContent, idToUuid, mergeRecordMaps, normalizeTitle, normalizeUrl, parsePageId, uuidToId }; |
@@ -717,2 +717,49 @@ // src/estimate-page-read-time.ts | ||
// src/map-image-url.ts | ||
import "notion-types"; | ||
var defaultMapImageUrl = (url, block) => { | ||
if (!url) { | ||
return void 0; | ||
} | ||
if (url.startsWith("data:")) { | ||
return url; | ||
} | ||
if (url.startsWith("https://images.unsplash.com")) { | ||
return url; | ||
} | ||
try { | ||
const u = new URL(url); | ||
if (u.pathname.startsWith("/secure.notion-static.com") && u.hostname.endsWith(".amazonaws.com")) { | ||
if (u.searchParams.has("X-Amz-Credential") && u.searchParams.has("X-Amz-Signature") && u.searchParams.has("X-Amz-Algorithm")) { | ||
return url; | ||
} | ||
} | ||
} catch (e) { | ||
} | ||
if (url.startsWith("/images")) { | ||
url = `https://www.notion.so${url}`; | ||
} | ||
url = `https://www.notion.so${url.startsWith("/image") ? url : `/image/${encodeURIComponent(url)}`}`; | ||
const notionImageUrlV2 = new URL(url); | ||
let table = block.parent_table === "space" ? "block" : block.parent_table; | ||
if (table === "collection" || table === "team") { | ||
table = "block"; | ||
} | ||
notionImageUrlV2.searchParams.set("table", table); | ||
notionImageUrlV2.searchParams.set("id", block.id); | ||
notionImageUrlV2.searchParams.set("cache", "v2"); | ||
url = notionImageUrlV2.toString(); | ||
return url; | ||
}; | ||
// src/map-page-url.ts | ||
var defaultMapPageUrl = (rootPageId) => (pageId) => { | ||
pageId = (pageId || "").replaceAll("-", ""); | ||
if (rootPageId && pageId === rootPageId) { | ||
return "/"; | ||
} else { | ||
return `/${pageId}`; | ||
} | ||
}; | ||
// src/merge-record-maps.ts | ||
@@ -781,2 +828,4 @@ import "notion-types"; | ||
export { | ||
defaultMapImageUrl, | ||
defaultMapPageUrl, | ||
estimatePageReadTime, | ||
@@ -783,0 +832,0 @@ estimatePageReadTimeAsHumanizedString, |
{ | ||
"name": "notion-utils", | ||
"version": "7.0.1", | ||
"version": "7.1.0", | ||
"type": "module", | ||
@@ -25,11 +25,5 @@ "description": "Useful utilities for working with Notion data. Isomorphic.", | ||
}, | ||
"dependencies": { | ||
"is-url-superb": "^6.1.0", | ||
"mem": "^10.0.0", | ||
"normalize-url": "^8.0.1", | ||
"p-queue": "^8.0.1", | ||
"notion-types": "7.0.1" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "tsup --watch", | ||
"watch": "tsup --watch --silent --onSuccess 'echo build successful'", | ||
@@ -41,3 +35,10 @@ "clean": "del build", | ||
"test:unit": "vitest run" | ||
}, | ||
"dependencies": { | ||
"is-url-superb": "^6.1.0", | ||
"mem": "^10.0.0", | ||
"normalize-url": "^8.0.1", | ||
"notion-types": "workspace:*", | ||
"p-queue": "^8.0.1" | ||
} | ||
} | ||
} |
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
83614
973
5
- Removednotion-types@7.0.1(transitive)
Updatednotion-types@workspace:*