@fluidframework/test-utils 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.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 (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +3 -3
  4. package/api-report/test-utils.api.md +83 -74
  5. package/dist/DriverWrappers.d.ts +3 -0
  6. package/dist/DriverWrappers.d.ts.map +1 -1
  7. package/dist/DriverWrappers.js +3 -0
  8. package/dist/DriverWrappers.js.map +1 -1
  9. package/dist/TestConfigs.d.ts +4 -1
  10. package/dist/TestConfigs.d.ts.map +1 -1
  11. package/dist/TestConfigs.js +3 -0
  12. package/dist/TestConfigs.js.map +1 -1
  13. package/dist/TestSummaryUtils.d.ts +4 -2
  14. package/dist/TestSummaryUtils.d.ts.map +1 -1
  15. package/dist/TestSummaryUtils.js +3 -0
  16. package/dist/TestSummaryUtils.js.map +1 -1
  17. package/dist/containerUtils.d.ts +17 -0
  18. package/dist/containerUtils.d.ts.map +1 -1
  19. package/dist/containerUtils.js +41 -1
  20. package/dist/containerUtils.js.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +4 -1
  24. package/dist/index.js.map +1 -1
  25. package/dist/interfaces.d.ts +6 -0
  26. package/dist/interfaces.d.ts.map +1 -1
  27. package/dist/interfaces.js.map +1 -1
  28. package/dist/loaderContainerTracker.d.ts +3 -0
  29. package/dist/loaderContainerTracker.d.ts.map +1 -1
  30. package/dist/loaderContainerTracker.js +3 -0
  31. package/dist/loaderContainerTracker.js.map +1 -1
  32. package/dist/localCodeLoader.d.ts +7 -0
  33. package/dist/localCodeLoader.d.ts.map +1 -1
  34. package/dist/localCodeLoader.js +1 -0
  35. package/dist/localCodeLoader.js.map +1 -1
  36. package/dist/localLoader.d.ts +2 -0
  37. package/dist/localLoader.d.ts.map +1 -1
  38. package/dist/localLoader.js +2 -0
  39. package/dist/localLoader.js.map +1 -1
  40. package/dist/packageVersion.d.ts +1 -1
  41. package/dist/packageVersion.js +1 -1
  42. package/dist/packageVersion.js.map +1 -1
  43. package/dist/retry.d.ts +1 -0
  44. package/dist/retry.d.ts.map +1 -1
  45. package/dist/retry.js +1 -0
  46. package/dist/retry.js.map +1 -1
  47. package/dist/test-utils-alpha.d.ts +140 -0
  48. package/dist/test-utils-beta.d.ts +228 -0
  49. package/dist/test-utils-public.d.ts +228 -0
  50. package/dist/test-utils-untrimmed.d.ts +993 -0
  51. package/dist/testContainerRuntimeFactory.d.ts +2 -0
  52. package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
  53. package/dist/testContainerRuntimeFactory.js +35 -12
  54. package/dist/testContainerRuntimeFactory.js.map +1 -1
  55. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +1 -0
  56. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  57. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +10 -2
  58. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  59. package/dist/testFluidObject.d.ts +5 -0
  60. package/dist/testFluidObject.d.ts.map +1 -1
  61. package/dist/testFluidObject.js +6 -3
  62. package/dist/testFluidObject.js.map +1 -1
  63. package/dist/testObjectProvider.d.ts +287 -37
  64. package/dist/testObjectProvider.d.ts.map +1 -1
  65. package/dist/testObjectProvider.js +310 -25
  66. package/dist/testObjectProvider.js.map +1 -1
  67. package/dist/timeoutUtils.d.ts +11 -0
  68. package/dist/timeoutUtils.d.ts.map +1 -1
  69. package/dist/timeoutUtils.js +5 -0
  70. package/dist/timeoutUtils.js.map +1 -1
  71. package/dist/tsdoc-metadata.json +1 -1
  72. package/lib/test-utils-alpha.d.ts +140 -0
  73. package/lib/test-utils-beta.d.ts +228 -0
  74. package/lib/test-utils-public.d.ts +228 -0
  75. package/lib/test-utils-untrimmed.d.ts +993 -0
  76. package/package.json +63 -35
  77. package/src/DriverWrappers.ts +3 -0
  78. package/src/TestConfigs.ts +4 -1
  79. package/src/TestSummaryUtils.ts +9 -2
  80. package/src/containerUtils.ts +42 -0
  81. package/src/index.ts +7 -1
  82. package/src/interfaces.ts +6 -0
  83. package/src/loaderContainerTracker.ts +3 -0
  84. package/src/localCodeLoader.ts +7 -0
  85. package/src/localLoader.ts +2 -0
  86. package/src/packageVersion.ts +1 -1
  87. package/src/retry.ts +1 -0
  88. package/src/testContainerRuntimeFactory.ts +40 -13
  89. package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +11 -0
  90. package/src/testFluidObject.ts +10 -10
  91. package/src/testObjectProvider.ts +524 -47
  92. package/src/timeoutUtils.ts +11 -0
@@ -9,6 +9,7 @@ import { RuntimeRequestHandler } from "@fluidframework/request-handler";
9
9
  import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
10
10
  /**
11
11
  * Create a container runtime factory class that allows you to set runtime options
12
+ * @internal
12
13
  */
13
14
  export declare const createTestContainerRuntimeFactory: (containerRuntimeCtor: typeof ContainerRuntime) => {
14
15
  new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): {
@@ -26,6 +27,7 @@ export declare const createTestContainerRuntimeFactory: (containerRuntimeCtor: t
26
27
  };
27
28
  /**
28
29
  * A container runtime factory that allows you to set runtime options
30
+ * @internal
29
31
  */
30
32
  export declare const TestContainerRuntimeFactory: {
31
33
  new (type: string, dataStoreFactory: IFluidDataStoreFactory, runtimeOptions?: IContainerRuntimeOptions, requestHandlers?: RuntimeRequestHandler[]): {
@@ -1 +1 @@
1
- {"version":3,"file":"testContainerRuntimeFactory.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EACN,gBAAgB,EA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AM,iCAAiC,CAAC;AACpG,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAG7E;;;GAGG;AACH,eAAO,MAAM,iCAAiC,yBACvB,uBAAuB;eAI9B,MAAM,oBACM,sBAAsB,mBACxB,wBAAwB,oBAUvB,qBAAqB,EAAE;cAZlC,MAAM;0BACM,sBAAsB;wBACxB,wBAAwB;yBAUvB,qBAAqB,EAAE;sCAKL,gBAAgB,GAAG,QAAQ,IAAI,CAAC;yCAS7B,gBAAgB,GAAG,QAAQ,IAAI,CAAC;+BAUpE,iBAAiB,YAChB,OAAO,GACf,QAAQ,QAAQ,GAAG,iBAAiB,CAAC;;;;;CA6CzC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B;eAzFxB,MAAM,oBACM,sBAAsB,mBACxB,wBAAwB,oBAUvB,qBAAqB,EAAE;cAZlC,MAAM;0BACM,sBAAsB;wBACxB,wBAAwB;yBAUvB,qBAAqB,EAAE;sCAKL,gBAAgB,GAAG,QAAQ,IAAI,CAAC;yCAS7B,gBAAgB,GAAG,QAAQ,IAAI,CAAC;+BAUpE,iBAAiB,YAChB,OAAO,GACf,QAAQ,QAAQ,GAAG,iBAAiB,CAAC;;;;;CAmDoD,CAAC"}
@@ -5,14 +5,13 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.TestContainerRuntimeFactory = exports.createTestContainerRuntimeFactory = void 0;
8
- // eslint-disable-next-line import/no-deprecated
9
8
  const aqueduct_1 = require("@fluidframework/aqueduct");
10
9
  const container_runtime_1 = require("@fluidframework/container-runtime");
11
- // eslint-disable-next-line import/no-deprecated
12
10
  const request_handler_1 = require("@fluidframework/request-handler");
13
11
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
14
12
  /**
15
13
  * Create a container runtime factory class that allows you to set runtime options
14
+ * @internal
16
15
  */
17
16
  const createTestContainerRuntimeFactory = (containerRuntimeCtor) => {
18
17
  return class extends runtime_utils_1.RuntimeFactoryHelper {
@@ -41,24 +40,48 @@ const createTestContainerRuntimeFactory = (containerRuntimeCtor) => {
41
40
  async instantiateFromExisting(runtime) {
42
41
  // Validate we can load root data stores.
43
42
  // We should be able to load any data store that was created in initializeFirstTime!
44
- await runtime.getAliasedDataStoreEntryPoint("default");
43
+ // Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat
44
+ // testing. Can be removed when we no longer support v1.X.
45
+ await (runtime.getAliasedDataStoreEntryPoint?.("default") ??
46
+ runtime.getRootDataStore("default"));
45
47
  }
46
48
  async preInitialize(context, existing) {
47
- const runtime = await containerRuntimeCtor.load(context, [
48
- ["default", Promise.resolve(this.dataStoreFactory)],
49
- [this.type, Promise.resolve(this.dataStoreFactory)],
50
- ],
51
- // eslint-disable-next-line import/no-deprecated
52
- (0, request_handler_1.buildRuntimeRequestHandler)(
53
- // eslint-disable-next-line import/no-deprecated
54
- (0, aqueduct_1.defaultRouteRequestHandler)("default"), ...this.requestHandlers), this.runtimeOptions, context.scope, existing);
55
- return runtime;
49
+ if (containerRuntimeCtor.loadRuntime === undefined) {
50
+ // Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.
51
+ // Can be removed when we no longer support v1.X.
52
+ return containerRuntimeCtor.load(context, [
53
+ ["default", Promise.resolve(this.dataStoreFactory)],
54
+ [this.type, Promise.resolve(this.dataStoreFactory)],
55
+ ], (0, request_handler_1.buildRuntimeRequestHandler)((0, aqueduct_1.defaultRouteRequestHandler)("default"), ...this.requestHandlers), this.runtimeOptions, context.scope, existing);
56
+ }
57
+ const provideEntryPoint = async (runtime) => {
58
+ const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
59
+ if (entryPoint === undefined) {
60
+ throw new Error("default dataStore must exist");
61
+ }
62
+ return entryPoint.get();
63
+ };
64
+ return containerRuntimeCtor.loadRuntime({
65
+ context,
66
+ registryEntries: [
67
+ ["default", Promise.resolve(this.dataStoreFactory)],
68
+ [this.type, Promise.resolve(this.dataStoreFactory)],
69
+ ],
70
+ requestHandler: (0, request_handler_1.buildRuntimeRequestHandler)((0, aqueduct_1.defaultRouteRequestHandler)("default"), ...this.requestHandlers),
71
+ provideEntryPoint,
72
+ // ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0
73
+ initializeEntryPoint: provideEntryPoint,
74
+ runtimeOptions: this.runtimeOptions,
75
+ containerScope: context.scope,
76
+ existing,
77
+ });
56
78
  }
57
79
  };
58
80
  };
59
81
  exports.createTestContainerRuntimeFactory = createTestContainerRuntimeFactory;
60
82
  /**
61
83
  * A container runtime factory that allows you to set runtime options
84
+ * @internal
62
85
  */
63
86
  exports.TestContainerRuntimeFactory = (0, exports.createTestContainerRuntimeFactory)(container_runtime_1.ContainerRuntime);
64
87
  //# sourceMappingURL=testContainerRuntimeFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testContainerRuntimeFactory.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gDAAgD;AAChD,uDAAsE;AAEtE,yEAI2C;AAE3C,gDAAgD;AAChD,qEAAoG;AAEpG,iEAAqE;AAErE;;GAEG;AACI,MAAM,iCAAiC,GAAG,CAChD,oBAA6C,EAC5C,EAAE;IACH,OAAO,KAAM,SAAQ,oCAAoB;QACxC,YACQ,IAAY,EACZ,gBAAwC,EACxC,iBAA2C;YACjD,cAAc,EAAE;gBACf,sBAAsB,EAAE;oBACvB,GAAG,+CAA2B;oBAC9B,GAAG;wBACF,wBAAwB,EAAE,CAAC;qBAC3B;iBACD;aACD;SACD,EACM,kBAA2C,EAAE;YAEpD,KAAK,EAAE,CAAC;YAdD,SAAI,GAAJ,IAAI,CAAQ;YACZ,qBAAgB,GAAhB,gBAAgB,CAAwB;YACxC,mBAAc,GAAd,cAAc,CASpB;YACM,oBAAe,GAAf,eAAe,CAA8B;QAGrD,CAAC;QAEM,KAAK,CAAC,oBAAoB,CAAC,OAAyB;YAC1D,MAAM,WAAW,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;YAChF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CACnE,WAAW;YACX,cAAc,CAAC,KAAK,CACpB,CAAC;YACF,MAAM,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;QACrE,CAAC;QAEM,KAAK,CAAC,uBAAuB,CAAC,OAAyB;YAC7D,yCAAyC;YACzC,oFAAoF;YACpF,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;QACxD,CAAC;QAED,KAAK,CAAC,aAAa,CAClB,OAA0B,EAC1B,QAAiB;YAEjB,MAAM,OAAO,GAAqB,MAAM,oBAAoB,CAAC,IAAI,CAChE,OAAO,EACP;gBACC,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBACnD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACnD;YACD,gDAAgD;YAChD,IAAA,4CAA0B;YACzB,gDAAgD;YAChD,IAAA,qCAA0B,EAAC,SAAS,CAAC,EACrC,GAAG,IAAI,CAAC,eAAe,CACvB,EACD,IAAI,CAAC,cAAc,EACnB,OAAO,CAAC,KAAK,EACb,QAAQ,CACR,CAAC;YAEF,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC,CAAC;AA7DW,QAAA,iCAAiC,qCA6D5C;AAEF;;GAEG;AACU,QAAA,2BAA2B,GAAG,IAAA,yCAAiC,EAAC,oCAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-deprecated\nimport { defaultRouteRequestHandler } from \"@fluidframework/aqueduct\";\nimport { IContainerContext, IRuntime } from \"@fluidframework/container-definitions\";\nimport {\n\tContainerRuntime,\n\tIContainerRuntimeOptions,\n\tDefaultSummaryConfiguration,\n} from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\n// eslint-disable-next-line import/no-deprecated\nimport { buildRuntimeRequestHandler, RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\nimport { RuntimeFactoryHelper } from \"@fluidframework/runtime-utils\";\n\n/**\n * Create a container runtime factory class that allows you to set runtime options\n */\nexport const createTestContainerRuntimeFactory = (\n\tcontainerRuntimeCtor: typeof ContainerRuntime,\n) => {\n\treturn class extends RuntimeFactoryHelper {\n\t\tconstructor(\n\t\t\tpublic type: string,\n\t\t\tpublic dataStoreFactory: IFluidDataStoreFactory,\n\t\t\tpublic runtimeOptions: IContainerRuntimeOptions = {\n\t\t\t\tsummaryOptions: {\n\t\t\t\t\tsummaryConfigOverrides: {\n\t\t\t\t\t\t...DefaultSummaryConfiguration,\n\t\t\t\t\t\t...{\n\t\t\t\t\t\t\tinitialSummarizerDelayMs: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tpublic requestHandlers: RuntimeRequestHandler[] = [],\n\t\t) {\n\t\t\tsuper();\n\t\t}\n\n\t\tpublic async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {\n\t\t\tconst rootContext = runtime.createDetachedRootDataStore([this.type], \"default\");\n\t\t\tconst rootRuntime = await this.dataStoreFactory.instantiateDataStore(\n\t\t\t\trootContext,\n\t\t\t\t/* existing */ false,\n\t\t\t);\n\t\t\tawait rootContext.attachRuntime(this.dataStoreFactory, rootRuntime);\n\t\t}\n\n\t\tpublic async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {\n\t\t\t// Validate we can load root data stores.\n\t\t\t// We should be able to load any data store that was created in initializeFirstTime!\n\t\t\tawait runtime.getAliasedDataStoreEntryPoint(\"default\");\n\t\t}\n\n\t\tasync preInitialize(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime & IContainerRuntime> {\n\t\t\tconst runtime: ContainerRuntime = await containerRuntimeCtor.load(\n\t\t\t\tcontext,\n\t\t\t\t[\n\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t],\n\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\tbuildRuntimeRequestHandler(\n\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\tdefaultRouteRequestHandler(\"default\"),\n\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t),\n\t\t\t\tthis.runtimeOptions,\n\t\t\t\tcontext.scope,\n\t\t\t\texisting,\n\t\t\t);\n\n\t\t\treturn runtime;\n\t\t}\n\t};\n};\n\n/**\n * A container runtime factory that allows you to set runtime options\n */\nexport const TestContainerRuntimeFactory = createTestContainerRuntimeFactory(ContainerRuntime);\n"]}
1
+ {"version":3,"file":"testContainerRuntimeFactory.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAsE;AAEtE,yEAI2C;AAE3C,qEAAoG;AAEpG,iEAAqE;AAErE;;;GAGG;AACI,MAAM,iCAAiC,GAAG,CAChD,oBAA6C,EAC5C,EAAE;IACH,OAAO,KAAM,SAAQ,oCAAoB;QACxC,YACQ,IAAY,EACZ,gBAAwC,EACxC,iBAA2C;YACjD,cAAc,EAAE;gBACf,sBAAsB,EAAE;oBACvB,GAAG,+CAA2B;oBAC9B,GAAG;wBACF,wBAAwB,EAAE,CAAC;qBAC3B;iBACD;aACD;SACD,EACM,kBAA2C,EAAE;YAEpD,KAAK,EAAE,CAAC;YAdD,SAAI,GAAJ,IAAI,CAAQ;YACZ,qBAAgB,GAAhB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G,KAAK,EAAE,OAA0B,EAAE,EAAE;gBAC9D,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;gBAC1E,IAAI,UAAU,KAAK,SAAS,EAAE;oBAC7B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;iBAChD;gBACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;YACzB,CAAC,CAAC;YACF,OAAO,oBAAoB,CAAC,WAAW,CAAC;gBACvC,OAAO;gBACP,eAAe,EAAE;oBAChB,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;oBACnD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;iBACnD;gBACD,cAAc,EAAE,IAAA,4CAA0B,EACzC,IAAA,qCAA0B,EAAC,SAAS,CAAC,EACrC,GAAG,IAAI,CAAC,eAAe,CACvB;gBACD,iBAAiB;gBACjB,gFAAgF;gBAChF,oBAAoB,EAAE,iBAAiB;gBACvC,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,cAAc,EAAE,OAAO,CAAC,KAAK;gBAC7B,QAAQ;aACD,CAAC,CAAC;QACX,CAAC;KACD,CAAC;AACH,CAAC,CAAC;AAxFW,QAAA,iCAAiC,qCAwF5C;AAEF;;;GAGG;AACU,QAAA,2BAA2B,GAAG,IAAA,yCAAiC,EAAC,oCAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { defaultRouteRequestHandler } from \"@fluidframework/aqueduct\";\nimport { IContainerContext, IRuntime } from \"@fluidframework/container-definitions\";\nimport {\n\tContainerRuntime,\n\tIContainerRuntimeOptions,\n\tDefaultSummaryConfiguration,\n} from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { buildRuntimeRequestHandler, RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreFactory } from \"@fluidframework/runtime-definitions\";\nimport { RuntimeFactoryHelper } from \"@fluidframework/runtime-utils\";\n\n/**\n * Create a container runtime factory class that allows you to set runtime options\n * @internal\n */\nexport const createTestContainerRuntimeFactory = (\n\tcontainerRuntimeCtor: typeof ContainerRuntime,\n) => {\n\treturn class extends RuntimeFactoryHelper {\n\t\tconstructor(\n\t\t\tpublic type: string,\n\t\t\tpublic dataStoreFactory: IFluidDataStoreFactory,\n\t\t\tpublic runtimeOptions: IContainerRuntimeOptions = {\n\t\t\t\tsummaryOptions: {\n\t\t\t\t\tsummaryConfigOverrides: {\n\t\t\t\t\t\t...DefaultSummaryConfiguration,\n\t\t\t\t\t\t...{\n\t\t\t\t\t\t\tinitialSummarizerDelayMs: 0,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t\tpublic requestHandlers: RuntimeRequestHandler[] = [],\n\t\t) {\n\t\t\tsuper();\n\t\t}\n\n\t\tpublic async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {\n\t\t\tconst rootContext = runtime.createDetachedRootDataStore([this.type], \"default\");\n\t\t\tconst rootRuntime = await this.dataStoreFactory.instantiateDataStore(\n\t\t\t\trootContext,\n\t\t\t\t/* existing */ false,\n\t\t\t);\n\t\t\tawait rootContext.attachRuntime(this.dataStoreFactory, rootRuntime);\n\t\t}\n\n\t\tpublic async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {\n\t\t\t// Validate we can load root data stores.\n\t\t\t// We should be able to load any data store that was created in initializeFirstTime!\n\t\t\t// Note: We use the deprecated `getRootDataStore` from v1.X here to allow for cross-major version compat\n\t\t\t// testing. Can be removed when we no longer support v1.X.\n\t\t\tawait (runtime.getAliasedDataStoreEntryPoint?.(\"default\") ??\n\t\t\t\truntime.getRootDataStore(\"default\"));\n\t\t}\n\n\t\tasync preInitialize(\n\t\t\tcontext: IContainerContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IRuntime & IContainerRuntime> {\n\t\t\tif (containerRuntimeCtor.loadRuntime === undefined) {\n\t\t\t\t// Note: We use the deprecated `load` from v1.X here to allow for cross-major version compat testing.\n\t\t\t\t// Can be removed when we no longer support v1.X.\n\t\t\t\treturn containerRuntimeCtor.load(\n\t\t\t\t\tcontext,\n\t\t\t\t\t[\n\t\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t],\n\t\t\t\t\tbuildRuntimeRequestHandler(\n\t\t\t\t\t\tdefaultRouteRequestHandler(\"default\"),\n\t\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t\t),\n\t\t\t\t\tthis.runtimeOptions,\n\t\t\t\t\tcontext.scope,\n\t\t\t\t\texisting,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst provideEntryPoint = async (runtime: IContainerRuntime) => {\n\t\t\t\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\t\t\t\tif (entryPoint === undefined) {\n\t\t\t\t\tthrow new Error(\"default dataStore must exist\");\n\t\t\t\t}\n\t\t\t\treturn entryPoint.get();\n\t\t\t};\n\t\t\treturn containerRuntimeCtor.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries: [\n\t\t\t\t\t[\"default\", Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t\t[this.type, Promise.resolve(this.dataStoreFactory)],\n\t\t\t\t],\n\t\t\t\trequestHandler: buildRuntimeRequestHandler(\n\t\t\t\t\tdefaultRouteRequestHandler(\"default\"),\n\t\t\t\t\t...this.requestHandlers,\n\t\t\t\t),\n\t\t\t\tprovideEntryPoint,\n\t\t\t\t// ! This prop is needed for back-compat. Can be removed in 2.0.0-internal.8.0.0\n\t\t\t\tinitializeEntryPoint: provideEntryPoint,\n\t\t\t\truntimeOptions: this.runtimeOptions,\n\t\t\t\tcontainerScope: context.scope,\n\t\t\t\texisting,\n\t\t\t} as any);\n\t\t}\n\t};\n};\n\n/**\n * A container runtime factory that allows you to set runtime options\n * @internal\n */\nexport const TestContainerRuntimeFactory = createTestContainerRuntimeFactory(ContainerRuntime);\n"]}
@@ -10,6 +10,7 @@ import { RuntimeRequestHandler } from "@fluidframework/request-handler";
10
10
  import { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions";
11
11
  /**
12
12
  * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed
13
+ * @internal
13
14
  */
14
15
  export declare const createContainerRuntimeFactoryWithDefaultDataStore: (Base: typeof ContainerRuntimeFactoryWithDefaultDataStore | undefined, ctorArgs: {
15
16
  defaultFactory: IFluidDataStoreFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACN,sBAAsB,EACtB,kCAAkC,EAClC,MAAM,qCAAqC,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,iDAAiD;oBAG5C,sBAAsB;;0BAEhB,GAAG;;;mCAGK,iBAAiB,KAAK,QAAQ,WAAW,CAAC;MAEvE,2CAqBF,CAAC"}
1
+ {"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.d.ts","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,2CAA2C,EAAE,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EACN,sBAAsB,EACtB,kCAAkC,EAClC,MAAM,qCAAqC,CAAC;AAU7C;;;GAGG;AACH,eAAO,MAAM,iDAAiD;oBAG5C,sBAAsB;;0BAEhB,GAAG;;;mCAGK,iBAAiB,KAAK,QAAQ,WAAW,CAAC;MAEvE,2CAuBF,CAAC"}
@@ -6,8 +6,16 @@
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.createContainerRuntimeFactoryWithDefaultDataStore = void 0;
8
8
  const aqueduct_1 = require("@fluidframework/aqueduct");
9
+ const getDefaultFluidObject = async (runtime) => {
10
+ const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
11
+ if (entryPoint === undefined) {
12
+ throw new Error("default dataStore must exist");
13
+ }
14
+ return entryPoint.get();
15
+ };
9
16
  /**
10
17
  * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed
18
+ * @internal
11
19
  */
12
20
  const createContainerRuntimeFactoryWithDefaultDataStore = (Base = aqueduct_1.ContainerRuntimeFactoryWithDefaultDataStore, ctorArgs) => {
13
21
  try {
@@ -15,9 +23,9 @@ const createContainerRuntimeFactoryWithDefaultDataStore = (Base = aqueduct_1.Con
15
23
  }
16
24
  catch (err) {
17
25
  // IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore's
18
- const { defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, } = ctorArgs;
26
+ const { defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint, } = ctorArgs;
19
27
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
20
- return new Base(defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions);
28
+ return new Base(defaultFactory, registryEntries, dependencyContainer, requestHandlers, runtimeOptions, provideEntryPoint ?? getDefaultFluidObject);
21
29
  }
22
30
  };
23
31
  exports.createContainerRuntimeFactoryWithDefaultDataStore = createContainerRuntimeFactoryWithDefaultDataStore;
@@ -1 +1 @@
1
- {"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuF;AAUvF;;GAEG;AACI,MAAM,iDAAiD,GAAG,CAChE,OAA2D,sDAA2C,EACtG,QAOC,EAC6C,EAAE;IAChD,IAAI;QACH,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1B;IAAC,OAAO,GAAG,EAAE;QACb,qJAAqJ;QACrJ,MAAM,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,GACd,GAAG,QAAQ,CAAC;QACb,+DAA+D;QAC/D,OAAO,IAAK,IAAY,CACvB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,CACd,CAAC;KACF;AACF,CAAC,CAAC;AA/BW,QAAA,iDAAiD,qDA+B5D","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"@fluidframework/aqueduct\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\n\n/**\n * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed\n */\nexport const createContainerRuntimeFactoryWithDefaultDataStore = (\n\tBase: typeof ContainerRuntimeFactoryWithDefaultDataStore = ContainerRuntimeFactoryWithDefaultDataStore,\n\tctorArgs: {\n\t\tdefaultFactory: IFluidDataStoreFactory;\n\t\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t\tdependencyContainer?: any;\n\t\trequestHandlers?: RuntimeRequestHandler[];\n\t\truntimeOptions?: IContainerRuntimeOptions;\n\t\tprovideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n\t},\n): ContainerRuntimeFactoryWithDefaultDataStore => {\n\ttry {\n\t\treturn new Base(ctorArgs);\n\t} catch (err) {\n\t\t// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore's\n\t\tconst {\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t} = ctorArgs;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn new (Base as any)(\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t);\n\t}\n};\n"]}
1
+ {"version":3,"file":"testContainerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../src/testContainerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuF;AAUvF,MAAM,qBAAqB,GAAG,KAAK,EAAE,OAA0B,EAAE,EAAE;IAClE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,SAAS,CAAC,CAAC;IAC1E,IAAI,UAAU,KAAK,SAAS,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;KAChD;IACD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF;;;GAGG;AACI,MAAM,iDAAiD,GAAG,CAChE,OAA2D,sDAA2C,EACtG,QAOC,EAC6C,EAAE;IAChD,IAAI;QACH,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC;KAC1B;IAAC,OAAO,GAAG,EAAE;QACb,qJAAqJ;QACrJ,MAAM,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,GACjB,GAAG,QAAQ,CAAC;QACb,+DAA+D;QAC/D,OAAO,IAAK,IAAY,CACvB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,iBAAiB,IAAI,qBAAqB,CAC1C,CAAC;KACF;AACF,CAAC,CAAC;AAjCW,QAAA,iDAAiD,qDAiC5D","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ContainerRuntimeFactoryWithDefaultDataStore } from \"@fluidframework/aqueduct\";\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\n\nconst getDefaultFluidObject = async (runtime: IContainerRuntime) => {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(\"default\");\n\tif (entryPoint === undefined) {\n\t\tthrow new Error(\"default dataStore must exist\");\n\t}\n\treturn entryPoint.get();\n};\n\n/**\n * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed\n * @internal\n */\nexport const createContainerRuntimeFactoryWithDefaultDataStore = (\n\tBase: typeof ContainerRuntimeFactoryWithDefaultDataStore = ContainerRuntimeFactoryWithDefaultDataStore,\n\tctorArgs: {\n\t\tdefaultFactory: IFluidDataStoreFactory;\n\t\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t\tdependencyContainer?: any;\n\t\trequestHandlers?: RuntimeRequestHandler[];\n\t\truntimeOptions?: IContainerRuntimeOptions;\n\t\tprovideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n\t},\n): ContainerRuntimeFactoryWithDefaultDataStore => {\n\ttry {\n\t\treturn new Base(ctorArgs);\n\t} catch (err) {\n\t\t// IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore's\n\t\tconst {\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t\tprovideEntryPoint,\n\t\t} = ctorArgs;\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn new (Base as any)(\n\t\t\tdefaultFactory,\n\t\t\tregistryEntries,\n\t\t\tdependencyContainer,\n\t\t\trequestHandlers,\n\t\t\truntimeOptions,\n\t\t\tprovideEntryPoint ?? getDefaultFluidObject,\n\t\t);\n\t}\n};\n"]}
@@ -12,6 +12,7 @@ import { ITestFluidObject } from "./interfaces";
12
12
  * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.
13
13
  * The shared objects can be retrieved by passing the key of the entry to getSharedObject.
14
14
  * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.
15
+ * @internal
15
16
  */
16
17
  export declare class TestFluidObject implements ITestFluidObject {
17
18
  readonly runtime: IFluidDataStoreRuntime;
@@ -47,6 +48,9 @@ export declare class TestFluidObject implements ITestFluidObject {
47
48
  request(request: IRequest): Promise<IResponse>;
48
49
  initialize(existing: boolean): Promise<void>;
49
50
  }
51
+ /**
52
+ * @internal
53
+ */
50
54
  export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;
51
55
  /**
52
56
  * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime
@@ -77,6 +81,7 @@ export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFacto
77
81
  * `describeCompat` aims to provide:
78
82
  * `SharedMap`s always reference the current version of SharedMap.
79
83
  * AB#4670 tracks improving this situation.
84
+ * @internal
80
85
  */
81
86
  export declare class TestFluidObjectFactory implements IFluidDataStoreFactory {
82
87
  private readonly factoryEntries;
@@ -1 +1 @@
1
- {"version":3,"file":"testFluidObject.d.ts","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,QAAQ,EACR,SAAS,EACT,YAAY,EAGZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEN,qBAAqB,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAa,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAEhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,gBAAgB;aAgCtC,OAAO,EAAE,sBAAsB;aAC/B,OAAO,EAAE,sBAAsB;aAC/B,OAAO,EAAE,sBAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAlCnC,IAAW,gBAAgB,SAE1B;IAED,IAAW,cAAc,SAExB;IAED;;OAEG;IACH,IAAW,YAAY,SAEtB;IAED,IAAW,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAEtC;IAEM,IAAI,EAAG,UAAU,CAAC;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,WAAW,CAA4B;IAE/C;;;;;;OAMG;gBAEc,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE,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C,qBAAqB,CAAC;CAmDjC"}
@@ -14,6 +14,7 @@ const core_utils_1 = require("@fluidframework/core-utils");
14
14
  * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.
15
15
  * The shared objects can be retrieved by passing the key of the entry to getSharedObject.
16
16
  * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.
17
+ * @internal
17
18
  */
18
19
  class TestFluidObject {
19
20
  get ITestFluidObject() {
@@ -116,6 +117,7 @@ exports.TestFluidObject = TestFluidObject;
116
117
  * `describeCompat` aims to provide:
117
118
  * `SharedMap`s always reference the current version of SharedMap.
118
119
  * AB#4670 tracks improving this situation.
120
+ * @internal
119
121
  */
120
122
  class TestFluidObjectFactory {
121
123
  get IFluidDataStoreFactory() {
@@ -149,9 +151,10 @@ class TestFluidObjectFactory {
149
151
  }
150
152
  }
151
153
  const runtimeClass = (0, datastore_1.mixinRequestHandler)(async (request, rt) => {
152
- const maybeRouter = await rt.entryPoint.get();
153
- (0, core_utils_1.assert)(maybeRouter.IFluidRouter !== undefined, "entryPoint should have been initialized by now");
154
- return maybeRouter.IFluidRouter.request(request);
154
+ // The provideEntryPoint callback below always returns FluidDataStoreRuntime, so this cast is safe
155
+ const dataObject = (await rt.entryPoint.get());
156
+ (0, core_utils_1.assert)(dataObject.request !== undefined, "entryPoint should have been initialized by now");
157
+ return dataObject.request(request);
155
158
  });
156
159
  const runtime = new runtimeClass(context, dataTypes, existing, async () => {
157
160
  await instance.initialize(true);
@@ -1 +1 @@
1
- {"version":3,"file":"testFluidObject.js","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gDAAgD;AAChD,uDAA4E;AAQ5E,yDAImC;AACnC,6CAA4D;AAO5D,2DAAoD;AAGpD;;;;GAIG;AACH,MAAa,eAAe;IAC3B,IAAW,gBAAgB;QAC1B,OAAO,IAAI,CAAC;IACb,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC;IACb,CAAC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\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-deprecated\nimport { defaultFluidObjectRequestHandler } from \"@fluidframework/aqueduct\";\nimport {\n\tIRequest,\n\tIResponse,\n\tIFluidHandle,\n\tFluidObject,\n\tIProvideFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidObjectHandle,\n\tFluidDataStoreRuntime,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { SharedMap, ISharedMap } from \"@fluidframework/map\";\nimport {\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime, IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ITestFluidObject } from \"./interfaces\";\n\n/**\n * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.\n * The shared objects can be retrieved by passing the key of the entry to getSharedObject.\n * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.\n */\nexport class TestFluidObject implements ITestFluidObject {\n\tpublic get ITestFluidObject() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic get IFluidRouter() {\n\t\treturn this;\n\t}\n\n\tpublic get handle(): IFluidHandle<this> {\n\t\treturn this.innerHandle;\n\t}\n\n\tpublic root!: ISharedMap;\n\tprivate readonly innerHandle: IFluidHandle<this>;\n\tprivate initializeP: Promise<void> | undefined;\n\n\t/**\n\t * Creates a new TestFluidObject.\n\t * @param runtime - The data store runtime.\n\t * @param context - The data store context.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,\n\t * a shared object is created which can be retrieved by calling getSharedObject() with the id;\n\t */\n\tconstructor(\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly channel: IFluidDataStoreChannel,\n\t\tpublic readonly context: IFluidDataStoreContext,\n\t\tprivate readonly factoryEntriesMap: Map<string, IChannelFactory>,\n\t) {\n\t\tthis.innerHandle = new FluidObjectHandle(this, \"\", runtime.objectsRoutingContext);\n\t}\n\n\t/**\n\t * Retrieves a shared object with the given id.\n\t * @param id - The id of the shared object to retrieve.\n\t */\n\tpublic async getSharedObject<T = any>(id: string): Promise<T> {\n\t\tif (this.factoryEntriesMap === undefined) {\n\t\t\tthrow new Error(\"Shared objects were not provided during creation.\");\n\t\t}\n\n\t\tfor (const key of this.factoryEntriesMap.keys()) {\n\t\t\tif (key === id) {\n\t\t\t\tconst handle = this.root.get<IFluidHandle>(id);\n\t\t\t\treturn handle?.get() as unknown as T;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Shared object with id ${id} not found.`);\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\treturn defaultFluidObjectRequestHandler(this, request);\n\t}\n\n\tpublic async initialize(existing: boolean) {\n\t\tconst doInitialization = async () => {\n\t\t\tif (!existing) {\n\t\t\t\tthis.root = SharedMap.create(this.runtime, \"root\");\n\n\t\t\t\tthis.factoryEntriesMap.forEach(\n\t\t\t\t\t(sharedObjectFactory: IChannelFactory, key: string) => {\n\t\t\t\t\t\tconst sharedObject = this.runtime.createChannel(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tsharedObjectFactory.type,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.root.set(key, sharedObject.handle);\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tthis.root.bindToContext();\n\t\t\t}\n\n\t\t\tthis.root = (await this.runtime.getChannel(\"root\")) as ISharedMap;\n\t\t};\n\n\t\tif (this.initializeP === undefined) {\n\t\t\tthis.initializeP = doInitialization();\n\t\t}\n\n\t\treturn this.initializeP;\n\t}\n}\n\nexport type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;\n\n/**\n * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime\n * with the object factories in the entry list. All the entries with an id other than undefined are passed to the\n * Fluid object so that it can create a shared object for each.\n *\n * @example\n *\n * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.\n * It will add SparseMatrix to the data store's factory so that it can be created later.\n *\n * ```typescript\n * new TestFluidObjectFactory([\n * [ \"sharedString\", SharedString.getFactory() ],\n * [ \"sharedDirectory\", SharedDirectory.getFactory() ],\n * [ undefined, SparseMatrix.getFactory() ],\n * ]);\n * ```\n *\n * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:\n *\n * ```typescript\n * sharedString = testFluidObject.getSharedObject<SharedString>(\"sharedString\");\n * sharedDir = testFluidObject.getSharedObject<SharedDirectory>(\"sharedDirectory\");\n * ```\n *\n * @privateRemarks Beware that using this class generally forfeits some compatibility coverage\n * `describeCompat` aims to provide:\n * `SharedMap`s always reference the current version of SharedMap.\n * AB#4670 tracks improving this situation.\n */\nexport class TestFluidObjectFactory implements IFluidDataStoreFactory {\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a new TestFluidObjectFactory.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each\n\t * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object\n\t * for it.\n\t */\n\tconstructor(\n\t\tprivate readonly factoryEntries: ChannelFactoryRegistry,\n\t\tpublic readonly type = \"TestFluidObjectFactory\",\n\t) {}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<FluidDataStoreRuntime> {\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\n\t\t// Add SharedMap's factory which will be used to create the root map.\n\t\tconst sharedMapFactory = SharedMap.getFactory();\n\t\tdataTypes.set(sharedMapFactory.type, sharedMapFactory);\n\n\t\t// Add the object factories to the list to be sent to data store runtime.\n\t\tfor (const [, factory] of this.factoryEntries) {\n\t\t\tdataTypes.set(factory.type, factory);\n\t\t}\n\n\t\t// Create a map from the factory entries with entries that don't have the id as undefined. This will be\n\t\t// passed to the Fluid object.\n\t\tconst factoryEntriesMapForObject = new Map<string, IChannelFactory>();\n\t\tfor (const [id, factory] of this.factoryEntries) {\n\t\t\tif (id !== undefined) {\n\t\t\t\tfactoryEntriesMapForObject.set(id, factory);\n\t\t\t}\n\t\t}\n\n\t\tconst runtimeClass = mixinRequestHandler(\n\t\t\tasync (request: IRequest, rt: FluidDataStoreRuntime) => {\n\t\t\t\tconst maybeRouter: FluidObject<IProvideFluidRouter> = await rt.entryPoint.get();\n\t\t\t\tassert(\n\t\t\t\t\tmaybeRouter.IFluidRouter !== undefined,\n\t\t\t\t\t\"entryPoint should have been initialized by now\",\n\t\t\t\t);\n\t\t\t\treturn maybeRouter.IFluidRouter.request(request);\n\t\t\t},\n\t\t);\n\n\t\tconst runtime = new runtimeClass(context, dataTypes, existing, async () => {\n\t\t\tawait instance.initialize(true);\n\t\t\treturn instance;\n\t\t});\n\n\t\tconst instance: TestFluidObject = new TestFluidObject(\n\t\t\truntime, // runtime\n\t\t\truntime, // channel\n\t\t\tcontext,\n\t\t\tfactoryEntriesMapForObject,\n\t\t);\n\n\t\tif (!existing) {\n\t\t\tawait instance.initialize(false);\n\t\t}\n\n\t\treturn runtime;\n\t}\n}\n"]}
1
+ {"version":3,"file":"testFluidObject.js","sourceRoot":"","sources":["../src/testFluidObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,gDAAgD;AAChD,uDAA4E;AAE5E,yDAImC;AACnC,6CAA4D;AAO5D,2DAAoD;AAGpD;;;;;GAKG;AACH,MAAa,eAAe;IAC3B,IAA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AAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACjC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACD;AAtED,wDAsEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// eslint-disable-next-line import/no-deprecated\nimport { defaultFluidObjectRequestHandler } from \"@fluidframework/aqueduct\";\nimport { IRequest, IResponse, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidObjectHandle,\n\tFluidDataStoreRuntime,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { SharedMap, ISharedMap } from \"@fluidframework/map\";\nimport {\n\tIFluidDataStoreContext,\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime, IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { ITestFluidObject } from \"./interfaces\";\n\n/**\n * A test Fluid object that will create a shared object for each key-value pair in the factoryEntries passed to load.\n * The shared objects can be retrieved by passing the key of the entry to getSharedObject.\n * It exposes the IFluidDataStoreContext and IFluidDataStoreRuntime.\n * @internal\n */\nexport class TestFluidObject implements ITestFluidObject {\n\tpublic get ITestFluidObject() {\n\t\treturn this;\n\t}\n\n\tpublic get IFluidLoadable() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic get IFluidRouter() {\n\t\treturn this;\n\t}\n\n\tpublic get handle(): IFluidHandle<this> {\n\t\treturn this.innerHandle;\n\t}\n\n\tpublic root!: ISharedMap;\n\tprivate readonly innerHandle: IFluidHandle<this>;\n\tprivate initializeP: Promise<void> | undefined;\n\n\t/**\n\t * Creates a new TestFluidObject.\n\t * @param runtime - The data store runtime.\n\t * @param context - The data store context.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. For each item in the list,\n\t * a shared object is created which can be retrieved by calling getSharedObject() with the id;\n\t */\n\tconstructor(\n\t\tpublic readonly runtime: IFluidDataStoreRuntime,\n\t\tpublic readonly channel: IFluidDataStoreChannel,\n\t\tpublic readonly context: IFluidDataStoreContext,\n\t\tprivate readonly factoryEntriesMap: Map<string, IChannelFactory>,\n\t) {\n\t\tthis.innerHandle = new FluidObjectHandle(this, \"\", runtime.objectsRoutingContext);\n\t}\n\n\t/**\n\t * Retrieves a shared object with the given id.\n\t * @param id - The id of the shared object to retrieve.\n\t */\n\tpublic async getSharedObject<T = any>(id: string): Promise<T> {\n\t\tif (this.factoryEntriesMap === undefined) {\n\t\t\tthrow new Error(\"Shared objects were not provided during creation.\");\n\t\t}\n\n\t\tfor (const key of this.factoryEntriesMap.keys()) {\n\t\t\tif (key === id) {\n\t\t\t\tconst handle = this.root.get<IFluidHandle>(id);\n\t\t\t\treturn handle?.get() as unknown as T;\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Shared object with id ${id} not found.`);\n\t}\n\n\t/**\n\t * @deprecated Will be removed in future major release. Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// eslint-disable-next-line import/no-deprecated\n\t\treturn defaultFluidObjectRequestHandler(this, request);\n\t}\n\n\tpublic async initialize(existing: boolean) {\n\t\tconst doInitialization = async () => {\n\t\t\tif (!existing) {\n\t\t\t\tthis.root = SharedMap.create(this.runtime, \"root\");\n\n\t\t\t\tthis.factoryEntriesMap.forEach(\n\t\t\t\t\t(sharedObjectFactory: IChannelFactory, key: string) => {\n\t\t\t\t\t\tconst sharedObject = this.runtime.createChannel(\n\t\t\t\t\t\t\tkey,\n\t\t\t\t\t\t\tsharedObjectFactory.type,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.root.set(key, sharedObject.handle);\n\t\t\t\t\t},\n\t\t\t\t);\n\n\t\t\t\tthis.root.bindToContext();\n\t\t\t}\n\n\t\t\tthis.root = (await this.runtime.getChannel(\"root\")) as ISharedMap;\n\t\t};\n\n\t\tif (this.initializeP === undefined) {\n\t\t\tthis.initializeP = doInitialization();\n\t\t}\n\n\t\treturn this.initializeP;\n\t}\n}\n\n/**\n * @internal\n */\nexport type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;\n\n/**\n * Creates a factory for a TestFluidObject with the given object factory entries. It creates a data store runtime\n * with the object factories in the entry list. All the entries with an id other than undefined are passed to the\n * Fluid object so that it can create a shared object for each.\n *\n * @example\n *\n * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.\n * It will add SparseMatrix to the data store's factory so that it can be created later.\n *\n * ```typescript\n * new TestFluidObjectFactory([\n * [ \"sharedString\", SharedString.getFactory() ],\n * [ \"sharedDirectory\", SharedDirectory.getFactory() ],\n * [ undefined, SparseMatrix.getFactory() ],\n * ]);\n * ```\n *\n * The SharedString and SharedDirectory can be retrieved via getSharedObject() on the TestFluidObject as follows:\n *\n * ```typescript\n * sharedString = testFluidObject.getSharedObject<SharedString>(\"sharedString\");\n * sharedDir = testFluidObject.getSharedObject<SharedDirectory>(\"sharedDirectory\");\n * ```\n *\n * @privateRemarks Beware that using this class generally forfeits some compatibility coverage\n * `describeCompat` aims to provide:\n * `SharedMap`s always reference the current version of SharedMap.\n * AB#4670 tracks improving this situation.\n * @internal\n */\nexport class TestFluidObjectFactory implements IFluidDataStoreFactory {\n\tpublic get IFluidDataStoreFactory() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates a new TestFluidObjectFactory.\n\t * @param factoryEntries - A list of id to IChannelFactory mapping. It creates a data store runtime with each\n\t * IChannelFactory. Entries with string ids are passed to the Fluid object so that it can create a shared object\n\t * for it.\n\t */\n\tconstructor(\n\t\tprivate readonly factoryEntries: ChannelFactoryRegistry,\n\t\tpublic readonly type = \"TestFluidObjectFactory\",\n\t) {}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<FluidDataStoreRuntime> {\n\t\tconst dataTypes = new Map<string, IChannelFactory>();\n\n\t\t// Add SharedMap's factory which will be used to create the root map.\n\t\tconst sharedMapFactory = SharedMap.getFactory();\n\t\tdataTypes.set(sharedMapFactory.type, sharedMapFactory);\n\n\t\t// Add the object factories to the list to be sent to data store runtime.\n\t\tfor (const [, factory] of this.factoryEntries) {\n\t\t\tdataTypes.set(factory.type, factory);\n\t\t}\n\n\t\t// Create a map from the factory entries with entries that don't have the id as undefined. This will be\n\t\t// passed to the Fluid object.\n\t\tconst factoryEntriesMapForObject = new Map<string, IChannelFactory>();\n\t\tfor (const [id, factory] of this.factoryEntries) {\n\t\t\tif (id !== undefined) {\n\t\t\t\tfactoryEntriesMapForObject.set(id, factory);\n\t\t\t}\n\t\t}\n\n\t\tconst runtimeClass = mixinRequestHandler(\n\t\t\tasync (request: IRequest, rt: FluidDataStoreRuntime) => {\n\t\t\t\t// The provideEntryPoint callback below always returns FluidDataStoreRuntime, so this cast is safe\n\t\t\t\tconst dataObject = (await rt.entryPoint.get()) as FluidDataStoreRuntime;\n\t\t\t\tassert(\n\t\t\t\t\tdataObject.request !== undefined,\n\t\t\t\t\t\"entryPoint should have been initialized by now\",\n\t\t\t\t);\n\t\t\t\treturn dataObject.request(request);\n\t\t\t},\n\t\t);\n\n\t\tconst runtime = new runtimeClass(context, dataTypes, existing, async () => {\n\t\t\tawait instance.initialize(true);\n\t\t\treturn instance;\n\t\t});\n\n\t\tconst instance: TestFluidObject = new TestFluidObject(\n\t\t\truntime, // runtime\n\t\t\truntime, // channel\n\t\t\tcontext,\n\t\t\tfactoryEntriesMapForObject,\n\t\t);\n\n\t\tif (!existing) {\n\t\t\tawait instance.initialize(false);\n\t\t}\n\n\t\treturn runtime;\n\t}\n}\n"]}