-
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.
- Loading branch information
1 parent
22baa50
commit 26953b4
Showing
11 changed files
with
402 additions
and
50 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
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,11 +1,13 @@ | ||
import { Anemic } from '@toxictoast/azkaban-base-domain'; | ||
import { Nullable } from '@toxictoast/azkaban-base-types'; | ||
|
||
export interface ViewerAnemic extends Anemic { | ||
readonly user_id: string; | ||
readonly login: string; | ||
readonly display_name: string; | ||
readonly type: string; | ||
readonly profile_image_url: string; | ||
readonly offline_image_url: string; | ||
readonly view_count: number; | ||
readonly lastseen_at: Nullable<Date>; | ||
readonly joins: number; | ||
readonly parts: number; | ||
readonly messages: number; | ||
readonly timeouts: number; | ||
readonly bans: number; | ||
readonly minutes_watched: number; | ||
} |
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,9 +1,3 @@ | ||
export interface ViewerData { | ||
readonly user_id: string; | ||
readonly login: string; | ||
readonly display_name: string; | ||
readonly type: string; | ||
readonly profile_image_url: string; | ||
readonly offline_image_url: string; | ||
readonly view_count: number; | ||
} |
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 +1 @@ | ||
export {}; | ||
export * from './viewer.factory'; |
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,96 @@ | ||
import { Factory } from '@toxictoast/azkaban-base-domain'; | ||
import { ViewerAnemic } from '../anemics'; | ||
import { ViewerAggregate } from '../aggregates'; | ||
import { ViewerData } from '../data'; | ||
import { ViewerId } from '../valueObjects'; | ||
|
||
export class ViewerFactory | ||
implements Factory<ViewerAnemic, ViewerAggregate, ViewerData> | ||
{ | ||
reconstitute(data: ViewerAnemic): ViewerAggregate { | ||
const { | ||
id, | ||
display_name, | ||
lastseen_at, | ||
joins, | ||
parts, | ||
messages, | ||
timeouts, | ||
bans, | ||
minutes_watched, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
} = data; | ||
|
||
return new ViewerAggregate( | ||
id, | ||
display_name, | ||
joins, | ||
parts, | ||
messages, | ||
timeouts, | ||
bans, | ||
minutes_watched, | ||
lastseen_at, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
); | ||
} | ||
|
||
constitute(data: ViewerAggregate): ViewerAnemic { | ||
const { | ||
id, | ||
display_name, | ||
lastseen_at, | ||
joins, | ||
parts, | ||
messages, | ||
timeouts, | ||
bans, | ||
minutes_watched, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
isUpdated, | ||
isDeleted, | ||
} = data.toAnemic(); | ||
|
||
return { | ||
id, | ||
display_name, | ||
lastseen_at, | ||
joins, | ||
parts, | ||
messages, | ||
timeouts, | ||
bans, | ||
minutes_watched, | ||
created_at, | ||
updated_at, | ||
deleted_at, | ||
isUpdated, | ||
isDeleted, | ||
}; | ||
} | ||
|
||
createDomain(data: ViewerData): ViewerAggregate { | ||
const { display_name } = data; | ||
const viewerId = new ViewerId(); | ||
return new ViewerAggregate( | ||
viewerId.value, | ||
display_name, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
0, | ||
new Date(), | ||
new Date(), | ||
null, | ||
null, | ||
); | ||
} | ||
} |
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 +1 @@ | ||
export {}; | ||
export * from './viewer.repository'; |
12 changes: 12 additions & 0 deletions
12
libs/twitch-domain/src/lib/repositories/viewer.repository.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,12 @@ | ||
import { ViewerAnemic } from '../anemics'; | ||
import { Repository } from '@toxictoast/azkaban-base-domain'; | ||
import { Chainable } from '@toxictoast/azkaban-base-types'; | ||
|
||
interface ViewerAdditions { | ||
findByDisplayName(display_name: string): Promise<ViewerAnemic>; | ||
} | ||
|
||
export type ViewerRepository = Chainable< | ||
ViewerAdditions, | ||
Repository<ViewerAnemic> | ||
>; |
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 +1 @@ | ||
export {}; | ||
export * from './viewer.service'; |
Oops, something went wrong.