@fluidframework/odsp-driver 2.0.0-internal.2.1.2 → 2.0.0-internal.2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.eslintrc.js +1 -1
  2. package/dist/compactSnapshotParser.d.ts +1 -2
  3. package/dist/compactSnapshotParser.d.ts.map +1 -1
  4. package/dist/compactSnapshotParser.js +6 -2
  5. package/dist/compactSnapshotParser.js.map +1 -1
  6. package/dist/fetchSnapshot.d.ts.map +1 -1
  7. package/dist/fetchSnapshot.js +13 -18
  8. package/dist/fetchSnapshot.js.map +1 -1
  9. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  10. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  11. package/dist/localOdspDriver/localOdspDeltaStorageService.js +35 -0
  12. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  13. package/dist/localOdspDriver/localOdspDocumentService.d.ts +1 -0
  14. package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  15. package/dist/localOdspDriver/localOdspDocumentService.js +5 -2
  16. package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -1
  17. package/dist/odspDeltaStorageService.d.ts +0 -1
  18. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  19. package/dist/odspDeltaStorageService.js +4 -20
  20. package/dist/odspDeltaStorageService.js.map +1 -1
  21. package/dist/odspDocumentDeltaConnection.js +1 -1
  22. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  23. package/dist/odspDocumentService.d.ts.map +1 -1
  24. package/dist/odspDocumentService.js +9 -2
  25. package/dist/odspDocumentService.js.map +1 -1
  26. package/dist/odspUtils.d.ts +4 -0
  27. package/dist/odspUtils.d.ts.map +1 -1
  28. package/dist/odspUtils.js +32 -1
  29. package/dist/odspUtils.js.map +1 -1
  30. package/dist/packageVersion.d.ts +1 -1
  31. package/dist/packageVersion.js +1 -1
  32. package/dist/packageVersion.js.map +1 -1
  33. package/dist/zipItDataRepresentationUtils.d.ts +17 -2
  34. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  35. package/dist/zipItDataRepresentationUtils.js +15 -2
  36. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  37. package/lib/compactSnapshotParser.d.ts +1 -2
  38. package/lib/compactSnapshotParser.d.ts.map +1 -1
  39. package/lib/compactSnapshotParser.js +6 -2
  40. package/lib/compactSnapshotParser.js.map +1 -1
  41. package/lib/fetchSnapshot.d.ts.map +1 -1
  42. package/lib/fetchSnapshot.js +14 -19
  43. package/lib/fetchSnapshot.js.map +1 -1
  44. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts +17 -0
  45. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -0
  46. package/lib/localOdspDriver/localOdspDeltaStorageService.js +31 -0
  47. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -0
  48. package/lib/localOdspDriver/localOdspDocumentService.d.ts +1 -0
  49. package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -1
  50. package/lib/localOdspDriver/localOdspDocumentService.js +6 -3
  51. package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -1
  52. package/lib/odspDeltaStorageService.d.ts +0 -1
  53. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  54. package/lib/odspDeltaStorageService.js +5 -21
  55. package/lib/odspDeltaStorageService.js.map +1 -1
  56. package/lib/odspDocumentDeltaConnection.js +1 -1
  57. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  58. package/lib/odspDocumentService.d.ts.map +1 -1
  59. package/lib/odspDocumentService.js +10 -3
  60. package/lib/odspDocumentService.js.map +1 -1
  61. package/lib/odspUtils.d.ts +4 -0
  62. package/lib/odspUtils.d.ts.map +1 -1
  63. package/lib/odspUtils.js +28 -0
  64. package/lib/odspUtils.js.map +1 -1
  65. package/lib/packageVersion.d.ts +1 -1
  66. package/lib/packageVersion.js +1 -1
  67. package/lib/packageVersion.js.map +1 -1
  68. package/lib/zipItDataRepresentationUtils.d.ts +17 -2
  69. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  70. package/lib/zipItDataRepresentationUtils.js +15 -2
  71. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  72. package/package.json +19 -14
  73. package/prettier.config.cjs +8 -0
  74. package/src/compactSnapshotParser.ts +16 -12
  75. package/src/fetchSnapshot.ts +29 -24
  76. package/src/localOdspDriver/localOdspDeltaStorageService.ts +46 -0
  77. package/src/localOdspDriver/localOdspDocumentService.ts +9 -3
  78. package/src/odspDeltaStorageService.ts +5 -22
  79. package/src/odspDocumentDeltaConnection.ts +1 -1
  80. package/src/odspDocumentService.ts +9 -2
  81. package/src/odspUtils.ts +37 -0
  82. package/src/packageVersion.ts +1 -1
  83. package/src/zipItDataRepresentationUtils.ts +18 -3
