@fluidframework/replay-driver 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

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 (121) hide show
  1. package/.eslintrc.js +5 -7
  2. package/CHANGELOG.md +144 -0
  3. package/README.md +38 -0
  4. package/api-extractor-lint.json +4 -0
  5. package/api-extractor.json +2 -2
  6. package/api-report/replay-driver.api.md +150 -0
  7. package/dist/{emptyDeltaStorageService.js → emptyDeltaStorageService.cjs} +1 -1
  8. package/dist/emptyDeltaStorageService.cjs.map +1 -0
  9. package/dist/emptyDeltaStorageService.d.ts.map +1 -1
  10. package/dist/index.cjs +20 -0
  11. package/dist/index.cjs.map +1 -0
  12. package/dist/index.d.ts +4 -4
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/replay-driver-alpha.d.ts +34 -0
  15. package/dist/replay-driver-beta.d.ts +44 -0
  16. package/dist/replay-driver-public.d.ts +44 -0
  17. package/dist/replay-driver-untrimmed.d.ts +187 -0
  18. package/dist/{replayController.js → replayController.cjs} +6 -4
  19. package/dist/replayController.cjs.map +1 -0
  20. package/dist/replayController.d.ts +4 -2
  21. package/dist/replayController.d.ts.map +1 -1
  22. package/dist/{replayDocumentDeltaConnection.js → replayDocumentDeltaConnection.cjs} +25 -27
  23. package/dist/replayDocumentDeltaConnection.cjs.map +1 -0
  24. package/dist/replayDocumentDeltaConnection.d.ts +2 -2
  25. package/dist/replayDocumentDeltaConnection.d.ts.map +1 -1
  26. package/dist/{replayDocumentService.js → replayDocumentService.cjs} +9 -7
  27. package/dist/replayDocumentService.cjs.map +1 -0
  28. package/dist/replayDocumentService.d.ts +1 -0
  29. package/dist/replayDocumentService.d.ts.map +1 -1
  30. package/dist/{replayDocumentServiceFactory.js → replayDocumentServiceFactory.cjs} +13 -8
  31. package/dist/replayDocumentServiceFactory.cjs.map +1 -0
  32. package/dist/replayDocumentServiceFactory.d.ts +4 -2
  33. package/dist/replayDocumentServiceFactory.d.ts.map +1 -1
  34. package/dist/{storageImplementations.js → storageImplementations.cjs} +21 -12
  35. package/dist/storageImplementations.cjs.map +1 -0
  36. package/dist/storageImplementations.d.ts +18 -6
  37. package/dist/storageImplementations.d.ts.map +1 -1
  38. package/dist/tsdoc-metadata.json +11 -0
  39. package/lib/emptyDeltaStorageService.d.mts.map +1 -0
  40. package/lib/{emptyDeltaStorageService.js → emptyDeltaStorageService.mjs} +1 -1
  41. package/lib/emptyDeltaStorageService.mjs.map +1 -0
  42. package/lib/index.d.mts +9 -0
  43. package/lib/index.d.mts.map +1 -0
  44. package/lib/index.mjs +9 -0
  45. package/lib/index.mjs.map +1 -0
  46. package/lib/replay-driver-alpha.d.mts +34 -0
  47. package/lib/replay-driver-beta.d.mts +44 -0
  48. package/lib/replay-driver-public.d.mts +44 -0
  49. package/lib/replay-driver-untrimmed.d.mts +187 -0
  50. package/lib/{replayController.d.ts → replayController.d.mts} +4 -2
  51. package/lib/replayController.d.mts.map +1 -0
  52. package/lib/{replayController.js → replayController.mjs} +6 -4
  53. package/lib/replayController.mjs.map +1 -0
  54. package/lib/{replayDocumentDeltaConnection.d.ts → replayDocumentDeltaConnection.d.mts} +3 -3
  55. package/lib/replayDocumentDeltaConnection.d.mts.map +1 -0
  56. package/lib/{replayDocumentDeltaConnection.js → replayDocumentDeltaConnection.mjs} +23 -25
  57. package/lib/replayDocumentDeltaConnection.mjs.map +1 -0
  58. package/lib/{replayDocumentService.d.ts → replayDocumentService.d.mts} +2 -1
  59. package/lib/replayDocumentService.d.mts.map +1 -0
  60. package/lib/{replayDocumentService.js → replayDocumentService.mjs} +9 -7
  61. package/lib/replayDocumentService.mjs.map +1 -0
  62. package/lib/{replayDocumentServiceFactory.d.ts → replayDocumentServiceFactory.d.mts} +5 -3
  63. package/lib/replayDocumentServiceFactory.d.mts.map +1 -0
  64. package/lib/{replayDocumentServiceFactory.js → replayDocumentServiceFactory.mjs} +14 -9
  65. package/lib/replayDocumentServiceFactory.mjs.map +1 -0
  66. package/lib/{storageImplementations.d.ts → storageImplementations.d.mts} +19 -7
  67. package/lib/storageImplementations.d.mts.map +1 -0
  68. package/lib/{storageImplementations.js → storageImplementations.mjs} +20 -11
  69. package/lib/storageImplementations.mjs.map +1 -0
  70. package/lib/test/types/validateReplayDriverPrevious.generated.d.mts +2 -0
  71. package/lib/test/types/validateReplayDriverPrevious.generated.d.mts.map +1 -0
  72. package/lib/test/types/{validateReplayDriverPrevious.js → validateReplayDriverPrevious.generated.mjs} +1 -3
  73. package/lib/test/types/validateReplayDriverPrevious.generated.mjs.map +1 -0
  74. package/package.json +79 -47
  75. package/prettier.config.cjs +8 -0
  76. package/src/emptyDeltaStorageService.ts +14 -13
  77. package/src/index.ts +10 -4
  78. package/src/replayController.ts +61 -55
  79. package/src/replayDocumentDeltaConnection.ts +326 -318
  80. package/src/replayDocumentService.ts +48 -44
  81. package/src/replayDocumentServiceFactory.ts +59 -47
  82. package/src/storageImplementations.ts +168 -153
  83. package/tsconfig.json +11 -13
  84. package/dist/emptyDeltaStorageService.js.map +0 -1
  85. package/dist/index.js +0 -21
  86. package/dist/index.js.map +0 -1
  87. package/dist/packageVersion.d.ts +0 -9
  88. package/dist/packageVersion.d.ts.map +0 -1
  89. package/dist/packageVersion.js +0 -12
  90. package/dist/packageVersion.js.map +0 -1
  91. package/dist/replayController.js.map +0 -1
  92. package/dist/replayDocumentDeltaConnection.js.map +0 -1
  93. package/dist/replayDocumentService.js.map +0 -1
  94. package/dist/replayDocumentServiceFactory.js.map +0 -1
  95. package/dist/storageImplementations.js.map +0 -1
  96. package/lib/emptyDeltaStorageService.d.ts.map +0 -1
  97. package/lib/emptyDeltaStorageService.js.map +0 -1
  98. package/lib/index.d.ts +0 -9
  99. package/lib/index.d.ts.map +0 -1
  100. package/lib/index.js +0 -9
  101. package/lib/index.js.map +0 -1
  102. package/lib/packageVersion.d.ts +0 -9
  103. package/lib/packageVersion.d.ts.map +0 -1
  104. package/lib/packageVersion.js +0 -9
  105. package/lib/packageVersion.js.map +0 -1
  106. package/lib/replayController.d.ts.map +0 -1
  107. package/lib/replayController.js.map +0 -1
  108. package/lib/replayDocumentDeltaConnection.d.ts.map +0 -1
  109. package/lib/replayDocumentDeltaConnection.js.map +0 -1
  110. package/lib/replayDocumentService.d.ts.map +0 -1
  111. package/lib/replayDocumentService.js.map +0 -1
  112. package/lib/replayDocumentServiceFactory.d.ts.map +0 -1
  113. package/lib/replayDocumentServiceFactory.js.map +0 -1
  114. package/lib/storageImplementations.d.ts.map +0 -1
  115. package/lib/storageImplementations.js.map +0 -1
  116. package/lib/test/types/validateReplayDriverPrevious.d.ts +0 -2
  117. package/lib/test/types/validateReplayDriverPrevious.d.ts.map +0 -1
  118. package/lib/test/types/validateReplayDriverPrevious.js.map +0 -1
  119. package/src/packageVersion.ts +0 -9
  120. package/tsconfig.esnext.json +0 -7
  121. /package/lib/{emptyDeltaStorageService.d.ts → emptyDeltaStorageService.d.mts} +0 -0
