@fluidframework/odsp-driver 2.13.0 → 2.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/WriteBufferUtils.js.map +1 -1
  3. package/dist/compactSnapshotParser.js +5 -5
  4. package/dist/compactSnapshotParser.js.map +1 -1
  5. package/dist/fetchSnapshot.d.ts.map +1 -1
  6. package/dist/fetchSnapshot.js +8 -3
  7. package/dist/fetchSnapshot.js.map +1 -1
  8. package/dist/getFileLink.js +3 -3
  9. package/dist/getFileLink.js.map +1 -1
  10. package/dist/index.d.ts +0 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -3
  13. package/dist/index.js.map +1 -1
  14. package/dist/odspDelayLoadedDeltaStream.d.ts +2 -1
  15. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  16. package/dist/odspDelayLoadedDeltaStream.js +12 -11
  17. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  18. package/dist/odspDocumentDeltaConnection.js +3 -3
  19. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  20. package/dist/odspDocumentStorageManager.js +6 -6
  21. package/dist/odspDocumentStorageManager.js.map +1 -1
  22. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  23. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  24. package/dist/odspDriverUrlResolver.js +1 -1
  25. package/dist/odspDriverUrlResolver.js.map +1 -1
  26. package/dist/odspUtils.js +6 -6
  27. package/dist/odspUtils.js.map +1 -1
  28. package/dist/opsCaching.js +2 -2
  29. package/dist/opsCaching.js.map +1 -1
  30. package/dist/package.json +2 -1
  31. package/dist/packageVersion.d.ts +1 -1
  32. package/dist/packageVersion.js +1 -1
  33. package/dist/packageVersion.js.map +1 -1
  34. package/dist/prefetchLatestSnapshot.js +1 -1
  35. package/dist/prefetchLatestSnapshot.js.map +1 -1
  36. package/dist/retryUtils.js +4 -4
  37. package/dist/retryUtils.js.map +1 -1
  38. package/dist/vroom.d.ts +4 -3
  39. package/dist/vroom.d.ts.map +1 -1
  40. package/dist/vroom.js +12 -7
  41. package/dist/vroom.js.map +1 -1
  42. package/lib/WriteBufferUtils.js.map +1 -1
  43. package/lib/compactSnapshotParser.js +5 -5
  44. package/lib/compactSnapshotParser.js.map +1 -1
  45. package/lib/fetchSnapshot.d.ts.map +1 -1
  46. package/lib/fetchSnapshot.js +8 -3
  47. package/lib/fetchSnapshot.js.map +1 -1
  48. package/lib/getFileLink.js +3 -3
  49. package/lib/getFileLink.js.map +1 -1
  50. package/lib/index.d.ts +0 -1
  51. package/lib/index.d.ts.map +1 -1
  52. package/lib/index.js +0 -1
  53. package/lib/index.js.map +1 -1
  54. package/lib/odspDelayLoadedDeltaStream.d.ts +2 -1
  55. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  56. package/lib/odspDelayLoadedDeltaStream.js +13 -12
  57. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  58. package/lib/odspDocumentDeltaConnection.js +4 -4
  59. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  60. package/lib/odspDocumentStorageManager.js +7 -7
  61. package/lib/odspDocumentStorageManager.js.map +1 -1
  62. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  63. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  64. package/lib/odspDriverUrlResolver.js +1 -1
  65. package/lib/odspDriverUrlResolver.js.map +1 -1
  66. package/lib/odspUtils.js +7 -7
  67. package/lib/odspUtils.js.map +1 -1
  68. package/lib/opsCaching.js +3 -3
  69. package/lib/opsCaching.js.map +1 -1
  70. package/lib/packageVersion.d.ts +1 -1
  71. package/lib/packageVersion.js +1 -1
  72. package/lib/packageVersion.js.map +1 -1
  73. package/lib/prefetchLatestSnapshot.js +2 -2
  74. package/lib/prefetchLatestSnapshot.js.map +1 -1
  75. package/lib/retryUtils.js +5 -5
  76. package/lib/retryUtils.js.map +1 -1
  77. package/lib/vroom.d.ts +4 -3
  78. package/lib/vroom.d.ts.map +1 -1
  79. package/lib/vroom.js +12 -7
  80. package/lib/vroom.js.map +1 -1
  81. package/package.json +14 -14
  82. package/src/WriteBufferUtils.ts +2 -2
  83. package/src/compactSnapshotParser.ts +5 -5
  84. package/src/fetchSnapshot.ts +7 -8
  85. package/src/getFileLink.ts +2 -3
  86. package/src/index.ts +0 -1
  87. package/src/odspDelayLoadedDeltaStream.ts +14 -5
  88. package/src/odspDocumentDeltaConnection.ts +4 -4
  89. package/src/odspDocumentStorageManager.ts +7 -7
  90. package/src/odspDocumentStorageServiceBase.ts +2 -3
  91. package/src/odspDriverUrlResolver.ts +1 -1
  92. package/src/odspUtils.ts +7 -7
  93. package/src/opsCaching.ts +3 -3
  94. package/src/packageVersion.ts +1 -1
  95. package/src/prefetchLatestSnapshot.ts +2 -2
  96. package/src/retryUtils.ts +5 -5
  97. package/src/vroom.ts +14 -8
  98. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +0 -16
  99. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +0 -1
  100. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +0 -20
  101. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  102. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +0 -16
  103. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +0 -1
  104. package/lib/odspDocumentServiceFactoryWithCodeSplit.js +0 -16
  105. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +0 -1
  106. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +0 -33
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fluidframework/odsp-driver
2
2
 
3
+ ## 2.21.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.20.0
8
+
9
+ Dependency updates only.
10
+
3
11
  ## 2.13.0
4
12
 
5
13
  Dependency updates only.
