@sanity/export 2.21.11-reference-updates.62 → 2.21.12-purple-unicorn.1300
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/jest.config.js +3 -2
- package/lib/AssetHandler.js +2 -2
- package/lib/export.js +12 -1
- package/lib/getDocumentsStream.js +2 -2
- package/lib/requestStream.js +19 -41
- package/package.json +12 -11
- package/src/export.js +18 -2
- package/src/requestStream.js +10 -34
package/jest.config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const {createJestConfig} = require('../../../test/config')
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @type {import('@jest/types').Config.InitialOptions} */
|
|
4
|
+
module.exports = createJestConfig({
|
|
4
5
|
displayName: require('./package.json').name,
|
|
5
6
|
testEnvironment: 'node',
|
|
6
7
|
})
|
package/lib/AssetHandler.js
CHANGED
|
@@ -14,9 +14,9 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
14
14
|
|
|
15
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
16
|
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
18
|
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
20
|
|
|
21
21
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
22
22
|
|
package/lib/export.js
CHANGED
|
@@ -67,7 +67,14 @@ function exportDataset(opts) {
|
|
|
67
67
|
});
|
|
68
68
|
debug('Outputting assets (temporarily) to %s', tmpDir);
|
|
69
69
|
debug('Outputting to %s', options.outputPath === '-' ? 'stdout' : options.outputPath);
|
|
70
|
-
var outputStream
|
|
70
|
+
var outputStream;
|
|
71
|
+
|
|
72
|
+
if (isWritableStream(options.outputPath)) {
|
|
73
|
+
outputStream = options.outputPath;
|
|
74
|
+
} else {
|
|
75
|
+
outputStream = options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath);
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
var assetStreamHandler = assetHandler.noop;
|
|
72
79
|
|
|
73
80
|
if (!options.raw) {
|
|
@@ -235,4 +242,8 @@ function exportDataset(opts) {
|
|
|
235
242
|
}());
|
|
236
243
|
}
|
|
237
244
|
|
|
245
|
+
function isWritableStream(val) {
|
|
246
|
+
return val !== null && typeof val === 'object' && typeof val.pipe === 'function' && typeof val._write === 'function' && typeof val._writableState === 'object';
|
|
247
|
+
}
|
|
248
|
+
|
|
238
249
|
module.exports = exportDataset;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
|
package/lib/requestStream.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
|
|
@@ -10,45 +10,23 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
10
10
|
|
|
11
11
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var getIt = require('get-it');
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _require = require('get-it/middleware'),
|
|
16
|
+
keepAlive = _require.keepAlive,
|
|
17
|
+
promise = _require.promise;
|
|
16
18
|
|
|
17
19
|
var debug = require('./debug');
|
|
18
20
|
|
|
19
|
-
var
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
var request = getIt([keepAlive(), promise({
|
|
22
|
+
onlyBody: true
|
|
23
|
+
})]);
|
|
22
24
|
var socketsWithTimeout = new WeakSet();
|
|
23
25
|
var CONNECTION_TIMEOUT = 15 * 1000; // 15 seconds
|
|
24
26
|
|
|
25
27
|
var READ_TIMEOUT = 3 * 60 * 1000; // 3 minutes
|
|
26
28
|
|
|
27
|
-
var MAX_RETRIES = 5;
|
|
28
|
-
|
|
29
|
-
function getStream(options) {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
var rejected = false;
|
|
32
|
-
var openTimeout = setTimeout(() => {
|
|
33
|
-
rejected = true;
|
|
34
|
-
reject(new Error("Connection timed out after ".concat(CONNECTION_TIMEOUT, " ms")));
|
|
35
|
-
}, CONNECTION_TIMEOUT);
|
|
36
|
-
simpleGet(options, (err, res) => {
|
|
37
|
-
clearTimeout(openTimeout);
|
|
38
|
-
|
|
39
|
-
if (rejected) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (err) {
|
|
44
|
-
reject(err);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
resolve(res);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
}
|
|
29
|
+
var MAX_RETRIES = 5;
|
|
52
30
|
|
|
53
31
|
function delay(ms) {
|
|
54
32
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -58,19 +36,19 @@ function delay(ms) {
|
|
|
58
36
|
|
|
59
37
|
module.exports = /*#__PURE__*/function () {
|
|
60
38
|
var _ref = _asyncToGenerator(function* (options) {
|
|
61
|
-
var agent = options.url.startsWith('https:') ? httpsAgent : httpAgent;
|
|
62
|
-
|
|
63
|
-
var reqOptions = _objectSpread(_objectSpread({}, options), {}, {
|
|
64
|
-
followRedirects: false,
|
|
65
|
-
agent
|
|
66
|
-
});
|
|
67
|
-
|
|
68
39
|
var error;
|
|
69
40
|
|
|
70
41
|
for (var i = 0; i < MAX_RETRIES; i++) {
|
|
71
42
|
try {
|
|
72
43
|
var _ret = yield* function* () {
|
|
73
|
-
var response = yield
|
|
44
|
+
var response = yield request(_objectSpread(_objectSpread({}, options), {}, {
|
|
45
|
+
stream: true,
|
|
46
|
+
maxRedirects: 0,
|
|
47
|
+
timeout: {
|
|
48
|
+
connect: CONNECTION_TIMEOUT,
|
|
49
|
+
socket: READ_TIMEOUT
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
74
52
|
|
|
75
53
|
if (response.connection && typeof response.connection.setTimeout === 'function' && !socketsWithTimeout.has(response.connection)) {
|
|
76
54
|
socketsWithTimeout.add(response.connection);
|
|
@@ -88,7 +66,7 @@ module.exports = /*#__PURE__*/function () {
|
|
|
88
66
|
} catch (err) {
|
|
89
67
|
error = err;
|
|
90
68
|
|
|
91
|
-
if (err.statusCode && err.statusCode < 500) {
|
|
69
|
+
if (err.response && err.response.statusCode && err.response.statusCode < 500) {
|
|
92
70
|
break;
|
|
93
71
|
}
|
|
94
72
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/export",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.12-purple-unicorn.1300+abdd014728",
|
|
4
4
|
"description": "Export Sanity documents and assets",
|
|
5
|
-
"main": "lib/export.js",
|
|
5
|
+
"main": "./lib/export.js",
|
|
6
|
+
"types": "./lib/dts/src/export.d.ts",
|
|
6
7
|
"engines": {
|
|
7
8
|
"node": ">=12.0.0"
|
|
8
9
|
},
|
|
9
10
|
"author": "Sanity.io <hello@sanity.io>",
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"scripts": {
|
|
12
|
-
"build": "
|
|
13
|
-
"clean": "rimraf lib
|
|
14
|
-
"prebuild": "
|
|
15
|
-
"test": "jest"
|
|
13
|
+
"build": "../../../bin/pkg-utils transpile --target node",
|
|
14
|
+
"clean": "rimraf lib",
|
|
15
|
+
"prebuild": "yarn clean",
|
|
16
|
+
"test": "jest",
|
|
17
|
+
"watch": "../../../bin/pkg-utils transpile --target node --watch"
|
|
16
18
|
},
|
|
17
19
|
"keywords": [
|
|
18
20
|
"sanity",
|
|
@@ -24,18 +26,17 @@
|
|
|
24
26
|
"ndjson"
|
|
25
27
|
],
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"agentkeepalive": "^4.1.0",
|
|
28
29
|
"archiver": "^5.0.0",
|
|
29
30
|
"debug": "^3.2.7",
|
|
30
31
|
"fs-extra": "^7.0.0",
|
|
31
|
-
"
|
|
32
|
+
"get-it": "^5.2.1",
|
|
33
|
+
"lodash": "^4.17.21",
|
|
32
34
|
"mississippi": "^4.0.0",
|
|
33
35
|
"p-queue": "^2.3.0",
|
|
34
|
-
"simple-get": "^4.0.0",
|
|
35
36
|
"split2": "^3.2.2"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"rimraf": "^
|
|
39
|
+
"rimraf": "^3.0.2",
|
|
39
40
|
"string-to-stream": "^1.1.0"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
@@ -50,5 +51,5 @@
|
|
|
50
51
|
"url": "https://github.com/sanity-io/sanity/issues"
|
|
51
52
|
},
|
|
52
53
|
"homepage": "https://www.sanity.io/",
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "abdd014728981dd514951705252054db61bcd3f4"
|
|
54
55
|
}
|
package/src/export.js
CHANGED
|
@@ -48,8 +48,14 @@ function exportDataset(opts) {
|
|
|
48
48
|
|
|
49
49
|
debug('Outputting assets (temporarily) to %s', tmpDir)
|
|
50
50
|
debug('Outputting to %s', options.outputPath === '-' ? 'stdout' : options.outputPath)
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
|
|
52
|
+
let outputStream
|
|
53
|
+
if (isWritableStream(options.outputPath)) {
|
|
54
|
+
outputStream = options.outputPath
|
|
55
|
+
} else {
|
|
56
|
+
outputStream =
|
|
57
|
+
options.outputPath === '-' ? process.stdout : fse.createWriteStream(options.outputPath)
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
let assetStreamHandler = assetHandler.noop
|
|
55
61
|
if (!options.raw) {
|
|
@@ -195,4 +201,14 @@ function exportDataset(opts) {
|
|
|
195
201
|
})
|
|
196
202
|
}
|
|
197
203
|
|
|
204
|
+
function isWritableStream(val) {
|
|
205
|
+
return (
|
|
206
|
+
val !== null &&
|
|
207
|
+
typeof val === 'object' &&
|
|
208
|
+
typeof val.pipe === 'function' &&
|
|
209
|
+
typeof val._write === 'function' &&
|
|
210
|
+
typeof val._writableState === 'object'
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
|
|
198
214
|
module.exports = exportDataset
|
package/src/requestStream.js
CHANGED
|
@@ -1,53 +1,29 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const getIt = require('get-it')
|
|
2
|
+
const {keepAlive, promise} = require('get-it/middleware')
|
|
3
3
|
const debug = require('./debug')
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const httpAgent = new HttpAgent()
|
|
7
|
-
const httpsAgent = new HttpsAgent()
|
|
5
|
+
const request = getIt([keepAlive(), promise({onlyBody: true})])
|
|
8
6
|
const socketsWithTimeout = new WeakSet()
|
|
9
7
|
|
|
10
8
|
const CONNECTION_TIMEOUT = 15 * 1000 // 15 seconds
|
|
11
9
|
const READ_TIMEOUT = 3 * 60 * 1000 // 3 minutes
|
|
12
10
|
const MAX_RETRIES = 5
|
|
13
11
|
|
|
14
|
-
// Just a promisified simpleGet
|
|
15
|
-
function getStream(options) {
|
|
16
|
-
return new Promise((resolve, reject) => {
|
|
17
|
-
let rejected = false
|
|
18
|
-
const openTimeout = setTimeout(() => {
|
|
19
|
-
rejected = true
|
|
20
|
-
reject(new Error(`Connection timed out after ${CONNECTION_TIMEOUT} ms`))
|
|
21
|
-
}, CONNECTION_TIMEOUT)
|
|
22
|
-
|
|
23
|
-
simpleGet(options, (err, res) => {
|
|
24
|
-
clearTimeout(openTimeout)
|
|
25
|
-
if (rejected) {
|
|
26
|
-
return
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (err) {
|
|
30
|
-
reject(err)
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
resolve(res)
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
12
|
function delay(ms) {
|
|
40
13
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
41
14
|
}
|
|
42
15
|
|
|
43
16
|
/* eslint-disable no-await-in-loop, max-depth */
|
|
44
17
|
module.exports = async (options) => {
|
|
45
|
-
const agent = options.url.startsWith('https:') ? httpsAgent : httpAgent
|
|
46
|
-
const reqOptions = {...options, followRedirects: false, agent}
|
|
47
18
|
let error
|
|
48
19
|
for (let i = 0; i < MAX_RETRIES; i++) {
|
|
49
20
|
try {
|
|
50
|
-
const response = await
|
|
21
|
+
const response = await request({
|
|
22
|
+
...options,
|
|
23
|
+
stream: true,
|
|
24
|
+
maxRedirects: 0,
|
|
25
|
+
timeout: {connect: CONNECTION_TIMEOUT, socket: READ_TIMEOUT},
|
|
26
|
+
})
|
|
51
27
|
|
|
52
28
|
if (
|
|
53
29
|
response.connection &&
|
|
@@ -66,7 +42,7 @@ module.exports = async (options) => {
|
|
|
66
42
|
} catch (err) {
|
|
67
43
|
error = err
|
|
68
44
|
|
|
69
|
-
if (err.statusCode && err.statusCode < 500) {
|
|
45
|
+
if (err.response && err.response.statusCode && err.response.statusCode < 500) {
|
|
70
46
|
break
|
|
71
47
|
}
|
|
72
48
|
|