@fluidframework/datastore 2.0.0-dev-rc.3.0.0.250606 → 2.0.0-dev-rc.3.0.0.254274

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 (92) hide show
  1. package/api-report/datastore.api.md +4 -4
  2. package/dist/channelContext.d.ts +3 -2
  3. package/dist/channelContext.d.ts.map +1 -1
  4. package/dist/channelContext.js +9 -9
  5. package/dist/channelContext.js.map +1 -1
  6. package/dist/channelDeltaConnection.js +5 -5
  7. package/dist/channelDeltaConnection.js.map +1 -1
  8. package/dist/channelStorageService.d.ts +1 -1
  9. package/dist/channelStorageService.d.ts.map +1 -1
  10. package/dist/channelStorageService.js +2 -2
  11. package/dist/channelStorageService.js.map +1 -1
  12. package/dist/dataStoreRuntime.d.ts +4 -3
  13. package/dist/dataStoreRuntime.d.ts.map +1 -1
  14. package/dist/dataStoreRuntime.js +74 -73
  15. package/dist/dataStoreRuntime.js.map +1 -1
  16. package/dist/datastore-alpha.d.ts +5 -5
  17. package/dist/datastore-beta.d.ts +3 -3
  18. package/dist/datastore-public.d.ts +3 -3
  19. package/dist/datastore-untrimmed.d.ts +5 -5
  20. package/dist/fluidHandle.js +2 -2
  21. package/dist/fluidHandle.js.map +1 -1
  22. package/dist/localChannelContext.d.ts +4 -3
  23. package/dist/localChannelContext.d.ts.map +1 -1
  24. package/dist/localChannelContext.js +33 -23
  25. package/dist/localChannelContext.js.map +1 -1
  26. package/dist/localChannelStorageService.js +2 -2
  27. package/dist/localChannelStorageService.js.map +1 -1
  28. package/dist/packageVersion.d.ts +9 -0
  29. package/dist/packageVersion.d.ts.map +1 -0
  30. package/dist/packageVersion.js +12 -0
  31. package/dist/packageVersion.js.map +1 -0
  32. package/dist/remoteChannelContext.d.ts +3 -2
  33. package/dist/remoteChannelContext.d.ts.map +1 -1
  34. package/dist/remoteChannelContext.js +12 -12
  35. package/dist/remoteChannelContext.js.map +1 -1
  36. package/lib/channelContext.d.ts +3 -2
  37. package/lib/channelContext.d.ts.map +1 -1
  38. package/lib/channelContext.js +3 -3
  39. package/lib/channelContext.js.map +1 -1
  40. package/lib/channelDeltaConnection.js +2 -2
  41. package/lib/channelDeltaConnection.js.map +1 -1
  42. package/lib/channelStorageService.d.ts +1 -1
  43. package/lib/channelStorageService.d.ts.map +1 -1
  44. package/lib/channelStorageService.js +1 -1
  45. package/lib/channelStorageService.js.map +1 -1
  46. package/lib/dataStoreRuntime.d.ts +4 -3
  47. package/lib/dataStoreRuntime.d.ts.map +1 -1
  48. package/lib/dataStoreRuntime.js +8 -7
  49. package/lib/dataStoreRuntime.js.map +1 -1
  50. package/lib/datastore-alpha.d.ts +5 -5
  51. package/lib/datastore-beta.d.ts +3 -3
  52. package/lib/datastore-public.d.ts +3 -3
  53. package/lib/datastore-untrimmed.d.ts +5 -5
  54. package/lib/fluidHandle.js +1 -1
  55. package/lib/fluidHandle.js.map +1 -1
  56. package/lib/localChannelContext.d.ts +4 -3
  57. package/lib/localChannelContext.d.ts.map +1 -1
  58. package/lib/localChannelContext.js +19 -6
  59. package/lib/localChannelContext.js.map +1 -1
  60. package/lib/localChannelStorageService.js +1 -1
  61. package/lib/localChannelStorageService.js.map +1 -1
  62. package/lib/packageVersion.d.ts +9 -0
  63. package/lib/packageVersion.d.ts.map +1 -0
  64. package/lib/packageVersion.js +9 -0
  65. package/lib/packageVersion.js.map +1 -0
  66. package/lib/remoteChannelContext.d.ts +3 -2
  67. package/lib/remoteChannelContext.d.ts.map +1 -1
  68. package/lib/remoteChannelContext.js +2 -2
  69. package/lib/remoteChannelContext.js.map +1 -1
  70. package/lib/tsdoc-metadata.json +11 -0
  71. package/package.json +17 -29
  72. package/src/channelContext.ts +9 -9
  73. package/src/channelDeltaConnection.ts +2 -2
  74. package/src/channelStorageService.ts +2 -2
  75. package/src/dataStoreRuntime.ts +22 -13
  76. package/src/fluidHandle.ts +1 -1
  77. package/src/localChannelContext.ts +26 -12
  78. package/src/localChannelStorageService.ts +1 -1
  79. package/src/packageVersion.ts +9 -0
  80. package/src/remoteChannelContext.ts +11 -11
  81. package/lib/test/channelStorageService.spec.js +0 -70
  82. package/lib/test/channelStorageService.spec.js.map +0 -1
  83. package/lib/test/dataStoreRuntime.spec.js +0 -121
  84. package/lib/test/dataStoreRuntime.spec.js.map +0 -1
  85. package/lib/test/localChannelContext.spec.js +0 -41
  86. package/lib/test/localChannelContext.spec.js.map +0 -1
  87. package/lib/test/localChannelStorageService.spec.js +0 -72
  88. package/lib/test/localChannelStorageService.spec.js.map +0 -1
  89. package/lib/test/remoteChannelContext.spec.js +0 -33
  90. package/lib/test/remoteChannelContext.spec.js.map +0 -1
  91. package/lib/test/types/validateDatastorePrevious.generated.js +0 -16
  92. package/lib/test/types/validateDatastorePrevious.generated.js.map +0 -1
