@fluidframework/aqueduct 0.51.3 → 0.53.0-46105
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.
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/dist/container-services/containerServices.d.ts +5 -2
- package/dist/container-services/containerServices.d.ts.map +1 -1
- package/dist/container-services/containerServices.js.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.d.ts +21 -4
- package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.js +18 -4
- package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.d.ts +30 -13
- package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.js +20 -5
- package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/dist/data-objects/dataObject.d.ts +25 -5
- package/dist/data-objects/dataObject.d.ts.map +1 -1
- package/dist/data-objects/dataObject.js +21 -5
- package/dist/data-objects/dataObject.js.map +1 -1
- package/dist/data-objects/index.d.ts +3 -2
- package/dist/data-objects/index.d.ts.map +1 -1
- package/dist/data-objects/index.js +3 -1
- package/dist/data-objects/index.js.map +1 -1
- package/dist/data-objects/pureDataObject.d.ts +29 -18
- package/dist/data-objects/pureDataObject.d.ts.map +1 -1
- package/dist/data-objects/pureDataObject.js +18 -5
- package/dist/data-objects/pureDataObject.js.map +1 -1
- package/dist/data-objects/types.d.ts +38 -0
- package/dist/data-objects/types.d.ts.map +1 -0
- package/dist/data-objects/types.js +7 -0
- package/dist/data-objects/types.js.map +1 -0
- package/dist/request-handlers/requestHandlers.d.ts +2 -2
- package/dist/request-handlers/requestHandlers.d.ts.map +1 -1
- package/dist/request-handlers/requestHandlers.js.map +1 -1
- package/dist/test/defaultRoute.spec.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +151 -169
- package/dist/utils/containerInteractions.d.ts +4 -4
- package/dist/utils/containerInteractions.d.ts.map +1 -1
- package/dist/utils/containerInteractions.js.map +1 -1
- package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/lib/container-services/containerServices.js.map +1 -1
- package/lib/data-object-factories/dataObjectFactory.js +16 -3
- package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
- package/lib/data-object-factories/pureDataObjectFactory.js +18 -4
- package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/lib/data-objects/dataObject.js +19 -4
- package/lib/data-objects/dataObject.js.map +1 -1
- package/lib/data-objects/index.js +2 -2
- package/lib/data-objects/index.js.map +1 -1
- package/lib/data-objects/pureDataObject.js +16 -4
- package/lib/data-objects/pureDataObject.js.map +1 -1
- package/lib/data-objects/types.js +6 -0
- package/lib/data-objects/types.js.map +1 -0
- package/lib/request-handlers/requestHandlers.js.map +1 -1
- package/lib/utils/containerInteractions.js.map +1 -1
- package/package.json +15 -15
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IFluidObject } from "@fluidframework/core-interfaces";
|
|
5
|
+
import { FluidObject, IFluidObject } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IContainer } from "@fluidframework/container-definitions";
|
|
7
7
|
/**
|
|
8
8
|
* Helper function for getting the default Fluid Object from a Container. This function only works for
|
|
@@ -12,7 +12,7 @@ import { IContainer } from "@fluidframework/container-definitions";
|
|
|
12
12
|
*
|
|
13
13
|
* @param container - Container you're attempting to get the object from
|
|
14
14
|
*/
|
|
15
|
-
export declare function getDefaultObjectFromContainer<T = IFluidObject>(container: IContainer): Promise<T>;
|
|
15
|
+
export declare function getDefaultObjectFromContainer<T = IFluidObject & FluidObject>(container: IContainer): Promise<T>;
|
|
16
16
|
/**
|
|
17
17
|
* Helper function for getting as Fluid Object from a Container given a Unique Id. This function only works for
|
|
18
18
|
* Containers that support getting FluidObjects via request.
|
|
@@ -22,7 +22,7 @@ export declare function getDefaultObjectFromContainer<T = IFluidObject>(containe
|
|
|
22
22
|
* @param id - Unique id of the FluidObject
|
|
23
23
|
* @param container - Container you're attempting to get the object from
|
|
24
24
|
*/
|
|
25
|
-
export declare function getObjectWithIdFromContainer<T = IFluidObject>(id: string, container: IContainer): Promise<T>;
|
|
25
|
+
export declare function getObjectWithIdFromContainer<T = IFluidObject & FluidObject>(id: string, container: IContainer): Promise<T>;
|
|
26
26
|
/**
|
|
27
27
|
* Helper function for getting a Fluid Object from a Container given a path/url. This function only works for
|
|
28
28
|
* Containers that support getting FluidObjects via request.
|
|
@@ -32,5 +32,5 @@ export declare function getObjectWithIdFromContainer<T = IFluidObject>(id: strin
|
|
|
32
32
|
* @param path - Unique path/url of the FluidObject
|
|
33
33
|
* @param container - Container you're attempting to get the object from
|
|
34
34
|
*/
|
|
35
|
-
export declare function getObjectFromContainer<T = IFluidObject>(path: string, container: IContainer): Promise<T>;
|
|
35
|
+
export declare function getObjectFromContainer<T = IFluidObject & FluidObject>(path: string, container: IContainer): Promise<T>;
|
|
36
36
|
//# sourceMappingURL=containerInteractions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerInteractions.d.ts","sourceRoot":"","sources":["../../src/utils/containerInteractions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"containerInteractions.d.ts","sourceRoot":"","sources":["../../src/utils/containerInteractions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAEnE;;;;;;;GAOG;AACH,wBAAsB,6BAA6B,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAarH;AAED;;;;;;;;GAQG;AACH,wBAAsB,4BAA4B,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,EAC7E,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAajD;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,EACvE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAWnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerInteractions.js","sourceRoot":"","sources":["../../src/utils/containerInteractions.ts"],"names":[],"mappings":";;;AAOA;;;;;;;GAOG;AACI,KAAK,UAAU,6BAA6B,
|
|
1
|
+
{"version":3,"file":"containerInteractions.js","sourceRoot":"","sources":["../../src/utils/containerInteractions.ts"],"names":[],"mappings":";;;AAOA;;;;;;;GAOG;AACI,KAAK,UAAU,6BAA6B,CAAiC,SAAqB;IACrG,MAAM,GAAG,GAAG,GAAG,CAAC;IAChB,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAElD,sBAAsB;IACtB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,4CAA4C,GAAG,GAAG,CAAC,CAAC;KACvE;SAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,GAAG,CAAC,CAAC;KACxD;IAED,+DAA+D;IAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC1B,CAAC;AAbD,sEAaC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,4BAA4B,CAC9C,EAAU,EAAE,SAAqB;IACjC,MAAM,GAAG,GAAG,IAAI,EAAE,EAAE,CAAC;IACrB,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAElD,sBAAsB;IACtB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,6CAA6C,EAAE,gBAAgB,GAAG,GAAG,CAAC,CAAC;KAC1F;SAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,2BAA2B,EAAE,gBAAgB,GAAG,GAAG,CAAC,CAAC;KACxE;IAED,+DAA+D;IAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC1B,CAAC;AAdD,oEAcC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,sBAAsB,CACxC,IAAY,EAAE,SAAqB;IACnC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAExD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,mDAAmD,IAAI,GAAG,CAAC,CAAC;KAC/E;SAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;KAC7D;IAED,+DAA+D;IAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC1B,CAAC;AAZD,wDAYC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { FluidObject, IFluidObject } from \"@fluidframework/core-interfaces\";\nimport { IContainer } from \"@fluidframework/container-definitions\";\n\n/**\n * Helper function for getting the default Fluid Object from a Container. This function only works for\n * Containers that support \"/\" request.\n *\n * T - defines the type you expect to be returned\n *\n * @param container - Container you're attempting to get the object from\n */\nexport async function getDefaultObjectFromContainer<T = IFluidObject & FluidObject>(container: IContainer): Promise<T> {\n const url = \"/\";\n const response = await container.request({ url });\n\n // Verify the response\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object at URL: \"${url}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response from URL: \"${url}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n\n/**\n * Helper function for getting as Fluid Object from a Container given a Unique Id. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * T - defines the type you expect to be returned\n *\n * @param id - Unique id of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectWithIdFromContainer<T = IFluidObject & FluidObject>(\n id: string, container: IContainer): Promise<T> {\n const url = `/${id}`;\n const response = await container.request({ url });\n\n // Verify the response\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object with ID: \"${id}\" from URL: \"${url}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response for ID: \"${id}\" from URL: \"${url}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n\n/**\n * Helper function for getting a Fluid Object from a Container given a path/url. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * T - defines the type you expect to be returned\n *\n * @param path - Unique path/url of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectFromContainer<T = IFluidObject & FluidObject>(\n path: string, container: IContainer): Promise<T> {\n const response = await container.request({ url: path });\n\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object with from URL: \"${path}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response for from URL: \"${path}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseContainerRuntimeFactory.js","sourceRoot":"","sources":["../../src/container-runtime-factories/baseContainerRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEH,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,iBAAiB,GACpB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAEH,0BAA0B,EAC1B,mBAAmB,GACtB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EACH,mBAAmB,GAGtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"baseContainerRuntimeFactory.js","sourceRoot":"","sources":["../../src/container-runtime-factories/baseContainerRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEH,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,iBAAiB,GACpB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAEH,0BAA0B,EAC1B,mBAAmB,GACtB,MAAM,iCAAiC,CAAC;AAMzC,OAAO,EACH,mBAAmB,GAGtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAGrE;;;;GAIG;AACH,MAAM,OAAO,2BACT,SAAQ,oBAAoB;IAK5B;;;;;OAKG;IACH,YACqB,eAAmD,EACnD,kBAA+C,EAAE,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAE1D,KAAK,EAAE,CAAC;QALS,oBAAe,GAAf,eAAe,CAAoC;QACnD,oBAAe,GAAf,eAAe,CAAkC;QACjD,oBAAe,GAAf,eAAe,CAA8B;QAC7C,mBAAc,GAAd,cAAc,CAA2B;Q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BAA8B,CAAC,OAA0B,IAAI,CAAC;IAE9E;;;;OAIG;IACO,KAAK,CAAC,uBAAuB,CAAC,OAA0B,IAAI,CAAC;CAC1E","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainerContext } from \"@fluidframework/container-definitions\";\nimport {\n IContainerRuntimeOptions,\n FluidDataStoreRegistry,\n ContainerRuntime,\n} from \"@fluidframework/container-runtime\";\nimport {\n IContainerRuntime,\n} from \"@fluidframework/container-runtime-definitions\";\nimport {\n RuntimeRequestHandler,\n buildRuntimeRequestHandler,\n innerRequestHandler,\n} from \"@fluidframework/request-handler\";\nimport {\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n DependencyContainer,\n DependencyContainerRegistry,\n IProvideFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\nimport { RuntimeFactoryHelper } from \"@fluidframework/runtime-utils\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * BaseContainerRuntimeFactory produces container runtimes with a given data store and service registry, as well as\n * given request handlers. It can be subclassed to implement a first-time initialization procedure for the containers\n * it creates.\n */\nexport class BaseContainerRuntimeFactory\n extends RuntimeFactoryHelper\n implements IProvideFluidDataStoreRegistry {\n public get IFluidDataStoreRegistry() { return this.registry; }\n private readonly registry: IFluidDataStoreRegistry;\n\n /**\n * @param registryEntries - The data store registry for containers produced\n * @param serviceRegistry - The service registry for containers produced\n * @param requestHandlers - Request handlers for containers produced\n * @param runtimeOptions - The runtime options passed to the ContainerRuntime when instantiating it\n */\n constructor(\n private readonly registryEntries: NamedFluidDataStoreRegistryEntries,\n private readonly providerEntries: DependencyContainerRegistry = [],\n private readonly requestHandlers: RuntimeRequestHandler[] = [],\n private readonly runtimeOptions?: IContainerRuntimeOptions,\n ) {\n super();\n this.registry = new FluidDataStoreRegistry(registryEntries);\n }\n\n public async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {\n await this.containerInitializingFirstTime(runtime);\n await this.containerHasInitialized(runtime);\n }\n\n public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {\n await this.containerHasInitialized(runtime);\n }\n\n public async preInitialize(\n context: IContainerContext,\n existing: boolean,\n ): Promise<ContainerRuntime> {\n const scope: FluidObject<IProvideFluidDependencySynthesizer> = context.scope;\n const parentDependencyContainer = scope.IFluidDependencySynthesizer;\n const dc = new DependencyContainer(parentDependencyContainer);\n for (const entry of Array.from(this.providerEntries)) {\n dc.register(entry.type, entry.provider);\n }\n scope.IFluidDependencySynthesizer = dc;\n\n const runtime: ContainerRuntime = await ContainerRuntime.load(\n context,\n this.registryEntries,\n buildRuntimeRequestHandler(\n ...this.requestHandlers,\n innerRequestHandler),\n this.runtimeOptions,\n scope,\n existing,\n );\n\n // we register the runtime so developers of providers can use it in the factory pattern.\n dc.register(IContainerRuntime, runtime);\n\n return runtime;\n }\n\n /**\n * Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container\n * is created. This likely includes creating any initial data stores that are expected to be there at the outset.\n * @param runtime - The container runtime for the container being initialized\n */\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) { }\n\n /**\n * Subclasses may override containerHasInitialized to perform any steps after the container has initialized.\n * This likely includes loading any data stores that are expected to be there at the outset.\n * @param runtime - The container runtime for the container being initialized\n */\n protected async containerHasInitialized(runtime: IContainerRuntime) { }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerServices.js","sourceRoot":"","sources":["../../src/container-services/containerServices.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAEH,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,+BAA+B,CAAC;AAEvC,iCAAiC;AACjC,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"containerServices.js","sourceRoot":"","sources":["../../src/container-services/container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oB,EAAE;YAC/C,yFAAyF;YACzF,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,4DAA4D;YAC5D,OAAO,mBAAmB,CAAC,GAAG,EAAE,+CAA+C,EAAE,OAAO,CAAC,CAAC;SAC7F;QAED,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,EAAE;YACV,gDAAgD;YAChD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;SACrC;QAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QAC/C,IAAI,MAAM,EAAE;YACR,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SACrC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;YACpB,qFAAqF;YACrF,OAAO,mBAAmB,CAAC,GAAG,EAAE,0DAA0D,EAAE,OAAO,CAAC,CAAC;SACxG;QAED,4CAA4C;QAC5C,OAAO;YACH,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,OAAO;SACjB,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResponse, IFluidObject, IFluidRouter, IRequest, FluidObject } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport {\n RequestParser,\n create404Response,\n createResponseError,\n} from \"@fluidframework/runtime-utils\";\n\n// TODO: should this just be \"s\"?\nexport const serviceRoutePathRoot = \"_services\";\n\nexport type ContainerServiceRegistryEntries = Iterable<[string, (runtime: IContainerRuntime) =>\n Promise<IFluidObject & FluidObject>]>;\n\n/**\n * This class is a simple starter class for building a Container Service. It simply provides routing\n */\nexport abstract class BaseContainerService implements IFluidRouter {\n public get IFluidRouter() { return this; }\n\n constructor(protected readonly runtime: IContainerRuntime) {\n }\n\n public async request(request: IRequest): Promise<IResponse> {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: this,\n };\n }\n}\n\n/**\n * ContainerService Factory that will only create one instance of the service for the Container.\n */\nclass SingletonContainerServiceFactory {\n private service: Promise<FluidObject> | undefined;\n\n public constructor(\n private readonly serviceFn: (runtime: IContainerRuntime) => Promise<FluidObject>,\n ) { }\n\n public async getService(runtime: IContainerRuntime): Promise<IFluidObject & FluidObject> {\n if (!this.service) {\n this.service = this.serviceFn(runtime);\n }\n return this.service;\n }\n}\n\n/**\n * Given a collection of IContainerServices will produce a RequestHandler for them all\n * @param serviceRegistry - Collection of Container Services\n */\nexport const generateContainerServicesRequestHandler =\n (serviceRegistry: ContainerServiceRegistryEntries): RuntimeRequestHandler => {\n const factories: Map<string, SingletonContainerServiceFactory> = new Map();\n new Map(serviceRegistry).forEach((fn, id) => {\n factories.set(id, new SingletonContainerServiceFactory(fn));\n });\n\n return async (request: RequestParser, runtime: IContainerRuntime) => {\n if (request.pathParts[0] !== serviceRoutePathRoot) {\n // If the request is not for a service we return undefined so the next handler can use it\n return undefined;\n }\n\n if (request.pathParts.length < 2) {\n // If there is not service to route to then return a failure\n return createResponseError(400, \"request did not specify a service to route to\", request);\n }\n\n const factory = factories.get(request.pathParts[1]);\n if (!factory) {\n // If we can't find a registry entry then return\n return create404Response(request);\n }\n\n const service = await factory.getService(runtime);\n const router = service.IFluidRouter;\n const subRequest = request.createSubRequest(2);\n if (router) {\n return router.request(subRequest);\n }\n\n if (!request.isLeaf(2)) {\n // If there is not terminating route but a sub-route was requested then we will fail.\n return createResponseError(400, \"request sub-url for service that doesn't support routing\", request);\n }\n\n // Otherwise we will just return the service\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: service,\n };\n };\n };\n"]}
|
|
@@ -11,9 +11,7 @@ import { PureDataObjectFactory } from "./pureDataObjectFactory";
|
|
|
11
11
|
* ensuring relevant shared objects etc are available to the factory.
|
|
12
12
|
*
|
|
13
13
|
* @typeParam TObj - DataObject (concrete type)
|
|
14
|
-
* @typeParam
|
|
15
|
-
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
16
|
-
* @typeParam E - represents events that will be available in the EventForwarder
|
|
14
|
+
* @typeParam I - The input types for the DataObject
|
|
17
15
|
*/
|
|
18
16
|
export class DataObjectFactory extends PureDataObjectFactory {
|
|
19
17
|
constructor(type, ctor, sharedObjects = [], optionalProviders, registryEntries, runtimeFactory = FluidDataStoreRuntime) {
|
|
@@ -30,4 +28,19 @@ export class DataObjectFactory extends PureDataObjectFactory {
|
|
|
30
28
|
super(type, ctor, mergedObjects, optionalProviders, registryEntries, runtimeFactory);
|
|
31
29
|
}
|
|
32
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated - This type is meant to ease the transition from the old PureDataObjectFactory type to the new.
|
|
33
|
+
* please migrate to PureDataObjectFactory.
|
|
34
|
+
*
|
|
35
|
+
* DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.
|
|
36
|
+
* It facilitates DataObject's features (such as its shared directory) by
|
|
37
|
+
* ensuring relevant shared objects etc are available to the factory.
|
|
38
|
+
*
|
|
39
|
+
* @typeParam TObj - DataObject (concrete type)
|
|
40
|
+
* @typeParam O - represents a type that will define optional providers that will be injected
|
|
41
|
+
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
42
|
+
* @typeParam E - represents events that will be available in the EventForwarder
|
|
43
|
+
*/
|
|
44
|
+
export class LegacyDataObjectFactory extends DataObjectFactory {
|
|
45
|
+
}
|
|
33
46
|
//# sourceMappingURL=dataObjectFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,SAAS,GACZ,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,SAAS,GACZ,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAIlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,MAAM,OAAO,iBACT,SAAQ,qBAA8B;IAEtC,YACI,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoF,EACpF,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;YAC1E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACpD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,CAAC,EAAE;YACpE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC;SAC9C;QAED,KAAK,CACD,IAAI,EACJ,IAAI,EACJ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,cAAc,CACjB,CAAC;IACN,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACF,MAAM,OAAO,uBACb,SAAQ,iBAA2E;CAAG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n DirectoryFactory,\n MapFactory,\n SharedDirectory,\n SharedMap,\n} from \"@fluidframework/map\";\nimport {\n NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectSymbolProvider } from \"@fluidframework/synthesize\";\nimport { FluidDataStoreRuntime } from \"@fluidframework/datastore\";\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { DataObject, DataObjectTypes, DataObjectType, IDataObjectProps, LegacyDataObject } from \"../data-objects\";\nimport { PureDataObjectFactory } from \"./pureDataObjectFactory\";\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 */\nexport class DataObjectFactory<TObj extends DataObject<I>, I extends DataObjectTypes = DataObjectTypes>\n extends PureDataObjectFactory<TObj, I>\n{\n constructor(\n type: string,\n ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[] = [],\n optionalProviders: FluidObjectSymbolProvider<DataObjectType<I, \"OptionalProviders\">>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n runtimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n const mergedObjects = [...sharedObjects];\n\n if (!sharedObjects.find((factory) => factory.type === DirectoryFactory.Type)) {\n // User did not register for directory\n mergedObjects.push(SharedDirectory.getFactory());\n }\n\n // TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10\n if (!sharedObjects.find((factory) => factory.type === MapFactory.Type)) {\n // User did not register for map\n mergedObjects.push(SharedMap.getFactory());\n }\n\n super(\n type,\n ctor,\n mergedObjects,\n optionalProviders,\n registryEntries,\n runtimeFactory,\n );\n }\n}\n\n/**\n * @deprecated - This type is meant to ease the transition from the old PureDataObjectFactory type to the new.\n * please migrate to PureDataObjectFactory.\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 O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n export class LegacyDataObjectFactory<TObj extends LegacyDataObject<O, S, E>, O, S, E extends IEvent = IEvent>\n extends DataObjectFactory<TObj, {OptionalProviders: O, InitialState: S, Events: E}> {}\n"]}
|
|
@@ -23,7 +23,8 @@ async function createDataObject(ctor, context, sharedObjectRegistry, optionalPro
|
|
|
23
23
|
// becomes globally available. But it's not full initialization - constructor can't
|
|
24
24
|
// access DDSs or other services of runtime as objects are not fully initialized.
|
|
25
25
|
// In order to use object, we need to go through full initialization by calling finishInitialization().
|
|
26
|
-
const
|
|
26
|
+
const scope = context.scope;
|
|
27
|
+
const dependencyContainer = new DependencyContainer(scope.IFluidDependencySynthesizer);
|
|
27
28
|
const providers = dependencyContainer.synthesize(optionalProviders, {});
|
|
28
29
|
const instance = new ctor({ runtime, context, providers, initProps });
|
|
29
30
|
// if it's a newly created object, we need to wait for it to finish initialization
|
|
@@ -46,9 +47,7 @@ async function createDataObject(ctor, context, sharedObjectRegistry, optionalPro
|
|
|
46
47
|
* another base data store factory.
|
|
47
48
|
*
|
|
48
49
|
* @typeParam TObj - DataObject (concrete type)
|
|
49
|
-
* @typeParam
|
|
50
|
-
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
51
|
-
* @typeParam E - represents events that will be available in the EventForwarder
|
|
50
|
+
* @typeParam I - The input types for the DataObject
|
|
52
51
|
*/
|
|
53
52
|
export class PureDataObjectFactory {
|
|
54
53
|
constructor(type, ctor, sharedObjects, optionalProviders, registryEntries, runtimeClass = FluidDataStoreRuntime) {
|
|
@@ -151,4 +150,19 @@ export class PureDataObjectFactory {
|
|
|
151
150
|
return instance;
|
|
152
151
|
}
|
|
153
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated - This type is meant to ease the transition from the old PureDataObjectFactory type to the new.
|
|
155
|
+
* please migrate to PureDataObjectFactory.
|
|
156
|
+
*
|
|
157
|
+
* PureDataObjectFactory is a barebones IFluidDataStoreFactory for use with PureDataObject.
|
|
158
|
+
* Consumers should typically use DataObjectFactory instead unless creating
|
|
159
|
+
* another base data store factory.
|
|
160
|
+
*
|
|
161
|
+
* @typeParam TObj - DataObject (concrete type)
|
|
162
|
+
* @typeParam O - represents a type that will define optional providers that will be injected
|
|
163
|
+
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
164
|
+
* @typeParam E - represents events that will be available in the EventForwarder
|
|
165
|
+
*/
|
|
166
|
+
export class LegacyPureDataObjectFactory extends PureDataObjectFactory {
|
|
167
|
+
}
|
|
154
168
|
//# sourceMappingURL=pureDataObjectFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,qBAAqB,EAErB,mBAAmB,GACrB,MAAM,2BAA2B,CAAC;AAEpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAa3E,OAAO,EAEH,mBAAmB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAEH,cAAc,GACjB,MAAM,iBAAiB,CAAC;AAWzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAAiD,EACjD,OAA+B,EAC/B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C,CAAC;QAElB,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IFluidRouter } from \"@fluidframework/core-interfaces\";\nimport {\n FluidDataStoreRuntime,\n ISharedObjectRegistry,\n mixinRequestHandler,\n } from \"@fluidframework/datastore\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n IFluidDataStoreContext,\n IContainerRuntimeBase,\n IFluidDataStoreFactory,\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n NamedFluidDataStoreRegistryEntry,\n IFluidDataStoreContextDetached,\n} from \"@fluidframework/runtime-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n FluidObjectSymbolProvider,\n DependencyContainer,\n} from \"@fluidframework/synthesize\";\n\nimport {\n IDataObjectProps,\n PureDataObject,\n} from \"../data-objects\";\n\n/*\n * Useful interface in places where it's useful to do type erasure for PureDataObject generic\n */\nexport interface IRootDataObjectFactory extends IFluidDataStoreFactory {\n createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime): Promise<IFluidRouter>;\n}\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n*/\nasync function createDataObject<TObj extends PureDataObject<O, S, E>, O, S, E extends IEvent = IEvent>(\n ctor: new (props: IDataObjectProps<O, S>) => TObj,\n context: IFluidDataStoreContext,\n sharedObjectRegistry: ISharedObjectRegistry,\n optionalProviders: FluidObjectSymbolProvider<O>,\n runtimeClassArg: typeof FluidDataStoreRuntime,\n existing: boolean,\n initProps?: S)\n{\n // base\n let runtimeClass = runtimeClassArg;\n\n // request mixin in\n runtimeClass = mixinRequestHandler(\n async (request: IRequest, runtimeArg: FluidDataStoreRuntime) =>\n (await PureDataObject.getDataObject(runtimeArg)).request(request),\n runtimeClass);\n\n // Create a new runtime for our data store\n // The runtime is what Fluid uses to create DDS' and route to your data store\n const runtime = new runtimeClass(\n context,\n sharedObjectRegistry,\n existing,\n );\n\n // Create object right away.\n // This allows object to register various callbacks with runtime before runtime\n // becomes globally available. But it's not full initialization - constructor can't\n // access DDSs or other services of runtime as objects are not fully initialized.\n // In order to use object, we need to go through full initialization by calling finishInitialization().\n const dependencyContainer = new DependencyContainer(context.scope.IFluidDependencySynthesizer);\n const providers = dependencyContainer.synthesize<O>(optionalProviders, {});\n const instance = new ctor({ runtime, context, providers, initProps });\n\n // if it's a newly created object, we need to wait for it to finish initialization\n // as that results in creation of DDSs, before it gets attached, providing atomic\n // guarantee of creation.\n // WARNING: we can't do the same (yet) for already existing PureDataObject!\n // This will result in deadlock, as it tries to resolve internal handles, but any\n // handle resolution goes through root (container runtime), which can't route it back\n // to this data store, as it's still not initialized and not known to container runtime yet.\n // In the future, we should address it by using relative paths for handles and be able to resolve\n // local DDSs while data store is not fully initialized.\n if (!existing) {\n await instance.finishInitialization(existing);\n }\n\n return { 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 O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\nexport class PureDataObjectFactory<TObj extends PureDataObject<O, S, E>, O, S, E extends IEvent = IEvent>\n implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>, IRootDataObjectFactory\n{\n private readonly sharedObjectRegistry: ISharedObjectRegistry;\n private readonly registry: IFluidDataStoreRegistry | undefined;\n\n constructor(\n public readonly type: string,\n private readonly ctor: new (props: IDataObjectProps<O, S>) => TObj,\n sharedObjects: readonly IChannelFactory[],\n private readonly optionalProviders: FluidObjectSymbolProvider<O>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n private readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n if (this.type === \"\") {\n throw new Error(\"undefined type member\");\n }\n if (registryEntries !== undefined) {\n this.registry = new FluidDataStoreRegistry(registryEntries);\n }\n this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n }\n\n public get IFluidDataStoreFactory() { return this; }\n\n public get IFluidDataStoreRegistry() {\n return this.registry;\n }\n\n /**\n * Convenience helper to get the data store's/factory's data store registry entry.\n * The return type hides the factory's generics, easing grouping of registry\n * entries that differ only in this way into the same array.\n * @returns The NamedFluidDataStoreRegistryEntry\n */\n public get registryEntry(): NamedFluidDataStoreRegistryEntry {\n return [this.type, Promise.resolve(this)];\n }\n\n /**\n * This is where we do data store setup.\n *\n * @param context - data store context used to load a data store runtime\n */\n public async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n const { runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n existing);\n\n return runtime;\n }\n\n /**\n * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n * In other words, registry of context passed in has to contain this factory, with the name that matches\n * this factory's type.\n * It is intended to be used by data store objects that create sub-objects.\n * @param context - The context being used to create the runtime\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created data store.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createChildInstance(\n parentContext: IFluidDataStoreContext,\n initialState?: S,\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n parentContext.containerRuntime,\n [...parentContext.packagePath, this.type],\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n * In other words, registry of context passed in has to have this factory.\n * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n * @param context - The component context being used to create the object\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createPeerInstance(\n peerContext: IFluidDataStoreContext,\n initialState?: S,\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n peerContext.containerRuntime,\n peerContext.packagePath,\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createInstance(\n runtime: IContainerRuntimeBase,\n initialState?: S,\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n runtime,\n [this.type],\n initialState);\n }\n\n /**\n * Creates a new root instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime,\n initialState?: S,\n ): Promise<TObj> {\n const context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createNonRootInstanceCore(\n containerRuntime: IContainerRuntimeBase,\n packagePath: Readonly<string[]>,\n initialState?: S,\n ): Promise<TObj> {\n const context = containerRuntime.createDetachedDataStore(packagePath);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createInstanceCore(\n context: IFluidDataStoreContextDetached,\n initialState?: S,\n ): Promise<TObj> {\n const { instance, runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n false, // existing\n initialState);\n\n await context.attachRuntime(this, runtime);\n\n return instance;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,qBAAqB,EAErB,mBAAmB,GACrB,MAAM,2BAA2B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAa3E,OAAO,EAEH,mBAAmB,GAEtB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAEH,cAAc,GAIjB,MAAM,iBAAiB,CAAC;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoF,EACpF,eAA6C,EAC7C,QAAiB,EACjB,SAA6C;IAE7C,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,mBAAmB,CAC9B,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE,CAC3D,CAAC,MAAM,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EACjE,YAAY,CAAC,CAAC;IAEtB,0CAA0C;IAC1C,6EAA6E;IAC7E,MAAM,OAAO,GAAG,IAAI,YAAY,CAC5B,OAAO,EACP,oBAAoB,EACpB,QAAQ,CACX,CAAC;IAEF,4BAA4B;IAC5B,+EAA+E;IAC/E,mFAAmF;IACnF,iFAAiF;IACjF,uGAAuG;IACvG,MAAM,KAAK,GAA6C,OAAO,CAAC,KAAK,CAAC;IACtE,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACvF,MAA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CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAES,KAAK,CAAC,yBAAyB,CACrC,gBAAuC,EACvC,WAA+B,EAC/B,YAAgD;QAEhD,MAAM,OAAO,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAES,KAAK,CAAC,kBAAkB,CAC9B,OAAuC,EACvC,YAAgD;QAEhD,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,gBAAgB,CAChD,IAAI,CAAC,IAAI,EACT,OAAO,EACP,IAAI,CAAC,oBAAoB,EACzB,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,YAAY,EACjB,KAAK,EAAE,WAAW;QAClB,YAAY,CAAC,CAAC;QAElB,MAAM,OAAO,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE3C,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAED;;;;;;;;;;;;GAYG;AACF,MAAM,OAAO,2BACb,SAAQ,qBAA8E;CAAG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IFluidRouter, FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n FluidDataStoreRuntime,\n ISharedObjectRegistry,\n mixinRequestHandler,\n } from \"@fluidframework/datastore\";\nimport { FluidDataStoreRegistry } from \"@fluidframework/container-runtime\";\nimport {\n IFluidDataStoreContext,\n IContainerRuntimeBase,\n IFluidDataStoreFactory,\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n NamedFluidDataStoreRegistryEntry,\n IFluidDataStoreContextDetached,\n} from \"@fluidframework/runtime-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n FluidObjectSymbolProvider,\n DependencyContainer,\n IFluidDependencySynthesizer,\n} from \"@fluidframework/synthesize\";\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport {\n IDataObjectProps,\n PureDataObject,\n DataObjectType,\n DataObjectTypes,\n LegacyPureDataObject,\n} from \"../data-objects\";\n/*\n * Useful interface in places where it's useful to do type erasure for PureDataObject generic\n */\nexport interface IRootDataObjectFactory extends IFluidDataStoreFactory {\n createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime): Promise<IFluidRouter>;\n}\n\n/**\n * Proxy over PureDataObject\n * Does delayed creation & initialization of PureDataObject\n*/\nasync function createDataObject<TObj extends PureDataObject,I extends DataObjectTypes = DataObjectTypes>(\n ctor: new (props: IDataObjectProps<I>) => TObj,\n context: IFluidDataStoreContext,\n sharedObjectRegistry: ISharedObjectRegistry,\n optionalProviders: FluidObjectSymbolProvider<DataObjectType<I, \"OptionalProviders\">>,\n runtimeClassArg: typeof FluidDataStoreRuntime,\n existing: boolean,\n initProps?: DataObjectType<I, \"InitialState\">)\n{\n // base\n let runtimeClass = runtimeClassArg;\n\n // request mixin in\n runtimeClass = mixinRequestHandler(\n async (request: IRequest, runtimeArg: FluidDataStoreRuntime) =>\n (await PureDataObject.getDataObject(runtimeArg)).request(request),\n runtimeClass);\n\n // Create a new runtime for our data store\n // The runtime is what Fluid uses to create DDS' and route to your data store\n const runtime = new runtimeClass(\n context,\n sharedObjectRegistry,\n existing,\n );\n\n // Create object right away.\n // This allows object to register various callbacks with runtime before runtime\n // becomes globally available. But it's not full initialization - constructor can't\n // access DDSs or other services of runtime as objects are not fully initialized.\n // In order to use object, we need to go through full initialization by calling finishInitialization().\n const scope: FluidObject<IFluidDependencySynthesizer> = context.scope;\n const dependencyContainer = new DependencyContainer(scope.IFluidDependencySynthesizer);\n const providers = dependencyContainer.synthesize<DataObjectType<I, \"OptionalProviders\">>(optionalProviders, {});\n const instance = new ctor({ runtime, context, providers, initProps });\n\n // if it's a newly created object, we need to wait for it to finish initialization\n // as that results in creation of DDSs, before it gets attached, providing atomic\n // guarantee of creation.\n // WARNING: we can't do the same (yet) for already existing PureDataObject!\n // This will result in deadlock, as it tries to resolve internal handles, but any\n // handle resolution goes through root (container runtime), which can't route it back\n // to this data store, as it's still not initialized and not known to container runtime yet.\n // In the future, we should address it by using relative paths for handles and be able to resolve\n // local DDSs while data store is not fully initialized.\n if (!existing) {\n await instance.finishInitialization(existing);\n }\n\n return { 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 */\nexport class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends DataObjectTypes = DataObjectTypes>\n implements IFluidDataStoreFactory, Partial<IProvideFluidDataStoreRegistry>, IRootDataObjectFactory\n{\n private readonly sharedObjectRegistry: ISharedObjectRegistry;\n private readonly registry: IFluidDataStoreRegistry | undefined;\n\n constructor(\n public readonly type: string,\n private readonly ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[],\n private readonly optionalProviders: FluidObjectSymbolProvider<DataObjectType<I, \"OptionalProviders\">>,\n registryEntries?: NamedFluidDataStoreRegistryEntries,\n private readonly runtimeClass: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,\n ) {\n if (this.type === \"\") {\n throw new Error(\"undefined type member\");\n }\n if (registryEntries !== undefined) {\n this.registry = new FluidDataStoreRegistry(registryEntries);\n }\n this.sharedObjectRegistry = new Map(sharedObjects.map((ext) => [ext.type, ext]));\n }\n\n public get IFluidDataStoreFactory() { return this; }\n\n public get IFluidDataStoreRegistry() {\n return this.registry;\n }\n\n /**\n * Convenience helper to get the data store's/factory's data store registry entry.\n * The return type hides the factory's generics, easing grouping of registry\n * entries that differ only in this way into the same array.\n * @returns The NamedFluidDataStoreRegistryEntry\n */\n public get registryEntry(): NamedFluidDataStoreRegistryEntry {\n return [this.type, Promise.resolve(this)];\n }\n\n /**\n * This is where we do data store setup.\n *\n * @param context - data store context used to load a data store runtime\n */\n public async instantiateDataStore(context: IFluidDataStoreContext, existing: boolean) {\n const { runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n existing);\n\n return runtime;\n }\n\n /**\n * Creates a new instance of the object. Uses parent context's registry to build package path to this factory.\n * In other words, registry of context passed in has to contain this factory, with the name that matches\n * this factory's type.\n * It is intended to be used by data store objects that create sub-objects.\n * @param context - The context being used to create the runtime\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created data store.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createChildInstance(\n parentContext: IFluidDataStoreContext,\n initialState?: DataObjectType<I, \"InitialState\">,\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n parentContext.containerRuntime,\n [...parentContext.packagePath, this.type],\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses peer context's registry and its package path to identify this factory.\n * In other words, registry of context passed in has to have this factory.\n * Intended to be used by data store objects that need to create peers (similar) instances of existing objects.\n * @param context - The component context being used to create the object\n * (the created object will have its own new context created as well)\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createPeerInstance(\n peerContext: IFluidDataStoreContext,\n initialState?: DataObjectType<I, \"InitialState\">,\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n peerContext.containerRuntime,\n peerContext.packagePath,\n initialState);\n }\n\n /**\n * Creates a new instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createInstance(\n runtime: IContainerRuntimeBase,\n initialState?: DataObjectType<I, \"InitialState\">,\n ): Promise<TObj> {\n return this.createNonRootInstanceCore(\n runtime,\n [this.type],\n initialState);\n }\n\n /**\n * Creates a new root instance of the object. Uses container's registry to find this factory.\n * It's expected that only container owners would use this functionality, as only such developers\n * have knowledge of entries in container registry.\n * The name in this registry for such record should match type of this factory.\n * @param runtime - container runtime. It's registry is used to create an object.\n * @param initialState - The initial state to provide to the created component.\n * @returns an object created by this factory. Data store and objects created are not attached to container.\n * They get attached only when a handle to one of them is attached to already attached objects.\n */\n public async createRootInstance(\n rootDataStoreId: string,\n runtime: IContainerRuntime,\n initialState?: DataObjectType<I, \"InitialState\">,\n ): Promise<TObj> {\n const context = runtime.createDetachedRootDataStore([this.type], rootDataStoreId);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createNonRootInstanceCore(\n containerRuntime: IContainerRuntimeBase,\n packagePath: Readonly<string[]>,\n initialState?: DataObjectType<I, \"InitialState\">,\n ): Promise<TObj> {\n const context = containerRuntime.createDetachedDataStore(packagePath);\n return this.createInstanceCore(context, initialState);\n }\n\n protected async createInstanceCore(\n context: IFluidDataStoreContextDetached,\n initialState?: DataObjectType<I, \"InitialState\">,\n ): Promise<TObj> {\n const { instance, runtime } = await createDataObject(\n this.ctor,\n context,\n this.sharedObjectRegistry,\n this.optionalProviders,\n this.runtimeClass,\n false, // existing\n initialState);\n\n await context.attachRuntime(this, runtime);\n\n return instance;\n }\n}\n\n/**\n * @deprecated - This type is meant to ease the transition from the old PureDataObjectFactory type to the new.\n * please migrate to PureDataObjectFactory.\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 O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n export class LegacyPureDataObjectFactory<TObj extends LegacyPureDataObject<O, S, E>, O, S, E extends IEvent = IEvent>\n extends PureDataObjectFactory<TObj,{OptionalProviders: O, InitialState: S, Events: E}> {}\n"]}
|
|
@@ -13,11 +13,8 @@ import { PureDataObject } from "./pureDataObject";
|
|
|
13
13
|
* and registering channels with the runtime any new DDS that is set on the root
|
|
14
14
|
* will automatically be registered.
|
|
15
15
|
*
|
|
16
|
-
* @typeParam
|
|
17
|
-
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
18
|
-
* @typeParam E - represents events that will be available in the EventForwarder
|
|
16
|
+
* @typeParam I - The optional input types used to strongly type the data object
|
|
19
17
|
*/
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
21
18
|
export class DataObject extends PureDataObject {
|
|
22
19
|
constructor() {
|
|
23
20
|
super(...arguments);
|
|
@@ -77,4 +74,22 @@ export class DataObject extends PureDataObject {
|
|
|
77
74
|
return `${item} must be initialized before being accessed.`;
|
|
78
75
|
}
|
|
79
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated - This type is meant to ease the transition from the old DataObject type to the new.
|
|
79
|
+
* please migrate to DataObject.
|
|
80
|
+
*
|
|
81
|
+
* DataObject is a base data store that is primed with a root directory. It
|
|
82
|
+
* ensures that it is created and ready before you can access it.
|
|
83
|
+
*
|
|
84
|
+
* Having a single root directory allows for easier development. Instead of creating
|
|
85
|
+
* and registering channels with the runtime any new DDS that is set on the root
|
|
86
|
+
* will automatically be registered.
|
|
87
|
+
*
|
|
88
|
+
* @typeParam O - represents a type that will define optional providers that will be injected
|
|
89
|
+
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
90
|
+
* @typeParam E - represents events that will be available in the EventForwarder
|
|
91
|
+
*/
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
93
|
+
export class LegacyDataObject extends DataObject {
|
|
94
|
+
}
|
|
80
95
|
//# sourceMappingURL=dataObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAoB,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;;GASG;AACH,MAAM,OAAgB,UAAwD,SAAQ,cAAiB;IAAvG;;QAGqB,oBAAe,GAAG,MAAM,CAAC;IA2D9C,CAAC;IAzDU,KAAK,CAAC,OAAO,CAAC,OAAiB;QAClC,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,MAAM,KAAK,UAAU,EAAE;YACvB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAS,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACvE,IAAI,KAAK,KAAK,SAAS,EAAE;gBACrB,OAAO,iBAAiB,CAAC,aAAa,CAAC,CAAC;aAC3C;YACD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;SAC3D;aAAM;YACH,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;SACvC;IACL,CAAC;IAED;;;OAGG;IACH,IAAc,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACpB,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;SAC7D;QAED,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QAC7C,IAAI,CAAC,QAAQ,EAAE;YACX,+EAA+E;YAC/E,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;YAC/E,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC;SACrC;aAAM;YACH,oGAAoG;YACpG,IAAI,CAAC,YAAY,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAqB,CAAC;YAE5F,oGAAoG;YACpG,gGAAgG;YAChG,qGAAqG;YACrG,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE;gBACvD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC;oBACrB,QAAQ,EAAE,SAAS;oBACnB,SAAS,EAAE,eAAe;oBAC1B,OAAO,EAAE,6EAA6E;iBACzF,CAAC,CAAC;aACN;SACJ;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAES,2BAA2B,CAAC,IAAY;QAC9C,OAAO,GAAG,IAAI,6CAA6C,CAAC;IAChE,CAAC;CACJ;AAED;;;;;;;;;;;;;;GAcG;AACH,wDAAwD;AACxD,MAAM,OAAgB,gBAClB,SAAQ,UAA8D;CAErE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport {\n IFluidObject,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { ISharedDirectory, MapFactory, SharedDirectory } from \"@fluidframework/map\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\nimport { PureDataObject } from \"./pureDataObject\";\nimport { DataObjectTypes } from \"./types\";\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 */\nexport abstract class DataObject<I extends DataObjectTypes = DataObjectTypes> extends PureDataObject<I>\n{\n private internalRoot: ISharedDirectory | undefined;\n private readonly rootDirectoryId = \"root\";\n\n public async request(request: IRequest): Promise<IResponse> {\n const requestParser = RequestParser.create(request);\n const itemId = requestParser.pathParts[0];\n if (itemId === \"bigBlobs\") {\n const value = this.root.get<string>(requestParser.pathParts.join(\"/\"));\n if (value === undefined) {\n return create404Response(requestParser);\n }\n return { mimeType: \"fluid/object\", status: 200, value };\n } else {\n return super.request(requestParser);\n }\n }\n\n /**\n * The root directory will either be ready or will return an error. If an error is thrown\n * the root has not been correctly created/set.\n */\n protected get root(): ISharedDirectory {\n if (!this.internalRoot) {\n throw new Error(this.getUninitializedErrorString(`root`));\n }\n\n return this.internalRoot;\n }\n\n /**\n * Initializes internal objects and calls initialization overrides.\n * Caller is responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n if (!existing) {\n // Create a root directory and register it before calling initializingFirstTime\n this.internalRoot = SharedDirectory.create(this.runtime, this.rootDirectoryId);\n this.internalRoot.bindToContext();\n } else {\n // data store has a root directory so we just need to set it before calling initializingFromExisting\n this.internalRoot = await this.runtime.getChannel(this.rootDirectoryId) as ISharedDirectory;\n\n // This will actually be an ISharedMap if the channel was previously created by the older version of\n // DataObject which used a SharedMap. Since SharedMap and SharedDirectory are compatible unless\n // SharedDirectory-only commands are used on SharedMap, this will mostly just work for compatibility.\n if (this.internalRoot.attributes.type === MapFactory.Type) {\n this.runtime.logger.send({\n category: \"generic\",\n eventName: \"MapDataObject\",\n message: \"Legacy document, SharedMap is masquerading as SharedDirectory in DataObject\",\n });\n }\n }\n\n await super.initializeInternal(existing);\n }\n\n protected getUninitializedErrorString(item: string) {\n return `${item} must be initialized before being accessed.`;\n }\n}\n\n/**\n * @deprecated - This type is meant to ease the transition from the old DataObject type to the new.\n * please migrate to DataObject.\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 O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport abstract class LegacyDataObject<O extends IFluidObject = object, S = undefined, E extends IEvent = IEvent>\n extends DataObject<{OptionalProviders: O, InitialState: S, Events: E}> {\n\n }\n"]}
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { DataObject } from "./dataObject";
|
|
6
|
-
export { PureDataObject, } from "./pureDataObject";
|
|
5
|
+
export { DataObject, LegacyDataObject } from "./dataObject";
|
|
6
|
+
export { PureDataObject, LegacyPureDataObject } from "./pureDataObject";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-objects/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObject, LegacyDataObject } from \"./dataObject\";\nexport { PureDataObject, LegacyPureDataObject } from \"./pureDataObject\";\nexport { DataObjectTypes, DataObjectType, IDataObjectProps } from \"./types\";\n"]}
|
|
@@ -12,11 +12,8 @@ import { defaultFluidObjectRequestHandler } from "../request-handlers";
|
|
|
12
12
|
* You probably don't want to inherit from this data store directly unless
|
|
13
13
|
* you are creating another base data store class
|
|
14
14
|
*
|
|
15
|
-
* @typeParam
|
|
16
|
-
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
17
|
-
* @typeParam E - represents events that will be available in the EventForwarder
|
|
15
|
+
* @typeParam I - The optional input types used to strongly type the data object
|
|
18
16
|
*/
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
17
|
export class PureDataObject extends EventForwarder {
|
|
21
18
|
constructor(props) {
|
|
22
19
|
super();
|
|
@@ -165,4 +162,19 @@ export class PureDataObject extends EventForwarder {
|
|
|
165
162
|
super.dispose();
|
|
166
163
|
}
|
|
167
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated - This type is meant to ease the transition from the old PureDataObject type to the new.
|
|
167
|
+
* please migrate to PureDataObject.
|
|
168
|
+
*
|
|
169
|
+
* This is a bare-bones base class that does basic setup and enables for factory on an initialize call.
|
|
170
|
+
* You probably don't want to inherit from this data store directly unless
|
|
171
|
+
* you are creating another base data store class
|
|
172
|
+
*
|
|
173
|
+
* @typeParam O - represents a type that will define optional providers that will be injected
|
|
174
|
+
* @typeParam S - the initial state type that the produced data object may take during creation
|
|
175
|
+
* @typeParam E - represents events that will be available in the EventForwarder
|
|
176
|
+
*/
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
178
|
+
export class LegacyPureDataObject extends PureDataObject {
|
|
179
|
+
}
|
|
168
180
|
//# sourceMappingURL=pureDataObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAWvE;;;;;;;;GAQG;AACH,wDAAwD;AACxD,MAAM,OAAgB,cAClB,SAAQ,cAAiB;IAgDzB,YAAmB,KAA6B;QAC5C,KAAK,EAAE,CAAC;QA9CJ,cAAS,GAAG,KAAK,CAAC;QA+CtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QAEjC,MAAM,CAAE,IAAI,CAAC,OAAe,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7G,IAAI,CAAC,OAAe,CAAC,WAAW,GAAG,IAAI,CAAC;QAEzC,8GAA8G;QAC9G,4GAA4G;QAC5G,yBAAyB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEvF,2BAA2B;QAC3B,IAAI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AC,yBAAyB,CAAC,GAAG,CAAC,CAAM,CAAC;SACnF;IACL,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,yBAAyB,CAAyB,EAAU;QACxE,OAAO,mBAAmB,CAAI,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACjF,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAyB,EAAU;QACzD,OAAO,mBAAmB,CAAI,IAAI,oBAAoB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACzG,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAoB,CAAC;IAElD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAS,IAAmB,CAAC;IAEnE;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAoB,CAAC;IAE7D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidObject,\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n} from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider, FluidObjectKey } from \"@fluidframework/synthesize\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport interface IDataObjectProps<O = object, S = undefined> {\n readonly runtime: IFluidDataStoreRuntime;\n readonly context: IFluidDataStoreContext;\n // eslint-disable-next-line @typescript-eslint/ban-types\n readonly providers: AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<object>>;\n readonly initProps?: S;\n}\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport abstract class PureDataObject<O extends IFluidObject = object, S = undefined, E extends IEvent = IEvent>\n extends EventForwarder<E>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle, IFluidObject {\n private readonly innerHandle: IFluidHandle<this>;\n private _disposed = false;\n\n /**\n * This is your FluidDataStoreRuntime object\n */\n protected readonly runtime: IFluidDataStoreRuntime;\n\n /**\n * This context is used to talk up to the ContainerRuntime\n */\n protected readonly context: IFluidDataStoreContext;\n\n /**\n * Providers are IFluidObject keyed objects that provide back\n * a promise to the corresponding IFluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set IFluidObject interfaces in the generic O type for your data store\n */\n // eslint-disable-next-line @typescript-eslint/ban-types\n protected readonly providers: AsyncFluidObjectProvider<FluidObjectKey<O>, FluidObjectKey<object>>;\n\n protected initProps?: S;\n\n protected initializeP: Promise<void> | undefined;\n\n public get disposed() { return this._disposed; }\n\n public get id() { return this.runtime.id; }\n public get IFluidRouter() { return this; }\n public get IFluidLoadable() { return this; }\n public get IFluidHandle() { return this.innerHandle; }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = (runtime as any)._dataObject as PureDataObject;\n assert(obj !== undefined, 0x0bc /* \"Runtime has no DataObject!\" */);\n await obj.finishInitialization(true);\n return obj;\n }\n\n public constructor(props: IDataObjectProps<O, S>) {\n super();\n this.runtime = props.runtime;\n this.context = props.context;\n this.providers = props.providers;\n this.initProps = props.initProps;\n\n assert((this.runtime as any)._dataObject === undefined, 0x0bd /* \"Object runtime already has DataObject!\" */);\n (this.runtime as any)._dataObject = this;\n\n // Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the\n // same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the\n // routeContext is empty.\n this.innerHandle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\n // Container event handlers\n this.runtime.once(\"dispose\", () => {\n this._disposed = true;\n this.dispose();\n });\n }\n\n // #region IFluidRouter\n\n /**\n * Return this object if someone requests it directly\n * We will return this object in two scenarios:\n * 1. the request url is a \"/\"\n * 2. the request url is empty\n */\n public async request(req: IRequest): Promise<IResponse> {\n return defaultFluidObjectRequestHandler(this, req);\n }\n\n // #endregion IFluidRouter\n\n // #region IFluidLoadable\n\n // #endregion IFluidLoadable\n\n /**\n * Call this API to ensure PureDataObject is fully initialized\n * initialization happens on demand, only on as-needed bases.\n * In most cases you should allow factory/object to decide when to finish initialization.\n * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n * and need fully initialized object, then you can call this API to ensure object is fully initialized.\n */\n public async finishInitialization(existing: boolean): Promise<void> {\n if (this.initializeP !== undefined) {\n return this.initializeP;\n }\n this.initializeP = this.initializeInternal(existing);\n return this.initializeP;\n }\n\n /**\n * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n * generally not be done.\n *\n * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n * responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n await this.preInitialize();\n if (existing) {\n assert(this.initProps === undefined,\n 0x0be /* \"Trying to initialize from existing while initProps is set!\" */);\n await this.initializingFromExisting();\n } else {\n await this.initializingFirstTime(this.context.createProps as S ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retreive Fluid object using the handle get or the older requestFluidObject_UNSAFE call to fetch by ID\n *\n * @param key - key that object (handle/id) is stored with in the directory\n * @param directory - directory containing the object\n * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n * define custom types/getters for object retrieval\n */\n public async getFluidObjectFromDirectory<T extends IFluidObject & IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => string | IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleOrId = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n if (typeof handleOrId === \"string\") {\n // For backwards compatibility with older stored IDs\n // We update the storage with the handle so that this code path is less and less trafficked\n const fluidObject = await this.requestFluidObject_UNSAFE<T>(handleOrId);\n if (fluidObject.IFluidLoadable && fluidObject.handle) {\n directory.set(key, fluidObject.handle);\n }\n return fluidObject;\n } else {\n const handle = handleOrId?.IFluidHandle;\n return await (handle ? handle.get() : this.requestFluidObject_UNSAFE(key)) as T;\n }\n }\n\n /**\n * @deprecated\n * Gets the data store of a given id. Will follow the pattern of the container for waiting.\n * @param id - data store id\n */\n protected async requestFluidObject_UNSAFE<T extends IFluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends IFluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Called every time the data store is initialized, before initializingFirstTime or\n * initializingFromExisting is called.\n */\n protected async preInitialize(): Promise<void> { }\n\n /**\n * Called the first time the data store is initialized (new creations with a new\n * data store runtime)\n *\n * @param props - Optional props to be passed in on create\n */\n protected async initializingFirstTime(props?: S): Promise<void> { }\n\n /**\n * Called every time but the first time the data store is initialized (creations\n * with an existing data store runtime)\n */\n protected async initializingFromExisting(): Promise<void> { }\n\n /**\n * Called every time the data store is initialized after create or existing.\n */\n protected async hasInitialized(): Promise<void> { }\n\n /**\n * Called when the host container closes and disposes itself\n */\n public dispose(): void {\n super.dispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAGvE;;;;;;GAMG;AACH,MAAM,OAAgB,cAClB,SAAQ,cAA2C;IAiDnD,YAAmB,KAA0B;QACzC,KAAK,EAAE,CAAC;QA/CJ,cAAS,GAAG,KAAK,CAAC;QAgDtB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QAEjC,MAAM,CAAE,IAAI,CAAC,OAAe,CAAC,WAAW,KAAK,SAAS,EAAE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QAC7G,IAAI,CAAC,OAAe,CAAC,WAAW,GAAG,IAAI,CAAC;QAEzC,8GAA8G;QAC9G,4GAA4G;QAC5G,yBAAyB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAiB,CAAC,IAAI,EAAE,E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AM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAM,CAAC;SACnF;IACL,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,yBAAyB,CAAyB,EAAU;QACxE,OAAO,mBAAmB,CAAI,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACjF,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,UAAU,CAAuC,EAAU;QACvE,OAAO,mBAAmB,CAAI,IAAI,oBAAoB,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,GAAG,EAAE,CAAC;IACzG,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,aAAa,KAAoB,CAAC;IAElD;;;;;OAKG;IACO,KAAK,CAAC,qBAAqB,CAAC,KAAyC,IAAmB,CAAC;IAEnG;;;OAGG;IACO,KAAK,CAAC,wBAAwB,KAAoB,CAAC;IAE7D;;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAED;;;;;;;;;;;GAWG;AACH,wDAAwD;AACxD,MAAM,OAAgB,oBACtB,SAAQ,cAAkE;CAEzE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IFluidObject,\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider, FluidObjectKey } from \"@fluidframework/synthesize\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, DataObjectType, IDataObjectProps } from \"./types\";\n\n/**\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam I - The optional input types used to strongly type the data object\n */\nexport abstract class PureDataObject<I extends DataObjectTypes = DataObjectTypes>\n extends EventForwarder<DataObjectType<I, \"Events\">>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle, IFluidObject {\n private readonly innerHandle: IFluidHandle<this>;\n private _disposed = false;\n\n /**\n * This is your FluidDataStoreRuntime object\n */\n protected readonly runtime: IFluidDataStoreRuntime;\n\n /**\n * This context is used to talk up to the ContainerRuntime\n */\n protected readonly context: IFluidDataStoreContext;\n\n /**\n * Providers are IFluidObject keyed objects that provide back\n * a promise to the corresponding IFluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set IFluidObject interfaces in the generic O type for your data store\n */\n protected readonly providers:\n // eslint-disable-next-line @typescript-eslint/ban-types\n AsyncFluidObjectProvider<FluidObjectKey<DataObjectType<I, \"OptionalProviders\">>, FluidObjectKey<object>>;\n\n protected initProps?: DataObjectType<I, \"InitialState\">;\n\n protected initializeP: Promise<void> | undefined;\n\n public get disposed() { return this._disposed; }\n\n public get id() { return this.runtime.id; }\n public get IFluidRouter() { return this; }\n public get IFluidLoadable() { return this; }\n public get IFluidHandle() { return this.innerHandle; }\n\n /**\n * Handle to a data store\n */\n public get handle(): IFluidHandle<this> { return this.innerHandle; }\n\n public static async getDataObject(runtime: IFluidDataStoreRuntime) {\n const obj = (runtime as any)._dataObject as PureDataObject;\n assert(obj !== undefined, 0x0bc /* \"Runtime has no DataObject!\" */);\n await obj.finishInitialization(true);\n return obj;\n }\n\n public constructor(props: IDataObjectProps<I>) {\n super();\n this.runtime = props.runtime;\n this.context = props.context;\n this.providers = props.providers;\n this.initProps = props.initProps;\n\n assert((this.runtime as any)._dataObject === undefined, 0x0bd /* \"Object runtime already has DataObject!\" */);\n (this.runtime as any)._dataObject = this;\n\n // Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the\n // same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the\n // routeContext is empty.\n this.innerHandle = new FluidObjectHandle(this, \"\", this.runtime.objectsRoutingContext);\n\n // Container event handlers\n this.runtime.once(\"dispose\", () => {\n this._disposed = true;\n this.dispose();\n });\n }\n\n // #region IFluidRouter\n\n /**\n * Return this object if someone requests it directly\n * We will return this object in two scenarios:\n * 1. the request url is a \"/\"\n * 2. the request url is empty\n */\n public async request(req: IRequest): Promise<IResponse> {\n return defaultFluidObjectRequestHandler(this, req);\n }\n\n // #endregion IFluidRouter\n\n // #region IFluidLoadable\n\n // #endregion IFluidLoadable\n\n /**\n * Call this API to ensure PureDataObject is fully initialized\n * initialization happens on demand, only on as-needed bases.\n * In most cases you should allow factory/object to decide when to finish initialization.\n * But if you are supplying your own implementation of DataStoreRuntime factory and overriding some methods\n * and need fully initialized object, then you can call this API to ensure object is fully initialized.\n */\n public async finishInitialization(existing: boolean): Promise<void> {\n if (this.initializeP !== undefined) {\n return this.initializeP;\n }\n this.initializeP = this.initializeInternal(existing);\n return this.initializeP;\n }\n\n /**\n * Internal initialize implementation. Overwriting this will change the flow of the PureDataObject and should\n * generally not be done.\n *\n * Calls initializingFirstTime, initializingFromExisting, and hasInitialized. Caller is\n * responsible for ensuring this is only invoked once.\n */\n public async initializeInternal(existing: boolean): Promise<void> {\n await this.preInitialize();\n if (existing) {\n assert(this.initProps === undefined,\n 0x0be /* \"Trying to initialize from existing while initProps is set!\" */);\n await this.initializingFromExisting();\n } else {\n await this.initializingFirstTime(\n this.context.createProps as DataObjectType<I, \"InitialState\"> ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retreive Fluid object using the handle get or the older requestFluidObject_UNSAFE call to fetch by ID\n *\n * @param key - key that object (handle/id) is stored with in the directory\n * @param directory - directory containing the object\n * @param getObjectFromDirectory - optional callback for fetching object from the directory, allows users to\n * define custom types/getters for object retrieval\n */\n public async getFluidObjectFromDirectory<T extends IFluidObject & FluidObject & IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => string | IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleOrId = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n if (typeof handleOrId === \"string\") {\n // For backwards compatibility with older stored IDs\n // We update the storage with the handle so that this code path is less and less trafficked\n const fluidObject = await this.requestFluidObject_UNSAFE<T>(handleOrId);\n if (fluidObject.IFluidLoadable && fluidObject.handle) {\n directory.set(key, fluidObject.handle);\n }\n return fluidObject;\n } else {\n const handle = handleOrId?.IFluidHandle;\n return await (handle ? handle.get() : this.requestFluidObject_UNSAFE(key)) as T;\n }\n }\n\n /**\n * @deprecated\n * Gets the data store of a given id. Will follow the pattern of the container for waiting.\n * @param id - data store id\n */\n protected async requestFluidObject_UNSAFE<T extends IFluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends IFluidObject & FluidObject>(id: string): Promise<T> {\n return handleFromLegacyUri<T>(`/${serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();\n }\n\n /**\n * Called every time the data store is initialized, before initializingFirstTime or\n * initializingFromExisting is called.\n */\n protected async preInitialize(): Promise<void> { }\n\n /**\n * Called the first time the data store is initialized (new creations with a new\n * data store runtime)\n *\n * @param props - Optional props to be passed in on create\n */\n protected async initializingFirstTime(props?: DataObjectType<I, \"InitialState\">): Promise<void> { }\n\n /**\n * Called every time but the first time the data store is initialized (creations\n * with an existing data store runtime)\n */\n protected async initializingFromExisting(): Promise<void> { }\n\n /**\n * Called every time the data store is initialized after create or existing.\n */\n protected async hasInitialized(): Promise<void> { }\n\n /**\n * Called when the host container closes and disposes itself\n */\n public dispose(): void {\n super.dispose();\n }\n}\n\n/**\n * @deprecated - This type is meant to ease the transition from the old PureDataObject type to the new.\n * please migrate to PureDataObject.\n *\n * This is a bare-bones base class that does basic setup and enables for factory on an initialize call.\n * You probably don't want to inherit from this data store directly unless\n * you are creating another base data store class\n *\n * @typeParam O - represents a type that will define optional providers that will be injected\n * @typeParam S - the initial state type that the produced data object may take during creation\n * @typeParam E - represents events that will be available in the EventForwarder\n */\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport abstract class LegacyPureDataObject<O extends IFluidObject = object, S = undefined, E extends IEvent = IEvent>\nextends PureDataObject<{OptionalProviders: O, InitialState: S, Events: E}> {\n\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/data-objects/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { AsyncFluidObjectProvider, FluidObjectKey } from \"@fluidframework/synthesize\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IEvent } from \"@fluidframework/common-definitions\";\n\n/**\n * This type is used as the base generic input to DataObject and PureDataObject.\n */\nexport interface DataObjectTypes {\n /**\n * represents a type that will define optional providers that will be injected\n */\n OptionalProviders?: FluidObject;\n /**\n * the initial state type that the produced data object may take during creation\n */\n InitialState?: any;\n /**\n * represents events that will be available in the EventForwarder\n */\n Events?: IEvent;\n}\n\n/**\n * @internal This utility type pulls a specific key's type off the T and returns that,\n * or the default value if TKey is not specified by T\n */\nexport type DataObjectType<T extends DataObjectTypes, P extends keyof DataObjectTypes> =\n T[P] extends Required<DataObjectTypes>[P] ? T[P] : Required<DataObjectTypes>[P];\n\nexport interface IDataObjectProps<I extends DataObjectTypes = DataObjectTypes> {\n readonly runtime: IFluidDataStoreRuntime;\n readonly context: IFluidDataStoreContext;\n readonly providers:\n // eslint-disable-next-line @typescript-eslint/ban-types\n AsyncFluidObjectProvider<FluidObjectKey<DataObjectType<I, \"OptionalProviders\">>, FluidObjectKey<object>>;\n readonly initProps?: DataObjectType<I, \"InitialState\">;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAyB,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACpC,CAAC,kBAA4C,EAAE,QAAiC,EAAE,EAAE;IAChF,MAAM,aAAa,GAAG,0BAA0B,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC9D,OAAO,KAAK,EAAE,OAAsB,EAAE,OAA0B,EAAE,EAAE;;QAChE,MAAM,aAAa,GAAG,OAAA,OAAO,CAAC,OAAO,0CAAE,aAAa,MAAK,IAAI,CAAC;QAC9D,IAAI,UAAU,GAAa,OAAO,CAAC;QACnC,IAAI,aAAa,EAAE;YACf,wDAAwD;YACxD,mDAAmD;YACnD,MAAM,OAAO,qBAAwB,OAAO,CAAC,OAAO,CAAE,CAAC;YACvD,OAAQ,OAAe,CAAC,aAAa,CAAC;YACtC,UAAU,GAAG;gBACT,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,OAAO;aACV,CAAC;SAC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BAC7C,GAAG,EAAE,IAAI,aAAa,GAAG,MAAM,CAAC,KAAK,EAAE;gBACvC,OAAO,EAAE,OAAO,CAAC,OAAO;aAAE,CAAC,CAAC;SACnC;QACD,OAAO,SAAS,CAAC,CAAC,kBAAkB;IACxC,CAAC,CAAC;AACN,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB,EAAE,OAAiB;IACxF,IAAI,OAAO,CAAC,GAAG,KAAK,EAAE,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC3E,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;KACxE;SAAM;QACH,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;KACrC;AACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { FluidObject, IRequest, IRequestHeader, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidMountableViewClass } from \"@fluidframework/view-interfaces\";\nimport { RuntimeRequestHandler, buildRuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\n\n/**\n * A mountable view is only required if the view needs to be mounted across a bundle boundary. Mounting across\n * bundle boundaries breaks some frameworks, so the mountable view is used to ensure the mounting is done within\n * the same bundle as the view. For example, React hooks don't work if mounted across bundles since there will\n * be two React instances, breaking the Rules of Hooks. When cross-bundle mounting isn't required, the mountable\n * view isn't necessary.\n *\n * When a request is received with a mountableView: true header, this request handler will reissue the request\n * without the header, and respond with a mountable view of the given class using the response.\n * @param MountableViewClass - The type of mountable view to use when responding\n */\nexport const mountableViewRequestHandler =\n (MountableViewClass: IFluidMountableViewClass, handlers: RuntimeRequestHandler[]) => {\n const nestedHandler = buildRuntimeRequestHandler(...handlers);\n return async (request: RequestParser, runtime: IContainerRuntime) => {\n const mountableView = request.headers?.mountableView === true;\n let newRequest: IRequest = request;\n if (mountableView) {\n // Reissue the request without the mountableView header.\n // We'll repack whatever the response is if we can.\n const headers: IRequestHeader = { ...request.headers };\n delete (headers as any).mountableView;\n newRequest = {\n url: request.url,\n headers,\n };\n }\n const response = await nestedHandler(newRequest, runtime);\n\n if (mountableView && response.status === 200 && MountableViewClass.canMount(response.value)) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: new MountableViewClass(response.value),\n };\n }\n return response;\n };\n };\n\n/**\n * Pipe through container request into internal request.\n * If request is empty and default url is provided, redirect request to such default url.\n * @param defaultRootId - optional default root data store ID to pass request in case request is empty.\n */\nexport const defaultRouteRequestHandler = (defaultRootId: string) => {\n return async (request: IRequest, runtime: IContainerRuntime) => {\n const parser = RequestParser.create(request);\n if (parser.pathParts.length === 0) {\n return runtime.IFluidHandleContext.resolveHandle({\n url: `/${defaultRootId}${parser.query}`,\n headers: request.headers });\n }\n return undefined; // continue search\n };\n};\n\n/**\n * Default request handler for a Fluid object that returns the object itself if:\n * 1. the request url is empty\n * 2. the request url is \"/\"\n * 3. the request url starts with \"/\" and is followed by a query param, such as /?key=value\n * Returns a 404 error for any other url.\n */\nexport function defaultFluidObjectRequestHandler(fluidObject: FluidObject, request: IRequest): IResponse {\n if (request.url === \"\" || request.url === \"/\" || request.url.startsWith(\"/?\")) {\n return { mimeType: \"fluid/object\", status: 200, value: fluidObject };\n } else {\n return create404Response(request);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerInteractions.js","sourceRoot":"","sources":["../../src/utils/containerInteractions.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,
|
|
1
|
+
{"version":3,"file":"containerInteractions.js","sourceRoot":"","sources":["../../src/utils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ACxC,IAAY,EAAE,SAAqB;IACnC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAExD,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;QACjE,MAAM,IAAI,KAAK,CAAC,mDAAmD,IAAI,GAAG,CAAC,CAAC;KAC/E;SAAM,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE;QACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,GAAG,CAAC,CAAC;KAC7D;IAED,+DAA+D;IAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { FluidObject, IFluidObject } from \"@fluidframework/core-interfaces\";\nimport { IContainer } from \"@fluidframework/container-definitions\";\n\n/**\n * Helper function for getting the default Fluid Object from a Container. This function only works for\n * Containers that support \"/\" request.\n *\n * T - defines the type you expect to be returned\n *\n * @param container - Container you're attempting to get the object from\n */\nexport async function getDefaultObjectFromContainer<T = IFluidObject & FluidObject>(container: IContainer): Promise<T> {\n const url = \"/\";\n const response = await container.request({ url });\n\n // Verify the response\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object at URL: \"${url}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response from URL: \"${url}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n\n/**\n * Helper function for getting as Fluid Object from a Container given a Unique Id. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * T - defines the type you expect to be returned\n *\n * @param id - Unique id of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectWithIdFromContainer<T = IFluidObject & FluidObject>(\n id: string, container: IContainer): Promise<T> {\n const url = `/${id}`;\n const response = await container.request({ url });\n\n // Verify the response\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object with ID: \"${id}\" from URL: \"${url}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response for ID: \"${id}\" from URL: \"${url}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n\n/**\n * Helper function for getting a Fluid Object from a Container given a path/url. This function only works for\n * Containers that support getting FluidObjects via request.\n *\n * T - defines the type you expect to be returned\n *\n * @param path - Unique path/url of the FluidObject\n * @param container - Container you're attempting to get the object from\n */\nexport async function getObjectFromContainer<T = IFluidObject & FluidObject>(\n path: string, container: IContainer): Promise<T> {\n const response = await container.request({ url: path });\n\n if (response.status !== 200 || response.mimeType !== \"fluid/object\") {\n throw new Error(`Unable to retrieve Fluid object with from URL: \"${path}\"`);\n } else if (response.value === undefined) {\n throw new Error(`Empty response for from URL: \"${path}\"`);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n}\n"]}
|