@sanity/export 5.0.1 → 6.0.1

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.
Files changed (115) hide show
  1. package/dist/AssetHandler.d.ts +47 -0
  2. package/dist/AssetHandler.d.ts.map +1 -0
  3. package/dist/AssetHandler.js +384 -0
  4. package/dist/AssetHandler.js.map +1 -0
  5. package/dist/constants.d.ts +45 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/{src → dist}/constants.js +13 -18
  8. package/dist/constants.js.map +1 -0
  9. package/dist/debug.d.ts +3 -0
  10. package/dist/debug.d.ts.map +1 -0
  11. package/dist/debug.js +3 -0
  12. package/dist/debug.js.map +1 -0
  13. package/dist/export.d.ts +43 -0
  14. package/dist/export.d.ts.map +1 -0
  15. package/dist/export.js +269 -0
  16. package/dist/export.js.map +1 -0
  17. package/dist/filterDocumentTypes.d.ts +3 -0
  18. package/dist/filterDocumentTypes.d.ts.map +1 -0
  19. package/dist/filterDocumentTypes.js +16 -0
  20. package/dist/filterDocumentTypes.js.map +1 -0
  21. package/dist/filterDocuments.d.ts +3 -0
  22. package/dist/filterDocuments.d.ts.map +1 -0
  23. package/dist/filterDocuments.js +36 -0
  24. package/dist/filterDocuments.js.map +1 -0
  25. package/dist/getDocumentCursorStream.d.ts +4 -0
  26. package/dist/getDocumentCursorStream.d.ts.map +1 -0
  27. package/dist/getDocumentCursorStream.js +85 -0
  28. package/dist/getDocumentCursorStream.js.map +1 -0
  29. package/dist/getDocumentsStream.d.ts +5 -0
  30. package/dist/getDocumentsStream.d.ts.map +1 -0
  31. package/dist/getDocumentsStream.js +28 -0
  32. package/dist/getDocumentsStream.js.map +1 -0
  33. package/dist/getUserAgent.d.ts +2 -0
  34. package/dist/getUserAgent.d.ts.map +1 -0
  35. package/dist/getUserAgent.js +12 -0
  36. package/dist/getUserAgent.js.map +1 -0
  37. package/dist/index.d.ts +3 -0
  38. package/dist/index.d.ts.map +1 -0
  39. package/dist/index.js +3 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/logFirstChunk.d.ts +3 -0
  42. package/dist/logFirstChunk.d.ts.map +1 -0
  43. package/dist/logFirstChunk.js +14 -0
  44. package/dist/logFirstChunk.js.map +1 -0
  45. package/dist/options.d.ts +14 -0
  46. package/dist/options.d.ts.map +1 -0
  47. package/dist/options.js +97 -0
  48. package/dist/options.js.map +1 -0
  49. package/dist/rejectOnApiError.d.ts +3 -0
  50. package/dist/rejectOnApiError.d.ts.map +1 -0
  51. package/dist/rejectOnApiError.js +35 -0
  52. package/dist/rejectOnApiError.js.map +1 -0
  53. package/dist/requestStream.d.ts +3 -0
  54. package/dist/requestStream.d.ts.map +1 -0
  55. package/dist/requestStream.js +48 -0
  56. package/dist/requestStream.js.map +1 -0
  57. package/dist/stringifyStream.d.ts +3 -0
  58. package/dist/stringifyStream.d.ts.map +1 -0
  59. package/dist/stringifyStream.js +5 -0
  60. package/dist/stringifyStream.js.map +1 -0
  61. package/dist/tryParseJson.d.ts +10 -0
  62. package/dist/tryParseJson.d.ts.map +1 -0
  63. package/dist/tryParseJson.js +36 -0
  64. package/dist/tryParseJson.js.map +1 -0
  65. package/dist/types.d.ts +241 -0
  66. package/dist/types.d.ts.map +1 -0
  67. package/dist/types.js +2 -0
  68. package/dist/types.js.map +1 -0
  69. package/dist/util/delay.d.ts +2 -0
  70. package/dist/util/delay.d.ts.map +1 -0
  71. package/dist/util/delay.js +4 -0
  72. package/dist/util/delay.js.map +1 -0
  73. package/dist/util/extractFirstError.d.ts +2 -0
  74. package/dist/util/extractFirstError.d.ts.map +1 -0
  75. package/dist/util/extractFirstError.js +22 -0
  76. package/dist/util/extractFirstError.js.map +1 -0
  77. package/dist/util/friendlyError.d.ts +2 -0
  78. package/dist/util/friendlyError.d.ts.map +1 -0
  79. package/dist/util/friendlyError.js +49 -0
  80. package/dist/util/friendlyError.js.map +1 -0
  81. package/dist/util/streamHelpers.d.ts +10 -0
  82. package/dist/util/streamHelpers.d.ts.map +1 -0
  83. package/dist/util/streamHelpers.js +99 -0
  84. package/dist/util/streamHelpers.js.map +1 -0
  85. package/package.json +22 -7
  86. package/src/{AssetHandler.js → AssetHandler.ts} +174 -99
  87. package/src/constants.ts +50 -0
  88. package/src/debug.ts +3 -0
  89. package/src/{export.js → export.ts} +110 -70
  90. package/src/filterDocumentTypes.ts +21 -0
  91. package/src/filterDocuments.ts +55 -0
  92. package/src/{getDocumentCursorStream.js → getDocumentCursorStream.ts} +37 -18
  93. package/src/{getDocumentsStream.js → getDocumentsStream.ts} +16 -6
  94. package/src/{getUserAgent.js → getUserAgent.ts} +8 -3
  95. package/src/index.ts +11 -0
  96. package/src/{logFirstChunk.js → logFirstChunk.ts} +6 -4
  97. package/src/options.ts +138 -0
  98. package/src/rejectOnApiError.ts +62 -0
  99. package/src/requestStream.ts +81 -0
  100. package/src/stringifyStream.ts +7 -0
  101. package/src/{tryParseJson.js → tryParseJson.ts} +29 -17
  102. package/src/types.ts +274 -0
  103. package/src/util/{delay.js → delay.ts} +1 -1
  104. package/src/util/extractFirstError.ts +31 -0
  105. package/src/util/friendlyError.ts +75 -0
  106. package/src/util/{streamHelpers.js → streamHelpers.ts} +35 -18
  107. package/src/debug.js +0 -3
  108. package/src/filterDocumentTypes.js +0 -18
  109. package/src/filterDocuments.js +0 -33
  110. package/src/rejectOnApiError.js +0 -31
  111. package/src/requestStream.js +0 -64
  112. package/src/stringifyStream.js +0 -5
  113. package/src/util/extractFirstError.js +0 -14
  114. package/src/util/friendlyError.js +0 -58
  115. package/src/validateOptions.js +0 -113