@@ -1 +1 @@
1
- {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;EAGE;AAEF,+DAAmG;AAEnG,+DAAiE;AACjE,2EAAqE;AAErE,qDAA+D;AAE/D,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACnB,sDAAa,CAAA;IACb,wDAAc,CAAA;IAEd,4DAAgB,CAAA;IAChB,gEAAkB,CAAA;IAClB,kEAAmB,CAAA;IACnB,kEAAmB,CAAA;IAEnB,kEAAmB,CAAA;IACnB,oEAAoB,CAAA;IACpB,oEAAoB,CAAA;IACpB,0EAAuB,CAAA;IACvB,gFAA0B,CAAA;IAE1B,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,iDAAU,CAAA;IACV,6CAAQ,CAAA;IACR,+CAAS,CAAA;IACT,+CAAS,CAAA;IACT,+CAAS,CAAA;IAET,4DAAgB,CAAA;IAChB,gEAA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AI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC;AARD,oDAQC;AAED,SAAgB,kBAAkB,CAC9B,IAAe,EACf,OAAe;IAEf,IAAI,OAAO,IAAI,KAAK,SAAS,EAAE;QAC3B,OAAO;KACV;IACD,yBAAyB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AARD,gDAQC;AAED,SAAS,yBAAyB,CAC9B,IAAe,EACf,gBAA0B,EAC1B,OAAe;IAEf,MAAM,IAAI,gCAAiB,CACvB,6BAA6B,OAAO,EAAE,EACtC,oCAAe,CAAC,uBAAuB,EACvC;QACI,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;QAChB,aAAa,EAAb,2BAAa;KAChB,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACnB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number; }, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* key must exist in the map */);\n return val;\n}\n\nexport function getNodeProps(node: NodeCore) {\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n const id = getStringInstance(keyNode, \"keynode should be a string\");\n res[id] = valueNode;\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: { [Symbol.iterator]: () => IterableIterator<T>; }) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public abstract get arrayBuffer(): ArrayBufferLike;\n\n /**\n * Represents a blob.\n */\n constructor() {}\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n */\n constructor(protected readonly data: Uint8Array) {\n super();\n }\n\n public get buffer() {\n return this.data;\n }\n\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n */\n constructor(\n protected data: Uint8Array,\n protected start: number,\n protected end: number,\n ) {\n super();\n }\n\n public get buffer() {\n return this.data.subarray(this.start, this.end);\n }\n\n // Equivalent to Uint8ArrayToArrayBuffer(this.buffer)\n public get arrayBuffer(): ArrayBufferLike {\n const offset = this.data.byteOffset;\n return this.data.buffer.slice(this.start + offset, this.end + offset);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer.buffer, pos, pos + length);\n }\n}\n\nexport const addStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addDictionaryStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) => {\n node.addDictionaryString(a); node.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) => {\n node.addDictionaryString(a); node.addBool(b);\n};\n\nexport interface IStringElement {\n content: string;\n dictionary: boolean;\n _stringElement: true;\n}\n\nexport interface IStringElementInternal extends Omit<IStringElement, \"content\"> {\n content?: string;\n startPos: number;\n endPos: number;\n}\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n return getStringInstance(node, \"getString should return string\");\n }\n\n public getMaybeString(index: number) {\n const node = this.children[index];\n return getMaybeStringInstance(node);\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore {\n const node = this.children[index];\n assertNodeCoreInstance(node, \"getNode should return a node\");\n return node;\n }\n\n public getNumber(index: number): number {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array) {\n this.children.push(new BlobDeepCopy(blob));\n }\n\n public addDictionaryString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: true,\n _stringElement: true,\n });\n }\n\n public addString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: false,\n _stringElement: true,\n });\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n // Can we do more efficiently here, without extra objects somehow??\n private static readString(buffer: ReadBuffer, code: number, dictionary: boolean) {\n const lengthLen = getValueSafely(codeToBytesMap, code);\n const length = buffer.read(lengthLen);\n const startPos = buffer.pos;\n buffer.skip(length);\n const result: IStringElementInternal = {\n // Note: Setting here property 'content: undefined' makes code substantially slower!\n dictionary,\n _stringElement: true,\n startPos,\n endPos: buffer.pos,\n };\n\n // We are lying here in terms of presence of `content` property.\n // This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!\n // It's equivalent (but much slower!) to do it here via\n // result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), \"utf-8\");\n return result as IStringElementInternal & IStringElement;\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const stack: NodeTypes[][] = [];\n const stringsToResolve: IStringElementInternal[] = [];\n const dictionary: IStringElement[] = [];\n\n let children = this.children;\n for (;!buffer.eof;) {\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n const childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n children.push(childValue);\n stack.push(children);\n children = childValue.children;\n continue;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = NodeCore.readString(buffer, code, true /* dictionary */);\n stringsToResolve.push(constString);\n dictionary[stringId] = constString;\n continue;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const content = dictionary[stringId];\n assert(content !== undefined, 0x3de /* const string not found */);\n children.push(content);\n continue;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n {\n const str = NodeCore.readString(buffer, code, false /* dictionary */);\n stringsToResolve.push(str);\n children.push(str);\n continue;\n }\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n children.push(BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code)));\n continue;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n children.push(0);\n continue;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n children.push(buffer.read(getValueSafely(codeToBytesMap, code)));\n continue;\n }\n case MarkerCodes.BoolTrue:\n children.push(true);\n continue;\n case MarkerCodes.BoolFalse:\n children.push(false);\n continue;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n // Note: We are not checking that end marker matches start marker.\n // I.e. that we do not have a case where we start a 'list' but end with a 'set'\n // Checking it would require more state tracking that seems not very useful, given\n // our code does not care.\n children = stack.pop()!;\n\n // To my surprise, checking children !== undefined adds measurable cost!\n // We will rely on children.push() crashing in case of mismatch, and check below\n // (outside of the loop)\n continue;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n\n // This also ensures that stack.length === 0.\n assert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);\n\n /**\n * Process all the strings at once!\n */\n let length = 0;\n for (const el of stringsToResolve) {\n length += el.endPos - el.startPos + 1;\n }\n const stringBuffer = new Uint8Array(length);\n\n length = 0;\n const input = buffer.buffer;\n assert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);\n\n for (const el of stringsToResolve) {\n for (let it = el.startPos; it < el.endPos; it++) {\n stringBuffer[length] = input[it];\n length++;\n }\n stringBuffer[length] = 0;\n length++;\n }\n assert(length === stringBuffer.length, 0x418 /* properly encoded */);\n\n const result = Uint8ArrayToString(stringBuffer, \"utf-8\").split(String.fromCharCode(0));\n if (result.length === stringsToResolve.length + 1) {\n // All is good, we expect all the cases to get here\n for (let i = 0; i < stringsToResolve.length; i++) {\n stringsToResolve[i].content = result[i];\n }\n } else {\n // String content has \\0 chars!\n // Recovery code\n logger.sendErrorEvent({ eventName: \"StringParsingError\" });\n for (const el of stringsToResolve) {\n assert(el.content === Uint8ArrayToString(input.subarray(el.startPos, el.endPos), \"utf-8\"),\n 0x3ea /* test */);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer, logger: ITelemetryLogger): TreeBuilder {\n const builder = new TreeBuilder();\n builder.load(buffer, logger);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return builder;\n }\n}\n\nexport function getMaybeStringInstance(node: NodeTypes): string | undefined {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n}\n\nexport function getStringInstance(\n node: NodeTypes,\n message: string,\n): string {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n throw new NonRetryableError(\n `Buffer parsing exception: ${message}`,\n DriverErrorType.incorrectServerResponse,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n driverVersion,\n });\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if (value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n } else if (value._stringElement) {\n return \"String\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\" | \"String\";\n"]}
1
+ {"version":3,"file":"zipItDataRepresentationUtils.js","sourceRoot":"","sources":["../src/zipItDataRepresentationUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;EAGE;AAEF,+DAAmG;AAEnG,+DAAiE;AACjE,2EAAqE;AAErE,qDAA+D;AAC/D,2CAAsC;AAEtC,mCAAmC;AACnC,wJAAwJ;AACxJ;;;GAGG;AACH,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACnB,sDAAa,CAAA;IACb,wDAAc,CAAA;IAEd,4DAAgB,CAAA;IAChB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AAM,IAAI,gCAAiB,CACvB,6BAA6B,OAAO,EAAE,EACtC,oCAAe,CAAC,uBAAuB,EACvC;QACI,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;QAChB,aAAa,EAAb,2BAAa;KAChB,CAAC,CAAC;AACX,CAAC;AAED,SAAS,WAAW,CAAC,KAAgB;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC3B,OAAO,QAAQ,CAAC;KACnB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,KAAK,YAAY,QAAQ,EAAE;QAClC,OAAO,UAAU,CAAC;KACrB;SAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;QACnC,OAAO,SAAS,CAAC;KACpB;SAAM,IAAI,KAAK,CAAC,cAAc,EAAE;QAC7B,OAAO,QAAQ,CAAC;KACnB;IACD,OAAO,aAAa,CAAC;AACzB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Data representation which is followed(zipIt Protocol) here is described in this document:\n * https://microsoft.sharepoint-df.com/:w:/t/ODSPFileStore/ER06b64K_XdDjEyAKl-UT60BJiId39SCVkYSyo_2pvH9gQ?e=KYQ0c5\n*/\n\nimport { assert, Uint8ArrayToArrayBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { measure } from \"./odspUtils\";\n\n// eslint-disable-next-line max-len\n// https://onedrive.visualstudio.com/SharePoint%20Online/_git/SPO?path=/cobalt/Base/Property/BinaryEncodedPropertyReader.cs&version=GBmaster&_a=contents\n/**\n * Control codes used by tree serialization / decentralization code. Same as on server. These can be found on\n * filestore code on server too at above link.\n */\nexport enum MarkerCodes {\n BoolTrue = 11, // value = true\n BoolFalse = 12, // value = false\n\n StringEmpty = 13, // value = \"\"\n String8Length = 14, // unsigned-8-bit little-endian length, follows by UTF-8 bytes of length\n String16Length = 15, // unsigned-16-bit little-endian length, follows by UTF-8 bytes of length\n String32Length = 16, // unsigned-32-bit little-endian length, follows by UTF-8 bytes of length\n\n ConstString8Id = 17, // unsigned-8-bit little-endian const string id follows\n ConstString16Id = 18, // unsigned-16-bit little-endian const string id follows\n ConstString32Id = 19, // unsigned-32-bit little-endian const string id follows\n ConstStringDeclare = 20, // Code for declaring a const string with size <= 1 byte\n ConstStringDeclareBig = 21, // Code for declaring a const string with size > 1 byte. It is represented in 4 bytes.\n\n Int0 = 1, // value = 0\n UInt8 = 3, // unsigned-8-bit little-endian follows\n UInt16 = 5, // unsigned-16-bit little-endian follows\n UInt32 = 7, // unsigned-32-bit little-endian follows\n UInt64 = 9, // unsigned-64-bit little-endian follows\n Int8 = 2, // signed-8-bit little-endian follows\n Int16 = 4, // signed-16-bit little-endian follows\n Int32 = 6, // signed-32-bit little-endian follows\n Int64 = 8, // signed-64-bit little-endian follows\n\n BinaryEmpty = 32, // value = byte[]\n BinarySingle8 = 33, // unsigned-8-bit little-endian length, follows by bytes of length\n BinarySingle16 = 34, // unsigned-16-bit little-endian length, follows by bytes of length\n BinarySingle32 = 35, // unsigned-32-bit little-endian length, follows by bytes of length\n BinarySingle64 = 36, // unsigned-64-bit little-endian length, follows by bytes of length\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the start of sections.\n */\nexport enum MarkerCodesStart {\n \"list\" = 49,\n \"set\" = 51,\n}\n\n/**\n * Control codes used by tree serialization / decentralization code. They mark the end of sections.\n */\nexport enum MarkerCodesEnd {\n \"list\" = 50,\n \"set\" = 52,\n}\n\n/**\n * This contains mapping of Marker Codes to number of bytes in which the corresponding data\n * will be stored.\n*/\nexport const codeToBytesMap = {\n // Integer code to bytes\n 1: 0,\n 2: 1,\n 3: 1,\n 4: 2,\n 5: 2,\n 6: 4,\n 7: 4,\n 8: 8,\n 9: 8,\n\n // String code to Bytes\n 13: 0,\n 14: 1,\n 15: 2,\n 16: 4,\n\n 17: 1,\n 18: 2,\n 19: 4,\n\n 20: 1,\n 21: 4,\n\n // Binary code to bytes\n 32: 0,\n 33: 1,\n 34: 2,\n 35: 4,\n 36: 8,\n};\n\nexport function getValueSafely(map: { [index: number]: number; }, key: number) {\n const val = map[key];\n assert(val !== undefined, 0x287 /* key must exist in the map */);\n return val;\n}\n\nexport function getNodeProps(node: NodeCore) {\n const res: Record<string, NodeTypes> = {};\n for (const [keyNode, valueNode] of node.iteratePairs()) {\n const id = getStringInstance(keyNode, \"keynode should be a string\");\n res[id] = valueNode;\n }\n return res;\n}\n\nexport function iteratePairs<T>(it: IterableIterator<T>) {\n const res: IterableIterator<[T, T]> = {\n next: () => {\n const a = it.next();\n if (a.done) {\n return { value: undefined, done: true };\n }\n const b = it.next();\n assert(b.done !== true, 0x22b /* \"Should be a pair\" */);\n return { value: [a.value, b.value], done: b.done };\n },\n [Symbol.iterator]: () => { return res; },\n };\n return res;\n}\n\n/**\n * Helper function that returns iterator from an object\n * @param obj - object that supports iteration\n */\nexport function iterate<T>(obj: { [Symbol.iterator]: () => IterableIterator<T>; }) {\n return obj[Symbol.iterator]();\n}\n\n/**\n * Base class to represent binary blob element.\n * Binary blob is one of three types supported as a leaf node of a tree.\n * Note: concrete implementations (derived classes) are not exposed from this module\n */\nexport abstract class BlobCore {\n public abstract get buffer(): Uint8Array;\n public abstract get arrayBuffer(): ArrayBufferLike;\n\n /**\n * Represents a blob.\n */\n constructor() {}\n}\n\n/**\n * \"deep copy\" blob, holds to binary data passed in\n * It is called deep copy as a counter-part to BlobShallowCopy, which\n * is a reference to underlying binary stream (ReadBuffer).\n*/\nclass BlobDeepCopy extends BlobCore {\n /**\n * Represents a deep copy of the blob.\n * @param data - Data array of the blob\n */\n constructor(protected readonly data: Uint8Array) {\n super();\n }\n\n public get buffer() {\n return this.data;\n }\n\n public get arrayBuffer(): ArrayBufferLike {\n return Uint8ArrayToArrayBuffer(this.buffer);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const data = new Uint8Array(length);\n for (let counter = 0; counter < length; counter++) {\n data[counter] = buffer.read();\n }\n return new BlobDeepCopy(data);\n }\n}\n\n/**\n * Shallow copy blob, keeps a reference to portion of ReadBuffer\n * it was constructed from. It takes much less memory compared to BlobDeepCopy\n */\n export class BlobShallowCopy extends BlobCore {\n /**\n * Represents a shallow copy of the blob. It is not a separate blob, just reference to original blobs.\n * @param data - Data array of the blob\n * @param start - Start point of the blob in the buffer.\n * @param end - End point of the blob in the buffer.\n */\n constructor(\n protected data: Uint8Array,\n protected start: number,\n protected end: number,\n ) {\n super();\n }\n\n public get buffer() {\n return this.data.subarray(this.start, this.end);\n }\n\n // Equivalent to Uint8ArrayToArrayBuffer(this.buffer)\n public get arrayBuffer(): ArrayBufferLike {\n const offset = this.data.byteOffset;\n return this.data.buffer.slice(this.start + offset, this.end + offset);\n }\n\n public static read(buffer: ReadBuffer, lengthLen: number): BlobCore {\n const length = buffer.read(lengthLen);\n const pos = buffer.pos;\n buffer.skip(length);\n return new BlobShallowCopy(buffer.buffer, pos, pos + length);\n }\n}\n\nexport const addStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addDictionaryStringProperty =\n (node: NodeCore, a: string, b: string) => {\n node.addDictionaryString(a); node.addString(b);\n };\nexport const addNumberProperty = (node: NodeCore, a: string, b: number) => {\n node.addDictionaryString(a); node.addNumber(b);\n};\nexport const addBoolProperty = (node: NodeCore, a: string, b: boolean) => {\n node.addDictionaryString(a); node.addBool(b);\n};\n\nexport interface IStringElement {\n content: string;\n dictionary: boolean;\n _stringElement: true;\n}\n\nexport interface IStringElementInternal extends Omit<IStringElement, \"content\"> {\n content?: string;\n startPos: number;\n endPos: number;\n}\n\n/**\n * Three leaf types supported by tree:\n * 1. Node (sub-tree)\n * 2. binary blob\n * 3. integer\n * 4. boolean\n */\nexport type NodeTypes = NodeCore | BlobCore | number | boolean | IStringElement;\n\nexport type NodeCoreTypes = \"list\" | \"set\";\n\n/**\n * Node - node in the tree (non-leaf element of the tree)\n */\nexport class NodeCore {\n // It is an array of nodes.\n private readonly children: NodeTypes[] = [];\n public get nodes() {\n return this.children;\n }\n\n constructor(public type: NodeCoreTypes = \"set\") {}\n\n public [Symbol.iterator]() {\n return this.children[Symbol.iterator]();\n }\n\n public iteratePairs() {\n assert((this.length % 2) === 0, 0x22c /* \"reading pairs\" */);\n return iteratePairs(iterate(this));\n }\n\n public get length() { return this.children.length; }\n\n public get(index: number) { return this.children[index]; }\n\n public getString(index: number): string {\n const node = this.children[index];\n return getStringInstance(node, \"getString should return string\");\n }\n\n public getMaybeString(index: number) {\n const node = this.children[index];\n return getMaybeStringInstance(node);\n }\n\n public getBlob(index: number): BlobCore {\n const node = this.children[index];\n assertBlobCoreInstance(node, \"getBlob should return a blob\");\n return node;\n }\n\n public getNode(index: number): NodeCore {\n const node = this.children[index];\n assertNodeCoreInstance(node, \"getNode should return a node\");\n return node;\n }\n\n public getNumber(index: number): number {\n const node = this.children[index];\n assertNumberInstance(node, \"getNumber should return a number\");\n return node;\n }\n\n public getBool(index: number): boolean {\n const node = this.children[index];\n assertBoolInstance(node, \"getBool should return a boolean\");\n return node;\n }\n\n public addNode(type?: NodeCoreTypes): NodeCore {\n const node = new NodeCore(type);\n this.children.push(node);\n return node;\n }\n\n public addBlob(blob: Uint8Array) {\n this.children.push(new BlobDeepCopy(blob));\n }\n\n public addDictionaryString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: true,\n _stringElement: true,\n });\n }\n\n public addString(payload: string) {\n this.children.push({\n content: payload,\n dictionary: false,\n _stringElement: true,\n });\n }\n\n public addNumber(payload: number | undefined) {\n assert(Number.isInteger(payload), 0x231 /* \"Number should be an integer\" */);\n assert(payload !== undefined && payload >= 0, 0x232 /* \"Payload should not be negative\" */);\n this.children.push(payload);\n }\n\n public addBool(payload: boolean) {\n this.children.push(payload);\n }\n\n // Can we do more efficiently here, without extra objects somehow??\n private static readString(buffer: ReadBuffer, code: number, dictionary: boolean) {\n const lengthLen = getValueSafely(codeToBytesMap, code);\n const length = buffer.read(lengthLen);\n const startPos = buffer.pos;\n buffer.skip(length);\n const result: IStringElementInternal = {\n // Note: Setting here property 'content: undefined' makes code substantially slower!\n dictionary,\n _stringElement: true,\n startPos,\n endPos: buffer.pos,\n };\n\n // We are lying here in terms of presence of `content` property.\n // This will be addressed at the bottom of NodeCore.load() by resolving all strings at once!\n // It's equivalent (but much slower!) to do it here via\n // result.content = Uint8ArrayToString(buffer.buffer.subarray(startPos, buffer.pos), \"utf-8\");\n return result as IStringElementInternal & IStringElement;\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected load(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const [stringsToResolve, durationStructure] = measure(() => this.loadStructure(buffer, logger));\n const [, durationStrings] = measure(() => this.loadStrings(buffer, stringsToResolve, logger));\n return { durationStructure, durationStrings };\n }\n\n /**\n * Load and parse the buffer into a tree.\n * @param buffer - buffer to read from.\n */\n protected loadStructure(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const stack: NodeTypes[][] = [];\n const stringsToResolve: IStringElementInternal[] = [];\n const dictionary: IStringElement[] = [];\n\n let children = this.children;\n for (;!buffer.eof;) {\n const code = buffer.read();\n switch (code) {\n case MarkerCodesStart.list:\n case MarkerCodesStart.set: {\n const childValue = new NodeCore(code === MarkerCodesStart.set ? \"set\" : \"list\");\n children.push(childValue);\n stack.push(children);\n children = childValue.children;\n continue;\n }\n case MarkerCodes.ConstStringDeclare:\n case MarkerCodes.ConstStringDeclareBig:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const constString = NodeCore.readString(buffer, code, true /* dictionary */);\n stringsToResolve.push(constString);\n dictionary[stringId] = constString;\n continue;\n }\n case MarkerCodes.ConstString8Id:\n case MarkerCodes.ConstString16Id:\n case MarkerCodes.ConstString32Id:\n {\n const stringId = buffer.read(getValueSafely(codeToBytesMap, code));\n const content = dictionary[stringId];\n assert(content !== undefined, 0x3de /* const string not found */);\n children.push(content);\n continue;\n }\n case MarkerCodes.StringEmpty:\n case MarkerCodes.String8Length:\n case MarkerCodes.String16Length:\n case MarkerCodes.String32Length:\n {\n const str = NodeCore.readString(buffer, code, false /* dictionary */);\n stringsToResolve.push(str);\n children.push(str);\n continue;\n }\n case MarkerCodes.BinaryEmpty:\n case MarkerCodes.BinarySingle8:\n case MarkerCodes.BinarySingle16:\n case MarkerCodes.BinarySingle32:\n case MarkerCodes.BinarySingle64:\n {\n children.push(BlobShallowCopy.read(buffer, getValueSafely(codeToBytesMap, code)));\n continue;\n }\n // If integer is 0.\n case MarkerCodes.Int0:\n {\n children.push(0);\n continue;\n }\n case MarkerCodes.UInt8:\n case MarkerCodes.UInt16:\n case MarkerCodes.UInt32:\n case MarkerCodes.UInt64:\n case MarkerCodes.Int8:\n case MarkerCodes.Int16:\n case MarkerCodes.Int32:\n case MarkerCodes.Int64:\n {\n children.push(buffer.read(getValueSafely(codeToBytesMap, code)));\n continue;\n }\n case MarkerCodes.BoolTrue:\n children.push(true);\n continue;\n case MarkerCodes.BoolFalse:\n children.push(false);\n continue;\n case MarkerCodesEnd.list:\n case MarkerCodesEnd.set:\n // Note: We are not checking that end marker matches start marker.\n // I.e. that we do not have a case where we start a 'list' but end with a 'set'\n // Checking it would require more state tracking that seems not very useful, given\n // our code does not care.\n children = stack.pop()!;\n\n // To my surprise, checking children !== undefined adds measurable cost!\n // We will rely on children.push() crashing in case of mismatch, and check below\n // (outside of the loop)\n continue;\n default:\n throw new Error(`Invalid code: ${code}`);\n }\n }\n\n // This also ensures that stack.length === 0.\n assert(children === this.children, 0x3e7 /* Unpaired start/end list/set markers! */);\n\n return stringsToResolve;\n }\n\n private loadStrings(buffer: ReadBuffer, stringsToResolve: IStringElementInternal[], logger: ITelemetryLogger) {\n /**\n * Process all the strings at once!\n */\n let length = 0;\n for (const el of stringsToResolve) {\n length += el.endPos - el.startPos + 1;\n }\n const stringBuffer = new Uint8Array(length);\n\n length = 0;\n const input = buffer.buffer;\n assert(input.byteOffset === 0, 0x3e8 /* code below assumes no offset */);\n\n for (const el of stringsToResolve) {\n for (let it = el.startPos; it < el.endPos; it++) {\n stringBuffer[length] = input[it];\n length++;\n }\n stringBuffer[length] = 0;\n length++;\n }\n assert(length === stringBuffer.length, 0x418 /* properly encoded */);\n\n const result = Uint8ArrayToString(stringBuffer, \"utf-8\").split(String.fromCharCode(0));\n if (result.length === stringsToResolve.length + 1) {\n // All is good, we expect all the cases to get here\n for (let i = 0; i < stringsToResolve.length; i++) {\n stringsToResolve[i].content = result[i];\n }\n } else {\n // String content has \\0 chars!\n // Recovery code\n logger.sendErrorEvent({ eventName: \"StringParsingError\" });\n for (const el of stringsToResolve) {\n assert(el.content === Uint8ArrayToString(input.subarray(el.startPos, el.endPos), \"utf-8\"),\n 0x3ea /* test */);\n }\n }\n }\n}\n\n /**\n * TreeBuilder - Root of the tree.\n * Provides loading and serialization capabilities.\n */\nexport class TreeBuilder extends NodeCore {\n static load(buffer: ReadBuffer, logger: ITelemetryLogger) {\n const builder = new TreeBuilder();\n const telemetryProps = builder.load(buffer, logger);\n assert(buffer.eof, 0x233 /* \"Unexpected data at the end of buffer\" */);\n return { builder, telemetryProps };\n }\n}\n\nexport function getMaybeStringInstance(node: NodeTypes): string | undefined {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n}\n\nexport function getStringInstance(\n node: NodeTypes,\n message: string,\n): string {\n const maybeString = node as IStringElement;\n if (maybeString._stringElement) {\n return maybeString.content;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertBlobCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is BlobCore {\n if (node instanceof BlobCore) {\n return;\n }\n throwBufferParseException(node, \"BlobCore\", message);\n}\n\nexport function assertNodeCoreInstance(\n node: NodeTypes,\n message: string,\n): asserts node is NodeCore {\n if (node instanceof NodeCore) {\n return;\n }\n throwBufferParseException(node, \"NodeCore\", message);\n}\n\nexport function assertNumberInstance(\n node: NodeTypes,\n message: string,\n): asserts node is number {\n if (typeof node === \"number\") {\n return;\n }\n throwBufferParseException(node, \"Number\", message);\n}\n\nexport function assertBoolInstance(\n node: NodeTypes,\n message: string,\n): asserts node is boolean {\n if (typeof node === \"boolean\") {\n return;\n }\n throwBufferParseException(node, \"Boolean\", message);\n}\n\nfunction throwBufferParseException(\n node: NodeTypes,\n expectedNodeType: NodeType,\n message: string,\n): never {\n throw new NonRetryableError(\n `Buffer parsing exception: ${message}`,\n DriverErrorType.incorrectServerResponse,\n {\n nodeType: getNodeType(node),\n expectedNodeType,\n driverVersion,\n });\n}\n\nfunction getNodeType(value: NodeTypes): NodeType {\n if (typeof value === \"number\") {\n return \"Number\";\n } else if (value instanceof BlobCore) {\n return \"BlobCore\";\n } else if (value instanceof NodeCore) {\n return \"NodeCore\";\n } else if (typeof value === \"boolean\") {\n return \"Boolean\";\n } else if (value._stringElement) {\n return \"String\";\n }\n return \"UnknownType\";\n}\n\ntype NodeType = \"Number\" | \"BlobCore\" | \"NodeCore\" | \"Boolean\" | \"UnknownType\" | \"String\";\n"]}
@@ -11,8 +11,7 @@ export declare const currentReadVersion = "1.0";
11
11
  * represents how many times slower parsing path is executed. This will be then logged into telemetry.
