diff --git a/classes/RocketChatUser.html b/classes/RocketChatUser.html new file mode 100644 index 00000000000..d33726a6166 --- /dev/null +++ b/classes/RocketChatUser.html @@ -0,0 +1,504 @@ + + +
+ + ++
+ apps/server/src/modules/rocketchat-user/domain/rocket-chat-user.do.ts
+
+
+ DomainObject
+
+ Properties+ |
+
+
|
+
+ Methods+ |
+
+
|
+
+ Accessors+ |
+
+ + | +
+ + + Protected + props + + + | +
+ Type : T
+
+ |
+
+ Inherited from
+ DomainObject
+ |
+
+ Defined in
+ DomainObject:8
+ |
+
+ + + Public + getProps + + + | +
+
+ getProps()
+ |
+
+ Inherited from
+ DomainObject
+ |
+
+ Defined in
+ DomainObject:18
+ |
+
+
+
+ Returns :
+ T
+
+ |
+
+ + userId + | +
+ getuserId()
+ |
+
+ + | +
+ + username + | +
+ getusername()
+ |
+
+ + | +
+ + rcId + | +
+ getrcId()
+ |
+
+ + | +
+ + authToken + | +
+ getauthToken()
+ |
+
+ + | +
+ + createdAt + | +
+ getcreatedAt()
+ |
+
+ + | +
+ + updatedAt + | +
+ getupdatedAt()
+ |
+
+ + | +
import { EntityId } from '@shared/domain/types';
+import { AuthorizableObject, DomainObject } from '@shared/domain/domain-object';
+
+export interface RocketChatUserProps extends AuthorizableObject {
+ userId: EntityId;
+ username: string;
+ rcId: string;
+ authToken?: string;
+ createdAt?: Date;
+ updatedAt?: Date;
+}
+
+export class RocketChatUser extends DomainObject<RocketChatUserProps> {
+ get userId(): EntityId {
+ return this.props.userId;
+ }
+
+ get username(): string {
+ return this.props.username;
+ }
+
+ get rcId(): string {
+ return this.props.rcId;
+ }
+
+ get authToken(): string | undefined {
+ return this.props.authToken;
+ }
+
+ get createdAt(): Date | undefined {
+ return this.props.createdAt;
+ }
+
+ get updatedAt(): Date | undefined {
+ return this.props.updatedAt;
+ }
+}
+
+ +
+ apps/server/src/modules/rocketchat-user/entity/testing/rocket-chat-user.entity.factory.ts
+
+
+ BaseFactory
+
+ Properties+ |
+
+
|
+
+ Methods+ |
+
+
|
+
+ + + Protected + Readonly + propsFactory + + + | +
+ Type : Factory<U | I | C>
+
+ |
+
+ Inherited from
+ BaseFactory
+ |
+
+ Defined in
+ BaseFactory:15
+ |
+
+ + + afterBuild + + + | +||||||||
+afterBuild(afterBuildFn: HookFn)
+ |
+ ||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||
+ Defined in
+ BaseFactory:98
+ |
+ ||||||||
+ Extend the factory by adding a function to be called after an object is built. +
+ Parameters :
+
+
+
|
+
+ + + associations + + + | +||||||
+associations(associations: Partial)
+ |
+ ||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||
+ Defined in
+ BaseFactory:110
+ |
+ ||||||
+ Extend the factory by adding default associations to be passed to the factory when "build" is called +
+ Parameters :
+
+
+
|
+
+ + + build + + + | +||||||||||||
+build(params?: DeepPartial, options: BuildOptions<U | I>)
+ |
+ ||||||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||||||
+ Defined in
+ BaseFactory:47
+ |
+ ||||||||||||
+ Build an entity using your factory +
+ Parameters :
+
+
+
+ Returns :
+ T
+
+
+
+ an entity + + |
+
+ + + buildList + + + | +||||||||||||||||
+buildList(number: number, params?: DeepPartial, options: BuildOptions<U | I>)
+ |
+ ||||||||||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||||||||||
+ Defined in
+ BaseFactory:75
+ |
+ ||||||||||||||||
+ Build a list of entities using your factory +
+ Parameters :
+
+
+
+ Returns :
+ T[]
+
+
+
+ a list of entities + + |
+
+ + + buildListWithId + + + | +||||||||||||||||
+buildListWithId(number: number, params?: DeepPartial, options: BuildOptions<U | I>)
+ |
+ ||||||||||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||||||||||
+ Defined in
+ BaseFactory:84
+ |
+ ||||||||||||||||
+
+
+ Parameters :
+
+
+
+ Returns :
+ T[]
+
+
+
+
+ |
+
+ + + buildWithId + + + | +||||||||||||||||
+buildWithId(params?: DeepPartial, id?: string, options: BuildOptions<U | I>)
+ |
+ ||||||||||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||||||||||
+ Defined in
+ BaseFactory:60
+ |
+ ||||||||||||||||
+ Build an entity using your factory and generate a id for it. +
+ Parameters :
+
+
+
+ Returns :
+ T
+
+
+
+ an entity + + |
+
+ + + Protected + clone + + + | +|||||||||
+
+ clone(this: F, propsFactory: Factory)
+ |
+ |||||||||
+ Inherited from
+ BaseFactory
+ |
+ |||||||||
+ Defined in
+ BaseFactory:148
+ |
+ |||||||||
+ Type parameters :
+
|
+ |||||||||
+
+
+ Parameters :
+
+
+
+ Returns :
+ F
+
+
+
+
+ |
+
+ + + Static + define + + + | +||||||||||||||||
+
+ define(this, EntityClass: literal type, generator: GeneratorFn)
+ |
+ ||||||||||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||||||||||
+ Defined in
+ BaseFactory:32
+ |
+ ||||||||||||||||
+ Type parameters :
+
|
+ ||||||||||||||||
+ Define a factory +
+ Parameters :
+
+
+
+ Returns :
+ F
+
+
+
+
+ |
+
+ + + params + + + | +||||||
+params(params: DeepPartial)
+ |
+ ||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||
+ Defined in
+ BaseFactory:122
+ |
+ ||||||
+ Extend the factory by adding default parameters to be passed to the factory when "build" is called +
+ Parameters :
+
+
+
|
+
+ + + rewindSequence + + + | +
+rewindSequence()
+ |
+
+ Inherited from
+ BaseFactory
+ |
+
+ Defined in
+ BaseFactory:144
+ |
+
+ Set sequence back to its default value +
+ Returns :
+ void
+
+ |
+
+ + + Protected + sequence + + + | +
+
+ sequence()
+ |
+
+ Inherited from
+ BaseFactory
+ |
+
+ Defined in
+ BaseFactory:160
+ |
+
+ Get the next sequence value +
+ Returns :
+ number
+
+
+
+ the next sequence value + + |
+
+ + + transient + + + | +||||||||
+transient(transient: Partial)
+ |
+ ||||||||
+ Inherited from
+ BaseFactory
+ |
+ ||||||||
+ Defined in
+ BaseFactory:134
+ |
+ ||||||||
+ Extend the factory by adding default transient parameters to be passed to the factory when "build" is called +
+ Parameters :
+
+
+
|
+
import { ObjectId } from '@mikro-orm/mongodb';
+import { BaseFactory } from '@shared/testing';
+import { RocketChatUserEntity, RocketChatUserEntityProps } from '../rocket-chat-user.entity';
+
+class RocketChatUserFactory extends BaseFactory<RocketChatUserEntity, RocketChatUserEntityProps> {}
+
+export const rocketChatUserEntityFactory = RocketChatUserFactory.define<
+ RocketChatUserEntity,
+ RocketChatUserEntityProps
+>(RocketChatUserEntity, ({ sequence }) => {
+ return {
+ id: new ObjectId().toHexString(),
+ userId: new ObjectId(),
+ username: `username-${sequence}`,
+ rcId: `rcId-${sequence}`,
+ authToken: `aythToken-${sequence}`,
+ createdAt: new Date(),
+ updatedAt: new Date(),
+ };
+});
+
+ +
+ apps/server/src/modules/rocketchat-user/repo/mapper/rocket-chat-user.mapper.ts
+
+ Methods+ |
+
+
|
+
+ + + Static + mapToDO + + + | +||||||
+
+ mapToDO(entity: RocketChatUserEntity)
+ |
+ ||||||
+ + | +||||||
+
+
+ Parameters :
+
+
+
+ Returns :
+ RocketChatUser
+
+
+
+
+ |
+
+ + + Static + mapToEntity + + + | +||||||
+
+ mapToEntity(domainObject: RocketChatUser)
+ |
+ ||||||
+ + | +||||||
+
+
+ Parameters :
+
+
+
+ Returns :
+ RocketChatUserEntity
+
+
+
+
+ |
+
import { ObjectId } from '@mikro-orm/mongodb';
+import { RocketChatUserEntity } from '../../entity';
+import { RocketChatUser } from '../../domain/rocket-chat-user.do';
+
+export class RocketChatUserMapper {
+ static mapToDO(entity: RocketChatUserEntity): RocketChatUser {
+ return new RocketChatUser({
+ id: entity.id,
+ userId: entity.userId.toHexString(),
+ username: entity.username,
+ rcId: entity.rcId,
+ authToken: entity.authToken,
+ createdAt: entity.createdAt,
+ updatedAt: entity.updatedAt,
+ });
+ }
+
+ static mapToEntity(domainObject: RocketChatUser): RocketChatUserEntity {
+ return new RocketChatUserEntity({
+ id: domainObject.id,
+ userId: new ObjectId(domainObject.userId),
+ username: domainObject.username,
+ rcId: domainObject.rcId,
+ authToken: domainObject.authToken,
+ createdAt: domainObject.createdAt,
+ updatedAt: domainObject.updatedAt,
+ });
+ }
+}
+
+ +
+ apps/server/src/modules/rocketchat-user/entity/rocket-chat-user.entity.ts
+
+ Properties+ |
+
+ + | +
+ + + + Optional + authToken + + + | +
+ Type : string
+
+ |
+
+ Decorators :
+ +
+ @Property({nullable: true})
+ |
+
+ + | +
+ + + + + rcId + + + | +
+ Type : string
+
+ |
+
+ Decorators :
+ +
+ @Property()
+ |
+
+ + | +
+ + + + + userId + + + | +
+ Type : ObjectId
+
+ |
+
+ Decorators :
+ +
+ @Property()
+ |
+
+ + | +
+ + + + + username + + + | +
+ Type : string
+
+ |
+
+ Decorators :
+ +
+ @Property()
+ |
+
+ + | +
import { Entity, Index, Property, Unique } from '@mikro-orm/core';
+import { ObjectId } from '@mikro-orm/mongodb';
+import { BaseEntityWithTimestamps } from '@shared/domain/entity/base.entity';
+import { EntityId } from '@shared/domain';
+
+export interface RocketChatUserEntityProps {
+ id?: EntityId;
+ userId: ObjectId;
+ username: string;
+ rcId: string;
+ authToken?: string;
+ createdAt?: Date;
+ updatedAt?: Date;
+}
+
+@Entity({ tableName: 'rocketchatuser' })
+export class RocketChatUserEntity extends BaseEntityWithTimestamps {
+ @Property()
+ @Unique()
+ username: string;
+
+ @Property()
+ @Unique()
+ userId: ObjectId;
+
+ @Property()
+ @Index()
+ rcId: string;
+
+ @Property({ nullable: true })
+ authToken?: string;
+
+ constructor(props: RocketChatUserEntityProps) {
+ super();
+
+ if (props.id !== undefined) {
+ this.id = props.id;
+ }
+
+ this.userId = props.userId;
+ this.username = props.username;
+ this.rcId = props.rcId;
+
+ if (props.authToken !== undefined) {
+ this.authToken = props.authToken;
+ }
+
+ if (props.createdAt !== undefined) {
+ this.createdAt = props.createdAt;
+ }
+
+ if (props.updatedAt !== undefined) {
+ this.updatedAt = props.updatedAt;
+ }
+ }
+}
+
+