@fluidframework/runtime-utils 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.
Files changed (187) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +191 -0
  4. package/README.md +68 -1
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/runtime-utils.api.md +201 -0
  8. package/dist/{dataStoreHandleContextUtils.js → dataStoreHandleContextUtils.cjs} +5 -2
  9. package/dist/dataStoreHandleContextUtils.cjs.map +1 -0
  10. package/dist/dataStoreHandleContextUtils.d.ts +1 -0
  11. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  12. package/dist/{dataStoreHelpers.js → dataStoreHelpers.cjs} +44 -25
  13. package/dist/dataStoreHelpers.cjs.map +1 -0
  14. package/dist/dataStoreHelpers.d.ts +23 -4
  15. package/dist/dataStoreHelpers.d.ts.map +1 -1
  16. package/dist/index.cjs +44 -0
  17. package/dist/index.cjs.map +1 -0
  18. package/dist/index.d.ts +9 -9
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/{objectstoragepartition.js → objectstoragepartition.cjs} +4 -3
  21. package/dist/objectstoragepartition.cjs.map +1 -0
  22. package/dist/objectstoragepartition.d.ts +1 -0
  23. package/dist/objectstoragepartition.d.ts.map +1 -1
  24. package/dist/{objectstorageutils.js → objectstorageutils.cjs} +11 -15
  25. package/dist/objectstorageutils.cjs.map +1 -0
  26. package/dist/objectstorageutils.d.ts +6 -0
  27. package/dist/objectstorageutils.d.ts.map +1 -1
  28. package/dist/{requestParser.js → requestParser.cjs} +7 -11
  29. package/dist/requestParser.cjs.map +1 -0
  30. package/dist/requestParser.d.ts +1 -0
  31. package/dist/requestParser.d.ts.map +1 -1
  32. package/dist/runtime-utils-alpha.d.ts +155 -0
  33. package/dist/runtime-utils-beta.d.ts +103 -0
  34. package/dist/runtime-utils-public.d.ts +103 -0
  35. package/dist/runtime-utils-untrimmed.d.ts +306 -0
  36. package/dist/{runtimeFactoryHelper.js → runtimeFactoryHelper.cjs} +11 -12
  37. package/dist/runtimeFactoryHelper.cjs.map +1 -0
  38. package/dist/runtimeFactoryHelper.d.ts +4 -1
  39. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  40. package/dist/{summaryUtils.js → summaryUtils.cjs} +138 -34
  41. package/dist/summaryUtils.cjs.map +1 -0
  42. package/dist/summaryUtils.d.ts +66 -4
  43. package/dist/summaryUtils.d.ts.map +1 -1
  44. package/dist/tsdoc-metadata.json +11 -0
  45. package/dist/unpackUsedRoutes.cjs +34 -0
  46. package/dist/unpackUsedRoutes.cjs.map +1 -0
  47. package/dist/unpackUsedRoutes.d.ts +12 -0
  48. package/dist/unpackUsedRoutes.d.ts.map +1 -0
  49. package/dist/{utils.js → utils.cjs} +2 -1
  50. package/dist/utils.cjs.map +1 -0
  51. package/dist/utils.d.ts +7 -2
  52. package/dist/utils.d.ts.map +1 -1
  53. package/lib/{dataStoreHandleContextUtils.d.ts → dataStoreHandleContextUtils.d.mts} +1 -0
  54. package/lib/dataStoreHandleContextUtils.d.mts.map +1 -0
  55. package/lib/{dataStoreHandleContextUtils.js → dataStoreHandleContextUtils.mjs} +5 -2
  56. package/lib/dataStoreHandleContextUtils.mjs.map +1 -0
  57. package/lib/{dataStoreHelpers.d.ts → dataStoreHelpers.d.mts} +23 -4
  58. package/lib/dataStoreHelpers.d.mts.map +1 -0
  59. package/lib/{dataStoreHelpers.js → dataStoreHelpers.mjs} +42 -22
  60. package/lib/dataStoreHelpers.mjs.map +1 -0
  61. package/lib/index.d.mts +14 -0
  62. package/lib/index.d.mts.map +1 -0
  63. package/lib/index.mjs +14 -0
  64. package/lib/index.mjs.map +1 -0
  65. package/lib/{objectstoragepartition.d.ts → objectstoragepartition.d.mts} +1 -0
  66. package/lib/objectstoragepartition.d.mts.map +1 -0
  67. package/lib/{objectstoragepartition.js → objectstoragepartition.mjs} +3 -2
  68. package/lib/objectstoragepartition.mjs.map +1 -0
  69. package/lib/{objectstorageutils.d.ts → objectstorageutils.d.mts} +6 -0
  70. package/lib/objectstorageutils.d.mts.map +1 -0
  71. package/lib/{objectstorageutils.js → objectstorageutils.mjs} +11 -15
  72. package/lib/objectstorageutils.mjs.map +1 -0
  73. package/lib/{requestParser.d.ts → requestParser.d.mts} +1 -4
  74. package/lib/requestParser.d.mts.map +1 -0
  75. package/lib/{requestParser.js → requestParser.mjs} +7 -11
  76. package/lib/requestParser.mjs.map +1 -0
  77. package/lib/runtime-utils-alpha.d.mts +155 -0
  78. package/lib/runtime-utils-beta.d.mts +103 -0
  79. package/lib/runtime-utils-public.d.mts +103 -0
  80. package/lib/runtime-utils-untrimmed.d.mts +306 -0
  81. package/lib/{runtimeFactoryHelper.d.ts → runtimeFactoryHelper.d.mts} +4 -1
  82. package/lib/runtimeFactoryHelper.d.mts.map +1 -0
  83. package/lib/runtimeFactoryHelper.mjs +24 -0
  84. package/lib/runtimeFactoryHelper.mjs.map +1 -0
  85. package/lib/{summaryUtils.d.ts → summaryUtils.d.mts} +66 -4
  86. package/lib/summaryUtils.d.mts.map +1 -0
  87. package/lib/{summaryUtils.js → summaryUtils.mjs} +129 -26
  88. package/lib/summaryUtils.mjs.map +1 -0
  89. package/lib/unpackUsedRoutes.d.mts +12 -0
  90. package/lib/unpackUsedRoutes.d.mts.map +1 -0
  91. package/lib/unpackUsedRoutes.mjs +30 -0
  92. package/lib/unpackUsedRoutes.mjs.map +1 -0
  93. package/lib/{utils.d.ts → utils.d.mts} +7 -2
  94. package/lib/utils.d.mts.map +1 -0
  95. package/lib/{utils.js → utils.mjs} +2 -1
  96. package/lib/utils.mjs.map +1 -0
  97. package/package.json +102 -66
  98. package/prettier.config.cjs +8 -0
  99. package/src/dataStoreHandleContextUtils.ts +24 -16
  100. package/src/dataStoreHelpers.ts +106 -83
  101. package/src/index.ts +31 -9
  102. package/src/objectstoragepartition.ts +18 -14
  103. package/src/objectstorageutils.ts +37 -36
  104. package/src/requestParser.ts +81 -86
  105. package/src/runtimeFactoryHelper.ts +27 -26
  106. package/src/summaryUtils.ts +425 -299
  107. package/src/unpackUsedRoutes.ts +31 -0
  108. package/src/utils.ts +12 -7
  109. package/tsc-multi.test.json +4 -0
  110. package/tsconfig.json +10 -12
  111. package/dist/dataStoreHandleContextUtils.js.map +0 -1
  112. package/dist/dataStoreHelpers.js.map +0 -1
  113. package/dist/index.js +0 -26
  114. package/dist/index.js.map +0 -1
  115. package/dist/objectstoragepartition.js.map +0 -1
  116. package/dist/objectstorageutils.js.map +0 -1
  117. package/dist/packageVersion.d.ts +0 -9
  118. package/dist/packageVersion.d.ts.map +0 -1
  119. package/dist/packageVersion.js +0 -12
  120. package/dist/packageVersion.js.map +0 -1
  121. package/dist/requestParser.js.map +0 -1
  122. package/dist/runtimeFactoryHelper.js.map +0 -1
  123. package/dist/summarizerNode/index.d.ts +0 -8
  124. package/dist/summarizerNode/index.d.ts.map +0 -1
  125. package/dist/summarizerNode/index.js +0 -12
  126. package/dist/summarizerNode/index.js.map +0 -1
  127. package/dist/summarizerNode/summarizerNode.d.ts +0 -139
  128. package/dist/summarizerNode/summarizerNode.d.ts.map +0 -1
  129. package/dist/summarizerNode/summarizerNode.js +0 -480
  130. package/dist/summarizerNode/summarizerNode.js.map +0 -1
  131. package/dist/summarizerNode/summarizerNodeUtils.d.ts +0 -161
  132. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  133. package/dist/summarizerNode/summarizerNodeUtils.js +0 -225
  134. package/dist/summarizerNode/summarizerNodeUtils.js.map +0 -1
  135. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +0 -133
  136. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  137. package/dist/summarizerNode/summarizerNodeWithGc.js +0 -294
  138. package/dist/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  139. package/dist/summaryUtils.js.map +0 -1
  140. package/dist/utils.js.map +0 -1
  141. package/lib/dataStoreHandleContextUtils.d.ts.map +0 -1
  142. package/lib/dataStoreHandleContextUtils.js.map +0 -1
  143. package/lib/dataStoreHelpers.d.ts.map +0 -1
  144. package/lib/dataStoreHelpers.js.map +0 -1
  145. package/lib/index.d.ts +0 -14
  146. package/lib/index.d.ts.map +0 -1
  147. package/lib/index.js +0 -14
  148. package/lib/index.js.map +0 -1
  149. package/lib/objectstoragepartition.d.ts.map +0 -1
  150. package/lib/objectstoragepartition.js.map +0 -1
  151. package/lib/objectstorageutils.d.ts.map +0 -1
  152. package/lib/objectstorageutils.js.map +0 -1
  153. package/lib/packageVersion.d.ts +0 -9
  154. package/lib/packageVersion.d.ts.map +0 -1
  155. package/lib/packageVersion.js +0 -9
  156. package/lib/packageVersion.js.map +0 -1
  157. package/lib/requestParser.d.ts.map +0 -1
  158. package/lib/requestParser.js.map +0 -1
  159. package/lib/runtimeFactoryHelper.d.ts.map +0 -1
  160. package/lib/runtimeFactoryHelper.js +0 -25
  161. package/lib/runtimeFactoryHelper.js.map +0 -1
  162. package/lib/summarizerNode/index.d.ts +0 -8
  163. package/lib/summarizerNode/index.d.ts.map +0 -1
  164. package/lib/summarizerNode/index.js +0 -7
  165. package/lib/summarizerNode/index.js.map +0 -1
  166. package/lib/summarizerNode/summarizerNode.d.ts +0 -139
  167. package/lib/summarizerNode/summarizerNode.d.ts.map +0 -1
  168. package/lib/summarizerNode/summarizerNode.js +0 -475
  169. package/lib/summarizerNode/summarizerNode.js.map +0 -1
  170. package/lib/summarizerNode/summarizerNodeUtils.d.ts +0 -161
  171. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +0 -1
  172. package/lib/summarizerNode/summarizerNodeUtils.js +0 -216
  173. package/lib/summarizerNode/summarizerNodeUtils.js.map +0 -1
  174. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +0 -133
  175. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +0 -1
  176. package/lib/summarizerNode/summarizerNodeWithGc.js +0 -289
  177. package/lib/summarizerNode/summarizerNodeWithGc.js.map +0 -1
  178. package/lib/summaryUtils.d.ts.map +0 -1
  179. package/lib/summaryUtils.js.map +0 -1
  180. package/lib/utils.d.ts.map +0 -1
  181. package/lib/utils.js.map +0 -1
  182. package/src/packageVersion.ts +0 -9
  183. package/src/summarizerNode/index.ts +0 -8
  184. package/src/summarizerNode/summarizerNode.ts +0 -662
  185. package/src/summarizerNode/summarizerNodeUtils.ts +0 -339
  186. package/src/summarizerNode/summarizerNodeWithGc.ts +0 -459
  187. package/tsconfig.esnext.json +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/runtime-utils",
