@fluidframework/driver-utils 2.0.0-dev.3.1.0.125672 → 2.0.0-dev.4.1.0.148229

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 (137) hide show
  1. package/dist/fluidResolvedUrl.d.ts +8 -0
  2. package/dist/fluidResolvedUrl.d.ts.map +1 -1
  3. package/dist/fluidResolvedUrl.js +8 -0
  4. package/dist/fluidResolvedUrl.js.map +1 -1
  5. package/dist/index.d.ts +4 -11
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -21
  8. package/dist/index.js.map +1 -1
  9. package/dist/messageRecognition.d.ts +0 -20
  10. package/dist/messageRecognition.d.ts.map +1 -1
  11. package/dist/messageRecognition.js +1 -37
  12. package/dist/messageRecognition.js.map +1 -1
  13. package/dist/network.d.ts +0 -15
  14. package/dist/network.d.ts.map +1 -1
  15. package/dist/network.js.map +1 -1
  16. package/dist/networkUtils.d.ts +0 -10
  17. package/dist/networkUtils.d.ts.map +1 -1
  18. package/dist/networkUtils.js +1 -32
  19. package/dist/networkUtils.js.map +1 -1
  20. package/dist/packageVersion.d.ts +1 -1
  21. package/dist/packageVersion.js +1 -1
  22. package/dist/packageVersion.js.map +1 -1
  23. package/dist/parallelRequests.d.ts.map +1 -1
  24. package/dist/parallelRequests.js +33 -14
  25. package/dist/parallelRequests.js.map +1 -1
  26. package/dist/summaryForCreateNew.d.ts +21 -1
  27. package/dist/summaryForCreateNew.d.ts.map +1 -1
  28. package/dist/summaryForCreateNew.js +26 -1
  29. package/dist/summaryForCreateNew.js.map +1 -1
  30. package/dist/treeConversions.d.ts.map +1 -1
  31. package/dist/treeConversions.js +8 -9
  32. package/dist/treeConversions.js.map +1 -1
  33. package/lib/fluidResolvedUrl.d.ts +8 -0
  34. package/lib/fluidResolvedUrl.d.ts.map +1 -1
  35. package/lib/fluidResolvedUrl.js +8 -0
  36. package/lib/fluidResolvedUrl.js.map +1 -1
  37. package/lib/index.d.ts +4 -11
  38. package/lib/index.d.ts.map +1 -1
  39. package/lib/index.js +3 -10
  40. package/lib/index.js.map +1 -1
  41. package/lib/messageRecognition.d.ts +0 -20
  42. package/lib/messageRecognition.d.ts.map +1 -1
  43. package/lib/messageRecognition.js +0 -35
  44. package/lib/messageRecognition.js.map +1 -1
  45. package/lib/network.d.ts +0 -15
  46. package/lib/network.d.ts.map +1 -1
  47. package/lib/network.js.map +1 -1
  48. package/lib/networkUtils.d.ts +0 -10
  49. package/lib/networkUtils.d.ts.map +1 -1
  50. package/lib/networkUtils.js +0 -30
  51. package/lib/networkUtils.js.map +1 -1
  52. package/lib/packageVersion.d.ts +1 -1
  53. package/lib/packageVersion.js +1 -1
  54. package/lib/packageVersion.js.map +1 -1
  55. package/lib/parallelRequests.d.ts.map +1 -1
  56. package/lib/parallelRequests.js +34 -15
  57. package/lib/parallelRequests.js.map +1 -1
  58. package/lib/summaryForCreateNew.d.ts +21 -1
  59. package/lib/summaryForCreateNew.d.ts.map +1 -1
  60. package/lib/summaryForCreateNew.js +24 -0
  61. package/lib/summaryForCreateNew.js.map +1 -1
  62. package/lib/treeConversions.d.ts.map +1 -1
  63. package/lib/treeConversions.js +8 -9
  64. package/lib/treeConversions.js.map +1 -1
  65. package/package.json +52 -75
  66. package/src/fluidResolvedUrl.ts +8 -0
  67. package/src/index.ts +4 -19
  68. package/src/messageRecognition.ts +0 -36
  69. package/src/network.ts +0 -16
  70. package/src/networkUtils.ts +0 -32
  71. package/src/packageVersion.ts +1 -1
  72. package/src/parallelRequests.ts +37 -18
  73. package/src/summaryForCreateNew.ts +48 -2
  74. package/src/treeConversions.ts +8 -9
  75. package/dist/blobAggregationStorage.d.ts +0 -43
  76. package/dist/blobAggregationStorage.d.ts.map +0 -1
  77. package/dist/blobAggregationStorage.js +0 -323
  78. package/dist/blobAggregationStorage.js.map +0 -1
  79. package/dist/blobCacheStorageService.d.ts +0 -16
  80. package/dist/blobCacheStorageService.d.ts.map +0 -1
  81. package/dist/blobCacheStorageService.js +0 -29
  82. package/dist/blobCacheStorageService.js.map +0 -1
  83. package/dist/emptyDocumentDeltaStorageService.d.ts +0 -13
  84. package/dist/emptyDocumentDeltaStorageService.d.ts.map +0 -1
  85. package/dist/emptyDocumentDeltaStorageService.js +0 -20
  86. package/dist/emptyDocumentDeltaStorageService.js.map +0 -1
  87. package/dist/mapWithExpiration.d.ts +0 -34
  88. package/dist/mapWithExpiration.d.ts.map +0 -1
  89. package/dist/mapWithExpiration.js +0 -105
  90. package/dist/mapWithExpiration.js.map +0 -1
  91. package/dist/multiDocumentServiceFactory.d.ts +0 -16
  92. package/dist/multiDocumentServiceFactory.d.ts.map +0 -1
  93. package/dist/multiDocumentServiceFactory.js +0 -63
  94. package/dist/multiDocumentServiceFactory.js.map +0 -1
  95. package/dist/multiUrlResolver.d.ts +0 -20
  96. package/dist/multiUrlResolver.d.ts.map +0 -1
  97. package/dist/multiUrlResolver.js +0 -45
  98. package/dist/multiUrlResolver.js.map +0 -1
  99. package/dist/treeUtils.d.ts +0 -51
  100. package/dist/treeUtils.d.ts.map +0 -1
  101. package/dist/treeUtils.js +0 -85
  102. package/dist/treeUtils.js.map +0 -1
  103. package/lib/blobAggregationStorage.d.ts +0 -43
  104. package/lib/blobAggregationStorage.d.ts.map +0 -1
  105. package/lib/blobAggregationStorage.js +0 -318
  106. package/lib/blobAggregationStorage.js.map +0 -1
  107. package/lib/blobCacheStorageService.d.ts +0 -16
  108. package/lib/blobCacheStorageService.d.ts.map +0 -1
  109. package/lib/blobCacheStorageService.js +0 -25
  110. package/lib/blobCacheStorageService.js.map +0 -1
  111. package/lib/emptyDocumentDeltaStorageService.d.ts +0 -13
  112. package/lib/emptyDocumentDeltaStorageService.d.ts.map +0 -1
  113. package/lib/emptyDocumentDeltaStorageService.js +0 -16
  114. package/lib/emptyDocumentDeltaStorageService.js.map +0 -1
  115. package/lib/mapWithExpiration.d.ts +0 -34
  116. package/lib/mapWithExpiration.d.ts.map +0 -1
  117. package/lib/mapWithExpiration.js +0 -101
  118. package/lib/mapWithExpiration.js.map +0 -1
  119. package/lib/multiDocumentServiceFactory.d.ts +0 -16
  120. package/lib/multiDocumentServiceFactory.d.ts.map +0 -1
  121. package/lib/multiDocumentServiceFactory.js +0 -59
  122. package/lib/multiDocumentServiceFactory.js.map +0 -1
  123. package/lib/multiUrlResolver.d.ts +0 -20
  124. package/lib/multiUrlResolver.d.ts.map +0 -1
  125. package/lib/multiUrlResolver.js +0 -40
  126. package/lib/multiUrlResolver.js.map +0 -1
  127. package/lib/treeUtils.d.ts +0 -51
  128. package/lib/treeUtils.d.ts.map +0 -1
  129. package/lib/treeUtils.js +0 -80
  130. package/lib/treeUtils.js.map +0 -1
  131. package/src/blobAggregationStorage.ts +0 -420
  132. package/src/blobCacheStorageService.ts +0 -35
  133. package/src/emptyDocumentDeltaStorageService.ts +0 -25
  134. package/src/mapWithExpiration.ts +0 -124
  135. package/src/multiDocumentServiceFactory.ts +0 -91
  136. package/src/multiUrlResolver.ts +0 -48
  137. package/src/treeUtils.ts +0 -107
