@fluidframework/odsp-driver 2.71.0 → 2.73.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 (72) hide show
  1. package/CHANGELOG.md +8 -7
  2. package/dist/contracts.js.map +1 -1
  3. package/dist/createFile/createNewUtils.d.ts.map +1 -1
  4. package/dist/createFile/createNewUtils.js.map +1 -1
  5. package/dist/epochTracker.d.ts.map +1 -1
  6. package/dist/epochTracker.js.map +1 -1
  7. package/dist/fetchSnapshot.d.ts.map +1 -1
  8. package/dist/fetchSnapshot.js.map +1 -1
  9. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  10. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  11. package/dist/odspDeltaStorageService.d.ts.map +1 -1
  12. package/dist/odspDeltaStorageService.js.map +1 -1
  13. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  14. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  15. package/dist/odspDocumentServiceFactory.js +1 -1
  16. package/dist/odspDocumentServiceFactory.js.map +1 -1
  17. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  18. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  19. package/dist/odspDocumentStorageManager.js +1 -1
  20. package/dist/odspDocumentStorageManager.js.map +1 -1
  21. package/dist/odspLayerCompatState.js +1 -1
  22. package/dist/odspLayerCompatState.js.map +1 -1
  23. package/dist/odspUtils.js +1 -1
  24. package/dist/odspUtils.js.map +1 -1
  25. package/dist/packageVersion.d.ts +1 -1
  26. package/dist/packageVersion.js +1 -1
  27. package/dist/packageVersion.js.map +1 -1
  28. package/dist/vroom.d.ts.map +1 -1
  29. package/dist/vroom.js.map +1 -1
  30. package/lib/contracts.js.map +1 -1
  31. package/lib/createFile/createNewUtils.d.ts.map +1 -1
  32. package/lib/createFile/createNewUtils.js.map +1 -1
  33. package/lib/epochTracker.d.ts.map +1 -1
  34. package/lib/epochTracker.js.map +1 -1
  35. package/lib/fetchSnapshot.d.ts.map +1 -1
  36. package/lib/fetchSnapshot.js.map +1 -1
  37. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  38. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  39. package/lib/odspDeltaStorageService.d.ts.map +1 -1
  40. package/lib/odspDeltaStorageService.js.map +1 -1
  41. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  42. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  43. package/lib/odspDocumentServiceFactory.js +1 -1
  44. package/lib/odspDocumentServiceFactory.js.map +1 -1
  45. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  46. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  47. package/lib/odspDocumentStorageManager.js +1 -1
  48. package/lib/odspDocumentStorageManager.js.map +1 -1
  49. package/lib/odspLayerCompatState.js +1 -1
  50. package/lib/odspLayerCompatState.js.map +1 -1
  51. package/lib/odspUtils.js +1 -1
  52. package/lib/odspUtils.js.map +1 -1
  53. package/lib/packageVersion.d.ts +1 -1
  54. package/lib/packageVersion.js +1 -1
  55. package/lib/packageVersion.js.map +1 -1
  56. package/lib/vroom.d.ts.map +1 -1
  57. package/lib/vroom.js.map +1 -1
  58. package/package.json +15 -15
  59. package/src/contracts.ts +2 -2
  60. package/src/createFile/createNewUtils.ts +1 -0
  61. package/src/epochTracker.ts +1 -0
  62. package/src/fetchSnapshot.ts +1 -0
  63. package/src/odspDelayLoadedDeltaStream.ts +1 -0
  64. package/src/odspDeltaStorageService.ts +1 -0
  65. package/src/odspDocumentDeltaConnection.ts +1 -0
  66. package/src/odspDocumentServiceFactory.ts +1 -1
  67. package/src/odspDocumentServiceFactoryCore.ts +1 -0
  68. package/src/odspDocumentStorageManager.ts +2 -2
  69. package/src/odspLayerCompatState.ts +1 -1
  70. package/src/odspUtils.ts +2 -2
  71. package/src/packageVersion.ts +1 -1
  72. package/src/vroom.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @fluidframework/odsp-driver
2
2
 
3
+ ## 2.73.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.72.0
8
+
9
+ Dependency updates only.
10
+
3
11
  ## 2.71.0
4
12
 
5
13
  Dependency updates only.
@@ -21,7 +29,6 @@ Dependency updates only.
21
29
  In an effort to decouple the driver web cache from the odsp driver a number of types have been moved from `@fluidframework/odsp-driver-definitions` to `@fluidframework/driver-definitions`. The moved types have been deprecated in `@fluidframework/odsp-driver-definitions`, and any usages should be moved to `@fluidframework/driver-definitions`.
22
30
 
23
31
  The moved types are:
24
-
25
32
  - `IEntry`
26
33
  - `IFileEntry`
27
34
  - `ICacheEntry`
@@ -185,7 +192,6 @@ Dependency updates only.
185
192
  TypeScript types and implementation code.
186
193
 
187
194
  This means that using Fluid Framework packages require the following TypeScript settings in tsconfig.json:
188
-
189
195
  - `"moduleResolution": "Node16"` with `"module": "Node16"`
190
196
  - `"moduleResolution": "Bundler"` with `"module": "ESNext"`
191
197
 
