@fluidframework/file-driver 2.0.0-rc.1.0.3 → 2.0.0-rc.2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.eslintrc.js → .eslintrc.cjs} +4 -1
- package/CHANGELOG.md +20 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -2
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/file-driver.api.md +4 -2
- package/dist/file-driver-alpha.d.ts +2 -0
- package/dist/file-driver-beta.d.ts +2 -0
- package/dist/file-driver-public.d.ts +2 -0
- package/dist/file-driver-untrimmed.d.ts +4 -2
- package/dist/fileDocumentDeltaConnection.d.ts +1 -1
- package/dist/fileDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/fileDocumentDeltaConnection.js.map +1 -1
- package/dist/fileDocumentService.d.ts +3 -2
- package/dist/fileDocumentService.d.ts.map +1 -1
- package/dist/fileDocumentService.js +3 -1
- package/dist/fileDocumentService.js.map +1 -1
- package/dist/fileDocumentServiceFactory.d.ts +1 -1
- package/dist/fileDocumentServiceFactory.d.ts.map +1 -1
- package/dist/fileDocumentServiceFactory.js +2 -2
- package/dist/fileDocumentServiceFactory.js.map +1 -1
- package/dist/fileDocumentStorageService.d.ts +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/file-driver-alpha.d.ts +53 -0
- package/lib/file-driver-beta.d.ts +71 -0
- package/lib/file-driver-public.d.ts +71 -0
- package/lib/file-driver-untrimmed.d.ts +211 -0
- package/lib/fileDeltaStorageService.d.ts +26 -0
- package/lib/fileDeltaStorageService.d.ts.map +1 -0
- package/lib/fileDeltaStorageService.js +59 -0
- package/lib/fileDeltaStorageService.js.map +1 -0
- package/lib/fileDocumentDeltaConnection.d.ts +61 -0
- package/lib/fileDocumentDeltaConnection.d.ts.map +1 -0
- package/lib/fileDocumentDeltaConnection.js +161 -0
- package/lib/fileDocumentDeltaConnection.js.map +1 -0
- package/lib/fileDocumentService.d.ts +31 -0
- package/lib/fileDocumentService.d.ts.map +1 -0
- package/lib/fileDocumentService.js +37 -0
- package/lib/fileDocumentService.js.map +1 -0
- package/lib/fileDocumentServiceFactory.d.ts +28 -0
- package/lib/fileDocumentServiceFactory.d.ts.map +1 -0
- package/lib/fileDocumentServiceFactory.js +31 -0
- package/lib/fileDocumentServiceFactory.js.map +1 -0
- package/lib/fileDocumentStorageService.d.ts +91 -0
- package/lib/fileDocumentStorageService.d.ts.map +1 -0
- package/lib/fileDocumentStorageService.js +197 -0
- package/lib/fileDocumentStorageService.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/lib/test/types/validateFileDriverPrevious.generated.d.ts +2 -0
- package/lib/test/types/validateFileDriverPrevious.generated.d.ts.map +1 -0
- package/lib/test/types/validateFileDriverPrevious.generated.js +26 -0
- package/lib/test/types/validateFileDriverPrevious.generated.js.map +1 -0
- package/package.json +61 -19
- package/src/fileDocumentDeltaConnection.ts +1 -1
- package/src/fileDocumentService.ts +9 -3
- package/src/fileDocumentServiceFactory.ts +2 -2
- package/src/index.ts +4 -4
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as api from '@fluidframework/protocol-definitions';
|
|
2
|
+
import { ConnectionMode } from '@fluidframework/protocol-definitions';
|
|
3
|
+
import { IClientConfiguration } from '@fluidframework/protocol-definitions';
|
|
4
|
+
import { IConnected } from '@fluidframework/protocol-definitions';
|
|
5
|
+
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
6
|
+
import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
|
|
7
|
+
import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
|
|
8
|
+
import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
|
|
9
|
+
import { IDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
10
|
+
import { IDocumentService } from '@fluidframework/driver-definitions';
|
|
11
|
+
import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
|
|
12
|
+
import { IDocumentStorageService } from '@fluidframework/driver-definitions';
|
|
13
|
+
import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
|
|
14
|
+
import { IFileSnapshot } from '@fluidframework/replay-driver';
|
|
15
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
16
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
17
|
+
import { ISignalClient } from '@fluidframework/protocol-definitions';
|
|
18
|
+
import { ISignalMessage } from '@fluidframework/protocol-definitions';
|
|
19
|
+
import { ISnapshot } from '@fluidframework/driver-definitions';
|
|
20
|
+
import { ISnapshotFetchOptions } from '@fluidframework/driver-definitions';
|
|
21
|
+
import { IStream } from '@fluidframework/driver-definitions';
|
|
22
|
+
import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
23
|
+
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
24
|
+
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
25
|
+
import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
26
|
+
import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
|
|
27
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
28
|
+
|
|
29
|
+
/* Excluded from this release type: FileDeltaStorageService */
|
|
30
|
+
|
|
31
|
+
/* Excluded from this release type: FileDocumentServiceFactory */
|
|
32
|
+
|
|
33
|
+
/* Excluded from this release type: FileSnapshotWriterClassFactory */
|
|
34
|
+
|
|
35
|
+
/* Excluded from this release type: FileStorageDocumentName */
|
|
36
|
+
|
|
37
|
+
/* Excluded from this release type: FluidFetchReader */
|
|
38
|
+
|
|
39
|
+
/* Excluded from this release type: FluidFetchReaderFileSnapshotWriter */
|
|
40
|
+
|
|
41
|
+
/* Excluded from this release type: IDocumentDeltaConnection */
|
|
42
|
+
|
|
43
|
+
/* Excluded from this release type: IDocumentDeltaConnectionEvents */
|
|
44
|
+
|
|
45
|
+
/* Excluded from this release type: IDocumentDeltaStorageService */
|
|
46
|
+
|
|
47
|
+
/* Excluded from this release type: IDocumentService */
|
|
48
|
+
|
|
49
|
+
/* Excluded from this release type: IDocumentServiceFactory */
|
|
50
|
+
|
|
51
|
+
/* Excluded from this release type: IDocumentStorageService */
|
|
52
|
+
|
|
53
|
+
/* Excluded from this release type: IFileSnapshot */
|
|
54
|
+
|
|
55
|
+
/* Excluded from this release type: IResolvedUrl */
|
|
56
|
+
|
|
57
|
+
/* Excluded from this release type: ISnapshotWriterStorage */
|
|
58
|
+
|
|
59
|
+
/* Excluded from this release type: IStream */
|
|
60
|
+
|
|
61
|
+
/* Excluded from this release type: ISummaryContext */
|
|
62
|
+
|
|
63
|
+
/* Excluded from this release type: ReadDocumentStorageServiceBase */
|
|
64
|
+
|
|
65
|
+
/* Excluded from this release type: ReaderConstructor */
|
|
66
|
+
|
|
67
|
+
/* Excluded from this release type: Replayer */
|
|
68
|
+
|
|
69
|
+
/* Excluded from this release type: ReplayFileDeltaConnection */
|
|
70
|
+
|
|
71
|
+
export { }
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as api from '@fluidframework/protocol-definitions';
|
|
2
|
+
import { ConnectionMode } from '@fluidframework/protocol-definitions';
|
|
3
|
+
import { IClientConfiguration } from '@fluidframework/protocol-definitions';
|
|
4
|
+
import { IConnected } from '@fluidframework/protocol-definitions';
|
|
5
|
+
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
6
|
+
import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
|
|
7
|
+
import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
|
|
8
|
+
import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
|
|
9
|
+
import { IDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
10
|
+
import { IDocumentService } from '@fluidframework/driver-definitions';
|
|
11
|
+
import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
|
|
12
|
+
import { IDocumentStorageService } from '@fluidframework/driver-definitions';
|
|
13
|
+
import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
|
|
14
|
+
import { IFileSnapshot } from '@fluidframework/replay-driver';
|
|
15
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
16
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
17
|
+
import { ISignalClient } from '@fluidframework/protocol-definitions';
|
|
18
|
+
import { ISignalMessage } from '@fluidframework/protocol-definitions';
|
|
19
|
+
import { ISnapshot } from '@fluidframework/driver-definitions';
|
|
20
|
+
import { ISnapshotFetchOptions } from '@fluidframework/driver-definitions';
|
|
21
|
+
import { IStream } from '@fluidframework/driver-definitions';
|
|
22
|
+
import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
23
|
+
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
24
|
+
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
25
|
+
import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
26
|
+
import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
|
|
27
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Provides access to the underlying delta storage on the local file storage for file driver.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
34
|
+
private readonly path;
|
|
35
|
+
private readonly messages;
|
|
36
|
+
private lastOps;
|
|
37
|
+
constructor(path: string);
|
|
38
|
+
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<api.ISequencedDocumentMessage[]>;
|
|
39
|
+
get ops(): readonly Readonly<api.ISequencedDocumentMessage>[];
|
|
40
|
+
/**
|
|
41
|
+
* Retrieve ops within the exclusive sequence number range.
|
|
42
|
+
*
|
|
43
|
+
* @param from - First op to be fetched.
|
|
44
|
+
* @param to - Last op to be fetched. This is exclusive.
|
|
45
|
+
*/
|
|
46
|
+
getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Factory for creating the file document service. Use this if you want to
|
|
51
|
+
* use the local file storage as underlying storage.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
export declare class FileDocumentServiceFactory implements IDocumentServiceFactory {
|
|
55
|
+
private readonly storage;
|
|
56
|
+
private readonly deltaStorage;
|
|
57
|
+
private readonly deltaConnection;
|
|
58
|
+
constructor(storage: IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: IDocumentDeltaConnection);
|
|
59
|
+
/**
|
|
60
|
+
* Creates the file document service if the path exists.
|
|
61
|
+
*
|
|
62
|
+
* @param fileURL - Path of directory containing ops/snapshots.
|
|
63
|
+
* @returns file document service.
|
|
64
|
+
*/
|
|
65
|
+
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
66
|
+
createContainer(createNewSummary: ISummaryTree, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
|
|
73
|
+
new (...args: any[]): {
|
|
74
|
+
blobsWriter: Map<string, ArrayBufferLike>;
|
|
75
|
+
latestWriterTree?: api.ISnapshotTree | undefined;
|
|
76
|
+
docId?: string | undefined;
|
|
77
|
+
reset(): void;
|
|
78
|
+
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
79
|
+
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
80
|
+
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
81
|
+
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
82
|
+
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
83
|
+
buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
|
|
84
|
+
readonly policies?: IDocumentStorageServicePolicies | undefined;
|
|
85
|
+
getSnapshot?(snapshotFetchOptions?: ISnapshotFetchOptions | undefined): Promise<ISnapshot>;
|
|
86
|
+
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
87
|
+
downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
|
|
88
|
+
readonly disposed?: boolean | undefined;
|
|
89
|
+
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
90
|
+
};
|
|
91
|
+
} & TBase;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
export declare const FileStorageDocumentName = "FileStorageDocId";
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Document storage service for the file driver.
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
export declare class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
|
|
103
|
+
private readonly path;
|
|
104
|
+
private readonly versionName?;
|
|
105
|
+
protected docTree: api.ISnapshotTree | null;
|
|
106
|
+
constructor(path: string, versionName?: string | undefined);
|
|
107
|
+
/**
|
|
108
|
+
* Read the file and returns the snapshot tree.
|
|
109
|
+
* @param version - The version contains the path of the file which contains the snapshot tree.
|
|
110
|
+
*/
|
|
111
|
+
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
112
|
+
/**
|
|
113
|
+
* Gets the path of the snapshot tree to be read.
|
|
114
|
+
* @param versionId - version ID.
|
|
115
|
+
* @param count - Number of versions to be returned.
|
|
116
|
+
*/
|
|
117
|
+
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
118
|
+
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @internal
|
|
123
|
+
*/
|
|
124
|
+
export declare const FluidFetchReaderFileSnapshotWriter: {
|
|
125
|
+
new (...args: any[]): {
|
|
126
|
+
blobsWriter: Map<string, ArrayBufferLike>;
|
|
127
|
+
latestWriterTree?: api.ISnapshotTree | undefined;
|
|
128
|
+
docId?: string | undefined;
|
|
129
|
+
reset(): void;
|
|
130
|
+
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
131
|
+
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
132
|
+
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
133
|
+
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
134
|
+
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
135
|
+
buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
|
|
136
|
+
readonly policies?: IDocumentStorageServicePolicies | undefined;
|
|
137
|
+
getSnapshot?(snapshotFetchOptions?: ISnapshotFetchOptions | undefined): Promise<ISnapshot>;
|
|
138
|
+
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
139
|
+
downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
|
|
140
|
+
readonly disposed?: boolean | undefined;
|
|
141
|
+
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
142
|
+
};
|
|
143
|
+
} & typeof FluidFetchReader;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export declare interface ISnapshotWriterStorage extends IDocumentStorageService {
|
|
149
|
+
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
150
|
+
reset(): void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
export declare type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Replay service used to play ops using the delta connection.
|
|
160
|
+
* @internal
|
|
161
|
+
*/
|
|
162
|
+
export declare class Replayer {
|
|
163
|
+
private readonly deltaConnection;
|
|
164
|
+
private readonly documentStorageService;
|
|
165
|
+
private currentReplayOp;
|
|
166
|
+
constructor(deltaConnection: ReplayFileDeltaConnection, documentStorageService: FileDeltaStorageService);
|
|
167
|
+
get currentReplayedOp(): number;
|
|
168
|
+
set currentReplayedOp(op: number);
|
|
169
|
+
get ops(): readonly Readonly<ISequencedDocumentMessage>[];
|
|
170
|
+
/**
|
|
171
|
+
* Replay the ops upto a certain number.
|
|
172
|
+
* @param replayTo - The last op number to be replayed.
|
|
173
|
+
*/
|
|
174
|
+
replay(replayTo: number): number;
|
|
175
|
+
private isDoneFetch;
|
|
176
|
+
private emit;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @internal
|
|
181
|
+
*/
|
|
182
|
+
export declare class ReplayFileDeltaConnection extends TypedEventEmitter<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable {
|
|
183
|
+
details: IConnected;
|
|
184
|
+
/**
|
|
185
|
+
* Mimic the delta connection to replay ops on it.
|
|
186
|
+
*
|
|
187
|
+
* @param documentDeltaStorageService - The delta storage service to get ops from.
|
|
188
|
+
* @returns Document delta connection.
|
|
189
|
+
*/
|
|
190
|
+
static create(documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection>;
|
|
191
|
+
readonly maxMessageSize: number;
|
|
192
|
+
private readonly replayer;
|
|
193
|
+
constructor(details: IConnected, documentDeltaStorageService: FileDeltaStorageService);
|
|
194
|
+
getReplayer(): Replayer;
|
|
195
|
+
get clientId(): string;
|
|
196
|
+
get mode(): ConnectionMode;
|
|
197
|
+
get claims(): ITokenClaims;
|
|
198
|
+
get existing(): boolean;
|
|
199
|
+
get version(): string;
|
|
200
|
+
get initialMessages(): ISequencedDocumentMessage[];
|
|
201
|
+
get initialSignals(): ISignalMessage[];
|
|
202
|
+
get initialClients(): ISignalClient[];
|
|
203
|
+
get serviceConfiguration(): IClientConfiguration;
|
|
204
|
+
submit(documentMessages: IDocumentMessage[]): void;
|
|
205
|
+
submitSignal(message: any): Promise<void>;
|
|
206
|
+
private _disposed;
|
|
207
|
+
get disposed(): boolean;
|
|
208
|
+
dispose(): void;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export { }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentDeltaStorageService, IStream } from "@fluidframework/driver-definitions";
|
|
6
|
+
import * as api from "@fluidframework/protocol-definitions";
|
|
7
|
+
/**
|
|
8
|
+
* Provides access to the underlying delta storage on the local file storage for file driver.
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
12
|
+
private readonly path;
|
|
13
|
+
private readonly messages;
|
|
14
|
+
private lastOps;
|
|
15
|
+
constructor(path: string);
|
|
16
|
+
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<api.ISequencedDocumentMessage[]>;
|
|
17
|
+
get ops(): readonly Readonly<api.ISequencedDocumentMessage>[];
|
|
18
|
+
/**
|
|
19
|
+
* Retrieve ops within the exclusive sequence number range.
|
|
20
|
+
*
|
|
21
|
+
* @param from - First op to be fetched.
|
|
22
|
+
* @param to - Last op to be fetched. This is exclusive.
|
|
23
|
+
*/
|
|
24
|
+
getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=fileDeltaStorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAE3F,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,4BAA4B;IAI/D,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,OAAO,CAAC,OAAO,CAAuC;gBAEzB,IAAI,EAAE,MAAM;IAkBlC,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,CAAC;IAI3C,IAAW,GAAG,IAAI,SAAS,QAAQ,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,CAEnE;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC,yBAAyB,EAAE;CAmBlF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
7
|
+
import { emptyMessageStream } from "@fluidframework/driver-utils";
|
|
8
|
+
/**
|
|
9
|
+
* Provides access to the underlying delta storage on the local file storage for file driver.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export class FileDeltaStorageService {
|
|
13
|
+
constructor(path) {
|
|
14
|
+
this.path = path;
|
|
15
|
+
this.lastOps = [];
|
|
16
|
+
this.messages = [];
|
|
17
|
+
let counter = 0;
|
|
18
|
+
// eslint-disable-next-line no-constant-condition
|
|
19
|
+
while (true) {
|
|
20
|
+
const filename = `${this.path}//messages${counter === 0 ? "" : counter}.json`;
|
|
21
|
+
if (!fs.existsSync(filename)) {
|
|
22
|
+
if (counter === 0) {
|
|
23
|
+
throw new Error(`file ${filename} not found`);
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
const data = fs.readFileSync(filename);
|
|
28
|
+
this.messages = this.messages.concat(JSON.parse(data.toString("utf-8")));
|
|
29
|
+
counter++;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
fetchMessages(from, to, abortSignal, cachedOnly) {
|
|
33
|
+
return emptyMessageStream;
|
|
34
|
+
}
|
|
35
|
+
get ops() {
|
|
36
|
+
return this.messages;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve ops within the exclusive sequence number range.
|
|
40
|
+
*
|
|
41
|
+
* @param from - First op to be fetched.
|
|
42
|
+
* @param to - Last op to be fetched. This is exclusive.
|
|
43
|
+
*/
|
|
44
|
+
getFromWebSocket(from, to) {
|
|
45
|
+
const readFrom = Math.max(from, 0); // Inclusive
|
|
46
|
+
const readTo = Math.min(to, this.messages.length); // Exclusive
|
|
47
|
+
if (readFrom >= this.messages.length || readTo <= 0 || readFrom >= readTo) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
// Optimizations for multiple readers (replay tool)
|
|
51
|
+
if (this.lastOps.length > 0 && this.lastOps[0].sequenceNumber === readFrom + 1) {
|
|
52
|
+
return this.lastOps;
|
|
53
|
+
}
|
|
54
|
+
this.lastOps = this.messages.slice(readFrom, readTo);
|
|
55
|
+
assert(this.lastOps[0].sequenceNumber === readFrom + 1, 0x091 /* "Retrieved ops' first sequence number has unexpected value!" */);
|
|
56
|
+
return this.lastOps;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=fileDeltaStorageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileDeltaStorageService.js","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAGlE;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAInC,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAFjC,YAAO,GAAoC,EAAE,CAAC;QAGrD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,iDAAiD;QACjD,OAAO,IAAI,EAAE;YACZ,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,aAAa,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,OAAO,CAAC;YAC9E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;gBAC7B,IAAI,OAAO,KAAK,CAAC,EAAE;oBAClB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,YAAY,CAAC,CAAC;iBAC9C;gBACD,MAAM;aACN;YACD,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;YACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACzE,OAAO,EAAE,CAAC;SACV;IACF,CAAC;IAEM,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEpB,OAAO,kBAAkB,CAAC;IAC3B,CAAC;IAED,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAY,EAAE,EAAU;QAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY;QAE/D,IAAI,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,MAAM,IAAI,CAAC,IAAI,QAAQ,IAAI,MAAM,EAAE;YAC1E,OAAO,EAAE,CAAC;SACV;QAED,mDAAmD;QACnD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,QAAQ,GAAG,CAAC,EAAE;YAC/E,OAAO,IAAI,CAAC,OAAO,CAAC;SACpB;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrD,MAAM,CACL,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,QAAQ,GAAG,CAAC,EAC/C,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { emptyMessageStream } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\n\n/**\n * Provides access to the underlying delta storage on the local file storage for file driver.\n * @internal\n */\nexport class FileDeltaStorageService implements IDocumentDeltaStorageService {\n\tprivate readonly messages: api.ISequencedDocumentMessage[];\n\tprivate lastOps: api.ISequencedDocumentMessage[] = [];\n\n\tconstructor(private readonly path: string) {\n\t\tthis.messages = [];\n\t\tlet counter = 0;\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\tconst filename = `${this.path}//messages${counter === 0 ? \"\" : counter}.json`;\n\t\t\tif (!fs.existsSync(filename)) {\n\t\t\t\tif (counter === 0) {\n\t\t\t\t\tthrow new Error(`file ${filename} not found`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst data = fs.readFileSync(filename);\n\t\t\tthis.messages = this.messages.concat(JSON.parse(data.toString(\"utf-8\")));\n\t\t\tcounter++;\n\t\t}\n\t}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t): IStream<api.ISequencedDocumentMessage[]> {\n\t\treturn emptyMessageStream;\n\t}\n\n\tpublic get ops(): readonly Readonly<api.ISequencedDocumentMessage>[] {\n\t\treturn this.messages;\n\t}\n\n\t/**\n\t * Retrieve ops within the exclusive sequence number range.\n\t *\n\t * @param from - First op to be fetched.\n\t * @param to - Last op to be fetched. This is exclusive.\n\t */\n\tpublic getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[] {\n\t\tconst readFrom = Math.max(from, 0); // Inclusive\n\t\tconst readTo = Math.min(to, this.messages.length); // Exclusive\n\n\t\tif (readFrom >= this.messages.length || readTo <= 0 || readFrom >= readTo) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Optimizations for multiple readers (replay tool)\n\t\tif (this.lastOps.length > 0 && this.lastOps[0].sequenceNumber === readFrom + 1) {\n\t\t\treturn this.lastOps;\n\t\t}\n\t\tthis.lastOps = this.messages.slice(readFrom, readTo);\n\t\tassert(\n\t\t\tthis.lastOps[0].sequenceNumber === readFrom + 1,\n\t\t\t0x091 /* \"Retrieved ops' first sequence number has unexpected value!\" */,\n\t\t);\n\t\treturn this.lastOps;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IDocumentDeltaConnection, IDocumentDeltaConnectionEvents } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { ConnectionMode, IClientConfiguration, IConnected, IDocumentMessage, ISequencedDocumentMessage, ISignalClient, ISignalMessage, ITokenClaims } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
9
|
+
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
10
|
+
/**
|
|
11
|
+
* Replay service used to play ops using the delta connection.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare class Replayer {
|
|
15
|
+
private readonly deltaConnection;
|
|
16
|
+
private readonly documentStorageService;
|
|
17
|
+
private currentReplayOp;
|
|
18
|
+
constructor(deltaConnection: ReplayFileDeltaConnection, documentStorageService: FileDeltaStorageService);
|
|
19
|
+
get currentReplayedOp(): number;
|
|
20
|
+
set currentReplayedOp(op: number);
|
|
21
|
+
get ops(): readonly Readonly<ISequencedDocumentMessage>[];
|
|
22
|
+
/**
|
|
23
|
+
* Replay the ops upto a certain number.
|
|
24
|
+
* @param replayTo - The last op number to be replayed.
|
|
25
|
+
*/
|
|
26
|
+
replay(replayTo: number): number;
|
|
27
|
+
private isDoneFetch;
|
|
28
|
+
private emit;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare class ReplayFileDeltaConnection extends TypedEventEmitter<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable {
|
|
34
|
+
details: IConnected;
|
|
35
|
+
/**
|
|
36
|
+
* Mimic the delta connection to replay ops on it.
|
|
37
|
+
*
|
|
38
|
+
* @param documentDeltaStorageService - The delta storage service to get ops from.
|
|
39
|
+
* @returns Document delta connection.
|
|
40
|
+
*/
|
|
41
|
+
static create(documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection>;
|
|
42
|
+
readonly maxMessageSize: number;
|
|
43
|
+
private readonly replayer;
|
|
44
|
+
constructor(details: IConnected, documentDeltaStorageService: FileDeltaStorageService);
|
|
45
|
+
getReplayer(): Replayer;
|
|
46
|
+
get clientId(): string;
|
|
47
|
+
get mode(): ConnectionMode;
|
|
48
|
+
get claims(): ITokenClaims;
|
|
49
|
+
get existing(): boolean;
|
|
50
|
+
get version(): string;
|
|
51
|
+
get initialMessages(): ISequencedDocumentMessage[];
|
|
52
|
+
get initialSignals(): ISignalMessage[];
|
|
53
|
+
get initialClients(): ISignalClient[];
|
|
54
|
+
get serviceConfiguration(): IClientConfiguration;
|
|
55
|
+
submit(documentMessages: IDocumentMessage[]): void;
|
|
56
|
+
submitSignal(message: any): Promise<void>;
|
|
57
|
+
private _disposed;
|
|
58
|
+
get disposed(): boolean;
|
|
59
|
+
dispose(): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=fileDocumentDeltaConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC9B,MAAM,oCAAoC,CAAC;AAC5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O,IAAI,MAAM,CAE3B;IAED,IAAW,eAAe,IAAI,yBAAyB,EAAE,CAExD;IAED,IAAW,cAAc,IAAI,cAAc,EAAE,CAE5C;IAED,IAAW,cAAc,IAAI,aAAa,EAAE,CAE3C;IAED,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAEM,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAM5C,YAAY,CAAC,OAAO,EAAE,GAAG;IAEtC,OAAO,CAAC,SAAS,CAAS;IAC1B,IAAW,QAAQ,YAElB;IACM,OAAO;CAGd"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ScopeType, } from "@fluidframework/protocol-definitions";
|
|
6
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
|
+
const MaxBatchDeltas = 2000;
|
|
8
|
+
// Since the replay service never actually sends messages the size below is arbitrary
|
|
9
|
+
const ReplayMaxMessageSize = 16 * 1024;
|
|
10
|
+
const fileProtocolVersion = "^0.1.0";
|
|
11
|
+
const replayDocumentId = "replayDocId";
|
|
12
|
+
const Claims = {
|
|
13
|
+
documentId: replayDocumentId,
|
|
14
|
+
scopes: [ScopeType.DocRead],
|
|
15
|
+
tenantId: "",
|
|
16
|
+
user: {
|
|
17
|
+
id: "",
|
|
18
|
+
},
|
|
19
|
+
iat: Math.round(new Date().getTime() / 1000),
|
|
20
|
+
exp: Math.round(new Date().getTime() / 1000) + 60 * 60,
|
|
21
|
+
ver: "1.0",
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Replay service used to play ops using the delta connection.
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export class Replayer {
|
|
28
|
+
constructor(deltaConnection, documentStorageService) {
|
|
29
|
+
this.deltaConnection = deltaConnection;
|
|
30
|
+
this.documentStorageService = documentStorageService;
|
|
31
|
+
this.currentReplayOp = 0;
|
|
32
|
+
}
|
|
33
|
+
get currentReplayedOp() {
|
|
34
|
+
return this.currentReplayOp;
|
|
35
|
+
}
|
|
36
|
+
set currentReplayedOp(op) {
|
|
37
|
+
this.currentReplayOp = op;
|
|
38
|
+
}
|
|
39
|
+
get ops() {
|
|
40
|
+
return this.documentStorageService.ops;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Replay the ops upto a certain number.
|
|
44
|
+
* @param replayTo - The last op number to be replayed.
|
|
45
|
+
*/
|
|
46
|
+
replay(replayTo) {
|
|
47
|
+
let totalReplayedOps = 0;
|
|
48
|
+
let done;
|
|
49
|
+
do {
|
|
50
|
+
const fetchToBatch = this.currentReplayOp + MaxBatchDeltas;
|
|
51
|
+
const fetchTo = Math.min(fetchToBatch, replayTo);
|
|
52
|
+
const fetchedOps = this.documentStorageService.getFromWebSocket(this.currentReplayOp, fetchTo);
|
|
53
|
+
if (fetchedOps.length <= 0) {
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.emit(fetchedOps);
|
|
58
|
+
totalReplayedOps += fetchedOps.length;
|
|
59
|
+
this.currentReplayOp += fetchedOps.length;
|
|
60
|
+
done = this.isDoneFetch(replayTo);
|
|
61
|
+
}
|
|
62
|
+
} while (!done);
|
|
63
|
+
return totalReplayedOps;
|
|
64
|
+
}
|
|
65
|
+
isDoneFetch(replayTo) {
|
|
66
|
+
if (replayTo >= 0) {
|
|
67
|
+
return this.currentReplayOp >= replayTo;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
emit(ops) {
|
|
72
|
+
// Note: do not clone messages here!
|
|
73
|
+
// If Replay Tool fails due to one container patching message in-place,
|
|
74
|
+
// then same thing can happen in shipping product due to
|
|
75
|
+
// socket reuse in ODSP between main and summarizer containers.
|
|
76
|
+
this.deltaConnection.emit("op", replayDocumentId, ops);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @internal
|
|
81
|
+
*/
|
|
82
|
+
export class ReplayFileDeltaConnection extends TypedEventEmitter {
|
|
83
|
+
/**
|
|
84
|
+
* Mimic the delta connection to replay ops on it.
|
|
85
|
+
*
|
|
86
|
+
* @param documentDeltaStorageService - The delta storage service to get ops from.
|
|
87
|
+
* @returns Document delta connection.
|
|
88
|
+
*/
|
|
89
|
+
static async create(documentDeltaStorageService) {
|
|
90
|
+
const mode = "read";
|
|
91
|
+
const connection = {
|
|
92
|
+
claims: Claims,
|
|
93
|
+
clientId: "PseudoClientId",
|
|
94
|
+
existing: true,
|
|
95
|
+
initialMessages: [],
|
|
96
|
+
initialSignals: [],
|
|
97
|
+
initialClients: [],
|
|
98
|
+
maxMessageSize: ReplayMaxMessageSize,
|
|
99
|
+
mode,
|
|
100
|
+
serviceConfiguration: {
|
|
101
|
+
blockSize: 64436,
|
|
102
|
+
maxMessageSize: ReplayMaxMessageSize,
|
|
103
|
+
},
|
|
104
|
+
supportedVersions: [fileProtocolVersion],
|
|
105
|
+
user: null,
|
|
106
|
+
version: fileProtocolVersion,
|
|
107
|
+
};
|
|
108
|
+
const deltaConnection = new ReplayFileDeltaConnection(connection, documentDeltaStorageService);
|
|
109
|
+
return deltaConnection;
|
|
110
|
+
}
|
|
111
|
+
constructor(details, documentDeltaStorageService) {
|
|
112
|
+
super();
|
|
113
|
+
this.details = details;
|
|
114
|
+
this.maxMessageSize = ReplayMaxMessageSize;
|
|
115
|
+
this._disposed = false;
|
|
116
|
+
this.replayer = new Replayer(this, documentDeltaStorageService);
|
|
117
|
+
}
|
|
118
|
+
getReplayer() {
|
|
119
|
+
return this.replayer;
|
|
120
|
+
}
|
|
121
|
+
get clientId() {
|
|
122
|
+
return this.details.clientId;
|
|
123
|
+
}
|
|
124
|
+
get mode() {
|
|
125
|
+
return this.details.mode;
|
|
126
|
+
}
|
|
127
|
+
get claims() {
|
|
128
|
+
return this.details.claims;
|
|
129
|
+
}
|
|
130
|
+
get existing() {
|
|
131
|
+
return this.details.existing;
|
|
132
|
+
}
|
|
133
|
+
get version() {
|
|
134
|
+
return this.details.version;
|
|
135
|
+
}
|
|
136
|
+
get initialMessages() {
|
|
137
|
+
return this.details.initialMessages;
|
|
138
|
+
}
|
|
139
|
+
get initialSignals() {
|
|
140
|
+
return this.details.initialSignals;
|
|
141
|
+
}
|
|
142
|
+
get initialClients() {
|
|
143
|
+
return this.details.initialClients;
|
|
144
|
+
}
|
|
145
|
+
get serviceConfiguration() {
|
|
146
|
+
return this.details.serviceConfiguration;
|
|
147
|
+
}
|
|
148
|
+
submit(documentMessages) {
|
|
149
|
+
// ReplayFileDeltaConnection.submit() can't be called - client never sees its own join on,
|
|
150
|
+
// and thus can never move to sending ops.
|
|
151
|
+
throw new Error("ReplayFileDeltaConnection.submit() can't be called");
|
|
152
|
+
}
|
|
153
|
+
async submitSignal(message) { }
|
|
154
|
+
get disposed() {
|
|
155
|
+
return this._disposed;
|
|
156
|
+
}
|
|
157
|
+
dispose() {
|
|
158
|
+
this._disposed = true;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=fileDocumentDeltaConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EASN,SAAS,GACT,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,qFAAqF;AACrF,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,MAAM,MAAM,GAAiB;IAC5B,UAAU,EAAE,gBAAgB;I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AAC,OAAY,IAAG,CAAC;IAG1C,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IACM,OAAO;QACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService.js\";\n\nconst MaxBatchDeltas = 2000;\n\n// Since the replay service never actually sends messages the size below is arbitrary\nconst ReplayMaxMessageSize = 16 * 1024;\n\nconst fileProtocolVersion = \"^0.1.0\";\n\nconst replayDocumentId = \"replayDocId\";\n\nconst Claims: ITokenClaims = {\n\tdocumentId: replayDocumentId,\n\tscopes: [ScopeType.DocRead],\n\ttenantId: \"\",\n\tuser: {\n\t\tid: \"\",\n\t},\n\tiat: Math.round(new Date().getTime() / 1000),\n\texp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n\tver: \"1.0\",\n};\n\n/**\n * Replay service used to play ops using the delta connection.\n * @internal\n */\nexport class Replayer {\n\tprivate currentReplayOp = 0;\n\n\tconstructor(\n\t\tprivate readonly deltaConnection: ReplayFileDeltaConnection,\n\t\tprivate readonly documentStorageService: FileDeltaStorageService,\n\t) {}\n\n\tpublic get currentReplayedOp() {\n\t\treturn this.currentReplayOp;\n\t}\n\n\tpublic set currentReplayedOp(op: number) {\n\t\tthis.currentReplayOp = op;\n\t}\n\n\tpublic get ops(): readonly Readonly<ISequencedDocumentMessage>[] {\n\t\treturn this.documentStorageService.ops;\n\t}\n\n\t/**\n\t * Replay the ops upto a certain number.\n\t * @param replayTo - The last op number to be replayed.\n\t */\n\tpublic replay(replayTo: number) {\n\t\tlet totalReplayedOps = 0;\n\t\tlet done: boolean;\n\t\tdo {\n\t\t\tconst fetchToBatch = this.currentReplayOp + MaxBatchDeltas;\n\t\t\tconst fetchTo = Math.min(fetchToBatch, replayTo);\n\n\t\t\tconst fetchedOps = this.documentStorageService.getFromWebSocket(\n\t\t\t\tthis.currentReplayOp,\n\t\t\t\tfetchTo,\n\t\t\t);\n\n\t\t\tif (fetchedOps.length <= 0) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.emit(fetchedOps);\n\t\t\t\ttotalReplayedOps += fetchedOps.length;\n\t\t\t\tthis.currentReplayOp += fetchedOps.length;\n\t\t\t\tdone = this.isDoneFetch(replayTo);\n\t\t\t}\n\t\t} while (!done);\n\t\treturn totalReplayedOps;\n\t}\n\n\tprivate isDoneFetch(replayTo: number) {\n\t\tif (replayTo >= 0) {\n\t\t\treturn this.currentReplayOp >= replayTo;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate emit(ops: ISequencedDocumentMessage[]) {\n\t\t// Note: do not clone messages here!\n\t\t// If Replay Tool fails due to one container patching message in-place,\n\t\t// then same thing can happen in shipping product due to\n\t\t// socket reuse in ODSP between main and summarizer containers.\n\t\tthis.deltaConnection.emit(\"op\", replayDocumentId, ops);\n\t}\n}\n\n/**\n * @internal\n */\nexport class ReplayFileDeltaConnection\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\t/**\n\t * Mimic the delta connection to replay ops on it.\n\t *\n\t * @param documentDeltaStorageService - The delta storage service to get ops from.\n\t * @returns Document delta connection.\n\t */\n\tpublic static async create(\n\t\tdocumentDeltaStorageService: FileDeltaStorageService,\n\t): Promise<ReplayFileDeltaConnection> {\n\t\tconst mode: ConnectionMode = \"read\";\n\t\tconst connection = {\n\t\t\tclaims: Claims,\n\t\t\tclientId: \"PseudoClientId\",\n\t\t\texisting: true,\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tinitialClients: [],\n\t\t\tmaxMessageSize: ReplayMaxMessageSize,\n\t\t\tmode,\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 64436,\n\t\t\t\tmaxMessageSize: ReplayMaxMessageSize,\n\t\t\t},\n\t\t\tsupportedVersions: [fileProtocolVersion],\n\t\t\tuser: null,\n\t\t\tversion: fileProtocolVersion,\n\t\t};\n\t\tconst deltaConnection = new ReplayFileDeltaConnection(\n\t\t\tconnection,\n\t\t\tdocumentDeltaStorageService,\n\t\t);\n\t\treturn deltaConnection;\n\t}\n\n\tpublic readonly maxMessageSize = ReplayMaxMessageSize;\n\tprivate readonly replayer: Replayer;\n\n\tpublic constructor(\n\t\tpublic details: IConnected,\n\t\tdocumentDeltaStorageService: FileDeltaStorageService,\n\t) {\n\t\tsuper();\n\t\tthis.replayer = new Replayer(this, documentDeltaStorageService);\n\t}\n\n\tpublic getReplayer() {\n\t\treturn this.replayer;\n\t}\n\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\treturn this.details.initialMessages;\n\t}\n\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\treturn this.details.initialSignals;\n\t}\n\n\tpublic get initialClients(): ISignalClient[] {\n\t\treturn this.details.initialClients;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tpublic submit(documentMessages: IDocumentMessage[]): void {\n\t\t// ReplayFileDeltaConnection.submit() can't be called - client never sees its own join on,\n\t\t// and thus can never move to sending ops.\n\t\tthrow new Error(\"ReplayFileDeltaConnection.submit() can't be called\");\n\t}\n\n\tpublic async submitSignal(message: any) {}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
+
import * as api from "@fluidframework/driver-definitions";
|
|
7
|
+
import { IClient } from "@fluidframework/protocol-definitions";
|
|
8
|
+
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
9
|
+
/**
|
|
10
|
+
* The DocumentService manages the different endpoints for connecting to
|
|
11
|
+
* underlying storage for file document service.
|
|
12
|
+
*/
|
|
13
|
+
export declare class FileDocumentService extends TypedEventEmitter<api.IDocumentServiceEvents> implements api.IDocumentService {
|
|
14
|
+
readonly resolvedUrl: api.IResolvedUrl;
|
|
15
|
+
private readonly storage;
|
|
16
|
+
private readonly deltaStorage;
|
|
17
|
+
private readonly deltaConnection;
|
|
18
|
+
constructor(resolvedUrl: api.IResolvedUrl, storage: api.IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: api.IDocumentDeltaConnection);
|
|
19
|
+
dispose(): void;
|
|
20
|
+
connectToStorage(): Promise<api.IDocumentStorageService>;
|
|
21
|
+
connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService>;
|
|
22
|
+
/**
|
|
23
|
+
* Connects to a delta storage endpoint of provided documentService to get ops and then replaying
|
|
24
|
+
* them so as to mimic a delta stream endpoint.
|
|
25
|
+
*
|
|
26
|
+
* @param client - Client that connects to socket.
|
|
27
|
+
* @returns returns the delta stream service.
|
|
28
|
+
*/
|
|
29
|
+
connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection>;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=fileDocumentService.d.ts.map
|