@fluidframework/routerlicious-driver 2.5.0-302463 → 2.5.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/CHANGELOG.md +4 -0
- package/dist/contracts.d.ts +6 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +7 -0
- package/dist/contracts.js.map +1 -1
- package/dist/documentDeltaConnection.d.ts +5 -1
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js +12 -2
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +6 -7
- package/dist/documentService.js.map +1 -1
- package/dist/errorUtils.d.ts +31 -4
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +78 -8
- package/dist/errorUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +15 -10
- package/dist/restWrapper.js.map +1 -1
- package/dist/socketModule.d.ts +7 -0
- package/dist/socketModule.d.ts.map +1 -0
- package/dist/socketModule.js +11 -0
- package/dist/socketModule.js.map +1 -0
- package/lib/contracts.d.ts +6 -0
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +6 -1
- package/lib/contracts.js.map +1 -1
- package/lib/documentDeltaConnection.d.ts +5 -1
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js +13 -3
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +6 -4
- package/lib/documentService.js.map +1 -1
- package/lib/errorUtils.d.ts +31 -4
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +75 -7
- package/lib/errorUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +16 -11
- package/lib/restWrapper.js.map +1 -1
- package/lib/socketModule.d.ts +7 -0
- package/lib/socketModule.d.ts.map +1 -0
- package/lib/socketModule.js +8 -0
- package/lib/socketModule.js.map +1 -0
- package/package.json +11 -11
- package/src/contracts.ts +7 -0
- package/src/documentDeltaConnection.ts +32 -3
- package/src/documentService.ts +9 -5
- package/src/errorUtils.ts +103 -6
- package/src/packageVersion.ts +1 -1
- package/src/restWrapper.ts +29 -10
- package/src/socketModule.ts +9 -0
package/dist/restWrapper.js
CHANGED
|
@@ -116,6 +116,12 @@ class RouterliciousRestWrapper extends restWrapperBase_js_1.RestWrapper {
|
|
|
116
116
|
const result = await (0, cross_fetch_1.default)(completeRequestUrl, fetchRequestConfig).catch(async (error) => {
|
|
117
117
|
// on failure, add the request entry into the retryCounter map to count the subsequent retries, if any
|
|
118
118
|
this.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);
|
|
119
|
+
const telemetryProps = {
|
|
120
|
+
driverVersion: packageVersion_js_1.pkgVersion,
|
|
121
|
+
retryCount: requestRetryCount,
|
|
122
|
+
url: (0, errorUtils_js_1.getUrlForTelemetry)(completeRequestUrl.hostname, completeRequestUrl.pathname),
|
|
123
|
+
requestMethod: fetchRequestConfig.method,
|
|
124
|
+
};
|
|
119
125
|
// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError
|
|
120
126
|
const isNetworkError = ["TypeError", "FetchError"].includes(error?.name);
|
|
121
127
|
const errorMessage = isNetworkError
|
|
@@ -127,14 +133,8 @@ class RouterliciousRestWrapper extends restWrapperBase_js_1.RestWrapper {
|
|
|
127
133
|
// If there exists a self-signed SSL certificates error, throw a NonRetryableError
|
|
128
134
|
// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections
|
|
129
135
|
const err = errorMessage.includes("failed, reason: self signed certificate")
|
|
130
|
-
? new internal_2.NonRetryableError(errorMessage, errorUtils_js_1.RouterliciousErrorTypes.sslCertError,
|
|
131
|
-
|
|
132
|
-
retryCount: requestRetryCount,
|
|
133
|
-
})
|
|
134
|
-
: new internal_2.GenericNetworkError(errorMessage, errorMessage.startsWith("NetworkError"), {
|
|
135
|
-
driverVersion: packageVersion_js_1.pkgVersion,
|
|
136
|
-
retryCount: requestRetryCount,
|
|
137
|
-
});
|
|
136
|
+
? new internal_2.NonRetryableError(errorMessage, errorUtils_js_1.RouterliciousErrorTypes.sslCertError, telemetryProps)
|
|
137
|
+
: new internal_2.GenericNetworkError(errorMessage, errorMessage.startsWith("NetworkError"), telemetryProps);
|
|
138
138
|
throw err;
|
|
139
139
|
});
|
|
140
140
|
return {
|
|
@@ -143,6 +143,7 @@ class RouterliciousRestWrapper extends restWrapperBase_js_1.RestWrapper {
|
|
|
143
143
|
};
|
|
144
144
|
});
|
|
145
145
|
const response = res.response;
|
|
146
|
+
const headers = headersToMap(response.headers);
|
|
146
147
|
let start = client_utils_1.performance.now();
|
|
147
148
|
const text = await response.text();
|
|
148
149
|
const receiveContentTime = client_utils_1.performance.now() - start;
|
|
@@ -159,7 +160,6 @@ class RouterliciousRestWrapper extends restWrapperBase_js_1.RestWrapper {
|
|
|
159
160
|
// on successful response, remove the entry from the retryCounter map
|
|
160
161
|
this.retryCounter.delete(requestKey);
|
|
161
162
|
const result = responseBody;
|
|
162
|
-
const headers = headersToMap(response.headers);
|
|
163
163
|
return {
|
|
164
164
|
content: result,
|
|
165
165
|
headers,
|
|
@@ -195,7 +195,12 @@ class RouterliciousRestWrapper extends restWrapperBase_js_1.RestWrapper {
|
|
|
195
195
|
? responseBody
|
|
196
196
|
: (0, json_stringify_safe_1.default)(responseBody)
|
|
197
197
|
: response.statusText;
|
|
198
|
-
(0, errorUtils_js_1.throwR11sNetworkError)(`R11s fetch error: ${responseSummary}`, response.status, responseBody?.retryAfter
|
|
198
|
+
(0, errorUtils_js_1.throwR11sNetworkError)(`R11s fetch error: ${responseSummary}`, response.status, responseBody?.retryAfter, {
|
|
199
|
+
...getPropsToLogFromResponse(headers),
|
|
200
|
+
driverVersion: packageVersion_js_1.pkgVersion,
|
|
201
|
+
url: (0, errorUtils_js_1.getUrlForTelemetry)(completeRequestUrl.hostname, completeRequestUrl.pathname),
|
|
202
|
+
requestMethod: fetchRequestConfig.method,
|
|
203
|
+
});
|
|
199
204
|
}
|
|
200
205
|
async generateHeaders(requestHeaders) {
|
|
201
206
|
const token = await this.getToken();
|
package/dist/restWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,+DAA6E;AAE7E,kEAA6D;AAC7D,oEAI+C;AAC/C,mFAKgD;AAChD,uEAIkD;AAClD,8DAAgC;AAChC,8EAAgD;AAGhD,mDAAiF;AACjF,2DAAkE;AAClE,+DAAqF;AACrF,6DAAmD;AAMnD,MAAM,eAAe,GAAG,CAAC,aAAiC,EAAE,EAAE,CAC7D,aAAa,CAAC,OAAO,KAAK,SAAS;IAClC,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,IAAI,EAAE,GAAG,aAAa,CAAC,GAAG,IAAI,EAAE,EAAE;IAC5D,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;AAE9B,MAAM,2BAA2B,GAAG,CAAC,aAAiC,EAAe,EAAE;IACtF,MAAM,WAAW,GAAgB;QAChC,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,oGAAoG;QACpG,qEAAqE;QACrE,OAAO,EAAE,aAAa,CAAC,OAAiC;QACxD,IAAI,EAAE,aAAa,CAAC,IAAI;KACxB,CAAC;IACF,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AASF;;;;GAIG;AACH,SAAgB,6BAA6B,CAAI,OAAU;IAC1D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,+BAA+B,CACtD,MAAM,EACN,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,WAAW,EACX,OAAO,EACP,aAAa,CACb,CAAC;QAEF,OAAO,WAAW,CAAC;IACpB,CAAC;CACD;AAjDD,0EAiDC;AAED,SAAgB,qCAAqC,CACpD,QAAgB,EAChB,UAA8B,EAC9B,aAA6B,EAC7B,MAA2B;IAE3B,MAAM,iBAAiB,GAAG,KAAK,EAAE,YAAsB,EAA2B,EAAE;QACnF,OAAO,2BAAgB,CAAC,cAAc,CACrC,MAAM,EACN;YACC,SAAS,EAAE,mBAAmB;YAC9B,KAAK,EAAE,UAAU;SACjB,EACD,KAAK,IAAI,EAAE;YACV,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,iBAAiB,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;YAEF,OAAO,YAAY,CAAC;QACrB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAzBD,sFAyBC;AAED,SAAgB,qCAAqC,CACpD,QAAgB,EAChB,UAAkB,EAClB,aAA6B,EAC7B,MAA2B;IAE3B,MAAM,iBAAiB,GAAG,KAAK,EAAE,YAAsB,EAA2B,EAAE;QACnF,OAAO,2BAAgB,CAAC,cAAc,CACrC,MAAM,EACN;YACC,SAAS,EAAE,mBAAmB;YAC9B,KAAK,EAAE,UAAU;SACjB,EACD,KAAK,IAAI,EAAE;YACV,8CAA8C;YAC9C,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,iBAAiB,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;YAEF,OAAO,YAAY,CAAC;QACrB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AA1BD,sFA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64, performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tGenericNetworkError,\n\tNonRetryableError,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tCorrelationIdHeaderName,\n\tDriverVersionHeaderName,\n\tRestLessClient,\n\tgetAuthorizationTokenFromCredentials,\n} from \"@fluidframework/server-services-client\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tnumberFromString,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport fetch from \"cross-fetch\";\nimport safeStringify from \"json-stringify-safe\";\n\nimport type { AxiosRequestConfig, RawAxiosRequestHeaders } from \"./axios.cjs\";\nimport { RouterliciousErrorTypes, throwR11sNetworkError } from \"./errorUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { addOrUpdateQueryParams, type QueryStringType } from \"./queryStringUtils.js\";\nimport { RestWrapper } from \"./restWrapperBase.js\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens.js\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\nexport type TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst buildRequestUrl = (requestConfig: AxiosRequestConfig) =>\n\trequestConfig.baseURL !== undefined\n\t\t? `${requestConfig.baseURL ?? \"\"}${requestConfig.url ?? \"\"}`\n\t\t: (requestConfig.url ?? \"\");\n\nconst axiosBuildRequestInitConfig = (requestConfig: AxiosRequestConfig): RequestInit => {\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 requestInit;\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a Routerlicious response without any additional props as we might not have them always.\n * @param content - Response which is equivalent to content.\n * @returns A Routerlicious 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\t// eslint-disable-next-line @rushstack/no-new-null\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: CorrelationIdHeaderName, logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryBaseProperties = {\n\t\tcontentsize: 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\nclass RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\tprivate token: ITokenResponse | undefined;\n\n\t/**\n\t * A locally maintained map which saves the number of retries for any REST api call made through restWrapper.\n\t * It uses the href of the request url as a key against which it saves the retry counts. Retries are only counted in case of failures.\n\t * This feature is added to enable FRS to have more telemetry insights into whether the requests are being retried from same client or multiple.\n\t */\n\tprivate readonly retryCounter = new Map<string, number>();\n\n\tconstructor(\n\t\tlogger: ITelemetryLoggerExt,\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\tprivate tokenP?: Promise<ITokenResponse>,\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\tif (requestConfig.params) {\n\t\t\t// delete the retry param, if any. We do this to ensure there is no retry added by any of callers, which would conflict with the one we maintain here in the retryCounter map.\n\t\t\tdelete requestConfig.params.retry;\n\t\t}\n\n\t\t// Build the complete request url including baseUrl, url and query params. (all except 'retry' query param)\n\t\tlet completeRequestUrl = addOrUpdateQueryParams(\n\t\t\tbuildRequestUrl(requestConfig),\n\t\t\trequestConfig.params,\n\t\t);\n\n\t\t// Check whether this request has been made before or if it is a retry.\n\t\t// requestKey is built using the HTTP method appended with the complete URL ommitting the 'retry' param\n\t\tconst requestKey = `${requestConfig.method ?? \"\"}|${completeRequestUrl.href}`;\n\t\tconst requestRetryCount = this.retryCounter.get(requestKey);\n\t\tif (requestRetryCount) {\n\t\t\tcompleteRequestUrl = addOrUpdateQueryParams(completeRequestUrl, {\n\t\t\t\tretry: requestRetryCount,\n\t\t\t});\n\t\t}\n\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 = axiosBuildRequestInitConfig(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(completeRequestUrl, fetchRequestConfig).catch(\n\t\t\t\tasync (error) => {\n\t\t\t\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries, if any\n\t\t\t\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\n\t\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\t\tconst errorMessage = isNetworkError\n\t\t\t\t\t\t? `NetworkError: ${error.message}`\n\t\t\t\t\t\t: safeStringify(error);\n\t\t\t\t\t// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw\n\t\t\t\t\t// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and\n\t\t\t\t\t// the error message will start with NetworkError as defined in restWrapper.ts\n\t\t\t\t\t// If there exists a self-signed SSL certificates error, throw a NonRetryableError\n\t\t\t\t\t// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections\n\t\t\t\t\tconst err = errorMessage.includes(\"failed, reason: self signed certificate\")\n\t\t\t\t\t\t? new NonRetryableError(errorMessage, RouterliciousErrorTypes.sslCertError, {\n\t\t\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t\t\tretryCount: requestRetryCount,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: new GenericNetworkError(errorMessage, errorMessage.startsWith(\"NetworkError\"), {\n\t\t\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t\t\tretryCount: requestRetryCount,\n\t\t\t\t\t\t\t});\n\t\t\t\t\tthrow err;\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\n\t\t\t.get(\"content-type\")\n\t\t\t?.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\t// on successful response, remove the entry from the retryCounter map\n\t\t\tthis.retryCounter.delete(requestKey);\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: completeRequestUrl.href,\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\n\t\t// Failure\n\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries\n\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\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\t// use the original request URL without the retryCount appended\n\t\t\t\t\tthis.request<T>({ ...config }, statusCode)\n\t\t\t\t\t\t.then(resolve)\n\t\t\t\t\t\t.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?: RawAxiosRequestHeaders | undefined,\n\t): Promise<RawAxiosRequestHeaders> {\n\t\tconst token = await this.getToken();\n\t\tassert(token !== undefined, 0x679 /* token should be present */);\n\t\tconst headers: RawAxiosRequestHeaders = {\n\t\t\t...requestHeaders,\n\t\t\t[DriverVersionHeaderName]: driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\tAuthorization: this.getAuthorizationHeader(token),\n\t\t};\n\t\treturn headers;\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.tokenP ?? this.fetchRefreshedToken());\n\t\tthis.setToken(token);\n\t\tthis.tokenP = undefined;\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: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\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\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttenantId: string,\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): RouterliciousStorageRestWrapper {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\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\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\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: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\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\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): 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 restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport function toInstrumentedR11sOrdererTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string | undefined,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn ordererToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchOrdererToken;\n}\n\nexport function toInstrumentedR11sStorageTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn storageToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchStorageToken;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,+DAA6E;AAE7E,kEAA6D;AAC7D,oEAI+C;AAC/C,mFAKgD;AAChD,uEAIkD;AAClD,8DAAgC;AAChC,8EAAgD;AAGhD,mDAIyB;AACzB,2DAAkE;AAClE,+DAAqF;AACrF,6DAAmD;AAMnD,MAAM,eAAe,GAAG,CAAC,aAAiC,EAAE,EAAE,CAC7D,aAAa,CAAC,OAAO,KAAK,SAAS;IAClC,CAAC,CAAC,GAAG,aAAa,CAAC,OAAO,IAAI,EAAE,GAAG,aAAa,CAAC,GAAG,IAAI,EAAE,EAAE;IAC5D,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC;AAE9B,MAAM,2BAA2B,GAAG,CAAC,aAAiC,EAAe,EAAE;IACtF,MAAM,WAAW,GAAgB;QAChC,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,oGAAoG;QACpG,qEAAqE;QACrE,OAAO,EAAE,aAAa,CAAC,OAAiC;QACxD,IAAI,EAAE,aAAa,CAAC,IAAI;KACxB,CAAC;IACF,OAAO,WAAW,CAAC;AACpB,CAAC,CAAC;AASF;;;;GAIG;AACH,SAAgB,6BAA6B,CAAI,OAAU;IAC1D,OAAO;QACN,OAAO;QACP,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,UAAU,EAAE,EAAE;QACd,UAAU,EAAE,EAAE;KACd,CAAC;AACH,CAAC;AAPD,sEAOC;AAED,SAAS,YAAY,CAAC,OAAgB;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC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reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64, performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tGenericNetworkError,\n\tNonRetryableError,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tCorrelationIdHeaderName,\n\tDriverVersionHeaderName,\n\tRestLessClient,\n\tgetAuthorizationTokenFromCredentials,\n} from \"@fluidframework/server-services-client\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tnumberFromString,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport fetch from \"cross-fetch\";\nimport safeStringify from \"json-stringify-safe\";\n\nimport type { AxiosRequestConfig, RawAxiosRequestHeaders } from \"./axios.cjs\";\nimport {\n\tgetUrlForTelemetry,\n\tRouterliciousErrorTypes,\n\tthrowR11sNetworkError,\n} from \"./errorUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { addOrUpdateQueryParams, type QueryStringType } from \"./queryStringUtils.js\";\nimport { RestWrapper } from \"./restWrapperBase.js\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens.js\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\nexport type TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst buildRequestUrl = (requestConfig: AxiosRequestConfig) =>\n\trequestConfig.baseURL !== undefined\n\t\t? `${requestConfig.baseURL ?? \"\"}${requestConfig.url ?? \"\"}`\n\t\t: (requestConfig.url ?? \"\");\n\nconst axiosBuildRequestInitConfig = (requestConfig: AxiosRequestConfig): RequestInit => {\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 requestInit;\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a Routerlicious response without any additional props as we might not have them always.\n * @param content - Response which is equivalent to content.\n * @returns A Routerlicious 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\t// eslint-disable-next-line @rushstack/no-new-null\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: CorrelationIdHeaderName, logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryBaseProperties = {\n\t\tcontentsize: 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\nclass RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\tprivate token: ITokenResponse | undefined;\n\n\t/**\n\t * A locally maintained map which saves the number of retries for any REST api call made through restWrapper.\n\t * It uses the href of the request url as a key against which it saves the retry counts. Retries are only counted in case of failures.\n\t * This feature is added to enable FRS to have more telemetry insights into whether the requests are being retried from same client or multiple.\n\t */\n\tprivate readonly retryCounter = new Map<string, number>();\n\n\tconstructor(\n\t\tlogger: ITelemetryLoggerExt,\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\tprivate tokenP?: Promise<ITokenResponse>,\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\tif (requestConfig.params) {\n\t\t\t// delete the retry param, if any. We do this to ensure there is no retry added by any of callers, which would conflict with the one we maintain here in the retryCounter map.\n\t\t\tdelete requestConfig.params.retry;\n\t\t}\n\n\t\t// Build the complete request url including baseUrl, url and query params. (all except 'retry' query param)\n\t\tlet completeRequestUrl = addOrUpdateQueryParams(\n\t\t\tbuildRequestUrl(requestConfig),\n\t\t\trequestConfig.params,\n\t\t);\n\n\t\t// Check whether this request has been made before or if it is a retry.\n\t\t// requestKey is built using the HTTP method appended with the complete URL ommitting the 'retry' param\n\t\tconst requestKey = `${requestConfig.method ?? \"\"}|${completeRequestUrl.href}`;\n\t\tconst requestRetryCount = this.retryCounter.get(requestKey);\n\t\tif (requestRetryCount) {\n\t\t\tcompleteRequestUrl = addOrUpdateQueryParams(completeRequestUrl, {\n\t\t\t\tretry: requestRetryCount,\n\t\t\t});\n\t\t}\n\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 = axiosBuildRequestInitConfig(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(completeRequestUrl, fetchRequestConfig).catch(\n\t\t\t\tasync (error) => {\n\t\t\t\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries, if any\n\t\t\t\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\n\t\t\t\t\tconst telemetryProps = {\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\tretryCount: requestRetryCount,\n\t\t\t\t\t\turl: getUrlForTelemetry(completeRequestUrl.hostname, completeRequestUrl.pathname),\n\t\t\t\t\t\trequestMethod: fetchRequestConfig.method,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\t\tconst errorMessage = isNetworkError\n\t\t\t\t\t\t? `NetworkError: ${error.message}`\n\t\t\t\t\t\t: safeStringify(error);\n\t\t\t\t\t// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw\n\t\t\t\t\t// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and\n\t\t\t\t\t// the error message will start with NetworkError as defined in restWrapper.ts\n\t\t\t\t\t// If there exists a self-signed SSL certificates error, throw a NonRetryableError\n\t\t\t\t\t// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections\n\t\t\t\t\tconst err = errorMessage.includes(\"failed, reason: self signed certificate\")\n\t\t\t\t\t\t? new NonRetryableError(\n\t\t\t\t\t\t\t\terrorMessage,\n\t\t\t\t\t\t\t\tRouterliciousErrorTypes.sslCertError,\n\t\t\t\t\t\t\t\ttelemetryProps,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: new GenericNetworkError(\n\t\t\t\t\t\t\t\terrorMessage,\n\t\t\t\t\t\t\t\terrorMessage.startsWith(\"NetworkError\"),\n\t\t\t\t\t\t\t\ttelemetryProps,\n\t\t\t\t\t\t\t);\n\t\t\t\t\tthrow err;\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\t\tconst headers = headersToMap(response.headers);\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\n\t\t\t.get(\"content-type\")\n\t\t\t?.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\t// on successful response, remove the entry from the retryCounter map\n\t\t\tthis.retryCounter.delete(requestKey);\n\t\t\tconst result = responseBody as T;\n\t\t\treturn {\n\t\t\t\tcontent: result,\n\t\t\t\theaders,\n\t\t\t\trequestUrl: completeRequestUrl.href,\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\n\t\t// Failure\n\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries\n\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\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\t// use the original request URL without the retryCount appended\n\t\t\t\t\tthis.request<T>({ ...config }, statusCode)\n\t\t\t\t\t\t.then(resolve)\n\t\t\t\t\t\t.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\t{\n\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\tdriverVersion,\n\t\t\t\turl: getUrlForTelemetry(completeRequestUrl.hostname, completeRequestUrl.pathname),\n\t\t\t\trequestMethod: fetchRequestConfig.method,\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async generateHeaders(\n\t\trequestHeaders?: RawAxiosRequestHeaders | undefined,\n\t): Promise<RawAxiosRequestHeaders> {\n\t\tconst token = await this.getToken();\n\t\tassert(token !== undefined, 0x679 /* token should be present */);\n\t\tconst headers: RawAxiosRequestHeaders = {\n\t\t\t...requestHeaders,\n\t\t\t[DriverVersionHeaderName]: driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\tAuthorization: this.getAuthorizationHeader(token),\n\t\t};\n\t\treturn headers;\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.tokenP ?? this.fetchRefreshedToken());\n\t\tthis.setToken(token);\n\t\tthis.tokenP = undefined;\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: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\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\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttenantId: string,\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): RouterliciousStorageRestWrapper {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\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\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\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: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\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\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): 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 restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport function toInstrumentedR11sOrdererTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string | undefined,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn ordererToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchOrdererToken;\n}\n\nexport function toInstrumentedR11sStorageTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn storageToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchStorageToken;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socketModule.d.ts","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAGtC,eAAO,MAAM,oBAAoB,WAAK,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.SocketIOClientStatic = void 0;
|
|
8
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
9
|
+
// Import is required for side-effects.
|
|
10
|
+
exports.SocketIOClientStatic = socket_io_client_1.io;
|
|
11
|
+
//# sourceMappingURL=socketModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socketModule.js","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAsC;AAEtC,uCAAuC;AAC1B,QAAA,oBAAoB,GAAG,qBAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { io } from \"socket.io-client\";\n\n// Import is required for side-effects.\nexport const SocketIOClientStatic = io;\n"]}
|
package/lib/contracts.d.ts
CHANGED
|
@@ -40,4 +40,10 @@ export interface INormalizedWholeSnapshot {
|
|
|
40
40
|
sequenceNumber: number | undefined;
|
|
41
41
|
id: string;
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Error code for when the service drains a cluster to which the socket connection is connected to and it disconnects
|
|
45
|
+
* all the clients in that cluster.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare const R11sServiceClusterDrainingErrorCode = "ClusterDraining";
|
|
43
49
|
//# sourceMappingURL=contracts.d.ts.map
|
package/lib/contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAQ5E,MAAM,WAAW,+BAA+B;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY,CAAC,EAAE,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,+BAA+B;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,2BAA2B,GACpC,+BAA+B,GAC/B,+BAA+B,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,2BAA2B,EAAE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sB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IAElC,EAAE,EAAE,MAAM,CAAC;IAEX,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,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;AAED;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,oBAAoB,CAAC"}
|
package/lib/contracts.js
CHANGED
|
@@ -2,5 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Error code for when the service drains a cluster to which the socket connection is connected to and it disconnects
|
|
7
|
+
* all the clients in that cluster.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const R11sServiceClusterDrainingErrorCode = "ClusterDraining";
|
|
6
11
|
//# sourceMappingURL=contracts.js.map
|
package/lib/contracts.js.map
CHANGED
|
@@ -1 +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/driver-definitions/internal\";\n\n/*\n *\n * Whole Snapshot Download Data Structures\n *\n */\n\nexport interface IWholeFlatSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IWholeFlatSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IWholeFlatSnapshotTreeEntry =\n\t| IWholeFlatSnapshotTreeEntryTree\n\t| IWholeFlatSnapshotTreeEntryBlob;\n\nexport interface IWholeFlatSnapshotTree {\n\tentries: IWholeFlatSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\nexport interface IWholeFlatSnapshotBlob {\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n\tid: string;\n\tsize: number;\n}\n\nexport interface IWholeFlatSnapshot {\n\t// The same as the id of the first snapshot tree in the trees array.\n\tid: string;\n\t// Receive an array of snapshot trees for future-proofing, however, always length 1 for now.\n\ttrees: IWholeFlatSnapshotTree[];\n\tblobs?: IWholeFlatSnapshotBlob[];\n}\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface INormalizedWholeSnapshot {\n\tblobs: Map<string, ArrayBuffer>;\n\tsnapshotTree: ISnapshotTree;\n\tsequenceNumber: number | undefined;\n\tid: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2DH;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,iBAAiB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/driver-definitions/internal\";\n\n/*\n *\n * Whole Snapshot Download Data Structures\n *\n */\n\nexport interface IWholeFlatSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IWholeFlatSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IWholeFlatSnapshotTreeEntry =\n\t| IWholeFlatSnapshotTreeEntryTree\n\t| IWholeFlatSnapshotTreeEntryBlob;\n\nexport interface IWholeFlatSnapshotTree {\n\tentries: IWholeFlatSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\nexport interface IWholeFlatSnapshotBlob {\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n\tid: string;\n\tsize: number;\n}\n\nexport interface IWholeFlatSnapshot {\n\t// The same as the id of the first snapshot tree in the trees array.\n\tid: string;\n\t// Receive an array of snapshot trees for future-proofing, however, always length 1 for now.\n\ttrees: IWholeFlatSnapshotTree[];\n\tblobs?: IWholeFlatSnapshotBlob[];\n}\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface INormalizedWholeSnapshot {\n\tblobs: Map<string, ArrayBuffer>;\n\tsnapshotTree: ISnapshotTree;\n\tsequenceNumber: number | undefined;\n\tid: string;\n}\n\n/**\n * Error code for when the service drains a cluster to which the socket connection is connected to and it disconnects\n * all the clients in that cluster.\n * @internal\n */\nexport const R11sServiceClusterDrainingErrorCode = \"ClusterDraining\";\n"]}
|
|
@@ -5,16 +5,20 @@
|
|
|
5
5
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base/internal";
|
|
6
6
|
import { IClient } from "@fluidframework/driver-definitions";
|
|
7
7
|
import { IDocumentDeltaConnection, IAnyDriverError } from "@fluidframework/driver-definitions/internal";
|
|
8
|
+
import type { DriverErrorTelemetryProps } from "@fluidframework/driver-utils/internal";
|
|
8
9
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
-
import
|
|
10
|
+
import { SocketIOClientStatic } from "./socketModule.js";
|
|
10
11
|
/**
|
|
11
12
|
* Wrapper over the shared one for driver specific translation.
|
|
12
13
|
*/
|
|
13
14
|
export declare class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
15
|
+
private readonly url;
|
|
14
16
|
static create(tenantId: string, id: string, token: string | null, io: typeof SocketIOClientStatic, client: IClient, url: string, logger: ITelemetryLoggerExt, timeoutMs?: number, enableLongPollingDowngrade?: boolean): Promise<IDocumentDeltaConnection>;
|
|
17
|
+
private constructor();
|
|
15
18
|
/**
|
|
16
19
|
* Error raising for socket.io issues
|
|
17
20
|
*/
|
|
18
21
|
protected createErrorObject(handler: string, error?: any, canRetry?: boolean): IAnyDriverError;
|
|
22
|
+
protected getAdditionalErrorProps(handler: string): DriverErrorTelemetryProps;
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=documentDeltaConnection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,eAAe,EAEf,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,eAAe,EAEf,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAU/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAIzD;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,uBAAuB;IAmDtE,OAAO,CAAC,QAAQ,CAAC,GAAG;WAlDD,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,EAAE,EAAE,OAAO,oBAAoB,EAC/B,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,mBAAmB,EAC3B,SAAS,SAAQ,EACjB,0BAA0B,UAAO,GAC/B,OAAO,CAAC,wBAAwB,CAAC;IAoCpC,OAAO;IAUP;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,QAAQ,UAAO,GAAG,eAAe;IAa3F,SAAS,CAAC,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,yBAAyB;CAM7E"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base/internal";
|
|
6
|
-
import { errorObjectFromSocketError } from "./errorUtils.js";
|
|
6
|
+
import { errorObjectFromSocketError, getUrlForTelemetry, socketIoPath, } from "./errorUtils.js";
|
|
7
7
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
8
8
|
const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
|
|
9
9
|
/**
|
|
@@ -30,10 +30,14 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
30
30
|
versions: protocolVersions,
|
|
31
31
|
relayUserAgent: [client.details.environment, ` driverVersion:${driverVersion}`].join(";"),
|
|
32
32
|
};
|
|
33
|
-
const deltaConnection = new R11sDocumentDeltaConnection(socket, id, logger, enableLongPollingDowngrade);
|
|
33
|
+
const deltaConnection = new R11sDocumentDeltaConnection(socket, id, logger, url, enableLongPollingDowngrade);
|
|
34
34
|
await deltaConnection.initialize(connectMessage, timeoutMs);
|
|
35
35
|
return deltaConnection;
|
|
36
36
|
}
|
|
37
|
+
constructor(socket, documentId, logger, url, enableLongPollingDowngrades) {
|
|
38
|
+
super(socket, documentId, logger, enableLongPollingDowngrades);
|
|
39
|
+
this.url = url;
|
|
40
|
+
}
|
|
37
41
|
/**
|
|
38
42
|
* Error raising for socket.io issues
|
|
39
43
|
*/
|
|
@@ -42,8 +46,14 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
42
46
|
// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.
|
|
43
47
|
// - anything else: let base class handle it
|
|
44
48
|
return canRetry && Number.isInteger(error?.code) && typeof error?.message === "string"
|
|
45
|
-
? errorObjectFromSocketError(error, handler)
|
|
49
|
+
? errorObjectFromSocketError(error, handler, this.getAdditionalErrorProps(handler))
|
|
46
50
|
: super.createErrorObject(handler, error, canRetry);
|
|
47
51
|
}
|
|
52
|
+
getAdditionalErrorProps(handler) {
|
|
53
|
+
return {
|
|
54
|
+
...super.getAdditionalErrorProps(handler),
|
|
55
|
+
url: getUrlForTelemetry(this.url, socketIoPath),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
48
58
|
}
|
|
49
59
|
//# sourceMappingURL=documentDeltaConnection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"documentDeltaConnection.js","sourceRoot":"","sources":["../src/documentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAW/E,OAAO,EAEN,0BAA0B,EAC1B,kBAAkB,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E,UAAU,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAAC;QAH9C,QAAG,GAAH,GAAG,CAAQ;IAI7B,CAAC;IAED;;OAEG;IACO,iBAAiB,CAAC,OAAe,EAAE,KAAW,EAAE,QAAQ,GAAG,IAAI;QACxE,wDAAwD;QACxD,wGAAwG;QACxG,4CAA4C;QAC5C,OAAO,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,OAAO,KAAK,EAAE,OAAO,KAAK,QAAQ;YACrF,CAAC,CAAC,0BAA0B,CAC1B,KAAyB,EACzB,OAAO,EACP,IAAI,CAAC,uBAAuB,CAAC,OAAO,CAAC,CACrC;YACF,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAES,uBAAuB,CAAC,OAAe;QAChD,OAAO;YACN,GAAG,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC;YACzC,GAAG,EAAE,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC;SAC/C,CAAC;IACH,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIAnyDriverError,\n\tIConnect,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { DriverErrorTelemetryProps } from \"@fluidframework/driver-utils/internal\";\nimport { ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Socket } from \"socket.io-client\";\n\nimport {\n\tIR11sSocketError,\n\terrorObjectFromSocketError,\n\tgetUrlForTelemetry,\n\tsocketIoPath,\n} from \"./errorUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { SocketIOClientStatic } from \"./socketModule.js\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Wrapper over the shared one for driver specific translation.\n */\nexport class R11sDocumentDeltaConnection extends DocumentDeltaConnection {\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string | null,\n\t\tio: typeof SocketIOClientStatic,\n\t\tclient: IClient,\n\t\turl: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\ttimeoutMs = 20000,\n\t\tenableLongPollingDowngrade = true,\n\t): Promise<IDocumentDeltaConnection> {\n\t\tconst socket = io(url, {\n\t\t\tquery: {\n\t\t\t\tdocumentId: id,\n\t\t\t\ttenantId,\n\t\t\t},\n\t\t\treconnection: false,\n\t\t\t// Default to websocket connection, with long-polling disabled\n\t\t\ttransports: [\"websocket\"],\n\t\t\ttimeout: timeoutMs,\n\t\t});\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: protocolVersions,\n\t\t\trelayUserAgent: [client.details.environment, ` driverVersion:${driverVersion}`].join(\n\t\t\t\t\";\",\n\t\t\t),\n\t\t};\n\n\t\tconst deltaConnection = new R11sDocumentDeltaConnection(\n\t\t\tsocket,\n\t\t\tid,\n\t\t\tlogger,\n\t\t\turl,\n\t\t\tenableLongPollingDowngrade,\n\t\t);\n\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tprivate constructor(\n\t\tsocket: Socket,\n\t\tdocumentId: string,\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly url: string,\n\t\tenableLongPollingDowngrades?: boolean,\n\t) {\n\t\tsuper(socket, documentId, logger, enableLongPollingDowngrades);\n\t}\n\n\t/**\n\t * Error raising for socket.io issues\n\t */\n\tprotected createErrorObject(handler: string, error?: any, canRetry = true): IAnyDriverError {\n\t\t// Note: we suspect the incoming error object is either:\n\t\t// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.\n\t\t// - anything else: let base class handle it\n\t\treturn canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\"\n\t\t\t? errorObjectFromSocketError(\n\t\t\t\t\terror as IR11sSocketError,\n\t\t\t\t\thandler,\n\t\t\t\t\tthis.getAdditionalErrorProps(handler),\n\t\t\t\t)\n\t\t\t: super.createErrorObject(handler, error, canRetry);\n\t}\n\n\tprotected getAdditionalErrorProps(handler: string): DriverErrorTelemetryProps {\n\t\treturn {\n\t\t\t...super.getAdditionalErrorProps(handler),\n\t\t\turl: getUrlForTelemetry(this.url, socketIoPath),\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentService.d.ts","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,+BAA+B,EAC/B,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAMrD,OAAO,EACN,mBAAmB,EAGnB,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"documentService.d.ts","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,sBAAsB,EACtB,wBAAwB,EACxB,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,uBAAuB,EACvB,+BAA+B,EAC/B,YAAY,EACZ,MAAM,6CAA6C,CAA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c,CAAyB;IAC/C,OAAO,CAAC,qBAAqB,CAAyB;IAEtD,OAAO,CAAC,SAAS,CAAuC;IAExD,IAAW,WAAW,iBAErB;gBAGQ,YAAY,EAAE,YAAY,EACxB,UAAU,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EACT,MAAM,EAAE,mBAAmB,EAClC,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,kBAAkB,EAAE,+BAA+B,EAC5C,8BAA8B,EAAE,+BAA+B,EAC/D,cAAc,EAAE,4BAA4B,EAC5C,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,EAClC,sBAAsB,EAAE,MAAM,CAAC,wBAAwB,CAAC,EACxD,wBAAwB,EAAE,MAAM,CAAC,oBAAoB,CAAC,EACtD,cAAc,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,EAC/D,kBAAkB,EAAE,+BAA+B,EAC1C,mBAAmB,EAAE,YAAY,EACjC,mBAAmB,EAAE,YAAY;IAKnD,OAAO,CAAC,sBAAsB,CAAqC;IAEnE,IAAW,QAAQ,IAAI,wBAAwB,GAAG,SAAS,CAE1D;IAEM,OAAO;IAEd;;;;OAIG;IACU,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAmDjE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAmC3E;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA4FrF;;;OAGG;YACW,0BAA0B;CAaxC"}
|
package/lib/documentService.js
CHANGED
|
@@ -6,7 +6,6 @@ import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { NetworkErrorBasic, RateLimiter, canRetryOnError, } from "@fluidframework/driver-utils/internal";
|
|
8
8
|
import { PerformanceEvent, wrapError, } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
-
import io from "socket.io-client";
|
|
10
9
|
import { DeltaStorageService, DocumentDeltaStorageService } from "./deltaStorageService.js";
|
|
11
10
|
import { R11sDocumentDeltaConnection } from "./documentDeltaConnection.js";
|
|
12
11
|
import { DocumentStorageService } from "./documentStorageService.js";
|
|
@@ -16,6 +15,7 @@ import { Historian } from "./historian.js";
|
|
|
16
15
|
import { NullBlobStorageService } from "./nullBlobStorageService.js";
|
|
17
16
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
18
17
|
import { RouterliciousOrdererRestWrapper, RouterliciousStorageRestWrapper, } from "./restWrapper.js";
|
|
18
|
+
import { SocketIOClientStatic } from "./socketModule.js";
|
|
19
19
|
/**
|
|
20
20
|
* The DocumentService manages the Socket.IO connection and manages routing requests to connected
|
|
21
21
|
* clients.
|
|
@@ -132,7 +132,7 @@ export class DocumentService extends TypedEventEmitter {
|
|
|
132
132
|
eventName: "ConnectToDeltaStream",
|
|
133
133
|
docId: this.documentId,
|
|
134
134
|
}, async () => {
|
|
135
|
-
return R11sDocumentDeltaConnection.create(this.tenantId, this.documentId, ordererToken.jwt,
|
|
135
|
+
return R11sDocumentDeltaConnection.create(this.tenantId, this.documentId, ordererToken.jwt, SocketIOClientStatic, client, this.deltaStreamUrl, this.logger, undefined /* timeoutMs */, this.driverPolicies.enableLongPollingDowngrade);
|
|
136
136
|
});
|
|
137
137
|
};
|
|
138
138
|
// Attempt to establish connection.
|
|
@@ -152,9 +152,11 @@ export class DocumentService extends TypedEventEmitter {
|
|
|
152
152
|
return connection;
|
|
153
153
|
}
|
|
154
154
|
catch (error) {
|
|
155
|
-
if (error
|
|
155
|
+
if (typeof error === "object" &&
|
|
156
|
+
error !== null &&
|
|
157
|
+
error.errorType === RouterliciousErrorTypes.authorizationError) {
|
|
156
158
|
// Fetch new token and retry once,
|
|
157
|
-
// otherwise 401 will be bubbled up as non-retriable AuthorizationError.
|
|
159
|
+
// otherwise 401/403 will be bubbled up as non-retriable AuthorizationError.
|
|
158
160
|
return connect(true /* refreshToken */);
|
|
159
161
|
}
|
|
160
162
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentService.js","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAY7D,OAAO,EACN,iBAAiB,EACjB,WAAW,EACX,eAAe,GACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,gBAAgB,EAChB,SAAS,GACT,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKlC,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EACN,+BAA+B,EAC/B,+BAA+B,GAE/B,MAAM,kBAAkB,CAAC;AAK1B;;;GAGG;AACH,MAAM,OAAO,eACZ,SAAQ,iBAAyC;IASjD,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED,YACS,YAA0B,EACxB,UAAkB,EACpB,eAAuB,EACvB,cAAsB,EACtB,UAAkB,EACT,MAA2B,EAClC,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B,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,SAAS,CAAC,eAAe,CAAC;QAClE,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;QACnF,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tNetworkErrorBasic,\n\tRateLimiter,\n\tcanRetryOnError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport io from \"socket.io-client\";\n\nimport { ICache } from \"./cache.js\";\nimport { INormalizedWholeSnapshot } from \"./contracts.js\";\nimport { ISnapshotTreeVersion } from \"./definitions.js\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService.js\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection.js\";\nimport { DocumentStorageService } from \"./documentStorageService.js\";\nimport { RouterliciousErrorTypes } from \"./errorUtils.js\";\nimport { GitManager } from \"./gitManager.js\";\nimport { Historian } from \"./historian.js\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { IRouterliciousDriverPolicies } from \"./policies.js\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\tTokenFetcher,\n} from \"./restWrapper.js\";\nimport { RestWrapper } from \"./restWrapperBase.js\";\nimport type { IGetSessionInfoResponse } from \"./sessionInfoManager.js\";\nimport { ITokenProvider } from \"./tokens.js\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\nexport class DocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\t// eslint-disable-next-line import/namespace\n\timplements IDocumentService\n{\n\tprivate storageManager: GitManager | undefined;\n\tprivate noCacheStorageManager: GitManager | undefined;\n\n\tprivate _policies: IDocumentServicePolicies | undefined;\n\n\tpublic get resolvedUrl() {\n\t\treturn this._resolvedUrl;\n\t}\n\n\tconstructor(\n\t\tprivate _resolvedUrl: IResolvedUrl,\n\t\tprotected ordererUrl: string,\n\t\tprivate deltaStorageUrl: string,\n\t\tprivate deltaStreamUrl: string,\n\t\tprivate storageUrl: string,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprotected tokenProvider: ITokenProvider,\n\t\tprotected tenantId: string,\n\t\tprotected documentId: string,\n\t\tprotected ordererRestWrapper: RouterliciousOrdererRestWrapper,\n\t\tprivate readonly documentStorageServicePolicies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike>,\n\t\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,\n\t\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly getSessionInfo: () => Promise<IGetSessionInfoResponse>,\n\t\tprivate storageRestWrapper: RouterliciousStorageRestWrapper,\n\t\tprivate readonly storageTokenFetcher: TokenFetcher,\n\t\tprivate readonly ordererTokenFetcher: TokenFetcher,\n\t) {\n\t\tsuper();\n\t}\n\n\tprivate documentStorageService: DocumentStorageService | undefined;\n\n\tpublic get policies(): IDocumentServicePolicies | undefined {\n\t\treturn this._policies;\n\t}\n\n\tpublic dispose() {}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for routerlicious driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (this.documentStorageService !== undefined) {\n\t\t\treturn this.documentStorageService;\n\t\t}\n\n\t\tif (this.storageUrl === undefined) {\n\t\t\treturn new NullBlobStorageService();\n\t\t}\n\n\t\tconst getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n\t\t\tconst refreshed = await this.refreshSessionInfoIfNeeded();\n\t\t\tif (!this.storageManager || !this.noCacheStorageManager || refreshed) {\n\t\t\t\tif (refreshed) {\n\t\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\t\tthis.driverPolicies.maxConcurrentStorageRequests,\n\t\t\t\t\t);\n\t\t\t\t\tthis.storageRestWrapper = RouterliciousStorageRestWrapper.load(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.storageTokenFetcher,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\trateLimiter,\n\t\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t\t\tthis.storageUrl /* baseUrl */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst historian = new Historian(true, false, this.storageRestWrapper);\n\t\t\t\tthis.storageManager = new GitManager(historian);\n\t\t\t\tconst noCacheHistorian = new Historian(true, true, this.storageRestWrapper);\n\t\t\t\tthis.noCacheStorageManager = new GitManager(noCacheHistorian);\n\t\t\t}\n\n\t\t\treturn disableCache ? this.noCacheStorageManager : this.storageManager;\n\t\t};\n\t\t// Initialize storageManager and noCacheStorageManager\n\t\tconst storageManager = await getStorageManager();\n\t\tconst noCacheStorageManager = await getStorageManager(true);\n\t\tthis.documentStorageService = new DocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tstorageManager,\n\t\t\tthis.logger,\n\t\t\tthis.documentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tnoCacheStorageManager,\n\t\t\tgetStorageManager,\n\t\t);\n\t\treturn this.documentStorageService;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tawait this.connectToStorage();\n\t\tassert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n\t\tconst getRestWrapper = async (): Promise<RestWrapper> => {\n\t\t\tconst refreshed = await this.refreshSessionInfoIfNeeded();\n\n\t\t\tif (refreshed) {\n\t\t\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\t\t\tthis.ordererRestWrapper = RouterliciousOrdererRestWrapper.load(\n\t\t\t\t\tthis.ordererTokenFetcher,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.ordererRestWrapper;\n\t\t};\n\t\tconst restWrapper = await getRestWrapper();\n\t\tconst deltaStorageService = new DeltaStorageService(\n\t\t\tthis.deltaStorageUrl,\n\t\t\trestWrapper,\n\t\t\tthis.logger,\n\t\t\tgetRestWrapper,\n\t\t\t() => this.deltaStorageUrl,\n\t\t);\n\t\treturn new DocumentDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tdeltaStorageService,\n\t\t\tthis.documentStorageService,\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tconst connect = async (refreshToken?: boolean) => {\n\t\t\tlet ordererToken = await this.ordererRestWrapper.getToken();\n\t\t\tawait this.refreshSessionInfoIfNeeded();\n\n\t\t\tif (refreshToken) {\n\t\t\t\tordererToken = await PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"GetDeltaStreamToken\",\n\t\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tthis.tokenProvider\n\t\t\t\t\t\t\t.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)\n\t\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t\t(newOrdererToken) => {\n\t\t\t\t\t\t\t\t\tthis.ordererRestWrapper.setToken(newOrdererToken);\n\t\t\t\t\t\t\t\t\treturn newOrdererToken;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\t\t\t\tRouterliciousErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\t\t\t\tcanRetryOnError(error),\n\t\t\t\t\t\t\t\t\t\t\t\t{ errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ConnectToDeltaStream\",\n\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\treturn R11sDocumentDeltaConnection.create(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.documentId,\n\t\t\t\t\t\tordererToken.jwt,\n\t\t\t\t\t\tio,\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tthis.deltaStreamUrl,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\tundefined /* timeoutMs */,\n\t\t\t\t\t\tthis.driverPolicies.enableLongPollingDowngrade,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\t// Attempt to establish connection.\n\t\t// Retry with new token on authorization error; otherwise, allow container layer to handle.\n\t\ttry {\n\t\t\tconst connection = await connect();\n\t\t\t// Enable single-commit summaries via driver policy based on the enable_single_commit_summary flag which maybe provided by the service during connection.\n\t\t\t// summarizeProtocolTree flag is used by the loader layer to attach protocol tree along with the summary required in the single-commit summaries.\n\t\t\tconst shouldSummarizeProtocolTree = (connection as R11sDocumentDeltaConnection).details\n\t\t\t\t?.supportedFeatures?.enable_single_commit_summary\n\t\t\t\t? true\n\t\t\t\t: false;\n\t\t\tthis._policies = {\n\t\t\t\t...this._policies,\n\t\t\t\tsummarizeProtocolTree: shouldSummarizeProtocolTree,\n\t\t\t};\n\n\t\t\treturn connection;\n\t\t} catch (error: any) {\n\t\t\tif (error?.statusCode === 401) {\n\t\t\t\t// Fetch new token and retry once,\n\t\t\t\t// otherwise 401 will be bubbled up as non-retriable AuthorizationError.\n\t\t\t\treturn connect(true /* refreshToken */);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Refresh session info URLs if necessary.\n\t * @returns boolean - true if session info was refreshed\n\t */\n\tprivate async refreshSessionInfoIfNeeded(): Promise<boolean> {\n\t\tconst response = await this.getSessionInfo();\n\t\tif (!response.refreshed) {\n\t\t\treturn false;\n\t\t}\n\t\tconst fluidResolvedUrl = response.resolvedUrl;\n\t\tthis._resolvedUrl = fluidResolvedUrl;\n\t\tthis.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tthis.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tthis.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tthis.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? this.ordererUrl;\n\t\treturn true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"documentService.js","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAY7D,OAAO,EACN,iBAAiB,EACjB,WAAW,EACX,eAAe,GACf,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,gBAAgB,EAChB,SAAS,GACT,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,EACN,+BAA+B,EAC/B,+BAA+B,GAE/B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,oBAAoB,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;OAGG;IACK,KAAK,CAAC,0BAA0B;QACvC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAC7C,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC;QACd,CAAC;QACD,MAAM,gBAAgB,GAAG,QAAQ,CAAC,WAAW,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,SAAS,CAAC,eAAe,CAAC;QAClE,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;QACnF,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tNetworkErrorBasic,\n\tRateLimiter,\n\tcanRetryOnError,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { ICache } from \"./cache.js\";\nimport { INormalizedWholeSnapshot } from \"./contracts.js\";\nimport { ISnapshotTreeVersion } from \"./definitions.js\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService.js\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection.js\";\nimport { DocumentStorageService } from \"./documentStorageService.js\";\nimport { RouterliciousErrorTypes, type IR11sError } from \"./errorUtils.js\";\nimport { GitManager } from \"./gitManager.js\";\nimport { Historian } from \"./historian.js\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { IRouterliciousDriverPolicies } from \"./policies.js\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\tTokenFetcher,\n} from \"./restWrapper.js\";\nimport { RestWrapper } from \"./restWrapperBase.js\";\nimport type { IGetSessionInfoResponse } from \"./sessionInfoManager.js\";\nimport { SocketIOClientStatic } from \"./socketModule.js\";\nimport { ITokenProvider } from \"./tokens.js\";\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\nexport class DocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\t// eslint-disable-next-line import/namespace\n\timplements IDocumentService\n{\n\tprivate storageManager: GitManager | undefined;\n\tprivate noCacheStorageManager: GitManager | undefined;\n\n\tprivate _policies: IDocumentServicePolicies | undefined;\n\n\tpublic get resolvedUrl() {\n\t\treturn this._resolvedUrl;\n\t}\n\n\tconstructor(\n\t\tprivate _resolvedUrl: IResolvedUrl,\n\t\tprotected ordererUrl: string,\n\t\tprivate deltaStorageUrl: string,\n\t\tprivate deltaStreamUrl: string,\n\t\tprivate storageUrl: string,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprotected tokenProvider: ITokenProvider,\n\t\tprotected tenantId: string,\n\t\tprotected documentId: string,\n\t\tprotected ordererRestWrapper: RouterliciousOrdererRestWrapper,\n\t\tprivate readonly documentStorageServicePolicies: IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike>,\n\t\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,\n\t\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly getSessionInfo: () => Promise<IGetSessionInfoResponse>,\n\t\tprivate storageRestWrapper: RouterliciousStorageRestWrapper,\n\t\tprivate readonly storageTokenFetcher: TokenFetcher,\n\t\tprivate readonly ordererTokenFetcher: TokenFetcher,\n\t) {\n\t\tsuper();\n\t}\n\n\tprivate documentStorageService: DocumentStorageService | undefined;\n\n\tpublic get policies(): IDocumentServicePolicies | undefined {\n\t\treturn this._policies;\n\t}\n\n\tpublic dispose() {}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for routerlicious driver.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\tif (this.documentStorageService !== undefined) {\n\t\t\treturn this.documentStorageService;\n\t\t}\n\n\t\tif (this.storageUrl === undefined) {\n\t\t\treturn new NullBlobStorageService();\n\t\t}\n\n\t\tconst getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n\t\t\tconst refreshed = await this.refreshSessionInfoIfNeeded();\n\t\t\tif (!this.storageManager || !this.noCacheStorageManager || refreshed) {\n\t\t\t\tif (refreshed) {\n\t\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\t\tthis.driverPolicies.maxConcurrentStorageRequests,\n\t\t\t\t\t);\n\t\t\t\t\tthis.storageRestWrapper = RouterliciousStorageRestWrapper.load(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.storageTokenFetcher,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\trateLimiter,\n\t\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t\t\tthis.storageUrl /* baseUrl */,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst historian = new Historian(true, false, this.storageRestWrapper);\n\t\t\t\tthis.storageManager = new GitManager(historian);\n\t\t\t\tconst noCacheHistorian = new Historian(true, true, this.storageRestWrapper);\n\t\t\t\tthis.noCacheStorageManager = new GitManager(noCacheHistorian);\n\t\t\t}\n\n\t\t\treturn disableCache ? this.noCacheStorageManager : this.storageManager;\n\t\t};\n\t\t// Initialize storageManager and noCacheStorageManager\n\t\tconst storageManager = await getStorageManager();\n\t\tconst noCacheStorageManager = await getStorageManager(true);\n\t\tthis.documentStorageService = new DocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tstorageManager,\n\t\t\tthis.logger,\n\t\t\tthis.documentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tnoCacheStorageManager,\n\t\t\tgetStorageManager,\n\t\t);\n\t\treturn this.documentStorageService;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tawait this.connectToStorage();\n\t\tassert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n\t\tconst getRestWrapper = async (): Promise<RestWrapper> => {\n\t\t\tconst refreshed = await this.refreshSessionInfoIfNeeded();\n\n\t\t\tif (refreshed) {\n\t\t\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\t\t\tthis.ordererRestWrapper = RouterliciousOrdererRestWrapper.load(\n\t\t\t\t\tthis.ordererTokenFetcher,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.ordererRestWrapper;\n\t\t};\n\t\tconst restWrapper = await getRestWrapper();\n\t\tconst deltaStorageService = new DeltaStorageService(\n\t\t\tthis.deltaStorageUrl,\n\t\t\trestWrapper,\n\t\t\tthis.logger,\n\t\t\tgetRestWrapper,\n\t\t\t() => this.deltaStorageUrl,\n\t\t);\n\t\treturn new DocumentDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tdeltaStorageService,\n\t\t\tthis.documentStorageService,\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tconst connect = async (refreshToken?: boolean) => {\n\t\t\tlet ordererToken = await this.ordererRestWrapper.getToken();\n\t\t\tawait this.refreshSessionInfoIfNeeded();\n\n\t\t\tif (refreshToken) {\n\t\t\t\tordererToken = await PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"GetDeltaStreamToken\",\n\t\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tthis.tokenProvider\n\t\t\t\t\t\t\t.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)\n\t\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t\t(newOrdererToken) => {\n\t\t\t\t\t\t\t\t\tthis.ordererRestWrapper.setToken(newOrdererToken);\n\t\t\t\t\t\t\t\t\treturn newOrdererToken;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\t\t\t\tRouterliciousErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\t\t\t\tcanRetryOnError(error),\n\t\t\t\t\t\t\t\t\t\t\t\t{ errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ConnectToDeltaStream\",\n\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\treturn R11sDocumentDeltaConnection.create(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.documentId,\n\t\t\t\t\t\tordererToken.jwt,\n\t\t\t\t\t\tSocketIOClientStatic,\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tthis.deltaStreamUrl,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\tundefined /* timeoutMs */,\n\t\t\t\t\t\tthis.driverPolicies.enableLongPollingDowngrade,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\t// Attempt to establish connection.\n\t\t// Retry with new token on authorization error; otherwise, allow container layer to handle.\n\t\ttry {\n\t\t\tconst connection = await connect();\n\t\t\t// Enable single-commit summaries via driver policy based on the enable_single_commit_summary flag which maybe provided by the service during connection.\n\t\t\t// summarizeProtocolTree flag is used by the loader layer to attach protocol tree along with the summary required in the single-commit summaries.\n\t\t\tconst shouldSummarizeProtocolTree = (connection as R11sDocumentDeltaConnection).details\n\t\t\t\t?.supportedFeatures?.enable_single_commit_summary\n\t\t\t\t? true\n\t\t\t\t: false;\n\t\t\tthis._policies = {\n\t\t\t\t...this._policies,\n\t\t\t\tsummarizeProtocolTree: shouldSummarizeProtocolTree,\n\t\t\t};\n\n\t\t\treturn connection;\n\t\t} catch (error: any) {\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t(error as Partial<IR11sError>).errorType === RouterliciousErrorTypes.authorizationError\n\t\t\t) {\n\t\t\t\t// Fetch new token and retry once,\n\t\t\t\t// otherwise 401/403 will be bubbled up as non-retriable AuthorizationError.\n\t\t\t\treturn connect(true /* refreshToken */);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Refresh session info URLs if necessary.\n\t * @returns boolean - true if session info was refreshed\n\t */\n\tprivate async refreshSessionInfoIfNeeded(): Promise<boolean> {\n\t\tconst response = await this.getSessionInfo();\n\t\tif (!response.refreshed) {\n\t\t\treturn false;\n\t\t}\n\t\tconst fluidResolvedUrl = response.resolvedUrl;\n\t\tthis._resolvedUrl = fluidResolvedUrl;\n\t\tthis.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tthis.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tthis.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tthis.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl ?? this.ordererUrl;\n\t\treturn true;\n\t}\n}\n"]}
|
package/lib/errorUtils.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { DriverError, IDriverErrorBase } from "@fluidframework/driver-definitions/internal";
|
|
6
|
-
import {
|
|
6
|
+
import { type DriverErrorTelemetryProps } from "@fluidframework/driver-utils/internal";
|
|
7
|
+
import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils/internal";
|
|
7
8
|
/**
|
|
8
9
|
* Routerlicious Error types
|
|
9
10
|
* Different error types that may be thrown by the routerlicious driver
|
|
@@ -14,12 +15,21 @@ export declare const RouterliciousErrorTypes: {
|
|
|
14
15
|
* SSL Certificate Error.
|
|
15
16
|
*/
|
|
16
17
|
readonly sslCertError: "sslCertError";
|
|
18
|
+
/**
|
|
19
|
+
* Error for when the service drains a cluster to which the socket connection is connected to and it disconnects
|
|
20
|
+
* all the clients in that cluster.
|
|
21
|
+
*/
|
|
22
|
+
readonly clusterDrainingError: "clusterDrainingError";
|
|
17
23
|
readonly genericNetworkError: "genericNetworkError";
|
|
18
24
|
readonly authorizationError: "authorizationError";
|
|
19
25
|
readonly fileNotFoundOrAccessDeniedError: "fileNotFoundOrAccessDeniedError";
|
|
20
26
|
readonly offlineError: "offlineError";
|
|
21
27
|
readonly unsupportedClientProtocolVersion: "unsupportedClientProtocolVersion";
|
|
22
28
|
readonly writeError: "writeError";
|
|
29
|
+
/**
|
|
30
|
+
* Interface for error responses for the WebSocket connection
|
|
31
|
+
* Intended to be compatible with output from `NetworkError.toJSON`.
|
|
32
|
+
*/
|
|
23
33
|
readonly fetchFailure: "fetchFailure";
|
|
24
34
|
readonly fetchTokenError: "fetchTokenError";
|
|
25
35
|
readonly incorrectServerResponse: "incorrectServerResponse";
|
|
@@ -62,15 +72,32 @@ export interface IR11sSocketError {
|
|
|
62
72
|
* The client should wait this many milliseconds before retrying its request.
|
|
63
73
|
*/
|
|
64
74
|
retryAfterMs?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Optional internalErrorCode to specify the specific error code for the error within the main code above.
|
|
77
|
+
*/
|
|
78
|
+
internalErrorCode?: string | number;
|
|
79
|
+
}
|
|
80
|
+
export declare class ClusterDrainingError extends LoggingError implements IFluidErrorBase {
|
|
81
|
+
readonly retryAfterSeconds: number;
|
|
82
|
+
readonly errorType: "clusterDrainingError";
|
|
83
|
+
readonly canRetry = true;
|
|
84
|
+
constructor(message: string, retryAfterSeconds: number, props: DriverErrorTelemetryProps);
|
|
65
85
|
}
|
|
66
86
|
export interface IR11sError extends Omit<IDriverErrorBase, "errorType"> {
|
|
67
87
|
readonly errorType: RouterliciousErrorTypes;
|
|
68
88
|
}
|
|
69
89
|
export type R11sError = DriverError | IR11sError;
|
|
70
|
-
export declare function createR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number): IFluidErrorBase & R11sError;
|
|
71
|
-
export declare function throwR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number): never;
|
|
90
|
+
export declare function createR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number, additionalProps?: DriverErrorTelemetryProps, internalErrorCode?: string | number): IFluidErrorBase & R11sError;
|
|
91
|
+
export declare function throwR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number, additionalProps?: DriverErrorTelemetryProps): never;
|
|
72
92
|
/**
|
|
73
93
|
* Returns network error based on error object from R11s socket (IR11sSocketError)
|
|
74
94
|
*/
|
|
75
|
-
export declare function errorObjectFromSocketError(socketError: IR11sSocketError, handler: string): R11sError;
|
|
95
|
+
export declare function errorObjectFromSocketError(socketError: IR11sSocketError, handler: string, additionalProps?: DriverErrorTelemetryProps): R11sError;
|
|
96
|
+
/** Simulate the pathname for socket connection */
|
|
97
|
+
export declare const socketIoPath = "socket.io";
|
|
98
|
+
/**
|
|
99
|
+
* Get a stripped version of a URL safe for r11s telemetry
|
|
100
|
+
* @returns undefined if no appropriate hostName is provided
|
|
101
|
+
*/
|
|
102
|
+
export declare function getUrlForTelemetry(hostName: string, path?: string): string | undefined;
|
|
76
103
|
//# sourceMappingURL=errorUtils.d.ts.map
|
package/lib/errorUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EAEX,gBAAgB,EAChB,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EAEX,gBAAgB,EAChB,MAAM,6CAA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