@fluidframework/request-handler 2.0.0-internal.6.1.1 → 2.0.0-internal.6.3.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,13 @@
1
1
  # @fluidframework/request-handler
2
2
 
3
+ ## 2.0.0-internal.6.3.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.6.2.0
8
+
9
+ Dependency updates only.
10
+
3
11
  ## 2.0.0-internal.6.1.0
4
12
 
5
13
  Dependency updates only.
package/README.md CHANGED
@@ -13,9 +13,10 @@ When taking a dependency on a Fluid Framework library, we recommend using a `^`
13
13
  While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
14
14
  library consumers should always prefer `^`.
15
15
 
16
- Note that when depending on a library version of the form 2.0.0-internal.x.y.z, called the Fluid internal version
17
- scheme, you must use a `>= <` dependency range. Standard `^` and `~` ranges will not work as expected. See the
18
- [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
16
+ Note that when depending on a library version of the form `2.0.0-internal.x.y.z`, called the Fluid internal version scheme,
17
+ you must use a `>= <` dependency range (such as `>=2.0.0-internal.x.y.z <2.0.0-internal.w.0.0` where `w` is `x+1`).
18
+ Standard `^` and `~` ranges will not work as expected.
19
+ See the [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
19
20
  package for more information including tools to convert between version schemes.
20
21
 
21
22
  <!-- prettier-ignore-end -->
@@ -5,7 +5,7 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.handleFromLegacyUri = exports.createFluidObjectResponse = exports.rootDataStoreRequestHandler = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
8
+ const core_utils_1 = require("@fluidframework/core-utils");
9
9
  const runtime_utils_1 = require("@fluidframework/runtime-utils");
10
10
  /**
11
11
  * A request handler to expose access to all root data stores in the container by id.
@@ -47,7 +47,7 @@ class LegacyUriHandle {
47
47
  return this;
48
48
  }
49
49
  attachGraph() {
50
- (0, common_utils_1.assert)(false, 0x0ca /* "Trying to use legacy graph attach!" */);
50
+ (0, core_utils_1.assert)(false, 0x0ca /* "Trying to use legacy graph attach!" */);
51
51
  }
52
52
  async get() {
53
53
  const response = await this.runtime.IFluidHandleContext.resolveHandle({
@@ -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,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"]}
1
+ {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AAWpD,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,EA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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/core-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"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { assert } from "@fluidframework/common-utils";
5
+ import { assert } from "@fluidframework/core-utils";
6
6
  import { RequestParser } from "@fluidframework/runtime-utils";
7
7
  /**
8
8
  * A request handler to expose access to all root data stores in the container by id.
@@ -1 +1 @@
1
- {"version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B,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"]}
1
+ {"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAWpD,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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O,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/core-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.6.1.1",
3
+ "version": "2.0.0-internal.6.3.0",
4
4
  "description": "A simple request handling library for Fluid Framework",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "main": "dist/index.js",
15
15
  "module": "lib/index.js",
16
16
  "types": "dist/index.d.ts",
17
- "nyc": {
17
+ "c8": {
18
18
  "all": true,
19
19
  "cache-dir": "nyc/.cache",
20
20
  "exclude": [
@@ -35,26 +35,25 @@
35
35
  "temp-directory": "nyc/.nyc_output"
36
36
  },
37
37
  "dependencies": {
38
- "@fluidframework/common-utils": "^1.1.1",
39
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
40
- "@fluidframework/core-interfaces": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
41
- "@fluidframework/runtime-definitions": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0",
42
- "@fluidframework/runtime-utils": ">=2.0.0-internal.6.1.1 <2.0.0-internal.6.2.0"
38
+ "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
39
+ "@fluidframework/core-interfaces": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
40
+ "@fluidframework/core-utils": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
41
+ "@fluidframework/runtime-definitions": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
42
+ "@fluidframework/runtime-utils": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@fluid-tools/build-cli": "^0.22.0",
46
46
  "@fluidframework/build-common": "^2.0.0",
47
47
  "@fluidframework/build-tools": "^0.22.0",
48
- "@fluidframework/eslint-config-fluid": "^2.0.0",
49
- "@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.1.1 <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.1 <2.0.0-internal.6.2.0",
48
+ "@fluidframework/eslint-config-fluid": "^2.1.0",
49
+ "@fluidframework/mocha-test-setup": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
50
+ "@fluidframework/request-handler-previous": "npm:@fluidframework/request-handler@2.0.0-internal.6.1.1",
51
+ "@fluidframework/test-runtime-utils": ">=2.0.0-internal.6.3.0 <2.0.0-internal.6.4.0",
52
52
  "@microsoft/api-extractor": "^7.34.4",
53
53
  "@types/diff": "^3.5.1",
54
54
  "@types/mocha": "^9.1.1",
55
55
  "@types/node": "^16.18.38",
56
- "@types/random-js": "^1.0.31",
57
- "concurrently": "^7.6.0",
56
+ "c8": "^7.7.1",
58
57
  "copyfiles": "^2.4.1",
59
58
  "cross-env": "^7.0.3",
60
59
  "diff": "^3.5.0",
@@ -63,9 +62,7 @@
63
62
  "mocha-json-output-reporter": "^2.0.1",
64
63
  "mocha-multi-reporters": "^1.5.1",
65
64
  "moment": "^2.21.0",
66
- "nyc": "^15.1.0",
67
65
  "prettier": "~2.6.2",
68
- "random-js": "^1.0.8",
69
66
  "rimraf": "^4.4.0",
70
67
  "typescript": "~4.5.5"
71
68
  },
@@ -80,7 +77,7 @@
80
77
  "build:esnext": "tsc --project ./tsconfig.esnext.json",
81
78
  "build:test": "tsc --project ./src/test/tsconfig.json",
82
79
  "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
83
- "clean": "rimraf --glob \"dist\" \"lib\" \"*.tsbuildinfo\" \"*.build.log\"",
80
+ "clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
84
81
  "eslint": "eslint --format stylish src",
85
82
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
86
83
  "format": "npm run prettier:fix",
@@ -89,9 +86,8 @@
89
86
  "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
90
87
  "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
91
88
  "test": "npm run test:mocha",
92
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
93
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
94
- "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
89
+ "test:coverage": "c8 npm test",
90
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup",
95
91
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
96
92
  "tsc": "tsc",
97
93
  "typetests:gen": "fluid-type-test-generator",
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
7
  import {
8
8
  IResponse,
9
9
  IRequest,