feat: extract cache entry model to domain-core (#581)

* feat: extract cache entry model to domain-core

* fix(auth): rename cache table to be auth specific
This commit is contained in:
Karol Sójko 2023-05-02 11:43:50 +02:00 committed by GitHub
parent fe18420913
commit c71f7ff8ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 48 additions and 25 deletions

View file

@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class changeCacheTableName1683017908845 implements MigrationInterface {
name = 'changeCacheTableName1683017908845'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('RENAME TABLE `cache_entries` TO `auth_cache_entries`')
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('RENAME TABLE `auth_cache_entries` TO `cache_entries`')
}
}

View file

@ -0,0 +1,13 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class changeCacheTableName1683017671034 implements MigrationInterface {
name = 'changeCacheTableName1683017671034'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE "cache_entries" RENAME TO "auth_cache_entries"')
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE "auth_cache_entries" RENAME TO "cache_entries"')
}
}

View file

@ -187,7 +187,7 @@ import { UserRequestsController } from '../Controller/UserRequestsController'
import { EmailSubscriptionUnsubscribedEventHandler } from '../Domain/Handler/EmailSubscriptionUnsubscribedEventHandler'
import { SessionTraceRepositoryInterface } from '../Domain/Session/SessionTraceRepositoryInterface'
import { TypeORMSessionTraceRepository } from '../Infra/TypeORM/TypeORMSessionTraceRepository'
import { MapperInterface } from '@standardnotes/domain-core'
import { CacheEntry, CacheEntryRepositoryInterface, MapperInterface } from '@standardnotes/domain-core'
import { SessionTracePersistenceMapper } from '../Mapping/SessionTracePersistenceMapper'
import { SessionTrace } from '../Domain/Session/SessionTrace'
import { TypeORMSessionTrace } from '../Infra/TypeORM/TypeORMSessionTrace'
@ -218,9 +218,7 @@ import { SignInWithRecoveryCodes } from '../Domain/UseCase/SignInWithRecoveryCod
import { GetUserKeyParamsRecovery } from '../Domain/UseCase/GetUserKeyParamsRecovery/GetUserKeyParamsRecovery'
import { CleanupExpiredSessions } from '../Domain/UseCase/CleanupExpiredSessions/CleanupExpiredSessions'
import { TypeORMCacheEntry } from '../Infra/TypeORM/TypeORMCacheEntry'
import { CacheEntryRepositoryInterface } from '../Domain/Cache/CacheEntryRepositoryInterface'
import { TypeORMCacheEntryRepository } from '../Infra/TypeORM/TypeORMCacheEntryRepository'
import { CacheEntry } from '../Domain/Cache/CacheEntry'
import { CacheEntryPersistenceMapper } from '../Mapping/CacheEntryPersistenceMapper'
import { TypeORMLockRepository } from '../Infra/TypeORM/TypeORMLockRepository'
import { EphemeralSessionRepositoryInterface } from '../Domain/Session/EphemeralSessionRepositoryInterface'

View file