@@ -1 +1 @@
1
- {"version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copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\tnewData[index] = oldData[index]!;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode: MarkerCodesStart | undefined = MarkerCodesStart[child.type];\n\t\t\tconst endCode: MarkerCodesEnd | undefined = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
1
+ {"version":3,"file":"WriteBufferUtils.js","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAyD;AACzD,kEAA6D;AAE7D,uFAQ2C;AAE3C;;;GAGG;AACH,MAAa,WAAW;IAAxB;QACW,SAAI,GAAgB,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QACzC,UAAK,GAAG,CAAC,CAAC;IAsCrB,CAAC;IApCU,IAAI,CAAC,IAAY;QAC1B,IAAA,iBAAM,EAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACpE,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;QAChC,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,CAAC;YAC3B,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;YACpD,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;YAC1B,OAAO,KAAK,GAAG,MAAM,EAAE,CAAC;gBACvB,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAE,CAAC;gBACjC,KAAK,EAAE,CAAC;YACT,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,IAAI,CA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I,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;IAC5D,CAAC;CACD;AAED,MAAa,qBAAsB,SAAQ,kBAAkB;IAC5D;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS;QACf,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QACjC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;CACD;AAVD,sDAUC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IsoBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\nimport {\n\tBlobCore,\n\tMarkerCodes,\n\tMarkerCodesEnd,\n\tMarkerCodesStart,\n\tNodeCore,\n\tcodeToBytesMap,\n\tgetValueSafely,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Buffer class, used to sequentially writ data.\n * Used by tree code to serialize tree into binary representation.\n */\nexport class WriteBuffer {\n\tprotected data?: Uint8Array = new Uint8Array(4096);\n\tprotected index = 0;\n\n\tprotected push(code: number): void {\n\t\tassert(this.data !== undefined, 0x225 /* \"Data should be there\" */);\n\t\tconst length = this.data.length;\n\t\tif (this.index === length) {\n\t\t\tconst newData = new Uint8Array(length * 1.2 + 4096);\n\t\t\tlet index = 0;\n\t\t\tconst oldData = this.data;\n\t\t\twhile (index < length) {\n\t\t\t\tnewData[index] = oldData[index]!;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tthis.data = newData;\n\t\t}\n\t\tthis.data[this.index] = code % 256;\n\t\tthis.index++;\n\t}\n\n\tpublic write(codeArg: number, lengthArg = 1): void {\n\t\tlet code = codeArg;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tthis.push(code % 256);\n\t\t\tcode = Math.floor(code / 256);\n\t\t\tlength--;\n\t\t}\n\t\tassert(code === 0, 0x226 /* Should write complete data */);\n\t}\n\n\tpublic done(): Uint8Array {\n\t\tassert(this.data !== undefined, 0x227 /* \"Data should be there\" */);\n\t\t// We can slice it to have smaller memory representation.\n\t\t// But it will be way more expensive in terms of CPU cycles!\n\t\tconst buffer = this.data.subarray(0, this.index);\n\t\tthis.data = undefined;\n\t\treturn buffer;\n\t}\n}\n\n// This list of maps below is reverse mapping of Marker Codes specified in zipItDataRepresentationUtils.ts file.\n// We can also found them on server filestore code.\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n\n/**\n * This contains mapping of number of bytes representing the corresponding string length to Marker Codes.\n */\nconst utf8StringBytesToCodeMap = {\n\t0: 13,\n\t1: 14,\n\t2: 15,\n\t4: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding length in which actual data(base64 string)\n * will be stored to Marker Codes.\n */\nconst binaryBytesToCodeMap = {\n\t0: 32,\n\t1: 33,\n\t2: 34,\n\t4: 35,\n\t8: 16,\n};\n\n/**\n * This contains mapping of number of bytes representing the corresponding const string id to Marker Codes.\n */\nconst constStringBytesToCodeMap = {\n\t1: 17,\n\t2: 18,\n\t4: 19,\n};\n\n/**\n * This contains mapping of number of bytes to Marker Codes representing the corresponding Integer.\n */\nconst integerBytesToCodeMap = {\n\t0: 1,\n\t1: 3,\n\t2: 5,\n\t4: 7,\n\t8: 9,\n};\n\n/**\n * This contains mapping of boolean to Marker Codes representing the corresponding bool value.\n */\nconst boolToCodeMap = [\n\t12, // false\n\t11, // true\n];\n\n/**\n * Calculate how many bytes are required to encode an integer. This is always power of 2.\n * So if 6 bytes are required to store an integer than it will return 8. 0 is a special case for which we\n * return 0 as it is usually just represented by marker code and we don't store the actual data.\n * @param num - number to encode.\n */\nexport function calcLength(numArg: number): number {\n\tif (numArg === 0) {\n\t\treturn 0;\n\t}\n\tlet num = numArg;\n\tlet lengthLen = 0;\n\twhile (num > 0) {\n\t\tnum = Math.floor(num / 256);\n\t\tlengthLen++;\n\t}\n\tlet res = 1;\n\twhile (res < lengthLen) {\n\t\tres *= 2;\n\t}\n\treturn res;\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param content - string to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeDictionaryString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tdictionary: Map<string, number>,\n): void {\n\tlet id = dictionary.get(content);\n\tlet idLength: number;\n\tif (id === undefined) {\n\t\tconst data = IsoBuffer.from(content, \"utf8\");\n\t\tconst lengthOfDataLen = calcLength(data.length);\n\n\t\tid = dictionary.size + 1;\n\t\tidLength = calcLength(id);\n\t\tdictionary.set(content, id);\n\t\tconst code =\n\t\t\tlengthOfDataLen > 1 || idLength > 1\n\t\t\t\t? MarkerCodes.ConstStringDeclareBig\n\t\t\t\t: MarkerCodes.ConstStringDeclare;\n\t\t// Write marker code for const string.\n\t\tbuffer.write(code);\n\t\tconst bytes = getValueSafely(codeToBytesMap, code);\n\t\tassert(\n\t\t\tbytes >= lengthOfDataLen,\n\t\t\t0x283 /* \"Length of data len should fit in the bytes from the map\" */,\n\t\t);\n\t\tassert(bytes >= idLength, 0x284 /* \"Length of id should fit in the bytes from the map\" */);\n\t\t// Assign and write id for const string.\n\t\tbuffer.write(id, bytes);\n\t\t// Write length of const string.\n\t\tbuffer.write(data.length, bytes);\n\t\t// Write const string data.\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t} else {\n\t\tidLength = calcLength(id);\n\t}\n\t// Write Marker Code\n\tbuffer.write(getValueSafely(constStringBytesToCodeMap, idLength));\n\t// Write id of const string\n\tbuffer.write(id, idLength);\n}\n\nfunction serializeString(\n\tbuffer: WriteBuffer,\n\tcontent: string,\n\tcodeMap = binaryBytesToCodeMap,\n): void {\n\tserializeBlob(buffer, IsoBuffer.from(content, \"utf8\"), utf8StringBytesToCodeMap);\n}\n\n/**\n * Implementation of serialization of blobs in buffer with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param blob - blob to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeBlob(\n\tbuffer: WriteBuffer,\n\tdata: Uint8Array,\n\tcodeMap: Record<number, number> = binaryBytesToCodeMap,\n): void {\n\tconst lengthOfDataLen = calcLength(data.length);\n\t// Write Marker code.\n\tbuffer.write(getValueSafely(codeMap, lengthOfDataLen));\n\t// Write actual data if length greater than 0, otherwise Marker Code is enough.\n\tif (lengthOfDataLen > 0) {\n\t\tbuffer.write(data.length, lengthOfDataLen);\n\t\tfor (const element of data) {\n\t\t\tbuffer.write(element);\n\t\t}\n\t}\n}\n\n/**\n * Implementation of serialization of nodes with Marker Codes etc.\n * @param buffer - Buffer to serialize to.\n * @param nodeCore - Node to be serialized.\n * @param dictionary - Const strings dictionary to be used while serializing.\n */\nfunction serializeNodeCore(\n\tbuffer: WriteBuffer,\n\tnodeCore: NodeCore,\n\tdictionary: Map<string, number>,\n): void {\n\tfor (const child of nodeCore.nodes) {\n\t\tif (child instanceof NodeCore) {\n\t\t\t// For a tree node start and end with set/list start and end marker codes.\n\t\t\tconst startCode = MarkerCodesStart[child.type];\n\t\t\tconst endCode = MarkerCodesEnd[child.type];\n\t\t\tassert(startCode !== undefined, 0x285 /* \"Start code should not undefined\" */);\n\t\t\tassert(endCode !== undefined, 0x286 /* \"End code should not undefined\" */);\n\t\t\tbuffer.write(startCode);\n\t\t\tserializeNodeCore(buffer, child, dictionary);\n\t\t\tbuffer.write(endCode);\n\t\t} else if (child instanceof BlobCore) {\n\t\t\tserializeBlob(buffer, child.buffer);\n\t\t} else if (typeof child === \"number\") {\n\t\t\t// Calculate length in which integer will be stored\n\t\t\tconst len = calcLength(child);\n\t\t\t// Write corresponding Marker code for length of integer.\n\t\t\tbuffer.write(getValueSafely(integerBytesToCodeMap, len));\n\t\t\t// Write actual number if greater than 0, otherwise Marker Code is enough.\n\t\t\tif (len > 0) {\n\t\t\t\tbuffer.write(child, len);\n\t\t\t}\n\t\t} else if (typeof child === \"boolean\") {\n\t\t\tbuffer.write(boolToCodeMap[child ? 1 : 0]);\n\t\t} else {\n\t\t\tassert(child._stringElement, 0x3dd /* Unsupported node type */);\n\t\t\tif (child.dictionary) {\n\t\t\t\tserializeDictionaryString(buffer, child.content, dictionary);\n\t\t\t} else {\n\t\t\t\tserializeString(buffer, child.content);\n\t\t\t}\n\t\t}\n\t}\n}\n\nclass NodeCoreSerializer extends NodeCore {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(buffer: WriteBuffer): void {\n\t\tserializeNodeCore(buffer, this, new Map<string, number>());\n\t}\n}\n\nexport class TreeBuilderSerializer extends NodeCoreSerializer {\n\tconstructor() {\n\t\tsuper();\n\t}\n\n\tpublic serialize(): Uint8Array {\n\t\tconst buffer = new WriteBuffer();\n\t\tsuper.serialize(buffer);\n\t\treturn buffer.done();\n\t}\n}\n"]}
@@ -41,7 +41,7 @@ function readBlobSection(node) {
41
41
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(blob);
42
42
  (0, zipItDataRepresentationUtils_js_1.assertBlobCoreInstance)(records.data, "data should be of BlobCore type");
43
43
  const id = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.id, "blob id should be string");
