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:
parent
fe18420913
commit
c71f7ff8ad
15 changed files with 48 additions and 25 deletions
|
@ -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`')
|
||||
}
|
||||
}
|
|
@ -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"')
|
||||
}
|
||||
}
|
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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> {
|
||||
|
|
|
@ -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> {
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue