@fluidframework/odsp-driver 2.1.0-276985 → 2.1.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 (187) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +93 -2
  3. package/api-extractor/{api-extractor-lint-beta.cjs.json → api-extractor.current.json} +2 -2
  4. package/api-extractor/api-extractor.legacy.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/odsp-driver.legacy.public.api.md +9 -0
  7. package/dist/ReadBufferUtils.d.ts.map +1 -1
  8. package/dist/ReadBufferUtils.js +1 -0
  9. package/dist/ReadBufferUtils.js.map +1 -1
  10. package/dist/WriteBufferUtils.d.ts.map +1 -1
  11. package/dist/WriteBufferUtils.js +2 -0
  12. package/dist/WriteBufferUtils.js.map +1 -1
  13. package/dist/compactSnapshotParser.d.ts.map +1 -1
  14. package/dist/compactSnapshotParser.js +28 -5
  15. package/dist/compactSnapshotParser.js.map +1 -1
  16. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  17. package/dist/compactSnapshotWriter.js +3 -1
  18. package/dist/compactSnapshotWriter.js.map +1 -1
  19. package/dist/createFile.d.ts.map +1 -1
  20. package/dist/createFile.js +1 -1
  21. package/dist/createFile.js.map +1 -1
  22. package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
  23. package/dist/createNewContainerOnExistingFile.js +2 -1
  24. package/dist/createNewContainerOnExistingFile.js.map +1 -1
  25. package/dist/createNewUtils.d.ts.map +1 -1
  26. package/dist/createNewUtils.js +3 -1
  27. package/dist/createNewUtils.js.map +1 -1
  28. package/dist/epochTracker.d.ts.map +1 -1
  29. package/dist/epochTracker.js +3 -3
  30. package/dist/epochTracker.js.map +1 -1
  31. package/dist/fetchSnapshot.d.ts +1 -1
  32. package/dist/fetchSnapshot.d.ts.map +1 -1
  33. package/dist/fetchSnapshot.js +8 -3
  34. package/dist/fetchSnapshot.js.map +1 -1
  35. package/dist/legacy.d.ts +1 -1
  36. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
  37. package/dist/localOdspDriver/localOdspDeltaStorageService.js +1 -0
  38. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
  39. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  40. package/dist/odspDelayLoadedDeltaStream.js +2 -0
  41. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  42. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  43. package/dist/odspDeltaStorageService.js +4 -1
  44. package/dist/odspDeltaStorageService.js.map +1 -1
  45. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  46. package/dist/odspDocumentDeltaConnection.js +2 -0
  47. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  48. package/dist/odspDocumentStorageManager.d.ts +1 -0
  49. package/dist/odspDocumentStorageManager.d.ts.map +1 -1
  50. package/dist/odspDocumentStorageManager.js +4 -3
  51. package/dist/odspDocumentStorageManager.js.map +1 -1
  52. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  53. package/dist/odspDocumentStorageServiceBase.js +2 -0
  54. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  55. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  56. package/dist/odspDriverUrlResolver.js +2 -1
  57. package/dist/odspDriverUrlResolver.js.map +1 -1
  58. package/dist/odspSnapshotParser.d.ts.map +1 -1
  59. package/dist/odspSnapshotParser.js +5 -1
  60. package/dist/odspSnapshotParser.js.map +1 -1
  61. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  62. package/dist/odspSummaryUploadManager.js +2 -1
  63. package/dist/odspSummaryUploadManager.js.map +1 -1
  64. package/dist/odspUrlHelper.d.ts.map +1 -1
  65. package/dist/odspUrlHelper.js +5 -1
  66. package/dist/odspUrlHelper.js.map +1 -1
  67. package/dist/odspUtils.d.ts +3 -2
  68. package/dist/odspUtils.d.ts.map +1 -1
  69. package/dist/odspUtils.js +7 -3
  70. package/dist/odspUtils.js.map +1 -1
  71. package/dist/packageVersion.d.ts +1 -1
  72. package/dist/packageVersion.d.ts.map +1 -1
  73. package/dist/packageVersion.js +1 -1
  74. package/dist/packageVersion.js.map +1 -1
  75. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  76. package/dist/prefetchLatestSnapshot.js +2 -2
  77. package/dist/prefetchLatestSnapshot.js.map +1 -1
  78. package/dist/public.d.ts +1 -1
  79. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  80. package/dist/zipItDataRepresentationUtils.js +9 -0
  81. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  82. package/internal.d.ts +1 -1
  83. package/legacy.d.ts +1 -1
  84. package/lib/ReadBufferUtils.d.ts.map +1 -1
  85. package/lib/ReadBufferUtils.js +1 -0
  86. package/lib/ReadBufferUtils.js.map +1 -1
  87. package/lib/WriteBufferUtils.d.ts.map +1 -1
  88. package/lib/WriteBufferUtils.js +2 -0
  89. package/lib/WriteBufferUtils.js.map +1 -1
  90. package/lib/compactSnapshotParser.d.ts.map +1 -1
  91. package/lib/compactSnapshotParser.js +28 -5
  92. package/lib/compactSnapshotParser.js.map +1 -1
  93. package/lib/compactSnapshotWriter.d.ts.map +1 -1
  94. package/lib/compactSnapshotWriter.js +3 -1
  95. package/lib/compactSnapshotWriter.js.map +1 -1
  96. package/lib/createFile.d.ts.map +1 -1
  97. package/lib/createFile.js +3 -3
  98. package/lib/createFile.js.map +1 -1
  99. package/lib/createNewContainerOnExistingFile.d.ts.map +1 -1
  100. package/lib/createNewContainerOnExistingFile.js +3 -2
  101. package/lib/createNewContainerOnExistingFile.js.map +1 -1
  102. package/lib/createNewUtils.d.ts.map +1 -1
  103. package/lib/createNewUtils.js +3 -1
  104. package/lib/createNewUtils.js.map +1 -1
  105. package/lib/epochTracker.d.ts.map +1 -1
  106. package/lib/epochTracker.js +4 -4
  107. package/lib/epochTracker.js.map +1 -1
  108. package/lib/fetchSnapshot.d.ts +1 -1
  109. package/lib/fetchSnapshot.d.ts.map +1 -1
  110. package/lib/fetchSnapshot.js +8 -3
  111. package/lib/fetchSnapshot.js.map +1 -1
  112. package/lib/legacy.d.ts +1 -1
  113. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
  114. package/lib/localOdspDriver/localOdspDeltaStorageService.js +1 -0
  115. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
  116. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  117. package/lib/odspDelayLoadedDeltaStream.js +2 -0
  118. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  119. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  120. package/lib/odspDeltaStorageService.js +4 -1
  121. package/lib/odspDeltaStorageService.js.map +1 -1
  122. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  123. package/lib/odspDocumentDeltaConnection.js +2 -0
  124. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  125. package/lib/odspDocumentStorageManager.d.ts +1 -0
  126. package/lib/odspDocumentStorageManager.d.ts.map +1 -1
  127. package/lib/odspDocumentStorageManager.js +5 -4
  128. package/lib/odspDocumentStorageManager.js.map +1 -1
  129. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  130. package/lib/odspDocumentStorageServiceBase.js +2 -0
  131. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  132. package/lib/odspDriverUrlResolver.d.ts.map +1 -1
  133. package/lib/odspDriverUrlResolver.js +2 -1
  134. package/lib/odspDriverUrlResolver.js.map +1 -1
  135. package/lib/odspSnapshotParser.d.ts.map +1 -1
  136. package/lib/odspSnapshotParser.js +5 -1
  137. package/lib/odspSnapshotParser.js.map +1 -1
  138. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  139. package/lib/odspSummaryUploadManager.js +2 -1
  140. package/lib/odspSummaryUploadManager.js.map +1 -1
  141. package/lib/odspUrlHelper.d.ts.map +1 -1
  142. package/lib/odspUrlHelper.js +5 -1
  143. package/lib/odspUrlHelper.js.map +1 -1
  144. package/lib/odspUtils.d.ts +3 -2
  145. package/lib/odspUtils.d.ts.map +1 -1
  146. package/lib/odspUtils.js +6 -3
  147. package/lib/odspUtils.js.map +1 -1
  148. package/lib/packageVersion.d.ts +1 -1
  149. package/lib/packageVersion.d.ts.map +1 -1
  150. package/lib/packageVersion.js +1 -1
  151. package/lib/packageVersion.js.map +1 -1
  152. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  153. package/lib/prefetchLatestSnapshot.js +3 -3
  154. package/lib/prefetchLatestSnapshot.js.map +1 -1
  155. package/lib/public.d.ts +1 -1
  156. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  157. package/lib/zipItDataRepresentationUtils.js +9 -0
  158. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  159. package/package.json +25 -35
  160. package/src/ReadBufferUtils.ts +2 -1
  161. package/src/WriteBufferUtils.ts +4 -2
  162. package/src/compactSnapshotParser.ts +41 -17
  163. package/src/compactSnapshotWriter.ts +4 -2
  164. package/src/createFile.ts +9 -1
  165. package/src/createNewContainerOnExistingFile.ts +16 -3
  166. package/src/createNewUtils.ts +5 -3
  167. package/src/epochTracker.ts +4 -3
  168. package/src/fetchSnapshot.ts +10 -3
  169. package/src/localOdspDriver/localOdspDeltaStorageService.ts +2 -1
  170. package/src/odspDelayLoadedDeltaStream.ts +4 -2
  171. package/src/odspDeltaStorageService.ts +4 -2
  172. package/src/odspDocumentDeltaConnection.ts +4 -2
  173. package/src/odspDocumentStorageManager.ts +18 -3
  174. package/src/odspDocumentStorageServiceBase.ts +4 -2
  175. package/src/odspDriverUrlResolver.ts +2 -1
  176. package/src/odspSnapshotParser.ts +8 -4
  177. package/src/odspSummaryUploadManager.ts +3 -2
  178. package/src/odspUrlHelper.ts +8 -4
  179. package/src/odspUtils.ts +13 -2
  180. package/src/packageVersion.ts +1 -1
  181. package/src/prefetchLatestSnapshot.ts +3 -4
  182. package/src/zipItDataRepresentationUtils.ts +18 -9
  183. package/tsconfig.json +0 -1
  184. package/api-extractor/api-extractor-lint-beta.esm.json +0 -5
  185. package/beta.d.ts +0 -11
  186. package/dist/beta.d.ts +0 -12
  187. package/lib/beta.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/odsp-driver
