@fluidframework/datastore 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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 (67) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +2 -2
  3. package/README.md +3 -0
  4. package/api-extractor.json +2 -2
  5. package/dist/channelContext.d.ts.map +1 -1
  6. package/dist/channelContext.js.map +1 -1
  7. package/dist/channelDeltaConnection.d.ts.map +1 -1
  8. package/dist/channelDeltaConnection.js.map +1 -1
  9. package/dist/channelStorageService.d.ts.map +1 -1
  10. package/dist/channelStorageService.js +1 -3
  11. package/dist/channelStorageService.js.map +1 -1
  12. package/dist/dataStoreRuntime.d.ts +10 -18
  13. package/dist/dataStoreRuntime.d.ts.map +1 -1
  14. package/dist/dataStoreRuntime.js +65 -83
  15. package/dist/dataStoreRuntime.js.map +1 -1
  16. package/dist/fluidHandle.d.ts.map +1 -1
  17. package/dist/fluidHandle.js.map +1 -1
  18. package/dist/localChannelContext.d.ts.map +1 -1
  19. package/dist/localChannelContext.js +9 -5
  20. package/dist/localChannelContext.js.map +1 -1
  21. package/dist/localChannelStorageService.d.ts.map +1 -1
  22. package/dist/localChannelStorageService.js.map +1 -1
  23. package/dist/packageVersion.d.ts +1 -1
  24. package/dist/packageVersion.js +1 -1
  25. package/dist/packageVersion.js.map +1 -1
  26. package/dist/remoteChannelContext.d.ts +2 -2
  27. package/dist/remoteChannelContext.d.ts.map +1 -1
  28. package/dist/remoteChannelContext.js +4 -4
  29. package/dist/remoteChannelContext.js.map +1 -1
  30. package/lib/channelContext.d.ts.map +1 -1
  31. package/lib/channelContext.js.map +1 -1
  32. package/lib/channelDeltaConnection.d.ts.map +1 -1
  33. package/lib/channelDeltaConnection.js.map +1 -1
  34. package/lib/channelStorageService.d.ts.map +1 -1
  35. package/lib/channelStorageService.js +1 -3
  36. package/lib/channelStorageService.js.map +1 -1
  37. package/lib/dataStoreRuntime.d.ts +10 -18
  38. package/lib/dataStoreRuntime.d.ts.map +1 -1
  39. package/lib/dataStoreRuntime.js +68 -86
  40. package/lib/dataStoreRuntime.js.map +1 -1
  41. package/lib/fluidHandle.d.ts.map +1 -1
  42. package/lib/fluidHandle.js.map +1 -1
  43. package/lib/localChannelContext.d.ts.map +1 -1
  44. package/lib/localChannelContext.js +9 -5
  45. package/lib/localChannelContext.js.map +1 -1
  46. package/lib/localChannelStorageService.d.ts.map +1 -1
  47. package/lib/localChannelStorageService.js.map +1 -1
  48. package/lib/packageVersion.d.ts +1 -1
  49. package/lib/packageVersion.js +1 -1
  50. package/lib/packageVersion.js.map +1 -1
  51. package/lib/remoteChannelContext.d.ts +2 -2
  52. package/lib/remoteChannelContext.d.ts.map +1 -1
  53. package/lib/remoteChannelContext.js +4 -4
  54. package/lib/remoteChannelContext.js.map +1 -1
  55. package/package.json +50 -49
  56. package/prettier.config.cjs +1 -1
  57. package/src/channelContext.ts +66 -65
  58. package/src/channelDeltaConnection.ts +50 -44
  59. package/src/channelStorageService.ts +58 -54
  60. package/src/dataStoreRuntime.ts +1131 -1087
  61. package/src/fluidHandle.ts +87 -91
  62. package/src/localChannelContext.ts +302 -255
  63. package/src/localChannelStorageService.ts +47 -45
  64. package/src/packageVersion.ts +1 -1
  65. package/src/remoteChannelContext.ts +297 -291
  66. package/tsconfig.esnext.json +6 -6
  67. package/tsconfig.json +9 -13
@@ -10,68 +10,72 @@ import { getNormalizedObjectStoragePathParts } from "@fluidframework/runtime-uti
10
10
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
11
11
 
