@fluidframework/runtime-utils 2.0.0-rc.1.0.6 → 2.0.0-rc.2.0.1

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 (117) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +4 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +30 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor-lint.json +1 -1
  6. package/api-extractor.json +1 -1
  7. package/api-report/runtime-utils.api.md +7 -11
  8. package/dist/index.d.ts +10 -10
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +40 -40
  11. package/dist/index.js.map +1 -1
  12. package/dist/package.json +3 -0
  13. package/dist/runtime-utils-alpha.d.ts +3 -3
  14. package/dist/runtime-utils-beta.d.ts +3 -3
  15. package/dist/runtime-utils-public.d.ts +3 -3
  16. package/dist/runtime-utils-untrimmed.d.ts +19 -9
  17. package/dist/summaryUtils.d.ts +4 -8
  18. package/dist/summaryUtils.d.ts.map +1 -1
  19. package/dist/summaryUtils.js +5 -10
  20. package/dist/summaryUtils.js.map +1 -1
  21. package/dist/tsdoc-metadata.json +1 -1
  22. package/dist/utils.d.ts +14 -0
  23. package/dist/utils.d.ts.map +1 -1
  24. package/dist/utils.js +49 -1
  25. package/dist/utils.js.map +1 -1
  26. package/lib/{dataStoreHandleContextUtils.d.mts → dataStoreHandleContextUtils.d.ts} +1 -1
  27. package/lib/dataStoreHandleContextUtils.d.ts.map +1 -0
  28. package/lib/{dataStoreHandleContextUtils.mjs → dataStoreHandleContextUtils.js} +1 -1
  29. package/lib/dataStoreHandleContextUtils.js.map +1 -0
  30. package/lib/{dataStoreHelpers.d.mts → dataStoreHelpers.d.ts} +1 -1
  31. package/lib/dataStoreHelpers.d.ts.map +1 -0
  32. package/lib/{dataStoreHelpers.mjs → dataStoreHelpers.js} +1 -1
  33. package/lib/dataStoreHelpers.js.map +1 -0
  34. package/lib/{handles.d.mts → handles.d.ts} +1 -1
  35. package/lib/handles.d.ts.map +1 -0
  36. package/lib/{handles.mjs → handles.js} +1 -1
  37. package/lib/handles.js.map +1 -0
  38. package/lib/index.d.ts +15 -0
  39. package/lib/index.d.ts.map +1 -0
  40. package/lib/index.js +15 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/{objectstoragepartition.d.mts → objectstoragepartition.d.ts} +1 -1
  43. package/lib/objectstoragepartition.d.ts.map +1 -0
  44. package/lib/{objectstoragepartition.mjs → objectstoragepartition.js} +1 -1
  45. package/lib/objectstoragepartition.js.map +1 -0
  46. package/lib/{objectstorageutils.d.mts → objectstorageutils.d.ts} +1 -1
  47. package/lib/objectstorageutils.d.ts.map +1 -0
  48. package/lib/{objectstorageutils.mjs → objectstorageutils.js} +1 -1
  49. package/lib/objectstorageutils.js.map +1 -0
  50. package/lib/{requestParser.d.mts → requestParser.d.ts} +5 -1
  51. package/lib/requestParser.d.ts.map +1 -0
  52. package/lib/{requestParser.mjs → requestParser.js} +1 -1
  53. package/lib/requestParser.js.map +1 -0
  54. package/lib/{runtime-utils-alpha.d.mts → runtime-utils-alpha.d.ts} +3 -3
  55. package/lib/{runtime-utils-beta.d.mts → runtime-utils-beta.d.ts} +3 -3
  56. package/lib/{runtime-utils-public.d.mts → runtime-utils-public.d.ts} +3 -3
  57. package/lib/{runtime-utils-untrimmed.d.mts → runtime-utils-untrimmed.d.ts} +19 -9
  58. package/lib/{runtimeFactoryHelper.d.mts → runtimeFactoryHelper.d.ts} +1 -1
  59. package/lib/runtimeFactoryHelper.d.ts.map +1 -0
  60. package/lib/{runtimeFactoryHelper.mjs → runtimeFactoryHelper.js} +1 -1
  61. package/lib/runtimeFactoryHelper.js.map +1 -0
  62. package/lib/{summaryUtils.d.mts → summaryUtils.d.ts} +5 -9
  63. package/lib/summaryUtils.d.ts.map +1 -0
  64. package/lib/{summaryUtils.mjs → summaryUtils.js} +5 -9
  65. package/lib/summaryUtils.js.map +1 -0
  66. package/lib/test/dataStoreHelpers.spec.js +29 -0
  67. package/lib/test/dataStoreHelpers.spec.js.map +1 -0
  68. package/lib/test/requestParser.spec.js +111 -0
  69. package/lib/test/requestParser.spec.js.map +1 -0
  70. package/lib/test/runtimeFactoryHelper.spec.js +44 -0
  71. package/lib/test/runtimeFactoryHelper.spec.js.map +1 -0
  72. package/lib/test/summaryUtils.spec.js +283 -0
  73. package/lib/test/summaryUtils.spec.js.map +1 -0
  74. package/lib/test/types/validateRuntimeUtilsPrevious.generated.js +58 -0
  75. package/lib/test/types/validateRuntimeUtilsPrevious.generated.js.map +1 -0
  76. package/lib/test/utils.spec.js +65 -0
  77. package/lib/test/utils.spec.js.map +1 -0
  78. package/lib/{unpackUsedRoutes.d.mts → unpackUsedRoutes.d.ts} +1 -1
  79. package/lib/unpackUsedRoutes.d.ts.map +1 -0
  80. package/lib/{unpackUsedRoutes.mjs → unpackUsedRoutes.js} +1 -1
  81. package/lib/unpackUsedRoutes.js.map +1 -0
  82. package/lib/utils.d.ts +34 -0
  83. package/lib/utils.d.ts.map +1 -0
  84. package/lib/utils.js +64 -0
  85. package/lib/utils.js.map +1 -0
  86. package/package.json +48 -49
  87. package/src/index.ts +10 -11
  88. package/src/summaryUtils.ts +9 -18
  89. package/src/utils.ts +48 -0
  90. package/tsconfig.cjs.json +7 -0
  91. package/tsconfig.json +2 -5
  92. package/lib/dataStoreHandleContextUtils.d.mts.map +0 -1
  93. package/lib/dataStoreHandleContextUtils.mjs.map +0 -1
  94. package/lib/dataStoreHelpers.d.mts.map +0 -1
  95. package/lib/dataStoreHelpers.mjs.map +0 -1
  96. package/lib/handles.d.mts.map +0 -1
  97. package/lib/handles.mjs.map +0 -1
  98. package/lib/index.d.mts +0 -15
  99. package/lib/index.d.mts.map +0 -1
  100. package/lib/index.mjs +0 -15
  101. package/lib/index.mjs.map +0 -1
  102. package/lib/objectstoragepartition.d.mts.map +0 -1
  103. package/lib/objectstoragepartition.mjs.map +0 -1
  104. package/lib/objectstorageutils.d.mts.map +0 -1
  105. package/lib/objectstorageutils.mjs.map +0 -1
  106. package/lib/requestParser.d.mts.map +0 -1
  107. package/lib/requestParser.mjs.map +0 -1
  108. package/lib/runtimeFactoryHelper.d.mts.map +0 -1
  109. package/lib/runtimeFactoryHelper.mjs.map +0 -1
  110. package/lib/summaryUtils.d.mts.map +0 -1
  111. package/lib/summaryUtils.mjs.map +0 -1
  112. package/lib/unpackUsedRoutes.d.mts.map +0 -1
  113. package/lib/unpackUsedRoutes.mjs.map +0 -1
  114. package/lib/utils.d.mts +0 -20
  115. package/lib/utils.d.mts.map +0 -1
  116. package/lib/utils.mjs +0 -17
  117. package/lib/utils.mjs.map +0 -1
