@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.
Files changed (123) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/ReadBufferUtils.d.ts.map +1 -1
  3. package/dist/ReadBufferUtils.js +0 -1
  4. package/dist/ReadBufferUtils.js.map +1 -1
  5. package/dist/WriteBufferUtils.d.ts.map +1 -1
  6. package/dist/WriteBufferUtils.js +0 -2
  7. package/dist/WriteBufferUtils.js.map +1 -1
  8. package/dist/compactSnapshotParser.d.ts.map +1 -1
  9. package/dist/compactSnapshotParser.js +2 -18
  10. package/dist/compactSnapshotParser.js.map +1 -1
  11. package/dist/compactSnapshotWriter.d.ts.map +1 -1
  12. package/dist/compactSnapshotWriter.js +1 -3
  13. package/dist/compactSnapshotWriter.js.map +1 -1
  14. package/dist/createNewUtils.d.ts.map +1 -1
  15. package/dist/createNewUtils.js +0 -2
  16. package/dist/createNewUtils.js.map +1 -1
  17. package/dist/fetchSnapshot.d.ts.map +1 -1
  18. package/dist/fetchSnapshot.js +1 -2
  19. package/dist/fetchSnapshot.js.map +1 -1
  20. package/dist/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
  21. package/dist/localOdspDriver/localOdspDeltaStorageService.js +0 -1
  22. package/dist/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
  23. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  24. package/dist/odspDelayLoadedDeltaStream.js +0 -2
  25. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  26. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  27. package/dist/odspDeltaStorageService.js +1 -4
  28. package/dist/odspDeltaStorageService.js.map +1 -1
  29. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  30. package/dist/odspDocumentDeltaConnection.js +1 -6
  31. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  32. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  33. package/dist/odspDocumentStorageServiceBase.js +0 -2
  34. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  35. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  36. package/dist/odspDriverUrlResolver.js +1 -2
  37. package/dist/odspDriverUrlResolver.js.map +1 -1
  38. package/dist/odspSnapshotParser.d.ts.map +1 -1
  39. package/dist/odspSnapshotParser.js +1 -5
  40. package/dist/odspSnapshotParser.js.map +1 -1
  41. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  42. package/dist/odspSummaryUploadManager.js +0 -1
  43. package/dist/odspSummaryUploadManager.js.map +1 -1
  44. package/dist/odspUrlHelper.d.ts.map +1 -1
  45. package/dist/odspUrlHelper.js +1 -5
  46. package/dist/odspUrlHelper.js.map +1 -1
  47. package/dist/packageVersion.d.ts +1 -1
  48. package/dist/packageVersion.js +1 -1
  49. package/dist/packageVersion.js.map +1 -1
  50. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  51. package/dist/zipItDataRepresentationUtils.js +0 -9
  52. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  53. package/lib/ReadBufferUtils.d.ts.map +1 -1
  54. package/lib/ReadBufferUtils.js +0 -1
  55. package/lib/ReadBufferUtils.js.map +1 -1
  56. package/lib/WriteBufferUtils.d.ts.map +1 -1
  57. package/lib/WriteBufferUtils.js +0 -2
  58. package/lib/WriteBufferUtils.js.map +1 -1
  59. package/lib/compactSnapshotParser.d.ts.map +1 -1
  60. package/lib/compactSnapshotParser.js +2 -18
  61. package/lib/compactSnapshotParser.js.map +1 -1
  62. package/lib/compactSnapshotWriter.d.ts.map +1 -1
  63. package/lib/compactSnapshotWriter.js +1 -3
  64. package/lib/compactSnapshotWriter.js.map +1 -1
  65. package/lib/createNewUtils.d.ts.map +1 -1
  66. package/lib/createNewUtils.js +0 -2
  67. package/lib/createNewUtils.js.map +1 -1
  68. package/lib/fetchSnapshot.d.ts.map +1 -1
  69. package/lib/fetchSnapshot.js +1 -2
  70. package/lib/fetchSnapshot.js.map +1 -1
  71. package/lib/localOdspDriver/localOdspDeltaStorageService.d.ts.map +1 -1
  72. package/lib/localOdspDriver/localOdspDeltaStorageService.js +0 -1
  73. package/lib/localOdspDriver/localOdspDeltaStorageService.js.map +1 -1
  74. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  75. package/lib/odspDelayLoadedDeltaStream.js +0 -2
  76. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  77. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  78. package/lib/odspDeltaStorageService.js +1 -4
  79. package/lib/odspDeltaStorageService.js.map +1 -1
  80. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  81. package/lib/odspDocumentDeltaConnection.js +1 -6
  82. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  83. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  84. package/lib/odspDocumentStorageServiceBase.js +0 -2
  85. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  86. package/lib/odspDriverUrlResolver.d.ts.map +1 -1
  87. package/lib/odspDriverUrlResolver.js +1 -2
  88. package/lib/odspDriverUrlResolver.js.map +1 -1
  89. package/lib/odspSnapshotParser.d.ts.map +1 -1
  90. package/lib/odspSnapshotParser.js +1 -5
  91. package/lib/odspSnapshotParser.js.map +1 -1
  92. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  93. package/lib/odspSummaryUploadManager.js +0 -1
  94. package/lib/odspSummaryUploadManager.js.map +1 -1
  95. package/lib/odspUrlHelper.d.ts.map +1 -1
  96. package/lib/odspUrlHelper.js +1 -5
  97. package/lib/odspUrlHelper.js.map +1 -1
  98. package/lib/packageVersion.d.ts +1 -1
  99. package/lib/packageVersion.js +1 -1
  100. package/lib/packageVersion.js.map +1 -1
  101. package/lib/tsdoc-metadata.json +1 -1
  102. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  103. package/lib/zipItDataRepresentationUtils.js +0 -9
  104. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  105. package/package.json +18 -17
  106. package/src/ReadBufferUtils.ts +1 -2
  107. package/src/WriteBufferUtils.ts +2 -4
  108. package/src/compactSnapshotParser.ts +14 -28
  109. package/src/compactSnapshotWriter.ts +2 -4
  110. package/src/createNewUtils.ts +2 -4
  111. package/src/fetchSnapshot.ts +1 -2
  112. package/src/localOdspDriver/localOdspDeltaStorageService.ts +1 -2
  113. package/src/odspDelayLoadedDeltaStream.ts +2 -4
  114. package/src/odspDeltaStorageService.ts +2 -4
  115. package/src/odspDocumentDeltaConnection.ts +3 -8
  116. package/src/odspDocumentStorageServiceBase.ts +2 -4
  117. package/src/odspDriverUrlResolver.ts +1 -2
  118. package/src/odspSnapshotParser.ts +4 -8
  119. package/src/odspSummaryUploadManager.ts +1 -2
  120. package/src/odspUrlHelper.ts +4 -8
  121. package/src/packageVersion.ts +1 -1
  122. package/src/zipItDataRepresentationUtils.ts +9 -18
  123. package/tsconfig.json +1 -0
@@ -14,7 +14,6 @@ import { SocketIOClientStatic } from "./socketModule.js";
14
14
  const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
15
15
  const feature_get_ops = "api_get_ops";
16
16
  const feature_flush_ops = "api_flush_ops";
17
- const feature_submit_signals_v2 = "submit_signals_v2";
18
17
  // How long to wait before disconnecting the socket after the last reference is removed
19
18
  // This allows reconnection after receiving a nack to be smooth
20
19
  const socketReferenceBufferTime = 2000;
@@ -188,9 +187,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
188
187
  epoch: epochTracker.fluidEpoch,
189
188
  relayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(";"),
190
189
  };
191
- connectMessage.supportedFeatures = {
192
- [feature_submit_signals_v2]: true,
193
- };
190
+ connectMessage.supportedFeatures = {};
194
191
  // Reference to this client supporting get_ops flow.
