@fluidframework/runtime-definitions 2.0.0-internal.7.2.2 → 2.0.0-internal.7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -2
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/runtime-definitions.api.md +75 -113
- package/dist/attribution.d.ts +1 -4
- package/dist/attribution.d.ts.map +1 -1
- package/dist/attribution.js.map +1 -1
- package/dist/dataStoreContext.d.ts +26 -2
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +5 -0
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreFactory.d.ts +7 -0
- package/dist/dataStoreFactory.d.ts.map +1 -1
- package/dist/dataStoreFactory.js +3 -0
- package/dist/dataStoreFactory.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts +10 -0
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/dataStoreRegistry.js +3 -0
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/garbageCollection.d.ts +22 -4
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +20 -4
- package/dist/garbageCollection.js.map +1 -1
- package/dist/index.d.ts +49 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +7 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime-definitions-alpha.d.ts +1002 -0
- package/dist/runtime-definitions-beta.d.ts +201 -0
- package/dist/runtime-definitions-public.d.ts +201 -0
- package/dist/runtime-definitions-untrimmed.d.ts +1117 -0
- package/dist/summary.d.ts +34 -0
- package/dist/summary.d.ts.map +1 -1
- package/dist/summary.js +12 -0
- package/dist/summary.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/runtime-definitions-alpha.d.ts +1002 -0
- package/lib/runtime-definitions-beta.d.ts +201 -0
- package/lib/runtime-definitions-public.d.ts +201 -0
- package/lib/runtime-definitions-untrimmed.d.ts +1117 -0
- package/package.json +44 -15
- package/src/attribution.ts +1 -4
- package/src/dataStoreContext.ts +26 -2
- package/src/dataStoreFactory.ts +7 -0
- package/src/dataStoreRegistry.ts +10 -0
- package/src/garbageCollection.ts +22 -4
- package/src/index.ts +46 -7
- package/src/protocol.ts +7 -0
- package/src/summary.ts +34 -0
- package/dist/id-compressor/idCompressor.d.ts +0 -136
- package/dist/id-compressor/idCompressor.d.ts.map +0 -1
- package/dist/id-compressor/idCompressor.js +0 -7
- package/dist/id-compressor/idCompressor.js.map +0 -1
- package/dist/id-compressor/identifiers.d.ts +0 -36
- package/dist/id-compressor/identifiers.d.ts.map +0 -1
- package/dist/id-compressor/identifiers.js +0 -7
- package/dist/id-compressor/identifiers.js.map +0 -1
- package/dist/id-compressor/index.d.ts +0 -8
- package/dist/id-compressor/index.d.ts.map +0 -1
- package/dist/id-compressor/index.js +0 -10
- package/dist/id-compressor/index.js.map +0 -1
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +0 -44
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +0 -1
- package/dist/id-compressor/persisted-types/0.0.1.js +0 -13
- package/dist/id-compressor/persisted-types/0.0.1.js.map +0 -1
- package/dist/id-compressor/persisted-types/index.d.ts +0 -6
- package/dist/id-compressor/persisted-types/index.d.ts.map +0 -1
- package/dist/id-compressor/persisted-types/index.js +0 -10
- package/dist/id-compressor/persisted-types/index.js.map +0 -1
- package/src/id-compressor/idCompressor.ts +0 -152
- package/src/id-compressor/identifiers.ts +0 -35
- package/src/id-compressor/index.ts +0 -17
- package/src/id-compressor/persisted-types/0.0.1.ts +0 -50
- package/src/id-compressor/persisted-types/README.md +0 -3
- package/src/id-compressor/persisted-types/index.ts +0 -13
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId } from "./identifiers";
|
|
6
|
-
import { IdCreationRange, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession } from "./persisted-types";
|
|
7
|
-
export interface IIdCompressorCore {
|
|
8
|
-
/**
|
|
9
|
-
* Returns a range of IDs created by this session in a format for sending to the server for finalizing.
|
|
10
|
-
* The range will include all IDs generated via calls to `generateCompressedId` since the last time this method was called.
|
|
11
|
-
* @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before
|
|
12
|
-
* it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.
|
|
13
|
-
*/
|
|
14
|
-
takeNextCreationRange(): IdCreationRange;
|
|
15
|
-
/**
|
|
16
|
-
* Finalizes the supplied range of IDs (which may be from either a remote or local session).
|
|
17
|
-
* @param range - the range of session-local IDs to finalize.
|
|
18
|
-
*/
|
|
19
|
-
finalizeCreationRange(range: IdCreationRange): void;
|
|
20
|
-
/**
|
|
21
|
-
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
22
|
-
* This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.
|
|
23
|
-
*/
|
|
24
|
-
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
25
|
-
/**
|
|
26
|
-
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
27
|
-
* This only includes finalized state and is therefore suitable for use in summaries.
|
|
28
|
-
*/
|
|
29
|
-
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* A distributed UUID generator and compressor.
|
|
33
|
-
*
|
|
34
|
-
* Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple "sessions" (which can be distributed across the network),
|
|
35
|
-
* providing each session with the ability to map these UUIDs to `numbers`.
|
|
36
|
-
*
|
|
37
|
-
* A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API
|
|
38
|
-
* which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is
|
|
39
|
-
* created it is said to be created by the compressor's "local" session.
|
|
40
|
-
*
|
|
41
|
-
* For each stable ID created, two numeric IDs are provided by the compressor:
|
|
42
|
-
*
|
|
43
|
-
* 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
|
|
44
|
-
* be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only
|
|
45
|
-
* safely usable within the scope of the compressor that created it.
|
|
46
|
-
*
|
|
47
|
-
* 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing
|
|
48
|
-
* the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.
|
|
49
|
-
* Final IDs are known to and publicly usable by any compressor that has received them.
|
|
50
|
-
*
|
|
51
|
-
* Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed
|
|
52
|
-
* to map the UUIDs to the numbers.
|
|
53
|
-
*
|
|
54
|
-
* The following invariants are upheld by IdCompressor:
|
|
55
|
-
*
|
|
56
|
-
* 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.
|
|
57
|
-
*
|
|
58
|
-
* 2. Final IDs will always decompress to the same UUIDs.
|
|
59
|
-
*
|
|
60
|
-
* 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
|
|
61
|
-
* translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the
|
|
62
|
-
* same final ID.
|
|
63
|
-
*
|
|
64
|
-
* 4. A UUID will always compress into the same session-local ID for the lifetime of the session.
|
|
65
|
-
*
|
|
66
|
-
* Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*
|
|
67
|
-
* be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.
|
|
68
|
-
*
|
|
69
|
-
* Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This
|
|
70
|
-
* could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a
|
|
71
|
-
* 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
|
|
72
|
-
* produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the
|
|
73
|
-
* session-local IDs have been finalized, the compressor defines two "spaces" of IDs:
|
|
74
|
-
*
|
|
75
|
-
* 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
|
|
76
|
-
* will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after
|
|
77
|
-
* 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
|
|
78
|
-
* 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
|
|
79
|
-
* these IDs across compressor objects, as the local IDs are specific to the compressor that created them.
|
|
80
|
-
*
|
|
81
|
-
* 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
|
|
82
|
-
* 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
|
|
83
|
-
* 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
|
|
84
|
-
* out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a "more final form".
|
|
85
|
-
* Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially
|
|
86
|
-
* 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
|
|
87
|
-
* "local as possible".
|
|
88
|
-
*
|
|
89
|
-
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
90
|
-
* should use op-space IDs.
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
export interface IIdCompressor {
|
|
94
|
-
localSessionId: SessionId;
|
|
95
|
-
/**
|
|
96
|
-
* Generates a new compressed ID or returns an existing one.
|
|
97
|
-
* This should ONLY be called to generate IDs for local operations.
|
|
98
|
-
* @returns A new local ID in session space.
|
|
99
|
-
*/
|
|
100
|
-
generateCompressedId(): SessionSpaceCompressedId;
|
|
101
|
-
/**
|
|
102
|
-
* Normalizes a session space ID into op space.
|
|
103
|
-
* @param id - the local ID to normalize.
|
|
104
|
-
* @returns the ID in op space.
|
|
105
|
-
*/
|
|
106
|
-
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
107
|
-
/**
|
|
108
|
-
* Normalizes an ID into session space.
|
|
109
|
-
* @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding
|
|
110
|
-
* to `sessionId`.
|
|
111
|
-
* @param originSessionId - the session from which `id` originated
|
|
112
|
-
* @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
|
|
113
|
-
* 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
|
|
114
|
-
* range that contained it from the server.
|
|
115
|
-
*/
|
|
116
|
-
normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
|
|
117
|
-
/**
|
|
118
|
-
* Decompresses a previously compressed ID into a UUID.
|
|
119
|
-
* @param id - the compressed ID to be decompressed.
|
|
120
|
-
* @returns the UUID associated with the compressed ID. Fails if the ID was not generated by this compressor.
|
|
121
|
-
*/
|
|
122
|
-
decompress(id: SessionSpaceCompressedId): StableId;
|
|
123
|
-
/**
|
|
124
|
-
* Recompresses a UUID.
|
|
125
|
-
* @param uncompressed - the UUID to recompress.
|
|
126
|
-
* @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
|
|
127
|
-
*/
|
|
128
|
-
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
129
|
-
/**
|
|
130
|
-
* Attempts to recompresses a UUID.
|
|
131
|
-
* @param uncompressed - the UUID to recompress,
|
|
132
|
-
* @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.
|
|
133
|
-
*/
|
|
134
|
-
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=idCompressor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EACN,eAAe,EACf,mCAAmC,EACnC,wCAAwC,EACxC,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,iBAAiB;IACjC;;;;;OAKG;IACH,qBAAqB,IAAI,eAAe,CAAC;IAEzC;;;OAGG;IACH,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IAEpD;;;OAGG;IACH,SAAS,CAAC,WAAW,EAAE,IAAI,GAAG,wCAAwC,CAAC;IAEvE;;;OAGG;IACH,SAAS,CAAC,WAAW,EAAE,KAAK,GAAG,mCAAmC,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,MAAM,WAAW,aAAa;IAC7B,cAAc,EAAE,SAAS,CAAC;IAE1B;;;;OAIG;IACH,oBAAoB,IAAI,wBAAwB,CAAC;IACjD;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,EAAE,wBAAwB,GAAG,mBAAmB,CAAC;IACtE;;;;;;;;OAQG;IACH,uBAAuB,CACtB,EAAE,EAAE,mBAAmB,EACvB,eAAe,EAAE,SAAS,GACxB,wBAAwB,CAAC;IAE5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,EAAE,wBAAwB,GAAG,QAAQ,CAAC;IAEnD;;;;OAIG;IACH,UAAU,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB,CAAC;IAE7D;;;;OAIG;IACH,aAAa,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB,GAAG,SAAS,CAAC;CAC5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/id-compressor/idCompressor.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 { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId } from \"./identifiers\";\nimport {\n\tIdCreationRange,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types\";\n\nexport interface IIdCompressorCore {\n\t/**\n\t * Returns a range of IDs created by this session in a format for sending to the server for finalizing.\n\t * The range will include all IDs generated via calls to `generateCompressedId` since the last time this method was called.\n\t * @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before\n\t * it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.\n\t */\n\ttakeNextCreationRange(): IdCreationRange;\n\n\t/**\n\t * Finalizes the supplied range of IDs (which may be from either a remote or local session).\n\t * @param range - the range of session-local IDs to finalize.\n\t */\n\tfinalizeCreationRange(range: IdCreationRange): void;\n\n\t/**\n\t * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.\n\t * This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.\n\t */\n\tserialize(withSession: true): SerializedIdCompressorWithOngoingSession;\n\n\t/**\n\t * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.\n\t * This only includes finalized state and is therefore suitable for use in summaries.\n\t */\n\tserialize(withSession: false): SerializedIdCompressorWithNoSession;\n}\n\n/**\n * A distributed UUID generator and compressor.\n *\n * Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple \"sessions\" (which can be distributed across the network),\n * providing each session with the ability to map these UUIDs to `numbers`.\n *\n * A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API\n * which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is\n * created it is said to be created by the compressor's \"local\" session.\n *\n * For each stable ID created, two numeric IDs are provided by the compressor:\n *\n * 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\n * be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only\n * safely usable within the scope of the compressor that created it.\n *\n * 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing\n * the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.\n * Final IDs are known to and publicly usable by any compressor that has received them.\n *\n * Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed\n * to map the UUIDs to the numbers.\n *\n * The following invariants are upheld by IdCompressor:\n *\n * 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.\n *\n * 2. Final IDs will always decompress to the same UUIDs.\n *\n * 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\n * translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the\n * same final ID.\n *\n * 4. A UUID will always compress into the same session-local ID for the lifetime of the session.\n *\n * Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*\n * be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.\n *\n * Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This\n * could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a\n * 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\n * produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the\n * session-local IDs have been finalized, the compressor defines two \"spaces\" of IDs:\n *\n * 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\n * will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after\n * 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\n * 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\n * these IDs across compressor objects, as the local IDs are specific to the compressor that created them.\n *\n * 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\n * 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\n * 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\n * out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a \"more final form\".\n * Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially\n * 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\n * \"local as possible\".\n *\n * These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops\n * should use op-space IDs.\n *\n */\nexport interface IIdCompressor {\n\tlocalSessionId: SessionId;\n\n\t/**\n\t * Generates a new compressed ID or returns an existing one.\n\t * This should ONLY be called to generate IDs for local operations.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateCompressedId(): SessionSpaceCompressedId;\n\t/**\n\t * Normalizes a session space ID into op space.\n\t * @param id - the local ID to normalize.\n\t * @returns the ID in op space.\n\t */\n\tnormalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;\n\t/**\n\t * Normalizes an ID into session space.\n\t * @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding\n\t * to `sessionId`.\n\t * @param originSessionId - the session from which `id` originated\n\t * @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\n\t * 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\n\t * range that contained it from the server.\n\t */\n\tnormalizeToSessionSpace(\n\t\tid: OpSpaceCompressedId,\n\t\toriginSessionId: SessionId,\n\t): SessionSpaceCompressedId;\n\n\t/**\n\t * Decompresses a previously compressed ID into a UUID.\n\t * @param id - the compressed ID to be decompressed.\n\t * @returns the UUID associated with the compressed ID. Fails if the ID was not generated by this compressor.\n\t */\n\tdecompress(id: SessionSpaceCompressedId): StableId;\n\n\t/**\n\t * Recompresses a UUID.\n\t * @param uncompressed - the UUID to recompress.\n\t * @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.\n\t */\n\trecompress(uncompressed: StableId): SessionSpaceCompressedId;\n\n\t/**\n\t * Attempts to recompresses a UUID.\n\t * @param uncompressed - the UUID to recompress,\n\t * @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.\n\t */\n\ttryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;\n}\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
7
|
-
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to
|
|
8
|
-
* the scope of the session (i.e. compressor) that produced them.
|
|
9
|
-
*/
|
|
10
|
-
export type SessionSpaceCompressedId = number & {
|
|
11
|
-
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* A compressed ID that has been normalized into "op space".
|
|
15
|
-
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
|
|
16
|
-
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
17
|
-
*/
|
|
18
|
-
export type OpSpaceCompressedId = number & {
|
|
19
|
-
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
|
|
23
|
-
* A 128-bit Universally Unique IDentifier. Represented here
|
|
24
|
-
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
25
|
-
* where x is a lowercase hex digit.
|
|
26
|
-
*/
|
|
27
|
-
export type StableId = string & {
|
|
28
|
-
readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* A StableId which is suitable for use as a session identifier
|
|
32
|
-
*/
|
|
33
|
-
export type SessionId = StableId & {
|
|
34
|
-
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=identifiers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../../src/id-compressor/identifiers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG;IAC/C,QAAQ,CAAC,aAAa,EAAE,sCAAsC,CAAC;CAC/D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG;IAC1C,QAAQ,CAAC,YAAY,EAAE,sCAAsC,CAAC;CAC9D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,sCAAsC,CAAA;CAAE,CAAC;AAE9F;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,sCAAsC,CAAA;CAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../../src/id-compressor/identifiers.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * A compressed ID that has been normalized into \"session space\" (see `IdCompressor` for more).\n * Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to\n * the scope of the session (i.e. compressor) that produced them.\n */\nexport type SessionSpaceCompressedId = number & {\n\treadonly SessionUnique: \"cea55054-6b82-4cbf-ad19-1fa645ea3b3e\";\n};\n\n/**\n * A compressed ID that has been normalized into \"op space\".\n * Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when\n * received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.\n */\nexport type OpSpaceCompressedId = number & {\n\treadonly OpNormalized: \"9209432d-a959-4df7-b2ad-767ead4dbcae\";\n};\n\n/**\n * A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).\n * A 128-bit Universally Unique IDentifier. Represented here\n * with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,\n * where x is a lowercase hex digit.\n */\nexport type StableId = string & { readonly StableId: \"53172b0d-a3d5-41ea-bd75-b43839c97f5a\" };\n\n/**\n * A StableId which is suitable for use as a session identifier\n */\nexport type SessionId = StableId & { readonly SessionId: \"4498f850-e14e-4be9-8db0-89ec00997e58\" };\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
export { IdCreationRange, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, IdCreationRangeWithStashedState, initialClusterCapacity, } from "./persisted-types";
|
|
6
|
-
export { IIdCompressorCore, IIdCompressor } from "./idCompressor";
|
|
7
|
-
export { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId } from "./identifiers";
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,EACxC,+BAA+B,EAC/B,sBAAsB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.initialClusterCapacity = void 0;
|
|
8
|
-
var persisted_types_1 = require("./persisted-types");
|
|
9
|
-
Object.defineProperty(exports, "initialClusterCapacity", { enumerable: true, get: function () { return persisted_types_1.initialClusterCapacity; } });
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/id-compressor/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qDAO2B;AAD1B,yHAAA,sBAAsB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIdCreationRange,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tIdCreationRangeWithStashedState,\n\tinitialClusterCapacity,\n} from \"./persisted-types\";\n\nexport { IIdCompressorCore, IIdCompressor } from \"./idCompressor\";\n\nexport { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId } from \"./identifiers\";\n"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { SessionId } from "../identifiers";
|
|
6
|
-
/**
|
|
7
|
-
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
8
|
-
*/
|
|
9
|
-
export type SerializedIdCompressor = string & {
|
|
10
|
-
readonly _serializedIdCompressor: "8c73c57c-1cf4-4278-8915-6444cb4f6af5";
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
14
|
-
*/
|
|
15
|
-
export type SerializedIdCompressorWithNoSession = SerializedIdCompressor & {
|
|
16
|
-
readonly _noLocalState: "3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb";
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
20
|
-
*/
|
|
21
|
-
export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor & {
|
|
22
|
-
readonly _hasLocalState: "1281acae-6d14-47e7-bc92-71c8ee0819cb";
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Data describing a range of session-local IDs (from a remote or local session).
|
|
26
|
-
*
|
|
27
|
-
* A range is composed of local IDs that were generated.
|
|
28
|
-
*/
|
|
29
|
-
export interface IdCreationRange {
|
|
30
|
-
readonly sessionId: SessionId;
|
|
31
|
-
readonly ids?: {
|
|
32
|
-
readonly firstGenCount: number;
|
|
33
|
-
readonly count: number;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.
|
|
38
|
-
* This value must *NOT* change without careful consideration to compatibility.
|
|
39
|
-
*/
|
|
40
|
-
export declare const initialClusterCapacity = 512;
|
|
41
|
-
export type IdCreationRangeWithStashedState = IdCreationRange & {
|
|
42
|
-
stashedState: SerializedIdCompressorWithOngoingSession;
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=0.0.1.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG;IAC7C,QAAQ,CAAC,uBAAuB,EAAE,sCAAsC,CAAC;CACzE,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG,sBAAsB,GAAG;IAC1E,QAAQ,CAAC,aAAa,EAAE,sCAAsC,CAAC;CAC/D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAAG,sBAAsB,GAAG;IAC/E,QAAQ,CAAC,cAAc,EAAE,sCAAsC,CAAC;CAChE,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAE;QACd,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;QAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;KACvB,CAAC;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,MAAM,MAAM,+BAA+B,GAAG,eAAe,GAAG;IAC/D,YAAY,EAAE,wCAAwC,CAAC;CACvD,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.initialClusterCapacity = void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.
|
|
10
|
-
* This value must *NOT* change without careful consideration to compatibility.
|
|
11
|
-
*/
|
|
12
|
-
exports.initialClusterCapacity = 512;
|
|
13
|
-
//# sourceMappingURL=0.0.1.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0.0.1.js","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsCH;;;GAGG;AACU,QAAA,sBAAsB,GAAG,GAAG,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { SessionId } from \"../identifiers\";\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport type SerializedIdCompressor = string & {\n\treadonly _serializedIdCompressor: \"8c73c57c-1cf4-4278-8915-6444cb4f6af5\";\n};\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport type SerializedIdCompressorWithNoSession = 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 type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor & {\n\treadonly _hasLocalState: \"1281acae-6d14-47e7-bc92-71c8ee0819cb\";\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.\n */\nexport interface IdCreationRange {\n\treadonly sessionId: SessionId;\n\treadonly ids?: {\n\t\treadonly firstGenCount: number;\n\t\treadonly count: number;\n\t};\n}\n\n/**\n * Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.\n * This value must *NOT* change without careful consideration to compatibility.\n */\nexport const initialClusterCapacity = 512;\n\nexport type IdCreationRangeWithStashedState = IdCreationRange & {\n\tstashedState: SerializedIdCompressorWithOngoingSession;\n};\n"]}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
export { IdCreationRange, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, IdCreationRangeWithStashedState, initialClusterCapacity, } from "./0.0.1";
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,EACxC,+BAA+B,EAC/B,sBAAsB,GACtB,MAAM,SAAS,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.initialClusterCapacity = void 0;
|
|
8
|
-
var _0_0_1_1 = require("./0.0.1");
|
|
9
|
-
Object.defineProperty(exports, "initialClusterCapacity", { enumerable: true, get: function () { return _0_0_1_1.initialClusterCapacity; } });
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kCAOiB;AADhB,gHAAA,sBAAsB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIdCreationRange,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tIdCreationRangeWithStashedState,\n\tinitialClusterCapacity,\n} from \"./0.0.1\";\n"]}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId } from "./identifiers";
|
|
7
|
-
import {
|
|
8
|
-
IdCreationRange,
|
|
9
|
-
SerializedIdCompressorWithNoSession,
|
|
10
|
-
SerializedIdCompressorWithOngoingSession,
|
|
11
|
-
} from "./persisted-types";
|
|
12
|
-
|
|
13
|
-
export interface IIdCompressorCore {
|
|
14
|
-
/**
|
|
15
|
-
* Returns a range of IDs created by this session in a format for sending to the server for finalizing.
|
|
16
|
-
* The range will include all IDs generated via calls to `generateCompressedId` since the last time this method was called.
|
|
17
|
-
* @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before
|
|
18
|
-
* it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.
|
|
19
|
-
*/
|
|
20
|
-
takeNextCreationRange(): IdCreationRange;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Finalizes the supplied range of IDs (which may be from either a remote or local session).
|
|
24
|
-
* @param range - the range of session-local IDs to finalize.
|
|
25
|
-
*/
|
|
26
|
-
finalizeCreationRange(range: IdCreationRange): void;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
30
|
-
* This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.
|
|
31
|
-
*/
|
|
32
|
-
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
36
|
-
* This only includes finalized state and is therefore suitable for use in summaries.
|
|
37
|
-
*/
|
|
38
|
-
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* A distributed UUID generator and compressor.
|
|
43
|
-
*
|
|
44
|
-
* Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple "sessions" (which can be distributed across the network),
|
|
45
|
-
* providing each session with the ability to map these UUIDs to `numbers`.
|
|
46
|
-
*
|
|
47
|
-
* A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API
|
|
48
|
-
* which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is
|
|
49
|
-
* created it is said to be created by the compressor's "local" session.
|
|
50
|
-
*
|
|
51
|
-
* For each stable ID created, two numeric IDs are provided by the compressor:
|
|
52
|
-
*
|
|
53
|
-
* 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
|
|
54
|
-
* be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only
|
|
55
|
-
* safely usable within the scope of the compressor that created it.
|
|
56
|
-
*
|
|
57
|
-
* 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing
|
|
58
|
-
* the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.
|
|
59
|
-
* Final IDs are known to and publicly usable by any compressor that has received them.
|
|
60
|
-
*
|
|
61
|
-
* Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed
|
|
62
|
-
* to map the UUIDs to the numbers.
|
|
63
|
-
*
|
|
64
|
-
* The following invariants are upheld by IdCompressor:
|
|
65
|
-
*
|
|
66
|
-
* 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.
|
|
67
|
-
*
|
|
68
|
-
* 2. Final IDs will always decompress to the same UUIDs.
|
|
69
|
-
*
|
|
70
|
-
* 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
|
|
71
|
-
* translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the
|
|
72
|
-
* same final ID.
|
|
73
|
-
*
|
|
74
|
-
* 4. A UUID will always compress into the same session-local ID for the lifetime of the session.
|
|
75
|
-
*
|
|
76
|
-
* Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*
|
|
77
|
-
* be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.
|
|
78
|
-
*
|
|
79
|
-
* Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This
|
|
80
|
-
* could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a
|
|
81
|
-
* 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
|
|
82
|
-
* produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the
|
|
83
|
-
* session-local IDs have been finalized, the compressor defines two "spaces" of IDs:
|
|
84
|
-
*
|
|
85
|
-
* 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
|
|
86
|
-
* will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after
|
|
87
|
-
* 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
|
|
88
|
-
* 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
|
|
89
|
-
* these IDs across compressor objects, as the local IDs are specific to the compressor that created them.
|
|
90
|
-
*
|
|
91
|
-
* 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
|
|
92
|
-
* 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
|
|
93
|
-
* 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
|
|
94
|
-
* out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a "more final form".
|
|
95
|
-
* Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially
|
|
96
|
-
* 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
|
|
97
|
-
* "local as possible".
|
|
98
|
-
*
|
|
99
|
-
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
100
|
-
* should use op-space IDs.
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
export interface IIdCompressor {
|
|
104
|
-
localSessionId: SessionId;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Generates a new compressed ID or returns an existing one.
|
|
108
|
-
* This should ONLY be called to generate IDs for local operations.
|
|
109
|
-
* @returns A new local ID in session space.
|
|
110
|
-
*/
|
|
111
|
-
generateCompressedId(): SessionSpaceCompressedId;
|
|
112
|
-
/**
|
|
113
|
-
* Normalizes a session space ID into op space.
|
|
114
|
-
* @param id - the local ID to normalize.
|
|
115
|
-
* @returns the ID in op space.
|
|
116
|
-
*/
|
|
117
|
-
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
118
|
-
/**
|
|
119
|
-
* Normalizes an ID into session space.
|
|
120
|
-
* @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding
|
|
121
|
-
* to `sessionId`.
|
|
122
|
-
* @param originSessionId - the session from which `id` originated
|
|
123
|
-
* @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
|
|
124
|
-
* 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
|
|
125
|
-
* range that contained it from the server.
|
|
126
|
-
*/
|
|
127
|
-
normalizeToSessionSpace(
|
|
128
|
-
id: OpSpaceCompressedId,
|
|
129
|
-
originSessionId: SessionId,
|
|
130
|
-
): SessionSpaceCompressedId;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Decompresses a previously compressed ID into a UUID.
|
|
134
|
-
* @param id - the compressed ID to be decompressed.
|
|
135
|
-
* @returns the UUID associated with the compressed ID. Fails if the ID was not generated by this compressor.
|
|
136
|
-
*/
|
|
137
|
-
decompress(id: SessionSpaceCompressedId): StableId;
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Recompresses a UUID.
|
|
141
|
-
* @param uncompressed - the UUID to recompress.
|
|
142
|
-
* @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
|
|
143
|
-
*/
|
|
144
|
-
recompress(uncompressed: StableId): SessionSpaceCompressedId;
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Attempts to recompresses a UUID.
|
|
148
|
-
* @param uncompressed - the UUID to recompress,
|
|
149
|
-
* @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.
|
|
150
|
-
*/
|
|
151
|
-
tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
|
|
152
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
8
|
-
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to
|
|
9
|
-
* the scope of the session (i.e. compressor) that produced them.
|
|
10
|
-
*/
|
|
11
|
-
export type SessionSpaceCompressedId = number & {
|
|
12
|
-
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A compressed ID that has been normalized into "op space".
|
|
17
|
-
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
|
|
18
|
-
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
19
|
-
*/
|
|
20
|
-
export type OpSpaceCompressedId = number & {
|
|
21
|
-
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
|
|
26
|
-
* A 128-bit Universally Unique IDentifier. Represented here
|
|
27
|
-
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
28
|
-
* where x is a lowercase hex digit.
|
|
29
|
-
*/
|
|
30
|
-
export type StableId = string & { readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a" };
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* A StableId which is suitable for use as a session identifier
|
|
34
|
-
*/
|
|
35
|
-
export type SessionId = StableId & { readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58" };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
IdCreationRange,
|
|
8
|
-
SerializedIdCompressor,
|
|
9
|
-
SerializedIdCompressorWithNoSession,
|
|
10
|
-
SerializedIdCompressorWithOngoingSession,
|
|
11
|
-
IdCreationRangeWithStashedState,
|
|
12
|
-
initialClusterCapacity,
|
|
13
|
-
} from "./persisted-types";
|
|
14
|
-
|
|
15
|
-
export { IIdCompressorCore, IIdCompressor } from "./idCompressor";
|
|
16
|
-
|
|
17
|
-
export { SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, StableId } from "./identifiers";
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { SessionId } from "../identifiers";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
10
|
-
*/
|
|
11
|
-
export type SerializedIdCompressor = string & {
|
|
12
|
-
readonly _serializedIdCompressor: "8c73c57c-1cf4-4278-8915-6444cb4f6af5";
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
17
|
-
*/
|
|
18
|
-
export type SerializedIdCompressorWithNoSession = SerializedIdCompressor & {
|
|
19
|
-
readonly _noLocalState: "3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb";
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
24
|
-
*/
|
|
25
|
-
export type SerializedIdCompressorWithOngoingSession = SerializedIdCompressor & {
|
|
26
|
-
readonly _hasLocalState: "1281acae-6d14-47e7-bc92-71c8ee0819cb";
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Data describing a range of session-local IDs (from a remote or local session).
|
|
31
|
-
*
|
|
32
|
-
* A range is composed of local IDs that were generated.
|
|
33
|
-
*/
|
|
34
|
-
export interface IdCreationRange {
|
|
35
|
-
readonly sessionId: SessionId;
|
|
36
|
-
readonly ids?: {
|
|
37
|
-
readonly firstGenCount: number;
|
|
38
|
-
readonly count: number;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Roughly equates to a minimum of 1M sessions before we start allocating 64 bit IDs.
|
|
44
|
-
* This value must *NOT* change without careful consideration to compatibility.
|
|
45
|
-
*/
|
|
46
|
-
export const initialClusterCapacity = 512;
|
|
47
|
-
|
|
48
|
-
export type IdCreationRangeWithStashedState = IdCreationRange & {
|
|
49
|
-
stashedState: SerializedIdCompressorWithOngoingSession;
|
|
50
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
IdCreationRange,
|
|
8
|
-
SerializedIdCompressor,
|
|
9
|
-
SerializedIdCompressorWithNoSession,
|
|
10
|
-
SerializedIdCompressorWithOngoingSession,
|
|
11
|
-
IdCreationRangeWithStashedState,
|
|
12
|
-
initialClusterCapacity,
|
|
13
|
-
} from "./0.0.1";
|