3
- "version": "1.4.0-115997",
3
+ "version": "2.0.0-dev-rc.1.0.0.224419",
4
4
  "description": "Collection of utility functions for Fluid Runtime",
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
- "main": "dist/index.js",
15
- "module": "lib/index.js",
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
- "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 -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
- "nyc": {
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/**/*.ts",
46
- "dist/test/**/*.js"
33
+ "src/test/**/*.*ts",
34
+ "dist/test/**/*.*js"
47
35
  ],
48
36
  "exclude-after-remap": false,
49
37
  "include": [
50
- "src/**/*.ts",
51
- "dist/**/*.js"
38
+ "src/**/*.*ts",
39
+ "dist/**/*.*js"
52
40
  ],
53
41
  "report-dir": "nyc/report",
54
42
  "reporter": [
@@ -59,44 +47,92 @@
59
47
  "temp-directory": "nyc/.nyc_output"
60
48
  },
61
49
  "dependencies": {
62
- "@fluidframework/common-definitions": "^0.20.1",
63
- "@fluidframework/common-utils": "^0.32.1",
64
- "@fluidframework/container-definitions": "1.4.0-115997",
65
- "@fluidframework/container-runtime-definitions": "1.4.0-115997",
66
- "@fluidframework/core-interfaces": "1.4.0-115997",
67
- "@fluidframework/datastore-definitions": "1.4.0-115997",
68
- "@fluidframework/garbage-collector": "1.4.0-115997",
69
- "@fluidframework/protocol-base": "^0.1036.5000",
70
- "@fluidframework/protocol-definitions": "^0.1028.2000",
71
- "@fluidframework/runtime-definitions": "1.4.0-115997",
72
- "@fluidframework/telemetry-utils": "1.4.0-115997"
50
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.224419",
51
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.1.0.0.224419",
52
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.1.0.0.224419",
53
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.224419",
54
+ "@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.224419",
55
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.224419",
56
+ "@fluidframework/driver-utils": "2.0.0-dev-rc.1.0.0.224419",
57
+ "@fluidframework/protocol-definitions": "^3.1.0-223007",
58
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.224419",
59
+ "@fluidframework/telemetry-utils": "2.0.0-dev-rc.1.0.0.224419"
73
60
  },
