@fluidframework/odsp-driver 0.59.4001 → 1.1.0-75972
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/.eslintrc.js +1 -1
- package/dist/compactSnapshotParser.d.ts +1 -1
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +7 -4
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +4 -3
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/contracts.d.ts +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/createFile.d.ts.map +1 -1
- package/dist/createFile.js.map +1 -1
- package/dist/createNewUtils.d.ts +1 -1
- package/dist/createNewUtils.d.ts.map +1 -1
- package/dist/createNewUtils.js +1 -0
- package/dist/createNewUtils.js.map +1 -1
- package/dist/epochTracker.d.ts +3 -2
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +10 -4
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetchSnapshot.d.ts +7 -6
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +57 -31
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +18 -17
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js +8 -4
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +2 -2
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +2 -3
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +13 -17
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspError.d.ts +3 -1
- package/dist/odspError.d.ts.map +1 -1
- package/dist/odspError.js +14 -5
- package/dist/odspError.js.map +1 -1
- package/dist/odspPublicUtils.d.ts +14 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSnapshotParser.d.ts +2 -2
- package/dist/odspSnapshotParser.d.ts.map +1 -1
- package/dist/odspSnapshotParser.js +7 -4
- package/dist/odspSnapshotParser.js.map +1 -1
- package/dist/odspSummaryUploadManager.d.ts.map +1 -1
- package/dist/odspSummaryUploadManager.js +1 -4
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUtils.d.ts +0 -7
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +4 -3
- package/dist/odspUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retryErrorsStorageAdapter.d.ts +1 -2
- package/dist/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/dist/retryErrorsStorageAdapter.js +0 -3
- package/dist/retryErrorsStorageAdapter.js.map +1 -1
- package/dist/retryUtils.d.ts.map +1 -1
- package/dist/retryUtils.js +2 -3
- package/dist/retryUtils.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +7 -4
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +4 -3
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/contracts.d.ts +1 -1
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js.map +1 -1
- package/lib/createNewUtils.d.ts +1 -1
- package/lib/createNewUtils.d.ts.map +1 -1
- package/lib/createNewUtils.js +1 -0
- package/lib/createNewUtils.js.map +1 -1
- package/lib/epochTracker.d.ts +3 -2
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +10 -4
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetchSnapshot.d.ts +7 -6
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +58 -33
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +18 -17
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +9 -5
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +2 -2
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +2 -3
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +13 -17
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspError.d.ts +3 -1
- package/lib/odspError.d.ts.map +1 -1
- package/lib/odspError.js +14 -5
- package/lib/odspError.js.map +1 -1
- package/lib/odspPublicUtils.d.ts +14 -0
- package/lib/odspPublicUtils.d.ts.map +1 -1
- package/lib/odspPublicUtils.js.map +1 -1
- package/lib/odspSnapshotParser.d.ts +2 -2
- package/lib/odspSnapshotParser.d.ts.map +1 -1
- package/lib/odspSnapshotParser.js +5 -2
- package/lib/odspSnapshotParser.js.map +1 -1
- package/lib/odspSummaryUploadManager.d.ts.map +1 -1
- package/lib/odspSummaryUploadManager.js +1 -4
- package/lib/odspSummaryUploadManager.js.map +1 -1
- package/lib/odspUtils.d.ts +0 -7
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +4 -3
- package/lib/odspUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/retryErrorsStorageAdapter.d.ts +1 -2
- package/lib/retryErrorsStorageAdapter.d.ts.map +1 -1
- package/lib/retryErrorsStorageAdapter.js +0 -3
- package/lib/retryErrorsStorageAdapter.js.map +1 -1
- package/lib/retryUtils.d.ts.map +1 -1
- package/lib/retryUtils.js +3 -4
- package/lib/retryUtils.js.map +1 -1
- package/package.json +15 -28
- package/src/compactSnapshotParser.ts +10 -4
- package/src/compactSnapshotWriter.ts +7 -4
- package/src/contracts.ts +1 -1
- package/src/createFile.ts +2 -2
- package/src/createNewUtils.ts +2 -1
- package/src/epochTracker.ts +10 -3
- package/src/fetchSnapshot.ts +113 -67
- package/src/index.ts +4 -0
- package/src/odspDocumentDeltaConnection.ts +18 -18
- package/src/odspDocumentService.ts +7 -3
- package/src/odspDocumentServiceFactoryCore.ts +4 -2
- package/src/odspDocumentStorageManager.ts +18 -21
- package/src/odspError.ts +23 -10
- package/src/odspPublicUtils.ts +17 -0
- package/src/odspSnapshotParser.ts +8 -3
- package/src/odspSummaryUploadManager.ts +1 -4
- package/src/odspUtils.ts +4 -11
- package/src/packageVersion.ts +1 -1
- package/src/retryErrorsStorageAdapter.ts +0 -8
- package/src/retryUtils.ts +3 -4
package/src/odspError.ts
CHANGED
|
@@ -4,20 +4,33 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { createOdspNetworkError } from "@fluidframework/odsp-doclib-utils";
|
|
7
|
+
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
8
|
+
import { NonRetryableError } from "@fluidframework/driver-utils";
|
|
9
|
+
import { OdspError } from "@fluidframework/odsp-driver-definitions";
|
|
10
|
+
import { IFluidErrorBase } from "@fluidframework/telemetry-utils";
|
|
7
11
|
import { IOdspSocketError } from "./contracts";
|
|
12
|
+
import { pkgVersion as driverVersion } from "./packageVersion";
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Returns network error based on error object from ODSP socket (IOdspSocketError)
|
|
11
16
|
*/
|
|
12
|
-
export function errorObjectFromSocketError(socketError: IOdspSocketError, handler: string)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
message
|
|
17
|
-
socketError.
|
|
18
|
-
|
|
17
|
+
export function errorObjectFromSocketError(socketError: IOdspSocketError, handler: string):
|
|
18
|
+
IFluidErrorBase & OdspError {
|
|
19
|
+
// Make sure we always return something, and do not throw.
|
|
20
|
+
try {
|
|
21
|
+
// pre-0.58 error message prefix: OdspSocketError
|
|
22
|
+
const message = `ODSP socket error (${handler}): ${socketError.message}`;
|
|
23
|
+
const error = createOdspNetworkError(
|
|
24
|
+
message,
|
|
25
|
+
socketError.code,
|
|
26
|
+
socketError.retryAfter);
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
error.addTelemetryProperties({ odspError: true, relayServiceError: true });
|
|
29
|
+
return error;
|
|
30
|
+
} catch (error) {
|
|
31
|
+
return new NonRetryableError(
|
|
32
|
+
"Internal error: errorObjectFromSocketError",
|
|
33
|
+
DriverErrorType.fileNotFoundOrAccessDeniedError,
|
|
34
|
+
{ driverVersion });
|
|
35
|
+
}
|
|
23
36
|
}
|
package/src/odspPublicUtils.ts
CHANGED
|
@@ -4,8 +4,25 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { hashFile, IsoBuffer } from "@fluidframework/common-utils";
|
|
7
|
+
import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
7
8
|
|
|
8
9
|
export async function getHashedDocumentId(driveId: string, itemId: string): Promise<string> {
|
|
9
10
|
const buffer = IsoBuffer.from(`${driveId}_${itemId}`);
|
|
10
11
|
return encodeURIComponent(await hashFile(buffer, "SHA-256", "base64"));
|
|
11
12
|
}
|
|
13
|
+
|
|
14
|
+
export interface ISnapshotContents {
|
|
15
|
+
snapshotTree: ISnapshotTree;
|
|
16
|
+
blobs: Map<string, ArrayBuffer>;
|
|
17
|
+
ops: ISequencedDocumentMessage[];
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Sequence number of the snapshot
|
|
21
|
+
*/
|
|
22
|
+
sequenceNumber: number | undefined;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Sequence number for the latest op/snapshot for the file in ODSP
|
|
26
|
+
*/
|
|
27
|
+
latestSequenceNumber: number | undefined;
|
|
28
|
+
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { assert, stringToBuffer } from "@fluidframework/common-utils";
|
|
7
7
|
import * as api from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { IOdspSnapshot, IOdspSnapshotCommit, ISnapshotTreeEx } from "./contracts";
|
|
9
|
-
import { ISnapshotContents } from "./
|
|
9
|
+
import { ISnapshotContents } from "./odspPublicUtils";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Build a tree hierarchy base on a flat tree
|
|
@@ -51,7 +51,7 @@ function buildHierarchy(flatTree: IOdspSnapshotCommit): api.ISnapshotTree {
|
|
|
51
51
|
* Converts existing IOdspSnapshot to snapshot tree, blob array and ops
|
|
52
52
|
* @param odspSnapshot - snapshot
|
|
53
53
|
*/
|
|
54
|
-
export function
|
|
54
|
+
export function convertOdspSnapshotToSnapshotTreeAndBlobs(
|
|
55
55
|
odspSnapshot: IOdspSnapshot,
|
|
56
56
|
): ISnapshotContents {
|
|
57
57
|
const blobsWithBufferContent = new Map<string, ArrayBuffer>();
|
|
@@ -62,11 +62,16 @@ export function convertOdspSnapshotToSnapsohtTreeAndBlobs(
|
|
|
62
62
|
blobsWithBufferContent.set(blob.id, stringToBuffer(blob.content, blob.encoding ?? "utf8"));
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
const sequenceNumber = odspSnapshot?.trees[0].sequenceNumber;
|
|
67
|
+
|
|
65
68
|
const val: ISnapshotContents = {
|
|
66
69
|
blobs: blobsWithBufferContent,
|
|
67
70
|
ops: odspSnapshot.ops?.map((op) => op.op) ?? [],
|
|
68
|
-
sequenceNumber
|
|
71
|
+
sequenceNumber,
|
|
69
72
|
snapshotTree: buildHierarchy(odspSnapshot.trees[0]),
|
|
73
|
+
latestSequenceNumber: (odspSnapshot.ops && odspSnapshot.ops.length > 0) ?
|
|
74
|
+
odspSnapshot.ops[odspSnapshot.ops.length - 1].sequenceNumber : sequenceNumber,
|
|
70
75
|
};
|
|
71
76
|
return val;
|
|
72
77
|
}
|
|
@@ -69,9 +69,7 @@ export class OdspSummaryUploadManager {
|
|
|
69
69
|
referenceSequenceNumber: number,
|
|
70
70
|
tree: api.ISummaryTree,
|
|
71
71
|
): Promise<IWriteSummaryResponse> {
|
|
72
|
-
const
|
|
73
|
-
const containsProtocolTree = enableContainerTypeSummaryUpload &&
|
|
74
|
-
Object.keys(tree.tree).includes(".protocol");
|
|
72
|
+
const containsProtocolTree = Object.keys(tree.tree).includes(".protocol");
|
|
75
73
|
const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(
|
|
76
74
|
parentHandle,
|
|
77
75
|
tree,
|
|
@@ -112,7 +110,6 @@ export class OdspSummaryUploadManager {
|
|
|
112
110
|
size: postBody.length,
|
|
113
111
|
referenceSequenceNumber,
|
|
114
112
|
type: snapshot.type,
|
|
115
|
-
enableContainerTypeSummaryUpload,
|
|
116
113
|
},
|
|
117
114
|
async () => {
|
|
118
115
|
const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(
|
package/src/odspUtils.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
NetworkErrorBasic,
|
|
14
14
|
} from "@fluidframework/driver-utils";
|
|
15
15
|
import { assert, performance } from "@fluidframework/common-utils";
|
|
16
|
-
import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
17
16
|
import { ChildLogger, PerformanceEvent, wrapError } from "@fluidframework/telemetry-utils";
|
|
18
17
|
import {
|
|
19
18
|
fetchIncorrectResponse,
|
|
@@ -43,13 +42,6 @@ export const getWithRetryForTokenRefreshRepeat = "getWithRetryForTokenRefreshRep
|
|
|
43
42
|
/** Parse the given url and return the origin (host name) */
|
|
44
43
|
export const getOrigin = (url: string) => new URL(url).origin;
|
|
45
44
|
|
|
46
|
-
export interface ISnapshotContents {
|
|
47
|
-
snapshotTree: ISnapshotTree;
|
|
48
|
-
blobs: Map<string, ArrayBuffer>;
|
|
49
|
-
ops: ISequencedDocumentMessage[];
|
|
50
|
-
sequenceNumber: number | undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
45
|
export interface IOdspResponse<T> {
|
|
54
46
|
content: T;
|
|
55
47
|
headers: Map<string, string>;
|
|
@@ -243,7 +235,8 @@ export const createOdspLogger = (logger?: ITelemetryBaseLogger) =>
|
|
|
243
235
|
ChildLogger.create(
|
|
244
236
|
logger,
|
|
245
237
|
"OdspDriver",
|
|
246
|
-
{
|
|
238
|
+
{
|
|
239
|
+
all:
|
|
247
240
|
{
|
|
248
241
|
driverVersion,
|
|
249
242
|
},
|
|
@@ -307,7 +300,7 @@ export function toInstrumentedOdspTokenFetcher(
|
|
|
307
300
|
if (token === null && throwOnNullToken) {
|
|
308
301
|
throw new NonRetryableError(
|
|
309
302
|
// pre-0.58 error message: Token is null for ${name} call
|
|
310
|
-
`The Host-provided token fetcher
|
|
303
|
+
`The Host-provided token fetcher returned null`,
|
|
311
304
|
OdspErrorType.fetchTokenError,
|
|
312
305
|
{ method: name, driverVersion });
|
|
313
306
|
}
|
|
@@ -319,7 +312,7 @@ export function toInstrumentedOdspTokenFetcher(
|
|
|
319
312
|
const tokenError = wrapError(
|
|
320
313
|
error,
|
|
321
314
|
(errorMessage) => new NetworkErrorBasic(
|
|
322
|
-
`The Host-provided token fetcher
|
|
315
|
+
`The Host-provided token fetcher threw an error: ${errorMessage}`,
|
|
323
316
|
OdspErrorType.fetchTokenError,
|
|
324
317
|
typeof rawCanRetry === "boolean" ? rawCanRetry : false /* canRetry */,
|
|
325
318
|
{ method: name, driverVersion }));
|
package/src/packageVersion.ts
CHANGED
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
ISnapshotTree,
|
|
15
15
|
ISummaryHandle,
|
|
16
16
|
ISummaryTree,
|
|
17
|
-
ITree,
|
|
18
17
|
IVersion,
|
|
19
18
|
} from "@fluidframework/protocol-definitions";
|
|
20
19
|
import { IDisposable, ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
@@ -61,13 +60,6 @@ export class RetryErrorsStorageAdapter implements IDocumentStorageService, IDisp
|
|
|
61
60
|
);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
public async write(tree: ITree, parents: string[], message: string, ref: string): Promise<IVersion> {
|
|
65
|
-
return this.runWithRetry(
|
|
66
|
-
async () => this.internalStorageService.write(tree, parents, message, ref),
|
|
67
|
-
"storage_write",
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
63
|
public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {
|
|
72
64
|
// Creation flow with attachment blobs - need to do retries!
|
|
73
65
|
return this.runWithRetry(
|
package/src/retryUtils.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
|
-
import {
|
|
7
|
+
import { delay, performance } from "@fluidframework/common-utils";
|
|
8
8
|
import { canRetryOnError } from "@fluidframework/driver-utils";
|
|
9
9
|
import { OdspErrorType } from "@fluidframework/odsp-driver-definitions";
|
|
10
10
|
import { Odsp409Error } from "./epochTracker";
|
|
@@ -43,8 +43,8 @@ export async function runWithRetry<T>(
|
|
|
43
43
|
|
|
44
44
|
const coherencyError = error?.[Odsp409Error] === true;
|
|
45
45
|
const serviceReadonlyError = error?.errorType === OdspErrorType.serviceReadOnly;
|
|
46
|
-
// Retry for 409 coherency errors or serviceReadOnly errors.
|
|
47
|
-
if (!(coherencyError || serviceReadonlyError)) {
|
|
46
|
+
// Retry for retriable 409 coherency errors or serviceReadOnly errors.
|
|
47
|
+
if (!(coherencyError || serviceReadonlyError || canRetry)) {
|
|
48
48
|
throw error;
|
|
49
49
|
}
|
|
50
50
|
|
|
@@ -66,7 +66,6 @@ export async function runWithRetry<T>(
|
|
|
66
66
|
throw error;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
assert(canRetry, 0x24d /* "can retry" */);
|
|
70
69
|
await delay(Math.floor(retryAfter));
|
|
71
70
|
retryAfter += retryAfter / 4 * (1 + Math.random());
|
|
72
71
|
lastError = error;
|