@fluidframework/request-handler 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
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 +5 -7
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +119 -0
- package/README.md +37 -1
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/request-handler.api.md +20 -0
- package/dist/index.cjs +10 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/request-handler-alpha.d.ts +19 -0
- package/dist/request-handler-beta.d.ts +14 -0
- package/dist/request-handler-public.d.ts +14 -0
- package/dist/request-handler-untrimmed.d.ts +24 -0
- package/dist/requestHandlers.cjs +7 -0
- package/dist/requestHandlers.cjs.map +1 -0
- package/dist/requestHandlers.d.ts +5 -16
- package/dist/requestHandlers.d.ts.map +1 -1
- package/dist/{runtimeRequestHandlerBuilder.js → runtimeRequestHandlerBuilder.cjs} +13 -6
- package/dist/runtimeRequestHandlerBuilder.cjs.map +1 -0
- package/dist/runtimeRequestHandlerBuilder.d.ts +4 -8
- package/dist/runtimeRequestHandlerBuilder.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/index.d.mts +7 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/{index.js → index.mjs} +2 -3
- package/lib/index.mjs.map +1 -0
- package/lib/request-handler-alpha.d.mts +19 -0
- package/lib/request-handler-beta.d.mts +14 -0
- package/lib/request-handler-public.d.mts +14 -0
- package/lib/request-handler-untrimmed.d.mts +24 -0
- package/lib/requestHandlers.d.mts +18 -0
- package/lib/requestHandlers.d.mts.map +1 -0
- package/lib/{index.d.ts → requestHandlers.mjs} +2 -3
- package/lib/requestHandlers.mjs.map +1 -0
- package/lib/runtimeRequestHandlerBuilder.d.mts +14 -0
- package/lib/runtimeRequestHandlerBuilder.d.mts.map +1 -0
- package/lib/{runtimeRequestHandlerBuilder.js → runtimeRequestHandlerBuilder.mjs} +13 -5
- package/lib/runtimeRequestHandlerBuilder.mjs.map +1 -0
- package/package.json +109 -61
- package/prettier.config.cjs +8 -0
- package/src/index.ts +2 -2
- package/src/requestHandlers.ts +8 -74
- package/src/runtimeRequestHandlerBuilder.ts +33 -23
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/dist/index.js +0 -19
- package/dist/index.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/dist/requestHandlers.js +0 -67
- package/dist/requestHandlers.js.map +0 -1
- package/dist/runtimeRequestHandlerBuilder.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packageVersion.d.ts +0 -9
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js +0 -9
- package/lib/packageVersion.js.map +0 -1
- package/lib/requestHandlers.d.ts +0 -29
- package/lib/requestHandlers.d.ts.map +0 -1
- package/lib/requestHandlers.js +0 -61
- package/lib/requestHandlers.js.map +0 -1
- package/lib/runtimeRequestHandlerBuilder.d.ts +0 -18
- package/lib/runtimeRequestHandlerBuilder.d.ts.map +0 -1
- package/lib/runtimeRequestHandlerBuilder.js.map +0 -1
- package/src/packageVersion.ts +0 -9
- package/tsconfig.esnext.json +0 -7
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
7
|
+
import { RuntimeRequestHandler } from "./requestHandlers.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildRuntimeRequestHandler(...handlers: RuntimeRequestHandler[]): (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
|
|
14
|
+
//# sourceMappingURL=runtimeRequestHandlerBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeRequestHandlerBuilder.d.ts","sourceRoot":"","sources":["../src/runtimeRequestHandlerBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iCAAiC;OAC9D,EAAE,iBAAiB,EAAE,MAAM,+CAA+C;OAG1E,EAAE,qBAAqB,EAAE;AA6BhC;;;;GAIG;AAEH,wBAAgB,0BAA0B,CAAC,GAAG,QAAQ,EAAE,qBAAqB,EAAE,aAGvD,QAAQ,WAAW,iBAAiB,wBAE3D"}
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { RequestParser, create404Response } from "@fluidframework/runtime-utils";
|
|
6
6
|
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
* The RuntimeRequestHandlerBuilder creates a runtime request handler based on request handlers.
|
|
8
|
+
* The provided handlers sequentially applied until one is able to satisfy the request.
|
|
9
|
+
*/
|
|
10
|
+
class RuntimeRequestHandlerBuilder {
|
|
11
11
|
constructor() {
|
|
12
|
+
// eslint-disable-next-line import/no-deprecated
|
|
12
13
|
this.handlers = [];
|
|
13
14
|
}
|
|
15
|
+
// eslint-disable-next-line import/no-deprecated
|
|
14
16
|
pushHandler(...handlers) {
|
|
15
17
|
if (handlers !== undefined) {
|
|
16
18
|
this.handlers.push(...handlers);
|
|
@@ -27,9 +29,15 @@ export class RuntimeRequestHandlerBuilder {
|
|
|
27
29
|
return create404Response(request);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
34
|
+
*
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
// eslint-disable-next-line import/no-deprecated
|
|
30
38
|
export function buildRuntimeRequestHandler(...handlers) {
|
|
31
39
|
const builder = new RuntimeRequestHandlerBuilder();
|
|
32
40
|
builder.pushHandler(...handlers);
|
|
33
41
|
return async (request, runtime) => builder.handleRequest(request, runtime);
|
|
34
42
|
}
|
|
35
|
-
//# sourceMappingURL=runtimeRequestHandlerBuilder.
|
|
43
|
+
//# sourceMappingURL=runtimeRequestHandlerBuilder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeRequestHandlerBuilder.mjs","sourceRoot":"","sources":["../src/runtimeRequestHandlerBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAII,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,+BAA+B;AAIhF;;;GAGG;AACH,MAAM,4BAA4B;IAAlC;QACC,gDAAgD;QAC/B,aAAQ,GAA4B,EAAE,CAAC;IAmBzD,CAAC;IAjBA,gDAAgD;IACzC,WAAW,CAAC,GAAG,QAAiC;QACtD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC3B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;SAChC;IACF,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,OAAiB,EAAE,OAA0B;QACvE,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;YACpC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChD,IAAI,QAAQ,KAAK,SAAS,EAAE;gBAC3B,OAAO,QAAQ,CAAC;aAChB;SACD;QACD,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;CACD;AAED;;;;GAIG;AACH,gDAAgD;AAChD,MAAM,UAAU,0BAA0B,CAAC,GAAG,QAAiC;IAC9E,MAAM,OAAO,GAAG,IAAI,4BAA4B,EAAE,CAAC;IACnD,OAAO,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC;IACjC,OAAO,KAAK,EAAE,OAAiB,EAAE,OAA0B,EAAE,EAAE,CAC9D,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\n// eslint-disable-next-line import/no-deprecated\nimport { RuntimeRequestHandler } from \"./requestHandlers\";\n\n/**\n * The RuntimeRequestHandlerBuilder creates a runtime request handler based on request handlers.\n * The provided handlers sequentially applied until one is able to satisfy the request.\n */\nclass RuntimeRequestHandlerBuilder {\n\t// eslint-disable-next-line import/no-deprecated\n\tprivate readonly handlers: RuntimeRequestHandler[] = [];\n\n\t// eslint-disable-next-line import/no-deprecated\n\tpublic pushHandler(...handlers: RuntimeRequestHandler[]) {\n\t\tif (handlers !== undefined) {\n\t\t\tthis.handlers.push(...handlers);\n\t\t}\n\t}\n\n\tpublic async handleRequest(request: IRequest, runtime: IContainerRuntime): Promise<IResponse> {\n\t\tconst parser = RequestParser.create(request);\n\t\tfor (const handler of this.handlers) {\n\t\t\tconst response = await handler(parser, runtime);\n\t\t\tif (response !== undefined) {\n\t\t\t\treturn response;\n\t\t\t}\n\t\t}\n\t\treturn create404Response(request);\n\t}\n}\n\n/**\n * @deprecated Will be removed once Loader LTS version is \"2.0.0-internal.7.0.0\". Migrate all usage of IFluidRouter to the \"entryPoint\" pattern. Refer to Removing-IFluidRouter.md\n *\n * @internal\n */\n// eslint-disable-next-line import/no-deprecated\nexport function buildRuntimeRequestHandler(...handlers: RuntimeRequestHandler[]) {\n\tconst builder = new RuntimeRequestHandlerBuilder();\n\tbuilder.pushHandler(...handlers);\n\treturn async (request: IRequest, runtime: IContainerRuntime) =>\n\t\tbuilder.handleRequest(request, runtime);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/request-handler",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.0.0-dev-rc.1.0.0.224419",
|
|
4
4
|
"description": "A simple request handling library for Fluid Framework",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,44 +11,32 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"build:genver": "gen-version",
|
|
26
|
-
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
27
|
-
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
28
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
29
|
-
"eslint": "eslint --format stylish src",
|
|
30
|
-
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
31
|
-
"lint": "npm run eslint",
|
|
32
|
-
"lint:fix": "npm run eslint:fix",
|
|
33
|
-
"test": "npm run test:mocha",
|
|
34
|
-
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
35
|
-
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
36
|
-
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
37
|
-
"tsc": "tsc",
|
|
38
|
-
"typetests:gen": "flub generate typetests --generate --dir . --no-generateInName",
|
|
39
|
-
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./lib/index.d.mts",
|
|
18
|
+
"default": "./lib/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"require": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
40
25
|
},
|
|
41
|
-
"
|
|
26
|
+
"main": "dist/index.cjs",
|
|
27
|
+
"module": "lib/index.mjs",
|
|
28
|
+
"types": "dist/index.d.ts",
|
|
29
|
+
"c8": {
|
|
42
30
|
"all": true,
|
|
43
31
|
"cache-dir": "nyc/.cache",
|
|
44
32
|
"exclude": [
|
|
45
|
-
"src/test
|
|
46
|
-
"dist/test
|
|
33
|
+
"src/test/**/*.*ts",
|
|
34
|
+
"dist/test/**/*.*js"
|
|
47
35
|
],
|
|
48
36
|
"exclude-after-remap": false,
|
|
49
37
|
"include": [
|
|
50
|
-
"src
|
|
51
|
-
"dist
|
|
38
|
+
"src/**/*.*ts",
|
|
39
|
+
"dist/**/*.*js"
|
|
52
40
|
],
|
|
53
41
|
"report-dir": "nyc/report",
|
|
54
42
|
"reporter": [
|
|
@@ -59,40 +47,100 @@
|
|
|
59
47
|
"temp-directory": "nyc/.nyc_output"
|
|
60
48
|
},
|
|
61
49
|
"dependencies": {
|
|
62
|
-
"@fluidframework/
|
|
63
|
-
"@fluidframework/
|
|
64
|
-
"@fluidframework/core-
|
|
65
|
-
"@fluidframework/runtime-definitions": "1.
|
|
66
|
-
"@fluidframework/runtime-utils": "1.
|
|
50
|
+
"@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.1.0.0.224419",
|
|
51
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.224419",
|
|
52
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.224419",
|
|
53
|
+
"@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.224419",
|
|
54
|
+
"@fluidframework/runtime-utils": "2.0.0-dev-rc.1.0.0.224419"
|
|
67
55
|
},
|
|
68
56
|
"devDependencies": {
|
|
69
|
-
"@
|
|
70
|
-
"@
|
|
71
|
-
"@fluidframework/
|
|
72
|
-
"@fluidframework/
|
|
73
|
-
"@fluidframework/
|
|
74
|
-
"@fluidframework/test-
|
|
75
|
-
"@
|
|
76
|
-
"@
|
|
57
|
+
"@arethetypeswrong/cli": "^0.13.3",
|
|
58
|
+
"@fluid-tools/build-cli": "0.29.0-222379",
|
|
59
|
+
"@fluidframework/build-common": "^2.0.3",
|
|
60
|
+
"@fluidframework/build-tools": "0.29.0-222379",
|
|
61
|
+
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
62
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.224419",
|
|
63
|
+
"@fluidframework/request-handler-previous": "npm:@fluidframework/request-handler@2.0.0-internal.7.2.0",
|
|
64
|
+
"@fluidframework/test-runtime-utils": "2.0.0-dev-rc.1.0.0.224419",
|
|
65
|
+
"@microsoft/api-extractor": "^7.38.3",
|
|
77
66
|
"@types/diff": "^3.5.1",
|
|
78
67
|
"@types/mocha": "^9.1.1",
|
|
79
|
-
"@types/
|
|
80
|
-
"
|
|
81
|
-
"copyfiles": "^2.1
|
|
82
|
-
"cross-env": "^7.0.
|
|
68
|
+
"@types/node": "^18.19.0",
|
|
69
|
+
"c8": "^7.7.1",
|
|
70
|
+
"copyfiles": "^2.4.1",
|
|
71
|
+
"cross-env": "^7.0.3",
|
|
83
72
|
"diff": "^3.5.0",
|
|
84
|
-
"eslint": "~8.
|
|
85
|
-
"mocha": "^10.
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
73
|
+
"eslint": "~8.50.0",
|
|
74
|
+
"mocha": "^10.2.0",
|
|
75
|
+
"mocha-json-output-reporter": "^2.0.1",
|
|
76
|
+
"mocha-multi-reporters": "^1.5.1",
|
|
77
|
+
"moment": "^2.21.0",
|
|
78
|
+
"prettier": "~3.0.3",
|
|
79
|
+
"renamer": "^4.0.0",
|
|
80
|
+
"rimraf": "^4.4.0",
|
|
81
|
+
"tsc-multi": "^1.1.0",
|
|
82
|
+
"typescript": "~5.1.6"
|
|
83
|
+
},
|
|
84
|
+
"fluidBuild": {
|
|
85
|
+
"tasks": {
|
|
86
|
+
"build:docs": {
|
|
87
|
+
"dependsOn": [
|
|
88
|
+
"...",
|
|
89
|
+
"api-extractor:commonjs",
|
|
90
|
+
"api-extractor:esnext"
|
|
91
|
+
],
|
|
92
|
+
"script": false
|
|
93
|
+
}
|
|
94
|
+
}
|
|
91
95
|
},
|
|
92
96
|
"typeValidation": {
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
"broken": {
|
|
98
|
+
"RemovedVariableDeclaration_createFluidObjectResponse": {
|
|
99
|
+
"forwardCompat": false,
|
|
100
|
+
"backCompat": false
|
|
101
|
+
},
|
|
102
|
+
"RemovedVariableDeclaration_rootDataStoreRequestHandler": {
|
|
103
|
+
"forwardCompat": false,
|
|
104
|
+
"backCompat": false
|
|
105
|
+
},
|
|
106
|
+
"RemovedFunctionDeclaration_handleFromLegacyUri": {
|
|
107
|
+
"forwardCompat": false,
|
|
108
|
+
"backCompat": false
|
|
109
|
+
},
|
|
110
|
+
"RemovedClassDeclaration_RuntimeRequestHandlerBuilder": {
|
|
111
|
+
"forwardCompat": false,
|
|
112
|
+
"backCompat": false
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"scripts": {
|
|
117
|
+
"api": "fluid-build . --task api",
|
|
118
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
119
|
+
"api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
|
|
120
|
+
"build": "fluid-build . --task build",
|
|
121
|
+
"build:commonjs": "fluid-build . --task commonjs",
|
|
122
|
+
"build:compile": "fluid-build . --task compile",
|
|
123
|
+
"build:docs": "fluid-build . --task api",
|
|
124
|
+
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
125
|
+
"build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
|
|
126
|
+
"build:test": "tsc-multi --config ./tsc-multi.test.json",
|
|
127
|
+
"check:are-the-types-wrong": "attw --pack",
|
|
128
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
129
|
+
"ci:build:docs": "api-extractor run",
|
|
130
|
+
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
131
|
+
"eslint": "eslint --format stylish src",
|
|
132
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
133
|
+
"format": "npm run prettier:fix",
|
|
134
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
135
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
136
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
137
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
138
|
+
"test": "npm run test:mocha",
|
|
139
|
+
"test:coverage": "c8 npm test",
|
|
140
|
+
"test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup",
|
|
141
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
142
|
+
"tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
|
|
143
|
+
"typetests:gen": "fluid-type-test-generator",
|
|
144
|
+
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
97
145
|
}
|
|
98
|
-
}
|
|
146
|
+
}
|
package/src/index.ts
CHANGED
package/src/requestHandlers.ts
CHANGED
|
@@ -3,17 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
IResponse,
|
|
9
|
-
IRequest,
|
|
10
|
-
IFluidHandle,
|
|
11
|
-
IFluidLoadable,
|
|
12
|
-
FluidObject,
|
|
13
|
-
IFluidRouter,
|
|
14
|
-
} from "@fluidframework/core-interfaces";
|
|
6
|
+
import { IResponse } from "@fluidframework/core-interfaces";
|
|
15
7
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
16
|
-
import { IContainerRuntimeBase } from "@fluidframework/runtime-definitions";
|
|
17
8
|
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
18
9
|
|
|
19
10
|
/**
|
|
@@ -21,68 +12,11 @@ import { RequestParser } from "@fluidframework/runtime-utils";
|
|
|
21
12
|
* if it does not apply. These handlers are called in series, so there may be other handlers before or after.
|
|
22
13
|
* A handler should only return error if the request is for a route the handler owns, and there is a problem with
|
|
23
14
|
* the route, or fulling the specific request.
|
|
15
|
+
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
16
|
+
*
|
|
17
|
+
* @alpha
|
|
24
18
|
*/
|
|
25
|
-
export type RuntimeRequestHandler = (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* A request handler to expose access to all root data stores in the container by id.
|
|
30
|
-
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
31
|
-
* @param runtime - the container runtime
|
|
32
|
-
* @returns the result of the request
|
|
33
|
-
*/
|
|
34
|
-
export const rootDataStoreRequestHandler = async (request: IRequest, runtime: IContainerRuntime) => {
|
|
35
|
-
const requestParser = RequestParser.create(request);
|
|
36
|
-
const id = requestParser.pathParts[0];
|
|
37
|
-
const wait = typeof request.headers?.wait === "boolean" ? request.headers.wait : undefined;
|
|
38
|
-
let rootDataStore: IFluidRouter;
|
|
39
|
-
try {
|
|
40
|
-
// getRootDataStore currently throws if the data store is not found
|
|
41
|
-
rootDataStore = await runtime.getRootDataStore(id, wait);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
return undefined; // continue search
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));
|
|
47
|
-
} catch (error) {
|
|
48
|
-
return { status: 500, mimeType: "fluid/object", value: error };
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const createFluidObjectResponse = (fluidObject: FluidObject):
|
|
53
|
-
{ status: 200; mimeType: "fluid/object"; value: FluidObject; } => {
|
|
54
|
-
return { status: 200, mimeType: "fluid/object", value: fluidObject };
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
class LegacyUriHandle<T = FluidObject & IFluidLoadable> implements IFluidHandle<T> {
|
|
58
|
-
public readonly isAttached = true;
|
|
59
|
-
|
|
60
|
-
public get IFluidHandle(): IFluidHandle { return this; }
|
|
61
|
-
|
|
62
|
-
public constructor(public readonly absolutePath, public readonly runtime: IContainerRuntimeBase) {
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public attachGraph() {
|
|
66
|
-
assert(false, 0x0ca /* "Trying to use legacy graph attach!" */);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public async get(): Promise<any> {
|
|
70
|
-
const response = await this.runtime.IFluidHandleContext.resolveHandle({ url: this.absolutePath });
|
|
71
|
-
if (response.status === 200 && response.mimeType === "fluid/object") {
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
73
|
-
return response.value;
|
|
74
|
-
}
|
|
75
|
-
throw new Error(`Failed to resolve container path ${this.absolutePath}`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public bind(handle: IFluidHandle) {
|
|
79
|
-
throw new Error("Cannot bind to LegacyUriHandle");
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function handleFromLegacyUri<T = FluidObject & IFluidLoadable>(
|
|
84
|
-
uri: string,
|
|
85
|
-
runtime: IContainerRuntimeBase,
|
|
86
|
-
): IFluidHandle<T> {
|
|
87
|
-
return new LegacyUriHandle<T>(uri, runtime);
|
|
88
|
-
}
|
|
19
|
+
export type RuntimeRequestHandler = (
|
|
20
|
+
request: RequestParser,
|
|
21
|
+
runtime: IContainerRuntime,
|
|
22
|
+
) => Promise<IResponse | undefined>;
|
|
@@ -6,35 +6,45 @@
|
|
|
6
6
|
import { IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
8
8
|
import { RequestParser, create404Response } from "@fluidframework/runtime-utils";
|
|
9
|
+
// eslint-disable-next-line import/no-deprecated
|
|
9
10
|
import { RuntimeRequestHandler } from "./requestHandlers";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
* The RuntimeRequestHandlerBuilder creates a runtime request handler based on request handlers.
|
|
14
|
+
* The provided handlers sequentially applied until one is able to satisfy the request.
|
|
15
|
+
*/
|
|
16
|
+
class RuntimeRequestHandlerBuilder {
|
|
17
|
+
// eslint-disable-next-line import/no-deprecated
|
|
18
|
+
private readonly handlers: RuntimeRequestHandler[] = [];
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
// eslint-disable-next-line import/no-deprecated
|
|
21
|
+
public pushHandler(...handlers: RuntimeRequestHandler[]) {
|
|
22
|
+
if (handlers !== undefined) {
|
|
23
|
+
this.handlers.push(...handlers);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
public async handleRequest(request: IRequest, runtime: IContainerRuntime): Promise<IResponse> {
|
|
28
|
+
const parser = RequestParser.create(request);
|
|
29
|
+
for (const handler of this.handlers) {
|
|
30
|
+
const response = await handler(parser, runtime);
|
|
31
|
+
if (response !== undefined) {
|
|
32
|
+
return response;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return create404Response(request);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
// eslint-disable-next-line import/no-deprecated
|
|
36
45
|
export function buildRuntimeRequestHandler(...handlers: RuntimeRequestHandler[]) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
const builder = new RuntimeRequestHandlerBuilder();
|
|
47
|
+
builder.pushHandler(...handlers);
|
|
48
|
+
return async (request: IRequest, runtime: IContainerRuntime) =>
|
|
49
|
+
builder.handleRequest(request, runtime);
|
|
40
50
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
]
|
|
14
|
-
}
|
|
2
|
+
"extends": [
|
|
3
|
+
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
+
"../../../common/build/build-common/tsconfig.cjs.json",
|
|
5
|
+
],
|
|
6
|
+
"include": ["src/**/*"],
|
|
7
|
+
"exclude": ["src/test/**/*"],
|
|
8
|
+
"compilerOptions": {
|
|
9
|
+
"rootDir": "./src",
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
},
|
|
12
|
+
}
|
package/dist/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./requestHandlers"), exports);
|
|
18
|
-
__exportStar(require("./runtimeRequestHandlerBuilder"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,oDAAkC;AAClC,iEAA+C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./requestHandlers\";\nexport * from \"./runtimeRequestHandlerBuilder\";\n"]}
|
package/dist/packageVersion.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
-
*/
|
|
7
|
-
export declare const pkgName = "@fluidframework/request-handler";
|
|
8
|
-
export declare const pkgVersion = "1.4.0-115997";
|
|
9
|
-
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*
|
|
6
|
-
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
|
-
exports.pkgName = "@fluidframework/request-handler";
|
|
11
|
-
exports.pkgVersion = "1.4.0-115997";
|
|
12
|
-
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 = \"1.4.0-115997\";\n"]}
|
package/dist/requestHandlers.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.handleFromLegacyUri = exports.createFluidObjectResponse = exports.rootDataStoreRequestHandler = void 0;
|
|
8
|
-
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
-
const runtime_utils_1 = require("@fluidframework/runtime-utils");
|
|
10
|
-
/**
|
|
11
|
-
* A request handler to expose access to all root data stores in the container by id.
|
|
12
|
-
* @param request - the request for the root data store. The first path part must be the data store's ID.
|
|
13
|
-
* @param runtime - the container runtime
|
|
14
|
-
* @returns the result of the request
|
|
15
|
-
*/
|
|
16
|
-
const rootDataStoreRequestHandler = async (request, runtime) => {
|
|
17
|
-
var _a;
|
|
18
|
-
const requestParser = runtime_utils_1.RequestParser.create(request);
|
|
19
|
-
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;
|
|
21
|
-
let rootDataStore;
|
|
22
|
-
try {
|
|
23
|
-
// getRootDataStore currently throws if the data store is not found
|
|
24
|
-
rootDataStore = await runtime.getRootDataStore(id, wait);
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
return undefined; // continue search
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
return rootDataStore.IFluidRouter.request(requestParser.createSubRequest(1));
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return { status: 500, mimeType: "fluid/object", value: error };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
exports.rootDataStoreRequestHandler = rootDataStoreRequestHandler;
|
|
37
|
-
const createFluidObjectResponse = (fluidObject) => {
|
|
38
|
-
return { status: 200, mimeType: "fluid/object", value: fluidObject };
|
|
39
|
-
};
|
|
40
|
-
exports.createFluidObjectResponse = createFluidObjectResponse;
|
|
41
|
-
class LegacyUriHandle {
|
|
42
|
-
constructor(absolutePath, runtime) {
|
|
43
|
-
this.absolutePath = absolutePath;
|
|
44
|
-
this.runtime = runtime;
|
|
45
|
-
this.isAttached = true;
|
|
46
|
-
}
|
|
47
|
-
get IFluidHandle() { return this; }
|
|
48
|
-
attachGraph() {
|
|
49
|
-
(0, common_utils_1.assert)(false, 0x0ca /* "Trying to use legacy graph attach!" */);
|
|
50
|
-
}
|
|
51
|
-
async get() {
|
|
52
|
-
const response = await this.runtime.IFluidHandleContext.resolveHandle({ url: this.absolutePath });
|
|
53
|
-
if (response.status === 200 && response.mimeType === "fluid/object") {
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
55
|
-
return response.value;
|
|
56
|
-
}
|
|
57
|
-
throw new Error(`Failed to resolve container path ${this.absolutePath}`);
|
|
58
|
-
}
|
|
59
|
-
bind(handle) {
|
|
60
|
-
throw new Error("Cannot bind to LegacyUriHandle");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
function handleFromLegacyUri(uri, runtime) {
|
|
64
|
-
return new LegacyUriHandle(uri, runtime);
|
|
65
|
-
}
|
|
66
|
-
exports.handleFromLegacyUri = handleFromLegacyUri;
|
|
67
|
-
//# sourceMappingURL=requestHandlers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"requestHandlers.js","sourceRoot":"","sources":["../src/requestHandlers.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAWtD,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,OAAO,CAAA,MAAA,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,EACC,EAAE;IACjE,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,IAAA,qBAAM,EAAC,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 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 = 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 = FluidObject & IFluidLoadable>(\n uri: string,\n runtime: IContainerRuntimeBase,\n): IFluidHandle<T> {\n return new LegacyUriHandle<T>(uri, runtime);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeRequestHandlerBuilder.js","sourceRoot":"","sources":["../src/runtimeRequestHandlerBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iEAAiF;AAGjF;;;IAGI;AACJ,MAAa,4BAA4B;IAAzC;QACqB,aAAQ,GAA4B,EAAE,CAAC;IAkB5D,CAAC;IAhBU,WAAW,CAAC,GAAG,QAAiC;QACnD,IAAI,QAAQ,KAAK,SAAS,EAAE;YACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;SACnC;IACL,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,OAAiB,EAAE,OAA0B;QACpE,MAAM,MAAM,GAAG,6BAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC7C,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChD,IAAI,QAAQ,KAAK,SAAS,EAAE;gBACxB,OAAO,QAAQ,CAAC;aACnB;SACJ;QACD,OAAO,IAAA,iCAAiB,EAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACJ;AAnBD,oEAmBC;AAED,SAAgB,0BAA0B,CAAC,GAAG,QAAiC;IAC3E,MAAM,OAAO,GAAG,IAAI,4BAA4B,EAAE,CAAC;IACnD,OAAO,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAC;IACjC,OAAO,KAAK,EAAE,OAAiB,EAAE,OAA0B,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC5G,CAAC;AAJD,gEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport { RequestParser, create404Response } from \"@fluidframework/runtime-utils\";\nimport { RuntimeRequestHandler } from \"./requestHandlers\";\n\n/**\n * The RuntimeRequestHandlerBuilder creates a runtime request handler based on request handlers.\n * The provided handlers sequentially applied until one is able to satisfy the request.\n */\nexport class RuntimeRequestHandlerBuilder {\n private readonly handlers: RuntimeRequestHandler[] = [];\n\n public pushHandler(...handlers: RuntimeRequestHandler[]) {\n if (handlers !== undefined) {\n this.handlers.push(...handlers);\n }\n }\n\n public async handleRequest(request: IRequest, runtime: IContainerRuntime): Promise<IResponse> {\n const parser = RequestParser.create(request);\n for (const handler of this.handlers) {\n const response = await handler(parser, runtime);\n if (response !== undefined) {\n return response;\n }\n }\n return create404Response(request);\n }\n}\n\nexport function buildRuntimeRequestHandler(...handlers: RuntimeRequestHandler[]) {\n const builder = new RuntimeRequestHandlerBuilder();\n builder.pushHandler(...handlers);\n return async (request: IRequest, runtime: IContainerRuntime) => builder.handleRequest(request, runtime);\n}\n"]}
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC"}
|