forked from vendure-ecommerce/vendure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Added multiple events (vendure-ecommerce#1219)
- Loading branch information
Kevin
committed
Nov 15, 2021
1 parent
ce096c9
commit 573a32f
Showing
53 changed files
with
902 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CreateAdministratorInput, UpdateAdministratorInput } from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { Administrator } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type AdministratorInputTypes = CreateAdministratorInput | UpdateAdministratorInput | ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link Administrator} is added, updated or deleted. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class AdministratorEvent extends VendureEntityEvent<Administrator, AdministratorInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: Administrator, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: AdministratorInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/core/src/event-bus/events/change-channel-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ID, Type } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { ChannelAware } from '../../common'; | ||
import { VendureEntity } from '../../entity'; | ||
import { VendureEvent } from '../vendure-event'; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever an {@link ChannelAware} entity is assigned or removed | ||
* from a channel. The entity property contains the value before updating the channels. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class ChangeChannelEvent<T extends ChannelAware & VendureEntity> extends VendureEvent { | ||
constructor( | ||
public ctx: RequestContext, | ||
public entity: T, | ||
public channelIds: ID[], | ||
public type: 'assigned' | 'removed', | ||
public entityType?: Type<T>, | ||
) { | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CreateChannelInput, UpdateChannelInput } from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { Channel } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type ChannelInputTypes = CreateChannelInput | UpdateChannelInput | ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link Channel} is added, updated or deleted. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class ChannelEvent extends VendureEntityEvent<Channel, ChannelInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: Channel, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: ChannelInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CreateCollectionInput, UpdateCollectionInput } from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { Collection } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type CollectionInputTypes = CreateCollectionInput | UpdateCollectionInput | ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link Collection} is added, updated or deleted. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class CollectionEvent extends VendureEntityEvent<Collection, CollectionInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: Collection, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: CollectionInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CreateCountryInput, UpdateCountryInput } from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { Country } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type CountryInputTypes = CreateCountryInput | UpdateCountryInput | ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link Country} is added, updated or deleted. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class CountryEvent extends VendureEntityEvent<Country, CountryInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: Country, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: CountryInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api/common/request-context'; | ||
import { VendureEvent } from '../vendure-event'; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever an {@link Asset} is assigned or removed | ||
* From a channel. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class CouponCodeEvent extends VendureEvent { | ||
constructor( | ||
public ctx: RequestContext, | ||
public couponCode: string, | ||
public orderId: ID, | ||
public type: 'assigned' | 'removed', | ||
) { | ||
super(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/core/src/event-bus/events/customer-group-entity-event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { CreateCustomerGroupInput, UpdateCustomerGroupInput } from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { CustomerGroup } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type CustomerGroupInputTypes = CreateCustomerGroupInput | UpdateCustomerGroupInput | ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link CustomerGroup} is added, updated or deleted. | ||
* This Entity shall replace the {@link CustomerGroupEvent} later! | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class CustomerGroupEntityEvent extends VendureEntityEvent<CustomerGroup, CustomerGroupInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: CustomerGroup, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: CustomerGroupInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CreateFacetInput, UpdateFacetInput } from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { Facet } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type FacetInputTypes = CreateFacetInput | UpdateFacetInput | ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link Facet} is added, updated or deleted. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class FacetEvent extends VendureEntityEvent<Facet, FacetInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: Facet, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: FacetInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
CreateFacetValueInput, | ||
CreateFacetValueWithFacetInput, | ||
UpdateFacetValueInput, | ||
} from '@vendure/common/lib/generated-types'; | ||
import { ID } from '@vendure/common/lib/shared-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { FacetValue } from '../../entity'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type FacetValueInputTypes = | ||
| CreateFacetValueInput | ||
| CreateFacetValueWithFacetInput | ||
| UpdateFacetValueInput | ||
| ID; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever a {@link FacetValue} is added, updated or deleted. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class FacetValueEvent extends VendureEntityEvent<FacetValue, FacetValueInputTypes> { | ||
constructor( | ||
ctx: RequestContext, | ||
entity: FacetValue, | ||
type: 'created' | 'updated' | 'deleted', | ||
input: FacetValueInputTypes, | ||
) { | ||
super(entity, type, ctx, input); | ||
} | ||
} |
Oops, something went wrong.