@strapi/data-transfer 4.14.5 → 4.15.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.
- package/dist/index.js +190 -292
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +190 -292
- package/dist/index.mjs.map +1 -1
- package/dist/strapi/remote/handlers/push.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -247,13 +247,13 @@ const createTransaction = (strapi2) => {
|
|
|
247
247
|
const e = new events.EventEmitter();
|
|
248
248
|
e.on("spawn", (uuid, cb) => {
|
|
249
249
|
fns.push({ fn: cb, uuid });
|
|
250
|
-
resume
|
|
250
|
+
resume?.();
|
|
251
251
|
});
|
|
252
252
|
e.on("close", () => {
|
|
253
253
|
e.removeAllListeners("rollback");
|
|
254
254
|
e.removeAllListeners("spawn");
|
|
255
255
|
done = true;
|
|
256
|
-
resume
|
|
256
|
+
resume?.();
|
|
257
257
|
});
|
|
258
258
|
strapi2.db.transaction(async ({ trx, rollback }) => {
|
|
259
259
|
e.once("rollback", async () => {
|
|
@@ -266,7 +266,7 @@ const createTransaction = (strapi2) => {
|
|
|
266
266
|
e.emit("rollback_failed");
|
|
267
267
|
} finally {
|
|
268
268
|
done = true;
|
|
269
|
-
resume
|
|
269
|
+
resume?.();
|
|
270
270
|
}
|
|
271
271
|
});
|
|
272
272
|
while (!done) {
|
|
@@ -351,13 +351,12 @@ const isAttributeIgnorable = (diff2) => {
|
|
|
351
351
|
["private", "required", "configurable"].includes(diff2.path[2]);
|
|
352
352
|
};
|
|
353
353
|
const isOptionalAdminType = (diff2) => {
|
|
354
|
-
var _a, _b, _c, _d;
|
|
355
354
|
if ("value" in diff2 && fp.isObject(diff2.value)) {
|
|
356
|
-
const name =
|
|
355
|
+
const name = diff2?.value?.info?.singularName;
|
|
357
356
|
return OPTIONAL_CONTENT_TYPES.includes(name);
|
|
358
357
|
}
|
|
359
358
|
if ("values" in diff2 && fp.isArray(diff2.values) && fp.isObject(diff2.values[0])) {
|
|
360
|
-
const name =
|
|
359
|
+
const name = diff2?.values[0]?.info?.singularName;
|
|
361
360
|
return OPTIONAL_CONTENT_TYPES.includes(name);
|
|
362
361
|
}
|
|
363
362
|
return false;
|
|
@@ -546,21 +545,18 @@ class TransferEngine {
|
|
|
546
545
|
errors: {}
|
|
547
546
|
};
|
|
548
547
|
onSchemaDiff(handler) {
|
|
549
|
-
|
|
550
|
-
(_b = (_a = this.#handlers) == null ? void 0 : _a.schemaDiff) == null ? void 0 : _b.push(handler);
|
|
548
|
+
this.#handlers?.schemaDiff?.push(handler);
|
|
551
549
|
}
|
|
552
550
|
addErrorHandler(handlerName, handler) {
|
|
553
|
-
var _a;
|
|
554
551
|
if (!this.#handlers.errors[handlerName]) {
|
|
555
552
|
this.#handlers.errors[handlerName] = [];
|
|
556
553
|
}
|
|
557
|
-
|
|
554
|
+
this.#handlers.errors[handlerName]?.push(handler);
|
|
558
555
|
}
|
|
559
556
|
async attemptResolveError(error) {
|
|
560
|
-
var _a, _b;
|
|
561
557
|
const context = {};
|
|
562
|
-
if (error instanceof ProviderTransferError &&
|
|
563
|
-
const errorCode =
|
|
558
|
+
if (error instanceof ProviderTransferError && error.details?.details.code) {
|
|
559
|
+
const errorCode = error.details?.details.code;
|
|
564
560
|
if (!this.#handlers.errors[errorCode]) {
|
|
565
561
|
this.#handlers.errors[errorCode] = [];
|
|
566
562
|
}
|
|
@@ -625,10 +621,9 @@ class TransferEngine {
|
|
|
625
621
|
* Allowed transformations includes 'filter' and 'map'.
|
|
626
622
|
*/
|
|
627
623
|
#createStageTransformStream(key, options = {}) {
|
|
628
|
-
var _a;
|
|
629
624
|
const { includeGlobal = true } = options;
|
|
630
625
|
const { throttle } = this.options;
|
|
631
|
-
const { global: globalTransforms, [key]: stageTransforms } =
|
|
626
|
+
const { global: globalTransforms, [key]: stageTransforms } = this.options?.transforms ?? {};
|
|
632
627
|
let stream2 = new stream$1.PassThrough({ objectMode: true });
|
|
633
628
|
const applyTransforms = (transforms = []) => {
|
|
634
629
|
const chainTransforms = [];
|
|
@@ -669,7 +664,6 @@ class TransferEngine {
|
|
|
669
664
|
* Providing aggregate options enable custom computation to get the size (bytes) or the aggregate key associated with the data
|
|
670
665
|
*/
|
|
671
666
|
#updateTransferProgress(stage, data, aggregate) {
|
|
672
|
-
var _a, _b;
|
|
673
667
|
if (!this.progress.data[stage]) {
|
|
674
668
|
this.progress.data[stage] = { count: 0, bytes: 0, startTime: Date.now() };
|
|
675
669
|
}
|
|
@@ -677,8 +671,8 @@ class TransferEngine {
|
|
|
677
671
|
if (!stageProgress) {
|
|
678
672
|
return;
|
|
679
673
|
}
|
|
680
|
-
const size =
|
|
681
|
-
const key =
|
|
674
|
+
const size = aggregate?.size?.(data) ?? JSON.stringify(data).length;
|
|
675
|
+
const key = aggregate?.key?.(data);
|
|
682
676
|
stageProgress.count += 1;
|
|
683
677
|
stageProgress.bytes += size;
|
|
684
678
|
if (key) {
|
|
@@ -899,21 +893,19 @@ ${formattedDiffs}`,
|
|
|
899
893
|
this.#currentStream.destroy(err);
|
|
900
894
|
}
|
|
901
895
|
async init() {
|
|
902
|
-
var _a, _b;
|
|
903
896
|
await this.#resolveProviderResource();
|
|
904
897
|
const { source: sourceMetadata } = this.#metadata;
|
|
905
898
|
if (sourceMetadata) {
|
|
906
|
-
|
|
899
|
+
this.destinationProvider.setMetadata?.("source", sourceMetadata);
|
|
907
900
|
}
|
|
908
901
|
}
|
|
909
902
|
/**
|
|
910
903
|
* Run the bootstrap method in both source and destination providers
|
|
911
904
|
*/
|
|
912
905
|
async bootstrap() {
|
|
913
|
-
var _a, _b, _c, _d;
|
|
914
906
|
const results = await Promise.allSettled([
|
|
915
|
-
|
|
916
|
-
|
|
907
|
+
this.sourceProvider.bootstrap?.(),
|
|
908
|
+
this.destinationProvider.bootstrap?.()
|
|
917
909
|
]);
|
|
918
910
|
results.forEach((result) => {
|
|
919
911
|
if (result.status === "rejected") {
|
|
@@ -925,10 +917,9 @@ ${formattedDiffs}`,
|
|
|
925
917
|
* Run the close method in both source and destination providers
|
|
926
918
|
*/
|
|
927
919
|
async close() {
|
|
928
|
-
var _a, _b, _c, _d;
|
|
929
920
|
const results = await Promise.allSettled([
|
|
930
|
-
|
|
931
|
-
|
|
921
|
+
this.sourceProvider.close?.(),
|
|
922
|
+
this.destinationProvider.close?.()
|
|
932
923
|
]);
|
|
933
924
|
results.forEach((result) => {
|
|
934
925
|
if (result.status === "rejected") {
|
|
@@ -947,12 +938,11 @@ ${formattedDiffs}`,
|
|
|
947
938
|
}
|
|
948
939
|
}
|
|
949
940
|
async #getSchemas() {
|
|
950
|
-
var _a, _b, _c, _d;
|
|
951
941
|
if (!this.#schema.source) {
|
|
952
|
-
this.#schema.source = await
|
|
942
|
+
this.#schema.source = await this.sourceProvider.getSchemas?.();
|
|
953
943
|
}
|
|
954
944
|
if (!this.#schema.destination) {
|
|
955
|
-
this.#schema.destination = await
|
|
945
|
+
this.#schema.destination = await this.destinationProvider.getSchemas?.();
|
|
956
946
|
}
|
|
957
947
|
return {
|
|
958
948
|
sourceSchemas: this.#schema.source,
|
|
@@ -960,13 +950,12 @@ ${formattedDiffs}`,
|
|
|
960
950
|
};
|
|
961
951
|
}
|
|
962
952
|
async integrityCheck() {
|
|
963
|
-
var _a, _b, _c, _d, _e, _f;
|
|
964
953
|
const sourceMetadata = await this.sourceProvider.getMetadata();
|
|
965
954
|
const destinationMetadata = await this.destinationProvider.getMetadata();
|
|
966
955
|
if (sourceMetadata && destinationMetadata) {
|
|
967
956
|
this.#assertStrapiVersionIntegrity(
|
|
968
|
-
|
|
969
|
-
|
|
957
|
+
sourceMetadata?.strapi?.version,
|
|
958
|
+
destinationMetadata?.strapi?.version
|
|
970
959
|
);
|
|
971
960
|
}
|
|
972
961
|
const { sourceSchemas, destinationSchemas } = await this.#getSchemas();
|
|
@@ -975,8 +964,8 @@ ${formattedDiffs}`,
|
|
|
975
964
|
this.#assertSchemasMatching(sourceSchemas, destinationSchemas);
|
|
976
965
|
}
|
|
977
966
|
} catch (error) {
|
|
978
|
-
if (error instanceof TransferEngineValidationError &&
|
|
979
|
-
const schemaDiffs =
|
|
967
|
+
if (error instanceof TransferEngineValidationError && error.details?.details?.diffs) {
|
|
968
|
+
const schemaDiffs = error.details?.details?.diffs;
|
|
980
969
|
const context = {
|
|
981
970
|
ignoredDiffs: {},
|
|
982
971
|
diffs: schemaDiffs,
|
|
@@ -1005,7 +994,6 @@ ${formattedDiffs}`,
|
|
|
1005
994
|
}
|
|
1006
995
|
}
|
|
1007
996
|
async transfer() {
|
|
1008
|
-
var _a, _b;
|
|
1009
997
|
this.progress.data = {};
|
|
1010
998
|
try {
|
|
1011
999
|
this.#emitTransferUpdate("init");
|
|
@@ -1027,7 +1015,7 @@ ${formattedDiffs}`,
|
|
|
1027
1015
|
if (e instanceof Error && (!lastDiagnostic || lastDiagnostic.kind !== "error" || lastDiagnostic.details.error !== e)) {
|
|
1028
1016
|
this.reportError(e, e.severity || "fatal");
|
|
1029
1017
|
}
|
|
1030
|
-
await
|
|
1018
|
+
await this.destinationProvider.rollback?.(e);
|
|
1031
1019
|
throw e;
|
|
1032
1020
|
}
|
|
1033
1021
|
return {
|
|
@@ -1038,9 +1026,8 @@ ${formattedDiffs}`,
|
|
|
1038
1026
|
}
|
|
1039
1027
|
async beforeTransfer() {
|
|
1040
1028
|
const runWithDiagnostic = async (provider) => {
|
|
1041
|
-
var _a;
|
|
1042
1029
|
try {
|
|
1043
|
-
await
|
|
1030
|
+
await provider.beforeTransfer?.();
|
|
1044
1031
|
} catch (error) {
|
|
1045
1032
|
if (error instanceof Error) {
|
|
1046
1033
|
const resolved = await this.attemptResolveError(error);
|
|
@@ -1059,13 +1046,12 @@ ${formattedDiffs}`,
|
|
|
1059
1046
|
await runWithDiagnostic(this.destinationProvider);
|
|
1060
1047
|
}
|
|
1061
1048
|
async transferSchemas() {
|
|
1062
|
-
var _a, _b, _c, _d;
|
|
1063
1049
|
const stage = "schemas";
|
|
1064
1050
|
if (this.shouldSkipStage(stage)) {
|
|
1065
1051
|
return;
|
|
1066
1052
|
}
|
|
1067
|
-
const source = await
|
|
1068
|
-
const destination = await
|
|
1053
|
+
const source = await this.sourceProvider.createSchemasReadStream?.();
|
|
1054
|
+
const destination = await this.destinationProvider.createSchemasWriteStream?.();
|
|
1069
1055
|
const transform = this.#createStageTransformStream(stage);
|
|
1070
1056
|
const tracker = this.#progressTracker(stage, {
|
|
1071
1057
|
key: (value) => value.modelType
|
|
@@ -1073,13 +1059,12 @@ ${formattedDiffs}`,
|
|
|
1073
1059
|
await this.#transferStage({ stage, source, destination, transform, tracker });
|
|
1074
1060
|
}
|
|
1075
1061
|
async transferEntities() {
|
|
1076
|
-
var _a, _b, _c, _d;
|
|
1077
1062
|
const stage = "entities";
|
|
1078
1063
|
if (this.shouldSkipStage(stage)) {
|
|
1079
1064
|
return;
|
|
1080
1065
|
}
|
|
1081
|
-
const source = await
|
|
1082
|
-
const destination = await
|
|
1066
|
+
const source = await this.sourceProvider.createEntitiesReadStream?.();
|
|
1067
|
+
const destination = await this.destinationProvider.createEntitiesWriteStream?.();
|
|
1083
1068
|
const transform = streamChain.chain([
|
|
1084
1069
|
this.#createStageTransformStream(stage),
|
|
1085
1070
|
new stream$1.Transform({
|
|
@@ -1105,13 +1090,12 @@ ${formattedDiffs}`,
|
|
|
1105
1090
|
await this.#transferStage({ stage, source, destination, transform, tracker });
|
|
1106
1091
|
}
|
|
1107
1092
|
async transferLinks() {
|
|
1108
|
-
var _a, _b, _c, _d;
|
|
1109
1093
|
const stage = "links";
|
|
1110
1094
|
if (this.shouldSkipStage(stage)) {
|
|
1111
1095
|
return;
|
|
1112
1096
|
}
|
|
1113
|
-
const source = await
|
|
1114
|
-
const destination = await
|
|
1097
|
+
const source = await this.sourceProvider.createLinksReadStream?.();
|
|
1098
|
+
const destination = await this.destinationProvider.createLinksWriteStream?.();
|
|
1115
1099
|
const transform = streamChain.chain([
|
|
1116
1100
|
this.#createStageTransformStream(stage),
|
|
1117
1101
|
new stream$1.Transform({
|
|
@@ -1134,13 +1118,12 @@ ${formattedDiffs}`,
|
|
|
1134
1118
|
await this.#transferStage({ stage, source, destination, transform, tracker });
|
|
1135
1119
|
}
|
|
1136
1120
|
async transferAssets() {
|
|
1137
|
-
var _a, _b, _c, _d;
|
|
1138
1121
|
const stage = "assets";
|
|
1139
1122
|
if (this.shouldSkipStage(stage)) {
|
|
1140
1123
|
return;
|
|
1141
1124
|
}
|
|
1142
|
-
const source = await
|
|
1143
|
-
const destination = await
|
|
1125
|
+
const source = await this.sourceProvider.createAssetsReadStream?.();
|
|
1126
|
+
const destination = await this.destinationProvider.createAssetsWriteStream?.();
|
|
1144
1127
|
const transform = this.#createStageTransformStream(stage);
|
|
1145
1128
|
const tracker = this.#progressTracker(stage, {
|
|
1146
1129
|
size: (value) => value.stats.size,
|
|
@@ -1149,13 +1132,12 @@ ${formattedDiffs}`,
|
|
|
1149
1132
|
await this.#transferStage({ stage, source, destination, transform, tracker });
|
|
1150
1133
|
}
|
|
1151
1134
|
async transferConfiguration() {
|
|
1152
|
-
var _a, _b, _c, _d;
|
|
1153
1135
|
const stage = "configuration";
|
|
1154
1136
|
if (this.shouldSkipStage(stage)) {
|
|
1155
1137
|
return;
|
|
1156
1138
|
}
|
|
1157
|
-
const source = await
|
|
1158
|
-
const destination = await
|
|
1139
|
+
const source = await this.sourceProvider.createConfigurationReadStream?.();
|
|
1140
|
+
const destination = await this.destinationProvider.createConfigurationWriteStream?.();
|
|
1159
1141
|
const transform = this.#createStageTransformStream(stage);
|
|
1160
1142
|
const tracker = this.#progressTracker(stage);
|
|
1161
1143
|
await this.#transferStage({ stage, source, destination, transform, tracker });
|
|
@@ -1173,10 +1155,7 @@ const engineDatatransfer = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.
|
|
|
1173
1155
|
createTransferEngine: createTransferEngine$2,
|
|
1174
1156
|
errors
|
|
1175
1157
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1176
|
-
const isDialectMySQL = () =>
|
|
1177
|
-
var _a;
|
|
1178
|
-
return ((_a = strapi.db) == null ? void 0 : _a.dialect.client) === "mysql";
|
|
1179
|
-
};
|
|
1158
|
+
const isDialectMySQL = () => strapi.db?.dialect.client === "mysql";
|
|
1180
1159
|
function omitComponentData(contentType, data) {
|
|
1181
1160
|
const { attributes } = contentType;
|
|
1182
1161
|
const componentAttributes = Object.keys(attributes).filter(
|
|
@@ -1185,7 +1164,6 @@ function omitComponentData(contentType, data) {
|
|
|
1185
1164
|
return fp.omit(componentAttributes, data);
|
|
1186
1165
|
}
|
|
1187
1166
|
const createComponents = async (uid, data) => {
|
|
1188
|
-
var _a, _b;
|
|
1189
1167
|
const { attributes = {} } = strapi.getModel(uid);
|
|
1190
1168
|
const componentBody = {};
|
|
1191
1169
|
const attributeNames = Object.keys(attributes);
|
|
@@ -1207,7 +1185,7 @@ const createComponents = async (uid, data) => {
|
|
|
1207
1185
|
const components = await utils.mapAsync(
|
|
1208
1186
|
componentValue,
|
|
1209
1187
|
(value) => createComponent(componentUID, value),
|
|
1210
|
-
{ concurrency: isDialectMySQL() && !
|
|
1188
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
1211
1189
|
);
|
|
1212
1190
|
componentBody[attributeName] = components.map(({ id }) => {
|
|
1213
1191
|
return {
|
|
@@ -1251,7 +1229,7 @@ const createComponents = async (uid, data) => {
|
|
|
1251
1229
|
componentBody[attributeName] = await utils.mapAsync(
|
|
1252
1230
|
dynamiczoneValues,
|
|
1253
1231
|
createDynamicZoneComponents,
|
|
1254
|
-
{ concurrency: isDialectMySQL() && !
|
|
1232
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
1255
1233
|
);
|
|
1256
1234
|
continue;
|
|
1257
1235
|
}
|
|
@@ -1266,7 +1244,6 @@ const getComponents = async (uid, entity2) => {
|
|
|
1266
1244
|
return strapi.query(uid).load(entity2, componentAttributes);
|
|
1267
1245
|
};
|
|
1268
1246
|
const deleteComponents = async (uid, entityToDelete, { loadComponents = true } = {}) => {
|
|
1269
|
-
var _a, _b;
|
|
1270
1247
|
const { attributes = {} } = strapi.getModel(uid);
|
|
1271
1248
|
const attributeNames = Object.keys(attributes);
|
|
1272
1249
|
for (const attributeName of attributeNames) {
|
|
@@ -1287,14 +1264,14 @@ const deleteComponents = async (uid, entityToDelete, { loadComponents = true } =
|
|
|
1287
1264
|
___default.default.castArray(value),
|
|
1288
1265
|
(subValue) => deleteComponent(componentUID, subValue),
|
|
1289
1266
|
{
|
|
1290
|
-
concurrency: isDialectMySQL() && !
|
|
1267
|
+
concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity
|
|
1291
1268
|
}
|
|
1292
1269
|
);
|
|
1293
1270
|
} else {
|
|
1294
1271
|
await utils.mapAsync(
|
|
1295
1272
|
___default.default.castArray(value),
|
|
1296
1273
|
(subValue) => deleteComponent(subValue.__component, subValue),
|
|
1297
|
-
{ concurrency: isDialectMySQL() && !
|
|
1274
|
+
{ concurrency: isDialectMySQL() && !strapi.db?.inTransaction() ? 1 : Infinity }
|
|
1298
1275
|
);
|
|
1299
1276
|
}
|
|
1300
1277
|
continue;
|
|
@@ -1650,7 +1627,7 @@ const createEntitiesWriteStream = (options) => {
|
|
|
1650
1627
|
return new stream$1.Writable({
|
|
1651
1628
|
objectMode: true,
|
|
1652
1629
|
async write(entity2, _encoding, callback) {
|
|
1653
|
-
await
|
|
1630
|
+
await transaction2?.attach(async () => {
|
|
1654
1631
|
const { type, id, data } = entity2;
|
|
1655
1632
|
const { create, getDeepPopulateComponentLikeQuery } = query(type);
|
|
1656
1633
|
const contentType = strapi2.getModel(type);
|
|
@@ -1702,7 +1679,7 @@ const createEntitiesWriteStream = (options) => {
|
|
|
1702
1679
|
return callback(new ProviderTransferError(`Failed to create "${type}" (${id})`));
|
|
1703
1680
|
}
|
|
1704
1681
|
return callback(null);
|
|
1705
|
-
})
|
|
1682
|
+
});
|
|
1706
1683
|
}
|
|
1707
1684
|
});
|
|
1708
1685
|
};
|
|
@@ -1732,7 +1709,7 @@ const createConfigurationWriteStream = async (strapi2, transaction2) => {
|
|
|
1732
1709
|
return new stream$1.Writable({
|
|
1733
1710
|
objectMode: true,
|
|
1734
1711
|
async write(config, _encoding, callback) {
|
|
1735
|
-
await
|
|
1712
|
+
await transaction2?.attach(async () => {
|
|
1736
1713
|
try {
|
|
1737
1714
|
await restoreConfigs(strapi2, config);
|
|
1738
1715
|
} catch (error) {
|
|
@@ -1745,7 +1722,7 @@ const createConfigurationWriteStream = async (strapi2, transaction2) => {
|
|
|
1745
1722
|
);
|
|
1746
1723
|
}
|
|
1747
1724
|
callback();
|
|
1748
|
-
})
|
|
1725
|
+
});
|
|
1749
1726
|
}
|
|
1750
1727
|
});
|
|
1751
1728
|
};
|
|
@@ -1753,7 +1730,7 @@ const createLinksWriteStream = (mapID, strapi2, transaction2) => {
|
|
|
1753
1730
|
return new stream$1.Writable({
|
|
1754
1731
|
objectMode: true,
|
|
1755
1732
|
async write(link2, _encoding, callback) {
|
|
1756
|
-
await
|
|
1733
|
+
await transaction2?.attach(async (trx) => {
|
|
1757
1734
|
const { left, right } = link2;
|
|
1758
1735
|
const query = createLinkQuery(strapi2, trx);
|
|
1759
1736
|
left.ref = mapID(left.type, left.ref) ?? left.ref;
|
|
@@ -1771,7 +1748,7 @@ const createLinksWriteStream = (mapID, strapi2, transaction2) => {
|
|
|
1771
1748
|
);
|
|
1772
1749
|
}
|
|
1773
1750
|
callback(null);
|
|
1774
|
-
})
|
|
1751
|
+
});
|
|
1775
1752
|
}
|
|
1776
1753
|
});
|
|
1777
1754
|
};
|
|
@@ -1792,13 +1769,13 @@ const deleteEntitiesRecords = async (strapi2, options = {}) => {
|
|
|
1792
1769
|
);
|
|
1793
1770
|
const contentTypesToClear = contentTypes.filter((contentType) => {
|
|
1794
1771
|
let removeThisContentType = true;
|
|
1795
|
-
if (entities
|
|
1772
|
+
if (entities?.include) {
|
|
1796
1773
|
removeThisContentType = entities.include.includes(contentType.uid);
|
|
1797
1774
|
}
|
|
1798
|
-
if (
|
|
1775
|
+
if (entities?.exclude && entities.exclude.includes(contentType.uid)) {
|
|
1799
1776
|
removeThisContentType = false;
|
|
1800
1777
|
}
|
|
1801
|
-
if (entities
|
|
1778
|
+
if (entities?.filters) {
|
|
1802
1779
|
removeThisContentType = entities.filters.every((filter2) => filter2(contentType));
|
|
1803
1780
|
}
|
|
1804
1781
|
return removeThisContentType;
|
|
@@ -1807,7 +1784,7 @@ const deleteEntitiesRecords = async (strapi2, options = {}) => {
|
|
|
1807
1784
|
contentTypesToClear.map((contentType) => contentType.uid)
|
|
1808
1785
|
);
|
|
1809
1786
|
const deletePromises = contentTypesToClear.map(async (contentType) => {
|
|
1810
|
-
const result = await query(contentType.uid).deleteMany(entities
|
|
1787
|
+
const result = await query(contentType.uid).deleteMany(entities?.params);
|
|
1811
1788
|
if (result) {
|
|
1812
1789
|
updateResults(result.count || 0, contentType.uid);
|
|
1813
1790
|
}
|
|
@@ -1816,7 +1793,7 @@ const deleteEntitiesRecords = async (strapi2, options = {}) => {
|
|
|
1816
1793
|
return results;
|
|
1817
1794
|
};
|
|
1818
1795
|
const deleteConfigurationRecords = async (strapi2, options = {}) => {
|
|
1819
|
-
const { coreStore = true, webhook = true } =
|
|
1796
|
+
const { coreStore = true, webhook = true } = options?.configuration ?? {};
|
|
1820
1797
|
const models = [];
|
|
1821
1798
|
if (coreStore) {
|
|
1822
1799
|
models.push("strapi::core-store");
|
|
@@ -1883,21 +1860,18 @@ class LocalStrapiDestinationProvider {
|
|
|
1883
1860
|
}
|
|
1884
1861
|
// 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
|
|
1885
1862
|
#areAssetsIncluded = () => {
|
|
1886
|
-
|
|
1887
|
-
return (_a = this.options.restore) == null ? void 0 : _a.assets;
|
|
1863
|
+
return this.options.restore?.assets;
|
|
1888
1864
|
};
|
|
1889
1865
|
#isContentTypeIncluded = (type) => {
|
|
1890
|
-
|
|
1891
|
-
const
|
|
1892
|
-
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));
|
|
1866
|
+
const notIncluded = this.options.restore?.entities?.include && !this.options.restore?.entities?.include?.includes(type);
|
|
1867
|
+
const excluded = this.options.restore?.entities?.exclude && this.options.restore?.entities.exclude.includes(type);
|
|
1893
1868
|
return !excluded && !notIncluded;
|
|
1894
1869
|
};
|
|
1895
1870
|
async close() {
|
|
1896
|
-
var _a, _b;
|
|
1897
1871
|
const { autoDestroy } = this.options;
|
|
1898
|
-
|
|
1872
|
+
this.transaction?.end();
|
|
1899
1873
|
if (autoDestroy === void 0 || autoDestroy === true) {
|
|
1900
|
-
await
|
|
1874
|
+
await this.strapi?.destroy();
|
|
1901
1875
|
}
|
|
1902
1876
|
}
|
|
1903
1877
|
#validateOptions() {
|
|
@@ -1935,15 +1909,13 @@ class LocalStrapiDestinationProvider {
|
|
|
1935
1909
|
}
|
|
1936
1910
|
}
|
|
1937
1911
|
async rollback() {
|
|
1938
|
-
|
|
1939
|
-
await ((_a = this.transaction) == null ? void 0 : _a.rollback());
|
|
1912
|
+
await this.transaction?.rollback();
|
|
1940
1913
|
}
|
|
1941
1914
|
async beforeTransfer() {
|
|
1942
|
-
var _a;
|
|
1943
1915
|
if (!this.strapi) {
|
|
1944
1916
|
throw new Error("Strapi instance not found");
|
|
1945
1917
|
}
|
|
1946
|
-
await
|
|
1918
|
+
await this.transaction?.attach(async (trx) => {
|
|
1947
1919
|
try {
|
|
1948
1920
|
if (this.options.strategy === "restore") {
|
|
1949
1921
|
await this.#handleAssetsBackup();
|
|
@@ -1953,7 +1925,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1953
1925
|
} catch (error) {
|
|
1954
1926
|
throw new Error(`restore failed ${error}`);
|
|
1955
1927
|
}
|
|
1956
|
-
})
|
|
1928
|
+
});
|
|
1957
1929
|
}
|
|
1958
1930
|
getMetadata() {
|
|
1959
1931
|
assertValidStrapi(this.strapi, "Not able to get Schemas");
|
|
@@ -2060,8 +2032,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2060
2032
|
next();
|
|
2061
2033
|
},
|
|
2062
2034
|
async write(chunk, _encoding, callback) {
|
|
2063
|
-
await
|
|
2064
|
-
var _a;
|
|
2035
|
+
await transaction2?.attach(async () => {
|
|
2065
2036
|
if (!chunk.metadata) {
|
|
2066
2037
|
const assetsDirectory = path__default.default.join(strapi2.dirs.static.public, "uploads");
|
|
2067
2038
|
const entryPath = path__default.default.join(assetsDirectory, chunk.filename);
|
|
@@ -2090,7 +2061,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2090
2061
|
const uploadData = {
|
|
2091
2062
|
...chunk.metadata,
|
|
2092
2063
|
stream: stream$1.Readable.from(chunk.stream),
|
|
2093
|
-
buffer: chunk
|
|
2064
|
+
buffer: chunk?.buffer
|
|
2094
2065
|
};
|
|
2095
2066
|
const provider = strapi2.config.get("plugin.upload").provider;
|
|
2096
2067
|
try {
|
|
@@ -2098,11 +2069,11 @@ class LocalStrapiDestinationProvider {
|
|
|
2098
2069
|
if (!restoreMediaEntitiesContent) {
|
|
2099
2070
|
return callback();
|
|
2100
2071
|
}
|
|
2101
|
-
if (uploadData
|
|
2072
|
+
if (uploadData?.type) {
|
|
2102
2073
|
const entry2 = await strapi2.db.query("plugin::upload.file").findOne({
|
|
2103
2074
|
where: { hash: uploadData.mainHash }
|
|
2104
2075
|
});
|
|
2105
|
-
const specificFormat =
|
|
2076
|
+
const specificFormat = entry2?.formats?.[uploadData.type];
|
|
2106
2077
|
if (specificFormat) {
|
|
2107
2078
|
specificFormat.url = uploadData.url;
|
|
2108
2079
|
}
|
|
@@ -2130,7 +2101,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2130
2101
|
} catch (error) {
|
|
2131
2102
|
callback(new Error(`Error while uploading asset ${chunk.filename} ${error}`));
|
|
2132
2103
|
}
|
|
2133
|
-
})
|
|
2104
|
+
});
|
|
2134
2105
|
}
|
|
2135
2106
|
});
|
|
2136
2107
|
}
|
|
@@ -2151,10 +2122,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2151
2122
|
throw new Error("Not able to stream links. Strapi instance not found");
|
|
2152
2123
|
}
|
|
2153
2124
|
const { strategy } = this.options;
|
|
2154
|
-
const mapID = (uid, id) =>
|
|
2155
|
-
var _a;
|
|
2156
|
-
return (_a = this.#entitiesMapper[uid]) == null ? void 0 : _a[id];
|
|
2157
|
-
};
|
|
2125
|
+
const mapID = (uid, id) => this.#entitiesMapper[uid]?.[id];
|
|
2158
2126
|
if (strategy === "restore") {
|
|
2159
2127
|
return createLinksWriteStream(mapID, this.strapi, this.transaction);
|
|
2160
2128
|
}
|
|
@@ -2246,7 +2214,7 @@ const wrapConfigurationItem = (type) => (value) => ({
|
|
|
2246
2214
|
value
|
|
2247
2215
|
});
|
|
2248
2216
|
const protocolForPath = (filepath) => {
|
|
2249
|
-
return
|
|
2217
|
+
return filepath?.startsWith("https") ? https__default.default : http__default.default;
|
|
2250
2218
|
};
|
|
2251
2219
|
function getFileStream(filepath, isLocal = false) {
|
|
2252
2220
|
if (isLocal) {
|
|
@@ -2337,10 +2305,9 @@ class LocalStrapiSourceProvider {
|
|
|
2337
2305
|
this.strapi = await this.options.getStrapi();
|
|
2338
2306
|
}
|
|
2339
2307
|
async close() {
|
|
2340
|
-
var _a;
|
|
2341
2308
|
const { autoDestroy } = this.options;
|
|
2342
2309
|
if (autoDestroy === void 0 || autoDestroy === true) {
|
|
2343
|
-
await
|
|
2310
|
+
await this.strapi?.destroy();
|
|
2344
2311
|
}
|
|
2345
2312
|
}
|
|
2346
2313
|
getMetadata() {
|
|
@@ -2396,12 +2363,11 @@ const createDispatcher = (ws2, retryMessageOptions = {
|
|
|
2396
2363
|
throw new Error("No websocket connection found");
|
|
2397
2364
|
}
|
|
2398
2365
|
return new Promise((resolve, reject2) => {
|
|
2399
|
-
var _a;
|
|
2400
2366
|
const uuid = crypto.randomUUID();
|
|
2401
2367
|
const payload = { ...message, uuid };
|
|
2402
2368
|
let numberOfTimesMessageWasSent = 0;
|
|
2403
2369
|
if (options.attachTransfer) {
|
|
2404
|
-
Object.assign(payload, { transferID:
|
|
2370
|
+
Object.assign(payload, { transferID: state.transfer?.id });
|
|
2405
2371
|
}
|
|
2406
2372
|
const stringifiedPayload = JSON.stringify(payload);
|
|
2407
2373
|
ws2.send(stringifiedPayload, (error) => {
|
|
@@ -2424,14 +2390,13 @@ const createDispatcher = (ws2, retryMessageOptions = {
|
|
|
2424
2390
|
};
|
|
2425
2391
|
const interval = setInterval(sendPeriodically, retryMessageTimeout);
|
|
2426
2392
|
const onResponse = (raw) => {
|
|
2427
|
-
var _a2, _b;
|
|
2428
2393
|
const response = JSON.parse(raw.toString());
|
|
2429
2394
|
if (response.uuid === uuid) {
|
|
2430
2395
|
clearInterval(interval);
|
|
2431
2396
|
if (response.error) {
|
|
2432
2397
|
const message2 = response.error.message;
|
|
2433
|
-
const details =
|
|
2434
|
-
const step =
|
|
2398
|
+
const details = response.error.details?.details;
|
|
2399
|
+
const step = response.error.details?.step;
|
|
2435
2400
|
let error = new ProviderError("error", message2, details);
|
|
2436
2401
|
if (step === "transfer") {
|
|
2437
2402
|
error = new ProviderTransferError(message2, details);
|
|
@@ -2470,12 +2435,10 @@ const createDispatcher = (ws2, retryMessageOptions = {
|
|
|
2470
2435
|
};
|
|
2471
2436
|
return {
|
|
2472
2437
|
get transferID() {
|
|
2473
|
-
|
|
2474
|
-
return (_a = state.transfer) == null ? void 0 : _a.id;
|
|
2438
|
+
return state.transfer?.id;
|
|
2475
2439
|
},
|
|
2476
2440
|
get transferKind() {
|
|
2477
|
-
|
|
2478
|
-
return (_a = state.transfer) == null ? void 0 : _a.kind;
|
|
2441
|
+
return state.transfer?.kind;
|
|
2479
2442
|
},
|
|
2480
2443
|
setTransferProperties,
|
|
2481
2444
|
dispatch,
|
|
@@ -2554,14 +2517,13 @@ class RemoteStrapiDestinationProvider {
|
|
|
2554
2517
|
this.transferID = null;
|
|
2555
2518
|
}
|
|
2556
2519
|
async initTransfer() {
|
|
2557
|
-
var _a;
|
|
2558
2520
|
const { strategy, restore } = this.options;
|
|
2559
|
-
const query =
|
|
2521
|
+
const query = this.dispatcher?.dispatchCommand({
|
|
2560
2522
|
command: "init",
|
|
2561
2523
|
params: { options: { strategy, restore }, transfer: "push" }
|
|
2562
2524
|
});
|
|
2563
2525
|
const res = await query;
|
|
2564
|
-
if (!
|
|
2526
|
+
if (!res?.transferID) {
|
|
2565
2527
|
throw new ProviderTransferError("Init failed, invalid response from the server");
|
|
2566
2528
|
}
|
|
2567
2529
|
return res.transferID;
|
|
@@ -2570,9 +2532,8 @@ class RemoteStrapiDestinationProvider {
|
|
|
2570
2532
|
return fp.once(() => this.#startStep(stage));
|
|
2571
2533
|
}
|
|
2572
2534
|
async #startStep(step) {
|
|
2573
|
-
var _a;
|
|
2574
2535
|
try {
|
|
2575
|
-
await
|
|
2536
|
+
await this.dispatcher?.dispatchTransferStep({ action: "start", step });
|
|
2576
2537
|
} catch (e) {
|
|
2577
2538
|
if (e instanceof Error) {
|
|
2578
2539
|
return e;
|
|
@@ -2585,9 +2546,8 @@ class RemoteStrapiDestinationProvider {
|
|
|
2585
2546
|
return null;
|
|
2586
2547
|
}
|
|
2587
2548
|
async #endStep(step) {
|
|
2588
|
-
var _a;
|
|
2589
2549
|
try {
|
|
2590
|
-
await
|
|
2550
|
+
await this.dispatcher?.dispatchTransferStep({ action: "end", step });
|
|
2591
2551
|
} catch (e) {
|
|
2592
2552
|
if (e instanceof Error) {
|
|
2593
2553
|
return e;
|
|
@@ -2600,9 +2560,8 @@ class RemoteStrapiDestinationProvider {
|
|
|
2600
2560
|
return null;
|
|
2601
2561
|
}
|
|
2602
2562
|
async #streamStep(step, data) {
|
|
2603
|
-
var _a;
|
|
2604
2563
|
try {
|
|
2605
|
-
await
|
|
2564
|
+
await this.dispatcher?.dispatchTransferStep({ action: "stream", step, data });
|
|
2606
2565
|
} catch (e) {
|
|
2607
2566
|
if (e instanceof Error) {
|
|
2608
2567
|
return e;
|
|
@@ -2704,16 +2663,13 @@ class RemoteStrapiDestinationProvider {
|
|
|
2704
2663
|
});
|
|
2705
2664
|
}
|
|
2706
2665
|
getMetadata() {
|
|
2707
|
-
|
|
2708
|
-
return ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("getMetadata")) ?? null;
|
|
2666
|
+
return this.dispatcher?.dispatchTransferAction("getMetadata") ?? null;
|
|
2709
2667
|
}
|
|
2710
2668
|
async beforeTransfer() {
|
|
2711
|
-
|
|
2712
|
-
await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("beforeTransfer"));
|
|
2669
|
+
await this.dispatcher?.dispatchTransferAction("beforeTransfer");
|
|
2713
2670
|
}
|
|
2714
2671
|
async rollback() {
|
|
2715
|
-
|
|
2716
|
-
await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("rollback"));
|
|
2672
|
+
await this.dispatcher?.dispatchTransferAction("rollback");
|
|
2717
2673
|
}
|
|
2718
2674
|
getSchemas() {
|
|
2719
2675
|
if (!this.dispatcher) {
|
|
@@ -2813,7 +2769,6 @@ class RemoteStrapiSourceProvider {
|
|
|
2813
2769
|
}
|
|
2814
2770
|
results;
|
|
2815
2771
|
async #createStageReadStream(stage) {
|
|
2816
|
-
var _a;
|
|
2817
2772
|
const startResult = await this.#startStep(stage);
|
|
2818
2773
|
if (startResult instanceof Error) {
|
|
2819
2774
|
throw startResult;
|
|
@@ -2821,10 +2776,9 @@ class RemoteStrapiSourceProvider {
|
|
|
2821
2776
|
const { id: processID } = startResult;
|
|
2822
2777
|
const stream2 = new stream$1.PassThrough({ objectMode: true });
|
|
2823
2778
|
const listener = async (raw) => {
|
|
2824
|
-
var _a2, _b, _c, _d;
|
|
2825
2779
|
const parsed = JSON.parse(raw.toString());
|
|
2826
|
-
if (!parsed.uuid ||
|
|
2827
|
-
|
|
2780
|
+
if (!parsed.uuid || parsed?.data?.type !== "transfer" || parsed?.data?.id !== processID) {
|
|
2781
|
+
this.ws?.once("message", listener);
|
|
2828
2782
|
return;
|
|
2829
2783
|
}
|
|
2830
2784
|
const { uuid, data: message } = parsed;
|
|
@@ -2844,10 +2798,10 @@ class RemoteStrapiSourceProvider {
|
|
|
2844
2798
|
for (const item of fp.castArray(data)) {
|
|
2845
2799
|
stream2.push(item);
|
|
2846
2800
|
}
|
|
2847
|
-
|
|
2801
|
+
this.ws?.once("message", listener);
|
|
2848
2802
|
await this.#respond(uuid);
|
|
2849
2803
|
};
|
|
2850
|
-
|
|
2804
|
+
this.ws?.once("message", listener);
|
|
2851
2805
|
return stream2;
|
|
2852
2806
|
}
|
|
2853
2807
|
createEntitiesReadStream() {
|
|
@@ -2899,8 +2853,7 @@ class RemoteStrapiSourceProvider {
|
|
|
2899
2853
|
return this.#createStageReadStream("configuration");
|
|
2900
2854
|
}
|
|
2901
2855
|
async getMetadata() {
|
|
2902
|
-
|
|
2903
|
-
const metadata = await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("getMetadata"));
|
|
2856
|
+
const metadata = await this.dispatcher?.dispatchTransferAction("getMetadata");
|
|
2904
2857
|
return metadata ?? null;
|
|
2905
2858
|
}
|
|
2906
2859
|
assertValidProtocol(url) {
|
|
@@ -2916,12 +2869,11 @@ class RemoteStrapiSourceProvider {
|
|
|
2916
2869
|
}
|
|
2917
2870
|
}
|
|
2918
2871
|
async initTransfer() {
|
|
2919
|
-
|
|
2920
|
-
const query = (_a = this.dispatcher) == null ? void 0 : _a.dispatchCommand({
|
|
2872
|
+
const query = this.dispatcher?.dispatchCommand({
|
|
2921
2873
|
command: "init"
|
|
2922
2874
|
});
|
|
2923
2875
|
const res = await query;
|
|
2924
|
-
if (!
|
|
2876
|
+
if (!res?.transferID) {
|
|
2925
2877
|
throw new ProviderTransferError("Init failed, invalid response from the server");
|
|
2926
2878
|
}
|
|
2927
2879
|
return res.transferID;
|
|
@@ -2955,8 +2907,7 @@ class RemoteStrapiSourceProvider {
|
|
|
2955
2907
|
await this.dispatcher.dispatchTransferAction("bootstrap");
|
|
2956
2908
|
}
|
|
2957
2909
|
async close() {
|
|
2958
|
-
|
|
2959
|
-
await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction("close"));
|
|
2910
|
+
await this.dispatcher?.dispatchTransferAction("close");
|
|
2960
2911
|
await new Promise((resolve) => {
|
|
2961
2912
|
const { ws: ws2 } = this;
|
|
2962
2913
|
if (!ws2 || ws2.CLOSED) {
|
|
@@ -2967,16 +2918,14 @@ class RemoteStrapiSourceProvider {
|
|
|
2967
2918
|
});
|
|
2968
2919
|
}
|
|
2969
2920
|
async getSchemas() {
|
|
2970
|
-
|
|
2971
|
-
const schemas = await ((_a = this.dispatcher) == null ? void 0 : _a.dispatchTransferAction(
|
|
2921
|
+
const schemas = await this.dispatcher?.dispatchTransferAction(
|
|
2972
2922
|
"getSchemas"
|
|
2973
|
-
)
|
|
2923
|
+
) ?? null;
|
|
2974
2924
|
return schemas;
|
|
2975
2925
|
}
|
|
2976
2926
|
async #startStep(step) {
|
|
2977
|
-
var _a;
|
|
2978
2927
|
try {
|
|
2979
|
-
return await
|
|
2928
|
+
return await this.dispatcher?.dispatchTransferStep({ action: "start", step });
|
|
2980
2929
|
} catch (e) {
|
|
2981
2930
|
if (e instanceof Error) {
|
|
2982
2931
|
return e;
|
|
@@ -2989,8 +2938,7 @@ class RemoteStrapiSourceProvider {
|
|
|
2989
2938
|
}
|
|
2990
2939
|
async #respond(uuid) {
|
|
2991
2940
|
return new Promise((resolve, reject2) => {
|
|
2992
|
-
|
|
2993
|
-
(_a = this.ws) == null ? void 0 : _a.send(JSON.stringify({ uuid }), (e) => {
|
|
2941
|
+
this.ws?.send(JSON.stringify({ uuid }), (e) => {
|
|
2994
2942
|
if (e) {
|
|
2995
2943
|
reject2(e);
|
|
2996
2944
|
} else {
|
|
@@ -3000,9 +2948,8 @@ class RemoteStrapiSourceProvider {
|
|
|
3000
2948
|
});
|
|
3001
2949
|
}
|
|
3002
2950
|
async #endStep(step) {
|
|
3003
|
-
var _a;
|
|
3004
2951
|
try {
|
|
3005
|
-
await
|
|
2952
|
+
await this.dispatcher?.dispatchTransferStep({ action: "end", step });
|
|
3006
2953
|
} catch (e) {
|
|
3007
2954
|
if (e instanceof Error) {
|
|
3008
2955
|
return e;
|
|
@@ -3113,8 +3060,7 @@ const transformUpgradeHeader = (header = "") => {
|
|
|
3113
3060
|
};
|
|
3114
3061
|
let timeouts;
|
|
3115
3062
|
const disableTimeouts = () => {
|
|
3116
|
-
|
|
3117
|
-
if (!((_a = strapi == null ? void 0 : strapi.server) == null ? void 0 : _a.httpServer)) {
|
|
3063
|
+
if (!strapi?.server?.httpServer) {
|
|
3118
3064
|
return;
|
|
3119
3065
|
}
|
|
3120
3066
|
const { httpServer } = strapi.server;
|
|
@@ -3129,8 +3075,7 @@ const disableTimeouts = () => {
|
|
|
3129
3075
|
strapi.log.info("[Data transfer] Disabling http timeouts");
|
|
3130
3076
|
};
|
|
3131
3077
|
const resetTimeouts = () => {
|
|
3132
|
-
|
|
3133
|
-
if (!((_a = strapi == null ? void 0 : strapi.server) == null ? void 0 : _a.httpServer) || !timeouts) {
|
|
3078
|
+
if (!strapi?.server?.httpServer || !timeouts) {
|
|
3134
3079
|
return;
|
|
3135
3080
|
}
|
|
3136
3081
|
const { httpServer } = strapi.server;
|
|
@@ -3139,12 +3084,11 @@ const resetTimeouts = () => {
|
|
|
3139
3084
|
httpServer.requestTimeout = timeouts.requestTimeout;
|
|
3140
3085
|
};
|
|
3141
3086
|
const assertValidHeader = (ctx) => {
|
|
3142
|
-
var _a;
|
|
3143
3087
|
if (ctx.headers.upgrade === "websocket") {
|
|
3144
3088
|
return;
|
|
3145
3089
|
}
|
|
3146
3090
|
const upgradeHeader = transformUpgradeHeader(ctx.headers.upgrade);
|
|
3147
|
-
const logSafeUpgradeHeader =
|
|
3091
|
+
const logSafeUpgradeHeader = JSON.stringify(ctx.headers.upgrade)?.replace(/[^a-z0-9\s.,|]/gi, "").substring(0, 50);
|
|
3148
3092
|
if (!upgradeHeader.includes("websocket")) {
|
|
3149
3093
|
throw new Error(
|
|
3150
3094
|
`Transfer Upgrade header expected 'websocket', found '${logSafeUpgradeHeader}'. Please ensure that your server or proxy is not modifying the Upgrade header.`
|
|
@@ -3184,21 +3128,19 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3184
3128
|
const { verify, server: serverOptions } = options ?? {};
|
|
3185
3129
|
const wss = new ws.WebSocket.Server({ ...serverOptions, noServer: true });
|
|
3186
3130
|
return async (ctx) => {
|
|
3187
|
-
var _a, _b;
|
|
3188
3131
|
const cb = (ws2) => {
|
|
3189
3132
|
const state = { id: void 0 };
|
|
3190
3133
|
const messageUUIDs = /* @__PURE__ */ new Set();
|
|
3191
3134
|
const cannotRespondHandler = (err) => {
|
|
3192
|
-
|
|
3193
|
-
(_a2 = strapi == null ? void 0 : strapi.log) == null ? void 0 : _a2.error(
|
|
3135
|
+
strapi?.log?.error(
|
|
3194
3136
|
"[Data transfer] Cannot send error response to client, closing connection"
|
|
3195
3137
|
);
|
|
3196
|
-
|
|
3138
|
+
strapi?.log?.error(err);
|
|
3197
3139
|
try {
|
|
3198
3140
|
ws2.terminate();
|
|
3199
3141
|
ctx.req.socket.destroy();
|
|
3200
3142
|
} catch (err2) {
|
|
3201
|
-
|
|
3143
|
+
strapi?.log?.error("[Data transfer] Failed to close socket on error");
|
|
3202
3144
|
}
|
|
3203
3145
|
};
|
|
3204
3146
|
const prototype = {
|
|
@@ -3263,8 +3205,8 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3263
3205
|
uuid,
|
|
3264
3206
|
data: data ?? null,
|
|
3265
3207
|
error: e ? {
|
|
3266
|
-
code:
|
|
3267
|
-
message: e
|
|
3208
|
+
code: e?.name ?? "ERR",
|
|
3209
|
+
message: e?.message,
|
|
3268
3210
|
details
|
|
3269
3211
|
} : null
|
|
3270
3212
|
});
|
|
@@ -3341,34 +3283,31 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3341
3283
|
};
|
|
3342
3284
|
const handler = Object.assign(Object.create(prototype), implementation(prototype));
|
|
3343
3285
|
ws2.on("close", async (...args) => {
|
|
3344
|
-
var _a2, _b2;
|
|
3345
3286
|
try {
|
|
3346
3287
|
await handler.onClose(...args);
|
|
3347
3288
|
} catch (err) {
|
|
3348
|
-
|
|
3349
|
-
|
|
3289
|
+
strapi?.log?.error("[Data transfer] Uncaught error closing connection");
|
|
3290
|
+
strapi?.log?.error(err);
|
|
3350
3291
|
cannotRespondHandler(err);
|
|
3351
3292
|
} finally {
|
|
3352
3293
|
resetTimeouts();
|
|
3353
3294
|
}
|
|
3354
3295
|
});
|
|
3355
3296
|
ws2.on("error", async (...args) => {
|
|
3356
|
-
var _a2, _b2;
|
|
3357
3297
|
try {
|
|
3358
3298
|
await handler.onError(...args);
|
|
3359
3299
|
} catch (err) {
|
|
3360
|
-
|
|
3361
|
-
|
|
3300
|
+
strapi?.log?.error("[Data transfer] Uncaught error in error handling");
|
|
3301
|
+
strapi?.log?.error(err);
|
|
3362
3302
|
cannotRespondHandler(err);
|
|
3363
3303
|
}
|
|
3364
3304
|
});
|
|
3365
3305
|
ws2.on("message", async (...args) => {
|
|
3366
|
-
var _a2, _b2;
|
|
3367
3306
|
try {
|
|
3368
3307
|
await handler.onMessage(...args);
|
|
3369
3308
|
} catch (err) {
|
|
3370
|
-
|
|
3371
|
-
|
|
3309
|
+
strapi?.log?.error("[Data transfer] Uncaught error in message handling");
|
|
3310
|
+
strapi?.log?.error(err);
|
|
3372
3311
|
cannotRespondHandler(err);
|
|
3373
3312
|
}
|
|
3374
3313
|
});
|
|
@@ -3376,8 +3315,8 @@ const handlerControllerFactory = (implementation) => (options) => {
|
|
|
3376
3315
|
try {
|
|
3377
3316
|
handleWSUpgrade(wss, ctx, cb);
|
|
3378
3317
|
} catch (err) {
|
|
3379
|
-
|
|
3380
|
-
|
|
3318
|
+
strapi?.log?.error("[Data transfer] Error in websocket upgrade request");
|
|
3319
|
+
strapi?.log?.error(err);
|
|
3381
3320
|
}
|
|
3382
3321
|
};
|
|
3383
3322
|
};
|
|
@@ -3436,15 +3375,14 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3436
3375
|
});
|
|
3437
3376
|
},
|
|
3438
3377
|
assertValidStreamTransferStep(stage) {
|
|
3439
|
-
|
|
3440
|
-
const currentStep = (_a = this.flow) == null ? void 0 : _a.get();
|
|
3378
|
+
const currentStep = this.flow?.get();
|
|
3441
3379
|
const nextStep = { kind: "transfer", stage };
|
|
3442
|
-
if (
|
|
3380
|
+
if (currentStep?.kind === "transfer" && !currentStep.locked) {
|
|
3443
3381
|
throw new ProviderTransferError(
|
|
3444
3382
|
`You need to initialize the transfer stage (${nextStep}) before starting to stream data`
|
|
3445
3383
|
);
|
|
3446
3384
|
}
|
|
3447
|
-
if (
|
|
3385
|
+
if (this.flow?.cannot(nextStep)) {
|
|
3448
3386
|
throw new ProviderTransferError(`Invalid stage (${nextStep}) provided for the current flow`, {
|
|
3449
3387
|
step: nextStep
|
|
3450
3388
|
});
|
|
@@ -3452,22 +3390,10 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3452
3390
|
},
|
|
3453
3391
|
async createWritableStreamForStep(step) {
|
|
3454
3392
|
const mapper = {
|
|
3455
|
-
entities: () =>
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
links: () => {
|
|
3460
|
-
var _a;
|
|
3461
|
-
return (_a = this.provider) == null ? void 0 : _a.createLinksWriteStream();
|
|
3462
|
-
},
|
|
3463
|
-
configuration: () => {
|
|
3464
|
-
var _a;
|
|
3465
|
-
return (_a = this.provider) == null ? void 0 : _a.createConfigurationWriteStream();
|
|
3466
|
-
},
|
|
3467
|
-
assets: () => {
|
|
3468
|
-
var _a;
|
|
3469
|
-
return (_a = this.provider) == null ? void 0 : _a.createAssetsWriteStream();
|
|
3470
|
-
}
|
|
3393
|
+
entities: () => this.provider?.createEntitiesWriteStream(),
|
|
3394
|
+
links: () => this.provider?.createLinksWriteStream(),
|
|
3395
|
+
configuration: () => this.provider?.createConfigurationWriteStream(),
|
|
3396
|
+
assets: () => this.provider?.createAssetsWriteStream()
|
|
3471
3397
|
};
|
|
3472
3398
|
if (!(step in mapper)) {
|
|
3473
3399
|
throw new Error("Invalid transfer step, impossible to create a stream");
|
|
@@ -3487,8 +3413,8 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3487
3413
|
}
|
|
3488
3414
|
if (proto.hasUUID(msg.uuid)) {
|
|
3489
3415
|
const previousResponse = proto.response;
|
|
3490
|
-
if (
|
|
3491
|
-
await this.respond(previousResponse
|
|
3416
|
+
if (previousResponse?.uuid === msg.uuid) {
|
|
3417
|
+
await this.respond(previousResponse?.uuid, previousResponse.e, previousResponse.data);
|
|
3492
3418
|
}
|
|
3493
3419
|
return;
|
|
3494
3420
|
}
|
|
@@ -3523,43 +3449,40 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3523
3449
|
}
|
|
3524
3450
|
},
|
|
3525
3451
|
lockTransferStep(stage) {
|
|
3526
|
-
|
|
3527
|
-
const currentStep = (_a = this.flow) == null ? void 0 : _a.get();
|
|
3452
|
+
const currentStep = this.flow?.get();
|
|
3528
3453
|
const nextStep = { kind: "transfer", stage };
|
|
3529
|
-
if (
|
|
3454
|
+
if (currentStep?.kind === "transfer" && currentStep.locked) {
|
|
3530
3455
|
throw new ProviderTransferError(
|
|
3531
3456
|
`It's not possible to start a new transfer stage (${stage}) while another one is in progress (${currentStep.stage})`
|
|
3532
3457
|
);
|
|
3533
3458
|
}
|
|
3534
|
-
if (
|
|
3459
|
+
if (this.flow?.cannot(nextStep)) {
|
|
3535
3460
|
throw new ProviderTransferError(`Invalid stage (${stage}) provided for the current flow`, {
|
|
3536
3461
|
step: nextStep
|
|
3537
3462
|
});
|
|
3538
3463
|
}
|
|
3539
|
-
|
|
3464
|
+
this.flow?.set({ ...nextStep, locked: true });
|
|
3540
3465
|
},
|
|
3541
3466
|
unlockTransferStep(stage) {
|
|
3542
|
-
|
|
3543
|
-
const currentStep = (_a = this.flow) == null ? void 0 : _a.get();
|
|
3467
|
+
const currentStep = this.flow?.get();
|
|
3544
3468
|
const nextStep = { kind: "transfer", stage };
|
|
3545
|
-
if (
|
|
3469
|
+
if (currentStep?.kind === "transfer" && !currentStep.locked) {
|
|
3546
3470
|
throw new ProviderTransferError(
|
|
3547
3471
|
`You need to initialize the transfer stage (${stage}) before ending it`
|
|
3548
3472
|
);
|
|
3549
3473
|
}
|
|
3550
|
-
if (
|
|
3474
|
+
if (this.flow?.cannot(nextStep)) {
|
|
3551
3475
|
throw new ProviderTransferError(`Invalid stage (${stage}) provided for the current flow`, {
|
|
3552
3476
|
step: nextStep
|
|
3553
3477
|
});
|
|
3554
3478
|
}
|
|
3555
|
-
|
|
3479
|
+
this.flow?.set({ ...nextStep, locked: false });
|
|
3556
3480
|
},
|
|
3557
3481
|
async onTransferStep(msg) {
|
|
3558
|
-
var _a, _b, _c, _d;
|
|
3559
3482
|
const { step: stage } = msg;
|
|
3560
3483
|
if (msg.action === "start") {
|
|
3561
3484
|
this.lockTransferStep(stage);
|
|
3562
|
-
if (
|
|
3485
|
+
if (this.streams?.[stage] instanceof stream$1.Writable) {
|
|
3563
3486
|
throw new Error("Stream already created, something went wrong");
|
|
3564
3487
|
}
|
|
3565
3488
|
await this.createWritableStreamForStep(stage);
|
|
@@ -3567,7 +3490,7 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3567
3490
|
}
|
|
3568
3491
|
if (msg.action === "stream") {
|
|
3569
3492
|
this.assertValidStreamTransferStep(stage);
|
|
3570
|
-
const stream2 =
|
|
3493
|
+
const stream2 = this.streams?.[stage];
|
|
3571
3494
|
if (!stream2) {
|
|
3572
3495
|
throw new Error("You need to init first");
|
|
3573
3496
|
}
|
|
@@ -3578,64 +3501,60 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3578
3501
|
}
|
|
3579
3502
|
if (msg.action === "end") {
|
|
3580
3503
|
this.unlockTransferStep(stage);
|
|
3581
|
-
const stream2 =
|
|
3504
|
+
const stream2 = this.streams?.[stage];
|
|
3582
3505
|
if (stream2 && !stream2.closed) {
|
|
3583
3506
|
await new Promise((resolve, reject2) => {
|
|
3584
3507
|
stream2.on("close", resolve).on("error", reject2).end();
|
|
3585
3508
|
});
|
|
3586
3509
|
}
|
|
3587
|
-
|
|
3510
|
+
delete this.streams?.[stage];
|
|
3588
3511
|
return { ok: true };
|
|
3589
3512
|
}
|
|
3590
3513
|
},
|
|
3591
3514
|
async onTransferAction(msg) {
|
|
3592
|
-
var _a, _b, _c, _d;
|
|
3593
3515
|
const { action: action2 } = msg;
|
|
3594
3516
|
this.assertValidTransferAction(action2);
|
|
3595
3517
|
const step = { kind: "action", action: action2 };
|
|
3596
|
-
const isStepRegistered =
|
|
3518
|
+
const isStepRegistered = this.flow?.has(step);
|
|
3597
3519
|
if (isStepRegistered) {
|
|
3598
|
-
if (
|
|
3520
|
+
if (this.flow?.cannot(step)) {
|
|
3599
3521
|
throw new ProviderTransferError(`Invalid action "${action2}" found for the current flow `, {
|
|
3600
3522
|
action: action2
|
|
3601
3523
|
});
|
|
3602
3524
|
}
|
|
3603
|
-
|
|
3525
|
+
this.flow?.set(step);
|
|
3604
3526
|
}
|
|
3605
|
-
return
|
|
3527
|
+
return this.provider?.[action2]();
|
|
3606
3528
|
},
|
|
3607
3529
|
async streamAsset(payload) {
|
|
3608
|
-
|
|
3609
|
-
const assetsStream = (_a = this.streams) == null ? void 0 : _a.assets;
|
|
3530
|
+
const assetsStream = this.streams?.assets;
|
|
3610
3531
|
if (payload === null) {
|
|
3611
|
-
|
|
3532
|
+
this.streams?.assets?.end();
|
|
3612
3533
|
return;
|
|
3613
3534
|
}
|
|
3614
3535
|
for (const item of payload) {
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
}
|
|
3638
|
-
});
|
|
3536
|
+
const { action: action2, assetID } = item;
|
|
3537
|
+
if (!assetsStream) {
|
|
3538
|
+
throw new Error("Stream not defined");
|
|
3539
|
+
}
|
|
3540
|
+
if (action2 === "start") {
|
|
3541
|
+
this.assets[assetID] = { ...item.data, stream: new stream$1.PassThrough() };
|
|
3542
|
+
writeAsync(assetsStream, this.assets[assetID]);
|
|
3543
|
+
}
|
|
3544
|
+
if (action2 === "stream") {
|
|
3545
|
+
const rawBuffer = item.data;
|
|
3546
|
+
const chunk = Buffer.from(rawBuffer.data);
|
|
3547
|
+
await writeAsync(this.assets[assetID].stream, chunk);
|
|
3548
|
+
}
|
|
3549
|
+
if (action2 === "end") {
|
|
3550
|
+
await new Promise((resolve, reject2) => {
|
|
3551
|
+
const { stream: assetStream } = this.assets[assetID];
|
|
3552
|
+
assetStream.on("close", () => {
|
|
3553
|
+
delete this.assets[assetID];
|
|
3554
|
+
resolve();
|
|
3555
|
+
}).on("error", reject2).end();
|
|
3556
|
+
});
|
|
3557
|
+
}
|
|
3639
3558
|
}
|
|
3640
3559
|
},
|
|
3641
3560
|
onClose() {
|
|
@@ -3678,7 +3597,7 @@ const createPushController = handlerControllerFactory((proto) => ({
|
|
|
3678
3597
|
},
|
|
3679
3598
|
async end(params) {
|
|
3680
3599
|
await this.verifyAuth();
|
|
3681
|
-
if (this.transferID !==
|
|
3600
|
+
if (this.transferID !== params?.transferID) {
|
|
3682
3601
|
throw new ProviderTransferError("Bad transfer ID provided");
|
|
3683
3602
|
}
|
|
3684
3603
|
this.cleanup();
|
|
@@ -3719,8 +3638,8 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3719
3638
|
}
|
|
3720
3639
|
if (proto.hasUUID(msg.uuid)) {
|
|
3721
3640
|
const previousResponse = proto.response;
|
|
3722
|
-
if (
|
|
3723
|
-
await this.respond(previousResponse
|
|
3641
|
+
if (previousResponse?.uuid === msg.uuid) {
|
|
3642
|
+
await this.respond(previousResponse?.uuid, previousResponse.e, previousResponse.data);
|
|
3724
3643
|
}
|
|
3725
3644
|
return;
|
|
3726
3645
|
}
|
|
@@ -3755,16 +3674,14 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3755
3674
|
}
|
|
3756
3675
|
},
|
|
3757
3676
|
async onTransferAction(msg) {
|
|
3758
|
-
var _a;
|
|
3759
3677
|
const { action: action2 } = msg;
|
|
3760
3678
|
this.assertValidTransferAction(action2);
|
|
3761
|
-
return
|
|
3679
|
+
return this.provider?.[action2]();
|
|
3762
3680
|
},
|
|
3763
3681
|
async flush(stage, id) {
|
|
3764
|
-
var _a;
|
|
3765
3682
|
const batchSize = 1024 * 1024;
|
|
3766
3683
|
let batch = [];
|
|
3767
|
-
const stream2 =
|
|
3684
|
+
const stream2 = this.streams?.[stage];
|
|
3768
3685
|
const batchLength = () => Buffer.byteLength(JSON.stringify(batch));
|
|
3769
3686
|
const sendBatch = async () => {
|
|
3770
3687
|
await this.confirm({
|
|
@@ -3796,10 +3713,9 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3796
3713
|
}
|
|
3797
3714
|
},
|
|
3798
3715
|
async onTransferStep(msg) {
|
|
3799
|
-
var _a, _b, _c;
|
|
3800
3716
|
const { step, action: action2 } = msg;
|
|
3801
3717
|
if (action2 === "start") {
|
|
3802
|
-
if (
|
|
3718
|
+
if (this.streams?.[step] instanceof stream$1.Readable) {
|
|
3803
3719
|
throw new Error("Stream already created, something went wrong");
|
|
3804
3720
|
}
|
|
3805
3721
|
const flushUUID = crypto.randomUUID();
|
|
@@ -3808,33 +3724,23 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3808
3724
|
return { ok: true, id: flushUUID };
|
|
3809
3725
|
}
|
|
3810
3726
|
if (action2 === "end") {
|
|
3811
|
-
const stream2 =
|
|
3812
|
-
if (
|
|
3727
|
+
const stream2 = this.streams?.[step];
|
|
3728
|
+
if (stream2?.readableEnded === false) {
|
|
3813
3729
|
await new Promise((resolve) => {
|
|
3814
|
-
stream2
|
|
3730
|
+
stream2?.on("close", resolve).destroy();
|
|
3815
3731
|
});
|
|
3816
3732
|
}
|
|
3817
|
-
|
|
3733
|
+
delete this.streams?.[step];
|
|
3818
3734
|
return { ok: true };
|
|
3819
3735
|
}
|
|
3820
3736
|
},
|
|
3821
3737
|
async createReadableStreamForStep(step) {
|
|
3822
3738
|
const mapper = {
|
|
3823
|
-
entities: () =>
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
},
|
|
3827
|
-
links: () => {
|
|
3828
|
-
var _a;
|
|
3829
|
-
return (_a = this.provider) == null ? void 0 : _a.createLinksReadStream();
|
|
3830
|
-
},
|
|
3831
|
-
configuration: () => {
|
|
3832
|
-
var _a;
|
|
3833
|
-
return (_a = this.provider) == null ? void 0 : _a.createConfigurationReadStream();
|
|
3834
|
-
},
|
|
3739
|
+
entities: () => this.provider?.createEntitiesReadStream(),
|
|
3740
|
+
links: () => this.provider?.createLinksReadStream(),
|
|
3741
|
+
configuration: () => this.provider?.createConfigurationReadStream(),
|
|
3835
3742
|
assets: () => {
|
|
3836
|
-
|
|
3837
|
-
const assets = (_a = this.provider) == null ? void 0 : _a.createAssetsReadStream();
|
|
3743
|
+
const assets = this.provider?.createAssetsReadStream();
|
|
3838
3744
|
let batch = [];
|
|
3839
3745
|
const batchLength = () => {
|
|
3840
3746
|
return batch.reduce(
|
|
@@ -3897,7 +3803,7 @@ const createPullController = handlerControllerFactory((proto) => ({
|
|
|
3897
3803
|
},
|
|
3898
3804
|
async end(params) {
|
|
3899
3805
|
await this.verifyAuth();
|
|
3900
|
-
if (this.transferID !==
|
|
3806
|
+
if (this.transferID !== params?.transferID) {
|
|
3901
3807
|
throw new ProviderTransferError("Bad transfer ID provided");
|
|
3902
3808
|
}
|
|
3903
3809
|
this.cleanup();
|
|
@@ -3969,12 +3875,11 @@ class LocalFileSourceProvider {
|
|
|
3969
3875
|
* Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
|
|
3970
3876
|
*/
|
|
3971
3877
|
async bootstrap() {
|
|
3972
|
-
var _a, _b;
|
|
3973
3878
|
const { path: filePath } = this.options.file;
|
|
3974
3879
|
try {
|
|
3975
3880
|
await this.#loadMetadata();
|
|
3976
3881
|
} catch (e) {
|
|
3977
|
-
if (
|
|
3882
|
+
if (this.options?.encryption?.enabled) {
|
|
3978
3883
|
throw new ProviderInitializationError(
|
|
3979
3884
|
`Key is incorrect or the file '${filePath}' is not a valid Strapi data file.`
|
|
3980
3885
|
);
|
|
@@ -4723,11 +4628,11 @@ const loadersFactory = (defaultLoaders = {}) => {
|
|
|
4723
4628
|
createLoader(stage);
|
|
4724
4629
|
}
|
|
4725
4630
|
const stageData = data[stage];
|
|
4726
|
-
const elapsedTime =
|
|
4727
|
-
const size = `size: ${readableBytes(
|
|
4631
|
+
const elapsedTime = stageData?.startTime ? (stageData?.endTime || Date.now()) - stageData.startTime : 0;
|
|
4632
|
+
const size = `size: ${readableBytes(stageData?.bytes ?? 0)}`;
|
|
4728
4633
|
const elapsed = `elapsed: ${elapsedTime} ms`;
|
|
4729
|
-
const speed = elapsedTime > 0 ? `(${readableBytes((
|
|
4730
|
-
loaders[stage].text = `${stage}: ${
|
|
4634
|
+
const speed = elapsedTime > 0 ? `(${readableBytes((stageData?.bytes ?? 0) * 1e3 / elapsedTime)}/s)` : "";
|
|
4635
|
+
loaders[stage].text = `${stage}: ${stageData?.count ?? 0} transfered (${size}) (${elapsed}) ${!stageData?.endTime ? speed : ""}`;
|
|
4731
4636
|
return loaders[stage];
|
|
4732
4637
|
};
|
|
4733
4638
|
const createLoader = (stage) => {
|
|
@@ -4744,11 +4649,10 @@ const loadersFactory = (defaultLoaders = {}) => {
|
|
|
4744
4649
|
};
|
|
4745
4650
|
};
|
|
4746
4651
|
const getTransferTelemetryPayload = (engine) => {
|
|
4747
|
-
var _a, _b;
|
|
4748
4652
|
return {
|
|
4749
4653
|
eventProperties: {
|
|
4750
|
-
source:
|
|
4751
|
-
destination:
|
|
4654
|
+
source: engine?.sourceProvider?.name,
|
|
4655
|
+
destination: engine?.destinationProvider?.name
|
|
4752
4656
|
}
|
|
4753
4657
|
};
|
|
4754
4658
|
};
|
|
@@ -4767,7 +4671,7 @@ const getDiffHandler = (engine, {
|
|
|
4767
4671
|
for (const diff2 of diffs) {
|
|
4768
4672
|
const path2 = [uid].concat(diff2.path).join(".");
|
|
4769
4673
|
const endPath = diff2.path[diff2.path.length - 1];
|
|
4770
|
-
if (uid === "admin::workflow" || uid === "admin::workflow-stage" ||
|
|
4674
|
+
if (uid === "admin::workflow" || uid === "admin::workflow-stage" || endPath?.startsWith("strapi_stage") || endPath?.startsWith("strapi_assignee")) {
|
|
4771
4675
|
workflowsStatus = diff2.kind;
|
|
4772
4676
|
} else if (diff2.kind === "added") {
|
|
4773
4677
|
engine.reportWarning(chalk__default.default.red(`${chalk__default.default.bold(path2)} does not exist on source`), source);
|
|
@@ -4832,8 +4736,7 @@ const getAssetsBackupHandler = (engine, {
|
|
|
4832
4736
|
};
|
|
4833
4737
|
};
|
|
4834
4738
|
const shouldSkipStage = (opts, dataKind) => {
|
|
4835
|
-
|
|
4836
|
-
if ((_a = opts.exclude) == null ? void 0 : _a.includes(dataKind)) {
|
|
4739
|
+
if (opts.exclude?.includes(dataKind)) {
|
|
4837
4740
|
return true;
|
|
4838
4741
|
}
|
|
4839
4742
|
if (opts.only) {
|
|
@@ -4842,12 +4745,11 @@ const shouldSkipStage = (opts, dataKind) => {
|
|
|
4842
4745
|
return false;
|
|
4843
4746
|
};
|
|
4844
4747
|
const parseRestoreFromOptions = (opts) => {
|
|
4845
|
-
var _a;
|
|
4846
4748
|
const entitiesOptions = {
|
|
4847
4749
|
exclude: DEFAULT_IGNORED_CONTENT_TYPES,
|
|
4848
4750
|
include: void 0
|
|
4849
4751
|
};
|
|
4850
|
-
if (opts.only && !opts.only.includes("content") ||
|
|
4752
|
+
if (opts.only && !opts.only.includes("content") || opts.exclude?.includes("content")) {
|
|
4851
4753
|
entitiesOptions.include = [];
|
|
4852
4754
|
}
|
|
4853
4755
|
const restoreConfig = {
|
|
@@ -4868,7 +4770,6 @@ const {
|
|
|
4868
4770
|
} = strapiDatatransfer;
|
|
4869
4771
|
const BYTES_IN_MB = 1024 * 1024;
|
|
4870
4772
|
const action$2 = async (opts) => {
|
|
4871
|
-
var _a, _b;
|
|
4872
4773
|
if (!fp.isObject(opts)) {
|
|
4873
4774
|
exitWith(1, "Could not parse command arguments");
|
|
4874
4775
|
}
|
|
@@ -4921,7 +4822,7 @@ const action$2 = async (opts) => {
|
|
|
4921
4822
|
try {
|
|
4922
4823
|
setSignalHandler(() => abortTransfer({ engine, strapi: strapi2 }));
|
|
4923
4824
|
results = await engine.transfer();
|
|
4924
|
-
outFile =
|
|
4825
|
+
outFile = results.destination?.file?.path ?? "";
|
|
4925
4826
|
const outFileExists = await fse__namespace.default.pathExists(outFile);
|
|
4926
4827
|
if (!outFileExists) {
|
|
4927
4828
|
throw new TransferEngineTransferError(`Export file not created "${outFile}"`);
|
|
@@ -4929,7 +4830,7 @@ const action$2 = async (opts) => {
|
|
|
4929
4830
|
await strapi2.telemetry.send("didDEITSProcessFinish", getTransferTelemetryPayload(engine));
|
|
4930
4831
|
try {
|
|
4931
4832
|
const table = buildTransferTable(results.engine);
|
|
4932
|
-
console.log(table
|
|
4833
|
+
console.log(table?.toString());
|
|
4933
4834
|
} catch (e) {
|
|
4934
4835
|
console.error("There was an error displaying the results of the transfer.");
|
|
4935
4836
|
}
|
|
@@ -5052,7 +4953,7 @@ const action$1 = async (opts) => {
|
|
|
5052
4953
|
results = await engine2.transfer();
|
|
5053
4954
|
try {
|
|
5054
4955
|
const table = buildTransferTable(results.engine);
|
|
5055
|
-
console.log(table
|
|
4956
|
+
console.log(table?.toString());
|
|
5056
4957
|
} catch (e) {
|
|
5057
4958
|
console.error("There was an error displaying the results of the transfer.");
|
|
5058
4959
|
}
|
|
@@ -5085,7 +4986,6 @@ const command$1 = ({ command: command2 }) => {
|
|
|
5085
4986
|
"Provide encryption key in command instead of using the prompt"
|
|
5086
4987
|
)
|
|
5087
4988
|
).addOption(forceOption).addOption(excludeOption).addOption(onlyOption).addOption(throttleOption).hook("preAction", validateExcludeOnly).hook("preAction", async (thisCommand) => {
|
|
5088
|
-
var _a;
|
|
5089
4989
|
const opts = thisCommand.opts();
|
|
5090
4990
|
const ext = path__default.default.extname(String(opts.file));
|
|
5091
4991
|
if (ext === ".enc") {
|
|
@@ -5097,7 +4997,7 @@ const command$1 = ({ command: command2 }) => {
|
|
|
5097
4997
|
name: "key"
|
|
5098
4998
|
}
|
|
5099
4999
|
]);
|
|
5100
|
-
if (!
|
|
5000
|
+
if (!answers.key?.length) {
|
|
5101
5001
|
exitWith(1, "No key entered, aborting import.");
|
|
5102
5002
|
}
|
|
5103
5003
|
opts.key = answers.key;
|
|
@@ -5246,7 +5146,7 @@ const action = async (opts) => {
|
|
|
5246
5146
|
await strapi2.telemetry.send("didDEITSProcessFinish", getTransferTelemetryPayload(engine));
|
|
5247
5147
|
try {
|
|
5248
5148
|
const table = buildTransferTable(results.engine);
|
|
5249
|
-
console.log(table
|
|
5149
|
+
console.log(table?.toString());
|
|
5250
5150
|
} catch (e) {
|
|
5251
5151
|
console.error("There was an error displaying the results of the transfer.");
|
|
5252
5152
|
}
|
|
@@ -5281,7 +5181,6 @@ const command = ({ command: command2 }) => {
|
|
|
5281
5181
|
ifOptions(
|
|
5282
5182
|
(opts) => opts.from,
|
|
5283
5183
|
async (thisCommand) => {
|
|
5284
|
-
var _a;
|
|
5285
5184
|
assertUrlHasProtocol(thisCommand.opts().from, ["https:", "http:"]);
|
|
5286
5185
|
if (!thisCommand.opts().fromToken) {
|
|
5287
5186
|
const answers = await inquirer__default.default.prompt([
|
|
@@ -5291,7 +5190,7 @@ const command = ({ command: command2 }) => {
|
|
|
5291
5190
|
name: "fromToken"
|
|
5292
5191
|
}
|
|
5293
5192
|
]);
|
|
5294
|
-
if (!
|
|
5193
|
+
if (!answers.fromToken?.length) {
|
|
5295
5194
|
exitWith(1, "No token provided for remote source, aborting transfer.");
|
|
5296
5195
|
}
|
|
5297
5196
|
thisCommand.opts().fromToken = answers.fromToken;
|
|
@@ -5307,7 +5206,6 @@ const command = ({ command: command2 }) => {
|
|
|
5307
5206
|
ifOptions(
|
|
5308
5207
|
(opts) => opts.to,
|
|
5309
5208
|
async (thisCommand) => {
|
|
5310
|
-
var _a;
|
|
5311
5209
|
assertUrlHasProtocol(thisCommand.opts().to, ["https:", "http:"]);
|
|
5312
5210
|
if (!thisCommand.opts().toToken) {
|
|
5313
5211
|
const answers = await inquirer__default.default.prompt([
|
|
@@ -5317,7 +5215,7 @@ const command = ({ command: command2 }) => {
|
|
|
5317
5215
|
name: "toToken"
|
|
5318
5216
|
}
|
|
5319
5217
|
]);
|
|
5320
|
-
if (!
|
|
5218
|
+
if (!answers.toToken?.length) {
|
|
5321
5219
|
exitWith(1, "No token provided for remote destination, aborting transfer.");
|
|
5322
5220
|
}
|
|
5323
5221
|
thisCommand.opts().toToken = answers.toToken;
|