@fluidframework/odsp-driver 2.53.0 → 2.60.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 (130) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/{odsp-driver.legacy.alpha.api.md → odsp-driver.legacy.beta.api.md} +31 -31
  3. package/dist/checkUrl.d.ts +1 -1
  4. package/dist/checkUrl.js +1 -1
  5. package/dist/checkUrl.js.map +1 -1
  6. package/dist/constants.d.ts +2 -2
  7. package/dist/constants.js +2 -2
  8. package/dist/constants.js.map +1 -1
  9. package/dist/contractsPublic.d.ts +1 -1
  10. package/dist/contractsPublic.js.map +1 -1
  11. package/dist/createOdspCreateContainerRequest.d.ts +1 -1
  12. package/dist/createOdspCreateContainerRequest.js +1 -1
  13. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  14. package/dist/createOdspUrl.d.ts +1 -1
  15. package/dist/createOdspUrl.js +1 -1
  16. package/dist/createOdspUrl.js.map +1 -1
  17. package/dist/epochTracker.d.ts +4 -4
  18. package/dist/epochTracker.js +1 -1
  19. package/dist/epochTracker.js.map +1 -1
  20. package/dist/fetchSnapshot.d.ts +1 -1
  21. package/dist/fetchSnapshot.js +1 -1
  22. package/dist/fetchSnapshot.js.map +1 -1
  23. package/dist/getFileLink.js +1 -1
  24. package/dist/getFileLink.js.map +1 -1
  25. package/dist/odspCache.d.ts +4 -4
  26. package/dist/odspCache.js.map +1 -1
  27. package/dist/odspDocumentService.d.ts.map +1 -1
  28. package/dist/odspDocumentService.js +4 -4
  29. package/dist/odspDocumentService.js.map +1 -1
  30. package/dist/odspDocumentServiceFactory.d.ts +2 -2
  31. package/dist/odspDocumentServiceFactory.js +2 -2
  32. package/dist/odspDocumentServiceFactory.js.map +1 -1
  33. package/dist/odspDocumentServiceFactoryCore.d.ts +1 -1
  34. package/dist/odspDocumentServiceFactoryCore.js +1 -1
  35. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  36. package/dist/odspDriverUrlResolver.d.ts +1 -1
  37. package/dist/odspDriverUrlResolver.js +1 -1
  38. package/dist/odspDriverUrlResolver.js.map +1 -1
  39. package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -2
  40. package/dist/odspDriverUrlResolverForShareLink.js +1 -1
  41. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  42. package/dist/odspFluidFileLink.d.ts +4 -4
  43. package/dist/odspFluidFileLink.js +4 -4
  44. package/dist/odspFluidFileLink.js.map +1 -1
  45. package/dist/odspPublicUtils.d.ts +2 -2
  46. package/dist/odspPublicUtils.js +1 -1
  47. package/dist/odspPublicUtils.js.map +1 -1
  48. package/dist/odspUtils.d.ts +2 -2
  49. package/dist/odspUtils.js +1 -1
  50. package/dist/odspUtils.js.map +1 -1
  51. package/dist/packageVersion.d.ts +1 -1
  52. package/dist/packageVersion.js +1 -1
  53. package/dist/packageVersion.js.map +1 -1
  54. package/dist/prefetchLatestSnapshot.d.ts +1 -1
  55. package/dist/prefetchLatestSnapshot.js +1 -1
  56. package/dist/prefetchLatestSnapshot.js.map +1 -1
  57. package/lib/checkUrl.d.ts +1 -1
  58. package/lib/checkUrl.js +1 -1
  59. package/lib/checkUrl.js.map +1 -1
  60. package/lib/constants.d.ts +2 -2
  61. package/lib/constants.js +2 -2
  62. package/lib/constants.js.map +1 -1
  63. package/lib/contractsPublic.d.ts +1 -1
  64. package/lib/contractsPublic.js.map +1 -1
  65. package/lib/createOdspCreateContainerRequest.d.ts +1 -1
  66. package/lib/createOdspCreateContainerRequest.js +1 -1
  67. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  68. package/lib/createOdspUrl.d.ts +1 -1
  69. package/lib/createOdspUrl.js +1 -1
  70. package/lib/createOdspUrl.js.map +1 -1
  71. package/lib/epochTracker.d.ts +4 -4
  72. package/lib/epochTracker.js +1 -1
  73. package/lib/epochTracker.js.map +1 -1
  74. package/lib/fetchSnapshot.d.ts +1 -1
  75. package/lib/fetchSnapshot.js +1 -1
  76. package/lib/fetchSnapshot.js.map +1 -1
  77. package/lib/getFileLink.js +1 -1
  78. package/lib/getFileLink.js.map +1 -1
  79. package/lib/odspCache.d.ts +4 -4
  80. package/lib/odspCache.js.map +1 -1
  81. package/lib/odspDocumentService.d.ts.map +1 -1
  82. package/lib/odspDocumentService.js +4 -4
  83. package/lib/odspDocumentService.js.map +1 -1
  84. package/lib/odspDocumentServiceFactory.d.ts +2 -2
  85. package/lib/odspDocumentServiceFactory.js +2 -2
  86. package/lib/odspDocumentServiceFactory.js.map +1 -1
  87. package/lib/odspDocumentServiceFactoryCore.d.ts +1 -1
  88. package/lib/odspDocumentServiceFactoryCore.js +1 -1
  89. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  90. package/lib/odspDriverUrlResolver.d.ts +1 -1
  91. package/lib/odspDriverUrlResolver.js +1 -1
  92. package/lib/odspDriverUrlResolver.js.map +1 -1
  93. package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -2
  94. package/lib/odspDriverUrlResolverForShareLink.js +1 -1
  95. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  96. package/lib/odspFluidFileLink.d.ts +4 -4
  97. package/lib/odspFluidFileLink.js +4 -4
  98. package/lib/odspFluidFileLink.js.map +1 -1
  99. package/lib/odspPublicUtils.d.ts +2 -2
  100. package/lib/odspPublicUtils.js +1 -1
  101. package/lib/odspPublicUtils.js.map +1 -1
  102. package/lib/odspUtils.d.ts +2 -2
  103. package/lib/odspUtils.js +1 -1
  104. package/lib/odspUtils.js.map +1 -1
  105. package/lib/packageVersion.d.ts +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/prefetchLatestSnapshot.d.ts +1 -1
  109. package/lib/prefetchLatestSnapshot.js +1 -1
  110. package/lib/prefetchLatestSnapshot.js.map +1 -1
  111. package/package.json +13 -13
  112. package/src/checkUrl.ts +1 -1
  113. package/src/constants.ts +2 -2
  114. package/src/contractsPublic.ts +1 -1
  115. package/src/createOdspCreateContainerRequest.ts +1 -1
  116. package/src/createOdspUrl.ts +1 -1
  117. package/src/epochTracker.ts +4 -4
  118. package/src/fetchSnapshot.ts +1 -1
  119. package/src/getFileLink.ts +1 -1
  120. package/src/odspCache.ts +4 -4
  121. package/src/odspDocumentService.ts +5 -4
  122. package/src/odspDocumentServiceFactory.ts +2 -2
  123. package/src/odspDocumentServiceFactoryCore.ts +1 -1
  124. package/src/odspDriverUrlResolver.ts +1 -1
  125. package/src/odspDriverUrlResolverForShareLink.ts +2 -2
  126. package/src/odspFluidFileLink.ts +4 -4
  127. package/src/odspPublicUtils.ts +2 -2
  128. package/src/odspUtils.ts +2 -2
  129. package/src/packageVersion.ts +1 -1
  130. package/src/prefetchLatestSnapshot.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"odspCache.js","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAON,mBAAmB,GACnB,MAAM,kDAAkD,CAAC;AAiB1D;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAKhC,YAAoC,uBAAuB,IAAI,GAAG,IAAI;QAAlC,yBAAoB,GAApB,oBAAoB,CAAc;QAJrD,UAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;QACpD,wGAAwG;QACvF,uBAAkB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEd,CAAC;IAE1E,KAAK,CAAC,GAAG,CAAC,KAAkB;QAC3B,MAAM,GAAG,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAkB,EAAE,KAAc;QAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,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QACzC,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAC7B,CAAC;IACH,CAAC;CACD;AACD,MAAM,OAAO,oCAAwC,SAAQ,YAAuB;IACnF,YAAY,aAA2C;QACtD,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9E,CAAC;CACD;AAwCD,MAAM,OAAO,kBAAkB;IAA/B;QACiB,qBAAgB,GAAG,IAAI,YAAY,EAGhD,CAAC;QAEY,iBAAY,GAAG,IAAI,YAAY,EAA4B,CAAC;QAE5D,gCAA2B,GAAG,IAAI,YAAY,EAG3D,CAAC;IACL,CAAC;CAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype ICacheEntry,\n\ttype IEntry,\n\ttype IFileEntry,\n\ttype IOdspResolvedUrl,\n\ttype IPersistedCache,\n\ttype ISocketStorageDiscovery,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n/**\n * Similar to IPersistedCache, but exposes cache interface for single file\n * @legacy\n * @alpha\n */\nexport interface IPersistedFileCache {\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tget(entry: IEntry): Promise<any>;\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tput(entry: IEntry, value: any): Promise<void>;\n\tremoveEntries(): Promise<void>;\n}\n\n/**\n * Default local-only implementation of IPersistedCache,\n * used if no persisted cache is provided by the host\n */\nexport class LocalPersistentCache implements IPersistedCache {\n\tprivate readonly cache = new Map<string, unknown>();\n\t// For every document id there will be a single expiration entry inspite of the number of cache entries.\n\tprivate readonly docIdExpirationMap = new Map<string, ReturnType<typeof setTimeout>>();\n\n\tpublic constructor(private readonly snapshotExpiryPolicy = 3600 * 1000) {}\n\n\tasync get(entry: ICacheEntry): Promise<unknown> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\treturn this.cache.get(key);\n\t}\n\n\tasync put(entry: ICacheEntry, value: unknown): Promise<void> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\tthis.cache.set(key, value);\n\t\tthis.updateExpirationEntry(entry.file.docId);\n\t}\n\n\tasync removeEntries(file: IFileEntry): Promise<void> {\n\t\tthis.removeDocIdEntriesFromCache(file.docId);\n\t}\n\n\tprivate removeDocIdEntriesFromCache(docId: string): void[] {\n\t\tthis.removeExpirationEntry(docId);\n\t\treturn [...this.cache]\n\t\t\t.filter(([cachekey]) => {\n\t\t\t\tconst docIdFromKey = cachekey.split(\"_\");\n\t\t\t\tif (docIdFromKey[0] === docId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.map(([cachekey]) => {\n\t\t\t\tthis.cache.delete(cachekey);\n\t\t\t});\n\t}\n\n\tprivate removeExpirationEntry(docId: string): void {\n\t\tconst timeout = this.docIdExpirationMap.get(docId);\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthis.docIdExpirationMap.delete(docId);\n\t\t}\n\t}\n\n\tprivate updateExpirationEntry(docId: string): void {\n\t\tthis.removeExpirationEntry(docId);\n\t\tthis.docIdExpirationMap.set(\n\t\t\tdocId,\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.removeDocIdEntriesFromCache(docId);\n\t\t\t}, this.snapshotExpiryPolicy),\n\t\t);\n\t}\n}\nexport class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCache<string, T> {\n\tconstructor(removeOnError?: (error: unknown) => boolean) {\n\t\tsuper({ expiry: { policy: \"sliding\", durationMs: 3600000 }, removeOnError });\n\t}\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @alpha\n */\nexport interface INonPersistentCache {\n\t/**\n\t * Cache of joined/joining session info\n\t */\n\treadonly sessionJoinCache: PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>;\n\n\t/**\n\t * Cache of resolved/resolving file URLs\n\t */\n\treadonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;\n\n\t/**\n\t * Used to store the snapshot fetch promise if the prefetch has been made using the prefetchLatestSnapshot api.\n\t * This is then used later to look for the promise during the container load.\n\t */\n\treadonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @alpha\n */\nexport interface IOdspCache extends INonPersistentCache {\n\t/**\n\t * Persisted cache - only serializable content is allowed\n\t */\n\treadonly persistedCache: IPersistedFileCache;\n}\n\nexport class NonPersistentCache implements INonPersistentCache {\n\tpublic readonly sessionJoinCache = new PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>();\n\n\tpublic readonly fileUrlCache = new PromiseCache<string, IOdspResolvedUrl>();\n\n\tpublic readonly snapshotPrefetchResultCache = new PromiseCache<\n\t\tstring,\n\t\tIPrefetchSnapshotContents\n\t>();\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IPrefetchSnapshotContents extends ISnapshot {\n\tfluidEpoch: string;\n\tprefetchStartTime: number;\n}\n"]}