@@ -0,0 +1,47 @@
1
+ import PQueue from 'p-queue';
2
+ import type { AssetDocument, AssetMap, SanityClientLike } from './types.js';
3
+ declare const ACTION_REMOVE: "remove";
4
+ declare const ACTION_REWRITE: "rewrite";
5
+ type AssetAction = typeof ACTION_REMOVE | typeof ACTION_REWRITE;
6
+ interface AssetHandlerOptions {
7
+ client: SanityClientLike;
8
+ tmpDir: string;
9
+ prefix?: string;
10
+ concurrency?: number;
11
+ maxRetries?: number;
12
+ retryDelayMs?: number;
13
+ queue?: PQueue;
14
+ }
15
+ interface AssetRequestOptions {
16
+ url: string;
17
+ headers: Record<string, string>;
18
+ }
19
+ export declare class AssetHandler {
20
+ client: SanityClientLike;
21
+ tmpDir: string;
22
+ assetDirsCreated: boolean;
23
+ downloading: string[];
24
+ assetsSeen: Map<string, string>;
25
+ assetMap: AssetMap;
26
+ filesWritten: number;
27
+ queueSize: number;
28
+ maxRetries: number;
29
+ retryDelayMs: number | undefined;
30
+ queue: PQueue;
31
+ rejectedError: Error | null;
32
+ reject: (err: Error) => void;
33
+ constructor(options: AssetHandlerOptions);
34
+ clear(): void;
35
+ finish(): Promise<AssetMap>;
36
+ rewriteAssets: import("stream").Transform;
37
+ stripAssets: import("stream").Transform;
38
+ skipAssets: import("stream").Transform;
39
+ noop: import("stream").Transform;
40
+ queueAssetDownload(assetDoc: AssetDocument, dstPath: string): void;
41
+ maybeCreateAssetDirs(): void;
42
+ getAssetRequestOptions(assetDoc: AssetDocument): AssetRequestOptions;
43
+ downloadAsset(assetDoc: AssetDocument, dstPath: string): Promise<boolean>;
44
+ findAndModify: (item: unknown, action: AssetAction) => unknown;
45
+ }
46
+ export {};
47
+ //# sourceMappingURL=AssetHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssetHandler.d.ts","sourceRoot":"","sources":["../src/AssetHandler.ts"],"names":[],"mappings":"AAKA,OAAO,MAAM,MAAM,SAAS,CAAA;AAY5B,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EAGR,gBAAgB,EAEjB,MAAM,YAAY,CAAA;AAInB,QAAA,MAAM,aAAa,EAAG,QAAiB,CAAA;AACvC,QAAA,MAAM,cAAc,EAAG,SAAkB,CAAA;AAEzC,KAAK,WAAW,GAAG,OAAO,aAAa,GAAG,OAAO,cAAc,CAAA;AAE/D,UAAU,mBAAmB;IAC3B,MAAM,EAAE,gBAAgB,CAAA;IACxB,MAAM,EAAE,MAA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AC,OAAO,CAAC;IA0H/E,aAAa,GAAI,MAAM,OAAO,EAAE,QAAQ,WAAW,KAAG,OAAO,CA2C5D;CACF"}
@@ -0,0 +1,384 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { createWriteStream, mkdirSync } from 'node:fs';
3
+ import { join as joinPath } from 'node:path';
4
+ import { pipeline } from 'node:stream/promises';
5
+ import PQueue from 'p-queue';
6
+ import { delay } from './util/delay.js';
7
+ import { through, throughObj } from './util/streamHelpers.js';
8
+ import { ASSET_DOWNLOAD_CONCURRENCY, ASSET_DOWNLOAD_MAX_RETRIES, DEFAULT_RETRY_DELAY, } from './constants.js';
9
+ import { debug } from './debug.js';
10
+ import { getUserAgent } from './getUserAgent.js';
11
+ import { requestStream } from './requestStream.js';
12
+ import { rm } from 'node:fs/promises';
13
+ const EXCLUDE_PROPS = ['_id', '_type', 'assetId', 'extension', 'mimeType', 'path', 'url'];
14
+ const ACTION_REMOVE = 'remove';
15
+ const ACTION_REWRITE = 'rewrite';
16
+ export class AssetHandler {
17
+ client;
18
+ tmpDir;
19
+ assetDirsCreated;
20
+ downloading;
21
+ assetsSeen;
22
+ assetMap;
23
+ filesWritten;
24
+ queueSize;
25
+ maxRetries;
26
+ retryDelayMs;
27
+ queue;
28
+ rejectedError;
29
+ reject;
30
+ constructor(options) {
31
+ const concurrency = options.concurrency ?? ASSET_DOWNLOAD_CONCURRENCY;
32
+ debug('Using asset download concurrency of %d', concurrency);
33
+ this.client = options.client;
34
+ this.tmpDir = options.tmpDir;
35
+ this.assetDirsCreated = false;
36
+ this.downloading = [];
37
+ this.assetsSeen = new Map();
38
+ this.assetMap = {};
39
+ this.filesWritten = 0;
40
+ this.queueSize = 0;
41
+ this.maxRetries = options.maxRetries ?? ASSET_DOWNLOAD_MAX_RETRIES;
42
+ this.retryDelayMs = options.retryDelayMs;
43
+ this.queue = options.queue ?? new PQueue({ concurrency });
44
+ this.rejectedError = null;
45
+ this.reject = (err) => {
46
+ this.rejectedError = err;
47
+ };
48
+ }
49
+ clear() {
50
+ this.assetsSeen.clear();
51
+ this.queue.clear();
52
+ this.queueSize = 0;
53
+ }
54
+ finish() {
55
+ return new Promise((resolve, reject) => {
56
+ if (this.rejectedError) {
57
+ reject(this.rejectedError);
58
+ return;
59
+ }
60
+ this.reject = reject;
61
+ void this.queue.onIdle().then(() => resolve(this.assetMap));
62
+ });
63
+ }
64
+ // Called when we want to download all assets to local filesystem and rewrite documents to hold
65
+ // placeholder asset references (_sanityAsset: 'image@file:///local/path')
66
+ rewriteAssets = throughObj((doc, _enc, callback) => {
67
+ if (['sanity.imageAsset', 'sanity.fileAsset'].includes(doc._type)) {
68
+ const assetDoc = doc;
69
+ const type = doc._type === 'sanity.imageAsset' ? 'image' : 'file';
70
+ const filePath = `${type}s/${generateFilename(doc._id)}`;
71
+ this.assetsSeen.set(doc._id, type);
72
+ this.queueAssetDownload(assetDoc, filePath);
73
+ callback();
74
+ return;
75
+ }
76
+ callback(null, this.findAndModify(doc, ACTION_REWRITE));
77
+ });
78
+ // Called in the case where we don't _want_ assets, so basically just remove all asset documents
79
+ // as well as references to assets (*.asset._ref ^= (image|file)-)
80
+ stripAssets = throughObj((doc, _enc, callback) => {
81
+ if (['sanity.imageAsset', 'sanity.fileAsset'].includes(doc._type)) {
82
+ callback();
83
+ return;
84
+ }
85
+ callback(null, this.findAndModify(doc, ACTION_REMOVE));
86
+ });
87
+ // Called when we are using raw export mode along with `assets: false`, where we simply
88
+ // want to skip asset documents but retain asset references (useful for data mangling)
89
+ skipAssets = throughObj((doc, _enc, callback) => {
90
+ const isAsset = ['sanity.imageAsset', 'sanity.fileAsset'].includes(doc._type);
91
+ if (isAsset) {
92
+ callback();
93
+ return;
94
+ }
95
+ callback(null, doc);
96
+ });
97
+ noop = throughObj((doc, _enc, callback) => callback(null, doc));
98
+ queueAssetDownload(assetDoc, dstPath) {
99
+ if (!assetDoc.url) {
100
+ debug('Asset document "%s" does not have a URL property, skipping', assetDoc._id);
101
+ return;
102
+ }
103
+ debug('Adding download task for %s (destination: %s)', assetDoc._id, dstPath);
104
+ this.queueSize++;
105
+ this.downloading.push(assetDoc.url);
106
+ const doDownload = async () => {
107
+ let dlError;
108
+ for (let attempt = 0; attempt < this.maxRetries; attempt++) {
109
+ try {
110
+ return await this.downloadAsset(assetDoc, dstPath);
111
+ }
112
+ catch (err) {
113
+ const downloadError = err;
114
+ // Ignore inaccessible assets
115
+ switch (downloadError.statusCode) {
116
+ case 401:
117
+ case 403:
118
+ case 404:
119
+ console.warn(`⚠ Asset failed with HTTP %d (ignoring): %s`, downloadError.statusCode, assetDoc._id);
120
+ return true;
121
+ default:
122
+ }
123
+ debug(`Error downloading asset %s (destination: %s), attempt %d`, assetDoc._id, dstPath, attempt, err);
124
+ dlError = downloadError;
125
+ if (downloadError.statusCode &&
126
+ downloadError.statusCode >= 400 &&
127
+ downloadError.statusCode < 500) {
128
+ // Don't retry on client errors
129
+ break;
130
+ }
131
+ await delay(this.retryDelayMs ?? DEFAULT_RETRY_DELAY);
132
+ }
133
+ }
134
+ throw new Error(dlError?.message ?? 'Unknown error downloading asset');
135
+ };
136
+ this.queue
137
+ .add(() => doDownload().catch((err) => {
138
+ debug('Failed to download the asset, aborting download', err);
139
+ this.queue.clear();
140
+ this.reject(err instanceof Error ? err : new Error(String(err)));
141
+ }))
142
+ .catch((error) => {
143
+ debug('Queued task failed', error);
144
+ });
145
+ }
146
+ maybeCreateAssetDirs() {
147
+ if (this.assetDirsCreated) {
148
+ return;
149
+ }
150
+ mkdirSync(joinPath(this.tmpDir, 'files'), { recursive: true });
151
+ mkdirSync(joinPath(this.tmpDir, 'images'), { recursive: true });
152
+ this.assetDirsCreated = true;
153
+ }
154
+ getAssetRequestOptions(assetDoc) {
155
+ const token = this.client.config().token;
156
+ const headers = { 'User-Agent': getUserAgent() };
157
+ const isImage = assetDoc._type === 'sanity.imageAsset';
158
+ const url = URL.parse(assetDoc.url ?? '');
159
+ // If we can't parse it, return as-is
160
+ if (!url) {
161
+ return { url: assetDoc.url ?? '', headers };
162
+ }
163
+ if (isImage &&
164
+ token &&
165
+ (url.hostname === 'cdn.sanity.io' ||
166
+ url.hostname === 'cdn.sanity.work' ||
167
+ // used in tests. use a very specific port to avoid conflicts
168
+ url.host === 'localhost:43216')) {
169
+ headers.Authorization = `Bearer ${token}`;
170
+ url.searchParams.set('dlRaw', 'true');
171
+ }
172
+ return { url: url.toString(), headers };
173
+ }
174
+ async downloadAsset(assetDoc, dstPath) {
175
+ const { url } = assetDoc;
176
+ debug('Downloading asset %s', url);
177
+ const options = this.getAssetRequestOptions(assetDoc);
178
+ let stream;
179
+ try {
180
+ stream = await requestStream({
181
+ maxRetries: 0, // We handle retries ourselves in queueAssetDownload
182
+ ...options,
183
+ });
184
+ }
185
+ catch (err) {
186
+ const message = 'Failed to create asset stream';
187
+ if (err instanceof Error) {
188
+ err.message = `${message}: ${err.message}`;
189
+ throw err;
190
+ }
191
+ throw new Error('Failed create asset stream', { cause: err });
192
+ }
193
+ if (stream.statusCode !== 200) {
194
+ let errMsg;
195
+ try {
196
+ const err = await tryGetErrorFromStream(stream);
197
+ errMsg = `Referenced asset URL "${url}" returned HTTP ${stream.statusCode}`;
198
+ if (err) {
199
+ errMsg = `${errMsg}: ${err}`;
200
+ }
201
+ }
202
+ catch (err) {
203
+ const message = 'Failed to parse error response from asset stream';
204
+ if (err instanceof Error) {
205
+ err.message = `${message}: ${err.message}`;
206
+ throw err;
207
+ }
208
+ throw new Error(message, { cause: err });
209
+ }
210
+ const streamError = new Error(errMsg);
211
+ if (stream.statusCode !== undefined) {
212
+ streamError.statusCode = stream.statusCode;
213
+ }
214
+ throw streamError;
215
+ }
216
+ this.maybeCreateAssetDirs();
217
+ debug('Asset stream ready, writing to filesystem at %s', dstPath);
218
+ const tmpPath = joinPath(this.tmpDir, dstPath);
219
+ let sha1 = '';
220
+ let md5 = '';
221
+ let size = 0;
222
+ try {
223
+ const res = await writeHashedStream(tmpPath, stream);
224
+ sha1 = res.sha1;
225
+ md5 = res.md5;
226
+ size = res.size;
227
+ }
228
+ catch (err) {
229
+ const message = 'Failed to write asset stream to filesystem';
230
+ if (err instanceof Error) {
231
+ err.message = `${message}: ${err.message}`;
232
+ throw err;
233
+ }
234
+ throw new Error(message, { cause: err });
235
+ }
236
+ // Verify it against our downloaded stream to make sure we have the same copy
237
+ const contentLength = stream.headers?.['content-length'];
238
+ const remoteSha1 = stream.headers?.['x-sanity-sha1'];
239
+ const remoteMd5 = stream.headers?.['x-sanity-md5'];
240
+ const hasHash = Boolean(remoteSha1 || remoteMd5);
241
+ const method = sha1 ? 'sha1' : 'md5';
242
+ // Asset validity is primarily determined by the sha1 hash. However, the sha1 hash is computed
243
+ // before certain processes (i.e. svg sanitization) which can result in a different hash.
244
+ // When the sha1 hashes don't match, fallback to using the md5 hash.
245
+ const sha1Differs = remoteSha1 && sha1 !== remoteSha1;
246
+ const md5Differs = remoteMd5 && md5 !== remoteMd5;
247
+ const differs = sha1Differs && md5Differs;
248
+ if (differs) {
249
+ const details = [
250
+ hasHash &&
251
+ (method === 'md5'
252
+ ? `md5 should be ${remoteMd5}, got ${md5}`
253
+ : `sha1 should be ${remoteSha1}, got ${sha1}`),
254
+ contentLength &&
255
+ parseInt(String(contentLength), 10) !== size &&
256
+ `Asset should be ${contentLength} bytes, got ${size}`,
257
+ ];
258
+ const detailsString = `Details:\n - ${details.filter(Boolean).join('\n - ')}`;
259
+ await rm(tmpPath, { recursive: true, force: true });
260
+ throw new Error(`Failed to download asset at ${assetDoc.url}. ${detailsString}`);
261
+ }
262
+ const isImage = assetDoc._type === 'sanity.imageAsset';
263
+ const type = isImage ? 'image' : 'file';
264
+ const id = `${type}-${sha1}`;
265
+ const metaProps = omit(assetDoc, EXCLUDE_PROPS);
266
+ if (Object.keys(metaProps).length > 0) {
267
+ this.assetMap[id] = metaProps;
268
+ }
269
+ this.downloading.splice(this.downloading.findIndex((datUrl) => datUrl === url), 1);
270
+ this.filesWritten++;
271
+ return true;
272
+ }
273
+ findAndModify = (item, action) => {
274
+ if (Array.isArray(item)) {
275
+ const children = item.map((child) => this.findAndModify(child, action));
276
+ return children.filter((child) => child != null);
277
+ }
278
+ if (!item || typeof item !== 'object') {
279
+ return item;
280
+ }
281
+ const record = item;
282
+ const isAsset = isAssetField(record);
283
+ if (isAsset && action === ACTION_REMOVE) {
284
+ return undefined;
285
+ }
286
+ if (isAsset && action === ACTION_REWRITE) {
287
+ const { asset, ...other } = record;
288
+ const assetId = asset._ref;
289
+ const assetType = getAssetType(record);
290
+ const filePath = `${assetType}s/${generateFilename(assetId)}`;
291
+ const modified = this.findAndModify(other, action);
292
+ return {
293
+ _sanityAsset: `${assetType}@file://./${filePath}`,
294
+ ...(typeof modified === 'object' && modified !== null ? modified : {}),
295
+ };
296
+ }
297
+ const newItem = {};
298
+ const keys = Object.keys(record);
299
+ for (const key of keys) {
300
+ const value = record[key];
301
+ newItem[key] = this.findAndModify(value, action);
302
+ if (typeof newItem[key] === 'undefined') {
303
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
304
+ delete newItem[key];
305
+ }
306
+ }
307
+ return newItem;
308
+ };
309
+ }
310
+ function isAssetField(item) {
311
+ const asset = item.asset;
312
+ return Boolean(asset?._ref && typeof asset._ref === 'string' && isSanityAsset(asset._ref));
313
+ }
314
+ function getAssetType(item) {
315
+ const asset = item.asset;
316
+ if (!asset || typeof asset._ref !== 'string') {
317
+ return null;
318
+ }
319
+ const match = asset._ref.match(/^(image|file)-/);
320
+ return match?.[1] ?? null;
321
+ }
322
+ function isSanityAsset(assetId) {
323
+ return (/^image-[a-f0-9]{40}-\d+x\d+-[a-z]+$/.test(assetId) ||
324
+ /^file-[a-f0-9]{40}-[a-z0-9]+$/.test(assetId));
325
+ }
326
+ function generateFilename(assetId) {
327
+ const match = assetId.match(/^(image|file)-(.*?)(-[a-z]+)?$/);
328
+ const asset = match?.[2];
329
+ const ext = match?.[3];
330
+ const extension = (ext ?? 'bin').replace(/^-/, '');
331
+ return asset ? `${asset}.${extension}` : `${assetId}.bin`;
332
+ }
333
+ async function writeHashedStream(filePath, stream) {
334
+ let size = 0;
335
+ const md5 = createHash('md5');
336
+ const sha1 = createHash('sha1');
337
+ const hasher = through((chunk, _enc, cb) => {
338
+ size += chunk.length;
339
+ md5.update(chunk);
340
+ sha1.update(chunk);
341
+ cb(null, chunk);
342
+ });
343
+ await pipeline(stream, hasher, createWriteStream(filePath));
344
+ return {
345
+ size,
346
+ sha1: sha1.digest('hex'),
347
+ md5: md5.digest('hex'),
348
+ };
349
+ }
350
+ function tryGetErrorFromStream(stream) {
351
+ return new Promise((resolve, reject) => {
352
+ const chunks = [];
353
+ let receivedData = false;
354
+ stream.on('data', (chunk) => {
355
+ receivedData = true;
356
+ chunks.push(chunk);
357
+ });
358
+ stream.on('end', () => {
359
+ if (!receivedData) {
360
+ resolve(null);
361
+ return;
362
+ }
363
+ const body = Buffer.concat(chunks);
364
+ try {
365
+ const parsed = JSON.parse(body.toString('utf8'));
366
+ resolve(parsed.message ?? parsed.error ?? null);
367
+ }
368
+ catch {
369
+ resolve(body.toString('utf8').slice(0, 16000));
370
+ }
371
+ });
372
+ stream.on('error', reject);
373
+ });
374
+ }
375
+ function omit(obj, keys) {
376
+ const copy = {};
377
+ for (const [key, value] of Object.entries(obj)) {
378
+ if (!keys.includes(key)) {
379
+ copy[key] = value;
380
+ }
381
+ }
382
+ return copy;
383
+ }
384
+ //# sourceMappingURL=AssetHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssetHandler.js","sourceRoot":"","sources":["../src/AssetHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAA;AACtC,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAC,MAAM,SAAS,CAAA;AACpD,OAAO,EAAC,IAAI,IAAI,QAAQ,EAAC,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAA;AAE7C,OAAO,MAAM,MA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D,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;YAChD,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,GAA4B,EAAE,IAAc;IACxD,MAAM,IAAI,GAAkB,EAAE,CAAA;IAC9B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACnB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * How many retries to attempt when retrieving the document stream.
3
+ * User overridable as `options.maxRetries`.
4
+ *
5
+ * Note: Only for initial connection - if download fails while streaming, we cannot easily resume.
6
+ * @internal
7
+ */
8
+ export declare const DOCUMENT_STREAM_MAX_RETRIES: number;
9
+ /**
10
+ * How many retries to attempt when downloading an asset.
11
+ * User overridable as `options.maxAssetRetries`.
12
+ * @internal
13
+ */
14
+ export declare const ASSET_DOWNLOAD_MAX_RETRIES: number;
15
+ /**
16
+ * Default delay between retries when retrieving assets or document stream.
17
+ * User overridable as `options.retryDelayMs`.
18
+ * @internal
19
+ */
20
+ export declare const DEFAULT_RETRY_DELAY: number;
21
+ /**
22
+ * How many concurrent asset downloads to allow.
23
+ * User overridable as `options.assetConcurrency`.
24
+ * @internal
25
+ */
26
+ export declare const ASSET_DOWNLOAD_CONCURRENCY: number;
27
+ /**
28
+ * How frequently we will `debug` log while streaming the documents.
29
+ * @internal
30
+ */
31
+ export declare const DOCUMENT_STREAM_DEBUG_INTERVAL: number;
32
+ /**
33
+ * How long to wait before timing out the read of a request due to inactivity.
34
+ * User overridable as `options.readTimeout`.
35
+ * @internal
36
+ */
37
+ export declare const REQUEST_READ_TIMEOUT: number;
38
+ /**
39
+ * What mode to use when exporting documents.
40
+ * stream: Export all documents in the dataset in one request, this will be consistent but might be slow on large datasets.
41
+ * cursor: Export documents using a cursor, this might lead to inconsistent results if a mutation is performed while exporting.
42
+ */
43
+ export declare const MODE_STREAM: "stream";
44
+ export declare const MODE_CURSOR: "cursor";
45
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAU,CAAA;AAEpD;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAW,CAAA;AAEpD;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAa,CAAA;AAE/C;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAU,CAAA;AAEnD;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAc,CAAA;AAE3D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAsB,CAAA;AAEzD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAG,QAAiB,CAAA;AAC5C,eAAO,MAAM,WAAW,EAAG,QAAiB,CAAA"}
@@ -5,46 +5,41 @@
5
5
  * Note: Only for initial connection - if download fails while streaming, we cannot easily resume.
