feat(nbstore): rename SyncStorage to DocSyncStorage (#10751)

This commit is contained in:
EYHN
2025-03-14 06:25:26 +00:00
parent 92effd9b51
commit f3ef9c4415
19 changed files with 90 additions and 79 deletions

View File

@@ -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(

View File

@@ -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

View File

@@ -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> {

View File

@@ -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';

View File

@@ -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;