74
61
  "devDependencies": {
75
- "@fluidframework/build-common": "^0.24.0",
76
- "@fluidframework/build-tools": "^0.6.0-110101",
77
- "@fluidframework/eslint-config-fluid": "^0.28.2000",
78
- "@fluidframework/mocha-test-setup": "1.4.0-115997",
79
- "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@1.3.1",
80
- "@microsoft/api-extractor": "^7.22.2",
81
- "@rushstack/eslint-config": "^2.5.1",
62
+ "@arethetypeswrong/cli": "^0.13.3",
63
+ "@fluid-tools/build-cli": "0.29.0-222379",
64
+ "@fluidframework/build-common": "^2.0.3",
65
+ "@fluidframework/build-tools": "0.29.0-222379",
66
+ "@fluidframework/eslint-config-fluid": "^3.1.0",
67
+ "@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.224419",
68
+ "@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.7.2.0",
69
+ "@microsoft/api-extractor": "^7.38.3",
82
70
  "@types/mocha": "^9.1.1",
83
- "@types/node": "^14.18.0",
84
- "concurrently": "^6.2.0",
85
- "copyfiles": "^2.1.0",
86
- "cross-env": "^7.0.2",
87
- "eslint": "~8.6.0",
88
- "mocha": "^10.0.0",
89
- "nyc": "^15.0.0",
90
- "rimraf": "^2.6.2",
71
+ "@types/node": "^18.19.0",
72
+ "c8": "^7.7.1",
73
+ "copyfiles": "^2.4.1",
74
+ "cross-env": "^7.0.3",
75
+ "eslint": "~8.50.0",
76
+ "mocha": "^10.2.0",
77
+ "mocha-json-output-reporter": "^2.0.1",
78
+ "mocha-multi-reporters": "^1.5.1",
79
+ "moment": "^2.21.0",
80
+ "prettier": "~3.0.3",
81
+ "renamer": "^4.0.0",
82
+ "rimraf": "^4.4.0",
91
83
  "sinon": "^7.4.2",
92
- "ts-node": "^7.0.1",
93
- "typescript": "~4.5.5",
94
- "typescript-formatter": "7.1.0"
84
+ "ts-node": "^10.9.1",
85
+ "tsc-multi": "^1.1.0",
86
+ "typescript": "~5.1.6"
87
+ },
88
+ "fluidBuild": {
89
+ "tasks": {
90
+ "build:docs": {
91
+ "dependsOn": [
92
+ "...",
93
+ "api-extractor:commonjs",
94
+ "api-extractor:esnext"
95
+ ],
96
+ "script": false
97
+ }
98
+ }
95
99
  },