@@ -254,7 +260,6 @@ Dependency updates only.
254
260
  - Updated server dependencies ([#19122](https://github.com/microsoft/FluidFramework/issues/19122)) [25366b4229](https://github.com/microsoft/FluidFramework/commits/25366b422918cb43685c5f328b50450749592902)
255
261
 
256
262
  The following Fluid server dependencies have been updated to the latest version, 3.0.0. [See the full changelog.](https://github.com/microsoft/FluidFramework/releases/tag/server_v3.0.0)
257
-
258
263
  - @fluidframework/gitresources
259
264
  - @fluidframework/server-kafka-orderer
260
265
  - @fluidframework/server-lambdas
@@ -308,7 +313,6 @@ Dependency updates only.
308
313
  - Dependencies on @fluidframework/protocol-definitions package updated to 3.0.0 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
309
314
 
310
315
  This included the following changes from the protocol-definitions release:
311
-
312
316
  - Updating signal interfaces for some planned improvements. The intention is split the interface between signals
313
317
  submitted by clients to the server and the resulting signals sent from the server to clients.
314
318
  - A new optional type member is available on the ISignalMessage interface and a new ISentSignalMessage interface has
@@ -323,7 +327,6 @@ Dependency updates only.
323
327
  - Server upgrade: dependencies on Fluid server packages updated to 2.0.1 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
324
328
 
325
329
  Dependencies on the following Fluid server package have been updated to version 2.0.1:
326
-
327
330
  - @fluidframework/gitresources: 2.0.1
328
331
  - @fluidframework/server-kafka-orderer: 2.0.1
329
332
  - @fluidframework/server-lambdas: 2.0.1
@@ -354,7 +357,6 @@ Dependency updates only.
354
357
  ### Minor Changes
355
358
 
356
359
  - Upcoming: The type of the logger property/param in various APIs will be changing ([#17350](https://github.com/microsoft/FluidFramework/issues/17350)) [27284bcda3](https://github.com/microsoft/FluidFramework/commits/27284bcda3d63cc4306cf76806f8a075db0db60f)
357
-
358
360
  - @fluidframework/runtime-definitions
359
361
  - `IFluidDataStoreRuntime.logger` will be re-typed as `ITelemetryBaseLogger`
360
362
  - @fluidframework/odsp-driver
@@ -375,7 +377,6 @@ Dependency updates only.
375
377
 
376
378
  The **@fluidframework/common-definitions** package is being deprecated, so the following interfaces and types are now
377
379
  imported from the **@fluidframework/core-interfaces** package:
378
-
379
380
  - interface IDisposable
380
381
  - interface IErrorEvent
381
382
  - interface IErrorEvent
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8MU,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAuC5C;;GAEG;AACU,QAAA,6BAA6B,GAAG,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tISnapshot,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { HostStoragePolicy } from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// eslint-disable-next-line import/no-deprecated\nimport type { ISnapshotContents } from \"./odspPublicUtils.js\";\n\n/**\n * Interface for error responses for the WebSocket connection\n */\nexport interface IOdspSocketError {\n\t/**\n\t * An error code number for the error that occurred\n\t * It will be a valid HTTP status code\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes\n\t * This should not be displayed to the user directly\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds\n\t * The client should wait this many seconds before retrying its request\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Any error supplied by the socket containing codes and inner errors with further\n\t * details about the error.\n\t */\n\terror?: unknown;\n}\n\n/**\n * Interface for delta storage response.\n * Contains either SequencedDocumentMessages or SequencedDeltaOpMessage.\n */\nexport interface IDeltaStorageGetResponse {\n\tvalue: ISequencedDocumentMessage[] | ISequencedDeltaOpMessage[];\n}\n\nexport interface ISequencedDeltaOpMessage {\n\top: ISequencedDocumentMessage;\n\tsequenceNumber: number;\n}\n\nexport interface IDocumentStorageGetVersionsResponse {\n\tvalue: IDocumentStorageVersion[];\n}\n\nexport interface IDocumentStorageVersion {\n\tid: string;\n}\n\n/**\n *\n * Data structures that form ODSP Summary\n *\n */\n\nexport interface IOdspSummaryPayload {\n\ttype: \"container\" | \"channel\";\n\tmessage: string;\n\tsequenceNumber: number;\n\tentries: OdspSummaryTreeEntry[];\n}\n\nexport interface IWriteSummaryResponse {\n\tid: string;\n}\n\nexport type OdspSummaryTreeEntry = IOdspSummaryTreeValueEntry | IOdspSummaryTreeHandleEntry;\n\nexport interface IOdspSummaryTreeBaseEntry {\n\tpath: string;\n\ttype: \"blob\" | \"tree\" | \"commit\";\n}\n\nexport interface IOdspSummaryTreeValueEntry extends IOdspSummaryTreeBaseEntry {\n\tvalue: OdspSummaryTreeValue;\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IOdspSummaryTreeHandleEntry extends IOdspSummaryTreeBaseEntry {\n\tid: string;\n}\n\nexport type OdspSummaryTreeValue = IOdspSummaryTree | IOdspSummaryBlob;\n\nexport interface IOdspSummaryTree {\n\ttype: \"tree\";\n\tentries?: OdspSummaryTreeEntry[];\n}\n\nexport interface IOdspSummaryBlob {\n\ttype: \"blob\";\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n}\n\n/**\n *\n * Data structures that form ODSP Snapshot\n *\n */\n\nexport interface IOdspSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IOdspSnapshotTreeEntryCommit {\n\tid: string;\n\tpath: string;\n\ttype: \"commit\";\n}\n\nexport interface IOdspSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IOdspSnapshotTreeEntry =\n\t| IOdspSnapshotTreeEntryTree\n\t| IOdspSnapshotTreeEntryCommit\n\t| IOdspSnapshotTreeEntryBlob;\n\nexport interface IOdspSnapshotCommit {\n\tentries: IOdspSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\n/**\n * Blob content, represents blobs in downloaded snapshot.\n */\nexport interface IOdspSnapshotBlob {\n\tcontent: string;\n\t// SPO only uses \"base64\" today for download.\n\t// We are adding undefined too, as temp way to roundtrip strings unchanged.\n\tencoding: \"base64\" | undefined;\n\tid: string;\n\tsize: number;\n}\n\nexport interface IOdspSnapshot {\n\tid: string;\n\ttrees: IOdspSnapshotCommit[];\n\tblobs?: IOdspSnapshotBlob[];\n\tops?: ISequencedDeltaOpMessage[];\n}\n\n/**\n * Same as HostStoragePolicy, but adds options that are internal to runtime.\n * All fields should be optional.\n */\nexport interface HostStoragePolicyInternal extends HostStoragePolicy {\n\tsummarizerClient?: boolean;\n\n\tsupportGetSnapshotApi?: boolean;\n}\n\nexport interface ICreateFileResponse {\n\t\"@odata.context\": string;\n\t\"driveId\": string;\n\t\"id\": string;\n\t\"itemId\": string;\n\t\"itemUrl\": string;\n\t\"sequenceNumber\": number;\n\t// sharing object contains shareId, sharingLink data or error in the response\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\"sharing\"?: any;\n\t\"sharingLink\"?: string;\n\t\"sharingLinkErrorReason\"?: string;\n\t\"name\": string;\n}\n\nexport interface IRenameFileResponse {\n\t\"@odata.context\": string;\n\t\"id\": string;\n\t\"name\": string;\n}\n\nexport interface IVersionedValueWithEpoch {\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tvalue: any;\n\tfluidEpoch: string;\n\t// This is same as \"persistedCacheValueVersion\" below. This represents the version of data stored in cache.\n\tversion: 3;\n}\n\nexport const persistedCacheValueVersion = 3;\n\nexport interface IGetOpsResponse {\n\tnonce: string;\n\tcode: number;\n\t/**\n\t * Time in seconds. Currently never set by PUSH\n\t */\n\tretryAfter?: number;\n\tmessages?: ISequencedDocumentMessage[];\n}\n\nexport interface IFlushOpsResponse {\n\tnonce: string;\n\tcode: number;\n\t/**\n\t * Time in seconds\n\t */\n\tretryAfter?: number;\n\tlastPersistedSequenceNumber?: number;\n}\n\n/**\n * Represents the cached snapshot value.\n * @deprecated This will be replaced with ISnapshotCachedEntry2 which wraps the new ISnapshot interface.\n * For now, to support back compat from cache, we need to keep it for now.\n */\n// eslint-disable-next-line import/no-deprecated\nexport interface ISnapshotCachedEntry extends ISnapshotContents {\n\tcacheEntryTime: number;\n}\n\n/**\n * Represents the cached snapshot value.\n */\nexport interface ISnapshotCachedEntry2 extends ISnapshot {\n\tcacheEntryTime: number;\n}\n\n/**\n * Represents the type of signal containing the sensitivity policy labels for the container.\n */\nexport const policyLabelsUpdatesSignalType = \"PolicyLabelsUpdate\";\n"]}
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA8MU,QAAA,0BAA0B,GAAG,CAAC,CAAC;AAuC5C;;GAEG;AACU,QAAA,6BAA6B,GAAG,oBAAoB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tISnapshot,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { HostStoragePolicy } from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// eslint-disable-next-line import-x/no-deprecated\nimport type { ISnapshotContents } from \"./odspPublicUtils.js\";\n\n/**\n * Interface for error responses for the WebSocket connection\n */\nexport interface IOdspSocketError {\n\t/**\n\t * An error code number for the error that occurred\n\t * It will be a valid HTTP status code\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes\n\t * This should not be displayed to the user directly\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds\n\t * The client should wait this many seconds before retrying its request\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Any error supplied by the socket containing codes and inner errors with further\n\t * details about the error.\n\t */\n\terror?: unknown;\n}\n\n/**\n * Interface for delta storage response.\n * Contains either SequencedDocumentMessages or SequencedDeltaOpMessage.\n */\nexport interface IDeltaStorageGetResponse {\n\tvalue: ISequencedDocumentMessage[] | ISequencedDeltaOpMessage[];\n}\n\nexport interface ISequencedDeltaOpMessage {\n\top: ISequencedDocumentMessage;\n\tsequenceNumber: number;\n}\n\nexport interface IDocumentStorageGetVersionsResponse {\n\tvalue: IDocumentStorageVersion[];\n}\n\nexport interface IDocumentStorageVersion {\n\tid: string;\n}\n\n/**\n *\n * Data structures that form ODSP Summary\n *\n */\n\nexport interface IOdspSummaryPayload {\n\ttype: \"container\" | \"channel\";\n\tmessage: string;\n\tsequenceNumber: number;\n\tentries: OdspSummaryTreeEntry[];\n}\n\nexport interface IWriteSummaryResponse {\n\tid: string;\n}\n\nexport type OdspSummaryTreeEntry = IOdspSummaryTreeValueEntry | IOdspSummaryTreeHandleEntry;\n\nexport interface IOdspSummaryTreeBaseEntry {\n\tpath: string;\n\ttype: \"blob\" | \"tree\" | \"commit\";\n}\n\nexport interface IOdspSummaryTreeValueEntry extends IOdspSummaryTreeBaseEntry {\n\tvalue: OdspSummaryTreeValue;\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IOdspSummaryTreeHandleEntry extends IOdspSummaryTreeBaseEntry {\n\tid: string;\n}\n\nexport type OdspSummaryTreeValue = IOdspSummaryTree | IOdspSummaryBlob;\n\nexport interface IOdspSummaryTree {\n\ttype: \"tree\";\n\tentries?: OdspSummaryTreeEntry[];\n}\n\nexport interface IOdspSummaryBlob {\n\ttype: \"blob\";\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n}\n\n/**\n *\n * Data structures that form ODSP Snapshot\n *\n */\n\nexport interface IOdspSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IOdspSnapshotTreeEntryCommit {\n\tid: string;\n\tpath: string;\n\ttype: \"commit\";\n}\n\nexport interface IOdspSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IOdspSnapshotTreeEntry =\n\t| IOdspSnapshotTreeEntryTree\n\t| IOdspSnapshotTreeEntryCommit\n\t| IOdspSnapshotTreeEntryBlob;\n\nexport interface IOdspSnapshotCommit {\n\tentries: IOdspSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\n/**\n * Blob content, represents blobs in downloaded snapshot.\n */\nexport interface IOdspSnapshotBlob {\n\tcontent: string;\n\t// SPO only uses \"base64\" today for download.\n\t// We are adding undefined too, as temp way to roundtrip strings unchanged.\n\tencoding: \"base64\" | undefined;\n\tid: string;\n\tsize: number;\n}\n\nexport interface IOdspSnapshot {\n\tid: string;\n\ttrees: IOdspSnapshotCommit[];\n\tblobs?: IOdspSnapshotBlob[];\n\tops?: ISequencedDeltaOpMessage[];\n}\n\n/**\n * Same as HostStoragePolicy, but adds options that are internal to runtime.\n * All fields should be optional.\n */\nexport interface HostStoragePolicyInternal extends HostStoragePolicy {\n\tsummarizerClient?: boolean;\n\n\tsupportGetSnapshotApi?: boolean;\n}\n\nexport interface ICreateFileResponse {\n\t\"@odata.context\": string;\n\t\"driveId\": string;\n\t\"id\": string;\n\t\"itemId\": string;\n\t\"itemUrl\": string;\n\t\"sequenceNumber\": number;\n\t// sharing object contains shareId, sharingLink data or error in the response\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\"sharing\"?: any;\n\t\"sharingLink\"?: string;\n\t\"sharingLinkErrorReason\"?: string;\n\t\"name\": string;\n}\n\nexport interface IRenameFileResponse {\n\t\"@odata.context\": string;\n\t\"id\": string;\n\t\"name\": string;\n}\n\nexport interface IVersionedValueWithEpoch {\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tvalue: any;\n\tfluidEpoch: string;\n\t// This is same as \"persistedCacheValueVersion\" below. This represents the version of data stored in cache.\n\tversion: 3;\n}\n\nexport const persistedCacheValueVersion = 3;\n\nexport interface IGetOpsResponse {\n\tnonce: string;\n\tcode: number;\n\t/**\n\t * Time in seconds. Currently never set by PUSH\n\t */\n\tretryAfter?: number;\n\tmessages?: ISequencedDocumentMessage[];\n}\n\nexport interface IFlushOpsResponse {\n\tnonce: string;\n\tcode: number;\n\t/**\n\t * Time in seconds\n\t */\n\tretryAfter?: number;\n\tlastPersistedSequenceNumber?: number;\n}\n\n/**\n * Represents the cached snapshot value.\n * @deprecated This will be replaced with ISnapshotCachedEntry2 which wraps the new ISnapshot interface.\n * For now, to support back compat from cache, we need to keep it for now.\n */\n// eslint-disable-next-line import-x/no-deprecated\nexport interface ISnapshotCachedEntry extends ISnapshotContents {\n\tcacheEntryTime: number;\n}\n\n/**\n * Represents the cached snapshot value.\n */\nexport interface ISnapshotCachedEntry2 extends ISnapshot {\n\tcacheEntryTime: number;\n}\n\n/**\n * Represents the type of signal containing the sensitivity policy labels for the container.\n */\nexport const policyLabelsUpdatesSignalType = \"PolicyLabelsUpdate\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createNewUtils.d.ts","sourceRoot":"","sources":["../../src/createFile/createNewUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,KAAK,YAAY,EAGjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAM5F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,kDAAkD,CAAC;AACxG,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACX,mBAAmB,EAInB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMpE;;GAEG;AACH,wBAAgB,yCAAyC,CACxD,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,GACZ,SAAS,CAiBX;AAiDD,wBAAgB,mCAAmC,CAClD,gBAAgB,EAAE,YAAY,GAC5B,mBAAmB,CA2BrB;AAiED,wBAAsB,2BAA2B,CAAC,CAAC,EAAE,IAAI,EAAE;IAC1D,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,aAAa,EAAE,+BAA+B,CAAC;IAC/C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC,EAAE,OAAO,CAAC;IAChD,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IAChD,iB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BAAY,EACvC,KAAK,IAAI,EAAE,CACV,YAAY,CAAC,mBAAmB,CAC/B,GAAG,EACH;gBACC,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,MAAM;aACN,EACD,SAAS,EACT,SAAS,CACT,EACF,aAAa,EACb,MAAM,CACN,CAAC;YAEF,wBAAwB,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAElD,KAAK,CAAC,GAAG,CAAC;gBACT,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAnHD,kEAmHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ISummaryBlob,\n\ttype ISummaryTree,\n\ttype SummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport type { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetGitType,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport type { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./../contracts.js\";\nimport type { EpochTracker, FetchType } from \"./../epochTracker.js\";\nimport { getHeadersWithAuth } from \"./../getUrlAndHeadersWithAuth.js\";\nimport { checkForKnownServerFarmType } from \"./../odspUrlHelper.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./../odspUtils.js\";\nimport { runWithRetry } from \"./../retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tassert(!key.includes(\"/\"), 0x9cc /* id should not include slashes */);\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: key,\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetAuthHeader: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n\tadditionalHeaders?: { [key: string]: string };\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t\tadditionalHeaders = {},\n\t} = args;\n\tconst internalFarmType = checkForKnownServerFarmType(initialUrl);\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName, details: { internalFarmType } },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\tconst authInBodyUrl = urlObj.href;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url: authInBodyUrl, method } },\n\t\t\t\t\ttelemetryName,\n\t\t\t\t);\n\t\t\t\tconst postBodyWithAuthHeaders = [\n\t\t\t\t\t`Authorization: ${authHeader}`,\n\t\t\t\t\t`X-HTTP-Method-Override: POST`,\n\t\t\t\t\t`Content-Type: application/json`,\n\t\t\t\t];\n\t\t\t\tif (additionalHeaders !== undefined) {\n\t\t\t\t\tfor (const [key, value] of Object.entries(additionalHeaders)) {\n\t\t\t\t\t\tpostBodyWithAuthHeaders.push(`${key}: ${value}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst postBodyWithAuth = [\n\t\t\t\t\t`--${formBoundary}`,\n\t\t\t\t\t...postBodyWithAuthHeaders,\n\t\t\t\t\t`_post: 1`,\n\t\t\t\t\t`\\r\\n${snapshotBody}`,\n\t\t\t\t\t`\\r\\n--${formBoundary}--`,\n\t\t\t\t].join(\"\\r\\n\");\n\n\t\t\t\tlet postBody = snapshotBody;\n\t\t\t\t// We use the byte length of the post body to determine if we should use the multipart/form-data or not. This helps\n\t\t\t\t// in cases where the body contains data with different language where 1 char could be multiple code points.\n\t\t\t\tif (\n\t\t\t\t\tnew TextEncoder().encode(postBodyWithAuth).length <= maxUmpPostBodySize &&\n\t\t\t\t\tauthHeader?.startsWith(\"Bearer\")\n\t\t\t\t) {\n\t\t\t\t\turl = authInBodyUrl;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t\tpostBody = postBodyWithAuth;\n\t\t\t\t} else {\n\t\t\t\t\turl = initialUrl;\n\t\t\t\t\tconst authHeaderNoUmp = await getAuthHeader(\n\t\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\ttelemetryName,\n\t\t\t\t\t);\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...additionalHeaders,\n\t\t\t\t\t\t...getHeadersWithAuth(authHeaderNoUmp),\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
1
+ {"version":3,"file":"createNewUtils.js","sourceRoot":"","sources":["../../src/createFile/createNewUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkF;AAClF,kEAA8E;AAC9E,2EAK4C;AAE5C,oEAI+C;AAE/C,uEAGkD;AAElD,+BAAkC;AASlC,kFAAsE;AACtE,4DAAoE;AACpE,oDAAoF;AACpF,sDAAkD;AAElD;;GAEG;AACH,SAAgB,yCAAyC,CACxD,OAAqB,EACrB,MAAc;IAEd,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAiB,CAAC;IAClE,MAAM,kBAAkB,GAAG,IAAA,8CAAmC,EAAC,eAAe,CAAC,CAAC;IAChF,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAuB,CAAC;IACpD,MAAM,YAAY,GAAG,6CAA6C,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1F,YAAY,CAAC,EAAE,GAAG,MAAM,CAAC;IACzB,MAAM,iBAAiB,GAAc;QACpC,YAAY;QACZ,YAAY;QACZ,GAAG,EAAE,EAAE;QACP,c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AAI,CAAC;gBACjB,QAAQ,GAAG,gBAAgB,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACP,GAAG,GAAG,UAAU,CAAC;gBACjB,MAAM,eAAe,GAAG,MAAM,aAAa,CAC1C,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EACxC,aAAa,CACb,CAAC;gBACF,OAAO,GAAG;oBACT,GAAG,iBAAiB;oBACpB,GAAG,IAAA,gDAAkB,EAAC,eAAe,CAAC;oBACtC,cAAc,EAAE,kBAAkB;iBAClC,CAAC;gBACF,QAAQ,GAAG,YAAY,CAAC;YACzB,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,IAAA,4BAAY,EACvC,KAAK,IAAI,EAAE,CACV,YAAY,CAAC,mBAAmB,CAC/B,GAAG,EACH;gBACC,IAAI,EAAE,QAAQ;gBACd,OAAO;gBACP,MAAM;aACN,EACD,SAAS,EACT,SAAS,CACT,EACF,aAAa,EACb,MAAM,CACN,CAAC;YAEF,wBAAwB,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YAElD,KAAK,CAAC,GAAG,CAAC;gBACT,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjC,GAAG,aAAa,CAAC,UAAU;aAC3B,CAAC,CAAC;YAEH,OAAO,aAAa,CAAC,OAAO,CAAC;QAC9B,CAAC,CACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC;AAnHD,kEAmHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype ISummaryBlob,\n\ttype ISummaryTree,\n\ttype SummaryObject,\n\tSummaryType,\n} from \"@fluidframework/driver-definitions\";\nimport type { ISnapshot, ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetGitType,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport type { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tIOdspSummaryPayload,\n\tIOdspSummaryTree,\n\tOdspSummaryTreeEntry,\n\tOdspSummaryTreeValue,\n} from \"./../contracts.js\";\nimport type { EpochTracker, FetchType } from \"./../epochTracker.js\";\nimport { getHeadersWithAuth } from \"./../getUrlAndHeadersWithAuth.js\";\nimport { checkForKnownServerFarmType } from \"./../odspUrlHelper.js\";\nimport { getWithRetryForTokenRefresh, maxUmpPostBodySize } from \"./../odspUtils.js\";\nimport { runWithRetry } from \"./../retryUtils.js\";\n\n/**\n * Converts a summary(ISummaryTree) taken in detached container to snapshot tree and blobs\n */\nexport function convertCreateNewSummaryTreeToTreeAndBlobs(\n\tsummary: ISummaryTree,\n\ttreeId: string,\n): ISnapshot {\n\tconst protocolSummary = summary.tree[\".protocol\"] as ISummaryTree;\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tconst blobContents = new Map<string, ArrayBuffer>();\n\tconst snapshotTree = convertCreateNewSummaryTreeToTreeAndBlobsCore(summary, blobContents);\n\tsnapshotTree.id = treeId;\n\tconst snapshotTreeValue: ISnapshot = {\n\t\tsnapshotTree,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber,\n\t\tlatestSequenceNumber: sequenceNumber,\n\t\tsnapshotFormatV: 1,\n\t};\n\n\treturn snapshotTreeValue;\n}\n\nfunction convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\tsummary: ISummaryTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISnapshotTree {\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] = convertCreateNewSummaryTreeToTreeAndBlobsCore(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\tblobs,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tblobs.set(blobId, contentBuffer);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\tcase SummaryType.Attachment: {\n\t\t\t\tthrow new Error(`No ${summaryObject.type} should be present for detached summary!`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(\n\t\t\t\t\tsummaryObject,\n\t\t\t\t\t`Unknown tree type ${(summaryObject as SummaryObject).type}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\nexport function convertSummaryIntoContainerSnapshot(\n\tcreateNewSummary: ISummaryTree,\n): IOdspSummaryPayload {\n\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\tthrow new Error(\"App and protocol summary required for create new path!!\");\n\t}\n\tconst appSummary = createNewSummary.tree[\".app\"];\n\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst attributesSummaryBlob: ISummaryBlob = {\n\t\ttype: SummaryType.Blob,\n\t\tcontent: JSON.stringify(documentAttributes),\n\t};\n\tprotocolSummary.tree.attributes = attributesSummaryBlob;\n\tconst convertedCreateNewSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\tconst snapshotTree = convertSummaryToSnapshotTreeForCreateNew(convertedCreateNewSummary);\n\tconst snapshot: IOdspSummaryPayload = {\n\t\tentries: snapshotTree.entries ?? [],\n\t\tmessage: \"app\",\n\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\ttype: \"container\",\n\t};\n\treturn snapshot;\n}\n\n/**\n * Converts a summary tree to ODSP tree\n */\nfunction convertSummaryToSnapshotTreeForCreateNew(summary: ISummaryTree): IOdspSummaryTree {\n\tconst snapshotTree: IOdspSummaryTree = {\n\t\ttype: \"tree\",\n\t\tentries: [],\n\t};\n\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tassert(!key.includes(\"/\"), 0x9cc /* id should not include slashes */);\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tlet value: OdspSummaryTreeValue;\n\t\t// Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n\t\t// property is not present, the tree entry is considered referenced. If the property is present and is true,\n\t\t// the tree entry is considered unreferenced.\n\t\tlet unreferenced: true | undefined;\n\t\tlet groupId: string | undefined;\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tvalue = convertSummaryToSnapshotTreeForCreateNew(summaryObject);\n\t\t\t\tunreferenced = summaryObject.unreferenced;\n\t\t\t\tgroupId = summaryObject.groupId;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst content =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? summaryObject.content\n\t\t\t\t\t\t: Uint8ArrayToString(summaryObject.content, \"base64\");\n\t\t\t\tconst encoding = typeof summaryObject.content === \"string\" ? \"utf-8\" : \"base64\";\n\n\t\t\t\tvalue = {\n\t\t\t\t\ttype: \"blob\",\n\t\t\t\t\tcontent,\n\t\t\t\t\tencoding,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle: {\n\t\t\t\tthrow new Error(\"No handle should be present for first summary!!\");\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tthrow new Error(`Unknown tree type ${summaryObject.type}`);\n\t\t\t}\n\t\t}\n\n\t\tconst entry: OdspSummaryTreeEntry = {\n\t\t\tpath: key,\n\t\t\ttype: getGitType(summaryObject),\n\t\t\tvalue,\n\t\t\tunreferenced,\n\t\t\tgroupId,\n\t\t};\n\t\tsnapshotTree.entries?.push(entry);\n\t}\n\n\treturn snapshotTree;\n}\n\nexport async function createNewFluidContainerCore<T>(args: {\n\tcontainerSnapshot: IOdspSummaryPayload;\n\tgetAuthHeader: InstrumentedStorageTokenFetcher;\n\tlogger: ITelemetryLoggerExt;\n\tinitialUrl: string;\n\tforceAccessTokenViaAuthorizationHeader: boolean;\n\tepochTracker: EpochTracker;\n\ttelemetryName: string;\n\tfetchType: FetchType;\n\tvalidateResponseCallback?: (content: T) => void;\n\tadditionalHeaders?: { [key: string]: string };\n}): Promise<T> {\n\tconst {\n\t\tcontainerSnapshot,\n\t\tgetAuthHeader,\n\t\tlogger,\n\t\tinitialUrl,\n\t\tepochTracker,\n\t\ttelemetryName,\n\t\tfetchType,\n\t\tvalidateResponseCallback,\n\t\tadditionalHeaders = {},\n\t} = args;\n\tconst internalFarmType = checkForKnownServerFarmType(initialUrl);\n\n\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: telemetryName, details: { internalFarmType } },\n\t\t\tasync (event) => {\n\t\t\t\tconst snapshotBody = JSON.stringify(containerSnapshot);\n\t\t\t\tlet url: string;\n\t\t\t\tlet headers: { [index: string]: string };\n\t\t\t\tlet addInBody = false;\n\t\t\t\tconst formBoundary = uuid();\n\t\t\t\tconst urlObj = new URL(initialUrl);\n\t\t\t\turlObj.searchParams.set(\"ump\", \"1\");\n\t\t\t\tconst authInBodyUrl = urlObj.href;\n\t\t\t\tconst method = \"POST\";\n\t\t\t\tconst authHeader = await getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url: authInBodyUrl, method } },\n\t\t\t\t\ttelemetryName,\n\t\t\t\t);\n\t\t\t\tconst postBodyWithAuthHeaders = [\n\t\t\t\t\t`Authorization: ${authHeader}`,\n\t\t\t\t\t`X-HTTP-Method-Override: POST`,\n\t\t\t\t\t`Content-Type: application/json`,\n\t\t\t\t];\n\t\t\t\tif (additionalHeaders !== undefined) {\n\t\t\t\t\tfor (const [key, value] of Object.entries(additionalHeaders)) {\n\t\t\t\t\t\tpostBodyWithAuthHeaders.push(`${key}: ${value}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst postBodyWithAuth = [\n\t\t\t\t\t`--${formBoundary}`,\n\t\t\t\t\t...postBodyWithAuthHeaders,\n\t\t\t\t\t`_post: 1`,\n\t\t\t\t\t`\\r\\n${snapshotBody}`,\n\t\t\t\t\t`\\r\\n--${formBoundary}--`,\n\t\t\t\t].join(\"\\r\\n\");\n\n\t\t\t\tlet postBody = snapshotBody;\n\t\t\t\t// We use the byte length of the post body to determine if we should use the multipart/form-data or not. This helps\n\t\t\t\t// in cases where the body contains data with different language where 1 char could be multiple code points.\n\t\t\t\tif (\n\t\t\t\t\tnew TextEncoder().encode(postBodyWithAuth).length <= maxUmpPostBodySize &&\n\t\t\t\t\tauthHeader?.startsWith(\"Bearer\")\n\t\t\t\t) {\n\t\t\t\t\turl = authInBodyUrl;\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t\t\t\t\t};\n\t\t\t\t\taddInBody = true;\n\t\t\t\t\tpostBody = postBodyWithAuth;\n\t\t\t\t} else {\n\t\t\t\t\turl = initialUrl;\n\t\t\t\t\tconst authHeaderNoUmp = await getAuthHeader(\n\t\t\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\t\ttelemetryName,\n\t\t\t\t\t);\n\t\t\t\t\theaders = {\n\t\t\t\t\t\t...additionalHeaders,\n\t\t\t\t\t\t...getHeadersWithAuth(authHeaderNoUmp),\n\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t};\n\t\t\t\t\tpostBody = snapshotBody;\n\t\t\t\t}\n\n\t\t\t\tconst fetchResponse = await runWithRetry(\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tepochTracker.fetchAndParseAsJSON<T>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: postBody,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfetchType,\n\t\t\t\t\t\t\taddInBody,\n\t\t\t\t\t\t),\n\t\t\t\t\ttelemetryName,\n\t\t\t\t\tlogger,\n\t\t\t\t);\n\n\t\t\t\tvalidateResponseCallback?.(fetchResponse.content);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t...fetchResponse.propsToLog,\n\t\t\t\t});\n\n\t\t\t\treturn fetchResponse.content;\n\t\t\t},\n\t\t);\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"epochTracker.d.ts","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAEX,MAAM,EACN,UAAU,EACV,eAAe,EACf,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAIN,WAAW,EAEX,MAAM,uCAAuC,CAAC;AAS/C,OAAO,EACN,KAAK,mBAAmB,EAMxB,MAAM,0CA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CAAC;CACD;AA5HD,gEA4HC;AAWD,SAAgB,yBAAyB,CACxC,iBAAkC,EAClC,kBAAuC,EACvC,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;IAE5B,MAAM,YAAY,GAAG,IAAI,0BAA0B,CAClD,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,kBAAkB,CAClB,CAAC;IACF,OAAO;QACN,KAAK,EAAE;YACN,GAAG,kBAAkB;YACrB,cAAc,EAAE,YAAY;SAC5B;QACD,YAAY;KACZ,CAAC;AACH,CAAC;AApBD,8DAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tLocationRedirectionError,\n\tmaximumCacheDurationMs,\n\tNonRetryableError,\n\tRateLimiter,\n\tThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspError,\n\ttype IOdspErrorAugmentations,\n\ttype IOdspResolvedUrl,\n\tOdspErrorTypes,\n\tsnapshotKey,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { type IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport type { INonPersistentCache, IOdspCache, IPersistedFileCache } from \"./odspCache.js\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection.js\";\nimport {\n\ttype IOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * @legacy\n * @beta\n */\nexport type FetchType =\n\t| \"blob\"\n\t| \"createBlob\"\n\t| \"createFile\"\n\t| \"joinSession\"\n\t| \"ops\"\n\t| \"test\"\n\t| \"snapshotTree\"\n\t| \"treesLatest\"\n\t| \"uploadSummary\"\n\t| \"push\"\n\t| \"versions\"\n\t| \"renameFile\";\n\n/**\n * @legacy\n * @beta\n */\nexport type FetchTypeInternal = FetchType | \"cache\";\n\nexport const Odsp409Error = \"Odsp409Error\";\n\n/**\n * In ODSP, the concept of \"epoch\" refers to binary updates to files. For example, this might include using\n * version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch\n * value being incremented.\n *\n * The implications of these binary updates is that the Fluid state is disrupted: the sequence number might\n * go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's\n * not safe to continue collaboration across an epoch change. We need to detect these epoch changes and\n * error out from the collaboration.\n *\n * This class is a wrapper around fetch calls. It adds epoch to the request made so that the\n * server can match it with its epoch value in order to match the version.\n * It also validates the epoch value received in response of fetch calls. If the epoch does not match,\n * then it also clears all the cached entries for the given container.\n * @legacy\n * @beta\n */\nexport class EpochTracker implements IPersistedFileCache {\n\tprivate _fluidEpoch: string | undefined;\n\n\tprivate readonly snapshotCacheExpiryTimeoutMs: number;\n\tpublic readonly rateLimiter: RateLimiter;\n\tprivate readonly driverId = uuid();\n\t// This tracks the request number made by the driver instance.\n\tprivate networkCallNumber = 1;\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\t// Limits the max number of concurrent requests to 24.\n\t\tthis.rateLimiter = new RateLimiter(24);\n\n\t\t// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts\n\t\tthis.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\",\n\t\t)\n\t\t\t? 0\n\t\t\t: maximumCacheDurationMs;\n\t}\n\n\t// public for UT purposes only!\n\tpublic setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal): void {\n\t\tassert(this._fluidEpoch === undefined, 0x1db /* \"epoch exists\" */);\n\t\tthis._fluidEpoch = epoch;\n\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"EpochLearnedFirstTime\",\n\t\t\tepoch,\n\t\t\tfetchType,\n\t\t\tfromCache,\n\t\t});\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\ttry {\n\t\t\t// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache\n\t\t\tconst value = (await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t)) as IVersionedValueWithEpoch;\n\t\t\t// Version mismatch between what the runtime expects and what it recieved.\n\t\t\t// The cached value should not be used\n\t\t\tif (value === undefined || value.version !== persistedCacheValueVersion) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tassert(value.fluidEpoch !== undefined, 0x1dc /* \"all entries have to have epoch\" */);\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(value.fluidEpoch, true, \"cache\");\n\t\t\t\t// Epoch mismatch, the cached value is considerably different from what the current state of\n\t\t\t\t// the runtime and should not be used\n\t\t\t} else if (this._fluidEpoch !== value.fluidEpoch) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately\n\t\t\t// expire all old caches that do not have cacheEntryTime\n\t\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tconst cacheTime = value.value?.cacheEntryTime;\n\t\t\t\tconst currentTime = Date.now();\n\t\t\t\tif (\n\t\t\t\t\tcacheTime === undefined ||\n\t\t\t\t\tcurrentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"odspVersionsCacheExpired\",\n\t\t\t\t\t\tduration: currentTime - cacheTime,\n\t\t\t\t\t\tmaxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tawait this.removeEntries();\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value.value;\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cacheFetchError\", type: entry.type }, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t// TODO: take a stronger type or `unknown`\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tpublic async put(entry: IEntry, value: any): Promise<void> {\n\t\tassert(this._fluidEpoch !== undefined, 0x1dd /* \"no epoch\" */);\n\t\t// For snapshots, the value should have the cacheEntryTime.\n\t\t// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.\n\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tvalue.cacheEntryTime = value.cacheEntryTime ?? Date.now();\n\t\t}\n\t\tconst data: IVersionedValueWithEpoch = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tvalue,\n\t\t\tversion: persistedCacheValueVersion,\n\t\t\tfluidEpoch: this._fluidEpoch,\n\t\t};\n\t\treturn this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cachePutError\", type: entry.type }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic async removeEntries(): Promise<void> {\n\t\ttry {\n\t\t\treturn await this.cache.removeEntries(this.fileEntry);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"removeCacheEntries\" }, error);\n\t\t}\n\t}\n\n\tpublic get fluidEpoch(): string | undefined {\n\t\treturn this._fluidEpoch;\n\t}\n\n\tpublic async validateEpoch(epoch: string | undefined, fetchType: FetchType): Promise<void> {\n\t\tassert(epoch !== undefined, 0x584 /* response should contain epoch */);\n\t\ttry {\n\t\t\tthis.validateEpochFromResponse(epoch, fetchType);\n\t\t} catch (error) {\n\t\t\tawait this.checkForEpochError(error, epoch, fetchType);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\treturn this.fetchCore<T>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchAndParseAsJSONHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetch(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<Response>> {\n\t\treturn this.fetchCore<Response>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async fetchCore<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetcher: (url: string, fetchOptions: RequestInit) => Promise<IOdspResponse<T>>,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\tconst clientCorrelationId = this.formatClientCorrelationId(fetchReason);\n\t\t// Add epoch in fetch request.\n\t\tthis.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);\n\t\tlet epochFromResponse: string | undefined;\n\t\treturn this.rateLimiter\n\t\t\t.schedule(async () => fetcher(url, fetchOptions))\n\t\t\t.then((response) => {\n\t\t\t\tepochFromResponse = response.headers.get(\"x-fluid-epoch\");\n\t\t\t\tthis.validateEpochFromResponse(epochFromResponse, fetchType);\n\t\t\t\tresponse.propsToLog.XRequestStatsHeader = clientCorrelationId;\n\t\t\t\treturn response;\n\t\t\t})\n\t\t\t.catch(async (error) => {\n\t\t\t\t// Get the server epoch from error in case we don't have it as if undefined we won't be able\n\t\t\t\t// to mark it as epoch error.\n\t\t\t\tif (epochFromResponse === undefined) {\n\t\t\t\t\tepochFromResponse = (error as IOdspError).serverEpoch;\n\t\t\t\t}\n\t\t\t\tawait this.checkForEpochError(error, epochFromResponse, fetchType);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If the error is about location redirection, then we need to generate new resolved url with correct\n\t\t\t\t// location info.\n\t\t\t\tif (\n\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t\t) {\n\t\t\t\t\tconst redirectLocation = (error as IOdspErrorAugmentations).redirectLocation;\n\t\t\t\t\tif (redirectLocation !== undefined) {\n\t\t\t\t\t\tconst redirectUrl: IOdspResolvedUrl = patchOdspResolvedUrl(\n\t\t\t\t\t\t\tthis.fileEntry.resolvedUrl,\n\t\t\t\t\t\t\tredirectLocation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst locationRedirectionError = new LocationRedirectionError(\n\t\t\t\t\t\t\terror.message,\n\t\t\t\t\t\t\tredirectUrl,\n\t\t\t\t\t\t\t{ driverVersion, redirectLocation },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlocationRedirectionError.addTelemetryProperties(error.getTelemetryProperties());\n\t\t\t\t\t\tthrow locationRedirectionError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconst fluidError = normalizeError(error, {\n\t\t\t\t\tprops: { XRequestStatsHeader: clientCorrelationId },\n\t\t\t\t});\n\t\t\t\tthrow fluidError;\n\t\t\t});\n\t}\n\n\t/**\n\t * Api to fetch the response as it is for given request.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchArray(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<ArrayBuffer>> {\n\t\treturn this.fetchCore<ArrayBuffer>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchArray,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate addEpochInRequest(\n\t\tfetchOptions: RequestInit,\n\t\taddInBody: boolean,\n\t\tclientCorrelationId: string,\n\t): void {\n\t\tconst isClpCompliantApp = getOdspResolvedUrl(this.fileEntry.resolvedUrl).isClpCompliantApp;\n\t\tif (addInBody) {\n\t\t\tconst headers: { [key: string]: string } = {};\n\t\t\theaders[\"X-RequestStats\"] = clientCorrelationId;\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\theaders[\"x-fluid-epoch\"] = this.fluidEpoch;\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\theaders[ClpCompliantAppHeader.isClpCompliantApp] = isClpCompliantApp.toString();\n\t\t\t}\n\t\t\tthis.addParamInBody(fetchOptions, headers);\n\t\t} else {\n\t\t\tconst addHeader = (key: string, val: string): void => {\n\t\t\t\tfetchOptions.headers = {\n\t\t\t\t\t...fetchOptions.headers,\n\t\t\t\t};\n\t\t\t\tassert(\n\t\t\t\t\tfetchOptions.headers !== undefined,\n\t\t\t\t\t0x282 /* \"Headers should be present now\" */,\n\t\t\t\t);\n\t\t\t\tfetchOptions.headers[key] = val;\n\t\t\t};\n\t\t\taddHeader(\"X-RequestStats\", clientCorrelationId);\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\taddHeader(\"x-fluid-epoch\", this.fluidEpoch);\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\taddHeader(ClpCompliantAppHeader.isClpCompliantApp, isClpCompliantApp.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addParamInBody(fetchOptions: RequestInit, headers: { [key: string]: string }): void {\n\t\t// We use multi part form request for post body where we want to use this.\n\t\t// So extract the form boundary to mark the end of form.\n\t\tconst body = fetchOptions.body;\n\t\tassert(typeof body === \"string\", 0x21d /* \"body is not string\" */);\n\t\tconst splitBody = body.split(\"\\r\\n\");\n\t\tconst firstLine = splitBody.shift();\n\t\tassert(firstLine?.startsWith(\"--\") === true, 0x21e /* \"improper boundary format\" */);\n\t\tconst formParams = [firstLine];\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tformParams.push(`${key}: ${value}`);\n\t\t}\n\t\tfor (const value of splitBody) {\n\t\t\tformParams.push(value);\n\t\t}\n\t\tfetchOptions.body = formParams.join(\"\\r\\n\");\n\t}\n\n\tprivate formatClientCorrelationId(fetchReason?: string): string {\n\t\tconst items: string[] = [\n\t\t\t`driverId=${this.driverId}`,\n\t\t\t`RequestNumber=${this.networkCallNumber++}`,\n\t\t\t`driverVersion=${driverVersion}`,\n\t\t\t`isSummarizer=${this.clientIsSummarizer}`,\n\t\t];\n\t\tif (fetchReason !== undefined) {\n\t\t\titems.push(`fetchReason=${fetchReason}`);\n\t\t}\n\t\treturn items.join(\", \");\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tconst error = this.checkForEpochErrorCore(epochFromResponse);\n\t\tif (error !== undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (epochFromResponse !== undefined && this._fluidEpoch === undefined) {\n\t\t\tthis.setEpoch(epochFromResponse, fromCache, fetchType);\n\t\t}\n\t}\n\n\tprivate async checkForEpochError(\n\t\terror: unknown,\n\t\tepochFromResponse: string | null | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): Promise<void> {\n\t\tif (isFluidError(error) && error.errorType === OdspErrorTypes.fileOverwrittenInStorage) {\n\t\t\tconst epochError = this.checkForEpochErrorCore(epochFromResponse);\n\t\t\tif (epochError !== undefined) {\n\t\t\t\tepochError.addTelemetryProperties({\n\t\t\t\t\tfromCache,\n\t\t\t\t\tfetchType,\n\t\t\t\t});\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"fileOverwrittenInStorage\" }, epochError);\n\t\t\t\t// If the epoch mismatches, then clear all entries for such file entry from cache.\n\t\t\t\tawait this.removeEntries();\n\t\t\t\tthrow epochError;\n\t\t\t}\n\t\t\t// If it was categorized as epoch error but the epoch returned in response matches with the client epoch\n\t\t\t// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling\n\t\t\t// time is 1s.\n\t\t\tconst newError = wrapError(error, (message: string) => {\n\t\t\t\treturn new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {\n\t\t\t\t\t[Odsp409Error]: true,\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t});\n\t\t\tthrow newError;\n\t\t}\n\t}\n\n\tprivate checkForEpochErrorCore(\n\t\tepochFromResponse: string | null | undefined,\n\t): NonRetryableError<\"fileOverwrittenInStorage\"> | undefined {\n\t\t// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest\n\t\t// initializes this value. Sometimes response does not contain epoch as it is still in\n\t\t// implementation phase at server side. In that case also, don't compare it with our epoch value.\n\t\tif (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {\n\t\t\t// This is similar in nature to how fluidEpochMismatchError (409) is handled.\n\t\t\t// Difference - client detected mismatch, instead of server detecting it.\n\t\t\treturn new NonRetryableError(\"Epoch mismatch\", OdspErrorTypes.fileOverwrittenInStorage, {\n\t\t\t\tdriverVersion,\n\t\t\t\tserverEpoch: epochFromResponse,\n\t\t\t\tclientEpoch: this.fluidEpoch,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate fileEntryFromEntry(entry: IEntry): ICacheEntry {\n\t\treturn { ...entry, file: this.fileEntry };\n\t}\n}\n\nexport class EpochTrackerWithRedemption extends EpochTracker {\n\tprivate readonly treesLatestDeferral = new Deferred<void>();\n\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper(cache, fileEntry, logger, clientIsSummarizer);\n\t\t// Handles the rejected promise within treesLatestDeferral.\n\t\tthis.treesLatestDeferral.promise.catch(() => {});\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchType,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tsuper.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);\n\n\t\t// Any successful call means we have access to a file, i.e. any redemption that was required already happened.\n\t\t// That covers cases of \"treesLatest\" as well as \"getVersions\" or \"createFile\" - all the ways we can start\n\t\t// exploring a file.\n\t\tthis.treesLatestDeferral.resolve();\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\tlet result = super.get(entry);\n\n\t\t// equivalence of what happens in fetchAndParseAsJSON()\n\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\tresult = result\n\t\t\t\t.then((value) => {\n\t\t\t\t\t// If there is nothing in cache, we need to wait for network call to complete (and do redemption)\n\t\t\t\t\t// Otherwise file was redeemed in prior session, so if joinSession failed, we should not retry\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tthis.treesLatestDeferral.resolve();\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\t\treturn value;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\t// Optimize the flow if we know that treesLatestDeferral was already completed by the timer we started\n\t\t// joinSession call. If we did - there is no reason to repeat the call as it will fail with same error.\n\t\tconst completed = this.treesLatestDeferral.isCompleted;\n\n\t\ttry {\n\t\t\treturn await super.fetchAndParseAsJSON<T>(\n\t\t\t\turl,\n\t\t\t\tfetchOptions,\n\t\t\t\tfetchType,\n\t\t\t\taddInBody,\n\t\t\t\tfetchReason,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\t// Only handling here treesLatest. If createFile failed, we should never try to do joinSession.\n\t\t\t// Similar, if getVersions failed, we should not do any further storage calls.\n\t\t\t// So treesLatest is the only call that can have parallel joinSession request.\n\t\t\tif (fetchType === \"treesLatest\") {\n\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfetchType !== \"joinSession\" ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode < 401 ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode > 404 ||\n\t\t\t\tcompleted\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\t// It is joinSession failing with 401..404 error\n\t\t// Repeat after waiting for treeLatest succeeding (or fail if it failed).\n\t\t// No special handling after first call - if file has been deleted, then it's game over.\n\n\t\t// Ensure we have some safety here - we do not want to deadlock if we got logic somewhere wrong.\n\t\t// If we waited too long, we will log error event and proceed with call.\n\t\t// It may result in failure for user, but refreshing document would address it.\n\t\t// Thus we use rather long timeout (not to get these failures as much as possible), but not large enough\n\t\t// to unblock the process.\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{ eventName: \"JoinSessionSyncWait\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst timeoutRes = 51; // anything will work here\n\t\t\t\tlet timer: ReturnType<typeof setTimeout>;\n\t\t\t\tconst timeoutP = new Promise<number>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tresolve(timeoutRes);\n\t\t\t\t\t}, 15000);\n\t\t\t\t});\n\t\t\t\tconst res = await Promise.race([\n\t\t\t\t\ttimeoutP,\n\t\t\t\t\t// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)\n\t\t\t\t\tthis.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),\n\t\t\t\t]);\n\t\t\t\tif (res === timeoutRes) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t\treturn super.fetchAndParseAsJSON<T>(url, fetchOptions, fetchType, addInBody);\n\t}\n}\n\n/**\n * @legacy\n * @beta\n */\nexport interface ICacheAndTracker {\n\tcache: IOdspCache;\n\tepochTracker: EpochTracker;\n}\n\nexport function createOdspCacheAndTracker(\n\tpersistedCacheArg: IPersistedCache,\n\tnonpersistentCache: INonPersistentCache,\n\tfileEntry: IFileEntry,\n\tlogger: ITelemetryLoggerExt,\n\tclientIsSummarizer?: boolean,\n): ICacheAndTracker {\n\tconst epochTracker = new EpochTrackerWithRedemption(\n\t\tpersistedCacheArg,\n\t\tfileEntry,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t);\n\treturn {\n\t\tcache: {\n\t\t\t...nonpersistentCache,\n\t\t\tpersistedCache: epochTracker,\n\t\t},\n\t\tepochTracker,\n\t};\n}\n"]}
1
+ {"version":3,"file":"epochTracker.js","sourceRoot":"","sources":["../src/epochTracker.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAAuE;AAOvE,oEAM+C;AAC/C,+EAO0D;AAC1D,uEAOkD;AAElD,+BAAkC;AAElC,iDAA2F;AAC3F,6DAA6D;AAE7D,6EAAoE;AACpE,iDAMwB;AACxB,2DAAkE;AA0BrD,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,YAAY;IAQxB,YACoB,KAAsB,EACtB,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;QAH5B,UAAK,GAAL,KAAK,CAAiB;QACtB,cAAS,GAAT,SAAS,CAAY;QACrB,WAAM,GA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oC,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE;gBAChD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBACvB,OAAO,CAAC,UAAU,CAAC,CAAC;gBACrB,CAAC,EAAE,KAAK,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;gBAC9B,QAAQ;gBACR,kFAAkF;gBAClF,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;aACnE,CAAC,CAAC;YACH,IAAI,GAAG,KAAK,UAAU,EAAE,CAAC;gBACxB,KAAK,CAAC,MAAM,EAAE,CAAC;YAChB,CAAC;QACF,CAAC,EACD,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAC7C,CAAC;QACF,OAAO,KAAK,CAAC,mBAAmB,CAAI,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAC9E,CAAC;CACD;AA5HD,gEA4HC;AAWD,SAAgB,yBAAyB,CACxC,iBAAkC,EAClC,kBAAuC,EACvC,SAAqB,EACrB,MAA2B,EAC3B,kBAA4B;IAE5B,MAAM,YAAY,GAAG,IAAI,0BAA0B,CAClD,iBAAiB,EACjB,SAAS,EACT,MAAM,EACN,kBAAkB,CAClB,CAAC;IACF,OAAO;QACN,KAAK,EAAE;YACN,GAAG,kBAAkB;YACrB,cAAc,EAAE,YAAY;SAC5B;QACD,YAAY;KACZ,CAAC;AACH,CAAC;AApBD,8DAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tLocationRedirectionError,\n\tmaximumCacheDurationMs,\n\tNonRetryableError,\n\tRateLimiter,\n\tThrottlingError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspError,\n\ttype IOdspErrorAugmentations,\n\ttype IOdspResolvedUrl,\n\tOdspErrorTypes,\n\tsnapshotKey,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n\tisFluidError,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { v4 as uuid } from \"uuid\";\n\nimport { type IVersionedValueWithEpoch, persistedCacheValueVersion } from \"./contracts.js\";\nimport { ClpCompliantAppHeader } from \"./contractsPublic.js\";\nimport type { INonPersistentCache, IOdspCache, IPersistedFileCache } from \"./odspCache.js\";\nimport { patchOdspResolvedUrl } from \"./odspLocationRedirection.js\";\nimport {\n\ttype IOdspResponse,\n\tfetchAndParseAsJSONHelper,\n\tfetchArray,\n\tfetchHelper,\n\tgetOdspResolvedUrl,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * @legacy\n * @beta\n */\nexport type FetchType =\n\t| \"blob\"\n\t| \"createBlob\"\n\t| \"createFile\"\n\t| \"joinSession\"\n\t| \"ops\"\n\t| \"test\"\n\t| \"snapshotTree\"\n\t| \"treesLatest\"\n\t| \"uploadSummary\"\n\t| \"push\"\n\t| \"versions\"\n\t| \"renameFile\";\n\n/**\n * @legacy\n * @beta\n */\nexport type FetchTypeInternal = FetchType | \"cache\";\n\nexport const Odsp409Error = \"Odsp409Error\";\n\n/**\n * In ODSP, the concept of \"epoch\" refers to binary updates to files. For example, this might include using\n * version restore, or if the user downloads a Fluid file and then uploads it again. These result in the epoch\n * value being incremented.\n *\n * The implications of these binary updates is that the Fluid state is disrupted: the sequence number might\n * go backwards, the data might be inconsistent with the latest state of collaboration, etc. As a result, it's\n * not safe to continue collaboration across an epoch change. We need to detect these epoch changes and\n * error out from the collaboration.\n *\n * This class is a wrapper around fetch calls. It adds epoch to the request made so that the\n * server can match it with its epoch value in order to match the version.\n * It also validates the epoch value received in response of fetch calls. If the epoch does not match,\n * then it also clears all the cached entries for the given container.\n * @legacy\n * @beta\n */\nexport class EpochTracker implements IPersistedFileCache {\n\tprivate _fluidEpoch: string | undefined;\n\n\tprivate readonly snapshotCacheExpiryTimeoutMs: number;\n\tpublic readonly rateLimiter: RateLimiter;\n\tprivate readonly driverId = uuid();\n\t// This tracks the request number made by the driver instance.\n\tprivate networkCallNumber = 1;\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\t// Limits the max number of concurrent requests to 24.\n\t\tthis.rateLimiter = new RateLimiter(24);\n\n\t\t// Matches the TestOverride logic for the policy defined in odspDocumentStorageServiceBase.ts\n\t\tthis.snapshotCacheExpiryTimeoutMs = loggerToMonitoringContext(logger).config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.TestOverride.DisableSnapshotCache\",\n\t\t)\n\t\t\t? 0\n\t\t\t: maximumCacheDurationMs;\n\t}\n\n\t// public for UT purposes only!\n\tpublic setEpoch(epoch: string, fromCache: boolean, fetchType: FetchTypeInternal): void {\n\t\tassert(this._fluidEpoch === undefined, 0x1db /* \"epoch exists\" */);\n\t\tthis._fluidEpoch = epoch;\n\n\t\tthis.logger.sendTelemetryEvent({\n\t\t\teventName: \"EpochLearnedFirstTime\",\n\t\t\tepoch,\n\t\t\tfetchType,\n\t\t\tfromCache,\n\t\t});\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\ttry {\n\t\t\t// Return undefined so that the ops/snapshots are grabbed from the server instead of the cache\n\t\t\tconst value = (await this.cache.get(\n\t\t\t\tthis.fileEntryFromEntry(entry),\n\t\t\t)) as IVersionedValueWithEpoch;\n\t\t\t// Version mismatch between what the runtime expects and what it recieved.\n\t\t\t// The cached value should not be used\n\t\t\tif (value === undefined || value.version !== persistedCacheValueVersion) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tassert(value.fluidEpoch !== undefined, 0x1dc /* \"all entries have to have epoch\" */);\n\t\t\tif (this._fluidEpoch === undefined) {\n\t\t\t\tthis.setEpoch(value.fluidEpoch, true, \"cache\");\n\t\t\t\t// Epoch mismatch, the cached value is considerably different from what the current state of\n\t\t\t\t// the runtime and should not be used\n\t\t\t} else if (this._fluidEpoch !== value.fluidEpoch) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\t// Expire the cached snapshot if it's older than snapshotCacheExpiryTimeoutMs and immediately\n\t\t\t// expire all old caches that do not have cacheEntryTime\n\t\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\tconst cacheTime = value.value?.cacheEntryTime;\n\t\t\t\tconst currentTime = Date.now();\n\t\t\t\tif (\n\t\t\t\t\tcacheTime === undefined ||\n\t\t\t\t\tcurrentTime - cacheTime >= this.snapshotCacheExpiryTimeoutMs\n\t\t\t\t) {\n\t\t\t\t\tthis.logger.sendTelemetryEvent({\n\t\t\t\t\t\teventName: \"odspVersionsCacheExpired\",\n\t\t\t\t\t\tduration: currentTime - cacheTime,\n\t\t\t\t\t\tmaxCacheAgeMs: this.snapshotCacheExpiryTimeoutMs,\n\t\t\t\t\t});\n\t\t\t\t\tawait this.removeEntries();\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value.value;\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cacheFetchError\", type: entry.type }, error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\t// TODO: take a stronger type or `unknown`\n\t// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any\n\tpublic async put(entry: IEntry, value: any): Promise<void> {\n\t\tassert(this._fluidEpoch !== undefined, 0x1dd /* \"no epoch\" */);\n\t\t// For snapshots, the value should have the cacheEntryTime.\n\t\t// This will be used to expire snapshots older than snapshotCacheExpiryTimeoutMs.\n\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tvalue.cacheEntryTime = value.cacheEntryTime ?? Date.now();\n\t\t}\n\t\tconst data: IVersionedValueWithEpoch = {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tvalue,\n\t\t\tversion: persistedCacheValueVersion,\n\t\t\tfluidEpoch: this._fluidEpoch,\n\t\t};\n\t\treturn this.cache.put(this.fileEntryFromEntry(entry), data).catch((error) => {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"cachePutError\", type: entry.type }, error);\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tpublic async removeEntries(): Promise<void> {\n\t\ttry {\n\t\t\treturn await this.cache.removeEntries(this.fileEntry);\n\t\t} catch (error) {\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"removeCacheEntries\" }, error);\n\t\t}\n\t}\n\n\tpublic get fluidEpoch(): string | undefined {\n\t\treturn this._fluidEpoch;\n\t}\n\n\tpublic async validateEpoch(epoch: string | undefined, fetchType: FetchType): Promise<void> {\n\t\tassert(epoch !== undefined, 0x584 /* response should contain epoch */);\n\t\ttry {\n\t\t\tthis.validateEpochFromResponse(epoch, fetchType);\n\t\t} catch (error) {\n\t\t\tawait this.checkForEpochError(error, epoch, fetchType);\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\treturn this.fetchCore<T>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchAndParseAsJSONHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\t/**\n\t * Api to fetch the response for given request and parse it as json.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetch(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<Response>> {\n\t\treturn this.fetchCore<Response>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchHelper,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate async fetchCore<T>(\n\t\turl: string,\n\t\tfetchOptions: RequestInit,\n\t\tfetcher: (url: string, fetchOptions: RequestInit) => Promise<IOdspResponse<T>>,\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\tconst clientCorrelationId = this.formatClientCorrelationId(fetchReason);\n\t\t// Add epoch in fetch request.\n\t\tthis.addEpochInRequest(fetchOptions, addInBody, clientCorrelationId);\n\t\tlet epochFromResponse: string | undefined;\n\t\treturn this.rateLimiter\n\t\t\t.schedule(async () => fetcher(url, fetchOptions))\n\t\t\t.then((response) => {\n\t\t\t\tepochFromResponse = response.headers.get(\"x-fluid-epoch\");\n\t\t\t\tthis.validateEpochFromResponse(epochFromResponse, fetchType);\n\t\t\t\tresponse.propsToLog.XRequestStatsHeader = clientCorrelationId;\n\t\t\t\treturn response;\n\t\t\t})\n\t\t\t.catch(async (error) => {\n\t\t\t\t// Get the server epoch from error in case we don't have it as if undefined we won't be able\n\t\t\t\t// to mark it as epoch error.\n\t\t\t\tif (epochFromResponse === undefined) {\n\t\t\t\t\tepochFromResponse = (error as IOdspError).serverEpoch;\n\t\t\t\t}\n\t\t\t\tawait this.checkForEpochError(error, epochFromResponse, fetchType);\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// If the error is about location redirection, then we need to generate new resolved url with correct\n\t\t\t\t// location info.\n\t\t\t\tif (\n\t\t\t\t\tisFluidError(error) &&\n\t\t\t\t\terror.errorType === OdspErrorTypes.fileNotFoundOrAccessDeniedError\n\t\t\t\t) {\n\t\t\t\t\tconst redirectLocation = (error as IOdspErrorAugmentations).redirectLocation;\n\t\t\t\t\tif (redirectLocation !== undefined) {\n\t\t\t\t\t\tconst redirectUrl: IOdspResolvedUrl = patchOdspResolvedUrl(\n\t\t\t\t\t\t\tthis.fileEntry.resolvedUrl,\n\t\t\t\t\t\t\tredirectLocation,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst locationRedirectionError = new LocationRedirectionError(\n\t\t\t\t\t\t\terror.message,\n\t\t\t\t\t\t\tredirectUrl,\n\t\t\t\t\t\t\t{ driverVersion, redirectLocation },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tlocationRedirectionError.addTelemetryProperties(error.getTelemetryProperties());\n\t\t\t\t\t\tthrow locationRedirectionError;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tconst fluidError = normalizeError(error, {\n\t\t\t\t\tprops: { XRequestStatsHeader: clientCorrelationId },\n\t\t\t\t});\n\t\t\t\tthrow fluidError;\n\t\t\t});\n\t}\n\n\t/**\n\t * Api to fetch the response as it is for given request.\n\t * @param url - url of the request\n\t * @param fetchOptions - fetch options for request containing body, headers etc.\n\t * @param fetchType - method for which fetch is called.\n\t * @param addInBody - Pass True if caller wants to add epoch in post body.\n\t * @param fetchReason - fetch reason to add to the request.\n\t */\n\tpublic async fetchArray(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<ArrayBuffer>> {\n\t\treturn this.fetchCore<ArrayBuffer>(\n\t\t\turl,\n\t\t\tfetchOptions,\n\t\t\tfetchArray,\n\t\t\tfetchType,\n\t\t\taddInBody,\n\t\t\tfetchReason,\n\t\t);\n\t}\n\n\tprivate addEpochInRequest(\n\t\tfetchOptions: RequestInit,\n\t\taddInBody: boolean,\n\t\tclientCorrelationId: string,\n\t): void {\n\t\tconst isClpCompliantApp = getOdspResolvedUrl(this.fileEntry.resolvedUrl).isClpCompliantApp;\n\t\tif (addInBody) {\n\t\t\tconst headers: { [key: string]: string } = {};\n\t\t\theaders[\"X-RequestStats\"] = clientCorrelationId;\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\theaders[\"x-fluid-epoch\"] = this.fluidEpoch;\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\theaders[ClpCompliantAppHeader.isClpCompliantApp] = isClpCompliantApp.toString();\n\t\t\t}\n\t\t\tthis.addParamInBody(fetchOptions, headers);\n\t\t} else {\n\t\t\tconst addHeader = (key: string, val: string): void => {\n\t\t\t\tfetchOptions.headers = {\n\t\t\t\t\t...fetchOptions.headers,\n\t\t\t\t};\n\t\t\t\tassert(\n\t\t\t\t\tfetchOptions.headers !== undefined,\n\t\t\t\t\t0x282 /* \"Headers should be present now\" */,\n\t\t\t\t);\n\t\t\t\tfetchOptions.headers[key] = val;\n\t\t\t};\n\t\t\taddHeader(\"X-RequestStats\", clientCorrelationId);\n\t\t\tif (this.fluidEpoch !== undefined) {\n\t\t\t\taddHeader(\"x-fluid-epoch\", this.fluidEpoch);\n\t\t\t}\n\t\t\tif (isClpCompliantApp) {\n\t\t\t\taddHeader(ClpCompliantAppHeader.isClpCompliantApp, isClpCompliantApp.toString());\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate addParamInBody(fetchOptions: RequestInit, headers: { [key: string]: string }): void {\n\t\t// We use multi part form request for post body where we want to use this.\n\t\t// So extract the form boundary to mark the end of form.\n\t\tconst body = fetchOptions.body;\n\t\tassert(typeof body === \"string\", 0x21d /* \"body is not string\" */);\n\t\tconst splitBody = body.split(\"\\r\\n\");\n\t\tconst firstLine = splitBody.shift();\n\t\tassert(firstLine?.startsWith(\"--\") === true, 0x21e /* \"improper boundary format\" */);\n\t\tconst formParams = [firstLine];\n\t\tfor (const [key, value] of Object.entries(headers)) {\n\t\t\tformParams.push(`${key}: ${value}`);\n\t\t}\n\t\tfor (const value of splitBody) {\n\t\t\tformParams.push(value);\n\t\t}\n\t\tfetchOptions.body = formParams.join(\"\\r\\n\");\n\t}\n\n\tprivate formatClientCorrelationId(fetchReason?: string): string {\n\t\tconst items: string[] = [\n\t\t\t`driverId=${this.driverId}`,\n\t\t\t`RequestNumber=${this.networkCallNumber++}`,\n\t\t\t`driverVersion=${driverVersion}`,\n\t\t\t`isSummarizer=${this.clientIsSummarizer}`,\n\t\t];\n\t\tif (fetchReason !== undefined) {\n\t\t\titems.push(`fetchReason=${fetchReason}`);\n\t\t}\n\t\treturn items.join(\", \");\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tconst error = this.checkForEpochErrorCore(epochFromResponse);\n\t\tif (error !== undefined) {\n\t\t\tthrow error;\n\t\t}\n\t\tif (epochFromResponse !== undefined && this._fluidEpoch === undefined) {\n\t\t\tthis.setEpoch(epochFromResponse, fromCache, fetchType);\n\t\t}\n\t}\n\n\tprivate async checkForEpochError(\n\t\terror: unknown,\n\t\tepochFromResponse: string | null | undefined,\n\t\tfetchType: FetchTypeInternal,\n\t\tfromCache: boolean = false,\n\t): Promise<void> {\n\t\tif (isFluidError(error) && error.errorType === OdspErrorTypes.fileOverwrittenInStorage) {\n\t\t\tconst epochError = this.checkForEpochErrorCore(epochFromResponse);\n\t\t\tif (epochError !== undefined) {\n\t\t\t\tepochError.addTelemetryProperties({\n\t\t\t\t\tfromCache,\n\t\t\t\t\tfetchType,\n\t\t\t\t});\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"fileOverwrittenInStorage\" }, epochError);\n\t\t\t\t// If the epoch mismatches, then clear all entries for such file entry from cache.\n\t\t\t\tawait this.removeEntries();\n\t\t\t\tthrow epochError;\n\t\t\t}\n\t\t\t// If it was categorized as epoch error but the epoch returned in response matches with the client epoch\n\t\t\t// then it was coherency 409, so rethrow it as throttling error so that it can retried. Default throttling\n\t\t\t// time is 1s.\n\t\t\tconst newError = wrapError(error, (message: string) => {\n\t\t\t\treturn new ThrottlingError(`Coherency 409: ${message}`, 1 /* retryAfterSeconds */, {\n\t\t\t\t\t[Odsp409Error]: true,\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t});\n\t\t\tthrow newError;\n\t\t}\n\t}\n\n\tprivate checkForEpochErrorCore(\n\t\tepochFromResponse: string | null | undefined,\n\t): NonRetryableError<\"fileOverwrittenInStorage\"> | undefined {\n\t\t// If epoch is undefined, then don't compare it because initially for createNew or TreesLatest\n\t\t// initializes this value. Sometimes response does not contain epoch as it is still in\n\t\t// implementation phase at server side. In that case also, don't compare it with our epoch value.\n\t\tif (this.fluidEpoch && epochFromResponse && this.fluidEpoch !== epochFromResponse) {\n\t\t\t// This is similar in nature to how fluidEpochMismatchError (409) is handled.\n\t\t\t// Difference - client detected mismatch, instead of server detecting it.\n\t\t\treturn new NonRetryableError(\"Epoch mismatch\", OdspErrorTypes.fileOverwrittenInStorage, {\n\t\t\t\tdriverVersion,\n\t\t\t\tserverEpoch: epochFromResponse,\n\t\t\t\tclientEpoch: this.fluidEpoch,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate fileEntryFromEntry(entry: IEntry): ICacheEntry {\n\t\treturn { ...entry, file: this.fileEntry };\n\t}\n}\n\nexport class EpochTrackerWithRedemption extends EpochTracker {\n\tprivate readonly treesLatestDeferral = new Deferred<void>();\n\n\tconstructor(\n\t\tprotected readonly cache: IPersistedCache,\n\t\tprotected readonly fileEntry: IFileEntry,\n\t\tprotected readonly logger: ITelemetryLoggerExt,\n\t\tprotected readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper(cache, fileEntry, logger, clientIsSummarizer);\n\t\t// Handles the rejected promise within treesLatestDeferral.\n\t\tthis.treesLatestDeferral.promise.catch(() => {});\n\t}\n\n\tprotected validateEpochFromResponse(\n\t\tepochFromResponse: string | undefined,\n\t\tfetchType: FetchType,\n\t\tfromCache: boolean = false,\n\t): void {\n\t\tsuper.validateEpochFromResponse(epochFromResponse, fetchType, fromCache);\n\n\t\t// Any successful call means we have access to a file, i.e. any redemption that was required already happened.\n\t\t// That covers cases of \"treesLatest\" as well as \"getVersions\" or \"createFile\" - all the ways we can start\n\t\t// exploring a file.\n\t\tthis.treesLatestDeferral.resolve();\n\t}\n\n\t// TODO: return a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tpublic async get(entry: IEntry): Promise<any> {\n\t\tlet result = super.get(entry);\n\n\t\t// equivalence of what happens in fetchAndParseAsJSON()\n\t\tif (entry.type === snapshotKey || entry.type === snapshotWithLoadingGroupIdKey) {\n\t\t\tresult = result\n\t\t\t\t.then((value) => {\n\t\t\t\t\t// If there is nothing in cache, we need to wait for network call to complete (and do redemption)\n\t\t\t\t\t// Otherwise file was redeemed in prior session, so if joinSession failed, we should not retry\n\t\t\t\t\tif (value !== undefined) {\n\t\t\t\t\t\tthis.treesLatestDeferral.resolve();\n\t\t\t\t\t}\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\t\t\treturn value;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\t\treturn result;\n\t}\n\n\tpublic async fetchAndParseAsJSON<T>(\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: RequestInit },\n\t\tfetchType: FetchType,\n\t\taddInBody: boolean = false,\n\t\tfetchReason?: string,\n\t): Promise<IOdspResponse<T>> {\n\t\t// Optimize the flow if we know that treesLatestDeferral was already completed by the timer we started\n\t\t// joinSession call. If we did - there is no reason to repeat the call as it will fail with same error.\n\t\tconst completed = this.treesLatestDeferral.isCompleted;\n\n\t\ttry {\n\t\t\treturn await super.fetchAndParseAsJSON<T>(\n\t\t\t\turl,\n\t\t\t\tfetchOptions,\n\t\t\t\tfetchType,\n\t\t\t\taddInBody,\n\t\t\t\tfetchReason,\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\t// Only handling here treesLatest. If createFile failed, we should never try to do joinSession.\n\t\t\t// Similar, if getVersions failed, we should not do any further storage calls.\n\t\t\t// So treesLatest is the only call that can have parallel joinSession request.\n\t\t\tif (fetchType === \"treesLatest\") {\n\t\t\t\tthis.treesLatestDeferral.reject(error);\n\t\t\t}\n\t\t\tif (\n\t\t\t\tfetchType !== \"joinSession\" ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode < 401 ||\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.statusCode > 404 ||\n\t\t\t\tcompleted\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\n\t\t// It is joinSession failing with 401..404 error\n\t\t// Repeat after waiting for treeLatest succeeding (or fail if it failed).\n\t\t// No special handling after first call - if file has been deleted, then it's game over.\n\n\t\t// Ensure we have some safety here - we do not want to deadlock if we got logic somewhere wrong.\n\t\t// If we waited too long, we will log error event and proceed with call.\n\t\t// It may result in failure for user, but refreshing document would address it.\n\t\t// Thus we use rather long timeout (not to get these failures as much as possible), but not large enough\n\t\t// to unblock the process.\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{ eventName: \"JoinSessionSyncWait\" },\n\t\t\tasync (event) => {\n\t\t\t\tconst timeoutRes = 51; // anything will work here\n\t\t\t\tlet timer: ReturnType<typeof setTimeout>;\n\t\t\t\tconst timeoutP = new Promise<number>((resolve) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\tresolve(timeoutRes);\n\t\t\t\t\t}, 15000);\n\t\t\t\t});\n\t\t\t\tconst res = await Promise.race([\n\t\t\t\t\ttimeoutP,\n\t\t\t\t\t// cancel timeout to unblock UTs (otherwise Node process does not exit for 15 sec)\n\t\t\t\t\tthis.treesLatestDeferral.promise.finally(() => clearTimeout(timer)),\n\t\t\t\t]);\n\t\t\t\tif (res === timeoutRes) {\n\t\t\t\t\tevent.cancel();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ start: true, end: true, cancel: \"generic\" },\n\t\t);\n\t\treturn super.fetchAndParseAsJSON<T>(url, fetchOptions, fetchType, addInBody);\n\t}\n}\n\n/**\n * @legacy\n * @beta\n */\nexport interface ICacheAndTracker {\n\tcache: IOdspCache;\n\tepochTracker: EpochTracker;\n}\n\nexport function createOdspCacheAndTracker(\n\tpersistedCacheArg: IPersistedCache,\n\tnonpersistentCache: INonPersistentCache,\n\tfileEntry: IFileEntry,\n\tlogger: ITelemetryLoggerExt,\n\tclientIsSummarizer?: boolean,\n): ICacheAndTracker {\n\tconst epochTracker = new EpochTrackerWithRedemption(\n\t\tpersistedCacheArg,\n\t\tfileEntry,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t);\n\treturn {\n\t\tcache: {\n\t\t\t...nonpersistentCache,\n\t\t\tpersistedCache: epochTracker,\n\t\t},\n\t\tepochTracker,\n\t};\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchSnapshot.d.ts","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,6CAA6C,CAAC;AAU5F,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,+BAA+B,EAEpC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,KAAK,mBAAmB,EAIxB,MAAM,0CAA0C,CAAC;AAQlD,OAAO,EACN,KAAK,aAAa,EAElB,KAAK,wBAAwB,EAE7B,MAAM,gBAAgB,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,OAAO,EACN,KAAK,aAAa,EASlB,KAAK,mBAAmB,EACxB,MAAM,gBAAgB,CAAC;AAGxB;;;;GAIG;AACH,oBAAY,yBAAyB;IACpC,IAAI,IAAI;IACR,MAAM,IAAI;IACV,aAAa,IAAI;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAClC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,OAAO,EAC1B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,mBAAmB,EAC3B,kBAAkB,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,GAClE,OAAO,CAAC,SAAS,CAAC,CAkBpB;AAED,wBAAsB,uBAAuB,CAC5C,eAAe,EA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