@fluidframework/runtime-utils 2.0.0-dev-rc.3.0.0.250606 → 2.0.0-dev-rc.3.0.0.253463

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 (63) hide show
  1. package/api-report/runtime-utils.api.md +9 -9
  2. package/dist/dataStoreHelpers.d.ts +1 -1
  3. package/dist/dataStoreHelpers.d.ts.map +1 -1
  4. package/dist/dataStoreHelpers.js +6 -6
  5. package/dist/dataStoreHelpers.js.map +1 -1
  6. package/dist/objectstoragepartition.js +2 -2
  7. package/dist/objectstoragepartition.js.map +1 -1
  8. package/dist/runtime-utils-alpha.d.ts +9 -9
  9. package/dist/runtime-utils-beta.d.ts +9 -9
  10. package/dist/runtime-utils-public.d.ts +9 -9
  11. package/dist/runtime-utils-untrimmed.d.ts +9 -9
  12. package/dist/runtimeFactoryHelper.d.ts +2 -2
  13. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  14. package/dist/runtimeFactoryHelper.js.map +1 -1
  15. package/dist/summaryUtils.d.ts +3 -2
  16. package/dist/summaryUtils.d.ts.map +1 -1
  17. package/dist/summaryUtils.js +7 -7
  18. package/dist/summaryUtils.js.map +1 -1
  19. package/dist/unpackUsedRoutes.js +2 -2
  20. package/dist/unpackUsedRoutes.js.map +1 -1
  21. package/dist/utils.js +2 -2
  22. package/dist/utils.js.map +1 -1
  23. package/lib/dataStoreHelpers.d.ts +1 -1
  24. package/lib/dataStoreHelpers.d.ts.map +1 -1
  25. package/lib/dataStoreHelpers.js +2 -2
  26. package/lib/dataStoreHelpers.js.map +1 -1
  27. package/lib/objectstoragepartition.js +1 -1
  28. package/lib/objectstoragepartition.js.map +1 -1
  29. package/lib/runtime-utils-alpha.d.ts +9 -9
  30. package/lib/runtime-utils-beta.d.ts +9 -9
  31. package/lib/runtime-utils-public.d.ts +9 -9
  32. package/lib/runtime-utils-untrimmed.d.ts +9 -9
  33. package/lib/runtimeFactoryHelper.d.ts +2 -2
  34. package/lib/runtimeFactoryHelper.d.ts.map +1 -1
  35. package/lib/runtimeFactoryHelper.js.map +1 -1
  36. package/lib/summaryUtils.d.ts +3 -2
  37. package/lib/summaryUtils.d.ts.map +1 -1
  38. package/lib/summaryUtils.js +2 -2
  39. package/lib/summaryUtils.js.map +1 -1
  40. package/lib/tsdoc-metadata.json +11 -0
  41. package/lib/unpackUsedRoutes.js +1 -1
  42. package/lib/unpackUsedRoutes.js.map +1 -1
  43. package/lib/utils.js +1 -1
  44. package/lib/utils.js.map +1 -1
  45. package/package.json +12 -24
  46. package/src/dataStoreHelpers.ts +3 -3
  47. package/src/objectstoragepartition.ts +1 -1
  48. package/src/runtimeFactoryHelper.ts +2 -2
  49. package/src/summaryUtils.ts +8 -4
  50. package/src/unpackUsedRoutes.ts +1 -1
  51. package/src/utils.ts +1 -1
  52. package/lib/test/dataStoreHelpers.spec.js +0 -29
  53. package/lib/test/dataStoreHelpers.spec.js.map +0 -1
  54. package/lib/test/requestParser.spec.js +0 -111
  55. package/lib/test/requestParser.spec.js.map +0 -1
  56. package/lib/test/runtimeFactoryHelper.spec.js +0 -44
  57. package/lib/test/runtimeFactoryHelper.spec.js.map +0 -1
  58. package/lib/test/summaryUtils.spec.js +0 -283
  59. package/lib/test/summaryUtils.spec.js.map +0 -1
  60. package/lib/test/types/validateRuntimeUtilsPrevious.generated.js +0 -58
  61. package/lib/test/types/validateRuntimeUtilsPrevious.generated.js.map +0 -1
  62. package/lib/test/utils.spec.js +0 -65
  63. package/lib/test/utils.spec.js.map +0 -1
@@ -4,13 +4,13 @@
4
4
  */
5
5
 
6
6
  import { IRequest, IResponse } from "@fluidframework/core-interfaces";
7
- import { assert } from "@fluidframework/core-utils";
7
+ import { assert } from "@fluidframework/core-utils/internal";
8
8
  import {
9
9
  IFluidDataStoreFactory,
10
10
  IFluidDataStoreRegistry,
11
11
  IProvideFluidDataStoreRegistry,
12
- } from "@fluidframework/runtime-definitions";
13
- import { generateErrorWithStack } from "@fluidframework/telemetry-utils";
12
+ } from "@fluidframework/runtime-definitions/internal";
13
+ import { generateErrorWithStack } from "@fluidframework/telemetry-utils/internal";
14
14
 
