@fluidframework/driver-utils 2.0.0-dev.3.1.0.125672 → 2.0.0-dev.4.2.0.153917

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 (139) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +68 -1
  3. package/dist/fluidResolvedUrl.d.ts +8 -0
  4. package/dist/fluidResolvedUrl.d.ts.map +1 -1
  5. package/dist/fluidResolvedUrl.js +8 -0
  6. package/dist/fluidResolvedUrl.js.map +1 -1
  7. package/dist/index.d.ts +4 -11
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -21
  10. package/dist/index.js.map +1 -1
  11. package/dist/messageRecognition.d.ts +0 -20
  12. package/dist/messageRecognition.d.ts.map +1 -1
  13. package/dist/messageRecognition.js +1 -37
  14. package/dist/messageRecognition.js.map +1 -1
  15. package/dist/network.d.ts +0 -15
  16. package/dist/network.d.ts.map +1 -1
  17. package/dist/network.js.map +1 -1
  18. package/dist/networkUtils.d.ts +0 -10
  19. package/dist/networkUtils.d.ts.map +1 -1
  20. package/dist/networkUtils.js +1 -32
  21. package/dist/networkUtils.js.map +1 -1
  22. package/dist/packageVersion.d.ts +1 -1
  23. package/dist/packageVersion.js +1 -1
  24. package/dist/packageVersion.js.map +1 -1
  25. package/dist/parallelRequests.d.ts.map +1 -1
  26. package/dist/parallelRequests.js +45 -14
  27. package/dist/parallelRequests.js.map +1 -1
  28. package/dist/summaryForCreateNew.d.ts +21 -1
  29. package/dist/summaryForCreateNew.d.ts.map +1 -1
  30. package/dist/summaryForCreateNew.js +27 -5
  31. package/dist/summaryForCreateNew.js.map +1 -1
  32. package/dist/treeConversions.d.ts.map +1 -1
  33. package/dist/treeConversions.js +8 -9
  34. package/dist/treeConversions.js.map +1 -1
  35. package/lib/fluidResolvedUrl.d.ts +8 -0
  36. package/lib/fluidResolvedUrl.d.ts.map +1 -1
  37. package/lib/fluidResolvedUrl.js +8 -0
  38. package/lib/fluidResolvedUrl.js.map +1 -1
  39. package/lib/index.d.ts +4 -11
  40. package/lib/index.d.ts.map +1 -1
  41. package/lib/index.js +3 -10
  42. package/lib/index.js.map +1 -1
  43. package/lib/messageRecognition.d.ts +0 -20
  44. package/lib/messageRecognition.d.ts.map +1 -1
  45. package/lib/messageRecognition.js +0 -35
  46. package/lib/messageRecognition.js.map +1 -1
  47. package/lib/network.d.ts +0 -15
  48. package/lib/network.d.ts.map +1 -1
  49. package/lib/network.js.map +1 -1
  50. package/lib/networkUtils.d.ts +0 -10
  51. package/lib/networkUtils.d.ts.map +1 -1
  52. package/lib/networkUtils.js +0 -30
  53. package/lib/networkUtils.js.map +1 -1
  54. package/lib/packageVersion.d.ts +1 -1
  55. package/lib/packageVersion.js +1 -1
  56. package/lib/packageVersion.js.map +1 -1
  57. package/lib/parallelRequests.d.ts.map +1 -1
  58. package/lib/parallelRequests.js +46 -15
  59. package/lib/parallelRequests.js.map +1 -1
  60. package/lib/summaryForCreateNew.d.ts +21 -1
  61. package/lib/summaryForCreateNew.d.ts.map +1 -1
  62. package/lib/summaryForCreateNew.js +25 -4
  63. package/lib/summaryForCreateNew.js.map +1 -1
  64. package/lib/treeConversions.d.ts.map +1 -1
  65. package/lib/treeConversions.js +8 -9
  66. package/lib/treeConversions.js.map +1 -1
  67. package/package.json +52 -75
  68. package/src/fluidResolvedUrl.ts +8 -0
  69. package/src/index.ts +4 -19
  70. package/src/messageRecognition.ts +0 -36
  71. package/src/network.ts +0 -16
  72. package/src/networkUtils.ts +0 -32
  73. package/src/packageVersion.ts +1 -1
  74. package/src/parallelRequests.ts +54 -19
  75. package/src/summaryForCreateNew.ts +49 -5
  76. package/src/treeConversions.ts +8 -9
  77. package/dist/blobAggregationStorage.d.ts +0 -43
  78. package/dist/blobAggregationStorage.d.ts.map +0 -1
  79. package/dist/blobAggregationStorage.js +0 -323
  80. package/dist/blobAggregationStorage.js.map +0 -1
  81. package/dist/blobCacheStorageService.d.ts +0 -16
  82. package/dist/blobCacheStorageService.d.ts.map +0 -1
  83. package/dist/blobCacheStorageService.js +0 -29
  84. package/dist/blobCacheStorageService.js.map +0 -1
  85. package/dist/emptyDocumentDeltaStorageService.d.ts +0 -13
  86. package/dist/emptyDocumentDeltaStorageService.d.ts.map +0 -1
  87. package/dist/emptyDocumentDeltaStorageService.js +0 -20
  88. package/dist/emptyDocumentDeltaStorageService.js.map +0 -1
  89. package/dist/mapWithExpiration.d.ts +0 -34
  90. package/dist/mapWithExpiration.d.ts.map +0 -1
  91. package/dist/mapWithExpiration.js +0 -105
  92. package/dist/mapWithExpiration.js.map +0 -1
  93. package/dist/multiDocumentServiceFactory.d.ts +0 -16
  94. package/dist/multiDocumentServiceFactory.d.ts.map +0 -1
  95. package/dist/multiDocumentServiceFactory.js +0 -63
  96. package/dist/multiDocumentServiceFactory.js.map +0 -1
  97. package/dist/multiUrlResolver.d.ts +0 -20
  98. package/dist/multiUrlResolver.d.ts.map +0 -1
  99. package/dist/multiUrlResolver.js +0 -45
  100. package/dist/multiUrlResolver.js.map +0 -1
  101. package/dist/treeUtils.d.ts +0 -51
  102. package/dist/treeUtils.d.ts.map +0 -1
  103. package/dist/treeUtils.js +0 -85
  104. package/dist/treeUtils.js.map +0 -1
  105. package/lib/blobAggregationStorage.d.ts +0 -43
  106. package/lib/blobAggregationStorage.d.ts.map +0 -1
  107. package/lib/blobAggregationStorage.js +0 -318
  108. package/lib/blobAggregationStorage.js.map +0 -1
  109. package/lib/blobCacheStorageService.d.ts +0 -16
  110. package/lib/blobCacheStorageService.d.ts.map +0 -1
  111. package/lib/blobCacheStorageService.js +0 -25
  112. package/lib/blobCacheStorageService.js.map +0 -1
  113. package/lib/emptyDocumentDeltaStorageService.d.ts +0 -13
  114. package/lib/emptyDocumentDeltaStorageService.d.ts.map +0 -1
  115. package/lib/emptyDocumentDeltaStorageService.js +0 -16
  116. package/lib/emptyDocumentDeltaStorageService.js.map +0 -1
  117. package/lib/mapWithExpiration.d.ts +0 -34
  118. package/lib/mapWithExpiration.d.ts.map +0 -1
  119. package/lib/mapWithExpiration.js +0 -101
  120. package/lib/mapWithExpiration.js.map +0 -1
  121. package/lib/multiDocumentServiceFactory.d.ts +0 -16
  122. package/lib/multiDocumentServiceFactory.d.ts.map +0 -1
  123. package/lib/multiDocumentServiceFactory.js +0 -59
  124. package/lib/multiDocumentServiceFactory.js.map +0 -1
  125. package/lib/multiUrlResolver.d.ts +0 -20
  126. package/lib/multiUrlResolver.d.ts.map +0 -1
  127. package/lib/multiUrlResolver.js +0 -40
  128. package/lib/multiUrlResolver.js.map +0 -1
  129. package/lib/treeUtils.d.ts +0 -51
  130. package/lib/treeUtils.d.ts.map +0 -1
  131. package/lib/treeUtils.js +0 -80
  132. package/lib/treeUtils.js.map +0 -1
  133. package/src/blobAggregationStorage.ts +0 -420
  134. package/src/blobCacheStorageService.ts +0 -35
  135. package/src/emptyDocumentDeltaStorageService.ts +0 -25
  136. package/src/mapWithExpiration.ts +0 -124
  137. package/src/multiDocumentServiceFactory.ts +0 -91
  138. package/src/multiUrlResolver.ts +0 -48
  139. package/src/treeUtils.ts +0 -107