@@ -1 +1 @@
1
- {"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAmC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEpG;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IACtE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAiB,CAAC;IAC5D,yEAAyE;IACzE,MAAM,eAAe,GAAG,eAAe,IAAI,UAAU,CAAC;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I,CAAC,IAAI,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,eAAe,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst protocolSummary = summaryTree.tree[\".protocol\"] as ISummaryTree;\n\tconst appSummary = summaryTree.tree[\".app\"] as ISummaryTree;\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tconst adaptSumaryTree = protocolSummary && appSummary;\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tconst allSummaryEntries = adaptSumaryTree\n\t\t? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tconst k = adaptSumaryTree && [\"attributes\"].includes(key) ? `.${key}` : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n"]}
1
+ {"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAmC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC,WAAW,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,gBAAgB;QACzC,CAA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AE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,eAAe,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { isCombinedAppAndProtocolSummary } from \"./summaryForCreateNew\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);\n\tconst allSummaryEntries = adaptSummaryTree\n\t\t? [\n\t\t\t\t...Object.entries(summaryTree.tree[\".protocol\"].tree),\n\t\t\t\t...Object.entries(summaryTree.tree[\".app\"].tree),\n\t\t ]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\tconst k = adaptSummaryTree && key === \"attributes\" ? \".attributes\" : key;\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(k, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(k, convertSummaryTreeToSnapshotITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(k, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t};\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/driver-utils",
3
- "version": "2.0.0-dev.3.1.0.125672",
3
+ "version": "2.0.0-dev.4.1.0.148229",
4
4
  "description": "Collection of utility functions for Fluid drivers",
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 prettier && npm run eslint",
33
- "lint:fix": "npm run prettier: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,68 +36,72 @@
63
36
  },