@@ -13,57 +13,61 @@ import { ReplayDocumentDeltaConnection } from "./replayDocumentDeltaConnection";
13
13
  * The Replay document service dummies out the snapshot and the delta storage.
14
14
  * Delta connection simulates the socket by fetching the ops from delta storage
15
15
  * and emitting them with a pre determined delay
16
+ * @internal
16
17
  */
18
+ // eslint-disable-next-line import/namespace
17
19
  export class ReplayDocumentService implements api.IDocumentService {
18
- public static async create(
19
- documentService: api.IDocumentService,
20
- controller: ReplayController): Promise<api.IDocumentService> {
21
- const useController = await controller.initStorage(documentService);
22
- if (!useController) {
23
- return documentService;
24
- }
20
+ public static async create(
21
+ documentService: api.IDocumentService,
22
+ controller: ReplayController,
23
+ ): Promise<api.IDocumentService> {
24
+ const useController = await controller.initStorage(documentService);
25
+ if (!useController) {
26
+ return documentService;
27
+ }
25
28
 
26
- const deltaConnection = ReplayDocumentDeltaConnection.create(
27
- await documentService.connectToDeltaStorage(),
28
- controller);
29
- return new ReplayDocumentService(controller, deltaConnection);
30
- }
29
+ const deltaConnection = ReplayDocumentDeltaConnection.create(
30
+ await documentService.connectToDeltaStorage(),
31
+ controller,
32
+ );
33
+ return new ReplayDocumentService(controller, deltaConnection);
34
+ }
31
35
 
32
- constructor(
33
- private readonly controller: api.IDocumentStorageService,
34
- private readonly deltaStorage: api.IDocumentDeltaConnection) {
35
- }
36
+ constructor(
37
+ private readonly controller: api.IDocumentStorageService,
38
+ private readonly deltaStorage: api.IDocumentDeltaConnection,
39
+ ) {}
36
40
 
37
- public dispose() {}
41
+ public dispose() {}
38
42
 
39
- // TODO: Issue-2109 Implement detach container api or put appropriate comment.
40
- public get resolvedUrl(): api.IResolvedUrl {
41
- throw new Error("Not implemented");
42
- }
43
+ // TODO: Issue-2109 Implement detach container api or put appropriate comment.
44
+ public get resolvedUrl(): api.IResolvedUrl {
45
+ throw new Error("Not implemented");
46
+ }
43
47
 
44
- /**
45
- * Connects to a storage endpoint for snapshot service and blobs.
46
- * @returns returns the dummy document storage service for replay driver.
47
- */
48
- public async connectToStorage(): Promise<api.IDocumentStorageService> {
49
- return this.controller;
50
- }
48
+ /**
49
+ * Connects to a storage endpoint for snapshot service and blobs.
50
+ * @returns returns the dummy document storage service for replay driver.
51
+ */
52
+ public async connectToStorage(): Promise<api.IDocumentStorageService> {
53
+ return this.controller;
54
+ }
51
55
 
52
- /**
53
- * Connects to a delta storage endpoint for getting ops between a range.
54
- * @returns returns the dummy document delta storage service for replay driver.
55
- */
56
- public async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {
57
- return new EmptyDeltaStorageService();
58
- }
56
+ /**
57
+ * Connects to a delta storage endpoint for getting ops between a range.
58
+ * @returns returns the dummy document delta storage service for replay driver.
59
+ */
60
+ public async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {
61
+ return new EmptyDeltaStorageService();
62
+ }
59
63
 
60
- /**
61
- * Connects to a delta storage endpoint of provided documentService to get ops and then replaying
62
- * them so as to mimic a delta stream endpoint.
63
- * @param client - Client that connects to socket.
64
- * @returns returns the delta stream service which replay ops from --from to --to arguments.
65
- */
66
- public async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {
67
- return this.deltaStorage;
68
- }
64
+ /**
65
+ * Connects to a delta storage endpoint of provided documentService to get ops and then replaying
66
+ * them so as to mimic a delta stream endpoint.
67
+ * @param client - Client that connects to socket.
68
+ * @returns returns the delta stream service which replay ops from --from to --to arguments.
69
+ */
70
+ public async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {
71
+ return this.deltaStorage;
72
+ }
69
73
  }