44
- blobContents.set(id, records.data?.arrayBuffer);
44
+ blobContents.set(id, records.data.arrayBuffer);
45
45
  }
46
46
  }
47
47
  return { blobContents, slowBlobStructureCount };
@@ -56,14 +56,14 @@ function readOpsSection(node) {
56
56
  const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(node);
57
57
  (0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.firstSequenceNumber, "Seq number should be a number");
58
58
  (0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(records.deltas, "Deltas should be a Node");
59
- for (let i = 0; i < records.deltas?.length; ++i) {
59
+ for (let i = 0; i < records.deltas.length; ++i) {
60
60
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
61
- ops.push(JSON.parse(records.deltas?.getString(i)));
61
+ ops.push(JSON.parse(records.deltas.getString(i)));
62
62
  }
63
63
  // Due to a bug at service side, in an edge case service was serializing deltas even
64
64
  // when there are no ops. So just make the code resilient to that bug. Service has also
65
65
  // fixed that bug.
66
- (0, internal_1.assert)(ops.length === 0 || records.firstSequenceNumber?.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
66
+ (0, internal_1.assert)(ops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber, 0x280 /* "Validate first op seq number" */);
67
67
  return ops;
68
68
  }
69
69
  /**
@@ -186,7 +186,7 @@ function readSnapshotSection(node) {
186
186
  (0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.sequenceNumber, "sequenceNumber should be of type number");
187
187
  const { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } = readTreeSection(records.treeNodes);
188
188
  snapshotTree.id = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.id, "snapshotId should be string");
189
- const sequenceNumber = records.sequenceNumber?.valueOf();
189
+ const sequenceNumber = records.sequenceNumber.valueOf();
190
190
  return {
191
191
  sequenceNumber,
192
192
  snapshotTree,
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAQ7D,6DAAkD;AAClD,iDAAyC;AACzC,uFAU2C;AAE9B,QAAA,sBAAsB,GAAG,KAAK,CAAC;AAC/B,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAWxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IAIvC,IAAA,wDAAsB,EAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,MAAM,YAAY,GAA6B,IAAI,GAAG,EAAE,CAAC;IACzD,KAA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I,MAAM,CAAC,UAAU,CAAC,8BAAsB,CAAC,EAClE,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,IAAA,iBAAM,EACL,0BAAkB,KAAK,EAAE,EACzB,KAAK,CAAC,4DAA4D,CAClE,CAAC;IAEF,MAAM,CAAC,QAAQ,EAAE,oBAAoB,CAAC,GAAG,IAAA,sBAAO,EAAC,GAAG,EAAE,CACrD,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CACrC,CAAC;IACF,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,IAAA,sBAAO,EAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,OAAO;QACN,GAAG,QAAQ;QACX,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;QACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG;QACjC,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE;YACf,GAAG,cAAc;YACjB,oBAAoB;YACpB,aAAa;YACb,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,sBAAsB,EAAE,YAAY,CAAC,sBAAsB;YAC3D,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;SACrE;KACD,CAAC;AACH,CAAC;AAjDD,oEAiDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\tassertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n\t\t\tconst id = getStringInstance(records.id, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data?.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\tassertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n\tassertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas?.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas?.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\tops.length === 0 || records.firstSequenceNumber?.valueOf() === ops[0].sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\tconst path = getStringInstance(records.name, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\ttrees[path].groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\tassertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n\tassertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\tsnapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber?.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\tconst mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n\tconst cv = getStringInstance(records.cv, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\treadSnapshotSection(records.snapshot),\n\t);\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
1
+ {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAQ7D,6DAAkD;AAClD,iDAAyC;AACzC,uFAU2C;AAE9B,QAAA,sBAAsB,GAAG,KAAK,CAAC;AAC/B,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAWxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IAIvC,IAAA,wDAAsB,EAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,MAAM,YAAY,GAA6B,IAAI,GAAG,EAAE,CAAC;IACzD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,IAAA,wDAAsB,EAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEpD;;;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kB,KAAK,EAAE,EACzB,KAAK,CAAC,4DAA4D,CAClE,CAAC;IAEF,MAAM,CAAC,QAAQ,EAAE,oBAAoB,CAAC,GAAG,IAAA,sBAAO,EAAC,GAAG,EAAE,CACrD,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,CACrC,CAAC;IACF,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,IAAA,sBAAO,EAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAEpF,OAAO;QACN,GAAG,QAAQ;QACX,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC;QACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG;QACjC,eAAe,EAAE,CAAC;QAClB,cAAc,EAAE;YACf,GAAG,cAAc;YACjB,oBAAoB;YACpB,aAAa;YACb,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;YACvD,sBAAsB,EAAE,YAAY,CAAC,sBAAsB;YAC3D,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;SACrE;KACD,CAAC;AACH,CAAC;AAjDD,oEAiDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ReadBuffer } from \"./ReadBufferUtils.js\";\nimport { measure } from \"./odspUtils.js\";\nimport {\n\tNodeCore,\n\tNodeTypes,\n\tTreeBuilder,\n\tassertBlobCoreInstance,\n\tassertBoolInstance,\n\tassertNodeCoreInstance,\n\tassertNumberInstance,\n\tgetNodeProps,\n\tgetStringInstance,\n} from \"./zipItDataRepresentationUtils.js\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\n/**\n * The parsing is significantly faster if the position of props is well known instead of dynamic. So these variables\n * represents how many times slower parsing path is executed. This will be then logged into telemetry.\n * @internal\n */\nexport interface ISnapshotContentsWithProps extends ISnapshot {\n\ttelemetryProps: Record<string, number>;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes): {\n\tblobContents: Map<string, ArrayBuffer>;\n\tslowBlobStructureCount: number;\n} {\n\tassertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n\tlet slowBlobStructureCount = 0;\n\tconst blobContents: Map<string, ArrayBuffer> = new Map();\n\tfor (const blob of node) {\n\t\tassertNodeCoreInstance(blob, \"blob should be node\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tif (\n\t\t\tblob.length === 4 &&\n\t\t\tblob.getMaybeString(0) === \"id\" &&\n\t\t\tblob.getMaybeString(2) === \"data\"\n\t\t) {\n\t\t\t// \"id\": <node name>\n\t\t\t// \"data\": <blob>\n\t\t\tblobContents.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n\t\t} else {\n\t\t\t/**\n\t\t\t * More generalized workflow\n\t\t\t */\n\t\t\tslowBlobStructureCount += 1;\n\t\t\tconst records = getNodeProps(blob);\n\t\t\tassertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n\t\t\tconst id = getStringInstance(records.id, \"blob id should be string\");\n\t\t\tblobContents.set(id, records.data.arrayBuffer);\n\t\t}\n\t}\n\treturn { blobContents, slowBlobStructureCount };\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes): ISequencedDocumentMessage[] {\n\tassertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n\tconst ops: ISequencedDocumentMessage[] = [];\n\tconst records = getNodeProps(node);\n\tassertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n\tassertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n\tfor (let i = 0; i < records.deltas.length; ++i) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\tops.push(JSON.parse(records.deltas.getString(i)));\n\t}\n\t// Due to a bug at service side, in an edge case service was serializing deltas even\n\t// when there are no ops. So just make the code resilient to that bug. Service has also\n\t// fixed that bug.\n\tassert(\n\t\tops.length === 0 || records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n\t\t0x280 /* \"Validate first op seq number\" */,\n\t);\n\treturn ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore): {\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tlet slowTreeStructureCount = 0;\n\tlet treeStructureCountWithGroupId = 0;\n\tconst trees: Record<string, ISnapshotTree> = {};\n\tconst snapshotTree: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees,\n\t};\n\tfor (const treeNode of node) {\n\t\tassertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n\t\t/**\n\t\t * Perf optimization - the most common cases!\n\t\t * This is essentially unrolling code below for faster processing\n\t\t * It speeds up tree parsing by 2-3x times!\n\t\t */\n\t\tconst length = treeNode.length;\n\t\tif (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n\t\t\tswitch (length) {\n\t\t\t\tcase 2: {\n\t\t\t\t\t// empty tree case\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\ttrees[treeNode.getString(1)] = { blobs: {}, trees: {} };\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase 4: {\n\t\t\t\t\tconst content = treeNode.getMaybeString(2);\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (content === \"children\") {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(3));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (content === \"value\") {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 6: {\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"nodeType\": 3\n\t\t\t\t\t// \"value\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"nodeType\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"value\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tsnapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// \"name\": <node name>\n\t\t\t\t\t// \"unreferenced\": true\n\t\t\t\t\t// \"children\": <blob id>\n\t\t\t\t\tif (\n\t\t\t\t\t\ttreeNode.getMaybeString(2) === \"unreferenced\" &&\n\t\t\t\t\t\ttreeNode.getMaybeString(4) === \"children\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst result = readTreeSection(treeNode.getNode(5));\n\t\t\t\t\t\ttrees[treeNode.getString(1)] = result.snapshotTree;\n\t\t\t\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\t\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t\t\t\t\tassert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n\t\t\t\t\t\tsnapshotTree.unreferenced = true;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/**\n\t\t * More generalized workflow\n\t\t */\n\t\tslowTreeStructureCount++;\n\t\tconst records = getNodeProps(treeNode);\n\n\t\tif (records.unreferenced !== undefined) {\n\t\t\tassertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n\t\t\tassert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n\t\t\tsnapshotTree.unreferenced = true;\n\t\t}\n\n\t\tconst path = getStringInstance(records.name, \"Path name should be string\");\n\t\tif (records.value !== undefined) {\n\t\t\tsnapshotTree.blobs[path] = getStringInstance(\n\t\t\t\trecords.value,\n\t\t\t\t\"Blob value should be string\",\n\t\t\t);\n\t\t\t// eslint-disable-next-line unicorn/no-negated-condition\n\t\t} else if (records.children !== undefined) {\n\t\t\tassertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n\t\t\tconst result = readTreeSection(records.children);\n\t\t\ttrees[path] = result.snapshotTree;\n\t\t\tif (records.groupId !== undefined) {\n\t\t\t\tconst groupId = getStringInstance(records.groupId, \"groupId should be a string\");\n\t\t\t\ttrees[path].groupId = groupId;\n\t\t\t\ttreeStructureCountWithGroupId++;\n\t\t\t}\n\t\t\tslowTreeStructureCount += result.slowTreeStructureCount;\n\t\t\ttreeStructureCountWithGroupId += result.treeStructureCountWithGroupId;\n\t\t} else {\n\t\t\ttrees[path] = { blobs: {}, trees: {} };\n\t\t}\n\t}\n\treturn { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId };\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): {\n\tsequenceNumber: number;\n\tsnapshotTree: ISnapshotTree;\n\tslowTreeStructureCount: number;\n\ttreeStructureCountWithGroupId: number;\n} {\n\tassertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n\tconst records = getNodeProps(node);\n\n\tassertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n\tassertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\tsnapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n\tconst sequenceNumber = records.sequenceNumber.valueOf();\n\treturn {\n\t\tsequenceNumber,\n\t\tsnapshotTree,\n\t\tslowTreeStructureCount,\n\t\ttreeStructureCountWithGroupId,\n\t};\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns Tree, blobs and ops from the snapshot.\n * @internal\n */\nexport function parseCompactSnapshotResponse(\n\tbuffer: Uint8Array,\n\tlogger: ITelemetryLoggerExt,\n): ISnapshotContentsWithProps {\n\tconst { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n\tassert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n\tconst root = builder.getNode(0);\n\n\tconst records = getNodeProps(root);\n\n\tconst mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n\tconst cv = getStringInstance(records.cv, \"createVersion should be string\");\n\tif (records.lsn !== undefined) {\n\t\tassertNumberInstance(records.lsn, \"lsn should be a number\");\n\t}\n\n\tassert(\n\t\tNumber.parseFloat(snapshotMinReadVersion) >= Number.parseFloat(mrv),\n\t\t0x20f /* \"Driver min read version should >= to server minReadVersion\" */,\n\t);\n\tassert(\n\t\tNumber.parseFloat(cv) >= Number.parseFloat(snapshotMinReadVersion),\n\t\t0x210 /* \"Snapshot should be created with minReadVersion or above\" */,\n\t);\n\tassert(\n\t\tcurrentReadVersion === cv,\n\t\t0x2c2 /* \"Create Version should be equal to currentReadVersion\" */,\n\t);\n\n\tconst [snapshot, durationSnapshotTree] = measure(() =>\n\t\treadSnapshotSection(records.snapshot),\n\t);\n\tconst [blobContents, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n\treturn {\n\t\t...snapshot,\n\t\tblobContents: blobContents.blobContents,\n\t\tops: records.deltas === undefined ? [] : readOpsSection(records.deltas),\n\t\tlatestSequenceNumber: records.lsn,\n\t\tsnapshotFormatV: 1,\n\t\ttelemetryProps: {\n\t\t\t...telemetryProps,\n\t\t\tdurationSnapshotTree,\n\t\t\tdurationBlobs,\n\t\t\tslowTreeStructureCount: snapshot.slowTreeStructureCount,\n\t\t\tslowBlobStructureCount: blobContents.slowBlobStructureCount,\n\t\t\ttreeStructureCountWithGroupId: snapshot.treeStructureCountWithGroupId,\n\t\t},\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAUvF,OAAO,EAEN,gBAAgB,EAChB,gBAAgB,EAChB,+BAA+B,EAE/B,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,mBAAmB,EAKnB,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACN,aAAa,EAEb,wBAAwB,EAExB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAKjD,OAAO,EACN,aAAa,EASb,KAAK,mBAAmB,EACxB,MAAM,gBAAgB,CAAC;AAGxB;;;;GAIG;AACH,oBAAY,yBAAyB;IACpC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,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AAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CASnE;AAiBD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACrC,eAAe,EAAE,gBAAgB,EACjC,aAAa,EAAE,+BAA+B,EAC9C,iBAAiB,EAAE,mBAAmB,EACtC,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,EACrC,eAAe,EAAE,gBAAgB,GAAG,SAAS,EAC7C,uBAAuB,CAAC,EAAE,yBAAyB,EACnD,UAAU,CAAC,EAAE,eAAe,EAC5B,YAAY,CAAC,EAAE,YAAY,EAC3B,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,kCAAkC,CAAC,CAsE7C"}
@@ -68,7 +68,7 @@ async function fetchSnapshotWithRedeem(odspResolvedUrl, storageTokenFetcher, sna
68
68
  // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
69
69
  if (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {
70
70
  // Execute the redeem fallback
71
- await redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger, forceAccessTokenViaAuthorizationHeader);
71
+ await redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger);
72
72
  const odspResolvedUrlWithoutShareLink = {
73
73
  ...odspResolvedUrl,
74
74
  shareLinkInfo: {
@@ -107,7 +107,7 @@ async function fetchSnapshotWithRedeem(odspResolvedUrl, storageTokenFetcher, sna
107
107
  });
108
108
  }
109
109
  exports.fetchSnapshotWithRedeem = fetchSnapshotWithRedeem;
110
- async function redeemSharingLink(odspResolvedUrl, getAuthHeader, logger, forceAccessTokenViaAuthorizationHeader) {
110
+ async function redeemSharingLink(odspResolvedUrl, getAuthHeader, logger) {
111
111
  await internal_6.PerformanceEvent.timedExecAsync(logger, {
112
112
  eventName: "RedeemShareLink",
113
113
  }, async () => {
@@ -116,7 +116,12 @@ async function redeemSharingLink(odspResolvedUrl, getAuthHeader, logger, forceAc
116
116
  let redeemUrl;
117
117
  async function callSharesAPI(baseUrl) {
118
118
  await (0, odspUtils_js_1.getWithRetryForTokenRefresh)(async (tokenFetchOptions) => {
119
- redeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}`;
119
+ // IMPORTANT: Note that redeemUrl has '/driveItem' in it. Technically it is not required for executing redeem operation.
120
+ // However, we have other cases that use '/shares' API and do require to specify '/driveItem' in order to get specific
121
+ // drive item properties. The reason this matters is when caller of this API must possess logical permissions to call
122
+ // this API (for instance, this will be the case when call is made with app-only token) then two separate logical
123
+ // permissions are needed for the '/shares' call with and without '/driveItem'.
124
+ redeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}/driveItem`;
120
125
  const url = redeemUrl;
121
126
  const method = "GET";
122
127
  const authHeader = await getAuthHeader({ ...tokenFetchOptions, request: { url, method } }, "RedeemShareLink");
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAChE,kEAA6D;AAC7D,mEAAkE;AAElE,oEAI+C;AAC/C,yEAGoD;AACpD,+EAM0D;AAC1D,uEAMkD;AAClD,+BAAkC;AAElC,yEAIoC;AACpC,iDAKwB;AAExB,2DAAqD;AACrD,+EAAmE;AACnE,mEAAoF;AACpF,yDAAiE;AACjE,iDAWwB;AACxB,2DAAiD;AAEjD;;;;GAIG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB,EACnB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAAoE;IAEpE,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC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CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,EAAE,KAAK,CAC9C,GAAG,EACH,YAAY,EACZ,aAAa,EACb,IAAI,EACJ,YAAY,CACZ,IAAI,IAAA,0BAAW,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAErC,OAAO;QACN,YAAY;QACZ,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,GAAG;KACf,CAAC;AACH,CAAC;AAhFD,4CAgFC;AAED,SAAS,wBAAwB,CAChC,eAAiC,EACjC,KAA0B;IAE1B,IACC,eAAe,CAAC,aAAa,EAAE,mBAAmB,KAAK,SAAS;QAChE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,kBAAkB;YACrD,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,+BAA+B,CAAC,EACnE,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData } from \"@fluidframework/driver-base/internal\";\nimport { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tDriverErrorTelemetryProps,\n\tNonRetryableError,\n\tisRuntimeMessage,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\ttype IOdspError,\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tISnapshotContentsWithProps,\n\tcurrentReadVersion,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport { checkForKnownServerFarmType } from \"./odspUrlHelper.js\";\nimport {\n\tIOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @legacy\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - Deprecated and not used, true value always used instead. Whether to force passing given token via authorization header\n * @param snapshotDownloader - Implementation of the get/post methods used to fetch the snapshot. snapshotDownloader is responsible for generating the appropriate headers (including Authorization header) as well as handling any token refreshes before retrying.\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (url: string) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}${path}${queryString}`;\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t},\n\t\tasync () => snapshotDownloader(url),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\n\t\t\t\tawait redeemSharingLink(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<void> {\n\tawait PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () => {\n\t\t\tassert(\n\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t);\n\n\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t);\n\n\t\t\tlet redeemUrl: string | undefined;\n\t\t\tasync function callSharesAPI(baseUrl: string): Promise<void> {\n\t\t\t\tawait getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\t\tredeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n\t\t\t\t\tconst url = redeemUrl;\n\t\t\t\t\tconst method = \"GET\";\n\t\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t\t);\n\t\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\t\tawait fetchAndParseAsJSONHelper(url, { headers, method });\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst disableUsingTenantDomain = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\t\"Fluid.Driver.Odsp.DisableUsingTenantDomainForSharesApi\",\n\t\t\t);\n\t\t\t// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)\n\t\t\t// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So, first\n\t\t\t// construct the url for /shares using tenant domain but to be on safer side, fallback to using the siteUrl. We get tenant domain\n\t\t\t// by getting origin of the siteUrl.\n\t\t\tif (!disableUsingTenantDomain) {\n\t\t\t\ttry {\n\t\t\t\t\tawait callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);\n\t\t\t\t\treturn;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"ShareLinkRedeemFailedWithTenantDomain\",\n\t\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\t\tlength: redeemUrl?.length,\n\t\t\t\t\t\t\t\tshareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,\n\t\t\t\t\t\t\t\tqueryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem)\n\t\t\t\t\t\t\t\t\t.search.length,\n\t\t\t\t\t\t\t\tuseHeaders: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait callSharesAPI(odspResolvedUrl.siteUrl);\n\t\t},\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst internalFarmType = checkForKnownServerFarmType(odspResolvedUrl.siteUrl);\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t\tdetails: {\n\t\t\t\tinternalFarmType,\n\t\t\t},\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.text()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.length === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.arrayBuffer()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.byteLength === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tconst treeStructureCountWithGroupId = props.treeStructureCountWithGroupId ?? 0;\n\t\t\t\t\t\t// As trees with groupId go through normal parsing, so exclude them.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tslowTreeParseCodePaths - treeStructureCountWithGroupId > 10 ||\n\t\t\t\t\t\t\tslowBlobParseCodePaths > 10\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t\ttreeStructureCountWithGroupId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\t// trees, leafTrees, blobNodes, encodedBlobsSize,\n\t\t\t\t// blobNodes - blobs tells us (roughly) how many blobs are deduped by service.\n\t\t\t\t...getTreeStats(snapshot),\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tauthHeader: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: ${authHeader}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\ninterface ITreeStats {\n\ttrees: number;\n\tleafTrees: number;\n\tblobNodes: number;\n}\n\nexport function getTreeStats(snapshot: ISnapshot): ITreeStats & { encodedBlobsSize: number } {\n\tconst stats: ITreeStats = {\n\t\ttrees: 0,\n\t\tleafTrees: 0,\n\t\tblobNodes: 0,\n\t};\n\tgetTreeStatsCore(snapshot.snapshotTree, stats);\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { ...stats, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction getTreeStatsCore(snapshotTree: ISnapshotTree, stats: ITreeStats): void {\n\tstats.blobNodes += Object.entries(snapshotTree.blobs).length;\n\tstats.trees++;\n\n\tconst entries = Object.entries(snapshotTree.trees);\n\tif (entries.length === 0) {\n\t\tstats.leafTrees++;\n\t} else {\n\t\tfor (const [_, tree] of entries) {\n\t\t\tstats.trees++;\n\t\t\tgetTreeStatsCore(tree, stats);\n\t\t}\n\t}\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\ttokenFetchOptions: TokenFetchOptionsEx,\n\tloadingGroupIds: string[] | undefined,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\tcontroller?: AbortController,\n\tepochTracker?: EpochTracker,\n\tscenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\tif (snapshotOptions !== undefined) {\n\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t// Exclude \"timeout\" from query string\n\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\tqueryParams[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (loadingGroupIds !== undefined) {\n\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\tconst method = \"POST\";\n\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\tconst header = { prefer: \"manualredirect\" };\n\tconst authHeader = await getAuthHeader(\n\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\"downloadSnapshot\",\n\t);\n\tassert(authHeader !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, authHeader, header);\n\tconst fetchOptions = {\n\t\tbody,\n\t\theaders,\n\t\tsignal: controller?.signal,\n\t\tmethod,\n\t};\n\t// Decide what snapshot format to fetch as per the feature gate.\n\tswitch (snapshotFormatFetchType) {\n\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t}\n\t}\n\n\tconst odspResponse = await (epochTracker?.fetch(\n\t\turl,\n\t\tfetchOptions,\n\t\t\"treesLatest\",\n\t\ttrue,\n\t\tscenarioName,\n\t) ?? fetchHelper(url, fetchOptions));\n\n\treturn {\n\t\todspResponse,\n\t\trequestHeaders: headers,\n\t\trequestUrl: url,\n\t};\n}\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
1
+ {"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAgE;AAChE,kEAA6D;AAC7D,mEAAkE;AAElE,oEAI+C;AAC/C,yEAGoD;AACpD,+EAM0D;AAC1D,uEAMkD;AAClD,+BAAkC;AAElC,yEAIoC;AACpC,iDAKwB;AAExB,2DAAqD;AACrD,+EAAmE;AACnE,mEAAoF;AACpF,yDAAiE;AACjE,iDAWwB;AACxB,2DAAiD;AAEjD;;;;GAIG;AACH,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACpC,yEAAQ,CAAA;IACR,6EAAU,CAAA;IACV,2FAAiB,CAAA;AAClB,CAAC,EAJW,yBAAyB,yCAAzB,yBAAyB,QAIpC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,aAAa,CAClC,WAAmB,EACnB,SAAiB,EACjB,iBAA0B,EAC1B,sCAA+C,EAC/C,MAA2B,EAC3B,kBAAoE;IAEpE,MAAM,IAAI,GAAG,UAAU,SAAS,EAAE,CAAC;IACnC,IAAI,WAAW,GAAqB,EAAE,CAAC;IAEvC,IAAI,iBAAiB,EAAE,CAAC;QACvB,WAAW,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAC/E,CAAC;IAED,MAAM,WAAW,GAAG,IAAA,kCAAc,EAAC,WAAW,CAAC,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,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,GAAG;KACf,CAAC;AACH,CAAC;AAhFD,4CAgFC;AAED,SAAS,wBAAwB,CAChC,eAAiC,EACjC,KAA0B;IAE1B,IACC,eAAe,CAAC,aAAa,EAAE,mBAAmB,KAAK,SAAS;QAChE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,kBAAkB;YACrD,KAAK,CAAC,SAAS,KAAK,yBAAc,CAAC,+BAA+B,CAAC,EACnE,CAAC;QACF,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,IAAA,+BAAgB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { getW3CData } from \"@fluidframework/driver-base/internal\";\nimport { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tDriverErrorTelemetryProps,\n\tNonRetryableError,\n\tisRuntimeMessage,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\ttype IOdspError,\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tISnapshotContentsWithProps,\n\tcurrentReadVersion,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser.js\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { getQueryString } from \"./getQueryString.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser.js\";\nimport { checkForKnownServerFarmType } from \"./odspUrlHelper.js\";\nimport {\n\tIOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tisSnapshotFetchForLoadingGroup,\n\tmeasure,\n\tmeasureP,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @legacy\n * @alpha\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - Deprecated and not used, true value always used instead. Whether to force passing given token via authorization header\n * @param snapshotDownloader - Implementation of the get/post methods used to fetch the snapshot. snapshotDownloader is responsible for generating the appropriate headers (including Authorization header) as well as handling any token refreshes before retrying.\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (url: string) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshot> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId === \"latest\" ? { deltas: 1, blobs: 2 } : { blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}${path}${queryString}`;\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t},\n\t\tasync () => snapshotDownloader(url),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tloadingGroupIds,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\t\t\t\tawait redeemSharingLink(odspResolvedUrl, storageTokenFetcher, logger);\n\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.errorType === OdspErrorTypes.authorizationError) ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n): Promise<void> {\n\tawait PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () => {\n\t\t\tassert(\n\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t);\n\n\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t);\n\n\t\t\tlet redeemUrl: string | undefined;\n\t\t\tasync function callSharesAPI(baseUrl: string): Promise<void> {\n\t\t\t\tawait getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\t\t// IMPORTANT: Note that redeemUrl has '/driveItem' in it. Technically it is not required for executing redeem operation.\n\t\t\t\t\t// However, we have other cases that use '/shares' API and do require to specify '/driveItem' in order to get specific\n\t\t\t\t\t// drive item properties. The reason this matters is when caller of this API must possess logical permissions to call\n\t\t\t\t\t// this API (for instance, this will be the case when call is made with app-only token) then two separate logical\n\t\t\t\t\t// permissions are needed for the '/shares' call with and without '/driveItem'.\n\t\t\t\t\tredeemUrl = `${baseUrl}/_api/v2.0/shares/${encodedShareUrl}/driveItem`;\n\t\t\t\t\tconst url = redeemUrl;\n\t\t\t\t\tconst method = \"GET\";\n\t\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t\t);\n\t\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\t\tawait fetchAndParseAsJSONHelper(url, { headers, method });\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst disableUsingTenantDomain = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\t\"Fluid.Driver.Odsp.DisableUsingTenantDomainForSharesApi\",\n\t\t\t);\n\t\t\t// There is an issue where if we use the siteUrl in /shares, then the allowed length of url is just a few hundred characters(300-400)\n\t\t\t// and we fail to do the redeem. But if we use the tenant domain in the url, then the allowed length becomes 2048. So, first\n\t\t\t// construct the url for /shares using tenant domain but to be on safer side, fallback to using the siteUrl. We get tenant domain\n\t\t\t// by getting origin of the siteUrl.\n\t\t\tif (!disableUsingTenantDomain) {\n\t\t\t\ttry {\n\t\t\t\t\tawait callSharesAPI(new URL(odspResolvedUrl.siteUrl).origin);\n\t\t\t\t\treturn;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"ShareLinkRedeemFailedWithTenantDomain\",\n\t\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\t\tlength: redeemUrl?.length,\n\t\t\t\t\t\t\t\tshareLinkUrlLength: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem.length,\n\t\t\t\t\t\t\t\tqueryParamsLength: new URL(odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem)\n\t\t\t\t\t\t\t\t\t.search.length,\n\t\t\t\t\t\t\t\tuseHeaders: true,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tawait callSharesAPI(odspResolvedUrl.siteUrl);\n\t\t},\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tloadingGroupIds: string[] | undefined,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshot> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst fetchSnapshotForLoadingGroup = isSnapshotFetchForLoadingGroup(loadingGroupIds);\n\t\tconst eventName = fetchSnapshotForLoadingGroup ? \"TreesLatestForGroup\" : \"TreesLatest\";\n\t\tconst internalFarmType = checkForKnownServerFarmType(odspResolvedUrl.siteUrl);\n\n\t\tconst perfEvent = {\n\t\t\teventName,\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t\tdetails: {\n\t\t\t\tinternalFarmType,\n\t\t\t},\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tcontroller,\n\t\t\t\t),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.text()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.length === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshot =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content\n\t\t\t\t\t\t\t\t.arrayBuffer()\n\t\t\t\t\t\t\t\t.then((res) => {\n\t\t\t\t\t\t\t\t\tif (res.byteLength === 0) {\n\t\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\t\"Response from browser is empty\",\n\t\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\treturn res;\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t.catch((error) =>\n\t\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tconst treeStructureCountWithGroupId = props.treeStructureCountWithGroupId ?? 0;\n\t\t\t\t\t\t// As trees with groupId go through normal parsing, so exclude them.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tslowTreeParseCodePaths - treeStructureCountWithGroupId > 10 ||\n\t\t\t\t\t\t\tslowBlobParseCodePaths > 10\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t\ttreeStructureCountWithGroupId,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault: {\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header. Only cache snapshot if it is not for a loading group.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\" &&\n\t\t\t\t!fetchSnapshotForLoadingGroup;\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(fluidEpoch !== undefined, 0x1e6 /* \"Epoch should be present in response\" */);\n\t\t\t\tconst value: ISnapshotCachedEntry2 = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\t// trees, leafTrees, blobNodes, encodedBlobsSize,\n\t\t\t\t// blobNodes - blobs tells us (roughly) how many blobs are deduped by service.\n\t\t\t\t...getTreeStats(snapshot),\n\t\t\t\tblobs: snapshot.blobContents?.size ?? 0,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tfetchSnapshotForLoadingGroup,\n\t\t\t\tuseLegacyFlowWithoutGroups:\n\t\t\t\t\tuseLegacyFlowWithoutGroupsForSnapshotFetch(loadingGroupIds),\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t((error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchFailure ||\n\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.fetchTimeout)\n\t\t\t) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: string };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tauthHeader: string,\n\theaders?: { [index: string]: string },\n): {\n\tbody: string;\n\theaders: {\n\t\t[index: string]: string;\n\t};\n} {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(\n\t\t`--${formBoundary}`,\n\t\t`Authorization: ${authHeader}`,\n\t\t`X-HTTP-Method-Override: GET`,\n\t);\n\n\tif (headers !== undefined) {\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`, `\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: string } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\ninterface ITreeStats {\n\ttrees: number;\n\tleafTrees: number;\n\tblobNodes: number;\n}\n\nexport function getTreeStats(snapshot: ISnapshot): ITreeStats & { encodedBlobsSize: number } {\n\tconst stats: ITreeStats = {\n\t\ttrees: 0,\n\t\tleafTrees: 0,\n\t\tblobNodes: 0,\n\t};\n\tgetTreeStatsCore(snapshot.snapshotTree, stats);\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobContents) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { ...stats, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot): void {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction getTreeStatsCore(snapshotTree: ISnapshotTree, stats: ITreeStats): void {\n\tstats.blobNodes += Object.entries(snapshotTree.blobs).length;\n\tstats.trees++;\n\n\tconst entries = Object.entries(snapshotTree.trees);\n\tif (entries.length === 0) {\n\t\tstats.leafTrees++;\n\t} else {\n\t\tfor (const [_, tree] of entries) {\n\t\t\tstats.trees++;\n\t\t\tgetTreeStatsCore(tree, stats);\n\t\t}\n\t}\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param loadingGroupIds - loadingGroupIds for which snapshot needs to be downloaded. Note:\n * 1.) If undefined, then legacy trees latest call will be used where no groupId query param would be specified.\n * 2.) If [] is passed, then snapshot with all ungrouped data will be fetched.\n * 3.) If any groupId is specified like [\"g1\"], then snapshot for g1 group will be fetched.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\ttokenFetchOptions: TokenFetchOptionsEx,\n\tloadingGroupIds: string[] | undefined,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\tcontroller?: AbortController,\n\tepochTracker?: EpochTracker,\n\tscenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\tconst queryParams: Record<string, unknown> = { ump: 1 };\n\tif (snapshotOptions !== undefined) {\n\t\tfor (const [key, value] of Object.entries(snapshotOptions)) {\n\t\t\t// Exclude \"timeout\" from query string\n\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\tqueryParams[key] = value;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (loadingGroupIds !== undefined) {\n\t\tqueryParams.groupId = loadingGroupIds.join(\",\");\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\tconst method = \"POST\";\n\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t// for further reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\tconst header = { prefer: \"manualredirect\" };\n\tconst authHeader = await getAuthHeader(\n\t\t{ ...tokenFetchOptions, request: { url, method } },\n\t\t\"downloadSnapshot\",\n\t);\n\tassert(authHeader !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, authHeader, header);\n\tconst fetchOptions = {\n\t\tbody,\n\t\theaders,\n\t\tsignal: controller?.signal,\n\t\tmethod,\n\t};\n\t// Decide what snapshot format to fetch as per the feature gate.\n\tswitch (snapshotFormatFetchType) {\n\t\tcase SnapshotFormatSupportType.Binary: {\n\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t\t}\n\t}\n\n\tconst odspResponse = await (epochTracker?.fetch(\n\t\turl,\n\t\tfetchOptions,\n\t\t\"treesLatest\",\n\t\ttrue,\n\t\tscenarioName,\n\t) ?? fetchHelper(url, fetchOptions));\n\n\treturn {\n\t\todspResponse,\n\t\trequestHeaders: headers,\n\t\trequestUrl: url,\n\t};\n}\n\nfunction isRedeemSharingLinkError(\n\todspResolvedUrl: IOdspResolvedUrl,\n\terror: Partial<IOdspError>,\n): boolean {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === OdspErrorTypes.authorizationError ||\n\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
@@ -67,7 +67,7 @@ async function getFileLink(getToken, resolvedUrl, logger) {
67
67
  }
68
68
  exports.getFileLink = getFileLink;
69
69
  /**
70
- * Handles location redirection while fulfilling the getFilelink call. We don't want browser to handle
70
+ * Handles location redirection while fulfilling the getFileLink call. We don't want browser to handle
71
71
  * the redirection as the browser will retry with same auth token which will not work as we need app
72
72
  * to regenerate tokens for the new site domain. So when we will make the network calls below we will set
73
73
  * the redirect:manual header to manually handle these redirects.
@@ -86,7 +86,7 @@ async function getFileLinkWithLocationRedirectionHandling(getToken, resolvedUrl,
86
86
  let locationRedirected = false;
87
87
  for (let count = 1; count <= 5; count++) {
88
88
  try {
89
- const fileItem = await getFileItemLite(getToken, resolvedUrl, logger, true);
89
+ const fileItem = await getFileItemLite(getToken, resolvedUrl, logger);
90
90
  // Sometimes the siteUrl in the actual file is different from the siteUrl in the resolvedUrl due to location
91
91
  // redirection. This creates issues in the getSharingInformation call. So we need to update the siteUrl in the
92
92
  // resolvedUrl to the siteUrl in the fileItem which is the updated siteUrl.
@@ -165,7 +165,7 @@ const isFileItemLite = (maybeFileItemLite) => typeof maybeFileItemLite.webUrl ==
165
165
  typeof maybeFileItemLite.webDavUrl === "string" &&
166
166
  // TODO: stronger check
167
167
  typeof maybeFileItemLite.sharepointIds === "object";
168
- async function getFileItemLite(getToken, odspUrlParts, logger, forceAccessTokenViaAuthorizationHeader) {
168
+ async function getFileItemLite(getToken, odspUrlParts, logger) {
169
169
  return internal_4.PerformanceEvent.timedExecAsync(logger, { eventName: "odspFileLink", requestName: "getFileItemLite" }, async (event) => {
170
170
  let attempts = 0;
171
171
  let additionalProps;