@fluidframework/file-driver 2.0.0-internal.7.3.0 → 2.0.0-internal.8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +3 -3
  4. package/api-report/file-driver.api.md +10 -10
  5. package/dist/file-driver-alpha.d.ts +51 -0
  6. package/dist/file-driver-beta.d.ts +75 -0
  7. package/dist/file-driver-public.d.ts +75 -0
  8. package/dist/file-driver-untrimmed.d.ts +209 -0
  9. package/dist/fileDeltaStorageService.d.ts +1 -0
  10. package/dist/fileDeltaStorageService.d.ts.map +1 -1
  11. package/dist/fileDeltaStorageService.js +1 -0
  12. package/dist/fileDeltaStorageService.js.map +1 -1
  13. package/dist/fileDocumentDeltaConnection.d.ts +4 -0
  14. package/dist/fileDocumentDeltaConnection.d.ts.map +1 -1
  15. package/dist/fileDocumentDeltaConnection.js +4 -0
  16. package/dist/fileDocumentDeltaConnection.js.map +1 -1
  17. package/dist/fileDocumentServiceFactory.d.ts +1 -0
  18. package/dist/fileDocumentServiceFactory.d.ts.map +1 -1
  19. package/dist/fileDocumentServiceFactory.js +1 -0
  20. package/dist/fileDocumentServiceFactory.js.map +1 -1
  21. package/dist/fileDocumentStorageService.d.ts +16 -0
  22. package/dist/fileDocumentStorageService.d.ts.map +1 -1
  23. package/dist/fileDocumentStorageService.js +10 -0
  24. package/dist/fileDocumentStorageService.js.map +1 -1
  25. package/lib/file-driver-alpha.d.ts +51 -0
  26. package/lib/file-driver-beta.d.ts +75 -0
  27. package/lib/file-driver-public.d.ts +75 -0
  28. package/lib/file-driver-untrimmed.d.ts +209 -0
  29. package/package.json +27 -12
  30. package/src/fileDeltaStorageService.ts +1 -0
  31. package/src/fileDocumentDeltaConnection.ts +4 -0
  32. package/src/fileDocumentServiceFactory.ts +1 -0
  33. package/src/fileDocumentStorageService.ts +16 -0
@@ -1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,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;AAxGD,8DAwGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\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 */\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\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"]}
1
+ {"version":3,"file":"fileDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+EAU8C;AAC9C,+DAAiE;AAGjE,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,qFAAqF;AACrF,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,MAAM,MAAM,GAAiB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,CAAC,gCAAS,CAAC,OAAO,CAAC;IAC3B,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACL,EAAE,EAAE,EAAE;KACN;IACD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAA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soft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\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"]}
@@ -9,6 +9,7 @@ import { FileDeltaStorageService } from "./fileDeltaStorageService";
9
9
  /**
10
10
  * Factory for creating the file document service. Use this if you want to
11
11
  * use the local file storage as underlying storage.
12
+ * @internal
12
13
  */
