@fluidframework/file-driver 2.0.0-rc.4.0.6 → 2.0.0-rc.5.0.1
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/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor.json +1 -1
- package/api-report/file-driver.alpha.api.md +41 -0
- package/api-report/file-driver.beta.api.md +41 -0
- package/api-report/file-driver.public.api.md +41 -0
- package/biome.jsonc +4 -0
- package/dist/fileDeltaStorageService.d.ts +4 -5
- package/dist/fileDeltaStorageService.d.ts.map +1 -1
- package/dist/fileDeltaStorageService.js.map +1 -1
- package/dist/fileDocumentDeltaConnection.d.ts +2 -2
- package/dist/fileDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/fileDocumentDeltaConnection.js +3 -3
- package/dist/fileDocumentDeltaConnection.js.map +1 -1
- package/dist/fileDocumentService.d.ts +8 -8
- package/dist/fileDocumentService.d.ts.map +1 -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.map +1 -1
- package/dist/fileDocumentStorageService.d.ts +19 -19
- package/dist/fileDocumentStorageService.d.ts.map +1 -1
- package/dist/fileDocumentStorageService.js +11 -34
- package/dist/fileDocumentStorageService.js.map +1 -1
- package/lib/fileDeltaStorageService.d.ts +4 -5
- package/lib/fileDeltaStorageService.d.ts.map +1 -1
- package/lib/fileDeltaStorageService.js.map +1 -1
- package/lib/fileDocumentDeltaConnection.d.ts +2 -2
- package/lib/fileDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/fileDocumentDeltaConnection.js +2 -2
- package/lib/fileDocumentDeltaConnection.js.map +1 -1
- package/lib/fileDocumentService.d.ts +8 -8
- package/lib/fileDocumentService.d.ts.map +1 -1
- package/lib/fileDocumentService.js.map +1 -1
- package/lib/fileDocumentServiceFactory.d.ts +1 -1
- package/lib/fileDocumentServiceFactory.d.ts.map +1 -1
- package/lib/fileDocumentServiceFactory.js.map +1 -1
- package/lib/fileDocumentStorageService.d.ts +19 -19
- package/lib/fileDocumentStorageService.d.ts.map +1 -1
- package/lib/fileDocumentStorageService.js +6 -6
- package/lib/fileDocumentStorageService.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +28 -18
- package/src/fileDeltaStorageService.ts +10 -7
- package/src/fileDocumentDeltaConnection.ts +4 -6
- package/src/fileDocumentService.ts +17 -10
- package/src/fileDocumentServiceFactory.ts +1 -1
- package/src/fileDocumentStorageService.ts +25 -18
- package/tsconfig.json +2 -0
- package/tsdoc.json +4 -0
- package/api-report/file-driver.api.md +0 -173
|
@@ -3,29 +3,6 @@
|
|
|
3
3
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
-
}) : function(o, v) {
|
|
20
|
-
o["default"] = v;
|
|
21
|
-
});
|
|
22
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
-
if (mod && mod.__esModule) return mod;
|
|
24
|
-
var result = {};
|
|
25
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
-
__setModuleDefault(result, mod);
|
|
27
|
-
return result;
|
|
28
|
-
};
|
|
29
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
30
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
31
8
|
};
|
|
@@ -34,9 +11,9 @@ exports.FluidFetchReaderFileSnapshotWriter = exports.FileSnapshotWriterClassFact
|
|
|
34
11
|
const fs_1 = __importDefault(require("fs"));
|
|
35
12
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
36
13
|
const internal_1 = require("@fluidframework/core-utils/internal");
|
|
37
|
-
const internal_2 = require("@fluidframework/driver-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
14
|
+
const internal_2 = require("@fluidframework/driver-definitions/internal");
|
|
15
|
+
const internal_3 = require("@fluidframework/driver-utils/internal");
|
|
16
|
+
const internal_4 = require("@fluidframework/replay-driver/internal");
|
|
40
17
|
// This ID is used by replay tool as Document Id.
|
|
41
18
|
// We leverage it to figure out when container is asking for root document tree.
|
|
42
19
|
/**
|
|
@@ -49,7 +26,7 @@ const FileStorageVersionTreeId = "FileStorageTreeId";
|
|
|
49
26
|
* Document storage service for the file driver.
|
|
50
27
|
* @internal
|
|
51
28
|
*/
|
|
52
|
-
class FluidFetchReader extends
|
|
29
|
+
class FluidFetchReader extends internal_4.ReadDocumentStorageServiceBase {
|
|
53
30
|
constructor(path, versionName) {
|
|
54
31
|
super();
|
|
55
32
|
this.path = path;
|
|
@@ -174,11 +151,11 @@ const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
174
151
|
return super.getSnapshotTree(version);
|
|
175
152
|
}
|
|
176
153
|
async uploadSummaryWithContext(summary, context) {
|
|
177
|
-
const tree = (0,
|
|
154
|
+
const tree = (0, internal_3.convertSummaryTreeToSnapshotITree)(summary);
|
|
178
155
|
// Remove tree IDs for easier comparison of snapshots
|
|
179
156
|
delete tree.id;
|
|
180
157
|
removeNullTreeIds(tree);
|
|
181
|
-
this.latestWriterTree = (0,
|
|
158
|
+
this.latestWriterTree = (0, internal_3.buildSnapshotTree)(tree.entries, this.blobsWriter);
|
|
182
159
|
const fileSnapshot = { tree, commits: {} };
|
|
183
160
|
this.onSnapshotHandler(fileSnapshot);
|
|
184
161
|
return "testHandleId";
|
|
@@ -188,9 +165,9 @@ const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
188
165
|
for (const subTreeId of Object.keys(snapshotTree.trees)) {
|
|
189
166
|
const subTree = await this.buildTree(snapshotTree.trees[subTreeId]);
|
|
190
167
|
tree.entries.push({
|
|
191
|
-
mode:
|
|
168
|
+
mode: internal_2.FileMode.Directory,
|
|
192
169
|
path: subTreeId,
|
|
193
|
-
type:
|
|
170
|
+
type: internal_2.TreeEntry.Tree,
|
|
194
171
|
value: subTree,
|
|
195
172
|
});
|
|
196
173
|
}
|
|
@@ -202,9 +179,9 @@ const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
202
179
|
encoding: "utf-8",
|
|
203
180
|
};
|
|
204
181
|
tree.entries.push({
|
|
205
|
-
mode:
|
|
182
|
+
mode: internal_2.FileMode.File,
|
|
206
183
|
path: blobName,
|
|
207
|
-
type:
|
|
184
|
+
type: internal_2.TreeEntry.Blob,
|
|
208
185
|
value: blob,
|
|
209
186
|
});
|
|
210
187
|
}
|
|
@@ -214,7 +191,7 @@ const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
214
191
|
exports.FileSnapshotWriterClassFactory = FileSnapshotWriterClassFactory;
|
|
215
192
|
function removeNullTreeIds(tree) {
|
|
216
193
|
for (const node of tree.entries) {
|
|
217
|
-
if (node.type ===
|
|
194
|
+
if (node.type === internal_2.TreeEntry.Tree) {
|
|
218
195
|
removeNullTreeIds(node.value);
|
|
219
196
|
}
|
|
220
197
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AAEpB,+DAA8D;AAC9D,kEAA6D;AAK7D,oEAG+C;AAC/C,0EAA4D;AAC5D,qEAGgD;AAEhD,iDAAiD;AACjD,gFAAgF;AAChF;;GAEG;AACU,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAa,gBACZ,SAAQ,yCAA8B;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,iBAAM,EAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACzF,IAAA,iBAAM,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,OAAO,CAAC;aACpB;YACD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;gBACnC,OAAO,IAAI,CAAC;aACZ;YACD,QAAQ,GAAG,IAAI,C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IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;YACrC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC9B;KACD;IACD,IAAA,iBAAM,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;AACD;;GAEG;AACU,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\";\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tbuildSnapshotTree,\n\tconvertSummaryTreeToSnapshotITree,\n} from \"@fluidframework/driver-utils/internal\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport {\n\tIFileSnapshot,\n\tReadDocumentStorageServiceBase,\n} from \"@fluidframework/replay-driver/internal\";\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.\n/**\n * @internal\n */\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 * @internal\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\n/**\n * @internal\n */\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n\tonSnapshotHandler(snapshot: IFileSnapshot): void;\n\treset(): void;\n}\n\n/**\n * @internal\n */\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\n/**\n * @internal\n */\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}\n/**\n * @internal\n */\nexport const FluidFetchReaderFileSnapshotWriter = FileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
|
|
1
|
+
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AAEpB,+DAA8D;AAC9D,kEAA6D;AAE7D,0EASqD;AACrD,oEAG+C;AAC/C,qEAGgD;AAEhD,iDAAiD;AACjD,gFAAgF;AAChF;;GAEG;AACU,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAa,gBACZ,SAAQ,yCAA8B;IAKtC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AAkC,GAC9C,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\";\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tISnapshotTree,\n\tIVersion,\n\tITree,\n\tFileMode,\n\tTreeEntry,\n\tIBlob,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tbuildSnapshotTree,\n\tconvertSummaryTreeToSnapshotITree,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIFileSnapshot,\n\tReadDocumentStorageServiceBase,\n} from \"@fluidframework/replay-driver/internal\";\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.\n/**\n * @internal\n */\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 * @internal\n */\nexport class FluidFetchReader\n\textends ReadDocumentStorageServiceBase\n\timplements IDocumentStorageService\n{\n\tprotected docTree: 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?: IVersion): Promise<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<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\n/**\n * @internal\n */\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n\tonSnapshotHandler(snapshot: IFileSnapshot): void;\n\treset(): void;\n}\n\n/**\n * @internal\n */\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\n/**\n * @internal\n */\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?: 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<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?: IVersion): Promise<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: 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: ISnapshotTree): Promise<ITree> {\n\t\t\tconst tree: 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: FileMode.Directory,\n\t\t\t\t\tpath: subTreeId,\n\t\t\t\t\ttype: 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: 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: FileMode.File,\n\t\t\t\t\tpath: blobName,\n\t\t\t\t\ttype: 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: ITree) {\n\tfor (const node of tree.entries) {\n\t\tif (node.type === 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}\n/**\n * @internal\n */\nexport const FluidFetchReaderFileSnapshotWriter =\n\tFileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDocumentDeltaStorageService, IStream } from "@fluidframework/driver-definitions/internal";
|
|
6
|
-
import * as api from "@fluidframework/protocol-definitions";
|
|
5
|
+
import { IDocumentDeltaStorageService, IStream, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
7
6
|
/**
|
|
8
7
|
* Provides access to the underlying delta storage on the local file storage for file driver.
|
|
9
8
|
* @internal
|
|
@@ -13,14 +12,14 @@ export declare class FileDeltaStorageService implements IDocumentDeltaStorageSer
|
|
|
13
12
|
private readonly messages;
|
|
14
13
|
private lastOps;
|
|
15
14
|
constructor(path: string);
|
|
16
|
-
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<
|
|
17
|
-
get ops(): readonly Readonly<
|
|
15
|
+
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<ISequencedDocumentMessage[]>;
|
|
16
|
+
get ops(): readonly Readonly<ISequencedDocumentMessage>[];
|
|
18
17
|
/**
|
|
19
18
|
* Retrieve ops within the exclusive sequence number range.
|
|
20
19
|
*
|
|
21
20
|
* @param from - First op to be fetched.
|
|
22
21
|
* @param to - Last op to be fetched. This is exclusive.
|
|
23
22
|
*/
|
|
24
|
-
getFromWebSocket(from: number, to: number):
|
|
23
|
+
getFromWebSocket(from: number, to: number): ISequencedDocumentMessage[];
|
|
25
24
|
}
|
|
26
25
|
//# sourceMappingURL=fileDeltaStorageService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,
|
|
1
|
+
{"version":3,"file":"fileDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EACN,4BAA4B,EAC5B,OAAO,EACP,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AAGrD;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,4BAA4B;IAI/D,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD,OAAO,CAAC,OAAO,CAAmC;gBAErB,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,yBAAyB,EAAE,CAAC;IAIvC,IAAW,GAAG,IAAI,SAAS,QAAQ,CAAC,yBAAyB,CAAC,EAAE,CAE/D;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,yBAAyB,EAAE;CAmB9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDeltaStorageService.js","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"fileDeltaStorageService.js","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAM7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAInC,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAFjC,YAAO,GAAgC,EAAE,CAAC;QAGjD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,iDAAiD;QACjD,OAAO,IAAI,EAAE,CAAC;YACb,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,CAAC;gBAC9B,IAAI,OAAO,KAAK,CAAC,EAAE,CAAC;oBACnB,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,YAAY,CAAC,CAAC;gBAC/C,CAAC;gBACD,MAAM;YACP,CAAC;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;QACX,CAAC;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,CAAC;YAC3E,OAAO,EAAE,CAAC;QACX,CAAC;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,CAAC;YAChF,OAAO,IAAI,CAAC,OAAO,CAAC;QACrB,CAAC;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\";\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { emptyMessageStream } from \"@fluidframework/driver-utils/internal\";\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: ISequencedDocumentMessage[];\n\tprivate lastOps: 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<ISequencedDocumentMessage[]> {\n\t\treturn emptyMessageStream;\n\t}\n\n\tpublic get ops(): readonly Readonly<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): 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"]}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
6
|
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { ConnectionMode } from "@fluidframework/driver-definitions";
|
|
8
|
+
import { IDocumentDeltaConnection, IDocumentDeltaConnectionEvents, IClientConfiguration, IConnected, IDocumentMessage, ISignalClient, ITokenClaims, ISequencedDocumentMessage, ISignalMessage } from "@fluidframework/driver-definitions/internal";
|
|
9
9
|
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
10
10
|
/**
|
|
11
11
|
* Replay service used to play ops using the delta connection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"fileDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,cAA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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"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
-
import { ScopeType, } from "@fluidframework/
|
|
6
|
+
import { ScopeType, } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
const MaxBatchDeltas = 2000;
|
|
8
8
|
// Since the replay service never actually sends messages the size below is arbitrary
|
|
9
9
|
const ReplayMaxMessageSize = 16 * 1024;
|
|
@@ -17,7 +17,7 @@ const Claims = {
|
|
|
17
17
|
id: "",
|
|
18
18
|
},
|
|
19
19
|
iat: Math.round(new Date().getTime() / 1000),
|
|
20
|
-
exp: Math.round(new Date().getTime() / 1000) + 60 * 60,
|
|
20
|
+
exp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration
|
|
21
21
|
ver: "1.0",
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"fileDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;G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AC,eAAe,CAAC;IACrC,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;IACpC,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;IACpC,CAAC;IAED,IAAW,oBAAoB;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,gBAAoC;QACjD,0FAA0F;QAC1F,0CAA0C;QAC1C,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,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 { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { ConnectionMode } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISignalClient,\n\tITokenClaims,\n\tScopeType,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\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"]}
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
6
|
+
import { IClient } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { IDocumentServiceEvents, IDocumentService, IResolvedUrl, IDocumentStorageService, IDocumentDeltaConnection, IDocumentDeltaStorageService } from "@fluidframework/driver-definitions/internal";
|
|
8
8
|
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
9
9
|
/**
|
|
10
10
|
* The DocumentService manages the different endpoints for connecting to
|
|
11
11
|
* underlying storage for file document service.
|
|
12
12
|
*/
|
|
13
|
-
export declare class FileDocumentService extends TypedEventEmitter<
|
|
14
|
-
readonly resolvedUrl:
|
|
13
|
+
export declare class FileDocumentService extends TypedEventEmitter<IDocumentServiceEvents> implements IDocumentService {
|
|
14
|
+
readonly resolvedUrl: IResolvedUrl;
|
|
15
15
|
private readonly storage;
|
|
16
16
|
private readonly deltaStorage;
|
|
17
17
|
private readonly deltaConnection;
|
|
18
|
-
constructor(resolvedUrl:
|
|
18
|
+
constructor(resolvedUrl: IResolvedUrl, storage: IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: IDocumentDeltaConnection);
|
|
19
19
|
dispose(): void;
|
|
20
|
-
connectToStorage(): Promise<
|
|
21
|
-
connectToDeltaStorage(): Promise<
|
|
20
|
+
connectToStorage(): Promise<IDocumentStorageService>;
|
|
21
|
+
connectToDeltaStorage(): Promise<IDocumentDeltaStorageService>;
|
|
22
22
|
/**
|
|
23
23
|
* Connects to a delta storage endpoint of provided documentService to get ops and then replaying
|
|
24
24
|
* them so as to mimic a delta stream endpoint.
|
|
@@ -26,6 +26,6 @@ export declare class FileDocumentService extends TypedEventEmitter<api.IDocument
|
|
|
26
26
|
* @param client - Client that connects to socket.
|
|
27
27
|
* @returns returns the delta stream service.
|
|
28
28
|
*/
|
|
29
|
-
connectToDeltaStream(client: IClient): Promise<
|
|
29
|
+
connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection>;
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=fileDocumentService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentService.d.ts","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"fileDocumentService.d.ts","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,wBAAwB,EACxB,4BAA4B,EAC5B,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE;;;GAGG;AACH,qBAAa,mBACZ,SAAQ,iBAAiB,CAAC,sBAAsB,CAEhD,YAAW,gBAAgB;aAGV,WAAW,EAAE,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAHhB,WAAW,EAAE,YAAY,EACxB,OAAO,EAAE,uBAAuB,EAChC,YAAY,EAAE,uBAAuB,EACrC,eAAe,EAAE,wBAAwB;IAKpD,OAAO;IAED,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAIpD,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAI3E;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAGrF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentService.js","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"fileDocumentService.js","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAajE;;;GAGG;AACH,MAAM,OAAO,mBACZ,SAAQ,iBAAyC;IAIjD,YACiB,WAAyB,EACxB,OAAgC,EAChC,YAAqC,EACrC,eAAyC;QAE1D,KAAK,EAAE,CAAC;QALQ,gBAAW,GAAX,WAAW,CAAc;QACxB,YAAO,GAAP,OAAO,CAAyB;QAChC,iBAAY,GAAZ,YAAY,CAAyB;QACrC,oBAAe,GAAf,eAAe,CAA0B;IAG3D,CAAC;IAEM,OAAO,KAAI,CAAC;IAEZ,KAAK,CAAC,gBAAgB;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,qBAAqB;QACjC,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,oBAAoB,CAAC,MAAe;QAChD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentServiceEvents,\n\tIDocumentService,\n\tIResolvedUrl,\n\tIDocumentStorageService,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService.js\";\n\n/**\n * The DocumentService manages the different endpoints for connecting to\n * underlying storage for file document service.\n */\nexport class FileDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\t// eslint-disable-next-line import/namespace\n\timplements IDocumentService\n{\n\tconstructor(\n\t\tpublic readonly resolvedUrl: IResolvedUrl,\n\t\tprivate readonly storage: IDocumentStorageService,\n\t\tprivate readonly deltaStorage: FileDeltaStorageService,\n\t\tprivate readonly deltaConnection: IDocumentDeltaConnection,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic dispose() {}\n\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\treturn this.storage;\n\t}\n\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\treturn this.deltaStorage;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint of provided documentService to get ops and then replaying\n\t * them so as to mimic a delta stream endpoint.\n\t *\n\t * @param client - Client that connects to socket.\n\t * @returns returns the delta stream service.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\treturn this.deltaConnection;\n\t}\n}\n"]}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
6
7
|
import { IDocumentDeltaConnection, IDocumentService, IDocumentServiceFactory, IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
7
|
-
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
9
9
|
/**
|
|
10
10
|
* Factory for creating the file document service. Use this if you want to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"fileDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8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BAA8B,EAC9B,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B;QAE5B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\
|
|
1
|
+
{"version":3,"file":"fileDocumentServiceFactory.js","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,OAAO,0BAA0B;IACtC,YACkB,OAAgC,EAChC,YAAqC,EACrC,eAAyC;QAFzC,YAAO,GAAP,OAAO,CAAyB;QAChC,iBAAY,GAAZ,YAAY,CAAyB;QACrC,oBAAe,GAAf,eAAe,CAA0B;IACxD,CAAC;IAEJ;;;;;OAKG;IACI,KAAK,CAAC,qBAAqB,CACjC,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B;QAE5B,OAAO,IAAI,mBAAmB,CAC7B,WAAW,EACX,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,eAAe,CACpB,CAAC;IACH,CAAC;IAED,8EAA8E;IACvE,KAAK,CAAC,eAAe,CAC3B,gBAA8B,EAC9B,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B;QAE5B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService.js\";\nimport { FileDocumentService } from \"./fileDocumentService.js\";\n\n/**\n * Factory for creating the file document service. Use this if you want to\n * use the local file storage as underlying storage.\n * @internal\n */\nexport class FileDocumentServiceFactory implements IDocumentServiceFactory {\n\tconstructor(\n\t\tprivate readonly storage: IDocumentStorageService,\n\t\tprivate readonly deltaStorage: FileDeltaStorageService,\n\t\tprivate readonly deltaConnection: IDocumentDeltaConnection,\n\t) {}\n\n\t/**\n\t * Creates the file document service if the path exists.\n\t *\n\t * @param fileURL - Path of directory containing ops/snapshots.\n\t * @returns file document service.\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new FileDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.storage,\n\t\t\tthis.deltaStorage,\n\t\t\tthis.deltaConnection,\n\t\t);\n\t}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
5
|
+
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { IDocumentStorageService, ISummaryContext, ISnapshotTree, IVersion, ITree } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
import { IFileSnapshot, ReadDocumentStorageServiceBase } from "@fluidframework/replay-driver/internal";
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
@@ -16,19 +16,19 @@ export declare const FileStorageDocumentName = "FileStorageDocId";
|
|
|
16
16
|
export declare class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
|
|
17
17
|
private readonly path;
|
|
18
18
|
private readonly versionName?;
|
|
19
|
-
protected docTree:
|
|
19
|
+
protected docTree: ISnapshotTree | null;
|
|
20
20
|
constructor(path: string, versionName?: string | undefined);
|
|
21
21
|
/**
|
|
22
22
|
* Read the file and returns the snapshot tree.
|
|
23
23
|
* @param version - The version contains the path of the file which contains the snapshot tree.
|
|
24
24
|
*/
|
|
25
|
-
getSnapshotTree(version?:
|
|
25
|
+
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
26
26
|
/**
|
|
27
27
|
* Gets the path of the snapshot tree to be read.
|
|
28
28
|
* @param versionId - version ID.
|
|
29
29
|
* @param count - Number of versions to be returned.
|
|
30
30
|
*/
|
|
31
|
-
getVersions(versionId: string | null, count: number): Promise<
|
|
31
|
+
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
32
32
|
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
@@ -48,19 +48,19 @@ export type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
|
|
|
48
48
|
export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
|
|
49
49
|
new (...args: any[]): {
|
|
50
50
|
blobsWriter: Map<string, ArrayBufferLike>;
|
|
51
|
-
latestWriterTree?:
|
|
51
|
+
latestWriterTree?: ISnapshotTree | undefined;
|
|
52
52
|
docId?: string | undefined;
|
|
53
53
|
reset(): void;
|
|
54
54
|
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
55
55
|
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
56
|
-
getVersions(versionId: string | null, count: number): Promise<
|
|
57
|
-
getSnapshotTree(version?:
|
|
58
|
-
uploadSummaryWithContext(summary:
|
|
59
|
-
buildTree(snapshotTree:
|
|
56
|
+
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
57
|
+
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
58
|
+
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
59
|
+
buildTree(snapshotTree: ISnapshotTree): Promise<ITree>;
|
|
60
60
|
readonly policies?: import("@fluidframework/driver-definitions/internal").IDocumentStorageServicePolicies | undefined;
|
|
61
61
|
getSnapshot?(snapshotFetchOptions?: import("@fluidframework/driver-definitions/internal").ISnapshotFetchOptions | undefined): Promise<import("@fluidframework/driver-definitions/internal").ISnapshot>;
|
|
62
|
-
createBlob(file: ArrayBufferLike): Promise<
|
|
63
|
-
downloadSummary(handle:
|
|
62
|
+
createBlob(file: ArrayBufferLike): Promise<import("@fluidframework/driver-definitions/internal").ICreateBlobResponse>;
|
|
63
|
+
downloadSummary(handle: import("@fluidframework/driver-definitions").ISummaryHandle): Promise<ISummaryTree>;
|
|
64
64
|
readonly disposed?: boolean | undefined;
|
|
65
65
|
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
66
66
|
};
|
|
@@ -71,19 +71,19 @@ export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstr
|
|
|
71
71
|
export declare const FluidFetchReaderFileSnapshotWriter: {
|
|
72
72
|
new (...args: any[]): {
|
|
73
73
|
blobsWriter: Map<string, ArrayBufferLike>;
|
|
74
|
-
latestWriterTree?:
|
|
74
|
+
latestWriterTree?: ISnapshotTree | undefined;
|
|
75
75
|
docId?: string | undefined;
|
|
76
76
|
reset(): void;
|
|
77
77
|
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
78
78
|
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
79
|
-
getVersions(versionId: string | null, count: number): Promise<
|
|
80
|
-
getSnapshotTree(version?:
|
|
81
|
-
uploadSummaryWithContext(summary:
|
|
82
|
-
buildTree(snapshotTree:
|
|
79
|
+
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
80
|
+
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
81
|
+
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
82
|
+
buildTree(snapshotTree: ISnapshotTree): Promise<ITree>;
|
|
83
83
|
readonly policies?: import("@fluidframework/driver-definitions/internal").IDocumentStorageServicePolicies | undefined;
|
|
84
84
|
getSnapshot?(snapshotFetchOptions?: import("@fluidframework/driver-definitions/internal").ISnapshotFetchOptions | undefined): Promise<import("@fluidframework/driver-definitions/internal").ISnapshot>;
|
|
85
|
-
createBlob(file: ArrayBufferLike): Promise<
|
|
86
|
-
downloadSummary(handle:
|
|
85
|
+
createBlob(file: ArrayBufferLike): Promise<import("@fluidframework/driver-definitions/internal").ICreateBlobResponse>;
|
|
86
|
+
downloadSummary(handle: import("@fluidframework/driver-definitions").ISummaryHandle): Promise<ISummaryTree>;
|
|
87
87
|
readonly disposed?: boolean | undefined;
|
|
88
88
|
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
89
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"fileDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,KAAK,EAIL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ACZ,eAAe,GACtB,QAAQ,MAAM,CAAC;gCAcmB,aAAa,GAAG,QAAQ,KAAK,CAAC;;;;;;;;SA8BnE,CAAC;AAcH;;GAEG;AACH,eAAO,MAAM,kCAAkC;kBAvHD,GAAG,EAAE;;;;;oCAiBd,aAAa,GAAG,IAAI;sBAI5B,MAAM,GAAG,QAAQ,eAAe,CAAC;+BASxB,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,QAAQ,QAAQ,EAAE,CAAC;kCAkB/C,QAAQ,GAAG,QAAQ,aAAa,GAAG,IAAI,CAAC;0CAQrE,YAAY,WACZ,eAAe,GACtB,QAAQ,MAAM,CAAC;gCAcmB,aAAa,GAAG,QAAQ,KAAK,CAAC;;;;;;;;2BAgDpB,CAAC"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import { bufferToString } from "@fluid-internal/client-utils";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
|
+
import { FileMode, TreeEntry, } from "@fluidframework/driver-definitions/internal";
|
|
8
9
|
import { buildSnapshotTree, convertSummaryTreeToSnapshotITree, } from "@fluidframework/driver-utils/internal";
|
|
9
|
-
import * as api from "@fluidframework/protocol-definitions";
|
|
10
10
|
import { ReadDocumentStorageServiceBase, } from "@fluidframework/replay-driver/internal";
|
|
11
11
|
// This ID is used by replay tool as Document Id.
|
|
12
12
|
// We leverage it to figure out when container is asking for root document tree.
|
|
@@ -158,9 +158,9 @@ export const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
158
158
|
for (const subTreeId of Object.keys(snapshotTree.trees)) {
|
|
159
159
|
const subTree = await this.buildTree(snapshotTree.trees[subTreeId]);
|
|
160
160
|
tree.entries.push({
|
|
161
|
-
mode:
|
|
161
|
+
mode: FileMode.Directory,
|
|
162
162
|
path: subTreeId,
|
|
163
|
-
type:
|
|
163
|
+
type: TreeEntry.Tree,
|
|
164
164
|
value: subTree,
|
|
165
165
|
});
|
|
166
166
|
}
|
|
@@ -172,9 +172,9 @@ export const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
172
172
|
encoding: "utf-8",
|
|
173
173
|
};
|
|
174
174
|
tree.entries.push({
|
|
175
|
-
mode:
|
|
175
|
+
mode: FileMode.File,
|
|
176
176
|
path: blobName,
|
|
177
|
-
type:
|
|
177
|
+
type: TreeEntry.Blob,
|
|
178
178
|
value: blob,
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -183,7 +183,7 @@ export const FileSnapshotWriterClassFactory = (Base) => class extends Base {
|
|
|
183
183
|
};
|
|
184
184
|
function removeNullTreeIds(tree) {
|
|
185
185
|
for (const node of tree.entries) {
|
|
186
|
-
if (node.type ===
|
|
186
|
+
if (node.type === TreeEntry.Tree) {
|
|
187
187
|
removeNullTreeIds(node.value);
|
|
188
188
|
}
|
|
189
189
|
}
|