96
100
  "typeValidation": {
97
- "version": "1.4.0",
98
- "baselineRange": "~1.3.0",
99
- "baselineVersion": "1.3.1",
100
- "broken": {}
101
+ "broken": {
102
+ "RemovedFunctionDeclaration_requestFluidObject": {
103
+ "forwardCompat": false,
104
+ "backCompat": false
105
+ }
106
+ }
107
+ },
108
+ "scripts": {
109
+ "api": "fluid-build . --task api",
110
+ "api-extractor:commonjs": "api-extractor run --local",
111
+ "api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
112
+ "build": "fluid-build . --task build",
113
+ "build:commonjs": "fluid-build . --task commonjs",
114
+ "build:compile": "fluid-build . --task compile",
115
+ "build:docs": "fluid-build . --task api",
116
+ "build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
117
+ "build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
118
+ "build:test": "tsc-multi --config ./tsc-multi.test.json",
119
+ "check:are-the-types-wrong": "attw --pack",
120
+ "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
121
+ "ci:build:docs": "api-extractor run",
122
+ "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
123
+ "eslint": "eslint --format stylish src",
124
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
125
+ "format": "npm run prettier:fix",
126
+ "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
127
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
128
+ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
129
+ "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
130
+ "test": "npm run test:mocha",
131
+ "test:coverage": "c8 npm test",
132
+ "test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
133
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
134
+ "tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
135
+ "typetests:gen": "fluid-type-test-generator",
136
+ "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
101
137
  }
