@fluidframework/file-driver 2.0.0-dev.7.4.0.215930 → 2.0.0-dev.7.4.0.217212

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.
Files changed (32) hide show
  1. package/api-extractor-lint.json +13 -0
  2. package/api-extractor.json +0 -4
  3. package/api-report/file-driver.api.md +10 -10
  4. package/dist/file-driver-alpha.d.ts +14 -152
  5. package/dist/file-driver-beta.d.ts +46 -173
  6. package/dist/file-driver-public.d.ts +46 -173
  7. package/dist/file-driver-untrimmed.d.ts +22 -0
  8. package/dist/fileDeltaStorageService.d.ts +1 -0
  9. package/dist/fileDeltaStorageService.d.ts.map +1 -1
  10. package/dist/fileDeltaStorageService.js +1 -0
  11. package/dist/fileDeltaStorageService.js.map +1 -1
  12. package/dist/fileDocumentDeltaConnection.d.ts +4 -0
  13. package/dist/fileDocumentDeltaConnection.d.ts.map +1 -1
  14. package/dist/fileDocumentDeltaConnection.js +4 -0
  15. package/dist/fileDocumentDeltaConnection.js.map +1 -1
  16. package/dist/fileDocumentServiceFactory.d.ts +1 -0
  17. package/dist/fileDocumentServiceFactory.d.ts.map +1 -1
  18. package/dist/fileDocumentServiceFactory.js +1 -0
  19. package/dist/fileDocumentServiceFactory.js.map +1 -1
  20. package/dist/fileDocumentStorageService.d.ts +16 -0
  21. package/dist/fileDocumentStorageService.d.ts.map +1 -1
  22. package/dist/fileDocumentStorageService.js +10 -0
  23. package/dist/fileDocumentStorageService.js.map +1 -1
  24. package/lib/file-driver-alpha.d.ts +14 -152
  25. package/lib/file-driver-beta.d.ts +46 -173
  26. package/lib/file-driver-public.d.ts +46 -173
  27. package/lib/file-driver-untrimmed.d.ts +22 -0
  28. package/package.json +9 -8
  29. package/src/fileDeltaStorageService.ts +1 -0
  30. package/src/fileDocumentDeltaConnection.ts +4 -0
  31. package/src/fileDocumentServiceFactory.ts +1 -0
  32. package/src/fileDocumentStorageService.ts +16 -0