@@ -3,61 +3,73 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { IDocumentService, IDocumentServiceFactory, IResolvedUrl } from "@fluidframework/driver-definitions";
6
+ import {
7
+ IDocumentService,
8
+ IDocumentServiceFactory,
9
+ IResolvedUrl,
10
+ } from "@fluidframework/driver-definitions";
7
11
  import { ISummaryTree } from "@fluidframework/protocol-definitions";
8
- import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
9
- import { ChildLogger } from "@fluidframework/telemetry-utils";
12
+ import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
13
+ import { createChildLogger } from "@fluidframework/telemetry-utils";
10
14
  import { ReplayController } from "./replayController";
11
15
  import { ReplayControllerStatic } from "./replayDocumentDeltaConnection";
12
16
  import { ReplayDocumentService } from "./replayDocumentService";
13
17
 
18
+ /**
19
+ * @internal
20
+ */
14
21
  export class ReplayDocumentServiceFactory implements IDocumentServiceFactory {
15
- public static create(
16
- from: number,
17
- to: number,
18
- documentServiceFactory: IDocumentServiceFactory) {
19
- return new ReplayDocumentServiceFactory(
20
- documentServiceFactory,
21
- new ReplayControllerStatic(from, to),
22
- );
23
- }
24
-
25
- public readonly protocolName;
22
+ public static create(
23
+ from: number,
24
+ to: number,
25
+ documentServiceFactory: IDocumentServiceFactory,
26
+ ) {
27
+ return new ReplayDocumentServiceFactory(
28
+ documentServiceFactory,
29
+ new ReplayControllerStatic(from, to),
30
+ );
31
+ }
26
32
 
27
- public constructor(
28
- private readonly documentServiceFactory: IDocumentServiceFactory,
29
- private readonly controller: ReplayController) {
30
- this.protocolName = documentServiceFactory.protocolName;
31
- }
33
+ public constructor(
34
+ private readonly documentServiceFactory: IDocumentServiceFactory,
35
+ private readonly controller: ReplayController,
36
+ ) {}
32
37
 
33
- /**
34
- * Creates a replay document service which uses the document service of provided
35
- * documentServiceFactory for connecting to delta stream endpoint.
36
- * @param resolvedUrl - URL to be used for connecting to endpoints.
37
- * @returns returns the requested document service
38
- */
39
- public async createDocumentService(
40
- resolvedUrl: IResolvedUrl,
41
- logger?: ITelemetryBaseLogger,
42
- clientIsSummarizer?: boolean,
43
- ): Promise<IDocumentService> {
44
- // Always include isReplay: true on events for the Replay Driver.
45
- // It's used in testing/debugging scenarios, so we want to be able to filter these events out sometimes.
46
- const replayLogger = ChildLogger.create(
47
- logger, undefined /* namespace */, { all: { isReplay: true } } /* properties */);
38
+ /**
39
+ * Creates a replay document service which uses the document service of provided
40
+ * documentServiceFactory for connecting to delta stream endpoint.
41
+ * @param resolvedUrl - URL to be used for connecting to endpoints.
42
+ * @returns returns the requested document service
43
+ */
44
+ public async createDocumentService(
45
+ resolvedUrl: IResolvedUrl,
46
+ logger?: ITelemetryBaseLogger,
47
+ clientIsSummarizer?: boolean,
48
+ ): Promise<IDocumentService> {
49
+ // Always include isReplay: true on events for the Replay Driver.
50
+ // It's used in testing/debugging scenarios, so we want to be able to filter these events out sometimes.
51
+ const replayLogger = createChildLogger({
52
+ logger,
53
+ properties: { all: { isReplay: true } },
54
+ });
48
55
 
49
- return ReplayDocumentService.create(
50
- await this.documentServiceFactory.createDocumentService(resolvedUrl, replayLogger, clientIsSummarizer),
51
- this.controller);
52
- }
56
+ return ReplayDocumentService.create(
57
+ await this.documentServiceFactory.createDocumentService(
58
+ resolvedUrl,
59
+ replayLogger,
60
+ clientIsSummarizer,
61
+ ),
62
+ this.controller,
63
+ );
64
+ }
53
65
 
54
- // TODO: Issue-2109 Implement detach container api or put appropriate comment.
55
- public async createContainer(
56
- createNewSummary: ISummaryTree,
57
- resolvedUrl: IResolvedUrl,
58
- logger?: ITelemetryBaseLogger,
59
- clientIsSummarizer?: boolean,
60
- ): Promise<IDocumentService> {
61
- throw new Error("Not implemented");
62
- }
66
+ // TODO: Issue-2109 Implement detach container api or put appropriate comment.
67
+ public async createContainer(
68
+ createNewSummary: ISummaryTree,
69
+ resolvedUrl: IResolvedUrl,
70
+ logger?: ITelemetryBaseLogger,
71
+ clientIsSummarizer?: boolean,
72
+ ): Promise<IDocumentService> {
73
+ throw new Error("Not implemented");
74
+ }
63
75
  }
