@sanity/export 3.43.0 → 3.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/export",
3
- "version": "3.43.0",
3
+ "version": "3.44.0",
4
4
  "description": "Export Sanity documents and assets",
5
5
  "keywords": [
6
6
  "sanity",
package/src/export.js CHANGED
@@ -9,9 +9,7 @@ const JsonStreamStringify = require('json-stream-stringify')
9
9
  const AssetHandler = require('./AssetHandler')
10
10
  const debug = require('./debug')
11
11
  const pipeAsync = require('./util/pipeAsync')
12
- const filterDocumentTypes = require('./filterDocumentTypes')
13
- const filterDrafts = require('./filterDrafts')
14
- const filterSystemDocuments = require('./filterSystemDocuments')
12
+ const filterDocuments = require('./filterDocuments')
15
13
  const getDocumentsStream = require('./getDocumentsStream')
16
14
  const getDocumentCursorStream = require('./getDocumentCursorStream')
17
15
  const logFirstChunk = require('./logFirstChunk')
@@ -156,10 +154,8 @@ async function exportDataset(opts) {
156
154
  logFirstChunk(),
157
155
  split(tryParseJson),
158
156
  rejectOnApiError(),
159
- filterSystemDocuments(),
157
+ filterDocuments(options.drafts),
160
158
  assetStreamHandler,
161
- filterDocumentTypes(options.types),
162
- options.drafts ? miss.through.obj() : filterDrafts(),
163
159
  miss.through.obj((doc, _enc, callback) => {
164
160
  if (options.filterDocument(doc)) {
165
161
  return callback(null, doc)
@@ -1,19 +1,34 @@
1
1
  const miss = require('mississippi')
2
2
  const debug = require('./debug')
3
3
 
4
+ const isDraftOrVersion = (doc) => doc && doc._id && (
5
+ doc._id.indexOf('drafts.') === 0 ||
6
+ doc._id.indexOf('versions.') === 0
7
+ )
8
+
4
9
  const isSystemDocument = (doc) => doc && doc._id && doc._id.indexOf('_.') === 0
10
+ const isRelease = (doc) => doc && doc._id && doc._id.indexOf('_.releases.') === 0
5
11
  const isCursor = (doc) => doc && !doc._id && doc.nextCursor !== undefined
6
12
 
7
- module.exports = () =>
13
+ module.exports = (drafts) =>
8
14
  miss.through.obj((doc, enc, callback) => {
9
- if (isSystemDocument(doc)) {
10
- debug('%s is a system document, skipping', doc && doc._id)
11
- return callback()
12
- }
13
15
  if (isCursor(doc)) {
14
16
  debug('%o is a cursor, skipping', doc)
15
17
  return callback()
16
18
  }
17
19
 
20
+ if (!drafts && isDraftOrVersion(doc)) {
21
+ debug('%s is a draft or version, skipping', doc && doc._id)
22
+ return callback()
23
+ }
24
+
25
+ if (isSystemDocument(doc)) {
26
+ if (!drafts && isRelease(doc)) {
27
+ return callback(null, doc)
28
+ }
29
+ debug('%s is a system document, skipping', doc && doc._id)
30
+ return callback()
31
+ }
32
+
18
33
  return callback(null, doc)
19
- })
34
+ })
@@ -1,12 +0,0 @@
1
- const miss = require('mississippi')
2
-
3
- const isDraft = (doc) => doc && doc._id && doc._id.indexOf('drafts.') === 0
4
-
5
- module.exports = () =>
6
- miss.through.obj((doc, enc, callback) => {
7
- if (isDraft(doc)) {
8
- return callback()
9
- }
10
-
11
- return callback(null, doc)
12
- })