2
2
 
3
+ ## 2.1.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.5.0.0
4
8
 
5
9
  ### Minor Changes
package/README.md CHANGED
@@ -7,7 +7,7 @@ The ODSP Fluid service is not a publicly available service, and currently it is
7
7
  to connect to it. This driver is present as an illustration of a different Fluid driver implementation.
8
8
  Developers should not depend on this driver for their own solutions.
9
9
 
10
- <!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
10
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README_HEADER) -->
11
11
 
12
12
  <!-- prettier-ignore-start -->
13
13
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
@@ -20,6 +20,27 @@ library consumers should always prefer `^`.
20
20
 
21
21
  If using any of Fluid Framework's unstable APIs (for example, its `beta` APIs), we recommend using a more constrained version range, such as `~`.
22
22
 
23
+ ## Installation
24
+
25
+ To get started, install the package by running the following command:
26
+
27
+ ```bash
28
+ npm i @fluidframework/odsp-driver
29
+ ```
30
+
31
+ ## Importing from this package
32
+
33
+ This package leverages [package.json exports](https://nodejs.org/api/packages.html#exports) to separate its APIs by support level.
34
+ For more information on the related support guarantees, see [API Support Levels](https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels).
35
+
36
+ To access the `public` ([SemVer](https://semver.org/)) APIs, import via `@fluidframework/odsp-driver` like normal.
37
+
38
+ To access the `legacy` APIs, import via `@fluidframework/odsp-driver/legacy`.
39
+
40
+ ## API Documentation
41
+
42
+ API documentation for **@fluidframework/odsp-driver** is available at <https://fluidframework.com/docs/apis/odsp-driver>.
43
+
23
44
  <!-- prettier-ignore-end -->
24
45
 
25
46
  <!-- AUTO-GENERATED-CONTENT:END -->
@@ -42,11 +63,81 @@ Documenting some basics about opds-driver specific apis that are relevant for cr
42
63
  - Earlier, application needed to redeem the sharing link of the file before a /trees/latest fetch could be made. To reduce the number of round trips made to ODSP, redemption of the share link now happens along with fetching latest snapshot in the same api request by passing share link in `&sl` request parameter.
43
64
  - This api is also preflight-less, which means it is not preceded by an OPTIONS call in the browsers to reduce the network trips to the server.
44
65
 
45
- <!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
66
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README_FOOTER) -->
46
67
 
47
68
  <!-- prettier-ignore-start -->
48
69
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
49
70
 
71
+ ## Minimum Client Requirements
72
+
73
+ These are the platform requirements for the current version of Fluid Framework Client Packages.
74
+ These requirements err on the side of being too strict since within a major version they can be relaxed over time, but not made stricter.
75
+ For Long Term Support (LTS) versions this can require supporting these platforms for several years.
76
+
77
+ It is likely that other configurations will work, but they are not supported: if they stop working, we do not consider that a bug.
78
+ If you would benefit from support for something not listed here, file an issue and the product team will evaluate your request.
79
+ When making such a request please include if the configuration already works (and thus the request is just that it becomes officially supported), or if changes are required to get it working.
80
+
81
+ ### Supported Runtimes
82
+
83
+ - NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
84
+ - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
85
+
86
+ ### Supported Tools
87
+
88
+ - TypeScript 5.4:
89
+ - All [`strict`](https://www.typescriptlang.org/tsconfig) options are supported.
90
+ - [`strictNullChecks`](https://www.typescriptlang.org/tsconfig) is required.
91
+ - [Configuration options deprecated in 5.0](https://github.com/microsoft/TypeScript/issues/51909) are not supported.
92
+ - `exactOptionalPropertyTypes` is currently not fully supported.
93
+ If used, narrowing members of Fluid Framework types types using `in`, `Reflect.has`, `Object.hasOwn` or `Object.prototype.hasOwnProperty` should be avoided as they may incorrectly exclude `undefined` from the possible values in some cases.
94
+ - [webpack](https://webpack.js.org/) 5
95
+ - We are not intending to be prescriptive about what bundler to use.
96
+ Other bundlers which can handle ES Modules should work, but webpack is the only one we actively test.
97
+
98
+ ### Module Resolution
99
+
100
+ [`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) resolution should be used with TypeScript compilerOptions to follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
101
+ Node10 resolution is not supported as it does not support Fluid Framework's API structuring pattern that is used to distinguish stable APIs from those that are in development.
102
+
103
+ ### Module Formats
104
+
105
+ - ES Modules:
106
+ ES Modules are the preferred way to consume our client packages (including in NodeJs) and consuming our client packages from ES Modules is fully supported.
107
+ - CommonJs:
108
+ Consuming our client packages as CommonJs is supported only in NodeJS and only for the cases listed below.
109
+ This is done to accommodate some workflows without good ES Module support.
110
+ If you have a workflow you would like included in this list, file an issue.
111
+ Once this list of workflows motivating CommonJS support is empty, we may drop support for CommonJS one year after notice of the change is posted here.
112
+
113
+ - Testing with Jest (which lacks [stable ESM support](https://jestjs.io/docs/ecmascript-modules) due to [unstable APIs in NodeJs](https://github.com/nodejs/node/issues/37648))
114
+
115
+ ## Contribution Guidelines
116
+
117
+ There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
118
+
119
+ - Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
120
+ - [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
121
+ - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
122
+ - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
123
+
124
+ Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
125
+
126
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
127
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
128
+
129
+ This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
130
+ Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
131
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
132
+
133
+ ## Help
134
+
135
+ Not finding what you're looking for in this README? Check out [fluidframework.com](https://fluidframework.com/docs/).
136
+
137
+ Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
138
+
139
+ Thank you!
140
+
50
141
  ## Trademark
51
142
 
52
143
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-lint.entrypoint.json",
4
- "mainEntryPointFilePath": "<projectFolder>/dist/beta.d.ts"
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.current.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
5
5
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-base.esm.legacy.json"
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.legacy.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.esm.current.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-model.esm.json"
4
4
  }
@@ -0,0 +1,9 @@
1
+ ## Public API Report File for "@fluidframework/odsp-driver"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ // (No @packageDocumentation comment for this package)
8
+
9
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"ReadBufferUtils.d.ts","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,UAAU;IAOV,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAN/C,SAAS,CAAC,KAAK,SAAK;IAEpB,IAAW,MAAM,IAAI,UAAU,CAE9B;gBAE8B,IAAI,EAAE,UAAU;IAO/C,IAAW,GAAG,IAAI,OAAO,CAExB;IACD,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,SAAS,SAAI,GAAG,MAAM;IAc3B,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAKjC"}
1
+ {"version":3,"file":"ReadBufferUtils.d.ts","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,UAAU;IAOV,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAN/C,SAAS,CAAC,KAAK,SAAK;IAEpB,IAAW,MAAM,IAAI,UAAU,CAE9B;gBAE8B,IAAI,EAAE,UAAU;IAO/C,IAAW,GAAG,IAAI,OAAO,CAExB;IACD,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,SAAS,SAAI,GAAG,MAAM;IAe3B,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAKjC"}
@@ -43,6 +43,7 @@ class ReadBuffer {
43
43
  let length = lengthArg;
44
44
  while (length > 0) {
45
45
  (0, internal_1.assert)(!this.eof, 0x223 /* "unexpected end of buffer" */);
46
+ // TODO Why are we non null asserting here?
46
47
  res += this.data[this.index] * multiplier;
47
48
  this.index++;
48
49
  multiplier *= 256;
@@ -1 +1 @@
1
- {"version":3,"file":"ReadBufferUtils.js","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D;;;GAGG;AACH,MAAa,UAAU;IAGtB,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,YAA+B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QANrC,UAAK,GAAG,CAAC,CAAC;QAOnB,4DAA4D;QAC5D,+DAA+D;QAC/D,8DAA8D;QAC9D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IACxC,CAAC;IACD,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,KAAa,EAAE,GAAW;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC;IAEM,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAChB,CAAC;IAEM,IAAI,CAAC,SAAS,GAAG,CAAC;QACxB,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,IAAA,iBAAM,EAAC,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAC1D,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;YAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,UAAU,IAAI,GAAG,CAAC;YAClB,MAAM,EAAE,CAAC;QACV,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,IAAI,CAAC,MAAc;QACzB,IAAA,iBAAM,EAAC,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QACrB,IAAA,iBAAM,EAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClF,CAAC;CACD;AAnDD,gCAmDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Buffer class, used to sequentially read data.\n * Used by tree code to reconstruct a tree from binary representation.\n */\nexport class ReadBuffer {\n\tprotected index = 0;\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data;\n\t}\n\n\tconstructor(protected readonly data: Uint8Array) {\n\t\t// BlobShallowCopy will return to users parts of this array.\n\t\t// We need to ensure that nobody can change it, as it will have\n\t\t// catastrophic result and will be really hard to investigate.\n\t\tObject.freeze(data.buffer);\n\t}\n\n\tpublic get eof(): boolean {\n\t\treturn this.index === this.data.length;\n\t}\n\tpublic get pos(): number {\n\t\treturn this.index;\n\t}\n\tpublic get length(): number {\n\t\treturn this.data.length;\n\t}\n\n\tpublic slice(start: number, end: number): Uint8Array {\n\t\treturn this.data.slice(start, end);\n\t}\n\n\tpublic reset(): void {\n\t\tthis.index = 0;\n\t}\n\n\tpublic read(lengthArg = 1): number {\n\t\tlet res = 0;\n\t\tlet multiplier = 1;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tassert(!this.eof, 0x223 /* \"unexpected end of buffer\" */);\n\t\t\tres += this.data[this.index] * multiplier;\n\t\t\tthis.index++;\n\t\t\tmultiplier *= 256;\n\t\t\tlength--;\n\t\t}\n\t\treturn res;\n\t}\n\n\tpublic skip(length: number): void {\n\t\tassert(length >= 0, 0x224 /* \"Skip length should be positive\" */);\n\t\tthis.index += length;\n\t\tassert(this.index <= this.data.length, 0x3dc /* skipping past size of buffer */);\n\t}\n}\n"]}
1
+ {"version":3,"file":"ReadBufferUtils.js","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D;;;GAGG;AACH,MAAa,UAAU;IAGtB,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,YAA+B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QANrC,UAAK,GAAG,CAAC,CAAC;QAOnB,4DAA4D;QAC5D,+DAA+D;QAC/D,8DAA8D;QAC9D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAA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* Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * Buffer class, used to sequentially read data.\n * Used by tree code to reconstruct a tree from binary representation.\n */\nexport class ReadBuffer {\n\tprotected index = 0;\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data;\n\t}\n\n\tconstructor(protected readonly data: Uint8Array) {\n\t\t// BlobShallowCopy will return to users parts of this array.\n\t\t// We need to ensure that nobody can change it, as it will have\n\t\t// catastrophic result and will be really hard to investigate.\n\t\tObject.freeze(data.buffer);\n\t}\n\n\tpublic get eof(): boolean {\n\t\treturn this.index === this.data.length;\n\t}\n\tpublic get pos(): number {\n\t\treturn this.index;\n\t}\n\tpublic get length(): number {\n\t\treturn this.data.length;\n\t}\n\n\tpublic slice(start: number, end: number): Uint8Array {\n\t\treturn this.data.slice(start, end);\n\t}\n\n\tpublic reset(): void {\n\t\tthis.index = 0;\n\t}\n\n\tpublic read(lengthArg = 1): number {\n\t\tlet res = 0;\n\t\tlet multiplier = 1;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tassert(!this.eof, 0x223 /* \"unexpected end of buffer\" */);\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\tres += this.data[this.index]! * multiplier;\n\t\t\tthis.index++;\n\t\t\tmultiplier *= 256;\n\t\t\tlength--;\n\t\t}\n\t\treturn res;\n\t}\n\n\tpublic skip(length: number): void {\n\t\tassert(length >= 0, 0x224 /* \"Skip length should be positive\" */);\n\t\tthis.index += length;\n\t\tassert(this.index <= this.data.length, 0x3dc /* skipping past size of buffer */);\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WriteBufferUtils.d.ts","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKN,QAAQ,EAGR,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAwB;IACnD,SAAS,CAAC,KAAK,SAAK;IAEpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiB3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,IAAI;IAW3C,IAAI,IAAI,UAAU;CAQzB;AAwDD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAejD;AA+HD,cAAM,kBAAmB,SAAQ,QAAQ;;IAKjC,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAG3C;AAED,qBAAa,qBAAsB,SAAQ,kBAAkB;;IAKrD,SAAS,IAAI,UAAU;CAK9B"}
1
+ {"version":3,"file":"WriteBufferUtils.d.ts","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKN,QAAQ,EAGR,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAwB;IACnD,SAAS,CAAC,KAAK,SAAK;IAEpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAkB3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,IAAI;IAW3C,IAAI,IAAI,UAAU;CAQzB;AAwDD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAejD;AAgID,cAAM,kBAAmB,SAAQ,QAAQ;;IAKjC,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAG3C;AAED,qBAAa,qBAAsB,SAAQ,kBAAkB;;IAKrD,SAAS,IAAI,UAAU;CAK9B"}
@@ -25,6 +25,7 @@ class WriteBuffer {
25
25
  let index = 0;
26
26
  const oldData = this.data;
27
27
  while (index < length) {
28
+ // TODO Why are we non null asserting here?
28
29
  newData[index] = oldData[index];
29
30
  index++;
30
31
  }
@@ -217,6 +218,7 @@ function serializeNodeCore(buffer, nodeCore, dictionary) {
217
218
  }
218
219
  }
219
220
  else if (typeof child === "boolean") {
221
+ // TODO Why are we non null asserting here?
220
222
  buffer.write(boolToCodeMap[child ? 1 : 0]);
221
223
  }
222
224
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyD;AACzD,kEAA6D;AAE7D,uFAQ2C;AAE3C;;;GAGG;AACH,MAAa,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,UAAK,GAAG,CAAC,CAAC;IAsCrB,CAAC;IApCU,IAAI,CAAC,IAAY;QAC1B,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;YACpD,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;YAC1B,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;gBAChC,KAAK,EAAE,CAAC;YACT,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;I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AAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD;AAVD,sDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\tnewData[index] = oldData[index];\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode = MarkerCodesStart[child.type];\n\t\t\tconst endCode = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
1
+ {"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyD;AACzD,kEAA6D;AAE7D,uFAQ2C;AAE3C;;;GAGG;AACH,MAAa,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,UAAK,GAAG,CAAC,CAAC;IAuCrB,CAAC;IArCU,IAAI,CAAC,IAAY;QAC1B,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;YACpD,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;YAC1B,OAAO,KAAK,GAAG,MAAM,EAAE,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AM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,kBAAmB,SAAQ,0CAAQ;IACxC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS,CAAC,MAAmB;QACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,MAAa,qBAAsB,SAAQ,kBAAkB;IAC5D;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD;AAVD,sDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\t// TODO Why are we non null asserting here?\n\t\t\t\tnewData[index] = oldData[index]!;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode = MarkerCodesStart[child.type];\n\t\t\tconst endCode = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\t// TODO Why are we non null asserting here?\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]!);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,SAAS,EAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAgB/E,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAiND;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,mBAAmB,GACzB,0BAA0B,CA6C5B"}
1
+ {"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,SAAS,EAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAgB/E,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAoOD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,mBAAmB,GACzB,0BAA0B,CAkD5B"}
@@ -39,7 +39,9 @@ function readBlobSection(node) {
39
39
  */
40
40
  slowBlobStructureCount += 1;
41
41
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(blob);
42
+ // TODO why are we non null asserting here?
42
43
  (0, zipItDataRepresentationUtils_js_1.assertBlobCoreInstance)(records.data, "data should be of BlobCore type");
44
+ // TODO why are we non null asserting here?
43
45
  const id = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.id, "blob id should be string");
44
46
  blobContents.set(id, records.data.arrayBuffer);
45
47
  }
@@ -54,7 +56,9 @@ function readOpsSection(node) {
54
56
  (0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(node, "Deltas should be of type NodeCore");
55
57
  const ops = [];
56
58
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(node);
59
+ // TODO Why are we non null asserting here?
57
60
  (0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.firstSequenceNumber, "Seq number should be a number");
61
+ // TODO Why are we non null asserting here?
58
62
  (0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(records.deltas, "Deltas should be a Node");
59
63
  for (let i = 0; i < records.deltas.length; ++i) {
60
64
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -63,7 +67,9 @@ function readOpsSection(node) {
63
67
  // Due to a bug at service side, in an edge case service was serializing deltas even
64
68
  // when there are no ops. So just make the code resilient to that bug. Service has also
65
69
  // fixed that bug.
66
- (0, internal_1.assert)(ops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
70
+ (0, internal_1.assert)(
71
+ // Non null asserting here because of the length check
72
+ ops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
67
73
  return ops;
68
74
  }
69
75
  /**
@@ -72,6 +78,7 @@ function readOpsSection(node) {
72
78
  */
73
79
  function readTreeSection(node) {
74
80
  let slowTreeStructureCount = 0;
81
+ let treeStructureCountWithGroupId = 0;
75
82
  const trees = {};
76
83
  const snapshotTree = {
77
84
  blobs: {},
@@ -101,6 +108,7 @@ function readTreeSection(node) {
101
108
  const result = readTreeSection(treeNode.getNode(3));
102
109
  trees[treeNode.getString(1)] = result.snapshotTree;
103
110
  slowTreeStructureCount += result.slowTreeStructureCount;
111
+ treeStructureCountWithGroupId += result.treeStructureCountWithGroupId;
104
112
  continue;
105
113
  }
106
114
  // "name": <node name>
@@ -128,6 +136,7 @@ function readTreeSection(node) {
128
136
  const result = readTreeSection(treeNode.getNode(5));
129
137
  trees[treeNode.getString(1)] = result.snapshotTree;
130
138
  slowTreeStructureCount += result.slowTreeStructureCount;
139
+ treeStructureCountWithGroupId += result.treeStructureCountWithGroupId;
131
140
  (0, internal_1.assert)(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);
132
141
  snapshotTree.unreferenced = true;
133
142
  continue;
@@ -142,13 +151,14 @@ function readTreeSection(node) {
142
151
  /**
143
152
  * More generalized workflow
144
153
  */
145
- slowTreeStructureCount += 1;
154
+ slowTreeStructureCount++;
146
155
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(treeNode);
147
156
  if (records.unreferenced !== undefined) {
148
157
  (0, zipItDataRepresentationUtils_js_1.assertBoolInstance)(records.unreferenced, "Unreferenced flag should be bool");
149
158
  (0, internal_1.assert)(records.unreferenced, 0x281 /* "Unreferenced if present should be true" */);
150
159
  snapshotTree.unreferenced = true;
151
160
  }
161
+ // TODO Why are we non null asserting here?
152
162
  const path = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.name, "Path name should be string");
153
163
  if (records.value !== undefined) {
154
164
  snapshotTree.blobs[path] = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.value, "Blob value should be string");
@@ -160,15 +170,18 @@ function readTreeSection(node) {
160
170
  trees[path] = result.snapshotTree;
161
171
  if (records.groupId !== undefined) {
162
172
  const groupId = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.groupId, "groupId should be a string");
173
+ // Non null asserting since trees[path] is already created
163
174
  trees[path].groupId = groupId;
175
+ treeStructureCountWithGroupId++;
164
176
  }
165
177
  slowTreeStructureCount += result.slowTreeStructureCount;
178
+ treeStructureCountWithGroupId += result.treeStructureCountWithGroupId;
166
179
  }
167
180
  else {
168
181
  trees[path] = { blobs: {}, trees: {} };
169
182
  }
170
183
  }
171
- return { snapshotTree, slowTreeStructureCount };
184
+ return { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };
172
185
  }
173
186
  /**
174
187
  * Recreates snapshot tree out of tree representation.
@@ -177,15 +190,19 @@ function readTreeSection(node) {
177
190
  function readSnapshotSection(node) {
178
191
  (0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(node, "Snapshot should be of type NodeCore");
179
192
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(node);
193
+ // TODO Why are we non null asserting here?
180
194
  (0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(records.treeNodes, "TreeNodes should be of type NodeCore");
195
+ // TODO Why are we non null asserting here?
181
196
  (0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.sequenceNumber, "sequenceNumber should be of type number");
182
- const { snapshotTree, slowTreeStructureCount } = readTreeSection(records.treeNodes);
197
+ const { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } = readTreeSection(records.treeNodes);
198
+ // TODO Why are we non null asserting here?
183
199
  snapshotTree.id = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.id, "snapshotId should be string");
184
200
  const sequenceNumber = records.sequenceNumber.valueOf();
185
201
  return {
186
202
  sequenceNumber,
187
203
  snapshotTree,
188
204
  slowTreeStructureCount,
205
+ treeStructureCountWithGroupId,
189
206
  };
190
207
  }
191
208
  /**
@@ -199,7 +216,9 @@ function parseCompactSnapshotResponse(buffer, logger) {
199
216
  (0, internal_1.assert)(builder.length === 1, 0x219 /* "1 root should be there" */);
200
217
  const root = builder.getNode(0);
201
218
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(root);
219
+ // TODO Why are we non null asserting here?
202
220
  const mrv = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.mrv, "minReadVersion should be string");
221
+ // TODO Why are we non null asserting here?
203
222
  const cv = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.cv, "createVersion should be string");
204
223
  if (records.lsn !== undefined) {
205
224
  (0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.lsn, "lsn should be a number");
@@ -207,7 +226,10 @@ function parseCompactSnapshotResponse(buffer, logger) {
207
226
  (0, internal_1.assert)(Number.parseFloat(exports.snapshotMinReadVersion) >= Number.parseFloat(mrv), 0x20f /* "Driver min read version should >= to server minReadVersion" */);
208
227
  (0, internal_1.assert)(Number.parseFloat(cv) >= Number.parseFloat(exports.snapshotMinReadVersion), 0x210 /* "Snapshot should be created with minReadVersion or above" */);
209
228
  (0, internal_1.assert)(exports.currentReadVersion === cv, 0x2c2 /* "Create Version should be equal to currentReadVersion" */);
210
- const [snapshot, durationSnapshotTree] = (0, odspUtils_js_1.measure)(() => readSnapshotSection(records.snapshot));
229
+ const [snapshot, durationSnapshotTree] = (0, odspUtils_js_1.measure)(() =>
230
+ // TODO Why are we non null asserting here?
231
+ readSnapshotSection(records.snapshot));
232
+ // TODO Why are we non null asserting here?
211
233
  const [blobContents, durationBlobs] = (0, odspUtils_js_1.measure)(() => readBlobSection(records.blobs));
212
234
  return {
213
235
  ...snapshot,
@@ -221,6 +243,7 @@ function parseCompactSnapshotResponse(buffer, logger) {
221
243
  durationBlobs,
222
244
  slowTreeStructureCount: snapshot.slowTreeStructureCount,
223
245
  slowBlobStructureCount: blobContents.slowBlobStructureCount,
246
+ treeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,
224
247
  },
225
248
  };
226
249
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAQ7D,6DAAkD;AAClD,iDAAyC;AACzC,uFAU2C;AAE9B,QAAA,sBAAsB,GAAG,KAAK,CAAC;AAC/B,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAWxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IAIvC,IAAA,wDAAsB,EAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,MAAM,YAAY,GAA6B,IAAI,GAAG,EAAE,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,IAAA,wDAAsB,EAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEpD;;;;WAIG;QACH,IACC,IAAI,CAAC,MAAM,KAAK,CAAC;YACjB,IAAI,CAAC,cAAc,CAAC,CAA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EpF,OAAO;QACN,GAAG,QAAQ;QACX,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;QACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG;QACjC,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE;YACf,GAAG,cAAc;YACjB,oBAAoB;YACpB,aAAa;YACb,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,sBAAsB,EAAE,YAAY,CAAC,sBAAsB;SAC3D;KACD,CAAC;AACH,CAAC;AAhDD,oEAgDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\tassertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n\t\t\tconst id = getStringInstance(records.id, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\tassertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n\tassertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\tops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount += 1;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\tconst path = getStringInstance(records.name, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\ttrees[path].groupId = groupId;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\tassertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n\tassertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount } = readTreeSection(records.treeNodes);\n\tsnapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\tconst mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n\tconst cv = getStringInstance(records.cv, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\treadSnapshotSection(records.snapshot),\n\t);\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAQ7D,6DAAkD;AAClD,iDAAyC;AACzC,uFAU2C;AAE9B,QAAA,sBAAsB,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sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,sBAAsB,EAAE,YAAY,CAAC,sBAAsB;YAC3D,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;SACrE;KACD,CAAC;AACH,CAAC;AArDD,oEAqDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\t// TODO why are we non null asserting here?\n\t\t\tassertBlobCoreInstance(records.data!, \"data should be of BlobCore type\");\n\t\t\t// TODO why are we non null asserting here?\n\t\t\tconst id = getStringInstance(records.id!, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\t// TODO Why are we non null asserting here?\n\tassertNumberInstance(records.firstSequenceNumber!, \"Seq number should be a number\");\n\t// TODO Why are we non null asserting here?\n\tassertNodeCoreInstance(records.deltas!, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\t// Non null asserting here because of the length check\n\t\tops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0]!.sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\t// TODO Why are we non null asserting here?\n\t\tconst path = getStringInstance(records.name!, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\t// Non null asserting since trees[path] is already created\n\t\t\t\ttrees[path]!.groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\t// TODO Why are we non null asserting here?\n\tassertNodeCoreInstance(records.treeNodes!, \"TreeNodes should be of type NodeCore\");\n\t// TODO Why are we non null asserting here?\n\tassertNumberInstance(records.sequenceNumber!, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\t// TODO Why are we non null asserting here?\n\tsnapshotTree.id = getStringInstance(records.id!, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\t// TODO Why are we non null asserting here?\n\tconst mrv = getStringInstance(records.mrv!, \"minReadVersion should be string\");\n\t// TODO Why are we non null asserting here?\n\tconst cv = getStringInstance(records.cv!, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\t// TODO Why are we non null asserting here?\n\t\treadSnapshotSection(records.snapshot!),\n\t);\n\t// TODO Why are we non null asserting here?\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs!));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,SAAS,EAIT,MAAM,6CAA6C,CAAC;AAsIrD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,SAAS,GAAG,UAAU,CAgChF"}
1
+ {"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,SAAS,EAIT,MAAM,6CAA6C,CAAC;AAuIrD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,SAAS,GAAG,UAAU,CAiChF"}
@@ -104,6 +104,7 @@ function writeSnapshotSection(rootNode, snapshotTree, snapshotSequenceNumber) {
104
104
  function writeOpsSection(rootNode, ops) {
105
105
  let firstSequenceNumber;
106
106
  if (ops.length > 0) {
107
+ // Non null asserting here because of the length check above
107
108
  firstSequenceNumber = ops[0].sequenceNumber;
108
109
  }
109
110
  if (firstSequenceNumber !== undefined) {
@@ -131,7 +132,8 @@ function convertToCompactSnapshot(snapshotContents) {
131
132
  if (latestSequenceNumber === undefined) {
132
133
  latestSequenceNumber =
133
134
  snapshotContents.ops.length > 0
134
- ? snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber
135
+ ? // Non null asserting here because of the length check above
136
+ snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber
135
137
  : snapshotContents.sequenceNumber;
136
138
  }
137
139
  writeSnapshotProps(rootNode, latestSequenceNumber);