@@ -1 +1 @@
1
- {"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,YAAY,EAGZ,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,YAAY,EACxB,eAAe,EAAE,YAAY,GAC3B,YAAY,CASd;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,eAAe,EAAE,YAAY,GAC3B,mBAAmB,CAKrB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CACjD,eAAe,EAAE,YAAY,GAC3B,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAOhC"}
1
+ {"version":3,"file":"summaryForCreateNew.d.ts","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,YAAY,EAGZ,kBAAkB,EAClB,mBAAmB,EACnB,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,6BAA8B,SAAQ,YAAY;IAClE,IAAI,EAAE;QACL,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;QACvB,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;KAC5B,CAAC;CACF;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC9C,OAAO,EAAE,YAAY,GAAG,SAAS,GAC/B,OAAO,IAAI,6BAA6B,CAa1C;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC3C,UAAU,EAAE,YAAY,EACxB,eAAe,EAAE,YAAY,GAC3B,6BAA6B,CAiB/B;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,eAAe,EAAE,YAAY,GAC3B,mBAAmB,CAGrB;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CACjD,eAAe,EAAE,YAAY,GAC3B,CAAC,MAAM,EAAE,kBAAkB,CAAC,EAAE,CAOhC"}
@@ -2,13 +2,37 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
+ import { assert } from "@fluidframework/common-utils";
5
6
  import { SummaryType, } from "@fluidframework/protocol-definitions";
7
+ /**
8
+ * Validates the current layout of an .app + .protocol summary tree
9
+ * this is used internally for create new, and single commit summary
10
+ * @internal
11
+ */
12
+ export function isCombinedAppAndProtocolSummary(summary) {
13
+ var _a, _b, _c, _d;
14
+ if ((summary === null || summary === void 0 ? void 0 : summary.tree) === undefined ||
15
+ ((_b = (_a = summary.tree) === null || _a === void 0 ? void 0 : _a[".app"]) === null || _b === void 0 ? void 0 : _b.type) !== SummaryType.Tree ||
16
+ ((_d = (_c = summary.tree) === null || _c === void 0 ? void 0 : _c[".protocol"]) === null || _d === void 0 ? void 0 : _d.type) !== SummaryType.Tree) {
17
+ return false;
18
+ }
19
+ const treeKeys = Object.keys(summary.tree);
20
+ if (treeKeys.length !== 2) {
21
+ return false;
22
+ }
23
+ return true;
24
+ }
6
25
  /**
7
26
  * Combine the app summary and protocol summary in 1 tree.
8
27
  * @param appSummary - Summary of the app.
9
28
  * @param protocolSummary - Summary of the protocol.
29
+ * @internal
30
+ *
31
+ * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.
10
32
  */
