@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EACN,iBAAiB,EACjB,iCAAiC,GACjC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAEN,8BAA8B,GAC9B,MAAM,wCAAwC,CAAC;AAEhD,iDAAiD;AACjD,gFAAgF;AAChF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,gBACZ,SAAQ,8BAA8B;IAKtC,YACkB,IAAY,EACZ,WAAoB;QAErC,KAAK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KAAK,CAAC,EAAE;YACvD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YACjE,MAAM,QAAQ,GAAG,cAAc,CAAC,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;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,MAAM,CACL,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;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,8BAA8B,CAAC,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,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAMN,QAAQ,EACR,SAAS,GAET,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,iBAAiB,EACjB,iCAAiC,GACjC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,8BAA8B,GAC9B,MAAM,wCAAwC,CAAC;AAEhD,iDAAiD;AACjD,gFAAgF;AAChF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,gBACZ,SAAQ,8BAA8B;IAKtC,YACkB,IAAY,EACZ,WAAoB;QAErC,KAAK,EAAE,CAAC;QAHS,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAS;QAJ5B,YAAO,GAAyB,IAAI,CAAC;IAO/C,CAAC;IAED;;;OAGG;IACH,kDAAkD;IAC3C,KAAK,CAAC,eAAe,CAAC,OAAkB;QAC9C,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACzF,MAAM,CACL,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,wBAA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AAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChD,MAAM,IAAI,GAAU;gBACnB,QAAQ;gBACR,QAAQ,EAAE,OAAO;aACjB,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,QAAQ,CAAC,IAAI;gBACnB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS,CAAC,IAAI;gBACpB,KAAK,EAAE,IAAI;aACX,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC;AAEH,SAAS,iBAAiB,CAAC,IAAW;IACrC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,EAAE,CAAC;YAClC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACF,CAAC;IACD,MAAM,CACL,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;AACH,MAAM,CAAC,MAAM,kCAAkC,GAC9C,8BAA8B,CAAC,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"]}
|
package/lib/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-rc.
|
|
3
|
+
"version": "2.0.0-rc.5.0.1",
|
|
4
4
|
"description": "A driver that reads/write from/to local file storage.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,29 +37,29 @@
|
|
|
37
37
|
"main": "lib/index.js",
|
|
38
38
|
"types": "lib/public.d.ts",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.
|
|
41
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.
|
|
42
|
-
"@fluidframework/core-utils": ">=2.0.0-rc.
|
|
43
|
-
"@fluidframework/driver-definitions": ">=2.0.0-rc.
|
|
44
|
-
"@fluidframework/driver-utils": ">=2.0.0-rc.
|
|
45
|
-
"@fluidframework/
|
|
46
|
-
"@fluidframework/replay-driver": ">=2.0.0-rc.4.0.6 <2.0.0-rc.4.1.0"
|
|
40
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
41
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
42
|
+
"@fluidframework/core-utils": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
43
|
+
"@fluidframework/driver-definitions": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
44
|
+
"@fluidframework/driver-utils": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0",
|
|
45
|
+
"@fluidframework/replay-driver": ">=2.0.0-rc.5.0.1 <2.0.0-rc.5.1.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
50
|
-
"@biomejs/biome": "^1.
|
|
51
|
-
"@fluid-tools/build-cli": "^0.
|
|
49
|
+
"@biomejs/biome": "^1.7.3",
|
|
50
|
+
"@fluid-tools/build-cli": "^0.39.0",
|
|
52
51
|
"@fluidframework/build-common": "^2.0.3",
|
|
53
|
-
"@fluidframework/build-tools": "^0.
|
|
54
|
-
"@fluidframework/eslint-config-fluid": "^5.
|
|
55
|
-
"@fluidframework/file-driver-previous": "npm:@fluidframework/file-driver@2.0.0-rc.
|
|
56
|
-
"@microsoft/api-extractor": "^7.
|
|
52
|
+
"@fluidframework/build-tools": "^0.39.0",
|
|
53
|
+
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
54
|
+
"@fluidframework/file-driver-previous": "npm:@fluidframework/file-driver@2.0.0-rc.4.0.0",
|
|
55
|
+
"@microsoft/api-extractor": "^7.45.1",
|
|
57
56
|
"@types/node": "^18.19.0",
|
|
57
|
+
"concurrently": "^8.2.1",
|
|
58
58
|
"copyfiles": "^2.4.1",
|
|
59
59
|
"eslint": "~8.55.0",
|
|
60
60
|
"prettier": "~3.0.3",
|
|
61
61
|
"rimraf": "^4.4.0",
|
|
62
|
-
"typescript": "~5.
|
|
62
|
+
"typescript": "~5.4.5"
|
|
63
63
|
},
|
|
64
64
|
"fluidBuild": {
|
|
65
65
|
"tasks": {
|
|
@@ -69,7 +69,11 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"typeValidation": {
|
|
72
|
-
"broken": {
|
|
72
|
+
"broken": {
|
|
73
|
+
"VariableDeclaration_FluidFetchReaderFileSnapshotWriter": {
|
|
74
|
+
"forwardCompat": false
|
|
75
|
+
}
|
|
76
|
+
}
|
|
73
77
|
},
|
|
74
78
|
"scripts": {
|
|
75
79
|
"api": "fluid-build . --task api",
|
|
@@ -80,13 +84,19 @@
|
|
|
80
84
|
"build:docs": "api-extractor run --local",
|
|
81
85
|
"build:esnext": "tsc --project ./tsconfig.json",
|
|
82
86
|
"check:are-the-types-wrong": "attw --pack .",
|
|
87
|
+
"check:biome": "biome check . --formatter-enabled=true",
|
|
88
|
+
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
89
|
+
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
90
|
+
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
|
|
91
|
+
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
92
|
+
"check:format": "npm run check:biome",
|
|
83
93
|
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
84
|
-
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
85
94
|
"ci:build:docs": "api-extractor run",
|
|
86
95
|
"clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp",
|
|
87
96
|
"eslint": "eslint --format stylish src",
|
|
88
97
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
89
|
-
"format": "
|
|
98
|
+
"format": "npm run format:biome",
|
|
99
|
+
"format:biome": "biome check . --formatter-enabled=true --apply",
|
|
90
100
|
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
91
101
|
"lint": "fluid-build . --task lint",
|
|
92
102
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
@@ -6,17 +6,20 @@
|
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
|
|
8
8
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
IDocumentDeltaStorageService,
|
|
11
|
+
IStream,
|
|
12
|
+
ISequencedDocumentMessage,
|
|
13
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
10
14
|
import { emptyMessageStream } from "@fluidframework/driver-utils/internal";
|
|
11
|
-
import * as api from "@fluidframework/protocol-definitions";
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Provides access to the underlying delta storage on the local file storage for file driver.
|
|
15
18
|
* @internal
|
|
16
19
|
*/
|
|
17
20
|
export class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
18
|
-
private readonly messages:
|
|
19
|
-
private lastOps:
|
|
21
|
+
private readonly messages: ISequencedDocumentMessage[];
|
|
22
|
+
private lastOps: ISequencedDocumentMessage[] = [];
|
|
20
23
|
|
|
21
24
|
constructor(private readonly path: string) {
|
|
22
25
|
this.messages = [];
|
|
@@ -41,11 +44,11 @@ export class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
|
41
44
|
to: number | undefined,
|
|
42
45
|
abortSignal?: AbortSignal,
|
|
43
46
|
cachedOnly?: boolean,
|
|
44
|
-
): IStream<
|
|
47
|
+
): IStream<ISequencedDocumentMessage[]> {
|
|
45
48
|
return emptyMessageStream;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
public get ops(): readonly Readonly<
|
|
51
|
+
public get ops(): readonly Readonly<ISequencedDocumentMessage>[] {
|
|
49
52
|
return this.messages;
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -55,7 +58,7 @@ export class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
|
55
58
|
* @param from - First op to be fetched.
|
|
56
59
|
* @param to - Last op to be fetched. This is exclusive.
|
|
57
60
|
*/
|
|
58
|
-
public getFromWebSocket(from: number, to: number):
|
|
61
|
+
public getFromWebSocket(from: number, to: number): ISequencedDocumentMessage[] {
|
|
59
62
|
const readFrom = Math.max(from, 0); // Inclusive
|
|
60
63
|
const readTo = Math.min(to, this.messages.length); // Exclusive
|
|
61
64
|
|
|
@@ -5,21 +5,19 @@
|
|
|
5
5
|
|
|
6
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
7
|
import { IDisposable } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { ConnectionMode } from "@fluidframework/driver-definitions";
|
|
8
9
|
import {
|
|
9
10
|
IDocumentDeltaConnection,
|
|
10
11
|
IDocumentDeltaConnectionEvents,
|
|
11
|
-
} from "@fluidframework/driver-definitions/internal";
|
|
12
|
-
import {
|
|
13
|
-
ConnectionMode,
|
|
14
12
|
IClientConfiguration,
|
|
15
13
|
IConnected,
|
|
16
14
|
IDocumentMessage,
|
|
17
|
-
ISequencedDocumentMessage,
|
|
18
15
|
ISignalClient,
|
|
19
|
-
ISignalMessage,
|
|
20
16
|
ITokenClaims,
|
|
21
17
|
ScopeType,
|
|
22
|
-
|
|
18
|
+
ISequencedDocumentMessage,
|
|
19
|
+
ISignalMessage,
|
|
20
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
23
21
|
|
|
24
22
|
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
25
23
|
|
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import { IClient } from "@fluidframework/driver-definitions";
|
|
8
|
+
import {
|
|
9
|
+
IDocumentServiceEvents,
|
|
10
|
+
IDocumentService,
|
|
11
|
+
IResolvedUrl,
|
|
12
|
+
IDocumentStorageService,
|
|
13
|
+
IDocumentDeltaConnection,
|
|
14
|
+
IDocumentDeltaStorageService,
|
|
15
|
+
} from "@fluidframework/driver-definitions/internal";
|
|
9
16
|
|
|
10
17
|
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
11
18
|
|
|
@@ -14,26 +21,26 @@ import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
|
14
21
|
* underlying storage for file document service.
|
|
15
22
|
*/
|
|
16
23
|
export class FileDocumentService
|
|
17
|
-
extends TypedEventEmitter<
|
|
24
|
+
extends TypedEventEmitter<IDocumentServiceEvents>
|
|
18
25
|
// eslint-disable-next-line import/namespace
|
|
19
|
-
implements
|
|
26
|
+
implements IDocumentService
|
|
20
27
|
{
|
|
21
28
|
constructor(
|
|
22
|
-
public readonly resolvedUrl:
|
|
23
|
-
private readonly storage:
|
|
29
|
+
public readonly resolvedUrl: IResolvedUrl,
|
|
30
|
+
private readonly storage: IDocumentStorageService,
|
|
24
31
|
private readonly deltaStorage: FileDeltaStorageService,
|
|
25
|
-
private readonly deltaConnection:
|
|
32
|
+
private readonly deltaConnection: IDocumentDeltaConnection,
|
|
26
33
|
) {
|
|
27
34
|
super();
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
public dispose() {}
|
|
31
38
|
|
|
32
|
-
public async connectToStorage(): Promise<
|
|
39
|
+
public async connectToStorage(): Promise<IDocumentStorageService> {
|
|
33
40
|
return this.storage;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
|
-
public async connectToDeltaStorage(): Promise<
|
|
43
|
+
public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {
|
|
37
44
|
return this.deltaStorage;
|
|
38
45
|
}
|
|
39
46
|
|
|
@@ -44,7 +51,7 @@ export class FileDocumentService
|
|
|
44
51
|
* @param client - Client that connects to socket.
|
|
45
52
|
* @returns returns the delta stream service.
|
|
46
53
|
*/
|
|
47
|
-
public async connectToDeltaStream(client: IClient): Promise<
|
|
54
|
+
public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {
|
|
48
55
|
return this.deltaConnection;
|
|
49
56
|
}
|
|
50
57
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
7
8
|
import {
|
|
8
9
|
IDocumentDeltaConnection,
|
|
9
10
|
IDocumentService,
|
|
@@ -11,7 +12,6 @@ import {
|
|
|
11
12
|
IDocumentStorageService,
|
|
12
13
|
IResolvedUrl,
|
|
13
14
|
} from "@fluidframework/driver-definitions/internal";
|
|
14
|
-
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
15
15
|
|
|
16
16
|
import { FileDeltaStorageService } from "./fileDeltaStorageService.js";
|
|
17
17
|
import { FileDocumentService } from "./fileDocumentService.js";
|
|
@@ -7,15 +7,21 @@ import fs from "fs";
|
|
|
7
7
|
|
|
8
8
|
import { bufferToString } from "@fluid-internal/client-utils";
|
|
9
9
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
10
|
+
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
10
11
|
import {
|
|
11
12
|
IDocumentStorageService,
|
|
12
13
|
ISummaryContext,
|
|
14
|
+
ISnapshotTree,
|
|
15
|
+
IVersion,
|
|
16
|
+
ITree,
|
|
17
|
+
FileMode,
|
|
18
|
+
TreeEntry,
|
|
19
|
+
IBlob,
|
|
13
20
|
} from "@fluidframework/driver-definitions/internal";
|
|
14
21
|
import {
|
|
15
22
|
buildSnapshotTree,
|
|
16
23
|
convertSummaryTreeToSnapshotITree,
|
|
17
24
|
} from "@fluidframework/driver-utils/internal";
|
|
18
|
-
import * as api from "@fluidframework/protocol-definitions";
|
|
19
25
|
import {
|
|
20
26
|
IFileSnapshot,
|
|
21
27
|
ReadDocumentStorageServiceBase,
|
|
@@ -39,7 +45,7 @@ export class FluidFetchReader
|
|
|
39
45
|
extends ReadDocumentStorageServiceBase
|
|
40
46
|
implements IDocumentStorageService
|
|
41
47
|
{
|
|
42
|
-
protected docTree:
|
|
48
|
+
protected docTree: ISnapshotTree | null = null;
|
|
43
49
|
|
|
44
50
|
constructor(
|
|
45
51
|
private readonly path: string,
|
|
@@ -53,7 +59,7 @@ export class FluidFetchReader
|
|
|
53
59
|
* @param version - The version contains the path of the file which contains the snapshot tree.
|
|
54
60
|
*/
|
|
55
61
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
56
|
-
public async getSnapshotTree(version?:
|
|
62
|
+
public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
|
|
57
63
|
assert(version !== null, 0x092 /* "version input for reading snapshot tree is null!" */);
|
|
58
64
|
assert(
|
|
59
65
|
!version || version.treeId === FileStorageVersionTreeId,
|
|
@@ -93,7 +99,7 @@ export class FluidFetchReader
|
|
|
93
99
|
* @param count - Number of versions to be returned.
|
|
94
100
|
*/
|
|
95
101
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
96
|
-
public async getVersions(versionId: string | null, count: number): Promise<
|
|
102
|
+
public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
|
|
97
103
|
if (versionId === FileStorageDocumentName || versionId === null) {
|
|
98
104
|
if (this.docTree !== null || this.versionName !== undefined) {
|
|
99
105
|
return [{ id: "latest", treeId: FileStorageVersionTreeId }];
|
|
@@ -143,7 +149,7 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
143
149
|
class extends Base implements ISnapshotWriterStorage {
|
|
144
150
|
// Note: if variable name has same name as in base class, it overrides it!
|
|
145
151
|
public blobsWriter = new Map<string, ArrayBufferLike>();
|
|
146
|
-
public latestWriterTree?:
|
|
152
|
+
public latestWriterTree?: ISnapshotTree;
|
|
147
153
|
public docId?: string;
|
|
148
154
|
|
|
149
155
|
public reset() {
|
|
@@ -165,7 +171,7 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
168
|
-
public async getVersions(versionId: string | null, count: number): Promise<
|
|
174
|
+
public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
|
|
169
175
|
// If we already saved document, that means we are getting here because of snapshot generation.
|
|
170
176
|
// Not returning tree ensures that ContainerRuntime.snapshot() would regenerate subtrees for
|
|
171
177
|
// each unchanged data store.
|
|
@@ -183,7 +189,7 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
183
189
|
}
|
|
184
190
|
|
|
185
191
|
// eslint-disable-next-line @rushstack/no-new-null
|
|
186
|
-
public async getSnapshotTree(version?:
|
|
192
|
+
public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
|
|
187
193
|
if (this.latestWriterTree && (!version || version.id === "latest")) {
|
|
188
194
|
return this.latestWriterTree;
|
|
189
195
|
}
|
|
@@ -191,7 +197,7 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
public async uploadSummaryWithContext(
|
|
194
|
-
summary:
|
|
200
|
+
summary: ISummaryTree,
|
|
195
201
|
context: ISummaryContext,
|
|
196
202
|
): Promise<string> {
|
|
197
203
|
const tree = convertSummaryTreeToSnapshotITree(summary);
|
|
@@ -207,15 +213,15 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
207
213
|
return "testHandleId";
|
|
208
214
|
}
|
|
209
215
|
|
|
210
|
-
public async buildTree(snapshotTree:
|
|
211
|
-
const tree:
|
|
216
|
+
public async buildTree(snapshotTree: ISnapshotTree): Promise<ITree> {
|
|
217
|
+
const tree: ITree = { entries: [] };
|
|
212
218
|
|
|
213
219
|
for (const subTreeId of Object.keys(snapshotTree.trees)) {
|
|
214
220
|
const subTree = await this.buildTree(snapshotTree.trees[subTreeId]);
|
|
215
221
|
tree.entries.push({
|
|
216
|
-
mode:
|
|
222
|
+
mode: FileMode.Directory,
|
|
217
223
|
path: subTreeId,
|
|
218
|
-
type:
|
|
224
|
+
type: TreeEntry.Tree,
|
|
219
225
|
value: subTree,
|
|
220
226
|
});
|
|
221
227
|
}
|
|
@@ -223,14 +229,14 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
223
229
|
for (const blobName of Object.keys(snapshotTree.blobs)) {
|
|
224
230
|
const buffer = await this.readBlob(snapshotTree.blobs[blobName]);
|
|
225
231
|
const contents = bufferToString(buffer, "utf8");
|
|
226
|
-
const blob:
|
|
232
|
+
const blob: IBlob = {
|
|
227
233
|
contents,
|
|
228
234
|
encoding: "utf-8",
|
|
229
235
|
};
|
|
230
236
|
tree.entries.push({
|
|
231
|
-
mode:
|
|
237
|
+
mode: FileMode.File,
|
|
232
238
|
path: blobName,
|
|
233
|
-
type:
|
|
239
|
+
type: TreeEntry.Blob,
|
|
234
240
|
value: blob,
|
|
235
241
|
});
|
|
236
242
|
}
|
|
@@ -239,9 +245,9 @@ export const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(
|
|
|
239
245
|
}
|
|
240
246
|
};
|
|
241
247
|
|
|
242
|
-
function removeNullTreeIds(tree:
|
|
248
|
+
function removeNullTreeIds(tree: ITree) {
|
|
243
249
|
for (const node of tree.entries) {
|
|
244
|
-
if (node.type ===
|
|
250
|
+
if (node.type === TreeEntry.Tree) {
|
|
245
251
|
removeNullTreeIds(node.value);
|
|
246
252
|
}
|
|
247
253
|
}
|
|
@@ -254,4 +260,5 @@ function removeNullTreeIds(tree: api.ITree) {
|
|
|
254
260
|
/**
|
|
255
261
|
* @internal
|
|
256
262
|
*/
|
|
257
|
-
export const FluidFetchReaderFileSnapshotWriter =
|
|
263
|
+
export const FluidFetchReaderFileSnapshotWriter =
|
|
264
|
+
FileSnapshotWriterClassFactory(FluidFetchReader);
|
package/tsconfig.json
CHANGED
package/tsdoc.json
ADDED
|
@@ -1,173 +0,0 @@
|
|
|
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/internal';
|
|
13
|
-
import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions/internal';
|
|
14
|
-
import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions/internal';
|
|
15
|
-
import { IDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
16
|
-
import { IDocumentService } from '@fluidframework/driver-definitions/internal';
|
|
17
|
-
import { IDocumentServiceFactory } from '@fluidframework/driver-definitions/internal';
|
|
18
|
-
import { IDocumentStorageService } from '@fluidframework/driver-definitions/internal';
|
|
19
|
-
import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions/internal';
|
|
20
|
-
import { IFileSnapshot } from '@fluidframework/replay-driver/internal';
|
|
21
|
-
import { IResolvedUrl } from '@fluidframework/driver-definitions/internal';
|
|
22
|
-
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
|
|
23
|
-
import { ISignalClient } from '@fluidframework/protocol-definitions';
|
|
24
|
-
import { ISignalMessage } from '@fluidframework/protocol-definitions';
|
|
25
|
-
import { ISnapshot } from '@fluidframework/driver-definitions/internal';
|
|
26
|
-
import { ISnapshotFetchOptions } from '@fluidframework/driver-definitions/internal';
|
|
27
|
-
import { IStream } from '@fluidframework/driver-definitions/internal';
|
|
28
|
-
import { ISummaryContext } from '@fluidframework/driver-definitions/internal';
|
|
29
|
-
import { ISummaryTree } from '@fluidframework/protocol-definitions';
|
|
30
|
-
import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
31
|
-
import { ITokenClaims } from '@fluidframework/protocol-definitions';
|
|
32
|
-
import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver/internal';
|
|
33
|
-
import { TypedEventEmitter } from '@fluid-internal/client-utils';
|
|
34
|
-
|
|
35
|
-
// @internal
|
|
36
|
-
export class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
37
|
-
constructor(path: string);
|
|
38
|
-
// (undocumented)
|
|
39
|
-
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<api.ISequencedDocumentMessage[]>;
|
|
40
|
-
getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[];
|
|
41
|
-
// (undocumented)
|
|
42
|
-
get ops(): readonly Readonly<api.ISequencedDocumentMessage>[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// @internal
|
|
46
|
-
export class FileDocumentServiceFactory implements IDocumentServiceFactory {
|
|
47
|
-
constructor(storage: IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: IDocumentDeltaConnection);
|
|
48
|
-
// (undocumented)
|
|
49
|
-
createContainer(createNewSummary: ISummaryTree, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
50
|
-
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// @internal (undocumented)
|
|
54
|
-
export const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
|
|
55
|
-
new (...args: any[]): {
|
|
56
|
-
blobsWriter: Map<string, ArrayBufferLike>;
|
|
57
|
-
latestWriterTree?: api.ISnapshotTree | undefined;
|
|
58
|
-
docId?: string | undefined;
|
|
59
|
-
reset(): void;
|
|
60
|
-
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
61
|
-
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
62
|
-
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
63
|
-
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
64
|
-
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
65
|
-
buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
|
|
66
|
-
readonly policies?: IDocumentStorageServicePolicies | undefined;
|
|
67
|
-
getSnapshot?(snapshotFetchOptions?: ISnapshotFetchOptions | undefined): Promise<ISnapshot>;
|
|
68
|
-
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
69
|
-
downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
|
|
70
|
-
readonly disposed?: boolean | undefined;
|
|
71
|
-
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
72
|
-
};
|
|
73
|
-
} & TBase;
|
|
74
|
-
|
|
75
|
-
// @internal (undocumented)
|
|
76
|
-
export const FileStorageDocumentName = "FileStorageDocId";
|
|
77
|
-
|
|
78
|
-
// @internal
|
|
79
|
-
export class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
|
|
80
|
-
constructor(path: string, versionName?: string | undefined);
|
|
81
|
-
// (undocumented)
|
|
82
|
-
protected docTree: api.ISnapshotTree | null;
|
|
83
|
-
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
84
|
-
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
85
|
-
// (undocumented)
|
|
86
|
-
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// @internal (undocumented)
|
|
90
|
-
export const FluidFetchReaderFileSnapshotWriter: {
|
|
91
|
-
new (...args: any[]): {
|
|
92
|
-
blobsWriter: Map<string, ArrayBufferLike>;
|
|
93
|
-
latestWriterTree?: api.ISnapshotTree | undefined;
|
|
94
|
-
docId?: string | undefined;
|
|
95
|
-
reset(): void;
|
|
96
|
-
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
97
|
-
readBlob(sha: string): Promise<ArrayBufferLike>;
|
|
98
|
-
getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
|
|
99
|
-
getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
|
|
100
|
-
uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
101
|
-
buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
|
|
102
|
-
readonly policies?: IDocumentStorageServicePolicies | undefined;
|
|
103
|
-
getSnapshot?(snapshotFetchOptions?: ISnapshotFetchOptions | undefined): Promise<ISnapshot>;
|
|
104
|
-
createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
|
|
105
|
-
downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
|
|
106
|
-
readonly disposed?: boolean | undefined;
|
|
107
|
-
dispose?: ((error?: Error | undefined) => void) | undefined;
|
|
108
|
-
};
|
|
109
|
-
} & typeof FluidFetchReader;
|
|
110
|
-
|
|
111
|
-
// @internal (undocumented)
|
|
112
|
-
export interface ISnapshotWriterStorage extends IDocumentStorageService {
|
|
113
|
-
// (undocumented)
|
|
114
|
-
onSnapshotHandler(snapshot: IFileSnapshot): void;
|
|
115
|
-
// (undocumented)
|
|
116
|
-
reset(): void;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// @internal (undocumented)
|
|
120
|
-
export type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
|
|
121
|
-
|
|
122
|
-
// @internal
|
|
123
|
-
export class Replayer {
|
|
124
|
-
constructor(deltaConnection: ReplayFileDeltaConnection, documentStorageService: FileDeltaStorageService);
|
|
125
|
-
// (undocumented)
|
|
126
|
-
get currentReplayedOp(): number;
|
|
127
|
-
set currentReplayedOp(op: number);
|
|
128
|
-
// (undocumented)
|
|
129
|
-
get ops(): readonly Readonly<ISequencedDocumentMessage>[];
|
|
130
|
-
replay(replayTo: number): number;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// @internal (undocumented)
|
|
134
|
-
export class ReplayFileDeltaConnection extends TypedEventEmitter<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable {
|
|
135
|
-
constructor(details: IConnected, documentDeltaStorageService: FileDeltaStorageService);
|
|
136
|
-
// (undocumented)
|
|
137
|
-
get claims(): ITokenClaims;
|
|
138
|
-
// (undocumented)
|
|
139
|
-
get clientId(): string;
|
|
140
|
-
static create(documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection>;
|
|
141
|
-
// (undocumented)
|
|
142
|
-
details: IConnected;
|
|
143
|
-
// (undocumented)
|
|
144
|
-
dispose(): void;
|
|
145
|
-
// (undocumented)
|
|
146
|
-
get disposed(): boolean;
|
|
147
|
-
// (undocumented)
|
|
148
|
-
get existing(): boolean;
|
|
149
|
-
// (undocumented)
|
|
150
|
-
getReplayer(): Replayer;
|
|
151
|
-
// (undocumented)
|
|
152
|
-
get initialClients(): ISignalClient[];
|
|
153
|
-
// (undocumented)
|
|
154
|
-
get initialMessages(): ISequencedDocumentMessage[];
|
|
155
|
-
// (undocumented)
|
|
156
|
-
get initialSignals(): ISignalMessage[];
|
|
157
|
-
// (undocumented)
|
|
158
|
-
readonly maxMessageSize: number;
|
|
159
|
-
// (undocumented)
|
|
160
|
-
get mode(): ConnectionMode;
|
|
161
|
-
// (undocumented)
|
|
162
|
-
get serviceConfiguration(): IClientConfiguration;
|
|
163
|
-
// (undocumented)
|
|
164
|
-
submit(documentMessages: IDocumentMessage[]): void;
|
|
165
|
-
// (undocumented)
|
|
166
|
-
submitSignal(message: any): Promise<void>;
|
|
167
|
-
// (undocumented)
|
|
168
|
-
get version(): string;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// (No @packageDocumentation comment for this package)
|
|
172
|
-
|
|
173
|
-
```
|