@fluidframework/runtime-definitions 2.0.0-dev.7.4.0.217212 → 2.0.0-dev.7.4.0.221926

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/api-extractor.json +0 -3
  3. package/api-report/runtime-definitions.api.md +66 -99
  4. package/dist/attribution.d.ts +4 -4
  5. package/dist/attribution.js.map +1 -1
  6. package/dist/dataStoreContext.d.ts +13 -13
  7. package/dist/dataStoreContext.d.ts.map +1 -1
  8. package/dist/dataStoreContext.js +2 -2
  9. package/dist/dataStoreContext.js.map +1 -1
  10. package/dist/dataStoreFactory.d.ts +3 -3
  11. package/dist/dataStoreFactory.js +1 -1
  12. package/dist/dataStoreFactory.js.map +1 -1
  13. package/dist/dataStoreRegistry.d.ts +6 -6
  14. package/dist/dataStoreRegistry.js +1 -1
  15. package/dist/dataStoreRegistry.js.map +1 -1
  16. package/dist/garbageCollection.d.ts +2 -2
  17. package/dist/garbageCollection.js.map +1 -1
  18. package/dist/index.d.ts +49 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +11 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/protocol.d.ts +1 -1
  23. package/dist/protocol.js.map +1 -1
  24. package/dist/runtime-definitions-alpha.d.ts +939 -93
  25. package/dist/runtime-definitions-beta.d.ts +31 -0
  26. package/dist/runtime-definitions-public.d.ts +31 -0
  27. package/dist/runtime-definitions-untrimmed.d.ts +66 -248
  28. package/dist/summary.d.ts +13 -13
  29. package/dist/summary.js +1 -1
  30. package/dist/summary.js.map +1 -1
  31. package/lib/runtime-definitions-alpha.d.ts +939 -93
  32. package/lib/runtime-definitions-beta.d.ts +31 -0
  33. package/lib/runtime-definitions-public.d.ts +31 -0
  34. package/lib/runtime-definitions-untrimmed.d.ts +66 -248
  35. package/package.json +7 -4
  36. package/src/attribution.ts +4 -4
  37. package/src/dataStoreContext.ts +13 -13
  38. package/src/dataStoreFactory.ts +3 -3
  39. package/src/dataStoreRegistry.ts +6 -6
  40. package/src/garbageCollection.ts +2 -2
  41. package/src/index.ts +46 -6
  42. package/src/protocol.ts +1 -1
  43. package/src/summary.ts +13 -13
  44. package/dist/id-compressor/idCompressor.d.ts +0 -139
  45. package/dist/id-compressor/idCompressor.d.ts.map +0 -1
  46. package/dist/id-compressor/idCompressor.js +0 -7
  47. package/dist/id-compressor/idCompressor.js.map +0 -1
  48. package/dist/id-compressor/identifiers.d.ts +0 -40
  49. package/dist/id-compressor/identifiers.d.ts.map +0 -1
  50. package/dist/id-compressor/identifiers.js +0 -7
  51. package/dist/id-compressor/identifiers.js.map +0 -1
  52. package/dist/id-compressor/index.d.ts +0 -8
  53. package/dist/id-compressor/index.d.ts.map +0 -1
  54. package/dist/id-compressor/index.js +0 -10
  55. package/dist/id-compressor/index.js.map +0 -1
  56. package/dist/id-compressor/persisted-types/0.0.1.d.ts +0 -46
  57. package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +0 -1
  58. package/dist/id-compressor/persisted-types/0.0.1.js +0 -14
  59. package/dist/id-compressor/persisted-types/0.0.1.js.map +0 -1
  60. package/dist/id-compressor/persisted-types/index.d.ts +0 -6
  61. package/dist/id-compressor/persisted-types/index.d.ts.map +0 -1
  62. package/dist/id-compressor/persisted-types/index.js +0 -10
  63. package/dist/id-compressor/persisted-types/index.js.map +0 -1
  64. package/src/id-compressor/idCompressor.ts +0 -155
  65. package/src/id-compressor/identifiers.ts +0 -39
  66. package/src/id-compressor/index.ts +0 -16
  67. package/src/id-compressor/persisted-types/0.0.1.ts +0 -51
  68. package/src/id-compressor/persisted-types/README.md +0 -3
  69. package/src/id-compressor/persisted-types/index.ts +0 -12
