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

@sanity/export

Package Overview
Dependencies
Maintainers
0
Versions
1042
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/export - npm Package Compare versions

Comparing version 3.38.1 to 3.38.2

2

package.json
{
"name": "@sanity/export",
"version": "3.38.1",
"version": "3.38.2",
"description": "Export Sanity documents and assets",

@@ -5,0 +5,0 @@ "keywords": [

@@ -23,1 +23,7 @@ /**

exports.ASSET_DOWNLOAD_CONCURRENCY = 8
/**
* How frequently we will `debug` log while streaming the documents.
* @internal
*/
exports.DOCUMENT_STREAM_DEBUG_INTERVAL = 10000

@@ -20,2 +20,3 @@ const fs = require('fs')

const validateOptions = require('./validateOptions')
const {DOCUMENT_STREAM_DEBUG_INTERVAL} = require('./constants')

@@ -97,7 +98,10 @@ const noop = () => null

let documentCount = 0
let lastDocumentID = null
let lastReported = Date.now()
const reportDocumentCount = (chunk, enc, cb) => {
const reportDocumentCount = (doc, enc, cb) => {
++documentCount
const now = Date.now()
// We report to the `onProgress` handler every 50 ms.
// It's up to the caller to not do too much expensive work.
if (now - lastReported > 50) {

@@ -114,3 +118,5 @@ onProgress({

cb(null, chunk)
lastDocumentID = doc._id
cb(null, doc)
}

@@ -122,2 +128,17 @@

let debugTimer = null
function scheduleDebugTimer() {
debugTimer = setTimeout(() => {
debug('Still streaming documents', {
documentCount,
lastDocumentID,
})
// Schedule another tick:
scheduleDebugTimer()
}, DOCUMENT_STREAM_DEBUG_INTERVAL)
}
scheduleDebugTimer()
const jsonStream = miss.pipeline(

@@ -132,9 +153,11 @@ inputStream,

options.drafts ? miss.through.obj() : filterDrafts(),
miss.through.obj(reportDocumentCount),
stringifyStream(),
miss.through(reportDocumentCount),
)
miss.pipe(jsonStream, fs.createWriteStream(dataPath), async (err) => {
if (debugTimer !== null) clearTimeout(debugTimer)
if (err) {
debug('Export stream error: ', err)
debug(`Export stream error @ ${lastDocumentID}/${documentCount}: `, err)
reject(err)

@@ -141,0 +164,0 @@ return

@@ -5,14 +5,22 @@ const miss = require('mississippi')

miss.through.obj((doc, enc, callback) => {
if (doc.error && doc.statusCode) {
callback(
new Error(
['Export', `HTTP ${doc.statusCode}`, doc.error, doc.message]
.filter((part) => typeof part === 'string')
.join(': '),
),
)
// check if the document passed contains a document attribtue first, and return early.
if (doc._id) {
callback(null, doc)
return
}
if (!doc._id && doc.error) {
if (doc.error) {
// if we got a statusCode we can decorate the error with it
if (doc.statusCode) {
callback(
new Error(
['Export', `HTTP ${doc.statusCode}`, doc.error, doc.message]
.filter((part) => typeof part === 'string')
.join(': '),
),
)
return
}
// no statusCode, just serialize and return the error
callback(new Error(doc.error.description || doc.error.message || JSON.stringify(doc)))

@@ -19,0 +27,0 @@ return

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