@fluidframework/odsp-driver 1.1.0 → 1.2.0-77818
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/dist/contractsPublic.d.ts +1 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/contractsPublic.js.map +1 -1
- package/dist/localOdspDriver/localOdspDocumentService.d.ts +26 -0
- package/dist/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentService.js +39 -0
- package/dist/localOdspDriver/localOdspDocumentService.js.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js +45 -0
- package/dist/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js +66 -0
- package/dist/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/odspDocumentService.d.ts.map +1 -1
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.d.ts +2 -1
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +7 -1
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +3 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +5 -23
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +52 -245
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +58 -0
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -0
- package/dist/odspDocumentStorageServiceBase.js +216 -0
- package/dist/odspDocumentStorageServiceBase.js.map +1 -0
- package/dist/odspDriverUrlResolver.js +1 -1
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +8 -2
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +11 -3
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspFluidFileLink.js +27 -21
- package/dist/odspFluidFileLink.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/lib/contractsPublic.d.ts +1 -0
- package/lib/contractsPublic.d.ts.map +1 -1
- package/lib/contractsPublic.js.map +1 -1
- package/lib/localOdspDriver/localOdspDocumentService.d.ts +26 -0
- package/lib/localOdspDriver/localOdspDocumentService.d.ts.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentService.js +35 -0
- package/lib/localOdspDriver/localOdspDocumentService.js.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts +24 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.d.ts.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js +41 -0
- package/lib/localOdspDriver/localOdspDocumentServiceFactory.js.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts +27 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.d.ts.map +1 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js +62 -0
- package/lib/localOdspDriver/localOdspDocumentStorageManager.js.map +1 -0
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/odspDocumentService.d.ts.map +1 -1
- package/lib/odspDocumentService.js +1 -1
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactory.d.ts +2 -1
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactory.js +5 -0
- package/lib/odspDocumentServiceFactory.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +3 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +5 -23
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +53 -246
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts +58 -0
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -0
- package/lib/odspDocumentStorageServiceBase.js +212 -0
- package/lib/odspDocumentStorageServiceBase.js.map +1 -0
- package/lib/odspDriverUrlResolver.js +1 -1
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +8 -2
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +11 -3
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.d.ts.map +1 -1
- package/lib/odspFluidFileLink.js +27 -21
- package/lib/odspFluidFileLink.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/package.json +11 -11
- package/src/contractsPublic.ts +1 -0
- package/src/localOdspDriver/localOdspDocumentService.ts +54 -0
- package/src/localOdspDriver/localOdspDocumentServiceFactory.ts +67 -0
- package/src/localOdspDriver/localOdspDocumentStorageManager.ts +83 -0
- package/src/odspDeltaStorageService.ts +1 -1
- package/src/odspDocumentService.ts +5 -1
- package/src/odspDocumentServiceFactory.ts +7 -3
- package/src/odspDocumentServiceFactoryCore.ts +1 -1
- package/src/odspDocumentStorageManager.ts +81 -312
- package/src/odspDocumentStorageServiceBase.ts +268 -0
- package/src/odspDriverUrlResolver.ts +1 -1
- package/src/odspDriverUrlResolverForShareLink.ts +13 -1
- package/src/odspFluidFileLink.ts +26 -22
- package/src/packageVersion.ts +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IDocumentService, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
7
|
+
import { UsageError } from "@fluidframework/driver-utils";
|
|
8
|
+
import { TelemetryLogger } from "@fluidframework/telemetry-utils";
|
|
9
|
+
import { ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
10
|
+
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
11
|
+
import { createOdspLogger, getOdspResolvedUrl } from "../odspUtils";
|
|
12
|
+
import { ICacheAndTracker } from "../epochTracker";
|
|
13
|
+
import { OdspDocumentServiceFactoryCore } from "../odspDocumentServiceFactoryCore";
|
|
14
|
+
import { LocalOdspDocumentService } from "./localOdspDocumentService";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Factory for creating sharepoint document service with a provided snapshot.
|
|
18
|
+
* Use if you don't want to connect to any kind of external/internal storages and want to provide
|
|
19
|
+
* content directly.
|
|
20
|
+
*/
|
|
21
|
+
export class LocalOdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
|
|
22
|
+
private logger: TelemetryLogger | undefined;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
private readonly localSnapshot: Uint8Array | string,
|
|
26
|
+
) {
|
|
27
|
+
super(
|
|
28
|
+
(_options) => this.throwUnsupportedUsageError("Getting storage token"),
|
|
29
|
+
(_options) => this.throwUnsupportedUsageError("Getting websocket token"),
|
|
30
|
+
() => this.throwUnsupportedUsageError("Getting SocketIO Client"),
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private throwUnsupportedUsageError(unsupportedFuncName: string): never {
|
|
35
|
+
const toThrow = new UsageError(
|
|
36
|
+
`${unsupportedFuncName} is not supported by LocalOdspDocumentServiceFactory`);
|
|
37
|
+
this.logger?.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
38
|
+
throw toThrow;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public createContainer(
|
|
42
|
+
_createNewSummary: ISummaryTree | undefined,
|
|
43
|
+
_createNewResolvedUrl: IResolvedUrl,
|
|
44
|
+
logger?: ITelemetryBaseLogger,
|
|
45
|
+
_clientIsSummarizer?: boolean,
|
|
46
|
+
): never {
|
|
47
|
+
const toThrow = new UsageError("\"createContainer\" is not supported by LocalOdspDocumentServiceFactory");
|
|
48
|
+
createOdspLogger(logger).sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
49
|
+
throw toThrow;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected async createDocumentServiceCore(
|
|
53
|
+
resolvedUrl: IResolvedUrl,
|
|
54
|
+
odspLogger: TelemetryLogger,
|
|
55
|
+
_cacheAndTrackerArg?: ICacheAndTracker,
|
|
56
|
+
_clientIsSummarizer?: boolean,
|
|
57
|
+
): Promise<IDocumentService> {
|
|
58
|
+
if (_cacheAndTrackerArg !== undefined) {
|
|
59
|
+
throw new UsageError("Invalid usage. \"_cacheAndTrackerArg\" should not be provided");
|
|
60
|
+
}
|
|
61
|
+
if (_clientIsSummarizer) {
|
|
62
|
+
throw new UsageError("Invalid usage. \"_clientIsSummarizer\" should not be provided");
|
|
63
|
+
}
|
|
64
|
+
this.logger = odspLogger;
|
|
65
|
+
return new LocalOdspDocumentService(getOdspResolvedUrl(resolvedUrl), odspLogger, this.localSnapshot);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { assert } from "@fluidframework/common-utils";
|
|
7
|
+
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
8
|
+
import { ISummaryContext } from "@fluidframework/driver-definitions";
|
|
9
|
+
import { UsageError } from "@fluidframework/driver-utils";
|
|
10
|
+
import * as api from "@fluidframework/protocol-definitions";
|
|
11
|
+
import { OdspDocumentStorageServiceBase } from "../odspDocumentStorageServiceBase";
|
|
12
|
+
import { ISnapshotContents } from "../odspPublicUtils";
|
|
13
|
+
import { IOdspSnapshot } from "../contracts";
|
|
14
|
+
import { convertOdspSnapshotToSnapshotTreeAndBlobs } from "../odspSnapshotParser";
|
|
15
|
+
import { parseCompactSnapshotResponse } from "../compactSnapshotParser";
|
|
16
|
+
import { ReadBuffer } from "../ReadBufferUtils";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* ODSP document storage service that works on a provided snapshot for all its processing.
|
|
20
|
+
* Attempting to use unsupported actions/methods will result in errors being thrown.
|
|
21
|
+
*/
|
|
22
|
+
export class LocalOdspDocumentStorageService extends OdspDocumentStorageServiceBase {
|
|
23
|
+
private snapshotTreeId: string | undefined;
|
|
24
|
+
|
|
25
|
+
constructor(
|
|
26
|
+
private readonly logger: ITelemetryLogger,
|
|
27
|
+
private readonly localSnapshot: Uint8Array | string,
|
|
28
|
+
) {
|
|
29
|
+
super();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private calledGetVersions = false;
|
|
33
|
+
|
|
34
|
+
public async getVersions(blobid: string | null, count: number, _scenarioName?: string): Promise<api.IVersion[]> {
|
|
35
|
+
assert(blobid === null, "Invalid usage. \"blobid\" should always be null");
|
|
36
|
+
assert(count === 1, "Invalid usage. \"count\" should always be 1");
|
|
37
|
+
|
|
38
|
+
// No reason to re-parse the data since it will never change
|
|
39
|
+
if (this.calledGetVersions) {
|
|
40
|
+
return this.getSnapshotVersion();
|
|
41
|
+
}
|
|
42
|
+
this.calledGetVersions = true;
|
|
43
|
+
|
|
44
|
+
let snapshotContents: ISnapshotContents;
|
|
45
|
+
|
|
46
|
+
if (typeof this.localSnapshot === "string") {
|
|
47
|
+
const content: IOdspSnapshot = JSON.parse(this.localSnapshot);
|
|
48
|
+
snapshotContents = convertOdspSnapshotToSnapshotTreeAndBlobs(content);
|
|
49
|
+
} else {
|
|
50
|
+
snapshotContents = parseCompactSnapshotResponse(
|
|
51
|
+
new ReadBuffer(this.localSnapshot));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.snapshotTreeId = this.initializeFromSnapshot(snapshotContents);
|
|
55
|
+
return this.getSnapshotVersion();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private getSnapshotVersion(): api.IVersion[] {
|
|
59
|
+
return this.snapshotTreeId ? [{ id: this.snapshotTreeId, treeId: undefined! }] : [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected fetchTreeFromSnapshot(_id: string, _scenarioName?: string): never {
|
|
63
|
+
this.throwUsageError("fetchTreeFromSnapshot");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected fetchBlobFromStorage(_blobId: string, _evicted: boolean): never {
|
|
67
|
+
this.throwUsageError("fetchBlobFromStorage");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public uploadSummaryWithContext(_summary: api.ISummaryTree, _context: ISummaryContext): never {
|
|
71
|
+
this.throwUsageError("uploadSummaryWithContext");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public createBlob(_file: ArrayBufferLike): never {
|
|
75
|
+
this.throwUsageError("createBlob");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private throwUsageError(methodName: string): never {
|
|
79
|
+
const toThrow = new UsageError(`"${methodName}" is not supported by LocalOdspDocumentStorageService`);
|
|
80
|
+
this.logger.sendErrorEvent({ eventName: "UnsupportedUsage" }, toThrow);
|
|
81
|
+
throw toThrow;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -21,7 +21,11 @@ import {
|
|
|
21
21
|
IDocumentServicePolicies,
|
|
22
22
|
DriverErrorType,
|
|
23
23
|
} from "@fluidframework/driver-definitions";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
canRetryOnError,
|
|
26
|
+
DeltaStreamConnectionForbiddenError,
|
|
27
|
+
NonRetryableError,
|
|
28
|
+
} from "@fluidframework/driver-utils";
|
|
25
29
|
import { IFacetCodes } from "@fluidframework/odsp-doclib-utils";
|
|
26
30
|
import {
|
|
27
31
|
IClient,
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
} from "@fluidframework/odsp-driver-definitions";
|
|
13
13
|
import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore";
|
|
14
14
|
import { getSocketIo } from "./getSocketIo";
|
|
15
|
+
// eslint-disable-next-line import/no-internal-modules
|
|
16
|
+
import { LocalOdspDocumentServiceFactory } from "./localOdspDriver/localOdspDocumentServiceFactory";
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Factory for creating the sharepoint document service. Use this if you want to
|
|
18
20
|
* use the sharepoint implementation.
|
|
19
21
|
*/
|
|
20
|
-
export class OdspDocumentServiceFactory
|
|
21
|
-
extends OdspDocumentServiceFactoryCore
|
|
22
|
-
implements IDocumentServiceFactory {
|
|
22
|
+
export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
|
|
23
23
|
constructor(
|
|
24
24
|
getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,
|
|
25
25
|
getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,
|
|
@@ -35,3 +35,7 @@ export class OdspDocumentServiceFactory
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
+
|
|
39
|
+
export function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory {
|
|
40
|
+
return new LocalOdspDocumentServiceFactory(localSnapshot);
|
|
41
|
+
}
|
|
@@ -174,7 +174,7 @@ export class OdspDocumentServiceFactoryCore implements IDocumentServiceFactory {
|
|
|
174
174
|
return this.createDocumentServiceCore(resolvedUrl, createOdspLogger(logger), undefined, clientIsSummarizer);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
protected async createDocumentServiceCore(
|
|
178
178
|
resolvedUrl: IResolvedUrl,
|
|
179
179
|
odspLogger: TelemetryLogger,
|
|
180
180
|
cacheAndTrackerArg?: ICacheAndTracker,
|