@fluidframework/local-driver 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
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 +19 -22
- package/.mocharc.js +2 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/auth.js.map +1 -1
- package/dist/localDeltaStorageService.d.ts.map +1 -1
- package/dist/localDeltaStorageService.js.map +1 -1
- package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/localDocumentDeltaConnection.js.map +1 -1
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/localDocumentService.js.map +1 -1
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentServiceFactory.js +3 -2
- package/dist/localDocumentServiceFactory.js.map +1 -1
- package/dist/localDocumentStorageService.d.ts.map +1 -1
- package/dist/localDocumentStorageService.js +4 -3
- package/dist/localDocumentStorageService.js.map +1 -1
- package/dist/localResolver.d.ts.map +1 -1
- package/dist/localResolver.js.map +1 -1
- package/dist/localSessionStorageDb.d.ts.map +1 -1
- 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/package.json +37 -36
- package/prettier.config.cjs +1 -1
- package/src/auth.ts +35 -29
- package/src/localDeltaStorageService.ts +26 -29
- package/src/localDocumentDeltaConnection.ts +89 -85
- package/src/localDocumentService.ts +106 -98
- package/src/localDocumentServiceFactory.ts +126 -117
- package/src/localDocumentStorageService.ts +17 -10
- package/src/localResolver.ts +55 -55
- package/src/localSessionStorageDb.ts +267 -261
- package/src/packageVersion.ts +1 -1
- package/tsconfig.json +9 -13
|
@@ -4,103 +4,110 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
IDocumentDeltaConnection,
|
|
8
|
+
IDocumentDeltaStorageService,
|
|
9
|
+
IDocumentService,
|
|
10
|
+
IDocumentServicePolicies,
|
|
11
|
+
IDocumentStorageService,
|
|
12
|
+
IResolvedUrl,
|
|
13
13
|
} from "@fluidframework/driver-definitions";
|
|
14
14
|
import { IClient } from "@fluidframework/protocol-definitions";
|
|
15
15
|
import { ITokenProvider } from "@fluidframework/routerlicious-driver";
|
|
16
16
|
import { GitManager } from "@fluidframework/server-services-client";
|
|
17
17
|
import { TestHistorian } from "@fluidframework/server-test-utils";
|
|
18
18
|
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
LocalDeltaStorageService,
|
|
21
|
+
LocalDocumentDeltaConnection,
|
|
22
|
+
LocalDocumentStorageService,
|
|
23
|
+
} from ".";
|
|
20
24
|
/**
|
|
21
25
|
* Basic implementation of a document service for local use.
|
|
22
26
|
*/
|
|
23
27
|
export class LocalDocumentService implements IDocumentService {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
30
|
+
* @param tokenProvider - token provider
|
|
31
|
+
* @param tenantId - ID of tenant
|
|
32
|
+
* @param documentId - ID of document
|
|
33
|
+
*/
|
|
34
|
+
constructor(
|
|
35
|
+
public readonly resolvedUrl: IResolvedUrl,
|
|
36
|
+
private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,
|
|
37
|
+
private readonly tokenProvider: ITokenProvider,
|
|
38
|
+
private readonly tenantId: string,
|
|
39
|
+
private readonly documentId: string,
|
|
40
|
+
private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,
|
|
41
|
+
public readonly policies: IDocumentServicePolicies = {},
|
|
42
|
+
private readonly innerDocumentService?: IDocumentService,
|
|
43
|
+
) {}
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
public dispose() {}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Creates and returns a document storage service for local use.
|
|
49
|
+
*/
|
|
50
|
+
public async connectToStorage(): Promise<IDocumentStorageService> {
|
|
51
|
+
return new LocalDocumentStorageService(
|
|
52
|
+
this.documentId,
|
|
53
|
+
new GitManager(
|
|
54
|
+
new TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase),
|
|
55
|
+
),
|
|
56
|
+
{
|
|
57
|
+
minBlobSize: 2048, // Test blob aggregation
|
|
58
|
+
maximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
}
|
|
56
62
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Creates and returns a delta storage service for local use.
|
|
65
|
+
*/
|
|
66
|
+
public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {
|
|
67
|
+
if (this.innerDocumentService) {
|
|
68
|
+
return this.innerDocumentService.connectToDeltaStorage();
|
|
69
|
+
}
|
|
70
|
+
return new LocalDeltaStorageService(
|
|
71
|
+
this.tenantId,
|
|
72
|
+
this.documentId,
|
|
73
|
+
this.localDeltaConnectionServer.databaseManager,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
69
76
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Creates and returns a delta stream for local use.
|
|
79
|
+
* @param client - client data
|
|
80
|
+
*/
|
|
81
|
+
public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {
|
|
82
|
+
if (this.policies.storageOnly === true) {
|
|
83
|
+
throw new Error("can't connect to delta stream in storage-only mode");
|
|
84
|
+
}
|
|
85
|
+
if (this.innerDocumentService) {
|
|
86
|
+
return this.innerDocumentService.connectToDeltaStream(client);
|
|
87
|
+
}
|
|
88
|
+
const ordererToken = await this.tokenProvider.fetchOrdererToken(
|
|
89
|
+
this.tenantId,
|
|
90
|
+
this.documentId,
|
|
91
|
+
);
|
|
92
|
+
const documentDeltaConnection = await LocalDocumentDeltaConnection.create(
|
|
93
|
+
this.tenantId,
|
|
94
|
+
this.documentId,
|
|
95
|
+
ordererToken.jwt,
|
|
96
|
+
client,
|
|
97
|
+
this.localDeltaConnectionServer.webSocketServer,
|
|
98
|
+
);
|
|
99
|
+
const clientId = documentDeltaConnection.clientId;
|
|
93
100
|
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
// Add this document service for the clientId in the document service factory.
|
|
102
|
+
this.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);
|
|
96
103
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
104
|
+
// Add a listener to remove this document service when the client is disconnected.
|
|
105
|
+
documentDeltaConnection.on("disconnect", () => {
|
|
106
|
+
this.documentDeltaConnectionsMap.delete(clientId);
|
|
107
|
+
});
|
|
101
108
|
|
|
102
|
-
|
|
103
|
-
|
|
109
|
+
return documentDeltaConnection;
|
|
110
|
+
}
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
/**
|
|
@@ -111,22 +118,23 @@ export class LocalDocumentService implements IDocumentService {
|
|
|
111
118
|
* @param documentId - ID of document
|
|
112
119
|
*/
|
|
113
120
|
export function createLocalDocumentService(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
resolvedUrl: IResolvedUrl,
|
|
122
|
+
localDeltaConnectionServer: ILocalDeltaConnectionServer,
|
|
123
|
+
tokenProvider: ITokenProvider,
|
|
124
|
+
tenantId: string,
|
|
125
|
+
documentId: string,
|
|
126
|
+
documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,
|
|
127
|
+
policies?: IDocumentServicePolicies,
|
|
128
|
+
innerDocumentService?: IDocumentService,
|
|
129
|
+
): IDocumentService {
|
|
130
|
+
return new LocalDocumentService(
|
|
131
|
+
resolvedUrl,
|
|
132
|
+
localDeltaConnectionServer,
|
|
133
|
+
tokenProvider,
|
|
134
|
+
tenantId,
|
|
135
|
+
documentId,
|
|
136
|
+
documentDeltaConnectionsMap,
|
|
137
|
+
policies,
|
|
138
|
+
innerDocumentService,
|
|
139
|
+
);
|
|
132
140
|
}
|
|
@@ -5,18 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
import { parse } from "url";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
IDocumentService,
|
|
9
|
+
IDocumentServiceFactory,
|
|
10
|
+
IDocumentServicePolicies,
|
|
11
|
+
IResolvedUrl,
|
|
12
12
|
} from "@fluidframework/driver-definitions";
|
|
13
13
|
import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
|
|
14
14
|
import { DefaultTokenProvider } from "@fluidframework/routerlicious-driver";
|
|
15
|
-
import { ILocalDeltaConnectionServer, LocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
16
15
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
ILocalDeltaConnectionServer,
|
|
17
|
+
LocalDeltaConnectionServer,
|
|
18
|
+
} from "@fluidframework/server-local-server";
|
|
19
|
+
import {
|
|
20
|
+
ensureFluidResolvedUrl,
|
|
21
|
+
getDocAttributesFromProtocolSummary,
|
|
22
|
+
getQuorumValuesFromProtocolSummary,
|
|
20
23
|
} from "@fluidframework/driver-utils";
|
|
21
24
|
import { ISummaryTree, NackErrorType } from "@fluidframework/protocol-definitions";
|
|
22
25
|
import { defaultHash } from "@fluidframework/server-services-client";
|
|
@@ -27,124 +30,130 @@ import { createLocalDocumentService } from "./localDocumentService";
|
|
|
27
30
|
* Implementation of document service factory for local use.
|
|
28
31
|
*/
|
|
29
32
|
export class LocalDocumentServiceFactory implements IDocumentServiceFactory {
|
|
30
|
-
|
|
33
|
+
public readonly protocolName = "fluid-test:";
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
// A map of clientId to LocalDocumentService.
|
|
36
|
+
private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> =
|
|
37
|
+
new Map();
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @param localDeltaConnectionServer - delta connection server for ops
|
|
41
|
+
*/
|
|
42
|
+
constructor(
|
|
43
|
+
private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,
|
|
44
|
+
private readonly policies?: IDocumentServicePolicies,
|
|
45
|
+
private readonly innerDocumentService?: IDocumentService,
|
|
46
|
+
) {}
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
public async createContainer(
|
|
49
|
+
createNewSummary: ISummaryTree | undefined,
|
|
50
|
+
resolvedUrl: IResolvedUrl,
|
|
51
|
+
logger?: ITelemetryBaseLogger,
|
|
52
|
+
clientIsSummarizer?: boolean,
|
|
53
|
+
): Promise<IDocumentService> {
|
|
54
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
55
|
+
if (createNewSummary === undefined) {
|
|
56
|
+
throw new Error("Empty file summary creation isn't supported in this driver.");
|
|
57
|
+
}
|
|
58
|
+
const pathName = new URL(resolvedUrl.url).pathname;
|
|
59
|
+
const pathArr = pathName.split("/");
|
|
60
|
+
const tenantId = pathArr[pathArr.length - 2];
|
|
61
|
+
const id = pathArr[pathArr.length - 1];
|
|
62
|
+
if (!this.localDeltaConnectionServer) {
|
|
63
|
+
throw new Error("Provide the localDeltaConnectionServer!!");
|
|
64
|
+
}
|
|
65
|
+
const documentStorage = (this.localDeltaConnectionServer as LocalDeltaConnectionServer)
|
|
66
|
+
.documentStorage;
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
68
|
+
const protocolSummary = createNewSummary.tree[".protocol"] as ISummaryTree;
|
|
69
|
+
const appSummary = createNewSummary.tree[".app"] as ISummaryTree;
|
|
70
|
+
if (!(protocolSummary && appSummary)) {
|
|
71
|
+
throw new Error("Protocol and App Summary required in the full summary");
|
|
72
|
+
}
|
|
73
|
+
const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);
|
|
74
|
+
const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);
|
|
75
|
+
const sequenceNumber = documentAttributes.sequenceNumber;
|
|
76
|
+
await documentStorage.createDocument(
|
|
77
|
+
tenantId,
|
|
78
|
+
id,
|
|
79
|
+
appSummary,
|
|
80
|
+
sequenceNumber,
|
|
81
|
+
documentAttributes.term ?? 1,
|
|
82
|
+
defaultHash,
|
|
83
|
+
resolvedUrl.endpoints.ordererUrl ?? "",
|
|
84
|
+
resolvedUrl.endpoints.storageUrl ?? "",
|
|
85
|
+
resolvedUrl.endpoints.deltaStorageUrl ?? "",
|
|
86
|
+
quorumValues,
|
|
87
|
+
false /* enableDiscovery */,
|
|
88
|
+
);
|
|
89
|
+
return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
|
|
90
|
+
}
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Creates and returns a document service for testing using the given resolved
|
|
94
|
+
* URL for the tenant ID, document ID, and token.
|
|
95
|
+
* @param resolvedUrl - resolved URL of document
|
|
96
|
+
*/
|
|
97
|
+
public async createDocumentService(
|
|
98
|
+
resolvedUrl: IResolvedUrl,
|
|
99
|
+
logger?: ITelemetryBaseLogger,
|
|
100
|
+
clientIsSummarizer?: boolean,
|
|
101
|
+
): Promise<IDocumentService> {
|
|
102
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
97
103
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
const parsedUrl = parse(resolvedUrl.url);
|
|
105
|
+
const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split("/") : [];
|
|
106
|
+
if (!documentId || !tenantId) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
103
111
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
const fluidResolvedUrl = resolvedUrl;
|
|
113
|
+
const jwtToken = fluidResolvedUrl.tokens.jwt;
|
|
114
|
+
if (!jwtToken) {
|
|
115
|
+
throw new Error(`Token was not provided.`);
|
|
116
|
+
}
|
|
109
117
|
|
|
110
|
-
|
|
118
|
+
const tokenProvider = new DefaultTokenProvider(jwtToken);
|
|
111
119
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
return createLocalDocumentService(
|
|
121
|
+
resolvedUrl,
|
|
122
|
+
this.localDeltaConnectionServer,
|
|
123
|
+
tokenProvider,
|
|
124
|
+
tenantId,
|
|
125
|
+
documentId,
|
|
126
|
+
this.documentDeltaConnectionsMap,
|
|
127
|
+
this.policies,
|
|
128
|
+
this.innerDocumentService,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
122
131
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Gets the document delta connection for the clientId and asks it to disconnect the client.
|
|
134
|
+
* @param clientId - The ID of the client to be disconnected.
|
|
135
|
+
* @param disconnectReason - The reason of the disconnection.
|
|
136
|
+
*/
|
|
137
|
+
public disconnectClient(clientId: string, disconnectReason: string) {
|
|
138
|
+
const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
|
|
139
|
+
if (documentDeltaConnection === undefined) {
|
|
140
|
+
throw new Error(`No client with the id: ${clientId}`);
|
|
141
|
+
}
|
|
142
|
+
documentDeltaConnection.disconnectClient(disconnectReason);
|
|
143
|
+
}
|
|
135
144
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Gets the document delta connection for the clientId and asks it to nack the client.
|
|
147
|
+
* @param clientId - The ID of the client to be Nack'd.
|
|
148
|
+
* @param code - An error code number that represents the error. It will be a valid HTTP error code.
|
|
149
|
+
* @param type - Type of the Nack.
|
|
150
|
+
* @param message - A message about the nack for debugging/logging/telemetry purposes.
|
|
151
|
+
*/
|
|
152
|
+
public nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any) {
|
|
153
|
+
const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
|
|
154
|
+
if (documentDeltaConnection === undefined) {
|
|
155
|
+
throw new Error(`No client with the id: ${clientId}`);
|
|
156
|
+
}
|
|
157
|
+
documentDeltaConnection.nackClient(code, type, message);
|
|
158
|
+
}
|
|
150
159
|
}
|
|
@@ -17,7 +17,11 @@ import {
|
|
|
17
17
|
IVersion,
|
|
18
18
|
} from "@fluidframework/protocol-definitions";
|
|
19
19
|
import { buildHierarchy } from "@fluidframework/protocol-base";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
GitManager,
|
|
22
|
+
ISummaryUploadManager,
|
|
23
|
+
SummaryTreeUploadManager,
|
|
24
|
+
} from "@fluidframework/server-services-client";
|
|
21
25
|
|
|
22
26
|
export class LocalDocumentStorageService implements IDocumentStorageService {
|
|
23
27
|
// The values of this cache is useless. We only need the keys. So we are always putting
|
|
@@ -74,7 +78,10 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
|
|
|
74
78
|
return bufferContent;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
public async uploadSummaryWithContext(
|
|
81
|
+
public async uploadSummaryWithContext(
|
|
82
|
+
summary: ISummaryTree,
|
|
83
|
+
context: ISummaryContext,
|
|
84
|
+
): Promise<string> {
|
|
78
85
|
return this.summaryTreeUploadManager.writeSummaryTree(
|
|
79
86
|
summary,
|
|
80
87
|
context.ackHandle ?? "",
|
|
@@ -84,24 +91,24 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
|
|
|
84
91
|
|
|
85
92
|
public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {
|
|
86
93
|
const uint8ArrayFile = new Uint8Array(file);
|
|
87
|
-
return this.manager
|
|
88
|
-
Uint8ArrayToString(
|
|
89
|
-
|
|
90
|
-
"base64").then((r) => ({ id: r.sha, url: r.url }));
|
|
94
|
+
return this.manager
|
|
95
|
+
.createBlob(Uint8ArrayToString(uint8ArrayFile, "base64"), "base64")
|
|
96
|
+
.then((r) => ({ id: r.sha, url: r.url }));
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {
|
|
94
100
|
throw new Error("NOT IMPLEMENTED!");
|
|
95
101
|
}
|
|
96
102
|
|
|
97
|
-
private async getPreviousFullSnapshot(
|
|
103
|
+
private async getPreviousFullSnapshot(
|
|
104
|
+
parentHandle: string,
|
|
105
|
+
): Promise<ISnapshotTreeEx | null | undefined> {
|
|
98
106
|
return parentHandle
|
|
99
|
-
? this.getVersions(parentHandle, 1)
|
|
100
|
-
.then(async (versions) => {
|
|
107
|
+
? this.getVersions(parentHandle, 1).then(async (versions) => {
|
|
101
108
|
// Clear the cache as the getSnapshotTree call will fill the cache.
|
|
102
109
|
this.blobsShaCache.clear();
|
|
103
110
|
return this.getSnapshotTree(versions[0]);
|
|
104
|
-
|
|
111
|
+
})
|
|
105
112
|
: undefined;
|
|
106
113
|
}
|
|
107
114
|
}
|