@@ -3,189 +3,204 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
7
  import {
8
- IDocumentDeltaConnection,
9
- IDocumentDeltaStorageService,
10
- IDocumentService,
11
- IDocumentServiceFactory,
12
- IDocumentStorageService,
13
- IResolvedUrl,
8
+ IDocumentDeltaConnection,
9
+ IDocumentDeltaStorageService,
10
+ IDocumentService,
11
+ IDocumentServiceFactory,
12
+ IDocumentStorageService,
13
+ IResolvedUrl,
14
14
  } from "@fluidframework/driver-definitions";
15
15
  import { buildSnapshotTree } from "@fluidframework/driver-utils";
16
16
  import {
17
- IClient,
18
- ISnapshotTree,
19
- ITree,
20
- IVersion,
21
- ISummaryTree,
17
+ IClient,
18
+ ISnapshotTree,
19
+ ITree,
20
+ IVersion,
21
+ ISummaryTree,
22
22
  } from "@fluidframework/protocol-definitions";
23
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
23
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
24
24
  import { EmptyDeltaStorageService } from "./emptyDeltaStorageService";
25
25
  import { ReadDocumentStorageServiceBase } from "./replayController";
26
26
 
27
27
  /**
28
28
  * Structure of snapshot on disk, when we store snapshot as single file
29
+ * @internal
29
30
  */
