fix(medusa): Bulk create variant + pass transaction to the inventory service context methods (#3835)

* fix(medusa): Bulk create variant and pass transaction where needed

* Create fair-penguins-stare.md

* fix unit tests

* event

* transaction orchestration

* revert options

* Prevent isolated module to use the given transaction if any in the exposed service

* Use enum

* remove changeset to re do it

* Create thick-ants-tickle.md

* update event bus local

* remove changeset to re do it

* Create thick-kings-wonder.md

* remove changeset to re do it

* Create slimy-bees-eat.md

* Update packages/utils/src/event-bus/index.ts

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2023-04-19 09:27:48 +02:00
1 parent 366b12fcea
commit af710f1b48
17 files changed
+504 -275

No files matched your search

@@ -4,6 +4,7 @@ import {
FilterableStockLocationProps,
FindConfig,
IEventBusService,
MODULE_RESOURCE_TYPE,
SharedContext,
StockLocationAddressInput,
UpdateStockLocationInput,
@@ -41,7 +42,7 @@ export default class StockLocationService {
constructor(
{ eventBusService, manager }: InjectedDependencies,
options?: unknown,
moduleDeclaration?: InternalModuleDeclaration
protected readonly moduleDeclaration?: InternalModuleDeclaration
) {
this.manager_ = manager
this.eventBusService_ = eventBusService
@@ -53,7 +54,10 @@ export default class StockLocationService {
* @param config - Additional configuration for the query.
* @return A list of stock locations.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
async list(
selector: FilterableStockLocationProps = {},
config: FindConfig<StockLocation> = { relations: [], skip: 0, take: 10 },
@@ -72,7 +76,10 @@ export default class StockLocationService {
* @param config - Additional configuration for the query.
* @return A list of stock locations and the count of matching stock locations.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
async listAndCount(
selector: FilterableStockLocationProps = {},
config: FindConfig<StockLocation> = { relations: [], skip: 0, take: 10 },
@@ -92,7 +99,10 @@ export default class StockLocationService {
* @return The stock location.
* @throws If the stock location ID is not definedor the stock location with the given ID was not found.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
async retrieve(
stockLocationId: string,
config: FindConfig<StockLocation> = {},
@@ -126,7 +136,10 @@ export default class StockLocationService {
* @param data - The input data for creating a Stock Location.
* @returns The created stock location.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
async create(
data: CreateStockLocationInput,
@MedusaContext() context: SharedContext = {}
@@ -170,7 +183,10 @@ export default class StockLocationService {
* @param updateData - The update data for the stock location.
* @returns The updated stock location.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
async update(
stockLocationId: string,
updateData: UpdateStockLocationInput,
@@ -216,7 +232,10 @@ export default class StockLocationService {
* @param address - The update data for the address.
* @returns The updated stock location address.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
protected async updateAddress(
addressId: string,
address: StockLocationAddressInput,
@@ -257,7 +276,10 @@ export default class StockLocationService {
* @param id - The ID of the stock location to delete.
* @returns An empty promise.
*/
@InjectEntityManager()
@InjectEntityManager(
(target) =>
target.moduleDeclaration?.resources === MODULE_RESOURCE_TYPE.ISOLATED
)
async delete(
id: string,
@MedusaContext() context: SharedContext = {}