13
14
  export declare class FileDocumentServiceFactory implements IDocumentServiceFactory {
14
15
  private readonly storage;
@@ -1 +1 @@
1
- {"version":3,"file":"fileDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,uBAAuB;IAExE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,OAAO,EAAE,uBAAuB,EAChC,YAAY,EAAE,uBAAuB,EACrC,eAAe,EAAE,wBAAwB;IAG3D;;;;;OAKG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAUf,eAAe,CAC3B,gBAAgB,EAAE,YAAY,EAC9B,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;CAG5B"}
1
+ {"version":3,"file":"fileDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,uBAAuB;IAExE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,OAAO,EAAE,uBAAuB,EAChC,YAAY,EAAE,uBAAuB,EACrC,eAAe,EAAE,wBAAwB;IAG3D;;;;;OAKG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAUf,eAAe,CAC3B,gBAAgB,EAAE,YAAY,EAC9B,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;CAG5B"}
@@ -9,6 +9,7 @@ const fileDocumentService_1 = require("./fileDocumentService");
9
9
  /**
10
10
  * Factory for creating the file document service. Use this if you want to
11
11
  * use the local file storage as underlying storage.
12
+ * @internal
12
13
  */
13
14
  class FileDocumentServiceFactory {
14
15
  constructor(storage, deltaStorage, deltaConnection) {
@@ -1 +1 @@
1
- {"version":3,"file":"fileDocumentServiceFactory.js","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,+DAA4D;AAE5D;;;GAGG;AACH,MAAa,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,yCAAmB,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;AAnCD,gEAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\nimport { FileDocumentService } from \"./fileDocumentService\";\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 */\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"]}
1
+ {"version":3,"file":"fileDocumentServiceFactory.js","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,+DAA4D;AAE5D;;;;GAIG;AACH,MAAa,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,yCAAmB,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;AAnCD,gEAmCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\nimport { FileDocumentService } from \"./fileDocumentService\";\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"]}
@@ -5,9 +5,13 @@
5
5
  import { IDocumentStorageService, ISummaryContext } from "@fluidframework/driver-definitions";
6
6
  import * as api from "@fluidframework/protocol-definitions";
7
7
  import { IFileSnapshot, ReadDocumentStorageServiceBase } from "@fluidframework/replay-driver";
8
+ /**
9
+ * @internal
10
+ */
8
11
  export declare const FileStorageDocumentName = "FileStorageDocId";
9
12
  /**
10
13
  * Document storage service for the file driver.
14
+ * @internal
11
15
  */
12
16
  export declare class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
13
17
  private readonly path;
@@ -27,11 +31,20 @@ export declare class FluidFetchReader extends ReadDocumentStorageServiceBase imp
27
31
  getVersions(versionId: string | null, count: number): Promise<api.IVersion[]>;
28
32
  readBlob(sha: string): Promise<ArrayBufferLike>;
29
33
  }
34
+ /**
35
+ * @internal
36
+ */
30
37
  export interface ISnapshotWriterStorage extends IDocumentStorageService {
31
38
  onSnapshotHandler(snapshot: IFileSnapshot): void;
32
39
  reset(): void;
33
40
  }
41
+ /**
42
+ * @internal
43
+ */
34
44
  export type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;
45
+ /**
46
+ * @internal
47
+ */
35
48
  export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstructor>(Base: TBase) => {
36
49
  new (...args: any[]): {
37
50
  blobsWriter: Map<string, ArrayBufferLike>;
@@ -52,6 +65,9 @@ export declare const FileSnapshotWriterClassFactory: <TBase extends ReaderConstr
52
65
  dispose?: ((error?: Error | undefined) => void) | undefined;
53
66
  };
54
67
  } & TBase;