@@ -22,7 +22,7 @@ import { ITelemetryContext } from '@fluidframework/runtime-definitions';
22
22
  import { ITree } from '@fluidframework/protocol-definitions';
23
23
  import { SummaryObject } from '@fluidframework/protocol-definitions';
24
24
  import { SummaryType } from '@fluidframework/protocol-definitions';
25
- import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
25
+ import type { TelemetryBaseEventPropertyType } from '@fluidframework/core-interfaces';
26
26
 
27
27
  /**
28
28
  * @internal
@@ -34,11 +34,6 @@ export declare function addBlobToSummary(summary: ISummaryTreeWithStats, key: st
34
34
  */
35
35
  export declare function addSummarizeResultToSummary(summary: ISummaryTreeWithStats, key: string, summarizeResult: ISummarizeResult): void;
36
36
 
37
- /**
38
- * @internal
39
- */
40
- export declare function addTreeToSummary(summary: ISummaryTreeWithStats, key: string, summarizeResult: ISummarizeResult): void;
41
-
42
37
  /**
43
38
  * @internal
44
39
  */
@@ -92,6 +87,21 @@ export declare function createResponseError(status: number, value: string, reque
92
87
  [key: string]: any;
93
88
  }): IResponse;
94
89
 
90
+ /**
91
+ * Encode compact ID (returned by IContainerRuntime.generateDocumentUniqueId()) to a compact string representation.
92
+ * While this is the main usage pattern, it works with any non-negative integer or a string.
93
+ * Strings are retured as is, and assumed to be UUIDs, i.e. unique enough to never overlap with
94
+ * numbers encoded as strings by this function. Any other strings are likely to run into collisions and should not be used!
95
+ * This function is useful in places where we serialize resulting ID as string and use them as strings, thus we are not
96
+ * gaining any efficiency from having a number type.
97
+ * 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.
98
+ * @param idArg - input - either a non-negative integer or a string. Strings are returned as is, while numbers are encoded in compat form
99
+ * @param prefix - optinal string prefix
100
+ * @returns A string - representation of an input
101
+ * @internal
102
+ */
103
+ export declare function encodeCompactIdToString(idArg: number | string, prefix?: string): string;
104
+
95
105
  /**
96
106
  * @internal
97
107
  */