195
192
  if (mc.config.getBoolean("Fluid.Driver.Odsp.GetOpsEnabled") !== false) {
196
193
  connectMessage.supportedFeatures[feature_get_ops] = true;
@@ -412,9 +409,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
412
409
  if (messages !== undefined && messages.length > 0) {
413
410
  this.logger.sendPerformanceEvent({
414
411
  ...common,
415
- // Non null asserting here because of the length check above
416
412
  first: messages[0].sequenceNumber,
417
- // Non null asserting here because of the length check above
418
413
  last: messages[messages.length - 1].sequenceNumber,
419
414
  length: messages.length,
420
415
  });
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAW/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAGN,yBAAyB,GACzB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAIlC,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAClE,MAAM,eAAe,GAAG,aAAa,CAAC;AACtC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAC1C,MAAM,yBAAyB,GAAG,mBAAmB,CAAC;AAOtD,uFAAuF;AACvF,+DAA+D;AAC/D,MAAM,yBAAyB,GAAG,IAAI,CAAC;AASvC,MAAM,eAAgB,SAAQ,iBAAgC;IActD,MAAM,CAAC,I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C/C,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACnF,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1B,MAAM,CACL,IAAI,CAAC,eAAe,KAAK,SAAS,EAClC,KAAK,CAAC,4CAA4C,CAClD,CAAC;IACH,CAAC;IAED;;OAEG;IACO,cAAc;QACvB,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACtE,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QAEjC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,qEAAqE;YACrE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,CAAC,uBAAuB,EAAE,CAAC;IAClC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter, performance } from \"@fluid-internal/client-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIAnyDriverError,\n\tIConnect,\n\tIDocumentMessage,\n\tINack,\n\tISentSignalMessage,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils/internal\";\nimport { OdspError } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tIFluidErrorBase,\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { Socket } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { IFlushOpsResponse, IGetOpsResponse, IOdspSocketError } from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { errorObjectFromSocketError } from \"./odspError.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\nimport { SocketIOClientStatic } from \"./socketModule.js\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\nconst feature_get_ops = \"api_get_ops\";\nconst feature_flush_ops = \"api_flush_ops\";\nconst feature_submit_signals_v2 = \"submit_signals_v2\";\n\nexport interface FlushResult {\n\tlastPersistedSequenceNumber?: number;\n\tretryAfter?: number;\n}\n\n// How long to wait before disconnecting the socket after the last reference is removed\n// This allows reconnection after receiving a nack to be smooth\nconst socketReferenceBufferTime = 2000;\n\ninterface ISocketEvents extends IEvent {\n\t(\n\t\tevent: \"disconnect\",\n\t\tlistener: (error: IFluidErrorBase & OdspError, clientId?: string) => void,\n\t);\n}\n\nclass SocketReference extends TypedEventEmitter<ISocketEvents> {\n\tprivate references: number = 1;\n\tprivate delayDeleteTimeout: ReturnType<typeof setTimeout> | undefined;\n\tprivate _socket: Socket | undefined;\n\n\t// When making decisions about socket reuse, we do not reuse disconnected socket.\n\t// But we want to differentiate the following case from disconnected case:\n\t// Socket that never connected and never failed, it's in \"attempting to connect\" mode\n\t// such sockets should be reused, despite socket.disconnected === true\n\tprivate isPendingInitialConnection = true;\n\n\t// Map of all existing socket io sockets. [url, tenantId, documentId] -> socket\n\tprivate static readonly socketIoSockets: Map<string, SocketReference> = new Map();\n\n\tpublic static find(key: string, logger: ITelemetryLoggerExt): SocketReference | undefined {\n\t\tconst socketReference = SocketReference.socketIoSockets.get(key);\n\n\t\t// Verify the socket is healthy before reusing it\n\t\tif (socketReference?.disconnected) {\n\t\t\t// The socket is in a bad state. fully remove the reference\n\t\t\tsocketReference.closeSocket();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (socketReference) {\n\t\t\t// Clear the pending deletion if there is one\n\t\t\tsocketReference.clearTimer();\n\t\t\tsocketReference.references++;\n\t\t}\n\n\t\treturn socketReference;\n\t}\n\n\t/**\n\t * Removes a reference for the given key\n\t * Once the ref count hits 0, the socket is disconnected and removed\n\t */\n\tpublic removeSocketIoReference(): void {\n\t\tassert(this.references > 0, 0x09f /* \"No more socketIO refs to remove!\" */);\n\t\tthis.references--;\n\n\t\t// see comment in disconnected() getter\n\t\tthis.isPendingInitialConnection = false;\n\n\t\tif (this.disconnected) {\n\t\t\tthis.closeSocket();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.references === 0 && this.delayDeleteTimeout === undefined) {\n\t\t\tthis.delayDeleteTimeout = setTimeout(() => {\n\t\t\t\t// We should not get here with active users.\n\t\t\t\tassert(this.references === 0, 0x0a0 /* \"Unexpected socketIO references on timeout\" */);\n\t\t\t\tthis.closeSocket();\n\t\t\t}, socketReferenceBufferTime);\n\t\t}\n\t}\n\n\tpublic get socket(): Socket {\n\t\tif (!this._socket) {\n\t\t\tthrow new Error(`Invalid socket for key \"${this.key}`);\n\t\t}\n\t\treturn this._socket;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly key: string,\n\t\tsocket: Socket,\n\t) {\n\t\tsuper();\n\n\t\tthis._socket = socket;\n\t\tassert(!SocketReference.socketIoSockets.has(key), 0x220 /* \"socket key collision\" */);\n\t\tSocketReference.socketIoSockets.set(key, this);\n\n\t\t// Server sends this event when it wants to disconnect a particular client in which case the client id would\n\t\t// be present or if it wants to disconnect all the clients. The server always closes the socket in case all\n\t\t// clients needs to be disconnected. So fully remove the socket reference in this case.\n\t\tsocket.on(\"server_disconnect\", this.serverDisconnectEventHandler);\n\t}\n\n\tprivate readonly serverDisconnectEventHandler = (\n\t\tsocketError: IOdspSocketError,\n\t\tclientId?: string,\n\t): void => {\n\t\t// Treat all errors as recoverable, and rely on joinSession / reconnection flow to\n\t\t// filter out retryable vs. non-retryable cases.\n\t\tconst error = errorObjectFromSocketError(socketError, \"server_disconnect\");\n\t\terror.addTelemetryProperties({ disconnectClientId: clientId });\n\t\terror.canRetry = true;\n\n\t\t// see comment in disconnected() getter\n\t\t// Setting it here to ensure socket reuse does not happen if new request to connect\n\t\t// comes in from \"disconnect\" listener below, before we close socket.\n\t\tthis.isPendingInitialConnection = false;\n\n\t\tif (clientId === undefined) {\n\t\t\t// We could first raise \"disconnect\" event, but that may result in socket reuse due to\n\t\t\t// new connection comming in. So, it's better to have more explicit flow to make it impossible.\n\t\t\tthis.closeSocket(error);\n\t\t} else {\n\t\t\tthis.emit(\"disconnect\", error, clientId);\n\t\t}\n\t};\n\n\tprivate clearTimer(): void {\n\t\tif (this.delayDeleteTimeout !== undefined) {\n\t\t\tclearTimeout(this.delayDeleteTimeout);\n\t\t\tthis.delayDeleteTimeout = undefined;\n\t\t}\n\t}\n\n\tpublic closeSocket(error?: IAnyDriverError): void {\n\t\tif (!this._socket) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._socket.off(\"server_disconnect\", this.serverDisconnectEventHandler);\n\t\tthis.clearTimer();\n\n\t\tassert(\n\t\t\tSocketReference.socketIoSockets.get(this.key) === this,\n\t\t\t0x0a1 /* \"Socket reference set unexpectedly does not point to this socket!\" */,\n\t\t);\n\n\t\t// First, remove socket to ensure no socket reuse is possible.\n\t\tSocketReference.socketIoSockets.delete(this.key);\n\n\t\t// Block access to socket. From now on, calls like flush() or requestOps()\n\t\t// Disconnect flow should be synchronous and result in system fully forgetting about this connection / socket.\n\t\tconst socket = this._socket;\n\t\tthis._socket = undefined;\n\n\t\t// Let all connections know they need to go through disconnect flow.\n\t\tthis.emit(\n\t\t\t\"disconnect\",\n\t\t\terror ??\n\t\t\t\tcreateGenericNetworkError(\n\t\t\t\t\t\"Socket closed without error\",\n\t\t\t\t\t{ canRetry: true },\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t),\n\t\t\tundefined /* clientId */,\n\t\t);\n\n\t\t// We should not have any users now, assuming synchronous disconnect flow in response to\n\t\t// \"disconnect\" event\n\t\tassert(\n\t\t\tthis.references === 0,\n\t\t\t0x412 /* Nobody should be connected to this socket at this point! */,\n\t\t);\n\n\t\tsocket.disconnect();\n\t}\n\n\tpublic get disconnected(): boolean {\n\t\tif (this._socket === undefined) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.socket.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// We have a socket that is not connected. Possible cases:\n\t\t// 1) It was connected some time ago and lost connection. We do not want to reuse it.\n\t\t// 2) It failed to connect (was never connected).\n\t\t// 3) It was just created and never had a chance to connect - connection is in process.\n\t\t// We have to differentiate 1 from 2-3 (specifically 1 & 3) in order to be able to reuse socket in #3.\n\t\t// We will use the fact that socket had some activity. I.e. if socket disconnected, or client stopped using\n\t\t// socket, then removeSocketIoReference() will be called for it, and it will be the indiction that it's not #3.\n\t\treturn !this.isPendingInitialConnection;\n\t}\n}\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class OdspDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a OdspDocumentDeltaConnection\n\t * If url #1 fails to connect, will try url #2 if applicable.\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param mode - mode of the client\n\t * @param url - websocket URL\n\t * @param telemetryLogger - optional telemetry logger\n\t * @param timeoutMs - time limit on making the connection\n\t * @param epochTracker - track epoch changes\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\turl: string,\n\t\ttelemetryLogger: ITelemetryLoggerExt,\n\t\ttimeoutMs: number,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix: string | undefined,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst mc = loggerToMonitoringContext(telemetryLogger);\n\n\t\t// enable multiplexing when the websocket url does not include the tenant/document id\n\t\tconst parsedUrl = new URL(url);\n\t\tconst enableMultiplexing =\n\t\t\t!parsedUrl.searchParams.has(\"documentId\") && !parsedUrl.searchParams.has(\"tenantId\");\n\n\t\t// do not include the specific tenant/doc id in the ref key when multiplexing\n\t\t// this will allow multiple documents to share the same websocket connection\n\t\tconst key = socketReferenceKeyPrefix ? `${socketReferenceKeyPrefix},${url}` : url;\n\t\tconst socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;\n\n\t\tconst socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(\n\t\t\ttimeoutMs,\n\t\t\tsocketReferenceKey,\n\t\t\turl,\n\t\t\tenableMultiplexing,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttelemetryLogger,\n\t\t);\n\n\t\tconst socket = socketReference.socket;\n\t\tconst connectionId = uuid();\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid: documentId,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: protocolVersions,\n\t\t\tdriverVersion: pkgVersion,\n\t\t\tnonce: connectionId,\n\t\t\tepoch: epochTracker.fluidEpoch,\n\t\t\trelayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(\";\"),\n\t\t};\n\n\t\tconnectMessage.supportedFeatures = {\n\t\t\t[feature_submit_signals_v2]: true,\n\t\t};\n\n\t\t// Reference to this client supporting get_ops flow.\n\t\tif (mc.config.getBoolean(\"Fluid.Driver.Odsp.GetOpsEnabled\") !== false) {\n\t\t\tconnectMessage.supportedFeatures[feature_get_ops] = true;\n\t\t}\n\n\t\tconst deltaConnection = new OdspDocumentDeltaConnection(\n\t\t\tsocket,\n\t\t\tdocumentId,\n\t\t\tsocketReference,\n\t\t\ttelemetryLogger,\n\t\t\tenableMultiplexing,\n\t\t\tconnectionId,\n\t\t);\n\n\t\ttry {\n\t\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\t\tawait epochTracker.validateEpoch(deltaConnection.details.epoch, \"push\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\tif (error !== null && typeof error === \"object\") {\n\t\t\t\t// We have to special-case error types here in terms of what is re-triable.\n\t\t\t\t// These errors have to re-retried, we just need new joinSession result to connect to right server:\n\t\t\t\t// 400: Invalid tenant or document id. The WebSocket is connected to a different document\n\t\t\t\t// Document is full (with retryAfter)\n\t\t\t\t// 404: Invalid document. The document \\\"local/w1-...\\\" does not exist\n\t\t\t\t// But this has to stay not-retriable:\n\t\t\t\t// 406: Unsupported client protocol. This path is the only gatekeeper, have to fail!\n\t\t\t\t// 409: Epoch Version Mismatch. Client epoch and server epoch does not match, so app needs\n\t\t\t\t// to be refreshed.\n\t\t\t\t// This one is fine either way\n\t\t\t\t// 401/403: Code will retry once with new token either way, then it becomes fatal - on this path\n\t\t\t\t// and on join Session path.\n\t\t\t\t// 501: (Fluid not enabled): this is fine either way, as joinSession is gatekeeper\n\t\t\t\t// eslint-disable-next-line unicorn/no-lonely-if, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tif (error.statusCode === 400 || error.statusCode === 404) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.canRetry = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate socketReference: SocketReference | undefined;\n\n\tprivate readonly requestOpsNoncePrefix: string;\n\tprivate pushCallCounter = 0;\n\tprivate readonly getOpsMap: Map<string, { start: number; from: number; to: number }> =\n\t\tnew Map();\n\tprivate flushOpNonce: string | undefined;\n\tprivate flushDeferred: Deferred<FlushResult> | undefined;\n\tprivate connectionNotYetDisposedTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(\n\t\thandler: string,\n\t\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\t\terror?: any,\n\t\tcanRetry = true,\n\t): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.\n\t\t// - anything else: let base class handle it\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\treturn canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\"\n\t\t\t? errorObjectFromSocketError(error as IOdspSocketError, handler)\n\t\t\t: super.createErrorObject(handler, error, canRetry);\n\t}\n\n\t/**\n\t * Gets or create a socket io connection for the given key\n\t */\n\tprivate static getOrCreateSocketIoReference(\n\t\ttimeoutMs: number,\n\t\tkey: string,\n\t\turl: string,\n\t\tenableMultiplexing: boolean,\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SocketReference {\n\t\t// eslint-disable-next-line unicorn/no-array-callback-reference, unicorn/no-array-method-this-argument\n\t\tconst existingSocketReference = SocketReference.find(key, logger);\n\t\tif (existingSocketReference) {\n\t\t\treturn existingSocketReference;\n\t\t}\n\n\t\tconst query = enableMultiplexing ? undefined : { documentId, tenantId };\n\n\t\tconst socket = SocketIOClientStatic(url, {\n\t\t\tmultiplex: false, // Don't rely on socket.io built-in multiplexing\n\t\t\tquery,\n\t\t\treconnection: false,\n\t\t\ttransports: [\"websocket\"],\n\t\t\ttimeout: timeoutMs,\n\t\t});\n\n\t\treturn new SocketReference(key, socket);\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param details - details of the websocket connection\n\t * @param socketReferenceKey - socket reference key\n\t * @param enableMultiplexing - If the websocket is multiplexing multiple documents\n\t */\n\tprivate constructor(\n\t\tsocket: Socket,\n\t\tdocumentId: string,\n\t\tsocketReference: SocketReference,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableMultiplexing?: boolean,\n\t\tconnectionId?: string,\n\t) {\n\t\tsuper(socket, documentId, logger, false, connectionId);\n\t\tthis.socketReference = socketReference;\n\t\tthis.requestOpsNoncePrefix = `${uuid()}-`;\n\t}\n\n\t/**\n\t * Retrieves ops from PUSH\n\t * @param from - inclusive\n\t * @param to - exclusive\n\t * @returns ops retrieved\n\t */\n\tpublic requestOps(from: number, to: number): void {\n\t\tassert(!this.socketReference?.disconnected, 0x413 /* non-active socket */);\n\n\t\t// Given that to is exclusive, we should be asking for at least something!\n\t\tassert(to > from, 0x272 /* \"empty request\" */);\n\n\t\t// PUSH may disable this functionality\n\t\t// back-compat: remove cast to any once latest version of IConnected is consumed\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n\t\tif ((this.details as any).supportedFeatures?.[feature_get_ops] !== true) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pushCallCounter++;\n\t\tconst nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n\t\tconst start = performance.now();\n\n\t\t// We may keep keep accumulating memory for nothing, if we are not getting responses.\n\t\t// Note that we should not have overlapping requests, as DeltaManager allows only one\n\t\t// outstanding request to storage, and that's the only way to get here.\n\t\t// But requests could be cancelled, and thus overlapping requests might be in the picture\n\t\t// If it happens, we do not care about stale requests.\n\t\t// So track some number of requests, but log if we get too many in flight - that likely\n\t\t// indicates an error somewhere.\n\t\tif (this.getOpsMap.size >= 5) {\n\t\t\tlet time = start;\n\t\t\tlet key: string | undefined;\n\t\t\tfor (const [keyCandidate, value] of this.getOpsMap.entries()) {\n\t\t\t\tif (value.start <= time || key === undefined) {\n\t\t\t\t\ttime = value.start;\n\t\t\t\t\tkey = keyCandidate;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst payloadToDelete = this.getOpsMap.get(key!)!;\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"GetOpsTooMany\",\n\t\t\t\tnonce,\n\t\t\t\tfrom: payloadToDelete.from,\n\t\t\t\tto: payloadToDelete.to,\n\t\t\t\tlength: payloadToDelete.to - payloadToDelete.from,\n\t\t\t\tduration: performance.now() - payloadToDelete.start,\n\t\t\t});\n\t\t\tthis.getOpsMap.delete(key!);\n\t\t}\n\t\tthis.getOpsMap.set(nonce, {\n\t\t\tstart,\n\t\t\tfrom,\n\t\t\tto,\n\t\t});\n\t\tthis.socket.emit(\"get_ops\", this.clientId, {\n\t\t\tnonce,\n\t\t\tfrom,\n\t\t\tto: to - 1,\n\t\t});\n\t}\n\n\tpublic async flush(): Promise<FlushResult> {\n\t\tassert(!this.socketReference?.disconnected, 0x414 /* non-active socket */);\n\n\t\t// back-compat: remove cast to any once latest version of IConnected is consumed\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n\t\tif ((this.details as any).supportedFeatures?.[feature_flush_ops] !== true) {\n\t\t\t// Once single-commit summary is enabled end-to-end, flush support is a must!\n\t\t\t// The only alternative is change in design where SPO fetches ops from PUSH OR\n\t\t\t// summary includes required ops and SPO has some validation mechanism to ensure\n\t\t\t// they are not forged by client.\n\t\t\t// If design changes, we can reconsider it, but right now it's non-recoverable failure.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FlushOpsNotSupported\" });\n\t\t\tthrow new Error(\n\t\t\t\t\"flush() API is not supported by PUSH, required for single-commit summaries\",\n\t\t\t);\n\t\t}\n\n\t\tthis.pushCallCounter++;\n\t\tconst nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n\t\t// There should be only one flush ops in flight, kicked out by upload summary workflow\n\t\t// That said, it could timeout and request could be repeated, so theoretically we can\n\t\t// get overlapping requests, but it should be very rare\n\t\tif (this.flushDeferred !== undefined) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FlushOpsTooMany\" });\n\t\t\tthis.flushDeferred.reject(\n\t\t\t\t\"process involving flush() was cancelled OR unsupported concurrency\",\n\t\t\t);\n\t\t}\n\t\tthis.socket.emit(\"flush_ops\", this.clientId, { nonce });\n\n\t\tthis.flushOpNonce = nonce;\n\t\tthis.flushDeferred = new Deferred<FlushResult>();\n\t\treturn this.flushDeferred.promise;\n\t}\n\n\tprotected disconnectHandler = (\n\t\terror: IFluidErrorBase & OdspError,\n\t\tclientId?: string,\n\t): void => {\n\t\tif (clientId === undefined || clientId === this.clientId) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"ServerDisconnect\",\n\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.disconnect(error);\n\t\t}\n\t};\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number): Promise<void> {\n\t\tassert(!this.socketReference?.disconnected, 0x415 /* non-active socket */);\n\n\t\tif (this.enableMultiplexing) {\n\t\t\t// multiplex compatible early handlers\n\t\t\tthis.earlyOpHandler = (\n\t\t\t\tmessageDocumentId: string,\n\t\t\t\tmsgs: ISequencedDocumentMessage[],\n\t\t\t): void => {\n\t\t\t\tif (this.documentId === messageDocumentId) {\n\t\t\t\t\tthis.queuedMessages.push(...msgs);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.earlySignalHandler = (\n\t\t\t\tmsg: ISignalMessage | ISignalMessage[],\n\t\t\t\tmessageDocumentId?: string,\n\t\t\t): void => {\n\t\t\t\tif (messageDocumentId === undefined || messageDocumentId === this.documentId) {\n\t\t\t\t\tif (Array.isArray(msg)) {\n\t\t\t\t\t\tthis.queuedSignals.push(...msg);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.queuedSignals.push(msg);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tthis.socketReference!.on(\"disconnect\", this.disconnectHandler);\n\n\t\tthis.addTrackedListener(\"get_ops_response\", (result: IGetOpsResponse) => {\n\t\t\tconst messages = result.messages;\n\t\t\tconst data = this.getOpsMap.get(result.nonce);\n\t\t\t// Due to socket multiplexing, this client may not have asked for any data\n\t\t\t// If so, there it most likely does not need these ops (otherwise it already asked for them)\n\t\t\t// Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.\n\t\t\t// But not processing such result may push us into infinite loop of fast requests and dropping all responses\n\t\t\tif (data !== undefined || result.nonce.startsWith(this.requestOpsNoncePrefix)) {\n\t\t\t\tthis.getOpsMap.delete(result.nonce);\n\t\t\t\tconst common = {\n\t\t\t\t\teventName: \"GetOps\",\n\t\t\t\t\t// We need nonce only to pair with GetOpsTooMany events, i.e. when record was deleted\n\t\t\t\t\tnonce: data === undefined ? result.nonce : undefined,\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tfrom: data?.from,\n\t\t\t\t\tto: data?.to,\n\t\t\t\t\tduration: data === undefined ? undefined : performance.now() - data.start,\n\t\t\t\t};\n\t\t\t\tif (messages !== undefined && messages.length > 0) {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t\t\tfirst: messages[0]!.sequenceNumber,\n\t\t\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t\t\tlast: messages[messages.length - 1]!.sequenceNumber,\n\t\t\t\t\t\tlength: messages.length,\n\t\t\t\t\t});\n\t\t\t\t\tthis.emit(\"op\", this.documentId, messages);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\tlength: 0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.addTrackedListener(\"flush_ops_response\", (result: IFlushOpsResponse) => {\n\t\t\tif (this.flushOpNonce === result.nonce) {\n\t\t\t\tconst seq = result.lastPersistedSequenceNumber;\n\t\t\t\tlet category: \"generic\" | \"error\" = \"generic\";\n\t\t\t\tif (result.lastPersistedSequenceNumber === undefined || result.code !== 200) {\n\t\t\t\t\tswitch (result.code) {\n\t\t\t\t\t\tcase 409:\n\t\t\t\t\t\tcase 429: {\n\t\t\t\t\t\t\tcategory = \"error\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 204: {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tcategory = \"error\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"FlushResult\",\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tsequenceNumber: seq,\n\t\t\t\t\tcategory,\n\t\t\t\t});\n\t\t\t\tthis.flushDeferred!.resolve(result);\n\t\t\t\tthis.flushDeferred = undefined;\n\t\t\t\tthis.flushOpNonce = undefined;\n\t\t\t}\n\t\t});\n\n\t\tawait super.initialize(connectMessage, timeout).finally(() => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"ConnectionAttemptInfo\",\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t});\n\t\t});\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void): void {\n\t\t// override some event listeners in order to support multiple documents/clients over the same websocket\n\t\tswitch (event) {\n\t\t\tcase \"op\": {\n\t\t\t\t// per document op handling\n\t\t\t\tsuper.addTrackedListener(\n\t\t\t\t\tevent,\n\t\t\t\t\t(documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\t\t\t\t\tif (!this.enableMultiplexing || this.documentId === documentId) {\n\t\t\t\t\t\t\tlistener(documentId, msgs);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"signal\": {\n\t\t\t\t// per document signal handling\n\t\t\t\tsuper.addTrackedListener(\n\t\t\t\t\tevent,\n\t\t\t\t\t(msg: ISignalMessage | ISignalMessage[], documentId?: string) => {\n\t\t\t\t\t\tif (!this.enableMultiplexing || !documentId || documentId === this.documentId) {\n\t\t\t\t\t\t\tlistener(msg, documentId);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"nack\": {\n\t\t\t\t// per client / document nack handling\n\t\t\t\tsuper.addTrackedListener(event, (clientIdOrDocumentId: string, nacks: INack[]) => {\n\t\t\t\t\tconst handle =\n\t\t\t\t\t\tclientIdOrDocumentId.length === 0 ||\n\t\t\t\t\t\tclientIdOrDocumentId === this.documentId ||\n\t\t\t\t\t\tclientIdOrDocumentId === this.clientId;\n\t\t\t\t\tconst { code, type, message, retryAfter } = nacks[0]?.content ?? {};\n\t\t\t\t\tconst { clientSequenceNumber, referenceSequenceNumber } = nacks[0]?.operation ?? {};\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"ServerNack\",\n\t\t\t\t\t\tcode,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tretryAfterSeconds: retryAfter,\n\t\t\t\t\t\tclientId: this.clientId,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\t\topType: nacks[0]?.operation?.type,\n\t\t\t\t\t});\n\t\t\t\t\tif (handle) {\n\t\t\t\t\t\tthis.emit(\"nack\", clientIdOrDocumentId, nacks);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tsuper.addTrackedListener(event, listener);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get disposed(): boolean {\n\t\tif (!(this._disposed || this.socket.connected)) {\n\t\t\t// Send error event if this connection is not yet disposed after socket is disconnected for 15s.\n\t\t\t// eslint-disable-next-line unicorn/no-lonely-if\n\t\t\tif (this.connectionNotYetDisposedTimeout === undefined) {\n\t\t\t\tthis.connectionNotYetDisposedTimeout = setTimeout(() => {\n\t\t\t\t\tif (!this._disposed) {\n\t\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\t\teventName: \"ConnectionNotYetDisposed\",\n\t\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}, 15000);\n\t\t\t}\n\t\t}\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Returns true in case the connection is not yet disposed and the socket is also connected. The expectation is\n\t * that it will be called only after connection is fully established. i.e. there should no way to submit an op\n\t * while we are connecting, as connection object is not exposed to Loader layer until connection is established.\n\t */\n\tprivate get connected(): boolean {\n\t\treturn !this.disposed && this.socket.connected;\n\t}\n\n\tprotected override emitMessages(type: \"submitOp\", messages: IDocumentMessage[][]): void;\n\tprotected override emitMessages(\n\t\ttype: \"submitSignal\",\n\t\tmessages: string[][] | ISentSignalMessage[],\n\t): void;\n\tprotected override emitMessages(type: string, messages: unknown): void {\n\t\t// Only submit the op/signals if we are connected.\n\t\tif (this.connected) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param content - Content of the signal.\n\t * @param targetClientId - When specified, the signal is only sent to the provided client id.\n\t */\n\tpublic submitSignal(content: string, targetClientId?: string): void {\n\t\tconst signal: ISentSignalMessage = {\n\t\t\tcontent,\n\t\t\ttargetClientId,\n\t\t};\n\n\t\tthis.emitMessages(\"submitSignal\", [signal]);\n\t}\n\n\t/**\n\t * Critical path where we need to also close the socket for an error.\n\t * @param error - Error causing the socket to close.\n\t */\n\tprotected closeSocketCore(error: IAnyDriverError): void {\n\t\tconst socket = this.socketReference;\n\t\tassert(socket !== undefined, 0x416 /* reentrancy not supported in close socket */);\n\t\tsocket.closeSocket(error);\n\t\tassert(\n\t\t\tthis.socketReference === undefined,\n\t\t\t0x417 /* disconnect flow did not work correctly */,\n\t\t);\n\t}\n\n\t/**\n\t * Disconnect from the websocket\n\t */\n\tprotected disconnectCore(): void {\n\t\tconst socket = this.socketReference;\n\t\tassert(socket !== undefined, 0x0a2 /* \"reentrancy not supported!\" */);\n\t\tthis.socketReference = undefined;\n\n\t\tsocket.off(\"disconnect\", this.disconnectHandler);\n\t\tif (this.hasDetails) {\n\t\t\t// tell the server we are disconnecting this client from the document\n\t\t\tthis.socket.emit(\"disconnect_document\", this.clientId, this.documentId);\n\t\t}\n\n\t\tsocket.removeSocketIoReference();\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAW/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAGN,yBAAyB,GACzB,MAAM,0CAA0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right (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter, performance } from \"@fluid-internal/client-utils\";\nimport { IEvent } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIAnyDriverError,\n\tIConnect,\n\tIDocumentMessage,\n\tINack,\n\tISentSignalMessage,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { createGenericNetworkError } from \"@fluidframework/driver-utils/internal\";\nimport { OdspError } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tIFluidErrorBase,\n\tITelemetryLoggerExt,\n\tloggerToMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { Socket } from \"socket.io-client\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { IFlushOpsResponse, IGetOpsResponse, IOdspSocketError } from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { errorObjectFromSocketError } from \"./odspError.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\nimport { SocketIOClientStatic } from \"./socketModule.js\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\nconst feature_get_ops = \"api_get_ops\";\nconst feature_flush_ops = \"api_flush_ops\";\n\nexport interface FlushResult {\n\tlastPersistedSequenceNumber?: number;\n\tretryAfter?: number;\n}\n\n// How long to wait before disconnecting the socket after the last reference is removed\n// This allows reconnection after receiving a nack to be smooth\nconst socketReferenceBufferTime = 2000;\n\ninterface ISocketEvents extends IEvent {\n\t(\n\t\tevent: \"disconnect\",\n\t\tlistener: (error: IFluidErrorBase & OdspError, clientId?: string) => void,\n\t);\n}\n\nclass SocketReference extends TypedEventEmitter<ISocketEvents> {\n\tprivate references: number = 1;\n\tprivate delayDeleteTimeout: ReturnType<typeof setTimeout> | undefined;\n\tprivate _socket: Socket | undefined;\n\n\t// When making decisions about socket reuse, we do not reuse disconnected socket.\n\t// But we want to differentiate the following case from disconnected case:\n\t// Socket that never connected and never failed, it's in \"attempting to connect\" mode\n\t// such sockets should be reused, despite socket.disconnected === true\n\tprivate isPendingInitialConnection = true;\n\n\t// Map of all existing socket io sockets. [url, tenantId, documentId] -> socket\n\tprivate static readonly socketIoSockets: Map<string, SocketReference> = new Map();\n\n\tpublic static find(key: string, logger: ITelemetryLoggerExt): SocketReference | undefined {\n\t\tconst socketReference = SocketReference.socketIoSockets.get(key);\n\n\t\t// Verify the socket is healthy before reusing it\n\t\tif (socketReference?.disconnected) {\n\t\t\t// The socket is in a bad state. fully remove the reference\n\t\t\tsocketReference.closeSocket();\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (socketReference) {\n\t\t\t// Clear the pending deletion if there is one\n\t\t\tsocketReference.clearTimer();\n\t\t\tsocketReference.references++;\n\t\t}\n\n\t\treturn socketReference;\n\t}\n\n\t/**\n\t * Removes a reference for the given key\n\t * Once the ref count hits 0, the socket is disconnected and removed\n\t */\n\tpublic removeSocketIoReference(): void {\n\t\tassert(this.references > 0, 0x09f /* \"No more socketIO refs to remove!\" */);\n\t\tthis.references--;\n\n\t\t// see comment in disconnected() getter\n\t\tthis.isPendingInitialConnection = false;\n\n\t\tif (this.disconnected) {\n\t\t\tthis.closeSocket();\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.references === 0 && this.delayDeleteTimeout === undefined) {\n\t\t\tthis.delayDeleteTimeout = setTimeout(() => {\n\t\t\t\t// We should not get here with active users.\n\t\t\t\tassert(this.references === 0, 0x0a0 /* \"Unexpected socketIO references on timeout\" */);\n\t\t\t\tthis.closeSocket();\n\t\t\t}, socketReferenceBufferTime);\n\t\t}\n\t}\n\n\tpublic get socket(): Socket {\n\t\tif (!this._socket) {\n\t\t\tthrow new Error(`Invalid socket for key \"${this.key}`);\n\t\t}\n\t\treturn this._socket;\n\t}\n\n\tpublic constructor(\n\t\tpublic readonly key: string,\n\t\tsocket: Socket,\n\t) {\n\t\tsuper();\n\n\t\tthis._socket = socket;\n\t\tassert(!SocketReference.socketIoSockets.has(key), 0x220 /* \"socket key collision\" */);\n\t\tSocketReference.socketIoSockets.set(key, this);\n\n\t\t// Server sends this event when it wants to disconnect a particular client in which case the client id would\n\t\t// be present or if it wants to disconnect all the clients. The server always closes the socket in case all\n\t\t// clients needs to be disconnected. So fully remove the socket reference in this case.\n\t\tsocket.on(\"server_disconnect\", this.serverDisconnectEventHandler);\n\t}\n\n\tprivate readonly serverDisconnectEventHandler = (\n\t\tsocketError: IOdspSocketError,\n\t\tclientId?: string,\n\t): void => {\n\t\t// Treat all errors as recoverable, and rely on joinSession / reconnection flow to\n\t\t// filter out retryable vs. non-retryable cases.\n\t\tconst error = errorObjectFromSocketError(socketError, \"server_disconnect\");\n\t\terror.addTelemetryProperties({ disconnectClientId: clientId });\n\t\terror.canRetry = true;\n\n\t\t// see comment in disconnected() getter\n\t\t// Setting it here to ensure socket reuse does not happen if new request to connect\n\t\t// comes in from \"disconnect\" listener below, before we close socket.\n\t\tthis.isPendingInitialConnection = false;\n\n\t\tif (clientId === undefined) {\n\t\t\t// We could first raise \"disconnect\" event, but that may result in socket reuse due to\n\t\t\t// new connection comming in. So, it's better to have more explicit flow to make it impossible.\n\t\t\tthis.closeSocket(error);\n\t\t} else {\n\t\t\tthis.emit(\"disconnect\", error, clientId);\n\t\t}\n\t};\n\n\tprivate clearTimer(): void {\n\t\tif (this.delayDeleteTimeout !== undefined) {\n\t\t\tclearTimeout(this.delayDeleteTimeout);\n\t\t\tthis.delayDeleteTimeout = undefined;\n\t\t}\n\t}\n\n\tpublic closeSocket(error?: IAnyDriverError): void {\n\t\tif (!this._socket) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._socket.off(\"server_disconnect\", this.serverDisconnectEventHandler);\n\t\tthis.clearTimer();\n\n\t\tassert(\n\t\t\tSocketReference.socketIoSockets.get(this.key) === this,\n\t\t\t0x0a1 /* \"Socket reference set unexpectedly does not point to this socket!\" */,\n\t\t);\n\n\t\t// First, remove socket to ensure no socket reuse is possible.\n\t\tSocketReference.socketIoSockets.delete(this.key);\n\n\t\t// Block access to socket. From now on, calls like flush() or requestOps()\n\t\t// Disconnect flow should be synchronous and result in system fully forgetting about this connection / socket.\n\t\tconst socket = this._socket;\n\t\tthis._socket = undefined;\n\n\t\t// Let all connections know they need to go through disconnect flow.\n\t\tthis.emit(\n\t\t\t\"disconnect\",\n\t\t\terror ??\n\t\t\t\tcreateGenericNetworkError(\n\t\t\t\t\t\"Socket closed without error\",\n\t\t\t\t\t{ canRetry: true },\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t),\n\t\t\tundefined /* clientId */,\n\t\t);\n\n\t\t// We should not have any users now, assuming synchronous disconnect flow in response to\n\t\t// \"disconnect\" event\n\t\tassert(\n\t\t\tthis.references === 0,\n\t\t\t0x412 /* Nobody should be connected to this socket at this point! */,\n\t\t);\n\n\t\tsocket.disconnect();\n\t}\n\n\tpublic get disconnected(): boolean {\n\t\tif (this._socket === undefined) {\n\t\t\treturn true;\n\t\t}\n\t\tif (this.socket.connected) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// We have a socket that is not connected. Possible cases:\n\t\t// 1) It was connected some time ago and lost connection. We do not want to reuse it.\n\t\t// 2) It failed to connect (was never connected).\n\t\t// 3) It was just created and never had a chance to connect - connection is in process.\n\t\t// We have to differentiate 1 from 2-3 (specifically 1 & 3) in order to be able to reuse socket in #3.\n\t\t// We will use the fact that socket had some activity. I.e. if socket disconnected, or client stopped using\n\t\t// socket, then removeSocketIoReference() will be called for it, and it will be the indiction that it's not #3.\n\t\treturn !this.isPendingInitialConnection;\n\t}\n}\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class OdspDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a OdspDocumentDeltaConnection\n\t * If url #1 fails to connect, will try url #2 if applicable.\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param mode - mode of the client\n\t * @param url - websocket URL\n\t * @param telemetryLogger - optional telemetry logger\n\t * @param timeoutMs - time limit on making the connection\n\t * @param epochTracker - track epoch changes\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\turl: string,\n\t\ttelemetryLogger: ITelemetryLoggerExt,\n\t\ttimeoutMs: number,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix: string | undefined,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst mc = loggerToMonitoringContext(telemetryLogger);\n\n\t\t// enable multiplexing when the websocket url does not include the tenant/document id\n\t\tconst parsedUrl = new URL(url);\n\t\tconst enableMultiplexing =\n\t\t\t!parsedUrl.searchParams.has(\"documentId\") && !parsedUrl.searchParams.has(\"tenantId\");\n\n\t\t// do not include the specific tenant/doc id in the ref key when multiplexing\n\t\t// this will allow multiple documents to share the same websocket connection\n\t\tconst key = socketReferenceKeyPrefix ? `${socketReferenceKeyPrefix},${url}` : url;\n\t\tconst socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;\n\n\t\tconst socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(\n\t\t\ttimeoutMs,\n\t\t\tsocketReferenceKey,\n\t\t\turl,\n\t\t\tenableMultiplexing,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttelemetryLogger,\n\t\t);\n\n\t\tconst socket = socketReference.socket;\n\t\tconst connectionId = uuid();\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid: documentId,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: protocolVersions,\n\t\t\tdriverVersion: pkgVersion,\n\t\t\tnonce: connectionId,\n\t\t\tepoch: epochTracker.fluidEpoch,\n\t\t\trelayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(\";\"),\n\t\t};\n\n\t\tconnectMessage.supportedFeatures = {};\n\n\t\t// Reference to this client supporting get_ops flow.\n\t\tif (mc.config.getBoolean(\"Fluid.Driver.Odsp.GetOpsEnabled\") !== false) {\n\t\t\tconnectMessage.supportedFeatures[feature_get_ops] = true;\n\t\t}\n\n\t\tconst deltaConnection = new OdspDocumentDeltaConnection(\n\t\t\tsocket,\n\t\t\tdocumentId,\n\t\t\tsocketReference,\n\t\t\ttelemetryLogger,\n\t\t\tenableMultiplexing,\n\t\t\tconnectionId,\n\t\t);\n\n\t\ttry {\n\t\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\t\tawait epochTracker.validateEpoch(deltaConnection.details.epoch, \"push\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\tif (error !== null && typeof error === \"object\") {\n\t\t\t\t// We have to special-case error types here in terms of what is re-triable.\n\t\t\t\t// These errors have to re-retried, we just need new joinSession result to connect to right server:\n\t\t\t\t// 400: Invalid tenant or document id. The WebSocket is connected to a different document\n\t\t\t\t// Document is full (with retryAfter)\n\t\t\t\t// 404: Invalid document. The document \\\"local/w1-...\\\" does not exist\n\t\t\t\t// But this has to stay not-retriable:\n\t\t\t\t// 406: Unsupported client protocol. This path is the only gatekeeper, have to fail!\n\t\t\t\t// 409: Epoch Version Mismatch. Client epoch and server epoch does not match, so app needs\n\t\t\t\t// to be refreshed.\n\t\t\t\t// This one is fine either way\n\t\t\t\t// 401/403: Code will retry once with new token either way, then it becomes fatal - on this path\n\t\t\t\t// and on join Session path.\n\t\t\t\t// 501: (Fluid not enabled): this is fine either way, as joinSession is gatekeeper\n\t\t\t\t// eslint-disable-next-line unicorn/no-lonely-if, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tif (error.statusCode === 400 || error.statusCode === 404) {\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\terror.canRetry = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn deltaConnection;\n\t}\n\n\tprivate socketReference: SocketReference | undefined;\n\n\tprivate readonly requestOpsNoncePrefix: string;\n\tprivate pushCallCounter = 0;\n\tprivate readonly getOpsMap: Map<string, { start: number; from: number; to: number }> =\n\t\tnew Map();\n\tprivate flushOpNonce: string | undefined;\n\tprivate flushDeferred: Deferred<FlushResult> | undefined;\n\tprivate connectionNotYetDisposedTimeout: ReturnType<typeof setTimeout> | undefined;\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(\n\t\thandler: string,\n\t\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\t\terror?: any,\n\t\tcanRetry = true,\n\t): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.\n\t\t// - anything else: let base class handle it\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\treturn canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\"\n\t\t\t? errorObjectFromSocketError(error as IOdspSocketError, handler)\n\t\t\t: super.createErrorObject(handler, error, canRetry);\n\t}\n\n\t/**\n\t * Gets or create a socket io connection for the given key\n\t */\n\tprivate static getOrCreateSocketIoReference(\n\t\ttimeoutMs: number,\n\t\tkey: string,\n\t\turl: string,\n\t\tenableMultiplexing: boolean,\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t): SocketReference {\n\t\t// eslint-disable-next-line unicorn/no-array-callback-reference, unicorn/no-array-method-this-argument\n\t\tconst existingSocketReference = SocketReference.find(key, logger);\n\t\tif (existingSocketReference) {\n\t\t\treturn existingSocketReference;\n\t\t}\n\n\t\tconst query = enableMultiplexing ? undefined : { documentId, tenantId };\n\n\t\tconst socket = SocketIOClientStatic(url, {\n\t\t\tmultiplex: false, // Don't rely on socket.io built-in multiplexing\n\t\t\tquery,\n\t\t\treconnection: false,\n\t\t\ttransports: [\"websocket\"],\n\t\t\ttimeout: timeoutMs,\n\t\t});\n\n\t\treturn new SocketReference(key, socket);\n\t}\n\n\t/**\n\t * @param socket - websocket to be used\n\t * @param documentId - ID of the document\n\t * @param details - details of the websocket connection\n\t * @param socketReferenceKey - socket reference key\n\t * @param enableMultiplexing - If the websocket is multiplexing multiple documents\n\t */\n\tprivate constructor(\n\t\tsocket: Socket,\n\t\tdocumentId: string,\n\t\tsocketReference: SocketReference,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly enableMultiplexing?: boolean,\n\t\tconnectionId?: string,\n\t) {\n\t\tsuper(socket, documentId, logger, false, connectionId);\n\t\tthis.socketReference = socketReference;\n\t\tthis.requestOpsNoncePrefix = `${uuid()}-`;\n\t}\n\n\t/**\n\t * Retrieves ops from PUSH\n\t * @param from - inclusive\n\t * @param to - exclusive\n\t * @returns ops retrieved\n\t */\n\tpublic requestOps(from: number, to: number): void {\n\t\tassert(!this.socketReference?.disconnected, 0x413 /* non-active socket */);\n\n\t\t// Given that to is exclusive, we should be asking for at least something!\n\t\tassert(to > from, 0x272 /* \"empty request\" */);\n\n\t\t// PUSH may disable this functionality\n\t\t// back-compat: remove cast to any once latest version of IConnected is consumed\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n\t\tif ((this.details as any).supportedFeatures?.[feature_get_ops] !== true) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.pushCallCounter++;\n\t\tconst nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n\t\tconst start = performance.now();\n\n\t\t// We may keep keep accumulating memory for nothing, if we are not getting responses.\n\t\t// Note that we should not have overlapping requests, as DeltaManager allows only one\n\t\t// outstanding request to storage, and that's the only way to get here.\n\t\t// But requests could be cancelled, and thus overlapping requests might be in the picture\n\t\t// If it happens, we do not care about stale requests.\n\t\t// So track some number of requests, but log if we get too many in flight - that likely\n\t\t// indicates an error somewhere.\n\t\tif (this.getOpsMap.size >= 5) {\n\t\t\tlet time = start;\n\t\t\tlet key: string | undefined;\n\t\t\tfor (const [keyCandidate, value] of this.getOpsMap.entries()) {\n\t\t\t\tif (value.start <= time || key === undefined) {\n\t\t\t\t\ttime = value.start;\n\t\t\t\t\tkey = keyCandidate;\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst payloadToDelete = this.getOpsMap.get(key!)!;\n\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\teventName: \"GetOpsTooMany\",\n\t\t\t\tnonce,\n\t\t\t\tfrom: payloadToDelete.from,\n\t\t\t\tto: payloadToDelete.to,\n\t\t\t\tlength: payloadToDelete.to - payloadToDelete.from,\n\t\t\t\tduration: performance.now() - payloadToDelete.start,\n\t\t\t});\n\t\t\tthis.getOpsMap.delete(key!);\n\t\t}\n\t\tthis.getOpsMap.set(nonce, {\n\t\t\tstart,\n\t\t\tfrom,\n\t\t\tto,\n\t\t});\n\t\tthis.socket.emit(\"get_ops\", this.clientId, {\n\t\t\tnonce,\n\t\t\tfrom,\n\t\t\tto: to - 1,\n\t\t});\n\t}\n\n\tpublic async flush(): Promise<FlushResult> {\n\t\tassert(!this.socketReference?.disconnected, 0x414 /* non-active socket */);\n\n\t\t// back-compat: remove cast to any once latest version of IConnected is consumed\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access\n\t\tif ((this.details as any).supportedFeatures?.[feature_flush_ops] !== true) {\n\t\t\t// Once single-commit summary is enabled end-to-end, flush support is a must!\n\t\t\t// The only alternative is change in design where SPO fetches ops from PUSH OR\n\t\t\t// summary includes required ops and SPO has some validation mechanism to ensure\n\t\t\t// they are not forged by client.\n\t\t\t// If design changes, we can reconsider it, but right now it's non-recoverable failure.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FlushOpsNotSupported\" });\n\t\t\tthrow new Error(\n\t\t\t\t\"flush() API is not supported by PUSH, required for single-commit summaries\",\n\t\t\t);\n\t\t}\n\n\t\tthis.pushCallCounter++;\n\t\tconst nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n\t\t// There should be only one flush ops in flight, kicked out by upload summary workflow\n\t\t// That said, it could timeout and request could be repeated, so theoretically we can\n\t\t// get overlapping requests, but it should be very rare\n\t\tif (this.flushDeferred !== undefined) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FlushOpsTooMany\" });\n\t\t\tthis.flushDeferred.reject(\n\t\t\t\t\"process involving flush() was cancelled OR unsupported concurrency\",\n\t\t\t);\n\t\t}\n\t\tthis.socket.emit(\"flush_ops\", this.clientId, { nonce });\n\n\t\tthis.flushOpNonce = nonce;\n\t\tthis.flushDeferred = new Deferred<FlushResult>();\n\t\treturn this.flushDeferred.promise;\n\t}\n\n\tprotected disconnectHandler = (\n\t\terror: IFluidErrorBase & OdspError,\n\t\tclientId?: string,\n\t): void => {\n\t\tif (clientId === undefined || clientId === this.clientId) {\n\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"ServerDisconnect\",\n\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t\terror,\n\t\t\t);\n\t\t\tthis.disconnect(error);\n\t\t}\n\t};\n\n\tprotected async initialize(connectMessage: IConnect, timeout: number): Promise<void> {\n\t\tassert(!this.socketReference?.disconnected, 0x415 /* non-active socket */);\n\n\t\tif (this.enableMultiplexing) {\n\t\t\t// multiplex compatible early handlers\n\t\t\tthis.earlyOpHandler = (\n\t\t\t\tmessageDocumentId: string,\n\t\t\t\tmsgs: ISequencedDocumentMessage[],\n\t\t\t): void => {\n\t\t\t\tif (this.documentId === messageDocumentId) {\n\t\t\t\t\tthis.queuedMessages.push(...msgs);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tthis.earlySignalHandler = (\n\t\t\t\tmsg: ISignalMessage | ISignalMessage[],\n\t\t\t\tmessageDocumentId?: string,\n\t\t\t): void => {\n\t\t\t\tif (messageDocumentId === undefined || messageDocumentId === this.documentId) {\n\t\t\t\t\tif (Array.isArray(msg)) {\n\t\t\t\t\t\tthis.queuedSignals.push(...msg);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.queuedSignals.push(msg);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\tthis.socketReference!.on(\"disconnect\", this.disconnectHandler);\n\n\t\tthis.addTrackedListener(\"get_ops_response\", (result: IGetOpsResponse) => {\n\t\t\tconst messages = result.messages;\n\t\t\tconst data = this.getOpsMap.get(result.nonce);\n\t\t\t// Due to socket multiplexing, this client may not have asked for any data\n\t\t\t// If so, there it most likely does not need these ops (otherwise it already asked for them)\n\t\t\t// Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.\n\t\t\t// But not processing such result may push us into infinite loop of fast requests and dropping all responses\n\t\t\tif (data !== undefined || result.nonce.startsWith(this.requestOpsNoncePrefix)) {\n\t\t\t\tthis.getOpsMap.delete(result.nonce);\n\t\t\t\tconst common = {\n\t\t\t\t\teventName: \"GetOps\",\n\t\t\t\t\t// We need nonce only to pair with GetOpsTooMany events, i.e. when record was deleted\n\t\t\t\t\tnonce: data === undefined ? result.nonce : undefined,\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tfrom: data?.from,\n\t\t\t\t\tto: data?.to,\n\t\t\t\t\tduration: data === undefined ? undefined : performance.now() - data.start,\n\t\t\t\t};\n\t\t\t\tif (messages !== undefined && messages.length > 0) {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\tfirst: messages[0].sequenceNumber,\n\t\t\t\t\t\tlast: messages[messages.length - 1].sequenceNumber,\n\t\t\t\t\t\tlength: messages.length,\n\t\t\t\t\t});\n\t\t\t\t\tthis.emit(\"op\", this.documentId, messages);\n\t\t\t\t} else {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\tlength: 0,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tthis.addTrackedListener(\"flush_ops_response\", (result: IFlushOpsResponse) => {\n\t\t\tif (this.flushOpNonce === result.nonce) {\n\t\t\t\tconst seq = result.lastPersistedSequenceNumber;\n\t\t\t\tlet category: \"generic\" | \"error\" = \"generic\";\n\t\t\t\tif (result.lastPersistedSequenceNumber === undefined || result.code !== 200) {\n\t\t\t\t\tswitch (result.code) {\n\t\t\t\t\t\tcase 409:\n\t\t\t\t\t\tcase 429: {\n\t\t\t\t\t\t\tcategory = \"error\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 204: {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tcategory = \"error\";\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"FlushResult\",\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tsequenceNumber: seq,\n\t\t\t\t\tcategory,\n\t\t\t\t});\n\t\t\t\tthis.flushDeferred!.resolve(result);\n\t\t\t\tthis.flushDeferred = undefined;\n\t\t\t\tthis.flushOpNonce = undefined;\n\t\t\t}\n\t\t});\n\n\t\tawait super.initialize(connectMessage, timeout).finally(() => {\n\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\teventName: \"ConnectionAttemptInfo\",\n\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t});\n\t\t});\n\t}\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tprotected addTrackedListener(event: string, listener: (...args: any[]) => void): void {\n\t\t// override some event listeners in order to support multiple documents/clients over the same websocket\n\t\tswitch (event) {\n\t\t\tcase \"op\": {\n\t\t\t\t// per document op handling\n\t\t\t\tsuper.addTrackedListener(\n\t\t\t\t\tevent,\n\t\t\t\t\t(documentId: string, msgs: ISequencedDocumentMessage[]) => {\n\t\t\t\t\t\tif (!this.enableMultiplexing || this.documentId === documentId) {\n\t\t\t\t\t\t\tlistener(documentId, msgs);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"signal\": {\n\t\t\t\t// per document signal handling\n\t\t\t\tsuper.addTrackedListener(\n\t\t\t\t\tevent,\n\t\t\t\t\t(msg: ISignalMessage | ISignalMessage[], documentId?: string) => {\n\t\t\t\t\t\tif (!this.enableMultiplexing || !documentId || documentId === this.documentId) {\n\t\t\t\t\t\t\tlistener(msg, documentId);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tcase \"nack\": {\n\t\t\t\t// per client / document nack handling\n\t\t\t\tsuper.addTrackedListener(event, (clientIdOrDocumentId: string, nacks: INack[]) => {\n\t\t\t\t\tconst handle =\n\t\t\t\t\t\tclientIdOrDocumentId.length === 0 ||\n\t\t\t\t\t\tclientIdOrDocumentId === this.documentId ||\n\t\t\t\t\t\tclientIdOrDocumentId === this.clientId;\n\t\t\t\t\tconst { code, type, message, retryAfter } = nacks[0]?.content ?? {};\n\t\t\t\t\tconst { clientSequenceNumber, referenceSequenceNumber } = nacks[0]?.operation ?? {};\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"ServerNack\",\n\t\t\t\t\t\tcode,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\tretryAfterSeconds: retryAfter,\n\t\t\t\t\t\tclientId: this.clientId,\n\t\t\t\t\t\thandle,\n\t\t\t\t\t\tclientSequenceNumber,\n\t\t\t\t\t\treferenceSequenceNumber,\n\t\t\t\t\t\topType: nacks[0]?.operation?.type,\n\t\t\t\t\t});\n\t\t\t\t\tif (handle) {\n\t\t\t\t\t\tthis.emit(\"nack\", clientIdOrDocumentId, nacks);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\tsuper.addTrackedListener(event, listener);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic get disposed(): boolean {\n\t\tif (!(this._disposed || this.socket.connected)) {\n\t\t\t// Send error event if this connection is not yet disposed after socket is disconnected for 15s.\n\t\t\t// eslint-disable-next-line unicorn/no-lonely-if\n\t\t\tif (this.connectionNotYetDisposedTimeout === undefined) {\n\t\t\t\tthis.connectionNotYetDisposedTimeout = setTimeout(() => {\n\t\t\t\t\tif (!this._disposed) {\n\t\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\t\teventName: \"ConnectionNotYetDisposed\",\n\t\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\t\t...this.getConnectionDetailsProps(),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}, 15000);\n\t\t\t}\n\t\t}\n\t\treturn this._disposed;\n\t}\n\n\t/**\n\t * Returns true in case the connection is not yet disposed and the socket is also connected. The expectation is\n\t * that it will be called only after connection is fully established. i.e. there should no way to submit an op\n\t * while we are connecting, as connection object is not exposed to Loader layer until connection is established.\n\t */\n\tprivate get connected(): boolean {\n\t\treturn !this.disposed && this.socket.connected;\n\t}\n\n\tprotected override emitMessages(type: \"submitOp\", messages: IDocumentMessage[][]): void;\n\tprotected override emitMessages(\n\t\ttype: \"submitSignal\",\n\t\tmessages: string[][] | ISentSignalMessage[],\n\t): void;\n\tprotected override emitMessages(type: string, messages: unknown): void {\n\t\t// Only submit the op/signals if we are connected.\n\t\tif (this.connected) {\n\t\t\tthis.socket.emit(type, this.clientId, messages);\n\t\t}\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t * @param message - delta operation to submit\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t *\n\t * @param content - Content of the signal.\n\t * @param targetClientId - When specified, the signal is only sent to the provided client id.\n\t */\n\tpublic submitSignal(content: string, targetClientId?: string): void {\n\t\tconst signal: ISentSignalMessage = {\n\t\t\tcontent,\n\t\t\ttargetClientId,\n\t\t};\n\n\t\tthis.emitMessages(\"submitSignal\", [signal]);\n\t}\n\n\t/**\n\t * Critical path where we need to also close the socket for an error.\n\t * @param error - Error causing the socket to close.\n\t */\n\tprotected closeSocketCore(error: IAnyDriverError): void {\n\t\tconst socket = this.socketReference;\n\t\tassert(socket !== undefined, 0x416 /* reentrancy not supported in close socket */);\n\t\tsocket.closeSocket(error);\n\t\tassert(\n\t\t\tthis.socketReference === undefined,\n\t\t\t0x417 /* disconnect flow did not work correctly */,\n\t\t);\n\t}\n\n\t/**\n\t * Disconnect from the websocket\n\t */\n\tprotected disconnectCore(): void {\n\t\tconst socket = this.socketReference;\n\t\tassert(socket !== undefined, 0x0a2 /* \"reentrancy not supported!\" */);\n\t\tthis.socketReference = undefined;\n\n\t\tsocket.off(\"disconnect\", this.disconnectHandler);\n\t\tif (this.hasDetails) {\n\t\t\t// tell the server we are disconnecting this client from the document\n\t\t\tthis.socket.emit(\"disconnect_document\", this.clientId, this.documentId);\n\t\t}\n\n\t\tsocket.removeSocketIoReference();\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentStorageServiceBase.d.ts","sourceRoot":"","sources":["../src/odspDocumentStor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K,EAAE,MAAM,EACb,YAAY,CAAC,EAAE,MAAM,EACrB,WAAW,CAAC,EAAE,WAAW,GACvB,OAAO,CAAC,QAAQ,EAAE,CAAC;aAEN,wBAAwB,CACvC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAEL,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAI3E,SAAS,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAI5D,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;YAIjD,QAAQ;IAUtB,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CACvC,EAAE,EAAE,MAAM,EACV,YAAY,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAErC,SAAS,CAAC,iCAAiC,CAAC,YAAY,EAAE,aAAa,GAAG,aAAa;IAwBvF,SAAS,CAAC,sBAAsB,CAC/B,sBAAsB,EAAE,SAAS,EACjC,QAAQ,GAAE,OAAc,EACxB,aAAa,GAAE,OAAc,GAC3B,MAAM,GAAG,SAAS;CAwBrB"}
@@ -142,7 +142,6 @@ export class OdspDocumentStorageServiceBase {
142
142
  // eslint-disable-next-line unicorn/no-null
143
143
  return null;
144
144
  }
145
- // Non null asserting here because of the length check above
146
145
  id = versions[0].id;
147
146
  }