@@ -10,23 +10,23 @@ import {
10
10
  IChannelFactory,
11
11
  IFluidDataStoreRuntime,
12
12
  } from "@fluidframework/datastore-definitions";
13
- import { IDocumentStorageService } from "@fluidframework/driver-definitions";
14
- import { readAndParse } from "@fluidframework/driver-utils";
13
+ import { IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
14
+ import { readAndParse } from "@fluidframework/driver-utils/internal";
15
15
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
16
16
  import {
17
17
  IExperimentalIncrementalSummaryContext,
18
- IFluidDataStoreContext,
19
18
  IGarbageCollectionData,
20
- ISummarizeResult,
21
19
  ISummaryTreeWithStats,
22
20
  ITelemetryContext,
23
21
  } from "@fluidframework/runtime-definitions";
24
- import { addBlobToSummary } from "@fluidframework/runtime-utils";
25
22
  import {
26
- DataCorruptionError,
27
- ITelemetryLoggerExt,
28
- tagCodeArtifacts,
29
- } from "@fluidframework/telemetry-utils";
23
+ IFluidDataStoreContext,
24
+ ISummarizeResult,
25
+ } from "@fluidframework/runtime-definitions/internal";
26
+ import { addBlobToSummary } from "@fluidframework/runtime-utils/internal";
27
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
28
+ import { DataCorruptionError, tagCodeArtifacts } from "@fluidframework/telemetry-utils/internal";
29
+
30
30
  import { ChannelDeltaConnection } from "./channelDeltaConnection.js";
31
31
  import { ChannelStorageService } from "./channelStorageService.js";
32
32
  import { ISharedObjectRegistry } from "./dataStoreRuntime.js";
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import { IFluidHandle } from "@fluidframework/core-interfaces";
7
- import { assert } from "@fluidframework/core-utils";
7
+ import { assert } from "@fluidframework/core-utils/internal";
8
8
  import { IDeltaConnection, IDeltaHandler } from "@fluidframework/datastore-definitions";
9
9
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
10
- import { DataProcessingError } from "@fluidframework/telemetry-utils";
10
+ import { DataProcessingError } from "@fluidframework/telemetry-utils/internal";
11
11
 
12
12
  const stashedOpMetadataMark = Symbol();
13
13
 
@@ -4,9 +4,9 @@
4
4
  */
5
5
 
6
6
  import { IChannelStorageService } from "@fluidframework/datastore-definitions";
