Skip to content

High performance self-hosted photo and video management solution.

986 B
Raw Blame
import { Selectable } from 'kysely';
import { SessionTable } from 'src/schema/tables/session.table.js';
import { SessionLike } from 'test/factories/types.js';
import { newDate, newUuid, newUuidV7 } from 'test/small.factory.js';

export class SessionFactory {
  private constructor(private value: Selectable<SessionTable>) {}

  static create(dto: SessionLike = {}) {
    return SessionFactory.from(dto).build();
  }

  static from(dto: SessionLike = {}) {
    return new SessionFactory({
      appVersion: null,
      createdAt: newDate(),
      deviceOS: 'android',
      deviceType: 'mobile',
      expiresAt: null,
      id: newUuid(),
      isPendingSyncReset: false,
      parentId: null,
      pinExpiresAt: null,
      token: Buffer.from('abc123'),
      updateId: newUuidV7(),
      updatedAt: newDate(),
      userId: newUuid(),
      oauthSid: newUuid(),
      oauthBearerToken: 'oauth-bearer-token',
      ...dto,
    });
  }

  build() {
    return { ...this.value };
  }
}