@fluidframework/request-handler 2.0.0-internal.5.4.0 → 2.0.0-internal.6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @fluidframework/request-handler
2
2
 
3
+ ## 2.0.0-internal.6.1.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.6.0.0
8
+
9
+ ### Major Changes
10
+
11
+ - Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
12
+
13
+ Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
14
+
3
15
  ## 2.0.0-internal.5.4.0
4
16
 
5
17
  Dependency updates only.
@@ -14,10 +14,9 @@ const runtime_utils_1 = require("@fluidframework/runtime-utils");
14
14
  * @returns the result of the request
15
15
  */
16
16
  const rootDataStoreRequestHandler = async (request, runtime) => {
17
- var _a;
18
17
  const requestParser = runtime_utils_1.RequestParser.create(request);
19
18
  const id = requestParser.pathParts[0];
20
- const wait = typeof ((_a = request.headers) === null || _a === void 0 ? void 0 : _a.wait) === "boolean" ? request.headers.wait : undefined;
19
+ const wait = typeof request.headers?.wait === "boolean" ? request.headers.wait : undefined;
21
20
  let rootDataStore;
22
21
  try {
23
22
  // getRootDataStore currently throws if the data store is not found
@@ -1 +1 @@
1
- {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAWtD,iEAA8D;AAa9D;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,KAAK,EAC/C,OAAiB,EACj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IAOM,WAAW;QACjB,IAAA,qBAAM,EAAC,KAAK,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC;YACrE,GAAG,EAAE,IAAI,CAAC,YAAY;SACtB,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;YACpE,+DAA+D;YAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;SACtB;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACnD,CAAC;CACD;AAED,SAAgB,mBAAmB,CAClC,GAAW,EACX,OAA8B;IAE9B,OAAO,IAAI,eAAe,CAAI,GAAG,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AALD,kDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIResponse,\n\tIRequest,\n\tIFluidHandle,\n\tIFluidLoadable,\n\tFluidObject,\n\tIFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IContainerRuntimeBase } from \"@fluidframework/runtime-definitions\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\n\n/**\n * A request handler for the container runtime. Each handler should handle a specific request, and return undefined\n * if it does not apply. These handlers are called in series, so there may be other handlers before or after.\n * A handler should only return error if the request is for a route the handler owns, and there is a problem with\n * the route, or fulling the specific request.\n */\nexport type RuntimeRequestHandler = (\n\trequest: RequestParser,\n\truntime: IContainerRuntime,\n) => Promise<IResponse | undefined>;\n\n/**\n * A request handler to expose access to all root data stores in the container by id.\n * @param request - the request for the root data store. The first path part must be the data store's ID.\n * @param runtime - the container runtime\n * @returns the result of the request\n */\nexport const rootDataStoreRequestHandler = async (\n\trequest: IRequest,\n\truntime: IContainerRuntime,\n) => {\n\tconst requestParser = RequestParser.create(request);\n\tconst id = requestParser.pathParts[0];\n\tconst wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n\tlet rootDataStore: IFluidRouter;\n\ttry {\n\t\t// getRootDataStore currently throws if the data store is not found\n\t\trootDataStore = await runtime.getRootDataStore(id, wait);\n\t} catch (error) {\n\t\treturn undefined; // continue search\n\t}\n\ttry {\n\t\treturn rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));\n\t} catch (error) {\n\t\treturn { status: 500, mimeType: \"fluid/object\", value: error };\n\t}\n};\n\nexport const createFluidObjectResponse = (\n\tfluidObject: FluidObject,\n): { status: 200; mimeType: \"fluid/object\"; value: FluidObject } => {\n\treturn { status: 200, mimeType: \"fluid/object\", value: fluidObject };\n};\n\nclass LegacyUriHandle<T = FluidObject & IFluidLoadable> implements IFluidHandle<T> {\n\tpublic readonly isAttached = true;\n\n\tpublic get IFluidHandle(): IFluidHandle {\n\t\treturn this;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly absolutePath,\n\t\tpublic readonly runtime: IContainerRuntimeBase,\n\t) {}\n\n\tpublic attachGraph() {\n\t\tassert(false, 0x0ca /* \"Trying to use legacy graph attach!\" */);\n\t}\n\n\tpublic async get(): Promise<any> {\n\t\tconst response = await this.runtime.IFluidHandleContext.resolveHandle({\n\t\t\turl: this.absolutePath,\n\t\t});\n\t\tif (response.status === 200 && response.mimeType === \"fluid/object\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn response.value;\n\t\t}\n\t\tthrow new Error(`Failed to resolve container path ${this.absolutePath}`);\n\t}\n\n\tpublic bind(handle: IFluidHandle) {\n\t\tthrow new Error(\"Cannot bind to LegacyUriHandle\");\n\t}\n}\n\nexport function handleFromLegacyUri<T = FluidObject & IFluidLoadable>(\n\turi: string,\n\truntime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n\treturn new LegacyUriHandle<T>(uri, runtime);\n}\n"]}
1
+ {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAWtD,iEAA8D;AAa9D;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,KAAK,EAC/C,OAAiB,EACjB,OAA0B,EACzB,EAAE;IACH,MAAM,aAAa,GAAG,6BAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,IAAI,aAA2B,CAAC;IAChC,IAAI;QACH,mEAAmE;QACnE,aAAa,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;KACzD;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,SAAS,CAAC,CAAC,kBAAkB;KACpC;IACD,IAAI;QACH,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7E;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KAC/D;AACF,CAAC,CAAC;AAnBW,QAAA,2BAA2B,+BAmBtC;AAEK,MAAM,yBAAyB,GAAG,CACxC,WAAwB,EACwC,EAAE;IAClE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACtE,CAAC,CAAC;AAJW,QAAA,yBAAyB,6BAIpC;AAEF,MAAM,eAAe;IAOpB,YACiB,YAAY,EACZ,OAA8B;QAD9B,iBAAY,GAAZ,YAAY,CAAA;QACZ,YAAO,GAAP,OAAO,CAAuB;QAR/B,eAAU,GAAG,IAAI,CAAC;IAS/B,CAAC;IAPJ,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAOM,WAAW;QACjB,IAAA,qBAAM,EAAC,KAAK,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC;YACrE,GAAG,EAAE,IAAI,CAAC,YAAY;SACtB,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;YACpE,+DAA+D;YAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;SACtB;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACnD,CAAC;CACD;AAED,SAAgB,mBAAmB,CAClC,GAAW,EACX,OAA8B;IAE9B,OAAO,IAAI,eAAe,CAAI,GAAG,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AALD,kDAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIResponse,\n\tIRequest,\n\tIFluidHandle,\n\tIFluidLoadable,\n\tFluidObject,\n\tIFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IContainerRuntimeBase } from \"@fluidframework/runtime-definitions\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\n\n/**\n * A request handler for the container runtime. Each handler should handle a specific request, and return undefined\n * if it does not apply. These handlers are called in series, so there may be other handlers before or after.\n * A handler should only return error if the request is for a route the handler owns, and there is a problem with\n * the route, or fulling the specific request.\n */\nexport type RuntimeRequestHandler = (\n\trequest: RequestParser,\n\truntime: IContainerRuntime,\n) => Promise<IResponse | undefined>;\n\n/**\n * A request handler to expose access to all root data stores in the container by id.\n * @param request - the request for the root data store. The first path part must be the data store's ID.\n * @param runtime - the container runtime\n * @returns the result of the request\n */\nexport const rootDataStoreRequestHandler = async (\n\trequest: IRequest,\n\truntime: IContainerRuntime,\n) => {\n\tconst requestParser = RequestParser.create(request);\n\tconst id = requestParser.pathParts[0];\n\tconst wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n\tlet rootDataStore: IFluidRouter;\n\ttry {\n\t\t// getRootDataStore currently throws if the data store is not found\n\t\trootDataStore = await runtime.getRootDataStore(id, wait);\n\t} catch (error) {\n\t\treturn undefined; // continue search\n\t}\n\ttry {\n\t\treturn rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));\n\t} catch (error) {\n\t\treturn { status: 500, mimeType: \"fluid/object\", value: error };\n\t}\n};\n\nexport const createFluidObjectResponse = (\n\tfluidObject: FluidObject,\n): { status: 200; mimeType: \"fluid/object\"; value: FluidObject } => {\n\treturn { status: 200, mimeType: \"fluid/object\", value: fluidObject };\n};\n\nclass LegacyUriHandle<T = FluidObject & IFluidLoadable> implements IFluidHandle<T> {\n\tpublic readonly isAttached = true;\n\n\tpublic get IFluidHandle(): IFluidHandle {\n\t\treturn this;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly absolutePath,\n\t\tpublic readonly runtime: IContainerRuntimeBase,\n\t) {}\n\n\tpublic attachGraph() {\n\t\tassert(false, 0x0ca /* \"Trying to use legacy graph attach!\" */);\n\t}\n\n\tpublic async get(): Promise<any> {\n\t\tconst response = await this.runtime.IFluidHandleContext.resolveHandle({\n\t\t\turl: this.absolutePath,\n\t\t});\n\t\tif (response.status === 200 && response.mimeType === \"fluid/object\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn response.value;\n\t\t}\n\t\tthrow new Error(`Failed to resolve container path ${this.absolutePath}`);\n\t}\n\n\tpublic bind(handle: IFluidHandle) {\n\t\tthrow new Error(\"Cannot bind to LegacyUriHandle\");\n\t}\n}\n\nexport function handleFromLegacyUri<T = FluidObject & IFluidLoadable>(\n\turi: string,\n\truntime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n\treturn new LegacyUriHandle<T>(uri, runtime);\n}\n"]}
@@ -11,10 +11,9 @@ import { RequestParser } from "@fluidframework/runtime-utils";
11
11
  * @returns the result of the request
