@fluidframework/routerlicious-driver 2.0.0-internal.4.1.2 → 2.0.0-internal.4.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/dist/contracts.d.ts +15 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +7 -0
- package/dist/contracts.js.map +1 -0
- package/dist/documentService.d.ts +4 -2
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +5 -4
- package/dist/documentService.js.map +1 -1
- package/dist/documentServiceFactory.d.ts +2 -1
- package/dist/documentServiceFactory.d.ts.map +1 -1
- package/dist/documentServiceFactory.js +11 -4
- package/dist/documentServiceFactory.js.map +1 -1
- package/dist/documentStorageService.d.ts +3 -2
- package/dist/documentStorageService.d.ts.map +1 -1
- package/dist/documentStorageService.js +4 -4
- package/dist/documentStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/r11sSnapshotParser.d.ts +15 -0
- package/dist/r11sSnapshotParser.d.ts.map +1 -0
- package/dist/r11sSnapshotParser.js +75 -0
- package/dist/r11sSnapshotParser.js.map +1 -0
- package/dist/restWrapper.d.ts +3 -3
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +19 -15
- package/dist/restWrapper.js.map +1 -1
- package/dist/treeUtils.d.ts +1 -1
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.d.ts +4 -3
- package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/dist/wholeSummaryDocumentStorageService.js +57 -26
- package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
- package/lib/contracts.d.ts +15 -0
- package/lib/contracts.d.ts.map +1 -0
- package/lib/contracts.js +6 -0
- package/lib/contracts.js.map +1 -0
- package/lib/documentService.d.ts +4 -2
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +5 -4
- package/lib/documentService.js.map +1 -1
- package/lib/documentServiceFactory.d.ts +2 -1
- package/lib/documentServiceFactory.d.ts.map +1 -1
- package/lib/documentServiceFactory.js +11 -4
- package/lib/documentServiceFactory.js.map +1 -1
- package/lib/documentStorageService.d.ts +3 -2
- package/lib/documentStorageService.d.ts.map +1 -1
- package/lib/documentStorageService.js +4 -4
- package/lib/documentStorageService.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/r11sSnapshotParser.d.ts +15 -0
- package/lib/r11sSnapshotParser.d.ts.map +1 -0
- package/lib/r11sSnapshotParser.js +71 -0
- package/lib/r11sSnapshotParser.js.map +1 -0
- package/lib/restWrapper.d.ts +3 -3
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +20 -16
- package/lib/restWrapper.js.map +1 -1
- package/lib/treeUtils.d.ts +1 -1
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.d.ts +4 -3
- package/lib/wholeSummaryDocumentStorageService.d.ts.map +1 -1
- package/lib/wholeSummaryDocumentStorageService.js +56 -25
- package/lib/wholeSummaryDocumentStorageService.js.map +1 -1
- package/package.json +8 -8
- package/src/contracts.ts +16 -0
- package/src/documentService.ts +6 -3
- package/src/documentServiceFactory.ts +16 -5
- package/src/documentStorageService.ts +8 -4
- package/src/packageVersion.ts +1 -1
- package/src/r11sSnapshotParser.ts +83 -0
- package/src/restWrapper.ts +15 -18
- package/src/treeUtils.ts +1 -1
- package/src/wholeSummaryDocumentStorageService.ts +79 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.d.ts","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC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CAAC,CAAC,CAAC,CAAC;YAkFd,eAAe;IAkBhB,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IASzC,QAAQ,CAAC,KAAK,EAAE,cAAc;CAGrC;AAED,qBAAa,+BAAgC,SAAQ,wBAAwB;IAC5E,OAAO;WAoBa,IAAI,CACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,+BAA+B,CAAC;CA+C3C;AAED,qBAAa,+BAAgC,SAAQ,wBAAwB;IAC5E,OAAO;WAoBa,IAAI,CACvB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,gBAAgB,EACxB,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,+BAA+B,CAAC;CAqC3C"}
|
package/dist/restWrapper.js
CHANGED
|
@@ -73,10 +73,9 @@ function getPropsToLogFromResponse(headers) {
|
|
|
73
73
|
}
|
|
74
74
|
exports.getPropsToLogFromResponse = getPropsToLogFromResponse;
|
|
75
75
|
class RouterliciousRestWrapper extends restWrapperBase_1.RestWrapper {
|
|
76
|
-
constructor(logger, rateLimiter,
|
|
76
|
+
constructor(logger, rateLimiter, fetchRefreshedToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString = {}) {
|
|
77
77
|
super(baseurl, defaultQueryString);
|
|
78
78
|
this.rateLimiter = rateLimiter;
|
|
79
|
-
this.token = token;
|
|
80
79
|
this.fetchRefreshedToken = fetchRefreshedToken;
|
|
81
80
|
this.getAuthorizationHeader = getAuthorizationHeader;
|
|
82
81
|
this.useRestLess = useRestLess;
|
|
@@ -84,7 +83,7 @@ class RouterliciousRestWrapper extends restWrapperBase_1.RestWrapper {
|
|
|
84
83
|
}
|
|
85
84
|
async request(requestConfig, statusCode, canRetry = true) {
|
|
86
85
|
var _a;
|
|
87
|
-
const config = Object.assign(Object.assign({}, requestConfig), { headers: this.generateHeaders(requestConfig.headers) });
|
|
86
|
+
const config = Object.assign(Object.assign({}, requestConfig), { headers: await this.generateHeaders(requestConfig.headers) });
|
|
88
87
|
const translatedConfig = this.useRestLess ? this.restLess.translate(config) : config;
|
|
89
88
|
const fetchRequestConfig = axiosRequestConfigToFetchRequestConfig(translatedConfig);
|
|
90
89
|
const res = await this.rateLimiter.schedule(async () => {
|
|
@@ -141,18 +140,25 @@ class RouterliciousRestWrapper extends restWrapperBase_1.RestWrapper {
|
|
|
141
140
|
: response.statusText;
|
|
142
141
|
(0, errorUtils_1.throwR11sNetworkError)(`R11s fetch error: ${responseSummary}`, response.status, responseBody === null || responseBody === void 0 ? void 0 : responseBody.retryAfter);
|
|
143
142
|
}
|
|
144
|
-
generateHeaders(requestHeaders) {
|
|
143
|
+
async generateHeaders(requestHeaders) {
|
|
145
144
|
var _a;
|
|
145
|
+
const token = await this.getToken();
|
|
146
|
+
(0, common_utils_1.assert)(token !== undefined, 0x679 /* token should be present */);
|
|
146
147
|
const correlationId = (_a = requestHeaders === null || requestHeaders === void 0 ? void 0 : requestHeaders["x-correlation-id"]) !== null && _a !== void 0 ? _a : (0, uuid_1.v4)();
|
|
147
148
|
return Object.assign(Object.assign({}, requestHeaders), {
|
|
148
149
|
// TODO: replace header names with CorrelationIdHeaderName and DriverVersionHeaderName from services-client
|
|
149
150
|
// NOTE: Can correlationId actually be number | true?
|
|
150
151
|
"x-correlation-id": correlationId, "x-driver-version": packageVersion_1.pkgVersion,
|
|
151
152
|
// NOTE: If this.authorizationHeader is undefined, should "Authorization" be removed entirely?
|
|
152
|
-
"Authorization": this.getAuthorizationHeader(
|
|
153
|
+
"Authorization": this.getAuthorizationHeader(token) });
|
|
153
154
|
}
|
|
154
|
-
getToken() {
|
|
155
|
-
|
|
155
|
+
async getToken() {
|
|
156
|
+
if (this.token !== undefined) {
|
|
157
|
+
return this.token;
|
|
158
|
+
}
|
|
159
|
+
const token = await this.fetchRefreshedToken();
|
|
160
|
+
this.setToken(token);
|
|
161
|
+
return token;
|
|
156
162
|
}
|
|
157
163
|
setToken(token) {
|
|
158
164
|
this.token = token;
|
|
@@ -160,8 +166,8 @@ class RouterliciousRestWrapper extends restWrapperBase_1.RestWrapper {
|
|
|
160
166
|
}
|
|
161
167
|
exports.RouterliciousRestWrapper = RouterliciousRestWrapper;
|
|
162
168
|
class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {
|
|
163
|
-
constructor(logger, rateLimiter,
|
|
164
|
-
super(logger, rateLimiter,
|
|
169
|
+
constructor(logger, rateLimiter, fetchToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString = {}) {
|
|
170
|
+
super(logger, rateLimiter, fetchToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString);
|
|
165
171
|
}
|
|
166
172
|
static async load(tenantId, documentId, tokenProvider, logger, rateLimiter, useRestLess, baseurl) {
|
|
167
173
|
const defaultQueryString = {
|
|
@@ -184,15 +190,14 @@ class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {
|
|
|
184
190
|
};
|
|
185
191
|
return (0, server_services_client_1.getAuthorizationTokenFromCredentials)(credentials);
|
|
186
192
|
};
|
|
187
|
-
const
|
|
188
|
-
const restWrapper = new RouterliciousStorageRestWrapper(logger, rateLimiter, storagetoken, fetchStorageToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString);
|
|
193
|
+
const restWrapper = new RouterliciousStorageRestWrapper(logger, rateLimiter, fetchStorageToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString);
|
|
189
194
|
return restWrapper;
|
|
190
195
|
}
|
|
191
196
|
}
|
|
192
197
|
exports.RouterliciousStorageRestWrapper = RouterliciousStorageRestWrapper;
|
|
193
198
|
class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {
|
|
194
|
-
constructor(logger, rateLimiter,
|
|
195
|
-
super(logger, rateLimiter,
|
|
199
|
+
constructor(logger, rateLimiter, fetchToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString = {}) {
|
|
200
|
+
super(logger, rateLimiter, fetchToken, getAuthorizationHeader, useRestLess, baseurl, defaultQueryString);
|
|
196
201
|
}
|
|
197
202
|
static async load(tenantId, documentId, tokenProvider, logger, rateLimiter, useRestLess, baseurl) {
|
|
198
203
|
const getAuthorizationHeader = (token) => {
|
|
@@ -207,8 +212,7 @@ class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {
|
|
|
207
212
|
return ordererToken;
|
|
208
213
|
});
|
|
209
214
|
};
|
|
210
|
-
const
|
|
211
|
-
const restWrapper = new RouterliciousOrdererRestWrapper(logger, rateLimiter, newtoken, fetchOrdererToken, getAuthorizationHeader, useRestLess, baseurl);
|
|
215
|
+
const restWrapper = new RouterliciousOrdererRestWrapper(logger, rateLimiter, fetchOrdererToken, getAuthorizationHeader, useRestLess, baseurl);
|
|
212
216
|
return restWrapper;
|
|
213
217
|
}
|
|
214
218
|
}
|
package/dist/restWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,+DAA6E;AAE7E,mFAGgD;AAChD,qEAAoF;AACpF,8DAAgC;AAEhC,8EAAgD;AAChD,+BAAkC;AAClC,6CAAqD;AAErD,qDAA+D;AAC/D,uDAAiE;AAKjE,MAAM,sCAAsC,GAAG,CAC9C,aAAiC,EACJ,EAAE;;IAC/B,MAAM,WAAW,GAChB,aAAa,CAAC,OAAO,KAAK,SAAS;QAClC,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,GAAG,MAAA,aAAa,CAAC,GAAG,mCAAI,EAAE,EAAE;QACtD,CAAC,CAAC,MAAA,aAAa,CAA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QAEhB,MAAM,sBAAsB,GAA8B,CACzD,KAAqB,EACZ,EAAE;YACX,OAAO,SAAS,KAAK,CAAC,GAAG,EAAE,CAAC;QAC7B,CAAC,CAAC;QAEF,MAAM,iBAAiB,GAAG,KAAK,EAAE,YAAsB,EAA2B,EAAE;YACnF,OAAO,kCAAgB,CAAC,cAAc,CACrC,MAAM,EACN;gBACC,SAAS,EAAE,mBAAmB;gBAC9B,KAAK,EAAE,UAAU;aACjB,EACD,KAAK,IAAI,EAAE;gBACV,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,iBAAiB,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;gBAEF,OAAO,YAAY,CAAC;YACrB,CAAC,CACD,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,iBAAiB,EAAE,CAAC;QAE3C,MAAM,WAAW,GAAG,IAAI,+BAA+B,CACtD,MAAM,EACN,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,OAAO,CACP,CAAC;QAEF,OAAO,WAAW,CAAC;IACpB,CAAC;CACD;AAvED,0EAuEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { RateLimiter } from \"@fluidframework/driver-utils\";\nimport {\n\tgetAuthorizationTokenFromCredentials,\n\tRestLessClient,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent, TelemetryLogger } from \"@fluidframework/telemetry-utils\";\nimport fetch from \"cross-fetch\";\nimport type { AxiosRequestConfig, AxiosRequestHeaders } from \"axios\";\nimport safeStringify from \"json-stringify-safe\";\nimport { v4 as uuid } from \"uuid\";\nimport { throwR11sNetworkError } from \"./errorUtils\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { QueryStringType, RestWrapper } from \"./restWrapperBase\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\ntype TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst axiosRequestConfigToFetchRequestConfig = (\n\trequestConfig: AxiosRequestConfig,\n): [RequestInfo, RequestInit] => {\n\tconst requestInfo: string =\n\t\trequestConfig.baseURL !== undefined\n\t\t\t? `${requestConfig.baseURL}${requestConfig.url ?? \"\"}`\n\t\t\t: requestConfig.url ?? \"\";\n\tconst requestInit: RequestInit = {\n\t\tmethod: requestConfig.method,\n\t\t// NOTE: I believe that although the Axios type permits non-string values in the header, here we are\n\t\t// guaranteed the requestConfig only has string values in its header.\n\t\theaders: requestConfig.headers as Record<string, string>,\n\t\tbody: requestConfig.data,\n\t};\n\treturn [requestInfo, requestInit];\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a r11s response without any additional props as we might not have them always.\n * @param content - response which is equivalent to content.\n * @returns - a r11s response without any extra props.\n */\nexport function createR11sResponseFromContent<T>(content: T): IR11sResponse<T> {\n\treturn {\n\t\tcontent,\n\t\theaders: new Map(),\n\t\tpropsToLog: {},\n\t\trequestUrl: \"\",\n\t};\n}\n\nfunction headersToMap(headers: Headers) {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\nexport function getPropsToLogFromResponse(headers: {\n\tget: (id: string) => string | undefined | null;\n}) {\n\tinterface LoggingHeader {\n\t\theaderName: string;\n\t\tlogName: string;\n\t}\n\n\t// We rename headers so that otel doesn't scrub them away. Otel doesn't allow\n\t// certain characters in headers including '-'\n\tconst headersToLog: LoggingHeader[] = [\n\t\t{ headerName: \"x-correlation-id\", logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryProperties = {\n\t\tcontentsize: TelemetryLogger.numberFromString(headers.get(\"content-length\")),\n\t};\n\theadersToLog.forEach((header) => {\n\t\tconst headerValue = headers.get(header.headerName);\n\t\tif (headerValue !== undefined && headerValue !== null) {\n\t\t\tadditionalProps[header.logName] = headerValue;\n\t\t}\n\t});\n\n\treturn additionalProps;\n}\n\nexport class RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\n\tconstructor(\n\t\tlogger: ITelemetryLogger,\n\t\tprivate readonly rateLimiter: RateLimiter,\n\t\tprivate token: ITokenResponse,\n\t\tprivate readonly fetchRefreshedToken: TokenFetcher,\n\t\tprivate readonly getAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tprivate readonly useRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(baseurl, defaultQueryString);\n\t}\n\n\tprotected async request<T>(\n\t\trequestConfig: AxiosRequestConfig,\n\t\tstatusCode: number,\n\t\tcanRetry = true,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst config = {\n\t\t\t...requestConfig,\n\t\t\theaders: this.generateHeaders(requestConfig.headers),\n\t\t};\n\n\t\tconst translatedConfig = this.useRestLess ? this.restLess.translate(config) : config;\n\t\tconst fetchRequestConfig = axiosRequestConfigToFetchRequestConfig(translatedConfig);\n\n\t\tconst res = await this.rateLimiter.schedule(async () => {\n\t\t\tconst perfStart = performance.now();\n\t\t\tconst result = await fetch(...fetchRequestConfig).catch(async (error) => {\n\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\tthrowR11sNetworkError(\n\t\t\t\t\tisNetworkError ? `NetworkError: ${error.message}` : safeStringify(error),\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tresponse: result,\n\t\t\t\tduration: performance.now() - perfStart,\n\t\t\t};\n\t\t});\n\n\t\tconst response = res.response;\n\n\t\tlet start = performance.now();\n\t\tconst text = await response.text();\n\t\tconst receiveContentTime = performance.now() - start;\n\n\t\tconst bodySize = text.length;\n\t\tstart = performance.now();\n\t\tconst responseBody: any = response.headers.get(\"content-type\")?.includes(\"application/json\")\n\t\t\t? JSON.parse(text)\n\t\t\t: text;\n\t\tconst parseTime = performance.now() - start;\n\n\t\t// Success\n\t\tif (response.ok || response.status === statusCode) {\n\t\t\tconst result = responseBody as T;\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: result,\n\t\t\t\theaders,\n\t\t\t\trequestUrl: fetchRequestConfig[0].toString(),\n\t\t\t\tpropsToLog: {\n\t\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\t\tbodySize,\n\t\t\t\t\treceiveContentTime,\n\t\t\t\t\tparseTime,\n\t\t\t\t\tfetchTime: res.duration,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\t// Failure\n\t\tif (response.status === 401 && canRetry) {\n\t\t\t// Refresh Authorization header and retry once\n\t\t\tthis.token = await this.fetchRefreshedToken(true /* refreshToken */);\n\t\t\treturn this.request<T>(config, statusCode, false);\n\t\t}\n\t\tif (response.status === 429 && responseBody?.retryAfter > 0) {\n\t\t\t// Retry based on retryAfter[Seconds]\n\t\t\treturn new Promise<IR11sResponse<T>>((resolve, reject) =>\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.request<T>(config, statusCode).then(resolve).catch(reject);\n\t\t\t\t}, responseBody.retryAfter * 1000),\n\t\t\t);\n\t\t}\n\n\t\tconst responseSummary =\n\t\t\tresponseBody !== undefined\n\t\t\t\t? typeof responseBody === \"string\"\n\t\t\t\t\t? responseBody\n\t\t\t\t\t: safeStringify(responseBody)\n\t\t\t\t: response.statusText;\n\t\tthrowR11sNetworkError(\n\t\t\t`R11s fetch error: ${responseSummary}`,\n\t\t\tresponse.status,\n\t\t\tresponseBody?.retryAfter,\n\t\t);\n\t}\n\n\tprivate generateHeaders(\n\t\trequestHeaders?: AxiosRequestHeaders | undefined,\n\t): Record<string, string> {\n\t\tconst correlationId = requestHeaders?.[\"x-correlation-id\"] ?? uuid();\n\n\t\treturn {\n\t\t\t...requestHeaders,\n\t\t\t// TODO: replace header names with CorrelationIdHeaderName and DriverVersionHeaderName from services-client\n\t\t\t// NOTE: Can correlationId actually be number | true?\n\t\t\t\"x-correlation-id\": correlationId as string,\n\t\t\t\"x-driver-version\": driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\t\"Authorization\": this.getAuthorizationHeader(this.token),\n\t\t};\n\t}\n\n\tpublic getToken(): ITokenResponse {\n\t\treturn this.token;\n\t}\n\n\tpublic setToken(token: ITokenResponse) {\n\t\tthis.token = token;\n\t}\n}\n\nexport class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\ttoken: ITokenResponse,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttoken,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static async load(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\ttokenProvider: ITokenProvider,\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t): Promise<RouterliciousStorageRestWrapper> {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\n\t\t};\n\n\t\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\t\ttenantId,\n\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn storageToken;\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\tconst credentials = {\n\t\t\t\tpassword: token.jwt,\n\t\t\t\tuser: tenantId,\n\t\t\t};\n\t\t\treturn getAuthorizationTokenFromCredentials(credentials);\n\t\t};\n\n\t\tconst storagetoken = await fetchStorageToken();\n\n\t\tconst restWrapper = new RouterliciousStorageRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tstoragetoken,\n\t\t\tfetchStorageToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tdefaultQueryString,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\ttoken: ITokenResponse,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttoken,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static async load(\n\t\ttenantId: string,\n\t\tdocumentId: string | undefined,\n\t\ttokenProvider: ITokenProvider,\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t): Promise<RouterliciousOrdererRestWrapper> {\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\treturn `Basic ${token.jwt}`;\n\t\t};\n\n\t\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\t\ttenantId,\n\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn ordererToken;\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\tconst newtoken = await fetchOrdererToken();\n\n\t\tconst restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tnewtoken,\n\t\t\tfetchOrdererToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAGH,+DAAqF;AAErF,mFAGg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All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert, fromUtf8ToBase64, performance } from \"@fluidframework/common-utils\";\nimport { RateLimiter } from \"@fluidframework/driver-utils\";\nimport {\n\tgetAuthorizationTokenFromCredentials,\n\tRestLessClient,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent, TelemetryLogger } from \"@fluidframework/telemetry-utils\";\nimport fetch from \"cross-fetch\";\nimport type { AxiosRequestConfig, AxiosRequestHeaders } from \"axios\";\nimport safeStringify from \"json-stringify-safe\";\nimport { v4 as uuid } from \"uuid\";\nimport { throwR11sNetworkError } from \"./errorUtils\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { QueryStringType, RestWrapper } from \"./restWrapperBase\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\ntype TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst axiosRequestConfigToFetchRequestConfig = (\n\trequestConfig: AxiosRequestConfig,\n): [RequestInfo, RequestInit] => {\n\tconst requestInfo: string =\n\t\trequestConfig.baseURL !== undefined\n\t\t\t? `${requestConfig.baseURL}${requestConfig.url ?? \"\"}`\n\t\t\t: requestConfig.url ?? \"\";\n\tconst requestInit: RequestInit = {\n\t\tmethod: requestConfig.method,\n\t\t// NOTE: I believe that although the Axios type permits non-string values in the header, here we are\n\t\t// guaranteed the requestConfig only has string values in its header.\n\t\theaders: requestConfig.headers as Record<string, string>,\n\t\tbody: requestConfig.data,\n\t};\n\treturn [requestInfo, requestInit];\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a r11s response without any additional props as we might not have them always.\n * @param content - response which is equivalent to content.\n * @returns - a r11s response without any extra props.\n */\nexport function createR11sResponseFromContent<T>(content: T): IR11sResponse<T> {\n\treturn {\n\t\tcontent,\n\t\theaders: new Map(),\n\t\tpropsToLog: {},\n\t\trequestUrl: \"\",\n\t};\n}\n\nfunction headersToMap(headers: Headers) {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\nexport function getPropsToLogFromResponse(headers: {\n\tget: (id: string) => string | undefined | null;\n}) {\n\tinterface LoggingHeader {\n\t\theaderName: string;\n\t\tlogName: string;\n\t}\n\n\t// We rename headers so that otel doesn't scrub them away. Otel doesn't allow\n\t// certain characters in headers including '-'\n\tconst headersToLog: LoggingHeader[] = [\n\t\t{ headerName: \"x-correlation-id\", logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryProperties = {\n\t\tcontentsize: TelemetryLogger.numberFromString(headers.get(\"content-length\")),\n\t};\n\theadersToLog.forEach((header) => {\n\t\tconst headerValue = headers.get(header.headerName);\n\t\tif (headerValue !== undefined && headerValue !== null) {\n\t\t\tadditionalProps[header.logName] = headerValue;\n\t\t}\n\t});\n\n\treturn additionalProps;\n}\n\nexport class RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\tprivate token: ITokenResponse | undefined;\n\n\tconstructor(\n\t\tlogger: ITelemetryLogger,\n\t\tprivate readonly rateLimiter: RateLimiter,\n\t\tprivate readonly fetchRefreshedToken: TokenFetcher,\n\t\tprivate readonly getAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tprivate readonly useRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(baseurl, defaultQueryString);\n\t}\n\n\tprotected async request<T>(\n\t\trequestConfig: AxiosRequestConfig,\n\t\tstatusCode: number,\n\t\tcanRetry = true,\n\t): Promise<IR11sResponse<T>> {\n\t\tconst config = {\n\t\t\t...requestConfig,\n\t\t\theaders: await this.generateHeaders(requestConfig.headers),\n\t\t};\n\n\t\tconst translatedConfig = this.useRestLess ? this.restLess.translate(config) : config;\n\t\tconst fetchRequestConfig = axiosRequestConfigToFetchRequestConfig(translatedConfig);\n\n\t\tconst res = await this.rateLimiter.schedule(async () => {\n\t\t\tconst perfStart = performance.now();\n\t\t\tconst result = await fetch(...fetchRequestConfig).catch(async (error) => {\n\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\tthrowR11sNetworkError(\n\t\t\t\t\tisNetworkError ? `NetworkError: ${error.message}` : safeStringify(error),\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tresponse: result,\n\t\t\t\tduration: performance.now() - perfStart,\n\t\t\t};\n\t\t});\n\n\t\tconst response = res.response;\n\n\t\tlet start = performance.now();\n\t\tconst text = await response.text();\n\t\tconst receiveContentTime = performance.now() - start;\n\n\t\tconst bodySize = text.length;\n\t\tstart = performance.now();\n\t\tconst responseBody: any = response.headers.get(\"content-type\")?.includes(\"application/json\")\n\t\t\t? JSON.parse(text)\n\t\t\t: text;\n\t\tconst parseTime = performance.now() - start;\n\n\t\t// Success\n\t\tif (response.ok || response.status === statusCode) {\n\t\t\tconst result = responseBody as T;\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: result,\n\t\t\t\theaders,\n\t\t\t\trequestUrl: fetchRequestConfig[0].toString(),\n\t\t\t\tpropsToLog: {\n\t\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\t\tbodySize,\n\t\t\t\t\treceiveContentTime,\n\t\t\t\t\tparseTime,\n\t\t\t\t\tfetchTime: res.duration,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\t// Failure\n\t\tif (response.status === 401 && canRetry) {\n\t\t\t// Refresh Authorization header and retry once\n\t\t\tthis.token = await this.fetchRefreshedToken(true /* refreshToken */);\n\t\t\treturn this.request<T>(config, statusCode, false);\n\t\t}\n\t\tif (response.status === 429 && responseBody?.retryAfter > 0) {\n\t\t\t// Retry based on retryAfter[Seconds]\n\t\t\treturn new Promise<IR11sResponse<T>>((resolve, reject) =>\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.request<T>(config, statusCode).then(resolve).catch(reject);\n\t\t\t\t}, responseBody.retryAfter * 1000),\n\t\t\t);\n\t\t}\n\n\t\tconst responseSummary =\n\t\t\tresponseBody !== undefined\n\t\t\t\t? typeof responseBody === \"string\"\n\t\t\t\t\t? responseBody\n\t\t\t\t\t: safeStringify(responseBody)\n\t\t\t\t: response.statusText;\n\t\tthrowR11sNetworkError(\n\t\t\t`R11s fetch error: ${responseSummary}`,\n\t\t\tresponse.status,\n\t\t\tresponseBody?.retryAfter,\n\t\t);\n\t}\n\n\tprivate async generateHeaders(\n\t\trequestHeaders?: AxiosRequestHeaders | undefined,\n\t): Promise<Record<string, string>> {\n\t\tconst token = await this.getToken();\n\t\tassert(token !== undefined, 0x679 /* token should be present */);\n\t\tconst correlationId = requestHeaders?.[\"x-correlation-id\"] ?? uuid();\n\n\t\treturn {\n\t\t\t...requestHeaders,\n\t\t\t// TODO: replace header names with CorrelationIdHeaderName and DriverVersionHeaderName from services-client\n\t\t\t// NOTE: Can correlationId actually be number | true?\n\t\t\t\"x-correlation-id\": correlationId as string,\n\t\t\t\"x-driver-version\": driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\t\"Authorization\": this.getAuthorizationHeader(token),\n\t\t};\n\t}\n\n\tpublic async getToken(): Promise<ITokenResponse> {\n\t\tif (this.token !== undefined) {\n\t\t\treturn this.token;\n\t\t}\n\t\tconst token = await this.fetchRefreshedToken();\n\t\tthis.setToken(token);\n\t\treturn token;\n\t}\n\n\tpublic setToken(token: ITokenResponse) {\n\t\tthis.token = token;\n\t}\n}\n\nexport class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static async load(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\ttokenProvider: ITokenProvider,\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t): Promise<RouterliciousStorageRestWrapper> {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\n\t\t};\n\n\t\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\t\ttenantId,\n\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn storageToken;\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\tconst credentials = {\n\t\t\t\tpassword: token.jwt,\n\t\t\t\tuser: tenantId,\n\t\t\t};\n\t\t\treturn getAuthorizationTokenFromCredentials(credentials);\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousStorageRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchStorageToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tdefaultQueryString,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static async load(\n\t\ttenantId: string,\n\t\tdocumentId: string | undefined,\n\t\ttokenProvider: ITokenProvider,\n\t\tlogger: ITelemetryLogger,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t): Promise<RouterliciousOrdererRestWrapper> {\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\treturn `Basic ${token.jwt}`;\n\t\t};\n\n\t\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\t\ttenantId,\n\t\t\t\t\t\tdocumentId,\n\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t);\n\n\t\t\t\t\treturn ordererToken;\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchOrdererToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n"]}
|
package/dist/treeUtils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { SummaryType, ISnapshotTree, ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
6
|
-
import { INormalizedWholeSummary } from "
|
|
6
|
+
import { INormalizedWholeSummary } from "./contracts";
|
|
7
7
|
/**
|
|
8
8
|
* Summary tree assembler props
|
|
9
9
|
*/
|
package/dist/treeUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"treeUtils.d.ts","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C;;OAEG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC;CACpB;AAED;;GAEG;AACH,qBAAa,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AAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC3D,QAAQ,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, IsoBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { INormalizedWholeSummary } from \"
|
|
1
|
+
{"version":3,"file":"treeUtils.js","sourceRoot":"","sources":["../src/treeUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,+EAK8C;AAa9C;;GAEG;AACH,MAAa,oBAAoB;IAIhC,YAA6B,KAAkC;QAAlC,UAAK,GAAL,KAAK,CAA6B;QAHvD,sBAAiB,GAAW,CAAC,CAAC;QACrB,gBAAW,GAAsC,EAAE,CAAC;IAEH,CAAC;IAEnE;;OAEG;IACH,IAAW,OAAO;;QACjB,OAAO;YACN,IAAI,EAAE,kCAAW,CAAC,IAAI;YACtB,IAAI,oBAAO,IAAI,CAAC,WAAW,CAAE;YAC7B,YAAY,EAAE,MAAA,IAAI,CAAC,KAAK,0CAAE,YAAY;SACtC,CAAC;IACH,CAAC;IAED;;OAEG;IACI,OAAO,CAAC,GAAW,EAAE,OAA4B;QACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,kCAAW,CAAC,IAAI;YACtB,OAAO;SACP,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS,CACf,GAAW,EACX,UAAwE,EACxE,MAAc;QAEd,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG;YACvB,IAAI,EAAE,kCAAW,CAAC,MAAM;YAC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iBAAiB,CAAC,QAAiC;IAClE,MAAM,KAAK,GAAG,wBAAwB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;IACrC,IAAI,gBAAgB,GAAG,CAAC,CAAC;IACzB,KAAK,MAAM,CAAC,CAAC,EAAE,WAAW,CAAC,IAAI,QAAQ,CAAC,KAAK,EAAE;QAC9C,gBAAgB,IAAI,WAAW,CAAC,UAAU,CAAC;KAC3C;IACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;AAC9C,CAAC;AARD,8CAQC;AAED,SAAgB,qBAAqB,CAAC,QAAuB;IAC5D,IAAA,qBAAM,EACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;IACF,IAAA,qBAAM,EACL,QAAQ,CAAC,KAAK,KAAK,SAAS,EAC5B,KAAK,CAAC,oDAAoD,CAC1D,CAAC;AACH,CAAC;AATD,sDASC;AAED,SAAS,wBAAwB,CAAC,YAA2B;IAC5D,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE;QAC3D,QAAQ,IAAI,CAAC,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;KAC/C;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, IsoBuffer } from \"@fluidframework/common-utils\";\nimport {\n\tSummaryType,\n\tISnapshotTree,\n\tISummaryTree,\n\tSummaryObject,\n} from \"@fluidframework/protocol-definitions\";\nimport { INormalizedWholeSummary } from \"./contracts\";\n\n/**\n * Summary tree assembler props\n */\nexport interface ISummaryTreeAssemblerProps {\n\t/**\n\t * Indicates that this tree is unreferenced. If this is not present, the tree is considered referenced.\n\t */\n\tunreferenced?: true;\n}\n\n/**\n * Summary tree assembler (without stats collection).\n */\nexport class SummaryTreeAssembler {\n\tprivate attachmentCounter: number = 0;\n\tprivate readonly summaryTree: { [path: string]: SummaryObject } = {};\n\n\tconstructor(private readonly props?: ISummaryTreeAssemblerProps) {}\n\n\t/**\n\t * Get final summary\n\t */\n\tpublic get summary(): ISummaryTree {\n\t\treturn {\n\t\t\ttype: SummaryType.Tree,\n\t\t\ttree: { ...this.summaryTree },\n\t\t\tunreferenced: this.props?.unreferenced,\n\t\t};\n\t}\n\n\t/**\n\t * Add blob to summary\n\t */\n\tpublic addBlob(key: string, content: string | Uint8Array): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Blob,\n\t\t\tcontent,\n\t\t};\n\t}\n\n\t/**\n\t * Add handle to summary\n\t */\n\tpublic addHandle(\n\t\tkey: string,\n\t\thandleType: SummaryType.Tree | SummaryType.Blob | SummaryType.Attachment,\n\t\thandle: string,\n\t): void {\n\t\tthis.summaryTree[key] = {\n\t\t\ttype: SummaryType.Handle,\n\t\t\thandleType,\n\t\t\thandle,\n\t\t};\n\t}\n\n\t/**\n\t * Add tree to summary\n\t */\n\tpublic addTree(key: string, summary: ISummaryTree): void {\n\t\tthis.summaryTree[key] = summary;\n\t}\n\n\t/**\n\t * Add attachment to summary\n\t */\n\tpublic addAttachment(id: string) {\n\t\tthis.summaryTree[this.attachmentCounter++] = { id, type: SummaryType.Attachment };\n\t}\n}\n\n/**\n * Helper function that converts ISnapshotTree and blobs to ISummaryTree\n * @param snapshot - Source snapshot tree\n * @param blobs - Blobs cache\n * @returns Converted snapshot in ISummaryTree format\n */\nexport function convertSnapshotAndBlobsToSummaryTree(\n\tsnapshot: ISnapshotTree,\n\tblobs: Map<string, ArrayBuffer>,\n): ISummaryTree {\n\tconst assembler = new SummaryTreeAssembler({\n\t\tunreferenced: snapshot.unreferenced,\n\t});\n\tfor (const [path, id] of Object.entries(snapshot.blobs)) {\n\t\tconst blob = blobs.get(id);\n\t\tassert(blob !== undefined, 0x2dd /* \"Cannot find blob for a given id\" */);\n\t\tassembler.addBlob(path, IsoBuffer.from(blob).toString(\"utf-8\"));\n\t}\n\tfor (const [key, tree] of Object.entries(snapshot.trees)) {\n\t\tconst subtree = convertSnapshotAndBlobsToSummaryTree(tree, blobs);\n\t\tassembler.addTree(key, subtree);\n\t}\n\treturn assembler.summary;\n}\n\nexport function evalBlobsAndTrees(snapshot: INormalizedWholeSummary) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: ISnapshotTree) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x5d0 /* Returned r11s snapshot is malformed. No trees! */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x5d1 /* Returned r11s snapshot is malformed. No blobs! */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1 + countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n"]}
|
|
@@ -6,9 +6,9 @@ import type { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
|
6
6
|
import { IDocumentStorageService, ISummaryContext, IDocumentStorageServicePolicies } from "@fluidframework/driver-definitions";
|
|
7
7
|
import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
|
|
8
8
|
import { ICache } from "./cache";
|
|
9
|
-
import { ISnapshotTreeVersion } from "./definitions";
|
|
10
9
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
11
10
|
import { GitManager } from "./gitManager";
|
|
11
|
+
import { INormalizedWholeSummary } from "./contracts";
|
|
12
12
|
export declare class WholeSummaryDocumentStorageService implements IDocumentStorageService {
|
|
13
13
|
protected readonly id: string;
|
|
14
14
|
protected readonly manager: GitManager;
|
|
@@ -22,14 +22,15 @@ export declare class WholeSummaryDocumentStorageService implements IDocumentStor
|
|
|
22
22
|
private firstVersionsCall;
|
|
23
23
|
get repositoryUrl(): string;
|
|
24
24
|
private getSummaryUploadManager;
|
|
25
|
-
constructor(id: string, manager: GitManager, logger: ITelemetryLogger, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies | undefined, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<
|
|
25
|
+
constructor(id: string, manager: GitManager, logger: ITelemetryLogger, policies: IDocumentStorageServicePolicies, driverPolicies?: IRouterliciousDriverPolicies | undefined, blobCache?: ICache<ArrayBufferLike>, snapshotTreeCache?: ICache<INormalizedWholeSummary>, noCacheGitManager?: GitManager | undefined, getStorageManager?: (disableCache?: boolean) => Promise<GitManager>);
|
|
26
26
|
getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
|
|
27
27
|
getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null>;
|
|
28
28
|
readBlob(blobId: string): Promise<ArrayBufferLike>;
|
|
29
29
|
uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
|
|
30
30
|
downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree>;
|
|
31
31
|
createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
|
|
32
|
-
private
|
|
32
|
+
private fetchSnapshotTree;
|
|
33
|
+
private initializeFromSnapshot;
|
|
33
34
|
private initBlobCache;
|
|
34
35
|
private getCacheKey;
|
|
35
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAQ3E,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAQ3E,OAAO,EACN,uBAAuB,EACvB,eAAe,EACf,+BAA+B,EAC/B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,MAAM,EAAiB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAM1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAKtD,qBAAa,kCAAmC,YAAW,uBAAuB;IAahF,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM;IAC7B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU;IACtC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB;aAC3B,QAAQ,EAAE,+BAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAC;IACnC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IApBnC,OAAO,CAAC,iBAAiB,CAAiB;IAE1C,IAAW,aAAa,IAAI,MAAM,CAEjC;YAEa,uBAAuB;gBAMjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,gBAAgB,EAC3B,QAAQ,EAAE,+BAA+B,EACxC,cAAc,CAAC,0CAA8B,EAC7C,SAAS,GAAE,MAAM,CAAC,eAAe,CAAuB,EACxD,iBAAiB,GAAE,MAAM,CAAC,uBAAuB,CAAuB,EACxE,iBAAiB,CAAC,wBAAY,EAC9B,iBAAiB,GAAE,CACnC,YAAY,CAAC,EAAE,OAAO,KAClB,OAAO,CAAC,UAAU,CAGP;IAGJ,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IA4FzE,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqBlE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IA4BlD,wBAAwB,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAqBL,eAAe,CAAC,aAAa,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAwBrE,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAqB9D,iBAAiB;YAwCjB,sBAAsB;YAyBtB,aAAa;IAS3B,OAAO,CAAC,WAAW;CAGnB"}
|
|
@@ -7,11 +7,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.WholeSummaryDocumentStorageService = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
9
|
const driver_base_1 = require("@fluidframework/driver-base");
|
|
10
|
-
const server_services_client_1 = require("@fluidframework/server-services-client");
|
|
11
10
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
12
11
|
const cache_1 = require("./cache");
|
|
13
12
|
const treeUtils_1 = require("./treeUtils");
|
|
14
13
|
const wholeSummaryUploadManager_1 = require("./wholeSummaryUploadManager");
|
|
14
|
+
const r11sSnapshotParser_1 = require("./r11sSnapshotParser");
|
|
15
15
|
const latestSnapshotId = "latest";
|
|
16
16
|
class WholeSummaryDocumentStorageService {
|
|
17
17
|
constructor(id, manager, logger, policies, driverPolicies, blobCache = new cache_1.InMemoryCache(), snapshotTreeCache = new cache_1.InMemoryCache(), noCacheGitManager, getStorageManager = async (disableCache) => disableCache && this.noCacheGitManager !== undefined
|
|
@@ -49,14 +49,47 @@ class WholeSummaryDocumentStorageService {
|
|
|
49
49
|
// If this is the first versions call for the document, we know we will want the latest summary.
|
|
50
50
|
// Fetch latest summary, cache it, and return its id.
|
|
51
51
|
if (this.firstVersionsCall && count === 1) {
|
|
52
|
+
const normalizedSnapshotContents = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
53
|
+
eventName: "ObtainSnapshot",
|
|
54
|
+
versionId: versionId !== null && versionId !== void 0 ? versionId : undefined,
|
|
55
|
+
count,
|
|
56
|
+
enableDiscovery: (_a = this.driverPolicies) === null || _a === void 0 ? void 0 : _a.enableDiscovery,
|
|
57
|
+
}, async (event) => {
|
|
58
|
+
var _a;
|
|
59
|
+
let method;
|
|
60
|
+
const cachedSnapshotP = this.snapshotTreeCache.get(this.getCacheKey(latestSnapshotId));
|
|
61
|
+
const networkSnapshotP = !((_a = this.driverPolicies) === null || _a === void 0 ? void 0 : _a.enableDiscovery)
|
|
62
|
+
? this.fetchSnapshotTree(latestSnapshotId, false, "getVersions")
|
|
63
|
+
: this.fetchSnapshotTree(latestSnapshotId, true, "getVersions");
|
|
64
|
+
const promiseRaceWinner = await (0, driver_base_1.promiseRaceWithWinner)([
|
|
65
|
+
cachedSnapshotP.catch(() => undefined),
|
|
66
|
+
networkSnapshotP.catch(() => undefined),
|
|
67
|
+
]);
|
|
68
|
+
let retrievedSnapshot = promiseRaceWinner.value;
|
|
69
|
+
method = promiseRaceWinner.index === 0 ? "cache" : "network";
|
|
70
|
+
if (retrievedSnapshot === undefined) {
|
|
71
|
+
// if network failed -> wait for cache ( then return network failure)
|
|
72
|
+
// If cache returned empty or failed -> wait for network (success of failure)
|
|
73
|
+
if (promiseRaceWinner.index === 1) {
|
|
74
|
+
retrievedSnapshot = await cachedSnapshotP;
|
|
75
|
+
method = "cache";
|
|
76
|
+
}
|
|
77
|
+
if (retrievedSnapshot === undefined) {
|
|
78
|
+
retrievedSnapshot = await networkSnapshotP;
|
|
79
|
+
method = "network";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
event.end({
|
|
83
|
+
method,
|
|
84
|
+
});
|
|
85
|
+
return retrievedSnapshot;
|
|
86
|
+
});
|
|
87
|
+
const _id = await this.initializeFromSnapshot(normalizedSnapshotContents, latestSnapshotId);
|
|
52
88
|
this.firstVersionsCall = false;
|
|
53
|
-
const { id: _id, snapshotTree } = !((_a = this.driverPolicies) === null || _a === void 0 ? void 0 : _a.enableDiscovery)
|
|
54
|
-
? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)
|
|
55
|
-
: await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);
|
|
56
89
|
return [
|
|
57
90
|
{
|
|
58
91
|
id: _id,
|
|
59
|
-
treeId: snapshotTree.id,
|
|
92
|
+
treeId: normalizedSnapshotContents.snapshotTree.id,
|
|
60
93
|
},
|
|
61
94
|
];
|
|
62
95
|
}
|
|
@@ -85,7 +118,12 @@ class WholeSummaryDocumentStorageService {
|
|
|
85
118
|
}
|
|
86
119
|
requestVersion = versions[0];
|
|
87
120
|
}
|
|
88
|
-
|
|
121
|
+
const normalizedWholeSnapshot = await this.snapshotTreeCache.get(this.getCacheKey(requestVersion.id));
|
|
122
|
+
if (normalizedWholeSnapshot !== undefined) {
|
|
123
|
+
return normalizedWholeSnapshot.snapshotTree;
|
|
124
|
+
}
|
|
125
|
+
return (await this.fetchSnapshotTree(requestVersion.id, undefined, "getSnapshotTree"))
|
|
126
|
+
.snapshotTree;
|
|
89
127
|
}
|
|
90
128
|
async readBlob(blobId) {
|
|
91
129
|
const cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));
|
|
@@ -133,7 +171,7 @@ class WholeSummaryDocumentStorageService {
|
|
|
133
171
|
});
|
|
134
172
|
return response.content;
|
|
135
173
|
});
|
|
136
|
-
const { blobs, snapshotTree } = (0,
|
|
174
|
+
const { blobs, snapshotTree } = (0, r11sSnapshotParser_1.convertWholeFlatSummaryToSnapshotTreeAndBlobs)(wholeFlatSummary, "");
|
|
137
175
|
return (0, treeUtils_1.convertSnapshotAndBlobsToSummaryTree)(snapshotTree, blobs);
|
|
138
176
|
}
|
|
139
177
|
async createBlob(file) {
|
|
@@ -152,48 +190,41 @@ class WholeSummaryDocumentStorageService {
|
|
|
152
190
|
return response;
|
|
153
191
|
});
|
|
154
192
|
}
|
|
155
|
-
async
|
|
156
|
-
const cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(this.getCacheKey(versionId));
|
|
157
|
-
if (cachedSnapshotTreeVersion !== undefined) {
|
|
158
|
-
return {
|
|
159
|
-
id: cachedSnapshotTreeVersion.id,
|
|
160
|
-
snapshotTree: cachedSnapshotTreeVersion.snapshotTree,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
193
|
+
async fetchSnapshotTree(versionId, disableCache, scenarioName) {
|
|
163
194
|
const normalizedWholeSummary = await telemetry_utils_1.PerformanceEvent.timedExecAsync(this.logger, {
|
|
164
195
|
eventName: "getWholeFlatSummary",
|
|
165
196
|
treeId: versionId,
|
|
197
|
+
scenarioName,
|
|
166
198
|
}, async (event) => {
|
|
167
199
|
var _a;
|
|
168
200
|
const manager = await this.getStorageManager(disableCache);
|
|
169
201
|
const response = await manager.getSummary(versionId);
|
|
170
202
|
const start = common_utils_1.performance.now();
|
|
171
|
-
const snapshot = (0,
|
|
203
|
+
const snapshot = (0, r11sSnapshotParser_1.convertWholeFlatSummaryToSnapshotTreeAndBlobs)(response.content);
|
|
172
204
|
const snapshotConversionTime = common_utils_1.performance.now() - start;
|
|
173
205
|
(0, treeUtils_1.validateBlobsAndTrees)(snapshot.snapshotTree);
|
|
174
206
|
const { trees, numBlobs, encodedBlobsSize } = (0, treeUtils_1.evalBlobsAndTrees)(snapshot);
|
|
175
207
|
event.end(Object.assign(Object.assign(Object.assign({ size: (_a = response.content.trees[0]) === null || _a === void 0 ? void 0 : _a.entries.length, trees, blobs: numBlobs, encodedBlobsSize }, response.propsToLog), { snapshotConversionTime }), (0, driver_base_1.getW3CData)(response.requestUrl, "xmlhttprequest")));
|
|
176
208
|
return snapshot;
|
|
177
209
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
};
|
|
210
|
+
return normalizedWholeSummary;
|
|
211
|
+
}
|
|
212
|
+
async initializeFromSnapshot(normalizedWholeSummary, versionId) {
|
|
213
|
+
const snapshotId = normalizedWholeSummary.id;
|
|
214
|
+
(0, common_utils_1.assert)(snapshotId !== undefined, 0x275 /* "Root tree should contain the id" */);
|
|
184
215
|
const cachePs = [
|
|
185
|
-
this.snapshotTreeCache.put(this.getCacheKey(
|
|
216
|
+
this.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),
|
|
186
217
|
this.initBlobCache(normalizedWholeSummary.blobs),
|
|
187
218
|
];
|
|
188
|
-
if (
|
|
219
|
+
if (snapshotId !== versionId && versionId !== null) {
|
|
189
220
|
// versionId could be "latest". When summarizer checks cache for "latest", we want it to be available.
|
|
190
221
|
// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,
|
|
191
222
|
// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply
|
|
192
223
|
// cache with versionId?
|
|
193
|
-
cachePs.push(this.snapshotTreeCache.put(this.getCacheKey(versionId),
|
|
224
|
+
cachePs.push(this.snapshotTreeCache.put(this.getCacheKey(versionId), normalizedWholeSummary));
|
|
194
225
|
}
|
|
195
226
|
await Promise.all(cachePs);
|
|
196
|
-
return
|
|
227
|
+
return snapshotId;
|
|
197
228
|
}
|
|
198
229
|
async initBlobCache(blobs) {
|
|
199
230
|
const blobCachePutPs = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAKsC;AACtC,6DAAyD;AAazD,mFAIgD;AAChD,qEAAmE;AACnE,mCAAgD;AAGhD,2CAIqB;AAErB,2EAAwE;AAIxE,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAa,kCAAkC;IAY9C,YACoB,EAAU,EACV,OAAmB,EACnB,MAAwB,EAC3B,QAAyC,EACxC,cAA6C,EAC7C,YAAqC,IAAI,qBAAa,EAAE,EACxD,oBAAkD,IAAI,qBAAa,EAAE,EACrE,iBAA8B,EAC9B,oBAEU,KAAK,EAAE,YAAY,EAAE,EAAE,CACjD,YAAY,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;QACnD,CAAC,CAAC,IAAI,CAAC,iBAAiB;QACxB,CAAC,CAAC,IAAI,CAAC,OAAO;QAbG,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACnB,WAAM,GAAN,MAAM,CAAkB;QAC3B,aAAQ,GAAR,QAAQ,CAAiC;QACxC,mBAAc,GAAd,cAAc,CAA+B;QAC7C,cAAS,GAAT,SAAS,CAA+C;QACxD,sBAAiB,GAAjB,iBAAiB,CAAoD;QACrE,sBAAiB,GAAjB,iBAAiB,CAAa;QAC9B,sBAAiB,GAAjB,iBAAiB,CAKlB;QAzBT,sBAAiB,GAAY,IAAI,CAAC;I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AAE,EAAE,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AAhRD,gFAgRC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs,\n\tINormalizedWholeSummary,\n\tIWholeFlatSummary,\n} from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLogger,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<ISnapshotTreeVersion> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tthis.firstVersionsCall = false;\n\t\t\tconst { id: _id, snapshotTree } = !this.driverPolicies?.enableDiscovery\n\t\t\t\t? await this.fetchAndCacheSnapshotTree(latestSnapshotId, false)\n\t\t\t\t: await this.fetchAndCacheSnapshotTree(latestSnapshotId, true);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\treturn (await this.fetchAndCacheSnapshotTree(requestVersion.id)).snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchAndCacheSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t): Promise<ISnapshotTreeVersion> {\n\t\tconst cachedSnapshotTreeVersion = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(versionId),\n\t\t);\n\t\tif (cachedSnapshotTreeVersion !== undefined) {\n\t\t\treturn {\n\t\t\t\tid: cachedSnapshotTreeVersion.id,\n\t\t\t\tsnapshotTree: cachedSnapshotTreeVersion.snapshotTree,\n\t\t\t};\n\t\t}\n\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSummary> = await manager.getSummary(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSummary =\n\t\t\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\tassert(\n\t\t\tnormalizedWholeSummary.snapshotTree.id !== undefined,\n\t\t\t0x275 /* \"Root tree should contain the id\" */,\n\t\t);\n\t\tconst wholeFlatSummaryId: string = normalizedWholeSummary.snapshotTree.id;\n\t\tconst snapshotTreeVersion = {\n\t\t\tid: wholeFlatSummaryId,\n\t\t\tsnapshotTree: normalizedWholeSummary.snapshotTree,\n\t\t};\n\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(wholeFlatSummaryId), snapshotTreeVersion),\n\t\t\tthis.initBlobCache(normalizedWholeSummary.blobs),\n\t\t];\n\t\tif (wholeFlatSummaryId !== versionId) {\n\t\t\t// versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n\t\t\t// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n\t\t\t// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n\t\t\t// cache with versionId?\n\t\t\tcachePs.push(\n\t\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(versionId), snapshotTreeVersion),\n\t\t\t);\n\t\t}\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotTreeVersion;\n\t}\n\n\tprivate async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wholeSummaryDocumentStorageService.js","sourceRoot":"","sources":["../src/wholeSummaryDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAKsC;AACtC,6DAAgF;AAchF,qEAAmE;AACnE,mCAAgD;AAEhD,2CAIqB;AAErB,2EAAwE;AAIxE,6DAAqF;AAErF,MAAM,gBAAgB,GAAW,QAAQ,CAAC;AAE1C,MAAa,kCAAkC;IAY9C,YACoB,EAAU,EACV,OAAmB,EACnB,MAAwB,EAC3B,QAAyC,EACxC,cAA6C,EAC7C,YAAqC,IAAI,qBAAa,EAAE,EACxD,oBAAqD,IAAI,qBAAa,EAAE,EACxE,iBAA8B,EAC9B,oBAEU,KAAK,EAAE,YAAY,EAAE,EAAE,CACjD,YAAY,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS;QACnD,CAAC,CAAC,IAAI,CAAC,iBAAiB;QACxB,CAAC,CAAC,IAAI,CAAC,OAAO;QAbG,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACnB,WAAM,GAAN,MAAM,CAAkB;QAC3B,aAAQ,GAAR,QAAQ,CAAiC;QACxC,mBAAc,GAAd,cAAc,CAA+B;QAC7C,cAAS,GAAT,SAAS,CAA+C;QACxD,sBAAiB,GAAjB,iBAAiB,CAAuD;QACxE,sBAAiB,GAAjB,iBAAiB,CAAa;QAC9B,sBAAiB,GAAjB,iBAAiB,CAKlB;QAzBT,sBAAiB,GAAY,IAAI,CAAC;IA0BvC,CAAC;IAxBJ,IAAW,aAAa;QACvB,OAAO,EAAE,CAAC;IACX,CAAC;IAEO,K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AM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACtC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,CAAC;IAEO,WAAW,CAAC,MAAc;QACjC,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IAC/B,CAAC;CACD;AA5TD,gFA4TC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n\tassert,\n\tperformance,\n\tstringToBuffer,\n\tUint8ArrayToString,\n} from \"@fluidframework/common-utils\";\nimport { getW3CData, promiseRaceWithWinner } from \"@fluidframework/driver-base\";\nimport {\n\tIDocumentStorageService,\n\tISummaryContext,\n\tIDocumentStorageServicePolicies,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTree,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { IWholeFlatSummary } from \"@fluidframework/server-services-client\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ICache, InMemoryCache } from \"./cache\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tconvertSnapshotAndBlobsToSummaryTree,\n\tevalBlobsAndTrees,\n\tvalidateBlobsAndTrees,\n} from \"./treeUtils\";\nimport { GitManager } from \"./gitManager\";\nimport { WholeSummaryUploadManager } from \"./wholeSummaryUploadManager\";\nimport { ISummaryUploadManager } from \"./storageContracts\";\nimport { IR11sResponse } from \"./restWrapper\";\nimport { INormalizedWholeSummary } from \"./contracts\";\nimport { convertWholeFlatSummaryToSnapshotTreeAndBlobs } from \"./r11sSnapshotParser\";\n\nconst latestSnapshotId: string = \"latest\";\n\nexport class WholeSummaryDocumentStorageService implements IDocumentStorageService {\n\tprivate firstVersionsCall: boolean = true;\n\n\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tprivate async getSummaryUploadManager(): Promise<ISummaryUploadManager> {\n\t\tconst manager = await this.getStorageManager();\n\t\treturn new WholeSummaryUploadManager(manager);\n\t}\n\n\tconstructor(\n\t\tprotected readonly id: string,\n\t\tprotected readonly manager: GitManager,\n\t\tprotected readonly logger: ITelemetryLogger,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies?: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike> = new InMemoryCache(),\n\t\tprivate readonly snapshotTreeCache: ICache<INormalizedWholeSummary> = new InMemoryCache(),\n\t\tprivate readonly noCacheGitManager?: GitManager,\n\t\tprivate readonly getStorageManager: (\n\t\t\tdisableCache?: boolean,\n\t\t) => Promise<GitManager> = async (disableCache) =>\n\t\t\tdisableCache && this.noCacheGitManager !== undefined\n\t\t\t\t? this.noCacheGitManager\n\t\t\t\t: this.manager,\n\t) {}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tif (versionId !== this.id && versionId !== null) {\n\t\t\t// Blobs/Trees in this scenario will never have multiple versions, so return versionId as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\t// If this is the first versions call for the document, we know we will want the latest summary.\n\t\t// Fetch latest summary, cache it, and return its id.\n\t\tif (this.firstVersionsCall && count === 1) {\n\t\t\tconst normalizedSnapshotContents = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ObtainSnapshot\",\n\t\t\t\t\tversionId: versionId ?? undefined,\n\t\t\t\t\tcount,\n\t\t\t\t\tenableDiscovery: this.driverPolicies?.enableDiscovery,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tlet method: string;\n\t\t\t\t\tconst cachedSnapshotP = this.snapshotTreeCache.get(\n\t\t\t\t\t\tthis.getCacheKey(latestSnapshotId),\n\t\t\t\t\t);\n\n\t\t\t\t\tconst networkSnapshotP = !this.driverPolicies?.enableDiscovery\n\t\t\t\t\t\t? this.fetchSnapshotTree(latestSnapshotId, false, \"getVersions\")\n\t\t\t\t\t\t: this.fetchSnapshotTree(latestSnapshotId, true, \"getVersions\");\n\n\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t]);\n\n\t\t\t\t\tlet retrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tmethod,\n\t\t\t\t\t});\n\t\t\t\t\treturn retrievedSnapshot;\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tconst _id = await this.initializeFromSnapshot(\n\t\t\t\tnormalizedSnapshotContents,\n\t\t\t\tlatestSnapshotId,\n\t\t\t);\n\t\t\tthis.firstVersionsCall = false;\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: _id,\n\t\t\t\t\ttreeId: normalizedSnapshotContents.snapshotTree.id!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Otherwise, get the latest version of the document as normal.\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getVersions\",\n\t\t\t\tversionId: id,\n\t\t\t\tcount,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\treturn (await manager.getCommits(id, count)).content;\n\t\t\t},\n\t\t);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst normalizedWholeSnapshot = await this.snapshotTreeCache.get(\n\t\t\tthis.getCacheKey(requestVersion.id),\n\t\t);\n\t\tif (normalizedWholeSnapshot !== undefined) {\n\t\t\treturn normalizedWholeSnapshot.snapshotTree;\n\t\t}\n\t\treturn (await this.fetchSnapshotTree(requestVersion.id, undefined, \"getSnapshotTree\"))\n\t\t\t.snapshotTree;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst cachedBlob = await this.blobCache.get(this.getCacheKey(blobId));\n\t\tif (cachedBlob !== undefined) {\n\t\t\treturn cachedBlob;\n\t\t}\n\n\t\tconst blob = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"readBlob\",\n\t\t\t\tblobId,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = (await manager.getBlob(blobId)).content;\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.size,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t\tconst bufferValue = stringToBuffer(blob.content, blob.encoding);\n\n\t\tawait this.blobCache.put(this.getCacheKey(blob.sha), bufferValue);\n\n\t\treturn bufferValue;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tconst summaryHandle = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"uploadSummaryWithContext\",\n\t\t\t\tproposalHandle: context.proposalHandle,\n\t\t\t\tackHandle: context.ackHandle,\n\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst summaryUploadManager = await this.getSummaryUploadManager();\n\t\t\t\treturn summaryUploadManager.writeSummaryTree(\n\t\t\t\t\tsummary,\n\t\t\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\t\t\"channel\",\n\t\t\t\t);\n\t\t\t},\n\t\t);\n\t\treturn summaryHandle;\n\t}\n\n\tpublic async downloadSummary(summaryHandle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tconst wholeFlatSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: summaryHandle.handle,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager.getSummary(summaryHandle.handle);\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\tconst { blobs, snapshotTree } = convertWholeFlatSummaryToSnapshotTreeAndBlobs(\n\t\t\twholeFlatSummary,\n\t\t\t\"\",\n\t\t);\n\t\treturn convertSnapshotAndBlobsToSummaryTree(snapshotTree, blobs);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"createBlob\",\n\t\t\t\tsize: uint8ArrayFile.length,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager();\n\t\t\t\tconst response = await manager\n\t\t\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t\t\t.then((r) => ({ id: r.content.sha, url: r.content.url }));\n\t\t\t\tevent.end({\n\t\t\t\t\tblobId: response.id,\n\t\t\t\t});\n\t\t\t\treturn response;\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async fetchSnapshotTree(\n\t\tversionId: string,\n\t\tdisableCache?: boolean,\n\t\tscenarioName?: string,\n\t): Promise<INormalizedWholeSummary> {\n\t\tconst normalizedWholeSummary = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"getWholeFlatSummary\",\n\t\t\t\ttreeId: versionId,\n\t\t\t\tscenarioName,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst manager = await this.getStorageManager(disableCache);\n\t\t\t\tconst response: IR11sResponse<IWholeFlatSummary> = await manager.getSummary(\n\t\t\t\t\tversionId,\n\t\t\t\t);\n\t\t\t\tconst start = performance.now();\n\t\t\t\tconst snapshot: INormalizedWholeSummary =\n\t\t\t\t\tconvertWholeFlatSummaryToSnapshotTreeAndBlobs(response.content);\n\t\t\t\tconst snapshotConversionTime = performance.now() - start;\n\t\t\t\tvalidateBlobsAndTrees(snapshot.snapshotTree);\n\t\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t\tevent.end({\n\t\t\t\t\tsize: response.content.trees[0]?.entries.length,\n\t\t\t\t\ttrees,\n\t\t\t\t\tblobs: numBlobs,\n\t\t\t\t\tencodedBlobsSize,\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\tsnapshotConversionTime,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn snapshot;\n\t\t\t},\n\t\t);\n\n\t\treturn normalizedWholeSummary;\n\t}\n\n\tprivate async initializeFromSnapshot(\n\t\tnormalizedWholeSummary: INormalizedWholeSummary,\n\t\tversionId: string | null,\n\t): Promise<string> {\n\t\tconst snapshotId = normalizedWholeSummary.id;\n\t\tassert(snapshotId !== undefined, 0x275 /* \"Root tree should contain the id\" */);\n\t\tconst cachePs: Promise<any>[] = [\n\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(snapshotId), normalizedWholeSummary),\n\t\t\tthis.initBlobCache(normalizedWholeSummary.blobs),\n\t\t];\n\t\tif (snapshotId !== versionId && versionId !== null) {\n\t\t\t// versionId could be \"latest\". When summarizer checks cache for \"latest\", we want it to be available.\n\t\t\t// TODO: For in-memory cache, <latest,snapshotTree> will be a shared pointer with <snapshotId,snapshotTree>,\n\t\t\t// However, for something like Redis, this will cache the same value twice. Alternatively, could we simply\n\t\t\t// cache with versionId?\n\t\t\tcachePs.push(\n\t\t\t\tthis.snapshotTreeCache.put(this.getCacheKey(versionId), normalizedWholeSummary),\n\t\t\t);\n\t\t}\n\n\t\tawait Promise.all(cachePs);\n\n\t\treturn snapshotId;\n\t}\n\n\tprivate async initBlobCache(blobs: Map<string, ArrayBuffer>): Promise<void> {\n\t\tconst blobCachePutPs: Promise<void>[] = [];\n\t\tblobs.forEach((value, id) => {\n\t\t\tconst cacheKey = this.getCacheKey(id);\n\t\t\tblobCachePutPs.push(this.blobCache.put(cacheKey, value));\n\t\t});\n\t\tawait Promise.all(blobCachePutPs);\n\t}\n\n\tprivate getCacheKey(blobId: string): string {\n\t\treturn `${this.id}:${blobId}`;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
6
|
+
/**
|
|
7
|
+
* Normalized Whole Summary with decoded blobs and unflattened snapshot tree.
|
|
8
|
+
*/
|
|
9
|
+
export interface INormalizedWholeSummary {
|
|
10
|
+
blobs: Map<string, ArrayBuffer>;
|
|
11
|
+
snapshotTree: ISnapshotTree;
|
|
12
|
+
sequenceNumber: number | undefined;
|
|
13
|
+
id: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChC,YAAY,EAAE,aAAa,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,EAAE,EAAE,MAAM,CAAC;CACX"}
|
package/lib/contracts.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface INormalizedWholeSummary {\n\tblobs: Map<string, ArrayBuffer>;\n\tsnapshotTree: ISnapshotTree;\n\tsequenceNumber: number | undefined;\n\tid: string;\n}\n"]}
|
package/lib/documentService.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { RouterliciousOrdererRestWrapper } from "./restWrapper";
|
|
|
10
10
|
import { IRouterliciousDriverPolicies } from "./policies";
|
|
11
11
|
import { ICache } from "./cache";
|
|
12
12
|
import { ISnapshotTreeVersion } from "./definitions";
|
|
13
|
+
import { INormalizedWholeSummary } from "./contracts";
|
|
13
14
|
/**
|
|
14
15
|
* The DocumentService manages the Socket.IO connection and manages routing requests to connected
|
|
15
16
|
* clients.
|
|
@@ -28,14 +29,15 @@ export declare class DocumentService implements api.IDocumentService {
|
|
|
28
29
|
private readonly documentStorageServicePolicies;
|
|
29
30
|
private readonly driverPolicies;
|
|
30
31
|
private readonly blobCache;
|
|
31
|
-
private readonly
|
|
32
|
+
private readonly wholeSnapshotTreeCache;
|
|
33
|
+
private readonly shreddedSummaryTreeCache;
|
|
32
34
|
private readonly discoverFluidResolvedUrl;
|
|
33
35
|
private lastDiscoveredAt;
|
|
34
36
|
private discoverP;
|
|
35
37
|
private storageManager;
|
|
36
38
|
private noCacheStorageManager;
|
|
37
39
|
get resolvedUrl(): api.IResolvedUrl;
|
|
38
|
-
constructor(_resolvedUrl: api.IResolvedUrl, ordererUrl: string, deltaStorageUrl: string, deltaStreamUrl: string, storageUrl: string, logger: ITelemetryLogger, tokenProvider: ITokenProvider, tenantId: string, documentId: string, ordererRestWrapper: RouterliciousOrdererRestWrapper, documentStorageServicePolicies: api.IDocumentStorageServicePolicies, driverPolicies: IRouterliciousDriverPolicies, blobCache: ICache<ArrayBufferLike>,
|
|
40
|
+
constructor(_resolvedUrl: api.IResolvedUrl, ordererUrl: string, deltaStorageUrl: string, deltaStreamUrl: string, storageUrl: string, logger: ITelemetryLogger, tokenProvider: ITokenProvider, tenantId: string, documentId: string, ordererRestWrapper: RouterliciousOrdererRestWrapper, documentStorageServicePolicies: api.IDocumentStorageServicePolicies, driverPolicies: IRouterliciousDriverPolicies, blobCache: ICache<ArrayBufferLike>, wholeSnapshotTreeCache: ICache<INormalizedWholeSummary>, shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>, discoverFluidResolvedUrl: () => Promise<api.IFluidResolvedUrl>);
|
|
39
41
|
private documentStorageService;
|
|
40
42
|
dispose(): void;
|
|
41
43
|
/**
|