@strapi/data-transfer 4.26.0 → 4.26.2

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/dist/index.mjs CHANGED
@@ -2,22 +2,22 @@ import { Transform, PassThrough, Writable, Readable, Duplex, pipeline } from "st
2
2
  import path, { extname, join, posix } from "path";
3
3
  import { EOL } from "os";
4
4
  import { chain } from "stream-chain";
5
- import { isArray, zip, isObject, uniq, isEqual, mapValues, pick, reject as reject$1, capitalize, isNumber, isEmpty, last, difference, set, omit, get, has, pipe, assign, map as map$1, size, isNil, clone, once, castArray, keyBy, isString, isNaN, merge, isFinite, toNumber } from "lodash/fp";
5
+ import { isArray, zip, isObject, uniq, isEqual, mapValues, pick, reject as reject$1, capitalize, isNumber, isEmpty, last, difference, set, omit, get, has, pipe, assign, size, map as map$1, isNil, clone, once, castArray, keyBy, isString, isNaN, merge, isFinite, toNumber } from "lodash/fp";
6
6
  import { diff as diff$1 } from "semver";
7
7
  import { scryptSync, createCipheriv, createDecipheriv, randomUUID } from "crypto";
8
8
  import { EventEmitter } from "events";
9
9
  import * as fse from "fs-extra";
10
- import fse__default, { createReadStream, stat, createWriteStream, rm } from "fs-extra";
10
+ import fse__default, { stat, createReadStream, createWriteStream, rm } from "fs-extra";
11
11
  import _ from "lodash";
12
- import { contentTypes, mapAsync } from "@strapi/utils";
12
+ import { mapAsync, contentTypes } from "@strapi/utils";
13
13
  import chalk from "chalk";
14
14
  import https from "https";
15
15
  import http from "http";
16
16
  import { WebSocket } from "ws";
17
17
  import zip$1 from "zlib";
18
- import tar from "tar";
18
+ import { Parser } from "tar";
19
19
  import { parser } from "stream-json/jsonl/Parser";
20
- import tar$1 from "tar-stream";
20
+ import tar from "tar-stream";
21
21
  import { stringer } from "stream-json/jsonl/Stringer";
22
22
  import { Option, InvalidOptionArgumentError } from "commander";
23
23
  import Table from "cli-table3";
@@ -347,7 +347,6 @@ const compareSchemas = (a, b, strategy) => {
347
347
  };
348
348
  const SeverityKind = {
349
349
  FATAL: "fatal",
350
- ERROR: "error",
351
350
  SILLY: "silly"
352
351
  };
353
352
  class DataTransferError extends Error {
@@ -2601,11 +2600,7 @@ const connectToWebsocket = (address, options, diagnostics) => {
2601
2600
  });
2602
2601
  server.on("message", (raw) => {
2603
2602
  const response = JSON.parse(raw.toString());
2604
- if (response.diagnostic) {
2605
- diagnostics?.report({
2606
- ...response.diagnostic
2607
- });
2608
- }
2603
+ if (response.diagnostic) ;
2609
2604
  });
2610
2605
  server.once("error", (err) => {
2611
2606
  reject2(
@@ -4287,15 +4282,15 @@ class LocalFileSourceProvider {
4287
4282
  pipeline(
4288
4283
  [
4289
4284
  inStream,
4290
- new tar.Parse({
4285
+ new Parser({
4291
4286
  // find only files in the assets/uploads folder
4292
4287
  filter(filePath, entry) {
4293
- if (entry.type !== "File") {
4288
+ if (!("type" in entry) || entry.type !== "File") {
4294
4289
  return false;
4295
4290
  }
4296
4291
  return isFilePathInDirname("assets/uploads", filePath);
4297
4292
  },
4298
- async onentry(entry) {
4293
+ async onReadEntry(entry) {
4299
4294
  const { path: filePath, size: size2 = 0 } = entry;
4300
4295
  const normalizedPath = unknownPathToPosix(filePath);
4301
4296
  const file2 = path.basename(normalizedPath);
@@ -4345,14 +4340,14 @@ class LocalFileSourceProvider {
4345
4340
  pipeline(
4346
4341
  [
4347
4342
  inStream,
4348
- new tar.Parse({
4343
+ new Parser({
4349
4344
  filter(filePath, entry) {
4350
- if (entry.type !== "File") {
4345
+ if (!("type" in entry) || entry.type !== "File") {
4351
4346
  return false;
4352
4347
  }
4353
4348
  return isFilePathInDirname(directory, filePath);
4354
4349
  },
4355
- async onentry(entry) {
4350
+ async onReadEntry(entry) {
4356
4351
  const transforms = [
4357
4352
  // JSONL parser to read the data chunks one by one (line by line)
4358
4353
  parser({
@@ -4394,17 +4389,17 @@ class LocalFileSourceProvider {
4394
4389
  [
4395
4390
  fileStream,
4396
4391
  // Custom backup archive parsing
4397
- new tar.Parse({
4392
+ new Parser({
4398
4393
  /**
4399
4394
  * Filter the parsed entries to only keep the one that matches the given filepath
4400
4395
  */
4401
4396
  filter(entryPath, entry) {
4402
- if (entry.type !== "File") {
4397
+ if (!("type" in entry) || entry.type !== "File") {
4403
4398
  return false;
4404
4399
  }
4405
4400
  return isPathEquivalent(entryPath, filePath);
4406
4401
  },
4407
- async onentry(entry) {
4402
+ async onReadEntry(entry) {
4408
4403
  const content = await entry.collect();
4409
4404
  try {
4410
4405
  const parsedContent = JSON.parse(Buffer.concat(content).toString());
@@ -4523,7 +4518,7 @@ class LocalFileDestinationProvider {
4523
4518
  if (encryption.enabled && !encryption.key) {
4524
4519
  throw new Error("Can't encrypt without a key");
4525
4520
  }
4526
- this.#archive.stream = tar$1.pack();
4521
+ this.#archive.stream = tar.pack();
4527
4522
  const outStream = createWriteStream(this.#archivePath);
4528
4523
  outStream.on("error", (err) => {
4529
4524
  if (err.code === "ENOSPC") {
@@ -4791,8 +4786,7 @@ const promptEncryptionKey = async (thisCommand) => {
4791
4786
  message: "Please enter an encryption key",
4792
4787
  name: "key",
4793
4788
  validate(key) {
4794
- if (key.length > 0)
4795
- return true;
4789
+ if (key.length > 0) return true;
4796
4790
  return "Key must be present when using the encrypt option";
4797
4791
  }
4798
4792
  }