@fluidframework/odsp-driver 2.2.0 → 2.3.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.
- package/CHANGELOG.md +4 -0
- package/dist/ReadBufferUtils.d.ts.map +1 -1
- package/dist/ReadBufferUtils.js +0 -1
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/WriteBufferUtils.d.ts.map +1 -1
- package/dist/WriteBufferUtils.js +0 -2
- package/dist/WriteBufferUtils.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +2 -18
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +1 -3
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +0 -2
- package/dist/createNewUtils.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +1 -2
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.js +0 -1
- package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/dist/odspDelayLoadedDeltaStream.js +0 -2
- package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +1 -4
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +1 -6
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +0 -2
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +1 -2
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +1 -5
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +0 -1
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/odspUrlHelper.js +1 -5
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +0 -9
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/ReadBufferUtils.d.ts.map +1 -1
- package/lib/ReadBufferUtils.js +0 -1
- package/lib/ReadBufferUtils.js.map +1 -1
- package/lib/WriteBufferUtils.d.ts.map +1 -1
- package/lib/WriteBufferUtils.js +0 -2
- package/lib/WriteBufferUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +2 -18
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +1 -3
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +0 -2
- package/lib/createNewUtils.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +1 -2
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.js +0 -1
- package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
- package/lib/odspDelayLoadedDeltaStream.js +0 -2
- package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +1 -4
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +1 -6
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/lib/odspDocumentStorageServiceBase.js +0 -2
- package/lib/odspDocumentStorageServiceBase.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +1 -2
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +1 -5
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +0 -1
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUrlHelper.d.ts.map +1 -1
- package/lib/odspUrlHelper.js +1 -5
- package/lib/odspUrlHelper.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +0 -9
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +18 -17
- package/src/ReadBufferUtils.ts +1 -2
- package/src/WriteBufferUtils.ts +2 -4
- package/src/compactSnapshotParser.ts +14 -28
- package/src/compactSnapshotWriter.ts +2 -4
- package/src/createNewUtils.ts +2 -4
- package/src/fetchSnapshot.ts +1 -2
- package/src/localOdspDriver/localOdspDeltaStorageService.ts +1 -2
- package/src/odspDelayLoadedDeltaStream.ts +2 -4
- package/src/odspDeltaStorageService.ts +2 -4
- package/src/odspDocumentDeltaConnection.ts +3 -8
- package/src/odspDocumentStorageServiceBase.ts +2 -4
- package/src/odspDriverUrlResolver.ts +1 -2
- package/src/odspSnapshotParser.ts +4 -8
- package/src/odspSummaryUploadManager.ts +1 -2
- package/src/odspUrlHelper.ts +4 -8
- package/src/packageVersion.ts +1 -1
- package/src/zipItDataRepresentationUtils.ts +9 -18
- package/tsconfig.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadBufferUtils.d.ts","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,UAAU;IAOV,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAN/C,SAAS,CAAC,KAAK,SAAK;IAEpB,IAAW,MAAM,IAAI,UAAU,CAE9B;gBAE8B,IAAI,EAAE,UAAU;IAO/C,IAAW,GAAG,IAAI,OAAO,CAExB;IACD,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,SAAS,SAAI,GAAG,MAAM;
|
|
1
|
+
{"version":3,"file":"ReadBufferUtils.d.ts","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;GAGG;AACH,qBAAa,UAAU;IAOV,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,UAAU;IAN/C,SAAS,CAAC,KAAK,SAAK;IAEpB,IAAW,MAAM,IAAI,UAAU,CAE9B;gBAE8B,IAAI,EAAE,UAAU;IAO/C,IAAW,GAAG,IAAI,OAAO,CAExB;IACD,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD,IAAW,MAAM,IAAI,MAAM,CAE1B;IAEM,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU;IAI7C,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,SAAS,SAAI,GAAG,MAAM;IAc3B,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAKjC"}
|
package/dist/ReadBufferUtils.js
CHANGED
|
@@ -43,7 +43,6 @@ class ReadBuffer {
|
|
|
43
43
|
let length = lengthArg;
|
|
44
44
|
while (length > 0) {
|
|
45
45
|
(0, internal_1.assert)(!this.eof, 0x223 /* "unexpected end of buffer" */);
|
|
46
|
-
// TODO Why are we non null asserting here?
|
|
47
46
|
res += this.data[this.index] * multiplier;
|
|
48
47
|
this.index++;
|
|
49
48
|
multiplier *= 256;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadBufferUtils.js","sourceRoot":"","sources":["../src/ReadBufferUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA6D;AAE7D;;;GAGG;AACH,MAAa,UAAU;IAGtB,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAED,YAA+B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;QANrC,UAAK,GAAG,CAAC,CAAC;QAOnB,4DAA4D;QAC5D,+DAA+D;QAC/D,8DAA8D;QAC9D,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IACxC,CAAC;IACD,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;IACzB,CAAC;IAEM,KAAK,CAAC,KAAa,EAA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AC;IAEM,KAAK;QACX,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAChB,CAAC;IAEM,IAAI,CAAC,SAAS,GAAG,CAAC;QACxB,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,IAAA,iBAAM,EAAC,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAC1D,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC;YAC1C,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,UAAU,IAAI,GAAG,CAAC;YAClB,MAAM,EAAE,CAAC;QACV,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IAEM,IAAI,CAAC,MAAc;QACzB,IAAA,iBAAM,EAAC,MAAM,IAAI,CAAC,EAAE,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK,IAAI,MAAM,CAAC;QACrB,IAAA,iBAAM,EAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;IAClF,CAAC;CACD;AAnDD,gCAmDC","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\";\n\n/**\n * Buffer class, used to sequentially read data.\n * Used by tree code to reconstruct a tree from binary representation.\n */\nexport class ReadBuffer {\n\tprotected index = 0;\n\n\tpublic get buffer(): Uint8Array {\n\t\treturn this.data;\n\t}\n\n\tconstructor(protected readonly data: Uint8Array) {\n\t\t// BlobShallowCopy will return to users parts of this array.\n\t\t// We need to ensure that nobody can change it, as it will have\n\t\t// catastrophic result and will be really hard to investigate.\n\t\tObject.freeze(data.buffer);\n\t}\n\n\tpublic get eof(): boolean {\n\t\treturn this.index === this.data.length;\n\t}\n\tpublic get pos(): number {\n\t\treturn this.index;\n\t}\n\tpublic get length(): number {\n\t\treturn this.data.length;\n\t}\n\n\tpublic slice(start: number, end: number): Uint8Array {\n\t\treturn this.data.slice(start, end);\n\t}\n\n\tpublic reset(): void {\n\t\tthis.index = 0;\n\t}\n\n\tpublic read(lengthArg = 1): number {\n\t\tlet res = 0;\n\t\tlet multiplier = 1;\n\t\tlet length = lengthArg;\n\t\twhile (length > 0) {\n\t\t\tassert(!this.eof, 0x223 /* \"unexpected end of buffer\" */);\n\t\t\tres += this.data[this.index] * multiplier;\n\t\t\tthis.index++;\n\t\t\tmultiplier *= 256;\n\t\t\tlength--;\n\t\t}\n\t\treturn res;\n\t}\n\n\tpublic skip(length: number): void {\n\t\tassert(length >= 0, 0x224 /* \"Skip length should be positive\" */);\n\t\tthis.index += length;\n\t\tassert(this.index <= this.data.length, 0x3dc /* skipping past size of buffer */);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteBufferUtils.d.ts","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKN,QAAQ,EAGR,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAwB;IACnD,SAAS,CAAC,KAAK,SAAK;IAEpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"WriteBufferUtils.d.ts","sourceRoot":"","sources":["../src/WriteBufferUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAKN,QAAQ,EAGR,MAAM,mCAAmC,CAAC;AAE3C;;;GAGG;AACH,qBAAa,WAAW;IACvB,SAAS,CAAC,IAAI,CAAC,EAAE,UAAU,CAAwB;IACnD,SAAS,CAAC,KAAK,SAAK;IAEpB,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiB3B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,IAAI;IAW3C,IAAI,IAAI,UAAU;CAQzB;AAwDD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAejD;AA+HD,cAAM,kBAAmB,SAAQ,QAAQ;;IAKjC,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;CAG3C;AAED,qBAAa,qBAAsB,SAAQ,kBAAkB;;IAKrD,SAAS,IAAI,UAAU;CAK9B"}
|
package/dist/WriteBufferUtils.js
CHANGED
|
@@ -25,7 +25,6 @@ class WriteBuffer {
|
|
|
25
25
|
let index = 0;
|
|
26
26
|
const oldData = this.data;
|
|
27
27
|
while (index < length) {
|
|
28
|
-
// TODO Why are we non null asserting here?
|
|
29
28
|
newData[index] = oldData[index];
|
|
30
29
|
index++;
|
|
31
30
|
}
|
|
@@ -218,7 +217,6 @@ function serializeNodeCore(buffer, nodeCore, dictionary) {
|
|
|
218
217
|
}
|
|
219
218
|
}
|
|
220
219
|
else if (typeof child === "boolean") {
|
|
221
|
-
// TODO Why are we non null asserting here?
|
|
222
220
|
buffer.write(boolToCodeMap[child ? 1 : 0]);
|
|
223
221
|
}
|
|
224
222
|
else {
|
|
@@ -1 +1 @@
|
|
|
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;IAuCrB,CAAC;IArCU,IAAI,CAAC,IAAY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AS,EAAE,CAAC;YACvC,2CAA2C;YAC3C,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;QAC7C,CAAC;aAAM,CAAC;YACP,IAAA,iBAAM,EAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAChE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtB,yBAAyB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YAC9D,CAAC;iBAAM,CAAC;gBACP,eAAe,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YACxC,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAED,MAAM,kBAAmB,SAAQ,0CAAQ;IACxC;QACC,KAAK,EAAE,CAAC;IACT,CAAC;IAEM,SAAS,CAAC,MAAmB;QACnC,iBAAiB,CAAC,MAAM,EAAE,IAAI,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\t// TODO Why are we non null asserting here?\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\t// TODO Why are we non null asserting here?\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,CAAC,CAAC;gBAChC,KAAK,EAAE,CAAC;YACT,CAAC;YACD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC;QACnC,IAAI,CAAC,KAAK,EAAE,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAe,EAAE,SAAS,GAAG,CAAC;QAC1C,IAAI,IAAI,GAAG,OAAO,CAAC;QACnB,IAAI,MAAM,GAAG,SAAS,CAAC;QACvB,O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,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,SAAS,EAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAgB/E,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;
|
|
1
|
+
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,SAAS,EAGT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAgB/E,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;GAIG;AACH,MAAM,WAAW,0BAA2B,SAAQ,SAAS;IAC5D,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AA0ND;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,mBAAmB,GACzB,0BAA0B,CA8C5B"}
|
|
@@ -39,9 +39,7 @@ function readBlobSection(node) {
|
|
|
39
39
|
*/
|
|
40
40
|
slowBlobStructureCount += 1;
|
|
41
41
|
const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(blob);
|
|
42
|
-
// TODO why are we non null asserting here?
|
|
43
42
|
(0, zipItDataRepresentationUtils_js_1.assertBlobCoreInstance)(records.data, "data should be of BlobCore type");
|
|
44
|
-
// TODO why are we non null asserting here?
|
|
45
43
|
const id = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.id, "blob id should be string");
|
|
46
44
|
blobContents.set(id, records.data.arrayBuffer);
|
|
47
45
|
}
|
|
@@ -56,9 +54,7 @@ function readOpsSection(node) {
|
|
|
56
54
|
(0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(node, "Deltas should be of type NodeCore");
|
|
57
55
|
const ops = [];
|
|
58
56
|
const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(node);
|
|
59
|
-
// TODO Why are we non null asserting here?
|
|
60
57
|
(0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.firstSequenceNumber, "Seq number should be a number");
|
|
61
|
-
// TODO Why are we non null asserting here?
|
|
62
58
|
(0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(records.deltas, "Deltas should be a Node");
|
|
63
59
|
for (let i = 0; i < records.deltas.length; ++i) {
|
|
64
60
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
@@ -67,9 +63,7 @@ function readOpsSection(node) {
|
|
|
67
63
|
// Due to a bug at service side, in an edge case service was serializing deltas even
|
|
68
64
|
// when there are no ops. So just make the code resilient to that bug. Service has also
|
|
69
65
|
// fixed that bug.
|
|
70
|
-
(0, internal_1.assert)(
|
|
71
|
-
// Non null asserting here because of the length check
|
|
72
|
-
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" */);
|
|
73
67
|
return ops;
|
|
74
68
|
}
|
|
75
69
|
/**
|
|
@@ -158,7 +152,6 @@ function readTreeSection(node) {
|
|
|
158
152
|
(0, internal_1.assert)(records.unreferenced, 0x281 /* "Unreferenced if present should be true" */);
|
|
159
153
|
snapshotTree.unreferenced = true;
|
|
160
154
|
}
|
|
161
|
-
// TODO Why are we non null asserting here?
|
|
162
155
|
const path = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.name, "Path name should be string");
|
|
163
156
|
if (records.value !== undefined) {
|
|
164
157
|
snapshotTree.blobs[path] = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.value, "Blob value should be string");
|
|
@@ -170,7 +163,6 @@ function readTreeSection(node) {
|
|
|
170
163
|
trees[path] = result.snapshotTree;
|
|
171
164
|
if (records.groupId !== undefined) {
|
|
172
165
|
const groupId = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.groupId, "groupId should be a string");
|
|
173
|
-
// Non null asserting since trees[path] is already created
|
|
174
166
|
trees[path].groupId = groupId;
|
|
175
167
|
treeStructureCountWithGroupId++;
|
|
176
168
|
}
|
|
@@ -190,12 +182,9 @@ function readTreeSection(node) {
|
|
|
190
182
|
function readSnapshotSection(node) {
|
|
191
183
|
(0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(node, "Snapshot should be of type NodeCore");
|
|
192
184
|
const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(node);
|
|
193
|
-
// TODO Why are we non null asserting here?
|
|
194
185
|
(0, zipItDataRepresentationUtils_js_1.assertNodeCoreInstance)(records.treeNodes, "TreeNodes should be of type NodeCore");
|
|
195
|
-
// TODO Why are we non null asserting here?
|
|
196
186
|
(0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.sequenceNumber, "sequenceNumber should be of type number");
|
|
197
187
|
const { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } = readTreeSection(records.treeNodes);
|
|
198
|
-
// TODO Why are we non null asserting here?
|
|
199
188
|
snapshotTree.id = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.id, "snapshotId should be string");
|
|
200
189
|
const sequenceNumber = records.sequenceNumber.valueOf();
|
|
201
190
|
return {
|
|
@@ -216,9 +205,7 @@ function parseCompactSnapshotResponse(buffer, logger) {
|
|
|
216
205
|
(0, internal_1.assert)(builder.length === 1, 0x219 /* "1 root should be there" */);
|
|
217
206
|
const root = builder.getNode(0);
|
|
218
207
|
const records = (0, zipItDataRepresentationUtils_js_1.getNodeProps)(root);
|
|
219
|
-
// TODO Why are we non null asserting here?
|
|
220
208
|
const mrv = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.mrv, "minReadVersion should be string");
|
|
221
|
-
// TODO Why are we non null asserting here?
|
|
222
209
|
const cv = (0, zipItDataRepresentationUtils_js_1.getStringInstance)(records.cv, "createVersion should be string");
|
|
223
210
|
if (records.lsn !== undefined) {
|
|
224
211
|
(0, zipItDataRepresentationUtils_js_1.assertNumberInstance)(records.lsn, "lsn should be a number");
|
|
@@ -226,10 +213,7 @@ function parseCompactSnapshotResponse(buffer, logger) {
|
|
|
226
213
|
(0, internal_1.assert)(Number.parseFloat(exports.snapshotMinReadVersion) >= Number.parseFloat(mrv), 0x20f /* "Driver min read version should >= to server minReadVersion" */);
|
|
227
214
|
(0, internal_1.assert)(Number.parseFloat(cv) >= Number.parseFloat(exports.snapshotMinReadVersion), 0x210 /* "Snapshot should be created with minReadVersion or above" */);
|
|
228
215
|
(0, internal_1.assert)(exports.currentReadVersion === cv, 0x2c2 /* "Create Version should be equal to currentReadVersion" */);
|
|
229
|
-
const [snapshot, durationSnapshotTree] = (0, odspUtils_js_1.measure)(() =>
|
|
230
|
-
// TODO Why are we non null asserting here?
|
|
231
|
-
readSnapshotSection(records.snapshot));
|
|
232
|
-
// TODO Why are we non null asserting here?
|
|
216
|
+
const [snapshot, durationSnapshotTree] = (0, odspUtils_js_1.measure)(() => readSnapshotSection(records.snapshot));
|
|
233
217
|
const [blobContents, durationBlobs] = (0, odspUtils_js_1.measure)(() => readBlobSection(records.blobs));
|
|
234
218
|
return {
|
|
235
219
|
...snapshot,
|
|
@@ -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,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACzB,IAAA,wDAAsB,EAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;QAEpD;;;;WAIG;QACH,IACC,IAAI,CAAC,MAAM,KAAK,CAAC;YACjB,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,IAAI;YAC/B,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,MAAM,EAChC,CAAC;YACF,oBAAoB;YACpB,iBAAiB;YACjB,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACP;;eAEG;YACH,sBAAsB,IAAI,CAAC,CAAC;YAC5B,MAAM,OAAO,GAAG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M,CAAC,YAAY,EAAE,aAAa,CAAC,GAAG,IAAA,sBAAO,EAAC,GAAG,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,KAAM,CAAC,CAAC,CAAC;IAErF,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;AArDD,oEAqDC","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\t// TODO why are we non null asserting here?\n\t\t\tassertBlobCoreInstance(records.data!, \"data should be of BlobCore type\");\n\t\t\t// TODO why are we non null asserting here?\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\t// TODO Why are we non null asserting here?\n\tassertNumberInstance(records.firstSequenceNumber!, \"Seq number should be a number\");\n\t// TODO Why are we non null asserting here?\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\t// Non null asserting here because of the length check\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\t// TODO Why are we non null asserting here?\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\t// Non null asserting since trees[path] is already created\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\t// TODO Why are we non null asserting here?\n\tassertNodeCoreInstance(records.treeNodes!, \"TreeNodes should be of type NodeCore\");\n\t// TODO Why are we non null asserting here?\n\tassertNumberInstance(records.sequenceNumber!, \"sequenceNumber should be of type number\");\n\tconst { snapshotTree, slowTreeStructureCount, treeStructureCountWithGroupId } =\n\t\treadTreeSection(records.treeNodes);\n\t// TODO Why are we non null asserting here?\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\t// TODO Why are we non null asserting here?\n\tconst mrv = getStringInstance(records.mrv!, \"minReadVersion should be string\");\n\t// TODO Why are we non null asserting here?\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\t// TODO Why are we non null asserting here?\n\t\treadSnapshotSection(records.snapshot!),\n\t);\n\t// TODO Why are we non null asserting here?\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,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+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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,SAAS,EAIT,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,SAAS,EAIT,MAAM,6CAA6C,CAAC;AAsIrD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,SAAS,GAAG,UAAU,CAgChF"}
|
|
@@ -104,7 +104,6 @@ function writeSnapshotSection(rootNode, snapshotTree, snapshotSequenceNumber) {
|
|
|
104
104
|
function writeOpsSection(rootNode, ops) {
|
|
105
105
|
let firstSequenceNumber;
|
|
106
106
|
if (ops.length > 0) {
|
|
107
|
-
// Non null asserting here because of the length check above
|
|
108
107
|
firstSequenceNumber = ops[0].sequenceNumber;
|
|
109
108
|
}
|
|
110
109
|
if (firstSequenceNumber !== undefined) {
|
|
@@ -132,8 +131,7 @@ function convertToCompactSnapshot(snapshotContents) {
|
|
|
132
131
|
if (latestSequenceNumber === undefined) {
|
|
133
132
|
latestSequenceNumber =
|
|
134
133
|
snapshotContents.ops.length > 0
|
|
135
|
-
?
|
|
136
|
-
snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber
|
|
134
|
+
? snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber
|
|
137
135
|
: snapshotContents.sequenceNumber;
|
|
138
136
|
}
|
|
139
137
|
writeSnapshotProps(rootNode, latestSequenceNumber);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotWriter.js","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC9D,kEAA6D;AAQ7D,+DAA8D;AAC9D,yEAAoE;AACpE,uFAM2C;AAE3C;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAc,EAAE,oBAA4B;IACvE,IAAA,mDAAiB,EAAC,IAAI,EAAE,KAAK,EAAE,iDAAsB,CAAC,CAAC;IACvD,IAAA,mDAAiB,EAAC,IAAI,EAAE,IAAI,EAAE,iDAAsB,CAAC,CAAC;IACtD,IAAA,mDAAiB,EAAC,IAAI,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;AACtD,CAAC;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CACzB,YAAsB,EACtB,KAAuC;IAEvC,YAAY,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,KAAK,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,OAA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CAC3C,CAAC;IAEF,IAAI,oBAAoB,GAAG,gBAAgB,CAAC,oBAAoB,CAAC;IACjE,IAAI,oBAAoB,KAAK,SAAS,EAAE,CAAC;QACxC,oBAAoB;YACnB,gBAAgB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;gBAC9B,CAAC,CAAC,4DAA4D;oBAC7D,gBAAgB,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,cAAc;gBACtE,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC;IACrC,CAAC;IAED,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEnD,oBAAoB,CACnB,QAAQ,EACR,gBAAgB,CAAC,YAAY,EAC7B,gBAAgB,CAAC,cAAc,CAC/B,CAAC;IAEF,YAAY;IACZ,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAE3D,2BAA2B;IAC3B,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC;AAjCD,4DAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tIBlob,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { TreeBuilderSerializer } from \"./WriteBufferUtils.js\";\nimport { snapshotMinReadVersion } from \"./compactSnapshotParser.js\";\nimport {\n\tNodeCore,\n\taddBoolProperty,\n\taddDictionaryStringProperty,\n\taddNumberProperty,\n\taddStringProperty,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Writes header section of the snapshot.\n * @param node - snapshot node to serialize to\n * @param latestSequenceNumber - latest seq number of the container.\n */\nfunction writeSnapshotProps(node: NodeCore, latestSequenceNumber: number): void {\n\taddStringProperty(node, \"mrv\", snapshotMinReadVersion);\n\taddStringProperty(node, \"cv\", snapshotMinReadVersion);\n\taddNumberProperty(node, \"lsn\", latestSequenceNumber);\n}\n\n/**\n * Represents blobs in the tree.\n * @param snapshotNode - node to serialize to.\n * @param blobs - blobs that is being serialized\n */\nfunction writeBlobsSection(\n\tsnapshotNode: NodeCore,\n\tblobs: Map<string, IBlob | ArrayBuffer>,\n): void {\n\tsnapshotNode.addDictionaryString(\"blobs\");\n\tconst blobsNode = snapshotNode.addNode(\"list\");\n\tfor (const [storageBlobId, blob] of blobs) {\n\t\tconst blobNode = blobsNode.addNode();\n\t\taddDictionaryStringProperty(blobNode, \"id\", storageBlobId);\n\t\tblobNode.addString(\"data\");\n\t\tif (blob instanceof ArrayBuffer) {\n\t\t\tblobNode.addBlob(new Uint8Array(blob));\n\t\t} else {\n\t\t\tblobNode.addBlob(new Uint8Array(stringToBuffer(blob.contents, blob.encoding ?? \"utf8\")));\n\t\t}\n\t}\n}\n\n/**\n * Represents and serializes tree part of the snapshot\n * @param snapshotNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n */\nfunction writeTreeSection(snapshotNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tsnapshotNode.addDictionaryString(\"treeNodes\");\n\tconst treesNode = snapshotNode.addNode(\"list\");\n\twriteTreeSectionCore(treesNode, snapshotTree);\n}\n\nfunction writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tfor (const [path, value] of Object.entries(snapshotTree.trees)) {\n\t\tconst treeNode = treesNode.addNode();\n\t\t// Many leaf nodes in the tree have same names like \"content\", \"body\", \"header\"\n\t\t// We could be smarter here and not use dictionary where we are sure reuse is unlikely, but\n\t\t// it does not feel like it's worth it.\n\t\taddDictionaryStringProperty(treeNode, \"name\", path);\n\t\tif (snapshotTree.unreferenced) {\n\t\t\taddBoolProperty(treeNode, \"unreferenced\", snapshotTree.unreferenced);\n\t\t}\n\t\t// Only write children prop if either blobs or trees are present.\n\t\tif (Object.keys(value.blobs).length > 0 || Object.keys(value.trees).length > 0) {\n\t\t\ttreeNode.addDictionaryString(\"children\");\n\t\t\tconst childNode = treeNode.addNode(\"list\");\n\t\t\twriteTreeSectionCore(childNode, value);\n\t\t}\n\t\tif (value.groupId !== undefined) {\n\t\t\taddDictionaryStringProperty(treeNode, \"groupId\", value.groupId);\n\t\t}\n\t}\n\n\tif (snapshotTree.blobs) {\n\t\tfor (const [path, id] of Object.entries(snapshotTree.blobs)) {\n\t\t\tconst blobNode = treesNode.addNode();\n\t\t\taddDictionaryStringProperty(blobNode, \"name\", path);\n\t\t\taddDictionaryStringProperty(blobNode, \"value\", id);\n\t\t}\n\t}\n}\n\n/**\n * Represents (serializes) snapshot tree as generalizes tree\n * @param rootNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n * @param blobs - blobs mapping of the snapshot\n * @param snapshotSequenceNumber - seq number at which snapshot is taken\n */\nfunction writeSnapshotSection(\n\trootNode: NodeCore,\n\tsnapshotTree: ISnapshotTree,\n\tsnapshotSequenceNumber: number,\n): void {\n\trootNode.addDictionaryString(\"snapshot\");\n\tconst snapshotNode = rootNode.addNode();\n\n\tconst snapshotId = snapshotTree.id;\n\tassert(snapshotId !== undefined, 0x21b /* \"Snapshot id should be provided\" */);\n\taddStringProperty(snapshotNode, \"id\", snapshotId);\n\taddStringProperty(snapshotNode, \"message\", `Snapshot@${snapshotSequenceNumber}`);\n\taddNumberProperty(snapshotNode, \"sequenceNumber\", snapshotSequenceNumber);\n\n\t// Add Trees\n\twriteTreeSection(snapshotNode, snapshotTree);\n}\n\n/**\n * Represents ops in the tree.\n * @param rootNode - node to serialize to.\n * @param ops - ops that is being serialized\n */\nfunction writeOpsSection(rootNode: NodeCore, ops: ISequencedDocumentMessage[]): void {\n\tlet firstSequenceNumber: number | undefined;\n\tif (ops.length > 0) {\n\t\t// Non null asserting here because of the length check above\n\t\tfirstSequenceNumber = ops[0]!.sequenceNumber;\n\t}\n\tif (firstSequenceNumber !== undefined) {\n\t\trootNode.addDictionaryString(\"deltas\");\n\t\tconst opsNode = rootNode.addNode();\n\t\taddNumberProperty(opsNode, \"firstSequenceNumber\", firstSequenceNumber);\n\t\topsNode.addDictionaryString(\"deltas\");\n\t\tconst deltaNode = opsNode.addNode(\"list\");\n\t\tfor (const op of ops) {\n\t\t\tdeltaNode.addString(JSON.stringify(op));\n\t\t}\n\t}\n}\n\n/**\n * Converts trees/blobs/ops to binary compact representation.\n * @param snapshotContents - snapshot tree contents to serialize\n * @returns ReadBuffer - binary representation of the data.\n */\nexport function convertToCompactSnapshot(snapshotContents: ISnapshot): Uint8Array {\n\tconst builder = new TreeBuilderSerializer();\n\t// Create the root node.\n\tconst rootNode = builder.addNode();\n\tassert(\n\t\tsnapshotContents.sequenceNumber !== undefined,\n\t\t0x21c /* \"Seq number should be provided\" */,\n\t);\n\n\tlet latestSequenceNumber = snapshotContents.latestSequenceNumber;\n\tif (latestSequenceNumber === undefined) {\n\t\tlatestSequenceNumber =\n\t\t\tsnapshotContents.ops.length > 0\n\t\t\t\t? // Non null asserting here because of the length check above\n\t\t\t\t\tsnapshotContents.ops[snapshotContents.ops.length - 1]!.sequenceNumber\n\t\t\t\t: snapshotContents.sequenceNumber;\n\t}\n\n\twriteSnapshotProps(rootNode, latestSequenceNumber);\n\n\twriteSnapshotSection(\n\t\trootNode,\n\t\tsnapshotContents.snapshotTree,\n\t\tsnapshotContents.sequenceNumber,\n\t);\n\n\t// Add Blobs\n\twriteBlobsSection(rootNode, snapshotContents.blobContents);\n\n\t// Then write the ops node.\n\twriteOpsSection(rootNode, snapshotContents.ops);\n\n\treturn builder.serialize();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compactSnapshotWriter.js","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAC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QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC5B,CAAC;AAhCD,4DAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISnapshot,\n\tIBlob,\n\tISnapshotTree,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { TreeBuilderSerializer } from \"./WriteBufferUtils.js\";\nimport { snapshotMinReadVersion } from \"./compactSnapshotParser.js\";\nimport {\n\tNodeCore,\n\taddBoolProperty,\n\taddDictionaryStringProperty,\n\taddNumberProperty,\n\taddStringProperty,\n} from \"./zipItDataRepresentationUtils.js\";\n\n/**\n * Writes header section of the snapshot.\n * @param node - snapshot node to serialize to\n * @param latestSequenceNumber - latest seq number of the container.\n */\nfunction writeSnapshotProps(node: NodeCore, latestSequenceNumber: number): void {\n\taddStringProperty(node, \"mrv\", snapshotMinReadVersion);\n\taddStringProperty(node, \"cv\", snapshotMinReadVersion);\n\taddNumberProperty(node, \"lsn\", latestSequenceNumber);\n}\n\n/**\n * Represents blobs in the tree.\n * @param snapshotNode - node to serialize to.\n * @param blobs - blobs that is being serialized\n */\nfunction writeBlobsSection(\n\tsnapshotNode: NodeCore,\n\tblobs: Map<string, IBlob | ArrayBuffer>,\n): void {\n\tsnapshotNode.addDictionaryString(\"blobs\");\n\tconst blobsNode = snapshotNode.addNode(\"list\");\n\tfor (const [storageBlobId, blob] of blobs) {\n\t\tconst blobNode = blobsNode.addNode();\n\t\taddDictionaryStringProperty(blobNode, \"id\", storageBlobId);\n\t\tblobNode.addString(\"data\");\n\t\tif (blob instanceof ArrayBuffer) {\n\t\t\tblobNode.addBlob(new Uint8Array(blob));\n\t\t} else {\n\t\t\tblobNode.addBlob(new Uint8Array(stringToBuffer(blob.contents, blob.encoding ?? \"utf8\")));\n\t\t}\n\t}\n}\n\n/**\n * Represents and serializes tree part of the snapshot\n * @param snapshotNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n */\nfunction writeTreeSection(snapshotNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tsnapshotNode.addDictionaryString(\"treeNodes\");\n\tconst treesNode = snapshotNode.addNode(\"list\");\n\twriteTreeSectionCore(treesNode, snapshotTree);\n}\n\nfunction writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree): void {\n\tfor (const [path, value] of Object.entries(snapshotTree.trees)) {\n\t\tconst treeNode = treesNode.addNode();\n\t\t// Many leaf nodes in the tree have same names like \"content\", \"body\", \"header\"\n\t\t// We could be smarter here and not use dictionary where we are sure reuse is unlikely, but\n\t\t// it does not feel like it's worth it.\n\t\taddDictionaryStringProperty(treeNode, \"name\", path);\n\t\tif (snapshotTree.unreferenced) {\n\t\t\taddBoolProperty(treeNode, \"unreferenced\", snapshotTree.unreferenced);\n\t\t}\n\t\t// Only write children prop if either blobs or trees are present.\n\t\tif (Object.keys(value.blobs).length > 0 || Object.keys(value.trees).length > 0) {\n\t\t\ttreeNode.addDictionaryString(\"children\");\n\t\t\tconst childNode = treeNode.addNode(\"list\");\n\t\t\twriteTreeSectionCore(childNode, value);\n\t\t}\n\t\tif (value.groupId !== undefined) {\n\t\t\taddDictionaryStringProperty(treeNode, \"groupId\", value.groupId);\n\t\t}\n\t}\n\n\tif (snapshotTree.blobs) {\n\t\tfor (const [path, id] of Object.entries(snapshotTree.blobs)) {\n\t\t\tconst blobNode = treesNode.addNode();\n\t\t\taddDictionaryStringProperty(blobNode, \"name\", path);\n\t\t\taddDictionaryStringProperty(blobNode, \"value\", id);\n\t\t}\n\t}\n}\n\n/**\n * Represents (serializes) snapshot tree as generalizes tree\n * @param rootNode - tree node to serialize to\n * @param snapshotTree - snapshot tree that is being serialized\n * @param blobs - blobs mapping of the snapshot\n * @param snapshotSequenceNumber - seq number at which snapshot is taken\n */\nfunction writeSnapshotSection(\n\trootNode: NodeCore,\n\tsnapshotTree: ISnapshotTree,\n\tsnapshotSequenceNumber: number,\n): void {\n\trootNode.addDictionaryString(\"snapshot\");\n\tconst snapshotNode = rootNode.addNode();\n\n\tconst snapshotId = snapshotTree.id;\n\tassert(snapshotId !== undefined, 0x21b /* \"Snapshot id should be provided\" */);\n\taddStringProperty(snapshotNode, \"id\", snapshotId);\n\taddStringProperty(snapshotNode, \"message\", `Snapshot@${snapshotSequenceNumber}`);\n\taddNumberProperty(snapshotNode, \"sequenceNumber\", snapshotSequenceNumber);\n\n\t// Add Trees\n\twriteTreeSection(snapshotNode, snapshotTree);\n}\n\n/**\n * Represents ops in the tree.\n * @param rootNode - node to serialize to.\n * @param ops - ops that is being serialized\n */\nfunction writeOpsSection(rootNode: NodeCore, ops: ISequencedDocumentMessage[]): void {\n\tlet firstSequenceNumber: number | undefined;\n\tif (ops.length > 0) {\n\t\tfirstSequenceNumber = ops[0].sequenceNumber;\n\t}\n\tif (firstSequenceNumber !== undefined) {\n\t\trootNode.addDictionaryString(\"deltas\");\n\t\tconst opsNode = rootNode.addNode();\n\t\taddNumberProperty(opsNode, \"firstSequenceNumber\", firstSequenceNumber);\n\t\topsNode.addDictionaryString(\"deltas\");\n\t\tconst deltaNode = opsNode.addNode(\"list\");\n\t\tfor (const op of ops) {\n\t\t\tdeltaNode.addString(JSON.stringify(op));\n\t\t}\n\t}\n}\n\n/**\n * Converts trees/blobs/ops to binary compact representation.\n * @param snapshotContents - snapshot tree contents to serialize\n * @returns ReadBuffer - binary representation of the data.\n */\nexport function convertToCompactSnapshot(snapshotContents: ISnapshot): Uint8Array {\n\tconst builder = new TreeBuilderSerializer();\n\t// Create the root node.\n\tconst rootNode = builder.addNode();\n\tassert(\n\t\tsnapshotContents.sequenceNumber !== undefined,\n\t\t0x21c /* \"Seq number should be provided\" */,\n\t);\n\n\tlet latestSequenceNumber = snapshotContents.latestSequenceNumber;\n\tif (latestSequenceNumber === undefined) {\n\t\tlatestSequenceNumber =\n\t\t\tsnapshotContents.ops.length > 0\n\t\t\t\t? snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber\n\t\t\t\t: snapshotContents.sequenceNumber;\n\t}\n\n\twriteSnapshotProps(rootNode, latestSequenceNumber);\n\n\twriteSnapshotSection(\n\t\trootNode,\n\t\tsnapshotContents.snapshotTree,\n\t\tsnapshotContents.sequenceNumber,\n\t);\n\n\t// Add Blobs\n\twriteBlobsSection(rootNode, snapshotContents.blobContents);\n\n\t// Then write the ops node.\n\twriteOpsSection(rootNode, snapshotContents.ops);\n\n\treturn builder.serialize();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,YAAY,EAGZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAMvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACN,mBAAmB,EAInB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK5D;;GAEG;AACH,wBAAgB,yCAAyC,CACxD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,GACZ,SAAS,CAiBX;
|
|
1
|
+
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,YAAY,EAGZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAMvF,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACN,mBAAmB,EAInB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK5D;;GAEG;AACH,wBAAgB,yCAAyC,CACxD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,GACZ,SAAS,CAiBX;AAiDD,wBAAgB,mCAAmC,CAClD,gBAAgB,EAAE,YAAY,GAC5B,mBAAmB,CA2BrB;AAiED,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,aAAa,EAAE,+BAA+B,CAAC;IAC/C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC,EAAE,OAAO,CAAC;IAChD,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;CAChD,GAAG,OAAO,CAAC,CAAC,CAAC,CA4Fb"}
|
package/dist/createNewUtils.js
CHANGED
|
@@ -44,7 +44,6 @@ function convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobs) {
|
|
|
44
44
|
};
|
|
45
45
|
const keys = Object.keys(summary.tree);
|
|
46
46
|
for (const key of keys) {
|
|
47
|
-
// Non null asserting for now this should change to Object.entries
|
|
48
47
|
const summaryObject = summary.tree[key];
|
|
49
48
|
switch (summaryObject.type) {
|
|
50
49
|
case driver_definitions_1.SummaryType.Tree: {
|
|
@@ -111,7 +110,6 @@ function convertSummaryToSnapshotTreeForCreateNew(summary) {
|
|
|
111
110
|
const keys = Object.keys(summary.tree);
|
|
112
111
|
for (const key of keys) {
|
|
113
112
|
(0, internal_1.assert)(!key.includes("/"), 0x9cc /* id should not include slashes */);
|
|
114
|
-
// Non null asserting for now this should change to Object.entries
|
|
115
113
|
const summaryObject = summary.tree[key];
|
|
116
114
|
let value;
|
|
117
115
|
// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkF;AAClF,kEAA8E;AAC9E,2EAK4C;AAE5C,oEAI+C;AAE/C,uEAGkD;AAClD,+BAAkC;AASlC,+EAAmE;AACnE,iDAAiF;AACjF,mDAA+C;AAE/C;;GAEG;AACH,SAAgB,yCAAyC,CACxD,OAAqB,EACrB,MAAc;IAEd,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IAClE,MAAM,kBAAkB,GAAG,IAAA,8CAAmC,EAAC,eAAe,CAAC,CAAC;IAChF,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;IACpD,MAAM,YAAY,GAAG,6CAA6C,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1F,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,iBAAiB,GAAc;QACpC,YAAY;QACZ,YAAY;QACZ,GAAG,EAAE,EAAE;QACP,cAAc;QACd,oBAAoB,EAAE,cAAc;QACpC,eAAe,EAAE,CAAC;KAClB,CAAC;IAEF,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AApBD,8FAoBC;AAED,SAAS,6CAA6C,CACrD,OAAqB,EACrB,KAA+B;IAE/B,MAAM,QAAQ,GAAkB;QAC/B,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,EAAE;QACT,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,OAAO,EAAE,OAAO,CAAC,OAAO;KACxB,CAAC;IACF,MAAM,IA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G,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAtGD,kEAsGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\ttype SummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetGitType,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./contracts.js\";\nimport { EpochTracker, FetchType } from \"./epochTracker.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./odspUtils.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\t// Non null asserting for now this should change to Object.entries\n\t\tconst summaryObject = summary.tree[key]!;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tassert(!key.includes(\"/\"), 0x9cc /* id should not include slashes */);\n\t\t// Non null asserting for now this should change to Object.entries\n\t\tconst summaryObject = summary.tree[key]!;\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: key,\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetAuthHeader: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t} = args;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\tconst authInBodyUrl = urlObj.href;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url: authInBodyUrl, method } },\n\t\t\t\t\ttelemetryName,\n\t\t\t\t);\n\t\t\t\tconst postBodyWithAuth =\n\t\t\t\t\t`--${formBoundary}\\r\\n` +\n\t\t\t\t\t`Authorization: ${authHeader}\\r\\n` +\n\t\t\t\t\t`X-HTTP-Method-Override: POST\\r\\n` +\n\t\t\t\t\t`Content-Type: application/json\\r\\n` +\n\t\t\t\t\t`_post: 1\\r\\n` +\n\t\t\t\t\t`\\r\\n${snapshotBody}\\r\\n` +\n\t\t\t\t\t`\\r\\n--${formBoundary}--`;\n\n\t\t\t\tlet postBody = snapshotBody;\n\t\t\t\t// We use the byte length of the post body to determine if we should use the multipart/form-data or not. This helps\n\t\t\t\t// in cases where the body contains data with different language where 1 char could be multiple code points.\n\t\t\t\tif (\n\t\t\t\t\tnew TextEncoder().encode(postBodyWithAuth).length <= maxUmpPostBodySize &&\n\t\t\t\t\tauthHeader?.startsWith(\"Bearer\")\n\t\t\t\t) {\n\t\t\t\t\turl = authInBodyUrl;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t\tpostBody = postBodyWithAuth;\n\t\t\t\t} else {\n\t\t\t\t\turl = initialUrl;\n\t\t\t\t\tconst authHeaderNoUmp = await getAuthHeader(\n\t\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\ttelemetryName,\n\t\t\t\t\t);\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...getHeadersWithAuth(authHeaderNoUmp),\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkF;AAClF,kEAA8E;AAC9E,2EAK4C;AAE5C,oEAI+C;AAE/C,uEAGkD;AAClD,+BAAkC;AASlC,+EAAmE;AACnE,iDAAi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,SAAS,GAAG,IAAI,CAAC;gBACjB,QAAQ,GAAG,gBAAgB,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACP,GAAG,GAAG,UAAU,CAAC;gBACjB,MAAM,eAAe,GAAG,MAAM,aAAa,CAC1C,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EACxC,aAAa,CACb,CAAC;gBACF,OAAO,GAAG;oBACT,GAAG,IAAA,gDAAkB,EAAC,eAAe,CAAC;oBACtC,cAAc,EAAE,kBAAkB;iBAClC,CAAC;gBACF,QAAQ,GAAG,YAAY,CAAC;YACzB,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,IAAA,4BAAY,EACvC,KAAK,IAAI,EAAE,CACV,YAAY,CAAC,mBAAmB,CAC/B,GAAG,EACH;gBACC,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,MAAM;aACN,EACD,SAAS,EACT,SAAS,CACT,EACF,aAAa,EACb,MAAM,CACN,CAAC;YAEF,wBAAwB,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAElD,KAAK,CAAC,GAAG,CAAC;gBACT,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAtGD,kEAsGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tISummaryBlob,\n\tISummaryTree,\n\ttype SummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetGitType,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./contracts.js\";\nimport { EpochTracker, FetchType } from \"./epochTracker.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./odspUtils.js\";\nimport { runWithRetry } from \"./retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tassert(!key.includes(\"/\"), 0x9cc /* id should not include slashes */);\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: key,\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetAuthHeader: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t} = args;\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\tconst authInBodyUrl = urlObj.href;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url: authInBodyUrl, method } },\n\t\t\t\t\ttelemetryName,\n\t\t\t\t);\n\t\t\t\tconst postBodyWithAuth =\n\t\t\t\t\t`--${formBoundary}\\r\\n` +\n\t\t\t\t\t`Authorization: ${authHeader}\\r\\n` +\n\t\t\t\t\t`X-HTTP-Method-Override: POST\\r\\n` +\n\t\t\t\t\t`Content-Type: application/json\\r\\n` +\n\t\t\t\t\t`_post: 1\\r\\n` +\n\t\t\t\t\t`\\r\\n${snapshotBody}\\r\\n` +\n\t\t\t\t\t`\\r\\n--${formBoundary}--`;\n\n\t\t\t\tlet postBody = snapshotBody;\n\t\t\t\t// We use the byte length of the post body to determine if we should use the multipart/form-data or not. This helps\n\t\t\t\t// in cases where the body contains data with different language where 1 char could be multiple code points.\n\t\t\t\tif (\n\t\t\t\t\tnew TextEncoder().encode(postBodyWithAuth).length <= maxUmpPostBodySize &&\n\t\t\t\t\tauthHeader?.startsWith(\"Bearer\")\n\t\t\t\t) {\n\t\t\t\t\turl = authInBodyUrl;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t\tpostBody = postBodyWithAuth;\n\t\t\t\t} else {\n\t\t\t\t\turl = initialUrl;\n\t\t\t\t\tconst authHeaderNoUmp = await getAuthHeader(\n\t\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\ttelemetryName,\n\t\t\t\t\t);\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...getHeadersWithAuth(authHeaderNoUmp),\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\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;AAIjD,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,MAAM,EACjB,iBAAiB,EAA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CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC5C;AAsCD,UAAU,UAAU;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG;IAAE,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAY3F;AAED,wBAAgB,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"}
|
package/dist/fetchSnapshot.js
CHANGED
|
@@ -299,8 +299,7 @@ async function fetchLatestSnapshotCore(odspResolvedUrl, getAuthHeader, snapshotO
|
|
|
299
299
|
!fetchSnapshotForLoadingGroup;
|
|
300
300
|
const sequenceNumber = snapshot.sequenceNumber ?? 0;
|
|
301
301
|
const seqNumberFromOps = snapshot.ops && snapshot.ops.length > 0
|
|
302
|
-
?
|
|
303
|
-
snapshot.ops[0].sequenceNumber - 1
|
|
302
|
+
? snapshot.ops[0].sequenceNumber - 1
|
|
304
303
|
: undefined;
|
|
305
304
|
if (!Number.isInteger(sequenceNumber) ||
|
|
306
305
|
(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)) {
|