68
+ /**
69
+ * @internal
70
+ */
55
71
  export declare const FluidFetchReaderFileSnapshotWriter: {
56
72
  new (...args: any[]): {
57
73
  blobsWriter: Map<string, ArrayBufferLike>;
@@ -1 +1 @@
1
- {"version":3,"file":"fileDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE9F,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,8BAA8B,EAAE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 const api = __importStar(require("@fluidframework/protocol-definitions"));
39
39
  const replay_driver_1 = require("@fluidframework/replay-driver");
40
40
  // This ID is used by replay tool as Document Id.
41
41
  // We leverage it to figure out when container is asking for root document tree.
42
+ /**
43
+ * @internal
44
+ */
42
45
  exports.FileStorageDocumentName = "FileStorageDocId"; // Some unique document name
43
46
  // Tree ID use to communicate between getVersions() & getSnapshotTree() that IVersion is ours.
44
47
  const FileStorageVersionTreeId = "FileStorageTreeId";
45
48
  /**
46
49
  * Document storage service for the file driver.
50
+ * @internal
47
51
  */
48
52
  class FluidFetchReader extends replay_driver_1.ReadDocumentStorageServiceBase {
49
53
  constructor(path, versionName) {
@@ -123,6 +127,9 @@ class FluidFetchReader extends replay_driver_1.ReadDocumentStorageServiceBase {
123
127
  }
124
128
  }
125
129
  exports.FluidFetchReader = FluidFetchReader;
130
+ /**
131
+ * @internal
132
+ */
126
133
  const FileSnapshotWriterClassFactory = (Base) => class extends Base {
127
134
  constructor() {
128
135
  super(...arguments);
@@ -214,5 +221,8 @@ function removeNullTreeIds(tree) {
214
221
  (0, core_utils_1.assert)(tree.id === undefined || tree.id === null, 0x096 /* "Trying to remove valid tree IDs in removeNullTreeIds()!" */);
215
222
  delete tree.id;
216
223
  }
224
+ /**
225
+ * @internal
226
+ */
217
227
  exports.FluidFetchReaderFileSnapshotWriter = (0, exports.FileSnapshotWriterClassFactory)(FluidFetchReader);
218
228
  //# sourceMappingURL=fileDocumentStorageService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,+DAA8D;AAC9D,2DAAoD;AAEpD,+DAAoG;AACpG,0EAA4D;AAC5D,iEAA8F;AAE9F,iDAAiD;AACjD,gFAAgF;AACnE,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF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. 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,IAAA,mBAAM,EAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACzF,IAAA,mBAAM,EACL,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,wBAAwB,EACvD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;QAEF,IAAI,QAAgB,CAAC;QACrB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,KAAK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;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"]}
@@ -0,0 +1,51 @@
1
+ import * as api from '@fluidframework/protocol-definitions';
2
+ import { ConnectionMode } from '@fluidframework/protocol-definitions';
3
+ import { IClientConfiguration } from '@fluidframework/protocol-definitions';
4
+ import { IConnected } from '@fluidframework/protocol-definitions';
5
+ import { IDisposable } from '@fluidframework/core-interfaces';
6
+ import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
7
+ import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
8
+ import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
+ import { IDocumentService } from '@fluidframework/driver-definitions';
11
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
13
+ import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
14
+ import { IFileSnapshot } from '@fluidframework/replay-driver';
15
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
16
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
17
+ import { ISignalClient } from '@fluidframework/protocol-definitions';
18
+ import { ISignalMessage } from '@fluidframework/protocol-definitions';
19
+ import { IStream } from '@fluidframework/driver-definitions';
20
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
21
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
22
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
23
+ import { ITokenClaims } from '@fluidframework/protocol-definitions';
24
+ import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
25
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
26
+
27
+ /* Excluded from this release type: FileDeltaStorageService */
28
+
29
+ /* Excluded from this release type: FileDocumentServiceFactory */
30
+
31
+ /* Excluded from this release type: FileSnapshotWriterClassFactory */
32
+
33
+ /* Excluded from this release type: FileStorageDocumentName */
34
+
35
+ /* Excluded from this release type: FluidFetchReader */
36
+
37
+ /* Excluded from this release type: FluidFetchReaderFileSnapshotWriter */
38
+
39
+ /* Excluded from this release type: IFileSnapshot */
40
+
41
+ /* Excluded from this release type: ISnapshotWriterStorage */
42
+
43
+ /* Excluded from this release type: ReadDocumentStorageServiceBase */
44
+
45
+ /* Excluded from this release type: ReaderConstructor */
46
+
47
+ /* Excluded from this release type: Replayer */
48
+
49
+ /* Excluded from this release type: ReplayFileDeltaConnection */
50
+
51
+ export { }
@@ -0,0 +1,75 @@
1
+ import * as api from '@fluidframework/protocol-definitions';
2
+ import { ConnectionMode } from '@fluidframework/protocol-definitions';
3
+ import { IClientConfiguration } from '@fluidframework/protocol-definitions';
4
+ import { IConnected } from '@fluidframework/protocol-definitions';
5
+ import { IDisposable } from '@fluidframework/core-interfaces';
6
+ import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
7
+ import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
8
+ import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
+ import { IDocumentService } from '@fluidframework/driver-definitions';
11
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
13
+ import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
14
+ import { IFileSnapshot } from '@fluidframework/replay-driver';
15
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
16
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
17
+ import { ISignalClient } from '@fluidframework/protocol-definitions';
18
+ import { ISignalMessage } from '@fluidframework/protocol-definitions';
19
+ import { IStream } from '@fluidframework/driver-definitions';
20
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
21
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
22
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
23
+ import { ITokenClaims } from '@fluidframework/protocol-definitions';
24
+ import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
25
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
26
+
27
+ /* Excluded from this release type: FileDeltaStorageService */
28
+
29
+ /* Excluded from this release type: FileDocumentServiceFactory */
30
+
31
+ /* Excluded from this release type: FileSnapshotWriterClassFactory */
32
+
33
+ /* Excluded from this release type: FileStorageDocumentName */
34
+
35
+ /* Excluded from this release type: FluidFetchReader */
36
+
37
+ /* Excluded from this release type: FluidFetchReaderFileSnapshotWriter */
38
+
39
+ /* Excluded from this release type: IDisposable */
40
+
41
+ /* Excluded from this release type: IDocumentDeltaConnection */
42
+
43
+ /* Excluded from this release type: IDocumentDeltaConnectionEvents */
44
+
45
+ /* Excluded from this release type: IDocumentDeltaStorageService */
46
+
47
+ /* Excluded from this release type: IDocumentService */
48
+
49
+ /* Excluded from this release type: IDocumentServiceFactory */
50
+
51
+ /* Excluded from this release type: IDocumentStorageService */
52
+
53
+ /* Excluded from this release type: IFileSnapshot */
54
+
55
+ /* Excluded from this release type: IResolvedUrl */
56
+
57
+ /* Excluded from this release type: ISnapshotWriterStorage */
58
+
59
+ /* Excluded from this release type: IStream */
60
+
61
+ /* Excluded from this release type: ISummaryContext */
62
+
63
+ /* Excluded from this release type: ITelemetryBaseLogger */
64
+
65
+ /* Excluded from this release type: ReadDocumentStorageServiceBase */
66
+
67
+ /* Excluded from this release type: ReaderConstructor */
68
+
69
+ /* Excluded from this release type: Replayer */
70
+
71
+ /* Excluded from this release type: ReplayFileDeltaConnection */
72
+
73
+ /* Excluded from this release type: TypedEventEmitter */
74
+
75
+ export { }
@@ -0,0 +1,75 @@
1
+ import * as api from '@fluidframework/protocol-definitions';
2
+ import { ConnectionMode } from '@fluidframework/protocol-definitions';
3
+ import { IClientConfiguration } from '@fluidframework/protocol-definitions';
4
+ import { IConnected } from '@fluidframework/protocol-definitions';
5
+ import { IDisposable } from '@fluidframework/core-interfaces';
6
+ import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
7
+ import { IDocumentDeltaConnectionEvents } from '@fluidframework/driver-definitions';
8
+ import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
+ import { IDocumentService } from '@fluidframework/driver-definitions';
11
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
13
+ import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
14
+ import { IFileSnapshot } from '@fluidframework/replay-driver';
15
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
16
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
17
+ import { ISignalClient } from '@fluidframework/protocol-definitions';
18
+ import { ISignalMessage } from '@fluidframework/protocol-definitions';
19
+ import { IStream } from '@fluidframework/driver-definitions';
20
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
21
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
22
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
23
+ import { ITokenClaims } from '@fluidframework/protocol-definitions';
24
+ import { ReadDocumentStorageServiceBase } from '@fluidframework/replay-driver';
25
+ import { TypedEventEmitter } from '@fluid-internal/client-utils';
26
+
27
+ /* Excluded from this release type: FileDeltaStorageService */
28
+
29
+ /* Excluded from this release type: FileDocumentServiceFactory */
30
+
31
+ /* Excluded from this release type: FileSnapshotWriterClassFactory */
32
+
33
+ /* Excluded from this release type: FileStorageDocumentName */
34
+
35
+ /* Excluded from this release type: FluidFetchReader */
36
+
37
+ /* Excluded from this release type: FluidFetchReaderFileSnapshotWriter */
38
+
39
+ /* Excluded from this release type: IDisposable */
40
+
41
+ /* Excluded from this release type: IDocumentDeltaConnection */
42
+
43
+ /* Excluded from this release type: IDocumentDeltaConnectionEvents */
44
+
45
+ /* Excluded from this release type: IDocumentDeltaStorageService */
46
+
47
+ /* Excluded from this release type: IDocumentService */
48
+
49
+ /* Excluded from this release type: IDocumentServiceFactory */
50
+
51
+ /* Excluded from this release type: IDocumentStorageService */
52
+
53
+ /* Excluded from this release type: IFileSnapshot */
54
+
55
+ /* Excluded from this release type: IResolvedUrl */
56
+
57
+ /* Excluded from this release type: ISnapshotWriterStorage */
58
+
59
+ /* Excluded from this release type: IStream */
60
+
61
+ /* Excluded from this release type: ISummaryContext */
62
+
63
+ /* Excluded from this release type: ITelemetryBaseLogger */
64
+
65
+ /* Excluded from this release type: ReadDocumentStorageServiceBase */
66
+
67
+ /* Excluded from this release type: ReaderConstructor */
68
+
69
+ /* Excluded from this release type: Replayer */
70
+
71
+ /* Excluded from this release type: ReplayFileDeltaConnection */
72
+
73
+ /* Excluded from this release type: TypedEventEmitter */
74
+
75
+ export { }