@fluidframework/odsp-driver 0.59.4001 → 1.1.0-75972
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/.eslintrc.js +1 -1
- package/dist/compactSnapshotParser.d.ts +1 -1
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +7 -4
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +4 -3
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js.map +1 -1
- package/dist/createNewUtils.d.ts +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +1 -0
- package/dist/createNewUtils.js.map +1 -1
- package/dist/epochTracker.d.ts +3 -2
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +10 -4
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +7 -6
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +57 -31
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +18 -17
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +8 -4
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +2 -2
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +2 -3
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +13 -17
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspError.d.ts +3 -1
- package/dist/odspError.d.ts.map +1 -1
- package/dist/odspError.js +14 -5
- package/dist/odspError.js.map +1 -1
- package/dist/odspPublicUtils.d.ts +14 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts +2 -2
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +7 -4
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +1 -4
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUtils.d.ts +0 -7
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +4 -3
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts +1 -2
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/retryErrorsStorageAdapter.js +0 -3
- package/dist/retryErrorsStorageAdapter.js.map +1 -1
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/retryUtils.js +2 -3
- package/dist/retryUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +7 -4
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +4 -3
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/contracts.d.ts +1 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js.map +1 -1
- package/lib/createNewUtils.d.ts +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +1 -0
- package/lib/createNewUtils.js.map +1 -1
- package/lib/epochTracker.d.ts +3 -2
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +10 -4
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +7 -6
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +58 -33
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +18 -17
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +9 -5
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +2 -2
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +2 -3
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +13 -17
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspError.d.ts +3 -1
- package/lib/odspError.d.ts.map +1 -1
- package/lib/odspError.js +14 -5
- package/lib/odspError.js.map +1 -1
- package/lib/odspPublicUtils.d.ts +14 -0
- package/lib/odspPublicUtils.d.ts.map +1 -1
- package/lib/odspPublicUtils.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts +2 -2
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +5 -2
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +1 -4
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUtils.d.ts +0 -7
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +4 -3
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/retryErrorsStorageAdapter.d.ts +1 -2
- package/lib/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/lib/retryErrorsStorageAdapter.js +0 -3
- package/lib/retryErrorsStorageAdapter.js.map +1 -1
- package/lib/retryUtils.d.ts.map +1 -1
- package/lib/retryUtils.js +3 -4
- package/lib/retryUtils.js.map +1 -1
- package/package.json +15 -28
- package/src/compactSnapshotParser.ts +10 -4
- package/src/compactSnapshotWriter.ts +7 -4
- package/src/contracts.ts +1 -1
- package/src/createFile.ts +2 -2
- package/src/createNewUtils.ts +2 -1
- package/src/epochTracker.ts +10 -3
- package/src/fetchSnapshot.ts +113 -67
- package/src/index.ts +4 -0
- package/src/odspDocumentDeltaConnection.ts +18 -18
- package/src/odspDocumentService.ts +7 -3
- package/src/odspDocumentServiceFactoryCore.ts +4 -2
- package/src/odspDocumentStorageManager.ts +18 -21
- package/src/odspError.ts +23 -10
- package/src/odspPublicUtils.ts +17 -0
- package/src/odspSnapshotParser.ts +8 -3
- package/src/odspSummaryUploadManager.ts +1 -4
- package/src/odspUtils.ts +4 -11
- package/src/packageVersion.ts +1 -1
- package/src/retryErrorsStorageAdapter.ts +0 -8
- package/src/retryUtils.ts +3 -4
package/.eslintrc.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISnapshotContents } from "./
|
|
5
|
+
import { ISnapshotContents } from "./odspPublicUtils";
|
|
6
6
|
import { ReadBuffer } from "./ReadBufferUtils";
|
|
7
7
|
export declare const snapshotMinReadVersion = "1.0";
|
|
8
8
|
export declare const currentReadVersion = "1.0";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"compactSnapshotParser.d.ts","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAa/C,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAgGxC;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,UAAU,GAAG,iBAAiB,CA2BlF"}
|
|
@@ -100,13 +100,16 @@ function parseCompactSnapshotResponse(buffer) {
|
|
|
100
100
|
const builder = zipItDataRepresentationUtils_1.TreeBuilder.load(buffer);
|
|
101
101
|
(0, common_utils_1.assert)(builder.length === 1, 0x219 /* "1 root should be there" */);
|
|
102
102
|
const root = builder.getNode(0);
|
|
103
|
-
const records = (0, zipItDataRepresentationUtils_1.getAndValidateNodeProps)(root, ["mrv", "cv", "snapshot", "blobs", "deltas"], false);
|
|
103
|
+
const records = (0, zipItDataRepresentationUtils_1.getAndValidateNodeProps)(root, ["mrv", "cv", "lsn", "snapshot", "blobs", "deltas"], false);
|
|
104
104
|
(0, zipItDataRepresentationUtils_1.assertBlobCoreInstance)(records.mrv, "minReadVersion should be of BlobCore type");
|
|
105
105
|
(0, zipItDataRepresentationUtils_1.assertBlobCoreInstance)(records.cv, "createVersion should be of BlobCore type");
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
if (records.lsn !== undefined) {
|
|
107
|
+
(0, zipItDataRepresentationUtils_1.assertNumberInstance)(records.lsn, "lsn should be a number");
|
|
108
|
+
}
|
|
109
|
+
(0, common_utils_1.assert)(parseFloat(exports.snapshotMinReadVersion) >= parseFloat(records.mrv.toString()), 0x20f /* "Driver min read version should >= to server minReadVersion" */);
|
|
110
|
+
(0, common_utils_1.assert)(parseFloat(records.cv.toString()) >= parseFloat(exports.snapshotMinReadVersion), 0x210 /* "Snapshot should be created with minReadVersion or above" */);
|
|
108
111
|
(0, common_utils_1.assert)(exports.currentReadVersion === records.cv.toString(), 0x2c2 /* "Create Version should be equal to currentReadVersion" */);
|
|
109
|
-
return Object.assign(Object.assign({}, readSnapshotSection(records.snapshot)), { blobs: readBlobSection(records.blobs), ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [] });
|
|
112
|
+
return Object.assign(Object.assign({}, readSnapshotSection(records.snapshot)), { blobs: readBlobSection(records.blobs), ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [], latestSequenceNumber: records.lsn });
|
|
110
113
|
}
|
|
111
114
|
exports.parseCompactSnapshotResponse = parseCompactSnapshotResponse;
|
|
112
115
|
//# sourceMappingURL=compactSnapshotParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAKtD,iFASwC;AAE3B,QAAA,sBAAsB,GAAG,KAAK,CAAC;AAC/B,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAOxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IACpC,IAAA,qDAAsB,EAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,MAAM,KAAK,GAA6B,IAAI,GAAG,EAAE,CAAC;IAClD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;Q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KAAK,CAAC,CAAC;IAEzD,IAAA,qDAAsB,EAAC,OAAO,CAAC,GAAG,EAAE,2CAA2C,CAAC,CAAC;IACjF,IAAA,qDAAsB,EAAC,OAAO,CAAC,EAAE,EAAE,0CAA0C,CAAC,CAAC;IAC/E,IAAA,qBAAM,EAAC,8BAAsB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EACnD,KAAK,CAAC,kEAAkE,CAAC,CAAC;IAC9E,IAAA,qBAAM,EAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,8BAAsB,EAClD,KAAK,CAAC,+DAA+D,CAAC,CAAC;IAC3E,IAAA,qBAAM,EAAC,0BAAkB,KAAK,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAC/C,KAAK,CAAC,4DAA4D,CAAC,CAAC;IACxE,uCACO,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,KACxC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,EACrC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,IACzE;AACN,CAAC;AArBD,oEAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { ISnapshotContents } from \"./odspUtils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { ISnapshotTreeEx } from \"./contracts\";\nimport {\n assertBlobCoreInstance,\n assertBoolInstance,\n assertNodeCoreInstance,\n assertNumberInstance,\n getAndValidateNodeProps,\n NodeCore,\n NodeTypes,\n TreeBuilder,\n} from \"./zipItDataRepresentationUtils\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\ninterface ISnapshotSection {\n snapshotTree: ISnapshotTree;\n sequenceNumber: number;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes) {\n assertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n const blobs: Map<string, ArrayBuffer> = new Map();\n for (let count = 0; count < node.length; ++count) {\n const blob = node.getNode(count);\n const records = getAndValidateNodeProps(blob, [\"id\", \"data\"]);\n assertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n assertBlobCoreInstance(records.id, \"blob id should be of BlobCore type\");\n blobs.set(records.id.toString(), records.data.arrayBuffer);\n }\n return blobs;\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes) {\n assertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n const ops: ISequencedDocumentMessage[] = [];\n const records = getAndValidateNodeProps(node, [\"firstSequenceNumber\", \"deltas\"]);\n assertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n assertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n for (let i = 0; i < records.deltas.length; ++i) {\n ops.push(JSON.parse(records.deltas.getString(i)));\n }\n assert(records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n 0x280 /* \"Validate first op seq number\" */);\n return ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore) {\n const snapshotTree: ISnapshotTreeEx = {\n blobs: {},\n commits: {},\n trees: {},\n };\n for (let count = 0; count < node.length; count++) {\n const treeNode = node.getNode(count);\n const records = getAndValidateNodeProps(treeNode,\n [\"name\", \"value\", \"children\", \"unreferenced\"], false);\n assertBlobCoreInstance(records.name, \"Path should be of BlobCore\");\n const path = records.name.toString();\n if (records.value !== undefined) {\n assertBlobCoreInstance(records.value, \"Blob value should be BlobCore\");\n snapshotTree.blobs[path] = records.value.toString();\n } else {\n assertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n snapshotTree.trees[path] = readTreeSection(records.children);\n }\n if (records.unreferenced !== undefined) {\n assertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n const unreferenced = records.unreferenced.valueOf();\n assert(unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n snapshotTree.unreferenced = unreferenced;\n }\n }\n return snapshotTree;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): ISnapshotSection {\n assertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n const records = getAndValidateNodeProps(node,\n [\"id\", \"sequenceNumber\", \"treeNodes\"]);\n\n assertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n assertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n assertBlobCoreInstance(records.id, \"snapshotId should be BlobCore\");\n const snapshotTree: ISnapshotTree = readTreeSection(records.treeNodes);\n snapshotTree.id = records.id.toString();\n const sequenceNumber = records.sequenceNumber.valueOf();\n return {\n sequenceNumber,\n snapshotTree,\n };\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns - tree, blobs and ops from the snapshot.\n */\nexport function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotContents {\n const builder = TreeBuilder.load(buffer);\n assert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n const root = builder.getNode(0);\n\n const records = getAndValidateNodeProps(root,\n [\"mrv\", \"cv\", \"snapshot\", \"blobs\", \"deltas\"], false);\n\n assertBlobCoreInstance(records.mrv, \"minReadVersion should be of BlobCore type\");\n assertBlobCoreInstance(records.cv, \"createVersion should be of BlobCore type\");\n assert(snapshotMinReadVersion >= records.mrv.toString(),\n 0x20f /* \"Driver min read version should >= to server minReadVersion\" */);\n assert(records.cv.toString() >= snapshotMinReadVersion,\n 0x210 /* \"Snapshot should be created with minReadVersion or above\" */);\n assert(currentReadVersion === records.cv.toString(),\n 0x2c2 /* \"Create Version should be equal to currentReadVersion\" */);\n return {\n ...readSnapshotSection(records.snapshot),\n blobs: readBlobSection(records.blobs),\n ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compactSnapshotParser.js","sourceRoot":"","sources":["../src/compactSnapshotParser.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsD;AAKtD,iFASwC;AAE3B,QAAA,sBAAsB,GAAG,KAAK,CAAC;AAC/B,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAOxC;;;GAGG;AACH,SAAS,eAAe,CAAC,IAAe;IACpC,IAAA,qDAAsB,EAAC,IAAI,EAAE,sCAAsC,CAAC,CAAC;IACrE,MAAM,KAAK,GAA6B,IAAI,GAAG,EAAE,CAAC;IAClD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,IAAA,sDAAuB,EAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QAC9D,IAAA,qDAAsB,EAAC,OAAO,CAAC,IAAI,EAAE,iCAAiC,CAAC,CAAC;QACxE,IAAA,qDAAsB,EAAC,OAAO,CAAC,EAAE,EAAE,oCAAoC,CAAC,CAAC;QACzE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC9D;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,IAAe;IACnC,IAAA,qDAAsB,EAAC,IAAI,EAAE,mCAAmC,CAAC,CAAC;IAClE,M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,KAAK,CAAC,+DAA+D,CAAC,CAAC;IAC3E,IAAA,qBAAM,EAAC,0BAAkB,KAAK,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,EAC/C,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAExE,uCACO,mBAAmB,CAAC,OAAO,CAAC,QAAQ,CAAC,KACxC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC,EACrC,GAAG,EAAE,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EACvE,oBAAoB,EAAE,OAAO,CAAC,GAAG,IACnC;AACN,CAAC;AA3BD,oEA2BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { ISnapshotTreeEx } from \"./contracts\";\nimport {\n assertBlobCoreInstance,\n assertBoolInstance,\n assertNodeCoreInstance,\n assertNumberInstance,\n getAndValidateNodeProps,\n NodeCore,\n NodeTypes,\n TreeBuilder,\n} from \"./zipItDataRepresentationUtils\";\n\nexport const snapshotMinReadVersion = \"1.0\";\nexport const currentReadVersion = \"1.0\";\n\ninterface ISnapshotSection {\n snapshotTree: ISnapshotTree;\n sequenceNumber: number;\n}\n\n/**\n * Recreates blobs section of the tree.\n * @param node - tree node to read blob section from\n */\nfunction readBlobSection(node: NodeTypes) {\n assertNodeCoreInstance(node, \"TreeBlobs should be of type NodeCore\");\n const blobs: Map<string, ArrayBuffer> = new Map();\n for (let count = 0; count < node.length; ++count) {\n const blob = node.getNode(count);\n const records = getAndValidateNodeProps(blob, [\"id\", \"data\"]);\n assertBlobCoreInstance(records.data, \"data should be of BlobCore type\");\n assertBlobCoreInstance(records.id, \"blob id should be of BlobCore type\");\n blobs.set(records.id.toString(), records.data.arrayBuffer);\n }\n return blobs;\n}\n\n/**\n * Recreates ops section of the tree.\n * @param node - tree node to read ops section from\n */\nfunction readOpsSection(node: NodeTypes) {\n assertNodeCoreInstance(node, \"Deltas should be of type NodeCore\");\n const ops: ISequencedDocumentMessage[] = [];\n const records = getAndValidateNodeProps(node, [\"firstSequenceNumber\", \"deltas\"]);\n assertNumberInstance(records.firstSequenceNumber, \"Seq number should be a number\");\n assertNodeCoreInstance(records.deltas, \"Deltas should be a Node\");\n for (let i = 0; i < records.deltas.length; ++i) {\n ops.push(JSON.parse(records.deltas.getString(i)));\n }\n assert(records.firstSequenceNumber.valueOf() === ops[0].sequenceNumber,\n 0x280 /* \"Validate first op seq number\" */);\n return ops;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readTreeSection(node: NodeCore) {\n const snapshotTree: ISnapshotTreeEx = {\n blobs: {},\n commits: {},\n trees: {},\n };\n for (let count = 0; count < node.length; count++) {\n const treeNode = node.getNode(count);\n const records = getAndValidateNodeProps(treeNode,\n [\"name\", \"value\", \"children\", \"unreferenced\"], false);\n assertBlobCoreInstance(records.name, \"Path should be of BlobCore\");\n const path = records.name.toString();\n if (records.value !== undefined) {\n assertBlobCoreInstance(records.value, \"Blob value should be BlobCore\");\n snapshotTree.blobs[path] = records.value.toString();\n } else {\n assertNodeCoreInstance(records.children, \"Trees should be of type NodeCore\");\n snapshotTree.trees[path] = readTreeSection(records.children);\n }\n if (records.unreferenced !== undefined) {\n assertBoolInstance(records.unreferenced, \"Unreferenced flag should be bool\");\n const unreferenced = records.unreferenced.valueOf();\n assert(unreferenced, 0x281 /* \"Unreferenced if present should be true\" */);\n snapshotTree.unreferenced = unreferenced;\n }\n }\n return snapshotTree;\n}\n\n/**\n * Recreates snapshot tree out of tree representation.\n * @param node - tree node to de-serialize from\n */\nfunction readSnapshotSection(node: NodeTypes): ISnapshotSection {\n assertNodeCoreInstance(node, \"Snapshot should be of type NodeCore\");\n const records = getAndValidateNodeProps(node,\n [\"id\", \"sequenceNumber\", \"treeNodes\"]);\n\n assertNodeCoreInstance(records.treeNodes, \"TreeNodes should be of type NodeCore\");\n assertNumberInstance(records.sequenceNumber, \"sequenceNumber should be of type number\");\n assertBlobCoreInstance(records.id, \"snapshotId should be BlobCore\");\n const snapshotTree: ISnapshotTree = readTreeSection(records.treeNodes);\n snapshotTree.id = records.id.toString();\n const sequenceNumber = records.sequenceNumber.valueOf();\n return {\n sequenceNumber,\n snapshotTree,\n };\n}\n\n/**\n * Converts snapshot from binary compact representation to tree/blobs/ops.\n * @param buffer - Compact snapshot to be parsed into tree/blobs/ops.\n * @returns - tree, blobs and ops from the snapshot.\n */\nexport function parseCompactSnapshotResponse(buffer: ReadBuffer): ISnapshotContents {\n const builder = TreeBuilder.load(buffer);\n assert(builder.length === 1, 0x219 /* \"1 root should be there\" */);\n const root = builder.getNode(0);\n\n const records = getAndValidateNodeProps(root,\n [\"mrv\", \"cv\", \"lsn\", \"snapshot\", \"blobs\", \"deltas\"], false);\n\n assertBlobCoreInstance(records.mrv, \"minReadVersion should be of BlobCore type\");\n assertBlobCoreInstance(records.cv, \"createVersion should be of BlobCore type\");\n if (records.lsn !== undefined) {\n assertNumberInstance(records.lsn, \"lsn should be a number\");\n }\n\n assert(parseFloat(snapshotMinReadVersion) >= parseFloat(records.mrv.toString()),\n 0x20f /* \"Driver min read version should >= to server minReadVersion\" */);\n assert(parseFloat(records.cv.toString()) >= parseFloat(snapshotMinReadVersion),\n 0x210 /* \"Snapshot should be created with minReadVersion or above\" */);\n assert(currentReadVersion === records.cv.toString(),\n 0x2c2 /* \"Create Version should be equal to currentReadVersion\" */);\n\n return {\n ...readSnapshotSection(records.snapshot),\n blobs: readBlobSection(records.blobs),\n ops: records.deltas !== undefined ? readOpsSection(records.deltas) : [],\n latestSequenceNumber: records.lsn,\n };\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISnapshotContents } from "./
|
|
5
|
+
import { ISnapshotContents } from "./odspPublicUtils";
|
|
6
6
|
import { ReadBuffer } from "./ReadBufferUtils";
|
|
7
7
|
/**
|
|
8
8
|
* Converts trees/blobs/ops to binary compact representation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"compactSnapshotWriter.d.ts","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAkH/C;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,UAAU,CAyBxF"}
|
|
@@ -114,18 +114,19 @@ function writeOpsSection(rootNode, ops) {
|
|
|
114
114
|
* @returns - ReadBuffer - binary representation of the data.
|
|
115
115
|
*/
|
|
116
116
|
function convertToCompactSnapshot(snapshotContents) {
|
|
117
|
+
var _a;
|
|
117
118
|
const builder = new WriteBufferUtils_1.TreeBuilderSerializer();
|
|
118
119
|
// Create the root node.
|
|
119
120
|
const rootNode = builder.addNode();
|
|
120
121
|
(0, common_utils_1.assert)(snapshotContents.sequenceNumber !== undefined, 0x21c /* "Seq number should be provided" */);
|
|
121
|
-
const
|
|
122
|
-
|
|
122
|
+
const latestSequenceNumber = ((_a = snapshotContents.latestSequenceNumber) !== null && _a !== void 0 ? _a : snapshotContents.ops.length > 0) ?
|
|
123
|
+
snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber : snapshotContents.sequenceNumber;
|
|
123
124
|
writeSnapshotProps(rootNode, latestSequenceNumber);
|
|
124
125
|
writeSnapshotSection(rootNode, snapshotContents.snapshotTree, snapshotContents.sequenceNumber);
|
|
125
126
|
// Add Blobs
|
|
126
127
|
writeBlobsSection(rootNode, snapshotContents.blobs);
|
|
127
128
|
// Then write the ops node.
|
|
128
|
-
writeOpsSection(rootNode, ops);
|
|
129
|
+
writeOpsSection(rootNode, snapshotContents.ops);
|
|
129
130
|
return builder.serialize();
|
|
130
131
|
}
|
|
131
132
|
exports.convertToCompactSnapshot = convertToCompactSnapshot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compactSnapshotWriter.js","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAEtE,mEAAiE;AAGjE,yDAA2D;AAC3D,iFAAiH;AAEjH;;;;EAIE;AACF,SAAS,kBAAkB,CAAC,IAAc,EAAE,oBAA4B;IACpE,IAAA,gDAAiB,EAAC,IAAI,EAAE,KAAK,EAAE,8CAAsB,CAAC,CAAC;IACvD,IAAA,gDAAiB,EAAC,IAAI,EAAE,IAAI,EAAE,8CAAsB,CAAC,CAAC;IACtD,IAAA,gDAAiB,EAAC,IAAI,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC;AACzD,CAAC;AAED;;;;EAIE;AACF,SAAS,iBAAiB,CAAC,YAAsB,EAAE,KAAuC;;IACtF,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,KAAK,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE;QACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;QACrC,IAAA,gDAAiB,EAAC,QAAQ,EAA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,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEpD,2BAA2B;IAC3B,eAAe,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE/B,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC/B,CAAC;AAtBD,4DAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport { IBlob, ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { snapshotMinReadVersion } from \"./compactSnapshotParser\";\nimport { ISnapshotContents } from \"./odspUtils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { TreeBuilderSerializer } from \"./WriteBufferUtils\";\nimport { addBoolProperty, addNumberProperty, addStringProperty, NodeCore } from \"./zipItDataRepresentationUtils\";\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) {\n addStringProperty(node, \"mrv\", snapshotMinReadVersion);\n addStringProperty(node, \"cv\", snapshotMinReadVersion);\n addNumberProperty(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(snapshotNode: NodeCore, blobs: Map<string, IBlob | ArrayBuffer>) {\n snapshotNode.addString(\"blobs\", true);\n const blobsNode = snapshotNode.addNode(\"list\");\n for (const [storageBlobId, blob] of blobs) {\n const blobNode = blobsNode.addNode();\n addStringProperty(blobNode, \"id\", storageBlobId, true);\n blobNode.addString(\"data\", true);\n if (blob instanceof ArrayBuffer) {\n blobNode.addBlob(new Uint8Array(blob), false);\n } else {\n blobNode.addBlob(new Uint8Array(stringToBuffer(blob.contents, blob.encoding ?? \"utf-8\")), false);\n }\n }\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) {\n snapshotNode.addString(\"treeNodes\", true);\n const treesNode = snapshotNode.addNode(\"list\");\n writeTreeSectionCore(treesNode, snapshotTree);\n}\n\nfunction writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree) {\n for (const [path, value] of Object.entries(snapshotTree.trees)) {\n const treeNode = treesNode.addNode();\n addStringProperty(treeNode, \"name\", path);\n if (snapshotTree.unreferenced) {\n addBoolProperty(treeNode, \"unreferenced\", snapshotTree.unreferenced);\n }\n treeNode.addString(\"children\", true);\n const childNode = treeNode.addNode(\"list\");\n writeTreeSectionCore(childNode, value);\n }\n\n if (snapshotTree.blobs) {\n for (const [path, id] of Object.entries(snapshotTree.blobs)) {\n const blobNode = treesNode.addNode();\n addStringProperty(blobNode, \"name\", path);\n addStringProperty(blobNode, \"value\", id, true);\n }\n }\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 rootNode: NodeCore,\n snapshotTree: ISnapshotTree,\n snapshotSequenceNumber: number,\n) {\n rootNode.addString(\"snapshot\", true);\n const snapshotNode = rootNode.addNode();\n\n const snapshotId = snapshotTree.id;\n assert(snapshotId !== undefined, 0x21b /* \"Snapshot id should be provided\" */);\n addStringProperty(snapshotNode, \"id\", snapshotId);\n addStringProperty(snapshotNode, \"message\", `Snapshot@${snapshotSequenceNumber}`);\n addNumberProperty(snapshotNode, \"sequenceNumber\", snapshotSequenceNumber);\n\n // Add Trees\n writeTreeSection(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[]) {\n let firstSequenceNumber: number | undefined;\n if (ops.length > 0) {\n firstSequenceNumber = ops[0].sequenceNumber;\n }\n if (firstSequenceNumber !== undefined) {\n rootNode.addString(\"deltas\", true);\n const opsNode = rootNode.addNode();\n addNumberProperty(opsNode, \"firstSequenceNumber\", firstSequenceNumber);\n opsNode.addString(\"deltas\", true);\n const deltaNode = opsNode.addNode(\"list\");\n ops.forEach((op) => {\n deltaNode.addString(JSON.stringify(op), false);\n });\n }\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: ISnapshotContents): ReadBuffer {\n const builder = new TreeBuilderSerializer();\n // Create the root node.\n const rootNode = builder.addNode();\n assert(snapshotContents.sequenceNumber !== undefined, 0x21c /* \"Seq number should be provided\" */);\n const ops = snapshotContents.ops;\n const latestSequenceNumber = ops.length > 0 ? ops[ops.length - 1].sequenceNumber : snapshotContents.sequenceNumber;\n writeSnapshotProps(rootNode, latestSequenceNumber);\n\n writeSnapshotSection(\n rootNode,\n snapshotContents.snapshotTree,\n snapshotContents.sequenceNumber,\n );\n\n // Add Blobs\n writeBlobsSection(rootNode, snapshotContents.blobs);\n\n // Then write the ops node.\n writeOpsSection(rootNode, ops);\n\n return builder.serialize();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compactSnapshotWriter.js","sourceRoot":"","sources":["../src/compactSnapshotWriter.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAsE;AAEtE,mEAAiE;AAGjE,yDAA2D;AAC3D,iFAAiH;AAEjH;;;;EAIE;AACF,SAAS,kBAAkB,CAAC,IAAc,EAAE,oBAA4B;IACpE,IAAA,gDAAiB,EAAC,IAAI,EAAE,KAAK,EAAE,8CAAsB,CAAC,CAAC;IACvD,IAAA,gDAAiB,EAAC,IAAI,EAA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,cAAc,KAAK,SAAS,EAAE,KAAK,CAAC,qCAAqC,CAAC,CAAC;IAEnG,MAAM,oBAAoB,GAAG,CAAA,MAAA,gBAAgB,CAAC,oBAAoB,mCAC9D,gBAAgB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAC,CAAC;QACjC,gBAAgB,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,gBAAgB,CAAC,cAAc,CAAC;IAE3G,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAEnD,oBAAoB,CAChB,QAAQ,EACR,gBAAgB,CAAC,YAAY,EAC7B,gBAAgB,CAAC,cAAc,CAClC,CAAC;IAEF,YAAY;IACZ,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAEpD,2BAA2B;IAC3B,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC,SAAS,EAAE,CAAC;AAC/B,CAAC;AAzBD,4DAyBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, stringToBuffer } from \"@fluidframework/common-utils\";\nimport { IBlob, ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport { snapshotMinReadVersion } from \"./compactSnapshotParser\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { ReadBuffer } from \"./ReadBufferUtils\";\nimport { TreeBuilderSerializer } from \"./WriteBufferUtils\";\nimport { addBoolProperty, addNumberProperty, addStringProperty, NodeCore } from \"./zipItDataRepresentationUtils\";\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) {\n addStringProperty(node, \"mrv\", snapshotMinReadVersion);\n addStringProperty(node, \"cv\", snapshotMinReadVersion);\n addNumberProperty(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(snapshotNode: NodeCore, blobs: Map<string, IBlob | ArrayBuffer>) {\n snapshotNode.addString(\"blobs\", true);\n const blobsNode = snapshotNode.addNode(\"list\");\n for (const [storageBlobId, blob] of blobs) {\n const blobNode = blobsNode.addNode();\n addStringProperty(blobNode, \"id\", storageBlobId, true);\n blobNode.addString(\"data\", true);\n if (blob instanceof ArrayBuffer) {\n blobNode.addBlob(new Uint8Array(blob), false);\n } else {\n blobNode.addBlob(new Uint8Array(stringToBuffer(blob.contents, blob.encoding ?? \"utf-8\")), false);\n }\n }\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) {\n snapshotNode.addString(\"treeNodes\", true);\n const treesNode = snapshotNode.addNode(\"list\");\n writeTreeSectionCore(treesNode, snapshotTree);\n}\n\nfunction writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree) {\n for (const [path, value] of Object.entries(snapshotTree.trees)) {\n const treeNode = treesNode.addNode();\n addStringProperty(treeNode, \"name\", path);\n if (snapshotTree.unreferenced) {\n addBoolProperty(treeNode, \"unreferenced\", snapshotTree.unreferenced);\n }\n treeNode.addString(\"children\", true);\n const childNode = treeNode.addNode(\"list\");\n writeTreeSectionCore(childNode, value);\n }\n\n if (snapshotTree.blobs) {\n for (const [path, id] of Object.entries(snapshotTree.blobs)) {\n const blobNode = treesNode.addNode();\n addStringProperty(blobNode, \"name\", path);\n addStringProperty(blobNode, \"value\", id, true);\n }\n }\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 rootNode: NodeCore,\n snapshotTree: ISnapshotTree,\n snapshotSequenceNumber: number,\n) {\n rootNode.addString(\"snapshot\", true);\n const snapshotNode = rootNode.addNode();\n\n const snapshotId = snapshotTree.id;\n assert(snapshotId !== undefined, 0x21b /* \"Snapshot id should be provided\" */);\n addStringProperty(snapshotNode, \"id\", snapshotId);\n addStringProperty(snapshotNode, \"message\", `Snapshot@${snapshotSequenceNumber}`);\n addNumberProperty(snapshotNode, \"sequenceNumber\", snapshotSequenceNumber);\n\n // Add Trees\n writeTreeSection(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[]) {\n let firstSequenceNumber: number | undefined;\n if (ops.length > 0) {\n firstSequenceNumber = ops[0].sequenceNumber;\n }\n if (firstSequenceNumber !== undefined) {\n rootNode.addString(\"deltas\", true);\n const opsNode = rootNode.addNode();\n addNumberProperty(opsNode, \"firstSequenceNumber\", firstSequenceNumber);\n opsNode.addString(\"deltas\", true);\n const deltaNode = opsNode.addNode(\"list\");\n ops.forEach((op) => {\n deltaNode.addString(JSON.stringify(op), false);\n });\n }\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: ISnapshotContents): ReadBuffer {\n const builder = new TreeBuilderSerializer();\n // Create the root node.\n const rootNode = builder.addNode();\n assert(snapshotContents.sequenceNumber !== undefined, 0x21c /* \"Seq number should be provided\" */);\n\n const latestSequenceNumber = snapshotContents.latestSequenceNumber ??\n snapshotContents.ops.length > 0 ?\n snapshotContents.ops[snapshotContents.ops.length - 1].sequenceNumber : snapshotContents.sequenceNumber;\n\n writeSnapshotProps(rootNode, latestSequenceNumber);\n\n writeSnapshotSection(\n rootNode,\n snapshotContents.snapshotTree,\n snapshotContents.sequenceNumber,\n );\n\n // Add Blobs\n writeBlobsSection(rootNode, snapshotContents.blobs);\n\n // Then write the ops node.\n writeOpsSection(rootNode, snapshotContents.ops);\n\n return builder.serialize();\n}\n"]}
|
package/dist/contracts.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as api from "@fluidframework/protocol-definitions";
|
|
6
6
|
import { HostStoragePolicy } from "@fluidframework/odsp-driver-definitions";
|
|
7
|
-
import { ISnapshotContents } from "./
|
|
7
|
+
import { ISnapshotContents } from "./odspPublicUtils";
|
|
8
8
|
/** https://portal.microsofticm.com/imp/v3/incidents/details/308931013/home
|
|
9
9
|
* The commits property was removed from protocol-definitions but in order to support back compat, we will
|
|
10
10
|
* temporarily add back in this local structure in order to upload the snapshot to support rolling back to 0.58.
|
package/dist/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;EAIE;AACF,MAAM,WAAW,eAAe;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE;QAA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;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC,yBAAyB,EAAE,CAAC;CAC9C;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC3D,cAAc,EAAE,MAAM,CAAC;CAC1B"}
|
package/dist/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkOU,QAAA,0BAA0B,GAAG,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { HostStoragePolicy } from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotContents } from \"./
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkOU,QAAA,0BAA0B,GAAG,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { HostStoragePolicy } from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\n/** https://portal.microsofticm.com/imp/v3/incidents/details/308931013/home\n * The commits property was removed from protocol-definitions but in order to support back compat, we will\n * temporarily add back in this local structure in order to upload the snapshot to support rolling back to 0.58.\n * Notice this entire interface will be removed once the backward compatibility is not required anymore.\n*/\nexport interface ISnapshotTreeEx {\n id?: string;\n blobs: { [path: string]: string; };\n commits: { [path: string]: string; };\n trees: { [path: string]: ISnapshotTreeEx; };\n // Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n unreferenced?: true;\n}\n\n/**\n * Socket storage discovery api response\n */\nexport interface ISocketStorageDiscovery {\n // The id of the web socket\n id: string;\n\n // SPO gives us runtimeTenantId, we remap it to tenantId\n // See getSocketStorageDiscovery\n runtimeTenantId?: string;\n tenantId: string;\n\n snapshotStorageUrl: string;\n deltaStorageUrl: string;\n\n /**\n * PUSH URL\n */\n deltaStreamSocketUrl: string;\n\n /**\n * The access token for PushChannel. Optionally returned, depending on implementation.\n * OneDrive for Consumer implementation returns it and OneDrive for Business implementation\n * does not return it and instead expects token to be returned via `getWebsocketToken` callback\n * passed as a parameter to `OdspDocumentService.create()` factory.\n */\n socketToken?: string;\n\n /**\n * This is the time within which client has to refresh the session on (ODSP) relay service.\n */\n refreshSessionDurationSeconds?: number;\n}\n\n/**\n * Interface for error responses for the WebSocket connection\n */\nexport interface IOdspSocketError {\n /**\n * An error code number for the error that occurred\n * It will be a valid HTTP status code\n */\n code: number;\n\n /**\n * A message about the error that occurred for debugging / logging purposes\n * This should not be displayed to the user directly\n */\n message: string;\n\n /**\n * Optional Retry-After time in seconds\n * The client should wait this many seconds before retrying its request\n */\n retryAfter?: number;\n}\n\n/**\n * Interface for delta storage response.\n * Contains either SequencedDocumentMessages or SequencedDeltaOpMessage.\n */\nexport interface IDeltaStorageGetResponse {\n value: api.ISequencedDocumentMessage[] | ISequencedDeltaOpMessage[];\n}\n\nexport interface ISequencedDeltaOpMessage {\n op: api.ISequencedDocumentMessage;\n sequenceNumber: number;\n}\n\nexport interface IDocumentStorageGetVersionsResponse {\n value: IDocumentStorageVersion[];\n}\n\nexport interface IDocumentStorageVersion {\n id: string;\n}\n\n/**\n *\n * Data structures that form ODSP Summary\n *\n */\n\nexport interface IOdspSummaryPayload {\n type: \"container\" | \"channel\";\n message: string;\n sequenceNumber: number;\n entries: OdspSummaryTreeEntry[];\n}\n\nexport interface IWriteSummaryResponse {\n id: string;\n}\n\nexport type OdspSummaryTreeEntry = IOdspSummaryTreeValueEntry | IOdspSummaryTreeHandleEntry;\n\nexport interface IOdspSummaryTreeBaseEntry {\n path: string;\n type: \"blob\" | \"tree\" | \"commit\";\n}\n\nexport interface IOdspSummaryTreeValueEntry extends IOdspSummaryTreeBaseEntry {\n value: OdspSummaryTreeValue;\n // Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n unreferenced?: true;\n}\n\nexport interface IOdspSummaryTreeHandleEntry extends IOdspSummaryTreeBaseEntry {\n id: string;\n}\n\nexport type OdspSummaryTreeValue = IOdspSummaryTree | IOdspSummaryBlob;\n\nexport interface IOdspSummaryTree {\n type: \"tree\";\n entries?: OdspSummaryTreeEntry[];\n}\n\nexport interface IOdspSummaryBlob {\n type: \"blob\";\n content: string;\n encoding: \"base64\" | \"utf-8\";\n}\n\n/**\n *\n * Data structures that form ODSP Snapshot\n *\n */\n\nexport interface IOdspSnapshotTreeEntryTree {\n path: string;\n type: \"tree\";\n // Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n unreferenced?: true;\n}\n\nexport interface IOdspSnapshotTreeEntryCommit {\n id: string;\n path: string;\n type: \"commit\";\n}\n\nexport interface IOdspSnapshotTreeEntryBlob {\n id: string;\n path: string;\n type: \"blob\";\n}\n\nexport type IOdspSnapshotTreeEntry =\n | IOdspSnapshotTreeEntryTree\n | IOdspSnapshotTreeEntryCommit\n | IOdspSnapshotTreeEntryBlob;\n\nexport interface IOdspSnapshotCommit {\n entries: IOdspSnapshotTreeEntry[];\n id: string;\n sequenceNumber: number;\n}\n\n/**\n * Blob content, represents blobs in downloaded snapshot.\n */\nexport interface IOdspSnapshotBlob {\n content: string;\n // SPO only uses \"base64\" today for download.\n // We are adding undefined too, as temp way to roundtrip strings unchanged.\n encoding: \"base64\" | undefined;\n id: string;\n size: number;\n}\n\nexport interface IOdspSnapshot {\n id: string;\n trees: IOdspSnapshotCommit[];\n blobs?: IOdspSnapshotBlob[];\n ops?: ISequencedDeltaOpMessage[];\n}\n\n/**\n * Same as HostStoragePolicy, but adds options that are internal to runtime.\n * All fields should be optional.\n */\nexport interface HostStoragePolicyInternal extends HostStoragePolicy {\n summarizerClient?: boolean;\n}\n\nexport interface ICreateFileResponse {\n \"@odata.context\": string;\n driveId: string;\n id: string;\n itemId: string;\n itemUrl: string;\n sequenceNumber: number;\n sharingLink?: string;\n sharingLinkErrorReason?: string;\n}\n\nexport interface IVersionedValueWithEpoch {\n value: any;\n fluidEpoch: string;\n // This is same as \"persistedCacheValueVersion\" below. This represents the version of data stored in cache.\n version: 3;\n}\n\nexport const persistedCacheValueVersion = 3;\n\nexport interface IGetOpsResponse {\n nonce: string;\n code: number;\n /** Time in seconds. Currently never set by PUSH */\n retryAfter?: number;\n messages?: api.ISequencedDocumentMessage[];\n}\n\nexport interface IFlushOpsResponse {\n nonce: string;\n code: number;\n /** Time in seconds */\n retryAfter?: number;\n lastPersistedSequenceNumber?: number;\n}\n\n/**\n * Represents the cached snapshot value.\n */\nexport interface ISnapshotCachedEntry extends ISnapshotContents {\n cacheEntryTime: number;\n}\n"]}
|
package/dist/createFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFile.d.ts","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAe,YAAY,EAAgB,MAAM,sCAAsC,CAAC;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EACH,UAAU,EACV,+BAA+B,EAC/B,gBAAgB,EAEnB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACH,gBAAgB,EAGhB,mBAAmB,EAEtB,MAAM,aAAa,CAAC;AAErB,OAAO,EAGH,YAAY,
|
|
1
|
+
{"version":3,"file":"createFile.d.ts","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAe,YA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,aAAa,CAAC,CAAC;gBAChE,YAAY,GAAG,aAAa,CAAC,YAAY,CAAC;gBAC1C,MAAM;aACT;YACD,KAAK,kCAAW,CAAC,IAAI,CAAC,CAAC;gBACnB,MAAM,OAAO,GAAG,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;oBACvD,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,iCAAkB,EAAC,aAAa,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAChF,MAAM,QAAQ,GAAG,OAAO,aAAa,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC;gBAEhF,KAAK,GAAG;oBACJ,IAAI,EAAE,MAAM;oBACZ,OAAO;oBACP,QAAQ;iBACX,CAAC;gBACF,MAAM;aACT;YACD,KAAK,kCAAW,CAAC,MAAM,CAAC,CAAC;gBACrB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;aACtE;YACD,OAAO,CAAC,CAAC;gBACL,MAAM,IAAI,KAAK,CAAC,qBAAqB,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aAC9D;SACJ;QAED,MAAM,KAAK,GAAyB;YAChC,IAAI,EAAE,kBAAkB,CAAC,GAAG,CAAC;YAC7B,IAAI,EAAE,IAAA,0BAAU,EAAC,aAAa,CAAC;YAC/B,KAAK;YACL,YAAY;SACf,CAAC;QACF,MAAA,YAAY,CAAC,OAAO,0CAAE,IAAI,CAAC,KAAK,CAAC,CAAC;KACrC;IAED,OAAO,YAAY,CAAC;AACxB,CAAC;AApDD,4FAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { assert, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { getDocAttributesFromProtocolSummary, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport { SummaryType, ISummaryTree, ISummaryBlob } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IFileEntry,\n InstrumentedStorageTokenFetcher,\n IOdspResolvedUrl,\n OdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspSummaryTree,\n OdspSummaryTreeValue,\n OdspSummaryTreeEntry,\n ICreateFileResponse,\n IOdspSummaryPayload,\n} from \"./contracts\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n createCacheSnapshotKey,\n getWithRetryForTokenRefresh,\n INewFileInfo,\n getOrigin,\n ISnapshotContents,\n maxUmpPostBodySize,\n} from \"./odspUtils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { convertCreateNewSummaryTreeToTreeAndBlobs } from \"./createNewUtils\";\nimport { runWithRetry } from \"./retryUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n const invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n return !!fileName.match(invalidCharsRegex);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n getStorageToken: InstrumentedStorageTokenFetcher,\n newFileInfo: INewFileInfo,\n logger: ITelemetryLogger,\n createNewSummary: ISummaryTree | undefined,\n epochTracker: EpochTracker,\n fileEntry: IFileEntry,\n createNewCaching: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n isClpCompliantApp?: boolean,\n): Promise<IOdspResolvedUrl> {\n // Check for valid filename before the request to create file is actually made.\n if (isInvalidFileName(newFileInfo.filename)) {\n throw new NonRetryableError(\n // pre-0.58 error message: Invalid filename\n \"Invalid filename for createNew\", OdspErrorType.invalidFileNameError, { driverVersion });\n }\n\n let itemId: string;\n let summaryHandle: string = \"\";\n let sharingLink: string | undefined;\n let sharingLinkErrorReason: string | undefined;\n if (createNewSummary === undefined) {\n itemId = await createNewEmptyFluidFile(\n getStorageToken, newFileInfo, logger, epochTracker, forceAccessTokenViaAuthorizationHeader);\n } else {\n const content = await createNewFluidFileFromSummary(\n getStorageToken,\n newFileInfo,\n logger,\n createNewSummary,\n epochTracker,\n forceAccessTokenViaAuthorizationHeader,\n );\n itemId = content.itemId;\n summaryHandle = content.id;\n sharingLink = content.sharingLink;\n sharingLinkErrorReason = content.sharingLinkErrorReason;\n }\n\n const odspUrl = createOdspUrl({ ... newFileInfo, itemId, dataStorePath: \"/\" });\n const resolver = new OdspDriverUrlResolver();\n const odspResolvedUrl = await resolver.resolve({\n url: odspUrl,\n headers: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n });\n fileEntry.docId = odspResolvedUrl.hashedDocumentId;\n fileEntry.resolvedUrl = odspResolvedUrl;\n\n if (sharingLink || sharingLinkErrorReason) {\n odspResolvedUrl.shareLinkInfo = {\n createLink: {\n type: newFileInfo.createLinkType,\n link: sharingLink,\n error: sharingLinkErrorReason,\n },\n };\n }\n\n if (createNewSummary !== undefined && createNewCaching) {\n assert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n // converting summary and getting sequence number\n const snapshot: ISnapshotContents = convertCreateNewSummaryTreeToTreeAndBlobs(createNewSummary, summaryHandle);\n // caching the converted summary\n await epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n }\n return odspResolvedUrl;\n}\n\nexport async function createNewEmptyFluidFile(\n getStorageToken: InstrumentedStorageTokenFetcher,\n newFileInfo: INewFileInfo,\n logger: ITelemetryLogger,\n epochTracker: EpochTracker,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<string> {\n const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n // add .tmp extension to empty file (host is expected to rename)\n const encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n const initialUrl =\n `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:/${filePath\n }/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"createNewEmptyFile\" },\n async (event) => {\n const { url, headers } = getUrlAndHeadersWithAuth(\n initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers[\"Content-Type\"] = \"application/json\";\n\n const fetchResponse = await runWithRetry(\n async () => epochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n url,\n {\n body: undefined,\n headers,\n method: \"PUT\",\n },\n \"createFile\",\n ),\n \"createFile\",\n logger,\n );\n\n const content = fetchResponse.content;\n if (!content || !content.id) {\n throw new NonRetryableError(\n // pre-0.58 error message: ODSP CreateFile call returned no item ID\n \"ODSP CreateFile call returned no item ID (for empty file)\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n event.end({\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n ...fetchResponse.propsToLog,\n });\n return content.id;\n },\n { end: true, cancel: \"error\" });\n });\n}\n\nexport async function createNewFluidFileFromSummary(\n getStorageToken: InstrumentedStorageTokenFetcher,\n newFileInfo: INewFileInfo,\n logger: ITelemetryLogger,\n createNewSummary: ISummaryTree,\n epochTracker: EpochTracker,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n const encodedFilename = encodeURIComponent(newFileInfo.filename);\n const baseUrl =\n `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n `${filePath}/${encodedFilename}`;\n\n const containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n const initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${newFileInfo.createLinkType ?\n `?createLinkType=${newFileInfo.createLinkType}` : \"\"}`;\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"createNewFile\" },\n async (event) => {\n const snapshotBody = JSON.stringify(containerSnapshot);\n let url: string;\n let headers: { [index: string]: string; };\n let addInBody = false;\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: POST\\r\\n`;\n postBody += `Content-Type: application/json\\r\\n`;\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n${snapshotBody}\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n\n if (postBody.length <= maxUmpPostBodySize) {\n const urlObj = new URL(initialUrl);\n urlObj.searchParams.set(\"ump\", \"1\");\n url = urlObj.href;\n headers = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n addInBody = true;\n } else {\n const parts = getUrlAndHeadersWithAuth(\n initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n url = parts.url;\n headers = {\n ...parts.headers,\n \"Content-Type\": \"application/json\",\n };\n postBody = snapshotBody;\n }\n\n const fetchResponse = await runWithRetry(\n async () => epochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"createFile\",\n addInBody,\n ),\n \"createFile\",\n logger,\n );\n\n const content = fetchResponse.content;\n if (!content || !content.itemId) {\n throw new NonRetryableError(\n \"ODSP CreateFile call returned no item ID\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n event.end({\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n attempts: options.refresh ? 2 : 1,\n ...fetchResponse.propsToLog,\n });\n return content;\n },\n );\n });\n}\n\nfunction convertSummaryIntoContainerSnapshot(createNewSummary: ISummaryTree) {\n const appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n const protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n if (!(appSummary && protocolSummary)) {\n throw new Error(\"App and protocol summary required for create new path!!\");\n }\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const attributesSummaryBlob: ISummaryBlob = {\n type: SummaryType.Blob,\n content: JSON.stringify(documentAttributes),\n };\n protocolSummary.tree.attributes = attributesSummaryBlob;\n const convertedCreateNewSummary: ISummaryTree = {\n type: SummaryType.Tree,\n tree: {\n \".protocol\": protocolSummary,\n \".app\": appSummary,\n },\n };\n const snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries ?? [],\n message: \"app\",\n sequenceNumber: documentAttributes.sequenceNumber,\n type: \"container\",\n };\n return snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nexport function convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [],\n };\n\n const keys = Object.keys(summary.tree);\n for (const key of keys) {\n const summaryObject = summary.tree[key];\n\n let value: OdspSummaryTreeValue;\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is true,\n // the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n unreferenced = summaryObject.unreferenced;\n break;\n }\n case SummaryType.Blob: {\n const content = typeof summaryObject.content === \"string\" ?\n summaryObject.content : Uint8ArrayToString(summaryObject.content, \"base64\");\n const encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n value = {\n type: \"blob\",\n content,\n encoding,\n };\n break;\n }\n case SummaryType.Handle: {\n throw new Error(\"No handle should be present for first summary!!\");\n }\n default: {\n throw new Error(`Unknown tree type ${summaryObject.type}`);\n }\n }\n\n const entry: OdspSummaryTreeEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n value,\n unreferenced,\n };\n snapshotTree.entries?.push(entry);\n }\n\n return snapshotTree;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createFile.js","sourceRoot":"","sources":["../src/createFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,+DAA0E;AAC1E,+DAAsG;AACtG,iEAA2D;AAC3D,+EAA+F;AAE/F,qEAAmE;AACnE,qFAKiD;AACjD,2EAAqE;AAQrE,yEAAsE;AACtE,2CAMqB;AAErB,mDAAgD;AAChD,mDAA6C;AAE7C,mEAAgE;AAChE,qDAA6E;AAC7E,6CAA4C;AAC5C,qDAA+D;AAC/D,uDAA0D;AAE1D,MAAM,iBAAiB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACpD,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACpC,eAAgD,EAChD,WAAyB,EACzB,MAAwB,EACxB,gBAA0C,EAC1C,YAA0B,EAC1B,SAAqB,EACrB,gBAAyB,EACzB,sCAA+C,EAC/C,iBAA2B;IAE3B,+EAA+E;IAC/E,IAAI,iBAAiB,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;QACzC,MAAM,IAAI,gCAAiB;QACvB,2CAA2C;QAC3C,gCAAgC,EAAE,uCAAa,CAAC,oBAAoB,EAAE,EAAE,aAAa,EAAb,2BAAa,EAAE,CAAC,CAA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AAY;SACf,CAAC;QACF,MAAA,YAAY,CAAC,OAAO,0CAAE,IAAI,CAAC,KAAK,CAAC,CAAC;KACrC;IAED,OAAO,YAAY,CAAC;AACxB,CAAC;AApDD,4FAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { assert, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport { getDocAttributesFromProtocolSummary, NonRetryableError } from \"@fluidframework/driver-utils\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport { SummaryType, ISummaryTree, ISummaryBlob } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IFileEntry,\n InstrumentedStorageTokenFetcher,\n IOdspResolvedUrl,\n OdspErrorType,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n IOdspSummaryTree,\n OdspSummaryTreeValue,\n OdspSummaryTreeEntry,\n ICreateFileResponse,\n IOdspSummaryPayload,\n} from \"./contracts\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n createCacheSnapshotKey,\n getWithRetryForTokenRefresh,\n INewFileInfo,\n getOrigin,\n maxUmpPostBodySize,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { createOdspUrl } from \"./createOdspUrl\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nimport { convertCreateNewSummaryTreeToTreeAndBlobs } from \"./createNewUtils\";\nimport { runWithRetry } from \"./retryUtils\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic\";\n\nconst isInvalidFileName = (fileName: string): boolean => {\n const invalidCharsRegex = /[\"*/:<>?\\\\|]+/g;\n return !!fileName.match(invalidCharsRegex);\n};\n\n/**\n * Creates a new Fluid file.\n * Returns resolved url\n */\nexport async function createNewFluidFile(\n getStorageToken: InstrumentedStorageTokenFetcher,\n newFileInfo: INewFileInfo,\n logger: ITelemetryLogger,\n createNewSummary: ISummaryTree | undefined,\n epochTracker: EpochTracker,\n fileEntry: IFileEntry,\n createNewCaching: boolean,\n forceAccessTokenViaAuthorizationHeader: boolean,\n isClpCompliantApp?: boolean,\n): Promise<IOdspResolvedUrl> {\n // Check for valid filename before the request to create file is actually made.\n if (isInvalidFileName(newFileInfo.filename)) {\n throw new NonRetryableError(\n // pre-0.58 error message: Invalid filename\n \"Invalid filename for createNew\", OdspErrorType.invalidFileNameError, { driverVersion });\n }\n\n let itemId: string;\n let summaryHandle: string = \"\";\n let sharingLink: string | undefined;\n let sharingLinkErrorReason: string | undefined;\n if (createNewSummary === undefined) {\n itemId = await createNewEmptyFluidFile(\n getStorageToken, newFileInfo, logger, epochTracker, forceAccessTokenViaAuthorizationHeader);\n } else {\n const content = await createNewFluidFileFromSummary(\n getStorageToken,\n newFileInfo,\n logger,\n createNewSummary,\n epochTracker,\n forceAccessTokenViaAuthorizationHeader,\n );\n itemId = content.itemId;\n summaryHandle = content.id;\n sharingLink = content.sharingLink;\n sharingLinkErrorReason = content.sharingLinkErrorReason;\n }\n\n const odspUrl = createOdspUrl({ ...newFileInfo, itemId, dataStorePath: \"/\" });\n const resolver = new OdspDriverUrlResolver();\n const odspResolvedUrl = await resolver.resolve({\n url: odspUrl,\n headers: { [ClpCompliantAppHeader.isClpCompliantApp]: isClpCompliantApp },\n });\n fileEntry.docId = odspResolvedUrl.hashedDocumentId;\n fileEntry.resolvedUrl = odspResolvedUrl;\n\n if (sharingLink || sharingLinkErrorReason) {\n odspResolvedUrl.shareLinkInfo = {\n createLink: {\n type: newFileInfo.createLinkType,\n link: sharingLink,\n error: sharingLinkErrorReason,\n },\n };\n }\n\n if (createNewSummary !== undefined && createNewCaching) {\n assert(summaryHandle !== undefined, 0x203 /* \"Summary handle is undefined\" */);\n // converting summary and getting sequence number\n const snapshot: ISnapshotContents = convertCreateNewSummaryTreeToTreeAndBlobs(createNewSummary, summaryHandle);\n // caching the converted summary\n await epochTracker.put(createCacheSnapshotKey(odspResolvedUrl), snapshot);\n }\n return odspResolvedUrl;\n}\n\nexport async function createNewEmptyFluidFile(\n getStorageToken: InstrumentedStorageTokenFetcher,\n newFileInfo: INewFileInfo,\n logger: ITelemetryLogger,\n epochTracker: EpochTracker,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<string> {\n const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n // add .tmp extension to empty file (host is expected to rename)\n const encodedFilename = encodeURIComponent(`${newFileInfo.filename}.tmp`);\n const initialUrl =\n `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:/${filePath\n }/${encodedFilename}:/content?@name.conflictBehavior=rename&select=id,name,parentReference`;\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"createNewEmptyFile\" },\n async (event) => {\n const { url, headers } = getUrlAndHeadersWithAuth(\n initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n headers[\"Content-Type\"] = \"application/json\";\n\n const fetchResponse = await runWithRetry(\n async () => epochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n url,\n {\n body: undefined,\n headers,\n method: \"PUT\",\n },\n \"createFile\",\n ),\n \"createFile\",\n logger,\n );\n\n const content = fetchResponse.content;\n if (!content || !content.id) {\n throw new NonRetryableError(\n // pre-0.58 error message: ODSP CreateFile call returned no item ID\n \"ODSP CreateFile call returned no item ID (for empty file)\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n event.end({\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n ...fetchResponse.propsToLog,\n });\n return content.id;\n },\n { end: true, cancel: \"error\" });\n });\n}\n\nexport async function createNewFluidFileFromSummary(\n getStorageToken: InstrumentedStorageTokenFetcher,\n newFileInfo: INewFileInfo,\n logger: ITelemetryLogger,\n createNewSummary: ISummaryTree,\n epochTracker: EpochTracker,\n forceAccessTokenViaAuthorizationHeader: boolean,\n): Promise<ICreateFileResponse> {\n const filePath = newFileInfo.filePath ? encodeURIComponent(`/${newFileInfo.filePath}`) : \"\";\n const encodedFilename = encodeURIComponent(newFileInfo.filename);\n const baseUrl =\n `${getApiRoot(getOrigin(newFileInfo.siteUrl))}/drives/${newFileInfo.driveId}/items/root:` +\n `${filePath}/${encodedFilename}`;\n\n const containerSnapshot = convertSummaryIntoContainerSnapshot(createNewSummary);\n const initialUrl = `${baseUrl}:/opStream/snapshots/snapshot${newFileInfo.createLinkType ?\n `?createLinkType=${newFileInfo.createLinkType}` : \"\"}`;\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await getStorageToken(options, \"CreateNewFile\");\n\n return PerformanceEvent.timedExecAsync(\n logger,\n { eventName: \"createNewFile\" },\n async (event) => {\n const snapshotBody = JSON.stringify(containerSnapshot);\n let url: string;\n let headers: { [index: string]: string; };\n let addInBody = false;\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: POST\\r\\n`;\n postBody += `Content-Type: application/json\\r\\n`;\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n${snapshotBody}\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n\n if (postBody.length <= maxUmpPostBodySize) {\n const urlObj = new URL(initialUrl);\n urlObj.searchParams.set(\"ump\", \"1\");\n url = urlObj.href;\n headers = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n addInBody = true;\n } else {\n const parts = getUrlAndHeadersWithAuth(\n initialUrl, storageToken, forceAccessTokenViaAuthorizationHeader);\n url = parts.url;\n headers = {\n ...parts.headers,\n \"Content-Type\": \"application/json\",\n };\n postBody = snapshotBody;\n }\n\n const fetchResponse = await runWithRetry(\n async () => epochTracker.fetchAndParseAsJSON<ICreateFileResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"createFile\",\n addInBody,\n ),\n \"createFile\",\n logger,\n );\n\n const content = fetchResponse.content;\n if (!content || !content.itemId) {\n throw new NonRetryableError(\n \"ODSP CreateFile call returned no item ID\",\n DriverErrorType.incorrectServerResponse,\n { driverVersion });\n }\n event.end({\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n attempts: options.refresh ? 2 : 1,\n ...fetchResponse.propsToLog,\n });\n return content;\n },\n );\n });\n}\n\nfunction convertSummaryIntoContainerSnapshot(createNewSummary: ISummaryTree) {\n const appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n const protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n if (!(appSummary && protocolSummary)) {\n throw new Error(\"App and protocol summary required for create new path!!\");\n }\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const attributesSummaryBlob: ISummaryBlob = {\n type: SummaryType.Blob,\n content: JSON.stringify(documentAttributes),\n };\n protocolSummary.tree.attributes = attributesSummaryBlob;\n const convertedCreateNewSummary: ISummaryTree = {\n type: SummaryType.Tree,\n tree: {\n \".protocol\": protocolSummary,\n \".app\": appSummary,\n },\n };\n const snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries ?? [],\n message: \"app\",\n sequenceNumber: documentAttributes.sequenceNumber,\n type: \"container\",\n };\n return snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nexport function convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [],\n };\n\n const keys = Object.keys(summary.tree);\n for (const key of keys) {\n const summaryObject = summary.tree[key];\n\n let value: OdspSummaryTreeValue;\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is true,\n // the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n value = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n unreferenced = summaryObject.unreferenced;\n break;\n }\n case SummaryType.Blob: {\n const content = typeof summaryObject.content === \"string\" ?\n summaryObject.content : Uint8ArrayToString(summaryObject.content, \"base64\");\n const encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n value = {\n type: \"blob\",\n content,\n encoding,\n };\n break;\n }\n case SummaryType.Handle: {\n throw new Error(\"No handle should be present for first summary!!\");\n }\n default: {\n throw new Error(`Unknown tree type ${summaryObject.type}`);\n }\n }\n\n const entry: OdspSummaryTreeEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n value,\n unreferenced,\n };\n snapshotTree.entries?.push(entry);\n }\n\n return snapshotTree;\n}\n"]}
|
package/dist/createNewUtils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import { ISnapshotContents } from "./
|
|
6
|
+
import { ISnapshotContents } from "./odspPublicUtils";
|
|
7
7
|
/**
|
|
8
8
|
* Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAe,MAAM,sCAAsC,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD;;GAEG;AACH,wBAAgB,yCAAyC,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAgBlH"}
|
package/dist/createNewUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,+EAAiF;AACjF,+DAAmF;AACnF,+DAA+E;AAI/E;;GAEG;AACH,SAAgB,yCAAyC,CAAC,OAAqB,EAAE,MAAc;IAC3F,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IAClE,MAAM,kBAAkB,GAAG,IAAA,kDAAmC,EAAC,eAAe,CAAC,CAAC;IAChF,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,MAAM,YAAY,GAAG,6CAA6C,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACnF,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,iBAAiB,GAAsB;QACzC,YAAY;QACZ,KAAK;QACL,GAAG,EAAE,EAAE;QACP,cAAc;
|
|
1
|
+
{"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../src/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAkC;AAClC,+EAAiF;AACjF,+DAAmF;AACnF,+DAA+E;AAI/E;;GAEG;AACH,SAAgB,yCAAyC,CAAC,OAAqB,EAAE,MAAc;IAC3F,MAAM,eAAe,GAAG,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AAE,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC;gBAC1E,MAAM,MAAM,GAAG,IAAA,SAAI,GAAE,CAAC;gBACtB,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;gBAC7B,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;gBACjC,MAAM;aACT;YACD,KAAK,kCAAW,CAAC,MAAM,CAAC;YACxB,KAAK,kCAAW,CAAC,UAAU,CAAC,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,MAAM,aAAa,CAAC,IAAI,0CAA0C,CAAC,CAAC;aACvF;YACD,OAAO,CAAC,CAAC;gBACL,IAAA,8BAAe,EAAC,aAAa,EAAE,qBAAsB,aAAqB,CAAC,IAAI,EAAE,CAAC,CAAC;aACtF;SACJ;KACJ;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { getDocAttributesFromProtocolSummary } from \"@fluidframework/driver-utils\";\nimport { stringToBuffer, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { ISnapshotTreeEx } from \"./contracts\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(summary: ISummaryTree, treeId: string): ISnapshotContents {\n const protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const sequenceNumber = documentAttributes.sequenceNumber;\n const blobs = new Map<string, ArrayBuffer>();\n const snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobs);\n snapshotTree.id = treeId;\n const snapshotTreeValue: ISnapshotContents = {\n snapshotTree,\n blobs,\n ops: [],\n sequenceNumber,\n latestSequenceNumber: sequenceNumber,\n };\n\n return snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n summary: ISummaryTree,\n blobs: Map<string, ArrayBuffer>,\n) {\n const treeNode: ISnapshotTreeEx = {\n blobs: {},\n trees: {},\n commits: {},\n unreferenced: summary.unreferenced,\n };\n const keys = Object.keys(summary.tree);\n for (const key of keys) {\n const summaryObject = summary.tree[key];\n\n switch (summaryObject.type) {\n case SummaryType.Tree: {\n treeNode.trees[key] =\n convertCreateNewSummaryTreeToTreeAndBlobsCore(summaryObject, blobs);\n break;\n }\n case SummaryType.Blob: {\n const contentBuffer = typeof summaryObject.content === \"string\" ?\n stringToBuffer(summaryObject.content, \"utf8\") : summaryObject.content;\n const blobId = uuid();\n treeNode.blobs[key] = blobId;\n blobs.set(blobId, contentBuffer);\n break;\n }\n case SummaryType.Handle:\n case SummaryType.Attachment: {\n throw new Error(`No ${summaryObject.type} should be present for detached summary!`);\n }\n default: {\n unreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n }\n }\n }\n return treeNode;\n}\n"]}
|
package/dist/epochTracker.d.ts
CHANGED
|
@@ -22,11 +22,12 @@ export declare class EpochTracker implements IPersistedFileCache {
|
|
|
22
22
|
protected readonly cache: IPersistedCache;
|
|
23
23
|
protected readonly fileEntry: IFileEntry;
|
|
24
24
|
protected readonly logger: ITelemetryLogger;
|
|
25
|
+
protected readonly clientIsSummarizer?: boolean | undefined;
|
|
25
26
|
private _fluidEpoch;
|
|
26
27
|
readonly rateLimiter: RateLimiter;
|
|
27
28
|
private readonly driverId;
|
|
28
29
|
private networkCallNumber;
|
|
29
|
-
constructor(cache: IPersistedCache, fileEntry: IFileEntry, logger: ITelemetryLogger);
|
|
30
|
+
constructor(cache: IPersistedCache, fileEntry: IFileEntry, logger: ITelemetryLogger, clientIsSummarizer?: boolean | undefined);
|
|
30
31
|
setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal): void;
|
|
31
32
|
get(entry: IEntry): Promise<any>;
|
|
32
33
|
put(entry: IEntry, value: any): Promise<void>;
|
|
@@ -83,5 +84,5 @@ export interface ICacheAndTracker {
|
|
|
83
84
|
cache: IOdspCache;
|
|
84
85
|
epochTracker: EpochTracker;
|
|
85
86
|
}
|
|
86
|
-
export declare function createOdspCacheAndTracker(persistedCacheArg: IPersistedCache, nonpersistentCache: INonPersistentCache, fileEntry: IFileEntry, logger: ITelemetryLogger): ICacheAndTracker;
|
|
87
|
+
export declare function createOdspCacheAndTracker(persistedCacheArg: IPersistedCache, nonpersistentCache: INonPersistentCache, fileEntry: IFileEntry, logger: ITelemetryLogger, clientIsSummarizer?: boolean): ICacheAndTracker;
|
|
87
88
|
//# sourceMappingURL=epochTracker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epochTracker.d.ts","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAmB,WAAW,EAAqB,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAClE,OAAO,EAGH,MAAM,EACN,UAAU,EACV,eAAe,EAElB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAA0E,aAAa,EAAE,MAAM,aAAa,CAAC;AACpH,OAAO,EACH,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACrB,MAAM,aAAa,CAAC;AAKtB,oBAAY,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,YAAY,GAAG,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,cAAc,GAC1G,aAAa,GAAG,eAAe,GAAG,MAAM,GAAG,UAAU,CAAC;AAE1D,oBAAY,iBAAiB,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpD,eAAO,MAAM,YAAY,iBAAi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kCzB,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,yBAAyB;IAajC,SAAS,CAAC,yBAAyB,CAC/B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,SAAS,EAAE,iBAAiB,EAC5B,SAAS,GAAE,OAAe;YAahB,kBAAkB;IA6BhC,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,kBAAkB;CAG7B;AAED,qBAAa,0BAA2B,SAAQ,YAAY;IACxD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAwB;IAE5D,SAAS,CAAC,yBAAyB,CAC/B,iBAAiB,EAAE,MAAM,GAAG,SAAS,EACrC,SAAS,EAAE,SAAS,EACpB,SAAS,GAAE,OAAe;IAUjB,GAAG,CACZ,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,GAAG,CAAC;IAuBF,mBAAmB,CAAC,CAAC,EAC9B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC;KAAE,EACvC,SAAS,EAAE,SAAS,EACpB,SAAS,GAAE,OAAe,EAC1B,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;CAgD/B;AAED,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,UAAU,CAAC;IAClB,YAAY,EAAE,YAAY,CAAC;CAC9B;AAED,wBAAgB,yBAAyB,CACrC,iBAAiB,EAAE,eAAe,EAClC,kBAAkB,EAAE,mBAAmB,EACvC,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,gBAAgB,EACxB,kBAAkB,CAAC,EAAE,OAAO,GAAG,gBAAgB,CASlD"}
|
package/dist/epochTracker.js
CHANGED
|
@@ -25,10 +25,11 @@ exports.defaultCacheExpiryTimeoutMs = 2 * 24 * 60 * 60 * 1000;
|
|
|
25
25
|
* then it also clears all the cached entries for the given container.
|
|
26
26
|
*/
|
|
27
27
|
class EpochTracker {
|
|
28
|
-
constructor(cache, fileEntry, logger) {
|
|
28
|
+
constructor(cache, fileEntry, logger, clientIsSummarizer) {
|
|
29
29
|
this.cache = cache;
|
|
30
30
|
this.fileEntry = fileEntry;
|
|
31
31
|
this.logger = logger;
|
|
32
|
+
this.clientIsSummarizer = clientIsSummarizer;
|
|
32
33
|
this.driverId = (0, uuid_1.v4)();
|
|
33
34
|
// This tracks the request number made by the driver instance.
|
|
34
35
|
this.networkCallNumber = 1;
|
|
@@ -231,7 +232,12 @@ class EpochTracker {
|
|
|
231
232
|
fetchOptions.body = formParams.join("\r\n");
|
|
232
233
|
}
|
|
233
234
|
formatClientCorrelationId(fetchReason) {
|
|
234
|
-
const items = [
|
|
235
|
+
const items = [
|
|
236
|
+
`driverId=${this.driverId}`,
|
|
237
|
+
`RequestNumber=${this.networkCallNumber++}`,
|
|
238
|
+
`driverVersion=${packageVersion_1.pkgVersion}`,
|
|
239
|
+
`isSummarizer=${this.clientIsSummarizer}`,
|
|
240
|
+
];
|
|
235
241
|
if (fetchReason !== undefined) {
|
|
236
242
|
items.push(`fetchReason=${fetchReason}`);
|
|
237
243
|
}
|
|
@@ -361,8 +367,8 @@ class EpochTrackerWithRedemption extends EpochTracker {
|
|
|
361
367
|
}
|
|
362
368
|
}
|
|
363
369
|
exports.EpochTrackerWithRedemption = EpochTrackerWithRedemption;
|
|
364
|
-
function createOdspCacheAndTracker(persistedCacheArg, nonpersistentCache, fileEntry, logger) {
|
|
365
|
-
const epochTracker = new EpochTrackerWithRedemption(persistedCacheArg, fileEntry, logger);
|
|
370
|
+
function createOdspCacheAndTracker(persistedCacheArg, nonpersistentCache, fileEntry, logger, clientIsSummarizer) {
|
|
371
|
+
const epochTracker = new EpochTrackerWithRedemption(persistedCacheArg, fileEntry, logger, clientIsSummarizer);
|
|
366
372
|
return {
|
|
367
373
|
cache: Object.assign(Object.assign({}, nonpersistentCache), { persistedCache: epochTracker }),
|
|
368
374
|
epochTracker,
|