@@ -8,7 +8,7 @@ import type { IUser } from "@fluidframework/protocol-definitions";
8
8
  /**
9
9
  * AttributionKey representing a reference to some op in the op stream.
10
10
  * Content associated with this key aligns with content modified by that op.
11
- * @internal
11
+ * @alpha
12
12
  */
13
13
  export interface OpAttributionKey {
14
14
  /**
@@ -32,7 +32,7 @@ export interface OpAttributionKey {
32
32
  * is currently unsupported, as applications can effectively modify content anonymously while detached.
33
33
  * The runtime has no mechanism for reliably obtaining the user. It would be reasonable to start supporting
34
34
  * this functionality if the host provided additional context to their attributor or attach calls.
35
- * @internal
35
+ * @alpha
36
36
  */
37
37
  export interface DetachedAttributionKey {
38
38
  type: "detached";
@@ -50,7 +50,7 @@ export interface DetachedAttributionKey {
50
50
 
51
51
  /**
52
52
  * AttributionKey associated with content that has been made locally but not yet acked by the server.
53
- * @internal
53
+ * @alpha
54
54
  */
55
55
  export interface LocalAttributionKey {
56
56
  type: "local";
@@ -58,7 +58,7 @@ export interface LocalAttributionKey {
58
58
 
59
59
  /**
60
60
  * Can be indexed into the ContainerRuntime in order to retrieve {@link AttributionInfo}.
61
- * @internal
61
+ * @alpha
62
62
  */
63
63
  export type AttributionKey = OpAttributionKey | DetachedAttributionKey | LocalAttributionKey;
64
64
 
@@ -31,6 +31,7 @@ import {
31
31
  ISequencedDocumentMessage,
32
32
  ISnapshotTree,
33
33
  } from "@fluidframework/protocol-definitions";
34
+ import { IIdCompressor } from "@fluidframework/id-compressor";
34
35
  import { IProvideFluidDataStoreFactory } from "./dataStoreFactory";
35
36
  import { IProvideFluidDataStoreRegistry } from "./dataStoreRegistry";
36
37
  import { IGarbageCollectionData, IGarbageCollectionDetailsBase } from "./garbageCollection";
@@ -42,11 +43,10 @@ import {
42
43
  ITelemetryContext,
43
44
  SummarizeInternalFn,
44
45
  } from "./summary";
45
- import { IIdCompressor } from "./id-compressor";
46
46
 
47
47
  /**
48
48
  * Runtime flush mode handling
49
- * @internal
49
+ * @alpha
50
50
  */
51
51
  export enum FlushMode {
52
52
  /**
@@ -80,7 +80,7 @@ export enum FlushModeExperimental {
80
80
  /**
81
81
  * This tells the visibility state of a Fluid object. It basically tracks whether the object is not visible, visible
82
82
  * locally within the container only or visible globally to all clients.
83
- * @internal
83
+ * @alpha
84
84
  */
85
85
  export const VisibilityState = {
86
86
  /**
@@ -107,12 +107,12 @@ export const VisibilityState = {
107
107
  GloballyVisible: "GloballyVisible",
108
108
  };
109
109
  /**
110
- * @internal
110
+ * @alpha
111
111
  */
112
112
  export type VisibilityState = (typeof VisibilityState)[keyof typeof VisibilityState];
113
113
 
114
114
  /**
115
- * @internal
115
+ * @alpha
116
116
  */
117
117
  export interface IContainerRuntimeBaseEvents extends IEvent {
118
118
  (event: "batchBegin", listener: (op: ISequencedDocumentMessage) => void);
@@ -133,7 +133,7 @@ export interface IContainerRuntimeBaseEvents extends IEvent {
133
133
  * the `IContainerRuntime.getAliasedDataStoreEntryPoint` function. The current datastore should be discarded
134
134
  * and will be garbage collected. The current datastore cannot be aliased to a different value.
135
135
  * 'AlreadyAliased' - the datastore has already been previously bound to another alias name.
136
- * @internal
136
+ * @alpha
137
137
  */
138
138
  export type AliasResult = "Success" | "Conflict" | "AlreadyAliased";
139
139
 
@@ -142,7 +142,7 @@ export type AliasResult = "Success" | "Conflict" | "AlreadyAliased";
142
142
  * - Handle to the data store's entryPoint
143
143
  * - Fluid router for the data store
144
144
  * - Can be assigned an alias
145
- * @internal
145
+ * @alpha
146
146
  */
147
147
  export interface IDataStore {
148
148
  /**
@@ -197,7 +197,7 @@ export interface IDataStore {
197
197
  /**
198
198
  * A reduced set of functionality of IContainerRuntime that a data store context/data store runtime will need
199
199
  * TODO: this should be merged into IFluidDataStoreContext
200
- * @internal
200
+ * @alpha
201
201
  */
202
202
  export interface IContainerRuntimeBase extends IEventProvider<IContainerRuntimeBaseEvents> {
203
203
  readonly logger: ITelemetryBaseLogger;
@@ -277,7 +277,7 @@ export interface IContainerRuntimeBase extends IEventProvider<IContainerRuntimeB
277
277
  *
278
278
  * Functionality include attach, snapshot, op/signal processing, request routes, expose an entryPoint,
279
279
  * and connection state notifications
280
- * @internal
280
+ * @alpha
281
281
  */
282
282
  export interface IFluidDataStoreChannel extends IDisposable {
283
283
  readonly id: string;
@@ -384,7 +384,7 @@ export interface IFluidDataStoreChannel extends IDisposable {
384
384
  }
385
385
 
386
386
  /**
387
- * @internal
387
+ * @alpha
388
388
  */
389
389
  export type CreateChildSummarizerNodeFn = (
390
390
  summarizeInternal: SummarizeInternalFn,
@@ -396,7 +396,7 @@ export type CreateChildSummarizerNodeFn = (
396
396
  ) => ISummarizerNodeWithGC;
397
397
 
398
398
  /**
399
- * @internal
399
+ * @alpha
400
400
  */
401
401
  export interface IFluidDataStoreContextEvents extends IEvent {
402
402
  (event: "attaching" | "attached", listener: () => void);
@@ -405,7 +405,7 @@ export interface IFluidDataStoreContextEvents extends IEvent {
405
405
  /**
406
406
  * Represents the context for the data store. It is used by the data store runtime to
407
407
  * get information and call functionality to the container.
408
- * @internal
408
+ * @alpha
409
409
  */
410
410
  export interface IFluidDataStoreContext
411
411
  extends IEventProvider<IFluidDataStoreContextEvents>,
@@ -542,7 +542,7 @@ export interface IFluidDataStoreContext
542
542
  }
543
543
 
544
544
  /**
545
- * @internal
545
+ * @alpha
546
546
  */
547
547
  export interface IFluidDataStoreContextDetached extends IFluidDataStoreContext {
548
548
  /**
@@ -6,12 +6,12 @@
6
6
  import { IFluidDataStoreContext, IFluidDataStoreChannel } from "./dataStoreContext";
7
7
 
8
8
  /**
9
- * @internal
9
+ * @alpha
10
10
  */
11
11
  export const IFluidDataStoreFactory: keyof IProvideFluidDataStoreFactory = "IFluidDataStoreFactory";
12
12
 
13
13
  /**
14
- * @internal
14
+ * @alpha
15
15
  */
16
16
  export interface IProvideFluidDataStoreFactory {
17
17
  readonly IFluidDataStoreFactory: IFluidDataStoreFactory;
@@ -20,7 +20,7 @@ export interface IProvideFluidDataStoreFactory {
20
20
  /**
21
21
  * IFluidDataStoreFactory create data stores. It is associated with an identifier (its `type` member)
22
22
  * and usually provided to consumers using this mapping through a data store registry.
23
- * @internal
23
+ * @alpha
24
24
  */
25
25
  export interface IFluidDataStoreFactory extends IProvideFluidDataStoreFactory {
26
26
  /**
@@ -8,7 +8,7 @@ import { IProvideFluidDataStoreFactory } from "./dataStoreFactory";
8
8
  /**
9
9
  * A single registry entry that may be used to create data stores
10
10
  * It has to have either factory or registry, or both.
11
- * @internal
11
+ * @alpha
12
12
  */
13
13
  export type FluidDataStoreRegistryEntry = Readonly<
14
14
  Partial<IProvideFluidDataStoreRegistry & IProvideFluidDataStoreFactory>
@@ -16,23 +16,23 @@ export type FluidDataStoreRegistryEntry = Readonly<
16
16
  /**
17
17
  * An associated pair of an identifier and registry entry. Registry entries
18
18
  * may be dynamically loaded.
19
- * @internal
19
+ * @alpha
20
20
  */
21
21
  export type NamedFluidDataStoreRegistryEntry = [string, Promise<FluidDataStoreRegistryEntry>];
22
22
  /**
23
23
  * An iterable identifier/registry entry pair list
24
- * @internal
24
+ * @alpha
25
25
  */
26
26
  export type NamedFluidDataStoreRegistryEntries = Iterable<NamedFluidDataStoreRegistryEntry>;
27
27
 
28
28
  /**
29
- * @internal
29
+ * @alpha
30
30
  */
31
31
  export const IFluidDataStoreRegistry: keyof IProvideFluidDataStoreRegistry =
32
32
  "IFluidDataStoreRegistry";
33
33
 
34
34
  /**
35
- * @internal
35
+ * @alpha
36
36
  */
37
37
  export interface IProvideFluidDataStoreRegistry {
38
38
  readonly IFluidDataStoreRegistry: IFluidDataStoreRegistry;
@@ -41,7 +41,7 @@ export interface IProvideFluidDataStoreRegistry {
41
41
  /**
42
42
  * An association of identifiers to data store registry entries, where the
43
43
  * entries can be used to create data stores.
44
- * @internal
44
+ * @alpha
45
45
  */
46
46
  export interface IFluidDataStoreRegistry extends IProvideFluidDataStoreRegistry {
47
47
  get(name: string): Promise<FluidDataStoreRegistryEntry | undefined>;
@@ -31,7 +31,7 @@ export const gcDeletedBlobKey = "__deletedNodes";
31
31
  /**
32
32
  * Garbage collection data returned by nodes in a Container.
33
33
  * Used for running GC in the Container.
34
- * @internal
34
+ * @alpha
35
35
  */
36
36
  export interface IGarbageCollectionData {
37
37
  /**
@@ -42,7 +42,7 @@ export interface IGarbageCollectionData {
42
42
 
43
43
  /**
44
44
  * GC details provided to each node during creation.
45
- * @internal
45
+ * @alpha
46
46
  */
47
47
  export interface IGarbageCollectionDetailsBase {
48
48
  /**
package/src/index.ts CHANGED
@@ -65,16 +65,56 @@ export {
65
65
  SummarizeInternalFn,
66
66
  totalBlobSizePropertyName,
67
67
  } from "./summary";
68
+
69
+ // Re-exports for backwards compatibility.
70
+ // Will be removed in the future.
68
71
  export {
69
- IIdCompressorCore,
72
+ /**
73
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
74
+ */
75
+ IdCompressor,
76
+ /**
77
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
78
+ */
70
79
  IIdCompressor,
80
+ /**
81
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
82
+ */
83
+ IIdCompressorCore,
84
+ /**
85
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
86
+ */
87
+ IdCreationRange,
88
+ /**
89
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
90
+ */
91
+ OpSpaceCompressedId,
92
+ /**
93
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
94
+ */
71
95
  SerializedIdCompressor,
72
- SerializedIdCompressorWithOngoingSession,
96
+ /**
97
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
98
+ */
73
99
  SerializedIdCompressorWithNoSession,
74
- SessionSpaceCompressedId,
75
- OpSpaceCompressedId,
100
+ /**
101
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
102
+ */
103
+ SerializedIdCompressorWithOngoingSession,
104
+ /**
105
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
106
+ */
76
107
  SessionId,
108
+ /**
109
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
110
+ */
111
+ SessionSpaceCompressedId,
112
+ /**
113
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
114
+ */
77
115
  StableId,
78
- IdCreationRange,
116
+ /**
117
+ * @deprecated Import from `@fluidframework/id-compressor` instead.
118
+ */
79
119
  initialClusterCapacity,
80
- } from "./id-compressor";
120
+ } from "@fluidframework/id-compressor";
package/src/protocol.ts CHANGED
@@ -46,7 +46,7 @@ export interface ISignalEnvelope {
46
46
 
47
47
  /**
48
48
  * Represents ISignalMessage with its type.
49
- * @internal
49
+ * @alpha
50
50
  */
51
51
  export interface IInboundSignalMessage extends ISignalMessage {
52
52
  type: string;
package/src/summary.ts CHANGED
@@ -15,7 +15,7 @@ import { IGarbageCollectionData, IGarbageCollectionDetailsBase } from "./garbage
15
15
 
16
16
  /**
17
17
  * Contains the aggregation data from a Tree/Subtree.
18
- * @internal
18
+ * @alpha
19
19
  */
20
20
  export interface ISummaryStats {
21
21
  treeNodeCount: number;
@@ -31,7 +31,7 @@ export interface ISummaryStats {
31
31
  * each of its DDS.
32
32
  * Any component that implements IChannelContext, IFluidDataStoreChannel or extends SharedObject
33
33
  * will be taking part of the summarization process.
34
- * @internal
34
+ * @alpha
35
35
  */
36
36
  export interface ISummaryTreeWithStats {
37
37
  /**
@@ -47,7 +47,7 @@ export interface ISummaryTreeWithStats {
47
47
 
48
48
  /**
49
49
  * Represents a summary at a current sequence number.
50
- * @internal
50
+ * @alpha
51
51
  */
52
52
  export interface ISummarizeResult {
53
53
  stats: ISummaryStats;
@@ -68,7 +68,7 @@ export interface ISummarizeResult {
68
68
  * ...
69
69
  * "path1":
70
70
  * ```
71
- * @internal
71
+ * @alpha
72
72
  */
73
73
  export interface ISummarizeInternalResult extends ISummarizeResult {
74
74
  id: string;
@@ -81,7 +81,7 @@ export interface ISummarizeInternalResult extends ISummarizeResult {
81
81
  /**
82
82
  * @experimental - Can be deleted/changed at any time
83
83
  * Contains the necessary information to allow DDSes to do incremental summaries
84
- * @internal
84
+ * @alpha
85
85
  */
86
86
  export interface IExperimentalIncrementalSummaryContext {
87
87
  /**
@@ -107,7 +107,7 @@ export interface IExperimentalIncrementalSummaryContext {
107
107
  }
108
108
 
109
109
  /**
110
- * @internal
110
+ * @alpha
111
111
  */
112
112
  export type SummarizeInternalFn = (
113
113
  fullTree: boolean,
@@ -117,7 +117,7 @@ export type SummarizeInternalFn = (
117
117
  ) => Promise<ISummarizeInternalResult>;
118
118
 
119
119
  /**
120
- * @internal
120
+ * @alpha
121
121
  */
122
122
  export interface ISummarizerNodeConfig {
123
123
  /**
@@ -138,7 +138,7 @@ export interface ISummarizerNodeConfig {
138
138
  }
139
139
 
140
140
  /**
141
- * @internal
141
+ * @alpha
142
142
  */
143
143
  export interface ISummarizerNodeConfigWithGC extends ISummarizerNodeConfig {
144
144
  /**
@@ -149,7 +149,7 @@ export interface ISummarizerNodeConfigWithGC extends ISummarizerNodeConfig {
149
149
  }
150
150
 
151
151
  /**
152
- * @internal
152
+ * @alpha
153
153
  */
154
154
  export enum CreateSummarizerNodeSource {
155
155
  FromSummary,
@@ -157,7 +157,7 @@ export enum CreateSummarizerNodeSource {
157
157
  Local,
158
158
  }
159
159
  /**
160
- * @internal
160
+ * @alpha
161
161
  */
162
162
  export type CreateChildSummarizerNodeParam =
163
163
  | {
@@ -173,7 +173,7 @@ export type CreateChildSummarizerNodeParam =
173
173
  };
174
174
 
175
175
  /**
176
- * @internal
176
+ * @alpha
177
177
  */
178
178
  export interface ISummarizerNode {
179
179
  /**
@@ -263,7 +263,7 @@ export interface ISummarizerNode {
263
263
  * `isReferenced`: This tells whether this node is referenced in the document or not.
264
264
  *
265
265
  * `updateUsedRoutes`: Used to notify this node of routes that are currently in use in it.
266
- * @internal
266
+ * @alpha
267
267
  */
268
268
  export interface ISummarizerNodeWithGC extends ISummarizerNode {
269
269
  createChild(
@@ -330,7 +330,7 @@ export const channelsTreeName = ".channels";
330
330
  /**
331
331
  * Contains telemetry data relevant to summarization workflows.
332
332
  * This object is expected to be modified directly by various summarize methods.
333
- * @internal
333
+ * @alpha
334
334
  */
335
335
  export interface ITelemetryContext {
336
336
  /**
@@ -1,139 +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
- /**
8
- * @internal
9
- */
10
- export interface IIdCompressorCore {
11
- /**
12
- * Returns a range of IDs created by this session in a format for sending to the server for finalizing.
13
- * The range will include all IDs generated via calls to `generateCompressedId` since the last time this method was called.
14
- * @returns the range of IDs, which may be empty. This range must be sent to the server for ordering before
15
- * it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.
16
- */
17
- takeNextCreationRange(): IdCreationRange;
18
- /**
19
- * Finalizes the supplied range of IDs (which may be from either a remote or local session).
20
- * @param range - the range of session-local IDs to finalize.
21
- */
22
- finalizeCreationRange(range: IdCreationRange): void;
23
- /**
24
- * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
25
- * This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.
26
- */
27
- serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
28
- /**
29
- * Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
30
- * This only includes finalized state and is therefore suitable for use in summaries.
31
- */
32
- serialize(withSession: false): SerializedIdCompressorWithNoSession;
33
- }
34
- /**
35
- * A distributed UUID generator and compressor.
36
- *
37
- * Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple "sessions" (which can be distributed across the network),
38
- * providing each session with the ability to map these UUIDs to `numbers`.
39
- *
40
- * A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API
41
- * which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is
42
- * created it is said to be created by the compressor's "local" session.
43
- *
44
- * For each stable ID created, two numeric IDs are provided by the compressor:
45
- *
46
- * 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
47
- * be serialized for offline usage). Available as soon as the stable ID is allocated. These IDs are session-unique and are thus only
48
- * safely usable within the scope of the compressor that created it.
49
- *
50
- * 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing
51
- * the corresponding session-local ID is totally ordered (via consensus) with respect to other sessions' allocations.
52
- * Final IDs are known to and publicly usable by any compressor that has received them.
53
- *
54
- * Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed
55
- * to map the UUIDs to the numbers.
56
- *
57
- * The following invariants are upheld by IdCompressor:
58
- *
59
- * 1. Session-local IDs will always decompress to the same UUIDs for the lifetime of the session.
60
- *
61
- * 2. Final IDs will always decompress to the same UUIDs.
62
- *
63
- * 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
64
- * translated by the compressor into the corresponding final ID. For any given session-local ID, this translation will always yield the
65
- * same final ID.
66
- *
67
- * 4. A UUID will always compress into the same session-local ID for the lifetime of the session.
68
- *
69
- * Session-local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*
70
- * be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.
71
- *
72
- * Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This
73
- * could make reasoning about equality of those two forms difficult. For example, if a cache is keyed off of a
74
- * 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
75
- * produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the
76
- * session-local IDs have been finalized, the compressor defines two "spaces" of IDs:
77
- *
78
- * 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
79
- * will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after
80
- * 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
81
- * 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
82
- * these IDs across compressor objects, as the local IDs are specific to the compressor that created them.
83
- *
84
- * 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
85
- * 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
86
- * 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
87
- * out of Op space over time, namely, when a session-local ID in this space becomes finalized, and thereafter has a "more final form".
88
- * Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially
89
- * 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
90
- * "local as possible".
91
- *
92
- * These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
93
- * should use op-space IDs.
94
- * @internal
95
- */
96
- export interface IIdCompressor {
97
- localSessionId: SessionId;
98
- /**
99
- * Generates a new compressed ID or returns an existing one.
100
- * This should ONLY be called to generate IDs for local operations.
101
- * @returns A new local ID in session space.
102
- */
103
- generateCompressedId(): SessionSpaceCompressedId;
104
- /**
105
- * Normalizes a session space ID into op space.
106
- * @param id - the local ID to normalize.
107
- * @returns the ID in op space.
108
- */
109
- normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
110
- /**
111
- * Normalizes an ID into session space.
112
- * @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding
113
- * to `sessionId`.
114
- * @param originSessionId - the session from which `id` originated
115
- * @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
116
- * 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
117
- * range that contained it from the server.
118
- */
119
- normalizeToSessionSpace(id: OpSpaceCompressedId, originSessionId: SessionId): SessionSpaceCompressedId;
120
- /**
121
- * Decompresses a previously compressed ID into a UUID.
122
- * @param id - the compressed ID to be decompressed.
123
- * @returns the UUID associated with the compressed ID. Fails if the ID was not generated by this compressor.
124
- */
125
- decompress(id: SessionSpaceCompressedId): StableId;
126
- /**
127
- * Recompresses a UUID.
128
- * @param uncompressed - the UUID to recompress.
129
- * @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
130
- */
131
- recompress(uncompressed: StableId): SessionSpaceCompressedId;
132
- /**
133
- * Attempts to recompresses a UUID.
134
- * @param uncompressed - the UUID to recompress,
135
- * @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.
136
- */
137
- tryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;
138
- }
139
- //# 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;;GAEG;AACH,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,7 +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
- //# sourceMappingURL=idCompressor.js.map
@@ -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\n/**\n * @internal\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 * @internal\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,40 +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
- * @internal
10
- */
11
- export type SessionSpaceCompressedId = number & {
12
- readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
13
- };
14
- /**
15
- * A compressed ID that has been normalized into "op space".
16
- * Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require less normalizing when
17
- * received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
18
- * @internal
19
- */
20
- export type OpSpaceCompressedId = number & {
21
- readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
22
- };
23
- /**
24
- * A version 4, variant 1 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
25
- * A 128-bit Universally Unique IDentifier. Represented here
26
- * with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
27
- * where x is a lowercase hex digit.
28
- * @internal
29
- */
30
- export type StableId = string & {
31
- readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a";
32
- };
33
- /**
34
- * A StableId which is suitable for use as a session identifier
35
- * @internal
36
- */
37
- export type SessionId = StableId & {
38
- readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
39
- };
40
- //# 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;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,GAAG;IAC/C,QAAQ,CAAC,aAAa,EAAE,sCAAsC,CAAC;CAC/D,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG;IAC1C,QAAQ,CAAC,YAAY,EAAE,sCAAsC,CAAC;CAC9D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,sCAAsC,CAAA;CAAE,CAAC;AAE9F;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,sCAAsC,CAAA;CAAE,CAAC"}
@@ -1,7 +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
- //# sourceMappingURL=identifiers.js.map
@@ -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 * @internal\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 * @internal\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 * @internal\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 * @internal\n */\nexport type SessionId = StableId & { readonly SessionId: \"4498f850-e14e-4be9-8db0-89ec00997e58\" };\n"]}