refactor: remove Uuid and RoleName from @standardnotes/common in favour of @standardnotes/domain-core value objects (#2167)

This commit is contained in:
Karol Sójko
2023-01-19 16:17:59 +01:00
committed by GitHub
parent 2d63b7431a
commit 856a7e3500
108 changed files with 319 additions and 374 deletions

View File

@@ -1,15 +1,14 @@
import { removeFromArray } from '@standardnotes/utils'
import { Uuid } from '@standardnotes/common'
import { EncryptedBytes } from '../Types/EncryptedBytes'
export class FileMemoryCache {
private cache: Record<Uuid, EncryptedBytes> = {}
private orderedQueue: Uuid[] = []
private cache: Record<string, EncryptedBytes> = {}
private orderedQueue: string[] = []
constructor(public readonly maxSize: number) {}
add(uuid: Uuid, data: EncryptedBytes): boolean {
add(uuid: string, data: EncryptedBytes): boolean {
if (data.encryptedBytes.length > this.maxSize) {
return false
}
@@ -31,11 +30,11 @@ export class FileMemoryCache {
.reduce((total, fileLength) => total + fileLength, 0)
}
get(uuid: Uuid): EncryptedBytes | undefined {
get(uuid: string): EncryptedBytes | undefined {
return this.cache[uuid]
}
remove(uuid: Uuid): void {
remove(uuid: string): void {
delete this.cache[uuid]
removeFromArray(this.orderedQueue, uuid)

View File

@@ -1,4 +1,3 @@
import { Uuid } from '@standardnotes/common'
import { FileDownloadProgress } from '../Types/FileDownloadProgress'
import { FileBackupRecord, FileBackupsMapping } from './FileBackupsMapping'
@@ -8,7 +7,7 @@ export type FileBackupReadChunkResponse = { chunk: Uint8Array; isLast: boolean;
export interface FileBackupsDevice {
getFilesBackupsMappingFile(): Promise<FileBackupsMapping>
saveFilesBackupsFile(
uuid: Uuid,
uuid: string,
metaFile: string,
downloadRequest: {
chunkSizes: number[]

View File

@@ -1,4 +1,3 @@
import { Uuid } from '@standardnotes/common'
import { FileBackupsConstantsV1 } from './FileBackupsConstantsV1'
export type FileBackupRecord = {
@@ -12,5 +11,5 @@ export type FileBackupRecord = {
export interface FileBackupsMapping {
version: typeof FileBackupsConstantsV1.Version
files: Record<Uuid, FileBackupRecord>
files: Record<string, FileBackupRecord>
}