@@ -305,15 +315,15 @@ export declare class TelemetryContext implements ITelemetryContext {
305
315
  /**
306
316
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}
307
317
  */
308
- set(prefix: string, property: string, value: TelemetryEventPropertyType): void;
318
+ set(prefix: string, property: string, value: TelemetryBaseEventPropertyType): void;
309
319
  /**
310
320
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}
311
321
  */
312
- setMultiple(prefix: string, property: string, values: Record<string, TelemetryEventPropertyType>): void;
322
+ setMultiple(prefix: string, property: string, values: Record<string, TelemetryBaseEventPropertyType>): void;
313
323
  /**
314
324
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
315
325
  */
316
- get(prefix: string, property: string): TelemetryEventPropertyType;
326
+ get(prefix: string, property: string): TelemetryBaseEventPropertyType;
317
327
  /**
318
328
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}
319
329
  */
@@ -15,4 +15,4 @@ export declare abstract class RuntimeFactoryHelper<T = IContainerRuntime> implem
15
15
  instantiateFromExisting(_runtime: T): Promise<void>;
16
16
  hasInitialized(_runtime: T): Promise<void>;
17
17
  }
18
- //# sourceMappingURL=runtimeFactoryHelper.d.mts.map
18
+ //# sourceMappingURL=runtimeFactoryHelper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeFactoryHelper.d.ts","sourceRoot":"","sources":["../src/runtimeFactoryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF;;GAEG;AACH,8BAAsB,oBAAoB,CAAC,CAAC,GAAG,iBAAiB,CAAE,YAAW,eAAe;IAC3F,IAAW,eAAe,SAEzB;IAEY,kBAAkB,CAC9B,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC;aASJ,aAAa,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACX,oBAAoB,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAChD,uBAAuB,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IACnD,cAAc,CAAC,QAAQ,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CACvD"}
@@ -21,4 +21,4 @@ export class RuntimeFactoryHelper {
21
21
  async instantiateFromExisting(_runtime) { }
22
22
  async hasInitialized(_runtime) { }
23
23
  }
24
- //# sourceMappingURL=runtimeFactoryHelper.mjs.map
24
+ //# sourceMappingURL=runtimeFactoryHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeFactoryHelper.js","sourceRoot":"","sources":["../src/runtimeFactoryHelper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;GAEG;AACH,MAAM,OAAgB,oBAAoB;IACzC,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAC9B,OAA0B,EAC1B,QAAiB;QAEjB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC5D,MAAM,CAAC,QAAQ;YACd,CAAC,CAAC,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC;YACvC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;QACvC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACnC,OAAO,OAAO,CAAC;IAChB,CAAC;IAMM,KAAK,CAAC,oBAAoB,CAAC,QAAW,IAAkB,CAAC;IACzD,KAAK,CAAC,uBAAuB,CAAC,QAAW,IAAkB,CAAC;IAC5D,KAAK,CAAC,cAAc,CAAC,QAAW,IAAkB,CAAC;CAC1D","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIContainerContext,\n\tIRuntime,\n\tIRuntimeFactory,\n} from \"@fluidframework/container-definitions\";\nimport { IContainerRuntime } from \"@fluidframework/container-runtime-definitions\";\n\n/**\n * @alpha\n */\nexport abstract class RuntimeFactoryHelper<T = IContainerRuntime> implements IRuntimeFactory {\n\tpublic get IRuntimeFactory() {\n\t\treturn this;\n\t}\n\n\tpublic async instantiateRuntime(\n\t\tcontext: IContainerContext,\n\t\texisting: boolean,\n\t): Promise<IRuntime> {\n\t\tconst runtime = await this.preInitialize(context, existing);\n\t\tawait (existing\n\t\t\t? this.instantiateFromExisting(runtime)\n\t\t\t: this.instantiateFirstTime(runtime));\n\t\tawait this.hasInitialized(runtime);\n\t\treturn runtime;\n\t}\n\n\tpublic abstract preInitialize(\n\t\tcontext: IContainerContext,\n\t\texisting: boolean,\n\t): Promise<IRuntime & T>;\n\tpublic async instantiateFirstTime(_runtime: T): Promise<void> {}\n\tpublic async instantiateFromExisting(_runtime: T): Promise<void> {}\n\tpublic async hasInitialized(_runtime: T): Promise<void> {}\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { TelemetryEventPropertyType } from "@fluidframework/core-interfaces";
5
+ import type { TelemetryBaseEventPropertyType } from "@fluidframework/core-interfaces";
6
6
  import { ITree, SummaryType, ISummaryTree, SummaryObject, ISummaryBlob } from "@fluidframework/protocol-definitions";
