@fluidframework/datastore 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.1

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 (65) 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 +11 -24
  13. package/dist/dataStoreRuntime.d.ts.map +1 -1
  14. package/dist/dataStoreRuntime.js +68 -86
  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.map +1 -1
  27. package/dist/remoteChannelContext.js +2 -2
  28. package/dist/remoteChannelContext.js.map +1 -1
  29. package/lib/channelContext.d.ts.map +1 -1
  30. package/lib/channelContext.js.map +1 -1
  31. package/lib/channelDeltaConnection.d.ts.map +1 -1
  32. package/lib/channelDeltaConnection.js.map +1 -1
  33. package/lib/channelStorageService.d.ts.map +1 -1
  34. package/lib/channelStorageService.js +1 -3
  35. package/lib/channelStorageService.js.map +1 -1
  36. package/lib/dataStoreRuntime.d.ts +11 -24
  37. package/lib/dataStoreRuntime.d.ts.map +1 -1
  38. package/lib/dataStoreRuntime.js +71 -89
  39. package/lib/dataStoreRuntime.js.map +1 -1
  40. package/lib/fluidHandle.d.ts.map +1 -1
  41. package/lib/fluidHandle.js.map +1 -1
  42. package/lib/localChannelContext.d.ts.map +1 -1
  43. package/lib/localChannelContext.js +9 -5
  44. package/lib/localChannelContext.js.map +1 -1
  45. package/lib/localChannelStorageService.d.ts.map +1 -1
  46. package/lib/localChannelStorageService.js.map +1 -1
  47. package/lib/packageVersion.d.ts +1 -1
  48. package/lib/packageVersion.js +1 -1
  49. package/lib/packageVersion.js.map +1 -1
  50. package/lib/remoteChannelContext.d.ts.map +1 -1
  51. package/lib/remoteChannelContext.js +2 -2
  52. package/lib/remoteChannelContext.js.map +1 -1
  53. package/package.json +111 -110
  54. package/prettier.config.cjs +1 -1
  55. package/src/channelContext.ts +66 -65
  56. package/src/channelDeltaConnection.ts +50 -44
  57. package/src/channelStorageService.ts +58 -54
  58. package/src/dataStoreRuntime.ts +1122 -1086
  59. package/src/fluidHandle.ts +87 -91
  60. package/src/localChannelContext.ts +302 -255
  61. package/src/localChannelStorageService.ts +47 -45
  62. package/src/packageVersion.ts +1 -1
  63. package/src/remoteChannelContext.ts +300 -291
  64. package/tsconfig.esnext.json +6 -6
  65. package/tsconfig.json +9 -13
@@ -10,56 +10,62 @@ import { DataProcessingError } from "@fluidframework/container-utils";
10
10
  import { IFluidHandle } from "@fluidframework/core-interfaces";
11
11
 
12
12
  export class ChannelDeltaConnection implements IDeltaConnection {
13
- private _handler: IDeltaHandler | undefined;
13
+ private _handler: IDeltaHandler | undefined;
14
14
 
15
- private get handler(): IDeltaHandler {
16
- assert(!!this._handler, 0x177 /* "Missing delta handler" */);
17
- return this._handler;
18
- }
19
- public get connected(): boolean {
20
- return this._connected;
21
- }
15
+ private get handler(): IDeltaHandler {
16
+ assert(!!this._handler, 0x177 /* "Missing delta handler" */);
17
+ return this._handler;
18
+ }
19
+ public get connected(): boolean {
20
+ return this._connected;
21
+ }
22
22
 
23
- constructor(
24
- public objectId: string,
25
- private _connected: boolean,
26
- public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,
27
- public readonly dirty: () => void,
28
- public readonly addedGCOutboundReference: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void) {
29
- }
23
+ constructor(
24
+ public objectId: string,
25
+ private _connected: boolean,
26
+ public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,
27
+ public readonly dirty: () => void,
28
+ public readonly addedGCOutboundReference: (
29
+ srcHandle: IFluidHandle,
30
+ outboundHandle: IFluidHandle,
31
+ ) => void,
32
+ ) {}
30
33
 
31
- public attach(handler: IDeltaHandler) {
32
- assert(this._handler === undefined, 0x178 /* "Missing delta handler on attach" */);
33
- this._handler = handler;
34
- }
34
+ public attach(handler: IDeltaHandler) {
35
+ assert(this._handler === undefined, 0x178 /* "Missing delta handler on attach" */);
36
+ this._handler = handler;
37
+ }
35
38
 
36
- public setConnectionState(connected: boolean) {
37
- this._connected = connected;
38
- this.handler.setConnectionState(connected);
39
- }
39
+ public setConnectionState(connected: boolean) {
40
+ this._connected = connected;
41
+ this.handler.setConnectionState(connected);
42
+ }
40
43
 
41
- public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {
42
- try {
43
- // catches as data processing error whether or not they come from async pending queues
44
- this.handler.process(message, local, localOpMetadata);
45
- } catch (error) {
46
- throw DataProcessingError.wrapIfUnrecognized(
47
- error, "channelDeltaConnectionFailedToProcessMessage", message);
48
- }
49
- }
44
+ public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {
45
+ try {
46
+ // catches as data processing error whether or not they come from async pending queues
47
+ this.handler.process(message, local, localOpMetadata);
48
+ } catch (error) {
49
+ throw DataProcessingError.wrapIfUnrecognized(
50
+ error,
51
+ "channelDeltaConnectionFailedToProcessMessage",
52
+ message,
53
+ );
54
+ }
55
+ }
50
56
 
51
- public reSubmit(content: any, localOpMetadata: unknown) {
52
- this.handler.reSubmit(content, localOpMetadata);
53
- }
57
+ public reSubmit(content: any, localOpMetadata: unknown) {
58
+ this.handler.reSubmit(content, localOpMetadata);
59
+ }
54
60
 
55
- public rollback(content: any, localOpMetadata: unknown) {
56
- if (this.handler.rollback === undefined) {
57
- throw new Error("Handler doesn't support rollback");
58
- }
59
- this.handler.rollback(content, localOpMetadata);
60
- }
61
+ public rollback(content: any, localOpMetadata: unknown) {
62
+ if (this.handler.rollback === undefined) {
63
+ throw new Error("Handler doesn't support rollback");
64
+ }
65
+ this.handler.rollback(content, localOpMetadata);
66
+ }
61
67
 
62
- public applyStashedOp(message: ISequencedDocumentMessage): unknown {
63
- return this.handler.applyStashedOp(message);
64
- }
68
+ public applyStashedOp(message: ISequencedDocumentMessage): unknown {
69
+ return this.handler.applyStashedOp(message);
70
+ }
65
71
  }
@@ -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
  }