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

notabase

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

notabase - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

2

package.json
{
"name": "notabase",
"version": "0.6.0",
"version": "0.6.1",
"description": "API Wrapper For Notion's Database",

@@ -5,0 +5,0 @@ "main": "src/notabase.js",

import Collection from './collection'
import { getBlockHashId, getFullBlockId } from './utils'
import { getBlockHashId, getFullBlockId, getUrlPageId } from './utils'

@@ -11,2 +11,3 @@

this.collectionSchemaStore = {}
this.collectionStore = {}
const { proxy, token } = options

@@ -117,24 +118,30 @@ // proxy > browser env + cloudflare worker

}
async _fetch(urlOrPageId) {
let collectionId, collectionViewId
async fetch(urlOrPageId) {
let collectionId, collectionViewId, pageId
if (urlOrPageId.match("^[a-zA-Z0-9-]+$")) {
// pageId with '-' split
[collectionId, collectionViewId] = await this.getPageCollectionInfo(getBlockHashId(urlOrPageId))
pageId = getBlockHashId(urlOrPageId)
if (pageId && pageId in this.collectionStore) {
return this.collectionStore[pageId]
} else {
[collectionId, collectionViewId] = await this.getPageCollectionInfo(getBlockHashId(urlOrPageId))
}
} else if (urlOrPageId.startsWith("http")) {
// url
let [base, params] = urlOrPageId.split('?')
if (!process.browser) {
const { URLSearchParams } = require('url')
pageId = getUrlPageId(urlOrPageId)
if (pageId && pageId in this.collectionStore) {
return this.collectionStore[pageId]
} else {
let [base, params] = urlOrPageId.split('?')
let baseUrlList = base.split('/'); // 这里需要添加分号,否则编译出错。 参见 https://www.zhihu.com/question/20298345/answer/49551142
[collectionId, collectionViewId] = await this.getPageCollectionInfo(baseUrlList[baseUrlList.length - 1])
}
let p = new URLSearchParams(params)
let baseUrlList = base.split('/'); // 这里需要添加分号,否则编译出错。 参见 https://www.zhihu.com/question/20298345/answer/49551142
[collectionId, collectionViewId] = await this.getPageCollectionInfo(baseUrlList[baseUrlList.length - 1])
}
let r = await this.fetchCollectionData(collectionId, collectionViewId)
this.collectionStore[pageId] = r
return r
}
async fetch(dbMap) {
async fetchAll(dbMap) {
let db = {}

@@ -141,0 +148,0 @@ let requests = Object.entries(dbMap).map(item => {

@@ -25,3 +25,3 @@ const NOTION_BASE_URL = "https://www.notion.so"

}
const getUrlBlockId = (url) => {
const getUrlPageId = (url) => {
let pUrl

@@ -35,4 +35,4 @@ if (!process.browser) {

let pathList = pUrl.pathname.split('/')
let blockID = pathList[pathList.length - 1]
return blockID
let pagId = pathList[pathList.length - 1]
return pagId
}

@@ -57,2 +57,2 @@ const parseImageUrl = (url, width) => {

module.exports = { isPageId, getBlockHashId, getFullBlockId, getBrowseableUrl, getUrlBlockId, parseImageUrl }
module.exports = { isPageId, getBlockHashId, getFullBlockId, getBrowseableUrl, getUrlPageId, parseImageUrl }
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