@strapi/data-transfer 0.0.0-experimental.62ce06180fe9a772eaeb3d43d238b26644f39f7c → 0.0.0-experimental.6340da17068c3bed7fb006e7bcc554c71129e282
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -4
- package/dist/directory/index.d.ts +2 -0
- package/dist/directory/index.d.ts.map +1 -0
- package/dist/directory/index.js +8 -0
- package/dist/directory/index.js.map +1 -0
- package/dist/directory/index.mjs +3 -0
- package/dist/directory/index.mjs.map +1 -0
- package/dist/directory/providers/destination/index.d.ts +38 -0
- package/dist/directory/providers/destination/index.d.ts.map +1 -0
- package/dist/directory/providers/destination/index.js +184 -0
- package/dist/directory/providers/destination/index.js.map +1 -0
- package/dist/directory/providers/destination/index.mjs +177 -0
- package/dist/directory/providers/destination/index.mjs.map +1 -0
- package/dist/directory/providers/destination/utils.d.ts +8 -0
- package/dist/directory/providers/destination/utils.d.ts.map +1 -0
- package/dist/directory/providers/destination/utils.js +62 -0
- package/dist/directory/providers/destination/utils.js.map +1 -0
- package/dist/directory/providers/destination/utils.mjs +56 -0
- package/dist/directory/providers/destination/utils.mjs.map +1 -0
- package/dist/directory/providers/index.d.ts +3 -0
- package/dist/directory/providers/index.d.ts.map +1 -0
- package/dist/directory/providers/index.js +10 -0
- package/dist/directory/providers/index.js.map +1 -0
- package/dist/directory/providers/index.mjs +3 -0
- package/dist/directory/providers/index.mjs.map +1 -0
- package/dist/directory/providers/source/index.d.ts +27 -0
- package/dist/directory/providers/source/index.d.ts.map +1 -0
- package/dist/directory/providers/source/index.js +266 -0
- package/dist/directory/providers/source/index.js.map +1 -0
- package/dist/directory/providers/source/index.mjs +259 -0
- package/dist/directory/providers/source/index.mjs.map +1 -0
- package/dist/engine/errors.js +39 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/errors.mjs +34 -0
- package/dist/engine/errors.mjs.map +1 -0
- package/dist/engine/index.d.ts +2 -3
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +922 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/index.mjs +917 -0
- package/dist/engine/index.mjs.map +1 -0
- package/dist/engine/validation/provider.d.ts +2 -2
- package/dist/engine/validation/provider.d.ts.map +1 -1
- package/dist/engine/validation/provider.js +19 -0
- package/dist/engine/validation/provider.js.map +1 -0
- package/dist/engine/validation/provider.mjs +17 -0
- package/dist/engine/validation/provider.mjs.map +1 -0
- package/dist/engine/validation/schemas/index.d.ts.map +1 -1
- package/dist/engine/validation/schemas/index.js +59 -0
- package/dist/engine/validation/schemas/index.js.map +1 -0
- package/dist/engine/validation/schemas/index.mjs +57 -0
- package/dist/engine/validation/schemas/index.mjs.map +1 -0
- package/dist/errors/base.js +13 -0
- package/dist/errors/base.js.map +1 -0
- package/dist/errors/base.mjs +11 -0
- package/dist/errors/base.mjs.map +1 -0
- package/dist/errors/constants.d.ts +1 -1
- package/dist/errors/constants.d.ts.map +1 -1
- package/dist/errors/constants.js +9 -0
- package/dist/errors/constants.js.map +1 -0
- package/dist/errors/constants.mjs +7 -0
- package/dist/errors/constants.mjs.map +1 -0
- package/dist/errors/providers.d.ts +1 -1
- package/dist/errors/providers.d.ts.map +1 -1
- package/dist/errors/providers.js +41 -0
- package/dist/errors/providers.js.map +1 -0
- package/dist/errors/providers.mjs +36 -0
- package/dist/errors/providers.mjs.map +1 -0
- package/dist/file/index.js +8 -0
- package/dist/file/index.js.map +1 -0
- package/dist/file/index.mjs +3 -0
- package/dist/file/index.mjs.map +1 -0
- package/dist/file/providers/destination/index.d.ts +3 -5
- package/dist/file/providers/destination/index.d.ts.map +1 -1
- package/dist/file/providers/destination/index.js +254 -0
- package/dist/file/providers/destination/index.js.map +1 -0
- package/dist/file/providers/destination/index.mjs +246 -0
- package/dist/file/providers/destination/index.mjs.map +1 -0
- package/dist/file/providers/destination/utils.d.ts +0 -1
- package/dist/file/providers/destination/utils.d.ts.map +1 -1
- package/dist/file/providers/destination/utils.js +63 -0
- package/dist/file/providers/destination/utils.js.map +1 -0
- package/dist/file/providers/destination/utils.mjs +60 -0
- package/dist/file/providers/destination/utils.mjs.map +1 -0
- package/dist/file/providers/index.js +10 -0
- package/dist/file/providers/index.js.map +1 -0
- package/dist/file/providers/index.mjs +3 -0
- package/dist/file/providers/index.mjs.map +1 -0
- package/dist/file/providers/source/index.d.ts +3 -3
- package/dist/file/providers/source/index.d.ts.map +1 -1
- package/dist/file/providers/source/index.js +336 -0
- package/dist/file/providers/source/index.js.map +1 -0
- package/dist/file/providers/source/index.mjs +328 -0
- package/dist/file/providers/source/index.mjs.map +1 -0
- package/dist/file/providers/source/utils.d.ts.map +1 -1
- package/dist/file/providers/source/utils.js +60 -0
- package/dist/file/providers/source/utils.js.map +1 -0
- package/dist/file/providers/source/utils.mjs +52 -0
- package/dist/file/providers/source/utils.mjs.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -4408
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -4382
- package/dist/index.mjs.map +1 -1
- package/dist/strapi/index.js +12 -0
- package/dist/strapi/index.js.map +1 -0
- package/dist/strapi/index.mjs +7 -0
- package/dist/strapi/index.mjs.map +1 -0
- package/dist/strapi/providers/index.js +18 -0
- package/dist/strapi/providers/index.js.map +1 -0
- package/dist/strapi/providers/index.mjs +8 -0
- package/dist/strapi/providers/index.mjs.map +1 -0
- package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts +26 -0
- package/dist/strapi/providers/local-destination/assets-destination-writable.d.ts.map +1 -0
- package/dist/strapi/providers/local-destination/assets-destination-writable.js +125 -0
- package/dist/strapi/providers/local-destination/assets-destination-writable.js.map +1 -0
- package/dist/strapi/providers/local-destination/assets-destination-writable.mjs +123 -0
- package/dist/strapi/providers/local-destination/assets-destination-writable.mjs.map +1 -0
- package/dist/strapi/providers/local-destination/index.d.ts +5 -3
- package/dist/strapi/providers/local-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/index.js +362 -0
- package/dist/strapi/providers/local-destination/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/index.mjs +335 -0
- package/dist/strapi/providers/local-destination/index.mjs.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts +1 -2
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js +58 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs +51 -0
- package/dist/strapi/providers/local-destination/strategies/restore/configuration.mjs.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts +1 -2
- package/dist/strapi/providers/local-destination/strategies/restore/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js +54 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs +52 -0
- package/dist/strapi/providers/local-destination/strategies/restore/entities.mjs.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/index.js +124 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs +120 -0
- package/dist/strapi/providers/local-destination/strategies/restore/index.mjs.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts +1 -2
- package/dist/strapi/providers/local-destination/strategies/restore/links.d.ts.map +1 -1
- package/dist/strapi/providers/local-destination/strategies/restore/links.js +79 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.js.map +1 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs +77 -0
- package/dist/strapi/providers/local-destination/strategies/restore/links.mjs.map +1 -0
- package/dist/strapi/providers/local-source/assets.d.ts +8 -2
- package/dist/strapi/providers/local-source/assets.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/assets.js +151 -0
- package/dist/strapi/providers/local-source/assets.js.map +1 -0
- package/dist/strapi/providers/local-source/assets.mjs +147 -0
- package/dist/strapi/providers/local-source/assets.mjs.map +1 -0
- package/dist/strapi/providers/local-source/configuration.d.ts +0 -1
- package/dist/strapi/providers/local-source/configuration.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/configuration.js +47 -0
- package/dist/strapi/providers/local-source/configuration.js.map +1 -0
- package/dist/strapi/providers/local-source/configuration.mjs +45 -0
- package/dist/strapi/providers/local-source/configuration.mjs.map +1 -0
- package/dist/strapi/providers/local-source/entities.d.ts +3 -2
- package/dist/strapi/providers/local-source/entities.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/entities.js +66 -0
- package/dist/strapi/providers/local-source/entities.js.map +1 -0
- package/dist/strapi/providers/local-source/entities.mjs +63 -0
- package/dist/strapi/providers/local-source/entities.mjs.map +1 -0
- package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts +11 -0
- package/dist/strapi/providers/local-source/estimate-asset-totals.d.ts.map +1 -0
- package/dist/strapi/providers/local-source/estimate-asset-totals.js +130 -0
- package/dist/strapi/providers/local-source/estimate-asset-totals.js.map +1 -0
- package/dist/strapi/providers/local-source/estimate-asset-totals.mjs +128 -0
- package/dist/strapi/providers/local-source/estimate-asset-totals.mjs.map +1 -0
- package/dist/strapi/providers/local-source/index.d.ts +6 -4
- package/dist/strapi/providers/local-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/index.js +186 -0
- package/dist/strapi/providers/local-source/index.js.map +1 -0
- package/dist/strapi/providers/local-source/index.mjs +183 -0
- package/dist/strapi/providers/local-source/index.mjs.map +1 -0
- package/dist/strapi/providers/local-source/links.d.ts +0 -1
- package/dist/strapi/providers/local-source/links.d.ts.map +1 -1
- package/dist/strapi/providers/local-source/links.js +26 -0
- package/dist/strapi/providers/local-source/links.js.map +1 -0
- package/dist/strapi/providers/local-source/links.mjs +24 -0
- package/dist/strapi/providers/local-source/links.mjs.map +1 -0
- package/dist/strapi/providers/remote-destination/index.d.ts +13 -5
- package/dist/strapi/providers/remote-destination/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-destination/index.js +482 -0
- package/dist/strapi/providers/remote-destination/index.js.map +1 -0
- package/dist/strapi/providers/remote-destination/index.mjs +480 -0
- package/dist/strapi/providers/remote-destination/index.mjs.map +1 -0
- package/dist/strapi/providers/remote-source/index.d.ts +11 -6
- package/dist/strapi/providers/remote-source/index.d.ts.map +1 -1
- package/dist/strapi/providers/remote-source/index.js +538 -0
- package/dist/strapi/providers/remote-source/index.js.map +1 -0
- package/dist/strapi/providers/remote-source/index.mjs +536 -0
- package/dist/strapi/providers/remote-source/index.mjs.map +1 -0
- package/dist/strapi/providers/utils.d.ts +22 -16
- package/dist/strapi/providers/utils.d.ts.map +1 -1
- package/dist/strapi/providers/utils.js +178 -0
- package/dist/strapi/providers/utils.js.map +1 -0
- package/dist/strapi/providers/utils.mjs +174 -0
- package/dist/strapi/providers/utils.mjs.map +1 -0
- package/dist/strapi/queries/entity.d.ts.map +1 -1
- package/dist/strapi/queries/entity.js +125 -0
- package/dist/strapi/queries/entity.js.map +1 -0
- package/dist/strapi/queries/entity.mjs +123 -0
- package/dist/strapi/queries/entity.mjs.map +1 -0
- package/dist/strapi/queries/index.js +10 -0
- package/dist/strapi/queries/index.js.map +1 -0
- package/dist/strapi/queries/index.mjs +5 -0
- package/dist/strapi/queries/index.mjs.map +1 -0
- package/dist/strapi/queries/link.d.ts +1 -1
- package/dist/strapi/queries/link.d.ts.map +1 -1
- package/dist/strapi/queries/link.js +298 -0
- package/dist/strapi/queries/link.js.map +1 -0
- package/dist/strapi/queries/link.mjs +295 -0
- package/dist/strapi/queries/link.mjs.map +1 -0
- package/dist/strapi/remote/constants.d.ts.map +1 -1
- package/dist/strapi/remote/constants.js +11 -0
- package/dist/strapi/remote/constants.js.map +1 -0
- package/dist/strapi/remote/constants.mjs +8 -0
- package/dist/strapi/remote/constants.mjs.map +1 -0
- package/dist/strapi/remote/flows/default.d.ts.map +1 -1
- package/dist/strapi/remote/flows/default.js +43 -0
- package/dist/strapi/remote/flows/default.js.map +1 -0
- package/dist/strapi/remote/flows/default.mjs +41 -0
- package/dist/strapi/remote/flows/default.mjs.map +1 -0
- package/dist/strapi/remote/flows/index.d.ts +1 -1
- package/dist/strapi/remote/flows/index.d.ts.map +1 -1
- package/dist/strapi/remote/flows/index.js +54 -0
- package/dist/strapi/remote/flows/index.js.map +1 -0
- package/dist/strapi/remote/flows/index.mjs +52 -0
- package/dist/strapi/remote/flows/index.mjs.map +1 -0
- package/dist/strapi/remote/handlers/abstract.d.ts +4 -1
- package/dist/strapi/remote/handlers/abstract.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/constants.js +10 -0
- package/dist/strapi/remote/handlers/constants.js.map +1 -0
- package/dist/strapi/remote/handlers/constants.mjs +8 -0
- package/dist/strapi/remote/handlers/constants.mjs.map +1 -0
- package/dist/strapi/remote/handlers/index.js +12 -0
- package/dist/strapi/remote/handlers/index.js.map +1 -0
- package/dist/strapi/remote/handlers/index.mjs +4 -0
- package/dist/strapi/remote/handlers/index.mjs.map +1 -0
- package/dist/strapi/remote/handlers/pull.d.ts +2 -3
- package/dist/strapi/remote/handlers/pull.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/pull.js +369 -0
- package/dist/strapi/remote/handlers/pull.js.map +1 -0
- package/dist/strapi/remote/handlers/pull.mjs +367 -0
- package/dist/strapi/remote/handlers/pull.mjs.map +1 -0
- package/dist/strapi/remote/handlers/push.d.ts +16 -5
- package/dist/strapi/remote/handlers/push.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/push.js +454 -0
- package/dist/strapi/remote/handlers/push.js.map +1 -0
- package/dist/strapi/remote/handlers/push.mjs +452 -0
- package/dist/strapi/remote/handlers/push.mjs.map +1 -0
- package/dist/strapi/remote/handlers/utils.d.ts +1 -2
- package/dist/strapi/remote/handlers/utils.d.ts.map +1 -1
- package/dist/strapi/remote/handlers/utils.js +318 -0
- package/dist/strapi/remote/handlers/utils.js.map +1 -0
- package/dist/strapi/remote/handlers/utils.mjs +312 -0
- package/dist/strapi/remote/handlers/utils.mjs.map +1 -0
- package/dist/strapi/remote/index.js +10 -0
- package/dist/strapi/remote/index.js.map +1 -0
- package/dist/strapi/remote/index.mjs +5 -0
- package/dist/strapi/remote/index.mjs.map +1 -0
- package/dist/strapi/utils/project-settings-logos.d.ts +29 -0
- package/dist/strapi/utils/project-settings-logos.d.ts.map +1 -0
- package/dist/strapi/utils/project-settings-logos.js +174 -0
- package/dist/strapi/utils/project-settings-logos.js.map +1 -0
- package/dist/strapi/utils/project-settings-logos.mjs +169 -0
- package/dist/strapi/utils/project-settings-logos.mjs.map +1 -0
- package/dist/types/common-entities.d.ts +149 -0
- package/dist/types/common-entities.d.ts.map +1 -0
- package/dist/types/encryption.d.ts +13 -0
- package/dist/types/encryption.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/providers.d.ts +49 -0
- package/dist/types/providers.d.ts.map +1 -0
- package/dist/types/remote/index.d.ts +2 -0
- package/dist/types/remote/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/auth.d.ts +5 -0
- package/dist/types/remote/protocol/auth.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/commands.d.ts +37 -0
- package/dist/types/remote/protocol/client/commands.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/index.d.ts +9 -0
- package/dist/types/remote/protocol/client/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/action.d.ts +5 -0
- package/dist/types/remote/protocol/client/transfer/action.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/index.d.ts +12 -0
- package/dist/types/remote/protocol/client/transfer/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/pull.d.ts +25 -0
- package/dist/types/remote/protocol/client/transfer/pull.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/push.d.ts +29 -0
- package/dist/types/remote/protocol/client/transfer/push.d.ts.map +1 -0
- package/dist/types/remote/protocol/client/transfer/utils.d.ts +47 -0
- package/dist/types/remote/protocol/client/transfer/utils.d.ts.map +1 -0
- package/dist/types/remote/protocol/index.d.ts +4 -0
- package/dist/types/remote/protocol/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/error.d.ts +18 -0
- package/dist/types/remote/protocol/server/error.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/index.d.ts +3 -0
- package/dist/types/remote/protocol/server/index.d.ts.map +1 -0
- package/dist/types/remote/protocol/server/messaging.d.ts +37 -0
- package/dist/types/remote/protocol/server/messaging.d.ts.map +1 -0
- package/dist/types/transfer-engine.d.ts +148 -0
- package/dist/types/transfer-engine.d.ts.map +1 -0
- package/dist/types/utils.d.ts +82 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/utils/components.d.ts +23 -3
- package/dist/utils/components.d.ts.map +1 -1
- package/dist/utils/components.js +230 -0
- package/dist/utils/components.js.map +1 -0
- package/dist/utils/components.mjs +219 -0
- package/dist/utils/components.mjs.map +1 -0
- package/dist/{engine → utils}/diagnostic.d.ts +1 -0
- package/dist/utils/diagnostic.d.ts.map +1 -0
- package/dist/utils/diagnostic.js +51 -0
- package/dist/utils/diagnostic.js.map +1 -0
- package/dist/utils/diagnostic.mjs +49 -0
- package/dist/utils/diagnostic.mjs.map +1 -0
- package/dist/utils/encryption/decrypt.d.ts +6 -5
- package/dist/utils/encryption/decrypt.d.ts.map +1 -1
- package/dist/utils/encryption/decrypt.js +47 -0
- package/dist/utils/encryption/decrypt.js.map +1 -0
- package/dist/utils/encryption/decrypt.mjs +45 -0
- package/dist/utils/encryption/decrypt.mjs.map +1 -0
- package/dist/utils/encryption/encrypt.d.ts +6 -5
- package/dist/utils/encryption/encrypt.d.ts.map +1 -1
- package/dist/utils/encryption/encrypt.js +47 -0
- package/dist/utils/encryption/encrypt.js.map +1 -0
- package/dist/utils/encryption/encrypt.mjs +45 -0
- package/dist/utils/encryption/encrypt.mjs.map +1 -0
- package/dist/utils/encryption/index.js +10 -0
- package/dist/utils/encryption/index.js.map +1 -0
- package/dist/utils/encryption/index.mjs +3 -0
- package/dist/utils/encryption/index.mjs.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +28 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +17 -0
- package/dist/utils/index.mjs.map +1 -0
- package/dist/utils/json.d.ts.map +1 -1
- package/dist/utils/json.js +96 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/json.mjs +94 -0
- package/dist/utils/json.mjs.map +1 -0
- package/dist/utils/middleware.d.ts +1 -1
- package/dist/utils/middleware.d.ts.map +1 -1
- package/dist/utils/middleware.js +14 -0
- package/dist/utils/middleware.js.map +1 -0
- package/dist/utils/middleware.mjs +12 -0
- package/dist/utils/middleware.mjs.map +1 -0
- package/dist/utils/providers.js +12 -0
- package/dist/utils/providers.js.map +1 -0
- package/dist/utils/providers.mjs +10 -0
- package/dist/utils/providers.mjs.map +1 -0
- package/dist/utils/schema.d.ts.map +1 -1
- package/dist/utils/schema.js +32 -0
- package/dist/utils/schema.js.map +1 -0
- package/dist/utils/schema.mjs +29 -0
- package/dist/utils/schema.mjs.map +1 -0
- package/dist/utils/stream.d.ts +0 -1
- package/dist/utils/stream.d.ts.map +1 -1
- package/dist/utils/stream.js +96 -0
- package/dist/utils/stream.js.map +1 -0
- package/dist/utils/stream.mjs +92 -0
- package/dist/utils/stream.mjs.map +1 -0
- package/dist/utils/transaction.d.ts +1 -1
- package/dist/utils/transaction.d.ts.map +1 -1
- package/dist/utils/transaction.js +93 -0
- package/dist/utils/transaction.js.map +1 -0
- package/dist/utils/transaction.mjs +91 -0
- package/dist/utils/transaction.mjs.map +1 -0
- package/dist/utils/transfer-asset-chunk.d.ts +61 -0
- package/dist/utils/transfer-asset-chunk.d.ts.map +1 -0
- package/dist/utils/transfer-asset-chunk.js +118 -0
- package/dist/utils/transfer-asset-chunk.js.map +1 -0
- package/dist/utils/transfer-asset-chunk.mjs +112 -0
- package/dist/utils/transfer-asset-chunk.mjs.map +1 -0
- package/dist/utils/transfer-websocket-json.d.ts +24 -0
- package/dist/utils/transfer-websocket-json.d.ts.map +1 -0
- package/dist/utils/transfer-websocket-json.js +67 -0
- package/dist/utils/transfer-websocket-json.js.map +1 -0
- package/dist/utils/transfer-websocket-json.mjs +63 -0
- package/dist/utils/transfer-websocket-json.mjs.map +1 -0
- package/dist/utils/writable-async-write.d.ts +16 -0
- package/dist/utils/writable-async-write.d.ts.map +1 -0
- package/dist/utils/writable-async-write.js +61 -0
- package/dist/utils/writable-async-write.js.map +1 -0
- package/dist/utils/writable-async-write.mjs +59 -0
- package/dist/utils/writable-async-write.mjs.map +1 -0
- package/package.json +40 -26
- package/dist/engine/diagnostic.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.mjs","sources":["../../../../src/strapi/providers/local-source/entities.ts"],"sourcesContent":["import { Readable, Transform } from 'stream';\nimport type { Core, Struct } from '@strapi/types';\n\nimport * as shared from '../../queries';\nimport { IEntity } from '../../../types';\n\n/**\n * Generate and consume content-types streams in order to stream each entity individually\n */\nexport const createEntitiesStream = (\n strapi: Core.Strapi,\n options: { onWarning?: (message: string) => void } = {}\n): Readable => {\n const contentTypes: Struct.ContentTypeSchema[] = Object.values(strapi.contentTypes);\n\n async function* contentTypeStreamGenerator() {\n for (const contentType of contentTypes) {\n const query = shared.entity.createEntityQuery(strapi).call(null, contentType.uid);\n\n const stream: Readable = strapi.db\n // Create a query builder instance (default type is 'select')\n .queryBuilder(contentType.uid)\n // Fetch all columns\n .select('*')\n // Apply the populate\n .populate(query.deepPopulateComponentLikeQuery)\n // Get a readable stream\n .stream();\n\n yield { contentType, stream };\n }\n }\n\n return Readable.from(\n (async function* entitiesGenerator(): AsyncGenerator<{\n entity: IEntity;\n contentType: Struct.ContentTypeSchema;\n }> {\n for await (const { stream, contentType } of contentTypeStreamGenerator()) {\n try {\n for await (const entity of stream) {\n yield { entity, contentType };\n }\n } catch (error) {\n // Surface the failure instead of silently dropping the remaining\n // entities of this content type: every entity skipped here leaves\n // dangling links pointing at rows that were never transferred\n const message = error instanceof Error ? error.message : String(error);\n\n options.onWarning?.(\n `Failed to read all entities of type \"${contentType.uid}\" from the source, the remaining entities of this type were skipped: ${message}`\n );\n } finally {\n stream.destroy();\n }\n }\n })()\n );\n};\n\n/**\n * Create an entity transform stream which convert the output of\n * the multi-content-types stream to the transfer entity format\n */\nexport const createEntitiesTransformStream = (): Transform => {\n return new Transform({\n objectMode: true,\n transform(data, _encoding, callback) {\n const { entity, contentType } = data;\n const { id, ...attributes } = entity;\n\n callback(null, {\n type: contentType.uid,\n id,\n data: attributes,\n });\n },\n });\n};\n"],"names":["createEntitiesStream","strapi","options","contentTypes","Object","values","contentTypeStreamGenerator","contentType","query","shared","call","uid","stream","db","queryBuilder","select","populate","deepPopulateComponentLikeQuery","Readable","from","entitiesGenerator","entity","error","message","Error","String","onWarning","destroy","createEntitiesTransformStream","Transform","objectMode","transform","data","_encoding","callback","id","attributes","type"],"mappings":";;;;AAMA;;AAEC,IACM,MAAMA,oBAAAA,GAAuB,CAClCC,MAAAA,EACAC,OAAAA,GAAqD,EAAE,GAAA;AAEvD,IAAA,MAAMC,YAAAA,GAA2CC,MAAAA,CAAOC,MAAM,CAACJ,OAAOE,YAAY,CAAA;IAElF,gBAAgBG,0BAAAA,GAAAA;QACd,KAAK,MAAMC,eAAeJ,YAAAA,CAAc;YACtC,MAAMK,KAAAA,GAAQC,iBAA+B,CAACR,MAAAA,CAAAA,CAAQS,IAAI,CAAC,IAAA,EAAMH,WAAAA,CAAYI,GAAG,CAAA;AAEhF,YAAA,MAAMC,MAAAA,GAAmBX,MAAAA,CAAOY,EAC9B;AACCC,aAAAA,YAAY,CAACP,WAAAA,CAAYI,GAA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bG,gBAAAA,IAAAA,EAAM9B,YAAYI,GAAG;AACrBwB,gBAAAA,EAAAA;gBACAH,IAAAA,EAAMI;AACR,aAAA,CAAA;AACF,QAAA;AACF,KAAA,CAAA;AACF;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Core } from '@strapi/types';
|
|
2
|
+
import type { StageTotalsEstimate } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Sum sizes and counts for the same asset rows `createAssetsStream` would yield (main + formats),
|
|
5
|
+
* skipping missing files with ENOENT like the stream does. Used for transfer progress totals / ETA.
|
|
6
|
+
*
|
|
7
|
+
* - **Local (`provider === 'local'`):** `stat` on disk (source of truth; matches ENOENT skips).
|
|
8
|
+
* - **Remote:** sum `size` from DB when present on main and every format; otherwise sign + `fetch` / `Content-Length` like before.
|
|
9
|
+
*/
|
|
10
|
+
export declare function estimateAssetTotals(strapi: Core.Strapi): Promise<StageTotalsEstimate>;
|
|
11
|
+
//# sourceMappingURL=estimate-asset-totals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimate-asset-totals.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/estimate-asset-totals.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,KAAK,EAAU,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AA2BlE;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA0H3F"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var assets = require('./assets.js');
|
|
5
|
+
|
|
6
|
+
/** Strapi stores byte size on each file record; use for remote totals to avoid per-URL HTTP. */ function hasReliableDbSize(size) {
|
|
7
|
+
return typeof size === 'number' && Number.isFinite(size) && size >= 0;
|
|
8
|
+
}
|
|
9
|
+
/** When every main + format has a DB size, remote rows need no signing or HTTP stat. */ function remoteRowCanUseDbOnly(file) {
|
|
10
|
+
if (!hasReliableDbSize(file.size)) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (!file.formats) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
for (const key of Object.keys(file.formats)){
|
|
17
|
+
if (!hasReliableDbSize(file.formats[key].size)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sum sizes and counts for the same asset rows `createAssetsStream` would yield (main + formats),
|
|
25
|
+
* skipping missing files with ENOENT like the stream does. Used for transfer progress totals / ETA.
|
|
26
|
+
*
|
|
27
|
+
* - **Local (`provider === 'local'`):** `stat` on disk (source of truth; matches ENOENT skips).
|
|
28
|
+
* - **Remote:** sum `size` from DB when present on main and every format; otherwise sign + `fetch` / `Content-Length` like before.
|
|
29
|
+
*/ async function estimateAssetTotals(strapi) {
|
|
30
|
+
let totalBytes = 0;
|
|
31
|
+
let totalCount = 0;
|
|
32
|
+
const stream = strapi.db.queryBuilder('plugin::upload.file').select('*').stream();
|
|
33
|
+
for await (const file of stream){
|
|
34
|
+
const isLocalProvider = file.provider === 'local';
|
|
35
|
+
if (isLocalProvider) {
|
|
36
|
+
const filepath = path.join(strapi.dirs.static.public, file.url);
|
|
37
|
+
try {
|
|
38
|
+
const stats = await assets.getFileStatsForTransfer(filepath, strapi, true);
|
|
39
|
+
totalBytes += stats.size;
|
|
40
|
+
totalCount += 1;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
43
|
+
if (code === 'ENOENT') {
|
|
44
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${filepath}`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
throw err;
|
|
48
|
+
}
|
|
49
|
+
if (file.formats) {
|
|
50
|
+
for (const format of Object.keys(file.formats)){
|
|
51
|
+
const fileFormat = file.formats[format];
|
|
52
|
+
const fileFormatFilepath = path.join(strapi.dirs.static.public, fileFormat.url);
|
|
53
|
+
try {
|
|
54
|
+
const fileFormatStats = await assets.getFileStatsForTransfer(fileFormatFilepath, strapi, true);
|
|
55
|
+
totalBytes += fileFormatStats.size;
|
|
56
|
+
totalCount += 1;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
59
|
+
if (code === 'ENOENT') {
|
|
60
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
throw err;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
// Remote: prefer DB sizes (fast); fall back to signed URL + HTTP where `size` is missing.
|
|
70
|
+
if (remoteRowCanUseDbOnly(file)) {
|
|
71
|
+
totalBytes += file.size;
|
|
72
|
+
totalCount += 1;
|
|
73
|
+
if (file.formats) {
|
|
74
|
+
for (const format of Object.keys(file.formats)){
|
|
75
|
+
totalBytes += file.formats[format].size;
|
|
76
|
+
totalCount += 1;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
await assets.signUploadFileForTransfer(strapi, file);
|
|
82
|
+
if (hasReliableDbSize(file.size)) {
|
|
83
|
+
totalBytes += file.size;
|
|
84
|
+
totalCount += 1;
|
|
85
|
+
} else {
|
|
86
|
+
try {
|
|
87
|
+
const stats = await assets.getFileStatsForTransfer(file.url, strapi, false);
|
|
88
|
+
totalBytes += stats.size;
|
|
89
|
+
totalCount += 1;
|
|
90
|
+
} catch (err) {
|
|
91
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
92
|
+
if (code === 'ENOENT') {
|
|
93
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${file.url}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
throw err;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (file.formats) {
|
|
100
|
+
for (const format of Object.keys(file.formats)){
|
|
101
|
+
const fileFormat = file.formats[format];
|
|
102
|
+
const fileFormatFilepath = fileFormat.url;
|
|
103
|
+
if (hasReliableDbSize(fileFormat.size)) {
|
|
104
|
+
totalBytes += fileFormat.size;
|
|
105
|
+
totalCount += 1;
|
|
106
|
+
} else {
|
|
107
|
+
try {
|
|
108
|
+
const fileFormatStats = await assets.getFileStatsForTransfer(fileFormatFilepath, strapi, false);
|
|
109
|
+
totalBytes += fileFormatStats.size;
|
|
110
|
+
totalCount += 1;
|
|
111
|
+
} catch (err) {
|
|
112
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
113
|
+
if (code === 'ENOENT') {
|
|
114
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
totalBytes,
|
|
125
|
+
totalCount
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
exports.estimateAssetTotals = estimateAssetTotals;
|
|
130
|
+
//# sourceMappingURL=estimate-asset-totals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimate-asset-totals.js","sources":["../../../../src/strapi/providers/local-source/estimate-asset-totals.ts"],"sourcesContent":["import { join } from 'path';\nimport type { Readable } from 'stream';\nimport type { Core } from '@strapi/types';\n\nimport type { IAsset, StageTotalsEstimate } from '../../../types';\n\nimport { getFileStatsForTransfer, signUploadFileForTransfer } from './assets';\n\ntype UploadFileRecord = IAsset['metadata'];\n\n/** Strapi stores byte size on each file record; use for remote totals to avoid per-URL HTTP. */\nfunction hasReliableDbSize(size: unknown): size is number {\n return typeof size === 'number' && Number.isFinite(size) && size >= 0;\n}\n\n/** When every main + format has a DB size, remote rows need no signing or HTTP stat. */\nfunction remoteRowCanUseDbOnly(file: UploadFileRecord): boolean {\n if (!hasReliableDbSize(file.size)) {\n return false;\n }\n if (!file.formats) {\n return true;\n }\n for (const key of Object.keys(file.formats)) {\n if (!hasReliableDbSize(file.formats[key].size)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Sum sizes and counts for the same asset rows `createAssetsStream` would yield (main + formats),\n * skipping missing files with ENOENT like the stream does. Used for transfer progress totals / ETA.\n *\n * - **Local (`provider === 'local'`):** `stat` on disk (source of truth; matches ENOENT skips).\n * - **Remote:** sum `size` from DB when present on main and every format; otherwise sign + `fetch` / `Content-Length` like before.\n */\nexport async function estimateAssetTotals(strapi: Core.Strapi): Promise<StageTotalsEstimate> {\n let totalBytes = 0;\n let totalCount = 0;\n\n const stream: Readable = strapi.db.queryBuilder('plugin::upload.file').select('*').stream();\n\n for await (const file of stream) {\n const isLocalProvider = file.provider === 'local';\n\n if (isLocalProvider) {\n const filepath = join(strapi.dirs.static.public, file.url);\n try {\n const stats = await getFileStatsForTransfer(filepath, strapi, true);\n totalBytes += stats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${filepath}`);\n continue;\n }\n throw err;\n }\n\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n const fileFormat = file.formats[format];\n const fileFormatFilepath = join(strapi.dirs.static.public, fileFormat.url);\n try {\n const fileFormatStats = await getFileStatsForTransfer(fileFormatFilepath, strapi, true);\n totalBytes += fileFormatStats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);\n continue;\n }\n throw err;\n }\n }\n }\n\n continue;\n }\n\n // Remote: prefer DB sizes (fast); fall back to signed URL + HTTP where `size` is missing.\n if (remoteRowCanUseDbOnly(file)) {\n totalBytes += file.size;\n totalCount += 1;\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n totalBytes += file.formats[format].size;\n totalCount += 1;\n }\n }\n continue;\n }\n\n await signUploadFileForTransfer(strapi, file);\n\n if (hasReliableDbSize(file.size)) {\n totalBytes += file.size;\n totalCount += 1;\n } else {\n try {\n const stats = await getFileStatsForTransfer(file.url, strapi, false);\n totalBytes += stats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${file.url}`);\n continue;\n }\n throw err;\n }\n }\n\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n const fileFormat = file.formats[format];\n const fileFormatFilepath = fileFormat.url;\n\n if (hasReliableDbSize(fileFormat.size)) {\n totalBytes += fileFormat.size;\n totalCount += 1;\n } else {\n try {\n const fileFormatStats = await getFileStatsForTransfer(\n fileFormatFilepath,\n strapi,\n false\n );\n totalBytes += fileFormatStats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);\n continue;\n }\n throw err;\n }\n }\n }\n }\n }\n\n return { totalBytes, totalCount };\n}\n"],"names":["hasReliableDbSize","size","Number","isFinite","remoteRowCanUseDbOnly","file","formats","key","Object","keys","estimateAssetTotals","strapi","totalBytes","totalCount","stream","db","queryBuilder","select","isLocalProvider","provider","filepath","join","dirs","static","public","url","stats","getFileStatsForTransfer","err","code","undefined","log","warn","format","fileFormat","fileFormatFilepath","fileFormatStats","signUploadFileForTransfer"],"mappings":";;;;;AAUA,iGACA,SAASA,iBAAAA,CAAkBC,IAAa,EAAA;AACtC,IAAA,OAAO,OAAOA,IAAAA,KAAS,QAAA,IAAYC,OAAOC,QAAQ,CAACF,SAASA,IAAAA,IAAQ,CAAA;AACtE;AAEA,yFACA,SAASG,qBAAAA,CAAsBC,IAAsB,EAAA;AACnD,IAAA,IAAI,CAACL,iBAAAA,CAAkBK,IAAAA,CAAKJ,IAAI,CAAA,EAAG;QACjC,OAAO,KAAA;AACT,IAAA;IACA,IAAI,CAACI,IAAAA,CAAKC,OAAO,EAAE;QACjB,OAAO,IAAA;AACT,IAAA;AACA,IAAA,KAAK,MAAMC,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACJ,IAAAA,CAAKC,OAAO,CAAA,CAAG;QAC3C,IAAI,CAACN,kBAAkBK,IAAAA,CAAKC,OAAO,CAACC,GAAAA,CAAI,CAACN,IAAI,CAAA,EAAG;YAC9C,OAAO,KAAA;AACT,QAAA;AACF,IAAA;IACA,OAAO,IAAA;AACT;AAEA;;;;;;IAOO,eAAeS,mBAAAA,CAAoBC,MAAmB,EAAA;AAC3D,IAAA,IAAIC,UAAAA,GAAa,CAAA;AACjB,IAAA,IAAIC,UAAAA,GAAa,CAAA;IAEjB,MAAMC,MAAAA,GAAmBH,MAAAA,CAAOI,EAAE,CAACC,YAAY,CAAC,qBAAA,CAAA,CAAuBC,MAAM,CAAC,GAAA,CAAA,CAAKH,MAAM,EAAA;IAEzF,WAAW,MAAMT,QAAQS,MAAAA,CAAQ;QAC/B,MAAMI,eAAAA,GAAkBb,IAAAA,CAAKc,QAAQ,KAAK,OAAA;AAE1C,QAAA,IAAID,eAAAA,EAAiB;YACnB,MAAME,QAAAA,GAAWC,SAAAA,CAAKV,MAAAA,CAAOW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,CAAC,CAAC,6CAA6C,EAAEG,kBAAAA,CAAAA,CAAoB,CAAA;AACpF,4BAAA;AACF,wBAAA;wBACA,MAAMP,GAAAA;AACR,oBAAA;AACF,gBAAA;AACF,YAAA;AACF,QAAA;AACF,IAAA;IAEA,OAAO;AAAEhB,QAAAA,UAAAA;AAAYC,QAAAA;AAAW,KAAA;AAClC;;;;"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { getFileStatsForTransfer, signUploadFileForTransfer } from './assets.mjs';
|
|
3
|
+
|
|
4
|
+
/** Strapi stores byte size on each file record; use for remote totals to avoid per-URL HTTP. */ function hasReliableDbSize(size) {
|
|
5
|
+
return typeof size === 'number' && Number.isFinite(size) && size >= 0;
|
|
6
|
+
}
|
|
7
|
+
/** When every main + format has a DB size, remote rows need no signing or HTTP stat. */ function remoteRowCanUseDbOnly(file) {
|
|
8
|
+
if (!hasReliableDbSize(file.size)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (!file.formats) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
for (const key of Object.keys(file.formats)){
|
|
15
|
+
if (!hasReliableDbSize(file.formats[key].size)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sum sizes and counts for the same asset rows `createAssetsStream` would yield (main + formats),
|
|
23
|
+
* skipping missing files with ENOENT like the stream does. Used for transfer progress totals / ETA.
|
|
24
|
+
*
|
|
25
|
+
* - **Local (`provider === 'local'`):** `stat` on disk (source of truth; matches ENOENT skips).
|
|
26
|
+
* - **Remote:** sum `size` from DB when present on main and every format; otherwise sign + `fetch` / `Content-Length` like before.
|
|
27
|
+
*/ async function estimateAssetTotals(strapi) {
|
|
28
|
+
let totalBytes = 0;
|
|
29
|
+
let totalCount = 0;
|
|
30
|
+
const stream = strapi.db.queryBuilder('plugin::upload.file').select('*').stream();
|
|
31
|
+
for await (const file of stream){
|
|
32
|
+
const isLocalProvider = file.provider === 'local';
|
|
33
|
+
if (isLocalProvider) {
|
|
34
|
+
const filepath = join(strapi.dirs.static.public, file.url);
|
|
35
|
+
try {
|
|
36
|
+
const stats = await getFileStatsForTransfer(filepath, strapi, true);
|
|
37
|
+
totalBytes += stats.size;
|
|
38
|
+
totalCount += 1;
|
|
39
|
+
} catch (err) {
|
|
40
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
41
|
+
if (code === 'ENOENT') {
|
|
42
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${filepath}`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
if (file.formats) {
|
|
48
|
+
for (const format of Object.keys(file.formats)){
|
|
49
|
+
const fileFormat = file.formats[format];
|
|
50
|
+
const fileFormatFilepath = join(strapi.dirs.static.public, fileFormat.url);
|
|
51
|
+
try {
|
|
52
|
+
const fileFormatStats = await getFileStatsForTransfer(fileFormatFilepath, strapi, true);
|
|
53
|
+
totalBytes += fileFormatStats.size;
|
|
54
|
+
totalCount += 1;
|
|
55
|
+
} catch (err) {
|
|
56
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
57
|
+
if (code === 'ENOENT') {
|
|
58
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
throw err;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
// Remote: prefer DB sizes (fast); fall back to signed URL + HTTP where `size` is missing.
|
|
68
|
+
if (remoteRowCanUseDbOnly(file)) {
|
|
69
|
+
totalBytes += file.size;
|
|
70
|
+
totalCount += 1;
|
|
71
|
+
if (file.formats) {
|
|
72
|
+
for (const format of Object.keys(file.formats)){
|
|
73
|
+
totalBytes += file.formats[format].size;
|
|
74
|
+
totalCount += 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
await signUploadFileForTransfer(strapi, file);
|
|
80
|
+
if (hasReliableDbSize(file.size)) {
|
|
81
|
+
totalBytes += file.size;
|
|
82
|
+
totalCount += 1;
|
|
83
|
+
} else {
|
|
84
|
+
try {
|
|
85
|
+
const stats = await getFileStatsForTransfer(file.url, strapi, false);
|
|
86
|
+
totalBytes += stats.size;
|
|
87
|
+
totalCount += 1;
|
|
88
|
+
} catch (err) {
|
|
89
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
90
|
+
if (code === 'ENOENT') {
|
|
91
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${file.url}`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (file.formats) {
|
|
98
|
+
for (const format of Object.keys(file.formats)){
|
|
99
|
+
const fileFormat = file.formats[format];
|
|
100
|
+
const fileFormatFilepath = fileFormat.url;
|
|
101
|
+
if (hasReliableDbSize(fileFormat.size)) {
|
|
102
|
+
totalBytes += fileFormat.size;
|
|
103
|
+
totalCount += 1;
|
|
104
|
+
} else {
|
|
105
|
+
try {
|
|
106
|
+
const fileFormatStats = await getFileStatsForTransfer(fileFormatFilepath, strapi, false);
|
|
107
|
+
totalBytes += fileFormatStats.size;
|
|
108
|
+
totalCount += 1;
|
|
109
|
+
} catch (err) {
|
|
110
|
+
const code = err && typeof err === 'object' && 'code' in err ? err.code : undefined;
|
|
111
|
+
if (code === 'ENOENT') {
|
|
112
|
+
strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
totalBytes,
|
|
123
|
+
totalCount
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { estimateAssetTotals };
|
|
128
|
+
//# sourceMappingURL=estimate-asset-totals.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimate-asset-totals.mjs","sources":["../../../../src/strapi/providers/local-source/estimate-asset-totals.ts"],"sourcesContent":["import { join } from 'path';\nimport type { Readable } from 'stream';\nimport type { Core } from '@strapi/types';\n\nimport type { IAsset, StageTotalsEstimate } from '../../../types';\n\nimport { getFileStatsForTransfer, signUploadFileForTransfer } from './assets';\n\ntype UploadFileRecord = IAsset['metadata'];\n\n/** Strapi stores byte size on each file record; use for remote totals to avoid per-URL HTTP. */\nfunction hasReliableDbSize(size: unknown): size is number {\n return typeof size === 'number' && Number.isFinite(size) && size >= 0;\n}\n\n/** When every main + format has a DB size, remote rows need no signing or HTTP stat. */\nfunction remoteRowCanUseDbOnly(file: UploadFileRecord): boolean {\n if (!hasReliableDbSize(file.size)) {\n return false;\n }\n if (!file.formats) {\n return true;\n }\n for (const key of Object.keys(file.formats)) {\n if (!hasReliableDbSize(file.formats[key].size)) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Sum sizes and counts for the same asset rows `createAssetsStream` would yield (main + formats),\n * skipping missing files with ENOENT like the stream does. Used for transfer progress totals / ETA.\n *\n * - **Local (`provider === 'local'`):** `stat` on disk (source of truth; matches ENOENT skips).\n * - **Remote:** sum `size` from DB when present on main and every format; otherwise sign + `fetch` / `Content-Length` like before.\n */\nexport async function estimateAssetTotals(strapi: Core.Strapi): Promise<StageTotalsEstimate> {\n let totalBytes = 0;\n let totalCount = 0;\n\n const stream: Readable = strapi.db.queryBuilder('plugin::upload.file').select('*').stream();\n\n for await (const file of stream) {\n const isLocalProvider = file.provider === 'local';\n\n if (isLocalProvider) {\n const filepath = join(strapi.dirs.static.public, file.url);\n try {\n const stats = await getFileStatsForTransfer(filepath, strapi, true);\n totalBytes += stats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${filepath}`);\n continue;\n }\n throw err;\n }\n\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n const fileFormat = file.formats[format];\n const fileFormatFilepath = join(strapi.dirs.static.public, fileFormat.url);\n try {\n const fileFormatStats = await getFileStatsForTransfer(fileFormatFilepath, strapi, true);\n totalBytes += fileFormatStats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);\n continue;\n }\n throw err;\n }\n }\n }\n\n continue;\n }\n\n // Remote: prefer DB sizes (fast); fall back to signed URL + HTTP where `size` is missing.\n if (remoteRowCanUseDbOnly(file)) {\n totalBytes += file.size;\n totalCount += 1;\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n totalBytes += file.formats[format].size;\n totalCount += 1;\n }\n }\n continue;\n }\n\n await signUploadFileForTransfer(strapi, file);\n\n if (hasReliableDbSize(file.size)) {\n totalBytes += file.size;\n totalCount += 1;\n } else {\n try {\n const stats = await getFileStatsForTransfer(file.url, strapi, false);\n totalBytes += stats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${file.url}`);\n continue;\n }\n throw err;\n }\n }\n\n if (file.formats) {\n for (const format of Object.keys(file.formats)) {\n const fileFormat = file.formats[format];\n const fileFormatFilepath = fileFormat.url;\n\n if (hasReliableDbSize(fileFormat.size)) {\n totalBytes += fileFormat.size;\n totalCount += 1;\n } else {\n try {\n const fileFormatStats = await getFileStatsForTransfer(\n fileFormatFilepath,\n strapi,\n false\n );\n totalBytes += fileFormatStats.size;\n totalCount += 1;\n } catch (err: unknown) {\n const code =\n err && typeof err === 'object' && 'code' in err\n ? (err as NodeJS.ErrnoException).code\n : undefined;\n if (code === 'ENOENT') {\n strapi.log.warn(`[Data transfer] Skipping missing asset file: ${fileFormatFilepath}`);\n continue;\n }\n throw err;\n }\n }\n }\n }\n }\n\n return { totalBytes, totalCount };\n}\n"],"names":["hasReliableDbSize","size","Number","isFinite","remoteRowCanUseDbOnly","file","formats","key","Object","keys","estimateAssetTotals","strapi","totalBytes","totalCount","stream","db","queryBuilder","select","isLocalProvider","provider","filepath","join","dirs","static","public","url","stats","getFileStatsForTransfer","err","code","undefined","log","warn","format","fileFormat","fileFormatFilepath","fileFormatStats","signUploadFileForTransfer"],"mappings":";;;AAUA,iGACA,SAASA,iBAAAA,CAAkBC,IAAa,EAAA;AACtC,IAAA,OAAO,OAAOA,IAAAA,KAAS,QAAA,IAAYC,OAAOC,QAAQ,CAACF,SAASA,IAAAA,IAAQ,CAAA;AACtE;AAEA,yFACA,SAASG,qBAAAA,CAAsBC,IAAsB,EAAA;AACnD,IAAA,IAAI,CAACL,iBAAAA,CAAkBK,IAAAA,CAAKJ,IAAI,CAAA,EAAG;QACjC,OAAO,KAAA;AACT,IAAA;IACA,IAAI,CAACI,IAAAA,CAAKC,OAAO,EAAE;QACjB,OAAO,IAAA;AACT,IAAA;AACA,IAAA,KAAK,MAAMC,GAAAA,IAAOC,MAAAA,CAAOC,IAAI,CAACJ,IAAAA,CAAKC,OAAO,CAAA,CAAG;QAC3C,IAAI,CAACN,kBAAkBK,IAAAA,CAAKC,OAAO,CAACC,GAAAA,CAAI,CAACN,IAAI,CAAA,EAAG;YAC9C,OAAO,KAAA;AACT,QAAA;AACF,IAAA;IACA,OAAO,IAAA;AACT;AAEA;;;;;;IAOO,eAAeS,mBAAAA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,MAAMuB,eAAAA,GAAkB,MAAMT,uBAAAA,CAC5BQ,kBAAAA,EACAxB,MAAAA,EACA,KAAA,CAAA;AAEFC,wBAAAA,UAAAA,IAAcwB,gBAAgBnC,IAAI;wBAClCY,UAAAA,IAAc,CAAA;AAChB,oBAAA,CAAA,CAAE,OAAOe,GAAAA,EAAc;wBACrB,MAAMC,IAAAA,GACJD,GAAAA,IAAO,OAAOA,GAAAA,KAAQ,QAAA,IAAY,UAAUA,GAAAA,GACvCA,GAAAA,CAA8BC,IAAI,GACnCC,SAAAA;AACN,wBAAA,IAAID,SAAS,QAAA,EAAU;AACrBlB,4BAAAA,MAAAA,CAAOoB,GAAG,CAACC,IAAI,CAAC,CAAC,6CAA6C,EAAEG,kBAAAA,CAAAA,CAAoB,CAAA;AACpF,4BAAA;AACF,wBAAA;wBACA,MAAMP,GAAAA;AACR,oBAAA;AACF,gBAAA;AACF,YAAA;AACF,QAAA;AACF,IAAA;IAEA,OAAO;AAAEhB,QAAAA,UAAAA;AAAYC,QAAAA;AAAW,KAAA;AAClC;;;;"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Readable } from 'stream';
|
|
3
2
|
import type { Core, Struct } from '@strapi/types';
|
|
4
|
-
import type { IMetadata, ISourceProvider, ProviderType } from '
|
|
3
|
+
import type { IMetadata, ISourceProvider, ProviderType, TransferStage } from '../../../types';
|
|
4
|
+
import type { IDiagnosticReporter } from '../../../utils/diagnostic';
|
|
5
5
|
export interface ILocalStrapiSourceProviderOptions {
|
|
6
6
|
getStrapi(): Core.Strapi | Promise<Core.Strapi>;
|
|
7
7
|
autoDestroy?: boolean;
|
|
8
8
|
}
|
|
9
9
|
export declare const createLocalStrapiSourceProvider: (options: ILocalStrapiSourceProviderOptions) => LocalStrapiSourceProvider;
|
|
10
10
|
declare class LocalStrapiSourceProvider implements ISourceProvider {
|
|
11
|
+
#private;
|
|
11
12
|
name: string;
|
|
12
13
|
type: ProviderType;
|
|
13
14
|
options: ILocalStrapiSourceProviderOptions;
|
|
14
15
|
strapi?: Core.Strapi;
|
|
15
16
|
constructor(options: ILocalStrapiSourceProviderOptions);
|
|
16
|
-
bootstrap(): Promise<void>;
|
|
17
|
+
bootstrap(diagnostics?: IDiagnosticReporter): Promise<void>;
|
|
17
18
|
close(): Promise<void>;
|
|
18
19
|
getMetadata(): IMetadata;
|
|
19
20
|
createEntitiesReadStream(): Promise<Readable>;
|
|
@@ -22,7 +23,8 @@ declare class LocalStrapiSourceProvider implements ISourceProvider {
|
|
|
22
23
|
getSchemas(): Record<string, Struct.Schema>;
|
|
23
24
|
createSchemasReadStream(): Readable;
|
|
24
25
|
createAssetsReadStream(): Readable;
|
|
26
|
+
getStageTotals(stage: TransferStage): Promise<import("../../../types").StageTotalsEstimate | null>;
|
|
25
27
|
}
|
|
26
28
|
export type ILocalStrapiSourceProvider = InstanceType<typeof LocalStrapiSourceProvider>;
|
|
27
|
-
export {};
|
|
29
|
+
export { estimateAssetTotals } from './estimate-asset-totals';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/strapi/providers/local-source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AASrE,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;IA4D3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B,WAAW,IAAI,SAAS;IAclB,wBAAwB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAiBnD,qBAAqB,IAAI,QAAQ;IAOjC,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"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stream = require('stream');
|
|
4
|
+
var streamChain = require('stream-chain');
|
|
5
|
+
var entities = require('./entities.js');
|
|
6
|
+
var links = require('./links.js');
|
|
7
|
+
var configuration = require('./configuration.js');
|
|
8
|
+
var assets = require('./assets.js');
|
|
9
|
+
var estimateAssetTotals = require('./estimate-asset-totals.js');
|
|
10
|
+
require('crypto');
|
|
11
|
+
require('node:events');
|
|
12
|
+
require('node:stream/promises');
|
|
13
|
+
require('lodash/fp');
|
|
14
|
+
var schema = require('../../../utils/schema.js');
|
|
15
|
+
require('events');
|
|
16
|
+
var providers = require('../../../utils/providers.js');
|
|
17
|
+
|
|
18
|
+
function _class_private_field_loose_base(receiver, privateKey) {
|
|
19
|
+
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
|
|
20
|
+
throw new TypeError("attempted to use private field on non-instance");
|
|
21
|
+
}
|
|
22
|
+
return receiver;
|
|
23
|
+
}
|
|
24
|
+
var id = 0;
|
|
25
|
+
function _class_private_field_loose_key(name) {
|
|
26
|
+
return "__private_" + id++ + "_" + name;
|
|
27
|
+
}
|
|
28
|
+
const createLocalStrapiSourceProvider = (options)=>{
|
|
29
|
+
return new LocalStrapiSourceProvider(options);
|
|
30
|
+
};
|
|
31
|
+
var _diagnostics = /*#__PURE__*/ _class_private_field_loose_key("_diagnostics"), _reportInfo = /*#__PURE__*/ _class_private_field_loose_key("_reportInfo"), _reportWarning = /*#__PURE__*/ _class_private_field_loose_key("_reportWarning"), /**
|
|
32
|
+
* Reports an error to the diagnostic reporter.
|
|
33
|
+
*/ _reportError = /*#__PURE__*/ _class_private_field_loose_key("_reportError"), /**
|
|
34
|
+
* Handles errors that occur in read streams.
|
|
35
|
+
*/ _handleStreamError = /*#__PURE__*/ _class_private_field_loose_key("_handleStreamError");
|
|
36
|
+
class LocalStrapiSourceProvider {
|
|
37
|
+
async bootstrap(diagnostics) {
|
|
38
|
+
_class_private_field_loose_base(this, _diagnostics)[_diagnostics] = diagnostics;
|
|
39
|
+
this.strapi = await this.options.getStrapi();
|
|
40
|
+
this.strapi.db.lifecycles.disable();
|
|
41
|
+
}
|
|
42
|
+
async close() {
|
|
43
|
+
const { autoDestroy } = this.options;
|
|
44
|
+
providers.assertValidStrapi(this.strapi);
|
|
45
|
+
this.strapi.db.lifecycles.enable();
|
|
46
|
+
// Basically `!== false` but more deterministic
|
|
47
|
+
if (autoDestroy === undefined || autoDestroy === true) {
|
|
48
|
+
await this.strapi?.destroy();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
getMetadata() {
|
|
52
|
+
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting metadata');
|
|
53
|
+
providers.assertValidStrapi(this.strapi);
|
|
54
|
+
const strapiVersion = this.strapi.config.get('info.strapi');
|
|
55
|
+
const createdAt = new Date().toISOString();
|
|
56
|
+
return {
|
|
57
|
+
createdAt,
|
|
58
|
+
strapi: {
|
|
59
|
+
version: strapiVersion
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async createEntitiesReadStream() {
|
|
64
|
+
providers.assertValidStrapi(this.strapi, 'Not able to stream entities');
|
|
65
|
+
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating entities read stream');
|
|
66
|
+
return streamChain.chain([
|
|
67
|
+
// Entities stream
|
|
68
|
+
entities.createEntitiesStream(this.strapi, {
|
|
69
|
+
onWarning: (message)=>{
|
|
70
|
+
this.strapi?.log.warn(message);
|
|
71
|
+
_class_private_field_loose_base(this, _reportWarning)[_reportWarning](message);
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
// Transform stream
|
|
75
|
+
entities.createEntitiesTransformStream()
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
createLinksReadStream() {
|
|
79
|
+
providers.assertValidStrapi(this.strapi, 'Not able to stream links');
|
|
80
|
+
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating links read stream');
|
|
81
|
+
return links.createLinksStream(this.strapi);
|
|
82
|
+
}
|
|
83
|
+
createConfigurationReadStream() {
|
|
84
|
+
providers.assertValidStrapi(this.strapi, 'Not able to stream configuration');
|
|
85
|
+
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating configuration read stream');
|
|
86
|
+
return configuration.createConfigurationStream(this.strapi);
|
|
87
|
+
}
|
|
88
|
+
getSchemas() {
|
|
89
|
+
providers.assertValidStrapi(this.strapi, 'Not able to get Schemas');
|
|
90
|
+
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('getting schemas');
|
|
91
|
+
const schemas = schema.schemasToValidJSON({
|
|
92
|
+
...this.strapi.contentTypes,
|
|
93
|
+
...this.strapi.components
|
|
94
|
+
});
|
|
95
|
+
return schema.mapSchemasValues(schemas);
|
|
96
|
+
}
|
|
97
|
+
createSchemasReadStream() {
|
|
98
|
+
return stream.Readable.from(Object.values(this.getSchemas()));
|
|
99
|
+
}
|
|
100
|
+
createAssetsReadStream() {
|
|
101
|
+
providers.assertValidStrapi(this.strapi, 'Not able to stream assets');
|
|
102
|
+
_class_private_field_loose_base(this, _reportInfo)[_reportInfo]('creating assets read stream');
|
|
103
|
+
const stream = assets.createAssetsStream(this.strapi, {
|
|
104
|
+
onWarning: (message)=>_class_private_field_loose_base(this, _reportWarning)[_reportWarning](message)
|
|
105
|
+
});
|
|
106
|
+
stream.on('error', (err)=>{
|
|
107
|
+
_class_private_field_loose_base(this, _handleStreamError)[_handleStreamError]('assets', err);
|
|
108
|
+
});
|
|
109
|
+
return stream;
|
|
110
|
+
}
|
|
111
|
+
async getStageTotals(stage) {
|
|
112
|
+
if (stage !== 'assets') {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
providers.assertValidStrapi(this.strapi, 'Not able to estimate asset totals');
|
|
116
|
+
return estimateAssetTotals.estimateAssetTotals(this.strapi);
|
|
117
|
+
}
|
|
118
|
+
constructor(options){
|
|
119
|
+
Object.defineProperty(this, _reportInfo, {
|
|
120
|
+
value: reportInfo
|
|
121
|
+
});
|
|
122
|
+
Object.defineProperty(this, _reportWarning, {
|
|
123
|
+
value: reportWarning
|
|
124
|
+
});
|
|
125
|
+
Object.defineProperty(this, _reportError, {
|
|
126
|
+
value: reportError
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(this, _handleStreamError, {
|
|
129
|
+
value: handleStreamError
|
|
130
|
+
});
|
|
131
|
+
Object.defineProperty(this, _diagnostics, {
|
|
132
|
+
writable: true,
|
|
133
|
+
value: void 0
|
|
134
|
+
});
|
|
135
|
+
this.name = 'source::local-strapi';
|
|
136
|
+
this.type = 'source';
|
|
137
|
+
this.options = options;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function reportInfo(message) {
|
|
141
|
+
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
|
|
142
|
+
details: {
|
|
143
|
+
createdAt: new Date(),
|
|
144
|
+
message,
|
|
145
|
+
origin: 'local-source-provider'
|
|
146
|
+
},
|
|
147
|
+
kind: 'info'
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function reportWarning(message) {
|
|
151
|
+
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
|
|
152
|
+
details: {
|
|
153
|
+
createdAt: new Date(),
|
|
154
|
+
message,
|
|
155
|
+
origin: 'local-source-provider'
|
|
156
|
+
},
|
|
157
|
+
kind: 'warning'
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function reportError(message, error) {
|
|
161
|
+
_class_private_field_loose_base(this, _diagnostics)[_diagnostics]?.report({
|
|
162
|
+
details: {
|
|
163
|
+
createdAt: new Date(),
|
|
164
|
+
message,
|
|
165
|
+
error,
|
|
166
|
+
severity: 'fatal',
|
|
167
|
+
name: error.name
|
|
168
|
+
},
|
|
169
|
+
kind: 'error'
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function handleStreamError(streamType, err) {
|
|
173
|
+
const { message, stack } = err;
|
|
174
|
+
const errorMessage = `[Data transfer] Error in ${streamType} read stream: ${message}`;
|
|
175
|
+
const formattedError = {
|
|
176
|
+
message: errorMessage,
|
|
177
|
+
stack,
|
|
178
|
+
timestamp: new Date().toISOString()
|
|
179
|
+
};
|
|
180
|
+
this.strapi?.log.error(formattedError);
|
|
181
|
+
_class_private_field_loose_base(this, _reportError)[_reportError](formattedError.message, err);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
exports.estimateAssetTotals = estimateAssetTotals.estimateAssetTotals;
|
|
185
|
+
exports.createLocalStrapiSourceProvider = createLocalStrapiSourceProvider;
|
|
186
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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 }\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,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