12
12
  export class ChannelStorageService implements IChannelStorageService {
13
- private static flattenTree(base: string, tree: ISnapshotTree, results: { [path: string]: string; }) {
14
- // eslint-disable-next-line guard-for-in, no-restricted-syntax
15
- for (const path in tree.trees) {
16
- ChannelStorageService.flattenTree(`${base}${path}/`, tree.trees[path], results);
17
- }
13
+ private static flattenTree(
14
+ base: string,
15
+ tree: ISnapshotTree,
16
+ results: { [path: string]: string },
17
+ ) {
18
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
19
+ for (const path in tree.trees) {
20
+ ChannelStorageService.flattenTree(`${base}${path}/`, tree.trees[path], results);
21
+ }
18
22
 
19
- // eslint-disable-next-line guard-for-in, no-restricted-syntax
20
- for (const blob in tree.blobs) {
21
- results[`${base}${blob}`] = tree.blobs[blob];
22
- }
23
- }
23
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
24
+ for (const blob in tree.blobs) {
25
+ results[`${base}${blob}`] = tree.blobs[blob];
26
+ }
27
+ }
24
28
 
25
- private readonly flattenedTree: { [path: string]: string; };
29
+ private readonly flattenedTree: { [path: string]: string };
26
30
 
27
- constructor(
28
- private readonly tree: ISnapshotTree | undefined,
29
- private readonly storage: Pick<IDocumentStorageService, "readBlob">,
30
- private readonly logger: ITelemetryLogger,
31
- private readonly extraBlobs?: Map<string, ArrayBufferLike>,
32
- ) {
33
- this.flattenedTree = {};
34
- // Create a map from paths to blobs
35
- if (tree !== undefined) {
36
- ChannelStorageService.flattenTree("", tree, this.flattenedTree);
37
- }
38
- }
31
+ constructor(
32
+ private readonly tree: ISnapshotTree | undefined,
33
+ private readonly storage: Pick<IDocumentStorageService, "readBlob">,
34
+ private readonly logger: ITelemetryLogger,
35
+ private readonly extraBlobs?: Map<string, ArrayBufferLike>,
36
+ ) {
37
+ this.flattenedTree = {};
38
+ // Create a map from paths to blobs
39
+ if (tree !== undefined) {
40
+ ChannelStorageService.flattenTree("", tree, this.flattenedTree);
41
+ }
42
+ }
39
43
 
40
- public async contains(path: string): Promise<boolean> {
41
- return this.flattenedTree[path] !== undefined;
42
- }
44
+ public async contains(path: string): Promise<boolean> {
45
+ return this.flattenedTree[path] !== undefined;
46
+ }
43
47
 
44
- public async readBlob(path: string): Promise<ArrayBufferLike> {
45
- const id = await this.getIdForPath(path);
46
- const blob = this.extraBlobs !== undefined
47
- ? this.extraBlobs.get(id)
48
- : undefined;
48
+ public async readBlob(path: string): Promise<ArrayBufferLike> {
49
+ const id = await this.getIdForPath(path);
50
+ const blob = this.extraBlobs !== undefined ? this.extraBlobs.get(id) : undefined;
49
51
 
50
- if (blob !== undefined) {
51
- return blob;
52
- }
53
- const blobP = this.storage.readBlob(id);
54
- blobP.catch((error) => this.logger.sendErrorEvent({ eventName: "ChannelStorageBlobError" }, error));
52
+ if (blob !== undefined) {
53
+ return blob;
54
+ }
55
+ const blobP = this.storage.readBlob(id);
56
+ blobP.catch((error) =>
57
+ this.logger.sendErrorEvent({ eventName: "ChannelStorageBlobError" }, error),
58
+ );
55
59
 
56
- return blobP;
57
- }
60
+ return blobP;
61
+ }
58
62
 
59
- public async list(path: string): Promise<string[]> {
60
- let tree = this.tree;
61
- const pathParts = getNormalizedObjectStoragePathParts(path);
62
- while (tree !== undefined && pathParts.length > 0) {
63
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
- const part = pathParts.shift()!;
65
- tree = tree.trees[part];
66
- }
67
- if (tree === undefined || pathParts.length !== 0) {
68
- throw new Error("path does not exist");
69
- }
63
+ public async list(path: string): Promise<string[]> {
64
+ let tree = this.tree;
65
+ const pathParts = getNormalizedObjectStoragePathParts(path);
66
+ while (tree !== undefined && pathParts.length > 0) {
67
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
68
+ const part = pathParts.shift()!;
69
+ tree = tree.trees[part];
70
+ }
71
+ if (tree === undefined || pathParts.length !== 0) {
72
+ throw new Error("path does not exist");
73
+ }
70
74
 
71
- return Object.keys(tree?.blobs ?? {});
72
- }
75
+ return Object.keys(tree?.blobs ?? {});
76
+ }
73
77
 
74
- private async getIdForPath(path: string): Promise<string> {
75
- return this.flattenedTree[path];
76
- }
78
+ private async getIdForPath(path: string): Promise<string> {
79
+ return this.flattenedTree[path];
80
+ }
77
81
  }