@fluidframework/test-utils 2.22.1 → 2.23.0-325054

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 (62) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/TestSummaryUtils.d.ts +2 -2
  3. package/dist/TestSummaryUtils.d.ts.map +1 -1
  4. package/dist/TestSummaryUtils.js +17 -17
  5. package/dist/TestSummaryUtils.js.map +1 -1
  6. package/dist/containerRuntimeFactories.d.ts +80 -0
  7. package/dist/containerRuntimeFactories.d.ts.map +1 -0
  8. package/dist/containerRuntimeFactories.js +94 -0
  9. package/dist/containerRuntimeFactories.js.map +1 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/localCodeLoader.d.ts.map +1 -1
  14. package/dist/localCodeLoader.js +6 -4
  15. package/dist/localCodeLoader.js.map +1 -1
  16. package/dist/packageVersion.d.ts +1 -1
  17. package/dist/packageVersion.d.ts.map +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +42 -10
  21. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  22. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -7
  23. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  24. package/dist/testFluidObject.d.ts +1 -0
  25. package/dist/testFluidObject.d.ts.map +1 -1
  26. package/dist/testFluidObject.js +5 -4
  27. package/dist/testFluidObject.js.map +1 -1
  28. package/lib/TestSummaryUtils.d.ts +2 -2
  29. package/lib/TestSummaryUtils.d.ts.map +1 -1
  30. package/lib/TestSummaryUtils.js +8 -8
  31. package/lib/TestSummaryUtils.js.map +1 -1
  32. package/lib/containerRuntimeFactories.d.ts +80 -0
  33. package/lib/containerRuntimeFactories.d.ts.map +1 -0
  34. package/lib/containerRuntimeFactories.js +92 -0
  35. package/lib/containerRuntimeFactories.js.map +1 -0
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js +1 -1
  39. package/lib/index.js.map +1 -1
  40. package/lib/localCodeLoader.d.ts.map +1 -1
  41. package/lib/localCodeLoader.js +3 -1
  42. package/lib/localCodeLoader.js.map +1 -1
  43. package/lib/packageVersion.d.ts +1 -1
  44. package/lib/packageVersion.d.ts.map +1 -1
  45. package/lib/packageVersion.js +1 -1
  46. package/lib/packageVersion.js.map +1 -1
  47. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +42 -10
  48. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  49. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js +9 -7
  50. package/lib/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  51. package/lib/testFluidObject.d.ts +1 -0
  52. package/lib/testFluidObject.d.ts.map +1 -1
  53. package/lib/testFluidObject.js +5 -4
  54. package/lib/testFluidObject.js.map +1 -1
  55. package/package.json +23 -24
  56. package/src/TestSummaryUtils.ts +9 -6
  57. package/src/containerRuntimeFactories.ts +183 -0
  58. package/src/index.ts +5 -1
  59. package/src/localCodeLoader.ts +4 -1
  60. package/src/packageVersion.ts +1 -1
  61. package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +57 -17
  62. package/src/testFluidObject.ts +8 -4
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/test-utils";
9
- export const pkgVersion = "2.22.1";
9
+ export const pkgVersion = "2.23.0-325054";
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct/internal";
6
+ import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
7
7
  import { IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
8
8
  import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
9
9
  import { FluidObject } from "@fluidframework/core-interfaces";
@@ -23,25 +23,65 @@ const getDefaultFluidObject = async (runtime: IContainerRuntime) => {
23
23
  };
24
24
 
25
25
  /**
26
- * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed
26
+ * {@link ContainerRuntimeFactoryWithDefaultDataStoreConstructor} input properties.
27
+ *
28
+ * @internal
29
+ */
30
+ export interface ContainerRuntimeFactoryWithDefaultDataStoreProps {
31
+ readonly defaultFactory: IFluidDataStoreFactory;
32
+ /**
33
+ * The data store registry for containers produced.
34
+ */
35
+ readonly registryEntries: NamedFluidDataStoreRegistryEntries;
36
+
37
+ /**
38
+ * @deprecated Do not use. This strictly exists for backwards compatibility.
39
+ */
40
+ readonly dependencyContainer?: never;
41
+
42
+ /**
43
+ * Request handlers for containers produced.
44
+ * @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
45
+ */
46
+ // eslint-disable-next-line import/no-deprecated
47
+ readonly requestHandlers?: RuntimeRequestHandler[];
48
+
49
+ /**
50
+ * The runtime options passed to the IContainerRuntime when instantiating it
51
+ */
52
+ readonly runtimeOptions?: IContainerRuntimeOptions;
53
+
54
+ /**
55
+ * Function that will initialize the entryPoint of the IContainerRuntime instances
56
+ * created with this factory
57
+ */
58
+ readonly provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
59
+ }
60
+
61
+ /**
62
+ * {@link @fluidframework/container-definitions#IRuntimeFactory} construct signature.
63
+ *
64
+ * @internal
65
+ */
66
+ export type ContainerRuntimeFactoryWithDefaultDataStoreConstructor = new (
67
+ props: ContainerRuntimeFactoryWithDefaultDataStoreProps,
68
+ ) => IRuntimeFactory;
69
+
70
+ /**
71
+ * @remarks
72
+ * This function is purely needed for back-compat as the constructor argument structure of
73
+ * `ContainerRuntimeFactoryWithDefaultDataStore` was changed.
74
+ *
27
75
  * @internal
28
76
  */
29
77
  export const createContainerRuntimeFactoryWithDefaultDataStore = (
30
- Base: typeof ContainerRuntimeFactoryWithDefaultDataStore = ContainerRuntimeFactoryWithDefaultDataStore,
31
- ctorArgs: {
32
- defaultFactory: IFluidDataStoreFactory;
33
- registryEntries: NamedFluidDataStoreRegistryEntries;
34
- dependencyContainer?: any;
35
- // eslint-disable-next-line import/no-deprecated
36
- requestHandlers?: RuntimeRequestHandler[];
37
- runtimeOptions?: IContainerRuntimeOptions;
38
- provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
39
- },
40
- ): ContainerRuntimeFactoryWithDefaultDataStore => {
78
+ ctor: ContainerRuntimeFactoryWithDefaultDataStoreConstructor,
79
+ ctorProps: ContainerRuntimeFactoryWithDefaultDataStoreProps,
80
+ ): IRuntimeFactory => {
41
81
  try {
42
- return new Base(ctorArgs);
82
+ return new ctor(ctorProps);
43
83
  } catch (err) {
44
- // IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore's
84
+ // IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older `ContainerRuntimeFactoryWithDefaultDataStore`s
45
85
  const {
46
86
  defaultFactory,
47
87
  registryEntries,
@@ -49,9 +89,9 @@ export const createContainerRuntimeFactoryWithDefaultDataStore = (
49
89
  requestHandlers,
50
90
  runtimeOptions,
51
91
  provideEntryPoint,
52
- } = ctorArgs;
92
+ } = ctorProps;
53
93
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
54
- return new (Base as any)(
94
+ return new (ctor as any)(
55
95
  defaultFactory,
56
96
  registryEntries,
57
97
  dependencyContainer,
@@ -72,11 +72,14 @@ export class TestFluidObject implements ITestFluidObject {
72
72
  throw new Error("Shared objects were not provided during creation.");
73
73
  }
74
74
 
75
- for (const key of this.factoryEntriesMap.keys()) {
76
- if (key === id) {
77
- const handle = this.root.get<IFluidHandle>(id);
78
- return handle?.get() as Promise<T>;
75
+ if (this.factoryEntriesMap.has(id)) {
76
+ const handle = this.root.get<IFluidHandle<T>>(id);
77
+ if (handle === undefined) {
78
+ throw new Error(
79
+ `Shared object with id '${id}' is in factoryEntriesMap but not found under root.`,
80
+ );
79
81
  }
82
+ return handle.get();
80
83
  }
81
84
 
82
85
  throw new Error(`Shared object with id ${id} not found.`);
@@ -110,6 +113,7 @@ export class TestFluidObject implements ITestFluidObject {
110
113
  }
111
114
 
112
115
  /**
116
+ * Iterable\<[ChannelId, IChannelFactory]\>.
113
117
  * @internal
114
118
  */
115
119
  export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFactory]>;