@fluidframework/runtime-utils 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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.
Files changed (96) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/dataStoreHandleContextUtils.d.ts.map +1 -1
  5. package/dist/dataStoreHandleContextUtils.js +3 -1
  6. package/dist/dataStoreHandleContextUtils.js.map +1 -1
  7. package/dist/dataStoreHelpers.d.ts.map +1 -1
  8. package/dist/dataStoreHelpers.js +23 -7
  9. package/dist/dataStoreHelpers.js.map +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/objectstoragepartition.d.ts.map +1 -1
  14. package/dist/objectstoragepartition.js.map +1 -1
  15. package/dist/objectstorageutils.d.ts.map +1 -1
  16. package/dist/objectstorageutils.js.map +1 -1
  17. package/dist/packageVersion.d.ts +1 -1
  18. package/dist/packageVersion.js +1 -1
  19. package/dist/packageVersion.js.map +1 -1
  20. package/dist/requestParser.d.ts.map +1 -1
  21. package/dist/requestParser.js.map +1 -1
  22. package/dist/runtimeFactoryHelper.d.ts.map +1 -1
  23. package/dist/runtimeFactoryHelper.js +6 -2
  24. package/dist/runtimeFactoryHelper.js.map +1 -1
  25. package/dist/summarizerNode/summarizerNode.d.ts +25 -10
  26. package/dist/summarizerNode/summarizerNode.d.ts.map +1 -1
  27. package/dist/summarizerNode/summarizerNode.js +117 -52
  28. package/dist/summarizerNode/summarizerNode.js.map +1 -1
  29. package/dist/summarizerNode/summarizerNodeUtils.d.ts +12 -14
  30. package/dist/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  31. package/dist/summarizerNode/summarizerNodeUtils.js.map +1 -1
  32. package/dist/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
  33. package/dist/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  34. package/dist/summarizerNode/summarizerNodeWithGc.js +45 -19
  35. package/dist/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  36. package/dist/summaryUtils.d.ts +2 -2
  37. package/dist/summaryUtils.d.ts.map +1 -1
  38. package/dist/summaryUtils.js +5 -4
  39. package/dist/summaryUtils.js.map +1 -1
  40. package/dist/utils.d.ts.map +1 -1
  41. package/dist/utils.js.map +1 -1
  42. package/lib/dataStoreHandleContextUtils.d.ts.map +1 -1
  43. package/lib/dataStoreHandleContextUtils.js +3 -1
  44. package/lib/dataStoreHandleContextUtils.js.map +1 -1
  45. package/lib/dataStoreHelpers.d.ts.map +1 -1
  46. package/lib/dataStoreHelpers.js +23 -7
  47. package/lib/dataStoreHelpers.js.map +1 -1
  48. package/lib/index.d.ts.map +1 -1
  49. package/lib/index.js +1 -0
  50. package/lib/index.js.map +1 -1
  51. package/lib/objectstoragepartition.d.ts.map +1 -1
  52. package/lib/objectstoragepartition.js.map +1 -1
  53. package/lib/objectstorageutils.d.ts.map +1 -1
  54. package/lib/objectstorageutils.js.map +1 -1
  55. package/lib/packageVersion.d.ts +1 -1
  56. package/lib/packageVersion.js +1 -1
  57. package/lib/packageVersion.js.map +1 -1
  58. package/lib/requestParser.d.ts.map +1 -1
  59. package/lib/requestParser.js.map +1 -1
  60. package/lib/runtimeFactoryHelper.d.ts.map +1 -1
  61. package/lib/runtimeFactoryHelper.js +6 -2
  62. package/lib/runtimeFactoryHelper.js.map +1 -1
  63. package/lib/summarizerNode/summarizerNode.d.ts +25 -10
  64. package/lib/summarizerNode/summarizerNode.d.ts.map +1 -1
  65. package/lib/summarizerNode/summarizerNode.js +117 -52
  66. package/lib/summarizerNode/summarizerNode.js.map +1 -1
  67. package/lib/summarizerNode/summarizerNodeUtils.d.ts +12 -14
  68. package/lib/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  69. package/lib/summarizerNode/summarizerNodeUtils.js.map +1 -1
  70. package/lib/summarizerNode/summarizerNodeWithGc.d.ts +8 -114
  71. package/lib/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  72. package/lib/summarizerNode/summarizerNodeWithGc.js +46 -19
  73. package/lib/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  74. package/lib/summaryUtils.d.ts +2 -2
  75. package/lib/summaryUtils.d.ts.map +1 -1
  76. package/lib/summaryUtils.js +5 -4
  77. package/lib/summaryUtils.js.map +1 -1
  78. package/lib/utils.d.ts.map +1 -1
  79. package/lib/utils.js.map +1 -1
  80. package/package.json +45 -48
  81. package/prettier.config.cjs +1 -1
  82. package/src/dataStoreHandleContextUtils.ts +23 -16
  83. package/src/dataStoreHelpers.ts +104 -86
  84. package/src/index.ts +3 -2
  85. package/src/objectstoragepartition.ts +13 -13
  86. package/src/objectstorageutils.ts +31 -28
  87. package/src/packageVersion.ts +1 -1
  88. package/src/requestParser.ts +80 -82
  89. package/src/runtimeFactoryHelper.ts +24 -17
  90. package/src/summarizerNode/summarizerNode.ts +702 -575
  91. package/src/summarizerNode/summarizerNodeUtils.ts +157 -159
  92. package/src/summarizerNode/summarizerNodeWithGc.ts +532 -473
  93. package/src/summaryUtils.ts +313 -305
  94. package/src/utils.ts +6 -6
  95. package/tsconfig.esnext.json +6 -6
  96. package/tsconfig.json +8 -12