1
+ {"version":3,"file":"odspCache.js","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAON,mBAAmB,GACnB,MAAM,kDAAkD,CAAC;AAiB1D;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAKhC,YAAoC,uBAAuB,IAAI,GAAG,IAAI;QAAlC,yBAAoB,GAApB,oBAAoB,CAAc;QAJrD,UAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;QACp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,CAAC,CAAC;QACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC3B,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;IACF,CAAC;IAEO,qBAAqB,CAAC,KAAa;QAC1C,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAC1B,KAAK,EACL,UAAU,CAAC,GAAG,EAAE;YACf,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAC7B,CAAC;IACH,CAAC;CACD;AACD,MAAM,OAAO,oCAAwC,SAAQ,YAAuB;IACnF,YAAY,aAA2C;QACtD,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9E,CAAC;CACD;AAwCD,MAAM,OAAO,kBAAkB;IAA/B;QACiB,qBAAgB,GAAG,IAAI,YAAY,EAGhD,CAAC;QAEY,iBAAY,GAAG,IAAI,YAAY,EAA4B,CAAC;QAE5D,gCAA2B,GAAG,IAAI,YAAY,EAG3D,CAAC;IACL,CAAC;CAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype ICacheEntry,\n\ttype IEntry,\n\ttype IFileEntry,\n\ttype IOdspResolvedUrl,\n\ttype IPersistedCache,\n\ttype ISocketStorageDiscovery,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n/**\n * Similar to IPersistedCache, but exposes cache interface for single file\n * @legacy\n * @beta\n */\nexport interface IPersistedFileCache {\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tget(entry: IEntry): Promise<any>;\n\t// TODO: use a stronger type\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tput(entry: IEntry, value: any): Promise<void>;\n\tremoveEntries(): Promise<void>;\n}\n\n/**\n * Default local-only implementation of IPersistedCache,\n * used if no persisted cache is provided by the host\n */\nexport class LocalPersistentCache implements IPersistedCache {\n\tprivate readonly cache = new Map<string, unknown>();\n\t// For every document id there will be a single expiration entry inspite of the number of cache entries.\n\tprivate readonly docIdExpirationMap = new Map<string, ReturnType<typeof setTimeout>>();\n\n\tpublic constructor(private readonly snapshotExpiryPolicy = 3600 * 1000) {}\n\n\tasync get(entry: ICacheEntry): Promise<unknown> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\treturn this.cache.get(key);\n\t}\n\n\tasync put(entry: ICacheEntry, value: unknown): Promise<void> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\tthis.cache.set(key, value);\n\t\tthis.updateExpirationEntry(entry.file.docId);\n\t}\n\n\tasync removeEntries(file: IFileEntry): Promise<void> {\n\t\tthis.removeDocIdEntriesFromCache(file.docId);\n\t}\n\n\tprivate removeDocIdEntriesFromCache(docId: string): void[] {\n\t\tthis.removeExpirationEntry(docId);\n\t\treturn [...this.cache]\n\t\t\t.filter(([cachekey]) => {\n\t\t\t\tconst docIdFromKey = cachekey.split(\"_\");\n\t\t\t\tif (docIdFromKey[0] === docId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.map(([cachekey]) => {\n\t\t\t\tthis.cache.delete(cachekey);\n\t\t\t});\n\t}\n\n\tprivate removeExpirationEntry(docId: string): void {\n\t\tconst timeout = this.docIdExpirationMap.get(docId);\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthis.docIdExpirationMap.delete(docId);\n\t\t}\n\t}\n\n\tprivate updateExpirationEntry(docId: string): void {\n\t\tthis.removeExpirationEntry(docId);\n\t\tthis.docIdExpirationMap.set(\n\t\t\tdocId,\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.removeDocIdEntriesFromCache(docId);\n\t\t\t}, this.snapshotExpiryPolicy),\n\t\t);\n\t}\n}\nexport class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCache<string, T> {\n\tconstructor(removeOnError?: (error: unknown) => boolean) {\n\t\tsuper({ expiry: { policy: \"sliding\", durationMs: 3600000 }, removeOnError });\n\t}\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @beta\n */\nexport interface INonPersistentCache {\n\t/**\n\t * Cache of joined/joining session info\n\t */\n\treadonly sessionJoinCache: PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>;\n\n\t/**\n\t * Cache of resolved/resolving file URLs\n\t */\n\treadonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;\n\n\t/**\n\t * Used to store the snapshot fetch promise if the prefetch has been made using the prefetchLatestSnapshot api.\n\t * This is then used later to look for the promise during the container load.\n\t */\n\treadonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;\n}\n\n/**\n * Internal cache interface used within driver only\n * @legacy\n * @beta\n */\nexport interface IOdspCache extends INonPersistentCache {\n\t/**\n\t * Persisted cache - only serializable content is allowed\n\t */\n\treadonly persistedCache: IPersistedFileCache;\n}\n\nexport class NonPersistentCache implements INonPersistentCache {\n\tpublic readonly sessionJoinCache = new PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>();\n\n\tpublic readonly fileUrlCache = new PromiseCache<string, IOdspResolvedUrl>();\n\n\tpublic readonly snapshotPrefetchResultCache = new PromiseCache<\n\t\tstring,\n\t\tIPrefetchSnapshotContents\n\t>();\n}\n\n/**\n * @legacy\n * @beta\n */\nexport interface IPrefetchSnapshotContents extends ISnapshot {\n\tfluidEpoch: string;\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CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,SAAS,EACvF,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,YAAY,EAC1B,wBAAwB,CAAC,EAAE,MAAM,EACjC,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAc5B,OAAO,CAAC,cAAc,CAAC,CAA6B;IAEpD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;IAEvC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA4B;IAEvD,OAAO,CAAC,SAAS,CAAC,CAAW;IAE7B;;;;;;;;;;;;;OAaG;IACH,OAAO;IAqCP,IAAW,WAAW,IAAI,YAAY,CAErC;IACD,IAAW,QAAQ,IAAI,wBAAwB,CAE9C;IAED;;;;OAIG;IACU,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IA4BjE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAsC3E;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAiBrF;;;;;OAKG;YACW,yBAAyB;IA6BhC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAerC,SAAS,KAAK,QAAQ,IAAI,QAAQ,GAAG,SAAS,CAgC7C;IAID,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,yBAAyB,EAAE,GAAG,IAAI;CAQ7D"}
@@ -122,10 +122,10 @@ export class OdspDocumentService extends TypedEventEmitter {
122
122
  // Get Ops from storage callback.
123
123
  async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason),
124
124
  // Get cachedOps Callback.
125
- async (from, to) => {
126
- const res = await this.opsCache?.get(from, to);
127
- return res ?? [];
128
- },
125
+ // TODO AB#47218: This condition will be removed when file version can be read from the cache entry for an op.
126
+ this.odspResolvedUrl.fileVersion === undefined
127
+ ? async (from, to) => (await this.opsCache?.get(from, to)) ?? []
128
+ : async () => [],
129
129
  // Ops requestFromSocket Callback.