@@ -1 +1 @@
1
- {"version":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AC,CAAC;SAC9B;KACD;IACD,IAAA,mBAAM,EACL,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EACzC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,OAAO,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC;AACY,QAAA,kCAAkC,GAAG,IAAA,sCAA8B,EAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { buildSnapshotTree, convertSummaryTreeToSnapshotITree } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IFileSnapshot, ReadDocumentStorageServiceBase } from \"@fluidframework/replay-driver\";\n\n// This ID is used by replay tool as Document Id.\n// We leverage it to figure out when container is asking for root document tree.\nexport const FileStorageDocumentName = \"FileStorageDocId\"; // Some unique document name\n\n// Tree ID use to communicate between getVersions() & getSnapshotTree() that IVersion is ours.\nconst FileStorageVersionTreeId = \"FileStorageTreeId\";\n\n/**\n * Document storage service for the file driver.\n */\nexport class FluidFetchReader\n\textends ReadDocumentStorageServiceBase\n\timplements IDocumentStorageService\n{\n\tprotected docTree: api.ISnapshotTree | null = null;\n\n\tconstructor(\n\t\tprivate readonly path: string,\n\t\tprivate readonly versionName?: string,\n\t) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Read the file and returns the snapshot tree.\n\t * @param version - The version contains the path of the file which contains the snapshot tree.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\tassert(version !== null, 0x092 /* \"version input for reading snapshot tree is null!\" */);\n\t\tassert(\n\t\t\t!version || version.treeId === FileStorageVersionTreeId,\n\t\t\t0x093 /* \"invalid version input for reading snapshot tree!\" */,\n\t\t);\n\n\t\tlet filename: string;\n\t\tlet rootTree = false;\n\t\tif (!version || version.id === \"latest\") {\n\t\t\tif (this.docTree) {\n\t\t\t\treturn this.docTree;\n\t\t\t}\n\t\t\tif (this.versionName === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\trootTree = true;\n\t\t\tfilename = `${this.path}/${this.versionName}/tree.json`;\n\t\t} else {\n\t\t\tfilename = `${this.path}/${this.versionName}/${version.id}.json`;\n\t\t}\n\n\t\tif (!fs.existsSync(filename)) {\n\t\t\tthrow new Error(`Can't find file ${filename}`);\n\t\t}\n\t\tconst data = fs.readFileSync(filename);\n\t\tconst tree = JSON.parse(data.toString(\"utf-8\"));\n\t\tif (rootTree) {\n\t\t\tthis.docTree = tree;\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Gets the path of the snapshot tree to be read.\n\t * @param versionId - version ID.\n\t * @param count - Number of versions to be returned.\n\t */\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\tif (versionId === FileStorageDocumentName || versionId === null) {\n\t\t\tif (this.docTree !== null || this.versionName !== undefined) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\t\t\t// Started with ops - return empty set.\n\t\t\treturn [];\n\t\t} else if (this.versionName !== undefined) {\n\t\t\tassert(!!this.docTree, 0x094 /* \"Missing snapshot tree!\" */);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: FileStorageVersionTreeId,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tthrow new Error(`Unknown version: ${versionId}`);\n\t}\n\n\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\tif (this.versionName !== undefined) {\n\t\t\tconst fileName = `${this.path}/${this.versionName}/${sha}`;\n\t\t\tif (fs.existsSync(fileName)) {\n\t\t\t\tconst data = fs.readFileSync(fileName);\n\t\t\t\treturn data;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Can't find blob ${sha}`);\n\t}\n}\n\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n\tonSnapshotHandler(snapshot: IFileSnapshot): void;\n\treset(): void;\n}\n\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\nexport const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(Base: TBase) =>\n\tclass extends Base implements ISnapshotWriterStorage {\n\t\t// Note: if variable name has same name as in base class, it overrides it!\n\t\tpublic blobsWriter = new Map<string, ArrayBufferLike>();\n\t\tpublic latestWriterTree?: api.ISnapshotTree;\n\t\tpublic docId?: string;\n\n\t\tpublic reset() {\n\t\t\tthis.blobsWriter = new Map<string, ArrayBufferLike>();\n\t\t\tthis.latestWriterTree = undefined;\n\t\t\tthis.docId = undefined;\n\t\t}\n\n\t\tpublic onSnapshotHandler(snapshot: IFileSnapshot): void {\n\t\t\tthrow new Error(\"onSnapshotHandler is not setup! Please provide your handler!\");\n\t\t}\n\n\t\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\t\tconst blob = this.blobsWriter.get(sha);\n\t\t\tif (blob !== undefined) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn super.readBlob(sha);\n\t\t}\n\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\t\t// If we already saved document, that means we are getting here because of snapshot generation.\n\t\t\t// Not returning tree ensures that ContainerRuntime.snapshot() would regenerate subtrees for\n\t\t\t// each unchanged data store.\n\t\t\t// If we want to change that, we would need to capture docId on first call and return this.latestWriterTree\n\t\t\t// when latest is requested.\n\t\t\tif (this.latestWriterTree && (this.docId === versionId || versionId === null)) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\n\t\t\tif (this.docId === undefined && versionId !== null) {\n\t\t\t\tthis.docId = versionId;\n\t\t\t}\n\n\t\t\treturn super.getVersions(versionId, count);\n\t\t}\n\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\t\tif (this.latestWriterTree && (!version || version.id === \"latest\")) {\n\t\t\t\treturn this.latestWriterTree;\n\t\t\t}\n\t\t\treturn super.getSnapshotTree(version);\n\t\t}\n\n\t\tpublic async uploadSummaryWithContext(\n\t\t\tsummary: api.ISummaryTree,\n\t\t\tcontext: ISummaryContext,\n\t\t): Promise<string> {\n\t\t\tconst tree = convertSummaryTreeToSnapshotITree(summary);\n\n\t\t\t// Remove tree IDs for easier comparison of snapshots\n\t\t\tdelete tree.id;\n\t\t\tremoveNullTreeIds(tree);\n\n\t\t\tthis.latestWriterTree = buildSnapshotTree(tree.entries, this.blobsWriter);\n\n\t\t\tconst fileSnapshot: IFileSnapshot = { tree, commits: {} };\n\t\t\tthis.onSnapshotHandler(fileSnapshot);\n\t\t\treturn \"testHandleId\";\n\t\t}\n\n\t\tpublic async buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree> {\n\t\t\tconst tree: api.ITree = { entries: [] };\n\n\t\t\tfor (const subTreeId of Object.keys(snapshotTree.trees)) {\n\t\t\t\tconst subTree = await this.buildTree(snapshotTree.trees[subTreeId]);\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.Directory,\n\t\t\t\t\tpath: subTreeId,\n\t\t\t\t\ttype: api.TreeEntry.Tree,\n\t\t\t\t\tvalue: subTree,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const blobName of Object.keys(snapshotTree.blobs)) {\n\t\t\t\tconst buffer = await this.readBlob(snapshotTree.blobs[blobName]);\n\t\t\t\tconst contents = bufferToString(buffer, \"utf8\");\n\t\t\t\tconst blob: api.IBlob = {\n\t\t\t\t\tcontents,\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t};\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.File,\n\t\t\t\t\tpath: blobName,\n\t\t\t\t\ttype: api.TreeEntry.Blob,\n\t\t\t\t\tvalue: blob,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn tree;\n\t\t}\n\t};\n\nfunction removeNullTreeIds(tree: api.ITree) {\n\tfor (const node of tree.entries) {\n\t\tif (node.type === api.TreeEntry.Tree) {\n\t\t\tremoveNullTreeIds(node.value);\n\t\t}\n\t}\n\tassert(\n\t\ttree.id === undefined || tree.id === null,\n\t\t0x096 /* \"Trying to remove valid tree IDs in removeNullTreeIds()!\" */,\n\t);\n\tdelete tree.id;\n}\nexport const FluidFetchReaderFileSnapshotWriter = FileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
1
+ {"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,+DAA8D;AAC9D,2DAAoD;AAEpD,+DAAoG;AACpG,0EAA4D;AAC5D,iEAA8F;AAE9F,iDAAiD;AACjD,gFAAgF;AAChF;;GAEG;AACU,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;;GAGG;AACH,MAAa,gBACZ,SAAQ,8CAA8B;IAKtC,YACkB,IAAY,EACZ,WAAoB;QAErC,KAAK,EAAE,CAAC;QAHS,SAAI,GAAJ,IAAI,CAAQ;QACZ,gBAAW,GAAX,WAAW,CAAS;QAJ5B,YAAO,GAA6B,IAAI,CAAC;IAOnD,CAAC;IAED;;;OAGG;IACH,kDAAkD;IAC3C,KAAK,CAAC,eAAe,CAAC,OAAsB;QAClD,IA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,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChD,MAAM,IAAI,GAAc;gBACvB,QAAQ;gBACR,QAAQ,EAAE,OAAO;aACjB,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,IAAI;gBACvB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI;gBACxB,KAAK,EAAE,IAAI;aACX,CAAC,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC;AAlGU,QAAA,8BAA8B,kCAkGxC;AAEH,SAAS,iBAAiB,CAAC,IAAe;IACzC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;YACrC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC9B;KACD;IACD,IAAA,mBAAM,EACL,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EACzC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,OAAO,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC;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\";\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { buildSnapshotTree, convertSummaryTreeToSnapshotITree } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IFileSnapshot, ReadDocumentStorageServiceBase } from \"@fluidframework/replay-driver\";\n\n// This ID is used by replay tool as Document Id.\n// We leverage it to figure out when container is asking for root document tree.\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"]}
@@ -11,7 +11,6 @@ import { IDocumentService } from '@fluidframework/driver-definitions';
11
11
  import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