11
33
  export function combineAppAndProtocolSummary(appSummary, protocolSummary) {
34
+ assert(!isCombinedAppAndProtocolSummary(appSummary), 0x5a8 /* app summary is already a combined tree! */);
35
+ assert(!isCombinedAppAndProtocolSummary(protocolSummary), 0x5a9 /* protocol summary is already a combined tree! */);
12
36
  const createNewSummary = {
13
37
  type: SummaryType.Tree,
14
38
  tree: {
@@ -23,11 +47,8 @@ export function combineAppAndProtocolSummary(appSummary, protocolSummary) {
23
47
  * @param protocolSummary - protocol summary from which the values are to be extracted.
24
48
  */
25
49
  export function getDocAttributesFromProtocolSummary(protocolSummary) {
26
- var _a;
27
50
  const attributesBlob = protocolSummary.tree.attributes;
28
- const documentAttributes = JSON.parse(attributesBlob.content);
29
- documentAttributes.term = (_a = documentAttributes.term) !== null && _a !== void 0 ? _a : 1;
30
- return documentAttributes;
51
+ return JSON.parse(attributesBlob.content);
31
52
  }
32
53
  /**
33
54
  * Extract quorum values from the protocol summary.
@@ -1 +1 @@
1
- {"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,WAAW,GAIX,MAAM,sCAAsC,CAAC;AAE9C;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC3C,UAAwB,EACxB,eAA6B;IAE7B,MAAM,gBAAgB,GAAiB;QACtC,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE;YACL,WAAW,EAAE,eAAe;YAC5B,MAAM,EAAE,UAAU;SAClB;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAClD,eAA6B;;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;IAC/F,kBAAkB,CAAC,IAAI,GAAG,MAAA,kBAAkB,CAAC,IAAI,mCAAI,CAAC,CAAC;IACvD,OAAO,kBAAkB,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tISummaryTree,\n\tSummaryType,\n\tISummaryBlob,\n\tICommittedProposal,\n\tIDocumentAttributes,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): ISummaryTree {\n\tconst createNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\tconst documentAttributes = JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n\tdocumentAttributes.term = documentAttributes.term ?? 1;\n\treturn documentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
1
+ {"version":3,"file":"summaryForCreateNew.js","sourceRoot":"","sources":["../src/summaryForCreateNew.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAEN,WAAW,GAIX,MAAM,sCAAsC,CAAC;AAc9C;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAC9C,OAAiC;;IAEjC,IACC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,SAAS;QAC3B,CAAA,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAG,MAAM,CAAC,0CAAE,IAAI,MAAK,WAAW,CAAC,IAAI;QACjD,CAAA,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAG,WAAW,CAAC,0CAAE,IAAI,MAAK,WAAW,CAAC,IAAI,EACrD;QACD,OAAO,KAAK,CAAC;KACb;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAC1B,OAAO,KAAK,CAAC;KACb;IACD,OAAO,IAAI,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAC3C,UAAwB,EACxB,eAA6B;IAE7B,MAAM,CACL,CAAC,+BAA+B,CAAC,UAAU,CAAC,EAC5C,KAAK,CAAC,6CAA6C,CACnD,CAAC;IACF,MAAM,CACL,CAAC,+BAA+B,CAAC,eAAe,CAAC,EACjD,KAAK,CAAC,kDAAkD,CACxD,CAAC;IACF,MAAM,gBAAgB,GAAkC;QACvD,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,IAAI,EAAE;YACL,WAAW,EAAE,eAAe;YAC5B,MAAM,EAAE,UAAU;SAClB;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAClD,eAA6B;IAE7B,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CAAC,UAA0B,CAAC;IACvE,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAiB,CAAwB,CAAC;AAC5E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kCAAkC,CACjD,eAA6B;IAE7B,MAAM,gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,YAA4B,CAAC;IAC3E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAiB,CAG/D,CAAC;IACJ,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport {\n\tISummaryTree,\n\tSummaryType,\n\tISummaryBlob,\n\tICommittedProposal,\n\tIDocumentAttributes,\n} from \"@fluidframework/protocol-definitions\";\n\n/**\n * Defines the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport interface CombinedAppAndProtocolSummary extends ISummaryTree {\n\ttree: {\n\t\t[\".app\"]: ISummaryTree;\n\t\t[\".protocol\"]: ISummaryTree;\n\t};\n}\n\n/**\n * Validates the current layout of an .app + .protocol summary tree\n * this is used internally for create new, and single commit summary\n * @internal\n */\nexport function isCombinedAppAndProtocolSummary(\n\tsummary: ISummaryTree | undefined,\n): summary is CombinedAppAndProtocolSummary {\n\tif (\n\t\tsummary?.tree === undefined ||\n\t\tsummary.tree?.[\".app\"]?.type !== SummaryType.Tree ||\n\t\tsummary.tree?.[\".protocol\"]?.type !== SummaryType.Tree\n\t) {\n\t\treturn false;\n\t}\n\tconst treeKeys = Object.keys(summary.tree);\n\tif (treeKeys.length !== 2) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n *\n * @deprecated 2.0.0-internal.3.4.0 - Not intended for public use. Will be moved to container-loader and no longer exported in an upcoming release.\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Extract the attributes from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getDocAttributesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): IDocumentAttributes {\n\tconst attributesBlob = protocolSummary.tree.attributes as ISummaryBlob;\n\treturn JSON.parse(attributesBlob.content as string) as IDocumentAttributes;\n}\n\n/**\n * Extract quorum values from the protocol summary.\n * @param protocolSummary - protocol summary from which the values are to be extracted.\n */\nexport function getQuorumValuesFromProtocolSummary(\n\tprotocolSummary: ISummaryTree,\n): [string, ICommittedProposal][] {\n\tconst quorumValuesBlob = protocolSummary.tree.quorumValues as ISummaryBlob;\n\tconst quorumValues = JSON.parse(quorumValuesBlob.content as string) as [\n\t\tstring,\n\t\tICommittedProposal,\n\t][];\n\treturn quorumValues;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAEpG;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAkDlF"}
1
+ {"version":3,"file":"treeConversions.d.ts","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,KAAK,EAA2B,MAAM,sCAAsC,CAAC;AAGpG;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,YAAY,GAAG,KAAK,CAgDlF"}
@@ -5,23 +5,22 @@
5
5
  import { Uint8ArrayToString, unreachableCase } from "@fluidframework/common-utils";
6
6
  import { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from "@fluidframework/protocol-base";
7
7
  import { SummaryType } from "@fluidframework/protocol-definitions";
8
+ import { isCombinedAppAndProtocolSummary } from "./summaryForCreateNew";
8
9
  /**
9
10
  * Converts ISummaryTree to ITree format.
10
11
  * @param summaryTree - summary tree in ISummaryTree format
11
12
  */
12
13
  export function convertSummaryTreeToSnapshotITree(summaryTree) {
13
14
  const entries = [];
14
- const protocolSummary = summaryTree.tree[".protocol"];
15
- const appSummary = summaryTree.tree[".app"];
16
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
17
- const adaptSumaryTree = protocolSummary && appSummary;
18
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
19
- const allSummaryEntries = adaptSumaryTree
20
- ? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]
15
+ const adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);
16
+ const allSummaryEntries = adaptSummaryTree
17
+ ? [
18
+ ...Object.entries(summaryTree.tree[".protocol"].tree),
19
+ ...Object.entries(summaryTree.tree[".app"].tree),
20
+ ]
21
21
  : Object.entries(summaryTree.tree);
22
22
  for (const [key, value] of allSummaryEntries) {
23
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
24
- const k = adaptSumaryTree && ["attributes"].includes(key) ? `.${key}` : key;
23
+ const k = adaptSummaryTree && key === "attributes" ? ".attributes" : key;
25
24
  switch (value.type) {
26
25
  case SummaryType.Blob: {
27
26
  let parsedContent;
@@ -1 +1 @@
1
- {"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAmC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEpG;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IACtE,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,CAAiB,CAAC;IAC5D,yEAAyE;IACzE,MAAM,eAAe,GAAG,eAAe,IAAI,UAAU,CAAC;IACtD,yEAAyE;IACzE,MAAM,iBAAiB,GAAG,eAAe;QACxC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/E,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,EAAE;QAC7C,yEAAyE;QACzE,MAAM,CAAC,GAAG,eAAe,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC5E,QAAQ,KAAK,CAAC,IAAI,EAAE;YACnB,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,aAAqB,CAAC;gBAC1B,IAAI,QAAQ,GAAuB,OAAO,CAAC;gBAC3C,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;oBACtC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;iBAC9B;qBAAM;oBACN,aAAa,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAC5D,QAAQ,GAAG,QAAQ,CAAC;iBACpB;gBACD,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC5D,MAAM;aACN;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7E,MAAM;aACN;YAED,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,eAAe,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst protocolSummary = summaryTree.tree[\".protocol\"] as ISummaryTree;\n\tconst appSummary = summaryTree.tree[\".app\"] as ISummaryTree;\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tconst adaptSumaryTree = protocolSummary && appSummary;\n\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\tconst allSummaryEntries = adaptSumaryTree\n\t\t? [...Object.entries(protocolSummary.tree), ...Object.entries(appSummary.tree)]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\t// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n\t\tconst k = adaptSumaryTree && [\"attributes\"].includes(key) ? `.${key}` : key;\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(k, 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(k, convertSummaryTreeToSnapshotITree(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(k, 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};\n}\n"]}
1
+ {"version":3,"file":"treeConversions.js","sourceRoot":"","sources":["../src/treeConversions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAmC,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACpG,OAAO,EAAE,+BAA+B,EAAE,MAAM,uBAAuB,CAAC;AAExE;;;GAGG;AACH,MAAM,UAAU,iCAAiC,CAAC,WAAyB;IAC1E,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,gBAAgB,GAAG,+BAA+B,CAAC,WAAW,CAAC,CAAC;IACtE,MAAM,iBAAiB,GAAG,gBAAgB;QACzC,CAAC,CAAC;YACA,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;YACrD,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC;SAC/C;QACH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAEpC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,iBAAiB,EAAE;QAC7C,MAAM,CAAC,GAAG,gBAAgB,IAAI,GAAG,KAAK,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC;QACzE,QAAQ,KAAK,CAAC,IAAI,EAAE;YACnB,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,IAAI,aAAqB,CAAC;gBAC1B,IAAI,QAAQ,GAAuB,OAAO,CAAC;gBAC3C,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;oBACtC,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC;iBAC9B;qBAAM;oBACN,aAAa,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;oBAC5D,QAAQ,GAAG,QAAQ,CAAC;iBACpB;gBACD,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;gBAC5D,MAAM;aACN;YAED,KAAK,WAAW,CAAC,IAAI,CAAC,CAAC;gBACtB,OAAO,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,CAAC,EAAE,iCAAiC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC7E,MAAM;aACN;YAED,KAAK,WAAW,CAAC,UAAU,CAAC,CAAC;gBAC5B,OAAO,CAAC,IAAI,CAAC,IAAI,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;gBACnD,MAAM;aACN;YAED,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;aAC/D;YAED;gBACC,eAAe,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;SACxD;KACD;IACD,OAAO;QACN,OAAO;QACP,YAAY,EAAE,WAAW,CAAC,YAAY;KACtC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/protocol-base\";\nimport { ISummaryTree, ITree, ITreeEntry, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { isCombinedAppAndProtocolSummary } from \"./summaryForCreateNew\";\n\n/**\n * Converts ISummaryTree to ITree format.\n * @param summaryTree - summary tree in ISummaryTree format\n */\nexport function convertSummaryTreeToSnapshotITree(summaryTree: ISummaryTree): ITree {\n\tconst entries: ITreeEntry[] = [];\n\tconst adaptSummaryTree = isCombinedAppAndProtocolSummary(summaryTree);\n\tconst allSummaryEntries = adaptSummaryTree\n\t\t? [\n\t\t\t\t...Object.entries(summaryTree.tree[\".protocol\"].tree),\n\t\t\t\t...Object.entries(summaryTree.tree[\".app\"].tree),\n\t\t ]\n\t\t: Object.entries(summaryTree.tree);\n\n\tfor (const [key, value] of allSummaryEntries) {\n\t\tconst k = adaptSummaryTree && key === \"attributes\" ? \".attributes\" : key;\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(k, 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(k, convertSummaryTreeToSnapshotITree(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(k, 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};\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/driver-utils",
3
- "version": "2.0.0-dev.3.1.0.125672",
3
+ "version": "2.0.0-dev.4.2.0.153917",
4
4
  "description": "Collection of utility functions for Fluid drivers",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -14,33 +14,6 @@
14
14
  "main": "dist/index.js",
15
15
  "module": "lib/index.js",
16
16
  "types": "dist/index.d.ts",
17
- "scripts": {
18
- "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
19
- "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
20
- "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
21
- "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
22
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
23
- "build:full": "npm run build",
24
- "build:full:compile": "npm run build:compile",
25
- "build:genver": "gen-version",
26
- "build:test": "tsc --project ./src/test/tsconfig.json",
27
- "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
28
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
- "eslint": "eslint --format stylish src",
30
- "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
- "format": "npm run prettier:fix",
32
- "lint": "npm run prettier && npm run eslint",
33
- "lint:fix": "npm run prettier:fix && npm run eslint:fix",
34
- "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
35
- "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
36
- "test": "npm run test:mocha",
37
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
38
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
39
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
40
- "tsc": "tsc",
41
- "typetests:gen": "flub generate typetests --generate --dir .",
42
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
43
- },
44
17
  "nyc": {
45
18
  "all": true,
46
19
  "cache-dir": "nyc/.cache",
@@ -63,68 +36,72 @@
63
36
  },
64
37
  "dependencies": {
65
38
  "@fluidframework/common-definitions": "^0.20.1",
66
- "@fluidframework/common-utils": "^1.0.0",
67
- "@fluidframework/core-interfaces": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
68
- "@fluidframework/driver-definitions": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
69
- "@fluidframework/gitresources": "^0.1038.2000",
70
- "@fluidframework/protocol-base": "^0.1038.2000",
39
+ "@fluidframework/common-utils": "^1.1.1",
40
+ "@fluidframework/core-interfaces": "2.0.0-dev.4.2.0.153917",
41
+ "@fluidframework/driver-definitions": "2.0.0-dev.4.2.0.153917",
42
+ "@fluidframework/gitresources": "^0.1039.1000",
43
+ "@fluidframework/protocol-base": "^0.1039.1000",
71
44
  "@fluidframework/protocol-definitions": "^1.1.0",
72
- "@fluidframework/telemetry-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
45
+ "@fluidframework/telemetry-utils": "2.0.0-dev.4.2.0.153917",
73
46
  "axios": "^0.26.0",
74
47
  "url": "^0.11.0",
75
48
  "uuid": "^8.3.1"
76
49
  },
77
50
  "devDependencies": {
78
- "@fluid-tools/build-cli": "^0.8.0",
51
+ "@fluid-tools/build-cli": "^0.15.0",
79
52
  "@fluidframework/build-common": "^1.1.0",
80
- "@fluidframework/build-tools": "^0.8.0",
81
- "@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.3.0.0",
53
+ "@fluidframework/build-tools": "^0.15.0",
54
+ "@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.4.0.0",
82
55
  "@fluidframework/eslint-config-fluid": "^2.0.0",
83
- "@fluidframework/mocha-test-setup": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
84
- "@fluidframework/runtime-utils": ">=2.0.0-dev.3.1.0.125672 <2.0.0-dev.4.0.0",
85
- "@microsoft/api-extractor": "^7.22.2",
86
- "@rushstack/eslint-config": "^2.5.1",
56
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.4.2.0.153917",
57
+ "@fluidframework/runtime-utils": "2.0.0-dev.4.2.0.153917",
58
+ "@microsoft/api-extractor": "^7.34.4",
87
59
  "@types/mocha": "^9.1.1",
88
- "@types/node": "^14.18.36",
60
+ "@types/node": "^14.18.38",
89
61
  "@types/sinon": "^7.0.13",
90
- "concurrently": "^6.2.0",
62
+ "concurrently": "^7.6.0",
91
63
  "copyfiles": "^2.4.1",
92
- "cross-env": "^7.0.2",
64
+ "cross-env": "^7.0.3",
93
65
  "eslint": "~8.6.0",
94
- "mocha": "^10.0.0",
95
- "nyc": "^15.0.0",
66
+ "mocha": "^10.2.0",
67
+ "mocha-json-output-reporter": "^2.0.1",
68
+ "mocha-multi-reporters": "^1.5.1",
69
+ "moment": "^2.21.0",
70
+ "nyc": "^15.1.0",
96
71
  "prettier": "~2.6.2",
97
- "rimraf": "^2.6.2",
72
+ "rimraf": "^4.4.0",
98
73
  "sinon": "^7.4.2",
99
74
  "typescript": "~4.5.5"
100
75
  },
101
76
  "typeValidation": {
102
- "version": "2.0.0-internal.3.1.0",
103
- "previousVersionStyle": "~previousMinor",
104
- "baselineRange": ">=2.0.0-internal.3.0.0 <2.0.0-internal.3.1.0",
105
- "baselineVersion": "2.0.0-internal.3.0.0",
106
- "broken": {
107
- "ClassDeclaration_AuthorizationError": {
108
- "backCompat": false
109
- },
110
- "ClassDeclaration_DeltaStreamConnectionForbiddenError": {
111
- "backCompat": false
112
- },
113
- "ClassDeclaration_FluidInvalidSchemaError": {
114
- "backCompat": false
115
- },
116
- "ClassDeclaration_GenericNetworkError": {
117
- "backCompat": false
118
- },
119
- "ClassDeclaration_LocationRedirectionError": {
120
- "backCompat": false
121
- },
122
- "ClassDeclaration_ThrottlingError": {
123
- "backCompat": false
124
- },
125
- "ClassDeclaration_UsageError": {
126
- "backCompat": false
127
- }
128
- }
77
+ "broken": {}
78
+ },
79
+ "scripts": {
80
+ "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
81
+ "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
82
+ "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
83
+ "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
84
+ "build:esnext": "tsc --project ./tsconfig.esnext.json",
85
+ "build:full": "npm run build",
86
+ "build:full:compile": "npm run build:compile",
87
+ "build:genver": "gen-version",
88
+ "build:test": "tsc --project ./src/test/tsconfig.json",
89
+ "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
90
+ "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
91
+ "eslint": "eslint --format stylish src",
92
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
93
+ "format": "npm run prettier:fix",
94
+ "lint": "npm run prettier && npm run eslint",
95
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
96
+ "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
97
+ "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
98
+ "test": "npm run test:mocha",
99
+ "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
100
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
101
+ "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
102
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
103
+ "tsc": "tsc",
104
+ "typetests:gen": "fluid-type-test-generator",
105
+ "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
129
106
  }
130
- }
107
+ }
@@ -5,10 +5,18 @@
5
5
 
6
6
  import { IResolvedUrl, IFluidResolvedUrl } from "@fluidframework/driver-definitions";
7
7
 
8
+ /**
9
+ * @deprecated In the next major release all IResolvedUrl will be IFluidResolvedUrl,
10
+ * so this method is no longer necessary.
11
+ */
8
12
  export const isFluidResolvedUrl = (
9
13
  resolved: IResolvedUrl | undefined,
10
14
  ): resolved is IFluidResolvedUrl => resolved?.type === "fluid";
11
15
 
16
+ /**
17
+ * @deprecated In the next major release all IResolvedUrl will be IFluidResolvedUrl,
18
+ * so this method is no longer necessary.
19
+ */
12
20
  export function ensureFluidResolvedUrl(
13
21
  resolved: IResolvedUrl | undefined,
14
22
  ): asserts resolved is IFluidResolvedUrl {
package/src/index.ts CHANGED
@@ -3,23 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export { BlobAggregationStorage, SnapshotExtractor } from "./blobAggregationStorage";
7
- export { BlobCacheStorageService } from "./blobCacheStorageService";
8
6
  export { buildSnapshotTree } from "./buildSnapshotTree";
9
7
  export { DocumentStorageServiceProxy } from "./documentStorageServiceProxy";
10
- export { EmptyDocumentDeltaStorageService } from "./emptyDocumentDeltaStorageService";
11
8
  export { UsageError } from "./error";
12
9
  export { ensureFluidResolvedUrl, isFluidResolvedUrl } from "./fluidResolvedUrl";
13
10
  export { InsecureUrlResolver } from "./insecureUrlResolver";
14
- export { MapWithExpiration } from "./mapWithExpiration";
15
- export {
16
- canBeCoalescedByService,
17
- isRuntimeMessage,
18
- isUnpackedRuntimeMessage,
19
- MessageType2,
20
- } from "./messageRecognition";
21
- export { MultiDocumentServiceFactory } from "./multiDocumentServiceFactory";
22
- export { configurableUrlResolver, MultiUrlResolver } from "./multiUrlResolver";
11
+ export { canBeCoalescedByService, isRuntimeMessage, MessageType2 } from "./messageRecognition";
23
12
  export {
24
13
  AuthorizationError,
25
14
  canRetryOnError,
@@ -31,7 +20,6 @@ export {
31
20
  GenericNetworkError,
32
21
  getRetryDelayFromError,
33
22
  getRetryDelaySecondsFromError,
34
- IAnyDriverError,
35
23
  isOnline,
36
24
  LocationRedirectionError,
37
25
  NetworkErrorBasic,
@@ -40,7 +28,7 @@ export {
40
28
  RetryableError,
41
29
  ThrottlingError,
42
30
  } from "./network";
43
- export { logNetworkFailure, waitForConnectedState } from "./networkUtils";
31
+ export { logNetworkFailure } from "./networkUtils";
44
32
  export {
45
33
  emptyMessageStream,
46
34
  ParallelRequests,
@@ -55,12 +43,9 @@ export { readAndParse } from "./readAndParse";
55
43
  export { IProgress, runWithRetry } from "./runWithRetry";
56
44
  export {
57
45
  combineAppAndProtocolSummary,
46
+ CombinedAppAndProtocolSummary,
58
47
  getDocAttributesFromProtocolSummary,
59
48
  getQuorumValuesFromProtocolSummary,
49
+ isCombinedAppAndProtocolSummary,
60
50
  } from "./summaryForCreateNew";
61
51
  export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
62
- export {
63
- convertSnapshotAndBlobsToSummaryTree,
64
- ISummaryTreeAssemblerProps,
65
- SummaryTreeAssembler,
66
- } from "./treeUtils";
@@ -17,42 +17,6 @@ export function isRuntimeMessage(message: { type: string }): boolean {
17
17
  return message.type === MessageType.Operation;
18
18
  }
19
19
 
20
- enum RuntimeMessage {
21
- FluidDataStoreOp = "component",
22
- Attach = "attach",
23
- ChunkedOp = "chunkedOp",
24
- BlobAttach = "blobAttach",
25
- Rejoin = "rejoin",
26
- Alias = "alias",
27
- Operation = "op",
28
- }
29
-
30
- /**
31
- * Determines whether or not the message type is one of the following: (legacy)
32
- *
33
- * - "component"
34
- *
35
- * - "attach"
36
- *
37
- * - "chunkedOp"
38
- *
39
- * - "blobAttach"
40
- *
41
- * - "rejoin"
42
- *
43
- * - "alias"
44
- *
45
- * - "op"
46
- *
47
- * @deprecated This API should not be used.
48
- */
49
- export function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean {
50
- if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {
51
- return true;
52
- }
53
- return false;
54
- }
55
-
56
20
  // ADO #1385: staging code changes across layers.
57
21
  // Eventually to be replaced by MessageType.accept
58
22
  export enum MessageType2 {
package/src/network.ts CHANGED
@@ -34,22 +34,6 @@ export function isOnline(): OnlineStatus {
34
34
  return OnlineStatus.Unknown;
35
35
  }
36
36
 
37
- /**
38
- * Interface describing errors and warnings raised by any driver code.
39
- * Not expected to be implemented by a class or an object literal, but rather used in place of
40
- * any or unknown in various function signatures that pass errors around.
41
- *
42
- * "Any" in the interface name is a nod to the fact that errorType has lost its type constraint.
43
- * It will be either DriverErrorType or the specific driver's specialized error type enum,
44
- * but we can't reference a specific driver's error type enum in this code.
45
- *
46
- * @deprecated - In favour of {@link @fluidframework/driver-definitions#IAnyDriverError} so that
47
- * it can used from the base to upper layers.
48
- */
49
- export interface IAnyDriverError extends Omit<IDriverErrorBase, "errorType"> {
50
- readonly errorType: string;
51
- }
52
-
53
37
  /** Telemetry props with driver-specific required properties */
54
38
  export type DriverErrorTelemetryProps = ITelemetryProperties & {
55
39
  driverVersion: string | undefined;
@@ -29,35 +29,3 @@ export function logNetworkFailure(
29
29
  newEvent.category = canRetryOnError(error) ? "generic" : "error";
30
30
  logger.sendTelemetryEvent(newEvent, error);
31
31
  }
32
-
33
- /**
34
- * Wait for browser to get to connected state.
35
- * If connected, waits minimum of minDelay anyway (between network retries)
36
- * If disconnected, polls every 30 seconds anyway, to make sure we are not getting stuck because of wrong signal
37
- * Note that browsers will have false positives (like having Hyper-V adapter on machine,
38
- * or machine connected to router that is not connected to internet)
39
- * But there should be no false negatives.
40
- * The only exception - Opera returns false when user enters "Work Offline" mode, regardless of actual connectivity.
41
- */
42
- // eslint-disable-next-line @typescript-eslint/promise-function-async
43
- export function waitForConnectedState(minDelay: number): Promise<void> {
44
- // Use this frequency to poll even when we are offline and able to setup online/offline listener
45
- // This is mostly safety net
46
- const offlinePollFrequency = 30000;
47
-
48
- return new Promise((resolve) => {
49
- let listener: () => void = resolve;
50
- let delay = minDelay;
51
- if (isOnline() === OnlineStatus.Offline) {
52
- if (window?.addEventListener !== undefined) {
53
- listener = () => {
54
- resolve();
55
- window.removeEventListener("online", listener);
56
- };
57
- window.addEventListener("online", listener, false);
58
- delay = Math.max(minDelay, offlinePollFrequency);
59
- }
60
- }
61
- setTimeout(listener, delay);
62
- });
63
- }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/driver-utils";
9
- export const pkgVersion = "2.0.0-dev.3.1.0.125672";
9
+ export const pkgVersion = "2.0.0-dev.4.2.0.153917";
@@ -8,7 +8,7 @@ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
8
8
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
9
9
  import { IDeltasFetchResult, IStream, IStreamResult } from "@fluidframework/driver-definitions";
10
10
  import { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from "./network";
11
- import { waitForConnectedState, logNetworkFailure } from "./networkUtils";
11
+ import { logNetworkFailure } from "./networkUtils";
12
12
  // For now, this package is versioned and released in unison with the specific drivers
13
13
  import { pkgVersion as driverVersion } from "./packageVersion";
14
14
 
@@ -379,6 +379,19 @@ export class Queue<T> implements IStream<T> {
379
379
  }
380
380
  }
381
381
 
382
+ const waitForOnline = async (): Promise<void> => {
383
+ // Only wait if we have a strong signal that we're offline - otherwise assume we're online.
384
+ if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
385
+ return new Promise<void>((resolve) => {
386
+ const resolveAndRemoveListener = () => {
387
+ resolve();
388
+ globalThis.removeEventListener("online", resolveAndRemoveListener);
389
+ };
390
+ globalThis.addEventListener("online", resolveAndRemoveListener);
391
+ });
392
+ }
393
+ };
394
+
382
395
  /**
383
396
  * Retrieve single batch of ops
384
397
  * @param request - request index
@@ -401,10 +414,11 @@ async function getSingleOpBatch(
401
414
  scenarioName?: string,
402
415
  ): Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[] }> {
403
416
  let lastSuccessTime: number | undefined;
404
-
417
+ let totalRetryAfterTime = 0;
418
+ let telemetryEvent: PerformanceEvent | undefined;
405
419
  let retry: number = 0;
406
- const deltas: ISequencedDocumentMessage[] = [];
407
420
  const nothing = { partial: false, cancel: true, payload: [] };
421
+ let waitStartTime: number = 0;
408
422
 
409
423
  while (signal?.aborted !== true) {
410
424
  retry++;
@@ -412,23 +426,28 @@ async function getSingleOpBatch(
412
426
  const startTime = performance.now();
413
427
 
414
428
  try {
415
- // Issue async request for deltas - limit the number fetched to MaxBatchDeltas
416
- const deltasP = get({ ...props, retry } /* telemetry props */);
417
-
418
- const { messages, partialResult } = await deltasP;
419
- deltas.push(...messages);
420
-
421
- const deltasRetrievedLast = messages.length;
429
+ // Issue async request for deltas
430
+ const { messages, partialResult } = await get(
431
+ { ...props, retry } /* telemetry props */,
432
+ );
422
433
 
423
- if (deltasRetrievedLast !== 0 || !strongTo) {
424
- return { payload: deltas, cancel: false, partial: partialResult };
434
+ // If we got messages back, return them. Return regardless of whether we got messages back if we didn't
435
+ // specify a "to", since we don't have an expectation of how many to receive.
436
+ if (messages.length !== 0 || !strongTo) {
437
+ // Report this event if we waited to fetch ops due to being offline or throttling.
438
+ telemetryEvent?.end({
439
+ duration: totalRetryAfterTime,
440
+ ...props,
441
+ reason: scenarioName,
442
+ });
443
+ return { payload: messages, cancel: false, partial: partialResult };
425
444
  }
426
445
 
427
- // Storage does not have ops we need.
428
- // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry
429
- // count since something prevented us from seeing those deltas
446
+ // Otherwise, the storage gave us back an empty set of ops but we were expecting a non-empty set.
430
447
 
431
448
  if (lastSuccessTime === undefined) {
449
+ // Take timestamp of the first time server responded successfully, even though it wasn't with the ops we asked for.
450
+ // If we keep getting empty responses we'll eventually fail out below.
432
451
  lastSuccessTime = performance.now();
433
452
  } else if (performance.now() - lastSuccessTime > 30000) {
434
453
  // If we are connected and receiving proper responses from server, but can't get any ops back,
@@ -449,8 +468,6 @@ async function getSingleOpBatch(
449
468
  } catch (error) {
450
469
  const canRetry = canRetryOnError(error);
451
470
 
452
- lastSuccessTime = undefined;
453
-
454
471
  const retryAfter = getRetryDelayFromError(error);
455
472
 
456
473
  // This will log to error table only if the error is non-retryable
@@ -472,12 +489,30 @@ async function getSingleOpBatch(
472
489
  throw error;
473
490
  }
474
491
 
475
- if (retryAfter !== undefined && retryAfter >= 0) {
492
+ if (retryAfter !== undefined) {
493
+ // If the error told us to wait, then we will wait for that specific amount rather than the default.
476
494
  delay = retryAfter;
477
495
  }
478
496
  }
479
497
 
480
- await waitForConnectedState(delay);
498
+ if (telemetryEvent === undefined) {
499
+ waitStartTime = performance.now();
500
+ telemetryEvent = PerformanceEvent.start(logger, {
501
+ eventName: "GetDeltasWaitTime",
502
+ });
503
+ }
504
+
505
+ // If we get here something has gone wrong - either got an unexpected empty set of messages back or a real error.
506
+ // Either way we will wait a little bit before retrying.
507
+ await new Promise<void>((resolve) => {
508
+ setTimeout(resolve, delay);
509
+ });
510
+
511
+ // If we believe we're offline, we assume there's no point in trying until we at least think we're online.
512
+ // NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
513
+ // should probably live in the driver.
514
+ await waitForOnline();
515
+ totalRetryAfterTime += performance.now() - waitStartTime;
481
516
  }
482
517
 
483
518
  return nothing;