102
- }
138
+ }
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
+ };
@@ -10,22 +10,30 @@ import { IFluidHandleContext } from "@fluidframework/core-interfaces";
10
10
  * @param path - The path to the Fluid object relative to the route context.
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
+ * @internal
13
14
  */
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;
15
+ export function generateHandleContextPath(
16
+ path: string,
17
+ routeContext?: IFluidHandleContext,
18
+ ): string {
19
+ if (path === "") {
20
+ // The `path` is empty.
21
+ // If the routeContext does not exist, this is the root.
22
+ // If the routeContext exists, the absolute path is the same as that of the routeContext.
23
+ return routeContext === undefined ? "" : routeContext.absolutePath;
24
+ } else {
25
+ // Remove beginning and trailing slashes, if any, from the path.
26
+ let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
27
+ normalizedPath = normalizedPath.endsWith("/")
28
+ ? normalizedPath.slice(0, -1)
29
+ : normalizedPath;
24
30
 
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
- }
31
+ // If the routeContext does not exist, path is the absolute path.
32
+ // If the routeContext exists, absolute path is routeContext's absolute path plus the path.
33
+ return routeContext === undefined
34
+ ? `/${normalizedPath}`
35
+ : `${
36
+ routeContext.absolutePath === "/" ? "" : routeContext.absolutePath
37
+ }/${normalizedPath}`;
38
+ }
31
39
  }
@@ -3,106 +3,129 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
+ import { IRequest, IResponse } from "@fluidframework/core-interfaces";
7
8
  import {
8
- FluidObject,
9
- IFluidRouter,
10
- IRequest,
11
- IResponse,
12
- } from "@fluidframework/core-interfaces";
13
- import {
14
- IFluidDataStoreFactory,
15
- IFluidDataStoreRegistry,
16
- IProvideFluidDataStoreRegistry,
9
+ IFluidDataStoreFactory,
10
+ IFluidDataStoreRegistry,
11
+ IProvideFluidDataStoreRegistry,
17
12
  } from "@fluidframework/runtime-definitions";