15
15
  interface IResponseException extends Error {
16
16
  errorFromRequestFluidObject: true;
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/core-utils";
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { IChannelStorageService } from "@fluidframework/datastore-definitions";
8
8
 
9
9
  /**
@@ -7,8 +7,8 @@ import {
7
7
  IContainerContext,
8
8
  IRuntime,
9
9
  IRuntimeFactory,
10
- } from "@fluidframework/container-definitions";
11
- import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
10
+ } from "@fluidframework/container-definitions/internal";
11
+ import { IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
12
12
 
13
13
  /**
14
14
  * @alpha
@@ -9,10 +9,14 @@ import {
9
9
  bufferToString,
10
10
  fromBase64ToUtf8,
11
11
  } from "@fluid-internal/client-utils";
12
- import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
12
+ import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions/internal";
13
13
  import type { TelemetryBaseEventPropertyType } from "@fluidframework/core-interfaces";
14
- import { assert, unreachableCase } from "@fluidframework/core-utils";
15
- import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "@fluidframework/driver-utils";
14
+ import { assert, unreachableCase } from "@fluidframework/core-utils/internal";
15
+ import {
16
+ AttachmentTreeEntry,
17
+ BlobTreeEntry,
18
+ TreeTreeEntry,
19
+ } from "@fluidframework/driver-utils/internal";
16
20
  import {
17
21
  ISummaryBlob,
18
22
  ISummaryTree,
@@ -24,11 +28,11 @@ import {
24
28
  } from "@fluidframework/protocol-definitions";
25
29
  import {
26
30
  IGarbageCollectionData,
27
- ISummarizeResult,
28
31
  ISummaryStats,
29
32
  ISummaryTreeWithStats,
30
33
  ITelemetryContext,
31
34
  } from "@fluidframework/runtime-definitions";
35
+ import { ISummarizeResult } from "@fluidframework/runtime-definitions/internal";
32
36
 
33
37
  /**
34
38
  * Combines summary stats by adding their totals together.
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/core-utils";
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
7
 
8
8
  /**
9
9
  * Helper function that unpacks the used routes of children from a given node's used routes.
package/src/utils.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/core-utils";
6
+ import { assert } from "@fluidframework/core-utils/internal";
7
7
  import { IDocumentAttributes, ISnapshotTree } from "@fluidframework/protocol-definitions";
8
8
 
9
9
  /**
@@ -1,29 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { strict as assert } from "assert";
6
- import { createResponseError, exceptionToResponse, responseToException, } from "../dataStoreHelpers.js";
7
- describe("createResponseError", () => {
8
- it("Strip URL query param ", () => {
9
- const response = createResponseError(400, "SomeValue", { url: "http://foo.com?a=b" });
10
- assert.strictEqual(response.value, "SomeValue: http://foo.com");
11
- });
12
- it("request / response / error handling ", () => {
13
- const request = { url: "/foo/bar?something" };
14
- const response = createResponseError(401, "some value", request);
15
- const value = "some value: /foo/bar";
16
- assert.strict.equal(response.status, 401, "status code");
17
- assert.strict.equal(response.value, value, "value");
18
- const stack = response.stack;
19
- assert.strict.notEqual(stack, undefined, "stack");
20
- const exception = responseToException(response, request);
21
- assert.strict.equal(exception.message, value, "value2");
22
- assert.strict.equal(exception.stack, stack, "stack2");
23
- const response2 = exceptionToResponse(exception);
24
- assert.strict.equal(response2.status, 401, "status code3");
25
- assert.strict.equal(response2.value, value, "value3");
26
- assert.strict.equal(response.stack, stack, "stack3");
27
- });
28
- });
29
- //# sourceMappingURL=dataStoreHelpers.spec.js.map
@@ -1 +0,0 @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C,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACxD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAEtD,MAAM,SAAS,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport {\n\tcreateResponseError,\n\texceptionToResponse,\n\tresponseToException,\n} from \"../dataStoreHelpers.js\";\n\ndescribe(\"createResponseError\", () => {\n\tit(\"Strip URL query param \", () => {\n\t\tconst response = createResponseError(400, \"SomeValue\", { url: \"http://foo.com?a=b\" });\n\t\tassert.strictEqual(response.value, \"SomeValue: http://foo.com\");\n\t});\n\n\tit(\"request / response / error handling \", () => {\n\t\tconst request = { url: \"/foo/bar?something\" };\n\t\tconst response = createResponseError(401, \"some value\", request);\n\t\tconst value = \"some value: /foo/bar\";\n\t\tassert.strict.equal(response.status, 401, \"status code\");\n\t\tassert.strict.equal(response.value, value, \"value\");\n\t\tconst stack = response.stack;\n\t\tassert.strict.notEqual(stack, undefined, \"stack\");\n\n\t\tconst exception = responseToException(response, request);\n\t\tassert.strict.equal(exception.message, value, \"value2\");\n\t\tassert.strict.equal(exception.stack, stack, \"stack2\");\n\n\t\tconst response2 = exceptionToResponse(exception);\n\t\tassert.strict.equal(response2.status, 401, \"status code3\");\n\t\tassert.strict.equal(response2.value, value, \"value3\");\n\t\tassert.strict.equal(response.stack, stack, \"stack3\");\n\t});\n});\n"]}
@@ -1,111 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { strict as assert } from "assert";
6
- import { RequestParser } from "../requestParser.js";
7
- describe("RequestParser", () => {
8
- describe(".getPathParts", () => {
9
- it("Parse Data Store Id", () => {
10
- const url = "dataStoreId";
11
- const pathParts = RequestParser.getPathParts(url);
12
- assert.strictEqual(pathParts.length, 1);
13
- assert.strictEqual(pathParts[0], "dataStoreId");
14
- });
15
- it("Parse Data Store Id with /", () => {
16
- const url = "/dataStoreId/";
17
- const pathParts = RequestParser.getPathParts(url);
18
- assert.strictEqual(pathParts.length, 1);
19
- assert.strictEqual(pathParts[0], "dataStoreId");
20
- });
21
- it("Parse Data Store Id with query", () => {
22
- const url = "/dataStoreId/?foo=bar";
23
- const pathParts = RequestParser.getPathParts(url);
24
- assert.strictEqual(pathParts.length, 1);
25
- assert.strictEqual(pathParts[0], "dataStoreId");
26
- });
27
- it("Parse Data Store Id with sub route with query", () => {
28
- const url = "/dataStoreId//some/route?foo=bar";
29
- const pathParts = RequestParser.getPathParts(url);
30
- assert.strictEqual(pathParts.length, 3);
31
- assert.strictEqual(pathParts[0], "dataStoreId");
32
- assert.strictEqual(pathParts[1], "some");
33
- assert.strictEqual(pathParts[2], "route");
34
- });
35
- it("Parse encoded Data Store Id", () => {
36
- const url = "data%20store%20Id";
37
- const pathParts = RequestParser.getPathParts(url);
38
- assert.strictEqual(pathParts.length, 1);
39
- assert.strictEqual(pathParts[0], "data store Id");
40
- });
41
- });
42
- describe(".createSubRequest with special characters", () => {
43
- let requestParser;
44
- beforeEach(() => {
45
- requestParser = RequestParser.create({ url: "//dataStoreId!@//some!@//route!@//" });
46
- });
47
- it("Create request from part 0", () => {
48
- assert.strictEqual(requestParser.createSubRequest(0).url, "/dataStoreId!@/some!@/route!@");
49
- });
50
- it("Create request from part 1", () => {
51
- assert.strictEqual(requestParser.createSubRequest(1).url, "/some!@/route!@");
52
- });
53
- it("Create request from part 2", () => {
54
- assert.strictEqual(requestParser.createSubRequest(2).url, "/route!@");
55
- });
56
- it("Create request from parts length ", () => {
57
- assert.strictEqual(requestParser.createSubRequest(3).url, "/");
58
- });
59
- it("Create request from invalid part ", () => {
60
- assert.throws(() => requestParser.createSubRequest(4));
61
- assert.throws(() => requestParser.createSubRequest(-1));
62
- });
63
- });
64
- describe(".createSubRequest with special urls", () => {
65
- it("Create request for `/`", () => {
66
- const testRequestParser = RequestParser.create({ url: "/" });
67
- assert.strictEqual(testRequestParser.createSubRequest(0).url, "/");
68
- assert.throws(() => testRequestParser.createSubRequest(1));
69
- assert.throws(() => testRequestParser.createSubRequest(-1));
70
- });
71
- it("Create request from empty string", () => {
72
- const testRequestParser = RequestParser.create({ url: "" });
73
- assert.strictEqual(testRequestParser.createSubRequest(0).url, "/");
74
- assert.throws(() => testRequestParser.createSubRequest(1));
75
- assert.throws(() => testRequestParser.createSubRequest(-1));
76
- });
77
- it("Create request for just query params", () => {
78
- const testRequestParser = RequestParser.create({ url: "/?query" });
79
- assert.strictEqual(testRequestParser.createSubRequest(0).url, "/?query");
80
- assert.throws(() => testRequestParser.createSubRequest(1));
81
- assert.throws(() => testRequestParser.createSubRequest(-1));
82
- });
83
- });
84
- const testSubRequest = function (uri) {
85
- describe(".createSubRequest with query params", () => {
86
- let requestParser2;
87
- beforeEach(() => {
88
- requestParser2 = RequestParser.create({ url: uri });
89
- });
90
- it("Create request from part 0", () => {
91
- assert.strictEqual(requestParser2.createSubRequest(0).url, "/dataStoreId/some/route/?query1=1&query2=2");
92
- });
93
- it("Create request from part 1", () => {
94
- assert.strictEqual(requestParser2.createSubRequest(1).url, "/some/route/?query1=1&query2=2");
95
- });
96
- it("Create request from part 2", () => {
97
- assert.strictEqual(requestParser2.createSubRequest(2).url, "/route/?query1=1&query2=2");
98
- });
99
- it("Create request from parts length", () => {
100
- assert.strictEqual(requestParser2.createSubRequest(3).url, "/?query1=1&query2=2");
101
- });
102
- it("Create request from invalid part ", () => {
103
- assert.throws(() => requestParser2.createSubRequest(4));
104
- assert.throws(() => requestParser2.createSubRequest(-1));
105
- });
106
- });
107
- };
108
- testSubRequest("/dataStoreId/some/route/?query1=1&query2=2");
109
- testSubRequest("dataStoreId/some/route/?query1=1&query2=2");
110
- });
111
- //# sourceMappingURL=requestParser.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"requestParser.spec.js","sourceRoot":"","sources":["../../src/test/requestParser.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC9B,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;YAC9B,MAAM,GAAG,GAAG,aAAa,CAAC;YAC1B,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAClD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;YACrC,MAAM,GAAG,GAAG,eAAe,CAAC;YAC5B,MAAM,SAAS,GAAG,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YAClD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;YACxC,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,CA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AC,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1D,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IACF,cAAc,CAAC,4CAA4C,CAAC,CAAC;IAC7D,cAAc,CAAC,2CAA2C,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { strict as assert } from \"assert\";\nimport { RequestParser } from \"../requestParser.js\";\n\ndescribe(\"RequestParser\", () => {\n\tdescribe(\".getPathParts\", () => {\n\t\tit(\"Parse Data Store Id\", () => {\n\t\t\tconst url = \"dataStoreId\";\n\t\t\tconst pathParts = RequestParser.getPathParts(url);\n\t\t\tassert.strictEqual(pathParts.length, 1);\n\t\t\tassert.strictEqual(pathParts[0], \"dataStoreId\");\n\t\t});\n\t\tit(\"Parse Data Store Id with /\", () => {\n\t\t\tconst url = \"/dataStoreId/\";\n\t\t\tconst pathParts = RequestParser.getPathParts(url);\n\t\t\tassert.strictEqual(pathParts.length, 1);\n\t\t\tassert.strictEqual(pathParts[0], \"dataStoreId\");\n\t\t});\n\t\tit(\"Parse Data Store Id with query\", () => {\n\t\t\tconst url = \"/dataStoreId/?foo=bar\";\n\t\t\tconst pathParts = RequestParser.getPathParts(url);\n\t\t\tassert.strictEqual(pathParts.length, 1);\n\t\t\tassert.strictEqual(pathParts[0], \"dataStoreId\");\n\t\t});\n\t\tit(\"Parse Data Store Id with sub route with query\", () => {\n\t\t\tconst url = \"/dataStoreId//some/route?foo=bar\";\n\t\t\tconst pathParts = RequestParser.getPathParts(url);\n\t\t\tassert.strictEqual(pathParts.length, 3);\n\t\t\tassert.strictEqual(pathParts[0], \"dataStoreId\");\n\t\t\tassert.strictEqual(pathParts[1], \"some\");\n\t\t\tassert.strictEqual(pathParts[2], \"route\");\n\t\t});\n\t\tit(\"Parse encoded Data Store Id\", () => {\n\t\t\tconst url = \"data%20store%20Id\";\n\t\t\tconst pathParts = RequestParser.getPathParts(url);\n\t\t\tassert.strictEqual(pathParts.length, 1);\n\t\t\tassert.strictEqual(pathParts[0], \"data store Id\");\n\t\t});\n\t});\n\tdescribe(\".createSubRequest with special characters\", () => {\n\t\tlet requestParser: RequestParser;\n\t\tbeforeEach(() => {\n\t\t\trequestParser = RequestParser.create({ url: \"//dataStoreId!@//some!@//route!@//\" });\n\t\t});\n\t\tit(\"Create request from part 0\", () => {\n\t\t\tassert.strictEqual(\n\t\t\t\trequestParser.createSubRequest(0).url,\n\t\t\t\t\"/dataStoreId!@/some!@/route!@\",\n\t\t\t);\n\t\t});\n\t\tit(\"Create request from part 1\", () => {\n\t\t\tassert.strictEqual(requestParser.createSubRequest(1).url, \"/some!@/route!@\");\n\t\t});\n\t\tit(\"Create request from part 2\", () => {\n\t\t\tassert.strictEqual(requestParser.createSubRequest(2).url, \"/route!@\");\n\t\t});\n\t\tit(\"Create request from parts length \", () => {\n\t\t\tassert.strictEqual(requestParser.createSubRequest(3).url, \"/\");\n\t\t});\n\t\tit(\"Create request from invalid part \", () => {\n\t\t\tassert.throws(() => requestParser.createSubRequest(4));\n\t\t\tassert.throws(() => requestParser.createSubRequest(-1));\n\t\t});\n\t});\n\n\tdescribe(\".createSubRequest with special urls\", () => {\n\t\tit(\"Create request for `/`\", () => {\n\t\t\tconst testRequestParser = RequestParser.create({ url: \"/\" });\n\t\t\tassert.strictEqual(testRequestParser.createSubRequest(0).url, \"/\");\n\t\t\tassert.throws(() => testRequestParser.createSubRequest(1));\n\t\t\tassert.throws(() => testRequestParser.createSubRequest(-1));\n\t\t});\n\t\tit(\"Create request from empty string\", () => {\n\t\t\tconst testRequestParser = RequestParser.create({ url: \"\" });\n\t\t\tassert.strictEqual(testRequestParser.createSubRequest(0).url, \"/\");\n\t\t\tassert.throws(() => testRequestParser.createSubRequest(1));\n\t\t\tassert.throws(() => testRequestParser.createSubRequest(-1));\n\t\t});\n\t\tit(\"Create request for just query params\", () => {\n\t\t\tconst testRequestParser = RequestParser.create({ url: \"/?query\" });\n\t\t\tassert.strictEqual(testRequestParser.createSubRequest(0).url, \"/?query\");\n\t\t\tassert.throws(() => testRequestParser.createSubRequest(1));\n\t\t\tassert.throws(() => testRequestParser.createSubRequest(-1));\n\t\t});\n\t});\n\n\tconst testSubRequest = function (uri: string) {\n\t\tdescribe(\".createSubRequest with query params\", () => {\n\t\t\tlet requestParser2: RequestParser;\n\t\t\tbeforeEach(() => {\n\t\t\t\trequestParser2 = RequestParser.create({ url: uri });\n\t\t\t});\n\t\t\tit(\"Create request from part 0\", () => {\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\trequestParser2.createSubRequest(0).url,\n\t\t\t\t\t\"/dataStoreId/some/route/?query1=1&query2=2\",\n\t\t\t\t);\n\t\t\t});\n\t\t\tit(\"Create request from part 1\", () => {\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\trequestParser2.createSubRequest(1).url,\n\t\t\t\t\t\"/some/route/?query1=1&query2=2\",\n\t\t\t\t);\n\t\t\t});\n\t\t\tit(\"Create request from part 2\", () => {\n\t\t\t\tassert.strictEqual(\n\t\t\t\t\trequestParser2.createSubRequest(2).url,\n\t\t\t\t\t\"/route/?query1=1&query2=2\",\n\t\t\t\t);\n\t\t\t});\n\t\t\tit(\"Create request from parts length\", () => {\n\t\t\t\tassert.strictEqual(requestParser2.createSubRequest(3).url, \"/?query1=1&query2=2\");\n\t\t\t});\n\t\t\tit(\"Create request from invalid part \", () => {\n\t\t\t\tassert.throws(() => requestParser2.createSubRequest(4));\n\t\t\t\tassert.throws(() => requestParser2.createSubRequest(-1));\n\t\t\t});\n\t\t});\n\t};\n\ttestSubRequest(\"/dataStoreId/some/route/?query1=1&query2=2\");\n\ttestSubRequest(\"dataStoreId/some/route/?query1=1&query2=2\");\n});\n"]}
@@ -1,44 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import Sinon from "sinon";
6
- import { RuntimeFactoryHelper } from "../runtimeFactoryHelper.js";
7
- class TestRuntimeFactoryHelper extends RuntimeFactoryHelper {
8
- constructor(runtime) {
9
- super();
10
- this.runtime = runtime;
11
- }
12
- async preInitialize(_context, _existing) {
13
- return this.runtime;
14
- }
15
- }
16
- describe("RuntimeFactoryHelper", () => {
17
- const sandbox = Sinon.createSandbox();
18
- const context = {};
19
- const runtime = {};
20
- let helper;
21
- let unit;
22
- beforeEach(() => {
23
- helper = new TestRuntimeFactoryHelper(runtime);
24
- unit = sandbox.mock(helper);
25
- unit.expects("preInitialize").once();
26
- unit.expects("hasInitialized").once();
27
- });
28
- afterEach(() => {
29
- sandbox.restore();
30
- });
31
- it("Instantiate when existing flag is `true`", async () => {
32
- unit.expects("instantiateFirstTime").never();
33
- unit.expects("instantiateFromExisting").once();
34
- await helper.instantiateRuntime(context, /* existing */ true);
35
- unit.verify();
36
- });
37
- it("Instantiate when existing flag is `false`", async () => {
38
- unit.expects("instantiateFirstTime").once();
39
- unit.expects("instantiateFromExisting").never();
40
- await helper.instantiateRuntime(context, /* existing */ false);
41
- unit.verify();
42
- });
43
- });
44
- //# sourceMappingURL=runtimeFactoryHelper.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtimeFactoryHelper.spec.js","sourceRoot":"","sources":["../../src/test/runtimeFactoryHelper.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,MAAM,wBAAyB,SAAQ,oBAAoB;IAC1D,YAA6B,OAAqC;QACjE,KAAK,EAAE,CAAC;QADoB,YAAO,GAAP,OAAO,CAA8B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AyB,CAAC,CAAC,KAAK,EAAE,CAAC;QAChD,MAAM,MAAM,CAAC,kBAAkB,CAAC,OAA4B,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAEpF,IAAI,CAAC,MAAM,EAAE,CAAC;IACf,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IContainerContext, IRuntime } from \"@fluidframework/container-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\nimport Sinon from \"sinon\";\nimport { RuntimeFactoryHelper } from \"../runtimeFactoryHelper.js\";\n\nclass TestRuntimeFactoryHelper extends RuntimeFactoryHelper {\n\tconstructor(private readonly runtime: IRuntime & IContainerRuntime) {\n\t\tsuper();\n\t}\n\n\tpublic async preInitialize(\n\t\t_context: IContainerContext,\n\t\t_existing: boolean,\n\t): Promise<IRuntime & IContainerRuntime> {\n\t\treturn this.runtime;\n\t}\n}\n\ndescribe(\"RuntimeFactoryHelper\", () => {\n\tconst sandbox: Sinon.SinonSandbox = Sinon.createSandbox();\n\tconst context: Partial<IContainerContext> = {};\n\tconst runtime: Partial<IRuntime & IContainerRuntime> = {};\n\tlet helper: TestRuntimeFactoryHelper;\n\tlet unit: Sinon.SinonMock;\n\n\tbeforeEach(() => {\n\t\thelper = new TestRuntimeFactoryHelper(runtime as IRuntime & IContainerRuntime);\n\t\tunit = sandbox.mock(helper);\n\t\tunit.expects(\"preInitialize\").once();\n\t\tunit.expects(\"hasInitialized\").once();\n\t});\n\n\tafterEach(() => {\n\t\tsandbox.restore();\n\t});\n\n\tit(\"Instantiate when existing flag is `true`\", async () => {\n\t\tunit.expects(\"instantiateFirstTime\").never();\n\t\tunit.expects(\"instantiateFromExisting\").once();\n\t\tawait helper.instantiateRuntime(context as IContainerContext, /* existing */ true);\n\n\t\tunit.verify();\n\t});\n\n\tit(\"Instantiate when existing flag is `false`\", async () => {\n\t\tunit.expects(\"instantiateFirstTime\").once();\n\t\tunit.expects(\"instantiateFromExisting\").never();\n\t\tawait helper.instantiateRuntime(context as IContainerContext, /* existing */ false);\n\n\t\tunit.verify();\n\t});\n});\n"]}
@@ -1,283 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { strict as assert } from "assert";
6
- import { IsoBuffer, Uint8ArrayToString, stringToBuffer } from "@fluid-internal/client-utils";
7
- import { BlobTreeEntry, TreeTreeEntry } from "@fluidframework/driver-utils";
8
- import { SummaryType, } from "@fluidframework/protocol-definitions";
9
- import { TelemetryContext, convertSnapshotTreeToSummaryTree, convertSummaryTreeToITree, convertToSummaryTree, utf8ByteLength, } from "../summaryUtils.js";
10
- describe("Summary Utils", () => {
11
- function assertSummaryTree(obj) {
12
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
13
- if (obj && obj.type === SummaryType.Tree) {
14
- return obj;
15
- }
16
- else {
17
- assert.fail("Object should be summary tree");
18
- }
19
- }
20
- function assertSummaryBlob(obj) {
21
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
22
- if (obj && obj.type === SummaryType.Blob) {
23
- return obj;
24
- }
25
- else {
26
- assert.fail("Object should be summary blob");
27
- }
28
- }
29
- function assertSummaryHandle(obj) {
30
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
31
- if (obj && obj.type === SummaryType.Handle) {
32
- return obj;
33
- }
34
- else {
35
- assert.fail("Object should be summary handle");
36
- }
37
- }
38
- describe("ITree <-> ISummaryTree", () => {
39
- let tree;
40
- beforeEach(() => {
41
- const base64Content = IsoBuffer.from("test-b64").toString("base64");
42
- tree = {
43
- entries: [
44
- new TreeTreeEntry("t", {
45
- entries: [
46
- new BlobTreeEntry("bu8", "test-u8"),
47
- new BlobTreeEntry("b64", base64Content, "base64"),
48
- new TreeTreeEntry("tu", {
49
- entries: [],
50
- unreferenced: true,
51
- groupId: undefined,
52
- }),
53
- ],
54
- unreferenced: undefined,
55
- groupId: undefined,
56
- }),
57
- new BlobTreeEntry("b", "test-blob"),
58
- new TreeTreeEntry("h", {
59
- id: "test-handle",
60
- entries: [new BlobTreeEntry("ignore", "this-should-be-ignored")],
61
- }),
62
- new TreeTreeEntry("unref", {
63
- entries: [],
64
- unreferenced: true,
65
- groupId: undefined,
66
- }),
67
- new TreeTreeEntry("groupId", {
68
- entries: [],
69
- unreferenced: undefined,
70
- groupId: "group-id",
71
- }),
72
- ],
73
- unreferenced: undefined,
74
- groupId: undefined,
75
- };
76
- });
77
- it("Should convert ITree to ISummaryTree correctly", () => {
78
- const summaryResults = convertToSummaryTree(tree);
79
- const summaryTree = assertSummaryTree(summaryResults.summary);
80
- // blobs should parse
81
- const blob = assertSummaryBlob(summaryTree.tree.b);
82
- assert.strictEqual(blob.content, "test-blob");
83
- // trees with ids should become handles
84
- const handle = assertSummaryHandle(summaryTree.tree.h);
85
- assert.strictEqual(handle.handleType, SummaryType.Tree);
86
- assert.strictEqual(handle.handle, "test-handle");
87
- // subtrees should recurse
88
- const subTree = assertSummaryTree(summaryTree.tree.t);
89
- const subBlobUtf8 = assertSummaryBlob(subTree.tree.bu8);
90
- assert.strictEqual(subBlobUtf8.content, "test-u8");
91
- const subBlobBase64 = assertSummaryBlob(subTree.tree.b64);
92
- assert.strictEqual(Uint8ArrayToString(subBlobBase64.content), "test-b64");
93
- const subTreeUnref = assertSummaryTree(subTree.tree.tu);
94
- assert.strictEqual(Object.keys(subTreeUnref.tree).length, 0, "There should be no entries in tu subtree");
95
- });
96
- it("Should convert ITree to ISummaryTree correctly with fullTree enabled", () => {
97
- const summaryResults = convertToSummaryTree(tree, true);
98
- const summaryTree = assertSummaryTree(summaryResults.summary);
99
- // blobs should parse
100
- const blob = assertSummaryBlob(summaryTree.tree.b);
101
- assert.strictEqual(blob.content, "test-blob");
102
- // trees with ids should not become handles
103
- const usuallyIgnoredSubtree = assertSummaryTree(summaryTree.tree.h);
104
- const usuallyIgnoredBlob = assertSummaryBlob(usuallyIgnoredSubtree.tree.ignore);
105
- assert.strictEqual(usuallyIgnoredBlob.content, "this-should-be-ignored");
106
- // subtrees should recurse
107
- const subTree = assertSummaryTree(summaryTree.tree.t);
108
- const subBlobUtf8 = assertSummaryBlob(subTree.tree.bu8);
109
- assert.strictEqual(subBlobUtf8.content, "test-u8");
110
- const subBlobBase64 = assertSummaryBlob(subTree.tree.b64);
111
- assert.strictEqual(Uint8ArrayToString(subBlobBase64.content), "test-b64");
112
- const subUnrefTree = assertSummaryTree(subTree.tree.tu);
113
- assert.strictEqual(Object.keys(subUnrefTree.tree).length, 0, "There should be no entries in tu subtree");
114
- });
115
- it("Should calculate summary data correctly", () => {
116
- const summaryResults = convertToSummaryTree(tree);
117
- // nodes should count
118
- assert.strictEqual(summaryResults.stats.blobNodeCount, 3);
119
- assert.strictEqual(summaryResults.stats.handleNodeCount, 1);
120
- assert.strictEqual(summaryResults.stats.treeNodeCount, 5);
121
- const bufferLength = IsoBuffer.from("test-b64").byteLength +
122
- IsoBuffer.from("test-blob").byteLength +
123
- IsoBuffer.from("test-u8").byteLength;
124
- assert.strictEqual(summaryResults.stats.totalBlobSize, bufferLength);
125
- });
126
- it("should convert unreferenced state correctly", () => {
127
- const summaryResults = convertToSummaryTree(tree);
128
- const summaryTree = assertSummaryTree(summaryResults.summary);
129
- assert.strictEqual(summaryTree.unreferenced, undefined, "The root summary tree should be referenced");
130
- const subTreeT = assertSummaryTree(summaryTree.tree.t);
131
- assert.strictEqual(subTreeT.unreferenced, undefined, "The t subtree should be referenced");
132
- const subTreeTUnrefTree = assertSummaryTree(subTreeT.tree.tu);
133
- assert.strictEqual(subTreeTUnrefTree.unreferenced, true, "The tu subtree of t should be referenced");
134
- const subTreeUnref = assertSummaryTree(summaryTree.tree.unref);
135
- assert.strictEqual(subTreeUnref.unreferenced, true, "The unref subtree should be unreferenced");
136
- });
137
- it("should convert ISummaryTree to ITree correctly", () => {
138
- // convertSummaryTreeToITree API does not accept a tree with handles. So, remove handles from the ITree.
139
- const treeWithoutHandles = {
140
- entries: tree.entries.filter((treeEntry) => {
141
- return treeEntry.path !== "h";
142
- }),
143
- unreferenced: undefined,
144
- groupId: undefined,
145
- };
146
- const summaryResults = convertToSummaryTree(treeWithoutHandles);
147
- const summaryTree = assertSummaryTree(summaryResults.summary);
148
- // Covert the ISummaryTree back to ITree and validate that it matches with the original tree.
149
- const iTree = convertSummaryTreeToITree(summaryTree);
150
- assert.deepStrictEqual(treeWithoutHandles, iTree, "Could not covert back to ITree correctly");
151
- });
152
- });
153
- describe("ISnapshotTree -> ISummaryTree", () => {
154
- let snapshotTree;
155
- beforeEach(() => {
156
- snapshotTree = {
157
- blobs: {
158
- "b": "blob-b",
159
- "blob-b": IsoBuffer.from("test-blob").toString("base64"),
160
- },
161
- trees: {
162
- t: {
163
- blobs: {
164
- "bu8": "blob-bu8",
165
- "blob-bu8": IsoBuffer.from("test-u8").toString("base64"),
166
- "b64": "blob-b64",
167
- "blob-b64": IsoBuffer.from("test-b64").toString("base64"),
168
- },
169
- trees: {
170
- tu: {
171
- blobs: {},
172
- trees: {},
173
- unreferenced: true,
174
- groupId: undefined,
175
- },
176
- },
177
- },
178
- unref: {
179
- blobs: {},
180
- trees: {},
181
- unreferenced: true,
182
- groupId: undefined,
183
- },
184
- groupId: {
185
- blobs: {},
186
- trees: {},
187
- unreferenced: true,
188
- groupId: "group-id",
189
- },
190
- },
191
- };
192
- });
193
- it("Should convert correctly", () => {
194
- const summaryResults = convertSnapshotTreeToSummaryTree(snapshotTree);
195
- const summaryTree = assertSummaryTree(summaryResults.summary);
196
- // blobs should parse
197
- const blob = assertSummaryBlob(summaryTree.tree.b);
198
- assert.strictEqual(blob.content, "test-blob");
199
- // subtrees should recurse
200
- const subTree = assertSummaryTree(summaryTree.tree.t);
201
- const subBlobUtf8 = assertSummaryBlob(subTree.tree.bu8);
202
- assert.strictEqual(subBlobUtf8.content, "test-u8");
203
- const subBlobBase64 = assertSummaryBlob(subTree.tree.b64);
204
- assert.strictEqual(Uint8ArrayToString(subBlobBase64.content), "test-b64");
205
- const subTreeUnref = assertSummaryTree(subTree.tree.tu);
206
- assert.strictEqual(Object.keys(subTreeUnref.tree).length, 0, "There should be no entries in tu subtree");
207
- });
208
- it("Should calculate summary data correctly", () => {
209
- const summaryResults = convertSnapshotTreeToSummaryTree(snapshotTree);
210
- // nodes should count
211
- assert.strictEqual(summaryResults.stats.blobNodeCount, 3);
212
- assert.strictEqual(summaryResults.stats.handleNodeCount, 0);
213
- assert.strictEqual(summaryResults.stats.treeNodeCount, 5);
214
- const bufferLength = IsoBuffer.from("test-b64").byteLength +
215
- IsoBuffer.from("test-blob").byteLength +
216
- IsoBuffer.from("test-u8").byteLength;
217
- assert.strictEqual(summaryResults.stats.totalBlobSize, bufferLength);
218
- });
219
- it("should convert unreferenced state correctly", () => {
220
- const summaryResults = convertSnapshotTreeToSummaryTree(snapshotTree);
221
- const summaryTree = assertSummaryTree(summaryResults.summary);
222
- assert.strictEqual(summaryTree.unreferenced, undefined, "The root summary tree should be referenced");
223
- const subTreeT = assertSummaryTree(summaryTree.tree.t);
224
- assert.strictEqual(subTreeT.unreferenced, undefined, "The t subtree should be referenced");
225
- const subTreeTUnrefTree = assertSummaryTree(subTreeT.tree.tu);
226
- assert.strictEqual(subTreeTUnrefTree.unreferenced, true, "The tu subtree of t should be referenced");
227
- const subTreeUnref = assertSummaryTree(summaryTree.tree.unref);
228
- assert.strictEqual(subTreeUnref.unreferenced, true, "The unref subtree should be unreferenced");
229
- });
230
- it("should convert groupId state correctly", () => {
231
- const summaryResults = convertSnapshotTreeToSummaryTree(snapshotTree);
232
- const summaryTree = assertSummaryTree(summaryResults.summary);
233
- assert.strictEqual(summaryTree.groupId, undefined, "The root summary tree should not have groupId");
234
- const subTreeT = assertSummaryTree(summaryTree.tree.t);
235
- assert.strictEqual(subTreeT.groupId, undefined, "The t subtree not have groupId");
236
- const subTreeTUnrefTree = assertSummaryTree(subTreeT.tree.tu);
237
- assert.strictEqual(subTreeTUnrefTree.groupId, undefined, "The tu subtree of t not have groupId");
238
- const subTreeUnref = assertSummaryTree(summaryTree.tree.unref);
239
- assert.strictEqual(subTreeUnref.groupId, undefined, "The groupId should not be set");
240
- const subTreeGroupId = assertSummaryTree(summaryTree.tree.groupId);
241
- assert.strictEqual(subTreeGroupId.groupId, "group-id", "The groupId should be set");
242
- });
243
- });
244
- describe("utf8ByteLength()", () => {
245
- it("gives correct utf8 byte length", () => {
246
- const a = [
247
- "prague is a city in europe",
248
- "ᚠᛇᚻ᛫ᛒᛦᚦ᛫ᚠᚱᚩᚠᚢᚱ᛫ᚠᛁᚱᚪ᛫ᚷᛖᚻᚹᛦᛚᚳᚢᛗ",
249
- "Τὴ γλῶσσα μοῦ ἔδωσαν ἑλληνικὴ",
250
- "На берегу пустынных волн",
251
- "⠊⠀⠉⠁⠝⠀⠑⠁⠞⠀⠛⠇⠁⠎⠎⠀⠁⠝⠙⠀⠊⠞⠀⠙⠕⠑⠎⠝⠞⠀⠓⠥⠗⠞⠀⠍⠑",
252
- "أنا قادر على أكل الزجاج و هذا لا يؤلمني.",
253
- " 我能吞下玻璃而不傷身體。",
254
- "ᐊᓕᒍᖅ ᓂᕆᔭᕌᖓᒃᑯ ᓱᕋᙱᑦᑐᓐᓇᖅᑐᖓ",
255
- "🤦🏼‍♂️",
256
- "🏴󠁧󠁢󠁷󠁬󠁳󠁿",
257
- "���",
258
- "������",
259
- ];
260
- a.map((s) => assert.strictEqual(utf8ByteLength(s), stringToBuffer(s, "utf8").byteLength, s));
261
- });
262
- });
263
- describe("TelemetryContext", () => {
264
- it("Should serialize properly", () => {
265
- const telemetryContext = new TelemetryContext();
266
- telemetryContext.set("pre1_", "prop1", 10);
267
- telemetryContext.set("pre2_", "prop1", "10");
268
- telemetryContext.set("pre2_", "prop2", true);
269
- telemetryContext.set("pre1_", "prop2", undefined);
270
- telemetryContext.setMultiple("pre3_", "obj1", { prop1: "1", prop2: 2, prop3: true });
271
- const serialized = telemetryContext.serialize();
272
- const obj = JSON.parse(serialized);
273
- assert.strictEqual(obj.pre1_prop1, 10);
274
- assert.strictEqual(obj.pre1_prop2, undefined);
275
- assert.strictEqual(obj.pre2_prop1, "10");
276
- assert.strictEqual(obj.pre2_prop2, true);
277
- assert.strictEqual(obj.pre3_obj1_prop1, "1");
278
- assert.strictEqual(obj.pre3_obj1_prop2, 2);
279
- assert.strictEqual(obj.pre3_obj1_prop3, true);
280
- });
281
- });
282
- });
283
- //# sourceMappingURL=summaryUtils.spec.js.map