@strapi/data-transfer 5.61.1 → 5.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/directory/providers/destination/index.d.ts +1 -1
  2. package/dist/directory/providers/destination/index.d.ts.map +1 -1
  3. package/dist/directory/providers/destination/index.js +15 -31
  4. package/dist/directory/providers/destination/index.js.map +1 -1
  5. package/dist/directory/providers/destination/index.mjs +15 -31
  6. package/dist/directory/providers/destination/index.mjs.map +1 -1
  7. package/dist/directory/providers/destination/utils.d.ts +1 -2
  8. package/dist/directory/providers/destination/utils.d.ts.map +1 -1
  9. package/dist/directory/providers/destination/utils.js +7 -36
  10. package/dist/directory/providers/destination/utils.js.map +1 -1
  11. package/dist/directory/providers/destination/utils.mjs +7 -36
  12. package/dist/directory/providers/destination/utils.mjs.map +1 -1
  13. package/dist/directory/providers/source/index.d.ts.map +1 -1
  14. package/dist/directory/providers/source/index.js +7 -7
  15. package/dist/directory/providers/source/index.js.map +1 -1
  16. package/dist/directory/providers/source/index.mjs +7 -7
  17. package/dist/directory/providers/source/index.mjs.map +1 -1
  18. package/dist/engine/index.d.ts.map +1 -1
  19. package/dist/engine/index.js +45 -32
  20. package/dist/engine/index.js.map +1 -1
  21. package/dist/engine/index.mjs +43 -30
  22. package/dist/engine/index.mjs.map +1 -1
  23. package/dist/file/providers/destination/index.d.ts +1 -1
  24. package/dist/file/providers/destination/index.d.ts.map +1 -1
  25. package/dist/file/providers/destination/index.js +46 -48
  26. package/dist/file/providers/destination/index.js.map +1 -1
  27. package/dist/file/providers/destination/index.mjs +46 -48
  28. package/dist/file/providers/destination/index.mjs.map +1 -1
  29. package/dist/file/providers/destination/utils.d.ts +1 -2
  30. package/dist/file/providers/destination/utils.d.ts.map +1 -1
  31. package/dist/file/providers/destination/utils.js +28 -37
  32. package/dist/file/providers/destination/utils.js.map +1 -1
  33. package/dist/file/providers/destination/utils.mjs +28 -37
  34. package/dist/file/providers/destination/utils.mjs.map +1 -1
  35. package/dist/file/providers/source/index.d.ts +1 -1
  36. package/dist/file/providers/source/index.d.ts.map +1 -1
  37. package/dist/file/providers/source/index.js +85 -61
  38. package/dist/file/providers/source/index.js.map +1 -1
  39. package/dist/file/providers/source/index.mjs +84 -60
  40. package/dist/file/providers/source/index.mjs.map +1 -1
  41. package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
  42. package/dist/strapi/providers/local-destination/index.js +12 -5
  43. package/dist/strapi/providers/local-destination/index.js.map +1 -1
  44. package/dist/strapi/providers/local-destination/index.mjs +13 -6
  45. package/dist/strapi/providers/local-destination/index.mjs.map +1 -1
  46. package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
  47. package/dist/strapi/providers/local-source/configuration.js +4 -3
  48. package/dist/strapi/providers/local-source/configuration.js.map +1 -1
  49. package/dist/strapi/providers/local-source/configuration.mjs +2 -1
  50. package/dist/strapi/providers/local-source/configuration.mjs.map +1 -1
  51. package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
  52. package/dist/strapi/providers/local-source/index.js +12 -2
  53. package/dist/strapi/providers/local-source/index.js.map +1 -1
  54. package/dist/strapi/providers/local-source/index.mjs +11 -1
  55. package/dist/strapi/providers/local-source/index.mjs.map +1 -1
  56. package/dist/strapi/remote/handlers/push.js +0 -1
  57. package/dist/strapi/remote/handlers/push.js.map +1 -1
  58. package/dist/strapi/remote/handlers/push.mjs +0 -1
  59. package/dist/strapi/remote/handlers/push.mjs.map +1 -1
  60. package/dist/utils/buffered-entry-writer.d.ts +21 -0
  61. package/dist/utils/buffered-entry-writer.d.ts.map +1 -0
  62. package/dist/utils/buffered-entry-writer.js +95 -0
  63. package/dist/utils/buffered-entry-writer.js.map +1 -0
  64. package/dist/utils/buffered-entry-writer.mjs +93 -0
  65. package/dist/utils/buffered-entry-writer.mjs.map +1 -0
  66. package/dist/utils/defer-writable.d.ts +11 -0
  67. package/dist/utils/defer-writable.d.ts.map +1 -0
  68. package/dist/utils/defer-writable.js +106 -0
  69. package/dist/utils/defer-writable.js.map +1 -0
  70. package/dist/utils/defer-writable.mjs +104 -0
  71. package/dist/utils/defer-writable.mjs.map +1 -0
  72. package/dist/utils/esm-deps.d.ts +16 -0
  73. package/dist/utils/esm-deps.d.ts.map +1 -0
  74. package/dist/utils/esm-deps.js +33 -0
  75. package/dist/utils/esm-deps.js.map +1 -0
  76. package/dist/utils/esm-deps.mjs +31 -0
  77. package/dist/utils/esm-deps.mjs.map +1 -0
  78. package/dist/utils/jsonl-write-stream.d.ts +13 -0
  79. package/dist/utils/jsonl-write-stream.d.ts.map +1 -0
  80. package/dist/utils/jsonl-write-stream.js +75 -0
  81. package/dist/utils/jsonl-write-stream.js.map +1 -0
  82. package/dist/utils/jsonl-write-stream.mjs +73 -0
  83. package/dist/utils/jsonl-write-stream.mjs.map +1 -0
  84. package/dist/utils/transaction.d.ts +6 -1
  85. package/dist/utils/transaction.d.ts.map +1 -1
  86. package/dist/utils/transaction.js +47 -7
  87. package/dist/utils/transaction.js.map +1 -1
  88. package/dist/utils/transaction.mjs +47 -8
  89. package/dist/utils/transaction.mjs.map +1 -1
  90. package/dist/utils/unknown-error.d.ts +7 -0
  91. package/dist/utils/unknown-error.d.ts.map +1 -0
  92. package/dist/utils/unknown-error.js +30 -0
  93. package/dist/utils/unknown-error.js.map +1 -0
  94. package/dist/utils/unknown-error.mjs +27 -0
  95. package/dist/utils/unknown-error.mjs.map +1 -0
  96. package/package.json +7 -10
@@ -8,7 +8,7 @@ import 'node:stream/promises';
8
8
  import 'stream';
9
9
  import 'lodash';
10
10
  import { schemasToValidJSON, mapSchemasValues } from '../../../utils/schema.mjs';
11
- import { createTransaction } from '../../../utils/transaction.mjs';
11
+ import { createTransaction, transactionCommit } from '../../../utils/transaction.mjs';
12
12
  import 'events';
13
13
  import { ProviderInitializationError, ProviderValidationError, ProviderTransferError } from '../../../errors/providers.mjs';
14
14
  import { assertValidStrapi } from '../../../utils/providers.mjs';
