diff --git a/docs/docs/reference/typescript-api/events/event-types.md b/docs/docs/reference/typescript-api/events/event-types.md index b10f73a8e5..cc00202a6b 100644 --- a/docs/docs/reference/typescript-api/events/event-types.md +++ b/docs/docs/reference/typescript-api/events/event-types.md @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; -This event is fired when a new user registers an account, either as a stand-alone signup or after +This event is fired when a new user registers an account, either as a stand-alone signup or after placing an order. ```ts title="Signature" @@ -41,7 +41,7 @@ class AccountRegistrationEvent extends VendureEvent { -This event is fired when a users email address successfully gets verified after +This event is fired when a users email address successfully gets verified after the `verifyCustomerAccount` mutation was executed. ```ts title="Signature" @@ -96,7 +96,7 @@ class AdministratorEvent extends VendureEntityEvent -This event is fired whenever an Asset is assigned or removed +This event is fired whenever an Asset is assigned or removed From a channel. ```ts title="Signature" @@ -157,8 +157,8 @@ class AssetEvent extends VendureEntityEvent { -This event is fired when an attempt is made to log in via the shop or admin API `login` mutation. -The `strategy` represents the name of the AuthenticationStrategy used in the login attempt. +This event is fired when an attempt is made to log in via the shop or admin API `login` mutation. +The `strategy` represents the name of the AuthenticationStrategy used in the login attempt. If the "native" strategy is used, the additional `identifier` property will be available. ```ts title="Signature" @@ -186,7 +186,7 @@ class AttemptedLoginEvent extends VendureEvent { -This event is fired whenever an ChannelAware entity is assigned or removed +This event is fired whenever an ChannelAware entity is assigned or removed from a channel. The entity property contains the value before updating the channels. ```ts title="Signature" @@ -268,10 +268,10 @@ class CollectionEvent extends VendureEntityEvent -This event is fired whenever a Collection is modified in some way. The `productVariantIds` -argument is an array of ids of all ProductVariants which: - -1. were part of this collection prior to modification and are no longer +This event is fired whenever a Collection is modified in some way. The `productVariantIds` +argument is an array of ids of all ProductVariants which: + +1. were part of this collection prior to modification and are no longer 2. are now part of this collection after modification but were not before ```ts title="Signature" @@ -326,7 +326,7 @@ class CountryEvent extends VendureEntityEvent { -This event is fired whenever an coupon code of an active Promotion +This event is fired whenever an coupon code of an active Promotion is assigned or removed to an Order. ```ts title="Signature" @@ -354,7 +354,7 @@ class CouponCodeEvent extends VendureEvent { -This event is fired whenever a Address is added, updated +This event is fired whenever a Address is added, updated or deleted. ```ts title="Signature" @@ -388,7 +388,7 @@ class CustomerAddressEvent extends VendureEntityEvent -This event is fired whenever a Customer is added, updated +This event is fired whenever a Customer is added, updated or deleted. ```ts title="Signature" @@ -422,7 +422,7 @@ class CustomerEvent extends VendureEntityEvent { -This event is fired whenever one or more Customer is assigned to or removed from a +This event is fired whenever one or more Customer is assigned to or removed from a CustomerGroup. ```ts title="Signature" @@ -585,7 +585,7 @@ class FulfillmentStateTransitionEvent extends VendureEvent { -This event is fired whenever a {@link GlobalSettings} is added. The type is always `updated`, because it's +This event is fired whenever a {@link GlobalSettings} is added. The type is always `updated`, because it's only created once and never deleted. ```ts title="Signature" @@ -646,7 +646,7 @@ class HistoryEntryEvent extends VendureEntityEvent { -This event is fired when a registered user successfully changes the identifier (ie email address) +This event is fired when a registered user successfully changes the identifier (ie email address) associated with their account. ```ts title="Signature" @@ -674,7 +674,7 @@ class IdentifierChangeEvent extends VendureEvent { -This event is fired when a registered user requests to update the identifier (ie email address) +This event is fired when a registered user requests to update the identifier (ie email address) associated with the account. ```ts title="Signature" @@ -783,7 +783,7 @@ class LogoutEvent extends VendureEvent { -This event is fired whenever an Order is added, updated +This event is fired whenever an Order is added, updated or deleted. ```ts title="Signature" @@ -811,12 +811,11 @@ class OrderEvent extends VendureEvent { -This event is fired whenever an OrderLine is added, updated -or deleted. +This event is fired whenever an OrderLine is added, updated, deleted or cancelled. ```ts title="Signature" class OrderLineEvent extends VendureEvent { - constructor(ctx: RequestContext, order: Order, orderLine: OrderLine, type: 'created' | 'updated' | 'deleted') + constructor(ctx: RequestContext, order: Order, orderLine: OrderLine, type: 'created' | 'updated' | 'deleted' | 'cancelled') } ``` * Extends: VendureEvent @@ -839,10 +838,10 @@ class OrderLineEvent extends VendureEvent { -This event is fired whenever an Order is set as "placed", which by default is -when it transitions from 'ArrangingPayment' to either 'PaymentAuthorized' or 'PaymentSettled'. - -Note that the exact point that it is set as "placed" can be configured according to the +This event is fired whenever an Order is set as "placed", which by default is +when it transitions from 'ArrangingPayment' to either 'PaymentAuthorized' or 'PaymentSettled'. + +Note that the exact point that it is set as "placed" can be configured according to the OrderPlacedStrategy. ```ts title="Signature" @@ -951,7 +950,7 @@ class PasswordResetVerifiedEvent extends VendureEvent { -This event is fired whenever a PaymentMethod is added, updated +This event is fired whenever a PaymentMethod is added, updated or deleted. ```ts title="Signature" @@ -979,7 +978,7 @@ class PaymentMethodEvent extends VendureEntityEvent -This event is fired whenever a Payment transitions from one PaymentState to another, e.g. +This event is fired whenever a Payment transitions from one PaymentState to another, e.g. a Payment is authorized by the payment provider. ```ts title="Signature" @@ -1007,7 +1006,7 @@ class PaymentStateTransitionEvent extends VendureEvent { -This event is fired whenever a Product is added, updated +This event is fired whenever a Product is added, updated or deleted. ```ts title="Signature" @@ -1035,7 +1034,7 @@ class ProductChannelEvent extends VendureEvent { -This event is fired whenever a Product is added, updated +This event is fired whenever a Product is added, updated or deleted. ```ts title="Signature" @@ -1126,14 +1125,17 @@ class ProductOptionGroupChangeEvent extends VendureEvent { This event is fired whenever a ProductOptionGroup is added or updated. ```ts title="Signature" -class ProductOptionGroupEvent extends VendureEntityEvent< - ProductOptionGroup, - ProductOptionGroupInputTypes +class ProductOptionGroupEvent extends VendureEntityEvent< + ProductOptionGroup, + ProductOptionGroupInputTypes > { constructor(ctx: RequestContext, entity: ProductOptionGroup, type: 'created' | 'updated' | 'deleted', input?: ProductOptionGroupInputTypes) } ``` -* Extends: VendureEntityEvent< ProductOptionGroup, ProductOptionGroupInputTypes > +* Extends: VendureEntityEvent< + ProductOptionGroup, + ProductOptionGroupInputTypes + > @@ -1180,7 +1182,7 @@ class ProductVariantChannelEvent extends VendureEvent { -This event is fired whenever a ProductVariant is added, updated +This event is fired whenever a ProductVariant is added, updated or deleted. ```ts title="Signature" @@ -1217,14 +1219,17 @@ class ProductVariantEvent extends VendureEntityEventProductVariantPrice is added, updated or deleted. ```ts title="Signature" -class ProductVariantPriceEvent extends VendureEntityEvent< - ProductVariantPrice[], - ProductVariantInputTypes +class ProductVariantPriceEvent extends VendureEntityEvent< + ProductVariantPrice[], + ProductVariantInputTypes > { constructor(ctx: RequestContext, entity: ProductVariantPrice[], type: 'created' | 'updated' | 'deleted', input?: ProductVariantInputTypes) } ``` -* Extends: VendureEntityEvent< ProductVariantPrice[], ProductVariantInputTypes > +* Extends: VendureEntityEvent< + ProductVariantPrice[], + ProductVariantInputTypes + > @@ -1244,7 +1249,7 @@ class ProductVariantPriceEvent extends VendureEntityEvent< -This event is fired whenever a Promotion is added, updated +This event is fired whenever a Promotion is added, updated or deleted. ```ts title="Signature" @@ -1326,7 +1331,7 @@ class RefundStateTransitionEvent extends VendureEvent { -This event is fired whenever one Role is assigned or removed from a user. +This event is fired whenever one Role is assigned or removed from a user. The property `roleIds` only contains the removed or assigned role ids. ```ts title="Signature" @@ -1435,7 +1440,7 @@ class SellerEvent extends VendureEntityEvent { -This event is fired whenever a ShippingMethod is added, updated +This event is fired whenever a ShippingMethod is added, updated or deleted. ```ts title="Signature" @@ -1463,7 +1468,7 @@ class ShippingMethodEvent extends VendureEntityEvent -This event is fired whenever a StockMovement entity is created, which occurs when the saleable +This event is fired whenever a StockMovement entity is created, which occurs when the saleable stock level of a ProductVariant is altered due to things like sales, manual adjustments, and cancellations. ```ts title="Signature" @@ -1497,7 +1502,7 @@ class StockMovementEvent extends VendureEvent { -This event is fired whenever a TaxCategory is added, updated +This event is fired whenever a TaxCategory is added, updated or deleted. ```ts title="Signature" @@ -1525,7 +1530,7 @@ class TaxCategoryEvent extends VendureEntityEvent -This event is fired whenever a TaxRate is added, updated +This event is fired whenever a TaxRate is added, updated or deleted. ```ts title="Signature" @@ -1580,7 +1585,7 @@ class TaxRateModificationEvent extends VendureEvent { -This event is fired whenever a Zone is added, updated +This event is fired whenever a Zone is added, updated or deleted. ```ts title="Signature" @@ -1608,7 +1613,7 @@ class ZoneEvent extends VendureEntityEvent { -This event is fired whenever a Zone gets Country members assigned or removed +This event is fired whenever a Zone gets Country members assigned or removed The `entity` property contains the zone with the already updated member field. ```ts title="Signature" diff --git a/packages/core/src/event-bus/events/order-line-event.ts b/packages/core/src/event-bus/events/order-line-event.ts index 5d37006d44..73aea643f1 100644 --- a/packages/core/src/event-bus/events/order-line-event.ts +++ b/packages/core/src/event-bus/events/order-line-event.ts @@ -15,7 +15,7 @@ export class OrderLineEvent extends VendureEvent { public ctx: RequestContext, public order: Order, public orderLine: OrderLine, - public type: 'created' | 'updated' | 'deleted', + public type: 'created' | 'updated' | 'deleted' | 'cancelled', ) { super(); } diff --git a/packages/core/src/service/helpers/order-modifier/order-modifier.ts b/packages/core/src/service/helpers/order-modifier/order-modifier.ts index 04deae0790..fdd47b6595 100644 --- a/packages/core/src/service/helpers/order-modifier/order-modifier.ts +++ b/packages/core/src/service/helpers/order-modifier/order-modifier.ts @@ -341,6 +341,8 @@ export class OrderModifier { await this.connection.getRepository(ctx, OrderLine).update(line.orderLineId, { quantity: orderLine.quantity - line.quantity, }); + + await this.eventBus.publish(new OrderLineEvent(ctx, order, orderLine, 'cancelled')); } }