130
130
  (from, to) => {
131
131
  const currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentService.js","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAmB7D,OAAO,EAGN,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAMlD,OAAO,EACN,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;GAGG;AACH,MAAM,OAAO,mBACZ,SAAQ,iBAAyC;IAYjD;;;;;;;;;;;;;;OAcG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,WAAyB,EACzB,aAA8C;IAC9C,kDAAkD;IAClD,iBAAuF,EACvF,MAA2B,EAC3B,KAAiB,EACjB,UAA6B,EAC7B,YAA0B,EAC1B,wBAAiC,EACjC,kBAA4B;QAE5B,OAAO,IAAI,mBAAmB,CAC7B,kBAAkB,CAAC,WAAW,CAAC,EAC/B,aAAa,EACb,iBAAiB,EACjB,MAAM,EACN,KAAK,EACL,UAAU,EACV,YAAY,EACZ,wBAAwB,EACxB,kBAAkB,CAClB,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,EAAE,KAAK,EAAE,GAAW,EAAE,OAAe,EAAiB,EAAE;gBAC5D,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC;YACnE,CAAC;YACD,IAAI,EAAE,KAAK,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC;YAC9E,MAAM,EAAE,GAAS,EAAE;gBAClB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC3D,CAAC;SACD,EACD,SAAS,EACT,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,gBAAgB,IAAI,IAAI,EACpD,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,IAAI,IAAI,CACnD,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,mHAAmH;IACnH,8EAA8E;IACpE,WAAW,CAAC,GAAgC;QACrD,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YACzD,OAAO;QACR,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tIEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n\tTokenFetchOptions,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\ttype MonitoringContext,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { HostStoragePolicyInternal } from \"./contracts.js\";\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport type { IOdspCache } from \"./odspCache.js\";\nimport type { OdspDelayLoadedDeltaStream } from \"./odspDelayLoadedDeltaStream.js\";\nimport {\n\tOdspDeltaStorageService,\n\tOdspDeltaStorageWithCache,\n} from \"./odspDeltaStorageService.js\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager.js\";\nimport { hasOdcOrigin } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { OpsCache } from \"./opsCaching.js\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter.js\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\tprivate readonly _policies: IDocumentServicePolicies;\n\n\t// Promise to load socket module only once.\n\tprivate socketModuleP: Promise<OdspDelayLoadedDeltaStream> | undefined;\n\n\tprivate odspDelayLoadedDeltaStream: OdspDelayLoadedDeltaStream | undefined;\n\n\tprivate odspSocketModuleLoaded: boolean = false;\n\n\t/**\n\t * Creates a new OdspDocumentService instance.\n\t *\n\t * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - This host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tgetWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix?: string,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new OdspDocumentService(\n\t\t\tgetOdspResolvedUrl(resolvedUrl),\n\t\t\tgetAuthHeader,\n\t\t\tgetWebsocketToken,\n\t\t\tlogger,\n\t\t\tcache,\n\t\t\thostPolicy,\n\t\t\tepochTracker,\n\t\t\tsocketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprivate storageManager?: OdspDocumentStorageService;\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly hostPolicy: HostStoragePolicyInternal;\n\n\tprivate _opsCache?: OpsCache;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tprivate constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly cache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t\tprivate readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper();\n\t\tthis._policies = {\n\t\t\t// load in storage-only mode if a file version is specified\n\t\t\tstorageOnly: odspResolvedUrl.fileVersion !== undefined,\n\t\t\tsummarizeProtocolTree: true,\n\t\t\tsupportGetSnapshotApi: true,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\todc: hasOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl)),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tthis.hostPolicy = hostPolicy;\n\t\tthis.hostPolicy.supportGetSnapshotApi = this._policies.supportGetSnapshotApi;\n\t\tif (this.clientIsSummarizer) {\n\t\t\tthis.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n\t\t}\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\tpublic get policies(): IDocumentServicePolicies {\n\t\treturn this._policies;\n\t}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for sharepoint driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (!this.storageManager) {\n\t\t\tthis.storageManager = new OdspDocumentStorageService(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tthis.mc.logger,\n\t\t\t\ttrue,\n\t\t\t\tthis.cache,\n\t\t\t\tthis.hostPolicy,\n\t\t\t\tthis.epochTracker,\n\t\t\t\t// flushCallback\n\t\t\t\tasync () => {\n\t\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\t\treturn currentConnection.flush();\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\"Disconnected while uploading summary (attempt to perform flush())\");\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\treturn this.odspDelayLoadedDeltaStream?.relayServiceTenantAndSessionId;\n\t\t\t\t},\n\t\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n\t\t\t);\n\t\t}\n\n\t\treturn new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for sharepoint driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tconst snapshotOps = this.storageManager?.ops ?? [];\n\t\tconst service = new OdspDeltaStorageService(\n\t\t\tthis.odspResolvedUrl.endpoints.deltaStorageUrl,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.epochTracker,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// batch size, please see issue #5211 for data around batch sizing\n\t\tconst batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n\t\tconst concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n\t\treturn new OdspDeltaStorageWithCache(\n\t\t\tsnapshotOps,\n\t\t\tthis.mc.logger,\n\t\t\tbatchSize,\n\t\t\tconcurrency,\n\t\t\t// Get Ops from storage callback.\n\t\t\tasync (from, to, telemetryProps, fetchReason) =>\n\t\t\t\tservice.get(from, to, telemetryProps, fetchReason),\n\t\t\t// Get cachedOps Callback.\n\t\t\tasync (from, to) => {\n\t\t\t\tconst res = await this.opsCache?.get(from, to);\n\t\t\t\treturn (res as ISequencedDocumentMessage[]) ?? [];\n\t\t\t},\n\t\t\t// Ops requestFromSocket Callback.\n\t\t\t(from, to) => {\n\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\tcurrentConnection.requestOps(from, to);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t() => this.storageManager,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.socketModuleP === undefined) {\n\t\t\tthis.socketModuleP = this.getDelayLoadedDeltaStream();\n\t\t}\n\t\treturn this.socketModuleP\n\t\t\t.then(async (m) => {\n\t\t\t\tthis.odspSocketModuleLoaded = true;\n\t\t\t\treturn m.connectToDeltaStream(client);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// Setting undefined in case someone tries to recover from module failure by calling again.\n\t\t\t\tthis.socketModuleP = undefined;\n\t\t\t\tthis.odspSocketModuleLoaded = false;\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * This dynamically imports the module for loading the delta connection. In many cases the delta stream, is not\n\t * required during the critical load flow. So this way we don't have to bundle this in the initial bundle and can\n\t * import this later on when required.\n\t * @returns The delta stream object.\n\t */\n\tprivate async getDelayLoadedDeltaStream(): Promise<OdspDelayLoadedDeltaStream> {\n\t\tassert(this.odspSocketModuleLoaded === false, 0x507 /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"socketModule\" */ \"./odspDelayLoadedDeltaStream.js\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"SocketModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SocketModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspDelayLoadedDeltaStream = new module.OdspDelayLoadedDeltaStream(\n\t\t\tthis.odspResolvedUrl,\n\t\t\tthis._policies,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.getWebsocketToken,\n\t\t\tthis.mc,\n\t\t\tthis.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tthis.epochTracker,\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t(metadata: Record<string, string>) => this.emit(\"metadataUpdate\", metadata),\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\treturn this.odspDelayLoadedDeltaStream;\n\t}\n\n\tpublic dispose(error?: unknown): void {\n\t\t// Error might indicate mismatch between client & server knowledge about file\n\t\t// (OdspErrorTypes.fileOverwrittenInStorage).\n\t\t// For example, file might have been overwritten in storage without generating new epoch\n\t\t// In such case client cached info is stale and has to be removed.\n\t\tif (error === undefined) {\n\t\t\tthis._opsCache?.flushOps();\n\t\t} else {\n\t\t\tthis.epochTracker.removeEntries().catch(() => {});\n\t\t}\n\t\tthis._opsCache?.dispose();\n\t\t// Only need to dipose this, if it is already loaded.\n\t\tthis.odspDelayLoadedDeltaStream?.dispose();\n\t}\n\n\tprotected get opsCache(): OpsCache | undefined {\n\t\tif (this._opsCache) {\n\t\t\treturn this._opsCache;\n\t\t}\n\n\t\tconst seqNumber = this.storageManager?.snapshotSequenceNumber;\n\t\tconst batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n\t\tif (seqNumber === undefined || batchSize < 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst opsKey: Omit<IEntry, \"key\"> = {\n\t\t\ttype: \"ops\",\n\t\t};\n\t\tthis._opsCache = new OpsCache(\n\t\t\tseqNumber,\n\t\t\tthis.mc.logger,\n\t\t\t// ICache\n\t\t\t{\n\t\t\t\twrite: async (key: string, opsData: string): Promise<void> => {\n\t\t\t\t\treturn this.cache.persistedCache.put({ ...opsKey, key }, opsData);\n\t\t\t\t},\n\t\t\t\tread: async (key: string) => this.cache.persistedCache.get({ ...opsKey, key }),\n\t\t\t\tremove: (): void => {\n\t\t\t\t\tthis.cache.persistedCache.removeEntries().catch(() => {});\n\t\t\t\t},\n\t\t\t},\n\t\t\tbatchSize,\n\t\t\tthis.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n\t\t\tthis.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n\t\t);\n\t\treturn this._opsCache;\n\t}\n\n\t// Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n\t// We use it to notify caching layer of how stale is snapshot stored in cache.\n\tprotected opsReceived(ops: ISequencedDocumentMessage[]): void {\n\t\t// No need for two clients to save same ops\n\t\tif (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsCache?.addOps(ops);\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDocumentService.js","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAmB7D,OAAO,EAGN,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAMlD,OAAO,EACN,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,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AAC,UAAU,CAAC,UAAU,EAAE,gBAAgB,IAAI,IAAI,EACpD,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,eAAe,IAAI,IAAI,CACnD,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IAED,mHAAmH;IACnH,8EAA8E;IACpE,WAAW,CAAC,GAAgC;QACrD,2CAA2C;QAC3C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,CAAC;YACzD,OAAO;QACR,CAAC;QAED,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tIEntry,\n\tIOdspResolvedUrl,\n\tInstrumentedStorageTokenFetcher,\n\tTokenFetchOptions,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\ttype MonitoringContext,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { HostStoragePolicyInternal } from \"./contracts.js\";\nimport type { EpochTracker } from \"./epochTracker.js\";\nimport type { IOdspCache } from \"./odspCache.js\";\nimport type { OdspDelayLoadedDeltaStream } from \"./odspDelayLoadedDeltaStream.js\";\nimport {\n\tOdspDeltaStorageService,\n\tOdspDeltaStorageWithCache,\n} from \"./odspDeltaStorageService.js\";\nimport { OdspDocumentStorageService } from \"./odspDocumentStorageManager.js\";\nimport { hasOdcOrigin } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { OpsCache } from \"./opsCaching.js\";\nimport { RetryErrorsStorageAdapter } from \"./retryErrorsStorageAdapter.js\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients\n */\nexport class OdspDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\tprivate readonly _policies: IDocumentServicePolicies;\n\n\t// Promise to load socket module only once.\n\tprivate socketModuleP: Promise<OdspDelayLoadedDeltaStream> | undefined;\n\n\tprivate odspDelayLoadedDeltaStream: OdspDelayLoadedDeltaStream | undefined;\n\n\tprivate odspSocketModuleLoaded: boolean = false;\n\n\t/**\n\t * Creates a new OdspDocumentService instance.\n\t *\n\t * @param resolvedUrl - resolved url identifying document that will be managed by returned service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - This host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by returned service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic static async create(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tgetAuthHeader: InstrumentedStorageTokenFetcher,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tgetWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tcache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tepochTracker: EpochTracker,\n\t\tsocketReferenceKeyPrefix?: string,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new OdspDocumentService(\n\t\t\tgetOdspResolvedUrl(resolvedUrl),\n\t\t\tgetAuthHeader,\n\t\t\tgetWebsocketToken,\n\t\t\tlogger,\n\t\t\tcache,\n\t\t\thostPolicy,\n\t\t\tepochTracker,\n\t\t\tsocketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprivate storageManager?: OdspDocumentStorageService;\n\n\tprivate readonly mc: MonitoringContext;\n\n\tprivate readonly hostPolicy: HostStoragePolicyInternal;\n\n\tprivate _opsCache?: OpsCache;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param logger - a logger that can capture performance and diagnostic information\n\t * @param socketIoClientFactory - A factory that returns a promise to the socket io library required by the driver\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tprivate constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly cache: IOdspCache,\n\t\thostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t\tprivate readonly clientIsSummarizer?: boolean,\n\t) {\n\t\tsuper();\n\t\tthis._policies = {\n\t\t\t// load in storage-only mode if a file version is specified\n\t\t\tstorageOnly: odspResolvedUrl.fileVersion !== undefined,\n\t\t\tsummarizeProtocolTree: true,\n\t\t\tsupportGetSnapshotApi: true,\n\t\t};\n\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger,\n\t\t\tproperties: {\n\t\t\t\tall: {\n\t\t\t\t\todc: hasOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl)),\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\n\t\tthis.hostPolicy = hostPolicy;\n\t\tthis.hostPolicy.supportGetSnapshotApi = this._policies.supportGetSnapshotApi;\n\t\tif (this.clientIsSummarizer) {\n\t\t\tthis.hostPolicy = { ...this.hostPolicy, summarizerClient: true };\n\t\t}\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\tpublic get policies(): IDocumentServicePolicies {\n\t\treturn this._policies;\n\t}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for sharepoint driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (!this.storageManager) {\n\t\t\tthis.storageManager = new OdspDocumentStorageService(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tthis.mc.logger,\n\t\t\t\ttrue,\n\t\t\t\tthis.cache,\n\t\t\t\tthis.hostPolicy,\n\t\t\t\tthis.epochTracker,\n\t\t\t\t// flushCallback\n\t\t\t\tasync () => {\n\t\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\t\treturn currentConnection.flush();\n\t\t\t\t\t}\n\t\t\t\t\tthrow new Error(\"Disconnected while uploading summary (attempt to perform flush())\");\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\treturn this.odspDelayLoadedDeltaStream?.relayServiceTenantAndSessionId;\n\t\t\t\t},\n\t\t\t\tthis.mc.config.getNumber(\"Fluid.Driver.Odsp.snapshotFormatFetchType\"),\n\t\t\t);\n\t\t}\n\n\t\treturn new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for sharepoint driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tconst snapshotOps = this.storageManager?.ops ?? [];\n\t\tconst service = new OdspDeltaStorageService(\n\t\t\tthis.odspResolvedUrl.endpoints.deltaStorageUrl,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.epochTracker,\n\t\t\tthis.mc.logger,\n\t\t);\n\n\t\t// batch size, please see issue #5211 for data around batch sizing\n\t\tconst batchSize = this.hostPolicy.opsBatchSize ?? 5000;\n\t\tconst concurrency = this.hostPolicy.concurrentOpsBatches ?? 1;\n\t\treturn new OdspDeltaStorageWithCache(\n\t\t\tsnapshotOps,\n\t\t\tthis.mc.logger,\n\t\t\tbatchSize,\n\t\t\tconcurrency,\n\t\t\t// Get Ops from storage callback.\n\t\t\tasync (from, to, telemetryProps, fetchReason) =>\n\t\t\t\tservice.get(from, to, telemetryProps, fetchReason),\n\t\t\t// Get cachedOps Callback.\n\t\t\t// TODO AB#47218: This condition will be removed when file version can be read from the cache entry for an op.\n\t\t\tthis.odspResolvedUrl.fileVersion === undefined\n\t\t\t\t? async (from, to) =>\n\t\t\t\t\t\t((await this.opsCache?.get(from, to)) as ISequencedDocumentMessage[]) ?? []\n\t\t\t\t: async () => [],\n\t\t\t// Ops requestFromSocket Callback.\n\t\t\t(from, to) => {\n\t\t\t\tconst currentConnection = this.odspDelayLoadedDeltaStream?.currentDeltaConnection;\n\t\t\t\tif (currentConnection !== undefined && !currentConnection.disposed) {\n\t\t\t\t\tcurrentConnection.requestOps(from, to);\n\t\t\t\t}\n\t\t\t},\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t() => this.storageManager,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.socketModuleP === undefined) {\n\t\t\tthis.socketModuleP = this.getDelayLoadedDeltaStream();\n\t\t}\n\t\treturn this.socketModuleP\n\t\t\t.then(async (m) => {\n\t\t\t\tthis.odspSocketModuleLoaded = true;\n\t\t\t\treturn m.connectToDeltaStream(client);\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\t// Setting undefined in case someone tries to recover from module failure by calling again.\n\t\t\t\tthis.socketModuleP = undefined;\n\t\t\t\tthis.odspSocketModuleLoaded = false;\n\t\t\t\tthrow error;\n\t\t\t});\n\t}\n\n\t/**\n\t * This dynamically imports the module for loading the delta connection. In many cases the delta stream, is not\n\t * required during the critical load flow. So this way we don't have to bundle this in the initial bundle and can\n\t * import this later on when required.\n\t * @returns The delta stream object.\n\t */\n\tprivate async getDelayLoadedDeltaStream(): Promise<OdspDelayLoadedDeltaStream> {\n\t\tassert(this.odspSocketModuleLoaded === false, 0x507 /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"socketModule\" */ \"./odspDelayLoadedDeltaStream.js\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({ eventName: \"SocketModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.mc.logger.sendErrorEvent({ eventName: \"SocketModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspDelayLoadedDeltaStream = new module.OdspDelayLoadedDeltaStream(\n\t\t\tthis.odspResolvedUrl,\n\t\t\tthis._policies,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.getWebsocketToken,\n\t\t\tthis.mc,\n\t\t\tthis.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tthis.epochTracker,\n\t\t\t(ops: ISequencedDocumentMessage[]) => this.opsReceived(ops),\n\t\t\t(metadata: Record<string, string>) => this.emit(\"metadataUpdate\", metadata),\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\treturn this.odspDelayLoadedDeltaStream;\n\t}\n\n\tpublic dispose(error?: unknown): void {\n\t\t// Error might indicate mismatch between client & server knowledge about file\n\t\t// (OdspErrorTypes.fileOverwrittenInStorage).\n\t\t// For example, file might have been overwritten in storage without generating new epoch\n\t\t// In such case client cached info is stale and has to be removed.\n\t\tif (error === undefined) {\n\t\t\tthis._opsCache?.flushOps();\n\t\t} else {\n\t\t\tthis.epochTracker.removeEntries().catch(() => {});\n\t\t}\n\t\tthis._opsCache?.dispose();\n\t\t// Only need to dipose this, if it is already loaded.\n\t\tthis.odspDelayLoadedDeltaStream?.dispose();\n\t}\n\n\tprotected get opsCache(): OpsCache | undefined {\n\t\tif (this._opsCache) {\n\t\t\treturn this._opsCache;\n\t\t}\n\n\t\tconst seqNumber = this.storageManager?.snapshotSequenceNumber;\n\t\tconst batchSize = this.hostPolicy.opsCaching?.batchSize ?? 100;\n\t\tif (seqNumber === undefined || batchSize < 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst opsKey: Omit<IEntry, \"key\"> = {\n\t\t\ttype: \"ops\",\n\t\t};\n\t\tthis._opsCache = new OpsCache(\n\t\t\tseqNumber,\n\t\t\tthis.mc.logger,\n\t\t\t// ICache\n\t\t\t{\n\t\t\t\twrite: async (key: string, opsData: string): Promise<void> => {\n\t\t\t\t\treturn this.cache.persistedCache.put({ ...opsKey, key }, opsData);\n\t\t\t\t},\n\t\t\t\tread: async (key: string) => this.cache.persistedCache.get({ ...opsKey, key }),\n\t\t\t\tremove: (): void => {\n\t\t\t\t\tthis.cache.persistedCache.removeEntries().catch(() => {});\n\t\t\t\t},\n\t\t\t},\n\t\t\tbatchSize,\n\t\t\tthis.hostPolicy.opsCaching?.timerGranularity ?? 5000,\n\t\t\tthis.hostPolicy.opsCaching?.totalOpsToCache ?? 5000,\n\t\t);\n\t\treturn this._opsCache;\n\t}\n\n\t// Called whenever re receive ops through any channel for this document (snapshot, delta connection, delta storage)\n\t// We use it to notify caching layer of how stale is snapshot stored in cache.\n\tprotected opsReceived(ops: ISequencedDocumentMessage[]): void {\n\t\t// No need for two clients to save same ops\n\t\tif (ops.length === 0 || this.odspResolvedUrl.summarizer) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.opsCache?.addOps(ops);\n\t}\n}\n"]}
@@ -9,7 +9,7 @@ import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore
9
9
  * Factory for creating the sharepoint document service. Use this if you want to
10
10
  * use the sharepoint implementation.
11
11
  * @legacy
12
- * @alpha
12
+ * @beta
13
13
  */
14
14
  export declare class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
15
15
  constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
@@ -21,7 +21,7 @@ export declare class OdspDocumentServiceFactory extends OdspDocumentServiceFacto
21
21
  * content directly.
22
22
  *
23
23
  * @legacy
24
- * @alpha
24
+ * @beta
25
25
  */
26
26
  export declare function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory;
27
27
  //# sourceMappingURL=odspDocumentServiceFactory.d.ts.map
@@ -9,7 +9,7 @@ import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore
9
9
  * Factory for creating the sharepoint document service. Use this if you want to
10
10
  * use the sharepoint implementation.
11
11
  * @legacy
12
- * @alpha
12
+ * @beta
13
13
  */
14
14
  export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
15
15
  constructor(getStorageToken, getWebsocketToken, persistedCache, hostPolicy) {
@@ -23,7 +23,7 @@ export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
23
23
  * content directly.
24
24
  *
25
25
  * @legacy
26
- * @alpha
26
+ * @beta
27
27
  */
28
28
  export function createLocalOdspDocumentServiceFactory(localSnapshot) {
29
29
  return new LocalOdspDocumentServiceFactory(localSnapshot);
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,sDAAsD;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAC;AACvG,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF;;;;;GAKG;AACH,MAAM,OAAO,0BAA2B,SAAQ,8BAA8B;IAC7E,YACC,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qCAAqC,CACpD,aAAkC;IAElC,OAAO,IAAI,+BAA+B,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tIPersistedCache,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// eslint-disable-next-line import/no-internal-modules\nimport { LocalOdspDocumentServiceFactory } from \"./localOdspDriver/localOdspDocumentServiceFactory.js\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n * @legacy\n * @alpha\n */\nexport class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n\n/**\n * Creates a factory instance for creating a sharepoint document service from a provided snapshot.\n *\n * @remarks Use if you don't want to connect to any kind of external/internal storages and want to provide\n * content directly.\n *\n * @legacy\n * @alpha\n */\nexport function createLocalOdspDocumentServiceFactory(\n\tlocalSnapshot: Uint8Array | string,\n): IDocumentServiceFactory {\n\treturn new LocalOdspDocumentServiceFactory(localSnapshot);\n}\n"]}
1
+ {"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,sDAAsD;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAC;AACvG,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF;;;;;GAKG;AACH,MAAM,OAAO,0BAA2B,SAAQ,8BAA8B;IAC7E,YACC,eAA4D,EAC5D,iBAA0E,EAC1E,cAAgC,EAChC,UAA8B;QAE9B,KAAK,CAAC,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC;IACvE,CAAC;CACD;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qCAAqC,CACpD,aAAkC;IAElC,OAAO,IAAI,+BAA+B,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IDocumentServiceFactory } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tIPersistedCache,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// eslint-disable-next-line import/no-internal-modules\nimport { LocalOdspDocumentServiceFactory } from \"./localOdspDriver/localOdspDocumentServiceFactory.js\";\nimport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n\n/**\n * Creates a factory instance for creating a sharepoint document service from a provided snapshot.\n *\n * @remarks Use if you don't want to connect to any kind of external/internal storages and want to provide\n * content directly.\n *\n * @legacy\n * @beta\n */\nexport function createLocalOdspDocumentServiceFactory(\n\tlocalSnapshot: Uint8Array | string,\n): IDocumentServiceFactory {\n\treturn new LocalOdspDocumentServiceFactory(localSnapshot);\n}\n"]}
@@ -16,7 +16,7 @@ import { type IPrefetchSnapshotContents } from "./odspCache.js";
16
16
  * This constructor should be used by environments that support dynamic imports and that wish
17
17
  * to leverage code splitting as a means to keep bundles as small as possible.
18
18
  * @legacy
19
- * @alpha
19
+ * @beta
20
20
  */
21
21
  export declare class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory, IRelaySessionAwareDriverFactory {
22
22
  private readonly getStorageToken;
@@ -19,7 +19,7 @@ import { createOdspLogger, getJoinSessionCacheKey, getOdspResolvedUrl, isNewFile
19
19
  * This constructor should be used by environments that support dynamic imports and that wish
20
20
  * to leverage code splitting as a means to keep bundles as small as possible.
21
21
  * @legacy
22
- * @alpha
22
+ * @beta
23
23
  */
24
24
  export class OdspDocumentServiceFactoryCore {
25
25
  get snapshotPrefetchResultCache() {
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EASN,eAAe,EACf,gBAAgB,GAGhB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAyB,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAGN,oBAAoB,EACpB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAGN,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,qCAAqC,EACrC,8BAA8B,GAC9B,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,OAAO,8BAA8B;IAM1C,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC;IAC5D,CAAC;IAED,qFAAqF;IACrF,IAAW,+BAA+B;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,0BAA0B,CACtC,WAAyB;QAEzB,MAAM,eAAe,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;QACxD,MAAM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E,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,EAAE;oBAC1C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype HostStoragePolicy,\n\ttype IFileEntry,\n\ttype IOdspUrlParts,\n\ttype IPersistedCache,\n\ttype IRelaySessionAwareDriverFactory,\n\ttype ISharingLinkKind,\n\ttype ISocketStorageDiscovery,\n\ttype OdspResourceTokenFetchOptions,\n\tSharingLinkRole,\n\tSharingLinkScope,\n\ttype TokenFetchOptions,\n\ttype TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { useCreateNewModule } from \"./createFile/index.js\";\nimport { type ICacheAndTracker, createOdspCacheAndTracker } from \"./epochTracker.js\";\nimport {\n\ttype INonPersistentCache,\n\ttype IPrefetchSnapshotContents,\n\tLocalPersistentCache,\n\tNonPersistentCache,\n} from \"./odspCache.js\";\nimport { OdspDocumentService } from \"./odspDocumentService.js\";\nimport { odspDriverCompatDetailsForLoader } from \"./odspLayerCompatState.js\";\nimport {\n\ttype IExistingFileInfo,\n\ttype INewFileInfo,\n\tcreateOdspLogger,\n\tgetJoinSessionCacheKey,\n\tgetOdspResolvedUrl,\n\tisNewFileInfo,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n * @legacy\n * @alpha\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache(): PromiseCache<string, IPrefetchSnapshotContents> {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\t// TODO: return `IRelaySessionAwareDriverFactory` instead of `this` (breaking change)\n\tpublic get IRelaySessionAwareDriverFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t);\n\t\t\t\tconst _odspResolvedUrl = await useCreateNewModule(odspLogger, async (module) => {\n\t\t\t\t\treturn isNewFileInfo(fileInfo)\n\t\t\t\t\t\t? module.createNewFluidFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\todspResolvedUrl.fileMetadata?.eTag,\n\t\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\t_odspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: _odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| TokenFetcher<OdspResourceTokenFetchOptions>\n\t\t\t| undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\t/**\n\t * The compatibility details of the ODSP Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = odspDriverCompatDetailsForLoader;\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryBaseLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst extLogger = createChildLogger({ logger: odspLogger });\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{ resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n\t\t\t\textLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspStorageTokenFetcher(\n\t\t\textLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions): Promise<string | null> =>\n\t\t\t\t\t\t// websocket expects a plain token\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\textLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t\ttrue /* returnPlainToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\textLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t{ role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
1
+ {"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EASN,eAAe,EACf,gBAAgB,GAGhB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAyB,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAGN,oBAAoB,EACpB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAGN,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,qCAAqC,EACrC,8BAA8B,GAC9B,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,OAAO,8BAA8B;IAM1C,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC,kBAAkB,CAAC,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AI,gBAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1D,oBAAoB,GAAG;gBACtB,mEAAmE;gBACnE,KAAK,EAAE,gBAAgB,CAAC,eAAe,CAAC;gBACxC,GAAG,CAAC,cAAc,IAAI,eAAe,CAAC,cAAc,CAAC;oBACpD,CAAC,CAAC,mEAAmE;wBACpE,EAAE,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,EAAE;oBAC1C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype HostStoragePolicy,\n\ttype IFileEntry,\n\ttype IOdspUrlParts,\n\ttype IPersistedCache,\n\ttype IRelaySessionAwareDriverFactory,\n\ttype ISharingLinkKind,\n\ttype ISocketStorageDiscovery,\n\ttype OdspResourceTokenFetchOptions,\n\tSharingLinkRole,\n\tSharingLinkScope,\n\ttype TokenFetchOptions,\n\ttype TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { useCreateNewModule } from \"./createFile/index.js\";\nimport { type ICacheAndTracker, createOdspCacheAndTracker } from \"./epochTracker.js\";\nimport {\n\ttype INonPersistentCache,\n\ttype IPrefetchSnapshotContents,\n\tLocalPersistentCache,\n\tNonPersistentCache,\n} from \"./odspCache.js\";\nimport { OdspDocumentService } from \"./odspDocumentService.js\";\nimport { odspDriverCompatDetailsForLoader } from \"./odspLayerCompatState.js\";\nimport {\n\ttype IExistingFileInfo,\n\ttype INewFileInfo,\n\tcreateOdspLogger,\n\tgetJoinSessionCacheKey,\n\tgetOdspResolvedUrl,\n\tisNewFileInfo,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache(): PromiseCache<string, IPrefetchSnapshotContents> {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\t// TODO: return `IRelaySessionAwareDriverFactory` instead of `this` (breaking change)\n\tpublic get IRelaySessionAwareDriverFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t);\n\t\t\t\tconst _odspResolvedUrl = await useCreateNewModule(odspLogger, async (module) => {\n\t\t\t\t\treturn isNewFileInfo(fileInfo)\n\t\t\t\t\t\t? module.createNewFluidFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\todspResolvedUrl.fileMetadata?.eTag,\n\t\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\t_odspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: _odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| TokenFetcher<OdspResourceTokenFetchOptions>\n\t\t\t| undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\t/**\n\t * The compatibility details of the ODSP Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = odspDriverCompatDetailsForLoader;\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryBaseLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst extLogger = createChildLogger({ logger: odspLogger });\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{ resolvedUrl: odspResolvedUrl, docId: odspResolvedUrl.hashedDocumentId },\n\t\t\t\textLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspStorageTokenFetcher(\n\t\t\textLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions): Promise<string | null> =>\n\t\t\t\t\t\t// websocket expects a plain token\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\textLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t\ttrue /* returnPlainToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\textLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t{ role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
@@ -9,7 +9,7 @@ import { type IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions/i
9
9
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
10
10
  * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`
11
11
  * @legacy
12
- * @alpha
12
+ * @beta
13
13
  */
14
14
  export declare class OdspDriverUrlResolver implements IUrlResolver {
15
15
  constructor();
@@ -48,7 +48,7 @@ const isFluidPackage = (pkg) => typeof pkg === "object" && typeof pkg?.name ===
48
48
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
49
49
  * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`
50
50
  * @legacy
51
- * @alpha
51
+ * @beta
52
52
  */
53
53
  export class OdspDriverUrlResolver {
54
54
  constructor() { }
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC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IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;IAEtD,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;IACtE,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEpD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACpD,CAAC;IAED,OAAO;QACN,OAAO;QACP,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,MAAM,CAAC;QAClC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAC9B,oBAAoB,EAAE,oBAAoB;YACzC,CAAC,CAAC,kBAAkB,CAAC,oBAAoB,CAAC;YAC1C,CAAC,CAAC,SAAS;QACZ,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\ttype IContainerPackageInfo,\n\ttype IResolvedUrl,\n\ttype IUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspResolvedUrl,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { ClpCompliantAppHeader, FileMetadataHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getHashedDocumentId } from \"./odspPublicUtils.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\nfunction getUrlBase(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(new URL(siteUrl))}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.slice(1);\n\t}\n\n\treturn str;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n * @legacy\n * @alpha\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IUrlResolver.resolve}\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst fileName: string = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there\",\n\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `https://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo: undefined,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } =\n\t\t\tdecodeOdspUrl(request.url);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `https://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\tfileMetadata: {\n\t\t\t\teTag: request.headers?.[FileMetadataHeader.eTag],\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.slice(1);\n\t\t}\n\n\t\tlet containerPackageName: string | undefined;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t\t// TODO: use stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nexport function decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\tsiteUrl,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n}\n"]}
1
+ {"version":3,"file":"odspDriverUrlResolver.js","sourceRoot":"","sources":["../src/odspDriverUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,YAAY,GAIZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAEN,cAAc,GACd,MAAM,kDAAkD,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,SAAS,UAAU,CAClB,OAAe,EACf,OAAe,EACf,MAAc,EACd,WAAoB;IAEpB,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,YAAY,WAAW,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9D,OAAO,GAAG,UAAU,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,WAAW,OAAO,UAAU,MAAM,IAAI,OAAO,EAAE,CAAC;AACvF,CAAC;AAED,SAAS,cAAc,CACtB,OAAe,EACf,OAAe,EACf,MAAc,EACd,WAAoB;IAEpB,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAClE,OAAO,GAAG,OAAO,oBAAoB,CAAC;AACvC,CAAC;AAED,SAAS,oBAAoB,CAC5B,OAAe,EACf,OAAe,EACf,MAAc,EACd,WAAoB;IAEpB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AAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\ttype IContainerPackageInfo,\n\ttype IResolvedUrl,\n\ttype IUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError } from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype IOdspResolvedUrl,\n\tOdspErrorTypes,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { ClpCompliantAppHeader, FileMetadataHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getHashedDocumentId } from \"./odspPublicUtils.js\";\nimport { getApiRoot } from \"./odspUrlHelper.js\";\nimport { getOdspResolvedUrl } from \"./odspUtils.js\";\nimport { pkgVersion } from \"./packageVersion.js\";\n\nfunction getUrlBase(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst version = fileVersion ? `versions/${fileVersion}/` : \"\";\n\treturn `${getApiRoot(new URL(siteUrl))}/drives/${driveId}/items/${itemId}/${version}`;\n}\n\nfunction getSnapshotUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/snapshots`;\n}\n\nfunction getAttachmentPOSTUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachment`;\n}\n\nfunction getAttachmentGETUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream/attachments`;\n}\n\nfunction getDeltaStorageUrl(\n\tsiteUrl: string,\n\tdriveId: string,\n\titemId: string,\n\tfileVersion?: string,\n): string {\n\tconst urlBase = getUrlBase(siteUrl, driveId, itemId, fileVersion);\n\treturn `${urlBase}opStream`;\n}\n\n/**\n * Utility that enables us to handle paths provided with a beginning slash.\n * For example if a value of '/id1/id2' is provided, id1/id2 is returned.\n */\nfunction removeBeginningSlash(str: string): string {\n\tif (str.startsWith(\"/\")) {\n\t\treturn str.slice(1);\n\t}\n\n\treturn str;\n}\n\n// back-compat: GitHub #9653\nconst isFluidPackage = (pkg: Record<string, unknown>): boolean =>\n\ttypeof pkg === \"object\" && typeof pkg?.name === \"string\" && typeof pkg?.fluid === \"object\";\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`\n * @legacy\n * @beta\n */\nexport class OdspDriverUrlResolver implements IUrlResolver {\n\tconstructor() {}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IUrlResolver.resolve}\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tif (request.headers?.[DriverHeader.createNew]) {\n\t\t\tconst [siteURL, queryString] = request.url.split(\"?\");\n\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst fileName: string = request.headers[DriverHeader.createNew].fileName;\n\t\t\tconst driveID = searchParams.get(\"driveId\");\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tconst packageName = searchParams.get(\"containerPackageName\");\n\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive\n\t\t\tif (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Proper new file params should be there\",\n\t\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t\t{ driverVersion: pkgVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tendpoints: {\n\t\t\t\t\tsnapshotStorageUrl: \"\",\n\t\t\t\t\tattachmentGETStorageUrl: \"\",\n\t\t\t\t\tattachmentPOSTStorageUrl: \"\",\n\t\t\t\t\tdeltaStorageUrl: \"\",\n\t\t\t\t},\n\t\t\t\ttokens: {},\n\t\t\t\ttype: \"fluid\",\n\t\t\t\todspResolvedUrl: true,\n\t\t\t\tid: \"odspCreateNew\",\n\t\t\t\turl: `https://${siteURL}?${queryString}&version=null`,\n\t\t\t\tsiteUrl: siteURL,\n\t\t\t\thashedDocumentId: \"\",\n\t\t\t\tdriveId: driveID,\n\t\t\t\titemId: \"\",\n\t\t\t\tfileName,\n\t\t\t\tsummarizer: false,\n\t\t\t\tcodeHint: {\n\t\t\t\t\tcontainerPackageName: packageName ?? undefined,\n\t\t\t\t},\n\t\t\t\tfileVersion: undefined,\n\t\t\t\tshareLinkInfo: undefined,\n\t\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\t};\n\t\t}\n\t\tconst { siteUrl, driveId, itemId, path, containerPackageName, fileVersion } =\n\t\t\tdecodeOdspUrl(request.url);\n\t\tconst hashedDocumentId = await getHashedDocumentId(driveId, itemId);\n\t\tassert(!hashedDocumentId.includes(\"/\"), 0x0a8 /* \"Docid should not contain slashes!!\" */);\n\n\t\tconst documentUrl = `https://placeholder/placeholder/${hashedDocumentId}/${removeBeginningSlash(\n\t\t\tpath,\n\t\t)}`;\n\n\t\tconst summarizer = !!request.headers?.[DriverHeader.summarizingClient];\n\t\treturn {\n\t\t\ttype: \"fluid\",\n\t\t\todspResolvedUrl: true,\n\t\t\tendpoints: {\n\t\t\t\tsnapshotStorageUrl: getSnapshotUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentPOSTStorageUrl: getAttachmentPOSTUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tattachmentGETStorageUrl: getAttachmentGETUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t\tdeltaStorageUrl: getDeltaStorageUrl(siteUrl, driveId, itemId, fileVersion),\n\t\t\t},\n\t\t\tid: hashedDocumentId,\n\t\t\ttokens: {},\n\t\t\turl: documentUrl,\n\t\t\thashedDocumentId,\n\t\t\tsiteUrl,\n\t\t\tdriveId,\n\t\t\titemId,\n\t\t\tdataStorePath: path,\n\t\t\tfileName: \"\",\n\t\t\tsummarizer,\n\t\t\tcodeHint: {\n\t\t\t\tcontainerPackageName,\n\t\t\t},\n\t\t\tfileVersion,\n\t\t\tisClpCompliantApp: request.headers?.[ClpCompliantAppHeader.isClpCompliantApp],\n\t\t\tfileMetadata: {\n\t\t\t\teTag: request.headers?.[FileMetadataHeader.eTag],\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL.\n\t * @param resolvedUrl - The driver resolved URL.\n\t * @param relativeUrl - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tlet dataStorePath = relativeUrl;\n\t\tif (relativeUrl === \"\" && odspResolvedUrl.dataStorePath !== undefined) {\n\t\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\t\tdataStorePath = odspResolvedUrl.dataStorePath;\n\t\t}\n\t\tif (dataStorePath.startsWith(\"/\")) {\n\t\t\tdataStorePath = dataStorePath.slice(1);\n\t\t}\n\n\t\tlet containerPackageName: string | undefined;\n\t\tif (packageInfoSource && \"name\" in packageInfoSource) {\n\t\t\tcontainerPackageName = packageInfoSource.name;\n\t\t\t// packageInfoSource is cast to any as it is typed to IContainerPackageInfo instead of IFluidCodeDetails\n\t\t\t// TODO: use stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t} else if (isFluidPackage((packageInfoSource as any)?.package)) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package.name;\n\t\t} else {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tcontainerPackageName = (packageInfoSource as any)?.package;\n\t\t}\n\t\tcontainerPackageName =\n\t\t\tcontainerPackageName ?? odspResolvedUrl.codeHint?.containerPackageName;\n\n\t\treturn createOdspUrl({\n\t\t\t...odspResolvedUrl,\n\t\t\tcontainerPackageName,\n\t\t\tdataStorePath,\n\t\t});\n\t}\n}\n\nexport function decodeOdspUrl(url: string): {\n\tsiteUrl: string;\n\tdriveId: string;\n\titemId: string;\n\tpath: string;\n\tcontainerPackageName?: string;\n\tfileVersion?: string;\n} {\n\tconst [siteUrl, queryString] = url.split(\"?\");\n\n\tconst searchParams = new URLSearchParams(queryString);\n\n\tconst driveId = searchParams.get(\"driveId\");\n\tconst itemId = searchParams.get(\"itemId\");\n\tconst path = searchParams.get(\"path\");\n\tconst containerPackageName = searchParams.get(\"containerPackageName\");\n\tconst fileVersion = searchParams.get(\"fileVersion\");\n\n\tif (driveId === null) {\n\t\tthrow new Error(\"ODSP URL did not contain a drive id\");\n\t}\n\n\tif (itemId === null) {\n\t\tthrow new Error(\"ODSP Url did not contain an item id\");\n\t}\n\n\tif (path === null) {\n\t\tthrow new Error(\"ODSP Url did not contain a path\");\n\t}\n\n\treturn {\n\t\tsiteUrl,\n\t\tdriveId: decodeURIComponent(driveId),\n\t\titemId: decodeURIComponent(itemId),\n\t\tpath: decodeURIComponent(path),\n\t\tcontainerPackageName: containerPackageName\n\t\t\t? decodeURIComponent(containerPackageName)\n\t\t\t: undefined,\n\t\tfileVersion: fileVersion ? decodeURIComponent(fileVersion) : undefined,\n\t};\n}\n"]}
@@ -9,7 +9,7 @@ import { type OdspFluidDataStoreLocator } from "./contractsPublic.js";
9
9
  /**
10
10
  * Properties passed to the code responsible for fetching share link for a file.
11
11
  * @legacy
12
- * @alpha
12
+ * @beta
13
13
  */
14
14
  export interface ShareLinkFetcherProps {
15
15
  /**
@@ -26,7 +26,7 @@ export interface ShareLinkFetcherProps {
26
26
  * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
27
27
  * This resolver also handles share links and try to generate one for the use by the app.
28
28
  * @legacy
29
- * @alpha
29
+ * @beta
30
30
  */
31
31
  export declare class OdspDriverUrlResolverForShareLink implements IUrlResolver {
32
32
  private readonly appName?;
@@ -14,7 +14,7 @@ import { appendNavParam, createOdspLogger, getOdspResolvedUrl, getContainerPacka
14
14
  * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
15
15
  * This resolver also handles share links and try to generate one for the use by the app.
16
16
  * @legacy
17
- * @alpha
17
+ * @beta
18
18
  */
19
19
  export class OdspDriverUrlResolverForShareLink {
20
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAcnE,OAAO,EAAkC,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,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AU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRequest, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getFileLink } from \"./getFileLink.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tlocatorQueryParamName,\n\tstoreLocatorInOdspUrl,\n} from \"./odspFluidFileLink.js\";\nimport {\n\tappendNavParam,\n\tcreateOdspLogger,\n\tgetOdspResolvedUrl,\n\tgetContainerPackageName,\n} from \"./odspUtils.js\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n * @legacy\n * @alpha\n */\nexport interface ShareLinkFetcherProps {\n\t/**\n\t * Callback method that is used to fetch access token necessary to call API that produces share link\n\t */\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/**\n\t * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n\t */\n\tidentityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n * @legacy\n * @alpha\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly sharingLinkCache = new PromiseCache<string, string>();\n\tprivate readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n\t/**\n\t * Creates url resolver instance\n\t * @param shareLinkFetcherProps - properties used when fetching share link.\n\t * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n\t * getAbsoluteUrl() method requires share link.\n\t * @param logger - logger object that is used as telemetry sink\n\t * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n\t * This hint is used by link handling logic which determines which app to redirect to when user\n\t * navigates directly to the link.\n\t * @param getContext - callback function which is used to get context for given resolved url. If context\n\t * is returned then it will be embedded into url returned by getAbsoluteUrl() method.\n\t * @param containerPackageInfo - container package information which will be used to extract the container package name.\n\t */\n\tpublic constructor(\n\t\tshareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tprivate readonly appName?: string,\n\t\tprivate readonly getContext?: (\n\t\t\tresolvedUrl: IOdspResolvedUrl,\n\t\t\tdataStorePath: string,\n\t\t) => Promise<string | undefined>,\n\t\tprivate readonly containerPackageInfo?: IContainerPackageInfo,\n\t) {\n\t\tthis.logger = createOdspLogger(logger);\n\t\tif (shareLinkFetcherProps) {\n\t\t\tthis.shareLinkFetcherProps = {\n\t\t\t\t...shareLinkFetcherProps,\n\t\t\t\ttokenFetcher: shareLinkFetcherProps.tokenFetcher,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Takes an already generated data store url (from requestUrl) and appends a path to the\n\t * existing data store information.\n\t */\n\tpublic appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n\t\tconst fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n\t\tif (!fluidInfo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parsingUrl = new URL(\n\t\t\tfluidInfo.dataStorePath,\n\t\t\t`${requestUrl.protocol}//${requestUrl.hostname}`,\n\t\t);\n\t\t// Determine if the caller is passing a query parameter or path since processing will be different.\n\t\tif (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n\t\t\tconst queryParams = new URLSearchParams(pathToAppend);\n\t\t\tfor (const [key, value] of queryParams.entries()) {\n\t\t\t\tparsingUrl.searchParams.append(key, value);\n\t\t\t}\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n\t\t} else {\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${\n\t\t\t\tparsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n\t\t\t}${pathToAppend}/${parsingUrl.search}`;\n\t\t}\n\t\tstoreLocatorInOdspUrl(requestUrl, fluidInfo);\n\n\t\treturn requestUrl.href;\n\t}\n\n\tprivate getKey(resolvedUrl: IOdspResolvedUrl): string {\n\t\treturn `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n\t}\n\n\t/**\n\t * Resolves request URL into driver details\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tconst requestToBeResolved = { headers: request.headers, url: request.url };\n\t\tconst isSharingLinkToRedeem =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n\t\tconst isRedemptionNonDurable =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isRedemptionNonDurable];\n\t\ttry {\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconst odspFluidInfo = getLocatorFromOdspUrl(url);\n\t\t\tif (odspFluidInfo) {\n\t\t\t\trequestToBeResolved.url = createOdspUrl(odspFluidInfo);\n\t\t\t}\n\t\t} catch {\n\t\t\t// If the locator throws some error, then try to resolve the request as it is.\n\t\t}\n\n\t\tconst odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n\t\todspResolvedUrl.context = await this.getContext?.(\n\t\t\todspResolvedUrl,\n\t\t\todspResolvedUrl.dataStorePath ?? \"\",\n\t\t);\n\n\t\todspResolvedUrl.appName = this.appName;\n\n\t\todspResolvedUrl.codeHint = odspResolvedUrl.codeHint?.containerPackageName\n\t\t\t? odspResolvedUrl.codeHint\n\t\t\t: { containerPackageName: getContainerPackageName(this.containerPackageInfo) };\n\n\t\tif (isSharingLinkToRedeem) {\n\t\t\t// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n\t\t\t// when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n\t\t\t// the eligible length.\n\t\t\todspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, {\n\t\t\t\tsharingLinkToRedeem: this.removeNavParam(request.url),\n\t\t\t\tisRedemptionNonDurable: isRedemptionNonDurable ?? false,\n\t\t\t});\n\t\t}\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\t// Kick start the sharing link request if we don't have it already as a performance optimization.\n\t\t\t// For detached create new, we don't have an item id yet and therefore cannot generate a share link\n\t\t\tthis.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n\t\t}\n\t\treturn odspResolvedUrl;\n\t}\n\n\tprivate removeNavParam(link: string): string {\n\t\tconst url = new URL(link);\n\t\tconst params = new URLSearchParams(url.search);\n\t\tparams.delete(locatorQueryParamName);\n\t\turl.search = params.toString();\n\t\treturn url.href;\n\t}\n\n\tprivate async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n\t\tif (this.shareLinkFetcherProps === undefined) {\n\t\t\tthrow new Error(\"Failed to get share link because share link fetcher props are missing\");\n\t\t}\n\n\t\tif (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to get share link because necessary information is missing \" +\n\t\t\t\t\t\"(e.g. siteUrl, driveId or itemId)\",\n\t\t\t);\n\t\t}\n\n\t\tconst key = this.getKey(resolvedUrl);\n\t\tconst cachedLinkPromise = this.sharingLinkCache.get(key);\n\t\tif (cachedLinkPromise) {\n\t\t\treturn cachedLinkPromise;\n\t\t}\n\t\tconst newLinkPromise = getFileLink(\n\t\t\tthis.shareLinkFetcherProps.tokenFetcher,\n\t\t\tresolvedUrl,\n\t\t\tthis.logger,\n\t\t).catch((error) => {\n\t\t\t// This should imply that error is a non-retriable error.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n\t\t\tthis.sharingLinkCache.remove(key);\n\t\t\tthrow error;\n\t\t});\n\t\tthis.sharingLinkCache.add(key, async () => newLinkPromise);\n\t\treturn newLinkPromise;\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n\t * and it will throw in case share link fetcher props were not specified when instance was created.\n\t * @param resolvedUrl - The driver resolved URL\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tconst shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\n\t\treturn this.appendLocatorParams(shareLink, resolvedUrl, dataStorePath, packageInfoSource);\n\t}\n\n\t/**\n\t * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n\t * has a base URL (for example a sharing link) of the Fluid file, but does not have the locator information that would be used by Fluid\n\t * to load the file later.\n\t * @param baseUrl - The input URL on which the locator params will be appended.\n\t * @param resolvedUrl - odsp-driver's resolvedURL object.\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @returns The provided base URL appended with odsp-specific locator information\n\t */\n\tpublic async appendLocatorParams(\n\t\tbaseUrl: string,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\t\todspResolvedUrl.context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\t/**\n\t\t * containerPackageName can be provided by various ways, in the order of priority:\n\t\t * 1. packageInfoSource - passed by the call of appendLocatorParams\n\t\t * 2. odspResolvedUrl.codeHint?.containerPackageName - passed by the odsp-driver's resolvedURL object\n\t\t * 3. this.containerPackageInfo - passed by the constructor of OdspDrvierUrlResolverForShareLink\n\t\t * */\n\t\tconst containerPackageName: string | undefined =\n\t\t\tgetContainerPackageName(packageInfoSource) ??\n\t\t\todspResolvedUrl.codeHint?.containerPackageName ??\n\t\t\tgetContainerPackageName(this.containerPackageInfo);\n\n\t\todspResolvedUrl.appName = this.appName;\n\n\t\treturn appendNavParam(baseUrl, odspResolvedUrl, actualDataStorePath, containerPackageName);\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(\n\t\tbaseUrl: string,\n\t\tdriverInfo: OdspFluidDataStoreLocator,\n\t): string {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDriverUrlResolverForShareLink.js","sourceRoot":"","sources":["../src/odspDriverUrlResolverForShareLink.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAcnE,OAAO,EAAkC,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,o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B,CAC9B,OAAe,EACf,UAAqC;QAErC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QAE7B,qBAAqB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAEvC,OAAO,GAAG,CAAC,IAAI,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRequest, ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIContainerPackageInfo,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIOdspResolvedUrl,\n\tIdentityType,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport type { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { type OdspFluidDataStoreLocator, SharingLinkHeader } from \"./contractsPublic.js\";\nimport { createOdspUrl } from \"./createOdspUrl.js\";\nimport { getFileLink } from \"./getFileLink.js\";\nimport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver.js\";\nimport {\n\tgetLocatorFromOdspUrl,\n\tlocatorQueryParamName,\n\tstoreLocatorInOdspUrl,\n} from \"./odspFluidFileLink.js\";\nimport {\n\tappendNavParam,\n\tcreateOdspLogger,\n\tgetOdspResolvedUrl,\n\tgetContainerPackageName,\n} from \"./odspUtils.js\";\n\n/**\n * Properties passed to the code responsible for fetching share link for a file.\n * @legacy\n * @beta\n */\nexport interface ShareLinkFetcherProps {\n\t/**\n\t * Callback method that is used to fetch access token necessary to call API that produces share link\n\t */\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/**\n\t * Identity type determining the shape of share link as it differs for Enterprise and Consumer users.\n\t */\n\tidentityType: IdentityType;\n}\n\n/**\n * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner\n * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.\n * This resolver also handles share links and try to generate one for the use by the app.\n * @legacy\n * @beta\n */\nexport class OdspDriverUrlResolverForShareLink implements IUrlResolver {\n\tprivate readonly logger: ITelemetryLoggerExt;\n\tprivate readonly sharingLinkCache = new PromiseCache<string, string>();\n\tprivate readonly shareLinkFetcherProps: ShareLinkFetcherProps | undefined;\n\n\t/**\n\t * Creates url resolver instance\n\t * @param shareLinkFetcherProps - properties used when fetching share link.\n\t * Can be set as 'undefined' for cases where share link is not needed. Currently, only\n\t * getAbsoluteUrl() method requires share link.\n\t * @param logger - logger object that is used as telemetry sink\n\t * @param appName - application name hint that is encoded with url produced by getAbsoluteUrl() method.\n\t * This hint is used by link handling logic which determines which app to redirect to when user\n\t * navigates directly to the link.\n\t * @param getContext - callback function which is used to get context for given resolved url. If context\n\t * is returned then it will be embedded into url returned by getAbsoluteUrl() method.\n\t * @param containerPackageInfo - container package information which will be used to extract the container package name.\n\t */\n\tpublic constructor(\n\t\tshareLinkFetcherProps?: ShareLinkFetcherProps | undefined,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tprivate readonly appName?: string,\n\t\tprivate readonly getContext?: (\n\t\t\tresolvedUrl: IOdspResolvedUrl,\n\t\t\tdataStorePath: string,\n\t\t) => Promise<string | undefined>,\n\t\tprivate readonly containerPackageInfo?: IContainerPackageInfo,\n\t) {\n\t\tthis.logger = createOdspLogger(logger);\n\t\tif (shareLinkFetcherProps) {\n\t\t\tthis.shareLinkFetcherProps = {\n\t\t\t\t...shareLinkFetcherProps,\n\t\t\t\ttokenFetcher: shareLinkFetcherProps.tokenFetcher,\n\t\t\t};\n\t\t}\n\t}\n\n\t/**\n\t * Takes an already generated data store url (from requestUrl) and appends a path to the\n\t * existing data store information.\n\t */\n\tpublic appendDataStorePath(requestUrl: URL, pathToAppend: string): string | undefined {\n\t\tconst fluidInfo = getLocatorFromOdspUrl(requestUrl);\n\n\t\tif (!fluidInfo) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst parsingUrl = new URL(\n\t\t\tfluidInfo.dataStorePath,\n\t\t\t`${requestUrl.protocol}//${requestUrl.hostname}`,\n\t\t);\n\t\t// Determine if the caller is passing a query parameter or path since processing will be different.\n\t\tif (pathToAppend.startsWith(\"/?\") || pathToAppend.startsWith(\"?\")) {\n\t\t\tconst queryParams = new URLSearchParams(pathToAppend);\n\t\t\tfor (const [key, value] of queryParams.entries()) {\n\t\t\t\tparsingUrl.searchParams.append(key, value);\n\t\t\t}\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${parsingUrl.search}`;\n\t\t} else {\n\t\t\tfluidInfo.dataStorePath = `${parsingUrl.pathname}${\n\t\t\t\tparsingUrl.pathname.endsWith(\"/\") || pathToAppend.startsWith(\"/\") ? \"\" : \"/\"\n\t\t\t}${pathToAppend}/${parsingUrl.search}`;\n\t\t}\n\t\tstoreLocatorInOdspUrl(requestUrl, fluidInfo);\n\n\t\treturn requestUrl.href;\n\t}\n\n\tprivate getKey(resolvedUrl: IOdspResolvedUrl): string {\n\t\treturn `${resolvedUrl.siteUrl},${resolvedUrl.driveId},${resolvedUrl.itemId}`;\n\t}\n\n\t/**\n\t * Resolves request URL into driver details\n\t */\n\tpublic async resolve(request: IRequest): Promise<IOdspResolvedUrl> {\n\t\tconst requestToBeResolved = { headers: request.headers, url: request.url };\n\t\tconst isSharingLinkToRedeem =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isSharingLinkToRedeem];\n\t\tconst isRedemptionNonDurable =\n\t\t\trequestToBeResolved.headers?.[SharingLinkHeader.isRedemptionNonDurable];\n\t\ttry {\n\t\t\tconst url = new URL(request.url);\n\n\t\t\tconst odspFluidInfo = getLocatorFromOdspUrl(url);\n\t\t\tif (odspFluidInfo) {\n\t\t\t\trequestToBeResolved.url = createOdspUrl(odspFluidInfo);\n\t\t\t}\n\t\t} catch {\n\t\t\t// If the locator throws some error, then try to resolve the request as it is.\n\t\t}\n\n\t\tconst odspResolvedUrl = await new OdspDriverUrlResolver().resolve(requestToBeResolved);\n\n\t\todspResolvedUrl.context = await this.getContext?.(\n\t\t\todspResolvedUrl,\n\t\t\todspResolvedUrl.dataStorePath ?? \"\",\n\t\t);\n\n\t\todspResolvedUrl.appName = this.appName;\n\n\t\todspResolvedUrl.codeHint = odspResolvedUrl.codeHint?.containerPackageName\n\t\t\t? odspResolvedUrl.codeHint\n\t\t\t: { containerPackageName: getContainerPackageName(this.containerPackageInfo) };\n\n\t\tif (isSharingLinkToRedeem) {\n\t\t\t// We need to remove the nav param if set by host when setting the sharelink as otherwise the shareLinkId\n\t\t\t// when redeeming the share link during the redeem fallback for trees latest call becomes greater than\n\t\t\t// the eligible length.\n\t\t\todspResolvedUrl.shareLinkInfo = Object.assign(odspResolvedUrl.shareLinkInfo ?? {}, {\n\t\t\t\tsharingLinkToRedeem: this.removeNavParam(request.url),\n\t\t\t\tisRedemptionNonDurable: isRedemptionNonDurable ?? false,\n\t\t\t});\n\t\t}\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\t// Kick start the sharing link request if we don't have it already as a performance optimization.\n\t\t\t// For detached create new, we don't have an item id yet and therefore cannot generate a share link\n\t\t\tthis.getShareLinkPromise(odspResolvedUrl).catch(() => {});\n\t\t}\n\t\treturn odspResolvedUrl;\n\t}\n\n\tprivate removeNavParam(link: string): string {\n\t\tconst url = new URL(link);\n\t\tconst params = new URLSearchParams(url.search);\n\t\tparams.delete(locatorQueryParamName);\n\t\turl.search = params.toString();\n\t\treturn url.href;\n\t}\n\n\tprivate async getShareLinkPromise(resolvedUrl: IOdspResolvedUrl): Promise<string> {\n\t\tif (this.shareLinkFetcherProps === undefined) {\n\t\t\tthrow new Error(\"Failed to get share link because share link fetcher props are missing\");\n\t\t}\n\n\t\tif (!(resolvedUrl.siteUrl && resolvedUrl.driveId && resolvedUrl.itemId)) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Failed to get share link because necessary information is missing \" +\n\t\t\t\t\t\"(e.g. siteUrl, driveId or itemId)\",\n\t\t\t);\n\t\t}\n\n\t\tconst key = this.getKey(resolvedUrl);\n\t\tconst cachedLinkPromise = this.sharingLinkCache.get(key);\n\t\tif (cachedLinkPromise) {\n\t\t\treturn cachedLinkPromise;\n\t\t}\n\t\tconst newLinkPromise = getFileLink(\n\t\t\tthis.shareLinkFetcherProps.tokenFetcher,\n\t\t\tresolvedUrl,\n\t\t\tthis.logger,\n\t\t).catch((error) => {\n\t\t\t// This should imply that error is a non-retriable error.\n\t\t\tthis.logger.sendErrorEvent({ eventName: \"FluidFileUrlError\" }, error);\n\t\t\tthis.sharingLinkCache.remove(key);\n\t\t\tthrow error;\n\t\t});\n\t\tthis.sharingLinkCache.add(key, async () => newLinkPromise);\n\t\treturn newLinkPromise;\n\t}\n\n\t/**\n\t * Requests a driver + data store storage URL. Note that this method requires share link to be fetched\n\t * and it will throw in case share link fetcher props were not specified when instance was created.\n\t * @param resolvedUrl - The driver resolved URL\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @param packageInfoSource - optional, represents container package information to be included in url.\n\t */\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\tconst shareLink = await this.getShareLinkPromise(odspResolvedUrl);\n\n\t\treturn this.appendLocatorParams(shareLink, resolvedUrl, dataStorePath, packageInfoSource);\n\t}\n\n\t/**\n\t * Appends the store locator properties to the provided base URL. This function is useful for scenarios where an application\n\t * has a base URL (for example a sharing link) of the Fluid file, but does not have the locator information that would be used by Fluid\n\t * to load the file later.\n\t * @param baseUrl - The input URL on which the locator params will be appended.\n\t * @param resolvedUrl - odsp-driver's resolvedURL object.\n\t * @param dataStorePath - The relative data store path URL.\n\t * For requesting a driver URL, this value should always be '/'. If an empty string is passed, then dataStorePath\n\t * will be extracted from the resolved url if present.\n\t * @returns The provided base URL appended with odsp-specific locator information\n\t */\n\tpublic async appendLocatorParams(\n\t\tbaseUrl: string,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tdataStorePath: string,\n\t\tpackageInfoSource?: IContainerPackageInfo,\n\t): Promise<string> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\t\t// If the user has passed an empty dataStorePath, then extract it from the resolved url.\n\t\tconst actualDataStorePath = dataStorePath || (odspResolvedUrl.dataStorePath ?? \"\");\n\n\t\todspResolvedUrl.context = await this.getContext?.(odspResolvedUrl, actualDataStorePath);\n\n\t\t/**\n\t\t * containerPackageName can be provided by various ways, in the order of priority:\n\t\t * 1. packageInfoSource - passed by the call of appendLocatorParams\n\t\t * 2. odspResolvedUrl.codeHint?.containerPackageName - passed by the odsp-driver's resolvedURL object\n\t\t * 3. this.containerPackageInfo - passed by the constructor of OdspDrvierUrlResolverForShareLink\n\t\t * */\n\t\tconst containerPackageName: string | undefined =\n\t\t\tgetContainerPackageName(packageInfoSource) ??\n\t\t\todspResolvedUrl.codeHint?.containerPackageName ??\n\t\t\tgetContainerPackageName(this.containerPackageInfo);\n\n\t\todspResolvedUrl.appName = this.appName;\n\n\t\treturn appendNavParam(baseUrl, odspResolvedUrl, actualDataStorePath, containerPackageName);\n\t}\n\n\t/**\n\t * Crafts a supported document/driver URL\n\t */\n\tpublic static createDocumentUrl(\n\t\tbaseUrl: string,\n\t\tdriverInfo: OdspFluidDataStoreLocator,\n\t): string {\n\t\tconst url = new URL(baseUrl);\n\n\t\tstoreLocatorInOdspUrl(url, driverInfo);\n\n\t\treturn url.href;\n\t}\n}\n"]}
@@ -8,14 +8,14 @@ import type { OdspFluidDataStoreLocator } from "./contractsPublic.js";
8
8
  * @param locator - describes Fluid data store locator info to be encoded
9
9
  * @returns string representing encoded Fluid data store locator info
10
10
  * @legacy
11
- * @alpha
11
+ * @beta
12
12
  */
13
13
  export declare function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string;
14
14
  /**
15
15
  * This parameter is provided by host in the resolve request and it contains information about the file
16
16
  * like driveId, itemId, siteUrl, datastorePath, packageName etc.
17
17
  * @legacy
18
- * @alpha
18
+ * @beta
19
19
  */
20
20
  export declare const locatorQueryParamName = "nav";
21
21
  /**
@@ -23,7 +23,7 @@ export declare const locatorQueryParamName = "nav";
23
23
  * @param url - file url in ODSP format (can be either canonical or share link)
24
24
  * @param locator - object representing Fluid data store location in ODSP terms
25
25
  * @legacy
26
- * @alpha
26
+ * @beta
27
27
  */
28
28
  export declare function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator): void;
29
29
  /**
@@ -33,7 +33,7 @@ export declare function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataSt
33
33
  * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
34
34
  * @returns object representing Fluid data store location in ODSP terms
35
35
  * @legacy
36
- * @alpha
36
+ * @beta
37
37
  */
38
38
  export declare function getLocatorFromOdspUrl(url: URL, requireFluidSignature?: boolean): OdspFluidDataStoreLocator | undefined;
39
39
  //# sourceMappingURL=odspFluidFileLink.d.ts.map