@fluidframework/aqueduct 2.0.0-rc.1.0.3 → 2.0.0-rc.2.0.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 (135) hide show
  1. package/dist/aqueduct-alpha.d.ts +116 -48
  2. package/dist/aqueduct-beta.d.ts +10 -0
  3. package/dist/aqueduct-public.d.ts +10 -0
  4. package/dist/aqueduct-untrimmed.d.ts +116 -48
  5. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts +39 -23
  6. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
  7. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js +3 -8
  8. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  9. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts +37 -25
  10. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  11. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js +4 -13
  12. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  13. package/dist/container-runtime-factories/index.d.ts +2 -2
  14. package/dist/container-runtime-factories/index.d.ts.map +1 -1
  15. package/dist/container-runtime-factories/index.js +4 -4
  16. package/dist/container-runtime-factories/index.js.map +1 -1
  17. package/dist/data-object-factories/dataObjectFactory.d.ts +6 -6
  18. package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
  19. package/dist/data-object-factories/dataObjectFactory.js +4 -4
  20. package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
  21. package/dist/data-object-factories/index.d.ts +2 -2
  22. package/dist/data-object-factories/index.d.ts.map +1 -1
  23. package/dist/data-object-factories/index.js +4 -4
  24. package/dist/data-object-factories/index.js.map +1 -1
  25. package/dist/data-object-factories/pureDataObjectFactory.d.ts +44 -14
  26. package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
  27. package/dist/data-object-factories/pureDataObjectFactory.js +56 -14
  28. package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
  29. package/dist/data-objects/dataObject.d.ts +3 -3
  30. package/dist/data-objects/dataObject.d.ts.map +1 -1
  31. package/dist/data-objects/dataObject.js +8 -8
  32. package/dist/data-objects/dataObject.js.map +1 -1
  33. package/dist/data-objects/index.d.ts +3 -3
  34. package/dist/data-objects/index.d.ts.map +1 -1
  35. package/dist/data-objects/index.js +4 -4
  36. package/dist/data-objects/index.js.map +1 -1
  37. package/dist/data-objects/pureDataObject.d.ts +12 -6
  38. package/dist/data-objects/pureDataObject.d.ts.map +1 -1
  39. package/dist/data-objects/pureDataObject.js +10 -0
  40. package/dist/data-objects/pureDataObject.js.map +1 -1
  41. package/dist/data-objects/types.d.ts +7 -7
  42. package/dist/data-objects/types.d.ts.map +1 -1
  43. package/dist/data-objects/types.js.map +1 -1
  44. package/dist/index.d.ts +3 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +9 -9
  47. package/dist/index.js.map +1 -1
  48. package/dist/package.json +3 -0
  49. package/dist/tsdoc-metadata.json +1 -1
  50. package/lib/{aqueduct-alpha.d.mts → aqueduct-alpha.d.ts} +131 -48
  51. package/lib/{aqueduct-beta.d.mts → aqueduct-beta.d.ts} +25 -0
  52. package/lib/{aqueduct-public.d.mts → aqueduct-public.d.ts} +25 -0
  53. package/lib/{aqueduct-untrimmed.d.mts → aqueduct-untrimmed.d.ts} +131 -48
  54. package/lib/container-runtime-factories/{baseContainerRuntimeFactory.d.mts → baseContainerRuntimeFactory.d.ts} +40 -24
  55. package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -0
  56. package/lib/container-runtime-factories/{baseContainerRuntimeFactory.mjs → baseContainerRuntimeFactory.js} +6 -10
  57. package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -0
  58. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts +57 -0
  59. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
  60. package/lib/container-runtime-factories/{containerRuntimeFactoryWithDefaultDataStore.mjs → containerRuntimeFactoryWithDefaultDataStore.js} +4 -13
  61. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
  62. package/lib/container-runtime-factories/index.d.ts +7 -0
  63. package/lib/container-runtime-factories/index.d.ts.map +1 -0
  64. package/lib/container-runtime-factories/index.js +7 -0
  65. package/lib/container-runtime-factories/index.js.map +1 -0
  66. package/lib/data-object-factories/dataObjectFactory.d.ts +23 -0
  67. package/lib/data-object-factories/dataObjectFactory.d.ts.map +1 -0
  68. package/lib/data-object-factories/{dataObjectFactory.mjs → dataObjectFactory.js} +4 -4
  69. package/lib/data-object-factories/dataObjectFactory.js.map +1 -0
  70. package/lib/data-object-factories/index.d.ts +7 -0
  71. package/lib/data-object-factories/index.d.ts.map +1 -0
  72. package/lib/data-object-factories/index.js +7 -0
  73. package/lib/data-object-factories/index.js.map +1 -0
  74. package/lib/data-object-factories/{pureDataObjectFactory.d.mts → pureDataObjectFactory.d.ts} +45 -15
  75. package/lib/data-object-factories/pureDataObjectFactory.d.ts.map +1 -0
  76. package/lib/data-object-factories/{pureDataObjectFactory.mjs → pureDataObjectFactory.js} +57 -15
  77. package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -0
  78. package/lib/data-objects/{dataObject.d.mts → dataObject.d.ts} +4 -4
  79. package/lib/data-objects/dataObject.d.ts.map +1 -0
  80. package/lib/data-objects/{dataObject.mjs → dataObject.js} +8 -8
  81. package/lib/data-objects/dataObject.js.map +1 -0
  82. package/lib/data-objects/index.d.ts +8 -0
  83. package/lib/data-objects/index.d.ts.map +1 -0
  84. package/lib/data-objects/index.js +7 -0
  85. package/lib/data-objects/index.js.map +1 -0
  86. package/lib/data-objects/{pureDataObject.d.mts → pureDataObject.d.ts} +13 -7
  87. package/lib/data-objects/pureDataObject.d.ts.map +1 -0
  88. package/lib/data-objects/{pureDataObject.mjs → pureDataObject.js} +11 -1
  89. package/lib/data-objects/pureDataObject.js.map +1 -0
  90. package/lib/data-objects/{types.d.mts → types.d.ts} +8 -8
  91. package/lib/data-objects/types.d.ts.map +1 -0
  92. package/lib/data-objects/{types.mjs → types.js} +1 -1
  93. package/lib/data-objects/types.js.map +1 -0
  94. package/lib/index.d.ts +22 -0
  95. package/lib/index.d.ts.map +1 -0
  96. package/lib/index.js +22 -0
  97. package/lib/index.js.map +1 -0
  98. package/lib/test/aqueduct.spec.js +8 -0
  99. package/lib/test/aqueduct.spec.js.map +1 -0
  100. package/lib/test/tsconfig.tsbuildinfo +1 -0
  101. package/lib/test/types/validateAqueductPrevious.generated.js +24 -0
  102. package/lib/test/types/validateAqueductPrevious.generated.js.map +1 -0
  103. package/package.json +54 -54
  104. package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.mts.map +0 -1
  105. package/lib/container-runtime-factories/baseContainerRuntimeFactory.mjs.map +0 -1
  106. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.mts +0 -45
  107. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.mts.map +0 -1
  108. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.mjs.map +0 -1
  109. package/lib/container-runtime-factories/index.d.mts +0 -7
  110. package/lib/container-runtime-factories/index.d.mts.map +0 -1
  111. package/lib/container-runtime-factories/index.mjs +0 -7
  112. package/lib/container-runtime-factories/index.mjs.map +0 -1
  113. package/lib/data-object-factories/dataObjectFactory.d.mts +0 -23
  114. package/lib/data-object-factories/dataObjectFactory.d.mts.map +0 -1
  115. package/lib/data-object-factories/dataObjectFactory.mjs.map +0 -1
  116. package/lib/data-object-factories/index.d.mts +0 -7
  117. package/lib/data-object-factories/index.d.mts.map +0 -1
  118. package/lib/data-object-factories/index.mjs +0 -7
  119. package/lib/data-object-factories/index.mjs.map +0 -1
  120. package/lib/data-object-factories/pureDataObjectFactory.d.mts.map +0 -1
  121. package/lib/data-object-factories/pureDataObjectFactory.mjs.map +0 -1
  122. package/lib/data-objects/dataObject.d.mts.map +0 -1
  123. package/lib/data-objects/dataObject.mjs.map +0 -1
  124. package/lib/data-objects/index.d.mts +0 -8
  125. package/lib/data-objects/index.d.mts.map +0 -1
  126. package/lib/data-objects/index.mjs +0 -7
  127. package/lib/data-objects/index.mjs.map +0 -1
  128. package/lib/data-objects/pureDataObject.d.mts.map +0 -1
  129. package/lib/data-objects/pureDataObject.mjs.map +0 -1
  130. package/lib/data-objects/types.d.mts.map +0 -1
  131. package/lib/data-objects/types.mjs.map +0 -1
  132. package/lib/index.d.mts +0 -8
  133. package/lib/index.d.mts.map +0 -1
  134. package/lib/index.mjs +0 -8
  135. package/lib/index.mjs.map +0 -1