12
12
  */
13
13
  export interface ISnapshotContentsWithProps extends ISnapshotContents {
14
- slowBlobStructureCount?: number;
15
- slowTreeStructureCount?: number;
14
+ telemetryProps: Record<string, number>;
16
15
  }
17
16
  /**
18
17
  * Converts snapshot from binary compact representation to tree/blobs/ops.
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AActD,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAQxC;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACjE,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACnC;AAsKD;;;;GAIG;AACH,wBAAgB,4BAA4B,CACxC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACzB,0BAA0B,CA0B5B"}
1
+ {"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAetD,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;GAGG;AACH,MAAM,WAAW,0BAA2B,SAAQ,iBAAiB;IACjE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAsKD;;;;GAIG;AACH,wBAAgB,4BAA4B,CACxC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,gBAAgB,GACzB,0BAA0B,CAoC5B"}
@@ -5,6 +5,7 @@
5
5
  import { assert } from "@fluidframework/common-utils";
6
6
  import { ReadBuffer } from "./ReadBufferUtils";
7
7
  import { assertBlobCoreInstance, getStringInstance, assertBoolInstance, assertNodeCoreInstance, assertNumberInstance, getNodeProps, TreeBuilder, } from "./zipItDataRepresentationUtils";
8
+ import { measure } from "./odspUtils";
8
9
  export const snapshotMinReadVersion = "1.0";
9
10
  export const currentReadVersion = "1.0";
10
11
  /**
@@ -165,7 +166,7 @@ function readSnapshotSection(node) {
165
166
  * @returns - tree, blobs and ops from the snapshot.
166
167
  */
