@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.
Files changed (96) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  5. package/dist/dataStoreHandleContextUtils.js +3 -1
  6. package/dist/dataStoreHandleContextUtils.js.map +1 -1
  7. package/dist/dataStoreHelpers.d.ts.map +1 -1
  8. package/dist/dataStoreHelpers.js +23 -7
  9. package/dist/dataStoreHelpers.js.map +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/objectstoragepartition.d.ts.map +1 -1
  14. package/dist/objectstoragepartition.js.map +1 -1
  15. package/dist/objectstorageutils.d.ts.map +1 -1
  16. package/dist/objectstorageutils.js.map +1 -1
  17. package/dist/packageVersion.d.ts +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/dist/requestParser.d.ts.map +1 -1
  21. package/dist/requestParser.js.map +1 -1
  22. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  23. package/dist/runtimeFactoryHelper.js +6 -2
  24. package/dist/runtimeFactoryHelper.js.map +1 -1
  25. package/dist/summarizerNode/summarizerNode.d.ts +25 -10
  26. package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
  27. package/dist/summarizerNode/summarizerNode.js +117 -52
  28. package/dist/summarizerNode/summarizerNode.js.map +1 -1
  29. package/dist/summarizerNode/summarizerNodeUtils.d.ts +12 -14
  30. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  31. package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
  32. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
  33. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  34. package/dist/summarizerNode/summarizerNodeWithGc.js +45 -19
  35. package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  36. package/dist/summaryUtils.d.ts +2 -2
  37. package/dist/summaryUtils.d.ts.map +1 -1
  38. package/dist/summaryUtils.js +5 -4
  39. package/dist/summaryUtils.js.map +1 -1
  40. package/dist/utils.d.ts.map +1 -1
  41. package/dist/utils.js.map +1 -1
  42. package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
  43. package/lib/dataStoreHandleContextUtils.js +3 -1
  44. package/lib/dataStoreHandleContextUtils.js.map +1 -1
  45. package/lib/dataStoreHelpers.d.ts.map +1 -1
  46. package/lib/dataStoreHelpers.js +23 -7
  47. package/lib/dataStoreHelpers.js.map +1 -1
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js +1 -0
  50. package/lib/index.js.map +1 -1
  51. package/lib/objectstoragepartition.d.ts.map +1 -1
  52. package/lib/objectstoragepartition.js.map +1 -1
  53. package/lib/objectstorageutils.d.ts.map +1 -1
  54. package/lib/objectstorageutils.js.map +1 -1
  55. package/lib/packageVersion.d.ts +1 -1
  56. package/lib/packageVersion.js +1 -1
  57. package/lib/packageVersion.js.map +1 -1
  58. package/lib/requestParser.d.ts.map +1 -1
  59. package/lib/requestParser.js.map +1 -1
  60. package/lib/runtimeFactoryHelper.d.ts.map +1 -1
  61. package/lib/runtimeFactoryHelper.js +6 -2
  62. package/lib/runtimeFactoryHelper.js.map +1 -1
  63. package/lib/summarizerNode/summarizerNode.d.ts +25 -10
  64. package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
  65. package/lib/summarizerNode/summarizerNode.js +117 -52
  66. package/lib/summarizerNode/summarizerNode.js.map +1 -1
  67. package/lib/summarizerNode/summarizerNodeUtils.d.ts +12 -14
  68. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  69. package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
  70. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
  71. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  72. package/lib/summarizerNode/summarizerNodeWithGc.js +46 -19
  73. package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  74. package/lib/summaryUtils.d.ts +2 -2
  75. package/lib/summaryUtils.d.ts.map +1 -1
  76. package/lib/summaryUtils.js +5 -4
  77. package/lib/summaryUtils.js.map +1 -1
  78. package/lib/utils.d.ts.map +1 -1
  79. package/lib/utils.js.map +1 -1
  80. package/package.json +45 -48
  81. package/prettier.config.cjs +1 -1
  82. package/src/dataStoreHandleContextUtils.ts +23 -16
  83. package/src/dataStoreHelpers.ts +104 -86
  84. package/src/index.ts +3 -2
  85. package/src/objectstoragepartition.ts +13 -13
  86. package/src/objectstorageutils.ts +31 -28
  87. package/src/packageVersion.ts +1 -1
  88. package/src/requestParser.ts +80 -82
  89. package/src/runtimeFactoryHelper.ts +24 -17
  90. package/src/summarizerNode/summarizerNode.ts +702 -575
  91. package/src/summarizerNode/summarizerNodeUtils.ts +157 -159
  92. package/src/summarizerNode/summarizerNodeWithGc.ts +532 -473
  93. package/src/summaryUtils.ts +313 -305
  94. package/src/utils.ts +6 -6
  95. package/tsconfig.esnext.json +6 -6
  96. package/tsconfig.json +8 -12