6
6
  * @internal
7
7
  */
8
- export const DOCUMENT_STREAM_MAX_RETRIES = 5
9
-
8
+ export const DOCUMENT_STREAM_MAX_RETRIES = 5;
10
9
  /**
11
10
  * How many retries to attempt when downloading an asset.
12
11
  * User overridable as `options.maxAssetRetries`.
13
12
  * @internal
14
13
  */
15
- export const ASSET_DOWNLOAD_MAX_RETRIES = 10
16
-
14
+ export const ASSET_DOWNLOAD_MAX_RETRIES = 10;
17
15
  /**
18
16
  * Default delay between retries when retrieving assets or document stream.
19
17
  * User overridable as `options.retryDelayMs`.
20
18
  * @internal
21
19
  */
22
- export const DEFAULT_RETRY_DELAY = 1500
23
-
20
+ export const DEFAULT_RETRY_DELAY = 1500;
24
21
  /**
25
22
  * How many concurrent asset downloads to allow.
26
23
  * User overridable as `options.assetConcurrency`.
27
24
  * @internal
28
25
  */
29
- export const ASSET_DOWNLOAD_CONCURRENCY = 8
30
-
26
+ export const ASSET_DOWNLOAD_CONCURRENCY = 8;
31
27
  /**
32
28
  * How frequently we will `debug` log while streaming the documents.
33
29
  * @internal
34
30
  */