@@ -8,94 +8,92 @@ import { IRequest, IRequestHeader } from "@fluidframework/core-interfaces";
8
8
  * The Request Parser takes an IRequest provides parsing and sub request creation
9
9
  */
10
10
  export class RequestParser implements IRequest {
11
- /**
12
- * Splits the path of the url and decodes each path part
13
- * @param url - the url to get path parts of
14
- */
15
- public static getPathParts(url: string): readonly string[] {
16
- const queryStartIndex = url.indexOf("?");
17
- return url
18
- .substring(0, queryStartIndex < 0 ? url.length : queryStartIndex)
19
- .split("/")
20
- .reduce<string[]>(
21
- (pv, cv) => {
22
- if (cv !== undefined && cv.length > 0) {
23
- pv.push(decodeURIComponent(cv));
24
- }
25
- return pv;
26
- },
27
- []);
28
- }
11
+ /**
12
+ * Splits the path of the url and decodes each path part
13
+ * @param url - the url to get path parts of
14
+ */
15
+ public static getPathParts(url: string): readonly string[] {
16
+ const queryStartIndex = url.indexOf("?");
17
+ return url
18
+ .substring(0, queryStartIndex < 0 ? url.length : queryStartIndex)
19
+ .split("/")
20
+ .reduce<string[]>((pv, cv) => {
21
+ if (cv !== undefined && cv.length > 0) {
22
+ pv.push(decodeURIComponent(cv));
23
+ }
24
+ return pv;
25
+ }, []);
26
+ }
29
27
 
30
- private requestPathParts: readonly string[] | undefined;
31
- public readonly query: string;
28
+ private requestPathParts: readonly string[] | undefined;
29
+ public readonly query: string;
32
30
 
33
- public static create(request: Readonly<IRequest>) {
34
- // Perf optimizations.
35
- if (request instanceof RequestParser) {
36
- return request;
37
- }
38
- return new RequestParser(request);
39
- }
31
+ public static create(request: Readonly<IRequest>) {
32
+ // Perf optimizations.
33
+ if (request instanceof RequestParser) {
34
+ return request;
35
+ }
36
+ return new RequestParser(request);
37
+ }
40
38
 
41
- protected constructor(private readonly request: Readonly<IRequest>) {
42
- const queryStartIndex = this.request.url.indexOf("?");
43
- this.query = queryStartIndex >= 0 ? this.request.url.substring(queryStartIndex) : "";
44
- }
39
+ protected constructor(private readonly request: Readonly<IRequest>) {
40
+ const queryStartIndex = this.request.url.indexOf("?");
41
+ this.query = queryStartIndex >= 0 ? this.request.url.substring(queryStartIndex) : "";
42
+ }
45
43
 
46
- public get url(): string {
47
- return this.request.url;
48
- }
44
+ public get url(): string {
45
+ return this.request.url;
46
+ }
49
47
 
50
- public get headers(): IRequestHeader | undefined {
51
- return this.request.headers;
52
- }
48
+ public get headers(): IRequestHeader | undefined {
49
+ return this.request.headers;
50
+ }
53
51
 
54
- /**
55
- * Returns the decoded path parts of the request's url
56
- */
57
- public get pathParts(): readonly string[] {
58
- if (this.requestPathParts === undefined) {
59
- this.requestPathParts = RequestParser.getPathParts(this.url);
60
- }
61
- return this.requestPathParts;
62
- }
52
+ /**
53
+ * Returns the decoded path parts of the request's url
54
+ */
55
+ public get pathParts(): readonly string[] {
56
+ if (this.requestPathParts === undefined) {
57
+ this.requestPathParts = RequestParser.getPathParts(this.url);
58
+ }
59
+ return this.requestPathParts;
60
+ }
63
61
 
64
- /**
65
- * Returns true if it's a terminating path, i.e. no more elements after `elements` entries and empty query.
66
- * @param elements - number of elements in path
67
- */
68
- public isLeaf(elements: number) {
69
- return this.query === "" && this.pathParts.length === elements;
70
- }
62
+ /**
63
+ * Returns true if it's a terminating path, i.e. no more elements after `elements` entries and empty query.
64
+ * @param elements - number of elements in path
65
+ */
66
+ public isLeaf(elements: number) {
67
+ return this.query === "" && this.pathParts.length === elements;
68
+ }
71
69
 
72
- /**
73
- * Creates a sub request starting at a specific path part of this request's url
74
- * The sub request url always has a leading slash, and always include query params if original url has any
75
- * e.g. original url is /a/b/?queryParams, createSubRequest(0) is /a/b/?queryParams
76
- * createSubRequest(1) is /b/?queryParams
77
- * createSubRequest(2) is /?queryParams
78
- * createSubRequest(n) where n is bigger than parts length, e.g. 2, or n is less than 0 will throw an exception
79
- *
80
- * note: query params are not counted towards path parts.
81
- *
82
- * @param startingPathIndex - The index of the first path part of the sub request
83
- */
84
- public createSubRequest(startingPathIndex: number): IRequest {
85
- const pathLen = this.pathParts.length;
86
- if (startingPathIndex < 0 || startingPathIndex > pathLen) {
87
- throw new Error("incorrect sub-request");
88
- }
89
- if (startingPathIndex === pathLen && this.url.includes("?")) {
90
- return {
91
- url: `/${this.query}`,
92
- headers: this.headers,
93
- };
94
- }
95
- const path = `/${this.pathParts.slice(startingPathIndex).join("/")}`;
96
- return {
97
- url: this.query === "" ? path : `${path}/${this.query}`,
98
- headers: this.headers,
99
- };
100
- }
70
+ /**
71
+ * Creates a sub request starting at a specific path part of this request's url
72
+ * The sub request url always has a leading slash, and always include query params if original url has any
73
+ * e.g. original url is /a/b/?queryParams, createSubRequest(0) is /a/b/?queryParams
74
+ * createSubRequest(1) is /b/?queryParams
75
+ * createSubRequest(2) is /?queryParams
76
+ * createSubRequest(n) where n is bigger than parts length, e.g. 2, or n is less than 0 will throw an exception
77
+ *
78
+ * note: query params are not counted towards path parts.
79
+ *
80
+ * @param startingPathIndex - The index of the first path part of the sub request
81
+ */
82
+ public createSubRequest(startingPathIndex: number): IRequest {
83
+ const pathLen = this.pathParts.length;
84
+ if (startingPathIndex < 0 || startingPathIndex > pathLen) {
85
+ throw new Error("incorrect sub-request");
86
+ }
87
+ if (startingPathIndex === pathLen && this.url.includes("?")) {
88
+ return {
89
+ url: `/${this.query}`,
90
+ headers: this.headers,
91
+ };
92
+ }
93
+ const path = `/${this.pathParts.slice(startingPathIndex).join("/")}`;
94
+ return {
95
+ url: this.query === "" ? path : `${path}/${this.query}`,
96
+ headers: this.headers,
97
+ };
98
+ }
101
99
  }