12
12
  */
13
13
  export const rootDataStoreRequestHandler = async (request, runtime) => {
14
- var _a;
15
14
  const requestParser = RequestParser.create(request);
16
15
  const id = requestParser.pathParts[0];
17
- const wait = typeof ((_a = request.headers) === null || _a === void 0 ? void 0 : _a.wait) === "boolean" ? request.headers.wait : undefined;
16
+ const wait = typeof request.headers?.wait === "boolean" ? request.headers.wait : undefined;
18
17
  let rootDataStore;
19
18
  try {
20
19
  // getRootDataStore currently throws if the data store is not found
@@ -1 +1 @@
1
- {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAWtD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAa9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAC/C,OAAiB,EACjB,OAA0B,EACzB,EAAE;;IACH,MAAM,aAAa,GAAG,aAA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CAAC,GAAG;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC;YACrE,GAAG,EAAE,IAAI,CAAC,YAAY;SACtB,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;YACpE,+DAA+D;YAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;SACtB;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACnD,CAAC;CACD;AAED,MAAM,UAAU,mBAAmB,CAClC,GAAW,EACX,OAA8B;IAE9B,OAAO,IAAI,eAAe,CAAI,GAAG,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIResponse,\n\tIRequest,\n\tIFluidHandle,\n\tIFluidLoadable,\n\tFluidObject,\n\tIFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IContainerRuntimeBase } from \"@fluidframework/runtime-definitions\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\n\n/**\n * A request handler for the container runtime. Each handler should handle a specific request, and return undefined\n * if it does not apply. These handlers are called in series, so there may be other handlers before or after.\n * A handler should only return error if the request is for a route the handler owns, and there is a problem with\n * the route, or fulling the specific request.\n */\nexport type RuntimeRequestHandler = (\n\trequest: RequestParser,\n\truntime: IContainerRuntime,\n) => Promise<IResponse | undefined>;\n\n/**\n * A request handler to expose access to all root data stores in the container by id.\n * @param request - the request for the root data store. The first path part must be the data store's ID.\n * @param runtime - the container runtime\n * @returns the result of the request\n */\nexport const rootDataStoreRequestHandler = async (\n\trequest: IRequest,\n\truntime: IContainerRuntime,\n) => {\n\tconst requestParser = RequestParser.create(request);\n\tconst id = requestParser.pathParts[0];\n\tconst wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n\tlet rootDataStore: IFluidRouter;\n\ttry {\n\t\t// getRootDataStore currently throws if the data store is not found\n\t\trootDataStore = await runtime.getRootDataStore(id, wait);\n\t} catch (error) {\n\t\treturn undefined; // continue search\n\t}\n\ttry {\n\t\treturn rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));\n\t} catch (error) {\n\t\treturn { status: 500, mimeType: \"fluid/object\", value: error };\n\t}\n};\n\nexport const createFluidObjectResponse = (\n\tfluidObject: FluidObject,\n): { status: 200; mimeType: \"fluid/object\"; value: FluidObject } => {\n\treturn { status: 200, mimeType: \"fluid/object\", value: fluidObject };\n};\n\nclass LegacyUriHandle<T = FluidObject & IFluidLoadable> implements IFluidHandle<T> {\n\tpublic readonly isAttached = true;\n\n\tpublic get IFluidHandle(): IFluidHandle {\n\t\treturn this;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly absolutePath,\n\t\tpublic readonly runtime: IContainerRuntimeBase,\n\t) {}\n\n\tpublic attachGraph() {\n\t\tassert(false, 0x0ca /* \"Trying to use legacy graph attach!\" */);\n\t}\n\n\tpublic async get(): Promise<any> {\n\t\tconst response = await this.runtime.IFluidHandleContext.resolveHandle({\n\t\t\turl: this.absolutePath,\n\t\t});\n\t\tif (response.status === 200 && response.mimeType === \"fluid/object\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn response.value;\n\t\t}\n\t\tthrow new Error(`Failed to resolve container path ${this.absolutePath}`);\n\t}\n\n\tpublic bind(handle: IFluidHandle) {\n\t\tthrow new Error(\"Cannot bind to LegacyUriHandle\");\n\t}\n}\n\nexport function handleFromLegacyUri<T = FluidObject & IFluidLoadable>(\n\turi: string,\n\truntime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n\treturn new LegacyUriHandle<T>(uri, runtime);\n}\n"]}
1
+ {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAWtD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAa9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAC/C,OAAiB,EACjB,OAA0B,EACzB,EAAE;IACH,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,EAAE,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,IAAI,aAA2B,CAAC;IAChC,IAAI;QACH,mEAAmE;QACnE,aAAa,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;KACzD;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,SAAS,CAAC,CAAC,kBAAkB;KACpC;IACD,IAAI;QACH,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7E;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KAC/D;AACF,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACxC,WAAwB,EACwC,EAAE;IAClE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,eAAe;IAOpB,YACiB,YAAY,EACZ,OAA8B;QAD9B,iBAAY,GAAZ,YAAY,CAAA;QACZ,YAAO,GAAP,OAAO,CAAuB;QAR/B,eAAU,GAAG,IAAI,CAAC;IAS/B,CAAC;IAPJ,IAAW,YAAY;QACtB,OAAO,IAAI,CAAC;IACb,CAAC;IAOM,WAAW;QACjB,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,GAAG;QACf,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC;YACrE,GAAG,EAAE,IAAI,CAAC,YAAY;SACtB,CAAC,CAAC;QACH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;YACpE,+DAA+D;YAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;SACtB;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC1E,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACnD,CAAC;CACD;AAED,MAAM,UAAU,mBAAmB,CAClC,GAAW,EACX,OAA8B;IAE9B,OAAO,IAAI,eAAe,CAAI,GAAG,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tIResponse,\n\tIRequest,\n\tIFluidHandle,\n\tIFluidLoadable,\n\tFluidObject,\n\tIFluidRouter,\n} from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { IContainerRuntimeBase } from \"@fluidframework/runtime-definitions\";\nimport { RequestParser } from \"@fluidframework/runtime-utils\";\n\n/**\n * A request handler for the container runtime. Each handler should handle a specific request, and return undefined\n * if it does not apply. These handlers are called in series, so there may be other handlers before or after.\n * A handler should only return error if the request is for a route the handler owns, and there is a problem with\n * the route, or fulling the specific request.\n */\nexport type RuntimeRequestHandler = (\n\trequest: RequestParser,\n\truntime: IContainerRuntime,\n) => Promise<IResponse | undefined>;\n\n/**\n * A request handler to expose access to all root data stores in the container by id.\n * @param request - the request for the root data store. The first path part must be the data store's ID.\n * @param runtime - the container runtime\n * @returns the result of the request\n */\nexport const rootDataStoreRequestHandler = async (\n\trequest: IRequest,\n\truntime: IContainerRuntime,\n) => {\n\tconst requestParser = RequestParser.create(request);\n\tconst id = requestParser.pathParts[0];\n\tconst wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n\tlet rootDataStore: IFluidRouter;\n\ttry {\n\t\t// getRootDataStore currently throws if the data store is not found\n\t\trootDataStore = await runtime.getRootDataStore(id, wait);\n\t} catch (error) {\n\t\treturn undefined; // continue search\n\t}\n\ttry {\n\t\treturn rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));\n\t} catch (error) {\n\t\treturn { status: 500, mimeType: \"fluid/object\", value: error };\n\t}\n};\n\nexport const createFluidObjectResponse = (\n\tfluidObject: FluidObject,\n): { status: 200; mimeType: \"fluid/object\"; value: FluidObject } => {\n\treturn { status: 200, mimeType: \"fluid/object\", value: fluidObject };\n};\n\nclass LegacyUriHandle<T = FluidObject & IFluidLoadable> implements IFluidHandle<T> {\n\tpublic readonly isAttached = true;\n\n\tpublic get IFluidHandle(): IFluidHandle {\n\t\treturn this;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly absolutePath,\n\t\tpublic readonly runtime: IContainerRuntimeBase,\n\t) {}\n\n\tpublic attachGraph() {\n\t\tassert(false, 0x0ca /* \"Trying to use legacy graph attach!\" */);\n\t}\n\n\tpublic async get(): Promise<any> {\n\t\tconst response = await this.runtime.IFluidHandleContext.resolveHandle({\n\t\t\turl: this.absolutePath,\n\t\t});\n\t\tif (response.status === 200 && response.mimeType === \"fluid/object\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn response.value;\n\t\t}\n\t\tthrow new Error(`Failed to resolve container path ${this.absolutePath}`);\n\t}\n\n\tpublic bind(handle: IFluidHandle) {\n\t\tthrow new Error(\"Cannot bind to LegacyUriHandle\");\n\t}\n}\n\nexport function handleFromLegacyUri<T = FluidObject & IFluidLoadable>(\n\turi: string,\n\truntime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n\treturn new LegacyUriHandle<T>(uri, runtime);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/request-handler",
3
- "version": "2.0.0-internal.5.4.0",
3
+ "version": "2.0.0-internal.6.1.0",
4
4
  "description": "A simple request handling library for Fluid Framework",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -36,19 +36,19 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@fluidframework/common-utils": "^1.1.1",
