@fluidframework/runtime-utils 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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/.eslintrc.js +5 -7
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
- package/dist/dataStoreHandleContextUtils.js +3 -1
- package/dist/dataStoreHandleContextUtils.js.map +1 -1
- package/dist/dataStoreHelpers.d.ts.map +1 -1
- package/dist/dataStoreHelpers.js +23 -7
- package/dist/dataStoreHelpers.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/objectstoragepartition.d.ts.map +1 -1
- package/dist/objectstoragepartition.js.map +1 -1
- package/dist/objectstorageutils.d.ts.map +1 -1
- package/dist/objectstorageutils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/requestParser.d.ts.map +1 -1
- package/dist/requestParser.js.map +1 -1
- package/dist/runtimeFactoryHelper.d.ts.map +1 -1
- package/dist/runtimeFactoryHelper.js +6 -2
- package/dist/runtimeFactoryHelper.js.map +1 -1
- package/dist/summarizerNode/summarizerNode.d.ts +25 -10
- package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNode.js +117 -52
- package/dist/summarizerNode/summarizerNode.js.map +1 -1
- package/dist/summarizerNode/summarizerNodeUtils.d.ts +12 -14
- package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/dist/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
- package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/dist/summarizerNode/summarizerNodeWithGc.js +45 -19
- package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/dist/summaryUtils.d.ts +2 -2
- package/dist/summaryUtils.d.ts.map +1 -1
- package/dist/summaryUtils.js +5 -4
- package/dist/summaryUtils.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
- package/lib/dataStoreHandleContextUtils.js +3 -1
- package/lib/dataStoreHandleContextUtils.js.map +1 -1
- package/lib/dataStoreHelpers.d.ts.map +1 -1
- package/lib/dataStoreHelpers.js +23 -7
- package/lib/dataStoreHelpers.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/objectstoragepartition.d.ts.map +1 -1
- package/lib/objectstoragepartition.js.map +1 -1
- package/lib/objectstorageutils.d.ts.map +1 -1
- package/lib/objectstorageutils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/requestParser.d.ts.map +1 -1
- package/lib/requestParser.js.map +1 -1
- package/lib/runtimeFactoryHelper.d.ts.map +1 -1
- package/lib/runtimeFactoryHelper.js +6 -2
- package/lib/runtimeFactoryHelper.js.map +1 -1
- package/lib/summarizerNode/summarizerNode.d.ts +25 -10
- package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNode.js +117 -52
- package/lib/summarizerNode/summarizerNode.js.map +1 -1
- package/lib/summarizerNode/summarizerNodeUtils.d.ts +12 -14
- package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
- package/lib/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
- package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
- package/lib/summarizerNode/summarizerNodeWithGc.js +46 -19
- package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
- package/lib/summaryUtils.d.ts +2 -2
- package/lib/summaryUtils.d.ts.map +1 -1
- package/lib/summaryUtils.js +5 -4
- package/lib/summaryUtils.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +45 -48
- package/prettier.config.cjs +1 -1
- package/src/dataStoreHandleContextUtils.ts +23 -16
- package/src/dataStoreHelpers.ts +104 -86
- package/src/index.ts +3 -2
- package/src/objectstoragepartition.ts +13 -13
- package/src/objectstorageutils.ts +31 -28
- package/src/packageVersion.ts +1 -1
- package/src/requestParser.ts +80 -82
- package/src/runtimeFactoryHelper.ts +24 -17
- package/src/summarizerNode/summarizerNode.ts +702 -575
- package/src/summarizerNode/summarizerNodeUtils.ts +157 -159
- package/src/summarizerNode/summarizerNodeWithGc.ts +532 -473
- package/src/summaryUtils.ts +313 -305
- package/src/utils.ts +6 -6
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1F,yDAAyD;AACzD,oBAAY,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1F,yDAAyD;AACzD,oBAAY,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;GAKG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,aAAa,EACnB,gBAAgB,EAAE,gBAAgB,GAChC,OAAO,CAAC,MAAM,CAAC,CAIjB"}
|
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,IAAmB,EACnB,gBAAkC;IAElC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAsB,cAAc,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,cAAc,CAAC;AAC9B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentAttributes, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/** Reads a blob from storage and parses it from JSON. */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\tconst attributesHash = tree.trees[\".protocol\"].blobs.attributes;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-utils",
|
|
3
|
-
"version": "2.0.0-internal.3.0
|
|
3
|
+
"version": "2.0.0-internal.3.2.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid Runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,33 +14,6 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"module": "lib/index.js",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
19
|
-
"build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
20
|
-
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
21
|
-
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
22
|
-
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
23
|
-
"build:full": "npm run build",
|
|
24
|
-
"build:full:compile": "npm run build:compile",
|
|
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
|
-
"format": "npm run prettier:fix",
|
|
32
|
-
"lint": "npm run eslint",
|
|
33
|
-
"lint:fix": "npm run eslint:fix",
|
|
34
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
35
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
36
|
-
"test": "npm run test:mocha",
|
|
37
|
-
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
38
|
-
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
39
|
-
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
40
|
-
"tsc": "tsc",
|
|
41
|
-
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
42
|
-
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
43
|
-
},
|
|
44
17
|
"nyc": {
|
|
45
18
|
"all": true,
|
|
46
19
|
"cache-dir": "nyc/.cache",
|
|
@@ -63,24 +36,24 @@
|
|
|
63
36
|
},
|
|
64
37
|
"dependencies": {
|
|
65
38
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
66
|
-
"@fluidframework/common-utils": "^1.
|
|
67
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.3.0
|
|
68
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.0
|
|
69
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.3.0
|
|
70
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-internal.3.0
|
|
71
|
-
"@fluidframework/garbage-collector": ">=2.0.0-internal.3.0
|
|
39
|
+
"@fluidframework/common-utils": "^1.1.1",
|
|
40
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
41
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
42
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
43
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
44
|
+
"@fluidframework/garbage-collector": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
72
45
|
"@fluidframework/protocol-base": "^0.1038.2000",
|
|
73
46
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
74
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.3.0
|
|
75
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.3.0
|
|
47
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
48
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0"
|
|
76
49
|
},
|
|
77
50
|
"devDependencies": {
|
|
78
|
-
"@fluid-tools/build-cli": "^0.
|
|
51
|
+
"@fluid-tools/build-cli": "^0.10.0",
|
|
79
52
|
"@fluidframework/build-common": "^1.1.0",
|
|
80
|
-
"@fluidframework/build-tools": "^0.
|
|
53
|
+
"@fluidframework/build-tools": "^0.10.0",
|
|
81
54
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
82
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.0
|
|
83
|
-
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.3.
|
|
55
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
56
|
+
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.3.1.0",
|
|
84
57
|
"@microsoft/api-extractor": "^7.22.2",
|
|
85
58
|
"@rushstack/eslint-config": "^2.5.1",
|
|
86
59
|
"@types/mocha": "^9.1.1",
|
|
@@ -98,17 +71,41 @@
|
|
|
98
71
|
"typescript": "~4.5.5"
|
|
99
72
|
},
|
|
100
73
|
"typeValidation": {
|
|
101
|
-
"version": "2.0.0-internal.3.0
|
|
102
|
-
"previousVersionStyle": "
|
|
103
|
-
"baselineRange": "2.0.0-internal.3.0.0",
|
|
74
|
+
"version": "2.0.0-internal.3.2.0",
|
|
75
|
+
"previousVersionStyle": "~previousMinor",
|
|
76
|
+
"baselineRange": ">=2.0.0-internal.3.1.0 <2.0.0-internal.3.2.0",
|
|
77
|
+
"baselineVersion": "2.0.0-internal.3.1.0",
|
|
104
78
|
"broken": {
|
|
105
|
-
"TypeAliasDeclaration_RefreshSummaryResult": {
|
|
106
|
-
"forwardCompat": false,
|
|
107
|
-
"backCompat": false
|
|
108
|
-
},
|
|
109
79
|
"ClassDeclaration_TelemetryContext": {
|
|
110
80
|
"forwardCompat": false
|
|
111
81
|
}
|
|
112
82
|
}
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
86
|
+
"build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
|
|
87
|
+
"build:compile": "concurrently npm:build:commonjs npm:build:esnext",
|
|
88
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
89
|
+
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
90
|
+
"build:full": "npm run build",
|
|
91
|
+
"build:full:compile": "npm run build:compile",
|
|
92
|
+
"build:genver": "gen-version",
|
|
93
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
94
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
95
|
+
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
96
|
+
"eslint": "eslint --format stylish src",
|
|
97
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
98
|
+
"format": "npm run prettier:fix",
|
|
99
|
+
"lint": "npm run prettier && npm run eslint",
|
|
100
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
101
|
+
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
102
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
103
|
+
"test": "npm run test:mocha",
|
|
104
|
+
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
105
|
+
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
106
|
+
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
107
|
+
"tsc": "tsc",
|
|
108
|
+
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
109
|
+
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
113
110
|
}
|
|
114
|
-
}
|
|
111
|
+
}
|
package/prettier.config.cjs
CHANGED
|
@@ -11,21 +11,28 @@ import { IFluidHandleContext } from "@fluidframework/core-interfaces";
|
|
|
11
11
|
* @param routeContext - The route context that contains the Fluid object.
|
|
12
12
|
* @returns The absolute path to the Fluid object from the root of the Container.
|
|
13
13
|
*/
|
|
14
|
-
export function generateHandleContextPath(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
export function generateHandleContextPath(
|
|
15
|
+
path: string,
|
|
16
|
+
routeContext?: IFluidHandleContext,
|
|
17
|
+
): string {
|
|
18
|
+
if (path === "") {
|
|
19
|
+
// The `path` is empty.
|
|
20
|
+
// If the routeContext does not exist, this is the root.
|
|
21
|
+
// If the routeContext exists, the absolute path is the same as that of the routeContext.
|
|
22
|
+
return routeContext === undefined ? "" : routeContext.absolutePath;
|
|
23
|
+
} else {
|
|
24
|
+
// Remove beginning and trailing slashes, if any, from the path.
|
|
25
|
+
let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
26
|
+
normalizedPath = normalizedPath.endsWith("/")
|
|
27
|
+
? normalizedPath.slice(0, -1)
|
|
28
|
+
: normalizedPath;
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
// If the routeContext does not exist, path is the absolute path.
|
|
31
|
+
// If the routeContext exists, absolute path is routeContext's absolute path plus the path.
|
|
32
|
+
return routeContext === undefined
|
|
33
|
+
? `/${normalizedPath}`
|
|
34
|
+
: `${
|
|
35
|
+
routeContext.absolutePath === "/" ? "" : routeContext.absolutePath
|
|
36
|
+
}/${normalizedPath}`;
|
|
37
|
+
}
|
|
31
38
|
}
|
package/src/dataStoreHelpers.ts
CHANGED
|
@@ -5,118 +5,136 @@
|
|
|
5
5
|
|
|
6
6
|
import { ITaggedTelemetryPropertyType } from "@fluidframework/common-definitions";
|
|
7
7
|
import { assert } from "@fluidframework/common-utils";
|
|
8
|
+
import { FluidObject, IFluidRouter, IRequest, IResponse } from "@fluidframework/core-interfaces";
|
|
8
9
|
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
IResponse,
|
|
13
|
-
} from "@fluidframework/core-interfaces";
|
|
14
|
-
import {
|
|
15
|
-
IFluidDataStoreFactory,
|
|
16
|
-
IFluidDataStoreRegistry,
|
|
17
|
-
IProvideFluidDataStoreRegistry,
|
|
10
|
+
IFluidDataStoreFactory,
|
|
11
|
+
IFluidDataStoreRegistry,
|
|
12
|
+
IProvideFluidDataStoreRegistry,
|
|
18
13
|
} from "@fluidframework/runtime-definitions";
|
|
19
14
|
import { generateErrorWithStack, TelemetryDataTag } from "@fluidframework/telemetry-utils";
|
|
20
15
|
|
|
21
16
|
interface IResponseException extends Error {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
errorFromRequestFluidObject: true;
|
|
18
|
+
message: string;
|
|
19
|
+
code: number;
|
|
20
|
+
stack?: string;
|
|
21
|
+
underlyingResponseHeaders?: { [key: string]: any };
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
export function exceptionToResponse(err: any): IResponse {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
25
|
+
const status = 500;
|
|
26
|
+
if (err !== null && typeof err === "object" && err.errorFromRequestFluidObject === true) {
|
|
27
|
+
const responseErr: IResponseException = err;
|
|
28
|
+
return {
|
|
29
|
+
mimeType: "text/plain",
|
|
30
|
+
status: responseErr.code,
|
|
31
|
+
value: responseErr.message,
|
|
32
|
+
get stack() {
|
|
33
|
+
return responseErr.stack;
|
|
34
|
+
},
|
|
35
|
+
headers: responseErr.underlyingResponseHeaders,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
|
|
40
|
+
const errWithStack = generateErrorWithStack();
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
mimeType: "text/plain",
|
|
44
|
+
status,
|
|
45
|
+
value: `${err}`,
|
|
46
|
+
get stack() {
|
|
47
|
+
return (err?.stack as string | undefined) ?? errWithStack.stack;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
export function responseToException(response: IResponse, request: IRequest): Error {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
53
|
+
const message = response.value;
|
|
54
|
+
const errWithStack = generateErrorWithStack();
|
|
55
|
+
const responseErr: Error & IResponseException = {
|
|
56
|
+
errorFromRequestFluidObject: true,
|
|
57
|
+
message,
|
|
58
|
+
name: "Error",
|
|
59
|
+
code: response.status,
|
|
60
|
+
get stack() {
|
|
61
|
+
return response.stack ?? errWithStack.stack;
|
|
62
|
+
},
|
|
63
|
+
underlyingResponseHeaders: response.headers,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return responseErr;
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
70
|
* Takes a set of packages and joins them pkg1/pkg2... etc. Tags the field as a code artifact
|
|
70
71
|
*/
|
|
71
72
|
export function packagePathToTelemetryProperty(
|
|
72
|
-
|
|
73
|
+
packagePath: readonly string[] | undefined,
|
|
73
74
|
): ITaggedTelemetryPropertyType | undefined {
|
|
74
|
-
|
|
75
|
+
return packagePath
|
|
76
|
+
? { value: packagePath.join("/"), tag: TelemetryDataTag.CodeArtifact }
|
|
77
|
+
: undefined;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
export async function requestFluidObject<T = FluidObject>(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
router: IFluidRouter,
|
|
82
|
+
url: string | IRequest,
|
|
83
|
+
): Promise<T> {
|
|
84
|
+
const request = typeof url === "string" ? { url } : url;
|
|
85
|
+
const response = await router.request(request);
|
|
86
|
+
|
|
87
|
+
if (response.status !== 200 || response.mimeType !== "fluid/object") {
|
|
88
|
+
throw responseToException(response, request);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
assert(response.value, 0x19a /* "Invalid response value for Fluid object request" */);
|
|
92
|
+
return response.value as T;
|
|
88
93
|
}
|
|
89
94
|
|
|
90
|
-
export const create404Response = (request: IRequest) =>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
95
|
+
export const create404Response = (request: IRequest) =>
|
|
96
|
+
createResponseError(404, "not found", request);
|
|
97
|
+
|
|
98
|
+
export function createResponseError(
|
|
99
|
+
status: number,
|
|
100
|
+
value: string,
|
|
101
|
+
request: IRequest,
|
|
102
|
+
headers?: { [key: string]: any },
|
|
103
|
+
): IResponse {
|
|
104
|
+
assert(status !== 200, 0x19b /* "Cannot not create response error on 200 status" */);
|
|
105
|
+
// Omit query string which could contain personal data (aka "PII")
|
|
106
|
+
const urlNoQuery = request.url?.split("?")[0];
|
|
107
|
+
|
|
108
|
+
// Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
|
|
109
|
+
const errWithStack = generateErrorWithStack();
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
mimeType: "text/plain",
|
|
113
|
+
status,
|
|
114
|
+
value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,
|
|
115
|
+
get stack() {
|
|
116
|
+
return errWithStack.stack;
|
|
117
|
+
},
|
|
118
|
+
headers,
|
|
119
|
+
};
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
export type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;
|
|
110
123
|
|
|
111
124
|
export function createDataStoreFactory(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
type: string,
|
|
126
|
+
factory: Factory | Promise<Factory>,
|
|
127
|
+
): IFluidDataStoreFactory & IFluidDataStoreRegistry {
|
|
128
|
+
return {
|
|
129
|
+
type,
|
|
130
|
+
get IFluidDataStoreFactory() {
|
|
131
|
+
return this;
|
|
132
|
+
},
|
|
133
|
+
get IFluidDataStoreRegistry() {
|
|
134
|
+
return this;
|
|
135
|
+
},
|
|
136
|
+
instantiateDataStore: async (context, existing) =>
|
|
137
|
+
(await factory).instantiateDataStore(context, existing),
|
|
138
|
+
get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),
|
|
139
|
+
};
|
|
122
140
|
}
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
createResponseError,
|
|
11
11
|
exceptionToResponse,
|
|
12
12
|
Factory,
|
|
13
|
-
|
|
13
|
+
packagePathToTelemetryProperty,
|
|
14
14
|
requestFluidObject,
|
|
15
15
|
responseToException,
|
|
16
16
|
} from "./dataStoreHelpers";
|
|
@@ -18,10 +18,11 @@ export { ObjectStoragePartition } from "./objectstoragepartition";
|
|
|
18
18
|
export { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from "./objectstorageutils";
|
|
19
19
|
export { RequestParser } from "./requestParser";
|
|
20
20
|
export { RuntimeFactoryHelper } from "./runtimeFactoryHelper";
|
|
21
|
+
// TODO: Move summarizerNode content to container-runtime in next branch.
|
|
21
22
|
export {
|
|
22
23
|
createRootSummarizerNode,
|
|
23
24
|
createRootSummarizerNodeWithGC,
|
|
24
|
-
|
|
25
|
+
IFetchSnapshotResult,
|
|
25
26
|
IRootSummarizerNode,
|
|
26
27
|
IRootSummarizerNodeWithGC,
|
|
27
28
|
ISummarizerNodeRootContract,
|
|
@@ -10,20 +10,20 @@ import { IChannelStorageService } from "@fluidframework/datastore-definitions";
|
|
|
10
10
|
* Returns a new IChannelStorageService that resolves the given `path` as root.
|
|
11
11
|
*/
|
|
12
12
|
export class ObjectStoragePartition implements IChannelStorageService {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
constructor(private readonly storage: IChannelStorageService, private readonly path: string) {
|
|
14
|
+
// `path` must not include the trailing separator.
|
|
15
|
+
assert(!path.endsWith("/"), 0x19c /* "storage service path has trailing separator" */);
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
public async readBlob(path: string): Promise<ArrayBufferLike> {
|
|
19
|
+
return this.storage.readBlob(`${this.path}/${path}`);
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
public async contains(path: string): Promise<boolean> {
|
|
23
|
+
return this.storage.contains(`${this.path}/${path}`);
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
public async list(path: string): Promise<string[]> {
|
|
27
|
+
return this.storage.list(`${this.path}/${path}`);
|
|
28
|
+
}
|
|
29
29
|
}
|
|
@@ -6,35 +6,38 @@
|
|
|
6
6
|
import { ITree } from "@fluidframework/protocol-definitions";
|
|
7
7
|
|
|
8
8
|
export function getNormalizedObjectStoragePathParts(path: string) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
let normalizePath = path;
|
|
10
|
+
if (normalizePath.startsWith("/")) {
|
|
11
|
+
normalizePath = normalizePath.substr(1);
|
|
12
|
+
}
|
|
13
|
+
if (normalizePath.endsWith("/")) {
|
|
14
|
+
normalizePath = normalizePath.substr(0, normalizePath.length - 1);
|
|
15
|
+
}
|
|
16
|
+
if (normalizePath.length > 0) {
|
|
17
|
+
return normalizePath.split("/");
|
|
18
|
+
}
|
|
19
|
+
return [];
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export async function listBlobsAtTreePath(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
export async function listBlobsAtTreePath(
|
|
23
|
+
inputTree: ITree | undefined,
|
|
24
|
+
path: string,
|
|
25
|
+
): Promise<string[]> {
|
|
26
|
+
const pathParts = getNormalizedObjectStoragePathParts(path);
|
|
27
|
+
let tree: ITree | undefined = inputTree;
|
|
28
|
+
while (tree?.entries !== undefined && pathParts.length > 0) {
|
|
29
|
+
const part = pathParts.shift();
|
|
30
|
+
const treeEntry = tree.entries.find((value) => {
|
|
31
|
+
return value.type === "Tree" && value.path === part ? true : false;
|
|
32
|
+
});
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
// this check is largely superfluous due to the same check being done
|
|
35
|
+
// immediately above. the type system, however, is not aware of this.
|
|
36
|
+
// so we must redundantly determine that the entry's type is "Tree"
|
|
37
|
+
tree = treeEntry?.type === "Tree" ? treeEntry.value : undefined;
|
|
38
|
+
}
|
|
39
|
+
if (tree?.entries === undefined || pathParts.length !== 0) {
|
|
40
|
+
throw new Error("path does not exist");
|
|
41
|
+
}
|
|
42
|
+
return tree.entries.filter((e) => e.type === "Blob").map((e) => e.path);
|
|
40
43
|
}
|
package/src/packageVersion.ts
CHANGED