@fluidframework/id-compressor 2.91.0 → 2.93.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/api-report/id-compressor.legacy.beta.api.md +8 -1
  3. package/dist/idCompressor.d.ts +67 -0
  4. package/dist/idCompressor.d.ts.map +1 -1
  5. package/dist/idCompressor.js +43 -28
  6. package/dist/idCompressor.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/legacy.d.ts +3 -2
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.js +1 -1
  14. package/dist/packageVersion.js.map +1 -1
  15. package/dist/public.d.ts +1 -1
  16. package/dist/test/idCompressor.spec.js.map +1 -1
  17. package/dist/test/types/validateIdCompressorPrevious.generated.d.ts +6 -0
  18. package/dist/test/types/validateIdCompressorPrevious.generated.d.ts.map +1 -0
  19. package/dist/test/types/validateIdCompressorPrevious.generated.js +7 -0
  20. package/dist/test/types/validateIdCompressorPrevious.generated.js.map +1 -0
  21. package/dist/types/idCompressor.d.ts +28 -0
  22. package/dist/types/idCompressor.d.ts.map +1 -1
  23. package/dist/types/idCompressor.js.map +1 -1
  24. package/eslint.config.mts +1 -1
  25. package/internal.d.ts +1 -1
  26. package/legacy.d.ts +1 -1
  27. package/lib/idCompressor.d.ts +67 -0
  28. package/lib/idCompressor.d.ts.map +1 -1
  29. package/lib/idCompressor.js +40 -27
  30. package/lib/idCompressor.js.map +1 -1
  31. package/lib/index.d.ts +1 -1
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/index.js +1 -1
  34. package/lib/index.js.map +1 -1
  35. package/lib/legacy.d.ts +3 -2
  36. package/lib/packageVersion.d.ts +1 -1
  37. package/lib/packageVersion.js +1 -1
  38. package/lib/packageVersion.js.map +1 -1
  39. package/lib/public.d.ts +1 -1
  40. package/lib/test/idCompressor.spec.js.map +1 -1
  41. package/lib/test/types/validateIdCompressorPrevious.generated.d.ts +6 -0
  42. package/lib/test/types/validateIdCompressorPrevious.generated.d.ts.map +1 -0
  43. package/lib/test/types/validateIdCompressorPrevious.generated.js +6 -0
  44. package/lib/test/types/validateIdCompressorPrevious.generated.js.map +1 -0
  45. package/lib/tsdoc-metadata.json +1 -1
  46. package/lib/types/idCompressor.d.ts +28 -0
  47. package/lib/types/idCompressor.d.ts.map +1 -1
  48. package/lib/types/idCompressor.js.map +1 -1
  49. package/package.json +18 -17
  50. package/src/idCompressor.ts +114 -29
  51. package/src/index.ts +6 -1
  52. package/src/packageVersion.ts +1 -1
  53. package/src/test/types/validateIdCompressorPrevious.generated.ts +234 -0
  54. package/src/types/idCompressor.ts +29 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateIdCompressorPrevious.generated.js","sourceRoot":"","sources":["../../../src/test/types/validateIdCompressorPrevious.generated.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 * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n * Generated by \"flub generate typetests\" from @fluid-tools/build-cli.\n *\n * Baseline (previous) version: 2.92.0\n */\n\nimport type { TypeOnly, MinimalType, FullType, requireAssignableTo } from \"@fluidframework/build-tools\";\nimport type * as old from \"@fluidframework/id-compressor-previous/legacy\";\n\nimport type * as current from \"@fluidframework/id-compressor/legacy\";\n\ndeclare type MakeUnusedImportErrorsGoAway<T> = TypeOnly<T> | MinimalType<T> | FullType<T> | typeof old | typeof current | requireAssignableTo<true, true>;\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Function_createIdCompressor\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Function_createIdCompressor = requireAssignableTo<TypeOnly<typeof current.createIdCompressor>, TypeOnly<typeof old.createIdCompressor>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Function_createSessionId\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Function_createSessionId = requireAssignableTo<TypeOnly<typeof current.createSessionId>, TypeOnly<typeof old.createSessionId>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Function_deserializeIdCompressor\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Function_deserializeIdCompressor = requireAssignableTo<TypeOnly<typeof current.deserializeIdCompressor>, TypeOnly<typeof old.deserializeIdCompressor>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Function_serializeIdCompressor\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Function_serializeIdCompressor = requireAssignableTo<TypeOnly<typeof current.serializeIdCompressor>, TypeOnly<typeof old.serializeIdCompressor>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Interface_IdCreationRange\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_Interface_IdCreationRange = requireAssignableTo<TypeOnly<old.IdCreationRange>, TypeOnly<current.IdCreationRange>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Interface_IdCreationRange\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Interface_IdCreationRange = requireAssignableTo<TypeOnly<current.IdCreationRange>, TypeOnly<old.IdCreationRange>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Interface_IIdCompressor\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_Interface_IIdCompressor = requireAssignableTo<TypeOnly<old.IIdCompressor>, TypeOnly<current.IIdCompressor>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Interface_IIdCompressor\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Interface_IIdCompressor = requireAssignableTo<TypeOnly<current.IIdCompressor>, TypeOnly<old.IIdCompressor>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Interface_IIdCompressorCore\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_Interface_IIdCompressorCore = requireAssignableTo<TypeOnly<old.IIdCompressorCore>, TypeOnly<current.IIdCompressorCore>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"Interface_IIdCompressorCore\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_Interface_IIdCompressorCore = requireAssignableTo<TypeOnly<current.IIdCompressorCore>, TypeOnly<old.IIdCompressorCore>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_OpSpaceCompressedId\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_OpSpaceCompressedId = requireAssignableTo<TypeOnly<old.OpSpaceCompressedId>, TypeOnly<current.OpSpaceCompressedId>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_OpSpaceCompressedId\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_OpSpaceCompressedId = requireAssignableTo<TypeOnly<current.OpSpaceCompressedId>, TypeOnly<old.OpSpaceCompressedId>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SerializedIdCompressor\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_SerializedIdCompressor = requireAssignableTo<TypeOnly<old.SerializedIdCompressor>, TypeOnly<current.SerializedIdCompressor>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SerializedIdCompressor\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_SerializedIdCompressor = requireAssignableTo<TypeOnly<current.SerializedIdCompressor>, TypeOnly<old.SerializedIdCompressor>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SerializedIdCompressorWithNoSession\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_SerializedIdCompressorWithNoSession = requireAssignableTo<TypeOnly<old.SerializedIdCompressorWithNoSession>, TypeOnly<current.SerializedIdCompressorWithNoSession>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SerializedIdCompressorWithNoSession\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_SerializedIdCompressorWithNoSession = requireAssignableTo<TypeOnly<current.SerializedIdCompressorWithNoSession>, TypeOnly<old.SerializedIdCompressorWithNoSession>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SerializedIdCompressorWithOngoingSession\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_SerializedIdCompressorWithOngoingSession = requireAssignableTo<TypeOnly<old.SerializedIdCompressorWithOngoingSession>, TypeOnly<current.SerializedIdCompressorWithOngoingSession>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SerializedIdCompressorWithOngoingSession\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_SerializedIdCompressorWithOngoingSession = requireAssignableTo<TypeOnly<current.SerializedIdCompressorWithOngoingSession>, TypeOnly<old.SerializedIdCompressorWithOngoingSession>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SessionId\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_SessionId = requireAssignableTo<TypeOnly<old.SessionId>, TypeOnly<current.SessionId>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SessionId\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_SessionId = requireAssignableTo<TypeOnly<current.SessionId>, TypeOnly<old.SessionId>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SessionSpaceCompressedId\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_SessionSpaceCompressedId = requireAssignableTo<TypeOnly<old.SessionSpaceCompressedId>, TypeOnly<current.SessionSpaceCompressedId>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_SessionSpaceCompressedId\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_SessionSpaceCompressedId = requireAssignableTo<TypeOnly<current.SessionSpaceCompressedId>, TypeOnly<old.SessionSpaceCompressedId>>\n\n/*\n * Validate forward compatibility by using the old type in place of the current type.\n * If this test starts failing, it indicates a change that is not forward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_StableId\": {\"forwardCompat\": false}\n */\ndeclare type old_as_current_for_TypeAlias_StableId = requireAssignableTo<TypeOnly<old.StableId>, TypeOnly<current.StableId>>\n\n/*\n * Validate backward compatibility by using the current type in place of the old type.\n * If this test starts failing, it indicates a change that is not backward compatible.\n * To acknowledge the breaking change, add the following to package.json under\n * typeValidation.broken:\n * \"TypeAlias_StableId\": {\"backCompat\": false}\n */\ndeclare type current_as_old_for_TypeAlias_StableId = requireAssignableTo<TypeOnly<current.StableId>, TypeOnly<old.StableId>>\n"]}