@@ -3,15 +3,15 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { RequestParser } from "@fluidframework/runtime-utils";
6
- import { BaseContainerRuntimeFactory } from "./baseContainerRuntimeFactory.mjs";
6
+ import { BaseContainerRuntimeFactory } from "./baseContainerRuntimeFactory.js";
7
7
  const defaultDataStoreId = "default";
8
- const getDefaultFluidObject = async (runtime) => {
8
+ async function getDefaultFluidObject(runtime) {
9
9
  const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
10
10
  if (entryPoint === undefined) {
11
11
  throw new Error("default dataStore must exist");
12
12
  }
13
13
  return entryPoint.get();
14
- };
14
+ }
15
15
  /**
16
16
  * A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from
17
17
  * the container with an empty URL.
@@ -20,15 +20,6 @@ const getDefaultFluidObject = async (runtime) => {
20
20
  * @alpha
21
21
  */
22
22
  export class ContainerRuntimeFactoryWithDefaultDataStore extends BaseContainerRuntimeFactory {
23
- /**
24
- * Constructor
25
- * @param defaultFactory -
26
- * @param registryEntries -
27
- * @param dependencyContainer - deprecated, will be removed in a future release
28
- * @param requestHandlers -
29
- * @param runtimeOptions -
30
- * @param provideEntryPoint -
31
- */
32
23
  constructor(props) {
33
24
  const requestHandlers = props.requestHandlers ?? [];
34
25
  const provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;
@@ -59,4 +50,4 @@ export class ContainerRuntimeFactoryWithDefaultDataStore extends BaseContainerRu
59
50
  }
60
51
  }
61
52
  ContainerRuntimeFactoryWithDefaultDataStore.defaultDataStoreId = defaultDataStoreId;
62
- //# sourceMappingURL=containerRuntimeFactoryWithDefaultDataStore.mjs.map
53
+ //# sourceMappingURL=containerRuntimeFactoryWithDefaultDataStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../../src/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC,KAAK,UAAU,qBAAqB,CAAC,OAA0B;IAC9D,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;AAgCD;;;;;;GAMG;AACH,MAAM,OAAO,2CAA4C,SAAQ,2BAA2B;IAK3F,YAAmB,KAAuD;QACzE,MAAM,eAAe,GAAG,KAAK,CAAC,eAAe,IAAI,EAAE,CAAC;QACpD,MAAM,iBAAiB,GAAG,KAAK,CAAC,iBAAiB,IAAI,qBAAqB,CAAC;QAE3E,MAAM,gBAAgB,GAAG,KAAK,EAC7B,OAAiB,EACjB,OAA0B,EAEO,EAAE;YACnC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC7C,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;gBAClC,gFAAgF;gBAChF,OAAQ,OAA4B,CAAC,aAAa,CAAC;oBAClD,GAAG,EAAE,IAAI,kBAAkB,GAAG,MAAM,CAAC,KAAK,EAAE;oBAC5C,OAAO,EAAE,OAAO,CAAC,OAAO;iBACxB,CAAC,CAAC;aACH;YACD,OAAO,SAAS,CAAC,CAAC,kBAAkB;QACrC,CAAC,CAAC;QAEF,KAAK,CAAC;YACL,GAAG,KAAK;YACR,eAAe,EAAE,CAAC,gBAAgB,EAAE,GAAG,eAAe,CAAC;YACvD,iBAAiB;SACjB,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC;IAC5C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACxE,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC1E,MAAM,SAAS,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACjD,CAAC;;AAvCsB,8DAAkB,GAAG,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype IContainerRuntimeOptions,\n\ttype ContainerRuntime,\n} from \"@fluidframework/container-runtime\";\nimport {\n\ttype NamedFluidDataStoreRegistryEntries,\n\ttype IFluidDataStoreFactory,\n} from \"@fluidframework/runtime-definitions\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { type FluidObject, type IRequest, type IResponse } from \"@fluidframework/core-interfaces\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\nimport { type IFluidDependencySynthesizer } from \"@fluidframework/synthesize\";\nimport { type RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { BaseContainerRuntimeFactory } from \"./baseContainerRuntimeFactory.js\";\n\nconst defaultDataStoreId = \"default\";\n\nasync function getDefaultFluidObject(runtime: IContainerRuntime): Promise<FluidObject> {\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 * {@link ContainerRuntimeFactoryWithDefaultDataStore} construction properties.\n * @alpha\n */\nexport interface ContainerRuntimeFactoryWithDefaultDataStoreProps {\n\tdefaultFactory: IFluidDataStoreFactory;\n\t/**\n\t * The data store registry for containers produced.\n\t */\n\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t/**\n\t * @deprecated Will be removed in a future release.\n\t */\n\tdependencyContainer?: IFluidDependencySynthesizer;\n\t/**\n\t * Request handlers for containers produced.\n\t * @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\n\t */\n\trequestHandlers?: RuntimeRequestHandler[];\n\t/**\n\t * The runtime options passed to the ContainerRuntime when instantiating it\n\t */\n\truntimeOptions?: IContainerRuntimeOptions;\n\t/**\n\t * Function that will initialize the entryPoint of the ContainerRuntime instances\n\t * created with this factory\n\t */\n\tprovideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;\n}\n\n/**\n * A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from\n * the container with an empty URL.\n *\n * This factory should be exposed as fluidExport off the entry point to your module.\n * @alpha\n */\nexport class ContainerRuntimeFactoryWithDefaultDataStore extends BaseContainerRuntimeFactory {\n\tpublic static readonly defaultDataStoreId = defaultDataStoreId;\n\n\tprotected readonly defaultFactory: IFluidDataStoreFactory;\n\n\tpublic constructor(props: ContainerRuntimeFactoryWithDefaultDataStoreProps) {\n\t\tconst requestHandlers = props.requestHandlers ?? [];\n\t\tconst provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;\n\n\t\tconst getDefaultObject = async (\n\t\t\trequest: IRequest,\n\t\t\truntime: IContainerRuntime,\n\t\t\t// eslint-disable-next-line unicorn/consistent-function-scoping\n\t\t): Promise<IResponse | undefined> => {\n\t\t\tconst parser = RequestParser.create(request);\n\t\t\tif (parser.pathParts.length === 0) {\n\t\t\t\t// This cast is safe as ContainerRuntime.loadRuntime is called in the base class\n\t\t\t\treturn (runtime as ContainerRuntime).resolveHandle({\n\t\t\t\t\turl: `/${defaultDataStoreId}${parser.query}`,\n\t\t\t\t\theaders: request.headers,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn undefined; // continue search\n\t\t};\n\n\t\tsuper({\n\t\t\t...props,\n\t\t\trequestHandlers: [getDefaultObject, ...requestHandlers],\n\t\t\tprovideEntryPoint,\n\t\t});\n\n\t\tthis.defaultFactory = props.defaultFactory;\n\t}\n\n\t/**\n\t * {@inheritDoc BaseContainerRuntimeFactory.containerInitializingFirstTime}\n\t */\n\tprotected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {\n\t\tconst dataStore = await runtime.createDataStore(this.defaultFactory.type);\n\t\tawait dataStore.trySetAlias(defaultDataStoreId);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { BaseContainerRuntimeFactory, type BaseContainerRuntimeFactoryProps, } from "./baseContainerRuntimeFactory.js";
6
+ export { ContainerRuntimeFactoryWithDefaultDataStore, type ContainerRuntimeFactoryWithDefaultDataStoreProps, } from "./containerRuntimeFactoryWithDefaultDataStore.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/container-runtime-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,EAC3B,KAAK,gCAAgC,GACrC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,2CAA2C,EAC3C,KAAK,gDAAgD,GACrD,MAAM,kDAAkD,CAAC"}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { BaseContainerRuntimeFactory, } from "./baseContainerRuntimeFactory.js";
6
+ export { ContainerRuntimeFactoryWithDefaultDataStore, } from "./containerRuntimeFactoryWithDefaultDataStore.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/container-runtime-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,2BAA2B,GAE3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,2CAA2C,GAE3C,MAAM,kDAAkD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tBaseContainerRuntimeFactory,\n\ttype BaseContainerRuntimeFactoryProps,\n} from \"./baseContainerRuntimeFactory.js\";\nexport {\n\tContainerRuntimeFactoryWithDefaultDataStore,\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreProps,\n} from \"./containerRuntimeFactoryWithDefaultDataStore.js\";\n"]}
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions";
6
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
7
+ import { type FluidObjectSymbolProvider } from "@fluidframework/synthesize";
8
+ import { FluidDataStoreRuntime } from "@fluidframework/datastore";
9
+ import { type DataObject, type DataObjectTypes, type IDataObjectProps } from "../data-objects/index.js";
10
+ import { PureDataObjectFactory } from "./pureDataObjectFactory.js";
11
+ /**
12
+ * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.
13
+ * It facilitates DataObject's features (such as its shared directory) by
14
+ * ensuring relevant shared objects etc are available to the factory.
15
+ *
16
+ * @typeParam TObj - DataObject (concrete type)
17
+ * @typeParam I - The input types for the DataObject
18
+ * @alpha
19
+ */
20
+ export declare class DataObjectFactory<TObj extends DataObject<I>, I extends DataObjectTypes = DataObjectTypes> extends PureDataObjectFactory<TObj, I> {
21
+ constructor(type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory<import("@fluidframework/core-interfaces").IFluidLoadable>[] | undefined, optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeFactory?: typeof FluidDataStoreRuntime);
22
+ }
23
+ //# sourceMappingURL=dataObjectFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,kCAAkC,EAAE,MAAM,qCAAqC,CAAC;AAC9F,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EACN,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;GAQG;AACH,qBAAa,iBAAiB,CAC7B,IAAI,SAAS,UAAU,CAAC,CAAC,CAAC,EAC1B,CAAC,SAAS,eAAe,GAAG,eAAe,CAC1C,SAAQ,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;gBAEtC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9C,aAAa,kGAAiC,EAC9C,iBAAiB,EAAE,yBAAyB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,EACpE,eAAe,CAAC,EAAE,kCAAkC,EACpD,cAAc,GAAE,OAAO,qBAA6C;CAiBrE"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { DirectoryFactory, MapFactory, SharedDirectory, SharedMap } from "@fluidframework/map";
6
6
  import { FluidDataStoreRuntime } from "@fluidframework/datastore";
