@strapi/data-transfer 5.4.1 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/diagnostic.d.ts +1 -0
- package/dist/engine/diagnostic.d.ts.map +1 -1
- package/dist/file/providers/destination/index.d.ts +2 -1
- package/dist/file/providers/destination/index.d.ts.map +1 -1
- package/dist/file/providers/source/index.d.ts +2 -1
- package/dist/file/providers/source/index.d.ts.map +1 -1
- package/dist/index.js +161 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -12
- package/dist/index.mjs.map +1 -1
- package/dist/strapi/providers/local-destination/index.d.ts +2 -1
- package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/index.d.ts +3 -1
- package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-destination/index.d.ts +2 -1
- package/dist/strapi/providers/remote-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-source/index.d.ts +2 -1
- package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/utils.d.ts +1 -1
- package/dist/strapi/providers/utils.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -576,7 +576,7 @@ class TransferEngine {
|
|
|
576
576
|
reportInfo(message, params) {
|
|
577
577
|
this.diagnostics.report({
|
|
578
578
|
kind: "info",
|
|
579
|
-
details: { createdAt: /* @__PURE__ */ new Date(), message, params }
|
|
579
|
+
details: { createdAt: /* @__PURE__ */ new Date(), message, params, source: "engine" }
|
|
580
580
|
});
|
|
581
581
|
}
|
|
582
582
|
/**
|
|
@@ -868,8 +868,8 @@ ${formattedDiffs}`,
|
|
|
868
868
|
*/
|
|
869
869
|
async bootstrap() {
|
|
870
870
|
const results = await Promise.allSettled([
|
|
871
|
-
this.sourceProvider.bootstrap?.(),
|
|
872
|
-
this.destinationProvider.bootstrap?.()
|
|
871
|
+
this.sourceProvider.bootstrap?.(this.diagnostics),
|
|
872
|
+
this.destinationProvider.bootstrap?.(this.diagnostics)
|
|
873
873
|
]);
|
|
874
874
|
results.forEach((result) => {
|
|
875
875
|
if (result.status === "rejected") {
|
|
@@ -1874,6 +1874,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1874
1874
|
transaction;
|
|
1875
1875
|
uploadsBackupDirectoryName;
|
|
1876
1876
|
onWarning;
|
|
1877
|
+
#diagnostics;
|
|
1877
1878
|
/**
|
|
1878
1879
|
* The entities mapper is used to map old entities to their new IDs
|
|
1879
1880
|
*/
|
|
@@ -1883,7 +1884,8 @@ class LocalStrapiDestinationProvider {
|
|
|
1883
1884
|
this.#entitiesMapper = {};
|
|
1884
1885
|
this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;
|
|
1885
1886
|
}
|
|
1886
|
-
async bootstrap() {
|
|
1887
|
+
async bootstrap(diagnostics) {
|
|
1888
|
+
this.#diagnostics = diagnostics;
|
|
1887
1889
|
this.#validateOptions();
|
|
1888
1890
|
this.strapi = await this.options.getStrapi();
|
|
1889
1891
|
if (!this.strapi) {
|
|
@@ -1900,6 +1902,16 @@ class LocalStrapiDestinationProvider {
|
|
|
1900
1902
|
const excluded = this.options.restore?.entities?.exclude && this.options.restore?.entities.exclude.includes(type);
|
|
1901
1903
|
return !excluded && !notIncluded;
|
|
1902
1904
|
};
|
|
1905
|
+
#reportInfo(message) {
|
|
1906
|
+
this.#diagnostics?.report({
|
|
1907
|
+
details: {
|
|
1908
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
1909
|
+
message,
|
|
1910
|
+
source: "local-destination-provider"
|
|
1911
|
+
},
|
|
1912
|
+
kind: "info"
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1903
1915
|
async close() {
|
|
1904
1916
|
const { autoDestroy } = this.options;
|
|
1905
1917
|
this.transaction?.end();
|
|
@@ -1908,6 +1920,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1908
1920
|
}
|
|
1909
1921
|
}
|
|
1910
1922
|
#validateOptions() {
|
|
1923
|
+
this.#reportInfo("validating options");
|
|
1911
1924
|
if (!VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {
|
|
1912
1925
|
throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
|
|
1913
1926
|
check: "strategy",
|
|
@@ -1924,10 +1937,12 @@ class LocalStrapiDestinationProvider {
|
|
|
1924
1937
|
if (!this.options.restore) {
|
|
1925
1938
|
throw new ProviderValidationError("Missing restore options");
|
|
1926
1939
|
}
|
|
1940
|
+
this.#reportInfo("deleting record ");
|
|
1927
1941
|
return deleteRecords(this.strapi, this.options.restore);
|
|
1928
1942
|
}
|
|
1929
1943
|
async #deleteAllAssets(trx) {
|
|
1930
1944
|
assertValidStrapi(this.strapi);
|
|
1945
|
+
this.#reportInfo("deleting all assets");
|
|
1931
1946
|
if (!this.#areAssetsIncluded()) {
|
|
1932
1947
|
return;
|
|
1933
1948
|
}
|
|
@@ -1940,9 +1955,12 @@ class LocalStrapiDestinationProvider {
|
|
|
1940
1955
|
}
|
|
1941
1956
|
}
|
|
1942
1957
|
}
|
|
1958
|
+
this.#reportInfo("deleted all assets");
|
|
1943
1959
|
}
|
|
1944
1960
|
async rollback() {
|
|
1961
|
+
this.#reportInfo("Rolling back transaction");
|
|
1945
1962
|
await this.transaction?.rollback();
|
|
1963
|
+
this.#reportInfo("Rolled back transaction");
|
|
1946
1964
|
}
|
|
1947
1965
|
async beforeTransfer() {
|
|
1948
1966
|
if (!this.strapi) {
|
|
@@ -1961,6 +1979,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1961
1979
|
});
|
|
1962
1980
|
}
|
|
1963
1981
|
getMetadata() {
|
|
1982
|
+
this.#reportInfo("getting metadata");
|
|
1964
1983
|
assertValidStrapi(this.strapi, "Not able to get Schemas");
|
|
1965
1984
|
const strapiVersion = this.strapi.config.get("info.strapi");
|
|
1966
1985
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1972,6 +1991,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1972
1991
|
};
|
|
1973
1992
|
}
|
|
1974
1993
|
getSchemas() {
|
|
1994
|
+
this.#reportInfo("getting schema");
|
|
1975
1995
|
assertValidStrapi(this.strapi, "Not able to get Schemas");
|
|
1976
1996
|
const schemas = schemasToValidJSON({
|
|
1977
1997
|
...this.strapi.contentTypes,
|
|
@@ -1981,6 +2001,7 @@ class LocalStrapiDestinationProvider {
|
|
|
1981
2001
|
}
|
|
1982
2002
|
createEntitiesWriteStream() {
|
|
1983
2003
|
assertValidStrapi(this.strapi, "Not able to import entities");
|
|
2004
|
+
this.#reportInfo("creating entities stream");
|
|
1984
2005
|
const { strategy } = this.options;
|
|
1985
2006
|
const updateMappingTable = (type, oldID, newID) => {
|
|
1986
2007
|
if (!this.#entitiesMapper[type]) {
|
|
@@ -2007,6 +2028,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2007
2028
|
return;
|
|
2008
2029
|
}
|
|
2009
2030
|
if (this.strapi.config.get("plugin::upload").provider === "local") {
|
|
2031
|
+
this.#reportInfo("creating assets backup directory");
|
|
2010
2032
|
const assetsDirectory = path.join(this.strapi.dirs.static.public, "uploads");
|
|
2011
2033
|
const backupDirectory = path.join(
|
|
2012
2034
|
this.strapi.dirs.static.public,
|
|
@@ -2022,6 +2044,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2022
2044
|
await fse.move(assetsDirectory, backupDirectory);
|
|
2023
2045
|
await fse.mkdir(assetsDirectory);
|
|
2024
2046
|
await fse.outputFile(path.join(assetsDirectory, ".gitkeep"), "");
|
|
2047
|
+
this.#reportInfo(`created assets backup directory ${backupDirectory}`);
|
|
2025
2048
|
} catch (err) {
|
|
2026
2049
|
throw new ProviderTransferError(
|
|
2027
2050
|
"The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory",
|
|
@@ -2039,17 +2062,20 @@ class LocalStrapiDestinationProvider {
|
|
|
2039
2062
|
return;
|
|
2040
2063
|
}
|
|
2041
2064
|
if (this.strapi.config.get("plugin::upload").provider === "local") {
|
|
2065
|
+
this.#reportInfo("removing assets backup");
|
|
2042
2066
|
assertValidStrapi(this.strapi);
|
|
2043
2067
|
const backupDirectory = path.join(
|
|
2044
2068
|
this.strapi.dirs.static.public,
|
|
2045
2069
|
this.uploadsBackupDirectoryName
|
|
2046
2070
|
);
|
|
2047
2071
|
await fse.rm(backupDirectory, { recursive: true, force: true });
|
|
2072
|
+
this.#reportInfo("successfully removed assets backup");
|
|
2048
2073
|
}
|
|
2049
2074
|
}
|
|
2050
2075
|
// TODO: Move this logic to the restore strategy
|
|
2051
2076
|
async createAssetsWriteStream() {
|
|
2052
2077
|
assertValidStrapi(this.strapi, "Not able to stream Assets");
|
|
2078
|
+
this.#reportInfo("creating assets write stream");
|
|
2053
2079
|
if (!this.#areAssetsIncluded()) {
|
|
2054
2080
|
throw new ProviderTransferError(
|
|
2055
2081
|
"Attempting to transfer assets when `assets` is not set in restore options"
|
|
@@ -2144,6 +2170,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2144
2170
|
}
|
|
2145
2171
|
async createConfigurationWriteStream() {
|
|
2146
2172
|
assertValidStrapi(this.strapi, "Not able to stream Configurations");
|
|
2173
|
+
this.#reportInfo("creating configuration write stream");
|
|
2147
2174
|
const { strategy } = this.options;
|
|
2148
2175
|
if (strategy === "restore") {
|
|
2149
2176
|
return createConfigurationWriteStream(this.strapi, this.transaction);
|
|
@@ -2155,6 +2182,7 @@ class LocalStrapiDestinationProvider {
|
|
|
2155
2182
|
});
|
|
2156
2183
|
}
|
|
2157
2184
|
async createLinksWriteStream() {
|
|
2185
|
+
this.#reportInfo("creating links write stream");
|
|
2158
2186
|
if (!this.strapi) {
|
|
2159
2187
|
throw new Error("Not able to stream links. Strapi instance not found");
|
|
2160
2188
|
}
|
|
@@ -2353,12 +2381,24 @@ class LocalStrapiSourceProvider {
|
|
|
2353
2381
|
type = "source";
|
|
2354
2382
|
options;
|
|
2355
2383
|
strapi;
|
|
2384
|
+
#diagnostics;
|
|
2356
2385
|
constructor(options) {
|
|
2357
2386
|
this.options = options;
|
|
2358
2387
|
}
|
|
2359
|
-
async bootstrap() {
|
|
2388
|
+
async bootstrap(diagnostics) {
|
|
2389
|
+
this.#diagnostics = diagnostics;
|
|
2360
2390
|
this.strapi = await this.options.getStrapi();
|
|
2361
2391
|
}
|
|
2392
|
+
#reportInfo(message) {
|
|
2393
|
+
this.#diagnostics?.report({
|
|
2394
|
+
details: {
|
|
2395
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2396
|
+
message,
|
|
2397
|
+
source: "local-source-provider"
|
|
2398
|
+
},
|
|
2399
|
+
kind: "info"
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2362
2402
|
async close() {
|
|
2363
2403
|
const { autoDestroy } = this.options;
|
|
2364
2404
|
if (autoDestroy === void 0 || autoDestroy === true) {
|
|
@@ -2366,6 +2406,7 @@ class LocalStrapiSourceProvider {
|
|
|
2366
2406
|
}
|
|
2367
2407
|
}
|
|
2368
2408
|
getMetadata() {
|
|
2409
|
+
this.#reportInfo("getting metadata");
|
|
2369
2410
|
const strapiVersion = strapi.config.get("info.strapi");
|
|
2370
2411
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2371
2412
|
return {
|
|
@@ -2377,6 +2418,7 @@ class LocalStrapiSourceProvider {
|
|
|
2377
2418
|
}
|
|
2378
2419
|
async createEntitiesReadStream() {
|
|
2379
2420
|
assertValidStrapi(this.strapi, "Not able to stream entities");
|
|
2421
|
+
this.#reportInfo("creating entities read stream");
|
|
2380
2422
|
return chain([
|
|
2381
2423
|
// Entities stream
|
|
2382
2424
|
createEntitiesStream(this.strapi),
|
|
@@ -2386,14 +2428,17 @@ class LocalStrapiSourceProvider {
|
|
|
2386
2428
|
}
|
|
2387
2429
|
createLinksReadStream() {
|
|
2388
2430
|
assertValidStrapi(this.strapi, "Not able to stream links");
|
|
2431
|
+
this.#reportInfo("creating links read stream");
|
|
2389
2432
|
return createLinksStream(this.strapi);
|
|
2390
2433
|
}
|
|
2391
2434
|
createConfigurationReadStream() {
|
|
2392
2435
|
assertValidStrapi(this.strapi, "Not able to stream configuration");
|
|
2436
|
+
this.#reportInfo("creating configuration read stream");
|
|
2393
2437
|
return createConfigurationStream(this.strapi);
|
|
2394
2438
|
}
|
|
2395
2439
|
getSchemas() {
|
|
2396
2440
|
assertValidStrapi(this.strapi, "Not able to get Schemas");
|
|
2441
|
+
this.#reportInfo("getting schemas");
|
|
2397
2442
|
const schemas = schemasToValidJSON({
|
|
2398
2443
|
...this.strapi.contentTypes,
|
|
2399
2444
|
...this.strapi.components
|
|
@@ -2405,13 +2450,14 @@ class LocalStrapiSourceProvider {
|
|
|
2405
2450
|
}
|
|
2406
2451
|
createAssetsReadStream() {
|
|
2407
2452
|
assertValidStrapi(this.strapi, "Not able to stream assets");
|
|
2453
|
+
this.#reportInfo("creating assets read stream");
|
|
2408
2454
|
return createAssetsStream(this.strapi);
|
|
2409
2455
|
}
|
|
2410
2456
|
}
|
|
2411
2457
|
const createDispatcher = (ws, retryMessageOptions = {
|
|
2412
2458
|
retryMessageMaxRetries: 5,
|
|
2413
2459
|
retryMessageTimeout: 3e4
|
|
2414
|
-
}) => {
|
|
2460
|
+
}, reportInfo) => {
|
|
2415
2461
|
const state = {};
|
|
2416
2462
|
const dispatch = async (message, options = {}) => {
|
|
2417
2463
|
if (!ws) {
|
|
@@ -2424,6 +2470,16 @@ const createDispatcher = (ws, retryMessageOptions = {
|
|
|
2424
2470
|
if (options.attachTransfer) {
|
|
2425
2471
|
Object.assign(payload, { transferID: state.transfer?.id });
|
|
2426
2472
|
}
|
|
2473
|
+
if (message.type === "command") {
|
|
2474
|
+
reportInfo?.(
|
|
2475
|
+
`dispatching message command:${message.command} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
|
|
2476
|
+
);
|
|
2477
|
+
} else if (message.type === "transfer") {
|
|
2478
|
+
const messageToSend = message;
|
|
2479
|
+
reportInfo?.(
|
|
2480
|
+
`dispatching message action:${messageToSend.action} ${messageToSend.kind === "step" ? `step:${messageToSend.step}` : ""} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
|
|
2481
|
+
);
|
|
2482
|
+
}
|
|
2427
2483
|
const stringifiedPayload = JSON.stringify(payload);
|
|
2428
2484
|
ws.send(stringifiedPayload, (error) => {
|
|
2429
2485
|
if (error) {
|
|
@@ -2446,6 +2502,16 @@ const createDispatcher = (ws, retryMessageOptions = {
|
|
|
2446
2502
|
const interval = setInterval(sendPeriodically, retryMessageTimeout);
|
|
2447
2503
|
const onResponse = (raw) => {
|
|
2448
2504
|
const response = JSON.parse(raw.toString());
|
|
2505
|
+
if (message.type === "command") {
|
|
2506
|
+
reportInfo?.(
|
|
2507
|
+
`recieved response to message command: ${message.command} uuid: ${uuid} sent: ${numberOfTimesMessageWasSent}`
|
|
2508
|
+
);
|
|
2509
|
+
} else if (message.type === "transfer") {
|
|
2510
|
+
const messageToSend = message;
|
|
2511
|
+
reportInfo?.(
|
|
2512
|
+
`recieved response to message action:${messageToSend.action} ${messageToSend.kind === "step" ? `step:${messageToSend.step}` : ""} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
|
|
2513
|
+
);
|
|
2514
|
+
}
|
|
2449
2515
|
if (response.uuid === uuid) {
|
|
2450
2516
|
clearInterval(interval);
|
|
2451
2517
|
if (response.error) {
|
|
@@ -2577,6 +2643,7 @@ class RemoteStrapiDestinationProvider {
|
|
|
2577
2643
|
dispatcher;
|
|
2578
2644
|
transferID;
|
|
2579
2645
|
stats;
|
|
2646
|
+
#diagnostics;
|
|
2580
2647
|
constructor(options) {
|
|
2581
2648
|
this.options = options;
|
|
2582
2649
|
this.ws = null;
|
|
@@ -2703,7 +2770,18 @@ class RemoteStrapiDestinationProvider {
|
|
|
2703
2770
|
}
|
|
2704
2771
|
});
|
|
2705
2772
|
}
|
|
2706
|
-
|
|
2773
|
+
#reportInfo(message) {
|
|
2774
|
+
this.#diagnostics?.report({
|
|
2775
|
+
details: {
|
|
2776
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
2777
|
+
message,
|
|
2778
|
+
source: "remote-destination-provider"
|
|
2779
|
+
},
|
|
2780
|
+
kind: "info"
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
async bootstrap(diagnostics) {
|
|
2784
|
+
this.#diagnostics = diagnostics;
|
|
2707
2785
|
const { url, auth } = this.options;
|
|
2708
2786
|
const validProtocols = ["https:", "http:"];
|
|
2709
2787
|
let ws;
|
|
@@ -2720,6 +2798,7 @@ class RemoteStrapiDestinationProvider {
|
|
|
2720
2798
|
const wsUrl = `${wsProtocol}//${url.host}${trimTrailingSlash(
|
|
2721
2799
|
url.pathname
|
|
2722
2800
|
)}${TRANSFER_PATH}/push`;
|
|
2801
|
+
this.#reportInfo("establishing websocket connection");
|
|
2723
2802
|
if (!auth) {
|
|
2724
2803
|
ws = await connectToWebsocket(wsUrl);
|
|
2725
2804
|
} else if (auth.type === "token") {
|
|
@@ -2733,10 +2812,19 @@ class RemoteStrapiDestinationProvider {
|
|
|
2733
2812
|
}
|
|
2734
2813
|
});
|
|
2735
2814
|
}
|
|
2815
|
+
this.#reportInfo("established websocket connection");
|
|
2736
2816
|
this.ws = ws;
|
|
2737
2817
|
const { retryMessageOptions } = this.options;
|
|
2738
|
-
this
|
|
2818
|
+
this.#reportInfo("creating dispatcher");
|
|
2819
|
+
this.dispatcher = createDispatcher(
|
|
2820
|
+
this.ws,
|
|
2821
|
+
retryMessageOptions,
|
|
2822
|
+
(message) => this.#reportInfo(message)
|
|
2823
|
+
);
|
|
2824
|
+
this.#reportInfo("created dispatcher");
|
|
2825
|
+
this.#reportInfo("initialize transfer");
|
|
2739
2826
|
this.transferID = await this.initTransfer();
|
|
2827
|
+
this.#reportInfo(`initialized transfer ${this.transferID}`);
|
|
2740
2828
|
this.dispatcher.setTransferProperties({ id: this.transferID, kind: "push" });
|
|
2741
2829
|
await this.dispatcher.dispatchTransferAction("bootstrap");
|
|
2742
2830
|
}
|
|
@@ -2863,6 +2951,7 @@ class RemoteStrapiSourceProvider {
|
|
|
2863
2951
|
this.dispatcher = null;
|
|
2864
2952
|
}
|
|
2865
2953
|
results;
|
|
2954
|
+
#diagnostics;
|
|
2866
2955
|
async #createStageReadStream(stage) {
|
|
2867
2956
|
const startResult = await this.#startStep(stage);
|
|
2868
2957
|
if (startResult instanceof Error) {
|
|
@@ -3045,7 +3134,18 @@ class RemoteStrapiSourceProvider {
|
|
|
3045
3134
|
}
|
|
3046
3135
|
return res.transferID;
|
|
3047
3136
|
}
|
|
3048
|
-
|
|
3137
|
+
#reportInfo(message) {
|
|
3138
|
+
this.#diagnostics?.report({
|
|
3139
|
+
details: {
|
|
3140
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
3141
|
+
message,
|
|
3142
|
+
source: "remote-source-provider"
|
|
3143
|
+
},
|
|
3144
|
+
kind: "info"
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
async bootstrap(diagnostics) {
|
|
3148
|
+
this.#diagnostics = diagnostics;
|
|
3049
3149
|
const { url, auth } = this.options;
|
|
3050
3150
|
let ws;
|
|
3051
3151
|
this.assertValidProtocol(url);
|
|
@@ -3053,6 +3153,7 @@ class RemoteStrapiSourceProvider {
|
|
|
3053
3153
|
const wsUrl = `${wsProtocol}//${url.host}${trimTrailingSlash(
|
|
3054
3154
|
url.pathname
|
|
3055
3155
|
)}${TRANSFER_PATH}/pull`;
|
|
3156
|
+
this.#reportInfo("establishing websocket connection");
|
|
3056
3157
|
if (!auth) {
|
|
3057
3158
|
ws = await connectToWebsocket(wsUrl);
|
|
3058
3159
|
} else if (auth.type === "token") {
|
|
@@ -3066,10 +3167,19 @@ class RemoteStrapiSourceProvider {
|
|
|
3066
3167
|
}
|
|
3067
3168
|
});
|
|
3068
3169
|
}
|
|
3170
|
+
this.#reportInfo("established websocket connection");
|
|
3069
3171
|
this.ws = ws;
|
|
3070
3172
|
const { retryMessageOptions } = this.options;
|
|
3071
|
-
this
|
|
3173
|
+
this.#reportInfo("creating dispatcher");
|
|
3174
|
+
this.dispatcher = createDispatcher(
|
|
3175
|
+
this.ws,
|
|
3176
|
+
retryMessageOptions,
|
|
3177
|
+
(message) => this.#reportInfo(message)
|
|
3178
|
+
);
|
|
3179
|
+
this.#reportInfo("creating dispatcher");
|
|
3180
|
+
this.#reportInfo("initialize transfer");
|
|
3072
3181
|
const transferID = await this.initTransfer();
|
|
3182
|
+
this.#reportInfo(`initialized transfer ${transferID}`);
|
|
3073
3183
|
this.dispatcher.setTransferProperties({ id: transferID, kind: "pull" });
|
|
3074
3184
|
await this.dispatcher.dispatchTransferAction("bootstrap");
|
|
3075
3185
|
}
|
|
@@ -4060,6 +4170,7 @@ class LocalFileSourceProvider {
|
|
|
4060
4170
|
name = "source::local-file";
|
|
4061
4171
|
options;
|
|
4062
4172
|
#metadata;
|
|
4173
|
+
#diagnostics;
|
|
4063
4174
|
constructor(options) {
|
|
4064
4175
|
this.options = options;
|
|
4065
4176
|
const { encryption } = this.options;
|
|
@@ -4067,10 +4178,21 @@ class LocalFileSourceProvider {
|
|
|
4067
4178
|
throw new Error("Missing encryption key");
|
|
4068
4179
|
}
|
|
4069
4180
|
}
|
|
4181
|
+
#reportInfo(message) {
|
|
4182
|
+
this.#diagnostics?.report({
|
|
4183
|
+
details: {
|
|
4184
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
4185
|
+
message,
|
|
4186
|
+
source: "file-source-provider"
|
|
4187
|
+
},
|
|
4188
|
+
kind: "info"
|
|
4189
|
+
});
|
|
4190
|
+
}
|
|
4070
4191
|
/**
|
|
4071
4192
|
* Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
|
|
4072
4193
|
*/
|
|
4073
|
-
async bootstrap() {
|
|
4194
|
+
async bootstrap(diagnostics) {
|
|
4195
|
+
this.#diagnostics = diagnostics;
|
|
4074
4196
|
const { path: filePath } = this.options.file;
|
|
4075
4197
|
try {
|
|
4076
4198
|
await this.#loadMetadata();
|
|
@@ -4095,12 +4217,14 @@ class LocalFileSourceProvider {
|
|
|
4095
4217
|
return this.#parseJSONFile(backupStream, path2);
|
|
4096
4218
|
}
|
|
4097
4219
|
async getMetadata() {
|
|
4220
|
+
this.#reportInfo("getting metadata");
|
|
4098
4221
|
if (!this.#metadata) {
|
|
4099
4222
|
await this.#loadMetadata();
|
|
4100
4223
|
}
|
|
4101
4224
|
return this.#metadata ?? null;
|
|
4102
4225
|
}
|
|
4103
4226
|
async getSchemas() {
|
|
4227
|
+
this.#reportInfo("getting schemas");
|
|
4104
4228
|
const schemaCollection = await collect(
|
|
4105
4229
|
this.createSchemasReadStream()
|
|
4106
4230
|
);
|
|
@@ -4111,21 +4235,26 @@ class LocalFileSourceProvider {
|
|
|
4111
4235
|
return schemasToValidJSON(schemas);
|
|
4112
4236
|
}
|
|
4113
4237
|
createEntitiesReadStream() {
|
|
4238
|
+
this.#reportInfo("creating entities read stream");
|
|
4114
4239
|
return this.#streamJsonlDirectory("entities");
|
|
4115
4240
|
}
|
|
4116
4241
|
createSchemasReadStream() {
|
|
4242
|
+
this.#reportInfo("creating schemas read stream");
|
|
4117
4243
|
return this.#streamJsonlDirectory("schemas");
|
|
4118
4244
|
}
|
|
4119
4245
|
createLinksReadStream() {
|
|
4246
|
+
this.#reportInfo("creating links read stream");
|
|
4120
4247
|
return this.#streamJsonlDirectory("links");
|
|
4121
4248
|
}
|
|
4122
4249
|
createConfigurationReadStream() {
|
|
4250
|
+
this.#reportInfo("creating configuration read stream");
|
|
4123
4251
|
return this.#streamJsonlDirectory("configuration");
|
|
4124
4252
|
}
|
|
4125
4253
|
createAssetsReadStream() {
|
|
4126
4254
|
const inStream = this.#getBackupStream();
|
|
4127
4255
|
const outStream = new PassThrough({ objectMode: true });
|
|
4128
4256
|
const loadAssetMetadata = this.#loadAssetMetadata.bind(this);
|
|
4257
|
+
this.#reportInfo("creating assets read stream");
|
|
4129
4258
|
pipeline(
|
|
4130
4259
|
[
|
|
4131
4260
|
inStream,
|
|
@@ -4326,9 +4455,20 @@ class LocalFileDestinationProvider {
|
|
|
4326
4455
|
results = {};
|
|
4327
4456
|
#providersMetadata = {};
|
|
4328
4457
|
#archive = {};
|
|
4458
|
+
#diagnostics;
|
|
4329
4459
|
constructor(options) {
|
|
4330
4460
|
this.options = options;
|
|
4331
4461
|
}
|
|
4462
|
+
#reportInfo(message) {
|
|
4463
|
+
this.#diagnostics?.report({
|
|
4464
|
+
details: {
|
|
4465
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
4466
|
+
message,
|
|
4467
|
+
source: "file-destination-provider"
|
|
4468
|
+
},
|
|
4469
|
+
kind: "info"
|
|
4470
|
+
});
|
|
4471
|
+
}
|
|
4332
4472
|
get #archivePath() {
|
|
4333
4473
|
const { encryption, compression, file } = this.options;
|
|
4334
4474
|
let filePath = `${file.path}.tar`;
|
|
@@ -4345,9 +4485,11 @@ class LocalFileDestinationProvider {
|
|
|
4345
4485
|
return this;
|
|
4346
4486
|
}
|
|
4347
4487
|
createGzip() {
|
|
4488
|
+
this.#reportInfo("creating gzip");
|
|
4348
4489
|
return zip$1.createGzip();
|
|
4349
4490
|
}
|
|
4350
|
-
bootstrap() {
|
|
4491
|
+
bootstrap(diagnostics) {
|
|
4492
|
+
this.#diagnostics = diagnostics;
|
|
4351
4493
|
const { compression, encryption } = this.options;
|
|
4352
4494
|
if (encryption.enabled && !encryption.key) {
|
|
4353
4495
|
throw new Error("Can't encrypt without a key");
|
|
@@ -4386,6 +4528,7 @@ class LocalFileDestinationProvider {
|
|
|
4386
4528
|
}
|
|
4387
4529
|
}
|
|
4388
4530
|
async rollback() {
|
|
4531
|
+
this.#reportInfo("rolling back");
|
|
4389
4532
|
await this.close();
|
|
4390
4533
|
await rm(this.#archivePath, { force: true });
|
|
4391
4534
|
}
|
|
@@ -4393,6 +4536,7 @@ class LocalFileDestinationProvider {
|
|
|
4393
4536
|
return null;
|
|
4394
4537
|
}
|
|
4395
4538
|
async #writeMetadata() {
|
|
4539
|
+
this.#reportInfo("writing metadata");
|
|
4396
4540
|
const metadata = this.#providersMetadata.source;
|
|
4397
4541
|
if (metadata) {
|
|
4398
4542
|
await new Promise((resolve) => {
|
|
@@ -4413,6 +4557,7 @@ class LocalFileDestinationProvider {
|
|
|
4413
4557
|
if (!this.#archive.stream) {
|
|
4414
4558
|
throw new Error("Archive stream is unavailable");
|
|
4415
4559
|
}
|
|
4560
|
+
this.#reportInfo("creating schemas write stream");
|
|
4416
4561
|
const filePathFactory = createFilePathFactory("schemas");
|
|
4417
4562
|
const entryStream = createTarEntryStream(
|
|
4418
4563
|
this.#archive.stream,
|
|
@@ -4425,6 +4570,7 @@ class LocalFileDestinationProvider {
|
|
|
4425
4570
|
if (!this.#archive.stream) {
|
|
4426
4571
|
throw new Error("Archive stream is unavailable");
|
|
4427
4572
|
}
|
|
4573
|
+
this.#reportInfo("creating entities write stream");
|
|
4428
4574
|
const filePathFactory = createFilePathFactory("entities");
|
|
4429
4575
|
const entryStream = createTarEntryStream(
|
|
4430
4576
|
this.#archive.stream,
|
|
@@ -4437,6 +4583,7 @@ class LocalFileDestinationProvider {
|
|
|
4437
4583
|
if (!this.#archive.stream) {
|
|
4438
4584
|
throw new Error("Archive stream is unavailable");
|
|
4439
4585
|
}
|
|
4586
|
+
this.#reportInfo("creating links write stream");
|
|
4440
4587
|
const filePathFactory = createFilePathFactory("links");
|
|
4441
4588
|
const entryStream = createTarEntryStream(
|
|
4442
4589
|
this.#archive.stream,
|
|
@@ -4449,6 +4596,7 @@ class LocalFileDestinationProvider {
|
|
|
4449
4596
|
if (!this.#archive.stream) {
|
|
4450
4597
|
throw new Error("Archive stream is unavailable");
|
|
4451
4598
|
}
|
|
4599
|
+
this.#reportInfo("creating configuration write stream");
|
|
4452
4600
|
const filePathFactory = createFilePathFactory("configuration");
|
|
4453
4601
|
const entryStream = createTarEntryStream(
|
|
4454
4602
|
this.#archive.stream,
|
|
@@ -4462,6 +4610,7 @@ class LocalFileDestinationProvider {
|
|
|
4462
4610
|
if (!archiveStream) {
|
|
4463
4611
|
throw new Error("Archive stream is unavailable");
|
|
4464
4612
|
}
|
|
4613
|
+
this.#reportInfo("creating assets write stream");
|
|
4465
4614
|
return new Writable({
|
|
4466
4615
|
objectMode: true,
|
|
4467
4616
|
write(data, _encoding, callback) {
|