64
37
  "dependencies": {
65
38
  "@fluidframework/common-definitions": "^0.20.1",
66
- "@fluidframework/common-utils": "^1.0.0",
67
- "@fluidframework/core-interfaces": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
68
- "@fluidframework/driver-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
69
- "@fluidframework/gitresources": "^0.1038.2000",
70
- "@fluidframework/protocol-base": "^0.1038.2000",
39
+ "@fluidframework/common-utils": "^1.1.1",
40
+ "@fluidframework/core-interfaces": "2.0.0-dev.4.1.0.148229",
41
+ "@fluidframework/driver-definitions": "2.0.0-dev.4.1.0.148229",
42
+ "@fluidframework/gitresources": "^0.1039.1000",
43
+ "@fluidframework/protocol-base": "^0.1039.1000",
71
44
  "@fluidframework/protocol-definitions": "^1.1.0",
72
- "@fluidframework/telemetry-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
45
+ "@fluidframework/telemetry-utils": "2.0.0-dev.4.1.0.148229",
73
46
  "axios": "^0.26.0",
74
47
  "url": "^0.11.0",
75
48
  "uuid": "^8.3.1"
76
49
  },
77
50
  "devDependencies": {
78
- "@fluid-tools/build-cli": "^0.8.0",
51
+ "@fluid-tools/build-cli": "^0.13.1",
79
52
  "@fluidframework/build-common": "^1.1.0",
80
- "@fluidframework/build-tools": "^0.8.0",
81
- "@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.3.0.0",
53
+ "@fluidframework/build-tools": "^0.13.1",
54
+ "@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.4.0.0",
82
55
  "@fluidframework/eslint-config-fluid": "^2.0.0",
83
- "@fluidframework/mocha-test-setup": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
84
- "@fluidframework/runtime-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
85
- "@microsoft/api-extractor": "^7.22.2",
86
- "@rushstack/eslint-config": "^2.5.1",
56
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.4.1.0.148229",
57
+ "@fluidframework/runtime-utils": "2.0.0-dev.4.1.0.148229",
58
+ "@microsoft/api-extractor": "^7.34.4",
87
59
  "@types/mocha": "^9.1.1",
88
- "@types/node": "^14.18.36",
60
+ "@types/node": "^14.18.38",
89
61
  "@types/sinon": "^7.0.13",
90
- "concurrently": "^6.2.0",
62
+ "concurrently": "^7.6.0",
91
63
  "copyfiles": "^2.4.1",
92
- "cross-env": "^7.0.2",
64
+ "cross-env": "^7.0.3",
93
65
  "eslint": "~8.6.0",
94
- "mocha": "^10.0.0",
95
- "nyc": "^15.0.0",
66
+ "mocha": "^10.2.0",
67
+ "mocha-json-output-reporter": "^2.0.1",
68
+ "mocha-multi-reporters": "^1.5.1",
69
+ "moment": "^2.21.0",
70
+ "nyc": "^15.1.0",
96
71
  "prettier": "~2.6.2",
97
- "rimraf": "^2.6.2",
72
+ "rimraf": "^4.4.0",
98
73
  "sinon": "^7.4.2",
99
74
  "typescript": "~4.5.5"
100
75
  },