18
13
  import { generateErrorWithStack } from "@fluidframework/telemetry-utils";
19
14
 
20
15
  interface IResponseException extends Error {
21
- errorFromRequestFluidObject: true;
22
- message: string;
23
- code: number;
24
- stack?: string;
16
+ errorFromRequestFluidObject: true;
17
+ message: string;
18
+ code: number;
19
+ stack?: string;
20
+ underlyingResponseHeaders?: { [key: string]: any };
25
21
  }
26
22
 
23
+ /**
24
+ * @internal
25
+ */
27
26
  export function exceptionToResponse(err: any): IResponse {
28
- const status = 500;
29
- if (err !== null && typeof err === "object" && err.errorFromRequestFluidObject === true) {
30
- const responseErr: IResponseException = err;
31
- return {
32
- mimeType: "text/plain",
33
- status: responseErr.code,
34
- value: responseErr.message,
35
- get stack() { return responseErr.stack; },
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() { return ((err?.stack) as (string | undefined)) ?? errWithStack.stack; },
47
- };
27
+ const status = 500;
28
+ if (err !== null && typeof err === "object" && err.errorFromRequestFluidObject === true) {
29
+ const responseErr: IResponseException = err;
30
+ return {
31
+ mimeType: "text/plain",
32
+ status: responseErr.code,
33
+ value: responseErr.message,
34
+ get stack() {
35
+ return responseErr.stack;
36
+ },
37
+ headers: responseErr.underlyingResponseHeaders,
38
+ };
39
+ }
40
+
41
+ // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
42
+ const errWithStack = generateErrorWithStack();
43
+
44
+ return {
45
+ mimeType: "text/plain",
46
+ status,
47
+ value: `${err}`,
48
+ get stack() {
49
+ return (err?.stack as string | undefined) ?? errWithStack.stack;
50
+ },
51
+ };
48
52
  }
49
53
 
54
+ /**
55
+ * @internal
56
+ */
50
57
  export function responseToException(response: IResponse, request: IRequest): Error {
51
- const message = response.value;
52
- const errWithStack = generateErrorWithStack();
53
- const responseErr: Error & IResponseException = {
54
- errorFromRequestFluidObject: true,
55
- message,
56
- name: "Error",
57
- code: response.status,
58
- get stack() { return response.stack ?? errWithStack.stack; },
59
- };
60
-
61
- return responseErr;
62
- }
63
-
64
- export async function requestFluidObject<T = FluidObject>(
65
- router: IFluidRouter, url: string | IRequest): Promise<T> {
66
- const request = typeof url === "string" ? { url } : url;
67
- const response = await router.request(request);
68
-
69
- if (response.status !== 200 || response.mimeType !== "fluid/object") {
70
- throw responseToException(response, request);
71
- }
72
-
73
- assert(response.value, 0x19a /* "Invalid response value for Fluid object request" */);
74
- return response.value as T;
58
+ const message = response.value;
59
+ const errWithStack = generateErrorWithStack();
60
+ const responseErr: Error & IResponseException = {
61
+ errorFromRequestFluidObject: true,
62
+ message,
63
+ name: "Error",
64
+ code: response.status,
65
+ get stack() {
66
+ return response.stack ?? errWithStack.stack;
67
+ },
68
+ underlyingResponseHeaders: response.headers,
69
+ };
70
+
71
+ return responseErr;
75
72
  }
76
73
 
77
- export const create404Response = (request: IRequest) => createResponseError(404, "not found", request);
78
-
79
- export function createResponseError(status: number, value: string, request: IRequest): IResponse {
80
- assert(status !== 200, 0x19b /* "Cannot not create response error on 200 status" */);
81
- // Omit query string which could contain personal data (aka "PII")
82
- const urlNoQuery = request.url?.split("?")[0];
83
-
84
- // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
85
- const errWithStack = generateErrorWithStack();
74
+ /**
75
+ * @internal
76
+ */
77
+ export const create404Response = (request: IRequest) =>
78
+ createResponseError(404, "not found", request);
86
79
 
87
- return {
88
- mimeType: "text/plain",
89
- status,
90
- value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,
91
- get stack() { return errWithStack.stack; },
92
- };
80
+ /**
81
+ * @internal
82
+ */
83
+ export function createResponseError(
84
+ status: number,
85
+ value: string,
86
+ request: IRequest,
87
+ headers?: { [key: string]: any },
88
+ ): IResponse {
89
+ assert(status !== 200, 0x19b /* "Cannot not create response error on 200 status" */);
90
+ // Omit query string which could contain personal data unfit for logging
91
+ const urlNoQuery = request.url?.split("?")[0];
92
+
93
+ // Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it
94
+ const errWithStack = generateErrorWithStack();
95
+
96
+ return {
97
+ mimeType: "text/plain",
98
+ status,
99
+ value: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,
100
+ get stack() {
101
+ return errWithStack.stack;
102
+ },
103
+ headers,
104
+ };
93
105
  }
94
106
 
107
+ /**
108
+ * @internal
109
+ */
95
110
  export type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;
96
111
 
112
+ /**
113
+ * @internal
114
+ */
97
115
  export function createDataStoreFactory(
98
- type: string,
99
- factory: Factory | Promise<Factory>,
100
- ): IFluidDataStoreFactory & IFluidDataStoreRegistry {
101
- return {
102
- type,
103
- get IFluidDataStoreFactory() { return this; },
104
- get IFluidDataStoreRegistry() { return this; },
105
- instantiateDataStore: async (context, existing) => (await factory).instantiateDataStore(context, existing),
106
- get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),
107
- };
116
+ type: string,
117
+ factory: Factory | Promise<Factory>,
118
+ ): IFluidDataStoreFactory & IFluidDataStoreRegistry {
119
+ return {
120
+ type,
121
+ get IFluidDataStoreFactory() {
122
+ return this;
123
+ },
124
+ get IFluidDataStoreRegistry() {
125
+ return this;
126
+ },
127
+ instantiateDataStore: async (context, existing) =>
128
+ (await factory).instantiateDataStore(context, existing),
129
+ get: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),
130
+ };
108
131
  }
