@strapi/data-transfer 4.14.5 → 4.15.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/dist/index.mjs CHANGED
@@ -214,13 +214,13 @@ const createTransaction = (strapi2) => {
214
214
  const e = new EventEmitter();
215
215
  e.on("spawn", (uuid, cb) => {
216
216
  fns.push({ fn: cb, uuid });
217
- resume == null ? void 0 : resume();
217
+ resume?.();
218
218
  });
219
219
  e.on("close", () => {
220
220
  e.removeAllListeners("rollback");
221
221
  e.removeAllListeners("spawn");
222
222
  done = true;
223
- resume == null ? void 0 : resume();
223
+ resume?.();
224
224
  });
225
225
  strapi2.db.transaction(async ({ trx, rollback }) => {
226
226
  e.once("rollback", async () => {
@@ -233,7 +233,7 @@ const createTransaction = (strapi2) => {
233
233
  e.emit("rollback_failed");
234
234
  } finally {
235
235
  done = true;
236
- resume == null ? void 0 : resume();
236
+ resume?.();
237
237
  }
238
238
  });
239
239
  while (!done) {
@@ -318,13 +318,12 @@ const isAttributeIgnorable = (diff2) => {
318
318
  ["private", "required", "configurable"].includes(diff2.path[2]);
319
319
  };
320
320
  const isOptionalAdminType = (diff2) => {
321
- var _a, _b, _c, _d;
322
321
  if ("value" in diff2 && isObject(diff2.value)) {
323
- const name = (_b = (_a = diff2 == null ? void 0 : diff2.value) == null ? void 0 : _a.info) == null ? void 0 : _b.singularName;
322
+ const name = diff2?.value?.info?.singularName;
324
323
  return OPTIONAL_CONTENT_TYPES.includes(name);
325
324
  }
326
325
  if ("values" in diff2 && isArray(diff2.values) && isObject(diff2.values[0])) {
327
- const name = (_d = (_c = diff2 == null ? void 0 : diff2.values[0]) == null ? void 0 : _c.info) == null ? void 0 : _d.singularName;
326
+ const name = diff2?.values[0]?.info?.singularName;
328
327
  return OPTIONAL_CONTENT_TYPES.includes(name);
329
328
  }
330
329
  return false;
@@ -513,21 +512,18 @@ class TransferEngine {
513
512
  errors: {}
514
513
  };
515
514
  onSchemaDiff(handler) {
516
- var _a, _b;
517
- (_b = (_a = this.#handlers) == null ? void 0 : _a.schemaDiff) == null ? void 0 : _b.push(handler);
515
+ this.#handlers?.schemaDiff?.push(handler);
518
516
  }
519
517
  addErrorHandler(handlerName, handler) {
520
- var _a;
521
518
  if (!this.#handlers.errors[handlerName]) {
522
519
  this.#handlers.errors[handlerName] = [];
523
520
  }
524
- (_a = this.#handlers.errors[handlerName]) == null ? void 0 : _a.push(handler);
521
+ this.#handlers.errors[handlerName]?.push(handler);
525
522
  }
526
523
  async attemptResolveError(error) {
527
- var _a, _b;
528
524
  const context = {};
529
- if (error instanceof ProviderTransferError && ((_a = error.details) == null ? void 0 : _a.details.code)) {
530
- const errorCode = (_b = error.details) == null ? void 0 : _b.details.code;
525
+ if (error instanceof ProviderTransferError && error.details?.details.code) {
526
+ const errorCode = error.details?.details.code;
531
527
  if (!this.#handlers.errors[errorCode]) {
532
528
  this.#handlers.errors[errorCode] = [];
533
529
  }
@@ -592,10 +588,9 @@ class TransferEngine {
592
588
  * Allowed transformations includes 'filter' and 'map'.
593
589
  */
594
590
  #createStageTransformStream(key, options = {}) {
595
- var _a;
596
591
  const { includeGlobal = true } = options;
597
592
  const { throttle } = this.options;
598
- const { global: globalTransforms, [key]: stageTransforms } = ((_a = this.options) == null ? void 0 : _a.transforms) ?? {};
593
+ const { global: globalTransforms, [key]: stageTransforms } = this.options?.transforms ?? {};
599
594
  let stream2 = new PassThrough({ objectMode: true });
600
595
  const applyTransforms = (transforms = []) => {
601
596
  const chainTransforms = [];
@@ -636,7 +631,6 @@ class TransferEngine {
636
631
  * Providing aggregate options enable custom computation to get the size (bytes) or the aggregate key associated with the data
637
632
  */
638
633
  #updateTransferProgress(stage, data, aggregate) {
639
- var _a, _b;
640
634
  if (!this.progress.data[stage]) {
641
635
  this.progress.data[stage] = { count: 0, bytes: 0, startTime: Date.now() };
642
636
  }
@@ -644,8 +638,8 @@ class TransferEngine {
644
638
  if (!stageProgress) {
645
639
  return;
646
640
  }
647
- const size2 = ((_a = aggregate == null ? void 0 : aggregate.size) == null ? void 0 : _a.call(aggregate, data)) ?? JSON.stringify(data).length;
648
- const key = (_b = aggregate == null ? void 0 : aggregate.key) == null ? void 0 : _b.call(aggregate, data);
641
+ const size2 = aggregate?.size?.(data) ?? JSON.stringify(data).length;
642
+ const key = aggregate?.key?.(data);
649
643
  stageProgress.count += 1;
650
644
  stageProgress.bytes += size2;
651
645
  if (key) {
@@ -866,21 +860,19 @@ ${formattedDiffs}`,
866
860
  this.#currentStream.destroy(err);
867
861
  }
868
862
  async init() {
869
- var _a, _b;
870
863
  await this.#resolveProviderResource();
871
864
  const { source: sourceMetadata } = this.#metadata;
872
865
  if (sourceMetadata) {
873
- (_b = (_a = this.destinationProvider).setMetadata) == null ? void 0 : _b.call(_a, "source", sourceMetadata);
866
+ this.destinationProvider.setMetadata?.("source", sourceMetadata);
874
867
  }
875
868
  }
876
869
  /**
877
870
  * Run the bootstrap method in both source and destination providers
878
871
  */
879
872
  async bootstrap() {
880
- var _a, _b, _c, _d;
881
873
  const results = await Promise.allSettled([
882
- (_b = (_a = this.sourceProvider).bootstrap) == null ? void 0 : _b.call(_a),
883
- (_d = (_c = this.destinationProvider).bootstrap) == null ? void 0 : _d.call(_c)
874
+ this.sourceProvider.bootstrap?.(),
875
+ this.destinationProvider.bootstrap?.()
884
876
  ]);
885
877
  results.forEach((result) => {
886
878
  if (result.status === "rejected") {
@@ -892,10 +884,9 @@ ${formattedDiffs}`,
892
884
  * Run the close method in both source and destination providers
893
885
  */
894
886
  async close() {
895
- var _a, _b, _c, _d;
896
887
  const results = await Promise.allSettled([
897
- (_b = (_a = this.sourceProvider).close) == null ? void 0 : _b.call(_a),
898
- (_d = (_c = this.destinationProvider).close) == null ? void 0 : _d.call(_c)
888
+ this.sourceProvider.close?.(),
889
+ this.destinationProvider.close?.()
899
890
  ]);
900
891
  results.forEach((result) => {
901
892
  if (result.status === "rejected") {
@@ -914,12 +905,11 @@ ${formattedDiffs}`,
914
905
  }
915
906
  }
916
907
  async #getSchemas() {
917
- var _a, _b, _c, _d;
918
908
  if (!this.#schema.source) {
919
- this.#schema.source = await ((_b = (_a = this.sourceProvider).getSchemas) == null ? void 0 : _b.call(_a));
909
+ this.#schema.source = await this.sourceProvider.getSchemas?.();
920
910
  }
921
911
  if (!this.#schema.destination) {
922
- this.#schema.destination = await ((_d = (_c = this.destinationProvider).getSchemas) == null ? void 0 : _d.call(_c));
912
+ this.#schema.destination = await this.destinationProvider.getSchemas?.();
923
913
  }
924
914
  return {
925
915
  sourceSchemas: this.#schema.source,
@@ -927,13 +917,12 @@ ${formattedDiffs}`,
927
917
  };
928
918
  }
929
919
  async integrityCheck() {
930
- var _a, _b, _c, _d, _e, _f;
931
920
  const sourceMetadata = await this.sourceProvider.getMetadata();
932
921
  const destinationMetadata = await this.destinationProvider.getMetadata();
933
922
  if (sourceMetadata && destinationMetadata) {
934
923
  this.#assertStrapiVersionIntegrity(
935
- (_a = sourceMetadata == null ? void 0 : sourceMetadata.strapi) == null ? void 0 : _a.version,
936
- (_b = destinationMetadata == null ? void 0 : destinationMetadata.strapi) == null ? void 0 : _b.version
924
+ sourceMetadata?.strapi?.version,
925
+ destinationMetadata?.strapi?.version
937
926
  );
938
927
  }
939
928
  const { sourceSchemas, destinationSchemas } = await this.#getSchemas();
@@ -942,8 +931,8 @@ ${formattedDiffs}`,
942
931
  this.#assertSchemasMatching(sourceSchemas, destinationSchemas);
943
932
  }
944
933
  } catch (error) {
945
- if (error instanceof TransferEngineValidationError && ((_d = (_c = error.details) == null ? void 0 : _c.details) == null ? void 0 : _d.diffs)) {
946
- const schemaDiffs = (_f = (_e = error.details) == null ? void 0 : _e.details) == null ? void 0 : _f.diffs;
934
+ if (error instanceof TransferEngineValidationError && error.details?.details?.diffs) {
935
+ const schemaDiffs = error.details?.details?.diffs;
947
936
  const context = {
948
937
  ignoredDiffs: {},
949
938
  diffs: schemaDiffs,
@@ -972,7 +961,6 @@ ${formattedDiffs}`,
972
961
  }
973
962
  }
974
963
  async transfer() {
975
- var _a, _b;
976
964
  this.progress.data = {};
977
965
  try {
978
966
  this.#emitTransferUpdate("init");
@@ -994,7 +982,7 @@ ${formattedDiffs}`,
994
982
  if (e instanceof Error && (!lastDiagnostic || lastDiagnostic.kind !== "error" || lastDiagnostic.details.error !== e)) {
995
983
  this.reportError(e, e.severity || "fatal");
996
984
  }
997
- await ((_b = (_a = this.destinationProvider).rollback) == null ? void 0 : _b.call(_a, e));
985
+ await this.destinationProvider.rollback?.(e);
998
986
  throw e;
999
987
  }
1000
988
  return {
@@ -1005,9 +993,8 @@ ${formattedDiffs}`,
1005
993
  }
1006
994
  async beforeTransfer() {
1007
995
  const runWithDiagnostic = async (provider) => {
1008
- var _a;
1009
996
  try {
1010
- await ((_a = provider.beforeTransfer) == null ? void 0 : _a.call(provider));
997
+ await provider.beforeTransfer?.();
1011
998
  } catch (error) {
1012
999
  if (error instanceof Error) {
1013
1000
  const resolved = await this.attemptResolveError(error);
@@ -1026,13 +1013,12 @@ ${formattedDiffs}`,
1026
1013
  await runWithDiagnostic(this.destinationProvider);
1027
1014
  }
1028
1015
  async transferSchemas() {
1029
- var _a, _b, _c, _d;
1030
1016
  const stage = "schemas";
1031
1017
  if (this.shouldSkipStage(stage)) {
1032
1018
  return;
1033
1019
  }
1034
- const source = await ((_b = (_a = this.sourceProvider).createSchemasReadStream) == null ? void 0 : _b.call(_a));
1035
- const destination = await ((_d = (_c = this.destinationProvider).createSchemasWriteStream) == null ? void 0 : _d.call(_c));
1020
+ const source = await this.sourceProvider.createSchemasReadStream?.();
1021
+ const destination = await this.destinationProvider.createSchemasWriteStream?.();
1036
1022
  const transform = this.#createStageTransformStream(stage);
1037
1023
  const tracker = this.#progressTracker(stage, {
1038
1024
  key: (value) => value.modelType
@@ -1040,13 +1026,12 @@ ${formattedDiffs}`,
1040
1026
  await this.#transferStage({ stage, source, destination, transform, tracker });
1041
1027
  }
1042
1028
  async transferEntities() {
1043
- var _a, _b, _c, _d;
1044
1029
  const stage = "entities";
1045
1030
  if (this.shouldSkipStage(stage)) {
1046
1031
  return;
1047
1032
  }
1048
- const source = await ((_b = (_a = this.sourceProvider).createEntitiesReadStream) == null ? void 0 : _b.call(_a));
1049
- const destination = await ((_d = (_c = this.destinationProvider).createEntitiesWriteStream) == null ? void 0 : _d.call(_c));
1033
+ const source = await this.sourceProvider.createEntitiesReadStream?.();
1034
+ const destination = await this.destinationProvider.createEntitiesWriteStream?.();
1050
1035
  const transform = chain([
1051
1036
  this.#createStageTransformStream(stage),
1052
1037
  new Transform({
@@ -1072,13 +1057,12 @@ ${formattedDiffs}`,
1072
1057
  await this.#transferStage({ stage, source, destination, transform, tracker });
1073
1058
  }
1074
1059
  async transferLinks() {
1075
- var _a, _b, _c, _d;
1076
1060
  const stage = "links";
1077
1061
  if (this.shouldSkipStage(stage)) {
1078
1062
  return;
1079
1063
  }
1080
- const source = await ((_b = (_a = this.sourceProvider).createLinksReadStream) == null ? void 0 : _b.call(_a));
1081
- const destination = await ((_d = (_c = this.destinationProvider).createLinksWriteStream) == null ? void 0 : _d.call(_c));
1064
+ const source = await this.sourceProvider.createLinksReadStream?.();
1065
+ const destination = await this.destinationProvider.createLinksWriteStream?.();
1082
1066
  const transform = chain([
1083
1067
  this.#createStageTransformStream(stage),
1084
1068
  new Transform({
@@ -1101,13 +1085,12 @@ ${formattedDiffs}`,
1101
1085
  await this.#transferStage({ stage, source, destination, transform, tracker });
1102
1086
  }
1103
1087
  async transferAssets() {
1104
- var _a, _b, _c, _d;
1105
1088
  const stage = "assets";
1106
1089
  if (this.shouldSkipStage(stage)) {
1107
1090
  return;
1108
1091
  }
1109
- const source = await ((_b = (_a = this.sourceProvider).createAssetsReadStream) == null ? void 0 : _b.call(_a));
1110
- const destination = await ((_d = (_c = this.destinationProvider).createAssetsWriteStream) == null ? void 0 : _d.call(_c));
1092
+ const source = await this.sourceProvider.createAssetsReadStream?.();
1093
+ const destination = await this.destinationProvider.createAssetsWriteStream?.();
1111
1094
  const transform = this.#createStageTransformStream(stage);
1112
1095
  const tracker = this.#progressTracker(stage, {
1113
1096
  size: (value) => value.stats.size,
@@ -1116,13 +1099,12 @@ ${formattedDiffs}`,
1116
1099
  await this.#transferStage({ stage, source, destination, transform, tracker });
1117
1100
  }
1118
1101
  async transferConfiguration() {
1119
- var _a, _b, _c, _d;
1120
1102
  const stage = "configuration";
1121
1103
  if (this.shouldSkipStage(stage)) {
1122
1104
  return;
1123
1105
  }
1124
- const source = await ((_b = (_a = this.sourceProvider).createConfigurationReadStream) == null ? void 0 : _b.call(_a));
1125
- const destination = await ((_d = (_c = this.destinationProvider).createConfigurationWriteStream) == null ? void 0 : _d.call(_c));
1106
+ const source = await this.sourceProvider.createConfigurationReadStream?.();
1107
+ const destination = await this.destinationProvider.createConfigurationWriteStream?.();
1126
1108
  const transform = this.#createStageTransformStream(stage);
1127
1109
  const tracker = this.#progressTracker(stage);
1128
1110
  await this.#transferStage({ stage, source, destination, transform, tracker });
@@ -1140,10 +1122,7 @@ const engineDatatransfer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
1140
1122
  createTransferEngine: createTransferEngine$2,
1141
1123
  errors
1142
1124
  }, Symbol.toStringTag, { value: "Module" }));
1143
- const isDialectMySQL = () => {
1144
- var _a;
1145
- return ((_a = strapi.db) == null ? void 0 : _a.dialect.client) === "mysql";
1146
- };
1125
+ const isDialectMySQL = () => strapi.db?.dialect.client === "mysql";
1147
1126
  function omitComponentData(contentType, data) {
1148
1127
  const { attributes } = contentType;
1149
1128
  const componentAttributes = Object.keys(attributes).filter(
@@ -1152,7 +1131,6 @@ function omitComponentData(contentType, data) {
1152
1131
  return omit(componentAttributes, data);
1153
1132
  }
1154
1133
  const createComponents = async (uid, data) => {
1155
- var _a, _b;
1156
1134
  const { attributes = {} } = strapi.getModel(uid);
1157
1135
  const componentBody = {};
1158
1136
  const attributeNames = Object.keys(attributes);
@@ -1174,7 +1152,7 @@ const createComponents = async (uid, data) => {
1174
1152
  const components = await mapAsync(
1175
1153
  componentValue,
1176
1154
  (value) => createComponent(componentUID, value),
1177
- { concurrency: isDialectMySQL() && !((_a = strapi.db) == null ? void 0 : _a.inTransaction()) ? 1 : Infinity }
1155
+ { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
1178
1156
  );
1179
1157
  componentBody[attributeName] = components.map(({ id }) => {
1180
1158
  return {
@@ -1218,7 +1196,7 @@ const createComponents = async (uid, data) => {
1218
1196
  componentBody[attributeName] = await mapAsync(
1219
1197
  dynamiczoneValues,
1220
1198
  createDynamicZoneComponents,
1221
- { concurrency: isDialectMySQL() && !((_b = strapi.db) == null ? void 0 : _b.inTransaction()) ? 1 : Infinity }
1199
+ { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
1222
1200
  );
1223
1201
  continue;
1224
1202
  }
@@ -1233,7 +1211,6 @@ const getComponents = async (uid, entity2) => {
1233
1211
  return strapi.query(uid).load(entity2, componentAttributes);
1234
1212
  };
1235
1213
  const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {}) => {
1236
- var _a, _b;
1237
1214
  const { attributes = {} } = strapi.getModel(uid);
1238
1215
  const attributeNames = Object.keys(attributes);
1239
1216
  for (const attributeName of attributeNames) {
@@ -1254,14 +1231,14 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
1254
1231
  _.castArray(value),
1255
1232
  (subValue) => deleteComponent(componentUID, subValue),
1256
1233
  {
1257
- concurrency: isDialectMySQL() && !((_a = strapi.db) == null ? void 0 : _a.inTransaction()) ? 1 : Infinity
1234
+ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
1258
1235
  }
1259
1236
  );
1260
1237
  } else {
1261
1238
  await mapAsync(
1262
1239
  _.castArray(value),
1263
1240
  (subValue) => deleteComponent(subValue.__component, subValue),
1264
- { concurrency: isDialectMySQL() && !((_b = strapi.db) == null ? void 0 : _b.inTransaction()) ? 1 : Infinity }
1241
+ { concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
1265
1242
  );
1266
1243
  }
1267
1244
  continue;
@@ -1617,7 +1594,7 @@ const createEntitiesWriteStream = (options) => {
1617
1594
  return new Writable({
1618
1595
  objectMode: true,
1619
1596
  async write(entity2, _encoding, callback) {
1620
- await (transaction2 == null ? void 0 : transaction2.attach(async () => {
1597
+ await transaction2?.attach(async () => {
1621
1598
  const { type, id, data } = entity2;
1622
1599
  const { create, getDeepPopulateComponentLikeQuery } = query(type);
1623
1600
  const contentType = strapi2.getModel(type);
@@ -1669,7 +1646,7 @@ const createEntitiesWriteStream = (options) => {
1669
1646
  return callback(new ProviderTransferError(`Failed to create "${type}" (${id})`));
1670
1647
  }
1671
1648
  return callback(null);
1672
- }));
1649
+ });
1673
1650
  }
1674
1651
  });
1675
1652
  };
@@ -1699,7 +1676,7 @@ const createConfigurationWriteStream = async (strapi2, transaction2) => {
1699
1676
  return new Writable({
1700
1677
  objectMode: true,
1701
1678
  async write(config, _encoding, callback) {
1702
- await (transaction2 == null ? void 0 : transaction2.attach(async () => {
1679
+ await transaction2?.attach(async () => {
1703
1680
  try {
1704
1681
  await restoreConfigs(strapi2, config);
1705
1682
  } catch (error) {
@@ -1712,7 +1689,7 @@ const createConfigurationWriteStream = async (strapi2, transaction2) => {
1712
1689
  );
1713
1690
  }
1714
1691
  callback();
1715
- }));
1692
+ });
1716
1693
  }
1717
1694
  });
1718
1695
  };
@@ -1720,7 +1697,7 @@ const createLinksWriteStream = (mapID, strapi2, transaction2) => {
1720
1697
  return new Writable({
1721
1698
  objectMode: true,
1722
1699
  async write(link2, _encoding, callback) {
1723
- await (transaction2 == null ? void 0 : transaction2.attach(async (trx) => {
1700
+ await transaction2?.attach(async (trx) => {
1724
1701
  const { left, right } = link2;
1725
1702
  const query = createLinkQuery(strapi2, trx);
1726
1703
  left.ref = mapID(left.type, left.ref) ?? left.ref;
@@ -1738,7 +1715,7 @@ const createLinksWriteStream = (mapID, strapi2, transaction2) => {
1738
1715
  );
1739
1716
  }
1740
1717
  callback(null);
1741
- }));
1718
+ });
1742
1719
  }
1743
1720
  });
1744
1721
  };
@@ -1759,13 +1736,13 @@ const deleteEntitiesRecords = async (strapi2, options = {}) => {
1759
1736
  );
1760
1737
  const contentTypesToClear = contentTypes2.filter((contentType) => {
1761
1738
  let removeThisContentType = true;
1762
- if (entities == null ? void 0 : entities.include) {
1739
+ if (entities?.include) {
1763
1740
  removeThisContentType = entities.include.includes(contentType.uid);
1764
1741
  }
1765
- if ((entities == null ? void 0 : entities.exclude) && entities.exclude.includes(contentType.uid)) {
1742
+ if (entities?.exclude && entities.exclude.includes(contentType.uid)) {
1766
1743
  removeThisContentType = false;
1767
1744
  }
1768
- if (entities == null ? void 0 : entities.filters) {
1745
+ if (entities?.filters) {
1769
1746
  removeThisContentType = entities.filters.every((filter2) => filter2(contentType));
1770
1747
  }
1771
1748
  return removeThisContentType;
@@ -1774,7 +1751,7 @@ const deleteEntitiesRecords = async (strapi2, options = {}) => {
1774
1751
  contentTypesToClear.map((contentType) => contentType.uid)
1775
1752
  );
1776
1753
  const deletePromises = contentTypesToClear.map(async (contentType) => {
1777
- const result = await query(contentType.uid).deleteMany(entities == null ? void 0 : entities.params);
1754
+ const result = await query(contentType.uid).deleteMany(entities?.params);
1778
1755
  if (result) {
1779
1756
  updateResults(result.count || 0, contentType.uid);
1780
1757
  }
@@ -1783,7 +1760,7 @@ const deleteEntitiesRecords = async (strapi2, options = {}) => {
1783
1760
  return results;
1784
1761
  };
1785
1762
  const deleteConfigurationRecords = async (strapi2, options = {}) => {
1786
- const { coreStore = true, webhook = true } = (options == null ? void 0 : options.configuration) ?? {};
1763
+ const { coreStore = true, webhook = true } = options?.configuration ?? {};
1787
1764
  const models = [];
1788
1765
  if (coreStore) {
1789
1766
  models.push("strapi::core-store");
@@ -1850,21 +1827,18 @@ class LocalStrapiDestinationProvider {
1850
1827
  }
1851
1828
  // TODO: either move this to restore strategy, or restore strategy should given access to these instead of repeating the logic possibly in a different way
1852
1829
  #areAssetsIncluded = () => {
1853
- var _a;
1854
- return (_a = this.options.restore) == null ? void 0 : _a.assets;
1830
+ return this.options.restore?.assets;
1855
1831
  };
1856
1832
  #isContentTypeIncluded = (type) => {
1857
- var _a, _b, _c, _d, _e, _f, _g, _h;
1858
- const notIncluded = ((_b = (_a = this.options.restore) == null ? void 0 : _a.entities) == null ? void 0 : _b.include) && !((_e = (_d = (_c = this.options.restore) == null ? void 0 : _c.entities) == null ? void 0 : _d.include) == null ? void 0 : _e.includes(type));
1859
- const excluded = ((_g = (_f = this.options.restore) == null ? void 0 : _f.entities) == null ? void 0 : _g.exclude) && ((_h = this.options.restore) == null ? void 0 : _h.entities.exclude.includes(type));
1833
+ const notIncluded = this.options.restore?.entities?.include && !this.options.restore?.entities?.include?.includes(type);
1834
+ const excluded = this.options.restore?.entities?.exclude && this.options.restore?.entities.exclude.includes(type);
1860
1835
  return !excluded && !notIncluded;
1861
1836
  };
1862
1837
  async close() {
1863
- var _a, _b;
1864
1838
  const { autoDestroy } = this.options;
1865
- (_a = this.transaction) == null ? void 0 : _a.end();
1839
+ this.transaction?.end();
1866
1840
  if (autoDestroy === void 0 || autoDestroy === true) {
1867
- await ((_b = this.strapi) == null ? void 0 : _b.destroy());
1841
+ await this.strapi?.destroy();
1868
1842
  }
1869
1843
  }
1870
1844
  #validateOptions() {
@@ -1902,15 +1876,13 @@ class LocalStrapiDestinationProvider {
1902
1876
  }
1903
1877
  }
1904
1878
  async rollback() {
1905
- var _a;
1906
- await ((_a = this.transaction) == null ? void 0 : _a.rollback());
1879
+ await this.transaction?.rollback();
1907
1880
  }
1908
1881
  async beforeTransfer() {
1909
- var _a;
1910
1882
  if (!this.strapi) {
1911
1883
  throw new Error("Strapi instance not found");
1912
1884
  }
1913
- await ((_a = this.transaction) == null ? void 0 : _a.attach(async (trx) => {
1885
+ await this.transaction?.attach(async (trx) => {
1914
1886
  try {
1915
1887
  if (this.options.strategy === "restore") {
1916
1888
  await this.#handleAssetsBackup();
@@ -1920,7 +1892,7 @@ class LocalStrapiDestinationProvider {
1920
1892
  } catch (error) {
1921
1893
  throw new Error(`restore failed ${error}`);
1922
1894
  }
1923
- }));
1895
+ });
1924
1896
  }
1925
1897
  getMetadata() {
1926
1898
  assertValidStrapi(this.strapi, "Not able to get Schemas");
@@ -2027,8 +1999,7 @@ class LocalStrapiDestinationProvider {
2027
1999
  next();
2028
2000
  },
2029
2001
  async write(chunk, _encoding, callback) {
2030
- await (transaction2 == null ? void 0 : transaction2.attach(async () => {
2031
- var _a;
2002
+ await transaction2?.attach(async () => {
2032
2003
  if (!chunk.metadata) {
2033
2004
  const assetsDirectory = path.join(strapi2.dirs.static.public, "uploads");
2034
2005
  const entryPath = path.join(assetsDirectory, chunk.filename);
@@ -2057,7 +2028,7 @@ class LocalStrapiDestinationProvider {
2057
2028
  const uploadData = {
2058
2029
  ...chunk.metadata,
2059
2030
  stream: Readable.from(chunk.stream),
2060
- buffer: chunk == null ? void 0 : chunk.buffer
2031
+ buffer: chunk?.buffer
2061
2032
  };
2062
2033
  const provider = strapi2.config.get("plugin.upload").provider;
2063
2034
  try {
@@ -2065,11 +2036,11 @@ class LocalStrapiDestinationProvider {
2065
2036
  if (!restoreMediaEntitiesContent) {
2066
2037
  return callback();
2067
2038
  }
2068
- if (uploadData == null ? void 0 : uploadData.type) {
2039
+ if (uploadData?.type) {
2069
2040
  const entry2 = await strapi2.db.query("plugin::upload.file").findOne({
2070
2041
  where: { hash: uploadData.mainHash }
2071
2042
  });
2072
- const specificFormat = (_a = entry2 == null ? void 0 : entry2.formats) == null ? void 0 : _a[uploadData.type];
2043
+ const specificFormat = entry2?.formats?.[uploadData.type];
2073
2044
  if (specificFormat) {
2074
2045
  specificFormat.url = uploadData.url;
2075
2046
  }
@@ -2097,7 +2068,7 @@ class LocalStrapiDestinationProvider {
2097
2068
  } catch (error) {
2098
2069
  callback(new Error(`Error while uploading asset ${chunk.filename} ${error}`));
2099
2070
  }
2100
- }));
2071
+ });
2101
2072
  }
2102
2073
  });
2103
2074
  }
@@ -2118,10 +2089,7 @@ class LocalStrapiDestinationProvider {
2118
2089
  throw new Error("Not able to stream links. Strapi instance not found");
2119
2090
  }
2120
2091
  const { strategy } = this.options;
2121
- const mapID = (uid, id) => {
2122
- var _a;
2123
- return (_a = this.#entitiesMapper[uid]) == null ? void 0 : _a[id];
2124
- };
2092
+ const mapID = (uid, id) => this.#entitiesMapper[uid]?.[id];
2125
2093
  if (strategy === "restore") {
2126
2094
  return createLinksWriteStream(mapID, this.strapi, this.transaction);
2127
2095
  }
@@ -2213,7 +2181,7 @@ const wrapConfigurationItem = (type) => (value) => ({
2213
2181
  value
2214
2182
  });
2215
2183
  const protocolForPath = (filepath) => {
2216
- return (filepath == null ? void 0 : filepath.startsWith("https")) ? https : http;
2184
+ return filepath?.startsWith("https") ? https : http;
2217
2185
  };
2218
2186
  function getFileStream(filepath, isLocal = false) {
2219
2187
  if (isLocal) {
@@ -2304,10 +2272,9 @@ class LocalStrapiSourceProvider {
2304
2272
  this.strapi = await this.options.getStrapi();
2305
2273
  }
2306
2274
  async close() {
2307
- var _a;
2308
2275
  const { autoDestroy } = this.options;
2309
2276
  if (autoDestroy === void 0 || autoDestroy === true) {
2310
- await ((_a = this.strapi) == null ? void 0 : _a.destroy());
2277
+ await this.strapi?.destroy();
2311
2278
  }
2312
2279
  }
2313
2280
  getMetadata() {
@@ -2363,12 +2330,11 @@ const createDispatcher = (ws, retryMessageOptions = {
2363
2330
  throw new Error("No websocket connection found");
2364
2331
  }
2365
2332
  return new Promise((resolve, reject2) => {
2366
- var _a;
2367
2333
  const uuid = randomUUID();
2368
2334
  const payload = { ...message, uuid };
2369
2335
  let numberOfTimesMessageWasSent = 0;
2370
2336
  if (options.attachTransfer) {
2371
- Object.assign(payload, { transferID: (_a = state.transfer) == null ? void 0 : _a.id });
2337
+ Object.assign(payload, { transferID: state.transfer?.id });
2372
2338
  }
2373
2339
  const stringifiedPayload = JSON.stringify(payload);
2374
2340
  ws.send(stringifiedPayload, (error) => {
@@ -2391,14 +2357,13 @@ const createDispatcher = (ws, retryMessageOptions = {
2391
2357
  };
2392
2358
  const interval = setInterval(sendPeriodically, retryMessageTimeout);
2393
2359
  const onResponse = (raw) => {
2394
- var _a2, _b;
2395
2360
  const response = JSON.parse(raw.toString());
2396
2361
  if (response.uuid === uuid) {
2397
2362
  clearInterval(interval);
2398
2363
  if (response.error) {
2399
2364
  const message2 = response.error.message;
2400
- const details = (_a2 = response.error.details) == null ? void 0 : _a2.details;
2401
- const step = (_b = response.error.details) == null ? void 0 : _b.step;
2365
+ const details = response.error.details?.details;
2366
+ const step = response.error.details?.step;
2402
2367
  let error = new ProviderError("error", message2, details);
2403
2368
  if (step === "transfer") {
2404
2369
  error = new ProviderTransferError(message2, details);
@@ -2437,12 +2402,10 @@ const createDispatcher = (ws, retryMessageOptions = {
2437
2402
  };
2438
2403
  return {
2439
2404
  get transferID() {
2440
- var _a;
2441
- return (_a = state.transfer) == null ? void 0 : _a.id;
2405
+ return state.transfer?.id;
2442
2406
  },
2443
2407
  get transferKind() {
2444
- var _a;
2445
- return (_a = state.transfer) == null ? void 0 : _a.kind;
2408
+ return state.transfer?.kind;
2446
2409
  },
2447
2410
  setTransferProperties,
2448
2411
  dispatch,
@@ -2521,14 +2484,13 @@ class RemoteStrapiDestinationProvider {
2521
2484
  this.transferID = null;
2522
2485
  }
2523
2486
  async initTransfer() {
2524
- var _a;
2525
2487
  const { strategy, restore } = this.options;
2526
- const query = (_a = this.dispatcher) == null ? void 0 : _a.dispatchCommand({
2488
+ const query = this.dispatcher?.dispatchCommand({
2527
2489
  command: "init",
2528
2490
  params: { options: { strategy, restore }, transfer: "push" }
2529
2491
  });
2530
2492
  const res = await query;
2531
- if (!(res == null ? void 0 : res.transferID)) {
2493
+ if (!res?.transferID) {
2532
2494
  throw new ProviderTransferError("Init failed, invalid response from the server");
2533
2495
  }
2534
2496
  return res.transferID;
@@ -2537,9 +2499,8 @@ class RemoteStrapiDestinationProvider {
2537
2499
  return once(() => this.#startStep(stage));
2538
2500
  }
2539
2501
  async #startStep(step) {
2540
- var _a;
2541
2502
  try {
2542
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferStep({ action: "start", step }));
2503
+ await this.dispatcher?.dispatchTransferStep({ action: "start", step });
2543
2504
  } catch (e) {
2544
2505
  if (e instanceof Error) {
2545
2506
  return e;
@@ -2552,9 +2513,8 @@ class RemoteStrapiDestinationProvider {
2552
2513
  return null;
2553
2514
  }
2554
2515
  async #endStep(step) {
2555
- var _a;
2556
2516
  try {
2557
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferStep({ action: "end", step }));
2517
+ await this.dispatcher?.dispatchTransferStep({ action: "end", step });
2558
2518
  } catch (e) {
2559
2519
  if (e instanceof Error) {
2560
2520
  return e;
@@ -2567,9 +2527,8 @@ class RemoteStrapiDestinationProvider {
2567
2527
  return null;
2568
2528
  }
2569
2529
  async #streamStep(step, data) {
2570
- var _a;
2571
2530
  try {
2572
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferStep({ action: "stream", step, data }));
2531
+ await this.dispatcher?.dispatchTransferStep({ action: "stream", step, data });
2573
2532
  } catch (e) {
2574
2533
  if (e instanceof Error) {
2575
2534
  return e;
@@ -2671,16 +2630,13 @@ class RemoteStrapiDestinationProvider {
2671
2630
  });
2672
2631
  }
2673
2632
  getMetadata() {
2674
- var _a;
2675
- return ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("getMetadata")) ?? null;
2633
+ return this.dispatcher?.dispatchTransferAction("getMetadata") ?? null;
2676
2634
  }
2677
2635
  async beforeTransfer() {
2678
- var _a;
2679
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("beforeTransfer"));
2636
+ await this.dispatcher?.dispatchTransferAction("beforeTransfer");
2680
2637
  }
2681
2638
  async rollback() {
2682
- var _a;
2683
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("rollback"));
2639
+ await this.dispatcher?.dispatchTransferAction("rollback");
2684
2640
  }
2685
2641
  getSchemas() {
2686
2642
  if (!this.dispatcher) {
@@ -2780,7 +2736,6 @@ class RemoteStrapiSourceProvider {
2780
2736
  }
2781
2737
  results;
2782
2738
  async #createStageReadStream(stage) {
2783
- var _a;
2784
2739
  const startResult = await this.#startStep(stage);
2785
2740
  if (startResult instanceof Error) {
2786
2741
  throw startResult;
@@ -2788,10 +2743,9 @@ class RemoteStrapiSourceProvider {
2788
2743
  const { id: processID } = startResult;
2789
2744
  const stream2 = new PassThrough({ objectMode: true });
2790
2745
  const listener = async (raw) => {
2791
- var _a2, _b, _c, _d;
2792
2746
  const parsed = JSON.parse(raw.toString());
2793
- if (!parsed.uuid || ((_a2 = parsed == null ? void 0 : parsed.data) == null ? void 0 : _a2.type) !== "transfer" || ((_b = parsed == null ? void 0 : parsed.data) == null ? void 0 : _b.id) !== processID) {
2794
- (_c = this.ws) == null ? void 0 : _c.once("message", listener);
2747
+ if (!parsed.uuid || parsed?.data?.type !== "transfer" || parsed?.data?.id !== processID) {
2748
+ this.ws?.once("message", listener);
2795
2749
  return;
2796
2750
  }
2797
2751
  const { uuid, data: message } = parsed;
@@ -2811,10 +2765,10 @@ class RemoteStrapiSourceProvider {
2811
2765
  for (const item of castArray(data)) {
2812
2766
  stream2.push(item);
2813
2767
  }
2814
- (_d = this.ws) == null ? void 0 : _d.once("message", listener);
2768
+ this.ws?.once("message", listener);
2815
2769
  await this.#respond(uuid);
2816
2770
  };
2817
- (_a = this.ws) == null ? void 0 : _a.once("message", listener);
2771
+ this.ws?.once("message", listener);
2818
2772
  return stream2;
2819
2773
  }
2820
2774
  createEntitiesReadStream() {
@@ -2866,8 +2820,7 @@ class RemoteStrapiSourceProvider {
2866
2820
  return this.#createStageReadStream("configuration");
2867
2821
  }
2868
2822
  async getMetadata() {
2869
- var _a;
2870
- const metadata = await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("getMetadata"));
2823
+ const metadata = await this.dispatcher?.dispatchTransferAction("getMetadata");
2871
2824
  return metadata ?? null;
2872
2825
  }
2873
2826
  assertValidProtocol(url) {
@@ -2883,12 +2836,11 @@ class RemoteStrapiSourceProvider {
2883
2836
  }
2884
2837
  }
2885
2838
  async initTransfer() {
2886
- var _a;
2887
- const query = (_a = this.dispatcher) == null ? void 0 : _a.dispatchCommand({
2839
+ const query = this.dispatcher?.dispatchCommand({
2888
2840
  command: "init"
2889
2841
  });
2890
2842
  const res = await query;
2891
- if (!(res == null ? void 0 : res.transferID)) {
2843
+ if (!res?.transferID) {
2892
2844
  throw new ProviderTransferError("Init failed, invalid response from the server");
2893
2845
  }
2894
2846
  return res.transferID;
@@ -2922,8 +2874,7 @@ class RemoteStrapiSourceProvider {
2922
2874
  await this.dispatcher.dispatchTransferAction("bootstrap");
2923
2875
  }
2924
2876
  async close() {
2925
- var _a;
2926
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("close"));
2877
+ await this.dispatcher?.dispatchTransferAction("close");
2927
2878
  await new Promise((resolve) => {
2928
2879
  const { ws } = this;
2929
2880
  if (!ws || ws.CLOSED) {
@@ -2934,16 +2885,14 @@ class RemoteStrapiSourceProvider {
2934
2885
  });
2935
2886
  }
2936
2887
  async getSchemas() {
2937
- var _a;
2938
- const schemas = await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction(
2888
+ const schemas = await this.dispatcher?.dispatchTransferAction(
2939
2889
  "getSchemas"
2940
- )) ?? null;
2890
+ ) ?? null;
2941
2891
  return schemas;
2942
2892
  }
2943
2893
  async #startStep(step) {
2944
- var _a;
2945
2894
  try {
2946
- return await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferStep({ action: "start", step }));
2895
+ return await this.dispatcher?.dispatchTransferStep({ action: "start", step });
2947
2896
  } catch (e) {
2948
2897
  if (e instanceof Error) {
2949
2898
  return e;
@@ -2956,8 +2905,7 @@ class RemoteStrapiSourceProvider {
2956
2905
  }
2957
2906
  async #respond(uuid) {
2958
2907
  return new Promise((resolve, reject2) => {
2959
- var _a;
2960
- (_a = this.ws) == null ? void 0 : _a.send(JSON.stringify({ uuid }), (e) => {
2908
+ this.ws?.send(JSON.stringify({ uuid }), (e) => {
2961
2909
  if (e) {
2962
2910
  reject2(e);
2963
2911
  } else {
@@ -2967,9 +2915,8 @@ class RemoteStrapiSourceProvider {
2967
2915
  });
2968
2916
  }
2969
2917
  async #endStep(step) {
2970
- var _a;
2971
2918
  try {
2972
- await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferStep({ action: "end", step }));
2919
+ await this.dispatcher?.dispatchTransferStep({ action: "end", step });
2973
2920
  } catch (e) {
2974
2921
  if (e instanceof Error) {
2975
2922
  return e;
@@ -3080,8 +3027,7 @@ const transformUpgradeHeader = (header = "") => {
3080
3027
  };
3081
3028
  let timeouts;
3082
3029
  const disableTimeouts = () => {
3083
- var _a;
3084
- if (!((_a = strapi == null ? void 0 : strapi.server) == null ? void 0 : _a.httpServer)) {
3030
+ if (!strapi?.server?.httpServer) {
3085
3031
  return;
3086
3032
  }
3087
3033
  const { httpServer } = strapi.server;
@@ -3096,8 +3042,7 @@ const disableTimeouts = () => {
3096
3042
  strapi.log.info("[Data transfer] Disabling http timeouts");
3097
3043
  };
3098
3044
  const resetTimeouts = () => {
3099
- var _a;
3100
- if (!((_a = strapi == null ? void 0 : strapi.server) == null ? void 0 : _a.httpServer) || !timeouts) {
3045
+ if (!strapi?.server?.httpServer || !timeouts) {
3101
3046
  return;
3102
3047
  }
3103
3048
  const { httpServer } = strapi.server;
@@ -3106,12 +3051,11 @@ const resetTimeouts = () => {
3106
3051
  httpServer.requestTimeout = timeouts.requestTimeout;
3107
3052
  };
3108
3053
  const assertValidHeader = (ctx) => {
3109
- var _a;
3110
3054
  if (ctx.headers.upgrade === "websocket") {
3111
3055
  return;
3112
3056
  }
3113
3057
  const upgradeHeader = transformUpgradeHeader(ctx.headers.upgrade);
3114
- const logSafeUpgradeHeader = (_a = JSON.stringify(ctx.headers.upgrade)) == null ? void 0 : _a.replace(/[^a-z0-9\s.,|]/gi, "").substring(0, 50);
3058
+ const logSafeUpgradeHeader = JSON.stringify(ctx.headers.upgrade)?.replace(/[^a-z0-9\s.,|]/gi, "").substring(0, 50);
3115
3059
  if (!upgradeHeader.includes("websocket")) {
3116
3060
  throw new Error(
3117
3061
  `Transfer Upgrade header expected 'websocket', found '${logSafeUpgradeHeader}'. Please ensure that your server or proxy is not modifying the Upgrade header.`
@@ -3151,21 +3095,19 @@ const handlerControllerFactory = (implementation) => (options) => {
3151
3095
  const { verify, server: serverOptions } = options ?? {};
3152
3096
  const wss = new WebSocket.Server({ ...serverOptions, noServer: true });
3153
3097
  return async (ctx) => {
3154
- var _a, _b;
3155
3098
  const cb = (ws) => {
3156
3099
  const state = { id: void 0 };
3157
3100
  const messageUUIDs = /* @__PURE__ */ new Set();
3158
3101
  const cannotRespondHandler = (err) => {
3159
- var _a2, _b2, _c;
3160
- (_a2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _a2.error(
3102
+ strapi?.log?.error(
3161
3103
  "[Data transfer] Cannot send error response to client, closing connection"
3162
3104
  );
3163
- (_b2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _b2.error(err);
3105
+ strapi?.log?.error(err);
3164
3106
  try {
3165
3107
  ws.terminate();
3166
3108
  ctx.req.socket.destroy();
3167
3109
  } catch (err2) {
3168
- (_c = strapi == null ? void 0 : strapi.log) == null ? void 0 : _c.error("[Data transfer] Failed to close socket on error");
3110
+ strapi?.log?.error("[Data transfer] Failed to close socket on error");
3169
3111
  }
3170
3112
  };
3171
3113
  const prototype = {
@@ -3230,8 +3172,8 @@ const handlerControllerFactory = (implementation) => (options) => {
3230
3172
  uuid,
3231
3173
  data: data ?? null,
3232
3174
  error: e ? {
3233
- code: (e == null ? void 0 : e.name) ?? "ERR",
3234
- message: e == null ? void 0 : e.message,
3175
+ code: e?.name ?? "ERR",
3176
+ message: e?.message,
3235
3177
  details
3236
3178
  } : null
3237
3179
  });
@@ -3308,34 +3250,31 @@ const handlerControllerFactory = (implementation) => (options) => {
3308
3250
  };
3309
3251
  const handler = Object.assign(Object.create(prototype), implementation(prototype));
3310
3252
  ws.on("close", async (...args) => {
3311
- var _a2, _b2;
3312
3253
  try {
3313
3254
  await handler.onClose(...args);
3314
3255
  } catch (err) {
3315
- (_a2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _a2.error("[Data transfer] Uncaught error closing connection");
3316
- (_b2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _b2.error(err);
3256
+ strapi?.log?.error("[Data transfer] Uncaught error closing connection");
3257
+ strapi?.log?.error(err);
3317
3258
  cannotRespondHandler(err);
3318
3259
  } finally {
3319
3260
  resetTimeouts();
3320
3261
  }
3321
3262
  });
3322
3263
  ws.on("error", async (...args) => {
3323
- var _a2, _b2;
3324
3264
  try {
3325
3265
  await handler.onError(...args);
3326
3266
  } catch (err) {
3327
- (_a2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _a2.error("[Data transfer] Uncaught error in error handling");
3328
- (_b2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _b2.error(err);
3267
+ strapi?.log?.error("[Data transfer] Uncaught error in error handling");
3268
+ strapi?.log?.error(err);
3329
3269
  cannotRespondHandler(err);
3330
3270
  }
3331
3271
  });
3332
3272
  ws.on("message", async (...args) => {
3333
- var _a2, _b2;
3334
3273
  try {
3335
3274
  await handler.onMessage(...args);
3336
3275
  } catch (err) {
3337
- (_a2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _a2.error("[Data transfer] Uncaught error in message handling");
3338
- (_b2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _b2.error(err);
3276
+ strapi?.log?.error("[Data transfer] Uncaught error in message handling");
3277
+ strapi?.log?.error(err);
3339
3278
  cannotRespondHandler(err);
3340
3279
  }
3341
3280
  });
@@ -3343,8 +3282,8 @@ const handlerControllerFactory = (implementation) => (options) => {
3343
3282
  try {
3344
3283
  handleWSUpgrade(wss, ctx, cb);
3345
3284
  } catch (err) {
3346
- (_a = strapi == null ? void 0 : strapi.log) == null ? void 0 : _a.error("[Data transfer] Error in websocket upgrade request");
3347
- (_b = strapi == null ? void 0 : strapi.log) == null ? void 0 : _b.error(err);
3285
+ strapi?.log?.error("[Data transfer] Error in websocket upgrade request");
3286
+ strapi?.log?.error(err);
3348
3287
  }
3349
3288
  };
3350
3289
  };
@@ -3403,15 +3342,14 @@ const createPushController = handlerControllerFactory((proto) => ({
3403
3342
  });
3404
3343
  },
3405
3344
  assertValidStreamTransferStep(stage) {
3406
- var _a, _b;
3407
- const currentStep = (_a = this.flow) == null ? void 0 : _a.get();
3345
+ const currentStep = this.flow?.get();
3408
3346
  const nextStep = { kind: "transfer", stage };
3409
- if ((currentStep == null ? void 0 : currentStep.kind) === "transfer" && !currentStep.locked) {
3347
+ if (currentStep?.kind === "transfer" && !currentStep.locked) {
3410
3348
  throw new ProviderTransferError(
3411
3349
  `You need to initialize the transfer stage (${nextStep}) before starting to stream data`
3412
3350
  );
3413
3351
  }
3414
- if ((_b = this.flow) == null ? void 0 : _b.cannot(nextStep)) {
3352
+ if (this.flow?.cannot(nextStep)) {
3415
3353
  throw new ProviderTransferError(`Invalid stage (${nextStep}) provided for the current flow`, {
3416
3354
  step: nextStep
3417
3355
  });
@@ -3419,22 +3357,10 @@ const createPushController = handlerControllerFactory((proto) => ({
3419
3357
  },
3420
3358
  async createWritableStreamForStep(step) {
3421
3359
  const mapper = {
3422
- entities: () => {
3423
- var _a;
3424
- return (_a = this.provider) == null ? void 0 : _a.createEntitiesWriteStream();
3425
- },
3426
- links: () => {
3427
- var _a;
3428
- return (_a = this.provider) == null ? void 0 : _a.createLinksWriteStream();
3429
- },
3430
- configuration: () => {
3431
- var _a;
3432
- return (_a = this.provider) == null ? void 0 : _a.createConfigurationWriteStream();
3433
- },
3434
- assets: () => {
3435
- var _a;
3436
- return (_a = this.provider) == null ? void 0 : _a.createAssetsWriteStream();
3437
- }
3360
+ entities: () => this.provider?.createEntitiesWriteStream(),
3361
+ links: () => this.provider?.createLinksWriteStream(),
3362
+ configuration: () => this.provider?.createConfigurationWriteStream(),
3363
+ assets: () => this.provider?.createAssetsWriteStream()
3438
3364
  };
3439
3365
  if (!(step in mapper)) {
3440
3366
  throw new Error("Invalid transfer step, impossible to create a stream");
@@ -3454,8 +3380,8 @@ const createPushController = handlerControllerFactory((proto) => ({
3454
3380
  }
3455
3381
  if (proto.hasUUID(msg.uuid)) {
3456
3382
  const previousResponse = proto.response;
3457
- if ((previousResponse == null ? void 0 : previousResponse.uuid) === msg.uuid) {
3458
- await this.respond(previousResponse == null ? void 0 : previousResponse.uuid, previousResponse.e, previousResponse.data);
3383
+ if (previousResponse?.uuid === msg.uuid) {
3384
+ await this.respond(previousResponse?.uuid, previousResponse.e, previousResponse.data);
3459
3385
  }
3460
3386
  return;
3461
3387
  }
@@ -3490,43 +3416,40 @@ const createPushController = handlerControllerFactory((proto) => ({
3490
3416
  }
3491
3417
  },
3492
3418
  lockTransferStep(stage) {
3493
- var _a, _b, _c;
3494
- const currentStep = (_a = this.flow) == null ? void 0 : _a.get();
3419
+ const currentStep = this.flow?.get();
3495
3420
  const nextStep = { kind: "transfer", stage };
3496
- if ((currentStep == null ? void 0 : currentStep.kind) === "transfer" && currentStep.locked) {
3421
+ if (currentStep?.kind === "transfer" && currentStep.locked) {
3497
3422
  throw new ProviderTransferError(
3498
3423
  `It's not possible to start a new transfer stage (${stage}) while another one is in progress (${currentStep.stage})`
3499
3424
  );
3500
3425
  }
3501
- if ((_b = this.flow) == null ? void 0 : _b.cannot(nextStep)) {
3426
+ if (this.flow?.cannot(nextStep)) {
3502
3427
  throw new ProviderTransferError(`Invalid stage (${stage}) provided for the current flow`, {
3503
3428
  step: nextStep
3504
3429
  });
3505
3430
  }
3506
- (_c = this.flow) == null ? void 0 : _c.set({ ...nextStep, locked: true });
3431
+ this.flow?.set({ ...nextStep, locked: true });
3507
3432
  },
3508
3433
  unlockTransferStep(stage) {
3509
- var _a, _b, _c;
3510
- const currentStep = (_a = this.flow) == null ? void 0 : _a.get();
3434
+ const currentStep = this.flow?.get();
3511
3435
  const nextStep = { kind: "transfer", stage };
3512
- if ((currentStep == null ? void 0 : currentStep.kind) === "transfer" && !currentStep.locked) {
3436
+ if (currentStep?.kind === "transfer" && !currentStep.locked) {
3513
3437
  throw new ProviderTransferError(
3514
3438
  `You need to initialize the transfer stage (${stage}) before ending it`
3515
3439
  );
3516
3440
  }
3517
- if ((_b = this.flow) == null ? void 0 : _b.cannot(nextStep)) {
3441
+ if (this.flow?.cannot(nextStep)) {
3518
3442
  throw new ProviderTransferError(`Invalid stage (${stage}) provided for the current flow`, {
3519
3443
  step: nextStep
3520
3444
  });
3521
3445
  }
3522
- (_c = this.flow) == null ? void 0 : _c.set({ ...nextStep, locked: false });
3446
+ this.flow?.set({ ...nextStep, locked: false });
3523
3447
  },
3524
3448
  async onTransferStep(msg) {
3525
- var _a, _b, _c, _d;
3526
3449
  const { step: stage } = msg;
3527
3450
  if (msg.action === "start") {
3528
3451
  this.lockTransferStep(stage);
3529
- if (((_a = this.streams) == null ? void 0 : _a[stage]) instanceof Writable) {
3452
+ if (this.streams?.[stage] instanceof Writable) {
3530
3453
  throw new Error("Stream already created, something went wrong");
3531
3454
  }
3532
3455
  await this.createWritableStreamForStep(stage);
@@ -3534,7 +3457,7 @@ const createPushController = handlerControllerFactory((proto) => ({
3534
3457
  }
3535
3458
  if (msg.action === "stream") {
3536
3459
  this.assertValidStreamTransferStep(stage);
3537
- const stream2 = (_b = this.streams) == null ? void 0 : _b[stage];
3460
+ const stream2 = this.streams?.[stage];
3538
3461
  if (!stream2) {
3539
3462
  throw new Error("You need to init first");
3540
3463
  }
@@ -3545,37 +3468,35 @@ const createPushController = handlerControllerFactory((proto) => ({
3545
3468
  }
3546
3469
  if (msg.action === "end") {
3547
3470
  this.unlockTransferStep(stage);
3548
- const stream2 = (_c = this.streams) == null ? void 0 : _c[stage];
3471
+ const stream2 = this.streams?.[stage];
3549
3472
  if (stream2 && !stream2.closed) {
3550
3473
  await new Promise((resolve, reject2) => {
3551
3474
  stream2.on("close", resolve).on("error", reject2).end();
3552
3475
  });
3553
3476
  }
3554
- (_d = this.streams) == null ? true : delete _d[stage];
3477
+ delete this.streams?.[stage];
3555
3478
  return { ok: true };
3556
3479
  }
3557
3480
  },
3558
3481
  async onTransferAction(msg) {
3559
- var _a, _b, _c, _d;
3560
3482
  const { action: action2 } = msg;
3561
3483
  this.assertValidTransferAction(action2);
3562
3484
  const step = { kind: "action", action: action2 };
3563
- const isStepRegistered = (_a = this.flow) == null ? void 0 : _a.has(step);
3485
+ const isStepRegistered = this.flow?.has(step);
3564
3486
  if (isStepRegistered) {
3565
- if ((_b = this.flow) == null ? void 0 : _b.cannot(step)) {
3487
+ if (this.flow?.cannot(step)) {
3566
3488
  throw new ProviderTransferError(`Invalid action "${action2}" found for the current flow `, {
3567
3489
  action: action2
3568
3490
  });
3569
3491
  }
3570
- (_c = this.flow) == null ? void 0 : _c.set(step);
3492
+ this.flow?.set(step);
3571
3493
  }
3572
- return (_d = this.provider) == null ? void 0 : _d[action2]();
3494
+ return this.provider?.[action2]();
3573
3495
  },
3574
3496
  async streamAsset(payload) {
3575
- var _a, _b, _c;
3576
- const assetsStream = (_a = this.streams) == null ? void 0 : _a.assets;
3497
+ const assetsStream = this.streams?.assets;
3577
3498
  if (payload === null) {
3578
- (_c = (_b = this.streams) == null ? void 0 : _b.assets) == null ? void 0 : _c.end();
3499
+ this.streams?.assets?.end();
3579
3500
  return;
3580
3501
  }
3581
3502
  for (const item of payload) {
@@ -3645,7 +3566,7 @@ const createPushController = handlerControllerFactory((proto) => ({
3645
3566
  },
3646
3567
  async end(params) {
3647
3568
  await this.verifyAuth();
3648
- if (this.transferID !== (params == null ? void 0 : params.transferID)) {
3569
+ if (this.transferID !== params?.transferID) {
3649
3570
  throw new ProviderTransferError("Bad transfer ID provided");
3650
3571
  }
3651
3572
  this.cleanup();
@@ -3686,8 +3607,8 @@ const createPullController = handlerControllerFactory((proto) => ({
3686
3607
  }
3687
3608
  if (proto.hasUUID(msg.uuid)) {
3688
3609
  const previousResponse = proto.response;
3689
- if ((previousResponse == null ? void 0 : previousResponse.uuid) === msg.uuid) {
3690
- await this.respond(previousResponse == null ? void 0 : previousResponse.uuid, previousResponse.e, previousResponse.data);
3610
+ if (previousResponse?.uuid === msg.uuid) {
3611
+ await this.respond(previousResponse?.uuid, previousResponse.e, previousResponse.data);
3691
3612
  }
3692
3613
  return;
3693
3614
  }
@@ -3722,16 +3643,14 @@ const createPullController = handlerControllerFactory((proto) => ({
3722
3643
  }
3723
3644
  },
3724
3645
  async onTransferAction(msg) {
3725
- var _a;
3726
3646
  const { action: action2 } = msg;
3727
3647
  this.assertValidTransferAction(action2);
3728
- return (_a = this.provider) == null ? void 0 : _a[action2]();
3648
+ return this.provider?.[action2]();
3729
3649
  },
3730
3650
  async flush(stage, id) {
3731
- var _a;
3732
3651
  const batchSize = 1024 * 1024;
3733
3652
  let batch = [];
3734
- const stream2 = (_a = this.streams) == null ? void 0 : _a[stage];
3653
+ const stream2 = this.streams?.[stage];
3735
3654
  const batchLength = () => Buffer.byteLength(JSON.stringify(batch));
3736
3655
  const sendBatch = async () => {
3737
3656
  await this.confirm({
@@ -3763,10 +3682,9 @@ const createPullController = handlerControllerFactory((proto) => ({
3763
3682
  }
3764
3683
  },
3765
3684
  async onTransferStep(msg) {
3766
- var _a, _b, _c;
3767
3685
  const { step, action: action2 } = msg;
3768
3686
  if (action2 === "start") {
3769
- if (((_a = this.streams) == null ? void 0 : _a[step]) instanceof Readable) {
3687
+ if (this.streams?.[step] instanceof Readable) {
3770
3688
  throw new Error("Stream already created, something went wrong");
3771
3689
  }
3772
3690
  const flushUUID = randomUUID();
@@ -3775,33 +3693,23 @@ const createPullController = handlerControllerFactory((proto) => ({
3775
3693
  return { ok: true, id: flushUUID };
3776
3694
  }
3777
3695
  if (action2 === "end") {
3778
- const stream2 = (_b = this.streams) == null ? void 0 : _b[step];
3779
- if ((stream2 == null ? void 0 : stream2.readableEnded) === false) {
3696
+ const stream2 = this.streams?.[step];
3697
+ if (stream2?.readableEnded === false) {
3780
3698
  await new Promise((resolve) => {
3781
- stream2 == null ? void 0 : stream2.on("close", resolve).destroy();
3699
+ stream2?.on("close", resolve).destroy();
3782
3700
  });
3783
3701
  }
3784
- (_c = this.streams) == null ? true : delete _c[step];
3702
+ delete this.streams?.[step];
3785
3703
  return { ok: true };
3786
3704
  }
3787
3705
  },
3788
3706
  async createReadableStreamForStep(step) {
3789
3707
  const mapper = {
3790
- entities: () => {
3791
- var _a;
3792
- return (_a = this.provider) == null ? void 0 : _a.createEntitiesReadStream();
3793
- },
3794
- links: () => {
3795
- var _a;
3796
- return (_a = this.provider) == null ? void 0 : _a.createLinksReadStream();
3797
- },
3798
- configuration: () => {
3799
- var _a;
3800
- return (_a = this.provider) == null ? void 0 : _a.createConfigurationReadStream();
3801
- },
3708
+ entities: () => this.provider?.createEntitiesReadStream(),
3709
+ links: () => this.provider?.createLinksReadStream(),
3710
+ configuration: () => this.provider?.createConfigurationReadStream(),
3802
3711
  assets: () => {
3803
- var _a;
3804
- const assets = (_a = this.provider) == null ? void 0 : _a.createAssetsReadStream();
3712
+ const assets = this.provider?.createAssetsReadStream();
3805
3713
  let batch = [];
3806
3714
  const batchLength = () => {
3807
3715
  return batch.reduce(
@@ -3864,7 +3772,7 @@ const createPullController = handlerControllerFactory((proto) => ({
3864
3772
  },
3865
3773
  async end(params) {
3866
3774
  await this.verifyAuth();
3867
- if (this.transferID !== (params == null ? void 0 : params.transferID)) {
3775
+ if (this.transferID !== params?.transferID) {
3868
3776
  throw new ProviderTransferError("Bad transfer ID provided");
3869
3777
  }
3870
3778
  this.cleanup();
@@ -3936,12 +3844,11 @@ class LocalFileSourceProvider {
3936
3844
  * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
3937
3845
  */
3938
3846
  async bootstrap() {
3939
- var _a, _b;
3940
3847
  const { path: filePath } = this.options.file;
3941
3848
  try {
3942
3849
  await this.#loadMetadata();
3943
3850
  } catch (e) {
3944
- if ((_b = (_a = this.options) == null ? void 0 : _a.encryption) == null ? void 0 : _b.enabled) {
3851
+ if (this.options?.encryption?.enabled) {
3945
3852
  throw new ProviderInitializationError(
3946
3853
  `Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`
3947
3854
  );
@@ -4690,11 +4597,11 @@ const loadersFactory = (defaultLoaders = {}) => {
4690
4597
  createLoader(stage);
4691
4598
  }
4692
4599
  const stageData = data[stage];
4693
- const elapsedTime = (stageData == null ? void 0 : stageData.startTime) ? ((stageData == null ? void 0 : stageData.endTime) || Date.now()) - stageData.startTime : 0;
4694
- const size2 = `size: ${readableBytes((stageData == null ? void 0 : stageData.bytes) ?? 0)}`;
4600
+ const elapsedTime = stageData?.startTime ? (stageData?.endTime || Date.now()) - stageData.startTime : 0;
4601
+ const size2 = `size: ${readableBytes(stageData?.bytes ?? 0)}`;
4695
4602
  const elapsed = `elapsed: ${elapsedTime} ms`;
4696
- const speed = elapsedTime > 0 ? `(${readableBytes(((stageData == null ? void 0 : stageData.bytes) ?? 0) * 1e3 / elapsedTime)}/s)` : "";
4697
- loaders[stage].text = `${stage}: ${(stageData == null ? void 0 : stageData.count) ?? 0} transfered (${size2}) (${elapsed}) ${!(stageData == null ? void 0 : stageData.endTime) ? speed : ""}`;
4603
+ const speed = elapsedTime > 0 ? `(${readableBytes((stageData?.bytes ?? 0) * 1e3 / elapsedTime)}/s)` : "";
4604
+ loaders[stage].text = `${stage}: ${stageData?.count ?? 0} transfered (${size2}) (${elapsed}) ${!stageData?.endTime ? speed : ""}`;
4698
4605
  return loaders[stage];
4699
4606
  };
4700
4607
  const createLoader = (stage) => {
@@ -4711,11 +4618,10 @@ const loadersFactory = (defaultLoaders = {}) => {
4711
4618
  };
4712
4619
  };
4713
4620
  const getTransferTelemetryPayload = (engine) => {
4714
- var _a, _b;
4715
4621
  return {
4716
4622
  eventProperties: {
4717
- source: (_a = engine == null ? void 0 : engine.sourceProvider) == null ? void 0 : _a.name,
4718
- destination: (_b = engine == null ? void 0 : engine.destinationProvider) == null ? void 0 : _b.name
4623
+ source: engine?.sourceProvider?.name,
4624
+ destination: engine?.destinationProvider?.name
4719
4625
  }
4720
4626
  };
4721
4627
  };
@@ -4734,7 +4640,7 @@ const getDiffHandler = (engine, {
4734
4640
  for (const diff2 of diffs) {
4735
4641
  const path2 = [uid].concat(diff2.path).join(".");
4736
4642
  const endPath = diff2.path[diff2.path.length - 1];
4737
- if (uid === "admin::workflow" || uid === "admin::workflow-stage" || (endPath == null ? void 0 : endPath.startsWith("strapi_stage")) || (endPath == null ? void 0 : endPath.startsWith("strapi_assignee"))) {
4643
+ if (uid === "admin::workflow" || uid === "admin::workflow-stage" || endPath?.startsWith("strapi_stage") || endPath?.startsWith("strapi_assignee")) {
4738
4644
  workflowsStatus = diff2.kind;
4739
4645
  } else if (diff2.kind === "added") {
4740
4646
  engine.reportWarning(chalk.red(`${chalk.bold(path2)} does not exist on source`), source);
@@ -4799,8 +4705,7 @@ const getAssetsBackupHandler = (engine, {
4799
4705
  };
4800
4706
  };
4801
4707
  const shouldSkipStage = (opts, dataKind) => {
4802
- var _a;
4803
- if ((_a = opts.exclude) == null ? void 0 : _a.includes(dataKind)) {
4708
+ if (opts.exclude?.includes(dataKind)) {
4804
4709
  return true;
4805
4710
  }
4806
4711
  if (opts.only) {
@@ -4809,12 +4714,11 @@ const shouldSkipStage = (opts, dataKind) => {
4809
4714
  return false;
4810
4715
  };
4811
4716
  const parseRestoreFromOptions = (opts) => {
4812
- var _a;
4813
4717
  const entitiesOptions = {
4814
4718
  exclude: DEFAULT_IGNORED_CONTENT_TYPES,
4815
4719
  include: void 0
4816
4720
  };
4817
- if (opts.only && !opts.only.includes("content") || ((_a = opts.exclude) == null ? void 0 : _a.includes("content"))) {
4721
+ if (opts.only && !opts.only.includes("content") || opts.exclude?.includes("content")) {
4818
4722
  entitiesOptions.include = [];
4819
4723
  }
4820
4724
  const restoreConfig = {
@@ -4835,7 +4739,6 @@ const {
4835
4739
  } = strapiDatatransfer;
4836
4740
  const BYTES_IN_MB = 1024 * 1024;
4837
4741
  const action$2 = async (opts) => {
4838
- var _a, _b;
4839
4742
  if (!isObject(opts)) {
4840
4743
  exitWith(1, "Could not parse command arguments");
4841
4744
  }
@@ -4888,7 +4791,7 @@ const action$2 = async (opts) => {
4888
4791
  try {
4889
4792
  setSignalHandler(() => abortTransfer({ engine, strapi: strapi2 }));
4890
4793
  results = await engine.transfer();
4891
- outFile = ((_b = (_a = results.destination) == null ? void 0 : _a.file) == null ? void 0 : _b.path) ?? "";
4794
+ outFile = results.destination?.file?.path ?? "";
4892
4795
  const outFileExists = await fse__default.pathExists(outFile);
4893
4796
  if (!outFileExists) {
4894
4797
  throw new TransferEngineTransferError(`Export file not created "${outFile}"`);
@@ -4896,7 +4799,7 @@ const action$2 = async (opts) => {
4896
4799
  await strapi2.telemetry.send("didDEITSProcessFinish", getTransferTelemetryPayload(engine));
4897
4800
  try {
4898
4801
  const table = buildTransferTable(results.engine);
4899
- console.log(table == null ? void 0 : table.toString());
4802
+ console.log(table?.toString());
4900
4803
  } catch (e) {
4901
4804
  console.error("There was an error displaying the results of the transfer.");
4902
4805
  }
@@ -5019,7 +4922,7 @@ const action$1 = async (opts) => {
5019
4922
  results = await engine2.transfer();
5020
4923
  try {
5021
4924
  const table = buildTransferTable(results.engine);
5022
- console.log(table == null ? void 0 : table.toString());
4925
+ console.log(table?.toString());
5023
4926
  } catch (e) {
5024
4927
  console.error("There was an error displaying the results of the transfer.");
5025
4928
  }
@@ -5052,7 +4955,6 @@ const command$1 = ({ command: command2 }) => {
5052
4955
  "Provide encryption key in command instead of using the prompt"
5053
4956
  )
5054
4957
  ).addOption(forceOption).addOption(excludeOption).addOption(onlyOption).addOption(throttleOption).hook("preAction", validateExcludeOnly).hook("preAction", async (thisCommand) => {
5055
- var _a;
5056
4958
  const opts = thisCommand.opts();
5057
4959
  const ext = path.extname(String(opts.file));
5058
4960
  if (ext === ".enc") {
@@ -5064,7 +4966,7 @@ const command$1 = ({ command: command2 }) => {
5064
4966
  name: "key"
5065
4967
  }
5066
4968
  ]);
5067
- if (!((_a = answers.key) == null ? void 0 : _a.length)) {
4969
+ if (!answers.key?.length) {
5068
4970
  exitWith(1, "No key entered, aborting import.");
5069
4971
  }
5070
4972
  opts.key = answers.key;
@@ -5213,7 +5115,7 @@ const action = async (opts) => {
5213
5115
  await strapi2.telemetry.send("didDEITSProcessFinish", getTransferTelemetryPayload(engine));
5214
5116
  try {
5215
5117
  const table = buildTransferTable(results.engine);
5216
- console.log(table == null ? void 0 : table.toString());
5118
+ console.log(table?.toString());
5217
5119
  } catch (e) {
5218
5120
  console.error("There was an error displaying the results of the transfer.");
5219
5121
  }
@@ -5248,7 +5150,6 @@ const command = ({ command: command2 }) => {
5248
5150
  ifOptions(
5249
5151
  (opts) => opts.from,
5250
5152
  async (thisCommand) => {
5251
- var _a;
5252
5153
  assertUrlHasProtocol(thisCommand.opts().from, ["https:", "http:"]);
5253
5154
  if (!thisCommand.opts().fromToken) {
5254
5155
  const answers = await inquirer.prompt([
@@ -5258,7 +5159,7 @@ const command = ({ command: command2 }) => {
5258
5159
  name: "fromToken"
5259
5160
  }
5260
5161
  ]);
5261
- if (!((_a = answers.fromToken) == null ? void 0 : _a.length)) {
5162
+ if (!answers.fromToken?.length) {
5262
5163
  exitWith(1, "No token provided for remote source, aborting transfer.");
5263
5164
  }
5264
5165
  thisCommand.opts().fromToken = answers.fromToken;
@@ -5274,7 +5175,6 @@ const command = ({ command: command2 }) => {
5274
5175
  ifOptions(
5275
5176
  (opts) => opts.to,
5276
5177
  async (thisCommand) => {
5277
- var _a;
5278
5178
  assertUrlHasProtocol(thisCommand.opts().to, ["https:", "http:"]);
5279
5179
  if (!thisCommand.opts().toToken) {
5280
5180
  const answers = await inquirer.prompt([
@@ -5284,7 +5184,7 @@ const command = ({ command: command2 }) => {
5284
5184
  name: "toToken"
5285
5185
  }
5286
5186
  ]);
5287
- if (!((_a = answers.toToken) == null ? void 0 : _a.length)) {
5187
+ if (!answers.toToken?.length) {
5288
5188
  exitWith(1, "No token provided for remote destination, aborting transfer.");
5289
5189
  }
5290
5190
  thisCommand.opts().toToken = answers.toToken;