@@ -48,11 +48,18 @@ class LocalStrapiDestinationProvider {
48
48
  async close() {
49
49
  const { autoDestroy } = this.options;
50
50
  assertValidStrapi(this.strapi);
51
- this.transaction?.end();
52
- this.strapi.db.lifecycles.enable();
53
- // Basically `!== false` but more deterministic
54
- if (autoDestroy === undefined || autoDestroy === true) {
55
- await this.strapi?.destroy();
51
+ try {
52
+ // end() only signals the loop. The commit finishes on the promise.
53
+ const transaction = this.transaction;
54
+ const pending = transaction?.[transactionCommit]?.() ?? Promise.resolve();
55
+ transaction?.end();
56
+ await pending;
57
+ } finally{
58
+ this.strapi.db.lifecycles.enable();
59
+ // Basically `!== false` but more deterministic
60
+ if (autoDestroy === undefined || autoDestroy === true) {
61
+ await this.strapi?.destroy();
62
+ }
56
63
  }
57
64
  }
58
65
  async rollback() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/strapi/providers/local-destination/index.ts"],"sourcesContent":["import { Writable, Readable } from 'stream';\nimport path from 'path';\nimport * as fse from 'fs-extra';\nimport type { Knex } from 'knex';\nimport type { Core, Struct } from '@strapi/types';\nimport type { IDestinationProvider, IMetadata, ProviderType, Transaction } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\n\nimport { createAssetsDestinationWritable } from './assets-destination-writable';\nimport { restore } from './strategies';\nimport * as utils from '../../../utils';\nimport {\n ProviderInitializationError,\n ProviderTransferError,\n ProviderValidationError,\n} from '../../../errors/providers';\nimport { assertValidStrapi } from '../../../utils/providers';\n\nexport const VALID_CONFLICT_STRATEGIES = ['restore'];\nexport const DEFAULT_CONFLICT_STRATEGY = 'restore';\n\nexport interface ILocalStrapiDestinationProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n restore?: restore.IRestoreOptions; // erase data in strapi database before transfer; required if strategy is 'restore'\n strategy: 'restore'; // conflict management strategy; only the restore strategy is available at this time\n /** CLI / UI: human-readable progress during {@link beforeTransfer} (restore prep). */\n onTransferPhase?: (message: string) => void;\n}\n\nclass LocalStrapiDestinationProvider implements IDestinationProvider {\n name = 'destination::local-strapi';\n\n type: ProviderType = 'destination';\n\n options: ILocalStrapiDestinationProviderOptions;\n\n strapi?: Core.Strapi;\n\n transaction?: Transaction;\n\n uploadsBackupDirectoryName: string;\n\n onWarning?: ((message: string) => void) | undefined;\n\n #diagnostics?: IDiagnosticReporter;\n\n /**\n * The entities mapper is used to map old entities to their new IDs\n */\n #entitiesMapper: { [type: string]: { [id: number]: number } };\n\n constructor(options: ILocalStrapiDestinationProviderOptions) {\n this.options = options;\n this.#entitiesMapper = {};\n this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n this.#validateOptions();\n this.strapi = await this.options.getStrapi();\n if (!this.strapi) {\n throw new ProviderInitializationError('Could not access local strapi');\n }\n this.strapi.db.lifecycles.disable();\n this.transaction = utils.transaction.createTransaction(this.strapi);\n }\n\n // 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\n #areAssetsIncluded = () => {\n return this.options.restore?.assets;\n };\n\n #isContentTypeIncluded = (type: string) => {\n const notIncluded =\n this.options.restore?.entities?.include &&\n !this.options.restore?.entities?.include?.includes(type);\n const excluded =\n this.options.restore?.entities?.exclude &&\n this.options.restore?.entities.exclude.includes(type);\n\n return !excluded && !notIncluded;\n };\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-destination-provider',\n },\n kind: 'info',\n });\n }\n\n async close(): Promise<void> {\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n this.transaction?.end();\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n\n #validateOptions() {\n this.#reportInfo('validating options');\n if (!VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {\n throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {\n check: 'strategy',\n strategy: this.options.strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n // require restore options when using restore\n if (this.options.strategy === 'restore' && !this.options.restore) {\n throw new ProviderValidationError('Missing restore options');\n }\n }\n\n async #deleteFromRestoreOptions() {\n assertValidStrapi(this.strapi);\n if (!this.options.restore) {\n throw new ProviderValidationError('Missing restore options');\n }\n this.#reportInfo('deleting record ');\n return restore.deleteRecords(this.strapi, this.options.restore);\n }\n\n async #deleteAllAssets(trx?: Knex.Transaction) {\n assertValidStrapi(this.strapi);\n // if we're not restoring files, don't touch the files\n if (!this.#areAssetsIncluded()) {\n return;\n }\n\n this.#reportInfo('deleting all assets');\n\n const stream: Readable = this.strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder('plugin::upload.file')\n // Fetch all columns\n .select('*')\n // Attach the transaction\n .transacting(trx)\n // Get a readable stream\n .stream();\n\n // TODO use bulk delete when exists in providers\n for await (const file of stream) {\n await this.strapi.plugin('upload').provider.delete(file);\n if (file.formats) {\n for (const fileFormat of Object.values(file.formats)) {\n await this.strapi.plugin('upload').provider.delete(fileFormat);\n }\n }\n }\n\n this.#reportInfo('deleted all assets');\n }\n\n async rollback() {\n this.#reportInfo('Rolling back transaction');\n await this.transaction?.rollback();\n this.#reportInfo('Rolled back transaction');\n }\n\n async beforeTransfer() {\n if (!this.strapi) {\n throw new Error('Strapi instance not found');\n }\n\n this.options.onTransferPhase?.('Local: preparing destination for restore…');\n\n await this.transaction?.attach(async (trx) => {\n try {\n if (this.options.strategy === 'restore') {\n if (this.#areAssetsIncluded()) {\n this.options.onTransferPhase?.('Local: backing up existing upload folder…');\n }\n await this.#handleAssetsBackup();\n if (this.#areAssetsIncluded()) {\n this.options.onTransferPhase?.('Local: deleting existing media files from disk…');\n }\n await this.#deleteAllAssets(trx);\n this.options.onTransferPhase?.('Local: clearing database content for restore…');\n await this.#deleteFromRestoreOptions();\n }\n } catch (error) {\n throw new Error(`restore failed ${error}`);\n }\n });\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n this.#reportInfo('getting schema');\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createEntitiesWriteStream(): Writable {\n assertValidStrapi(this.strapi, 'Not able to import entities');\n this.#reportInfo('creating entities stream');\n const { strategy } = this.options;\n\n const updateMappingTable = (type: string, oldID: number, newID: number) => {\n if (!this.#entitiesMapper[type]) {\n this.#entitiesMapper[type] = {};\n }\n\n Object.assign(this.#entitiesMapper[type], { [oldID]: newID });\n };\n\n if (strategy === 'restore') {\n return restore.createEntitiesWriteStream({\n strapi: this.strapi,\n updateMappingTable,\n transaction: this.transaction,\n });\n }\n\n throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {\n check: 'strategy',\n strategy: this.options.strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n async #handleAssetsBackup() {\n assertValidStrapi(this.strapi, 'Not able to create the assets backup');\n\n // if we're not restoring assets, don't back them up because they won't be touched\n if (!this.#areAssetsIncluded()) {\n return;\n }\n\n if (this.strapi.config.get<{ provider: string }>('plugin::upload').provider === 'local') {\n this.#reportInfo('creating assets backup directory');\n const assetsDirectory = path.join(this.strapi.dirs.static.public, 'uploads');\n const backupDirectory = path.join(\n this.strapi.dirs.static.public,\n this.uploadsBackupDirectoryName\n );\n\n try {\n // Check access before attempting to do anything\n await fse.access(\n assetsDirectory,\n // eslint-disable-next-line no-bitwise\n fse.constants.W_OK | fse.constants.R_OK | fse.constants.F_OK\n );\n // eslint-disable-next-line no-bitwise\n await fse.access(path.join(assetsDirectory, '..'), fse.constants.W_OK | fse.constants.R_OK);\n\n await fse.move(assetsDirectory, backupDirectory);\n await fse.mkdir(assetsDirectory);\n // Create a .gitkeep file to ensure the directory is not empty\n await fse.outputFile(path.join(assetsDirectory, '.gitkeep'), '');\n this.#reportInfo(`created assets backup directory ${backupDirectory}`);\n } catch {\n throw new ProviderTransferError(\n 'The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory',\n {\n code: 'ASSETS_DIRECTORY_ERR',\n }\n );\n }\n return backupDirectory;\n }\n }\n\n async #removeAssetsBackup() {\n assertValidStrapi(this.strapi, 'Not able to remove Assets');\n // if we're not restoring assets, don't back them up because they won't be touched\n if (!this.#areAssetsIncluded()) {\n return;\n }\n // TODO: this should catch all thrown errors and bubble it up to engine so it can be reported as a non-fatal diagnostic message telling the user they may need to manually delete assets\n if (this.strapi.config.get<{ provider: string }>('plugin::upload').provider === 'local') {\n this.#reportInfo('removing assets backup');\n assertValidStrapi(this.strapi);\n const backupDirectory = path.join(\n this.strapi.dirs.static.public,\n this.uploadsBackupDirectoryName\n );\n await fse.rm(backupDirectory, { recursive: true, force: true });\n this.#reportInfo('successfully removed assets backup');\n }\n }\n\n // TODO: Move this logic to the restore strategy\n async createAssetsWriteStream(): Promise<Writable> {\n assertValidStrapi(this.strapi, 'Not able to stream Assets');\n this.#reportInfo('creating assets write stream');\n if (!this.#areAssetsIncluded()) {\n throw new ProviderTransferError(\n 'Attempting to transfer assets when `assets` is not set in restore options'\n );\n }\n\n const fileEntitiesMapper = this.#entitiesMapper['plugin::upload.file'];\n\n return createAssetsDestinationWritable({\n strapi: this.strapi,\n transaction: this.transaction!,\n resolveUploadFileId: (metadata) => fileEntitiesMapper?.[metadata.id],\n restoreMediaEntitiesContent: this.#isContentTypeIncluded('plugin::upload.file'),\n removeAssetsBackup: this.#removeAssetsBackup.bind(this),\n });\n }\n\n async createConfigurationWriteStream(): Promise<Writable> {\n assertValidStrapi(this.strapi, 'Not able to stream Configurations');\n this.#reportInfo('creating configuration write stream');\n const { strategy } = this.options;\n\n if (strategy === 'restore') {\n return restore.createConfigurationWriteStream(this.strapi, this.transaction);\n }\n\n throw new ProviderValidationError(`Invalid strategy ${strategy}`, {\n check: 'strategy',\n strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n async createLinksWriteStream(): Promise<Writable> {\n this.#reportInfo('creating links write stream');\n if (!this.strapi) {\n throw new Error('Not able to stream links. Strapi instance not found');\n }\n\n const { strategy } = this.options;\n const mapID = (uid: string, id: number): number | undefined => this.#entitiesMapper[uid]?.[id];\n\n if (strategy === 'restore') {\n return restore.createLinksWriteStream(mapID, this.strapi, this.transaction, this.onWarning);\n }\n\n throw new ProviderValidationError(`Invalid strategy ${strategy}`, {\n check: 'strategy',\n strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n}\n\nexport const createLocalStrapiDestinationProvider = (\n options: ILocalStrapiDestinationProviderOptions\n) => {\n return new LocalStrapiDestinationProvider(options);\n};\n"],"names":["VALID_CONFLICT_STRATEGIES","DEFAULT_CONFLICT_STRATEGY","LocalStrapiDestinationProvider","bootstrap","diagnostics","strapi","options","getStrapi","ProviderInitializationError","db","lifecycles","disable","transaction","utils","close","autoDestroy","assertValidStrapi","end","enable","undefined","destroy","rollback","beforeTransfer","Error","onTransferPhase","attach","trx","strategy","error","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","getSchemas","schemas","contentTypes","components","createEntitiesWriteStream","updateMappingTable","type","oldID","newID","Object","assign","restore","ProviderValidationError","check","validStrategies","createAssetsWriteStream","ProviderTransferError","fileEntitiesMapper","createAssetsDestinationWritable","resolveUploadFileId","metadata","id","restoreMediaEntitiesContent","removeAssetsBackup","bind","createConfigurationWriteStream","createLinksWriteStream","mapID","uid","onWarning","name","assets","notIncluded","entities","include","includes","excluded","exclude","uploadsBackupDirectoryName","now","message","report","details","origin","kind","stream","queryBuilder","select","transacting","file","plugin","provider","delete","formats","fileFormat","values","assetsDirectory","path","join","dirs","static","public","backupDirectory","fse","access","constants","W_OK","R_OK","F_OK","move","mkdir","outputFile","code","rm","recursive","force","createLocalStrapiDestinationProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkBaA,yBAAAA,GAA4B;AAAC,IAAA;;AACnC,MAAMC,4BAA4B;IA2BvC,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;AAIC,MACD;AAoBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA,EAIA,sBAAA,iBAAA,8BAAA,CAAA,wBAAA,CAAA,EAWA,WAAA,iBAAA,8BAAA,CAAA,aAAA,CAAA,EAsBA,gBAAA,iBAAA,8BAAA,CAAA,kBAAA,CAAA,EAgBM,yBAAA,iBAAA,8BAAA,CAAA,2BAAA,CAAA,EASA,qFAuHA,mBAAA,iBAAA,8BAAA,CAAA,qBAAA,CAAA,EA2CA,mBAAA,iBAAA,8BAAA,CAAA,qBAAA,CAAA;AAxQR,MAAMC,8BAAAA,CAAAA;IA4BJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;QACpB,+BAAA,CAAA,IAAI,EAAC,gBAAA,CAAA,CAAA,gBAAA,CAAA,EAAA;QACL,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACC,OAAO,CAACC,SAAS,EAAA;AAC1C,QAAA,IAAI,CAAC,IAAI,CAACF,MAAM,EAAE;AAChB,YAAA,MAAM,IAAIG,2BAAAA,CAA4B,+BAAA,CAAA;AACxC,QAAA;AACA,QAAA,IAAI,CAACH,MAAM,CAACI,EAAE,CAACC,UAAU,CAACC,OAAO,EAAA;QACjC,IAAI,CAACC,WAAW,GAAGC,iBAAmC,CAAC,IAAI,CAAC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E,CAACX,eAAAA,EAAiB;YAAEY,SAAAA,EAAW,IAAA;YAAMC,KAAAA,EAAO;AAAK,SAAA,CAAA;QAC7D,+BAAA,CAAA,IAAI,EAAC,WAAA,CAAA,CAAA,WAAA,CAAA,CAAY,oCAAA,CAAA;AACnB,IAAA;AACF;AA4DK,MAAMC,uCAAuC,CAClD3G,OAAAA,GAAAA;AAEA,IAAA,OAAO,IAAIJ,8BAAAA,CAA+BI,OAAAA,CAAAA;AAC5C;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/strapi/providers/local-destination/index.ts"],"sourcesContent":["import { Writable, Readable } from 'stream';\nimport path from 'path';\nimport * as fse from 'fs-extra';\nimport type { Knex } from 'knex';\nimport type { Core, Struct } from '@strapi/types';\nimport type { IDestinationProvider, IMetadata, ProviderType, Transaction } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\n\nimport { createAssetsDestinationWritable } from './assets-destination-writable';\nimport { restore } from './strategies';\nimport * as utils from '../../../utils';\nimport {\n ProviderInitializationError,\n ProviderTransferError,\n ProviderValidationError,\n} from '../../../errors/providers';\nimport { assertValidStrapi } from '../../../utils/providers';\n\nexport const VALID_CONFLICT_STRATEGIES = ['restore'];\nexport const DEFAULT_CONFLICT_STRATEGY = 'restore';\n\nexport interface ILocalStrapiDestinationProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n restore?: restore.IRestoreOptions; // erase data in strapi database before transfer; required if strategy is 'restore'\n strategy: 'restore'; // conflict management strategy; only the restore strategy is available at this time\n /** CLI / UI: human-readable progress during {@link beforeTransfer} (restore prep). */\n onTransferPhase?: (message: string) => void;\n}\n\nclass LocalStrapiDestinationProvider implements IDestinationProvider {\n name = 'destination::local-strapi';\n\n type: ProviderType = 'destination';\n\n options: ILocalStrapiDestinationProviderOptions;\n\n strapi?: Core.Strapi;\n\n transaction?: Transaction;\n\n uploadsBackupDirectoryName: string;\n\n onWarning?: ((message: string) => void) | undefined;\n\n #diagnostics?: IDiagnosticReporter;\n\n /**\n * The entities mapper is used to map old entities to their new IDs\n */\n #entitiesMapper: { [type: string]: { [id: number]: number } };\n\n constructor(options: ILocalStrapiDestinationProviderOptions) {\n this.options = options;\n this.#entitiesMapper = {};\n this.uploadsBackupDirectoryName = `uploads_backup_${Date.now()}`;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n this.#validateOptions();\n this.strapi = await this.options.getStrapi();\n if (!this.strapi) {\n throw new ProviderInitializationError('Could not access local strapi');\n }\n this.strapi.db.lifecycles.disable();\n this.transaction = utils.transaction.createTransaction(this.strapi);\n }\n\n // 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\n #areAssetsIncluded = () => {\n return this.options.restore?.assets;\n };\n\n #isContentTypeIncluded = (type: string) => {\n const notIncluded =\n this.options.restore?.entities?.include &&\n !this.options.restore?.entities?.include?.includes(type);\n const excluded =\n this.options.restore?.entities?.exclude &&\n this.options.restore?.entities.exclude.includes(type);\n\n return !excluded && !notIncluded;\n };\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-destination-provider',\n },\n kind: 'info',\n });\n }\n\n async close(): Promise<void> {\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n try {\n // end() only signals the loop. The commit finishes on the promise.\n const transaction = this.transaction as\n (Transaction & Partial<utils.transaction.TransactionCommit>) | undefined;\n const pending = transaction?.[utils.transaction.transactionCommit]?.() ?? Promise.resolve();\n transaction?.end();\n await pending;\n } finally {\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n }\n\n #validateOptions() {\n this.#reportInfo('validating options');\n if (!VALID_CONFLICT_STRATEGIES.includes(this.options.strategy)) {\n throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {\n check: 'strategy',\n strategy: this.options.strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n // require restore options when using restore\n if (this.options.strategy === 'restore' && !this.options.restore) {\n throw new ProviderValidationError('Missing restore options');\n }\n }\n\n async #deleteFromRestoreOptions() {\n assertValidStrapi(this.strapi);\n if (!this.options.restore) {\n throw new ProviderValidationError('Missing restore options');\n }\n this.#reportInfo('deleting record ');\n return restore.deleteRecords(this.strapi, this.options.restore);\n }\n\n async #deleteAllAssets(trx?: Knex.Transaction) {\n assertValidStrapi(this.strapi);\n // if we're not restoring files, don't touch the files\n if (!this.#areAssetsIncluded()) {\n return;\n }\n\n this.#reportInfo('deleting all assets');\n\n const stream: Readable = this.strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder('plugin::upload.file')\n // Fetch all columns\n .select('*')\n // Attach the transaction\n .transacting(trx)\n // Get a readable stream\n .stream();\n\n // TODO use bulk delete when exists in providers\n for await (const file of stream) {\n await this.strapi.plugin('upload').provider.delete(file);\n if (file.formats) {\n for (const fileFormat of Object.values(file.formats)) {\n await this.strapi.plugin('upload').provider.delete(fileFormat);\n }\n }\n }\n\n this.#reportInfo('deleted all assets');\n }\n\n async rollback() {\n this.#reportInfo('Rolling back transaction');\n await this.transaction?.rollback();\n this.#reportInfo('Rolled back transaction');\n }\n\n async beforeTransfer() {\n if (!this.strapi) {\n throw new Error('Strapi instance not found');\n }\n\n this.options.onTransferPhase?.('Local: preparing destination for restore…');\n\n await this.transaction?.attach(async (trx) => {\n try {\n if (this.options.strategy === 'restore') {\n if (this.#areAssetsIncluded()) {\n this.options.onTransferPhase?.('Local: backing up existing upload folder…');\n }\n await this.#handleAssetsBackup();\n if (this.#areAssetsIncluded()) {\n this.options.onTransferPhase?.('Local: deleting existing media files from disk…');\n }\n await this.#deleteAllAssets(trx);\n this.options.onTransferPhase?.('Local: clearing database content for restore…');\n await this.#deleteFromRestoreOptions();\n }\n } catch (error) {\n throw new Error(`restore failed ${error}`);\n }\n });\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n this.#reportInfo('getting schema');\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createEntitiesWriteStream(): Writable {\n assertValidStrapi(this.strapi, 'Not able to import entities');\n this.#reportInfo('creating entities stream');\n const { strategy } = this.options;\n\n const updateMappingTable = (type: string, oldID: number, newID: number) => {\n if (!this.#entitiesMapper[type]) {\n this.#entitiesMapper[type] = {};\n }\n\n Object.assign(this.#entitiesMapper[type], { [oldID]: newID });\n };\n\n if (strategy === 'restore') {\n return restore.createEntitiesWriteStream({\n strapi: this.strapi,\n updateMappingTable,\n transaction: this.transaction,\n });\n }\n\n throw new ProviderValidationError(`Invalid strategy ${this.options.strategy}`, {\n check: 'strategy',\n strategy: this.options.strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n async #handleAssetsBackup() {\n assertValidStrapi(this.strapi, 'Not able to create the assets backup');\n\n // if we're not restoring assets, don't back them up because they won't be touched\n if (!this.#areAssetsIncluded()) {\n return;\n }\n\n if (this.strapi.config.get<{ provider: string }>('plugin::upload').provider === 'local') {\n this.#reportInfo('creating assets backup directory');\n const assetsDirectory = path.join(this.strapi.dirs.static.public, 'uploads');\n const backupDirectory = path.join(\n this.strapi.dirs.static.public,\n this.uploadsBackupDirectoryName\n );\n\n try {\n // Check access before attempting to do anything\n await fse.access(\n assetsDirectory,\n // eslint-disable-next-line no-bitwise\n fse.constants.W_OK | fse.constants.R_OK | fse.constants.F_OK\n );\n // eslint-disable-next-line no-bitwise\n await fse.access(path.join(assetsDirectory, '..'), fse.constants.W_OK | fse.constants.R_OK);\n\n await fse.move(assetsDirectory, backupDirectory);\n await fse.mkdir(assetsDirectory);\n // Create a .gitkeep file to ensure the directory is not empty\n await fse.outputFile(path.join(assetsDirectory, '.gitkeep'), '');\n this.#reportInfo(`created assets backup directory ${backupDirectory}`);\n } catch {\n throw new ProviderTransferError(\n 'The backup folder for the assets could not be created inside the public folder. Please ensure Strapi has write permissions on the public directory',\n {\n code: 'ASSETS_DIRECTORY_ERR',\n }\n );\n }\n return backupDirectory;\n }\n }\n\n async #removeAssetsBackup() {\n assertValidStrapi(this.strapi, 'Not able to remove Assets');\n // if we're not restoring assets, don't back them up because they won't be touched\n if (!this.#areAssetsIncluded()) {\n return;\n }\n // TODO: this should catch all thrown errors and bubble it up to engine so it can be reported as a non-fatal diagnostic message telling the user they may need to manually delete assets\n if (this.strapi.config.get<{ provider: string }>('plugin::upload').provider === 'local') {\n this.#reportInfo('removing assets backup');\n assertValidStrapi(this.strapi);\n const backupDirectory = path.join(\n this.strapi.dirs.static.public,\n this.uploadsBackupDirectoryName\n );\n await fse.rm(backupDirectory, { recursive: true, force: true });\n this.#reportInfo('successfully removed assets backup');\n }\n }\n\n // TODO: Move this logic to the restore strategy\n async createAssetsWriteStream(): Promise<Writable> {\n assertValidStrapi(this.strapi, 'Not able to stream Assets');\n this.#reportInfo('creating assets write stream');\n if (!this.#areAssetsIncluded()) {\n throw new ProviderTransferError(\n 'Attempting to transfer assets when `assets` is not set in restore options'\n );\n }\n\n const fileEntitiesMapper = this.#entitiesMapper['plugin::upload.file'];\n\n return createAssetsDestinationWritable({\n strapi: this.strapi,\n transaction: this.transaction!,\n resolveUploadFileId: (metadata) => fileEntitiesMapper?.[metadata.id],\n restoreMediaEntitiesContent: this.#isContentTypeIncluded('plugin::upload.file'),\n removeAssetsBackup: this.#removeAssetsBackup.bind(this),\n });\n }\n\n async createConfigurationWriteStream(): Promise<Writable> {\n assertValidStrapi(this.strapi, 'Not able to stream Configurations');\n this.#reportInfo('creating configuration write stream');\n const { strategy } = this.options;\n\n if (strategy === 'restore') {\n return restore.createConfigurationWriteStream(this.strapi, this.transaction);\n }\n\n throw new ProviderValidationError(`Invalid strategy ${strategy}`, {\n check: 'strategy',\n strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n\n async createLinksWriteStream(): Promise<Writable> {\n this.#reportInfo('creating links write stream');\n if (!this.strapi) {\n throw new Error('Not able to stream links. Strapi instance not found');\n }\n\n const { strategy } = this.options;\n const mapID = (uid: string, id: number): number | undefined => this.#entitiesMapper[uid]?.[id];\n\n if (strategy === 'restore') {\n return restore.createLinksWriteStream(mapID, this.strapi, this.transaction, this.onWarning);\n }\n\n throw new ProviderValidationError(`Invalid strategy ${strategy}`, {\n check: 'strategy',\n strategy,\n validStrategies: VALID_CONFLICT_STRATEGIES,\n });\n }\n}\n\nexport const createLocalStrapiDestinationProvider = (\n options: ILocalStrapiDestinationProviderOptions\n) => {\n return new LocalStrapiDestinationProvider(options);\n};\n"],"names":["VALID_CONFLICT_STRATEGIES","DEFAULT_CONFLICT_STRATEGY","LocalStrapiDestinationProvider","bootstrap","diagnostics","strapi","options","getStrapi","ProviderInitializationError","db","lifecycles","disable","transaction","utils","close","autoDestroy","assertValidStrapi","pending","Promise","resolve","end","enable","undefined","destroy","rollback","beforeTransfer","Error","onTransferPhase","attach","trx","strategy","error","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","getSchemas","schemas","contentTypes","components","createEntitiesWriteStream","updateMappingTable","type","oldID","newID","Object","assign","restore","ProviderValidationError","check","validStrategies","createAssetsWriteStream","ProviderTransferError","fileEntitiesMapper","createAssetsDestinationWritable","resolveUploadFileId","metadata","id","restoreMediaEntitiesContent","removeAssetsBackup","bind","createConfigurationWriteStream","createLinksWriteStream","mapID","uid","onWarning","name","assets","notIncluded","entities","include","includes","excluded","exclude","uploadsBackupDirectoryName","now","message","report","details","origin","kind","stream","queryBuilder","select","transacting","file","plugin","provider","delete","formats","fileFormat","values","assetsDirectory","path","join","dirs","static","public","backupDirectory","fse","access","constants","W_OK","R_OK","F_OK","move","mkdir","outputFile","code","rm","recursive","force","createLocalStrapiDestinationProvider"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkBaA,yBAAAA,GAA4B;AAAC,IAAA;;AACnC,MAAMC,4BAA4B;IA2BvC,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;AAIC,MACD;AAoBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA,EAIA,sBAAA,iBAAA,8BAAA,CAAA,wBAAA,CAAA,EAWA,WAAA,iBAAA,8BAAA,CAAA,aAAA,CAAA,EA8BA,gBAAA,iBAAA,8BAAA,CAAA,kBAAA,CAAA,EAgBM,yBAAA,iBAAA,8BAAA,CAAA,2BAAA,CAAA,EASA,qFAuHA,mBAAA,iBAAA,8BAAA,CAAA,qBAAA,CAAA,EA2CA,mBAAA,iBAAA,8BAAA,CAAA,qBAAA,CAAA;AAhRR,MAAMC,8BAAAA,CAAAA;IA4BJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;QACpB,+BAAA,CAAA,IAAI,EAAC,gBAAA,CAAA,CAAA,gBAAA,CAAA,EAAA;QACL,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACC,OAAO,CAACC,SAAS,EAAA;AAC1C,QAAA,IAAI,CAAC,IAAI,CAACF,MAAM,EAAE;AAChB,YAAA,MAAM,IAAIG,2BAAAA,CAA4B,+BAAA,CAAA;AACxC,QAAA;AACA,QAAA,IAAI,CAACH,MAAM,CAACI,EAAE,CAACC,UAAU,CAACC,OAAO,EAAA;QACjC,IAAI,CAACC,WAAW,GAAGC,iBAAmC,CAAC,IAAI,CAACR,MAAM,CAAA;AACpE,IAAA;AA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kBAAkBL,IAAAA,CAAKC,IAAI,CAC/B,IAAI,CAAC7F,MAAM,CAAC8F,IAAI,CAACC,MAAM,CAACC,MAAM,EAC9B,IAAI,CAACvB,0BAA0B,CAAA;QAEjC,MAAMyB,EAAAA,CAAIU,EAAE,CAACX,eAAAA,EAAiB;YAAEY,SAAAA,EAAW,IAAA;YAAMC,KAAAA,EAAO;AAAK,SAAA,CAAA;QAC7D,+BAAA,CAAA,IAAI,EAAC,WAAA,CAAA,CAAA,WAAA,CAAA,CAAY,oCAAA,CAAA;AACnB,IAAA;AACF;AA4DK,MAAMC,uCAAuC,CAClD9G,OAAAA,GAAAA;AAEA,IAAA,OAAO,IAAIJ,8BAAAA,CAA+BI,OAAAA,CAAAA;AAC5C;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAK1C;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,IAAI,CAAC,MAAM,KAAG,QAoC/D,CAAC"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAM1C;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,IAAI,CAAC,MAAM,KAAG,QAsC/D,CAAC"}
@@ -1,15 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  var stream = require('stream');
4
- var streamChain = require('stream-chain');
4
+ var esmDeps = require('../../../utils/esm-deps.js');
5
5
  var projectSettingsLogos = require('../../utils/project-settings-logos.js');
6
6
 
7
7
  /**
8
8
  * Create a readable stream that export the Strapi app configuration
9
9
  */ const createConfigurationStream = (strapi)=>{
10
10
  return stream.Readable.from(async function* configurationGenerator() {
11
+ const { chain } = await esmDeps.loadStreamDeps();
11
12
  // Core Store
12
- const coreStoreStream = streamChain.chain([
13
+ const coreStoreStream = chain([
13
14
  strapi.db.queryBuilder('strapi::core-store').stream(),
14
15
  (data)=>({
15
16
  ...data,
@@ -18,7 +19,7 @@ var projectSettingsLogos = require('../../utils/project-settings-logos.js');
18
19
  wrapConfigurationItem('core-store')
19
20
  ]);
20
21
  // Webhook
21
- const webhooksStream = streamChain.chain([
22
+ const webhooksStream = chain([
22
23
  strapi.db.queryBuilder('strapi::webhook').stream(),
23
24
  wrapConfigurationItem('webhook')
24
25
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../types';\nimport { enrichProjectSettingsForExport } from '../../utils/project-settings-logos';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data) => ({ ...data, value: JSON.parse(data.value) }),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n if (item.type === 'core-store') {\n yield {\n ...item,\n value: await enrichProjectSettingsForExport(\n strapi,\n item.value as { key: string; value: unknown }\n ),\n };\n continue;\n }\n\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","coreStoreStream","chain","db","queryBuilder","stream","data","value","JSON","parse","wrapConfigurationItem","webhooksStream","streams","item","type","enrichProjectSettingsForExport"],"mappings":";;;;;;AAOA;;IAGO,MAAMA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,eAAAA,CAASC,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;;AAEf,QAAA,MAAMC,kBAAkBC,iBAAAA,CAAM;AAC5BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;AACnD,YAAA,CAACC,QAAU;AAAE,oBAAA,GAAGA,IAAI;AAAEC,oBAAAA,KAAAA,EAAOC,IAAAA,CAAKC,KAAK,CAACH,IAAAA,CAAKC,KAAK;iBAAE,CAAA;YACpDG,qBAAAA,CAAsB,YAAA;AACvB,SAAA,CAAA;;AAGD,QAAA,MAAMC,iBAAiBT,iBAAAA,CAAM;AAC3BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,mBAAmBC,MAAM,EAAA;YAChDK,qBAAAA,CAAsB,SAAA;AACvB,SAAA,CAAA;AAED,QAAA,MAAME,OAAAA,GAAU;AAACX,YAAAA,eAAAA;AAAiBU,YAAAA;AAAe,SAAA;QAEjD,KAAK,MAAMN,UAAUO,OAAAA,CAAS;YAC5B,WAAW,MAAMC,QAAQR,MAAAA,CAAQ;gBAC/B,IAAIQ,IAAAA,CAAKC,IAAI,KAAK,YAAA,EAAc;oBAC9B,MAAM;AACJ,wBAAA,GAAGD,IAAI;AACPN,wBAAAA,KAAAA,EAAO,MAAMQ,mDAAAA,CACXlB,MAAAA,EACAgB,IAAAA,CAAKN,KAAK;AAEd,qBAAA;AACA,oBAAA;AACF,gBAAA;gBAEA,MAAMM,IAAAA;AACR,YAAA;AACF,QAAA;AACF,IAAA,CAAA,EAAA,CAAA;AAEJ;AAEA,MAAMH,qBAAAA,GAAwB,CAACI,IAAAA,GAAmC,CAACP,SAAoB;AACrFO,YAAAA,IAAAA;AACAP,YAAAA;SACF,CAAA;;;;"}
1
+ {"version":3,"file":"configuration.js","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../types';\nimport { loadStreamDeps } from '../../../utils/esm-deps';\nimport { enrichProjectSettingsForExport } from '../../utils/project-settings-logos';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n const { chain } = await loadStreamDeps();\n\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data: { value: string }) => ({ ...data, value: JSON.parse(data.value) }),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n if (item.type === 'core-store') {\n yield {\n ...item,\n value: await enrichProjectSettingsForExport(\n strapi,\n item.value as { key: string; value: unknown }\n ),\n };\n continue;\n }\n\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","chain","loadStreamDeps","coreStoreStream","db","queryBuilder","stream","data","value","JSON","parse","wrapConfigurationItem","webhooksStream","streams","item","type","enrichProjectSettingsForExport"],"mappings":";;;;;;AAOA;;IAGO,MAAMA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,eAAAA,CAASC,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;AACf,QAAA,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMC,sBAAAA,EAAAA;;AAGxB,QAAA,MAAMC,kBAAkBF,KAAAA,CAAM;AAC5BJ,YAAAA,MAAAA,CAAOO,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;AACnD,YAAA,CAACC,QAA6B;AAAE,oBAAA,GAAGA,IAAI;AAAEC,oBAAAA,KAAAA,EAAOC,IAAAA,CAAKC,KAAK,CAACH,IAAAA,CAAKC,KAAK;iBAAE,CAAA;YACvEG,qBAAAA,CAAsB,YAAA;AACvB,SAAA,CAAA;;AAGD,QAAA,MAAMC,iBAAiBX,KAAAA,CAAM;AAC3BJ,YAAAA,MAAAA,CAAOO,EAAE,CAACC,YAAY,CAAC,mBAAmBC,MAAM,EAAA;YAChDK,qBAAAA,CAAsB,SAAA;AACvB,SAAA,CAAA;AAED,QAAA,MAAME,OAAAA,GAAU;AAACV,YAAAA,eAAAA;AAAiBS,YAAAA;AAAe,SAAA;QAEjD,KAAK,MAAMN,UAAUO,OAAAA,CAAS;YAC5B,WAAW,MAAMC,QAAQR,MAAAA,CAAQ;gBAC/B,IAAIQ,IAAAA,CAAKC,IAAI,KAAK,YAAA,EAAc;oBAC9B,MAAM;AACJ,wBAAA,GAAGD,IAAI;AACPN,wBAAAA,KAAAA,EAAO,MAAMQ,mDAAAA,CACXnB,MAAAA,EACAiB,IAAAA,CAAKN,KAAK;AAEd,qBAAA;AACA,oBAAA;AACF,gBAAA;gBAEA,MAAMM,IAAAA;AACR,YAAA;AACF,QAAA;AACF,IAAA,CAAA,EAAA,CAAA;AAEJ;AAEA,MAAMH,qBAAAA,GAAwB,CAACI,IAAAA,GAAmC,CAACP,SAAoB;AACrFO,YAAAA,IAAAA;AACAP,YAAAA;SACF,CAAA;;;;"}
@@ -1,11 +1,12 @@
1
1
  import { Readable } from 'stream';
2
- import { chain } from 'stream-chain';
2
+ import { loadStreamDeps } from '../../../utils/esm-deps.mjs';
3
3
  import { enrichProjectSettingsForExport } from '../../utils/project-settings-logos.mjs';
4
4
 
5
5
  /**
6
6
  * Create a readable stream that export the Strapi app configuration
7
7
  */ const createConfigurationStream = (strapi)=>{
8
8
  return Readable.from(async function* configurationGenerator() {
9
+ const { chain } = await loadStreamDeps();
9
10
  // Core Store
10
11
  const coreStoreStream = chain([
11
12
  strapi.db.queryBuilder('strapi::core-store').stream(),
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.mjs","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../types';\nimport { enrichProjectSettingsForExport } from '../../utils/project-settings-logos';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data) => ({ ...data, value: JSON.parse(data.value) }),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n if (item.type === 'core-store') {\n yield {\n ...item,\n value: await enrichProjectSettingsForExport(\n strapi,\n item.value as { key: string; value: unknown }\n ),\n };\n continue;\n }\n\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","coreStoreStream","chain","db","queryBuilder","stream","data","value","JSON","parse","wrapConfigurationItem","webhooksStream","streams","item","type","enrichProjectSettingsForExport"],"mappings":";;;;AAOA;;IAGO,MAAMA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,QAAAA,CAASC,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;;AAEf,QAAA,MAAMC,kBAAkBC,KAAAA,CAAM;AAC5BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;AACnD,YAAA,CAACC,QAAU;AAAE,oBAAA,GAAGA,IAAI;AAAEC,oBAAAA,KAAAA,EAAOC,IAAAA,CAAKC,KAAK,CAACH,IAAAA,CAAKC,KAAK;iBAAE,CAAA;YACpDG,qBAAAA,CAAsB,YAAA;AACvB,SAAA,CAAA;;AAGD,QAAA,MAAMC,iBAAiBT,KAAAA,CAAM;AAC3BL,YAAAA,MAAAA,CAAOM,EAAE,CAACC,YAAY,CAAC,mBAAmBC,MAAM,EAAA;YAChDK,qBAAAA,CAAsB,SAAA;AACvB,SAAA,CAAA;AAED,QAAA,MAAME,OAAAA,GAAU;AAACX,YAAAA,eAAAA;AAAiBU,YAAAA;AAAe,SAAA;QAEjD,KAAK,MAAMN,UAAUO,OAAAA,CAAS;YAC5B,WAAW,MAAMC,QAAQR,MAAAA,CAAQ;gBAC/B,IAAIQ,IAAAA,CAAKC,IAAI,KAAK,YAAA,EAAc;oBAC9B,MAAM;AACJ,wBAAA,GAAGD,IAAI;AACPN,wBAAAA,KAAAA,EAAO,MAAMQ,8BAAAA,CACXlB,MAAAA,EACAgB,IAAAA,CAAKN,KAAK;AAEd,qBAAA;AACA,oBAAA;AACF,gBAAA;gBAEA,MAAMM,IAAAA;AACR,YAAA;AACF,QAAA;AACF,IAAA,CAAA,EAAA,CAAA;AAEJ;AAEA,MAAMH,qBAAAA,GAAwB,CAACI,IAAAA,GAAmC,CAACP,SAAoB;AACrFO,YAAAA,IAAAA;AACAP,YAAAA;SACF,CAAA;;;;"}
1
+ {"version":3,"file":"configuration.mjs","sources":["../../../../src/strapi/providers/local-source/configuration.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport type { Core } from '@strapi/types';\n\nimport type { IConfiguration } from '../../../types';\nimport { loadStreamDeps } from '../../../utils/esm-deps';\nimport { enrichProjectSettingsForExport } from '../../utils/project-settings-logos';\n\n/**\n * Create a readable stream that export the Strapi app configuration\n */\nexport const createConfigurationStream = (strapi: Core.Strapi): Readable => {\n return Readable.from(\n (async function* configurationGenerator(): AsyncGenerator<IConfiguration> {\n const { chain } = await loadStreamDeps();\n\n // Core Store\n const coreStoreStream = chain([\n strapi.db.queryBuilder('strapi::core-store').stream(),\n (data: { value: string }) => ({ ...data, value: JSON.parse(data.value) }),\n wrapConfigurationItem('core-store'),\n ]);\n\n // Webhook\n const webhooksStream = chain([\n strapi.db.queryBuilder('strapi::webhook').stream(),\n wrapConfigurationItem('webhook'),\n ]);\n\n const streams = [coreStoreStream, webhooksStream];\n\n for (const stream of streams) {\n for await (const item of stream) {\n if (item.type === 'core-store') {\n yield {\n ...item,\n value: await enrichProjectSettingsForExport(\n strapi,\n item.value as { key: string; value: unknown }\n ),\n };\n continue;\n }\n\n yield item;\n }\n }\n })()\n );\n};\n\nconst wrapConfigurationItem = (type: 'core-store' | 'webhook') => (value: unknown) => ({\n type,\n value,\n});\n"],"names":["createConfigurationStream","strapi","Readable","from","configurationGenerator","chain","loadStreamDeps","coreStoreStream","db","queryBuilder","stream","data","value","JSON","parse","wrapConfigurationItem","webhooksStream","streams","item","type","enrichProjectSettingsForExport"],"mappings":";;;;AAOA;;IAGO,MAAMA,yBAAAA,GAA4B,CAACC,MAAAA,GAAAA;AACxC,IAAA,OAAOC,QAAAA,CAASC,IAAI,CACjB,gBAAgBC,sBAAAA,GAAAA;AACf,QAAA,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMC,cAAAA,EAAAA;;AAGxB,QAAA,MAAMC,kBAAkBF,KAAAA,CAAM;AAC5BJ,YAAAA,MAAAA,CAAOO,EAAE,CAACC,YAAY,CAAC,sBAAsBC,MAAM,EAAA;AACnD,YAAA,CAACC,QAA6B;AAAE,oBAAA,GAAGA,IAAI;AAAEC,oBAAA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AAgB,CAAC;AAC9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAUrE,MAAM,WAAW,iCAAiC;IAChD,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhD,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,+BAA+B,GAAI,SAAS,iCAAiC,8BAEzF,CAAC;AAEF,cAAM,yBAA0B,YAAW,eAAe;;IACxD,IAAI,SAA0B;IAE9B,IAAI,EAAE,YAAY,CAAY;IAE9B,OAAO,EAAE,iCAAiC,CAAC;IAE3C,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;gBAIT,OAAO,EAAE,iCAAiC;IAIhD,SAAS,CAAC,WAAW,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmE3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAe5B,WAAW,IAAI,SAAS;IAclB,wBAAwB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAkBnD,qBAAqB,IAAI,QAAQ;IAYjC,6BAA6B,IAAI,QAAQ;IAMzC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;IAW3C,uBAAuB,IAAI,QAAQ;IAInC,sBAAsB,IAAI,QAAQ;IAc5B,cAAc,CAAC,KAAK,EAAE,aAAa;CAO1C;AAED,MAAM,MAAM,0BAA0B,GAAG,YAAY,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAExF,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var stream = require('stream');
4
- var streamChain = require('stream-chain');
5
4
  var entities = require('./entities.js');
6
5
  var links = require('./links.js');
7
6
  var configuration = require('./configuration.js');
@@ -14,6 +13,7 @@ require('lodash');
14
13
  var schema = require('../../../utils/schema.js');
15
14
  require('events');
16
15
  var providers = require('../../../utils/providers.js');
16
+ var esmDeps = require('../../../utils/esm-deps.js');
17
17
 
18
18
  function _class_private_field_loose_base(receiver, privateKey) {
19
19
  if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
@@ -36,10 +36,19 @@ var _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"),
36
36
  class LocalStrapiSourceProvider {
37
37
  async bootstrap(diagnostics) {
38
38
  _class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
39
+ // Remote pull runs this on the server during the CLI engine bootstrap, which
40
+ // is before the CLI destination beforeTransfer moves or deletes local uploads.
41
+ // Load here so a missing stream-chain fails the pull at that point. Later
42
+ // reads reuse the cached load. Do this before touching the Strapi instance.
43
+ await esmDeps.loadStreamDeps();
39
44
  this.strapi = await this.options.getStrapi();
40
45
  this.strapi.db.lifecycles.disable();
41
46
  }
42
47
  async close() {
48
+ // bootstrap() can reject before getStrapi(), and close() is still called after that.
49
+ if (!this.strapi) {
50
+ return;
51
+ }
43
52
  const { autoDestroy } = this.options;
44
53
  providers.assertValidStrapi(this.strapi);
45
54
  this.strapi.db.lifecycles.enable();
@@ -63,7 +72,8 @@ class LocalStrapiSourceProvider {
63
72
  async createEntitiesReadStream() {
64
73
  providers.assertValidStrapi(this.strapi, 'Not able to stream entities');
65
74
  _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
66
- return streamChain.chain([
75
+ const { chain } = await esmDeps.loadStreamDeps();
76
+ return chain([
67
77
  // Entities stream
68
78
  entities.createEntitiesStream(this.strapi, {
69
79
  onWarning: (message)=>{
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/strapi/providers/local-source/index.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport type { Core, Struct } from '@strapi/types';\n\nimport type { IMetadata, ISourceProvider, ProviderType, TransferStage } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\nimport { createEntitiesStream, createEntitiesTransformStream } from './entities';\nimport { createLinksStream } from './links';\nimport { createConfigurationStream } from './configuration';\nimport { createAssetsStream } from './assets';\nimport { estimateAssetTotals } from './estimate-asset-totals';\nimport * as utils from '../../../utils';\nimport { assertValidStrapi } from '../../../utils/providers';\n\nexport interface ILocalStrapiSourceProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n}\n\nexport const createLocalStrapiSourceProvider = (options: ILocalStrapiSourceProviderOptions) => {\n return new LocalStrapiSourceProvider(options);\n};\n\nclass LocalStrapiSourceProvider implements ISourceProvider {\n name = 'source::local-strapi';\n\n type: ProviderType = 'source';\n\n options: ILocalStrapiSourceProviderOptions;\n\n strapi?: Core.Strapi;\n\n #diagnostics?: IDiagnosticReporter;\n\n constructor(options: ILocalStrapiSourceProviderOptions) {\n this.options = options;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n this.strapi = await this.options.getStrapi();\n this.strapi.db.lifecycles.disable();\n }\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'info',\n });\n }\n\n #reportWarning(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'warning',\n });\n }\n\n /**\n * Reports an error to the diagnostic reporter.\n */\n #reportError(message: string, error: Error) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n error,\n severity: 'fatal',\n name: error.name,\n },\n kind: 'error',\n });\n }\n\n /**\n * Handles errors that occur in read streams.\n */\n #handleStreamError(streamType: string, err: Error) {\n const { message, stack } = err;\n const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;\n const formattedError = {\n message: errorMessage,\n stack,\n timestamp: new Date().toISOString(),\n };\n\n this.strapi?.log.error(formattedError);\n this.#reportError(formattedError.message, err);\n }\n\n async close(): Promise<void> {\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi);\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n async createEntitiesReadStream(): Promise<Readable> {\n assertValidStrapi(this.strapi, 'Not able to stream entities');\n this.#reportInfo('creating entities read stream');\n return chain([\n // Entities stream\n createEntitiesStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n }),\n\n // Transform stream\n createEntitiesTransformStream(),\n ]);\n }\n\n createLinksReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream links');\n this.#reportInfo('creating links read stream');\n\n return createLinksStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n });\n }\n\n createConfigurationReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream configuration');\n this.#reportInfo('creating configuration read stream');\n return createConfigurationStream(this.strapi);\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n this.#reportInfo('getting schemas');\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createSchemasReadStream(): Readable {\n return Readable.from(Object.values(this.getSchemas()));\n }\n\n createAssetsReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream assets');\n this.#reportInfo('creating assets read stream');\n\n const stream = createAssetsStream(this.strapi, {\n onWarning: (message) => this.#reportWarning(message),\n });\n stream.on('error', (err) => {\n this.#handleStreamError('assets', err);\n });\n\n return stream;\n }\n\n async getStageTotals(stage: TransferStage) {\n if (stage !== 'assets') {\n return null;\n }\n assertValidStrapi(this.strapi, 'Not able to estimate asset totals');\n return estimateAssetTotals(this.strapi);\n }\n}\n\nexport type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;\n\nexport { estimateAssetTotals } from './estimate-asset-totals';\n"],"names":["createLocalStrapiSourceProvider","options","LocalStrapiSourceProvider","bootstrap","diagnostics","strapi","getStrapi","db","lifecycles","disable","close","autoDestroy","assertValidStrapi","enable","undefined","destroy","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","createEntitiesReadStream","chain","createEntitiesStream","onWarning","message","log","warn","createEntitiesTransformStream","createLinksReadStream","createLinksStream","createConfigurationReadStream","createConfigurationStream","getSchemas","schemas","utils","contentTypes","components","createSchemasReadStream","Readable","from","Object","values","createAssetsReadStream","stream","createAssetsStream","on","err","getStageTotals","stage","estimateAssetTotals","name","type","report","details","origin","kind","error","severity","streamType","stack","errorMessage","formattedError","timestamp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAMA,kCAAkC,CAACC,OAAAA,GAAAA;AAC9C,IAAA,OAAO,IAAIC,yBAAAA,CAA0BD,OAAAA,CAAAA;AACvC;AAWE,IAAA,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA,EAYA,2EAWA,cAAA,iBAAA,8BAAA,CAAA,gBAAA,CAAA;;AAaC,MACD,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;MAgBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA;AA9DF,MAAMC,yBAAAA,CAAAA;IAeJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;QACpB,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACJ,OAAO,CAACK,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AMM,MAAMN;AACd,SAAA;QACAK,IAAAA,EAAM;AACR,KAAA,CAAA;AACF;AAKA,SAAA,iBAAA,CAAmBG,UAAkB,EAAEZ,GAAU,EAAA;AAC/C,IAAA,MAAM,EAAEtB,OAAO,EAAEmC,KAAK,EAAE,GAAGb,GAAAA;AAC3B,IAAA,MAAMc,eAAe,CAAC,yBAAyB,EAAEF,UAAAA,CAAW,cAAc,EAAElC,OAAAA,CAAAA,CAAS;AACrF,IAAA,MAAMqC,cAAAA,GAAiB;QACrBrC,OAAAA,EAASoC,YAAAA;AACTD,QAAAA,KAAAA;QACAG,SAAAA,EAAW,IAAI7C,OAAOC,WAAW;AACnC,KAAA;AAEA,IAAA,IAAI,CAACjB,MAAM,EAAEwB,GAAAA,CAAI+B,KAAAA,CAAMK,cAAAA,CAAAA;AACvB,IAAA,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,CAAaA,cAAAA,CAAerC,OAAO,EAAEsB,GAAAA,CAAAA;AAC5C;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/strapi/providers/local-source/index.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport type { Core, Struct } from '@strapi/types';\n\nimport type { IMetadata, ISourceProvider, ProviderType, TransferStage } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\nimport { createEntitiesStream, createEntitiesTransformStream } from './entities';\nimport { createLinksStream } from './links';\nimport { createConfigurationStream } from './configuration';\nimport { createAssetsStream } from './assets';\nimport { estimateAssetTotals } from './estimate-asset-totals';\nimport * as utils from '../../../utils';\nimport { assertValidStrapi } from '../../../utils/providers';\nimport { loadStreamDeps } from '../../../utils/esm-deps';\n\nexport interface ILocalStrapiSourceProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n}\n\nexport const createLocalStrapiSourceProvider = (options: ILocalStrapiSourceProviderOptions) => {\n return new LocalStrapiSourceProvider(options);\n};\n\nclass LocalStrapiSourceProvider implements ISourceProvider {\n name = 'source::local-strapi';\n\n type: ProviderType = 'source';\n\n options: ILocalStrapiSourceProviderOptions;\n\n strapi?: Core.Strapi;\n\n #diagnostics?: IDiagnosticReporter;\n\n constructor(options: ILocalStrapiSourceProviderOptions) {\n this.options = options;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n\n // Remote pull runs this on the server during the CLI engine bootstrap, which\n // is before the CLI destination beforeTransfer moves or deletes local uploads.\n // Load here so a missing stream-chain fails the pull at that point. Later\n // reads reuse the cached load. Do this before touching the Strapi instance.\n await loadStreamDeps();\n\n this.strapi = await this.options.getStrapi();\n this.strapi.db.lifecycles.disable();\n }\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'info',\n });\n }\n\n #reportWarning(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'warning',\n });\n }\n\n /**\n * Reports an error to the diagnostic reporter.\n */\n #reportError(message: string, error: Error) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n error,\n severity: 'fatal',\n name: error.name,\n },\n kind: 'error',\n });\n }\n\n /**\n * Handles errors that occur in read streams.\n */\n #handleStreamError(streamType: string, err: Error) {\n const { message, stack } = err;\n const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;\n const formattedError = {\n message: errorMessage,\n stack,\n timestamp: new Date().toISOString(),\n };\n\n this.strapi?.log.error(formattedError);\n this.#reportError(formattedError.message, err);\n }\n\n async close(): Promise<void> {\n // bootstrap() can reject before getStrapi(), and close() is still called after that.\n if (!this.strapi) {\n return;\n }\n\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi);\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n async createEntitiesReadStream(): Promise<Readable> {\n assertValidStrapi(this.strapi, 'Not able to stream entities');\n this.#reportInfo('creating entities read stream');\n const { chain } = await loadStreamDeps();\n return chain([\n // Entities stream\n createEntitiesStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n }),\n\n // Transform stream\n createEntitiesTransformStream(),\n ]);\n }\n\n createLinksReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream links');\n this.#reportInfo('creating links read stream');\n\n return createLinksStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n });\n }\n\n createConfigurationReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream configuration');\n this.#reportInfo('creating configuration read stream');\n return createConfigurationStream(this.strapi);\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n this.#reportInfo('getting schemas');\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createSchemasReadStream(): Readable {\n return Readable.from(Object.values(this.getSchemas()));\n }\n\n createAssetsReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream assets');\n this.#reportInfo('creating assets read stream');\n\n const stream = createAssetsStream(this.strapi, {\n onWarning: (message) => this.#reportWarning(message),\n });\n stream.on('error', (err) => {\n this.#handleStreamError('assets', err);\n });\n\n return stream;\n }\n\n async getStageTotals(stage: TransferStage) {\n if (stage !== 'assets') {\n return null;\n }\n assertValidStrapi(this.strapi, 'Not able to estimate asset totals');\n return estimateAssetTotals(this.strapi);\n }\n}\n\nexport type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;\n\nexport { estimateAssetTotals } from './estimate-asset-totals';\n"],"names":["createLocalStrapiSourceProvider","options","LocalStrapiSourceProvider","bootstrap","diagnostics","loadStreamDeps","strapi","getStrapi","db","lifecycles","disable","close","autoDestroy","assertValidStrapi","enable","undefined","destroy","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","createEntitiesReadStream","chain","createEntitiesStream","onWarning","message","log","warn","createEntitiesTransformStream","createLinksReadStream","createLinksStream","createConfigurationReadStream","createConfigurationStream","getSchemas","schemas","utils","contentTypes","components","createSchemasReadStream","Readable","from","Object","values","createAssetsReadStream","stream","createAssetsStream","on","err","getStageTotals","stage","estimateAssetTotals","name","type","report","details","origin","kind","error","severity","streamType","stack","errorMessage","formattedError","timestamp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAMA,kCAAkC,CAACC,OAAAA,GAAAA;AAC9C,IAAA,OAAO,IAAIC,yBAAAA,CAA0BD,OAAAA,CAAAA;AACvC;AAWE,IAAA,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA,EAmBA,2EAWA,cAAA,iBAAA,8BAAA,CAAA,gBAAA,CAAA;;AAaC,MACD,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;MAgBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA;AArEF,MAAMC,yBAAAA,CAAAA;IAeJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;;;;;QAMpB,MAAMC,sBAAAA,EAAAA;QAEN,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACL,OAAO,CAACM,SAAS,EAAA;AAC1C,QAAA,IAAI,CAACD,MAAM,CAACE,EAAE,CAACC,UAAU,CAACC,OAAO,EAAA;A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KAAAA;YACAC,QAAAA,EAAU,OAAA;AACVP,YAAAA,IAAAA,EAAMM,MAAMN;AACd,SAAA;QACAK,IAAAA,EAAM;AACR,KAAA,CAAA;AACF;AAKA,SAAA,iBAAA,CAAmBG,UAAkB,EAAEZ,GAAU,EAAA;AAC/C,IAAA,MAAM,EAAEtB,OAAO,EAAEmC,KAAK,EAAE,GAAGb,GAAAA;AAC3B,IAAA,MAAMc,eAAe,CAAC,yBAAyB,EAAEF,UAAAA,CAAW,cAAc,EAAElC,OAAAA,CAAAA,CAAS;AACrF,IAAA,MAAMqC,cAAAA,GAAiB;QACrBrC,OAAAA,EAASoC,YAAAA;AACTD,QAAAA,KAAAA;QACAG,SAAAA,EAAW,IAAI7C,OAAOC,WAAW;AACnC,KAAA;AAEA,IAAA,IAAI,CAACjB,MAAM,EAAEwB,GAAAA,CAAI+B,KAAAA,CAAMK,cAAAA,CAAAA;AACvB,IAAA,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,CAAaA,cAAAA,CAAerC,OAAO,EAAEsB,GAAAA,CAAAA;AAC5C;;;;;"}
@@ -1,5 +1,4 @@
1
1
  import { Readable } from 'stream';
2
- import { chain } from 'stream-chain';
3
2
  import { createEntitiesStream, createEntitiesTransformStream } from './entities.mjs';
4
3
  import { createLinksStream } from './links.mjs';
5
4
  import { createConfigurationStream } from './configuration.mjs';
@@ -12,6 +11,7 @@ import 'lodash';
12
11
  import { schemasToValidJSON, mapSchemasValues } from '../../../utils/schema.mjs';
13
12
  import 'events';
14
13
  import { assertValidStrapi } from '../../../utils/providers.mjs';
14
+ import { loadStreamDeps } from '../../../utils/esm-deps.mjs';
15
15
 
16
16
  function _class_private_field_loose_base(receiver, privateKey) {
17
17
  if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
@@ -34,10 +34,19 @@ var _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"),
34
34
  class LocalStrapiSourceProvider {
35
35
  async bootstrap(diagnostics) {
36
36
  _class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
37
+ // Remote pull runs this on the server during the CLI engine bootstrap, which
38
+ // is before the CLI destination beforeTransfer moves or deletes local uploads.
39
+ // Load here so a missing stream-chain fails the pull at that point. Later
40
+ // reads reuse the cached load. Do this before touching the Strapi instance.
41
+ await loadStreamDeps();
37
42
  this.strapi = await this.options.getStrapi();
38
43
  this.strapi.db.lifecycles.disable();
39
44
  }
40
45
  async close() {
46
+ // bootstrap() can reject before getStrapi(), and close() is still called after that.
47
+ if (!this.strapi) {
48
+ return;
49
+ }
41
50
  const { autoDestroy } = this.options;
42
51
  assertValidStrapi(this.strapi);
43
52
  this.strapi.db.lifecycles.enable();
@@ -61,6 +70,7 @@ class LocalStrapiSourceProvider {
61
70
  async createEntitiesReadStream() {
62
71
  assertValidStrapi(this.strapi, 'Not able to stream entities');
63
72
  _class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
73
+ const { chain } = await loadStreamDeps();
64
74
  return chain([
65
75
  // Entities stream
66
76
  createEntitiesStream(this.strapi, {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../src/strapi/providers/local-source/index.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport { chain } from 'stream-chain';\nimport type { Core, Struct } from '@strapi/types';\n\nimport type { IMetadata, ISourceProvider, ProviderType, TransferStage } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\nimport { createEntitiesStream, createEntitiesTransformStream } from './entities';\nimport { createLinksStream } from './links';\nimport { createConfigurationStream } from './configuration';\nimport { createAssetsStream } from './assets';\nimport { estimateAssetTotals } from './estimate-asset-totals';\nimport * as utils from '../../../utils';\nimport { assertValidStrapi } from '../../../utils/providers';\n\nexport interface ILocalStrapiSourceProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n}\n\nexport const createLocalStrapiSourceProvider = (options: ILocalStrapiSourceProviderOptions) => {\n return new LocalStrapiSourceProvider(options);\n};\n\nclass LocalStrapiSourceProvider implements ISourceProvider {\n name = 'source::local-strapi';\n\n type: ProviderType = 'source';\n\n options: ILocalStrapiSourceProviderOptions;\n\n strapi?: Core.Strapi;\n\n #diagnostics?: IDiagnosticReporter;\n\n constructor(options: ILocalStrapiSourceProviderOptions) {\n this.options = options;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n this.strapi = await this.options.getStrapi();\n this.strapi.db.lifecycles.disable();\n }\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'info',\n });\n }\n\n #reportWarning(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'warning',\n });\n }\n\n /**\n * Reports an error to the diagnostic reporter.\n */\n #reportError(message: string, error: Error) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n error,\n severity: 'fatal',\n name: error.name,\n },\n kind: 'error',\n });\n }\n\n /**\n * Handles errors that occur in read streams.\n */\n #handleStreamError(streamType: string, err: Error) {\n const { message, stack } = err;\n const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;\n const formattedError = {\n message: errorMessage,\n stack,\n timestamp: new Date().toISOString(),\n };\n\n this.strapi?.log.error(formattedError);\n this.#reportError(formattedError.message, err);\n }\n\n async close(): Promise<void> {\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi);\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n async createEntitiesReadStream(): Promise<Readable> {\n assertValidStrapi(this.strapi, 'Not able to stream entities');\n this.#reportInfo('creating entities read stream');\n return chain([\n // Entities stream\n createEntitiesStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n }),\n\n // Transform stream\n createEntitiesTransformStream(),\n ]);\n }\n\n createLinksReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream links');\n this.#reportInfo('creating links read stream');\n\n return createLinksStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n });\n }\n\n createConfigurationReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream configuration');\n this.#reportInfo('creating configuration read stream');\n return createConfigurationStream(this.strapi);\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n this.#reportInfo('getting schemas');\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createSchemasReadStream(): Readable {\n return Readable.from(Object.values(this.getSchemas()));\n }\n\n createAssetsReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream assets');\n this.#reportInfo('creating assets read stream');\n\n const stream = createAssetsStream(this.strapi, {\n onWarning: (message) => this.#reportWarning(message),\n });\n stream.on('error', (err) => {\n this.#handleStreamError('assets', err);\n });\n\n return stream;\n }\n\n async getStageTotals(stage: TransferStage) {\n if (stage !== 'assets') {\n return null;\n }\n assertValidStrapi(this.strapi, 'Not able to estimate asset totals');\n return estimateAssetTotals(this.strapi);\n }\n}\n\nexport type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;\n\nexport { estimateAssetTotals } from './estimate-asset-totals';\n"],"names":["createLocalStrapiSourceProvider","options","LocalStrapiSourceProvider","bootstrap","diagnostics","strapi","getStrapi","db","lifecycles","disable","close","autoDestroy","assertValidStrapi","enable","undefined","destroy","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","createEntitiesReadStream","chain","createEntitiesStream","onWarning","message","log","warn","createEntitiesTransformStream","createLinksReadStream","createLinksStream","createConfigurationReadStream","createConfigurationStream","getSchemas","schemas","utils","contentTypes","components","createSchemasReadStream","Readable","from","Object","values","createAssetsReadStream","stream","createAssetsStream","on","err","getStageTotals","stage","estimateAssetTotals","name","type","report","details","origin","kind","error","severity","streamType","stack","errorMessage","formattedError","timestamp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAMA,kCAAkC,CAACC,OAAAA,GAAAA;AAC9C,IAAA,OAAO,IAAIC,yBAAAA,CAA0BD,OAAAA,CAAAA;AACvC;AAWE,IAAA,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA,EAYA,2EAWA,cAAA,iBAAA,8BAAA,CAAA,gBAAA,CAAA;;AAaC,MACD,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;MAgBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA;AA9DF,MAAMC,yBAAAA,CAAAA;IAeJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;QACpB,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACJ,OAAO,CAACK,SAAS,EAAA;AAC1C,QAAA,IAAI,CAACD,MAAM,CAACE,EAAE,CAACC,UAAU,CAACC,OAAO,EAAA;AACnC,IAAA;AAwDA,IAAA,MAAMC,KAAAA,GAAuB;AAC3B,QAAA,MAAM,EAAEC,WAAW,EAAE,GAAG,IAAI,CAACV,OAAO;QACpCW,iBAAAA,CAAkB,IAAI,CAACP,MAAM,CAAA;AAC7B,QAAA,IAAI,CAACA,MAAM,CAACE,EAAE,CAACC,UAAU,CAACK,MAAM,EAAA;;QAEhC,I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OAAAA,EAASoC,YAAAA;AACTD,QAAAA,KAAAA;QACAG,SAAAA,EAAW,IAAI7C,OAAOC,WAAW;AACnC,KAAA;AAEA,IAAA,IAAI,CAACjB,MAAM,EAAEwB,GAAAA,CAAI+B,KAAAA,CAAMK,cAAAA,CAAAA;AACvB,IAAA,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,CAAaA,cAAAA,CAAerC,OAAO,EAAEsB,GAAAA,CAAAA;AAC5C;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../src/strapi/providers/local-source/index.ts"],"sourcesContent":["import { Readable } from 'stream';\nimport type { Core, Struct } from '@strapi/types';\n\nimport type { IMetadata, ISourceProvider, ProviderType, TransferStage } from '../../../types';\nimport type { IDiagnosticReporter } from '../../../utils/diagnostic';\nimport { createEntitiesStream, createEntitiesTransformStream } from './entities';\nimport { createLinksStream } from './links';\nimport { createConfigurationStream } from './configuration';\nimport { createAssetsStream } from './assets';\nimport { estimateAssetTotals } from './estimate-asset-totals';\nimport * as utils from '../../../utils';\nimport { assertValidStrapi } from '../../../utils/providers';\nimport { loadStreamDeps } from '../../../utils/esm-deps';\n\nexport interface ILocalStrapiSourceProviderOptions {\n getStrapi(): Core.Strapi | Promise<Core.Strapi>; // return an initialized instance of Strapi\n\n autoDestroy?: boolean; // shut down the instance returned by getStrapi() at the end of the transfer\n}\n\nexport const createLocalStrapiSourceProvider = (options: ILocalStrapiSourceProviderOptions) => {\n return new LocalStrapiSourceProvider(options);\n};\n\nclass LocalStrapiSourceProvider implements ISourceProvider {\n name = 'source::local-strapi';\n\n type: ProviderType = 'source';\n\n options: ILocalStrapiSourceProviderOptions;\n\n strapi?: Core.Strapi;\n\n #diagnostics?: IDiagnosticReporter;\n\n constructor(options: ILocalStrapiSourceProviderOptions) {\n this.options = options;\n }\n\n async bootstrap(diagnostics?: IDiagnosticReporter): Promise<void> {\n this.#diagnostics = diagnostics;\n\n // Remote pull runs this on the server during the CLI engine bootstrap, which\n // is before the CLI destination beforeTransfer moves or deletes local uploads.\n // Load here so a missing stream-chain fails the pull at that point. Later\n // reads reuse the cached load. Do this before touching the Strapi instance.\n await loadStreamDeps();\n\n this.strapi = await this.options.getStrapi();\n this.strapi.db.lifecycles.disable();\n }\n\n #reportInfo(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'info',\n });\n }\n\n #reportWarning(message: string) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n origin: 'local-source-provider',\n },\n kind: 'warning',\n });\n }\n\n /**\n * Reports an error to the diagnostic reporter.\n */\n #reportError(message: string, error: Error) {\n this.#diagnostics?.report({\n details: {\n createdAt: new Date(),\n message,\n error,\n severity: 'fatal',\n name: error.name,\n },\n kind: 'error',\n });\n }\n\n /**\n * Handles errors that occur in read streams.\n */\n #handleStreamError(streamType: string, err: Error) {\n const { message, stack } = err;\n const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;\n const formattedError = {\n message: errorMessage,\n stack,\n timestamp: new Date().toISOString(),\n };\n\n this.strapi?.log.error(formattedError);\n this.#reportError(formattedError.message, err);\n }\n\n async close(): Promise<void> {\n // bootstrap() can reject before getStrapi(), and close() is still called after that.\n if (!this.strapi) {\n return;\n }\n\n const { autoDestroy } = this.options;\n assertValidStrapi(this.strapi);\n this.strapi.db.lifecycles.enable();\n // Basically `!== false` but more deterministic\n if (autoDestroy === undefined || autoDestroy === true) {\n await this.strapi?.destroy();\n }\n }\n\n getMetadata(): IMetadata {\n this.#reportInfo('getting metadata');\n assertValidStrapi(this.strapi);\n const strapiVersion = this.strapi.config.get<string>('info.strapi');\n const createdAt = new Date().toISOString();\n\n return {\n createdAt,\n strapi: {\n version: strapiVersion,\n },\n };\n }\n\n async createEntitiesReadStream(): Promise<Readable> {\n assertValidStrapi(this.strapi, 'Not able to stream entities');\n this.#reportInfo('creating entities read stream');\n const { chain } = await loadStreamDeps();\n return chain([\n // Entities stream\n createEntitiesStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n }),\n\n // Transform stream\n createEntitiesTransformStream(),\n ]);\n }\n\n createLinksReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream links');\n this.#reportInfo('creating links read stream');\n\n return createLinksStream(this.strapi, {\n onWarning: (message) => {\n this.strapi?.log.warn(message);\n this.#reportWarning(message);\n },\n });\n }\n\n createConfigurationReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream configuration');\n this.#reportInfo('creating configuration read stream');\n return createConfigurationStream(this.strapi);\n }\n\n getSchemas(): Record<string, Struct.Schema> {\n assertValidStrapi(this.strapi, 'Not able to get Schemas');\n this.#reportInfo('getting schemas');\n const schemas = utils.schema.schemasToValidJSON({\n ...this.strapi.contentTypes,\n ...this.strapi.components,\n });\n\n return utils.schema.mapSchemasValues(schemas);\n }\n\n createSchemasReadStream(): Readable {\n return Readable.from(Object.values(this.getSchemas()));\n }\n\n createAssetsReadStream(): Readable {\n assertValidStrapi(this.strapi, 'Not able to stream assets');\n this.#reportInfo('creating assets read stream');\n\n const stream = createAssetsStream(this.strapi, {\n onWarning: (message) => this.#reportWarning(message),\n });\n stream.on('error', (err) => {\n this.#handleStreamError('assets', err);\n });\n\n return stream;\n }\n\n async getStageTotals(stage: TransferStage) {\n if (stage !== 'assets') {\n return null;\n }\n assertValidStrapi(this.strapi, 'Not able to estimate asset totals');\n return estimateAssetTotals(this.strapi);\n }\n}\n\nexport type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;\n\nexport { estimateAssetTotals } from './estimate-asset-totals';\n"],"names":["createLocalStrapiSourceProvider","options","LocalStrapiSourceProvider","bootstrap","diagnostics","loadStreamDeps","strapi","getStrapi","db","lifecycles","disable","close","autoDestroy","assertValidStrapi","enable","undefined","destroy","getMetadata","strapiVersion","config","get","createdAt","Date","toISOString","version","createEntitiesReadStream","chain","createEntitiesStream","onWarning","message","log","warn","createEntitiesTransformStream","createLinksReadStream","createLinksStream","createConfigurationReadStream","createConfigurationStream","getSchemas","schemas","utils","contentTypes","components","createSchemasReadStream","Readable","from","Object","values","createAssetsReadStream","stream","createAssetsStream","on","err","getStageTotals","stage","estimateAssetTotals","name","type","report","details","origin","kind","error","severity","streamType","stack","errorMessage","formattedError","timestamp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAMA,kCAAkC,CAACC,OAAAA,GAAAA;AAC9C,IAAA,OAAO,IAAIC,yBAAAA,CAA0BD,OAAAA,CAAAA;AACvC;AAWE,IAAA,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA,EAmBA,2EAWA,cAAA,iBAAA,8BAAA,CAAA,gBAAA,CAAA;;AAaC,MACD,YAAA,iBAAA,8BAAA,CAAA,cAAA,CAAA;;MAgBA,kBAAA,iBAAA,8BAAA,CAAA,oBAAA,CAAA;AArEF,MAAMC,yBAAAA,CAAAA;IAeJ,MAAMC,SAAAA,CAAUC,WAAiC,EAAiB;QAChE,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,GAAeA,WAAAA;;;;;QAMpB,MAAMC,cAAAA,EAAAA;QAEN,IAAI,CAACC,MAAM,GAAG,MAAM,IAAI,CAACL,OAAO,CAACM,SAAS,EAAA;AAC1C,QAAA,IAAI,CAACD,MAAM,CAACE,EAAE,CAACC,UAAU,CAACC,OAAO,EAAA;AACnC,IAAA;AAwDA,IAAA,MAAMC,KAAAA,GAAuB;;AAE3B,QAAA,IAAI,CAAC,IAAI,CAACL,MAAM,EAAE;AAChB,YAAA;AACF,QAAA;AAEA,QAAA,MAAM,EAAEM,WAAW,EAAE,GAAG,IAAI,CAACX,OAAO;QACpCY,iBAAAA,CAAkB,IAAI,CAACP,MAAM,CAAA;AAC7B,QAAA,IAAI,CAACA,MAAM,CAACE,EAAE,CAACC,UAAU,CAACK,MAAM,EAAA;;QAEhC,IAAIF,WAAAA,KAAg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A,CAAS;AACrF,IAAA,MAAMqC,cAAAA,GAAiB;QACrBrC,OAAAA,EAASoC,YAAAA;AACTD,QAAAA,KAAAA;QACAG,SAAAA,EAAW,IAAI7C,OAAOC,WAAW;AACnC,KAAA;AAEA,IAAA,IAAI,CAACjB,MAAM,EAAEwB,GAAAA,CAAI+B,KAAAA,CAAMK,cAAAA,CAAAA;AACvB,IAAA,+BAAA,CAAA,IAAI,EAAC,YAAA,CAAA,CAAA,YAAA,CAAA,CAAaA,cAAAA,CAAerC,OAAO,EAAEsB,GAAAA,CAAAA;AAC5C;;;;"}
@@ -6,7 +6,6 @@ var providers = require('../../../errors/providers.js');
6
6
  var writableAsyncWrite = require('../../../utils/writable-async-write.js');
7
7
  var transferAssetChunk = require('../../../utils/transfer-asset-chunk.js');
8
8
  var index$1 = require('../../providers/local-destination/index.js');
9
- require('stream-chain');
10
9
  require('lodash');
11
10
  require('@strapi/utils');
12
11
  require('path');