@fluidframework/odsp-driver 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.203917

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 (259) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/api-extractor.json +1 -1
  3. package/api-report/odsp-driver.api.md +306 -0
  4. package/dist/ReadBufferUtils.js +3 -3
  5. package/dist/ReadBufferUtils.js.map +1 -1
  6. package/dist/checkUrl.d.ts +1 -0
  7. package/dist/checkUrl.d.ts.map +1 -1
  8. package/dist/checkUrl.js +1 -0
  9. package/dist/checkUrl.js.map +1 -1
  10. package/dist/compactSnapshotParser.d.ts +2 -0
  11. package/dist/compactSnapshotParser.d.ts.map +1 -1
  12. package/dist/compactSnapshotParser.js +1 -0
  13. package/dist/compactSnapshotParser.js.map +1 -1
  14. package/dist/constants.d.ts +6 -0
  15. package/dist/constants.d.ts.map +1 -1
  16. package/dist/constants.js +6 -0
  17. package/dist/constants.js.map +1 -1
  18. package/dist/contracts.d.ts +3 -3
  19. package/dist/contracts.d.ts.map +1 -1
  20. package/dist/contractsPublic.d.ts +15 -0
  21. package/dist/contractsPublic.d.ts.map +1 -1
  22. package/dist/contractsPublic.js +8 -2
  23. package/dist/contractsPublic.js.map +1 -1
  24. package/dist/createOdspCreateContainerRequest.d.ts +1 -0
  25. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  26. package/dist/createOdspCreateContainerRequest.js +1 -0
  27. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  28. package/dist/createOdspUrl.d.ts +1 -0
  29. package/dist/createOdspUrl.d.ts.map +1 -1
  30. package/dist/createOdspUrl.js +1 -0
  31. package/dist/createOdspUrl.js.map +1 -1
  32. package/dist/epochTracker.d.ts +12 -2
  33. package/dist/epochTracker.d.ts.map +1 -1
  34. package/dist/epochTracker.js +1 -0
  35. package/dist/epochTracker.js.map +1 -1
  36. package/dist/fetch.d.ts +1 -1
  37. package/dist/fetch.d.ts.map +1 -1
  38. package/dist/fetchSnapshot.d.ts +1 -0
  39. package/dist/fetchSnapshot.d.ts.map +1 -1
  40. package/dist/fetchSnapshot.js +15 -11
  41. package/dist/fetchSnapshot.js.map +1 -1
  42. package/dist/index.d.ts +5 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +3 -1
  45. package/dist/index.js.map +1 -1
  46. package/dist/odsp-driver-alpha.d.ts +558 -0
  47. package/dist/odsp-driver-beta.d.ts +558 -0
  48. package/dist/odsp-driver-public.d.ts +558 -0
  49. package/dist/odsp-driver-untrimmed.d.ts +558 -0
  50. package/dist/odspCache.d.ts +6 -0
  51. package/dist/odspCache.d.ts.map +1 -1
  52. package/dist/odspCache.js.map +1 -1
  53. package/dist/odspDocumentDeltaConnection.d.ts +1 -1
  54. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  55. package/dist/odspDocumentDeltaConnection.js +78 -69
  56. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  57. package/dist/odspDocumentService.js +23 -19
  58. package/dist/odspDocumentService.js.map +1 -1
  59. package/dist/odspDocumentServiceFactory.d.ts +4 -0
  60. package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
  61. package/dist/odspDocumentServiceFactory.js +4 -0
  62. package/dist/odspDocumentServiceFactory.js.map +1 -1
  63. package/dist/odspDocumentServiceFactoryCore.d.ts +1 -0
  64. package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  65. package/dist/odspDocumentServiceFactoryCore.js +32 -27
  66. package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
  67. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
  68. package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  69. package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
  70. package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  71. package/dist/odspDocumentStorageManager.js +5 -1
  72. package/dist/odspDocumentStorageManager.js.map +1 -1
  73. package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
  74. package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
  75. package/dist/odspDocumentStorageServiceBase.js +1 -14
  76. package/dist/odspDocumentStorageServiceBase.js.map +1 -1
  77. package/dist/odspDriverUrlResolver.d.ts +1 -0
  78. package/dist/odspDriverUrlResolver.d.ts.map +1 -1
  79. package/dist/odspDriverUrlResolver.js +2 -0
  80. package/dist/odspDriverUrlResolver.js.map +1 -1
  81. package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -0
  82. package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  83. package/dist/odspDriverUrlResolverForShareLink.js +1 -0
  84. package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
  85. package/dist/odspFluidFileLink.d.ts +10 -1
  86. package/dist/odspFluidFileLink.d.ts.map +1 -1
  87. package/dist/odspFluidFileLink.js +14 -6
  88. package/dist/odspFluidFileLink.js.map +1 -1
  89. package/dist/odspPublicUtils.d.ts +6 -0
  90. package/dist/odspPublicUtils.d.ts.map +1 -1
  91. package/dist/odspPublicUtils.js +3 -0
  92. package/dist/odspPublicUtils.js.map +1 -1
  93. package/dist/odspSummaryUploadManager.js +5 -1
  94. package/dist/odspSummaryUploadManager.js.map +1 -1
  95. package/dist/odspUrlHelper.d.ts +5 -0
  96. package/dist/odspUrlHelper.d.ts.map +1 -1
  97. package/dist/odspUrlHelper.js +5 -0
  98. package/dist/odspUrlHelper.js.map +1 -1
  99. package/dist/odspUtils.d.ts +4 -1
  100. package/dist/odspUtils.d.ts.map +1 -1
  101. package/dist/odspUtils.js +1 -0
  102. package/dist/odspUtils.js.map +1 -1
  103. package/dist/opsCaching.d.ts +1 -1
  104. package/dist/opsCaching.d.ts.map +1 -1
  105. package/dist/opsCaching.js +13 -1
  106. package/dist/opsCaching.js.map +1 -1
  107. package/dist/packageVersion.d.ts +1 -1
  108. package/dist/packageVersion.js +1 -1
  109. package/dist/packageVersion.js.map +1 -1
  110. package/dist/prefetchLatestSnapshot.d.ts +2 -0
  111. package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
  112. package/dist/prefetchLatestSnapshot.js +2 -0
  113. package/dist/prefetchLatestSnapshot.js.map +1 -1
  114. package/dist/socketModule.d.ts +7 -0
  115. package/dist/socketModule.d.ts.map +1 -0
  116. package/dist/socketModule.js +10 -0
  117. package/dist/socketModule.js.map +1 -0
  118. package/dist/tsdoc-metadata.json +1 -1
  119. package/dist/zipItDataRepresentationUtils.d.ts +2 -2
  120. package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
  121. package/dist/zipItDataRepresentationUtils.js +6 -6
  122. package/dist/zipItDataRepresentationUtils.js.map +1 -1
  123. package/lib/ReadBufferUtils.js +3 -3
  124. package/lib/ReadBufferUtils.js.map +1 -1
  125. package/lib/checkUrl.d.ts +1 -0
  126. package/lib/checkUrl.d.ts.map +1 -1
  127. package/lib/checkUrl.js +1 -0
  128. package/lib/checkUrl.js.map +1 -1
  129. package/lib/compactSnapshotParser.d.ts +2 -0
  130. package/lib/compactSnapshotParser.d.ts.map +1 -1
  131. package/lib/compactSnapshotParser.js +1 -0
  132. package/lib/compactSnapshotParser.js.map +1 -1
  133. package/lib/constants.d.ts +6 -0
  134. package/lib/constants.d.ts.map +1 -1
  135. package/lib/constants.js +6 -0
  136. package/lib/constants.js.map +1 -1
  137. package/lib/contracts.d.ts +3 -3
  138. package/lib/contracts.d.ts.map +1 -1
  139. package/lib/contractsPublic.d.ts +15 -0
  140. package/lib/contractsPublic.d.ts.map +1 -1
  141. package/lib/contractsPublic.js +6 -0
  142. package/lib/contractsPublic.js.map +1 -1
  143. package/lib/createOdspCreateContainerRequest.d.ts +1 -0
  144. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
  145. package/lib/createOdspCreateContainerRequest.js +1 -0
  146. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  147. package/lib/createOdspUrl.d.ts +1 -0
  148. package/lib/createOdspUrl.d.ts.map +1 -1
  149. package/lib/createOdspUrl.js +1 -0
  150. package/lib/createOdspUrl.js.map +1 -1
  151. package/lib/epochTracker.d.ts +12 -2
  152. package/lib/epochTracker.d.ts.map +1 -1
  153. package/lib/epochTracker.js +1 -0
  154. package/lib/epochTracker.js.map +1 -1
  155. package/lib/fetch.d.ts +1 -1
  156. package/lib/fetch.d.ts.map +1 -1
  157. package/lib/fetchSnapshot.d.ts +1 -0
  158. package/lib/fetchSnapshot.d.ts.map +1 -1
  159. package/lib/fetchSnapshot.js +14 -10
  160. package/lib/fetchSnapshot.js.map +1 -1
  161. package/lib/index.d.ts +5 -1
  162. package/lib/index.d.ts.map +1 -1
  163. package/lib/index.js +1 -0
  164. package/lib/index.js.map +1 -1
  165. package/lib/odspCache.d.ts +6 -0
  166. package/lib/odspCache.d.ts.map +1 -1
  167. package/lib/odspCache.js.map +1 -1
  168. package/lib/odspDocumentDeltaConnection.d.ts +1 -1
  169. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  170. package/lib/odspDocumentDeltaConnection.js +77 -68
  171. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  172. package/lib/odspDocumentService.js +18 -18
  173. package/lib/odspDocumentService.js.map +1 -1
  174. package/lib/odspDocumentServiceFactory.d.ts +4 -0
  175. package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
  176. package/lib/odspDocumentServiceFactory.js +4 -0
  177. package/lib/odspDocumentServiceFactory.js.map +1 -1
  178. package/lib/odspDocumentServiceFactoryCore.d.ts +1 -0
  179. package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
  180. package/lib/odspDocumentServiceFactoryCore.js +27 -26
  181. package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
  182. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
  183. package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
  184. package/lib/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
  185. package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
  186. package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
  187. package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
  188. package/lib/odspDocumentStorageServiceBase.js +1 -14
  189. package/lib/odspDocumentStorageServiceBase.js.map +1 -1
  190. package/lib/odspDriverUrlResolver.d.ts +1 -0
  191. package/lib/odspDriverUrlResolver.d.ts.map +1 -1
  192. package/lib/odspDriverUrlResolver.js +2 -0
  193. package/lib/odspDriverUrlResolver.js.map +1 -1
  194. package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -0
  195. package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
  196. package/lib/odspDriverUrlResolverForShareLink.js +1 -0
  197. package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
  198. package/lib/odspFluidFileLink.d.ts +10 -1
  199. package/lib/odspFluidFileLink.d.ts.map +1 -1
  200. package/lib/odspFluidFileLink.js +14 -6
  201. package/lib/odspFluidFileLink.js.map +1 -1
  202. package/lib/odspPublicUtils.d.ts +6 -0
  203. package/lib/odspPublicUtils.d.ts.map +1 -1
  204. package/lib/odspPublicUtils.js +3 -0
  205. package/lib/odspPublicUtils.js.map +1 -1
  206. package/lib/odspUrlHelper.d.ts +5 -0
  207. package/lib/odspUrlHelper.d.ts.map +1 -1
  208. package/lib/odspUrlHelper.js +5 -0
  209. package/lib/odspUrlHelper.js.map +1 -1
  210. package/lib/odspUtils.d.ts +4 -1
  211. package/lib/odspUtils.d.ts.map +1 -1
  212. package/lib/odspUtils.js +1 -0
  213. package/lib/odspUtils.js.map +1 -1
  214. package/lib/opsCaching.d.ts +1 -1
  215. package/lib/opsCaching.d.ts.map +1 -1
  216. package/lib/opsCaching.js +13 -1
  217. package/lib/opsCaching.js.map +1 -1
  218. package/lib/packageVersion.d.ts +1 -1
  219. package/lib/packageVersion.js +1 -1
  220. package/lib/packageVersion.js.map +1 -1
  221. package/lib/prefetchLatestSnapshot.d.ts +2 -0
  222. package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
  223. package/lib/prefetchLatestSnapshot.js +2 -0
  224. package/lib/prefetchLatestSnapshot.js.map +1 -1
  225. package/lib/socketModule.d.ts +7 -0
  226. package/lib/socketModule.d.ts.map +1 -0
  227. package/lib/socketModule.js +7 -0
  228. package/lib/socketModule.js.map +1 -0
  229. package/lib/zipItDataRepresentationUtils.d.ts +2 -2
  230. package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
  231. package/lib/zipItDataRepresentationUtils.js +3 -3
  232. package/lib/zipItDataRepresentationUtils.js.map +1 -1
  233. package/package.json +24 -26
  234. package/src/checkUrl.ts +1 -0
  235. package/src/compactSnapshotParser.ts +2 -0
  236. package/src/constants.ts +7 -0
  237. package/src/contractsPublic.ts +15 -1
  238. package/src/createOdspCreateContainerRequest.ts +1 -0
  239. package/src/createOdspUrl.ts +1 -0
  240. package/src/epochTracker.ts +10 -0
  241. package/src/fetchSnapshot.ts +16 -15
  242. package/src/index.ts +10 -1
  243. package/src/odspCache.ts +6 -0
  244. package/src/odspDocumentDeltaConnection.ts +56 -32
  245. package/src/odspDocumentServiceFactory.ts +4 -0
  246. package/src/odspDocumentServiceFactoryCore.ts +1 -0
  247. package/src/odspDocumentServiceFactoryWithCodeSplit.ts +2 -1
  248. package/src/odspDocumentStorageServiceBase.ts +1 -15
  249. package/src/odspDriverUrlResolver.ts +2 -0
  250. package/src/odspDriverUrlResolverForShareLink.ts +2 -0
  251. package/src/odspFluidFileLink.ts +21 -5
  252. package/src/odspPublicUtils.ts +6 -0
  253. package/src/odspUrlHelper.ts +5 -0
  254. package/src/odspUtils.ts +4 -0
  255. package/src/opsCaching.ts +15 -1
  256. package/src/packageVersion.ts +1 -1
  257. package/src/prefetchLatestSnapshot.ts +2 -0
  258. package/src/socketModule.ts +8 -0
  259. package/src/zipItDataRepresentationUtils.ts +5 -1