7
7
  import { ISummaryStats, ISummarizeResult, ISummaryTreeWithStats, ITelemetryContext, IGarbageCollectionData } from "@fluidframework/runtime-definitions";
8
8
  import { ISnapshotTreeWithBlobContents } from "@fluidframework/container-definitions";
@@ -29,10 +29,6 @@ export declare function calculateStats(summary: SummaryObject): ISummaryStats;
29
29
  * @internal
30
30
  */
31
31
  export declare function addBlobToSummary(summary: ISummaryTreeWithStats, key: string, content: string | Uint8Array): void;
32
- /**
33
- * @internal
34
- */
35
- export declare function addTreeToSummary(summary: ISummaryTreeWithStats, key: string, summarizeResult: ISummarizeResult): void;
36
32
  /**
37
33
  * @internal
38
34
  */
@@ -102,15 +98,15 @@ export declare class TelemetryContext implements ITelemetryContext {
102
98
  /**
103
99
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}
104
100
  */
105
- set(prefix: string, property: string, value: TelemetryEventPropertyType): void;
101
+ set(prefix: string, property: string, value: TelemetryBaseEventPropertyType): void;
106
102
  /**
107
103
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}
108
104
  */
109
- setMultiple(prefix: string, property: string, values: Record<string, TelemetryEventPropertyType>): void;
105
+ setMultiple(prefix: string, property: string, values: Record<string, TelemetryBaseEventPropertyType>): void;
110
106
  /**
111
107
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
112
108
  */
113
- get(prefix: string, property: string): TelemetryEventPropertyType;
109
+ get(prefix: string, property: string): TelemetryBaseEventPropertyType;
114
110
  /**
115
111
  * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}
116
112
  */
@@ -144,4 +140,4 @@ export declare class GCDataBuilder implements IGarbageCollectionData {
144
140
  addRouteToAllNodes(outboundRoute: string): void;
145
141
  getGCData(): IGarbageCollectionData;
146
142
  }
147
- //# sourceMappingURL=summaryUtils.d.mts.map
143
+ //# sourceMappingURL=summaryUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summaryUtils.d.ts","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AAStF,OAAO,EACN,KAAK,EACL,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EAGZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACN,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAEtF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,GAAG,KAAK,EAAE,aAAa,EAAE,GAAG,aAAa,CAgBnE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAelD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,MAAM,CAEpE;AAyBD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAIpE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,qBAAqB,EAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GAAG,UAAU,GAC1B,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,qBAAqB,EAC9B,GAAG,EAAE,MAAM,EACX,eAAe,EAAE,gBAAgB,GAC/B,IAAI,CAGN;AAED;;GAEG;AACH,qBAAa,kBAAmB,YAAW,qBAAqB;IAC/D,OAAO,CAAC,iBAAiB,CAAa;IAEtC,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,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B,GAAG,IAAI;IAIlF;;OAEG;IACH,WAAW,CACV,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,8BAA8B,CAAC,GACpD,IAAI;IAOP;;OAEG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,8BAA8B;IAIrE;;OAEG;IACH,SAAS,IAAI,MAAM;CAOnB;AAoBD;;;GAGG;AACH,qBAAa,aAAc,YAAW,sBAAsB;IAC3D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqC;IAChE,IAAW,OAAO,IAAI;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAM/C;IAEM,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE;IAInD;;;;;OAKG;IACI,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE;IAevE,QAAQ,CAAC,OAAO,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE;IAMnD;;OAEG;IACI,kBAAkB,CAAC,aAAa,EAAE,MAAM;IAMxC,SAAS,IAAI,sBAAsB;CAK1C"}
@@ -97,13 +97,6 @@ export function addBlobToSummary(summary, key, content) {
97
97
  summary.stats.blobNodeCount++;
98
98
  summary.stats.totalBlobSize += getBlobSize(content);
99
99
  }
100
- /**
101
- * @internal
102
- */
103
- export function addTreeToSummary(summary, key, summarizeResult) {
104
- summary.summary.tree[key] = summarizeResult.summary;
105
- summary.stats = mergeStats(summary.stats, summarizeResult.stats);
106
- }
107
100
  /**
108
101
  * @internal
109
102
  */
@@ -193,6 +186,7 @@ export function convertToSummaryTreeWithStats(snapshot, fullTree = false) {
193
186
  }
194
187
  const summaryTree = builder.getSummaryTree();
195
188
  summaryTree.summary.unreferenced = snapshot.unreferenced;
189
+ summaryTree.summary.groupId = snapshot.groupId;
196
190
  return summaryTree;
197
191
  }
