@fluidframework/datastore 1.4.0-121020 → 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 (145) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +273 -0
  4. package/README.md +41 -0
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/datastore.api.md +168 -0
  8. package/dist/channelContext.cjs +86 -0
  9. package/dist/channelContext.cjs.map +1 -0
  10. package/dist/channelContext.d.ts +15 -9
  11. package/dist/channelContext.d.ts.map +1 -1
  12. package/dist/{channelDeltaConnection.js → channelDeltaConnection.cjs} +14 -15
  13. package/dist/channelDeltaConnection.cjs.map +1 -0
  14. package/dist/channelDeltaConnection.d.ts +4 -5
  15. package/dist/channelDeltaConnection.d.ts.map +1 -1
  16. package/dist/{channelStorageService.js → channelStorageService.cjs} +13 -16
  17. package/dist/channelStorageService.cjs.map +1 -0
  18. package/dist/channelStorageService.d.ts +2 -2
  19. package/dist/channelStorageService.d.ts.map +1 -1
  20. package/dist/{dataStoreRuntime.js → dataStoreRuntime.cjs} +302 -225
  21. package/dist/dataStoreRuntime.cjs.map +1 -0
  22. package/dist/dataStoreRuntime.d.ts +81 -37
  23. package/dist/dataStoreRuntime.d.ts.map +1 -1
  24. package/dist/datastore-alpha.d.ts +317 -0
  25. package/dist/datastore-beta.d.ts +47 -0
  26. package/dist/datastore-public.d.ts +47 -0
  27. package/dist/datastore-untrimmed.d.ts +324 -0
  28. package/dist/{fluidHandle.js → fluidHandle.cjs} +44 -16
  29. package/dist/fluidHandle.cjs.map +1 -0
  30. package/dist/fluidHandle.d.ts +33 -6
  31. package/dist/fluidHandle.d.ts.map +1 -1
  32. package/dist/index.cjs +15 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/localChannelContext.cjs +190 -0
  37. package/dist/localChannelContext.cjs.map +1 -0
  38. package/dist/localChannelContext.d.ts +12 -21
  39. package/dist/localChannelContext.d.ts.map +1 -1
  40. package/dist/{localChannelStorageService.js → localChannelStorageService.cjs} +3 -3
  41. package/dist/localChannelStorageService.cjs.map +1 -0
  42. package/dist/localChannelStorageService.d.ts.map +1 -1
  43. package/dist/remoteChannelContext.cjs +124 -0
  44. package/dist/remoteChannelContext.cjs.map +1 -0
  45. package/dist/remoteChannelContext.d.ts +5 -10
  46. package/dist/remoteChannelContext.d.ts.map +1 -1
  47. package/dist/tsdoc-metadata.json +11 -0
  48. package/lib/{channelContext.d.ts → channelContext.d.mts} +16 -10
  49. package/lib/channelContext.d.mts.map +1 -0
  50. package/lib/channelContext.mjs +78 -0
  51. package/lib/channelContext.mjs.map +1 -0
  52. package/lib/{channelDeltaConnection.d.ts → channelDeltaConnection.d.mts} +4 -5
  53. package/lib/channelDeltaConnection.d.mts.map +1 -0
  54. package/lib/{channelDeltaConnection.js → channelDeltaConnection.mjs} +11 -12
  55. package/lib/channelDeltaConnection.mjs.map +1 -0
  56. package/lib/{channelStorageService.d.ts → channelStorageService.d.mts} +2 -2
  57. package/lib/channelStorageService.d.mts.map +1 -0
  58. package/lib/{channelStorageService.js → channelStorageService.mjs} +13 -16
  59. package/lib/channelStorageService.mjs.map +1 -0
  60. package/lib/{dataStoreRuntime.d.ts → dataStoreRuntime.d.mts} +81 -37
  61. package/lib/dataStoreRuntime.d.mts.map +1 -0
  62. package/lib/{dataStoreRuntime.js → dataStoreRuntime.mjs} +286 -209
  63. package/lib/dataStoreRuntime.mjs.map +1 -0
  64. package/lib/datastore-alpha.d.mts +317 -0
  65. package/lib/datastore-beta.d.mts +47 -0
  66. package/lib/datastore-public.d.mts +47 -0
  67. package/lib/datastore-untrimmed.d.mts +324 -0
  68. package/lib/fluidHandle.d.mts +57 -0
  69. package/lib/fluidHandle.d.mts.map +1 -0
  70. package/lib/{fluidHandle.js → fluidHandle.mjs} +44 -16
  71. package/lib/fluidHandle.mjs.map +1 -0
  72. package/lib/index.d.mts +7 -0
  73. package/lib/index.d.mts.map +1 -0
  74. package/lib/index.mjs +7 -0
  75. package/lib/index.mjs.map +1 -0
  76. package/lib/{localChannelContext.d.ts → localChannelContext.d.mts} +13 -22
  77. package/lib/localChannelContext.d.mts.map +1 -0
  78. package/lib/{localChannelContext.js → localChannelContext.mjs} +73 -85
  79. package/lib/localChannelContext.mjs.map +1 -0
  80. package/lib/localChannelStorageService.d.mts.map +1 -0
  81. package/lib/{localChannelStorageService.js → localChannelStorageService.mjs} +2 -2
  82. package/lib/localChannelStorageService.mjs.map +1 -0
  83. package/lib/{remoteChannelContext.d.ts → remoteChannelContext.d.mts} +7 -12
  84. package/lib/remoteChannelContext.d.mts.map +1 -0
  85. package/lib/remoteChannelContext.mjs +120 -0
  86. package/lib/remoteChannelContext.mjs.map +1 -0
  87. package/package.json +107 -72
  88. package/{lib/index.js → prettier.config.cjs} +4 -3
  89. package/src/channelContext.ts +168 -71
  90. package/src/channelDeltaConnection.ts +52 -47
  91. package/src/channelStorageService.ts +59 -55
  92. package/src/dataStoreRuntime.ts +1158 -983
  93. package/src/fluidHandle.ts +92 -64
  94. package/src/index.ts +8 -2
  95. package/src/localChannelContext.ts +278 -272
  96. package/src/localChannelStorageService.ts +48 -46
  97. package/src/remoteChannelContext.ts +237 -300
  98. package/tsc-multi.test.json +4 -0
  99. package/tsconfig.json +11 -13
  100. package/dist/channelContext.js +0 -35
  101. package/dist/channelContext.js.map +0 -1
  102. package/dist/channelDeltaConnection.js.map +0 -1
  103. package/dist/channelStorageService.js.map +0 -1
  104. package/dist/dataStoreRuntime.js.map +0 -1
  105. package/dist/fluidHandle.js.map +0 -1
  106. package/dist/index.js +0 -19
  107. package/dist/index.js.map +0 -1
  108. package/dist/localChannelContext.js +0 -202
  109. package/dist/localChannelContext.js.map +0 -1
  110. package/dist/localChannelStorageService.js.map +0 -1
  111. package/dist/packageVersion.d.ts +0 -9
  112. package/dist/packageVersion.d.ts.map +0 -1
  113. package/dist/packageVersion.js +0 -12
  114. package/dist/packageVersion.js.map +0 -1
  115. package/dist/remoteChannelContext.js +0 -207
  116. package/dist/remoteChannelContext.js.map +0 -1
  117. package/lib/channelContext.d.ts.map +0 -1
  118. package/lib/channelContext.js +0 -29
  119. package/lib/channelContext.js.map +0 -1
  120. package/lib/channelDeltaConnection.d.ts.map +0 -1
  121. package/lib/channelDeltaConnection.js.map +0 -1
  122. package/lib/channelStorageService.d.ts.map +0 -1
  123. package/lib/channelStorageService.js.map +0 -1
  124. package/lib/dataStoreRuntime.d.ts.map +0 -1
  125. package/lib/dataStoreRuntime.js.map +0 -1
  126. package/lib/fluidHandle.d.ts +0 -30
  127. package/lib/fluidHandle.d.ts.map +0 -1
  128. package/lib/fluidHandle.js.map +0 -1
  129. package/lib/index.d.ts +0 -7
  130. package/lib/index.d.ts.map +0 -1
  131. package/lib/index.js.map +0 -1
  132. package/lib/localChannelContext.d.ts.map +0 -1
  133. package/lib/localChannelContext.js.map +0 -1
  134. package/lib/localChannelStorageService.d.ts.map +0 -1
  135. package/lib/localChannelStorageService.js.map +0 -1
  136. package/lib/packageVersion.d.ts +0 -9
  137. package/lib/packageVersion.d.ts.map +0 -1
  138. package/lib/packageVersion.js +0 -9
  139. package/lib/packageVersion.js.map +0 -1
  140. package/lib/remoteChannelContext.d.ts.map +0 -1
  141. package/lib/remoteChannelContext.js +0 -203
  142. package/lib/remoteChannelContext.js.map +0 -1
  143. package/src/packageVersion.ts +0 -9
  144. package/tsconfig.esnext.json +0 -7
  145. /package/lib/{localChannelStorageService.d.ts → localChannelStorageService.d.mts} +0 -0
@@ -7,71 +7,75 @@ import { IDocumentStorageService } from "@fluidframework/driver-definitions";
7
7
  import { ISnapshotTree } from "@fluidframework/protocol-definitions";
8
8
  import { IChannelStorageService } from "@fluidframework/datastore-definitions";
9
9
  import { getNormalizedObjectStoragePathParts } from "@fluidframework/runtime-utils";
10
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
10
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
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: ITelemetryLoggerExt,
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
  }