167
168
  export function parseCompactSnapshotResponse(buffer, logger) {
168
- const builder = TreeBuilder.load(new ReadBuffer(buffer), logger);
169
+ const { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);
169
170
  assert(builder.length === 1, 0x219 /* "1 root should be there" */);
170
171
  const root = builder.getNode(0);
171
172
  const records = getNodeProps(root);
@@ -177,6 +178,9 @@ export function parseCompactSnapshotResponse(buffer, logger) {
177
178
  assert(parseFloat(snapshotMinReadVersion) >= parseFloat(mrv), 0x20f /* "Driver min read version should >= to server minReadVersion" */);
178
179
  assert(parseFloat(cv) >= parseFloat(snapshotMinReadVersion), 0x210 /* "Snapshot should be created with minReadVersion or above" */);
179
180
  assert(currentReadVersion === cv, 0x2c2 /* "Create Version should be equal to currentReadVersion" */);
180
- return Object.assign(Object.assign(Object.assign({}, readSnapshotSection(records.snapshot)), readBlobSection(records.blobs)), { ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [], latestSequenceNumber: records.lsn });
181
+ const [snapshot, durationSnapshotTree] = measure(() => readSnapshotSection(records.snapshot));
182
+ const [blobs, durationBlobs] = measure(() => readBlobSection(records.blobs));
183
+ return Object.assign(Object.assign(Object.assign({}, snapshot), blobs), { ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [], latestSequenceNumber: records.lsn, telemetryProps: Object.assign(Object.assign({}, telemetryProps), { durationSnapshotTree,
184
+ durationBlobs, slowTreeStructureCount: snapshot.slowTreeStructureCount, slowBlobStructureCount: blobs.slowBlobStructureCount }) });
181
185
  }
182
186
  //# sourceMappingURL=compactSnapshotParser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,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,GAAG,EAAE,iCAAiC,CAAC,CAAC;IAC9E,MAAM,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAAE,EAAE,gCAAgC,CAAC,CAAC;IAC3E,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE;QAC3B,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,wBAAwB,CAAC,CAAC;KAC/D;IAED,MAAM,CAAC,UAAU,CAAC,sBAAsB,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC,EACxD,KAAK,CAAC,kEAAkE,CAAC,CAAC;IAC9E,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,UAAU,CAAC,sBAAsB,CAAC,EACvD,KAAK,CAAC,+DAA+D,CAAC,CAAC;IAC3E,MAAM,CAAC,kBAAkB,KAAK,EAAE,EAC5B,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAExE,qDACO,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,GACrC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,KACjC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG,IACnC;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport {\n assertBlobCoreInstance,\n getStringInstance,\n assertBoolInstance,\n assertNodeCoreInstance,\n assertNumberInstance,\n getNodeProps,\n NodeCore,\n NodeTypes,\n TreeBuilder,\n} from \"./zipItDataRepresentationUtils\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\ninterface ISnapshotSection {\n snapshotTree: ISnapshotTree;\n sequenceNumber: number;\n slowTreeStructureCount: number;\n}\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 */\nexport interface ISnapshotContentsWithProps extends ISnapshotContents {\n slowBlobStructureCount?: number;\n slowTreeStructureCount?: 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 assertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n let slowBlobStructureCount = 0;\n const blobs: Map<string, ArrayBuffer> = new Map();\n for (const blob of node) {\n assertNodeCoreInstance(blob, \"blob should be node\");\n\n /**\n * Perf optimization - the most common cases!\n * This is essentially unrolling code below for faster processing\n * It speeds up tree parsing by 2-3x times!\n */\n if (blob.length === 4 && blob.getMaybeString(0) === \"id\" && blob.getMaybeString(2) === \"data\") {\n // \"id\": <node name>\n // \"data\": <blob>\n blobs.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n continue;\n }\n\n /**\n * More generalized workflow\n */\n slowBlobStructureCount += 1;\n const records = getNodeProps(blob);\n assertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n const id = getStringInstance(records.id, \"blob id should be string\");\n blobs.set(id, records.data.arrayBuffer);\n }\n return { blobs, 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) {\n assertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n const ops: ISequencedDocumentMessage[] = [];\n const records = getNodeProps(node);\n assertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n assertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n for (let i = 0; i < records.deltas.length; ++i) {\n ops.push(JSON.parse(records.deltas.getString(i)));\n }\n assert(records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n 0x280 /* \"Validate first op seq number\" */);\n return 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 let slowTreeStructureCount = 0;\n const trees = {};\n const snapshotTree: ISnapshotTree = {\n blobs: {},\n trees,\n };\n for (const treeNode of node) {\n assertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n /**\n * Perf optimization - the most common cases!\n * This is essentially unrolling code below for faster processing\n * It speeds up tree parsing by 2-3x times!\n */\n const length = treeNode.length;\n if (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n if (length === 4) {\n const content = treeNode.getMaybeString(2);\n // \"name\": <node name>\n // \"children\": <blob id>\n if (content === \"children\") {\n const result = readTreeSection(treeNode.getNode(3));\n trees[treeNode.getString(1)] = result.snapshotTree;\n slowTreeStructureCount += result.slowTreeStructureCount;\n continue;\n }\n // \"name\": <node name>\n // \"value\": <blob id>\n if (content === \"value\") {\n snapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n continue;\n }\n }\n\n // \"name\": <node name>\n // \"nodeType\": 3\n // \"value\": <blob id>\n if (length === 6 &&\n treeNode.getMaybeString(2) === \"nodeType\" &&\n treeNode.getMaybeString(4) === \"value\") {\n snapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n continue;\n }\n\n // \"name\": <node name>\n // \"unreferenced\": true\n // \"children\": <blob id>\n if (length === 6 &&\n treeNode.getMaybeString(2) === \"unreferenced\" &&\n treeNode.getMaybeString(4) === \"children\") {\n const result = readTreeSection(treeNode.getNode(5));\n trees[treeNode.getString(1)] = result.snapshotTree;\n slowTreeStructureCount += result.slowTreeStructureCount;\n assert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n snapshotTree.unreferenced = true;\n continue;\n }\n }\n\n /**\n * More generalized workflow\n */\n slowTreeStructureCount += 1;\n const records = getNodeProps(treeNode);\n\n if (records.unreferenced !== undefined) {\n assertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n assert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n snapshotTree.unreferenced = true;\n }\n\n const path = getStringInstance(records.name, \"Path name should be string\");\n if (records.value !== undefined) {\n snapshotTree.blobs[path] = getStringInstance(records.value, \"Blob value should be string\");\n } else if (records.children !== undefined) {\n assertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n const result = readTreeSection(records.children);\n trees[path] = result.snapshotTree;\n slowTreeStructureCount += result.slowTreeStructureCount;\n } else {\n trees[path] = { blobs: {}, trees: {} };\n }\n }\n return { snapshotTree, slowTreeStructureCount };\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): ISnapshotSection {\n assertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n const records = getNodeProps(node);\n\n assertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n assertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n const { snapshotTree, slowTreeStructureCount } = readTreeSection(records.treeNodes);\n snapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n const sequenceNumber = records.sequenceNumber.valueOf();\n return {\n sequenceNumber,\n snapshotTree,\n slowTreeStructureCount,\n };\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 */\nexport function parseCompactSnapshotResponse(\n buffer: Uint8Array,\n logger: ITelemetryLogger,\n): ISnapshotContentsWithProps {\n const builder = TreeBuilder.load(new ReadBuffer(buffer), logger);\n assert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n const root = builder.getNode(0);\n\n const records = getNodeProps(root);\n\n const mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n const cv = getStringInstance(records.cv, \"createVersion should be string\");\n if (records.lsn !== undefined) {\n assertNumberInstance(records.lsn, \"lsn should be a number\");\n }\n\n assert(parseFloat(snapshotMinReadVersion) >= parseFloat(mrv),\n 0x20f /* \"Driver min read version should >= to server minReadVersion\" */);\n assert(parseFloat(cv) >= parseFloat(snapshotMinReadVersion),\n 0x210 /* \"Snapshot should be created with minReadVersion or above\" */);\n assert(currentReadVersion === cv,\n 0x2c2 /* \"Create Version should be equal to currentReadVersion\" */);\n\n return {\n ...readSnapshotSection(records.snapshot),\n ...readBlobSection(records.blobs),\n ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],\n latestSequenceNumber: records.lsn,\n };\n}\n"]}
1
+ {"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACH,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EAGZ,WAAW,GACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAUxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IACpC,sBAAsB,CAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,IAAI,sBAAsB,GAAG,CAAC,CAAC;IAC/B,MAAM,KAAK,GAA6B,IAAI,GAAG,EAAE,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACrB,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEpD;;;;WAIG;QACH,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,C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AAC,QAAQ,CAAC,CAAC,CAAC;IAC9F,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAE7E,qDACO,QAAQ,GACR,KAAK,KACR,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG,EACjC,cAAc,kCACP,cAAc,KACjB,oBAAoB;YACpB,aAAa,EACb,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB,EACvD,sBAAsB,EAAE,KAAK,CAAC,sBAAsB,OAE1D;AACN,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport {\n assertBlobCoreInstance,\n getStringInstance,\n assertBoolInstance,\n assertNodeCoreInstance,\n assertNumberInstance,\n getNodeProps,\n NodeCore,\n NodeTypes,\n TreeBuilder,\n} from \"./zipItDataRepresentationUtils\";\nimport { measure } from \"./odspUtils\";\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 */\nexport interface ISnapshotContentsWithProps extends ISnapshotContents {\n telemetryProps: 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 assertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n let slowBlobStructureCount = 0;\n const blobs: Map<string, ArrayBuffer> = new Map();\n for (const blob of node) {\n assertNodeCoreInstance(blob, \"blob should be node\");\n\n /**\n * Perf optimization - the most common cases!\n * This is essentially unrolling code below for faster processing\n * It speeds up tree parsing by 2-3x times!\n */\n if (blob.length === 4 && blob.getMaybeString(0) === \"id\" && blob.getMaybeString(2) === \"data\") {\n // \"id\": <node name>\n // \"data\": <blob>\n blobs.set(blob.getString(1), blob.getBlob(3).arrayBuffer);\n continue;\n }\n\n /**\n * More generalized workflow\n */\n slowBlobStructureCount += 1;\n const records = getNodeProps(blob);\n assertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n const id = getStringInstance(records.id, \"blob id should be string\");\n blobs.set(id, records.data.arrayBuffer);\n }\n return { blobs, 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) {\n assertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n const ops: ISequencedDocumentMessage[] = [];\n const records = getNodeProps(node);\n assertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n assertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n for (let i = 0; i < records.deltas.length; ++i) {\n ops.push(JSON.parse(records.deltas.getString(i)));\n }\n assert(records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n 0x280 /* \"Validate first op seq number\" */);\n return 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 let slowTreeStructureCount = 0;\n const trees = {};\n const snapshotTree: ISnapshotTree = {\n blobs: {},\n trees,\n };\n for (const treeNode of node) {\n assertNodeCoreInstance(treeNode, \"tree nodes should be nodes\");\n\n /**\n * Perf optimization - the most common cases!\n * This is essentially unrolling code below for faster processing\n * It speeds up tree parsing by 2-3x times!\n */\n const length = treeNode.length;\n if (length > 0 && treeNode.getMaybeString(0) === \"name\") {\n if (length === 4) {\n const content = treeNode.getMaybeString(2);\n // \"name\": <node name>\n // \"children\": <blob id>\n if (content === \"children\") {\n const result = readTreeSection(treeNode.getNode(3));\n trees[treeNode.getString(1)] = result.snapshotTree;\n slowTreeStructureCount += result.slowTreeStructureCount;\n continue;\n }\n // \"name\": <node name>\n // \"value\": <blob id>\n if (content === \"value\") {\n snapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(3);\n continue;\n }\n }\n\n // \"name\": <node name>\n // \"nodeType\": 3\n // \"value\": <blob id>\n if (length === 6 &&\n treeNode.getMaybeString(2) === \"nodeType\" &&\n treeNode.getMaybeString(4) === \"value\") {\n snapshotTree.blobs[treeNode.getString(1)] = treeNode.getString(5);\n continue;\n }\n\n // \"name\": <node name>\n // \"unreferenced\": true\n // \"children\": <blob id>\n if (length === 6 &&\n treeNode.getMaybeString(2) === \"unreferenced\" &&\n treeNode.getMaybeString(4) === \"children\") {\n const result = readTreeSection(treeNode.getNode(5));\n trees[treeNode.getString(1)] = result.snapshotTree;\n slowTreeStructureCount += result.slowTreeStructureCount;\n assert(treeNode.getBool(3), 0x3db /* Unreferenced if present should be true */);\n snapshotTree.unreferenced = true;\n continue;\n }\n }\n\n /**\n * More generalized workflow\n */\n slowTreeStructureCount += 1;\n const records = getNodeProps(treeNode);\n\n if (records.unreferenced !== undefined) {\n assertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n assert(records.unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n snapshotTree.unreferenced = true;\n }\n\n const path = getStringInstance(records.name, \"Path name should be string\");\n if (records.value !== undefined) {\n snapshotTree.blobs[path] = getStringInstance(records.value, \"Blob value should be string\");\n } else if (records.children !== undefined) {\n assertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n const result = readTreeSection(records.children);\n trees[path] = result.snapshotTree;\n slowTreeStructureCount += result.slowTreeStructureCount;\n } else {\n trees[path] = { blobs: {}, trees: {} };\n }\n }\n return { snapshotTree, slowTreeStructureCount };\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 assertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n const records = getNodeProps(node);\n\n assertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n assertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n const { snapshotTree, slowTreeStructureCount } = readTreeSection(records.treeNodes);\n snapshotTree.id = getStringInstance(records.id, \"snapshotId should be string\");\n const sequenceNumber = records.sequenceNumber.valueOf();\n return {\n sequenceNumber,\n snapshotTree,\n slowTreeStructureCount,\n };\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 */\nexport function parseCompactSnapshotResponse(\n buffer: Uint8Array,\n logger: ITelemetryLogger,\n): ISnapshotContentsWithProps {\n const { builder, telemetryProps } = TreeBuilder.load(new ReadBuffer(buffer), logger);\n assert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n const root = builder.getNode(0);\n\n const records = getNodeProps(root);\n\n const mrv = getStringInstance(records.mrv, \"minReadVersion should be string\");\n const cv = getStringInstance(records.cv, \"createVersion should be string\");\n if (records.lsn !== undefined) {\n assertNumberInstance(records.lsn, \"lsn should be a number\");\n }\n\n assert(parseFloat(snapshotMinReadVersion) >= parseFloat(mrv),\n 0x20f /* \"Driver min read version should >= to server minReadVersion\" */);\n assert(parseFloat(cv) >= parseFloat(snapshotMinReadVersion),\n 0x210 /* \"Snapshot should be created with minReadVersion or above\" */);\n assert(currentReadVersion === cv,\n 0x2c2 /* \"Create Version should be equal to currentReadVersion\" */);\n\n const [snapshot, durationSnapshotTree] = measure(() => readSnapshotSection(records.snapshot));\n const [blobs, durationBlobs] = measure(() => readBlobSection(records.blobs));\n\n return {\n ...snapshot,\n ...blobs,\n ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],\n latestSequenceNumber: records.lsn,\n telemetryProps: {\n ...telemetryProps,\n durationSnapshotTree,\n durationBlobs,\n slowTreeStructureCount: snapshot.slowTreeStructureCount,\n slowBlobStructureCount: blobs.slowBlobStructureCount,\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAItE,OAAO,EACH,gBAAgB,EAChB,gBAAgB,EAEhB,+BAA+B,EAClC,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAwB,wBAAwB,EAA8B,MAAM,aAAa,CAAC;AAGxH,OAAO,EAKH,aAAa,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU9C;;GAEG;AACH,oBAAY,yBAAyB;IACjC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAC/B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,OAAO,EAC1B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,gBAAgB,EACxB,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;CAAE,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAC9G,OAAO,CAAC,iBAAiB,CAAC,CAoB5B;AAED,wBAAsB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CAAC,kCAAkC,CAAC,EAChD,UAAU,EAAE,CAAC,cAAc,EAAE,wBAAwB,KAAK,OAAO,CAAC,IAAI,CAAC,EACvE,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAClC,oBAAoB,CAAC,EAAE,OAAO,GAC/B,OAAO,CAAC,iBAAiB,CAAC,CA4D5B;AAyUD,MAAM,WAAW,kCAAkC;IAC/C,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;KAAE,CAAC;CAC7C;AAiDD,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,QAK5D;AAWD;;;;;;;;;;GAUG;AACH,wBAAsB,gBAAgB,CAClC,eAAe,EAAE,gBAAgB,EACjC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,gBAAgB,EACxB,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,GACtB,OAAO,CAAC,kCAAkC,CAAC,CAwC7C"}
@@ -12,16 +12,10 @@ import { isRuntimeMessage, NonRetryableError } from "@fluidframework/driver-util
12
12
  import { persistedCacheValueVersion } from "./contracts";
13
13
  import { getQueryString } from "./getQueryString";
14
14
  import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
15
- import { fetchAndParseAsJSONHelper, fetchHelper, getWithRetryForTokenRefresh, getWithRetryForTokenRefreshRepeat, } from "./odspUtils";
15
+ import { fetchAndParseAsJSONHelper, fetchHelper, getWithRetryForTokenRefresh, getWithRetryForTokenRefreshRepeat, measure, measureP, } from "./odspUtils";
16
16
  import { convertOdspSnapshotToSnapshotTreeAndBlobs } from "./odspSnapshotParser";
17
17
  import { currentReadVersion, parseCompactSnapshotResponse } from "./compactSnapshotParser";
18
18
  import { pkgVersion } from "./packageVersion";
19
- async function measure(callback) {
20
- const start = performance.now();
21
- const result = await callback();
22
- const time = performance.now() - start;
23
- return [result, time];
24
- }
25
19
  /**
26
20
  * Enum to support different types of snapshot formats.
27
21
  */
@@ -125,14 +119,14 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
125
119
  }