7
- import { PureDataObjectFactory } from "./pureDataObjectFactory.mjs";
7
+ import { PureDataObjectFactory } from "./pureDataObjectFactory.js";
8
8
  /**
9
9
  * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.
10
10
  * It facilitates DataObject's features (such as its shared directory) by
@@ -17,16 +17,16 @@ import { PureDataObjectFactory } from "./pureDataObjectFactory.mjs";
17
17
  export class DataObjectFactory extends PureDataObjectFactory {
18
18
  constructor(type, ctor, sharedObjects = [], optionalProviders, registryEntries, runtimeFactory = FluidDataStoreRuntime) {
19
19
  const mergedObjects = [...sharedObjects];
20
- if (!sharedObjects.find((factory) => factory.type === DirectoryFactory.Type)) {
20
+ if (!sharedObjects.some((factory) => factory.type === DirectoryFactory.Type)) {
21
21
  // User did not register for directory
22
22
  mergedObjects.push(SharedDirectory.getFactory());
23
23
  }
24
24
  // TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10
25
- if (!sharedObjects.find((factory) => factory.type === MapFactory.Type)) {
25
+ if (!sharedObjects.some((factory) => factory.type === MapFactory.Type)) {
26
26
  // User did not register for map
27
27
  mergedObjects.push(SharedMap.getFactory());
28
28
  }
29
29
  super(type, ctor, mergedObjects, optionalProviders, registryEntries, runtimeFactory);
30
30
  }
31
31
  }
32
- //# sourceMappingURL=dataObjectFactory.mjs.map
32
+ //# sourceMappingURL=dataObjectFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAI/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAOlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAGX,SAAQ,qBAA8B;IACvC,YACC,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoE,EACpE,eAAoD,EACpD,iBAA+C,qBAAqB;QAEpE,MAAM,aAAa,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;QAEzC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,gBAAgB,CAAC,IAAI,CAAC,EAAE;YAC7E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACjD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,EAAE;YACvE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;SAC3C;QAED,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;IACtF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DirectoryFactory, MapFactory, SharedDirectory, SharedMap } from \"@fluidframework/map\";\nimport { type NamedFluidDataStoreRegistryEntries } from \"@fluidframework/runtime-definitions\";\nimport { type IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { type FluidObjectSymbolProvider } from \"@fluidframework/synthesize\";\nimport { FluidDataStoreRuntime } from \"@fluidframework/datastore\";\n\nimport {\n\ttype DataObject,\n\ttype DataObjectTypes,\n\ttype IDataObjectProps,\n} from \"../data-objects/index.js\";\nimport { PureDataObjectFactory } from \"./pureDataObjectFactory.js\";\n\n/**\n * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.\n * It facilitates DataObject's features (such as its shared directory) by\n * ensuring relevant shared objects etc are available to the factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n * @alpha\n */\nexport class DataObjectFactory<\n\tTObj extends DataObject<I>,\n\tI extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObjectFactory<TObj, I> {\n\tpublic constructor(\n\t\ttype: string,\n\t\tctor: new (props: IDataObjectProps<I>) => TObj,\n\t\tsharedObjects: readonly IChannelFactory[] = [],\n\t\toptionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\t\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\t\truntimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n\t) {\n\t\tconst mergedObjects = [...sharedObjects];\n\n\t\tif (!sharedObjects.some((factory) => factory.type === DirectoryFactory.Type)) {\n\t\t\t// User did not register for directory\n\t\t\tmergedObjects.push(SharedDirectory.getFactory());\n\t\t}\n\n\t\t// TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10\n\t\tif (!sharedObjects.some((factory) => factory.type === MapFactory.Type)) {\n\t\t\t// User did not register for map\n\t\t\tmergedObjects.push(SharedMap.getFactory());\n\t\t}\n\n\t\tsuper(type, ctor, mergedObjects, optionalProviders, registryEntries, runtimeFactory);\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { DataObjectFactory } from "./dataObjectFactory.js";
6
+ export { PureDataObjectFactory } from "./pureDataObjectFactory.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { DataObjectFactory } from "./dataObjectFactory.js";
6
+ export { PureDataObjectFactory } from "./pureDataObjectFactory.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory.js\";\nexport { PureDataObjectFactory } from \"./pureDataObjectFactory.js\";\n"]}
@@ -3,11 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { FluidDataStoreRuntime } from "@fluidframework/datastore";
6
- import { IFluidDataStoreContext, IContainerRuntimeBase, IFluidDataStoreFactory, IFluidDataStoreRegistry, IProvideFluidDataStoreRegistry, NamedFluidDataStoreRegistryEntries, NamedFluidDataStoreRegistryEntry, IFluidDataStoreContextDetached } from "@fluidframework/runtime-definitions";
7
- import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
8
- import { IChannelFactory } from "@fluidframework/datastore-definitions";
9
- import { FluidObjectSymbolProvider } from "@fluidframework/synthesize";
10
- import { IDataObjectProps, PureDataObject, DataObjectTypes } from "../data-objects/index.mjs";
6
+ import { type IContainerRuntimeBase, type IDataStore, type IFluidDataStoreChannel, type IFluidDataStoreContext, type IFluidDataStoreContextDetached, type IFluidDataStoreFactory, type IFluidDataStoreRegistry, type NamedFluidDataStoreRegistryEntries, type NamedFluidDataStoreRegistryEntry, type IProvideFluidDataStoreRegistry } from "@fluidframework/runtime-definitions";
7
+ import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions";
8
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
9
+ import { type FluidObjectSymbolProvider } from "@fluidframework/synthesize";
10
+ import { type IDataObjectProps, type PureDataObject, type DataObjectTypes } from "../data-objects/index.js";
11
11
  /**
12
12
  * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.
13
13
  * Consumers should typically use DataObjectFactory instead unless creating
@@ -18,14 +18,27 @@ import { IDataObjectProps, PureDataObject, DataObjectTypes } from "../data-objec
18
18
  * @alpha
19
19
  */
20
20
  export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends DataObjectTypes = DataObjectTypes> implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry> {
21
+ /**
22
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
23
+ */
21
24
  readonly type: string;
22
25
  private readonly ctor;
23
26
  private readonly optionalProviders;
24
27
  private readonly runtimeClass;
25
28
  private readonly sharedObjectRegistry;
26
29
  private readonly registry;
27
- constructor(type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory[], optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeClass?: typeof FluidDataStoreRuntime);
30
+ constructor(
31
+ /**
32
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
33
+ */
34
+ type: string, ctor: new (props: IDataObjectProps<I>) => TObj, sharedObjects: readonly IChannelFactory[], optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>, registryEntries?: NamedFluidDataStoreRegistryEntries, runtimeClass?: typeof FluidDataStoreRuntime);
35
+ /**
36
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreFactory.IFluidDataStoreFactory}
37
+ */
28
38
  get IFluidDataStoreFactory(): this;
39
+ /**
40
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
41
+ */
29
42
  get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined;
30
43
  /**
31
44
  * Convenience helper to get the data store's/factory's data store registry entry.
@@ -35,11 +48,9 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
35
48
  */
36
49
  get registryEntry(): NamedFluidDataStoreRegistryEntry;
37
50
  /**
38
- * This is where we do data store setup.
39
- *
40
- * @param context - data store context used to load a data store runtime
51
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.instantiateDataStore}
41
52
  */
42
- instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<FluidDataStoreRuntime>;
53
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<IFluidDataStoreChannel>;
43
54
  /**
44
55
  * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.
45
56
  * In other words, registry of context passed in has to contain this factory, with the name that matches
@@ -48,10 +59,11 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
48
59
  * @param context - The context being used to create the runtime
49
60
  * (the created object will have its own new context created as well)
50
61
  * @param initialState - The initial state to provide to the created data store.
62
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
51
63
  * @returns an object created by this factory. Data store and objects created are not attached to container.
52
64
  * They get attached only when a handle to one of them is attached to already attached objects.
53
65
  */
54
- createChildInstance(parentContext: IFluidDataStoreContext, initialState?: I["InitialState"]): Promise<TObj>;
66
+ createChildInstance(parentContext: IFluidDataStoreContext, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
55
67
  /**
56
68
  * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.
57
69
  * In other words, registry of context passed in has to have this factory.
@@ -59,10 +71,11 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
59
71
  * @param context - The component context being used to create the object
60
72
  * (the created object will have its own new context created as well)
61
73
  * @param initialState - The initial state to provide to the created component.
74
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
62
75
  * @returns an object created by this factory. Data store and objects created are not attached to container.
63
76
  * They get attached only when a handle to one of them is attached to already attached objects.
64
77
  */
65
- createPeerInstance(peerContext: IFluidDataStoreContext, initialState?: I["InitialState"]): Promise<TObj>;
78
+ createPeerInstance(peerContext: IFluidDataStoreContext, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
66
79
  /**
67
80
  * Creates a new instance of the object. Uses container's registry to find this factory.
68
81
  * It's expected that only container owners would use this functionality, as only such developers
@@ -70,10 +83,24 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
70
83
  * The name in this registry for such record should match type of this factory.
71
84
  * @param runtime - container runtime. It's registry is used to create an object.
72
85
  * @param initialState - The initial state to provide to the created component.
86
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
73
87
  * @returns an object created by this factory. Data store and objects created are not attached to container.
74
88
  * They get attached only when a handle to one of them is attached to already attached objects.
75
89
  */
76
- createInstance(runtime: IContainerRuntimeBase, initialState?: I["InitialState"]): Promise<TObj>;
90
+ createInstance(runtime: IContainerRuntimeBase, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
91
+ /**
92
+ * Creates a new instance of the object with a datastore which exposes the aliasing api.
93
+ * @param runtime - container runtime. It is the runtime that will be used to create the object. It will produce
94
+ * the underlying infrastructure to get the data object to operate.
95
+ * @param initialState - The initial state to provide to the created component.
96
+ * @param packagePath - The path to the data store factory to use to create the data object.
97
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
98
+ * @returns an array containing the object created by this factory and an IDataStore object that enables users to
99
+ * alias the data object.
100
+ * The data object is attached only when it is attached to the handle graph that connects to an aliased object or
101
+ * when the data object is aliased.
102
+ */
103
+ createInstanceWithDataStore(containerRuntime: IContainerRuntimeBase, initialState?: I["InitialState"], packagePath?: Readonly<string[]>, loadingGroupId?: string): Promise<[TObj, IDataStore]>;
77
104
  /**
78
105
  * Creates a new root instance of the object. Uses container's registry to find this factory.
79
106
  * It's expected that only container owners would use this functionality, as only such developers
@@ -83,9 +110,12 @@ export declare class PureDataObjectFactory<TObj extends PureDataObject<I>, I ext
83
110
  * @param initialState - The initial state to provide to the created component.
84
111
  * @returns an object created by this factory. Data store and objects created are not attached to container.
85
112
  * They get attached only when a handle to one of them is attached to already attached objects.
113
+ *
114
+ * @deprecated - the issue is that it does not allow the customer to decide the conflict resolution policy when an
115
+ * aliasing conflict occurs. Use {@link PureDataObjectFactory.createInstanceWithDataStore} instead.
86
116
  */
87
117
  createRootInstance(rootDataStoreId: string, runtime: IContainerRuntime, initialState?: I["InitialState"]): Promise<TObj>;
88
- protected createNonRootInstanceCore(containerRuntime: IContainerRuntimeBase, packagePath: Readonly<string[]>, initialState?: I["InitialState"]): Promise<TObj>;
118
+ protected createNonRootInstanceCore(containerRuntime: IContainerRuntimeBase, packagePath: Readonly<string[]>, initialState?: I["InitialState"], loadingGroupId?: string): Promise<TObj>;
89
119
  protected createInstanceCore(context: IFluidDataStoreContextDetached, initialState?: I["InitialState"]): Promise<TObj>;
90
120
  }
91
- //# sourceMappingURL=pureDataObjectFactory.d.mts.map
121
+ //# sourceMappingURL=pureDataObjectFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pureDataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,qBAAqB,EAGrB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,kCAAkC,EACvC,KAAK,gCAAgC,EACrC,KAAK,8BAA8B,EACnC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,EACN,KAAK,eAAe,EAEpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,KAAK,yBAAyB,EAE9B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACN,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,0BAA0B,CAAC;AAuFlC;;;;;;;;GAQG;AACH,qBAAa,qBAAqB,CAChC,IAAI,SAAS,cAAc,CAAC,CAAC,CAAC,EAC9B,CAAC,SAAS,eAAe,GAAG,eAAe,CAE5C,YAAW,sBAAsB,EAAE,OAAO,CAAC,8BAA8B,CAAC;IAMzE;;OAEG;aACa,IAAI,EAAE,MAAM;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAErB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAElC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAZ9B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAwB;IAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;;IAG9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AE,CAAC,EAChC,cAAc,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAmB9B;;;;;;;;;;;;OAYG;IACU,kBAAkB,CAC9B,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,iBAAiB,EAC1B,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;cAqBA,yBAAyB,CACxC,gBAAgB,EAAE,qBAAqB,EACvC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAC/B,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,EAChC,cAAc,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC;cAKA,kBAAkB,CACjC,OAAO,EAAE,8BAA8B,EACvC,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;CAehB"}
@@ -65,7 +65,11 @@ async function createDataObject(ctor, context, sharedObjectRegistry, optionalPro
65
65
  * @alpha
66
66
  */
67
67
  export class PureDataObjectFactory {
68
- constructor(type, ctor, sharedObjects, optionalProviders, registryEntries, runtimeClass = FluidDataStoreRuntime) {
68
+ constructor(
69
+ /**
70
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory."type"}
71
+ */
72
+ type, ctor, sharedObjects, optionalProviders, registryEntries, runtimeClass = FluidDataStoreRuntime) {
69
73
  this.type = type;
70
74
  this.ctor = ctor;
71
75
  this.optionalProviders = optionalProviders;
@@ -78,9 +82,15 @@ export class PureDataObjectFactory {
78
82
  }
79
83
  this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));
80
84
  }
85
+ /**
86
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreFactory.IFluidDataStoreFactory}
87
+ */
81
88
  get IFluidDataStoreFactory() {
82
89
  return this;
83
90
  }
91
+ /**
92
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
93
+ */
84
94
  get IFluidDataStoreRegistry() {
85
95
  return this.registry;
86
96
  }
@@ -94,9 +104,7 @@ export class PureDataObjectFactory {
94
104
  return [this.type, Promise.resolve(this)];
95
105
  }
96
106
  /**
97
- * This is where we do data store setup.
98
- *
99
- * @param context - data store context used to load a data store runtime
107
+ * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.instantiateDataStore}
100
108
  */
101
109
  async instantiateDataStore(context, existing) {
102
110
  const { runtime } = await createDataObject(this.ctor, context, this.sharedObjectRegistry, this.optionalProviders, this.runtimeClass, existing);
@@ -110,11 +118,12 @@ export class PureDataObjectFactory {
110
118
  * @param context - The context being used to create the runtime
111
119
  * (the created object will have its own new context created as well)
112
120
  * @param initialState - The initial state to provide to the created data store.
121
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
113
122
  * @returns an object created by this factory. Data store and objects created are not attached to container.
114
123
  * They get attached only when a handle to one of them is attached to already attached objects.
115
124
  */
116
- async createChildInstance(parentContext, initialState) {
117
- return this.createNonRootInstanceCore(parentContext.containerRuntime, [...parentContext.packagePath, this.type], initialState);
125
+ async createChildInstance(parentContext, initialState, loadingGroupId) {
126
+ return this.createNonRootInstanceCore(parentContext.containerRuntime, [...parentContext.packagePath, this.type], initialState, loadingGroupId);
118
127
  }
119
128
  /**
120
129
  * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.
@@ -123,11 +132,12 @@ export class PureDataObjectFactory {
123
132
  * @param context - The component context being used to create the object
124
133
  * (the created object will have its own new context created as well)
125
134
  * @param initialState - The initial state to provide to the created component.
135
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
126
136
  * @returns an object created by this factory. Data store and objects created are not attached to container.
127
137
  * They get attached only when a handle to one of them is attached to already attached objects.
128
138
  */
129
- async createPeerInstance(peerContext, initialState) {
130
- return this.createNonRootInstanceCore(peerContext.containerRuntime, peerContext.packagePath, initialState);
139
+ async createPeerInstance(peerContext, initialState, loadingGroupId) {
140
+ return this.createNonRootInstanceCore(peerContext.containerRuntime, peerContext.packagePath, initialState, loadingGroupId);
131
141
  }
132
142
  /**
133
143
  * Creates a new instance of the object. Uses container's registry to find this factory.
@@ -136,11 +146,31 @@ export class PureDataObjectFactory {
136
146
  * The name in this registry for such record should match type of this factory.
137
147
  * @param runtime - container runtime. It's registry is used to create an object.
138
148
  * @param initialState - The initial state to provide to the created component.
149
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
139
150
  * @returns an object created by this factory. Data store and objects created are not attached to container.
140
151
  * They get attached only when a handle to one of them is attached to already attached objects.
141
152
  */
142
- async createInstance(runtime, initialState) {
143
- return this.createNonRootInstanceCore(runtime, [this.type], initialState);
153
+ async createInstance(runtime, initialState, loadingGroupId) {
154
+ return this.createNonRootInstanceCore(runtime, [this.type], initialState, loadingGroupId);
155
+ }
156
+ /**
157
+ * Creates a new instance of the object with a datastore which exposes the aliasing api.
158
+ * @param runtime - container runtime. It is the runtime that will be used to create the object. It will produce
159
+ * the underlying infrastructure to get the data object to operate.
160
+ * @param initialState - The initial state to provide to the created component.
161
+ * @param packagePath - The path to the data store factory to use to create the data object.
162
+ * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services
163
+ * @returns an array containing the object created by this factory and an IDataStore object that enables users to
164
+ * alias the data object.
165
+ * The data object is attached only when it is attached to the handle graph that connects to an aliased object or
166
+ * when the data object is aliased.
167
+ */
168
+ async createInstanceWithDataStore(containerRuntime, initialState, packagePath, loadingGroupId) {
169
+ const context = containerRuntime.createDetachedDataStore(packagePath ?? [this.type], loadingGroupId);
170
+ const { instance, runtime } = await createDataObject(this.ctor, context, this.sharedObjectRegistry, this.optionalProviders, this.runtimeClass, false, // existing
171
+ initialState);
172
+ const dataStore = await context.attachRuntime(this, runtime);
173
+ return [instance, dataStore];
144
174
  }
145
175
  /**
146
176
  * Creates a new root instance of the object. Uses container's registry to find this factory.
@@ -151,13 +181,25 @@ export class PureDataObjectFactory {
151
181
  * @param initialState - The initial state to provide to the created component.
152
182
  * @returns an object created by this factory. Data store and objects created are not attached to container.
153
183
  * They get attached only when a handle to one of them is attached to already attached objects.
184
+ *
185
+ * @deprecated - the issue is that it does not allow the customer to decide the conflict resolution policy when an
186
+ * aliasing conflict occurs. Use {@link PureDataObjectFactory.createInstanceWithDataStore} instead.
154
187
  */
155
188
  async createRootInstance(rootDataStoreId, runtime, initialState) {
156
- const context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);
157
- return this.createInstanceCore(context, initialState);
189
+ const context = runtime.createDetachedDataStore([this.type]);
190
+ const { instance, runtime: dataStoreRuntime } = await createDataObject(this.ctor, context, this.sharedObjectRegistry, this.optionalProviders, this.runtimeClass, false, // existing
191
+ initialState);
192
+ const dataStore = await context.attachRuntime(this, dataStoreRuntime);
193
+ const result = await dataStore.trySetAlias(rootDataStoreId);
194
+ if (result !== "Success") {
195
+ const handle = await runtime.getAliasedDataStoreEntryPoint(rootDataStoreId);
196
+ assert(handle !== undefined, 0x8e1 /* Should have retrieved aliased handle */);
197
+ return (await handle.get());
198
+ }
199
+ return instance;
158
200
  }
159
- async createNonRootInstanceCore(containerRuntime, packagePath, initialState) {
160
- const context = containerRuntime.createDetachedDataStore(packagePath);
201
+ async createNonRootInstanceCore(containerRuntime, packagePath, initialState, loadingGroupId) {
202
+ const context = containerRuntime.createDetachedDataStore(packagePath, loadingGroupId);
161
203
  return this.createInstanceCore(context, initialState);
162
204
  }
163
205
  async createInstanceCore(context, initialState) {
@@ -167,4 +209,4 @@ export class PureDataObjectFactory {
167
209
  return instance;
168
210
  }
169
211
  }
170
- //# sourceMappingURL=pureDataObjectFactory.mjs.map
212
+ //# sourceMappingURL=pureDataObjectFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,qBAAqB,EAErB,mBAAmB,GACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAwB3E,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAOpD;;;GAGG;AACH,KAAK,UAAU,gBAAgB,CAI9B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAK7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,mBAAmB,CACjC,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE;QAC9D,iFAAiF;QACjF,MAAM,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,CAAS,CAAC;QAC/D,MAAM,CACL,UAAU,CAAC,OAAO,KAAK,SAAS,EAChC,KAAK,CAAC,yDAAyD,CAC/D,CAAC;QACF,OAAO,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,EACD,YAAY,CACZ,CAAC;IAEF,gFAAgF;IAChF,+DAA+D;IAC/D,6EAA6E;IAC7E,MAAM,OAAO,GAA0B,IAAI,YAAY,CAAE,uCAAuC;IAC/F,OAAO,EACP,oBAAoB,EACpB,QAAQ,EACR,KAAK,EAAE,EAA0B,EAAE,EAAE;QACpC,MAAM,CAAC,QAAQ,KAAK,SA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Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IRequest, type FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n\tFluidDataStoreRuntime,\n\ttype ISharedObjectRegistry,\n\tmixinRequestHandler,\n} from \"@fluidframework/datastore\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n\ttype IContainerRuntimeBase,\n\ttype IDataStore,\n\ttype IFluidDataStoreChannel,\n\ttype IFluidDataStoreContext,\n\ttype IFluidDataStoreContextDetached,\n\ttype IFluidDataStoreFactory,\n\ttype IFluidDataStoreRegistry,\n\ttype NamedFluidDataStoreRegistryEntries,\n\ttype NamedFluidDataStoreRegistryEntry,\n\ttype IProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport {\n\ttype IChannelFactory,\n\ttype IFluidDataStoreRuntime,\n} from \"@fluidframework/datastore-definitions\";\nimport {\n\ttype AsyncFluidObjectProvider,\n\ttype FluidObjectSymbolProvider,\n\ttype IFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport {\n\ttype IDataObjectProps,\n\ttype PureDataObject,\n\ttype DataObjectTypes,\n} from \"../data-objects/index.js\";\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n */\nasync function createDataObject<\n\tTObj extends PureDataObject,\n\tI extends DataObjectTypes = DataObjectTypes,\n>(\n\tctor: new (props: IDataObjectProps<I>) => TObj,\n\tcontext: IFluidDataStoreContext,\n\tsharedObjectRegistry: ISharedObjectRegistry,\n\toptionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\truntimeClassArg: typeof FluidDataStoreRuntime,\n\texisting: boolean,\n\tinitProps?: I[\"InitialState\"],\n): Promise<{\n\tinstance: TObj;\n\truntime: FluidDataStoreRuntime;\n}> {\n\t// base\n\tlet runtimeClass = runtimeClassArg;\n\n\t// request mixin in\n\truntimeClass = mixinRequestHandler(\n\t\tasync (request: IRequest, runtimeArg: FluidDataStoreRuntime) => {\n\t\t\t// The provideEntryPoint callback below always returns TObj, so this cast is safe\n\t\t\tconst dataObject = (await runtimeArg.entryPoint.get()) as TObj;\n\t\t\tassert(\n\t\t\t\tdataObject.request !== undefined,\n\t\t\t\t0x795 /* Data store runtime entryPoint does not have request */,\n\t\t\t);\n\t\t\treturn dataObject.request(request);\n\t\t},\n\t\truntimeClass,\n\t);\n\n\t// Create a new runtime for our data store, as if via new FluidDataStoreRuntime,\n\t// but using the runtimeClass that's been augmented with mixins\n\t// The runtime is what Fluid uses to create DDS' and route to your data store\n\tconst runtime: FluidDataStoreRuntime = new runtimeClass( // calls new FluidDataStoreRuntime(...)\n\t\tcontext,\n\t\tsharedObjectRegistry,\n\t\texisting,\n\t\tasync (rt: IFluidDataStoreRuntime) => {\n\t\t\tassert(instance !== undefined, 0x46a /* entryPoint is undefined */);\n\t\t\t// Calling finishInitialization here like PureDataObject.getDataObject did, to keep the same behavior,\n\t\t\t// since accessing the runtime's entryPoint is how we want the data object to be retrieved going forward.\n\t\t\t// Without this I ran into issues with the load-existing flow not working correctly.\n\t\t\tawait instance.finishInitialization(true);\n\t\t\treturn instance;\n\t\t} /* provideEntryPoint */,\n\t);\n\n\t// Create object right away.\n\t// This allows object to register various callbacks with runtime before runtime\n\t// becomes globally available. But it's not full initialization - constructor can't\n\t// access DDSes or other services of runtime as objects are not fully initialized.\n\t// In order to use object, we need to go through full initialization by calling finishInitialization().\n\tconst scope: FluidObject<IFluidDependencySynthesizer> = context.scope;\n\tconst providers =\n\t\tscope.IFluidDependencySynthesizer?.synthesize<I[\"OptionalProviders\"]>(\n\t\t\toptionalProviders,\n\t\t\t{},\n\t\t) ??\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t({} as AsyncFluidObjectProvider<never>);\n\n\tconst instance = new ctor({ runtime, context, providers, initProps });\n\n\t// if it's a newly created object, we need to wait for it to finish initialization\n\t// as that results in creation of DDSes, before it gets attached, providing atomic\n\t// guarantee of creation.\n\t// WARNING: we can't do the same (yet) for already existing PureDataObject!\n\t// This will result in deadlock, as it tries to resolve internal handles, but any\n\t// handle resolution goes through root (container runtime), which can't route it back\n\t// to this data store, as it's still not initialized and not known to container runtime yet.\n\t// In the future, we should address it by using relative paths for handles and be able to resolve\n\t// local DDSes while data store is not fully initialized.\n\tif (!existing) {\n\t\tawait instance.finishInitialization(existing);\n\t}\n\n\treturn { instance, runtime };\n}\n\n/**\n * PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.\n * Consumers should typically use DataObjectFactory instead unless creating\n * another base data store factory.\n *\n * @typeParam TObj - DataObject (concrete type)\n * @typeParam I - The input types for the DataObject\n * @alpha\n */\nexport class PureDataObjectFactory<\n\t\tTObj extends PureDataObject<I>,\n\t\tI extends DataObjectTypes = DataObjectTypes,\n\t>\n\timplements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>\n{\n\tprivate readonly sharedObjectRegistry: ISharedObjectRegistry;\n\tprivate readonly registry: IFluidDataStoreRegistry | undefined;\n\n\tpublic constructor(\n\t\t/**\n\t\t * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.\"type\"}\n\t\t */\n\t\tpublic readonly type: string,\n\t\tprivate readonly ctor: new (props: IDataObjectProps<I>) => TObj,\n\t\tsharedObjects: readonly IChannelFactory[],\n\t\tprivate readonly optionalProviders: FluidObjectSymbolProvider<I[\"OptionalProviders\"]>,\n\t\tregistryEntries?: NamedFluidDataStoreRegistryEntries,\n\t\tprivate readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n\t) {\n\t\tif (this.type === \"\") {\n\t\t\tthrow new Error(\"undefined type member\");\n\t\t}\n\t\tif (registryEntries !== undefined) {\n\t\t\tthis.registry = new FluidDataStoreRegistry(registryEntries);\n\t\t}\n\t\tthis.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreFactory.IFluidDataStoreFactory}\n\t */\n\tpublic get IFluidDataStoreFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}\n\t */\n\tpublic get IFluidDataStoreRegistry(): IFluidDataStoreRegistry | undefined {\n\t\treturn this.registry;\n\t}\n\n\t/**\n\t * Convenience helper to get the data store's/factory's data store registry entry.\n\t * The return type hides the factory's generics, easing grouping of registry\n\t * entries that differ only in this way into the same array.\n\t * @returns The NamedFluidDataStoreRegistryEntry\n\t */\n\tpublic get registryEntry(): NamedFluidDataStoreRegistryEntry {\n\t\treturn [this.type, Promise.resolve(this)];\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#IFluidDataStoreFactory.instantiateDataStore}\n\t */\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst { runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\texisting,\n\t\t);\n\n\t\treturn runtime;\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n\t * In other words, registry of context passed in has to contain this factory, with the name that matches\n\t * this factory's type.\n\t * It is intended to be used by data store objects that create sub-objects.\n\t * @param context - The context being used to create the runtime\n\t * (the created object will have its own new context created as well)\n\t * @param initialState - The initial state to provide to the created data store.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createChildInstance(\n\t\tparentContext: IFluidDataStoreContext,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string,\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(\n\t\t\tparentContext.containerRuntime,\n\t\t\t[...parentContext.packagePath, this.type],\n\t\t\tinitialState,\n\t\t\tloadingGroupId,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n\t * In other words, registry of context passed in has to have this factory.\n\t * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n\t * @param context - The component context being used to create the object\n\t * (the created object will have its own new context created as well)\n\t * @param initialState - The initial state to provide to the created component.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createPeerInstance(\n\t\tpeerContext: IFluidDataStoreContext,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string, // DO NOT USE, this is an experimental feature\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(\n\t\t\tpeerContext.containerRuntime,\n\t\t\tpeerContext.packagePath,\n\t\t\tinitialState,\n\t\t\tloadingGroupId,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a new instance of the object. Uses container's registry to find this factory.\n\t * It's expected that only container owners would use this functionality, as only such developers\n\t * have knowledge of entries in container registry.\n\t * The name in this registry for such record should match type of this factory.\n\t * @param runtime - container runtime. It's registry is used to create an object.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t */\n\tpublic async createInstance(\n\t\truntime: IContainerRuntimeBase,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string,\n\t): Promise<TObj> {\n\t\treturn this.createNonRootInstanceCore(runtime, [this.type], initialState, loadingGroupId);\n\t}\n\n\t/**\n\t * Creates a new instance of the object with a datastore which exposes the aliasing api.\n\t * @param runtime - container runtime. It is the runtime that will be used to create the object. It will produce\n\t * the underlying infrastructure to get the data object to operate.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @param packagePath - The path to the data store factory to use to create the data object.\n\t * @param loadingGroupId - NOT production ready, EXPERIMENTAL, please read {@link https://github.com/microsoft/FluidFramework/blob/main/packages/runtime/container-runtime/README.md | README}. The service needs to support this feature, does not work for most services\n\t * @returns an array containing the object created by this factory and an IDataStore object that enables users to\n\t * alias the data object.\n\t * The data object is attached only when it is attached to the handle graph that connects to an aliased object or\n\t * when the data object is aliased.\n\t */\n\tpublic async createInstanceWithDataStore(\n\t\tcontainerRuntime: IContainerRuntimeBase,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tpackagePath?: Readonly<string[]>,\n\t\tloadingGroupId?: string,\n\t): Promise<[TObj, IDataStore]> {\n\t\tconst context = containerRuntime.createDetachedDataStore(\n\t\t\tpackagePath ?? [this.type],\n\t\t\tloadingGroupId,\n\t\t);\n\t\tconst { instance, runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\t\tconst dataStore = await context.attachRuntime(this, runtime);\n\n\t\treturn [instance, dataStore];\n\t}\n\n\t/**\n\t * Creates a new root instance of the object. Uses container's registry to find this factory.\n\t * It's expected that only container owners would use this functionality, as only such developers\n\t * have knowledge of entries in container registry.\n\t * The name in this registry for such record should match type of this factory.\n\t * @param runtime - container runtime. It's registry is used to create an object.\n\t * @param initialState - The initial state to provide to the created component.\n\t * @returns an object created by this factory. Data store and objects created are not attached to container.\n\t * They get attached only when a handle to one of them is attached to already attached objects.\n\t *\n\t * @deprecated - the issue is that it does not allow the customer to decide the conflict resolution policy when an\n\t * aliasing conflict occurs. Use {@link PureDataObjectFactory.createInstanceWithDataStore} instead.\n\t */\n\tpublic async createRootInstance(\n\t\trootDataStoreId: string,\n\t\truntime: IContainerRuntime,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst context = runtime.createDetachedDataStore([this.type]);\n\t\tconst { instance, runtime: dataStoreRuntime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\t\tconst dataStore = await context.attachRuntime(this, dataStoreRuntime);\n\t\tconst result = await dataStore.trySetAlias(rootDataStoreId);\n\t\tif (result !== \"Success\") {\n\t\t\tconst handle = await runtime.getAliasedDataStoreEntryPoint(rootDataStoreId);\n\t\t\tassert(handle !== undefined, 0x8e1 /* Should have retrieved aliased handle */);\n\t\t\treturn (await handle.get()) as TObj;\n\t\t}\n\t\treturn instance;\n\t}\n\n\tprotected async createNonRootInstanceCore(\n\t\tcontainerRuntime: IContainerRuntimeBase,\n\t\tpackagePath: Readonly<string[]>,\n\t\tinitialState?: I[\"InitialState\"],\n\t\tloadingGroupId?: string,\n\t): Promise<TObj> {\n\t\tconst context = containerRuntime.createDetachedDataStore(packagePath, loadingGroupId);\n\t\treturn this.createInstanceCore(context, initialState);\n\t}\n\n\tprotected async createInstanceCore(\n\t\tcontext: IFluidDataStoreContextDetached,\n\t\tinitialState?: I[\"InitialState\"],\n\t): Promise<TObj> {\n\t\tconst { instance, runtime } = await createDataObject(\n\t\t\tthis.ctor,\n\t\t\tcontext,\n\t\t\tthis.sharedObjectRegistry,\n\t\t\tthis.optionalProviders,\n\t\t\tthis.runtimeClass,\n\t\t\tfalse, // existing\n\t\t\tinitialState,\n\t\t);\n\n\t\tawait context.attachRuntime(this, runtime);\n\n\t\treturn instance;\n\t}\n}\n"]}
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { ISharedDirectory } from "@fluidframework/map";
6
- import { PureDataObject } from "./pureDataObject.mjs";
7
- import { DataObjectTypes } from "./types.mjs";
5
+ import { type ISharedDirectory } from "@fluidframework/map";
6
+ import { PureDataObject } from "./pureDataObject.js";
7
+ import { type DataObjectTypes } from "./types.js";
8
8
  /**
9
9
  * DataObject is a base data store that is primed with a root directory. It
10
10
  * ensures that it is created and ready before you can access it.
@@ -35,4 +35,4 @@ export declare abstract class DataObject<I extends DataObjectTypes = DataObjectT
35
35
  */
36
36
  protected getUninitializedErrorString(item: string): string;
37
37
  }
38
- //# sourceMappingURL=dataObject.d.mts.map
38
+ //# sourceMappingURL=dataObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAA+B,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;;;;;GAUG;AACH,8BAAsB,UAAU,CAC/B,CAAC,SAAS,eAAe,GAAG,eAAe,CAC1C,SAAQ,cAAc,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAE1C;;;OAGG;IACH,SAAS,KAAK,IAAI,IAAI,gBAAgB,CAMrC;IAED;;;OAGG;IACU,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BjE;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAG3D"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { MapFactory, SharedDirectory } from "@fluidframework/map";
6
- import { PureDataObject } from "./pureDataObject.mjs";
6
+ import { PureDataObject } from "./pureDataObject.js";
7
7
  /**
8
8
  * DataObject is a base data store that is primed with a root directory. It
9
9
  * ensures that it is created and ready before you can access it.
@@ -35,12 +35,7 @@ export class DataObject extends PureDataObject {
35
35
  * Caller is responsible for ensuring this is only invoked once.
36
36
  */
37
37
  async initializeInternal(existing) {
38
- if (!existing) {
39
- // Create a root directory and register it before calling initializingFirstTime
40
- this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);
41
- this.internalRoot.bindToContext();
42
- }
43
- else {
38
+ if (existing) {
44
39
  // data store has a root directory so we just need to set it before calling initializingFromExisting
45
40
  this.internalRoot = (await this.runtime.getChannel(this.rootDirectoryId));
46
41
  // This will actually be an ISharedMap if the channel was previously created by the older version of
@@ -54,6 +49,11 @@ export class DataObject extends PureDataObject {
54
49
  });
55
50
  }
56
51
  }
52
+ else {
53
+ // Create a root directory and register it before calling initializingFirstTime
54
+ this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);
55
+ this.internalRoot.bindToContext();
56
+ }
57
57
  await super.initializeInternal(existing);
58
58
  }
59
59
  /**
@@ -64,4 +64,4 @@ export class DataObject extends PureDataObject {
64
64
  return `${item} must be initialized before being accessed.`;
65
65
  }
66
66
  }
67
- //# sourceMappingURL=dataObject.mjs.map
67
+ //# sourceMappingURL=dataObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAyB,UAAU,EAAE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CAA6C,CAAC;IAC7D,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ISharedDirectory, MapFactory, SharedDirectory } from \"@fluidframework/map\";\nimport { PureDataObject } from \"./pureDataObject.js\";\nimport { type DataObjectTypes } from \"./types.js\";\n\n/**\n * DataObject is a base data store that is primed with a root directory. It\n * ensures that it is created and ready before you can access it.\n *\n * Having a single root directory allows for easier development. Instead of creating\n * and registering channels with the runtime any new DDS that is set on the root\n * will automatically be registered.\n *\n * @typeParam I - The optional input types used to strongly type the data object\n * @alpha\n */\nexport abstract class DataObject<\n\tI extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObject<I> {\n\tprivate internalRoot: ISharedDirectory | undefined;\n\tprivate readonly rootDirectoryId = \"root\";\n\n\t/**\n\t * The root directory will either be ready or will return an error. If an error is thrown\n\t * the root has not been correctly created/set.\n\t */\n\tprotected get root(): ISharedDirectory {\n\t\tif (!this.internalRoot) {\n\t\t\tthrow new Error(this.getUninitializedErrorString(`root`));\n\t\t}\n\n\t\treturn this.internalRoot;\n\t}\n\n\t/**\n\t * Initializes internal objects and calls initialization overrides.\n\t * Caller is responsible for ensuring this is only invoked once.\n\t */\n\tpublic async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root directory so we just need to set it before calling initializingFromExisting\n\t\t\tthis.internalRoot = (await this.runtime.getChannel(\n\t\t\t\tthis.rootDirectoryId,\n\t\t\t)) as ISharedDirectory;\n\n\t\t\t// This will actually be an ISharedMap if the channel was previously created by the older version of\n\t\t\t// DataObject which used a SharedMap. Since SharedMap and SharedDirectory are compatible unless\n\t\t\t// SharedDirectory-only commands are used on SharedMap, this will mostly just work for compatibility.\n\t\t\tif (this.internalRoot.attributes.type === MapFactory.Type) {\n\t\t\t\tthis.runtime.logger.send({\n\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\teventName: \"MapDataObject\",\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t\"Legacy document, SharedMap is masquerading as SharedDirectory in DataObject\",\n\t\t\t\t});\n\t\t\t}\n\t\t} else {\n\t\t\t// Create a root directory and register it before calling initializingFirstTime\n\t\t\tthis.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);\n\t\t\tthis.internalRoot.bindToContext();\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n\n\t/**\n\t * Generates an error string indicating an item is uninitialized.\n\t * @param item - The name of the item that was uninitialized.\n\t */\n\tprotected getUninitializedErrorString(item: string): string {\n\t\treturn `${item} must be initialized before being accessed.`;\n\t}\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { DataObject } from "./dataObject.js";
6
+ export { PureDataObject } from "./pureDataObject.js";
7
+ export type { DataObjectTypes, IDataObjectProps } from "./types.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { DataObject } from "./dataObject.js";
6
+ export { PureDataObject } from "./pureDataObject.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObject } from \"./dataObject.js\";\nexport { PureDataObject } from \"./pureDataObject.js\";\nexport type { DataObjectTypes, IDataObjectProps } from \"./types.js\";\n"]}