@fluidframework/local-driver 2.0.0-dev.3.1.0.125672 → 2.0.0-dev.4.1.0.148229
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/api-extractor.json +4 -0
- package/dist/localCreateDocument.d.ts +8 -0
- package/dist/localCreateDocument.d.ts.map +1 -0
- package/dist/localCreateDocument.js +29 -0
- package/dist/localCreateDocument.js.map +1 -0
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/localDocumentService.js +1 -1
- package/dist/localDocumentService.js.map +1 -1
- package/dist/localDocumentServiceFactory.d.ts +0 -1
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentServiceFactory.js +4 -21
- package/dist/localDocumentServiceFactory.js.map +1 -1
- package/dist/localDocumentStorageService.d.ts +5 -2
- package/dist/localDocumentStorageService.d.ts.map +1 -1
- package/dist/localDocumentStorageService.js +14 -1
- package/dist/localDocumentStorageService.js.map +1 -1
- package/dist/localSessionStorageDb.d.ts.map +1 -1
- package/dist/localSessionStorageDb.js +3 -0
- package/dist/localSessionStorageDb.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/lib/auth.d.ts +12 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +38 -0
- package/lib/auth.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/localCreateDocument.d.ts +8 -0
- package/lib/localCreateDocument.d.ts.map +1 -0
- package/lib/localCreateDocument.js +25 -0
- package/lib/localCreateDocument.js.map +1 -0
- package/lib/localDeltaStorageService.d.ts +19 -0
- package/lib/localDeltaStorageService.d.ts.map +1 -0
- package/lib/localDeltaStorageService.js +31 -0
- package/lib/localDeltaStorageService.js.map +1 -0
- package/lib/localDocumentDeltaConnection.d.ts +47 -0
- package/lib/localDocumentDeltaConnection.d.ts.map +1 -0
- package/lib/localDocumentDeltaConnection.js +88 -0
- package/lib/localDocumentDeltaConnection.js.map +1 -0
- package/lib/localDocumentService.d.ts +52 -0
- package/lib/localDocumentService.d.ts.map +1 -0
- package/lib/localDocumentService.js +80 -0
- package/lib/localDocumentService.js.map +1 -0
- package/lib/localDocumentServiceFactory.d.ts +43 -0
- package/lib/localDocumentServiceFactory.d.ts.map +1 -0
- package/lib/localDocumentServiceFactory.js +81 -0
- package/lib/localDocumentServiceFactory.js.map +1 -0
- package/lib/localDocumentStorageService.d.ts +27 -0
- package/lib/localDocumentStorageService.d.ts.map +1 -0
- package/lib/localDocumentStorageService.js +85 -0
- package/lib/localDocumentStorageService.js.map +1 -0
- package/lib/localResolver.d.ts +26 -0
- package/lib/localResolver.d.ts.map +1 -0
- package/lib/localResolver.js +70 -0
- package/lib/localResolver.js.map +1 -0
- package/lib/localSessionStorageDb.d.ts +10 -0
- package/lib/localSessionStorageDb.d.ts.map +1 -0
- package/lib/localSessionStorageDb.js +295 -0
- package/lib/localSessionStorageDb.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/package.json +57 -49
- package/src/localCreateDocument.ts +48 -0
- package/src/localDocumentService.ts +2 -0
- package/src/localDocumentServiceFactory.ts +6 -43
- package/src/localDocumentStorageService.ts +17 -0
- package/src/localSessionStorageDb.ts +3 -0
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +7 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, isCombinedAppAndProtocolSummary, } from "@fluidframework/driver-utils";
|
|
6
|
+
import { defaultHash } from "@fluidframework/server-services-client";
|
|
7
|
+
export async function createDocument(localDeltaConnectionServer, resolvedUrl, summary) {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
const pathName = new URL(resolvedUrl.url).pathname;
|
|
10
|
+
const pathArr = pathName.split("/");
|
|
11
|
+
const tenantId = pathArr[pathArr.length - 2];
|
|
12
|
+
const id = pathArr[pathArr.length - 1];
|
|
13
|
+
const documentStorage = localDeltaConnectionServer
|
|
14
|
+
.documentStorage;
|
|
15
|
+
if (!isCombinedAppAndProtocolSummary(summary)) {
|
|
16
|
+
throw new Error("Protocol and App Summary required in the full summary");
|
|
17
|
+
}
|
|
18
|
+
const protocolSummary = summary.tree[".protocol"];
|
|
19
|
+
const appSummary = summary.tree[".app"];
|
|
20
|
+
const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
|
|
21
|
+
const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
|
|
22
|
+
const sequenceNumber = documentAttributes.sequenceNumber;
|
|
23
|
+
await documentStorage.createDocument(tenantId, id, appSummary, sequenceNumber, (_a = documentAttributes.term) !== null && _a !== void 0 ? _a : 1, defaultHash, (_b = resolvedUrl.endpoints.ordererUrl) !== null && _b !== void 0 ? _b : "", (_c = resolvedUrl.endpoints.storageUrl) !== null && _c !== void 0 ? _c : "", (_d = resolvedUrl.endpoints.deltaStorageUrl) !== null && _d !== void 0 ? _d : "", quorumValues, false /* enableDiscovery */);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=localCreateDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localCreateDocument.js","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,cAAc,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ensed under the MIT License.\n */\n\nimport { IFluidResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IFluidResolvedUrl,\n\tsummary: ISummaryTree,\n) {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\tconst tenantId = pathArr[pathArr.length - 2];\n\tconst id = pathArr[pathArr.length - 1];\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdocumentAttributes.term ?? 1,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentDeltaStorageService, IStream } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { IDatabaseManager } from "@fluidframework/server-services-core";
|
|
8
|
+
/**
|
|
9
|
+
* Provides access to the underlying delta storage on the server for local driver.
|
|
10
|
+
*/
|
|
11
|
+
export declare class LocalDeltaStorageService implements IDocumentDeltaStorageService {
|
|
12
|
+
private readonly tenantId;
|
|
13
|
+
private readonly id;
|
|
14
|
+
private readonly databaseManager;
|
|
15
|
+
constructor(tenantId: string, id: string, databaseManager: IDatabaseManager);
|
|
16
|
+
fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<ISequencedDocumentMessage[]>;
|
|
17
|
+
private getCore;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=localDeltaStorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,4BAA4B;IAE3E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB;IAG5C,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAIzB,OAAO;CAcrB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { streamFromMessages } from "@fluidframework/driver-utils";
|
|
6
|
+
/**
|
|
7
|
+
* Provides access to the underlying delta storage on the server for local driver.
|
|
8
|
+
*/
|
|
9
|
+
export class LocalDeltaStorageService {
|
|
10
|
+
constructor(tenantId, id, databaseManager) {
|
|
11
|
+
this.tenantId = tenantId;
|
|
12
|
+
this.id = id;
|
|
13
|
+
this.databaseManager = databaseManager;
|
|
14
|
+
}
|
|
15
|
+
fetchMessages(from, to, abortSignal, cachedOnly) {
|
|
16
|
+
return streamFromMessages(this.getCore(from, to));
|
|
17
|
+
}
|
|
18
|
+
async getCore(from, to) {
|
|
19
|
+
const query = { documentId: this.id, tenantId: this.tenantId };
|
|
20
|
+
query["operation.sequenceNumber"] = {};
|
|
21
|
+
query["operation.sequenceNumber"].$gt = from - 1; // from is inclusive
|
|
22
|
+
// This looks like a bug. It used to work without setting $lt key. Now it does not
|
|
23
|
+
// Need follow up
|
|
24
|
+
query["operation.sequenceNumber"].$lt = to !== null && to !== void 0 ? to : Number.MAX_SAFE_INTEGER;
|
|
25
|
+
const allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);
|
|
26
|
+
const dbDeltas = await allDeltas.find(query, { "operation.sequenceNumber": 1 });
|
|
27
|
+
const messages = dbDeltas.map((delta) => delta.operation);
|
|
28
|
+
return messages;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=localDeltaStorageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;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C;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number) {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { DocumentDeltaConnection } from "@fluidframework/driver-base";
|
|
6
|
+
import { IClient, IDocumentMessage, NackErrorType } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { IWebSocketServer } from "@fluidframework/server-services-core";
|
|
8
|
+
import type { Socket } from "socket.io-client";
|
|
9
|
+
/**
|
|
10
|
+
* Represents a connection to a stream of delta updates
|
|
11
|
+
*/
|
|
12
|
+
export declare class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
13
|
+
/**
|
|
14
|
+
* Create a LocalDocumentDeltaConnection
|
|
15
|
+
* Handle initial messages, contents or signals if they were in queue
|
|
16
|
+
*
|
|
17
|
+
* @param tenantId - the ID of the tenant
|
|
18
|
+
* @param id - document ID
|
|
19
|
+
* @param token - authorization token for storage service
|
|
20
|
+
* @param client - information about the client
|
|
21
|
+
* @param webSocketServer - web socket server to create connection
|
|
22
|
+
*/
|
|
23
|
+
static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: IWebSocketServer, timeoutMs?: number): Promise<LocalDocumentDeltaConnection>;
|
|
24
|
+
constructor(socket: Socket, documentId: string);
|
|
25
|
+
protected submitCore(type: string, messages: IDocumentMessage[]): void;
|
|
26
|
+
/**
|
|
27
|
+
* Submits a new delta operation to the server
|
|
28
|
+
*/
|
|
29
|
+
submit(messages: IDocumentMessage[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* Submits a new signal to the server
|
|
32
|
+
*/
|
|
33
|
+
submitSignal(message: any): void;
|
|
34
|
+
/**
|
|
35
|
+
* Send a "disconnect" message on the socket.
|
|
36
|
+
* @param disconnectReason - The reason of the disconnection.
|
|
37
|
+
*/
|
|
38
|
+
disconnectClient(disconnectReason: string): void;
|
|
39
|
+
/**
|
|
40
|
+
* * Sends a "nack" message on the socket.
|
|
41
|
+
* @param code - An error code number that represents the error. It will be a valid HTTP error code.
|
|
42
|
+
* @param type - Type of the Nack.
|
|
43
|
+
* @param message - A message about the nack for debugging/logging/telemetry purposes.
|
|
44
|
+
*/
|
|
45
|
+
nackClient(code: number | undefined, type: NackErrorType | undefined, message: any): void;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=localDocumentDeltaConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACN,OAAO,EAEP,gBAAgB,EAChB,aAAa,EACb,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;WACiB,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,gBAAgB,EACjC,SAAS,SAAQ,GACf,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAI9C,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IAI/D;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIvC;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIhD;;;;;OAKG;IACI,UAAU,CAChB,IAAI,oBAAc,EAClB,IAAI,2BAA+C,EACnD,OAAO,EAAE,GAAG;CAab"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { DocumentDeltaConnection } from "@fluidframework/driver-base";
|
|
6
|
+
import { NackErrorType, } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { TelemetryNullLogger } from "@fluidframework/telemetry-utils";
|
|
8
|
+
const testProtocolVersions = ["^0.3.0", "^0.2.0", "^0.1.0"];
|
|
9
|
+
/**
|
|
10
|
+
* Represents a connection to a stream of delta updates
|
|
11
|
+
*/
|
|
12
|
+
export class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
13
|
+
/**
|
|
14
|
+
* Create a LocalDocumentDeltaConnection
|
|
15
|
+
* Handle initial messages, contents or signals if they were in queue
|
|
16
|
+
*
|
|
17
|
+
* @param tenantId - the ID of the tenant
|
|
18
|
+
* @param id - document ID
|
|
19
|
+
* @param token - authorization token for storage service
|
|
20
|
+
* @param client - information about the client
|
|
21
|
+
* @param webSocketServer - web socket server to create connection
|
|
22
|
+
*/
|
|
23
|
+
static async create(tenantId, id, token, client, webSocketServer, timeoutMs = 60000) {
|
|
24
|
+
const socket = webSocketServer.createConnection();
|
|
25
|
+
// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky
|
|
26
|
+
// but should be fine because this delta connection is for local use only.
|
|
27
|
+
const socketWithListener = socket;
|
|
28
|
+
const deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id);
|
|
29
|
+
const connectMessage = {
|
|
30
|
+
client,
|
|
31
|
+
id,
|
|
32
|
+
mode: client.mode,
|
|
33
|
+
tenantId,
|
|
34
|
+
token,
|
|
35
|
+
versions: testProtocolVersions,
|
|
36
|
+
};
|
|
37
|
+
await deltaConnection.initialize(connectMessage, timeoutMs);
|
|
38
|
+
return deltaConnection;
|
|
39
|
+
}
|
|
40
|
+
constructor(socket, documentId) {
|
|
41
|
+
super(socket, documentId, new TelemetryNullLogger());
|
|
42
|
+
}
|
|
43
|
+
submitCore(type, messages) {
|
|
44
|
+
this.emitMessages(type, [messages]);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Submits a new delta operation to the server
|
|
48
|
+
*/
|
|
49
|
+
submit(messages) {
|
|
50
|
+
// We use a promise resolve to force a turn break given message processing is sync
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
52
|
+
Promise.resolve().then(() => {
|
|
53
|
+
this.submitCore("submitOp", messages);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Submits a new signal to the server
|
|
58
|
+
*/
|
|
59
|
+
submitSignal(message) {
|
|
60
|
+
this.submitCore("submitSignal", [message]);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Send a "disconnect" message on the socket.
|
|
64
|
+
* @param disconnectReason - The reason of the disconnection.
|
|
65
|
+
*/
|
|
66
|
+
disconnectClient(disconnectReason) {
|
|
67
|
+
this.socket.emit("disconnect", disconnectReason);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* * Sends a "nack" message on the socket.
|
|
71
|
+
* @param code - An error code number that represents the error. It will be a valid HTTP error code.
|
|
72
|
+
* @param type - Type of the Nack.
|
|
73
|
+
* @param message - A message about the nack for debugging/logging/telemetry purposes.
|
|
74
|
+
*/
|
|
75
|
+
nackClient(code = 400, type = NackErrorType.ThrottlingError, message) {
|
|
76
|
+
const nackMessage = {
|
|
77
|
+
operation: undefined,
|
|
78
|
+
sequenceNumber: -1,
|
|
79
|
+
content: {
|
|
80
|
+
code,
|
|
81
|
+
type,
|
|
82
|
+
message,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
this.socket.emit("nack", "", [nackMessage]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=localDocumentDeltaConnection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,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AG,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,OAAY;QAC/B,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAChB,OAAe,GAAG,EAClB,OAAsB,aAAa,CAAC,eAAe,EACnD,OAAY;QAEZ,MAAM,WAAW,GAAG;YACnB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACR,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACP;SACD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport {\n\tIClient,\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TelemetryNullLogger } from \"@fluidframework/telemetry-utils\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport type { Socket } from \"socket.io-client\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string) {\n\t\tsuper(socket, documentId, new TelemetryNullLogger());\n\t}\n\n\tprotected submitCore(type: string, messages: IDocumentMessage[]) {\n\t\tthis.emitMessages(type, [messages]);\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.submitCore(\"submitOp\", messages);\n\t\t});\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t */\n\tpublic submitSignal(message: any): void {\n\t\tthis.submitCore(\"submitSignal\", [message]);\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string) {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t) {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentDeltaConnection, IDocumentDeltaStorageService, IDocumentService, IDocumentServicePolicies, IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { IClient } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { ITokenProvider } from "@fluidframework/routerlicious-driver";
|
|
8
|
+
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
9
|
+
import { LocalDocumentDeltaConnection } from ".";
|
|
10
|
+
/**
|
|
11
|
+
* Basic implementation of a document service for local use.
|
|
12
|
+
*/
|
|
13
|
+
export declare class LocalDocumentService implements IDocumentService {
|
|
14
|
+
readonly resolvedUrl: IResolvedUrl;
|
|
15
|
+
private readonly localDeltaConnectionServer;
|
|
16
|
+
private readonly tokenProvider;
|
|
17
|
+
private readonly tenantId;
|
|
18
|
+
private readonly documentId;
|
|
19
|
+
private readonly documentDeltaConnectionsMap;
|
|
20
|
+
readonly policies: IDocumentServicePolicies;
|
|
21
|
+
private readonly innerDocumentService?;
|
|
22
|
+
/**
|
|
23
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
24
|
+
* @param tokenProvider - token provider
|
|
25
|
+
* @param tenantId - ID of tenant
|
|
26
|
+
* @param documentId - ID of document
|
|
27
|
+
*/
|
|
28
|
+
constructor(resolvedUrl: IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: IDocumentServicePolicies, innerDocumentService?: IDocumentService | undefined);
|
|
29
|
+
dispose(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Creates and returns a document storage service for local use.
|
|
32
|
+
*/
|
|
33
|
+
connectToStorage(): Promise<IDocumentStorageService>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates and returns a delta storage service for local use.
|
|
36
|
+
*/
|
|
37
|
+
connectToDeltaStorage(): Promise<IDocumentDeltaStorageService>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates and returns a delta stream for local use.
|
|
40
|
+
* @param client - client data
|
|
41
|
+
*/
|
|
42
|
+
connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates and returns a document service for local use.
|
|
46
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
47
|
+
* @param tokenProvider - token provider with a single token
|
|
48
|
+
* @param tenantId - ID of tenant
|
|
49
|
+
* @param documentId - ID of document
|
|
50
|
+
*/
|
|
51
|
+
export declare function createLocalDocumentService(resolvedUrl: IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: IDocumentServicePolicies, innerDocumentService?: IDocumentService): IDocumentService;
|
|
52
|
+
//# sourceMappingURL=localDocumentService.d.ts.map
|
|
@@ -0,0 +1 @@
|
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,CAAC,wBAAwB,CAAC;CA8BrF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,EAAE,YAAY,EACzB,0BAA0B,EAAE,2BAA2B,EACvD,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,EACtE,QAAQ,CAAC,EAAE,wBAAwB,EACnC,oBAAoB,CAAC,EAAE,gBAAgB,GACrC,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { GitManager } from "@fluidframework/server-services-client";
|
|
6
|
+
import { TestHistorian } from "@fluidframework/server-test-utils";
|
|
7
|
+
import { LocalDeltaStorageService, LocalDocumentDeltaConnection, LocalDocumentStorageService, } from ".";
|
|
8
|
+
/**
|
|
9
|
+
* Basic implementation of a document service for local use.
|
|
10
|
+
*/
|
|
11
|
+
export class LocalDocumentService {
|
|
12
|
+
/**
|
|
13
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
14
|
+
* @param tokenProvider - token provider
|
|
15
|
+
* @param tenantId - ID of tenant
|
|
16
|
+
* @param documentId - ID of document
|
|
17
|
+
*/
|
|
18
|
+
constructor(resolvedUrl, localDeltaConnectionServer, tokenProvider, tenantId, documentId, documentDeltaConnectionsMap, policies = {}, innerDocumentService) {
|
|
19
|
+
this.resolvedUrl = resolvedUrl;
|
|
20
|
+
this.localDeltaConnectionServer = localDeltaConnectionServer;
|
|
21
|
+
this.tokenProvider = tokenProvider;
|
|
22
|
+
this.tenantId = tenantId;
|
|
23
|
+
this.documentId = documentId;
|
|
24
|
+
this.documentDeltaConnectionsMap = documentDeltaConnectionsMap;
|
|
25
|
+
this.policies = policies;
|
|
26
|
+
this.innerDocumentService = innerDocumentService;
|
|
27
|
+
}
|
|
28
|
+
dispose() { }
|
|
29
|
+
/**
|
|
30
|
+
* Creates and returns a document storage service for local use.
|
|
31
|
+
*/
|
|
32
|
+
async connectToStorage() {
|
|
33
|
+
return new LocalDocumentStorageService(this.documentId, new GitManager(new TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)), {
|
|
34
|
+
minBlobSize: 2048,
|
|
35
|
+
maximumCacheDurationMs: 432000000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario
|
|
36
|
+
}, this.localDeltaConnectionServer, this.resolvedUrl);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Creates and returns a delta storage service for local use.
|
|
40
|
+
*/
|
|
41
|
+
async connectToDeltaStorage() {
|
|
42
|
+
if (this.innerDocumentService) {
|
|
43
|
+
return this.innerDocumentService.connectToDeltaStorage();
|
|
44
|
+
}
|
|
45
|
+
return new LocalDeltaStorageService(this.tenantId, this.documentId, this.localDeltaConnectionServer.databaseManager);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates and returns a delta stream for local use.
|
|
49
|
+
* @param client - client data
|
|
50
|
+
*/
|
|
51
|
+
async connectToDeltaStream(client) {
|
|
52
|
+
if (this.policies.storageOnly === true) {
|
|
53
|
+
throw new Error("can't connect to delta stream in storage-only mode");
|
|
54
|
+
}
|
|
55
|
+
if (this.innerDocumentService) {
|
|
56
|
+
return this.innerDocumentService.connectToDeltaStream(client);
|
|
57
|
+
}
|
|
58
|
+
const ordererToken = await this.tokenProvider.fetchOrdererToken(this.tenantId, this.documentId);
|
|
59
|
+
const documentDeltaConnection = await LocalDocumentDeltaConnection.create(this.tenantId, this.documentId, ordererToken.jwt, client, this.localDeltaConnectionServer.webSocketServer);
|
|
60
|
+
const clientId = documentDeltaConnection.clientId;
|
|
61
|
+
// Add this document service for the clientId in the document service factory.
|
|
62
|
+
this.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);
|
|
63
|
+
// Add a listener to remove this document service when the client is disconnected.
|
|
64
|
+
documentDeltaConnection.on("disconnect", () => {
|
|
65
|
+
this.documentDeltaConnectionsMap.delete(clientId);
|
|
66
|
+
});
|
|
67
|
+
return documentDeltaConnection;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates and returns a document service for local use.
|
|
72
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
73
|
+
* @param tokenProvider - token provider with a single token
|
|
74
|
+
* @param tenantId - ID of tenant
|
|
75
|
+
* @param documentId - ID of document
|
|
76
|
+
*/
|
|
77
|
+
export function createLocalDocumentService(resolvedUrl, localDeltaConnectionServer, tokenProvider, tenantId, documentId, documentDeltaConnectionsMap, policies, innerDocumentService) {
|
|
78
|
+
return new LocalDocumentService(resolvedUrl, localDeltaConnectionServer, tokenProvider, tenantId, documentId, documentDeltaConnectionsMap, policies, innerDocumentService);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=localDocumentService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDocumentService.js","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EACN,wBAAwB,EACxB,4BAA4B,EAC5B,2BAA2B,GAC3B,MAAM,GAAG,CAAC;AACX;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAChC;;;;;OAKG;IACH,YACiB,WAAyB,EACxB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACvE,WAAqC,EAAE,EACtC,oBAAuC;QAPxC,gBAAW,GAAX,WAAW,CAAc;QACxB,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,kBAAa,GAAb,aAAa,CAAgB;QAC7B,aAAQ,GAAR,QAAQ,C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,4BAA4B,CAAC,MAAM,CACxE,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,UAAU,EACf,YAAY,CAAC,GAAG,EAChB,MAAM,EACN,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAC/C,CAAC;QACF,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC;QAElD,8EAA8E;QAC9E,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;QAExE,kFAAkF;QAClF,uBAAuB,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YAC7C,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;IAChC,CAAC;CACD;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACzC,WAAyB,EACzB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACtE,QAAmC,EACnC,oBAAuC;IAEvC,OAAO,IAAI,oBAAoB,CAC9B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,CACpB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { ITokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tLocalDeltaStorageService,\n\tLocalDocumentDeltaConnection,\n\tLocalDocumentStorageService,\n} from \".\";\n/**\n * Basic implementation of a document service for local use.\n */\nexport class LocalDocumentService implements IDocumentService {\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t * @param tokenProvider - token provider\n\t * @param tenantId - ID of tenant\n\t * @param documentId - ID of document\n\t */\n\tconstructor(\n\t\tpublic readonly resolvedUrl: IResolvedUrl,\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly documentId: string,\n\t\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\t\tpublic readonly policies: IDocumentServicePolicies = {},\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\tpublic dispose() {}\n\n\t/**\n\t * Creates and returns a document storage service for local use.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\treturn new LocalDocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tnew GitManager(\n\t\t\t\tnew TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase),\n\t\t\t),\n\t\t\t{\n\t\t\t\tminBlobSize: 2048, // Test blob aggregation\n\t\t\t\tmaximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario\n\t\t\t},\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\tthis.resolvedUrl,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta storage service for local use.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStorage();\n\t\t}\n\t\treturn new LocalDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tthis.localDeltaConnectionServer.databaseManager,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta stream for local use.\n\t * @param client - client data\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.policies.storageOnly === true) {\n\t\t\tthrow new Error(\"can't connect to delta stream in storage-only mode\");\n\t\t}\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStream(client);\n\t\t}\n\t\tconst ordererToken = await this.tokenProvider.fetchOrdererToken(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t);\n\t\tconst documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tordererToken.jwt,\n\t\t\tclient,\n\t\t\tthis.localDeltaConnectionServer.webSocketServer,\n\t\t);\n\t\tconst clientId = documentDeltaConnection.clientId;\n\n\t\t// Add this document service for the clientId in the document service factory.\n\t\tthis.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n\t\t// Add a listener to remove this document service when the client is disconnected.\n\t\tdocumentDeltaConnection.on(\"disconnect\", () => {\n\t\t\tthis.documentDeltaConnectionsMap.delete(clientId);\n\t\t});\n\n\t\treturn documentDeltaConnection;\n\t}\n}\n\n/**\n * Creates and returns a document service for local use.\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider with a single token\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n */\nexport function createLocalDocumentService(\n\tresolvedUrl: IResolvedUrl,\n\tlocalDeltaConnectionServer: ILocalDeltaConnectionServer,\n\ttokenProvider: ITokenProvider,\n\ttenantId: string,\n\tdocumentId: string,\n\tdocumentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\tpolicies?: IDocumentServicePolicies,\n\tinnerDocumentService?: IDocumentService,\n): IDocumentService {\n\treturn new LocalDocumentService(\n\t\tresolvedUrl,\n\t\tlocalDeltaConnectionServer,\n\t\ttokenProvider,\n\t\ttenantId,\n\t\tdocumentId,\n\t\tdocumentDeltaConnectionsMap,\n\t\tpolicies,\n\t\tinnerDocumentService,\n\t);\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentService, IDocumentServiceFactory, IDocumentServicePolicies, IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
7
|
+
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
8
|
+
import { ISummaryTree, NackErrorType } from "@fluidframework/protocol-definitions";
|
|
9
|
+
/**
|
|
10
|
+
* Implementation of document service factory for local use.
|
|
11
|
+
*/
|
|
12
|
+
export declare class LocalDocumentServiceFactory implements IDocumentServiceFactory {
|
|
13
|
+
private readonly localDeltaConnectionServer;
|
|
14
|
+
private readonly policies?;
|
|
15
|
+
private readonly innerDocumentService?;
|
|
16
|
+
private readonly documentDeltaConnectionsMap;
|
|
17
|
+
/**
|
|
18
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
19
|
+
*/
|
|
20
|
+
constructor(localDeltaConnectionServer: ILocalDeltaConnectionServer, policies?: IDocumentServicePolicies | undefined, innerDocumentService?: IDocumentService | undefined);
|
|
21
|
+
createContainer(createNewSummary: ISummaryTree | undefined, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates and returns a document service for testing using the given resolved
|
|
24
|
+
* URL for the tenant ID, document ID, and token.
|
|
25
|
+
* @param resolvedUrl - resolved URL of document
|
|
26
|
+
*/
|
|
27
|
+
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the document delta connection for the clientId and asks it to disconnect the client.
|
|
30
|
+
* @param clientId - The ID of the client to be disconnected.
|
|
31
|
+
* @param disconnectReason - The reason of the disconnection.
|
|
32
|
+
*/
|
|
33
|
+
disconnectClient(clientId: string, disconnectReason: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Gets the document delta connection for the clientId and asks it to nack the client.
|
|
36
|
+
* @param clientId - The ID of the client to be Nack'd.
|
|
37
|
+
* @param code - An error code number that represents the error. It will be a valid HTTP error code.
|
|
38
|
+
* @param type - Type of the Nack.
|
|
39
|
+
* @param message - A message about the nack for debugging/logging/telemetry purposes.
|
|
40
|
+
*/
|
|
41
|
+
nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=localDocumentServiceFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAKnF;;GAEG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IASzE,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IATvC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CACjC;IAEX;;OAEG;gBAEe,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,CAAC,sCAA0B,EACnC,oBAAoB,CAAC,8BAAkB;IAG5C,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAW5B;;;;OAIG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IA+B5B;;;;OAIG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAQlE;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,GAAG;CAOtF"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { parse } from "url";
|
|
6
|
+
import { DefaultTokenProvider } from "@fluidframework/routerlicious-driver";
|
|
7
|
+
import { ensureFluidResolvedUrl } from "@fluidframework/driver-utils";
|
|
8
|
+
import { createLocalDocumentService } from "./localDocumentService";
|
|
9
|
+
import { createDocument } from "./localCreateDocument";
|
|
10
|
+
/**
|
|
11
|
+
* Implementation of document service factory for local use.
|
|
12
|
+
*/
|
|
13
|
+
export class LocalDocumentServiceFactory {
|
|
14
|
+
/**
|
|
15
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
16
|
+
*/
|
|
17
|
+
constructor(localDeltaConnectionServer, policies, innerDocumentService) {
|
|
18
|
+
this.localDeltaConnectionServer = localDeltaConnectionServer;
|
|
19
|
+
this.policies = policies;
|
|
20
|
+
this.innerDocumentService = innerDocumentService;
|
|
21
|
+
// A map of clientId to LocalDocumentService.
|
|
22
|
+
this.documentDeltaConnectionsMap = new Map();
|
|
23
|
+
}
|
|
24
|
+
async createContainer(createNewSummary, resolvedUrl, logger, clientIsSummarizer) {
|
|
25
|
+
if (!this.localDeltaConnectionServer) {
|
|
26
|
+
throw new Error("Provide the localDeltaConnectionServer!!");
|
|
27
|
+
}
|
|
28
|
+
if (createNewSummary !== undefined) {
|
|
29
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
30
|
+
await createDocument(this.localDeltaConnectionServer, resolvedUrl, createNewSummary);
|
|
31
|
+
}
|
|
32
|
+
return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates and returns a document service for testing using the given resolved
|
|
36
|
+
* URL for the tenant ID, document ID, and token.
|
|
37
|
+
* @param resolvedUrl - resolved URL of document
|
|
38
|
+
*/
|
|
39
|
+
async createDocumentService(resolvedUrl, logger, clientIsSummarizer) {
|
|
40
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
41
|
+
const parsedUrl = parse(resolvedUrl.url);
|
|
42
|
+
const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split("/") : [];
|
|
43
|
+
if (!documentId || !tenantId) {
|
|
44
|
+
throw new Error(`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`);
|
|
45
|
+
}
|
|
46
|
+
const fluidResolvedUrl = resolvedUrl;
|
|
47
|
+
const jwtToken = fluidResolvedUrl.tokens.jwt;
|
|
48
|
+
if (!jwtToken) {
|
|
49
|
+
throw new Error(`Token was not provided.`);
|
|
50
|
+
}
|
|
51
|
+
const tokenProvider = new DefaultTokenProvider(jwtToken);
|
|
52
|
+
return createLocalDocumentService(resolvedUrl, this.localDeltaConnectionServer, tokenProvider, tenantId, documentId, this.documentDeltaConnectionsMap, this.policies, this.innerDocumentService);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Gets the document delta connection for the clientId and asks it to disconnect the client.
|
|
56
|
+
* @param clientId - The ID of the client to be disconnected.
|
|
57
|
+
* @param disconnectReason - The reason of the disconnection.
|
|
58
|
+
*/
|
|
59
|
+
disconnectClient(clientId, disconnectReason) {
|
|
60
|
+
const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
|
|
61
|
+
if (documentDeltaConnection === undefined) {
|
|
62
|
+
throw new Error(`No client with the id: ${clientId}`);
|
|
63
|
+
}
|
|
64
|
+
documentDeltaConnection.disconnectClient(disconnectReason);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Gets the document delta connection for the clientId and asks it to nack the client.
|
|
68
|
+
* @param clientId - The ID of the client to be Nack'd.
|
|
69
|
+
* @param code - An error code number that represents the error. It will be a valid HTTP error code.
|
|
70
|
+
* @param type - Type of the Nack.
|
|
71
|
+
* @param message - A message about the nack for debugging/logging/telemetry purposes.
|
|
72
|
+
*/
|
|
73
|
+
nackClient(clientId, code, type, message) {
|
|
74
|
+
const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
|
|
75
|
+
if (documentDeltaConnection === undefined) {
|
|
76
|
+
throw new Error(`No client with the id: ${clientId}`);
|
|
77
|
+
}
|
|
78
|
+
documentDeltaConnection.nackClient(code, type, message);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=localDocumentServiceFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAQ5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;GAEG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AAW,CAAC;QACrC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC;QAC7C,IAAI,CAAC,QAAQ,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;SAC3C;QAED,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEzD,OAAO,0BAA0B,CAChC,WAAW,EACX,IAAI,CAAC,0BAA0B,EAC/B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,IAAI,CAAC,2BAA2B,EAChC,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,oBAAoB,CACzB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,QAAgB,EAAE,gBAAwB;QACjE,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACtD;QACD,uBAAuB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAgB,EAAE,IAAa,EAAE,IAAoB,EAAE,OAAa;QACrF,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACtD;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { ensureFluidResolvedUrl } from \"@fluidframework/driver-utils\";\nimport { ISummaryTree, NackErrorType } from \"@fluidframework/protocol-definitions\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection\";\nimport { createLocalDocumentService } from \"./localDocumentService\";\nimport { createDocument } from \"./localCreateDocument\";\n\n/**\n * Implementation of document service factory for local use.\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n\t// A map of clientId to LocalDocumentService.\n\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> =\n\t\tnew Map();\n\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t */\n\tconstructor(\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly policies?: IDocumentServicePolicies,\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (!this.localDeltaConnectionServer) {\n\t\t\tthrow new Error(\"Provide the localDeltaConnectionServer!!\");\n\t\t}\n\t\tif (createNewSummary !== undefined) {\n\t\t\tensureFluidResolvedUrl(resolvedUrl);\n\t\t\tawait createDocument(this.localDeltaConnectionServer, resolvedUrl, createNewSummary);\n\t\t}\n\t\treturn this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n\t}\n\n\t/**\n\t * Creates and returns a document service for testing using the given resolved\n\t * URL for the tenant ID, document ID, and token.\n\t * @param resolvedUrl - resolved URL of document\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tensureFluidResolvedUrl(resolvedUrl);\n\n\t\tconst parsedUrl = parse(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split(\"/\") : [];\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst fluidResolvedUrl = resolvedUrl;\n\t\tconst jwtToken = fluidResolvedUrl.tokens.jwt;\n\t\tif (!jwtToken) {\n\t\t\tthrow new Error(`Token was not provided.`);\n\t\t}\n\n\t\tconst tokenProvider = new DefaultTokenProvider(jwtToken);\n\n\t\treturn createLocalDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\ttokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.documentDeltaConnectionsMap,\n\t\t\tthis.policies,\n\t\t\tthis.innerDocumentService,\n\t\t);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to disconnect the client.\n\t * @param clientId - The ID of the client to be disconnected.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(clientId: string, disconnectReason: string) {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.disconnectClient(disconnectReason);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to nack the client.\n\t * @param clientId - The ID of the client to be Nack'd.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any) {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.nackClient(code, type, message);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { IDocumentStorageService, IDocumentStorageServicePolicies, IResolvedUrl, ISummaryContext } from "@fluidframework/driver-definitions";
|
|
6
|
+
import { ICreateBlobResponse, ISnapshotTreeEx, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
7
|
+
import { GitManager } from "@fluidframework/server-services-client";
|
|
8
|
+
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
9
|
+
export declare class LocalDocumentStorageService implements IDocumentStorageService {
|
|
10
|
+
private readonly id;
|
|
11
|
+
private readonly manager;
|
|
12
|
+
readonly policies: IDocumentStorageServicePolicies;
|
|
13
|
+
private readonly localDeltaConnectionServer?;
|
|
14
|
+
private readonly resolvedUrl?;
|
|
15
|
+
protected readonly blobsShaCache: Map<string, string>;
|
|
16
|
+
private readonly summaryTreeUploadManager;
|
|
17
|
+
get repositoryUrl(): string;
|
|
18
|
+
constructor(id: string, manager: GitManager, policies: IDocumentStorageServicePolicies, localDeltaConnectionServer?: ILocalDeltaConnectionServer | undefined, resolvedUrl?: IResolvedUrl | undefined);
|
|
19
|
+
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
20
|
+
getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null>;
|
|
21
|
+
readBlob(blobId: string): Promise<ArrayBufferLike>;
|
|
22
|
+
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
23
|
+
createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
|
|
24
|
+
downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
|
|
25
|
+
private getPreviousFullSnapshot;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=localDocumentStorageService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,YAAY,EACZ,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACN,UAAU,EAGV,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAIlF,qBAAa,2BAA4B,YAAW,uBAAuB;IAWzE,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO;aACR,QAAQ,EAAE,+BAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAZ9B,SAAS,CAAC,QAAQ,CAAC,aAAa,sBAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAwB;IAEjE,IAAW,aAAa,IAAI,MAAM,CAEjC;gBAGiB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACpB,QAAQ,EAAE,+BAA+B,EACxC,0BAA0B,CAAC,yCAA6B,EACxD,WAAW,CAAC,0BAAc;IAS/B,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;I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