@@ -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;AACF,wBAAsB,WAAW,CAC9B,IAAI,EAAE,aAAa,EACnB,gBAAgB,EAAE,gBAAgB,GACnC,OAAO,CAAC,MAAM,CAAC,CAIjB"}
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;AACF,MAAM,CAAC,KAAK,UAAU,WAAW,CAC9B,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;AACjC,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 */\n export async function seqFromTree(\n tree: ISnapshotTree,\n readAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n const attributesHash = tree.trees[\".protocol\"].blobs.attributes;\n const attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n return attrib.sequenceNumber;\n}\n"]}
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.2",
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.0.0",
67
- "@fluidframework/container-definitions": ">=2.0.0-internal.3.0.2 <2.0.0-internal.4.0.0",
68
- "@fluidframework/container-runtime-definitions": ">=2.0.0-internal.3.0.2 <2.0.0-internal.4.0.0",
69
- "@fluidframework/core-interfaces": ">=2.0.0-internal.3.0.2 <2.0.0-internal.4.0.0",
70
- "@fluidframework/datastore-definitions": ">=2.0.0-internal.3.0.2 <2.0.0-internal.4.0.0",
71
- "@fluidframework/garbage-collector": ">=2.0.0-internal.3.0.2 <2.0.0-internal.4.0.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.2 <2.0.0-internal.4.0.0",
75
- "@fluidframework/telemetry-utils": ">=2.0.0-internal.3.0.2 <2.0.0-internal.4.0.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.8.0",
51
+ "@fluid-tools/build-cli": "^0.10.0",
79
52
  "@fluidframework/build-common": "^1.1.0",
80
- "@fluidframework/build-tools": "^0.8.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.2 <2.0.0-internal.4.0.0",
83
- "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.3.0.0",
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.1",
102
- "previousVersionStyle": "previousPatch",
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
+ }
@@ -4,5 +4,5 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- ...require("@fluidframework/build-common/prettier.config.cjs"),
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
8
  };