30
31
  export interface IFileSnapshot {
31
- tree: ITree;
32
- commits: { [key: string]: ITree; };
32
+ tree: ITree;
33
+ commits: { [key: string]: ITree };
33
34
  }
34
35
 
35
- export class FileSnapshotReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {
36
- // IVersion.treeId used to communicate between getVersions() & getSnapshotTree() calls to indicate IVersion is ours.
37
- protected static readonly FileStorageVersionTreeId = "FileStorageTreeId";
38
-
39
- protected docId?: string;
40
- protected docTree: ISnapshotTree;
41
- protected blobs: Map<string, ArrayBufferLike>;
42
- protected readonly commits: { [key: string]: ITree; } = {};
43
- protected readonly trees: { [key: string]: ISnapshotTree; } = {};
44
-
45
- public constructor(json: IFileSnapshot) {
46
- super();
47
- this.commits = json.commits;
48
-
49
- this.blobs = new Map<string, ArrayBufferLike>();
50
- this.docTree = buildSnapshotTree(json.tree.entries, this.blobs);
51
- }
52
-
53
- public async getVersions(
54
- versionId: string | null,
55
- count: number,
56
- ): Promise<IVersion[]> {
57
- if (this.docId === undefined || this.docId === versionId || versionId === null) {
58
- if (versionId !== null) {
59
- this.docId = versionId;
60
- }
61
- return [{ id: "latest", treeId: "" }];
62
- }
63
-
64
- if (this.commits[versionId] !== undefined) {
65
- return [{ id: versionId, treeId: FileSnapshotReader.FileStorageVersionTreeId }];
66
- }
67
- throw new Error(`Unknown version ID: ${versionId}`);
68
- }
69
-
70
- public async getSnapshotTree(versionRequested?: IVersion): Promise<ISnapshotTree | null> {
71
- if (!versionRequested || versionRequested.id === "latest") {
72
- return this.docTree;
73
- }
74
- if (versionRequested.treeId !== FileSnapshotReader.FileStorageVersionTreeId) {
75
- throw new Error(`Unknown version id: ${versionRequested}`);
76
- }
77
-
78
- let snapshotTree = this.trees[versionRequested.id];
79
- if (snapshotTree === undefined) {
80
- const tree = this.commits[versionRequested.id];
81
- if (tree === undefined) {
82
- throw new Error(`Can't find version ${versionRequested.id}`);
83
- }
84
-
85
- this.trees[versionRequested.id] = snapshotTree = buildSnapshotTree(tree.entries, this.blobs);
86
- }
87
- return snapshotTree;
88
- }
89
-
90
- public async readBlob(blobId: string): Promise<ArrayBufferLike> {
91
- const blob = this.blobs.get(blobId);
92
- if (blob !== undefined) {
93
- return blob;
94
- }
95
- throw new Error(`Unknown blob ID: ${blobId}`);
96
- }
36
+ /**
37
+ * @internal
38
+ */
39
+ export class FileSnapshotReader
40
+ extends ReadDocumentStorageServiceBase
41
+ implements IDocumentStorageService
42
+ {
43
+ // IVersion.treeId used to communicate between getVersions() & getSnapshotTree() calls to indicate IVersion is ours.
44
+ protected static readonly FileStorageVersionTreeId = "FileStorageTreeId";
45
+
46
+ protected docId?: string;
47
+ protected docTree: ISnapshotTree;
48
+ protected blobs: Map<string, ArrayBufferLike>;
49
+ protected readonly commits: { [key: string]: ITree } = {};
50
+ protected readonly trees: { [key: string]: ISnapshotTree } = {};
51
+
52
+ public constructor(json: IFileSnapshot) {
53
+ super();
54
+ this.commits = json.commits;
55
+
56
+ this.blobs = new Map<string, ArrayBufferLike>();
57
+ this.docTree = buildSnapshotTree(json.tree.entries, this.blobs);
58
+ }
59
+
60
+ public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
61
+ if (this.docId === undefined || this.docId === versionId || versionId === null) {
62
+ if (versionId !== null) {
63
+ this.docId = versionId;
64
+ }
65
+ return [{ id: "latest", treeId: "" }];
66
+ }
67
+
68
+ if (this.commits[versionId] !== undefined) {
69
+ return [{ id: versionId, treeId: FileSnapshotReader.FileStorageVersionTreeId }];
70
+ }
71
+ throw new Error(`Unknown version ID: ${versionId}`);
72
+ }
73
+
74
+ public async getSnapshotTree(versionRequested?: IVersion): Promise<ISnapshotTree | null> {
75
+ if (!versionRequested || versionRequested.id === "latest") {
76
+ return this.docTree;
77
+ }
78
+ if (versionRequested.treeId !== FileSnapshotReader.FileStorageVersionTreeId) {
79
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
80
+ throw new Error(`Unknown version id: ${versionRequested}`);
81
+ }
82
+
83
+ let snapshotTree = this.trees[versionRequested.id];
84
+ if (snapshotTree === undefined) {
85
+ const tree = this.commits[versionRequested.id];
86
+ if (tree === undefined) {
87
+ throw new Error(`Can't find version ${versionRequested.id}`);
88
+ }
89
+
90
+ this.trees[versionRequested.id] = snapshotTree = buildSnapshotTree(
91
+ tree.entries,
92
+ this.blobs,
93
+ );
94
+ }
95
+ return snapshotTree;
96
+ }
97
+
98
+ public async readBlob(blobId: string): Promise<ArrayBufferLike> {
99
+ const blob = this.blobs.get(blobId);
100
+ if (blob !== undefined) {
101
+ return blob;
102
+ }
103
+ throw new Error(`Unknown blob ID: ${blobId}`);
104
+ }
97
105
  }