@@ -4,27 +4,34 @@
4
4
  */
5
5
 
6
6
  import {
7
- IContainerContext,
8
- IRuntime,
9
- IRuntimeFactory,
7
+ IContainerContext,
8
+ IRuntime,
9
+ IRuntimeFactory,
10
10
  } from "@fluidframework/container-definitions";
11
11
  import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
12
12
 
13
13
  export abstract class RuntimeFactoryHelper<T = IContainerRuntime> implements IRuntimeFactory {
14
- public get IRuntimeFactory() { return this; }
14
+ public get IRuntimeFactory() {
15
+ return this;
16
+ }
15
17
 
16
- public async instantiateRuntime(
17
- context: IContainerContext,
18
- existing: boolean,
19
- ): Promise<IRuntime> {
20
- const runtime = await this.preInitialize(context, existing);
21
- await (existing ? this.instantiateFromExisting(runtime) : this.instantiateFirstTime(runtime));
22
- await this.hasInitialized(runtime);
23
- return runtime;
24
- }
18
+ public async instantiateRuntime(
19
+ context: IContainerContext,
20
+ existing: boolean,
21
+ ): Promise<IRuntime> {
22
+ const runtime = await this.preInitialize(context, existing);
23
+ await (existing
24
+ ? this.instantiateFromExisting(runtime)
25
+ : this.instantiateFirstTime(runtime));
26
+ await this.hasInitialized(runtime);
27
+ return runtime;
28
+ }
25
29
 
26
- public abstract preInitialize(context: IContainerContext, existing: boolean): Promise<IRuntime & T>;
27
- public async instantiateFirstTime(_runtime: T): Promise<void> {}
28
- public async instantiateFromExisting(_runtime: T): Promise<void> {}
29
- public async hasInitialized(_runtime: T): Promise<void> {}
30
+ public abstract preInitialize(
31
+ context: IContainerContext,
32
+ existing: boolean,
33
+ ): Promise<IRuntime & T>;
34
+ public async instantiateFirstTime(_runtime: T): Promise<void> {}
35
+ public async instantiateFromExisting(_runtime: T): Promise<void> {}
36
+ public async hasInitialized(_runtime: T): Promise<void> {}
30
37
  }