v1.15.0
Version 1.15.0 of Medusa comes with improvements to the Import and Export features, leading to several breaking changes.
Overview
This release contains breaking changes in the Import/Export and File Service domains.
How to Update
Run the following command in the root directory of your Medusa Backend:
To avoid unexpected issues with dependencies, it is also recommended to update all other Medusa plugins or packages you have installed. For this release in particular, you must update file service plugins to ensure they work as expected.
File Services
The file service streaming API to upload to public/private buckets has been updated to be consistent across all plugins.
File Service Interface
The following types specific to file services have moved from @medusajs/medusa
to @medusajs/types
:
export type FileServiceUploadResult = {
url: string
key: string
}
export type FileServiceGetUploadStreamResult = {
writeStream: stream.PassThrough
promise: Promise<any>
url: string
fileKey: string
[x: string]: unknown
}
export type GetUploadedFileType = {
fileKey: string
isPrivate?: boolean
[x: string]: unknown
}
export type DeleteFileType = {
fileKey: string
[x: string]: unknown
}
export type UploadStreamDescriptorType = {
name: string
ext?: string
isPrivate?: boolean
[x: string]: unknown
}
Also, previously, the getUploadStreamDescriptor
method of file services didn't require a specific option to specify whether a file should be uploaded to a private or public bucket. For example, if you used the MinIO plugin, you passed the usePrivateBucket
option, whereas with the S3 and Spaces plugins, you passed the acl
option.
With this update, the option is now specified within the signature of the method in the IFileService
interface that all file services extend. The getUploadStreamDescriptor
now accepts as part of its option the isPrivate
option:
File Service Plugins
Following the updates in the previous section, all the official plugins (MinIO, S3, and Spaces) now implement the new getUploadStreamDescriptor
signature. The isPrivate
option is optional and defaults to true
.
For example, here's a comparison of how you previously specified whether a file should be uploaded to a private or public bucket, and how you must do it now:
// before
// MinIO
fileService.getUploadStreamDescriptor({..., usePrivateBucket: false})
// S3 & Spaces
fileService.getUploadStreamDescriptor({..., acl: "public-read"})
// after
fileService.getUploadStreamDescriptor({..., isPrivate: true}) // private bucket (default)
fileService.getUploadStreamDescriptor({..., isPrivate: false}) // public bucket
Import/Export
The following method signatures in the Price List and Product import batch job strategies have been updated:
Mainly, both the downloadImportOpsFile
and deleteOpsFiles
methods now requires the batch job instance as the first parameter. Previously, they required only the ID of the batch job.