98
106
 
107
+ /**
108
+ * @internal
109
+ */
99
110
  export class SnapshotStorage extends ReadDocumentStorageServiceBase {
100
- protected docId?: string;
101
-
102
- constructor(
103
- protected readonly storage: IDocumentStorageService,
104
- protected readonly docTree: ISnapshotTree | null) {
105
- super();
106
- assert(!!this.docTree, 0x0b0 /* "Missing document snapshot tree!" */);
107
- }
108
-
109
- public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
110
- if (this.docId === undefined || this.docId === versionId || versionId === null) {
111
- if (versionId !== null) {
112
- this.docId = versionId;
113
- }
114
- return [{ id: "latest", treeId: "" }];
115
- }
116
- return this.storage.getVersions(versionId, count);
117
- }
118
-
119
- public async getSnapshotTree(versionRequested?: IVersion): Promise<ISnapshotTree | null> {
120
- if (versionRequested && versionRequested.id !== "latest") {
121
- return this.storage.getSnapshotTree(versionRequested);
122
- }
123
-
124
- return this.docTree;
125
- }
126
-
127
- public async readBlob(blobId: string): Promise<ArrayBufferLike> {
128
- return this.storage.readBlob(blobId);
129
- }
111
+ protected docId?: string;
112
+
113
+ constructor(
114
+ protected readonly storage: IDocumentStorageService,
115
+ protected readonly docTree: ISnapshotTree | null,
116
+ ) {
117
+ super();
118
+ assert(!!this.docTree, 0x0b0 /* "Missing document snapshot tree!" */);
119
+ }
120
+
121
+ public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
122
+ if (this.docId === undefined || this.docId === versionId || versionId === null) {
123
+ if (versionId !== null) {
124
+ this.docId = versionId;
125
+ }
126
+ return [{ id: "latest", treeId: "" }];
127
+ }
128
+ return this.storage.getVersions(versionId, count);
129
+ }
130
+
131
+ public async getSnapshotTree(versionRequested?: IVersion): Promise<ISnapshotTree | null> {
132
+ if (versionRequested && versionRequested.id !== "latest") {
133
+ return this.storage.getSnapshotTree(versionRequested);
134
+ }
135
+
136
+ return this.docTree;
137
+ }
138
+
139
+ public async readBlob(blobId: string): Promise<ArrayBufferLike> {
140
+ return this.storage.readBlob(blobId);
141
+ }
130
142
  }