package/src/index.ts CHANGED
@@ -3,12 +3,34 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export * from "./dataStoreHandleContextUtils";
7
- export * from "./dataStoreHelpers";
8
- export * from "./objectstoragepartition";
9
- export * from "./objectstorageutils";
10
- export * from "./requestParser";
11
- export * from "./runtimeFactoryHelper";
12
- export * from "./summarizerNode";
13
- export * from "./summaryUtils";
14
- export * from "./utils";
6
+ export { generateHandleContextPath } from "./dataStoreHandleContextUtils";
7
+ export {
8
+ create404Response,
9
+ createDataStoreFactory,
10
+ createResponseError,
11
+ exceptionToResponse,
12
+ Factory,
13
+ responseToException,
14
+ } from "./dataStoreHelpers";
15
+ export { ObjectStoragePartition } from "./objectstoragepartition";
16
+ export { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from "./objectstorageutils";
17
+ export { RequestParser } from "./requestParser";
18
+ export { RuntimeFactoryHelper } from "./runtimeFactoryHelper";
19
+ export {
20
+ addBlobToSummary,
21
+ addSummarizeResultToSummary,
22
+ addTreeToSummary,
23
+ calculateStats,
24
+ convertSnapshotTreeToSummaryTree,
25
+ convertSummaryTreeToITree,
26
+ convertToSummaryTree,
27
+ convertToSummaryTreeWithStats,
28
+ GCDataBuilder,
29
+ getBlobSize,
30
+ mergeStats,
31
+ SummaryTreeBuilder,
32
+ TelemetryContext,
33
+ utf8ByteLength,
34
+ } from "./summaryUtils";
35
+ export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes";
36
+ export { ReadAndParseBlob, seqFromTree } from "./utils";
@@ -3,27 +3,31 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
6
+ import { assert } from "@fluidframework/core-utils";
7
7
  import { IChannelStorageService } from "@fluidframework/datastore-definitions";
8
8
 
9
9
  /**
10
10
  * Returns a new IChannelStorageService that resolves the given `path` as root.
11
+ * @internal
11
12
  */
12
13
  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
- }
14
+ constructor(
15
+ private readonly storage: IChannelStorageService,
16
+ private readonly path: string,
17
+ ) {
18
+ // `path` must not include the trailing separator.
19
+ assert(!path.endsWith("/"), 0x19c /* "storage service path has trailing separator" */);
20
+ }
17
21
 
