@fluidframework/id-compressor 2.33.0-333010 → 2.33.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.
Files changed (42) hide show
  1. package/.eslintrc.cjs +5 -2
  2. package/CHANGELOG.md +4 -0
  3. package/api-report/id-compressor.legacy.alpha.api.md +10 -10
  4. package/dist/packageVersion.d.ts +1 -1
  5. package/dist/packageVersion.d.ts.map +1 -1
  6. package/dist/packageVersion.js +1 -1
  7. package/dist/packageVersion.js.map +1 -1
  8. package/dist/test/appendOnlySortedMap.spec.js.map +1 -1
  9. package/dist/test/idCompressor.spec.js.map +1 -1
  10. package/dist/test/idCompressorTestUtilities.d.ts +14 -0
  11. package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
  12. package/dist/test/idCompressorTestUtilities.js +40 -17
  13. package/dist/test/idCompressorTestUtilities.js.map +1 -1
  14. package/dist/test/index.d.ts +1 -1
  15. package/dist/test/index.d.ts.map +1 -1
  16. package/dist/test/index.js +2 -1
  17. package/dist/test/index.js.map +1 -1
  18. package/dist/test/numericUuid.spec.js.map +1 -1
  19. package/dist/test/sessionSpaceNormalizer.spec.js.map +1 -1
  20. package/dist/test/snapshots/summary.spec.js.map +1 -1
  21. package/lib/packageVersion.d.ts +1 -1
  22. package/lib/packageVersion.d.ts.map +1 -1
  23. package/lib/packageVersion.js +1 -1
  24. package/lib/packageVersion.js.map +1 -1
  25. package/lib/test/appendOnlySortedMap.spec.js.map +1 -1
  26. package/lib/test/idCompressor.spec.js.map +1 -1
  27. package/lib/test/idCompressorTestUtilities.d.ts +14 -0
  28. package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
  29. package/lib/test/idCompressorTestUtilities.js +37 -16
  30. package/lib/test/idCompressorTestUtilities.js.map +1 -1
  31. package/lib/test/index.d.ts +1 -1
  32. package/lib/test/index.d.ts.map +1 -1
  33. package/lib/test/index.js +1 -1
  34. package/lib/test/index.js.map +1 -1
  35. package/lib/test/numericUuid.spec.js.map +1 -1
  36. package/lib/test/sessionSpaceNormalizer.spec.js.map +1 -1
  37. package/lib/test/snapshots/summary.spec.js.map +1 -1
  38. package/lib/tsdoc-metadata.json +1 -1
  39. package/package.json +9 -10
  40. package/src/packageVersion.ts +1 -1
  41. package/src/test/idCompressorTestUtilities.ts +41 -18
  42. package/src/test/index.ts +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/id-compressor",
3
- "version": "2.33.0-333010",
3
+ "version": "2.33.1",
4
4
  "description": "ID compressor",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -81,25 +81,25 @@
81
81
  "temp-directory": "nyc/.nyc_output"
82
82
  },
83
83
  "dependencies": {
84
- "@fluid-internal/client-utils": "2.33.0-333010",
85
- "@fluidframework/core-interfaces": "2.33.0-333010",
86
- "@fluidframework/core-utils": "2.33.0-333010",
87
- "@fluidframework/telemetry-utils": "2.33.0-333010",
84
+ "@fluid-internal/client-utils": "~2.33.1",
85
+ "@fluidframework/core-interfaces": "~2.33.1",
86
+ "@fluidframework/core-utils": "~2.33.1",
87
+ "@fluidframework/telemetry-utils": "~2.33.1",
88
88
  "@tylerbu/sorted-btree-es6": "^1.8.0",
89
89
  "uuid": "^9.0.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@arethetypeswrong/cli": "^0.17.1",
93
93
  "@biomejs/biome": "~1.9.3",
94
- "@fluid-internal/mocha-test-setup": "2.33.0-333010",
95
- "@fluid-private/stochastic-test-utils": "2.33.0-333010",
94
+ "@fluid-internal/mocha-test-setup": "~2.33.1",
95
+ "@fluid-private/stochastic-test-utils": "~2.33.1",
96
96
  "@fluid-tools/benchmark": "^0.50.0",
97
97
  "@fluid-tools/build-cli": "^0.55.0",
98
98
  "@fluidframework/build-common": "^2.0.3",
99
99
  "@fluidframework/build-tools": "^0.55.0",
100
100
  "@fluidframework/eslint-config-fluid": "^5.7.3",
101
- "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.31.0",
102
- "@microsoft/api-extractor": "7.50.1",
101
+ "@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.33.0",
102
+ "@microsoft/api-extractor": "7.52.5",
103
103
  "@types/mocha": "^10.0.10",
104
104
  "@types/node": "^18.19.0",
105
105
  "@types/uuid": "^9.0.2",
@@ -110,7 +110,6 @@
110
110
  "eslint": "~8.55.0",
111
111
  "mocha": "^10.8.2",
112
112
  "mocha-multi-reporters": "^1.5.1",
113
- "moment": "^2.21.0",
114
113
  "rimraf": "^4.4.0",
115
114
  "typescript": "~5.4.5"
116
115
  },
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/id-compressor";
9
- export const pkgVersion = "2.33.0-333010";
9
+ export const pkgVersion = "2.33.1";
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- // eslint-disable-next-line import/no-nodejs-modules
7
6
  import { strict as assert } from "node:assert";
8
7
 
