@fluidframework/aqueduct 0.59.2001 → 0.59.3000
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.js +1 -1
- package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
- package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js +1 -1
- package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
- package/dist/container-services/containerServices.js +3 -3
- package/dist/container-services/containerServices.js.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.d.ts.map +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.js +1 -1
- package/dist/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/dist/data-objects/dataObject.d.ts.map +1 -1
- package/dist/data-objects/dataObject.js +1 -1
- package/dist/data-objects/dataObject.js.map +1 -1
- package/dist/data-objects/pureDataObject.js +5 -5
- package/dist/data-objects/pureDataObject.js.map +1 -1
- package/dist/request-handlers/requestHandlers.js +2 -2
- package/dist/request-handlers/requestHandlers.js.map +1 -1
- package/dist/test/containerServices.spec.js +31 -31
- package/dist/test/containerServices.spec.js.map +1 -1
- package/dist/test/defaultRoute.spec.js +9 -9
- package/dist/test/defaultRoute.spec.js.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -4917
- package/dist/test/types/validateAqueductPrevious.js.map +1 -1
- package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
- package/lib/data-object-factories/pureDataObjectFactory.js.map +1 -1
- package/lib/data-objects/dataObject.js.map +1 -1
- package/lib/data-objects/pureDataObject.js.map +1 -1
- package/lib/request-handlers/requestHandlers.js.map +1 -1
- package/package.json +18 -17
|
@@ -42,7 +42,7 @@ class BaseContainerRuntimeFactory extends runtime_utils_1.RuntimeFactoryHelper {
|
|
|
42
42
|
const scope = context.scope;
|
|
43
43
|
const dc = new synthesize_1.DependencyContainer(this.dependencyContainer, scope.IFluidDependencySynthesizer);
|
|
44
44
|
scope.IFluidDependencySynthesizer = dc;
|
|
45
|
-
const runtime = await container_runtime_1.ContainerRuntime.load(context, this.registryEntries, request_handler_1.buildRuntimeRequestHandler(...this.requestHandlers), this.runtimeOptions, scope, existing);
|
|
45
|
+
const runtime = await container_runtime_1.ContainerRuntime.load(context, this.registryEntries, (0, request_handler_1.buildRuntimeRequestHandler)(...this.requestHandlers), this.runtimeOptions, scope, existing);
|
|
46
46
|
// we register the runtime so developers of providers can use it in the factory pattern.
|
|
47
47
|
dc.register(container_runtime_definitions_1.IContainerRuntime, runtime);
|
|
48
48
|
return runtime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseContainerRuntimeFactory.js","sourceRoot":"","sources":["../../src/container-runtime-factories/baseContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAI2C;AAC3C,iGAEuD;AACvD,qEAGyC;AAMzC,2DAIoC;AACpC,iEAAqE;AAGrE;;;;GAIG;AACH,MAAa,2BACT,SAAQ,oCAAoB;IAK5B;;;;;OAKG;IACH,YACqB,eAAmD,EACnD,mBAAiD,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAE1D,KAAK,EAAE,CAAC;QALS,oBAAe,GAAf,eAAe,CAAoC;QACnD,wBAAmB,GAAnB,mBAAmB,CAA8B;QACjD,oBAAe,GAAf,eAAe,CAA8B;QAC7C,mBAAc,GAAd,cAAc,CAA2B;QAG1D,IAAI,CAAC,QAAQ,GAAG,IAAI,0CAAsB,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;IAjBD,IAAW,uBAAuB,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAmBvD,KAAK,CAAC,oBAAoB,CAAC,OAAyB;QACvD,MAAM,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,OAAyB;QAC1D,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,aAAa,CACtB,OAA0B,EAC1B,QAAiB;QAEjB,MAAM,KAAK,GAAgD,OAAO,CAAC,KAAK,CAAC;QACzE,MAAM,EAAE,GAAG,IAAI,gCAAmB,CAC9B,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACjE,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC;QAEvC,MAAM,OAAO,GAAqB,MAAM,oCAAgB,CAAC,IAAI,CACzD,OAAO,EACP,IAAI,CAAC,eAAe,EACpB,4CAA0B,
|
|
1
|
+
{"version":3,"file":"baseContainerRuntimeFactory.js","sourceRoot":"","sources":["../../src/container-runtime-factories/baseContainerRuntimeFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAI2C;AAC3C,iGAEuD;AACvD,qEAGyC;AAMzC,2DAIoC;AACpC,iEAAqE;AAGrE;;;;GAIG;AACH,MAAa,2BACT,SAAQ,oCAAoB;IAK5B;;;;;OAKG;IACH,YACqB,eAAmD,EACnD,mBAAiD,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAE1D,KAAK,EAAE,CAAC;QALS,oBAAe,GAAf,eAAe,CAAoC;QACnD,wBAAmB,GAAnB,mBAAmB,CAA8B;QACjD,oBAAe,GAAf,eAAe,CAA8B;QAC7C,mBAAc,GAAd,cAAc,CAA2B;QAG1D,IAAI,CAAC,QAAQ,GAAG,IAAI,0CAAsB,CAAC,eAAe,CAAC,CAAC;IAChE,CAAC;IAjBD,IAAW,uBAAuB,KAAK,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAmBvD,KAAK,CAAC,oBAAoB,CAAC,OAAyB;QACvD,MAAM,IAAI,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,OAAyB;QAC1D,MAAM,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,aAAa,CACtB,OAA0B,EAC1B,QAAiB;QAEjB,MAAM,KAAK,GAAgD,OAAO,CAAC,KAAK,CAAC;QACzE,MAAM,EAAE,GAAG,IAAI,gCAAmB,CAC9B,IAAI,CAAC,mBAAmB,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;QACjE,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC;QAEvC,MAAM,OAAO,GAAqB,MAAM,oCAAgB,CAAC,IAAI,CACzD,OAAO,EACP,IAAI,CAAC,eAAe,EACpB,IAAA,4CAA0B,EACtB,GAAG,IAAI,CAAC,eAAe,CAAC,EAC5B,IAAI,CAAC,cAAc,EACnB,KAAK,EACL,QAAQ,CACX,CAAC;QAEF,wFAAwF;QACxF,EAAE,CAAC,QAAQ,CAAC,iDAAiB,EAAE,OAAO,CAAC,CAAC;QAExC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B,IAAI,CAAC;IAE9E;;;;OAIG;IACO,KAAK,CAAC,uBAAuB,CAAC,OAA0B,IAAI,CAAC;CAC1E;AArED,kEAqEC","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} from \"@fluidframework/request-handler\";\nimport {\n IFluidDataStoreRegistry,\n IProvideFluidDataStoreRegistry,\n NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n DependencyContainer,\n IFluidDependencySynthesizer,\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 dependencyContainer?: IFluidDependencySynthesizer,\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: Partial<IProvideFluidDependencySynthesizer> = context.scope;\n const dc = new DependencyContainer<FluidObject<IContainerRuntime>>(\n this.dependencyContainer, scope.IFluidDependencySynthesizer);\n scope.IFluidDependencySynthesizer = dc;\n\n const runtime: ContainerRuntime = await ContainerRuntime.load(\n context,\n this.registryEntries,\n buildRuntimeRequestHandler(\n ...this.requestHandlers),\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"]}
|
|
@@ -17,7 +17,7 @@ const defaultDataStoreId = "default";
|
|
|
17
17
|
class ContainerRuntimeFactoryWithDefaultDataStore extends baseContainerRuntimeFactory_1.BaseContainerRuntimeFactory {
|
|
18
18
|
constructor(defaultFactory, registryEntries, dependencyContainer, requestHandlers = [], runtimeOptions) {
|
|
19
19
|
super(registryEntries, dependencyContainer, [
|
|
20
|
-
request_handlers_1.defaultRouteRequestHandler(defaultDataStoreId),
|
|
20
|
+
(0, request_handlers_1.defaultRouteRequestHandler)(defaultDataStoreId),
|
|
21
21
|
...requestHandlers,
|
|
22
22
|
], runtimeOptions);
|
|
23
23
|
this.defaultFactory = defaultFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../../src/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,0DAAiE;AACjE,+EAA4E;AAE5E,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC;;;;;GAKG;AACH,MAAa,2CAA4C,SAAQ,yDAA2B;IAGxF,YACuB,cAAsC,EACzD,eAAmD,EACnD,mBAAiD,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAEzC,KAAK,CACD,eAAe,EACf,mBAAmB,EACnB;YACI,6CAA0B,
|
|
1
|
+
{"version":3,"file":"containerRuntimeFactoryWithDefaultDataStore.js","sourceRoot":"","sources":["../../src/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,0DAAiE;AACjE,+EAA4E;AAE5E,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAErC;;;;;GAKG;AACH,MAAa,2CAA4C,SAAQ,yDAA2B;IAGxF,YACuB,cAAsC,EACzD,eAAmD,EACnD,mBAAiD,EACjD,kBAA2C,EAAE,EAC7C,cAAyC;QAEzC,KAAK,CACD,eAAe,EACf,mBAAmB,EACnB;YACI,IAAA,6CAA0B,EAAC,kBAAkB,CAAC;YAC9C,GAAG,eAAe;SACrB,EACD,cAAc,CACjB,CAAC;QAdiB,mBAAc,GAAd,cAAc,CAAwB;IAe7D,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,8BAA8B,CAAC,OAA0B;QACrE,MAAM,OAAO,CAAC,mBAAmB,CAC7B,IAAI,CAAC,cAAc,CAAC,IAAI,EACxB,kBAAkB,CACrB,CAAC;IACN,CAAC;;AA7BL,kGA8BC;AA7B0B,8DAAkB,GAAG,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainerRuntimeOptions } from \"@fluidframework/container-runtime\";\nimport { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntries } from \"@fluidframework/runtime-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IFluidDependencySynthesizer } from \"@fluidframework/synthesize\";\nimport { RuntimeRequestHandler } from \"@fluidframework/request-handler\";\nimport { defaultRouteRequestHandler } from \"../request-handlers\";\nimport { BaseContainerRuntimeFactory } from \"./baseContainerRuntimeFactory\";\n\nconst defaultDataStoreId = \"default\";\n\n/**\n * A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from\n * the container with an empty URL.\n *\n * This factory should be exposed as fluidExport off the entry point to your module.\n */\nexport class ContainerRuntimeFactoryWithDefaultDataStore extends BaseContainerRuntimeFactory {\n public static readonly defaultDataStoreId = defaultDataStoreId;\n\n constructor(\n protected readonly defaultFactory: IFluidDataStoreFactory,\n registryEntries: NamedFluidDataStoreRegistryEntries,\n dependencyContainer?: IFluidDependencySynthesizer,\n requestHandlers: RuntimeRequestHandler[] = [],\n runtimeOptions?: IContainerRuntimeOptions,\n ) {\n super(\n registryEntries,\n dependencyContainer,\n [\n defaultRouteRequestHandler(defaultDataStoreId),\n ...requestHandlers,\n ],\n runtimeOptions,\n );\n }\n\n /**\n * {@inheritDoc BaseContainerRuntimeFactory.containerInitializingFirstTime}\n */\n protected async containerInitializingFirstTime(runtime: IContainerRuntime) {\n await runtime.createRootDataStore(\n this.defaultFactory.type,\n defaultDataStoreId,\n );\n }\n}\n"]}
|
|
@@ -55,12 +55,12 @@ const generateContainerServicesRequestHandler = (serviceRegistry) => {
|
|
|
55
55
|
}
|
|
56
56
|
if (request.pathParts.length < 2) {
|
|
57
57
|
// If there is not service to route to then return a failure
|
|
58
|
-
return runtime_utils_1.createResponseError(400, "request did not specify a service to route to", request);
|
|
58
|
+
return (0, runtime_utils_1.createResponseError)(400, "request did not specify a service to route to", request);
|
|
59
59
|
}
|
|
60
60
|
const factory = factories.get(request.pathParts[1]);
|
|
61
61
|
if (!factory) {
|
|
62
62
|
// If we can't find a registry entry then return
|
|
63
|
-
return runtime_utils_1.create404Response(request);
|
|
63
|
+
return (0, runtime_utils_1.create404Response)(request);
|
|
64
64
|
}
|
|
65
65
|
const service = await factory.getService(runtime);
|
|
66
66
|
const router = service.IFluidRouter;
|
|
@@ -70,7 +70,7 @@ const generateContainerServicesRequestHandler = (serviceRegistry) => {
|
|
|
70
70
|
}
|
|
71
71
|
if (!request.isLeaf(2)) {
|
|
72
72
|
// If there is not terminating route but a sub-route was requested then we will fail.
|
|
73
|
-
return runtime_utils_1.createResponseError(400, "request sub-url for service that doesn't support routing", request);
|
|
73
|
+
return (0, runtime_utils_1.createResponseError)(400, "request sub-url for service that doesn't support routing", request);
|
|
74
74
|
}
|
|
75
75
|
// Otherwise we will just return the service
|
|
76
76
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerServices.js","sourceRoot":"","sources":["../../src/container-services/containerServices.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,iEAIuC;AAEvC,iCAAiC;AACpB,QAAA,oBAAoB,GAAG,WAAW,CAAC;AAKhD;;GAEG;AACH,MAAsB,oBAAoB;IAGtC,YAA+B,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IACzD,CAAC;IAHD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAKnC,KAAK,CAAC,OAAO,CAAC,OAAiB;QAClC,OAAO;YACH,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,IAAI;SACd,CAAC;IACN,CAAC;CACJ;AAbD,oDAaC;AAED;;GAEG;AACH,MAAM,gCAAgC;IAGlC,YACqB,SAA+D;QAA/D,cAAS,GAAT,SAAS,CAAsD;IAChF,CAAC;IAEE,KAAK,CAAC,UAAU,CAAC,OAA0B;QAC9C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SAC1C;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAED;;;GAGG;AACI,MAAM,uCAAuC,GAChD,CAAC,eAAgD,EAAyB,EAAE;IACxE,MAAM,SAAS,GAAkD,IAAI,GAAG,EAAE,CAAC;IAC3E,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;QACxC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,gCAAgC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,EAAE,OAAsB,EAAE,OAA0B,EAAE,EAAE;QAChE,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,4BAAoB,EAAE;YAC/C,yFAAyF;YACzF,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,4DAA4D;YAC5D,OAAO,mCAAmB,
|
|
1
|
+
{"version":3,"file":"containerServices.js","sourceRoot":"","sources":["../../src/container-services/containerServices.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,iEAIuC;AAEvC,iCAAiC;AACpB,QAAA,oBAAoB,GAAG,WAAW,CAAC;AAKhD;;GAEG;AACH,MAAsB,oBAAoB;IAGtC,YAA+B,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IACzD,CAAC;IAHD,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC;IAKnC,KAAK,CAAC,OAAO,CAAC,OAAiB;QAClC,OAAO;YACH,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,IAAI;SACd,CAAC;IACN,CAAC;CACJ;AAbD,oDAaC;AAED;;GAEG;AACH,MAAM,gCAAgC;IAGlC,YACqB,SAA+D;QAA/D,cAAS,GAAT,SAAS,CAAsD;IAChF,CAAC;IAEE,KAAK,CAAC,UAAU,CAAC,OAA0B;QAC9C,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;SAC1C;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;CACJ;AAED;;;GAGG;AACI,MAAM,uCAAuC,GAChD,CAAC,eAAgD,EAAyB,EAAE;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YACH,MAAM,EAAE,GAAG;YACX,QAAQ,EAAE,cAAc;YACxB,KAAK,EAAE,OAAO;SACjB,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC;AA3CO,QAAA,uCAAuC,2CA2C9C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResponse, 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<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<FluidObject<IFluidRouter>> {\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACH,kCAAkC,EACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,iBAAiB,CAAC,IAAI,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,CAClG,SAAQ,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACH,kCAAkC,EACrC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;GAOG;AACH,qBAAa,iBAAiB,CAAC,IAAI,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,CAClG,SAAQ,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;gBAElC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,KAAK,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,IAAI,EAC9C,aAAa,wCAAiC,EAC9C,iBAAiB,EAAE,yBAAyB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,EACpE,eAAe,CAAC,EAAE,kCAAkC,EACpD,cAAc,GAAE,OAAO,qBAA6C;CAwB3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAK6B;AAM7B,yDAAkE;AAGlE,mEAAgE;AAEhE;;;;;;;GAOG;AACH,MAAa,iBACT,SAAQ,6CAA8B;
|
|
1
|
+
{"version":3,"file":"dataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/dataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAK6B;AAM7B,yDAAkE;AAGlE,mEAAgE;AAEhE;;;;;;;GAOG;AACH,MAAa,iBACT,SAAQ,6CAA8B;IACtC,YACI,IAAY,EACZ,IAA8C,EAC9C,gBAA4C,EAAE,EAC9C,iBAAoE,EACpE,eAAoD,EACpD,iBAA+C,iCAAqB;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,sBAAgB,CAAC,IAAI,CAAC,EAAE;YAC1E,sCAAsC;YACtC,aAAa,CAAC,IAAI,CAAC,qBAAe,CAAC,UAAU,EAAE,CAAC,CAAC;SACpD;QAED,0GAA0G;QAC1G,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,gBAAU,CAAC,IAAI,CAAC,EAAE;YACpE,gCAAgC;YAChC,aAAa,CAAC,IAAI,CAAC,eAAS,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;AAhCD,8CAgCC","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 { DataObject, DataObjectTypes, IDataObjectProps } 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 constructor(\n type: string,\n ctor: new (props: IDataObjectProps<I>) => TObj,\n sharedObjects: readonly IChannelFactory[] = [],\n optionalProviders: FluidObjectSymbolProvider<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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,YAAY,EAAe,MAAM,iCAAiC,CAAC;AACtF,OAAO,EACH,qBAAqB,EAGvB,MAAM,2BAA2B,CAAC;AAEpC,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,gCAAgC,EAChC,8BAA8B,EACjC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EACH,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,eAAe,EAClB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IAClE,kBAAkB,CACd,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1D;
|
|
1
|
+
{"version":3,"file":"pureDataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,YAAY,EAAe,MAAM,iCAAiC,CAAC;AACtF,OAAO,EACH,qBAAqB,EAGvB,MAAM,2BAA2B,CAAC;AAEpC,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,gCAAgC,EAChC,8BAA8B,EACjC,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EACH,yBAAyB,EAG5B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACH,gBAAgB,EAChB,cAAc,EACd,eAAe,EAClB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,sBAAuB,SAAQ,sBAAsB;IAClE,kBAAkB,CACd,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1D;AAyDD;;;;;;;GAOG;AACH,qBAAa,qBAAqB,CAAC,IAAI,SAAS,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,CAC1G,YAAW,sBAAsB,EAAE,OAAO,CAAC,8BAA8B,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,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;cAKA,yBAAyB,CACrC,gBAAgB,EAAE,qBAAqB,EACvC,WAAW,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,EAC/B,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;cAKA,kBAAkB,CAC9B,OAAO,EAAE,8BAA8B,EACvC,YAAY,CAAC,EAAE,CAAC,CAAC,cAAc,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;CAcnB"}
|
|
@@ -17,7 +17,7 @@ async function createDataObject(ctor, context, sharedObjectRegistry, optionalPro
|
|
|
17
17
|
// base
|
|
18
18
|
let runtimeClass = runtimeClassArg;
|
|
19
19
|
// request mixin in
|
|
20
|
-
runtimeClass = datastore_1.mixinRequestHandler(async (request, runtimeArg) => (await data_objects_1.PureDataObject.getDataObject(runtimeArg)).request(request), runtimeClass);
|
|
20
|
+
runtimeClass = (0, datastore_1.mixinRequestHandler)(async (request, runtimeArg) => (await data_objects_1.PureDataObject.getDataObject(runtimeArg)).request(request), runtimeClass);
|
|
21
21
|
// Create a new runtime for our data store
|
|
22
22
|
// The runtime is what Fluid uses to create DDS' and route to your data store
|
|
23
23
|
const runtime = new runtimeClass(context, sharedObjectRegistry, existing);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAIoC;AACpC,yEAA2E;AAa3E,2DAIoC;AAEpC,kDAIyB;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAE7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;I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AAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAlKD,sDAkKC","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 {\n IDataObjectProps,\n PureDataObject,\n DataObjectTypes,\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<I[\"OptionalProviders\"]>,\n runtimeClassArg: typeof FluidDataStoreRuntime,\n existing: boolean,\n initProps?: 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<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<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?: 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?: 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?: 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?: 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?: 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?: 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"]}
|
|
1
|
+
{"version":3,"file":"pureDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/pureDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yDAIoC;AACpC,yEAA2E;AAa3E,2DAIoC;AAEpC,kDAIyB;AAUzB;;;EAGE;AACF,KAAK,UAAU,gBAAgB,CAC3B,IAA8C,EAC9C,OAA+B,EAC/B,oBAA2C,EAC3C,iBAAoE,EACpE,eAA6C,EAC7C,QAAiB,EACjB,SAA6B;IAC7B,OAAO;IACP,IAAI,YAAY,GAAG,eAAe,CAAC;IAEnC,mBAAmB;IACnB,YAAY,GAAG,IAAA,+BAAmB,EAC9B,KAAK,EAAE,OAAiB,EAAE,UAAiC,EAAE,EAAE,CAC3D,CAAC,MAAM,6BAAc,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,gCAAmB,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACvF,MAAM,SAAS,GAAG,mBAAmB,CAAC,UAAU,CAAyB,iBAAiB,EAAE,EAAE,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,EAAE,OAAO,EAAE,OAA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yB,CACrC,gBAAuC,EACvC,WAA+B,EAC/B,YAAgC;QAEhC,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,YAAgC;QAEhC,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;AAjKD,sDAiKC","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 {\n IDataObjectProps,\n PureDataObject,\n DataObjectTypes,\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<I[\"OptionalProviders\"]>,\n runtimeClassArg: typeof FluidDataStoreRuntime,\n existing: boolean,\n initProps?: I[\"InitialState\"]) {\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<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 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<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?: 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?: 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?: 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?: 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?: 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?: 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAA+B,MAAM,qBAAqB,CAAC;AAEpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;GASG;AACH,8BAAsB,UAAU,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"dataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EACR,SAAS,EACZ,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAA+B,MAAM,qBAAqB,CAAC;AAEpF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;;;;;;GASG;AACH,8BAAsB,UAAU,CAAC,CAAC,SAAS,eAAe,GAAG,eAAe,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;IACnG,OAAO,CAAC,YAAY,CAA+B;IACnD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAE7B,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAc3D;;;OAGG;IACH,SAAS,KAAK,IAAI,IAAI,gBAAgB,CAMrC;IAED;;;OAGG;IACU,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBjE,SAAS,CAAC,2BAA2B,CAAC,IAAI,EAAE,MAAM;CAGrD"}
|
|
@@ -29,7 +29,7 @@ class DataObject extends pureDataObject_1.PureDataObject {
|
|
|
29
29
|
if (itemId === "bigBlobs") {
|
|
30
30
|
const value = this.root.get(requestParser.pathParts.join("/"));
|
|
31
31
|
if (value === undefined) {
|
|
32
|
-
return runtime_utils_1.create404Response(requestParser);
|
|
32
|
+
return (0, runtime_utils_1.create404Response)(requestParser);
|
|
33
33
|
}
|
|
34
34
|
return { mimeType: "fluid/object", status: 200, value };
|
|
35
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataObject.js","sourceRoot":"","sources":["../../src/data-objects/dataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,6CAAoF;AACpF,iEAAiF;AACjF,qDAAkD;AAGlD;;;;;;;;;GASG;AACH,MAAsB,UAAwD,SA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AAI,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,gBAAU,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;AA7DD,gCA6DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\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 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"]}
|
|
@@ -25,7 +25,7 @@ class PureDataObject extends common_utils_1.EventForwarder {
|
|
|
25
25
|
this.context = props.context;
|
|
26
26
|
this.providers = props.providers;
|
|
27
27
|
this.initProps = props.initProps;
|
|
28
|
-
common_utils_1.assert(this.runtime._dataObject === undefined, 0x0bd /* "Object runtime already has DataObject!" */);
|
|
28
|
+
(0, common_utils_1.assert)(this.runtime._dataObject === undefined, 0x0bd /* "Object runtime already has DataObject!" */);
|
|
29
29
|
this.runtime._dataObject = this;
|
|
30
30
|
// Create a FluidObjectHandle with empty string as `path`. This is because reaching this PureDataObject is the
|
|
31
31
|
// same as reaching its routeContext (FluidDataStoreRuntime) so there is so the relative path to it from the
|
|
@@ -48,7 +48,7 @@ class PureDataObject extends common_utils_1.EventForwarder {
|
|
|
48
48
|
get handle() { return this.innerHandle; }
|
|
49
49
|
static async getDataObject(runtime) {
|
|
50
50
|
const obj = runtime._dataObject;
|
|
51
|
-
common_utils_1.assert(obj !== undefined, 0x0bc /* "Runtime has no DataObject!" */);
|
|
51
|
+
(0, common_utils_1.assert)(obj !== undefined, 0x0bc /* "Runtime has no DataObject!" */);
|
|
52
52
|
await obj.finishInitialization(true);
|
|
53
53
|
return obj;
|
|
54
54
|
}
|
|
@@ -60,7 +60,7 @@ class PureDataObject extends common_utils_1.EventForwarder {
|
|
|
60
60
|
* 2. the request url is empty
|
|
61
61
|
*/
|
|
62
62
|
async request(req) {
|
|
63
|
-
return request_handlers_1.defaultFluidObjectRequestHandler(this, req);
|
|
63
|
+
return (0, request_handlers_1.defaultFluidObjectRequestHandler)(this, req);
|
|
64
64
|
}
|
|
65
65
|
// #endregion IFluidRouter
|
|
66
66
|
// #region IFluidLoadable
|
|
@@ -90,7 +90,7 @@ class PureDataObject extends common_utils_1.EventForwarder {
|
|
|
90
90
|
var _a;
|
|
91
91
|
await this.preInitialize();
|
|
92
92
|
if (existing) {
|
|
93
|
-
common_utils_1.assert(this.initProps === undefined, 0x0be /* "Trying to initialize from existing while initProps is set!" */);
|
|
93
|
+
(0, common_utils_1.assert)(this.initProps === undefined, 0x0be /* "Trying to initialize from existing while initProps is set!" */);
|
|
94
94
|
await this.initializingFromExisting();
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
@@ -119,7 +119,7 @@ class PureDataObject extends common_utils_1.EventForwarder {
|
|
|
119
119
|
* @param id - service id
|
|
120
120
|
*/
|
|
121
121
|
async getService(id) {
|
|
122
|
-
return request_handler_1.handleFromLegacyUri(`/${container_services_1.serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();
|
|
122
|
+
return (0, request_handler_1.handleFromLegacyUri)(`/${container_services_1.serviceRoutePathRoot}/${id}`, this.context.containerRuntime).get();
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Called every time the data store is initialized, before initializingFirstTime or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsE;AAUtE,yDAA8D;AAG9D,qEAAsE;AAGtE,8DAA6D;AAC7D,0DAAuE;AAGvE;;;;;;GAMG;AACH,MAAsB,cAClB,SAAQ,6BAAoC;IA+C5C,YAAmB,KAA0B;QACzC,KAAK,EAAE,CAAC;QA7CJ,cAAS,GAAG,KAAK,CAAC;QA8CtB,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,qBAAM,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,6BAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEvF,2BAA2B;QAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAA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;OAEG;IACO,KAAK,CAAC,cAAc,KAAoB,CAAC;IAEnD;;OAEG;IACI,OAAO;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAvLD,wCAuLC","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 { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport {\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { AsyncFluidObjectProvider } from \"@fluidframework/synthesize\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, 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<I[\"Events\"] & IEvent>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle {\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 FluidObject keyed objects that provide back\n * a promise to the corresponding FluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n */\n protected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n protected initProps?: 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 I[\"InitialState\"] ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retrieve Fluid object using the handle get\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 IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleMaybe = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n const handle = handleMaybe?.IFluidHandle;\n if (handle) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return handle.get();\n }\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends 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?: 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"]}
|
|
1
|
+
{"version":3,"file":"pureDataObject.js","sourceRoot":"","sources":["../../src/data-objects/pureDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAsE;AAUtE,yDAA8D;AAG9D,qEAAsE;AAGtE,8DAA6D;AAC7D,0DAAuE;AAGvE;;;;;;GAMG;AACH,MAAsB,cAClB,SAAQ,6BAAoC;IA+C5C,YAAmB,KAA0B;QACzC,KAAK,EAAE,CAAC;QA7CJ,cAAS,GAAG,KAAK,CAAC;QA8CtB,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,IAAA,qBAAM,EAAE,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,6BAAiB,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAEvF,2BAA2B;QAC3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IAC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,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAvLD,wCAuLC","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 { assert, EventForwarder } from \"@fluidframework/common-utils\";\nimport {\n IFluidHandle,\n IFluidLoadable,\n IFluidRouter,\n IProvideFluidHandle,\n IRequest,\n IResponse,\n FluidObject,\n} from \"@fluidframework/core-interfaces\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore\";\nimport { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions\";\nimport { IDirectory } from \"@fluidframework/map\";\nimport { handleFromLegacyUri } from \"@fluidframework/request-handler\";\nimport { IFluidDataStoreContext } from \"@fluidframework/runtime-definitions\";\nimport { AsyncFluidObjectProvider } from \"@fluidframework/synthesize\";\nimport { serviceRoutePathRoot } from \"../container-services\";\nimport { defaultFluidObjectRequestHandler } from \"../request-handlers\";\nimport { DataObjectTypes, 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<I[\"Events\"] & IEvent>\n implements IFluidLoadable, IFluidRouter, IProvideFluidHandle {\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 FluidObject keyed objects that provide back\n * a promise to the corresponding FluidObject or undefined.\n * Providers injected/provided by the Container and/or HostingApplication\n *\n * To define providers set FluidObject interfaces in the OptionalProviders generic type for your data store\n */\n protected readonly providers: AsyncFluidObjectProvider<I[\"OptionalProviders\"]>;\n\n protected initProps?: 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 I[\"InitialState\"] ?? this.initProps);\n }\n await this.hasInitialized();\n }\n\n /**\n * Retrieve Fluid object using the handle get\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 IFluidLoadable>(\n key: string,\n directory: IDirectory,\n getObjectFromDirectory?: (id: string, directory: IDirectory) => IFluidHandle | undefined):\n Promise<T | undefined> {\n const handleMaybe = getObjectFromDirectory ? getObjectFromDirectory(key, directory) : directory.get(key);\n const handle = handleMaybe?.IFluidHandle;\n if (handle) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return handle.get();\n }\n }\n\n /**\n * Gets the service at a given id.\n * @param id - service id\n */\n protected async getService<T extends 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?: 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"]}
|
|
@@ -19,7 +19,7 @@ const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
|
19
19
|
* @param MountableViewClass - The type of mountable view to use when responding
|
|
20
20
|
*/
|
|
21
21
|
const mountableViewRequestHandler = (MountableViewClass, handlers) => {
|
|
22
|
-
const nestedHandler = request_handler_1.buildRuntimeRequestHandler(...handlers);
|
|
22
|
+
const nestedHandler = (0, request_handler_1.buildRuntimeRequestHandler)(...handlers);
|
|
23
23
|
return async (request, runtime) => {
|
|
24
24
|
var _a;
|
|
25
25
|
const mountableView = ((_a = request.headers) === null || _a === void 0 ? void 0 : _a.mountableView) === true;
|
|
@@ -76,7 +76,7 @@ function defaultFluidObjectRequestHandler(fluidObject, request) {
|
|
|
76
76
|
return { mimeType: "fluid/object", status: 200, value: fluidObject };
|
|
77
77
|
}
|
|
78
78
|
else {
|
|
79
|
-
return runtime_utils_1.create404Response(request);
|
|
79
|
+
return (0, runtime_utils_1.create404Response)(request);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
exports.defaultFluidObjectRequestHandler = defaultFluidObjectRequestHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,qEAAoG;AACpG,iEAAiF;AAEjF;;;;;;;;;;GAUG;AACI,MAAM,2BAA2B,GACpC,CAAC,kBAA4C,EAAE,QAAiC,EAAE,EAAE;IAChF,MAAM,aAAa,GAAG,4CAA0B,
|
|
1
|
+
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../../src/request-handlers/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,qEAAoG;AACpG,iEAAiF;AAEjF;;;;;;;;;;GAUG;AACI,MAAM,2BAA2B,G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AAmB,CAAC,aAAa,CAAC;gBAC7C,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;AAVW,QAAA,0BAA0B,8BAUrC;AAEF;;;;;;GAMG;AACH,SAAgB,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,IAAA,iCAAiB,EAAC,OAAO,CAAC,CAAC;KACrC;AACL,CAAC;AAND,4EAMC","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"]}
|
|
@@ -26,72 +26,72 @@ describe("Routerlicious", () => {
|
|
|
26
26
|
describe("Aqueduct", () => {
|
|
27
27
|
describe("generateContainerServicesRequestHandler", () => {
|
|
28
28
|
it(`Request to ${container_services_1.serviceRoutePathRoot} and no id should fail`, async () => {
|
|
29
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([]);
|
|
29
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([]);
|
|
30
30
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}` });
|
|
31
31
|
const response = await requestHandler(requestParser, {});
|
|
32
|
-
assert_1.strict(response, "Response returned");
|
|
33
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 400, "Returned 400 Status Code");
|
|
32
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
33
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 400, "Returned 400 Status Code");
|
|
34
34
|
});
|
|
35
35
|
it("Unknown service should return 404 with no services", async () => {
|
|
36
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([]);
|
|
36
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([]);
|
|
37
37
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id1` });
|
|
38
38
|
const response = await requestHandler(requestParser, {});
|
|
39
|
-
assert_1.strict(response, "Response returned");
|
|
40
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 404, "Returned 404 Status Code");
|
|
39
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
40
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 404, "Returned 404 Status Code");
|
|
41
41
|
});
|
|
42
42
|
it("Unknown service should return 404 with services", async () => {
|
|
43
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([
|
|
43
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([
|
|
44
44
|
["id1", async (r) => new ContainerServiceMock(r)],
|
|
45
45
|
]);
|
|
46
46
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id2` });
|
|
47
47
|
const response = await requestHandler(requestParser, {});
|
|
48
|
-
assert_1.strict(response, "Response returned");
|
|
49
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 404, "Returned 404 Status Code");
|
|
48
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
49
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 404, "Returned 404 Status Code");
|
|
50
50
|
});
|
|
51
51
|
it("Request to non-routeable service with sub-route should fail", async () => {
|
|
52
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([
|
|
52
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([
|
|
53
53
|
["id1", async (r) => { return {}; }],
|
|
54
54
|
]);
|
|
55
55
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id1/subroute` });
|
|
56
56
|
const response = await requestHandler(requestParser, {});
|
|
57
|
-
assert_1.strict(response, "Response returned");
|
|
58
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 400, "Returned 400 Status Code");
|
|
57
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
58
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 400, "Returned 400 Status Code");
|
|
59
59
|
});
|
|
60
60
|
it("Correct service should be returned with single service", async () => {
|
|
61
61
|
const service1 = new ContainerServiceMock({});
|
|
62
62
|
const serviceMap = new Map();
|
|
63
63
|
serviceMap.set("id1", async (r) => service1);
|
|
64
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler(serviceMap);
|
|
64
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)(serviceMap);
|
|
65
65
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id1` });
|
|
66
66
|
const response = await requestHandler(requestParser, {});
|
|
67
|
-
assert_1.strict(response, "Response returned");
|
|
68
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
69
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.value) === service1, "Returned expected service");
|
|
67
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
68
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
69
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.value) === service1, "Returned expected service");
|
|
70
70
|
});
|
|
71
71
|
it("Same service should be returned twice with two calls", async () => {
|
|
72
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([
|
|
72
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([
|
|
73
73
|
["id1", async (r) => new ContainerServiceMock(r)],
|
|
74
74
|
]);
|
|
75
75
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id1` });
|
|
76
76
|
const response1 = await requestHandler(requestParser, {});
|
|
77
77
|
const response2 = await requestHandler(requestParser, {});
|
|
78
|
-
assert_1.strict((response1 === null || response1 === void 0 ? void 0 : response1.value) === (response2 === null || response2 === void 0 ? void 0 : response2.value), "Returned same service twice");
|
|
78
|
+
(0, assert_1.strict)((response1 === null || response1 === void 0 ? void 0 : response1.value) === (response2 === null || response2 === void 0 ? void 0 : response2.value), "Returned same service twice");
|
|
79
79
|
});
|
|
80
80
|
it("Correct service should be returned with multiple services", async () => {
|
|
81
81
|
const service2 = new ContainerServiceMock({});
|
|
82
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([
|
|
82
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([
|
|
83
83
|
["id1", async (r) => new ContainerServiceMock(r)],
|
|
84
84
|
["id2", async (r) => service2],
|
|
85
85
|
]);
|
|
86
86
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id2` });
|
|
87
87
|
const response = await requestHandler(requestParser, {});
|
|
88
|
-
assert_1.strict(response, "Response returned");
|
|
89
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
90
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.value) === service2, "Returned expected service");
|
|
88
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
89
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
90
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.value) === service2, "Returned expected service");
|
|
91
91
|
});
|
|
92
92
|
it("Last registered service should be returned with multiple services of the same name", async () => {
|
|
93
93
|
const service1 = new ContainerServiceMock({});
|
|
94
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([
|
|
94
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([
|
|
95
95
|
["id1", async (r) => new ContainerServiceMock(r)],
|
|
96
96
|
["id1", async (r) => new ContainerServiceMock(r)],
|
|
97
97
|
["id1", async (r) => new ContainerServiceMock(r)],
|
|
@@ -101,19 +101,19 @@ describe("Routerlicious", () => {
|
|
|
101
101
|
]);
|
|
102
102
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id1` });
|
|
103
103
|
const response = await requestHandler(requestParser, {});
|
|
104
|
-
assert_1.strict(response, "Response returned");
|
|
105
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
106
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.value) === service1, "Returned expected service");
|
|
104
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
105
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
106
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.value) === service1, "Returned expected service");
|
|
107
107
|
});
|
|
108
108
|
it("Sub-route should be persisted through", async () => {
|
|
109
109
|
const service1 = new ContainerServiceMock({});
|
|
110
|
-
const requestHandler = container_services_1.generateContainerServicesRequestHandler([["id1", async (r) => service1]]);
|
|
110
|
+
const requestHandler = (0, container_services_1.generateContainerServicesRequestHandler)([["id1", async (r) => service1]]);
|
|
111
111
|
const requestParser = runtime_utils_1.RequestParser.create({ url: `/${container_services_1.serviceRoutePathRoot}/id1/sub1` });
|
|
112
112
|
const response = await requestHandler(requestParser, {});
|
|
113
|
-
assert_1.strict(response, "Response returned");
|
|
114
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
115
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.value) === service1, "Returned expected service");
|
|
116
|
-
assert_1.strict((response === null || response === void 0 ? void 0 : response.value).route === "/sub1", "sub-route persisted");
|
|
113
|
+
(0, assert_1.strict)(response, "Response returned");
|
|
114
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.status) === 200, "Returned 200 Status Code");
|
|
115
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.value) === service1, "Returned expected service");
|
|
116
|
+
(0, assert_1.strict)((response === null || response === void 0 ? void 0 : response.value).route === "/sub1", "sub-route persisted");
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
});
|