@@ -22,12 +22,13 @@ import {
22
22
  ISequencedDocumentMessage,
23
23
  ISignalMessage,
24
24
  } from "@fluidframework/protocol-definitions";
25
- import { Socket, io as SocketIOClientStatic } from "socket.io-client";
25
+ import { Socket } from "socket.io-client";
26
26
  import { v4 as uuid } from "uuid";
27
27
  import { createGenericNetworkError } from "@fluidframework/driver-utils";
28
28
  import { IOdspSocketError, IGetOpsResponse, IFlushOpsResponse } from "./contracts";
29
29
  import { EpochTracker } from "./epochTracker";
30
30
  import { errorObjectFromSocketError } from "./odspError";
31
+ import { SocketIOClientStatic } from "./socketModule";
31
32
  import { pkgVersion } from "./packageVersion";
32
33
 
33
34
  const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
@@ -118,7 +119,10 @@ class SocketReference extends TypedEventEmitter<ISocketEvents> {
118
119
  return this._socket;
119
120
  }
120
121
 
121
- public constructor(public readonly key: string, socket: Socket) {
122
+ public constructor(
123
+ public readonly key: string,
124
+ socket: Socket,
125
+ ) {
122
126
  super();
123
127
 
124
128
  this._socket = socket;
@@ -128,28 +132,33 @@ class SocketReference extends TypedEventEmitter<ISocketEvents> {
128
132
  // Server sends this event when it wants to disconnect a particular client in which case the client id would
129
133
  // be present or if it wants to disconnect all the clients. The server always closes the socket in case all
130
134
  // clients needs to be disconnected. So fully remove the socket reference in this case.
131
- socket.on("server_disconnect", (socketError: IOdspSocketError, clientId?: string) => {
132
- // Treat all errors as recoverable, and rely on joinSession / reconnection flow to
133
- // filter out retryable vs. non-retryable cases.
134
- const error = errorObjectFromSocketError(socketError, "server_disconnect");
135
- error.addTelemetryProperties({ disconnectClientId: clientId });
136
- error.canRetry = true;
137
-
138
- // see comment in disconnected() getter
139
- // Setting it here to ensure socket reuse does not happen if new request to connect
140
- // comes in from "disconnect" listener below, before we close socket.
141
- this.isPendingInitialConnection = false;
142
-
143
- if (clientId === undefined) {
144
- // We could first raise "disconnect" event, but that may result in socket reuse due to
145
- // new connection comming in. So, it's better to have more explicit flow to make it impossible.
146
- this.closeSocket(error);
147
- } else {
148
- this.emit("disconnect", error, clientId);
149
- }
150
- });
135
+ socket.on("server_disconnect", this.serverDisconnectEventHandler);
151
136
  }
152
137
 
138
+ private readonly serverDisconnectEventHandler = (
139
+ socketError: IOdspSocketError,
140
+ clientId?: string,
141
+ ) => {
142
+ // Treat all errors as recoverable, and rely on joinSession / reconnection flow to
143
+ // filter out retryable vs. non-retryable cases.
144
+ const error = errorObjectFromSocketError(socketError, "server_disconnect");
145
+ error.addTelemetryProperties({ disconnectClientId: clientId });
146
+ error.canRetry = true;
147
+
148
+ // see comment in disconnected() getter
149
+ // Setting it here to ensure socket reuse does not happen if new request to connect
150
+ // comes in from "disconnect" listener below, before we close socket.
151
+ this.isPendingInitialConnection = false;
152
+
153
+ if (clientId === undefined) {
154
+ // We could first raise "disconnect" event, but that may result in socket reuse due to
155
+ // new connection comming in. So, it's better to have more explicit flow to make it impossible.
156
+ this.closeSocket(error);
157
+ } else {
158
+ this.emit("disconnect", error, clientId);
159
+ }
160
+ };
161
+
153
162
  private clearTimer() {
154
163
  if (this.delayDeleteTimeout !== undefined) {
155
164
  clearTimeout(this.delayDeleteTimeout);
@@ -162,6 +171,7 @@ class SocketReference extends TypedEventEmitter<ISocketEvents> {
162
171
  return;
163
172
  }
164
173
 
174
+ this._socket.off("server_disconnect", this.serverDisconnectEventHandler);
165
175
  this.clearTimer();
166
176
 
167
177
  assert(
@@ -526,23 +536,30 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
526
536
  }
527
537
  };
528
538
 
529
- this.earlySignalHandler = (msg: ISignalMessage, messageDocumentId?: string) => {
539
+ this.earlySignalHandler = (
540
+ msg: ISignalMessage | ISignalMessage[],
541
+ messageDocumentId?: string,
542
+ ) => {
530
543
  if (messageDocumentId === undefined || messageDocumentId === this.documentId) {
531
- this.queuedSignals.push(msg);
544
+ if (Array.isArray(msg)) {
545
+ this.queuedSignals.push(...msg);
546
+ } else {
547
+ this.queuedSignals.push(msg);
548
+ }
532
549
  }
533
550
  };
534
551
  }
535
552
 
536
553
  this.socketReference!.on("disconnect", this.disconnectHandler);
537
554
 
538
- this.socket.on("get_ops_response", (result: IGetOpsResponse) => {
555
+ this.addTrackedListener("get_ops_response", (result: IGetOpsResponse) => {
539
556
  const messages = result.messages;
540
557
  const data = this.getOpsMap.get(result.nonce);
541
558
  // Due to socket multiplexing, this client may not have asked for any data
542
559
  // If so, there it most likely does not need these ops (otherwise it already asked for them)
543
560
  // Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.
544
561
  // But not processing such result may push us into infinite loop of fast requests and dropping all responses
545
- if (data !== undefined || result.nonce.indexOf(this.requestOpsNoncePrefix) === 0) {
562
+ if (data !== undefined || result.nonce.startsWith(this.requestOpsNoncePrefix)) {
546
563
  this.getOpsMap.delete(result.nonce);
547
564
  const common = {
548
565
  eventName: "GetOps",
@@ -570,7 +587,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
570
587
  }
571
588
  });
572
589
 
573
- this.socket.on("flush_ops_response", (result: IFlushOpsResponse) => {
590
+ this.addTrackedListener("flush_ops_response", (result: IFlushOpsResponse) => {
574
591
  if (this.flushOpNonce === result.nonce) {
575
592
  const seq = result.lastPersistedSequenceNumber;
576
593
  let category: "generic" | "error" = "generic";
@@ -624,11 +641,18 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
624
641
 
625
642
  case "signal":
626
643
  // per document signal handling
627
- super.addTrackedListener(event, (msg: ISignalMessage, documentId?: string) => {
628
- if (!this.enableMultiplexing || !documentId || documentId === this.documentId) {
629
- listener(msg, documentId);
630
- }
631
- });
644
+ super.addTrackedListener(
645
+ event,
646
+ (msg: ISignalMessage | ISignalMessage[], documentId?: string) => {
647
+ if (
648
+ !this.enableMultiplexing ||
649
+ !documentId ||
650
+ documentId === this.documentId
651
+ ) {
652
+ listener(msg, documentId);
653
+ }
654
+ },
655
+ );
632
656
  break;
633
657
 
634
658
  case "nack":
@@ -17,6 +17,7 @@ import { LocalOdspDocumentServiceFactory } from "./localOdspDriver/localOdspDocu
17
17
  /**
18
18
  * Factory for creating the sharepoint document service. Use this if you want to
19
19
  * use the sharepoint implementation.
20
+ * @public
20
21
  */
21
22
  export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
22
23
  constructor(
@@ -29,6 +30,9 @@ export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
29
30
  }
30
31
  }
31
32
 
33
+ /**
34
+ * @public
35
+ */
32
36
  export function createLocalOdspDocumentServiceFactory(
33
37
  localSnapshot: Uint8Array | string,
34
38
  ): IDocumentServiceFactory {
@@ -50,6 +50,7 @@ import {
50
50
  *
51
51
  * This constructor should be used by environments that support dynamic imports and that wish
52
52
  * to leverage code splitting as a means to keep bundles as small as possible.
53
+ * @public
53
54
  */
54
55
  export class OdspDocumentServiceFactoryCore
55
56
  implements IDocumentServiceFactory, IRelaySessionAwareDriverFactory
@@ -13,8 +13,9 @@ import {
13
13
  import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore";
14
14
 
15
15
  /**
16
- * @deprecated - This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the
16
+ * @deprecated This is deprecated in favour of OdspDocumentServiceFactory as the socket io is now loaded inside the
17
17
  * other dynamically imported module.
18
+ * @public
18
19
  */
19
20
  export class OdspDocumentServiceFactoryWithCodeSplit
20
21
  extends OdspDocumentServiceFactoryCore
@@ -131,18 +131,6 @@ export abstract class OdspDocumentStorageServiceBase implements IDocumentStorage
131
131
  this.policies = {
132
132
  // By default, ODSP tells the container not to prefetch/cache.
133
133
  caching: LoaderCachingPolicy.NoCaching,
134
-
135
- // ODSP storage works better if it has less number of blobs / edges
136
- // Runtime creating many small blobs results in sub-optimal perf.
137
- // 2K seems like the sweat spot:
138
- // The smaller the number, less blobs we aggregate. Most storages are very likely to have notion
139
- // of minimal "cluster" size, so having small blobs is wasteful
140
- // At the same time increasing the limit ensure that more blobs with user content are aggregated,
141
- // reducing possibility for de-duping of same blobs (i.e. .attributes rolled into aggregate blob
142
- // are not reused across data stores, or even within data store, resulting in duplication of content)
143
- // Note that duplication of content should not have significant impact for bytes over wire as
144
- // compression of http payload mostly takes care of it, but it does impact storage size and in-memory sizes.
145
- minBlobSize: 2048,
146
134
  maximumCacheDurationMs: maximumCacheDurationMsInEffect,
147
135
  };
148
136
  }
@@ -169,9 +157,7 @@ export abstract class OdspDocumentStorageServiceBase implements IDocumentStorage
169
157
  return this._snapshotSequenceNumber;
170
158
  }
171
159
 
172
- public get repositoryUrl(): string {
173
- return "";
174
- }
160
+ public readonly repositoryUrl = "";
175
161
 
176
162
  public abstract createBlob(file: ArrayBufferLike): Promise<api.ICreateBlobResponse>;
177
163
 
@@ -80,6 +80,7 @@ function removeBeginningSlash(str: string): string {
80
80
  /**
81
81
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
82
82
  * url format. Ex: `${siteUrl}?driveId=${driveId}&itemId=${itemId}&path=${path}`
83
+ * @public
83
84
  */
84
85
  export class OdspDriverUrlResolver implements IUrlResolver {
85
86
  constructor() {}
@@ -94,6 +95,7 @@ export class OdspDriverUrlResolver implements IUrlResolver {
94
95
  const filePath = searchParams.get("path");
95
96
  const packageName = searchParams.get("containerPackageName");
96
97
  const createLinkType = searchParams.get("createLinkType");
98
+ // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- false positive
97
99
  if (!(fileName && siteURL && driveID && filePath !== null && filePath !== undefined)) {
98
100
  throw new NonRetryableError(
99
101
  "Proper new file params should be there!!",
@@ -30,6 +30,7 @@ import { getFileLink } from "./getFileLink";
30
30
 
31
31
  /**
32
32
  * Properties passed to the code responsible for fetching share link for a file.
33
+ * @public
33
34
  */
34
35
  export interface ShareLinkFetcherProps {
35
36
  /**
@@ -46,6 +47,7 @@ export interface ShareLinkFetcherProps {
46
47
  * Resolver to resolve urls like the ones created by createOdspUrl which is driver inner
47
48
  * url format and the ones which have things like driveId, siteId, itemId etc encoded in nav param.
48
49
  * This resolver also handles share links and try to generate one for the use by the app.
50
+ * @public
49
51
  */
50
52
  export class OdspDriverUrlResolverForShareLink implements IUrlResolver {
51
53
  private readonly logger: ITelemetryLoggerExt;
@@ -22,6 +22,7 @@ const additionalContextParamName = "x";
22
22
  * Transforms given Fluid data store locator into string that can be embedded into url
23
23
  * @param locator - describes Fluid data store locator info to be encoded
24
24
  * @returns string representing encoded Fluid data store locator info
25
+ * @public
25
26
  */
26
27
  export function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocator): string {
27
28
  const siteUrl = new URL(locator.siteUrl);
@@ -56,16 +57,18 @@ export function encodeOdspFluidDataStoreLocator(locator: OdspFluidDataStoreLocat
56
57
  * @param encodedLocatorValue - encoded Fluid data store locator value which was produced by
57
58
  * {@link encodeOdspFluidDataStoreLocator} function
58
59
  * @param siteOriginUrl - site origin that will be appended to encoded relative path to form absolute file url
60
+ * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
59
61
  * @returns object representing Fluid data store location in ODSP terms
60
62
  */
61
63
  function decodeOdspFluidDataStoreLocator(
62
64
  encodedLocatorValue: string,
63
65
  siteOriginUrl: string,
66
+ requireFluidSignature: boolean = true,
64
67
  ): OdspFluidDataStoreLocator | undefined {
65
68
  const locatorInfo = new URLSearchParams(fromBase64ToUtf8(encodedLocatorValue));
66
69
 
67
70
  const signatureValue = locatorInfo.get(fluidSignatureParamName);
68
- if (signatureValue !== "1") {
71
+ if (requireFluidSignature && signatureValue !== "1") {
69
72
  return undefined;
70
73
  }
71
74
 
@@ -106,14 +109,18 @@ function decodeOdspFluidDataStoreLocator(
106
109
  };
107
110
  }
108
111
 
109
- // This parameter is provided by host in the resolve request and it contains information about the file
110
- // like driveId, itemId, siteUrl, datastorePath, packageName etc.
112
+ /**
113
+ * This parameter is provided by host in the resolve request and it contains information about the file
114
+ * like driveId, itemId, siteUrl, datastorePath, packageName etc.
115
+ * @public
116
+ */
111
117
  export const locatorQueryParamName = "nav";
112
118
 
113
119
  /**
114
120
  * Embeds Fluid data store locator data into given ODSP url
115
121
  * @param url - file url in ODSP format (can be either canonical or share link)
116
122
  * @param locator - object representing Fluid data store location in ODSP terms
123
+ * @public
117
124
  */
118
125
  export function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocator) {
119
126
  const encodedLocatorValue = encodeOdspFluidDataStoreLocator(locator);
@@ -126,9 +133,14 @@ export function storeLocatorInOdspUrl(url: URL, locator: OdspFluidDataStoreLocat
126
133
  * Extract ODSP Fluid data store locator object from given ODSP url. This extracts things like
127
134
  * driveId, ItemId, siteUrl etc from a url where these are encoded in nav query param.
128
135
  * @param url - ODSP url representing Fluid file link
136
+ * @param requireFluidSignature - flag representing if the Fluid signature is expected in the url, default true
129
137
  * @returns object representing Fluid data store location in ODSP terms
138
+ * @public
130
139
  */
131
- export function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | undefined {
140
+ export function getLocatorFromOdspUrl(
141
+ url: URL,
142
+ requireFluidSignature: boolean = true,
143
+ ): OdspFluidDataStoreLocator | undefined {
132
144
  // NOTE: No need to apply decodeURIComponent when accessing query params via URLSearchParams class.
133
145
  const encodedLocatorValue = url.searchParams.get(locatorQueryParamName);
134
146
  if (!encodedLocatorValue) {
@@ -140,5 +152,9 @@ export function getLocatorFromOdspUrl(url: URL): OdspFluidDataStoreLocator | und
140
152
  const siteOriginUrl =
141
153
  url.origin.toLowerCase() === OdcFileSiteOrigin ? OdcApiSiteOrigin : url.origin;
142
154
 
143
- return decodeOdspFluidDataStoreLocator(encodedLocatorValue, siteOriginUrl);
155
+ return decodeOdspFluidDataStoreLocator(
156
+ encodedLocatorValue,
157
+ siteOriginUrl,
158
+ requireFluidSignature,
159
+ );
144
160
  }
@@ -6,11 +6,17 @@
6
6
  import { hashFile, IsoBuffer } from "@fluid-internal/client-utils";
7
7
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
8
8
 
9
+ /**
10
+ * @public
11
+ */
9
12
  export async function getHashedDocumentId(driveId: string, itemId: string): Promise<string> {
10
13
  const buffer = IsoBuffer.from(`${driveId}_${itemId}`);
11
14
  return encodeURIComponent(await hashFile(buffer, "SHA-256", "base64"));
12
15
  }
13
16
 
17
+ /**
18
+ * @public
19
+ */
14
20
  export interface ISnapshotContents {
15
21
  snapshotTree: ISnapshotTree;
16
22
  blobs: Map<string, ArrayBuffer>;
@@ -10,6 +10,7 @@ import { IOdspUrlParts } from "@fluidframework/odsp-driver-definitions";
10
10
  /**
11
11
  * Checks whether or not the given URL origin is an ODC origin
12
12
  * @param origin - The URL origin to check
13
+ * @public
13
14
  */
14
15
  export function isOdcOrigin(origin: string): boolean {
15
16
  return (
@@ -27,6 +28,7 @@ export function isOdcOrigin(origin: string): boolean {
27
28
  /**
28
29
  * Gets the correct API root for the given ODSP url, e.g. 'https://foo-my.sharepoint.com/_api/v2.1'
29
30
  * @param origin - The URL origin
31
+ * @public
30
32
  */
31
33
  export function getApiRoot(origin: string): string {
32
34
  let prefix = "_api/";
@@ -40,6 +42,7 @@ export function getApiRoot(origin: string): string {
40
42
  /**
41
43
  * Whether or not the given URL is a valid SPO/ODB URL
42
44
  * @param url - The URL to check
45
+ * @public
43
46
  */
44
47
  export function isSpoUrl(url: string): boolean {
45
48
  const urlLower = url.toLowerCase();
@@ -52,6 +55,7 @@ export function isSpoUrl(url: string): boolean {
52
55
  /**
53
56
  * Whether or not the given URL is a valid ODC URL
54
57
  * @param url - The URL to check
58
+ * @public
55
59
  */
56
60
  export function isOdcUrl(url: string | URL): boolean {
57
61
  const urlObj = typeof url === "string" ? new URL(url) : url;
@@ -76,6 +80,7 @@ export function isOdcUrl(url: string | URL): boolean {
76
80
  * Breaks an ODSP URL into its parts, extracting the site, drive ID, and item ID.
77
81
  * Returns undefined for invalid/malformed URLs.
78
82
  * @param url - The (raw) URL to parse
83
+ * @public
79
84
  */
80
85
  export async function getOdspUrlParts(url: URL): Promise<IOdspUrlParts | undefined> {
81
86
  const pathname = url.pathname;
package/src/odspUtils.ts CHANGED
@@ -50,6 +50,9 @@ export const getWithRetryForTokenRefreshRepeat = "getWithRetryForTokenRefreshRep
50
50
  /** Parse the given url and return the origin (host name) */
51
51
  export const getOrigin = (url: string) => new URL(url).origin;
52
52
 
53
+ /**
54
+ * @public
55
+ */
53
56
  export interface IOdspResponse<T> {
54
57
  content: T;
55
58
  headers: Map<string, string>;
@@ -441,6 +444,7 @@ export function buildOdspShareLinkReqParams(
441
444
  }
442
445
  const scope = (shareLinkType as ISharingLinkKind).scope;
443
446
  if (!scope) {
447
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
444
448
  return `createLinkType=${shareLinkType}`;
445
449
  }
446
450
  let shareLinkRequestParams = `createLinkScope=${scope}`;
package/src/opsCaching.ts CHANGED
@@ -65,7 +65,14 @@ export class OpsCache {
65
65
 
66
66
  public flushOps() {
67
67
  for (const [key, value] of this.batches) {
68
- if (value === null || !value.dirty) {
68
+ // Don't flush if the batch has no ops, already flushed or has empty slots at both beginning and end.
69
+ if (
70
+ value === null ||
71
+ !value.dirty ||
72
+ value.batchData.length === 0 ||
73
+ (value.batchData[0] === undefined &&
74
+ value.batchData[value.batchData.length - 1] === undefined)
75
+ ) {
69
76
  continue;
70
77
  }
71
78
  value.dirty = false;
@@ -138,6 +145,7 @@ export class OpsCache {
138
145
  return messages;
139
146
  }
140
147
  const result: CacheEntry = JSON.parse(res);
148
+ const prevMessagesLength = messages.length;
141
149
  for (const op of result) {
142
150
  // Note that we write out undefined, but due to JSON.stringify, it turns into null!
143
151
  if (op) {
@@ -153,10 +161,16 @@ export class OpsCache {
153
161
  }
154
162
  messages.push(op);
155
163
  } else if (messages.length !== 0) {
164
+ // If there is any gap, return the messages till now.
156
165
  return messages;
157
166
  }
158
167
  }
159
168
 
169
+ // If we didn't get any op from this batch, then return messages till now. As it tells us that,
170
+ // either the first message "from" is not present in cache or a gap will occur from 1 batch to next.
171
+ if (prevMessagesLength === messages.length) {
172
+ return messages;
173
+ }
160
174
  batchNumber++;
161
175
  }
162
176
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/odsp-driver";
9
- export const pkgVersion = "2.0.0-dev.6.4.0.192049";
9
+ export const pkgVersion = "2.0.0-dev.7.2.0.203917";
@@ -52,6 +52,8 @@ import { OdspDocumentServiceFactory } from "./odspDocumentServiceFactory";
52
52
  * @param odspDocumentServiceFactory - factory to access the non persistent cache and store the prefetch promise.
53
53
  *
54
54
  * @returns `true` if the snapshot is cached, `false` otherwise.
55
+ *
56
+ * @public
55
57
  */
56
58
  export async function prefetchLatestSnapshot(
57
59
  resolvedUrl: IResolvedUrl,
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { io } from "socket.io-client";
7
+
8
+ export const SocketIOClientStatic = io;
@@ -206,7 +206,11 @@ export class BlobShallowCopy extends BlobCore {
206
206
  * @param start - Start point of the blob in the buffer.
207
207
  * @param end - End point of the blob in the buffer.
208
208
  */
209
- constructor(protected data: Uint8Array, protected start: number, protected end: number) {
209
+ constructor(
210
+ protected data: Uint8Array,
211
+ protected start: number,
212
+ protected end: number,
213
+ ) {
210
214
  super();
211
215
  }
212
216