@fluidframework/request-handler 0.54.2 → 0.55.0-48551
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/.eslintrc.js +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/requestHandlers.d.ts +1 -12
- package/dist/requestHandlers.d.ts.map +1 -1
- package/dist/requestHandlers.js +9 -16
- package/dist/requestHandlers.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/requestHandlers.d.ts +1 -12
- package/lib/requestHandlers.d.ts.map +1 -1
- package/lib/requestHandlers.js +9 -15
- package/lib/requestHandlers.js.map +1 -1
- package/package.json +16 -15
- package/src/packageVersion.ts +1 -1
- package/src/requestHandlers.ts +9 -17
package/.eslintrc.js
CHANGED
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/request-handler";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.55.0-48551";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,oCAAoC,CAAC;AACzD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,oCAAoC,CAAC;AACzD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/request-handler";
|
|
11
|
-
exports.pkgVersion = "0.
|
|
11
|
+
exports.pkgVersion = "0.55.0-48551";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,iCAAiC,CAAC;AAC5C,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,iCAAiC,CAAC;AAC5C,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/request-handler\";\nexport const pkgVersion = \"0.55.0-48551\";\n"]}
|
|
@@ -13,24 +13,13 @@ import { RequestParser } from "@fluidframework/runtime-utils";
|
|
|
13
13
|
* the route, or fulling the specific request.
|
|
14
14
|
*/
|
|
15
15
|
export declare type RuntimeRequestHandler = (request: RequestParser, runtime: IContainerRuntime) => Promise<IResponse | undefined>;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated - please avoid adding new references to this API! Instead prefer rootDataObjectRequestHandler.
|
|
18
|
-
* It exposes internal container guts to external world, which is not ideal.
|
|
19
|
-
* It also relies heavily on internal routing schema (formation of handle URIs) which will change in future
|
|
20
|
-
* And last, but not least, it does not allow any policy to be implemented around GC of data stores exposed
|
|
21
|
-
* through internal URIs. I.e. if there are no other references to such objects, they will be GC'd and
|
|
22
|
-
* external links would get broken. Maybe that's what is needed in some cases, but better, more centralized
|
|
23
|
-
* handling of external URI to internal handle is required (in future, we will support weak handle references,
|
|
24
|
-
* that will allow any GC policy to be implemented by container authors.)
|
|
25
|
-
*/
|
|
26
|
-
export declare const innerRequestHandler: (request: IRequest, runtime: IContainerRuntimeBase) => Promise<IResponse>;
|
|
27
16
|
/**
|
|
28
17
|
* A request handler to expose access to all root data stores in the container by id.
|
|
29
18
|
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
30
19
|
* @param runtime - the container runtime
|
|
31
20
|
* @returns the result of the request
|
|
32
21
|
*/
|
|
33
|
-
export declare const rootDataStoreRequestHandler: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
|
|
22
|
+
export declare const rootDataStoreRequestHandler: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse | undefined>;
|
|
34
23
|
export declare const createFluidObjectResponse: (fluidObject: FluidObject) => {
|
|
35
24
|
status: 200;
|
|
36
25
|
mimeType: "fluid/object";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandlers.d.ts","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"requestHandlers.d.ts","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,WAAW,EAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D;;;;;GAKG;AACH,oBAAY,qBAAqB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,KAChF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAAmB,QAAQ,WAAW,iBAAiB,mCAgB9F,CAAC;AAEF,eAAO,MAAM,yBAAyB,gBAAiB,WAAW,KAC9D;IAAC,QAAQ,GAAG,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAE7D,CAAC;AA4BF,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,EAC/E,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC/B,YAAY,CAAC,CAAC,CAAC,CAEjB"}
|
package/dist/requestHandlers.js
CHANGED
|
@@ -4,21 +4,9 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.handleFromLegacyUri = exports.createFluidObjectResponse = exports.rootDataStoreRequestHandler =
|
|
7
|
+
exports.handleFromLegacyUri = exports.createFluidObjectResponse = exports.rootDataStoreRequestHandler = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
9
|
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated - please avoid adding new references to this API! Instead prefer rootDataObjectRequestHandler.
|
|
12
|
-
* It exposes internal container guts to external world, which is not ideal.
|
|
13
|
-
* It also relies heavily on internal routing schema (formation of handle URIs) which will change in future
|
|
14
|
-
* And last, but not least, it does not allow any policy to be implemented around GC of data stores exposed
|
|
15
|
-
* through internal URIs. I.e. if there are no other references to such objects, they will be GC'd and
|
|
16
|
-
* external links would get broken. Maybe that's what is needed in some cases, but better, more centralized
|
|
17
|
-
* handling of external URI to internal handle is required (in future, we will support weak handle references,
|
|
18
|
-
* that will allow any GC policy to be implemented by container authors.)
|
|
19
|
-
*/
|
|
20
|
-
const innerRequestHandler = async (request, runtime) => runtime.IFluidHandleContext.resolveHandle(request);
|
|
21
|
-
exports.innerRequestHandler = innerRequestHandler;
|
|
22
10
|
/**
|
|
23
11
|
* A request handler to expose access to all root data stores in the container by id.
|
|
24
12
|
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
@@ -30,13 +18,19 @@ const rootDataStoreRequestHandler = async (request, runtime) => {
|
|
|
30
18
|
const requestParser = runtime_utils_1.RequestParser.create(request);
|
|
31
19
|
const id = requestParser.pathParts[0];
|
|
32
20
|
const wait = typeof ((_a = request.headers) === null || _a === void 0 ? void 0 : _a.wait) === "boolean" ? request.headers.wait : undefined;
|
|
21
|
+
let rootDataStore;
|
|
33
22
|
try {
|
|
34
23
|
// getRootDataStore currently throws if the data store is not found
|
|
35
|
-
|
|
24
|
+
rootDataStore = await runtime.getRootDataStore(id, wait);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
return undefined; // continue search
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
36
30
|
return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));
|
|
37
31
|
}
|
|
38
32
|
catch (error) {
|
|
39
|
-
return
|
|
33
|
+
return { status: 500, mimeType: "fluid/object", value: error };
|
|
40
34
|
}
|
|
41
35
|
};
|
|
42
36
|
exports.rootDataStoreRequestHandler = rootDataStoreRequestHandler;
|
|
@@ -66,7 +60,6 @@ class LegacyUriHandle {
|
|
|
66
60
|
throw new Error("Cannot bind to LegacyUriHandle");
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
|
-
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
|
70
63
|
function handleFromLegacyUri(uri, runtime) {
|
|
71
64
|
return new LegacyUriHandle(uri, runtime);
|
|
72
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;
|
|
1
|
+
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAYtD,iEAA8D;AAW9D;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,KAAK,EAAE,OAAiB,EAAE,OAA0B,EAAE,EAAE;;IAC/F,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,cAAO,OAAO,CAAC,OAAO,0CAAE,IAAI,CAAA,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,IAAI,aAA2B,CAAC;IAChC,IAAI;QACA,mEAAmE;QACnE,aAAa,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;KAC5D;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,SAAS,CAAC,CAAC,kBAAkB;KACvC;IACD,IAAI;QACA,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KAChF;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KAClE;AACL,CAAC,CAAC;AAhBW,QAAA,2BAA2B,+BAgBtC;AAEK,MAAM,yBAAyB,GAAG,CAAC,WAAwB,EACF,EAAE;IAC9D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACzE,CAAC,CAAC;AAHW,QAAA,yBAAyB,6BAGpC;AAEF,MAAM,eAAe;IAKjB,YAAmC,YAAY,EAAkB,OAA8B;QAA5D,iBAAY,GAAZ,YAAY,CAAA;QAAkB,YAAO,GAAP,OAAO,CAAuB;QAJ/E,eAAU,GAAG,IAAI,CAAC;IAKlC,CAAC;IAHD,IAAW,YAAY,KAAmB,OAAO,IAAI,CAAC,CAAC,CAAC;IAKjD,WAAW;QACd,qBAAM,CAAC,KAAK,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;IACpE,CAAC;IAEM,KAAK,CAAC,GAAG;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAClG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;YACjE,+DAA+D;YAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;SACzB;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;CACJ;AAED,SAAgB,mBAAmB,CAC/B,GAAW,EACX,OAA8B;IAE9B,OAAO,IAAI,eAAe,CAAI,GAAG,EAAE,OAAO,CAAC,CAAC;AAChD,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 IFluidObject,\n IResponse,\n IRequest,\n IFluidHandle,\n IFluidLoadable,\n FluidObject,\n IFluidRouter,\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 = (request: RequestParser, runtime: 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 (request: IRequest, runtime: IContainerRuntime) => {\n const requestParser = RequestParser.create(request);\n const id = requestParser.pathParts[0];\n const wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n let rootDataStore: IFluidRouter;\n try {\n // getRootDataStore currently throws if the data store is not found\n rootDataStore = await runtime.getRootDataStore(id, wait);\n } catch (error) {\n return undefined; // continue search\n }\n try {\n return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));\n } catch (error) {\n return { status: 500, mimeType: \"fluid/object\", value: error };\n }\n};\n\nexport const createFluidObjectResponse = (fluidObject: FluidObject):\n {status: 200, mimeType: \"fluid/object\", value: FluidObject} => {\n return { status: 200, mimeType: \"fluid/object\", value: fluidObject };\n};\n\nclass LegacyUriHandle<T = IFluidObject & FluidObject & IFluidLoadable> implements IFluidHandle<T> {\n public readonly isAttached = true;\n\n public get IFluidHandle(): IFluidHandle { return this; }\n\n public constructor(public readonly absolutePath, public readonly runtime: IContainerRuntimeBase) {\n }\n\n public attachGraph() {\n assert(false, 0x0ca /* \"Trying to use legacy graph attach!\" */);\n }\n\n public async get(): Promise<any> {\n const response = await this.runtime.IFluidHandleContext.resolveHandle({ url: this.absolutePath });\n if (response.status === 200 && response.mimeType === \"fluid/object\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n }\n throw new Error(`Failed to resolve container path ${this.absolutePath}`);\n }\n\n public bind(handle: IFluidHandle) {\n throw new Error(\"Cannot bind to LegacyUriHandle\");\n }\n}\n\nexport function handleFromLegacyUri<T = IFluidObject & FluidObject & IFluidLoadable>(\n uri: string,\n runtime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n return new LegacyUriHandle<T>(uri, runtime);\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/request-handler";
|
|
8
|
-
export declare const pkgVersion = "0.
|
|
8
|
+
export declare const pkgVersion = "0.55.0-48551";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,oCAAoC,CAAC;AACzD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,oCAAoC,CAAC;AACzD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,iCAAiC,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,iCAAiC,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/request-handler\";\nexport const pkgVersion = \"0.55.0-48551\";\n"]}
|
package/lib/requestHandlers.d.ts
CHANGED
|
@@ -13,24 +13,13 @@ import { RequestParser } from "@fluidframework/runtime-utils";
|
|
|
13
13
|
* the route, or fulling the specific request.
|
|
14
14
|
*/
|
|
15
15
|
export declare type RuntimeRequestHandler = (request: RequestParser, runtime: IContainerRuntime) => Promise<IResponse | undefined>;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated - please avoid adding new references to this API! Instead prefer rootDataObjectRequestHandler.
|
|
18
|
-
* It exposes internal container guts to external world, which is not ideal.
|
|
19
|
-
* It also relies heavily on internal routing schema (formation of handle URIs) which will change in future
|
|
20
|
-
* And last, but not least, it does not allow any policy to be implemented around GC of data stores exposed
|
|
21
|
-
* through internal URIs. I.e. if there are no other references to such objects, they will be GC'd and
|
|
22
|
-
* external links would get broken. Maybe that's what is needed in some cases, but better, more centralized
|
|
23
|
-
* handling of external URI to internal handle is required (in future, we will support weak handle references,
|
|
24
|
-
* that will allow any GC policy to be implemented by container authors.)
|
|
25
|
-
*/
|
|
26
|
-
export declare const innerRequestHandler: (request: IRequest, runtime: IContainerRuntimeBase) => Promise<IResponse>;
|
|
27
16
|
/**
|
|
28
17
|
* A request handler to expose access to all root data stores in the container by id.
|
|
29
18
|
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
30
19
|
* @param runtime - the container runtime
|
|
31
20
|
* @returns the result of the request
|
|
32
21
|
*/
|
|
33
|
-
export declare const rootDataStoreRequestHandler: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
|
|
22
|
+
export declare const rootDataStoreRequestHandler: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse | undefined>;
|
|
34
23
|
export declare const createFluidObjectResponse: (fluidObject: FluidObject) => {
|
|
35
24
|
status: 200;
|
|
36
25
|
mimeType: "fluid/object";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandlers.d.ts","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,WAAW,
|
|
1
|
+
{"version":3,"file":"requestHandlers.d.ts","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,WAAW,EAEd,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D;;;;;GAKG;AACH,oBAAY,qBAAqB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,KAChF,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAAmB,QAAQ,WAAW,iBAAiB,mCAgB9F,CAAC;AAEF,eAAO,MAAM,yBAAyB,gBAAiB,WAAW,KAC9D;IAAC,QAAQ,GAAG,CAAC;IAAC,QAAQ,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAE7D,CAAC;AA4BF,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,EAC/E,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC/B,YAAY,CAAC,CAAC,CAAC,CAEjB"}
|
package/lib/requestHandlers.js
CHANGED
|
@@ -3,18 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "@fluidframework/common-utils";
|
|
6
|
-
import {
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated - please avoid adding new references to this API! Instead prefer rootDataObjectRequestHandler.
|
|
9
|
-
* It exposes internal container guts to external world, which is not ideal.
|
|
10
|
-
* It also relies heavily on internal routing schema (formation of handle URIs) which will change in future
|
|
11
|
-
* And last, but not least, it does not allow any policy to be implemented around GC of data stores exposed
|
|
12
|
-
* through internal URIs. I.e. if there are no other references to such objects, they will be GC'd and
|
|
13
|
-
* external links would get broken. Maybe that's what is needed in some cases, but better, more centralized
|
|
14
|
-
* handling of external URI to internal handle is required (in future, we will support weak handle references,
|
|
15
|
-
* that will allow any GC policy to be implemented by container authors.)
|
|
16
|
-
*/
|
|
17
|
-
export const innerRequestHandler = async (request, runtime) => runtime.IFluidHandleContext.resolveHandle(request);
|
|
6
|
+
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
18
7
|
/**
|
|
19
8
|
* A request handler to expose access to all root data stores in the container by id.
|
|
20
9
|
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
@@ -26,13 +15,19 @@ export const rootDataStoreRequestHandler = async (request, runtime) => {
|
|
|
26
15
|
const requestParser = RequestParser.create(request);
|
|
27
16
|
const id = requestParser.pathParts[0];
|
|
28
17
|
const wait = typeof ((_a = request.headers) === null || _a === void 0 ? void 0 : _a.wait) === "boolean" ? request.headers.wait : undefined;
|
|
18
|
+
let rootDataStore;
|
|
29
19
|
try {
|
|
30
20
|
// getRootDataStore currently throws if the data store is not found
|
|
31
|
-
|
|
21
|
+
rootDataStore = await runtime.getRootDataStore(id, wait);
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return undefined; // continue search
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
32
27
|
return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));
|
|
33
28
|
}
|
|
34
29
|
catch (error) {
|
|
35
|
-
return
|
|
30
|
+
return { status: 500, mimeType: "fluid/object", value: error };
|
|
36
31
|
}
|
|
37
32
|
};
|
|
38
33
|
export const createFluidObjectResponse = (fluidObject) => {
|
|
@@ -60,7 +55,6 @@ class LegacyUriHandle {
|
|
|
60
55
|
throw new Error("Cannot bind to LegacyUriHandle");
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
|
-
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
|
64
58
|
export function handleFromLegacyUri(uri, runtime) {
|
|
65
59
|
return new LegacyUriHandle(uri, runtime);
|
|
66
60
|
}
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAYtD,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAW9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,EAAE,OAAiB,EAAE,OAA0B,EAAE,EAAE;;IAC/F,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,cAAO,OAAO,CAAC,OAAO,0CAAE,IAAI,CAAA,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3F,IAAI,aAA2B,CAAC;IAChC,IAAI;QACA,mEAAmE;QACnE,aAAa,GAAG,MAAM,OAAO,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;KAC5D;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,SAAS,CAAC,CAAC,kBAAkB;KACvC;IACD,IAAI;QACA,OAAO,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KAChF;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;KAClE;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,WAAwB,EACF,EAAE;IAC9D,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AACzE,CAAC,CAAC;AAEF,MAAM,eAAe;IAKjB,YAAmC,YAAY,EAAkB,OAA8B;QAA5D,iBAAY,GAAZ,YAAY,CAAA;QAAkB,YAAO,GAAP,OAAO,CAAuB;QAJ/E,eAAU,GAAG,IAAI,CAAC;IAKlC,CAAC;IAHD,IAAW,YAAY,KAAmB,OAAO,IAAI,CAAC,CAAC,CAAC;IAKjD,WAAW;QACd,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,0CAA0C,CAAC,CAAC;IACpE,CAAC;IAEM,KAAK,CAAC,GAAG;QACZ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QAClG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,QAAQ,KAAK,cAAc,EAAE;YACjE,+DAA+D;YAC/D,OAAO,QAAQ,CAAC,KAAK,CAAC;SACzB;QACD,MAAM,IAAI,KAAK,CAAC,oCAAoC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC7E,CAAC;IAEM,IAAI,CAAC,MAAoB;QAC5B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACtD,CAAC;CACJ;AAED,MAAM,UAAU,mBAAmB,CAC/B,GAAW,EACX,OAA8B;IAE9B,OAAO,IAAI,eAAe,CAAI,GAAG,EAAE,OAAO,CAAC,CAAC;AAChD,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 IFluidObject,\n IResponse,\n IRequest,\n IFluidHandle,\n IFluidLoadable,\n FluidObject,\n IFluidRouter,\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 = (request: RequestParser, runtime: 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 (request: IRequest, runtime: IContainerRuntime) => {\n const requestParser = RequestParser.create(request);\n const id = requestParser.pathParts[0];\n const wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n let rootDataStore: IFluidRouter;\n try {\n // getRootDataStore currently throws if the data store is not found\n rootDataStore = await runtime.getRootDataStore(id, wait);\n } catch (error) {\n return undefined; // continue search\n }\n try {\n return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));\n } catch (error) {\n return { status: 500, mimeType: \"fluid/object\", value: error };\n }\n};\n\nexport const createFluidObjectResponse = (fluidObject: FluidObject):\n {status: 200, mimeType: \"fluid/object\", value: FluidObject} => {\n return { status: 200, mimeType: \"fluid/object\", value: fluidObject };\n};\n\nclass LegacyUriHandle<T = IFluidObject & FluidObject & IFluidLoadable> implements IFluidHandle<T> {\n public readonly isAttached = true;\n\n public get IFluidHandle(): IFluidHandle { return this; }\n\n public constructor(public readonly absolutePath, public readonly runtime: IContainerRuntimeBase) {\n }\n\n public attachGraph() {\n assert(false, 0x0ca /* \"Trying to use legacy graph attach!\" */);\n }\n\n public async get(): Promise<any> {\n const response = await this.runtime.IFluidHandleContext.resolveHandle({ url: this.absolutePath });\n if (response.status === 200 && response.mimeType === \"fluid/object\") {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return response.value;\n }\n throw new Error(`Failed to resolve container path ${this.absolutePath}`);\n }\n\n public bind(handle: IFluidHandle) {\n throw new Error(\"Cannot bind to LegacyUriHandle\");\n }\n}\n\nexport function handleFromLegacyUri<T = IFluidObject & FluidObject & IFluidLoadable>(\n uri: string,\n runtime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n return 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": "0.
|
|
3
|
+
"version": "0.55.0-48551",
|
|
4
4
|
"description": "A simple request handling library for Fluid Framework",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": "https://github.com/microsoft/FluidFramework",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
24
24
|
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
25
25
|
"eslint": "eslint --format stylish src",
|
|
26
|
-
"eslint:fix": "eslint --format stylish src --fix",
|
|
26
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
27
27
|
"lint": "npm run eslint",
|
|
28
28
|
"lint:fix": "npm run eslint:fix",
|
|
29
29
|
"test": "npm run test:mocha",
|
|
@@ -56,33 +56,34 @@
|
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@fluidframework/common-utils": "^0.32.1",
|
|
59
|
-
"@fluidframework/container-runtime-definitions": "
|
|
59
|
+
"@fluidframework/container-runtime-definitions": "0.55.0-48551",
|
|
60
60
|
"@fluidframework/core-interfaces": "^0.41.0",
|
|
61
|
-
"@fluidframework/runtime-definitions": "
|
|
62
|
-
"@fluidframework/runtime-utils": "
|
|
61
|
+
"@fluidframework/runtime-definitions": "0.55.0-48551",
|
|
62
|
+
"@fluidframework/runtime-utils": "0.55.0-48551"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@fluidframework/build-common": "^0.23.0",
|
|
66
|
-
"@fluidframework/eslint-config-fluid": "^0.
|
|
67
|
-
"@fluidframework/mocha-test-setup": "
|
|
68
|
-
"@fluidframework/test-runtime-utils": "
|
|
66
|
+
"@fluidframework/eslint-config-fluid": "^0.25.0-0",
|
|
67
|
+
"@fluidframework/mocha-test-setup": "0.55.0-48551",
|
|
68
|
+
"@fluidframework/test-runtime-utils": "0.55.0-48551",
|
|
69
69
|
"@microsoft/api-extractor": "^7.16.1",
|
|
70
|
+
"@rushstack/eslint-config": "^2.5.1",
|
|
70
71
|
"@types/diff": "^3.5.1",
|
|
71
72
|
"@types/mocha": "^8.2.2",
|
|
72
73
|
"@types/random-js": "^1.0.31",
|
|
73
|
-
"@typescript-eslint/eslint-plugin": "~
|
|
74
|
-
"@typescript-eslint/parser": "~
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "~5.9.0",
|
|
75
|
+
"@typescript-eslint/parser": "~5.9.0",
|
|
75
76
|
"concurrently": "^6.2.0",
|
|
76
77
|
"copyfiles": "^2.1.0",
|
|
77
78
|
"cross-env": "^7.0.2",
|
|
78
79
|
"diff": "^3.5.0",
|
|
79
|
-
"eslint": "~
|
|
80
|
+
"eslint": "~8.6.0",
|
|
81
|
+
"eslint-plugin-editorconfig": "~3.2.0",
|
|
80
82
|
"eslint-plugin-eslint-comments": "~3.2.0",
|
|
81
|
-
"eslint-plugin-import": "~2.
|
|
83
|
+
"eslint-plugin-import": "~2.25.4",
|
|
82
84
|
"eslint-plugin-no-null": "~1.0.2",
|
|
83
|
-
"eslint-plugin-
|
|
84
|
-
"eslint-plugin-
|
|
85
|
-
"eslint-plugin-unicorn": "~26.0.1",
|
|
85
|
+
"eslint-plugin-react": "~7.28.0",
|
|
86
|
+
"eslint-plugin-unicorn": "~40.0.0",
|
|
86
87
|
"mocha": "^8.4.0",
|
|
87
88
|
"nyc": "^15.0.0",
|
|
88
89
|
"random-js": "^1.0.8",
|
package/src/packageVersion.ts
CHANGED
package/src/requestHandlers.ts
CHANGED
|
@@ -11,10 +11,11 @@ import {
|
|
|
11
11
|
IFluidHandle,
|
|
12
12
|
IFluidLoadable,
|
|
13
13
|
FluidObject,
|
|
14
|
+
IFluidRouter,
|
|
14
15
|
} from "@fluidframework/core-interfaces";
|
|
15
16
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
16
17
|
import { IContainerRuntimeBase } from "@fluidframework/runtime-definitions";
|
|
17
|
-
import {
|
|
18
|
+
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* A request handler for the container runtime. Each handler should handle a specific request, and return undefined
|
|
@@ -25,19 +26,6 @@ import { create404Response, RequestParser } from "@fluidframework/runtime-utils"
|
|
|
25
26
|
export type RuntimeRequestHandler = (request: RequestParser, runtime: IContainerRuntime)
|
|
26
27
|
=> Promise<IResponse | undefined>;
|
|
27
28
|
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated - please avoid adding new references to this API! Instead prefer rootDataObjectRequestHandler.
|
|
30
|
-
* It exposes internal container guts to external world, which is not ideal.
|
|
31
|
-
* It also relies heavily on internal routing schema (formation of handle URIs) which will change in future
|
|
32
|
-
* And last, but not least, it does not allow any policy to be implemented around GC of data stores exposed
|
|
33
|
-
* through internal URIs. I.e. if there are no other references to such objects, they will be GC'd and
|
|
34
|
-
* external links would get broken. Maybe that's what is needed in some cases, but better, more centralized
|
|
35
|
-
* handling of external URI to internal handle is required (in future, we will support weak handle references,
|
|
36
|
-
* that will allow any GC policy to be implemented by container authors.)
|
|
37
|
-
*/
|
|
38
|
-
export const innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>
|
|
39
|
-
runtime.IFluidHandleContext.resolveHandle(request);
|
|
40
|
-
|
|
41
29
|
/**
|
|
42
30
|
* A request handler to expose access to all root data stores in the container by id.
|
|
43
31
|
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
@@ -48,12 +36,17 @@ export const rootDataStoreRequestHandler = async (request: IRequest, runtime: IC
|
|
|
48
36
|
const requestParser = RequestParser.create(request);
|
|
49
37
|
const id = requestParser.pathParts[0];
|
|
50
38
|
const wait = typeof request.headers?.wait === "boolean" ? request.headers.wait : undefined;
|
|
39
|
+
let rootDataStore: IFluidRouter;
|
|
51
40
|
try {
|
|
52
41
|
// getRootDataStore currently throws if the data store is not found
|
|
53
|
-
|
|
42
|
+
rootDataStore = await runtime.getRootDataStore(id, wait);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return undefined; // continue search
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
54
47
|
return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));
|
|
55
48
|
} catch (error) {
|
|
56
|
-
return
|
|
49
|
+
return { status: 500, mimeType: "fluid/object", value: error };
|
|
57
50
|
}
|
|
58
51
|
};
|
|
59
52
|
|
|
@@ -88,7 +81,6 @@ class LegacyUriHandle<T = IFluidObject & FluidObject & IFluidLoadable> implement
|
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
83
|
|
|
91
|
-
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
|
|
92
84
|
export function handleFromLegacyUri<T = IFluidObject & FluidObject & IFluidLoadable>(
|
|
93
85
|
uri: string,
|
|
94
86
|
runtime: IContainerRuntimeBase,
|