@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.
- package/CHANGELOG.md +66 -0
- package/api-extractor.json +1 -1
- package/api-report/odsp-driver.api.md +306 -0
- package/dist/ReadBufferUtils.js +3 -3
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/checkUrl.d.ts +1 -0
- package/dist/checkUrl.d.ts.map +1 -1
- package/dist/checkUrl.js +1 -0
- package/dist/checkUrl.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts +2 -0
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +1 -0
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -1
- package/dist/contracts.d.ts +3 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contractsPublic.d.ts +15 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/contractsPublic.js +8 -2
- package/dist/contractsPublic.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts +1 -0
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +1 -0
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/createOdspUrl.d.ts +1 -0
- package/dist/createOdspUrl.d.ts.map +1 -1
- package/dist/createOdspUrl.js +1 -0
- package/dist/createOdspUrl.js.map +1 -1
- package/dist/epochTracker.d.ts +12 -2
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +1 -0
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetchSnapshot.d.ts +1 -0
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +15 -11
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/odsp-driver-alpha.d.ts +558 -0
- package/dist/odsp-driver-beta.d.ts +558 -0
- package/dist/odsp-driver-public.d.ts +558 -0
- package/dist/odsp-driver-untrimmed.d.ts +558 -0
- package/dist/odspCache.d.ts +6 -0
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +78 -69
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.js +23 -19
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.d.ts +4 -0
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +4 -0
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +1 -0
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +32 -27
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
- package/dist/odspDocumentStorageManager.js +5 -1
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +1 -14
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts +1 -0
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +2 -0
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -0
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +1 -0
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.d.ts +10 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspFluidFileLink.js +14 -6
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspPublicUtils.d.ts +6 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/odspPublicUtils.js +3 -0
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSummaryUploadManager.js +5 -1
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.d.ts +5 -0
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/odspUrlHelper.js +5 -0
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/odspUtils.d.ts +4 -1
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +1 -0
- package/dist/odspUtils.js.map +1 -1
- package/dist/opsCaching.d.ts +1 -1
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/opsCaching.js +13 -1
- package/dist/opsCaching.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/prefetchLatestSnapshot.d.ts +2 -0
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +2 -0
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/socketModule.d.ts +7 -0
- package/dist/socketModule.d.ts.map +1 -0
- package/dist/socketModule.js +10 -0
- package/dist/socketModule.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts +2 -2
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +6 -6
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/ReadBufferUtils.js +3 -3
- package/lib/ReadBufferUtils.js.map +1 -1
- package/lib/checkUrl.d.ts +1 -0
- package/lib/checkUrl.d.ts.map +1 -1
- package/lib/checkUrl.js +1 -0
- package/lib/checkUrl.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +2 -0
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +1 -0
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/constants.d.ts +6 -0
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +6 -0
- package/lib/constants.js.map +1 -1
- package/lib/contracts.d.ts +3 -3
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contractsPublic.d.ts +15 -0
- package/lib/contractsPublic.d.ts.map +1 -1
- package/lib/contractsPublic.js +6 -0
- package/lib/contractsPublic.js.map +1 -1
- package/lib/createOdspCreateContainerRequest.d.ts +1 -0
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/lib/createOdspCreateContainerRequest.js +1 -0
- package/lib/createOdspCreateContainerRequest.js.map +1 -1
- package/lib/createOdspUrl.d.ts +1 -0
- package/lib/createOdspUrl.d.ts.map +1 -1
- package/lib/createOdspUrl.js +1 -0
- package/lib/createOdspUrl.js.map +1 -1
- package/lib/epochTracker.d.ts +12 -2
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +1 -0
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetch.d.ts +1 -1
- package/lib/fetch.d.ts.map +1 -1
- package/lib/fetchSnapshot.d.ts +1 -0
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +14 -10
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/odspCache.d.ts +6 -0
- package/lib/odspCache.d.ts.map +1 -1
- package/lib/odspCache.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +77 -68
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.js +18 -18
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactory.d.ts +4 -0
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactory.js +4 -0
- package/lib/odspDocumentServiceFactory.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +1 -0
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +27 -26
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/lib/odspDocumentStorageServiceBase.js +1 -14
- package/lib/odspDocumentStorageServiceBase.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts +1 -0
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +2 -0
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -0
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +1 -0
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.d.ts +10 -1
- package/lib/odspFluidFileLink.d.ts.map +1 -1
- package/lib/odspFluidFileLink.js +14 -6
- package/lib/odspFluidFileLink.js.map +1 -1
- package/lib/odspPublicUtils.d.ts +6 -0
- package/lib/odspPublicUtils.d.ts.map +1 -1
- package/lib/odspPublicUtils.js +3 -0
- package/lib/odspPublicUtils.js.map +1 -1
- package/lib/odspUrlHelper.d.ts +5 -0
- package/lib/odspUrlHelper.d.ts.map +1 -1
- package/lib/odspUrlHelper.js +5 -0
- package/lib/odspUrlHelper.js.map +1 -1
- package/lib/odspUtils.d.ts +4 -1
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +1 -0
- package/lib/odspUtils.js.map +1 -1
- package/lib/opsCaching.d.ts +1 -1
- package/lib/opsCaching.d.ts.map +1 -1
- package/lib/opsCaching.js +13 -1
- package/lib/opsCaching.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/prefetchLatestSnapshot.d.ts +2 -0
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +2 -0
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/lib/socketModule.d.ts +7 -0
- package/lib/socketModule.d.ts.map +1 -0
- package/lib/socketModule.js +7 -0
- package/lib/socketModule.js.map +1 -0
- package/lib/zipItDataRepresentationUtils.d.ts +2 -2
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +3 -3
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +24 -26
- package/src/checkUrl.ts +1 -0
- package/src/compactSnapshotParser.ts +2 -0
- package/src/constants.ts +7 -0
- package/src/contractsPublic.ts +15 -1
- package/src/createOdspCreateContainerRequest.ts +1 -0
- package/src/createOdspUrl.ts +1 -0
- package/src/epochTracker.ts +10 -0
- package/src/fetchSnapshot.ts +16 -15
- package/src/index.ts +10 -1
- package/src/odspCache.ts +6 -0
- package/src/odspDocumentDeltaConnection.ts +56 -32
- package/src/odspDocumentServiceFactory.ts +4 -0
- package/src/odspDocumentServiceFactoryCore.ts +1 -0
- package/src/odspDocumentServiceFactoryWithCodeSplit.ts +2 -1
- package/src/odspDocumentStorageServiceBase.ts +1 -15
- package/src/odspDriverUrlResolver.ts +2 -0
- package/src/odspDriverUrlResolverForShareLink.ts +2 -0
- package/src/odspFluidFileLink.ts +21 -5
- package/src/odspPublicUtils.ts +6 -0
- package/src/odspUrlHelper.ts +5 -0
- package/src/odspUtils.ts +4 -0
- package/src/opsCaching.ts +15 -1
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +2 -0
- package/src/socketModule.ts +8 -0
- 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
|
|
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(
|
|
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",
|
|
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 = (
|
|
539
|
+
this.earlySignalHandler = (
|
|
540
|
+
msg: ISignalMessage | ISignalMessage[],
|
|
541
|
+
messageDocumentId?: string,
|
|
542
|
+
) => {
|
|
530
543
|
if (messageDocumentId === undefined || messageDocumentId === this.documentId) {
|
|
531
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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(
|
|
628
|
-
|
|
629
|
-
|
|
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
|
|
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
|
|
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;
|
package/src/odspFluidFileLink.ts
CHANGED
|
@@ -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
|
-
|
|
110
|
-
|
|
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(
|
|
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(
|
|
155
|
+
return decodeOdspFluidDataStoreLocator(
|
|
156
|
+
encodedLocatorValue,
|
|
157
|
+
siteOriginUrl,
|
|
158
|
+
requireFluidSignature,
|
|
159
|
+
);
|
|
144
160
|
}
|
package/src/odspPublicUtils.ts
CHANGED
|
@@ -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>;
|
package/src/odspUrlHelper.ts
CHANGED
|
@@ -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
|
|
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
|
}
|
package/src/packageVersion.ts
CHANGED
|
@@ -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,
|
|
@@ -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(
|
|
209
|
+
constructor(
|
|
210
|
+
protected data: Uint8Array,
|
|
211
|
+
protected start: number,
|
|
212
|
+
protected end: number,
|
|
213
|
+
) {
|
|
210
214
|
super();
|
|
211
215
|
}
|
|
212
216
|
|