18
- public async readBlob(path: string): Promise<ArrayBufferLike> {
19
- return this.storage.readBlob(`${this.path}/${path}`);
20
- }
22
+ public async readBlob(path: string): Promise<ArrayBufferLike> {
23
+ return this.storage.readBlob(`${this.path}/${path}`);
24
+ }
21
25
 
22
- public async contains(path: string): Promise<boolean> {
23
- return this.storage.contains(`${this.path}/${path}`);
24
- }
26
+ public async contains(path: string): Promise<boolean> {
27
+ return this.storage.contains(`${this.path}/${path}`);
28
+ }
25
29
 
26
- public async list(path: string): Promise<string[]> {
27
- return this.storage.list(`${this.path}/${path}`);
28
- }
30
+ public async list(path: string): Promise<string[]> {
31
+ return this.storage.list(`${this.path}/${path}`);
32
+ }
29
33
  }
@@ -5,44 +5,45 @@
5
5
 
6
6
  import { ITree } from "@fluidframework/protocol-definitions";
7
7
 
8
+ /**
9
+ * @internal
10
+ */
8
11
  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 [];
12
+ let normalizePath = path;
13
+ if (normalizePath.startsWith("/")) {
14
+ normalizePath = normalizePath.substr(1);
15
+ }
16
+ if (normalizePath.endsWith("/")) {
17
+ normalizePath = normalizePath.substr(0, normalizePath.length - 1);
18
+ }
19
+ if (normalizePath.length > 0) {
20
+ return normalizePath.split("/");
21
+ }
22
+ return [];
20
23
  }
21
24
 
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
- if (value.type === "Tree" && value.path === part) {
29
- return true;
30
- } else {
31
- return false;
32
- }
33
- });
25
+ /**
26
+ * @internal
27
+ */
28
+ export async function listBlobsAtTreePath(
29
+ inputTree: ITree | undefined,
30
+ path: string,
31
+ ): Promise<string[]> {
32
+ const pathParts = getNormalizedObjectStoragePathParts(path);
33
+ let tree: ITree | undefined = inputTree;
34
+ while (tree?.entries !== undefined && pathParts.length > 0) {
35
+ const part = pathParts.shift();
36
+ const treeEntry = tree.entries.find((value) => {
37
+ return value.type === "Tree" && value.path === part ? true : false;
38
+ });
34
39
 
35
- // this check is largely superfluous due to the same check being done
36
- // immediately above. the type system, however, is not aware of this.
37
- // so we must redundantly determine that the entry's type is "Tree"
38
- if (treeEntry?.type === "Tree") {
39
- tree = treeEntry.value;
40
- } else {
41
- tree = undefined;
42
- }
43
- }
44
- if (tree?.entries === undefined || pathParts.length !== 0) {
45
- throw new Error("path does not exist");
46
- }
47
- return tree.entries.filter((e) => e.type === "Blob").map((e) => e.path);
40
+ // this check is largely superfluous due to the same check being done
41
+ // immediately above. the type system, however, is not aware of this.
42
+ // so we must redundantly determine that the entry's type is "Tree"
43
+ tree = treeEntry?.type === "Tree" ? treeEntry.value : undefined;
44
+ }
45
+ if (tree?.entries === undefined || pathParts.length !== 0) {
46
+ throw new Error("path does not exist");
47
+ }
48
+ return tree.entries.filter((e) => e.type === "Blob").map((e) => e.path);
48
49
  }