12
  import { IDocumentStorageService } from '@fluidframework/driver-definitions';
13
13
  import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
14
- import { IFileSnapshot } from '@fluidframework/replay-driver';
15
14
  import { IResolvedUrl } from '@fluidframework/driver-definitions';
16
15
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
17
16
  import { ISignalClient } from '@fluidframework/protocol-definitions';
@@ -21,167 +20,30 @@ import { ISummaryContext } from '@fluidframework/driver-definitions';
21
20
  import { ISummaryTree } from '@fluidframework/protocol-definitions';
22
21
  import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
23
22
  import { ITokenClaims } from '@fluidframework/protocol-definitions';
24
- import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
25
23
 
26
- /**
27
- * Provides access to the underlying delta storage on the local file storage for file driver.
28
- */
29
- export declare class FileDeltaStorageService implements IDocumentDeltaStorageService {
30
- private readonly path;
31
- private readonly messages;
32
- private lastOps;
33
- constructor(path: string);
34
- fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<api.ISequencedDocumentMessage[]>;
35
- get ops(): readonly Readonly<api.ISequencedDocumentMessage>[];
36
- /**
37
- * Retrieve ops within the exclusive sequence number range.
38
- *
39
- * @param from - First op to be fetched.
40
- * @param to - Last op to be fetched. This is exclusive.
41
- */
42
- getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[];
43
- }
24
+ /* Excluded from this release type: FileDeltaStorageService */
44
25
 