148
147
  const snapshotTree = await this.readTree(id, scenarioName);
@@ -172,7 +171,6 @@ export class OdspDocumentStorageServiceBase {
172
171
  combineProtocolAndAppSnapshotTree(snapshotTree) {
173
172
  // When we upload the container snapshot, we upload appTree in ".app" and protocol tree in ".protocol"
174
173
  // So when we request the snapshot we get ".app" as tree and not as commit node as in the case just above.
175
- // TODO Why are we non null asserting here?
176
174
  const hierarchicalAppTree = snapshotTree.trees[".app"];
177
175
  const hierarchicalProtocolTree = snapshotTree.trees[".protocol"];
178
176
  const summarySnapshotTree = {
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentStorageServiceBase.js","sourceRoot":"","sources":["../src/odspDocumentStorageServiceBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAQN,mBAAmB,GAKnB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAG1F,MAAM,SAAS;IAAf;QAGC,kGAAkG;QAClG,gHAAgH;QAChH,6CAA6C;QACrC,wBAAmB,GAAY,KAAK,CAAC;QAE5B,eAAU,GAA6B,IAAI,GAAG,EAAE,CAAC;QAElE,yCAAyC;QACxB,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QAEvD,4CAA4C;QAC5C,uGAAuG;QACvG,0FAA0F;QAClF,6BAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAEjD,oFAAoF;QACpF,wGAAwG;QACxG,sEAAsE;QACtE,mCAAmC;QAClB,iBAAY,GAAG,KAAK,CAAC;IA6EvC,CAAC;IA3EA,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAEM,QAAQ,CAAC,KAA+B;QAC9C,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,+BAA+B;QAC/B,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACK,uBAAuB;QAC9B,IAAI,IAAI,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACzC,sFAAsF;YACtF,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QACjC,CAAC;aAAM,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E,0DAA0D;QAC1D,IAAI,EAAsB,CAAC;QAC3B,IAAI,YAAY,EAAE,CAAC;YAClB,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;YACxE,IAAI,aAAa,EAAE,CAAC;gBACnB,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QAED,yEAAyE;QACzE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","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 { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tFiveDaysMs,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tISnapshotTree,\n\tICreateBlobResponse,\n\tIVersion,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { maximumCacheDurationMs } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils/internal\";\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value(): Map<string, ArrayBuffer> {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>): void {\n\t\tfor (const [blobId, value] of blobs.entries()) {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t}\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache(): void {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = (): void => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tfor (const blobId of this._blobCache.keys()) {\n\t\t\t\t\t\tthis.blobsEvicted.add(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string): {\n\t\tblobContent: ArrayBuffer | undefined;\n\t\tevicted: boolean;\n\t} {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer): Map<string, ArrayBuffer> | undefined {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, ISnapshotTree> = new Map();\n\n\tprivate _ops: ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: ISequencedDocumentMessage[] | undefined) {\n\t\tassert(\n\t\t\tthis._ops === undefined,\n\t\t\t0x0a5 /* \"Trying to set ops when they are already set!\" */,\n\t\t);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber(): number | undefined {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(\n\t\tblobId: string,\n\t\tevicted: boolean,\n\t): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (version?.id) {\n\t\t\tid = version.id;\n\t\t} else {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t// Non null asserting here because of the length check above\n\t\t\tid = versions[0]!.id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(snapshotTree);\n\t}\n\n\tpublic abstract getSnapshot(\n\t\tsnapshotFetchOptions?: ISnapshotFetchOptions,\n\t): Promise<ISnapshot>;\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: ISnapshotTree): void {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>): void {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | undefined>;\n\n\tprotected combineProtocolAndAppSnapshotTree(snapshotTree: ISnapshotTree): ISnapshotTree {\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\t// TODO Why are we non null asserting here?\n\t\tconst hierarchicalAppTree = snapshotTree.trees[\".app\"]!;\n\t\tconst hierarchicalProtocolTree = snapshotTree.trees[\".protocol\"];\n\t\tconst summarySnapshotTree: ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t},\n\t\t\tid: snapshotTree.id,\n\t\t};\n\n\t\t// The app tree could have a .protocol in that case we want to server protocol to override it.\n\t\t// Snapshot which are for a loading GroupId, will not have a protocol tree.\n\t\tif (hierarchicalProtocolTree !== undefined) {\n\t\t\tsummarySnapshotTree.trees[\".protocol\"] = hierarchicalProtocolTree;\n\t\t}\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshot,\n\t\tcacheOps: boolean = true,\n\t\tcacheSnapshot: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobContents, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tif (cacheSnapshot) {\n\t\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t\t}\n\t\t}\n\n\t\t// Currently always cache blobs as container runtime is not caching them.\n\t\tif (blobContents !== undefined) {\n\t\t\tthis.initBlobsCache(blobContents);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDocumentStorageServiceBase.js","sourceRoot":"","sources":["../src/odspDocumentStorageServiceBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAQN,mBAAmB,GAKnB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAG1F,MAAM,SAAS;IAAf;QAGC,kGAAkG;QAClG,gHAAgH;QAChH,6CAA6C;QACrC,wBAAmB,GAAY,KAAK,CAAC;QAE5B,eAAU,GAA6B,IAAI,GAAG,EAAE,CAAC;QAElE,yCAAyC;QACxB,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QAEvD,4CAA4C;QAC5C,uGAAuG;QACvG,0FAA0F;QAClF,6BAAwB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAEjD,oFAAoF;QACpF,wGAAwG;QACxG,sEAAsE;QACtE,mCAAmC;QAClB,iBAAY,GAAG,KAAK,CAAC;IA6EvC,CAAC;IA3EA,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC;IACxB,CAAC;IAEM,QAAQ,CAAC,KAA+B;QAC9C,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;YAC/C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,+BAA+B;QAC/B,IAAI,CAAC,uBAAuB,EAAE,CA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AAI;QAE7B,IAAI,CAAC,uBAAuB,GAAG,sBAAsB,CAAC,cAAc,CAAC;QACrE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,sBAAsB,CAAC;QAEnE,0DAA0D;QAC1D,IAAI,EAAsB,CAAC;QAC3B,IAAI,YAAY,EAAE,CAAC;YAClB,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,uCAAuC,CAAC,CAAC;YACxE,IAAI,aAAa,EAAE,CAAC;gBACnB,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;YACpC,CAAC;QACF,CAAC;QAED,yEAAyE;QACzE,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAChC,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,CAAC;IACX,CAAC;CACD","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 { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tFiveDaysMs,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tLoaderCachingPolicy,\n\tISnapshotTree,\n\tICreateBlobResponse,\n\tIVersion,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { maximumCacheDurationMs } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { IConfigProvider } from \"@fluidframework/telemetry-utils/internal\";\n\nclass BlobCache {\n\t// Save the timeout so we can cancel and reschedule it as needed\n\tprivate blobCacheTimeout: ReturnType<typeof setTimeout> | undefined;\n\t// If the defer flag is set when the timeout fires, we'll reschedule rather than clear immediately\n\t// This deferral approach is used (rather than clearing/resetting the timer) as current calling patterns trigger\n\t// too many calls to setTimeout/clearTimeout.\n\tprivate deferBlobCacheClear: boolean = false;\n\n\tprivate readonly _blobCache: Map<string, ArrayBuffer> = new Map();\n\n\t// Tracks all blob IDs evicted from cache\n\tprivate readonly blobsEvicted: Set<string> = new Set();\n\n\t// Initial time-out to purge data from cache\n\t// If this time out is very small, then we purge blobs from cache too soon and that results in a lot of\n\t// requests to storage, which brings down perf and may trip protection limits causing 429s\n\tprivate blobCacheTimeoutDuration = 2 * 60 * 1000;\n\n\t// SPO does not keep old snapshots around for long, so we are running chances of not\n\t// being able to rehydrate data store / DDS in the future if we purge anything (and with blob de-duping,\n\t// even if blob read by runtime, it could be read again in the future)\n\t// So for now, purging is disabled.\n\tprivate readonly purgeEnabled = false;\n\n\tpublic get value(): Map<string, ArrayBuffer> {\n\t\treturn this._blobCache;\n\t}\n\n\tpublic addBlobs(blobs: Map<string, ArrayBuffer>): void {\n\t\tfor (const [blobId, value] of blobs.entries()) {\n\t\t\tthis._blobCache.set(blobId, value);\n\t\t}\n\t\t// Reset the timer on cache set\n\t\tthis.scheduleClearBlobsCache();\n\t}\n\n\t/**\n\t * Schedule a timer for clearing the blob cache or defer the current one.\n\t */\n\tprivate scheduleClearBlobsCache(): void {\n\t\tif (this.blobCacheTimeout !== undefined) {\n\t\t\t// If we already have an outstanding timer, just signal that we should defer the clear\n\t\t\tthis.deferBlobCacheClear = true;\n\t\t} else if (this.purgeEnabled) {\n\t\t\t// If we don't have an outstanding timer, set a timer\n\t\t\t// When the timer runs out, we'll decide whether to proceed with the cache clear or reset the timer\n\t\t\tconst clearCacheOrDefer = (): void => {\n\t\t\t\tthis.blobCacheTimeout = undefined;\n\t\t\t\tif (this.deferBlobCacheClear) {\n\t\t\t\t\tthis.deferBlobCacheClear = false;\n\t\t\t\t\tthis.scheduleClearBlobsCache();\n\t\t\t\t} else {\n\t\t\t\t\t// NOTE: Slightly better algorithm here would be to purge either only big blobs,\n\t\t\t\t\t// or sort them by size and purge enough big blobs to leave only 256Kb of small blobs in cache\n\t\t\t\t\t// Purging is optimizing memory footprint. But count controls potential number of storage requests\n\t\t\t\t\t// We want to optimize both - memory footprint and number of future requests to storage.\n\t\t\t\t\t// Note that Container can realize data store or DDS on-demand at any point in time, so we do not\n\t\t\t\t\t// control when blobs will be used.\n\t\t\t\t\tfor (const blobId of this._blobCache.keys()) {\n\t\t\t\t\t\tthis.blobsEvicted.add(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthis._blobCache.clear();\n\t\t\t\t}\n\t\t\t};\n\t\t\tthis.blobCacheTimeout = setTimeout(clearCacheOrDefer, this.blobCacheTimeoutDuration);\n\t\t\t// any future storage reads that get into the cache should be cleared from cache rather quickly -\n\t\t\t// there is not much value in keeping them longer\n\t\t\tthis.blobCacheTimeoutDuration = 10 * 1000;\n\t\t}\n\t}\n\n\tpublic getBlob(blobId: string): {\n\t\tblobContent: ArrayBuffer | undefined;\n\t\tevicted: boolean;\n\t} {\n\t\t// Reset the timer on attempted cache read\n\t\tthis.scheduleClearBlobsCache();\n\t\tconst blobContent = this._blobCache.get(blobId);\n\t\tconst evicted = this.blobsEvicted.has(blobId);\n\t\treturn { blobContent, evicted };\n\t}\n\n\tpublic setBlob(blobId: string, blob: ArrayBuffer): Map<string, ArrayBuffer> | undefined {\n\t\t// This API is called as result of cache miss and reading blob from storage.\n\t\t// Runtime never reads same blob twice.\n\t\t// The only reason we may get read request for same blob is blob de-duping in summaries.\n\t\t// Note that the bigger the size, the less likely blobs are the same, so there is very little benefit of caching big blobs.\n\t\t// Images are the only exception - user may insert same image twice. But we currently do not de-dup them - only snapshot\n\t\t// blobs are de-duped.\n\t\tconst size = blob.byteLength;\n\t\tif (size < 256 * 1024) {\n\t\t\t// Reset the timer on cache set\n\t\t\tthis.scheduleClearBlobsCache();\n\t\t\treturn this._blobCache.set(blobId, blob);\n\t\t} else {\n\t\t\t// we evicted it here by not caching.\n\t\t\tthis.blobsEvicted.add(blobId);\n\t\t}\n\t}\n}\n\nexport abstract class OdspDocumentStorageServiceBase implements IDocumentStorageService {\n\treadonly policies: IDocumentStorageServicePolicies;\n\n\tconstructor(config: IConfigProvider) {\n\t\t// We circumvent the restrictions on the policy only when using this TestOverride setting,\n\t\t// which also applies to the code that reads from the cache in epochTracker.ts\n\t\t// This may result in files created for testing being unusable in production sessions,\n\t\t// due to the GC code guarding against this policy changing over the lifetime of a file.\n\t\tconst maximumCacheDurationMsInEffect = (\n\t\t\tconfig.getBoolean(\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\")\n\t\t\t\t? 0\n\t\t\t\t: maximumCacheDurationMs\n\t\t) as FiveDaysMs;\n\n\t\tthis.policies = {\n\t\t\t// By default, ODSP tells the container not to prefetch/cache.\n\t\t\tcaching: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumCacheDurationMsInEffect,\n\t\t};\n\t}\n\tprotected readonly commitCache: Map<string, ISnapshotTree> = new Map();\n\n\tprivate _ops: ISequencedDocumentMessage[] | undefined;\n\n\tprivate _snapshotSequenceNumber: number | undefined;\n\n\tprotected readonly blobCache = new BlobCache();\n\n\tpublic set ops(ops: ISequencedDocumentMessage[] | undefined) {\n\t\tassert(\n\t\t\tthis._ops === undefined,\n\t\t\t0x0a5 /* \"Trying to set ops when they are already set!\" */,\n\t\t);\n\t\tthis._ops = ops;\n\t}\n\n\tpublic get ops(): ISequencedDocumentMessage[] | undefined {\n\t\treturn this._ops;\n\t}\n\n\tpublic get snapshotSequenceNumber(): number | undefined {\n\t\treturn this._snapshotSequenceNumber;\n\t}\n\n\tpublic abstract createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;\n\n\tprivate async readBlobCore(blobId: string): Promise<ArrayBuffer> {\n\t\tconst { blobContent, evicted } = this.blobCache.getBlob(blobId);\n\t\treturn blobContent ?? this.fetchBlobFromStorage(blobId, evicted);\n\t}\n\n\tprotected abstract fetchBlobFromStorage(\n\t\tblobId: string,\n\t\tevicted: boolean,\n\t): Promise<ArrayBuffer>;\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.readBlobCore(blobId);\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tlet id: string;\n\t\tif (version?.id) {\n\t\t\tid = version.id;\n\t\t} else {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst versions = await this.getVersions(null, 1, scenarioName);\n\t\t\tif (!versions || versions.length === 0) {\n\t\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tid = versions[0].id;\n\t\t}\n\n\t\tconst snapshotTree = await this.readTree(id, scenarioName);\n\t\tif (!snapshotTree) {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.combineProtocolAndAppSnapshotTree(snapshotTree);\n\t}\n\n\tpublic abstract getSnapshot(\n\t\tsnapshotFetchOptions?: ISnapshotFetchOptions,\n\t): Promise<ISnapshot>;\n\n\tpublic abstract getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]>;\n\n\tpublic abstract uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string>;\n\n\tpublic async downloadSummary(commit: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"Not implemented yet\");\n\t}\n\n\tprotected setRootTree(id: string, tree: ISnapshotTree): void {\n\t\tthis.commitCache.set(id, tree);\n\t}\n\n\tprotected initBlobsCache(blobs: Map<string, ArrayBuffer>): void {\n\t\tthis.blobCache.addBlobs(blobs);\n\t}\n\n\tprivate async readTree(id: string, scenarioName?: string): Promise<ISnapshotTree | null> {\n\t\tlet tree = this.commitCache.get(id);\n\t\tif (!tree) {\n\t\t\ttree = await this.fetchTreeFromSnapshot(id, scenarioName);\n\t\t}\n\n\t\t// eslint-disable-next-line unicorn/no-null\n\t\treturn tree ?? null;\n\t}\n\n\tprotected abstract fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | undefined>;\n\n\tprotected combineProtocolAndAppSnapshotTree(snapshotTree: ISnapshotTree): ISnapshotTree {\n\t\t// When we upload the container snapshot, we upload appTree in \".app\" and protocol tree in \".protocol\"\n\t\t// So when we request the snapshot we get \".app\" as tree and not as commit node as in the case just above.\n\t\tconst hierarchicalAppTree = snapshotTree.trees[\".app\"];\n\t\tconst hierarchicalProtocolTree = snapshotTree.trees[\".protocol\"];\n\t\tconst summarySnapshotTree: ISnapshotTree = {\n\t\t\tblobs: {\n\t\t\t\t...hierarchicalAppTree.blobs,\n\t\t\t},\n\t\t\ttrees: {\n\t\t\t\t...hierarchicalAppTree.trees,\n\t\t\t},\n\t\t\tid: snapshotTree.id,\n\t\t};\n\n\t\t// The app tree could have a .protocol in that case we want to server protocol to override it.\n\t\t// Snapshot which are for a loading GroupId, will not have a protocol tree.\n\t\tif (hierarchicalProtocolTree !== undefined) {\n\t\t\tsummarySnapshotTree.trees[\".protocol\"] = hierarchicalProtocolTree;\n\t\t}\n\n\t\treturn summarySnapshotTree;\n\t}\n\n\tprotected initializeFromSnapshot(\n\t\todspSnapshotCacheValue: ISnapshot,\n\t\tcacheOps: boolean = true,\n\t\tcacheSnapshot: boolean = true,\n\t): string | undefined {\n\t\tthis._snapshotSequenceNumber = odspSnapshotCacheValue.sequenceNumber;\n\t\tconst { snapshotTree, blobContents, ops } = odspSnapshotCacheValue;\n\n\t\t// id should be undefined in case of just ops in snapshot.\n\t\tlet id: string | undefined;\n\t\tif (snapshotTree) {\n\t\t\tid = snapshotTree.id;\n\t\t\tassert(id !== undefined, 0x221 /* \"Root tree should contain the id\" */);\n\t\t\tif (cacheSnapshot) {\n\t\t\t\tthis.setRootTree(id, snapshotTree);\n\t\t\t}\n\t\t}\n\n\t\t// Currently always cache blobs as container runtime is not caching them.\n\t\tif (blobContents !== undefined) {\n\t\t\tthis.initBlobsCache(blobContents);\n\t\t}\n\n\t\tif (cacheOps) {\n\t\t\tthis.ops = ops;\n\t\t}\n\t\treturn id;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolver.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAEN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACN,gBAAgB,EAEhB,MAAM,kDAAkD,CAAC;AA2E1D;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAGzD;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiFlE;;;;;;;OAOG;IACU,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;CAkClB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAkCA"}
1
+ {"version":3,"file":"odspDriverUrlResolver.d.ts","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAEN,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAErD,OAAO,EACN,gBAAgB,EAEhB,MAAM,kDAAkD,CAAC;AA2E1D;;;;;GAKG;AACH,qBAAa,qBAAsB,YAAW,YAAY;;IAGzD;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiFlE;;;;;;;OAOG;IACU,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,qBAAqB,GACvC,OAAO,CAAC,MAAM,CAAC;CAkClB;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB,CAiCA"}
@@ -185,8 +185,7 @@ export function decodeOdspUrl(url) {
185
185
  throw new Error("ODSP Url did not contain a path");
186
186
  }
187
187
  return {
188
- // TODO Why are we non null asserting here?
189
- siteUrl: siteUrl,
188
+ siteUrl,
190
189
  driveId: decodeURIComponent(driveId),
191
190
  itemId: decodeURIComponent(itemId),
192
191
  path: decodeURIComponent(path),
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,YAAY,GAIZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,i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I,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEpD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO;QACN,2CAA2C;QAC3C,OAAO,EAAE,OAAQ;QACjB,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB;YACzC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC;YAC1C,CAAC,CAAC,SAAS;QACZ,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getHashedDocumentId } from \"./odspPublicUtils.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\nfunction getUrlBase(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(new URL(siteUrl))}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.slice(1);\n\t}\n\n\treturn str;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n * @legacy\n * @alpha\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IUrlResolver.resolve}\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst fileName: string = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there\",\n\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `https://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo: undefined,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } =\n\t\t\tdecodeOdspUrl(request.url);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `https://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.slice(1);\n\t\t}\n\n\t\tlet containerPackageName: string | undefined;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t\t// TODO: use stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nexport function decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\t// TODO Why are we non null asserting here?\n\t\tsiteUrl: siteUrl!,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n}\n"]}
1
+ {"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,YAAY,GAIZ,MAAM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AAQ,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEpD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO;QACN,OAAO;QACP,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB;YACzC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC;YAC1C,CAAC,CAAC,SAAS;QACZ,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getHashedDocumentId } from \"./odspPublicUtils.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\nfunction getUrlBase(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(new URL(siteUrl))}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.slice(1);\n\t}\n\n\treturn str;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n * @legacy\n * @alpha\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IUrlResolver.resolve}\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst fileName: string = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there\",\n\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `https://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo: undefined,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } =\n\t\t\tdecodeOdspUrl(request.url);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `https://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.slice(1);\n\t\t}\n\n\t\tlet containerPackageName: string | undefined;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t\t// TODO: use stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nexport function decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\tsiteUrl,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspSnapshotParser.d.ts","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAuB,MAAM,gBAAgB,CAAC;AA0CpE;;;GAGG;AACH,wBAAgB,yCAAyC,CACxD,YAAY,EAAE,aAAa,GACzB,SAAS,CAgCX"}
1
+ {"version":3,"file":"odspSnapshotParser.d.ts","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAuB,MAAM,gBAAgB,CAAC;AAyCpE;;;GAGG;AACH,wBAAgB,yCAAyC,CACxD,YAAY,EAAE,aAAa,GACzB,SAAS,CA6BX"}
@@ -21,7 +21,6 @@ function buildHierarchy(flatTree) {
21
21
  const entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));
22
22
  const entryPathBase = entry.path.slice(lastIndex + 1);
23
23
  // ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents
24
- // TODO Why are we non null asserting here?
25
24
  const node = lookup[entryPathDir];
26
25
  // Add in either the blob or tree
27
26
  if (entry.type === "tree") {
@@ -52,17 +51,14 @@ export function convertOdspSnapshotToSnapshotTreeAndBlobs(odspSnapshot) {
52
51
  blobsWithBufferContent.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? "utf8"));
53
52
  }