101
76
  "typeValidation": {
102
- "version": "2.0.0-internal.3.1.0",
103
- "previousVersionStyle": "~previousMinor",
104
- "baselineRange": ">=2.0.0-internal.3.0.0 <2.0.0-internal.3.1.0",
105
- "baselineVersion": "2.0.0-internal.3.0.0",
106
- "broken": {
107
- "ClassDeclaration_AuthorizationError": {
108
- "backCompat": false
109
- },
110
- "ClassDeclaration_DeltaStreamConnectionForbiddenError": {
111
- "backCompat": false
112
- },
113
- "ClassDeclaration_FluidInvalidSchemaError": {
114
- "backCompat": false
115
- },
116
- "ClassDeclaration_GenericNetworkError": {
117
- "backCompat": false
118
- },
119
- "ClassDeclaration_LocationRedirectionError": {
120
- "backCompat": false
121
- },
122
- "ClassDeclaration_ThrottlingError": {
123
- "backCompat": false
124
- },
125
- "ClassDeclaration_UsageError": {
126
- "backCompat": false
127
- }
128
- }
77
+ "broken": {}
78
+ },
79
+ "scripts": {
80
+ "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
81
+ "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
82
+ "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
83
+ "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
84
+ "build:esnext": "tsc --project ./tsconfig.esnext.json",
85
+ "build:full": "npm run build",
86
+ "build:full:compile": "npm run build:compile",
87
+ "build:genver": "gen-version",
88
+ "build:test": "tsc --project ./src/test/tsconfig.json",
89
+ "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
90
+ "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
91
+ "eslint": "eslint --format stylish src",
92
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
93
+ "format": "npm run prettier:fix",
94
+ "lint": "npm run prettier && npm run eslint",
95
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
96
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
97
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
98
+ "test": "npm run test:mocha",
99
+ "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
100
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
101
+ "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
102
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
103
+ "tsc": "tsc",
104
+ "typetests:gen": "fluid-type-test-generator",
105
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
129
106
  }
130
- }
107
+ }
@@ -5,10 +5,18 @@
5
5
 
6
6
  import { IResolvedUrl, IFluidResolvedUrl } from "@fluidframework/driver-definitions";
7
7
 
8
+ /**
9
+ * @deprecated In the next major release all IResolvedUrl will be IFluidResolvedUrl,
10
+ * so this method is no longer necessary.
11
+ */
8
12
  export const isFluidResolvedUrl = (
9
13
  resolved: IResolvedUrl | undefined,
10
14
  ): resolved is IFluidResolvedUrl => resolved?.type === "fluid";
11
15
 