45
- /**
46
- * Factory for creating the file document service. Use this if you want to
47
- * use the local file storage as underlying storage.
48
- */
49
- export declare class FileDocumentServiceFactory implements IDocumentServiceFactory {
50
- private readonly storage;
51
- private readonly deltaStorage;
52
- private readonly deltaConnection;
53
- constructor(storage: IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: IDocumentDeltaConnection);
54
- /**
55
- * Creates the file document service if the path exists.
56
- *
57
- * @param fileURL - Path of directory containing ops/snapshots.
58
- * @returns file document service.
59
- */
60
- createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
61
- createContainer(createNewSummary: ISummaryTree, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
62
- }
26
+ /* Excluded from this release type: FileDocumentServiceFactory */
63
27
 
64
- export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
65
- new (...args: any[]): {
66
- blobsWriter: Map<string, ArrayBufferLike>;
67
- latestWriterTree?: api.ISnapshotTree | undefined;
68
- docId?: string | undefined;
69
- reset(): void;
70
- onSnapshotHandler(snapshot: IFileSnapshot): void;
71
- readBlob(sha: string): Promise<ArrayBufferLike>;
72
- getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
73
- getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
74
- uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
75
- buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
76
- repositoryUrl: string;
77
- readonly policies?: IDocumentStorageServicePolicies | undefined;
78
- createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
79
- downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
80
- readonly disposed?: boolean | undefined;
81
- dispose?: ((error?: Error | undefined) => void) | undefined;
82
- };
83
- } & TBase;
28
+ /* Excluded from this release type: FileSnapshotWriterClassFactory */
84
29
 
85
- export declare const FileStorageDocumentName = "FileStorageDocId";
30
+ /* Excluded from this release type: FileStorageDocumentName */
86
31
 
87
- /**
88
- * Document storage service for the file driver.
89
- */
90
- export declare class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
91
- private readonly path;
92
- private readonly versionName?;
93
- protected docTree: api.ISnapshotTree | null;
94
- constructor(path: string, versionName?: string | undefined);
95
- /**
96
- * Read the file and returns the snapshot tree.
97
- * @param version - The version contains the path of the file which contains the snapshot tree.
98
- */
99
- getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
100
- /**
101
- * Gets the path of the snapshot tree to be read.
102
- * @param versionId - version ID.
103
- * @param count - Number of versions to be returned.
104
- */
105
- getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
106
- readBlob(sha: string): Promise<ArrayBufferLike>;
107
- }
32
+ /* Excluded from this release type: FluidFetchReader */
108
33
 
109
- export declare const FluidFetchReaderFileSnapshotWriter: {
110
- new (...args: any[]): {
111
- blobsWriter: Map<string, ArrayBufferLike>;
112
- latestWriterTree?: api.ISnapshotTree | undefined;
113
- docId?: string | undefined;
114
- reset(): void;
115
- onSnapshotHandler(snapshot: IFileSnapshot): void;
116
- readBlob(sha: string): Promise<ArrayBufferLike>;
117
- getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
118
- getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
119
- uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
120
- buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
121
- repositoryUrl: string;
122
- readonly policies?: IDocumentStorageServicePolicies | undefined;
123
- createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
124
- downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
125
- readonly disposed?: boolean | undefined;
126
- dispose?: ((error?: Error | undefined) => void) | undefined;
127
- };
128
- } & typeof FluidFetchReader;
34
+ /* Excluded from this release type: FluidFetchReaderFileSnapshotWriter */
129
35
 