126
120
  // This event measures only successful cases of getLatest call (no tokens, no retries).
127
121
  return PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {
128
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
122
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
129
123
  let controller;
130
124
  let fetchTimeout;
131
125
  if ((snapshotOptions === null || snapshotOptions === void 0 ? void 0 : snapshotOptions.timeout) !== undefined) {
132
126
  controller = new AbortController();
133
127
  fetchTimeout = setTimeout(() => controller.abort(), snapshotOptions.timeout);
134
128
  }
135
- const [response, fetchTime] = await measure(async () => snapshotDownloader(odspResolvedUrl, storageToken, snapshotOptions, controller)).finally(() => {
129
+ const [response, fetchTime] = await measureP(async () => snapshotDownloader(odspResolvedUrl, storageToken, snapshotOptions, controller)).finally(() => {
136
130
  // Clear the fetchTimeout once the response is fetched.
137
131
  if (fetchTimeout !== undefined) {
138
132
  clearTimeout(fetchTimeout);
@@ -156,28 +150,29 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
156
150
  switch (contentTypeToRead) {
157
151
  case "application/json": {
158
152
  let text;
159
- [text, receiveContentTime] = await measure(async () => odspResponse.content.text());
153
+ [text, receiveContentTime] = await measureP(async () => odspResponse.content.text());
160
154
  propsToLog.bodySize = text.length;
161
155
  let content;
162
- [content, parseTime] = await measure(() => JSON.parse(text));
156
+ [content, parseTime] = measure(() => JSON.parse(text));
163
157
  validateBlobsAndTrees(content);
164
158
  const snapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);
165
- parsedSnapshotContents = Object.assign(Object.assign({}, odspResponse), { content: snapshotContents });
159
+ parsedSnapshotContents = Object.assign(Object.assign({}, odspResponse), { content: Object.assign(Object.assign({}, snapshotContents), { telemetryProps: {} }) });
166
160
  break;
167
161
  }
168
162
  case "application/ms-fluid": {
169
163
  let content;
170
164
  [content, receiveContentTime] =
171
- await measure(async () => odspResponse.content.arrayBuffer());
165
+ await measureP(async () => odspResponse.content.arrayBuffer());
172
166
  propsToLog.bodySize = content.byteLength;
173
167
  let snapshotContents;
174
- [snapshotContents, parseTime] = await measure(() => parseCompactSnapshotResponse(new Uint8Array(content), logger));
168
+ [snapshotContents, parseTime] = measure(() => parseCompactSnapshotResponse(new Uint8Array(content), logger));
175
169
  if (snapshotContents.snapshotTree.trees === undefined ||
176
170
  snapshotContents.snapshotTree.blobs === undefined) {
177
171
  throw new NonRetryableError("Returned odsp snapshot is malformed. No trees or blobs!", DriverErrorType.incorrectServerResponse, propsToLog);
178
172
  }
179
- const slowTreeParseCodePaths = (_a = snapshotContents.slowTreeStructureCount) !== null && _a !== void 0 ? _a : 0;
180
- const slowBlobParseCodePaths = (_b = snapshotContents.slowBlobStructureCount) !== null && _b !== void 0 ? _b : 0;
173
+ const props = snapshotContents.telemetryProps;
174
+ const slowTreeParseCodePaths = (_a = props.slowTreeStructureCount) !== null && _a !== void 0 ? _a : 0;
175
+ const slowBlobParseCodePaths = (_b = props.slowBlobStructureCount) !== null && _b !== void 0 ? _b : 0;
181
176
  if (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {
182
177
  logger.sendErrorEvent({
183
178
  eventName: "SlowSnapshotParseCodePaths",
@@ -276,8 +271,8 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
276
271
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
277
272
  putInCache(valueWithEpoch);
278
273
  }
279
- event.end(Object.assign({ trees, blobs: (_g = (_f = snapshot.blobs) === null || _f === void 0 ? void 0 : _f.size) !== null && _g !== void 0 ? _g : 0, leafNodes: numBlobs, encodedBlobsSize,
280
- sequenceNumber, ops: (_j = (_h = snapshot.ops) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0, slowTreeStructureCount: (_k = snapshot.slowTreeStructureCount) !== null && _k !== void 0 ? _k : 0, slowBlobStructureCount: (_l = snapshot.slowBlobStructureCount) !== null && _l !== void 0 ? _l : 0, userOps: (_o = (_m = snapshot.ops) === null || _m === void 0 ? void 0 : _m.filter((op) => isRuntimeMessage(op)).length) !== null && _o !== void 0 ? _o : 0, headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,
274
+ event.end(Object.assign(Object.assign({ trees, blobs: (_g = (_f = snapshot.blobs) === null || _f === void 0 ? void 0 : _f.size) !== null && _g !== void 0 ? _g : 0, leafNodes: numBlobs, encodedBlobsSize,
275
+ sequenceNumber, ops: (_j = (_h = snapshot.ops) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : 0, userOps: (_l = (_k = snapshot.ops) === null || _k === void 0 ? void 0 : _k.filter((op) => isRuntimeMessage(op)).length) !== null && _l !== void 0 ? _l : 0, headers: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,
281
276
  // Interval between the first fetch until the last byte of the last redirect.
282
277
  redirectTime,
283
278
  // Interval between start and finish of the domain name lookup for the resource.
@@ -313,7 +308,7 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, storageTokenFetcher, sna
313
308
  // Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,
314
309
  // Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate
315
310
  // if the permission has changed.
316
- sltelemetry: odspResponse.headers.get("x-fluid-sltelemetry") }, propsToLog));
311
+ sltelemetry: odspResponse.headers.get("x-fluid-sltelemetry") }, propsToLog), parsedSnapshotContents.content.telemetryProps));
317
312
  return snapshot;
318
313
  }).catch((error) => {
319
314
  // We hit these errors in stress tests, under load