@fluid-experimental/tree 0.59.2001 → 0.59.3000

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 (258) hide show
  1. package/.eslintrc.js +2 -0
  2. package/.vscode/SharedTree.code-workspace +15 -0
  3. package/.vscode/settings.json +6 -0
  4. package/dist/ChangeCompression.js +9 -9
  5. package/dist/ChangeCompression.js.map +1 -1
  6. package/dist/ChangeTypes.d.ts +1 -6
  7. package/dist/ChangeTypes.d.ts.map +1 -1
  8. package/dist/ChangeTypes.js +5 -5
  9. package/dist/ChangeTypes.js.map +1 -1
  10. package/dist/Checkout.js +14 -14
  11. package/dist/Checkout.js.map +1 -1
  12. package/dist/Common.d.ts +21 -3
  13. package/dist/Common.d.ts.map +1 -1
  14. package/dist/Common.js +29 -4
  15. package/dist/Common.js.map +1 -1
  16. package/dist/EditLog.js +26 -25
  17. package/dist/EditLog.js.map +1 -1
  18. package/dist/EditUtilities.js +17 -17
  19. package/dist/EditUtilities.js.map +1 -1
  20. package/dist/Forest.js +31 -31
  21. package/dist/Forest.js.map +1 -1
  22. package/dist/HistoryEditFactory.js +9 -9
  23. package/dist/HistoryEditFactory.js.map +1 -1
  24. package/dist/IdConversion.js +9 -9
  25. package/dist/IdConversion.js.map +1 -1
  26. package/dist/Identifiers.d.ts +4 -0
  27. package/dist/Identifiers.d.ts.map +1 -1
  28. package/dist/Identifiers.js.map +1 -1
  29. package/dist/LogViewer.d.ts +1 -5
  30. package/dist/LogViewer.d.ts.map +1 -1
  31. package/dist/LogViewer.js +11 -19
  32. package/dist/LogViewer.js.map +1 -1
  33. package/dist/MergeHealth.js +2 -2
  34. package/dist/MergeHealth.js.map +1 -1
  35. package/dist/NodeIdUtilities.js +2 -2
  36. package/dist/NodeIdUtilities.js.map +1 -1
  37. package/dist/PayloadUtilities.js +1 -1
  38. package/dist/PayloadUtilities.js.map +1 -1
  39. package/dist/RevisionValueCache.d.ts +13 -10
  40. package/dist/RevisionValueCache.d.ts.map +1 -1
  41. package/dist/RevisionValueCache.js +14 -11
  42. package/dist/RevisionValueCache.js.map +1 -1
  43. package/dist/RevisionView.js +4 -4
  44. package/dist/RevisionView.js.map +1 -1
  45. package/dist/SerializationUtilities.js +4 -4
  46. package/dist/SerializationUtilities.js.map +1 -1
  47. package/dist/SharedTree.d.ts +93 -31
  48. package/dist/SharedTree.d.ts.map +1 -1
  49. package/dist/SharedTree.js +160 -131
  50. package/dist/SharedTree.js.map +1 -1
  51. package/dist/SharedTreeEncoder.d.ts +3 -3
  52. package/dist/SharedTreeEncoder.d.ts.map +1 -1
  53. package/dist/SharedTreeEncoder.js +36 -36
  54. package/dist/SharedTreeEncoder.js.map +1 -1
  55. package/dist/StringInterner.js +1 -1
  56. package/dist/StringInterner.js.map +1 -1
  57. package/dist/Summary.js +1 -1
  58. package/dist/Summary.js.map +1 -1
  59. package/dist/SummaryBackCompatibility.js +8 -8
  60. package/dist/SummaryBackCompatibility.js.map +1 -1
  61. package/dist/Transaction.js +1 -1
  62. package/dist/Transaction.js.map +1 -1
  63. package/dist/TransactionInternal.js +17 -17
  64. package/dist/TransactionInternal.js.map +1 -1
  65. package/dist/TreeCompressor.d.ts.map +1 -1
  66. package/dist/TreeCompressor.js +6 -8
  67. package/dist/TreeCompressor.js.map +1 -1
  68. package/dist/TreeNodeHandle.js +4 -4
  69. package/dist/TreeNodeHandle.js.map +1 -1
  70. package/dist/TreeView.js +7 -7
  71. package/dist/TreeView.js.map +1 -1
  72. package/dist/TreeViewUtilities.js +2 -2
  73. package/dist/TreeViewUtilities.js.map +1 -1
  74. package/dist/UndoRedoHandler.js +1 -1
  75. package/dist/UndoRedoHandler.js.map +1 -1
  76. package/dist/UuidUtilities.d.ts +30 -0
  77. package/dist/UuidUtilities.d.ts.map +1 -0
  78. package/dist/UuidUtilities.js +106 -0
  79. package/dist/UuidUtilities.js.map +1 -0
  80. package/dist/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  81. package/dist/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  82. package/dist/id-compressor/AppendOnlySortedMap.js +167 -90
  83. package/dist/id-compressor/AppendOnlySortedMap.js.map +1 -1
  84. package/dist/id-compressor/IdCompressor.d.ts +43 -42
  85. package/dist/id-compressor/IdCompressor.d.ts.map +1 -1
  86. package/dist/id-compressor/IdCompressor.js +179 -177
  87. package/dist/id-compressor/IdCompressor.js.map +1 -1
  88. package/dist/id-compressor/IdRange.js +1 -1
  89. package/dist/id-compressor/IdRange.js.map +1 -1
  90. package/dist/id-compressor/NumericUuid.d.ts +6 -14
  91. package/dist/id-compressor/NumericUuid.d.ts.map +1 -1
  92. package/dist/id-compressor/NumericUuid.js +15 -76
  93. package/dist/id-compressor/NumericUuid.js.map +1 -1
  94. package/dist/id-compressor/SessionIdNormalizer.d.ts +122 -0
  95. package/dist/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  96. package/dist/id-compressor/SessionIdNormalizer.js +418 -0
  97. package/dist/id-compressor/SessionIdNormalizer.js.map +1 -0
  98. package/dist/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  99. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  100. package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -1
  101. package/dist/index.d.ts +2 -2
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js.map +1 -1
  104. package/dist/persisted-types/0.1.1.d.ts +1 -6
  105. package/dist/persisted-types/0.1.1.d.ts.map +1 -1
  106. package/dist/persisted-types/0.1.1.js +3 -3
  107. package/dist/persisted-types/0.1.1.js.map +1 -1
  108. package/lib/ChangeTypes.d.ts +1 -6
  109. package/lib/ChangeTypes.d.ts.map +1 -1
  110. package/lib/Checkout.js.map +1 -1
  111. package/lib/Common.d.ts +21 -3
  112. package/lib/Common.d.ts.map +1 -1
  113. package/lib/Common.js +25 -3
  114. package/lib/Common.js.map +1 -1
  115. package/lib/EditLog.js +2 -1
  116. package/lib/EditLog.js.map +1 -1
  117. package/lib/EditUtilities.js.map +1 -1
  118. package/lib/Forest.js.map +1 -1
  119. package/lib/HistoryEditFactory.js.map +1 -1
  120. package/lib/Identifiers.d.ts +4 -0
  121. package/lib/Identifiers.d.ts.map +1 -1
  122. package/lib/Identifiers.js.map +1 -1
  123. package/lib/LogViewer.d.ts +1 -5
  124. package/lib/LogViewer.d.ts.map +1 -1
  125. package/lib/LogViewer.js +5 -13
  126. package/lib/LogViewer.js.map +1 -1
  127. package/lib/MergeHealth.js.map +1 -1
  128. package/lib/NodeIdUtilities.js.map +1 -1
  129. package/lib/RevisionValueCache.d.ts +13 -10
  130. package/lib/RevisionValueCache.d.ts.map +1 -1
  131. package/lib/RevisionValueCache.js +10 -7
  132. package/lib/RevisionValueCache.js.map +1 -1
  133. package/lib/RevisionView.js.map +1 -1
  134. package/lib/SharedTree.d.ts +93 -31
  135. package/lib/SharedTree.d.ts.map +1 -1
  136. package/lib/SharedTree.js +107 -78
  137. package/lib/SharedTree.js.map +1 -1
  138. package/lib/SharedTreeEncoder.d.ts +3 -3
  139. package/lib/SharedTreeEncoder.d.ts.map +1 -1
  140. package/lib/SharedTreeEncoder.js +4 -4
  141. package/lib/SharedTreeEncoder.js.map +1 -1
  142. package/lib/StringInterner.js.map +1 -1
  143. package/lib/Summary.js.map +1 -1
  144. package/lib/TreeCompressor.d.ts.map +1 -1
  145. package/lib/TreeCompressor.js +1 -3
  146. package/lib/TreeCompressor.js.map +1 -1
  147. package/lib/TreeNodeHandle.js.map +1 -1
  148. package/lib/TreeView.js.map +1 -1
  149. package/lib/TreeViewUtilities.js.map +1 -1
  150. package/lib/UuidUtilities.d.ts +30 -0
  151. package/lib/UuidUtilities.d.ts.map +1 -0
  152. package/lib/UuidUtilities.js +98 -0
  153. package/lib/UuidUtilities.js.map +1 -0
  154. package/lib/id-compressor/AppendOnlySortedMap.d.ts +52 -28
  155. package/lib/id-compressor/AppendOnlySortedMap.d.ts.map +1 -1
  156. package/lib/id-compressor/AppendOnlySortedMap.js +165 -88
  157. package/lib/id-compressor/AppendOnlySortedMap.js.map +1 -1
  158. package/lib/id-compressor/IdCompressor.d.ts +43 -42
  159. package/lib/id-compressor/IdCompressor.d.ts.map +1 -1
  160. package/lib/id-compressor/IdCompressor.js +97 -95
  161. package/lib/id-compressor/IdCompressor.js.map +1 -1
  162. package/lib/id-compressor/NumericUuid.d.ts +6 -14
  163. package/lib/id-compressor/NumericUuid.d.ts.map +1 -1
  164. package/lib/id-compressor/NumericUuid.js +11 -70
  165. package/lib/id-compressor/NumericUuid.js.map +1 -1
  166. package/lib/id-compressor/SessionIdNormalizer.d.ts +122 -0
  167. package/lib/id-compressor/SessionIdNormalizer.d.ts.map +1 -0
  168. package/lib/id-compressor/SessionIdNormalizer.js +414 -0
  169. package/lib/id-compressor/SessionIdNormalizer.js.map +1 -0
  170. package/lib/id-compressor/persisted-types/0.0.1.d.ts +6 -13
  171. package/lib/id-compressor/persisted-types/0.0.1.d.ts.map +1 -1
  172. package/lib/id-compressor/persisted-types/0.0.1.js.map +1 -1
  173. package/lib/index.d.ts +2 -2
  174. package/lib/index.d.ts.map +1 -1
  175. package/lib/index.js.map +1 -1
  176. package/lib/persisted-types/0.1.1.d.ts +1 -6
  177. package/lib/persisted-types/0.1.1.d.ts.map +1 -1
  178. package/lib/persisted-types/0.1.1.js.map +1 -1
  179. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts +6 -0
  180. package/lib/test/AppendOnlySortedMap.perf.tests.d.ts.map +1 -0
  181. package/lib/test/AppendOnlySortedMap.perf.tests.js +49 -0
  182. package/lib/test/AppendOnlySortedMap.perf.tests.js.map +1 -0
  183. package/lib/test/AppendOnlySortedMap.tests.js +56 -14
  184. package/lib/test/AppendOnlySortedMap.tests.js.map +1 -1
  185. package/lib/test/Checkout.tests.js +2 -2
  186. package/lib/test/Checkout.tests.js.map +1 -1
  187. package/lib/test/Forest.tests.js.map +1 -1
  188. package/lib/test/IdCompressor.perf.tests.js +8 -2
  189. package/lib/test/IdCompressor.perf.tests.js.map +1 -1
  190. package/lib/test/IdCompressor.tests.js +75 -24
  191. package/lib/test/IdCompressor.tests.js.map +1 -1
  192. package/lib/test/LogViewer.tests.js +3 -5
  193. package/lib/test/LogViewer.tests.js.map +1 -1
  194. package/lib/test/NumericUuid.perf.tests.js +4 -4
  195. package/lib/test/NumericUuid.perf.tests.js.map +1 -1
  196. package/lib/test/NumericUuid.tests.js +5 -4
  197. package/lib/test/NumericUuid.tests.js.map +1 -1
  198. package/lib/test/RevisionValueCache.tests.js.map +1 -1
  199. package/lib/test/RevisionView.tests.js.map +1 -1
  200. package/lib/test/SessionIdNormalizer.tests.d.ts +6 -0
  201. package/lib/test/SessionIdNormalizer.tests.d.ts.map +1 -0
  202. package/lib/test/SessionIdNormalizer.tests.js +299 -0
  203. package/lib/test/SessionIdNormalizer.tests.js.map +1 -0
  204. package/lib/test/Summary.tests.js +1 -1
  205. package/lib/test/Summary.tests.js.map +1 -1
  206. package/lib/test/TreeCompression.tests.js +1 -1
  207. package/lib/test/TreeCompression.tests.js.map +1 -1
  208. package/lib/test/Virtualization.tests.js +1 -1
  209. package/lib/test/Virtualization.tests.js.map +1 -1
  210. package/lib/test/fuzz/Generators.d.ts +3 -14
  211. package/lib/test/fuzz/Generators.d.ts.map +1 -1
  212. package/lib/test/fuzz/Generators.js +60 -151
  213. package/lib/test/fuzz/Generators.js.map +1 -1
  214. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts +10 -7
  215. package/lib/test/fuzz/SharedTreeFuzzTests.d.ts.map +1 -1
  216. package/lib/test/fuzz/SharedTreeFuzzTests.js +94 -104
  217. package/lib/test/fuzz/SharedTreeFuzzTests.js.map +1 -1
  218. package/lib/test/fuzz/Types.d.ts +2 -9
  219. package/lib/test/fuzz/Types.d.ts.map +1 -1
  220. package/lib/test/fuzz/Types.js +1 -1
  221. package/lib/test/fuzz/Types.js.map +1 -1
  222. package/lib/test/utilities/IdCompressorTestUtilities.d.ts +57 -11
  223. package/lib/test/utilities/IdCompressorTestUtilities.d.ts.map +1 -1
  224. package/lib/test/utilities/IdCompressorTestUtilities.js +112 -98
  225. package/lib/test/utilities/IdCompressorTestUtilities.js.map +1 -1
  226. package/lib/test/utilities/PendingLocalStateTests.d.ts.map +1 -1
  227. package/lib/test/utilities/PendingLocalStateTests.js +2 -1
  228. package/lib/test/utilities/PendingLocalStateTests.js.map +1 -1
  229. package/lib/test/utilities/SharedTreeTests.d.ts.map +1 -1
  230. package/lib/test/utilities/SharedTreeTests.js +30 -1
  231. package/lib/test/utilities/SharedTreeTests.js.map +1 -1
  232. package/lib/test/utilities/SharedTreeVersioningTests.d.ts.map +1 -1
  233. package/lib/test/utilities/SharedTreeVersioningTests.js +20 -0
  234. package/lib/test/utilities/SharedTreeVersioningTests.js.map +1 -1
  235. package/lib/test/utilities/SummaryLoadPerfTests.d.ts.map +1 -1
  236. package/lib/test/utilities/SummaryLoadPerfTests.js +6 -3
  237. package/lib/test/utilities/SummaryLoadPerfTests.js.map +1 -1
  238. package/lib/test/utilities/TestNode.js.map +1 -1
  239. package/lib/test/utilities/TestUtilities.d.ts +9 -1
  240. package/lib/test/utilities/TestUtilities.d.ts.map +1 -1
  241. package/lib/test/utilities/TestUtilities.js +27 -13
  242. package/lib/test/utilities/TestUtilities.js.map +1 -1
  243. package/package.json +19 -17
  244. package/src/Common.ts +42 -4
  245. package/src/EditLog.ts +1 -1
  246. package/src/Identifiers.ts +5 -0
  247. package/src/LogViewer.ts +4 -20
  248. package/src/RevisionValueCache.ts +11 -8
  249. package/src/SharedTree.ts +222 -75
  250. package/src/SharedTreeEncoder.ts +17 -11
  251. package/src/TreeCompressor.ts +2 -4
  252. package/src/UuidUtilities.ts +123 -0
  253. package/src/id-compressor/AppendOnlySortedMap.ts +183 -94
  254. package/src/id-compressor/IdCompressor.ts +144 -132
  255. package/src/id-compressor/NumericUuid.ts +11 -80
  256. package/src/id-compressor/SessionIdNormalizer.ts +497 -0
  257. package/src/id-compressor/persisted-types/0.0.1.ts +12 -15
  258. package/src/index.ts +5 -0