131
143
 
144
+ /**
145
+ * @internal
146
+ */
132
147
  export class OpStorage extends ReadDocumentStorageServiceBase {
133
- public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
134
- return [];
135
- }
148
+ public async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {
149
+ return [];
150
+ }
136
151
 
137
- public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
138
- throw new Error("no snapshot tree should be asked when playing ops");
139
- }
152
+ public async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {
153
+ throw new Error("no snapshot tree should be asked when playing ops");
154
+ }
140
155
 
141
- public async readBlob(blobId: string): Promise<ArrayBufferLike> {
142
- throw new Error(`Unknown blob ID: ${blobId}`);
143
- }
156
+ public async readBlob(blobId: string): Promise<ArrayBufferLike> {
157
+ throw new Error(`Unknown blob ID: ${blobId}`);
158
+ }
144
159
  }
145
160
 
146
161
  export class StaticStorageDocumentService implements IDocumentService {
147
- constructor(private readonly storage: IDocumentStorageService) { }
148
-
149
- public dispose() {}
162
+ constructor(
163
+ public readonly resolvedUrl: IResolvedUrl,
164
+ private readonly storage: IDocumentStorageService,
165
+ ) {}
150
166
 
151
- // TODO: Issue-2109 Implement detach container api or put appropriate comment.
152
- public get resolvedUrl(): IResolvedUrl {
153
- throw new Error("Not implemented");
154
- }
167
+ public dispose() {}
155
168
 
156
- public async connectToStorage(): Promise<IDocumentStorageService> {
157
- return this.storage;
158
- }
169
+ public async connectToStorage(): Promise<IDocumentStorageService> {
170
+ return this.storage;
171
+ }
159
172
 
160
- public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {
161
- return new EmptyDeltaStorageService();
162
- }
173
+ public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {
174
+ return new EmptyDeltaStorageService();
175
+ }
163
176
 
164
- public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {
165
- // We have no delta stream, so make it not return forever...
166
- return new Promise(() => { });
167
- }
177
+ public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {
178
+ // We have no delta stream, so make it not return forever...
179
+ return new Promise(() => {});
180
+ }
168
181
  }
