@fluidframework/odsp-driver 1.2.6 → 1.3.0-100520
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +1 -4
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/compactSnapshotWriter.d.ts.map +1 -1
- package/dist/compactSnapshotWriter.js +3 -6
- package/dist/compactSnapshotWriter.js.map +1 -1
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +24 -22
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/getFileLink.d.ts.map +1 -1
- package/dist/getFileLink.js +23 -31
- package/dist/getFileLink.js.map +1 -1
- package/dist/odspDeltaStorageService.d.ts +2 -1
- package/dist/odspDeltaStorageService.d.ts.map +1 -1
- package/dist/odspDeltaStorageService.js +5 -4
- package/dist/odspDeltaStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +1 -4
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/compactSnapshotWriter.d.ts.map +1 -1
- package/lib/compactSnapshotWriter.js +3 -6
- package/lib/compactSnapshotWriter.js.map +1 -1
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +24 -22
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/getFileLink.d.ts.map +1 -1
- package/lib/getFileLink.js +25 -33
- package/lib/getFileLink.js.map +1 -1
- package/lib/odspDeltaStorageService.d.ts +2 -1
- package/lib/odspDeltaStorageService.d.ts.map +1 -1
- package/lib/odspDeltaStorageService.js +5 -4
- package/lib/odspDeltaStorageService.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +11 -11
- package/src/compactSnapshotParser.ts +1 -3
- package/src/compactSnapshotWriter.ts +3 -6
- package/src/fetchSnapshot.ts +33 -24
- package/src/getFileLink.ts +29 -32
- package/src/odspDeltaStorageService.ts +4 -2
- package/src/packageVersion.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAItD,OAAO,EACH,UAAU,EACV,cAAc,GACjB,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAChC,YACqB,YAAoB,EACpB,eAAgD,EAChD,YAA0B,EAC1B,MAAwB;QAHxB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,oBAAe,GAAf,eAAe,CAAiC;QAChD,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAkB;IAE7C,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,GAAG,CACb,IAAY,EACZ,EAAU,EACV,cAAoC,EACpC,WAAoB;QAEpB,OAAO,2BAA2B,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACjD,gFAAgF;YAChF,kFAAkF;YAClF,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAEzE,MAAM,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AAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n fetchReason,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n let messages: ISequencedDocumentMessage[];\n if (deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]) {\n messages = (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op);\n } else {\n messages = deltaStorageResponse.value as ISequencedDocumentMessage[];\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDeltaStorageService.js","sourceRoot":"","sources":["../src/odspDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAA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CAAC,CAAC;YAC7E,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACrD,cAAc,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YACtC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO,GAAG,CAAC;QACf,CAAC,CAAC;QAEF,MAAM,MAAM,GAAG,UAAU,CACrB,KAAK,EAAE,IAAY,EAAE,EAAU,EAAE,cAAoC,EAAE,EAAE;YACrE,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAC/D,+BAA+B;YAC/B,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC1D,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,CAAC,WAAW,EAChB,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,YAAY;QACrB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,MAAM,EACX,WAAW,EACX,WAAW,CACd,CAAC;QAEF,OAAO,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE;YACrC,IAAI,MAAM,CAAC,IAAI,IAAI,eAAe,GAAG,YAAY,GAAG,cAAc,KAAK,CAAC,EAAE;gBACtE,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe;oBACf,YAAY;oBACZ,cAAc;iBACjB,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { default as AbortController } from \"abort-controller\";\nimport { v4 as uuid } from \"uuid\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { IDeltasFetchResult, IDocumentDeltaStorageService } from \"@fluidframework/driver-definitions\";\nimport {\n requestOps,\n streamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { IDeltaStorageGetResponse, ISequencedDeltaOpMessage } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/**\n * Provides access to the underlying delta storage on the server for sharepoint driver.\n */\nexport class OdspDeltaStorageService {\n constructor(\n private readonly deltaFeedUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly epochTracker: EpochTracker,\n private readonly logger: ITelemetryLogger,\n ) {\n }\n\n /**\n * Retrieves ops from cache\n * @param from - inclusive\n * @param to - exclusive\n * @param telemetryProps - properties to add when issuing telemetry events\n * @param scenarioName - reason for fetching ops\n * @returns ops retrieved & info if result was partial (i.e. more is available)\n */\n public async get(\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n scenarioName?: string,\n ): Promise<IDeltasFetchResult> {\n return getWithRetryForTokenRefresh(async (options) => {\n // Note - this call ends up in getSocketStorageDiscovery() and can refresh token\n // Thus it needs to be done before we call getStorageToken() to reduce extra calls\n const baseUrl = this.buildUrl(from, to);\n const storageToken = await this.getStorageToken(options, \"DeltaStorage\");\n\n const formBoundary = uuid();\n let postBody = `--${formBoundary}\\r\\n`;\n postBody += `Authorization: Bearer ${storageToken}\\r\\n`;\n postBody += `X-HTTP-Method-Override: GET\\r\\n`;\n\n postBody += `_post: 1\\r\\n`;\n postBody += `\\r\\n--${formBoundary}--`;\n const headers: { [index: string]: any; } = {\n \"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n };\n\n // Some request take a long time (1-2 minutes) to complete, where telemetry shows very small amount\n // of time spent on server, and usually small payload sizes. I.e. all the time is spent somewhere in\n // networking. Even bigger problem - a lot of requests timeout (based on cursory look - after 1-2 minutes)\n // So adding some timeout to ensure we retry again in hope of faster success.\n // Please see https://github.com/microsoft/FluidFramework/issues/6997 for details.\n const abort = new AbortController();\n const timer = setTimeout(() => abort.abort(), 30000);\n\n const response = await this.epochTracker.fetchAndParseAsJSON<IDeltaStorageGetResponse>(\n baseUrl,\n {\n headers,\n body: postBody,\n method: \"POST\",\n signal: abort.signal,\n },\n \"ops\",\n true,\n scenarioName,\n );\n clearTimeout(timer);\n const deltaStorageResponse = response.content;\n let messages: ISequencedDocumentMessage[];\n if (deltaStorageResponse.value.length > 0 && \"op\" in deltaStorageResponse.value[0]) {\n messages = (deltaStorageResponse.value as ISequencedDeltaOpMessage[]).map((operation) => operation.op);\n } else {\n messages = deltaStorageResponse.value as ISequencedDocumentMessage[];\n }\n\n this.logger.sendPerformanceEvent({\n eventName: \"OpsFetch\",\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n length: messages.length,\n duration: response.duration, // this duration for single attempt!\n ...response.propsToLog,\n attempts: options.refresh ? 2 : 1,\n from,\n to,\n ...telemetryProps,\n reason: scenarioName,\n });\n\n // It is assumed that server always returns all the ops that it has in the range that was requested.\n // This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n return { messages, partialResult: false };\n });\n }\n\n public buildUrl(from: number, to: number) {\n const filter = encodeURIComponent(`sequenceNumber ge ${from} and sequenceNumber le ${to - 1}`);\n const queryString = `?ump=1&filter=${filter}`;\n return `${this.deltaFeedUrl}${queryString}`;\n }\n}\n\nexport class OdspDeltaStorageWithCache implements IDocumentDeltaStorageService {\n private firstCacheMiss = Number.MAX_SAFE_INTEGER;\n\n public constructor(\n private snapshotOps: ISequencedDocumentMessage[] | undefined,\n private readonly logger: ITelemetryLogger,\n private readonly batchSize: number,\n private readonly concurrency: number,\n private readonly getFromStorage: (\n from: number,\n to: number,\n telemetryProps: ITelemetryProperties,\n fetchReason?: string) => Promise<IDeltasFetchResult>,\n private readonly getCached: (from: number, to: number) => Promise<ISequencedDocumentMessage[]>,\n private readonly requestFromSocket: (from: number, to: number) => void,\n private readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n ) {\n }\n\n protected validateMessages(reason: string, messages: ISequencedDocumentMessage[], from: number) {\n if (messages.length !== 0) {\n const start = messages[0].sequenceNumber;\n const length = messages.length;\n const last = messages[length - 1].sequenceNumber;\n if (start !== from) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n messages.length = 0;\n }\n if (last + 1 !== from + length) {\n this.logger.sendErrorEvent({ eventName: \"OpsFetchViolation\", reason, from, start, last, length });\n // we can do better here by finding consecutive sub-block and return it\n messages.length = 0;\n }\n }\n }\n\n public fetchMessages(\n fromTotal: number,\n toTotal: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n fetchReason?: string) {\n // We do not control what's in the cache. Current API assumes that fetchMessages() keeps banging on\n // storage / cache until it gets ops it needs. This would result in deadlock if fixed range is asked from\n // cache and it's not there.\n // Better implementation would be to return only what we have in cache, but that also breaks API\n assert(!cachedOnly || toTotal === undefined, 0x1e3);\n\n let opsFromSnapshot = 0;\n let opsFromCache = 0;\n let opsFromStorage = 0;\n\n const requestCallback = async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n if (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n const messages = this.snapshotOps.filter((op) =>\n op.sequenceNumber >= from && op.sequenceNumber < to);\n this.validateMessages(\"cached\", messages, from);\n if (messages.length > 0 && messages[0].sequenceNumber === from) {\n this.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n opsFromSnapshot = messages.length;\n return { messages, partialResult: true };\n }\n this.snapshotOps = undefined;\n }\n\n // Kick out request to PUSH for ops if it has them\n this.requestFromSocket(from, to);\n\n // Cache in normal flow is continuous. Once there is a miss, stop consulting cache.\n // This saves a bit of processing time\n if (from < this.firstCacheMiss) {\n const messagesFromCache = await this.getCached(from, to);\n this.validateMessages(\"cached\", messagesFromCache, from);\n if (messagesFromCache.length !== 0) {\n opsFromCache += messagesFromCache.length;\n return {\n messages: messagesFromCache,\n partialResult: true,\n };\n }\n this.firstCacheMiss = Math.min(this.firstCacheMiss, from);\n }\n\n if (cachedOnly) {\n return { messages: [], partialResult: false };\n }\n\n const ops = await this.getFromStorage(from, to, telemetryProps, fetchReason);\n this.validateMessages(\"storage\", ops.messages, from);\n opsFromStorage += ops.messages.length;\n this.opsReceived(ops.messages);\n return ops;\n };\n\n const stream = requestOps(\n async (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n const result = await requestCallback(from, to, telemetryProps);\n // Catch all case, just in case\n this.validateMessages(\"catch all\", result.messages, from);\n return result;\n },\n // Staging: starting with no concurrency, listening for feedback first.\n // In future releases we will switch to actual concurrency\n this.concurrency,\n fromTotal, // inclusive\n toTotal, // exclusive\n this.batchSize,\n this.logger,\n abortSignal,\n fetchReason,\n );\n\n return streamObserver(stream, (result) => {\n if (result.done && opsFromSnapshot + opsFromCache + opsFromStorage !== 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"CacheOpsRetrieved\",\n opsFromSnapshot,\n opsFromCache,\n opsFromStorage,\n });\n }\n });\n }\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/odsp-driver";
|
|
8
|
-
export declare const pkgVersion = "1.
|
|
8
|
+
export declare const pkgVersion = "1.3.0-100520";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,gCAAgC,CAAC;AACrD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"1.3.0-100520\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/odsp-driver",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-100520",
|
|
4
4
|
"description": "Socket storage implementation for SPO and ODC",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -62,16 +62,16 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
64
64
|
"@fluidframework/common-utils": "^0.32.1",
|
|
65
|
-
"@fluidframework/core-interfaces": "
|
|
66
|
-
"@fluidframework/driver-base": "
|
|
67
|
-
"@fluidframework/driver-definitions": "
|
|
68
|
-
"@fluidframework/driver-utils": "
|
|
65
|
+
"@fluidframework/core-interfaces": "1.3.0-100520",
|
|
66
|
+
"@fluidframework/driver-base": "1.3.0-100520",
|
|
67
|
+
"@fluidframework/driver-definitions": "1.3.0-100520",
|
|
68
|
+
"@fluidframework/driver-utils": "1.3.0-100520",
|
|
69
69
|
"@fluidframework/gitresources": "^0.1036.5000",
|
|
70
|
-
"@fluidframework/odsp-doclib-utils": "
|
|
71
|
-
"@fluidframework/odsp-driver-definitions": "
|
|
70
|
+
"@fluidframework/odsp-doclib-utils": "1.3.0-100520",
|
|
71
|
+
"@fluidframework/odsp-driver-definitions": "1.3.0-100520",
|
|
72
72
|
"@fluidframework/protocol-base": "^0.1036.5000",
|
|
73
73
|
"@fluidframework/protocol-definitions": "^0.1028.2000",
|
|
74
|
-
"@fluidframework/telemetry-utils": "
|
|
74
|
+
"@fluidframework/telemetry-utils": "1.3.0-100520",
|
|
75
75
|
"abort-controller": "^3.0.0",
|
|
76
76
|
"node-fetch": "^2.6.1",
|
|
77
77
|
"socket.io-client": "^4.4.1",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"@fluidframework/build-common": "^0.24.0",
|
|
82
82
|
"@fluidframework/build-tools": "^0.2.74327",
|
|
83
83
|
"@fluidframework/eslint-config-fluid": "^0.28.2000",
|
|
84
|
-
"@fluidframework/mocha-test-setup": "
|
|
85
|
-
"@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver
|
|
84
|
+
"@fluidframework/mocha-test-setup": "1.3.0-100520",
|
|
85
|
+
"@fluidframework/odsp-driver-previous": "npm:@fluidframework/odsp-driver@^1.2.0",
|
|
86
86
|
"@microsoft/api-extractor": "^7.22.2",
|
|
87
87
|
"@rushstack/eslint-config": "^2.5.1",
|
|
88
88
|
"@types/mocha": "^9.1.1",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"typescript-formatter": "7.1.0"
|
|
101
101
|
},
|
|
102
102
|
"typeValidation": {
|
|
103
|
-
"version": "1.
|
|
103
|
+
"version": "1.3.0",
|
|
104
104
|
"broken": {}
|
|
105
105
|
}
|
|
106
106
|
}
|
|
@@ -81,11 +81,9 @@ function readTreeSection(node: NodeCore) {
|
|
|
81
81
|
if (records.value !== undefined) {
|
|
82
82
|
assertBlobCoreInstance(records.value, "Blob value should be BlobCore");
|
|
83
83
|
snapshotTree.blobs[path] = records.value.toString();
|
|
84
|
-
} else
|
|
84
|
+
} else {
|
|
85
85
|
assertNodeCoreInstance(records.children, "Trees should be of type NodeCore");
|
|
86
86
|
snapshotTree.trees[path] = readTreeSection(records.children);
|
|
87
|
-
} else {
|
|
88
|
-
snapshotTree.trees[path] = { blobs: {}, commits: {}, trees: {} };
|
|
89
87
|
}
|
|
90
88
|
if (records.unreferenced !== undefined) {
|
|
91
89
|
assertBoolInstance(records.unreferenced, "Unreferenced flag should be bool");
|
|
@@ -60,12 +60,9 @@ function writeTreeSectionCore(treesNode: NodeCore, snapshotTree: ISnapshotTree)
|
|
|
60
60
|
if (snapshotTree.unreferenced) {
|
|
61
61
|
addBoolProperty(treeNode, "unreferenced", snapshotTree.unreferenced);
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const childNode = treeNode.addNode("list");
|
|
67
|
-
writeTreeSectionCore(childNode, value);
|
|
68
|
-
}
|
|
63
|
+
treeNode.addString("children", true);
|
|
64
|
+
const childNode = treeNode.addNode("list");
|
|
65
|
+
writeTreeSectionCore(childNode, value);
|
|
69
66
|
}
|
|
70
67
|
|
|
71
68
|
if (snapshotTree.blobs) {
|
package/src/fetchSnapshot.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
InstrumentedStorageTokenFetcher,
|
|
17
17
|
} from "@fluidframework/odsp-driver-definitions";
|
|
18
18
|
import { ISnapshotTree } from "@fluidframework/protocol-definitions";
|
|
19
|
-
import { isRuntimeMessage, NonRetryableError } from "@fluidframework/driver-utils";
|
|
19
|
+
import { DriverErrorTelemetryProps, isRuntimeMessage, NonRetryableError } from "@fluidframework/driver-utils";
|
|
20
20
|
import { IOdspSnapshot, ISnapshotCachedEntry, IVersionedValueWithEpoch, persistedCacheValueVersion } from "./contracts";
|
|
21
21
|
import { getQueryString } from "./getQueryString";
|
|
22
22
|
import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
|
|
@@ -234,26 +234,30 @@ async function fetchLatestSnapshotCore(
|
|
|
234
234
|
snapshotOptions,
|
|
235
235
|
controller,
|
|
236
236
|
);
|
|
237
|
+
|
|
237
238
|
const odspResponse = response.odspResponse;
|
|
238
239
|
const contentType = odspResponse.headers.get("content-type");
|
|
239
|
-
|
|
240
|
+
|
|
241
|
+
// Measure how much time we spend processing payload
|
|
242
|
+
const snapshotParseEvent = PerformanceEvent.start(logger, {
|
|
243
|
+
eventName: "SnapshotParse",
|
|
244
|
+
driverVersion: pkgVersion,
|
|
245
|
+
contentType,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const propsToLog: DriverErrorTelemetryProps = {
|
|
240
249
|
...odspResponse.propsToLog,
|
|
241
250
|
contentType,
|
|
242
251
|
accept: response.requestHeaders.accept,
|
|
252
|
+
driverVersion: pkgVersion,
|
|
243
253
|
};
|
|
244
254
|
let parsedSnapshotContents: IOdspResponse<ISnapshotContents> | undefined;
|
|
245
|
-
let contentTypeToRead: string | undefined;
|
|
246
|
-
if (contentType?.indexOf("application/ms-fluid") !== -1) {
|
|
247
|
-
contentTypeToRead = "application/ms-fluid";
|
|
248
|
-
} else if (contentType?.indexOf("application/json") !== -1) {
|
|
249
|
-
contentTypeToRead = "application/json";
|
|
250
|
-
}
|
|
251
255
|
|
|
252
256
|
try {
|
|
253
|
-
switch (
|
|
257
|
+
switch (contentType) {
|
|
254
258
|
case "application/json": {
|
|
255
259
|
const text = await odspResponse.content.text();
|
|
256
|
-
|
|
260
|
+
propsToLog.bodySize = text.length;
|
|
257
261
|
const content: IOdspSnapshot = JSON.parse(text);
|
|
258
262
|
validateBlobsAndTrees(content);
|
|
259
263
|
const snapshotContents: ISnapshotContents =
|
|
@@ -263,7 +267,7 @@ async function fetchLatestSnapshotCore(
|
|
|
263
267
|
}
|
|
264
268
|
case "application/ms-fluid": {
|
|
265
269
|
const content = await odspResponse.content.arrayBuffer();
|
|
266
|
-
|
|
270
|
+
propsToLog.bodySize = content.byteLength;
|
|
267
271
|
const snapshotContents: ISnapshotContents = parseCompactSnapshotResponse(
|
|
268
272
|
new ReadBuffer(new Uint8Array(content)));
|
|
269
273
|
if (snapshotContents.snapshotTree.trees === undefined ||
|
|
@@ -271,7 +275,7 @@ async function fetchLatestSnapshotCore(
|
|
|
271
275
|
throw new NonRetryableError(
|
|
272
276
|
"Returned odsp snapshot is malformed. No trees or blobs!",
|
|
273
277
|
DriverErrorType.incorrectServerResponse,
|
|
274
|
-
|
|
278
|
+
propsToLog,
|
|
275
279
|
);
|
|
276
280
|
}
|
|
277
281
|
parsedSnapshotContents = { ...odspResponse, content: snapshotContents };
|
|
@@ -281,12 +285,12 @@ async function fetchLatestSnapshotCore(
|
|
|
281
285
|
throw new NonRetryableError(
|
|
282
286
|
"Unknown snapshot content type",
|
|
283
287
|
DriverErrorType.incorrectServerResponse,
|
|
284
|
-
|
|
288
|
+
propsToLog,
|
|
285
289
|
);
|
|
286
290
|
}
|
|
287
291
|
} catch (error) {
|
|
288
292
|
if (isFluidError(error)) {
|
|
289
|
-
error.addTelemetryProperties(
|
|
293
|
+
error.addTelemetryProperties(propsToLog);
|
|
290
294
|
throw error;
|
|
291
295
|
}
|
|
292
296
|
const enhancedError = wrapError(
|
|
@@ -294,11 +298,14 @@ async function fetchLatestSnapshotCore(
|
|
|
294
298
|
(errorMessage) => new NonRetryableError(
|
|
295
299
|
`Error parsing snapshot response: ${errorMessage}`,
|
|
296
300
|
DriverErrorType.genericError,
|
|
297
|
-
|
|
301
|
+
propsToLog));
|
|
298
302
|
throw enhancedError;
|
|
299
303
|
}
|
|
304
|
+
|
|
300
305
|
assert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);
|
|
301
306
|
const snapshot = parsedSnapshotContents.content;
|
|
307
|
+
const { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);
|
|
308
|
+
|
|
302
309
|
// From: https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
|
|
303
310
|
// fetchStart: immediately before the browser starts to fetch the resource.
|
|
304
311
|
// requestStart: immediately before the browser starts requesting the resource from the server
|
|
@@ -351,9 +358,6 @@ async function fetchLatestSnapshotCore(
|
|
|
351
358
|
}
|
|
352
359
|
}
|
|
353
360
|
|
|
354
|
-
const { numTrees, numBlobs, encodedBlobsSize } =
|
|
355
|
-
evalBlobsAndTrees(parsedSnapshotContents.content);
|
|
356
|
-
|
|
357
361
|
// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we
|
|
358
362
|
// cannot cache using an HTTP response header.
|
|
359
363
|
const canCache =
|
|
@@ -382,8 +386,11 @@ async function fetchLatestSnapshotCore(
|
|
|
382
386
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
383
387
|
putInCache(valueWithEpoch);
|
|
384
388
|
}
|
|
389
|
+
|
|
390
|
+
snapshotParseEvent.end();
|
|
391
|
+
|
|
385
392
|
event.end({
|
|
386
|
-
trees
|
|
393
|
+
trees,
|
|
387
394
|
blobs: snapshot.blobs?.size ?? 0,
|
|
388
395
|
leafNodes: numBlobs,
|
|
389
396
|
encodedBlobsSize,
|
|
@@ -413,7 +420,7 @@ async function fetchLatestSnapshotCore(
|
|
|
413
420
|
// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate
|
|
414
421
|
// if the permission has changed.
|
|
415
422
|
sltelemetry: odspResponse.headers.get("x-fluid-sltelemetry"),
|
|
416
|
-
...
|
|
423
|
+
...propsToLog,
|
|
417
424
|
});
|
|
418
425
|
return snapshot;
|
|
419
426
|
},
|
|
@@ -473,13 +480,13 @@ function getFormBodyAndHeaders(
|
|
|
473
480
|
}
|
|
474
481
|
|
|
475
482
|
function evalBlobsAndTrees(snapshot: ISnapshotContents) {
|
|
476
|
-
const
|
|
483
|
+
const trees = countTreesInSnapshotTree(snapshot.snapshotTree);
|
|
477
484
|
const numBlobs = snapshot.blobs.size;
|
|
478
485
|
let encodedBlobsSize = 0;
|
|
479
486
|
for (const [_, blobContent] of snapshot.blobs) {
|
|
480
487
|
encodedBlobsSize += blobContent.byteLength;
|
|
481
488
|
}
|
|
482
|
-
return {
|
|
489
|
+
return { trees, numBlobs, encodedBlobsSize };
|
|
483
490
|
}
|
|
484
491
|
|
|
485
492
|
export function validateBlobsAndTrees(snapshot: IOdspSnapshot) {
|
|
@@ -542,12 +549,14 @@ export async function downloadSnapshot(
|
|
|
542
549
|
};
|
|
543
550
|
// Decide what snapshot format to fetch as per the feature gate.
|
|
544
551
|
switch (snapshotFormatFetchType) {
|
|
552
|
+
case SnapshotFormatSupportType.JsonAndBinary:
|
|
553
|
+
headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;
|
|
554
|
+
break;
|
|
545
555
|
case SnapshotFormatSupportType.Binary:
|
|
546
556
|
headers.accept = `application/ms-fluid; v=${currentReadVersion}`;
|
|
547
557
|
break;
|
|
548
558
|
default:
|
|
549
|
-
|
|
550
|
-
headers.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;
|
|
559
|
+
headers.accept = "application/json";
|
|
551
560
|
}
|
|
552
561
|
|
|
553
562
|
const odspResponse = await (epochTracker?.fetch(url, fetchOptions, "treesLatest", true, scenarioName) ??
|
package/src/getFileLink.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
|
-
import { assert
|
|
8
|
-
import { canRetryOnError,
|
|
7
|
+
import { assert } from "@fluidframework/common-utils";
|
|
8
|
+
import { canRetryOnError, NonRetryableError } from "@fluidframework/driver-utils";
|
|
9
9
|
import { PerformanceEvent } from "@fluidframework/telemetry-utils";
|
|
10
10
|
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
11
11
|
import {
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { getUrlAndHeadersWithAuth } from "./getUrlAndHeadersWithAuth";
|
|
18
18
|
import { fetchHelper, getWithRetryForTokenRefresh, toInstrumentedOdspTokenFetcher } from "./odspUtils";
|
|
19
19
|
import { pkgVersion as driverVersion } from "./packageVersion";
|
|
20
|
+
import { runWithRetry } from "./retryUtils";
|
|
20
21
|
|
|
21
22
|
// Store cached responses for the lifetime of web session as file link remains the same for given file item
|
|
22
23
|
const fileLinkCache = new Map<string, Promise<string>>();
|
|
@@ -47,33 +48,29 @@ export async function getFileLink(
|
|
|
47
48
|
return maybeFileLinkCacheEntry;
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
const
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
// If the error is throttling error, then wait for the specified time before retrying.
|
|
66
|
-
// If the waitTime is not specified, then we start with retrying immediately to max of 8s.
|
|
67
|
-
retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);
|
|
68
|
-
await delay(retryAfterMs);
|
|
51
|
+
const fileLinkGenerator = async function() {
|
|
52
|
+
let fileLinkCore: string;
|
|
53
|
+
try {
|
|
54
|
+
fileLinkCore = await runWithRetry(
|
|
55
|
+
async () => getFileLinkCore(getToken, odspUrlParts, identityType, logger),
|
|
56
|
+
"getFileLinkCore",
|
|
57
|
+
logger,
|
|
58
|
+
);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
// runWithRetry throws a non retriable error after it hits the max # of attempts
|
|
61
|
+
// or encounters an unexpected error type
|
|
62
|
+
if (!canRetryOnError(err)) {
|
|
63
|
+
// Delete from the cache to permit retrying later.
|
|
64
|
+
fileLinkCache.delete(cacheKey);
|
|
69
65
|
}
|
|
70
|
-
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
71
68
|
|
|
72
69
|
// We are guaranteed to run the getFileLinkCore at least once with successful result (which must be a string)
|
|
73
|
-
assert(
|
|
74
|
-
return
|
|
70
|
+
assert(fileLinkCore !== undefined, 0x292 /* "Unexpected undefined result from getFileLinkCore" */);
|
|
71
|
+
return fileLinkCore;
|
|
75
72
|
};
|
|
76
|
-
const fileLink =
|
|
73
|
+
const fileLink = fileLinkGenerator();
|
|
77
74
|
fileLinkCache.set(cacheKey, fileLink);
|
|
78
75
|
return fileLink;
|
|
79
76
|
}
|
|
@@ -89,7 +86,7 @@ async function getFileLinkCore(
|
|
|
89
86
|
// ODSP link requires extra call to return link that is resistant to file being renamed or moved to different folder
|
|
90
87
|
return PerformanceEvent.timedExecAsync(
|
|
91
88
|
logger,
|
|
92
|
-
{ eventName: "odspFileLink", requestName: "
|
|
89
|
+
{ eventName: "odspFileLink", requestName: "getSharingLink" },
|
|
93
90
|
async (event) => {
|
|
94
91
|
let attempts = 0;
|
|
95
92
|
let additionalProps;
|
|
@@ -106,8 +103,8 @@ async function getFileLinkCore(
|
|
|
106
103
|
0x2bb /* "Instrumented token fetcher with throwOnNullToken = true should never return null" */);
|
|
107
104
|
|
|
108
105
|
const { url, headers } = getUrlAndHeadersWithAuth(
|
|
109
|
-
`${odspUrlParts.siteUrl}/_api/web/
|
|
110
|
-
encodeURIComponent(`'${fileItem.webDavUrl}'`)
|
|
106
|
+
`${odspUrlParts.siteUrl}/_api/web/GetFileByServerRelativeUrl(@a1)/Linkingurl?@a1=${
|
|
107
|
+
encodeURIComponent(`'${new URL(fileItem.webDavUrl).pathname}'`)
|
|
111
108
|
}`,
|
|
112
109
|
storageToken,
|
|
113
110
|
false,
|
|
@@ -124,15 +121,15 @@ async function getFileLinkCore(
|
|
|
124
121
|
additionalProps = response.propsToLog;
|
|
125
122
|
|
|
126
123
|
const sharingInfo = await response.content.json();
|
|
127
|
-
const
|
|
128
|
-
if (typeof
|
|
124
|
+
const linkingUrl = sharingInfo?.d?.LinkingUrl;
|
|
125
|
+
if (typeof linkingUrl !== "string") {
|
|
129
126
|
// This will retry once in getWithRetryForTokenRefresh
|
|
130
127
|
throw new NonRetryableError(
|
|
131
|
-
"Malformed
|
|
128
|
+
"Malformed GetSharingLink response",
|
|
132
129
|
DriverErrorType.incorrectServerResponse,
|
|
133
130
|
{ driverVersion });
|
|
134
131
|
}
|
|
135
|
-
return
|
|
132
|
+
return linkingUrl;
|
|
136
133
|
});
|
|
137
134
|
event.end({ ...additionalProps, attempts });
|
|
138
135
|
return fileLink;
|
|
@@ -35,13 +35,14 @@ export class OdspDeltaStorageService {
|
|
|
35
35
|
* @param from - inclusive
|
|
36
36
|
* @param to - exclusive
|
|
37
37
|
* @param telemetryProps - properties to add when issuing telemetry events
|
|
38
|
+
* @param scenarioName - reason for fetching ops
|
|
38
39
|
* @returns ops retrieved & info if result was partial (i.e. more is available)
|
|
39
40
|
*/
|
|
40
41
|
public async get(
|
|
41
42
|
from: number,
|
|
42
43
|
to: number,
|
|
43
44
|
telemetryProps: ITelemetryProperties,
|
|
44
|
-
|
|
45
|
+
scenarioName?: string,
|
|
45
46
|
): Promise<IDeltasFetchResult> {
|
|
46
47
|
return getWithRetryForTokenRefresh(async (options) => {
|
|
47
48
|
// Note - this call ends up in getSocketStorageDiscovery() and can refresh token
|
|
@@ -78,7 +79,7 @@ export class OdspDeltaStorageService {
|
|
|
78
79
|
},
|
|
79
80
|
"ops",
|
|
80
81
|
true,
|
|
81
|
-
|
|
82
|
+
scenarioName,
|
|
82
83
|
);
|
|
83
84
|
clearTimeout(timer);
|
|
84
85
|
const deltaStorageResponse = response.content;
|
|
@@ -99,6 +100,7 @@ export class OdspDeltaStorageService {
|
|
|
99
100
|
from,
|
|
100
101
|
to,
|
|
101
102
|
...telemetryProps,
|
|
103
|
+
reason: scenarioName,
|
|
102
104
|
});
|
|
103
105
|
|
|
104
106
|
// It is assumed that server always returns all the ops that it has in the range that was requested.
|
package/src/packageVersion.ts
CHANGED