16
+ /**
17
+ * @deprecated In the next major release all IResolvedUrl will be IFluidResolvedUrl,
18
+ * so this method is no longer necessary.
19
+ */
12
20
  export function ensureFluidResolvedUrl(
13
21
  resolved: IResolvedUrl | undefined,
14
22
  ): asserts resolved is IFluidResolvedUrl {
package/src/index.ts CHANGED
@@ -3,23 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export { BlobAggregationStorage, SnapshotExtractor } from "./blobAggregationStorage";
7
- export { BlobCacheStorageService } from "./blobCacheStorageService";
8
6
  export { buildSnapshotTree } from "./buildSnapshotTree";
9
7
  export { DocumentStorageServiceProxy } from "./documentStorageServiceProxy";
10
- export { EmptyDocumentDeltaStorageService } from "./emptyDocumentDeltaStorageService";
11
8
  export { UsageError } from "./error";
12
9
  export { ensureFluidResolvedUrl, isFluidResolvedUrl } from "./fluidResolvedUrl";
13
10
  export { InsecureUrlResolver } from "./insecureUrlResolver";
14
- export { MapWithExpiration } from "./mapWithExpiration";
15
- export {
16
- canBeCoalescedByService,
17
- isRuntimeMessage,
18
- isUnpackedRuntimeMessage,
19
- MessageType2,
20
- } from "./messageRecognition";
21
- export { MultiDocumentServiceFactory } from "./multiDocumentServiceFactory";
22
- export { configurableUrlResolver, MultiUrlResolver } from "./multiUrlResolver";
11
+ export { canBeCoalescedByService, isRuntimeMessage, MessageType2 } from "./messageRecognition";
23
12
  export {
24
13
  AuthorizationError,
25
14
  canRetryOnError,
@@ -31,7 +20,6 @@ export {
31
20
  GenericNetworkError,
32
21
  getRetryDelayFromError,
33
22
  getRetryDelaySecondsFromError,
34
- IAnyDriverError,
35
23
  isOnline,
36
24
  LocationRedirectionError,
37
25
  NetworkErrorBasic,
@@ -40,7 +28,7 @@ export {
40
28
  RetryableError,
41
29
  ThrottlingError,
42
30
  } from "./network";
43
- export { logNetworkFailure, waitForConnectedState } from "./networkUtils";
31
+ export { logNetworkFailure } from "./networkUtils";
44
32
  export {
45
33
  emptyMessageStream,
46
34
  ParallelRequests,
@@ -55,12 +43,9 @@ export { readAndParse } from "./readAndParse";
55
43
  export { IProgress, runWithRetry } from "./runWithRetry";
56
44
  export {
57
45
  combineAppAndProtocolSummary,
46
+ CombinedAppAndProtocolSummary,
58
47
  getDocAttributesFromProtocolSummary,
59
48
  getQuorumValuesFromProtocolSummary,
49
+ isCombinedAppAndProtocolSummary,
60
50
  } from "./summaryForCreateNew";
61
51
  export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
62
- export {
63
- convertSnapshotAndBlobsToSummaryTree,
64
- ISummaryTreeAssemblerProps,
65
- SummaryTreeAssembler,
66
- } from "./treeUtils";
@@ -17,42 +17,6 @@ export function isRuntimeMessage(message: { type: string }): boolean {
17
17
  return message.type === MessageType.Operation;
18
18
  }
19
19
 
20
- enum RuntimeMessage {
21
- FluidDataStoreOp = "component",
22
- Attach = "attach",
23
- ChunkedOp = "chunkedOp",
24
- BlobAttach = "blobAttach",
25
- Rejoin = "rejoin",
26
- Alias = "alias",
27
- Operation = "op",
28
- }
29
-
30
- /**
31
- * Determines whether or not the message type is one of the following: (legacy)
32
- *
33
- * - "component"
34
- *
35
- * - "attach"
36
- *
37
- * - "chunkedOp"
38
- *
39
- * - "blobAttach"
40
- *
41
- * - "rejoin"
42
- *
43
- * - "alias"
44
- *
45
- * - "op"
46
- *
47
- * @deprecated This API should not be used.
48
- */
49
- export function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean {
50
- if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {
51
- return true;
52
- }
53
- return false;
54
- }
55
-
56
20
  // ADO #1385: staging code changes across layers.
57
21
  // Eventually to be replaced by MessageType.accept
58
22
  export enum MessageType2 {
package/src/network.ts CHANGED
@@ -34,22 +34,6 @@ export function isOnline(): OnlineStatus {
34
34
  return OnlineStatus.Unknown;
35
35
  }
36
36
 
37
- /**
38
- * Interface describing errors and warnings raised by any driver code.
39
- * Not expected to be implemented by a class or an object literal, but rather used in place of
40
- * any or unknown in various function signatures that pass errors around.
41
- *
42
- * "Any" in the interface name is a nod to the fact that errorType has lost its type constraint.
43
- * It will be either DriverErrorType or the specific driver's specialized error type enum,
44
- * but we can't reference a specific driver's error type enum in this code.
45
- *
46
- * @deprecated - In favour of {@link @fluidframework/driver-definitions#IAnyDriverError} so that
47
- * it can used from the base to upper layers.
48
- */
49
- export interface IAnyDriverError extends Omit<IDriverErrorBase, "errorType"> {
50
- readonly errorType: string;
51
- }
52
-
53
37
  /** Telemetry props with driver-specific required properties */
54
38
  export type DriverErrorTelemetryProps = ITelemetryProperties & {
55
39
  driverVersion: string | undefined;
@@ -29,35 +29,3 @@ export function logNetworkFailure(
29
29
  newEvent.category = canRetryOnError(error) ? "generic" : "error";
30
30
  logger.sendTelemetryEvent(newEvent, error);
31
31
  }
32
-
33
- /**
34
- * Wait for browser to get to connected state.
35
- * If connected, waits minimum of minDelay anyway (between network retries)
36
- * If disconnected, polls every 30 seconds anyway, to make sure we are not getting stuck because of wrong signal
37
- * Note that browsers will have false positives (like having Hyper-V adapter on machine,
38
- * or machine connected to router that is not connected to internet)
39
- * But there should be no false negatives.
40
- * The only exception - Opera returns false when user enters "Work Offline" mode, regardless of actual connectivity.
41
- */
42
- // eslint-disable-next-line @typescript-eslint/promise-function-async
43
- export function waitForConnectedState(minDelay: number): Promise<void> {
44
- // Use this frequency to poll even when we are offline and able to setup online/offline listener
45
- // This is mostly safety net
46
- const offlinePollFrequency = 30000;
47
-
48
- return new Promise((resolve) => {
49
- let listener: () => void = resolve;
50
- let delay = minDelay;
51
- if (isOnline() === OnlineStatus.Offline) {
52
- if (window?.addEventListener !== undefined) {
53
- listener = () => {
54
- resolve();
55
- window.removeEventListener("online", listener);
56
- };
57
- window.addEventListener("online", listener, false);
58
- delay = Math.max(minDelay, offlinePollFrequency);
59
- }
60
- }
61
- setTimeout(listener, delay);
62
- });
63
- }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/driver-utils";
9
- export const pkgVersion = "2.0.0-dev.3.1.0.125672";
9
+ export const pkgVersion = "2.0.0-dev.4.1.0.148229";
@@ -8,7 +8,7 @@ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
8
8
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
9
9
  import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driver-definitions";
10
10
  import { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from "./network";
11
- import { waitForConnectedState, logNetworkFailure } from "./networkUtils";
11
+ import { logNetworkFailure } from "./networkUtils";
12
12
  // For now, this package is versioned and released in unison with the specific drivers
13
13
  import { pkgVersion as driverVersion } from "./packageVersion";
14
14
 
@@ -379,6 +379,19 @@ export class Queue<T> implements IStream<T> {
379
379
  }
380
380
  }
381
381
 
382
+ const waitForOnline = async (): Promise<void> => {
383
+ // Only wait if we have a strong signal that we're offline - otherwise assume we're online.
384
+ if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
385
+ return new Promise<void>((resolve) => {
386
+ const resolveAndRemoveListener = () => {
387
+ resolve();
388
+ globalThis.removeEventListener("online", resolveAndRemoveListener);
389
+ };
390
+ globalThis.addEventListener("online", resolveAndRemoveListener);
391
+ });
392
+ }
393
+ };
394
+
382
395
  /**
383
396
  * Retrieve single batch of ops
384
397
  * @param request - request index
@@ -403,7 +416,6 @@ async function getSingleOpBatch(
403
416
  let lastSuccessTime: number | undefined;
404
417
 
405
418
  let retry: number = 0;
406
- const deltas: ISequencedDocumentMessage[] = [];
407
419
  const nothing = { partial: false, cancel: true, payload: [] };
408
420
 
409
421
  while (signal?.aborted !== true) {
@@ -412,23 +424,22 @@ async function getSingleOpBatch(
412
424
  const startTime = performance.now();
413
425
 
414
426
  try {
415
- // Issue async request for deltas - limit the number fetched to MaxBatchDeltas
416
- const deltasP = get({ ...props, retry } /* telemetry props */);
417
-
418
- const { messages, partialResult } = await deltasP;
419
- deltas.push(...messages);
420
-
421
- const deltasRetrievedLast = messages.length;
427
+ // Issue async request for deltas
428
+ const { messages, partialResult } = await get(
429
+ { ...props, retry } /* telemetry props */,
430
+ );
422
431
 
423
- if (deltasRetrievedLast !== 0 || !strongTo) {
424
- return { payload: deltas, cancel: false, partial: partialResult };
432
+ // If we got messages back, return them. Return regardless of whether we got messages back if we didn't
433
+ // specify a "to", since we don't have an expectation of how many to receive.
434
+ if (messages.length !== 0 || !strongTo) {
435
+ return { payload: messages, cancel: false, partial: partialResult };
425
436
  }
426
437
 
427
- // Storage does not have ops we need.
428
- // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry
429
- // count since something prevented us from seeing those deltas
438
+ // Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.
430
439
 
431
440
  if (lastSuccessTime === undefined) {
441
+ // Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.
442
+ // If we keep getting empty responses we'll eventually fail out below.
432
443
  lastSuccessTime = performance.now();
433
444
  } else if (performance.now() - lastSuccessTime > 30000) {
434
445
  // If we are connected and receiving proper responses from server, but can't get any ops back,
@@ -449,8 +460,6 @@ async function getSingleOpBatch(
449
460
  } catch (error) {
450
461
  const canRetry = canRetryOnError(error);
451
462
 
452
- lastSuccessTime = undefined;
453
-
454
463
  const retryAfter = getRetryDelayFromError(error);
455
464
 
456
465
  // This will log to error table only if the error is non-retryable
@@ -472,12 +481,22 @@ async function getSingleOpBatch(
472
481
  throw error;
473
482
  }
474
483
 
475
- if (retryAfter !== undefined && retryAfter >= 0) {
484
+ if (retryAfter !== undefined) {
485
+ // If the error told us to wait, then we will wait for that specific amount rather than the default.
476
486
  delay = retryAfter;
477
487
  }
478
488
  }
479
489
 
480
- await waitForConnectedState(delay);
490
+ // If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.
491
+ // Either way we will wait a little bit before retrying.
492
+ await new Promise<void>((resolve) => {
493
+ setTimeout(resolve, delay);
494
+ });
495
+
496
+ // If we believe we're offline, we assume there's no point in trying until we at least think we're online.
497
+ // NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
498
+ // should probably live in the driver.
499
+ await waitForOnline();
481
500
  }
482
501
 
483
502
  return nothing;
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { assert } from "@fluidframework/common-utils";
6
7
  import {
7
8
  ISummaryTree,
8
9
  SummaryType,
@@ -11,16 +12,61 @@ import {
11
12
  IDocumentAttributes,
12
13
  } from "@fluidframework/protocol-definitions";
13
14
 
15
+ /**
16
+ * Defines the current layout of an .app + .protocol summary tree
17
+ * this is used internally for create new, and single commit summary
18
+ * @internal
19
+ */
20
+ export interface CombinedAppAndProtocolSummary extends ISummaryTree {
21
+ tree: {
22
+ [".app"]: ISummaryTree;
23
+ [".protocol"]: ISummaryTree;
24
+ };
25
+ }
26
+
27
+ /**
28
+ * Validates the current layout of an .app + .protocol summary tree
29
+ * this is used internally for create new, and single commit summary
30
+ * @internal
31
+ */
32
+ export function isCombinedAppAndProtocolSummary(
33
+ summary: ISummaryTree | undefined,
34
+ ): summary is CombinedAppAndProtocolSummary {
35
+ if (
36
+ summary?.tree === undefined ||
37
+ summary.tree?.[".app"]?.type !== SummaryType.Tree ||
38
+ summary.tree?.[".protocol"]?.type !== SummaryType.Tree
39
+ ) {
40
+ return false;
41
+ }
42
+ const treeKeys = Object.keys(summary.tree);
43
+ if (treeKeys.length !== 2) {
44
+ return false;
45
+ }
46
+ return true;
47
+ }
48
+
14
49
  /**
15
50
  * Combine the app summary and protocol summary in 1 tree.
16
51
  * @param appSummary - Summary of the app.
17
52
  * @param protocolSummary - Summary of the protocol.
53
+ * @internal
54
+ *
55
+ * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
18
56
  */
19
57
  export function combineAppAndProtocolSummary(
20
58
  appSummary: ISummaryTree,
21
59
  protocolSummary: ISummaryTree,
22
- ): ISummaryTree {
23
- const createNewSummary: ISummaryTree = {
60
+ ): CombinedAppAndProtocolSummary {
61
+ assert(
62
+ !isCombinedAppAndProtocolSummary(appSummary),
63
+ 0x5a8 /* app summary is already a combined tree! */,
64
+ );
65
+ assert(
66
+ !isCombinedAppAndProtocolSummary(protocolSummary),
67
+ 0x5a9 /* protocol summary is already a combined tree! */,
68
+ );
69
+ const createNewSummary: CombinedAppAndProtocolSummary = {
24
70
  type: SummaryType.Tree,
25
71
  tree: {
26
72
  ".protocol": protocolSummary,
@@ -6,6 +6,7 @@
6
6
  import { Uint8ArrayToString, unreachableCase } from "@fluidframework/common-utils";
7
7
  import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "@fluidframework/protocol-base";
8
8
  import { ISummaryTree, ITree, ITreeEntry, SummaryType } from "@fluidframework/protocol-definitions";
9
+ import { isCombinedAppAndProtocolSummary } from "./summaryForCreateNew";
9
10
 
10
11
  /**
11
12
  * Converts ISummaryTree to ITree format.
@@ -13,18 +14,16 @@ import { ISummaryTree, ITree, ITreeEntry, SummaryType } from "@fluidframework/pr
13
14
  */
14
15
  export function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {
15
16
  const entries: ITreeEntry[] = [];
16
- const protocolSummary = summaryTree.tree[".protocol"] as ISummaryTree;
17
- const appSummary = summaryTree.tree[".app"] as ISummaryTree;
18
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
19
- const adaptSumaryTree = protocolSummary && appSummary;
20
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
21
- const allSummaryEntries = adaptSumaryTree
22
- ? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]
17
+ const adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);
18
+ const allSummaryEntries = adaptSummaryTree
19
+ ? [
20
+ ...Object.entries(summaryTree.tree[".protocol"].tree),
21
+ ...Object.entries(summaryTree.tree[".app"].tree),
22
+ ]
23
23
  : Object.entries(summaryTree.tree);
24
24
 
25
25
  for (const [key, value] of allSummaryEntries) {
26
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
27
- const k = adaptSumaryTree && ["attributes"].includes(key) ? `.${key}` : key;
26
+ const k = adaptSummaryTree && key === "attributes" ? ".attributes" : key;
28
27
  switch (value.type) {
29
28
  case SummaryType.Blob: {
30
29
  let parsedContent: string;
@@ -1,43 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
6
- import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
7
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
8
- export declare abstract class SnapshotExtractor {
9
- protected readonly aggregatedBlobName = "__big";
10
- protected readonly virtualIdPrefix = "__";
11
- protected virtualIdCounter: number;
12
- protected getNextVirtualId(): string;
13
- abstract getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;
14
- abstract setBlob(id: string, tree: ISnapshotTree, content: string): any;
15
- unpackSnapshotCore(snapshot: ISnapshotTree, level?: number): Promise<void>;
16
- }
17
- export declare class BlobAggregationStorage extends SnapshotExtractor implements IDocumentStorageService {
18
- private readonly storage;
19
- private readonly logger;
20
- private readonly allowPacking;
21
- private readonly packingLevel;
22
- private readonly blobCutOffSize?;
23
- static readonly fullDataStoreSummaries = true;
24
- protected loadedFromSummary: boolean;
25
- protected virtualBlobs: Map<string, ArrayBufferLike>;
26
- static wrap(storage: IDocumentStorageService, logger: ITelemetryLogger, allowPacking?: boolean, packingLevel?: number): BlobAggregationStorage;
27
- static unpackSnapshot(snapshot: ISnapshotTree): Promise<void>;
28
- get policies(): IDocumentStorageServicePolicies | undefined;
29
- unpackSnapshot(snapshot: ISnapshotTree): Promise<void>;
30
- protected constructor(storage: IDocumentStorageService, logger: ITelemetryLogger, allowPacking: boolean, packingLevel: number, blobCutOffSize?: number | undefined);
31
- setBlob(id: string, tree: ISnapshotTree, content: string): void;
32
- getBlob(id: string, tree: ISnapshotTree): Promise<ArrayBufferLike>;
33
- get repositoryUrl(): string;
34
- getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
35
- downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
36
- createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
37
- getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
38
- readBlob(id: string): Promise<ArrayBufferLike>;
39
- uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
40
- private compressSmallBlobs;
41
- protected isRealStorageId(id: string): boolean;
42
- }
43
- //# sourceMappingURL=blobAggregationStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"blobAggregationStorage.d.ts","sourceRoot":"","sources":["../src/blobAggregationStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EAER,MAAM,sCAAsC,CAAC;AAS9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AA0CtE,8BAAsB,iBAAiB;IACtC,SAAS,CAAC,QAAQ,CAAC,kBAAkB,WAAW;IAChD,SAAS,CAAC,QAAQ,CAAC,eAAe,QAAQ;IAG1C,SAAS,CAAC,gBAAgB,SAAK;IAC/B,SAAS,CAAC,gBAAgB;IAI1B,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAC3E,QAAQ,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM;IAEpD,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAsClF;AAoCD,qBAAa,sBAAuB,SAAQ,iBAAkB,YAAW,uBAAuB;IAiE9F,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IA1DjC,MAAM,CAAC,QAAQ,CAAC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