@@ -64,6 +64,19 @@ import type { IdCreationRange, SerializedIdCompressorWithNoSession, SerializedId
64
64
  *
65
65
  * These two spaces naturally define a rule: consumers of compressed IDs should use session-space IDs, but serialized forms such as ops
66
66
  * should use op-space IDs.
67
+ *
68
+ * @privateremarks To be made internal in 2.100.0
69
+ *
70
+ * @deprecated `IIdCompressorCore` will be removed from the public API in 2.100.0.
71
+ *
72
+ * - If you use `serialize()`, use the free function
73
+ * {@link (serializeIdCompressor:1) | serializeIdCompressor(compressor, withSession)} instead.
74
+ *
75
+ * - `takeNextCreationRange`, `takeUnfinalizedCreationRange`, `finalizeCreationRange`, and
76
+ * `beginGhostSession` are internal runtime operations. External consumers should not call
77
+ * them directly. If you depend on these APIs, please file an issue on the FluidFramework
78
+ * repository describing your use case.
79
+ *
67
80
  * @legacy @beta
68
81
  */
69
82
  export interface IIdCompressorCore {
@@ -84,6 +97,21 @@ export interface IIdCompressorCore {
84
97
  * will result in an error.
85
98
  */
86
99
  takeUnfinalizedCreationRange(): IdCreationRange;
100
+ /**
101
+ * Resets the next creation range to include all unfinalized IDs.
102
+ *
103
+ * @remarks
104
+ * IMPORTANT: This must only be called if it's CERTAIN that the unfinalized range will never be finalized as-is (e.g. by in-flight ops).
105
+ *
106
+ * After calling this, the next call to {@link IIdCompressorCore.takeNextCreationRange} will produce a range
107
+ * covering all unfinalized IDs (equivalent to what {@link IIdCompressorCore.takeUnfinalizedCreationRange} would
108
+ * have returned) plus any IDs generated after this call.
109
+ *
110
+ * Unlike {@link IIdCompressorCore.takeUnfinalizedCreationRange}, this method does not produce or return a range,
111
+ * and does not advance the internal range counter. It is useful when the caller wants to
112
+ * defer the actual range submission to the next natural {@link IIdCompressorCore.takeNextCreationRange} call.
113
+ */
114
+ resetUnfinalizedCreationRange(): void;
87
115
  /**
88
116
  * Finalizes the supplied range of IDs (which may be from either a remote or local session).
89
117
  * @param range - the range of session-local IDs to finalize.
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../../src/types/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,mBAAmB,EACnB,SAAS,EACT,wBAAwB,EACxB,QAAQ,EACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACX,eAAe,EACf,mCAAmC,EACnC,wCAAwC,EACxC,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;;;;;;;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AAC,EAAE,EAAE,wBAAwB,GAAG,mBAAmB,CAAC;IAEtE;;;;;;;OAOG;IACH,uBAAuB,CACtB,EAAE,EAAE,mBAAmB,EACvB,eAAe,EAAE,SAAS,GACxB,wBAAwB,CAAC;IAE5B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,EAAE,wBAAwB,GAAG,QAAQ,CAAC;IAEnD;;;;;OAKG;IACH,UAAU,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB,CAAC;IAE7D;;;;OAIG;IACH,aAAa,CAAC,YAAY,EAAE,QAAQ,GAAG,wBAAwB,GAAG,SAAS,CAAC;CAC5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/types/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 type {\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./identifiers.js\";\nimport type {\n\tIdCreationRange,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types/index.js\";\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 * @legacy @beta\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 a\n\t * range was taken (via this method or `takeUnfinalizedCreationRange`).\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 * 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 unfinalized IDs generated via calls to `generateCompressedId`.\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 * Note: after finalizing the range returned by this method, finalizing any ranges that had been previously taken\n\t * will result in an error.\n\t */\n\ttakeUnfinalizedCreationRange(): 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 * Run a callback that is performed from the perspective of a special \"ghost\" session.\n\t * Any ids generated by this session will be immediately finalized on the local client as if\n\t * they were created by a remote client with `ghostSessionId`.\n\t *\n\t * *WARNING:* This API requires an external consensus mechanism to safely use:\n\t * In an attached container (i.e. multiple clients may have the document loaded), all clients must guarantee that:\n\t * - They invoke this API starting from the same finalized creation ranges\n\t * - This API is invoked with the same ghost session id\n\t * - `ghostSessionCallback` deterministically mints the same number of ids on each client within the ghost session\n\t * Failure to meet these requirement will result in divergence across clients and eventual consistency errors.\n\t * While the ghost sesion callback is running, IdCompressor does not support serialization.\n\t * @remarks This API is primarily intended for data migration scenarios which are able to deterministically transform\n\t * data in some format into data in a new format.\n\t * The first requirement (that all clients must invoke the API with the same finalized creation ranges) is guaranteed\n\t * for this scenario because the data transformation callback occurs at a specific ack within the op stream on all\n\t * clients, and clients don't finalize creation ranges for local changes they might have at this point in time.\n\t * @param ghostSessionId - The session id that minted ids generated within `ghostSessionCallback` should be attributed to.\n\t * @param ghostSessionCallback - Callback which mints ids attributed to the ghost session.\n\t */\n\tbeginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): 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 * `IdCompressor` offers the ability to generate arbitrary non-colliding v4 UUIDs, called stable IDs, while compressing them into small integers\n * for efficient storage and transmission. It also provides the ability to decompress these integers back into their original UUIDs.\n *\n * The compressor is designed to be used in a distributed environment, where multiple clients may be generating IDs concurrently.\n * IDs generated by a compressor, via calls to `generateCompressedId`, are created in the compressor's \"local\" session.\n * These IDs are unique within the session, but may not be unique across sessions. In the context of Fluid, the scope of a session\n * is the same as the scope of a container. This means that anytime IDs are transferred between sessions, they must be translated\n * through a process called \"normalization\":\n * - The scope of a local session (in which local IDs are unique) is called the \"session space\" of the client.\n * - The context of persisted state (in Fluid, this is the context of ops and summaries) is called \"op space\".\n * - `SessionSpaceCompressedId`s, generated via calls to `generateCompressedId`, should NEVER be serialized directly.\n * In Fluid, this means they should not be included in ops or summaries.\n * - Before serialization, IDs must be normalized to op space to ensure they are interpretable by other clients.\n * - Upon receipt, IDs should be normalized back to session space before use.\n *\n * Example Usage:\n *\n * ### Client A (Sender)\n *\n * ```typescript\n * // Generate several local IDs\n * const localId1 = idCompressor.generateCompressedId();\n * const localId2 = idCompressor.generateCompressedId();\n * const localId3 = idCompressor.generateCompressedId();\n *\n * // Normalize these IDs to op space for inclusion in a message\n * const opSpaceId1 = idCompressor.normalizeToOpSpace(localId1);\n * const opSpaceId2 = idCompressor.normalizeToOpSpace(localId2);\n * const opSpaceId3 = idCompressor.normalizeToOpSpace(localId3);\n *\n * // Create and send a message containing these op space IDs along with the sender's session ID\n * // In Fluid, this would be an op or summary\n * const message = {\n * sessionID: idCompressor.localSessionId,\n * ids: [opSpaceId1, opSpaceId2, opSpaceId3]\n * };\n * ```\n *\n * ### Client B (Receiver)\n *\n * ```typescript\n * // Receive the message from Client A\n * const receivedMessage = ...; // In Fluid, this would be an op or summary\n *\n * // Normalize the received IDs back to session space, utilizing the sender's session ID\n * const sessionSpaceId1 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[0], receivedMessage.sessionID);\n * const sessionSpaceId2 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[1], receivedMessage.sessionID);\n * const sessionSpaceId3 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[2], receivedMessage.sessionID);\n * ```\n * @public\n */\nexport interface IIdCompressor {\n\t/**\n\t * The local session ID.\n\t */\n\tlocalSessionId: SessionId;\n\n\t/**\n\t * Generates a new compressed ID.\n\t * The returned ID is in session space and should not be serialized directly. See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateCompressedId(): SessionSpaceCompressedId;\n\n\t/**\n\t * Generates a new ID that is guaranteed to be unique across all sessions known to this compressor without the need for any\n\t * normalization. The returned ID is not guaranteed to be a compressed ID (small number); it may be a stable ID (UUID string).\n\t * In Fluid, the likelihood of generating the bulkier stable ID is dictated by network conditions and is highly probably in\n\t * scenarios such as offline. This is still useful for use cases where simplicity is more important than performance and\n\t * this approach will often be superior to generating a UUID.\n\t * If small numbers are a requirement, `generateCompressedId` and normalization should be used instead.\n\t * See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateDocumentUniqueId(): (SessionSpaceCompressedId & OpSpaceCompressedId) | StableId;\n\n\t/**\n\t * Normalizes a session space ID into op space.\n\t * The returned ID is in op space and can be safely serialized. However, it should be normalized back to session space before use.\n\t * See `IIdCompressor` for more details.\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\n\t/**\n\t * Normalizes an ID into session space.\n\t * @param id - The ID to normalize.\n\t * @param originSessionId - The session from which `id` originated. This should be the ID of the client that normalized `id` to op space.\n\t * This means that it may not be the client that created `id` in the first place, but rather the client that serialized it.\n\t * This is an important distinction in the case of a reference, where a client might refer to an ID created by another client.\n\t * @returns The session-space ID in the local session corresponding to `id`.\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.\n\t * @throws If the ID was not generated by any session known to 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`.\n\t * @throws If the UUID was not generated by any session known to this compressor.\n\t */\n\trecompress(uncompressed: StableId): SessionSpaceCompressedId;\n\n\t/**\n\t * Attempts to recompress a UUID.\n\t * @param uncompressed - The UUID to recompress.\n\t * @returns The `CompressedId` associated with `uncompressed` or undefined if the UUID was not generated by any session known to this compressor.\n\t */\n\ttryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;\n}\n"]}
1
+ {"version":3,"file":"idCompressor.js","sourceRoot":"","sources":["../../src/types/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 type {\n\tOpSpaceCompressedId,\n\tSessionId,\n\tSessionSpaceCompressedId,\n\tStableId,\n} from \"./identifiers.js\";\nimport type {\n\tIdCreationRange,\n\tSerializedIdCompressorWithNoSession,\n\tSerializedIdCompressorWithOngoingSession,\n} from \"./persisted-types/index.js\";\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 * @privateremarks To be made internal in 2.100.0\n *\n * @deprecated `IIdCompressorCore` will be removed from the public API in 2.100.0.\n *\n * - If you use `serialize()`, use the free function\n * {@link (serializeIdCompressor:1) | serializeIdCompressor(compressor, withSession)} instead.\n *\n * - `takeNextCreationRange`, `takeUnfinalizedCreationRange`, `finalizeCreationRange`, and\n * `beginGhostSession` are internal runtime operations. External consumers should not call\n * them directly. If you depend on these APIs, please file an issue on the FluidFramework\n * repository describing your use case.\n *\n * @legacy @beta\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 a\n\t * range was taken (via this method or `takeUnfinalizedCreationRange`).\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 * 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 unfinalized IDs generated via calls to `generateCompressedId`.\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 * Note: after finalizing the range returned by this method, finalizing any ranges that had been previously taken\n\t * will result in an error.\n\t */\n\ttakeUnfinalizedCreationRange(): IdCreationRange;\n\n\t/**\n\t * Resets the next creation range to include all unfinalized IDs.\n\t *\n\t * @remarks\n\t * IMPORTANT: This must only be called if it's CERTAIN that the unfinalized range will never be finalized as-is (e.g. by in-flight ops).\n\t *\n\t * After calling this, the next call to {@link IIdCompressorCore.takeNextCreationRange} will produce a range\n\t * covering all unfinalized IDs (equivalent to what {@link IIdCompressorCore.takeUnfinalizedCreationRange} would\n\t * have returned) plus any IDs generated after this call.\n\t *\n\t * Unlike {@link IIdCompressorCore.takeUnfinalizedCreationRange}, this method does not produce or return a range,\n\t * and does not advance the internal range counter. It is useful when the caller wants to\n\t * defer the actual range submission to the next natural {@link IIdCompressorCore.takeNextCreationRange} call.\n\t */\n\tresetUnfinalizedCreationRange(): void;\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 * Run a callback that is performed from the perspective of a special \"ghost\" session.\n\t * Any ids generated by this session will be immediately finalized on the local client as if\n\t * they were created by a remote client with `ghostSessionId`.\n\t *\n\t * *WARNING:* This API requires an external consensus mechanism to safely use:\n\t * In an attached container (i.e. multiple clients may have the document loaded), all clients must guarantee that:\n\t * - They invoke this API starting from the same finalized creation ranges\n\t * - This API is invoked with the same ghost session id\n\t * - `ghostSessionCallback` deterministically mints the same number of ids on each client within the ghost session\n\t * Failure to meet these requirement will result in divergence across clients and eventual consistency errors.\n\t * While the ghost sesion callback is running, IdCompressor does not support serialization.\n\t * @remarks This API is primarily intended for data migration scenarios which are able to deterministically transform\n\t * data in some format into data in a new format.\n\t * The first requirement (that all clients must invoke the API with the same finalized creation ranges) is guaranteed\n\t * for this scenario because the data transformation callback occurs at a specific ack within the op stream on all\n\t * clients, and clients don't finalize creation ranges for local changes they might have at this point in time.\n\t * @param ghostSessionId - The session id that minted ids generated within `ghostSessionCallback` should be attributed to.\n\t * @param ghostSessionCallback - Callback which mints ids attributed to the ghost session.\n\t */\n\tbeginGhostSession(ghostSessionId: SessionId, ghostSessionCallback: () => void): 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 * `IdCompressor` offers the ability to generate arbitrary non-colliding v4 UUIDs, called stable IDs, while compressing them into small integers\n * for efficient storage and transmission. It also provides the ability to decompress these integers back into their original UUIDs.\n *\n * The compressor is designed to be used in a distributed environment, where multiple clients may be generating IDs concurrently.\n * IDs generated by a compressor, via calls to `generateCompressedId`, are created in the compressor's \"local\" session.\n * These IDs are unique within the session, but may not be unique across sessions. In the context of Fluid, the scope of a session\n * is the same as the scope of a container. This means that anytime IDs are transferred between sessions, they must be translated\n * through a process called \"normalization\":\n * - The scope of a local session (in which local IDs are unique) is called the \"session space\" of the client.\n * - The context of persisted state (in Fluid, this is the context of ops and summaries) is called \"op space\".\n * - `SessionSpaceCompressedId`s, generated via calls to `generateCompressedId`, should NEVER be serialized directly.\n * In Fluid, this means they should not be included in ops or summaries.\n * - Before serialization, IDs must be normalized to op space to ensure they are interpretable by other clients.\n * - Upon receipt, IDs should be normalized back to session space before use.\n *\n * Example Usage:\n *\n * ### Client A (Sender)\n *\n * ```typescript\n * // Generate several local IDs\n * const localId1 = idCompressor.generateCompressedId();\n * const localId2 = idCompressor.generateCompressedId();\n * const localId3 = idCompressor.generateCompressedId();\n *\n * // Normalize these IDs to op space for inclusion in a message\n * const opSpaceId1 = idCompressor.normalizeToOpSpace(localId1);\n * const opSpaceId2 = idCompressor.normalizeToOpSpace(localId2);\n * const opSpaceId3 = idCompressor.normalizeToOpSpace(localId3);\n *\n * // Create and send a message containing these op space IDs along with the sender's session ID\n * // In Fluid, this would be an op or summary\n * const message = {\n * sessionID: idCompressor.localSessionId,\n * ids: [opSpaceId1, opSpaceId2, opSpaceId3]\n * };\n * ```\n *\n * ### Client B (Receiver)\n *\n * ```typescript\n * // Receive the message from Client A\n * const receivedMessage = ...; // In Fluid, this would be an op or summary\n *\n * // Normalize the received IDs back to session space, utilizing the sender's session ID\n * const sessionSpaceId1 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[0], receivedMessage.sessionID);\n * const sessionSpaceId2 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[1], receivedMessage.sessionID);\n * const sessionSpaceId3 = idCompressor.normalizeToSessionSpace(receivedMessage.ids[2], receivedMessage.sessionID);\n * ```\n * @public\n */\nexport interface IIdCompressor {\n\t/**\n\t * The local session ID.\n\t */\n\tlocalSessionId: SessionId;\n\n\t/**\n\t * Generates a new compressed ID.\n\t * The returned ID is in session space and should not be serialized directly. See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateCompressedId(): SessionSpaceCompressedId;\n\n\t/**\n\t * Generates a new ID that is guaranteed to be unique across all sessions known to this compressor without the need for any\n\t * normalization. The returned ID is not guaranteed to be a compressed ID (small number); it may be a stable ID (UUID string).\n\t * In Fluid, the likelihood of generating the bulkier stable ID is dictated by network conditions and is highly probably in\n\t * scenarios such as offline. This is still useful for use cases where simplicity is more important than performance and\n\t * this approach will often be superior to generating a UUID.\n\t * If small numbers are a requirement, `generateCompressedId` and normalization should be used instead.\n\t * See `IIdCompressor` for more details.\n\t * @returns A new local ID in session space.\n\t */\n\tgenerateDocumentUniqueId(): (SessionSpaceCompressedId & OpSpaceCompressedId) | StableId;\n\n\t/**\n\t * Normalizes a session space ID into op space.\n\t * The returned ID is in op space and can be safely serialized. However, it should be normalized back to session space before use.\n\t * See `IIdCompressor` for more details.\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\n\t/**\n\t * Normalizes an ID into session space.\n\t * @param id - The ID to normalize.\n\t * @param originSessionId - The session from which `id` originated. This should be the ID of the client that normalized `id` to op space.\n\t * This means that it may not be the client that created `id` in the first place, but rather the client that serialized it.\n\t * This is an important distinction in the case of a reference, where a client might refer to an ID created by another client.\n\t * @returns The session-space ID in the local session corresponding to `id`.\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.\n\t * @throws If the ID was not generated by any session known to 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`.\n\t * @throws If the UUID was not generated by any session known to this compressor.\n\t */\n\trecompress(uncompressed: StableId): SessionSpaceCompressedId;\n\n\t/**\n\t * Attempts to recompress a UUID.\n\t * @param uncompressed - The UUID to recompress.\n\t * @returns The `CompressedId` associated with `uncompressed` or undefined if the UUID was not generated by any session known to this compressor.\n\t */\n\ttryRecompress(uncompressed: StableId): SessionSpaceCompressedId | undefined;\n}\n"]}
package/eslint.config.mts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import type { Linter } from "eslint";
7
- import { recommended } from "../../../common/build/eslint-config-fluid/flat.mts";
7
+ import { recommended } from "@fluidframework/eslint-config-fluid/flat.mts";
8
8
 
9
9
  const config: Linter.Config[] = [
10
10
  ...recommended,
package/internal.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/index.js";
package/legacy.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
8
+ * Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/legacy.js";
@@ -20,6 +20,12 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
20
20
  private readonly localSession;
21
21
  private readonly normalizer;
22
22
  private localGenCount;
23
+ /**
24
+ * The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.
25
+ * This is advanced to `generatedIdCount` + 1 each time it is called.
26
+ * On the other hand, when `resetUnfinalizedCreationRange` is called,
27
+ * this is moved back to the start of the unfinalized range, to ensure those IDs are included in the next range.
28
+ */
23
29
  private nextRangeBaseGenCount;
24
30
  private readonly sessions;
25
31
  private readonly finalSpace;
@@ -48,6 +54,7 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
48
54
  private generateNextLocalId;
49
55
  takeNextCreationRange(): IdCreationRange;
50
56
  takeUnfinalizedCreationRange(): IdCreationRange;
57
+ resetUnfinalizedCreationRange(): void;
51
58
  private updateToRange;
52
59
  private static assertValidRange;
53
60
  finalizeCreationRange(range: IdCreationRange): void;
@@ -73,23 +80,83 @@ export declare class IdCompressor implements IIdCompressor, IIdCompressorCore {
73
80
  }
74
81
  /**
75
82
  * Create a new {@link IIdCompressor}.
83
+ *
84
+ * @remarks
85
+ * The returned compressor previously also implemented {@link IIdCompressorCore}, but that
86
+ * interface is {@link IIdCompressorCore | deprecated} and will be removed from the return
87
+ * type in a future release. Consumers should type variables as {@link IIdCompressor} and
88
+ * use {@link (serializeIdCompressor:1)} for serialization instead of calling `serialize()` directly.
89
+ *
76
90
  * @legacy @beta
77
91
  */
78
92
  export declare function createIdCompressor(logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
79
93
  /**
80
94
  * Create a new {@link IIdCompressor}.
81
95
  * @param sessionId - The seed ID for the compressor.
96
+ *
97
+ * @remarks
98
+ * The returned compressor previously also implemented {@link IIdCompressorCore}, but that
99
+ * interface is {@link IIdCompressorCore | deprecated} and will be removed from the return
100
+ * type in a future release. Consumers should type variables as {@link IIdCompressor} and
101
+ * use {@link (serializeIdCompressor:1)} for serialization instead of calling `serialize()` directly.
102
+ *
82
103
  * @legacy @beta
83
104
  */
84
105
  export declare function createIdCompressor(sessionId: SessionId, logger?: ITelemetryBaseLogger): IIdCompressor & IIdCompressorCore;
85
106
  /**
86
107
  * Deserializes the supplied state into an ID compressor.
108
+ *
109
+ * @remarks
110
+ * The returned compressor previously also implemented {@link IIdCompressorCore}, but that
111
+ * interface is {@link IIdCompressorCore | deprecated} and will be removed from the return
112
+ * type in a future release. Consumers should type variables as {@link IIdCompressor} and
113
+ * use {@link (serializeIdCompressor:1)} for serialization instead of calling `serialize()` directly.
114
+ *
87
115
  * @legacy @beta
88
116
  */
89
117
  export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithOngoingSession, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
90
118
  /**
91
119
  * Deserializes the supplied state into an ID compressor.
120
+ *
121
+ * @remarks
122
+ * The returned compressor previously also implemented {@link IIdCompressorCore}, but that
123
+ * interface is {@link IIdCompressorCore | deprecated} and will be removed from the return
124
+ * type in a future release. Consumers should type variables as {@link IIdCompressor} and
125
+ * use {@link (serializeIdCompressor:1)} for serialization instead of calling `serialize()` directly.
126
+ *
92
127
  * @legacy @beta
93
128
  */
94
129
  export declare function deserializeIdCompressor(serialized: SerializedIdCompressorWithNoSession, newSessionId: SessionId, logger?: ITelemetryLoggerExt): IIdCompressor & IIdCompressorCore;
130
+ /**
131
+ * Serializes an ID compressor.
132
+ * @param compressor - The compressor to serialize.
133
+ * @param withSession - If true, the serialized state will include local session
134
+ * state (for stashing). If false, only finalized state is included (for summaries).
135
+ * @legacy @beta
136
+ */
137
+ export declare function serializeIdCompressor(compressor: IIdCompressor, withSession: true): SerializedIdCompressorWithOngoingSession;
138
+ /**
139
+ * Serializes an ID compressor.
140
+ * @param compressor - The compressor to serialize.
141
+ * @param withSession - If true, the serialized state will include local session
142
+ * state (for stashing). If false, only finalized state is included (for summaries).
143
+ * @legacy @beta
144
+ */
145
+ export declare function serializeIdCompressor(compressor: IIdCompressor, withSession: false): SerializedIdCompressorWithNoSession;
146
+ /**
147
+ * Casts an {@link IIdCompressor} to include {@link IIdCompressorCore}.
148
+ *
149
+ * @remarks
150
+ * Compressors returned by `createIdCompressor` and `deserializeIdCompressor`
151
+ * always implement both {@link IIdCompressor} and {@link IIdCompressorCore}, but their
152
+ * return types will be narrowed to {@link IIdCompressor} to keep {@link IIdCompressorCore}
153
+ * out of the `@legacy` API surface. Internal consumers that need access to core
154
+ * compressor operations (serialization, range management, etc.) should use this function.
155
+ *
156
+ * @param compressor - A compressor created by `createIdCompressor` or
157
+ * `deserializeIdCompressor`.
158
+ * @returns The same compressor, typed to include {@link IIdCompressorCore}.
159
+ * @internal
160
+ */
161
+ export declare function toIdCompressorWithCore(compressor: IIdCompressor): IIdCompressor & IIdCompressorCore;
95
162
  //# sourceMappingURL=idCompressor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"idCompressor.d.ts","sourceRoot":"","sources":["../src/idCompressor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,0CAA0C,CAAC;AASlD,OAAO,EACN,KAAK,KAAK,EAOV,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGN,QAAQ,EAKR,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACX,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EAEnB,mCAAmC,EACnC,wCAAwC,EACxC,SAAS,EACT,wBAAwB,EACxB,QAAQ,EACR,MAAM,kBAAkB,CAAC;AAwB1B;;GAEG;AACH,qBAAa,YAAa,YAAW,aAAa,EAAE,iBAAiB;IA+CnE,OAAO,CAAC,QAAQ,CAAC,MAAM;IA9CxB;;OAEG;IACH,gBAAuB,cAAc,SAAW;IAIhD,SAAgB,cAAc,EAAE,SAAS,CAAC;IAC1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgC;IAE3D,OAAO,CAAC,aAAa,CAAK;IAQ1B,OAAO,CAAC,qBAAqB,CAAK;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;IAM/C;;;;;OAKG;IAEH,OAAO,CAAC,wBAAwB,CAAe;IAE/C,OAAO,CAAC,qBAAqB,CAAK;IAElC,OAAO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;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,wCAAwC,EACpD,MAAM,CAAC,EAAE,mBAAmB,GAE1B,aAAa,GAAG,iBAAiB,CAAC;AACrC;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACtC,UAAU,EAAE,mCAAmC,EAC/C,YAAY,EAAE,SAAS,EACvB,MAAM,CAAC,EAAE,mBAAmB,GAE1B,aAAa,GAAG,iBAAiB,CAAC;AAyBrC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,IAAI,GACf,wCAAwC,CAAC;AAC5C;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,aAAa,EACzB,WAAW,EAAE,KAAK,GAChB,mCAAmC,CAAC;AASvC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,UAAU,EAAE,aAAa,GAEvB,aAAa,GAAG,iBAAiB,CAOnC"}
@@ -25,6 +25,7 @@ function rangeFinalizationError(expectedStart, actualStart) {
25
25
  /**
26
26
  * See {@link IIdCompressor} and {@link IIdCompressorCore}
27
27
  */
28
+ // eslint-disable-next-line import-x/no-deprecated -- Will be undeprecated in 2.100.0 when it becomes an internal API
28
29
  export class IdCompressor {
29
30
  // #endregion
30
31
  constructor(localSessionIdOrDeserialized, logger) {
@@ -34,8 +35,12 @@ export class IdCompressor {
34
35
  this.localGenCount = 0;
35
36
  // #endregion
36
37
  // #region Final state
37
- // The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.
38
- // This is updated to be equal to `generatedIdCount` + 1 each time it is called.
38
+ /**
39
+ * The gen count to be annotated on the range returned by the next call to `takeNextCreationRange`.
40
+ * This is advanced to `generatedIdCount` + 1 each time it is called.
41
+ * On the other hand, when `resetUnfinalizedCreationRange` is called,
42
+ * this is moved back to the start of the unfinalized range, to ensure those IDs are included in the next range.
43
+ */
39
44
  this.nextRangeBaseGenCount = 1;
40
45
  this.sessions = new Sessions();
41
46
  this.finalSpace = new FinalSpace();
@@ -153,32 +158,16 @@ export class IdCompressor {
153
158
  return this.updateToRange(range);
154
159
  }
155
160
  takeUnfinalizedCreationRange() {
161
+ this.resetUnfinalizedCreationRange();
162
+ return this.takeNextCreationRange();
163
+ }
164
+ resetUnfinalizedCreationRange() {
165
+ assert(!this.ongoingGhostSession, 0xcec /* IdCompressor should not be operated normally when in a ghost session */);
156
166
  const lastLocalCluster = this.localSession.getLastCluster();
157
- let count;
158
- let firstGenCount;
159
- if (lastLocalCluster === undefined) {
160
- firstGenCount = 1;
161
- count = this.localGenCount;
162
- }
163
- else {
164
- firstGenCount = genCountFromLocalId((lastLocalCluster.baseLocalId - lastLocalCluster.count));
165
- count = this.localGenCount - firstGenCount + 1;
166
- }
167
- if (count === 0) {
168
- return {
169
- sessionId: this.localSessionId,
170
- };
171
- }
172
- const range = {
173
- ids: {
174
- count,
175
- firstGenCount,
176
- localIdRanges: this.normalizer.getRangesBetween(firstGenCount, this.localGenCount),
177
- requestedClusterSize: this.nextRequestedClusterSize,
178
- },
179
- sessionId: this.localSessionId,
180
- };
181
- return this.updateToRange(range);
167
+ this.nextRangeBaseGenCount =
168
+ lastLocalCluster === undefined
169
+ ? 1
170
+ : genCountFromLocalId((lastLocalCluster.baseLocalId - lastLocalCluster.count));
182
171
  }
183
172
  updateToRange(range) {
184
173
  this.nextRangeBaseGenCount = this.localGenCount + 1;
@@ -588,4 +577,28 @@ export function deserializeIdCompressor(serialized, sessionIdOrLogger, loggerOrU
588
577
  logger: sessionIdOrLogger,
589
578
  });
590
579
  }
580
+ export function serializeIdCompressor(compressor, withSession) {
581
+ const core = toIdCompressorWithCore(compressor);
582
+ return withSession ? core.serialize(true) : core.serialize(false);
583
+ }
584
+ /**
585
+ * Casts an {@link IIdCompressor} to include {@link IIdCompressorCore}.
586
+ *
587
+ * @remarks
588
+ * Compressors returned by `createIdCompressor` and `deserializeIdCompressor`
589
+ * always implement both {@link IIdCompressor} and {@link IIdCompressorCore}, but their
590
+ * return types will be narrowed to {@link IIdCompressor} to keep {@link IIdCompressorCore}
591
+ * out of the `@legacy` API surface. Internal consumers that need access to core
592
+ * compressor operations (serialization, range management, etc.) should use this function.
593
+ *
594
+ * @param compressor - A compressor created by `createIdCompressor` or
595
+ * `deserializeIdCompressor`.
596
+ * @returns The same compressor, typed to include {@link IIdCompressorCore}.
597
+ * @internal
598
+ */
599
+ export function toIdCompressorWithCore(compressor) {
600
+ assert("serialize" in compressor, 0xced /* Expected compressor to implement IIdCompressorCore */);
601
+ // eslint-disable-next-line import-x/no-deprecated -- Will be undeprecated in 2.100.0 when it becomes an internal API
602
+ return compressor;
603
+ }
591
604
  //# sourceMappingURL=idCompressor.js.map