@fluidframework/runtime-definitions 2.0.0-internal.4.1.2 → 2.0.0-internal.4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dataStoreContext.d.ts +2 -0
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/id-compressor/idCompressor.d.ts +154 -0
- package/dist/id-compressor/idCompressor.d.ts.map +1 -0
- package/dist/id-compressor/idCompressor.js +7 -0
- package/dist/id-compressor/idCompressor.js.map +1 -0
- package/dist/id-compressor/identifiers.d.ts +77 -0
- package/dist/id-compressor/identifiers.d.ts.map +1 -0
- package/dist/id-compressor/identifiers.js +7 -0
- package/dist/id-compressor/identifiers.js.map +1 -0
- package/dist/id-compressor/index.d.ts +8 -0
- package/dist/id-compressor/index.d.ts.map +1 -0
- package/dist/id-compressor/index.js +7 -0
- package/dist/id-compressor/index.js.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts +162 -0
- package/dist/id-compressor/persisted-types/0.0.1.d.ts.map +1 -0
- package/dist/id-compressor/persisted-types/0.0.1.js +7 -0
- package/dist/id-compressor/persisted-types/0.0.1.js.map +1 -0
- package/dist/id-compressor/persisted-types/index.d.ts +6 -0
- package/dist/id-compressor/persisted-types/index.d.ts.map +1 -0
- package/dist/id-compressor/persisted-types/index.js +7 -0
- package/dist/id-compressor/persisted-types/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/dataStoreContext.ts +2 -0
- package/src/id-compressor/idCompressor.ts +179 -0
- package/src/id-compressor/identifiers.ts +83 -0
- package/src/id-compressor/index.ts +34 -0
- package/src/id-compressor/persisted-types/0.0.1.ts +191 -0
- package/src/id-compressor/persisted-types/README.md +3 -0
- package/src/id-compressor/persisted-types/index.ts +20 -0
- package/src/index.ts +26 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0.0.1.d.ts","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0.0.1.js","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/0.0.1.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tFinalCompressedId,\n\tLocalCompressedId,\n\tOpSpaceCompressedId,\n\tSessionId,\n} from \"../identifiers\";\n\n/**\n * A serialized ID allocation session for an `IdCompressor`.\n */\nexport type SerializedSessionData = readonly [\n\t/**\n\t * The ID of the session.\n\t */\n\tsessionId: SessionId,\n];\n\nexport type SerializedClusterOverrides = readonly [\n\t/** The overridden final ID, represented as an index into the cluster's ID range */\n\toverriddenFinalIndex: number, // A cluster with base UUID '...beef' and an `overriddenFinalIndex` of 3 would correspond to '...bef2'\n\t/** The override string */\n\toverride: string,\n\t/** The first ID that was finalized and associated with this override, set only if different than the `overriddenFinalIndex` */\n\toverriddenId?: FinalCompressedId,\n][];\n\n/**\n * A serialized final ID cluster.\n */\nexport type SerializedCluster = readonly [\n\t/**\n\t * Index into the serialized sessions array. Can be converted into a baseUuid via its order in `clusters`.\n\t * If negative, then this cluster was created by the local session.\n\t */\n\tsessionIndex: number,\n\n\t/**\n\t * The capacity of the cluster.\n\t */\n\tcapacity: number,\n\n\t/**\n\t * The number of IDs in the cluster. Omitted if count === capacity.\n\t * --OR--\n\t * The overrides in this cluster. Omitted if no overrides exist in the cluster.\n\t */\n\tcountOrOverrides?: number | SerializedClusterOverrides,\n\n\t/**\n\t * Overrides in this cluster. Omitted if no overrides exist in the cluster.\n\t */\n\toverrides?: SerializedClusterOverrides,\n];\n\nexport type SerializedLocalOverrides = readonly (readonly [LocalCompressedId, string])[];\n\nexport interface SerializedLocalState {\n\t/**\n\t * The total number of local IDs created by this session\n\t */\n\treadonly localIdCount: number;\n\t/**\n\t * Overrides generated by this session. Omitted if no local overrides exist in the session.\n\t */\n\treadonly overrides?: SerializedLocalOverrides;\n\n\t/**\n\t * The most recent local ID in a range returned by `takeNextCreationRange`.\n\t */\n\treadonly lastTakenLocalId: LocalCompressedId | undefined;\n\n\t/**\n\t * Serialized table for normalizing IDs made by the local session.\n\t */\n\treadonly sessionNormalizer: SerializedSessionIdNormalizer;\n}\n\n/**\n * Serialized table for normalizing IDs made by the local session.\n */\nexport interface SerializedSessionIdNormalizer {\n\treadonly nextLocalId: LocalCompressedId;\n\treadonly localRanges: readonly (readonly [\n\t\tfirstLocal: LocalCompressedId,\n\t\tlastLocal: LocalCompressedId,\n\t\tfinalRanges?: readonly (readonly [\n\t\t\talignedLocal: LocalCompressedId,\n\t\t\tfirstFinal: FinalCompressedId,\n\t\t\tlastFinal: FinalCompressedId,\n\t\t])[],\n\t])[];\n}\n\n/**\n * The minimal required contents of a serialized IdCompressor.\n */\nexport interface VersionedSerializedIdCompressor {\n\treadonly _versionedSerializedIdCompressor: \"8c73c57c-1cf4-4278-8915-6444cb4f6af5\";\n\treadonly version: string;\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressor extends VersionedSerializedIdCompressor {\n\t/** The cluster capacity of this compressor */\n\treadonly clusterCapacity: number;\n\t/** All sessions except the local session. */\n\treadonly sessions: readonly SerializedSessionData[];\n\t/** All clusters in the compressor in the order they were created. */\n\treadonly clusters: readonly SerializedCluster[];\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressorWithNoSession extends SerializedIdCompressor {\n\treadonly _noLocalState: \"3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb\";\n}\n\n/**\n * The serialized contents of an IdCompressor, suitable for persistence in a summary.\n */\nexport interface SerializedIdCompressorWithOngoingSession extends SerializedIdCompressor {\n\treadonly _hasLocalState: \"1281acae-6d14-47e7-bc92-71c8ee0819cb\";\n\t/** The session ID of the local session, by index into `sessions`. */\n\treadonly localSessionIndex: number;\n\t/** This is only present if the local session made any IDs. */\n\treadonly localState?: SerializedLocalState;\n}\n\n/**\n * Data describing a range of session-local IDs (from a remote or local session).\n *\n * A range is composed of local IDs that were generated. Some of these may have overrides.\n *\n * @example\n * Suppose an IdCompressor generated a sequence of local IDs as follows:\n * ```\n * compressor.generateLocalId()\n * compressor.generateLocalId('0093cf29-9454-4034-8940-33b1077b41c3')\n * compressor.generateLocalId()\n * compressor.generateLocalId('0ed545f8-e97e-4dc1-acf9-c4a783258bdf')\n * compressor.generateLocalId()\n * compressor.generateLocalId()\n * compressor.takeNextCreationRange()\n * ```\n * This would result in the following range:\n * ```\n * {\n * first: localId1,\n * last: localId6,\n * overrides: [[localId2, '0093cf29-9454-4034-8940-33b1077b41c3'], [localId4, '0ed545f8-e97e-4dc1-acf9-c4a783258bdf']]\n * }\n * ```\n */\nexport interface IdCreationRange {\n\treadonly sessionId: SessionId;\n\treadonly ids?: IdCreationRange.Ids;\n}\n\nexport type UnackedLocalId = LocalCompressedId & OpSpaceCompressedId;\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace IdCreationRange {\n\texport type Ids =\n\t\t| {\n\t\t\t\treadonly first: UnackedLocalId;\n\t\t\t\treadonly last: UnackedLocalId;\n\t\t }\n\t\t| ({\n\t\t\t\treadonly first?: UnackedLocalId;\n\t\t\t\treadonly last?: UnackedLocalId;\n\t\t } & HasOverrides);\n\n\texport interface HasOverrides {\n\t\treadonly overrides: Overrides;\n\t}\n\n\texport type Override = readonly [id: UnackedLocalId, override: string];\n\texport type Overrides = readonly [Override, ...Override[]];\n}\n\nexport type IdCreationRangeWithStashedState = IdCreationRange & {\n\tstashedState: SerializedIdCompressorWithOngoingSession;\n};\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export { IdCreationRange, SerializedCluster, SerializedClusterOverrides, SerializedIdCompressor, SerializedIdCompressorWithNoSession, SerializedIdCompressorWithOngoingSession, SerializedLocalOverrides, SerializedLocalState, SerializedSessionData, SerializedSessionIdNormalizer, UnackedLocalId, VersionedSerializedIdCompressor, IdCreationRangeWithStashedState, } from "./0.0.1";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,mCAAmC,EACnC,wCAAwC,EACxC,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACd,+BAA+B,EAC/B,+BAA+B,GAC/B,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/id-compressor/persisted-types/index.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tIdCreationRange,\n\tSerializedCluster,\n\tSerializedClusterOverrides,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedLocalOverrides,\n\tSerializedLocalState,\n\tSerializedSessionData,\n\tSerializedSessionIdNormalizer,\n\tUnackedLocalId,\n\tVersionedSerializedIdCompressor,\n\tIdCreationRangeWithStashedState,\n} from \"./0.0.1\";\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { FluidDataStoreRegistryEntry, IFluidDataStoreRegistry, IProvideFluidData
|
|
|
9
9
|
export { gcBlobPrefix, gcDeletedBlobKey, gcTombstoneBlobKey, gcTreeKey, IGarbageCollectionData, IGarbageCollectionDetailsBase, } from "./garbageCollection";
|
|
10
10
|
export { IAttachMessage, IEnvelope, IInboundSignalMessage, InboundAttachMessage, ISignalEnvelope, } from "./protocol";
|
|
11
11
|
export { blobCountPropertyName, channelsTreeName, CreateChildSummarizerNodeParam, CreateSummarizerNodeSource, IGarbageCollectionNodeData, IGarbageCollectionSnapshotData, IGarbageCollectionState, IGarbageCollectionSummaryDetailsLegacy, IExperimentalIncrementalSummaryContext, ISummarizeInternalResult, ISummarizeResult, ISummarizerNode, ISummarizerNodeConfig, ISummarizerNodeConfigWithGC, ISummarizerNodeWithGC, ISummaryStats, ISummaryTreeWithStats, ITelemetryContext, SummarizeInternalFn, totalBlobSizePropertyName, } from "./summary";
|
|
12
|
+
export { IIdCompressorCore, IIdCompressor, SerializedIdCompressor, SerializedIdCompressorWithOngoingSession, SerializedIdCompressorWithNoSession, SessionSpaceCompressedId, OpSpaceCompressedId, SessionId, FinalCompressedId, StableId, UuidString, CompressedId, SessionUnique, LocalCompressedId, IdCreationRange, VersionedSerializedIdCompressor, SerializedCluster, SerializedSessionData, SerializedLocalState, SerializedClusterOverrides, SerializedLocalOverrides, SerializedSessionIdNormalizer, UnackedLocalId, IdCreationRangeWithStashedState, } from "./id-compressor";
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,WAAW,EACX,2BAA2B,EAC3B,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,gCAAgC,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,6BAA6B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACvB,sCAAsC,EACtC,sCAAsC,EACtC,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,GAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EACN,WAAW,EACX,2BAA2B,EAC3B,SAAS,EACT,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,8BAA8B,EAC9B,kCAAkC,EAClC,gCAAgC,GAChC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,EAClB,SAAS,EACT,sBAAsB,EACtB,6BAA6B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,cAAc,EACd,SAAS,EACT,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,qBAAqB,EACrB,gBAAgB,EAChB,8BAA8B,EAC9B,0BAA0B,EAC1B,0BAA0B,EAC1B,8BAA8B,EAC9B,uBAAuB,EACvB,sCAAsC,EACtC,sCAAsC,EACtC,wBAAwB,EACxB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EACrB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,aAAa,EACb,sBAAsB,EACtB,wCAAwC,EACxC,mCAAmC,EACnC,wBAAwB,EACxB,mBAAmB,EACnB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,+BAA+B,EAC/B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,6BAA6B,EAC7B,cAAc,EACd,+BAA+B,GAC/B,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,uDAa4B;AAV3B,6GAAA,SAAS,OAAA;AACT,yHAAA,qBAAqB,OAAA;AAQrB,mHAAA,eAAe,OAAA;AAEhB,uDAA2F;AAAlF,0HAAA,sBAAsB,OAAA;AAC/B,yDAM6B;AAJ5B,4HAAA,uBAAuB,OAAA;AAKxB,yDAO6B;AAN5B,iHAAA,YAAY,OAAA;AACZ,qHAAA,gBAAgB,OAAA;AAChB,uHAAA,kBAAkB,OAAA;AAClB,8GAAA,SAAS,OAAA;AAWV,qCAqBmB;AApBlB,gHAAA,qBAAqB,OAAA;AACrB,2GAAA,gBAAgB,OAAA;AAEhB,qHAAA,0BAA0B,OAAA;AAgB1B,oHAAA,yBAAyB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tAttributionInfo,\n\tAttributionKey,\n\tDetachedAttributionKey,\n\tLocalAttributionKey,\n\tOpAttributionKey,\n} from \"./attribution\";\nexport {\n\tAliasResult,\n\tCreateChildSummarizerNodeFn,\n\tFlushMode,\n\tFlushModeExperimental,\n\tIContainerRuntimeBase,\n\tIContainerRuntimeBaseEvents,\n\tIDataStore,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreContextDetached,\n\tIFluidDataStoreContextEvents,\n\tVisibilityState,\n} from \"./dataStoreContext\";\nexport { IFluidDataStoreFactory, IProvideFluidDataStoreFactory } from \"./dataStoreFactory\";\nexport {\n\tFluidDataStoreRegistryEntry,\n\tIFluidDataStoreRegistry,\n\tIProvideFluidDataStoreRegistry,\n\tNamedFluidDataStoreRegistryEntries,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"./dataStoreRegistry\";\nexport {\n\tgcBlobPrefix,\n\tgcDeletedBlobKey,\n\tgcTombstoneBlobKey,\n\tgcTreeKey,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n} from \"./garbageCollection\";\nexport {\n\tIAttachMessage,\n\tIEnvelope,\n\tIInboundSignalMessage,\n\tInboundAttachMessage,\n\tISignalEnvelope,\n} from \"./protocol\";\nexport {\n\tblobCountPropertyName,\n\tchannelsTreeName,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tIGarbageCollectionSummaryDetailsLegacy,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tISummarizerNodeConfigWithGC,\n\tISummarizerNodeWithGC,\n\tISummaryStats,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tSummarizeInternalFn,\n\ttotalBlobSizePropertyName,\n} from \"./summary\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AASH,uDAa4B;AAV3B,6GAAA,SAAS,OAAA;AACT,yHAAA,qBAAqB,OAAA;AAQrB,mHAAA,eAAe,OAAA;AAEhB,uDAA2F;AAAlF,0HAAA,sBAAsB,OAAA;AAC/B,yDAM6B;AAJ5B,4HAAA,uBAAuB,OAAA;AAKxB,yDAO6B;AAN5B,iHAAA,YAAY,OAAA;AACZ,qHAAA,gBAAgB,OAAA;AAChB,uHAAA,kBAAkB,OAAA;AAClB,8GAAA,SAAS,OAAA;AAWV,qCAqBmB;AApBlB,gHAAA,qBAAqB,OAAA;AACrB,2GAAA,gBAAgB,OAAA;AAEhB,qHAAA,0BAA0B,OAAA;AAgB1B,oHAAA,yBAAyB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tAttributionInfo,\n\tAttributionKey,\n\tDetachedAttributionKey,\n\tLocalAttributionKey,\n\tOpAttributionKey,\n} from \"./attribution\";\nexport {\n\tAliasResult,\n\tCreateChildSummarizerNodeFn,\n\tFlushMode,\n\tFlushModeExperimental,\n\tIContainerRuntimeBase,\n\tIContainerRuntimeBaseEvents,\n\tIDataStore,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIFluidDataStoreContextDetached,\n\tIFluidDataStoreContextEvents,\n\tVisibilityState,\n} from \"./dataStoreContext\";\nexport { IFluidDataStoreFactory, IProvideFluidDataStoreFactory } from \"./dataStoreFactory\";\nexport {\n\tFluidDataStoreRegistryEntry,\n\tIFluidDataStoreRegistry,\n\tIProvideFluidDataStoreRegistry,\n\tNamedFluidDataStoreRegistryEntries,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"./dataStoreRegistry\";\nexport {\n\tgcBlobPrefix,\n\tgcDeletedBlobKey,\n\tgcTombstoneBlobKey,\n\tgcTreeKey,\n\tIGarbageCollectionData,\n\tIGarbageCollectionDetailsBase,\n} from \"./garbageCollection\";\nexport {\n\tIAttachMessage,\n\tIEnvelope,\n\tIInboundSignalMessage,\n\tInboundAttachMessage,\n\tISignalEnvelope,\n} from \"./protocol\";\nexport {\n\tblobCountPropertyName,\n\tchannelsTreeName,\n\tCreateChildSummarizerNodeParam,\n\tCreateSummarizerNodeSource,\n\tIGarbageCollectionNodeData,\n\tIGarbageCollectionSnapshotData,\n\tIGarbageCollectionState,\n\tIGarbageCollectionSummaryDetailsLegacy,\n\tIExperimentalIncrementalSummaryContext,\n\tISummarizeInternalResult,\n\tISummarizeResult,\n\tISummarizerNode,\n\tISummarizerNodeConfig,\n\tISummarizerNodeConfigWithGC,\n\tISummarizerNodeWithGC,\n\tISummaryStats,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tSummarizeInternalFn,\n\ttotalBlobSizePropertyName,\n} from \"./summary\";\nexport {\n\tIIdCompressorCore,\n\tIIdCompressor,\n\tSerializedIdCompressor,\n\tSerializedIdCompressorWithOngoingSession,\n\tSerializedIdCompressorWithNoSession,\n\tSessionSpaceCompressedId,\n\tOpSpaceCompressedId,\n\tSessionId,\n\tFinalCompressedId,\n\tStableId,\n\tUuidString,\n\tCompressedId,\n\tSessionUnique,\n\tLocalCompressedId,\n\tIdCreationRange,\n\tVersionedSerializedIdCompressor,\n\tSerializedCluster,\n\tSerializedSessionData,\n\tSerializedLocalState,\n\tSerializedClusterOverrides,\n\tSerializedLocalOverrides,\n\tSerializedSessionIdNormalizer,\n\tUnackedLocalId,\n\tIdCreationRangeWithStashedState,\n} from \"./id-compressor\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-definitions",
|
|
3
|
-
"version": "2.0.0-internal.4.1
|
|
3
|
+
"version": "2.0.0-internal.4.2.1",
|
|
4
4
|
"description": "Fluid Runtime definitions",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
18
18
|
"@fluidframework/common-utils": "^1.1.1",
|
|
19
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.4.1
|
|
20
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.4.1
|
|
21
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.4.1
|
|
19
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.4.2.1 <2.0.0-internal.4.3.0",
|
|
20
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.4.2.1 <2.0.0-internal.4.3.0",
|
|
21
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.4.2.1 <2.0.0-internal.4.3.0",
|
|
22
22
|
"@fluidframework/protocol-definitions": "^1.1.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@fluid-tools/build-cli": "^0.
|
|
25
|
+
"@fluid-tools/build-cli": "^0.17.0",
|
|
26
26
|
"@fluidframework/build-common": "^1.1.0",
|
|
27
|
-
"@fluidframework/build-tools": "^0.
|
|
27
|
+
"@fluidframework/build-tools": "^0.17.0",
|
|
28
28
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
29
29
|
"@fluidframework/runtime-definitions-previous": "npm:@fluidframework/runtime-definitions@2.0.0-internal.4.1.0",
|
|
30
30
|
"@microsoft/api-extractor": "^7.34.4",
|
package/src/dataStoreContext.ts
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
ITelemetryContext,
|
|
43
43
|
SummarizeInternalFn,
|
|
44
44
|
} from "./summary";
|
|
45
|
+
import { IIdCompressor } from "./id-compressor";
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Runtime flush mode handling
|
|
@@ -377,6 +378,7 @@ export interface IFluidDataStoreContext
|
|
|
377
378
|
readonly baseSnapshot: ISnapshotTree | undefined;
|
|
378
379
|
readonly logger: ITelemetryBaseLogger;
|
|
379
380
|
readonly clientDetails: IClientDetails;
|
|
381
|
+
readonly idCompressor?: IIdCompressor;
|
|
380
382
|
/**
|
|
381
383
|
* Indicates the attachment state of the data store to a host service.
|
|
382
384
|
*/
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
SessionSpaceCompressedId,
|
|
8
|
+
OpSpaceCompressedId,
|
|
9
|
+
SessionId,
|
|
10
|
+
FinalCompressedId,
|
|
11
|
+
StableId,
|
|
12
|
+
} from "./identifiers";
|
|
13
|
+
import {
|
|
14
|
+
IdCreationRange,
|
|
15
|
+
SerializedIdCompressorWithNoSession,
|
|
16
|
+
SerializedIdCompressorWithOngoingSession,
|
|
17
|
+
} from "./persisted-types";
|
|
18
|
+
|
|
19
|
+
export interface IIdCompressorCore {
|
|
20
|
+
clusterCapacity: number;
|
|
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 range of local IDs created by this session in a format for sending to the server for finalizing.
|
|
30
|
+
* The range will include all local IDs generated via calls to `generateCompressedId` since the last time this method was called.
|
|
31
|
+
* @returns the range of session-local IDs, which may be empty. This range must be sent to the server for ordering before
|
|
32
|
+
* it is finalized. Ranges must be sent to the server in the order that they are taken via calls to this method.
|
|
33
|
+
*/
|
|
34
|
+
takeNextCreationRange(): IdCreationRange;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
38
|
+
* This includes finalized state as well as un-finalized state and is therefore suitable for use in offline scenarios.
|
|
39
|
+
*/
|
|
40
|
+
serialize(withSession: true): SerializedIdCompressorWithOngoingSession;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Returns a persistable form of the current state of this `IdCompressor` which can be rehydrated via `IdCompressor.deserialize()`.
|
|
44
|
+
* This only includes finalized state and is therefore suitable for use in summaries.
|
|
45
|
+
*/
|
|
46
|
+
serialize(withSession: false): SerializedIdCompressorWithNoSession;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A distributed UUID generator and compressor.
|
|
51
|
+
*
|
|
52
|
+
* Generates arbitrary non-colliding v4 UUIDs, called stable IDs, for multiple "sessions" (which can be distributed across the network),
|
|
53
|
+
* providing each session with the ability to map these UUIDs to `numbers`.
|
|
54
|
+
*
|
|
55
|
+
* A session is a unique identifier that denotes a single compressor. New IDs are created through a single compressor API
|
|
56
|
+
* which should then sent in ranges to the server for total ordering (and are subsequently relayed to other clients). When a new ID is
|
|
57
|
+
* created it is said to be created by the compressor's "local" session.
|
|
58
|
+
*
|
|
59
|
+
* For each stable ID created, two numeric IDs are provided by the compressor:
|
|
60
|
+
*
|
|
61
|
+
* 1. A local ID, which is stable for the lifetime of the session (which could be longer than that of the compressor object, as it may
|
|
62
|
+
* be serialized for offline usage). Available as soon as the stable ID is allocated. Local IDs are session-unique and are thus only
|
|
63
|
+
* publicly usable by the compressor that created the stable ID.
|
|
64
|
+
*
|
|
65
|
+
* 2. A final ID, which is stable across serialization and deserialization of an IdCompressor. Available as soon as the range containing
|
|
66
|
+
* the corresponding local ID is totally ordered (via consensus) with respect to other sessions' allocations.
|
|
67
|
+
* Final IDs are known to and publicly usable by any compressor that has received them.
|
|
68
|
+
*
|
|
69
|
+
* Compressors will allocate UUIDs in non-random ways to reduce entropy allowing for optimized storage of the data needed
|
|
70
|
+
* to map the UUIDs to the numbers.
|
|
71
|
+
*
|
|
72
|
+
* A client may optionally supply an "override" for any generated ID, associating an arbitrary string with the local/final ID rather than
|
|
73
|
+
* the UUID that would otherwise be created.
|
|
74
|
+
*
|
|
75
|
+
* The following invariants are upheld by IdCompressor:
|
|
76
|
+
*
|
|
77
|
+
* 1. Local IDs will always decompress to the same UUIDs (or override string) for the lifetime of the session.
|
|
78
|
+
*
|
|
79
|
+
* 2. Final IDs will always decompress to the same UUIDs (or override string).
|
|
80
|
+
*
|
|
81
|
+
* 3. After a server-processed range of local IDs (from any session) is received by a compressor, any of those local IDs may be
|
|
82
|
+
* translated by the compressor into the corresponding final ID. For any given local ID, this translation will always yield the
|
|
83
|
+
* same final ID.
|
|
84
|
+
*
|
|
85
|
+
* 4. A UUID (or override string) will always compress into the same session-space ID for the lifetime of the session.
|
|
86
|
+
*
|
|
87
|
+
* Local IDs are sent across the wire in efficiently-represented ranges. These ranges are created by querying the compressor, and *must*
|
|
88
|
+
* be ordered (i.e. sent to the server) in the order they are created in order to preserve the above invariants.
|
|
89
|
+
*
|
|
90
|
+
* Session-local IDs can be used immediately after creation, but will eventually (after being sequenced) have a corresponding final ID. This
|
|
91
|
+
* could make reasoning about equality of those two forms (the local and final) difficult. For example, if a cache is keyed off of a
|
|
92
|
+
* local ID but is later queried using the final ID (which is semantically equal, as it decompresses to the same UUID/string) it will
|
|
93
|
+
* produce a cache miss. In order to make using collections of both remotely created and locally created IDs easy, regardless of whether the
|
|
94
|
+
* session-local IDs have been finalized, the compressor defines two "spaces" of IDs:
|
|
95
|
+
*
|
|
96
|
+
* 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
|
|
97
|
+
* will be in local form, regardless of if they have been finalized. Remotely created IDs, which could only have been received after
|
|
98
|
+
* 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
|
|
99
|
+
* 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
|
|
100
|
+
* these IDs across compressor objects, as the local IDs are specific to the compressor that created them.
|
|
101
|
+
*
|
|
102
|
+
* 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
|
|
103
|
+
* 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
|
|
104
|
+
* 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
|
|
105
|
+
* out of Op space over time, namely, when a local ID in this space becomes finalized, and thereafter has a "more final form".
|
|
106
|
+
* Consequentially, it may be useful to restrict parameters of a persisted type to this space (to optimize perf), but it is potentially
|
|
107
|
+
* 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
|
|
108
|
+
* "local as possible".
|
|
109
|
+
*
|
|
110
|
+
* These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
|
|
111
|
+
* should use op-space IDs.
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
export interface IIdCompressor {
|
|
115
|
+
localSessionId: SessionId;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Generates a new compressed ID or returns an existing one.
|
|
119
|
+
* This should ONLY be called to generate IDs for local operations.
|
|
120
|
+
* @param override - Specifies a specific string to be associated with the returned compressed ID.
|
|
121
|
+
* Performance note: assigning override strings incurs a performance overhead.
|
|
122
|
+
* @returns an existing ID if one already exists for `override`, and a new local ID otherwise. The returned ID is in session space.
|
|
123
|
+
*/
|
|
124
|
+
generateCompressedId(override?: string): SessionSpaceCompressedId;
|
|
125
|
+
/**
|
|
126
|
+
* Normalizes a session space ID into op space.
|
|
127
|
+
* @param id - the local ID to normalize.
|
|
128
|
+
* @returns the ID in op space.
|
|
129
|
+
*/
|
|
130
|
+
normalizeToOpSpace(id: SessionSpaceCompressedId): OpSpaceCompressedId;
|
|
131
|
+
/**
|
|
132
|
+
* Normalizes an ID into session space.
|
|
133
|
+
* @param id - the ID to normalize. If it is a local ID, it is assumed to have been created by the session corresponding
|
|
134
|
+
* to `sessionId`.
|
|
135
|
+
* @param originSessionId - the session from which `id` originated
|
|
136
|
+
* @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
|
|
137
|
+
* 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
|
|
138
|
+
* range that contained it from the server.
|
|
139
|
+
*/
|
|
140
|
+
normalizeToSessionSpace(
|
|
141
|
+
id: OpSpaceCompressedId,
|
|
142
|
+
originSessionId: SessionId,
|
|
143
|
+
): SessionSpaceCompressedId;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Normalizes a final ID into session space.
|
|
147
|
+
* @param id - the final ID to normalize.
|
|
148
|
+
* @returns the session-space ID corresponding to `id`.
|
|
149
|
+
*/
|
|
150
|
+
normalizeToSessionSpace(id: FinalCompressedId): SessionSpaceCompressedId;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Decompresses a previously compressed ID into a UUID or override string.
|
|
154
|
+
* @param id - the compressed ID to be decompressed.
|
|
155
|
+
* @returns the UUID or override string associated with the compressed ID. Fails if the ID was not generated by this compressor.
|
|
156
|
+
*/
|
|
157
|
+
decompress(id: SessionSpaceCompressedId | FinalCompressedId): StableId | string;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Attempts to decompress a previously compressed ID into a UUID or override string.
|
|
161
|
+
* @param id - the compressed ID to be decompressed.
|
|
162
|
+
* @returns the UUID or override string associated with the compressed ID, or undefined if the ID was not generated by this compressor.
|
|
163
|
+
*/
|
|
164
|
+
tryDecompress(id: SessionSpaceCompressedId | FinalCompressedId): StableId | string | undefined;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Recompresses a decompressed ID, which could be a UUID or an override string.
|
|
168
|
+
* @param uncompressed - the UUID or override string to recompress.
|
|
169
|
+
* @returns the `CompressedId` associated with `uncompressed`. Fails if it has not been previously compressed by this compressor.
|
|
170
|
+
*/
|
|
171
|
+
recompress(uncompressed: string): SessionSpaceCompressedId;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Attempts to recompresses a decompressed ID, which could be a UUID or an override string.
|
|
175
|
+
* @param uncompressed - the UUID or override string to recompress,
|
|
176
|
+
* @returns the `CompressedId` associated with `uncompressed` or undefined if it has not been previously compressed by this compressor.
|
|
177
|
+
*/
|
|
178
|
+
tryRecompress(uncompressed: string): SessionSpaceCompressedId | undefined;
|
|
179
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* An identifier (UUID) that has been shortened by a distributed compression algorithm.
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export type CompressedId = FinalCompressedId | LocalCompressedId;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A brand for identity types that are unique within a particular session (SharedTree instance).
|
|
14
|
+
*/
|
|
15
|
+
export interface SessionUnique {
|
|
16
|
+
readonly SessionUnique: "cea55054-6b82-4cbf-ad19-1fa645ea3b3e";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A compressed ID that has been normalized into "session space" (see `IdCompressor` for more).
|
|
21
|
+
* Consumer-facing APIs and data structures should use session-space IDs as their lifetime and equality is stable and tied to the
|
|
22
|
+
* compressor that produced them.
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
export type SessionSpaceCompressedId = CompressedId & SessionUnique;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A compressed ID that has been normalized into "op space" (see `IdCompressor` for more).
|
|
29
|
+
* Serialized/persisted structures (e.g. ops) should use op-space IDs as a performance optimization, as they require no normalizing when
|
|
30
|
+
* received by a remote client due to the fact that op space for a given compressor is session space for all other compressors.
|
|
31
|
+
*/
|
|
32
|
+
export type OpSpaceCompressedId = CompressedId & {
|
|
33
|
+
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A compressed ID that is local to a document. Stable across all revisions of a document starting from the one in which it was created.
|
|
38
|
+
* It should not be persisted outside of the history as it can only be decompressed in the context of the originating document.
|
|
39
|
+
* If external persistence is needed (e.g. by a client), a StableId should be used instead.
|
|
40
|
+
* @alpha
|
|
41
|
+
*/
|
|
42
|
+
export type FinalCompressedId = number & {
|
|
43
|
+
readonly FinalCompressedId: "5d83d1e2-98b7-4e4e-a889-54c855cfa73d";
|
|
44
|
+
|
|
45
|
+
// Same brand as OpNormalizedCompressedId, as final IDs are always finally normalized
|
|
46
|
+
readonly OpNormalized: "9209432d-a959-4df7-b2ad-767ead4dbcae";
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).
|
|
51
|
+
* It should not be persisted outside of the history as it can only be decompressed in the context of the originating session.
|
|
52
|
+
* If external persistence is needed (e.g. by a client), a StableId should be used instead.
|
|
53
|
+
* @alpha
|
|
54
|
+
*/
|
|
55
|
+
export type LocalCompressedId = number & {
|
|
56
|
+
readonly LocalCompressedId: "6fccb42f-e2a4-4243-bd29-f13d12b9c6d1";
|
|
57
|
+
} & SessionUnique; // Same brand as CompressedId, as local IDs are always locally normalized
|
|
58
|
+
|
|
59
|
+
export interface NodeIdBrand {
|
|
60
|
+
readonly NodeId: "e53e7d6b-c8b9-431a-8805-4843fc639342";
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Type-safe identifiers for specific use cases.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A 128-bit Universally Unique IDentifier. Represented here
|
|
69
|
+
* with a string of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,
|
|
70
|
+
* where x is a lowercase hex digit.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export type UuidString = string & { readonly UuidString: "9d40d0ae-90d9-44b1-9482-9f55d59d5465" };
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A version 4, variant 2 uuid (https://datatracker.ietf.org/doc/html/rfc4122).
|
|
77
|
+
*/
|
|
78
|
+
export type StableId = UuidString & { readonly StableId: "53172b0d-a3d5-41ea-bd75-b43839c97f5a" };
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A StableId which is suitable for use as a session identifier
|
|
82
|
+
*/
|
|
83
|
+
export type SessionId = StableId & { readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58" };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
IdCreationRange,
|
|
8
|
+
SerializedCluster,
|
|
9
|
+
SerializedClusterOverrides,
|
|
10
|
+
SerializedIdCompressor,
|
|
11
|
+
SerializedIdCompressorWithNoSession,
|
|
12
|
+
SerializedIdCompressorWithOngoingSession,
|
|
13
|
+
SerializedLocalOverrides,
|
|
14
|
+
SerializedLocalState,
|
|
15
|
+
SerializedSessionData,
|
|
16
|
+
SerializedSessionIdNormalizer,
|
|
17
|
+
UnackedLocalId,
|
|
18
|
+
VersionedSerializedIdCompressor,
|
|
19
|
+
IdCreationRangeWithStashedState,
|
|
20
|
+
} from "./persisted-types";
|
|
21
|
+
|
|
22
|
+
export { IIdCompressorCore, IIdCompressor } from "./idCompressor";
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
SessionSpaceCompressedId,
|
|
26
|
+
OpSpaceCompressedId,
|
|
27
|
+
SessionId,
|
|
28
|
+
FinalCompressedId,
|
|
29
|
+
StableId,
|
|
30
|
+
UuidString,
|
|
31
|
+
CompressedId,
|
|
32
|
+
SessionUnique,
|
|
33
|
+
LocalCompressedId,
|
|
34
|
+
} from "./identifiers";
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
FinalCompressedId,
|
|
8
|
+
LocalCompressedId,
|
|
9
|
+
OpSpaceCompressedId,
|
|
10
|
+
SessionId,
|
|
11
|
+
} from "../identifiers";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A serialized ID allocation session for an `IdCompressor`.
|
|
15
|
+
*/
|
|
16
|
+
export type SerializedSessionData = readonly [
|
|
17
|
+
/**
|
|
18
|
+
* The ID of the session.
|
|
19
|
+
*/
|
|
20
|
+
sessionId: SessionId,
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export type SerializedClusterOverrides = readonly [
|
|
24
|
+
/** The overridden final ID, represented as an index into the cluster's ID range */
|
|
25
|
+
overriddenFinalIndex: number, // A cluster with base UUID '...beef' and an `overriddenFinalIndex` of 3 would correspond to '...bef2'
|
|
26
|
+
/** The override string */
|
|
27
|
+
override: string,
|
|
28
|
+
/** The first ID that was finalized and associated with this override, set only if different than the `overriddenFinalIndex` */
|
|
29
|
+
overriddenId?: FinalCompressedId,
|
|
30
|
+
][];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A serialized final ID cluster.
|
|
34
|
+
*/
|
|
35
|
+
export type SerializedCluster = readonly [
|
|
36
|
+
/**
|
|
37
|
+
* Index into the serialized sessions array. Can be converted into a baseUuid via its order in `clusters`.
|
|
38
|
+
* If negative, then this cluster was created by the local session.
|
|
39
|
+
*/
|
|
40
|
+
sessionIndex: number,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The capacity of the cluster.
|
|
44
|
+
*/
|
|
45
|
+
capacity: number,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The number of IDs in the cluster. Omitted if count === capacity.
|
|
49
|
+
* --OR--
|
|
50
|
+
* The overrides in this cluster. Omitted if no overrides exist in the cluster.
|
|
51
|
+
*/
|
|
52
|
+
countOrOverrides?: number | SerializedClusterOverrides,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Overrides in this cluster. Omitted if no overrides exist in the cluster.
|
|
56
|
+
*/
|
|
57
|
+
overrides?: SerializedClusterOverrides,
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
export type SerializedLocalOverrides = readonly (readonly [LocalCompressedId, string])[];
|
|
61
|
+
|
|
62
|
+
export interface SerializedLocalState {
|
|
63
|
+
/**
|
|
64
|
+
* The total number of local IDs created by this session
|
|
65
|
+
*/
|
|
66
|
+
readonly localIdCount: number;
|
|
67
|
+
/**
|
|
68
|
+
* Overrides generated by this session. Omitted if no local overrides exist in the session.
|
|
69
|
+
*/
|
|
70
|
+
readonly overrides?: SerializedLocalOverrides;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The most recent local ID in a range returned by `takeNextCreationRange`.
|
|
74
|
+
*/
|
|
75
|
+
readonly lastTakenLocalId: LocalCompressedId | undefined;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Serialized table for normalizing IDs made by the local session.
|
|
79
|
+
*/
|
|
80
|
+
readonly sessionNormalizer: SerializedSessionIdNormalizer;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Serialized table for normalizing IDs made by the local session.
|
|
85
|
+
*/
|
|
86
|
+
export interface SerializedSessionIdNormalizer {
|
|
87
|
+
readonly nextLocalId: LocalCompressedId;
|
|
88
|
+
readonly localRanges: readonly (readonly [
|
|
89
|
+
firstLocal: LocalCompressedId,
|
|
90
|
+
lastLocal: LocalCompressedId,
|
|
91
|
+
finalRanges?: readonly (readonly [
|
|
92
|
+
alignedLocal: LocalCompressedId,
|
|
93
|
+
firstFinal: FinalCompressedId,
|
|
94
|
+
lastFinal: FinalCompressedId,
|
|
95
|
+
])[],
|
|
96
|
+
])[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The minimal required contents of a serialized IdCompressor.
|
|
101
|
+
*/
|
|
102
|
+
export interface VersionedSerializedIdCompressor {
|
|
103
|
+
readonly _versionedSerializedIdCompressor: "8c73c57c-1cf4-4278-8915-6444cb4f6af5";
|
|
104
|
+
readonly version: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
109
|
+
*/
|
|
110
|
+
export interface SerializedIdCompressor extends VersionedSerializedIdCompressor {
|
|
111
|
+
/** The cluster capacity of this compressor */
|
|
112
|
+
readonly clusterCapacity: number;
|
|
113
|
+
/** All sessions except the local session. */
|
|
114
|
+
readonly sessions: readonly SerializedSessionData[];
|
|
115
|
+
/** All clusters in the compressor in the order they were created. */
|
|
116
|
+
readonly clusters: readonly SerializedCluster[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
121
|
+
*/
|
|
122
|
+
export interface SerializedIdCompressorWithNoSession extends SerializedIdCompressor {
|
|
123
|
+
readonly _noLocalState: "3aa2e1e8-cc28-4ea7-bc1a-a11dc3f26dfb";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The serialized contents of an IdCompressor, suitable for persistence in a summary.
|
|
128
|
+
*/
|
|
129
|
+
export interface SerializedIdCompressorWithOngoingSession extends SerializedIdCompressor {
|
|
130
|
+
readonly _hasLocalState: "1281acae-6d14-47e7-bc92-71c8ee0819cb";
|
|
131
|
+
/** The session ID of the local session, by index into `sessions`. */
|
|
132
|
+
readonly localSessionIndex: number;
|
|
133
|
+
/** This is only present if the local session made any IDs. */
|
|
134
|
+
readonly localState?: SerializedLocalState;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Data describing a range of session-local IDs (from a remote or local session).
|
|
139
|
+
*
|
|
140
|
+
* A range is composed of local IDs that were generated. Some of these may have overrides.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* Suppose an IdCompressor generated a sequence of local IDs as follows:
|
|
144
|
+
* ```
|
|
145
|
+
* compressor.generateLocalId()
|
|
146
|
+
* compressor.generateLocalId('0093cf29-9454-4034-8940-33b1077b41c3')
|
|
147
|
+
* compressor.generateLocalId()
|
|
148
|
+
* compressor.generateLocalId('0ed545f8-e97e-4dc1-acf9-c4a783258bdf')
|
|
149
|
+
* compressor.generateLocalId()
|
|
150
|
+
* compressor.generateLocalId()
|
|
151
|
+
* compressor.takeNextCreationRange()
|
|
152
|
+
* ```
|
|
153
|
+
* This would result in the following range:
|
|
154
|
+
* ```
|
|
155
|
+
* {
|
|
156
|
+
* first: localId1,
|
|
157
|
+
* last: localId6,
|
|
158
|
+
* overrides: [[localId2, '0093cf29-9454-4034-8940-33b1077b41c3'], [localId4, '0ed545f8-e97e-4dc1-acf9-c4a783258bdf']]
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export interface IdCreationRange {
|
|
163
|
+
readonly sessionId: SessionId;
|
|
164
|
+
readonly ids?: IdCreationRange.Ids;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type UnackedLocalId = LocalCompressedId & OpSpaceCompressedId;
|
|
168
|
+
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
170
|
+
export namespace IdCreationRange {
|
|
171
|
+
export type Ids =
|
|
172
|
+
| {
|
|
173
|
+
readonly first: UnackedLocalId;
|
|
174
|
+
readonly last: UnackedLocalId;
|
|
175
|
+
}
|
|
176
|
+
| ({
|
|
177
|
+
readonly first?: UnackedLocalId;
|
|
178
|
+
readonly last?: UnackedLocalId;
|
|
179
|
+
} & HasOverrides);
|
|
180
|
+
|
|
181
|
+
export interface HasOverrides {
|
|
182
|
+
readonly overrides: Overrides;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export type Override = readonly [id: UnackedLocalId, override: string];
|
|
186
|
+
export type Overrides = readonly [Override, ...Override[]];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export type IdCreationRangeWithStashedState = IdCreationRange & {
|
|
190
|
+
stashedState: SerializedIdCompressorWithOngoingSession;
|
|
191
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
IdCreationRange,
|
|
8
|
+
SerializedCluster,
|
|
9
|
+
SerializedClusterOverrides,
|
|
10
|
+
SerializedIdCompressor,
|
|
11
|
+
SerializedIdCompressorWithNoSession,
|
|
12
|
+
SerializedIdCompressorWithOngoingSession,
|
|
13
|
+
SerializedLocalOverrides,
|
|
14
|
+
SerializedLocalState,
|
|
15
|
+
SerializedSessionData,
|
|
16
|
+
SerializedSessionIdNormalizer,
|
|
17
|
+
UnackedLocalId,
|
|
18
|
+
VersionedSerializedIdCompressor,
|
|
19
|
+
IdCreationRangeWithStashedState,
|
|
20
|
+
} from "./0.0.1";
|