7
- import { IDocumentStorageService } from "@fluidframework/driver-definitions";
7
+ import { IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
8
8
  import { ISnapshotTree } from "@fluidframework/protocol-definitions";
9
- import { getNormalizedObjectStoragePathParts } from "@fluidframework/runtime-utils";
9
+ import { getNormalizedObjectStoragePathParts } from "@fluidframework/runtime-utils/internal";
10
10
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
11
11
 
12
12
  export class ChannelStorageService implements IChannelStorageService {
@@ -12,14 +12,19 @@ import {
12
12
  IRequest,
13
13
  IResponse,
14
14
  } from "@fluidframework/core-interfaces";
15
- import { assert, Deferred, LazyPromise, unreachableCase } from "@fluidframework/core-utils";
15
+ import {
16
+ assert,
17
+ Deferred,
18
+ LazyPromise,
19
+ unreachableCase,
20
+ } from "@fluidframework/core-utils/internal";
16
21
  import {
17
22
  IChannel,
18
23
  IChannelFactory,
19
24
  IFluidDataStoreRuntime,
20
25
  IFluidDataStoreRuntimeEvents,
21
26
  } from "@fluidframework/datastore-definitions";
22
- import { buildSnapshotTree } from "@fluidframework/driver-utils";
27
+ import { buildSnapshotTree } from "@fluidframework/driver-utils/internal";
23
28
  import { IIdCompressor } from "@fluidframework/id-compressor";
24
29
  import {
25
30
  IClientDetails,
@@ -31,6 +36,12 @@ import {
31
36
  ISummaryTree,
32
37
  SummaryType,
33
38
  } from "@fluidframework/protocol-definitions";
39
+ import {
40
+ IGarbageCollectionData,
41
+ IInboundSignalMessage,
42
+ ISummaryTreeWithStats,
43
+ ITelemetryContext,
44
+ } from "@fluidframework/runtime-definitions";
34
45
  import {
35
46
  CreateChildSummarizerNodeParam,
36
47
  CreateSummarizerNodeSource,
@@ -38,13 +49,9 @@ import {
38
49
  IEnvelope,
39
50
  IFluidDataStoreChannel,
40
51
  IFluidDataStoreContext,
41
- IGarbageCollectionData,
42
- IInboundSignalMessage,
43
- ISummaryTreeWithStats,
44
- ITelemetryContext,
45
52
  VisibilityState,
46
53
  gcDataBlobKey,
47
- } from "@fluidframework/runtime-definitions";
54
+ } from "@fluidframework/runtime-definitions/internal";
48
55
  import {
49
56
  GCDataBuilder,
50
57
  RequestParser,
@@ -59,10 +66,10 @@ import {
59
66
  generateHandleContextPath,
60
67
  processAttachMessageGCData,
61
68
  unpackChildNodesUsedRoutes,
62
- } from "@fluidframework/runtime-utils";
69
+ } from "@fluidframework/runtime-utils/internal";
70
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
63
71
  import {
64
72
  DataProcessingError,
65
- ITelemetryLoggerExt,
66
73
  LoggingError,
67
74
  MonitoringContext,
68
75
  UsageError,
@@ -70,8 +77,9 @@ import {
70
77
  generateStack,
71
78
  raiseConnectedEvent,
72
79
  tagCodeArtifacts,
73
- } from "@fluidframework/telemetry-utils";
80
+ } from "@fluidframework/telemetry-utils/internal";
74
81
  import { v4 as uuid } from "uuid";
82
+
75
83
  import { IChannelContext, summarizeChannel } from "./channelContext.js";
76
84
  import { FluidObjectHandle } from "./fluidHandle.js";
77
85
  import {
@@ -79,6 +87,7 @@ import {
79
87
  LocalChannelContextBase,
80
88
  RehydratedLocalChannelContext,
81
89
  } from "./localChannelContext.js";
90
+ import { pkgVersion } from "./packageVersion.js";
82
91
  import { RemoteChannelContext } from "./remoteChannelContext.js";
83
92
 
84
93
  /**
@@ -236,7 +245,7 @@ export class FluidDataStoreRuntime
236
245
  logger: dataStoreContext.logger,
237
246
  namespace: "FluidDataStoreRuntime",
238
247
  properties: {
239
- all: { dataStoreId: uuid() },
248
+ all: { dataStoreId: uuid(), dataStoreVersion: pkgVersion },
240
249
  },
241
250
  });
242
251
 
@@ -961,10 +970,10 @@ export class FluidDataStoreRuntime
961
970
  /**
962
971
  * Submits the signal to be sent to other clients.
963
972
  * @param type - Type of the signal.
964
- * @param content - Content of the signal.
973
+ * @param content - Content of the signal. Should be a JSON serializable object or primitive.
965
974
  * @param targetClientId - When specified, the signal is only sent to the provided client id.
966
975
  */
967
- public submitSignal(type: string, content: any, targetClientId?: string) {
976
+ public submitSignal(type: string, content: unknown, targetClientId?: string) {
968
977
  this.verifyNotClosed();
969
978
  return this.dataStoreContext.submitSignal(type, content, targetClientId);
970
979
  }
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { FluidObject, IFluidHandle, IFluidHandleContext } from "@fluidframework/core-interfaces";
7
- import { generateHandleContextPath } from "@fluidframework/runtime-utils";
7
+ import { generateHandleContextPath } from "@fluidframework/runtime-utils/internal";
8
8
 
9
9
  /**
10
10
  * Handle for a shared {@link @fluidframework/core-interfaces#FluidObject}.
@@ -3,23 +3,20 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import lodashPkg from "lodash";
7
- // eslint-disable-next-line @typescript-eslint/unbound-method
8
- const { cloneDeep } = lodashPkg;
9
-
10
- import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
6
+ import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions/internal";
11
7
  import { IFluidHandle } from "@fluidframework/core-interfaces";
12
- import { assert, Lazy, LazyPromise } from "@fluidframework/core-utils";
8
+ import { assert, Lazy, LazyPromise } from "@fluidframework/core-utils/internal";
13
9
  import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
14
- import { IDocumentStorageService } from "@fluidframework/driver-definitions";
10
+ import { IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
15
11
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
12
+ import { IGarbageCollectionData, ITelemetryContext } from "@fluidframework/runtime-definitions";
16
13
  import {
17
14
  IFluidDataStoreContext,
18
- IGarbageCollectionData,
19
15
  ISummarizeResult,
20
- ITelemetryContext,
21
- } from "@fluidframework/runtime-definitions";
22
- import { DataProcessingError, ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
16
+ } from "@fluidframework/runtime-definitions/internal";
17
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
18
+ import { DataProcessingError } from "@fluidframework/telemetry-utils/internal";
19
+
23
20
  import {
24
21
  ChannelServiceEndpoints,
25
22
  IChannelContext,
@@ -215,7 +212,7 @@ export class RehydratedLocalChannelContext extends LocalChannelContextBase {
215
212
  const blobMap: Map<string, ArrayBufferLike> = new Map<string, ArrayBufferLike>(
216
213
  extraBlob,
217
214
  );
218
- const clonedSnapshotTree = cloneDeep(this.snapshotTree);
215
+ const clonedSnapshotTree = cloneSnapshotTree(this.snapshotTree);
219
216
  // 0.47 back-compat Need to sanitize if snapshotTree.blobs still contains blob contents too.
220
217
  // This is for older snapshot which is generated by loader <=0.47 version which still contains
221
218
  // the contents within blobs. After a couple of revisions we can remove it.
@@ -353,3 +350,20 @@ export class LocalChannelContext extends LocalChannelContextBase {
353
350
  throw new Error("no stashed ops on local channel");
354
351
  }
355
352
  }
353
+
354
+ /**
355
+ * Deep clones a snapshot tree.
356
+ *
357
+ * TODO: Investigate replacing this with a deep clone utility.
358
+ * This is a temporary solution to avoid issues with lodash deepClone and ungap structuredClone.
359
+ * Using lodash caused a significant bundle size regression. structuredClone cannot be used since
360
+ * it does not support ArrayBuffer data types, and ISnapshotTree can contain blobContents properties,
361
+ * which are ArrayBuffer data types.
362
+ */
363
+ function cloneSnapshotTree(tree: ISnapshotTree): ISnapshotTree {
364
+ const clone = { ...tree, blobs: { ...tree.blobs }, trees: {} };
365
+ for (const [k, v] of Object.entries(tree.trees)) {
366
+ clone.trees[k] = cloneSnapshotTree(v);
367
+ }
368
+ return clone;
369
+ }
@@ -6,7 +6,7 @@
6
6
  import { stringToBuffer } from "@fluid-internal/client-utils";
7
7
  import { IChannelStorageService } from "@fluidframework/datastore-definitions";
8
8
  import { IBlob, ITree, TreeEntry } from "@fluidframework/protocol-definitions";
9
- import { listBlobsAtTreePath } from "@fluidframework/runtime-utils";
9
+ import { listBlobsAtTreePath } from "@fluidframework/runtime-utils/internal";
10
10
 
11
11
  export class LocalChannelStorageService implements IChannelStorageService {
12
12
  constructor(private readonly tree: ITree) {}
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
+ */
7
+
8
+ export const pkgName = "@fluidframework/datastore";
9
+ export const pkgVersion = "2.0.0-dev-rc.3.0.0.254274";
@@ -5,25 +5,25 @@
5
5
 
6
6
  import { AttachState } from "@fluidframework/container-definitions";
7
7
  import { IFluidHandle } from "@fluidframework/core-interfaces";
8
- import { assert, LazyPromise } from "@fluidframework/core-utils";
8
+ import { assert, LazyPromise } from "@fluidframework/core-utils/internal";
9
9
  import { IChannel, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
10
- import { IDocumentStorageService } from "@fluidframework/driver-definitions";
10
+ import { IDocumentStorageService } from "@fluidframework/driver-definitions/internal";
11
11
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
12
12
  import {
13
- CreateChildSummarizerNodeFn,
14
13
  IExperimentalIncrementalSummaryContext,
15
- IFluidDataStoreContext,
16
14
  IGarbageCollectionData,
17
- ISummarizeInternalResult,
18
- ISummarizeResult,
19
- ISummarizerNodeWithGC,
20
15
  ITelemetryContext,
21
16
  } from "@fluidframework/runtime-definitions";
22
17
  import {
23
- ITelemetryLoggerExt,
24
- ThresholdCounter,
25
- createChildLogger,
26
- } from "@fluidframework/telemetry-utils";
18
+ CreateChildSummarizerNodeFn,
19
+ IFluidDataStoreContext,
20
+ ISummarizeInternalResult,
21
+ ISummarizeResult,
22
+ ISummarizerNodeWithGC,
23
+ } from "@fluidframework/runtime-definitions/internal";
24
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
25
+ import { ThresholdCounter, createChildLogger } from "@fluidframework/telemetry-utils/internal";
26
+
27
27
  import {
28
28
  ChannelServiceEndpoints,
29
29
  IChannelContext,
@@ -1,70 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { strict as assert } from "assert";
6
- import { stringToBuffer } from "@fluid-internal/client-utils";
7
- import { MockLogger } from "@fluidframework/telemetry-utils";
8
- import { ChannelStorageService } from "../channelStorageService.js";
9
- describe("ChannelStorageService", () => {
10
- it("Empty Tree", async () => {
11
- const tree = {
12
- blobs: {},
13
- trees: {},
14
- };
15
- const storage = {
16
- readBlob: async (id) => {
17
- throw new Error("not implemented");
18
- },
19
- };
20
- const logger = new MockLogger();
21
- const ss = new ChannelStorageService(tree, storage, logger.toTelemetryLogger());
22
- assert.strictEqual(await ss.contains("/"), false);
23
- assert.deepStrictEqual(await ss.list(""), []);
24
- logger.assertMatchNone([{ category: "error" }]);
25
- });
26
- it("Top Level Blob", async () => {
27
- const tree = {
28
- blobs: {
29
- foo: "bar",
30
- },
31
- trees: {},
32
- };
33
- const storage = {
34
- readBlob: async (id) => {
35
- return stringToBuffer(id, "utf8");
36
- },
37
- };
38
- const logger = new MockLogger();
39
- const ss = new ChannelStorageService(tree, storage, logger.toTelemetryLogger());
40
- assert.strictEqual(await ss.contains("foo"), true);
41
- assert.deepStrictEqual(await ss.list(""), ["foo"]);
42
- assert.deepStrictEqual(await ss.readBlob("foo"), stringToBuffer("bar", "utf8"));
43
- logger.assertMatchNone([{ category: "error" }]);
44
- });
45
- it("Nested Blob", async () => {
46
- const tree = {
47
- blobs: {},
48
- trees: {
49
- nested: {
50
- blobs: {
51
- foo: "bar",
52
- },
53
- trees: {},
54
- },
55
- },
56
- };
57
- const storage = {
58
- readBlob: async (id) => {
59
- return stringToBuffer(id, "utf8");
60
- },
61
- };
62
- const logger = new MockLogger();
63
- const ss = new ChannelStorageService(tree, storage, logger.toTelemetryLogger());
64
- assert.strictEqual(await ss.contains("nested/foo"), true);
65
- assert.deepStrictEqual(await ss.list("nested/"), ["foo"]);
66
- assert.deepStrictEqual(await ss.readBlob("nested/foo"), stringToBuffer("bar", "utf8"));
67
- logger.assertMatchNone([{ category: "error" }]);
68
- });
69
- });
70
- //# sourceMappingURL=channelStorageService.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channelStorageService.spec.js","sourceRoot":"","sources":["../../src/test/channelStorageService.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACtC,EAAE,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC3B,MAAM,IAAI,GAAkB;YAC3B,KAAK,EAAE,EAAE;YACT,KAAK,EAAE,EAAE;SACT,CAAC;QACF,MAAM,OAAO,GAA8C;YAC1D,QAAQ,EAAE,KAAK,EA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AAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { MockLogger } from \"@fluidframework/telemetry-utils\";\nimport { ChannelStorageService } from \"../channelStorageService.js\";\n\ndescribe(\"ChannelStorageService\", () => {\n\tit(\"Empty Tree\", async () => {\n\t\tconst tree: ISnapshotTree = {\n\t\t\tblobs: {},\n\t\t\ttrees: {},\n\t\t};\n\t\tconst storage: Pick<IDocumentStorageService, \"readBlob\"> = {\n\t\t\treadBlob: async (id: string) => {\n\t\t\t\tthrow new Error(\"not implemented\");\n\t\t\t},\n\t\t};\n\t\tconst logger = new MockLogger();\n\t\tconst ss = new ChannelStorageService(tree, storage, logger.toTelemetryLogger());\n\n\t\tassert.strictEqual(await ss.contains(\"/\"), false);\n\t\tassert.deepStrictEqual(await ss.list(\"\"), []);\n\t\tlogger.assertMatchNone([{ category: \"error\" }]);\n\t});\n\n\tit(\"Top Level Blob\", async () => {\n\t\tconst tree: ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\tfoo: \"bar\",\n\t\t\t},\n\t\t\ttrees: {},\n\t\t};\n\t\tconst storage: Pick<IDocumentStorageService, \"readBlob\"> = {\n\t\t\treadBlob: async (id: string) => {\n\t\t\t\treturn stringToBuffer(id, \"utf8\");\n\t\t\t},\n\t\t};\n\t\tconst logger = new MockLogger();\n\t\tconst ss = new ChannelStorageService(tree, storage, logger.toTelemetryLogger());\n\n\t\tassert.strictEqual(await ss.contains(\"foo\"), true);\n\t\tassert.deepStrictEqual(await ss.list(\"\"), [\"foo\"]);\n\t\tassert.deepStrictEqual(await ss.readBlob(\"foo\"), stringToBuffer(\"bar\", \"utf8\"));\n\t\tlogger.assertMatchNone([{ category: \"error\" }]);\n\t});\n\n\tit(\"Nested Blob\", async () => {\n\t\tconst tree: ISnapshotTree = {\n\t\t\tblobs: {},\n\t\t\ttrees: {\n\t\t\t\tnested: {\n\t\t\t\t\tblobs: {\n\t\t\t\t\t\tfoo: \"bar\",\n\t\t\t\t\t},\n\t\t\t\t\ttrees: {},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t\tconst storage: Pick<IDocumentStorageService, \"readBlob\"> = {\n\t\t\treadBlob: async (id: string) => {\n\t\t\t\treturn stringToBuffer(id, \"utf8\");\n\t\t\t},\n\t\t};\n\t\tconst logger = new MockLogger();\n\t\tconst ss = new ChannelStorageService(tree, storage, logger.toTelemetryLogger());\n\n\t\tassert.strictEqual(await ss.contains(\"nested/foo\"), true);\n\t\tassert.deepStrictEqual(await ss.list(\"nested/\"), [\"foo\"]);\n\t\tassert.deepStrictEqual(await ss.readBlob(\"nested/foo\"), stringToBuffer(\"bar\", \"utf8\"));\n\t\tlogger.assertMatchNone([{ category: \"error\" }]);\n\t});\n});\n"]}
@@ -1,121 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { strict as assert } from "assert";
6
- import { ContainerErrorTypes } from "@fluidframework/container-definitions";
7
- import { SummaryType } from "@fluidframework/protocol-definitions";
8
- import { MockFluidDataStoreContext, validateAssertionError, } from "@fluidframework/test-runtime-utils";
9
- import { FluidDataStoreRuntime } from "../dataStoreRuntime.js";
10
- describe("FluidDataStoreRuntime Tests", () => {
11
- let dataStoreContext;
12
- let sharedObjectRegistry;
13
- function createRuntime(context, registry, entrypointInitializationFn) {
14
- const runtime = new FluidDataStoreRuntime(context, registry,
15
- /* existing */ false, entrypointInitializationFn ?? (async () => runtime));
16
- return runtime;
17
- }
18
- beforeEach(() => {
19
- dataStoreContext = new MockFluidDataStoreContext();
20
- // back-compat 0.38 - DataStoreRuntime looks in container runtime for certain properties that are unavailable
21
- // in the data store context.
22
- dataStoreContext.containerRuntime = {};
23
- sharedObjectRegistry = {
24
- get(type) {
25
- return {
26
- type,
27
- attributes: { type, snapshotFormatVersion: "0" },
28
- create: (runtime, id) => ({
29
- id,
30
- type,
31
- attributes: { type, snapshotFormatVersion: "0" },
32
- clientDetails: {},
33
- }),
34
- load: async () => Promise.resolve({}),
35
- };
36
- },
37
- };
38
- });
39
- it("constructor rejects ids with forward slashes", () => {
40
- const invalidId = "beforeSlash/afterSlash";
41
- dataStoreContext = new MockFluidDataStoreContext(invalidId);
42
- const codeBlock = () => new FluidDataStoreRuntime(dataStoreContext, sharedObjectRegistry, false, async (dataStoreRuntime) => {
43
- throw new Error("This shouldn't be called during the test");
44
- });
45
- assert.throws(codeBlock, (e) => validateAssertionError(e, "Id cannot contain slashes. DataStoreContext should have validated this."));
46
- });
47
- it("can create a data store runtime", () => {
48
- let failed = false;
49
- let dataStoreRuntime;
50
- try {
51
- dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
52
- }
53
- catch (error) {
54
- failed = true;
55
- }
56
- assert.strictEqual(failed, false, "Data store runtime creation failed");
57
- assert.strictEqual(dataStoreRuntime?.id, dataStoreContext.id, "Data store runtime's id in incorrect");
58
- });
59
- it("can summarize an empty data store runtime", async () => {
60
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
61
- const summarizeResult = await dataStoreRuntime.summarize(true, false);
62
- assert(summarizeResult.summary.type === SummaryType.Tree, "Data store runtime did not return a summary tree");
63
- assert(Object.keys(summarizeResult.summary.tree).length === 0, "The summary should be empty");
64
- });
65
- it("can get GC data of an empty data store runtime", async () => {
66
- // The GC data should have a single node for the data store runtime with empty outbound routes.
67
- const expectedGCData = {
68
- gcNodes: { "/": [] },
69
- };
70
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
71
- const gcData = await dataStoreRuntime.getGCData();
72
- assert.deepStrictEqual(gcData, expectedGCData, "The GC data is incorrect");
73
- });
74
- it("createChannel rejects ids with slashes", async () => {
75
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
76
- const invalidId = "beforeSlash/afterSlash";
77
- const codeBlock = () => dataStoreRuntime.createChannel(invalidId, "SomeType");
78
- assert.throws(codeBlock, (e) => e.errorType === ContainerErrorTypes.usageError &&
79
- e.message === `Id cannot contain slashes: ${invalidId}`);
80
- });
81
- it("createChannel with default guid", async () => {
82
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
83
- const type = "SomeType";
84
- const channel = dataStoreRuntime.createChannel(undefined, type);
85
- assert(channel !== undefined, "channel should be created");
86
- assert(type === channel.attributes.type, "type should be as expected");
87
- });
88
- it("createChannel and then attach to dataStore runtime", async () => {
89
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
90
- const type = "SomeType";
91
- const channel = {
92
- id: "id",
93
- type,
94
- attributes: { type, snapshotFormatVersion: "0" },
95
- clientDetails: {},
96
- };
97
- dataStoreRuntime.addChannel(channel);
98
- const channel1 = await dataStoreRuntime.getChannel(channel.id);
99
- assert.deepStrictEqual(channel, channel1, "both channel should match");
100
- });
101
- it("createChannel rejects ids with slashes when channel is created first", async () => {
102
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);
103
- const invalidId = "beforeSlash/afterSlash";
104
- const type = "SomeType";
105
- const channel = {
106
- id: invalidId,
107
- type,
108
- attributes: { type, snapshotFormatVersion: "0" },
109
- clientDetails: {},
110
- };
111
- const codeBlock = () => dataStoreRuntime.addChannel(channel);
112
- assert.throws(codeBlock, (e) => e.errorType === ContainerErrorTypes.usageError &&
113
- e.message === `Id cannot contain slashes: ${invalidId}`);
114
- });
115
- it("entryPoint is initialized correctly", async () => {
116
- const myObj = { fakeProp: "fakeValue" };
117
- const dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry, async (dsRuntime) => myObj);
118
- assert((await dataStoreRuntime.entryPoint?.get()) === myObj, "entryPoint was not initialized");
119
- });
120
- });
121
- //# sourceMappingURL=dataStoreRuntime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IAAI,EAAE,qBAAqB,EAAE,GAAG,EAAE;YAChD,aAAa,EAAE,EAAE;SACE,CAAC;QACrB,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,CACZ,SAAS,EACT,CAAC,CAAa,EAAE,EAAE,CACjB,CAAC,CAAC,SAAS,KAAK,mBAAmB,CAAC,UAAU;YAC9C,CAAC,CAAC,OAAO,KAAK,8BAA8B,SAAS,EAAE,CACxD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACpD,MAAM,KAAK,GAAgB,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QACrD,MAAM,gBAAgB,GAAG,aAAa,CACrC,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,KAAK,CAC1B,CAAC;QACF,MAAM,CACL,CAAC,MAAM,gBAAgB,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,KAAK,KAAK,EACpD,gCAAgC,CAChC,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { ContainerErrorTypes } from \"@fluidframework/container-definitions\";\nimport { FluidObject, IErrorBase } from \"@fluidframework/core-interfaces\";\nimport { IChannel, IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { SummaryType } from \"@fluidframework/protocol-definitions\";\nimport {\n\tIContainerRuntimeBase,\n\tIFluidDataStoreContext,\n\tIGarbageCollectionData,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n\tMockFluidDataStoreContext,\n\tvalidateAssertionError,\n} from \"@fluidframework/test-runtime-utils\";\nimport { FluidDataStoreRuntime, ISharedObjectRegistry } from \"../dataStoreRuntime.js\";\n\ndescribe(\"FluidDataStoreRuntime Tests\", () => {\n\tlet dataStoreContext: MockFluidDataStoreContext;\n\tlet sharedObjectRegistry: ISharedObjectRegistry;\n\tfunction createRuntime(\n\t\tcontext: IFluidDataStoreContext,\n\t\tregistry: ISharedObjectRegistry,\n\t\tentrypointInitializationFn?: (rt: IFluidDataStoreRuntime) => Promise<FluidObject>,\n\t) {\n\t\tconst runtime: FluidDataStoreRuntime = new FluidDataStoreRuntime(\n\t\t\tcontext,\n\t\t\tregistry,\n\t\t\t/* existing */ false,\n\t\t\tentrypointInitializationFn ?? (async () => runtime),\n\t\t);\n\t\treturn runtime;\n\t}\n\n\tbeforeEach(() => {\n\t\tdataStoreContext = new MockFluidDataStoreContext();\n\t\t// back-compat 0.38 - DataStoreRuntime looks in container runtime for certain properties that are unavailable\n\t\t// in the data store context.\n\t\tdataStoreContext.containerRuntime = {} as unknown as IContainerRuntimeBase;\n\t\tsharedObjectRegistry = {\n\t\t\tget(type: string) {\n\t\t\t\treturn {\n\t\t\t\t\ttype,\n\t\t\t\t\tattributes: { type, snapshotFormatVersion: \"0\" },\n\t\t\t\t\tcreate: (runtime, id: string) =>\n\t\t\t\t\t\t({\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\tattributes: { type, snapshotFormatVersion: \"0\" },\n\t\t\t\t\t\t\tclientDetails: {},\n\t\t\t\t\t\t}) as any as IChannel,\n\t\t\t\t\tload: async () => Promise.resolve({} as any as IChannel),\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t});\n\n\tit(\"constructor rejects ids with forward slashes\", () => {\n\t\tconst invalidId = \"beforeSlash/afterSlash\";\n\t\tdataStoreContext = new MockFluidDataStoreContext(invalidId);\n\t\tconst codeBlock = () =>\n\t\t\tnew FluidDataStoreRuntime(\n\t\t\t\tdataStoreContext,\n\t\t\t\tsharedObjectRegistry,\n\t\t\t\tfalse,\n\t\t\t\tasync (dataStoreRuntime) => {\n\t\t\t\t\tthrow new Error(\"This shouldn't be called during the test\");\n\t\t\t\t},\n\t\t\t);\n\t\tassert.throws(codeBlock, (e: Error) =>\n\t\t\tvalidateAssertionError(\n\t\t\t\te,\n\t\t\t\t\"Id cannot contain slashes. DataStoreContext should have validated this.\",\n\t\t\t),\n\t\t);\n\t});\n\n\tit(\"can create a data store runtime\", () => {\n\t\tlet failed: boolean = false;\n\t\tlet dataStoreRuntime: FluidDataStoreRuntime | undefined;\n\t\ttry {\n\t\t\tdataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\t} catch (error) {\n\t\t\tfailed = true;\n\t\t}\n\t\tassert.strictEqual(failed, false, \"Data store runtime creation failed\");\n\t\tassert.strictEqual(\n\t\t\tdataStoreRuntime?.id,\n\t\t\tdataStoreContext.id,\n\t\t\t\"Data store runtime's id in incorrect\",\n\t\t);\n\t});\n\n\tit(\"can summarize an empty data store runtime\", async () => {\n\t\tconst dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst summarizeResult = await dataStoreRuntime.summarize(true, false);\n\t\tassert(\n\t\t\tsummarizeResult.summary.type === SummaryType.Tree,\n\t\t\t\"Data store runtime did not return a summary tree\",\n\t\t);\n\t\tassert(\n\t\t\tObject.keys(summarizeResult.summary.tree).length === 0,\n\t\t\t\"The summary should be empty\",\n\t\t);\n\t});\n\n\tit(\"can get GC data of an empty data store runtime\", async () => {\n\t\t// The GC data should have a single node for the data store runtime with empty outbound routes.\n\t\tconst expectedGCData: IGarbageCollectionData = {\n\t\t\tgcNodes: { \"/\": [] },\n\t\t};\n\t\tconst dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst gcData = await dataStoreRuntime.getGCData();\n\t\tassert.deepStrictEqual(gcData, expectedGCData, \"The GC data is incorrect\");\n\t});\n\n\tit(\"createChannel rejects ids with slashes\", async () => {\n\t\tconst dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst invalidId = \"beforeSlash/afterSlash\";\n\t\tconst codeBlock = () => dataStoreRuntime.createChannel(invalidId, \"SomeType\");\n\t\tassert.throws(\n\t\t\tcodeBlock,\n\t\t\t(e: IErrorBase) =>\n\t\t\t\te.errorType === ContainerErrorTypes.usageError &&\n\t\t\t\te.message === `Id cannot contain slashes: ${invalidId}`,\n\t\t);\n\t});\n\n\tit(\"createChannel with default guid\", async () => {\n\t\tconst dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst type = \"SomeType\";\n\t\tconst channel = dataStoreRuntime.createChannel(undefined, type);\n\t\tassert(channel !== undefined, \"channel should be created\");\n\t\tassert(type === channel.attributes.type, \"type should be as expected\");\n\t});\n\n\tit(\"createChannel and then attach to dataStore runtime\", async () => {\n\t\tconst dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst type = \"SomeType\";\n\t\tconst channel = {\n\t\t\tid: \"id\",\n\t\t\ttype,\n\t\t\tattributes: { type, snapshotFormatVersion: \"0\" },\n\t\t\tclientDetails: {},\n\t\t} as any as IChannel;\n\t\tdataStoreRuntime.addChannel(channel);\n\t\tconst channel1 = await dataStoreRuntime.getChannel(channel.id);\n\t\tassert.deepStrictEqual(channel, channel1, \"both channel should match\");\n\t});\n\n\tit(\"createChannel rejects ids with slashes when channel is created first\", async () => {\n\t\tconst dataStoreRuntime = createRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst invalidId = \"beforeSlash/afterSlash\";\n\t\tconst type = \"SomeType\";\n\t\tconst channel = {\n\t\t\tid: invalidId,\n\t\t\ttype,\n\t\t\tattributes: { type, snapshotFormatVersion: \"0\" },\n\t\t\tclientDetails: {},\n\t\t} as any as IChannel;\n\t\tconst codeBlock = () => dataStoreRuntime.addChannel(channel);\n\t\tassert.throws(\n\t\t\tcodeBlock,\n\t\t\t(e: IErrorBase) =>\n\t\t\t\te.errorType === ContainerErrorTypes.usageError &&\n\t\t\t\te.message === `Id cannot contain slashes: ${invalidId}`,\n\t\t);\n\t});\n\n\tit(\"entryPoint is initialized correctly\", async () => {\n\t\tconst myObj: FluidObject = { fakeProp: \"fakeValue\" };\n\t\tconst dataStoreRuntime = createRuntime(\n\t\t\tdataStoreContext,\n\t\t\tsharedObjectRegistry,\n\t\t\tasync (dsRuntime) => myObj,\n\t\t);\n\t\tassert(\n\t\t\t(await dataStoreRuntime.entryPoint?.get()) === myObj,\n\t\t\t\"entryPoint was not initialized\",\n\t\t);\n\t});\n});\n"]}
@@ -1,41 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { strict as assert } from "assert";
6
- import { MockFluidDataStoreContext, validateAssertionError, } from "@fluidframework/test-runtime-utils";
7
- import { FluidDataStoreRuntime } from "../dataStoreRuntime.js";
8
- import { LocalChannelContext, RehydratedLocalChannelContext } from "../localChannelContext.js";
9
- describe("LocalChannelContext Tests", () => {
10
- let dataStoreContext;
11
- let sharedObjectRegistry;
12
- const loadRuntime = (context, registry) => new FluidDataStoreRuntime(context, registry, /* existing */ false, async () => ({
13
- myProp: "myValue",
14
- }));
15
- beforeEach(() => {
16
- dataStoreContext = new MockFluidDataStoreContext();
17
- sharedObjectRegistry = {
18
- get(type) {
19
- return {
20
- type,
21
- attributes: { type, snapshotFormatVersion: "0" },
22
- create: () => ({}),
23
- load: async () => Promise.resolve({}),
24
- };
25
- },
26
- };
27
- });
28
- it("LocalChannelContext rejects ids with forward slashes", () => {
29
- const invalidId = "beforeSlash/afterSlash";
30
- const dataStoreRuntime = loadRuntime(dataStoreContext, sharedObjectRegistry);
31
- const codeBlock = () => new LocalChannelContext({ id: invalidId }, dataStoreRuntime, dataStoreContext, dataStoreContext.storage, dataStoreContext.logger, () => { }, (s) => { }, (s) => { });
32
- assert.throws(codeBlock, (e) => validateAssertionError(e, "Channel context ID cannot contain slashes"), "Expected exception was not thrown");
33
- });
34
- it("RehydratedLocalChannelContext rejects ids with forward slashes", () => {
35
- const invalidId = "beforeSlash/afterSlash";
36
- const dataStoreRuntime = loadRuntime(dataStoreContext, sharedObjectRegistry);
37
- const codeBlock = () => new RehydratedLocalChannelContext(invalidId, sharedObjectRegistry, dataStoreRuntime, dataStoreContext, dataStoreContext.storage, dataStoreContext.logger, (content, localOpMetadata) => { }, (s) => { }, (s, o) => { }, null);
38
- assert.throws(codeBlock, (e) => validateAssertionError(e, "Channel context ID cannot contain slashes"), "Expected exception was not thrown");
39
- });
40
- });
41
- //# sourceMappingURL=localChannelContext.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"localChannelContext.spec.js","sourceRoot":"","sources":["../../src/test/localChannelContext.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1C,OAAO,EACN,yBAAyB,EACzB,sBAAsB,GACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAyB,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAE/F,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IAC1C,IAAI,gBAA2C,CAAC;IAChD,IAAI,oBAA2C,CAAC;IAChD,MAAM,WAAW,GAAG,CAAC,OAA+B,EAAE,QAA+B,EAAE,EAAE,CACxF,IAAI,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,cAAc,CAAC,KAAK,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QAC/E,MAAM,EAAE,SAAS;KACjB,CAAC,CAAC,CAAC;IAEL,UAAU,CAAC,GAAG,EAAE;QACf,gBAAgB,GAAG,IAAI,yBAAyB,EAAE,CAAC;QACnD,oBAAoB,GAAG;YACtB,GAAG,CAAC,IAAY;gBACf,OAAO;oBACN,IAAI;oBACJ,UAAU,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,EAAE;oBAChD,MAAM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C,CAAC,EAAE,CAAC,EAAE,EAAE,GAAE,CAAC,EACZ,IAAgC,CAChC,CAAC;QACH,MAAM,CAAC,MAAM,CACZ,SAAS,EACT,CAAC,CAAQ,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,EAAE,2CAA2C,CAAC,EACpF,mCAAmC,CACnC,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { IChannel } from \"@fluidframework/datastore-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport {\n\tMockFluidDataStoreContext,\n\tvalidateAssertionError,\n} from \"@fluidframework/test-runtime-utils\";\nimport { FluidDataStoreRuntime, ISharedObjectRegistry } from \"../dataStoreRuntime.js\";\nimport { LocalChannelContext, RehydratedLocalChannelContext } from \"../localChannelContext.js\";\n\ndescribe(\"LocalChannelContext Tests\", () => {\n\tlet dataStoreContext: MockFluidDataStoreContext;\n\tlet sharedObjectRegistry: ISharedObjectRegistry;\n\tconst loadRuntime = (context: IFluidDataStoreContext, registry: ISharedObjectRegistry) =>\n\t\tnew FluidDataStoreRuntime(context, registry, /* existing */ false, async () => ({\n\t\t\tmyProp: \"myValue\",\n\t\t}));\n\n\tbeforeEach(() => {\n\t\tdataStoreContext = new MockFluidDataStoreContext();\n\t\tsharedObjectRegistry = {\n\t\t\tget(type: string) {\n\t\t\t\treturn {\n\t\t\t\t\ttype,\n\t\t\t\t\tattributes: { type, snapshotFormatVersion: \"0\" },\n\t\t\t\t\tcreate: () => ({}) as any as IChannel,\n\t\t\t\t\tload: async () => Promise.resolve({} as any as IChannel),\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t});\n\n\tit(\"LocalChannelContext rejects ids with forward slashes\", () => {\n\t\tconst invalidId = \"beforeSlash/afterSlash\";\n\t\tconst dataStoreRuntime = loadRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst codeBlock = () =>\n\t\t\tnew LocalChannelContext(\n\t\t\t\t{ id: invalidId } as any as IChannel,\n\t\t\t\tdataStoreRuntime,\n\t\t\t\tdataStoreContext,\n\t\t\t\tdataStoreContext.storage,\n\t\t\t\tdataStoreContext.logger,\n\t\t\t\t() => {},\n\t\t\t\t(s: string) => {},\n\t\t\t\t(s) => {},\n\t\t\t);\n\t\tassert.throws(\n\t\t\tcodeBlock,\n\t\t\t(e: Error) => validateAssertionError(e, \"Channel context ID cannot contain slashes\"),\n\t\t\t\"Expected exception was not thrown\",\n\t\t);\n\t});\n\n\tit(\"RehydratedLocalChannelContext rejects ids with forward slashes\", () => {\n\t\tconst invalidId = \"beforeSlash/afterSlash\";\n\t\tconst dataStoreRuntime = loadRuntime(dataStoreContext, sharedObjectRegistry);\n\t\tconst codeBlock = () =>\n\t\t\tnew RehydratedLocalChannelContext(\n\t\t\t\tinvalidId,\n\t\t\t\tsharedObjectRegistry,\n\t\t\t\tdataStoreRuntime,\n\t\t\t\tdataStoreContext,\n\t\t\t\tdataStoreContext.storage,\n\t\t\t\tdataStoreContext.logger,\n\t\t\t\t(content, localOpMetadata) => {},\n\t\t\t\t(s: string) => {},\n\t\t\t\t(s, o) => {},\n\t\t\t\tnull as unknown as ISnapshotTree,\n\t\t\t);\n\t\tassert.throws(\n\t\t\tcodeBlock,\n\t\t\t(e: Error) => validateAssertionError(e, \"Channel context ID cannot contain slashes\"),\n\t\t\t\"Expected exception was not thrown\",\n\t\t);\n\t});\n});\n"]}