@fluidframework/runtime-utils 2.0.0-rc.1.0.3 → 2.0.0-rc.2.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/{.eslintrc.js → .eslintrc.cjs} +4 -1
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +30 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/runtime-utils.api.md +10 -11
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -39
- package/dist/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/runtime-utils-alpha.d.ts +5 -3
- package/dist/runtime-utils-beta.d.ts +5 -3
- package/dist/runtime-utils-public.d.ts +5 -3
- package/dist/runtime-utils-untrimmed.d.ts +34 -9
- package/dist/summaryUtils.d.ts +18 -8
- package/dist/summaryUtils.d.ts.map +1 -1
- package/dist/summaryUtils.js +34 -9
- package/dist/summaryUtils.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +49 -1
- package/dist/utils.js.map +1 -1
- package/lib/{dataStoreHandleContextUtils.d.mts → dataStoreHandleContextUtils.d.ts} +1 -1
- package/lib/dataStoreHandleContextUtils.d.ts.map +1 -0
- package/lib/{dataStoreHandleContextUtils.mjs → dataStoreHandleContextUtils.js} +1 -1
- package/lib/dataStoreHandleContextUtils.js.map +1 -0
- package/lib/{dataStoreHelpers.d.mts → dataStoreHelpers.d.ts} +1 -1
- package/lib/dataStoreHelpers.d.ts.map +1 -0
- package/lib/{dataStoreHelpers.mjs → dataStoreHelpers.js} +1 -1
- package/lib/dataStoreHelpers.js.map +1 -0
- package/lib/{handles.d.mts → handles.d.ts} +1 -1
- package/lib/handles.d.ts.map +1 -0
- package/lib/{handles.mjs → handles.js} +1 -1
- package/lib/handles.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +15 -0
- package/lib/index.js.map +1 -0
- package/lib/{objectstoragepartition.d.mts → objectstoragepartition.d.ts} +1 -1
- package/lib/objectstoragepartition.d.ts.map +1 -0
- package/lib/{objectstoragepartition.mjs → objectstoragepartition.js} +1 -1
- package/lib/objectstoragepartition.js.map +1 -0
- package/lib/{objectstorageutils.d.mts → objectstorageutils.d.ts} +1 -1
- package/lib/objectstorageutils.d.ts.map +1 -0
- package/lib/{objectstorageutils.mjs → objectstorageutils.js} +1 -1
- package/lib/objectstorageutils.js.map +1 -0
- package/lib/{requestParser.d.mts → requestParser.d.ts} +5 -1
- package/lib/requestParser.d.ts.map +1 -0
- package/lib/{requestParser.mjs → requestParser.js} +1 -1
- package/lib/requestParser.js.map +1 -0
- package/lib/{runtime-utils-alpha.d.mts → runtime-utils-alpha.d.ts} +5 -3
- package/lib/{runtime-utils-beta.d.mts → runtime-utils-beta.d.ts} +5 -3
- package/lib/{runtime-utils-public.d.mts → runtime-utils-public.d.ts} +5 -3
- package/lib/{runtime-utils-untrimmed.d.mts → runtime-utils-untrimmed.d.ts} +34 -9
- package/lib/{runtimeFactoryHelper.d.mts → runtimeFactoryHelper.d.ts} +1 -1
- package/lib/runtimeFactoryHelper.d.ts.map +1 -0
- package/lib/{runtimeFactoryHelper.mjs → runtimeFactoryHelper.js} +1 -1
- package/lib/runtimeFactoryHelper.js.map +1 -0
- package/lib/{summaryUtils.d.mts → summaryUtils.d.ts} +19 -9
- package/lib/summaryUtils.d.ts.map +1 -0
- package/lib/{summaryUtils.mjs → summaryUtils.js} +34 -9
- package/lib/summaryUtils.js.map +1 -0
- package/lib/test/dataStoreHelpers.spec.js +29 -0
- package/lib/test/dataStoreHelpers.spec.js.map +1 -0
- package/lib/test/requestParser.spec.js +111 -0
- package/lib/test/requestParser.spec.js.map +1 -0
- package/lib/test/runtimeFactoryHelper.spec.js +44 -0
- package/lib/test/runtimeFactoryHelper.spec.js.map +1 -0
- package/lib/test/summaryUtils.spec.js +283 -0
- package/lib/test/summaryUtils.spec.js.map +1 -0
- package/lib/test/types/validateRuntimeUtilsPrevious.generated.js +58 -0
- package/lib/test/types/validateRuntimeUtilsPrevious.generated.js.map +1 -0
- package/lib/test/utils.spec.js +65 -0
- package/lib/test/utils.spec.js.map +1 -0
- package/lib/{unpackUsedRoutes.d.mts → unpackUsedRoutes.d.ts} +1 -1
- package/lib/unpackUsedRoutes.d.ts.map +1 -0
- package/lib/{unpackUsedRoutes.mjs → unpackUsedRoutes.js} +1 -1
- package/lib/unpackUsedRoutes.js.map +1 -0
- package/lib/utils.d.ts +34 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +64 -0
- package/lib/utils.js.map +1 -0
- package/package.json +48 -49
- package/src/index.ts +11 -11
- package/src/summaryUtils.ts +48 -18
- package/src/utils.ts +48 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/dataStoreHandleContextUtils.d.mts.map +0 -1
- package/lib/dataStoreHandleContextUtils.mjs.map +0 -1
- package/lib/dataStoreHelpers.d.mts.map +0 -1
- package/lib/dataStoreHelpers.mjs.map +0 -1
- package/lib/handles.d.mts.map +0 -1
- package/lib/handles.mjs.map +0 -1
- package/lib/index.d.mts +0 -15
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -15
- package/lib/index.mjs.map +0 -1
- package/lib/objectstoragepartition.d.mts.map +0 -1
- package/lib/objectstoragepartition.mjs.map +0 -1
- package/lib/objectstorageutils.d.mts.map +0 -1
- package/lib/objectstorageutils.mjs.map +0 -1
- package/lib/requestParser.d.mts.map +0 -1
- package/lib/requestParser.mjs.map +0 -1
- package/lib/runtimeFactoryHelper.d.mts.map +0 -1
- package/lib/runtimeFactoryHelper.mjs.map +0 -1
- package/lib/summaryUtils.d.mts.map +0 -1
- package/lib/summaryUtils.mjs.map +0 -1
- package/lib/unpackUsedRoutes.d.mts.map +0 -1
- package/lib/unpackUsedRoutes.mjs.map +0 -1
- package/lib/utils.d.mts +0 -20
- package/lib/utils.d.mts.map +0 -1
- package/lib/utils.mjs +0 -17
- package/lib/utils.mjs.map +0 -1
package/lib/utils.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
6
|
+
/**
|
|
7
|
+
* Reads a blob from storage and parses it from JSON.
|
|
8
|
+
*
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export type ReadAndParseBlob = <T>(id: string) => Promise<T>;
|
|
12
|
+
/**
|
|
13
|
+
* Fetches the sequence number of the snapshot tree by examining the protocol.
|
|
14
|
+
* @param tree - snapshot tree to examine
|
|
15
|
+
* @param readAndParseBlob - function to read blob contents from storage
|
|
16
|
+
* and parse the result from JSON.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function seqFromTree(tree: ISnapshotTree, readAndParseBlob: ReadAndParseBlob): Promise<number>;
|
|
20
|
+
/**
|
|
21
|
+
* Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.
|
|
22
|
+
* While this is the main usage pattern, it works with any non-negative integer or a string.
|
|
23
|
+
* Strings are retured as is, and assumed to be UUIDs, i.e. unique enough to never overlap with
|
|
24
|
+
* numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!
|
|
25
|
+
* This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not
|
|
26
|
+
* gaining any efficiency from having a number type.
|
|
27
|
+
* 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 origianl form.
|
|
28
|
+
* @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form
|
|
29
|
+
* @param prefix - optinal string prefix
|
|
30
|
+
* @returns A string - representation of an input
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export declare function encodeCompactIdToString(idArg: number | string, prefix?: string): string;
|
|
34
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAuB,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAE1F;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAsB,WAAW,CAChC,IAAI,EAAE,aAAa,EACnB,gBAAgB,EAAE,gBAAgB,GAChC,OAAO,CAAC,MAAM,CAAC,CAIjB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,SAAK,UAgC1E"}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { assert } from "@fluidframework/core-utils";
|
|
6
|
+
/**
|
|
7
|
+
* Fetches the sequence number of the snapshot tree by examining the protocol.
|
|
8
|
+
* @param tree - snapshot tree to examine
|
|
9
|
+
* @param readAndParseBlob - function to read blob contents from storage
|
|
10
|
+
* and parse the result from JSON.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export async function seqFromTree(tree, readAndParseBlob) {
|
|
14
|
+
const attributesHash = tree.trees[".protocol"].blobs.attributes;
|
|
15
|
+
const attrib = await readAndParseBlob(attributesHash);
|
|
16
|
+
return attrib.sequenceNumber;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.
|
|
20
|
+
* While this is the main usage pattern, it works with any non-negative integer or a string.
|
|
21
|
+
* Strings are retured as is, and assumed to be UUIDs, i.e. unique enough to never overlap with
|
|
22
|
+
* numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!
|
|
23
|
+
* This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not
|
|
24
|
+
* gaining any efficiency from having a number type.
|
|
25
|
+
* 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 origianl form.
|
|
26
|
+
* @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form
|
|
27
|
+
* @param prefix - optinal string prefix
|
|
28
|
+
* @returns A string - representation of an input
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export function encodeCompactIdToString(idArg, prefix = "") {
|
|
32
|
+
if (typeof idArg === "string") {
|
|
33
|
+
return idArg;
|
|
34
|
+
}
|
|
35
|
+
// WARNING: result of this function are stored in storage!
|
|
36
|
+
// If you ever need to change this function, you will need to ensure that
|
|
37
|
+
// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,
|
|
38
|
+
// and new() - is new implementation of encodeCompactIdToString()
|
|
39
|
+
// This likely means - this function can't be changed, unless it uses some prefix that ensures
|
|
40
|
+
// new values have zero overlap with old values.
|
|
41
|
+
// Also resulting string can't contain "/", as that's disallowed by some users
|
|
42
|
+
// (data store and DDS IDs can't have "/" in their IDs).
|
|
43
|
+
assert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);
|
|
44
|
+
let id = "";
|
|
45
|
+
let num = idArg;
|
|
46
|
+
do {
|
|
47
|
+
// 48-57 -> 0-9
|
|
48
|
+
// 65-91 > A-Z[
|
|
49
|
+
// 97-123 -> a-z}
|
|
50
|
+
// Here are some examples of the input & output:
|
|
51
|
+
// 0 -> 'A'
|
|
52
|
+
// 1 -> 'B'
|
|
53
|
+
// 64 -> "AA"
|
|
54
|
+
// 100 -> 'Aj'
|
|
55
|
+
// 10000 -> 'BaQ'
|
|
56
|
+
// 100000 -> 'XZf'
|
|
57
|
+
const encode = num % 64;
|
|
58
|
+
const base = encode < 27 ? 65 : encode < 54 ? 97 - 27 : 48 - 54;
|
|
59
|
+
id = String.fromCharCode(base + encode) + id;
|
|
60
|
+
num = Math.floor(num / 64) - 1;
|
|
61
|
+
} while (num !== -1);
|
|
62
|
+
return prefix + id;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAUpD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAChC,IAAmB,EACnB,gBAAkC;IAElC,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC;IAChE,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAsB,cAAc,CAAC,CAAC;IAC3E,OAAO,MAAM,CAAC,cAAc,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAsB,EAAE,MAAM,GAAG,EAAE;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC9B,OAAO,KAAK,CAAC;KACb;IACD,0DAA0D;IAC1D,yEAAyE;IACzE,wFAAwF;IACxF,iEAAiE;IACjE,8FAA8F;IAC9F,gDAAgD;IAChD,8EAA8E;IAC9E,wDAAwD;IACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACzE,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,IAAI,GAAG,GAAG,KAAK,CAAC;IAChB,GAAG;QACF,eAAe;QACf,eAAe;QACf,iBAAiB;QACjB,gDAAgD;QAChD,WAAW;QACX,WAAW;QACX,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,kBAAkB;QAClB,MAAM,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QAChE,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;QAC7C,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;KAC/B,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE;IACrB,OAAO,MAAM,GAAG,EAAE,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentAttributes, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Reads a blob from storage and parses it from JSON.\n *\n * @internal\n */\nexport type ReadAndParseBlob = <T>(id: string) => Promise<T>;\n\n/**\n * Fetches the sequence number of the snapshot tree by examining the protocol.\n * @param tree - snapshot tree to examine\n * @param readAndParseBlob - function to read blob contents from storage\n * and parse the result from JSON.\n * @internal\n */\nexport async function seqFromTree(\n\ttree: ISnapshotTree,\n\treadAndParseBlob: ReadAndParseBlob,\n): Promise<number> {\n\tconst attributesHash = tree.trees[\".protocol\"].blobs.attributes;\n\tconst attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);\n\treturn attrib.sequenceNumber;\n}\n\n/**\n * Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.\n * While this is the main usage pattern, it works with any non-negative integer or a string.\n * Strings are retured as is, and assumed to be UUIDs, i.e. unique enough to never overlap with\n * numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!\n * This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not\n * gaining any efficiency from having a number type.\n * 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 origianl form.\n * @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form\n * @param prefix - optinal string prefix\n * @returns A string - representation of an input\n * @internal\n */\nexport function encodeCompactIdToString(idArg: number | string, prefix = \"\") {\n\tif (typeof idArg === \"string\") {\n\t\treturn idArg;\n\t}\n\t// WARNING: result of this function are stored in storage!\n\t// If you ever need to change this function, you will need to ensure that\n\t// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,\n\t// and new() - is new implementation of encodeCompactIdToString()\n\t// This likely means - this function can't be changed, unless it uses some prefix that ensures\n\t// new values have zero overlap with old values.\n\t// Also resulting string can't contain \"/\", as that's disallowed by some users\n\t// (data store and DDS IDs can't have \"/\" in their IDs).\n\tassert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);\n\tlet id = \"\";\n\tlet num = idArg;\n\tdo {\n\t\t// 48-57 -> 0-9\n\t\t// 65-91 > A-Z[\n\t\t// 97-123 -> a-z}\n\t\t// Here are some examples of the input & output:\n\t\t// 0 -> 'A'\n\t\t// 1 -> 'B'\n\t\t// 64 -> \"AA\"\n\t\t// 100 -> 'Aj'\n\t\t// 10000 -> 'BaQ'\n\t\t// 100000 -> 'XZf'\n\t\tconst encode = num % 64;\n\t\tconst base = encode < 27 ? 65 : encode < 54 ? 97 - 27 : 48 - 54;\n\t\tid = String.fromCharCode(base + encode) + id;\n\t\tnum = Math.floor(num / 64) - 1;\n\t} while (num !== -1);\n\treturn prefix + id;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/runtime-utils",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.2.0.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid Runtime",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,60 +11,50 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"import": {
|
|
17
|
-
"types": "./lib/index.d.
|
|
18
|
-
"default": "./lib/index.
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
19
20
|
},
|
|
20
21
|
"require": {
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"default": "./dist/index.js"
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
"./
|
|
26
|
+
"./public": {
|
|
26
27
|
"import": {
|
|
27
|
-
"types": "./lib/runtime-utils-
|
|
28
|
-
"default": "./lib/index.
|
|
28
|
+
"types": "./lib/runtime-utils-public.d.ts",
|
|
29
|
+
"default": "./lib/index.js"
|
|
29
30
|
},
|
|
30
31
|
"require": {
|
|
31
|
-
"types": "./dist/runtime-utils-
|
|
32
|
+
"types": "./dist/runtime-utils-public.d.ts",
|
|
32
33
|
"default": "./dist/index.js"
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
|
-
"./
|
|
36
|
+
"./alpha": {
|
|
36
37
|
"import": {
|
|
37
|
-
"types": "./lib/runtime-utils-
|
|
38
|
-
"default": "./lib/index.
|
|
38
|
+
"types": "./lib/runtime-utils-alpha.d.ts",
|
|
39
|
+
"default": "./lib/index.js"
|
|
39
40
|
},
|
|
40
41
|
"require": {
|
|
41
|
-
"types": "./dist/runtime-utils-
|
|
42
|
+
"types": "./dist/runtime-utils-alpha.d.ts",
|
|
42
43
|
"default": "./dist/index.js"
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
46
|
"./internal": {
|
|
46
47
|
"import": {
|
|
47
|
-
"types": "./lib/index.d.
|
|
48
|
-
"default": "./lib/index.
|
|
48
|
+
"types": "./lib/index.d.ts",
|
|
49
|
+
"default": "./lib/index.js"
|
|
49
50
|
},
|
|
50
51
|
"require": {
|
|
51
52
|
"types": "./dist/index.d.ts",
|
|
52
53
|
"default": "./dist/index.js"
|
|
53
54
|
}
|
|
54
|
-
},
|
|
55
|
-
"./public": {
|
|
56
|
-
"import": {
|
|
57
|
-
"types": "./lib/runtime-utils-public.d.mts",
|
|
58
|
-
"default": "./lib/index.mjs"
|
|
59
|
-
},
|
|
60
|
-
"require": {
|
|
61
|
-
"types": "./dist/runtime-utils-public.d.ts",
|
|
62
|
-
"default": "./dist/index.js"
|
|
63
|
-
}
|
|
64
55
|
}
|
|
65
56
|
},
|
|
66
57
|
"main": "dist/index.js",
|
|
67
|
-
"module": "lib/index.mjs",
|
|
68
58
|
"types": "dist/index.d.ts",
|
|
69
59
|
"c8": {
|
|
70
60
|
"all": true,
|
|
@@ -87,41 +77,41 @@
|
|
|
87
77
|
"temp-directory": "nyc/.nyc_output"
|
|
88
78
|
},
|
|
89
79
|
"dependencies": {
|
|
90
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.
|
|
91
|
-
"@fluidframework/container-definitions": ">=2.0.0-rc.
|
|
92
|
-
"@fluidframework/container-runtime-definitions": ">=2.0.0-rc.
|
|
93
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.
|
|
94
|
-
"@fluidframework/core-utils": ">=2.0.0-rc.
|
|
95
|
-
"@fluidframework/datastore-definitions": ">=2.0.0-rc.
|
|
96
|
-
"@fluidframework/driver-utils": ">=2.0.0-rc.
|
|
97
|
-
"@fluidframework/protocol-definitions": "^3.
|
|
98
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-rc.
|
|
99
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-rc.
|
|
80
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
81
|
+
"@fluidframework/container-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
82
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
83
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
84
|
+
"@fluidframework/core-utils": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
85
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
86
|
+
"@fluidframework/driver-utils": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
87
|
+
"@fluidframework/protocol-definitions": "^3.2.0",
|
|
88
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
89
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0"
|
|
100
90
|
},
|
|
101
91
|
"devDependencies": {
|
|
102
92
|
"@arethetypeswrong/cli": "^0.13.3",
|
|
103
|
-
"@fluid-
|
|
93
|
+
"@fluid-internal/mocha-test-setup": ">=2.0.0-rc.2.0.0 <2.0.0-rc.2.1.0",
|
|
94
|
+
"@fluid-tools/build-cli": "^0.34.0",
|
|
104
95
|
"@fluidframework/build-common": "^2.0.3",
|
|
105
|
-
"@fluidframework/build-tools": "^0.
|
|
106
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
107
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-rc.1.0.3 <2.0.0-rc.1.1.0",
|
|
96
|
+
"@fluidframework/build-tools": "^0.34.0",
|
|
97
|
+
"@fluidframework/eslint-config-fluid": "^4.0.0",
|
|
108
98
|
"@fluidframework/runtime-utils-previous": "npm:@fluidframework/runtime-utils@2.0.0-internal.8.0.0",
|
|
109
|
-
"@microsoft/api-extractor": "^7.
|
|
99
|
+
"@microsoft/api-extractor": "^7.42.3",
|
|
110
100
|
"@types/mocha": "^9.1.1",
|
|
111
101
|
"@types/node": "^18.19.0",
|
|
102
|
+
"@types/sinon": "^17.0.3",
|
|
112
103
|
"c8": "^8.0.1",
|
|
113
104
|
"copyfiles": "^2.4.1",
|
|
114
105
|
"cross-env": "^7.0.3",
|
|
115
|
-
"eslint": "~8.
|
|
106
|
+
"eslint": "~8.55.0",
|
|
116
107
|
"mocha": "^10.2.0",
|
|
117
108
|
"mocha-json-output-reporter": "^2.0.1",
|
|
118
109
|
"mocha-multi-reporters": "^1.5.1",
|
|
119
110
|
"moment": "^2.21.0",
|
|
120
111
|
"prettier": "~3.0.3",
|
|
121
112
|
"rimraf": "^4.4.0",
|
|
122
|
-
"sinon": "^
|
|
113
|
+
"sinon": "^17.0.1",
|
|
123
114
|
"ts-node": "^10.9.1",
|
|
124
|
-
"tsc-multi": "^1.1.0",
|
|
125
115
|
"typescript": "~5.1.6"
|
|
126
116
|
},
|
|
127
117
|
"fluidBuild": {
|
|
@@ -137,18 +127,25 @@
|
|
|
137
127
|
}
|
|
138
128
|
},
|
|
139
129
|
"typeValidation": {
|
|
140
|
-
"broken": {
|
|
130
|
+
"broken": {
|
|
131
|
+
"RemovedFunctionDeclaration_addTreeToSummary": {
|
|
132
|
+
"forwardCompat": false,
|
|
133
|
+
"backCompat": false
|
|
134
|
+
}
|
|
135
|
+
}
|
|
141
136
|
},
|
|
142
137
|
"scripts": {
|
|
143
138
|
"api": "fluid-build . --task api",
|
|
144
|
-
"api-extractor:commonjs": "api-extractor run --
|
|
145
|
-
"api-extractor:esnext": "api-extractor run --
|
|
139
|
+
"api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
|
|
140
|
+
"api-extractor:esnext": "api-extractor run --local",
|
|
146
141
|
"build": "fluid-build . --task build",
|
|
147
142
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
148
143
|
"build:compile": "fluid-build . --task compile",
|
|
149
144
|
"build:docs": "fluid-build . --task api",
|
|
150
|
-
"build:esnext": "tsc
|
|
151
|
-
"build:test": "
|
|
145
|
+
"build:esnext": "tsc --project ./tsconfig.json",
|
|
146
|
+
"build:test": "npm run build:test:esm && npm run build:test:cjs",
|
|
147
|
+
"build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
|
|
148
|
+
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
152
149
|
"check:are-the-types-wrong": "attw --pack . --entrypoints .",
|
|
153
150
|
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
154
151
|
"ci:build:docs": "api-extractor run",
|
|
@@ -162,9 +159,11 @@
|
|
|
162
159
|
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
163
160
|
"test": "npm run test:mocha",
|
|
164
161
|
"test:coverage": "c8 npm test",
|
|
165
|
-
"test:mocha": "
|
|
162
|
+
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
163
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
|
|
164
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
|
|
166
165
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
167
|
-
"tsc": "tsc",
|
|
166
|
+
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
168
167
|
"typetests:gen": "fluid-type-test-generator",
|
|
169
168
|
"typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
|
|
170
169
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { generateHandleContextPath } from "./dataStoreHandleContextUtils";
|
|
6
|
+
export { generateHandleContextPath } from "./dataStoreHandleContextUtils.js";
|
|
7
7
|
export {
|
|
8
8
|
create404Response,
|
|
9
9
|
createDataStoreFactory,
|
|
@@ -11,16 +11,15 @@ export {
|
|
|
11
11
|
exceptionToResponse,
|
|
12
12
|
Factory,
|
|
13
13
|
responseToException,
|
|
14
|
-
} from "./dataStoreHelpers";
|
|
15
|
-
export { ISerializedHandle, isSerializedHandle } from "./handles";
|
|
16
|
-
export { ObjectStoragePartition } from "./objectstoragepartition";
|
|
17
|
-
export { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from "./objectstorageutils";
|
|
18
|
-
export { RequestParser } from "./requestParser";
|
|
19
|
-
export { RuntimeFactoryHelper } from "./runtimeFactoryHelper";
|
|
14
|
+
} from "./dataStoreHelpers.js";
|
|
15
|
+
export { ISerializedHandle, isSerializedHandle } from "./handles.js";
|
|
16
|
+
export { ObjectStoragePartition } from "./objectstoragepartition.js";
|
|
17
|
+
export { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from "./objectstorageutils.js";
|
|
18
|
+
export { RequestParser } from "./requestParser.js";
|
|
19
|
+
export { RuntimeFactoryHelper } from "./runtimeFactoryHelper.js";
|
|
20
20
|
export {
|
|
21
21
|
addBlobToSummary,
|
|
22
22
|
addSummarizeResultToSummary,
|
|
23
|
-
addTreeToSummary,
|
|
24
23
|
calculateStats,
|
|
25
24
|
convertSnapshotTreeToSummaryTree,
|
|
26
25
|
convertSummaryTreeToITree,
|
|
@@ -29,9 +28,10 @@ export {
|
|
|
29
28
|
GCDataBuilder,
|
|
30
29
|
getBlobSize,
|
|
31
30
|
mergeStats,
|
|
31
|
+
processAttachMessageGCData,
|
|
32
32
|
SummaryTreeBuilder,
|
|
33
33
|
TelemetryContext,
|
|
34
34
|
utf8ByteLength,
|
|
35
|
-
} from "./summaryUtils";
|
|
36
|
-
export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes";
|
|
37
|
-
export { ReadAndParseBlob, seqFromTree } from "./utils";
|
|
35
|
+
} from "./summaryUtils.js";
|
|
36
|
+
export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes.js";
|
|
37
|
+
export { ReadAndParseBlob, seqFromTree, encodeCompactIdToString } from "./utils.js";
|
package/src/summaryUtils.ts
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { TelemetryBaseEventPropertyType } from "@fluidframework/core-interfaces";
|
|
7
7
|
import {
|
|
8
8
|
bufferToString,
|
|
9
9
|
fromBase64ToUtf8,
|
|
10
10
|
IsoBuffer,
|
|
11
11
|
Uint8ArrayToString,
|
|
12
12
|
} from "@fluid-internal/client-utils";
|
|
13
|
-
import { unreachableCase } from "@fluidframework/core-utils";
|
|
13
|
+
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
14
14
|
import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "@fluidframework/driver-utils";
|
|
15
15
|
import {
|
|
16
16
|
ITree,
|
|
@@ -130,18 +130,6 @@ export function addBlobToSummary(
|
|
|
130
130
|
summary.stats.totalBlobSize += getBlobSize(content);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
/**
|
|
134
|
-
* @internal
|
|
135
|
-
*/
|
|
136
|
-
export function addTreeToSummary(
|
|
137
|
-
summary: ISummaryTreeWithStats,
|
|
138
|
-
key: string,
|
|
139
|
-
summarizeResult: ISummarizeResult,
|
|
140
|
-
): void {
|
|
141
|
-
summary.summary.tree[key] = summarizeResult.summary;
|
|
142
|
-
summary.stats = mergeStats(summary.stats, summarizeResult.stats);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
133
|
/**
|
|
146
134
|
* @internal
|
|
147
135
|
*/
|
|
@@ -265,6 +253,7 @@ export function convertToSummaryTreeWithStats(
|
|
|
265
253
|
|
|
266
254
|
const summaryTree = builder.getSummaryTree();
|
|
267
255
|
summaryTree.summary.unreferenced = snapshot.unreferenced;
|
|
256
|
+
summaryTree.summary.groupId = snapshot.groupId;
|
|
268
257
|
return summaryTree;
|
|
269
258
|
}
|
|
270
259
|
|
|
@@ -326,6 +315,7 @@ export function convertSnapshotTreeToSummaryTree(
|
|
|
326
315
|
|
|
327
316
|
const summaryTree = builder.getSummaryTree();
|
|
328
317
|
summaryTree.summary.unreferenced = snapshot.unreferenced;
|
|
318
|
+
summaryTree.summary.groupId = snapshot.groupId;
|
|
329
319
|
return summaryTree;
|
|
330
320
|
}
|
|
331
321
|
|
|
@@ -372,19 +362,59 @@ export function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {
|
|
|
372
362
|
return {
|
|
373
363
|
entries,
|
|
374
364
|
unreferenced: summaryTree.unreferenced,
|
|
365
|
+
groupId: summaryTree.groupId,
|
|
375
366
|
};
|
|
376
367
|
}
|
|
377
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Looks in the given attach message snapshot for the .gcdata blob, which would
|
|
371
|
+
* contain the initial GC Data for the node being attached.
|
|
372
|
+
* If it finds it, it notifies GC of all the new outbound routes being added by the attach.
|
|
373
|
+
*
|
|
374
|
+
* @param snapshot - The snapshot from the attach message
|
|
375
|
+
* @param addedGCOutboundRoute - Callback to notify GC of a new outbound route.
|
|
376
|
+
* IMPORTANT: addedGCOutboundRoute's param nodeId is "/" for the attaching node itself, or "/<id>" for its children.
|
|
377
|
+
*
|
|
378
|
+
* @returns true if it found/processed GC Data, false otherwise
|
|
379
|
+
*
|
|
380
|
+
* @internal
|
|
381
|
+
*/
|
|
382
|
+
export function processAttachMessageGCData(
|
|
383
|
+
snapshot: ITree | null,
|
|
384
|
+
addedGCOutboundRoute: (fromNodeId: string, toPath: string) => void,
|
|
385
|
+
): boolean {
|
|
386
|
+
const gcDataEntry = snapshot?.entries.find((e) => e.path === ".gcdata");
|
|
387
|
+
|
|
388
|
+
// Old attach messages won't have GC Data
|
|
389
|
+
// (And REALLY old DataStore Attach messages won't even have a snapshot!)
|
|
390
|
+
if (gcDataEntry === undefined) {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
assert(
|
|
395
|
+
gcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === "utf-8",
|
|
396
|
+
0x8ff /* GC data should be a utf-8-encoded blob */,
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
const gcData = JSON.parse(gcDataEntry.value.contents) as IGarbageCollectionData;
|
|
400
|
+
for (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {
|
|
401
|
+
outboundRoutes.forEach((toPath) => {
|
|
402
|
+
addedGCOutboundRoute(nodeId, toPath);
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
|
|
378
408
|
/**
|
|
379
409
|
* @internal
|
|
380
410
|
*/
|
|
381
411
|
export class TelemetryContext implements ITelemetryContext {
|
|
382
|
-
private readonly telemetry = new Map<string,
|
|
412
|
+
private readonly telemetry = new Map<string, TelemetryBaseEventPropertyType>();
|
|
383
413
|
|
|
384
414
|
/**
|
|
385
415
|
* {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}
|
|
386
416
|
*/
|
|
387
|
-
set(prefix: string, property: string, value:
|
|
417
|
+
set(prefix: string, property: string, value: TelemetryBaseEventPropertyType): void {
|
|
388
418
|
this.telemetry.set(`${prefix}${property}`, value);
|
|
389
419
|
}
|
|
390
420
|
|
|
@@ -394,7 +424,7 @@ export class TelemetryContext implements ITelemetryContext {
|
|
|
394
424
|
setMultiple(
|
|
395
425
|
prefix: string,
|
|
396
426
|
property: string,
|
|
397
|
-
values: Record<string,
|
|
427
|
+
values: Record<string, TelemetryBaseEventPropertyType>,
|
|
398
428
|
): void {
|
|
399
429
|
// Set the values individually so that they are logged as a flat list along with other properties.
|
|
400
430
|
for (const key of Object.keys(values)) {
|
|
@@ -405,7 +435,7 @@ export class TelemetryContext implements ITelemetryContext {
|
|
|
405
435
|
/**
|
|
406
436
|
* {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
|
|
407
437
|
*/
|
|
408
|
-
get(prefix: string, property: string):
|
|
438
|
+
get(prefix: string, property: string): TelemetryBaseEventPropertyType {
|
|
409
439
|
return this.telemetry.get(`${prefix}${property}`);
|
|
410
440
|
}
|
|
411
441
|
|
package/src/utils.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { assert } from "@fluidframework/core-utils";
|
|
6
7
|
import { IDocumentAttributes, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -27,3 +28,50 @@ export async function seqFromTree(
|
|
|
27
28
|
const attrib = await readAndParseBlob<IDocumentAttributes>(attributesHash);
|
|
28
29
|
return attrib.sequenceNumber;
|
|
29
30
|
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.
|
|
34
|
+
* While this is the main usage pattern, it works with any non-negative integer or a string.
|
|
35
|
+
* Strings are retured as is, and assumed to be UUIDs, i.e. unique enough to never overlap with
|
|
36
|
+
* numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!
|
|
37
|
+
* This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not
|
|
38
|
+
* gaining any efficiency from having a number type.
|
|
39
|
+
* 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 origianl form.
|
|
40
|
+
* @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form
|
|
41
|
+
* @param prefix - optinal string prefix
|
|
42
|
+
* @returns A string - representation of an input
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export function encodeCompactIdToString(idArg: number | string, prefix = "") {
|
|
46
|
+
if (typeof idArg === "string") {
|
|
47
|
+
return idArg;
|
|
48
|
+
}
|
|
49
|
+
// WARNING: result of this function are stored in storage!
|
|
50
|
+
// If you ever need to change this function, you will need to ensure that
|
|
51
|
+
// for any inputs N1 & N2, old(N1) !== new(N2), where old() - is the old implementation,
|
|
52
|
+
// and new() - is new implementation of encodeCompactIdToString()
|
|
53
|
+
// This likely means - this function can't be changed, unless it uses some prefix that ensures
|
|
54
|
+
// new values have zero overlap with old values.
|
|
55
|
+
// Also resulting string can't contain "/", as that's disallowed by some users
|
|
56
|
+
// (data store and DDS IDs can't have "/" in their IDs).
|
|
57
|
+
assert(Number.isInteger(idArg) && idArg >= 0, 0x900 /* invalid input */);
|
|
58
|
+
let id = "";
|
|
59
|
+
let num = idArg;
|
|
60
|
+
do {
|
|
61
|
+
// 48-57 -> 0-9
|
|
62
|
+
// 65-91 > A-Z[
|
|
63
|
+
// 97-123 -> a-z}
|
|
64
|
+
// Here are some examples of the input & output:
|
|
65
|
+
// 0 -> 'A'
|
|
66
|
+
// 1 -> 'B'
|
|
67
|
+
// 64 -> "AA"
|
|
68
|
+
// 100 -> 'Aj'
|
|
69
|
+
// 10000 -> 'BaQ'
|
|
70
|
+
// 100000 -> 'XZf'
|
|
71
|
+
const encode = num % 64;
|
|
72
|
+
const base = encode < 27 ? 65 : encode < 54 ? 97 - 27 : 48 - 54;
|
|
73
|
+
id = String.fromCharCode(base + encode) + id;
|
|
74
|
+
num = Math.floor(num / 64) - 1;
|
|
75
|
+
} while (num !== -1);
|
|
76
|
+
return prefix + id;
|
|
77
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends":
|
|
3
|
-
"../../../common/build/build-common/tsconfig.base.json",
|
|
4
|
-
"../../../common/build/build-common/tsconfig.cjs.json",
|
|
5
|
-
],
|
|
2
|
+
"extends": "../../../common/build/build-common/tsconfig.node16.json",
|
|
6
3
|
"include": ["src/**/*"],
|
|
7
4
|
"exclude": ["src/test/**/*"],
|
|
8
5
|
"compilerOptions": {
|
|
9
6
|
"rootDir": "./src",
|
|
10
|
-
"outDir": "./
|
|
7
|
+
"outDir": "./lib",
|
|
11
8
|
},
|
|
12
9
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHandleContextUtils.d.mts","sourceRoot":"","sources":["../src/dataStoreHandleContextUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,mBAAmB,EAAE,MAAM,iCAAiC;AAErE;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,mBAAmB,GAChC,MAAM,CAqBR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHandleContextUtils.mjs","sourceRoot":"","sources":["../src/dataStoreHandleContextUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACxC,IAAY,EACZ,YAAkC;IAElC,IAAI,IAAI,KAAK,EAAE,EAAE;QAChB,uBAAuB;QACvB,wDAAwD;QACxD,yFAAyF;QACzF,OAAO,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC;KACnE;SAAM;QACN,gEAAgE;QAChE,IAAI,cAAc,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACjE,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC;YAC5C,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC7B,CAAC,CAAC,cAAc,CAAC;QAElB,iEAAiE;QACjE,2FAA2F;QAC3F,OAAO,YAAY,KAAK,SAAS;YAChC,CAAC,CAAC,IAAI,cAAc,EAAE;YACtB,CAAC,CAAC,GACA,YAAY,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,YACtD,IAAI,cAAc,EAAE,CAAC;KACxB;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IFluidHandleContext } from \"@fluidframework/core-interfaces\";\n\n/**\n * Generates the absolute path for a Fluid object given its path and its parent routeContext.\n * @param path - The path to the Fluid object relative to the route context.\n * @param routeContext - The route context that contains the Fluid object.\n * @returns The absolute path to the Fluid object from the root of the Container.\n * @internal\n */\nexport function generateHandleContextPath(\n\tpath: string,\n\trouteContext?: IFluidHandleContext,\n): string {\n\tif (path === \"\") {\n\t\t// The `path` is empty.\n\t\t// If the routeContext does not exist, this is the root.\n\t\t// If the routeContext exists, the absolute path is the same as that of the routeContext.\n\t\treturn routeContext === undefined ? \"\" : routeContext.absolutePath;\n\t} else {\n\t\t// Remove beginning and trailing slashes, if any, from the path.\n\t\tlet normalizedPath = path.startsWith(\"/\") ? path.slice(1) : path;\n\t\tnormalizedPath = normalizedPath.endsWith(\"/\")\n\t\t\t? normalizedPath.slice(0, -1)\n\t\t\t: normalizedPath;\n\n\t\t// If the routeContext does not exist, path is the absolute path.\n\t\t// If the routeContext exists, absolute path is routeContext's absolute path plus the path.\n\t\treturn routeContext === undefined\n\t\t\t? `/${normalizedPath}`\n\t\t\t: `${\n\t\t\t\t\trouteContext.absolutePath === \"/\" ? \"\" : routeContext.absolutePath\n\t\t\t }/${normalizedPath}`;\n\t}\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHelpers.d.mts","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iCAAiC;OAC9D,EACN,sBAAsB,EACtB,uBAAuB,EACvB,8BAA8B,EAC9B,MAAM,qCAAqC;AAW5C;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CA0BvD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,GAAG,KAAK,CAejF;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,YAAa,QAAQ,cACJ,CAAC;AAEhD;;GAEG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAC9B,SAAS,CAiBX;AAED;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,sBAAsB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAEvF;;GAEG;AACH,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GACjC,sBAAsB,GAAG,uBAAuB,CAalD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dataStoreHelpers.mjs","sourceRoot":"","sources":["../src/dataStoreHelpers.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreRegistry,\n\tIProvideFluidDataStoreRegistry,\n} from \"@fluidframework/runtime-definitions\";\nimport { generateErrorWithStack } from \"@fluidframework/telemetry-utils\";\n\ninterface IResponseException extends Error {\n\terrorFromRequestFluidObject: true;\n\tmessage: string;\n\tcode: number;\n\tstack?: string;\n\tunderlyingResponseHeaders?: { [key: string]: any };\n}\n\n/**\n * @internal\n */\nexport function exceptionToResponse(err: any): IResponse {\n\tconst status = 500;\n\tif (err !== null && typeof err === \"object\" && err.errorFromRequestFluidObject === true) {\n\t\tconst responseErr: IResponseException = err;\n\t\treturn {\n\t\t\tmimeType: \"text/plain\",\n\t\t\tstatus: responseErr.code,\n\t\t\tvalue: responseErr.message,\n\t\t\tget stack() {\n\t\t\t\treturn responseErr.stack;\n\t\t\t},\n\t\t\theaders: responseErr.underlyingResponseHeaders,\n\t\t};\n\t}\n\n\t// Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it\n\tconst errWithStack = generateErrorWithStack();\n\n\treturn {\n\t\tmimeType: \"text/plain\",\n\t\tstatus,\n\t\tvalue: `${err}`,\n\t\tget stack() {\n\t\t\treturn (err?.stack as string | undefined) ?? errWithStack.stack;\n\t\t},\n\t};\n}\n\n/**\n * @internal\n */\nexport function responseToException(response: IResponse, request: IRequest): Error {\n\tconst message = response.value;\n\tconst errWithStack = generateErrorWithStack();\n\tconst responseErr: Error & IResponseException = {\n\t\terrorFromRequestFluidObject: true,\n\t\tmessage,\n\t\tname: \"Error\",\n\t\tcode: response.status,\n\t\tget stack() {\n\t\t\treturn response.stack ?? errWithStack.stack;\n\t\t},\n\t\tunderlyingResponseHeaders: response.headers,\n\t};\n\n\treturn responseErr;\n}\n\n/**\n * @internal\n */\nexport const create404Response = (request: IRequest) =>\n\tcreateResponseError(404, \"not found\", request);\n\n/**\n * @internal\n */\nexport function createResponseError(\n\tstatus: number,\n\tvalue: string,\n\trequest: IRequest,\n\theaders?: { [key: string]: any },\n): IResponse {\n\tassert(status !== 200, 0x19b /* \"Cannot not create response error on 200 status\" */);\n\t// Omit query string which could contain personal data unfit for logging\n\tconst urlNoQuery = request.url?.split(\"?\")[0];\n\n\t// Capture error objects, not stack itself, as stack retrieval is very expensive operation, so we delay it\n\tconst errWithStack = generateErrorWithStack();\n\n\treturn {\n\t\tmimeType: \"text/plain\",\n\t\tstatus,\n\t\tvalue: urlNoQuery === undefined ? value : `${value}: ${urlNoQuery}`,\n\t\tget stack() {\n\t\t\treturn errWithStack.stack;\n\t\t},\n\t\theaders,\n\t};\n}\n\n/**\n * @internal\n */\nexport type Factory = IFluidDataStoreFactory & Partial<IProvideFluidDataStoreRegistry>;\n\n/**\n * @internal\n */\nexport function createDataStoreFactory(\n\ttype: string,\n\tfactory: Factory | Promise<Factory>,\n): IFluidDataStoreFactory & IFluidDataStoreRegistry {\n\treturn {\n\t\ttype,\n\t\tget IFluidDataStoreFactory() {\n\t\t\treturn this;\n\t\t},\n\t\tget IFluidDataStoreRegistry() {\n\t\t\treturn this;\n\t\t},\n\t\tinstantiateDataStore: async (context, existing) =>\n\t\t\t(await factory).instantiateDataStore(context, existing),\n\t\tget: async (name: string) => (await factory).IFluidDataStoreRegistry?.get(name),\n\t};\n}\n"]}
|
package/lib/handles.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handles.d.mts","sourceRoot":"","sources":["../src/handles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEjC,IAAI,EAAE,kBAAkB,CAAC;IAGzB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,UAAW,GAAG,+BACV,CAAC"}
|
package/lib/handles.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handles.mjs","sourceRoot":"","sources":["../src/handles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAU,EAA8B,EAAE,CAC5E,KAAK,EAAE,IAAI,KAAK,kBAAkB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * JSON serialized form of an IFluidHandle\n * @internal\n */\nexport interface ISerializedHandle {\n\t// Marker to indicate to JSON.parse that the object is a Fluid handle\n\ttype: \"__fluid_handle__\";\n\n\t// URL to the object. Relative URLs are relative to the handle context passed to the stringify.\n\turl: string;\n}\n\n/**\n * Is the input object a @see ISerializedHandle?\n * @internal\n */\nexport const isSerializedHandle = (value: any): value is ISerializedHandle =>\n\tvalue?.type === \"__fluid_handle__\";\n"]}
|
package/lib/index.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
export { generateHandleContextPath } from "./dataStoreHandleContextUtils.mjs";
|
|
6
|
-
export { create404Response, createDataStoreFactory, createResponseError, exceptionToResponse, Factory, responseToException, } from "./dataStoreHelpers.mjs";
|
|
7
|
-
export { ISerializedHandle, isSerializedHandle } from "./handles.mjs";
|
|
8
|
-
export { ObjectStoragePartition } from "./objectstoragepartition.mjs";
|
|
9
|
-
export { getNormalizedObjectStoragePathParts, listBlobsAtTreePath } from "./objectstorageutils.mjs";
|
|
10
|
-
export { RequestParser } from "./requestParser.mjs";
|
|
11
|
-
export { RuntimeFactoryHelper } from "./runtimeFactoryHelper.mjs";
|
|
12
|
-
export { addBlobToSummary, addSummarizeResultToSummary, addTreeToSummary, calculateStats, convertSnapshotTreeToSummaryTree, convertSummaryTreeToITree, convertToSummaryTree, convertToSummaryTreeWithStats, GCDataBuilder, getBlobSize, mergeStats, SummaryTreeBuilder, TelemetryContext, utf8ByteLength, } from "./summaryUtils.mjs";
|
|
13
|
-
export { unpackChildNodesUsedRoutes } from "./unpackUsedRoutes.mjs";
|
|
14
|
-
export { ReadAndParseBlob, seqFromTree } from "./utils.mjs";
|
|
15
|
-
//# sourceMappingURL=index.d.mts.map
|
package/lib/index.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,yBAAyB,EAAE;OAC7B,EACN,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,OAAO,EACP,mBAAmB,GACnB;OACM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE;OACzC,EAAE,sBAAsB,EAAE;OAC1B,EAAE,mCAAmC,EAAE,mBAAmB,EAAE;OAC5D,EAAE,aAAa,EAAE;OACjB,EAAE,oBAAoB,EAAE;OACxB,EACN,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,cAAc,EACd,gCAAgC,EAChC,yBAAyB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,aAAa,EACb,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,GACd;OACM,EAAE,0BAA0B,EAAE;OAC9B,EAAE,gBAAgB,EAAE,WAAW,EAAE"}
|