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.0.6 to 6.0.8

81

build/index.js

@@ -77,46 +77,49 @@ var __async = (__this, __arguments, generator) => {

var _a;
if (!block.properties || !Object.keys(recordMap.collection)) {
return null;
}
const collection = (_a = recordMap.collection[block.parent_id]) == null ? void 0 : _a.value;
if (collection) {
const propertyId = Object.keys(collection.schema).find((key) => {
var _a2;
return ((_a2 = collection.schema[key]) == null ? void 0 : _a2.name) === propertyName;
});
if (!propertyId) {
try {
if (!block.properties || !Object.keys(recordMap.collection)) {
return null;
}
const { type } = collection.schema[propertyId];
const content = getTextContent(block.properties[propertyId]);
switch (type) {
case "created_time":
return block.created_time;
case "multi_select":
return content.split(",");
case "date": {
const property = block.properties[propertyId];
const formatDate = property[0][1][0][1];
if (formatDate.type == "datetime") {
return new Date(`${formatDate.start_date} ${formatDate.start_time}`).getTime();
} else if (formatDate.type == "date") {
return new Date(formatDate.start_date).getTime();
} else if (formatDate.type == "datetimerange") {
const { start_date, start_time, end_date, end_time } = formatDate;
const startTime = new Date(`${start_date} ${start_time}`).getTime();
const endTime = new Date(`${end_date} ${end_time}`).getTime();
return [startTime, endTime];
} else {
const startTime = new Date(formatDate.start_date).getTime();
const endTime = new Date(formatDate.end_date).getTime();
return [startTime, endTime];
const collection = (_a = recordMap.collection[block.parent_id]) == null ? void 0 : _a.value;
if (collection) {
const propertyId = Object.keys(collection.schema).find((key) => {
var _a2;
return ((_a2 = collection.schema[key]) == null ? void 0 : _a2.name) === propertyName;
});
if (!propertyId) {
return null;
}
const { type } = collection.schema[propertyId];
const content = getTextContent(block.properties[propertyId]);
switch (type) {
case "created_time":
return block.created_time;
case "multi_select":
return content.split(",");
case "date": {
const property = block.properties[propertyId];
const formatDate = property[0][1][0][1];
if (formatDate.type == "datetime") {
return new Date(`${formatDate.start_date} ${formatDate.start_time}`).getTime();
} else if (formatDate.type == "date") {
return new Date(formatDate.start_date).getTime();
} else if (formatDate.type == "datetimerange") {
const { start_date, start_time, end_date, end_time } = formatDate;
const startTime = new Date(`${start_date} ${start_time}`).getTime();
const endTime = new Date(`${end_date} ${end_time}`).getTime();
return [startTime, endTime];
} else {
const startTime = new Date(formatDate.start_date).getTime();
const endTime = new Date(formatDate.end_date).getTime();
return [startTime, endTime];
}
}
case "checkbox":
return content == "Yes";
case "last_edited_time":
return block.last_edited_time;
default:
return content;
}
case "checkbox":
return content == "Yes";
case "last_edited_time":
return block.last_edited_time;
default:
return content;
}
} catch (e) {
}

@@ -123,0 +126,0 @@ return null;

{
"name": "notion-utils",
"version": "6.0.6",
"version": "6.0.8",
"type": "module",

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

},
"gitHead": "dca0609ca0f2e052e24250a77ded071764f9dada"
"gitHead": "26b866613f5722751921c3f71c7b2aa2b1d75d47"
}

@@ -25,60 +25,65 @@ import { Block, DateFormat, ExtendedRecordMap } from 'notion-types'

) {
if (!block.properties || !Object.keys(recordMap.collection)) {
// console.warn(
// `block ${block.id} has no properties or this recordMap has no collection record`
// )
return null
}
try {
if (!block.properties || !Object.keys(recordMap.collection)) {
// console.warn(
// `block ${block.id} has no properties or this recordMap has no collection record`
// )
return null
}
const collection = recordMap.collection[block.parent_id]?.value
const collection = recordMap.collection[block.parent_id]?.value
if (collection) {
const propertyId = Object.keys(collection.schema).find(
(key) => collection.schema[key]?.name === propertyName
)
if (collection) {
const propertyId = Object.keys(collection.schema).find(
(key) => collection.schema[key]?.name === propertyName
)
if (!propertyId) {
return null
}
if (!propertyId) {
return null
}
const { type } = collection.schema[propertyId]
const content = getTextContent(block.properties[propertyId])
const { type } = collection.schema[propertyId]
const content = getTextContent(block.properties[propertyId])
switch (type) {
case 'created_time':
return block.created_time
switch (type) {
case 'created_time':
return block.created_time
case 'multi_select':
return content.split(',')
case 'multi_select':
return content.split(',')
case 'date': {
const property = block.properties[propertyId] as [['‣', [DateFormat]]]
const formatDate = property[0][1][0][1]
if (formatDate.type == 'datetime') {
return new Date(
`${formatDate.start_date} ${formatDate.start_time}`
).getTime()
} else if (formatDate.type == 'date') {
return new Date(formatDate.start_date).getTime()
} else if (formatDate.type == 'datetimerange') {
const { start_date, start_time, end_date, end_time } = formatDate
const startTime = new Date(`${start_date} ${start_time}`).getTime()
const endTime = new Date(`${end_date} ${end_time}`).getTime()
return [startTime, endTime]
} else {
const startTime = new Date(formatDate.start_date).getTime()
const endTime = new Date(formatDate.end_date).getTime()
return [startTime, endTime]
case 'date': {
const property = block.properties[propertyId] as [['‣', [DateFormat]]]
const formatDate = property[0][1][0][1]
if (formatDate.type == 'datetime') {
return new Date(
`${formatDate.start_date} ${formatDate.start_time}`
).getTime()
} else if (formatDate.type == 'date') {
return new Date(formatDate.start_date).getTime()
} else if (formatDate.type == 'datetimerange') {
const { start_date, start_time, end_date, end_time } = formatDate
const startTime = new Date(`${start_date} ${start_time}`).getTime()
const endTime = new Date(`${end_date} ${end_time}`).getTime()
return [startTime, endTime]
} else {
const startTime = new Date(formatDate.start_date).getTime()
const endTime = new Date(formatDate.end_date).getTime()
return [startTime, endTime]
}
}
}
case 'checkbox':
return content == 'Yes'
case 'checkbox':
return content == 'Yes'
case 'last_edited_time':
return block.last_edited_time
case 'last_edited_time':
return block.last_edited_time
default:
return content
default:
return content
}
}
} catch {
// ensure that no matter what, we don't throw errors because of an unexpected
// collection data format
}

@@ -85,0 +90,0 @@

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