mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
feat(nbstore): rename SyncStorage to DocSyncStorage (#10751)
This commit is contained in:
@@ -2,8 +2,8 @@ import type { Connection } from '../connection';
|
||||
import type { DocClock, DocClocks } from './doc';
|
||||
import { type Storage } from './storage';
|
||||
|
||||
export interface SyncStorage extends Storage {
|
||||
readonly storageType: 'sync';
|
||||
export interface DocSyncStorage extends Storage {
|
||||
readonly storageType: 'docSync';
|
||||
|
||||
getPeerRemoteClock(peer: string, docId: string): Promise<DocClock | null>;
|
||||
getPeerRemoteClocks(peer: string): Promise<DocClocks>;
|
||||
@@ -20,8 +20,8 @@ export interface SyncStorage extends Storage {
|
||||
clearClocks(): Promise<void>;
|
||||
}
|
||||
|
||||
export abstract class SyncStorageBase implements SyncStorage {
|
||||
readonly storageType = 'sync';
|
||||
export abstract class DocSyncStorageBase implements DocSyncStorage {
|
||||
readonly storageType = 'docSync';
|
||||
abstract readonly connection: Connection;
|
||||
|
||||
abstract getPeerRemoteClock(
|
||||
@@ -1,8 +1,8 @@
|
||||
import { DummyConnection } from '../../connection';
|
||||
import type { DocClock, DocClocks } from '../doc';
|
||||
import { SyncStorageBase } from '../sync';
|
||||
import { DocSyncStorageBase } from '../doc-sync';
|
||||
|
||||
export class DummySyncStorage extends SyncStorageBase {
|
||||
export class DummyDocSyncStorage extends DocSyncStorageBase {
|
||||
override getPeerRemoteClock(
|
||||
_peer: string,
|
||||
_docId: string
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
} from '../doc';
|
||||
|
||||
export class DummyDocStorage implements DocStorage {
|
||||
spaceId = '';
|
||||
readonly storageType = 'doc';
|
||||
readonly isReadonly = true;
|
||||
getDoc(_docId: string): Promise<DocRecord | null> {
|
||||
|
||||
@@ -3,14 +3,14 @@ import EventEmitter2 from 'eventemitter2';
|
||||
import type { AwarenessStorage } from './awareness';
|
||||
import type { BlobStorage } from './blob';
|
||||
import type { DocStorage } from './doc';
|
||||
import type { DocSyncStorage } from './doc-sync';
|
||||
import { DummyAwarenessStorage } from './dummy/awareness';
|
||||
import { DummyBlobStorage } from './dummy/blob';
|
||||
import { DummyDocStorage } from './dummy/doc';
|
||||
import { DummySyncStorage } from './dummy/sync';
|
||||
import { DummyDocSyncStorage } from './dummy/doc-sync';
|
||||
import type { StorageType } from './storage';
|
||||
import type { SyncStorage } from './sync';
|
||||
|
||||
type Storages = DocStorage | BlobStorage | SyncStorage | AwarenessStorage;
|
||||
type Storages = DocStorage | BlobStorage | DocSyncStorage | AwarenessStorage;
|
||||
|
||||
export type SpaceStorageOptions = {
|
||||
[K in StorageType]?: Storages & { storageType: K };
|
||||
@@ -28,7 +28,7 @@ export class SpaceStorage {
|
||||
awareness: storages.awareness ?? new DummyAwarenessStorage(),
|
||||
blob: storages.blob ?? new DummyBlobStorage(),
|
||||
doc: storages.doc ?? new DummyDocStorage(),
|
||||
sync: storages.sync ?? new DummySyncStorage(),
|
||||
['docSync']: storages['docSync'] ?? new DummyDocSyncStorage(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export class SpaceStorage {
|
||||
export * from './awareness';
|
||||
export * from './blob';
|
||||
export * from './doc';
|
||||
export * from './doc-sync';
|
||||
export * from './errors';
|
||||
export * from './history';
|
||||
export * from './storage';
|
||||
export * from './sync';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Connection } from '../connection';
|
||||
|
||||
export type StorageType = 'blob' | 'doc' | 'sync' | 'awareness';
|
||||
export type StorageType = 'blob' | 'doc' | 'docSync' | 'awareness';
|
||||
|
||||
export interface Storage {
|
||||
readonly storageType: StorageType;
|
||||
|
||||
Reference in New Issue
Block a user