54
53
  }
55
- // TODO Why are we non null asserting here?
56
54
  const sequenceNumber = odspSnapshot?.trees[0].sequenceNumber;
57
55
  const val = {
58
56
  blobContents: blobsWithBufferContent,
59
57
  ops: odspSnapshot.ops?.map((op) => op.op) ?? [],
60
58
  sequenceNumber,
61
- // TODO Why are we non null asserting here?
62
59
  snapshotTree: buildHierarchy(odspSnapshot.trees[0]),
63
60
  latestSequenceNumber: odspSnapshot.ops && odspSnapshot.ops.length > 0
64
- ? // Non null asserting here because of the length check above
65
- odspSnapshot.ops[odspSnapshot.ops.length - 1].sequenceNumber
61
+ ? odspSnapshot.ops[odspSnapshot.ops.length - 1].sequenceNumber
66
62
  : sequenceNumber,
67
63
  snapshotFormatV: 1,
68
64
  };
@@ -1 +1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GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,cAAc;YAC9D,CAAC,CAAC,cAAc;QAClB,eAAe,EAAE,CAAC;KAClB,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC","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 { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\n\nimport { IOdspSnapshot, IOdspSnapshotCommit } from \"./contracts.js\";\n\n/**\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @returns the hierarchical tree\n */\nfunction buildHierarchy(flatTree: IOdspSnapshotCommit): ISnapshotTree {\n\tconst lookup: { [path: string]: ISnapshotTree } = {};\n\t// id is required for root tree as it will be used to determine the version we loaded from.\n\tconst root: ISnapshotTree = { id: flatTree.id, blobs: {}, trees: {} };\n\tlookup[\"\"] = root;\n\n\tfor (const entry of flatTree.entries) {\n\t\tconst lastIndex = entry.path.lastIndexOf(\"/\");\n\t\tconst entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));\n\t\tconst entryPathBase = entry.path.slice(lastIndex + 1);\n\n\t\t// ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents\n\t\t// TODO Why are we non null asserting here?\n\t\tconst node = lookup[entryPathDir]!;\n\n\t\t// Add in either the blob or tree\n\t\tif (entry.type === \"tree\") {\n\t\t\tconst newTree: ISnapshotTree = {\n\t\t\t\tblobs: {},\n\t\t\t\ttrees: {},\n\t\t\t\tunreferenced: entry.unreferenced,\n\t\t\t\tgroupId: entry.groupId,\n\t\t\t};\n\t\t\tnode.trees[entryPathBase] = newTree;\n\t\t\tlookup[entry.path] = newTree;\n\t\t} else if (entry.type === \"blob\") {\n\t\t\tnode.blobs[entryPathBase] = entry.id;\n\t\t}\n\t}\n\n\treturn root;\n}\n\n/**\n * Converts existing IOdspSnapshot to snapshot tree, blob array and ops\n * @param odspSnapshot - snapshot\n */\nexport function convertOdspSnapshotToSnapshotTreeAndBlobs(\n\todspSnapshot: IOdspSnapshot,\n): ISnapshot {\n\tconst blobsWithBufferContent = new Map<string, ArrayBuffer>();\n\tif (odspSnapshot.blobs) {\n\t\tfor (const blob of odspSnapshot.blobs) {\n\t\t\tassert(\n\t\t\t\tblob.encoding === \"base64\" || blob.encoding === undefined,\n\t\t\t\t0x0a4 /* Unexpected blob encoding type */,\n\t\t\t);\n\t\t\tblobsWithBufferContent.set(\n\t\t\t\tblob.id,\n\t\t\t\tstringToBuffer(blob.content, blob.encoding ?? \"utf8\"),\n\t\t\t);\n\t\t}\n\t}\n\n\t// TODO Why are we non null asserting here?\n\tconst sequenceNumber = odspSnapshot?.trees[0]!.sequenceNumber;\n\n\tconst val: ISnapshot = {\n\t\tblobContents: blobsWithBufferContent,\n\t\tops: odspSnapshot.ops?.map((op) => op.op) ?? [],\n\t\tsequenceNumber,\n\t\t// TODO Why are we non null asserting here?\n\t\tsnapshotTree: buildHierarchy(odspSnapshot.trees[0]!),\n\t\tlatestSequenceNumber:\n\t\t\todspSnapshot.ops && odspSnapshot.ops.length > 0\n\t\t\t\t? // Non null asserting here because of the length check above\n\t\t\t\t\todspSnapshot.ops[odspSnapshot.ops.length - 1]!.sequenceNumber\n\t\t\t\t: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\treturn val;\n}\n"]}
1
+ {"version":3,"file":"odspSnapshotParser.js","sourceRoot":"","sources":["../src/odspSnapshotParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,QAA6B;I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yCAAyC,CACxD,YAA2B;IAE3B,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC9D,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,KAAK,EAAE,CAAC;YACvC,MAAM,CACL,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EACzD,KAAK,CAAC,mCAAmC,CACzC,CAAC;YACF,sBAAsB,CAAC,GAAG,CACzB,IAAI,CAAC,EAAE,EACP,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,CACrD,CAAC;QACH,CAAC;IACF,CAAC;IAED,MAAM,cAAc,GAAG,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAE7D,MAAM,GAAG,GAAc;QACtB,YAAY,EAAE,sBAAsB;QACpC,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE;QAC/C,cAAc;QACd,YAAY,EAAE,cAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACnD,oBAAoB,EACnB,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC;YAC9C,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;YAC9D,CAAC,CAAC,cAAc;QAClB,eAAe,EAAE,CAAC;KAClB,CAAC;IACF,OAAO,GAAG,CAAC;AACZ,CAAC","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 { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\n\nimport { IOdspSnapshot, IOdspSnapshotCommit } from \"./contracts.js\";\n\n/**\n * Build a tree hierarchy base on a flat tree\n *\n * @param flatTree - a flat tree\n * @param blobsShaToPathCache - Map with blobs sha as keys and values as path of the blob.\n * @returns the hierarchical tree\n */\nfunction buildHierarchy(flatTree: IOdspSnapshotCommit): ISnapshotTree {\n\tconst lookup: { [path: string]: ISnapshotTree } = {};\n\t// id is required for root tree as it will be used to determine the version we loaded from.\n\tconst root: ISnapshotTree = { id: flatTree.id, blobs: {}, trees: {} };\n\tlookup[\"\"] = root;\n\n\tfor (const entry of flatTree.entries) {\n\t\tconst lastIndex = entry.path.lastIndexOf(\"/\");\n\t\tconst entryPathDir = entry.path.slice(0, Math.max(0, lastIndex));\n\t\tconst entryPathBase = entry.path.slice(lastIndex + 1);\n\n\t\t// ODSP snapshots are created breadth-first so we can assume we see tree nodes prior to their contents\n\t\tconst node = lookup[entryPathDir];\n\n\t\t// Add in either the blob or tree\n\t\tif (entry.type === \"tree\") {\n\t\t\tconst newTree: ISnapshotTree = {\n\t\t\t\tblobs: {},\n\t\t\t\ttrees: {},\n\t\t\t\tunreferenced: entry.unreferenced,\n\t\t\t\tgroupId: entry.groupId,\n\t\t\t};\n\t\t\tnode.trees[entryPathBase] = newTree;\n\t\t\tlookup[entry.path] = newTree;\n\t\t} else if (entry.type === \"blob\") {\n\t\t\tnode.blobs[entryPathBase] = entry.id;\n\t\t}\n\t}\n\n\treturn root;\n}\n\n/**\n * Converts existing IOdspSnapshot to snapshot tree, blob array and ops\n * @param odspSnapshot - snapshot\n */\nexport function convertOdspSnapshotToSnapshotTreeAndBlobs(\n\todspSnapshot: IOdspSnapshot,\n): ISnapshot {\n\tconst blobsWithBufferContent = new Map<string, ArrayBuffer>();\n\tif (odspSnapshot.blobs) {\n\t\tfor (const blob of odspSnapshot.blobs) {\n\t\t\tassert(\n\t\t\t\tblob.encoding === \"base64\" || blob.encoding === undefined,\n\t\t\t\t0x0a4 /* Unexpected blob encoding type */,\n\t\t\t);\n\t\t\tblobsWithBufferContent.set(\n\t\t\t\tblob.id,\n\t\t\t\tstringToBuffer(blob.content, blob.encoding ?? \"utf8\"),\n\t\t\t);\n\t\t}\n\t}\n\n\tconst sequenceNumber = odspSnapshot?.trees[0].sequenceNumber;\n\n\tconst val: ISnapshot = {\n\t\tblobContents: blobsWithBufferContent,\n\t\tops: odspSnapshot.ops?.map((op) => op.op) ?? [],\n\t\tsequenceNumber,\n\t\tsnapshotTree: buildHierarchy(odspSnapshot.trees[0]),\n\t\tlatestSequenceNumber:\n\t\t\todspSnapshot.ops && odspSnapshot.ops.length > 0\n\t\t\t\t? odspSnapshot.ops[odspSnapshot.ops.length - 1].sequenceNumber\n\t\t\t\t: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\treturn val;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspSummaryUploadManager.d.ts","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAA8B,MAAM,oCAAoC,CAAC;AAC9F,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAK9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACnG,OAAO,EACN,mBAAmB,EAInB,MAAM,0CAA0C,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;GAGG;AACH,qBAAa,wBAAwB;IAMnC,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAE9B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,8BAA8B;IARhD,OAAO,CAAC,yBAAyB,CAAqB;IACtD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;gBAGrB,WAAW,EAAE,MAAM,E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,7 +104,6 @@ export class OdspSummaryUploadManager {
104
104
  const keys = Object.keys(tree.tree);
105
105
  for (const key of keys) {
106
106
  assert(!key.includes("/"), 0x9cd /* id should not include slashes */);
107
- // Non null asserting for now, this should be changed to Object.entries
108
107
  const summaryObject = tree.tree[key];
109
108
  let id;
110
109
  let value;