@fluidframework/runtime-utils 2.30.0 → 2.31.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 +192 -188
- package/dist/summaryUtils.d.ts +0 -3
- package/dist/summaryUtils.d.ts.map +1 -1
- package/dist/summaryUtils.js +0 -3
- package/dist/summaryUtils.js.map +1 -1
- package/dist/utils.d.ts +12 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +14 -9
- package/dist/utils.js.map +1 -1
- package/lib/summaryUtils.d.ts +0 -3
- package/lib/summaryUtils.d.ts.map +1 -1
- package/lib/summaryUtils.js +0 -3
- package/lib/summaryUtils.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/utils.d.ts +12 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +13 -8
- package/lib/utils.js.map +1 -1
- package/package.json +14 -17
- package/src/summaryUtils.ts +0 -3
- package/src/utils.ts +16 -8
- package/prettier.config.cjs +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid Runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,27 +69,27 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/container-definitions": "~2.
|
|
74
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
75
|
-
"@fluidframework/core-interfaces": "~2.
|
|
76
|
-
"@fluidframework/core-utils": "~2.
|
|
77
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
78
|
-
"@fluidframework/driver-definitions": "~2.
|
|
79
|
-
"@fluidframework/driver-utils": "~2.
|
|
80
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
81
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.31.0",
|
|
73
|
+
"@fluidframework/container-definitions": "~2.31.0",
|
|
74
|
+
"@fluidframework/container-runtime-definitions": "~2.31.0",
|
|
75
|
+
"@fluidframework/core-interfaces": "~2.31.0",
|
|
76
|
+
"@fluidframework/core-utils": "~2.31.0",
|
|
77
|
+
"@fluidframework/datastore-definitions": "~2.31.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.31.0",
|
|
79
|
+
"@fluidframework/driver-utils": "~2.31.0",
|
|
80
|
+
"@fluidframework/runtime-definitions": "~2.31.0",
|
|
81
|
+
"@fluidframework/telemetry-utils": "~2.31.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
85
85
|
"@biomejs/biome": "~1.9.3",
|
|
86
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
86
|
+
"@fluid-internal/mocha-test-setup": "~2.31.0",
|
|
87
87
|
"@fluid-tools/build-cli": "^0.54.0",
|
|
88
88
|
"@fluidframework/build-common": "^2.0.3",
|
|
89
89
|
"@fluidframework/build-tools": "^0.54.0",
|
|
90
90
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
91
|
-
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.
|
|
92
|
-
"@microsoft/api-extractor": "7.
|
|
91
|
+
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.30.0",
|
|
92
|
+
"@microsoft/api-extractor": "7.50.1",
|
|
93
93
|
"@types/mocha": "^10.0.10",
|
|
94
94
|
"@types/node": "^18.19.0",
|
|
95
95
|
"@types/sinon": "^17.0.3",
|
|
@@ -101,7 +101,6 @@
|
|
|
101
101
|
"mocha": "^10.8.2",
|
|
102
102
|
"mocha-multi-reporters": "^1.5.1",
|
|
103
103
|
"moment": "^2.21.0",
|
|
104
|
-
"prettier": "~3.0.3",
|
|
105
104
|
"rimraf": "^4.4.0",
|
|
106
105
|
"sinon": "^18.0.1",
|
|
107
106
|
"ts-node": "^10.9.1",
|
|
@@ -135,7 +134,6 @@
|
|
|
135
134
|
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
|
|
136
135
|
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
137
136
|
"check:format": "npm run check:biome",
|
|
138
|
-
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
139
137
|
"ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
|
|
140
138
|
"ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
|
|
141
139
|
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
|
|
@@ -145,7 +143,6 @@
|
|
|
145
143
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
146
144
|
"format": "npm run format:biome",
|
|
147
145
|
"format:biome": "biome check . --write",
|
|
148
|
-
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
149
146
|
"lint": "fluid-build . --task lint",
|
|
150
147
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
151
148
|
"test": "npm run test:mocha",
|
package/src/summaryUtils.ts
CHANGED
|
@@ -215,9 +215,6 @@ export class SummaryTreeBuilder implements ISummaryTreeWithStats {
|
|
|
215
215
|
/**
|
|
216
216
|
* Adds an {@link @fluidframework/driver-definitions#ISummaryHandle} that references a subtree, blob, or attachment in a previous summary.
|
|
217
217
|
*
|
|
218
|
-
* @remarks
|
|
219
|
-
* There are special limitations to both the key and handle parameters: We use encodeURIComponent and decodeURIComponent to encode and decode the key and handle parameters after they are added to the summary tree. This means that the key and handle parameters must be valid URI components. If they are not, the encoding and decoding will fail and the summary will not be generated correctly.
|
|
220
|
-
*
|
|
221
218
|
* @param key - The key to store the handle at in the current summary tree being generated. Should not contain any "/" characters.
|
|
222
219
|
* @param handleType - the type of {@link @fluidframework/driver-definitions#SummaryObject} besides a SummaryHandle, i.e. {@link @fluidframework/driver-definitions#SummaryType.Tree}, {@link @fluidframework/driver-definitions#SummaryType.Blob}, {@link @fluidframework/driver-definitions#SummaryType.Attachment}
|
|
223
220
|
* @param handle - The path pointing to the part of the previous summary being used to duplicate the data. Use {@link @fluidframework/driver-definitions#ISummaryHandle.handle} to help generate proper handle strings. Should not contain any "/" characters.
|
package/src/utils.ts
CHANGED
|
@@ -34,16 +34,27 @@ export async function seqFromTree(
|
|
|
34
34
|
return attrib.sequenceNumber;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* The following characters emulates the UTF-16 code sequence from 65 - 123, except for the `[` and `{`
|
|
39
|
+
* positioned at 91 and 123 respectively - which are changed to '(' and ')'. Used in the `encodeCompactIdToString` utility below.
|
|
40
|
+
* NOTE: The character set must never be changed - since it could result in collisions with existing ids.
|
|
41
|
+
* If changing, make sure to choose new characters that have never been
|
|
42
|
+
* used before, and the characters must not change their encoding with 'encodeURIComponent'.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export const charSetForEncodingIds =
|
|
46
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ(abcdefghijklmnopqrstuvwxyz)0123456789";
|
|
47
|
+
|
|
37
48
|
/**
|
|
38
49
|
* Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.
|
|
39
50
|
* While this is the main usage pattern, it works with any non-negative integer or a string.
|
|
40
|
-
* Strings are
|
|
51
|
+
* Strings are returned as is, and assumed to be UUIDs, i.e. unique enough to never overlap with
|
|
41
52
|
* numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!
|
|
42
53
|
* This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not
|
|
43
54
|
* gaining any efficiency from having a number type.
|
|
44
|
-
* We do not provide a decode function, so this API is only useful only result is stored and there is no need to go back to
|
|
55
|
+
* We do not provide a decode function, so this API is only useful only result is stored and there is no need to go back to original form.
|
|
45
56
|
* @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form
|
|
46
|
-
* @param prefix -
|
|
57
|
+
* @param prefix - optional string prefix
|
|
47
58
|
* @returns A string - representation of an input
|
|
48
59
|
* @internal
|
|
49
60
|
*/
|
|
@@ -51,6 +62,7 @@ export function encodeCompactIdToString(idArg: number | string, prefix = "") {
|
|
|
51
62
|
if (typeof idArg === "string") {
|
|
52
63
|
return idArg;
|
|
53
64
|
}
|
|
65
|
+
|
|
54
66
|
// WARNING: result of this function are stored in storage!
|
|
55
67
|
// If you ever need to change this function, you will need to ensure that
|
|
56
68
|
// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,
|
|
@@ -63,9 +75,6 @@ export function encodeCompactIdToString(idArg: number | string, prefix = "") {
|
|
|
63
75
|
let id = "";
|
|
64
76
|
let num = idArg;
|
|
65
77
|
do {
|
|
66
|
-
// 48-57 -> 0-9
|
|
67
|
-
// 65-91 > A-Z[
|
|
68
|
-
// 97-123 -> a-z}
|
|
69
78
|
// Here are some examples of the input & output:
|
|
70
79
|
// 0 -> 'A'
|
|
71
80
|
// 1 -> 'B'
|
|
@@ -74,8 +83,7 @@ export function encodeCompactIdToString(idArg: number | string, prefix = "") {
|
|
|
74
83
|
// 10000 -> 'BaQ'
|
|
75
84
|
// 100000 -> 'XZf'
|
|
76
85
|
const encode = num % 64;
|
|
77
|
-
|
|
78
|
-
id = String.fromCharCode(base + encode) + id;
|
|
86
|
+
id = charSetForEncodingIds[encode] + id;
|
|
79
87
|
num = Math.floor(num / 64) - 1;
|
|
80
88
|
} while (num !== -1);
|
|
81
89
|
return prefix + id;
|