35
- export const DOCUMENT_STREAM_DEBUG_INTERVAL = 10000
36
-
31
+ export const DOCUMENT_STREAM_DEBUG_INTERVAL = 10000;
37
32
  /**
38
33
  * How long to wait before timing out the read of a request due to inactivity.
39
34
  * User overridable as `options.readTimeout`.
40
35
  * @internal
41
36
  */
42
- export const REQUEST_READ_TIMEOUT = 3 * 60 * 1000 // 3 minutes
43
-
37
+ export const REQUEST_READ_TIMEOUT = 3 * 60 * 1000; // 3 minutes
44
38
  /**
45
- What mode to use when exporting documents.
46
- stream: Export all documents in the dataset in one request, this will be consistent but might be slow on large datasets.
47
- cursor: Export documents using a cursor, this might lead to inconsistent results if a mutation is performed while exporting.
48
- */
49
- export const MODE_STREAM = 'stream'
50
- export const MODE_CURSOR = 'cursor'
39
+ * What mode to use when exporting documents.
40
+ * stream: Export all documents in the dataset in one request, this will be consistent but might be slow on large datasets.
41
+ * cursor: Export documents using a cursor, this might lead to inconsistent results if a mutation is performed while exporting.
42
+ */
43
+ export const MODE_STREAM = 'stream';
44
+ export const MODE_CURSOR = 'cursor';
45
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAW,CAAC,CAAA;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAW,EAAE,CAAA;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAW,IAAI,CAAA;AAE/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAW,CAAC,CAAA;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAW,KAAK,CAAA;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,YAAY;AAEtE;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,QAAiB,CAAA;AAC5C,MAAM,CAAC,MAAM,WAAW,GAAG,QAAiB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { type Debugger } from 'debug';
2
+ export declare const debug: Debugger;
3
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,OAAoB,EAAC,KAAK,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEhD,eAAO,MAAM,KAAK,EAAE,QAAuC,CAAA"}
package/dist/debug.js ADDED
@@ -0,0 +1,3 @@
1
+ import createDebug, {} from 'debug';
2
+ export const debug = createDebug('sanity:export');
3
+ //# sourceMappingURL=debug.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.js","sourceRoot":"","sources":["../src/debug.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,EAAE,EAAe,MAAM,OAAO,CAAA;AAEhD,MAAM,CAAC,MAAM,KAAK,GAAa,WAAW,CAAC,eAAe,CAAC,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { type Writable } from 'node:stream';
2
+ import type { ExportOptions, ExportResult } from './types.js';
3
+ /**
4
+ * Export the dataset with the given options.
5
+ *
6
+ * @param opts - Export options
7
+ * @returns The export result
8
+ * @public
9
+ */
10
+ export declare function exportDataset(opts: ExportOptions & {
11
+ outputPath: Writable;
12
+ }): Promise<ExportResult<Writable>>;
13
+ export declare function exportDataset(opts: ExportOptions & {
14
+ outputPath: string;
15
+ }): Promise<ExportResult<string>>;
16
+ export declare function exportDataset(opts: ExportOptions): Promise<ExportResult>;
17
+ type MediaLibraryExportOptions = Omit<ExportOptions, 'dataset' | 'mediaLibraryId'> & {
18
+ mediaLibraryId: string;
19
+ };
20
+ /**
21
+ * Export the media library with the given `mediaLibraryId`.
22
+ *
23
+ * @param options - Export options
24
+ * @returns The export result
25
+ * @public
26
+ */
27
+ export declare function exportMediaLibrary(options: MediaLibraryExportOptions & {
28
+ outputPath: Writable;
29
+ }): Promise<ExportResult<Writable>>;
30
+ export declare function exportMediaLibrary(options: MediaLibraryExportOptions & {
31
+ outputPath: string;
32
+ }): Promise<ExportResult<string>>;
33
+ export declare function exportMediaLibrary(options: MediaLibraryExportOptions): Promise<ExportResult>;
34
+ /**
35
+ * Alias for `exportDataset`, for backwards compatibility.
36
+ * Use named `exportDataset` instead.
37
+ *
38
+ * @deprecated Default export is deprecated and will be removed in a future release. Use named "exportDataset" function instead.
39
+ * @public
40
+ */
41
+ declare const _default: (opts: ExportOptions) => Promise<ExportResult>;
42
+ export default _default;
43
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../src/export.ts"],"names":[],"mappings":"AAIA,OAAO,EAAc,KAAK,QAAQ,EAAC,MAAM,aAAa,CAAA;AAoBtD,OAAO,KAAK,EACV,aAAa,EAEb,YAAY,EAGb,MAAM,YAAY,CAAA;AAKnB;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,aAAa,GAAG;IAAC,UAAU,EAAE,QAAQ,CAAA;CAAC,GAC3C,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;AAClC,wBAAsB,aAAa,CACjC,IAAI,EAAE,aAAa,GAAG;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,GACzC,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;AAChC,wBAAsB,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAiS/E,KAAK,yBAAyB,GAAG,IAAI,CAAC,aAAa,EAAE,SAAS,GAAG,gBAAgB,CAAC,GAAG;IACnF,cAAc,EAAE,MAAM,CAAA;CACvB,CAAA;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GAAG;IAAC,UAAU,EAAE,QAAQ,CAAA;CAAC,GAC1D,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAA;AAClC,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GAAG;IAAC,UAAU,EAAE,MAAM,CAAA;CAAC,GACxD,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;AAChC,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAOnG;;;;;;GAMG;+BAE+B,aAAa,KAAG,OAAO,CAAC,YAAY,CAAC;AADvE,wBAMC"}