@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.
@@ -25,6 +25,7 @@ export type WarningDiagnostic = GenericDiagnostic<'warning', {
25
25
  origin?: string;
26
26
  }>;
27
27
  export type InfoDiagnostic<T = unknown> = GenericDiagnostic<'info', {
28
+ source: string;
28
29
  params?: T;
29
30
  }>;
30
31
  export interface IDiagnosticReporter {
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../src/engine/diagnostic.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,EAAE,CAAC,GAAG,OAAO,IAAI;IACrE,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE;QACP,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,IAAI,CAAC;KACjB,GAAG,CAAC,CAAC;CACP,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI,CAC1E,UAAU,EAAE;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG,UAAU,SAAS,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,KAC7D,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,cAAc,cAAc,EAAE,CAAC;AAE5E,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,eAAe,IAAI,CAAC,SAAS,YAAY,GAC5E,kBAAkB,GAClB,CAAC,SAAS,cAAc,MAAM,CAAC,EAAE,GAC/B,CAAC,SAAS,cAAc,GACtB,kBAAkB,CAAC,CAAC,CAAC,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AAC,CAAC,GAAG,OAAO,IAAI,iBAAiB,CACzD,MAAM,EACN;IACE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ,CACF,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE;QACL,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,CAAC;KAC9B,CAAC;IAEF,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB,CAAC;IACpD,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,mBAAmB,CAAC;IAChE,EAAE,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC;CAC7F;AAED,QAAA,MAAM,wBAAwB,aACnB,0BAA0B,KAClC,mBAyDF,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
@@ -4,6 +4,7 @@
4
4
  import zlib from 'zlib';
5
5
  import { Writable } from 'stream';
6
6
  import type { IDestinationProvider, IDestinationProviderTransferResults, IMetadata, ProviderType } from '../../../../types';
7
+ import type { IDiagnosticReporter } from '../../../engine/diagnostic';
7
8
  export interface ILocalFileDestinationProviderOptions {
8
9
  encryption: {
9
10
  enabled: boolean;
@@ -33,7 +34,7 @@ declare class LocalFileDestinationProvider implements IDestinationProvider {
33
34
  constructor(options: ILocalFileDestinationProviderOptions);
34
35
  setMetadata(target: ProviderType, metadata: IMetadata): IDestinationProvider;
35
36
  createGzip(): zlib.Gzip;
36
- bootstrap(): void | Promise<void>;
37
+ bootstrap(diagnostics: IDiagnosticReporter): void | Promise<void>;
37
38
  close(): Promise<void>;
38
39
  rollback(): Promise<void>;
39
40
  getMetadata(): null;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/destination/index.ts"],"names":[],"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AQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAM/B,WAAW;IA4BX,wBAAwB;IAgBxB,yBAAyB,IAAI,QAAQ;IAgBrC,sBAAsB,IAAI,QAAQ;IAgBlC,8BAA8B,IAAI,QAAQ;IAgB1C,uBAAuB,IAAI,QAAQ;CA8CpC"}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { Readable } from 'stream';
3
3
  import type { IMetadata, ISourceProvider, ProviderType } from '../../../../types';
4
+ import type { IDiagnosticReporter } from '../../../engine/diagnostic';
4
5
  /**
5
6
  * Provider options
6
7
  */
@@ -26,7 +27,7 @@ declare class LocalFileSourceProvider implements ISourceProvider {
26
27
  /**
27
28
  * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
28
29
  */
29
- bootstrap(): Promise<void>;
30
+ bootstrap(diagnostics: IDiagnosticReporter): Promise<void>;
30
31
  getMetadata(): Promise<IMetadata | null>;
31
32
  getSchemas(): Promise<any>;
32
33
  createEntitiesReadStream(): Readable;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/file/providers/source/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAYvC,OAAO,KAAK,EAAU,SAAS,EAAE,eAAe,EAAE,YAAY,EAAS,MAAM,mBAAmB,CAAC;AAajG;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,UAAU,EAAE;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,WAAW,EAAE;QACX,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;CACH;AAED,eAAO,MAAM,6BAA6B,YAAa,+BAA+B,4BAErF,CAAC;AAEF,cAAM,uBAAwB,YAAW,eAAe;;IACtD,IAAI,EAAE,YA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,6BAA6B,IAAI,QAAQ;IAMzC,sBAAsB,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;CA+KvD"}
package/dist/index.js CHANGED
@@ -604,7 +604,7 @@ class TransferEngine {
604
604
  reportInfo(message, params) {
605
605
  this.diagnostics.report({
606
606
  kind: "info",
607
- details: { createdAt: /* @__PURE__ */ new Date(), message, params }
607
+ details: { createdAt: /* @__PURE__ */ new Date(), message, params, source: "engine" }
608
608
  });
609
609
  }
610
610
  /**
@@ -896,8 +896,8 @@ ${formattedDiffs}`,
896
896
  */
897
897
  async bootstrap() {
898
898
  const results = await Promise.allSettled([
899
- this.sourceProvider.bootstrap?.(),
900
- this.destinationProvider.bootstrap?.()
899
+ this.sourceProvider.bootstrap?.(this.diagnostics),
900
+ this.destinationProvider.bootstrap?.(this.diagnostics)
901
901
  ]);
902
902
  results.forEach((result) => {
903
903
  if (result.status === "rejected") {
@@ -1902,6 +1902,7 @@ class LocalStrapiDestinationProvider {
1902
1902
  transaction;
1903
1903
  uploadsBackupDirectoryName;
1904
1904
  onWarning;
1905
+ #diagnostics;
1905
1906
  /**
1906
1907
  * The entities mapper is used to map old entities to their new IDs
1907
1908
  */
@@ -1911,7 +1912,8 @@ class LocalStrapiDestinationProvider {
1911
1912
  this.#entitiesMapper = {};
1912
1913
  this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;
1913
1914
  }
1914
- async bootstrap() {
1915
+ async bootstrap(diagnostics) {
1916
+ this.#diagnostics = diagnostics;
1915
1917
  this.#validateOptions();
1916
1918
  this.strapi = await this.options.getStrapi();
1917
1919
  if (!this.strapi) {
@@ -1928,6 +1930,16 @@ class LocalStrapiDestinationProvider {
1928
1930
  const excluded = this.options.restore?.entities?.exclude && this.options.restore?.entities.exclude.includes(type);
1929
1931
  return !excluded && !notIncluded;
1930
1932
  };
1933
+ #reportInfo(message) {
1934
+ this.#diagnostics?.report({
1935
+ details: {
1936
+ createdAt: /* @__PURE__ */ new Date(),
1937
+ message,
1938
+ source: "local-destination-provider"
1939
+ },
1940
+ kind: "info"
1941
+ });
1942
+ }
1931
1943
  async close() {
1932
1944
  const { autoDestroy } = this.options;
1933
1945
  this.transaction?.end();
@@ -1936,6 +1948,7 @@ class LocalStrapiDestinationProvider {
1936
1948
  }
1937
1949
  }
1938
1950
  #validateOptions() {
1951
+ this.#reportInfo("validating options");
1939
1952
  if (!VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {
1940
1953
  throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {
1941
1954
  check: "strategy",
@@ -1952,10 +1965,12 @@ class LocalStrapiDestinationProvider {
1952
1965
  if (!this.options.restore) {
1953
1966
  throw new ProviderValidationError("Missing restore options");
1954
1967
  }
1968
+ this.#reportInfo("deleting record ");
1955
1969
  return deleteRecords(this.strapi, this.options.restore);
1956
1970
  }
1957
1971
  async #deleteAllAssets(trx) {
1958
1972
  assertValidStrapi(this.strapi);
1973
+ this.#reportInfo("deleting all assets");
1959
1974
  if (!this.#areAssetsIncluded()) {
1960
1975
  return;
1961
1976
  }
@@ -1968,9 +1983,12 @@ class LocalStrapiDestinationProvider {
1968
1983
  }
1969
1984
  }
1970
1985
  }
1986
+ this.#reportInfo("deleted all assets");
1971
1987
  }
1972
1988
  async rollback() {
1989
+ this.#reportInfo("Rolling back transaction");
1973
1990
  await this.transaction?.rollback();
1991
+ this.#reportInfo("Rolled back transaction");
1974
1992
  }
1975
1993
  async beforeTransfer() {
1976
1994
  if (!this.strapi) {
@@ -1989,6 +2007,7 @@ class LocalStrapiDestinationProvider {
1989
2007
  });
1990
2008
  }
1991
2009
  getMetadata() {
2010
+ this.#reportInfo("getting metadata");
1992
2011
  assertValidStrapi(this.strapi, "Not able to get Schemas");
1993
2012
  const strapiVersion = this.strapi.config.get("info.strapi");
1994
2013
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -2000,6 +2019,7 @@ class LocalStrapiDestinationProvider {
2000
2019
  };
2001
2020
  }
2002
2021
  getSchemas() {
2022
+ this.#reportInfo("getting schema");
2003
2023
  assertValidStrapi(this.strapi, "Not able to get Schemas");
2004
2024
  const schemas = schemasToValidJSON({
2005
2025
  ...this.strapi.contentTypes,
@@ -2009,6 +2029,7 @@ class LocalStrapiDestinationProvider {
2009
2029
  }
2010
2030
  createEntitiesWriteStream() {
2011
2031
  assertValidStrapi(this.strapi, "Not able to import entities");
2032
+ this.#reportInfo("creating entities stream");
2012
2033
  const { strategy } = this.options;
2013
2034
  const updateMappingTable = (type, oldID, newID) => {
2014
2035
  if (!this.#entitiesMapper[type]) {
@@ -2035,6 +2056,7 @@ class LocalStrapiDestinationProvider {
2035
2056
  return;
2036
2057
  }
2037
2058
  if (this.strapi.config.get("plugin::upload").provider === "local") {
2059
+ this.#reportInfo("creating assets backup directory");
2038
2060
  const assetsDirectory = path__default.default.join(this.strapi.dirs.static.public, "uploads");
2039
2061
  const backupDirectory = path__default.default.join(
2040
2062
  this.strapi.dirs.static.public,
@@ -2050,6 +2072,7 @@ class LocalStrapiDestinationProvider {
2050
2072
  await fse__namespace.move(assetsDirectory, backupDirectory);
2051
2073
  await fse__namespace.mkdir(assetsDirectory);
2052
2074
  await fse__namespace.outputFile(path__default.default.join(assetsDirectory, ".gitkeep"), "");
2075
+ this.#reportInfo(`created assets backup directory ${backupDirectory}`);
2053
2076
  } catch (err) {
2054
2077
  throw new ProviderTransferError(
2055
2078
  "The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory",
@@ -2067,17 +2090,20 @@ class LocalStrapiDestinationProvider {
2067
2090
  return;
2068
2091
  }
2069
2092
  if (this.strapi.config.get("plugin::upload").provider === "local") {
2093
+ this.#reportInfo("removing assets backup");
2070
2094
  assertValidStrapi(this.strapi);
2071
2095
  const backupDirectory = path__default.default.join(
2072
2096
  this.strapi.dirs.static.public,
2073
2097
  this.uploadsBackupDirectoryName
2074
2098
  );
2075
2099
  await fse__namespace.rm(backupDirectory, { recursive: true, force: true });
2100
+ this.#reportInfo("successfully removed assets backup");
2076
2101
  }
2077
2102
  }
2078
2103
  // TODO: Move this logic to the restore strategy
2079
2104
  async createAssetsWriteStream() {
2080
2105
  assertValidStrapi(this.strapi, "Not able to stream Assets");
2106
+ this.#reportInfo("creating assets write stream");
2081
2107
  if (!this.#areAssetsIncluded()) {
2082
2108
  throw new ProviderTransferError(
2083
2109
  "Attempting to transfer assets when `assets` is not set in restore options"
@@ -2172,6 +2198,7 @@ class LocalStrapiDestinationProvider {
2172
2198
  }
2173
2199
  async createConfigurationWriteStream() {
2174
2200
  assertValidStrapi(this.strapi, "Not able to stream Configurations");
2201
+ this.#reportInfo("creating configuration write stream");
2175
2202
  const { strategy } = this.options;
2176
2203
  if (strategy === "restore") {
2177
2204
  return createConfigurationWriteStream(this.strapi, this.transaction);
@@ -2183,6 +2210,7 @@ class LocalStrapiDestinationProvider {
2183
2210
  });
2184
2211
  }
2185
2212
  async createLinksWriteStream() {
2213
+ this.#reportInfo("creating links write stream");
2186
2214
  if (!this.strapi) {
2187
2215
  throw new Error("Not able to stream links. Strapi instance not found");
2188
2216
  }
@@ -2381,12 +2409,24 @@ class LocalStrapiSourceProvider {
2381
2409
  type = "source";
2382
2410
  options;
2383
2411
  strapi;
2412
+ #diagnostics;
2384
2413
  constructor(options) {
2385
2414
  this.options = options;
2386
2415
  }
2387
- async bootstrap() {
2416
+ async bootstrap(diagnostics) {
2417
+ this.#diagnostics = diagnostics;
2388
2418
  this.strapi = await this.options.getStrapi();
2389
2419
  }
2420
+ #reportInfo(message) {
2421
+ this.#diagnostics?.report({
2422
+ details: {
2423
+ createdAt: /* @__PURE__ */ new Date(),
2424
+ message,
2425
+ source: "local-source-provider"
2426
+ },
2427
+ kind: "info"
2428
+ });
2429
+ }
2390
2430
  async close() {
2391
2431
  const { autoDestroy } = this.options;
2392
2432
  if (autoDestroy === void 0 || autoDestroy === true) {
@@ -2394,6 +2434,7 @@ class LocalStrapiSourceProvider {
2394
2434
  }
2395
2435
  }
2396
2436
  getMetadata() {
2437
+ this.#reportInfo("getting metadata");
2397
2438
  const strapiVersion = strapi.config.get("info.strapi");
2398
2439
  const createdAt = (/* @__PURE__ */ new Date()).toISOString();
2399
2440
  return {
@@ -2405,6 +2446,7 @@ class LocalStrapiSourceProvider {
2405
2446
  }
2406
2447
  async createEntitiesReadStream() {
2407
2448
  assertValidStrapi(this.strapi, "Not able to stream entities");
2449
+ this.#reportInfo("creating entities read stream");
2408
2450
  return streamChain.chain([
2409
2451
  // Entities stream
2410
2452
  createEntitiesStream(this.strapi),
@@ -2414,14 +2456,17 @@ class LocalStrapiSourceProvider {
2414
2456
  }
2415
2457
  createLinksReadStream() {
2416
2458
  assertValidStrapi(this.strapi, "Not able to stream links");
2459
+ this.#reportInfo("creating links read stream");
2417
2460
  return createLinksStream(this.strapi);
2418
2461
  }
2419
2462
  createConfigurationReadStream() {
2420
2463
  assertValidStrapi(this.strapi, "Not able to stream configuration");
2464
+ this.#reportInfo("creating configuration read stream");
2421
2465
  return createConfigurationStream(this.strapi);
2422
2466
  }
2423
2467
  getSchemas() {
2424
2468
  assertValidStrapi(this.strapi, "Not able to get Schemas");
2469
+ this.#reportInfo("getting schemas");
2425
2470
  const schemas = schemasToValidJSON({
2426
2471
  ...this.strapi.contentTypes,
2427
2472
  ...this.strapi.components
@@ -2433,13 +2478,14 @@ class LocalStrapiSourceProvider {
2433
2478
  }
2434
2479
  createAssetsReadStream() {
2435
2480
  assertValidStrapi(this.strapi, "Not able to stream assets");
2481
+ this.#reportInfo("creating assets read stream");
2436
2482
  return createAssetsStream(this.strapi);
2437
2483
  }
2438
2484
  }
2439
2485
  const createDispatcher = (ws2, retryMessageOptions = {
2440
2486
  retryMessageMaxRetries: 5,
2441
2487
  retryMessageTimeout: 3e4
2442
- }) => {
2488
+ }, reportInfo) => {
2443
2489
  const state = {};
2444
2490
  const dispatch = async (message, options = {}) => {
2445
2491
  if (!ws2) {
@@ -2452,6 +2498,16 @@ const createDispatcher = (ws2, retryMessageOptions = {
2452
2498
  if (options.attachTransfer) {
2453
2499
  Object.assign(payload, { transferID: state.transfer?.id });
2454
2500
  }
2501
+ if (message.type === "command") {
2502
+ reportInfo?.(
2503
+ `dispatching message command:${message.command} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
2504
+ );
2505
+ } else if (message.type === "transfer") {
2506
+ const messageToSend = message;
2507
+ reportInfo?.(
2508
+ `dispatching message action:${messageToSend.action} ${messageToSend.kind === "step" ? `step:${messageToSend.step}` : ""} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
2509
+ );
2510
+ }
2455
2511
  const stringifiedPayload = JSON.stringify(payload);
2456
2512
  ws2.send(stringifiedPayload, (error) => {
2457
2513
  if (error) {
@@ -2474,6 +2530,16 @@ const createDispatcher = (ws2, retryMessageOptions = {
2474
2530
  const interval = setInterval(sendPeriodically, retryMessageTimeout);
2475
2531
  const onResponse = (raw) => {
2476
2532
  const response = JSON.parse(raw.toString());
2533
+ if (message.type === "command") {
2534
+ reportInfo?.(
2535
+ `recieved response to message command: ${message.command} uuid: ${uuid} sent: ${numberOfTimesMessageWasSent}`
2536
+ );
2537
+ } else if (message.type === "transfer") {
2538
+ const messageToSend = message;
2539
+ reportInfo?.(
2540
+ `recieved response to message action:${messageToSend.action} ${messageToSend.kind === "step" ? `step:${messageToSend.step}` : ""} uuid:${uuid} sent:${numberOfTimesMessageWasSent}`
2541
+ );
2542
+ }
2477
2543
  if (response.uuid === uuid) {
2478
2544
  clearInterval(interval);
2479
2545
  if (response.error) {
@@ -2605,6 +2671,7 @@ class RemoteStrapiDestinationProvider {
2605
2671
  dispatcher;
2606
2672
  transferID;
2607
2673
  stats;
2674
+ #diagnostics;
2608
2675
  constructor(options) {
2609
2676
  this.options = options;
2610
2677
  this.ws = null;
@@ -2731,7 +2798,18 @@ class RemoteStrapiDestinationProvider {
2731
2798
  }
2732
2799
  });
2733
2800
  }
2734
- async bootstrap() {
2801
+ #reportInfo(message) {
2802
+ this.#diagnostics?.report({
2803
+ details: {
2804
+ createdAt: /* @__PURE__ */ new Date(),
2805
+ message,
2806
+ source: "remote-destination-provider"
2807
+ },
2808
+ kind: "info"
2809
+ });
2810
+ }
2811
+ async bootstrap(diagnostics) {
2812
+ this.#diagnostics = diagnostics;
2735
2813
  const { url, auth } = this.options;
2736
2814
  const validProtocols = ["https:", "http:"];
2737
2815
  let ws2;
@@ -2748,6 +2826,7 @@ class RemoteStrapiDestinationProvider {
2748
2826
  const wsUrl = `${wsProtocol}//${url.host}${trimTrailingSlash(
2749
2827
  url.pathname
2750
2828
  )}${TRANSFER_PATH}/push`;
2829
+ this.#reportInfo("establishing websocket connection");
2751
2830
  if (!auth) {
2752
2831
  ws2 = await connectToWebsocket(wsUrl);
2753
2832
  } else if (auth.type === "token") {
@@ -2761,10 +2840,19 @@ class RemoteStrapiDestinationProvider {
2761
2840
  }
2762
2841
  });
2763
2842
  }
2843
+ this.#reportInfo("established websocket connection");
2764
2844
  this.ws = ws2;
2765
2845
  const { retryMessageOptions } = this.options;
2766
- this.dispatcher = createDispatcher(this.ws, retryMessageOptions);
2846
+ this.#reportInfo("creating dispatcher");
2847
+ this.dispatcher = createDispatcher(
2848
+ this.ws,
2849
+ retryMessageOptions,
2850
+ (message) => this.#reportInfo(message)
2851
+ );
2852
+ this.#reportInfo("created dispatcher");
2853
+ this.#reportInfo("initialize transfer");
2767
2854
  this.transferID = await this.initTransfer();
2855
+ this.#reportInfo(`initialized transfer ${this.transferID}`);
2768
2856
  this.dispatcher.setTransferProperties({ id: this.transferID, kind: "push" });
2769
2857
  await this.dispatcher.dispatchTransferAction("bootstrap");
2770
2858
  }
@@ -2891,6 +2979,7 @@ class RemoteStrapiSourceProvider {
2891
2979
  this.dispatcher = null;
2892
2980
  }
2893
2981
  results;
2982
+ #diagnostics;
2894
2983
  async #createStageReadStream(stage) {
2895
2984
  const startResult = await this.#startStep(stage);
2896
2985
  if (startResult instanceof Error) {
@@ -3073,7 +3162,18 @@ class RemoteStrapiSourceProvider {
3073
3162
  }
3074
3163
  return res.transferID;
3075
3164
  }
3076
- async bootstrap() {
3165
+ #reportInfo(message) {
3166
+ this.#diagnostics?.report({
3167
+ details: {
3168
+ createdAt: /* @__PURE__ */ new Date(),
3169
+ message,
3170
+ source: "remote-source-provider"
3171
+ },
3172
+ kind: "info"
3173
+ });
3174
+ }
3175
+ async bootstrap(diagnostics) {
3176
+ this.#diagnostics = diagnostics;
3077
3177
  const { url, auth } = this.options;
3078
3178
  let ws2;
3079
3179
  this.assertValidProtocol(url);
@@ -3081,6 +3181,7 @@ class RemoteStrapiSourceProvider {
3081
3181
  const wsUrl = `${wsProtocol}//${url.host}${trimTrailingSlash(
3082
3182
  url.pathname
3083
3183
  )}${TRANSFER_PATH}/pull`;
3184
+ this.#reportInfo("establishing websocket connection");
3084
3185
  if (!auth) {
3085
3186
  ws2 = await connectToWebsocket(wsUrl);
3086
3187
  } else if (auth.type === "token") {
@@ -3094,10 +3195,19 @@ class RemoteStrapiSourceProvider {
3094
3195
  }
3095
3196
  });
3096
3197
  }
3198
+ this.#reportInfo("established websocket connection");
3097
3199
  this.ws = ws2;
3098
3200
  const { retryMessageOptions } = this.options;
3099
- this.dispatcher = createDispatcher(this.ws, retryMessageOptions);
3201
+ this.#reportInfo("creating dispatcher");
3202
+ this.dispatcher = createDispatcher(
3203
+ this.ws,
3204
+ retryMessageOptions,
3205
+ (message) => this.#reportInfo(message)
3206
+ );
3207
+ this.#reportInfo("creating dispatcher");
3208
+ this.#reportInfo("initialize transfer");
3100
3209
  const transferID = await this.initTransfer();
3210
+ this.#reportInfo(`initialized transfer ${transferID}`);
3101
3211
  this.dispatcher.setTransferProperties({ id: transferID, kind: "pull" });
3102
3212
  await this.dispatcher.dispatchTransferAction("bootstrap");
3103
3213
  }
@@ -4088,6 +4198,7 @@ class LocalFileSourceProvider {
4088
4198
  name = "source::local-file";
4089
4199
  options;
4090
4200
  #metadata;
4201
+ #diagnostics;
4091
4202
  constructor(options) {
4092
4203
  this.options = options;
4093
4204
  const { encryption } = this.options;
@@ -4095,10 +4206,21 @@ class LocalFileSourceProvider {
4095
4206
  throw new Error("Missing encryption key");
4096
4207
  }
4097
4208
  }
4209
+ #reportInfo(message) {
4210
+ this.#diagnostics?.report({
4211
+ details: {
4212
+ createdAt: /* @__PURE__ */ new Date(),
4213
+ message,
4214
+ source: "file-source-provider"
4215
+ },
4216
+ kind: "info"
4217
+ });
4218
+ }
4098
4219
  /**
4099
4220
  * Pre flight checks regarding the provided options, making sure that the file can be opened (decrypted, decompressed), etc.
4100
4221
  */
4101
- async bootstrap() {
4222
+ async bootstrap(diagnostics) {
4223
+ this.#diagnostics = diagnostics;
4102
4224
  const { path: filePath } = this.options.file;
4103
4225
  try {
4104
4226
  await this.#loadMetadata();
@@ -4123,12 +4245,14 @@ class LocalFileSourceProvider {
4123
4245
  return this.#parseJSONFile(backupStream, path2);
4124
4246
  }
4125
4247
  async getMetadata() {
4248
+ this.#reportInfo("getting metadata");
4126
4249
  if (!this.#metadata) {
4127
4250
  await this.#loadMetadata();
4128
4251
  }
4129
4252
  return this.#metadata ?? null;
4130
4253
  }
4131
4254
  async getSchemas() {
4255
+ this.#reportInfo("getting schemas");
4132
4256
  const schemaCollection = await collect(
4133
4257
  this.createSchemasReadStream()
4134
4258
  );
@@ -4139,21 +4263,26 @@ class LocalFileSourceProvider {
4139
4263
  return schemasToValidJSON(schemas);
4140
4264
  }
4141
4265
  createEntitiesReadStream() {
4266
+ this.#reportInfo("creating entities read stream");
4142
4267
  return this.#streamJsonlDirectory("entities");
4143
4268
  }
4144
4269
  createSchemasReadStream() {
4270
+ this.#reportInfo("creating schemas read stream");
4145
4271
  return this.#streamJsonlDirectory("schemas");
4146
4272
  }
4147
4273
  createLinksReadStream() {
4274
+ this.#reportInfo("creating links read stream");
4148
4275
  return this.#streamJsonlDirectory("links");
4149
4276
  }
4150
4277
  createConfigurationReadStream() {
4278
+ this.#reportInfo("creating configuration read stream");
4151
4279
  return this.#streamJsonlDirectory("configuration");
4152
4280
  }
4153
4281
  createAssetsReadStream() {
4154
4282
  const inStream = this.#getBackupStream();
4155
4283
  const outStream = new stream$1.PassThrough({ objectMode: true });
4156
4284
  const loadAssetMetadata = this.#loadAssetMetadata.bind(this);
4285
+ this.#reportInfo("creating assets read stream");
4157
4286
  stream$1.pipeline(
4158
4287
  [
4159
4288
  inStream,
@@ -4354,9 +4483,20 @@ class LocalFileDestinationProvider {
4354
4483
  results = {};
4355
4484
  #providersMetadata = {};
4356
4485
  #archive = {};
4486
+ #diagnostics;
4357
4487
  constructor(options) {
4358
4488
  this.options = options;
4359
4489
  }
4490
+ #reportInfo(message) {
4491
+ this.#diagnostics?.report({
4492
+ details: {
4493
+ createdAt: /* @__PURE__ */ new Date(),
4494
+ message,
4495
+ source: "file-destination-provider"
4496
+ },
4497
+ kind: "info"
4498
+ });
4499
+ }
4360
4500
  get #archivePath() {
4361
4501
  const { encryption, compression, file } = this.options;
4362
4502
  let filePath = `${file.path}.tar`;
@@ -4373,9 +4513,11 @@ class LocalFileDestinationProvider {
4373
4513
  return this;
4374
4514
  }
4375
4515
  createGzip() {
4516
+ this.#reportInfo("creating gzip");
4376
4517
  return zip__default.default.createGzip();
4377
4518
  }
4378
- bootstrap() {
4519
+ bootstrap(diagnostics) {
4520
+ this.#diagnostics = diagnostics;
4379
4521
  const { compression, encryption } = this.options;
4380
4522
  if (encryption.enabled && !encryption.key) {
4381
4523
  throw new Error("Can't encrypt without a key");
@@ -4414,6 +4556,7 @@ class LocalFileDestinationProvider {
4414
4556
  }
4415
4557
  }
4416
4558
  async rollback() {
4559
+ this.#reportInfo("rolling back");
4417
4560
  await this.close();
4418
4561
  await fse.rm(this.#archivePath, { force: true });
4419
4562
  }
@@ -4421,6 +4564,7 @@ class LocalFileDestinationProvider {
4421
4564
  return null;
4422
4565
  }
4423
4566
  async #writeMetadata() {
4567
+ this.#reportInfo("writing metadata");
4424
4568
  const metadata = this.#providersMetadata.source;
4425
4569
  if (metadata) {
4426
4570
  await new Promise((resolve) => {
@@ -4441,6 +4585,7 @@ class LocalFileDestinationProvider {
4441
4585
  if (!this.#archive.stream) {
4442
4586
  throw new Error("Archive stream is unavailable");
4443
4587
  }
4588
+ this.#reportInfo("creating schemas write stream");
4444
4589
  const filePathFactory = createFilePathFactory("schemas");
4445
4590
  const entryStream = createTarEntryStream(
4446
4591
  this.#archive.stream,
@@ -4453,6 +4598,7 @@ class LocalFileDestinationProvider {
4453
4598
  if (!this.#archive.stream) {
4454
4599
  throw new Error("Archive stream is unavailable");
4455
4600
  }
4601
+ this.#reportInfo("creating entities write stream");
4456
4602
  const filePathFactory = createFilePathFactory("entities");
4457
4603
  const entryStream = createTarEntryStream(
4458
4604
  this.#archive.stream,
@@ -4465,6 +4611,7 @@ class LocalFileDestinationProvider {
4465
4611
  if (!this.#archive.stream) {
4466
4612
  throw new Error("Archive stream is unavailable");
4467
4613
  }
4614
+ this.#reportInfo("creating links write stream");
4468
4615
  const filePathFactory = createFilePathFactory("links");
4469
4616
  const entryStream = createTarEntryStream(
4470
4617
  this.#archive.stream,
@@ -4477,6 +4624,7 @@ class LocalFileDestinationProvider {
4477
4624
  if (!this.#archive.stream) {
4478
4625
  throw new Error("Archive stream is unavailable");
4479
4626
  }
4627
+ this.#reportInfo("creating configuration write stream");
4480
4628
  const filePathFactory = createFilePathFactory("configuration");
4481
4629
  const entryStream = createTarEntryStream(
4482
4630
  this.#archive.stream,
@@ -4490,6 +4638,7 @@ class LocalFileDestinationProvider {
4490
4638
  if (!archiveStream) {
4491
4639
  throw new Error("Archive stream is unavailable");
4492
4640
  }
4641
+ this.#reportInfo("creating assets write stream");
4493
4642
  return new stream$1.Writable({
4494
4643
  objectMode: true,
4495
4644
  write(data, _encoding, callback) {