@@ -0,0 +1,414 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /* eslint-disable @typescript-eslint/restrict-plus-operands */
6
+ import { assert, compareFiniteNumbers, compareFiniteNumbersReversed, fail } from '../Common';
7
+ import { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap';
8
+ /**
9
+ * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.
10
+ * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such
11
+ * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.
12
+ * Below is an example to illustrate how various mappings can arise:
13
+ *
14
+ * +- Creation Index
15
+ * / +- Locals
16
+ * / / +- Finals
17
+ * / / /
18
+ * ---+-----+----
19
+ * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.
20
+ * 1 | -2 | 1 -|
21
+ * 2 | | 2 -|
22
+ * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.
23
+ * 4 | | 4 -|
24
+ * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.
25
+ * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.
26
+ * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.
27
+ * 8 | | 13
28
+ * 9 | | 14
29
+ * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.
30
+ *
31
+ * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.
32
+ * These kinds of "gaps" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,
33
+ * which depends on receiving an ack/sequence number from the server. Given this context, "session space" can be thought of as:
34
+ *
35
+ * for each index in the range of IDs created by a session:
36
+ * the local form if it exists, otherwise the final form
37
+ *
38
+ * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and
39
+ * final space) is uninterrupted by "gaps" and can be compactly represented by a (first, last) pair and is easily binary searched for
40
+ * normalization between local and final space.
41
+ */
42
+ export class SessionIdNormalizer {
43
+ constructor(expensiveAsserts = false) {
44
+ this.expensiveAsserts = expensiveAsserts;
45
+ this.nextLocalId = -1;
46
+ this.idRanges = new AppendOnlyDoublySortedMap(compareFiniteNumbersReversed, ([_, finalRanges]) => {
47
+ if (finalRanges !== undefined) {
48
+ const first = getFirstRange(finalRanges);
49
+ return extractFirstFinalFromRange(first);
50
+ }
51
+ return Number.POSITIVE_INFINITY;
52
+ }, compareFiniteNumbers);
53
+ }
54
+ /**
55
+ * Converts the final ID to its session-space representation.
56
+ * This will be the corresponding local if a local form exists, and `finalId` otherwise.
57
+ */
58
+ getSessionSpaceId(finalId) {
59
+ const localRange = this.idRanges.getPairOrNextLowerByValue(finalId);
60
+ if (localRange !== undefined) {
61
+ const [firstLocal, [lastLocal, finalRanges]] = localRange;
62
+ const finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);
63
+ if (finalRange !== undefined) {
64
+ const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
65
+ if (finalId <= lastFinal) {
66
+ const localRangeDelta = alignedLocal - lastLocal;
67
+ const finalDelta = finalId - firstFinal;
68
+ if (finalDelta <= localRangeDelta) {
69
+ return (alignedLocal - finalDelta);
70
+ }
71
+ // `finalId` was an eagerly generated final ID
72
+ return finalId;
73
+ }
74
+ }
75
+ }
76
+ return undefined;
77
+ }
78
+ /**
79
+ * Converts the local ID to its corresponding final ID, if one exists.
80
+ */
81
+ getFinalId(localId) {
82
+ var _a;
83
+ const localRange = (_a = this.idRanges.getPairOrNextLower(localId)) !== null && _a !== void 0 ? _a : fail('Local ID was never recorded with this normalizer.');
84
+ const [firstLocal, [lastLocal, finalRanges]] = localRange;
85
+ if (localId < lastLocal) {
86
+ fail('Local ID was never recorded with this normalizer.');
87
+ }
88
+ const finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);
89
+ if (finalRange !== undefined) {
90
+ const [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;
91
+ const rangeDelta = lastFinal - firstFinal;
92
+ const localDelta = alignedLocal - localId;
93
+ if (localDelta <= rangeDelta) {
94
+ // Local is within a range segment that has a corresponding final
95
+ return [(firstFinal + localDelta), rangeObject];
96
+ }
97
+ }
98
+ return undefined;
99
+ }
100
+ /**
101
+ * Returns the index of the supplied session-space ID in the total range of IDs created by the session, if the ID was created
102
+ * by the session for this `SessionIdNormalizer`.
103
+ */
104
+ getCreationIndex(finalId) {
105
+ const localRange = this.idRanges.getPairOrNextLowerByValue(finalId);
106
+ if (localRange !== undefined) {
107
+ const [firstLocal, [_, finalRanges]] = localRange;
108
+ const finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);
109
+ if (finalRange !== undefined) {
110
+ const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
111
+ if (finalId <= lastFinal) {
112
+ const finalDelta = finalId - firstFinal;
113
+ return -alignedLocal - 1 + finalDelta;
114
+ }
115
+ }
116
+ }
117
+ return undefined;
118
+ }
119
+ /**
120
+ * Returns the session-space ID at the supplied creation index, if one exists.
121
+ */
122
+ getIdByCreationIndex(index) {
123
+ var _a;
124
+ const localByIndex = -(index + 1);
125
+ const localRange = this.idRanges.getPairOrNextLower(localByIndex);
126
+ if (localRange === undefined) {
127
+ return undefined;
128
+ }
129
+ const [firstLocal, [lastLocal, finalRanges]] = localRange;
130
+ if (localByIndex >= lastLocal) {
131
+ return localByIndex;
132
+ }
133
+ const finalRange = (_a = getPairOrNextLower(firstLocal, finalRanges, localByIndex)) !== null && _a !== void 0 ? _a : fail('Final ranges not aligned with owning local range.');
134
+ const [alignedLocal, [firstFinal, lastFinal]] = finalRange;
135
+ const localDelta = alignedLocal - localByIndex;
136
+ const finalId = firstFinal + localDelta;
137
+ if (finalId <= lastFinal) {
138
+ // `finalId` was an eagerly generated final ID
139
+ return finalId;
140
+ }
141
+ return undefined;
142
+ }
143
+ static makeFinalRangesMap() {
144
+ return new AppendOnlyDoublySortedMap(compareFiniteNumbersReversed, extractFirstFinalFromRange, compareFiniteNumbers);
145
+ }
146
+ /**
147
+ * Returns the last final ID known to this normalizer.
148
+ */
149
+ getLastFinalId() {
150
+ const lastIndex = this.idRanges.size - 1;
151
+ const secondToLast = Math.max(0, lastIndex - 1);
152
+ for (let i = lastIndex; i >= secondToLast; i--) {
153
+ const localRange = this.idRanges.getAtIndex(i);
154
+ if (localRange !== undefined) {
155
+ const finalRanges = localRange[1][1];
156
+ if (finalRanges !== undefined) {
157
+ return getLastRange(finalRanges)[1];
158
+ }
159
+ }
160
+ }
161
+ return undefined;
162
+ }
163
+ /**
164
+ * Registers and returns the next ID in local space with this normalizer. An example:
165
+ *
166
+ * Locals: [-1, -2, X, X]
167
+ * Finals: [ 0, 1, 2, 3]
168
+ * In this scenario, a call to this method would generate and return -5.
169
+ */
170
+ addLocalId() {
171
+ const localId = this.nextLocalId--;
172
+ const lastLocalRange = this.idRanges.last();
173
+ if (lastLocalRange !== undefined) {
174
+ const lastLocal = lastLocalRange[1][0];
175
+ if (localId === lastLocal - 1) {
176
+ // New local simply expands the last local range tracked
177
+ lastLocalRange[1][0] = localId;
178
+ return localId;
179
+ }
180
+ }
181
+ if (this.expensiveAsserts) {
182
+ if (lastLocalRange === undefined) {
183
+ assert(localId === -1, 'Local ID space must start at -1.');
184
+ }
185
+ else {
186
+ const [firstLocal, [_, finalRanges]] = lastLocalRange;
187
+ let finalDelta = 0;
188
+ for (const [_, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {
189
+ finalDelta += lastFinal - firstFinal + 1;
190
+ }
191
+ assert(localId === firstLocal - finalDelta, 'Local ID space must be contiguous.');
192
+ }
193
+ }
194
+ this.idRanges.append(localId, [localId, undefined]);
195
+ return localId;
196
+ }
197
+ /**
198
+ * Registers a final ID with this normalizer.
199
+ * If there are any local IDs at the tip of session-space that do not have a corresponding final, it will be registered (aligned) with
200
+ * the first of those. Otherwise, will be registered as the next ID in session space in creation order. An example:
201
+ *
202
+ * Locals: [-1, -2, X, -4]
203
+ * Finals: [ 0, 1, 2, X]
204
+ * Calling `addFinalIds` with first === last === 5 results in the following:
205
+ * Locals: [-1, -2, X, -4]
206
+ * Finals: [ 0, 1, 2, 5]
207
+ * Calling `addFinalIds` with first === last === 6 results in the following:
208
+ * Locals: [-1, -2, X, -4, X]
209
+ * Finals: [ 0, 1, 2, 5, 6]
210
+ *
211
+ * Non-contiguous final IDs (i.e. the first final after a "gap" in final space) must always correspond to a local ID. For example,
212
+ * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a
213
+ * non-contiguous final ID without a local form:
214
+ * Locals: [-1, -2, X, -4, X]
215
+ * Finals: [ 0, 1, 2, 5, 9]
216
+ * ^final ID 9 is not contiguous and does not have a corresponding local ID
217
+ */
218
+ addFinalIds(firstFinal, lastFinal, rangeObject) {
219
+ var _a, _b;
220
+ assert(lastFinal >= firstFinal, 'Malformed normalization range.');
221
+ const [firstLocal, finalRangesObj] = (_a = this.idRanges.last()) !== null && _a !== void 0 ? _a : fail('Final IDs must be added to an existing local range.');
222
+ const [lastLocal, finalRanges] = finalRangesObj;
223
+ let nextLocal;
224
+ if (finalRanges === undefined) {
225
+ finalRangesObj[1] = [firstFinal, lastFinal, rangeObject];
226
+ nextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1);
227
+ }
228
+ else {
229
+ const isSingle = isSingleRange(finalRanges);
230
+ let lastFinalRange;
231
+ let firstAlignedLocal;
232
+ if (isSingle) {
233
+ firstAlignedLocal = firstLocal;
234
+ lastFinalRange = finalRanges;
235
+ }
236
+ else {
237
+ [firstAlignedLocal, lastFinalRange] = (_b = finalRanges.last()) !== null && _b !== void 0 ? _b : fail('Map should be non-empty.');
238
+ }
239
+ const [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;
240
+ const lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);
241
+ nextLocal = Math.min(this.nextLocalId, lastAlignedLocal - (lastFinal - firstFinal) - 2);
242
+ if (firstFinal === lastAlignedFinal + 1) {
243
+ lastFinalRange[1] = lastFinal;
244
+ }
245
+ else {
246
+ const alignedLocal = (lastAlignedLocal - 1);
247
+ let rangeMap;
248
+ if (isSingle) {
249
+ // Convert the single range to a range collection
250
+ rangeMap = SessionIdNormalizer.makeFinalRangesMap();
251
+ rangeMap.append(firstAlignedLocal, lastFinalRange);
252
+ finalRangesObj[1] = rangeMap;
253
+ }
254
+ else {
255
+ rangeMap = finalRanges;
256
+ }
257
+ rangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);
258
+ assert(alignedLocal >= lastLocal, 'Gaps in final space must align to a local.');
259
+ }
260
+ if (this.expensiveAsserts) {
261
+ this.idRanges.assertValid();
262
+ }
263
+ }
264
+ this.nextLocalId = nextLocal;
265
+ }
266
+ /**
267
+ * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.
268
+ */
269
+ *[Symbol.iterator]() {
270
+ var _a;
271
+ for (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {
272
+ for (let i = firstLocal; i >= lastLocal; i--) {
273
+ yield i;
274
+ }
275
+ if (finalRanges !== undefined) {
276
+ // Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)
277
+ let lastFinalRange;
278
+ let alignedLocal;
279
+ if (isSingleRange(finalRanges)) {
280
+ alignedLocal = firstLocal;
281
+ lastFinalRange = finalRanges;
282
+ }
283
+ else {
284
+ [alignedLocal, lastFinalRange] = (_a = finalRanges.last()) !== null && _a !== void 0 ? _a : fail('Map should be non-empty.');
285
+ }
286
+ const [firstFinal, lastFinal] = lastFinalRange;
287
+ const localRangeDelta = alignedLocal - lastLocal;
288
+ for (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {
289
+ yield i;
290
+ }
291
+ }
292
+ }
293
+ }
294
+ serialize() {
295
+ const serialized = { localRanges: [] };
296
+ const localRanges = serialized.localRanges;
297
+ for (const [firstLocal, finalRanges] of this.idRanges.entries()) {
298
+ const [lastLocal, finalRangesTable] = finalRanges;
299
+ if (finalRangesTable !== undefined) {
300
+ const serializedFinalRanges = [];
301
+ for (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {
302
+ serializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);
303
+ }
304
+ localRanges.push([firstLocal, lastLocal, serializedFinalRanges]);
305
+ }
306
+ else {
307
+ localRanges.push([firstLocal, lastLocal]);
308
+ }
309
+ }
310
+ return serialized;
311
+ }
312
+ static deserialize(serialized, getRangeObject) {
313
+ const normalizer = new SessionIdNormalizer();
314
+ const { idRanges } = normalizer;
315
+ for (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {
316
+ let finalRanges;
317
+ if (serializedFinalRanges !== undefined) {
318
+ assert(serializedFinalRanges.length !== 0, 'Empty range should not be reified.');
319
+ if (serializedFinalRanges.length === 1) {
320
+ const [_, firstFinal, lastFinal] = serializedFinalRanges[0];
321
+ finalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];
322
+ }
323
+ else {
324
+ finalRanges = SessionIdNormalizer.makeFinalRangesMap();
325
+ for (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {
326
+ finalRanges.append(alignedLocal, [firstFinal, lastFinal, getRangeObject(firstFinal)]);
327
+ }
328
+ }
329
+ }
330
+ idRanges.append(firstLocal, [lastLocal, finalRanges]);
331
+ }
332
+ return normalizer;
333
+ }
334
+ equals(other, compareRangeObjects = (a, b) => a === b) {
335
+ return this.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {
336
+ const [lastLocalA, finalRangesA] = localRangeA;
337
+ const [lastLocalB, finalRangesB] = localRangeB;
338
+ if (finalRangesA === undefined || finalRangesB === undefined) {
339
+ return finalRangesA === finalRangesB;
340
+ }
341
+ const rangeEquals = (finalRangeA, finalRangeB) => {
342
+ const [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;
343
+ const [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;
344
+ return (firstFinalA === firstFinalB &&
345
+ lastFinalA === lastFinalB &&
346
+ compareRangeObjects(rangeObjectA, rangeObjectB));
347
+ };
348
+ if (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {
349
+ if (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {
350
+ return false;
351
+ }
352
+ return rangeEquals(finalRangesA, finalRangesB);
353
+ }
354
+ return lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);
355
+ });
356
+ }
357
+ }
358
+ function isSingleRange(ranges) {
359
+ return Array.isArray(ranges);
360
+ }
361
+ function getLastRange(finalRanges) {
362
+ var _a;
363
+ if (isSingleRange(finalRanges)) {
364
+ return finalRanges;
365
+ }
366
+ return ((_a = finalRanges.last()) !== null && _a !== void 0 ? _a : fail('Map must be non-empty'))[1];
367
+ }
368
+ function getFirstRange(finalRanges) {
369
+ var _a;
370
+ if (isSingleRange(finalRanges)) {
371
+ return finalRanges;
372
+ }
373
+ return ((_a = finalRanges.first()) !== null && _a !== void 0 ? _a : fail('Map must be non-empty'))[1];
374
+ }
375
+ function extractFirstFinalFromRange(finalRange) {
376
+ return finalRange[0];
377
+ }
378
+ function getPairOrNextLowerByValue(firstLocal, finalRanges, finalId) {
379
+ if (finalRanges === undefined) {
380
+ return undefined;
381
+ }
382
+ if (isSingleRange(finalRanges)) {
383
+ if (finalId < finalRanges[0]) {
384
+ return undefined;
385
+ }
386
+ return [firstLocal, finalRanges];
387
+ }
388
+ return finalRanges.getPairOrNextLowerByValue(finalId);
389
+ }
390
+ function getPairOrNextLower(firstLocal, finalRanges, localId) {
391
+ if (finalRanges === undefined) {
392
+ return undefined;
393
+ }
394
+ if (isSingleRange(finalRanges)) {
395
+ if (localId > firstLocal) {
396
+ return undefined;
397
+ }
398
+ return [firstLocal, finalRanges];
399
+ }
400
+ return finalRanges.getPairOrNextLower(localId);
401
+ }
402
+ function* entries(firstLocal, finalRanges) {
403
+ if (finalRanges !== undefined) {
404
+ if (isSingleRange(finalRanges)) {
405
+ yield [firstLocal, finalRanges];
406
+ }
407
+ else {
408
+ for (const range of finalRanges.entries()) {
409
+ yield range;
410
+ }
411
+ }
412
+ }
413
+ }
414
+ //# sourceMappingURL=SessionIdNormalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionIdNormalizer.js","sourceRoot":"","sources":["../../src/id-compressor/SessionIdNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8DAA8D;AAE9D,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,IAAI,EAAW,MAAM,WAAW,CAAC;AAEtG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAO,mBAAmB;IAkB/B,YAAoC,mBAAmB,KAAK;QAAxB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAjBpD,gBAAW,GAAsB,CAAC,CAAsB,CAAC;QAChD,aAAQ,GAIrB,IAAI,yBAAyB,CAChC,4BAA4B,EAC5B,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,EAAE;YACpB,IAAI,WAAW,KAAK,SAAS,EAAE;gBAC9B,MAAM,KAAK,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;gBACzC,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC;aACzC;YACD,OAAO,MAAM,CAAC,iBAAsC,CAAC;QACtD,CAAC,EACD,oBAAoB,CACpB,CAAC;IAE6D,CAAC;IAEhE;;;OAGG;IACI,iBAAiB,CAAC,OAA0B;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,UAAU,KAAK,SAAS,EAAE;YAC7B,MAAM,CAAC,UAAU,EAAE,CAAC,SAAS,EAAE,WAAW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aACZ;SACD;KACD;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/restrict-plus-operands */\n\nimport { assert, compareFiniteNumbers, compareFiniteNumbersReversed, fail, Mutable } from '../Common';\nimport { FinalCompressedId, LocalCompressedId, SessionSpaceCompressedId } from '../Identifiers';\nimport { AppendOnlyDoublySortedMap } from './AppendOnlySortedMap';\n\n/**\n * Maps IDs created by a session between their local and final forms (i.e. normalization). These IDs are in a contiguous range.\n * The local and final forms of IDs made by a session can be thought of as two equal-length sparse arrays, aligned such\n * that normalizeLocalToFinal(locals[i]) === finals[i] and vice versa.\n * Below is an example to illustrate how various mappings can arise:\n *\n * +- Creation Index\n * / +- Locals\n * / / +- Finals\n * / / /\n * ---+-----+----\n * 0 | -1 | 0 -|___ Two IDs are allocated as locals since no cluster exists. A new cluster is created when acked.\n * 1 | -2 | 1 -|\n * 2 | | 2 -|\n * 3 | | 3 --|-- Three more IDs are allocated as finals eagerly since a cluster exists with available capacity.\n * 4 | | 4 -|\n * 5 | -6 | 10 ----- One ID is allocated as a local (it overflows the existing cluster) and a new cluster is created after ack.\n * 6 | | 11 ----- One ID is allocated as a final eagerly into the existing cluster.\n * 7 | -8 | 12 ----- A local ID with an override is allocated. The override forces it to be a local ID.\n * 8 | | 13\n * 9 | | 14\n * 10 | -11 | ----- A local ID is allocated. It has no corresponding final ID since it has not been acked.\n *\n * Note that in this example, some IDs (those at indices 2, 3, 4, 6, 8, and 9) have no local form. The ID at index 10 has no final form.\n * These kinds of \"gaps\" occur due to the timing of allocation calls on the client and how they relate to finalization/cluster creation,\n * which depends on receiving an ack/sequence number from the server. Given this context, \"session space\" can be thought of as:\n *\n * \t\tfor each index in the range of IDs created by a session:\n * \t\t\tthe local form if it exists, otherwise the final form\n *\n * This class is designed to efficiently build and query these mappings by leveraging the facts that much of the range (in both local and\n * final space) is uninterrupted by \"gaps\" and can be compactly represented by a (first, last) pair and is easily binary searched for\n * normalization between local and final space.\n */\nexport class SessionIdNormalizer<TRangeObject> {\n\tprivate nextLocalId: LocalCompressedId = -1 as LocalCompressedId;\n\tprivate readonly idRanges: AppendOnlyDoublySortedMap<\n\t\tLocalCompressedId,\n\t\t[lastLocal: LocalCompressedId, finalRanges: FinalRanges<TRangeObject> | undefined],\n\t\tFinalCompressedId\n\t> = new AppendOnlyDoublySortedMap(\n\t\tcompareFiniteNumbersReversed,\n\t\t([_, finalRanges]) => {\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\tconst first = getFirstRange(finalRanges);\n\t\t\t\treturn extractFirstFinalFromRange(first);\n\t\t\t}\n\t\t\treturn Number.POSITIVE_INFINITY as FinalCompressedId;\n\t\t},\n\t\tcompareFiniteNumbers\n\t);\n\n\tpublic constructor(private readonly expensiveAsserts = false) {}\n\n\t/**\n\t * Converts the final ID to its session-space representation.\n\t * This will be the corresponding local if a local form exists, and `finalId` otherwise.\n\t */\n\tpublic getSessionSpaceId(finalId: FinalCompressedId): SessionSpaceCompressedId | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\tif (finalDelta <= localRangeDelta) {\n\t\t\t\t\t\treturn (alignedLocal - finalDelta) as LocalCompressedId;\n\t\t\t\t\t}\n\t\t\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Converts the local ID to its corresponding final ID, if one exists.\n\t */\n\tpublic getFinalId(localId: LocalCompressedId): [FinalCompressedId, TRangeObject] | undefined {\n\t\tconst localRange =\n\t\t\tthis.idRanges.getPairOrNextLower(localId) ?? fail('Local ID was never recorded with this normalizer.');\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localId < lastLocal) {\n\t\t\tfail('Local ID was never recorded with this normalizer.');\n\t\t}\n\t\tconst finalRange = getPairOrNextLower(firstLocal, finalRanges, localId);\n\t\tif (finalRange !== undefined) {\n\t\t\tconst [alignedLocal, [firstFinal, lastFinal, rangeObject]] = finalRange;\n\t\t\tconst rangeDelta = lastFinal - firstFinal;\n\t\t\tconst localDelta = alignedLocal - localId;\n\t\t\tif (localDelta <= rangeDelta) {\n\t\t\t\t// Local is within a range segment that has a corresponding final\n\t\t\t\treturn [(firstFinal + localDelta) as FinalCompressedId, rangeObject];\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the index of the supplied session-space ID in the total range of IDs created by the session, if the ID was created\n\t * by the session for this `SessionIdNormalizer`.\n\t */\n\tpublic getCreationIndex(finalId: FinalCompressedId): number | undefined {\n\t\tconst localRange = this.idRanges.getPairOrNextLowerByValue(finalId);\n\t\tif (localRange !== undefined) {\n\t\t\tconst [firstLocal, [_, finalRanges]] = localRange;\n\t\t\tconst finalRange = getPairOrNextLowerByValue(firstLocal, finalRanges, finalId);\n\t\t\tif (finalRange !== undefined) {\n\t\t\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\t\t\tif (finalId <= lastFinal) {\n\t\t\t\t\tconst finalDelta = finalId - firstFinal;\n\t\t\t\t\treturn -alignedLocal - 1 + finalDelta;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Returns the session-space ID at the supplied creation index, if one exists.\n\t */\n\tpublic getIdByCreationIndex(index: number): SessionSpaceCompressedId | undefined {\n\t\tconst localByIndex = -(index + 1) as LocalCompressedId;\n\t\tconst localRange = this.idRanges.getPairOrNextLower(localByIndex);\n\t\tif (localRange === undefined) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst [firstLocal, [lastLocal, finalRanges]] = localRange;\n\t\tif (localByIndex >= lastLocal) {\n\t\t\treturn localByIndex;\n\t\t}\n\t\tconst finalRange =\n\t\t\tgetPairOrNextLower(firstLocal, finalRanges, localByIndex) ??\n\t\t\tfail('Final ranges not aligned with owning local range.');\n\n\t\tconst [alignedLocal, [firstFinal, lastFinal]] = finalRange;\n\t\tconst localDelta = alignedLocal - localByIndex;\n\t\tconst finalId = firstFinal + localDelta;\n\t\tif (finalId <= lastFinal) {\n\t\t\t// `finalId` was an eagerly generated final ID\n\t\t\treturn finalId as SessionSpaceCompressedId;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tprivate static makeFinalRangesMap<TRangeObject>(): FinalRangesMap<TRangeObject> {\n\t\treturn new AppendOnlyDoublySortedMap(\n\t\t\tcompareFiniteNumbersReversed,\n\t\t\textractFirstFinalFromRange,\n\t\t\tcompareFiniteNumbers\n\t\t);\n\t}\n\n\t/**\n\t * Returns the last final ID known to this normalizer.\n\t */\n\tpublic getLastFinalId(): FinalCompressedId | undefined {\n\t\tconst lastIndex = this.idRanges.size - 1;\n\t\tconst secondToLast = Math.max(0, lastIndex - 1);\n\t\tfor (let i = lastIndex; i >= secondToLast; i--) {\n\t\t\tconst localRange = this.idRanges.getAtIndex(i);\n\t\t\tif (localRange !== undefined) {\n\t\t\t\tconst finalRanges = localRange[1][1];\n\t\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t\treturn getLastRange(finalRanges)[1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Registers and returns the next ID in local space with this normalizer. An example:\n\t *\n\t * Locals: [-1, -2, X, X]\n\t * Finals: [ 0, 1, 2, 3]\n\t * In this scenario, a call to this method would generate and return -5.\n\t */\n\tpublic addLocalId(): LocalCompressedId {\n\t\tconst localId = this.nextLocalId-- as LocalCompressedId;\n\t\tconst lastLocalRange = this.idRanges.last();\n\t\tif (lastLocalRange !== undefined) {\n\t\t\tconst lastLocal = lastLocalRange[1][0];\n\t\t\tif (localId === lastLocal - 1) {\n\t\t\t\t// New local simply expands the last local range tracked\n\t\t\t\tlastLocalRange[1][0] = localId;\n\t\t\t\treturn localId;\n\t\t\t}\n\t\t}\n\n\t\tif (this.expensiveAsserts) {\n\t\t\tif (lastLocalRange === undefined) {\n\t\t\t\tassert(localId === -1, 'Local ID space must start at -1.');\n\t\t\t} else {\n\t\t\t\tconst [firstLocal, [_, finalRanges]] = lastLocalRange;\n\t\t\t\tlet finalDelta = 0;\n\t\t\t\tfor (const [_, [firstFinal, lastFinal]] of entries(firstLocal, finalRanges)) {\n\t\t\t\t\tfinalDelta += lastFinal - firstFinal + 1;\n\t\t\t\t}\n\t\t\t\tassert(localId === firstLocal - finalDelta, 'Local ID space must be contiguous.');\n\t\t\t}\n\t\t}\n\n\t\tthis.idRanges.append(localId, [localId, undefined]);\n\t\treturn localId;\n\t}\n\n\t/**\n\t * Registers a final ID with this normalizer.\n\t * If there are any local IDs at the tip of session-space that do not have a corresponding final, it will be registered (aligned) with\n\t * the first of those. Otherwise, will be registered as the next ID in session space in creation order. An example:\n\t *\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, X]\n\t * Calling `addFinalIds` with first === last === 5 results in the following:\n\t * Locals: [-1, -2, X, -4]\n\t * Finals: [ 0, 1, 2, 5]\n\t * Calling `addFinalIds` with first === last === 6 results in the following:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 6]\n\t *\n\t * Non-contiguous final IDs (i.e. the first final after a \"gap\" in final space) must always correspond to a local ID. For example,\n\t * in the final call to `addFinalIds` above would fail if first === last === 9, because the resulting state would have a\n\t * non-contiguous final ID without a local form:\n\t * Locals: [-1, -2, X, -4, X]\n\t * Finals: [ 0, 1, 2, 5, 9]\n\t * ^final ID 9 is not contiguous and does not have a corresponding local ID\n\t */\n\tpublic addFinalIds(firstFinal: FinalCompressedId, lastFinal: FinalCompressedId, rangeObject: TRangeObject): void {\n\t\tassert(lastFinal >= firstFinal, 'Malformed normalization range.');\n\t\tconst [firstLocal, finalRangesObj] =\n\t\t\tthis.idRanges.last() ?? fail('Final IDs must be added to an existing local range.');\n\t\tconst [lastLocal, finalRanges] = finalRangesObj;\n\t\tlet nextLocal: LocalCompressedId;\n\t\tif (finalRanges === undefined) {\n\t\t\tfinalRangesObj[1] = [firstFinal, lastFinal, rangeObject];\n\t\t\tnextLocal = Math.min(this.nextLocalId, firstLocal - (lastFinal - firstFinal) - 1) as LocalCompressedId;\n\t\t} else {\n\t\t\tconst isSingle = isSingleRange(finalRanges);\n\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\tlet firstAlignedLocal: LocalCompressedId;\n\t\t\tif (isSingle) {\n\t\t\t\tfirstAlignedLocal = firstLocal;\n\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t} else {\n\t\t\t\t[firstAlignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t\t}\n\n\t\t\tconst [firstAlignedFinal, lastAlignedFinal] = lastFinalRange;\n\t\t\tconst lastAlignedLocal = firstAlignedLocal - (lastAlignedFinal - firstAlignedFinal);\n\t\t\tnextLocal = Math.min(\n\t\t\t\tthis.nextLocalId,\n\t\t\t\tlastAlignedLocal - (lastFinal - firstFinal) - 2\n\t\t\t) as LocalCompressedId;\n\t\t\tif (firstFinal === lastAlignedFinal + 1) {\n\t\t\t\tlastFinalRange[1] = lastFinal;\n\t\t\t} else {\n\t\t\t\tconst alignedLocal = (lastAlignedLocal - 1) as LocalCompressedId;\n\t\t\t\tlet rangeMap: FinalRangesMap<TRangeObject>;\n\t\t\t\tif (isSingle) {\n\t\t\t\t\t// Convert the single range to a range collection\n\t\t\t\t\trangeMap = SessionIdNormalizer.makeFinalRangesMap();\n\t\t\t\t\trangeMap.append(firstAlignedLocal, lastFinalRange);\n\t\t\t\t\tfinalRangesObj[1] = rangeMap;\n\t\t\t\t} else {\n\t\t\t\t\trangeMap = finalRanges;\n\t\t\t\t}\n\t\t\t\trangeMap.append(alignedLocal, [firstFinal, lastFinal, rangeObject]);\n\t\t\t\tassert(alignedLocal >= lastLocal, 'Gaps in final space must align to a local.');\n\t\t\t}\n\t\t\tif (this.expensiveAsserts) {\n\t\t\t\tthis.idRanges.assertValid();\n\t\t\t}\n\t\t}\n\n\t\tthis.nextLocalId = nextLocal;\n\t}\n\n\t/**\n\t * Returns an enumerable of all session-space IDs known to this normalizer, in creation order.\n\t */\n\tpublic *[Symbol.iterator](): IterableIterator<SessionSpaceCompressedId> {\n\t\tfor (const [firstLocal, [lastLocal, finalRanges]] of this.idRanges.entries()) {\n\t\t\tfor (let i = firstLocal; i >= lastLocal; i--) {\n\t\t\t\tyield i;\n\t\t\t}\n\t\t\tif (finalRanges !== undefined) {\n\t\t\t\t// Safe to get only the last final range, as all others must have corresponding locals (see `addFinalIds` docs)\n\t\t\t\tlet lastFinalRange: FinalRange<TRangeObject>;\n\t\t\t\tlet alignedLocal: LocalCompressedId;\n\t\t\t\tif (isSingleRange(finalRanges)) {\n\t\t\t\t\talignedLocal = firstLocal;\n\t\t\t\t\tlastFinalRange = finalRanges;\n\t\t\t\t} else {\n\t\t\t\t\t[alignedLocal, lastFinalRange] = finalRanges.last() ?? fail('Map should be non-empty.');\n\t\t\t\t}\n\t\t\t\tconst [firstFinal, lastFinal] = lastFinalRange;\n\t\t\t\tconst localRangeDelta = alignedLocal - lastLocal;\n\t\t\t\tfor (let i = firstFinal + localRangeDelta + 1; i <= lastFinal; i++) {\n\t\t\t\t\tyield i as SessionSpaceCompressedId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic serialize(): SerializedSessionIdNormalizer {\n\t\tconst serialized: Mutable<SerializedSessionIdNormalizer> = { localRanges: [] };\n\t\tconst localRanges = serialized.localRanges as Mutable<typeof serialized.localRanges>;\n\t\tfor (const [firstLocal, finalRanges] of this.idRanges.entries()) {\n\t\t\tconst [lastLocal, finalRangesTable] = finalRanges;\n\t\t\tif (finalRangesTable !== undefined) {\n\t\t\t\tconst serializedFinalRanges: [LocalCompressedId, FinalCompressedId, FinalCompressedId][] = [];\n\t\t\t\tfor (const [alignedLocal, [firstFinal, lastFinal]] of entries(firstLocal, finalRangesTable)) {\n\t\t\t\t\tserializedFinalRanges.push([alignedLocal, firstFinal, lastFinal]);\n\t\t\t\t}\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal, serializedFinalRanges]);\n\t\t\t} else {\n\t\t\t\tlocalRanges.push([firstLocal, lastLocal]);\n\t\t\t}\n\t\t}\n\t\treturn serialized;\n\t}\n\n\tpublic static deserialize<TRangeObject>(\n\t\tserialized: SerializedSessionIdNormalizer,\n\t\tgetRangeObject: (finalId: FinalCompressedId) => TRangeObject\n\t): SessionIdNormalizer<TRangeObject> {\n\t\tconst normalizer = new SessionIdNormalizer<TRangeObject>();\n\t\tconst { idRanges } = normalizer;\n\t\tfor (const [firstLocal, lastLocal, serializedFinalRanges] of serialized.localRanges) {\n\t\t\tlet finalRanges: FinalRanges<TRangeObject> | undefined;\n\t\t\tif (serializedFinalRanges !== undefined) {\n\t\t\t\tassert(serializedFinalRanges.length !== 0, 'Empty range should not be reified.');\n\t\t\t\tif (serializedFinalRanges.length === 1) {\n\t\t\t\t\tconst [_, firstFinal, lastFinal] = serializedFinalRanges[0];\n\t\t\t\t\tfinalRanges = [firstFinal, lastFinal, getRangeObject(firstFinal)];\n\t\t\t\t} else {\n\t\t\t\t\tfinalRanges = SessionIdNormalizer.makeFinalRangesMap<TRangeObject>();\n\t\t\t\t\tfor (const [alignedLocal, firstFinal, lastFinal] of serializedFinalRanges) {\n\t\t\t\t\t\tfinalRanges.append(alignedLocal, [firstFinal, lastFinal, getRangeObject(firstFinal)]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tidRanges.append(firstLocal, [lastLocal, finalRanges]);\n\t\t}\n\t\treturn normalizer;\n\t}\n\n\tpublic equals(\n\t\tother: SessionIdNormalizer<TRangeObject>,\n\t\tcompareRangeObjects: (a: TRangeObject, b: TRangeObject) => boolean = (a, b) => a === b\n\t): boolean {\n\t\treturn this.idRanges.equals(other.idRanges, (localRangeA, localRangeB) => {\n\t\t\tconst [lastLocalA, finalRangesA] = localRangeA;\n\t\t\tconst [lastLocalB, finalRangesB] = localRangeB;\n\t\t\tif (finalRangesA === undefined || finalRangesB === undefined) {\n\t\t\t\treturn finalRangesA === finalRangesB;\n\t\t\t}\n\n\t\t\tconst rangeEquals = (finalRangeA: FinalRange<TRangeObject>, finalRangeB: FinalRange<TRangeObject>) => {\n\t\t\t\tconst [firstFinalA, lastFinalA, rangeObjectA] = finalRangeA;\n\t\t\t\tconst [firstFinalB, lastFinalB, rangeObjectB] = finalRangeB;\n\t\t\t\treturn (\n\t\t\t\t\tfirstFinalA === firstFinalB &&\n\t\t\t\t\tlastFinalA === lastFinalB &&\n\t\t\t\t\tcompareRangeObjects(rangeObjectA, rangeObjectB)\n\t\t\t\t);\n\t\t\t};\n\n\t\t\tif (isSingleRange(finalRangesA) || isSingleRange(finalRangesB)) {\n\t\t\t\tif (!isSingleRange(finalRangesA) || !isSingleRange(finalRangesB)) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\treturn rangeEquals(finalRangesA, finalRangesB);\n\t\t\t}\n\n\t\t\treturn lastLocalA === lastLocalB && finalRangesA.equals(finalRangesB, rangeEquals);\n\t\t});\n\t}\n}\n\n/**\n * Serialized table for normalizing IDs made by the local session.\n *\n * TODO: Move this into ID compressor persisted types when integrated.\n */\nexport interface SerializedSessionIdNormalizer {\n\treadonly localRanges: readonly (readonly [\n\t\tfirstLocal: LocalCompressedId,\n\t\tlastLocal: LocalCompressedId,\n\t\tfinalRanges?: readonly (readonly [\n\t\t\talignedLocal: LocalCompressedId,\n\t\t\tfirstFinal: FinalCompressedId,\n\t\t\tlastFinal: FinalCompressedId\n\t\t])[]\n\t])[];\n}\n\ntype FinalRange<TRangeObject> = [\n\tfirstFinal: FinalCompressedId,\n\tlastFinal: FinalCompressedId,\n\trangeObject: TRangeObject\n];\n\ntype FinalRangesMap<TRangeObject> = AppendOnlyDoublySortedMap<\n\tLocalCompressedId,\n\tFinalRange<TRangeObject>,\n\tFinalCompressedId\n>;\n\ntype FinalRanges<TRangeObject> = FinalRange<TRangeObject> | FinalRangesMap<TRangeObject>;\n\nfunction isSingleRange<TRangeObject>(ranges: FinalRanges<TRangeObject>): ranges is FinalRange<TRangeObject> {\n\treturn Array.isArray(ranges);\n}\n\nfunction getLastRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.last() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction getFirstRange<TRangeObject>(finalRanges: FinalRanges<TRangeObject>): FinalRange<TRangeObject> {\n\tif (isSingleRange(finalRanges)) {\n\t\treturn finalRanges;\n\t}\n\treturn (finalRanges.first() ?? fail('Map must be non-empty'))[1];\n}\n\nfunction extractFirstFinalFromRange<TRangeObject>(finalRange: FinalRange<TRangeObject>): FinalCompressedId {\n\treturn finalRange[0];\n}\n\nfunction getPairOrNextLowerByValue<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tfinalId: FinalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (finalId < finalRanges[0]) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLowerByValue(finalId);\n}\n\nfunction getPairOrNextLower<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined,\n\tlocalId: LocalCompressedId\n): readonly [LocalCompressedId, FinalRange<TRangeObject>] | undefined {\n\tif (finalRanges === undefined) {\n\t\treturn undefined;\n\t}\n\tif (isSingleRange(finalRanges)) {\n\t\tif (localId > firstLocal) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn [firstLocal, finalRanges];\n\t}\n\treturn finalRanges.getPairOrNextLower(localId);\n}\n\nfunction* entries<TRangeObject>(\n\tfirstLocal: LocalCompressedId,\n\tfinalRanges: FinalRanges<TRangeObject> | undefined\n): IterableIterator<readonly [LocalCompressedId, FinalRange<TRangeObject>]> {\n\tif (finalRanges !== undefined) {\n\t\tif (isSingleRange(finalRanges)) {\n\t\t\tyield [firstLocal, finalRanges];\n\t\t} else {\n\t\t\tfor (const range of finalRanges.entries()) {\n\t\t\t\tyield range;\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -2,12 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import type { Serializable } from '@fluidframework/datastore-definitions';
6
- import type { FinalCompressedId, LocalCompressedId, OpSpaceCompressedId, SessionId } from '../../Identifiers';
7
- /**
8
- * Extensible attribution info associated with a session.
9
- */
10
- export declare type AttributionInfo = Serializable;
5
+ import type { AttributionId, FinalCompressedId, LocalCompressedId, OpSpaceCompressedId, SessionId } from '../../Identifiers';
11
6
  /**
12
7
  * A serialized ID allocation session for an `IdCompressor`.
13
8
  */
@@ -17,9 +12,9 @@ export declare type SerializedSessionData = readonly [
17
12
  */
18
13
  sessionId: SessionId,
19
14
  /**
20
- * The attribution info provided for the session
15
+ * Index into the serialized AttributionIDs array; points to the attribution ID provided for this session
21
16
  */
22
- attributionInfo?: AttributionInfo
17
+ attributionId?: number
23
18
  ];
24
19
  export declare type SerializedClusterOverrides = readonly [
25
20
  /** The overridden final ID, represented as an index into the cluster's ID range */
@@ -63,10 +58,6 @@ export interface SerializedLocalState {
63
58
  * Overrides generated by this session. Omitted if no local overrides exist in the session.
64
59
  */
65
60
  overrides?: SerializedLocalOverrides;
66
- /**
67
- * Boolean to track whether attribution has been sent with an ID range yet.
68
- */
69
- sentAttributionInfo: boolean;
70
61
  /**
71
62
  * The most recent local ID in a range returned by `takeNextCreationRange`.
72
63
  */
@@ -91,6 +82,8 @@ export interface SerializedIdCompressor extends VersionedSerializedIdCompressor
91
82
  readonly sessions: readonly SerializedSessionData[];
92
83
  /** All clusters in the compressor in the order they were created. */
93
84
  readonly clusters: readonly SerializedCluster[];
85
+ /** All attribution IDs for all sessions */
86
+ readonly attributionIds?: readonly AttributionId[];
94
87
  }
95
88
  /**
96
89
  * The serialized contents of an IdCompressor, suitable for persistence in a summary.
@@ -136,7 +129,7 @@ export interface SerializedIdCompressorWithOngoingSession extends SerializedIdCo
136
129
  export interface IdCreationRange {
137
130
  readonly sessionId: SessionId;
138
131
  readonly ids?: IdCreationRange.Ids;
139
- readonly attributionInfo?: AttributionInfo;
132
+ readonly attributionId?: AttributionId;
140
133
  }
141
134
  export declare type UnackedLocalId = LocalCompressedId & OpSpaceCompressedId;
142
135
  export declare namespace IdCreationRange {
@@ -1 +1 @@
1
- {"version":3,"file":"0.0.1.d.ts","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9G;;GAEG;AACH,oBAAY,eAAe,GAAG,YAAY,CAAC;AAE3C;;GAEG;AACH,oBAAY,qBAAqB,GAAG,SAAS;IAC5C;;OAEG;IACH,SAAS,EAAE,SAAS;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,eAA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,QAAQ,GAAG,SAAS,CAAC,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvE,KAAY,SAAS,GAAG,SAAS,CAAC,QAAQ,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;CAC3D"}
@@ -1 +1 @@
1
- {"version":3,"file":"0.0.1.js","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { Serializable } from '@fluidframework/datastore-definitions';\nimport type { FinalCompressedId, LocalCompressedId, OpSpaceCompressedId, SessionId } from '../../Identifiers';\n\n/**\n * Extensible attribution info associated with a session.\n */\nexport type AttributionInfo = Serializable;\n\n/**\n * A serialized ID allocation session for an `IdCompressor`.\n */\nexport type SerializedSessionData = readonly [\n\t/**\n\t * The ID of the session.\n\t */\n\tsessionId: SessionId,\n\n\t/**\n\t * The attribution info provided for the session\n\t */\n\tattributionInfo?: AttributionInfo\n];\n\nexport type SerializedClusterOverrides = readonly [\n\t/** The overridden final ID, represented as an index into the cluster's ID range */\n\toverriddenFinalIndex: number, // A cluster with base UUID '...beef' and an `overriddenFinalIndex` of 3 would correspond to '...bef2'\n\t/** The override string */\n\toverride: string,\n\t/** The first ID that was finalized and associated with this override, set only if different than the `overriddenFinalIndex` */\n\toverriddenId?: FinalCompressedId\n][];\n\n/**\n * A serialized final ID cluster.\n */\nexport type SerializedCluster = readonly [\n\t/**\n\t * Index into the serialized sessions array. Can be converted into a baseUuid via its order in `clusters`.\n\t * If negative, then this cluster was created by the local session.\n\t */\n\tsessionIndex: number,\n\n\t/**\n\t * The capacity of the cluster.\n\t */\n\tcapacity: number,\n\n\t/**\n\t * The number of IDs in the cluster. Omitted if count === capacity.\n\t * --OR--\n\t * The overrides in this cluster. Omitted if no overrides exist in the cluster.\n\t */\n\tcountOrOverrides?: number | SerializedClusterOverrides,\n\n\t/**\n\t * Overrides in this cluster. Omitted if no overrides exist in the cluster.\n\t */\n\toverrides?: SerializedClusterOverrides\n];\n\nexport type SerializedLocalOverrides = readonly [LocalCompressedId, string][];\n\nexport interface SerializedLocalState {\n\t/**\n\t * The total number of local IDs created by this session\n\t */\n\tlocalIdCount: number;\n\t/**\n\t * Overrides generated by this session. Omitted if no local overrides exist in the session.\n\t */\n\toverrides?: SerializedLocalOverrides;\n\n\t/**\n\t * Boolean to track whether attribution has been sent with an ID range yet.\n\t */\n\tsentAttributionInfo: boolean;\n\n\t/**\n\t * The most recent local ID in a range returned by `takeNextCreationRange`.\n\t */\n\tlastTakenLocalId: LocalCompressedId | undefined;\n}\n\n/**\n * The minimal required contents of a serialized IdCompressor.\n */\nexport interface VersionedSerializedIdCompressor {\n\treadonly _versionedSerializedIdCompressor: '8c73c57c-1cf4-4278-8915-6444cb4f6af5';\n\treadonly version: string;\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressor extends VersionedSerializedIdCompressor {\n\t/** The cluster capacity of this compressor */\n\treadonly clusterCapacity: number;\n\t/** The number of reserved IDs in this compressor */\n\treadonly reservedIdCount: number;\n\t/** All sessions except the local session. */\n\treadonly sessions: readonly SerializedSessionData[];\n\t/** All clusters in the compressor in the order they were created. */\n\treadonly clusters: readonly SerializedCluster[];\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressorWithNoSession extends SerializedIdCompressor {\n\treadonly _noLocalState: '3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb';\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressorWithOngoingSession extends SerializedIdCompressor {\n\treadonly _hasLocalState: '1281acae-6d14-47e7-bc92-71c8ee0819cb';\n\t/** The session ID of the local session, by index into `sessions`. */\n\treadonly localSessionIndex: number;\n\t/** This is only present if the local session made any IDs. */\n\treadonly localState?: SerializedLocalState;\n}\n\n/**\n * Data describing a range of session-local IDs (from a remote or local session).\n *\n * A range is composed of local IDs that were generated. Some of these may have overrides.\n *\n * @example\n * Suppose an IdCompressor generated a sequence of local IDs as follows:\n * ```\n * compressor.generateLocalId()\n * compressor.generateLocalId('0093cf29-9454-4034-8940-33b1077b41c3')\n * compressor.generateLocalId()\n * compressor.generateLocalId('0ed545f8-e97e-4dc1-acf9-c4a783258bdf')\n * compressor.generateLocalId()\n * compressor.generateLocalId()\n * compressor.takeNextCreationRange()\n * ```\n * This would result in the following range:\n * ```\n * {\n * first: localId1,\n * last: localId6,\n * overrides: [[localId2, '0093cf29-9454-4034-8940-33b1077b41c3'], [localId4, '0ed545f8-e97e-4dc1-acf9-c4a783258bdf']]\n * }\n * ```\n */\nexport interface IdCreationRange {\n\treadonly sessionId: SessionId;\n\treadonly ids?: IdCreationRange.Ids;\n\treadonly attributionInfo?: AttributionInfo;\n}\n\nexport type UnackedLocalId = LocalCompressedId & OpSpaceCompressedId;\n\nexport namespace IdCreationRange {\n\texport type Ids =\n\t\t| {\n\t\t\t\treadonly first: UnackedLocalId;\n\t\t\t\treadonly last: UnackedLocalId;\n\t\t }\n\t\t| ({\n\t\t\t\treadonly first?: UnackedLocalId;\n\t\t\t\treadonly last?: UnackedLocalId;\n\t\t } & HasOverrides);\n\n\texport interface HasOverrides {\n\t\treadonly overrides: Overrides;\n\t}\n\n\texport type Override = readonly [id: UnackedLocalId, override: string];\n\texport type Overrides = readonly [Override, ...Override[]];\n}\n"]}
1
+ {"version":3,"file":"0.0.1.js","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tAttributionId,\n\tFinalCompressedId,\n\tLocalCompressedId,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from '../../Identifiers';\n\n/**\n * A serialized ID allocation session for an `IdCompressor`.\n */\nexport type SerializedSessionData = readonly [\n\t/**\n\t * The ID of the session.\n\t */\n\tsessionId: SessionId,\n\n\t/**\n\t * Index into the serialized AttributionIDs array; points to the attribution ID provided for this session\n\t */\n\tattributionId?: number\n];\n\nexport type SerializedClusterOverrides = readonly [\n\t/** The overridden final ID, represented as an index into the cluster's ID range */\n\toverriddenFinalIndex: number, // A cluster with base UUID '...beef' and an `overriddenFinalIndex` of 3 would correspond to '...bef2'\n\t/** The override string */\n\toverride: string,\n\t/** The first ID that was finalized and associated with this override, set only if different than the `overriddenFinalIndex` */\n\toverriddenId?: FinalCompressedId\n][];\n\n/**\n * A serialized final ID cluster.\n */\nexport type SerializedCluster = readonly [\n\t/**\n\t * Index into the serialized sessions array. Can be converted into a baseUuid via its order in `clusters`.\n\t * If negative, then this cluster was created by the local session.\n\t */\n\tsessionIndex: number,\n\n\t/**\n\t * The capacity of the cluster.\n\t */\n\tcapacity: number,\n\n\t/**\n\t * The number of IDs in the cluster. Omitted if count === capacity.\n\t * --OR--\n\t * The overrides in this cluster. Omitted if no overrides exist in the cluster.\n\t */\n\tcountOrOverrides?: number | SerializedClusterOverrides,\n\n\t/**\n\t * Overrides in this cluster. Omitted if no overrides exist in the cluster.\n\t */\n\toverrides?: SerializedClusterOverrides\n];\n\nexport type SerializedLocalOverrides = readonly [LocalCompressedId, string][];\n\nexport interface SerializedLocalState {\n\t/**\n\t * The total number of local IDs created by this session\n\t */\n\tlocalIdCount: number;\n\t/**\n\t * Overrides generated by this session. Omitted if no local overrides exist in the session.\n\t */\n\toverrides?: SerializedLocalOverrides;\n\n\t/**\n\t * The most recent local ID in a range returned by `takeNextCreationRange`.\n\t */\n\tlastTakenLocalId: LocalCompressedId | undefined;\n}\n\n/**\n * The minimal required contents of a serialized IdCompressor.\n */\nexport interface VersionedSerializedIdCompressor {\n\treadonly _versionedSerializedIdCompressor: '8c73c57c-1cf4-4278-8915-6444cb4f6af5';\n\treadonly version: string;\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressor extends VersionedSerializedIdCompressor {\n\t/** The cluster capacity of this compressor */\n\treadonly clusterCapacity: number;\n\t/** The number of reserved IDs in this compressor */\n\treadonly reservedIdCount: number;\n\t/** All sessions except the local session. */\n\treadonly sessions: readonly SerializedSessionData[];\n\t/** All clusters in the compressor in the order they were created. */\n\treadonly clusters: readonly SerializedCluster[];\n\t/** All attribution IDs for all sessions */\n\treadonly attributionIds?: readonly AttributionId[];\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressorWithNoSession extends SerializedIdCompressor {\n\treadonly _noLocalState: '3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb';\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressorWithOngoingSession extends SerializedIdCompressor {\n\treadonly _hasLocalState: '1281acae-6d14-47e7-bc92-71c8ee0819cb';\n\t/** The session ID of the local session, by index into `sessions`. */\n\treadonly localSessionIndex: number;\n\t/** This is only present if the local session made any IDs. */\n\treadonly localState?: SerializedLocalState;\n}\n\n/**\n * Data describing a range of session-local IDs (from a remote or local session).\n *\n * A range is composed of local IDs that were generated. Some of these may have overrides.\n *\n * @example\n * Suppose an IdCompressor generated a sequence of local IDs as follows:\n * ```\n * compressor.generateLocalId()\n * compressor.generateLocalId('0093cf29-9454-4034-8940-33b1077b41c3')\n * compressor.generateLocalId()\n * compressor.generateLocalId('0ed545f8-e97e-4dc1-acf9-c4a783258bdf')\n * compressor.generateLocalId()\n * compressor.generateLocalId()\n * compressor.takeNextCreationRange()\n * ```\n * This would result in the following range:\n * ```\n * {\n * first: localId1,\n * last: localId6,\n * overrides: [[localId2, '0093cf29-9454-4034-8940-33b1077b41c3'], [localId4, '0ed545f8-e97e-4dc1-acf9-c4a783258bdf']]\n * }\n * ```\n */\nexport interface IdCreationRange {\n\treadonly sessionId: SessionId;\n\treadonly ids?: IdCreationRange.Ids;\n\treadonly attributionId?: AttributionId;\n}\n\nexport type UnackedLocalId = LocalCompressedId & OpSpaceCompressedId;\n\nexport namespace IdCreationRange {\n\texport type Ids =\n\t\t| {\n\t\t\t\treadonly first: UnackedLocalId;\n\t\t\t\treadonly last: UnackedLocalId;\n\t\t }\n\t\t| ({\n\t\t\t\treadonly first?: UnackedLocalId;\n\t\t\t\treadonly last?: UnackedLocalId;\n\t\t } & HasOverrides);\n\n\texport interface HasOverrides {\n\t\treadonly overrides: Overrides;\n\t}\n\n\texport type Override = readonly [id: UnackedLocalId, override: string];\n\texport type Overrides = readonly [Override, ...Override[]];\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -15,7 +15,7 @@ export { initialTree } from './InitialTree';
15
15
  export { TreeNodeHandle } from './TreeNodeHandle';
16
16
  export { Delta, Forest, ForestNode, ParentData } from './Forest';
17
17
  export { sharedTreeAssertionErrorType, isSharedTreeEvent, Result } from './Common';
18
- export type { CompressedId, Definition, DetachedSequenceId, EditId, InternedStringId, FinalCompressedId, LocalCompressedId, NodeId, NodeIdBrand, StableNodeId, SessionSpaceCompressedId, SessionUnique, TraitLabel, UuidString, } from './Identifiers';
18
+ export type { CompressedId, Definition, DetachedSequenceId, EditId, InternedStringId, FinalCompressedId, LocalCompressedId, NodeId, NodeIdBrand, StableNodeId, SessionSpaceCompressedId, SessionUnique, TraitLabel, UuidString, AttributionId, } from './Identifiers';
19
19
  export { isDetachedSequenceId } from './Identifiers';
20
20
  export type { OrderedEditSet, EditHandle } from './EditLog';
21
21
  export { LogViewer } from './LogViewer';
@@ -28,7 +28,7 @@ export * from './MergeHealth';
28
28
  export * from './TreeViewUtilities';
29
29
  export { StringInterner } from './StringInterner';
30
30
  export { Side, EditStatus, TreeNode, TreeNodeSequence, Payload, ConstraintEffect, Edit, ChangeInternal, InternalizedChange, ChangeNode, ChangeNode_0_0_2, EditLogSummary, FluidEditHandle, SharedTreeSummaryBase, EditWithoutId, PlaceholderTree, EditBase, HasTraits, InsertInternal, DetachInternal, BuildInternal, SetValueInternal, ConstraintInternal, BuildNodeInternal, StablePlaceInternal_0_0_2, StableRangeInternal_0_0_2, NodeData, TraitMap, ChangeTypeInternal, TraitLocationInternal_0_0_2, WriteFormat, ConstraintInternal_0_0_2, StablePlaceInternal, StableRangeInternal, BuildNodeInternal_0_0_2, BuildInternal_0_0_2, InsertInternal_0_0_2, DetachInternal_0_0_2, SetValueInternal_0_0_2, TraitLocationInternal, } from './persisted-types';
31
- export { SharedTreeFactory, SharedTree, EditCommittedHandler, SequencedEditAppliedHandler, EditCommittedEventArguments, SequencedEditAppliedEventArguments, EditApplicationOutcome, ISharedTreeEvents, } from './SharedTree';
31
+ export { SharedTreeArgs, SharedTreeOptions, SharedTreeOptions_0_0_2, SharedTreeOptions_0_1_1, SharedTreeFactory, SharedTree, EditCommittedHandler, SequencedEditAppliedHandler, EditCommittedEventArguments, SequencedEditAppliedEventArguments, EditApplicationOutcome, ISharedTreeEvents, } from './SharedTree';
32
32
  export * from './EventTypes';
33
33
  export { setTrait, areRevisionViewsSemanticallyEqual, BadPlaceValidationResult, BadRangeValidationResult, PlaceValidationResult, RangeValidationResult, RangeValidationResultKind, } from './EditUtilities';
34
34
  export { comparePayloads } from './PayloadUtilities';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACnF,YAAY,EACX,YAAY,EACZ,UAAU,EACV,kB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