130
- export declare interface ISnapshotWriterStorage extends IDocumentStorageService {
131
- onSnapshotHandler(snapshot: IFileSnapshot): void;
132
- reset(): void;
133
- }
36
+ /* Excluded from this release type: IFileSnapshot */
134
37
 
135
- export declare type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
38
+ /* Excluded from this release type: ISnapshotWriterStorage */
136
39
 
137
- /**
138
- * Replay service used to play ops using the delta connection.
139
- */
140
- export declare class Replayer {
141
- private readonly deltaConnection;
142
- private readonly documentStorageService;
143
- private currentReplayOp;
144
- constructor(deltaConnection: ReplayFileDeltaConnection, documentStorageService: FileDeltaStorageService);
145
- get currentReplayedOp(): number;
146
- set currentReplayedOp(op: number);
147
- get ops(): readonly Readonly<ISequencedDocumentMessage>[];
148
- /**
149
- * Replay the ops upto a certain number.
150
- * @param replayTo - The last op number to be replayed.
151
- */
152
- replay(replayTo: number): number;
153
- private isDoneFetch;
154
- private emit;
155
- }
40
+ /* Excluded from this release type: ReadDocumentStorageServiceBase */
156
41
 
157
- export declare class ReplayFileDeltaConnection extends TypedEventEmitter<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable {
158
- details: IConnected;
159
- /**
160
- * Mimic the delta connection to replay ops on it.
161
- *
162
- * @param documentDeltaStorageService - The delta storage service to get ops from.
163
- * @returns Document delta connection.
164
- */
165
- static create(documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection>;
166
- readonly maxMessageSize: number;
167
- private readonly replayer;
168
- constructor(details: IConnected, documentDeltaStorageService: FileDeltaStorageService);
169
- getReplayer(): Replayer;
170
- get clientId(): string;
171
- get mode(): ConnectionMode;
172
- get claims(): ITokenClaims;
173
- get existing(): boolean;
174
- get version(): string;
175
- get initialMessages(): ISequencedDocumentMessage[];
176
- get initialSignals(): ISignalMessage[];
177
- get initialClients(): ISignalClient[];
178
- get serviceConfiguration(): IClientConfiguration;
179
- submit(documentMessages: IDocumentMessage[]): void;
180
- submitSignal(message: any): Promise<void>;
181
- private _disposed;
182
- get disposed(): boolean;
183
- dispose(): void;
184
- }
42
+ /* Excluded from this release type: ReaderConstructor */
43
+
44
+ /* Excluded from this release type: Replayer */
45
+
46
+ /* Excluded from this release type: ReplayFileDeltaConnection */
185
47
 
186
48
  /* Excluded from this release type: TypedEventEmitter */
187
49
 
@@ -2,186 +2,59 @@ import * as api from '@fluidframework/protocol-definitions';
2
2
  import { ConnectionMode } from '@fluidframework/protocol-definitions';
3
3
  import { IClientConfiguration } from '@fluidframework/protocol-definitions';
4
4
  import { IConnected } from '@fluidframework/protocol-definitions';
5
- import { IDisposable } from '@fluidframework/core-interfaces';
6
- import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
7
- import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
8
- import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
5
  import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
- import { IDocumentService } from '@fluidframework/driver-definitions';
11
- import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
- import { IDocumentStorageService } from '@fluidframework/driver-definitions';
13
6
  import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
14
- import { IFileSnapshot } from '@fluidframework/replay-driver';
15
- import { IResolvedUrl } from '@fluidframework/driver-definitions';
16
7
  import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
17
8
  import { ISignalClient } from '@fluidframework/protocol-definitions';
18
9
  import { ISignalMessage } from '@fluidframework/protocol-definitions';
19
- import { IStream } from '@fluidframework/driver-definitions';
20
- import { ISummaryContext } from '@fluidframework/driver-definitions';
21
10
  import { ISummaryTree } from '@fluidframework/protocol-definitions';
22
- import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
23
11
  import { ITokenClaims } from '@fluidframework/protocol-definitions';
24
- import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
25
-
26
- /**
27
- * Provides access to the underlying delta storage on the local file storage for file driver.
28
- */
29
- export declare class FileDeltaStorageService implements IDocumentDeltaStorageService {
30
- private readonly path;
31
- private readonly messages;
32
- private lastOps;
33
- constructor(path: string);
34
- fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<api.ISequencedDocumentMessage[]>;
35
- get ops(): readonly Readonly<api.ISequencedDocumentMessage>[];
36
- /**
37
- * Retrieve ops within the exclusive sequence number range.
38
- *
39
- * @param from - First op to be fetched.
40
- * @param to - Last op to be fetched. This is exclusive.
41
- */
42
- getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[];
43
- }
44
-
45
- /**
46
- * Factory for creating the file document service. Use this if you want to
47
- * use the local file storage as underlying storage.
48
- */
49
- export declare class FileDocumentServiceFactory implements IDocumentServiceFactory {
50
- private readonly storage;
51
- private readonly deltaStorage;
52
- private readonly deltaConnection;
53
- constructor(storage: IDocumentStorageService, deltaStorage: FileDeltaStorageService, deltaConnection: IDocumentDeltaConnection);
54
- /**
55
- * Creates the file document service if the path exists.
56
- *
57
- * @param fileURL - Path of directory containing ops/snapshots.
58
- * @returns file document service.
59
- */
60
- createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
61
- createContainer(createNewSummary: ISummaryTree, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
62
- }
63
-
64
- export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
65
- new (...args: any[]): {
66
- blobsWriter: Map<string, ArrayBufferLike>;
67
- latestWriterTree?: api.ISnapshotTree | undefined;
68
- docId?: string | undefined;
69
- reset(): void;
70
- onSnapshotHandler(snapshot: IFileSnapshot): void;
71
- readBlob(sha: string): Promise<ArrayBufferLike>;
72
- getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
73
- getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
74
- uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
75
- buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
76
- repositoryUrl: string;
77
- readonly policies?: IDocumentStorageServicePolicies | undefined;
78
- createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
79
- downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
80
- readonly disposed?: boolean | undefined;
81
- dispose?: ((error?: Error | undefined) => void) | undefined;
82
- };
83
- } & TBase;
84
-
85
- export declare const FileStorageDocumentName = "FileStorageDocId";
86
-
87
- /**
88
- * Document storage service for the file driver.
89
- */
90
- export declare class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
91
- private readonly path;
92
- private readonly versionName?;
93
- protected docTree: api.ISnapshotTree | null;
94
- constructor(path: string, versionName?: string | undefined);
95
- /**
96
- * Read the file and returns the snapshot tree.
97
- * @param version - The version contains the path of the file which contains the snapshot tree.
98
- */
99
- getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
100
- /**
101
- * Gets the path of the snapshot tree to be read.
102
- * @param versionId - version ID.
103
- * @param count - Number of versions to be returned.
104
- */
105
- getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
106
- readBlob(sha: string): Promise<ArrayBufferLike>;
107
- }
108
-
109
- export declare const FluidFetchReaderFileSnapshotWriter: {
110
- new (...args: any[]): {
111
- blobsWriter: Map<string, ArrayBufferLike>;
112
- latestWriterTree?: api.ISnapshotTree | undefined;
113
- docId?: string | undefined;
114
- reset(): void;
115
- onSnapshotHandler(snapshot: IFileSnapshot): void;
116
- readBlob(sha: string): Promise<ArrayBufferLike>;
117
- getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
118
- getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null>;
119
- uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string>;
120
- buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree>;
121
- repositoryUrl: string;
122
- readonly policies?: IDocumentStorageServicePolicies | undefined;
123
- createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
124
- downloadSummary(handle: api.ISummaryHandle): Promise<api.ISummaryTree>;
125
- readonly disposed?: boolean | undefined;
126
- dispose?: ((error?: Error | undefined) => void) | undefined;
127
- };
128
- } & typeof FluidFetchReader;
129
-
130
- export declare interface ISnapshotWriterStorage extends IDocumentStorageService {
131
- onSnapshotHandler(snapshot: IFileSnapshot): void;
132
- reset(): void;
133
- }
134
-
135
- export declare type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
136
-
137
- /**
138
- * Replay service used to play ops using the delta connection.
139
- */
140
- export declare class Replayer {
141
- private readonly deltaConnection;
142
- private readonly documentStorageService;
143
- private currentReplayOp;
144
- constructor(deltaConnection: ReplayFileDeltaConnection, documentStorageService: FileDeltaStorageService);
145
- get currentReplayedOp(): number;
146
- set currentReplayedOp(op: number);
147
- get ops(): readonly Readonly<ISequencedDocumentMessage>[];
148
- /**
149
- * Replay the ops upto a certain number.
150
- * @param replayTo - The last op number to be replayed.
151
- */
152
- replay(replayTo: number): number;
153
- private isDoneFetch;
154
- private emit;
155
- }
156
-
157
- export declare class ReplayFileDeltaConnection extends TypedEventEmitter<IDocumentDeltaConnectionEvents> implements IDocumentDeltaConnection, IDisposable {
158
- details: IConnected;
159
- /**
160
- * Mimic the delta connection to replay ops on it.
161
- *
162
- * @param documentDeltaStorageService - The delta storage service to get ops from.
163
- * @returns Document delta connection.
164
- */
165
- static create(documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection>;
166
- readonly maxMessageSize: number;
167
- private readonly replayer;
168
- constructor(details: IConnected, documentDeltaStorageService: FileDeltaStorageService);
169
- getReplayer(): Replayer;
170
- get clientId(): string;
171
- get mode(): ConnectionMode;
172
- get claims(): ITokenClaims;
173
- get existing(): boolean;
174
- get version(): string;
175
- get initialMessages(): ISequencedDocumentMessage[];
176
- get initialSignals(): ISignalMessage[];
177
- get initialClients(): ISignalClient[];
178
- get serviceConfiguration(): IClientConfiguration;
179
- submit(documentMessages: IDocumentMessage[]): void;
180
- submitSignal(message: any): Promise<void>;
181
- private _disposed;
182
- get disposed(): boolean;
183
- dispose(): void;
184
- }
12
+
13
+ /* Excluded from this release type: FileDeltaStorageService */
14
+
15
+ /* Excluded from this release type: FileDocumentServiceFactory */
16
+
17
+ /* Excluded from this release type: FileSnapshotWriterClassFactory */
18
+
19
+ /* Excluded from this release type: FileStorageDocumentName */
20
+
21
+ /* Excluded from this release type: FluidFetchReader */
22
+
23
+ /* Excluded from this release type: FluidFetchReaderFileSnapshotWriter */
24
+
25
+ /* Excluded from this release type: IDisposable */
26
+
27
+ /* Excluded from this release type: IDocumentDeltaConnection */
28
+
29
+ /* Excluded from this release type: IDocumentDeltaConnectionEvents */
30
+
31
+ /* Excluded from this release type: IDocumentDeltaStorageService */
32
+
33
+ /* Excluded from this release type: IDocumentService */
34
+
35
+ /* Excluded from this release type: IDocumentServiceFactory */
36
+
37
+ /* Excluded from this release type: IDocumentStorageService */
38
+
39
+ /* Excluded from this release type: IFileSnapshot */
40
+
41
+ /* Excluded from this release type: IResolvedUrl */
42
+
43
+ /* Excluded from this release type: ISnapshotWriterStorage */
44
+
45
+ /* Excluded from this release type: IStream */
46
+
47
+ /* Excluded from this release type: ISummaryContext */
48
+
49
+ /* Excluded from this release type: ITelemetryBaseLogger */
50
+
51
+ /* Excluded from this release type: ReadDocumentStorageServiceBase */
52
+
53
+ /* Excluded from this release type: ReaderConstructor */
54
+
55
+ /* Excluded from this release type: Replayer */
56
+
57
+ /* Excluded from this release type: ReplayFileDeltaConnection */
185
58
 
186
59
  /* Excluded from this release type: TypedEventEmitter */
187
60