@fluidframework/id-compressor 2.0.0-internal.8.0.1 → 2.0.0-rc.1.0.1
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.
- package/CHANGELOG.md +12 -0
- package/README.md +0 -6
- package/api-extractor-esm.json +4 -0
- package/api-extractor-lint.json +1 -10
- package/api-extractor.json +1 -9
- package/api-report/id-compressor.api.md +7 -5
- package/dist/id-compressor-alpha.d.ts +32 -5
- package/dist/id-compressor-beta.d.ts +142 -9
- package/dist/id-compressor-public.d.ts +142 -9
- package/dist/id-compressor-untrimmed.d.ts +32 -5
- package/dist/idCompressor.d.ts +6 -0
- package/dist/idCompressor.d.ts.map +1 -1
- package/dist/idCompressor.js +58 -20
- package/dist/idCompressor.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sessions.js +3 -6
- package/dist/sessions.js.map +1 -1
- package/dist/types/idCompressor.d.ts +22 -1
- package/dist/types/idCompressor.d.ts.map +1 -1
- package/dist/types/idCompressor.js.map +1 -1
- package/dist/types/identifiers.d.ts +4 -4
- package/dist/types/identifiers.js.map +1 -1
- package/lib/{appendOnlySortedMap.d.ts → appendOnlySortedMap.d.mts} +1 -1
- package/lib/appendOnlySortedMap.d.mts.map +1 -0
- package/lib/{appendOnlySortedMap.js → appendOnlySortedMap.mjs} +1 -3
- package/lib/appendOnlySortedMap.mjs.map +1 -0
- package/lib/{finalSpace.d.ts → finalSpace.d.mts} +3 -3
- package/lib/finalSpace.d.mts.map +1 -0
- package/lib/{finalSpace.js → finalSpace.mjs} +2 -2
- package/lib/finalSpace.mjs.map +1 -0
- package/lib/{id-compressor-alpha.d.ts → id-compressor-alpha.d.mts} +32 -5
- package/lib/id-compressor-beta.d.mts +172 -0
- package/lib/id-compressor-public.d.mts +172 -0
- package/lib/{id-compressor-untrimmed.d.ts → id-compressor-untrimmed.d.mts} +32 -5
- package/lib/{idCompressor.d.ts → idCompressor.d.mts} +8 -2
- package/lib/idCompressor.d.mts.map +1 -0
- package/lib/{idCompressor.js → idCompressor.mjs} +65 -27
- package/lib/idCompressor.mjs.map +1 -0
- package/lib/{identifiers.d.ts → identifiers.d.mts} +2 -2
- package/lib/identifiers.d.mts.map +1 -0
- package/lib/{identifiers.js → identifiers.mjs} +1 -1
- package/lib/identifiers.mjs.map +1 -0
- package/lib/{index.d.ts → index.d.mts} +4 -7
- package/lib/index.d.mts.map +1 -0
- package/lib/{index.js → index.mjs} +3 -6
- package/lib/index.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +2 -2
- package/lib/packageVersion.d.mts.map +1 -0
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{persistanceUtilities.d.ts → persistanceUtilities.d.mts} +2 -2
- package/lib/persistanceUtilities.d.mts.map +1 -0
- package/lib/{persistanceUtilities.js → persistanceUtilities.mjs} +1 -1
- package/lib/persistanceUtilities.mjs.map +1 -0
- package/lib/{sessionSpaceNormalizer.d.ts → sessionSpaceNormalizer.d.mts} +3 -3
- package/lib/sessionSpaceNormalizer.d.mts.map +1 -0
- package/lib/{sessionSpaceNormalizer.js → sessionSpaceNormalizer.mjs} +3 -3
- package/lib/sessionSpaceNormalizer.mjs.map +1 -0
- package/lib/{sessions.d.ts → sessions.d.mts} +3 -3
- package/lib/sessions.d.mts.map +1 -0
- package/lib/{sessions.js → sessions.mjs} +3 -3
- package/lib/sessions.mjs.map +1 -0
- package/lib/types/{idCompressor.d.ts → idCompressor.d.mts} +25 -4
- package/lib/types/idCompressor.d.mts.map +1 -0
- package/lib/types/{identifiers.js → idCompressor.mjs} +1 -1
- package/lib/types/idCompressor.mjs.map +1 -0
- package/lib/types/{identifiers.d.ts → identifiers.d.mts} +5 -5
- package/lib/types/identifiers.d.mts.map +1 -0
- package/lib/types/{idCompressor.js → identifiers.mjs} +1 -1
- package/lib/types/identifiers.mjs.map +1 -0
- package/lib/types/{index.d.ts → index.d.mts} +4 -4
- package/lib/types/index.d.mts.map +1 -0
- package/lib/types/{persisted-types/0.0.1.js → index.mjs} +1 -1
- package/lib/types/index.mjs.map +1 -0
- package/lib/types/persisted-types/{0.0.1.d.ts → 0.0.1.d.mts} +2 -2
- package/lib/types/persisted-types/0.0.1.d.mts.map +1 -0
- package/lib/types/persisted-types/{index.js → 0.0.1.mjs} +1 -1
- package/lib/types/persisted-types/0.0.1.mjs.map +1 -0
- package/lib/types/persisted-types/{index.d.ts → index.d.mts} +2 -2
- package/lib/types/persisted-types/index.d.mts.map +1 -0
- package/lib/types/{index.js → persisted-types/index.mjs} +1 -1
- package/lib/types/persisted-types/index.mjs.map +1 -0
- package/lib/{utilities.d.ts → utilities.d.mts} +3 -3
- package/lib/utilities.d.mts.map +1 -0
- package/lib/{utilities.js → utilities.mjs} +1 -2
- package/lib/utilities.mjs.map +1 -0
- package/package.json +26 -20
- package/src/idCompressor.ts +76 -19
- package/src/packageVersion.ts +1 -1
- package/src/sessions.ts +1 -1
- package/src/types/idCompressor.ts +23 -1
- package/src/types/identifiers.ts +4 -4
- package/tsconfig.json +4 -2
- package/lib/appendOnlySortedMap.d.ts.map +0 -1
- package/lib/appendOnlySortedMap.js.map +0 -1
- package/lib/finalSpace.d.ts.map +0 -1
- package/lib/finalSpace.js.map +0 -1
- package/lib/id-compressor-beta.d.ts +0 -39
- package/lib/id-compressor-public.d.ts +0 -39
- package/lib/idCompressor.d.ts.map +0 -1
- package/lib/idCompressor.js.map +0 -1
- package/lib/identifiers.d.ts.map +0 -1
- package/lib/identifiers.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packageVersion.d.ts.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/persistanceUtilities.d.ts.map +0 -1
- package/lib/persistanceUtilities.js.map +0 -1
- package/lib/sessionSpaceNormalizer.d.ts.map +0 -1
- package/lib/sessionSpaceNormalizer.js.map +0 -1
- package/lib/sessions.d.ts.map +0 -1
- package/lib/sessions.js.map +0 -1
- package/lib/types/idCompressor.d.ts.map +0 -1
- package/lib/types/idCompressor.js.map +0 -1
- package/lib/types/identifiers.d.ts.map +0 -1
- package/lib/types/identifiers.js.map +0 -1
- package/lib/types/index.d.ts.map +0 -1
- package/lib/types/index.js.map +0 -1
- package/lib/types/persisted-types/0.0.1.d.ts.map +0 -1
- package/lib/types/persisted-types/0.0.1.js.map +0 -1
- package/lib/types/persisted-types/index.d.ts.map +0 -1
- package/lib/types/persisted-types/index.js.map +0 -1
- package/lib/utilities.d.ts.map +0 -1
- package/lib/utilities.js.map +0 -1
- package/tsconfig.esnext.json +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @fluidframework/id-compressor
|
|
2
2
|
|
|
3
|
+
## 2.0.0-rc.1.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- id-compressor: Cluster allocation strategy updated ([#19066](https://github.com/microsoft/FluidFramework/issues/19066)) [0c36eb5f53](https://github.com/microsoft/FluidFramework/commits/0c36eb5f539362a8e27982e831a3ffe7999c1478)
|
|
8
|
+
|
|
9
|
+
This change adjusts the cluster allocation strategy for ghost sessions to exactly fill the cluster instead of needlessly allocating a large cluster.
|
|
10
|
+
It will also not make a cluster at all if IDs are not allocated.
|
|
11
|
+
This change adjusts a computation performed at a consensus point, and thus breaks any sessions collaborating across version numbers.
|
|
12
|
+
The version for the serialized format has been bumped to 2.0, and 1.0 documents will fail to load with the following error:
|
|
13
|
+
IdCompressor version 1.0 is no longer supported.
|
|
14
|
+
|
|
3
15
|
## 2.0.0-internal.8.0.0
|
|
4
16
|
|
|
5
17
|
Dependency updates only.
|
package/README.md
CHANGED
|
@@ -30,12 +30,6 @@ When taking a dependency on a Fluid Framework library, we recommend using a `^`
|
|
|
30
30
|
While Fluid Framework libraries may use different ranges with interdependencies between other Fluid Framework libraries,
|
|
31
31
|
library consumers should always prefer `^`.
|
|
32
32
|
|
|
33
|
-
Note that when depending on a library version of the form `2.0.0-internal.x.y.z`, called the Fluid internal version scheme,
|
|
34
|
-
you must use a `>= <` dependency range (such as `>=2.0.0-internal.x.y.z <2.0.0-internal.w.0.0` where `w` is `x+1`).
|
|
35
|
-
Standard `^` and `~` ranges will not work as expected.
|
|
36
|
-
See the [@fluid-tools/version-tools](https://github.com/microsoft/FluidFramework/blob/main/build-tools/packages/version-tools/README.md)
|
|
37
|
-
package for more information including tools to convert between version schemes.
|
|
38
|
-
|
|
39
33
|
<!-- prettier-ignore-end -->
|
|
40
34
|
|
|
41
35
|
<!-- AUTO-GENERATED-CONTENT:END -->
|
package/api-extractor-lint.json
CHANGED
|
@@ -1,13 +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-lint.json"
|
|
4
|
-
"messages": {
|
|
5
|
-
"extractorMessageReporting": {
|
|
6
|
-
// TODO: remove once base config has this enabled as an error
|
|
7
|
-
"ae-incompatible-release-tags": {
|
|
8
|
-
"logLevel": "error",
|
|
9
|
-
"addToApiReportFile": false
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-lint.json"
|
|
13
4
|
}
|
package/api-extractor.json
CHANGED
|
@@ -1,12 +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.json"
|
|
4
|
-
"messages": {
|
|
5
|
-
"extractorMessageReporting": {
|
|
6
|
-
// TODO: Add missing documentation and remove this rule override
|
|
7
|
-
"ae-undocumented": {
|
|
8
|
-
"logLevel": "none"
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.json"
|
|
12
4
|
}
|
|
@@ -29,6 +29,7 @@ export function generateStableId(): StableId;
|
|
|
29
29
|
|
|
30
30
|
// @alpha @deprecated
|
|
31
31
|
export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
32
|
+
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;
|
|
32
33
|
// @deprecated (undocumented)
|
|
33
34
|
static create(logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
34
35
|
// @deprecated (undocumented)
|
|
@@ -76,7 +77,7 @@ export interface IdCreationRange {
|
|
|
76
77
|
readonly sessionId: SessionId;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
// @
|
|
80
|
+
// @public
|
|
80
81
|
export interface IIdCompressor {
|
|
81
82
|
decompress(id: SessionSpaceCompressedId): StableId;
|
|
82
83
|
generateCompressedId(): SessionSpaceCompressedId;
|
|
@@ -90,6 +91,7 @@ export interface IIdCompressor {
|
|
|
90
91
|
|
|
91
92
|
// @alpha (undocumented)
|
|
92
93
|
export interface IIdCompressorCore {
|
|
94
|
+
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): any;
|
|
93
95
|
finalizeCreationRange(range: IdCreationRange): void;
|
|
94
96
|
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
95
97
|
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
@@ -99,7 +101,7 @@ export interface IIdCompressorCore {
|
|
|
99
101
|
// @internal
|
|
100
102
|
export function isStableId(str: string): str is StableId;
|
|
101
103
|
|
|
102
|
-
// @
|
|
104
|
+
// @public
|
|
103
105
|
export type OpSpaceCompressedId = number & {
|
|
104
106
|
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
105
107
|
};
|
|
@@ -119,17 +121,17 @@ export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor &
|
|
|
119
121
|
readonly _hasLocalState: "1281acae-6d14-47e7-bc92-71c8ee0819cb";
|
|
120
122
|
};
|
|
121
123
|
|
|
122
|
-
// @
|
|
124
|
+
// @public
|
|
123
125
|
export type SessionId = StableId & {
|
|
124
126
|
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
125
127
|
};
|
|
126
128
|
|
|
127
|
-
// @
|
|
129
|
+
// @public
|
|
128
130
|
export type SessionSpaceCompressedId = number & {
|
|
129
131
|
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
130
132
|
};
|
|
131
133
|
|
|
132
|
-
// @
|
|
134
|
+
// @public
|
|
133
135
|
export type StableId = string & {
|
|
134
136
|
readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
|
|
135
137
|
};
|
|
@@ -65,6 +65,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
65
65
|
private nextRequestedClusterSize;
|
|
66
66
|
private telemetryLocalIdCount;
|
|
67
67
|
private telemetryEagerFinalIdCount;
|
|
68
|
+
private ongoingGhostSession?;
|
|
68
69
|
private constructor();
|
|
69
70
|
/**
|
|
70
71
|
* @deprecated Use `createIdCompressor` instead.
|
|
@@ -75,6 +76,10 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
75
76
|
*/
|
|
76
77
|
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
77
78
|
generateCompressedId(): SessionSpaceCompressedId;
|
|
79
|
+
/**
|
|
80
|
+
* {@inheritdoc IIdCompressorCore.beginGhostSession}
|
|
81
|
+
*/
|
|
82
|
+
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;
|
|
78
83
|
private generateNextLocalId;
|
|
79
84
|
takeNextCreationRange(): IdCreationRange;
|
|
80
85
|
private static assertValidRange;
|
|
@@ -89,6 +94,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
89
94
|
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
90
95
|
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
91
96
|
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
97
|
+
private static deserialize2_0;
|
|
92
98
|
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
93
99
|
}
|
|
94
100
|
|
|
@@ -178,7 +184,7 @@ export declare interface IdCreationRange {
|
|
|
178
184
|
*
|
|
179
185
|
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
180
186
|
* should use op-space IDs.
|
|
181
|
-
* @
|
|
187
|
+
* @public
|
|
182
188
|
*/
|
|
183
189
|
export declare interface IIdCompressor {
|
|
184
190
|
localSessionId: SessionId;
|
|
@@ -240,6 +246,27 @@ export declare interface IIdCompressorCore {
|
|
|
240
246
|
* @param range - the range of session-local IDs to finalize.
|
|
241
247
|
*/
|
|
242
248
|
finalizeCreationRange(range: IdCreationRange): void;
|
|
249
|
+
/**
|
|
250
|
+
* Run a callback that is performed from the perspective of a special "ghost" session.
|
|
251
|
+
* Any ids generated by this session will be immediately finalized on the local client as if
|
|
252
|
+
* they were created by a remote client with `ghostSessionId`.
|
|
253
|
+
*
|
|
254
|
+
* *WARNING:* This API requires an external consensus mechanism to safely use:
|
|
255
|
+
* In an attached container (i.e. multiple clients may have the document loaded), all clients must guarantee that:
|
|
256
|
+
* - They invoke this API starting from the same finalized creation ranges
|
|
257
|
+
* - This API is invoked with the same ghost session id
|
|
258
|
+
* - `ghostSessionCallback` deterministically mints the same number of ids on each client within the ghost session
|
|
259
|
+
* Failure to meet these requirement will result in divergence across clients and eventual consistency errors.
|
|
260
|
+
* While the ghost sesion callback is running, IdCompressor does not support serialization.
|
|
261
|
+
* @remarks This API is primarily intended for data migration scenarios which are able to deterministically transform
|
|
262
|
+
* data in some format into data in a new format.
|
|
263
|
+
* The first requirement (that all clients must invoke the API with the same finalized creation ranges) is guaranteed
|
|
264
|
+
* for this scenario because the data transformation callback occurs at a specific ack within the op stream on all
|
|
265
|
+
* clients, and clients don't finalize creation ranges for local changes they might have at this point in time.
|
|
266
|
+
* @param ghostSessionId - The session id that minted ids generated within `ghostSessionCallback` should be attributed to.
|
|
267
|
+
* @param ghostSessionCallback - Callback which mints ids attributed to the ghost session.
|
|
268
|
+
*/
|
|
269
|
+
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): any;
|
|
243
270
|
/**
|
|
244
271
|
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
245
272
|
* This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.
|
|
@@ -258,7 +285,7 @@ export declare interface IIdCompressorCore {
|
|
|
258
285
|
* A compressed ID that has been normalized into "op space".
|
|
259
286
|
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
|
|
260
287
|
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
261
|
-
* @
|
|
288
|
+
* @public
|
|
262
289
|
*/
|
|
263
290
|
export declare type OpSpaceCompressedId = number & {
|
|
264
291
|
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
@@ -290,7 +317,7 @@ export declare type SerializedIdCompressorWithOngoingSession = SerializedIdCompr
|
|
|
290
317
|
|
|
291
318
|
/**
|
|
292
319
|
* A StableId which is suitable for use as a session identifier
|
|
293
|
-
* @
|
|
320
|
+
* @public
|
|
294
321
|
*/
|
|
295
322
|
export declare type SessionId = StableId & {
|
|
296
323
|
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
@@ -300,7 +327,7 @@ export declare type SessionId = StableId & {
|
|
|
300
327
|
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
301
328
|
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to
|
|
302
329
|
* the scope of the session (i.e. compressor) that produced them.
|
|
303
|
-
* @
|
|
330
|
+
* @public
|
|
304
331
|
*/
|
|
305
332
|
export declare type SessionSpaceCompressedId = number & {
|
|
306
333
|
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
@@ -311,7 +338,7 @@ export declare type SessionSpaceCompressedId = number & {
|
|
|
311
338
|
* A 128-bit Universally Unique IDentifier. Represented here
|
|
312
339
|
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
313
340
|
* where x is a lowercase hex digit.
|
|
314
|
-
* @
|
|
341
|
+
* @public
|
|
315
342
|
*/
|
|
316
343
|
export declare type StableId = string & {
|
|
317
344
|
readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
|
|
@@ -14,15 +14,125 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
|
14
14
|
|
|
15
15
|
/* Excluded from this release type: IdCreationRange */
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* A distributed UUID generator and compressor.
|
|
19
|
+
*
|
|
20
|
+
* Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple "sessions" (which can be distributed across the network),
|
|
21
|
+
* providing each session with the ability to map these UUIDs to `numbers`.
|
|
22
|
+
*
|
|
23
|
+
* A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API
|
|
24
|
+
* which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is
|
|
25
|
+
* created it is said to be created by the compressor's "local" session.
|
|
26
|
+
*
|
|
27
|
+
* For each stable ID created, two numeric IDs are provided by the compressor:
|
|
28
|
+
*
|
|
29
|
+
* 1. A session-local ID, which is stable for the lifetime of the session (which could be longer than that of the compressor object, as it may
|
|
30
|
+
* be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only
|
|
31
|
+
* safely usable within the scope of the compressor that created it.
|
|
32
|
+
*
|
|
33
|
+
* 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing
|
|
34
|
+
* the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.
|
|
35
|
+
* Final IDs are known to and publicly usable by any compressor that has received them.
|
|
36
|
+
*
|
|
37
|
+
* Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed
|
|
38
|
+
* to map the UUIDs to the numbers.
|
|
39
|
+
*
|
|
40
|
+
* The following invariants are upheld by IdCompressor:
|
|
41
|
+
*
|
|
42
|
+
* 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.
|
|
43
|
+
*
|
|
44
|
+
* 2. Final IDs will always decompress to the same UUIDs.
|
|
45
|
+
*
|
|
46
|
+
* 3. After a server-processed range of session-local IDs (from any session) is received by a compressor, any of those session-local IDs may be
|
|
47
|
+
* translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the
|
|
48
|
+
* same final ID.
|
|
49
|
+
*
|
|
50
|
+
* 4. A UUID will always compress into the same session-local ID for the lifetime of the session.
|
|
51
|
+
*
|
|
52
|
+
* Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*
|
|
53
|
+
* be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.
|
|
54
|
+
*
|
|
55
|
+
* Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This
|
|
56
|
+
* could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a
|
|
57
|
+
* session-local ID but is later queried using the final ID (which is semantically equal, as it decompresses to the same UUID/string) it will
|
|
58
|
+
* produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the
|
|
59
|
+
* session-local IDs have been finalized, the compressor defines two "spaces" of IDs:
|
|
60
|
+
*
|
|
61
|
+
* 1. Session space: in this space, all IDs are normalized to their "most local form". This means that all IDs created by the local session
|
|
62
|
+
* will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after
|
|
63
|
+
* finalizing and will never have a local form for the compressor, will of course be final IDs. This space should be used with consumer APIs
|
|
64
|
+
* and data structures, as the lifetime of the IDs is guaranteed to be the same as the compressor object. Care must be taken to not use
|
|
65
|
+
* these IDs across compressor objects, as the local IDs are specific to the compressor that created them.
|
|
66
|
+
*
|
|
67
|
+
* 2. Op space: in this space, all IDs are normalized to their "most final form". This means that all IDs except session-local IDs that
|
|
68
|
+
* have not yet been finalized will be in final ID form. This space is useful for serialization in ops (e.g. references), as other clients
|
|
69
|
+
* that receive them need not do any work to normalize them to *their* session-space in the common case. Note that IDs in op space may move
|
|
70
|
+
* out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a "more final form".
|
|
71
|
+
* Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially
|
|
72
|
+
* incorrect to use this type for a runtime variable. This is an asymmetry that does not affect session space, as local IDs are always as
|
|
73
|
+
* "local as possible".
|
|
74
|
+
*
|
|
75
|
+
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
76
|
+
* should use op-space IDs.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare interface IIdCompressor {
|
|
80
|
+
localSessionId: SessionId;
|
|
81
|
+
/**
|
|
82
|
+
* Generates a new compressed ID or returns an existing one.
|
|
83
|
+
* This should ONLY be called to generate IDs for local operations.
|
|
84
|
+
* @returns A new local ID in session space.
|
|
85
|
+
*/
|
|
86
|
+
generateCompressedId(): SessionSpaceCompressedId;
|
|
87
|
+
/**
|
|
88
|
+
* Normalizes a session space ID into op space.
|
|
89
|
+
* @param id - the local ID to normalize.
|
|
90
|
+
* @returns the ID in op space.
|
|
91
|
+
*/
|
|
92
|
+
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
93
|
+
/**
|
|
94
|
+
* Normalizes an ID into session space.
|
|
95
|
+
* @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding
|
|
96
|
+
* to `sessionId`.
|
|
97
|
+
* @param originSessionId - the session from which `id` originated
|
|
98
|
+
* @returns the session-space ID corresponding to `id`, which might not have been a final ID if the client that created it had not yet
|
|
99
|
+
* finalized it. This can occur when a client references an ID during the window of time in which it is waiting to receive the ordered
|
|
100
|
+
* range that contained it from the server.
|
|
101
|
+
*/
|
|
102
|
+
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
103
|
+
/**
|
|
104
|
+
* Decompresses a previously compressed ID into a UUID.
|
|
105
|
+
* @param id - the compressed ID to be decompressed.
|
|
106
|
+
* @returns the UUID associated with the compressed ID. Fails if the ID was not generated by this compressor.
|
|
107
|
+
*/
|
|
108
|
+
decompress(id: SessionSpaceCompressedId): StableId;
|
|
109
|
+
/**
|
|
110
|
+
* Recompresses a UUID.
|
|
111
|
+
* @param uncompressed - the UUID to recompress.
|
|
112
|
+
* @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
|
|
113
|
+
*/
|
|
114
|
+
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
115
|
+
/**
|
|
116
|
+
* Attempts to recompresses a UUID.
|
|
117
|
+
* @param uncompressed - the UUID to recompress,
|
|
118
|
+
* @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.
|
|
119
|
+
*/
|
|
120
|
+
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
121
|
+
}
|
|
18
122
|
|
|
19
123
|
/* Excluded from this release type: IIdCompressorCore */
|
|
20
124
|
|
|
21
125
|
/* Excluded from this release type: isStableId */
|
|
22
126
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
127
|
+
/**
|
|
128
|
+
* A compressed ID that has been normalized into "op space".
|
|
129
|
+
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
|
|
130
|
+
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export declare type OpSpaceCompressedId = number & {
|
|
134
|
+
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
135
|
+
};
|
|
26
136
|
|
|
27
137
|
/* Excluded from this release type: SerializedIdCompressor */
|
|
28
138
|
|
|
@@ -30,10 +140,33 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
|
30
140
|
|
|
31
141
|
/* Excluded from this release type: SerializedIdCompressorWithOngoingSession */
|
|
32
142
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
143
|
+
/**
|
|
144
|
+
* A StableId which is suitable for use as a session identifier
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare type SessionId = StableId & {
|
|
148
|
+
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
153
|
+
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to
|
|
154
|
+
* the scope of the session (i.e. compressor) that produced them.
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export declare type SessionSpaceCompressedId = number & {
|
|
158
|
+
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
|
|
163
|
+
* A 128-bit Universally Unique IDentifier. Represented here
|
|
164
|
+
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
165
|
+
* where x is a lowercase hex digit.
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export declare type StableId = string & {
|
|
169
|
+
readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
|
|
170
|
+
};
|
|
38
171
|
|
|
39
172
|
export { }
|
|
@@ -14,15 +14,125 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
|
14
14
|
|
|
15
15
|
/* Excluded from this release type: IdCreationRange */
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* A distributed UUID generator and compressor.
|
|
19
|
+
*
|
|
20
|
+
* Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple "sessions" (which can be distributed across the network),
|
|
21
|
+
* providing each session with the ability to map these UUIDs to `numbers`.
|
|
22
|
+
*
|
|
23
|
+
* A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API
|
|
24
|
+
* which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is
|
|
25
|
+
* created it is said to be created by the compressor's "local" session.
|
|
26
|
+
*
|
|
27
|
+
* For each stable ID created, two numeric IDs are provided by the compressor:
|
|
28
|
+
*
|
|
29
|
+
* 1. A session-local ID, which is stable for the lifetime of the session (which could be longer than that of the compressor object, as it may
|
|
30
|
+
* be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only
|
|
31
|
+
* safely usable within the scope of the compressor that created it.
|
|
32
|
+
*
|
|
33
|
+
* 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing
|
|
34
|
+
* the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.
|
|
35
|
+
* Final IDs are known to and publicly usable by any compressor that has received them.
|
|
36
|
+
*
|
|
37
|
+
* Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed
|
|
38
|
+
* to map the UUIDs to the numbers.
|
|
39
|
+
*
|
|
40
|
+
* The following invariants are upheld by IdCompressor:
|
|
41
|
+
*
|
|
42
|
+
* 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.
|
|
43
|
+
*
|
|
44
|
+
* 2. Final IDs will always decompress to the same UUIDs.
|
|
45
|
+
*
|
|
46
|
+
* 3. After a server-processed range of session-local IDs (from any session) is received by a compressor, any of those session-local IDs may be
|
|
47
|
+
* translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the
|
|
48
|
+
* same final ID.
|
|
49
|
+
*
|
|
50
|
+
* 4. A UUID will always compress into the same session-local ID for the lifetime of the session.
|
|
51
|
+
*
|
|
52
|
+
* Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*
|
|
53
|
+
* be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.
|
|
54
|
+
*
|
|
55
|
+
* Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This
|
|
56
|
+
* could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a
|
|
57
|
+
* session-local ID but is later queried using the final ID (which is semantically equal, as it decompresses to the same UUID/string) it will
|
|
58
|
+
* produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the
|
|
59
|
+
* session-local IDs have been finalized, the compressor defines two "spaces" of IDs:
|
|
60
|
+
*
|
|
61
|
+
* 1. Session space: in this space, all IDs are normalized to their "most local form". This means that all IDs created by the local session
|
|
62
|
+
* will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after
|
|
63
|
+
* finalizing and will never have a local form for the compressor, will of course be final IDs. This space should be used with consumer APIs
|
|
64
|
+
* and data structures, as the lifetime of the IDs is guaranteed to be the same as the compressor object. Care must be taken to not use
|
|
65
|
+
* these IDs across compressor objects, as the local IDs are specific to the compressor that created them.
|
|
66
|
+
*
|
|
67
|
+
* 2. Op space: in this space, all IDs are normalized to their "most final form". This means that all IDs except session-local IDs that
|
|
68
|
+
* have not yet been finalized will be in final ID form. This space is useful for serialization in ops (e.g. references), as other clients
|
|
69
|
+
* that receive them need not do any work to normalize them to *their* session-space in the common case. Note that IDs in op space may move
|
|
70
|
+
* out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a "more final form".
|
|
71
|
+
* Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially
|
|
72
|
+
* incorrect to use this type for a runtime variable. This is an asymmetry that does not affect session space, as local IDs are always as
|
|
73
|
+
* "local as possible".
|
|
74
|
+
*
|
|
75
|
+
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
76
|
+
* should use op-space IDs.
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare interface IIdCompressor {
|
|
80
|
+
localSessionId: SessionId;
|
|
81
|
+
/**
|
|
82
|
+
* Generates a new compressed ID or returns an existing one.
|
|
83
|
+
* This should ONLY be called to generate IDs for local operations.
|
|
84
|
+
* @returns A new local ID in session space.
|
|
85
|
+
*/
|
|
86
|
+
generateCompressedId(): SessionSpaceCompressedId;
|
|
87
|
+
/**
|
|
88
|
+
* Normalizes a session space ID into op space.
|
|
89
|
+
* @param id - the local ID to normalize.
|
|
90
|
+
* @returns the ID in op space.
|
|
91
|
+
*/
|
|
92
|
+
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
93
|
+
/**
|
|
94
|
+
* Normalizes an ID into session space.
|
|
95
|
+
* @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding
|
|
96
|
+
* to `sessionId`.
|
|
97
|
+
* @param originSessionId - the session from which `id` originated
|
|
98
|
+
* @returns the session-space ID corresponding to `id`, which might not have been a final ID if the client that created it had not yet
|
|
99
|
+
* finalized it. This can occur when a client references an ID during the window of time in which it is waiting to receive the ordered
|
|
100
|
+
* range that contained it from the server.
|
|
101
|
+
*/
|
|
102
|
+
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
103
|
+
/**
|
|
104
|
+
* Decompresses a previously compressed ID into a UUID.
|
|
105
|
+
* @param id - the compressed ID to be decompressed.
|
|
106
|
+
* @returns the UUID associated with the compressed ID. Fails if the ID was not generated by this compressor.
|
|
107
|
+
*/
|
|
108
|
+
decompress(id: SessionSpaceCompressedId): StableId;
|
|
109
|
+
/**
|
|
110
|
+
* Recompresses a UUID.
|
|
111
|
+
* @param uncompressed - the UUID to recompress.
|
|
112
|
+
* @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
|
|
113
|
+
*/
|
|
114
|
+
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
115
|
+
/**
|
|
116
|
+
* Attempts to recompresses a UUID.
|
|
117
|
+
* @param uncompressed - the UUID to recompress,
|
|
118
|
+
* @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.
|
|
119
|
+
*/
|
|
120
|
+
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
121
|
+
}
|
|
18
122
|
|
|
19
123
|
/* Excluded from this release type: IIdCompressorCore */
|
|
20
124
|
|
|
21
125
|
/* Excluded from this release type: isStableId */
|
|
22
126
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
127
|
+
/**
|
|
128
|
+
* A compressed ID that has been normalized into "op space".
|
|
129
|
+
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
|
|
130
|
+
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export declare type OpSpaceCompressedId = number & {
|
|
134
|
+
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
135
|
+
};
|
|
26
136
|
|
|
27
137
|
/* Excluded from this release type: SerializedIdCompressor */
|
|
28
138
|
|
|
@@ -30,10 +140,33 @@ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
|
|
|
30
140
|
|
|
31
141
|
/* Excluded from this release type: SerializedIdCompressorWithOngoingSession */
|
|
32
142
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
143
|
+
/**
|
|
144
|
+
* A StableId which is suitable for use as a session identifier
|
|
145
|
+
* @public
|
|
146
|
+
*/
|
|
147
|
+
export declare type SessionId = StableId & {
|
|
148
|
+
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
153
|
+
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to
|
|
154
|
+
* the scope of the session (i.e. compressor) that produced them.
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export declare type SessionSpaceCompressedId = number & {
|
|
158
|
+
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
|
|
163
|
+
* A 128-bit Universally Unique IDentifier. Represented here
|
|
164
|
+
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
165
|
+
* where x is a lowercase hex digit.
|
|
166
|
+
* @public
|
|
167
|
+
*/
|
|
168
|
+
export declare type StableId = string & {
|
|
169
|
+
readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
|
|
170
|
+
};
|
|
38
171
|
|
|
39
172
|
export { }
|
|
@@ -73,6 +73,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
73
73
|
private nextRequestedClusterSize;
|
|
74
74
|
private telemetryLocalIdCount;
|
|
75
75
|
private telemetryEagerFinalIdCount;
|
|
76
|
+
private ongoingGhostSession?;
|
|
76
77
|
private constructor();
|
|
77
78
|
/**
|
|
78
79
|
* @deprecated Use `createIdCompressor` instead.
|
|
@@ -83,6 +84,10 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
83
84
|
*/
|
|
84
85
|
static create(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
|
|
85
86
|
generateCompressedId(): SessionSpaceCompressedId;
|
|
87
|
+
/**
|
|
88
|
+
* {@inheritdoc IIdCompressorCore.beginGhostSession}
|
|
89
|
+
*/
|
|
90
|
+
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): void;
|
|
86
91
|
private generateNextLocalId;
|
|
87
92
|
takeNextCreationRange(): IdCreationRange;
|
|
88
93
|
private static assertValidRange;
|
|
@@ -97,6 +102,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
97
102
|
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
98
103
|
static deserialize(serialized: SerializedIdCompressorWithOngoingSession): IdCompressor;
|
|
99
104
|
static deserialize(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId): IdCompressor;
|
|
105
|
+
private static deserialize2_0;
|
|
100
106
|
equals(other: IdCompressor, includeLocalState: boolean): boolean;
|
|
101
107
|
}
|
|
102
108
|
|
|
@@ -186,7 +192,7 @@ export declare interface IdCreationRange {
|
|
|
186
192
|
*
|
|
187
193
|
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
188
194
|
* should use op-space IDs.
|
|
189
|
-
* @
|
|
195
|
+
* @public
|
|
190
196
|
*/
|
|
191
197
|
export declare interface IIdCompressor {
|
|
192
198
|
localSessionId: SessionId;
|
|
@@ -248,6 +254,27 @@ export declare interface IIdCompressorCore {
|
|
|
248
254
|
* @param range - the range of session-local IDs to finalize.
|
|
249
255
|
*/
|
|
250
256
|
finalizeCreationRange(range: IdCreationRange): void;
|
|
257
|
+
/**
|
|
258
|
+
* Run a callback that is performed from the perspective of a special "ghost" session.
|
|
259
|
+
* Any ids generated by this session will be immediately finalized on the local client as if
|
|
260
|
+
* they were created by a remote client with `ghostSessionId`.
|
|
261
|
+
*
|
|
262
|
+
* *WARNING:* This API requires an external consensus mechanism to safely use:
|
|
263
|
+
* In an attached container (i.e. multiple clients may have the document loaded), all clients must guarantee that:
|
|
264
|
+
* - They invoke this API starting from the same finalized creation ranges
|
|
265
|
+
* - This API is invoked with the same ghost session id
|
|
266
|
+
* - `ghostSessionCallback` deterministically mints the same number of ids on each client within the ghost session
|
|
267
|
+
* Failure to meet these requirement will result in divergence across clients and eventual consistency errors.
|
|
268
|
+
* While the ghost sesion callback is running, IdCompressor does not support serialization.
|
|
269
|
+
* @remarks This API is primarily intended for data migration scenarios which are able to deterministically transform
|
|
270
|
+
* data in some format into data in a new format.
|
|
271
|
+
* The first requirement (that all clients must invoke the API with the same finalized creation ranges) is guaranteed
|
|
272
|
+
* for this scenario because the data transformation callback occurs at a specific ack within the op stream on all
|
|
273
|
+
* clients, and clients don't finalize creation ranges for local changes they might have at this point in time.
|
|
274
|
+
* @param ghostSessionId - The session id that minted ids generated within `ghostSessionCallback` should be attributed to.
|
|
275
|
+
* @param ghostSessionCallback - Callback which mints ids attributed to the ghost session.
|
|
276
|
+
*/
|
|
277
|
+
beginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): any;
|
|
251
278
|
/**
|
|
252
279
|
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
253
280
|
* This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.
|
|
@@ -271,7 +298,7 @@ export declare function isStableId(str: string): str is StableId;
|
|
|
271
298
|
* A compressed ID that has been normalized into "op space".
|
|
272
299
|
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
|
|
273
300
|
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
274
|
-
* @
|
|
301
|
+
* @public
|
|
275
302
|
*/
|
|
276
303
|
export declare type OpSpaceCompressedId = number & {
|
|
277
304
|
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
@@ -303,7 +330,7 @@ export declare type SerializedIdCompressorWithOngoingSession = SerializedIdCompr
|
|
|
303
330
|
|
|
304
331
|
/**
|
|
305
332
|
* A StableId which is suitable for use as a session identifier
|
|
306
|
-
* @
|
|
333
|
+
* @public
|
|
307
334
|
*/
|
|
308
335
|
export declare type SessionId = StableId & {
|
|
309
336
|
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
@@ -313,7 +340,7 @@ export declare type SessionId = StableId & {
|
|
|
313
340
|
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
314
341
|
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to
|
|
315
342
|
* the scope of the session (i.e. compressor) that produced them.
|
|
316
|
-
* @
|
|
343
|
+
* @public
|
|
317
344
|
*/
|
|
318
345
|
export declare type SessionSpaceCompressedId = number & {
|
|
319
346
|
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
@@ -324,7 +351,7 @@ export declare type SessionSpaceCompressedId = number & {
|
|
|
324
351
|
* A 128-bit Universally Unique IDentifier. Represented here
|
|
325
352
|
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
326
353
|
* where x is a lowercase hex digit.
|
|
327
|
-
* @
|
|
354
|
+
* @public
|
|
328
355
|
*/
|
|
329
356
|
export declare type StableId = string & {
|
|
330
357
|
readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
|