198
192
  /**
@@ -250,6 +244,7 @@ export function convertSnapshotTreeToSummaryTree(snapshot) {
250
244
  }
251
245
  const summaryTree = builder.getSummaryTree();
252
246
  summaryTree.summary.unreferenced = snapshot.unreferenced;
247
+ summaryTree.summary.groupId = snapshot.groupId;
253
248
  return summaryTree;
254
249
  }
255
250
  /**
@@ -292,6 +287,7 @@ export function convertSummaryTreeToITree(summaryTree) {
292
287
  return {
293
288
  entries,
294
289
  unreferenced: summaryTree.unreferenced,
290
+ groupId: summaryTree.groupId,
295
291
  };
296
292
  }
297
293
  /**
@@ -314,7 +310,7 @@ export function processAttachMessageGCData(snapshot, addedGCOutboundRoute) {
314
310
  if (gcDataEntry === undefined) {
315
311
  return false;
316
312
  }
317
- assert(gcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === "utf-8", "GC data should be a utf-8-encoded blob");
313
+ assert(gcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === "utf-8", 0x8ff /* GC data should be a utf-8-encoded blob */);
318
314
  const gcData = JSON.parse(gcDataEntry.value.contents);
319
315
  for (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {
320
316
  outboundRoutes.forEach((toPath) => {
@@ -434,4 +430,4 @@ export class GCDataBuilder {
434
430
  };
435
431
  }
436
432
  }
437
- //# sourceMappingURL=summaryUtils.mjs.map
433
+ //# sourceMappingURL=summaryUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summaryUtils.js","sourceRoot":"","sources":["../src/summaryUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,kBAAkB,GAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EA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\nimport type { TelemetryBaseEventPropertyType } from \"@fluidframework/core-interfaces\";\nimport {\n\tbufferToString,\n\tfromBase64ToUtf8,\n\tIsoBuffer,\n\tUint8ArrayToString,\n} from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/driver-utils\";\nimport {\n\tITree,\n\tSummaryType,\n\tISummaryTree,\n\tSummaryObject,\n\tISummaryBlob,\n\tTreeEntry,\n\tITreeEntry,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tISummaryStats,\n\tISummarizeResult,\n\tISummaryTreeWithStats,\n\tITelemetryContext,\n\tIGarbageCollectionData,\n} from \"@fluidframework/runtime-definitions\";\nimport { ISnapshotTreeWithBlobContents } from \"@fluidframework/container-definitions\";\n\n/**\n * Combines summary stats by adding their totals together.\n * Returns empty stats if called without args.\n * @param stats - stats to merge\n * @internal\n */\nexport function mergeStats(...stats: ISummaryStats[]): ISummaryStats {\n\tconst results = {\n\t\ttreeNodeCount: 0,\n\t\tblobNodeCount: 0,\n\t\thandleNodeCount: 0,\n\t\ttotalBlobSize: 0,\n\t\tunreferencedBlobSize: 0,\n\t};\n\tfor (const stat of stats) {\n\t\tresults.treeNodeCount += stat.treeNodeCount;\n\t\tresults.blobNodeCount += stat.blobNodeCount;\n\t\tresults.handleNodeCount += stat.handleNodeCount;\n\t\tresults.totalBlobSize += stat.totalBlobSize;\n\t\tresults.unreferencedBlobSize += stat.unreferencedBlobSize;\n\t}\n\treturn results;\n}\n\n/**\n * @internal\n */\nexport function utf8ByteLength(str: string): number {\n\t// returns the byte length of an utf8 string\n\tlet s = str.length;\n\tfor (let i = str.length - 1; i >= 0; i--) {\n\t\tconst code = str.charCodeAt(i);\n\t\tif (code > 0x7f && code <= 0x7ff) {\n\t\t\ts++;\n\t\t} else if (code > 0x7ff && code <= 0xffff) {\n\t\t\ts += 2;\n\t\t}\n\t\tif (code >= 0xdc00 && code <= 0xdfff) {\n\t\t\ti--; // trail surrogate\n\t\t}\n\t}\n\treturn s;\n}\n\n/**\n * @internal\n */\nexport function getBlobSize(content: ISummaryBlob[\"content\"]): number {\n\treturn typeof content === \"string\" ? utf8ByteLength(content) : content.byteLength;\n}\n\nfunction calculateStatsCore(summaryObject: SummaryObject, stats: ISummaryStats): void {\n\tswitch (summaryObject.type) {\n\t\tcase SummaryType.Tree: {\n\t\t\tstats.treeNodeCount++;\n\t\t\tfor (const value of Object.values(summaryObject.tree)) {\n\t\t\t\tcalculateStatsCore(value, stats);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Handle: {\n\t\t\tstats.handleNodeCount++;\n\t\t\treturn;\n\t\t}\n\t\tcase SummaryType.Blob: {\n\t\t\tstats.blobNodeCount++;\n\t\t\tstats.totalBlobSize += getBlobSize(summaryObject.content);\n\t\t\treturn;\n\t\t}\n\t\tdefault:\n\t\t\treturn;\n\t}\n}\n\n/**\n * @internal\n */\nexport function calculateStats(summary: SummaryObject): ISummaryStats {\n\tconst stats = mergeStats();\n\tcalculateStatsCore(summary, stats);\n\treturn stats;\n}\n\n/**\n * @internal\n */\nexport function addBlobToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tcontent: string | Uint8Array,\n): void {\n\tconst blob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent,\n\t};\n\tsummary.summary.tree[key] = blob;\n\tsummary.stats.blobNodeCount++;\n\tsummary.stats.totalBlobSize += getBlobSize(content);\n}\n\n/**\n * @internal\n */\nexport function addSummarizeResultToSummary(\n\tsummary: ISummaryTreeWithStats,\n\tkey: string,\n\tsummarizeResult: ISummarizeResult,\n): void {\n\tsummary.summary.tree[key] = summarizeResult.summary;\n\tsummary.stats = mergeStats(summary.stats, summarizeResult.stats);\n}\n\n/**\n * @alpha\n */\nexport class SummaryTreeBuilder implements ISummaryTreeWithStats {\n\tprivate attachmentCounter: number = 0;\n\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t};\n\t}\n\n\tpublic get stats(): Readonly<ISummaryStats> {\n\t\treturn { ...this.summaryStats };\n\t}\n\n\tconstructor() {\n\t\tthis.summaryStats = mergeStats();\n\t\tthis.summaryStats.treeNodeCount++;\n\t}\n\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\tprivate summaryStats: ISummaryStats;\n\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\t// Prevent cloning by directly referencing underlying private properties\n\t\taddBlobToSummary(\n\t\t\t{\n\t\t\t\tsummary: {\n\t\t\t\t\ttype: SummaryType.Tree,\n\t\t\t\t\ttree: this.summaryTree,\n\t\t\t\t},\n\t\t\t\tstats: this.summaryStats,\n\t\t\t},\n\t\t\tkey,\n\t\t\tcontent,\n\t\t);\n\t}\n\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t\tthis.summaryStats.handleNodeCount++;\n\t}\n\n\tpublic addWithStats(key: string, summarizeResult: ISummarizeResult): void {\n\t\tthis.summaryTree[key] = summarizeResult.summary;\n\t\tthis.summaryStats = mergeStats(this.summaryStats, summarizeResult.stats);\n\t}\n\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n\n\tpublic getSummaryTree(): ISummaryTreeWithStats {\n\t\treturn { summary: this.summary, stats: this.stats };\n\t}\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @alpha\n */\nexport function convertToSummaryTreeWithStats(\n\tsnapshot: ITree,\n\tfullTree: boolean = false,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const entry of snapshot.entries) {\n\t\tswitch (entry.type) {\n\t\t\tcase TreeEntry.Blob: {\n\t\t\t\tconst blob = entry.value;\n\t\t\t\tconst content =\n\t\t\t\t\tblob.encoding === \"base64\"\n\t\t\t\t\t\t? IsoBuffer.from(blob.contents, \"base64\")\n\t\t\t\t\t\t: blob.contents;\n\t\t\t\tbuilder.addBlob(entry.path, content);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Tree: {\n\t\t\t\tconst subtree = convertToSummaryTree(entry.value, fullTree);\n\t\t\t\tbuilder.addWithStats(entry.path, subtree);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase TreeEntry.Attachment: {\n\t\t\t\tconst id = entry.value.id;\n\t\t\t\tbuilder.addAttachment(id);\n\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tthrow new Error(\"Unexpected TreeEntry type\");\n\t\t}\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts snapshot ITree to ISummaryTree format and tracks stats.\n * @param snapshot - snapshot in ITree format\n * @param fullTree - true to never use handles, even if id is specified\n * @internal\n */\nexport function convertToSummaryTree(snapshot: ITree, fullTree: boolean = false): ISummarizeResult {\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tif (snapshot.id && !fullTree) {\n\t\tconst stats = mergeStats();\n\t\tstats.handleNodeCount++;\n\t\treturn {\n\t\t\tsummary: {\n\t\t\t\thandle: snapshot.id,\n\t\t\t\thandleType: SummaryType.Tree,\n\t\t\t\ttype: SummaryType.Handle,\n\t\t\t},\n\t\t\tstats,\n\t\t};\n\t} else {\n\t\treturn convertToSummaryTreeWithStats(snapshot, fullTree);\n\t}\n}\n\n/**\n * Converts ISnapshotTree to ISummaryTree format and tracks stats. This snapshot tree was\n * was taken by serialize api in detached container.\n * @param snapshot - snapshot in ISnapshotTree format\n * @internal\n */\nexport function convertSnapshotTreeToSummaryTree(\n\tsnapshot: ISnapshotTreeWithBlobContents,\n): ISummaryTreeWithStats {\n\tconst builder = new SummaryTreeBuilder();\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tlet decoded: string | undefined;\n\t\tif (snapshot.blobsContents !== undefined) {\n\t\t\tconst content: ArrayBufferLike = snapshot.blobsContents[id];\n\t\t\tif (content !== undefined) {\n\t\t\t\tdecoded = bufferToString(content, \"utf-8\");\n\t\t\t}\n\t\t\t// 0.44 back-compat We still put contents in same blob for back-compat so need to add blob\n\t\t\t// only for blobPath -> blobId mapping and not for blobId -> blob value contents.\n\t\t} else if (snapshot.blobs[id] !== undefined) {\n\t\t\tdecoded = fromBase64ToUtf8(snapshot.blobs[id]);\n\t\t}\n\t\tif (decoded !== undefined) {\n\t\t\tbuilder.addBlob(path, decoded);\n\t\t}\n\t}\n\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotTreeToSummaryTree(tree);\n\t\tbuilder.addWithStats(key, subtree);\n\t}\n\n\tconst summaryTree = builder.getSummaryTree();\n\tsummaryTree.summary.unreferenced = snapshot.unreferenced;\n\tsummaryTree.summary.groupId = snapshot.groupId;\n\treturn summaryTree;\n}\n\n/**\n * Converts ISummaryTree to ITree format. This is needed for back-compat while we get rid of snapshot.\n * @param summaryTree - summary tree in ISummaryTree format\n * @internal\n */\nexport function convertSummaryTreeToITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tfor (const [key, value] of Object.entries(summaryTree.tree)) {\n\t\tswitch (value.type) {\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tlet parsedContent: string;\n\t\t\t\tlet encoding: \"utf-8\" | \"base64\" = \"utf-8\";\n\t\t\t\tif (typeof value.content === \"string\") {\n\t\t\t\t\tparsedContent = value.content;\n\t\t\t\t} else {\n\t\t\t\t\tparsedContent = Uint8ArrayToString(value.content, \"base64\");\n\t\t\t\t\tencoding = \"base64\";\n\t\t\t\t}\n\t\t\t\tentries.push(new BlobTreeEntry(key, parsedContent, encoding));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tentries.push(new TreeTreeEntry(key, convertSummaryTreeToITree(value)));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tentries.push(new AttachmentTreeEntry(key, value.id));\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"Should not have Handle type in summary tree\");\n\t\t\t}\n\n\t\t\tdefault:\n\t\t\t\tunreachableCase(value, \"Unexpected summary tree type\");\n\t\t}\n\t}\n\treturn {\n\t\tentries,\n\t\tunreferenced: summaryTree.unreferenced,\n\t\tgroupId: summaryTree.groupId,\n\t};\n}\n\n/**\n * Looks in the given attach message snapshot for the .gcdata blob, which would\n * contain the initial GC Data for the node being attached.\n * If it finds it, it notifies GC of all the new outbound routes being added by the attach.\n *\n * @param snapshot - The snapshot from the attach message\n * @param addedGCOutboundRoute - Callback to notify GC of a new outbound route.\n * IMPORTANT: addedGCOutboundRoute's param nodeId is \"/\" for the attaching node itself, or \"/<id>\" for its children.\n *\n * @returns true if it found/processed GC Data, false otherwise\n *\n * @internal\n */\nexport function processAttachMessageGCData(\n\tsnapshot: ITree | null,\n\taddedGCOutboundRoute: (fromNodeId: string, toPath: string) => void,\n): boolean {\n\tconst gcDataEntry = snapshot?.entries.find((e) => e.path === \".gcdata\");\n\n\t// Old attach messages won't have GC Data\n\t// (And REALLY old DataStore Attach messages won't even have a snapshot!)\n\tif (gcDataEntry === undefined) {\n\t\treturn false;\n\t}\n\n\tassert(\n\t\tgcDataEntry.type === TreeEntry.Blob && gcDataEntry.value.encoding === \"utf-8\",\n\t\t0x8ff /* GC data should be a utf-8-encoded blob */,\n\t);\n\n\tconst gcData = JSON.parse(gcDataEntry.value.contents) as IGarbageCollectionData;\n\tfor (const [nodeId, outboundRoutes] of Object.entries(gcData.gcNodes)) {\n\t\toutboundRoutes.forEach((toPath) => {\n\t\t\taddedGCOutboundRoute(nodeId, toPath);\n\t\t});\n\t}\n\treturn true;\n}\n\n/**\n * @internal\n */\nexport class TelemetryContext implements ITelemetryContext {\n\tprivate readonly telemetry = new Map<string, TelemetryBaseEventPropertyType>();\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.set}\n\t */\n\tset(prefix: string, property: string, value: TelemetryBaseEventPropertyType): void {\n\t\tthis.telemetry.set(`${prefix}${property}`, value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.setMultiple}\n\t */\n\tsetMultiple(\n\t\tprefix: string,\n\t\tproperty: string,\n\t\tvalues: Record<string, TelemetryBaseEventPropertyType>,\n\t): void {\n\t\t// Set the values individually so that they are logged as a flat list along with other properties.\n\t\tfor (const key of Object.keys(values)) {\n\t\t\tthis.set(prefix, `${property}_${key}`, values[key]);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}\n\t */\n\tget(prefix: string, property: string): TelemetryBaseEventPropertyType {\n\t\treturn this.telemetry.get(`${prefix}${property}`);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}\n\t */\n\tserialize(): string {\n\t\tconst jsonObject = {};\n\t\tthis.telemetry.forEach((value, key) => {\n\t\t\tjsonObject[key] = value;\n\t\t});\n\t\treturn JSON.stringify(jsonObject);\n\t}\n}\n\n/**\n * Trims the leading slashes from the given string.\n * @param str - A string that may contain leading slashes.\n * @returns A new string without leading slashes.\n */\nfunction trimLeadingSlashes(str: string) {\n\treturn str.replace(/^\\/+/g, \"\");\n}\n\n/**\n * Trims the trailing slashes from the given string.\n * @param str - A string that may contain trailing slashes.\n * @returns A new string without trailing slashes.\n */\nfunction trimTrailingSlashes(str: string) {\n\treturn str.replace(/\\/+$/g, \"\");\n}\n\n/**\n * Helper class to build the garbage collection data of a node by combining the data from multiple nodes.\n * @internal\n */\nexport class GCDataBuilder implements IGarbageCollectionData {\n\tprivate readonly gcNodesSet: { [id: string]: Set<string> } = {};\n\tpublic get gcNodes(): { [id: string]: string[] } {\n\t\tconst gcNodes = {};\n\t\tfor (const [nodeId, outboundRoutes] of Object.entries(this.gcNodesSet)) {\n\t\t\tgcNodes[nodeId] = [...outboundRoutes];\n\t\t}\n\t\treturn gcNodes;\n\t}\n\n\tpublic addNode(id: string, outboundRoutes: string[]) {\n\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t}\n\n\t/**\n\t * Adds the given GC nodes. It does the following:\n\t * - Normalizes the ids of the given nodes.\n\t * - Prefixes the given `prefixId` to the given nodes' ids.\n\t * - Adds the outbound routes of the nodes against the normalized and prefixed id.\n\t */\n\tpublic prefixAndAddNodes(prefixId: string, gcNodes: { [id: string]: string[] }) {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\t// Remove any leading slashes from the id.\n\t\t\tlet normalizedId = trimLeadingSlashes(id);\n\t\t\t// Prefix the given id to the normalized id.\n\t\t\tnormalizedId = `/${prefixId}/${normalizedId}`;\n\t\t\t// Remove any trailing slashes from the normalized id. Note that the trailing slashes are removed after\n\t\t\t// adding the prefix for handling the special case where id is \"/\".\n\t\t\tnormalizedId = trimTrailingSlashes(normalizedId);\n\n\t\t\t// Add the outbound routes against the normalized and prefixed id without duplicates.\n\t\t\tthis.gcNodesSet[normalizedId] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\tpublic addNodes(gcNodes: { [id: string]: string[] }) {\n\t\tfor (const [id, outboundRoutes] of Object.entries(gcNodes)) {\n\t\t\tthis.gcNodesSet[id] = new Set(outboundRoutes);\n\t\t}\n\t}\n\n\t/**\n\t * Adds the given outbound route to the outbound routes of all GC nodes.\n\t */\n\tpublic addRouteToAllNodes(outboundRoute: string) {\n\t\tfor (const outboundRoutes of Object.values(this.gcNodesSet)) {\n\t\t\toutboundRoutes.add(outboundRoute);\n\t\t}\n\t}\n\n\tpublic getGCData(): IGarbageCollectionData {\n\t\treturn {\n\t\t\tgcNodes: this.gcNodes,\n\t\t};\n\t}\n}\n"]}
@@ -0,0 +1,29 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataStoreHelpers.spec.js","sourceRoot":"","sources":["../../src/test/dataStoreHelpers.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,EACN,mBAAm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C,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"]}
@@ -0,0 +1,111 @@
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
@@ -0,0 +1 @@
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,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;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C,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"]}
@@ -0,0 +1,44 @@
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
@@ -0,0 +1 @@
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;IA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,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"]}