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): Implemented AssetEvent with new entity event base class (v…
- Loading branch information
Kevin
committed
Nov 15, 2021
1 parent
469c6ac
commit b16e9f6
Showing
2 changed files
with
24 additions
and
8 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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
import { RequestContext } from '../../api/common/request-context'; | ||
import { CreateAssetInput, DeleteAssetInput, UpdateAssetInput } from '@vendure/common/lib/generated-types'; | ||
|
||
import { RequestContext } from '../../api'; | ||
import { Asset } from '../../entity'; | ||
import { VendureEvent } from '../vendure-event'; | ||
import { VendureEntityEvent } from '../vendure-entity-event'; | ||
|
||
type AssetInputTypes = CreateAssetInput | UpdateAssetInput | DeleteAssetInput; | ||
|
||
/** | ||
* @description | ||
* This event is fired whenever aa {@link Asset} is added, updated | ||
* or deleted. | ||
* or deleted. The `input` property is only defined for `'created'` & `'updated'` event types. | ||
* | ||
* @docsCategory events | ||
* @docsPage Event Types | ||
* @since 1.4 | ||
*/ | ||
export class AssetEvent extends VendureEvent { | ||
export class AssetEvent extends VendureEntityEvent<Asset, AssetInputTypes> { | ||
constructor( | ||
public ctx: RequestContext, | ||
public asset: Asset, | ||
public entity: Asset, | ||
public type: 'created' | 'updated' | 'deleted', | ||
public input?: AssetInputTypes, | ||
) { | ||
super(); | ||
super(entity, type, ctx, input); | ||
} | ||
|
||
/** | ||
* Return an asset field to become compatible with the | ||
* deprecated old version of AssetEvent | ||
* @deprecated Use `entity` instead | ||
* @since 1.4 | ||
*/ | ||
get asset(): Asset { | ||
return this.entity; | ||
} | ||
} |
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