@ -1,6 +1,6 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
@Entity({ name: 'cache_entries' })
@Entity({ name: 'auth_cache_entries' })
export class TypeORMCacheEntry {
@PrimaryGeneratedColumn('uuid')
declare uuid: string

View file

@ -1,7 +1,6 @@
import { MapperInterface } from '@standardnotes/domain-core'
import { CacheEntry, CacheEntryRepositoryInterface, MapperInterface } from '@standardnotes/domain-core'
import { Repository } from 'typeorm'
import { CacheEntry } from '../../Domain/Cache/CacheEntry'
import { CacheEntryRepositoryInterface } from '../../Domain/Cache/CacheEntryRepositoryInterface'
import { TypeORMCacheEntry } from './TypeORMCacheEntry'
export class TypeORMCacheEntryRepository implements CacheEntryRepositoryInterface {

View file

@ -1,6 +1,6 @@
import { CacheEntryRepositoryInterface, CacheEntry } from '@standardnotes/domain-core'
import { TimerInterface } from '@standardnotes/time'
import { CacheEntry } from '../../Domain/Cache/CacheEntry'
import { CacheEntryRepositoryInterface } from '../../Domain/Cache/CacheEntryRepositoryInterface'
import { EphemeralSession } from '../../Domain/Session/EphemeralSession'
import { EphemeralSessionRepositoryInterface } from '../../Domain/Session/EphemeralSessionRepositoryInterface'

View file

@ -1,8 +1,6 @@
import { CacheEntryRepositoryInterface, CacheEntry } from '@standardnotes/domain-core'
import { TimerInterface } from '@standardnotes/time'
import { CacheEntry } from '../../Domain/Cache/CacheEntry'
import { CacheEntryRepositoryInterface } from '../../Domain/Cache/CacheEntryRepositoryInterface'
import { LockRepositoryInterface } from '../../Domain/User/LockRepositoryInterface'
export class TypeORMLockRepository implements LockRepositoryInterface {

View file

@ -1,9 +1,8 @@
import { OfflineSubscriptionToken } from '../../Domain/Auth/OfflineSubscriptionToken'
import { OfflineSubscriptionTokenRepositoryInterface } from '../../Domain/Auth/OfflineSubscriptionTokenRepositoryInterface'
import { CacheEntryRepositoryInterface, CacheEntry } from '@standardnotes/domain-core'
import { TimerInterface } from '@standardnotes/time'
import { CacheEntryRepositoryInterface } from '../../Domain/Cache/CacheEntryRepositoryInterface'
import { CacheEntry } from '../../Domain/Cache/CacheEntry'
import { OfflineSubscriptionToken } from '../../Domain/Auth/OfflineSubscriptionToken'
import { OfflineSubscriptionTokenRepositoryInterface } from '../../Domain/Auth/OfflineSubscriptionTokenRepositoryInterface'
export class TypeORMOfflineSubscriptionTokenRepository implements OfflineSubscriptionTokenRepositoryInterface {
private readonly PREFIX = 'offline-subscription-token'

View file

@ -1,8 +1,7 @@
import { CacheEntry, CacheEntryRepositoryInterface } from '@standardnotes/domain-core'
import { TimerInterface } from '@standardnotes/time'
import { Logger } from 'winston'
import { CacheEntry } from '../../Domain/Cache/CacheEntry'
import { CacheEntryRepositoryInterface } from '../../Domain/Cache/CacheEntryRepositoryInterface'
import { PKCERepositoryInterface } from '../../Domain/User/PKCERepositoryInterface'
export class TypeORMPKCERepository implements PKCERepositoryInterface {

View file

@ -1,8 +1,8 @@
import { CacheEntryRepositoryInterface, CacheEntry } from '@standardnotes/domain-core'
import { TimerInterface } from '@standardnotes/time'
import { SubscriptionToken } from '../../Domain/Subscription/SubscriptionToken'
import { SubscriptionTokenRepositoryInterface } from '../../Domain/Subscription/SubscriptionTokenRepositoryInterface'
import { TimerInterface } from '@standardnotes/time'
import { CacheEntryRepositoryInterface } from '../../Domain/Cache/CacheEntryRepositoryInterface'
import { CacheEntry } from '../../Domain/Cache/CacheEntry'
export class TypeORMSubscriptionTokenRepository implements SubscriptionTokenRepositoryInterface {
private readonly PREFIX = 'subscription-token'

View file

@ -1,6 +1,5 @@
import { MapperInterface, UniqueEntityId } from '@standardnotes/domain-core'
import { CacheEntry, MapperInterface, UniqueEntityId } from '@standardnotes/domain-core'
import { CacheEntry } from '../Domain/Cache/CacheEntry'
import { TypeORMCacheEntry } from '../Infra/TypeORM/TypeORMCacheEntry'
export class CacheEntryPersistenceMapper implements MapperInterface<CacheEntry, TypeORMCacheEntry> {

View file

@ -1,5 +1,6 @@
import { Entity, Result, UniqueEntityId } from '@standardnotes/domain-core'
import { Entity } from '../Core/Entity'
import { Result } from '../Core/Result'
import { UniqueEntityId } from '../Core/UniqueEntityId'
import { CacheEntryProps } from './CacheEntryProps'
export class CacheEntry extends Entity<CacheEntryProps> {

View file

@ -5,6 +5,10 @@ export * from './Auth/SessionProps'
export * from './Auth/SessionToken'
export * from './Auth/SessionTokenProps'
export * from './Cache/CacheEntry'
export * from './Cache/CacheEntryProps'
export * from './Cache/CacheEntryRepositoryInterface'
export * from './Common/Dates'
export * from './Common/DatesProps'
export * from './Common/Email'