@fluidframework/file-driver 2.0.0-internal.7.0.0 → 2.0.0-internal.7.2.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/CHANGELOG.md +8 -0
- package/api-extractor.json +9 -1
- package/api-report/file-driver.api.md +171 -0
- package/dist/fileDocumentStorageService.d.ts.map +1 -1
- package/dist/fileDocumentStorageService.js +1 -1
- package/dist/fileDocumentStorageService.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +18 -26
- package/src/fileDocumentStorageService.ts +5 -2
package/CHANGELOG.md
CHANGED
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "@fluidframework/build-common/api-extractor-
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-base.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
"ae-missing-release-tag": {
|
|
7
|
+
// TODO: Fix violations and remove this rule override
|
|
8
|
+
"logLevel": "none"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
## API Report File for "@fluidframework/file-driver"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import * as api from '@fluidframework/protocol-definitions';
|
|
8
|
+
import { ConnectionMode } from '@fluidframework/protocol-definitions';
|
|
9
|
+
import { IClientConfiguration } from '@fluidframework/protocol-definitions';
|
|
10
|
+
import { IConnected } from '@fluidframework/protocol-definitions';
|
|
11
|
+
import { IDisposable } from '@fluidframework/core-interfaces';
|
|
12
|
+
import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
|
|
13
|
+
import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
|
|
14
|
+
import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
|
|
15
|
+
import { IDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
16
|
+
import { IDocumentService } from '@fluidframework/driver-definitions';
|
|
17
|
+
import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
|
|
18
|
+
import { IDocumentStorageService } from '@fluidframework/driver-definitions';
|
|
19
|
+
import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
|
|
20
|
+
import { IFileSnapshot } from '@fluidframework/replay-driver';
|
|
21
|
+
import { IResolvedUrl } from '@fluidframework/driver-definitions';
|
|
22
|
+
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
23
|
+
import { ISignalClient } from '@fluidframework/protocol-definitions';
|
|
24
|
+
import { ISignalMessage } from '@fluidframework/protocol-definitions';
|
|
25
|
+
import { IStream } from '@fluidframework/driver-definitions';
|
|
26
|
+
import { ISummaryContext } from '@fluidframework/driver-definitions';
|
|
27
|
+
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
28
|
+
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
29
|
+
import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
30
|
+
import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
|
|
31
|
+
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
32
|
+
|
|
33
|
+
// @public
|
|
34
|
+
export class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
35
|
+
constructor(path: string);
|
|
36
|
+
// (undocumented)
|
|
37
|
+
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<api.ISequencedDocumentMessage[]>;
|
|
38
|
+
getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[];
|
|
39
|
+
// (undocumented)
|
|
40
|
+
get ops(): readonly Readonly<api.ISequencedDocumentMessage>[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// @public
|
|
44
|
+
export class FileDocumentServiceFactory implements IDocumentServiceFactory {
|
|
45
|
+
constructor(storage: IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: IDocumentDeltaConnection);
|
|
46
|
+
// (undocumented)
|
|
47
|
+
createContainer(createNewSummary: ISummaryTree, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
48
|
+
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// @public (undocumented)
|
|
52
|
+
export const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
|
|
53
|
+
new (...args: any[]): {
|
|
54
|
+
blobsWriter: Map<string, ArrayBufferLike>;
|
|
55
|
+
latestWriterTree?: api.ISnapshotTree | undefined;
|
|
56
|
+
docId?: string | undefined;
|
|
57
|
+
reset(): void;
|
|
58
|
+
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
59
|
+
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
60
|
+
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
61
|
+
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
62
|
+
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
63
|
+
buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
|
|
64
|
+
repositoryUrl: string;
|
|
65
|
+
readonly policies?: IDocumentStorageServicePolicies | undefined;
|
|
66
|
+
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
67
|
+
downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
|
|
68
|
+
readonly disposed?: boolean | undefined;
|
|
69
|
+
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
70
|
+
};
|
|
71
|
+
} & TBase;
|
|
72
|
+
|
|
73
|
+
// @public (undocumented)
|
|
74
|
+
export const FileStorageDocumentName = "FileStorageDocId";
|
|
75
|
+
|
|
76
|
+
// @public
|
|
77
|
+
export class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
|
|
78
|
+
constructor(path: string, versionName?: string | undefined);
|
|
79
|
+
// (undocumented)
|
|
80
|
+
protected docTree: api.ISnapshotTree | null;
|
|
81
|
+
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
82
|
+
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
83
|
+
// (undocumented)
|
|
84
|
+
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// @public (undocumented)
|
|
88
|
+
export const FluidFetchReaderFileSnapshotWriter: {
|
|
89
|
+
new (...args: any[]): {
|
|
90
|
+
blobsWriter: Map<string, ArrayBufferLike>;
|
|
91
|
+
latestWriterTree?: api.ISnapshotTree | undefined;
|
|
92
|
+
docId?: string | undefined;
|
|
93
|
+
reset(): void;
|
|
94
|
+
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
95
|
+
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
96
|
+
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
97
|
+
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
98
|
+
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
99
|
+
buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
|
|
100
|
+
repositoryUrl: string;
|
|
101
|
+
readonly policies?: IDocumentStorageServicePolicies | undefined;
|
|
102
|
+
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
103
|
+
downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
|
|
104
|
+
readonly disposed?: boolean | undefined;
|
|
105
|
+
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
106
|
+
};
|
|
107
|
+
} & typeof FluidFetchReader;
|
|
108
|
+
|
|
109
|
+
// @public (undocumented)
|
|
110
|
+
export interface ISnapshotWriterStorage extends IDocumentStorageService {
|
|
111
|
+
// (undocumented)
|
|
112
|
+
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
113
|
+
// (undocumented)
|
|
114
|
+
reset(): void;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// @public (undocumented)
|
|
118
|
+
export type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
|
|
119
|
+
|
|
120
|
+
// @public
|
|
121
|
+
export class Replayer {
|
|
122
|
+
constructor(deltaConnection: ReplayFileDeltaConnection, documentStorageService: FileDeltaStorageService);
|
|
123
|
+
// (undocumented)
|
|
124
|
+
get currentReplayedOp(): number;
|
|
125
|
+
set currentReplayedOp(op: number);
|
|
126
|
+
// (undocumented)
|
|
127
|
+
get ops(): readonly Readonly<ISequencedDocumentMessage>[];
|
|
128
|
+
replay(replayTo: number): number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// @public (undocumented)
|
|
132
|
+
export class ReplayFileDeltaConnection extends TypedEventEmitter<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable {
|
|
133
|
+
constructor(details: IConnected, documentDeltaStorageService: FileDeltaStorageService);
|
|
134
|
+
// (undocumented)
|
|
135
|
+
get claims(): ITokenClaims;
|
|
136
|
+
// (undocumented)
|
|
137
|
+
get clientId(): string;
|
|
138
|
+
static create(documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection>;
|
|
139
|
+
// (undocumented)
|
|
140
|
+
details: IConnected;
|
|
141
|
+
// (undocumented)
|
|
142
|
+
dispose(): void;
|
|
143
|
+
// (undocumented)
|
|
144
|
+
get disposed(): boolean;
|
|
145
|
+
// (undocumented)
|
|
146
|
+
get existing(): boolean;
|
|
147
|
+
// (undocumented)
|
|
148
|
+
getReplayer(): Replayer;
|
|
149
|
+
// (undocumented)
|
|
150
|
+
get initialClients(): ISignalClient[];
|
|
151
|
+
// (undocumented)
|
|
152
|
+
get initialMessages(): ISequencedDocumentMessage[];
|
|
153
|
+
// (undocumented)
|
|
154
|
+
get initialSignals(): ISignalMessage[];
|
|
155
|
+
// (undocumented)
|
|
156
|
+
readonly maxMessageSize: number;
|
|
157
|
+
// (undocumented)
|
|
158
|
+
get mode(): ConnectionMode;
|
|
159
|
+
// (undocumented)
|
|
160
|
+
get serviceConfiguration(): IClientConfiguration;
|
|
161
|
+
// (undocumented)
|
|
162
|
+
submit(documentMessages: IDocumentMessage[]): void;
|
|
163
|
+
// (undocumented)
|
|
164
|
+
submitSignal(message: any): Promise<void>;
|
|
165
|
+
// (undocumented)
|
|
166
|
+
get version(): string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// (No @packageDocumentation comment for this package)
|
|
170
|
+
|
|
171
|
+
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE9F,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAC;AAI9F,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAK1D;;GAEG;AACH,qBAAa,gBACZ,SAAQ,8BACR,YAAW,uBAAuB;
|
|
1
|
+
{"version":3,"file":"fileDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE9F,OAAO,KAAK,GAAG,MAAM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AChB,eAAe,GACtB,QAAQ,MAAM,CAAC;gCAcmB,IAAI,aAAa,GAAG,QAAQ,IAAI,KAAK,CAAC;;;;;;;;SA8B3E,CAAC;AAcH,eAAO,MAAM,kCAAkC;kBAjHD,GAAG,EAAE;;;;;oCAcd,aAAa,GAAG,IAAI;sBAI5B,MAAM,GAAG,QAAQ,eAAe,CAAC;+BASxB,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;kCAkBnD,IAAI,QAAQ,GAAG,QAAQ,IAAI,aAAa,GAAG,IAAI,CAAC;0CAQ7E,IAAI,YAAY,WAChB,eAAe,GACtB,QAAQ,MAAM,CAAC;gCAcmB,IAAI,aAAa,GAAG,QAAQ,IAAI,KAAK,CAAC;;;;;;;;2BA4CqB,CAAC"}
|
|
@@ -94,7 +94,7 @@ class FluidFetchReader extends replay_driver_1.ReadDocumentStorageServiceBase {
|
|
|
94
94
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
95
95
|
async getVersions(versionId, count) {
|
|
96
96
|
if (versionId === exports.FileStorageDocumentName || versionId === null) {
|
|
97
|
-
if (this.docTree || this.versionName !== undefined) {
|
|
97
|
+
if (this.docTree !== null || this.versionName !== undefined) {
|
|
98
98
|
return [{ id: "latest", treeId: FileStorageVersionTreeId }];
|
|
99
99
|
}
|
|
100
100
|
// Started with ops - return empty set.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,+DAA8D;AAC9D,2DAAoD;AAEpD,+DAAoG;AACpG,0EAA4D;AAC5D,iEAA8F;AAE9F,iDAAiD;AACjD,gFAAgF;AACnE,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,G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AC,IAAI;gBACxB,KAAK,EAAE,OAAO;aACd,CAAC,CAAC;SACH;QAED,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAG,IAAA,6BAAc,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChD,MAAM,IAAI,GAAc;gBACvB,QAAQ;gBACR,QAAQ,EAAE,OAAO;aACjB,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI;gBACvB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI;gBACxB,KAAK,EAAE,IAAI;aACX,CAAC,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC;AAlGU,QAAA,8BAA8B,kCAkGxC;AAEH,SAAS,iBAAiB,CAAC,IAAe;IACzC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;YACrC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC9B;KACD;IACD,IAAA,mBAAM,EACL,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EACzC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,OAAO,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC;AACY,QAAA,kCAAkC,GAAG,IAAA,sCAA8B,EAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { buildSnapshotTree, convertSummaryTreeToSnapshotITree } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IFileSnapshot, ReadDocumentStorageServiceBase } from \"@fluidframework/replay-driver\";\n\n// This ID is used by replay tool as Document Id.\n// We leverage it to figure out when container is asking for root document tree.\nexport const FileStorageDocumentName = \"FileStorageDocId\"; // Some unique document name\n\n// Tree ID use to communicate between getVersions() & getSnapshotTree() that IVersion is ours.\nconst FileStorageVersionTreeId = \"FileStorageTreeId\";\n\n/**\n * Document storage service for the file driver.\n */\nexport class FluidFetchReader\n\textends ReadDocumentStorageServiceBase\n\timplements IDocumentStorageService\n{\n\tprotected docTree: api.ISnapshotTree | null = null;\n\n\tconstructor(private readonly path: string, private readonly versionName?: string) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Read the file and returns the snapshot tree.\n\t * @param version - The version contains the path of the file which contains the snapshot tree.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\tassert(version !== null, 0x092 /* \"version input for reading snapshot tree is null!\" */);\n\t\tassert(\n\t\t\t!version || version.treeId === FileStorageVersionTreeId,\n\t\t\t0x093 /* \"invalid version input for reading snapshot tree!\" */,\n\t\t);\n\n\t\tlet filename: string;\n\t\tlet rootTree = false;\n\t\tif (!version || version.id === \"latest\") {\n\t\t\tif (this.docTree) {\n\t\t\t\treturn this.docTree;\n\t\t\t}\n\t\t\tif (this.versionName === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\trootTree = true;\n\t\t\tfilename = `${this.path}/${this.versionName}/tree.json`;\n\t\t} else {\n\t\t\tfilename = `${this.path}/${this.versionName}/${version.id}.json`;\n\t\t}\n\n\t\tif (!fs.existsSync(filename)) {\n\t\t\tthrow new Error(`Can't find file ${filename}`);\n\t\t}\n\t\tconst data = fs.readFileSync(filename);\n\t\tconst tree = JSON.parse(data.toString(\"utf-8\"));\n\t\tif (rootTree) {\n\t\t\tthis.docTree = tree;\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Gets the path of the snapshot tree to be read.\n\t * @param versionId - version ID.\n\t * @param count - Number of versions to be returned.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\tif (versionId === FileStorageDocumentName || versionId === null) {\n\t\t\tif (this.docTree || this.versionName !== undefined) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\t\t\t// Started with ops - return empty set.\n\t\t\treturn [];\n\t\t} else if (this.versionName !== undefined) {\n\t\t\tassert(!!this.docTree, 0x094 /* \"Missing snapshot tree!\" */);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: FileStorageVersionTreeId,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tthrow new Error(`Unknown version: ${versionId}`);\n\t}\n\n\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\tif (this.versionName !== undefined) {\n\t\t\tconst fileName = `${this.path}/${this.versionName}/${sha}`;\n\t\t\tif (fs.existsSync(fileName)) {\n\t\t\t\tconst data = fs.readFileSync(fileName);\n\t\t\t\treturn data;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Can't find blob ${sha}`);\n\t}\n}\n\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n\tonSnapshotHandler(snapshot: IFileSnapshot): void;\n\treset(): void;\n}\n\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\nexport const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(Base: TBase) =>\n\tclass extends Base implements ISnapshotWriterStorage {\n\t\t// Note: if variable name has same name as in base class, it overrides it!\n\t\tpublic blobsWriter = new Map<string, ArrayBufferLike>();\n\t\tpublic latestWriterTree?: api.ISnapshotTree;\n\t\tpublic docId?: string;\n\n\t\tpublic reset() {\n\t\t\tthis.blobsWriter = new Map<string, ArrayBufferLike>();\n\t\t\tthis.latestWriterTree = undefined;\n\t\t\tthis.docId = undefined;\n\t\t}\n\n\t\tpublic onSnapshotHandler(snapshot: IFileSnapshot): void {\n\t\t\tthrow new Error(\"onSnapshotHandler is not setup! Please provide your handler!\");\n\t\t}\n\n\t\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\t\tconst blob = this.blobsWriter.get(sha);\n\t\t\tif (blob !== undefined) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn super.readBlob(sha);\n\t\t}\n\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\t\t// If we already saved document, that means we are getting here because of snapshot generation.\n\t\t\t// Not returning tree ensures that ContainerRuntime.snapshot() would regenerate subtrees for\n\t\t\t// each unchanged data store.\n\t\t\t// If we want to change that, we would need to capture docId on first call and return this.latestWriterTree\n\t\t\t// when latest is requested.\n\t\t\tif (this.latestWriterTree && (this.docId === versionId || versionId === null)) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\n\t\t\tif (this.docId === undefined && versionId !== null) {\n\t\t\t\tthis.docId = versionId;\n\t\t\t}\n\n\t\t\treturn super.getVersions(versionId, count);\n\t\t}\n\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\t\tif (this.latestWriterTree && (!version || version.id === \"latest\")) {\n\t\t\t\treturn this.latestWriterTree;\n\t\t\t}\n\t\t\treturn super.getSnapshotTree(version);\n\t\t}\n\n\t\tpublic async uploadSummaryWithContext(\n\t\t\tsummary: api.ISummaryTree,\n\t\t\tcontext: ISummaryContext,\n\t\t): Promise<string> {\n\t\t\tconst tree = convertSummaryTreeToSnapshotITree(summary);\n\n\t\t\t// Remove tree IDs for easier comparison of snapshots\n\t\t\tdelete tree.id;\n\t\t\tremoveNullTreeIds(tree);\n\n\t\t\tthis.latestWriterTree = buildSnapshotTree(tree.entries, this.blobsWriter);\n\n\t\t\tconst fileSnapshot: IFileSnapshot = { tree, commits: {} };\n\t\t\tthis.onSnapshotHandler(fileSnapshot);\n\t\t\treturn \"testHandleId\";\n\t\t}\n\n\t\tpublic async buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree> {\n\t\t\tconst tree: api.ITree = { entries: [] };\n\n\t\t\tfor (const subTreeId of Object.keys(snapshotTree.trees)) {\n\t\t\t\tconst subTree = await this.buildTree(snapshotTree.trees[subTreeId]);\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.Directory,\n\t\t\t\t\tpath: subTreeId,\n\t\t\t\t\ttype: api.TreeEntry.Tree,\n\t\t\t\t\tvalue: subTree,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const blobName of Object.keys(snapshotTree.blobs)) {\n\t\t\t\tconst buffer = await this.readBlob(snapshotTree.blobs[blobName]);\n\t\t\t\tconst contents = bufferToString(buffer, \"utf8\");\n\t\t\t\tconst blob: api.IBlob = {\n\t\t\t\t\tcontents,\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t};\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.File,\n\t\t\t\t\tpath: blobName,\n\t\t\t\t\ttype: api.TreeEntry.Blob,\n\t\t\t\t\tvalue: blob,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn tree;\n\t\t}\n\t};\n\nfunction removeNullTreeIds(tree: api.ITree) {\n\tfor (const node of tree.entries) {\n\t\tif (node.type === api.TreeEntry.Tree) {\n\t\t\tremoveNullTreeIds(node.value);\n\t\t}\n\t}\n\tassert(\n\t\ttree.id === undefined || tree.id === null,\n\t\t0x096 /* \"Trying to remove valid tree IDs in removeNullTreeIds()!\" */,\n\t);\n\tdelete tree.id;\n}\nexport const FluidFetchReaderFileSnapshotWriter = FileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
|
|
1
|
+
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,+DAA8D;AAC9D,2DAAoD;AAEpD,+DAAoG;AACpG,0EAA4D;AAC5D,iEAA8F;AAE9F,iDAAiD;AACjD,gFAAgF;AACnE,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAa,gBACZ,SAAQ,8CAA8B;IAKtC,YACkB,IAAY,EACZ,WAAoB;QAErC,KAAK,EAAE,CAAC;QAHS,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAS;QAJ5B,YAAO,GAA6B,IAAI,CAAC;IAOnD,CAAC;IAED;;;OAGG;IACH,kDAAkD;IAC3C,KAAK,CAAC,eAAe,CAAC,OAAsB;QAClD,IAAA,mBAAM,EAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACzF,IAAA,mBAAM,EACL,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,wBAAwB,EACvD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QAEF,IAAI,QAAgB,CAAC;QACrB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ,EAAE;YACxC,IAAI,IAAI,CAAC,OAAO,EAAE;gBACjB,OAAO,IAAI,CAAC,OAA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AkGxC;AAEH,SAAS,iBAAiB,CAAC,IAAe;IACzC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;YACrC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC9B;KACD;IACD,IAAA,mBAAM,EACL,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EACzC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,OAAO,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC;AACY,QAAA,kCAAkC,GAAG,IAAA,sCAA8B,EAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { buildSnapshotTree, convertSummaryTreeToSnapshotITree } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IFileSnapshot, ReadDocumentStorageServiceBase } from \"@fluidframework/replay-driver\";\n\n// This ID is used by replay tool as Document Id.\n// We leverage it to figure out when container is asking for root document tree.\nexport const FileStorageDocumentName = \"FileStorageDocId\"; // Some unique document name\n\n// Tree ID use to communicate between getVersions() & getSnapshotTree() that IVersion is ours.\nconst FileStorageVersionTreeId = \"FileStorageTreeId\";\n\n/**\n * Document storage service for the file driver.\n */\nexport class FluidFetchReader\n\textends ReadDocumentStorageServiceBase\n\timplements IDocumentStorageService\n{\n\tprotected docTree: api.ISnapshotTree | null = null;\n\n\tconstructor(\n\t\tprivate readonly path: string,\n\t\tprivate readonly versionName?: string,\n\t) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Read the file and returns the snapshot tree.\n\t * @param version - The version contains the path of the file which contains the snapshot tree.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\tassert(version !== null, 0x092 /* \"version input for reading snapshot tree is null!\" */);\n\t\tassert(\n\t\t\t!version || version.treeId === FileStorageVersionTreeId,\n\t\t\t0x093 /* \"invalid version input for reading snapshot tree!\" */,\n\t\t);\n\n\t\tlet filename: string;\n\t\tlet rootTree = false;\n\t\tif (!version || version.id === \"latest\") {\n\t\t\tif (this.docTree) {\n\t\t\t\treturn this.docTree;\n\t\t\t}\n\t\t\tif (this.versionName === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\trootTree = true;\n\t\t\tfilename = `${this.path}/${this.versionName}/tree.json`;\n\t\t} else {\n\t\t\tfilename = `${this.path}/${this.versionName}/${version.id}.json`;\n\t\t}\n\n\t\tif (!fs.existsSync(filename)) {\n\t\t\tthrow new Error(`Can't find file ${filename}`);\n\t\t}\n\t\tconst data = fs.readFileSync(filename);\n\t\tconst tree = JSON.parse(data.toString(\"utf-8\"));\n\t\tif (rootTree) {\n\t\t\tthis.docTree = tree;\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Gets the path of the snapshot tree to be read.\n\t * @param versionId - version ID.\n\t * @param count - Number of versions to be returned.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\tif (versionId === FileStorageDocumentName || versionId === null) {\n\t\t\tif (this.docTree !== null || this.versionName !== undefined) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\t\t\t// Started with ops - return empty set.\n\t\t\treturn [];\n\t\t} else if (this.versionName !== undefined) {\n\t\t\tassert(!!this.docTree, 0x094 /* \"Missing snapshot tree!\" */);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: FileStorageVersionTreeId,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tthrow new Error(`Unknown version: ${versionId}`);\n\t}\n\n\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\tif (this.versionName !== undefined) {\n\t\t\tconst fileName = `${this.path}/${this.versionName}/${sha}`;\n\t\t\tif (fs.existsSync(fileName)) {\n\t\t\t\tconst data = fs.readFileSync(fileName);\n\t\t\t\treturn data;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Can't find blob ${sha}`);\n\t}\n}\n\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n\tonSnapshotHandler(snapshot: IFileSnapshot): void;\n\treset(): void;\n}\n\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\nexport const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(Base: TBase) =>\n\tclass extends Base implements ISnapshotWriterStorage {\n\t\t// Note: if variable name has same name as in base class, it overrides it!\n\t\tpublic blobsWriter = new Map<string, ArrayBufferLike>();\n\t\tpublic latestWriterTree?: api.ISnapshotTree;\n\t\tpublic docId?: string;\n\n\t\tpublic reset() {\n\t\t\tthis.blobsWriter = new Map<string, ArrayBufferLike>();\n\t\t\tthis.latestWriterTree = undefined;\n\t\t\tthis.docId = undefined;\n\t\t}\n\n\t\tpublic onSnapshotHandler(snapshot: IFileSnapshot): void {\n\t\t\tthrow new Error(\"onSnapshotHandler is not setup! Please provide your handler!\");\n\t\t}\n\n\t\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\t\tconst blob = this.blobsWriter.get(sha);\n\t\t\tif (blob !== undefined) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn super.readBlob(sha);\n\t\t}\n\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\t\t// If we already saved document, that means we are getting here because of snapshot generation.\n\t\t\t// Not returning tree ensures that ContainerRuntime.snapshot() would regenerate subtrees for\n\t\t\t// each unchanged data store.\n\t\t\t// If we want to change that, we would need to capture docId on first call and return this.latestWriterTree\n\t\t\t// when latest is requested.\n\t\t\tif (this.latestWriterTree && (this.docId === versionId || versionId === null)) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\n\t\t\tif (this.docId === undefined && versionId !== null) {\n\t\t\t\tthis.docId = versionId;\n\t\t\t}\n\n\t\t\treturn super.getVersions(versionId, count);\n\t\t}\n\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\t\tif (this.latestWriterTree && (!version || version.id === \"latest\")) {\n\t\t\t\treturn this.latestWriterTree;\n\t\t\t}\n\t\t\treturn super.getSnapshotTree(version);\n\t\t}\n\n\t\tpublic async uploadSummaryWithContext(\n\t\t\tsummary: api.ISummaryTree,\n\t\t\tcontext: ISummaryContext,\n\t\t): Promise<string> {\n\t\t\tconst tree = convertSummaryTreeToSnapshotITree(summary);\n\n\t\t\t// Remove tree IDs for easier comparison of snapshots\n\t\t\tdelete tree.id;\n\t\t\tremoveNullTreeIds(tree);\n\n\t\t\tthis.latestWriterTree = buildSnapshotTree(tree.entries, this.blobsWriter);\n\n\t\t\tconst fileSnapshot: IFileSnapshot = { tree, commits: {} };\n\t\t\tthis.onSnapshotHandler(fileSnapshot);\n\t\t\treturn \"testHandleId\";\n\t\t}\n\n\t\tpublic async buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree> {\n\t\t\tconst tree: api.ITree = { entries: [] };\n\n\t\t\tfor (const subTreeId of Object.keys(snapshotTree.trees)) {\n\t\t\t\tconst subTree = await this.buildTree(snapshotTree.trees[subTreeId]);\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.Directory,\n\t\t\t\t\tpath: subTreeId,\n\t\t\t\t\ttype: api.TreeEntry.Tree,\n\t\t\t\t\tvalue: subTree,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const blobName of Object.keys(snapshotTree.blobs)) {\n\t\t\t\tconst buffer = await this.readBlob(snapshotTree.blobs[blobName]);\n\t\t\t\tconst contents = bufferToString(buffer, \"utf8\");\n\t\t\t\tconst blob: api.IBlob = {\n\t\t\t\t\tcontents,\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t};\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.File,\n\t\t\t\t\tpath: blobName,\n\t\t\t\t\ttype: api.TreeEntry.Blob,\n\t\t\t\t\tvalue: blob,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn tree;\n\t\t}\n\t};\n\nfunction removeNullTreeIds(tree: api.ITree) {\n\tfor (const node of tree.entries) {\n\t\tif (node.type === api.TreeEntry.Tree) {\n\t\t\tremoveNullTreeIds(node.value);\n\t\t}\n\t}\n\tassert(\n\t\ttree.id === undefined || tree.id === null,\n\t\t0x096 /* \"Trying to remove valid tree IDs in removeNullTreeIds()!\" */,\n\t);\n\tdelete tree.id;\n}\nexport const FluidFetchReaderFileSnapshotWriter = FileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
|
package/dist/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/file-driver",
|
|
3
|
-
"version": "2.0.0-internal.7.
|
|
3
|
+
"version": "2.0.0-internal.7.2.0",
|
|
4
4
|
"description": "A driver that reads/write from/to local file storage.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,25 +14,24 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.7.
|
|
18
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.
|
|
19
|
-
"@fluidframework/core-utils": ">=2.0.0-internal.7.
|
|
20
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.
|
|
21
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.7.
|
|
17
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
18
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
19
|
+
"@fluidframework/core-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
20
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
21
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0",
|
|
22
22
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
23
|
-
"@fluidframework/replay-driver": ">=2.0.0-internal.7.
|
|
23
|
+
"@fluidframework/replay-driver": ">=2.0.0-internal.7.2.0 <2.0.0-internal.7.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@fluid-tools/build-cli": "^0.
|
|
27
|
-
"@fluidframework/build-common": "^2.0.
|
|
28
|
-
"@fluidframework/build-tools": "^0.
|
|
29
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
30
|
-
"@fluidframework/file-driver-previous": "npm:@fluidframework/file-driver@2.0.0-internal.
|
|
26
|
+
"@fluid-tools/build-cli": "^0.26.1",
|
|
27
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
28
|
+
"@fluidframework/build-tools": "^0.26.1",
|
|
29
|
+
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
30
|
+
"@fluidframework/file-driver-previous": "npm:@fluidframework/file-driver@2.0.0-internal.7.1.0",
|
|
31
31
|
"@microsoft/api-extractor": "^7.37.0",
|
|
32
32
|
"@types/node": "^16.18.38",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"prettier": "~2.6.2",
|
|
33
|
+
"eslint": "~8.50.0",
|
|
34
|
+
"prettier": "~3.0.3",
|
|
36
35
|
"rimraf": "^4.4.0",
|
|
37
36
|
"typescript": "~5.1.6"
|
|
38
37
|
},
|
|
@@ -45,21 +44,14 @@
|
|
|
45
44
|
}
|
|
46
45
|
},
|
|
47
46
|
"typeValidation": {
|
|
48
|
-
"broken": {
|
|
49
|
-
"ClassDeclaration_FileDeltaStorageService": {
|
|
50
|
-
"backCompat": false
|
|
51
|
-
},
|
|
52
|
-
"ClassDeclaration_Replayer": {
|
|
53
|
-
"backCompat": false
|
|
54
|
-
}
|
|
55
|
-
}
|
|
47
|
+
"broken": {}
|
|
56
48
|
},
|
|
57
49
|
"scripts": {
|
|
58
50
|
"build": "fluid-build . --task build",
|
|
59
51
|
"build:compile": "fluid-build . --task compile",
|
|
60
|
-
"build:docs": "api-extractor run --local
|
|
61
|
-
"ci:build:docs": "api-extractor run
|
|
62
|
-
"clean": "rimraf --glob
|
|
52
|
+
"build:docs": "api-extractor run --local",
|
|
53
|
+
"ci:build:docs": "api-extractor run",
|
|
54
|
+
"clean": "rimraf --glob dist lib \"*.tsbuildinfo\" \"*.build.log\" _api-extractor-temp",
|
|
63
55
|
"eslint": "eslint --format stylish src",
|
|
64
56
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
65
57
|
"format": "npm run prettier:fix",
|
|
@@ -27,7 +27,10 @@ export class FluidFetchReader
|
|
|
27
27
|
{
|
|
28
28
|
protected docTree: api.ISnapshotTree | null = null;
|
|
29
29
|
|
|
30
|
-
constructor(
|
|
30
|
+
constructor(
|
|
31
|
+
private readonly path: string,
|
|
32
|
+
private readonly versionName?: string,
|
|
33
|
+
) {
|
|
31
34
|
super();
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -78,7 +81,7 @@ export class FluidFetchReader
|
|
|
78
81
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
79
82
|
public async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {
|
|
80
83
|
if (versionId === FileStorageDocumentName || versionId === null) {
|
|
81
|
-
if (this.docTree || this.versionName !== undefined) {
|
|
84
|
+
if (this.docTree !== null || this.versionName !== undefined) {
|
|
82
85
|
return [{ id: "latest", treeId: FileStorageVersionTreeId }];
|
|
83
86
|
}
|
|
84
87
|
// Started with ops - return empty set.
|