39
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
40
- "@fluidframework/core-interfaces": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
41
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
42
- "@fluidframework/runtime-utils": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0"
39
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.6.1.0 <2.0.0-internal.6.2.0",
40
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.6.1.0 <2.0.0-internal.6.2.0",
41
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.6.1.0 <2.0.0-internal.6.2.0",
42
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.6.1.0 <2.0.0-internal.6.2.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@fluid-tools/build-cli": "^0.21.0",
46
- "@fluidframework/build-common": "^1.2.0",
47
- "@fluidframework/build-tools": "^0.21.0",
45
+ "@fluid-tools/build-cli": "^0.22.0",
46
+ "@fluidframework/build-common": "^2.0.0",
47
+ "@fluidframework/build-tools": "^0.22.0",
48
48
  "@fluidframework/eslint-config-fluid": "^2.0.0",
49
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
50
- "@fluidframework/request-handler-previous": "npm:@fluidframework/request-handler@2.0.0-internal.5.2.0",
51
- "@fluidframework/test-runtime-utils": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
49
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.1.0 <2.0.0-internal.6.2.0",
50
+ "@fluidframework/request-handler-previous": "npm:@fluidframework/request-handler@2.0.0-internal.6.0.0",
51
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.6.1.0 <2.0.0-internal.6.2.0",
52
52
  "@microsoft/api-extractor": "^7.34.4",
53
53
  "@types/diff": "^3.5.1",
54
54
  "@types/mocha": "^9.1.1",