@@ -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(path: string, routeContext?: IFluidHandleContext): string {
15
- if (path === "") {
16
- // The `path` is empty.
17
- // If the routeContext does not exist, this is the root.
18
- // If the routeContext exists, the absolute path is the same as that of the routeContext.
19
- return routeContext === undefined ? "" : routeContext.absolutePath;
20
- } else {
21
- // Remove beginning and trailing slashes, if any, from the path.
22
- let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
23
- normalizedPath = normalizedPath.endsWith("/") ? normalizedPath.slice(0, -1) : normalizedPath;
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
- // If the routeContext does not exist, path is the absolute path.
26
- // If the routeContext exists, absolute path is routeContext's absolute path plus the path.
27
- return routeContext === undefined
28
- ? `/${normalizedPath}`
29
- : `${routeContext.absolutePath === "/" ? "" : routeContext.absolutePath}/${normalizedPath}`;
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
  }
@@ -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
- FluidObject,
10
- IFluidRouter,
11
- IRequest,
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
- errorFromRequestFluidObject: true;
23
- message: string;
24
- code: number;
25
- stack?: string;
26
- underlyingResponseHeaders?: { [key: string]: any; };
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
- const status = 500;
31
- if (err !== null && typeof err === "object" && err.errorFromRequestFluidObject === true) {
32
- const responseErr: IResponseException = err;
33
- return {
34
- mimeType: "text/plain",
35
- status: responseErr.code,
36
- value: responseErr.message,
37
- get stack() { return responseErr.stack; },
38
- headers: responseErr.underlyingResponseHeaders,
39
- };
40
- }
41
-
42
- // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
43
- const errWithStack = generateErrorWithStack();
44
-
45
- return {
46
- mimeType: "text/plain",
47
- status,
48
- value: `${err}`,
49
- get stack() { return ((err?.stack) as (string | undefined)) ?? errWithStack.stack; },
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
- const message = response.value;
55
- const errWithStack = generateErrorWithStack();
56
- const responseErr: Error & IResponseException = {
57
- errorFromRequestFluidObject: true,
58
- message,
59
- name: "Error",
60
- code: response.status,
61
- get stack() { return response.stack ?? errWithStack.stack; },
62
- underlyingResponseHeaders: response.headers,
63
- };
64
-
65
- return responseErr;
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
- packagePath: readonly string[] | undefined,
73
+ packagePath: readonly string[] | undefined,
73
74
  ): ITaggedTelemetryPropertyType | undefined {
74
- return packagePath ? { value: packagePath.join("/"), tag: TelemetryDataTag.CodeArtifact } : undefined;
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
- router: IFluidRouter, url: string | IRequest): Promise<T> {
79
- const request = typeof url === "string" ? { url } : url;
80
- const response = await router.request(request);
81
-
82
- if (response.status !== 200 || response.mimeType !== "fluid/object") {
83
- throw responseToException(response, request);
84
- }
85
-
86
- assert(response.value, 0x19a /* "Invalid response value for Fluid object request" */);
87
- return response.value as T;
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) => createResponseError(404, "not found", request);
91
-
92
- export function createResponseError(status: number, value: string, request: IRequest, headers?: { [key: string]: any }): IResponse {
93
- assert(status !== 200, 0x19b /* "Cannot not create response error on 200 status" */);
94
- // Omit query string which could contain personal data (aka "PII")
95
- const urlNoQuery = request.url?.split("?")[0];
96
-
97
- // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
98
- const errWithStack = generateErrorWithStack();
99
-
100
- return {
101
- mimeType: "text/plain",
102
- status,
103
- value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,
104
- get stack() { return errWithStack.stack; },
105
- headers,
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
- type: string,
113
- factory: Factory | Promise<Factory>,
114
- ): IFluidDataStoreFactory & IFluidDataStoreRegistry {
115
- return {
116
- type,
117
- get IFluidDataStoreFactory() { return this; },
118
- get IFluidDataStoreRegistry() { return this; },
119
- instantiateDataStore: async (context, existing) => (await factory).instantiateDataStore(context, existing),
120
- get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),
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
- packagePathToTelemetryProperty,
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
- IFetchSnapshotResult,
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
- 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
- }
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
- public async readBlob(path: string): Promise<ArrayBufferLike> {
19
- return this.storage.readBlob(`${this.path}/${path}`);
20
- }
18
+ public async readBlob(path: string): Promise<ArrayBufferLike> {
19
+ return this.storage.readBlob(`${this.path}/${path}`);
20
+ }
21
21
 
22
- public async contains(path: string): Promise<boolean> {
23
- return this.storage.contains(`${this.path}/${path}`);
24
- }
22
+ public async contains(path: string): Promise<boolean> {
23
+ return this.storage.contains(`${this.path}/${path}`);
24
+ }
25
25
 
26
- public async list(path: string): Promise<string[]> {
27
- return this.storage.list(`${this.path}/${path}`);
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
- 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 [];
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(inputTree: ITree | undefined, path: string): Promise<string[]> {
23
- const pathParts = getNormalizedObjectStoragePathParts(path);
24
- let tree: ITree | undefined = inputTree;
25
- while (tree?.entries !== undefined && pathParts.length > 0) {
26
- const part = pathParts.shift();
27
- const treeEntry = tree.entries.find((value) => {
28
- return value.type === "Tree" && value.path === part ? true : false;
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
- // this check is largely superfluous due to the same check being done
32
- // immediately above. the type system, however, is not aware of this.
33
- // so we must redundantly determine that the entry's type is "Tree"
34
- tree = treeEntry?.type === "Tree" ? treeEntry.value : undefined;
35
- }
36
- if (tree?.entries === undefined || pathParts.length !== 0) {
37
- throw new Error("path does not exist");
38
- }
39
- return tree.entries.filter((e) => e.type === "Blob").map((e) => e.path);
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
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/runtime-utils";
9
- export const pkgVersion = "2.0.0-internal.3.0.2";
9
+ export const pkgVersion = "2.0.0-internal.3.2.0";