9
8
  import {
@@ -114,12 +113,46 @@ export class CompressorFactory {
114
113
  logger?: ITelemetryBaseLogger,
115
114
  ): IdCompressor {
116
115
  const compressor = createIdCompressor(sessionId, logger) as IdCompressor;
117
- // eslint-disable-next-line @typescript-eslint/dot-notation
118
- compressor["nextRequestedClusterSize"] = clusterCapacity;
116
+ modifyClusterSize(compressor, clusterCapacity);
119
117
  return compressor;
120
118
  }
121
119
  }
122
120
 
121
+ /**
122
+ * Modify the requested cluster size of the provided compressor.
123
+ * @remarks
124
+ * This is useful for testing purposes for a few reasons:
125
+ * - Id compressor bugs are often related to edge cases that occur on cluster boundaries
126
+ * - Smaller cluster sizes can enable writing tests without for loops generating "ids until a new cluster is created"
127
+ */
128
+ export function modifyClusterSize(compressor: IIdCompressor, newClusterSize: number): void {
129
+ verifyCompressorLike(compressor);
130
+ // eslint-disable-next-line @typescript-eslint/dot-notation
131
+ compressor["nextRequestedClusterSize"] = newClusterSize;
132
+ }
133
+
134
+ /**
135
+ * Returns the current cluster size of the compressor.
136
+ * @privateRemarks
137
+ * This is useful in writing tests to avoid having to hardcode the (currently constant) cluster size.
138
+ */
139
+ export function getClusterSize(compressor: ReadonlyIdCompressor): number {
140
+ verifyCompressorLike(compressor);
141
+ // eslint-disable-next-line @typescript-eslint/dot-notation
142
+ return compressor["nextRequestedClusterSize"] as number;
143
+ }
144
+
145
+ function verifyCompressorLike(compressor: ReadonlyIdCompressor | IIdCompressor): void {
146
+ assert(
147
+ // Some IdCompressor tests wrap underlying compressors with proxies--allow this for now.
148
+ // Because of id-compressor's dynamic import in container-runtime, instanceof checks for IdCompressor
149
+ // also won't necessarily work nicely. Get a small amount of validation that this function should work
150
+ // as intended by at least verifying the property name exists.
151
+ // eslint-disable-next-line @typescript-eslint/dot-notation
152
+ typeof compressor["nextRequestedClusterSize"] === "number",
153
+ );
154
+ }
155
+
123
156
  /**
124
157
  * Utility for building a huge compressor.
125
158
  * Build via the compressor factory.
@@ -311,7 +344,7 @@ export class IdCompressorTestNetwork {
311
344
  * Changes the capacity request amount for a client. It will take effect immediately.
312
345
  */
313
346
  public changeCapacity(client: Client, newClusterCapacity: number): void {
314
- changeCapacity(this.compressors.get(client), newClusterCapacity);
347
+ modifyClusterSize(this.compressors.get(client), newClusterCapacity);
315
348
  }
316
349
 
317
350
  private addNewId(
@@ -362,11 +395,7 @@ export class IdCompressorTestNetwork {
362
395
  ids: {
363
396
  firstGenCount: 1,
364
397
  count: numIds,
365
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
366
- requestedClusterSize: this.getCompressor(Client.Client1)[
367
- // eslint-disable-next-line @typescript-eslint/dot-notation
368
- "nextRequestedClusterSize"
369
- ],
398
+ requestedClusterSize: getClusterSize(this.getCompressor(Client.Client1)),
370
399
  localIdRanges: [], // remote session, can safely ignore in tests
371
400
  },
372
401
  };
@@ -673,11 +702,6 @@ export class IdCompressorTestNetwork {
673
702
  }
674
703
  }
675
704
 
676
- function changeCapacity(compressor: IdCompressor, newClusterCapacity: number): void {
677
- // eslint-disable-next-line @typescript-eslint/dot-notation
678
- compressor["nextRequestedClusterSize"] = newClusterCapacity;
679
- }
680
-
681
705
  /**
682
706
  * Roundtrips the supplied compressor through serialization and deserialization.
683
707
  */
@@ -703,17 +727,16 @@ export function roundtrip(
703
727
  ] {
704
728
  // preserve the capacity request as this property is normally private and resets
705
729
  // to a default on construction (deserialization)
706
- // eslint-disable-next-line @typescript-eslint/dot-notation, @typescript-eslint/no-unsafe-assignment
707
- const capacity: number = compressor["nextRequestedClusterSize"];
730
+ const capacity: number = getClusterSize(compressor);
708
731
  if (withSession) {
709
732
  const serialized = compressor.serialize(withSession);
710
733
  const roundtripped = IdCompressor.deserialize(serialized);
711
- changeCapacity(roundtripped, capacity);
734
+ modifyClusterSize(roundtripped, capacity);
712
735
  return [serialized, roundtripped];
713
736
  } else {
714
737
  const nonLocalSerialized = compressor.serialize(withSession);
715
738
  const roundtripped = IdCompressor.deserialize(nonLocalSerialized, createSessionId());
716
- changeCapacity(roundtripped, capacity);
739
+ modifyClusterSize(roundtripped, capacity);
717
740
  return [nonLocalSerialized, roundtripped];
718
741
  }
719
742
  }
package/src/test/index.ts CHANGED
@@ -7,4 +7,7 @@
7
7
  * Exports for test utilities for `id-compressor`
8
8
  */
9
9
 
10
- export { createAlwaysFinalizedIdCompressor } from "./idCompressorTestUtilities.js";
10
+ export {
11
+ createAlwaysFinalizedIdCompressor,
12
+ modifyClusterSize,
13
+ } from "./idCompressorTestUtilities.js";