-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatic transformation of record classes (#253)
Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
cf29d8f
commit e07b90e
Showing
23 changed files
with
266 additions
and
295 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
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
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
25 changes: 15 additions & 10 deletions
25
src/modules/basic-messages/repository/BasicMessageRecord.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 |
---|---|---|
@@ -1,26 +1,31 @@ | ||
import { v4 as uuid } from 'uuid' | ||
import { BaseRecord, RecordType, Tags } from '../../../storage/BaseRecord' | ||
import { uuid } from '../../../utils/uuid' | ||
import { BaseRecord, Tags } from '../../../storage/BaseRecord' | ||
|
||
export interface BasicMessageStorageProps { | ||
id?: string | ||
createdAt?: number | ||
createdAt?: Date | ||
tags: Tags | ||
|
||
content: string | ||
sentTime: string | ||
} | ||
|
||
export class BasicMessageRecord extends BaseRecord implements BasicMessageStorageProps { | ||
public content: string | ||
public sentTime: string | ||
public content!: string | ||
public sentTime!: string | ||
|
||
public static readonly type: RecordType = RecordType.BasicMessageRecord | ||
public static readonly type = 'BasicMessageRecord' | ||
public readonly type = BasicMessageRecord.type | ||
|
||
public constructor(props: BasicMessageStorageProps) { | ||
super(props.id ?? uuid(), props.createdAt ?? Date.now()) | ||
this.content = props.content | ||
this.sentTime = props.sentTime | ||
this.tags = props.tags | ||
super() | ||
|
||
if (props) { | ||
this.id = props.id ?? uuid() | ||
this.createdAt = props.createdAt ?? new Date() | ||
this.content = props.content | ||
this.sentTime = props.sentTime | ||
this.tags = props.tags | ||
} | ||
} | ||
} |
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,4 +1,4 @@ | ||
export enum ConnectionRole { | ||
Inviter = 'INVITER', | ||
Invitee = 'INVITEE', | ||
Inviter = 'inviter', | ||
Invitee = 'invitee', | ||
} |
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
Oops, something went wrong.