169
182
 
183
+ /**
184
+ * @internal
185
+ */
170
186
  export class StaticStorageDocumentServiceFactory implements IDocumentServiceFactory {
171
- public readonly protocolName = "fluid-static-storage:";
172
- public constructor(protected readonly storage: IDocumentStorageService) { }
173
-
174
- public async createDocumentService(
175
- fileURL: IResolvedUrl,
176
- logger?: ITelemetryLogger,
177
- clientIsSummarizer?: boolean,
178
- ): Promise<IDocumentService> {
179
- return new StaticStorageDocumentService(this.storage);
180
- }
181
-
182
- // TODO: Issue-2109 Implement detach container api or put appropriate comment.
183
- public async createContainer(
184
- createNewSummary: ISummaryTree,
185
- resolvedUrl: IResolvedUrl,
186
- logger: ITelemetryLogger,
187
- clientIsSummarizer?: boolean,
188
- ): Promise<IDocumentService> {
189
- throw new Error("Not implemented");
190
- }
187
+ public constructor(protected readonly storage: IDocumentStorageService) {}
188
+
189
+ public async createDocumentService(
190
+ fileURL: IResolvedUrl,
191
+ logger?: ITelemetryLoggerExt,
192
+ clientIsSummarizer?: boolean,
193
+ ): Promise<IDocumentService> {
194
+ return new StaticStorageDocumentService(fileURL, this.storage);
195
+ }
196
+
197
+ // TODO: Issue-2109 Implement detach container api or put appropriate comment.
198
+ public async createContainer(
199
+ createNewSummary: ISummaryTree,
200
+ resolvedUrl: IResolvedUrl,
201
+ logger: ITelemetryLoggerExt,
202
+ clientIsSummarizer?: boolean,
203
+ ): Promise<IDocumentService> {
204
+ throw new Error("Not implemented");
205
+ }
191
206
  }
package/tsconfig.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "exclude": [
4
- "dist",
5
- "node_modules"
6
- ],
7
- "compilerOptions": {
8
- "rootDir": "./src",
9
- "outDir": "./dist"
10
- },
11
- "include": [
12
- "src/**/*"
13
- ]
14
- }
2
+ "extends": [
3
+ "../../../common/build/build-common/tsconfig.base.json",
4
+ "../../../common/build/build-common/tsconfig.cjs.json",
5
+ ],
6
+ "include": ["src/**/*"],
7
+ "exclude": ["dist", "node_modules"],
8
+ "compilerOptions": {
9
+ "rootDir": "./src",
10
+ "outDir": "./dist",
11
+ },
12
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"emptyDeltaStorageService.js","sourceRoot":"","sources":["../src/emptyDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+DAAkE;AAElE,MAAa,wBAAwB;IACjC;;;;;OAKG;IACI,aAAa,CAChB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QACpB,OAAO,iCAAkB,CAAC;IAC9B,CAAC;CACJ;AAdD,4DAcC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { emptyMessageStream } from \"@fluidframework/driver-utils\";\n\nexport class EmptyDeltaStorageService implements IDocumentDeltaStorageService {\n /**\n * Returns ops from the list of ops generated till now.\n * @param from - Ops are returned from + 1.\n * @param to - Op are returned from to - 1.\n * @returns Array of ops requested by the user.\n */\n public fetchMessages(\n from: number,\n to: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean): IStream<ISequencedDocumentMessage[]> {\n return emptyMessageStream;\n }\n}\n"]}
package/dist/index.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- /*!
3
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
- * Licensed under the MIT License.
5
- */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./replayController"), exports);
18
- __exportStar(require("./replayDocumentService"), exports);
19
- __exportStar(require("./replayDocumentServiceFactory"), exports);
20
- __exportStar(require("./storageImplementations"), exports);
21
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,qDAAmC;AACnC,0DAAwC;AACxC,iEAA+C;AAC/C,2DAAyC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./replayController\";\nexport * from \"./replayDocumentService\";\nexport * from \"./replayDocumentServiceFactory\";\nexport * from \"./storageImplementations\";\n"]}