@fluidframework/id-compressor 2.0.0-rc.4.0.6 → 2.0.0-rc.5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor.json +1 -1
- package/api-report/{id-compressor.api.md → id-compressor.alpha.api.md} +1 -10
- package/api-report/id-compressor.beta.api.md +44 -0
- package/api-report/id-compressor.public.api.md +44 -0
- package/biome.jsonc +4 -0
- package/dist/appendOnlySortedMap.d.ts.map +1 -1
- package/dist/appendOnlySortedMap.js.map +1 -1
- package/dist/finalSpace.d.ts.map +1 -1
- package/dist/finalSpace.js.map +1 -1
- package/dist/idCompressor.d.ts.map +1 -1
- package/dist/idCompressor.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sessionSpaceNormalizer.d.ts.map +1 -1
- package/dist/sessionSpaceNormalizer.js.map +1 -1
- package/dist/sessions.js.map +1 -1
- package/dist/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/dist/test/appendOnlySortedMap.spec.js.map +1 -1
- package/dist/test/idCompressor.perf.spec.js.map +1 -1
- package/dist/test/idCompressor.spec.js.map +1 -1
- package/dist/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/dist/test/idCompressorTestUtilities.js +2 -3
- package/dist/test/idCompressorTestUtilities.js.map +1 -1
- package/dist/test/numericUuid.spec.js.map +1 -1
- package/dist/test/snapshots/summary.spec.js.map +1 -1
- package/dist/test/testCommon.d.ts +0 -3
- package/dist/test/testCommon.d.ts.map +1 -1
- package/dist/test/testCommon.js.map +1 -1
- package/dist/types/identifiers.d.ts.map +1 -1
- package/dist/types/identifiers.js.map +1 -1
- package/dist/utilities.js.map +1 -1
- package/lib/appendOnlySortedMap.d.ts.map +1 -1
- package/lib/appendOnlySortedMap.js.map +1 -1
- package/lib/finalSpace.d.ts.map +1 -1
- package/lib/finalSpace.js +1 -1
- package/lib/finalSpace.js.map +1 -1
- package/lib/idCompressor.d.ts.map +1 -1
- package/lib/idCompressor.js +1 -1
- package/lib/idCompressor.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sessionSpaceNormalizer.d.ts.map +1 -1
- package/lib/sessionSpaceNormalizer.js.map +1 -1
- package/lib/sessions.js.map +1 -1
- package/lib/test/appendOnlySortedMap.perf.spec.js.map +1 -1
- package/lib/test/appendOnlySortedMap.spec.js.map +1 -1
- package/lib/test/idCompressor.perf.spec.js.map +1 -1
- package/lib/test/idCompressor.spec.js.map +1 -1
- package/lib/test/idCompressorTestUtilities.d.ts.map +1 -1
- package/lib/test/idCompressorTestUtilities.js +2 -3
- package/lib/test/idCompressorTestUtilities.js.map +1 -1
- package/lib/test/numericUuid.spec.js.map +1 -1
- package/lib/test/snapshots/summary.spec.js.map +1 -1
- package/lib/test/testCommon.d.ts +0 -3
- package/lib/test/testCommon.d.ts.map +1 -1
- package/lib/test/testCommon.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/types/identifiers.d.ts.map +1 -1
- package/lib/types/identifiers.js.map +1 -1
- package/lib/utilities.js.map +1 -1
- package/package.json +25 -16
- package/src/appendOnlySortedMap.ts +1 -4
- package/src/finalSpace.ts +6 -1
- package/src/idCompressor.ts +23 -19
- package/src/index.ts +6 -1
- package/src/packageVersion.ts +1 -1
- package/src/sessionSpaceNormalizer.ts +4 -1
- package/src/test/idCompressorTestUtilities.ts +21 -17
- package/src/test/testCommon.ts +0 -3
- package/src/test/tsconfig.json +2 -0
- package/src/types/identifiers.ts +3 -1
- package/tsconfig.json +2 -0
- package/tsdoc.json +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/id-compressor",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.5.0.0",
|
|
4
4
|
"description": "ID compressor",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -79,29 +79,30 @@
|
|
|
79
79
|
"temp-directory": "nyc/.nyc_output"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.
|
|
83
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.
|
|
84
|
-
"@fluidframework/core-utils": ">=2.0.0-rc.
|
|
85
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-rc.
|
|
82
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
|
|
83
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
|
|
84
|
+
"@fluidframework/core-utils": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
|
|
85
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
|
|
86
86
|
"@tylerbu/sorted-btree-es6": "^1.8.0",
|
|
87
87
|
"uuid": "^9.0.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
91
|
-
"@biomejs/biome": "^1.
|
|
92
|
-
"@fluid-internal/mocha-test-setup": ">=2.0.0-rc.
|
|
93
|
-
"@fluid-private/stochastic-test-utils": ">=2.0.0-rc.
|
|
91
|
+
"@biomejs/biome": "^1.7.3",
|
|
92
|
+
"@fluid-internal/mocha-test-setup": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
|
|
93
|
+
"@fluid-private/stochastic-test-utils": ">=2.0.0-rc.5.0.0 <2.0.0-rc.5.1.0",
|
|
94
94
|
"@fluid-tools/benchmark": "^0.48.0",
|
|
95
|
-
"@fluid-tools/build-cli": "^0.
|
|
95
|
+
"@fluid-tools/build-cli": "^0.39.0",
|
|
96
96
|
"@fluidframework/build-common": "^2.0.3",
|
|
97
|
-
"@fluidframework/build-tools": "^0.
|
|
98
|
-
"@fluidframework/eslint-config-fluid": "^5.
|
|
99
|
-
"@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.0.0-rc.
|
|
100
|
-
"@microsoft/api-extractor": "^7.
|
|
97
|
+
"@fluidframework/build-tools": "^0.39.0",
|
|
98
|
+
"@fluidframework/eslint-config-fluid": "^5.3.0",
|
|
99
|
+
"@fluidframework/id-compressor-previous": "npm:@fluidframework/id-compressor@2.0.0-rc.4.0.0",
|
|
100
|
+
"@microsoft/api-extractor": "^7.45.1",
|
|
101
101
|
"@types/mocha": "^9.1.1",
|
|
102
102
|
"@types/node": "^18.19.0",
|
|
103
103
|
"@types/uuid": "^9.0.2",
|
|
104
104
|
"c8": "^8.0.1",
|
|
105
|
+
"concurrently": "^8.2.1",
|
|
105
106
|
"copyfiles": "^2.4.1",
|
|
106
107
|
"cross-env": "^7.0.3",
|
|
107
108
|
"eslint": "~8.55.0",
|
|
@@ -111,7 +112,7 @@
|
|
|
111
112
|
"moment": "^2.21.0",
|
|
112
113
|
"prettier": "~3.0.3",
|
|
113
114
|
"rimraf": "^4.4.0",
|
|
114
|
-
"typescript": "~5.
|
|
115
|
+
"typescript": "~5.4.5"
|
|
115
116
|
},
|
|
116
117
|
"typeValidation": {
|
|
117
118
|
"broken": {}
|
|
@@ -130,13 +131,21 @@
|
|
|
130
131
|
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
131
132
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
132
133
|
"check:are-the-types-wrong": "attw --pack . --exclude-entrypoints ./internal/test-utils",
|
|
134
|
+
"check:biome": "biome check . --formatter-enabled=true",
|
|
135
|
+
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
136
|
+
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
137
|
+
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
|
|
138
|
+
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
|
|
139
|
+
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
|
|
140
|
+
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
141
|
+
"check:format": "npm run check:biome",
|
|
133
142
|
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
134
|
-
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
135
143
|
"ci:build:docs": "api-extractor run",
|
|
136
144
|
"clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
137
145
|
"eslint": "eslint --format stylish src",
|
|
138
146
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
139
|
-
"format": "
|
|
147
|
+
"format": "npm run format:biome",
|
|
148
|
+
"format:biome": "biome check . --formatter-enabled=true --apply",
|
|
140
149
|
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
141
150
|
"lint": "fluid-build . --task lint",
|
|
142
151
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
@@ -234,10 +234,7 @@ export class AppendOnlySortedMap<K, V> {
|
|
|
234
234
|
let prev: readonly [K, unknown] | undefined;
|
|
235
235
|
for (const kv of this.entries()) {
|
|
236
236
|
if (prev !== undefined) {
|
|
237
|
-
assert(
|
|
238
|
-
this.comparator(kv[0], prev[0]) > 0,
|
|
239
|
-
0x752 /* Keys in map must be sorted. */,
|
|
240
|
-
);
|
|
237
|
+
assert(this.comparator(kv[0], prev[0]) > 0, 0x752 /* Keys in map must be sorted. */);
|
|
241
238
|
}
|
|
242
239
|
prev = kv;
|
|
243
240
|
}
|
package/src/finalSpace.ts
CHANGED
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
|
|
8
8
|
import { FinalCompressedId } from "./identifiers.js";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
IdCluster,
|
|
11
|
+
clustersEqual,
|
|
12
|
+
lastAllocatedFinal,
|
|
13
|
+
lastFinalizedFinal,
|
|
14
|
+
} from "./sessions.js";
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
17
|
* All IDs that have been finalized (acked), grouped into clusters sorted by their base final IDs.
|
package/src/idCompressor.ts
CHANGED
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
} from "@fluidframework/telemetry-utils/internal";
|
|
14
14
|
|
|
15
15
|
import { FinalSpace } from "./finalSpace.js";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
FinalCompressedId,
|
|
18
|
+
LocalCompressedId,
|
|
19
|
+
NumericUuid,
|
|
20
|
+
isFinalId,
|
|
21
|
+
} from "./identifiers.js";
|
|
17
22
|
import {
|
|
18
23
|
Index,
|
|
19
24
|
readBoolean,
|
|
@@ -178,7 +183,9 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
178
183
|
}
|
|
179
184
|
}
|
|
180
185
|
|
|
181
|
-
public generateDocumentUniqueId():
|
|
186
|
+
public generateDocumentUniqueId():
|
|
187
|
+
| (SessionSpaceCompressedId & OpSpaceCompressedId)
|
|
188
|
+
| StableId {
|
|
182
189
|
const id = this.generateCompressedId();
|
|
183
190
|
return isFinalId(id) ? id : this.decompress(id);
|
|
184
191
|
}
|
|
@@ -387,7 +394,10 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
387
394
|
capacity,
|
|
388
395
|
0,
|
|
389
396
|
);
|
|
390
|
-
assert(
|
|
397
|
+
assert(
|
|
398
|
+
!this.sessions.clusterCollides(newCluster),
|
|
399
|
+
0x758 /* Cluster collision detected. */,
|
|
400
|
+
);
|
|
391
401
|
this.finalSpace.addCluster(newCluster);
|
|
392
402
|
return newCluster;
|
|
393
403
|
}
|
|
@@ -462,16 +472,11 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
462
472
|
}
|
|
463
473
|
const alignedLocal = getAlignedLocal(containingCluster, id);
|
|
464
474
|
const alignedGenCount = genCountFromLocalId(alignedLocal);
|
|
465
|
-
const lastFinalizedGenCount = genCountFromLocalId(
|
|
466
|
-
lastFinalizedLocal(containingCluster),
|
|
467
|
-
);
|
|
475
|
+
const lastFinalizedGenCount = genCountFromLocalId(lastFinalizedLocal(containingCluster));
|
|
468
476
|
if (alignedGenCount > lastFinalizedGenCount) {
|
|
469
477
|
// should be an eager final id generated by the local session
|
|
470
478
|
if (containingCluster.session === this.localSession) {
|
|
471
|
-
assert(
|
|
472
|
-
!this.normalizer.contains(alignedLocal),
|
|
473
|
-
0x759 /* Normalizer out of sync. */,
|
|
474
|
-
);
|
|
479
|
+
assert(!this.normalizer.contains(alignedLocal), 0x759 /* Normalizer out of sync. */);
|
|
475
480
|
} else {
|
|
476
481
|
throw new Error("Unknown ID");
|
|
477
482
|
}
|
|
@@ -561,9 +566,9 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
561
566
|
}
|
|
562
567
|
const localStateSize = hasLocalState
|
|
563
568
|
? 1 + // generated ID count
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
569
|
+
1 + // next range base genCount
|
|
570
|
+
1 + // count of normalizer pairs
|
|
571
|
+
this.normalizer.idRanges.size * 2 // pairs
|
|
567
572
|
: 0;
|
|
568
573
|
// Layout size, in 8 byte increments
|
|
569
574
|
const totalSize =
|
|
@@ -695,11 +700,7 @@ export class IdCompressor implements IIdCompressor, IIdCompressorCore {
|
|
|
695
700
|
const session = sessions[sessionIndex + sessionOffset][1];
|
|
696
701
|
const capacity = readNumber(index);
|
|
697
702
|
const count = readNumber(index);
|
|
698
|
-
const cluster = session.addNewCluster(
|
|
699
|
-
baseFinalId as FinalCompressedId,
|
|
700
|
-
capacity,
|
|
701
|
-
count,
|
|
702
|
-
);
|
|
703
|
+
const cluster = session.addNewCluster(baseFinalId as FinalCompressedId, capacity, count);
|
|
703
704
|
compressor.finalSpace.addCluster(cluster);
|
|
704
705
|
baseFinalId += capacity;
|
|
705
706
|
}
|
|
@@ -809,5 +810,8 @@ export function deserializeIdCompressor(
|
|
|
809
810
|
);
|
|
810
811
|
}
|
|
811
812
|
|
|
812
|
-
return IdCompressor.deserialize(
|
|
813
|
+
return IdCompressor.deserialize(
|
|
814
|
+
serialized as SerializedIdCompressorWithOngoingSession,
|
|
815
|
+
logger,
|
|
816
|
+
);
|
|
813
817
|
}
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
export { createIdCompressor, deserializeIdCompressor } from "./idCompressor.js";
|
|
11
|
-
export {
|
|
11
|
+
export {
|
|
12
|
+
createSessionId,
|
|
13
|
+
assertIsStableId,
|
|
14
|
+
generateStableId,
|
|
15
|
+
isStableId,
|
|
16
|
+
} from "./utilities.js";
|
|
12
17
|
export {
|
|
13
18
|
IIdCompressorCore,
|
|
14
19
|
IIdCompressor,
|
package/src/packageVersion.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
|
+
|
|
7
8
|
import { AppendOnlySortedMap } from "./appendOnlySortedMap.js";
|
|
8
9
|
import { LocalCompressedId } from "./identifiers.js";
|
|
9
10
|
import { compareFiniteNumbers, genCountFromLocalId } from "./utilities.js";
|
|
@@ -43,7 +44,9 @@ import { compareFiniteNumbers, genCountFromLocalId } from "./utilities.js";
|
|
|
43
44
|
export class SessionSpaceNormalizer {
|
|
44
45
|
// Run-length encoding of IDs that were generated as local IDs. They are stored as a list of tuples (genCount, count)
|
|
45
46
|
// that are sorted on the genCount so that contains checks can use a binary search.
|
|
46
|
-
private readonly localIdRanges = new AppendOnlySortedMap<number, number>(
|
|
47
|
+
private readonly localIdRanges = new AppendOnlySortedMap<number, number>(
|
|
48
|
+
compareFiniteNumbers,
|
|
49
|
+
);
|
|
47
50
|
|
|
48
51
|
public get idRanges(): Pick<AppendOnlySortedMap<number, number>, "size" | "entries"> {
|
|
49
52
|
return this.localIdRanges;
|
|
@@ -31,9 +31,9 @@ import {
|
|
|
31
31
|
StableId,
|
|
32
32
|
createIdCompressor,
|
|
33
33
|
} from "../index.js";
|
|
34
|
+
import { SessionSpaceNormalizer } from "../sessionSpaceNormalizer.js";
|
|
34
35
|
import { assertIsSessionId, createSessionId, localIdFromGenCount } from "../utilities.js";
|
|
35
36
|
|
|
36
|
-
import { SessionSpaceNormalizer } from "../sessionSpaceNormalizer.js";
|
|
37
37
|
import {
|
|
38
38
|
FinalCompressedId,
|
|
39
39
|
ReadonlyIdCompressor,
|
|
@@ -120,7 +120,10 @@ export function buildHugeCompressor(
|
|
|
120
120
|
capacity = 10,
|
|
121
121
|
numClustersPerSession = 3,
|
|
122
122
|
): IdCompressor {
|
|
123
|
-
const compressor = CompressorFactory.createCompressorWithSession(
|
|
123
|
+
const compressor = CompressorFactory.createCompressorWithSession(
|
|
124
|
+
createSessionId(),
|
|
125
|
+
capacity,
|
|
126
|
+
);
|
|
124
127
|
const sessions: SessionId[] = [];
|
|
125
128
|
for (let i = 0; i < numSessions; i++) {
|
|
126
129
|
sessions.push(createSessionId());
|
|
@@ -378,7 +381,10 @@ export class IdCompressorTestNetwork {
|
|
|
378
381
|
/**
|
|
379
382
|
* Delivers all undelivered ID ranges from the server to the target clients.
|
|
380
383
|
*/
|
|
381
|
-
public deliverOperations(
|
|
384
|
+
public deliverOperations(
|
|
385
|
+
clientTakingDelivery: DestinationClient,
|
|
386
|
+
opsToDeliver?: number,
|
|
387
|
+
): void {
|
|
382
388
|
let opIndexBound: number;
|
|
383
389
|
if (clientTakingDelivery === DestinationClient.All) {
|
|
384
390
|
assert(opsToDeliver === undefined);
|
|
@@ -397,10 +403,7 @@ export class IdCompressorTestNetwork {
|
|
|
397
403
|
const ids = range.ids;
|
|
398
404
|
if (ids !== undefined) {
|
|
399
405
|
for (const id of opSpaceIds) {
|
|
400
|
-
const sessionSpaceId = compressorTo.normalizeToSessionSpace(
|
|
401
|
-
id,
|
|
402
|
-
range.sessionId,
|
|
403
|
-
);
|
|
406
|
+
const sessionSpaceId = compressorTo.normalizeToSessionSpace(id, range.sessionId);
|
|
404
407
|
this.addNewId(clientTo, sessionSpaceId, clientFrom, sessionIdFrom, true);
|
|
405
408
|
}
|
|
406
409
|
}
|
|
@@ -584,18 +587,14 @@ export class IdCompressorTestNetwork {
|
|
|
584
587
|
if (originatingSession !== OriginatingClient.Remote) {
|
|
585
588
|
assert.strictEqual(
|
|
586
589
|
idDataA.sessionId,
|
|
587
|
-
this.compressors.get(idDataA.originatingClient as Client)
|
|
588
|
-
.localSessionId,
|
|
590
|
+
this.compressors.get(idDataA.originatingClient as Client).localSessionId,
|
|
589
591
|
);
|
|
590
592
|
}
|
|
591
593
|
idCreatorCount++;
|
|
592
594
|
}
|
|
593
595
|
|
|
594
596
|
const uuidASessionSpace = compressorA.decompress(sessionSpaceIdA);
|
|
595
|
-
assert.strictEqual(
|
|
596
|
-
uuidASessionSpace,
|
|
597
|
-
incrementStableId(idDataA.sessionId, idIndex),
|
|
598
|
-
);
|
|
597
|
+
assert.strictEqual(uuidASessionSpace, incrementStableId(idDataA.sessionId, idIndex));
|
|
599
598
|
assert.strictEqual(compressorA.recompress(uuidASessionSpace), sessionSpaceIdA);
|
|
600
599
|
uuids.add(uuidASessionSpace);
|
|
601
600
|
const opSpaceIdA = compressorA.normalizeToOpSpace(sessionSpaceIdA);
|
|
@@ -675,7 +674,10 @@ export function roundtrip(
|
|
|
675
674
|
export function roundtrip(
|
|
676
675
|
compressor: ReadonlyIdCompressor,
|
|
677
676
|
withSession: boolean,
|
|
678
|
-
): [
|
|
677
|
+
): [
|
|
678
|
+
SerializedIdCompressorWithOngoingSession | SerializedIdCompressorWithNoSession,
|
|
679
|
+
IdCompressor,
|
|
680
|
+
] {
|
|
679
681
|
// preserve the capacity request as this property is normally private and resets
|
|
680
682
|
// to a default on construction (deserialization)
|
|
681
683
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
@@ -867,7 +869,9 @@ export function makeOpGenerator(
|
|
|
867
869
|
selectableClients,
|
|
868
870
|
network,
|
|
869
871
|
}: FuzzTestState): DeliverSomeOperations {
|
|
870
|
-
const pendingClients = selectableClients.filter(
|
|
872
|
+
const pendingClients = selectableClients.filter(
|
|
873
|
+
(c) => network.getPendingOperations(c) > 0,
|
|
874
|
+
);
|
|
871
875
|
if (pendingClients.length === 0) {
|
|
872
876
|
return {
|
|
873
877
|
type: "deliverSomeOperations",
|
|
@@ -1016,8 +1020,8 @@ export function createAlwaysFinalizedIdCompressor(
|
|
|
1016
1020
|
sessionIdOrLogger === undefined
|
|
1017
1021
|
? createIdCompressor()
|
|
1018
1022
|
: typeof sessionIdOrLogger === "string"
|
|
1019
|
-
|
|
1020
|
-
|
|
1023
|
+
? createIdCompressor(sessionIdOrLogger, loggerOrUndefined)
|
|
1024
|
+
: createIdCompressor(sessionIdOrLogger);
|
|
1021
1025
|
// Permanently put the compressor in a ghost session
|
|
1022
1026
|
(compressor as IdCompressor).startGhostSession(createSessionId());
|
|
1023
1027
|
return compressor;
|
package/src/test/testCommon.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
/**
|
|
17
17
|
* An identifier (v4 UUID) that has been shortened by a distributed compression algorithm.
|
|
18
18
|
* Lacks a space (session/op), meaning its scope is the same as the space-specific ID from which it was derived.
|
|
19
|
-
* @alpha
|
|
20
19
|
*/
|
|
21
20
|
export type CompressedId =
|
|
22
21
|
| SessionSpaceCompressedId
|
|
@@ -27,7 +26,6 @@ export type CompressedId =
|
|
|
27
26
|
/**
|
|
28
27
|
* A compressed ID that is stable and unique within the scope of network of compressors (i.e. a document).
|
|
29
28
|
* It can only be used/decompressed in the context of the originating document.
|
|
30
|
-
* @alpha
|
|
31
29
|
*/
|
|
32
30
|
export type FinalCompressedId = number & {
|
|
33
31
|
readonly FinalCompressedId: "5d83d1e2-98b7-4e4e-a889-54c855cfa73d";
|
|
@@ -40,7 +38,6 @@ export type FinalCompressedId = number & {
|
|
|
40
38
|
* A compressed ID that is local to a session (can only be decompressed when paired with a SessionId).
|
|
41
39
|
* Internally, it should not be persisted outside a scope annotated with the originating SessionId in order to be unambiguous.
|
|
42
40
|
* If external persistence is needed (e.g. by a client), a StableId should be used instead.
|
|
43
|
-
* @alpha
|
|
44
41
|
*/
|
|
45
42
|
export type LocalCompressedId = number & {
|
|
46
43
|
readonly LocalCompressedId: "6fccb42f-e2a4-4243-bd29-f13d12b9c6d1";
|
package/src/test/tsconfig.json
CHANGED
package/src/types/identifiers.ts
CHANGED
|
@@ -36,4 +36,6 @@ export type StableId = string & { readonly StableId: "53172b0d-a3d5-41ea-bd75-b4
|
|
|
36
36
|
* A StableId which is suitable for use as a session identifier
|
|
37
37
|
* @public
|
|
38
38
|
*/
|
|
39
|
-
export type SessionId = StableId & {
|
|
39
|
+
export type SessionId = StableId & {
|
|
40
|
+
readonly SessionId: "4498f850-e14e-4be9-8db0-89ec00997e58";
|
|
41
|
+
};
|
package/tsconfig.json
CHANGED
package/tsdoc.json
ADDED